Skip to content

Commit fe4d44b

Browse files
rgushchinborkmann
authored andcommitted
libbpf: prefer global symbols as bpf program name source
Libbpf picks the name of the first symbol in the corresponding elf section to use as a program name. But without taking symbol's scope into account it may end's up with some local label as a program name. E.g.: $ bpftool prog 1: type 15 name LBB0_10 tag 0390a5136ba23f5c loaded_at Dec 07/17:22 uid 0 xlated 456B not jited memlock 4096B Fix this by preferring global symbols as program name. For instance: $ bpftool prog 1: type 15 name bpf_prog1 tag 0390a5136ba23f5c loaded_at Dec 07/17:26 uid 0 xlated 456B not jited memlock 4096B Signed-off-by: Roman Gushchin <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Daniel Borkmann <[email protected]> Cc: Jakub Kicinski <[email protected]> Cc: Martin KaFai Lau <[email protected]> Cc: Quentin Monnet <[email protected]> Cc: David Ahern <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
1 parent 583c900 commit fe4d44b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tools/lib/bpf/libbpf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,8 @@ bpf_object__init_prog_names(struct bpf_object *obj)
387387
continue;
388388
if (sym.st_shndx != prog->idx)
389389
continue;
390+
if (GELF_ST_BIND(sym.st_info) != STB_GLOBAL)
391+
continue;
390392

391393
name = elf_strptr(obj->efile.elf,
392394
obj->efile.strtabidx,

0 commit comments

Comments
 (0)