kbuild: merge vmlinux_link() between the ordinary link and Clang LTO
When Clang LTO is enabled, vmlinux_link() reuses vmlinux.o instead of
re-linking ${KBUILD_VMLINUX_OBJS} and ${KBUILD_VMLINUX_LIBS}.
That is the only difference here, so merge the similar code.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
This commit is contained in:
@@ -154,12 +154,23 @@ vmlinux_link()
|
|||||||
local objects
|
local objects
|
||||||
local strip_debug
|
local strip_debug
|
||||||
local map_option
|
local map_option
|
||||||
|
local objs
|
||||||
|
local libs
|
||||||
|
|
||||||
info LD ${output}
|
info LD ${output}
|
||||||
|
|
||||||
# skip output file argument
|
# skip output file argument
|
||||||
shift
|
shift
|
||||||
|
|
||||||
|
if [ -n "${CONFIG_LTO_CLANG}" ]; then
|
||||||
|
# Use vmlinux.o instead of performing the slow LTO link again.
|
||||||
|
objs=vmlinux.o
|
||||||
|
libs=
|
||||||
|
else
|
||||||
|
objs="${KBUILD_VMLINUX_OBJS}"
|
||||||
|
libs="${KBUILD_VMLINUX_LIBS}"
|
||||||
|
fi
|
||||||
|
|
||||||
# The kallsyms linking does not need debug symbols included.
|
# The kallsyms linking does not need debug symbols included.
|
||||||
if [ "$output" != "${output#.tmp_vmlinux.kallsyms}" ] ; then
|
if [ "$output" != "${output#.tmp_vmlinux.kallsyms}" ] ; then
|
||||||
strip_debug=-Wl,--strip-debug
|
strip_debug=-Wl,--strip-debug
|
||||||
@@ -170,22 +181,9 @@ vmlinux_link()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${SRCARCH}" != "um" ]; then
|
if [ "${SRCARCH}" != "um" ]; then
|
||||||
if [ -n "${CONFIG_LTO_CLANG}" ]; then
|
objects="--whole-archive ${objs} --no-whole-archive \
|
||||||
# Use vmlinux.o instead of performing the slow LTO
|
--start-group ${libs} --end-group \
|
||||||
# link again.
|
$@"
|
||||||
objects="--whole-archive \
|
|
||||||
vmlinux.o \
|
|
||||||
--no-whole-archive \
|
|
||||||
${@}"
|
|
||||||
else
|
|
||||||
objects="--whole-archive \
|
|
||||||
${KBUILD_VMLINUX_OBJS} \
|
|
||||||
--no-whole-archive \
|
|
||||||
--start-group \
|
|
||||||
${KBUILD_VMLINUX_LIBS} \
|
|
||||||
--end-group \
|
|
||||||
${@}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} \
|
${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} \
|
||||||
${strip_debug#-Wl,} \
|
${strip_debug#-Wl,} \
|
||||||
|
|||||||
Reference in New Issue
Block a user