kbuild: merge vmlinux_link() between ARCH=um and other architectures
For ARCH=um, ${CC} is used as the linker driver. Hence, the linker
options are prefixed with -Wl, .
Merge the similar code.
I replaced the -T option with the long option --script= so that it
works well with/without ${wl}.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
This commit is contained in:
@@ -149,13 +149,12 @@ objtool_link()
|
|||||||
# ${2}, ${3}, ... - optional extra .o files
|
# ${2}, ${3}, ... - optional extra .o files
|
||||||
vmlinux_link()
|
vmlinux_link()
|
||||||
{
|
{
|
||||||
local lds="${objtree}/${KBUILD_LDS}"
|
|
||||||
local output=${1}
|
local output=${1}
|
||||||
local objects
|
|
||||||
local strip_debug
|
|
||||||
local map_option
|
|
||||||
local objs
|
local objs
|
||||||
local libs
|
local libs
|
||||||
|
local ld
|
||||||
|
local ldflags
|
||||||
|
local ldlibs
|
||||||
|
|
||||||
info LD ${output}
|
info LD ${output}
|
||||||
|
|
||||||
@@ -171,42 +170,33 @@ vmlinux_link()
|
|||||||
libs="${KBUILD_VMLINUX_LIBS}"
|
libs="${KBUILD_VMLINUX_LIBS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "${SRCARCH}" = "um" ]; then
|
||||||
|
wl=-Wl,
|
||||||
|
ld="${CC}"
|
||||||
|
ldflags="${CFLAGS_vmlinux}"
|
||||||
|
ldlibs="-lutil -lrt -lpthread"
|
||||||
|
else
|
||||||
|
wl=
|
||||||
|
ld="${LD}"
|
||||||
|
ldflags="${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux}"
|
||||||
|
ldlibs=
|
||||||
|
fi
|
||||||
|
|
||||||
|
ldflags="${ldflags} ${wl}--script=${objtree}/${KBUILD_LDS}"
|
||||||
|
|
||||||
# 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
|
ldflags="${ldflags} ${wl}--strip-debug"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${CONFIG_VMLINUX_MAP}" ]; then
|
if [ -n "${CONFIG_VMLINUX_MAP}" ]; then
|
||||||
map_option="-Map=${output}.map"
|
ldflags="${ldflags} ${wl}-Map=${output}.map"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${SRCARCH}" != "um" ]; then
|
${ld} ${ldflags} -o ${output} \
|
||||||
objects="--whole-archive ${objs} --no-whole-archive \
|
${wl}--whole-archive ${objs} ${wl}--no-whole-archive \
|
||||||
--start-group ${libs} --end-group \
|
${wl}--start-group ${libs} ${wl}--end-group \
|
||||||
$@"
|
$@ ${ldlibs}
|
||||||
|
|
||||||
${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} \
|
|
||||||
${strip_debug#-Wl,} \
|
|
||||||
-o ${output} \
|
|
||||||
${map_option} \
|
|
||||||
-T ${lds} ${objects}
|
|
||||||
else
|
|
||||||
objects="-Wl,--whole-archive \
|
|
||||||
${KBUILD_VMLINUX_OBJS} \
|
|
||||||
-Wl,--no-whole-archive \
|
|
||||||
-Wl,--start-group \
|
|
||||||
${KBUILD_VMLINUX_LIBS} \
|
|
||||||
-Wl,--end-group \
|
|
||||||
${@}"
|
|
||||||
|
|
||||||
${CC} ${CFLAGS_vmlinux} \
|
|
||||||
${strip_debug} \
|
|
||||||
-o ${output} \
|
|
||||||
${map_option:+-Wl,${map_option}} \
|
|
||||||
-Wl,-T,${lds} \
|
|
||||||
${objects} \
|
|
||||||
-lutil -lrt -lpthread
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# generate .BTF typeinfo from DWARF debuginfo
|
# generate .BTF typeinfo from DWARF debuginfo
|
||||||
|
|||||||
Reference in New Issue
Block a user