Skip to content

Commit 4d63192

Browse files
xiaobo55xpalmer-dabbelt
authored andcommitted
perf symbols: Ignore mapping symbols on 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 <[email protected]> Acked-by: Namhyung Kim <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Ghiti <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 9eb9ea3 commit 4d63192

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tools/perf/util/symbol-elf.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,12 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss,
17331733
continue;
17341734
}
17351735

1736+
/* Reject RISCV ELF "mapping symbols" */
1737+
if (ehdr.e_machine == EM_RISCV) {
1738+
if (elf_name[0] == '$' && strchr("dx", elf_name[1]))
1739+
continue;
1740+
}
1741+
17361742
if (runtime_ss->opdsec && sym.st_shndx == runtime_ss->opdidx) {
17371743
u32 offset = sym.st_value - syms_ss->opdshdr.sh_addr;
17381744
u64 *opd = opddata->d_buf + offset;

0 commit comments

Comments
 (0)