diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.build | 37 | ||||
-rw-r--r-- | scripts/Makefile.headersinst | 3 | ||||
-rw-r--r-- | scripts/Makefile.help | 3 | ||||
-rw-r--r-- | scripts/Makefile.modpost | 9 | ||||
-rwxr-xr-x | scripts/checkkconfigsymbols.sh | 2 | ||||
-rwxr-xr-x | scripts/checkpatch.pl | 42 | ||||
-rwxr-xr-x | scripts/checksyscalls.sh | 1 | ||||
-rwxr-xr-x | scripts/coccicheck | 80 | ||||
-rw-r--r-- | scripts/coccinelle/alloc/drop_kmalloc_cast.cocci | 67 | ||||
-rw-r--r-- | scripts/coccinelle/alloc/kzalloc-simple.cocci | 82 | ||||
-rw-r--r-- | scripts/coccinelle/deref_null.cocci | 293 | ||||
-rw-r--r-- | scripts/coccinelle/err_cast.cocci | 56 | ||||
-rw-r--r-- | scripts/coccinelle/resource_size.cocci | 93 | ||||
-rwxr-xr-x | scripts/decodecode | 10 | ||||
-rw-r--r-- | scripts/dtc/fstree.c | 1 | ||||
-rw-r--r-- | scripts/kconfig/.gitignore | 1 | ||||
-rw-r--r-- | scripts/kconfig/conf.c | 2 | ||||
-rwxr-xr-x | scripts/kernel-doc | 2 | ||||
-rw-r--r-- | scripts/mod/file2alias.c | 6 | ||||
-rw-r--r-- | scripts/mod/modpost.c | 175 | ||||
-rw-r--r-- | scripts/mod/modpost.h | 43 | ||||
-rw-r--r-- | scripts/package/Makefile | 37 | ||||
-rw-r--r-- | scripts/package/builddeb | 5 | ||||
-rwxr-xr-x | scripts/recordmcount.pl | 2 | ||||
-rwxr-xr-x | scripts/setlocalversion | 2 |
25 files changed, 963 insertions, 91 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index e4deb73e9a84..a1a5cf95a68d 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
@@ -115,7 +115,10 @@ endif | |||
115 | # --------------------------------------------------------------------------- | 115 | # --------------------------------------------------------------------------- |
116 | 116 | ||
117 | # Default is built-in, unless we know otherwise | 117 | # Default is built-in, unless we know otherwise |
118 | modkern_cflags = $(if $(part-of-module), $(CFLAGS_MODULE), $(CFLAGS_KERNEL)) | 118 | modkern_cflags = \ |
119 | $(if $(part-of-module), \ | ||
120 | $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \ | ||
121 | $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL)) | ||
119 | quiet_modtag := $(empty) $(empty) | 122 | quiet_modtag := $(empty) $(empty) |
120 | 123 | ||
121 | $(real-objs-m) : part-of-module := y | 124 | $(real-objs-m) : part-of-module := y |
@@ -156,14 +159,14 @@ $(obj)/%.i: $(src)/%.c FORCE | |||
156 | 159 | ||
157 | cmd_gensymtypes = \ | 160 | cmd_gensymtypes = \ |
158 | $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ | 161 | $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ |
159 | $(GENKSYMS) -T $@ -a $(ARCH) \ | 162 | $(GENKSYMS) $(if $(1), -T $(2)) -a $(ARCH) \ |
160 | $(if $(KBUILD_PRESERVE),-p) \ | 163 | $(if $(KBUILD_PRESERVE),-p) \ |
161 | $(if $(1),-r $(firstword $(wildcard $(@:.symtypes=.symref) /dev/null))) | 164 | -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) |
162 | 165 | ||
163 | quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ | 166 | quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ |
164 | cmd_cc_symtypes_c = \ | 167 | cmd_cc_symtypes_c = \ |
165 | set -e; \ | 168 | set -e; \ |
166 | $(call cmd_gensymtypes, true) >/dev/null; \ | 169 | $(call cmd_gensymtypes,true,$@) >/dev/null; \ |
167 | test -s $@ || rm -f $@ | 170 | test -s $@ || rm -f $@ |
168 | 171 | ||
169 | $(obj)/%.symtypes : $(src)/%.c FORCE | 172 | $(obj)/%.symtypes : $(src)/%.c FORCE |
@@ -192,16 +195,16 @@ else | |||
192 | # the actual value of the checksum generated by genksyms | 195 | # the actual value of the checksum generated by genksyms |
193 | 196 | ||
194 | cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< | 197 | cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< |
195 | cmd_modversions = \ | 198 | cmd_modversions = \ |
196 | if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ | 199 | if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ |
197 | $(call cmd_gensymtypes, $(KBUILD_SYMTYPES)) \ | 200 | $(call cmd_gensymtypes,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ |
198 | > $(@D)/.tmp_$(@F:.o=.ver); \ | 201 | > $(@D)/.tmp_$(@F:.o=.ver); \ |
199 | \ | 202 | \ |
200 | $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ | 203 | $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ |
201 | -T $(@D)/.tmp_$(@F:.o=.ver); \ | 204 | -T $(@D)/.tmp_$(@F:.o=.ver); \ |
202 | rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ | 205 | rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ |
203 | else \ | 206 | else \ |
204 | mv -f $(@D)/.tmp_$(@F) $@; \ | 207 | mv -f $(@D)/.tmp_$(@F) $@; \ |
205 | fi; | 208 | fi; |
206 | endif | 209 | endif |
207 | 210 | ||
@@ -248,10 +251,10 @@ $(obj)/%.lst: $(src)/%.c FORCE | |||
248 | # Compile assembler sources (.S) | 251 | # Compile assembler sources (.S) |
249 | # --------------------------------------------------------------------------- | 252 | # --------------------------------------------------------------------------- |
250 | 253 | ||
251 | modkern_aflags := $(AFLAGS_KERNEL) | 254 | modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL) |
252 | 255 | ||
253 | $(real-objs-m) : modkern_aflags := $(AFLAGS_MODULE) | 256 | $(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) |
254 | $(real-objs-m:.o=.s): modkern_aflags := $(AFLAGS_MODULE) | 257 | $(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) |
255 | 258 | ||
256 | quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ | 259 | quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ |
257 | cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< | 260 | cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< |
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index 0fcd83838771..f89cb87f5c01 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst | |||
@@ -3,7 +3,6 @@ | |||
3 | # | 3 | # |
4 | # header-y - list files to be installed. They are preprocessed | 4 | # header-y - list files to be installed. They are preprocessed |
5 | # to remove __KERNEL__ section of the file | 5 | # to remove __KERNEL__ section of the file |
6 | # unifdef-y - Same as header-y. Obsolete | ||
7 | # objhdr-y - Same as header-y but for generated files | 6 | # objhdr-y - Same as header-y but for generated files |
8 | # | 7 | # |
9 | # ========================================================================== | 8 | # ========================================================================== |
@@ -20,7 +19,7 @@ include scripts/Kbuild.include | |||
20 | 19 | ||
21 | install := $(INSTALL_HDR_PATH)/$(_dst) | 20 | install := $(INSTALL_HDR_PATH)/$(_dst) |
22 | 21 | ||
23 | header-y := $(sort $(header-y) $(unifdef-y)) | 22 | header-y := $(sort $(header-y)) |
24 | subdirs := $(patsubst %/,%,$(filter %/, $(header-y))) | 23 | subdirs := $(patsubst %/,%,$(filter %/, $(header-y))) |
25 | header-y := $(filter-out %/, $(header-y)) | 24 | header-y := $(filter-out %/, $(header-y)) |
26 | 25 | ||
diff --git a/scripts/Makefile.help b/scripts/Makefile.help new file mode 100644 index 000000000000..d03608f5db04 --- /dev/null +++ b/scripts/Makefile.help | |||
@@ -0,0 +1,3 @@ | |||
1 | |||
2 | checker-help: | ||
3 | @echo ' coccicheck - Check with Coccinelle.' | ||
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 8f14c81abbc7..7d22056582c1 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost | |||
@@ -30,7 +30,7 @@ | |||
30 | # - See include/linux/module.h for more details | 30 | # - See include/linux/module.h for more details |
31 | 31 | ||
32 | # Step 4 is solely used to allow module versioning in external modules, | 32 | # Step 4 is solely used to allow module versioning in external modules, |
33 | # where the CRC of each module is retrieved from the Module.symers file. | 33 | # where the CRC of each module is retrieved from the Module.symvers file. |
34 | 34 | ||
35 | # KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined | 35 | # KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined |
36 | # symbols in the final module linking stage | 36 | # symbols in the final module linking stage |
@@ -107,7 +107,7 @@ $(modules:.ko=.mod.c): __modpost ; | |||
107 | modname = $(notdir $(@:.mod.o=)) | 107 | modname = $(notdir $(@:.mod.o=)) |
108 | 108 | ||
109 | quiet_cmd_cc_o_c = CC $@ | 109 | quiet_cmd_cc_o_c = CC $@ |
110 | cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \ | 110 | cmd_cc_o_c = $(CC) $(c_flags) $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE) \ |
111 | -c -o $@ $< | 111 | -c -o $@ $< |
112 | 112 | ||
113 | $(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE | 113 | $(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE |
@@ -117,8 +117,9 @@ targets += $(modules:.ko=.mod.o) | |||
117 | 117 | ||
118 | # Step 6), final link of the modules | 118 | # Step 6), final link of the modules |
119 | quiet_cmd_ld_ko_o = LD [M] $@ | 119 | quiet_cmd_ld_ko_o = LD [M] $@ |
120 | cmd_ld_ko_o = $(LD) -r $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ \ | 120 | cmd_ld_ko_o = $(LD) -r $(LDFLAGS) \ |
121 | $(filter-out FORCE,$^) | 121 | $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ |
122 | -o $@ $(filter-out FORCE,$^) | ||
122 | 123 | ||
123 | $(modules): %.ko :%.o %.mod.o FORCE | 124 | $(modules): %.ko :%.o %.mod.o FORCE |
124 | $(call if_changed,ld_ko_o) | 125 | $(call if_changed,ld_ko_o) |
diff --git a/scripts/checkkconfigsymbols.sh b/scripts/checkkconfigsymbols.sh index 46be3c5a62b7..2ca49bb31efc 100755 --- a/scripts/checkkconfigsymbols.sh +++ b/scripts/checkkconfigsymbols.sh | |||
@@ -14,7 +14,7 @@ find $paths -name '*.[chS]' -o -name 'Makefile' -o -name 'Makefile*[^~]'| while | |||
14 | do | 14 | do |
15 | # Output the bare Kconfig variable and the filename; the _MODULE part at | 15 | # Output the bare Kconfig variable and the filename; the _MODULE part at |
16 | # the end is not removed here (would need perl an not-hungry regexp for that). | 16 | # the end is not removed here (would need perl an not-hungry regexp for that). |
17 | sed -ne 's!^.*\<\(UML_\)\?CONFIG_\([0-9A-Z_]\+\).*!\2 '$i'!p' < $i | 17 | sed -ne 's!^.*\<\(UML_\)\?CONFIG_\([0-9A-Za-z_]\+\).*!\2 '$i'!p' < $i |
18 | done | \ | 18 | done | \ |
19 | # Smart "sort|uniq" implemented in awk and tuned to collect the names of all | 19 | # Smart "sort|uniq" implemented in awk and tuned to collect the names of all |
20 | # files which use a given symbol | 20 | # files which use a given symbol |
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index bd88f11b0953..2039acdf5122 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -195,7 +195,7 @@ our $typeTypedefs = qr{(?x: | |||
195 | our $logFunctions = qr{(?x: | 195 | our $logFunctions = qr{(?x: |
196 | printk| | 196 | printk| |
197 | pr_(debug|dbg|vdbg|devel|info|warning|err|notice|alert|crit|emerg|cont)| | 197 | pr_(debug|dbg|vdbg|devel|info|warning|err|notice|alert|crit|emerg|cont)| |
198 | dev_(printk|dbg|vdbg|info|warn|err|notice|alert|crit|emerg|WARN)| | 198 | (dev|netdev|netif)_(printk|dbg|vdbg|info|warn|err|notice|alert|crit|emerg|WARN)| |
199 | WARN| | 199 | WARN| |
200 | panic | 200 | panic |
201 | )}; | 201 | )}; |
@@ -224,6 +224,12 @@ our @modifierList = ( | |||
224 | qr{fastcall}, | 224 | qr{fastcall}, |
225 | ); | 225 | ); |
226 | 226 | ||
227 | our $allowed_asm_includes = qr{(?x: | ||
228 | irq| | ||
229 | memory | ||
230 | )}; | ||
231 | # memory.h: ARM has a custom one | ||
232 | |||
227 | sub build_types { | 233 | sub build_types { |
228 | my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)"; | 234 | my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)"; |
229 | my $all = "(?x: \n" . join("|\n ", @typeList) . "\n)"; | 235 | my $all = "(?x: \n" . join("|\n ", @typeList) . "\n)"; |
@@ -552,6 +558,9 @@ sub ctx_statement_block { | |||
552 | $type = ($level != 0)? '{' : ''; | 558 | $type = ($level != 0)? '{' : ''; |
553 | 559 | ||
554 | if ($level == 0) { | 560 | if ($level == 0) { |
561 | if (substr($blk, $off + 1, 1) eq ';') { | ||
562 | $off++; | ||
563 | } | ||
555 | last; | 564 | last; |
556 | } | 565 | } |
557 | } | 566 | } |
@@ -1403,7 +1412,8 @@ sub process { | |||
1403 | #80 column limit | 1412 | #80 column limit |
1404 | if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && | 1413 | if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && |
1405 | $rawline !~ /^.\s*\*\s*\@$Ident\s/ && | 1414 | $rawline !~ /^.\s*\*\s*\@$Ident\s/ && |
1406 | $line !~ /^\+\s*$logFunctions\s*\(\s*(?:KERN_\S+\s*)?"[X\t]*"\s*(?:,|\)\s*;)\s*$/ && | 1415 | !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:,|\)\s*;)\s*$/ || |
1416 | $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) && | ||
1407 | $length > 80) | 1417 | $length > 80) |
1408 | { | 1418 | { |
1409 | WARN("line over 80 characters\n" . $herecurr); | 1419 | WARN("line over 80 characters\n" . $herecurr); |
@@ -1448,6 +1458,13 @@ sub process { | |||
1448 | WARN("please, no space before tabs\n" . $herevet); | 1458 | WARN("please, no space before tabs\n" . $herevet); |
1449 | } | 1459 | } |
1450 | 1460 | ||
1461 | # check for spaces at the beginning of a line. | ||
1462 | if ($rawline =~ /^\+ / && $rawline !~ /\+ +\*/) { | ||
1463 | my $herevet = "$here\n" . cat_vet($rawline) . "\n"; | ||
1464 | WARN("please, no space for starting a line, \ | ||
1465 | excluding comments\n" . $herevet); | ||
1466 | } | ||
1467 | |||
1451 | # check we are in a valid C source file if not then ignore this hunk | 1468 | # check we are in a valid C source file if not then ignore this hunk |
1452 | next if ($realfile !~ /\.(h|c)$/); | 1469 | next if ($realfile !~ /\.(h|c)$/); |
1453 | 1470 | ||
@@ -1778,9 +1795,9 @@ sub process { | |||
1778 | WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr); | 1795 | WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr); |
1779 | } | 1796 | } |
1780 | 1797 | ||
1781 | # check for external initialisers. | 1798 | # check for global initialisers. |
1782 | if ($line =~ /^.$Type\s*$Ident\s*(?:\s+$Modifier)*\s*=\s*(0|NULL|false)\s*;/) { | 1799 | if ($line =~ /^.$Type\s*$Ident\s*(?:\s+$Modifier)*\s*=\s*(0|NULL|false)\s*;/) { |
1783 | ERROR("do not initialise externals to 0 or NULL\n" . | 1800 | ERROR("do not initialise globals to 0 or NULL\n" . |
1784 | $herecurr); | 1801 | $herecurr); |
1785 | } | 1802 | } |
1786 | # check for static initialisers. | 1803 | # check for static initialisers. |
@@ -2308,7 +2325,7 @@ sub process { | |||
2308 | my $checkfile = "include/linux/$file"; | 2325 | my $checkfile = "include/linux/$file"; |
2309 | if (-f "$root/$checkfile" && | 2326 | if (-f "$root/$checkfile" && |
2310 | $realfile ne $checkfile && | 2327 | $realfile ne $checkfile && |
2311 | $1 ne 'irq') | 2328 | $1 !~ /$allowed_asm_includes/) |
2312 | { | 2329 | { |
2313 | if ($realfile =~ m{^arch/}) { | 2330 | if ($realfile =~ m{^arch/}) { |
2314 | CHK("Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr); | 2331 | CHK("Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr); |
@@ -2570,6 +2587,21 @@ sub process { | |||
2570 | } | 2587 | } |
2571 | } | 2588 | } |
2572 | 2589 | ||
2590 | # prefer usleep_range over udelay | ||
2591 | if ($line =~ /\budelay\s*\(\s*(\w+)\s*\)/) { | ||
2592 | # ignore udelay's < 10, however | ||
2593 | if (! (($1 =~ /(\d+)/) && ($1 < 10)) ) { | ||
2594 | CHK("usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt\n" . $line); | ||
2595 | } | ||
2596 | } | ||
2597 | |||
2598 | # warn about unexpectedly long msleep's | ||
2599 | if ($line =~ /\bmsleep\s*\((\d+)\);/) { | ||
2600 | if ($1 < 20) { | ||
2601 | WARN("msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt\n" . $line); | ||
2602 | } | ||
2603 | } | ||
2604 | |||
2573 | # warn about #ifdefs in C files | 2605 | # warn about #ifdefs in C files |
2574 | # if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) { | 2606 | # if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) { |
2575 | # print "#ifdef in C files should be avoided\n"; | 2607 | # print "#ifdef in C files should be avoided\n"; |
diff --git a/scripts/checksyscalls.sh b/scripts/checksyscalls.sh index 66ad375612f2..6bb42e72e0e5 100755 --- a/scripts/checksyscalls.sh +++ b/scripts/checksyscalls.sh | |||
@@ -183,7 +183,6 @@ cat << EOF | |||
183 | #define __IGNORE_ustat /* statfs */ | 183 | #define __IGNORE_ustat /* statfs */ |
184 | #define __IGNORE_utime /* utimes */ | 184 | #define __IGNORE_utime /* utimes */ |
185 | #define __IGNORE_vfork /* clone */ | 185 | #define __IGNORE_vfork /* clone */ |
186 | #define __IGNORE_wait4 /* waitid */ | ||
187 | 186 | ||
188 | /* sync_file_range had a stupid ABI. Allow sync_file_range2 instead */ | 187 | /* sync_file_range had a stupid ABI. Allow sync_file_range2 instead */ |
189 | #ifdef __NR_sync_file_range2 | 188 | #ifdef __NR_sync_file_range2 |
diff --git a/scripts/coccicheck b/scripts/coccicheck new file mode 100755 index 000000000000..b8bcf1f7bed7 --- /dev/null +++ b/scripts/coccicheck | |||
@@ -0,0 +1,80 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | SPATCH="`which ${SPATCH:=spatch}`" | ||
4 | |||
5 | if [ "$C" = "1" -o "$C" = "2" ]; then | ||
6 | ONLINE=1 | ||
7 | |||
8 | # This requires Coccinelle >= 0.2.3 | ||
9 | # FLAGS="-ignore_unknown_options -very_quiet" | ||
10 | # OPTIONS=$* | ||
11 | |||
12 | # Workaround for Coccinelle < 0.2.3 | ||
13 | FLAGS="-I $srctree/include -very_quiet" | ||
14 | shift $(( $# - 1 )) | ||
15 | OPTIONS=$1 | ||
16 | else | ||
17 | ONLINE=0 | ||
18 | FLAGS="-very_quiet" | ||
19 | fi | ||
20 | |||
21 | if [ ! -x "$SPATCH" ]; then | ||
22 | echo 'spatch is part of the Coccinelle project and is available at http://coccinelle.lip6.fr/' | ||
23 | exit 1 | ||
24 | fi | ||
25 | |||
26 | if [ "$MODE" = "" ] ; then | ||
27 | if [ "$ONLINE" = "0" ] ; then | ||
28 | echo 'You have not explicitly specify the mode to use. Fallback to "report".' | ||
29 | echo 'You can specify the mode with "make coccicheck MODE=<mode>"' | ||
30 | echo 'Available modes are: report, patch, context, org' | ||
31 | fi | ||
32 | MODE="report" | ||
33 | fi | ||
34 | |||
35 | if [ "$ONLINE" = "0" ] ; then | ||
36 | echo '' | ||
37 | echo 'Please check for false positives in the output before submitting a patch.' | ||
38 | echo 'When using "patch" mode, carefully review the patch before submitting it.' | ||
39 | echo '' | ||
40 | fi | ||
41 | |||
42 | coccinelle () { | ||
43 | COCCI="$1" | ||
44 | |||
45 | OPT=`grep "Option" $COCCI | cut -d':' -f2` | ||
46 | |||
47 | # The option '-parse_cocci' can be used to syntaxically check the SmPL files. | ||
48 | # | ||
49 | # $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null | ||
50 | |||
51 | if [ "$ONLINE" = "0" ] ; then | ||
52 | |||
53 | FILE=`echo $COCCI | sed "s|$srctree/||"` | ||
54 | |||
55 | echo "Processing `basename $COCCI` with option(s) \"$OPT\"" | ||
56 | echo 'Message example to submit a patch:' | ||
57 | |||
58 | sed -e '/\/\/\//!d' -e 's|^///||' $COCCI | ||
59 | |||
60 | echo ' The semantic patch that makes this change is available' | ||
61 | echo " in $FILE." | ||
62 | echo '' | ||
63 | echo ' More information about semantic patching is available at' | ||
64 | echo ' http://coccinelle.lip6.fr/' | ||
65 | echo '' | ||
66 | |||
67 | $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT -dir $srctree || exit 1 | ||
68 | else | ||
69 | $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 | ||
70 | fi | ||
71 | |||
72 | } | ||
73 | |||
74 | if [ "$COCCI" = "" ] ; then | ||
75 | for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do | ||
76 | coccinelle $f | ||
77 | done | ||
78 | else | ||
79 | coccinelle $COCCI | ||
80 | fi | ||
diff --git a/scripts/coccinelle/alloc/drop_kmalloc_cast.cocci b/scripts/coccinelle/alloc/drop_kmalloc_cast.cocci new file mode 100644 index 000000000000..7d4771d449c3 --- /dev/null +++ b/scripts/coccinelle/alloc/drop_kmalloc_cast.cocci | |||
@@ -0,0 +1,67 @@ | |||
1 | /// | ||
2 | /// Casting (void *) value returned by kmalloc is useless | ||
3 | /// as mentioned in Documentation/CodingStyle, Chap 14. | ||
4 | /// | ||
5 | // Confidence: High | ||
6 | // Copyright: 2009,2010 Nicolas Palix, DIKU. GPLv2. | ||
7 | // URL: http://coccinelle.lip6.fr/ | ||
8 | // Options: -no_includes -include_headers | ||
9 | // | ||
10 | // Keywords: kmalloc, kzalloc, kcalloc | ||
11 | // Version min: < 2.6.12 kmalloc | ||
12 | // Version min: < 2.6.12 kcalloc | ||
13 | // Version min: 2.6.14 kzalloc | ||
14 | // | ||
15 | |||
16 | virtual context | ||
17 | virtual patch | ||
18 | virtual org | ||
19 | virtual report | ||
20 | |||
21 | //---------------------------------------------------------- | ||
22 | // For context mode | ||
23 | //---------------------------------------------------------- | ||
24 | |||
25 | @depends on context@ | ||
26 | type T; | ||
27 | @@ | ||
28 | |||
29 | * (T *) | ||
30 | \(kmalloc\|kzalloc\|kcalloc\)(...) | ||
31 | |||
32 | //---------------------------------------------------------- | ||
33 | // For patch mode | ||
34 | //---------------------------------------------------------- | ||
35 | |||
36 | @depends on patch@ | ||
37 | type T; | ||
38 | @@ | ||
39 | |||
40 | - (T *) | ||
41 | \(kmalloc\|kzalloc\|kcalloc\)(...) | ||
42 | |||
43 | //---------------------------------------------------------- | ||
44 | // For org and report mode | ||
45 | //---------------------------------------------------------- | ||
46 | |||
47 | @r depends on org || report@ | ||
48 | type T; | ||
49 | position p; | ||
50 | @@ | ||
51 | |||
52 | (T@p *)\(kmalloc\|kzalloc\|kcalloc\)(...) | ||
53 | |||
54 | @script:python depends on org@ | ||
55 | p << r.p; | ||
56 | t << r.T; | ||
57 | @@ | ||
58 | |||
59 | coccilib.org.print_safe_todo(p[0], t) | ||
60 | |||
61 | @script:python depends on report@ | ||
62 | p << r.p; | ||
63 | t << r.T; | ||
64 | @@ | ||
65 | |||
66 | msg="WARNING: casting value returned by k[cmz]alloc to (%s *) is useless." % (t) | ||
67 | coccilib.report.print_report(p[0], msg) | ||
diff --git a/scripts/coccinelle/alloc/kzalloc-simple.cocci b/scripts/coccinelle/alloc/kzalloc-simple.cocci new file mode 100644 index 000000000000..2eae828fc657 --- /dev/null +++ b/scripts/coccinelle/alloc/kzalloc-simple.cocci | |||
@@ -0,0 +1,82 @@ | |||
1 | /// | ||
2 | /// kzalloc should be used rather than kmalloc followed by memset 0 | ||
3 | /// | ||
4 | // Confidence: High | ||
5 | // Copyright: (C) 2009-2010 Julia Lawall, Nicolas Palix, DIKU. GPLv2. | ||
6 | // Copyright: (C) 2009-2010 Gilles Muller, INRIA/LiP6. GPLv2. | ||
7 | // URL: http://coccinelle.lip6.fr/rules/kzalloc.html | ||
8 | // Options: -no_includes -include_headers | ||
9 | // | ||
10 | // Keywords: kmalloc, kzalloc | ||
11 | // Version min: < 2.6.12 kmalloc | ||
12 | // Version min: 2.6.14 kzalloc | ||
13 | // | ||
14 | |||
15 | virtual context | ||
16 | virtual patch | ||
17 | virtual org | ||
18 | virtual report | ||
19 | |||
20 | //---------------------------------------------------------- | ||
21 | // For context mode | ||
22 | //---------------------------------------------------------- | ||
23 | |||
24 | @depends on context@ | ||
25 | type T, T2; | ||
26 | expression x; | ||
27 | expression E1,E2; | ||
28 | statement S; | ||
29 | @@ | ||
30 | |||
31 | * x = (T)kmalloc(E1,E2); | ||
32 | if ((x==NULL) || ...) S | ||
33 | * memset((T2)x,0,E1); | ||
34 | |||
35 | //---------------------------------------------------------- | ||
36 | // For patch mode | ||
37 | //---------------------------------------------------------- | ||
38 | |||
39 | @depends on patch@ | ||
40 | type T, T2; | ||
41 | expression x; | ||
42 | expression E1,E2; | ||
43 | statement S; | ||
44 | @@ | ||
45 | |||
46 | - x = (T)kmalloc(E1,E2); | ||
47 | + x = kzalloc(E1,E2); | ||
48 | if ((x==NULL) || ...) S | ||
49 | - memset((T2)x,0,E1); | ||
50 | |||
51 | //---------------------------------------------------------- | ||
52 | // For org mode | ||
53 | //---------------------------------------------------------- | ||
54 | |||
55 | @r depends on org || report@ | ||
56 | type T, T2; | ||
57 | expression x; | ||
58 | expression E1,E2; | ||
59 | statement S; | ||
60 | position p; | ||
61 | @@ | ||
62 | |||
63 | x = (T)kmalloc@p(E1,E2); | ||
64 | if ((x==NULL) || ...) S | ||
65 | memset((T2)x,0,E1); | ||
66 | |||
67 | @script:python depends on org@ | ||
68 | p << r.p; | ||
69 | x << r.x; | ||
70 | @@ | ||
71 | |||
72 | msg="%s" % (x) | ||
73 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
74 | coccilib.org.print_todo(p[0], msg_safe) | ||
75 | |||
76 | @script:python depends on report@ | ||
77 | p << r.p; | ||
78 | x << r.x; | ||
79 | @@ | ||
80 | |||
81 | msg="WARNING: kzalloc should be used for %s, instead of kmalloc/memset" % (x) | ||
82 | coccilib.report.print_report(p[0], msg) | ||
diff --git a/scripts/coccinelle/deref_null.cocci b/scripts/coccinelle/deref_null.cocci new file mode 100644 index 000000000000..9969d76d0f4b --- /dev/null +++ b/scripts/coccinelle/deref_null.cocci | |||
@@ -0,0 +1,293 @@ | |||
1 | /// | ||
2 | /// A variable is dereference under a NULL test. | ||
3 | /// Even though it is know to be NULL. | ||
4 | /// | ||
5 | // Confidence: Moderate | ||
6 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. | ||
7 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. | ||
8 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. | ||
9 | // URL: http://coccinelle.lip6.fr/ | ||
10 | // Comments: -I ... -all_includes can give more complete results | ||
11 | // Options: | ||
12 | |||
13 | virtual context | ||
14 | virtual patch | ||
15 | virtual org | ||
16 | virtual report | ||
17 | |||
18 | @initialize:python depends on !context && patch && !org && !report@ | ||
19 | |||
20 | import sys | ||
21 | print >> sys.stderr, "This semantic patch does not support the 'patch' mode." | ||
22 | |||
23 | @depends on patch@ | ||
24 | @@ | ||
25 | |||
26 | this_rule_should_never_matches(); | ||
27 | |||
28 | @ifm depends on !patch@ | ||
29 | expression *E; | ||
30 | statement S1,S2; | ||
31 | position p1; | ||
32 | @@ | ||
33 | |||
34 | if@p1 ((E == NULL && ...) || ...) S1 else S2 | ||
35 | |||
36 | // The following two rules are separate, because both can match a single | ||
37 | // expression in different ways | ||
38 | @pr1 depends on !patch expression@ | ||
39 | expression *ifm.E; | ||
40 | identifier f; | ||
41 | position p1; | ||
42 | @@ | ||
43 | |||
44 | (E != NULL && ...) ? <+...E->f@p1...+> : ... | ||
45 | |||
46 | @pr2 depends on !patch expression@ | ||
47 | expression *ifm.E; | ||
48 | identifier f; | ||
49 | position p2; | ||
50 | @@ | ||
51 | |||
52 | ( | ||
53 | (E != NULL) && ... && <+...E->f@p2...+> | ||
54 | | | ||
55 | (E == NULL) || ... || <+...E->f@p2...+> | ||
56 | | | ||
57 | sizeof(<+...E->f@p2...+>) | ||
58 | ) | ||
59 | |||
60 | // For org and report modes | ||
61 | |||
62 | @r depends on !context && !patch && (org || report) exists@ | ||
63 | expression subE <= ifm.E; | ||
64 | expression *ifm.E; | ||
65 | expression E1,E2; | ||
66 | identifier f; | ||
67 | statement S1,S2,S3,S4; | ||
68 | iterator iter; | ||
69 | position p!={pr1.p1,pr2.p2}; | ||
70 | position ifm.p1; | ||
71 | @@ | ||
72 | |||
73 | if@p1 ((E == NULL && ...) || ...) | ||
74 | { | ||
75 | ... when != if (...) S1 else S2 | ||
76 | ( | ||
77 | iter(subE,...) S4 // no use | ||
78 | | | ||
79 | list_remove_head(E2,subE,...) | ||
80 | | | ||
81 | subE = E1 | ||
82 | | | ||
83 | for(subE = E1;...;...) S4 | ||
84 | | | ||
85 | subE++ | ||
86 | | | ||
87 | ++subE | ||
88 | | | ||
89 | --subE | ||
90 | | | ||
91 | subE-- | ||
92 | | | ||
93 | &subE | ||
94 | | | ||
95 | E->f@p // bad use | ||
96 | ) | ||
97 | ... when any | ||
98 | return ...; | ||
99 | } | ||
100 | else S3 | ||
101 | |||
102 | @script:python depends on !context && !patch && !org && report@ | ||
103 | p << r.p; | ||
104 | p1 << ifm.p1; | ||
105 | x << ifm.E; | ||
106 | @@ | ||
107 | |||
108 | msg="ERROR: %s is NULL but dereferenced." % (x) | ||
109 | coccilib.report.print_report(p[0], msg) | ||
110 | cocci.include_match(False) | ||
111 | |||
112 | @script:python depends on !context && !patch && org && !report@ | ||
113 | p << r.p; | ||
114 | p1 << ifm.p1; | ||
115 | x << ifm.E; | ||
116 | @@ | ||
117 | |||
118 | msg="ERROR: %s is NULL but dereferenced." % (x) | ||
119 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
120 | cocci.print_main(msg_safe,p) | ||
121 | cocci.include_match(False) | ||
122 | |||
123 | @s depends on !context && !patch && (org || report) exists@ | ||
124 | expression subE <= ifm.E; | ||
125 | expression *ifm.E; | ||
126 | expression E1,E2; | ||
127 | identifier f; | ||
128 | statement S1,S2,S3,S4; | ||
129 | iterator iter; | ||
130 | position p!={pr1.p1,pr2.p2}; | ||
131 | position ifm.p1; | ||
132 | @@ | ||
133 | |||
134 | if@p1 ((E == NULL && ...) || ...) | ||
135 | { | ||
136 | ... when != if (...) S1 else S2 | ||
137 | ( | ||
138 | iter(subE,...) S4 // no use | ||
139 | | | ||
140 | list_remove_head(E2,subE,...) | ||
141 | | | ||
142 | subE = E1 | ||
143 | | | ||
144 | for(subE = E1;...;...) S4 | ||
145 | | | ||
146 | subE++ | ||
147 | | | ||
148 | ++subE | ||
149 | | | ||
150 | --subE | ||
151 | | | ||
152 | subE-- | ||
153 | | | ||
154 | &subE | ||
155 | | | ||
156 | E->f@p // bad use | ||
157 | ) | ||
158 | ... when any | ||
159 | } | ||
160 | else S3 | ||
161 | |||
162 | @script:python depends on !context && !patch && !org && report@ | ||
163 | p << s.p; | ||
164 | p1 << ifm.p1; | ||
165 | x << ifm.E; | ||
166 | @@ | ||
167 | |||
168 | msg="ERROR: %s is NULL but dereferenced." % (x) | ||
169 | coccilib.report.print_report(p[0], msg) | ||
170 | |||
171 | @script:python depends on !context && !patch && org && !report@ | ||
172 | p << s.p; | ||
173 | p1 << ifm.p1; | ||
174 | x << ifm.E; | ||
175 | @@ | ||
176 | |||
177 | msg="ERROR: %s is NULL but dereferenced." % (x) | ||
178 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
179 | cocci.print_main(msg_safe,p) | ||
180 | |||
181 | // For context mode | ||
182 | |||
183 | @depends on context && !patch && !org && !report exists@ | ||
184 | expression subE <= ifm.E; | ||
185 | expression *ifm.E; | ||
186 | expression E1,E2; | ||
187 | identifier f; | ||
188 | statement S1,S2,S3,S4; | ||
189 | iterator iter; | ||
190 | position p!={pr1.p1,pr2.p2}; | ||
191 | position ifm.p1; | ||
192 | @@ | ||
193 | |||
194 | if@p1 ((E == NULL && ...) || ...) | ||
195 | { | ||
196 | ... when != if (...) S1 else S2 | ||
197 | ( | ||
198 | iter(subE,...) S4 // no use | ||
199 | | | ||
200 | list_remove_head(E2,subE,...) | ||
201 | | | ||
202 | subE = E1 | ||
203 | | | ||
204 | for(subE = E1;...;...) S4 | ||
205 | | | ||
206 | subE++ | ||
207 | | | ||
208 | ++subE | ||
209 | | | ||
210 | --subE | ||
211 | | | ||
212 | subE-- | ||
213 | | | ||
214 | &subE | ||
215 | | | ||
216 | * E->f@p // bad use | ||
217 | ) | ||
218 | ... when any | ||
219 | return ...; | ||
220 | } | ||
221 | else S3 | ||
222 | |||
223 | // The following three rules are duplicates of ifm, pr1 and pr2 respectively. | ||
224 | // It is need because the previous rule as already made a "change". | ||
225 | |||
226 | @ifm1 depends on !patch@ | ||
227 | expression *E; | ||
228 | statement S1,S2; | ||
229 | position p1; | ||
230 | @@ | ||
231 | |||
232 | if@p1 ((E == NULL && ...) || ...) S1 else S2 | ||
233 | |||
234 | @pr11 depends on !patch expression@ | ||
235 | expression *ifm1.E; | ||
236 | identifier f; | ||
237 | position p1; | ||
238 | @@ | ||
239 | |||
240 | (E != NULL && ...) ? <+...E->f@p1...+> : ... | ||
241 | |||
242 | @pr12 depends on !patch expression@ | ||
243 | expression *ifm1.E; | ||
244 | identifier f; | ||
245 | position p2; | ||
246 | @@ | ||
247 | |||
248 | ( | ||
249 | (E != NULL) && ... && <+...E->f@p2...+> | ||
250 | | | ||
251 | (E == NULL) || ... || <+...E->f@p2...+> | ||
252 | | | ||
253 | sizeof(<+...E->f@p2...+>) | ||
254 | ) | ||
255 | |||
256 | @depends on context && !patch && !org && !report exists@ | ||
257 | expression subE <= ifm1.E; | ||
258 | expression *ifm1.E; | ||
259 | expression E1,E2; | ||
260 | identifier f; | ||
261 | statement S1,S2,S3,S4; | ||
262 | iterator iter; | ||
263 | position p!={pr11.p1,pr12.p2}; | ||
264 | position ifm1.p1; | ||
265 | @@ | ||
266 | |||
267 | if@p1 ((E == NULL && ...) || ...) | ||
268 | { | ||
269 | ... when != if (...) S1 else S2 | ||
270 | ( | ||
271 | iter(subE,...) S4 // no use | ||
272 | | | ||
273 | list_remove_head(E2,subE,...) | ||
274 | | | ||
275 | subE = E1 | ||
276 | | | ||
277 | for(subE = E1;...;...) S4 | ||
278 | | | ||
279 | subE++ | ||
280 | | | ||
281 | ++subE | ||
282 | | | ||
283 | --subE | ||
284 | | | ||
285 | subE-- | ||
286 | | | ||
287 | &subE | ||
288 | | | ||
289 | * E->f@p // bad use | ||
290 | ) | ||
291 | ... when any | ||
292 | } | ||
293 | else S3 | ||
diff --git a/scripts/coccinelle/err_cast.cocci b/scripts/coccinelle/err_cast.cocci new file mode 100644 index 000000000000..2ce115000af6 --- /dev/null +++ b/scripts/coccinelle/err_cast.cocci | |||
@@ -0,0 +1,56 @@ | |||
1 | /// | ||
2 | /// Use ERR_CAST inlined function instead of ERR_PTR(PTR_ERR(...)) | ||
3 | /// | ||
4 | // Confidence: High | ||
5 | // Copyright: (C) 2009, 2010 Nicolas Palix, DIKU. GPLv2. | ||
6 | // Copyright: (C) 2009, 2010 Julia Lawall, DIKU. GPLv2. | ||
7 | // Copyright: (C) 2009, 2010 Gilles Muller, INRIA/LiP6. GPLv2. | ||
8 | // URL: http://coccinelle.lip6.fr/ | ||
9 | // Options: | ||
10 | // | ||
11 | // Keywords: ERR_PTR, PTR_ERR, ERR_CAST | ||
12 | // Version min: 2.6.25 | ||
13 | // | ||
14 | |||
15 | virtual context | ||
16 | virtual patch | ||
17 | virtual org | ||
18 | virtual report | ||
19 | |||
20 | |||
21 | @ depends on context && !patch && !org && !report@ | ||
22 | expression x; | ||
23 | @@ | ||
24 | |||
25 | * ERR_PTR(PTR_ERR(x)) | ||
26 | |||
27 | @ depends on !context && patch && !org && !report @ | ||
28 | expression x; | ||
29 | @@ | ||
30 | |||
31 | - ERR_PTR(PTR_ERR(x)) | ||
32 | + ERR_CAST(x) | ||
33 | |||
34 | @r depends on !context && !patch && (org || report)@ | ||
35 | expression x; | ||
36 | position p; | ||
37 | @@ | ||
38 | |||
39 | ERR_PTR@p(PTR_ERR(x)) | ||
40 | |||
41 | @script:python depends on org@ | ||
42 | p << r.p; | ||
43 | x << r.x; | ||
44 | @@ | ||
45 | |||
46 | msg="WARNING ERR_CAST can be used with %s" % (x) | ||
47 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
48 | coccilib.org.print_todo(p[0], msg_safe) | ||
49 | |||
50 | @script:python depends on report@ | ||
51 | p << r.p; | ||
52 | x << r.x; | ||
53 | @@ | ||
54 | |||
55 | msg="WARNING: ERR_CAST can be used with %s" % (x) | ||
56 | coccilib.report.print_report(p[0], msg) | ||
diff --git a/scripts/coccinelle/resource_size.cocci b/scripts/coccinelle/resource_size.cocci new file mode 100644 index 000000000000..1935a58b39d9 --- /dev/null +++ b/scripts/coccinelle/resource_size.cocci | |||
@@ -0,0 +1,93 @@ | |||
1 | /// | ||
2 | /// Use resource_size function on resource object | ||
3 | /// instead of explicit computation. | ||
4 | /// | ||
5 | // Confidence: High | ||
6 | // Copyright: (C) 2009, 2010 Nicolas Palix, DIKU. GPLv2. | ||
7 | // Copyright: (C) 2009, 2010 Julia Lawall, DIKU. GPLv2. | ||
8 | // Copyright: (C) 2009, 2010 Gilles Muller, INRIA/LiP6. GPLv2. | ||
9 | // URL: http://coccinelle.lip6.fr/ | ||
10 | // Options: | ||
11 | // | ||
12 | // Keywords: resource_size | ||
13 | // Version min: 2.6.27 resource_size | ||
14 | // | ||
15 | |||
16 | virtual context | ||
17 | virtual patch | ||
18 | virtual org | ||
19 | virtual report | ||
20 | |||
21 | //---------------------------------------------------------- | ||
22 | // For context mode | ||
23 | //---------------------------------------------------------- | ||
24 | |||
25 | @r_context depends on context && !patch && !org@ | ||
26 | struct resource *res; | ||
27 | @@ | ||
28 | |||
29 | * (res->end - res->start) + 1 | ||
30 | |||
31 | //---------------------------------------------------------- | ||
32 | // For patch mode | ||
33 | //---------------------------------------------------------- | ||
34 | |||
35 | @r_patch depends on !context && patch && !org@ | ||
36 | struct resource *res; | ||
37 | @@ | ||
38 | |||
39 | - (res->end - res->start) + 1 | ||
40 | + resource_size(res) | ||
41 | |||
42 | //---------------------------------------------------------- | ||
43 | // For org mode | ||
44 | //---------------------------------------------------------- | ||
45 | |||
46 | |||
47 | @r_org depends on !context && !patch && (org || report)@ | ||
48 | struct resource *res; | ||
49 | position p; | ||
50 | @@ | ||
51 | |||
52 | (res->end@p - res->start) + 1 | ||
53 | |||
54 | @rbad_org depends on !context && !patch && (org || report)@ | ||
55 | struct resource *res; | ||
56 | position p != r_org.p; | ||
57 | @@ | ||
58 | |||
59 | res->end@p - res->start | ||
60 | |||
61 | @script:python depends on org@ | ||
62 | p << r_org.p; | ||
63 | x << r_org.res; | ||
64 | @@ | ||
65 | |||
66 | msg="ERROR with %s" % (x) | ||
67 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
68 | coccilib.org.print_todo(p[0], msg_safe) | ||
69 | |||
70 | @script:python depends on report@ | ||
71 | p << r_org.p; | ||
72 | x << r_org.res; | ||
73 | @@ | ||
74 | |||
75 | msg="ERROR: Missing resource_size with %s" % (x) | ||
76 | coccilib.report.print_report(p[0], msg) | ||
77 | |||
78 | @script:python depends on org@ | ||
79 | p << rbad_org.p; | ||
80 | x << rbad_org.res; | ||
81 | @@ | ||
82 | |||
83 | msg="WARNING with %s" % (x) | ||
84 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
85 | coccilib.org.print_todo(p[0], msg_safe) | ||
86 | |||
87 | @script:python depends on report@ | ||
88 | p << rbad_org.p; | ||
89 | x << rbad_org.res; | ||
90 | @@ | ||
91 | |||
92 | msg="WARNING: Suspicious code. resource_size is maybe missing with %s" % (x) | ||
93 | coccilib.report.print_report(p[0], msg) | ||
diff --git a/scripts/decodecode b/scripts/decodecode index 8b30cc36744f..18ba881c3415 100755 --- a/scripts/decodecode +++ b/scripts/decodecode | |||
@@ -40,7 +40,7 @@ echo $code | |||
40 | code=`echo $code | sed -e 's/.*Code: //'` | 40 | code=`echo $code | sed -e 's/.*Code: //'` |
41 | 41 | ||
42 | width=`expr index "$code" ' '` | 42 | width=`expr index "$code" ' '` |
43 | width=$[($width-1)/2] | 43 | width=$((($width-1)/2)) |
44 | case $width in | 44 | case $width in |
45 | 1) type=byte ;; | 45 | 1) type=byte ;; |
46 | 2) type=2byte ;; | 46 | 2) type=2byte ;; |
@@ -48,10 +48,10 @@ case $width in | |||
48 | esac | 48 | esac |
49 | 49 | ||
50 | disas() { | 50 | disas() { |
51 | ${CROSS_COMPILE}as $AFLAGS -o $1.o $1.s &> /dev/null | 51 | ${CROSS_COMPILE}as $AFLAGS -o $1.o $1.s > /dev/null 2>&1 |
52 | 52 | ||
53 | if [ "$ARCH" == "arm" ]; then | 53 | if [ "$ARCH" = "arm" ]; then |
54 | if [ $width == 2 ]; then | 54 | if [ $width -eq 2 ]; then |
55 | OBJDUMPFLAGS="-M force-thumb" | 55 | OBJDUMPFLAGS="-M force-thumb" |
56 | fi | 56 | fi |
57 | 57 | ||
@@ -59,7 +59,7 @@ disas() { | |||
59 | fi | 59 | fi |
60 | 60 | ||
61 | ${CROSS_COMPILE}objdump $OBJDUMPFLAGS -S $1.o | \ | 61 | ${CROSS_COMPILE}objdump $OBJDUMPFLAGS -S $1.o | \ |
62 | grep -v "/tmp\|Disassembly\|\.text\|^$" &> $1.dis | 62 | grep -v "/tmp\|Disassembly\|\.text\|^$" > $1.dis 2>&1 |
63 | } | 63 | } |
64 | 64 | ||
65 | marker=`expr index "$code" "\<"` | 65 | marker=`expr index "$code" "\<"` |
diff --git a/scripts/dtc/fstree.c b/scripts/dtc/fstree.c index 766b2694d935..8fe1bdf239f0 100644 --- a/scripts/dtc/fstree.c +++ b/scripts/dtc/fstree.c | |||
@@ -77,6 +77,7 @@ static struct node *read_fstree(const char *dirname) | |||
77 | free(tmpnam); | 77 | free(tmpnam); |
78 | } | 78 | } |
79 | 79 | ||
80 | closedir(d); | ||
80 | return tree; | 81 | return tree; |
81 | } | 82 | } |
82 | 83 | ||
diff --git a/scripts/kconfig/.gitignore b/scripts/kconfig/.gitignore index 6a36a76e6606..624f6502e03e 100644 --- a/scripts/kconfig/.gitignore +++ b/scripts/kconfig/.gitignore | |||
@@ -17,6 +17,7 @@ gconf.glade.h | |||
17 | # | 17 | # |
18 | conf | 18 | conf |
19 | mconf | 19 | mconf |
20 | nconf | ||
20 | qconf | 21 | qconf |
21 | gconf | 22 | gconf |
22 | kxgettext | 23 | kxgettext |
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 4f0ed5b3a75e..5b7c86ea43a1 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c | |||
@@ -599,12 +599,12 @@ int main(int ac, char **av) | |||
599 | break; | 599 | break; |
600 | case savedefconfig: | 600 | case savedefconfig: |
601 | break; | 601 | break; |
602 | case oldconfig: | ||
603 | case oldaskconfig: | 602 | case oldaskconfig: |
604 | rootEntry = &rootmenu; | 603 | rootEntry = &rootmenu; |
605 | conf(&rootmenu); | 604 | conf(&rootmenu); |
606 | input_mode = silentoldconfig; | 605 | input_mode = silentoldconfig; |
607 | /* fall through */ | 606 | /* fall through */ |
607 | case oldconfig: | ||
608 | case listnewconfig: | 608 | case listnewconfig: |
609 | case oldnoconfig: | 609 | case oldnoconfig: |
610 | case silentoldconfig: | 610 | case silentoldconfig: |
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index fcdfb245a575..102e1235fd5c 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc | |||
@@ -1454,6 +1454,8 @@ sub dump_enum($$) { | |||
1454 | my $file = shift; | 1454 | my $file = shift; |
1455 | 1455 | ||
1456 | $x =~ s@/\*.*?\*/@@gos; # strip comments. | 1456 | $x =~ s@/\*.*?\*/@@gos; # strip comments. |
1457 | $x =~ s/^#\s*define\s+.*$//; # strip #define macros inside enums | ||
1458 | |||
1457 | if ($x =~ /enum\s+(\w+)\s*{(.*)}/) { | 1459 | if ($x =~ /enum\s+(\w+)\s*{(.*)}/) { |
1458 | $declaration_name = $1; | 1460 | $declaration_name = $1; |
1459 | my $members = $2; | 1461 | my $members = $2; |
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 5758aab0d8bb..88f3f07205f8 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -884,16 +884,16 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
884 | char *zeros = NULL; | 884 | char *zeros = NULL; |
885 | 885 | ||
886 | /* We're looking for a section relative symbol */ | 886 | /* We're looking for a section relative symbol */ |
887 | if (!sym->st_shndx || sym->st_shndx >= info->hdr->e_shnum) | 887 | if (!sym->st_shndx || get_secindex(info, sym) >= info->num_sections) |
888 | return; | 888 | return; |
889 | 889 | ||
890 | /* Handle all-NULL symbols allocated into .bss */ | 890 | /* Handle all-NULL symbols allocated into .bss */ |
891 | if (info->sechdrs[sym->st_shndx].sh_type & SHT_NOBITS) { | 891 | if (info->sechdrs[get_secindex(info, sym)].sh_type & SHT_NOBITS) { |
892 | zeros = calloc(1, sym->st_size); | 892 | zeros = calloc(1, sym->st_size); |
893 | symval = zeros; | 893 | symval = zeros; |
894 | } else { | 894 | } else { |
895 | symval = (void *)info->hdr | 895 | symval = (void *)info->hdr |
896 | + info->sechdrs[sym->st_shndx].sh_offset | 896 | + info->sechdrs[get_secindex(info, sym)].sh_offset |
897 | + sym->st_value; | 897 | + sym->st_value; |
898 | } | 898 | } |
899 | 899 | ||
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index f6127b9f5aca..1ec7158b6c1f 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #define _GNU_SOURCE | 14 | #define _GNU_SOURCE |
15 | #include <stdio.h> | 15 | #include <stdio.h> |
16 | #include <ctype.h> | 16 | #include <ctype.h> |
17 | #include <string.h> | ||
17 | #include "modpost.h" | 18 | #include "modpost.h" |
18 | #include "../../include/generated/autoconf.h" | 19 | #include "../../include/generated/autoconf.h" |
19 | #include "../../include/linux/license.h" | 20 | #include "../../include/linux/license.h" |
@@ -253,7 +254,7 @@ static enum export export_no(const char *s) | |||
253 | return export_unknown; | 254 | return export_unknown; |
254 | } | 255 | } |
255 | 256 | ||
256 | static enum export export_from_sec(struct elf_info *elf, Elf_Section sec) | 257 | static enum export export_from_sec(struct elf_info *elf, unsigned int sec) |
257 | { | 258 | { |
258 | if (sec == elf->export_sec) | 259 | if (sec == elf->export_sec) |
259 | return export_plain; | 260 | return export_plain; |
@@ -373,6 +374,8 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
373 | Elf_Ehdr *hdr; | 374 | Elf_Ehdr *hdr; |
374 | Elf_Shdr *sechdrs; | 375 | Elf_Shdr *sechdrs; |
375 | Elf_Sym *sym; | 376 | Elf_Sym *sym; |
377 | const char *secstrings; | ||
378 | unsigned int symtab_idx = ~0U, symtab_shndx_idx = ~0U; | ||
376 | 379 | ||
377 | hdr = grab_file(filename, &info->size); | 380 | hdr = grab_file(filename, &info->size); |
378 | if (!hdr) { | 381 | if (!hdr) { |
@@ -417,8 +420,27 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
417 | return 0; | 420 | return 0; |
418 | } | 421 | } |
419 | 422 | ||
423 | if (hdr->e_shnum == 0) { | ||
424 | /* | ||
425 | * There are more than 64k sections, | ||
426 | * read count from .sh_size. | ||
427 | * note: it doesn't need shndx2secindex() | ||
428 | */ | ||
429 | info->num_sections = TO_NATIVE(sechdrs[0].sh_size); | ||
430 | } | ||
431 | else { | ||
432 | info->num_sections = hdr->e_shnum; | ||
433 | } | ||
434 | if (hdr->e_shstrndx == SHN_XINDEX) { | ||
435 | info->secindex_strings = | ||
436 | shndx2secindex(TO_NATIVE(sechdrs[0].sh_link)); | ||
437 | } | ||
438 | else { | ||
439 | info->secindex_strings = hdr->e_shstrndx; | ||
440 | } | ||
441 | |||
420 | /* Fix endianness in section headers */ | 442 | /* Fix endianness in section headers */ |
421 | for (i = 0; i < hdr->e_shnum; i++) { | 443 | for (i = 0; i < info->num_sections; i++) { |
422 | sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name); | 444 | sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name); |
423 | sechdrs[i].sh_type = TO_NATIVE(sechdrs[i].sh_type); | 445 | sechdrs[i].sh_type = TO_NATIVE(sechdrs[i].sh_type); |
424 | sechdrs[i].sh_flags = TO_NATIVE(sechdrs[i].sh_flags); | 446 | sechdrs[i].sh_flags = TO_NATIVE(sechdrs[i].sh_flags); |
@@ -431,9 +453,8 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
431 | sechdrs[i].sh_entsize = TO_NATIVE(sechdrs[i].sh_entsize); | 453 | sechdrs[i].sh_entsize = TO_NATIVE(sechdrs[i].sh_entsize); |
432 | } | 454 | } |
433 | /* Find symbol table. */ | 455 | /* Find symbol table. */ |
434 | for (i = 1; i < hdr->e_shnum; i++) { | 456 | secstrings = (void *)hdr + sechdrs[info->secindex_strings].sh_offset; |
435 | const char *secstrings | 457 | for (i = 1; i < info->num_sections; i++) { |
436 | = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; | ||
437 | const char *secname; | 458 | const char *secname; |
438 | int nobits = sechdrs[i].sh_type == SHT_NOBITS; | 459 | int nobits = sechdrs[i].sh_type == SHT_NOBITS; |
439 | 460 | ||
@@ -461,14 +482,26 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
461 | else if (strcmp(secname, "__ksymtab_gpl_future") == 0) | 482 | else if (strcmp(secname, "__ksymtab_gpl_future") == 0) |
462 | info->export_gpl_future_sec = i; | 483 | info->export_gpl_future_sec = i; |
463 | 484 | ||
464 | if (sechdrs[i].sh_type != SHT_SYMTAB) | 485 | if (sechdrs[i].sh_type == SHT_SYMTAB) { |
465 | continue; | 486 | unsigned int sh_link_idx; |
487 | symtab_idx = i; | ||
488 | info->symtab_start = (void *)hdr + | ||
489 | sechdrs[i].sh_offset; | ||
490 | info->symtab_stop = (void *)hdr + | ||
491 | sechdrs[i].sh_offset + sechdrs[i].sh_size; | ||
492 | sh_link_idx = shndx2secindex(sechdrs[i].sh_link); | ||
493 | info->strtab = (void *)hdr + | ||
494 | sechdrs[sh_link_idx].sh_offset; | ||
495 | } | ||
466 | 496 | ||
467 | info->symtab_start = (void *)hdr + sechdrs[i].sh_offset; | 497 | /* 32bit section no. table? ("more than 64k sections") */ |
468 | info->symtab_stop = (void *)hdr + sechdrs[i].sh_offset | 498 | if (sechdrs[i].sh_type == SHT_SYMTAB_SHNDX) { |
469 | + sechdrs[i].sh_size; | 499 | symtab_shndx_idx = i; |
470 | info->strtab = (void *)hdr + | 500 | info->symtab_shndx_start = (void *)hdr + |
471 | sechdrs[sechdrs[i].sh_link].sh_offset; | 501 | sechdrs[i].sh_offset; |
502 | info->symtab_shndx_stop = (void *)hdr + | ||
503 | sechdrs[i].sh_offset + sechdrs[i].sh_size; | ||
504 | } | ||
472 | } | 505 | } |
473 | if (!info->symtab_start) | 506 | if (!info->symtab_start) |
474 | fatal("%s has no symtab?\n", filename); | 507 | fatal("%s has no symtab?\n", filename); |
@@ -480,6 +513,21 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
480 | sym->st_value = TO_NATIVE(sym->st_value); | 513 | sym->st_value = TO_NATIVE(sym->st_value); |
481 | sym->st_size = TO_NATIVE(sym->st_size); | 514 | sym->st_size = TO_NATIVE(sym->st_size); |
482 | } | 515 | } |
516 | |||
517 | if (symtab_shndx_idx != ~0U) { | ||
518 | Elf32_Word *p; | ||
519 | if (symtab_idx != | ||
520 | shndx2secindex(sechdrs[symtab_shndx_idx].sh_link)) | ||
521 | fatal("%s: SYMTAB_SHNDX has bad sh_link: %u!=%u\n", | ||
522 | filename, | ||
523 | shndx2secindex(sechdrs[symtab_shndx_idx].sh_link), | ||
524 | symtab_idx); | ||
525 | /* Fix endianness */ | ||
526 | for (p = info->symtab_shndx_start; p < info->symtab_shndx_stop; | ||
527 | p++) | ||
528 | *p = TO_NATIVE(*p); | ||
529 | } | ||
530 | |||
483 | return 1; | 531 | return 1; |
484 | } | 532 | } |
485 | 533 | ||
@@ -519,7 +567,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, | |||
519 | Elf_Sym *sym, const char *symname) | 567 | Elf_Sym *sym, const char *symname) |
520 | { | 568 | { |
521 | unsigned int crc; | 569 | unsigned int crc; |
522 | enum export export = export_from_sec(info, sym->st_shndx); | 570 | enum export export = export_from_sec(info, get_secindex(info, sym)); |
523 | 571 | ||
524 | switch (sym->st_shndx) { | 572 | switch (sym->st_shndx) { |
525 | case SHN_COMMON: | 573 | case SHN_COMMON: |
@@ -661,19 +709,19 @@ static const char *sym_name(struct elf_info *elf, Elf_Sym *sym) | |||
661 | return "(unknown)"; | 709 | return "(unknown)"; |
662 | } | 710 | } |
663 | 711 | ||
664 | static const char *sec_name(struct elf_info *elf, int shndx) | 712 | static const char *sec_name(struct elf_info *elf, int secindex) |
665 | { | 713 | { |
666 | Elf_Shdr *sechdrs = elf->sechdrs; | 714 | Elf_Shdr *sechdrs = elf->sechdrs; |
667 | return (void *)elf->hdr + | 715 | return (void *)elf->hdr + |
668 | elf->sechdrs[elf->hdr->e_shstrndx].sh_offset + | 716 | elf->sechdrs[elf->secindex_strings].sh_offset + |
669 | sechdrs[shndx].sh_name; | 717 | sechdrs[secindex].sh_name; |
670 | } | 718 | } |
671 | 719 | ||
672 | static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr) | 720 | static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr) |
673 | { | 721 | { |
674 | return (void *)elf->hdr + | 722 | return (void *)elf->hdr + |
675 | elf->sechdrs[elf->hdr->e_shstrndx].sh_offset + | 723 | elf->sechdrs[elf->secindex_strings].sh_offset + |
676 | sechdr->sh_name; | 724 | sechdr->sh_name; |
677 | } | 725 | } |
678 | 726 | ||
679 | /* if sym is empty or point to a string | 727 | /* if sym is empty or point to a string |
@@ -742,6 +790,7 @@ static const char *section_white_list[] = | |||
742 | { | 790 | { |
743 | ".comment*", | 791 | ".comment*", |
744 | ".debug*", | 792 | ".debug*", |
793 | ".GCC-command-line", /* mn10300 */ | ||
745 | ".mdebug*", /* alpha, score, mips etc. */ | 794 | ".mdebug*", /* alpha, score, mips etc. */ |
746 | ".pdr", /* alpha, score, mips etc. */ | 795 | ".pdr", /* alpha, score, mips etc. */ |
747 | ".stab*", | 796 | ".stab*", |
@@ -986,6 +1035,13 @@ static const struct sectioncheck *section_mismatch( | |||
986 | * fromsec = .data* | 1035 | * fromsec = .data* |
987 | * atsym =__param* | 1036 | * atsym =__param* |
988 | * | 1037 | * |
1038 | * Pattern 1a: | ||
1039 | * module_param_call() ops can refer to __init set function if permissions=0 | ||
1040 | * The pattern is identified by: | ||
1041 | * tosec = .init.text | ||
1042 | * fromsec = .data* | ||
1043 | * atsym = __param_ops_* | ||
1044 | * | ||
989 | * Pattern 2: | 1045 | * Pattern 2: |
990 | * Many drivers utilise a *driver container with references to | 1046 | * Many drivers utilise a *driver container with references to |
991 | * add, remove, probe functions etc. | 1047 | * add, remove, probe functions etc. |
@@ -1020,6 +1076,12 @@ static int secref_whitelist(const struct sectioncheck *mismatch, | |||
1020 | (strncmp(fromsym, "__param", strlen("__param")) == 0)) | 1076 | (strncmp(fromsym, "__param", strlen("__param")) == 0)) |
1021 | return 0; | 1077 | return 0; |
1022 | 1078 | ||
1079 | /* Check for pattern 1a */ | ||
1080 | if (strcmp(tosec, ".init.text") == 0 && | ||
1081 | match(fromsec, data_sections) && | ||
1082 | (strncmp(fromsym, "__param_ops_", strlen("__param_ops_")) == 0)) | ||
1083 | return 0; | ||
1084 | |||
1023 | /* Check for pattern 2 */ | 1085 | /* Check for pattern 2 */ |
1024 | if (match(tosec, init_exit_sections) && | 1086 | if (match(tosec, init_exit_sections) && |
1025 | match(fromsec, data_sections) && | 1087 | match(fromsec, data_sections) && |
@@ -1052,11 +1114,14 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr, | |||
1052 | Elf_Sym *near = NULL; | 1114 | Elf_Sym *near = NULL; |
1053 | Elf64_Sword distance = 20; | 1115 | Elf64_Sword distance = 20; |
1054 | Elf64_Sword d; | 1116 | Elf64_Sword d; |
1117 | unsigned int relsym_secindex; | ||
1055 | 1118 | ||
1056 | if (relsym->st_name != 0) | 1119 | if (relsym->st_name != 0) |
1057 | return relsym; | 1120 | return relsym; |
1121 | |||
1122 | relsym_secindex = get_secindex(elf, relsym); | ||
1058 | for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { | 1123 | for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { |
1059 | if (sym->st_shndx != relsym->st_shndx) | 1124 | if (get_secindex(elf, sym) != relsym_secindex) |
1060 | continue; | 1125 | continue; |
1061 | if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) | 1126 | if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) |
1062 | continue; | 1127 | continue; |
@@ -1118,9 +1183,9 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, | |||
1118 | for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { | 1183 | for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { |
1119 | const char *symsec; | 1184 | const char *symsec; |
1120 | 1185 | ||
1121 | if (sym->st_shndx >= SHN_LORESERVE) | 1186 | if (is_shndx_special(sym->st_shndx)) |
1122 | continue; | 1187 | continue; |
1123 | symsec = sec_name(elf, sym->st_shndx); | 1188 | symsec = sec_name(elf, get_secindex(elf, sym)); |
1124 | if (strcmp(symsec, sec) != 0) | 1189 | if (strcmp(symsec, sec) != 0) |
1125 | continue; | 1190 | continue; |
1126 | if (!is_valid_name(elf, sym)) | 1191 | if (!is_valid_name(elf, sym)) |
@@ -1167,7 +1232,7 @@ static char *sec2annotation(const char *s) | |||
1167 | strcat(p, " "); | 1232 | strcat(p, " "); |
1168 | return r; /* we leak her but we do not care */ | 1233 | return r; /* we leak her but we do not care */ |
1169 | } else { | 1234 | } else { |
1170 | return ""; | 1235 | return strdup(""); |
1171 | } | 1236 | } |
1172 | } | 1237 | } |
1173 | 1238 | ||
@@ -1195,6 +1260,8 @@ static void report_sec_mismatch(const char *modname, | |||
1195 | { | 1260 | { |
1196 | const char *from, *from_p; | 1261 | const char *from, *from_p; |
1197 | const char *to, *to_p; | 1262 | const char *to, *to_p; |
1263 | char *prl_from; | ||
1264 | char *prl_to; | ||
1198 | 1265 | ||
1199 | switch (from_is_func) { | 1266 | switch (from_is_func) { |
1200 | case 0: from = "variable"; from_p = ""; break; | 1267 | case 0: from = "variable"; from_p = ""; break; |
@@ -1218,16 +1285,21 @@ static void report_sec_mismatch(const char *modname, | |||
1218 | 1285 | ||
1219 | switch (mismatch->mismatch) { | 1286 | switch (mismatch->mismatch) { |
1220 | case TEXT_TO_ANY_INIT: | 1287 | case TEXT_TO_ANY_INIT: |
1288 | prl_from = sec2annotation(fromsec); | ||
1289 | prl_to = sec2annotation(tosec); | ||
1221 | fprintf(stderr, | 1290 | fprintf(stderr, |
1222 | "The function %s%s() references\n" | 1291 | "The function %s%s() references\n" |
1223 | "the %s %s%s%s.\n" | 1292 | "the %s %s%s%s.\n" |
1224 | "This is often because %s lacks a %s\n" | 1293 | "This is often because %s lacks a %s\n" |
1225 | "annotation or the annotation of %s is wrong.\n", | 1294 | "annotation or the annotation of %s is wrong.\n", |
1226 | sec2annotation(fromsec), fromsym, | 1295 | prl_from, fromsym, |
1227 | to, sec2annotation(tosec), tosym, to_p, | 1296 | to, prl_to, tosym, to_p, |
1228 | fromsym, sec2annotation(tosec), tosym); | 1297 | fromsym, prl_to, tosym); |
1298 | free(prl_from); | ||
1299 | free(prl_to); | ||
1229 | break; | 1300 | break; |
1230 | case DATA_TO_ANY_INIT: { | 1301 | case DATA_TO_ANY_INIT: { |
1302 | prl_to = sec2annotation(tosec); | ||
1231 | const char *const *s = mismatch->symbol_white_list; | 1303 | const char *const *s = mismatch->symbol_white_list; |
1232 | fprintf(stderr, | 1304 | fprintf(stderr, |
1233 | "The variable %s references\n" | 1305 | "The variable %s references\n" |
@@ -1235,20 +1307,24 @@ static void report_sec_mismatch(const char *modname, | |||
1235 | "If the reference is valid then annotate the\n" | 1307 | "If the reference is valid then annotate the\n" |
1236 | "variable with __init* or __refdata (see linux/init.h) " | 1308 | "variable with __init* or __refdata (see linux/init.h) " |
1237 | "or name the variable:\n", | 1309 | "or name the variable:\n", |
1238 | fromsym, to, sec2annotation(tosec), tosym, to_p); | 1310 | fromsym, to, prl_to, tosym, to_p); |
1239 | while (*s) | 1311 | while (*s) |
1240 | fprintf(stderr, "%s, ", *s++); | 1312 | fprintf(stderr, "%s, ", *s++); |
1241 | fprintf(stderr, "\n"); | 1313 | fprintf(stderr, "\n"); |
1314 | free(prl_to); | ||
1242 | break; | 1315 | break; |
1243 | } | 1316 | } |
1244 | case TEXT_TO_ANY_EXIT: | 1317 | case TEXT_TO_ANY_EXIT: |
1318 | prl_to = sec2annotation(tosec); | ||
1245 | fprintf(stderr, | 1319 | fprintf(stderr, |
1246 | "The function %s() references a %s in an exit section.\n" | 1320 | "The function %s() references a %s in an exit section.\n" |
1247 | "Often the %s %s%s has valid usage outside the exit section\n" | 1321 | "Often the %s %s%s has valid usage outside the exit section\n" |
1248 | "and the fix is to remove the %sannotation of %s.\n", | 1322 | "and the fix is to remove the %sannotation of %s.\n", |
1249 | fromsym, to, to, tosym, to_p, sec2annotation(tosec), tosym); | 1323 | fromsym, to, to, tosym, to_p, prl_to, tosym); |
1324 | free(prl_to); | ||
1250 | break; | 1325 | break; |
1251 | case DATA_TO_ANY_EXIT: { | 1326 | case DATA_TO_ANY_EXIT: { |
1327 | prl_to = sec2annotation(tosec); | ||
1252 | const char *const *s = mismatch->symbol_white_list; | 1328 | const char *const *s = mismatch->symbol_white_list; |
1253 | fprintf(stderr, | 1329 | fprintf(stderr, |
1254 | "The variable %s references\n" | 1330 | "The variable %s references\n" |
@@ -1256,24 +1332,31 @@ static void report_sec_mismatch(const char *modname, | |||
1256 | "If the reference is valid then annotate the\n" | 1332 | "If the reference is valid then annotate the\n" |
1257 | "variable with __exit* (see linux/init.h) or " | 1333 | "variable with __exit* (see linux/init.h) or " |
1258 | "name the variable:\n", | 1334 | "name the variable:\n", |
1259 | fromsym, to, sec2annotation(tosec), tosym, to_p); | 1335 | fromsym, to, prl_to, tosym, to_p); |
1260 | while (*s) | 1336 | while (*s) |
1261 | fprintf(stderr, "%s, ", *s++); | 1337 | fprintf(stderr, "%s, ", *s++); |
1262 | fprintf(stderr, "\n"); | 1338 | fprintf(stderr, "\n"); |
1339 | free(prl_to); | ||
1263 | break; | 1340 | break; |
1264 | } | 1341 | } |
1265 | case XXXINIT_TO_SOME_INIT: | 1342 | case XXXINIT_TO_SOME_INIT: |
1266 | case XXXEXIT_TO_SOME_EXIT: | 1343 | case XXXEXIT_TO_SOME_EXIT: |
1344 | prl_from = sec2annotation(fromsec); | ||
1345 | prl_to = sec2annotation(tosec); | ||
1267 | fprintf(stderr, | 1346 | fprintf(stderr, |
1268 | "The %s %s%s%s references\n" | 1347 | "The %s %s%s%s references\n" |
1269 | "a %s %s%s%s.\n" | 1348 | "a %s %s%s%s.\n" |
1270 | "If %s is only used by %s then\n" | 1349 | "If %s is only used by %s then\n" |
1271 | "annotate %s with a matching annotation.\n", | 1350 | "annotate %s with a matching annotation.\n", |
1272 | from, sec2annotation(fromsec), fromsym, from_p, | 1351 | from, prl_from, fromsym, from_p, |
1273 | to, sec2annotation(tosec), tosym, to_p, | 1352 | to, prl_to, tosym, to_p, |
1274 | tosym, fromsym, tosym); | 1353 | tosym, fromsym, tosym); |
1354 | free(prl_from); | ||
1355 | free(prl_to); | ||
1275 | break; | 1356 | break; |
1276 | case ANY_INIT_TO_ANY_EXIT: | 1357 | case ANY_INIT_TO_ANY_EXIT: |
1358 | prl_from = sec2annotation(fromsec); | ||
1359 | prl_to = sec2annotation(tosec); | ||
1277 | fprintf(stderr, | 1360 | fprintf(stderr, |
1278 | "The %s %s%s%s references\n" | 1361 | "The %s %s%s%s references\n" |
1279 | "a %s %s%s%s.\n" | 1362 | "a %s %s%s%s.\n" |
@@ -1282,11 +1365,15 @@ static void report_sec_mismatch(const char *modname, | |||
1282 | "uses functionality in the exit path.\n" | 1365 | "uses functionality in the exit path.\n" |
1283 | "The fix is often to remove the %sannotation of\n" | 1366 | "The fix is often to remove the %sannotation of\n" |
1284 | "%s%s so it may be used outside an exit section.\n", | 1367 | "%s%s so it may be used outside an exit section.\n", |
1285 | from, sec2annotation(fromsec), fromsym, from_p, | 1368 | from, prl_from, fromsym, from_p, |
1286 | to, sec2annotation(tosec), tosym, to_p, | 1369 | to, prl_to, tosym, to_p, |
1287 | sec2annotation(tosec), tosym, to_p); | 1370 | prl_to, tosym, to_p); |
1371 | free(prl_from); | ||
1372 | free(prl_to); | ||
1288 | break; | 1373 | break; |
1289 | case ANY_EXIT_TO_ANY_INIT: | 1374 | case ANY_EXIT_TO_ANY_INIT: |
1375 | prl_from = sec2annotation(fromsec); | ||
1376 | prl_to = sec2annotation(tosec); | ||
1290 | fprintf(stderr, | 1377 | fprintf(stderr, |
1291 | "The %s %s%s%s references\n" | 1378 | "The %s %s%s%s references\n" |
1292 | "a %s %s%s%s.\n" | 1379 | "a %s %s%s%s.\n" |
@@ -1295,16 +1382,20 @@ static void report_sec_mismatch(const char *modname, | |||
1295 | "uses functionality in the init path.\n" | 1382 | "uses functionality in the init path.\n" |
1296 | "The fix is often to remove the %sannotation of\n" | 1383 | "The fix is often to remove the %sannotation of\n" |
1297 | "%s%s so it may be used outside an init section.\n", | 1384 | "%s%s so it may be used outside an init section.\n", |
1298 | from, sec2annotation(fromsec), fromsym, from_p, | 1385 | from, prl_from, fromsym, from_p, |
1299 | to, sec2annotation(tosec), tosym, to_p, | 1386 | to, prl_to, tosym, to_p, |
1300 | sec2annotation(tosec), tosym, to_p); | 1387 | prl_to, tosym, to_p); |
1388 | free(prl_from); | ||
1389 | free(prl_to); | ||
1301 | break; | 1390 | break; |
1302 | case EXPORT_TO_INIT_EXIT: | 1391 | case EXPORT_TO_INIT_EXIT: |
1392 | prl_to = sec2annotation(tosec); | ||
1303 | fprintf(stderr, | 1393 | fprintf(stderr, |
1304 | "The symbol %s is exported and annotated %s\n" | 1394 | "The symbol %s is exported and annotated %s\n" |
1305 | "Fix this by removing the %sannotation of %s " | 1395 | "Fix this by removing the %sannotation of %s " |
1306 | "or drop the export.\n", | 1396 | "or drop the export.\n", |
1307 | tosym, sec2annotation(tosec), sec2annotation(tosec), tosym); | 1397 | tosym, prl_to, prl_to, tosym); |
1398 | free(prl_to); | ||
1308 | break; | 1399 | break; |
1309 | } | 1400 | } |
1310 | fprintf(stderr, "\n"); | 1401 | fprintf(stderr, "\n"); |
@@ -1316,7 +1407,7 @@ static void check_section_mismatch(const char *modname, struct elf_info *elf, | |||
1316 | const char *tosec; | 1407 | const char *tosec; |
1317 | const struct sectioncheck *mismatch; | 1408 | const struct sectioncheck *mismatch; |
1318 | 1409 | ||
1319 | tosec = sec_name(elf, sym->st_shndx); | 1410 | tosec = sec_name(elf, get_secindex(elf, sym)); |
1320 | mismatch = section_mismatch(fromsec, tosec); | 1411 | mismatch = section_mismatch(fromsec, tosec); |
1321 | if (mismatch) { | 1412 | if (mismatch) { |
1322 | Elf_Sym *to; | 1413 | Elf_Sym *to; |
@@ -1344,7 +1435,7 @@ static unsigned int *reloc_location(struct elf_info *elf, | |||
1344 | Elf_Shdr *sechdr, Elf_Rela *r) | 1435 | Elf_Shdr *sechdr, Elf_Rela *r) |
1345 | { | 1436 | { |
1346 | Elf_Shdr *sechdrs = elf->sechdrs; | 1437 | Elf_Shdr *sechdrs = elf->sechdrs; |
1347 | int section = sechdr->sh_info; | 1438 | int section = shndx2secindex(sechdr->sh_info); |
1348 | 1439 | ||
1349 | return (void *)elf->hdr + sechdrs[section].sh_offset + | 1440 | return (void *)elf->hdr + sechdrs[section].sh_offset + |
1350 | r->r_offset - sechdrs[section].sh_addr; | 1441 | r->r_offset - sechdrs[section].sh_addr; |
@@ -1452,7 +1543,7 @@ static void section_rela(const char *modname, struct elf_info *elf, | |||
1452 | r.r_addend = TO_NATIVE(rela->r_addend); | 1543 | r.r_addend = TO_NATIVE(rela->r_addend); |
1453 | sym = elf->symtab_start + r_sym; | 1544 | sym = elf->symtab_start + r_sym; |
1454 | /* Skip special sections */ | 1545 | /* Skip special sections */ |
1455 | if (sym->st_shndx >= SHN_LORESERVE) | 1546 | if (is_shndx_special(sym->st_shndx)) |
1456 | continue; | 1547 | continue; |
1457 | check_section_mismatch(modname, elf, &r, sym, fromsec); | 1548 | check_section_mismatch(modname, elf, &r, sym, fromsec); |
1458 | } | 1549 | } |
@@ -1510,7 +1601,7 @@ static void section_rel(const char *modname, struct elf_info *elf, | |||
1510 | } | 1601 | } |
1511 | sym = elf->symtab_start + r_sym; | 1602 | sym = elf->symtab_start + r_sym; |
1512 | /* Skip special sections */ | 1603 | /* Skip special sections */ |
1513 | if (sym->st_shndx >= SHN_LORESERVE) | 1604 | if (is_shndx_special(sym->st_shndx)) |
1514 | continue; | 1605 | continue; |
1515 | check_section_mismatch(modname, elf, &r, sym, fromsec); | 1606 | check_section_mismatch(modname, elf, &r, sym, fromsec); |
1516 | } | 1607 | } |
@@ -1535,7 +1626,7 @@ static void check_sec_ref(struct module *mod, const char *modname, | |||
1535 | Elf_Shdr *sechdrs = elf->sechdrs; | 1626 | Elf_Shdr *sechdrs = elf->sechdrs; |
1536 | 1627 | ||
1537 | /* Walk through all sections */ | 1628 | /* Walk through all sections */ |
1538 | for (i = 0; i < elf->hdr->e_shnum; i++) { | 1629 | for (i = 0; i < elf->num_sections; i++) { |
1539 | check_section(modname, elf, &elf->sechdrs[i]); | 1630 | check_section(modname, elf, &elf->sechdrs[i]); |
1540 | /* We want to process only relocation sections and not .init */ | 1631 | /* We want to process only relocation sections and not .init */ |
1541 | if (sechdrs[i].sh_type == SHT_RELA) | 1632 | if (sechdrs[i].sh_type == SHT_RELA) |
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index be987a44f250..0388cfccac8d 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h | |||
@@ -129,8 +129,51 @@ struct elf_info { | |||
129 | const char *strtab; | 129 | const char *strtab; |
130 | char *modinfo; | 130 | char *modinfo; |
131 | unsigned int modinfo_len; | 131 | unsigned int modinfo_len; |
132 | |||
133 | /* support for 32bit section numbers */ | ||
134 | |||
135 | unsigned int num_sections; /* max_secindex + 1 */ | ||
136 | unsigned int secindex_strings; | ||
137 | /* if Nth symbol table entry has .st_shndx = SHN_XINDEX, | ||
138 | * take shndx from symtab_shndx_start[N] instead */ | ||
139 | Elf32_Word *symtab_shndx_start; | ||
140 | Elf32_Word *symtab_shndx_stop; | ||
132 | }; | 141 | }; |
133 | 142 | ||
143 | static inline int is_shndx_special(unsigned int i) | ||
144 | { | ||
145 | return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE; | ||
146 | } | ||
147 | |||
148 | /* shndx is in [0..SHN_LORESERVE) U (SHN_HIRESERVE, 0xfffffff], thus: | ||
149 | * shndx == 0 <=> sechdrs[0] | ||
150 | * ...... | ||
151 | * shndx == SHN_LORESERVE-1 <=> sechdrs[SHN_LORESERVE-1] | ||
152 | * shndx == SHN_HIRESERVE+1 <=> sechdrs[SHN_LORESERVE] | ||
153 | * shndx == SHN_HIRESERVE+2 <=> sechdrs[SHN_LORESERVE+1] | ||
154 | * ...... | ||
155 | * fyi: sym->st_shndx is uint16, SHN_LORESERVE = ff00, SHN_HIRESERVE = ffff, | ||
156 | * so basically we map 0000..feff -> 0000..feff | ||
157 | * ff00..ffff -> (you are a bad boy, dont do it) | ||
158 | * 10000..xxxx -> ff00..(xxxx-0x100) | ||
159 | */ | ||
160 | static inline unsigned int shndx2secindex(unsigned int i) | ||
161 | { | ||
162 | if (i <= SHN_HIRESERVE) | ||
163 | return i; | ||
164 | return i - (SHN_HIRESERVE + 1 - SHN_LORESERVE); | ||
165 | } | ||
166 | |||
167 | /* Accessor for sym->st_shndx, hides ugliness of "64k sections" */ | ||
168 | static inline unsigned int get_secindex(const struct elf_info *info, | ||
169 | const Elf_Sym *sym) | ||
170 | { | ||
171 | if (sym->st_shndx != SHN_XINDEX) | ||
172 | return sym->st_shndx; | ||
173 | return shndx2secindex(info->symtab_shndx_start[sym - | ||
174 | info->symtab_start]); | ||
175 | } | ||
176 | |||
134 | /* file2alias.c */ | 177 | /* file2alias.c */ |
135 | extern unsigned int cross_build; | 178 | extern unsigned int cross_build; |
136 | void handle_moddevtable(struct module *mod, struct elf_info *info, | 179 | void handle_moddevtable(struct module *mod, struct elf_info *info, |
diff --git a/scripts/package/Makefile b/scripts/package/Makefile index d2c29b63adda..d0b931b994fc 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile | |||
@@ -111,13 +111,38 @@ tar%pkg: FORCE | |||
111 | clean-dirs += $(objtree)/tar-install/ | 111 | clean-dirs += $(objtree)/tar-install/ |
112 | 112 | ||
113 | 113 | ||
114 | # perf-pkg - generate a source tarball with perf source | ||
115 | # --------------------------------------------------------------------------- | ||
116 | |||
117 | perf-tar=perf-$(KERNELVERSION) | ||
118 | |||
119 | quiet_cmd_perf_tar = TAR | ||
120 | cmd_perf_tar = \ | ||
121 | git archive --prefix=$(perf-tar)/ HEAD^{tree} \ | ||
122 | $$(cat $(srctree)/tools/perf/MANIFEST) -o $(perf-tar).tar; \ | ||
123 | mkdir -p $(perf-tar); \ | ||
124 | git rev-parse HEAD > $(perf-tar)/HEAD; \ | ||
125 | tar rf $(perf-tar).tar $(perf-tar)/HEAD; \ | ||
126 | rm -r $(perf-tar); \ | ||
127 | $(if $(findstring tar-src,$@),, \ | ||
128 | $(if $(findstring bz2,$@),bzip2, \ | ||
129 | $(if $(findstring gz,$@),gzip, \ | ||
130 | $(error unknown target $@))) \ | ||
131 | -f -9 $(perf-tar).tar) | ||
132 | |||
133 | perf-%pkg: FORCE | ||
134 | $(call cmd,perf_tar) | ||
135 | |||
114 | # Help text displayed when executing 'make help' | 136 | # Help text displayed when executing 'make help' |
115 | # --------------------------------------------------------------------------- | 137 | # --------------------------------------------------------------------------- |
116 | help: FORCE | 138 | help: FORCE |
117 | @echo ' rpm-pkg - Build both source and binary RPM kernel packages' | 139 | @echo ' rpm-pkg - Build both source and binary RPM kernel packages' |
118 | @echo ' binrpm-pkg - Build only the binary kernel package' | 140 | @echo ' binrpm-pkg - Build only the binary kernel package' |
119 | @echo ' deb-pkg - Build the kernel as an deb package' | 141 | @echo ' deb-pkg - Build the kernel as an deb package' |
120 | @echo ' tar-pkg - Build the kernel as an uncompressed tarball' | 142 | @echo ' tar-pkg - Build the kernel as an uncompressed tarball' |
121 | @echo ' targz-pkg - Build the kernel as a gzip compressed tarball' | 143 | @echo ' targz-pkg - Build the kernel as a gzip compressed tarball' |
122 | @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball' | 144 | @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball' |
145 | @echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball' | ||
146 | @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball' | ||
147 | @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball' | ||
123 | 148 | ||
diff --git a/scripts/package/builddeb b/scripts/package/builddeb index 07f2fbde2abf..5f1e2fc7f171 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb | |||
@@ -148,10 +148,11 @@ EOF | |||
148 | # Generate a control file | 148 | # Generate a control file |
149 | cat <<EOF > debian/control | 149 | cat <<EOF > debian/control |
150 | Source: linux-upstream | 150 | Source: linux-upstream |
151 | Section: admin | 151 | Section: kernel |
152 | Priority: optional | 152 | Priority: optional |
153 | Maintainer: $maintainer | 153 | Maintainer: $maintainer |
154 | Standards-Version: 3.8.1 | 154 | Standards-Version: 3.8.4 |
155 | Homepage: http://www.kernel.org/ | ||
155 | EOF | 156 | EOF |
156 | 157 | ||
157 | if [ "$ARCH" = "um" ]; then | 158 | if [ "$ARCH" = "um" ]; then |
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl index f3c9c0a90b98..0171060b5fd6 100755 --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl | |||
@@ -326,7 +326,7 @@ if ($arch eq "x86_64") { | |||
326 | # 14: R_MIPS_NONE *ABS* | 326 | # 14: R_MIPS_NONE *ABS* |
327 | # 18: 00020021 nop | 327 | # 18: 00020021 nop |
328 | if ($is_module eq "0") { | 328 | if ($is_module eq "0") { |
329 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$"; | 329 | $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_26\\s+_mcount\$"; |
330 | } else { | 330 | } else { |
331 | $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_HI16\\s+_mcount\$"; | 331 | $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_HI16\\s+_mcount\$"; |
332 | } | 332 | } |
diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 64a9cb5556cd..e90a91cc5185 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion | |||
@@ -86,7 +86,7 @@ scm_version() | |||
86 | 86 | ||
87 | # Check for mercurial and a mercurial repo. | 87 | # Check for mercurial and a mercurial repo. |
88 | if hgid=`hg id 2>/dev/null`; then | 88 | if hgid=`hg id 2>/dev/null`; then |
89 | tag=`printf '%s' "$hgid" | cut -d' ' -f2` | 89 | tag=`printf '%s' "$hgid" | cut -s -d' ' -f2` |
90 | 90 | ||
91 | # Do we have an untagged version? | 91 | # Do we have an untagged version? |
92 | if [ -z "$tag" -o "$tag" = tip ]; then | 92 | if [ -z "$tag" -o "$tag" = tip ]; then |