History

Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild

* git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild: kbuild: documentation change on allowing checkers besides sparse kbuild: warn when a moduled uses a symbol marked UNUSED kbuild: fix segv in modpost kconfig: enhancing accessibility of lxdialog kbuild: fix ia64 breakage after introducing make -rR

Linus Torvalds committed 20 years ago

Commit b4bc7b52 parents 0cadaf4 701842e10 files · +96 −42Browse files

Showing the changes to scripts (8 of 10 files). Show all

Unified · Split

8 files
  1. scripts/Kbuild.include +4 −0
  2. scripts/Makefile.build +1 −1
  3. scripts/Makefile.host +4 −2
  4. scripts/Makefile.lib +3 −3
  5. scripts/Makefile.modpost +1 −1
  6. scripts/kconfig/lxdialog/checklist.c +5 −2
  7. scripts/mod/modpost.c +68 −26
  8. scripts/mod/modpost.h +2 −0
scripts/Kbuild.include+4−0
@@ -12,6 +12,10 @@ space := $(empty) $(empty) · 11 unmodified lines
1212 # contain a comma
1313 depfile = $(subst $(comma),_,$(@D)/.$(@F).d)
1414
15+###
16+# filename of target with directory and extension stripped
17+basetarget = $(basename $(notdir $@))
18+
1519 ###
1620 # Escape single quote for use in echo statements
1721 escsq = $(subst $(squote),'\$(squote)',$1)
scripts/Makefile.build+1−1
@@ -117,7 +117,7 @@ $(real-objs-m:.o=.lst): quiet_modtag := [M] · 116 unmodified lines
117117 $(obj-m) : quiet_modtag := [M]
118118
119119 # Default for not multi-part modules
120−modname = $(*F)
120+modname = $(basetarget)
121121
122122 $(multi-objs-m) : modname = $(modname-multi)
123123 $(multi-objs-m:.o=.i) : modname = $(modname-multi)
scripts/Makefile.host+4−2
@@ -80,8 +80,10 @@ obj-dirs += $(host-objdirs) · 79 unmodified lines
8080 #####
8181 # Handle options to gcc. Support building with separate output directory
8282
83−_hostc_flags = $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS_$(*F).o)
84−_hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) $(HOSTCXXFLAGS_$(*F).o)
83+_hostc_flags = $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
84+ $(HOSTCFLAGS_$(basetarget).o)
85+_hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
86+ $(HOSTCXXFLAGS_$(basetarget).o)
8587
8688 ifeq ($(KBUILD_SRC),)
8789 __hostc_flags = $(_hostc_flags)
scripts/Makefile.lib+3−3
@@ -82,12 +82,12 @@ obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) · 81 unmodified lines
8282 # than one module. In that case KBUILD_MODNAME will be set to foo_bar,
8383 # where foo and bar are the name of the modules.
8484 name-fix = $(subst $(comma),_,$(subst -,_,$1))
85−basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(*F)))"
85+basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
8686 modname_flags = $(if $(filter 1,$(words $(modname))),\
8787 -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
8888
89−_c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o)
90−_a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o)
89+_c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(basetarget).o)
90+_a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
9191 _cpp_flags = $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CPPFLAGS_$(@F))
9292
9393 # If building the kernel in a separate objtree expand all occurrences
scripts/Makefile.modpost+1−1
@@ -72,7 +72,7 @@ $(modules:.ko=.mod.c): __modpost ; · 71 unmodified lines
7272 # Step 5), compile all *.mod.c files
7373
7474 # modname is set to make c_flags define KBUILD_MODNAME
75−modname = $(*F)
75+modname = $(notdir $(@:.mod.o=))
7676
7777 quiet_cmd_cc_o_c = CC $@
7878 cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \
scripts/kconfig/lxdialog/checklist.c+5−2
@@ -187,9 +187,12 @@ int dialog_checklist(const char *title, const char *prompt, int height, · 186 unmodified lines
187187
188188 /* Print the list */
189189 for (i = 0; i < max_choice; i++) {
190− print_item(list, items[(scroll + i) * 3 + 1],
191− status[i + scroll], i, i == choice);
190+ if (i != choice)
191+ print_item(list, items[(scroll + i) * 3 + 1],
192+ status[i + scroll], i, 0);
192193 }
194+ print_item(list, items[(scroll + choice) * 3 + 1],
195+ status[choice + scroll], choice, 1);
193196
194197 print_arrows(dialog, choice, item_no, scroll,
195198 box_y, box_x + check_x + 5, list_height);
scripts/mod/modpost.c+68−26
@@ -24,7 +24,10 @@ static int all_versions = 0; · 23 unmodified lines
2424 /* If we are modposting external module set to 1 */
2525 static int external_module = 0;
2626 /* How a symbol is exported */
27−enum export {export_plain, export_gpl, export_gpl_future, export_unknown};
27+enum export {
28+ export_plain, export_unused, export_gpl,
29+ export_unused_gpl, export_gpl_future, export_unknown
30+};
2831
2932 void fatal(const char *fmt, ...)
3033 {
@@ -191,7 +194,9 @@ static struct { · 160 unmodified lines
191194 enum export export;
192195 } export_list[] = {
193196 { .str = "EXPORT_SYMBOL", .export = export_plain },
197+ { .str = "EXPORT_UNUSED_SYMBOL", .export = export_unused },
194198 { .str = "EXPORT_SYMBOL_GPL", .export = export_gpl },
199+ { .str = "EXPORT_UNUSED_SYMBOL_GPL", .export = export_unused_gpl },
195200 { .str = "EXPORT_SYMBOL_GPL_FUTURE", .export = export_gpl_future },
196201 { .str = "(unknown)", .export = export_unknown },
197202 };
@@ -205,6 +210,8 @@ static const char *export_str(enum export ex) · 7 unmodified lines
205210 static enum export export_no(const char * s)
206211 {
207212 int i;
213+ if (!s)
214+ return export_unknown;
208215 for (i = 0; export_list[i].export != export_unknown; i++) {
209216 if (strcmp(export_list[i].str, s) == 0)
210217 return export_list[i].export;
@@ -216,8 +223,12 @@ static enum export export_from_sec(struct elf_info *elf, Elf_Section sec) · 5 unmodified lines
216223 {
217224 if (sec == elf->export_sec)
218225 return export_plain;
226+ else if (sec == elf->export_unused_sec)
227+ return export_unused;
219228 else if (sec == elf->export_gpl_sec)
220229 return export_gpl;
230+ else if (sec == elf->export_unused_gpl_sec)
231+ return export_unused_gpl;
221232 else if (sec == elf->export_gpl_future_sec)
222233 return export_gpl_future;
223234 else
@@ -366,8 +377,12 @@ static void parse_elf(struct elf_info *info, const char *filename) · 142 unmodified lines
366377 info->modinfo_len = sechdrs[i].sh_size;
367378 } else if (strcmp(secname, "__ksymtab") == 0)
368379 info->export_sec = i;
380+ else if (strcmp(secname, "__ksymtab_unused") == 0)
381+ info->export_unused_sec = i;
369382 else if (strcmp(secname, "__ksymtab_gpl") == 0)
370383 info->export_gpl_sec = i;
384+ else if (strcmp(secname, "__ksymtab_unused_gpl") == 0)
385+ info->export_unused_gpl_sec = i;
371386 else if (strcmp(secname, "__ksymtab_gpl_future") == 0)
372387 info->export_gpl_future_sec = i;
373388
@@ -1085,38 +1100,64 @@ void buf_write(struct buffer *buf, const char *s, int len) · 711 unmodified lines
10851100 buf->pos += len;
10861101 }
10871102
1088−void check_license(struct module *mod)
1103+static void check_for_gpl_usage(enum export exp, const char *m, const char *s)
1104+{
1105+ const char *e = is_vmlinux(m) ?"":".ko";
1106+
1107+ switch (exp) {
1108+ case export_gpl:
1109+ fatal("modpost: GPL-incompatible module %s%s "
1110+ "uses GPL-only symbol '%s'\n", m, e, s);
1111+ break;
1112+ case export_unused_gpl:
1113+ fatal("modpost: GPL-incompatible module %s%s "
1114+ "uses GPL-only symbol marked UNUSED '%s'\n", m, e, s);
1115+ break;
1116+ case export_gpl_future:
1117+ warn("modpost: GPL-incompatible module %s%s "
1118+ "uses future GPL-only symbol '%s'\n", m, e, s);
1119+ break;
1120+ case export_plain:
1121+ case export_unused:
1122+ case export_unknown:
1123+ /* ignore */
1124+ break;
1125+ }
1126+}
1127+
1128+static void check_for_unused(enum export exp, const char* m, const char* s)
1129+{
1130+ const char *e = is_vmlinux(m) ?"":".ko";
1131+
1132+ switch (exp) {
1133+ case export_unused:
1134+ case export_unused_gpl:
1135+ warn("modpost: module %s%s "
1136+ "uses symbol '%s' marked UNUSED\n", m, e, s);
1137+ break;
1138+ default:
1139+ /* ignore */
1140+ break;
1141+ }
1142+}
1143+
1144+static void check_exports(struct module *mod)
10891145 {
10901146 struct symbol *s, *exp;
10911147
10921148 for (s = mod->unres; s; s = s->next) {
10931149 const char *basename;
1094− if (mod->gpl_compatible == 1) {
1095− /* GPL-compatible modules may use all symbols */
1096− continue;
1097− }
10981150 exp = find_symbol(s->name);
10991151 if (!exp || exp->module == mod)
11001152 continue;
11011153 basename = strrchr(mod->name, '/');
11021154 if (basename)
11031155 basename++;
1104− switch (exp->export) {
1105− case export_gpl:
1106− fatal("modpost: GPL-incompatible module %s "
1107− "uses GPL-only symbol '%s'\n",
1108− basename ? basename : mod->name,
1109− exp->name);
1110− break;
1111− case export_gpl_future:
1112− warn("modpost: GPL-incompatible module %s "
1113− "uses future GPL-only symbol '%s'\n",
1114− basename ? basename : mod->name,
1115− exp->name);
1116− break;
1117− case export_plain: /* ignore */ break;
1118− case export_unknown: /* ignore */ break;
1119− }
1156+ else
1157+ basename = mod->name;
1158+ if (!mod->gpl_compatible)
1159+ check_for_gpl_usage(exp->export, basename, exp->name);
1160+ check_for_unused(exp->export, basename, exp->name);
11201161 }
11211162 }
11221163
@@ -1271,7 +1312,7 @@ static void write_if_changed(struct buffer *b, const char *fname) · 148 unmodified lines
12711312 }
12721313
12731314 /* parse Module.symvers file. line format:
1274− * 0x12345678<tab>symbol<tab>module[<tab>export]
1315+ * 0x12345678<tab>symbol<tab>module[[<tab>export]<tab>something]
12751316 **/
12761317 static void read_dump(const char *fname, unsigned int kernel)
12771318 {
@@ -1284,7 +1325,7 @@ static void read_dump(const char *fname, unsigned int kernel) · 6 unmodified lines
12841325 return;
12851326
12861327 while ((line = get_next_line(&pos, file, size))) {
1287− char *symname, *modname, *d, *export;
1328+ char *symname, *modname, *d, *export, *end;
12881329 unsigned int crc;
12891330 struct module *mod;
12901331 struct symbol *s;
@@ -1297,7 +1338,8 @@ static void read_dump(const char *fname, unsigned int kernel) · 6 unmodified lines
12971338 *modname++ = '\0';
12981339 if ((export = strchr(modname, '\t')) != NULL)
12991340 *export++ = '\0';
1300−
1341+ if (export && ((end = strchr(export, '\t')) != NULL))
1342+ *end = '\0';
13011343 crc = strtoul(line, &d, 16);
13021344 if (*symname == '\0' || *modname == '\0' || *d != '\0')
13031345 goto fail;
@@ -1396,7 +1438,7 @@ int main(int argc, char **argv) · 92 unmodified lines
13961438 for (mod = modules; mod; mod = mod->next) {
13971439 if (mod->skip)
13981440 continue;
1399− check_license(mod);
1441+ check_exports(mod);
14001442 }
14011443
14021444 for (mod = modules; mod; mod = mod->next) {
scripts/mod/modpost.h+2−0
@@ -117,7 +117,9 @@ struct elf_info { · 116 unmodified lines
117117 Elf_Sym *symtab_start;
118118 Elf_Sym *symtab_stop;
119119 Elf_Section export_sec;
120+ Elf_Section export_unused_sec;
120121 Elf_Section export_gpl_sec;
122+ Elf_Section export_unused_gpl_sec;
121123 Elf_Section export_gpl_future_sec;
122124 const char *strtab;
123125 char *modinfo;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t