Centos-kernel-stream-9/scripts/Makefile.vmlinux_o

82 lines
2.5 KiB
Makefile
Raw Permalink Normal View History

# SPDX-License-Identifier: GPL-2.0-only
PHONY := __default
__default: vmlinux.o
include include/config/auto.conf
include $(srctree)/scripts/Kbuild.include
kbuild: factor out the common objtool arguments JIRA: https://issues.redhat.com/browse/RHEL-2773 Conflicts: scripts/Makefile.build scripts/Makefile.lib scripts/link-vmlinux.sh - Undo previous RHEL-only conflict workarounds in these files from cs-9 commits that avoided this backport: - 69cd8c67c728 ("x86: Add prefix symbols for function padding") - 2354000bfcfe ("objtool: Add entry UNRET validation") - 73afd5ec29a2 ("objtool: Add --hacks=skylake") - 21de65cbaf66 ("x86/ibt: Implement FineIBT") - af8931b27334 ("kbuild: Fixup the IBT kbuild changes") - eeb9f34df065 ("x86/srso: Fix unret validation dependencies") scripts/Makefile.vmlinux_o - cs-9 is doesn't have 9ec6ab6ee5ca ("kbuild: use objtool-args-y to clean up objtool arguments"), add CONFIG_CPU_SRSO check to objtool_args and not vmlinux-objtool-args commit b42d2306502419688190aa6dd4dab4a6def24b3d Author: Masahiro Yamada <masahiroy@kernel.org> Date: Sun May 29 00:47:04 2022 +0900 kbuild: factor out the common objtool arguments scripts/Makefile.build and scripts/link-vmlinux.sh have similar setups for the objtool arguments. It was difficult to factor out them because all the vmlinux build rules were written in a shell script. It is somewhat tedious to touch the two files every time a new objtool option is supported. To reduce the code duplication, move the objtool for vmlinux.o into scripts/Makefile.vmlinux_o. Then, move the common macros to Makefile.lib so they are shared between Makefile.build and Makefile.vmlinux_o. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14 (x86-64) Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2024-04-03 20:03:44 +00:00
# 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 \
$(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
$(call if_changed,gen_initcalls_lds)
targets := .tmp_initcalls.lds
ifdef CONFIG_LTO_CLANG
initcalls-lds := .tmp_initcalls.lds
endif
kbuild: factor out the common objtool arguments JIRA: https://issues.redhat.com/browse/RHEL-2773 Conflicts: scripts/Makefile.build scripts/Makefile.lib scripts/link-vmlinux.sh - Undo previous RHEL-only conflict workarounds in these files from cs-9 commits that avoided this backport: - 69cd8c67c728 ("x86: Add prefix symbols for function padding") - 2354000bfcfe ("objtool: Add entry UNRET validation") - 73afd5ec29a2 ("objtool: Add --hacks=skylake") - 21de65cbaf66 ("x86/ibt: Implement FineIBT") - af8931b27334 ("kbuild: Fixup the IBT kbuild changes") - eeb9f34df065 ("x86/srso: Fix unret validation dependencies") scripts/Makefile.vmlinux_o - cs-9 is doesn't have 9ec6ab6ee5ca ("kbuild: use objtool-args-y to clean up objtool arguments"), add CONFIG_CPU_SRSO check to objtool_args and not vmlinux-objtool-args commit b42d2306502419688190aa6dd4dab4a6def24b3d Author: Masahiro Yamada <masahiroy@kernel.org> Date: Sun May 29 00:47:04 2022 +0900 kbuild: factor out the common objtool arguments scripts/Makefile.build and scripts/link-vmlinux.sh have similar setups for the objtool arguments. It was difficult to factor out them because all the vmlinux build rules were written in a shell script. It is somewhat tedious to touch the two files every time a new objtool option is supported. To reduce the code duplication, move the objtool for vmlinux.o into scripts/Makefile.vmlinux_o. Then, move the common macros to Makefile.lib so they are shared between Makefile.build and Makefile.vmlinux_o. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14 (x86-64) Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2024-04-03 20:03:44 +00:00
# objtool for vmlinux.o
# ---------------------------------------------------------------------------
#
# For LTO and IBT, objtool doesn't run on individual translation units.
# Run everything on vmlinux instead.
objtool-enabled := $(or $(delay-objtool),$(CONFIG_NOINSTR_VALIDATION))
vmlinux-objtool-args-$(delay-objtool) += $(objtool-args-y)
vmlinux-objtool-args-$(CONFIG_GCOV_KERNEL) += --no-unreachable
vmlinux-objtool-args-$(CONFIG_NOINSTR_VALIDATION) += --noinstr \
$(if $(or $(CONFIG_MITIGATION_UNRET_ENTRY),$(CONFIG_MITIGATION_SRSO)), --unret)
kbuild: factor out the common objtool arguments JIRA: https://issues.redhat.com/browse/RHEL-2773 Conflicts: scripts/Makefile.build scripts/Makefile.lib scripts/link-vmlinux.sh - Undo previous RHEL-only conflict workarounds in these files from cs-9 commits that avoided this backport: - 69cd8c67c728 ("x86: Add prefix symbols for function padding") - 2354000bfcfe ("objtool: Add entry UNRET validation") - 73afd5ec29a2 ("objtool: Add --hacks=skylake") - 21de65cbaf66 ("x86/ibt: Implement FineIBT") - af8931b27334 ("kbuild: Fixup the IBT kbuild changes") - eeb9f34df065 ("x86/srso: Fix unret validation dependencies") scripts/Makefile.vmlinux_o - cs-9 is doesn't have 9ec6ab6ee5ca ("kbuild: use objtool-args-y to clean up objtool arguments"), add CONFIG_CPU_SRSO check to objtool_args and not vmlinux-objtool-args commit b42d2306502419688190aa6dd4dab4a6def24b3d Author: Masahiro Yamada <masahiroy@kernel.org> Date: Sun May 29 00:47:04 2022 +0900 kbuild: factor out the common objtool arguments scripts/Makefile.build and scripts/link-vmlinux.sh have similar setups for the objtool arguments. It was difficult to factor out them because all the vmlinux build rules were written in a shell script. It is somewhat tedious to touch the two files every time a new objtool option is supported. To reduce the code duplication, move the objtool for vmlinux.o into scripts/Makefile.vmlinux_o. Then, move the common macros to Makefile.lib so they are shared between Makefile.build and Makefile.vmlinux_o. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14 (x86-64) Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2024-04-03 20:03:44 +00:00
objtool-args = $(vmlinux-objtool-args-y) --link
kbuild: factor out the common objtool arguments JIRA: https://issues.redhat.com/browse/RHEL-2773 Conflicts: scripts/Makefile.build scripts/Makefile.lib scripts/link-vmlinux.sh - Undo previous RHEL-only conflict workarounds in these files from cs-9 commits that avoided this backport: - 69cd8c67c728 ("x86: Add prefix symbols for function padding") - 2354000bfcfe ("objtool: Add entry UNRET validation") - 73afd5ec29a2 ("objtool: Add --hacks=skylake") - 21de65cbaf66 ("x86/ibt: Implement FineIBT") - af8931b27334 ("kbuild: Fixup the IBT kbuild changes") - eeb9f34df065 ("x86/srso: Fix unret validation dependencies") scripts/Makefile.vmlinux_o - cs-9 is doesn't have 9ec6ab6ee5ca ("kbuild: use objtool-args-y to clean up objtool arguments"), add CONFIG_CPU_SRSO check to objtool_args and not vmlinux-objtool-args commit b42d2306502419688190aa6dd4dab4a6def24b3d Author: Masahiro Yamada <masahiroy@kernel.org> Date: Sun May 29 00:47:04 2022 +0900 kbuild: factor out the common objtool arguments scripts/Makefile.build and scripts/link-vmlinux.sh have similar setups for the objtool arguments. It was difficult to factor out them because all the vmlinux build rules were written in a shell script. It is somewhat tedious to touch the two files every time a new objtool option is supported. To reduce the code duplication, move the objtool for vmlinux.o into scripts/Makefile.vmlinux_o. Then, move the common macros to Makefile.lib so they are shared between Makefile.build and Makefile.vmlinux_o. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14 (x86-64) Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2024-04-03 20:03:44 +00:00
# Link of vmlinux.o used for section mismatch analysis
# ---------------------------------------------------------------------------
quiet_cmd_ld_vmlinux.o = LD $@
cmd_ld_vmlinux.o = \
$(LD) ${KBUILD_LDFLAGS} -r -o $@ \
$(addprefix -T , $(initcalls-lds)) \
--whole-archive $(KBUILD_VMLINUX_OBJS) --no-whole-archive \
--start-group $(KBUILD_VMLINUX_LIBS) --end-group \
kbuild: factor out the common objtool arguments JIRA: https://issues.redhat.com/browse/RHEL-2773 Conflicts: scripts/Makefile.build scripts/Makefile.lib scripts/link-vmlinux.sh - Undo previous RHEL-only conflict workarounds in these files from cs-9 commits that avoided this backport: - 69cd8c67c728 ("x86: Add prefix symbols for function padding") - 2354000bfcfe ("objtool: Add entry UNRET validation") - 73afd5ec29a2 ("objtool: Add --hacks=skylake") - 21de65cbaf66 ("x86/ibt: Implement FineIBT") - af8931b27334 ("kbuild: Fixup the IBT kbuild changes") - eeb9f34df065 ("x86/srso: Fix unret validation dependencies") scripts/Makefile.vmlinux_o - cs-9 is doesn't have 9ec6ab6ee5ca ("kbuild: use objtool-args-y to clean up objtool arguments"), add CONFIG_CPU_SRSO check to objtool_args and not vmlinux-objtool-args commit b42d2306502419688190aa6dd4dab4a6def24b3d Author: Masahiro Yamada <masahiroy@kernel.org> Date: Sun May 29 00:47:04 2022 +0900 kbuild: factor out the common objtool arguments scripts/Makefile.build and scripts/link-vmlinux.sh have similar setups for the objtool arguments. It was difficult to factor out them because all the vmlinux build rules were written in a shell script. It is somewhat tedious to touch the two files every time a new objtool option is supported. To reduce the code duplication, move the objtool for vmlinux.o into scripts/Makefile.vmlinux_o. Then, move the common macros to Makefile.lib so they are shared between Makefile.build and Makefile.vmlinux_o. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14 (x86-64) Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2024-04-03 20:03:44 +00:00
$(cmd_objtool)
define rule_ld_vmlinux.o
$(call cmd_and_savecmd,ld_vmlinux.o)
kbuild: factor out the common objtool arguments JIRA: https://issues.redhat.com/browse/RHEL-2773 Conflicts: scripts/Makefile.build scripts/Makefile.lib scripts/link-vmlinux.sh - Undo previous RHEL-only conflict workarounds in these files from cs-9 commits that avoided this backport: - 69cd8c67c728 ("x86: Add prefix symbols for function padding") - 2354000bfcfe ("objtool: Add entry UNRET validation") - 73afd5ec29a2 ("objtool: Add --hacks=skylake") - 21de65cbaf66 ("x86/ibt: Implement FineIBT") - af8931b27334 ("kbuild: Fixup the IBT kbuild changes") - eeb9f34df065 ("x86/srso: Fix unret validation dependencies") scripts/Makefile.vmlinux_o - cs-9 is doesn't have 9ec6ab6ee5ca ("kbuild: use objtool-args-y to clean up objtool arguments"), add CONFIG_CPU_SRSO check to objtool_args and not vmlinux-objtool-args commit b42d2306502419688190aa6dd4dab4a6def24b3d Author: Masahiro Yamada <masahiroy@kernel.org> Date: Sun May 29 00:47:04 2022 +0900 kbuild: factor out the common objtool arguments scripts/Makefile.build and scripts/link-vmlinux.sh have similar setups for the objtool arguments. It was difficult to factor out them because all the vmlinux build rules were written in a shell script. It is somewhat tedious to touch the two files every time a new objtool option is supported. To reduce the code duplication, move the objtool for vmlinux.o into scripts/Makefile.vmlinux_o. Then, move the common macros to Makefile.lib so they are shared between Makefile.build and Makefile.vmlinux_o. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # LLVM-14 (x86-64) Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
2024-04-03 20:03:44 +00:00
$(call cmd,gen_objtooldep)
endef
vmlinux.o: $(initcalls-lds) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
$(call if_changed_rule,ld_vmlinux.o)
targets += vmlinux.o
# Add FORCE to the prequisites 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)