summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2019-01-16 19:10:04 -0500
committerMasahiro Yamada <yamada.masahiro@socionext.com>2019-01-27 19:11:17 -0500
commitd151e9719f184f00d0bb2af864d0aef9beaee7ab (patch)
treeba05bfd964071fee52e3d8cbfcad58165c74cb8f
parentdee9495303f2c6d63a20c43a26420765909898eb (diff)
kbuild: merge KBUILD_VMLINUX_{INIT,MAIN} into KBUILD_VMLINUX_OBJS
The top Makefile does not need to export KBUILD_VMLINUX_INIT and KBUILD_VMLINUX_MAIN separately. Put every built-in.a into KBUILD_VMLINUX_OBJS. The order of $(head-y), $(init-y), $(core-y), ... is still retained. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
-rw-r--r--Documentation/kbuild/kbuild.txt15
-rw-r--r--Makefile6
-rwxr-xr-xscripts/link-vmlinux.sh28
3 files changed, 18 insertions, 31 deletions
diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt
index c9e3d93e7a89..8a3830b39c7d 100644
--- a/Documentation/kbuild/kbuild.txt
+++ b/Documentation/kbuild/kbuild.txt
@@ -232,17 +232,12 @@ KBUILD_LDS
232-------------------------------------------------- 232--------------------------------------------------
233The linker script with full path. Assigned by the top-level Makefile. 233The linker script with full path. Assigned by the top-level Makefile.
234 234
235KBUILD_VMLINUX_INIT 235KBUILD_VMLINUX_OBJS
236-------------------------------------------------- 236--------------------------------------------------
237All object files for the init (first) part of vmlinux. 237All object files for vmlinux. They are linked to vmlinux in the same
238Files specified with KBUILD_VMLINUX_INIT are linked first. 238order as listed in KBUILD_VMLINUX_OBJS.
239
240KBUILD_VMLINUX_MAIN
241--------------------------------------------------
242All object files for the main part of vmlinux.
243 239
244KBUILD_VMLINUX_LIBS 240KBUILD_VMLINUX_LIBS
245-------------------------------------------------- 241--------------------------------------------------
246All .a "lib" files for vmlinux. 242All .a "lib" files for vmlinux. KBUILD_VMLINUX_OBJS and KBUILD_VMLINUX_LIBS
247KBUILD_VMLINUX_INIT, KBUILD_VMLINUX_MAIN, and KBUILD_VMLINUX_LIBS together 243together specify all the object files used to link vmlinux.
248specify all the object files used to link vmlinux.
diff --git a/Makefile b/Makefile
index 141653226f3c..2b05cd59ff54 100644
--- a/Makefile
+++ b/Makefile
@@ -976,15 +976,15 @@ libs-y2 := $(patsubst %/, %/built-in.a, $(filter-out %.a, $(libs-y)))
976virt-y := $(patsubst %/, %/built-in.a, $(virt-y)) 976virt-y := $(patsubst %/, %/built-in.a, $(virt-y))
977 977
978# Externally visible symbols (used by link-vmlinux.sh) 978# Externally visible symbols (used by link-vmlinux.sh)
979export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) 979export KBUILD_VMLINUX_OBJS := $(head-y) $(init-y) $(core-y) $(libs-y2) \
980export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y2) $(drivers-y) $(net-y) $(virt-y) 980 $(drivers-y) $(net-y) $(virt-y)
981export KBUILD_VMLINUX_LIBS := $(libs-y1) 981export KBUILD_VMLINUX_LIBS := $(libs-y1)
982export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds 982export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
983export LDFLAGS_vmlinux 983export LDFLAGS_vmlinux
984# used by scripts/package/Makefile 984# used by scripts/package/Makefile
985export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools) 985export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools)
986 986
987vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS) 987vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
988 988
989# Recurse until adjust_autoksyms.sh is satisfied 989# Recurse until adjust_autoksyms.sh is satisfied
990PHONY += autoksyms_recursive 990PHONY += autoksyms_recursive
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index 4788def71358..bc7f1fc1f55b 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -3,22 +3,17 @@
3# 3#
4# link vmlinux 4# link vmlinux
5# 5#
6# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_INIT) and 6# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_OBJS) and
7# $(KBUILD_VMLINUX_MAIN) and $(KBUILD_VMLINUX_LIBS). Most are built-in.a files 7# $(KBUILD_VMLINUX_LIBS). Most are built-in.a files from top-level directories
8# from top-level directories in the kernel tree, others are specified in 8# in the kernel tree, others are specified in arch/$(ARCH)/Makefile.
9# arch/$(ARCH)/Makefile. Ordering when linking is important, and 9# $(KBUILD_VMLINUX_LIBS) are archives which are linked conditionally
10# $(KBUILD_VMLINUX_INIT) must be first. $(KBUILD_VMLINUX_LIBS) are archives 10# (not within --whole-archive), and do not require symbol indexes added.
11# which are linked conditionally (not within --whole-archive), and do not
12# require symbol indexes added.
13# 11#
14# vmlinux 12# vmlinux
15# ^ 13# ^
16# | 14# |
17# +-< $(KBUILD_VMLINUX_INIT) 15# +--< $(KBUILD_VMLINUX_OBJS)
18# | +--< init/version.o + more 16# | +--< init/built-in.a drivers/built-in.a mm/built-in.a + more
19# |
20# +--< $(KBUILD_VMLINUX_MAIN)
21# | +--< drivers/built-in.a mm/built-in.a + more
22# | 17# |
23# +--< $(KBUILD_VMLINUX_LIBS) 18# +--< $(KBUILD_VMLINUX_LIBS)
24# | +--< lib/lib.a + more 19# | +--< lib/lib.a + more
@@ -51,8 +46,7 @@ modpost_link()
51 local objects 46 local objects
52 47
53 objects="--whole-archive \ 48 objects="--whole-archive \
54 ${KBUILD_VMLINUX_INIT} \ 49 ${KBUILD_VMLINUX_OBJS} \
55 ${KBUILD_VMLINUX_MAIN} \
56 --no-whole-archive \ 50 --no-whole-archive \
57 --start-group \ 51 --start-group \
58 ${KBUILD_VMLINUX_LIBS} \ 52 ${KBUILD_VMLINUX_LIBS} \
@@ -71,8 +65,7 @@ vmlinux_link()
71 65
72 if [ "${SRCARCH}" != "um" ]; then 66 if [ "${SRCARCH}" != "um" ]; then
73 objects="--whole-archive \ 67 objects="--whole-archive \
74 ${KBUILD_VMLINUX_INIT} \ 68 ${KBUILD_VMLINUX_OBJS} \
75 ${KBUILD_VMLINUX_MAIN} \
76 --no-whole-archive \ 69 --no-whole-archive \
77 --start-group \ 70 --start-group \
78 ${KBUILD_VMLINUX_LIBS} \ 71 ${KBUILD_VMLINUX_LIBS} \
@@ -83,8 +76,7 @@ vmlinux_link()
83 -T ${lds} ${objects} 76 -T ${lds} ${objects}
84 else 77 else
85 objects="-Wl,--whole-archive \ 78 objects="-Wl,--whole-archive \
86 ${KBUILD_VMLINUX_INIT} \ 79 ${KBUILD_VMLINUX_OBJS} \
87 ${KBUILD_VMLINUX_MAIN} \
88 -Wl,--no-whole-archive \ 80 -Wl,--no-whole-archive \
89 -Wl,--start-group \ 81 -Wl,--start-group \
90 ${KBUILD_VMLINUX_LIBS} \ 82 ${KBUILD_VMLINUX_LIBS} \