From: Rui Qi Date: Fri, 22 May 2026 08:26:04 +0000 (+0800) Subject: perf: Apply is_ignored_kernel_symbol() filter in ELF loading path for kernel DSOs X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43b16bf3e7306b4c9ec1aa804872b32a969f5777;p=thirdparty%2Flinux.git perf: Apply is_ignored_kernel_symbol() filter in ELF loading path for kernel DSOs dso__load_sym_internal() had no filtering for .L* and L0* mapping symbols while the kallsyms path already filters them via is_ignored_kernel_symbol(). Add the same check gated by dso__kernel() so that kernel ELF objects (vmlinux, .ko) have mapping symbols filtered across all architectures, but userspace ELF objects are unaffected -- '$' is a valid prefix in languages like Java and Scala. The existing ARM/AArch64 and RISC-V architecture-specific mapping symbol checks are preserved; the new is_ignored_kernel_symbol() check adds x86 local symbol (.L*, L0*) filtering and provides unified cross-architecture coverage for kernel DSOs. Signed-off-by: Rui Qi Acked-by: Namhyung Kim Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Ian Rogers Cc: Ingo Molnar Cc: James Clark Cc: Jiri Olsa Cc: Mark Rutland Cc: Peter Zijlstra Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 7afa8a1171396..77e6dcba8fda1 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -1592,9 +1592,11 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss, if (!is_label && !elf_sym__filter(&sym)) continue; - /* Reject ARM ELF "mapping symbols": these aren't unique and + /* + * Reject ARM ELF "mapping symbols": these aren't unique and * don't identify functions, so will confuse the profile - * output: */ + * output: + */ if (ehdr.e_machine == EM_ARM || ehdr.e_machine == EM_AARCH64) { if (elf_name[0] == '$' && strchr("adtx", elf_name[1]) && (elf_name[2] == '\0' || elf_name[2] == '.')) @@ -1607,6 +1609,10 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss, continue; } + /* Reject kernel mapping symbols for kernel DSOs only */ + if (dso__kernel(dso) && is_ignored_kernel_symbol(elf_name)) + 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;