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 <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>
This commit is contained in:
Rui Qi 2026-05-22 16:26:04 +08:00 committed by Arnaldo Carvalho de Melo
parent e987110f09
commit 43b16bf3e7

View 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;