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 10, 2023
1 parent 2f65278 commit feec716
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 @@ -69,6 +69,16 @@ struct bpf_map_def array_of_hash_map __section("maps") = {
.max_entries = 2,
};

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");

static int __attribute__((noinline)) __section("static") static_fn(uint32_t arg) {
return arg - 1;
}
Expand Down

0 comments on commit feec716

Please sign in to comment.