diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-16 13:47:24 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-16 13:47:24 -0500 |
commit | 74f3ae743427b87e43b5cb9f4257021ae8ad4267 (patch) | |
tree | 378975998960af61558304c97999f3bf62c8ba12 | |
parent | d8bef0bb219154e655fa139e28400d6ae9aa3727 (diff) | |
parent | 8d99513c1b76cfd0b2dcf061c5136cb1061e6b37 (diff) |
Merge branch 'module' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus
* 'module' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus:
modpost: fix segfault with short symbol names
module: handle ppc64 relocating kcrctabs when CONFIG_RELOCATABLE=y
Kbuild: clear marker out of modpost
module: make MODULE_SYMBOL_PREFIX into a CONFIG option
ARM: unexport symbols used to implement floating point emulation
ARM: use unified discard definition in linker script
x86: don't export inline function
sparc64: don't export static inline pci_ functions
-rw-r--r-- | arch/arm/kernel/armksyms.c | 20 | ||||
-rw-r--r-- | arch/arm/kernel/vmlinux.lds.S | 13 | ||||
-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-- | arch/powerpc/include/asm/module.h | 5 | ||||
-rw-r--r-- | arch/powerpc/kernel/vmlinux.lds.S | 3 | ||||
-rw-r--r-- | arch/sparc/kernel/pci.c | 1 | ||||
-rw-r--r-- | arch/sparc/kernel/sparc_ksyms_64.c | 12 | ||||
-rw-r--r-- | arch/x86/kernel/x8664_ksyms_64.c | 4 | ||||
-rw-r--r-- | include/asm-generic/vmlinux.lds.h | 8 | ||||
-rw-r--r-- | include/linux/module.h | 6 | ||||
-rw-r--r-- | kernel/module.c | 28 | ||||
-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 | 177 | ||||
-rw-r--r-- | scripts/mod/modpost.h | 3 |
21 files changed, 75 insertions, 236 deletions
diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c index 0e627705f746..8214bfebfaca 100644 --- a/arch/arm/kernel/armksyms.c +++ b/arch/arm/kernel/armksyms.c | |||
@@ -48,27 +48,7 @@ extern void __aeabi_uidivmod(void); | |||
48 | extern void __aeabi_ulcmp(void); | 48 | extern void __aeabi_ulcmp(void); |
49 | 49 | ||
50 | extern void fpundefinstr(void); | 50 | extern void fpundefinstr(void); |
51 | extern void fp_enter(void); | ||
52 | 51 | ||
53 | /* | ||
54 | * This has a special calling convention; it doesn't | ||
55 | * modify any of the usual registers, except for LR. | ||
56 | */ | ||
57 | #define EXPORT_CRC_ALIAS(sym) __CRC_SYMBOL(sym, "") | ||
58 | |||
59 | #define EXPORT_SYMBOL_ALIAS(sym,orig) \ | ||
60 | EXPORT_CRC_ALIAS(sym) \ | ||
61 | static const struct kernel_symbol __ksymtab_##sym \ | ||
62 | __used __attribute__((section("__ksymtab"))) = \ | ||
63 | { (unsigned long)&orig, #sym }; | ||
64 | |||
65 | /* | ||
66 | * floating point math emulator support. | ||
67 | * These symbols will never change their calling convention... | ||
68 | */ | ||
69 | EXPORT_SYMBOL_ALIAS(kern_fp_enter,fp_enter); | ||
70 | EXPORT_SYMBOL_ALIAS(fp_printk,printk); | ||
71 | EXPORT_SYMBOL_ALIAS(fp_send_sig,send_sig); | ||
72 | 52 | ||
73 | EXPORT_SYMBOL(__backtrace); | 53 | EXPORT_SYMBOL(__backtrace); |
74 | 54 | ||
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S index 71151bd87a36..4957e13ef55b 100644 --- a/arch/arm/kernel/vmlinux.lds.S +++ b/arch/arm/kernel/vmlinux.lds.S | |||
@@ -65,11 +65,11 @@ SECTIONS | |||
65 | __init_end = .; | 65 | __init_end = .; |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | /DISCARD/ : { /* Exit code and data */ | 68 | /* |
69 | EXIT_TEXT | 69 | * unwind exit sections must be discarded before the rest of the |
70 | EXIT_DATA | 70 | * unwind sections get included. |
71 | *(.exitcall.exit) | 71 | */ |
72 | *(.discard) | 72 | /DISCARD/ : { |
73 | *(.ARM.exidx.exit.text) | 73 | *(.ARM.exidx.exit.text) |
74 | *(.ARM.extab.exit.text) | 74 | *(.ARM.extab.exit.text) |
75 | #ifndef CONFIG_HOTPLUG_CPU | 75 | #ifndef CONFIG_HOTPLUG_CPU |
@@ -238,6 +238,9 @@ SECTIONS | |||
238 | 238 | ||
239 | STABS_DEBUG | 239 | STABS_DEBUG |
240 | .comment 0 : { *(.comment) } | 240 | .comment 0 : { *(.comment) } |
241 | |||
242 | /* Default discards */ | ||
243 | DISCARDS | ||
241 | } | 244 | } |
242 | 245 | ||
243 | /* | 246 | /* |
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/arch/powerpc/include/asm/module.h b/arch/powerpc/include/asm/module.h index 08454880a2c0..0192a4ee2bc2 100644 --- a/arch/powerpc/include/asm/module.h +++ b/arch/powerpc/include/asm/module.h | |||
@@ -87,5 +87,10 @@ struct exception_table_entry; | |||
87 | void sort_ex_table(struct exception_table_entry *start, | 87 | void sort_ex_table(struct exception_table_entry *start, |
88 | struct exception_table_entry *finish); | 88 | struct exception_table_entry *finish); |
89 | 89 | ||
90 | #ifdef CONFIG_MODVERSIONS | ||
91 | #define ARCH_RELOCATES_KCRCTAB | ||
92 | |||
93 | extern const unsigned long reloc_start[]; | ||
94 | #endif | ||
90 | #endif /* __KERNEL__ */ | 95 | #endif /* __KERNEL__ */ |
91 | #endif /* _ASM_POWERPC_MODULE_H */ | 96 | #endif /* _ASM_POWERPC_MODULE_H */ |
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S index 27735a7ac12b..dcd01c82e701 100644 --- a/arch/powerpc/kernel/vmlinux.lds.S +++ b/arch/powerpc/kernel/vmlinux.lds.S | |||
@@ -38,6 +38,9 @@ jiffies = jiffies_64 + 4; | |||
38 | #endif | 38 | #endif |
39 | SECTIONS | 39 | SECTIONS |
40 | { | 40 | { |
41 | . = 0; | ||
42 | reloc_start = .; | ||
43 | |||
41 | . = KERNELBASE; | 44 | . = KERNELBASE; |
42 | 45 | ||
43 | /* | 46 | /* |
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c index b85374f7cf94..539e83f8e087 100644 --- a/arch/sparc/kernel/pci.c +++ b/arch/sparc/kernel/pci.c | |||
@@ -1064,7 +1064,6 @@ int pci64_dma_supported(struct pci_dev *pdev, u64 device_mask) | |||
1064 | 1064 | ||
1065 | return (device_mask & dma_addr_mask) == dma_addr_mask; | 1065 | return (device_mask & dma_addr_mask) == dma_addr_mask; |
1066 | } | 1066 | } |
1067 | EXPORT_SYMBOL(pci_dma_supported); | ||
1068 | 1067 | ||
1069 | void pci_resource_to_user(const struct pci_dev *pdev, int bar, | 1068 | void pci_resource_to_user(const struct pci_dev *pdev, int bar, |
1070 | const struct resource *rp, resource_size_t *start, | 1069 | const struct resource *rp, resource_size_t *start, |
diff --git a/arch/sparc/kernel/sparc_ksyms_64.c b/arch/sparc/kernel/sparc_ksyms_64.c index 0f26066a08d9..372ad59c4cba 100644 --- a/arch/sparc/kernel/sparc_ksyms_64.c +++ b/arch/sparc/kernel/sparc_ksyms_64.c | |||
@@ -38,17 +38,5 @@ EXPORT_SYMBOL(sun4v_niagara_setperf); | |||
38 | EXPORT_SYMBOL(sun4v_niagara2_getperf); | 38 | EXPORT_SYMBOL(sun4v_niagara2_getperf); |
39 | EXPORT_SYMBOL(sun4v_niagara2_setperf); | 39 | EXPORT_SYMBOL(sun4v_niagara2_setperf); |
40 | 40 | ||
41 | #ifdef CONFIG_PCI | ||
42 | /* inline functions in asm/pci_64.h */ | ||
43 | EXPORT_SYMBOL(pci_alloc_consistent); | ||
44 | EXPORT_SYMBOL(pci_free_consistent); | ||
45 | EXPORT_SYMBOL(pci_map_single); | ||
46 | EXPORT_SYMBOL(pci_unmap_single); | ||
47 | EXPORT_SYMBOL(pci_map_sg); | ||
48 | EXPORT_SYMBOL(pci_unmap_sg); | ||
49 | EXPORT_SYMBOL(pci_dma_sync_single_for_cpu); | ||
50 | EXPORT_SYMBOL(pci_dma_sync_sg_for_cpu); | ||
51 | #endif | ||
52 | |||
53 | /* Exporting a symbol from /init/main.c */ | 41 | /* Exporting a symbol from /init/main.c */ |
54 | EXPORT_SYMBOL(saved_command_line); | 42 | EXPORT_SYMBOL(saved_command_line); |
diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c index a1029769b6f2..084c1adc45f5 100644 --- a/arch/x86/kernel/x8664_ksyms_64.c +++ b/arch/x86/kernel/x8664_ksyms_64.c | |||
@@ -56,4 +56,6 @@ EXPORT_SYMBOL(__memcpy); | |||
56 | 56 | ||
57 | EXPORT_SYMBOL(empty_zero_page); | 57 | EXPORT_SYMBOL(empty_zero_page); |
58 | EXPORT_SYMBOL(init_level4_pgt); | 58 | EXPORT_SYMBOL(init_level4_pgt); |
59 | EXPORT_SYMBOL(load_gs_index); | 59 | #ifndef CONFIG_PARAVIRT |
60 | EXPORT_SYMBOL(native_load_gs_index); | ||
61 | #endif | ||
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/kernel/module.c b/kernel/module.c index 12afc5a3ddd3..a65dc787a27b 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -880,11 +880,23 @@ static int try_to_force_load(struct module *mod, const char *reason) | |||
880 | } | 880 | } |
881 | 881 | ||
882 | #ifdef CONFIG_MODVERSIONS | 882 | #ifdef CONFIG_MODVERSIONS |
883 | /* If the arch applies (non-zero) relocations to kernel kcrctab, unapply it. */ | ||
884 | static unsigned long maybe_relocated(unsigned long crc, | ||
885 | const struct module *crc_owner) | ||
886 | { | ||
887 | #ifdef ARCH_RELOCATES_KCRCTAB | ||
888 | if (crc_owner == NULL) | ||
889 | return crc - (unsigned long)reloc_start; | ||
890 | #endif | ||
891 | return crc; | ||
892 | } | ||
893 | |||
883 | static int check_version(Elf_Shdr *sechdrs, | 894 | static int check_version(Elf_Shdr *sechdrs, |
884 | unsigned int versindex, | 895 | unsigned int versindex, |
885 | const char *symname, | 896 | const char *symname, |
886 | struct module *mod, | 897 | struct module *mod, |
887 | const unsigned long *crc) | 898 | const unsigned long *crc, |
899 | const struct module *crc_owner) | ||
888 | { | 900 | { |
889 | unsigned int i, num_versions; | 901 | unsigned int i, num_versions; |
890 | struct modversion_info *versions; | 902 | struct modversion_info *versions; |
@@ -905,10 +917,10 @@ static int check_version(Elf_Shdr *sechdrs, | |||
905 | if (strcmp(versions[i].name, symname) != 0) | 917 | if (strcmp(versions[i].name, symname) != 0) |
906 | continue; | 918 | continue; |
907 | 919 | ||
908 | if (versions[i].crc == *crc) | 920 | if (versions[i].crc == maybe_relocated(*crc, crc_owner)) |
909 | return 1; | 921 | return 1; |
910 | DEBUGP("Found checksum %lX vs module %lX\n", | 922 | DEBUGP("Found checksum %lX vs module %lX\n", |
911 | *crc, versions[i].crc); | 923 | maybe_relocated(*crc, crc_owner), versions[i].crc); |
912 | goto bad_version; | 924 | goto bad_version; |
913 | } | 925 | } |
914 | 926 | ||
@@ -931,7 +943,8 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs, | |||
931 | if (!find_symbol(MODULE_SYMBOL_PREFIX "module_layout", NULL, | 943 | if (!find_symbol(MODULE_SYMBOL_PREFIX "module_layout", NULL, |
932 | &crc, true, false)) | 944 | &crc, true, false)) |
933 | BUG(); | 945 | BUG(); |
934 | return check_version(sechdrs, versindex, "module_layout", mod, crc); | 946 | return check_version(sechdrs, versindex, "module_layout", mod, crc, |
947 | NULL); | ||
935 | } | 948 | } |
936 | 949 | ||
937 | /* First part is kernel version, which we ignore if module has crcs. */ | 950 | /* First part is kernel version, which we ignore if module has crcs. */ |
@@ -949,7 +962,8 @@ static inline int check_version(Elf_Shdr *sechdrs, | |||
949 | unsigned int versindex, | 962 | unsigned int versindex, |
950 | const char *symname, | 963 | const char *symname, |
951 | struct module *mod, | 964 | struct module *mod, |
952 | const unsigned long *crc) | 965 | const unsigned long *crc, |
966 | const struct module *crc_owner) | ||
953 | { | 967 | { |
954 | return 1; | 968 | return 1; |
955 | } | 969 | } |
@@ -984,8 +998,8 @@ static const struct kernel_symbol *resolve_symbol(Elf_Shdr *sechdrs, | |||
984 | /* use_module can fail due to OOM, | 998 | /* use_module can fail due to OOM, |
985 | or module initialization or unloading */ | 999 | or module initialization or unloading */ |
986 | if (sym) { | 1000 | if (sym) { |
987 | if (!check_version(sechdrs, versindex, name, mod, crc) || | 1001 | if (!check_version(sechdrs, versindex, name, mod, crc, owner) |
988 | !use_module(mod, owner)) | 1002 | || !use_module(mod, owner)) |
989 | sym = NULL; | 1003 | sym = NULL; |
990 | } | 1004 | } |
991 | return sym; | 1005 | return sym; |
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..6c4ffc767b91 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) */ |
@@ -451,8 +460,6 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
451 | info->export_unused_gpl_sec = i; | 460 | info->export_unused_gpl_sec = i; |
452 | else if (strcmp(secname, "__ksymtab_gpl_future") == 0) | 461 | else if (strcmp(secname, "__ksymtab_gpl_future") == 0) |
453 | info->export_gpl_future_sec = i; | 462 | info->export_gpl_future_sec = i; |
454 | else if (strcmp(secname, "__markers_strings") == 0) | ||
455 | info->markers_strings_sec = i; | ||
456 | 463 | ||
457 | if (sechdrs[i].sh_type != SHT_SYMTAB) | 464 | if (sechdrs[i].sh_type != SHT_SYMTAB) |
458 | continue; | 465 | continue; |
@@ -515,7 +522,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, | |||
515 | break; | 522 | break; |
516 | case SHN_ABS: | 523 | case SHN_ABS: |
517 | /* CRC'd symbol */ | 524 | /* CRC'd symbol */ |
518 | if (memcmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) { | 525 | if (strncmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) { |
519 | crc = (unsigned int) sym->st_value; | 526 | crc = (unsigned int) sym->st_value; |
520 | sym_update_crc(symname + strlen(CRC_PFX), mod, crc, | 527 | sym_update_crc(symname + strlen(CRC_PFX), mod, crc, |
521 | export); | 528 | export); |
@@ -559,7 +566,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, | |||
559 | break; | 566 | break; |
560 | default: | 567 | default: |
561 | /* All exported symbols */ | 568 | /* All exported symbols */ |
562 | if (memcmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) { | 569 | if (strncmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) { |
563 | sym_add_exported(symname + strlen(KSYMTAB_PFX), mod, | 570 | sym_add_exported(symname + strlen(KSYMTAB_PFX), mod, |
564 | export); | 571 | export); |
565 | } | 572 | } |
@@ -1509,62 +1516,6 @@ static void check_sec_ref(struct module *mod, const char *modname, | |||
1509 | } | 1516 | } |
1510 | } | 1517 | } |
1511 | 1518 | ||
1512 | static void get_markers(struct elf_info *info, struct module *mod) | ||
1513 | { | ||
1514 | const Elf_Shdr *sh = &info->sechdrs[info->markers_strings_sec]; | ||
1515 | const char *strings = (const char *) info->hdr + sh->sh_offset; | ||
1516 | const Elf_Sym *sym, *first_sym, *last_sym; | ||
1517 | size_t n; | ||
1518 | |||
1519 | if (!info->markers_strings_sec) | ||
1520 | return; | ||
1521 | |||
1522 | /* | ||
1523 | * First count the strings. We look for all the symbols defined | ||
1524 | * in the __markers_strings section named __mstrtab_*. For | ||
1525 | * these local names, the compiler puts a random .NNN suffix on, | ||
1526 | * so the names don't correspond exactly. | ||
1527 | */ | ||
1528 | first_sym = last_sym = NULL; | ||
1529 | n = 0; | ||
1530 | for (sym = info->symtab_start; sym < info->symtab_stop; sym++) | ||
1531 | if (ELF_ST_TYPE(sym->st_info) == STT_OBJECT && | ||
1532 | sym->st_shndx == info->markers_strings_sec && | ||
1533 | !strncmp(info->strtab + sym->st_name, | ||
1534 | "__mstrtab_", sizeof "__mstrtab_" - 1)) { | ||
1535 | if (first_sym == NULL) | ||
1536 | first_sym = sym; | ||
1537 | last_sym = sym; | ||
1538 | ++n; | ||
1539 | } | ||
1540 | |||
1541 | if (n == 0) | ||
1542 | return; | ||
1543 | |||
1544 | /* | ||
1545 | * Now collect each name and format into a line for the output. | ||
1546 | * Lines look like: | ||
1547 | * marker_name vmlinux marker %s format %d | ||
1548 | * The format string after the second \t can use whitespace. | ||
1549 | */ | ||
1550 | mod->markers = NOFAIL(malloc(sizeof mod->markers[0] * n)); | ||
1551 | mod->nmarkers = n; | ||
1552 | |||
1553 | n = 0; | ||
1554 | for (sym = first_sym; sym <= last_sym; sym++) | ||
1555 | if (ELF_ST_TYPE(sym->st_info) == STT_OBJECT && | ||
1556 | sym->st_shndx == info->markers_strings_sec && | ||
1557 | !strncmp(info->strtab + sym->st_name, | ||
1558 | "__mstrtab_", sizeof "__mstrtab_" - 1)) { | ||
1559 | const char *name = strings + sym->st_value; | ||
1560 | const char *fmt = strchr(name, '\0') + 1; | ||
1561 | char *line = NULL; | ||
1562 | asprintf(&line, "%s\t%s\t%s\n", name, mod->name, fmt); | ||
1563 | NOFAIL(line); | ||
1564 | mod->markers[n++] = line; | ||
1565 | } | ||
1566 | } | ||
1567 | |||
1568 | static void read_symbols(char *modname) | 1519 | static void read_symbols(char *modname) |
1569 | { | 1520 | { |
1570 | const char *symname; | 1521 | const char *symname; |
@@ -1620,8 +1571,6 @@ static void read_symbols(char *modname) | |||
1620 | get_src_version(modname, mod->srcversion, | 1571 | get_src_version(modname, mod->srcversion, |
1621 | sizeof(mod->srcversion)-1); | 1572 | sizeof(mod->srcversion)-1); |
1622 | 1573 | ||
1623 | get_markers(&info, mod); | ||
1624 | |||
1625 | parse_elf_finish(&info); | 1574 | parse_elf_finish(&info); |
1626 | 1575 | ||
1627 | /* Our trick to get versioning for module struct etc. - it's | 1576 | /* Our trick to get versioning for module struct etc. - it's |
@@ -1976,96 +1925,6 @@ static void write_dump(const char *fname) | |||
1976 | write_if_changed(&buf, fname); | 1925 | write_if_changed(&buf, fname); |
1977 | } | 1926 | } |
1978 | 1927 | ||
1979 | static void add_marker(struct module *mod, const char *name, const char *fmt) | ||
1980 | { | ||
1981 | char *line = NULL; | ||
1982 | asprintf(&line, "%s\t%s\t%s\n", name, mod->name, fmt); | ||
1983 | NOFAIL(line); | ||
1984 | |||
1985 | mod->markers = NOFAIL(realloc(mod->markers, ((mod->nmarkers + 1) * | ||
1986 | sizeof mod->markers[0]))); | ||
1987 | mod->markers[mod->nmarkers++] = line; | ||
1988 | } | ||
1989 | |||
1990 | static void read_markers(const char *fname) | ||
1991 | { | ||
1992 | unsigned long size, pos = 0; | ||
1993 | void *file = grab_file(fname, &size); | ||
1994 | char *line; | ||
1995 | |||
1996 | if (!file) /* No old markers, silently ignore */ | ||
1997 | return; | ||
1998 | |||
1999 | while ((line = get_next_line(&pos, file, size))) { | ||
2000 | char *marker, *modname, *fmt; | ||
2001 | struct module *mod; | ||
2002 | |||
2003 | marker = line; | ||
2004 | modname = strchr(marker, '\t'); | ||
2005 | if (!modname) | ||
2006 | goto fail; | ||
2007 | *modname++ = '\0'; | ||
2008 | fmt = strchr(modname, '\t'); | ||
2009 | if (!fmt) | ||
2010 | goto fail; | ||
2011 | *fmt++ = '\0'; | ||
2012 | if (*marker == '\0' || *modname == '\0') | ||
2013 | goto fail; | ||
2014 | |||
2015 | mod = find_module(modname); | ||
2016 | if (!mod) { | ||
2017 | mod = new_module(modname); | ||
2018 | mod->skip = 1; | ||
2019 | } | ||
2020 | if (is_vmlinux(modname)) { | ||
2021 | have_vmlinux = 1; | ||
2022 | mod->skip = 0; | ||
2023 | } | ||
2024 | |||
2025 | if (!mod->skip) | ||
2026 | add_marker(mod, marker, fmt); | ||
2027 | } | ||
2028 | release_file(file, size); | ||
2029 | return; | ||
2030 | fail: | ||
2031 | fatal("parse error in markers list file\n"); | ||
2032 | } | ||
2033 | |||
2034 | static int compare_strings(const void *a, const void *b) | ||
2035 | { | ||
2036 | return strcmp(*(const char **) a, *(const char **) b); | ||
2037 | } | ||
2038 | |||
2039 | static void write_markers(const char *fname) | ||
2040 | { | ||
2041 | struct buffer buf = { }; | ||
2042 | struct module *mod; | ||
2043 | size_t i; | ||
2044 | |||
2045 | for (mod = modules; mod; mod = mod->next) | ||
2046 | if ((!external_module || !mod->skip) && mod->markers != NULL) { | ||
2047 | /* | ||
2048 | * Sort the strings so we can skip duplicates when | ||
2049 | * we write them out. | ||
2050 | */ | ||
2051 | qsort(mod->markers, mod->nmarkers, | ||
2052 | sizeof mod->markers[0], &compare_strings); | ||
2053 | for (i = 0; i < mod->nmarkers; ++i) { | ||
2054 | char *line = mod->markers[i]; | ||
2055 | buf_write(&buf, line, strlen(line)); | ||
2056 | while (i + 1 < mod->nmarkers && | ||
2057 | !strcmp(mod->markers[i], | ||
2058 | mod->markers[i + 1])) | ||
2059 | free(mod->markers[i++]); | ||
2060 | free(mod->markers[i]); | ||
2061 | } | ||
2062 | free(mod->markers); | ||
2063 | mod->markers = NULL; | ||
2064 | } | ||
2065 | |||
2066 | write_if_changed(&buf, fname); | ||
2067 | } | ||
2068 | |||
2069 | struct ext_sym_list { | 1928 | struct ext_sym_list { |
2070 | struct ext_sym_list *next; | 1929 | struct ext_sym_list *next; |
2071 | const char *file; | 1930 | const char *file; |
@@ -2077,8 +1936,6 @@ int main(int argc, char **argv) | |||
2077 | struct buffer buf = { }; | 1936 | struct buffer buf = { }; |
2078 | char *kernel_read = NULL, *module_read = NULL; | 1937 | char *kernel_read = NULL, *module_read = NULL; |
2079 | char *dump_write = NULL; | 1938 | char *dump_write = NULL; |
2080 | char *markers_read = NULL; | ||
2081 | char *markers_write = NULL; | ||
2082 | int opt; | 1939 | int opt; |
2083 | int err; | 1940 | int err; |
2084 | struct ext_sym_list *extsym_iter; | 1941 | struct ext_sym_list *extsym_iter; |
@@ -2122,12 +1979,6 @@ int main(int argc, char **argv) | |||
2122 | case 'w': | 1979 | case 'w': |
2123 | warn_unresolved = 1; | 1980 | warn_unresolved = 1; |
2124 | break; | 1981 | break; |
2125 | case 'M': | ||
2126 | markers_write = optarg; | ||
2127 | break; | ||
2128 | case 'K': | ||
2129 | markers_read = optarg; | ||
2130 | break; | ||
2131 | default: | 1982 | default: |
2132 | exit(1); | 1983 | exit(1); |
2133 | } | 1984 | } |
@@ -2182,11 +2033,5 @@ int main(int argc, char **argv) | |||
2182 | "'make CONFIG_DEBUG_SECTION_MISMATCH=y'\n", | 2033 | "'make CONFIG_DEBUG_SECTION_MISMATCH=y'\n", |
2183 | sec_mismatch_count); | 2034 | sec_mismatch_count); |
2184 | 2035 | ||
2185 | if (markers_read) | ||
2186 | read_markers(markers_read); | ||
2187 | |||
2188 | if (markers_write) | ||
2189 | write_markers(markers_write); | ||
2190 | |||
2191 | return err; | 2036 | return err; |
2192 | } | 2037 | } |
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 09f58e33d227..be987a44f250 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h | |||
@@ -112,8 +112,6 @@ struct module { | |||
112 | int has_init; | 112 | int has_init; |
113 | int has_cleanup; | 113 | int has_cleanup; |
114 | struct buffer dev_table_buf; | 114 | struct buffer dev_table_buf; |
115 | char **markers; | ||
116 | size_t nmarkers; | ||
117 | char srcversion[25]; | 115 | char srcversion[25]; |
118 | }; | 116 | }; |
119 | 117 | ||
@@ -128,7 +126,6 @@ struct elf_info { | |||
128 | Elf_Section export_gpl_sec; | 126 | Elf_Section export_gpl_sec; |
129 | Elf_Section export_unused_gpl_sec; | 127 | Elf_Section export_unused_gpl_sec; |
130 | Elf_Section export_gpl_future_sec; | 128 | Elf_Section export_gpl_future_sec; |
131 | Elf_Section markers_strings_sec; | ||
132 | const char *strtab; | 129 | const char *strtab; |
133 | char *modinfo; | 130 | char *modinfo; |
134 | unsigned int modinfo_len; | 131 | unsigned int modinfo_len; |