diff options
Diffstat (limited to 'scripts/mod')
-rw-r--r-- | scripts/mod/modpost.c | 37 | ||||
-rw-r--r-- | scripts/mod/sumversion.c | 2 |
2 files changed, 26 insertions, 13 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 8247979e8f64..17855761e6b7 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <string.h> | 17 | #include <string.h> |
18 | #include <limits.h> | 18 | #include <limits.h> |
19 | #include <stdbool.h> | 19 | #include <stdbool.h> |
20 | #include <errno.h> | ||
20 | #include "modpost.h" | 21 | #include "modpost.h" |
21 | #include "../../include/generated/autoconf.h" | 22 | #include "../../include/generated/autoconf.h" |
22 | #include "../../include/linux/license.h" | 23 | #include "../../include/linux/license.h" |
@@ -37,6 +38,8 @@ static int warn_unresolved = 0; | |||
37 | /* How a symbol is exported */ | 38 | /* How a symbol is exported */ |
38 | static int sec_mismatch_count = 0; | 39 | static int sec_mismatch_count = 0; |
39 | static int sec_mismatch_verbose = 1; | 40 | static int sec_mismatch_verbose = 1; |
41 | /* ignore missing files */ | ||
42 | static int ignore_missing_files; | ||
40 | 43 | ||
41 | enum export { | 44 | enum export { |
42 | export_plain, export_unused, export_gpl, | 45 | export_plain, export_unused, export_gpl, |
@@ -161,7 +164,7 @@ struct symbol { | |||
161 | unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */ | 164 | unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */ |
162 | unsigned int kernel:1; /* 1 if symbol is from kernel | 165 | unsigned int kernel:1; /* 1 if symbol is from kernel |
163 | * (only for external modules) **/ | 166 | * (only for external modules) **/ |
164 | unsigned int preloaded:1; /* 1 if symbol from Module.symvers */ | 167 | unsigned int preloaded:1; /* 1 if symbol from Module.symvers, or crc */ |
165 | enum export export; /* Type of export */ | 168 | enum export export; /* Type of export */ |
166 | char name[0]; | 169 | char name[0]; |
167 | }; | 170 | }; |
@@ -329,8 +332,11 @@ static void sym_update_crc(const char *name, struct module *mod, | |||
329 | { | 332 | { |
330 | struct symbol *s = find_symbol(name); | 333 | struct symbol *s = find_symbol(name); |
331 | 334 | ||
332 | if (!s) | 335 | if (!s) { |
333 | s = new_symbol(name, mod, export); | 336 | s = new_symbol(name, mod, export); |
337 | /* Don't complain when we find it later. */ | ||
338 | s->preloaded = 1; | ||
339 | } | ||
334 | s->crc = crc; | 340 | s->crc = crc; |
335 | s->crc_valid = 1; | 341 | s->crc_valid = 1; |
336 | } | 342 | } |
@@ -407,6 +413,11 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
407 | 413 | ||
408 | hdr = grab_file(filename, &info->size); | 414 | hdr = grab_file(filename, &info->size); |
409 | if (!hdr) { | 415 | if (!hdr) { |
416 | if (ignore_missing_files) { | ||
417 | fprintf(stderr, "%s: %s (ignored)\n", filename, | ||
418 | strerror(errno)); | ||
419 | return 0; | ||
420 | } | ||
410 | perror(filename); | 421 | perror(filename); |
411 | exit(1); | 422 | exit(1); |
412 | } | 423 | } |
@@ -599,18 +610,17 @@ static void handle_modversions(struct module *mod, struct elf_info *info, | |||
599 | else | 610 | else |
600 | export = export_from_sec(info, get_secindex(info, sym)); | 611 | export = export_from_sec(info, get_secindex(info, sym)); |
601 | 612 | ||
613 | /* CRC'd symbol */ | ||
614 | if (strncmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) { | ||
615 | crc = (unsigned int) sym->st_value; | ||
616 | sym_update_crc(symname + strlen(CRC_PFX), mod, crc, | ||
617 | export); | ||
618 | } | ||
619 | |||
602 | switch (sym->st_shndx) { | 620 | switch (sym->st_shndx) { |
603 | case SHN_COMMON: | 621 | case SHN_COMMON: |
604 | warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name); | 622 | warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name); |
605 | break; | 623 | break; |
606 | case SHN_ABS: | ||
607 | /* CRC'd symbol */ | ||
608 | if (strncmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) { | ||
609 | crc = (unsigned int) sym->st_value; | ||
610 | sym_update_crc(symname + strlen(CRC_PFX), mod, crc, | ||
611 | export); | ||
612 | } | ||
613 | break; | ||
614 | case SHN_UNDEF: | 624 | case SHN_UNDEF: |
615 | /* undefined symbol */ | 625 | /* undefined symbol */ |
616 | if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL && | 626 | if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL && |
@@ -1853,7 +1863,7 @@ static void add_header(struct buffer *b, struct module *mod) | |||
1853 | buf_printf(b, "\n"); | 1863 | buf_printf(b, "\n"); |
1854 | buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n"); | 1864 | buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n"); |
1855 | buf_printf(b, "\n"); | 1865 | buf_printf(b, "\n"); |
1856 | buf_printf(b, "struct module __this_module\n"); | 1866 | buf_printf(b, "__visible struct module __this_module\n"); |
1857 | buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n"); | 1867 | buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n"); |
1858 | buf_printf(b, "\t.name = KBUILD_MODNAME,\n"); | 1868 | buf_printf(b, "\t.name = KBUILD_MODNAME,\n"); |
1859 | if (mod->has_init) | 1869 | if (mod->has_init) |
@@ -2119,7 +2129,7 @@ int main(int argc, char **argv) | |||
2119 | struct ext_sym_list *extsym_iter; | 2129 | struct ext_sym_list *extsym_iter; |
2120 | struct ext_sym_list *extsym_start = NULL; | 2130 | struct ext_sym_list *extsym_start = NULL; |
2121 | 2131 | ||
2122 | while ((opt = getopt(argc, argv, "i:I:e:msST:o:awM:K:")) != -1) { | 2132 | while ((opt = getopt(argc, argv, "i:I:e:mnsST:o:awM:K:")) != -1) { |
2123 | switch (opt) { | 2133 | switch (opt) { |
2124 | case 'i': | 2134 | case 'i': |
2125 | kernel_read = optarg; | 2135 | kernel_read = optarg; |
@@ -2139,6 +2149,9 @@ int main(int argc, char **argv) | |||
2139 | case 'm': | 2149 | case 'm': |
2140 | modversions = 1; | 2150 | modversions = 1; |
2141 | break; | 2151 | break; |
2152 | case 'n': | ||
2153 | ignore_missing_files = 1; | ||
2154 | break; | ||
2142 | case 'o': | 2155 | case 'o': |
2143 | dump_write = optarg; | 2156 | dump_write = optarg; |
2144 | break; | 2157 | break; |
diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c index 9dfcd6d988da..deb2994b04c4 100644 --- a/scripts/mod/sumversion.c +++ b/scripts/mod/sumversion.c | |||
@@ -416,7 +416,7 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen) | |||
416 | basename = strrchr(modname, '/') + 1; | 416 | basename = strrchr(modname, '/') + 1; |
417 | else | 417 | else |
418 | basename = modname; | 418 | basename = modname; |
419 | sprintf(filelist, "%s/%.*s.mod", modverdir, | 419 | snprintf(filelist, sizeof(filelist), "%s/%.*s.mod", modverdir, |
420 | (int) strlen(basename) - 2, basename); | 420 | (int) strlen(basename) - 2, basename); |
421 | 421 | ||
422 | file = grab_file(filelist, &len); | 422 | file = grab_file(filelist, &len); |