aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile2
-rw-r--r--scripts/Makefile.build65
-rw-r--r--scripts/Makefile.extrawarn67
-rw-r--r--scripts/Makefile.fwinst26
-rw-r--r--scripts/Makefile.host2
-rw-r--r--scripts/Makefile.lib10
-rwxr-xr-xscripts/checkpatch.pl136
-rwxr-xr-xscripts/checksyscalls.sh5
-rw-r--r--scripts/conmakehash.c12
-rwxr-xr-xscripts/decode_stacktrace.sh126
-rw-r--r--scripts/kconfig/Makefile4
-rw-r--r--scripts/kconfig/streamline_config.pl2
-rwxr-xr-xscripts/mkcompile_h4
-rw-r--r--scripts/mkmakefile15
-rw-r--r--scripts/mod/modpost.c4
-rw-r--r--scripts/package/builddeb2
-rwxr-xr-xscripts/patch-kernel4
-rw-r--r--scripts/recordmcount.c7
-rwxr-xr-xscripts/recordmcount.pl5
-rw-r--r--scripts/sortextable.c5
20 files changed, 378 insertions, 125 deletions
diff --git a/scripts/Makefile b/scripts/Makefile
index 1d07860f6c42..890df5c6adfb 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -39,4 +39,4 @@ subdir-$(CONFIG_SECURITY_SELINUX) += selinux
39subdir-$(CONFIG_DTC) += dtc 39subdir-$(CONFIG_DTC) += dtc
40 40
41# Let clean descend into subdirs 41# Let clean descend into subdirs
42subdir- += basic kconfig package selinux 42subdir- += basic kconfig package
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 003bc263105a..bf3e6778cd71 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -50,67 +50,6 @@ ifeq ($(KBUILD_NOPEDANTIC),)
50 endif 50 endif
51endif 51endif
52 52
53#
54# make W=... settings
55#
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
61# are not supported by all versions of the compiler
62ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS
63warning- := $(empty)
64
65warning-1 := -Wextra -Wunused -Wno-unused-parameter
66warning-1 += -Wmissing-declarations
67warning-1 += -Wmissing-format-attribute
68warning-1 += $(call cc-option, -Wmissing-prototypes)
69warning-1 += -Wold-style-definition
70warning-1 += $(call cc-option, -Wmissing-include-dirs)
71warning-1 += $(call cc-option, -Wunused-but-set-variable)
72warning-1 += $(call cc-disable-warning, missing-field-initializers)
73
74# Clang
75warning-1 += $(call cc-disable-warning, initializer-overrides)
76warning-1 += $(call cc-disable-warning, unused-value)
77warning-1 += $(call cc-disable-warning, format)
78warning-1 += $(call cc-disable-warning, unknown-warning-option)
79warning-1 += $(call cc-disable-warning, sign-compare)
80warning-1 += $(call cc-disable-warning, format-zero-length)
81warning-1 += $(call cc-disable-warning, uninitialized)
82warning-1 += $(call cc-option, -fcatch-undefined-behavior)
83
84warning-2 := -Waggregate-return
85warning-2 += -Wcast-align
86warning-2 += -Wdisabled-optimization
87warning-2 += -Wnested-externs
88warning-2 += -Wshadow
89warning-2 += $(call cc-option, -Wlogical-op)
90warning-2 += $(call cc-option, -Wmissing-field-initializers)
91
92warning-3 := -Wbad-function-cast
93warning-3 += -Wcast-qual
94warning-3 += -Wconversion
95warning-3 += -Wpacked
96warning-3 += -Wpadded
97warning-3 += -Wpointer-arith
98warning-3 += -Wredundant-decls
99warning-3 += -Wswitch-default
100warning-3 += $(call cc-option, -Wpacked-bitfield-compat)
101warning-3 += $(call cc-option, -Wvla)
102
103warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
104warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
105warning += $(warning-$(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
106
107ifeq ("$(strip $(warning))","")
108 $(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown)
109endif
110
111KBUILD_CFLAGS += $(warning)
112endif
113
114include scripts/Makefile.lib 53include scripts/Makefile.lib
115 54
116ifdef host-progs 55ifdef host-progs
@@ -342,7 +281,7 @@ $(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
342$(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) 281$(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
343 282
344quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ 283quiet_cmd_as_s_S = CPP $(quiet_modtag) $@
345cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< 284cmd_as_s_S = $(CPP) $(a_flags) -o $@ $<
346 285
347$(obj)/%.s: $(src)/%.S FORCE 286$(obj)/%.s: $(src)/%.S FORCE
348 $(call if_changed_dep,as_s_S) 287 $(call if_changed_dep,as_s_S)
@@ -436,7 +375,7 @@ link_multi_deps = \
436$(filter $(addprefix $(obj)/, \ 375$(filter $(addprefix $(obj)/, \
437$($(subst $(obj)/,,$(@:.o=-objs))) \ 376$($(subst $(obj)/,,$(@:.o=-objs))) \
438$($(subst $(obj)/,,$(@:.o=-y)))), $^) 377$($(subst $(obj)/,,$(@:.o=-y)))), $^)
439 378
440quiet_cmd_link_multi-y = LD $@ 379quiet_cmd_link_multi-y = LD $@
441cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis) 380cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
442 381
diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
new file mode 100644
index 000000000000..65643506c71c
--- /dev/null
+++ b/scripts/Makefile.extrawarn
@@ -0,0 +1,67 @@
1# ==========================================================================
2#
3# make W=... settings
4#
5# W=1 - warnings that may be relevant and does not occur too often
6# W=2 - warnings that occur quite often but may still be relevant
7# W=3 - the more obscure warnings, can most likely be ignored
8#
9# $(call cc-option, -W...) handles gcc -W.. options which
10# are not supported by all versions of the compiler
11# ==========================================================================
12
13ifeq ("$(origin W)", "command line")
14 export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
15endif
16
17ifdef KBUILD_ENABLE_EXTRA_GCC_CHECKS
18warning- := $(empty)
19
20warning-1 := -Wextra -Wunused -Wno-unused-parameter
21warning-1 += -Wmissing-declarations
22warning-1 += -Wmissing-format-attribute
23warning-1 += $(call cc-option, -Wmissing-prototypes)
24warning-1 += -Wold-style-definition
25warning-1 += $(call cc-option, -Wmissing-include-dirs)
26warning-1 += $(call cc-option, -Wunused-but-set-variable)
27warning-1 += $(call cc-disable-warning, missing-field-initializers)
28
29# Clang
30warning-1 += $(call cc-disable-warning, initializer-overrides)
31warning-1 += $(call cc-disable-warning, unused-value)
32warning-1 += $(call cc-disable-warning, format)
33warning-1 += $(call cc-disable-warning, unknown-warning-option)
34warning-1 += $(call cc-disable-warning, sign-compare)
35warning-1 += $(call cc-disable-warning, format-zero-length)
36warning-1 += $(call cc-disable-warning, uninitialized)
37warning-1 += $(call cc-option, -fcatch-undefined-behavior)
38
39warning-2 := -Waggregate-return
40warning-2 += -Wcast-align
41warning-2 += -Wdisabled-optimization
42warning-2 += -Wnested-externs
43warning-2 += -Wshadow
44warning-2 += $(call cc-option, -Wlogical-op)
45warning-2 += $(call cc-option, -Wmissing-field-initializers)
46
47warning-3 := -Wbad-function-cast
48warning-3 += -Wcast-qual
49warning-3 += -Wconversion
50warning-3 += -Wpacked
51warning-3 += -Wpadded
52warning-3 += -Wpointer-arith
53warning-3 += -Wredundant-decls
54warning-3 += -Wswitch-default
55warning-3 += $(call cc-option, -Wpacked-bitfield-compat)
56warning-3 += $(call cc-option, -Wvla)
57
58warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
59warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
60warning += $(warning-$(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))
61
62ifeq ("$(strip $(warning))","")
63 $(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown)
64endif
65
66KBUILD_CFLAGS += $(warning)
67endif
diff --git a/scripts/Makefile.fwinst b/scripts/Makefile.fwinst
index 4d908d16c035..d8e335eed226 100644
--- a/scripts/Makefile.fwinst
+++ b/scripts/Makefile.fwinst
@@ -18,31 +18,29 @@ include $(srctree)/$(obj)/Makefile
18include scripts/Makefile.host 18include scripts/Makefile.host
19 19
20mod-fw := $(fw-shipped-m) 20mod-fw := $(fw-shipped-m)
21# If CONFIG_FIRMWARE_IN_KERNEL isn't set, then install the 21# If CONFIG_FIRMWARE_IN_KERNEL isn't set, then install the
22# firmware for in-kernel drivers too. 22# firmware for in-kernel drivers too.
23ifndef CONFIG_FIRMWARE_IN_KERNEL 23ifndef CONFIG_FIRMWARE_IN_KERNEL
24mod-fw += $(fw-shipped-y) 24mod-fw += $(fw-shipped-y)
25endif 25endif
26 26
27ifneq ($(KBUILD_SRC),)
28# Create output directory if not already present
29_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
30
31firmware-dirs := $(sort $(addprefix $(objtree)/$(obj)/,$(dir $(fw-external-y) $(fw-shipped-all))))
32# Create directories for firmware in subdirectories
33_dummy := $(foreach d,$(firmware-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
34endif
35
27installed-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw)) 36installed-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw))
28 37
29installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all)) 38installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all))
30installed-fw-dirs := $(sort $(dir $(installed-fw))) $(INSTALL_FW_PATH)/./
31
32# Workaround for make < 3.81, where .SECONDEXPANSION doesn't work.
33PHONY += $(INSTALL_FW_PATH)/$$(%) install-all-dirs
34$(INSTALL_FW_PATH)/$$(%): install-all-dirs
35 @true
36install-all-dirs: $(installed-fw-dirs)
37 @true
38 39
39quiet_cmd_install = INSTALL $(subst $(srctree)/,,$@) 40quiet_cmd_install = INSTALL $(subst $(srctree)/,,$@)
40 cmd_install = $(INSTALL) -m0644 $< $@ 41 cmd_install = mkdir -p $(@D); $(INSTALL) -m0644 $< $@
41
42$(installed-fw-dirs):
43 $(call cmd,mkdir)
44 42
45$(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/% | $(INSTALL_FW_PATH)/$$(dir %) 43$(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/%
46 $(call cmd,install) 44 $(call cmd,install)
47 45
48PHONY += __fw_install __fw_modinst FORCE 46PHONY += __fw_install __fw_modinst FORCE
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index b0ec4be67674..66893643fd7d 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -166,4 +166,4 @@ $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
166 $(call if_changed,host-cshlib) 166 $(call if_changed,host-cshlib)
167 167
168targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\ 168targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
169 $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) 169 $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 6a5b0decb797..260bf8acfce9 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -27,7 +27,7 @@ lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))
27# --------------------------------------------------------------------------- 27# ---------------------------------------------------------------------------
28# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.o 28# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.o
29# and add the directory to the list of dirs to descend into: $(subdir-y) 29# and add the directory to the list of dirs to descend into: $(subdir-y)
30# o if we encounter foo/ in $(obj-m), remove it from $(obj-m) 30# o if we encounter foo/ in $(obj-m), remove it from $(obj-m)
31# and add the directory to the list of dirs to descend into: $(subdir-m) 31# and add the directory to the list of dirs to descend into: $(subdir-m)
32 32
33# Determine modorder. 33# Determine modorder.
@@ -46,7 +46,7 @@ obj-m := $(filter-out %/, $(obj-m))
46 46
47subdir-ym := $(sort $(subdir-y) $(subdir-m)) 47subdir-ym := $(sort $(subdir-y) $(subdir-m))
48 48
49# if $(foo-objs) exists, foo.o is a composite object 49# if $(foo-objs) exists, foo.o is a composite object
50multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) 50multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
51multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) 51multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
52multi-used := $(multi-used-y) $(multi-used-m) 52multi-used := $(multi-used-y) $(multi-used-m)
@@ -91,7 +91,7 @@ obj-dirs := $(addprefix $(obj)/,$(obj-dirs))
91 91
92# These flags are needed for modversions and compiling, so we define them here 92# These flags are needed for modversions and compiling, so we define them here
93# already 93# already
94# $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will 94# $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will
95# end up in (or would, if it gets compiled in) 95# end up in (or would, if it gets compiled in)
96# Note: Files that end up in two or more modules are compiled without the 96# Note: Files that end up in two or more modules are compiled without the
97# KBUILD_MODNAME definition. The reason is that any made-up name would 97# KBUILD_MODNAME definition. The reason is that any made-up name would
@@ -212,7 +212,7 @@ $(obj)/%: $(src)/%_shipped
212 212
213# Commands useful for building a boot image 213# Commands useful for building a boot image
214# =========================================================================== 214# ===========================================================================
215# 215#
216# Use as following: 216# Use as following:
217# 217#
218# target: source(s) FORCE 218# target: source(s) FORCE
@@ -226,7 +226,7 @@ $(obj)/%: $(src)/%_shipped
226 226
227quiet_cmd_ld = LD $@ 227quiet_cmd_ld = LD $@
228cmd_ld = $(LD) $(LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) \ 228cmd_ld = $(LD) $(LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) \
229 $(filter-out FORCE,$^) -o $@ 229 $(filter-out FORCE,$^) -o $@
230 230
231# Objcopy 231# Objcopy
232# --------------------------------------------------------------------------- 232# ---------------------------------------------------------------------------
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 34eb2160489d..010b18ef4ea0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -24,6 +24,7 @@ my $emacs = 0;
24my $terse = 0; 24my $terse = 0;
25my $file = 0; 25my $file = 0;
26my $check = 0; 26my $check = 0;
27my $check_orig = 0;
27my $summary = 1; 28my $summary = 1;
28my $mailback = 0; 29my $mailback = 0;
29my $summary_file = 0; 30my $summary_file = 0;
@@ -146,6 +147,7 @@ GetOptions(
146help(0) if ($help); 147help(0) if ($help);
147 148
148$fix = 1 if ($fix_inplace); 149$fix = 1 if ($fix_inplace);
150$check_orig = $check;
149 151
150my $exit = 0; 152my $exit = 0;
151 153
@@ -397,6 +399,11 @@ foreach my $entry (@mode_permission_funcs) {
397 $mode_perms_search .= $entry->[0]; 399 $mode_perms_search .= $entry->[0];
398} 400}
399 401
402our $declaration_macros = qr{(?x:
403 (?:$Storage\s+)?(?:DECLARE|DEFINE)_[A-Z]+\s*\(|
404 (?:$Storage\s+)?LIST_HEAD\s*\(
405)};
406
400our $allowed_asm_includes = qr{(?x: 407our $allowed_asm_includes = qr{(?x:
401 irq| 408 irq|
402 memory 409 memory
@@ -1808,11 +1815,13 @@ sub process {
1808 $here = "#$linenr: " if (!$file); 1815 $here = "#$linenr: " if (!$file);
1809 $here = "#$realline: " if ($file); 1816 $here = "#$realline: " if ($file);
1810 1817
1818 my $found_file = 0;
1811 # extract the filename as it passes 1819 # extract the filename as it passes
1812 if ($line =~ /^diff --git.*?(\S+)$/) { 1820 if ($line =~ /^diff --git.*?(\S+)$/) {
1813 $realfile = $1; 1821 $realfile = $1;
1814 $realfile =~ s@^([^/]*)/@@ if (!$file); 1822 $realfile =~ s@^([^/]*)/@@ if (!$file);
1815 $in_commit_log = 0; 1823 $in_commit_log = 0;
1824 $found_file = 1;
1816 } elsif ($line =~ /^\+\+\+\s+(\S+)/) { 1825 } elsif ($line =~ /^\+\+\+\s+(\S+)/) {
1817 $realfile = $1; 1826 $realfile = $1;
1818 $realfile =~ s@^([^/]*)/@@ if (!$file); 1827 $realfile =~ s@^([^/]*)/@@ if (!$file);
@@ -1829,6 +1838,15 @@ sub process {
1829 ERROR("MODIFIED_INCLUDE_ASM", 1838 ERROR("MODIFIED_INCLUDE_ASM",
1830 "do not modify files in include/asm, change architecture specific files in include/asm-<architecture>\n" . "$here$rawline\n"); 1839 "do not modify files in include/asm, change architecture specific files in include/asm-<architecture>\n" . "$here$rawline\n");
1831 } 1840 }
1841 $found_file = 1;
1842 }
1843
1844 if ($found_file) {
1845 if ($realfile =~ m@^(drivers/net/|net/)@) {
1846 $check = 1;
1847 } else {
1848 $check = $check_orig;
1849 }
1832 next; 1850 next;
1833 } 1851 }
1834 1852
@@ -1926,6 +1944,12 @@ sub process {
1926 } 1944 }
1927 } 1945 }
1928 1946
1947# Check for old stable address
1948 if ($line =~ /^\s*cc:\s*.*<?\bstable\@kernel\.org\b>?.*$/i) {
1949 ERROR("STABLE_ADDRESS",
1950 "The 'stable' address should be 'stable\@vger.kernel.org'\n" . $herecurr);
1951 }
1952
1929# Check for unwanted Gerrit info 1953# Check for unwanted Gerrit info
1930 if ($in_commit_log && $line =~ /^\s*change-id:/i) { 1954 if ($in_commit_log && $line =~ /^\s*change-id:/i) {
1931 ERROR("GERRIT_CHANGE_ID", 1955 ERROR("GERRIT_CHANGE_ID",
@@ -2093,8 +2117,10 @@ sub process {
2093 2117
2094 foreach my $compat (@compats) { 2118 foreach my $compat (@compats) {
2095 my $compat2 = $compat; 2119 my $compat2 = $compat;
2096 $compat2 =~ s/\,[a-z]*\-/\,<\.\*>\-/; 2120 $compat2 =~ s/\,[a-zA-Z0-9]*\-/\,<\.\*>\-/;
2097 `grep -Erq "$compat|$compat2" $dt_path`; 2121 my $compat3 = $compat;
2122 $compat3 =~ s/\,([a-z]*)[0-9]*\-/\,$1<\.\*>\-/;
2123 `grep -Erq "$compat|$compat2|$compat3" $dt_path`;
2098 if ( $? >> 8 ) { 2124 if ( $? >> 8 ) {
2099 WARN("UNDOCUMENTED_DT_STRING", 2125 WARN("UNDOCUMENTED_DT_STRING",
2100 "DT compatible string \"$compat\" appears un-documented -- check $dt_path\n" . $herecurr); 2126 "DT compatible string \"$compat\" appears un-documented -- check $dt_path\n" . $herecurr);
@@ -2266,18 +2292,37 @@ sub process {
2266 } 2292 }
2267 2293
2268# check for missing blank lines after declarations 2294# check for missing blank lines after declarations
2269 if ($realfile =~ m@^(drivers/net/|net/)@ && 2295 if ($sline =~ /^\+\s+\S/ && #Not at char 1
2270 $prevline =~ /^\+\s+$Declare\s+$Ident/ && 2296 # actual declarations
2271 !($prevline =~ /(?:$Compare|$Assignment|$Operators)\s*$/ || 2297 ($prevline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ ||
2272 $prevline =~ /(?:\{\s*|\\)$/) && #extended lines 2298 # foo bar; where foo is some local typedef or #define
2273 $sline =~ /^\+\s+/ && #Not at char 1 2299 $prevline =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ ||
2274 !($sline =~ /^\+\s+$Declare/ || 2300 # known declaration macros
2275 $sline =~ /^\+\s+$Ident\s+$Ident/ || #eg: typedef foo 2301 $prevline =~ /^\+\s+$declaration_macros/) &&
2302 # for "else if" which can look like "$Ident $Ident"
2303 !($prevline =~ /^\+\s+$c90_Keywords\b/ ||
2304 # other possible extensions of declaration lines
2305 $prevline =~ /(?:$Compare|$Assignment|$Operators)\s*$/ ||
2306 # not starting a section or a macro "\" extended line
2307 $prevline =~ /(?:\{\s*|\\)$/) &&
2308 # looks like a declaration
2309 !($sline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ ||
2310 # foo bar; where foo is some local typedef or #define
2311 $sline =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ ||
2312 # known declaration macros
2313 $sline =~ /^\+\s+$declaration_macros/ ||
2314 # start of struct or union or enum
2276 $sline =~ /^\+\s+(?:union|struct|enum|typedef)\b/ || 2315 $sline =~ /^\+\s+(?:union|struct|enum|typedef)\b/ ||
2277 $sline =~ /^\+\s+(?:$|[\{\}\.\#\"\?\:\(])/ || 2316 # start or end of block or continuation of declaration
2278 $sline =~ /^\+\s+\(?\s*(?:$Compare|$Assignment|$Operators)/)) { 2317 $sline =~ /^\+\s+(?:$|[\{\}\.\#\"\?\:\(\[])/ ||
2318 # bitfield continuation
2319 $sline =~ /^\+\s+$Ident\s*:\s*\d+\s*[,;]/ ||
2320 # other possible extensions of declaration lines
2321 $sline =~ /^\+\s+\(?\s*(?:$Compare|$Assignment|$Operators)/) &&
2322 # indentation of previous and current line are the same
2323 (($prevline =~ /\+(\s+)\S/) && $sline =~ /^\+$1\S/)) {
2279 WARN("SPACING", 2324 WARN("SPACING",
2280 "networking uses a blank line after declarations\n" . $hereprev); 2325 "Missing a blank line after declarations\n" . $hereprev);
2281 } 2326 }
2282 2327
2283# check for spaces at the beginning of a line. 2328# check for spaces at the beginning of a line.
@@ -3431,6 +3476,13 @@ sub process {
3431 } 3476 }
3432 } 3477 }
3433 3478
3479# unnecessary return in a void function? (a single leading tab, then return;)
3480 if ($sline =~ /^\+\treturn\s*;\s*$/ &&
3481 $prevline =~ /^\+/) {
3482 WARN("RETURN_VOID",
3483 "void function return statements are not generally useful\n" . $herecurr);
3484 }
3485
3434# if statements using unnecessary parentheses - ie: if ((foo == bar)) 3486# if statements using unnecessary parentheses - ie: if ((foo == bar))
3435 if ($^V && $^V ge 5.10.0 && 3487 if ($^V && $^V ge 5.10.0 &&
3436 $line =~ /\bif\s*((?:\(\s*){2,})/) { 3488 $line =~ /\bif\s*((?:\(\s*){2,})/) {
@@ -3782,6 +3834,17 @@ sub process {
3782 WARN("DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON", 3834 WARN("DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON",
3783 "do {} while (0) macros should not be semicolon terminated\n" . "$herectx"); 3835 "do {} while (0) macros should not be semicolon terminated\n" . "$herectx");
3784 } 3836 }
3837 } elsif ($dstat =~ /^\+\s*#\s*define\s+$Ident.*;\s*$/) {
3838 $ctx =~ s/\n*$//;
3839 my $cnt = statement_rawlines($ctx);
3840 my $herectx = $here . "\n";
3841
3842 for (my $n = 0; $n < $cnt; $n++) {
3843 $herectx .= raw_line($linenr, $n) . "\n";
3844 }
3845
3846 WARN("TRAILING_SEMICOLON",
3847 "macros should not use a trailing semicolon\n" . "$herectx");
3785 } 3848 }
3786 } 3849 }
3787 3850
@@ -4264,6 +4327,27 @@ sub process {
4264 "unchecked sscanf return value\n" . "$here\n$stat_real\n"); 4327 "unchecked sscanf return value\n" . "$here\n$stat_real\n");
4265 } 4328 }
4266 4329
4330# check for simple sscanf that should be kstrto<foo>
4331 if ($^V && $^V ge 5.10.0 &&
4332 defined $stat &&
4333 $line =~ /\bsscanf\b/) {
4334 my $lc = $stat =~ tr@\n@@;
4335 $lc = $lc + $linenr;
4336 my $stat_real = raw_line($linenr, 0);
4337 for (my $count = $linenr + 1; $count <= $lc; $count++) {
4338 $stat_real = $stat_real . "\n" . raw_line($count, 0);
4339 }
4340 if ($stat_real =~ /\bsscanf\b\s*\(\s*$FuncArg\s*,\s*("[^"]+")/) {
4341 my $format = $6;
4342 my $count = $format =~ tr@%@%@;
4343 if ($count == 1 &&
4344 $format =~ /^"\%(?i:ll[udxi]|[udxi]ll|ll|[hl]h?[udxi]|[udxi][hl]h?|[hl]h?|[udxi])"$/) {
4345 WARN("SSCANF_TO_KSTRTO",
4346 "Prefer kstrto<type> to single variable sscanf\n" . "$here\n$stat_real\n");
4347 }
4348 }
4349 }
4350
4267# check for new externs in .h files. 4351# check for new externs in .h files.
4268 if ($realfile =~ /\.h$/ && 4352 if ($realfile =~ /\.h$/ &&
4269 $line =~ /^\+\s*(extern\s+)$Type\s*$Ident\s*\(/s) { 4353 $line =~ /^\+\s*(extern\s+)$Type\s*$Ident\s*\(/s) {
@@ -4328,6 +4412,30 @@ sub process {
4328 "Prefer $3(sizeof(*$1)...) over $3($4...)\n" . $herecurr); 4412 "Prefer $3(sizeof(*$1)...) over $3($4...)\n" . $herecurr);
4329 } 4413 }
4330 4414
4415# check for k[mz]alloc with multiplies that could be kmalloc_array/kcalloc
4416 if ($^V && $^V ge 5.10.0 &&
4417 $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*(k[mz]alloc)\s*\(\s*($FuncArg)\s*\*\s*($FuncArg)/) {
4418 my $oldfunc = $3;
4419 my $a1 = $4;
4420 my $a2 = $10;
4421 my $newfunc = "kmalloc_array";
4422 $newfunc = "kcalloc" if ($oldfunc eq "kzalloc");
4423 if ($a1 =~ /^sizeof\s*\S/ || $a2 =~ /^sizeof\s*\S/) {
4424 if (WARN("ALLOC_WITH_MULTIPLY",
4425 "Prefer $newfunc over $oldfunc with multiply\n" . $herecurr) &&
4426 $fix) {
4427 my $r1 = $a1;
4428 my $r2 = $a2;
4429 if ($a1 =~ /^sizeof\s*\S/) {
4430 $r1 = $a2;
4431 $r2 = $a1;
4432 }
4433 $fixed[$linenr - 1] =~ s/\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*(k[mz]alloc)\s*\(\s*($FuncArg)\s*\*\s*($FuncArg)/$1 . ' = ' . "$newfunc(" . trim($r1) . ', ' . trim($r2)/e;
4434
4435 }
4436 }
4437 }
4438
4331# check for krealloc arg reuse 4439# check for krealloc arg reuse
4332 if ($^V && $^V ge 5.10.0 && 4440 if ($^V && $^V ge 5.10.0 &&
4333 $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*\1\s*,/) { 4441 $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*\1\s*,/) {
@@ -4443,10 +4551,10 @@ sub process {
4443 "$1 is obsolete, use k$3 instead\n" . $herecurr); 4551 "$1 is obsolete, use k$3 instead\n" . $herecurr);
4444 } 4552 }
4445 4553
4446# check for __initcall(), use device_initcall() explicitly please 4554# check for __initcall(), use device_initcall() explicitly or more appropriate function please
4447 if ($line =~ /^.\s*__initcall\s*\(/) { 4555 if ($line =~ /^.\s*__initcall\s*\(/) {
4448 WARN("USE_DEVICE_INITCALL", 4556 WARN("USE_DEVICE_INITCALL",
4449 "please use device_initcall() instead of __initcall()\n" . $herecurr); 4557 "please use device_initcall() or more appropriate function instead of __initcall() (see include/linux/init.h)\n" . $herecurr);
4450 } 4558 }
4451 4559
4452# check for various ops structs, ensure they are const. 4560# check for various ops structs, ensure they are const.
diff --git a/scripts/checksyscalls.sh b/scripts/checksyscalls.sh
index fd8fa9aa7c4e..5b3add31f9f1 100755
--- a/scripts/checksyscalls.sh
+++ b/scripts/checksyscalls.sh
@@ -25,7 +25,7 @@ cat << EOF
25#define __IGNORE_rmdir /* unlinkat */ 25#define __IGNORE_rmdir /* unlinkat */
26#define __IGNORE_lchown /* fchownat */ 26#define __IGNORE_lchown /* fchownat */
27#define __IGNORE_access /* faccessat */ 27#define __IGNORE_access /* faccessat */
28#define __IGNORE_rename /* renameat */ 28#define __IGNORE_rename /* renameat2 */
29#define __IGNORE_readlink /* readlinkat */ 29#define __IGNORE_readlink /* readlinkat */
30#define __IGNORE_symlink /* symlinkat */ 30#define __IGNORE_symlink /* symlinkat */
31#define __IGNORE_utimes /* futimesat */ 31#define __IGNORE_utimes /* futimesat */
@@ -37,6 +37,9 @@ cat << EOF
37#define __IGNORE_lstat64 /* fstatat64 */ 37#define __IGNORE_lstat64 /* fstatat64 */
38#endif 38#endif
39 39
40/* Missing flags argument */
41#define __IGNORE_renameat /* renameat2 */
42
40/* CLOEXEC flag */ 43/* CLOEXEC flag */
41#define __IGNORE_pipe /* pipe2 */ 44#define __IGNORE_pipe /* pipe2 */
42#define __IGNORE_dup2 /* dup3 */ 45#define __IGNORE_dup2 /* dup3 */
diff --git a/scripts/conmakehash.c b/scripts/conmakehash.c
index 263a44d57fa9..61bbda54cf13 100644
--- a/scripts/conmakehash.c
+++ b/scripts/conmakehash.c
@@ -104,7 +104,7 @@ int main(int argc, char *argv[])
104 } 104 }
105 } 105 }
106 106
107 /* For now we assume the default font is always 256 characters. */ 107 /* For now we assume the default font is always 256 characters. */
108 fontlen = 256; 108 fontlen = 256;
109 109
110 /* Initialize table */ 110 /* Initialize table */
@@ -236,15 +236,15 @@ int main(int argc, char *argv[])
236 } 236 }
237 237
238 /* Okay, we hit EOF, now output hash table */ 238 /* Okay, we hit EOF, now output hash table */
239 239
240 fclose(ctbl); 240 fclose(ctbl);
241 241
242 242
243 /* Compute total size of Unicode list */ 243 /* Compute total size of Unicode list */
244 nuni = 0; 244 nuni = 0;
245 for ( i = 0 ; i < fontlen ; i++ ) 245 for ( i = 0 ; i < fontlen ; i++ )
246 nuni += unicount[i]; 246 nuni += unicount[i];
247 247
248 printf("\ 248 printf("\
249/*\n\ 249/*\n\
250 * Do not edit this file; it was automatically generated by\n\ 250 * Do not edit this file; it was automatically generated by\n\
@@ -268,9 +268,9 @@ u8 dfont_unicount[%d] = \n\
268 else 268 else
269 printf(", "); 269 printf(", ");
270 } 270 }
271 271
272 printf("\nu16 dfont_unitable[%d] = \n{\n\t", nuni); 272 printf("\nu16 dfont_unitable[%d] = \n{\n\t", nuni);
273 273
274 fp0 = 0; 274 fp0 = 0;
275 nent = 0; 275 nent = 0;
276 for ( i = 0 ; i < nuni ; i++ ) 276 for ( i = 0 ; i < nuni ; i++ )
diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh
new file mode 100755
index 000000000000..515c4c00e957
--- /dev/null
+++ b/scripts/decode_stacktrace.sh
@@ -0,0 +1,126 @@
1#!/bin/bash
2# (c) 2014, Sasha Levin <sasha.levin@oracle.com>
3#set -x
4
5if [[ $# != 2 ]]; then
6 echo "Usage:"
7 echo " $0 [vmlinux] [base path]"
8 exit 1
9fi
10
11vmlinux=$1
12basepath=$2
13declare -A cache
14
15parse_symbol() {
16 # The structure of symbol at this point is:
17 # [name]+[offset]/[total length]
18 #
19 # For example:
20 # do_basic_setup+0x9c/0xbf
21
22
23 # Strip the symbol name so that we could look it up
24 local name=${symbol%+*}
25
26 # Use 'nm vmlinux' to figure out the base address of said symbol.
27 # It's actually faster to call it every time than to load it
28 # all into bash.
29 if [[ "${cache[$name]+isset}" == "isset" ]]; then
30 local base_addr=${cache[$name]}
31 else
32 local base_addr=$(nm "$vmlinux" | grep -i ' t ' | awk "/ $name\$/ {print \$1}" | head -n1)
33 cache["$name"]="$base_addr"
34 fi
35 # Let's start doing the math to get the exact address into the
36 # symbol. First, strip out the symbol total length.
37 local expr=${symbol%/*}
38
39 # Now, replace the symbol name with the base address we found
40 # before.
41 expr=${expr/$name/0x$base_addr}
42
43 # Evaluate it to find the actual address
44 expr=$((expr))
45 local address=$(printf "%x\n" "$expr")
46
47 # Pass it to addr2line to get filename and line number
48 # Could get more than one result
49 if [[ "${cache[$address]+isset}" == "isset" ]]; then
50 local code=${cache[$address]}
51 else
52 local code=$(addr2line -i -e "$vmlinux" "$address")
53 cache[$address]=$code
54 fi
55
56 # addr2line doesn't return a proper error code if it fails, so
57 # we detect it using the value it prints so that we could preserve
58 # the offset/size into the function and bail out
59 if [[ $code == "??:0" ]]; then
60 return
61 fi
62
63 # Strip out the base of the path
64 code=${code//$basepath/""}
65
66 # In the case of inlines, move everything to same line
67 code=${code//$'\n'/' '}
68
69 # Replace old address with pretty line numbers
70 symbol="$name ($code)"
71}
72
73decode_code() {
74 local scripts=`dirname "${BASH_SOURCE[0]}"`
75
76 echo "$1" | $scripts/decodecode
77}
78
79handle_line() {
80 local words
81
82 # Tokenize
83 read -a words <<<"$1"
84
85 # Remove hex numbers. Do it ourselves until it happens in the
86 # kernel
87
88 # We need to know the index of the last element before we
89 # remove elements because arrays are sparse
90 local last=$(( ${#words[@]} - 1 ))
91
92 for i in "${!words[@]}"; do
93 # Remove the address
94 if [[ ${words[$i]} =~ \[\<([^]]+)\>\] ]]; then
95 unset words[$i]
96 fi
97
98 # Format timestamps with tabs
99 if [[ ${words[$i]} == \[ && ${words[$i+1]} == *\] ]]; then
100 unset words[$i]
101 words[$i+1]=$(printf "[%13s\n" "${words[$i+1]}")
102 fi
103 done
104
105 # The symbol is the last element, process it
106 symbol=${words[$last]}
107 unset words[$last]
108 parse_symbol # modifies $symbol
109
110 # Add up the line number to the symbol
111 echo "${words[@]}" "$symbol"
112}
113
114while read line; do
115 # Let's see if we have an address in the line
116 if [[ $line =~ \[\<([^]]+)\>\] ]]; then
117 # Translate address to line numbers
118 handle_line "$line"
119 # Is it a code line?
120 elif [[ $line == *Code:* ]]; then
121 decode_code "$line"
122 else
123 # Nothing special in this line, show it as is
124 echo "$line"
125 fi
126done
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index e57478aa66f7..9c4d2412fb72 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -33,11 +33,11 @@ oldconfig: $(obj)/conf
33 $< --$@ $(Kconfig) 33 $< --$@ $(Kconfig)
34 34
35silentoldconfig: $(obj)/conf 35silentoldconfig: $(obj)/conf
36 $(Q)mkdir -p include/generated 36 $(Q)mkdir -p include/config include/generated
37 $< --$@ $(Kconfig) 37 $< --$@ $(Kconfig)
38 38
39localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf 39localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
40 $(Q)mkdir -p include/generated 40 $(Q)mkdir -p include/config include/generated
41 $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config 41 $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config
42 $(Q)if [ -f .config ]; then \ 42 $(Q)if [ -f .config ]; then \
43 cmp -s .tmp.config .config || \ 43 cmp -s .tmp.config .config || \
diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
index 31331723e810..9cb8522d8d22 100644
--- a/scripts/kconfig/streamline_config.pl
+++ b/scripts/kconfig/streamline_config.pl
@@ -589,7 +589,7 @@ while ($repeat) {
589 589
590 # Now we need to see if we have to check selects; 590 # Now we need to see if we have to check selects;
591 loop_select; 591 loop_select;
592} 592}
593 593
594my %setconfigs; 594my %setconfigs;
595 595
diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
index cfb8440cc0b2..6fdc97ef6023 100755
--- a/scripts/mkcompile_h
+++ b/scripts/mkcompile_h
@@ -68,7 +68,7 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
68 68
69( echo /\* This file is auto generated, version $VERSION \*/ 69( echo /\* This file is auto generated, version $VERSION \*/
70 if [ -n "$CONFIG_FLAGS" ] ; then echo "/* $CONFIG_FLAGS */"; fi 70 if [ -n "$CONFIG_FLAGS" ] ; then echo "/* $CONFIG_FLAGS */"; fi
71 71
72 echo \#define UTS_MACHINE \"$ARCH\" 72 echo \#define UTS_MACHINE \"$ARCH\"
73 73
74 echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\" 74 echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\"
@@ -84,7 +84,7 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
84# recompilations. 84# recompilations.
85# We don't consider the file changed if only the date/time changed. 85# We don't consider the file changed if only the date/time changed.
86# A kernel config change will increase the generation number, thus 86# A kernel config change will increase the generation number, thus
87# causing compile.h to be updated (including date/time) due to the 87# causing compile.h to be updated (including date/time) due to the
88# changed comment in the 88# changed comment in the
89# first line. 89# first line.
90 90
diff --git a/scripts/mkmakefile b/scripts/mkmakefile
index 0cc044260744..84af27bf0f99 100644
--- a/scripts/mkmakefile
+++ b/scripts/mkmakefile
@@ -42,18 +42,11 @@ MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$
42 42
43MAKEFLAGS += --no-print-directory 43MAKEFLAGS += --no-print-directory
44 44
45.PHONY: all \$(MAKECMDGOALS) 45.PHONY: __sub-make \$(MAKECMDGOALS)
46 46
47all := \$(filter-out all Makefile,\$(MAKECMDGOALS)) 47__sub-make:
48 \$(Q)\$(MAKE) \$(MAKEARGS) \$(MAKECMDGOALS)
48 49
49all: 50\$(filter-out __sub-make, \$(MAKECMDGOALS)): __sub-make
50 \$(Q)\$(MAKE) \$(MAKEARGS) \$(all)
51
52Makefile:;
53
54\$(all): all
55 @:
56
57%/: all
58 @: 51 @:
59EOF 52EOF
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index cd766877871e..9d9c5b905b35 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -316,7 +316,7 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod,
316 s->module->name, 316 s->module->name,
317 is_vmlinux(s->module->name) ?"":".ko"); 317 is_vmlinux(s->module->name) ?"":".ko");
318 } else { 318 } else {
319 /* In case Modules.symvers was out of date */ 319 /* In case Module.symvers was out of date */
320 s->module = mod; 320 s->module = mod;
321 } 321 }
322 } 322 }
@@ -2113,8 +2113,10 @@ static void read_dump(const char *fname, unsigned int kernel)
2113 s->preloaded = 1; 2113 s->preloaded = 1;
2114 sym_update_crc(symname, mod, crc, export_no(export)); 2114 sym_update_crc(symname, mod, crc, export_no(export));
2115 } 2115 }
2116 release_file(file, size);
2116 return; 2117 return;
2117fail: 2118fail:
2119 release_file(file, size);
2118 fatal("parse error in symbol dump file\n"); 2120 fatal("parse error in symbol dump file\n");
2119} 2121}
2120 2122
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index c8e04b33b064..b5f08f727868 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -132,7 +132,7 @@ if [ "$ARCH" = "um" ] ; then
132 cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map" 132 cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map"
133 cp $KCONFIG_CONFIG "$tmpdir/usr/share/doc/$packagename/config" 133 cp $KCONFIG_CONFIG "$tmpdir/usr/share/doc/$packagename/config"
134 gzip "$tmpdir/usr/share/doc/$packagename/config" 134 gzip "$tmpdir/usr/share/doc/$packagename/config"
135else 135else
136 cp System.map "$tmpdir/boot/System.map-$version" 136 cp System.map "$tmpdir/boot/System.map-$version"
137 cp $KCONFIG_CONFIG "$tmpdir/boot/config-$version" 137 cp $KCONFIG_CONFIG "$tmpdir/boot/config-$version"
138fi 138fi
diff --git a/scripts/patch-kernel b/scripts/patch-kernel
index d000ea3a41fd..49b4241e814a 100755
--- a/scripts/patch-kernel
+++ b/scripts/patch-kernel
@@ -27,7 +27,7 @@
27# Nick Holloway <Nick.Holloway@alfie.demon.co.uk>, 2nd January 1995. 27# Nick Holloway <Nick.Holloway@alfie.demon.co.uk>, 2nd January 1995.
28# 28#
29# Added support for handling multiple types of compression. What includes 29# Added support for handling multiple types of compression. What includes
30# gzip, bzip, bzip2, zip, compress, and plaintext. 30# gzip, bzip, bzip2, zip, compress, and plaintext.
31# 31#
32# Adam Sulmicki <adam@cfar.umd.edu>, 1st January 1997. 32# Adam Sulmicki <adam@cfar.umd.edu>, 1st January 1997.
33# 33#
@@ -159,7 +159,7 @@ applyPatch () {
159 fi 159 fi
160 # Remove backup files 160 # Remove backup files
161 find $sourcedir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \; 161 find $sourcedir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
162 162
163 return 0; 163 return 0;
164} 164}
165 165
diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
index c0853063fcbc..650ecc83d7d7 100644
--- a/scripts/recordmcount.c
+++ b/scripts/recordmcount.c
@@ -40,6 +40,11 @@
40#define R_METAG_NONE 3 40#define R_METAG_NONE 3
41#endif 41#endif
42 42
43#ifndef EM_AARCH64
44#define EM_AARCH64 183
45#define R_AARCH64_ABS64 257
46#endif
47
43static int fd_map; /* File descriptor for file being modified. */ 48static int fd_map; /* File descriptor for file being modified. */
44static int mmap_failed; /* Boolean flag. */ 49static int mmap_failed; /* Boolean flag. */
45static void *ehdr_curr; /* current ElfXX_Ehdr * for resource cleanup */ 50static void *ehdr_curr; /* current ElfXX_Ehdr * for resource cleanup */
@@ -347,6 +352,8 @@ do_file(char const *const fname)
347 case EM_ARM: reltype = R_ARM_ABS32; 352 case EM_ARM: reltype = R_ARM_ABS32;
348 altmcount = "__gnu_mcount_nc"; 353 altmcount = "__gnu_mcount_nc";
349 break; 354 break;
355 case EM_AARCH64:
356 reltype = R_AARCH64_ABS64; gpfx = '_'; break;
350 case EM_IA_64: reltype = R_IA64_IMM64; gpfx = '_'; break; 357 case EM_IA_64: reltype = R_IA64_IMM64; gpfx = '_'; break;
351 case EM_METAG: reltype = R_METAG_ADDR32; 358 case EM_METAG: reltype = R_METAG_ADDR32;
352 altmcount = "_mcount_wrapper"; 359 altmcount = "_mcount_wrapper";
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index 91280b82da08..397b6b84e8c5 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -279,6 +279,11 @@ if ($arch eq "x86_64") {
279 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_ARM_(CALL|PC24|THM_CALL)" . 279 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_ARM_(CALL|PC24|THM_CALL)" .
280 "\\s+(__gnu_mcount_nc|mcount)\$"; 280 "\\s+(__gnu_mcount_nc|mcount)\$";
281 281
282} elsif ($arch eq "arm64") {
283 $alignment = 3;
284 $section_type = '%progbits';
285 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_AARCH64_CALL26\\s+_mcount\$";
286 $type = ".quad";
282} elsif ($arch eq "ia64") { 287} elsif ($arch eq "ia64") {
283 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$"; 288 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$";
284 $type = "data8"; 289 $type = "data8";
diff --git a/scripts/sortextable.c b/scripts/sortextable.c
index cc49062acdee..1052d4834a44 100644
--- a/scripts/sortextable.c
+++ b/scripts/sortextable.c
@@ -35,6 +35,10 @@
35#define EM_ARCOMPACT 93 35#define EM_ARCOMPACT 93
36#endif 36#endif
37 37
38#ifndef EM_XTENSA
39#define EM_XTENSA 94
40#endif
41
38#ifndef EM_AARCH64 42#ifndef EM_AARCH64
39#define EM_AARCH64 183 43#define EM_AARCH64 183
40#endif 44#endif
@@ -281,6 +285,7 @@ do_file(char const *const fname)
281 case EM_AARCH64: 285 case EM_AARCH64:
282 case EM_MICROBLAZE: 286 case EM_MICROBLAZE:
283 case EM_MIPS: 287 case EM_MIPS:
288 case EM_XTENSA:
284 break; 289 break;
285 } /* end switch */ 290 } /* end switch */
286 291