Message ID | 20201118223910.2711337-1-morbo@google.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 26ba9f9651d802ba38583138f43fea5dc7eb0fd6 |
Headers | show |
Series | powerpc/wrapper: add "-z rodynamic" when using LLD | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/apply_patch | success | Successfully applied on branch powerpc/merge (9d1aa2f025c6cc516125c42c70f6a9ce087c49ea) |
snowpatch_ozlabs/build-ppc64le | success | Build succeeded |
snowpatch_ozlabs/build-ppc64be | success | Build succeeded |
snowpatch_ozlabs/build-ppc64e | success | Build succeeded |
snowpatch_ozlabs/build-pmac32 | success | Build succeeded |
snowpatch_ozlabs/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 22 lines checked |
snowpatch_ozlabs/needsstable | success | Patch has no Fixes tags |
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 >
On Wed, 18 Nov 2020 14:39:10 -0800, 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. Applied to powerpc/next. [1/1] powerpc/boot/wrapper: Add "-z rodynamic" when using LLD https://git.kernel.org/powerpc/c/26ba9f9651d802ba38583138f43fea5dc7eb0fd6 cheers
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
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(-)