summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2025-03-11 12:06:19 +0100
committerMasahiro Yamada <masahiroy@kernel.org>2025-03-17 00:29:50 +0900
commit9b400d17259b70d1d68585028e96b30152d0796a (patch)
treedd967c6890ffd783ee65b3b3b749c0122bb514f0 /Makefile
parente22bbb8e97846bfb5a6942a2322f0237ff13df0f (diff)
kbuild: Introduce Kconfig symbol for linking vmlinux with relocations
Some architectures build vmlinux with static relocations preserved, but strip them again from the final vmlinux image. Arch specific tools consume these static relocations in order to construct relocation tables for KASLR. The fact that vmlinux is created, consumed and subsequently updated goes against the typical, declarative paradigm used by Make, which is based on rules and dependencies. So as a first step towards cleaning this up, introduce a Kconfig symbol to declare that the arch wants to consume the static relocations emitted into vmlinux. This will be wired up further in subsequent patches. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile4
1 files changed, 4 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 30242e731a0d..0904b73872cb 100644
--- a/Makefile
+++ b/Makefile
@@ -1120,6 +1120,10 @@ ifdef CONFIG_LD_ORPHAN_WARN
LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
endif
+ifneq ($(CONFIG_ARCH_VMLINUX_NEEDS_RELOCS),)
+LDFLAGS_vmlinux += --emit-relocs --discard-none
+endif
+
# Align the bit size of userspace programs with the kernel
KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))
KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS))