kernel: add support for 3.9-rc2
[openwrt/openwrt.git] / target / linux / generic / patches-3.9 / 221-module_exports.patch
1 --- a/include/asm-generic/vmlinux.lds.h
2 +++ b/include/asm-generic/vmlinux.lds.h
3 @@ -52,6 +52,16 @@
4 #define LOAD_OFFSET 0
5 #endif
6
7 +#ifndef SYMTAB_KEEP
8 +#define SYMTAB_KEEP KEEP(*(SORT(___ksymtab+*)))
9 +#define SYMTAB_KEEP_GPL KEEP(*(SORT(___ksymtab_gpl+*)))
10 +#endif
11 +
12 +#ifndef SYMTAB_DISCARD
13 +#define SYMTAB_DISCARD
14 +#define SYMTAB_DISCARD_GPL
15 +#endif
16 +
17 #ifndef SYMBOL_PREFIX
18 #define VMLINUX_SYMBOL(sym) sym
19 #else
20 @@ -304,14 +314,14 @@
21 /* Kernel symbol table: Normal symbols */ \
22 __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
23 VMLINUX_SYMBOL(__start___ksymtab) = .; \
24 - KEEP(*(SORT(___ksymtab+*))) \
25 + SYMTAB_KEEP \
26 VMLINUX_SYMBOL(__stop___ksymtab) = .; \
27 } \
28 \
29 /* Kernel symbol table: GPL-only symbols */ \
30 __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
31 VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \
32 - KEEP(*(SORT(___ksymtab_gpl+*))) \
33 + SYMTAB_KEEP_GPL \
34 VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
35 } \
36 \
37 @@ -373,7 +383,7 @@
38 \
39 /* Kernel symbol table: strings */ \
40 __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
41 - *(__ksymtab_strings) \
42 + *(__ksymtab_strings+*) \
43 } \
44 \
45 /* __*init sections */ \
46 @@ -710,6 +720,8 @@
47 EXIT_TEXT \
48 EXIT_DATA \
49 EXIT_CALL \
50 + SYMTAB_DISCARD \
51 + SYMTAB_DISCARD_GPL \
52 *(.discard) \
53 *(.discard.*) \
54 }
55 --- a/scripts/Makefile.build
56 +++ b/scripts/Makefile.build
57 @@ -348,7 +348,7 @@ targets += $(extra-y) $(MAKECMDGOALS) $(
58 # Linker scripts preprocessor (.lds.S -> .lds)
59 # ---------------------------------------------------------------------------
60 quiet_cmd_cpp_lds_S = LDS $@
61 - cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \
62 + cmd_cpp_lds_S = $(CPP) $(EXTRA_LDSFLAGS) $(cpp_flags) -P -C -U$(ARCH) \
63 -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $<
64
65 $(obj)/%.lds: $(src)/%.lds.S FORCE
66 --- a/include/linux/export.h
67 +++ b/include/linux/export.h
68 @@ -45,12 +45,19 @@ extern struct module __this_module;
69 #define __CRC_SYMBOL(sym, sec)
70 #endif
71
72 +#ifdef MODULE
73 +#define __EXPORT_SUFFIX(sym)
74 +#else
75 +#define __EXPORT_SUFFIX(sym) "+" #sym
76 +#endif
77 +
78 /* For every exported symbol, place a struct in the __ksymtab section */
79 #define __EXPORT_SYMBOL(sym, sec) \
80 extern typeof(sym) sym; \
81 __CRC_SYMBOL(sym, sec) \
82 static const char __kstrtab_##sym[] \
83 - __attribute__((section("__ksymtab_strings"), aligned(1))) \
84 + __attribute__((section("__ksymtab_strings" \
85 + __EXPORT_SUFFIX(sym)), aligned(1))) \
86 = MODULE_SYMBOL_PREFIX #sym; \
87 static const struct kernel_symbol __ksymtab_##sym \
88 __used \