]>
Commit | Line | Data |
---|---|---|
7748c0ed SL |
1 | From b99ebfceb8ad3217c446df0c2594f49e36d56ad7 Mon Sep 17 00:00:00 2001 |
2 | From: Jiri Olsa <jolsa@redhat.com> | |
3 | Date: Mon, 28 Jan 2019 14:35:26 +0100 | |
4 | Subject: perf symbols: Filter out hidden symbols from labels | |
5 | ||
6 | [ Upstream commit 59a17706915fe5ea6f711e1f92d4fb706bce07fe ] | |
7 | ||
8 | When perf is built with the annobin plugin (RHEL8 build) extra symbols | |
9 | are added to its binary: | |
10 | ||
11 | # nm perf | grep annobin | head -10 | |
12 | 0000000000241100 t .annobin_annotate.c | |
13 | 0000000000326490 t .annobin_annotate.c | |
14 | 0000000000249255 t .annobin_annotate.c_end | |
15 | 00000000003283a8 t .annobin_annotate.c_end | |
16 | 00000000001bce18 t .annobin_annotate.c_end.hot | |
17 | 00000000001bce18 t .annobin_annotate.c_end.hot | |
18 | 00000000001bc3e2 t .annobin_annotate.c_end.unlikely | |
19 | 00000000001bc400 t .annobin_annotate.c_end.unlikely | |
20 | 00000000001bce18 t .annobin_annotate.c.hot | |
21 | 00000000001bce18 t .annobin_annotate.c.hot | |
22 | ... | |
23 | ||
24 | Those symbols have no use for report or annotation and should be | |
25 | skipped. Moreover they interfere with the DWARF unwind test on the PPC | |
26 | arch, where they are mixed with checked symbols and then the test fails: | |
27 | ||
28 | # perf test dwarf -v | |
29 | 59: Test dwarf unwind : | |
30 | --- start --- | |
31 | test child forked, pid 8515 | |
32 | unwind: .annobin_dwarf_unwind.c:ip = 0x10dba40dc (0x2740dc) | |
33 | ... | |
34 | got: .annobin_dwarf_unwind.c 0x10dba40dc, expecting test__arch_unwind_sample | |
35 | unwind: failed with 'no error' | |
36 | ||
37 | The annobin symbols are defined as NOTYPE/LOCAL/HIDDEN: | |
38 | ||
39 | # readelf -s ./perf | grep annobin | head -1 | |
40 | 40: 00000000001bce4f 0 NOTYPE LOCAL HIDDEN 13 .annobin_init.c | |
41 | ||
42 | They can still pass the check for the label symbol. Adding check for | |
43 | HIDDEN and INTERNAL (as suggested by Nick below) visibility and filter | |
44 | out such symbols. | |
45 | ||
46 | > Just to be awkward, if you are going to ignore STV_HIDDEN | |
47 | > symbols then you should probably also ignore STV_INTERNAL ones | |
48 | > as well... Annobin does not generate them, but you never know, | |
49 | > one day some other tool might create some. | |
50 | ||
51 | Signed-off-by: Jiri Olsa <jolsa@kernel.org> | |
52 | Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> | |
53 | Cc: Masami Hiramatsu <mhiramat@kernel.org> | |
54 | Cc: Michael Petlan <mpetlan@redhat.com> | |
55 | Cc: Namhyung Kim <namhyung@kernel.org> | |
56 | Cc: Nick Clifton <nickc@redhat.com> | |
57 | Cc: Peter Zijlstra <peterz@infradead.org> | |
58 | Link: http://lkml.kernel.org/r/20190128133526.GD15461@krava | |
59 | Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> | |
60 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
61 | --- | |
62 | tools/perf/util/symbol-elf.c | 9 ++++++++- | |
63 | 1 file changed, 8 insertions(+), 1 deletion(-) | |
64 | ||
65 | diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c | |
66 | index 6e70cc00c161..a701a8a48f00 100644 | |
67 | --- a/tools/perf/util/symbol-elf.c | |
68 | +++ b/tools/perf/util/symbol-elf.c | |
69 | @@ -87,6 +87,11 @@ static inline uint8_t elf_sym__type(const GElf_Sym *sym) | |
70 | return GELF_ST_TYPE(sym->st_info); | |
71 | } | |
72 | ||
73 | +static inline uint8_t elf_sym__visibility(const GElf_Sym *sym) | |
74 | +{ | |
75 | + return GELF_ST_VISIBILITY(sym->st_other); | |
76 | +} | |
77 | + | |
78 | #ifndef STT_GNU_IFUNC | |
79 | #define STT_GNU_IFUNC 10 | |
80 | #endif | |
81 | @@ -111,7 +116,9 @@ static inline int elf_sym__is_label(const GElf_Sym *sym) | |
82 | return elf_sym__type(sym) == STT_NOTYPE && | |
83 | sym->st_name != 0 && | |
84 | sym->st_shndx != SHN_UNDEF && | |
85 | - sym->st_shndx != SHN_ABS; | |
86 | + sym->st_shndx != SHN_ABS && | |
87 | + elf_sym__visibility(sym) != STV_HIDDEN && | |
88 | + elf_sym__visibility(sym) != STV_INTERNAL; | |
89 | } | |
90 | ||
91 | static bool elf_sym__filter(GElf_Sym *sym) | |
92 | -- | |
93 | 2.19.1 | |
94 |