Skip to content

Commit f6b66ca

Browse files
committed
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 <[email protected]> Reviewed-by: Kees Cook <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Tested-by: Nathan Chancellor <[email protected]> Reviewed-by: Nicolas Schier <[email protected]> Tested-by: Sedat Dilek <[email protected]> # LLVM-14 (x86-64)
1 parent ebd191b commit f6b66ca

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

scripts/Makefile.build

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,18 @@ $(obj)/modules.order: $(obj-m) FORCE
413413
$(obj)/lib.a: $(lib-y) FORCE
414414
$(call if_changed,ar)
415415

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
418423

419424
$(multi-obj-m): objtool-enabled := $(delay-objtool)
420425
$(multi-obj-m): part-of-module := y
421426
$(multi-obj-m): %.o: %.mod FORCE
422-
$(call if_changed,link_multi-m)
427+
$(call if_changed_rule,ld_multi_m)
423428
$(call multi_depend, $(multi-obj-m), .o, -objs -y -m)
424429

425430
targets := $(filter-out $(PHONY), $(targets))

0 commit comments

Comments
 (0)