]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf: Apply is_ignored_kernel_symbol() filter in ELF loading path for kernel DSOs
authorRui Qi <qirui.001@bytedance.com>
Fri, 22 May 2026 08:26:04 +0000 (16:26 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 27 May 2026 11:15:01 +0000 (08:15 -0300)
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@bytedance.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/symbol-elf.c

index 7afa8a1171396b1770dbf6b78e7a32bc172440d7..77e6dcba8fda17fdc8569b9e41f0dd22202d5276 100644 (file)
@@ -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;