diff options
Diffstat (limited to 'scripts/mod')
-rw-r--r-- | scripts/mod/devicetable-offsets.c | 3 | ||||
-rw-r--r-- | scripts/mod/file2alias.c | 12 | ||||
-rw-r--r-- | scripts/mod/modpost.c | 94 |
3 files changed, 77 insertions, 32 deletions
diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c index b45260bfeaa0..e66d4d258e1a 100644 --- a/scripts/mod/devicetable-offsets.c +++ b/scripts/mod/devicetable-offsets.c | |||
@@ -174,5 +174,8 @@ int main(void) | |||
174 | DEVID_FIELD(x86_cpu_id, model); | 174 | DEVID_FIELD(x86_cpu_id, model); |
175 | DEVID_FIELD(x86_cpu_id, vendor); | 175 | DEVID_FIELD(x86_cpu_id, vendor); |
176 | 176 | ||
177 | DEVID(mei_cl_device_id); | ||
178 | DEVID_FIELD(mei_cl_device_id, name); | ||
179 | |||
177 | return 0; | 180 | return 0; |
178 | } | 181 | } |
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 771ac17f635d..45f9a3377dcd 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -1133,6 +1133,18 @@ static int do_x86cpu_entry(const char *filename, void *symval, | |||
1133 | } | 1133 | } |
1134 | ADD_TO_DEVTABLE("x86cpu", x86_cpu_id, do_x86cpu_entry); | 1134 | ADD_TO_DEVTABLE("x86cpu", x86_cpu_id, do_x86cpu_entry); |
1135 | 1135 | ||
1136 | /* Looks like: mei:S */ | ||
1137 | static int do_mei_entry(const char *filename, void *symval, | ||
1138 | char *alias) | ||
1139 | { | ||
1140 | DEF_FIELD_ADDR(symval, mei_cl_device_id, name); | ||
1141 | |||
1142 | sprintf(alias, MEI_CL_MODULE_PREFIX "%s", *name); | ||
1143 | |||
1144 | return 1; | ||
1145 | } | ||
1146 | ADD_TO_DEVTABLE("mei", mei_cl_device_id, do_mei_entry); | ||
1147 | |||
1136 | /* Does namelen bytes of name exactly match the symbol? */ | 1148 | /* Does namelen bytes of name exactly match the symbol? */ |
1137 | static bool sym_is(const char *name, unsigned namelen, const char *symbol) | 1149 | static bool sym_is(const char *name, unsigned namelen, const char *symbol) |
1138 | { | 1150 | { |
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; |