7c1507bba7e8ca18d5d90a8b73efaa5b5b1a86c2
[openwrt/staging/thess.git] /
1 From 579aee9fc594af94c242068c011b0233563d4bbf Mon Sep 17 00:00:00 2001
2 From: Stephen Rothwell <sfr@canb.auug.org.au>
3 Date: Mon, 10 Oct 2022 16:57:21 +1100
4 Subject: [PATCH] powerpc: suppress some linker warnings in recent linker
5 versions
6
7 This is a follow on from commit
8
9 0d362be5b142 ("Makefile: link with -z noexecstack --no-warn-rwx-segments")
10
11 for arch/powerpc/boot to address wanrings like:
12
13 ld: warning: opal-calls.o: missing .note.GNU-stack section implies executable stack
14 ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
15 ld: warning: arch/powerpc/boot/zImage.epapr has a LOAD segment with RWX permissions
16
17 This fixes issue https://github.com/linuxppc/issues/issues/417
18
19 Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
20 Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
21 Link: https://lore.kernel.org/r/20221010165721.106267e6@canb.auug.org.au
22 ---
23 arch/powerpc/boot/wrapper | 15 ++++++++++++++-
24 1 file changed, 14 insertions(+), 1 deletion(-)
25
26 --- a/arch/powerpc/boot/wrapper
27 +++ b/arch/powerpc/boot/wrapper
28 @@ -213,6 +213,11 @@ ld_version()
29 }'
30 }
31
32 +ld_is_lld()
33 +{
34 + ${CROSS}ld -V 2>&1 | grep -q LLD
35 +}
36 +
37 # Do not include PT_INTERP segment when linking pie. Non-pie linking
38 # just ignores this option.
39 LD_VERSION=$(${CROSS}ld --version | ld_version)
40 @@ -221,6 +226,14 @@ if [ "$LD_VERSION" -ge "$LD_NO_DL_MIN_VE
41 nodl="--no-dynamic-linker"
42 fi
43
44 +# suppress some warnings in recent ld versions
45 +nowarn="-z noexecstack"
46 +if ! ld_is_lld; then
47 + if [ "$LD_VERSION" -ge "$(echo 2.39 | ld_version)" ]; then
48 + nowarn="$nowarn --no-warn-rwx-segments"
49 + fi
50 +fi
51 +
52 platformo=$object/"$platform".o
53 lds=$object/zImage.lds
54 ext=strip
55 @@ -502,7 +515,7 @@ if [ "$platform" != "miboot" ]; then
56 text_start="-Ttext $link_address"
57 fi
58 #link everything
59 - ${CROSS}ld -m $format -T $lds $text_start $pie $nodl $rodynamic $notext -o "$ofile" $map \
60 + ${CROSS}ld -m $format -T $lds $text_start $pie $nodl $nowarn $rodynamic $notext -o "$ofile" $map \
61 $platformo $tmp $object/wrapper.a
62 rm $tmp
63 fi