From 80ffbaa5b1bd98e80e3239a3b8cfda2da433009a Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Mon, 3 Sep 2018 06:09:34 -0600 Subject: kallsyms: reduce size a little on 64-bit Both kallsyms_num_syms and kallsyms_markers[] don't really need to use unsigned long as their (base) types; unsigned int fully suffices. Signed-off-by: Jan Beulich Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index a9186a98a37d..085b6a584fe0 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -405,7 +405,7 @@ static void write_src(void) } output_label("kallsyms_num_syms"); - printf("\tPTR\t%u\n", table_cnt); + printf("\t.long\t%u\n", table_cnt); printf("\n"); /* table of offset markers, that give the offset in the compressed stream @@ -434,7 +434,7 @@ static void write_src(void) output_label("kallsyms_markers"); for (i = 0; i < ((table_cnt + 255) >> 8); i++) - printf("\tPTR\t%d\n", markers[i]); + printf("\t.long\t%u\n", markers[i]); printf("\n"); free(markers); -- cgit v1.2.3 From 36f546a1bdb5d268aec97b2fe4800c91a4f5596a Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 Sep 2018 09:42:24 +0900 Subject: kallsyms: remove left-over Blackfin code These symbols were added by commit 028f042613c3 ("kallsyms: support kernel symbols in Blackfin on-chip memory") for Blackfin. The Blackfin support was removed by commit 4ba66a976072 ("arch: remove blackfin port"). Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 085b6a584fe0..109a1af7e444 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -48,8 +48,6 @@ static unsigned long long relative_base; static struct addr_range text_ranges[] = { { "_stext", "_etext" }, { "_sinittext", "_einittext" }, - { "_stext_l1", "_etext_l1" }, /* Blackfin on-chip L1 inst SRAM */ - { "_stext_l2", "_etext_l2" }, /* Blackfin on-chip L2 SRAM */ }; #define text_range_text (&text_ranges[0]) #define text_range_inittext (&text_ranges[1]) -- cgit v1.2.3 From 487c7c7702ab12cfe6cd0b5a10364eefa1d2128f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 12 Sep 2018 13:52:54 +0900 Subject: kbuild: prefix Makefile.dtbinst path with $(srctree) unconditionally $(srctree) always points to the top of the source tree whether KBUILD_SRC is set or not. Signed-off-by: Masahiro Yamada --- scripts/Kbuild.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index ce53639a864a..46cc43e38866 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -193,7 +193,7 @@ modbuiltin := -f $(srctree)/scripts/Makefile.modbuiltin obj # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj= # Usage: # $(Q)$(MAKE) $(dtbinst)=dir -dtbinst := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.dtbinst obj +dtbinst := -f $(srctree)/scripts/Makefile.dtbinst obj ### # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj= -- cgit v1.2.3 From 0d91bf584fe55349193afa96a2f36d288f65b218 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 12 Sep 2018 15:18:02 +0900 Subject: kbuild: remove old check for CFLAGS use This check has been here for more than a decade since commit 0c53c8e6eb45 ("kbuild: check for wrong use of CFLAGS"). Enough time for migration has passed. Signed-off-by: Masahiro Yamada --- scripts/Makefile.build | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 5a2d1c9578a0..cb0377427f94 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -36,21 +36,11 @@ subdir-ccflags-y := include scripts/Kbuild.include -# For backward compatibility check that these variables do not change -save-cflags := $(CFLAGS) - # The filename Kbuild has precedence over Makefile kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile) include $(kbuild-file) -# If the save-* variables changed error out -ifeq ($(KBUILD_NOPEDANTIC),) - ifneq ("$(save-cflags)","$(CFLAGS)") - $(error CFLAGS was changed in "$(kbuild-file)". Fix it to use ccflags-y) - endif -endif - include scripts/Makefile.lib # Do not include host rules unless needed -- cgit v1.2.3 From 77ec0c20c7e012b5ebb22197c8a329611458cdf8 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 18 Sep 2018 17:45:51 +0900 Subject: kbuild: remove VERSION and PATCHLEVEL from $(objtree)/Makefile Neither VERSION nor PATCHLEVEL is used in any useful way. Signed-off-by: Masahiro Yamada --- Makefile | 3 +-- scripts/mkmakefile | 6 ------ 2 files changed, 1 insertion(+), 8 deletions(-) (limited to 'scripts') diff --git a/Makefile b/Makefile index 2087e797c954..182172c72441 100644 --- a/Makefile +++ b/Makefile @@ -494,8 +494,7 @@ PHONY += outputmakefile outputmakefile: ifneq ($(KBUILD_SRC),) $(Q)ln -fsn $(srctree) source - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ - $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) $(objtree) endif ifeq ($(cc-name),clang) diff --git a/scripts/mkmakefile b/scripts/mkmakefile index e19d6565f245..e21064445085 100755 --- a/scripts/mkmakefile +++ b/scripts/mkmakefile @@ -7,9 +7,6 @@ # Usage # $1 - Kernel src directory # $2 - Output directory -# $3 - version -# $4 - patchlevel - test ! -r $2/Makefile -o -O $2/Makefile || exit 0 # Only overwrite automatically generated Makefiles @@ -25,9 +22,6 @@ fi cat << EOF > $2/Makefile # Automatically generated by $0: don't edit -VERSION = $3 -PATCHLEVEL = $4 - lastword = \$(word \$(words \$(1)),\$(1)) makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST))) -- cgit v1.2.3 From 74bc0c09b2da005f028510b1ad21140c9d6c9b44 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 18 Sep 2018 17:45:52 +0900 Subject: kbuild: remove user ID check in scripts/mkmakefile This line was added by commit fd5f0cd6b0ce ("kbuild: Do not overwrite makefile as anohter user"). Its commit description says the intention was to prevent $(objtree)/Makefile from being owned by root when e.g. running 'make install'. However, as commit 19514fc665ff ("arm, kbuild: make "make install" not depend on vmlinux") stated, installation targets must not modify the source tree in the first place. If they do, we are already screwed up. We must fix the root cause. Installation targets should just copy files verbatim, hence we never expect $(objtree)/Makefile is touched by root. The user ID check in scripts/mkmakefile is unneeded. Signed-off-by: Masahiro Yamada --- scripts/mkmakefile | 1 - 1 file changed, 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mkmakefile b/scripts/mkmakefile index e21064445085..24354284d4ad 100755 --- a/scripts/mkmakefile +++ b/scripts/mkmakefile @@ -8,7 +8,6 @@ # $1 - Kernel src directory # $2 - Output directory -test ! -r $2/Makefile -o -O $2/Makefile || exit 0 # Only overwrite automatically generated Makefiles # (so we do not overwrite kernel Makefile) if test -e $2/Makefile && ! grep -q Automatically $2/Makefile -- cgit v1.2.3 From 4fd61277f66278d7ce4a77accb662d00e800cce7 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 18 Sep 2018 17:45:53 +0900 Subject: kbuild: do not pass $(objtree) to scripts/mkmakefile Since $(objtree) is always '.', it is not useful to pass it to scripts/mkmakefile. I assume nobody wants to run this script directly. Signed-off-by: Masahiro Yamada --- Makefile | 2 +- scripts/mkmakefile | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/Makefile b/Makefile index 182172c72441..d2de86c2eba3 100644 --- a/Makefile +++ b/Makefile @@ -494,7 +494,7 @@ PHONY += outputmakefile outputmakefile: ifneq ($(KBUILD_SRC),) $(Q)ln -fsn $(srctree) source - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) $(objtree) + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) endif ifeq ($(cc-name),clang) diff --git a/scripts/mkmakefile b/scripts/mkmakefile index 24354284d4ad..85995f90e5c8 100755 --- a/scripts/mkmakefile +++ b/scripts/mkmakefile @@ -6,19 +6,18 @@ # Usage # $1 - Kernel src directory -# $2 - Output directory # Only overwrite automatically generated Makefiles # (so we do not overwrite kernel Makefile) -if test -e $2/Makefile && ! grep -q Automatically $2/Makefile +if test -e Makefile && ! grep -q Automatically Makefile then exit 0 fi if [ "${quiet}" != "silent_" ]; then - echo " GEN $2/Makefile" + echo " GEN Makefile" fi -cat << EOF > $2/Makefile +cat << EOF > Makefile # Automatically generated by $0: don't edit lastword = \$(word \$(words \$(1)),\$(1)) -- cgit v1.2.3 From 80d0dda3a4e5ba00ae6a45fa840096dc9633aad7 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 18 Sep 2018 17:45:54 +0900 Subject: kbuild: simplify command line creation in scripts/mkmakefile Assuming we never invoke the generated Makefile from outside of the $(objtree) directory, $(CURDIR) points to the absolute path of $(objtree). BTW, 'lastword' is natively supported by GNU Make 3.81+, which is the current requirement for building the kernel. Signed-off-by: Masahiro Yamada --- scripts/mkmakefile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/mkmakefile b/scripts/mkmakefile index 85995f90e5c8..412f13fdff52 100755 --- a/scripts/mkmakefile +++ b/scripts/mkmakefile @@ -20,9 +20,6 @@ fi cat << EOF > Makefile # Automatically generated by $0: don't edit -lastword = \$(word \$(words \$(1)),\$(1)) -makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST))) - ifeq ("\$(origin V)", "command line") VERBOSE := \$(V) endif @@ -30,15 +27,12 @@ ifneq (\$(VERBOSE),1) Q := @ endif -MAKEARGS := -C $1 -MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir)) - MAKEFLAGS += --no-print-directory .PHONY: __sub-make \$(MAKECMDGOALS) __sub-make: - \$(Q)\$(MAKE) \$(MAKEARGS) \$(MAKECMDGOALS) + \$(Q)\$(MAKE) -C $1 O=\$(CURDIR) \$(MAKECMDGOALS) \$(filter-out __sub-make, \$(MAKECMDGOALS)): __sub-make @: -- cgit v1.2.3 From 153e04b373dd5a4fdb841a727e47c40b1ad10ffc Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 28 Sep 2018 15:21:55 +0900 Subject: modpost: remove leftover symbol prefix handling for module device table Blackfin and metag were the only architectures that prefix symbols with an underscore. They were removed by commit 4ba66a976072 ("arch: remove blackfin port"), commit bb6fb6dfcc17 ("metag: Remove arch/metag/"), respectively. It is no longer necessary to handle part of module device table symbols. Signed-off-by: Masahiro Yamada --- scripts/mod/file2alias.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 7be43697ff84..ba4ebc4b346e 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1415,11 +1415,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT) return; - /* All our symbols are of form __mod____device_table. */ - name = strstr(symname, "__mod_"); - if (!name) + /* All our symbols are of form __mod____device_table. */ + if (strncmp(symname, "__mod_", strlen("__mod_"))) return; - name += strlen("__mod_"); + name = symname + strlen("__mod_"); namelen = strlen(name); if (namelen < strlen("_device_table")) return; -- cgit v1.2.3 From 69ea912fda74a673d330d23595385e5b73e3a2b9 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 4 Oct 2018 13:25:19 +0900 Subject: kbuild: remove unneeded link_multi_deps Since commit c8589d1e9e01 ("kbuild: handle multi-objs dependency appropriately"), $^ really represents all the prerequisite of the composite object being built. Hence, $(filter %.o,$^) contains all the objects to link together, which is much simpler than link_multi_deps calculation. Please note $(filter-out FORCE,$^) does not work here. When a single object module is turned into a multi object module, $^ will contain header files that were previously included for building the single object, and recorded in the .*.cmd file. To filter out such headers, $(filter %.o,$^) should be used here. Signed-off-by: Masahiro Yamada --- scripts/Makefile.build | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index cb0377427f94..f21b48d4a8f2 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -485,28 +485,12 @@ targets += $(obj)/lib-ksyms.o endif -# -# Rule to link composite objects -# -# Composite objects are specified in kbuild makefile as follows: -# -objs := -# or -# -y := -# or -# -m := -# The -m syntax only works if is a module -link_multi_deps = \ -$(filter $(addprefix $(obj)/, \ -$($(subst $(obj)/,,$(@:.o=-objs))) \ -$($(subst $(obj)/,,$(@:.o=-y))) \ -$($(subst $(obj)/,,$(@:.o=-m)))), $^) - quiet_cmd_link_multi-m = LD [M] $@ -cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis) +cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^) $(cmd_secanalysis) $(multi-used-m): FORCE $(call if_changed,link_multi-m) - @{ echo $(@:.o=.ko); echo $(link_multi_deps); \ + @{ echo $(@:.o=.ko); echo $(filter %.o,$^); \ $(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod) $(call multi_depend, $(multi-used-m), .o, -objs -y -m) -- cgit v1.2.3 From 7d0ea2524202db5cb3f5bde9c0cdd6dea61bc0e3 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 10 Oct 2018 00:05:39 +0900 Subject: kbuild: use 'else ifeq' for checksrc to improve readability 'ifeq ... else ifeq ... endif' notation is supported by GNU Make 3.81 or later, which is the requirement for building the kernel since commit 37d69ee30808 ("docs: bump minimal GNU Make version to 3.81"). Use it to improve the readability. Signed-off-by: Masahiro Yamada --- scripts/Makefile.build | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index f21b48d4a8f2..7d884d8f37ff 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -73,14 +73,12 @@ __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ @: # Linus' kernel sanity checking tool -ifneq ($(KBUILD_CHECKSRC),0) - ifeq ($(KBUILD_CHECKSRC),2) - quiet_cmd_force_checksrc = CHECK $< - cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; - else - quiet_cmd_checksrc = CHECK $< - cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; - endif +ifeq ($(KBUILD_CHECKSRC),1) + quiet_cmd_checksrc = CHECK $< + cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; +else ifeq ($(KBUILD_CHECKSRC),2) + quiet_cmd_force_checksrc = CHECK $< + cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; endif ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),) -- cgit v1.2.3 From 9e1e8194332fa4c453bcbad434b5da17c1c7e4c5 Mon Sep 17 00:00:00 2001 From: Leonardo Bras Date: Wed, 24 Oct 2018 01:03:51 -0300 Subject: ASN.1: Remove unnecessary shadowed local variable Remove an unnecessary shadowed local variable (start). It was used only once, with the same value it was started before the if block. Signed-off-by: Leonardo Bras Signed-off-by: Masahiro Yamada --- scripts/asn1_compiler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c index c146020fc783..1b28787028d3 100644 --- a/scripts/asn1_compiler.c +++ b/scripts/asn1_compiler.c @@ -413,7 +413,7 @@ static void tokenise(char *buffer, char *end) /* Handle string tokens */ if (isalpha(*p)) { - const char **dir, *start = p; + const char **dir; /* Can be a directive, type name or element * name. Find the end of the name. -- cgit v1.2.3 From c2b1a9226fe7c1cee8f0ae42496f3eb282d73ebb Mon Sep 17 00:00:00 2001 From: Leonardo Bras Date: Wed, 24 Oct 2018 01:03:52 -0300 Subject: modpost: Create macro to avoid variable shadowing Create DEF_FIELD_ADDR_VAR as a more generic version of the DEF_FIELD_ADD macro, allowing usage of a variable name other than the struct element name. Also, sets DEF_FIELD_ADDR as a specific usage of DEF_FILD_ADDR_VAR in which the var name is the same as the struct element name. Then, makes use of DEF_FIELD_ADDR_VAR to create a variable of another name, in order to avoid variable shadowing. Signed-off-by: Leonardo Bras Signed-off-by: Masahiro Yamada --- scripts/mod/file2alias.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index ba4ebc4b346e..28a61665bb9c 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -95,12 +95,20 @@ extern struct devtable *__start___devtable[], *__stop___devtable[]; */ #define DEF_FIELD(m, devid, f) \ typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f)) + +/* Define a variable v that holds the address of field f of struct devid + * based at address m. Due to the way typeof works, for a field of type + * T[N] the variable has type T(*)[N], _not_ T*. + */ +#define DEF_FIELD_ADDR_VAR(m, devid, f, v) \ + typeof(((struct devid *)0)->f) *v = ((m) + OFF_##devid##_##f) + /* Define a variable f that holds the address of field f of struct devid * based at address m. Due to the way typeof works, for a field of type * T[N] the variable has type T(*)[N], _not_ T*. */ #define DEF_FIELD_ADDR(m, devid, f) \ - typeof(((struct devid *)0)->f) *f = ((m) + OFF_##devid##_##f) + DEF_FIELD_ADDR_VAR(m, devid, f, f) /* Add a table entry. We test function type matches while we're here. */ #define ADD_TO_DEVTABLE(device_id, type, function) \ @@ -644,7 +652,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size, for (i = 0; i < count; i++) { unsigned int j; - DEF_FIELD_ADDR(symval + i*id_size, pnp_card_device_id, devs); + DEF_FIELD_ADDR(symval + i * id_size, pnp_card_device_id, devs); for (j = 0; j < PNP_MAX_DEVICES; j++) { const char *id = (char *)(*devs)[j].id; @@ -656,10 +664,13 @@ static void do_pnp_card_entries(void *symval, unsigned long size, /* find duplicate, already added value */ for (i2 = 0; i2 < i && !dup; i2++) { - DEF_FIELD_ADDR(symval + i2*id_size, pnp_card_device_id, devs); + DEF_FIELD_ADDR_VAR(symval + i2 * id_size, + pnp_card_device_id, + devs, devs_dup); for (j2 = 0; j2 < PNP_MAX_DEVICES; j2++) { - const char *id2 = (char *)(*devs)[j2].id; + const char *id2 = + (char *)(*devs_dup)[j2].id; if (!id2[0]) break; -- cgit v1.2.3