LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Amit Machhiwal <amachhiw@linux.ibm.com>
To: Laurent Vivier <lvivier@redhat.com>,
	Thomas Huth <thuth@redhat.com>,
	Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Amit Machhiwal <amachhiw@linux.ibm.com>,
	linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org
Subject: [PATCH] powerpc: Link with -z notext
Date: Tue, 10 Nov 2026 21:14:15 +0530	[thread overview]
Message-ID: <20261110154415.46220-1-amachhiw@linux.ibm.com> (raw)

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)



             reply	other threads:[~2026-11-10 15:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 15:44 Amit Machhiwal [this message]
2026-11-11  7:54 ` [PATCH] powerpc: Link with -z notext Thomas Huth
2026-11-11 10:18   ` Amit Machhiwal
2026-11-11  8:30 ` Thomas Huth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261110154415.46220-1-amachhiw@linux.ibm.com \
    --to=amachhiw@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=lvivier@redhat.com \
    --cc=maddy@linux.ibm.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox