LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Amit Machhiwal <amachhiw@linux.ibm.com>,
	Laurent Vivier <lvivier@redhat.com>,
	Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH] powerpc: Link with -z notext
Date: Wed, 11 Nov 2026 09:30:26 +0100	[thread overview]
Message-ID: <620ad58f-50ed-4b0b-9d13-b4df34276448@redhat.com> (raw)
In-Reply-To: <20261110154415.46220-1-amachhiw@linux.ibm.com>

Am 10.11.26 um 16:44 schrieb Amit Machhiwal:
> 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 \
Another thought: Why are we only using -pie for the LDFLAGS, but we rather 
seem to compile with -fno-pic in the CFLAGS? That looks weird ... I guess 
the -fno-pic is required for certain targets (s390x and the non-EFI builds 
of the other targets?), but maybe we should only add it only where it is 
required and compile the targets that have relocation code with -fpie in the 
CFLAGS instead?

  Thomas



      parent reply	other threads:[~2026-11-11  8:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-11  8:30 ` Thomas Huth [this message]

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=620ad58f-50ed-4b0b-9d13-b4df34276448@redhat.com \
    --to=thuth@redhat.com \
    --cc=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=pbonzini@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