aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2007-10-12 21:27:47 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2007-10-12 21:27:47 -0400
commitb981d8b3f5e008ff10d993be633ad00564fc22cd (patch)
treee292dc07b22308912cf6a58354a608b9e5e8e1fd /scripts
parentb11d2127c4893a7315d1e16273bc8560049fa3ca (diff)
parent2b9e0aae1d50e880c58d46788e5e3ebd89d75d62 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts: drivers/macintosh/adbhid.c
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Kbuild.include7
-rwxr-xr-xscripts/Lindent2
-rw-r--r--scripts/Makefile.build18
-rw-r--r--scripts/Makefile.headersinst14
-rw-r--r--scripts/Makefile.modpost23
-rwxr-xr-xscripts/checkpatch.pl249
-rwxr-xr-xscripts/checkstack.pl5
-rwxr-xr-xscripts/checksyscalls.sh2
-rwxr-xr-xscripts/cleanfile54
-rwxr-xr-xscripts/cleanpatch58
-rw-r--r--scripts/gcc-version.sh15
-rw-r--r--scripts/gen_initramfs_list.sh12
-rw-r--r--scripts/kallsyms.c17
-rw-r--r--scripts/kconfig/Makefile35
-rw-r--r--scripts/kconfig/conf.c52
-rw-r--r--scripts/kconfig/confdata.c37
-rw-r--r--scripts/kconfig/expr.h4
-rw-r--r--scripts/kconfig/gconf.c10
-rw-r--r--scripts/kconfig/kxgettext.c8
-rw-r--r--scripts/kconfig/lkc_proto.h2
-rw-r--r--scripts/kconfig/lxdialog/check-lxdialog.sh2
-rw-r--r--scripts/kconfig/mconf.c15
-rw-r--r--scripts/kconfig/menu.c12
-rw-r--r--scripts/kconfig/qconf.cc2
-rw-r--r--scripts/kconfig/zconf.tab.c_shipped12
-rw-r--r--scripts/kconfig/zconf.y12
-rwxr-xr-xscripts/kernel-doc28
-rw-r--r--scripts/mod/file2alias.c50
-rw-r--r--scripts/mod/modpost.c456
-rw-r--r--scripts/mod/modpost.h3
-rwxr-xr-xscripts/namespace.pl8
-rwxr-xr-xscripts/ver_linux4
32 files changed, 857 insertions, 371 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 06c1a377c4c5..677bc6c175cb 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -100,9 +100,14 @@ cc-option-align = $(subst -functions=0,,\
100 $(call cc-option,-falign-functions=0,-malign-functions=0)) 100 $(call cc-option,-falign-functions=0,-malign-functions=0))
101 101
102# cc-version 102# cc-version
103# Usage gcc-ver := $(call cc-version,$(CC)) 103# Usage gcc-ver := $(call cc-version)
104cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) 104cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC))
105 105
106# cc-fullversion
107# Usage gcc-ver := $(call cc-fullversion)
108cc-fullversion = $(shell $(CONFIG_SHELL) \
109 $(srctree)/scripts/gcc-version.sh -p $(CC))
110
106# cc-ifversion 111# cc-ifversion
107# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) 112# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
108cc-ifversion = $(shell [ $(call cc-version, $(CC)) $(1) $(2) ] && echo $(3)) 113cc-ifversion = $(shell [ $(call cc-version, $(CC)) $(1) $(2) ] && echo $(3))
diff --git a/scripts/Lindent b/scripts/Lindent
index 7d8d8896e309..9468ec7971db 100755
--- a/scripts/Lindent
+++ b/scripts/Lindent
@@ -1,2 +1,2 @@
1#!/bin/sh 1#!/bin/sh
2indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs "$@" 2indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs -cp1 "$@"
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index a525112847fd..7fd6055bedfd 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -7,6 +7,22 @@ src := $(obj)
7PHONY := __build 7PHONY := __build
8__build: 8__build:
9 9
10# Init all relevant variables used in kbuild files so
11# 1) they have correct type
12# 2) they do not inherit any value from the environment
13obj-y :=
14obj-m :=
15lib-y :=
16lib-m :=
17always :=
18targets :=
19subdir-y :=
20subdir-m :=
21EXTRA_AFLAGS :=
22EXTRA_CFLAGS :=
23EXTRA_CPPFLAGS :=
24EXTRA_LDFLAGS :=
25
10# Read .config if it exist, otherwise ignore 26# Read .config if it exist, otherwise ignore
11-include include/config/auto.conf 27-include include/config/auto.conf
12 28
@@ -299,7 +315,7 @@ quiet_cmd_link_multi-y = LD $@
299cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) 315cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps)
300 316
301quiet_cmd_link_multi-m = LD [M] $@ 317quiet_cmd_link_multi-m = LD [M] $@
302cmd_link_multi-m = $(LD) $(ld_flags) $(LDFLAGS_MODULE) -o $@ $(link_multi_deps) 318cmd_link_multi-m = $(cmd_link_multi-y)
303 319
304# We would rather have a list of rules like 320# We would rather have a list of rules like
305# foo.o: $(foo-objs) 321# foo.o: $(foo-objs)
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index f98d772aac80..53dae3eb3d1f 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -11,13 +11,13 @@ UNIFDEF := scripts/unifdef -U__KERNEL__
11 11
12# Eliminate the contents of (and inclusions of) compiler.h 12# Eliminate the contents of (and inclusions of) compiler.h
13HDRSED := sed -e "s/ inline / __inline__ /g" \ 13HDRSED := sed -e "s/ inline / __inline__ /g" \
14 -e "s/[[:space:]]__user[[:space:]]\+/ /g" \ 14 -e "s/[[:space:]]__user[[:space:]]\{1,\}/ /g" \
15 -e "s/(__user[[:space:]]\+/ (/g" \ 15 -e "s/(__user[[:space:]]\{1,\}/ (/g" \
16 -e "s/[[:space:]]__force[[:space:]]\+/ /g" \ 16 -e "s/[[:space:]]__force[[:space:]]\{1,\}/ /g" \
17 -e "s/(__force[[:space:]]\+/ (/g" \ 17 -e "s/(__force[[:space:]]\{1,\}/ (/g" \
18 -e "s/[[:space:]]__iomem[[:space:]]\+/ /g" \ 18 -e "s/[[:space:]]__iomem[[:space:]]\{1,\}/ /g" \
19 -e "s/(__iomem[[:space:]]\+/ (/g" \ 19 -e "s/(__iomem[[:space:]]\{1,\}/ (/g" \
20 -e "s/[[:space:]]__attribute_const__[[:space:]]\+/\ /g" \ 20 -e "s/[[:space:]]__attribute_const__[[:space:]]\{1,\}/\ /g" \
21 -e "s/[[:space:]]__attribute_const__$$//" \ 21 -e "s/[[:space:]]__attribute_const__$$//" \
22 -e "/^\#include <linux\/compiler.h>/d" 22 -e "/^\#include <linux\/compiler.h>/d"
23 23
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index d5bbbcce31ef..d988f5d21e3d 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -56,24 +56,25 @@ _modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules))
56 56
57# Step 2), invoke modpost 57# Step 2), invoke modpost
58# Includes step 3,4 58# Includes step 3,4
59modpost = scripts/mod/modpost \
60 $(if $(CONFIG_MODVERSIONS),-m) \
61 $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \
62 $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \
63 $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \
64 $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
65 $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w)
66
59quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules 67quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules
60 cmd_modpost = scripts/mod/modpost \ 68 cmd_modpost = $(modpost) -s
61 $(if $(CONFIG_MODVERSIONS),-m) \
62 $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \
63 $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \
64 $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \
65 $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
66 $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w)
67 69
68PHONY += __modpost 70PHONY += __modpost
69__modpost: $(modules:.ko=.o) FORCE 71__modpost: $(modules:.ko=.o) FORCE
70 $(call cmd,modpost) $(wildcard vmlinux) $(filter-out FORCE,$^) 72 $(call cmd,modpost) $(wildcard vmlinux) $(filter-out FORCE,$^)
71 73
72quiet_cmd_kernel-mod = MODPOST $@ 74quiet_cmd_kernel-mod = MODPOST $@
73 cmd_kernel-mod = $(cmd_modpost) $(KBUILD_VMLINUX_OBJS) 75 cmd_kernel-mod = $(modpost) $@
74 76
75PHONY += vmlinux 77vmlinux.o: FORCE
76vmlinux: FORCE
77 $(call cmd,kernel-mod) 78 $(call cmd,kernel-mod)
78 79
79# Declare generated files as targets for modpost 80# Declare generated files as targets for modpost
@@ -97,7 +98,7 @@ targets += $(modules:.ko=.mod.o)
97 98
98# Step 6), final link of the modules 99# Step 6), final link of the modules
99quiet_cmd_ld_ko_o = LD [M] $@ 100quiet_cmd_ld_ko_o = LD [M] $@
100 cmd_ld_ko_o = $(LD) $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ \ 101 cmd_ld_ko_o = $(LD) -r $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ \
101 $(filter-out FORCE,$^) 102 $(filter-out FORCE,$^)
102 103
103$(modules): %.ko :%.o %.mod.o FORCE 104$(modules): %.ko :%.o %.mod.o FORCE
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 25e20a27fc59..dae7d30dca0f 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -9,7 +9,7 @@ use strict;
9my $P = $0; 9my $P = $0;
10$P =~ s@.*/@@g; 10$P =~ s@.*/@@g;
11 11
12my $V = '0.07'; 12my $V = '0.09';
13 13
14use Getopt::Long qw(:config no_auto_abbrev); 14use Getopt::Long qw(:config no_auto_abbrev);
15 15
@@ -47,16 +47,14 @@ my $removal = 'Documentation/feature-removal-schedule.txt';
47if ($tree && -f $removal) { 47if ($tree && -f $removal) {
48 open(REMOVE, "<$removal") || die "$P: $removal: open failed - $!\n"; 48 open(REMOVE, "<$removal") || die "$P: $removal: open failed - $!\n";
49 while (<REMOVE>) { 49 while (<REMOVE>) {
50 if (/^Files:\s+(.*\S)/) { 50 if (/^Check:\s+(.*\S)/) {
51 for my $file (split(/[, ]+/, $1)) { 51 for my $entry (split(/[, ]+/, $1)) {
52 if ($file =~ m@include/(.*)@) { 52 if ($entry =~ m@include/(.*)@) {
53 push(@dep_includes, $1); 53 push(@dep_includes, $1);
54 }
55 }
56 54
57 } elsif (/^Funcs:\s+(.*\S)/) { 55 } elsif ($entry !~ m@/@) {
58 for my $func (split(/[, ]+/, $1)) { 56 push(@dep_functions, $entry);
59 push(@dep_functions, $func); 57 }
60 } 58 }
61 } 59 }
62 } 60 }
@@ -153,7 +151,7 @@ sub sanitise_line {
153} 151}
154 152
155sub ctx_block_get { 153sub ctx_block_get {
156 my ($linenr, $remain, $outer, $open, $close) = @_; 154 my ($linenr, $remain, $outer, $open, $close, $off) = @_;
157 my $line; 155 my $line;
158 my $start = $linenr - 1; 156 my $start = $linenr - 1;
159 my $blk = ''; 157 my $blk = '';
@@ -161,38 +159,58 @@ sub ctx_block_get {
161 my @c; 159 my @c;
162 my @res = (); 160 my @res = ();
163 161
162 my $level = 0;
164 for ($line = $start; $remain > 0; $line++) { 163 for ($line = $start; $remain > 0; $line++) {
165 next if ($rawlines[$line] =~ /^-/); 164 next if ($rawlines[$line] =~ /^-/);
166 $remain--; 165 $remain--;
167 166
168 $blk .= $rawlines[$line]; 167 $blk .= $rawlines[$line];
168 foreach my $c (split(//, $rawlines[$line])) {
169 ##print "C<$c>L<$level><$open$close>O<$off>\n";
170 if ($off > 0) {
171 $off--;
172 next;
173 }
169 174
170 @o = ($blk =~ /$open/g); 175 if ($c eq $close && $level > 0) {
171 @c = ($blk =~ /$close/g); 176 $level--;
177 last if ($level == 0);
178 } elsif ($c eq $open) {
179 $level++;
180 }
181 }
172 182
173 if (!$outer || (scalar(@o) - scalar(@c)) == 1) { 183 if (!$outer || $level <= 1) {
174 push(@res, $rawlines[$line]); 184 push(@res, $rawlines[$line]);
175 } 185 }
176 186
177 last if (scalar(@o) == scalar(@c)); 187 last if ($level == 0);
178 } 188 }
179 189
180 return @res; 190 return ($level, @res);
181} 191}
182sub ctx_block_outer { 192sub ctx_block_outer {
183 my ($linenr, $remain) = @_; 193 my ($linenr, $remain) = @_;
184 194
185 return ctx_block_get($linenr, $remain, 1, '\{', '\}'); 195 my ($level, @r) = ctx_block_get($linenr, $remain, 1, '{', '}', 0);
196 return @r;
186} 197}
187sub ctx_block { 198sub ctx_block {
188 my ($linenr, $remain) = @_; 199 my ($linenr, $remain) = @_;
189 200
190 return ctx_block_get($linenr, $remain, 0, '\{', '\}'); 201 my ($level, @r) = ctx_block_get($linenr, $remain, 0, '{', '}', 0);
202 return @r;
191} 203}
192sub ctx_statement { 204sub ctx_statement {
205 my ($linenr, $remain, $off) = @_;
206
207 my ($level, @r) = ctx_block_get($linenr, $remain, 0, '(', ')', $off);
208 return @r;
209}
210sub ctx_block_level {
193 my ($linenr, $remain) = @_; 211 my ($linenr, $remain) = @_;
194 212
195 return ctx_block_get($linenr, $remain, 0, '\(', '\)'); 213 return ctx_block_get($linenr, $remain, 0, '{', '}', 0);
196} 214}
197 215
198sub ctx_locate_comment { 216sub ctx_locate_comment {
@@ -246,16 +264,23 @@ sub cat_vet {
246 return $vet; 264 return $vet;
247} 265}
248 266
267my @report = ();
268sub report {
269 push(@report, $_[0]);
270}
271sub report_dump {
272 @report;
273}
249sub ERROR { 274sub ERROR {
250 print "ERROR: $_[0]\n"; 275 report("ERROR: $_[0]\n");
251 our $clean = 0; 276 our $clean = 0;
252} 277}
253sub WARN { 278sub WARN {
254 print "WARNING: $_[0]\n"; 279 report("WARNING: $_[0]\n");
255 our $clean = 0; 280 our $clean = 0;
256} 281}
257sub CHK { 282sub CHK {
258 print "CHECK: $_[0]\n"; 283 report("CHECK: $_[0]\n");
259 our $clean = 0; 284 our $clean = 0;
260} 285}
261 286
@@ -286,7 +311,7 @@ sub process {
286 311
287 my $Ident = qr{[A-Za-z\d_]+}; 312 my $Ident = qr{[A-Za-z\d_]+};
288 my $Storage = qr{extern|static}; 313 my $Storage = qr{extern|static};
289 my $Sparse = qr{__user|__kernel|__force|__iomem}; 314 my $Sparse = qr{__user|__kernel|__force|__iomem|__must_check|__init_refok};
290 my $NonptrType = qr{ 315 my $NonptrType = qr{
291 \b 316 \b
292 (?:const\s+)? 317 (?:const\s+)?
@@ -300,6 +325,7 @@ sub process {
300 unsigned| 325 unsigned|
301 float| 326 float|
302 double| 327 double|
328 bool|
303 long\s+int| 329 long\s+int|
304 long\s+long| 330 long\s+long|
305 long\s+long\s+int| 331 long\s+long\s+int|
@@ -315,10 +341,14 @@ sub process {
315 }x; 341 }x;
316 my $Type = qr{ 342 my $Type = qr{
317 \b$NonptrType\b 343 \b$NonptrType\b
318 (?:\s*\*+\s*const|\s*\*+)? 344 (?:\s*\*+\s*const|\s*\*+|(?:\s*\[\s*\])+)?
345 (?:\s+$Sparse)*
319 }x; 346 }x;
320 my $Declare = qr{(?:$Storage\s+)?$Type}; 347 my $Declare = qr{(?:$Storage\s+)?$Type};
321 my $Attribute = qr{__read_mostly|__init|__initdata}; 348 my $Attribute = qr{const|__read_mostly|__init|__initdata|__meminit};
349
350 my $Member = qr{->$Ident|\.$Ident|\[[^]]*\]};
351 my $Lval = qr{$Ident(?:$Member)*};
322 352
323 # Pre-scan the patch looking for any __setup documentation. 353 # Pre-scan the patch looking for any __setup documentation.
324 my @setup_docs = (); 354 my @setup_docs = ();
@@ -466,16 +496,15 @@ sub process {
466 ERROR("use tabs not spaces\n" . $herevet); 496 ERROR("use tabs not spaces\n" . $herevet);
467 } 497 }
468 498
469 #
470 # The rest of our checks refer specifically to C style
471 # only apply those _outside_ comments.
472 #
473 next if ($in_comment);
474
475# Remove comments from the line before processing. 499# Remove comments from the line before processing.
476 $line =~ s@/\*.*\*/@@g; 500 my $comment_edge = ($line =~ s@/\*.*\*/@@g) +
477 $line =~ s@/\*.*@@; 501 ($line =~ s@/\*.*@@) +
478 $line =~ s@.*\*/@@; 502 ($line =~ s@^(.).*\*/@$1@);
503
504# The rest of our checks refer specifically to C style
505# only apply those _outside_ comments. Only skip
506# lines in the middle of comments.
507 next if (!$comment_edge && $in_comment);
479 508
480# Standardise the strings and chars within the input to simplify matching. 509# Standardise the strings and chars within the input to simplify matching.
481 $line = sanitise_line($line); 510 $line = sanitise_line($line);
@@ -509,7 +538,7 @@ sub process {
509# if/while/etc brace do not go on next line, unless defining a do while loop, 538# if/while/etc brace do not go on next line, unless defining a do while loop,
510# or if that brace on the next line is for something else 539# or if that brace on the next line is for something else
511 if ($line =~ /\b(?:(if|while|for|switch)\s*\(|do\b|else\b)/ && $line !~ /^.#/) { 540 if ($line =~ /\b(?:(if|while|for|switch)\s*\(|do\b|else\b)/ && $line !~ /^.#/) {
512 my @ctx = ctx_statement($linenr, $realcnt); 541 my @ctx = ctx_statement($linenr, $realcnt, 0);
513 my $ctx_ln = $linenr + $#ctx + 1; 542 my $ctx_ln = $linenr + $#ctx + 1;
514 my $ctx_cnt = $realcnt - $#ctx - 1; 543 my $ctx_cnt = $realcnt - $#ctx - 1;
515 my $ctx = join("\n", @ctx); 544 my $ctx = join("\n", @ctx);
@@ -521,7 +550,7 @@ sub process {
521 ##warn "line<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>"; 550 ##warn "line<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>";
522 551
523 if ($ctx !~ /{\s*/ && $ctx_cnt > 0 && $lines[$ctx_ln - 1] =~ /^\+\s*{/) { 552 if ($ctx !~ /{\s*/ && $ctx_cnt > 0 && $lines[$ctx_ln - 1] =~ /^\+\s*{/) {
524 ERROR("That { should be on the previous line\n" . 553 ERROR("That open brace { should be on the previous line\n" .
525 "$here\n$ctx\n$lines[$ctx_ln - 1]"); 554 "$here\n$ctx\n$lines[$ctx_ln - 1]");
526 } 555 }
527 } 556 }
@@ -535,6 +564,12 @@ sub process {
535 next; 564 next;
536 } 565 }
537 566
567# check for initialisation to aggregates open brace on the next line
568 if ($prevline =~ /$Declare\s*$Ident\s*=\s*$/ &&
569 $line =~ /^.\s*{/) {
570 ERROR("That open brace { should be on the previous line\n" . $hereprev);
571 }
572
538# 573#
539# Checks which are anchored on the added line. 574# Checks which are anchored on the added line.
540# 575#
@@ -565,13 +600,18 @@ sub process {
565 if (($prevline !~ /^}/) && 600 if (($prevline !~ /^}/) &&
566 ($prevline !~ /^\+}/) && 601 ($prevline !~ /^\+}/) &&
567 ($prevline !~ /^ }/) && 602 ($prevline !~ /^ }/) &&
568 ($prevline !~ /\s$name(?:\s+$Attribute)?\s*(?:;|=)/)) { 603 ($prevline !~ /\b\Q$name\E(?:\s+$Attribute)?\s*(?:;|=)/)) {
569 WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr); 604 WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr);
570 } 605 }
571 } 606 }
572 607
608# check for external initialisers.
609 if ($line =~ /^.$Type\s*$Ident\s*=\s*(0|NULL);/) {
610 ERROR("do not initialise externals to 0 or NULL\n" .
611 $herecurr);
612 }
573# check for static initialisers. 613# check for static initialisers.
574 if ($line=~/\s*static\s.*=\s+(0|NULL);/) { 614 if ($line =~ /\s*static\s.*=\s*(0|NULL);/) {
575 ERROR("do not initialise statics to 0 or NULL\n" . 615 ERROR("do not initialise statics to 0 or NULL\n" .
576 $herecurr); 616 $herecurr);
577 } 617 }
@@ -593,11 +633,11 @@ sub process {
593 ERROR("\"(foo $1 )\" should be \"(foo $1)\"\n" . 633 ERROR("\"(foo $1 )\" should be \"(foo $1)\"\n" .
594 $herecurr); 634 $herecurr);
595 635
596 } elsif ($line =~ m{$NonptrType(\*+)(?:\s+const)?\s+[A-Za-z\d_]+}) { 636 } elsif ($line =~ m{$NonptrType(\*+)(?:\s+$Attribute)?\s+[A-Za-z\d_]+}) {
597 ERROR("\"foo$1 bar\" should be \"foo $1bar\"\n" . 637 ERROR("\"foo$1 bar\" should be \"foo $1bar\"\n" .
598 $herecurr); 638 $herecurr);
599 639
600 } elsif ($line =~ m{$NonptrType\s+(\*+)(?!\s+const)\s+[A-Za-z\d_]+}) { 640 } elsif ($line =~ m{$NonptrType\s+(\*+)(?!\s+$Attribute)\s+[A-Za-z\d_]+}) {
601 ERROR("\"foo $1 bar\" should be \"foo $1bar\"\n" . 641 ERROR("\"foo $1 bar\" should be \"foo $1bar\"\n" .
602 $herecurr); 642 $herecurr);
603 } 643 }
@@ -614,7 +654,7 @@ sub process {
614# to try and find and validate the current printk. In summary the current 654# to try and find and validate the current printk. In summary the current
615# printk includes all preceeding printk's which have no newline on the end. 655# printk includes all preceeding printk's which have no newline on the end.
616# we assume the first bad printk is the one to report. 656# we assume the first bad printk is the one to report.
617 if ($line =~ /\bprintk\((?!KERN_)/) { 657 if ($line =~ /\bprintk\((?!KERN_)\s*"/) {
618 my $ok = 0; 658 my $ok = 0;
619 for (my $ln = $linenr - 1; $ln >= $first_line; $ln--) { 659 for (my $ln = $linenr - 1; $ln >= $first_line; $ln--) {
620 #print "CHECK<$lines[$ln - 1]\n"; 660 #print "CHECK<$lines[$ln - 1]\n";
@@ -639,6 +679,12 @@ sub process {
639 ERROR("open brace '{' following function declarations go on the next line\n" . $herecurr); 679 ERROR("open brace '{' following function declarations go on the next line\n" . $herecurr);
640 } 680 }
641 681
682# check for spaces between functions and their parentheses.
683 if ($line =~ /($Ident)\s+\(/ &&
684 $1 !~ /^(?:if|for|while|switch|return|volatile|__volatile__|__attribute__|format|__extension__|Copyright)$/ &&
685 $line !~ /$Type\s+\(/ && $line !~ /^.\#\s*define\b/) {
686 WARN("no space between function name and open parenthesis '('\n" . $herecurr);
687 }
642# Check operator spacing. 688# Check operator spacing.
643 # Note we expand the line with the leading + as the real 689 # Note we expand the line with the leading + as the real
644 # line will be displayed with the leading + and the tabs 690 # line will be displayed with the leading + and the tabs
@@ -647,7 +693,7 @@ sub process {
647 $opline = expand_tabs($opline); 693 $opline = expand_tabs($opline);
648 $opline =~ s/^./ /; 694 $opline =~ s/^./ /;
649 if (!($line=~/\#\s*include/)) { 695 if (!($line=~/\#\s*include/)) {
650 my @elements = split(/(<<=|>>=|<=|>=|==|!=|\+=|-=|\*=|\/=|%=|\^=|\|=|&=|->|<<|>>|<|>|=|!|~|&&|\|\||,|\^|\+\+|--|;|&|\||\+|-|\*|\/\/|\/)/, $opline); 696 my @elements = split(/(<<=|>>=|<=|>=|==|!=|\+=|-=|\*=|\/=|%=|\^=|\|=|&=|=>|->|<<|>>|<|>|=|!|~|&&|\|\||,|\^|\+\+|--|;|&|\||\+|-|\*|\/\/|\/)/, $opline);
651 my $off = 0; 697 my $off = 0;
652 for (my $n = 0; $n < $#elements; $n += 2) { 698 for (my $n = 0; $n < $#elements; $n += 2) {
653 $off += length($elements[$n]); 699 $off += length($elements[$n]);
@@ -667,6 +713,7 @@ sub process {
667 $c = 'W' if ($elements[$n + 2] =~ /^\s/); 713 $c = 'W' if ($elements[$n + 2] =~ /^\s/);
668 $c = 'B' if ($elements[$n + 2] =~ /^(\)|\]|;)/); 714 $c = 'B' if ($elements[$n + 2] =~ /^(\)|\]|;)/);
669 $c = 'O' if ($elements[$n + 2] eq ''); 715 $c = 'O' if ($elements[$n + 2] eq '');
716 $c = 'E' if ($elements[$n + 2] =~ /\s*\\$/);
670 } else { 717 } else {
671 $c = 'E'; 718 $c = 'E';
672 } 719 }
@@ -767,14 +814,39 @@ sub process {
767 814
768 # All the others need spaces both sides. 815 # All the others need spaces both sides.
769 } elsif ($ctx !~ /[EW]x[WE]/) { 816 } elsif ($ctx !~ /[EW]x[WE]/) {
770 ERROR("need spaces around that '$op' $at\n" . $hereptr); 817 # Ignore email addresses <foo@bar>
818 if (!($op eq '<' && $cb =~ /$;\S+\@\S+>/) &&
819 !($op eq '>' && $cb =~ /<\S+\@\S+$;/)) {
820 ERROR("need spaces around that '$op' $at\n" . $hereptr);
821 }
771 } 822 }
772 $off += length($elements[$n + 1]); 823 $off += length($elements[$n + 1]);
773 } 824 }
774 } 825 }
775 826
827# check for multiple assignments
828 if ($line =~ /^.\s*$Lval\s*=\s*$Lval\s*=(?!=)/) {
829 WARN("multiple assignments should be avoided\n" . $herecurr);
830 }
831
832## # check for multiple declarations, allowing for a function declaration
833## # continuation.
834## if ($line =~ /^.\s*$Type\s+$Ident(?:\s*=[^,{]*)?\s*,\s*$Ident.*/ &&
835## $line !~ /^.\s*$Type\s+$Ident(?:\s*=[^,{]*)?\s*,\s*$Type\s*$Ident.*/) {
836##
837## # Remove any bracketed sections to ensure we do not
838## # falsly report the parameters of functions.
839## my $ln = $line;
840## while ($ln =~ s/\([^\(\)]*\)//g) {
841## }
842## if ($ln =~ /,/) {
843## WARN("declaring multiple variables together should be avoided\n" . $herecurr);
844## }
845## }
846
776#need space before brace following if, while, etc 847#need space before brace following if, while, etc
777 if ($line =~ /\(.*\){/ || $line =~ /do{/) { 848 if (($line =~ /\(.*\){/ && $line !~ /\($Type\){/) ||
849 $line =~ /do{/) {
778 ERROR("need a space before the open brace '{'\n" . $herecurr); 850 ERROR("need a space before the open brace '{'\n" . $herecurr);
779 } 851 }
780 852
@@ -784,6 +856,22 @@ sub process {
784 ERROR("need a space after that close brace '}'\n" . $herecurr); 856 ERROR("need a space after that close brace '}'\n" . $herecurr);
785 } 857 }
786 858
859# check spacing on square brackets
860 if ($line =~ /\[\s/ && $line !~ /\[\s*$/) {
861 ERROR("no space after that open square bracket '['\n" . $herecurr);
862 }
863 if ($line =~ /\s\]/) {
864 ERROR("no space before that close square bracket ']'\n" . $herecurr);
865 }
866
867# check spacing on paretheses
868 if ($line =~ /\(\s/ && $line !~ /\(\s*$/) {
869 ERROR("no space after that open parenthesis '('\n" . $herecurr);
870 }
871 if ($line =~ /\s\)/) {
872 ERROR("no space before that close parenthesis ')'\n" . $herecurr);
873 }
874
787#goto labels aren't indented, allow a single space however 875#goto labels aren't indented, allow a single space however
788 if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and 876 if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and
789 !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) { 877 !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) {
@@ -847,13 +935,18 @@ sub process {
847 # or the one below. 935 # or the one below.
848 my $ln = $linenr; 936 my $ln = $linenr;
849 my $cnt = $realcnt; 937 my $cnt = $realcnt;
938 my $off = 0;
850 939
851 # If the macro starts on the define line start there. 940 # If the macro starts on the define line start
852 if ($prevline !~ m{^.#\s*define\s*$Ident(?:\([^\)]*\))?\s*\\\s*$}) { 941 # grabbing the statement after the identifier
942 $prevline =~ m{^(.#\s*define\s*$Ident(?:\([^\)]*\))?\s*)(.*)\\\s*$};
943 ##print "1<$1> 2<$2>\n";
944 if (defined $2 && $2 ne '') {
945 $off = length($1);
853 $ln--; 946 $ln--;
854 $cnt++; 947 $cnt++;
855 } 948 }
856 my @ctx = ctx_statement($ln, $cnt); 949 my @ctx = ctx_statement($ln, $cnt, $off);
857 my $ctx_ln = $ln + $#ctx + 1; 950 my $ctx_ln = $ln + $#ctx + 1;
858 my $ctx = join("\n", @ctx); 951 my $ctx = join("\n", @ctx);
859 952
@@ -873,6 +966,48 @@ sub process {
873 } 966 }
874 } 967 }
875 968
969# check for redundant bracing round if etc
970 if ($line =~ /\b(if|while|for|else)\b/) {
971 # Locate the end of the opening statement.
972 my @control = ctx_statement($linenr, $realcnt, 0);
973 my $nr = $linenr + (scalar(@control) - 1);
974 my $cnt = $realcnt - (scalar(@control) - 1);
975
976 my $off = $realcnt - $cnt;
977 #print "$off: line<$line>end<" . $lines[$nr - 1] . ">\n";
978
979 # If this is is a braced statement group check it
980 if ($lines[$nr - 1] =~ /{\s*$/) {
981 my ($lvl, @block) = ctx_block_level($nr, $cnt);
982
983 my $stmt = join(' ', @block);
984 $stmt =~ s/(^[^{]*){//;
985 my $before = $1;
986 $stmt =~ s/}([^}]*$)//;
987 my $after = $1;
988
989 #print "block<" . join(' ', @block) . "><" . scalar(@block) . ">\n";
990 #print "stmt<$stmt>\n\n";
991
992 # Count the ;'s if there is fewer than two
993 # then there can only be one statement,
994 # if there is a brace inside we cannot
995 # trivially detect if its one statement.
996 # Also nested if's often require braces to
997 # disambiguate the else binding so shhh there.
998 my @semi = ($stmt =~ /;/g);
999 push(@semi, "/**/") if ($stmt =~ m@/\*@);
1000 ##print "semi<" . scalar(@semi) . ">\n";
1001 if ($lvl == 0 && scalar(@semi) < 2 &&
1002 $stmt !~ /{/ && $stmt !~ /\bif\b/ &&
1003 $before !~ /}/ && $after !~ /{/) {
1004 my $herectx = "$here\n" . join("\n", @control, @block[1 .. $#block]) . "\n";
1005 shift(@block);
1006 WARN("braces {} are not necessary for single statement blocks\n" . $herectx);
1007 }
1008 }
1009 }
1010
876# don't include deprecated include files (uses RAW line) 1011# don't include deprecated include files (uses RAW line)
877 for my $inc (@dep_includes) { 1012 for my $inc (@dep_includes) {
878 if ($rawline =~ m@\#\s*include\s*\<$inc>@) { 1013 if ($rawline =~ m@\#\s*include\s*\<$inc>@) {
@@ -898,6 +1033,14 @@ sub process {
898 $herecurr); 1033 $herecurr);
899 } 1034 }
900 1035
1036# check for needless kfree() checks
1037 if ($prevline =~ /\bif\s*\(([^\)]*)\)/) {
1038 my $expr = $1;
1039 if ($line =~ /\bkfree\(\Q$expr\E\);/) {
1040 WARN("kfree(NULL) is safe this check is probabally not required\n" . $hereprev);
1041 }
1042 }
1043
901# warn about #ifdefs in C files 1044# warn about #ifdefs in C files
902# if ($line =~ /^.#\s*if(|n)def/ && ($realfile =~ /\.c$/)) { 1045# if ($line =~ /^.#\s*if(|n)def/ && ($realfile =~ /\.c$/)) {
903# print "#ifdef in C files should be avoided\n"; 1046# print "#ifdef in C files should be avoided\n";
@@ -905,6 +1048,11 @@ sub process {
905# $clean = 0; 1048# $clean = 0;
906# } 1049# }
907 1050
1051# warn about spacing in #ifdefs
1052 if ($line =~ /^.#\s*(ifdef|ifndef|elif)\s\s+/) {
1053 ERROR("exactly one space required after that #$1\n" . $herecurr);
1054 }
1055
908# check for spinlock_t definitions without a comment. 1056# check for spinlock_t definitions without a comment.
909 if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/) { 1057 if ($line =~ /^.\s*(struct\s+mutex|spinlock_t)\s+\S+;/) {
910 my $which = $1; 1058 my $which = $1;
@@ -919,14 +1067,14 @@ sub process {
919 } 1067 }
920 } 1068 }
921# check of hardware specific defines 1069# check of hardware specific defines
922 if ($line =~ m@^.#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@) { 1070 if ($line =~ m@^.#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@ && $realfile !~ m@include/asm-@) {
923 CHK("architecture specific defines should be avoided\n" . $herecurr); 1071 CHK("architecture specific defines should be avoided\n" . $herecurr);
924 } 1072 }
925 1073
926# check the location of the inline attribute, that it is between 1074# check the location of the inline attribute, that it is between
927# storage class and type. 1075# storage class and type.
928 if ($line =~ /$Type\s+(?:inline|__always_inline)\b/ || 1076 if ($line =~ /$Type\s+(?:inline|__always_inline|noinline)\b/ ||
929 $line =~ /\b(?:inline|always_inline)\s+$Storage/) { 1077 $line =~ /\b(?:inline|__always_inline|noinline)\s+$Storage/) {
930 ERROR("inline keyword should sit between storage class and type\n" . $herecurr); 1078 ERROR("inline keyword should sit between storage class and type\n" . $herecurr);
931 } 1079 }
932 1080
@@ -952,6 +1100,9 @@ sub process {
952 ERROR("Missing Signed-off-by: line(s)\n"); 1100 ERROR("Missing Signed-off-by: line(s)\n");
953 } 1101 }
954 1102
1103 if ($clean == 0 && ($chk_patch || $is_patch)) {
1104 print report_dump();
1105 }
955 if ($clean == 1 && $quiet == 0) { 1106 if ($clean == 1 && $quiet == 0) {
956 print "Your patch has no obvious style problems and is ready for submission.\n" 1107 print "Your patch has no obvious style problems and is ready for submission.\n"
957 } 1108 }
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
index f7844f6aa487..663158627155 100755
--- a/scripts/checkstack.pl
+++ b/scripts/checkstack.pl
@@ -12,6 +12,7 @@
12# sh64 port by Paul Mundt 12# sh64 port by Paul Mundt
13# Random bits by Matt Mackall <mpm@selenic.com> 13# Random bits by Matt Mackall <mpm@selenic.com>
14# M68k port by Geert Uytterhoeven and Andreas Schwab 14# M68k port by Geert Uytterhoeven and Andreas Schwab
15# AVR32 port by Haavard Skinnemoen <hskinnemoen@atmel.com>
15# 16#
16# Usage: 17# Usage:
17# objdump -d vmlinux | stackcheck.pl [arch] 18# objdump -d vmlinux | stackcheck.pl [arch]
@@ -37,6 +38,10 @@ my (@stack, $re, $x, $xs);
37 if ($arch eq 'arm') { 38 if ($arch eq 'arm') {
38 #c0008ffc: e24dd064 sub sp, sp, #100 ; 0x64 39 #c0008ffc: e24dd064 sub sp, sp, #100 ; 0x64
39 $re = qr/.*sub.*sp, sp, #(([0-9]{2}|[3-9])[0-9]{2})/o; 40 $re = qr/.*sub.*sp, sp, #(([0-9]{2}|[3-9])[0-9]{2})/o;
41 } elsif ($arch eq 'avr32') {
42 #8000008a: 20 1d sub sp,4
43 #80000ca8: fa cd 05 b0 sub sp,sp,1456
44 $re = qr/^.*sub.*sp.*,([0-9]{1,8})/o;
40 } elsif ($arch =~ /^i[3456]86$/) { 45 } elsif ($arch =~ /^i[3456]86$/) {
41 #c0105234: 81 ec ac 05 00 00 sub $0x5ac,%esp 46 #c0105234: 81 ec ac 05 00 00 sub $0x5ac,%esp
42 $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%esp$/o; 47 $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%esp$/o;
diff --git a/scripts/checksyscalls.sh b/scripts/checksyscalls.sh
index 0dcc01ce45a6..366f8c7f62bf 100755
--- a/scripts/checksyscalls.sh
+++ b/scripts/checksyscalls.sh
@@ -119,5 +119,5 @@ sed -n -e '/^\#define/ { s/[^_]*__NR_\([^[:space:]]*\).*/\
119\#endif/p }' $1 119\#endif/p }' $1
120} 120}
121 121
122(ignore_list && syscall_list ${srctree}/include/asm-i386/unistd.h) | \ 122(ignore_list && syscall_list ${srctree}/include/asm-x86/unistd_32.h) | \
123$* -E -x c - > /dev/null 123$* -E -x c - > /dev/null
diff --git a/scripts/cleanfile b/scripts/cleanfile
index f1ba8aa58a40..cefd29e52298 100755
--- a/scripts/cleanfile
+++ b/scripts/cleanfile
@@ -7,7 +7,9 @@
7use bytes; 7use bytes;
8use File::Basename; 8use File::Basename;
9 9
10# 10# Default options
11$max_width = 79;
12
11# Clean up space-tab sequences, either by removing spaces or 13# Clean up space-tab sequences, either by removing spaces or
12# replacing them with tabs. 14# replacing them with tabs.
13sub clean_space_tabs($) 15sub clean_space_tabs($)
@@ -48,9 +50,49 @@ sub clean_space_tabs($)
48 return $lo; 50 return $lo;
49} 51}
50 52
53# Compute the visual width of a string
54sub strwidth($) {
55 no bytes; # Tab alignment depends on characters
56
57 my($li) = @_;
58 my($c, $i);
59 my $pos = 0;
60 my $mlen = 0;
61
62 for ($i = 0; $i < length($li); $i++) {
63 $c = substr($li,$i,1);
64 if ($c eq "\t") {
65 $pos = ($pos+8) & ~7;
66 } elsif ($c eq "\n") {
67 $mlen = $pos if ($pos > $mlen);
68 $pos = 0;
69 } else {
70 $pos++;
71 }
72 }
73
74 $mlen = $pos if ($pos > $mlen);
75 return $mlen;
76}
77
51$name = basename($0); 78$name = basename($0);
52 79
53foreach $f ( @ARGV ) { 80@files = ();
81
82while (defined($a = shift(@ARGV))) {
83 if ($a =~ /^-/) {
84 if ($a eq '-width' || $a eq '-w') {
85 $max_width = shift(@ARGV)+0;
86 } else {
87 print STDERR "Usage: $name [-width #] files...\n";
88 exit 1;
89 }
90 } else {
91 push(@files, $a);
92 }
93}
94
95foreach $f ( @files ) {
54 print STDERR "$name: $f\n"; 96 print STDERR "$name: $f\n";
55 97
56 if (! -f $f) { 98 if (! -f $f) {
@@ -90,8 +132,10 @@ foreach $f ( @ARGV ) {
90 132
91 @blanks = (); 133 @blanks = ();
92 @lines = (); 134 @lines = ();
135 $lineno = 0;
93 136
94 while ( defined($line = <FILE>) ) { 137 while ( defined($line = <FILE>) ) {
138 $lineno++;
95 $in_bytes += length($line); 139 $in_bytes += length($line);
96 $line =~ s/[ \t\r]*$//; # Remove trailing spaces 140 $line =~ s/[ \t\r]*$//; # Remove trailing spaces
97 $line = clean_space_tabs($line); 141 $line = clean_space_tabs($line);
@@ -107,6 +151,12 @@ foreach $f ( @ARGV ) {
107 @blanks = (); 151 @blanks = ();
108 $blank_bytes = 0; 152 $blank_bytes = 0;
109 } 153 }
154
155 $l_width = strwidth($line);
156 if ($max_width && $l_width > $max_width) {
157 print STDERR
158 "$f:$lineno: line exceeds $max_width characters ($l_width)\n";
159 }
110 } 160 }
111 161
112 # Any blanks at the end of the file are discarded 162 # Any blanks at the end of the file are discarded
diff --git a/scripts/cleanpatch b/scripts/cleanpatch
index a53f987708f5..9680d03ad2b8 100755
--- a/scripts/cleanpatch
+++ b/scripts/cleanpatch
@@ -7,7 +7,9 @@
7use bytes; 7use bytes;
8use File::Basename; 8use File::Basename;
9 9
10# 10# Default options
11$max_width = 79;
12
11# Clean up space-tab sequences, either by removing spaces or 13# Clean up space-tab sequences, either by removing spaces or
12# replacing them with tabs. 14# replacing them with tabs.
13sub clean_space_tabs($) 15sub clean_space_tabs($)
@@ -48,9 +50,49 @@ sub clean_space_tabs($)
48 return $lo; 50 return $lo;
49} 51}
50 52
53# Compute the visual width of a string
54sub strwidth($) {
55 no bytes; # Tab alignment depends on characters
56
57 my($li) = @_;
58 my($c, $i);
59 my $pos = 0;
60 my $mlen = 0;
61
62 for ($i = 0; $i < length($li); $i++) {
63 $c = substr($li,$i,1);
64 if ($c eq "\t") {
65 $pos = ($pos+8) & ~7;
66 } elsif ($c eq "\n") {
67 $mlen = $pos if ($pos > $mlen);
68 $pos = 0;
69 } else {
70 $pos++;
71 }
72 }
73
74 $mlen = $pos if ($pos > $mlen);
75 return $mlen;
76}
77
51$name = basename($0); 78$name = basename($0);
52 79
53foreach $f ( @ARGV ) { 80@files = ();
81
82while (defined($a = shift(@ARGV))) {
83 if ($a =~ /^-/) {
84 if ($a eq '-width' || $a eq '-w') {
85 $max_width = shift(@ARGV)+0;
86 } else {
87 print STDERR "Usage: $name [-width #] files...\n";
88 exit 1;
89 }
90 } else {
91 push(@files, $a);
92 }
93}
94
95foreach $f ( @files ) {
54 print STDERR "$name: $f\n"; 96 print STDERR "$name: $f\n";
55 97
56 if (! -f $f) { 98 if (! -f $f) {
@@ -86,6 +128,7 @@ foreach $f ( @ARGV ) {
86 128
87 $in_bytes = 0; 129 $in_bytes = 0;
88 $out_bytes = 0; 130 $out_bytes = 0;
131 $lineno = 0;
89 132
90 @lines = (); 133 @lines = ();
91 134
@@ -93,10 +136,12 @@ foreach $f ( @ARGV ) {
93 $err = 0; 136 $err = 0;
94 137
95 while ( defined($line = <FILE>) ) { 138 while ( defined($line = <FILE>) ) {
139 $lineno++;
96 $in_bytes += length($line); 140 $in_bytes += length($line);
97 141
98 if (!$in_hunk) { 142 if (!$in_hunk) {
99 if ($line =~ /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@/) { 143 if ($line =~
144 /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@/) {
100 $minus_lines = $2; 145 $minus_lines = $2;
101 $plus_lines = $4; 146 $plus_lines = $4;
102 if ($minus_lines || $plus_lines) { 147 if ($minus_lines || $plus_lines) {
@@ -117,6 +162,13 @@ foreach $f ( @ARGV ) {
117 $text =~ s/[ \t\r]*$//; # Remove trailing spaces 162 $text =~ s/[ \t\r]*$//; # Remove trailing spaces
118 $text = clean_space_tabs($text); 163 $text = clean_space_tabs($text);
119 164
165 $l_width = strwidth($text);
166 if ($max_width && $l_width > $max_width) {
167 print STDERR
168 "$f:$lineno: adds line exceeds $max_width ",
169 "characters ($l_width)\n";
170 }
171
120 push(@hunk_lines, '+'.$text); 172 push(@hunk_lines, '+'.$text);
121 } elsif ($line =~ /^\-/) { 173 } elsif ($line =~ /^\-/) {
122 $minus_lines--; 174 $minus_lines--;
diff --git a/scripts/gcc-version.sh b/scripts/gcc-version.sh
index bb4fbeab8320..8a1d1879c7ad 100644
--- a/scripts/gcc-version.sh
+++ b/scripts/gcc-version.sh
@@ -1,14 +1,23 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# gcc-version gcc-command 3# gcc-version [-p] gcc-command
4# 4#
5# Prints the gcc version of `gcc-command' in a canonical 4-digit form 5# Prints the gcc version of `gcc-command' in a canonical 4-digit form
6# such as `0295' for gcc-2.95, `0303' for gcc-3.3, etc. 6# such as `0295' for gcc-2.95, `0303' for gcc-3.3, etc.
7# 7#
8# With the -p option, prints the patchlevel as well, for example `029503' for
9# gcc-2.95.3, `030301' for gcc-3.3.1, etc.
10#
11
12if [ $1 = "-p" ] ; then with_patchlevel=1; shift; fi
8 13
9compiler="$*" 14compiler="$*"
10 15
11MAJOR=$(echo __GNUC__ | $compiler -E -xc - | tail -n 1) 16MAJOR=$(echo __GNUC__ | $compiler -E -xc - | tail -n 1)
12MINOR=$(echo __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1) 17MINOR=$(echo __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1)
13printf "%02d%02d\\n" $MAJOR $MINOR 18if [ "x$with_patchlevel" != "x" ] ; then
14 19 PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -xc - | tail -n 1)
20 printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
21else
22 printf "%02d%02d\\n" $MAJOR $MINOR
23fi
diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
index 683eb12babbb..684fb9cdc055 100644
--- a/scripts/gen_initramfs_list.sh
+++ b/scripts/gen_initramfs_list.sh
@@ -19,11 +19,11 @@ $0 [-o <file>] [-u <uid>] [-g <gid>] {-d | <cpio_source>} ...
19 -o <file> Create gzipped initramfs file named <file> using 19 -o <file> Create gzipped initramfs file named <file> using
20 gen_init_cpio and gzip 20 gen_init_cpio and gzip
21 -u <uid> User ID to map to user ID 0 (root). 21 -u <uid> User ID to map to user ID 0 (root).
22 <uid> is only meaningful if <cpio_source> 22 <uid> is only meaningful if <cpio_source> is a
23 is a directory. 23 directory. "squash" forces all files to uid 0.
24 -g <gid> Group ID to map to group ID 0 (root). 24 -g <gid> Group ID to map to group ID 0 (root).
25 <gid> is only meaningful if <cpio_source> 25 <gid> is only meaningful if <cpio_source> is a
26 is a directory. 26 directory. "squash" forces all files to gid 0.
27 <cpio_source> File list or directory for cpio archive. 27 <cpio_source> File list or directory for cpio archive.
28 If <cpio_source> is a .cpio file it will be used 28 If <cpio_source> is a .cpio file it will be used
29 as direct input to initramfs. 29 as direct input to initramfs.
@@ -113,8 +113,8 @@ parse() {
113 local gid="$4" 113 local gid="$4"
114 local ftype=$(filetype "${location}") 114 local ftype=$(filetype "${location}")
115 # remap uid/gid to 0 if necessary 115 # remap uid/gid to 0 if necessary
116 [ "$uid" -eq "$root_uid" ] && uid=0 116 [ "$root_uid" = "squash" ] && uid=0 || [ "$uid" -eq "$root_uid" ] && uid=0
117 [ "$gid" -eq "$root_gid" ] && gid=0 117 [ "$root_gid" = "squash" ] && gid=0 || [ "$gid" -eq "$root_gid" ] && gid=0
118 local str="${mode} ${uid} ${gid}" 118 local str="${mode} ${uid} ${gid}"
119 119
120 [ "${ftype}" == "invalid" ] && return 0 120 [ "${ftype}" == "invalid" ] && return 0
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index 10b006694e5d..1f11d848532a 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -24,8 +24,6 @@
24 * 24 *
25 */ 25 */
26 26
27#define _GNU_SOURCE
28
29#include <stdio.h> 27#include <stdio.h>
30#include <stdlib.h> 28#include <stdlib.h>
31#include <string.h> 29#include <string.h>
@@ -378,6 +376,17 @@ static void build_initial_tok_table(void)
378 table_cnt = pos; 376 table_cnt = pos;
379} 377}
380 378
379static void *find_token(unsigned char *str, int len, unsigned char *token)
380{
381 int i;
382
383 for (i = 0; i < len - 1; i++) {
384 if (str[i] == token[0] && str[i+1] == token[1])
385 return &str[i];
386 }
387 return NULL;
388}
389
381/* replace a given token in all the valid symbols. Use the sampled symbols 390/* replace a given token in all the valid symbols. Use the sampled symbols
382 * to update the counts */ 391 * to update the counts */
383static void compress_symbols(unsigned char *str, int idx) 392static void compress_symbols(unsigned char *str, int idx)
@@ -391,7 +400,7 @@ static void compress_symbols(unsigned char *str, int idx)
391 p1 = table[i].sym; 400 p1 = table[i].sym;
392 401
393 /* find the token on the symbol */ 402 /* find the token on the symbol */
394 p2 = memmem(p1, len, str, 2); 403 p2 = find_token(p1, len, str);
395 if (!p2) continue; 404 if (!p2) continue;
396 405
397 /* decrease the counts for this symbol's tokens */ 406 /* decrease the counts for this symbol's tokens */
@@ -410,7 +419,7 @@ static void compress_symbols(unsigned char *str, int idx)
410 if (size < 2) break; 419 if (size < 2) break;
411 420
412 /* find the token on the symbol */ 421 /* find the token on the symbol */
413 p2 = memmem(p1, size, str, 2); 422 p2 = find_token(p1, size, str);
414 423
415 } while (p2); 424 } while (p2);
416 425
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index fb2bb3099dd9..8986a48c8c49 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -22,24 +22,25 @@ oldconfig: $(obj)/conf
22silentoldconfig: $(obj)/conf 22silentoldconfig: $(obj)/conf
23 $< -s arch/$(ARCH)/Kconfig 23 $< -s arch/$(ARCH)/Kconfig
24 24
25# Create new linux.po file
26# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
27# The symlink is used to repair a deficiency in arch/um
25update-po-config: $(obj)/kxgettext 28update-po-config: $(obj)/kxgettext
26 xgettext --default-domain=linux \ 29 xgettext --default-domain=linux \
27 --add-comments --keyword=_ --keyword=N_ \ 30 --add-comments --keyword=_ --keyword=N_ \
28 --files-from=scripts/kconfig/POTFILES.in \ 31 --from-code=UTF-8 \
29 --output scripts/kconfig/config.pot 32 --files-from=scripts/kconfig/POTFILES.in \
30 $(Q)ln -fs Kconfig_i386 arch/um/Kconfig_arch 33 --output $(obj)/config.pot
31 $(Q)for i in `ls arch/`; \ 34 $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot
32 do \ 35 $(Q)ln -fs Kconfig.i386 arch/um/Kconfig.arch
33 scripts/kconfig/kxgettext arch/$$i/Kconfig \ 36 (for i in `ls arch/`; \
34 | msguniq -o scripts/kconfig/linux_$${i}.pot; \ 37 do \
35 done 38 $(obj)/kxgettext arch/$$i/Kconfig; \
36 $(Q)msgcat scripts/kconfig/config.pot \ 39 done ) >> $(obj)/config.pot
37 `find scripts/kconfig/ -type f -name linux_*.pot` \ 40 msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
38 --output scripts/kconfig/linux_raw.pot 41 --output $(obj)/linux.pot
39 $(Q)msguniq --sort-by-file scripts/kconfig/linux_raw.pot \ 42 $(Q)rm -f arch/um/Kconfig.arch
40 --output scripts/kconfig/linux.pot 43 $(Q)rm -f $(obj)/config.pot
41 $(Q)rm -f arch/um/Kconfig_arch
42 $(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot
43 44
44PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig 45PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig
45 46
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 1199baf866ca..a38787a881ea 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -37,6 +37,14 @@ static struct menu *rootEntry;
37 37
38static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n"); 38static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n");
39 39
40static const char *get_help(struct menu *menu)
41{
42 if (menu_has_help(menu))
43 return menu_get_help(menu);
44 else
45 return nohelp_text;
46}
47
40static void strip(char *str) 48static void strip(char *str)
41{ 49{
42 char *p = str; 50 char *p = str;
@@ -64,7 +72,7 @@ static void check_stdin(void)
64 } 72 }
65} 73}
66 74
67static void conf_askvalue(struct symbol *sym, const char *def) 75static int conf_askvalue(struct symbol *sym, const char *def)
68{ 76{
69 enum symbol_type type = sym_get_type(sym); 77 enum symbol_type type = sym_get_type(sym);
70 tristate val; 78 tristate val;
@@ -79,7 +87,7 @@ static void conf_askvalue(struct symbol *sym, const char *def)
79 printf("%s\n", def); 87 printf("%s\n", def);
80 line[0] = '\n'; 88 line[0] = '\n';
81 line[1] = 0; 89 line[1] = 0;
82 return; 90 return 0;
83 } 91 }
84 92
85 switch (input_mode) { 93 switch (input_mode) {
@@ -89,23 +97,23 @@ static void conf_askvalue(struct symbol *sym, const char *def)
89 case set_random: 97 case set_random:
90 if (sym_has_value(sym)) { 98 if (sym_has_value(sym)) {
91 printf("%s\n", def); 99 printf("%s\n", def);
92 return; 100 return 0;
93 } 101 }
94 break; 102 break;
95 case ask_new: 103 case ask_new:
96 case ask_silent: 104 case ask_silent:
97 if (sym_has_value(sym)) { 105 if (sym_has_value(sym)) {
98 printf("%s\n", def); 106 printf("%s\n", def);
99 return; 107 return 0;
100 } 108 }
101 check_stdin(); 109 check_stdin();
102 case ask_all: 110 case ask_all:
103 fflush(stdout); 111 fflush(stdout);
104 fgets(line, 128, stdin); 112 fgets(line, 128, stdin);
105 return; 113 return 1;
106 case set_default: 114 case set_default:
107 printf("%s\n", def); 115 printf("%s\n", def);
108 return; 116 return 1;
109 default: 117 default:
110 break; 118 break;
111 } 119 }
@@ -115,7 +123,7 @@ static void conf_askvalue(struct symbol *sym, const char *def)
115 case S_HEX: 123 case S_HEX:
116 case S_STRING: 124 case S_STRING:
117 printf("%s\n", def); 125 printf("%s\n", def);
118 return; 126 return 1;
119 default: 127 default:
120 ; 128 ;
121 } 129 }
@@ -166,12 +174,13 @@ static void conf_askvalue(struct symbol *sym, const char *def)
166 break; 174 break;
167 } 175 }
168 printf("%s", line); 176 printf("%s", line);
177 return 1;
169} 178}
170 179
171int conf_string(struct menu *menu) 180int conf_string(struct menu *menu)
172{ 181{
173 struct symbol *sym = menu->sym; 182 struct symbol *sym = menu->sym;
174 const char *def, *help; 183 const char *def;
175 184
176 while (1) { 185 while (1) {
177 printf("%*s%s ", indent - 1, "", menu->prompt->text); 186 printf("%*s%s ", indent - 1, "", menu->prompt->text);
@@ -179,17 +188,15 @@ int conf_string(struct menu *menu)
179 def = sym_get_string_value(sym); 188 def = sym_get_string_value(sym);
180 if (sym_get_string_value(sym)) 189 if (sym_get_string_value(sym))
181 printf("[%s] ", def); 190 printf("[%s] ", def);
182 conf_askvalue(sym, def); 191 if (!conf_askvalue(sym, def))
192 return 0;
183 switch (line[0]) { 193 switch (line[0]) {
184 case '\n': 194 case '\n':
185 break; 195 break;
186 case '?': 196 case '?':
187 /* print help */ 197 /* print help */
188 if (line[1] == '\n') { 198 if (line[1] == '\n') {
189 help = nohelp_text; 199 printf("\n%s\n", get_help(menu));
190 if (menu->sym->help)
191 help = menu->sym->help;
192 printf("\n%s\n", menu->sym->help);
193 def = NULL; 200 def = NULL;
194 break; 201 break;
195 } 202 }
@@ -207,7 +214,6 @@ static int conf_sym(struct menu *menu)
207 struct symbol *sym = menu->sym; 214 struct symbol *sym = menu->sym;
208 int type; 215 int type;
209 tristate oldval, newval; 216 tristate oldval, newval;
210 const char *help;
211 217
212 while (1) { 218 while (1) {
213 printf("%*s%s ", indent - 1, "", menu->prompt->text); 219 printf("%*s%s ", indent - 1, "", menu->prompt->text);
@@ -233,10 +239,11 @@ static int conf_sym(struct menu *menu)
233 printf("/m"); 239 printf("/m");
234 if (oldval != yes && sym_tristate_within_range(sym, yes)) 240 if (oldval != yes && sym_tristate_within_range(sym, yes))
235 printf("/y"); 241 printf("/y");
236 if (sym->help) 242 if (menu_has_help(menu))
237 printf("/?"); 243 printf("/?");
238 printf("] "); 244 printf("] ");
239 conf_askvalue(sym, sym_get_string_value(sym)); 245 if (!conf_askvalue(sym, sym_get_string_value(sym)))
246 return 0;
240 strip(line); 247 strip(line);
241 248
242 switch (line[0]) { 249 switch (line[0]) {
@@ -269,10 +276,7 @@ static int conf_sym(struct menu *menu)
269 if (sym_set_tristate_value(sym, newval)) 276 if (sym_set_tristate_value(sym, newval))
270 return 0; 277 return 0;
271help: 278help:
272 help = nohelp_text; 279 printf("\n%s\n", get_help(menu));
273 if (sym->help)
274 help = sym->help;
275 printf("\n%s\n", help);
276 } 280 }
277} 281}
278 282
@@ -342,7 +346,7 @@ static int conf_choice(struct menu *menu)
342 goto conf_childs; 346 goto conf_childs;
343 } 347 }
344 printf("[1-%d", cnt); 348 printf("[1-%d", cnt);
345 if (sym->help) 349 if (menu_has_help(menu))
346 printf("?"); 350 printf("?");
347 printf("]: "); 351 printf("]: ");
348 switch (input_mode) { 352 switch (input_mode) {
@@ -359,8 +363,7 @@ static int conf_choice(struct menu *menu)
359 fgets(line, 128, stdin); 363 fgets(line, 128, stdin);
360 strip(line); 364 strip(line);
361 if (line[0] == '?') { 365 if (line[0] == '?') {
362 printf("\n%s\n", menu->sym->help ? 366 printf("\n%s\n", get_help(menu));
363 menu->sym->help : nohelp_text);
364 continue; 367 continue;
365 } 368 }
366 if (!line[0]) 369 if (!line[0])
@@ -391,8 +394,7 @@ static int conf_choice(struct menu *menu)
391 if (!child) 394 if (!child)
392 continue; 395 continue;
393 if (line[strlen(line) - 1] == '?') { 396 if (line[strlen(line) - 1] == '?') {
394 printf("\n%s\n", child->sym->help ? 397 printf("\n%s\n", get_help(child));
395 child->sym->help : nohelp_text);
396 continue; 398 continue;
397 } 399 }
398 sym_set_choice_value(sym, child->sym); 400 sym_set_choice_value(sym, child->sym);
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 664fe29dacef..b2913e9da495 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -341,27 +341,42 @@ int conf_read(const char *name)
341 conf_unsaved++; 341 conf_unsaved++;
342 /* maybe print value in verbose mode... */ 342 /* maybe print value in verbose mode... */
343 sym_ok: 343 sym_ok:
344 if (!sym_is_choice(sym))
345 continue;
346 /* The choice symbol only has a set value (and thus is not new)
347 * if all its visible childs have values.
348 */
349 prop = sym_get_choice_prop(sym);
350 flags = sym->flags;
351 for (e = prop->expr; e; e = e->left.expr)
352 if (e->right.sym->visible != no)
353 flags &= e->right.sym->flags;
354 sym->flags &= flags | ~SYMBOL_DEF_USER;
355 }
356
357 for_all_symbols(i, sym) {
344 if (sym_has_value(sym) && !sym_is_choice_value(sym)) { 358 if (sym_has_value(sym) && !sym_is_choice_value(sym)) {
345 if (sym->visible == no) 359 /* Reset values of generates values, so they'll appear
360 * as new, if they should become visible, but that
361 * doesn't quite work if the Kconfig and the saved
362 * configuration disagree.
363 */
364 if (sym->visible == no && !conf_unsaved)
346 sym->flags &= ~SYMBOL_DEF_USER; 365 sym->flags &= ~SYMBOL_DEF_USER;
347 switch (sym->type) { 366 switch (sym->type) {
348 case S_STRING: 367 case S_STRING:
349 case S_INT: 368 case S_INT:
350 case S_HEX: 369 case S_HEX:
351 if (!sym_string_within_range(sym, sym->def[S_DEF_USER].val)) 370 /* Reset a string value if it's out of range */
352 sym->flags &= ~(SYMBOL_VALID|SYMBOL_DEF_USER); 371 if (sym_string_within_range(sym, sym->def[S_DEF_USER].val))
372 break;
373 sym->flags &= ~(SYMBOL_VALID|SYMBOL_DEF_USER);
374 conf_unsaved++;
375 break;
353 default: 376 default:
354 break; 377 break;
355 } 378 }
356 } 379 }
357 if (!sym_is_choice(sym))
358 continue;
359 prop = sym_get_choice_prop(sym);
360 flags = sym->flags;
361 for (e = prop->expr; e; e = e->left.expr)
362 if (e->right.sym->visible != no)
363 flags &= e->right.sym->flags;
364 sym->flags &= flags | ~SYMBOL_DEF_USER;
365 } 380 }
366 381
367 sym_add_change_count(conf_warnings || conf_unsaved); 382 sym_add_change_count(conf_warnings || conf_unsaved);
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index 6084525f604b..a195986eec6f 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -71,14 +71,12 @@ enum {
71struct symbol { 71struct symbol {
72 struct symbol *next; 72 struct symbol *next;
73 char *name; 73 char *name;
74 char *help;
75 enum symbol_type type; 74 enum symbol_type type;
76 struct symbol_value curr; 75 struct symbol_value curr;
77 struct symbol_value def[4]; 76 struct symbol_value def[4];
78 tristate visible; 77 tristate visible;
79 int flags; 78 int flags;
80 struct property *prop; 79 struct property *prop;
81 struct expr *dep, *dep2;
82 struct expr_value rev_dep; 80 struct expr_value rev_dep;
83}; 81};
84 82
@@ -139,7 +137,7 @@ struct menu {
139 struct property *prompt; 137 struct property *prompt;
140 struct expr *dep; 138 struct expr *dep;
141 unsigned int flags; 139 unsigned int flags;
142 //char *help; 140 char *help;
143 struct file *file; 141 struct file *file;
144 int lineno; 142 int lineno;
145 void *data; 143 void *data;
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index 61d8166166ef..262908cfc2ac 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -38,9 +38,6 @@ static gboolean show_all = FALSE;
38static gboolean show_debug = FALSE; 38static gboolean show_debug = FALSE;
39static gboolean resizeable = FALSE; 39static gboolean resizeable = FALSE;
40 40
41static char nohelp_text[] =
42 N_("Sorry, no help available for this option yet.\n");
43
44GtkWidget *main_wnd = NULL; 41GtkWidget *main_wnd = NULL;
45GtkWidget *tree1_w = NULL; // left frame 42GtkWidget *tree1_w = NULL; // left frame
46GtkWidget *tree2_w = NULL; // right frame 43GtkWidget *tree2_w = NULL; // right frame
@@ -462,12 +459,9 @@ static void text_insert_help(struct menu *menu)
462 GtkTextIter start, end; 459 GtkTextIter start, end;
463 const char *prompt = menu_get_prompt(menu); 460 const char *prompt = menu_get_prompt(menu);
464 gchar *name; 461 gchar *name;
465 const char *help = _(nohelp_text); 462 const char *help;
466 463
467 if (!menu->sym) 464 help = _(menu_get_help(menu));
468 help = "";
469 else if (menu->sym->help)
470 help = _(menu->sym->help);
471 465
472 if (menu->sym && menu->sym->name) 466 if (menu->sym && menu->sym->name)
473 name = g_strdup_printf(_(menu->sym->name)); 467 name = g_strdup_printf(_(menu->sym->name));
diff --git a/scripts/kconfig/kxgettext.c b/scripts/kconfig/kxgettext.c
index abee55ca6174..6eb72a7f2562 100644
--- a/scripts/kconfig/kxgettext.c
+++ b/scripts/kconfig/kxgettext.c
@@ -170,8 +170,8 @@ void menu_build_message_list(struct menu *menu)
170 menu->file == NULL ? "Root Menu" : menu->file->name, 170 menu->file == NULL ? "Root Menu" : menu->file->name,
171 menu->lineno); 171 menu->lineno);
172 172
173 if (menu->sym != NULL && menu->sym->help != NULL) 173 if (menu->sym != NULL && menu_has_help(menu))
174 message__add(menu->sym->help, menu->sym->name, 174 message__add(menu_get_help(menu), menu->sym->name,
175 menu->file == NULL ? "Root Menu" : menu->file->name, 175 menu->file == NULL ? "Root Menu" : menu->file->name,
176 menu->lineno); 176 menu->lineno);
177 177
@@ -212,7 +212,9 @@ void menu__xgettext(void)
212 struct message *m = message__list; 212 struct message *m = message__list;
213 213
214 while (m != NULL) { 214 while (m != NULL) {
215 message__print_gettext_msgid_msgstr(m); 215 /* skip empty lines ("") */
216 if (strlen(m->msg) > sizeof("\"\""))
217 message__print_gettext_msgid_msgstr(m);
216 m = m->next; 218 m = m->next;
217 } 219 }
218} 220}
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index 15030770d1ad..4d09f6ddefe3 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -15,6 +15,8 @@ P(menu_is_visible,bool,(struct menu *menu));
15P(menu_get_prompt,const char *,(struct menu *menu)); 15P(menu_get_prompt,const char *,(struct menu *menu));
16P(menu_get_root_menu,struct menu *,(struct menu *menu)); 16P(menu_get_root_menu,struct menu *,(struct menu *menu));
17P(menu_get_parent_menu,struct menu *,(struct menu *menu)); 17P(menu_get_parent_menu,struct menu *,(struct menu *menu));
18P(menu_has_help,bool,(struct menu *menu));
19P(menu_get_help,const char *,(struct menu *menu));
18 20
19/* symbol.c */ 21/* symbol.c */
20P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); 22P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);
diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh
index cdca7388e0f1..9681476b96e7 100644
--- a/scripts/kconfig/lxdialog/check-lxdialog.sh
+++ b/scripts/kconfig/lxdialog/check-lxdialog.sh
@@ -51,7 +51,7 @@ usage() {
51 printf "Usage: $0 [-check compiler options|-header|-library]\n" 51 printf "Usage: $0 [-check compiler options|-header|-library]\n"
52} 52}
53 53
54if [ $# == 0 ]; then 54if [ $# -eq 0 ]; then
55 usage 55 usage
56 exit 1 56 exit 1
57fi 57fi
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index d0e4fa594fc7..bc5854ed6055 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -419,11 +419,13 @@ static void search_conf(void)
419{ 419{
420 struct symbol **sym_arr; 420 struct symbol **sym_arr;
421 struct gstr res; 421 struct gstr res;
422 char *dialog_input;
422 int dres; 423 int dres;
423again: 424again:
424 dialog_clear(); 425 dialog_clear();
425 dres = dialog_inputbox(_("Search Configuration Parameter"), 426 dres = dialog_inputbox(_("Search Configuration Parameter"),
426 _("Enter CONFIG_ (sub)string to search for (omit CONFIG_)"), 427 _("Enter CONFIG_ (sub)string to search for "
428 "(with or without \"CONFIG\")"),
427 10, 75, ""); 429 10, 75, "");
428 switch (dres) { 430 switch (dres) {
429 case 0: 431 case 0:
@@ -435,7 +437,12 @@ again:
435 return; 437 return;
436 } 438 }
437 439
438 sym_arr = sym_re_search(dialog_input_result); 440 /* strip CONFIG_ if necessary */
441 dialog_input = dialog_input_result;
442 if (strncasecmp(dialog_input_result, "CONFIG_", 7) == 0)
443 dialog_input += 7;
444
445 sym_arr = sym_re_search(dialog_input);
439 res = get_relations_str(sym_arr); 446 res = get_relations_str(sym_arr);
440 free(sym_arr); 447 free(sym_arr);
441 show_textbox(_("Search Results"), str_get(&res), 0, 0); 448 show_textbox(_("Search Results"), str_get(&res), 0, 0);
@@ -718,11 +725,11 @@ static void show_help(struct menu *menu)
718 struct gstr help = str_new(); 725 struct gstr help = str_new();
719 struct symbol *sym = menu->sym; 726 struct symbol *sym = menu->sym;
720 727
721 if (sym->help) 728 if (menu_has_help(menu))
722 { 729 {
723 if (sym->name) { 730 if (sym->name) {
724 str_printf(&help, "CONFIG_%s:\n\n", sym->name); 731 str_printf(&help, "CONFIG_%s:\n\n", sym->name);
725 str_append(&help, _(sym->help)); 732 str_append(&help, _(menu_get_help(menu)));
726 str_append(&help, "\n"); 733 str_append(&help, "\n");
727 } 734 }
728 } else { 735 } else {
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index f14aeac67d4f..f9d0d91a3fe4 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -417,3 +417,15 @@ struct menu *menu_get_parent_menu(struct menu *menu)
417 return menu; 417 return menu;
418} 418}
419 419
420bool menu_has_help(struct menu *menu)
421{
422 return menu->help != NULL;
423}
424
425const char *menu_get_help(struct menu *menu)
426{
427 if (menu->help)
428 return menu->help;
429 else
430 return "";
431}
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index f2a23a9c3938..e4eeb59a8c24 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -1041,7 +1041,7 @@ void ConfigInfoView::menuInfo(void)
1041 if (showDebug()) 1041 if (showDebug())
1042 debug = debug_info(sym); 1042 debug = debug_info(sym);
1043 1043
1044 help = print_filter(_(sym->help)); 1044 help = print_filter(_(menu_get_help(menu)));
1045 } else if (menu->prompt) { 1045 } else if (menu->prompt) {
1046 head += "<big><b>"; 1046 head += "<big><b>";
1047 head += print_filter(_(menu->prompt->text)); 1047 head += print_filter(_(menu->prompt->text));
diff --git a/scripts/kconfig/zconf.tab.c_shipped b/scripts/kconfig/zconf.tab.c_shipped
index 9a06b6771eee..ec21db77f78b 100644
--- a/scripts/kconfig/zconf.tab.c_shipped
+++ b/scripts/kconfig/zconf.tab.c_shipped
@@ -1722,7 +1722,7 @@ yyreduce:
1722 case 83: 1722 case 83:
1723 1723
1724 { 1724 {
1725 current_entry->sym->help = (yyvsp[0].string); 1725 current_entry->help = (yyvsp[0].string);
1726;} 1726;}
1727 break; 1727 break;
1728 1728
@@ -2280,11 +2280,11 @@ void print_symbol(FILE *out, struct menu *menu)
2280 break; 2280 break;
2281 } 2281 }
2282 } 2282 }
2283 if (sym->help) { 2283 if (menu->help) {
2284 int len = strlen(sym->help); 2284 int len = strlen(menu->help);
2285 while (sym->help[--len] == '\n') 2285 while (menu->help[--len] == '\n')
2286 sym->help[len] = 0; 2286 menu->help[len] = 0;
2287 fprintf(out, " help\n%s\n", sym->help); 2287 fprintf(out, " help\n%s\n", menu->help);
2288 } 2288 }
2289 fputc('\n', out); 2289 fputc('\n', out);
2290} 2290}
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 92eb02bdf9c5..79db4cf22a51 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -402,7 +402,7 @@ help_start: T_HELP T_EOL
402 402
403help: help_start T_HELPTEXT 403help: help_start T_HELPTEXT
404{ 404{
405 current_entry->sym->help = $2; 405 current_entry->help = $2;
406}; 406};
407 407
408/* depends option */ 408/* depends option */
@@ -649,11 +649,11 @@ void print_symbol(FILE *out, struct menu *menu)
649 break; 649 break;
650 } 650 }
651 } 651 }
652 if (sym->help) { 652 if (menu->help) {
653 int len = strlen(sym->help); 653 int len = strlen(menu->help);
654 while (sym->help[--len] == '\n') 654 while (menu->help[--len] == '\n')
655 sym->help[len] = 0; 655 menu->help[len] = 0;
656 fprintf(out, " help\n%s\n", sym->help); 656 fprintf(out, " help\n%s\n", menu->help);
657 } 657 }
658 fputc('\n', out); 658 fputc('\n', out);
659} 659}
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index e5bf649e516a..1f5835115cad 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -154,6 +154,7 @@ use strict;
154 154
155my $errors = 0; 155my $errors = 0;
156my $warnings = 0; 156my $warnings = 0;
157my $anon_struct_union = 0;
157 158
158# match expressions used to find embedded type information 159# match expressions used to find embedded type information
159my $type_constant = '\%([-_\w]+)'; 160my $type_constant = '\%([-_\w]+)';
@@ -403,7 +404,11 @@ sub output_highlight {
403 print $lineprefix, $blankline; 404 print $lineprefix, $blankline;
404 } else { 405 } else {
405 $line =~ s/\\\\\\/\&/g; 406 $line =~ s/\\\\\\/\&/g;
406 print $lineprefix, $line; 407 if ($output_mode eq "man" && substr($line, 0, 1) eq ".") {
408 print "\\&$line";
409 } else {
410 print $lineprefix, $line;
411 }
407 } 412 }
408 print "\n"; 413 print "\n";
409 } 414 }
@@ -718,6 +723,7 @@ sub output_struct_xml(%) {
718 # pointer-to-function 723 # pointer-to-function
719 print " $1 $parameter) ($2);\n"; 724 print " $1 $parameter) ($2);\n";
720 } elsif ($type =~ m/^(.*?)\s*(:.*)/) { 725 } elsif ($type =~ m/^(.*?)\s*(:.*)/) {
726 # bitfield
721 print " $1 $parameter$2;\n"; 727 print " $1 $parameter$2;\n";
722 } else { 728 } else {
723 print " ".$type." ".$parameter.";\n"; 729 print " ".$type." ".$parameter.";\n";
@@ -1260,6 +1266,7 @@ sub output_struct_text(%) {
1260 # pointer-to-function 1266 # pointer-to-function
1261 print "\t$1 $parameter) ($2);\n"; 1267 print "\t$1 $parameter) ($2);\n";
1262 } elsif ($type =~ m/^(.*?)\s*(:.*)/) { 1268 } elsif ($type =~ m/^(.*?)\s*(:.*)/) {
1269 # bitfield
1263 print "\t$1 $parameter$2;\n"; 1270 print "\t$1 $parameter$2;\n";
1264 } else { 1271 } else {
1265 print "\t".$type." ".$parameter.";\n"; 1272 print "\t".$type." ".$parameter.";\n";
@@ -1510,8 +1517,13 @@ sub push_parameter($$$) {
1510 my $param = shift; 1517 my $param = shift;
1511 my $type = shift; 1518 my $type = shift;
1512 my $file = shift; 1519 my $file = shift;
1513 my $anon = 0;
1514 1520
1521 if (($anon_struct_union == 1) && ($type eq "") &&
1522 ($param eq "}")) {
1523 return; # ignore the ending }; from anon. struct/union
1524 }
1525
1526 $anon_struct_union = 0;
1515 my $param_name = $param; 1527 my $param_name = $param;
1516 $param_name =~ s/\[.*//; 1528 $param_name =~ s/\[.*//;
1517 1529
@@ -1530,16 +1542,16 @@ sub push_parameter($$$) {
1530 # handle unnamed (anonymous) union or struct: 1542 # handle unnamed (anonymous) union or struct:
1531 { 1543 {
1532 $type = $param; 1544 $type = $param;
1533 $param = "{unnamed_" . $param. "}"; 1545 $param = "{unnamed_" . $param . "}";
1534 $parameterdescs{$param} = "anonymous\n"; 1546 $parameterdescs{$param} = "anonymous\n";
1535 $anon = 1; 1547 $anon_struct_union = 1;
1536 } 1548 }
1537 1549
1538 # warn if parameter has no description 1550 # warn if parameter has no description
1539 # (but ignore ones starting with # as these are not parameters 1551 # (but ignore ones starting with # as these are not parameters
1540 # but inline preprocessor statements); 1552 # but inline preprocessor statements);
1541 # also ignore unnamed structs/unions; 1553 # also ignore unnamed structs/unions;
1542 if (!$anon) { 1554 if (!$anon_struct_union) {
1543 if (!defined $parameterdescs{$param_name} && $param_name !~ /^#/) { 1555 if (!defined $parameterdescs{$param_name} && $param_name !~ /^#/) {
1544 1556
1545 $parameterdescs{$param_name} = $undescribed; 1557 $parameterdescs{$param_name} = $undescribed;
@@ -1691,6 +1703,8 @@ sub process_state3_function($$) {
1691 my $x = shift; 1703 my $x = shift;
1692 my $file = shift; 1704 my $file = shift;
1693 1705
1706 $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line
1707
1694 if ($x =~ m#\s*/\*\s+MACDOC\s*#io || ($x =~ /^#/ && $x !~ /^#define/)) { 1708 if ($x =~ m#\s*/\*\s+MACDOC\s*#io || ($x =~ /^#/ && $x !~ /^#define/)) {
1695 # do nothing 1709 # do nothing
1696 } 1710 }
@@ -1713,6 +1727,8 @@ sub process_state3_type($$) {
1713 $x =~ s@[\r\n]+@ @gos; # strip newlines/cr's. 1727 $x =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
1714 $x =~ s@^\s+@@gos; # strip leading spaces 1728 $x =~ s@^\s+@@gos; # strip leading spaces
1715 $x =~ s@\s+$@@gos; # strip trailing spaces 1729 $x =~ s@\s+$@@gos; # strip trailing spaces
1730 $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line
1731
1716 if ($x =~ /^#/) { 1732 if ($x =~ /^#/) {
1717 # To distinguish preprocessor directive from regular declaration later. 1733 # To distinguish preprocessor directive from regular declaration later.
1718 $x .= ";"; 1734 $x .= ";";
@@ -1796,7 +1812,7 @@ sub process_file($) {
1796 1812
1797 $state = 2; 1813 $state = 2;
1798 if (/-(.*)/) { 1814 if (/-(.*)/) {
1799 # strip leading/trailing/multiple spaces #RDD:T: 1815 # strip leading/trailing/multiple spaces
1800 $descr= $1; 1816 $descr= $1;
1801 $descr =~ s/^\s*//; 1817 $descr =~ s/^\s*//;
1802 $descr =~ s/\s*$//; 1818 $descr =~ s/\s*$//;
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index f646381dc015..36e3754db53a 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -290,6 +290,14 @@ static int do_serio_entry(const char *filename,
290 return 1; 290 return 1;
291} 291}
292 292
293/* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */
294static int do_acpi_entry(const char *filename,
295 struct acpi_device_id *id, char *alias)
296{
297 sprintf(alias, "acpi*:%s:", id->id);
298 return 1;
299}
300
293/* looks like: "pnp:dD" */ 301/* looks like: "pnp:dD" */
294static int do_pnp_entry(const char *filename, 302static int do_pnp_entry(const char *filename,
295 struct pnp_device_id *id, char *alias) 303 struct pnp_device_id *id, char *alias)
@@ -476,6 +484,36 @@ static int do_parisc_entry(const char *filename, struct parisc_device_id *id,
476 return 1; 484 return 1;
477} 485}
478 486
487/* Looks like: sdio:cNvNdN. */
488static int do_sdio_entry(const char *filename,
489 struct sdio_device_id *id, char *alias)
490{
491 id->class = TO_NATIVE(id->class);
492 id->vendor = TO_NATIVE(id->vendor);
493 id->device = TO_NATIVE(id->device);
494
495 strcpy(alias, "sdio:");
496 ADD(alias, "c", id->class != (__u8)SDIO_ANY_ID, id->class);
497 ADD(alias, "v", id->vendor != (__u16)SDIO_ANY_ID, id->vendor);
498 ADD(alias, "d", id->device != (__u16)SDIO_ANY_ID, id->device);
499 return 1;
500}
501
502/* Looks like: ssb:vNidNrevN. */
503static int do_ssb_entry(const char *filename,
504 struct ssb_device_id *id, char *alias)
505{
506 id->vendor = TO_NATIVE(id->vendor);
507 id->coreid = TO_NATIVE(id->coreid);
508 id->revision = TO_NATIVE(id->revision);
509
510 strcpy(alias, "ssb:");
511 ADD(alias, "v", id->vendor != SSB_ANY_VENDOR, id->vendor);
512 ADD(alias, "id", id->coreid != SSB_ANY_ID, id->coreid);
513 ADD(alias, "rev", id->revision != SSB_ANY_REV, id->revision);
514 return 1;
515}
516
479/* Ignore any prefix, eg. v850 prepends _ */ 517/* Ignore any prefix, eg. v850 prepends _ */
480static inline int sym_is(const char *symbol, const char *name) 518static inline int sym_is(const char *symbol, const char *name)
481{ 519{
@@ -551,6 +589,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
551 do_table(symval, sym->st_size, 589 do_table(symval, sym->st_size,
552 sizeof(struct serio_device_id), "serio", 590 sizeof(struct serio_device_id), "serio",
553 do_serio_entry, mod); 591 do_serio_entry, mod);
592 else if (sym_is(symname, "__mod_acpi_device_table"))
593 do_table(symval, sym->st_size,
594 sizeof(struct acpi_device_id), "acpi",
595 do_acpi_entry, mod);
554 else if (sym_is(symname, "__mod_pnp_device_table")) 596 else if (sym_is(symname, "__mod_pnp_device_table"))
555 do_table(symval, sym->st_size, 597 do_table(symval, sym->st_size,
556 sizeof(struct pnp_device_id), "pnp", 598 sizeof(struct pnp_device_id), "pnp",
@@ -587,6 +629,14 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
587 do_table(symval, sym->st_size, 629 do_table(symval, sym->st_size,
588 sizeof(struct parisc_device_id), "parisc", 630 sizeof(struct parisc_device_id), "parisc",
589 do_parisc_entry, mod); 631 do_parisc_entry, mod);
632 else if (sym_is(symname, "__mod_sdio_device_table"))
633 do_table(symval, sym->st_size,
634 sizeof(struct sdio_device_id), "sdio",
635 do_sdio_entry, mod);
636 else if (sym_is(symname, "__mod_ssb_device_table"))
637 do_table(symval, sym->st_size,
638 sizeof(struct ssb_device_id), "ssb",
639 do_ssb_entry, mod);
590} 640}
591 641
592/* Now add out buffered information to the generated C source */ 642/* Now add out buffered information to the generated C source */
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 3645e980da71..0a4051fbd34e 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -23,6 +23,8 @@ int have_vmlinux = 0;
23static int all_versions = 0; 23static int all_versions = 0;
24/* If we are modposting external module set to 1 */ 24/* If we are modposting external module set to 1 */
25static int external_module = 0; 25static int external_module = 0;
26/* Warn about section mismatch in vmlinux if set to 1 */
27static int vmlinux_section_warnings = 1;
26/* Only warn about unresolved symbols */ 28/* Only warn about unresolved symbols */
27static int warn_unresolved = 0; 29static int warn_unresolved = 0;
28/* How a symbol is exported */ 30/* How a symbol is exported */
@@ -75,7 +77,8 @@ static int is_vmlinux(const char *modname)
75 else 77 else
76 myname = modname; 78 myname = modname;
77 79
78 return strcmp(myname, "vmlinux") == 0; 80 return (strcmp(myname, "vmlinux") == 0) ||
81 (strcmp(myname, "vmlinux.o") == 0);
79} 82}
80 83
81void *do_nofail(void *ptr, const char *expr) 84void *do_nofail(void *ptr, const char *expr)
@@ -374,6 +377,7 @@ static int parse_elf(struct elf_info *info, const char *filename)
374 hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx); 377 hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx);
375 hdr->e_shnum = TO_NATIVE(hdr->e_shnum); 378 hdr->e_shnum = TO_NATIVE(hdr->e_shnum);
376 hdr->e_machine = TO_NATIVE(hdr->e_machine); 379 hdr->e_machine = TO_NATIVE(hdr->e_machine);
380 hdr->e_type = TO_NATIVE(hdr->e_type);
377 sechdrs = (void *)hdr + hdr->e_shoff; 381 sechdrs = (void *)hdr + hdr->e_shoff;
378 info->sechdrs = sechdrs; 382 info->sechdrs = sechdrs;
379 383
@@ -384,6 +388,8 @@ static int parse_elf(struct elf_info *info, const char *filename)
384 sechdrs[i].sh_size = TO_NATIVE(sechdrs[i].sh_size); 388 sechdrs[i].sh_size = TO_NATIVE(sechdrs[i].sh_size);
385 sechdrs[i].sh_link = TO_NATIVE(sechdrs[i].sh_link); 389 sechdrs[i].sh_link = TO_NATIVE(sechdrs[i].sh_link);
386 sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name); 390 sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name);
391 sechdrs[i].sh_info = TO_NATIVE(sechdrs[i].sh_info);
392 sechdrs[i].sh_addr = TO_NATIVE(sechdrs[i].sh_addr);
387 } 393 }
388 /* Find symbol table. */ 394 /* Find symbol table. */
389 for (i = 1; i < hdr->e_shnum; i++) { 395 for (i = 1; i < hdr->e_shnum; i++) {
@@ -580,13 +586,61 @@ static int strrcmp(const char *s, const char *sub)
580 return memcmp(s + slen - sublen, sub, sublen); 586 return memcmp(s + slen - sublen, sub, sublen);
581} 587}
582 588
589/*
590 * Functions used only during module init is marked __init and is stored in
591 * a .init.text section. Likewise data is marked __initdata and stored in
592 * a .init.data section.
593 * If this section is one of these sections return 1
594 * See include/linux/init.h for the details
595 */
596static int init_section(const char *name)
597{
598 if (strcmp(name, ".init") == 0)
599 return 1;
600 if (strncmp(name, ".init.", strlen(".init.")) == 0)
601 return 1;
602 return 0;
603}
604
605/*
606 * Functions used only during module exit is marked __exit and is stored in
607 * a .exit.text section. Likewise data is marked __exitdata and stored in
608 * a .exit.data section.
609 * If this section is one of these sections return 1
610 * See include/linux/init.h for the details
611 **/
612static int exit_section(const char *name)
613{
614 if (strcmp(name, ".exit.text") == 0)
615 return 1;
616 if (strcmp(name, ".exit.data") == 0)
617 return 1;
618 return 0;
619
620}
621
622/*
623 * Data sections are named like this:
624 * .data | .data.rel | .data.rel.*
625 * Return 1 if the specified section is a data section
626 */
627static int data_section(const char *name)
628{
629 if ((strcmp(name, ".data") == 0) ||
630 (strcmp(name, ".data.rel") == 0) ||
631 (strncmp(name, ".data.rel.", strlen(".data.rel.")) == 0))
632 return 1;
633 else
634 return 0;
635}
636
583/** 637/**
584 * Whitelist to allow certain references to pass with no warning. 638 * Whitelist to allow certain references to pass with no warning.
585 * 639 *
586 * Pattern 0: 640 * Pattern 0:
587 * Do not warn if funtion/data are marked with __init_refok/__initdata_refok. 641 * Do not warn if funtion/data are marked with __init_refok/__initdata_refok.
588 * The pattern is identified by: 642 * The pattern is identified by:
589 * fromsec = .text.init.refok | .data.init.refok 643 * fromsec = .text.init.refok* | .data.init.refok*
590 * 644 *
591 * Pattern 1: 645 * Pattern 1:
592 * If a module parameter is declared __initdata and permissions=0 646 * If a module parameter is declared __initdata and permissions=0
@@ -604,19 +658,15 @@ static int strrcmp(const char *s, const char *sub)
604 * These functions may often be marked __init and we do not want to 658 * These functions may often be marked __init and we do not want to
605 * warn here. 659 * warn here.
606 * the pattern is identified by: 660 * the pattern is identified by:
607 * tosec = .init.text | .exit.text | .init.data 661 * tosec = init or exit section
608 * fromsec = .data 662 * fromsec = data section
609 * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console 663 * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console, *_timer
610 * 664 *
611 * Pattern 3: 665 * Pattern 3:
612 * Whitelist all references from .pci_fixup* section to .init.text
613 * This is part of the PCI init when built-in
614 *
615 * Pattern 4:
616 * Whitelist all refereces from .text.head to .init.data 666 * Whitelist all refereces from .text.head to .init.data
617 * Whitelist all refereces from .text.head to .init.text 667 * Whitelist all refereces from .text.head to .init.text
618 * 668 *
619 * Pattern 5: 669 * Pattern 4:
620 * Some symbols belong to init section but still it is ok to reference 670 * Some symbols belong to init section but still it is ok to reference
621 * these from non-init sections as these symbols don't have any memory 671 * these from non-init sections as these symbols don't have any memory
622 * allocated for them and symbol address and value are same. So even 672 * allocated for them and symbol address and value are same. So even
@@ -625,42 +675,28 @@ static int strrcmp(const char *s, const char *sub)
625 * This pattern is identified by 675 * This pattern is identified by
626 * refsymname = __init_begin, _sinittext, _einittext 676 * refsymname = __init_begin, _sinittext, _einittext
627 * 677 *
628 * Pattern 7: 678 * Pattern 5:
629 * Logos used in drivers/video/logo reside in __initdata but the 679 * Xtensa uses literal sections for constants that are accessed PC-relative.
630 * funtion that references them are EXPORT_SYMBOL() so cannot be 680 * Literal sections may safely reference their text sections.
631 * marker __init. So we whitelist them here. 681 * (Note that the name for the literal section omits any trailing '.text')
632 * The pattern is: 682 * tosec = <section>[.text]
633 * tosec = .init.data 683 * fromsec = <section>.literal
634 * fromsec = .text*
635 * refsymname = logo_
636 *
637 * Pattern 8:
638 * Symbols contained in .paravirtprobe may safely reference .init.text.
639 * The pattern is:
640 * tosec = .init.text
641 * fromsec = .paravirtprobe
642 *
643 * Pattern 10:
644 * ia64 has machvec table for each platform and
645 * powerpc has a machine desc table for each platform.
646 * It is mixture of function pointers of .init.text and .text.
647 * fromsec = .machvec | .machine.desc
648 **/ 684 **/
649static int secref_whitelist(const char *modname, const char *tosec, 685static int secref_whitelist(const char *modname, const char *tosec,
650 const char *fromsec, const char *atsym, 686 const char *fromsec, const char *atsym,
651 const char *refsymname) 687 const char *refsymname)
652{ 688{
653 int f1 = 1, f2 = 1; 689 int len;
654 const char **s; 690 const char **s;
655 const char *pat2sym[] = { 691 const char *pat2sym[] = {
656 "driver", 692 "driver",
657 "_template", /* scsi uses *_template a lot */ 693 "_template", /* scsi uses *_template a lot */
694 "_timer", /* arm uses ops structures named _timer a lot */
658 "_sht", /* scsi also used *_sht to some extent */ 695 "_sht", /* scsi also used *_sht to some extent */
659 "_ops", 696 "_ops",
660 "_probe", 697 "_probe",
661 "_probe_one", 698 "_probe_one",
662 "_console", 699 "_console",
663 "apic_es7000",
664 NULL 700 NULL
665 }; 701 };
666 702
@@ -672,65 +708,41 @@ static int secref_whitelist(const char *modname, const char *tosec,
672 }; 708 };
673 709
674 /* Check for pattern 0 */ 710 /* Check for pattern 0 */
675 if ((strcmp(fromsec, ".text.init.refok") == 0) || 711 if ((strncmp(fromsec, ".text.init.refok", strlen(".text.init.refok")) == 0) ||
676 (strcmp(fromsec, ".data.init.refok") == 0)) 712 (strncmp(fromsec, ".exit.text.refok", strlen(".exit.text.refok")) == 0) ||
713 (strncmp(fromsec, ".data.init.refok", strlen(".data.init.refok")) == 0))
677 return 1; 714 return 1;
678 715
679 /* Check for pattern 1 */ 716 /* Check for pattern 1 */
680 if (strcmp(tosec, ".init.data") != 0) 717 if ((strcmp(tosec, ".init.data") == 0) &&
681 f1 = 0; 718 (strncmp(fromsec, ".data", strlen(".data")) == 0) &&
682 if (strncmp(fromsec, ".data", strlen(".data")) != 0) 719 (strncmp(atsym, "__param", strlen("__param")) == 0))
683 f1 = 0; 720 return 1;
684 if (strncmp(atsym, "__param", strlen("__param")) != 0)
685 f1 = 0;
686
687 if (f1)
688 return f1;
689 721
690 /* Check for pattern 2 */ 722 /* Check for pattern 2 */
691 if ((strcmp(tosec, ".init.text") != 0) && 723 if ((init_section(tosec) || exit_section(tosec)) && data_section(fromsec))
692 (strcmp(tosec, ".exit.text") != 0) && 724 for (s = pat2sym; *s; s++)
693 (strcmp(tosec, ".init.data") != 0)) 725 if (strrcmp(atsym, *s) == 0)
694 f2 = 0; 726 return 1;
695 if (strcmp(fromsec, ".data") != 0)
696 f2 = 0;
697
698 for (s = pat2sym; *s; s++)
699 if (strrcmp(atsym, *s) == 0)
700 f1 = 1;
701 if (f1 && f2)
702 return 1;
703 727
704 /* Check for pattern 3 */ 728 /* Check for pattern 3 */
705 if ((strncmp(fromsec, ".pci_fixup", strlen(".pci_fixup")) == 0) &&
706 (strcmp(tosec, ".init.text") == 0))
707 return 1;
708
709 /* Check for pattern 4 */
710 if ((strcmp(fromsec, ".text.head") == 0) && 729 if ((strcmp(fromsec, ".text.head") == 0) &&
711 ((strcmp(tosec, ".init.data") == 0) || 730 ((strcmp(tosec, ".init.data") == 0) ||
712 (strcmp(tosec, ".init.text") == 0))) 731 (strcmp(tosec, ".init.text") == 0)))
713 return 1; 732 return 1;
714 733
715 /* Check for pattern 5 */ 734 /* Check for pattern 4 */
716 for (s = pat3refsym; *s; s++) 735 for (s = pat3refsym; *s; s++)
717 if (strcmp(refsymname, *s) == 0) 736 if (strcmp(refsymname, *s) == 0)
718 return 1; 737 return 1;
719 738
720 /* Check for pattern 7 */ 739 /* Check for pattern 5 */
721 if ((strcmp(tosec, ".init.data") == 0) && 740 if (strrcmp(tosec, ".text") == 0)
722 (strncmp(fromsec, ".text", strlen(".text")) == 0) && 741 len = strlen(tosec) - strlen(".text");
723 (strncmp(refsymname, "logo_", strlen("logo_")) == 0)) 742 else
724 return 1; 743 len = strlen(tosec);
725 744 if ((strncmp(tosec, fromsec, len) == 0) && (strlen(fromsec) > len) &&
726 /* Check for pattern 8 */ 745 (strcmp(fromsec + len, ".literal") == 0))
727 if ((strcmp(tosec, ".init.text") == 0) &&
728 (strcmp(fromsec, ".paravirtprobe") == 0))
729 return 1;
730
731 /* Check for pattern 10 */
732 if ((strcmp(fromsec, ".machvec") == 0) ||
733 (strcmp(fromsec, ".machine.desc") == 0))
734 return 1; 746 return 1;
735 747
736 return 0; 748 return 0;
@@ -753,6 +765,8 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr,
753 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { 765 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
754 if (sym->st_shndx != relsym->st_shndx) 766 if (sym->st_shndx != relsym->st_shndx)
755 continue; 767 continue;
768 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
769 continue;
756 if (sym->st_value == addr) 770 if (sym->st_value == addr)
757 return sym; 771 return sym;
758 } 772 }
@@ -859,14 +873,9 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec,
859 refsymname = elf->strtab + refsym->st_name; 873 refsymname = elf->strtab + refsym->st_name;
860 874
861 /* check whitelist - we may ignore it */ 875 /* check whitelist - we may ignore it */
862 if (before && 876 if (secref_whitelist(modname, secname, fromsec,
863 secref_whitelist(modname, secname, fromsec, 877 before ? elf->strtab + before->st_name : "",
864 elf->strtab + before->st_name, refsymname)) 878 refsymname))
865 return;
866
867 /* fromsec whitelist - without a valid 'before'
868 * powerpc has a GOT table in .got2 section */
869 if (strcmp(fromsec, ".got2") == 0)
870 return; 879 return;
871 880
872 if (before && after) { 881 if (before && after) {
@@ -895,6 +904,78 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec,
895 } 904 }
896} 905}
897 906
907static unsigned int *reloc_location(struct elf_info *elf,
908 int rsection, Elf_Rela *r)
909{
910 Elf_Shdr *sechdrs = elf->sechdrs;
911 int section = sechdrs[rsection].sh_info;
912
913 return (void *)elf->hdr + sechdrs[section].sh_offset +
914 (r->r_offset - sechdrs[section].sh_addr);
915}
916
917static int addend_386_rel(struct elf_info *elf, int rsection, Elf_Rela *r)
918{
919 unsigned int r_typ = ELF_R_TYPE(r->r_info);
920 unsigned int *location = reloc_location(elf, rsection, r);
921
922 switch (r_typ) {
923 case R_386_32:
924 r->r_addend = TO_NATIVE(*location);
925 break;
926 case R_386_PC32:
927 r->r_addend = TO_NATIVE(*location) + 4;
928 /* For CONFIG_RELOCATABLE=y */
929 if (elf->hdr->e_type == ET_EXEC)
930 r->r_addend += r->r_offset;
931 break;
932 }
933 return 0;
934}
935
936static int addend_arm_rel(struct elf_info *elf, int rsection, Elf_Rela *r)
937{
938 unsigned int r_typ = ELF_R_TYPE(r->r_info);
939
940 switch (r_typ) {
941 case R_ARM_ABS32:
942 /* From ARM ABI: (S + A) | T */
943 r->r_addend = (int)(long)(elf->symtab_start + ELF_R_SYM(r->r_info));
944 break;
945 case R_ARM_PC24:
946 /* From ARM ABI: ((S + A) | T) - P */
947 r->r_addend = (int)(long)(elf->hdr + elf->sechdrs[rsection].sh_offset +
948 (r->r_offset - elf->sechdrs[rsection].sh_addr));
949 break;
950 default:
951 return 1;
952 }
953 return 0;
954}
955
956static int addend_mips_rel(struct elf_info *elf, int rsection, Elf_Rela *r)
957{
958 unsigned int r_typ = ELF_R_TYPE(r->r_info);
959 unsigned int *location = reloc_location(elf, rsection, r);
960 unsigned int inst;
961
962 if (r_typ == R_MIPS_HI16)
963 return 1; /* skip this */
964 inst = TO_NATIVE(*location);
965 switch (r_typ) {
966 case R_MIPS_LO16:
967 r->r_addend = inst & 0xffff;
968 break;
969 case R_MIPS_26:
970 r->r_addend = (inst & 0x03ffffff) << 2;
971 break;
972 case R_MIPS_32:
973 r->r_addend = inst;
974 break;
975 }
976 return 0;
977}
978
898/** 979/**
899 * A module includes a number of sections that are discarded 980 * A module includes a number of sections that are discarded
900 * either when loaded or when used as built-in. 981 * either when loaded or when used as built-in.
@@ -938,8 +1019,11 @@ static void check_sec_ref(struct module *mod, const char *modname,
938 r.r_offset = TO_NATIVE(rela->r_offset); 1019 r.r_offset = TO_NATIVE(rela->r_offset);
939#if KERNEL_ELFCLASS == ELFCLASS64 1020#if KERNEL_ELFCLASS == ELFCLASS64
940 if (hdr->e_machine == EM_MIPS) { 1021 if (hdr->e_machine == EM_MIPS) {
1022 unsigned int r_typ;
941 r_sym = ELF64_MIPS_R_SYM(rela->r_info); 1023 r_sym = ELF64_MIPS_R_SYM(rela->r_info);
942 r_sym = TO_NATIVE(r_sym); 1024 r_sym = TO_NATIVE(r_sym);
1025 r_typ = ELF64_MIPS_R_TYPE(rela->r_info);
1026 r.r_info = ELF64_R_INFO(r_sym, r_typ);
943 } else { 1027 } else {
944 r.r_info = TO_NATIVE(rela->r_info); 1028 r.r_info = TO_NATIVE(rela->r_info);
945 r_sym = ELF_R_SYM(r.r_info); 1029 r_sym = ELF_R_SYM(r.r_info);
@@ -972,8 +1056,11 @@ static void check_sec_ref(struct module *mod, const char *modname,
972 r.r_offset = TO_NATIVE(rel->r_offset); 1056 r.r_offset = TO_NATIVE(rel->r_offset);
973#if KERNEL_ELFCLASS == ELFCLASS64 1057#if KERNEL_ELFCLASS == ELFCLASS64
974 if (hdr->e_machine == EM_MIPS) { 1058 if (hdr->e_machine == EM_MIPS) {
1059 unsigned int r_typ;
975 r_sym = ELF64_MIPS_R_SYM(rel->r_info); 1060 r_sym = ELF64_MIPS_R_SYM(rel->r_info);
976 r_sym = TO_NATIVE(r_sym); 1061 r_sym = TO_NATIVE(r_sym);
1062 r_typ = ELF64_MIPS_R_TYPE(rel->r_info);
1063 r.r_info = ELF64_R_INFO(r_sym, r_typ);
977 } else { 1064 } else {
978 r.r_info = TO_NATIVE(rel->r_info); 1065 r.r_info = TO_NATIVE(rel->r_info);
979 r_sym = ELF_R_SYM(r.r_info); 1066 r_sym = ELF_R_SYM(r.r_info);
@@ -983,6 +1070,20 @@ static void check_sec_ref(struct module *mod, const char *modname,
983 r_sym = ELF_R_SYM(r.r_info); 1070 r_sym = ELF_R_SYM(r.r_info);
984#endif 1071#endif
985 r.r_addend = 0; 1072 r.r_addend = 0;
1073 switch (hdr->e_machine) {
1074 case EM_386:
1075 if (addend_386_rel(elf, i, &r))
1076 continue;
1077 break;
1078 case EM_ARM:
1079 if(addend_arm_rel(elf, i, &r))
1080 continue;
1081 break;
1082 case EM_MIPS:
1083 if (addend_mips_rel(elf, i, &r))
1084 continue;
1085 break;
1086 }
986 sym = elf->symtab_start + r_sym; 1087 sym = elf->symtab_start + r_sym;
987 /* Skip special sections */ 1088 /* Skip special sections */
988 if (sym->st_shndx >= SHN_LORESERVE) 1089 if (sym->st_shndx >= SHN_LORESERVE)
@@ -998,23 +1099,69 @@ static void check_sec_ref(struct module *mod, const char *modname,
998 } 1099 }
999} 1100}
1000 1101
1001/** 1102/*
1002 * Functions used only during module init is marked __init and is stored in 1103 * Identify sections from which references to either a
1003 * a .init.text section. Likewise data is marked __initdata and stored in 1104 * .init or a .exit section is OK.
1004 * a .init.data section. 1105 *
1005 * If this section is one of these sections return 1 1106 * [OPD] Keith Ownes <kaos@sgi.com> commented:
1006 * See include/linux/init.h for the details 1107 * For our future {in}sanity, add a comment that this is the ppc .opd
1007 **/ 1108 * section, not the ia64 .opd section.
1008static int init_section(const char *name) 1109 * ia64 .opd should not point to discarded sections.
1110 * [.rodata] like for .init.text we ignore .rodata references -same reason
1111 */
1112static int initexit_section_ref_ok(const char *name)
1009{ 1113{
1010 if (strcmp(name, ".init") == 0) 1114 const char **s;
1011 return 1; 1115 /* Absolute section names */
1012 if (strncmp(name, ".init.", strlen(".init.")) == 0) 1116 const char *namelist1[] = {
1013 return 1; 1117 "__bug_table", /* used by powerpc for BUG() */
1118 "__ex_table",
1119 ".altinstructions",
1120 ".cranges", /* used by sh64 */
1121 ".fixup",
1122 ".machvec", /* ia64 + powerpc uses these */
1123 ".machine.desc",
1124 ".opd", /* See comment [OPD] */
1125 "__dbe_table",
1126 ".parainstructions",
1127 ".pdr",
1128 ".plt", /* seen on ARCH=um build on x86_64. Harmless */
1129 ".smp_locks",
1130 ".stab",
1131 ".m68k_fixup",
1132 ".xt.prop", /* xtensa informational section */
1133 ".xt.lit", /* xtensa informational section */
1134 NULL
1135 };
1136 /* Start of section names */
1137 const char *namelist2[] = {
1138 ".debug",
1139 ".eh_frame",
1140 ".note", /* ignore ELF notes - may contain anything */
1141 ".got", /* powerpc - global offset table */
1142 ".toc", /* powerpc - table of contents */
1143 NULL
1144 };
1145 /* part of section name */
1146 const char *namelist3 [] = {
1147 ".unwind", /* Sample: IA_64.unwind.exit.text */
1148 NULL
1149 };
1150
1151 for (s = namelist1; *s; s++)
1152 if (strcmp(*s, name) == 0)
1153 return 1;
1154 for (s = namelist2; *s; s++)
1155 if (strncmp(*s, name, strlen(*s)) == 0)
1156 return 1;
1157 for (s = namelist3; *s; s++)
1158 if (strstr(name, *s) != NULL)
1159 return 1;
1014 return 0; 1160 return 0;
1015} 1161}
1016 1162
1017/** 1163
1164/*
1018 * Identify sections from which references to a .init section is OK. 1165 * Identify sections from which references to a .init section is OK.
1019 * 1166 *
1020 * Unfortunately references to read only data that referenced .init 1167 * Unfortunately references to read only data that referenced .init
@@ -1028,48 +1175,31 @@ static int init_section(const char *name)
1028 * 1175 *
1029 * where vgacon_startup is __init. If you want to wade through the false 1176 * where vgacon_startup is __init. If you want to wade through the false
1030 * positives, take out the check for rodata. 1177 * positives, take out the check for rodata.
1031 **/ 1178 */
1032static int init_section_ref_ok(const char *name) 1179static int init_section_ref_ok(const char *name)
1033{ 1180{
1034 const char **s; 1181 const char **s;
1035 /* Absolute section names */ 1182 /* Absolute section names */
1036 const char *namelist1[] = { 1183 const char *namelist1[] = {
1037 ".init", 1184 "__dbe_table", /* MIPS generate these */
1038 ".opd", /* see comment [OPD] at exit_section_ref_ok() */
1039 ".toc1", /* used by ppc64 */
1040 ".stab",
1041 ".data.rel.ro", /* used by parisc64 */
1042 ".parainstructions",
1043 ".text.lock",
1044 "__bug_table", /* used by powerpc for BUG() */
1045 ".pci_fixup_header",
1046 ".pci_fixup_final",
1047 ".pdr",
1048 "__param",
1049 "__ex_table",
1050 ".fixup",
1051 ".smp_locks",
1052 ".plt", /* seen on ARCH=um build on x86_64. Harmless */
1053 "__ftr_fixup", /* powerpc cpu feature fixup */ 1185 "__ftr_fixup", /* powerpc cpu feature fixup */
1054 "__fw_ftr_fixup", /* powerpc firmware feature fixup */ 1186 "__fw_ftr_fixup", /* powerpc firmware feature fixup */
1055 ".cranges", /* used by sh64 */ 1187 "__param",
1188 ".data.rel.ro", /* used by parisc64 */
1189 ".init",
1190 ".text.lock",
1056 NULL 1191 NULL
1057 }; 1192 };
1058 /* Start of section names */ 1193 /* Start of section names */
1059 const char *namelist2[] = { 1194 const char *namelist2[] = {
1060 ".init.", 1195 ".init.",
1061 ".altinstructions", 1196 ".pci_fixup",
1062 ".eh_frame",
1063 ".debug",
1064 ".parainstructions",
1065 ".rodata", 1197 ".rodata",
1066 NULL 1198 NULL
1067 }; 1199 };
1068 /* part of section name */ 1200
1069 const char *namelist3 [] = { 1201 if (initexit_section_ref_ok(name))
1070 ".unwind", /* sample: IA_64.unwind.init.text */ 1202 return 1;
1071 NULL
1072 };
1073 1203
1074 for (s = namelist1; *s; s++) 1204 for (s = namelist1; *s; s++)
1075 if (strcmp(*s, name) == 0) 1205 if (strcmp(*s, name) == 0)
@@ -1077,85 +1207,36 @@ static int init_section_ref_ok(const char *name)
1077 for (s = namelist2; *s; s++) 1207 for (s = namelist2; *s; s++)
1078 if (strncmp(*s, name, strlen(*s)) == 0) 1208 if (strncmp(*s, name, strlen(*s)) == 0)
1079 return 1; 1209 return 1;
1080 for (s = namelist3; *s; s++)
1081 if (strstr(name, *s) != NULL)
1082 return 1;
1083 if (strrcmp(name, ".init") == 0)
1084 return 1;
1085 return 0;
1086}
1087 1210
1088/* 1211 /* If section name ends with ".init" we allow references
1089 * Functions used only during module exit is marked __exit and is stored in 1212 * as is the case with .initcallN.init, .early_param.init, .taglist.init etc
1090 * a .exit.text section. Likewise data is marked __exitdata and stored in 1213 */
1091 * a .exit.data section. 1214 if (strrcmp(name, ".init") == 0)
1092 * If this section is one of these sections return 1
1093 * See include/linux/init.h for the details
1094 **/
1095static int exit_section(const char *name)
1096{
1097 if (strcmp(name, ".exit.text") == 0)
1098 return 1;
1099 if (strcmp(name, ".exit.data") == 0)
1100 return 1; 1215 return 1;
1101 return 0; 1216 return 0;
1102
1103} 1217}
1104 1218
1105/* 1219/*
1106 * Identify sections from which references to a .exit section is OK. 1220 * Identify sections from which references to a .exit section is OK.
1107 * 1221 */
1108 * [OPD] Keith Ownes <kaos@sgi.com> commented:
1109 * For our future {in}sanity, add a comment that this is the ppc .opd
1110 * section, not the ia64 .opd section.
1111 * ia64 .opd should not point to discarded sections.
1112 * [.rodata] like for .init.text we ignore .rodata references -same reason
1113 **/
1114static int exit_section_ref_ok(const char *name) 1222static int exit_section_ref_ok(const char *name)
1115{ 1223{
1116 const char **s; 1224 const char **s;
1117 /* Absolute section names */ 1225 /* Absolute section names */
1118 const char *namelist1[] = { 1226 const char *namelist1[] = {
1119 ".exit.text",
1120 ".exit.data", 1227 ".exit.data",
1121 ".init.text", 1228 ".exit.text",
1122 ".rodata",
1123 ".opd", /* See comment [OPD] */
1124 ".toc1", /* used by ppc64 */
1125 ".altinstructions",
1126 ".pdr",
1127 "__bug_table", /* used by powerpc for BUG() */
1128 ".exitcall.exit", 1229 ".exitcall.exit",
1129 ".eh_frame", 1230 ".rodata",
1130 ".parainstructions",
1131 ".stab",
1132 "__ex_table",
1133 ".fixup",
1134 ".smp_locks",
1135 ".plt", /* seen on ARCH=um build on x86_64. Harmless */
1136 ".cranges", /* used by sh64 */
1137 NULL
1138 };
1139 /* Start of section names */
1140 const char *namelist2[] = {
1141 ".debug",
1142 NULL
1143 };
1144 /* part of section name */
1145 const char *namelist3 [] = {
1146 ".unwind", /* Sample: IA_64.unwind.exit.text */
1147 NULL 1231 NULL
1148 }; 1232 };
1149 1233
1234 if (initexit_section_ref_ok(name))
1235 return 1;
1236
1150 for (s = namelist1; *s; s++) 1237 for (s = namelist1; *s; s++)
1151 if (strcmp(*s, name) == 0) 1238 if (strcmp(*s, name) == 0)
1152 return 1; 1239 return 1;
1153 for (s = namelist2; *s; s++)
1154 if (strncmp(*s, name, strlen(*s)) == 0)
1155 return 1;
1156 for (s = namelist3; *s; s++)
1157 if (strstr(name, *s) != NULL)
1158 return 1;
1159 return 0; 1240 return 0;
1160} 1241}
1161 1242
@@ -1198,8 +1279,10 @@ static void read_symbols(char *modname)
1198 handle_modversions(mod, &info, sym, symname); 1279 handle_modversions(mod, &info, sym, symname);
1199 handle_moddevtable(mod, &info, sym, symname); 1280 handle_moddevtable(mod, &info, sym, symname);
1200 } 1281 }
1201 check_sec_ref(mod, modname, &info, init_section, init_section_ref_ok); 1282 if (is_vmlinux(modname) && vmlinux_section_warnings) {
1202 check_sec_ref(mod, modname, &info, exit_section, exit_section_ref_ok); 1283 check_sec_ref(mod, modname, &info, init_section, init_section_ref_ok);
1284 check_sec_ref(mod, modname, &info, exit_section, exit_section_ref_ok);
1285 }
1203 1286
1204 version = get_modinfo(info.modinfo, info.modinfo_len, "version"); 1287 version = get_modinfo(info.modinfo, info.modinfo_len, "version");
1205 if (version) 1288 if (version)
@@ -1567,7 +1650,7 @@ int main(int argc, char **argv)
1567 int opt; 1650 int opt;
1568 int err; 1651 int err;
1569 1652
1570 while ((opt = getopt(argc, argv, "i:I:mo:aw")) != -1) { 1653 while ((opt = getopt(argc, argv, "i:I:mso:aw")) != -1) {
1571 switch(opt) { 1654 switch(opt) {
1572 case 'i': 1655 case 'i':
1573 kernel_read = optarg; 1656 kernel_read = optarg;
@@ -1585,6 +1668,9 @@ int main(int argc, char **argv)
1585 case 'a': 1668 case 'a':
1586 all_versions = 1; 1669 all_versions = 1;
1587 break; 1670 break;
1671 case 's':
1672 vmlinux_section_warnings = 0;
1673 break;
1588 case 'w': 1674 case 'w':
1589 warn_unresolved = 1; 1675 warn_unresolved = 1;
1590 break; 1676 break;
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 0858caa9c03f..4156dd34c5de 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -60,6 +60,9 @@ typedef union
60#define ELF64_MIPS_R_SYM(i) \ 60#define ELF64_MIPS_R_SYM(i) \
61 ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym) 61 ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym)
62 62
63#define ELF64_MIPS_R_TYPE(i) \
64 ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type1)
65
63#if KERNEL_ELFDATA != HOST_ELFDATA 66#if KERNEL_ELFDATA != HOST_ELFDATA
64 67
65static inline void __endian(const void *src, void *dest, unsigned int size) 68static inline void __endian(const void *src, void *dest, unsigned int size)
diff --git a/scripts/namespace.pl b/scripts/namespace.pl
index f34373853ef8..c6e88c652c2f 100755
--- a/scripts/namespace.pl
+++ b/scripts/namespace.pl
@@ -105,7 +105,7 @@ sub linux_objects
105 if (/.*\.o$/ && 105 if (/.*\.o$/ &&
106 ! ( 106 ! (
107 m:/built-in.o$: 107 m:/built-in.o$:
108 || m:arch/i386/kernel/vsyscall-syms.o$: 108 || m:arch/x86/kernel/vsyscall-syms.o$:
109 || m:arch/ia64/ia32/ia32.o$: 109 || m:arch/ia64/ia32/ia32.o$:
110 || m:arch/ia64/kernel/gate-syms.o$: 110 || m:arch/ia64/kernel/gate-syms.o$:
111 || m:arch/ia64/lib/__divdi3.o$: 111 || m:arch/ia64/lib/__divdi3.o$:
@@ -328,9 +328,9 @@ sub list_multiply_defined
328 } 328 }
329 # Special case for i386 entry code 329 # Special case for i386 entry code
330 if ($#{$def{$name}} == 1 && $name =~ /^__kernel_/ && 330 if ($#{$def{$name}} == 1 && $name =~ /^__kernel_/ &&
331 $def{$name}[0] eq "arch/i386/kernel/vsyscall-int80.o" && 331 $def{$name}[0] eq "arch/x86/kernel/vsyscall-int80_32.o" &&
332 $def{$name}[1] eq "arch/i386/kernel/vsyscall-sysenter.o") { 332 $def{$name}[1] eq "arch/x86/kernel/vsyscall-sysenter_32.o") {
333 &drop_def("arch/i386/kernel/vsyscall-sysenter.o", $name); 333 &drop_def("arch/x86/kernel/vsyscall-sysenter_32.o", $name);
334 next; 334 next;
335 } 335 }
336 printf "$name is multiply defined in :-\n"; 336 printf "$name is multiply defined in :-\n";
diff --git a/scripts/ver_linux b/scripts/ver_linux
index 72876dfadc8a..8f8df93141a9 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -66,8 +66,8 @@ showmount --version 2>&1 | grep nfs-utils | awk \
66'NR==1{print "nfs-utils ", $NF}' 66'NR==1{print "nfs-utils ", $NF}'
67 67
68ls -l `ldd /bin/sh | awk '/libc/{print $3}'` | sed \ 68ls -l `ldd /bin/sh | awk '/libc/{print $3}'` | sed \
69-e 's/\.so$//' | awk -F'[.-]' '{print "Linux C Library " \ 69-e 's/\.so$//' | sed -e 's/>//' | \
70$(NF-2)"."$(NF-1)"."$NF}' 70awk -F'[.-]' '{print "Linux C Library "$(NF-1)"."$NF}'
71 71
72ldd -v > /dev/null 2>&1 && ldd -v || ldd --version |head -n 1 | awk \ 72ldd -v > /dev/null 2>&1 && ldd -v || ldd --version |head -n 1 | awk \
73'NR==1{print "Dynamic linker (ldd) ", $NF}' 73'NR==1{print "Dynamic linker (ldd) ", $NF}'