Skip to content

Commit ff09f6f

Browse files
palmer-dabbeltmcgrof
authored andcommitted
modpost, kallsyms: Treat add '$'-prefixed symbols as mapping symbols
Trying to restrict the '$'-prefix change to RISC-V caused some fallout, so let's just treat all those symbols as special. Fixes: c05780e ("module: Ignore RISC-V mapping symbols too") Link: https://lore.kernel.org/all/20230712015747.77263-1-wangkefeng.wang@huawei.com/ Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Reviewed-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
1 parent 9ce170c commit ff09f6f

3 files changed

Lines changed: 4 additions & 16 deletions

File tree

include/linux/module_symbol.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,13 @@
33
#define _LINUX_MODULE_SYMBOL_H
44

55
/* This ignores the intensely annoying "mapping symbols" found in ELF files. */
6-
static inline int is_mapping_symbol(const char *str, int is_riscv)
6+
static inline int is_mapping_symbol(const char *str)
77
{
88
if (str[0] == '.' && str[1] == 'L')
99
return true;
1010
if (str[0] == 'L' && str[1] == '0')
1111
return true;
12-
/*
13-
* RISC-V defines various special symbols that start with "$".  The
14-
* mapping symbols, which exist to differentiate between incompatible
15-
* instruction encodings when disassembling, show up all over the place
16-
* and are generally not meant to be treated like other symbols.  So
17-
* just ignore any of the special symbols.
18-
*/
19-
if (is_riscv)
20-
return str[0] == '$';
21-
22-
return str[0] == '$' &&
23-
(str[1] == 'a' || str[1] == 'd' || str[1] == 't' || str[1] == 'x')
24-
&& (str[2] == '\0' || str[2] == '.');
12+
return str[0] == '$';
2513
}
2614

2715
#endif /* _LINUX_MODULE_SYMBOL_H */

kernel/module/kallsyms.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static const char *find_kallsyms_symbol(struct module *mod,
289289
* and inserted at a whim.
290290
*/
291291
if (*kallsyms_symbol_name(kallsyms, i) == '\0' ||
292-
is_mapping_symbol(kallsyms_symbol_name(kallsyms, i), IS_ENABLED(CONFIG_RISCV)))
292+
is_mapping_symbol(kallsyms_symbol_name(kallsyms, i)))
293293
continue;
294294

295295
if (thisval <= addr && thisval > bestval) {

scripts/mod/modpost.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ static inline int is_valid_name(struct elf_info *elf, Elf_Sym *sym)
10521052

10531053
if (!name || !strlen(name))
10541054
return 0;
1055-
return !is_mapping_symbol(name, elf->hdr->e_machine == EM_RISCV);
1055+
return !is_mapping_symbol(name);
10561056
}
10571057

10581058
/* Look up the nearest symbol based on the section and the address */

0 commit comments

Comments
 (0)