linux/linkage.h: fix symbol prefix handling
Subsystems (5)
RFC 1/1 linux/linkage.h: fix symbol prefix handling
The commit "consolidate cond_syscall and SYSCALL_ALIAS declarations" broke the build on blackfin and metag due to the following code:
#ifndef SYMBOL_NAME #ifdef CONFIG_SYMBOL_PREFIX #define SYMBOL_NAME(x) CONFIG_SYMBOL_PREFIX ## x #else #define SYMBOL_NAME(x) x #endif #endif #define __SYMBOL_NAME(x) __stringify(SYMBOL_NAME(x))
__stringify literally stringifies CONFIG_SYMBOL_PREFIX ##x, so you get lines like this in the assembly output:
.weak CONFIG_SYMBOL_PREFIXsys_quotactl
.set CONFIG_SYMBOL_PREFIXsys_quotactl,CONFIG_SYMBOL_PREFIXsys_ni_syscall
This is fixed by defining SYMBOL_PREFIX from the command line for c files in addition to assembly for architectures that set CONFIG_SYMBOL_PREFIX (scripts/Makefile.lib), and defining __SYMBOL_NAME as:
#define __SYMBOL_NAME(x) __stringify(SYMBOL_PREFIX) #x
We first have to ensure SYMBOL_PREFIX is defined (which avoids polluting the command lines for architectures that don't use symbol prefixes). Also the definition of SYMBOL_PREFIX in <linux/kernel.h> is removed as it conflicts, isn't used anywhere, and is defined as a string so differs from the assembly definition.
---
This is just one possible way of fixing it. It felt the cleanest out of the ways I tried, but feel free to suggest something better!
include/linux/kernel.h | 7 ------- include/linux/linkage.h | 12 +++++------- scripts/Makefile.lib | 1 + 3 files changed, 6 insertions(+), 14 deletions(-)
include/linux/kernel.h +0 -7
@@ -723,13 +723,6 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }/* Trap pasters of __FUNCTION__ at compile-time */ #define __FUNCTION__ (__func__) -/* This helps us to avoid #ifdef CONFIG_SYMBOL_PREFIX */ -#ifdef CONFIG_SYMBOL_PREFIX -#define SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX -#else -#define SYMBOL_PREFIX "" -#endif -/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ #ifdef CONFIG_FTRACE_MCOUNT_RECORD # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
include/linux/linkage.h +5 -7
@@ -15,14 +15,12 @@#define asmlinkage CPP_ASMLINKAGE#endif -#ifndef SYMBOL_NAME -#ifdef CONFIG_SYMBOL_PREFIX -#define SYMBOL_NAME (x) CONFIG_SYMBOL_PREFIX ## x -#else -#define SYMBOL_NAME (x) x -#endif +/* This helps us to avoid #ifdef SYMBOL_PREFIX */ +#ifndef SYMBOL_PREFIX +#define SYMBOL_PREFIX #endif -#define __SYMBOL_NAME (x) __stringify(SYMBOL_NAME(x)) + +#define __SYMBOL_NAME (x) __stringify(SYMBOL_PREFIX) #x#ifndef cond_syscall#define cond_syscall (x) asm(".weak\t" __SYMBOL_NAME(x) \
scripts/Makefile.lib +1 -0
@@ -123,6 +123,7 @@ ifdef CONFIG_SYMBOL_PREFIX _sym_flags = -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX)) _cpp_flags += $(_sym_flags) _a_flags += $(_sym_flags) +_c_flags += $(_sym_flags) endif
Signature · 1 line
1.8.1.2
Quoted 24 lines · James Hogan
The commit "consolidate
cond_syscallandSYSCALL_ALIASdeclarations" broke the build on blackfin and metag due to the following code:#ifndef SYMBOL_NAME #ifdef CONFIG_SYMBOL_PREFIX #define SYMBOL_NAME(x) CONFIG_SYMBOL_PREFIX ## x #else #define SYMBOL_NAME(x) x #endif #endif #define __SYMBOL_NAME(x) __stringify(SYMBOL_NAME(x))
__stringifyliterally stringifiesCONFIG_SYMBOL_PREFIX##x, so you get lines like this in the assembly output:.weak
CONFIG_SYMBOL_PREFIXsys_quotactl
.set CONFIG_SYMBOL_PREFIXsys_quotactl,CONFIG_SYMBOL_PREFIXsys_ni_syscallThis is fixed by defining
SYMBOL_PREFIXfrom the command line for c files in addition to assembly for architectures that setCONFIG_SYMBOL_PREFIX(scripts/Makefile.lib), and defining__SYMBOL_NAMEas:
Quoted 7 lines
#define __SYMBOL_NAME(x) __stringify(SYMBOL_PREFIX) #xWe first have to ensure
SYMBOL_PREFIXis defined (which avoids polluting the command lines for architectures that don't use symbol prefixes). Also the definition ofSYMBOL_PREFIXin <linux/kernel.h> is removed as it conflicts, isn't used anywhere, and is defined as a string so differs from the assembly definition.
So now, if CONFIG_SYMBOL_PREFIX, SYMBOL_PREFIX is defined on the cmdline as a string. Otherwise it's empty (not the empty string?):
include/linux/linkage.h line 23
Quoted 7 lines
include/linux/linkage.h +5
-1+/* This helps us to avoid #ifdef SYMBOL_PREFIX */ +#ifndef SYMBOL_PREFIX +#define SYMBOL_PREFIX #endif -#define __SYMBOL_NAME (x) __stringify(SYMBOL_NAME(x)) + +#define __SYMBOL_NAME (x) __stringify(SYMBOL_PREFIX) #x
And why are you __stringify()ing a string?
scripts/Makefile.lib ifdef CONFIG_SYMBOL_PREFIX · line 127
Quoted 12 lines
#ifndef
cond_syscall
#definecond_syscall(x)asm(".weak\t"__SYMBOL_NAME(x)\scripts/Makefile.lib +1
-0@@ -123,6 +123,7 @@ ifdef CONFIG_SYMBOL_PREFIX _sym_flags = -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX)) _cpp_flags += $(_sym_flags) _a_flags += $(_sym_flags) +_c_flags += $(_sym_flags) endif
Confused,
Rusty.
Hi Rusty,
Quoted 7 lines · Rusty Russell
Quoted 3 lines · James Hogan
Also the definition of
SYMBOL_PREFIXin <linux/kernel.h> is removed as it conflicts, isn't used anywhere, and is defined as a string so differs from the assembly definition.So now, if
CONFIG_SYMBOL_PREFIX,SYMBOL_PREFIXis defined on the cmdline as a string. Otherwise it's empty (not the empty string?):
No, SYMBOL_PREFIX is now defined as a non-string, same as asm files, but the now unused definition in linux/kernel.h did define it as a string as it used CONFIG_SYMBOL_PREFIX which is a string. When I said "and is defined as a string" I was referring to the one in linux/kernel.h that this removes.
Does that make sense? It's all a bit messy unfortunately (hence RFC).
Cheers
James
Quoted 4 lines · James Hogan
Hi Rusty,
Quoted 1 line · Rusty Russell
James Hogan <[email protected]> writes:
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Also the definition of
SYMBOL_PREFIXin <linux/kernel.h> is removed as it conflicts, isn't used anywhere, and is defined as a string so differs from the assembly definition.So now, if
CONFIG_SYMBOL_PREFIX,SYMBOL_PREFIXis defined on the cmdline as a string. Otherwise it's empty (not the empty string?):No,
SYMBOL_PREFIXis now defined as a non-string, same as asm files
Ah, I misread this. It's stripping the quotes, not adding them:
_sym_flags = -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))
Quoted 1 line
Does that make sense? It's all a bit messy unfortunately (hence RFC).
Yes, let's clear it up once and for all. Does this work?
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", 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_SYMBOL_PREFIX_UNDERSCORE.
2) Make linux/export.h usable from asm.
3) Define VMLINUX_SYMBOL, VMLINUX_SYMBOL_NAME and VMLINUX_SYMBOL_PREFIX_STR.
4) Make everyone use them.
Makefile +1 -1
@@ -1398,7 +1398,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)) # Run depmod only if we have System.map and depmod is executable quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ - $(KERNELRELEASE) "$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))" + $(KERNELRELEASE) "$(patsubst y,_,$(CONFIG_SYMBOL_PREFIX_UNDERSCORE))" # Create temporary dir for module support files # clean it up only when building all modules
arch/blackfin/Kconfig +2 -3
@@ -1,6 +1,5 @@ -config SYMBOL_PREFIX - string - default "_" +config SYMBOL_PREFIX_UNDERSCORE + def_bool y config MMU def_bool n
arch/h8300/Kconfig +2 -3
@@ -13,9 +13,8 @@ config H8300 select OLD_SIGSUSPEND3 select OLD_SIGACTION -config SYMBOL_PREFIX - string - default "_" +config SYMBOL_PREFIX_UNDERSCORE + def_bool y config MMU bool
arch/metag/Kconfig +2 -3
@@ -1,6 +1,5 @@ -config SYMBOL_PREFIX - string - default "_" +config SYMBOL_PREFIX_UNDERSCORE + def_bool y config METAG def_bool y
drivers/mtd/chips/gen_probe.c +3 -3
@@ -204,14 +204,14 @@ static inline struct mtd_info *cfi_cmdset_unknown(struct map_info *map,struct cfi_private *cfi = map->fldrv_priv;__u16 type = primary?cfi->cfiq->P_ID:cfi->cfiq->A_ID;#ifdef CONFIG_MODULES -char probename[16 +sizeof (MODULE_SYMBOL_PREFIX )]; +char probename[16 +sizeof (VMLINUX_SYMBOL_PREFIX_STR )];cfi_cmdset_fn_t *probe_function; -sprintf (probename,MODULE_SYMBOL_PREFIX "cfi_cmdset_%4.4X" , type); +sprintf (probename,VMLINUX_SYMBOL_PREFIX_STR "cfi_cmdset_%4.4X" , type); probe_function =__symbol_get (probename);if (!probe_function) { -request_module (probename +sizeof (MODULE_SYMBOL_PREFIX ) -1 ); +request_module (probename +sizeof (VMLINUX_SYMBOL_PREFIX_STR )-1 ); probe_function =__symbol_get (probename); }
include/asm-generic/unistd.h +4 -8
@@ -1,4 +1,5 @@#include <uapi/asm-generic/unistd.h> +#include <linux/export.h> /* * These are required system calls, we should
@@ -17,12 +18,7 @@* but it doesn't work on all toolchains, so we just do it by hand */ #ifndef cond_syscall -#ifdef CONFIG_SYMBOL_PREFIX -#define __SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX -#else -#define __SYMBOL_PREFIX -#endif -#define cond_syscall (x) asm(".weak\t" __SYMBOL_PREFIX #x "\n\t" \ - ".set\t" __SYMBOL_PREFIX #x "," \ - __SYMBOL_PREFIX "sys_ni_syscall") +#define cond_syscall (x) asm(".weak\t" SYMBOL_NAME_STR(x) "\n\t" \ + ".set\t" SYMBOL_NAME_STR(x) "," \ + SYMBOL_NAME_STR(sys_ni_syscall))#endif
include/asm-generic/vmlinux.lds.h +1 -7
@@ -52,13 +52,7 @@#define LOAD_OFFSET 0#endif -#ifndef SYMBOL_PREFIX -#define VMLINUX_SYMBOL (sym) sym -#else -#define PASTE2 (x,y) x##y -#define PASTE (x,y) PASTE2(x,y) -#define VMLINUX_SYMBOL (sym) PASTE(SYMBOL_PREFIX, sym) -#endif +#include <linux/export.h> /* Align . to a 8 byte boundary equals to maximum function alignment. */ #define ALIGN_FUNCTION () . = ALIGN(8)
include/linux/export.h +17 -4
@@ -7,15 +7,27 @@* * If you feel the need to add #include <linux/foo.h> to this file * then you are doing something wrong and should go away silently. +* +* If you think the above arrogance just encourages more people to add +* random crap to this file, you're not alone. */ /* Some toolchains use a `_' prefix for all user symbols. */ -#ifdef CONFIG_SYMBOL_PREFIX -#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX +#ifdef CONFIG_SYMBOL_PREFIX_UNDERSCORE +#define __VMLINUX_SYMBOL (x) _##x +#define __VMLINUX_SYMBOL_STR (x) "_" #x +#define VMLINUX_SYMBOL_PREFIX_STR "_"#else -#define MODULE_SYMBOL_PREFIX "" +#define __VMLINUX_SYMBOL (x) x +#define __VMLINUX_SYMBOL_STR (x) #x +#define VMLINUX_SYMBOL_PREFIX_STR ""#endif +/* Indirect, so macros are expanded before pasting. */ +#define VMLINUX_SYMBOL (x) __VMLINUX_SYMBOL(x) +#define VMLINUX_SYMBOL_STR (x) __VMLINUX_SYMBOL_STR(x) + +#ifndef __ASSEMBLY__ struct kernel_symbol { unsigned long value;
@@ -51,7 +63,7 @@ extern struct module __this_module; __CRC_SYMBOL(sym, sec) \ static const char __kstrtab_##sym[] \ __attribute__((section("__ksymtab_strings"), aligned(1))) \ - = MODULE_SYMBOL_PREFIX #sym; \ + = VMLINUX_SYMBOL_STR(sym); \ static const struct kernel_symbol __ksymtab_##sym \ __used \ __attribute__((section("___ksymtab" sec "+" #sym), unused)) \
@@ -85,5 +97,6 @@ extern struct module __this_module;#define EXPORT_UNUSED_SYMBOL_GPL (sym)#endif /* CONFIG_MODULES */ +#endif /* !__ASSEMBLY__ */ #endif /* _LINUX_EXPORT_H */
include/linux/kernel.h +0 -7
@@ -723,13 +723,6 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }/* Trap pasters of __FUNCTION__ at compile-time */ #define __FUNCTION__ (__func__) -/* This helps us to avoid #ifdef CONFIG_SYMBOL_PREFIX */ -#ifdef CONFIG_SYMBOL_PREFIX -#define SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX -#else -#define SYMBOL_PREFIX "" -#endif -/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ #ifdef CONFIG_FTRACE_MCOUNT_RECORD # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
include/linux/module.h +2 -2
@@ -190,7 +190,7 @@ extern int modules_disabled; /* for sysctl *//* Get/put a kernel symbol (calls must be symmetric) */ void *__symbol_get (const char *symbol);void *__symbol_get_gpl (const char *symbol); -#define symbol_get (x) ((typeof(&x))(__symbol_get(MODULE_SYMBOL_PREFIX #x))) +#define symbol_get (x) ((typeof(&x))(__symbol_get(VMLINUX_SYMBOL_STR(x))))/* modules using other modules: kdb wants to see this. */ struct module_use {
@@ -453,7 +453,7 @@ extern void __module_put_and_exit(struct module *mod, long code)#ifdef CONFIG_MODULE_UNLOAD unsigned long module_refcount (struct module *mod);void __symbol_put (const char *symbol); -#define symbol_put (x) __symbol_put(MODULE_SYMBOL_PREFIX #x) +#define symbol_put (x) __symbol_put(VMLINUX_SYMBOL_STR(x))void symbol_put_addr (void *addr);/* Sometimes we know we already have a refcount, and it's easier not
kernel/modsign_certificate.S +3 -10
@@ -1,15 +1,8 @@ -/* SYMBOL_PREFIX defined on commandline from CONFIG_SYMBOL_PREFIX */ -#ifndef SYMBOL_PREFIX -#define ASM_SYMBOL(sym) sym -#else -#define PASTE2(x,y) x##y -#define PASTE(x,y) PASTE2(x,y) -#define ASM_SYMBOL(sym) PASTE(SYMBOL_PREFIX, sym) -#endif +#include <linux/export.h> #define GLOBAL(name) \ - .globl ASM_SYMBOL(name); \ - ASM_SYMBOL(name): + .globl VMLINUX_SYMBOL(name); \ + VMLINUX_SYMBOL(name): .section ".init.data","aw"
kernel/module.c +1 -1
@@ -1209,7 +1209,7 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,/* Since this should be found in kernel (which can't be removed), * no locking is necessary. */ -if (!find_symbol (MODULE_SYMBOL_PREFIX "module_layout" ,NULL , +if (!find_symbol (VMLINUX_SYMBOL_STR (module_layout),NULL , &crc, true, false))BUG (); return check_version(sechdrs, versindex, "module_layout", mod, crc,
scripts/Makefile.lib +0 -7
@@ -119,13 +119,6 @@ _c_flags += $(if $(patsubst n%,, \ $(CFLAGS_GCOV)) endif -ifdef CONFIG_SYMBOL_PREFIX -_sym_flags = -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX)) -_cpp_flags += $(_sym_flags) -_a_flags += $(_sym_flags) -endif - - # If building the kernel in a separate objtree expand all occurrences # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
scripts/link-vmlinux.sh +2 -3
@@ -74,9 +74,8 @@ kallsyms() info KSYM ${2} local kallsymopt; - if [ -n "${CONFIG_SYMBOL_PREFIX}" ]; then - kallsymopt="${kallsymopt} \ - --symbol-prefix=${CONFIG_SYMBOL_PREFIX}" + if [ -n "${CONFIG_SYMBOL_PREFIX_UNDERSCORE}" ]; then + kallsymopt="${kallsymopt} --symbol-prefix=_" fi if [ -n "${CONFIG_KALLSYMS_ALL}" ]; then
scripts/mod/modpost.c +9 -16
@@ -18,14 +18,7 @@#include "modpost.h" #include "../../include/generated/autoconf.h" #include "../../include/linux/license.h" - -/* Some toolchains use a `_' prefix for all user symbols. */ -#ifdef CONFIG_SYMBOL_PREFIX -#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX -#else -#define MODULE_SYMBOL_PREFIX "" -#endif - +#include "../../include/linux/export.h" /* Are we using CONFIG_MODVERSIONS? */ int modversions =0 ;
@@ -562,7 +555,7 @@ static void parse_elf_finish(struct elf_info *info)static int ignore_undef_symbol (struct elf_info *info,const char *symname) {/* ignore __this_module, it will be resolved shortly */ -if (strcmp (symname,MODULE_SYMBOL_PREFIX "__this_module" ) ==0 ) +if (strcmp (symname,VMLINUX_SYMBOL_STR (__this_module)) ==0 )return 1 ;/* ignore global offset table */ if (strcmp (symname,"_GLOBAL_OFFSET_TABLE_" ) ==0 )
@@ -583,8 +576,8 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)return 0 ; } -#define CRC_PFX MODULE_SYMBOL_PREFIX "__crc_" -#define KSYMTAB_PFX MODULE_SYMBOL_PREFIX "__ksymtab_" +#define CRC_PFX VMLINUX_SYMBOL_STR(__crc_) +#define KSYMTAB_PFX VMLINUX_SYMBOL_STR(__ksymtab_)static void handle_modversions (struct module *mod,struct elf_info *info,Elf_Sym *sym,const char *symname)
@@ -637,11 +630,11 @@ static void handle_modversions(struct module *mod, struct elf_info *info, }#endif -if (memcmp (symname,MODULE_SYMBOL_PREFIX , -strlen (MODULE_SYMBOL_PREFIX )) ==0 ) { +if (memcmp (symname,VMLINUX_SYMBOL_PREFIX_STR , +strlen (VMLINUX_SYMBOL_PREFIX_STR )) ==0 ) { mod->unres =alloc_symbol (symname + -strlen (MODULE_SYMBOL_PREFIX ), +strlen (VMLINUX_SYMBOL_PREFIX_STR ),ELF_ST_BIND (sym->st_info) ==STB_WEAK , mod->unres); }
@@ -652,9 +645,9 @@ static void handle_modversions(struct module *mod, struct elf_info *info,sym_add_exported (symname +strlen (KSYMTAB_PFX ), mod, export); } -if (strcmp (symname,MODULE_SYMBOL_PREFIX "init_module" ) ==0 ) +if (strcmp (symname,VMLINUX_SYMBOL_STR (init_module)) ==0 ) mod->has_init =1 ; -if (strcmp (symname,MODULE_SYMBOL_PREFIX "cleanup_module" ) ==0 ) +if (strcmp (symname,VMLINUX_SYMBOL_STR (cleanup_module)) ==0 ) mod->has_cleanup =1 ;break ; }
Hi Rusty,
arch/blackfin/Kconfig line 2
Quoted 11 lines · On Mon, 11 Mar 2013 17:05:17 +1030 Rusty Russell <[email protected]> wrote:
arch/blackfin/Kconfig +2
-3@@ -1,6 +1,5 @@ -config SYMBOL_PREFIX - string - default "_" +config SYMBOL_PREFIX_UNDERSCORE + def_bool y
Please, if you are going to do this, just have
config SYMBOL_PREFIX_UNDERSCORE
bool
in one Kconfig file (probably arch/Kconfig) and then select it from the appropriate architecture Kconfig files. You could even put a help text on it to explain why a new architecture may need to select it.
Signature · 2 lines
Cheers, Stephen Rothwell [email protected]
Quoted 17 lines · Stephen Rothwell
Hi Rusty,
arch/blackfin/Kconfig line 2
Quoted 11 lines · On Mon, 11 Mar 2013 17:05:17 +1030 Rusty Russell <[email protected]> wrote:
arch/blackfin/Kconfig +2
-3@@ -1,6 +1,5 @@ -config SYMBOL_PREFIX - string - default "_" +config SYMBOL_PREFIX_UNDERSCORE + def_bool yPlease, if you are going to do this, just have
Quoted 10 lines
config
SYMBOL_PREFIX_UNDERSCORE
boolin one
Kconfigfile (probablyarch/Kconfig) and then select it from the appropriate architectureKconfigfiles. You could even put a help text on it to explain why a new architecture may need to select it.Signature · 2 lines
Cheers, Stephen Rothwell [email protected]
OK.
v2: Rename CONFIG_SYMBOL_PREFIX_UNDERSCORE to CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX,
which is defined in arch/Kconfig and selected by the 3 archs which need it.
Subject: 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", 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, VMLINUX_SYMBOL_NAME and VMLINUX_SYMBOL_PREFIX_STR.
4) Make everyone use them.
Makefile +1 -1
@@ -1398,7 +1398,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)) # Run depmod only if we have System.map and depmod is executable quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ - $(KERNELRELEASE) "$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))" + $(KERNELRELEASE) "$(patsubst y,_,$(CONFIG_SYMBOL_PREFIX_UNDERSCORE))" # Create temporary dir for module support files # clean it up only when building all modules
arch/Kconfig +6 -0
@@ -391,6 +391,12 @@ config MODULES_USE_ELF_REL Modules only use ELF REL relocations. Modules with ELF RELA relocations will give an error. +config HAVE_UNDERSCORE_SYMBOL_PREFIX + bool + help + Some architectures generate an _ in front of C symbols; things like + module loading and assembly files need to know about this. + # # ABI hall of shame #
arch/blackfin/Kconfig +2 -4
@@ -1,7 +1,3 @@ -config SYMBOL_PREFIX - string - default "_" - config MMU def_bool n
@@ -33,6 +29,7 @@ config BLACKFIN select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_WANT_OPTIONAL_GPIOLIB select HAVE_UID16 + select HAVE_UNDERSCORE_SYMBOL_PREFIX select HAVE_VIRT_TO_BUS select ARCH_WANT_IPC_PARSE_VERSION select HAVE_GENERIC_HARDIRQS
@@ -45,6 +42,7 @@ config BLACKFIN select HAVE_MOD_ARCH_SPECIFIC select MODULES_USE_ELF_RELA + config GENERIC_CSUM def_bool y
arch/h8300/Kconfig +3 -3
@@ -12,10 +12,10 @@ config H8300 select MODULES_USE_ELF_RELA select OLD_SIGSUSPEND3 select OLD_SIGACTION + select HAVE_UNDERSCORE_SYMBOL_PREFIX -config SYMBOL_PREFIX - string - default "_" +config SYMBOL_PREFIX_UNDERSCORE + def_bool y config MMU bool
arch/metag/Kconfig +3 -3
@@ -1,6 +1,5 @@ -config SYMBOL_PREFIX - string - default "_" +config SYMBOL_PREFIX_UNDERSCORE + def_bool y config METAG def_bool y
@@ -27,6 +26,7 @@ config METAG select HAVE_MOD_ARCH_SPECIFIC select HAVE_PERF_EVENTS select HAVE_SYSCALL_TRACEPOINTS + select HAVE_UNDERSCORE_SYMBOL_PREFIX select IRQ_DOMAIN select MODULES_USE_ELF_RELA select OF
drivers/mtd/chips/gen_probe.c +3 -3
@@ -204,14 +204,14 @@ static inline struct mtd_info *cfi_cmdset_unknown(struct map_info *map,struct cfi_private *cfi = map->fldrv_priv;__u16 type = primary?cfi->cfiq->P_ID:cfi->cfiq->A_ID;#ifdef CONFIG_MODULES -char probename[16 +sizeof (MODULE_SYMBOL_PREFIX )]; +char probename[16 +sizeof (VMLINUX_SYMBOL_PREFIX_STR )];cfi_cmdset_fn_t *probe_function; -sprintf (probename,MODULE_SYMBOL_PREFIX "cfi_cmdset_%4.4X" , type); +sprintf (probename,VMLINUX_SYMBOL_PREFIX_STR "cfi_cmdset_%4.4X" , type); probe_function =__symbol_get (probename);if (!probe_function) { -request_module (probename +sizeof (MODULE_SYMBOL_PREFIX ) -1 ); +request_module (probename +sizeof (VMLINUX_SYMBOL_PREFIX_STR )-1 ); probe_function =__symbol_get (probename); }
include/asm-generic/unistd.h +4 -8
@@ -1,4 +1,5 @@#include <uapi/asm-generic/unistd.h> +#include <linux/export.h> /* * These are required system calls, we should
@@ -17,12 +18,7 @@* but it doesn't work on all toolchains, so we just do it by hand */ #ifndef cond_syscall -#ifdef CONFIG_SYMBOL_PREFIX -#define __SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX -#else -#define __SYMBOL_PREFIX -#endif -#define cond_syscall (x) asm(".weak\t" __SYMBOL_PREFIX #x "\n\t" \ - ".set\t" __SYMBOL_PREFIX #x "," \ - __SYMBOL_PREFIX "sys_ni_syscall") +#define cond_syscall (x) asm(".weak\t" SYMBOL_NAME_STR(x) "\n\t" \ + ".set\t" SYMBOL_NAME_STR(x) "," \ + SYMBOL_NAME_STR(sys_ni_syscall))#endif
include/asm-generic/vmlinux.lds.h +1 -7
@@ -52,13 +52,7 @@#define LOAD_OFFSET 0#endif -#ifndef SYMBOL_PREFIX -#define VMLINUX_SYMBOL (sym) sym -#else -#define PASTE2 (x,y) x##y -#define PASTE (x,y) PASTE2(x,y) -#define VMLINUX_SYMBOL (sym) PASTE(SYMBOL_PREFIX, sym) -#endif +#include <linux/export.h> /* Align . to a 8 byte boundary equals to maximum function alignment. */ #define ALIGN_FUNCTION () . = ALIGN(8)
include/linux/export.h +17 -4
@@ -7,15 +7,27 @@* * If you feel the need to add #include <linux/foo.h> to this file * then you are doing something wrong and should go away silently. +* +* If you think the above arrogance just encourages more people to add +* random crap to this file, you're not alone. */ /* Some toolchains use a `_' prefix for all user symbols. */ -#ifdef CONFIG_SYMBOL_PREFIX -#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX +#ifdef CONFIG_SYMBOL_PREFIX_UNDERSCORE +#define __VMLINUX_SYMBOL (x) _##x +#define __VMLINUX_SYMBOL_STR (x) "_" #x +#define VMLINUX_SYMBOL_PREFIX_STR "_"#else -#define MODULE_SYMBOL_PREFIX "" +#define __VMLINUX_SYMBOL (x) x +#define __VMLINUX_SYMBOL_STR (x) #x +#define VMLINUX_SYMBOL_PREFIX_STR ""#endif +/* Indirect, so macros are expanded before pasting. */ +#define VMLINUX_SYMBOL (x) __VMLINUX_SYMBOL(x) +#define VMLINUX_SYMBOL_STR (x) __VMLINUX_SYMBOL_STR(x) + +#ifndef __ASSEMBLY__ struct kernel_symbol { unsigned long value;
@@ -51,7 +63,7 @@ extern struct module __this_module; __CRC_SYMBOL(sym, sec) \ static const char __kstrtab_##sym[] \ __attribute__((section("__ksymtab_strings"), aligned(1))) \ - = MODULE_SYMBOL_PREFIX #sym; \ + = VMLINUX_SYMBOL_STR(sym); \ static const struct kernel_symbol __ksymtab_##sym \ __used \ __attribute__((section("___ksymtab" sec "+" #sym), unused)) \
@@ -85,5 +97,6 @@ extern struct module __this_module;#define EXPORT_UNUSED_SYMBOL_GPL (sym)#endif /* CONFIG_MODULES */ +#endif /* !__ASSEMBLY__ */ #endif /* _LINUX_EXPORT_H */
include/linux/kernel.h +0 -7
@@ -723,13 +723,6 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }/* Trap pasters of __FUNCTION__ at compile-time */ #define __FUNCTION__ (__func__) -/* This helps us to avoid #ifdef CONFIG_SYMBOL_PREFIX */ -#ifdef CONFIG_SYMBOL_PREFIX -#define SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX -#else -#define SYMBOL_PREFIX "" -#endif -/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ #ifdef CONFIG_FTRACE_MCOUNT_RECORD # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
include/linux/module.h +2 -2
@@ -190,7 +190,7 @@ extern int modules_disabled; /* for sysctl *//* Get/put a kernel symbol (calls must be symmetric) */ void *__symbol_get (const char *symbol);void *__symbol_get_gpl (const char *symbol); -#define symbol_get (x) ((typeof(&x))(__symbol_get(MODULE_SYMBOL_PREFIX #x))) +#define symbol_get (x) ((typeof(&x))(__symbol_get(VMLINUX_SYMBOL_STR(x))))/* modules using other modules: kdb wants to see this. */ struct module_use {
@@ -453,7 +453,7 @@ extern void __module_put_and_exit(struct module *mod, long code)#ifdef CONFIG_MODULE_UNLOAD unsigned long module_refcount (struct module *mod);void __symbol_put (const char *symbol); -#define symbol_put (x) __symbol_put(MODULE_SYMBOL_PREFIX #x) +#define symbol_put (x) __symbol_put(VMLINUX_SYMBOL_STR(x))void symbol_put_addr (void *addr);/* Sometimes we know we already have a refcount, and it's easier not
kernel/modsign_certificate.S +3 -10
@@ -1,15 +1,8 @@ -/* SYMBOL_PREFIX defined on commandline from CONFIG_SYMBOL_PREFIX */ -#ifndef SYMBOL_PREFIX -#define ASM_SYMBOL(sym) sym -#else -#define PASTE2(x,y) x##y -#define PASTE(x,y) PASTE2(x,y) -#define ASM_SYMBOL(sym) PASTE(SYMBOL_PREFIX, sym) -#endif +#include <linux/export.h> #define GLOBAL(name) \ - .globl ASM_SYMBOL(name); \ - ASM_SYMBOL(name): + .globl VMLINUX_SYMBOL(name); \ + VMLINUX_SYMBOL(name): .section ".init.data","aw"
kernel/module.c +1 -1
@@ -1209,7 +1209,7 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,/* Since this should be found in kernel (which can't be removed), * no locking is necessary. */ -if (!find_symbol (MODULE_SYMBOL_PREFIX "module_layout" ,NULL , +if (!find_symbol (VMLINUX_SYMBOL_STR (module_layout),NULL , &crc, true, false))BUG (); return check_version(sechdrs, versindex, "module_layout", mod, crc,
scripts/Makefile.lib +0 -7
@@ -119,13 +119,6 @@ _c_flags += $(if $(patsubst n%,, \ $(CFLAGS_GCOV)) endif -ifdef CONFIG_SYMBOL_PREFIX -_sym_flags = -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX)) -_cpp_flags += $(_sym_flags) -_a_flags += $(_sym_flags) -endif - - # If building the kernel in a separate objtree expand all occurrences # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
scripts/link-vmlinux.sh +2 -3
@@ -74,9 +74,8 @@ kallsyms() info KSYM ${2} local kallsymopt; - if [ -n "${CONFIG_SYMBOL_PREFIX}" ]; then - kallsymopt="${kallsymopt} \ - --symbol-prefix=${CONFIG_SYMBOL_PREFIX}" + if [ -n "${CONFIG_SYMBOL_PREFIX_UNDERSCORE}" ]; then + kallsymopt="${kallsymopt} --symbol-prefix=_" fi if [ -n "${CONFIG_KALLSYMS_ALL}" ]; then
scripts/mod/modpost.c +9 -16
@@ -18,14 +18,7 @@#include "modpost.h" #include "../../include/generated/autoconf.h" #include "../../include/linux/license.h" - -/* Some toolchains use a `_' prefix for all user symbols. */ -#ifdef CONFIG_SYMBOL_PREFIX -#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX -#else -#define MODULE_SYMBOL_PREFIX "" -#endif - +#include "../../include/linux/export.h" /* Are we using CONFIG_MODVERSIONS? */ int modversions =0 ;
@@ -562,7 +555,7 @@ static void parse_elf_finish(struct elf_info *info)static int ignore_undef_symbol (struct elf_info *info,const char *symname) {/* ignore __this_module, it will be resolved shortly */ -if (strcmp (symname,MODULE_SYMBOL_PREFIX "__this_module" ) ==0 ) +if (strcmp (symname,VMLINUX_SYMBOL_STR (__this_module)) ==0 )return 1 ;/* ignore global offset table */ if (strcmp (symname,"_GLOBAL_OFFSET_TABLE_" ) ==0 )
@@ -583,8 +576,8 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)return 0 ; } -#define CRC_PFX MODULE_SYMBOL_PREFIX "__crc_" -#define KSYMTAB_PFX MODULE_SYMBOL_PREFIX "__ksymtab_" +#define CRC_PFX VMLINUX_SYMBOL_STR(__crc_) +#define KSYMTAB_PFX VMLINUX_SYMBOL_STR(__ksymtab_)static void handle_modversions (struct module *mod,struct elf_info *info,Elf_Sym *sym,const char *symname)
@@ -637,11 +630,11 @@ static void handle_modversions(struct module *mod, struct elf_info *info, }#endif -if (memcmp (symname,MODULE_SYMBOL_PREFIX , -strlen (MODULE_SYMBOL_PREFIX )) ==0 ) { +if (memcmp (symname,VMLINUX_SYMBOL_PREFIX_STR , +strlen (VMLINUX_SYMBOL_PREFIX_STR )) ==0 ) { mod->unres =alloc_symbol (symname + -strlen (MODULE_SYMBOL_PREFIX ), +strlen (VMLINUX_SYMBOL_PREFIX_STR ),ELF_ST_BIND (sym->st_info) ==STB_WEAK , mod->unres); }
@@ -652,9 +645,9 @@ static void handle_modversions(struct module *mod, struct elf_info *info,sym_add_exported (symname +strlen (KSYMTAB_PFX ), mod, export); } -if (strcmp (symname,MODULE_SYMBOL_PREFIX "init_module" ) ==0 ) +if (strcmp (symname,VMLINUX_SYMBOL_STR (init_module)) ==0 ) mod->has_init =1 ; -if (strcmp (symname,MODULE_SYMBOL_PREFIX "cleanup_module" ) ==0 ) +if (strcmp (symname,VMLINUX_SYMBOL_STR (cleanup_module)) ==0 ) mod->has_cleanup =1 ;break ; }
Hi Rusty,
Looks partly better. You seem to be usingCONFIG_SYMBOL_PREFIX_UNDERSCORE but selecting CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX. One trivial comment below.
Maybe this was an unfinished version of the patch?
arch/blackfin/Kconfig config BLACKFIN · line 47
Quoted 12 lines · On Tue, 12 Mar 2013 15:18:15 +1030 Rusty Russell <[email protected]> wrote:
arch/blackfin/Kconfig +1
-0@@ -45,6 +42,7 @@ config BLACKFIN select HAVE_MOD_ARCH_SPECIFIC select MODULES_USE_ELF_RELA + config GENERIC_CSUM def_bool y
Extra blank line added.
Signature · 2 lines
Cheers, Stephen Rothwell [email protected]
Hi Rusty,
Quoted 2 lines · Rusty Russell
v2: Rename
CONFIG_SYMBOL_PREFIX_UNDERSCOREtoCONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX,
which is defined inarch/Kconfigand selected by the 3 archs which need it.
Sorry I didn't get a chance to try your patch yesterday.
Quoted 20 lines
Subject:
CONFIG_SYMBOL_PREFIX: cleanup.We have
CONFIG_SYMBOL_PREFIX, which three archs define to the string "_". But Al Viro broke this in "consolidatecond_syscallandSYSCALL_ALIASdeclarations", and he's not the first to do so.Using
CONFIG_SYMBOL_PREFIXis awkward, since we usually just want to prefix it so something. So various places define helpers which are defined to nothing ifCONFIG_SYMBOL_PREFIXisn't set:1)
include/asm-generic/unistd.hdefines__SYMBOL_PREFIX.
2)include/asm-generic/vmlinux.lds.hdefinesVMLINUX_SYMBOL(sym)
3)include/linux/export.hdefinesMODULE_SYMBOL_PREFIX.
4)include/linux/kernel.hdefinesSYMBOL_PREFIX(which differs from #7)
5)kernel/modsign_certificate.SdefinesASM_SYMBOL(sym)
6)scripts/modpost.cdefinesMODULE_SYMBOL_PREFIX
7)scripts/Makefile.libdefinesSYMBOL_PREFIXon the commandline ifCONFIG_SYMBOL_PREFIXis set, so that we have a non-string version for pasting.
Quoted 6 lines
(
arch/h8300/include/asm/linkage.hdefinesSYMBOL_NAME(), too).Let's solve this properly:
1) No more generic prefix, justCONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX.
2) Makelinux/export.husable from asm.
3) DefineVMLINUX_SYMBOL,VMLINUX_SYMBOL_NAMEandVMLINUX_SYMBOL_PREFIX_STR.
You don't seem to define VMLINUX_SYMBOL_NAME
Quoted 3 lines
4) Make everyone use them.
Signed-off-by Rusty Russell <[email protected]>
After a few modifications detailed below (with a fixup patch at the end for convenience) it seems to work no worse than before for metag (module symbol versioning was apparently already broken, I need to look into that).
Cheers
James
Makefile quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)) · line 1401
Quoted 11 lines
Makefile +1
-1@@ -1398,7 +1398,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)) # Run depmod only if we have System.map and depmod is executable quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ - $(KERNELRELEASE) "$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))" + $(KERNELRELEASE) "$(patsubst y,_,$(CONFIG_SYMBOL_PREFIX_UNDERSCORE))"
should this be CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX now?
Quoted 5 lines
arch/h8300/Kconfig +0
-0
arch/h8300/Kconfig config H8300 · line 18
Quoted 10 lines
arch/h8300/Kconfig +3
-3@@ -12,10 +12,10 @@ config H8300 select MODULES_USE_ELF_RELA select OLD_SIGSUSPEND3 select OLD_SIGACTION + select HAVE_UNDERSCORE_SYMBOL_PREFIX -config SYMBOL_PREFIX - string - default "_" +config SYMBOL_PREFIX_UNDERSCORE + def_bool y
Not needed anymore I think
arch/metag/Kconfig line 2
Quoted 10 lines
arch/metag/Kconfig +2
-3@@ -1,6 +1,5 @@ -config SYMBOL_PREFIX - string - default "_" +config SYMBOL_PREFIX_UNDERSCORE + def_bool y
Same again.
Quoted 15 lines
include/asm-generic/unistd.h +1
-1@@ -1,4 +1,5 @@#include <uapi/asm-generic/unistd.h> +#include <linux/export.h> /* * These are required system calls, we should @@ -17,12 +18,7 @@* but it doesn't work on all toolchains, so we just do it by hand */ #ifndef cond_syscall -#ifdef CONFIG_SYMBOL_PREFIX
include/asm-generic/unistd.h line 23
Quoted 10 lines
include/asm-generic/unistd.h +3
-7-#define __SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX -#else -#define __SYMBOL_PREFIX -#endif -#define cond_syscall (x) asm(".weak\t" __SYMBOL_PREFIX #x "\n\t" \ - ".set\t" __SYMBOL_PREFIX #x "," \ - __SYMBOL_PREFIX "sys_ni_syscall") +#define cond_syscall (x) asm(".weak\t" SYMBOL_NAME_STR(x) "\n\t" \ + ".set\t" SYMBOL_NAME_STR(x) "," \ + SYMBOL_NAME_STR(sys_ni_syscall))
s/SYMBOL_NAME_STR/VMLINUX_SYMBOL_STR/
include/linux/export.h line 12
Quoted 11 lines
include/linux/export.h +3
-0@@ -7,15 +7,27 @@* * If you feel the need to add #include <linux/foo.h> to this file * then you are doing something wrong and should go away silently. +* +* If you think the above arrogance just encourages more people to add +* random crap to this file, you're not alone.
:-)
include/linux/export.h line 16
Quoted 6 lines
include/linux/export.h +1
-2*/ /* Some toolchains use a `_' prefix for all user symbols. */ -#ifdef CONFIG_SYMBOL_PREFIX -#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX +#ifdef CONFIG_SYMBOL_PREFIX_UNDERSCORE
CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX
scripts/link-vmlinux.sh kallsyms() · line 77
Quoted 12 lines
scripts/link-vmlinux.sh +1
-3@@ -74,9 +74,8 @@ kallsyms() info KSYM ${2} local kallsymopt; - if [ -n "${CONFIG_SYMBOL_PREFIX}" ]; then - kallsymopt="${kallsymopt} \ - --symbol-prefix=${CONFIG_SYMBOL_PREFIX}" + if [ -n "${CONFIG_SYMBOL_PREFIX_UNDERSCORE}" ]; then
CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX
Makefile +1 -1
@@ -1398,7 +1398,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)) # Run depmod only if we have System.map and depmod is executable quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ - $(KERNELRELEASE) "$(patsubst y,_,$(CONFIG_SYMBOL_PREFIX_UNDERSCORE))" + $(KERNELRELEASE) "$(patsubst y,_,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX))" # Create temporary dir for module support files # clean it up only when building all modules
arch/h8300/Kconfig +0 -3
@@ -14,9 +14,6 @@ config H8300 select OLD_SIGACTION select HAVE_UNDERSCORE_SYMBOL_PREFIX -config SYMBOL_PREFIX_UNDERSCORE - def_bool y - config MMU bool default n
arch/metag/Kconfig +0 -3
@@ -1,6 +1,3 @@ -config SYMBOL_PREFIX_UNDERSCORE - def_bool y - config METAG def_bool y select EMBEDDED
include/asm-generic/unistd.h +3 -3
@@ -18,7 +18,7 @@* but it doesn't work on all toolchains, so we just do it by hand */ #ifndef cond_syscall -#define cond_syscall (x) asm(".weak\t" SYMBOL_NAME_STR(x) "\n\t" \ - ".set\t" SYMBOL_NAME_STR(x) "," \ - SYMBOL_NAME_STR(sys_ni_syscall)) +#define cond_syscall (x) asm(".weak\t" VMLINUX_SYMBOL_STR(x) "\n\t" \ + ".set\t" VMLINUX_SYMBOL_STR(x) "," \ + VMLINUX_SYMBOL_STR(sys_ni_syscall))#endif
include/linux/export.h +1 -1
@@ -13,7 +13,7 @@*/ /* Some toolchains use a `_' prefix for all user symbols. */ -#ifdef CONFIG_SYMBOL_PREFIX_UNDERSCORE +#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX #define __VMLINUX_SYMBOL (x) _##x#define __VMLINUX_SYMBOL_STR (x) "_" #x#define VMLINUX_SYMBOL_PREFIX_STR "_"
scripts/link-vmlinux.sh +1 -1
@@ -74,7 +74,7 @@ kallsyms() info KSYM ${2} local kallsymopt; - if [ -n "${CONFIG_SYMBOL_PREFIX_UNDERSCORE}" ]; then + if [ -n "${CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX}" ]; then kallsymopt="${kallsymopt} --symbol-prefix=_" fi
Quoted 7 lines · Stephen Rothwell
Hi Rusty,
Looks partly better. You seem to be using
CONFIG_SYMBOL_PREFIX_UNDERSCOREbut selectingCONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX. One trivial comment below.Maybe this was an unfinished version of the patch?
Indeed. It was crap.... now I've applied James' copious fixes, and actually, y'know, proof-read it.
This is what I'll push into my fixes/ branch now, and if it survives a day in linux-next, will push to Linus.
Thanks,
Rusty.
v2: Rename CONFIG_SYMBOL_PREFIX_UNDERSCORE to
CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX, which is defined in arch/Kconfig and selected by the 3 archs which need it.
v3: Clean up remnants of v1, s/VMLINUX_SYMBOL_NAME/VMLINUX_SYMBOL_STR/
in description, note that Al's commit is in linux-next only, remove whitespace-only hunk.
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, VMLINUX_SYMBOL_STR and VMLINUX_SYMBOL_PREFIX_STR.
4) Make everyone use them.
Makefile +1 -1
@@ -1398,7 +1398,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)) # Run depmod only if we have System.map and depmod is executable quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ - $(KERNELRELEASE) "$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))" + $(KERNELRELEASE) "$(patsubst y,_,$(CONFIG_HAVE_SYMBOL_PREFIX_UNDERSCORE))" # Create temporary dir for module support files # clean it up only when building all modules
arch/Kconfig +6 -0
@@ -391,6 +391,12 @@ config MODULES_USE_ELF_REL Modules only use ELF REL relocations. Modules with ELF RELA relocations will give an error. +config HAVE_UNDERSCORE_SYMBOL_PREFIX + bool + help + Some architectures generate an _ in front of C symbols; things like + module loading and assembly files need to know about this. + # # ABI hall of shame #
arch/blackfin/Kconfig +1 -4
@@ -1,7 +1,3 @@ -config SYMBOL_PREFIX - string - default "_" - config MMU def_bool n
@@ -33,6 +29,7 @@ config BLACKFIN select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_WANT_OPTIONAL_GPIOLIB select HAVE_UID16 + select HAVE_UNDERSCORE_SYMBOL_PREFIX select HAVE_VIRT_TO_BUS select ARCH_WANT_IPC_PARSE_VERSION select HAVE_GENERIC_HARDIRQS
arch/h8300/Kconfig +1 -4
@@ -12,10 +12,7 @@ config H8300 select MODULES_USE_ELF_RELA select OLD_SIGSUSPEND3 select OLD_SIGACTION - -config SYMBOL_PREFIX - string - default "_" + select HAVE_UNDERSCORE_SYMBOL_PREFIX config MMU bool
arch/metag/Kconfig +1 -4
@@ -1,7 +1,3 @@ -config SYMBOL_PREFIX - string - default "_" - config METAG def_bool y select EMBEDDED
@@ -27,6 +23,7 @@ config METAG select HAVE_MOD_ARCH_SPECIFIC select HAVE_PERF_EVENTS select HAVE_SYSCALL_TRACEPOINTS + select HAVE_UNDERSCORE_SYMBOL_PREFIX select IRQ_DOMAIN select MODULES_USE_ELF_RELA select OF
drivers/mtd/chips/gen_probe.c +3 -3
@@ -204,14 +204,14 @@ static inline struct mtd_info *cfi_cmdset_unknown(struct map_info *map,struct cfi_private *cfi = map->fldrv_priv;__u16 type = primary?cfi->cfiq->P_ID:cfi->cfiq->A_ID;#ifdef CONFIG_MODULES -char probename[16 +sizeof (MODULE_SYMBOL_PREFIX )]; +char probename[16 +sizeof (VMLINUX_SYMBOL_PREFIX_STR )];cfi_cmdset_fn_t *probe_function; -sprintf (probename,MODULE_SYMBOL_PREFIX "cfi_cmdset_%4.4X" , type); +sprintf (probename,VMLINUX_SYMBOL_PREFIX_STR "cfi_cmdset_%4.4X" , type); probe_function =__symbol_get (probename);if (!probe_function) { -request_module (probename +sizeof (MODULE_SYMBOL_PREFIX ) -1 ); +request_module (probename +sizeof (VMLINUX_SYMBOL_PREFIX_STR )-1 ); probe_function =__symbol_get (probename); }
include/asm-generic/unistd.h +4 -8
@@ -1,4 +1,5 @@#include <uapi/asm-generic/unistd.h> +#include <linux/export.h> /* * These are required system calls, we should
@@ -17,12 +18,7 @@* but it doesn't work on all toolchains, so we just do it by hand */ #ifndef cond_syscall -#ifdef CONFIG_SYMBOL_PREFIX -#define __SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX -#else -#define __SYMBOL_PREFIX -#endif -#define cond_syscall (x) asm(".weak\t" __SYMBOL_PREFIX #x "\n\t" \ - ".set\t" __SYMBOL_PREFIX #x "," \ - __SYMBOL_PREFIX "sys_ni_syscall") +#define cond_syscall (x) asm(".weak\t" VMLINUX_SYMBOL_STR(x) "\n\t" \ + ".set\t" VMLINUX_SYMBOL_STR(x) "," \ + VMLINUX_SYMBOL_STR(sys_ni_syscall))#endif
include/asm-generic/vmlinux.lds.h +1 -7
@@ -52,13 +52,7 @@#define LOAD_OFFSET 0#endif -#ifndef SYMBOL_PREFIX -#define VMLINUX_SYMBOL (sym) sym -#else -#define PASTE2 (x,y) x##y -#define PASTE (x,y) PASTE2(x,y) -#define VMLINUX_SYMBOL (sym) PASTE(SYMBOL_PREFIX, sym) -#endif +#include <linux/export.h> /* Align . to a 8 byte boundary equals to maximum function alignment. */ #define ALIGN_FUNCTION () . = ALIGN(8)
include/linux/export.h +17 -4
@@ -7,15 +7,27 @@* * If you feel the need to add #include <linux/foo.h> to this file * then you are doing something wrong and should go away silently. +* +* If you think the above arrogance just encourages more people to add +* random crap to this file, you're not alone. */ /* Some toolchains use a `_' prefix for all user symbols. */ -#ifdef CONFIG_SYMBOL_PREFIX -#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX +#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX +#define __VMLINUX_SYMBOL (x) _##x +#define __VMLINUX_SYMBOL_STR (x) "_" #x +#define VMLINUX_SYMBOL_PREFIX_STR "_"#else -#define MODULE_SYMBOL_PREFIX "" +#define __VMLINUX_SYMBOL (x) x +#define __VMLINUX_SYMBOL_STR (x) #x +#define VMLINUX_SYMBOL_PREFIX_STR ""#endif +/* Indirect, so macros are expanded before pasting. */ +#define VMLINUX_SYMBOL (x) __VMLINUX_SYMBOL(x) +#define VMLINUX_SYMBOL_STR (x) __VMLINUX_SYMBOL_STR(x) + +#ifndef __ASSEMBLY__ struct kernel_symbol { unsigned long value;
@@ -51,7 +63,7 @@ extern struct module __this_module; __CRC_SYMBOL(sym, sec) \ static const char __kstrtab_##sym[] \ __attribute__((section("__ksymtab_strings"), aligned(1))) \ - = MODULE_SYMBOL_PREFIX #sym; \ + = VMLINUX_SYMBOL_STR(sym); \ static const struct kernel_symbol __ksymtab_##sym \ __used \ __attribute__((section("___ksymtab" sec "+" #sym), unused)) \
@@ -85,5 +97,6 @@ extern struct module __this_module;#define EXPORT_UNUSED_SYMBOL_GPL (sym)#endif /* CONFIG_MODULES */ +#endif /* !__ASSEMBLY__ */ #endif /* _LINUX_EXPORT_H */
include/linux/kernel.h +0 -7
@@ -723,13 +723,6 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }/* Trap pasters of __FUNCTION__ at compile-time */ #define __FUNCTION__ (__func__) -/* This helps us to avoid #ifdef CONFIG_SYMBOL_PREFIX */ -#ifdef CONFIG_SYMBOL_PREFIX -#define SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX -#else -#define SYMBOL_PREFIX "" -#endif -/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ #ifdef CONFIG_FTRACE_MCOUNT_RECORD # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
include/linux/module.h +2 -2
@@ -190,7 +190,7 @@ extern int modules_disabled; /* for sysctl *//* Get/put a kernel symbol (calls must be symmetric) */ void *__symbol_get (const char *symbol);void *__symbol_get_gpl (const char *symbol); -#define symbol_get (x) ((typeof(&x))(__symbol_get(MODULE_SYMBOL_PREFIX #x))) +#define symbol_get (x) ((typeof(&x))(__symbol_get(VMLINUX_SYMBOL_STR(x))))/* modules using other modules: kdb wants to see this. */ struct module_use {
@@ -453,7 +453,7 @@ extern void __module_put_and_exit(struct module *mod, long code)#ifdef CONFIG_MODULE_UNLOAD unsigned long module_refcount (struct module *mod);void __symbol_put (const char *symbol); -#define symbol_put (x) __symbol_put(MODULE_SYMBOL_PREFIX #x) +#define symbol_put (x) __symbol_put(VMLINUX_SYMBOL_STR(x))void symbol_put_addr (void *addr);/* Sometimes we know we already have a refcount, and it's easier not
kernel/modsign_certificate.S +3 -10
@@ -1,15 +1,8 @@ -/* SYMBOL_PREFIX defined on commandline from CONFIG_SYMBOL_PREFIX */ -#ifndef SYMBOL_PREFIX -#define ASM_SYMBOL(sym) sym -#else -#define PASTE2(x,y) x##y -#define PASTE(x,y) PASTE2(x,y) -#define ASM_SYMBOL(sym) PASTE(SYMBOL_PREFIX, sym) -#endif +#include <linux/export.h> #define GLOBAL(name) \ - .globl ASM_SYMBOL(name); \ - ASM_SYMBOL(name): + .globl VMLINUX_SYMBOL(name); \ + VMLINUX_SYMBOL(name): .section ".init.data","aw"
kernel/module.c +1 -1
@@ -1209,7 +1209,7 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,/* Since this should be found in kernel (which can't be removed), * no locking is necessary. */ -if (!find_symbol (MODULE_SYMBOL_PREFIX "module_layout" ,NULL , +if (!find_symbol (VMLINUX_SYMBOL_STR (module_layout),NULL , &crc, true, false))BUG (); return check_version(sechdrs, versindex, "module_layout", mod, crc,
scripts/Makefile.lib +0 -7
@@ -119,13 +119,6 @@ _c_flags += $(if $(patsubst n%,, \ $(CFLAGS_GCOV)) endif -ifdef CONFIG_SYMBOL_PREFIX -_sym_flags = -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX)) -_cpp_flags += $(_sym_flags) -_a_flags += $(_sym_flags) -endif - - # If building the kernel in a separate objtree expand all occurrences # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
scripts/link-vmlinux.sh +2 -3
@@ -74,9 +74,8 @@ kallsyms() info KSYM ${2} local kallsymopt; - if [ -n "${CONFIG_SYMBOL_PREFIX}" ]; then - kallsymopt="${kallsymopt} \ - --symbol-prefix=${CONFIG_SYMBOL_PREFIX}" + if [ -n "${CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX}" ]; then + kallsymopt="${kallsymopt} --symbol-prefix=_" fi if [ -n "${CONFIG_KALLSYMS_ALL}" ]; then
scripts/mod/modpost.c +9 -16
@@ -18,14 +18,7 @@#include "modpost.h" #include "../../include/generated/autoconf.h" #include "../../include/linux/license.h" - -/* Some toolchains use a `_' prefix for all user symbols. */ -#ifdef CONFIG_SYMBOL_PREFIX -#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX -#else -#define MODULE_SYMBOL_PREFIX "" -#endif - +#include "../../include/linux/export.h" /* Are we using CONFIG_MODVERSIONS? */ int modversions =0 ;
@@ -562,7 +555,7 @@ static void parse_elf_finish(struct elf_info *info)static int ignore_undef_symbol (struct elf_info *info,const char *symname) {/* ignore __this_module, it will be resolved shortly */ -if (strcmp (symname,MODULE_SYMBOL_PREFIX "__this_module" ) ==0 ) +if (strcmp (symname,VMLINUX_SYMBOL_STR (__this_module)) ==0 )return 1 ;/* ignore global offset table */ if (strcmp (symname,"_GLOBAL_OFFSET_TABLE_" ) ==0 )
@@ -583,8 +576,8 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)return 0 ; } -#define CRC_PFX MODULE_SYMBOL_PREFIX "__crc_" -#define KSYMTAB_PFX MODULE_SYMBOL_PREFIX "__ksymtab_" +#define CRC_PFX VMLINUX_SYMBOL_STR(__crc_) +#define KSYMTAB_PFX VMLINUX_SYMBOL_STR(__ksymtab_)static void handle_modversions (struct module *mod,struct elf_info *info,Elf_Sym *sym,const char *symname)
@@ -637,11 +630,11 @@ static void handle_modversions(struct module *mod, struct elf_info *info, }#endif -if (memcmp (symname,MODULE_SYMBOL_PREFIX , -strlen (MODULE_SYMBOL_PREFIX )) ==0 ) { +if (memcmp (symname,VMLINUX_SYMBOL_PREFIX_STR , +strlen (VMLINUX_SYMBOL_PREFIX_STR )) ==0 ) { mod->unres =alloc_symbol (symname + -strlen (MODULE_SYMBOL_PREFIX ), +strlen (VMLINUX_SYMBOL_PREFIX_STR ),ELF_ST_BIND (sym->st_info) ==STB_WEAK , mod->unres); }
@@ -652,9 +645,9 @@ static void handle_modversions(struct module *mod, struct elf_info *info,sym_add_exported (symname +strlen (KSYMTAB_PFX ), mod, export); } -if (strcmp (symname,MODULE_SYMBOL_PREFIX "init_module" ) ==0 ) +if (strcmp (symname,VMLINUX_SYMBOL_STR (init_module)) ==0 ) mod->has_init =1 ; -if (strcmp (symname,MODULE_SYMBOL_PREFIX "cleanup_module" ) ==0 ) +if (strcmp (symname,VMLINUX_SYMBOL_STR (cleanup_module)) ==0 ) mod->has_cleanup =1 ;break ; }
Quoted 1 line
actually, y'know, proof-read it.
Hmm..
Makefile quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))
Quoted 3 lines
Makefile +2
-0+ $(KERNELRELEASE) "$(patsubst y,_,$(CONFIG_HAVE_SYMBOL_PREFIX_UNDERSCORE))" +config HAVE_UNDERSCORE_SYMBOL_PREFIX
HAVE_UNDERSCORE_... or HAVE_SYMBOL_... confusion.
I prefer the HAVE_SYMBOL_... variant but no strong feelings..
Quoted 3 lines
+ *
+ * If you think the above arrogance just encourages more people to add
+ * random crap to this file, you're not alone.
Kill this.
include/linux/export.h line 24
Quoted 13 lines
/* Some toolchains use a `_' prefix for all user symbols. */
include/linux/export.h +7
-3-#ifdef CONFIG_SYMBOL_PREFIX -#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX +#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX +#define __VMLINUX_SYMBOL (x) _##x +#define __VMLINUX_SYMBOL_STR (x) "_" #x +#define VMLINUX_SYMBOL_PREFIX_STR "_"#else -#define MODULE_SYMBOL_PREFIX "" +#define __VMLINUX_SYMBOL (x) x +#define __VMLINUX_SYMBOL_STR (x) #x +#define VMLINUX_SYMBOL_PREFIX_STR ""#endif
We know the prefix is an underscore. No benefits from defining VMLINUX_SYMBOL_PREFIX_STR. The config name even syas so. Skipping the above give us only one way to check
for the prefix - today we mix the two.
Sam
Hi Sam,
Quoted 8 lines · Sam Ravnborg
Quoted 8 lines
/* Some toolchains use a `_' prefix for all user symbols. */
include/linux/export.h +4
-2-#ifdef CONFIG_SYMBOL_PREFIX -#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX +#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX +#define __VMLINUX_SYMBOL (x) _##x +#define __VMLINUX_SYMBOL_STR (x) "_" #x +#define VMLINUX_SYMBOL_PREFIX_STR "_"#else
Quoted 8 lines
include/linux/export.h line 24
Quoted 5 lines
include/linux/export.h +3
-1-#define MODULE_SYMBOL_PREFIX "" +#define __VMLINUX_SYMBOL (x) x +#define __VMLINUX_SYMBOL_STR (x) #x +#define VMLINUX_SYMBOL_PREFIX_STR ""#endif We know the prefix is an underscore. No benefits from defining
VMLINUX_SYMBOL_PREFIX_STR.
scripts/modpost.c uses the actual prefix string though:
Quoted 7 lines
if (memcmp(symname, MODULE_SYMBOL_PREFIX,
strlen(MODULE_SYMBOL_PREFIX)) == 0) {
mod->unres =
alloc_symbol(symname +
strlen(MODULE_SYMBOL_PREFIX),
ELF_ST_BIND(sym->st_info) == STB_WEAK,
mod->unres);See also my "module: fix symbol versioning with symbol prefixes" patch for an additional use in modpost.
Having a MODULE_SYMBOL_PREFIX/VMLINUX_SYMBOL_PREFIX_STR seems like the simplest way to keep this code clean and readable without special cases.
Cheers
James
Quoted 20 lines · James Hogan
Hi Sam,
Quoted 8 lines · Sam Ravnborg
Quoted 8 lines
/* Some toolchains use a `_' prefix for all user symbols. */
include/linux/export.h +4
-2-#ifdef CONFIG_SYMBOL_PREFIX -#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX +#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX +#define __VMLINUX_SYMBOL (x) _##x +#define __VMLINUX_SYMBOL_STR (x) "_" #x +#define VMLINUX_SYMBOL_PREFIX_STR "_"#else Quoted 8 lines
include/linux/export.h line 24
Quoted 5 lines
include/linux/export.h +3
-1-#define MODULE_SYMBOL_PREFIX "" +#define __VMLINUX_SYMBOL (x) x +#define __VMLINUX_SYMBOL_STR (x) #x +#define VMLINUX_SYMBOL_PREFIX_STR ""#endif We know the prefix is an underscore. No benefits from defining
VMLINUX_SYMBOL_PREFIX_STR.
Quoted 10 lines
scripts/modpost.cuses the actual prefix string though:Quoted 7 lines
if (memcmp(symname, MODULE_SYMBOL_PREFIX, strlen(MODULE_SYMBOL_PREFIX)) == 0) { mod->unres = alloc_symbol(symname + strlen(MODULE_SYMBOL_PREFIX), ELF_ST_BIND(sym->st_info) == STB_WEAK, mod->unres);
Allowing ourself to know this is "_" then we could make the above code look something like:
if (have_symbol_prefix_underscore) {
if (symname[0] == '_') {
mod->unres =
...But I do not feel strong about this part.
It is much more important to clean up so we use the same definition all over the kernel.
Sam
Quoted 9 lines · Sam Ravnborg
Quoted 1 line
actually, y'know, proof-read it.
Hmm..
Review
Quoted 3 lines
(quoted diff) +2
-0+ $(KERNELRELEASE) "$(patsubst y,_,$(CONFIG_HAVE_SYMBOL_PREFIX_UNDERSCORE))" +config HAVE_UNDERSCORE_SYMBOL_PREFIX
HAVE_UNDERSCORE_... orHAVE_SYMBOL_... confusion.
I prefer theHAVE_SYMBOL_... variant but no strong feelings..
Thanks, fixed. (HAVE_UNDERSCORE_ won by grep majority vote, but I don't really care either).
Quoted 4 lines
Quoted 3 lines
+ *
+ * If you think the above arrogance just encourages more people to add
+ * random crap to this file, you're not alone.Kill this.
?? It went in without my Ack, and it's a particularly offensive turd.
I can replace it with a civilized comment, instead of being snarky though...
Quoted 10 lines
Quoted 10 lines
/* Some toolchains use a `_' prefix for all user symbols. */
(quoted diff) +5
-3-#ifdef CONFIG_SYMBOL_PREFIX -#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX +#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX +#define __VMLINUX_SYMBOL(x) _##x +#define __VMLINUX_SYMBOL_STR(x) "_" #x +#define VMLINUX_SYMBOL_PREFIX_STR "_" #else -#define MODULE_SYMBOL_PREFIX "" +#define __VMLINUX_SYMBOL(x) x
Quoted 8 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+#define __VMLINUX_SYMBOL_STR(x) #x +#define VMLINUX_SYMBOL_PREFIX_STR "" #endifWe know the prefix is an underscore. No benefits from defining
VMLINUX_SYMBOL_PREFIX_STR. The config name even syas so. Skipping the above give us only one way to check
for the prefix - today we mix the two.
After testing, I think you're right. The two users are both slightly clearer after this (though mtd is a tiny bit less optimal).
Note: James, your patch hunk now looks like this:
- buf_printf(b, "\t{ %#8x, \"%s\" },\n", s->crc, s->name);
+ buf_printf(b, "\t{ %#8x, VMLINUX_SYMBOL_STR(%s) },\n",
+ s->crc, s->name);
Here's version 3:
From: Rusty Russell <[email protected]>
Subject: 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.
Makefile +1 -1
@@ -1398,7 +1398,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)) # Run depmod only if we have System.map and depmod is executable quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ - $(KERNELRELEASE) "$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))" + $(KERNELRELEASE) "$(patsubst y,_,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX))" # Create temporary dir for module support files # clean it up only when building all modules
arch/Kconfig +6 -0
@@ -384,6 +384,12 @@ config MODULES_USE_ELF_REL Modules only use ELF REL relocations. Modules with ELF RELA relocations will give an error. +config HAVE_UNDERSCORE_SYMBOL_PREFIX + bool + help + Some architectures generate an _ in front of C symbols; things like + module loading and assembly files need to know about this. + # # ABI hall of shame #
arch/blackfin/Kconfig +1 -4
@@ -1,7 +1,3 @@ -config SYMBOL_PREFIX - string - default "_" - config MMU def_bool n
@@ -33,6 +29,7 @@ config BLACKFIN select ARCH_HAVE_CUSTOM_GPIO_H select ARCH_WANT_OPTIONAL_GPIOLIB select HAVE_UID16 + select HAVE_UNDERSCORE_SYMBOL_PREFIX select VIRT_TO_BUS select ARCH_WANT_IPC_PARSE_VERSION select HAVE_GENERIC_HARDIRQS
arch/h8300/Kconfig +1 -4
@@ -12,10 +12,7 @@ config H8300 select MODULES_USE_ELF_RELA select OLD_SIGSUSPEND3 select OLD_SIGACTION - -config SYMBOL_PREFIX - string - default "_" + select HAVE_UNDERSCORE_SYMBOL_PREFIX config MMU bool
arch/metag/Kconfig +1 -4
@@ -1,7 +1,3 @@ -config SYMBOL_PREFIX - string - default "_" - config METAG def_bool y select EMBEDDED
@@ -27,6 +23,7 @@ config METAG select HAVE_MOD_ARCH_SPECIFIC select HAVE_PERF_EVENTS select HAVE_SYSCALL_TRACEPOINTS + select HAVE_UNDERSCORE_SYMBOL_PREFIX select IRQ_DOMAIN select MODULES_USE_ELF_RELA select OF
drivers/mtd/chips/gen_probe.c +5 -3
@@ -204,14 +204,16 @@ static inline struct mtd_info *cfi_cmdset_unknown(struct map_info *map,struct cfi_private *cfi = map->fldrv_priv;__u16 type = primary?cfi->cfiq->P_ID:cfi->cfiq->A_ID;#ifdef CONFIG_MODULES -char probename[16 +sizeof (MODULE_SYMBOL_PREFIX )]; + char probename[sizeof(VMLINUX_SYMBOL_STR(cfi_cmdset_%4.4X))];cfi_cmdset_fn_t *probe_function; -sprintf (probename,MODULE_SYMBOL_PREFIX "cfi_cmdset_%4.4X" , type); + sprintf(probename, VMLINUX_SYMBOL_STR(cfi_cmdset_%4.4X), type); probe_function =__symbol_get (probename);if (!probe_function) { -request_module (probename +sizeof (MODULE_SYMBOL_PREFIX ) -1 ); +char modname[sizeof ("cfi_cmdset_%4.4X" )]; +sprintf (modname,"cfi_cmdset_%4.4X" , type); +request_module (modname); probe_function =__symbol_get (probename); }
include/asm-generic/unistd.h +4 -8
@@ -1,4 +1,5 @@#include <uapi/asm-generic/unistd.h> +#include <linux/export.h> /* * These are required system calls, we should
@@ -17,12 +18,7 @@* but it doesn't work on all toolchains, so we just do it by hand */ #ifndef cond_syscall -#ifdef CONFIG_SYMBOL_PREFIX -#define __SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX -#else -#define __SYMBOL_PREFIX -#endif -#define cond_syscall (x) asm(".weak\t" __SYMBOL_PREFIX #x "\n\t" \ - ".set\t" __SYMBOL_PREFIX #x "," \ - __SYMBOL_PREFIX "sys_ni_syscall") +#define cond_syscall (x) asm(".weak\t" VMLINUX_SYMBOL_STR(x) "\n\t" \ + ".set\t" VMLINUX_SYMBOL_STR(x) "," \ + VMLINUX_SYMBOL_STR(sys_ni_syscall))#endif
include/asm-generic/vmlinux.lds.h +1 -7
@@ -52,13 +52,7 @@#define LOAD_OFFSET 0#endif -#ifndef SYMBOL_PREFIX -#define VMLINUX_SYMBOL (sym) sym -#else -#define PASTE2 (x,y) x##y -#define PASTE (x,y) PASTE2(x,y) -#define VMLINUX_SYMBOL (sym) PASTE(SYMBOL_PREFIX, sym) -#endif +#include <linux/export.h> /* Align . to a 8 byte boundary equals to maximum function alignment. */ #define ALIGN_FUNCTION () . = ALIGN(8)
include/linux/export.h +14 -6
@@ -5,17 +5,24 @@* to reduce the amount of pointless cruft we feed to gcc when only * exporting a simple symbol or two. * -* If you feel the need to add #include <linux/foo.h> to this file -* then you are doing something wrong and should go away silently. +* Try not to add #includes here. It slows compilation and makes kernel +* hackers place grumpy comments in header files. */ /* Some toolchains use a `_' prefix for all user symbols. */ -#ifdef CONFIG_SYMBOL_PREFIX -#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX +#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX +#define __VMLINUX_SYMBOL (x) _##x +#define __VMLINUX_SYMBOL_STR (x) "_" #x#else -#define MODULE_SYMBOL_PREFIX "" +#define __VMLINUX_SYMBOL (x) x +#define __VMLINUX_SYMBOL_STR (x) #x#endif +/* Indirect, so macros are expanded before pasting. */ +#define VMLINUX_SYMBOL (x) __VMLINUX_SYMBOL(x) +#define VMLINUX_SYMBOL_STR (x) __VMLINUX_SYMBOL_STR(x) + +#ifndef __ASSEMBLY__ struct kernel_symbol { unsigned long value;
@@ -51,7 +58,7 @@ extern struct module __this_module; __CRC_SYMBOL(sym, sec) \ static const char __kstrtab_##sym[] \ __attribute__((section("__ksymtab_strings"), aligned(1))) \ - = MODULE_SYMBOL_PREFIX #sym; \ + = VMLINUX_SYMBOL_STR(sym); \ static const struct kernel_symbol __ksymtab_##sym \ __used \ __attribute__((section("___ksymtab" sec "+" #sym), unused)) \
@@ -85,5 +92,6 @@ extern struct module __this_module;#define EXPORT_UNUSED_SYMBOL_GPL (sym)#endif /* CONFIG_MODULES */ +#endif /* !__ASSEMBLY__ */ #endif /* _LINUX_EXPORT_H */
include/linux/kernel.h +0 -7
@@ -723,13 +723,6 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }/* Trap pasters of __FUNCTION__ at compile-time */ #define __FUNCTION__ (__func__) -/* This helps us to avoid #ifdef CONFIG_SYMBOL_PREFIX */ -#ifdef CONFIG_SYMBOL_PREFIX -#define SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX -#else -#define SYMBOL_PREFIX "" -#endif -/* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ #ifdef CONFIG_FTRACE_MCOUNT_RECORD # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
include/linux/module.h +2 -2
@@ -190,7 +190,7 @@ extern int modules_disabled; /* for sysctl *//* Get/put a kernel symbol (calls must be symmetric) */ void *__symbol_get (const char *symbol);void *__symbol_get_gpl (const char *symbol); -#define symbol_get (x) ((typeof(&x))(__symbol_get(MODULE_SYMBOL_PREFIX #x))) +#define symbol_get (x) ((typeof(&x))(__symbol_get(VMLINUX_SYMBOL_STR(x))))/* modules using other modules: kdb wants to see this. */ struct module_use {
@@ -453,7 +453,7 @@ extern void __module_put_and_exit(struct module *mod, long code)#ifdef CONFIG_MODULE_UNLOAD unsigned long module_refcount (struct module *mod);void __symbol_put (const char *symbol); -#define symbol_put (x) __symbol_put(MODULE_SYMBOL_PREFIX #x) +#define symbol_put (x) __symbol_put(VMLINUX_SYMBOL_STR(x))void symbol_put_addr (void *addr);/* Sometimes we know we already have a refcount, and it's easier not
kernel/modsign_certificate.S +3 -10
@@ -1,15 +1,8 @@ -/* SYMBOL_PREFIX defined on commandline from CONFIG_SYMBOL_PREFIX */ -#ifndef SYMBOL_PREFIX -#define ASM_SYMBOL(sym) sym -#else -#define PASTE2(x,y) x##y -#define PASTE(x,y) PASTE2(x,y) -#define ASM_SYMBOL(sym) PASTE(SYMBOL_PREFIX, sym) -#endif +#include <linux/export.h> #define GLOBAL(name) \ - .globl ASM_SYMBOL(name); \ - ASM_SYMBOL(name): + .globl VMLINUX_SYMBOL(name); \ + VMLINUX_SYMBOL(name): .section ".init.data","aw"
kernel/module.c +1 -1
@@ -1209,7 +1209,7 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,/* Since this should be found in kernel (which can't be removed), * no locking is necessary. */ -if (!find_symbol (MODULE_SYMBOL_PREFIX "module_layout" ,NULL , +if (!find_symbol (VMLINUX_SYMBOL_STR (module_layout),NULL , &crc, true, false))BUG (); return check_version(sechdrs, versindex, "module_layout", mod, crc,
scripts/Makefile.lib +0 -7
@@ -119,13 +119,6 @@ _c_flags += $(if $(patsubst n%,, \ $(CFLAGS_GCOV)) endif -ifdef CONFIG_SYMBOL_PREFIX -_sym_flags = -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX)) -_cpp_flags += $(_sym_flags) -_a_flags += $(_sym_flags) -endif - - # If building the kernel in a separate objtree expand all occurrences # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
scripts/link-vmlinux.sh +2 -3
@@ -74,9 +74,8 @@ kallsyms() info KSYM ${2} local kallsymopt; - if [ -n "${CONFIG_SYMBOL_PREFIX}" ]; then - kallsymopt="${kallsymopt} \ - --symbol-prefix=${CONFIG_SYMBOL_PREFIX}" + if [ -n "${CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX}" ]; then + kallsymopt="${kallsymopt} --symbol-prefix=_" fi if [ -n "${CONFIG_KALLSYMS_ALL}" ]; then
scripts/mod/modpost.c +15 -21
@@ -18,14 +18,7 @@#include "modpost.h" #include "../../include/generated/autoconf.h" #include "../../include/linux/license.h" - -/* Some toolchains use a `_' prefix for all user symbols. */ -#ifdef CONFIG_SYMBOL_PREFIX -#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX -#else -#define MODULE_SYMBOL_PREFIX "" -#endif - +#include "../../include/linux/export.h" /* Are we using CONFIG_MODVERSIONS? */ int modversions =0 ;
@@ -562,7 +555,7 @@ static void parse_elf_finish(struct elf_info *info)static int ignore_undef_symbol (struct elf_info *info,const char *symname) {/* ignore __this_module, it will be resolved shortly */ -if (strcmp (symname,MODULE_SYMBOL_PREFIX "__this_module" ) ==0 ) +if (strcmp (symname,VMLINUX_SYMBOL_STR (__this_module)) ==0 )return 1 ;/* ignore global offset table */ if (strcmp (symname,"_GLOBAL_OFFSET_TABLE_" ) ==0 )
@@ -583,8 +576,8 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)return 0 ; } -#define CRC_PFX MODULE_SYMBOL_PREFIX "__crc_" -#define KSYMTAB_PFX MODULE_SYMBOL_PREFIX "__ksymtab_" +#define CRC_PFX VMLINUX_SYMBOL_STR(__crc_) +#define KSYMTAB_PFX VMLINUX_SYMBOL_STR(__ksymtab_)static void handle_modversions (struct module *mod,struct elf_info *info,Elf_Sym *sym,const char *symname)
@@ -637,14 +630,15 @@ static void handle_modversions(struct module *mod, struct elf_info *info, }#endif -if (memcmp (symname,MODULE_SYMBOL_PREFIX , -strlen (MODULE_SYMBOL_PREFIX )) ==0 ) { - mod->unres = -alloc_symbol (symname + -strlen (MODULE_SYMBOL_PREFIX ), -ELF_ST_BIND (sym->st_info) ==STB_WEAK , - mod->unres); - } +#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX +if (symname[0 ] !='_' ) +break ; +else + symname++; +#endif + mod->unres =alloc_symbol (symname, +ELF_ST_BIND (sym->st_info) ==STB_WEAK , + mod->unres);break ;default :/* All exported symbols */
@@ -652,9 +646,9 @@ static void handle_modversions(struct module *mod, struct elf_info *info,sym_add_exported (symname +strlen (KSYMTAB_PFX ), mod, export); } -if (strcmp (symname,MODULE_SYMBOL_PREFIX "init_module" ) ==0 ) +if (strcmp (symname,VMLINUX_SYMBOL_STR (init_module)) ==0 ) mod->has_init =1 ; -if (strcmp (symname,MODULE_SYMBOL_PREFIX "cleanup_module" ) ==0 ) +if (strcmp (symname,VMLINUX_SYMBOL_STR (cleanup_module)) ==0 ) mod->has_cleanup =1 ;break ; }
Quoted 24 lines · Rusty Russell
From: Rusty Russell <[email protected]>
Subject:CONFIG_SYMBOL_PREFIX: cleanup.We have
CONFIG_SYMBOL_PREFIX, which three archs define to the string "_". But Al Viro broke this in "consolidatecond_syscallandSYSCALL_ALIASdeclarations" (in linux-next), and he's not the first to do so.Using
CONFIG_SYMBOL_PREFIXis awkward, since we usually just want to prefix it so something. So various places define helpers which are defined to nothing ifCONFIG_SYMBOL_PREFIXisn't set:1)
include/asm-generic/unistd.hdefines__SYMBOL_PREFIX.
2)include/asm-generic/vmlinux.lds.hdefinesVMLINUX_SYMBOL(sym)
3)include/linux/export.hdefinesMODULE_SYMBOL_PREFIX.
4)include/linux/kernel.hdefinesSYMBOL_PREFIX(which differs from #7)
5)kernel/modsign_certificate.SdefinesASM_SYMBOL(sym)
6)scripts/modpost.cdefinesMODULE_SYMBOL_PREFIX
7)scripts/Makefile.libdefinesSYMBOL_PREFIXon the commandline ifCONFIG_SYMBOL_PREFIXis set, so that we have a non-string version for pasting.(
arch/h8300/include/asm/linkage.hdefinesSYMBOL_NAME(), too).
Quoted 7 lines
Let's solve this properly:
1) No more generic prefix, justCONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX.
2) Makelinux/export.husable from asm.
3) DefineVMLINUX_SYMBOL()andVMLINUX_SYMBOL_STR().
4) Make everyone use them.Signed-off-by Rusty Russell <[email protected]>
The only other special case of symbol prefixing I'm aware of is in scripts/genksyms/genksyms.c. It makes the decision at runtime based on the --arch=$ARCH argument, and is the only use of the arch argument:
Quoted 3 lines
if ((strcmp(arch, "h8300") == 0) || (strcmp(arch, "blackfin") == 0) || (strcmp(arch, "metag") == 0)) mod_prefix = "_";
Does the patch below look reasonable in addition to your patch? (Note: I'm not sure if genksyms is only used internally or whether it's API should be kept stable?).
Thanks
James
Subject: [PATCH] genksyms: pass symbol-prefix instead of arch
Pass symbol-prefix to genksyms instead of arch, so that the decision what symbol prefix to use is kept in one place.
Basically genksyms used to take a -a $ARCH argument and it used that to determine whether to add an underscore symbol prefix. It's now changed to take a -s $SYMBOL_PREFIX argument so that the caller decides whether a symbol prefix is required. The build system then uses CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX to determine whether to pass the argument.
--- scripts/Makefile.build | 3 ++- scripts/genksyms/genksyms.c | 18 +++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-)
scripts/Makefile.build +2 -1
@@ -211,7 +211,8 @@ $(obj)/%.i: $(src)/%.c FORCE cmd_gensymtypes = \ $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ - $(GENKSYMS) $(if $(1), -T $(2)) -a $(ARCH) \ + $(GENKSYMS) $(if $(1), -T $(2)) \ + $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \ $(if $(KBUILD_PRESERVE),-p) \ -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null))
scripts/genksyms/genksyms.c +7 -11
@@ -45,7 +45,6 @@ int in_source_file;static int flag_debug, flag_dump_defs, flag_reference, flag_dump_types, flag_preserve, flag_warnings; -static const char *arch ="" ;static const char *mod_prefix ="" ;static int errors;
@@ -731,7 +730,7 @@ static void genksyms_usage(void) {fputs ("Usage:\n" "genksyms [-adDTwqhV] > /path/to/.tmp_obj.ver\n" "\n" #ifdef __GNU_LIBRARY__ -" -a, --arch Select architecture\n" +" -s, --symbol-prefix Select symbol prefix\n" " -d, --debug Increment the debug level (repeatable)\n" " -D, --dump Dump expanded symbol defs (for debugging only)\n" " -r, --reference file Read reference symbols from a file\n"
@@ -742,7 +741,7 @@ static void genksyms_usage(void)" -h, --help Print this message\n" " -V, --version Print the release version\n"#else /* __GNU_LIBRARY__ */ -" -a Select architecture\n" +" -s Select symbol prefix\n" " -d Increment the debug level (repeatable)\n" " -D Dump expanded symbol defs (for debugging only)\n" " -r file Read reference symbols from a file\n"
@@ -763,7 +762,7 @@ int main(int argc, char **argv)#ifdef __GNU_LIBRARY__struct option long_opts[] = { - {"arch" ,1 ,0 ,'a' }, + {"symbol-prefix" ,1 ,0 ,'s' }, {"debug" ,0 ,0 ,'d' }, {"warnings" ,0 ,0 ,'w' }, {"quiet", 0, 0, 'q'},
@@ -776,14 +775,14 @@ int main(int argc, char **argv) {0, 0, 0, 0} }; -while ((o =getopt_long (argc, argv,"a:dwqVDr:T:ph" , +while ((o =getopt_long (argc, argv,"s:dwqVDr:T:ph" , &long_opts[0 ],NULL )) !=EOF ) #else /* __GNU_LIBRARY__ */ - while ((o = getopt(argc, argv, "a:dwqVDr:T:ph")) != EOF) + while ((o = getopt(argc, argv, "s:dwqVDr:T:ph")) != EOF)#endif /* __GNU_LIBRARY__ */ switch (o) { -case 'a' : - arch = optarg; +case 's' : + mod_prefix = optarg;break ;case 'd' : flag_debug++;
@@ -826,9 +825,6 @@ int main(int argc, char **argv)genksyms_usage ();return 1 ; } -if ((strcmp (arch,"h8300" ) ==0 ) || (strcmp (arch,"blackfin" ) ==0 ) || - (strcmp (arch,"metag" ) ==0 )) - mod_prefix ="_" ; {extern int yydebug;extern int yy_flex_debug;
Signature · 1 line
1.8.1.2
Quoted 3 lines · James Hogan
Quoted 2 lines · Rusty Russell
From: Rusty Russell <[email protected]>
Subject:CONFIG_SYMBOL_PREFIX: cleanup.
...
Quoted 2 lines
Reviewed-by James Hogan <[email protected]>Tested-by James Hogan <[email protected]> (metag)
Thanks.
Quoted 8 lines
The only other special case of symbol prefixing I'm aware of is in
scripts/genksyms/genksyms.c. It makes the decision at runtime based on the --arch=$ARCH argument, and is the only use of the arch argument:Quoted 3 lines
if ((strcmp(arch, "h8300") == 0) || (strcmp(arch, "blackfin") == 0) || (strcmp(arch, "metag") == 0)) mod_prefix = "_";
Quoted 8 lines
Does the patch below look reasonable in addition to your patch? (Note: I'm not sure if genksyms is only used internally or whether it's API should be kept stable?).
Thanks
JamesSubject: [PATCH] genksyms: pass symbol-prefix instead of arch
Agreed, I've applied this.
Thanks,
Rusty.