aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2013-03-15 00:34:17 -0400
committerRusty Russell <rusty@rustcorp.com.au>2013-03-15 00:39:43 -0400
commitb92021b09df70c1609e3547f3d6128dd560be97f (patch)
tree0203752a738c71718f5141b84f5143d1dc8b431d /scripts/mod
parent4febd95a8a85dd38b1a71fcf9726e19c7fd20039 (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 'scripts/mod')
-rw-r--r--scripts/mod/modpost.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 78b30c1548e9..282decfa29ae 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -18,14 +18,7 @@
18#include "modpost.h" 18#include "modpost.h"
19#include "../../include/generated/autoconf.h" 19#include "../../include/generated/autoconf.h"
20#include "../../include/linux/license.h" 20#include "../../include/linux/license.h"
21 21#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 22
30/* Are we using CONFIG_MODVERSIONS? */ 23/* Are we using CONFIG_MODVERSIONS? */
31int modversions = 0; 24int modversions = 0;
@@ -562,7 +555,7 @@ static void parse_elf_finish(struct elf_info *info)
562static int ignore_undef_symbol(struct elf_info *info, const char *symname) 555static int ignore_undef_symbol(struct elf_info *info, const char *symname)
563{ 556{
564 /* ignore __this_module, it will be resolved shortly */ 557 /* ignore __this_module, it will be resolved shortly */
565 if (strcmp(symname, MODULE_SYMBOL_PREFIX "__this_module") == 0) 558 if (strcmp(symname, VMLINUX_SYMBOL_STR(__this_module)) == 0)
566 return 1; 559 return 1;
567 /* ignore global offset table */ 560 /* ignore global offset table */
568 if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0) 561 if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0)
@@ -583,8 +576,8 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)
583 return 0; 576 return 0;
584} 577}
585 578
586#define CRC_PFX MODULE_SYMBOL_PREFIX "__crc_" 579#define CRC_PFX VMLINUX_SYMBOL_STR(__crc_)
587#define KSYMTAB_PFX MODULE_SYMBOL_PREFIX "__ksymtab_" 580#define KSYMTAB_PFX VMLINUX_SYMBOL_STR(__ksymtab_)
588 581
589static void handle_modversions(struct module *mod, struct elf_info *info, 582static void handle_modversions(struct module *mod, struct elf_info *info,
590 Elf_Sym *sym, const char *symname) 583 Elf_Sym *sym, const char *symname)
@@ -637,14 +630,15 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
637 } 630 }
638#endif 631#endif
639 632
640 if (memcmp(symname, MODULE_SYMBOL_PREFIX, 633#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX
641 strlen(MODULE_SYMBOL_PREFIX)) == 0) { 634 if (symname[0] != '_')
642 mod->unres = 635 break;
643 alloc_symbol(symname + 636 else
644 strlen(MODULE_SYMBOL_PREFIX), 637 symname++;
645 ELF_ST_BIND(sym->st_info) == STB_WEAK, 638#endif
646 mod->unres); 639 mod->unres = alloc_symbol(symname,
647 } 640 ELF_ST_BIND(sym->st_info) == STB_WEAK,
641 mod->unres);
648 break; 642 break;
649 default: 643 default:
650 /* All exported symbols */ 644 /* All exported symbols */
@@ -652,9 +646,9 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
652 sym_add_exported(symname + strlen(KSYMTAB_PFX), mod, 646 sym_add_exported(symname + strlen(KSYMTAB_PFX), mod,
653 export); 647 export);
654 } 648 }
655 if (strcmp(symname, MODULE_SYMBOL_PREFIX "init_module") == 0) 649 if (strcmp(symname, VMLINUX_SYMBOL_STR(init_module)) == 0)
656 mod->has_init = 1; 650 mod->has_init = 1;
657 if (strcmp(symname, MODULE_SYMBOL_PREFIX "cleanup_module") == 0) 651 if (strcmp(symname, VMLINUX_SYMBOL_STR(cleanup_module)) == 0)
658 mod->has_cleanup = 1; 652 mod->has_cleanup = 1;
659 break; 653 break;
660 } 654 }