Re: [PATCH v2 02/27] kbuild: Add CONFIG_OBJTOOL_DEFERRED

From: Julian Braha

Date: Thu Sep 10 2026 - 15:30:34 EST


Hi Josh,

On 9/8/26 21:33, Josh Poimboeuf wrote:
> For LTO, IBT, and KLP builds, the running of objtool is deferred to
> vmlinux.o rather than individual translation units. In preparation for
> deferring it in more cases, add a new config option.
>
> No functional change.
>
> Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> ---
> arch/x86/boot/startup/Makefile | 2 +-
> lib/Kconfig.debug | 7 +++++++
> scripts/Makefile.build | 4 ++--
> scripts/Makefile.lib | 4 +---
> scripts/Makefile.vmlinux_o | 13 +++++++------
> scripts/link-vmlinux.sh | 3 +--
> 6 files changed, 19 insertions(+), 14 deletions(-)
>
> diff --git a/arch/x86/boot/startup/Makefile b/arch/x86/boot/startup/Makefile
> index 5e499cfb29b5c..ab6e9970d4f4e 100644
> --- a/arch/x86/boot/startup/Makefile
> +++ b/arch/x86/boot/startup/Makefile
> @@ -36,7 +36,7 @@ $(patsubst %.o,$(obj)/%.o,$(lib-y)): OBJECT_FILES_NON_STANDARD := y
> # relocations, even if other objtool actions are being deferred.
> #
> $(pi-objs): objtool-enabled = 1
> -$(pi-objs): objtool-args = $(if $(delay-objtool),--dry-run,$(objtool-args-y)) --noabs
> +$(pi-objs): objtool-args = $(if $(CONFIG_OBJTOOL_DEFERRED),--dry-run,$(objtool-args-y)) --noabs
>
> #
> # Confine the startup code by prefixing all symbols with __pi_ (for position
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index 134b15a44625e..566e5be4c3f57 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -588,6 +588,13 @@ config NOINSTR_VALIDATION
> select OBJTOOL
> default y
>
> +# For when objtool defers its work to the linked image (vmlinux.o or module.o)
> +# rather than running on individual translation units.
> +config OBJTOOL_DEFERRED
> + def_bool y
> + depends on OBJTOOL
> + depends on LTO_CLANG || X86_KERNEL_IBT || KLP_BUILD
> +

Just commenting: if you move this option OBJTOOL_DEFERRED (and
OBJTOOL_CONTROL_FLOW in the next patch) a few entries up in this Kconfig
file, menuconfig will render them as part of the OBJTOOL submenu because
of the dependency on OBJTOOL.

E.g. this ordering:

OBJTOOL
OBJTOOL_WERROR
OBJTOOL_DEFERRED
OBJTOOL_CONTROL_FLOW
STACK_VALIDATION
NOINSTR_VALIDATION

would render better.

But this is minor, I don't think it necessitates a v3 on its own.

- Julian Braha