clang/ld.lld build fails with `can't create dynamic relocation R_PPC64_ADDR64 against local symbol in readonly segment`

Paul Menzel pmenzel at molgen.mpg.de
Wed Aug 11 04:38:26 AEST 2021


Dear Linux folks,


Am 29.07.21 um 10:23 schrieb Paul Menzel:

> I just wanted to make you aware that building Linux for ppc64le with 
> clang/lld.ld fails with [1]:
> 
>      ld.lld: error: can't create dynamic relocation R_PPC64_ADDR64 
> against symbol: empty_zero_page in readonly segment; recompile object 
> files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in 
> the output
>      >>> defined in arch/powerpc/kernel/head_64.o
>      >>> referenced by 
> arch/powerpc/kernel/head_64.o:(___ksymtab+empty_zero_page+0x0)
> 
> The patch below from one of the comments [2] fixes it.
> 
> --- i/arch/powerpc/Makefile
> +++ w/arch/powerpc/Makefile
> @@ -122,7 +122,7 @@ cflags-$(CONFIG_STACKPROTECTOR)     += 
> -mstack-protector-guard-reg=r2
>   endif
> 
>   LDFLAGS_vmlinux-y := -Bstatic
> -LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
> +LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie -z notext
>   LDFLAGS_vmlinux        := $(LDFLAGS_vmlinux-y)
>   LDFLAGS_vmlinux += $(call ld-option,--orphan-handling=warn)

Any comments, if this is the right fix? Current Linux master branch 
still fails to build with `LLVM=1` on Ubuntu 21.04 without this change.


Kind regards,

Paul


> [1]: https://github.com/ClangBuiltLinux/linux/issues/811
> [2]: https://github.com/ClangBuiltLinux/linux/issues/811#issuecomment-568316320


More information about the Linuxppc-dev mailing list