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 /scripts | |
| 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 'scripts')
| -rw-r--r-- | scripts/Makefile.lib | 7 | ||||
| -rw-r--r-- | scripts/link-vmlinux.sh | 5 | ||||
| -rw-r--r-- | scripts/mod/modpost.c | 36 |
3 files changed, 17 insertions, 31 deletions
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 07125e697d7a..a373a1f66023 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
| @@ -119,13 +119,6 @@ _c_flags += $(if $(patsubst n%,, \ | |||
| 119 | $(CFLAGS_GCOV)) | 119 | $(CFLAGS_GCOV)) |
| 120 | endif | 120 | endif |
| 121 | 121 | ||
| 122 | ifdef CONFIG_SYMBOL_PREFIX | ||
| 123 | _sym_flags = -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX)) | ||
| 124 | _cpp_flags += $(_sym_flags) | ||
| 125 | _a_flags += $(_sym_flags) | ||
| 126 | endif | ||
| 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/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..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? */ |
| 31 | int modversions = 0; | 24 | int modversions = 0; |
| @@ -562,7 +555,7 @@ static void parse_elf_finish(struct elf_info *info) | |||
| 562 | static int ignore_undef_symbol(struct elf_info *info, const char *symname) | 555 | static 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 | ||
| 589 | static void handle_modversions(struct module *mod, struct elf_info *info, | 582 | static 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 | } |
