ANDROID: fix kernelci compressed kernel linking

Kernel versions 5.4 and below have several bogus relocations defined in
arch/x86/boot/compressed/head_32.S that cause build errors like the
following when linked with the llvm toolchain:

ld.lld: error: relocation R_386_32 cannot be used against symbol '_bss';
recompile with -fPIC

These errors only show up when linking with LLD because BFD allows
relocations in read-only sections by default. Add "-z notext" to
KBUILD_LDFLAGS to replicate that behavior with ld.lld and unblock
kernelci builds for 5.4 branches.

Bug: 430124841

Change-Id: I393174e264fbc0181abb5ecfd518055a7cb14162
Signed-off-by: Tiffany Yang <ynaffit@google.com>
This commit is contained in:
Tiffany Yang 2025-07-17 16:39:35 -07:00
commit 5287b166b7

View file

@ -58,6 +58,8 @@ KBUILD_LDFLAGS += $(shell $(LD) --help 2>&1 | grep -q "\-z noreloc-overflow" \
&& echo "-z noreloc-overflow -pie --no-dynamic-linker")
endif
KBUILD_LDFLAGS += -z notext
KBUILD_LDFLAGS += -z noexecstack
KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments)