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

module: make MODULE_SYMBOL_PREFIX into a CONFIG option

The next commit will require the use of MODULE_SYMBOL_PREFIX in
.tmp_exports-asm.S. Currently it is mixed in with C structure
definitions in "asm/module.h". Move the definition of this arch option
into Kconfig, so it can be easily accessed by any code.

This also lets modpost.c use the same definition. Previously modpost
relied on a hardcoded list of architectures in mk_elfconfig.c.

A build test for blackfin, one of the two MODULE_SYMBOL_PREFIX archs,
showed the generated code was unchanged. vmlinux was identical save
for build ids, and an apparently randomized suffix on a single "__key"
symbol in the kallsyms data).

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Acked-by: Mike Frysinger <vapier@gentoo.org> (blackfin)
CC: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

authored by

Alan Jenkins and committed by
Rusty Russell
9e1b9b80 3e7b19ef

+33 -21
+4
arch/blackfin/Kconfig
··· 5 5 6 6 mainmenu "Blackfin Kernel Configuration" 7 7 8 + config SYMBOL_PREFIX 9 + string 10 + default "_" 11 + 8 12 config MMU 9 13 def_bool n 10 14
-2
arch/blackfin/include/asm/module.h
··· 7 7 #ifndef _ASM_BFIN_MODULE_H 8 8 #define _ASM_BFIN_MODULE_H 9 9 10 - #define MODULE_SYMBOL_PREFIX "_" 11 - 12 10 #define Elf_Shdr Elf32_Shdr 13 11 #define Elf_Sym Elf32_Sym 14 12 #define Elf_Ehdr Elf32_Ehdr
-2
arch/blackfin/kernel/vmlinux.lds.S
··· 4 4 * Licensed under the GPL-2 or later 5 5 */ 6 6 7 - #define VMLINUX_SYMBOL(_sym_) _##_sym_ 8 - 9 7 #include <asm-generic/vmlinux.lds.h> 10 8 #include <asm/mem_map.h> 11 9 #include <asm/page.h>
+4
arch/h8300/Kconfig
··· 10 10 default y 11 11 select HAVE_IDE 12 12 13 + config SYMBOL_PREFIX 14 + string 15 + default "_" 16 + 13 17 config MMU 14 18 bool 15 19 default n
-2
arch/h8300/include/asm/module.h
··· 8 8 #define Elf_Sym Elf32_Sym 9 9 #define Elf_Ehdr Elf32_Ehdr 10 10 11 - #define MODULE_SYMBOL_PREFIX "_" 12 - 13 11 #endif /* _ASM_H8/300_MODULE_H */
-1
arch/h8300/kernel/vmlinux.lds.S
··· 1 - #define VMLINUX_SYMBOL(_sym_) _##_sym_ 2 1 #include <asm-generic/vmlinux.lds.h> 3 2 #include <asm/page.h> 4 3
+6 -2
include/asm-generic/vmlinux.lds.h
··· 52 52 #define LOAD_OFFSET 0 53 53 #endif 54 54 55 - #ifndef VMLINUX_SYMBOL 56 - #define VMLINUX_SYMBOL(_sym_) _sym_ 55 + #ifndef SYMBOL_PREFIX 56 + #define VMLINUX_SYMBOL(sym) sym 57 + #else 58 + #define PASTE2(x,y) x##y 59 + #define PASTE(x,y) PASTE2(x,y) 60 + #define VMLINUX_SYMBOL(sym) PASTE(SYMBOL_PREFIX, sym) 57 61 #endif 58 62 59 63 /* Align . to a 8 byte boundary equals to maximum function alignment. */
+4 -2
include/linux/module.h
··· 25 25 /* Not Yet Implemented */ 26 26 #define MODULE_SUPPORTED_DEVICE(name) 27 27 28 - /* some toolchains uses a `_' prefix for all user symbols */ 29 - #ifndef MODULE_SYMBOL_PREFIX 28 + /* Some toolchains use a `_' prefix for all user symbols. */ 29 + #ifdef CONFIG_SYMBOL_PREFIX 30 + #define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX 31 + #else 30 32 #define MODULE_SYMBOL_PREFIX "" 31 33 #endif 32 34
+5
scripts/Makefile.lib
··· 127 127 $(CFLAGS_GCOV)) 128 128 endif 129 129 130 + ifdef CONFIG_SYMBOL_PREFIX 131 + _cpp_flags += -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX)) 132 + endif 133 + 134 + 130 135 # If building the kernel in a separate objtree expand all occurrences 131 136 # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). 132 137
+1 -1
scripts/mod/Makefile
··· 8 8 $(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h 9 9 10 10 quiet_cmd_elfconfig = MKELF $@ 11 - cmd_elfconfig = $(obj)/mk_elfconfig $(ARCH) < $< > $@ 11 + cmd_elfconfig = $(obj)/mk_elfconfig < $< > $@ 12 12 13 13 $(obj)/elfconfig.h: $(obj)/empty.o $(obj)/mk_elfconfig FORCE 14 14 $(call if_changed,elfconfig)
-9
scripts/mod/mk_elfconfig.c
··· 9 9 unsigned char ei[EI_NIDENT]; 10 10 union { short s; char c[2]; } endian_test; 11 11 12 - if (argc != 2) { 13 - fprintf(stderr, "Error: no arch\n"); 14 - } 15 12 if (fread(ei, 1, EI_NIDENT, stdin) != EI_NIDENT) { 16 13 fprintf(stderr, "Error: input truncated\n"); 17 14 return 1; ··· 51 54 printf("#define HOST_ELFDATA ELFDATA2LSB\n"); 52 55 else 53 56 exit(1); 54 - 55 - if ((strcmp(argv[1], "h8300") == 0) 56 - || (strcmp(argv[1], "blackfin") == 0)) 57 - printf("#define MODULE_SYMBOL_PREFIX \"_\"\n"); 58 - else 59 - printf("#define MODULE_SYMBOL_PREFIX \"\"\n"); 60 57 61 58 return 0; 62 59 }
+9
scripts/mod/modpost.c
··· 15 15 #include <stdio.h> 16 16 #include <ctype.h> 17 17 #include "modpost.h" 18 + #include "../../include/linux/autoconf.h" 18 19 #include "../../include/linux/license.h" 20 + 21 + /* Some toolchains use a `_' prefix for all user symbols. */ 22 + #ifdef CONFIG_SYMBOL_PREFIX 23 + #define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX 24 + #else 25 + #define MODULE_SYMBOL_PREFIX "" 26 + #endif 27 + 19 28 20 29 /* Are we using CONFIG_MODVERSIONS? */ 21 30 int modversions = 0;