Skip to content

Commit 6804c1a

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
kbuild/objtool: Add objtool-vmlinux.o pass
Now that objtool is capable of processing vmlinux.o and actually has something useful to do there, (conditionally) add it to the final link pass. This will increase build time by a few seconds. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Miroslav Benes <[email protected]> Reviewed-by: Alexandre Chartre <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 87ecb58 commit 6804c1a

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

lib/Kconfig.debug

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,11 @@ config STACK_VALIDATION
369369
For more information, see
370370
tools/objtool/Documentation/stack-validation.txt.
371371

372+
config VMLINUX_VALIDATION
373+
bool
374+
depends on STACK_VALIDATION && DEBUG_ENTRY && !PARAVIRT
375+
default y
376+
372377
config DEBUG_FORCE_WEAK_PER_CPU
373378
bool "Force weak per-cpu definitions"
374379
depends on DEBUG_KERNEL

scripts/link-vmlinux.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,29 @@ modpost_link()
5555
${LD} ${KBUILD_LDFLAGS} -r -o ${1} ${objects}
5656
}
5757

58+
objtool_link()
59+
{
60+
local objtoolopt;
61+
62+
if [ -n "${CONFIG_VMLINUX_VALIDATION}" ]; then
63+
objtoolopt="check"
64+
if [ -z "${CONFIG_FRAME_POINTER}" ]; then
65+
objtoolopt="${objtoolopt} --no-fp"
66+
fi
67+
if [ -n "${CONFIG_GCOV_KERNEL}" ]; then
68+
objtoolopt="${objtoolopt} --no-unreachable"
69+
fi
70+
if [ -n "${CONFIG_RETPOLINE}" ]; then
71+
objtoolopt="${objtoolopt} --retpoline"
72+
fi
73+
if [ -n "${CONFIG_X86_SMAP}" ]; then
74+
objtoolopt="${objtoolopt} --uaccess"
75+
fi
76+
info OBJTOOL ${1}
77+
tools/objtool/objtool ${objtoolopt} ${1}
78+
fi
79+
}
80+
5881
# Link of vmlinux
5982
# ${1} - output file
6083
# ${2}, ${3}, ... - optional extra .o files
@@ -251,6 +274,7 @@ ${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init need-builtin=1
251274
#link vmlinux.o
252275
info LD vmlinux.o
253276
modpost_link vmlinux.o
277+
objtool_link vmlinux.o
254278

255279
# modpost vmlinux.o to check for section mismatches
256280
${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=1

0 commit comments

Comments
 (0)