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 *(SORT(___ksymtab+*))
9 +#define SYMTAB_KEEP_GPL *(SORT(___ksymtab_gpl+*))
10 +#define SYMTAB_KEEP_STR *(__ksymtab_strings+*)
13 +#ifndef SYMTAB_DISCARD
14 +#define SYMTAB_DISCARD
15 +#define SYMTAB_DISCARD_GPL
16 +#define SYMTAB_DISCARD_STR
20 #define VMLINUX_SYMBOL(sym) sym
23 /* Kernel symbol table: Normal symbols */ \
24 __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
25 VMLINUX_SYMBOL(__start___ksymtab) = .; \
26 - *(SORT(___ksymtab+*)) \
28 VMLINUX_SYMBOL(__stop___ksymtab) = .; \
31 /* Kernel symbol table: GPL-only symbols */ \
32 __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
33 VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \
34 - *(SORT(___ksymtab_gpl+*)) \
36 VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
41 /* Kernel symbol table: strings */ \
42 __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
43 - *(__ksymtab_strings) \
47 /* __*init sections */ \
53 + SYMTAB_DISCARD_GPL \
54 + SYMTAB_DISCARD_STR \
58 --- a/include/linux/export.h
59 +++ b/include/linux/export.h
60 @@ -45,12 +45,19 @@ extern struct module __this_module;
61 #define __CRC_SYMBOL(sym, sec)
65 +#define __EXPORT_SUFFIX(sym)
67 +#define __EXPORT_SUFFIX(sym) "+" #sym
70 /* For every exported symbol, place a struct in the __ksymtab section */
71 #define __EXPORT_SYMBOL(sym, sec) \
72 extern typeof(sym) sym; \
73 __CRC_SYMBOL(sym, sec) \
74 static const char __kstrtab_##sym[] \
75 - __attribute__((section("__ksymtab_strings"), aligned(1))) \
76 + __attribute__((section("__ksymtab_strings" \
77 + __EXPORT_SUFFIX(sym)), aligned(1))) \
78 = MODULE_SYMBOL_PREFIX #sym; \
79 static const struct kernel_symbol __ksymtab_##sym \
81 --- a/scripts/Makefile.build
82 +++ b/scripts/Makefile.build
83 @@ -346,7 +346,7 @@ targets += $(extra-y) $(MAKECMDGOALS) $(
84 # Linker scripts preprocessor (.lds.S -> .lds)
85 # ---------------------------------------------------------------------------
86 quiet_cmd_cpp_lds_S = LDS $@
87 - cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \
88 + cmd_cpp_lds_S = $(CPP) $(EXTRA_LDSFLAGS) $(cpp_flags) -P -C -U$(ARCH) \
89 -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<
91 $(obj)/%.lds: $(src)/%.lds.S FORCE