summaryrefslogtreecommitdiff
path: root/scripts/Makefile.build
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2022-04-07 00:30:20 +0900
committerMasahiro Yamada <masahiroy@kernel.org>2022-05-08 03:16:59 +0900
commit9413e7640564fe70b24ea1a9ff3fb92c5bb52fcb (patch)
treeefb106529373b6c24577df146c8e3afc90fe0e8e /scripts/Makefile.build
parentb3591e061919c837c14680c1ceff8f009ed0afb4 (diff)
downloadlinux-rpi-9413e7640564fe70b24ea1a9ff3fb92c5bb52fcb.tar.gz
linux-rpi-9413e7640564fe70b24ea1a9ff3fb92c5bb52fcb.tar.bz2
linux-rpi-9413e7640564fe70b24ea1a9ff3fb92c5bb52fcb.zip
kbuild: split the second line of *.mod into *.usyms
The *.mod files have two lines; the first line lists the member objects of the module, and the second line, if CONFIG_TRIM_UNUSED_KSYMS=y, lists the undefined symbols. Currently, we generate *.mod after constructing composite modules, otherwise, we cannot compute the second line. No prerequisite is required to print the first line. They are orthogonal. Splitting them into separate commands will ease further cleanups. This commit splits the list of undefined symbols out to *.usyms files. Previously, the list of undefined symbols ended up with a very long line, but now it has one symbol per line. Use sed like we did before commit 7d32358be8ac ("kbuild: avoid split lines in .mod files"). Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
Diffstat (limited to 'scripts/Makefile.build')
-rw-r--r--scripts/Makefile.build17
1 files changed, 9 insertions, 8 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 857329844789..6ae92d119dfa 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -85,7 +85,8 @@ ifdef need-builtin
targets-for-builtin += $(obj)/built-in.a
endif
-targets-for-modules := $(patsubst %.o, %.mod, $(filter %.o, $(obj-m)))
+targets-for-modules := $(foreach x, mod $(if $(CONFIG_TRIM_UNUSED_KSYMS), usyms), \
+ $(patsubst %.o, %.$x, $(filter %.o, $(obj-m))))
ifneq ($(CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT),)
targets-for-modules += $(patsubst %.o, %.prelink.o, $(filter %.o, $(obj-m)))
@@ -256,9 +257,6 @@ endif
ifdef CONFIG_TRIM_UNUSED_KSYMS
cmd_gen_ksymdeps = \
$(CONFIG_SHELL) $(srctree)/scripts/gen_ksymdeps.sh $@ >> $(dot-target).cmd
-
-# List module undefined symbols
-undefined_syms = $(NM) $< | $(AWK) '$$1 == "U" { printf("%s%s", x++ ? " " : "", $$2) }';
endif
define rule_cc_o_c
@@ -305,14 +303,17 @@ $(obj)/%.prelink.o: $(obj)/%.o FORCE
$(call if_changed,cc_prelink_modules)
endif
-cmd_mod = { \
- echo $(addprefix $(obj)/, $(call real-search, $*.o, .o, -objs -y -m)); \
- $(undefined_syms) echo; \
- } > $@
+cmd_mod = echo $(addprefix $(obj)/, $(call real-search, $*.o, .o, -objs -y -m)) > $@
$(obj)/%.mod: $(obj)/%$(mod-prelink-ext).o FORCE
$(call if_changed,mod)
+# List module undefined symbols
+cmd_undefined_syms = $(NM) $< | sed -n 's/^ *U //p' > $@
+
+$(obj)/%.usyms: $(obj)/%$(mod-prelink-ext).o FORCE
+ $(call if_changed,undefined_syms)
+
quiet_cmd_cc_lst_c = MKLST $@
cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \
$(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \