btf_encoder: Ignore zero-sized ELF symbols
It's legal for ELF symbol to have size 0, if it's size is unknown or unspecified. Instead of erroring out, just ignore such symbols, as they can't be a valid per-CPU variable anyways. Reported-by: Érico Rolim <erico.erc@gmail.com> Reported-by: Jiri Slaby <jirislaby@kernel.org> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Tested-by: Jiri Slaby <jirislaby@kernel.org> Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1177921 Cc: bpf@vger.kernel.org Cc: dwarves@vger.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
040fd7f585
commit
8cac1c54c8
@ -287,6 +287,10 @@ static int find_all_percpu_vars(struct btf_elf *btfe)
|
||||
if (!addr)
|
||||
continue;
|
||||
|
||||
size = elf_sym__size(&sym);
|
||||
if (!size)
|
||||
continue; /* ignore zero-sized symbols */
|
||||
|
||||
sym_name = elf_sym__name(&sym, btfe->symtab);
|
||||
if (!btf_name_valid(sym_name)) {
|
||||
dump_invalid_symbol("Found symbol of invalid name when encoding btf",
|
||||
@ -295,14 +299,6 @@ static int find_all_percpu_vars(struct btf_elf *btfe)
|
||||
continue;
|
||||
return -1;
|
||||
}
|
||||
size = elf_sym__size(&sym);
|
||||
if (!size) {
|
||||
dump_invalid_symbol("Found symbol of zero size when encoding btf",
|
||||
sym_name, btf_elf__verbose, btf_elf__force);
|
||||
if (btf_elf__force)
|
||||
continue;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (btf_elf__verbose)
|
||||
printf("Found per-CPU symbol '%s' at address 0x%lx\n", sym_name, addr);
|
||||
|
Loading…
Reference in New Issue
Block a user