Message ID | 20250409025202.201046-1-haibo1.xu@intel.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | perf symbols: Ignore mapping symbols on riscv | expand |
Context | Check | Description |
---|---|---|
bjorn/pre-ci_am | success | Success |
bjorn/build-rv32-defconfig | success | build-rv32-defconfig |
bjorn/build-rv64-clang-allmodconfig | success | build-rv64-clang-allmodconfig |
bjorn/build-rv64-gcc-allmodconfig | success | build-rv64-gcc-allmodconfig |
bjorn/build-rv64-nommu-k210-defconfig | success | build-rv64-nommu-k210-defconfig |
bjorn/build-rv64-nommu-k210-virt | success | build-rv64-nommu-k210-virt |
bjorn/checkpatch | success | checkpatch |
bjorn/dtb-warn-rv64 | success | dtb-warn-rv64 |
bjorn/header-inline | success | header-inline |
bjorn/kdoc | success | kdoc |
bjorn/module-param | success | module-param |
bjorn/verify-fixes | success | verify-fixes |
bjorn/verify-signedoff | success | verify-signedoff |
Hello, On Wed, Apr 09, 2025 at 10:51:56AM +0800, Haibo Xu wrote: > 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> Acked-by: Namhyung Kim <namhyung@kernel.org> Thanks, Namhyung > --- > 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 >
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;
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(+)