[kernel] update to 2.6.31.5
[openwrt.git] / target / linux / generic-2.6 / patches-2.6.31 / 028-module_exports.patch
1 Index: linux-2.6.31.5/include/asm-generic/vmlinux.lds.h
2 ===================================================================
3 --- linux-2.6.31.5.orig/include/asm-generic/vmlinux.lds.h       2009-10-23 00:57:56.000000000 +0200
4 +++ linux-2.6.31.5/include/asm-generic/vmlinux.lds.h    2009-10-23 12:43:50.000000000 +0200
5 @@ -55,6 +55,27 @@
6  #define LOAD_OFFSET 0
7  #endif
8  
9 +#ifndef SYMTAB_KEEP_STR
10 +#define SYMTAB_KEEP_STR *(__ksymtab_strings.*)
11 +#define SYMTAB_DISCARD_STR
12 +#else
13 +#define SYMTAB_DISCARD_STR *(__ksymtab_strings.*)
14 +#endif
15 +
16 +#ifndef SYMTAB_KEEP
17 +#define SYMTAB_KEEP *(__ksymtab.*)
18 +#define SYMTAB_DISCARD
19 +#else
20 +#define SYMTAB_DISCARD *(__ksymtab.*)
21 +#endif
22 +
23 +#ifndef SYMTAB_KEEP_GPL
24 +#define SYMTAB_KEEP_GPL *(__ksymtab_gpl.*)
25 +#define SYMTAB_DISCARD_GPL
26 +#else
27 +#define SYMTAB_DISCARD_GPL *(__ksymtab_gpl.*)
28 +#endif
29 +
30  #ifndef VMLINUX_SYMBOL
31  #define VMLINUX_SYMBOL(_sym_) _sym_
32  #endif
33 @@ -256,35 +277,35 @@
34         /* Kernel symbol table: Normal symbols */                       \
35         __ksymtab         : AT(ADDR(__ksymtab) - LOAD_OFFSET) {         \
36                 VMLINUX_SYMBOL(__start___ksymtab) = .;                  \
37 -               *(__ksymtab)                                            \
38 +               SYMTAB_KEEP                                             \
39                 VMLINUX_SYMBOL(__stop___ksymtab) = .;                   \
40         }                                                               \
41                                                                         \
42         /* Kernel symbol table: GPL-only symbols */                     \
43         __ksymtab_gpl     : AT(ADDR(__ksymtab_gpl) - LOAD_OFFSET) {     \
44                 VMLINUX_SYMBOL(__start___ksymtab_gpl) = .;              \
45 -               *(__ksymtab_gpl)                                        \
46 +               SYMTAB_KEEP_GPL                                         \
47                 VMLINUX_SYMBOL(__stop___ksymtab_gpl) = .;               \
48         }                                                               \
49                                                                         \
50         /* Kernel symbol table: Normal unused symbols */                \
51         __ksymtab_unused  : AT(ADDR(__ksymtab_unused) - LOAD_OFFSET) {  \
52                 VMLINUX_SYMBOL(__start___ksymtab_unused) = .;           \
53 -               *(__ksymtab_unused)                                     \
54 +               *(__ksymtab_unused.*)                                   \
55                 VMLINUX_SYMBOL(__stop___ksymtab_unused) = .;            \
56         }                                                               \
57                                                                         \
58         /* Kernel symbol table: GPL-only unused symbols */              \
59         __ksymtab_unused_gpl : AT(ADDR(__ksymtab_unused_gpl) - LOAD_OFFSET) { \
60                 VMLINUX_SYMBOL(__start___ksymtab_unused_gpl) = .;       \
61 -               *(__ksymtab_unused_gpl)                                 \
62 +               *(__ksymtab_unused_gpl.*)                               \
63                 VMLINUX_SYMBOL(__stop___ksymtab_unused_gpl) = .;        \
64         }                                                               \
65                                                                         \
66         /* Kernel symbol table: GPL-future-only symbols */              \
67         __ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - LOAD_OFFSET) { \
68                 VMLINUX_SYMBOL(__start___ksymtab_gpl_future) = .;       \
69 -               *(__ksymtab_gpl_future)                                 \
70 +               *(__ksymtab_gpl_future.*)                               \
71                 VMLINUX_SYMBOL(__stop___ksymtab_gpl_future) = .;        \
72         }                                                               \
73                                                                         \
74 @@ -325,7 +346,13 @@
75                                                                         \
76         /* Kernel symbol table: strings */                              \
77          __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) {        \
78 -               *(__ksymtab_strings)                                    \
79 +               SYMTAB_KEEP_STR                                         \
80 +       }                                                               \
81 +                                                                       \
82 +       /DISCARD/ : {                                                   \
83 +               SYMTAB_DISCARD                                          \
84 +               SYMTAB_DISCARD_GPL                                      \
85 +               SYMTAB_DISCARD_STR                                      \
86         }                                                               \
87                                                                         \
88         /* __*init sections */                                          \
89 Index: linux-2.6.31.5/include/linux/module.h
90 ===================================================================
91 --- linux-2.6.31.5.orig/include/linux/module.h  2009-10-23 00:57:56.000000000 +0200
92 +++ linux-2.6.31.5/include/linux/module.h       2009-10-23 12:43:50.000000000 +0200
93 @@ -188,16 +188,24 @@
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)                                     \
120 Index: linux-2.6.31.5/arch/arm/kernel/vmlinux.lds.S
121 ===================================================================
122 --- linux-2.6.31.5.orig/arch/arm/kernel/vmlinux.lds.S   2009-10-23 00:57:56.000000000 +0200
123 +++ linux-2.6.31.5/arch/arm/kernel/vmlinux.lds.S        2009-10-23 12:43:50.000000000 +0200
124 @@ -79,26 +79,6 @@
125  #endif
126         }
127  
128 -       /DISCARD/ : {                   /* Exit code and data           */
129 -               EXIT_TEXT
130 -               EXIT_DATA
131 -               *(.exitcall.exit)
132 -               *(.ARM.exidx.exit.text)
133 -               *(.ARM.extab.exit.text)
134 -#ifndef CONFIG_HOTPLUG_CPU
135 -               *(.ARM.exidx.cpuexit.text)
136 -               *(.ARM.extab.cpuexit.text)
137 -#endif
138 -#ifndef CONFIG_HOTPLUG
139 -               *(.ARM.exidx.devexit.text)
140 -               *(.ARM.extab.devexit.text)
141 -#endif
142 -#ifndef CONFIG_MMU
143 -               *(.fixup)
144 -               *(__ex_table)
145 -#endif
146 -       }
147 -
148         .text : {                       /* Real text segment            */
149                 _text = .;              /* Text and read-only data      */
150                         __exception_text_start = .;
151 @@ -205,6 +185,28 @@
152                 __bss_stop = .;
153                 _end = .;
154         }
155 +
156 +       /DISCARD/ : {                   /* Exit code and data           */
157 +               EXIT_TEXT
158 +               EXIT_DATA
159 +               *(.discard)
160 +               *(.exitcall.exit)
161 +               *(.ARM.exidx.exit.text)
162 +               *(.ARM.extab.exit.text)
163 +#ifndef CONFIG_HOTPLUG_CPU
164 +               *(.ARM.exidx.cpuexit.text)
165 +               *(.ARM.extab.cpuexit.text)
166 +#endif
167 +#ifndef CONFIG_HOTPLUG
168 +               *(.ARM.exidx.devexit.text)
169 +               *(.ARM.extab.devexit.text)
170 +#endif
171 +#ifndef CONFIG_MMU
172 +               *(.fixup)
173 +               *(__ex_table)
174 +#endif
175 +       }
176 +
177                                         /* Stabs debugging sections.    */
178         .stab 0 : { *(.stab) }
179         .stabstr 0 : { *(.stabstr) }
180 Index: linux-2.6.31.5/arch/powerpc/kernel/vmlinux.lds.S
181 ===================================================================
182 --- linux-2.6.31.5.orig/arch/powerpc/kernel/vmlinux.lds.S       2009-10-23 00:57:56.000000000 +0200
183 +++ linux-2.6.31.5/arch/powerpc/kernel/vmlinux.lds.S    2009-10-23 12:43:50.000000000 +0200
184 @@ -37,12 +37,6 @@
185  #endif
186  SECTIONS
187  {
188 -       /* Sections to be discarded. */
189 -       /DISCARD/ : {
190 -       *(.exitcall.exit)
191 -       EXIT_DATA
192 -       }
193 -
194         . = KERNELBASE;
195  
196  /*
197 @@ -295,6 +289,12 @@
198                 __bss_stop = .;
199         }
200  
201 +       /* Sections to be discarded. */
202 +       /DISCARD/ : {
203 +       *(.exitcall.exit)
204 +       EXIT_DATA
205 +       }
206 +
207         . = ALIGN(PAGE_SIZE);
208         _end = . ;
209         PROVIDE32 (end = .);