summaryrefslogtreecommitdiff
path: root/scripts/link-vmlinux.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/link-vmlinux.sh')
-rwxr-xr-xscripts/link-vmlinux.sh63
1 files changed, 40 insertions, 23 deletions
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index a3c634b2f348..4ab44c73da4d 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -31,6 +31,7 @@ set -e
LD="$1"
KBUILD_LDFLAGS="$2"
LDFLAGS_vmlinux="$3"
+VMLINUX="$4"
is_enabled() {
grep -q "^$1=y" include/config/auto.conf
@@ -59,7 +60,8 @@ vmlinux_link()
# skip output file argument
shift
- if is_enabled CONFIG_LTO_CLANG || is_enabled CONFIG_X86_KERNEL_IBT; then
+ if is_enabled CONFIG_LTO_CLANG || is_enabled CONFIG_X86_KERNEL_IBT ||
+ is_enabled CONFIG_KLP_BUILD; then
# Use vmlinux.o instead of performing the slow LTO link again.
objs=vmlinux.o
libs=
@@ -68,10 +70,11 @@ vmlinux_link()
libs="${KBUILD_VMLINUX_LIBS}"
fi
- if is_enabled CONFIG_MODULES; then
- objs="${objs} .vmlinux.export.o"
+ if is_enabled CONFIG_GENERIC_BUILTIN_DTB; then
+ objs="${objs} .builtin-dtbs.o"
fi
+ objs="${objs} .vmlinux.export.o"
objs="${objs} init/version-timestamp.o"
if [ "${SRCARCH}" = "um" ]; then
@@ -93,8 +96,8 @@ vmlinux_link()
ldflags="${ldflags} ${wl}--strip-debug"
fi
- if is_enabled CONFIG_VMLINUX_MAP; then
- ldflags="${ldflags} ${wl}-Map=${output}.map"
+ if [ -n "${generate_map}" ]; then
+ ldflags="${ldflags} ${wl}-Map=vmlinux.map"
fi
${ld} ${ldflags} -o ${output} \
@@ -140,10 +143,6 @@ kallsyms()
kallsymopt="${kallsymopt} --all-symbols"
fi
- if is_enabled CONFIG_KALLSYMS_ABSOLUTE_PERCPU; then
- kallsymopt="${kallsymopt} --absolute-percpu"
- fi
-
info KSYMS "${2}.S"
scripts/kallsyms ${kallsymopt} "${1}" > "${2}.S"
@@ -173,12 +172,14 @@ mksysmap()
sorttable()
{
- ${objtree}/scripts/sorttable ${1}
+ ${NM} -S ${1} > .tmp_vmlinux.nm-sort
+ ${objtree}/scripts/sorttable -s .tmp_vmlinux.nm-sort ${1}
}
cleanup()
{
rm -f .btf.*
+ rm -f .tmp_vmlinux.nm-sort
rm -f System.map
rm -f vmlinux
rm -f vmlinux.map
@@ -206,10 +207,18 @@ fi
btf_vmlinux_bin_o=
kallsymso=
strip_debug=
+generate_map=
+
+# Use "make UT=1" to trigger warnings on unused tracepoints
+case "${WARN_ON_UNUSED_TRACEPOINTS}" in
+*1*)
+ ${objtree}/scripts/tracepoint-update vmlinux.o
+ ;;
+esac
if is_enabled CONFIG_KALLSYMS; then
- true > .tmp_vmlinux.kallsyms0.syms
- kallsyms .tmp_vmlinux.kallsyms0.syms .tmp_vmlinux0.kallsyms
+ true > .tmp_vmlinux0.syms
+ kallsyms .tmp_vmlinux0.syms .tmp_vmlinux0.kallsyms
fi
if is_enabled CONFIG_KALLSYMS || is_enabled CONFIG_DEBUG_INFO_BTF; then
@@ -236,14 +245,14 @@ if is_enabled CONFIG_KALLSYMS; then
# Generate section listing all symbols and add it into vmlinux
# It's a four step process:
# 0) Generate a dummy __kallsyms with empty symbol list.
- # 1) Link .tmp_vmlinux.kallsyms1 so it has all symbols and sections,
+ # 1) Link .tmp_vmlinux1.kallsyms so it has all symbols and sections,
# with a dummy __kallsyms.
- # Running kallsyms on that gives us .tmp_kallsyms1.o with
+ # Running kallsyms on that gives us .tmp_vmlinux1.kallsyms.o with
# the right size
- # 2) Link .tmp_vmlinux.kallsyms2 so it now has a __kallsyms section of
+ # 2) Link .tmp_vmlinux2.kallsyms so it now has a __kallsyms section of
# the right size, but due to the added section, some
# addresses have shifted.
- # From here, we generate a correct .tmp_vmlinux.kallsyms2.o
+ # From here, we generate a correct .tmp_vmlinux2.kallsyms.o
# 3) That link may have expanded the kernel image enough that
# more linker branch stubs / trampolines had to be added, which
# introduces new names, which further expands kallsyms. Do another
@@ -274,19 +283,27 @@ fi
strip_debug=
-vmlinux_link vmlinux
+if is_enabled CONFIG_VMLINUX_MAP; then
+ generate_map=1
+fi
+
+vmlinux_link "${VMLINUX}"
# fill in BTF IDs
if is_enabled CONFIG_DEBUG_INFO_BTF; then
- info BTFIDS vmlinux
- ${RESOLVE_BTFIDS} vmlinux
+ info BTFIDS "${VMLINUX}"
+ RESOLVE_BTFIDS_ARGS=""
+ if is_enabled CONFIG_WERROR; then
+ RESOLVE_BTFIDS_ARGS=" --fatal_warnings "
+ fi
+ ${RESOLVE_BTFIDS} ${RESOLVE_BTFIDS_ARGS} "${VMLINUX}"
fi
-mksysmap vmlinux System.map
+mksysmap "${VMLINUX}" System.map
if is_enabled CONFIG_BUILDTIME_TABLE_SORT; then
- info SORTTAB vmlinux
- if ! sorttable vmlinux; then
+ info SORTTAB "${VMLINUX}"
+ if ! sorttable "${VMLINUX}"; then
echo >&2 Failed to sort kernel tables
exit 1
fi
@@ -302,4 +319,4 @@ if is_enabled CONFIG_KALLSYMS; then
fi
# For fixdep
-echo "vmlinux: $0" > .vmlinux.d
+echo "${VMLINUX}: $0" > ".${VMLINUX}.d"