diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-05 13:58:06 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-05 13:58:06 -0400 |
| commit | f8ce1faf55955de62e0a12e330c6d9a526071f65 (patch) | |
| tree | a3b0ddd3f37e40d3ed0fd2cd433a2723403c8b97 /scripts/mod | |
| parent | 24d0c2542b38963ae4d5171ecc0a2c1326c656bc (diff) | |
| parent | a53a11f35762ff1d5e268adedf2ab9ce313f871d (diff) | |
Merge tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux
Pull mudule updates from Rusty Russell:
"We get rid of the general module prefix confusion with a binary config
option, fix a remove/insert race which Never Happens, and (my
favorite) handle the case when we have too many modules for a single
commandline. Seriously, the kernel is full, please go away!"
* tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
modpost: fix unwanted VMLINUX_SYMBOL_STR expansion
X.509: Support parse long form of length octets in Authority Key Identifier
module: don't unlink the module until we've removed all exposure.
kernel: kallsyms: memory override issue, need check destination buffer length
MODSIGN: do not send garbage to stderr when enabling modules signature
modpost: handle huge numbers of modules.
modpost: add -T option to read module names from file/stdin.
modpost: minor cleanup.
genksyms: pass symbol-prefix instead of arch
module: fix symbol versioning with symbol prefixes
CONFIG_SYMBOL_PREFIX: cleanup.
Diffstat (limited to 'scripts/mod')
| -rw-r--r-- | scripts/mod/modpost.c | 94 |
1 files changed, 62 insertions, 32 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 78b30c1548e9..a4be8e112bb6 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
| @@ -15,17 +15,12 @@ | |||
| 15 | #include <stdio.h> | 15 | #include <stdio.h> |
| 16 | #include <ctype.h> | 16 | #include <ctype.h> |
| 17 | #include <string.h> | 17 | #include <string.h> |
| 18 | #include <limits.h> | ||
| 19 | #include <stdbool.h> | ||
| 18 | #include "modpost.h" | 20 | #include "modpost.h" |
| 19 | #include "../../include/generated/autoconf.h" | 21 | #include "../../include/generated/autoconf.h" |
| 20 | #include "../../include/linux/license.h" | 22 | #include "../../include/linux/license.h" |
| 21 | 23 | #include "../../include/linux/export.h" | |
| 22 | /* Some toolchains use a `_' prefix for all user symbols. */ | ||
| 23 | #ifdef CONFIG_SYMBOL_PREFIX | ||
| 24 | #define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX | ||
| 25 | #else | ||
| 26 | #define MODULE_SYMBOL_PREFIX "" | ||
| 27 | #endif | ||
| 28 | |||
| 29 | 24 | ||
| 30 | /* Are we using CONFIG_MODVERSIONS? */ | 25 | /* Are we using CONFIG_MODVERSIONS? */ |
| 31 | int modversions = 0; | 26 | int modversions = 0; |
| @@ -85,6 +80,14 @@ PRINTF void merror(const char *fmt, ...) | |||
| 85 | va_end(arglist); | 80 | va_end(arglist); |
| 86 | } | 81 | } |
| 87 | 82 | ||
| 83 | static inline bool strends(const char *str, const char *postfix) | ||
| 84 | { | ||
| 85 | if (strlen(str) < strlen(postfix)) | ||
| 86 | return false; | ||
| 87 | |||
| 88 | return strcmp(str + strlen(str) - strlen(postfix), postfix) == 0; | ||
| 89 | } | ||
| 90 | |||
| 88 | static int is_vmlinux(const char *modname) | 91 | static int is_vmlinux(const char *modname) |
| 89 | { | 92 | { |
| 90 | const char *myname; | 93 | const char *myname; |
| @@ -120,22 +123,20 @@ static struct module *find_module(char *modname) | |||
| 120 | return mod; | 123 | return mod; |
| 121 | } | 124 | } |
| 122 | 125 | ||
| 123 | static struct module *new_module(char *modname) | 126 | static struct module *new_module(const char *modname) |
| 124 | { | 127 | { |
| 125 | struct module *mod; | 128 | struct module *mod; |
| 126 | char *p, *s; | 129 | char *p; |
| 127 | 130 | ||
| 128 | mod = NOFAIL(malloc(sizeof(*mod))); | 131 | mod = NOFAIL(malloc(sizeof(*mod))); |
| 129 | memset(mod, 0, sizeof(*mod)); | 132 | memset(mod, 0, sizeof(*mod)); |
| 130 | p = NOFAIL(strdup(modname)); | 133 | p = NOFAIL(strdup(modname)); |
| 131 | 134 | ||
| 132 | /* strip trailing .o */ | 135 | /* strip trailing .o */ |
| 133 | s = strrchr(p, '.'); | 136 | if (strends(p, ".o")) { |
| 134 | if (s != NULL) | 137 | p[strlen(p) - 2] = '\0'; |
| 135 | if (strcmp(s, ".o") == 0) { | 138 | mod->is_dot_o = 1; |
| 136 | *s = '\0'; | 139 | } |
| 137 | mod->is_dot_o = 1; | ||
| 138 | } | ||
| 139 | 140 | ||
| 140 | /* add to list */ | 141 | /* add to list */ |
| 141 | mod->name = p; | 142 | mod->name = p; |
| @@ -562,7 +563,7 @@ static void parse_elf_finish(struct elf_info *info) | |||
| 562 | static int ignore_undef_symbol(struct elf_info *info, const char *symname) | 563 | static int ignore_undef_symbol(struct elf_info *info, const char *symname) |
| 563 | { | 564 | { |
| 564 | /* ignore __this_module, it will be resolved shortly */ | 565 | /* ignore __this_module, it will be resolved shortly */ |
| 565 | if (strcmp(symname, MODULE_SYMBOL_PREFIX "__this_module") == 0) | 566 | if (strcmp(symname, VMLINUX_SYMBOL_STR(__this_module)) == 0) |
| 566 | return 1; | 567 | return 1; |
| 567 | /* ignore global offset table */ | 568 | /* ignore global offset table */ |
| 568 | if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0) | 569 | if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0) |
| @@ -583,8 +584,8 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname) | |||
| 583 | return 0; | 584 | return 0; |
| 584 | } | 585 | } |
| 585 | 586 | ||
| 586 | #define CRC_PFX MODULE_SYMBOL_PREFIX "__crc_" | 587 | #define CRC_PFX VMLINUX_SYMBOL_STR(__crc_) |
| 587 | #define KSYMTAB_PFX MODULE_SYMBOL_PREFIX "__ksymtab_" | 588 | #define KSYMTAB_PFX VMLINUX_SYMBOL_STR(__ksymtab_) |
| 588 | 589 | ||
| 589 | static void handle_modversions(struct module *mod, struct elf_info *info, | 590 | static void handle_modversions(struct module *mod, struct elf_info *info, |
| 590 | Elf_Sym *sym, const char *symname) | 591 | Elf_Sym *sym, const char *symname) |
| @@ -637,14 +638,15 @@ static void handle_modversions(struct module *mod, struct elf_info *info, | |||
| 637 | } | 638 | } |
| 638 | #endif | 639 | #endif |
| 639 | 640 | ||
| 640 | if (memcmp(symname, MODULE_SYMBOL_PREFIX, | 641 | #ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX |
| 641 | strlen(MODULE_SYMBOL_PREFIX)) == 0) { | 642 | if (symname[0] != '_') |
| 642 | mod->unres = | 643 | break; |
| 643 | alloc_symbol(symname + | 644 | else |
| 644 | strlen(MODULE_SYMBOL_PREFIX), | 645 | symname++; |
| 645 | ELF_ST_BIND(sym->st_info) == STB_WEAK, | 646 | #endif |
| 646 | mod->unres); | 647 | mod->unres = alloc_symbol(symname, |
| 647 | } | 648 | ELF_ST_BIND(sym->st_info) == STB_WEAK, |
| 649 | mod->unres); | ||
| 648 | break; | 650 | break; |
| 649 | default: | 651 | default: |
| 650 | /* All exported symbols */ | 652 | /* All exported symbols */ |
| @@ -652,9 +654,9 @@ static void handle_modversions(struct module *mod, struct elf_info *info, | |||
| 652 | sym_add_exported(symname + strlen(KSYMTAB_PFX), mod, | 654 | sym_add_exported(symname + strlen(KSYMTAB_PFX), mod, |
| 653 | export); | 655 | export); |
| 654 | } | 656 | } |
| 655 | if (strcmp(symname, MODULE_SYMBOL_PREFIX "init_module") == 0) | 657 | if (strcmp(symname, VMLINUX_SYMBOL_STR(init_module)) == 0) |
| 656 | mod->has_init = 1; | 658 | mod->has_init = 1; |
| 657 | if (strcmp(symname, MODULE_SYMBOL_PREFIX "cleanup_module") == 0) | 659 | if (strcmp(symname, VMLINUX_SYMBOL_STR(cleanup_module)) == 0) |
| 658 | mod->has_cleanup = 1; | 660 | mod->has_cleanup = 1; |
| 659 | break; | 661 | break; |
| 660 | } | 662 | } |
| @@ -1762,6 +1764,27 @@ static void read_symbols(char *modname) | |||
| 1762 | mod->unres = alloc_symbol("module_layout", 0, mod->unres); | 1764 | mod->unres = alloc_symbol("module_layout", 0, mod->unres); |
| 1763 | } | 1765 | } |
| 1764 | 1766 | ||
| 1767 | static void read_symbols_from_files(const char *filename) | ||
| 1768 | { | ||
| 1769 | FILE *in = stdin; | ||
| 1770 | char fname[PATH_MAX]; | ||
| 1771 | |||
| 1772 | if (strcmp(filename, "-") != 0) { | ||
| 1773 | in = fopen(filename, "r"); | ||
| 1774 | if (!in) | ||
| 1775 | fatal("Can't open filenames file %s: %m", filename); | ||
| 1776 | } | ||
| 1777 | |||
| 1778 | while (fgets(fname, PATH_MAX, in) != NULL) { | ||
| 1779 | if (strends(fname, "\n")) | ||
| 1780 | fname[strlen(fname)-1] = '\0'; | ||
| 1781 | read_symbols(fname); | ||
| 1782 | } | ||
| 1783 | |||
| 1784 | if (in != stdin) | ||
| 1785 | fclose(in); | ||
| 1786 | } | ||
| 1787 | |||
| 1765 | #define SZ 500 | 1788 | #define SZ 500 |
| 1766 | 1789 | ||
| 1767 | /* We first write the generated file into memory using the | 1790 | /* We first write the generated file into memory using the |
| @@ -1934,7 +1957,8 @@ static int add_versions(struct buffer *b, struct module *mod) | |||
| 1934 | s->name, mod->name); | 1957 | s->name, mod->name); |
| 1935 | continue; | 1958 | continue; |
| 1936 | } | 1959 | } |
| 1937 | buf_printf(b, "\t{ %#8x, \"%s\" },\n", s->crc, s->name); | 1960 | buf_printf(b, "\t{ %#8x, __VMLINUX_SYMBOL_STR(%s) },\n", |
| 1961 | s->crc, s->name); | ||
| 1938 | } | 1962 | } |
| 1939 | 1963 | ||
| 1940 | buf_printf(b, "};\n"); | 1964 | buf_printf(b, "};\n"); |
| @@ -2122,13 +2146,13 @@ int main(int argc, char **argv) | |||
| 2122 | struct module *mod; | 2146 | struct module *mod; |
| 2123 | struct buffer buf = { }; | 2147 | struct buffer buf = { }; |
| 2124 | char *kernel_read = NULL, *module_read = NULL; | 2148 | char *kernel_read = NULL, *module_read = NULL; |
| 2125 | char *dump_write = NULL; | 2149 | char *dump_write = NULL, *files_source = NULL; |
| 2126 | int opt; | 2150 | int opt; |
| 2127 | int err; | 2151 | int err; |
| 2128 | struct ext_sym_list *extsym_iter; | 2152 | struct ext_sym_list *extsym_iter; |
| 2129 | struct ext_sym_list *extsym_start = NULL; | 2153 | struct ext_sym_list *extsym_start = NULL; |
| 2130 | 2154 | ||
| 2131 | while ((opt = getopt(argc, argv, "i:I:e:msSo:awM:K:")) != -1) { | 2155 | while ((opt = getopt(argc, argv, "i:I:e:msST:o:awM:K:")) != -1) { |
| 2132 | switch (opt) { | 2156 | switch (opt) { |
| 2133 | case 'i': | 2157 | case 'i': |
| 2134 | kernel_read = optarg; | 2158 | kernel_read = optarg; |
| @@ -2160,6 +2184,9 @@ int main(int argc, char **argv) | |||
| 2160 | case 'S': | 2184 | case 'S': |
| 2161 | sec_mismatch_verbose = 0; | 2185 | sec_mismatch_verbose = 0; |
| 2162 | break; | 2186 | break; |
| 2187 | case 'T': | ||
| 2188 | files_source = optarg; | ||
| 2189 | break; | ||
| 2163 | case 'w': | 2190 | case 'w': |
| 2164 | warn_unresolved = 1; | 2191 | warn_unresolved = 1; |
| 2165 | break; | 2192 | break; |
| @@ -2182,6 +2209,9 @@ int main(int argc, char **argv) | |||
| 2182 | while (optind < argc) | 2209 | while (optind < argc) |
| 2183 | read_symbols(argv[optind++]); | 2210 | read_symbols(argv[optind++]); |
| 2184 | 2211 | ||
| 2212 | if (files_source) | ||
| 2213 | read_symbols_from_files(files_source); | ||
| 2214 | |||
| 2185 | for (mod = modules; mod; mod = mod->next) { | 2215 | for (mod = modules; mod; mod = mod->next) { |
| 2186 | if (mod->skip) | 2216 | if (mod->skip) |
| 2187 | continue; | 2217 | continue; |
