diff --git a/elf_reader_test.go b/elf_reader_test.go index c7271b823..be2fead55 100644 --- a/elf_reader_test.go +++ b/elf_reader_test.go @@ -90,6 +90,12 @@ func TestLoadCollectionSpec(t *testing.T) { MaxEntries: 1, }, }, + "btf_typedef_map": { + Type: Array, + KeySize: 4, + ValueSize: 4, + MaxEntries: 1, + }, }, Programs: map[string]*ProgramSpec{ "xdp_prog": { diff --git a/testdata/loader-clang-11-eb.elf b/testdata/loader-clang-11-eb.elf index 8961f8a37..fe483874e 100644 Binary files a/testdata/loader-clang-11-eb.elf and b/testdata/loader-clang-11-eb.elf differ diff --git a/testdata/loader-clang-11-el.elf b/testdata/loader-clang-11-el.elf index 1c3479f7e..1c38d4943 100644 Binary files a/testdata/loader-clang-11-el.elf and b/testdata/loader-clang-11-el.elf differ diff --git a/testdata/loader-clang-14-eb.elf b/testdata/loader-clang-14-eb.elf index 9b05b0519..1755bd04d 100644 Binary files a/testdata/loader-clang-14-eb.elf and b/testdata/loader-clang-14-eb.elf differ diff --git a/testdata/loader-clang-14-el.elf b/testdata/loader-clang-14-el.elf index 0e8fc9d06..f8a9b0b80 100644 Binary files a/testdata/loader-clang-14-el.elf and b/testdata/loader-clang-14-el.elf differ diff --git a/testdata/loader-clang-17-eb.elf b/testdata/loader-clang-17-eb.elf index 9b05b0519..1755bd04d 100644 Binary files a/testdata/loader-clang-17-eb.elf and b/testdata/loader-clang-17-eb.elf differ diff --git a/testdata/loader-clang-17-el.elf b/testdata/loader-clang-17-el.elf index 0e8fc9d06..f8a9b0b80 100644 Binary files a/testdata/loader-clang-17-el.elf and b/testdata/loader-clang-17-el.elf differ diff --git a/testdata/loader.c b/testdata/loader.c index 1a0f0f6b8..d49a2c5fe 100644 --- a/testdata/loader.c +++ b/testdata/loader.c @@ -64,6 +64,16 @@ struct { __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY); __uint(max_entries, 4096); } perf_event_array __section(".maps"); + +typedef struct { + __uint(type, BPF_MAP_TYPE_ARRAY); + __uint(key_size, sizeof(uint32_t)); + __uint(value_size, sizeof(uint64_t)); + __uint(max_entries, 1); +} array_map_t; + +// Map definition behind a typedef. +array_map_t btf_typedef_map __section(".maps"); #else struct bpf_map_def hash_map __section("maps") = { .type = BPF_MAP_TYPE_HASH,