diff options
| author | Alan Jenkins <alan-jenkins@tuffmail.co.uk> | 2009-11-07 16:03:54 -0500 |
|---|---|---|
| committer | Rusty Russell <rusty@rustcorp.com.au> | 2009-12-15 00:58:26 -0500 |
| commit | 9e1b9b80721661bd63b3662453767b22cd614fe7 (patch) | |
| tree | e1b53708f4b65c990db3b8b732dc3d984574c756 | |
| parent | 3e7b19efe621bcf8bfef896c9c4cc5c99c52c3ec (diff) | |
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>
| -rw-r--r-- | arch/blackfin/Kconfig | 4 | ||||
| -rw-r--r-- | arch/blackfin/include/asm/module.h | 2 | ||||
| -rw-r--r-- | arch/blackfin/kernel/vmlinux.lds.S | 2 | ||||
| -rw-r--r-- | arch/h8300/Kconfig | 4 | ||||
| -rw-r--r-- | arch/h8300/include/asm/module.h | 2 | ||||
| -rw-r--r-- | arch/h8300/kernel/vmlinux.lds.S | 1 | ||||
| -rw-r--r-- | include/asm-generic/vmlinux.lds.h | 8 | ||||
| -rw-r--r-- | include/linux/module.h | 6 | ||||
| -rw-r--r-- | scripts/Makefile.lib | 5 | ||||
| -rw-r--r-- | scripts/mod/Makefile | 2 | ||||
| -rw-r--r-- | scripts/mod/mk_elfconfig.c | 9 | ||||
| -rw-r--r-- | scripts/mod/modpost.c | 9 |
12 files changed, 33 insertions, 21 deletions
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig index ae6a60f10120..2180433213b7 100644 --- a/arch/blackfin/Kconfig +++ b/arch/blackfin/Kconfig | |||
| @@ -5,6 +5,10 @@ | |||
| 5 | 5 | ||
| 6 | mainmenu "Blackfin Kernel Configuration" | 6 | mainmenu "Blackfin Kernel Configuration" |
| 7 | 7 | ||
| 8 | config SYMBOL_PREFIX | ||
| 9 | string | ||
| 10 | default "_" | ||
| 11 | |||
| 8 | config MMU | 12 | config MMU |
| 9 | def_bool n | 13 | def_bool n |
| 10 | 14 | ||
diff --git a/arch/blackfin/include/asm/module.h b/arch/blackfin/include/asm/module.h index 9c1cfffddd9b..4282b169ead9 100644 --- a/arch/blackfin/include/asm/module.h +++ b/arch/blackfin/include/asm/module.h | |||
| @@ -7,8 +7,6 @@ | |||
| 7 | #ifndef _ASM_BFIN_MODULE_H | 7 | #ifndef _ASM_BFIN_MODULE_H |
| 8 | #define _ASM_BFIN_MODULE_H | 8 | #define _ASM_BFIN_MODULE_H |
| 9 | 9 | ||
| 10 | #define MODULE_SYMBOL_PREFIX "_" | ||
| 11 | |||
| 12 | #define Elf_Shdr Elf32_Shdr | 10 | #define Elf_Shdr Elf32_Shdr |
| 13 | #define Elf_Sym Elf32_Sym | 11 | #define Elf_Sym Elf32_Sym |
| 14 | #define Elf_Ehdr Elf32_Ehdr | 12 | #define Elf_Ehdr Elf32_Ehdr |
diff --git a/arch/blackfin/kernel/vmlinux.lds.S b/arch/blackfin/kernel/vmlinux.lds.S index 10e12539000e..f39707c6590d 100644 --- a/arch/blackfin/kernel/vmlinux.lds.S +++ b/arch/blackfin/kernel/vmlinux.lds.S | |||
| @@ -4,8 +4,6 @@ | |||
| 4 | * Licensed under the GPL-2 or later | 4 | * Licensed under the GPL-2 or later |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #define VMLINUX_SYMBOL(_sym_) _##_sym_ | ||
| 8 | |||
| 9 | #include <asm-generic/vmlinux.lds.h> | 7 | #include <asm-generic/vmlinux.lds.h> |
| 10 | #include <asm/mem_map.h> | 8 | #include <asm/mem_map.h> |
| 11 | #include <asm/page.h> | 9 | #include <asm/page.h> |
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig index 9420648352b8..53cc669e6d59 100644 --- a/arch/h8300/Kconfig +++ b/arch/h8300/Kconfig | |||
| @@ -10,6 +10,10 @@ config H8300 | |||
| 10 | default y | 10 | default y |
| 11 | select HAVE_IDE | 11 | select HAVE_IDE |
| 12 | 12 | ||
| 13 | config SYMBOL_PREFIX | ||
| 14 | string | ||
| 15 | default "_" | ||
| 16 | |||
| 13 | config MMU | 17 | config MMU |
| 14 | bool | 18 | bool |
| 15 | default n | 19 | default n |
diff --git a/arch/h8300/include/asm/module.h b/arch/h8300/include/asm/module.h index de23231f3196..8e46724b7c09 100644 --- a/arch/h8300/include/asm/module.h +++ b/arch/h8300/include/asm/module.h | |||
| @@ -8,6 +8,4 @@ struct mod_arch_specific { }; | |||
| 8 | #define Elf_Sym Elf32_Sym | 8 | #define Elf_Sym Elf32_Sym |
| 9 | #define Elf_Ehdr Elf32_Ehdr | 9 | #define Elf_Ehdr Elf32_Ehdr |
| 10 | 10 | ||
| 11 | #define MODULE_SYMBOL_PREFIX "_" | ||
| 12 | |||
| 13 | #endif /* _ASM_H8/300_MODULE_H */ | 11 | #endif /* _ASM_H8/300_MODULE_H */ |
diff --git a/arch/h8300/kernel/vmlinux.lds.S b/arch/h8300/kernel/vmlinux.lds.S index b9e24907e6ea..03d356d96e5d 100644 --- a/arch/h8300/kernel/vmlinux.lds.S +++ b/arch/h8300/kernel/vmlinux.lds.S | |||
| @@ -1,4 +1,3 @@ | |||
| 1 | #define VMLINUX_SYMBOL(_sym_) _##_sym_ | ||
| 2 | #include <asm-generic/vmlinux.lds.h> | 1 | #include <asm-generic/vmlinux.lds.h> |
| 3 | #include <asm/page.h> | 2 | #include <asm/page.h> |
| 4 | 3 | ||
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index b6e818f4b247..67e652068e0e 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h | |||
| @@ -52,8 +52,12 @@ | |||
| 52 | #define LOAD_OFFSET 0 | 52 | #define LOAD_OFFSET 0 |
| 53 | #endif | 53 | #endif |
| 54 | 54 | ||
| 55 | #ifndef VMLINUX_SYMBOL | 55 | #ifndef SYMBOL_PREFIX |
| 56 | #define VMLINUX_SYMBOL(_sym_) _sym_ | 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 | #endif | 61 | #endif |
| 58 | 62 | ||
| 59 | /* Align . to a 8 byte boundary equals to maximum function alignment. */ | 63 | /* Align . to a 8 byte boundary equals to maximum function alignment. */ |
diff --git a/include/linux/module.h b/include/linux/module.h index 482efc865acf..6cb1a3cab5d3 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
| @@ -25,8 +25,10 @@ | |||
| 25 | /* Not Yet Implemented */ | 25 | /* Not Yet Implemented */ |
| 26 | #define MODULE_SUPPORTED_DEVICE(name) | 26 | #define MODULE_SUPPORTED_DEVICE(name) |
| 27 | 27 | ||
| 28 | /* some toolchains uses a `_' prefix for all user symbols */ | 28 | /* Some toolchains use a `_' prefix for all user symbols. */ |
| 29 | #ifndef MODULE_SYMBOL_PREFIX | 29 | #ifdef CONFIG_SYMBOL_PREFIX |
| 30 | #define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX | ||
| 31 | #else | ||
| 30 | #define MODULE_SYMBOL_PREFIX "" | 32 | #define MODULE_SYMBOL_PREFIX "" |
| 31 | #endif | 33 | #endif |
| 32 | 34 | ||
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index ffdafb26f539..224d85e72ef1 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
| @@ -127,6 +127,11 @@ _c_flags += $(if $(patsubst n%,, \ | |||
| 127 | $(CFLAGS_GCOV)) | 127 | $(CFLAGS_GCOV)) |
| 128 | endif | 128 | endif |
| 129 | 129 | ||
| 130 | ifdef CONFIG_SYMBOL_PREFIX | ||
| 131 | _cpp_flags += -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX)) | ||
| 132 | endif | ||
| 133 | |||
| 134 | |||
| 130 | # If building the kernel in a separate objtree expand all occurrences | 135 | # If building the kernel in a separate objtree expand all occurrences |
| 131 | # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). | 136 | # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). |
| 132 | 137 | ||
diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile index 11d69c35e5b4..ff954f8168c1 100644 --- a/scripts/mod/Makefile +++ b/scripts/mod/Makefile | |||
| @@ -8,7 +8,7 @@ modpost-objs := modpost.o file2alias.o sumversion.o | |||
| 8 | $(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h | 8 | $(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h |
| 9 | 9 | ||
| 10 | quiet_cmd_elfconfig = MKELF $@ | 10 | quiet_cmd_elfconfig = MKELF $@ |
| 11 | cmd_elfconfig = $(obj)/mk_elfconfig $(ARCH) < $< > $@ | 11 | cmd_elfconfig = $(obj)/mk_elfconfig < $< > $@ |
| 12 | 12 | ||
| 13 | $(obj)/elfconfig.h: $(obj)/empty.o $(obj)/mk_elfconfig FORCE | 13 | $(obj)/elfconfig.h: $(obj)/empty.o $(obj)/mk_elfconfig FORCE |
| 14 | $(call if_changed,elfconfig) | 14 | $(call if_changed,elfconfig) |
diff --git a/scripts/mod/mk_elfconfig.c b/scripts/mod/mk_elfconfig.c index 6a96d47bd1e6..639bca7ba559 100644 --- a/scripts/mod/mk_elfconfig.c +++ b/scripts/mod/mk_elfconfig.c | |||
| @@ -9,9 +9,6 @@ main(int argc, char **argv) | |||
| 9 | unsigned char ei[EI_NIDENT]; | 9 | unsigned char ei[EI_NIDENT]; |
| 10 | union { short s; char c[2]; } endian_test; | 10 | union { short s; char c[2]; } endian_test; |
| 11 | 11 | ||
| 12 | if (argc != 2) { | ||
| 13 | fprintf(stderr, "Error: no arch\n"); | ||
| 14 | } | ||
| 15 | if (fread(ei, 1, EI_NIDENT, stdin) != EI_NIDENT) { | 12 | if (fread(ei, 1, EI_NIDENT, stdin) != EI_NIDENT) { |
| 16 | fprintf(stderr, "Error: input truncated\n"); | 13 | fprintf(stderr, "Error: input truncated\n"); |
| 17 | return 1; | 14 | return 1; |
| @@ -55,12 +52,6 @@ main(int argc, char **argv) | |||
| 55 | else | 52 | else |
| 56 | exit(1); | 53 | exit(1); |
| 57 | 54 | ||
| 58 | if ((strcmp(argv[1], "h8300") == 0) | ||
| 59 | || (strcmp(argv[1], "blackfin") == 0)) | ||
| 60 | printf("#define MODULE_SYMBOL_PREFIX \"_\"\n"); | ||
| 61 | else | ||
| 62 | printf("#define MODULE_SYMBOL_PREFIX \"\"\n"); | ||
| 63 | |||
| 64 | return 0; | 55 | return 0; |
| 65 | } | 56 | } |
| 66 | 57 | ||
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 801a16a17545..fb0f9b711af3 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
| @@ -15,8 +15,17 @@ | |||
| 15 | #include <stdio.h> | 15 | #include <stdio.h> |
| 16 | #include <ctype.h> | 16 | #include <ctype.h> |
| 17 | #include "modpost.h" | 17 | #include "modpost.h" |
| 18 | #include "../../include/linux/autoconf.h" | ||
| 18 | #include "../../include/linux/license.h" | 19 | #include "../../include/linux/license.h" |
| 19 | 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 | |||
| 28 | |||
| 20 | /* Are we using CONFIG_MODVERSIONS? */ | 29 | /* Are we using CONFIG_MODVERSIONS? */ |
| 21 | int modversions = 0; | 30 | int modversions = 0; |
| 22 | /* Warn about undefined symbols? (do so if we have vmlinux) */ | 31 | /* Warn about undefined symbols? (do so if we have vmlinux) */ |
