aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-05-05 13:58:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-05-05 13:58:06 -0400
commitf8ce1faf55955de62e0a12e330c6d9a526071f65 (patch)
treea3b0ddd3f37e40d3ed0fd2cd433a2723403c8b97
parent24d0c2542b38963ae4d5171ecc0a2c1326c656bc (diff)
parenta53a11f35762ff1d5e268adedf2ab9ce313f871d (diff)
Merge tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux
Pull mudule updates from Rusty Russell: "We get rid of the general module prefix confusion with a binary config option, fix a remove/insert race which Never Happens, and (my favorite) handle the case when we have too many modules for a single commandline. Seriously, the kernel is full, please go away!" * tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux: modpost: fix unwanted VMLINUX_SYMBOL_STR expansion X.509: Support parse long form of length octets in Authority Key Identifier module: don't unlink the module until we've removed all exposure. kernel: kallsyms: memory override issue, need check destination buffer length MODSIGN: do not send garbage to stderr when enabling modules signature modpost: handle huge numbers of modules. modpost: add -T option to read module names from file/stdin. modpost: minor cleanup. genksyms: pass symbol-prefix instead of arch module: fix symbol versioning with symbol prefixes CONFIG_SYMBOL_PREFIX: cleanup.
-rw-r--r--Makefile2
-rw-r--r--arch/Kconfig6
-rw-r--r--arch/blackfin/Kconfig5
-rw-r--r--arch/h8300/Kconfig5
-rw-r--r--arch/metag/Kconfig5
-rw-r--r--crypto/asymmetric_keys/x509_cert_parser.c55
-rw-r--r--drivers/mtd/chips/gen_probe.c8
-rw-r--r--include/asm-generic/unistd.h1
-rw-r--r--include/asm-generic/vmlinux.lds.h8
-rw-r--r--include/linux/export.h20
-rw-r--r--include/linux/kernel.h7
-rw-r--r--include/linux/linkage.h20
-rw-r--r--include/linux/module.h4
-rw-r--r--kernel/Makefile2
-rw-r--r--kernel/kallsyms.c26
-rw-r--r--kernel/modsign_certificate.S13
-rw-r--r--kernel/module.c18
-rw-r--r--scripts/Makefile.build3
-rw-r--r--scripts/Makefile.lib7
-rw-r--r--scripts/Makefile.modpost8
-rw-r--r--scripts/genksyms/genksyms.c18
-rw-r--r--scripts/link-vmlinux.sh5
-rw-r--r--scripts/mod/modpost.c94
23 files changed, 201 insertions, 139 deletions
diff --git a/Makefile b/Makefile
index 4572f106e30b..878d7aa3d2dd 100644
--- a/Makefile
+++ b/Makefile
@@ -1399,7 +1399,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))
1399# Run depmod only if we have System.map and depmod is executable 1399# Run depmod only if we have System.map and depmod is executable
1400quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) 1400quiet_cmd_depmod = DEPMOD $(KERNELRELEASE)
1401 cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ 1401 cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
1402 $(KERNELRELEASE) "$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))" 1402 $(KERNELRELEASE) "$(patsubst y,_,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX))"
1403 1403
1404# Create temporary dir for module support files 1404# Create temporary dir for module support files
1405# clean it up only when building all modules 1405# clean it up only when building all modules
diff --git a/arch/Kconfig b/arch/Kconfig
index 99f0e17df429..dd0e8eb8042f 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -381,6 +381,12 @@ config MODULES_USE_ELF_REL
381 Modules only use ELF REL relocations. Modules with ELF RELA 381 Modules only use ELF REL relocations. Modules with ELF RELA
382 relocations will give an error. 382 relocations will give an error.
383 383
384config HAVE_UNDERSCORE_SYMBOL_PREFIX
385 bool
386 help
387 Some architectures generate an _ in front of C symbols; things like
388 module loading and assembly files need to know about this.
389
384# 390#
385# ABI hall of shame 391# ABI hall of shame
386# 392#
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index c3f2e0bc644a..453ebe46b065 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -1,7 +1,3 @@
1config SYMBOL_PREFIX
2 string
3 default "_"
4
5config MMU 1config MMU
6 def_bool n 2 def_bool n
7 3
@@ -33,6 +29,7 @@ config BLACKFIN
33 select ARCH_HAVE_CUSTOM_GPIO_H 29 select ARCH_HAVE_CUSTOM_GPIO_H
34 select ARCH_WANT_OPTIONAL_GPIOLIB 30 select ARCH_WANT_OPTIONAL_GPIOLIB
35 select HAVE_UID16 31 select HAVE_UID16
32 select HAVE_UNDERSCORE_SYMBOL_PREFIX
36 select VIRT_TO_BUS 33 select VIRT_TO_BUS
37 select ARCH_WANT_IPC_PARSE_VERSION 34 select ARCH_WANT_IPC_PARSE_VERSION
38 select HAVE_GENERIC_HARDIRQS 35 select HAVE_GENERIC_HARDIRQS
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 79250de1b12a..303e4f9a79d1 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -12,10 +12,7 @@ config H8300
12 select MODULES_USE_ELF_RELA 12 select MODULES_USE_ELF_RELA
13 select OLD_SIGSUSPEND3 13 select OLD_SIGSUSPEND3
14 select OLD_SIGACTION 14 select OLD_SIGACTION
15 15 select HAVE_UNDERSCORE_SYMBOL_PREFIX
16config SYMBOL_PREFIX
17 string
18 default "_"
19 16
20config MMU 17config MMU
21 bool 18 bool
diff --git a/arch/metag/Kconfig b/arch/metag/Kconfig
index b06b41861aac..6f16c1469327 100644
--- a/arch/metag/Kconfig
+++ b/arch/metag/Kconfig
@@ -1,7 +1,3 @@
1config SYMBOL_PREFIX
2 string
3 default "_"
4
5config METAG 1config METAG
6 def_bool y 2 def_bool y
7 select EMBEDDED 3 select EMBEDDED
@@ -28,6 +24,7 @@ config METAG
28 select HAVE_OPROFILE 24 select HAVE_OPROFILE
29 select HAVE_PERF_EVENTS 25 select HAVE_PERF_EVENTS
30 select HAVE_SYSCALL_TRACEPOINTS 26 select HAVE_SYSCALL_TRACEPOINTS
27 select HAVE_UNDERSCORE_SYMBOL_PREFIX
31 select IRQ_DOMAIN 28 select IRQ_DOMAIN
32 select MODULES_USE_ELF_RELA 29 select MODULES_USE_ELF_RELA
33 select OF 30 select OF
diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
index 7fabc4c01993..facbf26bc6bb 100644
--- a/crypto/asymmetric_keys/x509_cert_parser.c
+++ b/crypto/asymmetric_keys/x509_cert_parser.c
@@ -373,6 +373,9 @@ int rsa_extract_mpi(void *context, size_t hdrlen,
373 return 0; 373 return 0;
374} 374}
375 375
376/* The keyIdentifier in AuthorityKeyIdentifier SEQUENCE is tag(CONT,PRIM,0) */
377#define SEQ_TAG_KEYID (ASN1_CONT << 6)
378
376/* 379/*
377 * Process certificate extensions that are used to qualify the certificate. 380 * Process certificate extensions that are used to qualify the certificate.
378 */ 381 */
@@ -407,21 +410,57 @@ int x509_process_extension(void *context, size_t hdrlen,
407 } 410 }
408 411
409 if (ctx->last_oid == OID_authorityKeyIdentifier) { 412 if (ctx->last_oid == OID_authorityKeyIdentifier) {
413 size_t key_len;
414
410 /* Get hold of the CA key fingerprint */ 415 /* Get hold of the CA key fingerprint */
411 if (vlen < 5) 416 if (vlen < 5)
412 return -EBADMSG; 417 return -EBADMSG;
413 if (v[0] != (ASN1_SEQ | (ASN1_CONS << 5)) || 418
414 v[1] != vlen - 2 || 419 /* Authority Key Identifier must be a Constructed SEQUENCE */
415 v[2] != (ASN1_CONT << 6) || 420 if (v[0] != (ASN1_SEQ | (ASN1_CONS << 5)))
416 v[3] != vlen - 4)
417 return -EBADMSG; 421 return -EBADMSG;
418 v += 4;
419 vlen -= 4;
420 422
421 f = kmalloc(vlen * 2 + 1, GFP_KERNEL); 423 /* Authority Key Identifier is not indefinite length */
424 if (unlikely(vlen == ASN1_INDEFINITE_LENGTH))
425 return -EBADMSG;
426
427 if (vlen < ASN1_INDEFINITE_LENGTH) {
428 /* Short Form length */
429 if (v[1] != vlen - 2 ||
430 v[2] != SEQ_TAG_KEYID ||
431 v[3] > vlen - 4)
432 return -EBADMSG;
433
434 key_len = v[3];
435 v += 4;
436 } else {
437 /* Long Form length */
438 size_t seq_len = 0;
439 size_t sub = v[1] - ASN1_INDEFINITE_LENGTH;
440
441 if (sub > 2)
442 return -EBADMSG;
443
444 /* calculate the length from subsequent octets */
445 v += 2;
446 for (i = 0; i < sub; i++) {
447 seq_len <<= 8;
448 seq_len |= v[i];
449 }
450
451 if (seq_len != vlen - 2 - sub ||
452 v[sub] != SEQ_TAG_KEYID ||
453 v[sub + 1] > vlen - 4 - sub)
454 return -EBADMSG;
455
456 key_len = v[sub + 1];
457 v += (sub + 2);
458 }
459
460 f = kmalloc(key_len * 2 + 1, GFP_KERNEL);
422 if (!f) 461 if (!f)
423 return -ENOMEM; 462 return -ENOMEM;
424 for (i = 0; i < vlen; i++) 463 for (i = 0; i < key_len; i++)
425 sprintf(f + i * 2, "%02x", v[i]); 464 sprintf(f + i * 2, "%02x", v[i]);
426 pr_debug("authority %s\n", f); 465 pr_debug("authority %s\n", f);
427 ctx->cert->authority = f; 466 ctx->cert->authority = f;
diff --git a/drivers/mtd/chips/gen_probe.c b/drivers/mtd/chips/gen_probe.c
index 3b9a2843c5f8..74dbb6bcf488 100644
--- a/drivers/mtd/chips/gen_probe.c
+++ b/drivers/mtd/chips/gen_probe.c
@@ -204,14 +204,16 @@ static inline struct mtd_info *cfi_cmdset_unknown(struct map_info *map,
204 struct cfi_private *cfi = map->fldrv_priv; 204 struct cfi_private *cfi = map->fldrv_priv;
205 __u16 type = primary?cfi->cfiq->P_ID:cfi->cfiq->A_ID; 205 __u16 type = primary?cfi->cfiq->P_ID:cfi->cfiq->A_ID;
206#ifdef CONFIG_MODULES 206#ifdef CONFIG_MODULES
207 char probename[16+sizeof(MODULE_SYMBOL_PREFIX)]; 207 char probename[sizeof(VMLINUX_SYMBOL_STR(cfi_cmdset_%4.4X))];
208 cfi_cmdset_fn_t *probe_function; 208 cfi_cmdset_fn_t *probe_function;
209 209
210 sprintf(probename, MODULE_SYMBOL_PREFIX "cfi_cmdset_%4.4X", type); 210 sprintf(probename, VMLINUX_SYMBOL_STR(cfi_cmdset_%4.4X), type);
211 211
212 probe_function = __symbol_get(probename); 212 probe_function = __symbol_get(probename);
213 if (!probe_function) { 213 if (!probe_function) {
214 request_module(probename + sizeof(MODULE_SYMBOL_PREFIX) - 1); 214 char modname[sizeof("cfi_cmdset_%4.4X")];
215 sprintf(modname, "cfi_cmdset_%4.4X", type);
216 request_module(modname);
215 probe_function = __symbol_get(probename); 217 probe_function = __symbol_get(probename);
216 } 218 }
217 219
diff --git a/include/asm-generic/unistd.h b/include/asm-generic/unistd.h
index 0501fa3f783d..cccc86ecfeaa 100644
--- a/include/asm-generic/unistd.h
+++ b/include/asm-generic/unistd.h
@@ -1,4 +1,5 @@
1#include <uapi/asm-generic/unistd.h> 1#include <uapi/asm-generic/unistd.h>
2#include <linux/export.h>
2 3
3/* 4/*
4 * These are required system calls, we should 5 * These are required system calls, we should
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index afa12c7a025c..eb58d2d7d971 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -52,13 +52,7 @@
52#define LOAD_OFFSET 0 52#define LOAD_OFFSET 0
53#endif 53#endif
54 54
55#ifndef SYMBOL_PREFIX 55#include <linux/export.h>
56#define VMLINUX_SYMBOL(sym) sym
57#else
58#define PASTE2(x,y) x##y
59#define PASTE(x,y) PASTE2(x,y)
60#define VMLINUX_SYMBOL(sym) PASTE(SYMBOL_PREFIX, sym)
61#endif
62 56
63/* Align . to a 8 byte boundary equals to maximum function alignment. */ 57/* Align . to a 8 byte boundary equals to maximum function alignment. */
64#define ALIGN_FUNCTION() . = ALIGN(8) 58#define ALIGN_FUNCTION() . = ALIGN(8)
diff --git a/include/linux/export.h b/include/linux/export.h
index 696c0f48afc7..412cd509effe 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -5,17 +5,24 @@
5 * to reduce the amount of pointless cruft we feed to gcc when only 5 * to reduce the amount of pointless cruft we feed to gcc when only
6 * exporting a simple symbol or two. 6 * exporting a simple symbol or two.
7 * 7 *
8 * If you feel the need to add #include <linux/foo.h> to this file 8 * Try not to add #includes here. It slows compilation and makes kernel
9 * then you are doing something wrong and should go away silently. 9 * hackers place grumpy comments in header files.
10 */ 10 */
11 11
12/* Some toolchains use a `_' prefix for all user symbols. */ 12/* Some toolchains use a `_' prefix for all user symbols. */
13#ifdef CONFIG_SYMBOL_PREFIX 13#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX
14#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX 14#define __VMLINUX_SYMBOL(x) _##x
15#define __VMLINUX_SYMBOL_STR(x) "_" #x
15#else 16#else
16#define MODULE_SYMBOL_PREFIX "" 17#define __VMLINUX_SYMBOL(x) x
18#define __VMLINUX_SYMBOL_STR(x) #x
17#endif 19#endif
18 20
21/* Indirect, so macros are expanded before pasting. */
22#define VMLINUX_SYMBOL(x) __VMLINUX_SYMBOL(x)
23#define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x)
24
25#ifndef __ASSEMBLY__
19struct kernel_symbol 26struct kernel_symbol
20{ 27{
21 unsigned long value; 28 unsigned long value;
@@ -51,7 +58,7 @@ extern struct module __this_module;
51 __CRC_SYMBOL(sym, sec) \ 58 __CRC_SYMBOL(sym, sec) \
52 static const char __kstrtab_##sym[] \ 59 static const char __kstrtab_##sym[] \
53 __attribute__((section("__ksymtab_strings"), aligned(1))) \ 60 __attribute__((section("__ksymtab_strings"), aligned(1))) \
54 = MODULE_SYMBOL_PREFIX #sym; \ 61 = VMLINUX_SYMBOL_STR(sym); \
55 static const struct kernel_symbol __ksymtab_##sym \ 62 static const struct kernel_symbol __ksymtab_##sym \
56 __used \ 63 __used \
57 __attribute__((section("___ksymtab" sec "+" #sym), unused)) \ 64 __attribute__((section("___ksymtab" sec "+" #sym), unused)) \
@@ -85,5 +92,6 @@ extern struct module __this_module;
85#define EXPORT_UNUSED_SYMBOL_GPL(sym) 92#define EXPORT_UNUSED_SYMBOL_GPL(sym)
86 93
87#endif /* CONFIG_MODULES */ 94#endif /* CONFIG_MODULES */
95#endif /* !__ASSEMBLY__ */
88 96
89#endif /* _LINUX_EXPORT_H */ 97#endif /* _LINUX_EXPORT_H */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 6d1844f393c0..e96329ceb28c 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -786,13 +786,6 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
786/* Trap pasters of __FUNCTION__ at compile-time */ 786/* Trap pasters of __FUNCTION__ at compile-time */
787#define __FUNCTION__ (__func__) 787#define __FUNCTION__ (__func__)
788 788
789/* This helps us to avoid #ifdef CONFIG_SYMBOL_PREFIX */
790#ifdef CONFIG_SYMBOL_PREFIX
791#define SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX
792#else
793#define SYMBOL_PREFIX ""
794#endif
795
796/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ 789/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */
797#ifdef CONFIG_FTRACE_MCOUNT_RECORD 790#ifdef CONFIG_FTRACE_MCOUNT_RECORD
798# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD 791# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
diff --git a/include/linux/linkage.h b/include/linux/linkage.h
index de09dec25ec3..d3e8ad23a8e0 100644
--- a/include/linux/linkage.h
+++ b/include/linux/linkage.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/compiler.h> 4#include <linux/compiler.h>
5#include <linux/stringify.h> 5#include <linux/stringify.h>
6#include <linux/export.h>
6#include <asm/linkage.h> 7#include <asm/linkage.h>
7 8
8#ifdef __cplusplus 9#ifdef __cplusplus
@@ -15,21 +16,18 @@
15#define asmlinkage CPP_ASMLINKAGE 16#define asmlinkage CPP_ASMLINKAGE
16#endif 17#endif
17 18
18#ifdef CONFIG_SYMBOL_PREFIX
19#define __SYMBOL_NAME(x) CONFIG_SYMBOL_PREFIX __stringify(x)
20#else
21#define __SYMBOL_NAME(x) __stringify(x)
22#endif
23
24#ifndef cond_syscall 19#ifndef cond_syscall
25#define cond_syscall(x) asm(".weak\t" __SYMBOL_NAME(x) \ 20#define cond_syscall(x) asm( \
26 "\n\t.set\t" __SYMBOL_NAME(x) "," __SYMBOL_NAME(sys_ni_syscall)); 21 ".weak " VMLINUX_SYMBOL_STR(x) "\n\t" \
22 ".set " VMLINUX_SYMBOL_STR(x) "," \
23 VMLINUX_SYMBOL_STR(sys_ni_syscall))
27#endif 24#endif
28 25
29#ifndef SYSCALL_ALIAS 26#ifndef SYSCALL_ALIAS
30#define SYSCALL_ALIAS(alias, name) \ 27#define SYSCALL_ALIAS(alias, name) asm( \
31 asm ("\t.globl " __SYMBOL_NAME(alias) \ 28 ".globl " VMLINUX_SYMBOL_STR(alias) "\n\t" \
32 "\n\t.set\t" __SYMBOL_NAME(alias) "," __SYMBOL_NAME(name)) 29 ".set " VMLINUX_SYMBOL_STR(alias) "," \
30 VMLINUX_SYMBOL_STR(name))
33#endif 31#endif
34 32
35#define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE) 33#define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
diff --git a/include/linux/module.h b/include/linux/module.h
index ead1b5719a12..46f1ea01e6f6 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -190,7 +190,7 @@ extern int modules_disabled; /* for sysctl */
190/* Get/put a kernel symbol (calls must be symmetric) */ 190/* Get/put a kernel symbol (calls must be symmetric) */
191void *__symbol_get(const char *symbol); 191void *__symbol_get(const char *symbol);
192void *__symbol_get_gpl(const char *symbol); 192void *__symbol_get_gpl(const char *symbol);
193#define symbol_get(x) ((typeof(&x))(__symbol_get(MODULE_SYMBOL_PREFIX #x))) 193#define symbol_get(x) ((typeof(&x))(__symbol_get(VMLINUX_SYMBOL_STR(x))))
194 194
195/* modules using other modules: kdb wants to see this. */ 195/* modules using other modules: kdb wants to see this. */
196struct module_use { 196struct module_use {
@@ -453,7 +453,7 @@ extern void __module_put_and_exit(struct module *mod, long code)
453#ifdef CONFIG_MODULE_UNLOAD 453#ifdef CONFIG_MODULE_UNLOAD
454unsigned long module_refcount(struct module *mod); 454unsigned long module_refcount(struct module *mod);
455void __symbol_put(const char *symbol); 455void __symbol_put(const char *symbol);
456#define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x) 456#define symbol_put(x) __symbol_put(VMLINUX_SYMBOL_STR(x))
457void symbol_put_addr(void *addr); 457void symbol_put_addr(void *addr);
458 458
459/* Sometimes we know we already have a refcount, and it's easier not 459/* Sometimes we know we already have a refcount, and it's easier not
diff --git a/kernel/Makefile b/kernel/Makefile
index d1574d47cf27..271fd3119af9 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -176,7 +176,7 @@ signing_key.priv signing_key.x509: x509.genkey
176 openssl req -new -nodes -utf8 -$(CONFIG_MODULE_SIG_HASH) -days 36500 \ 176 openssl req -new -nodes -utf8 -$(CONFIG_MODULE_SIG_HASH) -days 36500 \
177 -batch -x509 -config x509.genkey \ 177 -batch -x509 -config x509.genkey \
178 -outform DER -out signing_key.x509 \ 178 -outform DER -out signing_key.x509 \
179 -keyout signing_key.priv 179 -keyout signing_key.priv 2>&1
180 @echo "###" 180 @echo "###"
181 @echo "### Key pair generated." 181 @echo "### Key pair generated."
182 @echo "###" 182 @echo "###"
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 2169feeba529..3127ad52cdb2 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -84,9 +84,11 @@ static int is_ksym_addr(unsigned long addr)
84 84
85/* 85/*
86 * Expand a compressed symbol data into the resulting uncompressed string, 86 * Expand a compressed symbol data into the resulting uncompressed string,
87 * if uncompressed string is too long (>= maxlen), it will be truncated,
87 * given the offset to where the symbol is in the compressed stream. 88 * given the offset to where the symbol is in the compressed stream.
88 */ 89 */
89static unsigned int kallsyms_expand_symbol(unsigned int off, char *result) 90static unsigned int kallsyms_expand_symbol(unsigned int off,
91 char *result, size_t maxlen)
90{ 92{
91 int len, skipped_first = 0; 93 int len, skipped_first = 0;
92 const u8 *tptr, *data; 94 const u8 *tptr, *data;
@@ -113,15 +115,20 @@ static unsigned int kallsyms_expand_symbol(unsigned int off, char *result)
113 115
114 while (*tptr) { 116 while (*tptr) {
115 if (skipped_first) { 117 if (skipped_first) {
118 if (maxlen <= 1)
119 goto tail;
116 *result = *tptr; 120 *result = *tptr;
117 result++; 121 result++;
122 maxlen--;
118 } else 123 } else
119 skipped_first = 1; 124 skipped_first = 1;
120 tptr++; 125 tptr++;
121 } 126 }
122 } 127 }
123 128
124 *result = '\0'; 129tail:
130 if (maxlen)
131 *result = '\0';
125 132
126 /* Return to offset to the next symbol. */ 133 /* Return to offset to the next symbol. */
127 return off; 134 return off;
@@ -176,7 +183,7 @@ unsigned long kallsyms_lookup_name(const char *name)
176 unsigned int off; 183 unsigned int off;
177 184
178 for (i = 0, off = 0; i < kallsyms_num_syms; i++) { 185 for (i = 0, off = 0; i < kallsyms_num_syms; i++) {
179 off = kallsyms_expand_symbol(off, namebuf); 186 off = kallsyms_expand_symbol(off, namebuf, ARRAY_SIZE(namebuf));
180 187
181 if (strcmp(namebuf, name) == 0) 188 if (strcmp(namebuf, name) == 0)
182 return kallsyms_addresses[i]; 189 return kallsyms_addresses[i];
@@ -195,7 +202,7 @@ int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *,
195 int ret; 202 int ret;
196 203
197 for (i = 0, off = 0; i < kallsyms_num_syms; i++) { 204 for (i = 0, off = 0; i < kallsyms_num_syms; i++) {
198 off = kallsyms_expand_symbol(off, namebuf); 205 off = kallsyms_expand_symbol(off, namebuf, ARRAY_SIZE(namebuf));
199 ret = fn(data, namebuf, NULL, kallsyms_addresses[i]); 206 ret = fn(data, namebuf, NULL, kallsyms_addresses[i]);
200 if (ret != 0) 207 if (ret != 0)
201 return ret; 208 return ret;
@@ -294,7 +301,8 @@ const char *kallsyms_lookup(unsigned long addr,
294 301
295 pos = get_symbol_pos(addr, symbolsize, offset); 302 pos = get_symbol_pos(addr, symbolsize, offset);
296 /* Grab name */ 303 /* Grab name */
297 kallsyms_expand_symbol(get_symbol_offset(pos), namebuf); 304 kallsyms_expand_symbol(get_symbol_offset(pos),
305 namebuf, KSYM_NAME_LEN);
298 if (modname) 306 if (modname)
299 *modname = NULL; 307 *modname = NULL;
300 return namebuf; 308 return namebuf;
@@ -315,7 +323,8 @@ int lookup_symbol_name(unsigned long addr, char *symname)
315 323
316 pos = get_symbol_pos(addr, NULL, NULL); 324 pos = get_symbol_pos(addr, NULL, NULL);
317 /* Grab name */ 325 /* Grab name */
318 kallsyms_expand_symbol(get_symbol_offset(pos), symname); 326 kallsyms_expand_symbol(get_symbol_offset(pos),
327 symname, KSYM_NAME_LEN);
319 return 0; 328 return 0;
320 } 329 }
321 /* See if it's in a module. */ 330 /* See if it's in a module. */
@@ -333,7 +342,8 @@ int lookup_symbol_attrs(unsigned long addr, unsigned long *size,
333 342
334 pos = get_symbol_pos(addr, size, offset); 343 pos = get_symbol_pos(addr, size, offset);
335 /* Grab name */ 344 /* Grab name */
336 kallsyms_expand_symbol(get_symbol_offset(pos), name); 345 kallsyms_expand_symbol(get_symbol_offset(pos),
346 name, KSYM_NAME_LEN);
337 modname[0] = '\0'; 347 modname[0] = '\0';
338 return 0; 348 return 0;
339 } 349 }
@@ -463,7 +473,7 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
463 473
464 iter->type = kallsyms_get_symbol_type(off); 474 iter->type = kallsyms_get_symbol_type(off);
465 475
466 off = kallsyms_expand_symbol(off, iter->name); 476 off = kallsyms_expand_symbol(off, iter->name, ARRAY_SIZE(iter->name));
467 477
468 return off - iter->nameoff; 478 return off - iter->nameoff;
469} 479}
diff --git a/kernel/modsign_certificate.S b/kernel/modsign_certificate.S
index 246b4c6e6135..4a9a86d12c8b 100644
--- a/kernel/modsign_certificate.S
+++ b/kernel/modsign_certificate.S
@@ -1,15 +1,8 @@
1/* SYMBOL_PREFIX defined on commandline from CONFIG_SYMBOL_PREFIX */ 1#include <linux/export.h>
2#ifndef SYMBOL_PREFIX
3#define ASM_SYMBOL(sym) sym
4#else
5#define PASTE2(x,y) x##y
6#define PASTE(x,y) PASTE2(x,y)
7#define ASM_SYMBOL(sym) PASTE(SYMBOL_PREFIX, sym)
8#endif
9 2
10#define GLOBAL(name) \ 3#define GLOBAL(name) \
11 .globl ASM_SYMBOL(name); \ 4 .globl VMLINUX_SYMBOL(name); \
12 ASM_SYMBOL(name): 5 VMLINUX_SYMBOL(name):
13 6
14 .section ".init.data","aw" 7 .section ".init.data","aw"
15 8
diff --git a/kernel/module.c b/kernel/module.c
index 0925c9a71975..b049939177f6 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1209,10 +1209,11 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,
1209 1209
1210 /* Since this should be found in kernel (which can't be removed), 1210 /* Since this should be found in kernel (which can't be removed),
1211 * no locking is necessary. */ 1211 * no locking is necessary. */
1212 if (!find_symbol(MODULE_SYMBOL_PREFIX "module_layout", NULL, 1212 if (!find_symbol(VMLINUX_SYMBOL_STR(module_layout), NULL,
1213 &crc, true, false)) 1213 &crc, true, false))
1214 BUG(); 1214 BUG();
1215 return check_version(sechdrs, versindex, "module_layout", mod, crc, 1215 return check_version(sechdrs, versindex,
1216 VMLINUX_SYMBOL_STR(module_layout), mod, crc,
1216 NULL); 1217 NULL);
1217} 1218}
1218 1219
@@ -1861,12 +1862,12 @@ static void free_module(struct module *mod)
1861{ 1862{
1862 trace_module_free(mod); 1863 trace_module_free(mod);
1863 1864
1864 /* Delete from various lists */
1865 mutex_lock(&module_mutex);
1866 stop_machine(__unlink_module, mod, NULL);
1867 mutex_unlock(&module_mutex);
1868 mod_sysfs_teardown(mod); 1865 mod_sysfs_teardown(mod);
1869 1866
1867 /* We leave it in list to prevent duplicate loads, but make sure
1868 * that noone uses it while it's being deconstructed. */
1869 mod->state = MODULE_STATE_UNFORMED;
1870
1870 /* Remove dynamic debug info */ 1871 /* Remove dynamic debug info */
1871 ddebug_remove_module(mod->name); 1872 ddebug_remove_module(mod->name);
1872 1873
@@ -1879,6 +1880,11 @@ static void free_module(struct module *mod)
1879 /* Free any allocated parameters. */ 1880 /* Free any allocated parameters. */
1880 destroy_params(mod->kp, mod->num_kp); 1881 destroy_params(mod->kp, mod->num_kp);
1881 1882
1883 /* Now we can delete it from the lists */
1884 mutex_lock(&module_mutex);
1885 stop_machine(__unlink_module, mod, NULL);
1886 mutex_unlock(&module_mutex);
1887
1882 /* This may be NULL, but that's OK */ 1888 /* This may be NULL, but that's OK */
1883 unset_module_init_ro_nx(mod); 1889 unset_module_init_ro_nx(mod);
1884 module_free(mod, mod->module_init); 1890 module_free(mod, mod->module_init);
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 0e801c3cdaf8..d5d859c80729 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -211,7 +211,8 @@ $(obj)/%.i: $(src)/%.c FORCE
211 211
212cmd_gensymtypes = \ 212cmd_gensymtypes = \
213 $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ 213 $(CPP) -D__GENKSYMS__ $(c_flags) $< | \
214 $(GENKSYMS) $(if $(1), -T $(2)) -a $(ARCH) \ 214 $(GENKSYMS) $(if $(1), -T $(2)) \
215 $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \
215 $(if $(KBUILD_PRESERVE),-p) \ 216 $(if $(KBUILD_PRESERVE),-p) \
216 -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) 217 -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null))
217 218
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 3e73dfd838cd..51bb3de680b6 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -119,13 +119,6 @@ _c_flags += $(if $(patsubst n%,, \
119 $(CFLAGS_GCOV)) 119 $(CFLAGS_GCOV))
120endif 120endif
121 121
122ifdef CONFIG_SYMBOL_PREFIX
123_sym_flags = -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))
124_cpp_flags += $(_sym_flags)
125_a_flags += $(_sym_flags)
126endif
127
128
129# If building the kernel in a separate objtree expand all occurrences 122# If building the kernel in a separate objtree expand all occurrences
130# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). 123# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
131 124
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index cf82c832458f..8dcdca27d836 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -60,7 +60,8 @@ kernelsymfile := $(objtree)/Module.symvers
60modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers 60modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers
61 61
62# Step 1), find all modules listed in $(MODVERDIR)/ 62# Step 1), find all modules listed in $(MODVERDIR)/
63__modules := $(sort $(shell grep -h '\.ko$$' /dev/null $(wildcard $(MODVERDIR)/*.mod))) 63MODLISTCMD := find $(MODVERDIR) -name '*.mod' | xargs -r grep -h '\.ko$$' | sort -u
64__modules := $(shell $(MODLISTCMD))
64modules := $(patsubst %.o,%.ko, $(wildcard $(__modules:.ko=.o))) 65modules := $(patsubst %.o,%.ko, $(wildcard $(__modules:.ko=.o)))
65 66
66# Stop after building .o files if NOFINAL is set. Makes compile tests quicker 67# Stop after building .o files if NOFINAL is set. Makes compile tests quicker
@@ -78,12 +79,13 @@ modpost = scripts/mod/modpost \
78 $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \ 79 $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \
79 $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) 80 $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w)
80 81
82# We can go over command line length here, so be careful.
81quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules 83quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules
82 cmd_modpost = $(modpost) -s 84 cmd_modpost = $(MODLISTCMD) | sed 's/\.ko$$/.o/' | $(modpost) -s -T -
83 85
84PHONY += __modpost 86PHONY += __modpost
85__modpost: $(modules:.ko=.o) FORCE 87__modpost: $(modules:.ko=.o) FORCE
86 $(call cmd,modpost) $(wildcard vmlinux) $(filter-out FORCE,$^) 88 $(call cmd,modpost) $(wildcard vmlinux)
87 89
88quiet_cmd_kernel-mod = MODPOST $@ 90quiet_cmd_kernel-mod = MODPOST $@
89 cmd_kernel-mod = $(modpost) $@ 91 cmd_kernel-mod = $(modpost) $@
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
index d25e4a118d37..88632df4381b 100644
--- a/scripts/genksyms/genksyms.c
+++ b/scripts/genksyms/genksyms.c
@@ -45,7 +45,6 @@ int in_source_file;
45 45
46static int flag_debug, flag_dump_defs, flag_reference, flag_dump_types, 46static int flag_debug, flag_dump_defs, flag_reference, flag_dump_types,
47 flag_preserve, flag_warnings; 47 flag_preserve, flag_warnings;
48static const char *arch = "";
49static const char *mod_prefix = ""; 48static const char *mod_prefix = "";
50 49
51static int errors; 50static int errors;
@@ -731,7 +730,7 @@ static void genksyms_usage(void)
731{ 730{
732 fputs("Usage:\n" "genksyms [-adDTwqhV] > /path/to/.tmp_obj.ver\n" "\n" 731 fputs("Usage:\n" "genksyms [-adDTwqhV] > /path/to/.tmp_obj.ver\n" "\n"
733#ifdef __GNU_LIBRARY__ 732#ifdef __GNU_LIBRARY__
734 " -a, --arch Select architecture\n" 733 " -s, --symbol-prefix Select symbol prefix\n"
735 " -d, --debug Increment the debug level (repeatable)\n" 734 " -d, --debug Increment the debug level (repeatable)\n"
736 " -D, --dump Dump expanded symbol defs (for debugging only)\n" 735 " -D, --dump Dump expanded symbol defs (for debugging only)\n"
737 " -r, --reference file Read reference symbols from a file\n" 736 " -r, --reference file Read reference symbols from a file\n"
@@ -742,7 +741,7 @@ static void genksyms_usage(void)
742 " -h, --help Print this message\n" 741 " -h, --help Print this message\n"
743 " -V, --version Print the release version\n" 742 " -V, --version Print the release version\n"
744#else /* __GNU_LIBRARY__ */ 743#else /* __GNU_LIBRARY__ */
745 " -a Select architecture\n" 744 " -s Select symbol prefix\n"
746 " -d Increment the debug level (repeatable)\n" 745 " -d Increment the debug level (repeatable)\n"
747 " -D Dump expanded symbol defs (for debugging only)\n" 746 " -D Dump expanded symbol defs (for debugging only)\n"
748 " -r file Read reference symbols from a file\n" 747 " -r file Read reference symbols from a file\n"
@@ -763,7 +762,7 @@ int main(int argc, char **argv)
763 762
764#ifdef __GNU_LIBRARY__ 763#ifdef __GNU_LIBRARY__
765 struct option long_opts[] = { 764 struct option long_opts[] = {
766 {"arch", 1, 0, 'a'}, 765 {"symbol-prefix", 1, 0, 's'},
767 {"debug", 0, 0, 'd'}, 766 {"debug", 0, 0, 'd'},
768 {"warnings", 0, 0, 'w'}, 767 {"warnings", 0, 0, 'w'},
769 {"quiet", 0, 0, 'q'}, 768 {"quiet", 0, 0, 'q'},
@@ -776,14 +775,14 @@ int main(int argc, char **argv)
776 {0, 0, 0, 0} 775 {0, 0, 0, 0}
777 }; 776 };
778 777
779 while ((o = getopt_long(argc, argv, "a:dwqVDr:T:ph", 778 while ((o = getopt_long(argc, argv, "s:dwqVDr:T:ph",
780 &long_opts[0], NULL)) != EOF) 779 &long_opts[0], NULL)) != EOF)
781#else /* __GNU_LIBRARY__ */ 780#else /* __GNU_LIBRARY__ */
782 while ((o = getopt(argc, argv, "a:dwqVDr:T:ph")) != EOF) 781 while ((o = getopt(argc, argv, "s:dwqVDr:T:ph")) != EOF)
783#endif /* __GNU_LIBRARY__ */ 782#endif /* __GNU_LIBRARY__ */
784 switch (o) { 783 switch (o) {
785 case 'a': 784 case 's':
786 arch = optarg; 785 mod_prefix = optarg;
787 break; 786 break;
788 case 'd': 787 case 'd':
789 flag_debug++; 788 flag_debug++;
@@ -826,9 +825,6 @@ int main(int argc, char **argv)
826 genksyms_usage(); 825 genksyms_usage();
827 return 1; 826 return 1;
828 } 827 }
829 if ((strcmp(arch, "h8300") == 0) || (strcmp(arch, "blackfin") == 0) ||
830 (strcmp(arch, "metag") == 0))
831 mod_prefix = "_";
832 { 828 {
833 extern int yydebug; 829 extern int yydebug;
834 extern int yy_flex_debug; 830 extern int yy_flex_debug;
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index 3d569d6022c2..014994936b1c 100644
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -74,9 +74,8 @@ kallsyms()
74 info KSYM ${2} 74 info KSYM ${2}
75 local kallsymopt; 75 local kallsymopt;
76 76
77 if [ -n "${CONFIG_SYMBOL_PREFIX}" ]; then 77 if [ -n "${CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX}" ]; then
78 kallsymopt="${kallsymopt} \ 78 kallsymopt="${kallsymopt} --symbol-prefix=_"
79 --symbol-prefix=${CONFIG_SYMBOL_PREFIX}"
80 fi 79 fi
81 80
82 if [ -n "${CONFIG_KALLSYMS_ALL}" ]; then 81 if [ -n "${CONFIG_KALLSYMS_ALL}" ]; then
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 78b30c1548e9..a4be8e112bb6 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -15,17 +15,12 @@
15#include <stdio.h> 15#include <stdio.h>
16#include <ctype.h> 16#include <ctype.h>
17#include <string.h> 17#include <string.h>
18#include <limits.h>
19#include <stdbool.h>
18#include "modpost.h" 20#include "modpost.h"
19#include "../../include/generated/autoconf.h" 21#include "../../include/generated/autoconf.h"
20#include "../../include/linux/license.h" 22#include "../../include/linux/license.h"
21 23#include "../../include/linux/export.h"
22/* Some toolchains use a `_' prefix for all user symbols. */
23#ifdef CONFIG_SYMBOL_PREFIX
24#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX
25#else
26#define MODULE_SYMBOL_PREFIX ""
27#endif
28
29 24
30/* Are we using CONFIG_MODVERSIONS? */ 25/* Are we using CONFIG_MODVERSIONS? */
31int modversions = 0; 26int modversions = 0;
@@ -85,6 +80,14 @@ PRINTF void merror(const char *fmt, ...)
85 va_end(arglist); 80 va_end(arglist);
86} 81}
87 82
83static inline bool strends(const char *str, const char *postfix)
84{
85 if (strlen(str) < strlen(postfix))
86 return false;
87
88 return strcmp(str + strlen(str) - strlen(postfix), postfix) == 0;
89}
90
88static int is_vmlinux(const char *modname) 91static int is_vmlinux(const char *modname)
89{ 92{
90 const char *myname; 93 const char *myname;
@@ -120,22 +123,20 @@ static struct module *find_module(char *modname)
120 return mod; 123 return mod;
121} 124}
122 125
123static struct module *new_module(char *modname) 126static struct module *new_module(const char *modname)
124{ 127{
125 struct module *mod; 128 struct module *mod;
126 char *p, *s; 129 char *p;
127 130
128 mod = NOFAIL(malloc(sizeof(*mod))); 131 mod = NOFAIL(malloc(sizeof(*mod)));
129 memset(mod, 0, sizeof(*mod)); 132 memset(mod, 0, sizeof(*mod));
130 p = NOFAIL(strdup(modname)); 133 p = NOFAIL(strdup(modname));
131 134
132 /* strip trailing .o */ 135 /* strip trailing .o */
133 s = strrchr(p, '.'); 136 if (strends(p, ".o")) {
134 if (s != NULL) 137 p[strlen(p) - 2] = '\0';
135 if (strcmp(s, ".o") == 0) { 138 mod->is_dot_o = 1;
136 *s = '\0'; 139 }
137 mod->is_dot_o = 1;
138 }
139 140
140 /* add to list */ 141 /* add to list */
141 mod->name = p; 142 mod->name = p;
@@ -562,7 +563,7 @@ static void parse_elf_finish(struct elf_info *info)
562static int ignore_undef_symbol(struct elf_info *info, const char *symname) 563static int ignore_undef_symbol(struct elf_info *info, const char *symname)
563{ 564{
564 /* ignore __this_module, it will be resolved shortly */ 565 /* ignore __this_module, it will be resolved shortly */
565 if (strcmp(symname, MODULE_SYMBOL_PREFIX "__this_module") == 0) 566 if (strcmp(symname, VMLINUX_SYMBOL_STR(__this_module)) == 0)
566 return 1; 567 return 1;
567 /* ignore global offset table */ 568 /* ignore global offset table */
568 if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0) 569 if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0)
@@ -583,8 +584,8 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)
583 return 0; 584 return 0;
584} 585}
585 586
586#define CRC_PFX MODULE_SYMBOL_PREFIX "__crc_" 587#define CRC_PFX VMLINUX_SYMBOL_STR(__crc_)
587#define KSYMTAB_PFX MODULE_SYMBOL_PREFIX "__ksymtab_" 588#define KSYMTAB_PFX VMLINUX_SYMBOL_STR(__ksymtab_)
588 589
589static void handle_modversions(struct module *mod, struct elf_info *info, 590static void handle_modversions(struct module *mod, struct elf_info *info,
590 Elf_Sym *sym, const char *symname) 591 Elf_Sym *sym, const char *symname)
@@ -637,14 +638,15 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
637 } 638 }
638#endif 639#endif
639 640
640 if (memcmp(symname, MODULE_SYMBOL_PREFIX, 641#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX
641 strlen(MODULE_SYMBOL_PREFIX)) == 0) { 642 if (symname[0] != '_')
642 mod->unres = 643 break;
643 alloc_symbol(symname + 644 else
644 strlen(MODULE_SYMBOL_PREFIX), 645 symname++;
645 ELF_ST_BIND(sym->st_info) == STB_WEAK, 646#endif
646 mod->unres); 647 mod->unres = alloc_symbol(symname,
647 } 648 ELF_ST_BIND(sym->st_info) == STB_WEAK,
649 mod->unres);
648 break; 650 break;
649 default: 651 default:
650 /* All exported symbols */ 652 /* All exported symbols */
@@ -652,9 +654,9 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
652 sym_add_exported(symname + strlen(KSYMTAB_PFX), mod, 654 sym_add_exported(symname + strlen(KSYMTAB_PFX), mod,
653 export); 655 export);
654 } 656 }
655 if (strcmp(symname, MODULE_SYMBOL_PREFIX "init_module") == 0) 657 if (strcmp(symname, VMLINUX_SYMBOL_STR(init_module)) == 0)
656 mod->has_init = 1; 658 mod->has_init = 1;
657 if (strcmp(symname, MODULE_SYMBOL_PREFIX "cleanup_module") == 0) 659 if (strcmp(symname, VMLINUX_SYMBOL_STR(cleanup_module)) == 0)
658 mod->has_cleanup = 1; 660 mod->has_cleanup = 1;
659 break; 661 break;
660 } 662 }
@@ -1762,6 +1764,27 @@ static void read_symbols(char *modname)
1762 mod->unres = alloc_symbol("module_layout", 0, mod->unres); 1764 mod->unres = alloc_symbol("module_layout", 0, mod->unres);
1763} 1765}
1764 1766
1767static void read_symbols_from_files(const char *filename)
1768{
1769 FILE *in = stdin;
1770 char fname[PATH_MAX];
1771
1772 if (strcmp(filename, "-") != 0) {
1773 in = fopen(filename, "r");
1774 if (!in)
1775 fatal("Can't open filenames file %s: %m", filename);
1776 }
1777
1778 while (fgets(fname, PATH_MAX, in) != NULL) {
1779 if (strends(fname, "\n"))
1780 fname[strlen(fname)-1] = '\0';
1781 read_symbols(fname);
1782 }
1783
1784 if (in != stdin)
1785 fclose(in);
1786}
1787
1765#define SZ 500 1788#define SZ 500
1766 1789
1767/* We first write the generated file into memory using the 1790/* We first write the generated file into memory using the
@@ -1934,7 +1957,8 @@ static int add_versions(struct buffer *b, struct module *mod)
1934 s->name, mod->name); 1957 s->name, mod->name);
1935 continue; 1958 continue;
1936 } 1959 }
1937 buf_printf(b, "\t{ %#8x, \"%s\" },\n", s->crc, s->name); 1960 buf_printf(b, "\t{ %#8x, __VMLINUX_SYMBOL_STR(%s) },\n",
1961 s->crc, s->name);
1938 } 1962 }
1939 1963
1940 buf_printf(b, "};\n"); 1964 buf_printf(b, "};\n");
@@ -2122,13 +2146,13 @@ int main(int argc, char **argv)
2122 struct module *mod; 2146 struct module *mod;
2123 struct buffer buf = { }; 2147 struct buffer buf = { };
2124 char *kernel_read = NULL, *module_read = NULL; 2148 char *kernel_read = NULL, *module_read = NULL;
2125 char *dump_write = NULL; 2149 char *dump_write = NULL, *files_source = NULL;
2126 int opt; 2150 int opt;
2127 int err; 2151 int err;
2128 struct ext_sym_list *extsym_iter; 2152 struct ext_sym_list *extsym_iter;
2129 struct ext_sym_list *extsym_start = NULL; 2153 struct ext_sym_list *extsym_start = NULL;
2130 2154
2131 while ((opt = getopt(argc, argv, "i:I:e:msSo:awM:K:")) != -1) { 2155 while ((opt = getopt(argc, argv, "i:I:e:msST:o:awM:K:")) != -1) {
2132 switch (opt) { 2156 switch (opt) {
2133 case 'i': 2157 case 'i':
2134 kernel_read = optarg; 2158 kernel_read = optarg;
@@ -2160,6 +2184,9 @@ int main(int argc, char **argv)
2160 case 'S': 2184 case 'S':
2161 sec_mismatch_verbose = 0; 2185 sec_mismatch_verbose = 0;
2162 break; 2186 break;
2187 case 'T':
2188 files_source = optarg;
2189 break;
2163 case 'w': 2190 case 'w':
2164 warn_unresolved = 1; 2191 warn_unresolved = 1;
2165 break; 2192 break;
@@ -2182,6 +2209,9 @@ int main(int argc, char **argv)
2182 while (optind < argc) 2209 while (optind < argc)
2183 read_symbols(argv[optind++]); 2210 read_symbols(argv[optind++]);
2184 2211
2212 if (files_source)
2213 read_symbols_from_files(files_source);
2214
2185 for (mod = modules; mod; mod = mod->next) { 2215 for (mod = modules; mod; mod = mod->next) {
2186 if (mod->skip) 2216 if (mod->skip)
2187 continue; 2217 continue;