Skip to content

Commit 882528d

Browse files
Leo Yanacmel
authored andcommitted
perf symbol: Skip symbols if SHF_ALLOC flag is not set
Some symbols are observed with the 'st_value' field zeroed. E.g. libc.so.6 in Ubuntu contains a symbol '__evoke_link_warning_getwd' which resides in the '.gnu.warning.getwd' section. Unlike normal sections, such kind of sections are used for linker warning when a file calls deprecated functions, but they are not part of memory images, the symbols in these sections should be dropped. This patch checks the section attribute SHF_ALLOC bit, if the bit is not set, it skips symbols to avoid spurious ones. Suggested-by: Fangrui Song <[email protected]> Signed-off-by: Leo Yan <[email protected]> Acked-by: Namhyung Kim <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Chang Rui <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 2d86612 commit 882528d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tools/perf/util/symbol-elf.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,17 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss,
12551255

12561256
gelf_getshdr(sec, &shdr);
12571257

1258+
/*
1259+
* If the attribute bit SHF_ALLOC is not set, the section
1260+
* doesn't occupy memory during process execution.
1261+
* E.g. ".gnu.warning.*" section is used by linker to generate
1262+
* warnings when calling deprecated functions, the symbols in
1263+
* the section aren't loaded to memory during process execution,
1264+
* so skip them.
1265+
*/
1266+
if (!(shdr.sh_flags & SHF_ALLOC))
1267+
continue;
1268+
12581269
secstrs = secstrs_sym;
12591270

12601271
/*

0 commit comments

Comments
 (0)