'The def fields are zeros for my ebpf map in the ebpf obj file
I am playing a simple ebpf with the map definition as follows:
struct event {
char comm[TASK_COMM_LEN];
pid_t pid;
uid_t uid;
};
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, 128);
__type(key, pid_t);
__type(value, struct event);
} execs_1 SEC(".maps");
when I load the corresponding elf obj file using https://elixir.bootlin.com/linux/v4.14.2/source/samples/bpf/bpf_load.c, I saw correct map name as 'execs_1'. But when I was trying to get the map definition, all fields are just zero. See line 421 in the link. Basically, I am curious the bpf info kept in the corresponding elf obj file. I checked the corresponding code https://github.com/torvalds/linux/blob/master/tools/lib/bpf/libbpf.c at line 2026. It seems that there is no diff. Any comments on how to get the field info of the map from elf bpf object file:
struct bpf_map_def {
unsigned int type;
unsigned int key_size;
unsigned int value_size;
unsigned int max_entries;
unsigned int map_flags;
unsigned int inner_map_idx;
unsigned int numa_node;
};
Thanks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
