Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kbuild: rebuild multi-object modules when objtool is updated

When CONFIG_LTO_CLANG or CONFIG_X86_KERNEL_IBT is enabled, objtool for
multi-object modules is postponed until the objects are linked together.

Make sure to re-run objtool and re-link multi-object modules when
objtool is updated.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nicolas Schier <n.schier@avm.de>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14 (x86-64)

+8 -3
+8 -3
scripts/Makefile.build
··· 413 413 $(obj)/lib.a: $(lib-y) FORCE 414 414 $(call if_changed,ar) 415 415 416 - quiet_cmd_link_multi-m = LD [M] $@ 417 - cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ @$(patsubst %.o,%.mod,$@) $(cmd_objtool) 416 + quiet_cmd_ld_multi_m = LD [M] $@ 417 + cmd_ld_multi_m = $(LD) $(ld_flags) -r -o $@ @$(patsubst %.o,%.mod,$@) $(cmd_objtool) 418 + 419 + define rule_ld_multi_m 420 + $(call cmd_and_savecmd,ld_multi_m) 421 + $(call cmd,gen_objtooldep) 422 + endef 418 423 419 424 $(multi-obj-m): objtool-enabled := $(delay-objtool) 420 425 $(multi-obj-m): part-of-module := y 421 426 $(multi-obj-m): %.o: %.mod FORCE 422 - $(call if_changed,link_multi-m) 427 + $(call if_changed_rule,ld_multi_m) 423 428 $(call multi_depend, $(multi-obj-m), .o, -objs -y -m) 424 429 425 430 targets := $(filter-out $(PHONY), $(targets))