Skip to content

Commit d151e97

Browse files
committed
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>
1 parent dee9495 commit d151e97

File tree

3 files changed

+18
-31
lines changed

3 files changed

+18
-31
lines changed

Documentation/kbuild/kbuild.txt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,12 @@ KBUILD_LDS
232232
--------------------------------------------------
233233
The linker script with full path. Assigned by the top-level Makefile.
234234

235-
KBUILD_VMLINUX_INIT
235+
KBUILD_VMLINUX_OBJS
236236
--------------------------------------------------
237-
All object files for the init (first) part of vmlinux.
238-
Files specified with KBUILD_VMLINUX_INIT are linked first.
239-
240-
KBUILD_VMLINUX_MAIN
241-
--------------------------------------------------
242-
All object files for the main part of vmlinux.
237+
All object files for vmlinux. They are linked to vmlinux in the same
238+
order as listed in KBUILD_VMLINUX_OBJS.
243239

244240
KBUILD_VMLINUX_LIBS
245241
--------------------------------------------------
246-
All .a "lib" files for vmlinux.
247-
KBUILD_VMLINUX_INIT, KBUILD_VMLINUX_MAIN, and KBUILD_VMLINUX_LIBS together
248-
specify all the object files used to link vmlinux.
242+
All .a "lib" files for vmlinux. KBUILD_VMLINUX_OBJS and KBUILD_VMLINUX_LIBS
243+
together specify all the object files used to link vmlinux.

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -976,15 +976,15 @@ libs-y2 := $(patsubst %/, %/built-in.a, $(filter-out %.a, $(libs-y)))
976976
virt-y := $(patsubst %/, %/built-in.a, $(virt-y))
977977

978978
# Externally visible symbols (used by link-vmlinux.sh)
979-
export KBUILD_VMLINUX_INIT := $(head-y) $(init-y)
980-
export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y2) $(drivers-y) $(net-y) $(virt-y)
979+
export KBUILD_VMLINUX_OBJS := $(head-y) $(init-y) $(core-y) $(libs-y2) \
980+
$(drivers-y) $(net-y) $(virt-y)
981981
export KBUILD_VMLINUX_LIBS := $(libs-y1)
982982
export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
983983
export LDFLAGS_vmlinux
984984
# used by scripts/package/Makefile
985985
export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools)
986986

987-
vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS)
987+
vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
988988

989989
# Recurse until adjust_autoksyms.sh is satisfied
990990
PHONY += autoksyms_recursive

scripts/link-vmlinux.sh

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,17 @@
33
#
44
# link vmlinux
55
#
6-
# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_INIT) and
7-
# $(KBUILD_VMLINUX_MAIN) and $(KBUILD_VMLINUX_LIBS). Most are built-in.a files
8-
# from top-level directories in the kernel tree, others are specified in
9-
# arch/$(ARCH)/Makefile. Ordering when linking is important, and
10-
# $(KBUILD_VMLINUX_INIT) must be first. $(KBUILD_VMLINUX_LIBS) are archives
11-
# which are linked conditionally (not within --whole-archive), and do not
12-
# require symbol indexes added.
6+
# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_OBJS) and
7+
# $(KBUILD_VMLINUX_LIBS). Most are built-in.a files from top-level directories
8+
# in the kernel tree, others are specified in arch/$(ARCH)/Makefile.
9+
# $(KBUILD_VMLINUX_LIBS) are archives which are linked conditionally
10+
# (not within --whole-archive), and do not require symbol indexes added.
1311
#
1412
# vmlinux
1513
# ^
1614
# |
17-
# +-< $(KBUILD_VMLINUX_INIT)
18-
# | +--< init/version.o + more
19-
# |
20-
# +--< $(KBUILD_VMLINUX_MAIN)
21-
# | +--< drivers/built-in.a mm/built-in.a + more
15+
# +--< $(KBUILD_VMLINUX_OBJS)
16+
# | +--< init/built-in.a drivers/built-in.a mm/built-in.a + more
2217
# |
2318
# +--< $(KBUILD_VMLINUX_LIBS)
2419
# | +--< lib/lib.a + more
@@ -51,8 +46,7 @@ modpost_link()
5146
local objects
5247

5348
objects="--whole-archive \
54-
${KBUILD_VMLINUX_INIT} \
55-
${KBUILD_VMLINUX_MAIN} \
49+
${KBUILD_VMLINUX_OBJS} \
5650
--no-whole-archive \
5751
--start-group \
5852
${KBUILD_VMLINUX_LIBS} \
@@ -71,8 +65,7 @@ vmlinux_link()
7165

7266
if [ "${SRCARCH}" != "um" ]; then
7367
objects="--whole-archive \
74-
${KBUILD_VMLINUX_INIT} \
75-
${KBUILD_VMLINUX_MAIN} \
68+
${KBUILD_VMLINUX_OBJS} \
7669
--no-whole-archive \
7770
--start-group \
7871
${KBUILD_VMLINUX_LIBS} \
@@ -83,8 +76,7 @@ vmlinux_link()
8376
-T ${lds} ${objects}
8477
else
8578
objects="-Wl,--whole-archive \
86-
${KBUILD_VMLINUX_INIT} \
87-
${KBUILD_VMLINUX_MAIN} \
79+
${KBUILD_VMLINUX_OBJS} \
8880
-Wl,--no-whole-archive \
8981
-Wl,--start-group \
9082
${KBUILD_VMLINUX_LIBS} \

0 commit comments

Comments
 (0)