Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: c05780ef3c190 ("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>

authored by

Palmer Dabbelt and committed by
Luis Chamberlain
ff09f6fd 9ce170ce

+4 -16
+2 -14
include/linux/module_symbol.h
··· 3 3 #define _LINUX_MODULE_SYMBOL_H 4 4 5 5 /* 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) 7 7 { 8 8 if (str[0] == '.' && str[1] == 'L') 9 9 return true; 10 10 if (str[0] == 'L' && str[1] == '0') 11 11 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] == '$'; 25 13 } 26 14 27 15 #endif /* _LINUX_MODULE_SYMBOL_H */
+1 -1
kernel/module/kallsyms.c
··· 289 289 * and inserted at a whim. 290 290 */ 291 291 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))) 293 293 continue; 294 294 295 295 if (thisval <= addr && thisval > bestval) {
+1 -1
scripts/mod/modpost.c
··· 1052 1052 1053 1053 if (!name || !strlen(name)) 1054 1054 return 0; 1055 - return !is_mapping_symbol(name, elf->hdr->e_machine == EM_RISCV); 1055 + return !is_mapping_symbol(name); 1056 1056 } 1057 1057 1058 1058 /* Look up the nearest symbol based on the section and the address */