diff options
Diffstat (limited to 'scripts')
31 files changed, 974 insertions, 299 deletions
diff --git a/scripts/Makefile.dtbinst b/scripts/Makefile.dtbinst index 909ed7a2ac61..1c15717e0d56 100644 --- a/scripts/Makefile.dtbinst +++ b/scripts/Makefile.dtbinst | |||
@@ -18,7 +18,7 @@ export dtbinst-root ?= $(obj) | |||
18 | 18 | ||
19 | include include/config/auto.conf | 19 | include include/config/auto.conf |
20 | include scripts/Kbuild.include | 20 | include scripts/Kbuild.include |
21 | include $(srctree)/$(obj)/Makefile | 21 | include $(src)/Makefile |
22 | 22 | ||
23 | PHONY += __dtbs_install_prep | 23 | PHONY += __dtbs_install_prep |
24 | __dtbs_install_prep: | 24 | __dtbs_install_prep: |
diff --git a/scripts/Makefile.fwinst b/scripts/Makefile.fwinst index 5b698add4f31..b27290035253 100644 --- a/scripts/Makefile.fwinst +++ b/scripts/Makefile.fwinst | |||
@@ -13,7 +13,7 @@ src := $(obj) | |||
13 | -include $(objtree)/.config | 13 | -include $(objtree)/.config |
14 | 14 | ||
15 | include scripts/Kbuild.include | 15 | include scripts/Kbuild.include |
16 | include $(srctree)/$(obj)/Makefile | 16 | include $(src)/Makefile |
17 | 17 | ||
18 | include scripts/Makefile.host | 18 | include scripts/Makefile.host |
19 | 19 | ||
diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan index 631619b2b118..3f874d24234f 100644 --- a/scripts/Makefile.kasan +++ b/scripts/Makefile.kasan | |||
@@ -13,12 +13,16 @@ CFLAGS_KASAN := $(call cc-option, -fsanitize=kernel-address \ | |||
13 | --param asan-instrumentation-with-call-threshold=$(call_threshold)) | 13 | --param asan-instrumentation-with-call-threshold=$(call_threshold)) |
14 | 14 | ||
15 | ifeq ($(call cc-option, $(CFLAGS_KASAN_MINIMAL) -Werror),) | 15 | ifeq ($(call cc-option, $(CFLAGS_KASAN_MINIMAL) -Werror),) |
16 | ifneq ($(CONFIG_COMPILE_TEST),y) | ||
16 | $(warning Cannot use CONFIG_KASAN: \ | 17 | $(warning Cannot use CONFIG_KASAN: \ |
17 | -fsanitize=kernel-address is not supported by compiler) | 18 | -fsanitize=kernel-address is not supported by compiler) |
19 | endif | ||
18 | else | 20 | else |
19 | ifeq ($(CFLAGS_KASAN),) | 21 | ifeq ($(CFLAGS_KASAN),) |
20 | $(warning CONFIG_KASAN: compiler does not support all options.\ | 22 | ifneq ($(CONFIG_COMPILE_TEST),y) |
21 | Trying minimal configuration) | 23 | $(warning CONFIG_KASAN: compiler does not support all options.\ |
24 | Trying minimal configuration) | ||
25 | endif | ||
22 | CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL) | 26 | CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL) |
23 | endif | 27 | endif |
24 | endif | 28 | endif |
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 044eb4f89a91..79e86613712f 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
@@ -282,7 +282,8 @@ $(obj)/%.dtb.S: $(obj)/%.dtb | |||
282 | $(call cmd,dt_S_dtb) | 282 | $(call cmd,dt_S_dtb) |
283 | 283 | ||
284 | quiet_cmd_dtc = DTC $@ | 284 | quiet_cmd_dtc = DTC $@ |
285 | cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ | 285 | cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \ |
286 | $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ | ||
286 | $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \ | 287 | $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \ |
287 | -i $(dir $<) $(DTC_FLAGS) \ | 288 | -i $(dir $<) $(DTC_FLAGS) \ |
288 | -d $(depfile).dtc.tmp $(dtc-tmp) ; \ | 289 | -d $(depfile).dtc.tmp $(dtc-tmp) ; \ |
diff --git a/scripts/check_extable.sh b/scripts/check_extable.sh new file mode 100755 index 000000000000..0fb6b1c97c27 --- /dev/null +++ b/scripts/check_extable.sh | |||
@@ -0,0 +1,146 @@ | |||
1 | #! /bin/bash | ||
2 | # (c) 2015, Quentin Casasnovas <quentin.casasnovas@oracle.com> | ||
3 | |||
4 | obj=$1 | ||
5 | |||
6 | file ${obj} | grep -q ELF || (echo "${obj} is not and ELF file." 1>&2 ; exit 0) | ||
7 | |||
8 | # Bail out early if there isn't an __ex_table section in this object file. | ||
9 | objdump -hj __ex_table ${obj} 2> /dev/null > /dev/null | ||
10 | [ $? -ne 0 ] && exit 0 | ||
11 | |||
12 | white_list=.text,.fixup | ||
13 | |||
14 | suspicious_relocs=$(objdump -rj __ex_table ${obj} | tail -n +6 | | ||
15 | grep -v $(eval echo -e{${white_list}}) | awk '{print $3}') | ||
16 | |||
17 | # No suspicious relocs in __ex_table, jobs a good'un | ||
18 | [ -z "${suspicious_relocs}" ] && exit 0 | ||
19 | |||
20 | |||
21 | # After this point, something is seriously wrong since we just found out we | ||
22 | # have some relocations in __ex_table which point to sections which aren't | ||
23 | # white listed. If you're adding a new section in the Linux kernel, and | ||
24 | # you're expecting this section to contain code which can fault (i.e. the | ||
25 | # __ex_table relocation to your new section is expected), simply add your | ||
26 | # new section to the white_list variable above. If not, you're probably | ||
27 | # doing something wrong and the rest of this code is just trying to print | ||
28 | # you more information about it. | ||
29 | |||
30 | function find_section_offset_from_symbol() | ||
31 | { | ||
32 | eval $(objdump -t ${obj} | grep ${1} | sed 's/\([0-9a-f]\+\) .\{7\} \([^ \t]\+\).*/section="\2"; section_offset="0x\1" /') | ||
33 | |||
34 | # addr2line takes addresses in hexadecimal... | ||
35 | section_offset=$(printf "0x%016x" $(( ${section_offset} + $2 )) ) | ||
36 | } | ||
37 | |||
38 | function find_symbol_and_offset_from_reloc() | ||
39 | { | ||
40 | # Extract symbol and offset from the objdump output | ||
41 | eval $(echo $reloc | sed 's/\([^+]\+\)+\?\(0x[0-9a-f]\+\)\?/symbol="\1"; symbol_offset="\2"/') | ||
42 | |||
43 | # When the relocation points to the begining of a symbol or section, it | ||
44 | # won't print the offset since it is zero. | ||
45 | if [ -z "${symbol_offset}" ]; then | ||
46 | symbol_offset=0x0 | ||
47 | fi | ||
48 | } | ||
49 | |||
50 | function find_alt_replacement_target() | ||
51 | { | ||
52 | # The target of the .altinstr_replacement is the relocation just before | ||
53 | # the .altinstr_replacement one. | ||
54 | eval $(objdump -rj .altinstructions ${obj} | grep -B1 "${section}+${section_offset}" | head -n1 | awk '{print $3}' | | ||
55 | sed 's/\([^+]\+\)+\(0x[0-9a-f]\+\)/alt_target_section="\1"; alt_target_offset="\2"/') | ||
56 | } | ||
57 | |||
58 | function handle_alt_replacement_reloc() | ||
59 | { | ||
60 | # This will define alt_target_section and alt_target_section_offset | ||
61 | find_alt_replacement_target ${section} ${section_offset} | ||
62 | |||
63 | echo "Error: found a reference to .altinstr_replacement in __ex_table:" | ||
64 | addr2line -fip -j ${alt_target_section} -e ${obj} ${alt_target_offset} | awk '{print "\t" $0}' | ||
65 | |||
66 | error=true | ||
67 | } | ||
68 | |||
69 | function is_executable_section() | ||
70 | { | ||
71 | objdump -hwj ${section} ${obj} | grep -q CODE | ||
72 | return $? | ||
73 | } | ||
74 | |||
75 | function handle_suspicious_generic_reloc() | ||
76 | { | ||
77 | if is_executable_section ${section}; then | ||
78 | # We've got a relocation to a non white listed _executable_ | ||
79 | # section, print a warning so the developper adds the section to | ||
80 | # the white list or fix his code. We try to pretty-print the file | ||
81 | # and line number where that relocation was added. | ||
82 | echo "Warning: found a reference to section \"${section}\" in __ex_table:" | ||
83 | addr2line -fip -j ${section} -e ${obj} ${section_offset} | awk '{print "\t" $0}' | ||
84 | else | ||
85 | # Something is definitively wrong here since we've got a relocation | ||
86 | # to a non-executable section, there's no way this would ever be | ||
87 | # running in the kernel. | ||
88 | echo "Error: found a reference to non-executable section \"${section}\" in __ex_table at offset ${section_offset}" | ||
89 | error=true | ||
90 | fi | ||
91 | } | ||
92 | |||
93 | function handle_suspicious_reloc() | ||
94 | { | ||
95 | case "${section}" in | ||
96 | ".altinstr_replacement") | ||
97 | handle_alt_replacement_reloc ${section} ${section_offset} | ||
98 | ;; | ||
99 | *) | ||
100 | handle_suspicious_generic_reloc ${section} ${section_offset} | ||
101 | ;; | ||
102 | esac | ||
103 | } | ||
104 | |||
105 | function diagnose() | ||
106 | { | ||
107 | |||
108 | for reloc in ${suspicious_relocs}; do | ||
109 | # Let's find out where the target of the relocation in __ex_table | ||
110 | # is, this will define ${symbol} and ${symbol_offset} | ||
111 | find_symbol_and_offset_from_reloc ${reloc} | ||
112 | |||
113 | # When there's a global symbol at the place of the relocation, | ||
114 | # objdump will use it instead of giving us a section+offset, so | ||
115 | # let's find out which section is this symbol in and the total | ||
116 | # offset withing that section. | ||
117 | find_section_offset_from_symbol ${symbol} ${symbol_offset} | ||
118 | |||
119 | # In this case objdump was presenting us with a reloc to a symbol | ||
120 | # rather than a section. Now that we've got the actual section, | ||
121 | # we can skip it if it's in the white_list. | ||
122 | if [ -z "$( echo $section | grep -v $(eval echo -e{${white_list}}))" ]; then | ||
123 | continue; | ||
124 | fi | ||
125 | |||
126 | # Will either print a warning if the relocation happens to be in a | ||
127 | # section we do not know but has executable bit set, or error out. | ||
128 | handle_suspicious_reloc | ||
129 | done | ||
130 | } | ||
131 | |||
132 | function check_debug_info() { | ||
133 | objdump -hj .debug_info ${obj} 2> /dev/null > /dev/null || | ||
134 | echo -e "${obj} does not contain debug information, the addr2line output will be limited.\n" \ | ||
135 | "Recompile ${obj} with CONFIG_DEBUG_INFO to get a more useful output." | ||
136 | } | ||
137 | |||
138 | check_debug_info | ||
139 | |||
140 | diagnose | ||
141 | |||
142 | if [ "${error}" ]; then | ||
143 | exit 1 | ||
144 | fi | ||
145 | |||
146 | exit 0 | ||
diff --git a/scripts/checkkconfigsymbols.py b/scripts/checkkconfigsymbols.py index e9cc689033fe..74086a583d8d 100644..100755 --- a/scripts/checkkconfigsymbols.py +++ b/scripts/checkkconfigsymbols.py | |||
@@ -1,8 +1,8 @@ | |||
1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
2 | 2 | ||
3 | """Find Kconfig identifiers that are referenced but not defined.""" | 3 | """Find Kconfig symbols that are referenced but not defined.""" |
4 | 4 | ||
5 | # (c) 2014 Valentin Rothberg <valentinrothberg@gmail.com> | 5 | # (c) 2014-2015 Valentin Rothberg <Valentin.Rothberg@lip6.fr> |
6 | # (c) 2014 Stefan Hengelein <stefan.hengelein@fau.de> | 6 | # (c) 2014 Stefan Hengelein <stefan.hengelein@fau.de> |
7 | # | 7 | # |
8 | # Licensed under the terms of the GNU GPL License version 2 | 8 | # Licensed under the terms of the GNU GPL License version 2 |
@@ -10,7 +10,9 @@ | |||
10 | 10 | ||
11 | import os | 11 | import os |
12 | import re | 12 | import re |
13 | import sys | ||
13 | from subprocess import Popen, PIPE, STDOUT | 14 | from subprocess import Popen, PIPE, STDOUT |
15 | from optparse import OptionParser | ||
14 | 16 | ||
15 | 17 | ||
16 | # regex expressions | 18 | # regex expressions |
@@ -32,22 +34,149 @@ REGEX_KCONFIG_HELP = re.compile(r"^\s+(help|---help---)\s*$") | |||
32 | REGEX_FILTER_FEATURES = re.compile(r"[A-Za-z0-9]$") | 34 | REGEX_FILTER_FEATURES = re.compile(r"[A-Za-z0-9]$") |
33 | 35 | ||
34 | 36 | ||
37 | def parse_options(): | ||
38 | """The user interface of this module.""" | ||
39 | usage = "%prog [options]\n\n" \ | ||
40 | "Run this tool to detect Kconfig symbols that are referenced but " \ | ||
41 | "not defined in\nKconfig. The output of this tool has the " \ | ||
42 | "format \'Undefined symbol\\tFile list\'\n\n" \ | ||
43 | "If no option is specified, %prog will default to check your\n" \ | ||
44 | "current tree. Please note that specifying commits will " \ | ||
45 | "\'git reset --hard\'\nyour current tree! You may save " \ | ||
46 | "uncommitted changes to avoid losing data." | ||
47 | |||
48 | parser = OptionParser(usage=usage) | ||
49 | |||
50 | parser.add_option('-c', '--commit', dest='commit', action='store', | ||
51 | default="", | ||
52 | help="Check if the specified commit (hash) introduces " | ||
53 | "undefined Kconfig symbols.") | ||
54 | |||
55 | parser.add_option('-d', '--diff', dest='diff', action='store', | ||
56 | default="", | ||
57 | help="Diff undefined symbols between two commits. The " | ||
58 | "input format bases on Git log's " | ||
59 | "\'commmit1..commit2\'.") | ||
60 | |||
61 | parser.add_option('', '--force', dest='force', action='store_true', | ||
62 | default=False, | ||
63 | help="Reset current Git tree even when it's dirty.") | ||
64 | |||
65 | (opts, _) = parser.parse_args() | ||
66 | |||
67 | if opts.commit and opts.diff: | ||
68 | sys.exit("Please specify only one option at once.") | ||
69 | |||
70 | if opts.diff and not re.match(r"^[\w\-\.]+\.\.[\w\-\.]+$", opts.diff): | ||
71 | sys.exit("Please specify valid input in the following format: " | ||
72 | "\'commmit1..commit2\'") | ||
73 | |||
74 | if opts.commit or opts.diff: | ||
75 | if not opts.force and tree_is_dirty(): | ||
76 | sys.exit("The current Git tree is dirty (see 'git status'). " | ||
77 | "Running this script may\ndelete important data since it " | ||
78 | "calls 'git reset --hard' for some performance\nreasons. " | ||
79 | " Please run this script in a clean Git tree or pass " | ||
80 | "'--force' if you\nwant to ignore this warning and " | ||
81 | "continue.") | ||
82 | |||
83 | return opts | ||
84 | |||
85 | |||
35 | def main(): | 86 | def main(): |
36 | """Main function of this module.""" | 87 | """Main function of this module.""" |
88 | opts = parse_options() | ||
89 | |||
90 | if opts.commit or opts.diff: | ||
91 | head = get_head() | ||
92 | |||
93 | # get commit range | ||
94 | commit_a = None | ||
95 | commit_b = None | ||
96 | if opts.commit: | ||
97 | commit_a = opts.commit + "~" | ||
98 | commit_b = opts.commit | ||
99 | elif opts.diff: | ||
100 | split = opts.diff.split("..") | ||
101 | commit_a = split[0] | ||
102 | commit_b = split[1] | ||
103 | undefined_a = {} | ||
104 | undefined_b = {} | ||
105 | |||
106 | # get undefined items before the commit | ||
107 | execute("git reset --hard %s" % commit_a) | ||
108 | undefined_a = check_symbols() | ||
109 | |||
110 | # get undefined items for the commit | ||
111 | execute("git reset --hard %s" % commit_b) | ||
112 | undefined_b = check_symbols() | ||
113 | |||
114 | # report cases that are present for the commit but not before | ||
115 | for feature in sorted(undefined_b): | ||
116 | # feature has not been undefined before | ||
117 | if not feature in undefined_a: | ||
118 | files = sorted(undefined_b.get(feature)) | ||
119 | print "%s\t%s" % (feature, ", ".join(files)) | ||
120 | # check if there are new files that reference the undefined feature | ||
121 | else: | ||
122 | files = sorted(undefined_b.get(feature) - | ||
123 | undefined_a.get(feature)) | ||
124 | if files: | ||
125 | print "%s\t%s" % (feature, ", ".join(files)) | ||
126 | |||
127 | # reset to head | ||
128 | execute("git reset --hard %s" % head) | ||
129 | |||
130 | # default to check the entire tree | ||
131 | else: | ||
132 | undefined = check_symbols() | ||
133 | for feature in sorted(undefined): | ||
134 | files = sorted(undefined.get(feature)) | ||
135 | print "%s\t%s" % (feature, ", ".join(files)) | ||
136 | |||
137 | |||
138 | def execute(cmd): | ||
139 | """Execute %cmd and return stdout. Exit in case of error.""" | ||
140 | pop = Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True) | ||
141 | (stdout, _) = pop.communicate() # wait until finished | ||
142 | if pop.returncode != 0: | ||
143 | sys.exit(stdout) | ||
144 | return stdout | ||
145 | |||
146 | |||
147 | def tree_is_dirty(): | ||
148 | """Return true if the current working tree is dirty (i.e., if any file has | ||
149 | been added, deleted, modified, renamed or copied but not committed).""" | ||
150 | stdout = execute("git status --porcelain") | ||
151 | for line in stdout: | ||
152 | if re.findall(r"[URMADC]{1}", line[:2]): | ||
153 | return True | ||
154 | return False | ||
155 | |||
156 | |||
157 | def get_head(): | ||
158 | """Return commit hash of current HEAD.""" | ||
159 | stdout = execute("git rev-parse HEAD") | ||
160 | return stdout.strip('\n') | ||
161 | |||
162 | |||
163 | def check_symbols(): | ||
164 | """Find undefined Kconfig symbols and return a dict with the symbol as key | ||
165 | and a list of referencing files as value.""" | ||
37 | source_files = [] | 166 | source_files = [] |
38 | kconfig_files = [] | 167 | kconfig_files = [] |
39 | defined_features = set() | 168 | defined_features = set() |
40 | referenced_features = dict() # {feature: [files]} | 169 | referenced_features = dict() # {feature: [files]} |
41 | 170 | ||
42 | # use 'git ls-files' to get the worklist | 171 | # use 'git ls-files' to get the worklist |
43 | pop = Popen("git ls-files", stdout=PIPE, stderr=STDOUT, shell=True) | 172 | stdout = execute("git ls-files") |
44 | (stdout, _) = pop.communicate() # wait until finished | ||
45 | if len(stdout) > 0 and stdout[-1] == "\n": | 173 | if len(stdout) > 0 and stdout[-1] == "\n": |
46 | stdout = stdout[:-1] | 174 | stdout = stdout[:-1] |
47 | 175 | ||
48 | for gitfile in stdout.rsplit("\n"): | 176 | for gitfile in stdout.rsplit("\n"): |
49 | if ".git" in gitfile or "ChangeLog" in gitfile or \ | 177 | if ".git" in gitfile or "ChangeLog" in gitfile or \ |
50 | ".log" in gitfile or os.path.isdir(gitfile): | 178 | ".log" in gitfile or os.path.isdir(gitfile) or \ |
179 | gitfile.startswith("tools/"): | ||
51 | continue | 180 | continue |
52 | if REGEX_FILE_KCONFIG.match(gitfile): | 181 | if REGEX_FILE_KCONFIG.match(gitfile): |
53 | kconfig_files.append(gitfile) | 182 | kconfig_files.append(gitfile) |
@@ -61,7 +190,7 @@ def main(): | |||
61 | for kfile in kconfig_files: | 190 | for kfile in kconfig_files: |
62 | parse_kconfig_file(kfile, defined_features, referenced_features) | 191 | parse_kconfig_file(kfile, defined_features, referenced_features) |
63 | 192 | ||
64 | print "Undefined symbol used\tFile list" | 193 | undefined = {} # {feature: [files]} |
65 | for feature in sorted(referenced_features): | 194 | for feature in sorted(referenced_features): |
66 | # filter some false positives | 195 | # filter some false positives |
67 | if feature == "FOO" or feature == "BAR" or \ | 196 | if feature == "FOO" or feature == "BAR" or \ |
@@ -72,8 +201,8 @@ def main(): | |||
72 | # avoid false positives for kernel modules | 201 | # avoid false positives for kernel modules |
73 | if feature[:-len("_MODULE")] in defined_features: | 202 | if feature[:-len("_MODULE")] in defined_features: |
74 | continue | 203 | continue |
75 | files = referenced_features.get(feature) | 204 | undefined[feature] = referenced_features.get(feature) |
76 | print "%s\t%s" % (feature, ", ".join(files)) | 205 | return undefined |
77 | 206 | ||
78 | 207 | ||
79 | def parse_source_file(sfile, referenced_features): | 208 | def parse_source_file(sfile, referenced_features): |
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d12435992dea..89b1df4e72ab 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -47,6 +47,8 @@ my $ignore_perl_version = 0; | |||
47 | my $minimum_perl_version = 5.10.0; | 47 | my $minimum_perl_version = 5.10.0; |
48 | my $min_conf_desc_length = 4; | 48 | my $min_conf_desc_length = 4; |
49 | my $spelling_file = "$D/spelling.txt"; | 49 | my $spelling_file = "$D/spelling.txt"; |
50 | my $codespell = 0; | ||
51 | my $codespellfile = "/usr/local/share/codespell/dictionary.txt"; | ||
50 | 52 | ||
51 | sub help { | 53 | sub help { |
52 | my ($exitcode) = @_; | 54 | my ($exitcode) = @_; |
@@ -88,6 +90,9 @@ Options: | |||
88 | file. It's your fault if there's no backup or git | 90 | file. It's your fault if there's no backup or git |
89 | --ignore-perl-version override checking of perl version. expect | 91 | --ignore-perl-version override checking of perl version. expect |
90 | runtime errors. | 92 | runtime errors. |
93 | --codespell Use the codespell dictionary for spelling/typos | ||
94 | (default:/usr/local/share/codespell/dictionary.txt) | ||
95 | --codespellfile Use this codespell dictionary | ||
91 | -h, --help, --version display this help and exit | 96 | -h, --help, --version display this help and exit |
92 | 97 | ||
93 | When FILE is - read standard input. | 98 | When FILE is - read standard input. |
@@ -146,6 +151,8 @@ GetOptions( | |||
146 | 'ignore-perl-version!' => \$ignore_perl_version, | 151 | 'ignore-perl-version!' => \$ignore_perl_version, |
147 | 'debug=s' => \%debug, | 152 | 'debug=s' => \%debug, |
148 | 'test-only=s' => \$tst_only, | 153 | 'test-only=s' => \$tst_only, |
154 | 'codespell!' => \$codespell, | ||
155 | 'codespellfile=s' => \$codespellfile, | ||
149 | 'h|help' => \$help, | 156 | 'h|help' => \$help, |
150 | 'version' => \$help | 157 | 'version' => \$help |
151 | ) or help(1); | 158 | ) or help(1); |
@@ -316,6 +323,7 @@ our $Operators = qr{ | |||
316 | 323 | ||
317 | our $c90_Keywords = qr{do|for|while|if|else|return|goto|continue|switch|default|case|break}x; | 324 | our $c90_Keywords = qr{do|for|while|if|else|return|goto|continue|switch|default|case|break}x; |
318 | 325 | ||
326 | our $BasicType; | ||
319 | our $NonptrType; | 327 | our $NonptrType; |
320 | our $NonptrTypeMisordered; | 328 | our $NonptrTypeMisordered; |
321 | our $NonptrTypeWithAttr; | 329 | our $NonptrTypeWithAttr; |
@@ -436,6 +444,14 @@ foreach my $entry (@mode_permission_funcs) { | |||
436 | $mode_perms_search .= $entry->[0]; | 444 | $mode_perms_search .= $entry->[0]; |
437 | } | 445 | } |
438 | 446 | ||
447 | our $mode_perms_world_writable = qr{ | ||
448 | S_IWUGO | | ||
449 | S_IWOTH | | ||
450 | S_IRWXUGO | | ||
451 | S_IALLUGO | | ||
452 | 0[0-7][0-7][2367] | ||
453 | }x; | ||
454 | |||
439 | our $allowed_asm_includes = qr{(?x: | 455 | our $allowed_asm_includes = qr{(?x: |
440 | irq| | 456 | irq| |
441 | memory| | 457 | memory| |
@@ -449,7 +465,6 @@ my $misspellings; | |||
449 | my %spelling_fix; | 465 | my %spelling_fix; |
450 | 466 | ||
451 | if (open(my $spelling, '<', $spelling_file)) { | 467 | if (open(my $spelling, '<', $spelling_file)) { |
452 | my @spelling_list; | ||
453 | while (<$spelling>) { | 468 | while (<$spelling>) { |
454 | my $line = $_; | 469 | my $line = $_; |
455 | 470 | ||
@@ -461,21 +476,50 @@ if (open(my $spelling, '<', $spelling_file)) { | |||
461 | 476 | ||
462 | my ($suspect, $fix) = split(/\|\|/, $line); | 477 | my ($suspect, $fix) = split(/\|\|/, $line); |
463 | 478 | ||
464 | push(@spelling_list, $suspect); | ||
465 | $spelling_fix{$suspect} = $fix; | 479 | $spelling_fix{$suspect} = $fix; |
466 | } | 480 | } |
467 | close($spelling); | 481 | close($spelling); |
468 | $misspellings = join("|", @spelling_list); | ||
469 | } else { | 482 | } else { |
470 | warn "No typos will be found - file '$spelling_file': $!\n"; | 483 | warn "No typos will be found - file '$spelling_file': $!\n"; |
471 | } | 484 | } |
472 | 485 | ||
486 | if ($codespell) { | ||
487 | if (open(my $spelling, '<', $codespellfile)) { | ||
488 | while (<$spelling>) { | ||
489 | my $line = $_; | ||
490 | |||
491 | $line =~ s/\s*\n?$//g; | ||
492 | $line =~ s/^\s*//g; | ||
493 | |||
494 | next if ($line =~ m/^\s*#/); | ||
495 | next if ($line =~ m/^\s*$/); | ||
496 | next if ($line =~ m/, disabled/i); | ||
497 | |||
498 | $line =~ s/,.*$//; | ||
499 | |||
500 | my ($suspect, $fix) = split(/->/, $line); | ||
501 | |||
502 | $spelling_fix{$suspect} = $fix; | ||
503 | } | ||
504 | close($spelling); | ||
505 | } else { | ||
506 | warn "No codespell typos will be found - file '$codespellfile': $!\n"; | ||
507 | } | ||
508 | } | ||
509 | |||
510 | $misspellings = join("|", sort keys %spelling_fix) if keys %spelling_fix; | ||
511 | |||
473 | sub build_types { | 512 | sub build_types { |
474 | my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)"; | 513 | my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)"; |
475 | my $all = "(?x: \n" . join("|\n ", @typeList) . "\n)"; | 514 | my $all = "(?x: \n" . join("|\n ", @typeList) . "\n)"; |
476 | my $Misordered = "(?x: \n" . join("|\n ", @typeListMisordered) . "\n)"; | 515 | my $Misordered = "(?x: \n" . join("|\n ", @typeListMisordered) . "\n)"; |
477 | my $allWithAttr = "(?x: \n" . join("|\n ", @typeListWithAttr) . "\n)"; | 516 | my $allWithAttr = "(?x: \n" . join("|\n ", @typeListWithAttr) . "\n)"; |
478 | $Modifier = qr{(?:$Attribute|$Sparse|$mods)}; | 517 | $Modifier = qr{(?:$Attribute|$Sparse|$mods)}; |
518 | $BasicType = qr{ | ||
519 | (?:$typeOtherOSTypedefs\b)| | ||
520 | (?:$typeTypedefs\b)| | ||
521 | (?:${all}\b) | ||
522 | }x; | ||
479 | $NonptrType = qr{ | 523 | $NonptrType = qr{ |
480 | (?:$Modifier\s+|const\s+)* | 524 | (?:$Modifier\s+|const\s+)* |
481 | (?: | 525 | (?: |
@@ -1646,7 +1690,7 @@ sub fix_inserted_deleted_lines { | |||
1646 | foreach my $old_line (@{$linesRef}) { | 1690 | foreach my $old_line (@{$linesRef}) { |
1647 | my $save_line = 1; | 1691 | my $save_line = 1; |
1648 | my $line = $old_line; #don't modify the array | 1692 | my $line = $old_line; #don't modify the array |
1649 | if ($line =~ /^(?:\+\+\+\|\-\-\-)\s+\S+/) { #new filename | 1693 | if ($line =~ /^(?:\+\+\+|\-\-\-)\s+\S+/) { #new filename |
1650 | $delta_offset = 0; | 1694 | $delta_offset = 0; |
1651 | } elsif ($line =~ /^\@\@ -\d+,\d+ \+\d+,\d+ \@\@/) { #new hunk | 1695 | } elsif ($line =~ /^\@\@ -\d+,\d+ \+\d+,\d+ \@\@/) { #new hunk |
1652 | $range_last_linenr = $new_linenr; | 1696 | $range_last_linenr = $new_linenr; |
@@ -1854,6 +1898,7 @@ sub process { | |||
1854 | 1898 | ||
1855 | my $in_header_lines = $file ? 0 : 1; | 1899 | my $in_header_lines = $file ? 0 : 1; |
1856 | my $in_commit_log = 0; #Scanning lines before patch | 1900 | my $in_commit_log = 0; #Scanning lines before patch |
1901 | my $commit_log_long_line = 0; | ||
1857 | my $reported_maintainer_file = 0; | 1902 | my $reported_maintainer_file = 0; |
1858 | my $non_utf8_charset = 0; | 1903 | my $non_utf8_charset = 0; |
1859 | 1904 | ||
@@ -2189,6 +2234,14 @@ sub process { | |||
2189 | "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr); | 2234 | "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr); |
2190 | } | 2235 | } |
2191 | 2236 | ||
2237 | # Check for line lengths > 75 in commit log, warn once | ||
2238 | if ($in_commit_log && !$commit_log_long_line && | ||
2239 | length($line) > 75) { | ||
2240 | WARN("COMMIT_LOG_LONG_LINE", | ||
2241 | "Possible unwrapped commit description (prefer a maximum 75 chars per line)\n" . $herecurr); | ||
2242 | $commit_log_long_line = 1; | ||
2243 | } | ||
2244 | |||
2192 | # Check for git id commit length and improperly formed commit descriptions | 2245 | # Check for git id commit length and improperly formed commit descriptions |
2193 | if ($in_commit_log && $line =~ /\b(c)ommit\s+([0-9a-f]{5,})/i) { | 2246 | if ($in_commit_log && $line =~ /\b(c)ommit\s+([0-9a-f]{5,})/i) { |
2194 | my $init_char = $1; | 2247 | my $init_char = $1; |
@@ -2303,8 +2356,9 @@ sub process { | |||
2303 | } | 2356 | } |
2304 | 2357 | ||
2305 | # Check for various typo / spelling mistakes | 2358 | # Check for various typo / spelling mistakes |
2306 | if (defined($misspellings) && ($in_commit_log || $line =~ /^\+/)) { | 2359 | if (defined($misspellings) && |
2307 | while ($rawline =~ /(?:^|[^a-z@])($misspellings)(?:$|[^a-z@])/gi) { | 2360 | ($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) { |
2361 | while ($rawline =~ /(?:^|[^a-z@])($misspellings)(?:\b|$|[^a-z@])/gi) { | ||
2308 | my $typo = $1; | 2362 | my $typo = $1; |
2309 | my $typo_fix = $spelling_fix{lc($typo)}; | 2363 | my $typo_fix = $spelling_fix{lc($typo)}; |
2310 | $typo_fix = ucfirst($typo_fix) if ($typo =~ /^[A-Z]/); | 2364 | $typo_fix = ucfirst($typo_fix) if ($typo =~ /^[A-Z]/); |
@@ -2459,8 +2513,9 @@ sub process { | |||
2459 | #line length limit | 2513 | #line length limit |
2460 | if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && | 2514 | if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && |
2461 | $rawline !~ /^.\s*\*\s*\@$Ident\s/ && | 2515 | $rawline !~ /^.\s*\*\s*\@$Ident\s/ && |
2462 | !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ || | 2516 | !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?$String\s*(?:|,|\)\s*;)\s*$/ || |
2463 | $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) && | 2517 | $line =~ /^\+\s*$String\s*(?:\s*|,|\)\s*;)\s*$/ || |
2518 | $line =~ /^\+\s*#\s*define\s+\w+\s+$String$/) && | ||
2464 | $length > $max_line_length) | 2519 | $length > $max_line_length) |
2465 | { | 2520 | { |
2466 | WARN("LONG_LINE", | 2521 | WARN("LONG_LINE", |
@@ -2552,8 +2607,15 @@ sub process { | |||
2552 | } | 2607 | } |
2553 | } | 2608 | } |
2554 | 2609 | ||
2555 | if ($line =~ /^\+.*(\w+\s*)?\(\s*$Type\s*\)[ \t]+(?!$Assignment|$Arithmetic|[,;:\?\(\{\}\[\<\>]|&&|\|\||\\$)/ && | 2610 | # check for space after cast like "(int) foo" or "(struct foo) bar" |
2556 | (!defined($1) || $1 !~ /sizeof\s*/)) { | 2611 | # avoid checking a few false positives: |
2612 | # "sizeof(<type>)" or "__alignof__(<type>)" | ||
2613 | # function pointer declarations like "(*foo)(int) = bar;" | ||
2614 | # structure definitions like "(struct foo) { 0 };" | ||
2615 | # multiline macros that define functions | ||
2616 | # known attributes or the __attribute__ keyword | ||
2617 | if ($line =~ /^\+(.*)\(\s*$Type\s*\)([ \t]++)((?![={]|\\$|$Attribute|__attribute__))/ && | ||
2618 | (!defined($1) || $1 !~ /\b(?:sizeof|__alignof__)\s*$/)) { | ||
2557 | if (CHK("SPACING", | 2619 | if (CHK("SPACING", |
2558 | "No space is necessary after a cast\n" . $herecurr) && | 2620 | "No space is necessary after a cast\n" . $herecurr) && |
2559 | $fix) { | 2621 | $fix) { |
@@ -3146,6 +3208,18 @@ sub process { | |||
3146 | $herecurr); | 3208 | $herecurr); |
3147 | } | 3209 | } |
3148 | 3210 | ||
3211 | # check for const <foo> const where <foo> is not a pointer or array type | ||
3212 | if ($sline =~ /\bconst\s+($BasicType)\s+const\b/) { | ||
3213 | my $found = $1; | ||
3214 | if ($sline =~ /\bconst\s+\Q$found\E\s+const\b\s*\*/) { | ||
3215 | WARN("CONST_CONST", | ||
3216 | "'const $found const *' should probably be 'const $found * const'\n" . $herecurr); | ||
3217 | } elsif ($sline !~ /\bconst\s+\Q$found\E\s+const\s+\w+\s*\[/) { | ||
3218 | WARN("CONST_CONST", | ||
3219 | "'const $found const' should probably be 'const $found'\n" . $herecurr); | ||
3220 | } | ||
3221 | } | ||
3222 | |||
3149 | # check for non-global char *foo[] = {"bar", ...} declarations. | 3223 | # check for non-global char *foo[] = {"bar", ...} declarations. |
3150 | if ($line =~ /^.\s+(?:static\s+|const\s+)?char\s+\*\s*\w+\s*\[\s*\]\s*=\s*\{/) { | 3224 | if ($line =~ /^.\s+(?:static\s+|const\s+)?char\s+\*\s*\w+\s*\[\s*\]\s*=\s*\{/) { |
3151 | WARN("STATIC_CONST_CHAR_ARRAY", | 3225 | WARN("STATIC_CONST_CHAR_ARRAY", |
@@ -3153,6 +3227,19 @@ sub process { | |||
3153 | $herecurr); | 3227 | $herecurr); |
3154 | } | 3228 | } |
3155 | 3229 | ||
3230 | # check for sizeof(foo)/sizeof(foo[0]) that could be ARRAY_SIZE(foo) | ||
3231 | if ($line =~ m@\bsizeof\s*\(\s*($Lval)\s*\)@) { | ||
3232 | my $array = $1; | ||
3233 | if ($line =~ m@\b(sizeof\s*\(\s*\Q$array\E\s*\)\s*/\s*sizeof\s*\(\s*\Q$array\E\s*\[\s*0\s*\]\s*\))@) { | ||
3234 | my $array_div = $1; | ||
3235 | if (WARN("ARRAY_SIZE", | ||
3236 | "Prefer ARRAY_SIZE($array)\n" . $herecurr) && | ||
3237 | $fix) { | ||
3238 | $fixed[$fixlinenr] =~ s/\Q$array_div\E/ARRAY_SIZE($array)/; | ||
3239 | } | ||
3240 | } | ||
3241 | } | ||
3242 | |||
3156 | # check for function declarations without arguments like "int foo()" | 3243 | # check for function declarations without arguments like "int foo()" |
3157 | if ($line =~ /(\b$Type\s+$Ident)\s*\(\s*\)/) { | 3244 | if ($line =~ /(\b$Type\s+$Ident)\s*\(\s*\)/) { |
3158 | if (ERROR("FUNCTION_WITHOUT_ARGS", | 3245 | if (ERROR("FUNCTION_WITHOUT_ARGS", |
@@ -3309,6 +3396,14 @@ sub process { | |||
3309 | "Prefer dev_$level(... to dev_printk(KERN_$orig, ...\n" . $herecurr); | 3396 | "Prefer dev_$level(... to dev_printk(KERN_$orig, ...\n" . $herecurr); |
3310 | } | 3397 | } |
3311 | 3398 | ||
3399 | # ENOSYS means "bad syscall nr" and nothing else. This will have a small | ||
3400 | # number of false positives, but assembly files are not checked, so at | ||
3401 | # least the arch entry code will not trigger this warning. | ||
3402 | if ($line =~ /\bENOSYS\b/) { | ||
3403 | WARN("ENOSYS", | ||
3404 | "ENOSYS means 'invalid syscall nr' and nothing else\n" . $herecurr); | ||
3405 | } | ||
3406 | |||
3312 | # function brace can't be on same line, except for #defines of do while, | 3407 | # function brace can't be on same line, except for #defines of do while, |
3313 | # or if closed on same line | 3408 | # or if closed on same line |
3314 | if (($line=~/$Type\s*$Ident\(.*\).*\s*{/) and | 3409 | if (($line=~/$Type\s*$Ident\(.*\).*\s*{/) and |
@@ -3565,7 +3660,7 @@ sub process { | |||
3565 | 3660 | ||
3566 | # Ignore operators passed as parameters. | 3661 | # Ignore operators passed as parameters. |
3567 | if ($op_type ne 'V' && | 3662 | if ($op_type ne 'V' && |
3568 | $ca =~ /\s$/ && $cc =~ /^\s*,/) { | 3663 | $ca =~ /\s$/ && $cc =~ /^\s*[,\)]/) { |
3569 | 3664 | ||
3570 | # # Ignore comments | 3665 | # # Ignore comments |
3571 | # } elsif ($op =~ /^$;+$/) { | 3666 | # } elsif ($op =~ /^$;+$/) { |
@@ -3750,6 +3845,14 @@ sub process { | |||
3750 | $ok = 1; | 3845 | $ok = 1; |
3751 | } | 3846 | } |
3752 | 3847 | ||
3848 | # for asm volatile statements | ||
3849 | # ignore a colon with another | ||
3850 | # colon immediately before or after | ||
3851 | if (($op eq ':') && | ||
3852 | ($ca =~ /:$/ || $cc =~ /^:/)) { | ||
3853 | $ok = 1; | ||
3854 | } | ||
3855 | |||
3753 | # messages are ERROR, but ?: are CHK | 3856 | # messages are ERROR, but ?: are CHK |
3754 | if ($ok == 0) { | 3857 | if ($ok == 0) { |
3755 | my $msg_type = \&ERROR; | 3858 | my $msg_type = \&ERROR; |
@@ -3963,12 +4066,12 @@ sub process { | |||
3963 | } | 4066 | } |
3964 | } | 4067 | } |
3965 | 4068 | ||
3966 | # Return of what appears to be an errno should normally be -'ve | 4069 | # Return of what appears to be an errno should normally be negative |
3967 | if ($line =~ /^.\s*return\s*(E[A-Z]*)\s*;/) { | 4070 | if ($sline =~ /\breturn(?:\s*\(+\s*|\s+)(E[A-Z]+)(?:\s*\)+\s*|\s*)[;:,]/) { |
3968 | my $name = $1; | 4071 | my $name = $1; |
3969 | if ($name ne 'EOF' && $name ne 'ERROR') { | 4072 | if ($name ne 'EOF' && $name ne 'ERROR') { |
3970 | WARN("USE_NEGATIVE_ERRNO", | 4073 | WARN("USE_NEGATIVE_ERRNO", |
3971 | "return of an errno should typically be -ve (return -$1)\n" . $herecurr); | 4074 | "return of an errno should typically be negative (ie: return -$1)\n" . $herecurr); |
3972 | } | 4075 | } |
3973 | } | 4076 | } |
3974 | 4077 | ||
@@ -4178,7 +4281,8 @@ sub process { | |||
4178 | } | 4281 | } |
4179 | } | 4282 | } |
4180 | 4283 | ||
4181 | #warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line) | 4284 | # warn if <asm/foo.h> is #included and <linux/foo.h> is available and includes |
4285 | # itself <asm/foo.h> (uses RAW line) | ||
4182 | if ($tree && $rawline =~ m{^.\s*\#\s*include\s*\<asm\/(.*)\.h\>}) { | 4286 | if ($tree && $rawline =~ m{^.\s*\#\s*include\s*\<asm\/(.*)\.h\>}) { |
4183 | my $file = "$1.h"; | 4287 | my $file = "$1.h"; |
4184 | my $checkfile = "include/linux/$file"; | 4288 | my $checkfile = "include/linux/$file"; |
@@ -4186,12 +4290,15 @@ sub process { | |||
4186 | $realfile ne $checkfile && | 4290 | $realfile ne $checkfile && |
4187 | $1 !~ /$allowed_asm_includes/) | 4291 | $1 !~ /$allowed_asm_includes/) |
4188 | { | 4292 | { |
4189 | if ($realfile =~ m{^arch/}) { | 4293 | my $asminclude = `grep -Ec "#include\\s+<asm/$file>" $root/$checkfile`; |
4190 | CHK("ARCH_INCLUDE_LINUX", | 4294 | if ($asminclude > 0) { |
4191 | "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr); | 4295 | if ($realfile =~ m{^arch/}) { |
4192 | } else { | 4296 | CHK("ARCH_INCLUDE_LINUX", |
4193 | WARN("INCLUDE_LINUX", | 4297 | "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr); |
4194 | "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr); | 4298 | } else { |
4299 | WARN("INCLUDE_LINUX", | ||
4300 | "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr); | ||
4301 | } | ||
4195 | } | 4302 | } |
4196 | } | 4303 | } |
4197 | } | 4304 | } |
@@ -4700,6 +4807,16 @@ sub process { | |||
4700 | } | 4807 | } |
4701 | } | 4808 | } |
4702 | 4809 | ||
4810 | # check for __read_mostly with const non-pointer (should just be const) | ||
4811 | if ($line =~ /\b__read_mostly\b/ && | ||
4812 | $line =~ /($Type)\s*$Ident/ && $1 !~ /\*\s*$/ && $1 =~ /\bconst\b/) { | ||
4813 | if (ERROR("CONST_READ_MOSTLY", | ||
4814 | "Invalid use of __read_mostly with const type\n" . $herecurr) && | ||
4815 | $fix) { | ||
4816 | $fixed[$fixlinenr] =~ s/\s+__read_mostly\b//; | ||
4817 | } | ||
4818 | } | ||
4819 | |||
4703 | # don't use __constant_<foo> functions outside of include/uapi/ | 4820 | # don't use __constant_<foo> functions outside of include/uapi/ |
4704 | if ($realfile !~ m@^include/uapi/@ && | 4821 | if ($realfile !~ m@^include/uapi/@ && |
4705 | $line =~ /(__constant_(?:htons|ntohs|[bl]e(?:16|32|64)_to_cpu|cpu_to_[bl]e(?:16|32|64)))\s*\(/) { | 4822 | $line =~ /(__constant_(?:htons|ntohs|[bl]e(?:16|32|64)_to_cpu|cpu_to_[bl]e(?:16|32|64)))\s*\(/) { |
@@ -5261,6 +5378,7 @@ sub process { | |||
5261 | stacktrace_ops| | 5378 | stacktrace_ops| |
5262 | sysfs_ops| | 5379 | sysfs_ops| |
5263 | tty_operations| | 5380 | tty_operations| |
5381 | uart_ops| | ||
5264 | usb_mon_operations| | 5382 | usb_mon_operations| |
5265 | wd_ops}x; | 5383 | wd_ops}x; |
5266 | if ($line !~ /\bconst\b/ && | 5384 | if ($line !~ /\bconst\b/ && |
@@ -5318,8 +5436,8 @@ sub process { | |||
5318 | } | 5436 | } |
5319 | } | 5437 | } |
5320 | 5438 | ||
5321 | if ($line =~ /debugfs_create_file.*S_IWUGO/ || | 5439 | if ($line =~ /debugfs_create_\w+.*\b$mode_perms_world_writable\b/ || |
5322 | $line =~ /DEVICE_ATTR.*S_IWUGO/ ) { | 5440 | $line =~ /DEVICE_ATTR.*\b$mode_perms_world_writable\b/) { |
5323 | WARN("EXPORTED_WORLD_WRITABLE", | 5441 | WARN("EXPORTED_WORLD_WRITABLE", |
5324 | "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr); | 5442 | "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr); |
5325 | } | 5443 | } |
diff --git a/scripts/coccinelle/misc/bugon.cocci b/scripts/coccinelle/misc/bugon.cocci index 3b7eec24fb5a..27c97f1f2767 100644 --- a/scripts/coccinelle/misc/bugon.cocci +++ b/scripts/coccinelle/misc/bugon.cocci | |||
@@ -57,6 +57,6 @@ coccilib.org.print_todo(p[0], "WARNING use BUG_ON") | |||
57 | p << r.p; | 57 | p << r.p; |
58 | @@ | 58 | @@ |
59 | 59 | ||
60 | msg="WARNING: Use BUG_ON" | 60 | msg="WARNING: Use BUG_ON instead of if condition followed by BUG.\nPlease make sure the condition has no side effects (see conditional BUG_ON definition in include/asm-generic/bug.h)" |
61 | coccilib.report.print_report(p[0], msg) | 61 | coccilib.report.print_report(p[0], msg) |
62 | 62 | ||
diff --git a/scripts/coccinelle/misc/irqf_oneshot.cocci b/scripts/coccinelle/misc/irqf_oneshot.cocci index 6cfde94be0ef..a24a754ae1d7 100644 --- a/scripts/coccinelle/misc/irqf_oneshot.cocci +++ b/scripts/coccinelle/misc/irqf_oneshot.cocci | |||
@@ -12,11 +12,13 @@ virtual org | |||
12 | virtual report | 12 | virtual report |
13 | 13 | ||
14 | @r1@ | 14 | @r1@ |
15 | expression dev; | ||
15 | expression irq; | 16 | expression irq; |
16 | expression thread_fn; | 17 | expression thread_fn; |
17 | expression flags; | 18 | expression flags; |
18 | position p; | 19 | position p; |
19 | @@ | 20 | @@ |
21 | ( | ||
20 | request_threaded_irq@p(irq, NULL, thread_fn, | 22 | request_threaded_irq@p(irq, NULL, thread_fn, |
21 | ( | 23 | ( |
22 | flags | IRQF_ONESHOT | 24 | flags | IRQF_ONESHOT |
@@ -24,13 +26,24 @@ flags | IRQF_ONESHOT | |||
24 | IRQF_ONESHOT | 26 | IRQF_ONESHOT |
25 | ) | 27 | ) |
26 | , ...) | 28 | , ...) |
29 | | | ||
30 | devm_request_threaded_irq@p(dev, irq, NULL, thread_fn, | ||
31 | ( | ||
32 | flags | IRQF_ONESHOT | ||
33 | | | ||
34 | IRQF_ONESHOT | ||
35 | ) | ||
36 | , ...) | ||
37 | ) | ||
27 | 38 | ||
28 | @depends on patch@ | 39 | @depends on patch@ |
40 | expression dev; | ||
29 | expression irq; | 41 | expression irq; |
30 | expression thread_fn; | 42 | expression thread_fn; |
31 | expression flags; | 43 | expression flags; |
32 | position p != r1.p; | 44 | position p != r1.p; |
33 | @@ | 45 | @@ |
46 | ( | ||
34 | request_threaded_irq@p(irq, NULL, thread_fn, | 47 | request_threaded_irq@p(irq, NULL, thread_fn, |
35 | ( | 48 | ( |
36 | -0 | 49 | -0 |
@@ -40,6 +53,17 @@ request_threaded_irq@p(irq, NULL, thread_fn, | |||
40 | +flags | IRQF_ONESHOT | 53 | +flags | IRQF_ONESHOT |
41 | ) | 54 | ) |
42 | , ...) | 55 | , ...) |
56 | | | ||
57 | devm_request_threaded_irq@p(dev, irq, NULL, thread_fn, | ||
58 | ( | ||
59 | -0 | ||
60 | +IRQF_ONESHOT | ||
61 | | | ||
62 | -flags | ||
63 | +flags | IRQF_ONESHOT | ||
64 | ) | ||
65 | , ...) | ||
66 | ) | ||
43 | 67 | ||
44 | @depends on context@ | 68 | @depends on context@ |
45 | position p != r1.p; | 69 | position p != r1.p; |
diff --git a/scripts/extract-ikconfig b/scripts/extract-ikconfig index e1862429ccda..3b42f255e2ba 100755 --- a/scripts/extract-ikconfig +++ b/scripts/extract-ikconfig | |||
@@ -61,6 +61,7 @@ try_decompress '\3757zXZ\000' abcde unxz | |||
61 | try_decompress 'BZh' xy bunzip2 | 61 | try_decompress 'BZh' xy bunzip2 |
62 | try_decompress '\135\0\0\0' xxx unlzma | 62 | try_decompress '\135\0\0\0' xxx unlzma |
63 | try_decompress '\211\114\132' xy 'lzop -d' | 63 | try_decompress '\211\114\132' xy 'lzop -d' |
64 | try_decompress '\002\041\114\030' xyy 'lz4 -d -l' | ||
64 | 65 | ||
65 | # Bail out: | 66 | # Bail out: |
66 | echo "$me: Cannot find kernel config." >&2 | 67 | echo "$me: Cannot find kernel config." >&2 |
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index c6d33bd15b04..8fa81e84e295 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c | |||
@@ -212,15 +212,22 @@ static int symbol_valid(struct sym_entry *s) | |||
212 | "_SDA_BASE_", /* ppc */ | 212 | "_SDA_BASE_", /* ppc */ |
213 | "_SDA2_BASE_", /* ppc */ | 213 | "_SDA2_BASE_", /* ppc */ |
214 | NULL }; | 214 | NULL }; |
215 | |||
216 | static char *special_suffixes[] = { | ||
217 | "_veneer", /* arm */ | ||
218 | NULL }; | ||
219 | |||
215 | int i; | 220 | int i; |
216 | int offset = 1; | 221 | char *sym_name = (char *)s->sym + 1; |
222 | |||
217 | 223 | ||
218 | if (s->addr < kernel_start_addr) | 224 | if (s->addr < kernel_start_addr) |
219 | return 0; | 225 | return 0; |
220 | 226 | ||
221 | /* skip prefix char */ | 227 | /* skip prefix char */ |
222 | if (symbol_prefix_char && *(s->sym + 1) == symbol_prefix_char) | 228 | if (symbol_prefix_char && *sym_name == symbol_prefix_char) |
223 | offset++; | 229 | sym_name++; |
230 | |||
224 | 231 | ||
225 | /* if --all-symbols is not specified, then symbols outside the text | 232 | /* if --all-symbols is not specified, then symbols outside the text |
226 | * and inittext sections are discarded */ | 233 | * and inittext sections are discarded */ |
@@ -235,22 +242,26 @@ static int symbol_valid(struct sym_entry *s) | |||
235 | * rules. | 242 | * rules. |
236 | */ | 243 | */ |
237 | if ((s->addr == text_range_text->end && | 244 | if ((s->addr == text_range_text->end && |
238 | strcmp((char *)s->sym + offset, | 245 | strcmp(sym_name, |
239 | text_range_text->end_sym)) || | 246 | text_range_text->end_sym)) || |
240 | (s->addr == text_range_inittext->end && | 247 | (s->addr == text_range_inittext->end && |
241 | strcmp((char *)s->sym + offset, | 248 | strcmp(sym_name, |
242 | text_range_inittext->end_sym))) | 249 | text_range_inittext->end_sym))) |
243 | return 0; | 250 | return 0; |
244 | } | 251 | } |
245 | 252 | ||
246 | /* Exclude symbols which vary between passes. */ | 253 | /* Exclude symbols which vary between passes. */ |
247 | if (strstr((char *)s->sym + offset, "_compiled.")) | ||
248 | return 0; | ||
249 | |||
250 | for (i = 0; special_symbols[i]; i++) | 254 | for (i = 0; special_symbols[i]; i++) |
251 | if( strcmp((char *)s->sym + offset, special_symbols[i]) == 0 ) | 255 | if (strcmp(sym_name, special_symbols[i]) == 0) |
252 | return 0; | 256 | return 0; |
253 | 257 | ||
258 | for (i = 0; special_suffixes[i]; i++) { | ||
259 | int l = strlen(sym_name) - strlen(special_suffixes[i]); | ||
260 | |||
261 | if (l >= 0 && strcmp(sym_name + l, special_suffixes[i]) == 0) | ||
262 | return 0; | ||
263 | } | ||
264 | |||
254 | return 1; | 265 | return 1; |
255 | } | 266 | } |
256 | 267 | ||
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 9645c0739386..d9b1fef0c67e 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # Kernel configuration targets | 2 | # Kernel configuration targets |
3 | # These targets are used from top-level makefile | 3 | # These targets are used from top-level makefile |
4 | 4 | ||
5 | PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config \ | 5 | PHONY += xconfig gconfig menuconfig config silentoldconfig update-po-config \ |
6 | localmodconfig localyesconfig | 6 | localmodconfig localyesconfig |
7 | 7 | ||
8 | ifdef KBUILD_KCONFIG | 8 | ifdef KBUILD_KCONFIG |
@@ -11,30 +11,31 @@ else | |||
11 | Kconfig := Kconfig | 11 | Kconfig := Kconfig |
12 | endif | 12 | endif |
13 | 13 | ||
14 | ifeq ($(quiet),silent_) | ||
15 | silent := -s | ||
16 | endif | ||
17 | |||
14 | # We need this, in case the user has it in its environment | 18 | # We need this, in case the user has it in its environment |
15 | unexport CONFIG_ | 19 | unexport CONFIG_ |
16 | 20 | ||
17 | xconfig: $(obj)/qconf | 21 | xconfig: $(obj)/qconf |
18 | $< $(Kconfig) | 22 | $< $(silent) $(Kconfig) |
19 | 23 | ||
20 | gconfig: $(obj)/gconf | 24 | gconfig: $(obj)/gconf |
21 | $< $(Kconfig) | 25 | $< $(silent) $(Kconfig) |
22 | 26 | ||
23 | menuconfig: $(obj)/mconf | 27 | menuconfig: $(obj)/mconf |
24 | $< $(Kconfig) | 28 | $< $(silent) $(Kconfig) |
25 | 29 | ||
26 | config: $(obj)/conf | 30 | config: $(obj)/conf |
27 | $< --oldaskconfig $(Kconfig) | 31 | $< $(silent) --oldaskconfig $(Kconfig) |
28 | 32 | ||
29 | nconfig: $(obj)/nconf | 33 | nconfig: $(obj)/nconf |
30 | $< $(Kconfig) | 34 | $< $(silent) $(Kconfig) |
31 | |||
32 | oldconfig: $(obj)/conf | ||
33 | $< --$@ $(Kconfig) | ||
34 | 35 | ||
35 | silentoldconfig: $(obj)/conf | 36 | silentoldconfig: $(obj)/conf |
36 | $(Q)mkdir -p include/config include/generated | 37 | $(Q)mkdir -p include/config include/generated |
37 | $< --$@ $(Kconfig) | 38 | $< $(silent) --$@ $(Kconfig) |
38 | 39 | ||
39 | localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf | 40 | localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf |
40 | $(Q)mkdir -p include/config include/generated | 41 | $(Q)mkdir -p include/config include/generated |
@@ -43,18 +44,18 @@ localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf | |||
43 | cmp -s .tmp.config .config || \ | 44 | cmp -s .tmp.config .config || \ |
44 | (mv -f .config .config.old.1; \ | 45 | (mv -f .config .config.old.1; \ |
45 | mv -f .tmp.config .config; \ | 46 | mv -f .tmp.config .config; \ |
46 | $(obj)/conf --silentoldconfig $(Kconfig); \ | 47 | $(obj)/conf $(silent) --silentoldconfig $(Kconfig); \ |
47 | mv -f .config.old.1 .config.old) \ | 48 | mv -f .config.old.1 .config.old) \ |
48 | else \ | 49 | else \ |
49 | mv -f .tmp.config .config; \ | 50 | mv -f .tmp.config .config; \ |
50 | $(obj)/conf --silentoldconfig $(Kconfig); \ | 51 | $(obj)/conf $(silent) --silentoldconfig $(Kconfig); \ |
51 | fi | 52 | fi |
52 | $(Q)rm -f .tmp.config | 53 | $(Q)rm -f .tmp.config |
53 | 54 | ||
54 | # Create new linux.pot file | 55 | # Create new linux.pot file |
55 | # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files | 56 | # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files |
56 | update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h | 57 | update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h |
57 | $(Q)echo " GEN config.pot" | 58 | $(Q)$(kecho) " GEN config.pot" |
58 | $(Q)xgettext --default-domain=linux \ | 59 | $(Q)xgettext --default-domain=linux \ |
59 | --add-comments --keyword=_ --keyword=N_ \ | 60 | --add-comments --keyword=_ --keyword=N_ \ |
60 | --from-code=UTF-8 \ | 61 | --from-code=UTF-8 \ |
@@ -65,61 +66,58 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h | |||
65 | $(Q)(for i in `ls $(srctree)/arch/*/Kconfig \ | 66 | $(Q)(for i in `ls $(srctree)/arch/*/Kconfig \ |
66 | $(srctree)/arch/*/um/Kconfig`; \ | 67 | $(srctree)/arch/*/um/Kconfig`; \ |
67 | do \ | 68 | do \ |
68 | echo " GEN $$i"; \ | 69 | $(kecho) " GEN $$i"; \ |
69 | $(obj)/kxgettext $$i \ | 70 | $(obj)/kxgettext $$i \ |
70 | >> $(obj)/config.pot; \ | 71 | >> $(obj)/config.pot; \ |
71 | done ) | 72 | done ) |
72 | $(Q)echo " GEN linux.pot" | 73 | $(Q)$(kecho) " GEN linux.pot" |
73 | $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ | 74 | $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ |
74 | --output $(obj)/linux.pot | 75 | --output $(obj)/linux.pot |
75 | $(Q)rm -f $(obj)/config.pot | 76 | $(Q)rm -f $(obj)/config.pot |
76 | 77 | ||
77 | PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig | 78 | # These targets map 1:1 to the commandline options of 'conf' |
78 | 79 | simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \ | |
79 | allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf | 80 | alldefconfig randconfig listnewconfig olddefconfig |
80 | $< --$@ $(Kconfig) | 81 | PHONY += $(simple-targets) |
81 | 82 | ||
82 | PHONY += listnewconfig olddefconfig oldnoconfig savedefconfig defconfig | 83 | $(simple-targets): $(obj)/conf |
84 | $< $(silent) --$@ $(Kconfig) | ||
83 | 85 | ||
84 | listnewconfig olddefconfig: $(obj)/conf | 86 | PHONY += oldnoconfig savedefconfig defconfig |
85 | $< --$@ $(Kconfig) | ||
86 | 87 | ||
87 | # oldnoconfig is an alias of olddefconfig, because people already are dependent | 88 | # oldnoconfig is an alias of olddefconfig, because people already are dependent |
88 | # on its behavior(sets new symbols to their default value but not 'n') with the | 89 | # on its behavior(sets new symbols to their default value but not 'n') with the |
89 | # counter-intuitive name. | 90 | # counter-intuitive name. |
90 | oldnoconfig: $(obj)/conf | 91 | oldnoconfig: olddefconfig |
91 | $< --olddefconfig $(Kconfig) | ||
92 | 92 | ||
93 | savedefconfig: $(obj)/conf | 93 | savedefconfig: $(obj)/conf |
94 | $< --$@=defconfig $(Kconfig) | 94 | $< $(silent) --$@=defconfig $(Kconfig) |
95 | 95 | ||
96 | defconfig: $(obj)/conf | 96 | defconfig: $(obj)/conf |
97 | ifeq ($(KBUILD_DEFCONFIG),) | 97 | ifeq ($(KBUILD_DEFCONFIG),) |
98 | $< --defconfig $(Kconfig) | 98 | $< $(silent) --defconfig $(Kconfig) |
99 | else | 99 | else |
100 | @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" | 100 | @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" |
101 | $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) | 101 | $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) |
102 | endif | 102 | endif |
103 | 103 | ||
104 | %_defconfig: $(obj)/conf | 104 | %_defconfig: $(obj)/conf |
105 | $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) | 105 | $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) |
106 | 106 | ||
107 | configfiles=$(wildcard $(srctree)/kernel/configs/$(1).config $(srctree)/arch/$(SRCARCH)/configs/$(1).config) | 107 | configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@) |
108 | 108 | ||
109 | define mergeconfig | 109 | %.config: $(obj)/conf |
110 | $(if $(wildcard $(objtree)/.config),, $(error You need an existing .config for this target)) | 110 | $(if $(call configfiles),, $(error No configuration exists for this target on this architecture)) |
111 | $(if $(call configfiles,$(1)),, $(error No configuration exists for this target on this architecture)) | 111 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles) |
112 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m -O $(objtree) $(objtree)/.config $(call configfiles,$(1)) | 112 | +$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig |
113 | $(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig | ||
114 | endef | ||
115 | 113 | ||
116 | PHONY += kvmconfig | 114 | PHONY += kvmconfig |
117 | kvmconfig: | 115 | kvmconfig: kvm_guest.config |
118 | $(call mergeconfig,kvm_guest) | 116 | @: |
119 | 117 | ||
120 | PHONY += tinyconfig | 118 | PHONY += tinyconfig |
121 | tinyconfig: allnoconfig | 119 | tinyconfig: |
122 | $(call mergeconfig,tiny) | 120 | $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config |
123 | 121 | ||
124 | # Help text used by make help | 122 | # Help text used by make help |
125 | help: | 123 | help: |
@@ -221,7 +219,7 @@ $(obj)/.tmp_qtcheck: $(src)/Makefile | |||
221 | 219 | ||
222 | # QT needs some extra effort... | 220 | # QT needs some extra effort... |
223 | $(obj)/.tmp_qtcheck: | 221 | $(obj)/.tmp_qtcheck: |
224 | @set -e; echo " CHECK qt"; dir=""; pkg=""; \ | 222 | @set -e; $(kecho) " CHECK qt"; dir=""; pkg=""; \ |
225 | if ! pkg-config --exists QtCore 2> /dev/null; then \ | 223 | if ! pkg-config --exists QtCore 2> /dev/null; then \ |
226 | echo "* Unable to find the QT4 tool qmake. Trying to use QT3"; \ | 224 | echo "* Unable to find the QT4 tool qmake. Trying to use QT3"; \ |
227 | pkg-config --exists qt 2> /dev/null && pkg=qt; \ | 225 | pkg-config --exists qt 2> /dev/null && pkg=qt; \ |
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index fef75fc756f4..6c204318bc94 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c | |||
@@ -471,7 +471,7 @@ static struct option long_opts[] = { | |||
471 | static void conf_usage(const char *progname) | 471 | static void conf_usage(const char *progname) |
472 | { | 472 | { |
473 | 473 | ||
474 | printf("Usage: %s [option] <kconfig-file>\n", progname); | 474 | printf("Usage: %s [-s] [option] <kconfig-file>\n", progname); |
475 | printf("[option] is _one_ of the following:\n"); | 475 | printf("[option] is _one_ of the following:\n"); |
476 | printf(" --listnewconfig List new options\n"); | 476 | printf(" --listnewconfig List new options\n"); |
477 | printf(" --oldaskconfig Start a new configuration using a line-oriented program\n"); | 477 | printf(" --oldaskconfig Start a new configuration using a line-oriented program\n"); |
@@ -501,7 +501,11 @@ int main(int ac, char **av) | |||
501 | 501 | ||
502 | tty_stdio = isatty(0) && isatty(1) && isatty(2); | 502 | tty_stdio = isatty(0) && isatty(1) && isatty(2); |
503 | 503 | ||
504 | while ((opt = getopt_long(ac, av, "", long_opts, NULL)) != -1) { | 504 | while ((opt = getopt_long(ac, av, "s", long_opts, NULL)) != -1) { |
505 | if (opt == 's') { | ||
506 | conf_set_message_callback(NULL); | ||
507 | continue; | ||
508 | } | ||
505 | input_mode = (enum input_mode)opt; | 509 | input_mode = (enum input_mode)opt; |
506 | switch (opt) { | 510 | switch (opt) { |
507 | case silentoldconfig: | 511 | case silentoldconfig: |
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 28df18dd1147..c814f57672fc 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c | |||
@@ -16,6 +16,11 @@ | |||
16 | 16 | ||
17 | #include "lkc.h" | 17 | #include "lkc.h" |
18 | 18 | ||
19 | struct conf_printer { | ||
20 | void (*print_symbol)(FILE *, struct symbol *, const char *, void *); | ||
21 | void (*print_comment)(FILE *, const char *, void *); | ||
22 | }; | ||
23 | |||
19 | static void conf_warning(const char *fmt, ...) | 24 | static void conf_warning(const char *fmt, ...) |
20 | __attribute__ ((format (printf, 1, 2))); | 25 | __attribute__ ((format (printf, 1, 2))); |
21 | 26 | ||
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index d6626521f9b9..fb0a2a286dca 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c | |||
@@ -11,6 +11,12 @@ | |||
11 | 11 | ||
12 | #define DEBUG_EXPR 0 | 12 | #define DEBUG_EXPR 0 |
13 | 13 | ||
14 | static int expr_eq(struct expr *e1, struct expr *e2); | ||
15 | static struct expr *expr_eliminate_yn(struct expr *e); | ||
16 | static struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2); | ||
17 | static struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2); | ||
18 | static void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2); | ||
19 | |||
14 | struct expr *expr_alloc_symbol(struct symbol *sym) | 20 | struct expr *expr_alloc_symbol(struct symbol *sym) |
15 | { | 21 | { |
16 | struct expr *e = xcalloc(1, sizeof(*e)); | 22 | struct expr *e = xcalloc(1, sizeof(*e)); |
@@ -186,7 +192,7 @@ void expr_eliminate_eq(struct expr **ep1, struct expr **ep2) | |||
186 | #undef e1 | 192 | #undef e1 |
187 | #undef e2 | 193 | #undef e2 |
188 | 194 | ||
189 | int expr_eq(struct expr *e1, struct expr *e2) | 195 | static int expr_eq(struct expr *e1, struct expr *e2) |
190 | { | 196 | { |
191 | int res, old_count; | 197 | int res, old_count; |
192 | 198 | ||
@@ -228,7 +234,7 @@ int expr_eq(struct expr *e1, struct expr *e2) | |||
228 | return 0; | 234 | return 0; |
229 | } | 235 | } |
230 | 236 | ||
231 | struct expr *expr_eliminate_yn(struct expr *e) | 237 | static struct expr *expr_eliminate_yn(struct expr *e) |
232 | { | 238 | { |
233 | struct expr *tmp; | 239 | struct expr *tmp; |
234 | 240 | ||
@@ -823,7 +829,7 @@ bool expr_depends_symbol(struct expr *dep, struct symbol *sym) | |||
823 | return false; | 829 | return false; |
824 | } | 830 | } |
825 | 831 | ||
826 | struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2) | 832 | static struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2) |
827 | { | 833 | { |
828 | struct expr *tmp = NULL; | 834 | struct expr *tmp = NULL; |
829 | expr_extract_eq(E_AND, &tmp, ep1, ep2); | 835 | expr_extract_eq(E_AND, &tmp, ep1, ep2); |
@@ -834,7 +840,7 @@ struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2) | |||
834 | return tmp; | 840 | return tmp; |
835 | } | 841 | } |
836 | 842 | ||
837 | struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2) | 843 | static struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2) |
838 | { | 844 | { |
839 | struct expr *tmp = NULL; | 845 | struct expr *tmp = NULL; |
840 | expr_extract_eq(E_OR, &tmp, ep1, ep2); | 846 | expr_extract_eq(E_OR, &tmp, ep1, ep2); |
@@ -845,7 +851,7 @@ struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2) | |||
845 | return tmp; | 851 | return tmp; |
846 | } | 852 | } |
847 | 853 | ||
848 | void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2) | 854 | static void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2) |
849 | { | 855 | { |
850 | #define e1 (*ep1) | 856 | #define e1 (*ep1) |
851 | #define e2 (*ep2) | 857 | #define e2 (*ep2) |
@@ -976,11 +982,8 @@ tristate expr_calc_value(struct expr *e) | |||
976 | } | 982 | } |
977 | } | 983 | } |
978 | 984 | ||
979 | int expr_compare_type(enum expr_type t1, enum expr_type t2) | 985 | static int expr_compare_type(enum expr_type t1, enum expr_type t2) |
980 | { | 986 | { |
981 | #if 0 | ||
982 | return 1; | ||
983 | #else | ||
984 | if (t1 == t2) | 987 | if (t1 == t2) |
985 | return 0; | 988 | return 0; |
986 | switch (t1) { | 989 | switch (t1) { |
@@ -1005,7 +1008,6 @@ int expr_compare_type(enum expr_type t1, enum expr_type t2) | |||
1005 | } | 1008 | } |
1006 | printf("[%dgt%d?]", t1, t2); | 1009 | printf("[%dgt%d?]", t1, t2); |
1007 | return 0; | 1010 | return 0; |
1008 | #endif | ||
1009 | } | 1011 | } |
1010 | 1012 | ||
1011 | static inline struct expr * | 1013 | static inline struct expr * |
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 412ea8a2abb8..a2fc96a2bd2c 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h | |||
@@ -205,18 +205,13 @@ struct expr *expr_alloc_and(struct expr *e1, struct expr *e2); | |||
205 | struct expr *expr_alloc_or(struct expr *e1, struct expr *e2); | 205 | struct expr *expr_alloc_or(struct expr *e1, struct expr *e2); |
206 | struct expr *expr_copy(const struct expr *org); | 206 | struct expr *expr_copy(const struct expr *org); |
207 | void expr_free(struct expr *e); | 207 | void expr_free(struct expr *e); |
208 | int expr_eq(struct expr *e1, struct expr *e2); | ||
209 | void expr_eliminate_eq(struct expr **ep1, struct expr **ep2); | 208 | void expr_eliminate_eq(struct expr **ep1, struct expr **ep2); |
210 | tristate expr_calc_value(struct expr *e); | 209 | tristate expr_calc_value(struct expr *e); |
211 | struct expr *expr_eliminate_yn(struct expr *e); | ||
212 | struct expr *expr_trans_bool(struct expr *e); | 210 | struct expr *expr_trans_bool(struct expr *e); |
213 | struct expr *expr_eliminate_dups(struct expr *e); | 211 | struct expr *expr_eliminate_dups(struct expr *e); |
214 | struct expr *expr_transform(struct expr *e); | 212 | struct expr *expr_transform(struct expr *e); |
215 | int expr_contains_symbol(struct expr *dep, struct symbol *sym); | 213 | int expr_contains_symbol(struct expr *dep, struct symbol *sym); |
216 | bool expr_depends_symbol(struct expr *dep, struct symbol *sym); | 214 | bool expr_depends_symbol(struct expr *dep, struct symbol *sym); |
217 | struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2); | ||
218 | struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2); | ||
219 | void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2); | ||
220 | struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); | 215 | struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); |
221 | struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2); | 216 | struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2); |
222 | 217 | ||
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index d0a35b21f308..26d208b435a0 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c | |||
@@ -169,14 +169,6 @@ void init_main_window(const gchar * glade_file) | |||
169 | style = gtk_widget_get_style(main_wnd); | 169 | style = gtk_widget_get_style(main_wnd); |
170 | widget = glade_xml_get_widget(xml, "toolbar1"); | 170 | widget = glade_xml_get_widget(xml, "toolbar1"); |
171 | 171 | ||
172 | #if 0 /* Use stock Gtk icons instead */ | ||
173 | replace_button_icon(xml, main_wnd->window, style, | ||
174 | "button1", (gchar **) xpm_back); | ||
175 | replace_button_icon(xml, main_wnd->window, style, | ||
176 | "button2", (gchar **) xpm_load); | ||
177 | replace_button_icon(xml, main_wnd->window, style, | ||
178 | "button3", (gchar **) xpm_save); | ||
179 | #endif | ||
180 | replace_button_icon(xml, main_wnd->window, style, | 172 | replace_button_icon(xml, main_wnd->window, style, |
181 | "button4", (gchar **) xpm_single_view); | 173 | "button4", (gchar **) xpm_single_view); |
182 | replace_button_icon(xml, main_wnd->window, style, | 174 | replace_button_icon(xml, main_wnd->window, style, |
@@ -184,22 +176,6 @@ void init_main_window(const gchar * glade_file) | |||
184 | replace_button_icon(xml, main_wnd->window, style, | 176 | replace_button_icon(xml, main_wnd->window, style, |
185 | "button6", (gchar **) xpm_tree_view); | 177 | "button6", (gchar **) xpm_tree_view); |
186 | 178 | ||
187 | #if 0 | ||
188 | switch (view_mode) { | ||
189 | case SINGLE_VIEW: | ||
190 | widget = glade_xml_get_widget(xml, "button4"); | ||
191 | g_signal_emit_by_name(widget, "clicked"); | ||
192 | break; | ||
193 | case SPLIT_VIEW: | ||
194 | widget = glade_xml_get_widget(xml, "button5"); | ||
195 | g_signal_emit_by_name(widget, "clicked"); | ||
196 | break; | ||
197 | case FULL_VIEW: | ||
198 | widget = glade_xml_get_widget(xml, "button6"); | ||
199 | g_signal_emit_by_name(widget, "clicked"); | ||
200 | break; | ||
201 | } | ||
202 | #endif | ||
203 | txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w)); | 179 | txtbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text_w)); |
204 | tag1 = gtk_text_buffer_create_tag(txtbuf, "mytag1", | 180 | tag1 = gtk_text_buffer_create_tag(txtbuf, "mytag1", |
205 | "foreground", "red", | 181 | "foreground", "red", |
@@ -1498,9 +1474,12 @@ int main(int ac, char *av[]) | |||
1498 | case 'a': | 1474 | case 'a': |
1499 | //showAll = 1; | 1475 | //showAll = 1; |
1500 | break; | 1476 | break; |
1477 | case 's': | ||
1478 | conf_set_message_callback(NULL); | ||
1479 | break; | ||
1501 | case 'h': | 1480 | case 'h': |
1502 | case '?': | 1481 | case '?': |
1503 | printf("%s <config>\n", av[0]); | 1482 | printf("%s [-s] <config>\n", av[0]); |
1504 | exit(0); | 1483 | exit(0); |
1505 | } | 1484 | } |
1506 | name = av[2]; | 1485 | name = av[2]; |
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index d5daa7af8b49..91ca126ea080 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h | |||
@@ -21,9 +21,7 @@ static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; | |||
21 | extern "C" { | 21 | extern "C" { |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | #define P(name,type,arg) extern type name arg | ||
25 | #include "lkc_proto.h" | 24 | #include "lkc_proto.h" |
26 | #undef P | ||
27 | 25 | ||
28 | #define SRCTREE "srctree" | 26 | #define SRCTREE "srctree" |
29 | 27 | ||
@@ -70,9 +68,6 @@ struct kconf_id { | |||
70 | enum symbol_type stype; | 68 | enum symbol_type stype; |
71 | }; | 69 | }; |
72 | 70 | ||
73 | extern int zconfdebug; | ||
74 | |||
75 | int zconfparse(void); | ||
76 | void zconfdump(FILE *out); | 71 | void zconfdump(FILE *out); |
77 | void zconf_starthelp(void); | 72 | void zconf_starthelp(void); |
78 | FILE *zconf_fopen(const char *name); | 73 | FILE *zconf_fopen(const char *name); |
@@ -90,11 +85,6 @@ void sym_add_change_count(int count); | |||
90 | bool conf_set_all_new_symbols(enum conf_def_mode mode); | 85 | bool conf_set_all_new_symbols(enum conf_def_mode mode); |
91 | void set_all_choice_values(struct symbol *csym); | 86 | void set_all_choice_values(struct symbol *csym); |
92 | 87 | ||
93 | struct conf_printer { | ||
94 | void (*print_symbol)(FILE *, struct symbol *, const char *, void *); | ||
95 | void (*print_comment)(FILE *, const char *, void *); | ||
96 | }; | ||
97 | |||
98 | /* confdata.c and expr.c */ | 88 | /* confdata.c and expr.c */ |
99 | static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) | 89 | static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) |
100 | { | 90 | { |
@@ -113,7 +103,6 @@ void menu_add_entry(struct symbol *sym); | |||
113 | void menu_end_entry(void); | 103 | void menu_end_entry(void); |
114 | void menu_add_dep(struct expr *dep); | 104 | void menu_add_dep(struct expr *dep); |
115 | void menu_add_visibility(struct expr *dep); | 105 | void menu_add_visibility(struct expr *dep); |
116 | struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep); | ||
117 | struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); | 106 | struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); |
118 | void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); | 107 | void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); |
119 | void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); | 108 | void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); |
@@ -137,7 +126,6 @@ struct gstr { | |||
137 | int max_width; | 126 | int max_width; |
138 | }; | 127 | }; |
139 | struct gstr str_new(void); | 128 | struct gstr str_new(void); |
140 | struct gstr str_assign(const char *s); | ||
141 | void str_free(struct gstr *gs); | 129 | void str_free(struct gstr *gs); |
142 | void str_append(struct gstr *gs, const char *s); | 130 | void str_append(struct gstr *gs, const char *s); |
143 | void str_printf(struct gstr *gs, const char *fmt, ...); | 131 | void str_printf(struct gstr *gs, const char *fmt, ...); |
@@ -148,8 +136,6 @@ extern struct expr *sym_env_list; | |||
148 | 136 | ||
149 | void sym_init(void); | 137 | void sym_init(void); |
150 | void sym_clear_all_valid(void); | 138 | void sym_clear_all_valid(void); |
151 | void sym_set_all_changed(void); | ||
152 | void sym_set_changed(struct symbol *sym); | ||
153 | struct symbol *sym_choice_default(struct symbol *sym); | 139 | struct symbol *sym_choice_default(struct symbol *sym); |
154 | const char *sym_get_string_default(struct symbol *sym); | 140 | const char *sym_get_string_default(struct symbol *sym); |
155 | struct symbol *sym_check_deps(struct symbol *sym); | 141 | struct symbol *sym_check_deps(struct symbol *sym); |
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index ecdb9659b67d..d5398718ec2a 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h | |||
@@ -1,57 +1,52 @@ | |||
1 | #include <stdarg.h> | 1 | #include <stdarg.h> |
2 | 2 | ||
3 | /* confdata.c */ | 3 | /* confdata.c */ |
4 | P(conf_parse,void,(const char *name)); | 4 | void conf_parse(const char *name); |
5 | P(conf_read,int,(const char *name)); | 5 | int conf_read(const char *name); |
6 | P(conf_read_simple,int,(const char *name, int)); | 6 | int conf_read_simple(const char *name, int); |
7 | P(conf_write_defconfig,int,(const char *name)); | 7 | int conf_write_defconfig(const char *name); |
8 | P(conf_write,int,(const char *name)); | 8 | int conf_write(const char *name); |
9 | P(conf_write_autoconf,int,(void)); | 9 | int conf_write_autoconf(void); |
10 | P(conf_get_changed,bool,(void)); | 10 | bool conf_get_changed(void); |
11 | P(conf_set_changed_callback, void,(void (*fn)(void))); | 11 | void conf_set_changed_callback(void (*fn)(void)); |
12 | P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap))); | 12 | void conf_set_message_callback(void (*fn)(const char *fmt, va_list ap)); |
13 | 13 | ||
14 | /* menu.c */ | 14 | /* menu.c */ |
15 | P(rootmenu,struct menu,); | 15 | extern struct menu rootmenu; |
16 | 16 | ||
17 | P(menu_is_empty, bool, (struct menu *menu)); | 17 | bool menu_is_empty(struct menu *menu); |
18 | P(menu_is_visible, bool, (struct menu *menu)); | 18 | bool menu_is_visible(struct menu *menu); |
19 | P(menu_has_prompt, bool, (struct menu *menu)); | 19 | bool menu_has_prompt(struct menu *menu); |
20 | P(menu_get_prompt,const char *,(struct menu *menu)); | 20 | const char * menu_get_prompt(struct menu *menu); |
21 | P(menu_get_root_menu,struct menu *,(struct menu *menu)); | 21 | struct menu * menu_get_root_menu(struct menu *menu); |
22 | P(menu_get_parent_menu,struct menu *,(struct menu *menu)); | 22 | struct menu * menu_get_parent_menu(struct menu *menu); |
23 | P(menu_has_help,bool,(struct menu *menu)); | 23 | bool menu_has_help(struct menu *menu); |
24 | P(menu_get_help,const char *,(struct menu *menu)); | 24 | const char * menu_get_help(struct menu *menu); |
25 | P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct list_head | 25 | struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head); |
26 | *head)); | 26 | void menu_get_ext_help(struct menu *menu, struct gstr *help); |
27 | P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct list_head | ||
28 | *head)); | ||
29 | P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); | ||
30 | 27 | ||
31 | /* symbol.c */ | 28 | /* symbol.c */ |
32 | P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); | 29 | extern struct symbol * symbol_hash[SYMBOL_HASHSIZE]; |
33 | 30 | ||
34 | P(sym_lookup,struct symbol *,(const char *name, int flags)); | 31 | struct symbol * sym_lookup(const char *name, int flags); |
35 | P(sym_find,struct symbol *,(const char *name)); | 32 | struct symbol * sym_find(const char *name); |
36 | P(sym_expand_string_value,const char *,(const char *in)); | 33 | const char * sym_expand_string_value(const char *in); |
37 | P(sym_escape_string_value, const char *,(const char *in)); | 34 | const char * sym_escape_string_value(const char *in); |
38 | P(sym_re_search,struct symbol **,(const char *pattern)); | 35 | struct symbol ** sym_re_search(const char *pattern); |
39 | P(sym_type_name,const char *,(enum symbol_type type)); | 36 | const char * sym_type_name(enum symbol_type type); |
40 | P(sym_calc_value,void,(struct symbol *sym)); | 37 | void sym_calc_value(struct symbol *sym); |
41 | P(sym_get_type,enum symbol_type,(struct symbol *sym)); | 38 | enum symbol_type sym_get_type(struct symbol *sym); |
42 | P(sym_tristate_within_range,bool,(struct symbol *sym,tristate tri)); | 39 | bool sym_tristate_within_range(struct symbol *sym,tristate tri); |
43 | P(sym_set_tristate_value,bool,(struct symbol *sym,tristate tri)); | 40 | bool sym_set_tristate_value(struct symbol *sym,tristate tri); |
44 | P(sym_toggle_tristate_value,tristate,(struct symbol *sym)); | 41 | tristate sym_toggle_tristate_value(struct symbol *sym); |
45 | P(sym_string_valid,bool,(struct symbol *sym, const char *newval)); | 42 | bool sym_string_valid(struct symbol *sym, const char *newval); |
46 | P(sym_string_within_range,bool,(struct symbol *sym, const char *str)); | 43 | bool sym_string_within_range(struct symbol *sym, const char *str); |
47 | P(sym_set_string_value,bool,(struct symbol *sym, const char *newval)); | 44 | bool sym_set_string_value(struct symbol *sym, const char *newval); |
48 | P(sym_is_changable,bool,(struct symbol *sym)); | 45 | bool sym_is_changable(struct symbol *sym); |
49 | P(sym_get_choice_prop,struct property *,(struct symbol *sym)); | 46 | struct property * sym_get_choice_prop(struct symbol *sym); |
50 | P(sym_get_default_prop,struct property *,(struct symbol *sym)); | 47 | const char * sym_get_string_value(struct symbol *sym); |
51 | P(sym_get_string_value,const char *,(struct symbol *sym)); | ||
52 | 48 | ||
53 | P(prop_get_type_name,const char *,(enum prop_type type)); | 49 | const char * prop_get_type_name(enum prop_type type); |
54 | 50 | ||
55 | /* expr.c */ | 51 | /* expr.c */ |
56 | P(expr_compare_type,int,(enum expr_type t1, enum expr_type t2)); | 52 | void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken); |
57 | P(expr_print,void,(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)); | ||
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 4dd37552abc2..315ce2c7cb9d 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
@@ -279,6 +279,7 @@ static int child_count; | |||
279 | static int single_menu_mode; | 279 | static int single_menu_mode; |
280 | static int show_all_options; | 280 | static int show_all_options; |
281 | static int save_and_exit; | 281 | static int save_and_exit; |
282 | static int silent; | ||
282 | 283 | ||
283 | static void conf(struct menu *menu, struct menu *active_menu); | 284 | static void conf(struct menu *menu, struct menu *active_menu); |
284 | static void conf_choice(struct menu *menu); | 285 | static void conf_choice(struct menu *menu); |
@@ -777,10 +778,12 @@ static void conf_message_callback(const char *fmt, va_list ap) | |||
777 | char buf[PATH_MAX+1]; | 778 | char buf[PATH_MAX+1]; |
778 | 779 | ||
779 | vsnprintf(buf, sizeof(buf), fmt, ap); | 780 | vsnprintf(buf, sizeof(buf), fmt, ap); |
780 | if (save_and_exit) | 781 | if (save_and_exit) { |
781 | printf("%s", buf); | 782 | if (!silent) |
782 | else | 783 | printf("%s", buf); |
784 | } else { | ||
783 | show_textbox(NULL, buf, 6, 60); | 785 | show_textbox(NULL, buf, 6, 60); |
786 | } | ||
784 | } | 787 | } |
785 | 788 | ||
786 | static void show_help(struct menu *menu) | 789 | static void show_help(struct menu *menu) |
@@ -977,16 +980,18 @@ static int handle_exit(void) | |||
977 | } | 980 | } |
978 | /* fall through */ | 981 | /* fall through */ |
979 | case -1: | 982 | case -1: |
980 | printf(_("\n\n" | 983 | if (!silent) |
981 | "*** End of the configuration.\n" | 984 | printf(_("\n\n" |
982 | "*** Execute 'make' to start the build or try 'make help'." | 985 | "*** End of the configuration.\n" |
983 | "\n\n")); | 986 | "*** Execute 'make' to start the build or try 'make help'." |
987 | "\n\n")); | ||
984 | res = 0; | 988 | res = 0; |
985 | break; | 989 | break; |
986 | default: | 990 | default: |
987 | fprintf(stderr, _("\n\n" | 991 | if (!silent) |
988 | "Your configuration changes were NOT saved." | 992 | fprintf(stderr, _("\n\n" |
989 | "\n\n")); | 993 | "Your configuration changes were NOT saved." |
994 | "\n\n")); | ||
990 | if (res != KEY_ESC) | 995 | if (res != KEY_ESC) |
991 | res = 0; | 996 | res = 0; |
992 | } | 997 | } |
@@ -1010,6 +1015,12 @@ int main(int ac, char **av) | |||
1010 | 1015 | ||
1011 | signal(SIGINT, sig_handler); | 1016 | signal(SIGINT, sig_handler); |
1012 | 1017 | ||
1018 | if (ac > 1 && strcmp(av[1], "-s") == 0) { | ||
1019 | silent = 1; | ||
1020 | /* Silence conf_read() until the real callback is set up */ | ||
1021 | conf_set_message_callback(NULL); | ||
1022 | av++; | ||
1023 | } | ||
1013 | conf_parse(av[1]); | 1024 | conf_parse(av[1]); |
1014 | conf_read(NULL); | 1025 | conf_read(NULL); |
1015 | 1026 | ||
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 72c9dba84c5d..b05cc3d4a9be 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c | |||
@@ -125,7 +125,7 @@ void menu_set_type(int type) | |||
125 | sym_type_name(sym->type), sym_type_name(type)); | 125 | sym_type_name(sym->type), sym_type_name(type)); |
126 | } | 126 | } |
127 | 127 | ||
128 | struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep) | 128 | static struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep) |
129 | { | 129 | { |
130 | struct property *prop = prop_alloc(type, current_entry->sym); | 130 | struct property *prop = prop_alloc(type, current_entry->sym); |
131 | 131 | ||
@@ -615,7 +615,7 @@ static struct property *get_symbol_prop(struct symbol *sym) | |||
615 | /* | 615 | /* |
616 | * head is optional and may be NULL | 616 | * head is optional and may be NULL |
617 | */ | 617 | */ |
618 | void get_symbol_str(struct gstr *r, struct symbol *sym, | 618 | static void get_symbol_str(struct gstr *r, struct symbol *sym, |
619 | struct list_head *head) | 619 | struct list_head *head) |
620 | { | 620 | { |
621 | bool hit; | 621 | bool hit; |
diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh index 2ab91b9b100d..ec8e20350a64 100755 --- a/scripts/kconfig/merge_config.sh +++ b/scripts/kconfig/merge_config.sh | |||
@@ -35,7 +35,7 @@ usage() { | |||
35 | echo " -O dir to put generated output files" | 35 | echo " -O dir to put generated output files" |
36 | } | 36 | } |
37 | 37 | ||
38 | MAKE=true | 38 | RUNMAKE=true |
39 | ALLTARGET=alldefconfig | 39 | ALLTARGET=alldefconfig |
40 | WARNREDUN=false | 40 | WARNREDUN=false |
41 | OUTPUT=. | 41 | OUTPUT=. |
@@ -48,7 +48,7 @@ while true; do | |||
48 | continue | 48 | continue |
49 | ;; | 49 | ;; |
50 | "-m") | 50 | "-m") |
51 | MAKE=false | 51 | RUNMAKE=false |
52 | shift | 52 | shift |
53 | continue | 53 | continue |
54 | ;; | 54 | ;; |
@@ -85,6 +85,11 @@ fi | |||
85 | INITFILE=$1 | 85 | INITFILE=$1 |
86 | shift; | 86 | shift; |
87 | 87 | ||
88 | if [ ! -r "$INITFILE" ]; then | ||
89 | echo "The base file '$INITFILE' does not exist. Exit." >&2 | ||
90 | exit 1 | ||
91 | fi | ||
92 | |||
88 | MERGE_LIST=$* | 93 | MERGE_LIST=$* |
89 | SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p" | 94 | SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p" |
90 | TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX) | 95 | TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX) |
@@ -92,31 +97,29 @@ TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX) | |||
92 | echo "Using $INITFILE as base" | 97 | echo "Using $INITFILE as base" |
93 | cat $INITFILE > $TMP_FILE | 98 | cat $INITFILE > $TMP_FILE |
94 | 99 | ||
95 | # Merge files, printing warnings on overrided values | 100 | # Merge files, printing warnings on overridden values |
96 | for MERGE_FILE in $MERGE_LIST ; do | 101 | for MERGE_FILE in $MERGE_LIST ; do |
97 | echo "Merging $MERGE_FILE" | 102 | echo "Merging $MERGE_FILE" |
98 | CFG_LIST=$(sed -n "$SED_CONFIG_EXP" $MERGE_FILE) | 103 | CFG_LIST=$(sed -n "$SED_CONFIG_EXP" $MERGE_FILE) |
99 | 104 | ||
100 | for CFG in $CFG_LIST ; do | 105 | for CFG in $CFG_LIST ; do |
101 | grep -q -w $CFG $TMP_FILE | 106 | grep -q -w $CFG $TMP_FILE || continue |
102 | if [ $? -eq 0 ] ; then | 107 | PREV_VAL=$(grep -w $CFG $TMP_FILE) |
103 | PREV_VAL=$(grep -w $CFG $TMP_FILE) | 108 | NEW_VAL=$(grep -w $CFG $MERGE_FILE) |
104 | NEW_VAL=$(grep -w $CFG $MERGE_FILE) | 109 | if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then |
105 | if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then | ||
106 | echo Value of $CFG is redefined by fragment $MERGE_FILE: | 110 | echo Value of $CFG is redefined by fragment $MERGE_FILE: |
107 | echo Previous value: $PREV_VAL | 111 | echo Previous value: $PREV_VAL |
108 | echo New value: $NEW_VAL | 112 | echo New value: $NEW_VAL |
109 | echo | 113 | echo |
110 | elif [ "$WARNREDUN" = "true" ]; then | 114 | elif [ "$WARNREDUN" = "true" ]; then |
111 | echo Value of $CFG is redundant by fragment $MERGE_FILE: | 115 | echo Value of $CFG is redundant by fragment $MERGE_FILE: |
112 | fi | ||
113 | sed -i "/$CFG[ =]/d" $TMP_FILE | ||
114 | fi | 116 | fi |
117 | sed -i "/$CFG[ =]/d" $TMP_FILE | ||
115 | done | 118 | done |
116 | cat $MERGE_FILE >> $TMP_FILE | 119 | cat $MERGE_FILE >> $TMP_FILE |
117 | done | 120 | done |
118 | 121 | ||
119 | if [ "$MAKE" = "false" ]; then | 122 | if [ "$RUNMAKE" = "false" ]; then |
120 | cp $TMP_FILE $OUTPUT/.config | 123 | cp $TMP_FILE $OUTPUT/.config |
121 | echo "#" | 124 | echo "#" |
122 | echo "# merged configuration written to $OUTPUT/.config (needs make)" | 125 | echo "# merged configuration written to $OUTPUT/.config (needs make)" |
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 984489ef2b46..d42d534a66cd 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c | |||
@@ -1482,6 +1482,11 @@ int main(int ac, char **av) | |||
1482 | bindtextdomain(PACKAGE, LOCALEDIR); | 1482 | bindtextdomain(PACKAGE, LOCALEDIR); |
1483 | textdomain(PACKAGE); | 1483 | textdomain(PACKAGE); |
1484 | 1484 | ||
1485 | if (ac > 1 && strcmp(av[1], "-s") == 0) { | ||
1486 | /* Silence conf_read() until the real callback is set up */ | ||
1487 | conf_set_message_callback(NULL); | ||
1488 | av++; | ||
1489 | } | ||
1485 | conf_parse(av[1]); | 1490 | conf_parse(av[1]); |
1486 | conf_read(NULL); | 1491 | conf_read(NULL); |
1487 | 1492 | ||
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 9d3b04b0769c..c3bb7fe8dfa6 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc | |||
@@ -1746,7 +1746,7 @@ static const char *progname; | |||
1746 | 1746 | ||
1747 | static void usage(void) | 1747 | static void usage(void) |
1748 | { | 1748 | { |
1749 | printf(_("%s <config>\n"), progname); | 1749 | printf(_("%s [-s] <config>\n"), progname); |
1750 | exit(0); | 1750 | exit(0); |
1751 | } | 1751 | } |
1752 | 1752 | ||
@@ -1762,6 +1762,9 @@ int main(int ac, char** av) | |||
1762 | configApp = new QApplication(ac, av); | 1762 | configApp = new QApplication(ac, av); |
1763 | if (ac > 1 && av[1][0] == '-') { | 1763 | if (ac > 1 && av[1][0] == '-') { |
1764 | switch (av[1][1]) { | 1764 | switch (av[1][1]) { |
1765 | case 's': | ||
1766 | conf_set_message_callback(NULL); | ||
1767 | break; | ||
1765 | case 'h': | 1768 | case 'h': |
1766 | case '?': | 1769 | case '?': |
1767 | usage(); | 1770 | usage(); |
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 7caabdb51c64..6731377f9bb2 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c | |||
@@ -112,7 +112,7 @@ struct property *sym_get_env_prop(struct symbol *sym) | |||
112 | return NULL; | 112 | return NULL; |
113 | } | 113 | } |
114 | 114 | ||
115 | struct property *sym_get_default_prop(struct symbol *sym) | 115 | static struct property *sym_get_default_prop(struct symbol *sym) |
116 | { | 116 | { |
117 | struct property *prop; | 117 | struct property *prop; |
118 | 118 | ||
@@ -186,6 +186,26 @@ static void sym_validate_range(struct symbol *sym) | |||
186 | sym->curr.val = strdup(str); | 186 | sym->curr.val = strdup(str); |
187 | } | 187 | } |
188 | 188 | ||
189 | static void sym_set_changed(struct symbol *sym) | ||
190 | { | ||
191 | struct property *prop; | ||
192 | |||
193 | sym->flags |= SYMBOL_CHANGED; | ||
194 | for (prop = sym->prop; prop; prop = prop->next) { | ||
195 | if (prop->menu) | ||
196 | prop->menu->flags |= MENU_CHANGED; | ||
197 | } | ||
198 | } | ||
199 | |||
200 | static void sym_set_all_changed(void) | ||
201 | { | ||
202 | struct symbol *sym; | ||
203 | int i; | ||
204 | |||
205 | for_all_symbols(i, sym) | ||
206 | sym_set_changed(sym); | ||
207 | } | ||
208 | |||
189 | static void sym_calc_visibility(struct symbol *sym) | 209 | static void sym_calc_visibility(struct symbol *sym) |
190 | { | 210 | { |
191 | struct property *prop; | 211 | struct property *prop; |
@@ -451,26 +471,6 @@ void sym_clear_all_valid(void) | |||
451 | sym_calc_value(modules_sym); | 471 | sym_calc_value(modules_sym); |
452 | } | 472 | } |
453 | 473 | ||
454 | void sym_set_changed(struct symbol *sym) | ||
455 | { | ||
456 | struct property *prop; | ||
457 | |||
458 | sym->flags |= SYMBOL_CHANGED; | ||
459 | for (prop = sym->prop; prop; prop = prop->next) { | ||
460 | if (prop->menu) | ||
461 | prop->menu->flags |= MENU_CHANGED; | ||
462 | } | ||
463 | } | ||
464 | |||
465 | void sym_set_all_changed(void) | ||
466 | { | ||
467 | struct symbol *sym; | ||
468 | int i; | ||
469 | |||
470 | for_all_symbols(i, sym) | ||
471 | sym_set_changed(sym); | ||
472 | } | ||
473 | |||
474 | bool sym_tristate_within_range(struct symbol *sym, tristate val) | 474 | bool sym_tristate_within_range(struct symbol *sym, tristate val) |
475 | { | 475 | { |
476 | int type = sym_get_type(sym); | 476 | int type = sym_get_type(sym); |
diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 94f9c83e324f..0e76042473cc 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c | |||
@@ -88,16 +88,6 @@ struct gstr str_new(void) | |||
88 | return gs; | 88 | return gs; |
89 | } | 89 | } |
90 | 90 | ||
91 | /* Allocate and assign growable string */ | ||
92 | struct gstr str_assign(const char *s) | ||
93 | { | ||
94 | struct gstr gs; | ||
95 | gs.s = strdup(s); | ||
96 | gs.len = strlen(s) + 1; | ||
97 | gs.max_width = 0; | ||
98 | return gs; | ||
99 | } | ||
100 | |||
101 | /* Free storage for growable string */ | 91 | /* Free storage for growable string */ |
102 | void str_free(struct gstr *gs) | 92 | void str_free(struct gstr *gs) |
103 | { | 93 | { |
diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c index f282516acc7b..fce36d0f6898 100644 --- a/scripts/mod/devicetable-offsets.c +++ b/scripts/mod/devicetable-offsets.c | |||
@@ -168,6 +168,9 @@ int main(void) | |||
168 | DEVID_FIELD(amba_id, id); | 168 | DEVID_FIELD(amba_id, id); |
169 | DEVID_FIELD(amba_id, mask); | 169 | DEVID_FIELD(amba_id, mask); |
170 | 170 | ||
171 | DEVID(mips_cdmm_device_id); | ||
172 | DEVID_FIELD(mips_cdmm_device_id, type); | ||
173 | |||
171 | DEVID(x86_cpu_id); | 174 | DEVID(x86_cpu_id); |
172 | DEVID_FIELD(x86_cpu_id, feature); | 175 | DEVID_FIELD(x86_cpu_id, feature); |
173 | DEVID_FIELD(x86_cpu_id, family); | 176 | DEVID_FIELD(x86_cpu_id, family); |
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index e614ef689eee..78691d51a479 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -1109,6 +1109,22 @@ static int do_amba_entry(const char *filename, | |||
1109 | } | 1109 | } |
1110 | ADD_TO_DEVTABLE("amba", amba_id, do_amba_entry); | 1110 | ADD_TO_DEVTABLE("amba", amba_id, do_amba_entry); |
1111 | 1111 | ||
1112 | /* | ||
1113 | * looks like: "mipscdmm:tN" | ||
1114 | * | ||
1115 | * N is exactly 2 digits, where each is an upper-case hex digit, or | ||
1116 | * a ? or [] pattern matching exactly one digit. | ||
1117 | */ | ||
1118 | static int do_mips_cdmm_entry(const char *filename, | ||
1119 | void *symval, char *alias) | ||
1120 | { | ||
1121 | DEF_FIELD(symval, mips_cdmm_device_id, type); | ||
1122 | |||
1123 | sprintf(alias, "mipscdmm:t%02X*", type); | ||
1124 | return 1; | ||
1125 | } | ||
1126 | ADD_TO_DEVTABLE("mipscdmm", mips_cdmm_device_id, do_mips_cdmm_entry); | ||
1127 | |||
1112 | /* LOOKS like cpu:type:x86,venVVVVfamFFFFmodMMMM:feature:*,FEAT,* | 1128 | /* LOOKS like cpu:type:x86,venVVVVfamFFFFmodMMMM:feature:*,FEAT,* |
1113 | * All fields are numbers. It would be nicer to use strings for vendor | 1129 | * All fields are numbers. It would be nicer to use strings for vendor |
1114 | * and feature, but getting those out of the build system here is too | 1130 | * and feature, but getting those out of the build system here is too |
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index d439856f8176..91ee1b2e0f9a 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -776,6 +776,7 @@ static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr) | |||
776 | * "foo" will match an exact string equal to "foo" | 776 | * "foo" will match an exact string equal to "foo" |
777 | * "*foo" will match a string that ends with "foo" | 777 | * "*foo" will match a string that ends with "foo" |
778 | * "foo*" will match a string that begins with "foo" | 778 | * "foo*" will match a string that begins with "foo" |
779 | * "*foo*" will match a string that contains "foo" | ||
779 | */ | 780 | */ |
780 | static int match(const char *sym, const char * const pat[]) | 781 | static int match(const char *sym, const char * const pat[]) |
781 | { | 782 | { |
@@ -784,8 +785,17 @@ static int match(const char *sym, const char * const pat[]) | |||
784 | p = *pat++; | 785 | p = *pat++; |
785 | const char *endp = p + strlen(p) - 1; | 786 | const char *endp = p + strlen(p) - 1; |
786 | 787 | ||
788 | /* "*foo*" */ | ||
789 | if (*p == '*' && *endp == '*') { | ||
790 | char *here, *bare = strndup(p + 1, strlen(p) - 2); | ||
791 | |||
792 | here = strstr(sym, bare); | ||
793 | free(bare); | ||
794 | if (here != NULL) | ||
795 | return 1; | ||
796 | } | ||
787 | /* "*foo" */ | 797 | /* "*foo" */ |
788 | if (*p == '*') { | 798 | else if (*p == '*') { |
789 | if (strrcmp(sym, p + 1) == 0) | 799 | if (strrcmp(sym, p + 1) == 0) |
790 | return 1; | 800 | return 1; |
791 | } | 801 | } |
@@ -873,7 +883,10 @@ static void check_section(const char *modname, struct elf_info *elf, | |||
873 | #define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS | 883 | #define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS |
874 | 884 | ||
875 | #define DATA_SECTIONS ".data", ".data.rel" | 885 | #define DATA_SECTIONS ".data", ".data.rel" |
876 | #define TEXT_SECTIONS ".text", ".text.unlikely" | 886 | #define TEXT_SECTIONS ".text", ".text.unlikely", ".sched.text", \ |
887 | ".kprobes.text" | ||
888 | #define OTHER_TEXT_SECTIONS ".ref.text", ".head.text", ".spinlock.text", \ | ||
889 | ".fixup", ".entry.text", ".exception.text", ".text.*" | ||
877 | 890 | ||
878 | #define INIT_SECTIONS ".init.*" | 891 | #define INIT_SECTIONS ".init.*" |
879 | #define MEM_INIT_SECTIONS ".meminit.*" | 892 | #define MEM_INIT_SECTIONS ".meminit.*" |
@@ -881,6 +894,9 @@ static void check_section(const char *modname, struct elf_info *elf, | |||
881 | #define EXIT_SECTIONS ".exit.*" | 894 | #define EXIT_SECTIONS ".exit.*" |
882 | #define MEM_EXIT_SECTIONS ".memexit.*" | 895 | #define MEM_EXIT_SECTIONS ".memexit.*" |
883 | 896 | ||
897 | #define ALL_TEXT_SECTIONS ALL_INIT_TEXT_SECTIONS, ALL_EXIT_TEXT_SECTIONS, \ | ||
898 | TEXT_SECTIONS, OTHER_TEXT_SECTIONS | ||
899 | |||
884 | /* init data sections */ | 900 | /* init data sections */ |
885 | static const char *const init_data_sections[] = | 901 | static const char *const init_data_sections[] = |
886 | { ALL_INIT_DATA_SECTIONS, NULL }; | 902 | { ALL_INIT_DATA_SECTIONS, NULL }; |
@@ -892,6 +908,9 @@ static const char *const init_sections[] = { ALL_INIT_SECTIONS, NULL }; | |||
892 | static const char *const init_exit_sections[] = | 908 | static const char *const init_exit_sections[] = |
893 | {ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL }; | 909 | {ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL }; |
894 | 910 | ||
911 | /* all text sections */ | ||
912 | static const char *const text_sections[] = { ALL_TEXT_SECTIONS, NULL }; | ||
913 | |||
895 | /* data section */ | 914 | /* data section */ |
896 | static const char *const data_sections[] = { DATA_SECTIONS, NULL }; | 915 | static const char *const data_sections[] = { DATA_SECTIONS, NULL }; |
897 | 916 | ||
@@ -910,6 +929,7 @@ static const char *const data_sections[] = { DATA_SECTIONS, NULL }; | |||
910 | static const char *const head_sections[] = { ".head.text*", NULL }; | 929 | static const char *const head_sections[] = { ".head.text*", NULL }; |
911 | static const char *const linker_symbols[] = | 930 | static const char *const linker_symbols[] = |
912 | { "__init_begin", "_sinittext", "_einittext", NULL }; | 931 | { "__init_begin", "_sinittext", "_einittext", NULL }; |
932 | static const char *const optim_symbols[] = { "*.constprop.*", NULL }; | ||
913 | 933 | ||
914 | enum mismatch { | 934 | enum mismatch { |
915 | TEXT_TO_ANY_INIT, | 935 | TEXT_TO_ANY_INIT, |
@@ -921,34 +941,65 @@ enum mismatch { | |||
921 | ANY_INIT_TO_ANY_EXIT, | 941 | ANY_INIT_TO_ANY_EXIT, |
922 | ANY_EXIT_TO_ANY_INIT, | 942 | ANY_EXIT_TO_ANY_INIT, |
923 | EXPORT_TO_INIT_EXIT, | 943 | EXPORT_TO_INIT_EXIT, |
944 | EXTABLE_TO_NON_TEXT, | ||
924 | }; | 945 | }; |
925 | 946 | ||
947 | /** | ||
948 | * Describe how to match sections on different criterias: | ||
949 | * | ||
950 | * @fromsec: Array of sections to be matched. | ||
951 | * | ||
952 | * @bad_tosec: Relocations applied to a section in @fromsec to a section in | ||
953 | * this array is forbidden (black-list). Can be empty. | ||
954 | * | ||
955 | * @good_tosec: Relocations applied to a section in @fromsec must be | ||
956 | * targetting sections in this array (white-list). Can be empty. | ||
957 | * | ||
958 | * @mismatch: Type of mismatch. | ||
959 | * | ||
960 | * @symbol_white_list: Do not match a relocation to a symbol in this list | ||
961 | * even if it is targetting a section in @bad_to_sec. | ||
962 | * | ||
963 | * @handler: Specific handler to call when a match is found. If NULL, | ||
964 | * default_mismatch_handler() will be called. | ||
965 | * | ||
966 | */ | ||
926 | struct sectioncheck { | 967 | struct sectioncheck { |
927 | const char *fromsec[20]; | 968 | const char *fromsec[20]; |
928 | const char *tosec[20]; | 969 | const char *bad_tosec[20]; |
970 | const char *good_tosec[20]; | ||
929 | enum mismatch mismatch; | 971 | enum mismatch mismatch; |
930 | const char *symbol_white_list[20]; | 972 | const char *symbol_white_list[20]; |
973 | void (*handler)(const char *modname, struct elf_info *elf, | ||
974 | const struct sectioncheck* const mismatch, | ||
975 | Elf_Rela *r, Elf_Sym *sym, const char *fromsec); | ||
976 | |||
931 | }; | 977 | }; |
932 | 978 | ||
979 | static void extable_mismatch_handler(const char *modname, struct elf_info *elf, | ||
980 | const struct sectioncheck* const mismatch, | ||
981 | Elf_Rela *r, Elf_Sym *sym, | ||
982 | const char *fromsec); | ||
983 | |||
933 | static const struct sectioncheck sectioncheck[] = { | 984 | static const struct sectioncheck sectioncheck[] = { |
934 | /* Do not reference init/exit code/data from | 985 | /* Do not reference init/exit code/data from |
935 | * normal code and data | 986 | * normal code and data |
936 | */ | 987 | */ |
937 | { | 988 | { |
938 | .fromsec = { TEXT_SECTIONS, NULL }, | 989 | .fromsec = { TEXT_SECTIONS, NULL }, |
939 | .tosec = { ALL_INIT_SECTIONS, NULL }, | 990 | .bad_tosec = { ALL_INIT_SECTIONS, NULL }, |
940 | .mismatch = TEXT_TO_ANY_INIT, | 991 | .mismatch = TEXT_TO_ANY_INIT, |
941 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | 992 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, |
942 | }, | 993 | }, |
943 | { | 994 | { |
944 | .fromsec = { DATA_SECTIONS, NULL }, | 995 | .fromsec = { DATA_SECTIONS, NULL }, |
945 | .tosec = { ALL_XXXINIT_SECTIONS, NULL }, | 996 | .bad_tosec = { ALL_XXXINIT_SECTIONS, NULL }, |
946 | .mismatch = DATA_TO_ANY_INIT, | 997 | .mismatch = DATA_TO_ANY_INIT, |
947 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | 998 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, |
948 | }, | 999 | }, |
949 | { | 1000 | { |
950 | .fromsec = { DATA_SECTIONS, NULL }, | 1001 | .fromsec = { DATA_SECTIONS, NULL }, |
951 | .tosec = { INIT_SECTIONS, NULL }, | 1002 | .bad_tosec = { INIT_SECTIONS, NULL }, |
952 | .mismatch = DATA_TO_ANY_INIT, | 1003 | .mismatch = DATA_TO_ANY_INIT, |
953 | .symbol_white_list = { | 1004 | .symbol_white_list = { |
954 | "*_template", "*_timer", "*_sht", "*_ops", | 1005 | "*_template", "*_timer", "*_sht", "*_ops", |
@@ -957,56 +1008,66 @@ static const struct sectioncheck sectioncheck[] = { | |||
957 | }, | 1008 | }, |
958 | { | 1009 | { |
959 | .fromsec = { TEXT_SECTIONS, NULL }, | 1010 | .fromsec = { TEXT_SECTIONS, NULL }, |
960 | .tosec = { ALL_EXIT_SECTIONS, NULL }, | 1011 | .bad_tosec = { ALL_EXIT_SECTIONS, NULL }, |
961 | .mismatch = TEXT_TO_ANY_EXIT, | 1012 | .mismatch = TEXT_TO_ANY_EXIT, |
962 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | 1013 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, |
963 | }, | 1014 | }, |
964 | { | 1015 | { |
965 | .fromsec = { DATA_SECTIONS, NULL }, | 1016 | .fromsec = { DATA_SECTIONS, NULL }, |
966 | .tosec = { ALL_EXIT_SECTIONS, NULL }, | 1017 | .bad_tosec = { ALL_EXIT_SECTIONS, NULL }, |
967 | .mismatch = DATA_TO_ANY_EXIT, | 1018 | .mismatch = DATA_TO_ANY_EXIT, |
968 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | 1019 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, |
969 | }, | 1020 | }, |
970 | /* Do not reference init code/data from meminit code/data */ | 1021 | /* Do not reference init code/data from meminit code/data */ |
971 | { | 1022 | { |
972 | .fromsec = { ALL_XXXINIT_SECTIONS, NULL }, | 1023 | .fromsec = { ALL_XXXINIT_SECTIONS, NULL }, |
973 | .tosec = { INIT_SECTIONS, NULL }, | 1024 | .bad_tosec = { INIT_SECTIONS, NULL }, |
974 | .mismatch = XXXINIT_TO_SOME_INIT, | 1025 | .mismatch = XXXINIT_TO_SOME_INIT, |
975 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | 1026 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, |
976 | }, | 1027 | }, |
977 | /* Do not reference exit code/data from memexit code/data */ | 1028 | /* Do not reference exit code/data from memexit code/data */ |
978 | { | 1029 | { |
979 | .fromsec = { ALL_XXXEXIT_SECTIONS, NULL }, | 1030 | .fromsec = { ALL_XXXEXIT_SECTIONS, NULL }, |
980 | .tosec = { EXIT_SECTIONS, NULL }, | 1031 | .bad_tosec = { EXIT_SECTIONS, NULL }, |
981 | .mismatch = XXXEXIT_TO_SOME_EXIT, | 1032 | .mismatch = XXXEXIT_TO_SOME_EXIT, |
982 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | 1033 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, |
983 | }, | 1034 | }, |
984 | /* Do not use exit code/data from init code */ | 1035 | /* Do not use exit code/data from init code */ |
985 | { | 1036 | { |
986 | .fromsec = { ALL_INIT_SECTIONS, NULL }, | 1037 | .fromsec = { ALL_INIT_SECTIONS, NULL }, |
987 | .tosec = { ALL_EXIT_SECTIONS, NULL }, | 1038 | .bad_tosec = { ALL_EXIT_SECTIONS, NULL }, |
988 | .mismatch = ANY_INIT_TO_ANY_EXIT, | 1039 | .mismatch = ANY_INIT_TO_ANY_EXIT, |
989 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | 1040 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, |
990 | }, | 1041 | }, |
991 | /* Do not use init code/data from exit code */ | 1042 | /* Do not use init code/data from exit code */ |
992 | { | 1043 | { |
993 | .fromsec = { ALL_EXIT_SECTIONS, NULL }, | 1044 | .fromsec = { ALL_EXIT_SECTIONS, NULL }, |
994 | .tosec = { ALL_INIT_SECTIONS, NULL }, | 1045 | .bad_tosec = { ALL_INIT_SECTIONS, NULL }, |
995 | .mismatch = ANY_EXIT_TO_ANY_INIT, | 1046 | .mismatch = ANY_EXIT_TO_ANY_INIT, |
996 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | 1047 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, |
997 | }, | 1048 | }, |
998 | { | 1049 | { |
999 | .fromsec = { ALL_PCI_INIT_SECTIONS, NULL }, | 1050 | .fromsec = { ALL_PCI_INIT_SECTIONS, NULL }, |
1000 | .tosec = { INIT_SECTIONS, NULL }, | 1051 | .bad_tosec = { INIT_SECTIONS, NULL }, |
1001 | .mismatch = ANY_INIT_TO_ANY_EXIT, | 1052 | .mismatch = ANY_INIT_TO_ANY_EXIT, |
1002 | .symbol_white_list = { NULL }, | 1053 | .symbol_white_list = { NULL }, |
1003 | }, | 1054 | }, |
1004 | /* Do not export init/exit functions or data */ | 1055 | /* Do not export init/exit functions or data */ |
1005 | { | 1056 | { |
1006 | .fromsec = { "__ksymtab*", NULL }, | 1057 | .fromsec = { "__ksymtab*", NULL }, |
1007 | .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL }, | 1058 | .bad_tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL }, |
1008 | .mismatch = EXPORT_TO_INIT_EXIT, | 1059 | .mismatch = EXPORT_TO_INIT_EXIT, |
1009 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, | 1060 | .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, |
1061 | }, | ||
1062 | { | ||
1063 | .fromsec = { "__ex_table", NULL }, | ||
1064 | /* If you're adding any new black-listed sections in here, consider | ||
1065 | * adding a special 'printer' for them in scripts/check_extable. | ||
1066 | */ | ||
1067 | .bad_tosec = { ".altinstr_replacement", NULL }, | ||
1068 | .good_tosec = {ALL_TEXT_SECTIONS , NULL}, | ||
1069 | .mismatch = EXTABLE_TO_NON_TEXT, | ||
1070 | .handler = extable_mismatch_handler, | ||
1010 | } | 1071 | } |
1011 | }; | 1072 | }; |
1012 | 1073 | ||
@@ -1017,10 +1078,22 @@ static const struct sectioncheck *section_mismatch( | |||
1017 | int elems = sizeof(sectioncheck) / sizeof(struct sectioncheck); | 1078 | int elems = sizeof(sectioncheck) / sizeof(struct sectioncheck); |
1018 | const struct sectioncheck *check = §ioncheck[0]; | 1079 | const struct sectioncheck *check = §ioncheck[0]; |
1019 | 1080 | ||
1081 | /* | ||
1082 | * The target section could be the SHT_NUL section when we're | ||
1083 | * handling relocations to un-resolved symbols, trying to match it | ||
1084 | * doesn't make much sense and causes build failures on parisc and | ||
1085 | * mn10300 architectures. | ||
1086 | */ | ||
1087 | if (*tosec == '\0') | ||
1088 | return NULL; | ||
1089 | |||
1020 | for (i = 0; i < elems; i++) { | 1090 | for (i = 0; i < elems; i++) { |
1021 | if (match(fromsec, check->fromsec) && | 1091 | if (match(fromsec, check->fromsec)) { |
1022 | match(tosec, check->tosec)) | 1092 | if (check->bad_tosec[0] && match(tosec, check->bad_tosec)) |
1023 | return check; | 1093 | return check; |
1094 | if (check->good_tosec[0] && !match(tosec, check->good_tosec)) | ||
1095 | return check; | ||
1096 | } | ||
1024 | check++; | 1097 | check++; |
1025 | } | 1098 | } |
1026 | return NULL; | 1099 | return NULL; |
@@ -1067,6 +1140,17 @@ static const struct sectioncheck *section_mismatch( | |||
1067 | * This pattern is identified by | 1140 | * This pattern is identified by |
1068 | * refsymname = __init_begin, _sinittext, _einittext | 1141 | * refsymname = __init_begin, _sinittext, _einittext |
1069 | * | 1142 | * |
1143 | * Pattern 5: | ||
1144 | * GCC may optimize static inlines when fed constant arg(s) resulting | ||
1145 | * in functions like cpumask_empty() -- generating an associated symbol | ||
1146 | * cpumask_empty.constprop.3 that appears in the audit. If the const that | ||
1147 | * is passed in comes from __init, like say nmi_ipi_mask, we get a | ||
1148 | * meaningless section warning. May need to add isra symbols too... | ||
1149 | * This pattern is identified by | ||
1150 | * tosec = init section | ||
1151 | * fromsec = text section | ||
1152 | * refsymname = *.constprop.* | ||
1153 | * | ||
1070 | **/ | 1154 | **/ |
1071 | static int secref_whitelist(const struct sectioncheck *mismatch, | 1155 | static int secref_whitelist(const struct sectioncheck *mismatch, |
1072 | const char *fromsec, const char *fromsym, | 1156 | const char *fromsec, const char *fromsym, |
@@ -1099,6 +1183,12 @@ static int secref_whitelist(const struct sectioncheck *mismatch, | |||
1099 | if (match(tosym, linker_symbols)) | 1183 | if (match(tosym, linker_symbols)) |
1100 | return 0; | 1184 | return 0; |
1101 | 1185 | ||
1186 | /* Check for pattern 5 */ | ||
1187 | if (match(fromsec, text_sections) && | ||
1188 | match(tosec, init_sections) && | ||
1189 | match(fromsym, optim_symbols)) | ||
1190 | return 0; | ||
1191 | |||
1102 | return 1; | 1192 | return 1; |
1103 | } | 1193 | } |
1104 | 1194 | ||
@@ -1261,6 +1351,15 @@ static void print_section_list(const char * const list[20]) | |||
1261 | fprintf(stderr, "\n"); | 1351 | fprintf(stderr, "\n"); |
1262 | } | 1352 | } |
1263 | 1353 | ||
1354 | static inline void get_pretty_name(int is_func, const char** name, const char** name_p) | ||
1355 | { | ||
1356 | switch (is_func) { | ||
1357 | case 0: *name = "variable"; *name_p = ""; break; | ||
1358 | case 1: *name = "function"; *name_p = "()"; break; | ||
1359 | default: *name = "(unknown reference)"; *name_p = ""; break; | ||
1360 | } | ||
1361 | } | ||
1362 | |||
1264 | /* | 1363 | /* |
1265 | * Print a warning about a section mismatch. | 1364 | * Print a warning about a section mismatch. |
1266 | * Try to find symbols near it so user can find it. | 1365 | * Try to find symbols near it so user can find it. |
@@ -1280,21 +1379,13 @@ static void report_sec_mismatch(const char *modname, | |||
1280 | char *prl_from; | 1379 | char *prl_from; |
1281 | char *prl_to; | 1380 | char *prl_to; |
1282 | 1381 | ||
1283 | switch (from_is_func) { | ||
1284 | case 0: from = "variable"; from_p = ""; break; | ||
1285 | case 1: from = "function"; from_p = "()"; break; | ||
1286 | default: from = "(unknown reference)"; from_p = ""; break; | ||
1287 | } | ||
1288 | switch (to_is_func) { | ||
1289 | case 0: to = "variable"; to_p = ""; break; | ||
1290 | case 1: to = "function"; to_p = "()"; break; | ||
1291 | default: to = "(unknown reference)"; to_p = ""; break; | ||
1292 | } | ||
1293 | |||
1294 | sec_mismatch_count++; | 1382 | sec_mismatch_count++; |
1295 | if (!sec_mismatch_verbose) | 1383 | if (!sec_mismatch_verbose) |
1296 | return; | 1384 | return; |
1297 | 1385 | ||
1386 | get_pretty_name(from_is_func, &from, &from_p); | ||
1387 | get_pretty_name(to_is_func, &to, &to_p); | ||
1388 | |||
1298 | warn("%s(%s+0x%llx): Section mismatch in reference from the %s %s%s " | 1389 | warn("%s(%s+0x%llx): Section mismatch in reference from the %s %s%s " |
1299 | "to the %s %s:%s%s\n", | 1390 | "to the %s %s:%s%s\n", |
1300 | modname, fromsec, fromaddr, from, fromsym, from_p, to, tosec, | 1391 | modname, fromsec, fromaddr, from, fromsym, from_p, to, tosec, |
@@ -1408,41 +1499,179 @@ static void report_sec_mismatch(const char *modname, | |||
1408 | tosym, prl_to, prl_to, tosym); | 1499 | tosym, prl_to, prl_to, tosym); |
1409 | free(prl_to); | 1500 | free(prl_to); |
1410 | break; | 1501 | break; |
1502 | case EXTABLE_TO_NON_TEXT: | ||
1503 | fatal("There's a special handler for this mismatch type, " | ||
1504 | "we should never get here."); | ||
1505 | break; | ||
1411 | } | 1506 | } |
1412 | fprintf(stderr, "\n"); | 1507 | fprintf(stderr, "\n"); |
1413 | } | 1508 | } |
1414 | 1509 | ||
1415 | static void check_section_mismatch(const char *modname, struct elf_info *elf, | 1510 | static void default_mismatch_handler(const char *modname, struct elf_info *elf, |
1416 | Elf_Rela *r, Elf_Sym *sym, const char *fromsec) | 1511 | const struct sectioncheck* const mismatch, |
1512 | Elf_Rela *r, Elf_Sym *sym, const char *fromsec) | ||
1417 | { | 1513 | { |
1418 | const char *tosec; | 1514 | const char *tosec; |
1419 | const struct sectioncheck *mismatch; | 1515 | Elf_Sym *to; |
1516 | Elf_Sym *from; | ||
1517 | const char *tosym; | ||
1518 | const char *fromsym; | ||
1519 | |||
1520 | from = find_elf_symbol2(elf, r->r_offset, fromsec); | ||
1521 | fromsym = sym_name(elf, from); | ||
1522 | |||
1523 | if (!strncmp(fromsym, "reference___initcall", | ||
1524 | sizeof("reference___initcall")-1)) | ||
1525 | return; | ||
1420 | 1526 | ||
1421 | tosec = sec_name(elf, get_secindex(elf, sym)); | 1527 | tosec = sec_name(elf, get_secindex(elf, sym)); |
1422 | mismatch = section_mismatch(fromsec, tosec); | 1528 | to = find_elf_symbol(elf, r->r_addend, sym); |
1529 | tosym = sym_name(elf, to); | ||
1530 | |||
1531 | /* check whitelist - we may ignore it */ | ||
1532 | if (secref_whitelist(mismatch, | ||
1533 | fromsec, fromsym, tosec, tosym)) { | ||
1534 | report_sec_mismatch(modname, mismatch, | ||
1535 | fromsec, r->r_offset, fromsym, | ||
1536 | is_function(from), tosec, tosym, | ||
1537 | is_function(to)); | ||
1538 | } | ||
1539 | } | ||
1540 | |||
1541 | static int is_executable_section(struct elf_info* elf, unsigned int section_index) | ||
1542 | { | ||
1543 | if (section_index > elf->num_sections) | ||
1544 | fatal("section_index is outside elf->num_sections!\n"); | ||
1545 | |||
1546 | return ((elf->sechdrs[section_index].sh_flags & SHF_EXECINSTR) == SHF_EXECINSTR); | ||
1547 | } | ||
1548 | |||
1549 | /* | ||
1550 | * We rely on a gross hack in section_rel[a]() calling find_extable_entry_size() | ||
1551 | * to know the sizeof(struct exception_table_entry) for the target architecture. | ||
1552 | */ | ||
1553 | static unsigned int extable_entry_size = 0; | ||
1554 | static void find_extable_entry_size(const char* const sec, const Elf_Rela* r) | ||
1555 | { | ||
1556 | /* | ||
1557 | * If we're currently checking the second relocation within __ex_table, | ||
1558 | * that relocation offset tells us the offsetof(struct | ||
1559 | * exception_table_entry, fixup) which is equal to sizeof(struct | ||
1560 | * exception_table_entry) divided by two. We use that to our advantage | ||
1561 | * since there's no portable way to get that size as every architecture | ||
1562 | * seems to go with different sized types. Not pretty but better than | ||
1563 | * hard-coding the size for every architecture.. | ||
1564 | */ | ||
1565 | if (!extable_entry_size) | ||
1566 | extable_entry_size = r->r_offset * 2; | ||
1567 | } | ||
1568 | |||
1569 | static inline bool is_extable_fault_address(Elf_Rela *r) | ||
1570 | { | ||
1571 | /* | ||
1572 | * extable_entry_size is only discovered after we've handled the | ||
1573 | * _second_ relocation in __ex_table, so only abort when we're not | ||
1574 | * handling the first reloc and extable_entry_size is zero. | ||
1575 | */ | ||
1576 | if (r->r_offset && extable_entry_size == 0) | ||
1577 | fatal("extable_entry size hasn't been discovered!\n"); | ||
1578 | |||
1579 | return ((r->r_offset == 0) || | ||
1580 | (r->r_offset % extable_entry_size == 0)); | ||
1581 | } | ||
1582 | |||
1583 | #define is_second_extable_reloc(Start, Cur, Sec) \ | ||
1584 | (((Cur) == (Start) + 1) && (strcmp("__ex_table", (Sec)) == 0)) | ||
1585 | |||
1586 | static void report_extable_warnings(const char* modname, struct elf_info* elf, | ||
1587 | const struct sectioncheck* const mismatch, | ||
1588 | Elf_Rela* r, Elf_Sym* sym, | ||
1589 | const char* fromsec, const char* tosec) | ||
1590 | { | ||
1591 | Elf_Sym* fromsym = find_elf_symbol2(elf, r->r_offset, fromsec); | ||
1592 | const char* fromsym_name = sym_name(elf, fromsym); | ||
1593 | Elf_Sym* tosym = find_elf_symbol(elf, r->r_addend, sym); | ||
1594 | const char* tosym_name = sym_name(elf, tosym); | ||
1595 | const char* from_pretty_name; | ||
1596 | const char* from_pretty_name_p; | ||
1597 | const char* to_pretty_name; | ||
1598 | const char* to_pretty_name_p; | ||
1599 | |||
1600 | get_pretty_name(is_function(fromsym), | ||
1601 | &from_pretty_name, &from_pretty_name_p); | ||
1602 | get_pretty_name(is_function(tosym), | ||
1603 | &to_pretty_name, &to_pretty_name_p); | ||
1604 | |||
1605 | warn("%s(%s+0x%lx): Section mismatch in reference" | ||
1606 | " from the %s %s%s to the %s %s:%s%s\n", | ||
1607 | modname, fromsec, (long)r->r_offset, from_pretty_name, | ||
1608 | fromsym_name, from_pretty_name_p, | ||
1609 | to_pretty_name, tosec, tosym_name, to_pretty_name_p); | ||
1610 | |||
1611 | if (!match(tosec, mismatch->bad_tosec) && | ||
1612 | is_executable_section(elf, get_secindex(elf, sym))) | ||
1613 | fprintf(stderr, | ||
1614 | "The relocation at %s+0x%lx references\n" | ||
1615 | "section \"%s\" which is not in the list of\n" | ||
1616 | "authorized sections. If you're adding a new section\n" | ||
1617 | "and/or if this reference is valid, add \"%s\" to the\n" | ||
1618 | "list of authorized sections to jump to on fault.\n" | ||
1619 | "This can be achieved by adding \"%s\" to \n" | ||
1620 | "OTHER_TEXT_SECTIONS in scripts/mod/modpost.c.\n", | ||
1621 | fromsec, (long)r->r_offset, tosec, tosec, tosec); | ||
1622 | } | ||
1623 | |||
1624 | static void extable_mismatch_handler(const char* modname, struct elf_info *elf, | ||
1625 | const struct sectioncheck* const mismatch, | ||
1626 | Elf_Rela* r, Elf_Sym* sym, | ||
1627 | const char *fromsec) | ||
1628 | { | ||
1629 | const char* tosec = sec_name(elf, get_secindex(elf, sym)); | ||
1630 | |||
1631 | sec_mismatch_count++; | ||
1632 | |||
1633 | if (sec_mismatch_verbose) | ||
1634 | report_extable_warnings(modname, elf, mismatch, r, sym, | ||
1635 | fromsec, tosec); | ||
1636 | |||
1637 | if (match(tosec, mismatch->bad_tosec)) | ||
1638 | fatal("The relocation at %s+0x%lx references\n" | ||
1639 | "section \"%s\" which is black-listed.\n" | ||
1640 | "Something is seriously wrong and should be fixed.\n" | ||
1641 | "You might get more information about where this is\n" | ||
1642 | "coming from by using scripts/check_extable.sh %s\n", | ||
1643 | fromsec, (long)r->r_offset, tosec, modname); | ||
1644 | else if (!is_executable_section(elf, get_secindex(elf, sym))) { | ||
1645 | if (is_extable_fault_address(r)) | ||
1646 | fatal("The relocation at %s+0x%lx references\n" | ||
1647 | "section \"%s\" which is not executable, IOW\n" | ||
1648 | "it is not possible for the kernel to fault\n" | ||
1649 | "at that address. Something is seriously wrong\n" | ||
1650 | "and should be fixed.\n", | ||
1651 | fromsec, (long)r->r_offset, tosec); | ||
1652 | else | ||
1653 | fatal("The relocation at %s+0x%lx references\n" | ||
1654 | "section \"%s\" which is not executable, IOW\n" | ||
1655 | "the kernel will fault if it ever tries to\n" | ||
1656 | "jump to it. Something is seriously wrong\n" | ||
1657 | "and should be fixed.\n", | ||
1658 | fromsec, (long)r->r_offset, tosec); | ||
1659 | } | ||
1660 | } | ||
1661 | |||
1662 | static void check_section_mismatch(const char *modname, struct elf_info *elf, | ||
1663 | Elf_Rela *r, Elf_Sym *sym, const char *fromsec) | ||
1664 | { | ||
1665 | const char *tosec = sec_name(elf, get_secindex(elf, sym));; | ||
1666 | const struct sectioncheck *mismatch = section_mismatch(fromsec, tosec); | ||
1667 | |||
1423 | if (mismatch) { | 1668 | if (mismatch) { |
1424 | Elf_Sym *to; | 1669 | if (mismatch->handler) |
1425 | Elf_Sym *from; | 1670 | mismatch->handler(modname, elf, mismatch, |
1426 | const char *tosym; | 1671 | r, sym, fromsec); |
1427 | const char *fromsym; | 1672 | else |
1428 | 1673 | default_mismatch_handler(modname, elf, mismatch, | |
1429 | from = find_elf_symbol2(elf, r->r_offset, fromsec); | 1674 | r, sym, fromsec); |
1430 | fromsym = sym_name(elf, from); | ||
1431 | to = find_elf_symbol(elf, r->r_addend, sym); | ||
1432 | tosym = sym_name(elf, to); | ||
1433 | |||
1434 | if (!strncmp(fromsym, "reference___initcall", | ||
1435 | sizeof("reference___initcall")-1)) | ||
1436 | return; | ||
1437 | |||
1438 | /* check whitelist - we may ignore it */ | ||
1439 | if (secref_whitelist(mismatch, | ||
1440 | fromsec, fromsym, tosec, tosym)) { | ||
1441 | report_sec_mismatch(modname, mismatch, | ||
1442 | fromsec, r->r_offset, fromsym, | ||
1443 | is_function(from), tosec, tosym, | ||
1444 | is_function(to)); | ||
1445 | } | ||
1446 | } | 1675 | } |
1447 | } | 1676 | } |
1448 | 1677 | ||
@@ -1582,6 +1811,8 @@ static void section_rela(const char *modname, struct elf_info *elf, | |||
1582 | /* Skip special sections */ | 1811 | /* Skip special sections */ |
1583 | if (is_shndx_special(sym->st_shndx)) | 1812 | if (is_shndx_special(sym->st_shndx)) |
1584 | continue; | 1813 | continue; |
1814 | if (is_second_extable_reloc(start, rela, fromsec)) | ||
1815 | find_extable_entry_size(fromsec, &r); | ||
1585 | check_section_mismatch(modname, elf, &r, sym, fromsec); | 1816 | check_section_mismatch(modname, elf, &r, sym, fromsec); |
1586 | } | 1817 | } |
1587 | } | 1818 | } |
@@ -1640,6 +1871,8 @@ static void section_rel(const char *modname, struct elf_info *elf, | |||
1640 | /* Skip special sections */ | 1871 | /* Skip special sections */ |
1641 | if (is_shndx_special(sym->st_shndx)) | 1872 | if (is_shndx_special(sym->st_shndx)) |
1642 | continue; | 1873 | continue; |
1874 | if (is_second_extable_reloc(start, rel, fromsec)) | ||
1875 | find_extable_entry_size(fromsec, &r); | ||
1643 | check_section_mismatch(modname, elf, &r, sym, fromsec); | 1876 | check_section_mismatch(modname, elf, &r, sym, fromsec); |
1644 | } | 1877 | } |
1645 | } | 1878 | } |
diff --git a/scripts/spelling.txt b/scripts/spelling.txt index fc7fd52b5e03..bb8e4d0a1911 100644 --- a/scripts/spelling.txt +++ b/scripts/spelling.txt | |||
@@ -825,6 +825,7 @@ retreived||retrieved | |||
825 | retreive||retrieve | 825 | retreive||retrieve |
826 | retrive||retrieve | 826 | retrive||retrieve |
827 | retuned||returned | 827 | retuned||returned |
828 | reudce||reduce | ||
828 | reuest||request | 829 | reuest||request |
829 | reuqest||request | 830 | reuqest||request |
830 | reutnred||returned | 831 | reutnred||returned |
diff --git a/scripts/xen-hypercalls.sh b/scripts/xen-hypercalls.sh new file mode 100644 index 000000000000..676d9226814f --- /dev/null +++ b/scripts/xen-hypercalls.sh | |||
@@ -0,0 +1,12 @@ | |||
1 | #!/bin/sh | ||
2 | out="$1" | ||
3 | shift | ||
4 | in="$@" | ||
5 | |||
6 | for i in $in; do | ||
7 | eval $CPP $LINUXINCLUDE -dD -imacros "$i" -x c /dev/null | ||
8 | done | \ | ||
9 | awk '$1 == "#define" && $2 ~ /__HYPERVISOR_[a-z][a-z_0-9]*/ { v[$3] = $2 } | ||
10 | END { print "/* auto-generated by scripts/xen-hypercall.sh */" | ||
11 | for (i in v) if (!(v[i] in v)) | ||
12 | print "HYPERCALL("substr(v[i], 14)")"}' | sort -u >$out | ||