powerpc: Link with -z notext
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 <amachhiw@linux.ibm.com>
Message-ID: <20261110154415.46220-1-amachhiw@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
diff --git a/powerpc/Makefile b/powerpc/Makefile
index 41e752b..35fe588 100644
--- a/powerpc/Makefile
+++ b/powerpc/Makefile
@@ -78,7 +78,7 @@
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 \