All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf symbols: Ignore mapping symbols on riscv
@ 2025-04-09  2:51 ` Haibo Xu
  0 siblings, 0 replies; 8+ messages in thread
From: Haibo Xu @ 2025-04-09  2:51 UTC (permalink / raw)
  Cc: xiaobo55x, Haibo Xu, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	Liang, Kan, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti, Stephen Brennan, linux-perf-users, linux-kernel,
	linux-riscv

RISCV ELF use mapping symbols with special names $x, $d to
identify regions of RISCV code or code with different ISAs[1].
These symbols don't identify functions, so will confuse the
perf output.

The patch filters out these symbols at load time, similar to
"4886f2ca perf symbols: Ignore mapping symbols on aarch64".

[1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/
    master/riscv-elf.adoc#mapping-symbol

Signed-off-by: Haibo Xu <haibo1.xu@intel.com>
---
 tools/perf/util/symbol-elf.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index fbf6d0f73af9..55b1409b0593 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -1733,6 +1733,12 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss,
 				continue;
 		}
 
+		/* Reject RISCV ELF "mapping symbols" */
+		if (ehdr.e_machine == EM_RISCV) {
+			if (elf_name[0] == '$' && strchr("dx", elf_name[1]))
+				continue;
+		}
+
 		if (runtime_ss->opdsec && sym.st_shndx == runtime_ss->opdidx) {
 			u32 offset = sym.st_value - syms_ss->opdshdr.sh_addr;
 			u64 *opd = opddata->d_buf + offset;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-06-02 22:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-09  2:51 [PATCH] perf symbols: Ignore mapping symbols on riscv Haibo Xu
2025-04-09  2:51 ` Haibo Xu
2025-04-11  0:53 ` Namhyung Kim
2025-04-11  0:53   ` Namhyung Kim
2025-05-19  8:13   ` Haibo Xu
2025-05-19  8:13     ` Haibo Xu
2025-06-02 22:12 ` patchwork-bot+linux-riscv
2025-06-02 22:12   ` patchwork-bot+linux-riscv

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.