kernel: refresh patches
[openwrt/svn-archive/archive.git] / target / linux / generic / patches-2.6.35 / 028-module_exports.patch
1 --- a/include/asm-generic/vmlinux.lds.h
2 +++ b/include/asm-generic/vmlinux.lds.h
3 @@ -52,6 +52,27 @@
4 #define LOAD_OFFSET 0
5 #endif
6
7 +#ifndef SYMTAB_KEEP_STR
8 +#define SYMTAB_KEEP_STR *(__ksymtab_strings.*)
9 +#define SYMTAB_DISCARD_STR
10 +#else
11 +#define SYMTAB_DISCARD_STR *(__ksymtab_strings.*)
12 +#endif
13 +
14 +#ifndef SYMTAB_KEEP
15 +#define SYMTAB_KEEP *(__ksymtab.*)
16 +#define SYMTAB_DISCARD
17 +#else
18 +#define SYMTAB_DISCARD *(__ksymtab.*)
19 +#endif
20 +
21 +#ifndef SYMTAB_KEEP_GPL
22 +#define SYMTAB_KEEP_GPL *(__ksymtab_gpl.*)
23 +#define SYMTAB_DISCARD_GPL
24 +#else
25 +#define SYMTAB_DISCARD_GPL *(__ksymtab_gpl.*)
26 +#endif
27 +
28 #ifndef SYMBOL_PREFIX
29 #define VMLINUX_SYMBOL(sym) sym
30 #else
31 @@ -258,35 +279,35 @@
32 /* Kernel symbol table: Normal symbols */ \
33 __ksymtab : AT(ADDR(__ksymtab) - LOAD_OFFSET) { \
34 VMLINUX_SYMBOL(__start___ksymtab) = .; \
35 - *(__ksymtab) \
36 + SYMTAB_KEEP \
37 VMLINUX_SYMBOL(__stop___ksymtab) = .; \
38 } \
39 \
40 /* Kernel symbol table: GPL-only symbols */ \
41 __ksymtab_gpl : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) { \
42 VMLINUX_SYMBOL(__start___ksymtab_gpl) = .; \
43 - *(__ksymtab_gpl) \
44 + SYMTAB_KEEP_GPL \
45 VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .; \
46 } \
47 \
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) = .; \
54 } \
55 \
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) = .; \
62 } \
63 \
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) = .; \
70 } \
71 \
72 @@ -327,7 +348,7 @@
73 \
74 /* Kernel symbol table: strings */ \
75 __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
76 - *(__ksymtab_strings) \
77 + SYMTAB_KEEP_STR \
78 } \
79 \
80 /* __*init sections */ \
81 @@ -642,6 +663,9 @@
82 EXIT_TEXT \
83 EXIT_DATA \
84 EXIT_CALL \
85 + SYMTAB_DISCARD \
86 + SYMTAB_DISCARD_GPL \
87 + SYMTAB_DISCARD_STR \
88 *(.discard) \
89 }
90
91 --- a/include/linux/module.h
92 +++ b/include/linux/module.h
93 @@ -202,16 +202,24 @@ struct module_use {
94 #define __CRC_SYMBOL(sym, sec)
95 #endif
96
97 +#ifdef MODULE
98 +#define __EXPORT_SUFFIX(sym)
99 +#else
100 +#define __EXPORT_SUFFIX(sym) "." #sym
101 +#endif
102 +
103 /* For every exported symbol, place a struct in the __ksymtab section */
104 #define __EXPORT_SYMBOL(sym, sec) \
105 extern typeof(sym) sym; \
106 __CRC_SYMBOL(sym, sec) \
107 static const char __kstrtab_##sym[] \
108 - __attribute__((section("__ksymtab_strings"), aligned(1))) \
109 + __attribute__((section("__ksymtab_strings" \
110 + __EXPORT_SUFFIX(sym)), aligned(1))) \
111 = MODULE_SYMBOL_PREFIX #sym; \
112 static const struct kernel_symbol __ksymtab_##sym \
113 __used \
114 - __attribute__((section("__ksymtab" sec), unused)) \
115 + __attribute__((section("__ksymtab" sec \
116 + __EXPORT_SUFFIX(sym)), unused)) \
117 = { (unsigned long)&sym, __kstrtab_##sym }
118
119 #define EXPORT_SYMBOL(sym) \