Skip to content

Commit

Permalink
Tag ELF files with platform specific section (#3969)
Browse files Browse the repository at this point in the history
Compiling against Windows eBPF headers produces object files which are not easily
distinguishable from object files compiled against Linux headers. This is a problem
for cross-platform tooling which wishes to inspect the contents of an ELF.

Emit a section .ebpf_for_windows with the contents 0x01 into ELFs compiled against
the windows headers.

Updates #3956
  • Loading branch information
lmb authored Nov 5, 2024
1 parent a3edec5 commit 5c2cb9a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/bpf_helpers_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
* @brief This file contains platform specific defines used by eBPF programs.
*/

#include <stdbool.h>
#include <stdint.h>

// For eBPF programs, struct bpf_map means struct _ebpf_map_definition_in_file,
// since they use inner_map_idx and pass pointers to such structures to the various
// map APIs.
#define bpf_map _ebpf_map_definition_in_file

#if !defined(_MSC_VER)
const bool __ebpf_for_windows_tag __attribute__((section(".ebpf_for_windows"))) = true;
#endif

// Type aliases used by libbpf headers.
typedef int32_t __s32;
typedef int64_t __s64;
Expand Down

0 comments on commit 5c2cb9a

Please sign in to comment.