A recent change to a default value of configuration variable (ENABLE_X86_RELAX_RELOCATIONS OFF -> ON) in LLVM now causes Clang's integrated assembler to emit R_X86_64_GOTPCRELX/R_X86_64_REX_GOTPCRELX relocations. LLD will relax instructions with these relocations based on whether the image is being linked as position independent or not. When not, then LLD will relax these instructions to use absolute addressing mode (R_RELAX_GOT_PC_NOPIC). This causes kernels built with Clang and linked with LLD to fail to boot. Also, the LLVM commit notes that these relocation types aren't supported until binutils 2.26. Since we support binutils 2.23+, avoid the relocations regardless of linker. The proper solution is to build the compressed boot image as position independent. There's a series working its way through code review currently that does that, but it's unlikely to be backported to stable, due to its size. For now, cut a smaller patch that's more likely to be easily picked up into stable, so that we can get our kernels booting again. Cc: stable@xxxxxxxxxxxxxxx # 4.14.y Link: https://github.com/ClangBuiltLinux/linux/issues/1121 Link: https://reviews.llvm.org/rGc41a18cf61790fc898dcda1055c3efbf442c14c0 Link: https://travis-ci.com/github/ClangBuiltLinux/continuous-integration/builds/178868465 Signed-off-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx> --- https://lore.kernel.org/lkml/20200731230820.1742553-7-keescook@xxxxxxxxxxxx/ is the patch I'm hopeful for building the compressed image as -pie, but I don't think the series will be backported. Regardless, we probably want this for older binutils support. arch/x86/boot/compressed/Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index 3962f592633d..ab0f7e7dabf9 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -44,6 +44,13 @@ KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) KBUILD_CFLAGS += -fno-asynchronous-unwind-tables KBUILD_CFLAGS += -D__DISABLE_EXPORTS +# Until we can build arch/x86/boot/compressed/vmlinux as -Wl,-pie, don't emit +# R_X86_64_GOTPCRELX or R_X86_64_REX_GOTPCRELX relocations that LLD will relax +# into absolute addressed operands, and that BFD didn't support until 2.26. +ifdef CONFIG_CC_IS_CLANG +KBUILD_CFLAGS += -Wa,-mrelax-relocations=no +endif + KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ GCOV_PROFILE := n UBSAN_SANITIZE :=n -- 2.28.0.236.gb10cc79966-goog