[PATCH v4 2/2] perf: Apply is_ignored_kernel_symbol() filter in ELF loading path for kernel DSOs

From: Rui Qi

Date: Fri May 22 2026 - 04:28:46 EST


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 <qirui.001@xxxxxxxxxxxxx>
---
tools/perf/util/symbol-elf.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 7afa8a117139..77e6dcba8fda 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;
--
2.20.1