[11/11] s390: Link vmlinux with '-z notext'

Message ID 20240207-s390-lld-and-orphan-warn-v1-11-8a665b3346ab@kernel.org
State New
Headers
Series [01/11] s390: boot: Add support for CONFIG_LD_ORPHAN_WARN |

Commit Message

Nathan Chancellor Feb. 8, 2024, 12:15 a.m. UTC
  ld.bfd defaults to '-z notext' (although it is customizable with the
'--enable-textrel-check' configure option) but ld.lld defaults to '-z
text', which causes issues with building the kernel due to the presence
of dynamic relocations in sections that are not writable.

  ld.lld: error: relocation R_390_64 cannot be used against local symbol; recompile with -fPIC

Add '-z notext' to avoid these errors, as this is expected, which
matches other architectures.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/s390/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Fangrui Song Feb. 13, 2024, 5:20 a.m. UTC | #1
On Wed, Feb 7, 2024 at 4:15 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> ld.bfd defaults to '-z notext' (although it is customizable with the
> '--enable-textrel-check' configure option) but ld.lld defaults to '-z
> text', which causes issues with building the kernel due to the presence
> of dynamic relocations in sections that are not writable.
>
>   ld.lld: error: relocation R_390_64 cannot be used against local symbol; recompile with -fPIC
>
> Add '-z notext' to avoid these errors, as this is expected, which
> matches other architectures.
>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

This follows arm64/powerpc/loongarch/riscv.
LGTM.

Reviewed-by: Fangrui Song <maskray@google.com>

> ---
>  arch/s390/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/s390/Makefile b/arch/s390/Makefile
> index 73873e451686..994f9b3d575f 100644
> --- a/arch/s390/Makefile
> +++ b/arch/s390/Makefile
> @@ -15,7 +15,7 @@ KBUILD_CFLAGS_MODULE += -fPIC
>  KBUILD_AFLAGS  += -m64
>  KBUILD_CFLAGS  += -m64
>  KBUILD_CFLAGS  += -fPIE
> -LDFLAGS_vmlinux        := -pie
> +LDFLAGS_vmlinux        := -pie -z notext
>  aflags_dwarf   := -Wa,-gdwarf-2
>  KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__
>  ifndef CONFIG_AS_IS_LLVM
>
> --
> 2.43.0
>
  

Patch

diff --git a/arch/s390/Makefile b/arch/s390/Makefile
index 73873e451686..994f9b3d575f 100644
--- a/arch/s390/Makefile
+++ b/arch/s390/Makefile
@@ -15,7 +15,7 @@  KBUILD_CFLAGS_MODULE += -fPIC
 KBUILD_AFLAGS	+= -m64
 KBUILD_CFLAGS	+= -m64
 KBUILD_CFLAGS	+= -fPIE
-LDFLAGS_vmlinux	:= -pie
+LDFLAGS_vmlinux	:= -pie -z notext
 aflags_dwarf	:= -Wa,-gdwarf-2
 KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__
 ifndef CONFIG_AS_IS_LLVM