LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc: Link with -z notext
@ 2026-11-10 15:44 Amit Machhiwal
  2026-11-11  7:54 ` Thomas Huth
  2026-11-11  8:30 ` Thomas Huth
  0 siblings, 2 replies; 5+ messages in thread
From: Amit Machhiwal @ 2026-11-10 15:44 UTC (permalink / raw)
  To: Laurent Vivier, Thomas Huth, Madhavan Srinivasan
  Cc: Amit Machhiwal, linuxppc-dev, kvm

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>
---
 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)



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-13 12:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-10 15:44 [PATCH] powerpc: Link with -z notext Amit Machhiwal
2026-11-11  7:54 ` Thomas Huth
2026-11-11 10:18   ` Amit Machhiwal
2026-11-13 12:03     ` Thomas Huth
2026-11-11  8:30 ` Thomas Huth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox