kbuild: remove incremental linking option
This removes the old `ld -r` incremental link option, which has not been selected by any architecture since June 2017. Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
This commit is contained in:
parent
1fe7d2bb24
commit
6358d6e8b9
@ -153,8 +153,14 @@ more details, with real examples.
|
|||||||
configuration.
|
configuration.
|
||||||
|
|
||||||
Kbuild compiles all the $(obj-y) files. It then calls
|
Kbuild compiles all the $(obj-y) files. It then calls
|
||||||
"$(LD) -r" to merge these files into one built-in.o file.
|
"$(AR) rcSTP" to merge these files into one built-in.o file.
|
||||||
built-in.o is later linked into vmlinux by the parent Makefile.
|
This is a thin archive without a symbol table, which makes it
|
||||||
|
unsuitable as a linker input.
|
||||||
|
|
||||||
|
The scripts/link-vmlinux.sh script later makes an aggregate
|
||||||
|
built-in.o with "${AR} rcsTP", which creates the thin archive
|
||||||
|
with a symbol table and an index, making it a valid input for
|
||||||
|
the final vmlinux link passes.
|
||||||
|
|
||||||
The order of files in $(obj-y) is significant. Duplicates in
|
The order of files in $(obj-y) is significant. Duplicates in
|
||||||
the lists are allowed: the first instance will be linked into
|
the lists are allowed: the first instance will be linked into
|
||||||
|
@ -596,12 +596,6 @@ config CC_STACKPROTECTOR_AUTO
|
|||||||
|
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
config THIN_ARCHIVES
|
|
||||||
def_bool y
|
|
||||||
help
|
|
||||||
Select this if the architecture wants to use thin archives
|
|
||||||
instead of ld -r to create the built-in.o files.
|
|
||||||
|
|
||||||
config LD_DEAD_CODE_DATA_ELIMINATION
|
config LD_DEAD_CODE_DATA_ELIMINATION
|
||||||
bool
|
bool
|
||||||
help
|
help
|
||||||
|
@ -458,15 +458,13 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ;
|
|||||||
#
|
#
|
||||||
ifdef builtin-target
|
ifdef builtin-target
|
||||||
|
|
||||||
ifdef CONFIG_THIN_ARCHIVES
|
# built-in.o archives are made with no symbol table or index which
|
||||||
cmd_make_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS)
|
# makes them small and fast, but unable to be used by the linker.
|
||||||
cmd_make_empty_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS)
|
# scripts/link-vmlinux.sh builds an aggregate built-in.o with a symbol
|
||||||
quiet_cmd_link_o_target = AR $@
|
# table and index.
|
||||||
else
|
cmd_make_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS)
|
||||||
cmd_make_builtin = $(LD) $(ld_flags) -r -o
|
cmd_make_empty_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS)
|
||||||
cmd_make_empty_builtin = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS)
|
quiet_cmd_link_o_target = AR $@
|
||||||
quiet_cmd_link_o_target = LD $@
|
|
||||||
endif
|
|
||||||
|
|
||||||
# If the list of objects to link is empty, just create an empty built-in.o
|
# If the list of objects to link is empty, just create an empty built-in.o
|
||||||
cmd_link_o_target = $(if $(strip $(obj-y)),\
|
cmd_link_o_target = $(if $(strip $(obj-y)),\
|
||||||
@ -499,11 +497,8 @@ $(modorder-target): $(subdir-ym) FORCE
|
|||||||
ifdef lib-target
|
ifdef lib-target
|
||||||
quiet_cmd_link_l_target = AR $@
|
quiet_cmd_link_l_target = AR $@
|
||||||
|
|
||||||
ifdef CONFIG_THIN_ARCHIVES
|
# lib target archives do get a symbol table and index
|
||||||
cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(lib-y)
|
cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(lib-y)
|
||||||
else
|
|
||||||
cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y)
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(lib-target): $(lib-y) FORCE
|
$(lib-target): $(lib-y) FORCE
|
||||||
$(call if_changed,link_l_target)
|
$(call if_changed,link_l_target)
|
||||||
@ -551,13 +546,8 @@ $($(subst $(obj)/,,$(@:.o=-m)))), $^)
|
|||||||
|
|
||||||
cmd_link_multi-link = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
|
cmd_link_multi-link = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
|
||||||
|
|
||||||
ifdef CONFIG_THIN_ARCHIVES
|
quiet_cmd_link_multi-y = AR $@
|
||||||
quiet_cmd_link_multi-y = AR $@
|
cmd_link_multi-y = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(link_multi_deps)
|
||||||
cmd_link_multi-y = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(link_multi_deps)
|
|
||||||
else
|
|
||||||
quiet_cmd_link_multi-y = LD $@
|
|
||||||
cmd_link_multi-y = $(cmd_link_multi-link)
|
|
||||||
endif
|
|
||||||
|
|
||||||
quiet_cmd_link_multi-m = LD [M] $@
|
quiet_cmd_link_multi-m = LD [M] $@
|
||||||
cmd_link_multi-m = $(cmd_link_multi-link)
|
cmd_link_multi-m = $(cmd_link_multi-link)
|
||||||
|
@ -55,13 +55,11 @@ info()
|
|||||||
#
|
#
|
||||||
archive_builtin()
|
archive_builtin()
|
||||||
{
|
{
|
||||||
if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then
|
info AR built-in.o
|
||||||
info AR built-in.o
|
rm -f built-in.o;
|
||||||
rm -f built-in.o;
|
${AR} rcsTP${KBUILD_ARFLAGS} built-in.o \
|
||||||
${AR} rcsTP${KBUILD_ARFLAGS} built-in.o \
|
${KBUILD_VMLINUX_INIT} \
|
||||||
${KBUILD_VMLINUX_INIT} \
|
${KBUILD_VMLINUX_MAIN}
|
||||||
${KBUILD_VMLINUX_MAIN}
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Link of vmlinux.o used for section mismatch analysis
|
# Link of vmlinux.o used for section mismatch analysis
|
||||||
@ -70,20 +68,13 @@ modpost_link()
|
|||||||
{
|
{
|
||||||
local objects
|
local objects
|
||||||
|
|
||||||
if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then
|
objects="--whole-archive \
|
||||||
objects="--whole-archive \
|
built-in.o \
|
||||||
built-in.o \
|
--no-whole-archive \
|
||||||
--no-whole-archive \
|
--start-group \
|
||||||
--start-group \
|
${KBUILD_VMLINUX_LIBS} \
|
||||||
${KBUILD_VMLINUX_LIBS} \
|
--end-group"
|
||||||
--end-group"
|
|
||||||
else
|
|
||||||
objects="${KBUILD_VMLINUX_INIT} \
|
|
||||||
--start-group \
|
|
||||||
${KBUILD_VMLINUX_MAIN} \
|
|
||||||
${KBUILD_VMLINUX_LIBS} \
|
|
||||||
--end-group"
|
|
||||||
fi
|
|
||||||
${LD} ${LDFLAGS} -r -o ${1} ${objects}
|
${LD} ${LDFLAGS} -r -o ${1} ${objects}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,46 +87,28 @@ vmlinux_link()
|
|||||||
local objects
|
local objects
|
||||||
|
|
||||||
if [ "${SRCARCH}" != "um" ]; then
|
if [ "${SRCARCH}" != "um" ]; then
|
||||||
if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then
|
objects="--whole-archive \
|
||||||
objects="--whole-archive \
|
built-in.o \
|
||||||
built-in.o \
|
--no-whole-archive \
|
||||||
--no-whole-archive \
|
--start-group \
|
||||||
--start-group \
|
${KBUILD_VMLINUX_LIBS} \
|
||||||
${KBUILD_VMLINUX_LIBS} \
|
--end-group \
|
||||||
--end-group \
|
${1}"
|
||||||
${1}"
|
|
||||||
else
|
|
||||||
objects="${KBUILD_VMLINUX_INIT} \
|
|
||||||
--start-group \
|
|
||||||
${KBUILD_VMLINUX_MAIN} \
|
|
||||||
${KBUILD_VMLINUX_LIBS} \
|
|
||||||
--end-group \
|
|
||||||
${1}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
${LD} ${LDFLAGS} ${LDFLAGS_vmlinux} -o ${2} \
|
${LD} ${LDFLAGS} ${LDFLAGS_vmlinux} -o ${2} \
|
||||||
-T ${lds} ${objects}
|
-T ${lds} ${objects}
|
||||||
else
|
else
|
||||||
if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then
|
objects="-Wl,--whole-archive \
|
||||||
objects="-Wl,--whole-archive \
|
built-in.o \
|
||||||
built-in.o \
|
-Wl,--no-whole-archive \
|
||||||
-Wl,--no-whole-archive \
|
-Wl,--start-group \
|
||||||
-Wl,--start-group \
|
${KBUILD_VMLINUX_LIBS} \
|
||||||
${KBUILD_VMLINUX_LIBS} \
|
-Wl,--end-group \
|
||||||
-Wl,--end-group \
|
${1}"
|
||||||
${1}"
|
|
||||||
else
|
|
||||||
objects="${KBUILD_VMLINUX_INIT} \
|
|
||||||
-Wl,--start-group \
|
|
||||||
${KBUILD_VMLINUX_MAIN} \
|
|
||||||
${KBUILD_VMLINUX_LIBS} \
|
|
||||||
-Wl,--end-group \
|
|
||||||
${1}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
${CC} ${CFLAGS_vmlinux} -o ${2} \
|
${CC} ${CFLAGS_vmlinux} -o ${2} \
|
||||||
-Wl,-T,${lds} \
|
-Wl,-T,${lds} \
|
||||||
${objects} \
|
${objects} \
|
||||||
-lutil -lrt -lpthread
|
-lutil -lrt -lpthread
|
||||||
rm -f linux
|
rm -f linux
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user