Building the powerpc tests with GNU ld 2.46.1 fails when linking the
test binaries:

  /usr/bin/ld.bfd: error: read-only segment has dynamic relocations

The tests are linked with -pie and relocate themselves at boot (see
relocate() in powerpc/reloc64.c, called from powerpc/cstart64.S).
Newer GNU ld rejects relocations in read-only segments by default.  The
Makefile already checks after linking that only R_PPC64_RELATIVE
relocations are present.

Fix this by adding `-z notext` to the powerpc linker flags, as was done
for arm64 in commit 5d67db4e1860 ("arm64: Link with -z notext").

Signed-off-by: Amit Machhiwal <[email protected]>
---
 powerpc/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/powerpc/Makefile b/powerpc/Makefile
index 41e752b070bc..35fe58835726 100644
--- a/powerpc/Makefile
+++ b/powerpc/Makefile
@@ -78,7 +78,7 @@ include $(SRCDIR)/scripts/asm-offsets.mak
 
 FLATLIBS = $(libcflat) $(LIBFDT_archive)
 %.elf: CFLAGS += $(arch_CFLAGS)
-%.elf: LDFLAGS += $(arch_LDFLAGS) -pie -n
+%.elf: LDFLAGS += $(arch_LDFLAGS) -pie -n -z notext
 %.elf: %.o $(FLATLIBS) $(SRCDIR)/powerpc/flat.lds $(cstart.o) $(reloc.o) 
%.aux.o
        $(LD) $(LDFLAGS) -o $@ \
                -T $(SRCDIR)/powerpc/flat.lds --build-id=none \

base-commit: 5a221342a025948fa7d84f0c404748f6ba57f3ad
-- 
2.54.0 (Apple Git-157)


Reply via email to