Skip to content

Commit

Permalink
elf: test BTF map typedef support
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenz Bauer <[email protected]>
  • Loading branch information
lmb committed Oct 3, 2023
1 parent af3b14e commit 16841c3
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions elf_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Binary file modified testdata/loader-clang-11-eb.elf
Binary file not shown.
Binary file modified testdata/loader-clang-11-el.elf
Binary file not shown.
Binary file modified testdata/loader-clang-14-eb.elf
Binary file not shown.
Binary file modified testdata/loader-clang-14-el.elf
Binary file not shown.
Binary file modified testdata/loader-clang-17-eb.elf
Binary file not shown.
Binary file modified testdata/loader-clang-17-el.elf
Binary file not shown.
10 changes: 10 additions & 0 deletions testdata/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 16841c3

Please sign in to comment.