diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Kbuild.include | 4 | ||||
-rw-r--r-- | scripts/Makefile.build | 2 | ||||
-rw-r--r-- | scripts/Makefile.headersinst | 158 | ||||
-rw-r--r-- | scripts/Makefile.host | 6 | ||||
-rw-r--r-- | scripts/Makefile.lib | 6 | ||||
-rw-r--r-- | scripts/Makefile.modpost | 2 | ||||
-rwxr-xr-x | scripts/checkversion.pl | 7 | ||||
-rwxr-xr-x | scripts/hdrcheck.sh | 8 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/checklist.c | 7 | ||||
-rwxr-xr-x | scripts/kernel-doc | 13 | ||||
-rw-r--r-- | scripts/mod/modpost.c | 94 | ||||
-rw-r--r-- | scripts/mod/modpost.h | 2 |
12 files changed, 266 insertions, 43 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index b0d067be73..2180c88cfe 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include | |||
@@ -13,6 +13,10 @@ space := $(empty) $(empty) | |||
13 | depfile = $(subst $(comma),_,$(@D)/.$(@F).d) | 13 | depfile = $(subst $(comma),_,$(@D)/.$(@F).d) |
14 | 14 | ||
15 | ### | 15 | ### |
16 | # filename of target with directory and extension stripped | ||
17 | basetarget = $(basename $(notdir $@)) | ||
18 | |||
19 | ### | ||
16 | # Escape single quote for use in echo statements | 20 | # Escape single quote for use in echo statements |
17 | escsq = $(subst $(squote),'\$(squote)',$1) | 21 | escsq = $(subst $(squote),'\$(squote)',$1) |
18 | 22 | ||
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 02a7eea5fd..3cb445cc74 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
@@ -117,7 +117,7 @@ $(real-objs-m:.o=.lst): quiet_modtag := [M] | |||
117 | $(obj-m) : quiet_modtag := [M] | 117 | $(obj-m) : quiet_modtag := [M] |
118 | 118 | ||
119 | # Default for not multi-part modules | 119 | # Default for not multi-part modules |
120 | modname = $(*F) | 120 | modname = $(basetarget) |
121 | 121 | ||
122 | $(multi-objs-m) : modname = $(modname-multi) | 122 | $(multi-objs-m) : modname = $(modname-multi) |
123 | $(multi-objs-m:.o=.i) : modname = $(modname-multi) | 123 | $(multi-objs-m:.o=.i) : modname = $(modname-multi) |
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst new file mode 100644 index 0000000000..aa9990a3cc --- /dev/null +++ b/scripts/Makefile.headersinst | |||
@@ -0,0 +1,158 @@ | |||
1 | # ========================================================================== | ||
2 | # Installing headers | ||
3 | # | ||
4 | # header-y files will be installed verbatim | ||
5 | # unifdef-y are the files where unifdef will be run before installing files | ||
6 | # objhdr-y are generated files that will be installed verbatim | ||
7 | # | ||
8 | # ========================================================================== | ||
9 | |||
10 | UNIFDEF := unifdef -U__KERNEL__ | ||
11 | |||
12 | # Eliminate the contents of (and inclusions of) compiler.h | ||
13 | HDRSED := sed -e "s/ inline / __inline__ /g" \ | ||
14 | -e "s/[[:space:]]__user[[:space:]]\+/ /g" \ | ||
15 | -e "s/(__user[[:space:]]\+/ (/g" \ | ||
16 | -e "s/[[:space:]]__force[[:space:]]\+/ /g" \ | ||
17 | -e "s/(__force[[:space:]]\+/ (/g" \ | ||
18 | -e "s/[[:space:]]__iomem[[:space:]]\+/ /g" \ | ||
19 | -e "s/(__iomem[[:space:]]\+/ (/g" \ | ||
20 | -e "s/[[:space:]]__attribute_const__[[:space:]]\+/\ /g" \ | ||
21 | -e "s/[[:space:]]__attribute_const__$$//" \ | ||
22 | -e "/^\#include <linux\/compiler.h>/d" | ||
23 | |||
24 | _dst := $(if $(dst),$(dst),$(obj)) | ||
25 | |||
26 | .PHONY: __headersinst | ||
27 | __headersinst: | ||
28 | |||
29 | |||
30 | ifeq (,$(patsubst include/asm/%,,$(obj)/)) | ||
31 | # For producing the generated stuff in include/asm for biarch builds, include | ||
32 | # both sets of Kbuild files; we'll generate anything which is mentioned in | ||
33 | # _either_ arch, and recurse into subdirectories which are mentioned in either | ||
34 | # arch. Since some directories may exist in one but not the other, we must | ||
35 | # use '-include'. | ||
36 | GENASM := 1 | ||
37 | archasm := $(subst include/asm,asm-$(ARCH),$(obj)) | ||
38 | altarchasm := $(subst include/asm,asm-$(ALTARCH),$(obj)) | ||
39 | -include $(srctree)/include/$(archasm)/Kbuild | ||
40 | -include $(srctree)/include/$(altarchasm)/Kbuild | ||
41 | else | ||
42 | include $(srctree)/$(obj)/Kbuild | ||
43 | endif | ||
44 | |||
45 | include scripts/Kbuild.include | ||
46 | |||
47 | # If this is include/asm-$(ARCH) and there's no $(ALTARCH), then | ||
48 | # override $(_dst) so that we install to include/asm directly. | ||
49 | ifeq ($(obj)$(ALTARCH),include/asm-$(ARCH)) | ||
50 | _dst := include/asm | ||
51 | endif | ||
52 | |||
53 | header-y := $(sort $(header-y)) | ||
54 | unifdef-y := $(sort $(unifdef-y)) | ||
55 | subdir-y := $(patsubst %/,%,$(filter %/, $(header-y))) | ||
56 | header-y := $(filter-out %/, $(header-y)) | ||
57 | header-y := $(filter-out $(unifdef-y),$(header-y)) | ||
58 | |||
59 | ifdef ALTARCH | ||
60 | ifeq ($(obj),include/asm-$(ARCH)) | ||
61 | altarch-y := altarch-dir | ||
62 | endif | ||
63 | endif | ||
64 | |||
65 | # Make the definitions visible for recursive make invocations | ||
66 | export ALTARCH | ||
67 | export ARCHDEF | ||
68 | export ALTARCHDEF | ||
69 | |||
70 | quiet_cmd_o_hdr_install = INSTALL $(_dst)/$@ | ||
71 | cmd_o_hdr_install = cp $(objtree)/$(obj)/$@ $(INSTALL_HDR_PATH)/$(_dst) | ||
72 | |||
73 | quiet_cmd_headers_install = INSTALL $(_dst)/$@ | ||
74 | cmd_headers_install = $(HDRSED) $(srctree)/$(obj)/$@ \ | ||
75 | > $(INSTALL_HDR_PATH)/$(_dst)/$@ | ||
76 | |||
77 | quiet_cmd_unifdef = UNIFDEF $(_dst)/$@ | ||
78 | cmd_unifdef = $(UNIFDEF) $(srctree)/$(obj)/$@ | $(HDRSED) \ | ||
79 | > $(INSTALL_HDR_PATH)/$(_dst)/$@ || : | ||
80 | |||
81 | quiet_cmd_check = CHECK $(_dst)/$@ | ||
82 | cmd_check = $(srctree)/scripts/hdrcheck.sh \ | ||
83 | $(INSTALL_HDR_PATH)/include \ | ||
84 | $(INSTALL_HDR_PATH)/$(_dst)/$@ | ||
85 | |||
86 | quiet_cmd_mkdir = MKDIR $@ | ||
87 | cmd_mkdir = mkdir -p $(INSTALL_HDR_PATH)/$@ | ||
88 | |||
89 | quiet_cmd_gen = GEN $(_dst)/$@ | ||
90 | cmd_gen = \ | ||
91 | STUBDEF=__ASM_STUB_`echo $@ | tr a-z. A-Z_`; \ | ||
92 | (echo "/* File autogenerated by 'make headers_install' */" ; \ | ||
93 | echo "\#ifndef $$STUBDEF" ; \ | ||
94 | echo "\#define $$STUBDEF" ; \ | ||
95 | echo "\# if $(ARCHDEF)" ; \ | ||
96 | if [ -r $(srctree)/include/$(archasm)/$@ ]; then \ | ||
97 | echo "\# include <$(archasm)/$@>" ; \ | ||
98 | else \ | ||
99 | echo "\# error $(archasm)/$@ does not exist in" \ | ||
100 | "the $(ARCH) architecture" ; \ | ||
101 | fi ; \ | ||
102 | echo "\# elif $(ALTARCHDEF)" ; \ | ||
103 | if [ -r $(srctree)/include/$(altarchasm)/$@ ]; then \ | ||
104 | echo "\# include <$(altarchasm)/$@>" ; \ | ||
105 | else \ | ||
106 | echo "\# error $(altarchasm)/$@ does not exist in" \ | ||
107 | "the $(ALTARCH) architecture" ; \ | ||
108 | fi ; \ | ||
109 | echo "\# else" ; \ | ||
110 | echo "\# warning This machine appears to be" \ | ||
111 | "neither $(ARCH) nor $(ALTARCH)." ; \ | ||
112 | echo "\# endif" ; \ | ||
113 | echo "\#endif /* $$STUBDEF */" ; \ | ||
114 | ) > $(INSTALL_HDR_PATH)/$(_dst)/$@ | ||
115 | |||
116 | __headersinst: $(subdir-y) $(header-y) $(unifdef-y) $(altarch-y) $(objhdr-y) | ||
117 | |||
118 | .PHONY: $(header-y) $(unifdef-y) $(subdir-y) | ||
119 | |||
120 | ifdef HDRCHECK | ||
121 | # Rules for checking headers | ||
122 | $(objhdr-y) $(header-y) $(unifdef-y): | ||
123 | $(call cmd,check) | ||
124 | else | ||
125 | # Rules for installing headers | ||
126 | |||
127 | $(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y): $(_dst) | ||
128 | |||
129 | .PHONY: $(_dst) | ||
130 | $(_dst): | ||
131 | $(call cmd,mkdir) | ||
132 | |||
133 | ifdef GENASM | ||
134 | $(objhdr-y) $(header-y) $(unifdef-y): | ||
135 | $(call cmd,gen) | ||
136 | |||
137 | else | ||
138 | $(objhdr-y): | ||
139 | $(call cmd,o_hdr_install) | ||
140 | |||
141 | $(header-y): | ||
142 | $(call cmd,headers_install) | ||
143 | |||
144 | $(unifdef-y): | ||
145 | $(call cmd,unifdef) | ||
146 | endif | ||
147 | endif | ||
148 | |||
149 | hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj | ||
150 | |||
151 | .PHONY: altarch-dir | ||
152 | altarch-dir: | ||
153 | $(Q)$(MAKE) $(hdrinst)=include/asm-$(ALTARCH) dst=include/asm-$(ALTARCH) | ||
154 | $(Q)$(MAKE) $(hdrinst)=include/asm dst=include/asm | ||
155 | |||
156 | # Recursion | ||
157 | $(subdir-y): | ||
158 | $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel) | ||
diff --git a/scripts/Makefile.host b/scripts/Makefile.host index 2b066d12af..18ecd4d5df 100644 --- a/scripts/Makefile.host +++ b/scripts/Makefile.host | |||
@@ -80,8 +80,10 @@ obj-dirs += $(host-objdirs) | |||
80 | ##### | 80 | ##### |
81 | # Handle options to gcc. Support building with separate output directory | 81 | # Handle options to gcc. Support building with separate output directory |
82 | 82 | ||
83 | _hostc_flags = $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS_$(*F).o) | 83 | _hostc_flags = $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \ |
84 | _hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) $(HOSTCXXFLAGS_$(*F).o) | 84 | $(HOSTCFLAGS_$(basetarget).o) |
85 | _hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ | ||
86 | $(HOSTCXXFLAGS_$(basetarget).o) | ||
85 | 87 | ||
86 | ifeq ($(KBUILD_SRC),) | 88 | ifeq ($(KBUILD_SRC),) |
87 | __hostc_flags = $(_hostc_flags) | 89 | __hostc_flags = $(_hostc_flags) |
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 2cb4935e85..fc498fee68 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
@@ -82,12 +82,12 @@ obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) | |||
82 | # than one module. In that case KBUILD_MODNAME will be set to foo_bar, | 82 | # than one module. In that case KBUILD_MODNAME will be set to foo_bar, |
83 | # where foo and bar are the name of the modules. | 83 | # where foo and bar are the name of the modules. |
84 | name-fix = $(subst $(comma),_,$(subst -,_,$1)) | 84 | 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)))" |
86 | modname_flags = $(if $(filter 1,$(words $(modname))),\ | 86 | modname_flags = $(if $(filter 1,$(words $(modname))),\ |
87 | -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") | 87 | -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") |
88 | 88 | ||
89 | _c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) | 89 | _c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(basetarget).o) |
90 | _a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o) | 90 | _a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o) |
91 | _cpp_flags = $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CPPFLAGS_$(@F)) | 91 | _cpp_flags = $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CPPFLAGS_$(@F)) |
92 | 92 | ||
93 | # If building the kernel in a separate objtree expand all occurrences | 93 | # If building the kernel in a separate objtree expand all occurrences |
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 576cce5e38..a49550205d 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost | |||
@@ -72,7 +72,7 @@ $(modules:.ko=.mod.c): __modpost ; | |||
72 | # Step 5), compile all *.mod.c files | 72 | # Step 5), compile all *.mod.c files |
73 | 73 | ||
74 | # modname is set to make c_flags define KBUILD_MODNAME | 74 | # modname is set to make c_flags define KBUILD_MODNAME |
75 | modname = $(*F) | 75 | modname = $(notdir $(@:.mod.o=)) |
76 | 76 | ||
77 | quiet_cmd_cc_o_c = CC $@ | 77 | quiet_cmd_cc_o_c = CC $@ |
78 | cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \ | 78 | cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \ |
diff --git a/scripts/checkversion.pl b/scripts/checkversion.pl index 9f84e56231..ec7d21161b 100755 --- a/scripts/checkversion.pl +++ b/scripts/checkversion.pl | |||
@@ -1,7 +1,7 @@ | |||
1 | #! /usr/bin/perl | 1 | #! /usr/bin/perl |
2 | # | 2 | # |
3 | # checkversion find uses of LINUX_VERSION_CODE, KERNEL_VERSION, or | 3 | # checkversion find uses of LINUX_VERSION_CODE or KERNEL_VERSION |
4 | # UTS_RELEASE without including <linux/version.h>, or cases of | 4 | # without including <linux/version.h>, or cases of |
5 | # including <linux/version.h> that don't need it. | 5 | # including <linux/version.h> that don't need it. |
6 | # Copyright (C) 2003, Randy Dunlap <rdunlap@xenotime.net> | 6 | # Copyright (C) 2003, Randy Dunlap <rdunlap@xenotime.net> |
7 | 7 | ||
@@ -41,8 +41,7 @@ foreach $file (@ARGV) | |||
41 | } | 41 | } |
42 | 42 | ||
43 | # Look for uses: LINUX_VERSION_CODE, KERNEL_VERSION, UTS_RELEASE | 43 | # Look for uses: LINUX_VERSION_CODE, KERNEL_VERSION, UTS_RELEASE |
44 | if (($_ =~ /LINUX_VERSION_CODE/) || ($_ =~ /\WKERNEL_VERSION/) || | 44 | if (($_ =~ /LINUX_VERSION_CODE/) || ($_ =~ /\WKERNEL_VERSION/)) { |
45 | ($_ =~ /UTS_RELEASE/)) { | ||
46 | $fUseVersion = 1; | 45 | $fUseVersion = 1; |
47 | last LINE if $iLinuxVersion; | 46 | last LINE if $iLinuxVersion; |
48 | } | 47 | } |
diff --git a/scripts/hdrcheck.sh b/scripts/hdrcheck.sh new file mode 100755 index 0000000000..b3bb683b56 --- /dev/null +++ b/scripts/hdrcheck.sh | |||
@@ -0,0 +1,8 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | for FILE in `grep '^#include <' $2 | cut -f2 -d\< | cut -f1 -d\> | egrep ^linux\|^asm` ; do | ||
4 | if [ ! -r $1/$FILE ]; then | ||
5 | echo $2 requires $FILE, which does not exist | ||
6 | exit 1 | ||
7 | fi | ||
8 | done | ||
diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c index be0200e9cd..79886413b6 100644 --- a/scripts/kconfig/lxdialog/checklist.c +++ b/scripts/kconfig/lxdialog/checklist.c | |||
@@ -187,9 +187,12 @@ int dialog_checklist(const char *title, const char *prompt, int height, | |||
187 | 187 | ||
188 | /* Print the list */ | 188 | /* Print the list */ |
189 | for (i = 0; i < max_choice; i++) { | 189 | for (i = 0; i < max_choice; i++) { |
190 | print_item(list, items[(scroll + i) * 3 + 1], | 190 | if (i != choice) |
191 | status[i + scroll], i, i == choice); | 191 | print_item(list, items[(scroll + i) * 3 + 1], |
192 | status[i + scroll], i, 0); | ||
192 | } | 193 | } |
194 | print_item(list, items[(scroll + choice) * 3 + 1], | ||
195 | status[choice + scroll], choice, 1); | ||
193 | 196 | ||
194 | print_arrows(dialog, choice, item_no, scroll, | 197 | print_arrows(dialog, choice, item_no, scroll, |
195 | box_y, box_x + check_x + 5, list_height); | 198 | box_y, box_x + check_x + 5, list_height); |
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 00e21297ae..f9460a6218 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc | |||
@@ -1056,7 +1056,8 @@ sub output_struct_man(%) { | |||
1056 | # pointer-to-function | 1056 | # pointer-to-function |
1057 | print ".BI \" ".$1."\" ".$parameter." \") (".$2.")"."\"\n;\n"; | 1057 | print ".BI \" ".$1."\" ".$parameter." \") (".$2.")"."\"\n;\n"; |
1058 | } elsif ($type =~ m/^(.*?)\s*(:.*)/) { | 1058 | } elsif ($type =~ m/^(.*?)\s*(:.*)/) { |
1059 | print ".BI \" ".$1."\" ".$parameter.$2." \""."\"\n;\n"; | 1059 | # bitfield |
1060 | print ".BI \" ".$1."\ \" ".$parameter.$2." \""."\"\n;\n"; | ||
1060 | } else { | 1061 | } else { |
1061 | $type =~ s/([^\*])$/$1 /; | 1062 | $type =~ s/([^\*])$/$1 /; |
1062 | print ".BI \" ".$type."\" ".$parameter." \""."\"\n;\n"; | 1063 | print ".BI \" ".$type."\" ".$parameter." \""."\"\n;\n"; |
@@ -1118,7 +1119,10 @@ sub output_function_text(%) { | |||
1118 | my %args = %{$_[0]}; | 1119 | my %args = %{$_[0]}; |
1119 | my ($parameter, $section); | 1120 | my ($parameter, $section); |
1120 | 1121 | ||
1121 | print "Function:\n\n"; | 1122 | print "Name:\n\n"; |
1123 | print $args{'function'}." - ".$args{'purpose'}."\n"; | ||
1124 | |||
1125 | print "\nSynopsis:\n\n"; | ||
1122 | my $start=$args{'functiontype'}." ".$args{'function'}." ("; | 1126 | my $start=$args{'functiontype'}." ".$args{'function'}." ("; |
1123 | print $start; | 1127 | print $start; |
1124 | my $count = 0; | 1128 | my $count = 0; |
@@ -1169,6 +1173,7 @@ sub output_enum_text(%) { | |||
1169 | my $count; | 1173 | my $count; |
1170 | print "Enum:\n\n"; | 1174 | print "Enum:\n\n"; |
1171 | 1175 | ||
1176 | print "enum ".$args{'enum'}." - ".$args{'purpose'}."\n\n"; | ||
1172 | print "enum ".$args{'enum'}." {\n"; | 1177 | print "enum ".$args{'enum'}." {\n"; |
1173 | $count = 0; | 1178 | $count = 0; |
1174 | foreach $parameter (@{$args{'parameterlist'}}) { | 1179 | foreach $parameter (@{$args{'parameterlist'}}) { |
@@ -1197,7 +1202,7 @@ sub output_typedef_text(%) { | |||
1197 | my $count; | 1202 | my $count; |
1198 | print "Typedef:\n\n"; | 1203 | print "Typedef:\n\n"; |
1199 | 1204 | ||
1200 | print "typedef ".$args{'typedef'}."\n"; | 1205 | print "typedef ".$args{'typedef'}." - ".$args{'purpose'}."\n"; |
1201 | output_section_text(@_); | 1206 | output_section_text(@_); |
1202 | } | 1207 | } |
1203 | 1208 | ||
@@ -1206,7 +1211,7 @@ sub output_struct_text(%) { | |||
1206 | my %args = %{$_[0]}; | 1211 | my %args = %{$_[0]}; |
1207 | my ($parameter); | 1212 | my ($parameter); |
1208 | 1213 | ||
1209 | print $args{'type'}." ".$args{'struct'}.":\n\n"; | 1214 | print $args{'type'}." ".$args{'struct'}." - ".$args{'purpose'}."\n\n"; |
1210 | print $args{'type'}." ".$args{'struct'}." {\n"; | 1215 | print $args{'type'}." ".$args{'struct'}." {\n"; |
1211 | foreach $parameter (@{$args{'parameterlist'}}) { | 1216 | foreach $parameter (@{$args{'parameterlist'}}) { |
1212 | if ($parameter =~ /^#/) { | 1217 | if ($parameter =~ /^#/) { |
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 0dd1617764..dfde0e87a7 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -24,7 +24,10 @@ 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 | /* How a symbol is exported */ | 26 | /* 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 | }; | ||
28 | 31 | ||
29 | void fatal(const char *fmt, ...) | 32 | void fatal(const char *fmt, ...) |
30 | { | 33 | { |
@@ -191,7 +194,9 @@ static struct { | |||
191 | enum export export; | 194 | enum export export; |
192 | } export_list[] = { | 195 | } export_list[] = { |
193 | { .str = "EXPORT_SYMBOL", .export = export_plain }, | 196 | { .str = "EXPORT_SYMBOL", .export = export_plain }, |
197 | { .str = "EXPORT_UNUSED_SYMBOL", .export = export_unused }, | ||
194 | { .str = "EXPORT_SYMBOL_GPL", .export = export_gpl }, | 198 | { .str = "EXPORT_SYMBOL_GPL", .export = export_gpl }, |
199 | { .str = "EXPORT_UNUSED_SYMBOL_GPL", .export = export_unused_gpl }, | ||
195 | { .str = "EXPORT_SYMBOL_GPL_FUTURE", .export = export_gpl_future }, | 200 | { .str = "EXPORT_SYMBOL_GPL_FUTURE", .export = export_gpl_future }, |
196 | { .str = "(unknown)", .export = export_unknown }, | 201 | { .str = "(unknown)", .export = export_unknown }, |
197 | }; | 202 | }; |
@@ -205,6 +210,8 @@ static const char *export_str(enum export ex) | |||
205 | static enum export export_no(const char * s) | 210 | static enum export export_no(const char * s) |
206 | { | 211 | { |
207 | int i; | 212 | int i; |
213 | if (!s) | ||
214 | return export_unknown; | ||
208 | for (i = 0; export_list[i].export != export_unknown; i++) { | 215 | for (i = 0; export_list[i].export != export_unknown; i++) { |
209 | if (strcmp(export_list[i].str, s) == 0) | 216 | if (strcmp(export_list[i].str, s) == 0) |
210 | return export_list[i].export; | 217 | return export_list[i].export; |
@@ -216,8 +223,12 @@ static enum export export_from_sec(struct elf_info *elf, Elf_Section sec) | |||
216 | { | 223 | { |
217 | if (sec == elf->export_sec) | 224 | if (sec == elf->export_sec) |
218 | return export_plain; | 225 | return export_plain; |
226 | else if (sec == elf->export_unused_sec) | ||
227 | return export_unused; | ||
219 | else if (sec == elf->export_gpl_sec) | 228 | else if (sec == elf->export_gpl_sec) |
220 | return export_gpl; | 229 | return export_gpl; |
230 | else if (sec == elf->export_unused_gpl_sec) | ||
231 | return export_unused_gpl; | ||
221 | else if (sec == elf->export_gpl_future_sec) | 232 | else if (sec == elf->export_gpl_future_sec) |
222 | return export_gpl_future; | 233 | return export_gpl_future; |
223 | else | 234 | else |
@@ -366,8 +377,12 @@ static void parse_elf(struct elf_info *info, const char *filename) | |||
366 | info->modinfo_len = sechdrs[i].sh_size; | 377 | info->modinfo_len = sechdrs[i].sh_size; |
367 | } else if (strcmp(secname, "__ksymtab") == 0) | 378 | } else if (strcmp(secname, "__ksymtab") == 0) |
368 | info->export_sec = i; | 379 | info->export_sec = i; |
380 | else if (strcmp(secname, "__ksymtab_unused") == 0) | ||
381 | info->export_unused_sec = i; | ||
369 | else if (strcmp(secname, "__ksymtab_gpl") == 0) | 382 | else if (strcmp(secname, "__ksymtab_gpl") == 0) |
370 | info->export_gpl_sec = i; | 383 | info->export_gpl_sec = i; |
384 | else if (strcmp(secname, "__ksymtab_unused_gpl") == 0) | ||
385 | info->export_unused_gpl_sec = i; | ||
371 | else if (strcmp(secname, "__ksymtab_gpl_future") == 0) | 386 | else if (strcmp(secname, "__ksymtab_gpl_future") == 0) |
372 | info->export_gpl_future_sec = i; | 387 | info->export_gpl_future_sec = i; |
373 | 388 | ||
@@ -1085,38 +1100,64 @@ void buf_write(struct buffer *buf, const char *s, int len) | |||
1085 | buf->pos += len; | 1100 | buf->pos += len; |
1086 | } | 1101 | } |
1087 | 1102 | ||
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) | ||
1089 | { | 1145 | { |
1090 | struct symbol *s, *exp; | 1146 | struct symbol *s, *exp; |
1091 | 1147 | ||
1092 | for (s = mod->unres; s; s = s->next) { | 1148 | for (s = mod->unres; s; s = s->next) { |
1093 | const char *basename; | 1149 | const char *basename; |
1094 | if (mod->gpl_compatible == 1) { | ||
1095 | /* GPL-compatible modules may use all symbols */ | ||
1096 | continue; | ||
1097 | } | ||
1098 | exp = find_symbol(s->name); | 1150 | exp = find_symbol(s->name); |
1099 | if (!exp || exp->module == mod) | 1151 | if (!exp || exp->module == mod) |
1100 | continue; | 1152 | continue; |
1101 | basename = strrchr(mod->name, '/'); | 1153 | basename = strrchr(mod->name, '/'); |
1102 | if (basename) | 1154 | if (basename) |
1103 | basename++; | 1155 | basename++; |
1104 | switch (exp->export) { | 1156 | else |
1105 | case export_gpl: | 1157 | basename = mod->name; |
1106 | fatal("modpost: GPL-incompatible module %s " | 1158 | if (!mod->gpl_compatible) |
1107 | "uses GPL-only symbol '%s'\n", | 1159 | check_for_gpl_usage(exp->export, basename, exp->name); |
1108 | basename ? basename : mod->name, | 1160 | check_for_unused(exp->export, basename, exp->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 | } | ||
1120 | } | 1161 | } |
1121 | } | 1162 | } |
1122 | 1163 | ||
@@ -1271,7 +1312,7 @@ static void write_if_changed(struct buffer *b, const char *fname) | |||
1271 | } | 1312 | } |
1272 | 1313 | ||
1273 | /* parse Module.symvers file. line format: | 1314 | /* parse Module.symvers file. line format: |
1274 | * 0x12345678<tab>symbol<tab>module[<tab>export] | 1315 | * 0x12345678<tab>symbol<tab>module[[<tab>export]<tab>something] |
1275 | **/ | 1316 | **/ |
1276 | static void read_dump(const char *fname, unsigned int kernel) | 1317 | static void read_dump(const char *fname, unsigned int kernel) |
1277 | { | 1318 | { |
@@ -1284,7 +1325,7 @@ static void read_dump(const char *fname, unsigned int kernel) | |||
1284 | return; | 1325 | return; |
1285 | 1326 | ||
1286 | while ((line = get_next_line(&pos, file, size))) { | 1327 | while ((line = get_next_line(&pos, file, size))) { |
1287 | char *symname, *modname, *d, *export; | 1328 | char *symname, *modname, *d, *export, *end; |
1288 | unsigned int crc; | 1329 | unsigned int crc; |
1289 | struct module *mod; | 1330 | struct module *mod; |
1290 | struct symbol *s; | 1331 | struct symbol *s; |
@@ -1297,7 +1338,8 @@ static void read_dump(const char *fname, unsigned int kernel) | |||
1297 | *modname++ = '\0'; | 1338 | *modname++ = '\0'; |
1298 | if ((export = strchr(modname, '\t')) != NULL) | 1339 | if ((export = strchr(modname, '\t')) != NULL) |
1299 | *export++ = '\0'; | 1340 | *export++ = '\0'; |
1300 | 1341 | if (export && ((end = strchr(export, '\t')) != NULL)) | |
1342 | *end = '\0'; | ||
1301 | crc = strtoul(line, &d, 16); | 1343 | crc = strtoul(line, &d, 16); |
1302 | if (*symname == '\0' || *modname == '\0' || *d != '\0') | 1344 | if (*symname == '\0' || *modname == '\0' || *d != '\0') |
1303 | goto fail; | 1345 | goto fail; |
@@ -1396,7 +1438,7 @@ int main(int argc, char **argv) | |||
1396 | for (mod = modules; mod; mod = mod->next) { | 1438 | for (mod = modules; mod; mod = mod->next) { |
1397 | if (mod->skip) | 1439 | if (mod->skip) |
1398 | continue; | 1440 | continue; |
1399 | check_license(mod); | 1441 | check_exports(mod); |
1400 | } | 1442 | } |
1401 | 1443 | ||
1402 | for (mod = modules; mod; mod = mod->next) { | 1444 | for (mod = modules; mod; mod = mod->next) { |
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 2b00c60628..d398c61e55 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h | |||
@@ -117,7 +117,9 @@ struct elf_info { | |||
117 | Elf_Sym *symtab_start; | 117 | Elf_Sym *symtab_start; |
118 | Elf_Sym *symtab_stop; | 118 | Elf_Sym *symtab_stop; |
119 | Elf_Section export_sec; | 119 | Elf_Section export_sec; |
120 | Elf_Section export_unused_sec; | ||
120 | Elf_Section export_gpl_sec; | 121 | Elf_Section export_gpl_sec; |
122 | Elf_Section export_unused_gpl_sec; | ||
121 | Elf_Section export_gpl_future_sec; | 123 | Elf_Section export_gpl_future_sec; |
122 | const char *strtab; | 124 | const char *strtab; |
123 | char *modinfo; | 125 | char *modinfo; |