| @@ -43,8 +43,9 @@ static int allow_missing_ns_imports; · 42 unmodified lines |
| 43 | static bool error_occurred; | 43 | static bool error_occurred; |
| 44 | | 44 | |
| 45 | enum export { | 45 | enum export { |
| 46 | export_plain, export_unused, export_gpl, | 46 | export_plain, |
| 47 | export_unused_gpl, export_unknown | 47 | export_gpl, |
| | 48 | export_unknown |
| 48 | }; | 49 | }; |
| 49 | | 50 | |
| 50 | /* In kernel, this size is defined in linux/module.h; | 51 | /* In kernel, this size is defined in linux/module.h; |
| @@ -301,9 +302,7 @@ static const struct { · 250 unmodified lines |
| 301 | enum export export; | 302 | enum export export; |
| 302 | } export_list[] = { | 303 | } export_list[] = { |
| 303 | { .str = "EXPORT_SYMBOL", .export = export_plain }, | 304 | { .str = "EXPORT_SYMBOL", .export = export_plain }, |
| 304 | { .str = "EXPORT_UNUSED_SYMBOL", .export = export_unused }, | | |
| 305 | { .str = "EXPORT_SYMBOL_GPL", .export = export_gpl }, | 305 | { .str = "EXPORT_SYMBOL_GPL", .export = export_gpl }, |
| 306 | { .str = "EXPORT_UNUSED_SYMBOL_GPL", .export = export_unused_gpl }, | | |
| 307 | { .str = "(unknown)", .export = export_unknown }, | 306 | { .str = "(unknown)", .export = export_unknown }, |
| 308 | }; | 307 | }; |
| 309 | | 308 | |
| @@ -362,12 +361,8 @@ static enum export export_from_secname(struct elf_info *elf, unsigned int sec) · 52 unmodified lines |
| 362 | | 361 | |
| 363 | if (strstarts(secname, "___ksymtab+")) | 362 | if (strstarts(secname, "___ksymtab+")) |
| 364 | return export_plain; | 363 | return export_plain; |
| 365 | else if (strstarts(secname, "___ksymtab_unused+")) | | |
| 366 | return export_unused; | | |
| 367 | else if (strstarts(secname, "___ksymtab_gpl+")) | 364 | else if (strstarts(secname, "___ksymtab_gpl+")) |
| 368 | return export_gpl; | 365 | return export_gpl; |
| 369 | else if (strstarts(secname, "___ksymtab_unused_gpl+")) | | |
| 370 | return export_unused_gpl; | | |
| 371 | else | 366 | else |
| 372 | return export_unknown; | 367 | return export_unknown; |
| 373 | } | 368 | } |
| @@ -376,12 +371,8 @@ static enum export export_from_sec(struct elf_info *elf, unsigned int sec) · 2 unmodified lines |
| 376 | { | 371 | { |
| 377 | if (sec == elf->export_sec) | 372 | if (sec == elf->export_sec) |
| 378 | return export_plain; | 373 | return export_plain; |
| 379 | else if (sec == elf->export_unused_sec) | | |
| 380 | return export_unused; | | |
| 381 | else if (sec == elf->export_gpl_sec) | 374 | else if (sec == elf->export_gpl_sec) |
| 382 | return export_gpl; | 375 | return export_gpl; |
| 383 | else if (sec == elf->export_unused_gpl_sec) | | |
| 384 | return export_unused_gpl; | | |
| 385 | else | 376 | else |
| 386 | return export_unknown; | 377 | return export_unknown; |
| 387 | } | 378 | } |
| @@ -585,12 +576,8 @@ static int parse_elf(struct elf_info *info, const char *filename) · 197 unmodified lines |
| 585 | info->modinfo_len = sechdrs[i].sh_size; | 576 | info->modinfo_len = sechdrs[i].sh_size; |
| 586 | } else if (strcmp(secname, "__ksymtab") == 0) | 577 | } else if (strcmp(secname, "__ksymtab") == 0) |
| 587 | info->export_sec = i; | 578 | info->export_sec = i; |
| 588 | else if (strcmp(secname, "__ksymtab_unused") == 0) | | |
| 589 | info->export_unused_sec = i; | | |
| 590 | else if (strcmp(secname, "__ksymtab_gpl") == 0) | 579 | else if (strcmp(secname, "__ksymtab_gpl") == 0) |
| 591 | info->export_gpl_sec = i; | 580 | info->export_gpl_sec = i; |
| 592 | else if (strcmp(secname, "__ksymtab_unused_gpl") == 0) | | |
| 593 | info->export_unused_gpl_sec = i; | | |
| 594 | | 581 | |
| 595 | if (sechdrs[i].sh_type == SHT_SYMTAB) { | 582 | if (sechdrs[i].sh_type == SHT_SYMTAB) { |
| 596 | unsigned int sh_link_idx; | 583 | unsigned int sh_link_idx; |
| @@ -2141,32 +2128,13 @@ static void check_for_gpl_usage(enum export exp, const char *m, const char *s) · 1544 unmodified lines |
| 2141 | error("GPL-incompatible module %s.ko uses GPL-only symbol '%s'\n", | 2128 | error("GPL-incompatible module %s.ko uses GPL-only symbol '%s'\n", |
| 2142 | m, s); | 2129 | m, s); |
| 2143 | break; | 2130 | break; |
| 2144 | case export_unused_gpl: | | |
| 2145 | error("GPL-incompatible module %s.ko uses GPL-only symbol marked UNUSED '%s'\n", | | |
| 2146 | m, s); | | |
| 2147 | break; | | |
| 2148 | case export_plain: | 2131 | case export_plain: |
| 2149 | case export_unused: | | |
| 2150 | case export_unknown: | 2132 | case export_unknown: |
| 2151 | /* ignore */ | 2133 | /* ignore */ |
| 2152 | break; | 2134 | break; |
| 2153 | } | 2135 | } |
| 2154 | } | 2136 | } |
| 2155 | | 2137 | |
| 2156 | static void check_for_unused(enum export exp, const char *m, const char *s) | | |
| 2157 | { | | |
| 2158 | switch (exp) { | | |
| 2159 | case export_unused: | | |
| 2160 | case export_unused_gpl: | | |
| 2161 | warn("module %s.ko uses symbol '%s' marked UNUSED\n", | | |
| 2162 | m, s); | | |
| 2163 | break; | | |
| 2164 | default: | | |
| 2165 | /* ignore */ | | |
| 2166 | break; | | |
| 2167 | } | | |
| 2168 | } | | |
| 2169 | | | |
| 2170 | static void check_exports(struct module *mod) | 2138 | static void check_exports(struct module *mod) |
| 2171 | { | 2139 | { |
| 2172 | struct symbol *s, *exp; | 2140 | struct symbol *s, *exp; |
| @@ -2197,7 +2165,6 @@ static void check_exports(struct module *mod) · 24 unmodified lines |
| 2197 | | 2165 | |
| 2198 | if (!mod->gpl_compatible) | 2166 | if (!mod->gpl_compatible) |
| 2199 | check_for_gpl_usage(exp->export, basename, exp->name); | 2167 | check_for_gpl_usage(exp->export, basename, exp->name); |
| 2200 | check_for_unused(exp->export, basename, exp->name); | | |
| 2201 | } | 2168 | } |
| 2202 | } | 2169 | } |
| 2203 | | 2170 | |