diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2013-03-15 00:34:17 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2013-03-15 00:39:43 -0400 |
commit | b92021b09df70c1609e3547f3d6128dd560be97f (patch) | |
tree | 0203752a738c71718f5141b84f5143d1dc8b431d /include | |
parent | 4febd95a8a85dd38b1a71fcf9726e19c7fd20039 (diff) |
CONFIG_SYMBOL_PREFIX: cleanup.
We have CONFIG_SYMBOL_PREFIX, which three archs define to the string
"_". But Al Viro broke this in "consolidate cond_syscall and
SYSCALL_ALIAS declarations" (in linux-next), and he's not the first to
do so.
Using CONFIG_SYMBOL_PREFIX is awkward, since we usually just want to
prefix it so something. So various places define helpers which are
defined to nothing if CONFIG_SYMBOL_PREFIX isn't set:
1) include/asm-generic/unistd.h defines __SYMBOL_PREFIX.
2) include/asm-generic/vmlinux.lds.h defines VMLINUX_SYMBOL(sym)
3) include/linux/export.h defines MODULE_SYMBOL_PREFIX.
4) include/linux/kernel.h defines SYMBOL_PREFIX (which differs from #7)
5) kernel/modsign_certificate.S defines ASM_SYMBOL(sym)
6) scripts/modpost.c defines MODULE_SYMBOL_PREFIX
7) scripts/Makefile.lib defines SYMBOL_PREFIX on the commandline if
CONFIG_SYMBOL_PREFIX is set, so that we have a non-string version
for pasting.
(arch/h8300/include/asm/linkage.h defines SYMBOL_NAME(), too).
Let's solve this properly:
1) No more generic prefix, just CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX.
2) Make linux/export.h usable from asm.
3) Define VMLINUX_SYMBOL() and VMLINUX_SYMBOL_STR().
4) Make everyone use them.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Reviewed-by: James Hogan <james.hogan@imgtec.com>
Tested-by: James Hogan <james.hogan@imgtec.com> (metag)
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/unistd.h | 12 | ||||
-rw-r--r-- | include/asm-generic/vmlinux.lds.h | 8 | ||||
-rw-r--r-- | include/linux/export.h | 20 | ||||
-rw-r--r-- | include/linux/kernel.h | 7 | ||||
-rw-r--r-- | include/linux/module.h | 4 |
5 files changed, 21 insertions, 30 deletions
diff --git a/include/asm-generic/unistd.h b/include/asm-generic/unistd.h index 4077b5d9ff81..15c0598e1109 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 |
@@ -17,12 +18,7 @@ | |||
17 | * but it doesn't work on all toolchains, so we just do it by hand | 18 | * but it doesn't work on all toolchains, so we just do it by hand |
18 | */ | 19 | */ |
19 | #ifndef cond_syscall | 20 | #ifndef cond_syscall |
20 | #ifdef CONFIG_SYMBOL_PREFIX | 21 | #define cond_syscall(x) asm(".weak\t" VMLINUX_SYMBOL_STR(x) "\n\t" \ |
21 | #define __SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX | 22 | ".set\t" VMLINUX_SYMBOL_STR(x) "," \ |
22 | #else | 23 | VMLINUX_SYMBOL_STR(sys_ni_syscall)) |
23 | #define __SYMBOL_PREFIX | ||
24 | #endif | ||
25 | #define cond_syscall(x) asm(".weak\t" __SYMBOL_PREFIX #x "\n\t" \ | ||
26 | ".set\t" __SYMBOL_PREFIX #x "," \ | ||
27 | __SYMBOL_PREFIX "sys_ni_syscall") | ||
28 | #endif | 24 | #endif |
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__ | ||
19 | struct kernel_symbol | 26 | struct 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 80d36874689b..e13e992eae8a 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -723,13 +723,6 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
723 | /* Trap pasters of __FUNCTION__ at compile-time */ | 723 | /* Trap pasters of __FUNCTION__ at compile-time */ |
724 | #define __FUNCTION__ (__func__) | 724 | #define __FUNCTION__ (__func__) |
725 | 725 | ||
726 | /* This helps us to avoid #ifdef CONFIG_SYMBOL_PREFIX */ | ||
727 | #ifdef CONFIG_SYMBOL_PREFIX | ||
728 | #define SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX | ||
729 | #else | ||
730 | #define SYMBOL_PREFIX "" | ||
731 | #endif | ||
732 | |||
733 | /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ | 726 | /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ |
734 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD | 727 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD |
735 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD | 728 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD |
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) */ |
191 | void *__symbol_get(const char *symbol); | 191 | void *__symbol_get(const char *symbol); |
192 | void *__symbol_get_gpl(const char *symbol); | 192 | void *__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. */ |
196 | struct module_use { | 196 | struct 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 |
454 | unsigned long module_refcount(struct module *mod); | 454 | unsigned long module_refcount(struct module *mod); |
455 | void __symbol_put(const char *symbol); | 455 | void __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)) |
457 | void symbol_put_addr(void *addr); | 457 | void 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 |