All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fangrui Song <maskray@google.com>
To: Bill Wendling <morbo@google.com>
Cc: Alan Modra <amodra@gmail.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] powerpc/wrapper: add "-z rodynamic" when using LLD
Date: Wed, 18 Nov 2020 14:55:26 -0800	[thread overview]
Message-ID: <20201118225526.ps7iw46sxjo5rmbr@google.com> (raw)
In-Reply-To: <20201118223910.2711337-1-morbo@google.com>

We could wait for https://lkml.org/lkml/2020/11/13/19
"[PATCH] kbuild: Always link with '-z norelro'"

Then we would not need -z rodynamic to work around a -z relro issue.

(The issue is that some sections don't strictly follow the normal
R/RX/RW(RELRO)/RW(non-RELRO) section flag partition. As a linker person
I would suggest that we don't create multiple clusters with the same
section flags (e.g. RW in two separate places), but this is my very
minor complaint.)

On 2020-11-18, Bill Wendling wrote:
>Normally all read-only sections precede SHF_WRITE sections. .dynamic and
>.got have the SHF_WRITE flag; .dynamic probably because of DT_DEBUG. LLD
>emits an error when this happens, so use "-z rodynamic" to mark .dynamic
>as read-only.
>
>Cc: Fangrui Song <maskray@google.com>
>Cc: Alan Modra <amodra@gmail.com>
>Signed-off-by: Bill Wendling <morbo@google.com>
>---
> arch/powerpc/boot/wrapper | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
>diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
>index cd58a62e810d..e1194955adbb 100755
>--- a/arch/powerpc/boot/wrapper
>+++ b/arch/powerpc/boot/wrapper
>@@ -46,6 +46,7 @@ compression=.gz
> uboot_comp=gzip
> pie=
> format=
>+rodynamic=
>
> # cross-compilation prefix
> CROSS=
>@@ -353,6 +354,7 @@ epapr)
>     platformo="$object/pseries-head.o $object/epapr.o $object/epapr-wrapper.o"
>     link_address='0x20000000'
>     pie=-pie
>+    rodynamic=$(if ${CROSS}ld -V 2>&1 | grep -q LLD ; then echo "-z rodynamic"; fi)
>     ;;
> mvme5100)
>     platformo="$object/fixed-head.o $object/mvme5100.o"
>@@ -493,7 +495,7 @@ if [ "$platform" != "miboot" ]; then
>         text_start="-Ttext $link_address"
>     fi
> #link everything
>-    ${CROSS}ld -m $format -T $lds $text_start $pie $nodl -o "$ofile" $map \
>+    ${CROSS}ld -m $format -T $lds $text_start $pie $nodl $rodynamic -o "$ofile" $map \
> 	$platformo $tmp $object/wrapper.a
>     rm $tmp
> fi
>-- 
>2.29.2.454.gaff20da3a2-goog
>

  reply	other threads:[~2020-11-18 22:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-17  0:01 [PATCH] powerpc/boot: move the .got section to after the .dynamic section Bill Wendling
2020-10-19 23:56 ` Fāng-ruì Sòng
2020-11-18 22:39 ` [PATCH] powerpc/wrapper: add "-z rodynamic" when using LLD Bill Wendling
2020-11-18 22:55   ` Fangrui Song [this message]
2020-12-10 11:30   ` Michael Ellerman
2020-12-10 11:30 ` [PATCH] powerpc/boot: move the .got section to after the .dynamic section Michael Ellerman

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=20201118225526.ps7iw46sxjo5rmbr@google.com \
    --to=maskray@google.com \
    --cc=amodra@gmail.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=morbo@google.com \
    --cc=ndesaulniers@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.