Root/target/linux/generic/patches-3.7/220-module_exports.patch

1--- a/include/asm-generic/vmlinux.lds.h
2+++ b/include/asm-generic/vmlinux.lds.h
3@@ -52,6 +52,18 @@
4 #define LOAD_OFFSET 0
5 #endif
6 
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+*)
11+#endif
12+
13+#ifndef SYMTAB_DISCARD
14+#define SYMTAB_DISCARD
15+#define SYMTAB_DISCARD_GPL
16+#define SYMTAB_DISCARD_STR
17+#endif
18+
19 #ifndef SYMBOL_PREFIX
20 #define VMLINUX_SYMBOL(sym) sym
21 #else
22@@ -276,14 +288,14 @@
23     /* Kernel symbol table: Normal symbols */ \
24     __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
25         VMLINUX_SYMBOL(__start___ksymtab) = .; \
26- *(SORT(___ksymtab+*)) \
27+ SYMTAB_KEEP \
28         VMLINUX_SYMBOL(__stop___ksymtab) = .; \
29     } \
30                                     \
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+*)) \
35+ SYMTAB_KEEP_GPL \
36         VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
37     } \
38                                     \
39@@ -345,7 +357,7 @@
40                                     \
41     /* Kernel symbol table: strings */ \
42         __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
43- *(__ksymtab_strings) \
44+ SYMTAB_KEEP_STR \
45     } \
46                                     \
47     /* __*init sections */ \
48@@ -679,6 +691,9 @@
49     EXIT_TEXT \
50     EXIT_DATA \
51     EXIT_CALL \
52+ SYMTAB_DISCARD \
53+ SYMTAB_DISCARD_GPL \
54+ SYMTAB_DISCARD_STR \
55     *(.discard) \
56     *(.discard.*) \
57     }
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)
62 #endif
63 
64+#ifdef MODULE
65+#define __EXPORT_SUFFIX(sym)
66+#else
67+#define __EXPORT_SUFFIX(sym) "+" #sym
68+#endif
69+
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 \
80     __used \
81--- a/scripts/Makefile.build
82+++ b/scripts/Makefile.build
83@@ -348,7 +348,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 $@ $<
90 
91 $(obj)/%.lds: $(src)/%.lds.S FORCE
92

Archive Download this file



interactive