From e81ce4fb88164eb93e9ef92ebe69b576c226cb4d Mon Sep 17 00:00:00 2001 From: Dmitry Golovin Date: Fri, 1 May 2020 08:42:13 +0000 Subject: [PATCH] FROMLIST: x86/boot: allow a relocatable kernel to be linked with lld LLD by default disallows relocations in read-only segments. For a relocatable kernel, we pass -z notext to the linker to explicitly allow relocations. This behavior is the default for BFD. Link: https://github.com/ClangBuiltLinux/linux/issues/579 Signed-off-by: Dmitry Golovin Tested-by: Nathan Chancellor [adelva: ndesaulniers notes this is a simpler alternative to the upstream fix that is hard to backport to 5.4 due to many x86 assembler changes] Link: https://lore.kernel.org/lkml/20200501084215.242-1-dima@golovin.in/ Bug: 65987925 Signed-off-by: Alistair Delva Change-Id: Ie0085504ff58e468ad5b3f71014b58151b2f2f2d --- arch/x86/boot/compressed/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index 292b5bc6e3a3..aef6604b5292 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -57,6 +57,9 @@ else KBUILD_LDFLAGS += $(shell $(LD) --help 2>&1 | grep -q "\-z noreloc-overflow" \ && echo "-z noreloc-overflow -pie --no-dynamic-linker") endif +ifeq ($(CONFIG_RELOCATABLE), y) +KBUILD_LDFLAGS += -z notext +endif LDFLAGS_vmlinux := -T hostprogs-y := mkpiggy