]> Git Repo - linux.git/commitdiff
perf symbol: Skip symbols if SHF_ALLOC flag is not set
authorLeo Yan <[email protected]>
Sun, 24 Jul 2022 06:00:13 +0000 (14:00 +0800)
committerArnaldo Carvalho de Melo <[email protected]>
Wed, 27 Jul 2022 14:17:50 +0000 (11:17 -0300)
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]>
tools/perf/util/symbol-elf.c

index ef6ced5c5746af908d15662db7b83aafaf1b58ee..b3be5b1d9dbb00bcde88661bdb7e03a2505d2ca8 100644 (file)
@@ -1255,6 +1255,17 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss,
 
                gelf_getshdr(sec, &shdr);
 
+               /*
+                * If the attribute bit SHF_ALLOC is not set, the section
+                * doesn't occupy memory during process execution.
+                * E.g. ".gnu.warning.*" section is used by linker to generate
+                * warnings when calling deprecated functions, the symbols in
+                * the section aren't loaded to memory during process execution,
+                * so skip them.
+                */
+               if (!(shdr.sh_flags & SHF_ALLOC))
+                       continue;
+
                secstrs = secstrs_sym;
 
                /*
This page took 0.06162 seconds and 4 git commands to generate.