aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-07-24 12:54:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-24 12:54:54 -0400
commitfcda12e7f6d58d61997681a9d41779e3fd2ffc94 (patch)
treeea865215c10b8b09828db2918013dfe02ce62f25
parent5fabc487c96819dd12ddb9414835d170fd9cd6d5 (diff)
parent62a2635610dbc83c5e8d724e00941eee4d18c186 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus
* git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus: modpost: Fix modpost's license checking V3 module: add /sys/module/<name>/uevent files module: change attr callbacks to take struct module_kobject modules: make arch's use default loader hooks modules: add default loader hook implementations param: fix return value handling in param_set_*
-rw-r--r--arch/alpha/kernel/module.c34
-rw-r--r--arch/arm/kernel/module.c29
-rw-r--r--arch/avr32/kernel/module.c20
-rw-r--r--arch/blackfin/kernel/module.c21
-rw-r--r--arch/cris/kernel/module.c43
-rw-r--r--arch/frv/kernel/module.c57
-rw-r--r--arch/h8300/kernel/module.c45
-rw-r--r--arch/ia64/kernel/module.c16
-rw-r--r--arch/m32r/kernel/module.c38
-rw-r--r--arch/m68k/kernel/module_mm.c27
-rw-r--r--arch/m68k/kernel/module_no.c34
-rw-r--r--arch/microblaze/kernel/module.c35
-rw-r--r--arch/mips/kernel/module.c20
-rw-r--r--arch/mn10300/kernel/module.c61
-rw-r--r--arch/parisc/kernel/module.c12
-rw-r--r--arch/powerpc/kernel/module.c18
-rw-r--r--arch/powerpc/kernel/module_32.c11
-rw-r--r--arch/powerpc/kernel/module_64.c10
-rw-r--r--arch/s390/kernel/module.c20
-rw-r--r--arch/score/kernel/module.c29
-rw-r--r--arch/sh/kernel/module.c35
-rw-r--r--arch/sparc/kernel/module.c28
-rw-r--r--arch/tile/kernel/module.c31
-rw-r--r--arch/unicore32/kernel/module.c35
-rw-r--r--arch/x86/kernel/module.c37
-rw-r--r--arch/xtensa/kernel/module.c43
-rw-r--r--include/linux/module.h24
-rw-r--r--include/linux/moduleloader.h7
-rw-r--r--kernel/module.c80
-rw-r--r--kernel/params.c18
-rw-r--r--scripts/mod/modpost.c29
31 files changed, 143 insertions, 804 deletions
diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
index ebc3c894b5a2..2fd00b7077e4 100644
--- a/arch/alpha/kernel/module.c
+++ b/arch/alpha/kernel/module.c
@@ -29,20 +29,6 @@
29#define DEBUGP(fmt...) 29#define DEBUGP(fmt...)
30#endif 30#endif
31 31
32void *
33module_alloc(unsigned long size)
34{
35 if (size == 0)
36 return NULL;
37 return vmalloc(size);
38}
39
40void
41module_free(struct module *mod, void *module_region)
42{
43 vfree(module_region);
44}
45
46/* Allocate the GOT at the end of the core sections. */ 32/* Allocate the GOT at the end of the core sections. */
47 33
48struct got_entry { 34struct got_entry {
@@ -156,14 +142,6 @@ module_frob_arch_sections(Elf64_Ehdr *hdr, Elf64_Shdr *sechdrs,
156} 142}
157 143
158int 144int
159apply_relocate(Elf64_Shdr *sechdrs, const char *strtab, unsigned int symindex,
160 unsigned int relsec, struct module *me)
161{
162 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
163 return -ENOEXEC;
164}
165
166int
167apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab, 145apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
168 unsigned int symindex, unsigned int relsec, 146 unsigned int symindex, unsigned int relsec,
169 struct module *me) 147 struct module *me)
@@ -302,15 +280,3 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
302 280
303 return 0; 281 return 0;
304} 282}
305
306int
307module_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
308 struct module *me)
309{
310 return 0;
311}
312
313void
314module_arch_cleanup(struct module *mod)
315{
316}
diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index 016d6a0830a3..05b377616fd5 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -43,25 +43,7 @@ void *module_alloc(unsigned long size)
43 GFP_KERNEL, PAGE_KERNEL_EXEC, -1, 43 GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
44 __builtin_return_address(0)); 44 __builtin_return_address(0));
45} 45}
46#else /* CONFIG_MMU */ 46#endif
47void *module_alloc(unsigned long size)
48{
49 return size == 0 ? NULL : vmalloc(size);
50}
51#endif /* !CONFIG_MMU */
52
53void module_free(struct module *module, void *region)
54{
55 vfree(region);
56}
57
58int module_frob_arch_sections(Elf_Ehdr *hdr,
59 Elf_Shdr *sechdrs,
60 char *secstrings,
61 struct module *mod)
62{
63 return 0;
64}
65 47
66int 48int
67apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex, 49apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
@@ -265,15 +247,6 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
265 return 0; 247 return 0;
266} 248}
267 249
268int
269apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
270 unsigned int symindex, unsigned int relsec, struct module *module)
271{
272 printk(KERN_ERR "module %s: ADD RELOCATION unsupported\n",
273 module->name);
274 return -ENOEXEC;
275}
276
277struct mod_unwind_map { 250struct mod_unwind_map {
278 const Elf_Shdr *unw_sec; 251 const Elf_Shdr *unw_sec;
279 const Elf_Shdr *txt_sec; 252 const Elf_Shdr *txt_sec;
diff --git a/arch/avr32/kernel/module.c b/arch/avr32/kernel/module.c
index a727f54d64d6..596f7305d93f 100644
--- a/arch/avr32/kernel/module.c
+++ b/arch/avr32/kernel/module.c
@@ -19,13 +19,6 @@
19#include <linux/moduleloader.h> 19#include <linux/moduleloader.h>
20#include <linux/vmalloc.h> 20#include <linux/vmalloc.h>
21 21
22void *module_alloc(unsigned long size)
23{
24 if (size == 0)
25 return NULL;
26 return vmalloc(size);
27}
28
29void module_free(struct module *mod, void *module_region) 22void module_free(struct module *mod, void *module_region)
30{ 23{
31 vfree(mod->arch.syminfo); 24 vfree(mod->arch.syminfo);
@@ -299,15 +292,6 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
299 return ret; 292 return ret;
300} 293}
301 294
302int apply_relocate(Elf32_Shdr *sechdrs, const char *strtab,
303 unsigned int symindex, unsigned int relindex,
304 struct module *module)
305{
306 printk(KERN_ERR "module %s: REL relocations are not supported\n",
307 module->name);
308 return -ENOEXEC;
309}
310
311int module_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs, 295int module_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
312 struct module *module) 296 struct module *module)
313{ 297{
@@ -316,7 +300,3 @@ int module_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
316 300
317 return 0; 301 return 0;
318} 302}
319
320void module_arch_cleanup(struct module *module)
321{
322}
diff --git a/arch/blackfin/kernel/module.c b/arch/blackfin/kernel/module.c
index 35e350cad9d9..4489efc52883 100644
--- a/arch/blackfin/kernel/module.c
+++ b/arch/blackfin/kernel/module.c
@@ -16,19 +16,6 @@
16#include <asm/cacheflush.h> 16#include <asm/cacheflush.h>
17#include <asm/uaccess.h> 17#include <asm/uaccess.h>
18 18
19void *module_alloc(unsigned long size)
20{
21 if (size == 0)
22 return NULL;
23 return vmalloc(size);
24}
25
26/* Free memory returned from module_alloc */
27void module_free(struct module *mod, void *module_region)
28{
29 vfree(module_region);
30}
31
32/* Transfer the section to the L1 memory */ 19/* Transfer the section to the L1 memory */
33int 20int
34module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, 21module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
@@ -150,14 +137,6 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
150 return 0; 137 return 0;
151} 138}
152 139
153int
154apply_relocate(Elf_Shdr * sechdrs, const char *strtab,
155 unsigned int symindex, unsigned int relsec, struct module *mod)
156{
157 pr_err(".rel unsupported\n");
158 return -ENOEXEC;
159}
160
161/*************************************************************************/ 140/*************************************************************************/
162/* FUNCTION : apply_relocate_add */ 141/* FUNCTION : apply_relocate_add */
163/* ABSTRACT : Blackfin specific relocation handling for the loadable */ 142/* ABSTRACT : Blackfin specific relocation handling for the loadable */
diff --git a/arch/cris/kernel/module.c b/arch/cris/kernel/module.c
index bcd502f74cda..37400f5869e6 100644
--- a/arch/cris/kernel/module.c
+++ b/arch/cris/kernel/module.c
@@ -30,45 +30,19 @@
30#endif 30#endif
31 31
32#ifdef CONFIG_ETRAX_KMALLOCED_MODULES 32#ifdef CONFIG_ETRAX_KMALLOCED_MODULES
33#define MALLOC_MODULE(size) kmalloc(size, GFP_KERNEL)
34#define FREE_MODULE(region) kfree(region)
35#else
36#define MALLOC_MODULE(size) vmalloc_exec(size)
37#define FREE_MODULE(region) vfree(region)
38#endif
39
40void *module_alloc(unsigned long size) 33void *module_alloc(unsigned long size)
41{ 34{
42 if (size == 0) 35 if (size == 0)
43 return NULL; 36 return NULL;
44 return MALLOC_MODULE(size); 37 return kmalloc(size, GFP_KERNEL);
45} 38}
46 39
47
48/* Free memory returned from module_alloc */ 40/* Free memory returned from module_alloc */
49void module_free(struct module *mod, void *module_region) 41void module_free(struct module *mod, void *module_region)
50{ 42{
51 FREE_MODULE(module_region); 43 kfree(module_region);
52}
53
54/* We don't need anything special. */
55int module_frob_arch_sections(Elf_Ehdr *hdr,
56 Elf_Shdr *sechdrs,
57 char *secstrings,
58 struct module *mod)
59{
60 return 0;
61}
62
63int apply_relocate(Elf32_Shdr *sechdrs,
64 const char *strtab,
65 unsigned int symindex,
66 unsigned int relsec,
67 struct module *me)
68{
69 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70 return -ENOEXEC;
71} 44}
45#endif
72 46
73int apply_relocate_add(Elf32_Shdr *sechdrs, 47int apply_relocate_add(Elf32_Shdr *sechdrs,
74 const char *strtab, 48 const char *strtab,
@@ -108,14 +82,3 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
108 82
109 return 0; 83 return 0;
110} 84}
111
112int module_finalize(const Elf_Ehdr *hdr,
113 const Elf_Shdr *sechdrs,
114 struct module *me)
115{
116 return 0;
117}
118
119void module_arch_cleanup(struct module *mod)
120{
121}
diff --git a/arch/frv/kernel/module.c b/arch/frv/kernel/module.c
index 711763c8a6f3..9d9835f1fe2b 100644
--- a/arch/frv/kernel/module.c
+++ b/arch/frv/kernel/module.c
@@ -22,57 +22,6 @@
22#define DEBUGP(fmt...) 22#define DEBUGP(fmt...)
23#endif 23#endif
24 24
25void *module_alloc(unsigned long size) 25/* TODO: At least one of apply_relocate or apply_relocate_add must be
26{ 26 * implemented in order to get working module support.
27 if (size == 0) 27 */
28 return NULL;
29
30 return vmalloc_exec(size);
31}
32
33
34/* Free memory returned from module_alloc */
35void module_free(struct module *mod, void *module_region)
36{
37 vfree(module_region);
38}
39
40/* We don't need anything special. */
41int module_frob_arch_sections(Elf_Ehdr *hdr,
42 Elf_Shdr *sechdrs,
43 char *secstrings,
44 struct module *mod)
45{
46 return 0;
47}
48
49int apply_relocate(Elf32_Shdr *sechdrs,
50 const char *strtab,
51 unsigned int symindex,
52 unsigned int relsec,
53 struct module *me)
54{
55 printk(KERN_ERR "module %s: ADD RELOCATION unsupported\n", me->name);
56 return -ENOEXEC;
57}
58
59int apply_relocate_add(Elf32_Shdr *sechdrs,
60 const char *strtab,
61 unsigned int symindex,
62 unsigned int relsec,
63 struct module *me)
64{
65 printk(KERN_ERR "module %s: ADD RELOCATION unsupported\n", me->name);
66 return -ENOEXEC;
67}
68
69int module_finalize(const Elf_Ehdr *hdr,
70 const Elf_Shdr *sechdrs,
71 struct module *me)
72{
73 return 0;
74}
75
76void module_arch_cleanup(struct module *mod)
77{
78}
diff --git a/arch/h8300/kernel/module.c b/arch/h8300/kernel/module.c
index db4953dc4e1b..1d526e05db19 100644
--- a/arch/h8300/kernel/module.c
+++ b/arch/h8300/kernel/module.c
@@ -11,40 +11,6 @@
11#define DEBUGP(fmt...) 11#define DEBUGP(fmt...)
12#endif 12#endif
13 13
14void *module_alloc(unsigned long size)
15{
16 if (size == 0)
17 return NULL;
18 return vmalloc(size);
19}
20
21
22/* Free memory returned from module_alloc */
23void module_free(struct module *mod, void *module_region)
24{
25 vfree(module_region);
26}
27
28/* We don't need anything special. */
29int module_frob_arch_sections(Elf_Ehdr *hdr,
30 Elf_Shdr *sechdrs,
31 char *secstrings,
32 struct module *mod)
33{
34 return 0;
35}
36
37int apply_relocate(Elf32_Shdr *sechdrs,
38 const char *strtab,
39 unsigned int symindex,
40 unsigned int relsec,
41 struct module *me)
42{
43 printk(KERN_ERR "module %s: RELOCATION unsupported\n",
44 me->name);
45 return -ENOEXEC;
46}
47
48int apply_relocate_add(Elf32_Shdr *sechdrs, 14int apply_relocate_add(Elf32_Shdr *sechdrs,
49 const char *strtab, 15 const char *strtab,
50 unsigned int symindex, 16 unsigned int symindex,
@@ -107,14 +73,3 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
107 me->name, rela[i].r_offset); 73 me->name, rela[i].r_offset);
108 return -ENOEXEC; 74 return -ENOEXEC;
109} 75}
110
111int module_finalize(const Elf_Ehdr *hdr,
112 const Elf_Shdr *sechdrs,
113 struct module *me)
114{
115 return 0;
116}
117
118void module_arch_cleanup(struct module *mod)
119{
120}
diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
index 1481b0a28ca0..24603be24c14 100644
--- a/arch/ia64/kernel/module.c
+++ b/arch/ia64/kernel/module.c
@@ -304,14 +304,6 @@ plt_target (struct plt_entry *plt)
304 304
305#endif /* !USE_BRL */ 305#endif /* !USE_BRL */
306 306
307void *
308module_alloc (unsigned long size)
309{
310 if (!size)
311 return NULL;
312 return vmalloc(size);
313}
314
315void 307void
316module_free (struct module *mod, void *module_region) 308module_free (struct module *mod, void *module_region)
317{ 309{
@@ -853,14 +845,6 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
853 return 0; 845 return 0;
854} 846}
855 847
856int
857apply_relocate (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symindex,
858 unsigned int relsec, struct module *mod)
859{
860 printk(KERN_ERR "module %s: REL relocs in section %u unsupported\n", mod->name, relsec);
861 return -ENOEXEC;
862}
863
864/* 848/*
865 * Modules contain a single unwind table which covers both the core and the init text 849 * Modules contain a single unwind table which covers both the core and the init text
866 * sections but since the two are not contiguous, we need to split this table up such that 850 * sections but since the two are not contiguous, we need to split this table up such that
diff --git a/arch/m32r/kernel/module.c b/arch/m32r/kernel/module.c
index cb5f37d78d49..3071fe83ffc8 100644
--- a/arch/m32r/kernel/module.c
+++ b/arch/m32r/kernel/module.c
@@ -28,33 +28,6 @@
28#define DEBUGP(fmt...) 28#define DEBUGP(fmt...)
29#endif 29#endif
30 30
31void *module_alloc(unsigned long size)
32{
33 if (size == 0)
34 return NULL;
35#ifdef CONFIG_MMU
36 return vmalloc_exec(size);
37#else
38 return vmalloc(size);
39#endif
40}
41
42
43/* Free memory returned from module_alloc */
44void module_free(struct module *mod, void *module_region)
45{
46 vfree(module_region);
47}
48
49/* We don't need anything special. */
50int module_frob_arch_sections(Elf_Ehdr *hdr,
51 Elf_Shdr *sechdrs,
52 char *secstrings,
53 struct module *mod)
54{
55 return 0;
56}
57
58#define COPY_UNALIGNED_WORD(sw, tw, align) \ 31#define COPY_UNALIGNED_WORD(sw, tw, align) \
59{ \ 32{ \
60 void *__s = &(sw), *__t = &(tw); \ 33 void *__s = &(sw), *__t = &(tw); \
@@ -243,14 +216,3 @@ int apply_relocate(Elf32_Shdr *sechdrs,
243 return 0; 216 return 0;
244 217
245} 218}
246
247int module_finalize(const Elf_Ehdr *hdr,
248 const Elf_Shdr *sechdrs,
249 struct module *me)
250{
251 return 0;
252}
253
254void module_arch_cleanup(struct module *mod)
255{
256}
diff --git a/arch/m68k/kernel/module_mm.c b/arch/m68k/kernel/module_mm.c
index cd6bcb1c957e..ceafc47c96d5 100644
--- a/arch/m68k/kernel/module_mm.c
+++ b/arch/m68k/kernel/module_mm.c
@@ -19,29 +19,6 @@
19 19
20#ifdef CONFIG_MODULES 20#ifdef CONFIG_MODULES
21 21
22void *module_alloc(unsigned long size)
23{
24 if (size == 0)
25 return NULL;
26 return vmalloc(size);
27}
28
29
30/* Free memory returned from module_alloc */
31void module_free(struct module *mod, void *module_region)
32{
33 vfree(module_region);
34}
35
36/* We don't need anything special. */
37int module_frob_arch_sections(Elf_Ehdr *hdr,
38 Elf_Shdr *sechdrs,
39 char *secstrings,
40 struct module *mod)
41{
42 return 0;
43}
44
45int apply_relocate(Elf32_Shdr *sechdrs, 22int apply_relocate(Elf32_Shdr *sechdrs,
46 const char *strtab, 23 const char *strtab,
47 unsigned int symindex, 24 unsigned int symindex,
@@ -131,10 +108,6 @@ int module_finalize(const Elf_Ehdr *hdr,
131 return 0; 108 return 0;
132} 109}
133 110
134void module_arch_cleanup(struct module *mod)
135{
136}
137
138#endif /* CONFIG_MODULES */ 111#endif /* CONFIG_MODULES */
139 112
140void module_fixup(struct module *mod, struct m68k_fixup_info *start, 113void module_fixup(struct module *mod, struct m68k_fixup_info *start,
diff --git a/arch/m68k/kernel/module_no.c b/arch/m68k/kernel/module_no.c
index d11ffae7956a..5a097c6063fa 100644
--- a/arch/m68k/kernel/module_no.c
+++ b/arch/m68k/kernel/module_no.c
@@ -11,29 +11,6 @@
11#define DEBUGP(fmt...) 11#define DEBUGP(fmt...)
12#endif 12#endif
13 13
14void *module_alloc(unsigned long size)
15{
16 if (size == 0)
17 return NULL;
18 return vmalloc(size);
19}
20
21
22/* Free memory returned from module_alloc */
23void module_free(struct module *mod, void *module_region)
24{
25 vfree(module_region);
26}
27
28/* We don't need anything special. */
29int module_frob_arch_sections(Elf_Ehdr *hdr,
30 Elf_Shdr *sechdrs,
31 char *secstrings,
32 struct module *mod)
33{
34 return 0;
35}
36
37int apply_relocate(Elf32_Shdr *sechdrs, 14int apply_relocate(Elf32_Shdr *sechdrs,
38 const char *strtab, 15 const char *strtab,
39 unsigned int symindex, 16 unsigned int symindex,
@@ -113,14 +90,3 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
113 } 90 }
114 return 0; 91 return 0;
115} 92}
116
117int module_finalize(const Elf_Ehdr *hdr,
118 const Elf_Shdr *sechdrs,
119 struct module *me)
120{
121 return 0;
122}
123
124void module_arch_cleanup(struct module *mod)
125{
126}
diff --git a/arch/microblaze/kernel/module.c b/arch/microblaze/kernel/module.c
index 0e73f6606547..142426f631bb 100644
--- a/arch/microblaze/kernel/module.c
+++ b/arch/microblaze/kernel/module.c
@@ -18,37 +18,6 @@
18#include <asm/pgtable.h> 18#include <asm/pgtable.h>
19#include <asm/cacheflush.h> 19#include <asm/cacheflush.h>
20 20
21void *module_alloc(unsigned long size)
22{
23 void *ret;
24 ret = (size == 0) ? NULL : vmalloc(size);
25 pr_debug("module_alloc (%08lx@%08lx)\n", size, (unsigned long int)ret);
26 return ret;
27}
28
29void module_free(struct module *module, void *region)
30{
31 pr_debug("module_free(%s,%08lx)\n", module->name,
32 (unsigned long)region);
33 vfree(region);
34}
35
36int module_frob_arch_sections(Elf_Ehdr *hdr,
37 Elf_Shdr *sechdrs,
38 char *secstrings,
39 struct module *mod)
40{
41 return 0;
42}
43
44int apply_relocate(Elf32_Shdr *sechdrs, const char *strtab,
45 unsigned int symindex, unsigned int relsec, struct module *module)
46{
47 printk(KERN_ERR "module %s: ADD RELOCATION unsupported\n",
48 module->name);
49 return -ENOEXEC;
50}
51
52int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab, 21int apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
53 unsigned int symindex, unsigned int relsec, struct module *module) 22 unsigned int symindex, unsigned int relsec, struct module *module)
54{ 23{
@@ -155,7 +124,3 @@ int module_finalize(const Elf32_Ehdr *hdr, const Elf_Shdr *sechdrs,
155 flush_dcache(); 124 flush_dcache();
156 return 0; 125 return 0;
157} 126}
158
159void module_arch_cleanup(struct module *mod)
160{
161}
diff --git a/arch/mips/kernel/module.c b/arch/mips/kernel/module.c
index dd940b701963..4b930ac4aff2 100644
--- a/arch/mips/kernel/module.c
+++ b/arch/mips/kernel/module.c
@@ -45,30 +45,14 @@ static struct mips_hi16 *mips_hi16_list;
45static LIST_HEAD(dbe_list); 45static LIST_HEAD(dbe_list);
46static DEFINE_SPINLOCK(dbe_lock); 46static DEFINE_SPINLOCK(dbe_lock);
47 47
48#ifdef MODULE_START
48void *module_alloc(unsigned long size) 49void *module_alloc(unsigned long size)
49{ 50{
50#ifdef MODULE_START
51 return __vmalloc_node_range(size, 1, MODULE_START, MODULE_END, 51 return __vmalloc_node_range(size, 1, MODULE_START, MODULE_END,
52 GFP_KERNEL, PAGE_KERNEL, -1, 52 GFP_KERNEL, PAGE_KERNEL, -1,
53 __builtin_return_address(0)); 53 __builtin_return_address(0));
54#else
55 if (size == 0)
56 return NULL;
57 return vmalloc(size);
58#endif
59}
60
61/* Free memory returned from module_alloc */
62void module_free(struct module *mod, void *module_region)
63{
64 vfree(module_region);
65}
66
67int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
68 char *secstrings, struct module *mod)
69{
70 return 0;
71} 54}
55#endif
72 56
73static int apply_r_mips_none(struct module *me, u32 *location, Elf_Addr v) 57static int apply_r_mips_none(struct module *me, u32 *location, Elf_Addr v)
74{ 58{
diff --git a/arch/mn10300/kernel/module.c b/arch/mn10300/kernel/module.c
index 196a111e2e29..216ad23c9570 100644
--- a/arch/mn10300/kernel/module.c
+++ b/arch/mn10300/kernel/module.c
@@ -32,36 +32,6 @@
32#define DEBUGP(fmt, ...) 32#define DEBUGP(fmt, ...)
33#endif 33#endif
34 34
35/*
36 * allocate storage for a module
37 */
38void *module_alloc(unsigned long size)
39{
40 if (size == 0)
41 return NULL;
42 return vmalloc_exec(size);
43}
44
45/*
46 * free memory returned from module_alloc()
47 */
48void module_free(struct module *mod, void *module_region)
49{
50 vfree(module_region);
51}
52
53/*
54 * allow the arch to fix up the section table
55 * - we don't need anything special
56 */
57int module_frob_arch_sections(Elf_Ehdr *hdr,
58 Elf_Shdr *sechdrs,
59 char *secstrings,
60 struct module *mod)
61{
62 return 0;
63}
64
65static void reloc_put16(uint8_t *p, uint32_t val) 35static void reloc_put16(uint8_t *p, uint32_t val)
66{ 36{
67 p[0] = val & 0xff; 37 p[0] = val & 0xff;
@@ -81,20 +51,6 @@ static void reloc_put32(uint8_t *p, uint32_t val)
81} 51}
82 52
83/* 53/*
84 * apply a REL relocation
85 */
86int apply_relocate(Elf32_Shdr *sechdrs,
87 const char *strtab,
88 unsigned int symindex,
89 unsigned int relsec,
90 struct module *me)
91{
92 printk(KERN_ERR "module %s: RELOCATION unsupported\n",
93 me->name);
94 return -ENOEXEC;
95}
96
97/*
98 * apply a RELA relocation 54 * apply a RELA relocation
99 */ 55 */
100int apply_relocate_add(Elf32_Shdr *sechdrs, 56int apply_relocate_add(Elf32_Shdr *sechdrs,
@@ -198,20 +154,3 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
198 } 154 }
199 return 0; 155 return 0;
200} 156}
201
202/*
203 * finish loading the module
204 */
205int module_finalize(const Elf_Ehdr *hdr,
206 const Elf_Shdr *sechdrs,
207 struct module *me)
208{
209 return 0;
210}
211
212/*
213 * finish clearing the module
214 */
215void module_arch_cleanup(struct module *mod)
216{
217}
diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
index cedbbb8b18d9..5e34ccf39a49 100644
--- a/arch/parisc/kernel/module.c
+++ b/arch/parisc/kernel/module.c
@@ -540,18 +540,6 @@ static Elf_Addr get_stub(struct module *me, unsigned long value, long addend,
540 return (Elf_Addr)stub; 540 return (Elf_Addr)stub;
541} 541}
542 542
543int apply_relocate(Elf_Shdr *sechdrs,
544 const char *strtab,
545 unsigned int symindex,
546 unsigned int relsec,
547 struct module *me)
548{
549 /* parisc should not need this ... */
550 printk(KERN_ERR "module %s: RELOCATION unsupported\n",
551 me->name);
552 return -ENOEXEC;
553}
554
555#ifndef CONFIG_64BIT 543#ifndef CONFIG_64BIT
556int apply_relocate_add(Elf_Shdr *sechdrs, 544int apply_relocate_add(Elf_Shdr *sechdrs,
557 const char *strtab, 545 const char *strtab,
diff --git a/arch/powerpc/kernel/module.c b/arch/powerpc/kernel/module.c
index 49cee9df225b..a1cd701b5753 100644
--- a/arch/powerpc/kernel/module.c
+++ b/arch/powerpc/kernel/module.c
@@ -31,20 +31,6 @@
31 31
32LIST_HEAD(module_bug_list); 32LIST_HEAD(module_bug_list);
33 33
34void *module_alloc(unsigned long size)
35{
36 if (size == 0)
37 return NULL;
38
39 return vmalloc_exec(size);
40}
41
42/* Free memory returned from module_alloc */
43void module_free(struct module *mod, void *module_region)
44{
45 vfree(module_region);
46}
47
48static const Elf_Shdr *find_section(const Elf_Ehdr *hdr, 34static const Elf_Shdr *find_section(const Elf_Ehdr *hdr,
49 const Elf_Shdr *sechdrs, 35 const Elf_Shdr *sechdrs,
50 const char *name) 36 const char *name)
@@ -93,7 +79,3 @@ int module_finalize(const Elf_Ehdr *hdr,
93 79
94 return 0; 80 return 0;
95} 81}
96
97void module_arch_cleanup(struct module *mod)
98{
99}
diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
index f832773fc28e..0b6d79617d7b 100644
--- a/arch/powerpc/kernel/module_32.c
+++ b/arch/powerpc/kernel/module_32.c
@@ -174,17 +174,6 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
174 return 0; 174 return 0;
175} 175}
176 176
177int apply_relocate(Elf32_Shdr *sechdrs,
178 const char *strtab,
179 unsigned int symindex,
180 unsigned int relsec,
181 struct module *module)
182{
183 printk(KERN_ERR "%s: Non-ADD RELOCATION unsupported\n",
184 module->name);
185 return -ENOEXEC;
186}
187
188static inline int entry_matches(struct ppc_plt_entry *entry, Elf32_Addr val) 177static inline int entry_matches(struct ppc_plt_entry *entry, Elf32_Addr val)
189{ 178{
190 if (entry->jump[0] == 0x3d600000 + ((val + 0x8000) >> 16) 179 if (entry->jump[0] == 0x3d600000 + ((val + 0x8000) >> 16)
diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index 8fbb12508bf3..9f44a775a106 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -243,16 +243,6 @@ int module_frob_arch_sections(Elf64_Ehdr *hdr,
243 return 0; 243 return 0;
244} 244}
245 245
246int apply_relocate(Elf64_Shdr *sechdrs,
247 const char *strtab,
248 unsigned int symindex,
249 unsigned int relsec,
250 struct module *me)
251{
252 printk(KERN_ERR "%s: Non-ADD RELOCATION unsupported\n", me->name);
253 return -ENOEXEC;
254}
255
256/* r2 is the TOC pointer: it actually points 0x8000 into the TOC (this 246/* r2 is the TOC pointer: it actually points 0x8000 into the TOC (this
257 gives the value maximum span in an instruction which uses a signed 247 gives the value maximum span in an instruction which uses a signed
258 offset) */ 248 offset) */
diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
index f7167ee4604c..dfcb3436bad0 100644
--- a/arch/s390/kernel/module.c
+++ b/arch/s390/kernel/module.c
@@ -45,13 +45,6 @@
45#define PLT_ENTRY_SIZE 20 45#define PLT_ENTRY_SIZE 20
46#endif /* CONFIG_64BIT */ 46#endif /* CONFIG_64BIT */
47 47
48void *module_alloc(unsigned long size)
49{
50 if (size == 0)
51 return NULL;
52 return vmalloc(size);
53}
54
55/* Free memory returned from module_alloc */ 48/* Free memory returned from module_alloc */
56void module_free(struct module *mod, void *module_region) 49void module_free(struct module *mod, void *module_region)
57{ 50{
@@ -176,15 +169,6 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
176 return 0; 169 return 0;
177} 170}
178 171
179int
180apply_relocate(Elf_Shdr *sechdrs, const char *strtab, unsigned int symindex,
181 unsigned int relsec, struct module *me)
182{
183 printk(KERN_ERR "module %s: RELOCATION unsupported\n",
184 me->name);
185 return -ENOEXEC;
186}
187
188static int 172static int
189apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab, 173apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
190 struct module *me) 174 struct module *me)
@@ -409,7 +393,3 @@ int module_finalize(const Elf_Ehdr *hdr,
409 me->arch.syminfo = NULL; 393 me->arch.syminfo = NULL;
410 return 0; 394 return 0;
411} 395}
412
413void module_arch_cleanup(struct module *mod)
414{
415}
diff --git a/arch/score/kernel/module.c b/arch/score/kernel/module.c
index 4de8d47becd3..469e3b64e2f2 100644
--- a/arch/score/kernel/module.c
+++ b/arch/score/kernel/module.c
@@ -27,23 +27,6 @@
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/vmalloc.h> 28#include <linux/vmalloc.h>
29 29
30void *module_alloc(unsigned long size)
31{
32 return size ? vmalloc(size) : NULL;
33}
34
35/* Free memory returned from module_alloc */
36void module_free(struct module *mod, void *module_region)
37{
38 vfree(module_region);
39}
40
41int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
42 char *secstrings, struct module *mod)
43{
44 return 0;
45}
46
47int apply_relocate(Elf_Shdr *sechdrs, const char *strtab, 30int apply_relocate(Elf_Shdr *sechdrs, const char *strtab,
48 unsigned int symindex, unsigned int relindex, 31 unsigned int symindex, unsigned int relindex,
49 struct module *me) 32 struct module *me)
@@ -146,6 +129,9 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
146 unsigned int symindex, unsigned int relsec, 129 unsigned int symindex, unsigned int relsec,
147 struct module *me) 130 struct module *me)
148{ 131{
132 /* Non-standard return value... most other arch's return -ENOEXEC
133 * for an unsupported relocation variant
134 */
149 return 0; 135 return 0;
150} 136}
151 137
@@ -154,12 +140,3 @@ const struct exception_table_entry *search_module_dbetables(unsigned long addr)
154{ 140{
155 return NULL; 141 return NULL;
156} 142}
157
158/* Put in dbe list if necessary. */
159int module_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
160 struct module *me)
161{
162 return 0;
163}
164
165void module_arch_cleanup(struct module *mod) {}
diff --git a/arch/sh/kernel/module.c b/arch/sh/kernel/module.c
index 19b1f8826aef..1b525dedd29a 100644
--- a/arch/sh/kernel/module.c
+++ b/arch/sh/kernel/module.c
@@ -34,30 +34,6 @@
34#include <asm/unaligned.h> 34#include <asm/unaligned.h>
35#include <asm/dwarf.h> 35#include <asm/dwarf.h>
36 36
37void *module_alloc(unsigned long size)
38{
39 if (size == 0)
40 return NULL;
41
42 return vmalloc_exec(size);
43}
44
45
46/* Free memory returned from module_alloc */
47void module_free(struct module *mod, void *module_region)
48{
49 vfree(module_region);
50}
51
52/* We don't need anything special. */
53int module_frob_arch_sections(Elf_Ehdr *hdr,
54 Elf_Shdr *sechdrs,
55 char *secstrings,
56 struct module *mod)
57{
58 return 0;
59}
60
61int apply_relocate_add(Elf32_Shdr *sechdrs, 37int apply_relocate_add(Elf32_Shdr *sechdrs,
62 const char *strtab, 38 const char *strtab,
63 unsigned int symindex, 39 unsigned int symindex,
@@ -133,17 +109,6 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
133 return 0; 109 return 0;
134} 110}
135 111
136int apply_relocate(Elf32_Shdr *sechdrs,
137 const char *strtab,
138 unsigned int symindex,
139 unsigned int relsec,
140 struct module *me)
141{
142 printk(KERN_ERR "module %s: REL RELOCATION unsupported\n",
143 me->name);
144 return -ENOEXEC;
145}
146
147int module_finalize(const Elf_Ehdr *hdr, 112int module_finalize(const Elf_Ehdr *hdr,
148 const Elf_Shdr *sechdrs, 113 const Elf_Shdr *sechdrs,
149 struct module *me) 114 struct module *me)
diff --git a/arch/sparc/kernel/module.c b/arch/sparc/kernel/module.c
index 99ba5baa9497..da0c6c70ccb2 100644
--- a/arch/sparc/kernel/module.c
+++ b/arch/sparc/kernel/module.c
@@ -68,12 +68,6 @@ void *module_alloc(unsigned long size)
68 return ret; 68 return ret;
69} 69}
70 70
71/* Free memory returned from module_core_alloc/module_init_alloc */
72void module_free(struct module *mod, void *module_region)
73{
74 vfree(module_region);
75}
76
77/* Make generic code ignore STT_REGISTER dummy undefined symbols. */ 71/* Make generic code ignore STT_REGISTER dummy undefined symbols. */
78int module_frob_arch_sections(Elf_Ehdr *hdr, 72int module_frob_arch_sections(Elf_Ehdr *hdr,
79 Elf_Shdr *sechdrs, 73 Elf_Shdr *sechdrs,
@@ -107,17 +101,6 @@ int module_frob_arch_sections(Elf_Ehdr *hdr,
107 return 0; 101 return 0;
108} 102}
109 103
110int apply_relocate(Elf_Shdr *sechdrs,
111 const char *strtab,
112 unsigned int symindex,
113 unsigned int relsec,
114 struct module *me)
115{
116 printk(KERN_ERR "module %s: non-ADD RELOCATION unsupported\n",
117 me->name);
118 return -ENOEXEC;
119}
120
121int apply_relocate_add(Elf_Shdr *sechdrs, 104int apply_relocate_add(Elf_Shdr *sechdrs,
122 const char *strtab, 105 const char *strtab,
123 unsigned int symindex, 106 unsigned int symindex,
@@ -239,15 +222,4 @@ int module_finalize(const Elf_Ehdr *hdr,
239 222
240 return 0; 223 return 0;
241} 224}
242#else
243int module_finalize(const Elf_Ehdr *hdr,
244 const Elf_Shdr *sechdrs,
245 struct module *me)
246{
247 return 0;
248}
249#endif /* CONFIG_SPARC64 */ 225#endif /* CONFIG_SPARC64 */
250
251void module_arch_cleanup(struct module *mod)
252{
253}
diff --git a/arch/tile/kernel/module.c b/arch/tile/kernel/module.c
index f68df69f1f67..28fa6ece9d3a 100644
--- a/arch/tile/kernel/module.c
+++ b/arch/tile/kernel/module.c
@@ -98,25 +98,6 @@ void module_free(struct module *mod, void *module_region)
98 */ 98 */
99} 99}
100 100
101/* We don't need anything special. */
102int module_frob_arch_sections(Elf_Ehdr *hdr,
103 Elf_Shdr *sechdrs,
104 char *secstrings,
105 struct module *mod)
106{
107 return 0;
108}
109
110int apply_relocate(Elf_Shdr *sechdrs,
111 const char *strtab,
112 unsigned int symindex,
113 unsigned int relsec,
114 struct module *me)
115{
116 pr_err("module %s: .rel relocation unsupported\n", me->name);
117 return -ENOEXEC;
118}
119
120#ifdef __tilegx__ 101#ifdef __tilegx__
121/* 102/*
122 * Validate that the high 16 bits of "value" is just the sign-extension of 103 * Validate that the high 16 bits of "value" is just the sign-extension of
@@ -249,15 +230,3 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
249 } 230 }
250 return 0; 231 return 0;
251} 232}
252
253int module_finalize(const Elf_Ehdr *hdr,
254 const Elf_Shdr *sechdrs,
255 struct module *me)
256{
257 /* FIXME: perhaps remove the "writable" bit from the TLB? */
258 return 0;
259}
260
261void module_arch_cleanup(struct module *mod)
262{
263}
diff --git a/arch/unicore32/kernel/module.c b/arch/unicore32/kernel/module.c
index 3e5a38d71a1e..8fbe8577f5e6 100644
--- a/arch/unicore32/kernel/module.c
+++ b/arch/unicore32/kernel/module.c
@@ -37,19 +37,6 @@ void *module_alloc(unsigned long size)
37 return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL_EXEC); 37 return __vmalloc_area(area, GFP_KERNEL, PAGE_KERNEL_EXEC);
38} 38}
39 39
40void module_free(struct module *module, void *region)
41{
42 vfree(region);
43}
44
45int module_frob_arch_sections(Elf_Ehdr *hdr,
46 Elf_Shdr *sechdrs,
47 char *secstrings,
48 struct module *mod)
49{
50 return 0;
51}
52
53int 40int
54apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex, 41apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
55 unsigned int relindex, struct module *module) 42 unsigned int relindex, struct module *module)
@@ -128,25 +115,3 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
128 } 115 }
129 return 0; 116 return 0;
130} 117}
131
132int
133apply_relocate_add(Elf32_Shdr *sechdrs, const char *strtab,
134 unsigned int symindex, unsigned int relsec,
135 struct module *module)
136{
137 printk(KERN_ERR "module %s: ADD RELOCATION unsupported\n",
138 module->name);
139 return -ENOEXEC;
140}
141
142int
143module_finalize(const Elf32_Ehdr *hdr, const Elf_Shdr *sechdrs,
144 struct module *module)
145{
146 return 0;
147}
148
149void
150module_arch_cleanup(struct module *mod)
151{
152}
diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
index 52f256f2cc81..925179f871de 100644
--- a/arch/x86/kernel/module.c
+++ b/arch/x86/kernel/module.c
@@ -45,21 +45,6 @@ void *module_alloc(unsigned long size)
45 -1, __builtin_return_address(0)); 45 -1, __builtin_return_address(0));
46} 46}
47 47
48/* Free memory returned from module_alloc */
49void module_free(struct module *mod, void *module_region)
50{
51 vfree(module_region);
52}
53
54/* We don't need anything special. */
55int module_frob_arch_sections(Elf_Ehdr *hdr,
56 Elf_Shdr *sechdrs,
57 char *secstrings,
58 struct module *mod)
59{
60 return 0;
61}
62
63#ifdef CONFIG_X86_32 48#ifdef CONFIG_X86_32
64int apply_relocate(Elf32_Shdr *sechdrs, 49int apply_relocate(Elf32_Shdr *sechdrs,
65 const char *strtab, 50 const char *strtab,
@@ -100,17 +85,6 @@ int apply_relocate(Elf32_Shdr *sechdrs,
100 } 85 }
101 return 0; 86 return 0;
102} 87}
103
104int apply_relocate_add(Elf32_Shdr *sechdrs,
105 const char *strtab,
106 unsigned int symindex,
107 unsigned int relsec,
108 struct module *me)
109{
110 printk(KERN_ERR "module %s: ADD RELOCATION unsupported\n",
111 me->name);
112 return -ENOEXEC;
113}
114#else /*X86_64*/ 88#else /*X86_64*/
115int apply_relocate_add(Elf64_Shdr *sechdrs, 89int apply_relocate_add(Elf64_Shdr *sechdrs,
116 const char *strtab, 90 const char *strtab,
@@ -181,17 +155,6 @@ overflow:
181 me->name); 155 me->name);
182 return -ENOEXEC; 156 return -ENOEXEC;
183} 157}
184
185int apply_relocate(Elf_Shdr *sechdrs,
186 const char *strtab,
187 unsigned int symindex,
188 unsigned int relsec,
189 struct module *me)
190{
191 printk(KERN_ERR "non add relocation not supported\n");
192 return -ENOSYS;
193}
194
195#endif 158#endif
196 159
197int module_finalize(const Elf_Ehdr *hdr, 160int module_finalize(const Elf_Ehdr *hdr,
diff --git a/arch/xtensa/kernel/module.c b/arch/xtensa/kernel/module.c
index c1accea8cb56..451dda928c93 100644
--- a/arch/xtensa/kernel/module.c
+++ b/arch/xtensa/kernel/module.c
@@ -24,26 +24,6 @@
24 24
25#undef DEBUG_RELOCATE 25#undef DEBUG_RELOCATE
26 26
27void *module_alloc(unsigned long size)
28{
29 if (size == 0)
30 return NULL;
31 return vmalloc_exec(size);
32}
33
34void module_free(struct module *mod, void *module_region)
35{
36 vfree(module_region);
37}
38
39int module_frob_arch_sections(Elf32_Ehdr *hdr,
40 Elf32_Shdr *sechdrs,
41 char *secstrings,
42 struct module *mod)
43{
44 return 0;
45}
46
47static int 27static int
48decode_calln_opcode (unsigned char *location) 28decode_calln_opcode (unsigned char *location)
49{ 29{
@@ -66,18 +46,6 @@ decode_l32r_opcode (unsigned char *location)
66#endif 46#endif
67} 47}
68 48
69int apply_relocate(Elf32_Shdr *sechdrs,
70 const char *strtab,
71 unsigned int symindex,
72 unsigned int relsec,
73 struct module *mod)
74{
75 printk(KERN_ERR "module %s: REL RELOCATION unsupported\n",
76 mod->name);
77 return -ENOEXEC;
78
79}
80
81int apply_relocate_add(Elf32_Shdr *sechdrs, 49int apply_relocate_add(Elf32_Shdr *sechdrs,
82 const char *strtab, 50 const char *strtab,
83 unsigned int symindex, 51 unsigned int symindex,
@@ -222,14 +190,3 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
222 } 190 }
223 return 0; 191 return 0;
224} 192}
225
226int module_finalize(const Elf_Ehdr *hdr,
227 const Elf_Shdr *sechdrs,
228 struct module *mod)
229{
230 return 0;
231}
232
233void module_arch_cleanup(struct module *mod)
234{
235}
diff --git a/include/linux/module.h b/include/linux/module.h
index d9ca2d5dc6d0..1c30087a2d81 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -48,10 +48,18 @@ struct modversion_info
48 48
49struct module; 49struct module;
50 50
51struct module_kobject {
52 struct kobject kobj;
53 struct module *mod;
54 struct kobject *drivers_dir;
55 struct module_param_attrs *mp;
56};
57
51struct module_attribute { 58struct module_attribute {
52 struct attribute attr; 59 struct attribute attr;
53 ssize_t (*show)(struct module_attribute *, struct module *, char *); 60 ssize_t (*show)(struct module_attribute *, struct module_kobject *,
54 ssize_t (*store)(struct module_attribute *, struct module *, 61 char *);
62 ssize_t (*store)(struct module_attribute *, struct module_kobject *,
55 const char *, size_t count); 63 const char *, size_t count);
56 void (*setup)(struct module *, const char *); 64 void (*setup)(struct module *, const char *);
57 int (*test)(struct module *); 65 int (*test)(struct module *);
@@ -65,15 +73,9 @@ struct module_version_attribute {
65} __attribute__ ((__aligned__(sizeof(void *)))); 73} __attribute__ ((__aligned__(sizeof(void *))));
66 74
67extern ssize_t __modver_version_show(struct module_attribute *, 75extern ssize_t __modver_version_show(struct module_attribute *,
68 struct module *, char *); 76 struct module_kobject *, char *);
69 77
70struct module_kobject 78extern struct module_attribute module_uevent;
71{
72 struct kobject kobj;
73 struct module *mod;
74 struct kobject *drivers_dir;
75 struct module_param_attrs *mp;
76};
77 79
78/* These are either module local, or the kernel's dummy ones. */ 80/* These are either module local, or the kernel's dummy ones. */
79extern int init_module(void); 81extern int init_module(void);
diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
index c1f40c2f7ffb..b2be02ebf453 100644
--- a/include/linux/moduleloader.h
+++ b/include/linux/moduleloader.h
@@ -5,7 +5,12 @@
5#include <linux/module.h> 5#include <linux/module.h>
6#include <linux/elf.h> 6#include <linux/elf.h>
7 7
8/* These must be implemented by the specific architecture */ 8/* These may be implemented by architectures that need to hook into the
9 * module loader code. Architectures that don't need to do anything special
10 * can just rely on the 'weak' default hooks defined in kernel/module.c.
11 * Note, however, that at least one of apply_relocate or apply_relocate_add
12 * must be implemented by each architecture.
13 */
9 14
10/* Adjust arch-specific sections. Return 0 on success. */ 15/* Adjust arch-specific sections. Return 0 on success. */
11int module_frob_arch_sections(Elf_Ehdr *hdr, 16int module_frob_arch_sections(Elf_Ehdr *hdr,
diff --git a/kernel/module.c b/kernel/module.c
index 795bdc7f5c3f..04379f92f843 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -545,9 +545,9 @@ static void setup_modinfo_##field(struct module *mod, const char *s) \
545 mod->field = kstrdup(s, GFP_KERNEL); \ 545 mod->field = kstrdup(s, GFP_KERNEL); \
546} \ 546} \
547static ssize_t show_modinfo_##field(struct module_attribute *mattr, \ 547static ssize_t show_modinfo_##field(struct module_attribute *mattr, \
548 struct module *mod, char *buffer) \ 548 struct module_kobject *mk, char *buffer) \
549{ \ 549{ \
550 return sprintf(buffer, "%s\n", mod->field); \ 550 return sprintf(buffer, "%s\n", mk->mod->field); \
551} \ 551} \
552static int modinfo_##field##_exists(struct module *mod) \ 552static int modinfo_##field##_exists(struct module *mod) \
553{ \ 553{ \
@@ -902,9 +902,9 @@ void symbol_put_addr(void *addr)
902EXPORT_SYMBOL_GPL(symbol_put_addr); 902EXPORT_SYMBOL_GPL(symbol_put_addr);
903 903
904static ssize_t show_refcnt(struct module_attribute *mattr, 904static ssize_t show_refcnt(struct module_attribute *mattr,
905 struct module *mod, char *buffer) 905 struct module_kobject *mk, char *buffer)
906{ 906{
907 return sprintf(buffer, "%u\n", module_refcount(mod)); 907 return sprintf(buffer, "%u\n", module_refcount(mk->mod));
908} 908}
909 909
910static struct module_attribute refcnt = { 910static struct module_attribute refcnt = {
@@ -952,11 +952,11 @@ static inline int module_unload_init(struct module *mod)
952#endif /* CONFIG_MODULE_UNLOAD */ 952#endif /* CONFIG_MODULE_UNLOAD */
953 953
954static ssize_t show_initstate(struct module_attribute *mattr, 954static ssize_t show_initstate(struct module_attribute *mattr,
955 struct module *mod, char *buffer) 955 struct module_kobject *mk, char *buffer)
956{ 956{
957 const char *state = "unknown"; 957 const char *state = "unknown";
958 958
959 switch (mod->state) { 959 switch (mk->mod->state) {
960 case MODULE_STATE_LIVE: 960 case MODULE_STATE_LIVE:
961 state = "live"; 961 state = "live";
962 break; 962 break;
@@ -975,10 +975,27 @@ static struct module_attribute initstate = {
975 .show = show_initstate, 975 .show = show_initstate,
976}; 976};
977 977
978static ssize_t store_uevent(struct module_attribute *mattr,
979 struct module_kobject *mk,
980 const char *buffer, size_t count)
981{
982 enum kobject_action action;
983
984 if (kobject_action_type(buffer, count, &action) == 0)
985 kobject_uevent(&mk->kobj, action);
986 return count;
987}
988
989struct module_attribute module_uevent = {
990 .attr = { .name = "uevent", .mode = 0200 },
991 .store = store_uevent,
992};
993
978static struct module_attribute *modinfo_attrs[] = { 994static struct module_attribute *modinfo_attrs[] = {
979 &modinfo_version, 995 &modinfo_version,
980 &modinfo_srcversion, 996 &modinfo_srcversion,
981 &initstate, 997 &initstate,
998 &module_uevent,
982#ifdef CONFIG_MODULE_UNLOAD 999#ifdef CONFIG_MODULE_UNLOAD
983 &refcnt, 1000 &refcnt,
984#endif 1001#endif
@@ -1187,7 +1204,7 @@ struct module_sect_attrs
1187}; 1204};
1188 1205
1189static ssize_t module_sect_show(struct module_attribute *mattr, 1206static ssize_t module_sect_show(struct module_attribute *mattr,
1190 struct module *mod, char *buf) 1207 struct module_kobject *mk, char *buf)
1191{ 1208{
1192 struct module_sect_attr *sattr = 1209 struct module_sect_attr *sattr =
1193 container_of(mattr, struct module_sect_attr, mattr); 1210 container_of(mattr, struct module_sect_attr, mattr);
@@ -1697,6 +1714,15 @@ static void unset_module_core_ro_nx(struct module *mod) { }
1697static void unset_module_init_ro_nx(struct module *mod) { } 1714static void unset_module_init_ro_nx(struct module *mod) { }
1698#endif 1715#endif
1699 1716
1717void __weak module_free(struct module *mod, void *module_region)
1718{
1719 vfree(module_region);
1720}
1721
1722void __weak module_arch_cleanup(struct module *mod)
1723{
1724}
1725
1700/* Free a module, remove from lists, etc. */ 1726/* Free a module, remove from lists, etc. */
1701static void free_module(struct module *mod) 1727static void free_module(struct module *mod)
1702{ 1728{
@@ -1851,6 +1877,26 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
1851 return ret; 1877 return ret;
1852} 1878}
1853 1879
1880int __weak apply_relocate(Elf_Shdr *sechdrs,
1881 const char *strtab,
1882 unsigned int symindex,
1883 unsigned int relsec,
1884 struct module *me)
1885{
1886 pr_err("module %s: REL relocation unsupported\n", me->name);
1887 return -ENOEXEC;
1888}
1889
1890int __weak apply_relocate_add(Elf_Shdr *sechdrs,
1891 const char *strtab,
1892 unsigned int symindex,
1893 unsigned int relsec,
1894 struct module *me)
1895{
1896 pr_err("module %s: RELA relocation unsupported\n", me->name);
1897 return -ENOEXEC;
1898}
1899
1854static int apply_relocations(struct module *mod, const struct load_info *info) 1900static int apply_relocations(struct module *mod, const struct load_info *info)
1855{ 1901{
1856 unsigned int i; 1902 unsigned int i;
@@ -2235,6 +2281,11 @@ static void dynamic_debug_remove(struct _ddebug *debug)
2235 ddebug_remove_module(debug->modname); 2281 ddebug_remove_module(debug->modname);
2236} 2282}
2237 2283
2284void * __weak module_alloc(unsigned long size)
2285{
2286 return size == 0 ? NULL : vmalloc_exec(size);
2287}
2288
2238static void *module_alloc_update_bounds(unsigned long size) 2289static void *module_alloc_update_bounds(unsigned long size)
2239{ 2290{
2240 void *ret = module_alloc(size); 2291 void *ret = module_alloc(size);
@@ -2645,6 +2696,14 @@ static void flush_module_icache(const struct module *mod)
2645 set_fs(old_fs); 2696 set_fs(old_fs);
2646} 2697}
2647 2698
2699int __weak module_frob_arch_sections(Elf_Ehdr *hdr,
2700 Elf_Shdr *sechdrs,
2701 char *secstrings,
2702 struct module *mod)
2703{
2704 return 0;
2705}
2706
2648static struct module *layout_and_allocate(struct load_info *info) 2707static struct module *layout_and_allocate(struct load_info *info)
2649{ 2708{
2650 /* Module within temporary copy. */ 2709 /* Module within temporary copy. */
@@ -2716,6 +2775,13 @@ static void module_deallocate(struct module *mod, struct load_info *info)
2716 module_free(mod, mod->module_core); 2775 module_free(mod, mod->module_core);
2717} 2776}
2718 2777
2778int __weak module_finalize(const Elf_Ehdr *hdr,
2779 const Elf_Shdr *sechdrs,
2780 struct module *me)
2781{
2782 return 0;
2783}
2784
2719static int post_relocation(struct module *mod, const struct load_info *info) 2785static int post_relocation(struct module *mod, const struct load_info *info)
2720{ 2786{
2721 /* Sort exception table now relocations are done. */ 2787 /* Sort exception table now relocations are done. */
diff --git a/kernel/params.c b/kernel/params.c
index ed72e1330862..22df3e0d142a 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -225,8 +225,8 @@ int parse_args(const char *name,
225 int ret; \ 225 int ret; \
226 \ 226 \
227 ret = strtolfn(val, 0, &l); \ 227 ret = strtolfn(val, 0, &l); \
228 if (ret == -EINVAL || ((type)l != l)) \ 228 if (ret < 0 || ((type)l != l)) \
229 return -EINVAL; \ 229 return ret < 0 ? ret : -EINVAL; \
230 *((type *)kp->arg) = l; \ 230 *((type *)kp->arg) = l; \
231 return 0; \ 231 return 0; \
232 } \ 232 } \
@@ -511,7 +511,7 @@ struct module_param_attrs
511#define to_param_attr(n) container_of(n, struct param_attribute, mattr) 511#define to_param_attr(n) container_of(n, struct param_attribute, mattr)
512 512
513static ssize_t param_attr_show(struct module_attribute *mattr, 513static ssize_t param_attr_show(struct module_attribute *mattr,
514 struct module *mod, char *buf) 514 struct module_kobject *mk, char *buf)
515{ 515{
516 int count; 516 int count;
517 struct param_attribute *attribute = to_param_attr(mattr); 517 struct param_attribute *attribute = to_param_attr(mattr);
@@ -531,7 +531,7 @@ static ssize_t param_attr_show(struct module_attribute *mattr,
531 531
532/* sysfs always hands a nul-terminated string in buf. We rely on that. */ 532/* sysfs always hands a nul-terminated string in buf. We rely on that. */
533static ssize_t param_attr_store(struct module_attribute *mattr, 533static ssize_t param_attr_store(struct module_attribute *mattr,
534 struct module *owner, 534 struct module_kobject *km,
535 const char *buf, size_t len) 535 const char *buf, size_t len)
536{ 536{
537 int err; 537 int err;
@@ -730,6 +730,10 @@ static struct module_kobject * __init locate_module_kobject(const char *name)
730 mk->kobj.kset = module_kset; 730 mk->kobj.kset = module_kset;
731 err = kobject_init_and_add(&mk->kobj, &module_ktype, NULL, 731 err = kobject_init_and_add(&mk->kobj, &module_ktype, NULL,
732 "%s", name); 732 "%s", name);
733#ifdef CONFIG_MODULES
734 if (!err)
735 err = sysfs_create_file(&mk->kobj, &module_uevent.attr);
736#endif
733 if (err) { 737 if (err) {
734 kobject_put(&mk->kobj); 738 kobject_put(&mk->kobj);
735 printk(KERN_ERR 739 printk(KERN_ERR
@@ -807,7 +811,7 @@ static void __init param_sysfs_builtin(void)
807} 811}
808 812
809ssize_t __modver_version_show(struct module_attribute *mattr, 813ssize_t __modver_version_show(struct module_attribute *mattr,
810 struct module *mod, char *buf) 814 struct module_kobject *mk, char *buf)
811{ 815{
812 struct module_version_attribute *vattr = 816 struct module_version_attribute *vattr =
813 container_of(mattr, struct module_version_attribute, mattr); 817 container_of(mattr, struct module_version_attribute, mattr);
@@ -852,7 +856,7 @@ static ssize_t module_attr_show(struct kobject *kobj,
852 if (!attribute->show) 856 if (!attribute->show)
853 return -EIO; 857 return -EIO;
854 858
855 ret = attribute->show(attribute, mk->mod, buf); 859 ret = attribute->show(attribute, mk, buf);
856 860
857 return ret; 861 return ret;
858} 862}
@@ -871,7 +875,7 @@ static ssize_t module_attr_store(struct kobject *kobj,
871 if (!attribute->store) 875 if (!attribute->store)
872 return -EIO; 876 return -EIO;
873 877
874 ret = attribute->store(attribute, mk->mod, buf, len); 878 ret = attribute->store(attribute, mk, buf, len);
875 879
876 return ret; 880 return ret;
877} 881}
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 413c53693e62..a509ff8f32fa 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -254,6 +254,28 @@ static enum export export_no(const char *s)
254 return export_unknown; 254 return export_unknown;
255} 255}
256 256
257static const char *sec_name(struct elf_info *elf, int secindex);
258
259#define strstarts(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0)
260
261static enum export export_from_secname(struct elf_info *elf, unsigned int sec)
262{
263 const char *secname = sec_name(elf, sec);
264
265 if (strstarts(secname, "___ksymtab+"))
266 return export_plain;
267 else if (strstarts(secname, "___ksymtab_unused+"))
268 return export_unused;
269 else if (strstarts(secname, "___ksymtab_gpl+"))
270 return export_gpl;
271 else if (strstarts(secname, "___ksymtab_unused_gpl+"))
272 return export_unused_gpl;
273 else if (strstarts(secname, "___ksymtab_gpl_future+"))
274 return export_gpl_future;
275 else
276 return export_unknown;
277}
278
257static enum export export_from_sec(struct elf_info *elf, unsigned int sec) 279static enum export export_from_sec(struct elf_info *elf, unsigned int sec)
258{ 280{
259 if (sec == elf->export_sec) 281 if (sec == elf->export_sec)
@@ -563,7 +585,12 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
563 Elf_Sym *sym, const char *symname) 585 Elf_Sym *sym, const char *symname)
564{ 586{
565 unsigned int crc; 587 unsigned int crc;
566 enum export export = export_from_sec(info, get_secindex(info, sym)); 588 enum export export;
589
590 if (!is_vmlinux(mod->name) && strncmp(symname, "__ksymtab", 9) == 0)
591 export = export_from_secname(info, get_secindex(info, sym));
592 else
593 export = export_from_sec(info, get_secindex(info, sym));
567 594
568 switch (sym->st_shndx) { 595 switch (sym->st_shndx) {
569 case SHN_COMMON: 596 case SHN_COMMON: