[ar7] switch to 2.6.30.4
[openwrt/svn-archive/archive.git] / target / linux / generic-2.6 / patches-2.6.28 / 027-module_exports.patch
1 --- a/Makefile
2 +++ b/Makefile
3 @@ -963,7 +963,7 @@ prepare: prepare0
4 # Leave this as default for preprocessing vmlinux.lds.S, which is now
5 # done in arch/$(ARCH)/kernel/Makefile
6
7 -export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH)
8 +export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH) $(EXTRA_LDSFLAGS)
9
10 # The asm symlink changes when $(ARCH) changes.
11 # Detect this and ask user to run make mrproper
12 --- a/include/asm-generic/vmlinux.lds.h
13 +++ b/include/asm-generic/vmlinux.lds.h
14 @@ -2,6 +2,18 @@
15 #define LOAD_OFFSET 0
16 #endif
17
18 +#ifndef SYMTAB_KEEP_STR
19 +#define SYMTAB_KEEP_STR *(__ksymtab_strings.*)
20 +#endif
21 +
22 +#ifndef SYMTAB_KEEP
23 +#define SYMTAB_KEEP *(__ksymtab.*)
24 +#endif
25 +
26 +#ifndef SYMTAB_KEEP_GPL
27 +#define SYMTAB_KEEP_GPL *(__ksymtab_gpl.*)
28 +#endif
29 +
30 #ifndef VMLINUX_SYMBOL
31 #define VMLINUX_SYMBOL(_sym_) _sym_
32 #endif
33 @@ -124,35 +136,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 @@ -193,7 +205,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 + *(__ksymtab.*) \
84 + *(__ksymtab_gpl.*) \
85 + *(__ksymtab_strings.*) \
86 } \
87 \
88 /* __*init sections */ \
89 --- a/include/linux/module.h
90 +++ b/include/linux/module.h
91 @@ -187,16 +187,24 @@ void *__symbol_get_gpl(const char *symbo
92 #define __CRC_SYMBOL(sym, sec)
93 #endif
94
95 +#ifdef MODULE
96 +#define __EXPORT_SUFFIX(sym)
97 +#else
98 +#define __EXPORT_SUFFIX(sym) "." #sym
99 +#endif
100 +
101 /* For every exported symbol, place a struct in the __ksymtab section */
102 #define __EXPORT_SYMBOL(sym, sec) \
103 extern typeof(sym) sym; \
104 __CRC_SYMBOL(sym, sec) \
105 static const char __kstrtab_##sym[] \
106 - __attribute__((section("__ksymtab_strings"), aligned(1))) \
107 + __attribute__((section("__ksymtab_strings" \
108 + __EXPORT_SUFFIX(sym)), aligned(1))) \
109 = MODULE_SYMBOL_PREFIX #sym; \
110 static const struct kernel_symbol __ksymtab_##sym \
111 __used \
112 - __attribute__((section("__ksymtab" sec), unused)) \
113 + __attribute__((section("__ksymtab" sec \
114 + __EXPORT_SUFFIX(sym)), unused)) \
115 = { (unsigned long)&sym, __kstrtab_##sym }
116
117 #define EXPORT_SYMBOL(sym) \