1 --- a/include/asm-generic/vmlinux.lds.h
2 +++ b/include/asm-generic/vmlinux.lds.h
7 +#ifndef SYMTAB_KEEP_STR
8 +#define SYMTAB_KEEP_STR *(__ksymtab_strings.*)
9 +#define SYMTAB_DISCARD_STR
11 +#define SYMTAB_DISCARD_STR *(__ksymtab_strings.*)
15 +#define SYMTAB_KEEP *(__ksymtab.*)
16 +#define SYMTAB_DISCARD
18 +#define SYMTAB_DISCARD *(__ksymtab.*)
21 +#ifndef SYMTAB_KEEP_GPL
22 +#define SYMTAB_KEEP_GPL *(__ksymtab_gpl.*)
23 +#define SYMTAB_DISCARD_GPL
25 +#define SYMTAB_DISCARD_GPL *(__ksymtab_gpl.*)
28 #ifndef VMLINUX_SYMBOL
29 #define VMLINUX_SYMBOL(_sym_) _sym_
32 /* Kernel symbol table: Normal symbols */ \
33 __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
34 VMLINUX_SYMBOL(__start___ksymtab) = .; \
37 VMLINUX_SYMBOL(__stop___ksymtab) = .; \
40 /* Kernel symbol table: GPL-only symbols */ \
41 __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
42 VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \
45 VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
48 /* Kernel symbol table: Normal unused symbols */ \
49 __ksymtab_unused : AT(ADDR(__ksymtab_unused) - LOAD_OFFSET) { \
50 VMLINUX_SYMBOL(__start___ksymtab_unused) = .; \
51 - *(__ksymtab_unused) \
52 + *(__ksymtab_unused.*) \
53 VMLINUX_SYMBOL(__stop___ksymtab_unused) = .; \
56 /* Kernel symbol table: GPL-only unused symbols */ \
57 __ksymtab_unused_gpl : AT(ADDR(__ksymtab_unused_gpl) - LOAD_OFFSET) { \
58 VMLINUX_SYMBOL(__start___ksymtab_unused_gpl) = .; \
59 - *(__ksymtab_unused_gpl) \
60 + *(__ksymtab_unused_gpl.*) \
61 VMLINUX_SYMBOL(__stop___ksymtab_unused_gpl) = .; \
64 /* Kernel symbol table: GPL-future-only symbols */ \
65 __ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - LOAD_OFFSET) { \
66 VMLINUX_SYMBOL(__start___ksymtab_gpl_future) = .; \
67 - *(__ksymtab_gpl_future) \
68 + *(__ksymtab_gpl_future.*) \
69 VMLINUX_SYMBOL(__stop___ksymtab_gpl_future) = .; \
74 /* Kernel symbol table: strings */ \
75 __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
76 - *(__ksymtab_strings) \
82 + SYMTAB_DISCARD_GPL \
83 + SYMTAB_DISCARD_STR \
86 /* __*init sections */ \
87 --- a/include/linux/module.h
88 +++ b/include/linux/module.h
89 @@ -188,16 +188,24 @@ void *__symbol_get_gpl(const char *symbo
90 #define __CRC_SYMBOL(sym, sec)
94 +#define __EXPORT_SUFFIX(sym)
96 +#define __EXPORT_SUFFIX(sym) "." #sym
99 /* For every exported symbol, place a struct in the __ksymtab section */
100 #define __EXPORT_SYMBOL(sym, sec) \
101 extern typeof(sym) sym; \
102 __CRC_SYMBOL(sym, sec) \
103 static const char __kstrtab_##sym[] \
104 - __attribute__((section("__ksymtab_strings"), aligned(1))) \
105 + __attribute__((section("__ksymtab_strings" \
106 + __EXPORT_SUFFIX(sym)), aligned(1))) \
107 = MODULE_SYMBOL_PREFIX #sym; \
108 static const struct kernel_symbol __ksymtab_##sym \
110 - __attribute__((section("__ksymtab" sec), unused)) \
111 + __attribute__((section("__ksymtab" sec \
112 + __EXPORT_SUFFIX(sym)), unused)) \
113 = { (unsigned long)&sym, __kstrtab_##sym }
115 #define EXPORT_SYMBOL(sym) \
118 @@ -986,7 +986,7 @@ prepare: prepare0
119 # Leave this as default for preprocessing vmlinux.lds.S, which is now
120 # done in arch/$(ARCH)/kernel/Makefile
122 -export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH)
123 +export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH) $(EXTRA_LDSFLAGS)
125 # The asm symlink changes when $(ARCH) changes.
126 # Detect this and ask user to run make mrproper
127 --- a/arch/arm/kernel/vmlinux.lds.S
128 +++ b/arch/arm/kernel/vmlinux.lds.S
129 @@ -79,26 +79,6 @@ SECTIONS
133 - /DISCARD/ : { /* Exit code and data */
137 - *(.ARM.exidx.exit.text)
138 - *(.ARM.extab.exit.text)
139 -#ifndef CONFIG_HOTPLUG_CPU
140 - *(.ARM.exidx.cpuexit.text)
141 - *(.ARM.extab.cpuexit.text)
143 -#ifndef CONFIG_HOTPLUG
144 - *(.ARM.exidx.devexit.text)
145 - *(.ARM.extab.devexit.text)
153 .text : { /* Real text segment */
154 _text = .; /* Text and read-only data */
155 __exception_text_start = .;
156 @@ -205,6 +185,28 @@ SECTIONS
161 + /DISCARD/ : { /* Exit code and data */
166 + *(.ARM.exidx.exit.text)
167 + *(.ARM.extab.exit.text)
168 +#ifndef CONFIG_HOTPLUG_CPU
169 + *(.ARM.exidx.cpuexit.text)
170 + *(.ARM.extab.cpuexit.text)
172 +#ifndef CONFIG_HOTPLUG
173 + *(.ARM.exidx.devexit.text)
174 + *(.ARM.extab.devexit.text)
182 /* Stabs debugging sections. */
183 .stab 0 : { *(.stab) }
184 .stabstr 0 : { *(.stabstr) }
185 --- a/arch/powerpc/kernel/vmlinux.lds.S
186 +++ b/arch/powerpc/kernel/vmlinux.lds.S
187 @@ -37,12 +37,6 @@ jiffies = jiffies_64 + 4;
191 - /* Sections to be discarded. */
200 @@ -295,6 +289,12 @@ SECTIONS
204 + /* Sections to be discarded. */
210 . = ALIGN(PAGE_SIZE);