module/kallsyms: Rename is_mapping_symbol() to is_ignored_kernel_symbol()

The helper function is_mapping_symbol() historically checks for both
local labels prefixed with ".L" or "L0" and mapping symbols prefixed
with "$".

Rename it to is_ignored_kernel_symbol() to better reflect this actual
behavior and scope, preventing conceptual confusion.

While at it, update the related non-module files, no functional changes.

Suggested-by: Petr Pavlu <petr.pavlu@suse.com>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
This commit is contained in:
Tiezhu Yang 2026-08-20 20:50:05 +08:00 committed by Petr Pavlu
parent df2908090c
commit db91da8f05
5 changed files with 9 additions and 8 deletions

View File

@ -7,8 +7,11 @@ enum ksym_flags {
KSYM_FLAG_GPL_ONLY = 1 << 0,
};
/* This ignores the intensely annoying "mapping symbols" found in ELF files. */
static inline bool is_mapping_symbol(const char *str)
/*
* Ignore local labels (.L*, L0*) and mapping symbols ($*). These symbols are
* not useful for the kernel, for example, they should not appear in kallsyms.
*/
static inline bool is_ignored_kernel_symbol(const char *str)
{
if (str[0] == '.' && str[1] == 'L')
return true;

View File

@ -294,7 +294,7 @@ static const char *find_kallsyms_symbol(struct module *mod,
* and inserted at a whim.
*/
if (*kallsyms_symbol_name(kallsyms, i) == '\0' ||
is_mapping_symbol(kallsyms_symbol_name(kallsyms, i)))
is_ignored_kernel_symbol(kallsyms_symbol_name(kallsyms, i)))
continue;
if (thisval <= addr && thisval > bestval) {

View File

@ -243,7 +243,7 @@ __faddr2line() {
local cur_sym_elf_size=${fields[2]}
local cur_sym_name=${fields[7]:-}
# is_mapping_symbol(cur_sym_name)
# is_ignored_kernel_symbol(cur_sym_name)
if [[ ${cur_sym_name} =~ ^(\.L|L0|\$) ]]; then
continue
fi

View File

@ -198,7 +198,7 @@ static inline bool is_valid_name(struct elf_info *elf, Elf_Sym *sym)
if (!name || !strlen(name))
return false;
return !is_mapping_symbol(name);
return !is_ignored_kernel_symbol(name);
}
/* symsearch.c */

View File

@ -33,9 +33,7 @@ struct build_id;
struct perf_env;
/*
* Ignore kernel mapping symbols, matching kernel is_mapping_symbol() logic.
* This checks for '$' prefix (used by ARM, AArch64, RISC-V) and
* x86 local symbol prefixes (.L* and L0*).
* Ignore local labels and mapping symbols, matching kernel is_ignored_kernel_symbol() logic.
* Only use this for kernel symbols (kallsyms, ksymbol events, kernel ELF DSOs).
*/
static inline bool is_ignored_kernel_symbol(const char *str)