Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf symbol-elf: Decode dynsym even if symtab exists

In Fedora34, libc-2.33.so has both .dynsym and .symtab sections and
most of (not all) symbols moved to .dynsym. In this case, perf only
decode the symbols in .symtab, and perf probe can not list up the
functions in the library.

To fix this issue, decode both .symtab and .dynsym sections.

Without this fix,
-----
$ ./perf probe -x /usr/lib64/libc-2.33.so -F
@plt
@plt
calloc@plt
free@plt
malloc@plt
memalign@plt
realloc@plt
-----

With this fix.

-----
$ ./perf probe -x /usr/lib64/libc-2.33.so -F
@plt
@plt
a64l
abort
abs
accept
accept4
access
acct
addmntent
-----

Reported-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Thomas Richter <tmricht@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Stefan Liebler <stli@linux.ibm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Link: http://lore.kernel.org/lkml/162532652681.393143.10163733179955267999.stgit@devnote2
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Masami Hiramatsu and committed by
Arnaldo Carvalho de Melo
87704345 eb4717f7

+54 -28
+54 -28
tools/perf/util/symbol-elf.c
··· 1074 1074 return 0; 1075 1075 } 1076 1076 1077 - int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, 1078 - struct symsrc *runtime_ss, int kmodule) 1077 + static int 1078 + dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss, 1079 + struct symsrc *runtime_ss, int kmodule, int dynsym) 1079 1080 { 1080 1081 struct kmap *kmap = dso->kernel ? map__kmap(map) : NULL; 1081 1082 struct maps *kmaps = kmap ? map__kmaps(map) : NULL; ··· 1099 1098 if (kmap && !kmaps) 1100 1099 return -1; 1101 1100 1102 - dso->symtab_type = syms_ss->type; 1103 - dso->is_64_bit = syms_ss->is_64_bit; 1104 - dso->rel = syms_ss->ehdr.e_type == ET_REL; 1105 - 1106 - /* 1107 - * Modules may already have symbols from kallsyms, but those symbols 1108 - * have the wrong values for the dso maps, so remove them. 1109 - */ 1110 - if (kmodule && syms_ss->symtab) 1111 - symbols__delete(&dso->symbols); 1112 - 1113 - if (!syms_ss->symtab) { 1114 - /* 1115 - * If the vmlinux is stripped, fail so we will fall back 1116 - * to using kallsyms. The vmlinux runtime symbols aren't 1117 - * of much use. 1118 - */ 1119 - if (dso->kernel) 1120 - goto out_elf_end; 1121 - 1122 - syms_ss->symtab = syms_ss->dynsym; 1123 - syms_ss->symshdr = syms_ss->dynshdr; 1124 - } 1125 - 1126 1101 elf = syms_ss->elf; 1127 1102 ehdr = syms_ss->ehdr; 1128 - sec = syms_ss->symtab; 1129 - shdr = syms_ss->symshdr; 1103 + if (dynsym) { 1104 + sec = syms_ss->dynsym; 1105 + shdr = syms_ss->dynshdr; 1106 + } else { 1107 + sec = syms_ss->symtab; 1108 + shdr = syms_ss->symshdr; 1109 + } 1130 1110 1131 1111 if (elf_section_by_name(runtime_ss->elf, &runtime_ss->ehdr, &tshdr, 1132 1112 ".text", NULL)) ··· 1291 1309 } 1292 1310 err = nr; 1293 1311 out_elf_end: 1312 + return err; 1313 + } 1314 + 1315 + int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, 1316 + struct symsrc *runtime_ss, int kmodule) 1317 + { 1318 + int nr = 0; 1319 + int err = -1; 1320 + 1321 + dso->symtab_type = syms_ss->type; 1322 + dso->is_64_bit = syms_ss->is_64_bit; 1323 + dso->rel = syms_ss->ehdr.e_type == ET_REL; 1324 + 1325 + /* 1326 + * Modules may already have symbols from kallsyms, but those symbols 1327 + * have the wrong values for the dso maps, so remove them. 1328 + */ 1329 + if (kmodule && syms_ss->symtab) 1330 + symbols__delete(&dso->symbols); 1331 + 1332 + if (!syms_ss->symtab) { 1333 + /* 1334 + * If the vmlinux is stripped, fail so we will fall back 1335 + * to using kallsyms. The vmlinux runtime symbols aren't 1336 + * of much use. 1337 + */ 1338 + if (dso->kernel) 1339 + return err; 1340 + } else { 1341 + err = dso__load_sym_internal(dso, map, syms_ss, runtime_ss, 1342 + kmodule, 0); 1343 + if (err < 0) 1344 + return err; 1345 + nr = err; 1346 + } 1347 + 1348 + if (syms_ss->dynsym) { 1349 + err = dso__load_sym_internal(dso, map, syms_ss, runtime_ss, 1350 + kmodule, 1); 1351 + if (err < 0) 1352 + return err; 1353 + err += nr; 1354 + } 1355 + 1294 1356 return err; 1295 1357 } 1296 1358