diff options
Diffstat (limited to 'scripts/mod/modpost.c')
-rw-r--r-- | scripts/mod/modpost.c | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index dfde0e87a765..41277963f47a 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -23,6 +23,8 @@ int have_vmlinux = 0; | |||
23 | static int all_versions = 0; | 23 | static int all_versions = 0; |
24 | /* If we are modposting external module set to 1 */ | 24 | /* If we are modposting external module set to 1 */ |
25 | static int external_module = 0; | 25 | static int external_module = 0; |
26 | /* Only warn about unresolved symbols */ | ||
27 | static int warn_unresolved = 0; | ||
26 | /* How a symbol is exported */ | 28 | /* How a symbol is exported */ |
27 | enum export { | 29 | enum export { |
28 | export_plain, export_unused, export_gpl, | 30 | export_plain, export_unused, export_gpl, |
@@ -581,8 +583,8 @@ static int strrcmp(const char *s, const char *sub) | |||
581 | * fromsec = .data | 583 | * fromsec = .data |
582 | * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one | 584 | * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one |
583 | **/ | 585 | **/ |
584 | static int secref_whitelist(const char *tosec, const char *fromsec, | 586 | static int secref_whitelist(const char *modname, const char *tosec, |
585 | const char *atsym) | 587 | const char *fromsec, const char *atsym) |
586 | { | 588 | { |
587 | int f1 = 1, f2 = 1; | 589 | int f1 = 1, f2 = 1; |
588 | const char **s; | 590 | const char **s; |
@@ -618,8 +620,16 @@ static int secref_whitelist(const char *tosec, const char *fromsec, | |||
618 | for (s = pat2sym; *s; s++) | 620 | for (s = pat2sym; *s; s++) |
619 | if (strrcmp(atsym, *s) == 0) | 621 | if (strrcmp(atsym, *s) == 0) |
620 | f1 = 1; | 622 | f1 = 1; |
623 | if (f1 && f2) | ||
624 | return 1; | ||
621 | 625 | ||
622 | return f1 && f2; | 626 | /* Whitelist all references from .pci_fixup section if vmlinux */ |
627 | if (is_vmlinux(modname)) { | ||
628 | if ((strcmp(fromsec, ".pci_fixup") == 0) && | ||
629 | (strcmp(tosec, ".init.text") == 0)) | ||
630 | return 1; | ||
631 | } | ||
632 | return 0; | ||
623 | } | 633 | } |
624 | 634 | ||
625 | /** | 635 | /** |
@@ -726,7 +736,8 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, | |||
726 | 736 | ||
727 | /* check whitelist - we may ignore it */ | 737 | /* check whitelist - we may ignore it */ |
728 | if (before && | 738 | if (before && |
729 | secref_whitelist(secname, fromsec, elf->strtab + before->st_name)) | 739 | secref_whitelist(modname, secname, fromsec, |
740 | elf->strtab + before->st_name)) | ||
730 | return; | 741 | return; |
731 | 742 | ||
732 | if (before && after) { | 743 | if (before && after) { |
@@ -1187,16 +1198,19 @@ static void add_header(struct buffer *b, struct module *mod) | |||
1187 | /** | 1198 | /** |
1188 | * Record CRCs for unresolved symbols | 1199 | * Record CRCs for unresolved symbols |
1189 | **/ | 1200 | **/ |
1190 | static void add_versions(struct buffer *b, struct module *mod) | 1201 | static int add_versions(struct buffer *b, struct module *mod) |
1191 | { | 1202 | { |
1192 | struct symbol *s, *exp; | 1203 | struct symbol *s, *exp; |
1204 | int err = 0; | ||
1193 | 1205 | ||
1194 | for (s = mod->unres; s; s = s->next) { | 1206 | for (s = mod->unres; s; s = s->next) { |
1195 | exp = find_symbol(s->name); | 1207 | exp = find_symbol(s->name); |
1196 | if (!exp || exp->module == mod) { | 1208 | if (!exp || exp->module == mod) { |
1197 | if (have_vmlinux && !s->weak) | 1209 | if (have_vmlinux && !s->weak) { |
1198 | warn("\"%s\" [%s.ko] undefined!\n", | 1210 | warn("\"%s\" [%s.ko] undefined!\n", |
1199 | s->name, mod->name); | 1211 | s->name, mod->name); |
1212 | err = warn_unresolved ? 0 : 1; | ||
1213 | } | ||
1200 | continue; | 1214 | continue; |
1201 | } | 1215 | } |
1202 | s->module = exp->module; | 1216 | s->module = exp->module; |
@@ -1205,7 +1219,7 @@ static void add_versions(struct buffer *b, struct module *mod) | |||
1205 | } | 1219 | } |
1206 | 1220 | ||
1207 | if (!modversions) | 1221 | if (!modversions) |
1208 | return; | 1222 | return err; |
1209 | 1223 | ||
1210 | buf_printf(b, "\n"); | 1224 | buf_printf(b, "\n"); |
1211 | buf_printf(b, "static const struct modversion_info ____versions[]\n"); | 1225 | buf_printf(b, "static const struct modversion_info ____versions[]\n"); |
@@ -1225,6 +1239,8 @@ static void add_versions(struct buffer *b, struct module *mod) | |||
1225 | } | 1239 | } |
1226 | 1240 | ||
1227 | buf_printf(b, "};\n"); | 1241 | buf_printf(b, "};\n"); |
1242 | |||
1243 | return err; | ||
1228 | } | 1244 | } |
1229 | 1245 | ||
1230 | static void add_depends(struct buffer *b, struct module *mod, | 1246 | static void add_depends(struct buffer *b, struct module *mod, |
@@ -1402,8 +1418,9 @@ int main(int argc, char **argv) | |||
1402 | char *kernel_read = NULL, *module_read = NULL; | 1418 | char *kernel_read = NULL, *module_read = NULL; |
1403 | char *dump_write = NULL; | 1419 | char *dump_write = NULL; |
1404 | int opt; | 1420 | int opt; |
1421 | int err; | ||
1405 | 1422 | ||
1406 | while ((opt = getopt(argc, argv, "i:I:mo:a")) != -1) { | 1423 | while ((opt = getopt(argc, argv, "i:I:mo:aw")) != -1) { |
1407 | switch(opt) { | 1424 | switch(opt) { |
1408 | case 'i': | 1425 | case 'i': |
1409 | kernel_read = optarg; | 1426 | kernel_read = optarg; |
@@ -1421,6 +1438,9 @@ int main(int argc, char **argv) | |||
1421 | case 'a': | 1438 | case 'a': |
1422 | all_versions = 1; | 1439 | all_versions = 1; |
1423 | break; | 1440 | break; |
1441 | case 'w': | ||
1442 | warn_unresolved = 1; | ||
1443 | break; | ||
1424 | default: | 1444 | default: |
1425 | exit(1); | 1445 | exit(1); |
1426 | } | 1446 | } |
@@ -1441,6 +1461,8 @@ int main(int argc, char **argv) | |||
1441 | check_exports(mod); | 1461 | check_exports(mod); |
1442 | } | 1462 | } |
1443 | 1463 | ||
1464 | err = 0; | ||
1465 | |||
1444 | for (mod = modules; mod; mod = mod->next) { | 1466 | for (mod = modules; mod; mod = mod->next) { |
1445 | if (mod->skip) | 1467 | if (mod->skip) |
1446 | continue; | 1468 | continue; |
@@ -1448,7 +1470,7 @@ int main(int argc, char **argv) | |||
1448 | buf.pos = 0; | 1470 | buf.pos = 0; |
1449 | 1471 | ||
1450 | add_header(&buf, mod); | 1472 | add_header(&buf, mod); |
1451 | add_versions(&buf, mod); | 1473 | err |= add_versions(&buf, mod); |
1452 | add_depends(&buf, mod, modules); | 1474 | add_depends(&buf, mod, modules); |
1453 | add_moddevtable(&buf, mod); | 1475 | add_moddevtable(&buf, mod); |
1454 | add_srcversion(&buf, mod); | 1476 | add_srcversion(&buf, mod); |
@@ -1460,5 +1482,5 @@ int main(int argc, char **argv) | |||
1460 | if (dump_write) | 1482 | if (dump_write) |
1461 | write_dump(dump_write); | 1483 | write_dump(dump_write); |
1462 | 1484 | ||
1463 | return 0; | 1485 | return err; |
1464 | } | 1486 | } |