History

module: remove EXPORT_UNUSED_SYMBOL*

EXPORT_UNUSED_SYMBOL* is not actually used anywhere. Remove the unused functionality as we generally just remove unused code anyway.

Christoph Hellwig committed 5 years ago

Commit 36794821 parent f1c3d7324 files · +13 −193Browse files

Showing the changes to scripts (4 of 24 files). Show all

Unified · Split

4 files
  1. scripts/checkpatch.pl +2 −4
  2. scripts/mod/modpost.c +3 −36
  3. scripts/mod/modpost.h +0 −2
  4. scripts/module.lds.S +0 −4
scripts/checkpatch.pl+2−4
@@ -4290,8 +4290,7 @@ sub process { · 4289 unmodified lines
4290 if (defined $realline_next &&4290 if (defined $realline_next &&
4291 exists $lines[$realline_next - 1] &&4291 exists $lines[$realline_next - 1] &&
4292 !defined $suppress_export{$realline_next} &&4292 !defined $suppress_export{$realline_next} &&
4293 ($lines[$realline_next - 1] =~ /EXPORT_SYMBOL.*\((.*)\)/ ||4293 ($lines[$realline_next - 1] =~ /EXPORT_SYMBOL.*\((.*)\)/)) {
4294 $lines[$realline_next - 1] =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) {
4295 # Handle definitions which produce identifiers with4294 # Handle definitions which produce identifiers with
4296 # a prefix:4295 # a prefix:
4297 # XXX(foo);4296 # XXX(foo);
@@ -4318,8 +4317,7 @@ sub process { · 20 unmodified lines
4318 }4317 }
4319 if (!defined $suppress_export{$linenr} &&4318 if (!defined $suppress_export{$linenr} &&
4320 $prevline =~ /^.\s*$/ &&4319 $prevline =~ /^.\s*$/ &&
4321 ($line =~ /EXPORT_SYMBOL.*\((.*)\)/ ||4320 ($line =~ /EXPORT_SYMBOL.*\((.*)\)/)) {
4322 $line =~ /EXPORT_UNUSED_SYMBOL.*\((.*)\)/)) {
4323#print "FOO B <$lines[$linenr - 1]>\n";4321#print "FOO B <$lines[$linenr - 1]>\n";
4324 $suppress_export{$linenr} = 2;4322 $suppress_export{$linenr} = 2;
4325 }4323 }
scripts/mod/modpost.c+3−36
@@ -43,8 +43,9 @@ static int allow_missing_ns_imports; · 42 unmodified lines
43static bool error_occurred;43static bool error_occurred;
44 44
45enum export {45enum export {
46 export_plain, export_unused, export_gpl,46 export_plain,
47 export_unused_gpl, export_unknown47 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 else366 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 else376 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
2156static 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
2170static void check_exports(struct module *mod)2138static 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
scripts/mod/modpost.h+0−2
@@ -139,9 +139,7 @@ struct elf_info { · 138 unmodified lines
139 Elf_Sym *symtab_start;139 Elf_Sym *symtab_start;
140 Elf_Sym *symtab_stop;140 Elf_Sym *symtab_stop;
141 Elf_Section export_sec;141 Elf_Section export_sec;
142 Elf_Section export_unused_sec;
143 Elf_Section export_gpl_sec;142 Elf_Section export_gpl_sec;
144 Elf_Section export_unused_gpl_sec;
145 char *strtab;143 char *strtab;
146 char *modinfo;144 char *modinfo;
147 unsigned int modinfo_len;145 unsigned int modinfo_len;
scripts/module.lds.S+0−4
@@ -11,12 +11,8 @@ SECTIONS { · 10 unmodified lines
11 11
12 __ksymtab 0 : { *(SORT(___ksymtab+*)) }12 __ksymtab 0 : { *(SORT(___ksymtab+*)) }
13 __ksymtab_gpl 0 : { *(SORT(___ksymtab_gpl+*)) }13 __ksymtab_gpl 0 : { *(SORT(___ksymtab_gpl+*)) }
14 __ksymtab_unused 0 : { *(SORT(___ksymtab_unused+*)) }
15 __ksymtab_unused_gpl 0 : { *(SORT(___ksymtab_unused_gpl+*)) }
16 __kcrctab 0 : { *(SORT(___kcrctab+*)) }14 __kcrctab 0 : { *(SORT(___kcrctab+*)) }
17 __kcrctab_gpl 0 : { *(SORT(___kcrctab_gpl+*)) }15 __kcrctab_gpl 0 : { *(SORT(___kcrctab_gpl+*)) }
18 __kcrctab_unused 0 : { *(SORT(___kcrctab_unused+*)) }
19 __kcrctab_unused_gpl 0 : { *(SORT(___kcrctab_unused_gpl+*)) }
20 16
21 .init_array 0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) }17 .init_array 0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) }
22 18