aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-19 17:28:19 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-19 17:28:19 -0400
commitefffbeee5bc4168059683714b300d307f5193d69 (patch)
tree7fde51080f4534a86bfa27a430aaf7ef2bb8ef92 /scripts
parent40b42f1ebf653cd72c32eb1a1a0b9fea2dfbfd7d (diff)
parentb824325443bb010689d22262c6a4e0feb63bad56 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild
* git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild: (33 commits) xtensa: use DATA_DATA in xtensa powerpc: add missing DATA_DATA to powerpc cris: use DATA_DATA in cris kallsyms: remove usage of memmem and _GNU_SOURCE from scripts/kallsyms.c kbuild: use -fno-optimize-sibling-calls unconditionally kconfig: reset generated values only if Kconfig and .config agree. kbuild: fix the warning when running make tags kconfig: strip 'CONFIG_' automatically in kernel configuration search kbuild: use POSIX BRE in headers install target Whitelist references from __dbe_table to .init modpost white list pattern adjustment kbuild: do section mismatch check on full vmlinux kbuild: whitelist references from variables named _timer to .init.text kbuild: remove hardcoded _logo names from modpost kbuild: remove hardcoded apic_es7000 from modpost kbuild: warn about references from .init.text to .exit.text kbuild: consolidate section checks kbuild: refactor code in modpost to improve maintainability kbuild: ignore section mismatch warnings originating from .note section kbuild: .paravirtprobe section is obsolete, so modpost doesn't need to handle it ...
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Kbuild.include7
-rw-r--r--scripts/Makefile.build16
-rw-r--r--scripts/Makefile.headersinst14
-rw-r--r--scripts/Makefile.modpost4
-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/confdata.c37
-rw-r--r--scripts/kconfig/kxgettext.c4
-rw-r--r--scripts/kconfig/lxdialog/check-lxdialog.sh2
-rw-r--r--scripts/kconfig/mconf.c11
-rw-r--r--scripts/mod/modpost.c312
-rw-r--r--scripts/mod/modpost.h3
16 files changed, 414 insertions, 187 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/Makefile.build b/scripts/Makefile.build
index a525112847fd..3f7b451f3955 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
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..c6fcc597b3be 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -70,10 +70,10 @@ __modpost: $(modules:.ko=.o) FORCE
70 $(call cmd,modpost) $(wildcard vmlinux) $(filter-out FORCE,$^) 70 $(call cmd,modpost) $(wildcard vmlinux) $(filter-out FORCE,$^)
71 71
72quiet_cmd_kernel-mod = MODPOST $@ 72quiet_cmd_kernel-mod = MODPOST $@
73 cmd_kernel-mod = $(cmd_modpost) $(KBUILD_VMLINUX_OBJS) 73 cmd_kernel-mod = $(cmd_modpost) $@
74 74
75PHONY += vmlinux 75PHONY += vmlinux
76vmlinux: FORCE 76vmlinux.o: FORCE
77 $(call cmd,kernel-mod) 77 $(call cmd,kernel-mod)
78 78
79# Declare generated files as targets for modpost 79# Declare generated files as targets for modpost
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/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/kxgettext.c b/scripts/kconfig/kxgettext.c
index abee55ca6174..11f7dab94715 100644
--- a/scripts/kconfig/kxgettext.c
+++ b/scripts/kconfig/kxgettext.c
@@ -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/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..d2c2a429887b 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);
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 3645e980da71..04579a517900 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -75,7 +75,8 @@ static int is_vmlinux(const char *modname)
75 else 75 else
76 myname = modname; 76 myname = modname;
77 77
78 return strcmp(myname, "vmlinux") == 0; 78 return (strcmp(myname, "vmlinux") == 0) ||
79 (strcmp(myname, "vmlinux.o") == 0);
79} 80}
80 81
81void *do_nofail(void *ptr, const char *expr) 82void *do_nofail(void *ptr, const char *expr)
@@ -374,6 +375,7 @@ static int parse_elf(struct elf_info *info, const char *filename)
374 hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx); 375 hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx);
375 hdr->e_shnum = TO_NATIVE(hdr->e_shnum); 376 hdr->e_shnum = TO_NATIVE(hdr->e_shnum);
376 hdr->e_machine = TO_NATIVE(hdr->e_machine); 377 hdr->e_machine = TO_NATIVE(hdr->e_machine);
378 hdr->e_type = TO_NATIVE(hdr->e_type);
377 sechdrs = (void *)hdr + hdr->e_shoff; 379 sechdrs = (void *)hdr + hdr->e_shoff;
378 info->sechdrs = sechdrs; 380 info->sechdrs = sechdrs;
379 381
@@ -384,6 +386,8 @@ static int parse_elf(struct elf_info *info, const char *filename)
384 sechdrs[i].sh_size = TO_NATIVE(sechdrs[i].sh_size); 386 sechdrs[i].sh_size = TO_NATIVE(sechdrs[i].sh_size);
385 sechdrs[i].sh_link = TO_NATIVE(sechdrs[i].sh_link); 387 sechdrs[i].sh_link = TO_NATIVE(sechdrs[i].sh_link);
386 sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name); 388 sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name);
389 sechdrs[i].sh_info = TO_NATIVE(sechdrs[i].sh_info);
390 sechdrs[i].sh_addr = TO_NATIVE(sechdrs[i].sh_addr);
387 } 391 }
388 /* Find symbol table. */ 392 /* Find symbol table. */
389 for (i = 1; i < hdr->e_shnum; i++) { 393 for (i = 1; i < hdr->e_shnum; i++) {
@@ -605,18 +609,14 @@ static int strrcmp(const char *s, const char *sub)
605 * warn here. 609 * warn here.
606 * the pattern is identified by: 610 * the pattern is identified by:
607 * tosec = .init.text | .exit.text | .init.data 611 * tosec = .init.text | .exit.text | .init.data
608 * fromsec = .data 612 * fromsec = .data | .data.rel | .data.rel.*
609 * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console 613 * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console, *_timer
610 * 614 *
611 * Pattern 3: 615 * 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 616 * Whitelist all refereces from .text.head to .init.data
617 * Whitelist all refereces from .text.head to .init.text 617 * Whitelist all refereces from .text.head to .init.text
618 * 618 *
619 * Pattern 5: 619 * Pattern 4:
620 * Some symbols belong to init section but still it is ok to reference 620 * 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 621 * 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 622 * allocated for them and symbol address and value are same. So even
@@ -625,26 +625,6 @@ static int strrcmp(const char *s, const char *sub)
625 * This pattern is identified by 625 * This pattern is identified by
626 * refsymname = __init_begin, _sinittext, _einittext 626 * refsymname = __init_begin, _sinittext, _einittext
627 * 627 *
628 * Pattern 7:
629 * Logos used in drivers/video/logo reside in __initdata but the
630 * funtion that references them are EXPORT_SYMBOL() so cannot be
631 * marker __init. So we whitelist them here.
632 * The pattern is:
633 * tosec = .init.data
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 **/ 628 **/
649static int secref_whitelist(const char *modname, const char *tosec, 629static int secref_whitelist(const char *modname, const char *tosec,
650 const char *fromsec, const char *atsym, 630 const char *fromsec, const char *atsym,
@@ -655,12 +635,12 @@ static int secref_whitelist(const char *modname, const char *tosec,
655 const char *pat2sym[] = { 635 const char *pat2sym[] = {
656 "driver", 636 "driver",
657 "_template", /* scsi uses *_template a lot */ 637 "_template", /* scsi uses *_template a lot */
638 "_timer", /* arm uses ops structures named _timer a lot */
658 "_sht", /* scsi also used *_sht to some extent */ 639 "_sht", /* scsi also used *_sht to some extent */
659 "_ops", 640 "_ops",
660 "_probe", 641 "_probe",
661 "_probe_one", 642 "_probe_one",
662 "_console", 643 "_console",
663 "apic_es7000",
664 NULL 644 NULL
665 }; 645 };
666 646
@@ -692,7 +672,9 @@ static int secref_whitelist(const char *modname, const char *tosec,
692 (strcmp(tosec, ".exit.text") != 0) && 672 (strcmp(tosec, ".exit.text") != 0) &&
693 (strcmp(tosec, ".init.data") != 0)) 673 (strcmp(tosec, ".init.data") != 0))
694 f2 = 0; 674 f2 = 0;
695 if (strcmp(fromsec, ".data") != 0) 675 if ((strcmp(fromsec, ".data") != 0) &&
676 (strcmp(fromsec, ".data.rel") != 0) &&
677 (strncmp(fromsec, ".data.rel.", strlen(".data.rel.")) != 0))
696 f2 = 0; 678 f2 = 0;
697 679
698 for (s = pat2sym; *s; s++) 680 for (s = pat2sym; *s; s++)
@@ -702,37 +684,16 @@ static int secref_whitelist(const char *modname, const char *tosec,
702 return 1; 684 return 1;
703 685
704 /* Check for pattern 3 */ 686 /* 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) && 687 if ((strcmp(fromsec, ".text.head") == 0) &&
711 ((strcmp(tosec, ".init.data") == 0) || 688 ((strcmp(tosec, ".init.data") == 0) ||
712 (strcmp(tosec, ".init.text") == 0))) 689 (strcmp(tosec, ".init.text") == 0)))
713 return 1; 690 return 1;
714 691
715 /* Check for pattern 5 */ 692 /* Check for pattern 4 */
716 for (s = pat3refsym; *s; s++) 693 for (s = pat3refsym; *s; s++)
717 if (strcmp(refsymname, *s) == 0) 694 if (strcmp(refsymname, *s) == 0)
718 return 1; 695 return 1;
719 696
720 /* Check for pattern 7 */
721 if ((strcmp(tosec, ".init.data") == 0) &&
722 (strncmp(fromsec, ".text", strlen(".text")) == 0) &&
723 (strncmp(refsymname, "logo_", strlen("logo_")) == 0))
724 return 1;
725
726 /* Check for pattern 8 */
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;
735
736 return 0; 697 return 0;
737} 698}
738 699
@@ -753,6 +714,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++) { 714 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
754 if (sym->st_shndx != relsym->st_shndx) 715 if (sym->st_shndx != relsym->st_shndx)
755 continue; 716 continue;
717 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
718 continue;
756 if (sym->st_value == addr) 719 if (sym->st_value == addr)
757 return sym; 720 return sym;
758 } 721 }
@@ -864,11 +827,6 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec,
864 elf->strtab + before->st_name, refsymname)) 827 elf->strtab + before->st_name, refsymname))
865 return; 828 return;
866 829
867 /* fromsec whitelist - without a valid 'before'
868 * powerpc has a GOT table in .got2 section */
869 if (strcmp(fromsec, ".got2") == 0)
870 return;
871
872 if (before && after) { 830 if (before && after) {
873 warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s " 831 warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s "
874 "(between '%s' and '%s')\n", 832 "(between '%s' and '%s')\n",
@@ -895,6 +853,78 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec,
895 } 853 }
896} 854}
897 855
856static unsigned int *reloc_location(struct elf_info *elf,
857 int rsection, Elf_Rela *r)
858{
859 Elf_Shdr *sechdrs = elf->sechdrs;
860 int section = sechdrs[rsection].sh_info;
861
862 return (void *)elf->hdr + sechdrs[section].sh_offset +
863 (r->r_offset - sechdrs[section].sh_addr);
864}
865
866static int addend_386_rel(struct elf_info *elf, int rsection, Elf_Rela *r)
867{
868 unsigned int r_typ = ELF_R_TYPE(r->r_info);
869 unsigned int *location = reloc_location(elf, rsection, r);
870
871 switch (r_typ) {
872 case R_386_32:
873 r->r_addend = TO_NATIVE(*location);
874 break;
875 case R_386_PC32:
876 r->r_addend = TO_NATIVE(*location) + 4;
877 /* For CONFIG_RELOCATABLE=y */
878 if (elf->hdr->e_type == ET_EXEC)
879 r->r_addend += r->r_offset;
880 break;
881 }
882 return 0;
883}
884
885static int addend_arm_rel(struct elf_info *elf, int rsection, Elf_Rela *r)
886{
887 unsigned int r_typ = ELF_R_TYPE(r->r_info);
888
889 switch (r_typ) {
890 case R_ARM_ABS32:
891 /* From ARM ABI: (S + A) | T */
892 r->r_addend = (int)(long)(elf->symtab_start + ELF_R_SYM(r->r_info));
893 break;
894 case R_ARM_PC24:
895 /* From ARM ABI: ((S + A) | T) - P */
896 r->r_addend = (int)(long)(elf->hdr + elf->sechdrs[rsection].sh_offset +
897 (r->r_offset - elf->sechdrs[rsection].sh_addr));
898 break;
899 default:
900 return 1;
901 }
902 return 0;
903}
904
905static int addend_mips_rel(struct elf_info *elf, int rsection, Elf_Rela *r)
906{
907 unsigned int r_typ = ELF_R_TYPE(r->r_info);
908 unsigned int *location = reloc_location(elf, rsection, r);
909 unsigned int inst;
910
911 if (r_typ == R_MIPS_HI16)
912 return 1; /* skip this */
913 inst = TO_NATIVE(*location);
914 switch (r_typ) {
915 case R_MIPS_LO16:
916 r->r_addend = inst & 0xffff;
917 break;
918 case R_MIPS_26:
919 r->r_addend = (inst & 0x03ffffff) << 2;
920 break;
921 case R_MIPS_32:
922 r->r_addend = inst;
923 break;
924 }
925 return 0;
926}
927
898/** 928/**
899 * A module includes a number of sections that are discarded 929 * A module includes a number of sections that are discarded
900 * either when loaded or when used as built-in. 930 * either when loaded or when used as built-in.
@@ -938,8 +968,11 @@ static void check_sec_ref(struct module *mod, const char *modname,
938 r.r_offset = TO_NATIVE(rela->r_offset); 968 r.r_offset = TO_NATIVE(rela->r_offset);
939#if KERNEL_ELFCLASS == ELFCLASS64 969#if KERNEL_ELFCLASS == ELFCLASS64
940 if (hdr->e_machine == EM_MIPS) { 970 if (hdr->e_machine == EM_MIPS) {
971 unsigned int r_typ;
941 r_sym = ELF64_MIPS_R_SYM(rela->r_info); 972 r_sym = ELF64_MIPS_R_SYM(rela->r_info);
942 r_sym = TO_NATIVE(r_sym); 973 r_sym = TO_NATIVE(r_sym);
974 r_typ = ELF64_MIPS_R_TYPE(rela->r_info);
975 r.r_info = ELF64_R_INFO(r_sym, r_typ);
943 } else { 976 } else {
944 r.r_info = TO_NATIVE(rela->r_info); 977 r.r_info = TO_NATIVE(rela->r_info);
945 r_sym = ELF_R_SYM(r.r_info); 978 r_sym = ELF_R_SYM(r.r_info);
@@ -972,8 +1005,11 @@ static void check_sec_ref(struct module *mod, const char *modname,
972 r.r_offset = TO_NATIVE(rel->r_offset); 1005 r.r_offset = TO_NATIVE(rel->r_offset);
973#if KERNEL_ELFCLASS == ELFCLASS64 1006#if KERNEL_ELFCLASS == ELFCLASS64
974 if (hdr->e_machine == EM_MIPS) { 1007 if (hdr->e_machine == EM_MIPS) {
1008 unsigned int r_typ;
975 r_sym = ELF64_MIPS_R_SYM(rel->r_info); 1009 r_sym = ELF64_MIPS_R_SYM(rel->r_info);
976 r_sym = TO_NATIVE(r_sym); 1010 r_sym = TO_NATIVE(r_sym);
1011 r_typ = ELF64_MIPS_R_TYPE(rel->r_info);
1012 r.r_info = ELF64_R_INFO(r_sym, r_typ);
977 } else { 1013 } else {
978 r.r_info = TO_NATIVE(rel->r_info); 1014 r.r_info = TO_NATIVE(rel->r_info);
979 r_sym = ELF_R_SYM(r.r_info); 1015 r_sym = ELF_R_SYM(r.r_info);
@@ -983,6 +1019,20 @@ static void check_sec_ref(struct module *mod, const char *modname,
983 r_sym = ELF_R_SYM(r.r_info); 1019 r_sym = ELF_R_SYM(r.r_info);
984#endif 1020#endif
985 r.r_addend = 0; 1021 r.r_addend = 0;
1022 switch (hdr->e_machine) {
1023 case EM_386:
1024 if (addend_386_rel(elf, i, &r))
1025 continue;
1026 break;
1027 case EM_ARM:
1028 if(addend_arm_rel(elf, i, &r))
1029 continue;
1030 break;
1031 case EM_MIPS:
1032 if (addend_mips_rel(elf, i, &r))
1033 continue;
1034 break;
1035 }
986 sym = elf->symtab_start + r_sym; 1036 sym = elf->symtab_start + r_sym;
987 /* Skip special sections */ 1037 /* Skip special sections */
988 if (sym->st_shndx >= SHN_LORESERVE) 1038 if (sym->st_shndx >= SHN_LORESERVE)
@@ -998,6 +1048,63 @@ static void check_sec_ref(struct module *mod, const char *modname,
998 } 1048 }
999} 1049}
1000 1050
1051/*
1052 * Identify sections from which references to either a
1053 * .init or a .exit section is OK.
1054 *
1055 * [OPD] Keith Ownes <kaos@sgi.com> commented:
1056 * For our future {in}sanity, add a comment that this is the ppc .opd
1057 * section, not the ia64 .opd section.
1058 * ia64 .opd should not point to discarded sections.
1059 * [.rodata] like for .init.text we ignore .rodata references -same reason
1060 */
1061static int initexit_section_ref_ok(const char *name)
1062{
1063 const char **s;
1064 /* Absolute section names */
1065 const char *namelist1[] = {
1066 "__bug_table", /* used by powerpc for BUG() */
1067 "__ex_table",
1068 ".altinstructions",
1069 ".cranges", /* used by sh64 */
1070 ".fixup",
1071 ".machvec", /* ia64 + powerpc uses these */
1072 ".machine.desc",
1073 ".opd", /* See comment [OPD] */
1074 ".parainstructions",
1075 ".pdr",
1076 ".plt", /* seen on ARCH=um build on x86_64. Harmless */
1077 ".smp_locks",
1078 ".stab",
1079 NULL
1080 };
1081 /* Start of section names */
1082 const char *namelist2[] = {
1083 ".debug",
1084 ".eh_frame",
1085 ".note", /* ignore ELF notes - may contain anything */
1086 ".got", /* powerpc - global offset table */
1087 ".toc", /* powerpc - table of contents */
1088 NULL
1089 };
1090 /* part of section name */
1091 const char *namelist3 [] = {
1092 ".unwind", /* Sample: IA_64.unwind.exit.text */
1093 NULL
1094 };
1095
1096 for (s = namelist1; *s; s++)
1097 if (strcmp(*s, name) == 0)
1098 return 1;
1099 for (s = namelist2; *s; s++)
1100 if (strncmp(*s, name, strlen(*s)) == 0)
1101 return 1;
1102 for (s = namelist3; *s; s++)
1103 if (strstr(name, *s) != NULL)
1104 return 1;
1105 return 0;
1106}
1107
1001/** 1108/**
1002 * Functions used only during module init is marked __init and is stored in 1109 * Functions used only during module init is marked __init and is stored in
1003 * a .init.text section. Likewise data is marked __initdata and stored in 1110 * a .init.text section. Likewise data is marked __initdata and stored in
@@ -1014,7 +1121,7 @@ static int init_section(const char *name)
1014 return 0; 1121 return 0;
1015} 1122}
1016 1123
1017/** 1124/*
1018 * Identify sections from which references to a .init section is OK. 1125 * Identify sections from which references to a .init section is OK.
1019 * 1126 *
1020 * Unfortunately references to read only data that referenced .init 1127 * Unfortunately references to read only data that referenced .init
@@ -1028,48 +1135,31 @@ static int init_section(const char *name)
1028 * 1135 *
1029 * where vgacon_startup is __init. If you want to wade through the false 1136 * where vgacon_startup is __init. If you want to wade through the false
1030 * positives, take out the check for rodata. 1137 * positives, take out the check for rodata.
1031 **/ 1138 */
1032static int init_section_ref_ok(const char *name) 1139static int init_section_ref_ok(const char *name)
1033{ 1140{
1034 const char **s; 1141 const char **s;
1035 /* Absolute section names */ 1142 /* Absolute section names */
1036 const char *namelist1[] = { 1143 const char *namelist1[] = {
1037 ".init", 1144 "__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 */ 1145 "__ftr_fixup", /* powerpc cpu feature fixup */
1054 "__fw_ftr_fixup", /* powerpc firmware feature fixup */ 1146 "__fw_ftr_fixup", /* powerpc firmware feature fixup */
1055 ".cranges", /* used by sh64 */ 1147 "__param",
1148 ".data.rel.ro", /* used by parisc64 */
1149 ".init",
1150 ".text.lock",
1056 NULL 1151 NULL
1057 }; 1152 };
1058 /* Start of section names */ 1153 /* Start of section names */
1059 const char *namelist2[] = { 1154 const char *namelist2[] = {
1060 ".init.", 1155 ".init.",
1061 ".altinstructions", 1156 ".pci_fixup",
1062 ".eh_frame",
1063 ".debug",
1064 ".parainstructions",
1065 ".rodata", 1157 ".rodata",
1066 NULL 1158 NULL
1067 }; 1159 };
1068 /* part of section name */ 1160
1069 const char *namelist3 [] = { 1161 if (initexit_section_ref_ok(name))
1070 ".unwind", /* sample: IA_64.unwind.init.text */ 1162 return 1;
1071 NULL
1072 };
1073 1163
1074 for (s = namelist1; *s; s++) 1164 for (s = namelist1; *s; s++)
1075 if (strcmp(*s, name) == 0) 1165 if (strcmp(*s, name) == 0)
@@ -1077,9 +1167,10 @@ static int init_section_ref_ok(const char *name)
1077 for (s = namelist2; *s; s++) 1167 for (s = namelist2; *s; s++)
1078 if (strncmp(*s, name, strlen(*s)) == 0) 1168 if (strncmp(*s, name, strlen(*s)) == 0)
1079 return 1; 1169 return 1;
1080 for (s = namelist3; *s; s++) 1170
1081 if (strstr(name, *s) != NULL) 1171 /* If section name ends with ".init" we allow references
1082 return 1; 1172 * as is the case with .initcallN.init, .early_param.init, .taglist.init etc
1173 */
1083 if (strrcmp(name, ".init") == 0) 1174 if (strrcmp(name, ".init") == 0)
1084 return 1; 1175 return 1;
1085 return 0; 1176 return 0;
@@ -1104,58 +1195,25 @@ static int exit_section(const char *name)
1104 1195
1105/* 1196/*
1106 * Identify sections from which references to a .exit section is OK. 1197 * Identify sections from which references to a .exit section is OK.
1107 * 1198 */
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) 1199static int exit_section_ref_ok(const char *name)
1115{ 1200{
1116 const char **s; 1201 const char **s;
1117 /* Absolute section names */ 1202 /* Absolute section names */
1118 const char *namelist1[] = { 1203 const char *namelist1[] = {
1119 ".exit.text",
1120 ".exit.data", 1204 ".exit.data",
1121 ".init.text", 1205 ".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", 1206 ".exitcall.exit",
1129 ".eh_frame", 1207 ".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 1208 NULL
1148 }; 1209 };
1149 1210
1211 if (initexit_section_ref_ok(name))
1212 return 1;
1213
1150 for (s = namelist1; *s; s++) 1214 for (s = namelist1; *s; s++)
1151 if (strcmp(*s, name) == 0) 1215 if (strcmp(*s, name) == 0)
1152 return 1; 1216 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; 1217 return 0;
1160} 1218}
1161 1219
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)