mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-31 16:48:26 +02:00 
			
		
		
		
	 876a4bce38
			
		
	
	
		876a4bce38
		
	
	
	
	
		
			
			For (!X86_KERNEL_IBT && !LTO_CLANG && NOINSTR_VALIDATION), objtool runs on both translation units and vmlinux.o. The vmlinux.o run only does noinstr/noret validation. In that case --no-unreachable has no effect. Remove it. Note that for ((X86_KERNEL_IBT || LTO_CLANG) && KCOV), --no-unreachable still gets set in objtool-args-y by scripts/Makefile.lib. Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/r/05414246a0124db2f21b0d071b652aa9043d039d.1742852847.git.jpoimboe@kernel.org
		
			
				
	
	
		
			115 lines
		
	
	
	
		
			3.6 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			115 lines
		
	
	
	
		
			3.6 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
| # SPDX-License-Identifier: GPL-2.0-only
 | |
| 
 | |
| PHONY := __default
 | |
| __default: vmlinux.o modules.builtin.modinfo modules.builtin
 | |
| 
 | |
| include include/config/auto.conf
 | |
| include $(srctree)/scripts/Kbuild.include
 | |
| 
 | |
| # for objtool
 | |
| include $(srctree)/scripts/Makefile.lib
 | |
| 
 | |
| # Generate a linker script to ensure correct ordering of initcalls for Clang LTO
 | |
| # ---------------------------------------------------------------------------
 | |
| 
 | |
| quiet_cmd_gen_initcalls_lds = GEN     $@
 | |
|       cmd_gen_initcalls_lds = \
 | |
| 	$(PYTHON3) $(srctree)/scripts/jobserver-exec \
 | |
| 	$(PERL) $(real-prereqs) > $@
 | |
| 
 | |
| .tmp_initcalls.lds: $(srctree)/scripts/generate_initcall_order.pl \
 | |
| 		vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
 | |
| 	$(call if_changed,gen_initcalls_lds)
 | |
| 
 | |
| targets := .tmp_initcalls.lds
 | |
| 
 | |
| ifdef CONFIG_LTO_CLANG
 | |
| initcalls-lds := .tmp_initcalls.lds
 | |
| endif
 | |
| 
 | |
| # objtool for vmlinux.o
 | |
| # ---------------------------------------------------------------------------
 | |
| #
 | |
| # For delay-objtool (IBT or LTO), objtool doesn't run on individual translation
 | |
| # units.  Instead it runs on vmlinux.o.
 | |
| #
 | |
| # For !delay-objtool + CONFIG_NOINSTR_VALIDATION, it runs on both translation
 | |
| # units and vmlinux.o, with the latter only used for noinstr/unret validation.
 | |
| 
 | |
| objtool-enabled := $(or $(delay-objtool),$(CONFIG_NOINSTR_VALIDATION))
 | |
| 
 | |
| ifeq ($(delay-objtool),y)
 | |
| vmlinux-objtool-args-y					+= $(objtool-args-y)
 | |
| else
 | |
| vmlinux-objtool-args-$(CONFIG_OBJTOOL_WERROR)		+= --Werror
 | |
| endif
 | |
| 
 | |
| vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION)	+= --noinstr \
 | |
| 							   $(if $(or $(CONFIG_MITIGATION_UNRET_ENTRY),$(CONFIG_MITIGATION_SRSO)), --unret)
 | |
| 
 | |
| objtool-args = $(vmlinux-objtool-args-y) --link
 | |
| 
 | |
| # Link of vmlinux.o used for section mismatch analysis
 | |
| # ---------------------------------------------------------------------------
 | |
| 
 | |
| vmlinux-o-ld-args-$(CONFIG_BUILTIN_MODULE_RANGES)	+= -Map=$@.map
 | |
| 
 | |
| quiet_cmd_ld_vmlinux.o = LD      $@
 | |
|       cmd_ld_vmlinux.o = \
 | |
| 	$(LD) ${KBUILD_LDFLAGS} -r -o $@ \
 | |
| 	$(vmlinux-o-ld-args-y) \
 | |
| 	$(addprefix -T , $(initcalls-lds)) \
 | |
| 	--whole-archive vmlinux.a --no-whole-archive \
 | |
| 	--start-group $(KBUILD_VMLINUX_LIBS) --end-group \
 | |
| 	$(cmd_objtool)
 | |
| 
 | |
| define rule_ld_vmlinux.o
 | |
| 	$(call cmd_and_savecmd,ld_vmlinux.o)
 | |
| 	$(call cmd,gen_objtooldep)
 | |
| endef
 | |
| 
 | |
| vmlinux.o: $(initcalls-lds) vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE
 | |
| 	$(call if_changed_rule,ld_vmlinux.o)
 | |
| 
 | |
| targets += vmlinux.o
 | |
| 
 | |
| # module.builtin.modinfo
 | |
| # ---------------------------------------------------------------------------
 | |
| 
 | |
| OBJCOPYFLAGS_modules.builtin.modinfo := -j .modinfo -O binary
 | |
| 
 | |
| targets += modules.builtin.modinfo
 | |
| modules.builtin.modinfo: vmlinux.o FORCE
 | |
| 	$(call if_changed,objcopy)
 | |
| 
 | |
| # module.builtin
 | |
| # ---------------------------------------------------------------------------
 | |
| 
 | |
| # The second line aids cases where multiple modules share the same object.
 | |
| 
 | |
| quiet_cmd_modules_builtin = GEN     $@
 | |
|       cmd_modules_builtin = \
 | |
| 	tr '\0' '\n' < $< | \
 | |
| 	sed -n 's/^[[:alnum:]:_]*\.file=//p' | \
 | |
| 	tr ' ' '\n' | uniq | sed -e 's:^:kernel/:' -e 's/$$/.ko/' > $@
 | |
| 
 | |
| targets += modules.builtin
 | |
| modules.builtin: modules.builtin.modinfo FORCE
 | |
| 	$(call if_changed,modules_builtin)
 | |
| 
 | |
| # Add FORCE to the prerequisites of a target to force it to be always rebuilt.
 | |
| # ---------------------------------------------------------------------------
 | |
| 
 | |
| PHONY += FORCE
 | |
| FORCE:
 | |
| 
 | |
| # Read all saved command lines and dependencies for the $(targets) we
 | |
| # may be building above, using $(if_changed{,_dep}). As an
 | |
| # optimization, we don't need to read them if the target does not
 | |
| # exist, we will rebuild anyway in that case.
 | |
| 
 | |
| existing-targets := $(wildcard $(sort $(targets)))
 | |
| 
 | |
| -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
 | |
| 
 | |
| .PHONY: $(PHONY)
 |