]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.29/perf-symbols-filter-out-hidden-symbols-from-labels.patch
fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.19.29 / perf-symbols-filter-out-hidden-symbols-from-labels.patch
CommitLineData
7748c0ed
SL
1From b99ebfceb8ad3217c446df0c2594f49e36d56ad7 Mon Sep 17 00:00:00 2001
2From: Jiri Olsa <jolsa@redhat.com>
3Date: Mon, 28 Jan 2019 14:35:26 +0100
4Subject: perf symbols: Filter out hidden symbols from labels
5
6[ Upstream commit 59a17706915fe5ea6f711e1f92d4fb706bce07fe ]
7
8When perf is built with the annobin plugin (RHEL8 build) extra symbols
9are 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
24Those symbols have no use for report or annotation and should be
25skipped. Moreover they interfere with the DWARF unwind test on the PPC
26arch, 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
37The 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
42They can still pass the check for the label symbol. Adding check for
43HIDDEN and INTERNAL (as suggested by Nick below) visibility and filter
44out 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
51Signed-off-by: Jiri Olsa <jolsa@kernel.org>
52Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
53Cc: Masami Hiramatsu <mhiramat@kernel.org>
54Cc: Michael Petlan <mpetlan@redhat.com>
55Cc: Namhyung Kim <namhyung@kernel.org>
56Cc: Nick Clifton <nickc@redhat.com>
57Cc: Peter Zijlstra <peterz@infradead.org>
58Link: http://lkml.kernel.org/r/20190128133526.GD15461@krava
59Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
60Signed-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
65diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
66index 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--
932.19.1
94