aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/.gitignore1
-rw-r--r--scripts/Kbuild.include12
-rw-r--r--scripts/Makefile7
-rw-r--r--scripts/Makefile.asm-generic23
-rw-r--r--scripts/Makefile.build86
-rw-r--r--scripts/Makefile.headersinst10
-rw-r--r--scripts/Makefile.lib2
-rw-r--r--scripts/Makefile.modpost4
-rw-r--r--scripts/basic/.gitignore2
-rw-r--r--scripts/basic/Makefile3
-rwxr-xr-xscripts/checkpatch.pl19
-rwxr-xr-xscripts/checkstack.pl2
-rw-r--r--scripts/docproc.c (renamed from scripts/basic/docproc.c)0
-rw-r--r--scripts/dtc/libfdt/libfdt.h2
-rw-r--r--scripts/dtc/livetree.c2
-rw-r--r--scripts/gen_initramfs_list.sh29
-rw-r--r--scripts/kallsyms.c2
-rw-r--r--scripts/kconfig/conf.c2
-rwxr-xr-xscripts/kernel-doc2
-rwxr-xr-xscripts/mkcompile_h30
-rw-r--r--scripts/mod/file2alias.c22
-rw-r--r--scripts/mod/modpost.c16
-rw-r--r--scripts/mod/modpost.h27
-rw-r--r--scripts/module-common.lds11
-rw-r--r--scripts/package/Makefile4
-rw-r--r--scripts/package/buildtar2
-rwxr-xr-xscripts/package/mkspec19
-rw-r--r--scripts/recordmcount.c168
-rw-r--r--scripts/recordmcount.h174
-rwxr-xr-xscripts/recordmcount.pl5
-rw-r--r--scripts/rt-tester/rt-tester.py2
31 files changed, 485 insertions, 205 deletions
diff --git a/scripts/.gitignore b/scripts/.gitignore
index e2741d23bab8..105b21f08185 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -8,3 +8,4 @@ bin2c
8unifdef 8unifdef
9ihex2fw 9ihex2fw
10recordmcount 10recordmcount
11docproc
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,\
118cc-option-align = $(subst -functions=0,,\ 118cc-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)
123cc-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)
123cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) 128cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC))
@@ -141,6 +146,11 @@ cc-ldoption = $(call try-run,\
141ld-option = $(call try-run,\ 146ld-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
152ar-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
188arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ 198arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
189 $(filter-out $(cmd_$@), $(cmd_$(1))) ) 199 $(filter-out $(cmd_$@), $(cmd_$(1))) )
200else
201arg-check = $(if $(strip $(cmd_$@)),,1)
190endif 202endif
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
10hostprogs-$(CONFIG_KALLSYMS) += kallsyms 11hostprogs-$(CONFIG_KALLSYMS) += kallsyms
11hostprogs-$(CONFIG_LOGO) += pnmtologo 12hostprogs-$(CONFIG_LOGO) += pnmtologo
@@ -16,12 +17,14 @@ hostprogs-$(BUILD_C_RECORDMCOUNT) += recordmcount
16always := $(hostprogs-y) $(hostprogs-m) 17always := $(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
19hostprogs-y += unifdef 20hostprogs-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
22PHONY += build_unifdef 23PHONY += build_unifdef
23build_unifdef: scripts/unifdef FORCE 24build_unifdef: scripts/unifdef FORCE
24 @: 25 @:
26build_docproc: scripts/docproc FORCE
27 @:
25 28
26subdir-$(CONFIG_MODVERSIONS) += genksyms 29subdir-$(CONFIG_MODVERSIONS) += genksyms
27subdir-y += mod 30subdir-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
8kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild
9-include $(kbuild-file)
10
11include scripts/Kbuild.include
12
13# Create output directory if not already present
14_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
15
16quiet_cmd_wrap = WRAP $@
17cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@
18
19all: $(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),)
51endif 51endif
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
58ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS 62ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS
59KBUILD_EXTRA_WARNINGS := -Wextra 63warning- := $(empty)
60KBUILD_EXTRA_WARNINGS += -Wunused -Wno-unused-parameter 64
61KBUILD_EXTRA_WARNINGS += -Waggregate-return 65warning-1 := -Wextra -Wunused -Wno-unused-parameter
62KBUILD_EXTRA_WARNINGS += -Wbad-function-cast 66warning-1 += -Wmissing-declarations
63KBUILD_EXTRA_WARNINGS += -Wcast-qual 67warning-1 += -Wmissing-format-attribute
64KBUILD_EXTRA_WARNINGS += -Wcast-align 68warning-1 += -Wmissing-prototypes
65KBUILD_EXTRA_WARNINGS += -Wconversion 69warning-1 += -Wold-style-definition
66KBUILD_EXTRA_WARNINGS += -Wdisabled-optimization 70warning-1 += $(call cc-option, -Wmissing-include-dirs)
67KBUILD_EXTRA_WARNINGS += -Wlogical-op 71warning-1 += $(call cc-option, -Wunused-but-set-variable)
68KBUILD_EXTRA_WARNINGS += -Wmissing-declarations 72
69KBUILD_EXTRA_WARNINGS += -Wmissing-format-attribute 73warning-2 := -Waggregate-return
70KBUILD_EXTRA_WARNINGS += $(call cc-option, -Wmissing-include-dirs,) 74warning-2 += -Wcast-align
71KBUILD_EXTRA_WARNINGS += -Wmissing-prototypes 75warning-2 += -Wdisabled-optimization
72KBUILD_EXTRA_WARNINGS += -Wnested-externs 76warning-2 += -Wnested-externs
73KBUILD_EXTRA_WARNINGS += -Wold-style-definition 77warning-2 += -Wshadow
74KBUILD_EXTRA_WARNINGS += $(call cc-option, -Woverlength-strings,) 78warning-2 += $(call cc-option, -Wlogical-op)
75KBUILD_EXTRA_WARNINGS += -Wpacked 79
76KBUILD_EXTRA_WARNINGS += -Wpacked-bitfield-compat 80warning-3 := -Wbad-function-cast
77KBUILD_EXTRA_WARNINGS += -Wpadded 81warning-3 += -Wcast-qual
78KBUILD_EXTRA_WARNINGS += -Wpointer-arith 82warning-3 += -Wconversion
79KBUILD_EXTRA_WARNINGS += -Wredundant-decls 83warning-3 += -Wpacked
80KBUILD_EXTRA_WARNINGS += -Wshadow 84warning-3 += -Wpadded
81KBUILD_EXTRA_WARNINGS += -Wswitch-default 85warning-3 += -Wpointer-arith
82KBUILD_EXTRA_WARNINGS += $(call cc-option, -Wvla,) 86warning-3 += -Wredundant-decls
83KBUILD_CFLAGS += $(KBUILD_EXTRA_WARNINGS) 87warning-3 += -Wswitch-default
88warning-3 += $(call cc-option, -Wpacked-bitfield-compat)
89warning-3 += $(call cc-option, -Wvla)
90
91warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
92warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
93warning += $(warning-$(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
94
95ifeq ("$(strip $(warning))","")
96 $(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown)
97endif
98
99KBUILD_CFLAGS += $(warning)
84endif 100endif
85 101
86include scripts/Makefile.lib 102include scripts/Makefile.lib
@@ -244,14 +260,19 @@ endif
244 260
245ifdef CONFIG_FTRACE_MCOUNT_RECORD 261ifdef CONFIG_FTRACE_MCOUNT_RECORD
246ifdef BUILD_C_RECORDMCOUNT 262ifdef BUILD_C_RECORDMCOUNT
263ifeq ("$(origin RECORDMCOUNT_WARN)", "command line")
264 RECORDMCOUNT_FLAGS = -w
265endif
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.
251sub_cmd_record_mcount = \ 270sub_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;
274recordmcount_source := $(srctree)/scripts/recordmcount.c \
275 $(srctree)/scripts/recordmcount.h
255else 276else
256sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ 277sub_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)" "$(@)";
283recordmcount_source := $(srctree)/scripts/recordmcount.pl
262endif 284endif
263cmd_record_mcount = \ 285cmd_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
279endef 301endef
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 $@
345cmd_link_o_target = $(if $(strip $(obj-y)),\ 367cmd_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#
372ifdef lib-target 394ifdef lib-target
373quiet_cmd_link_l_target = AR $@ 395quiet_cmd_link_l_target = AR $@
374cmd_link_l_target = rm -f $@; $(AR) rcs $@ $(lib-y) 396cmd_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))
27install-file := $(install)/.install 27install-file := $(install)/.install
28check-file := $(install)/.check 28check-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
32wrapper-files := $(filter $(header-y), $(generic-y))
33
30# all headers files for this dir 34# all headers files for this dir
31all-files := $(header-y) $(objhdr-y) 35header-y := $(filter-out $(generic-y), $(header-y))
36all-files := $(header-y) $(objhdr-y) $(wrapper-files)
32input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \ 37input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
33 $(addprefix $(objtree)/$(obj)/,$(objhdr-y)) 38 $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
34output-files := $(addprefix $(install)/, $(all-files)) 39output-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
52quiet_cmd_remove = REMOVE $(unwanted) 60quiet_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
199quiet_cmd_gzip = GZIP $@ 199quiet_cmd_gzip = GZIP $@
200cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -f -9 > $@) || \ 200cmd_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/Makefile.modpost b/scripts/Makefile.modpost
index 7d22056582c1..56dfafc73c1a 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -35,14 +35,14 @@
35# KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined 35# KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined
36# symbols in the final module linking stage 36# symbols in the final module linking stage
37# KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. 37# KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
38# This is solely usefull to speed up test compiles 38# This is solely useful to speed up test compiles
39PHONY := _modpost 39PHONY := _modpost
40_modpost: __modpost 40_modpost: __modpost
41 41
42include include/config/auto.conf 42include include/config/auto.conf
43include scripts/Kbuild.include 43include scripts/Kbuild.include
44 44
45# When building external modules load the Kbuild file to retreive EXTRA_SYMBOLS info 45# When building external modules load the Kbuild file to retrieve EXTRA_SYMBOLS info
46ifneq ($(KBUILD_EXTMOD),) 46ifneq ($(KBUILD_EXTMOD),)
47 47
48# set src + obj - they may be used when building the .mod.c file 48# set src + obj - they may be used when building the .mod.c file
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 @@
1hash
2fixdep fixdep
3docproc
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
12hostprogs-y := fixdep docproc 11hostprogs-y := fixdep
13always := $(hostprogs-y) 12always := $(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 8f9e394298cd..8657f99bfb2b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -210,10 +210,10 @@ our $typeTypedefs = qr{(?x:
210 210
211our $logFunctions = qr{(?x: 211our $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
219our @typeList = ( 219our @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 {
@@ -1946,13 +1946,13 @@ sub process {
1946# printk should use KERN_* levels. Note that follow on printk's on the 1946# printk should use KERN_* levels. Note that follow on printk's on the
1947# same line do not need a level, so we use the current block context 1947# same line do not need a level, so we use the current block context
1948# to try and find and validate the current printk. In summary the current 1948# to try and find and validate the current printk. In summary the current
1949# printk includes all preceeding printk's which have no newline on the end. 1949# printk includes all preceding printk's which have no newline on the end.
1950# we assume the first bad printk is the one to report. 1950# we assume the first bad printk is the one to report.
1951 if ($line =~ /\bprintk\((?!KERN_)\s*"/) { 1951 if ($line =~ /\bprintk\((?!KERN_)\s*"/) {
1952 my $ok = 0; 1952 my $ok = 0;
1953 for (my $ln = $linenr - 1; $ln >= $first_line; $ln--) { 1953 for (my $ln = $linenr - 1; $ln >= $first_line; $ln--) {
1954 #print "CHECK<$lines[$ln - 1]\n"; 1954 #print "CHECK<$lines[$ln - 1]\n";
1955 # we have a preceeding printk if it ends 1955 # we have a preceding printk if it ends
1956 # with "\n" ignore it, else it is to blame 1956 # with "\n" ignore it, else it is to blame
1957 if ($lines[$ln - 1] =~ m{\bprintk\(}) { 1957 if ($lines[$ln - 1] =~ m{\bprintk\(}) {
1958 if ($rawlines[$ln - 1] !~ m{\\n"}) { 1958 if ($rawlines[$ln - 1] !~ m{\\n"}) {
@@ -2044,7 +2044,7 @@ sub process {
2044 for (my $n = 0; $n < $#elements; $n += 2) { 2044 for (my $n = 0; $n < $#elements; $n += 2) {
2045 $off += length($elements[$n]); 2045 $off += length($elements[$n]);
2046 2046
2047 # Pick up the preceeding and succeeding characters. 2047 # Pick up the preceding and succeeding characters.
2048 my $ca = substr($opline, 0, $off); 2048 my $ca = substr($opline, 0, $off);
2049 my $cc = ''; 2049 my $cc = '';
2050 if (length($opline) >= ($off + length($elements[$n + 1]))) { 2050 if (length($opline) >= ($off + length($elements[$n + 1]))) {
@@ -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/basic/docproc.c b/scripts/docproc.c
index 98dec87974d0..98dec87974d0 100644
--- a/scripts/basic/docproc.c
+++ b/scripts/docproc.c
diff --git a/scripts/dtc/libfdt/libfdt.h b/scripts/dtc/libfdt/libfdt.h
index ce80e4fb41b2..ff6246f000ce 100644
--- a/scripts/dtc/libfdt/libfdt.h
+++ b/scripts/dtc/libfdt/libfdt.h
@@ -61,7 +61,7 @@
61#define FDT_ERR_NOTFOUND 1 61#define FDT_ERR_NOTFOUND 1
62 /* FDT_ERR_NOTFOUND: The requested node or property does not exist */ 62 /* FDT_ERR_NOTFOUND: The requested node or property does not exist */
63#define FDT_ERR_EXISTS 2 63#define FDT_ERR_EXISTS 2
64 /* FDT_ERR_EXISTS: Attemped to create a node or property which 64 /* FDT_ERR_EXISTS: Attempted to create a node or property which
65 * already exists */ 65 * already exists */
66#define FDT_ERR_NOSPACE 3 66#define FDT_ERR_NOSPACE 3
67 /* FDT_ERR_NOSPACE: Operation needed to expand the device 67 /* FDT_ERR_NOSPACE: Operation needed to expand the device
diff --git a/scripts/dtc/livetree.c b/scripts/dtc/livetree.c
index c9209d5c999e..26d0e1e60c0c 100644
--- a/scripts/dtc/livetree.c
+++ b/scripts/dtc/livetree.c
@@ -155,7 +155,7 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node)
155 } 155 }
156 } 156 }
157 157
158 /* if no collision occured, add child to the old node. */ 158 /* if no collision occurred, add child to the old node. */
159 if (new_child) 159 if (new_child)
160 add_child(old_node, new_child); 160 add_child(old_node, new_child);
161 } 161 }
diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
index 55caecdad995..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
106parse() { 106parse() {
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=
226output="/dev/stdout" 226output="/dev/stdout"
227output_file="" 227output_file=""
228is_cpio_compressed= 228is_cpio_compressed=
229compr="gzip -9 -f" 229compr="gzip -n -9 -f"
230 230
231arg="$1" 231arg="$1"
232case "$arg" in 232case "$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$" && \
@@ -284,11 +284,18 @@ while [ $# -gt 0 ]; do
284done 284done
285 285
286# If output_file is set we will generate cpio archive and compress it 286# If output_file is set we will generate cpio archive and compress it
287# we are carefull to delete tmp files 287# we are careful to delete tmp files
288if [ ! -z ${output_file} ]; then 288if [ ! -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/conf.c b/scripts/kconfig/conf.c
index 659326c3e895..006ad817cd5f 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -332,7 +332,7 @@ static int conf_choice(struct menu *menu)
332 } 332 }
333 if (!child) 333 if (!child)
334 continue; 334 continue;
335 if (line[strlen(line) - 1] == '?') { 335 if (line[0] && line[strlen(line) - 1] == '?') {
336 print_help(child); 336 print_help(child);
337 continue; 337 continue;
338 } 338 }
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 9f85012acf0d..d793001929cf 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1705,7 +1705,7 @@ sub push_parameter($$$) {
1705 1705
1706 $param = xml_escape($param); 1706 $param = xml_escape($param);
1707 1707
1708 # strip spaces from $param so that it is one continous string 1708 # strip spaces from $param so that it is one continuous string
1709 # on @parameterlist; 1709 # on @parameterlist;
1710 # this fixes a problem where check_sections() cannot find 1710 # this fixes a problem where check_sections() cannot find
1711 # a parameter like "addr[6 + 2]" because it actually appears 1711 # a parameter like "addr[6 + 2]" because it actually appears
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
42else 42else
43 TIMESTAMP=$KBUILD_BUILD_TIMESTAMP 43 TIMESTAMP=$KBUILD_BUILD_TIMESTAMP
44fi 44fi
45if test -z "$KBUILD_BUILD_USER"; then
46 LINUX_COMPILE_BY=$(whoami | sed 's/\\/\\\\/')
47else
48 LINUX_COMPILE_BY=$KBUILD_BUILD_USER
49fi
50if test -z "$KBUILD_BUILD_HOST"; then
51 LINUX_COMPILE_HOST=`hostname`
52else
53 LINUX_COMPILE_HOST=$KBUILD_BUILD_HOST
54fi
45 55
46UTS_VERSION="#$VERSION" 56UTS_VERSION="#$VERSION"
47CONFIG_FLAGS="" 57CONFIG_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
93if [ -r $TARGET ] && \ 91if [ -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
98else 96else
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. */
706static 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 */
706static int do_virtio_entry(const char *filename, struct virtio_device_id *id, 724static 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 */
160static 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" */
168static inline unsigned int get_secindex(const struct elf_info *info, 156static 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 */
6SECTIONS { 6SECTIONS {
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
29KERNELPATH := kernel-$(subst -,,$(KERNELRELEASE)) 29KERNELPATH := kernel-$(subst -,_,$(KERNELRELEASE))
30MKSPEC := $(srctree)/scripts/package/mkspec 30MKSPEC := $(srctree)/scripts/package/mkspec
31PREV := set -e; cd ..; 31PREV := set -e; cd -P ..;
32 32
33# rpm-pkg 33# rpm-pkg
34# --------------------------------------------------------------------------- 34# ---------------------------------------------------------------------------
diff --git a/scripts/package/buildtar b/scripts/package/buildtar
index 83c9c04102f2..8a7b15598ea9 100644
--- a/scripts/package/buildtar
+++ b/scripts/package/buildtar
@@ -92,7 +92,7 @@ case "${ARCH}" in
92 echo "" >&2 92 echo "" >&2
93 echo '** ** ** WARNING ** ** **' >&2 93 echo '** ** ** WARNING ** ** **' >&2
94 echo "" >&2 94 echo "" >&2
95 echo "Your architecture did not define any architecture-dependant files" >&2 95 echo "Your architecture did not define any architecture-dependent files" >&2
96 echo "to be placed into the tarball. Please add those to ${0} ..." >&2 96 echo "to be placed into the tarball. Please add those to ${0} ..." >&2
97 echo "" >&2 97 echo "" >&2
98 sleep 5 98 sleep 5
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
22fi 22fi
23 23
24PROVIDES="$PROVIDES kernel-$KERNELRELEASE" 24PROVIDES="$PROVIDES kernel-$KERNELRELEASE"
25__KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-//g"` 25__KERNELRELEASE=`echo $KERNELRELEASE | sed -e "s/-/_/g"`
26 26
27echo "Name: kernel" 27echo "Name: kernel"
28echo "Summary: The Linux Kernel" 28echo "Summary: The Linux Kernel"
@@ -47,6 +47,18 @@ echo ""
47echo "%description" 47echo "%description"
48echo "The Linux Kernel, the operating system core itself" 48echo "The Linux Kernel, the operating system core itself"
49echo "" 49echo ""
50echo "%package headers"
51echo "Summary: Header files for the Linux kernel for use by glibc"
52echo "Group: Development/System"
53echo "Obsoletes: kernel-headers"
54echo "Provides: kernel-headers = %{version}"
55echo "%description headers"
56echo "Kernel-headers includes the C header files that specify the interface"
57echo "between the Linux kernel and userspace libraries and programs. The"
58echo "header files define structures and constants that are needed for"
59echo "building most standard programs and are also needed for rebuilding the"
60echo "glibc package."
61echo ""
50 62
51if ! $PREBUILT; then 63if ! $PREBUILT; then
52echo "%prep" 64echo "%prep"
@@ -83,6 +95,7 @@ echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/vmlinuz-$KERNELRELEASE"
83echo "%endif" 95echo "%endif"
84echo "%endif" 96echo "%endif"
85 97
98echo 'make %{?_smp_mflags} INSTALL_HDR_PATH=$RPM_BUILD_ROOT/usr headers_install'
86echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE" 99echo 'cp System.map $RPM_BUILD_ROOT'"/boot/System.map-$KERNELRELEASE"
87 100
88echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE" 101echo 'cp .config $RPM_BUILD_ROOT'"/boot/config-$KERNELRELEASE"
@@ -105,3 +118,7 @@ echo "/lib/modules/$KERNELRELEASE"
105echo "/lib/firmware" 118echo "/lib/firmware"
106echo "/boot/*" 119echo "/boot/*"
107echo "" 120echo ""
121echo "%files headers"
122echo '%defattr (-, root, root)'
123echo "/usr/include"
124echo ""
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 '_') */
39static struct stat sb; /* Remember .st_size, etc. */ 40static struct stat sb; /* Remember .st_size, etc. */
40static jmp_buf jmpenv; /* setjmp/longjmp per-file error escape */ 41static jmp_buf jmpenv; /* setjmp/longjmp per-file error escape */
41static const char *altmcount; /* alternate mcount symbol name */ 42static const char *altmcount; /* alternate mcount symbol name */
43static int warn_on_notrace_sect; /* warn when section has mcount not being recorded */
42 44
43/* setjmp() return values */ 45/* setjmp() return values */
44enum { 46enum {
@@ -78,7 +80,7 @@ static off_t
78ulseek(int const fd, off_t const offset, int const whence) 80ulseek(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 *
111umalloc(size_t size) 113umalloc(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
123static unsigned char ideal_nop5_x86_64[5] = { 0x0f, 0x1f, 0x44, 0x00, 0x00 };
124static unsigned char ideal_nop5_x86_32[5] = { 0x3e, 0x8d, 0x74, 0x26, 0x00 };
125static unsigned char *ideal_nop;
126
127static char rel_type_nop;
128
129static int (*make_nop)(void *map, size_t const offset);
130
131static 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);
206static int 236static int
207is_mcounted_section_name(char const *const txtname) 237is_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
361int 407int
362main(int argc, char const *argv[]) 408main(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}
124static void (*Elf_r_info)(Elf_Rel *const rp, unsigned sym, unsigned type) = fn_ELF_R_INFO; 136static void (*Elf_r_info)(Elf_Rel *const rp, unsigned sym, unsigned type) = fn_ELF_R_INFO;
125 137
138static 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
251static 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
271static 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 */
349static 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";
diff --git a/scripts/rt-tester/rt-tester.py b/scripts/rt-tester/rt-tester.py
index 8c81d76959ee..34186cac1d2f 100644
--- a/scripts/rt-tester/rt-tester.py
+++ b/scripts/rt-tester/rt-tester.py
@@ -180,7 +180,7 @@ while 1:
180 for s in stat: 180 for s in stat:
181 s = s.strip() 181 s = s.strip()
182 if s.startswith(testop[0]): 182 if s.startswith(testop[0]):
183 # Seperate status value 183 # Separate status value
184 val = s[2:].strip() 184 val = s[2:].strip()
185 query = analyse(val, testop, dat) 185 query = analyse(val, testop, dat)
186 break 186 break