diff options
Diffstat (limited to 'scripts')
35 files changed, 576 insertions, 278 deletions
diff --git a/scripts/.gitignore b/scripts/.gitignore index e2741d23bab8..105b21f08185 100644 --- a/scripts/.gitignore +++ b/scripts/.gitignore | |||
@@ -8,3 +8,4 @@ bin2c | |||
8 | unifdef | 8 | unifdef |
9 | ihex2fw | 9 | ihex2fw |
10 | recordmcount | 10 | recordmcount |
11 | docproc | ||
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index ed2773edfe71..be39cd1c74cf 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include | |||
@@ -118,6 +118,11 @@ cc-option-yn = $(call try-run,\ | |||
118 | cc-option-align = $(subst -functions=0,,\ | 118 | cc-option-align = $(subst -functions=0,,\ |
119 | $(call cc-option,-falign-functions=0,-malign-functions=0)) | 119 | $(call cc-option,-falign-functions=0,-malign-functions=0)) |
120 | 120 | ||
121 | # cc-disable-warning | ||
122 | # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) | ||
123 | cc-disable-warning = $(call try-run,\ | ||
124 | $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -xc /dev/null -o "$$TMP",-Wno-$(strip $(1))) | ||
125 | |||
121 | # cc-version | 126 | # cc-version |
122 | # Usage gcc-ver := $(call cc-version) | 127 | # Usage gcc-ver := $(call cc-version) |
123 | cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) | 128 | cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) |
@@ -141,6 +146,11 @@ cc-ldoption = $(call try-run,\ | |||
141 | ld-option = $(call try-run,\ | 146 | ld-option = $(call try-run,\ |
142 | $(CC) /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) | 147 | $(CC) /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) |
143 | 148 | ||
149 | # ar-option | ||
150 | # Usage: KBUILD_ARFLAGS := $(call ar-option,D) | ||
151 | # Important: no spaces around options | ||
152 | ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) | ||
153 | |||
144 | ###### | 154 | ###### |
145 | 155 | ||
146 | ### | 156 | ### |
@@ -187,6 +197,8 @@ ifneq ($(KBUILD_NOCMDDEP),1) | |||
187 | # User may override this check using make KBUILD_NOCMDDEP=1 | 197 | # User may override this check using make KBUILD_NOCMDDEP=1 |
188 | arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ | 198 | arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ |
189 | $(filter-out $(cmd_$@), $(cmd_$(1))) ) | 199 | $(filter-out $(cmd_$@), $(cmd_$(1))) ) |
200 | else | ||
201 | arg-check = $(if $(strip $(cmd_$@)),,1) | ||
190 | endif | 202 | endif |
191 | 203 | ||
192 | # >'< substitution is for echo to work, | 204 | # >'< substitution is for echo to work, |
diff --git a/scripts/Makefile b/scripts/Makefile index fcea26168bca..df7678febf27 100644 --- a/scripts/Makefile +++ b/scripts/Makefile | |||
@@ -6,6 +6,7 @@ | |||
6 | # pnmttologo: Convert pnm files to logo files | 6 | # pnmttologo: Convert pnm files to logo files |
7 | # conmakehash: Create chartable | 7 | # conmakehash: Create chartable |
8 | # conmakehash: Create arrays for initializing the kernel console tables | 8 | # conmakehash: Create arrays for initializing the kernel console tables |
9 | # docproc: Used in Documentation/DocBook | ||
9 | 10 | ||
10 | hostprogs-$(CONFIG_KALLSYMS) += kallsyms | 11 | hostprogs-$(CONFIG_KALLSYMS) += kallsyms |
11 | hostprogs-$(CONFIG_LOGO) += pnmtologo | 12 | hostprogs-$(CONFIG_LOGO) += pnmtologo |
@@ -16,12 +17,14 @@ hostprogs-$(BUILD_C_RECORDMCOUNT) += recordmcount | |||
16 | always := $(hostprogs-y) $(hostprogs-m) | 17 | always := $(hostprogs-y) $(hostprogs-m) |
17 | 18 | ||
18 | # The following hostprogs-y programs are only build on demand | 19 | # The following hostprogs-y programs are only build on demand |
19 | hostprogs-y += unifdef | 20 | hostprogs-y += unifdef docproc |
20 | 21 | ||
21 | # This target is used internally to avoid "is up to date" messages | 22 | # These targets are used internally to avoid "is up to date" messages |
22 | PHONY += build_unifdef | 23 | PHONY += build_unifdef |
23 | build_unifdef: scripts/unifdef FORCE | 24 | build_unifdef: scripts/unifdef FORCE |
24 | @: | 25 | @: |
26 | build_docproc: scripts/docproc FORCE | ||
27 | @: | ||
25 | 28 | ||
26 | subdir-$(CONFIG_MODVERSIONS) += genksyms | 29 | subdir-$(CONFIG_MODVERSIONS) += genksyms |
27 | subdir-y += mod | 30 | subdir-y += mod |
diff --git a/scripts/Makefile.asm-generic b/scripts/Makefile.asm-generic new file mode 100644 index 000000000000..490122c3e2aa --- /dev/null +++ b/scripts/Makefile.asm-generic | |||
@@ -0,0 +1,23 @@ | |||
1 | # include/asm-generic contains a lot of files that are used | ||
2 | # verbatim by several architectures. | ||
3 | # | ||
4 | # This Makefile reads the file arch/$(SRCARCH)/include/asm/Kbuild | ||
5 | # and for each file listed in this file with generic-y creates | ||
6 | # a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm) | ||
7 | |||
8 | kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild | ||
9 | -include $(kbuild-file) | ||
10 | |||
11 | include scripts/Kbuild.include | ||
12 | |||
13 | # Create output directory if not already present | ||
14 | _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) | ||
15 | |||
16 | quiet_cmd_wrap = WRAP $@ | ||
17 | cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@ | ||
18 | |||
19 | all: $(patsubst %, $(obj)/%, $(generic-y)) | ||
20 | |||
21 | $(obj)/%.h: | ||
22 | $(call cmd,wrap) | ||
23 | |||
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index d5f925abe4d2..a0fd5029cfe7 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
@@ -51,36 +51,52 @@ ifeq ($(KBUILD_NOPEDANTIC),) | |||
51 | endif | 51 | endif |
52 | 52 | ||
53 | # | 53 | # |
54 | # make W=1 settings | 54 | # make W=... settings |
55 | # | 55 | # |
56 | # $(call cc-option... ) handles gcc -W.. options which | 56 | # W=1 - warnings that may be relevant and does not occur too often |
57 | # W=2 - warnings that occur quite often but may still be relevant | ||
58 | # W=3 - the more obscure warnings, can most likely be ignored | ||
59 | # | ||
60 | # $(call cc-option, -W...) handles gcc -W.. options which | ||
57 | # are not supported by all versions of the compiler | 61 | # are not supported by all versions of the compiler |
58 | ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS | 62 | ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS |
59 | KBUILD_EXTRA_WARNINGS := -Wextra | 63 | warning- := $(empty) |
60 | KBUILD_EXTRA_WARNINGS += -Wunused -Wno-unused-parameter | 64 | |
61 | KBUILD_EXTRA_WARNINGS += -Waggregate-return | 65 | warning-1 := -Wextra -Wunused -Wno-unused-parameter |
62 | KBUILD_EXTRA_WARNINGS += -Wbad-function-cast | 66 | warning-1 += -Wmissing-declarations |
63 | KBUILD_EXTRA_WARNINGS += -Wcast-qual | 67 | warning-1 += -Wmissing-format-attribute |
64 | KBUILD_EXTRA_WARNINGS += -Wcast-align | 68 | warning-1 += -Wmissing-prototypes |
65 | KBUILD_EXTRA_WARNINGS += -Wconversion | 69 | warning-1 += -Wold-style-definition |
66 | KBUILD_EXTRA_WARNINGS += -Wdisabled-optimization | 70 | warning-1 += $(call cc-option, -Wmissing-include-dirs) |
67 | KBUILD_EXTRA_WARNINGS += -Wlogical-op | 71 | warning-1 += $(call cc-option, -Wunused-but-set-variable) |
68 | KBUILD_EXTRA_WARNINGS += -Wmissing-declarations | 72 | |
69 | KBUILD_EXTRA_WARNINGS += -Wmissing-format-attribute | 73 | warning-2 := -Waggregate-return |
70 | KBUILD_EXTRA_WARNINGS += $(call cc-option, -Wmissing-include-dirs,) | 74 | warning-2 += -Wcast-align |
71 | KBUILD_EXTRA_WARNINGS += -Wmissing-prototypes | 75 | warning-2 += -Wdisabled-optimization |
72 | KBUILD_EXTRA_WARNINGS += -Wnested-externs | 76 | warning-2 += -Wnested-externs |
73 | KBUILD_EXTRA_WARNINGS += -Wold-style-definition | 77 | warning-2 += -Wshadow |
74 | KBUILD_EXTRA_WARNINGS += $(call cc-option, -Woverlength-strings,) | 78 | warning-2 += $(call cc-option, -Wlogical-op) |
75 | KBUILD_EXTRA_WARNINGS += -Wpacked | 79 | |
76 | KBUILD_EXTRA_WARNINGS += -Wpacked-bitfield-compat | 80 | warning-3 := -Wbad-function-cast |
77 | KBUILD_EXTRA_WARNINGS += -Wpadded | 81 | warning-3 += -Wcast-qual |
78 | KBUILD_EXTRA_WARNINGS += -Wpointer-arith | 82 | warning-3 += -Wconversion |
79 | KBUILD_EXTRA_WARNINGS += -Wredundant-decls | 83 | warning-3 += -Wpacked |
80 | KBUILD_EXTRA_WARNINGS += -Wshadow | 84 | warning-3 += -Wpadded |
81 | KBUILD_EXTRA_WARNINGS += -Wswitch-default | 85 | warning-3 += -Wpointer-arith |
82 | KBUILD_EXTRA_WARNINGS += $(call cc-option, -Wvla,) | 86 | warning-3 += -Wredundant-decls |
83 | KBUILD_CFLAGS += $(KBUILD_EXTRA_WARNINGS) | 87 | warning-3 += -Wswitch-default |
88 | warning-3 += $(call cc-option, -Wpacked-bitfield-compat) | ||
89 | warning-3 += $(call cc-option, -Wvla) | ||
90 | |||
91 | warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) | ||
92 | warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) | ||
93 | warning += $(warning-$(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) | ||
94 | |||
95 | ifeq ("$(strip $(warning))","") | ||
96 | $(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown) | ||
97 | endif | ||
98 | |||
99 | KBUILD_CFLAGS += $(warning) | ||
84 | endif | 100 | endif |
85 | 101 | ||
86 | include scripts/Makefile.lib | 102 | include scripts/Makefile.lib |
@@ -244,14 +260,19 @@ endif | |||
244 | 260 | ||
245 | ifdef CONFIG_FTRACE_MCOUNT_RECORD | 261 | ifdef CONFIG_FTRACE_MCOUNT_RECORD |
246 | ifdef BUILD_C_RECORDMCOUNT | 262 | ifdef BUILD_C_RECORDMCOUNT |
263 | ifeq ("$(origin RECORDMCOUNT_WARN)", "command line") | ||
264 | RECORDMCOUNT_FLAGS = -w | ||
265 | endif | ||
247 | # Due to recursion, we must skip empty.o. | 266 | # Due to recursion, we must skip empty.o. |
248 | # The empty.o file is created in the make process in order to determine | 267 | # The empty.o file is created in the make process in order to determine |
249 | # the target endianness and word size. It is made before all other C | 268 | # the target endianness and word size. It is made before all other C |
250 | # files, including recordmcount. | 269 | # files, including recordmcount. |
251 | sub_cmd_record_mcount = \ | 270 | sub_cmd_record_mcount = \ |
252 | if [ $(@) != "scripts/mod/empty.o" ]; then \ | 271 | if [ $(@) != "scripts/mod/empty.o" ]; then \ |
253 | $(objtree)/scripts/recordmcount "$(@)"; \ | 272 | $(objtree)/scripts/recordmcount $(RECORDMCOUNT_FLAGS) "$(@)"; \ |
254 | fi; | 273 | fi; |
274 | recordmcount_source := $(srctree)/scripts/recordmcount.c \ | ||
275 | $(srctree)/scripts/recordmcount.h | ||
255 | else | 276 | else |
256 | sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ | 277 | sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ |
257 | "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \ | 278 | "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \ |
@@ -259,6 +280,7 @@ sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH | |||
259 | "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \ | 280 | "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CFLAGS)" \ |
260 | "$(LD)" "$(NM)" "$(RM)" "$(MV)" \ | 281 | "$(LD)" "$(NM)" "$(RM)" "$(MV)" \ |
261 | "$(if $(part-of-module),1,0)" "$(@)"; | 282 | "$(if $(part-of-module),1,0)" "$(@)"; |
283 | recordmcount_source := $(srctree)/scripts/recordmcount.pl | ||
262 | endif | 284 | endif |
263 | cmd_record_mcount = \ | 285 | cmd_record_mcount = \ |
264 | if [ "$(findstring -pg,$(_c_flags))" = "-pg" ]; then \ | 286 | if [ "$(findstring -pg,$(_c_flags))" = "-pg" ]; then \ |
@@ -279,13 +301,13 @@ define rule_cc_o_c | |||
279 | endef | 301 | endef |
280 | 302 | ||
281 | # Built-in and composite module parts | 303 | # Built-in and composite module parts |
282 | $(obj)/%.o: $(src)/%.c FORCE | 304 | $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE |
283 | $(call cmd,force_checksrc) | 305 | $(call cmd,force_checksrc) |
284 | $(call if_changed_rule,cc_o_c) | 306 | $(call if_changed_rule,cc_o_c) |
285 | 307 | ||
286 | # Single-part modules are special since we need to mark them in $(MODVERDIR) | 308 | # Single-part modules are special since we need to mark them in $(MODVERDIR) |
287 | 309 | ||
288 | $(single-used-m): $(obj)/%.o: $(src)/%.c FORCE | 310 | $(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE |
289 | $(call cmd,force_checksrc) | 311 | $(call cmd,force_checksrc) |
290 | $(call if_changed_rule,cc_o_c) | 312 | $(call if_changed_rule,cc_o_c) |
291 | @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod) | 313 | @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod) |
@@ -345,7 +367,7 @@ quiet_cmd_link_o_target = LD $@ | |||
345 | cmd_link_o_target = $(if $(strip $(obj-y)),\ | 367 | cmd_link_o_target = $(if $(strip $(obj-y)),\ |
346 | $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \ | 368 | $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \ |
347 | $(cmd_secanalysis),\ | 369 | $(cmd_secanalysis),\ |
348 | rm -f $@; $(AR) rcs $@) | 370 | rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@) |
349 | 371 | ||
350 | $(builtin-target): $(obj-y) FORCE | 372 | $(builtin-target): $(obj-y) FORCE |
351 | $(call if_changed,link_o_target) | 373 | $(call if_changed,link_o_target) |
@@ -371,7 +393,7 @@ $(modorder-target): $(subdir-ym) FORCE | |||
371 | # | 393 | # |
372 | ifdef lib-target | 394 | ifdef lib-target |
373 | quiet_cmd_link_l_target = AR $@ | 395 | quiet_cmd_link_l_target = AR $@ |
374 | cmd_link_l_target = rm -f $@; $(AR) rcs $@ $(lib-y) | 396 | cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y) |
375 | 397 | ||
376 | $(lib-target): $(lib-y) FORCE | 398 | $(lib-target): $(lib-y) FORCE |
377 | $(call if_changed,link_l_target) | 399 | $(call if_changed,link_l_target) |
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index f89cb87f5c01..a57f5bd5a13d 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst | |||
@@ -27,8 +27,13 @@ header-y := $(filter-out %/, $(header-y)) | |||
27 | install-file := $(install)/.install | 27 | install-file := $(install)/.install |
28 | check-file := $(install)/.check | 28 | check-file := $(install)/.check |
29 | 29 | ||
30 | # generic-y list all files an architecture uses from asm-generic | ||
31 | # Use this to build a list of headers which require a wrapper | ||
32 | wrapper-files := $(filter $(header-y), $(generic-y)) | ||
33 | |||
30 | # all headers files for this dir | 34 | # all headers files for this dir |
31 | all-files := $(header-y) $(objhdr-y) | 35 | header-y := $(filter-out $(generic-y), $(header-y)) |
36 | all-files := $(header-y) $(objhdr-y) $(wrapper-files) | ||
32 | input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \ | 37 | input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \ |
33 | $(addprefix $(objtree)/$(obj)/,$(objhdr-y)) | 38 | $(addprefix $(objtree)/$(obj)/,$(objhdr-y)) |
34 | output-files := $(addprefix $(install)/, $(all-files)) | 39 | output-files := $(addprefix $(install)/, $(all-files)) |
@@ -47,6 +52,9 @@ quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ | |||
47 | cmd_install = \ | 52 | cmd_install = \ |
48 | $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \ | 53 | $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \ |
49 | $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \ | 54 | $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \ |
55 | for F in $(wrapper-files); do \ | ||
56 | echo "\#include <asm-generic/$$F>" > $(install)/$$F; \ | ||
57 | done; \ | ||
50 | touch $@ | 58 | touch $@ |
51 | 59 | ||
52 | quiet_cmd_remove = REMOVE $(unwanted) | 60 | quiet_cmd_remove = REMOVE $(unwanted) |
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 1c702ca8aac8..93b2b5938a2e 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
@@ -197,7 +197,7 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ | |||
197 | # --------------------------------------------------------------------------- | 197 | # --------------------------------------------------------------------------- |
198 | 198 | ||
199 | quiet_cmd_gzip = GZIP $@ | 199 | quiet_cmd_gzip = GZIP $@ |
200 | cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -f -9 > $@) || \ | 200 | cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \ |
201 | (rm -f $@ ; false) | 201 | (rm -f $@ ; false) |
202 | 202 | ||
203 | # DTC | 203 | # DTC |
diff --git a/scripts/basic/.gitignore b/scripts/basic/.gitignore index bf8b199ec598..a776371a3502 100644 --- a/scripts/basic/.gitignore +++ b/scripts/basic/.gitignore | |||
@@ -1,3 +1 @@ | |||
1 | hash | ||
2 | fixdep | fixdep | |
3 | docproc | ||
diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile index 4c324a1f1e0e..4fcef87bb875 100644 --- a/scripts/basic/Makefile +++ b/scripts/basic/Makefile | |||
@@ -7,9 +7,8 @@ | |||
7 | # .config is included by main Makefile. | 7 | # .config is included by main Makefile. |
8 | # --------------------------------------------------------------------------- | 8 | # --------------------------------------------------------------------------- |
9 | # fixdep: Used to generate dependency information during build process | 9 | # fixdep: Used to generate dependency information during build process |
10 | # docproc: Used in Documentation/DocBook | ||
11 | 10 | ||
12 | hostprogs-y := fixdep docproc | 11 | hostprogs-y := fixdep |
13 | always := $(hostprogs-y) | 12 | always := $(hostprogs-y) |
14 | 13 | ||
15 | # fixdep is needed to compile other host programs | 14 | # fixdep is needed to compile other host programs |
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d8670810db65..8657f99bfb2b 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -210,10 +210,10 @@ our $typeTypedefs = qr{(?x: | |||
210 | 210 | ||
211 | our $logFunctions = qr{(?x: | 211 | our $logFunctions = qr{(?x: |
212 | printk| | 212 | printk| |
213 | pr_(debug|dbg|vdbg|devel|info|warning|err|notice|alert|crit|emerg|cont)| | 213 | [a-z]+_(emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)| |
214 | (dev|netdev|netif)_(printk|dbg|vdbg|info|warn|err|notice|alert|crit|emerg|WARN)| | ||
215 | WARN| | 214 | WARN| |
216 | panic | 215 | panic| |
216 | MODULE_[A-Z_]+ | ||
217 | )}; | 217 | )}; |
218 | 218 | ||
219 | our @typeList = ( | 219 | our @typeList = ( |
@@ -1462,7 +1462,7 @@ sub process { | |||
1462 | #80 column limit | 1462 | #80 column limit |
1463 | if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && | 1463 | if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && |
1464 | $rawline !~ /^.\s*\*\s*\@$Ident\s/ && | 1464 | $rawline !~ /^.\s*\*\s*\@$Ident\s/ && |
1465 | !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:,|\)\s*;)\s*$/ || | 1465 | !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ || |
1466 | $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) && | 1466 | $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) && |
1467 | $length > 80) | 1467 | $length > 80) |
1468 | { | 1468 | { |
@@ -2748,6 +2748,11 @@ sub process { | |||
2748 | WARN("sizeof(& should be avoided\n" . $herecurr); | 2748 | WARN("sizeof(& should be avoided\n" . $herecurr); |
2749 | } | 2749 | } |
2750 | 2750 | ||
2751 | # check for line continuations in quoted strings with odd counts of " | ||
2752 | if ($rawline =~ /\\$/ && $rawline =~ tr/"/"/ % 2) { | ||
2753 | WARN("Avoid line continuations in quoted strings\n" . $herecurr); | ||
2754 | } | ||
2755 | |||
2751 | # check for new externs in .c files. | 2756 | # check for new externs in .c files. |
2752 | if ($realfile =~ /\.c$/ && defined $stat && | 2757 | if ($realfile =~ /\.c$/ && defined $stat && |
2753 | $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) | 2758 | $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) |
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl index 1afff6658a7d..17e384396705 100755 --- a/scripts/checkstack.pl +++ b/scripts/checkstack.pl | |||
@@ -12,7 +12,7 @@ | |||
12 | # sh64 port by Paul Mundt | 12 | # sh64 port by Paul Mundt |
13 | # Random bits by Matt Mackall <mpm@selenic.com> | 13 | # Random bits by Matt Mackall <mpm@selenic.com> |
14 | # M68k port by Geert Uytterhoeven and Andreas Schwab | 14 | # M68k port by Geert Uytterhoeven and Andreas Schwab |
15 | # AVR32 port by Haavard Skinnemoen <hskinnemoen@atmel.com> | 15 | # AVR32 port by Haavard Skinnemoen (Atmel) |
16 | # PARISC port by Kyle McMartin <kyle@parisc-linux.org> | 16 | # PARISC port by Kyle McMartin <kyle@parisc-linux.org> |
17 | # sparc port by Martin Habets <errandir_news@mph.eclipse.co.uk> | 17 | # sparc port by Martin Habets <errandir_news@mph.eclipse.co.uk> |
18 | # | 18 | # |
diff --git a/scripts/checkversion.pl b/scripts/checkversion.pl index b444e89a0095..5e490a8ceca5 100755 --- a/scripts/checkversion.pl +++ b/scripts/checkversion.pl | |||
@@ -12,6 +12,7 @@ $| = 1; | |||
12 | my $debugging; | 12 | my $debugging; |
13 | 13 | ||
14 | foreach my $file (@ARGV) { | 14 | foreach my $file (@ARGV) { |
15 | next if $file =~ "include/linux/version\.h"; | ||
15 | # Open this file. | 16 | # Open this file. |
16 | open( my $f, '<', $file ) | 17 | open( my $f, '<', $file ) |
17 | or die "Can't open $file: $!\n"; | 18 | or die "Can't open $file: $!\n"; |
diff --git a/scripts/basic/docproc.c b/scripts/docproc.c index 98dec87974d0..98dec87974d0 100644 --- a/scripts/basic/docproc.c +++ b/scripts/docproc.c | |||
diff --git a/scripts/export_report.pl b/scripts/export_report.pl index 04dce7c15f83..8f79b701de87 100644 --- a/scripts/export_report.pl +++ b/scripts/export_report.pl | |||
@@ -25,11 +25,12 @@ sub alphabetically { | |||
25 | sub print_depends_on { | 25 | sub print_depends_on { |
26 | my ($href) = @_; | 26 | my ($href) = @_; |
27 | print "\n"; | 27 | print "\n"; |
28 | while (my ($mod, $list) = each %$href) { | 28 | for my $mod (sort keys %$href) { |
29 | my $list = $href->{$mod}; | ||
29 | print "\t$mod:\n"; | 30 | print "\t$mod:\n"; |
30 | foreach my $sym (sort numerically @{$list}) { | 31 | foreach my $sym (sort numerically @{$list}) { |
31 | my ($symbol, $no) = split /\s+/, $sym; | 32 | my ($symbol, $no) = split /\s+/, $sym; |
32 | printf("\t\t%-25s\t%-25d\n", $symbol, $no); | 33 | printf("\t\t%-25s\n", $symbol); |
33 | } | 34 | } |
34 | print "\n"; | 35 | print "\n"; |
35 | } | 36 | } |
@@ -49,8 +50,14 @@ sub usage { | |||
49 | } | 50 | } |
50 | 51 | ||
51 | sub collectcfiles { | 52 | sub collectcfiles { |
52 | my @file | 53 | my @file; |
53 | = `cat .tmp_versions/*.mod | grep '.*\.ko\$' | sed s/\.ko$/.mod.c/`; | 54 | while (<.tmp_versions/*.mod>) { |
55 | open my $fh, '<', $_ or die "cannot open $_: $!\n"; | ||
56 | push (@file, | ||
57 | grep s/\.ko/.mod.c/, # change the suffix | ||
58 | grep m/.+\.ko/, # find the .ko path | ||
59 | <$fh>); # lines in opened file | ||
60 | } | ||
54 | chomp @file; | 61 | chomp @file; |
55 | return @file; | 62 | return @file; |
56 | } | 63 | } |
@@ -95,6 +102,8 @@ close($module_symvers); | |||
95 | # | 102 | # |
96 | # collect the usage count of each symbol. | 103 | # collect the usage count of each symbol. |
97 | # | 104 | # |
105 | my $modversion_warnings = 0; | ||
106 | |||
98 | foreach my $thismod (@allcfiles) { | 107 | foreach my $thismod (@allcfiles) { |
99 | my $module; | 108 | my $module; |
100 | 109 | ||
@@ -125,7 +134,8 @@ foreach my $thismod (@allcfiles) { | |||
125 | } | 134 | } |
126 | } | 135 | } |
127 | if ($state != 2) { | 136 | if ($state != 2) { |
128 | print "WARNING:$thismod is not built with CONFIG_MODVERSION enabled\n"; | 137 | warn "WARNING:$thismod is not built with CONFIG_MODVERSIONS enabled\n"; |
138 | $modversion_warnings++; | ||
129 | } | 139 | } |
130 | close($module); | 140 | close($module); |
131 | } | 141 | } |
@@ -159,8 +169,12 @@ printf("SECTION 2:\n\tThis section reports export-symbol-usage of in-kernel | |||
159 | modules. Each module lists the modules, and the symbols from that module that | 169 | modules. Each module lists the modules, and the symbols from that module that |
160 | it uses. Each listed symbol reports the number of modules using it\n"); | 170 | it uses. Each listed symbol reports the number of modules using it\n"); |
161 | 171 | ||
172 | print "\nNOTE: Got $modversion_warnings CONFIG_MODVERSIONS warnings\n\n" | ||
173 | if $modversion_warnings; | ||
174 | |||
162 | print "~"x80 , "\n"; | 175 | print "~"x80 , "\n"; |
163 | while (my ($thismod, $list) = each %MODULE) { | 176 | for my $thismod (sort keys %MODULE) { |
177 | my $list = $MODULE{$thismod}; | ||
164 | my %depends; | 178 | my %depends; |
165 | $thismod =~ s/\.mod\.c/.ko/; | 179 | $thismod =~ s/\.mod\.c/.ko/; |
166 | print "\t\t\t$thismod\n"; | 180 | print "\t\t\t$thismod\n"; |
diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh index e12b1a7525cf..b482f162a18a 100644 --- a/scripts/gen_initramfs_list.sh +++ b/scripts/gen_initramfs_list.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/sh |
2 | # Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org> | 2 | # Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org> |
3 | # Copyright (C) 2006 Sam Ravnborg <sam@ravnborg.org> | 3 | # Copyright (C) 2006 Sam Ravnborg <sam@ravnborg.org> |
4 | # | 4 | # |
@@ -105,9 +105,9 @@ list_parse() { | |||
105 | # for links, devices etc the format differs. See gen_init_cpio for details | 105 | # for links, devices etc the format differs. See gen_init_cpio for details |
106 | parse() { | 106 | parse() { |
107 | local location="$1" | 107 | local location="$1" |
108 | local name="${location/${srcdir}//}" | 108 | local name="/${location#${srcdir}}" |
109 | # change '//' into '/' | 109 | # change '//' into '/' |
110 | name="${name//\/\///}" | 110 | name=$(echo "$name" | sed -e 's://*:/:g') |
111 | local mode="$2" | 111 | local mode="$2" |
112 | local uid="$3" | 112 | local uid="$3" |
113 | local gid="$4" | 113 | local gid="$4" |
@@ -117,8 +117,8 @@ parse() { | |||
117 | [ "$root_gid" = "squash" ] && gid=0 || [ "$gid" -eq "$root_gid" ] && gid=0 | 117 | [ "$root_gid" = "squash" ] && gid=0 || [ "$gid" -eq "$root_gid" ] && gid=0 |
118 | local str="${mode} ${uid} ${gid}" | 118 | local str="${mode} ${uid} ${gid}" |
119 | 119 | ||
120 | [ "${ftype}" == "invalid" ] && return 0 | 120 | [ "${ftype}" = "invalid" ] && return 0 |
121 | [ "${location}" == "${srcdir}" ] && return 0 | 121 | [ "${location}" = "${srcdir}" ] && return 0 |
122 | 122 | ||
123 | case "${ftype}" in | 123 | case "${ftype}" in |
124 | "file") | 124 | "file") |
@@ -192,7 +192,7 @@ input_file() { | |||
192 | if [ -f "$1" ]; then | 192 | if [ -f "$1" ]; then |
193 | ${dep_list}header "$1" | 193 | ${dep_list}header "$1" |
194 | is_cpio="$(echo "$1" | sed 's/^.*\.cpio\(\..*\)\?/cpio/')" | 194 | is_cpio="$(echo "$1" | sed 's/^.*\.cpio\(\..*\)\?/cpio/')" |
195 | if [ $2 -eq 0 -a ${is_cpio} == "cpio" ]; then | 195 | if [ $2 -eq 0 -a ${is_cpio} = "cpio" ]; then |
196 | cpio_file=$1 | 196 | cpio_file=$1 |
197 | echo "$1" | grep -q '^.*\.cpio\..*' && is_cpio_compressed="compressed" | 197 | echo "$1" | grep -q '^.*\.cpio\..*' && is_cpio_compressed="compressed" |
198 | [ ! -z ${dep_list} ] && echo "$1" | 198 | [ ! -z ${dep_list} ] && echo "$1" |
@@ -204,7 +204,7 @@ input_file() { | |||
204 | else | 204 | else |
205 | echo "$1 \\" | 205 | echo "$1 \\" |
206 | cat "$1" | while read type dir file perm ; do | 206 | cat "$1" | while read type dir file perm ; do |
207 | if [ "$type" == "file" ]; then | 207 | if [ "$type" = "file" ]; then |
208 | echo "$file \\"; | 208 | echo "$file \\"; |
209 | fi | 209 | fi |
210 | done | 210 | done |
@@ -226,7 +226,7 @@ cpio_list= | |||
226 | output="/dev/stdout" | 226 | output="/dev/stdout" |
227 | output_file="" | 227 | output_file="" |
228 | is_cpio_compressed= | 228 | is_cpio_compressed= |
229 | compr="gzip -9 -f" | 229 | compr="gzip -n -9 -f" |
230 | 230 | ||
231 | arg="$1" | 231 | arg="$1" |
232 | case "$arg" in | 232 | case "$arg" in |
@@ -240,7 +240,7 @@ case "$arg" in | |||
240 | output_file="$1" | 240 | output_file="$1" |
241 | cpio_list="$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX)" | 241 | cpio_list="$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX)" |
242 | output=${cpio_list} | 242 | output=${cpio_list} |
243 | echo "$output_file" | grep -q "\.gz$" && compr="gzip -9 -f" | 243 | echo "$output_file" | grep -q "\.gz$" && compr="gzip -n -9 -f" |
244 | echo "$output_file" | grep -q "\.bz2$" && compr="bzip2 -9 -f" | 244 | echo "$output_file" | grep -q "\.bz2$" && compr="bzip2 -9 -f" |
245 | echo "$output_file" | grep -q "\.lzma$" && compr="lzma -9 -f" | 245 | echo "$output_file" | grep -q "\.lzma$" && compr="lzma -9 -f" |
246 | echo "$output_file" | grep -q "\.xz$" && \ | 246 | echo "$output_file" | grep -q "\.xz$" && \ |
@@ -287,8 +287,15 @@ done | |||
287 | # we are careful to delete tmp files | 287 | # we are careful to delete tmp files |
288 | if [ ! -z ${output_file} ]; then | 288 | if [ ! -z ${output_file} ]; then |
289 | if [ -z ${cpio_file} ]; then | 289 | if [ -z ${cpio_file} ]; then |
290 | timestamp= | ||
291 | if test -n "$KBUILD_BUILD_TIMESTAMP"; then | ||
292 | timestamp="$(date -d"$KBUILD_BUILD_TIMESTAMP" +%s || :)" | ||
293 | if test -n "$timestamp"; then | ||
294 | timestamp="-t $timestamp" | ||
295 | fi | ||
296 | fi | ||
290 | cpio_tfile="$(mktemp ${TMPDIR:-/tmp}/cpiofile.XXXXXX)" | 297 | cpio_tfile="$(mktemp ${TMPDIR:-/tmp}/cpiofile.XXXXXX)" |
291 | usr/gen_init_cpio ${cpio_list} > ${cpio_tfile} | 298 | usr/gen_init_cpio $timestamp ${cpio_list} > ${cpio_tfile} |
292 | else | 299 | else |
293 | cpio_tfile=${cpio_file} | 300 | cpio_tfile=${cpio_file} |
294 | fi | 301 | fi |
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 60dd3eb9366e..487ac6f37ca2 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c | |||
@@ -500,6 +500,8 @@ static void optimize_result(void) | |||
500 | 500 | ||
501 | /* find the token with the breates profit value */ | 501 | /* find the token with the breates profit value */ |
502 | best = find_best_token(); | 502 | best = find_best_token(); |
503 | if (token_profit[best] == 0) | ||
504 | break; | ||
503 | 505 | ||
504 | /* place it in the "best" table */ | 506 | /* place it in the "best" table */ |
505 | best_table_len[i] = 2; | 507 | best_table_len[i] = 2; |
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 368ae306aee4..faa9a4701b6f 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile | |||
@@ -77,14 +77,15 @@ localyesconfig: $(obj)/streamline_config.pl $(obj)/conf | |||
77 | # The symlink is used to repair a deficiency in arch/um | 77 | # The symlink is used to repair a deficiency in arch/um |
78 | update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h | 78 | update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h |
79 | $(Q)echo " GEN config" | 79 | $(Q)echo " GEN config" |
80 | $(Q)xgettext --default-domain=linux \ | 80 | $(Q)xgettext --default-domain=linux \ |
81 | --add-comments --keyword=_ --keyword=N_ \ | 81 | --add-comments --keyword=_ --keyword=N_ \ |
82 | --from-code=UTF-8 \ | 82 | --from-code=UTF-8 \ |
83 | --files-from=scripts/kconfig/POTFILES.in \ | 83 | --files-from=$(srctree)/scripts/kconfig/POTFILES.in \ |
84 | --directory=$(srctree) --directory=$(objtree) \ | ||
84 | --output $(obj)/config.pot | 85 | --output $(obj)/config.pot |
85 | $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot | 86 | $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot |
86 | $(Q)ln -fs Kconfig.i386 arch/um/Kconfig.arch | 87 | $(Q)ln -fs Kconfig.x86 arch/um/Kconfig |
87 | $(Q)(for i in `ls arch/*/Kconfig`; \ | 88 | $(Q)(for i in `ls $(srctree)/arch/*/Kconfig`; \ |
88 | do \ | 89 | do \ |
89 | echo " GEN $$i"; \ | 90 | echo " GEN $$i"; \ |
90 | $(obj)/kxgettext $$i \ | 91 | $(obj)/kxgettext $$i \ |
@@ -92,7 +93,7 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h | |||
92 | done ) | 93 | done ) |
93 | $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ | 94 | $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ |
94 | --output $(obj)/linux.pot | 95 | --output $(obj)/linux.pot |
95 | $(Q)rm -f arch/um/Kconfig.arch | 96 | $(Q)rm -f $(srctree)/arch/um/Kconfig |
96 | $(Q)rm -f $(obj)/config.pot | 97 | $(Q)rm -f $(obj)/config.pot |
97 | 98 | ||
98 | PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig | 99 | PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig |
@@ -168,8 +169,11 @@ conf-objs := conf.o zconf.tab.o | |||
168 | mconf-objs := mconf.o zconf.tab.o $(lxdialog) | 169 | mconf-objs := mconf.o zconf.tab.o $(lxdialog) |
169 | nconf-objs := nconf.o zconf.tab.o nconf.gui.o | 170 | nconf-objs := nconf.o zconf.tab.o nconf.gui.o |
170 | kxgettext-objs := kxgettext.o zconf.tab.o | 171 | kxgettext-objs := kxgettext.o zconf.tab.o |
172 | qconf-cxxobjs := qconf.o | ||
173 | qconf-objs := kconfig_load.o zconf.tab.o | ||
174 | gconf-objs := gconf.o kconfig_load.o zconf.tab.o | ||
171 | 175 | ||
172 | hostprogs-y := conf qconf gconf kxgettext | 176 | hostprogs-y := conf |
173 | 177 | ||
174 | ifeq ($(MAKECMDGOALS),nconfig) | 178 | ifeq ($(MAKECMDGOALS),nconfig) |
175 | hostprogs-y += nconf | 179 | hostprogs-y += nconf |
@@ -179,6 +183,10 @@ ifeq ($(MAKECMDGOALS),menuconfig) | |||
179 | hostprogs-y += mconf | 183 | hostprogs-y += mconf |
180 | endif | 184 | endif |
181 | 185 | ||
186 | ifeq ($(MAKECMDGOALS),update-po-config) | ||
187 | hostprogs-y += kxgettext | ||
188 | endif | ||
189 | |||
182 | ifeq ($(MAKECMDGOALS),xconfig) | 190 | ifeq ($(MAKECMDGOALS),xconfig) |
183 | qconf-target := 1 | 191 | qconf-target := 1 |
184 | endif | 192 | endif |
@@ -188,16 +196,15 @@ endif | |||
188 | 196 | ||
189 | 197 | ||
190 | ifeq ($(qconf-target),1) | 198 | ifeq ($(qconf-target),1) |
191 | qconf-cxxobjs := qconf.o | 199 | hostprogs-y += qconf |
192 | qconf-objs := kconfig_load.o zconf.tab.o | ||
193 | endif | 200 | endif |
194 | 201 | ||
195 | ifeq ($(gconf-target),1) | 202 | ifeq ($(gconf-target),1) |
196 | gconf-objs := gconf.o kconfig_load.o zconf.tab.o | 203 | hostprogs-y += gconf |
197 | endif | 204 | endif |
198 | 205 | ||
199 | clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \ | 206 | clean-files := lkc_defs.h qconf.moc .tmp_qtcheck .tmp_gtkcheck |
200 | .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h | 207 | clean-files += zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h |
201 | clean-files += mconf qconf gconf nconf | 208 | clean-files += mconf qconf gconf nconf |
202 | clean-files += config.pot linux.pot | 209 | clean-files += config.pot linux.pot |
203 | 210 | ||
@@ -321,11 +328,12 @@ $(obj)/%.moc: $(src)/%.h | |||
321 | $(KC_QT_MOC) -i $< -o $@ | 328 | $(KC_QT_MOC) -i $< -o $@ |
322 | 329 | ||
323 | $(obj)/lkc_defs.h: $(src)/lkc_proto.h | 330 | $(obj)/lkc_defs.h: $(src)/lkc_proto.h |
324 | sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/' | 331 | $(Q)sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/' |
325 | 332 | ||
326 | # Extract gconf menu items for I18N support | 333 | # Extract gconf menu items for I18N support |
327 | $(obj)/gconf.glade.h: $(obj)/gconf.glade | 334 | $(obj)/gconf.glade.h: $(obj)/gconf.glade |
328 | intltool-extract --type=gettext/glade $(obj)/gconf.glade | 335 | $(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \ |
336 | $(obj)/gconf.glade | ||
329 | 337 | ||
330 | ### | 338 | ### |
331 | # The following requires flex/bison/gperf | 339 | # The following requires flex/bison/gperf |
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 61c35bf2d9cb..2bafd9a7c8da 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c | |||
@@ -560,8 +560,6 @@ int conf_write(const char *name) | |||
560 | const char *basename; | 560 | const char *basename; |
561 | const char *str; | 561 | const char *str; |
562 | char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1]; | 562 | char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1]; |
563 | time_t now; | ||
564 | int use_timestamp = 1; | ||
565 | char *env; | 563 | char *env; |
566 | 564 | ||
567 | dirname[0] = 0; | 565 | dirname[0] = 0; |
@@ -598,19 +596,11 @@ int conf_write(const char *name) | |||
598 | if (!out) | 596 | if (!out) |
599 | return 1; | 597 | return 1; |
600 | 598 | ||
601 | time(&now); | ||
602 | env = getenv("KCONFIG_NOTIMESTAMP"); | ||
603 | if (env && *env) | ||
604 | use_timestamp = 0; | ||
605 | |||
606 | fprintf(out, _("#\n" | 599 | fprintf(out, _("#\n" |
607 | "# Automatically generated make config: don't edit\n" | 600 | "# Automatically generated make config: don't edit\n" |
608 | "# %s\n" | 601 | "# %s\n" |
609 | "%s%s" | ||
610 | "#\n"), | 602 | "#\n"), |
611 | rootmenu.prompt->text, | 603 | rootmenu.prompt->text); |
612 | use_timestamp ? "# " : "", | ||
613 | use_timestamp ? ctime(&now) : ""); | ||
614 | 604 | ||
615 | if (!conf_get_changed()) | 605 | if (!conf_get_changed()) |
616 | sym_clear_all_valid(); | 606 | sym_clear_all_valid(); |
@@ -784,7 +774,6 @@ int conf_write_autoconf(void) | |||
784 | const char *str; | 774 | const char *str; |
785 | const char *name; | 775 | const char *name; |
786 | FILE *out, *tristate, *out_h; | 776 | FILE *out, *tristate, *out_h; |
787 | time_t now; | ||
788 | int i; | 777 | int i; |
789 | 778 | ||
790 | sym_clear_all_valid(); | 779 | sym_clear_all_valid(); |
@@ -811,22 +800,19 @@ int conf_write_autoconf(void) | |||
811 | return 1; | 800 | return 1; |
812 | } | 801 | } |
813 | 802 | ||
814 | time(&now); | ||
815 | fprintf(out, "#\n" | 803 | fprintf(out, "#\n" |
816 | "# Automatically generated make config: don't edit\n" | 804 | "# Automatically generated make config: don't edit\n" |
817 | "# %s\n" | 805 | "# %s\n" |
818 | "# %s" | ||
819 | "#\n", | 806 | "#\n", |
820 | rootmenu.prompt->text, ctime(&now)); | 807 | rootmenu.prompt->text); |
821 | fprintf(tristate, "#\n" | 808 | fprintf(tristate, "#\n" |
822 | "# Automatically generated - do not edit\n" | 809 | "# Automatically generated - do not edit\n" |
823 | "\n"); | 810 | "\n"); |
824 | fprintf(out_h, "/*\n" | 811 | fprintf(out_h, "/*\n" |
825 | " * Automatically generated C config: don't edit\n" | 812 | " * Automatically generated C config: don't edit\n" |
826 | " * %s\n" | 813 | " * %s\n" |
827 | " * %s" | ||
828 | " */\n", | 814 | " */\n", |
829 | rootmenu.prompt->text, ctime(&now)); | 815 | rootmenu.prompt->text); |
830 | 816 | ||
831 | for_all_symbols(i, sym) { | 817 | for_all_symbols(i, sym) { |
832 | sym_calc_value(sym); | 818 | sym_calc_value(sym); |
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 3d238db49764..16bfae2d3217 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h | |||
@@ -20,12 +20,8 @@ struct file { | |||
20 | struct file *parent; | 20 | struct file *parent; |
21 | const char *name; | 21 | const char *name; |
22 | int lineno; | 22 | int lineno; |
23 | int flags; | ||
24 | }; | 23 | }; |
25 | 24 | ||
26 | #define FILE_BUSY 0x0001 | ||
27 | #define FILE_SCANNED 0x0002 | ||
28 | |||
29 | typedef enum tristate { | 25 | typedef enum tristate { |
30 | no, mod, yes | 26 | no, mod, yes |
31 | } tristate; | 27 | } tristate; |
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index 455896164d72..a11d5f7b9eeb 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c | |||
@@ -253,7 +253,7 @@ void init_left_tree(void) | |||
253 | 253 | ||
254 | gtk_tree_view_set_model(view, model1); | 254 | gtk_tree_view_set_model(view, model1); |
255 | gtk_tree_view_set_headers_visible(view, TRUE); | 255 | gtk_tree_view_set_headers_visible(view, TRUE); |
256 | gtk_tree_view_set_rules_hint(view, FALSE); | 256 | gtk_tree_view_set_rules_hint(view, TRUE); |
257 | 257 | ||
258 | column = gtk_tree_view_column_new(); | 258 | column = gtk_tree_view_column_new(); |
259 | gtk_tree_view_append_column(view, column); | 259 | gtk_tree_view_append_column(view, column); |
@@ -298,7 +298,7 @@ void init_right_tree(void) | |||
298 | 298 | ||
299 | gtk_tree_view_set_model(view, model2); | 299 | gtk_tree_view_set_model(view, model2); |
300 | gtk_tree_view_set_headers_visible(view, TRUE); | 300 | gtk_tree_view_set_headers_visible(view, TRUE); |
301 | gtk_tree_view_set_rules_hint(view, FALSE); | 301 | gtk_tree_view_set_rules_hint(view, TRUE); |
302 | 302 | ||
303 | column = gtk_tree_view_column_new(); | 303 | column = gtk_tree_view_column_new(); |
304 | gtk_tree_view_append_column(view, column); | 304 | gtk_tree_view_append_column(view, column); |
@@ -756,7 +756,6 @@ void on_load_clicked(GtkButton * button, gpointer user_data) | |||
756 | void on_single_clicked(GtkButton * button, gpointer user_data) | 756 | void on_single_clicked(GtkButton * button, gpointer user_data) |
757 | { | 757 | { |
758 | view_mode = SINGLE_VIEW; | 758 | view_mode = SINGLE_VIEW; |
759 | gtk_paned_set_position(GTK_PANED(hpaned), 0); | ||
760 | gtk_widget_hide(tree1_w); | 759 | gtk_widget_hide(tree1_w); |
761 | current = &rootmenu; | 760 | current = &rootmenu; |
762 | display_tree_part(); | 761 | display_tree_part(); |
@@ -782,7 +781,6 @@ void on_split_clicked(GtkButton * button, gpointer user_data) | |||
782 | void on_full_clicked(GtkButton * button, gpointer user_data) | 781 | void on_full_clicked(GtkButton * button, gpointer user_data) |
783 | { | 782 | { |
784 | view_mode = FULL_VIEW; | 783 | view_mode = FULL_VIEW; |
785 | gtk_paned_set_position(GTK_PANED(hpaned), 0); | ||
786 | gtk_widget_hide(tree1_w); | 784 | gtk_widget_hide(tree1_w); |
787 | if (tree2) | 785 | if (tree2) |
788 | gtk_tree_store_clear(tree2); | 786 | gtk_tree_store_clear(tree2); |
@@ -1444,6 +1442,12 @@ static void display_tree(struct menu *menu) | |||
1444 | if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT)) | 1442 | if (((menu != &rootmenu) && !(menu->flags & MENU_ROOT)) |
1445 | || (view_mode == FULL_VIEW) | 1443 | || (view_mode == FULL_VIEW) |
1446 | || (view_mode == SPLIT_VIEW))*/ | 1444 | || (view_mode == SPLIT_VIEW))*/ |
1445 | |||
1446 | /* Change paned position if the view is not in 'split mode' */ | ||
1447 | if (view_mode == SINGLE_VIEW || view_mode == FULL_VIEW) { | ||
1448 | gtk_paned_set_position(GTK_PANED(hpaned), 0); | ||
1449 | } | ||
1450 | |||
1447 | if (((view_mode == SINGLE_VIEW) && (menu->flags & MENU_ROOT)) | 1451 | if (((view_mode == SINGLE_VIEW) && (menu->flags & MENU_ROOT)) |
1448 | || (view_mode == FULL_VIEW) | 1452 | || (view_mode == FULL_VIEW) |
1449 | || (view_mode == SPLIT_VIEW)) { | 1453 | || (view_mode == SPLIT_VIEW)) { |
diff --git a/scripts/kconfig/lex.zconf.c_shipped b/scripts/kconfig/lex.zconf.c_shipped index 6eb039718259..d9182916f724 100644 --- a/scripts/kconfig/lex.zconf.c_shipped +++ b/scripts/kconfig/lex.zconf.c_shipped | |||
@@ -2363,11 +2363,11 @@ void zconf_initscan(const char *name) | |||
2363 | 2363 | ||
2364 | current_file = file_lookup(name); | 2364 | current_file = file_lookup(name); |
2365 | current_file->lineno = 1; | 2365 | current_file->lineno = 1; |
2366 | current_file->flags = FILE_BUSY; | ||
2367 | } | 2366 | } |
2368 | 2367 | ||
2369 | void zconf_nextfile(const char *name) | 2368 | void zconf_nextfile(const char *name) |
2370 | { | 2369 | { |
2370 | struct file *iter; | ||
2371 | struct file *file = file_lookup(name); | 2371 | struct file *file = file_lookup(name); |
2372 | struct buffer *buf = malloc(sizeof(*buf)); | 2372 | struct buffer *buf = malloc(sizeof(*buf)); |
2373 | memset(buf, 0, sizeof(*buf)); | 2373 | memset(buf, 0, sizeof(*buf)); |
@@ -2383,18 +2383,25 @@ void zconf_nextfile(const char *name) | |||
2383 | buf->parent = current_buf; | 2383 | buf->parent = current_buf; |
2384 | current_buf = buf; | 2384 | current_buf = buf; |
2385 | 2385 | ||
2386 | if (file->flags & FILE_BUSY) { | 2386 | for (iter = current_file->parent; iter; iter = iter->parent ) { |
2387 | printf("%s:%d: do not source '%s' from itself\n", | 2387 | if (!strcmp(current_file->name,iter->name) ) { |
2388 | zconf_curname(), zconf_lineno(), name); | 2388 | printf("%s:%d: recursive inclusion detected. " |
2389 | exit(1); | 2389 | "Inclusion path:\n current file : '%s'\n", |
2390 | } | 2390 | zconf_curname(), zconf_lineno(), |
2391 | if (file->flags & FILE_SCANNED) { | 2391 | zconf_curname()); |
2392 | printf("%s:%d: file '%s' is already sourced from '%s'\n", | 2392 | iter = current_file->parent; |
2393 | zconf_curname(), zconf_lineno(), name, | 2393 | while (iter && \ |
2394 | file->parent->name); | 2394 | strcmp(iter->name,current_file->name)) { |
2395 | exit(1); | 2395 | printf(" included from: '%s:%d'\n", |
2396 | iter->name, iter->lineno-1); | ||
2397 | iter = iter->parent; | ||
2398 | } | ||
2399 | if (iter) | ||
2400 | printf(" included from: '%s:%d'\n", | ||
2401 | iter->name, iter->lineno+1); | ||
2402 | exit(1); | ||
2403 | } | ||
2396 | } | 2404 | } |
2397 | file->flags |= FILE_BUSY; | ||
2398 | file->lineno = 1; | 2405 | file->lineno = 1; |
2399 | file->parent = current_file; | 2406 | file->parent = current_file; |
2400 | current_file = file; | 2407 | current_file = file; |
@@ -2404,8 +2411,6 @@ static void zconf_endfile(void) | |||
2404 | { | 2411 | { |
2405 | struct buffer *parent; | 2412 | struct buffer *parent; |
2406 | 2413 | ||
2407 | current_file->flags |= FILE_SCANNED; | ||
2408 | current_file->flags &= ~FILE_BUSY; | ||
2409 | current_file = current_file->parent; | 2414 | current_file = current_file->parent; |
2410 | 2415 | ||
2411 | parent = current_buf->parent; | 2416 | parent = current_buf->parent; |
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index db56377393d7..488dd7410787 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c | |||
@@ -373,18 +373,18 @@ static void print_function_line(void) | |||
373 | const int skip = 1; | 373 | const int skip = 1; |
374 | 374 | ||
375 | for (i = 0; i < function_keys_num; i++) { | 375 | for (i = 0; i < function_keys_num; i++) { |
376 | wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]); | 376 | (void) wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]); |
377 | mvwprintw(main_window, LINES-3, offset, | 377 | mvwprintw(main_window, LINES-3, offset, |
378 | "%s", | 378 | "%s", |
379 | function_keys[i].key_str); | 379 | function_keys[i].key_str); |
380 | wattrset(main_window, attributes[FUNCTION_TEXT]); | 380 | (void) wattrset(main_window, attributes[FUNCTION_TEXT]); |
381 | offset += strlen(function_keys[i].key_str); | 381 | offset += strlen(function_keys[i].key_str); |
382 | mvwprintw(main_window, LINES-3, | 382 | mvwprintw(main_window, LINES-3, |
383 | offset, "%s", | 383 | offset, "%s", |
384 | function_keys[i].func); | 384 | function_keys[i].func); |
385 | offset += strlen(function_keys[i].func) + skip; | 385 | offset += strlen(function_keys[i].func) + skip; |
386 | } | 386 | } |
387 | wattrset(main_window, attributes[NORMAL]); | 387 | (void) wattrset(main_window, attributes[NORMAL]); |
388 | } | 388 | } |
389 | 389 | ||
390 | /* help */ | 390 | /* help */ |
@@ -953,16 +953,16 @@ static void show_menu(const char *prompt, const char *instructions, | |||
953 | current_instructions = instructions; | 953 | current_instructions = instructions; |
954 | 954 | ||
955 | clear(); | 955 | clear(); |
956 | wattrset(main_window, attributes[NORMAL]); | 956 | (void) wattrset(main_window, attributes[NORMAL]); |
957 | print_in_middle(stdscr, 1, 0, COLS, | 957 | print_in_middle(stdscr, 1, 0, COLS, |
958 | menu_backtitle, | 958 | menu_backtitle, |
959 | attributes[MAIN_HEADING]); | 959 | attributes[MAIN_HEADING]); |
960 | 960 | ||
961 | wattrset(main_window, attributes[MAIN_MENU_BOX]); | 961 | (void) wattrset(main_window, attributes[MAIN_MENU_BOX]); |
962 | box(main_window, 0, 0); | 962 | box(main_window, 0, 0); |
963 | wattrset(main_window, attributes[MAIN_MENU_HEADING]); | 963 | (void) wattrset(main_window, attributes[MAIN_MENU_HEADING]); |
964 | mvwprintw(main_window, 0, 3, " %s ", prompt); | 964 | mvwprintw(main_window, 0, 3, " %s ", prompt); |
965 | wattrset(main_window, attributes[NORMAL]); | 965 | (void) wattrset(main_window, attributes[NORMAL]); |
966 | 966 | ||
967 | set_menu_items(curses_menu, curses_menu_items); | 967 | set_menu_items(curses_menu, curses_menu_items); |
968 | 968 | ||
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 06dd2e33581d..c2796b866f8f 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc | |||
@@ -1489,8 +1489,7 @@ void ConfigMainWindow::saveConfigAs(void) | |||
1489 | QString s = Q3FileDialog::getSaveFileName(conf_get_configname(), NULL, this); | 1489 | QString s = Q3FileDialog::getSaveFileName(conf_get_configname(), NULL, this); |
1490 | if (s.isNull()) | 1490 | if (s.isNull()) |
1491 | return; | 1491 | return; |
1492 | if (conf_write(QFile::encodeName(s))) | 1492 | saveConfig(); |
1493 | QMessageBox::information(this, "qconf", _("Unable to save configuration!")); | ||
1494 | } | 1493 | } |
1495 | 1494 | ||
1496 | void ConfigMainWindow::searchConfig(void) | 1495 | void ConfigMainWindow::searchConfig(void) |
@@ -1643,7 +1642,7 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e) | |||
1643 | mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit")); | 1642 | mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit")); |
1644 | switch (mb.exec()) { | 1643 | switch (mb.exec()) { |
1645 | case QMessageBox::Yes: | 1644 | case QMessageBox::Yes: |
1646 | conf_write(NULL); | 1645 | saveConfig(); |
1647 | case QMessageBox::No: | 1646 | case QMessageBox::No: |
1648 | e->accept(); | 1647 | e->accept(); |
1649 | break; | 1648 | break; |
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 3dbaec185cc4..b22f884f9022 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l | |||
@@ -294,11 +294,11 @@ void zconf_initscan(const char *name) | |||
294 | 294 | ||
295 | current_file = file_lookup(name); | 295 | current_file = file_lookup(name); |
296 | current_file->lineno = 1; | 296 | current_file->lineno = 1; |
297 | current_file->flags = FILE_BUSY; | ||
298 | } | 297 | } |
299 | 298 | ||
300 | void zconf_nextfile(const char *name) | 299 | void zconf_nextfile(const char *name) |
301 | { | 300 | { |
301 | struct file *iter; | ||
302 | struct file *file = file_lookup(name); | 302 | struct file *file = file_lookup(name); |
303 | struct buffer *buf = malloc(sizeof(*buf)); | 303 | struct buffer *buf = malloc(sizeof(*buf)); |
304 | memset(buf, 0, sizeof(*buf)); | 304 | memset(buf, 0, sizeof(*buf)); |
@@ -314,18 +314,25 @@ void zconf_nextfile(const char *name) | |||
314 | buf->parent = current_buf; | 314 | buf->parent = current_buf; |
315 | current_buf = buf; | 315 | current_buf = buf; |
316 | 316 | ||
317 | if (file->flags & FILE_BUSY) { | 317 | for (iter = current_file->parent; iter; iter = iter->parent ) { |
318 | printf("%s:%d: do not source '%s' from itself\n", | 318 | if (!strcmp(current_file->name,iter->name) ) { |
319 | zconf_curname(), zconf_lineno(), name); | 319 | printf("%s:%d: recursive inclusion detected. " |
320 | exit(1); | 320 | "Inclusion path:\n current file : '%s'\n", |
321 | } | 321 | zconf_curname(), zconf_lineno(), |
322 | if (file->flags & FILE_SCANNED) { | 322 | zconf_curname()); |
323 | printf("%s:%d: file '%s' is already sourced from '%s'\n", | 323 | iter = current_file->parent; |
324 | zconf_curname(), zconf_lineno(), name, | 324 | while (iter && \ |
325 | file->parent->name); | 325 | strcmp(iter->name,current_file->name)) { |
326 | exit(1); | 326 | printf(" included from: '%s:%d'\n", |
327 | iter->name, iter->lineno-1); | ||
328 | iter = iter->parent; | ||
329 | } | ||
330 | if (iter) | ||
331 | printf(" included from: '%s:%d'\n", | ||
332 | iter->name, iter->lineno+1); | ||
333 | exit(1); | ||
334 | } | ||
327 | } | 335 | } |
328 | file->flags |= FILE_BUSY; | ||
329 | file->lineno = 1; | 336 | file->lineno = 1; |
330 | file->parent = current_file; | 337 | file->parent = current_file; |
331 | current_file = file; | 338 | current_file = file; |
@@ -335,8 +342,6 @@ static void zconf_endfile(void) | |||
335 | { | 342 | { |
336 | struct buffer *parent; | 343 | struct buffer *parent; |
337 | 344 | ||
338 | current_file->flags |= FILE_SCANNED; | ||
339 | current_file->flags &= ~FILE_BUSY; | ||
340 | current_file = current_file->parent; | 345 | current_file = current_file->parent; |
341 | 346 | ||
342 | parent = current_buf->parent; | 347 | parent = current_buf->parent; |
diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h index 50ad317a4bf9..f221ddf69080 100755 --- a/scripts/mkcompile_h +++ b/scripts/mkcompile_h | |||
@@ -42,6 +42,16 @@ if [ -z "$KBUILD_BUILD_TIMESTAMP" ]; then | |||
42 | else | 42 | else |
43 | TIMESTAMP=$KBUILD_BUILD_TIMESTAMP | 43 | TIMESTAMP=$KBUILD_BUILD_TIMESTAMP |
44 | fi | 44 | fi |
45 | if test -z "$KBUILD_BUILD_USER"; then | ||
46 | LINUX_COMPILE_BY=$(whoami | sed 's/\\/\\\\/') | ||
47 | else | ||
48 | LINUX_COMPILE_BY=$KBUILD_BUILD_USER | ||
49 | fi | ||
50 | if test -z "$KBUILD_BUILD_HOST"; then | ||
51 | LINUX_COMPILE_HOST=`hostname` | ||
52 | else | ||
53 | LINUX_COMPILE_HOST=$KBUILD_BUILD_HOST | ||
54 | fi | ||
45 | 55 | ||
46 | UTS_VERSION="#$VERSION" | 56 | UTS_VERSION="#$VERSION" |
47 | CONFIG_FLAGS="" | 57 | CONFIG_FLAGS="" |
@@ -63,20 +73,8 @@ UTS_TRUNCATE="cut -b -$UTS_LEN" | |||
63 | 73 | ||
64 | echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\" | 74 | echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\" |
65 | 75 | ||
66 | echo \#define LINUX_COMPILE_TIME \"`date +%T`\" | 76 | echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\" |
67 | echo \#define LINUX_COMPILE_BY \"`whoami`\" | 77 | echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\" |
68 | echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\" | ||
69 | |||
70 | domain=`dnsdomainname 2> /dev/null` | ||
71 | if [ -z "$domain" ]; then | ||
72 | domain=`domainname 2> /dev/null` | ||
73 | fi | ||
74 | |||
75 | if [ -n "$domain" ]; then | ||
76 | echo \#define LINUX_COMPILE_DOMAIN \"`echo $domain | $UTS_TRUNCATE`\" | ||
77 | else | ||
78 | echo \#define LINUX_COMPILE_DOMAIN | ||
79 | fi | ||
80 | 78 | ||
81 | echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -n 1`\" | 79 | echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -n 1`\" |
82 | ) > .tmpcompile | 80 | ) > .tmpcompile |
@@ -91,8 +89,8 @@ UTS_TRUNCATE="cut -b -$UTS_LEN" | |||
91 | # first line. | 89 | # first line. |
92 | 90 | ||
93 | if [ -r $TARGET ] && \ | 91 | if [ -r $TARGET ] && \ |
94 | grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' $TARGET > .tmpver.1 && \ | 92 | grep -v 'UTS_VERSION' $TARGET > .tmpver.1 && \ |
95 | grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' .tmpcompile > .tmpver.2 && \ | 93 | grep -v 'UTS_VERSION' .tmpcompile > .tmpver.2 && \ |
96 | cmp -s .tmpver.1 .tmpver.2; then | 94 | cmp -s .tmpver.1 .tmpver.2; then |
97 | rm -f .tmpcompile | 95 | rm -f .tmpcompile |
98 | else | 96 | else |
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 88f3f07205f8..e26e2fb462d4 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -702,6 +702,24 @@ static int do_ssb_entry(const char *filename, | |||
702 | return 1; | 702 | return 1; |
703 | } | 703 | } |
704 | 704 | ||
705 | /* Looks like: bcma:mNidNrevNclN. */ | ||
706 | static int do_bcma_entry(const char *filename, | ||
707 | struct bcma_device_id *id, char *alias) | ||
708 | { | ||
709 | id->manuf = TO_NATIVE(id->manuf); | ||
710 | id->id = TO_NATIVE(id->id); | ||
711 | id->rev = TO_NATIVE(id->rev); | ||
712 | id->class = TO_NATIVE(id->class); | ||
713 | |||
714 | strcpy(alias, "bcma:"); | ||
715 | ADD(alias, "m", id->manuf != BCMA_ANY_MANUF, id->manuf); | ||
716 | ADD(alias, "id", id->id != BCMA_ANY_ID, id->id); | ||
717 | ADD(alias, "rev", id->rev != BCMA_ANY_REV, id->rev); | ||
718 | ADD(alias, "cl", id->class != BCMA_ANY_CLASS, id->class); | ||
719 | add_wildcard(alias); | ||
720 | return 1; | ||
721 | } | ||
722 | |||
705 | /* Looks like: virtio:dNvN */ | 723 | /* Looks like: virtio:dNvN */ |
706 | static int do_virtio_entry(const char *filename, struct virtio_device_id *id, | 724 | static int do_virtio_entry(const char *filename, struct virtio_device_id *id, |
707 | char *alias) | 725 | char *alias) |
@@ -968,6 +986,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
968 | do_table(symval, sym->st_size, | 986 | do_table(symval, sym->st_size, |
969 | sizeof(struct ssb_device_id), "ssb", | 987 | sizeof(struct ssb_device_id), "ssb", |
970 | do_ssb_entry, mod); | 988 | do_ssb_entry, mod); |
989 | else if (sym_is(symname, "__mod_bcma_device_table")) | ||
990 | do_table(symval, sym->st_size, | ||
991 | sizeof(struct bcma_device_id), "bcma", | ||
992 | do_bcma_entry, mod); | ||
971 | else if (sym_is(symname, "__mod_virtio_device_table")) | 993 | else if (sym_is(symname, "__mod_virtio_device_table")) |
972 | do_table(symval, sym->st_size, | 994 | do_table(symval, sym->st_size, |
973 | sizeof(struct virtio_device_id), "virtio", | 995 | sizeof(struct virtio_device_id), "virtio", |
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index cd104afcc5f2..413c53693e62 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -420,11 +420,10 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
420 | return 0; | 420 | return 0; |
421 | } | 421 | } |
422 | 422 | ||
423 | if (hdr->e_shnum == 0) { | 423 | if (hdr->e_shnum == SHN_UNDEF) { |
424 | /* | 424 | /* |
425 | * There are more than 64k sections, | 425 | * There are more than 64k sections, |
426 | * read count from .sh_size. | 426 | * read count from .sh_size. |
427 | * note: it doesn't need shndx2secindex() | ||
428 | */ | 427 | */ |
429 | info->num_sections = TO_NATIVE(sechdrs[0].sh_size); | 428 | info->num_sections = TO_NATIVE(sechdrs[0].sh_size); |
430 | } | 429 | } |
@@ -432,8 +431,7 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
432 | info->num_sections = hdr->e_shnum; | 431 | info->num_sections = hdr->e_shnum; |
433 | } | 432 | } |
434 | if (hdr->e_shstrndx == SHN_XINDEX) { | 433 | if (hdr->e_shstrndx == SHN_XINDEX) { |
435 | info->secindex_strings = | 434 | info->secindex_strings = TO_NATIVE(sechdrs[0].sh_link); |
436 | shndx2secindex(TO_NATIVE(sechdrs[0].sh_link)); | ||
437 | } | 435 | } |
438 | else { | 436 | else { |
439 | info->secindex_strings = hdr->e_shstrndx; | 437 | info->secindex_strings = hdr->e_shstrndx; |
@@ -489,7 +487,7 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
489 | sechdrs[i].sh_offset; | 487 | sechdrs[i].sh_offset; |
490 | info->symtab_stop = (void *)hdr + | 488 | info->symtab_stop = (void *)hdr + |
491 | sechdrs[i].sh_offset + sechdrs[i].sh_size; | 489 | sechdrs[i].sh_offset + sechdrs[i].sh_size; |
492 | sh_link_idx = shndx2secindex(sechdrs[i].sh_link); | 490 | sh_link_idx = sechdrs[i].sh_link; |
493 | info->strtab = (void *)hdr + | 491 | info->strtab = (void *)hdr + |
494 | sechdrs[sh_link_idx].sh_offset; | 492 | sechdrs[sh_link_idx].sh_offset; |
495 | } | 493 | } |
@@ -516,11 +514,9 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
516 | 514 | ||
517 | if (symtab_shndx_idx != ~0U) { | 515 | if (symtab_shndx_idx != ~0U) { |
518 | Elf32_Word *p; | 516 | Elf32_Word *p; |
519 | if (symtab_idx != | 517 | if (symtab_idx != sechdrs[symtab_shndx_idx].sh_link) |
520 | shndx2secindex(sechdrs[symtab_shndx_idx].sh_link)) | ||
521 | fatal("%s: SYMTAB_SHNDX has bad sh_link: %u!=%u\n", | 518 | fatal("%s: SYMTAB_SHNDX has bad sh_link: %u!=%u\n", |
522 | filename, | 519 | filename, sechdrs[symtab_shndx_idx].sh_link, |
523 | shndx2secindex(sechdrs[symtab_shndx_idx].sh_link), | ||
524 | symtab_idx); | 520 | symtab_idx); |
525 | /* Fix endianness */ | 521 | /* Fix endianness */ |
526 | for (p = info->symtab_shndx_start; p < info->symtab_shndx_stop; | 522 | for (p = info->symtab_shndx_start; p < info->symtab_shndx_stop; |
@@ -1446,7 +1442,7 @@ static unsigned int *reloc_location(struct elf_info *elf, | |||
1446 | Elf_Shdr *sechdr, Elf_Rela *r) | 1442 | Elf_Shdr *sechdr, Elf_Rela *r) |
1447 | { | 1443 | { |
1448 | Elf_Shdr *sechdrs = elf->sechdrs; | 1444 | Elf_Shdr *sechdrs = elf->sechdrs; |
1449 | int section = shndx2secindex(sechdr->sh_info); | 1445 | int section = sechdr->sh_info; |
1450 | 1446 | ||
1451 | return (void *)elf->hdr + sechdrs[section].sh_offset + | 1447 | return (void *)elf->hdr + sechdrs[section].sh_offset + |
1452 | r->r_offset; | 1448 | r->r_offset; |
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 0388cfccac8d..2031119080dc 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h | |||
@@ -145,33 +145,22 @@ static inline int is_shndx_special(unsigned int i) | |||
145 | return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE; | 145 | return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE; |
146 | } | 146 | } |
147 | 147 | ||
148 | /* shndx is in [0..SHN_LORESERVE) U (SHN_HIRESERVE, 0xfffffff], thus: | 148 | /* |
149 | * shndx == 0 <=> sechdrs[0] | 149 | * Move reserved section indices SHN_LORESERVE..SHN_HIRESERVE out of |
150 | * ...... | 150 | * the way to -256..-1, to avoid conflicting with real section |
151 | * shndx == SHN_LORESERVE-1 <=> sechdrs[SHN_LORESERVE-1] | 151 | * indices. |
152 | * shndx == SHN_HIRESERVE+1 <=> sechdrs[SHN_LORESERVE] | ||
153 | * shndx == SHN_HIRESERVE+2 <=> sechdrs[SHN_LORESERVE+1] | ||
154 | * ...... | ||
155 | * fyi: sym->st_shndx is uint16, SHN_LORESERVE = ff00, SHN_HIRESERVE = ffff, | ||
156 | * so basically we map 0000..feff -> 0000..feff | ||
157 | * ff00..ffff -> (you are a bad boy, dont do it) | ||
158 | * 10000..xxxx -> ff00..(xxxx-0x100) | ||
159 | */ | 152 | */ |
160 | static inline unsigned int shndx2secindex(unsigned int i) | 153 | #define SPECIAL(i) ((i) - (SHN_HIRESERVE + 1)) |
161 | { | ||
162 | if (i <= SHN_HIRESERVE) | ||
163 | return i; | ||
164 | return i - (SHN_HIRESERVE + 1 - SHN_LORESERVE); | ||
165 | } | ||
166 | 154 | ||
167 | /* Accessor for sym->st_shndx, hides ugliness of "64k sections" */ | 155 | /* Accessor for sym->st_shndx, hides ugliness of "64k sections" */ |
168 | static inline unsigned int get_secindex(const struct elf_info *info, | 156 | static inline unsigned int get_secindex(const struct elf_info *info, |
169 | const Elf_Sym *sym) | 157 | const Elf_Sym *sym) |
170 | { | 158 | { |
159 | if (is_shndx_special(sym->st_shndx)) | ||
160 | return SPECIAL(sym->st_shndx); | ||
171 | if (sym->st_shndx != SHN_XINDEX) | 161 | if (sym->st_shndx != SHN_XINDEX) |
172 | return sym->st_shndx; | 162 | return sym->st_shndx; |
173 | return shndx2secindex(info->symtab_shndx_start[sym - | 163 | return info->symtab_shndx_start[sym - info->symtab_start]; |
174 | info->symtab_start]); | ||
175 | } | 164 | } |
176 | 165 | ||
177 | /* file2alias.c */ | 166 | /* file2alias.c */ |
diff --git a/scripts/module-common.lds b/scripts/module-common.lds index 47a1f9ae0ede..0865b3e752be 100644 --- a/scripts/module-common.lds +++ b/scripts/module-common.lds | |||
@@ -5,4 +5,15 @@ | |||
5 | */ | 5 | */ |
6 | SECTIONS { | 6 | SECTIONS { |
7 | /DISCARD/ : { *(.discard) } | 7 | /DISCARD/ : { *(.discard) } |
8 | |||
9 | __ksymtab : { *(SORT(___ksymtab+*)) } | ||
10 | __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) } | ||
11 | __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) } | ||
12 | __ksymtab_unused_gpl : { *(SORT(___ksymtab_unused_gpl+*)) } | ||
13 | __ksymtab_gpl_future : { *(SORT(___ksymtab_gpl_future+*)) } | ||
14 | __kcrctab : { *(SORT(___kcrctab+*)) } | ||
15 | __kcrctab_gpl : { *(SORT(___kcrctab_gpl+*)) } | ||
16 | __kcrctab_unused : { *(SORT(___kcrctab_unused+*)) } | ||
17 | __kcrctab_unused_gpl : { *(SORT(___kcrctab_unused_gpl+*)) } | ||
18 | __kcrctab_gpl_future : { *(SORT(___kcrctab_gpl_future+*)) } | ||
8 | } | 19 | } |
diff --git a/scripts/package/Makefile b/scripts/package/Makefile index a834b935f536..006960ebbce9 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile | |||
@@ -26,9 +26,9 @@ RPM := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \ | |||
26 | else echo rpm; fi) | 26 | else echo rpm; fi) |
27 | 27 | ||
28 | # Remove hyphens since they have special meaning in RPM filenames | 28 | # Remove hyphens since they have special meaning in RPM filenames |
29 | KERNELPATH := kernel-$(subst -,,$(KERNELRELEASE)) | 29 | KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE)) |
30 | MKSPEC := $(srctree)/scripts/package/mkspec | 30 | MKSPEC := $(srctree)/scripts/package/mkspec |
31 | PREV := set -e; cd ..; | 31 | PREV := set -e; cd -P ..; |
32 | 32 | ||
33 | # rpm-pkg | 33 | # rpm-pkg |
34 | # --------------------------------------------------------------------------- | 34 | # --------------------------------------------------------------------------- |
diff --git a/scripts/package/mkspec b/scripts/package/mkspec index e1c1d5b8ca70..4bf17ddf7c7f 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec | |||
@@ -22,7 +22,7 @@ if [ "`grep CONFIG_DRM=y .config | cut -f2 -d\=`" = "y" ]; then | |||
22 | fi | 22 | fi |
23 | 23 | ||
24 | PROVIDES="$PROVIDES kernel-$KERNELRELEASE" | 24 | PROVIDES="$PROVIDES kernel-$KERNELRELEASE" |
25 | __KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-//g"` | 25 | __KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-/_/g"` |
26 | 26 | ||
27 | echo "Name: kernel" | 27 | echo "Name: kernel" |
28 | echo "Summary: The Linux Kernel" | 28 | echo "Summary: The Linux Kernel" |
@@ -47,6 +47,18 @@ echo "" | |||
47 | echo "%description" | 47 | echo "%description" |
48 | echo "The Linux Kernel, the operating system core itself" | 48 | echo "The Linux Kernel, the operating system core itself" |
49 | echo "" | 49 | echo "" |
50 | echo "%package headers" | ||
51 | echo "Summary: Header files for the Linux kernel for use by glibc" | ||
52 | echo "Group: Development/System" | ||
53 | echo "Obsoletes: kernel-headers" | ||
54 | echo "Provides: kernel-headers = %{version}" | ||
55 | echo "%description headers" | ||
56 | echo "Kernel-headers includes the C header files that specify the interface" | ||
57 | echo "between the Linux kernel and userspace libraries and programs. The" | ||
58 | echo "header files define structures and constants that are needed for" | ||
59 | echo "building most standard programs and are also needed for rebuilding the" | ||
60 | echo "glibc package." | ||
61 | echo "" | ||
50 | 62 | ||
51 | if ! $PREBUILT; then | 63 | if ! $PREBUILT; then |
52 | echo "%prep" | 64 | echo "%prep" |
@@ -83,6 +95,7 @@ echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE" | |||
83 | echo "%endif" | 95 | echo "%endif" |
84 | echo "%endif" | 96 | echo "%endif" |
85 | 97 | ||
98 | echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr headers_install' | ||
86 | echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE" | 99 | echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE" |
87 | 100 | ||
88 | echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE" | 101 | echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE" |
@@ -105,3 +118,7 @@ echo "/lib/modules/$KERNELRELEASE" | |||
105 | echo "/lib/firmware" | 118 | echo "/lib/firmware" |
106 | echo "/boot/*" | 119 | echo "/boot/*" |
107 | echo "" | 120 | echo "" |
121 | echo "%files headers" | ||
122 | echo '%defattr (-, root, root)' | ||
123 | echo "/usr/include" | ||
124 | echo "" | ||
diff --git a/scripts/patch-kernel b/scripts/patch-kernel index 46a59cae3a0a..20fb25c23382 100755 --- a/scripts/patch-kernel +++ b/scripts/patch-kernel | |||
@@ -250,7 +250,7 @@ while : # incrementing SUBLEVEL (s in v.p.s) | |||
250 | do | 250 | do |
251 | CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL" | 251 | CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL" |
252 | EXTRAVER= | 252 | EXTRAVER= |
253 | if [ $STOPFULLVERSION = $CURRENTFULLVERSION ]; then | 253 | if [ x$STOPFULLVERSION = x$CURRENTFULLVERSION ]; then |
254 | echo "Stopping at $CURRENTFULLVERSION base as requested." | 254 | echo "Stopping at $CURRENTFULLVERSION base as requested." |
255 | break | 255 | break |
256 | fi | 256 | fi |
diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c index f9f6f52db772..ee52cb8e17ad 100644 --- a/scripts/recordmcount.c +++ b/scripts/recordmcount.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <sys/types.h> | 24 | #include <sys/types.h> |
25 | #include <sys/mman.h> | 25 | #include <sys/mman.h> |
26 | #include <sys/stat.h> | 26 | #include <sys/stat.h> |
27 | #include <getopt.h> | ||
27 | #include <elf.h> | 28 | #include <elf.h> |
28 | #include <fcntl.h> | 29 | #include <fcntl.h> |
29 | #include <setjmp.h> | 30 | #include <setjmp.h> |
@@ -39,6 +40,7 @@ static char gpfx; /* prefix for global symbol name (sometimes '_') */ | |||
39 | static struct stat sb; /* Remember .st_size, etc. */ | 40 | static struct stat sb; /* Remember .st_size, etc. */ |
40 | static jmp_buf jmpenv; /* setjmp/longjmp per-file error escape */ | 41 | static jmp_buf jmpenv; /* setjmp/longjmp per-file error escape */ |
41 | static const char *altmcount; /* alternate mcount symbol name */ | 42 | static const char *altmcount; /* alternate mcount symbol name */ |
43 | static int warn_on_notrace_sect; /* warn when section has mcount not being recorded */ | ||
42 | 44 | ||
43 | /* setjmp() return values */ | 45 | /* setjmp() return values */ |
44 | enum { | 46 | enum { |
@@ -78,7 +80,7 @@ static off_t | |||
78 | ulseek(int const fd, off_t const offset, int const whence) | 80 | ulseek(int const fd, off_t const offset, int const whence) |
79 | { | 81 | { |
80 | off_t const w = lseek(fd, offset, whence); | 82 | off_t const w = lseek(fd, offset, whence); |
81 | if ((off_t)-1 == w) { | 83 | if (w == (off_t)-1) { |
82 | perror("lseek"); | 84 | perror("lseek"); |
83 | fail_file(); | 85 | fail_file(); |
84 | } | 86 | } |
@@ -111,13 +113,41 @@ static void * | |||
111 | umalloc(size_t size) | 113 | umalloc(size_t size) |
112 | { | 114 | { |
113 | void *const addr = malloc(size); | 115 | void *const addr = malloc(size); |
114 | if (0 == addr) { | 116 | if (addr == 0) { |
115 | fprintf(stderr, "malloc failed: %zu bytes\n", size); | 117 | fprintf(stderr, "malloc failed: %zu bytes\n", size); |
116 | fail_file(); | 118 | fail_file(); |
117 | } | 119 | } |
118 | return addr; | 120 | return addr; |
119 | } | 121 | } |
120 | 122 | ||
123 | static unsigned char ideal_nop5_x86_64[5] = { 0x0f, 0x1f, 0x44, 0x00, 0x00 }; | ||
124 | static unsigned char ideal_nop5_x86_32[5] = { 0x3e, 0x8d, 0x74, 0x26, 0x00 }; | ||
125 | static unsigned char *ideal_nop; | ||
126 | |||
127 | static char rel_type_nop; | ||
128 | |||
129 | static int (*make_nop)(void *map, size_t const offset); | ||
130 | |||
131 | static int make_nop_x86(void *map, size_t const offset) | ||
132 | { | ||
133 | uint32_t *ptr; | ||
134 | unsigned char *op; | ||
135 | |||
136 | /* Confirm we have 0xe8 0x0 0x0 0x0 0x0 */ | ||
137 | ptr = map + offset; | ||
138 | if (*ptr != 0) | ||
139 | return -1; | ||
140 | |||
141 | op = map + offset - 1; | ||
142 | if (*op != 0xe8) | ||
143 | return -1; | ||
144 | |||
145 | /* convert to nop */ | ||
146 | ulseek(fd_map, offset - 1, SEEK_SET); | ||
147 | uwrite(fd_map, ideal_nop, 5); | ||
148 | return 0; | ||
149 | } | ||
150 | |||
121 | /* | 151 | /* |
122 | * Get the whole file as a programming convenience in order to avoid | 152 | * Get the whole file as a programming convenience in order to avoid |
123 | * malloc+lseek+read+free of many pieces. If successful, then mmap | 153 | * malloc+lseek+read+free of many pieces. If successful, then mmap |
@@ -136,7 +166,7 @@ static void *mmap_file(char const *fname) | |||
136 | void *addr; | 166 | void *addr; |
137 | 167 | ||
138 | fd_map = open(fname, O_RDWR); | 168 | fd_map = open(fname, O_RDWR); |
139 | if (0 > fd_map || 0 > fstat(fd_map, &sb)) { | 169 | if (fd_map < 0 || fstat(fd_map, &sb) < 0) { |
140 | perror(fname); | 170 | perror(fname); |
141 | fail_file(); | 171 | fail_file(); |
142 | } | 172 | } |
@@ -147,7 +177,7 @@ static void *mmap_file(char const *fname) | |||
147 | addr = mmap(0, sb.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, | 177 | addr = mmap(0, sb.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, |
148 | fd_map, 0); | 178 | fd_map, 0); |
149 | mmap_failed = 0; | 179 | mmap_failed = 0; |
150 | if (MAP_FAILED == addr) { | 180 | if (addr == MAP_FAILED) { |
151 | mmap_failed = 1; | 181 | mmap_failed = 1; |
152 | addr = umalloc(sb.st_size); | 182 | addr = umalloc(sb.st_size); |
153 | uread(fd_map, addr, sb.st_size); | 183 | uread(fd_map, addr, sb.st_size); |
@@ -206,12 +236,13 @@ static uint32_t (*w2)(uint16_t); | |||
206 | static int | 236 | static int |
207 | is_mcounted_section_name(char const *const txtname) | 237 | is_mcounted_section_name(char const *const txtname) |
208 | { | 238 | { |
209 | return 0 == strcmp(".text", txtname) || | 239 | return strcmp(".text", txtname) == 0 || |
210 | 0 == strcmp(".ref.text", txtname) || | 240 | strcmp(".ref.text", txtname) == 0 || |
211 | 0 == strcmp(".sched.text", txtname) || | 241 | strcmp(".sched.text", txtname) == 0 || |
212 | 0 == strcmp(".spinlock.text", txtname) || | 242 | strcmp(".spinlock.text", txtname) == 0 || |
213 | 0 == strcmp(".irqentry.text", txtname) || | 243 | strcmp(".irqentry.text", txtname) == 0 || |
214 | 0 == strcmp(".text.unlikely", txtname); | 244 | strcmp(".kprobes.text", txtname) == 0 || |
245 | strcmp(".text.unlikely", txtname) == 0; | ||
215 | } | 246 | } |
216 | 247 | ||
217 | /* 32 bit and 64 bit are very similar */ | 248 | /* 32 bit and 64 bit are very similar */ |
@@ -264,43 +295,48 @@ do_file(char const *const fname) | |||
264 | w8 = w8nat; | 295 | w8 = w8nat; |
265 | switch (ehdr->e_ident[EI_DATA]) { | 296 | switch (ehdr->e_ident[EI_DATA]) { |
266 | static unsigned int const endian = 1; | 297 | static unsigned int const endian = 1; |
267 | default: { | 298 | default: |
268 | fprintf(stderr, "unrecognized ELF data encoding %d: %s\n", | 299 | fprintf(stderr, "unrecognized ELF data encoding %d: %s\n", |
269 | ehdr->e_ident[EI_DATA], fname); | 300 | ehdr->e_ident[EI_DATA], fname); |
270 | fail_file(); | 301 | fail_file(); |
271 | } break; | 302 | break; |
272 | case ELFDATA2LSB: { | 303 | case ELFDATA2LSB: |
273 | if (1 != *(unsigned char const *)&endian) { | 304 | if (*(unsigned char const *)&endian != 1) { |
274 | /* main() is big endian, file.o is little endian. */ | 305 | /* main() is big endian, file.o is little endian. */ |
275 | w = w4rev; | 306 | w = w4rev; |
276 | w2 = w2rev; | 307 | w2 = w2rev; |
277 | w8 = w8rev; | 308 | w8 = w8rev; |
278 | } | 309 | } |
279 | } break; | 310 | break; |
280 | case ELFDATA2MSB: { | 311 | case ELFDATA2MSB: |
281 | if (0 != *(unsigned char const *)&endian) { | 312 | if (*(unsigned char const *)&endian != 0) { |
282 | /* main() is little endian, file.o is big endian. */ | 313 | /* main() is little endian, file.o is big endian. */ |
283 | w = w4rev; | 314 | w = w4rev; |
284 | w2 = w2rev; | 315 | w2 = w2rev; |
285 | w8 = w8rev; | 316 | w8 = w8rev; |
286 | } | 317 | } |
287 | } break; | 318 | break; |
288 | } /* end switch */ | 319 | } /* end switch */ |
289 | if (0 != memcmp(ELFMAG, ehdr->e_ident, SELFMAG) | 320 | if (memcmp(ELFMAG, ehdr->e_ident, SELFMAG) != 0 |
290 | || ET_REL != w2(ehdr->e_type) | 321 | || w2(ehdr->e_type) != ET_REL |
291 | || EV_CURRENT != ehdr->e_ident[EI_VERSION]) { | 322 | || ehdr->e_ident[EI_VERSION] != EV_CURRENT) { |
292 | fprintf(stderr, "unrecognized ET_REL file %s\n", fname); | 323 | fprintf(stderr, "unrecognized ET_REL file %s\n", fname); |
293 | fail_file(); | 324 | fail_file(); |
294 | } | 325 | } |
295 | 326 | ||
296 | gpfx = 0; | 327 | gpfx = 0; |
297 | switch (w2(ehdr->e_machine)) { | 328 | switch (w2(ehdr->e_machine)) { |
298 | default: { | 329 | default: |
299 | fprintf(stderr, "unrecognized e_machine %d %s\n", | 330 | fprintf(stderr, "unrecognized e_machine %d %s\n", |
300 | w2(ehdr->e_machine), fname); | 331 | w2(ehdr->e_machine), fname); |
301 | fail_file(); | 332 | fail_file(); |
302 | } break; | 333 | break; |
303 | case EM_386: reltype = R_386_32; break; | 334 | case EM_386: |
335 | reltype = R_386_32; | ||
336 | make_nop = make_nop_x86; | ||
337 | ideal_nop = ideal_nop5_x86_32; | ||
338 | mcount_adjust_32 = -1; | ||
339 | break; | ||
304 | case EM_ARM: reltype = R_ARM_ABS32; | 340 | case EM_ARM: reltype = R_ARM_ABS32; |
305 | altmcount = "__gnu_mcount_nc"; | 341 | altmcount = "__gnu_mcount_nc"; |
306 | break; | 342 | break; |
@@ -311,67 +347,91 @@ do_file(char const *const fname) | |||
311 | case EM_S390: /* reltype: e_class */ gpfx = '_'; break; | 347 | case EM_S390: /* reltype: e_class */ gpfx = '_'; break; |
312 | case EM_SH: reltype = R_SH_DIR32; break; | 348 | case EM_SH: reltype = R_SH_DIR32; break; |
313 | case EM_SPARCV9: reltype = R_SPARC_64; gpfx = '_'; break; | 349 | case EM_SPARCV9: reltype = R_SPARC_64; gpfx = '_'; break; |
314 | case EM_X86_64: reltype = R_X86_64_64; break; | 350 | case EM_X86_64: |
351 | make_nop = make_nop_x86; | ||
352 | ideal_nop = ideal_nop5_x86_64; | ||
353 | reltype = R_X86_64_64; | ||
354 | mcount_adjust_64 = -1; | ||
355 | break; | ||
315 | } /* end switch */ | 356 | } /* end switch */ |
316 | 357 | ||
317 | switch (ehdr->e_ident[EI_CLASS]) { | 358 | switch (ehdr->e_ident[EI_CLASS]) { |
318 | default: { | 359 | default: |
319 | fprintf(stderr, "unrecognized ELF class %d %s\n", | 360 | fprintf(stderr, "unrecognized ELF class %d %s\n", |
320 | ehdr->e_ident[EI_CLASS], fname); | 361 | ehdr->e_ident[EI_CLASS], fname); |
321 | fail_file(); | 362 | fail_file(); |
322 | } break; | 363 | break; |
323 | case ELFCLASS32: { | 364 | case ELFCLASS32: |
324 | if (sizeof(Elf32_Ehdr) != w2(ehdr->e_ehsize) | 365 | if (w2(ehdr->e_ehsize) != sizeof(Elf32_Ehdr) |
325 | || sizeof(Elf32_Shdr) != w2(ehdr->e_shentsize)) { | 366 | || w2(ehdr->e_shentsize) != sizeof(Elf32_Shdr)) { |
326 | fprintf(stderr, | 367 | fprintf(stderr, |
327 | "unrecognized ET_REL file: %s\n", fname); | 368 | "unrecognized ET_REL file: %s\n", fname); |
328 | fail_file(); | 369 | fail_file(); |
329 | } | 370 | } |
330 | if (EM_S390 == w2(ehdr->e_machine)) | 371 | if (w2(ehdr->e_machine) == EM_S390) { |
331 | reltype = R_390_32; | 372 | reltype = R_390_32; |
332 | if (EM_MIPS == w2(ehdr->e_machine)) { | 373 | mcount_adjust_32 = -4; |
374 | } | ||
375 | if (w2(ehdr->e_machine) == EM_MIPS) { | ||
333 | reltype = R_MIPS_32; | 376 | reltype = R_MIPS_32; |
334 | is_fake_mcount32 = MIPS32_is_fake_mcount; | 377 | is_fake_mcount32 = MIPS32_is_fake_mcount; |
335 | } | 378 | } |
336 | do32(ehdr, fname, reltype); | 379 | do32(ehdr, fname, reltype); |
337 | } break; | 380 | break; |
338 | case ELFCLASS64: { | 381 | case ELFCLASS64: { |
339 | Elf64_Ehdr *const ghdr = (Elf64_Ehdr *)ehdr; | 382 | Elf64_Ehdr *const ghdr = (Elf64_Ehdr *)ehdr; |
340 | if (sizeof(Elf64_Ehdr) != w2(ghdr->e_ehsize) | 383 | if (w2(ghdr->e_ehsize) != sizeof(Elf64_Ehdr) |
341 | || sizeof(Elf64_Shdr) != w2(ghdr->e_shentsize)) { | 384 | || w2(ghdr->e_shentsize) != sizeof(Elf64_Shdr)) { |
342 | fprintf(stderr, | 385 | fprintf(stderr, |
343 | "unrecognized ET_REL file: %s\n", fname); | 386 | "unrecognized ET_REL file: %s\n", fname); |
344 | fail_file(); | 387 | fail_file(); |
345 | } | 388 | } |
346 | if (EM_S390 == w2(ghdr->e_machine)) | 389 | if (w2(ghdr->e_machine) == EM_S390) { |
347 | reltype = R_390_64; | 390 | reltype = R_390_64; |
348 | if (EM_MIPS == w2(ghdr->e_machine)) { | 391 | mcount_adjust_64 = -8; |
392 | } | ||
393 | if (w2(ghdr->e_machine) == EM_MIPS) { | ||
349 | reltype = R_MIPS_64; | 394 | reltype = R_MIPS_64; |
350 | Elf64_r_sym = MIPS64_r_sym; | 395 | Elf64_r_sym = MIPS64_r_sym; |
351 | Elf64_r_info = MIPS64_r_info; | 396 | Elf64_r_info = MIPS64_r_info; |
352 | is_fake_mcount64 = MIPS64_is_fake_mcount; | 397 | is_fake_mcount64 = MIPS64_is_fake_mcount; |
353 | } | 398 | } |
354 | do64(ghdr, fname, reltype); | 399 | do64(ghdr, fname, reltype); |
355 | } break; | 400 | break; |
401 | } | ||
356 | } /* end switch */ | 402 | } /* end switch */ |
357 | 403 | ||
358 | cleanup(); | 404 | cleanup(); |
359 | } | 405 | } |
360 | 406 | ||
361 | int | 407 | int |
362 | main(int argc, char const *argv[]) | 408 | main(int argc, char *argv[]) |
363 | { | 409 | { |
364 | const char ftrace[] = "/ftrace.o"; | 410 | const char ftrace[] = "/ftrace.o"; |
365 | int ftrace_size = sizeof(ftrace) - 1; | 411 | int ftrace_size = sizeof(ftrace) - 1; |
366 | int n_error = 0; /* gcc-4.3.0 false positive complaint */ | 412 | int n_error = 0; /* gcc-4.3.0 false positive complaint */ |
413 | int c; | ||
414 | int i; | ||
415 | |||
416 | while ((c = getopt(argc, argv, "w")) >= 0) { | ||
417 | switch (c) { | ||
418 | case 'w': | ||
419 | warn_on_notrace_sect = 1; | ||
420 | break; | ||
421 | default: | ||
422 | fprintf(stderr, "usage: recordmcount [-w] file.o...\n"); | ||
423 | return 0; | ||
424 | } | ||
425 | } | ||
367 | 426 | ||
368 | if (argc <= 1) { | 427 | if ((argc - optind) < 1) { |
369 | fprintf(stderr, "usage: recordmcount file.o...\n"); | 428 | fprintf(stderr, "usage: recordmcount [-w] file.o...\n"); |
370 | return 0; | 429 | return 0; |
371 | } | 430 | } |
372 | 431 | ||
373 | /* Process each file in turn, allowing deep failure. */ | 432 | /* Process each file in turn, allowing deep failure. */ |
374 | for (--argc, ++argv; 0 < argc; --argc, ++argv) { | 433 | for (i = optind; i < argc; i++) { |
434 | char *file = argv[i]; | ||
375 | int const sjval = setjmp(jmpenv); | 435 | int const sjval = setjmp(jmpenv); |
376 | int len; | 436 | int len; |
377 | 437 | ||
@@ -380,29 +440,29 @@ main(int argc, char const *argv[]) | |||
380 | * function but does not call it. Since ftrace.o should | 440 | * function but does not call it. Since ftrace.o should |
381 | * not be traced anyway, we just skip it. | 441 | * not be traced anyway, we just skip it. |
382 | */ | 442 | */ |
383 | len = strlen(argv[0]); | 443 | len = strlen(file); |
384 | if (len >= ftrace_size && | 444 | if (len >= ftrace_size && |
385 | strcmp(argv[0] + (len - ftrace_size), ftrace) == 0) | 445 | strcmp(file + (len - ftrace_size), ftrace) == 0) |
386 | continue; | 446 | continue; |
387 | 447 | ||
388 | switch (sjval) { | 448 | switch (sjval) { |
389 | default: { | 449 | default: |
390 | fprintf(stderr, "internal error: %s\n", argv[0]); | 450 | fprintf(stderr, "internal error: %s\n", file); |
391 | exit(1); | 451 | exit(1); |
392 | } break; | 452 | break; |
393 | case SJ_SETJMP: { /* normal sequence */ | 453 | case SJ_SETJMP: /* normal sequence */ |
394 | /* Avoid problems if early cleanup() */ | 454 | /* Avoid problems if early cleanup() */ |
395 | fd_map = -1; | 455 | fd_map = -1; |
396 | ehdr_curr = NULL; | 456 | ehdr_curr = NULL; |
397 | mmap_failed = 1; | 457 | mmap_failed = 1; |
398 | do_file(argv[0]); | 458 | do_file(file); |
399 | } break; | 459 | break; |
400 | case SJ_FAIL: { /* error in do_file or below */ | 460 | case SJ_FAIL: /* error in do_file or below */ |
401 | ++n_error; | 461 | ++n_error; |
402 | } break; | 462 | break; |
403 | case SJ_SUCCEED: { /* premature success */ | 463 | case SJ_SUCCEED: /* premature success */ |
404 | /* do nothing */ | 464 | /* do nothing */ |
405 | } break; | 465 | break; |
406 | } /* end switch */ | 466 | } /* end switch */ |
407 | } | 467 | } |
408 | return !!n_error; | 468 | return !!n_error; |
diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h index baf187bee983..4be60364a405 100644 --- a/scripts/recordmcount.h +++ b/scripts/recordmcount.h | |||
@@ -22,11 +22,15 @@ | |||
22 | #undef is_fake_mcount | 22 | #undef is_fake_mcount |
23 | #undef fn_is_fake_mcount | 23 | #undef fn_is_fake_mcount |
24 | #undef MIPS_is_fake_mcount | 24 | #undef MIPS_is_fake_mcount |
25 | #undef mcount_adjust | ||
25 | #undef sift_rel_mcount | 26 | #undef sift_rel_mcount |
27 | #undef nop_mcount | ||
26 | #undef find_secsym_ndx | 28 | #undef find_secsym_ndx |
27 | #undef __has_rel_mcount | 29 | #undef __has_rel_mcount |
28 | #undef has_rel_mcount | 30 | #undef has_rel_mcount |
29 | #undef tot_relsize | 31 | #undef tot_relsize |
32 | #undef get_mcountsym | ||
33 | #undef get_sym_str_and_relp | ||
30 | #undef do_func | 34 | #undef do_func |
31 | #undef Elf_Addr | 35 | #undef Elf_Addr |
32 | #undef Elf_Ehdr | 36 | #undef Elf_Ehdr |
@@ -49,14 +53,18 @@ | |||
49 | #ifdef RECORD_MCOUNT_64 | 53 | #ifdef RECORD_MCOUNT_64 |
50 | # define append_func append64 | 54 | # define append_func append64 |
51 | # define sift_rel_mcount sift64_rel_mcount | 55 | # define sift_rel_mcount sift64_rel_mcount |
56 | # define nop_mcount nop_mcount_64 | ||
52 | # define find_secsym_ndx find64_secsym_ndx | 57 | # define find_secsym_ndx find64_secsym_ndx |
53 | # define __has_rel_mcount __has64_rel_mcount | 58 | # define __has_rel_mcount __has64_rel_mcount |
54 | # define has_rel_mcount has64_rel_mcount | 59 | # define has_rel_mcount has64_rel_mcount |
55 | # define tot_relsize tot64_relsize | 60 | # define tot_relsize tot64_relsize |
61 | # define get_sym_str_and_relp get_sym_str_and_relp_64 | ||
56 | # define do_func do64 | 62 | # define do_func do64 |
63 | # define get_mcountsym get_mcountsym_64 | ||
57 | # define is_fake_mcount is_fake_mcount64 | 64 | # define is_fake_mcount is_fake_mcount64 |
58 | # define fn_is_fake_mcount fn_is_fake_mcount64 | 65 | # define fn_is_fake_mcount fn_is_fake_mcount64 |
59 | # define MIPS_is_fake_mcount MIPS64_is_fake_mcount | 66 | # define MIPS_is_fake_mcount MIPS64_is_fake_mcount |
67 | # define mcount_adjust mcount_adjust_64 | ||
60 | # define Elf_Addr Elf64_Addr | 68 | # define Elf_Addr Elf64_Addr |
61 | # define Elf_Ehdr Elf64_Ehdr | 69 | # define Elf_Ehdr Elf64_Ehdr |
62 | # define Elf_Shdr Elf64_Shdr | 70 | # define Elf_Shdr Elf64_Shdr |
@@ -77,14 +85,18 @@ | |||
77 | #else | 85 | #else |
78 | # define append_func append32 | 86 | # define append_func append32 |
79 | # define sift_rel_mcount sift32_rel_mcount | 87 | # define sift_rel_mcount sift32_rel_mcount |
88 | # define nop_mcount nop_mcount_32 | ||
80 | # define find_secsym_ndx find32_secsym_ndx | 89 | # define find_secsym_ndx find32_secsym_ndx |
81 | # define __has_rel_mcount __has32_rel_mcount | 90 | # define __has_rel_mcount __has32_rel_mcount |
82 | # define has_rel_mcount has32_rel_mcount | 91 | # define has_rel_mcount has32_rel_mcount |
83 | # define tot_relsize tot32_relsize | 92 | # define tot_relsize tot32_relsize |
93 | # define get_sym_str_and_relp get_sym_str_and_relp_32 | ||
84 | # define do_func do32 | 94 | # define do_func do32 |
95 | # define get_mcountsym get_mcountsym_32 | ||
85 | # define is_fake_mcount is_fake_mcount32 | 96 | # define is_fake_mcount is_fake_mcount32 |
86 | # define fn_is_fake_mcount fn_is_fake_mcount32 | 97 | # define fn_is_fake_mcount fn_is_fake_mcount32 |
87 | # define MIPS_is_fake_mcount MIPS32_is_fake_mcount | 98 | # define MIPS_is_fake_mcount MIPS32_is_fake_mcount |
99 | # define mcount_adjust mcount_adjust_32 | ||
88 | # define Elf_Addr Elf32_Addr | 100 | # define Elf_Addr Elf32_Addr |
89 | # define Elf_Ehdr Elf32_Ehdr | 101 | # define Elf_Ehdr Elf32_Ehdr |
90 | # define Elf_Shdr Elf32_Shdr | 102 | # define Elf_Shdr Elf32_Shdr |
@@ -123,6 +135,8 @@ static void fn_ELF_R_INFO(Elf_Rel *const rp, unsigned sym, unsigned type) | |||
123 | } | 135 | } |
124 | static void (*Elf_r_info)(Elf_Rel *const rp, unsigned sym, unsigned type) = fn_ELF_R_INFO; | 136 | static void (*Elf_r_info)(Elf_Rel *const rp, unsigned sym, unsigned type) = fn_ELF_R_INFO; |
125 | 137 | ||
138 | static int mcount_adjust = 0; | ||
139 | |||
126 | /* | 140 | /* |
127 | * MIPS mcount long call has 2 _mcount symbols, only the position of the 1st | 141 | * MIPS mcount long call has 2 _mcount symbols, only the position of the 1st |
128 | * _mcount symbol is needed for dynamic function tracer, with it, to disable | 142 | * _mcount symbol is needed for dynamic function tracer, with it, to disable |
@@ -234,6 +248,49 @@ static void append_func(Elf_Ehdr *const ehdr, | |||
234 | uwrite(fd_map, ehdr, sizeof(*ehdr)); | 248 | uwrite(fd_map, ehdr, sizeof(*ehdr)); |
235 | } | 249 | } |
236 | 250 | ||
251 | static unsigned get_mcountsym(Elf_Sym const *const sym0, | ||
252 | Elf_Rel const *relp, | ||
253 | char const *const str0) | ||
254 | { | ||
255 | unsigned mcountsym = 0; | ||
256 | |||
257 | Elf_Sym const *const symp = | ||
258 | &sym0[Elf_r_sym(relp)]; | ||
259 | char const *symname = &str0[w(symp->st_name)]; | ||
260 | char const *mcount = gpfx == '_' ? "_mcount" : "mcount"; | ||
261 | |||
262 | if (symname[0] == '.') | ||
263 | ++symname; /* ppc64 hack */ | ||
264 | if (strcmp(mcount, symname) == 0 || | ||
265 | (altmcount && strcmp(altmcount, symname) == 0)) | ||
266 | mcountsym = Elf_r_sym(relp); | ||
267 | |||
268 | return mcountsym; | ||
269 | } | ||
270 | |||
271 | static void get_sym_str_and_relp(Elf_Shdr const *const relhdr, | ||
272 | Elf_Ehdr const *const ehdr, | ||
273 | Elf_Sym const **sym0, | ||
274 | char const **str0, | ||
275 | Elf_Rel const **relp) | ||
276 | { | ||
277 | Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff) | ||
278 | + (void *)ehdr); | ||
279 | unsigned const symsec_sh_link = w(relhdr->sh_link); | ||
280 | Elf_Shdr const *const symsec = &shdr0[symsec_sh_link]; | ||
281 | Elf_Shdr const *const strsec = &shdr0[w(symsec->sh_link)]; | ||
282 | Elf_Rel const *const rel0 = (Elf_Rel const *)(_w(relhdr->sh_offset) | ||
283 | + (void *)ehdr); | ||
284 | |||
285 | *sym0 = (Elf_Sym const *)(_w(symsec->sh_offset) | ||
286 | + (void *)ehdr); | ||
287 | |||
288 | *str0 = (char const *)(_w(strsec->sh_offset) | ||
289 | + (void *)ehdr); | ||
290 | |||
291 | *relp = rel0; | ||
292 | } | ||
293 | |||
237 | /* | 294 | /* |
238 | * Look at the relocations in order to find the calls to mcount. | 295 | * Look at the relocations in order to find the calls to mcount. |
239 | * Accumulate the section offsets that are found, and their relocation info, | 296 | * Accumulate the section offsets that are found, and their relocation info, |
@@ -250,47 +307,27 @@ static uint_t *sift_rel_mcount(uint_t *mlocp, | |||
250 | { | 307 | { |
251 | uint_t *const mloc0 = mlocp; | 308 | uint_t *const mloc0 = mlocp; |
252 | Elf_Rel *mrelp = *mrelpp; | 309 | Elf_Rel *mrelp = *mrelpp; |
253 | Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff) | 310 | Elf_Sym const *sym0; |
254 | + (void *)ehdr); | 311 | char const *str0; |
255 | unsigned const symsec_sh_link = w(relhdr->sh_link); | 312 | Elf_Rel const *relp; |
256 | Elf_Shdr const *const symsec = &shdr0[symsec_sh_link]; | ||
257 | Elf_Sym const *const sym0 = (Elf_Sym const *)(_w(symsec->sh_offset) | ||
258 | + (void *)ehdr); | ||
259 | |||
260 | Elf_Shdr const *const strsec = &shdr0[w(symsec->sh_link)]; | ||
261 | char const *const str0 = (char const *)(_w(strsec->sh_offset) | ||
262 | + (void *)ehdr); | ||
263 | |||
264 | Elf_Rel const *const rel0 = (Elf_Rel const *)(_w(relhdr->sh_offset) | ||
265 | + (void *)ehdr); | ||
266 | unsigned rel_entsize = _w(relhdr->sh_entsize); | 313 | unsigned rel_entsize = _w(relhdr->sh_entsize); |
267 | unsigned const nrel = _w(relhdr->sh_size) / rel_entsize; | 314 | unsigned const nrel = _w(relhdr->sh_size) / rel_entsize; |
268 | Elf_Rel const *relp = rel0; | ||
269 | |||
270 | unsigned mcountsym = 0; | 315 | unsigned mcountsym = 0; |
271 | unsigned t; | 316 | unsigned t; |
272 | 317 | ||
318 | get_sym_str_and_relp(relhdr, ehdr, &sym0, &str0, &relp); | ||
319 | |||
273 | for (t = nrel; t; --t) { | 320 | for (t = nrel; t; --t) { |
274 | if (!mcountsym) { | 321 | if (!mcountsym) |
275 | Elf_Sym const *const symp = | 322 | mcountsym = get_mcountsym(sym0, relp, str0); |
276 | &sym0[Elf_r_sym(relp)]; | ||
277 | char const *symname = &str0[w(symp->st_name)]; | ||
278 | char const *mcount = '_' == gpfx ? "_mcount" : "mcount"; | ||
279 | |||
280 | if ('.' == symname[0]) | ||
281 | ++symname; /* ppc64 hack */ | ||
282 | if (0 == strcmp(mcount, symname) || | ||
283 | (altmcount && 0 == strcmp(altmcount, symname))) | ||
284 | mcountsym = Elf_r_sym(relp); | ||
285 | } | ||
286 | 323 | ||
287 | if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) { | 324 | if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) { |
288 | uint_t const addend = _w(_w(relp->r_offset) - recval); | 325 | uint_t const addend = |
289 | 326 | _w(_w(relp->r_offset) - recval + mcount_adjust); | |
290 | mrelp->r_offset = _w(offbase | 327 | mrelp->r_offset = _w(offbase |
291 | + ((void *)mlocp - (void *)mloc0)); | 328 | + ((void *)mlocp - (void *)mloc0)); |
292 | Elf_r_info(mrelp, recsym, reltype); | 329 | Elf_r_info(mrelp, recsym, reltype); |
293 | if (sizeof(Elf_Rela) == rel_entsize) { | 330 | if (rel_entsize == sizeof(Elf_Rela)) { |
294 | ((Elf_Rela *)mrelp)->r_addend = addend; | 331 | ((Elf_Rela *)mrelp)->r_addend = addend; |
295 | *mlocp++ = 0; | 332 | *mlocp++ = 0; |
296 | } else | 333 | } else |
@@ -304,6 +341,63 @@ static uint_t *sift_rel_mcount(uint_t *mlocp, | |||
304 | return mlocp; | 341 | return mlocp; |
305 | } | 342 | } |
306 | 343 | ||
344 | /* | ||
345 | * Read the relocation table again, but this time its called on sections | ||
346 | * that are not going to be traced. The mcount calls here will be converted | ||
347 | * into nops. | ||
348 | */ | ||
349 | static void nop_mcount(Elf_Shdr const *const relhdr, | ||
350 | Elf_Ehdr const *const ehdr, | ||
351 | const char *const txtname) | ||
352 | { | ||
353 | Elf_Shdr *const shdr0 = (Elf_Shdr *)(_w(ehdr->e_shoff) | ||
354 | + (void *)ehdr); | ||
355 | Elf_Sym const *sym0; | ||
356 | char const *str0; | ||
357 | Elf_Rel const *relp; | ||
358 | Elf_Shdr const *const shdr = &shdr0[w(relhdr->sh_info)]; | ||
359 | unsigned rel_entsize = _w(relhdr->sh_entsize); | ||
360 | unsigned const nrel = _w(relhdr->sh_size) / rel_entsize; | ||
361 | unsigned mcountsym = 0; | ||
362 | unsigned t; | ||
363 | int once = 0; | ||
364 | |||
365 | get_sym_str_and_relp(relhdr, ehdr, &sym0, &str0, &relp); | ||
366 | |||
367 | for (t = nrel; t; --t) { | ||
368 | int ret = -1; | ||
369 | |||
370 | if (!mcountsym) | ||
371 | mcountsym = get_mcountsym(sym0, relp, str0); | ||
372 | |||
373 | if (mcountsym == Elf_r_sym(relp) && !is_fake_mcount(relp)) { | ||
374 | if (make_nop) | ||
375 | ret = make_nop((void *)ehdr, shdr->sh_offset + relp->r_offset); | ||
376 | if (warn_on_notrace_sect && !once) { | ||
377 | printf("Section %s has mcount callers being ignored\n", | ||
378 | txtname); | ||
379 | once = 1; | ||
380 | /* just warn? */ | ||
381 | if (!make_nop) | ||
382 | return; | ||
383 | } | ||
384 | } | ||
385 | |||
386 | /* | ||
387 | * If we successfully removed the mcount, mark the relocation | ||
388 | * as a nop (don't do anything with it). | ||
389 | */ | ||
390 | if (!ret) { | ||
391 | Elf_Rel rel; | ||
392 | rel = *(Elf_Rel *)relp; | ||
393 | Elf_r_info(&rel, Elf_r_sym(relp), rel_type_nop); | ||
394 | ulseek(fd_map, (void *)relp - (void *)ehdr, SEEK_SET); | ||
395 | uwrite(fd_map, &rel, sizeof(rel)); | ||
396 | } | ||
397 | relp = (Elf_Rel const *)(rel_entsize + (void *)relp); | ||
398 | } | ||
399 | } | ||
400 | |||
307 | 401 | ||
308 | /* | 402 | /* |
309 | * Find a symbol in the given section, to be used as the base for relocating | 403 | * Find a symbol in the given section, to be used as the base for relocating |
@@ -354,13 +448,13 @@ __has_rel_mcount(Elf_Shdr const *const relhdr, /* is SHT_REL or SHT_RELA */ | |||
354 | Elf_Shdr const *const txthdr = &shdr0[w(relhdr->sh_info)]; | 448 | Elf_Shdr const *const txthdr = &shdr0[w(relhdr->sh_info)]; |
355 | char const *const txtname = &shstrtab[w(txthdr->sh_name)]; | 449 | char const *const txtname = &shstrtab[w(txthdr->sh_name)]; |
356 | 450 | ||
357 | if (0 == strcmp("__mcount_loc", txtname)) { | 451 | if (strcmp("__mcount_loc", txtname) == 0) { |
358 | fprintf(stderr, "warning: __mcount_loc already exists: %s\n", | 452 | fprintf(stderr, "warning: __mcount_loc already exists: %s\n", |
359 | fname); | 453 | fname); |
360 | succeed_file(); | 454 | succeed_file(); |
361 | } | 455 | } |
362 | if (SHT_PROGBITS != w(txthdr->sh_type) || | 456 | if (w(txthdr->sh_type) != SHT_PROGBITS || |
363 | !is_mcounted_section_name(txtname)) | 457 | !(w(txthdr->sh_flags) & SHF_EXECINSTR)) |
364 | return NULL; | 458 | return NULL; |
365 | return txtname; | 459 | return txtname; |
366 | } | 460 | } |
@@ -370,7 +464,7 @@ static char const *has_rel_mcount(Elf_Shdr const *const relhdr, | |||
370 | char const *const shstrtab, | 464 | char const *const shstrtab, |
371 | char const *const fname) | 465 | char const *const fname) |
372 | { | 466 | { |
373 | if (SHT_REL != w(relhdr->sh_type) && SHT_RELA != w(relhdr->sh_type)) | 467 | if (w(relhdr->sh_type) != SHT_REL && w(relhdr->sh_type) != SHT_RELA) |
374 | return NULL; | 468 | return NULL; |
375 | return __has_rel_mcount(relhdr, shdr0, shstrtab, fname); | 469 | return __has_rel_mcount(relhdr, shdr0, shstrtab, fname); |
376 | } | 470 | } |
@@ -383,9 +477,11 @@ static unsigned tot_relsize(Elf_Shdr const *const shdr0, | |||
383 | { | 477 | { |
384 | unsigned totrelsz = 0; | 478 | unsigned totrelsz = 0; |
385 | Elf_Shdr const *shdrp = shdr0; | 479 | Elf_Shdr const *shdrp = shdr0; |
480 | char const *txtname; | ||
386 | 481 | ||
387 | for (; nhdr; --nhdr, ++shdrp) { | 482 | for (; nhdr; --nhdr, ++shdrp) { |
388 | if (has_rel_mcount(shdrp, shdr0, shstrtab, fname)) | 483 | txtname = has_rel_mcount(shdrp, shdr0, shstrtab, fname); |
484 | if (txtname && is_mcounted_section_name(txtname)) | ||
389 | totrelsz += _w(shdrp->sh_size); | 485 | totrelsz += _w(shdrp->sh_size); |
390 | } | 486 | } |
391 | return totrelsz; | 487 | return totrelsz; |
@@ -421,7 +517,7 @@ do_func(Elf_Ehdr *const ehdr, char const *const fname, unsigned const reltype) | |||
421 | for (relhdr = shdr0, k = nhdr; k; --k, ++relhdr) { | 517 | for (relhdr = shdr0, k = nhdr; k; --k, ++relhdr) { |
422 | char const *const txtname = has_rel_mcount(relhdr, shdr0, | 518 | char const *const txtname = has_rel_mcount(relhdr, shdr0, |
423 | shstrtab, fname); | 519 | shstrtab, fname); |
424 | if (txtname) { | 520 | if (txtname && is_mcounted_section_name(txtname)) { |
425 | uint_t recval = 0; | 521 | uint_t recval = 0; |
426 | unsigned const recsym = find_secsym_ndx( | 522 | unsigned const recsym = find_secsym_ndx( |
427 | w(relhdr->sh_info), txtname, &recval, | 523 | w(relhdr->sh_info), txtname, &recval, |
@@ -432,6 +528,12 @@ do_func(Elf_Ehdr *const ehdr, char const *const fname, unsigned const reltype) | |||
432 | mlocp = sift_rel_mcount(mlocp, | 528 | mlocp = sift_rel_mcount(mlocp, |
433 | (void *)mlocp - (void *)mloc0, &mrelp, | 529 | (void *)mlocp - (void *)mloc0, &mrelp, |
434 | relhdr, ehdr, recsym, recval, reltype); | 530 | relhdr, ehdr, recsym, recval, reltype); |
531 | } else if (txtname && (warn_on_notrace_sect || make_nop)) { | ||
532 | /* | ||
533 | * This section is ignored by ftrace, but still | ||
534 | * has mcount calls. Convert them to nops now. | ||
535 | */ | ||
536 | nop_mcount(relhdr, ehdr, txtname); | ||
435 | } | 537 | } |
436 | } | 538 | } |
437 | if (mloc0 != mlocp) { | 539 | if (mloc0 != mlocp) { |
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl index 4be0deea71ca..858966ab019c 100755 --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl | |||
@@ -134,6 +134,7 @@ my %text_sections = ( | |||
134 | ".sched.text" => 1, | 134 | ".sched.text" => 1, |
135 | ".spinlock.text" => 1, | 135 | ".spinlock.text" => 1, |
136 | ".irqentry.text" => 1, | 136 | ".irqentry.text" => 1, |
137 | ".kprobes.text" => 1, | ||
137 | ".text.unlikely" => 1, | 138 | ".text.unlikely" => 1, |
138 | ); | 139 | ); |
139 | 140 | ||
@@ -222,6 +223,7 @@ if ($arch eq "x86_64") { | |||
222 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount([+-]0x[0-9a-zA-Z]+)?\$"; | 223 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount([+-]0x[0-9a-zA-Z]+)?\$"; |
223 | $type = ".quad"; | 224 | $type = ".quad"; |
224 | $alignment = 8; | 225 | $alignment = 8; |
226 | $mcount_adjust = -1; | ||
225 | 227 | ||
226 | # force flags for this arch | 228 | # force flags for this arch |
227 | $ld .= " -m elf_x86_64"; | 229 | $ld .= " -m elf_x86_64"; |
@@ -231,6 +233,7 @@ if ($arch eq "x86_64") { | |||
231 | 233 | ||
232 | } elsif ($arch eq "i386") { | 234 | } elsif ($arch eq "i386") { |
233 | $alignment = 4; | 235 | $alignment = 4; |
236 | $mcount_adjust = -1; | ||
234 | 237 | ||
235 | # force flags for this arch | 238 | # force flags for this arch |
236 | $ld .= " -m elf_i386"; | 239 | $ld .= " -m elf_i386"; |
@@ -240,12 +243,14 @@ if ($arch eq "x86_64") { | |||
240 | 243 | ||
241 | } elsif ($arch eq "s390" && $bits == 32) { | 244 | } elsif ($arch eq "s390" && $bits == 32) { |
242 | $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_390_32\\s+_mcount\$"; | 245 | $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_390_32\\s+_mcount\$"; |
246 | $mcount_adjust = -4; | ||
243 | $alignment = 4; | 247 | $alignment = 4; |
244 | $ld .= " -m elf_s390"; | 248 | $ld .= " -m elf_s390"; |
245 | $cc .= " -m31"; | 249 | $cc .= " -m31"; |
246 | 250 | ||
247 | } elsif ($arch eq "s390" && $bits == 64) { | 251 | } elsif ($arch eq "s390" && $bits == 64) { |
248 | $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_390_(PC|PLT)32DBL\\s+_mcount\\+0x2\$"; | 252 | $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_390_(PC|PLT)32DBL\\s+_mcount\\+0x2\$"; |
253 | $mcount_adjust = -8; | ||
249 | $alignment = 8; | 254 | $alignment = 8; |
250 | $type = ".quad"; | 255 | $type = ".quad"; |
251 | $ld .= " -m elf64_s390"; | 256 | $ld .= " -m elf64_s390"; |