Emit a warning when -z relro is unsupported
Alan Modra
amodra@gmail.com
Wed Jul 29 00:38:50 GMT 2020
On Tue, Jul 28, 2020 at 11:00:38PM +0000, Joseph Myers wrote:
> On Fri, 19 Jun 2020, Alan Modra via Binutils wrote:
>
> > ld silently accepts -z relro and -z norelro for targets that lack the
> > necessary GNU_RELRO support. This patch makes those targets emit a
> > warning instead, and adds testsuite infrastructure to detect when
> > relro is unsupported.
>
> This patch seems to have some effect beyond emitting a warning.
Yes, it does. ia64-linux-ld did not have effective -z relro support
before this patch, due to ld/emulparames/elf64-ia64.sh having
# FIXME: It interferes with linker relaxation. Disable it until it is
# fixed.
if test "0" = "1" -a -n "$CREATE_SHLIB"; then
# Optimize shared libraries for 16K page size
COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
fi
No COMMONPAGESIZE define means that ia64-linux ld scripts don't have
DATA_SEGMENT_ALIGN, DATA_SEGMENT_RELRO_END or DATA_SEGMENT_END. (You
can check that is so in a binutils-2.34 ia64-linux build.) Those
keywords are necessary for relro support.
So the patch disabled setting of link_info.relro, which normally
happens when passing -z relro to ld or by configuring binutils with
--enable-relro.
That shouldn't make much difference to the BFD elf linker.
link_info.relro should be disabled before sizing anyway for ia64.
About the only significant change I can see is in the selection of
linker script, which happens early before the linker decides it won't
be generating PT_GNU_RELRO. But even that shouldn't make much
difference. So I'll need to dig into this one a bit.
> My glibc build bot is showing that building glibc for ia64-linux-gnu fails
> with GCC 9 and binutils 2.35 branch, when it succeeded with GCC 9 and
> binutils 2.34 branch. The failure is an interal linker error linking
> libc.so:
>
> /scratch/jmyers/glibc-bot/install/compilers/ia64-linux-gnu/lib/gcc/ia64-glibc-linux-gnu/9.3.1/../../../../ia64-glibc-linux-gnu/bin/ld: warning: -z relro ignored
> /scratch/jmyers/glibc-bot/install/compilers/ia64-linux-gnu/lib/gcc/ia64-glibc-linux-gnu/9.3.1/../../../../ia64-glibc-linux-gnu/bin/ld: internal error /scratch/jmyers/glibc-bot/src/binutils/ld/ldwrite.c 212
>
> That line is "ASSERT (output_section->owner == link_info.output_bfd);".
> Bisecting shows that this commit introduced the glibc build failure.
>
> (I'm guessing the reason this appears with GCC 9 but not with GCC 10 is
> most likely to be the GCC 10 change to default to -fno-common perturbing
> the linking inputs sufficiently to avoid this internal error. The only
> glibc bot I have using binutils master also uses GCC master, so I didn't
> see this error until the default for my bots using GCC release branches
> switched from binutils 2.34 branch to binutils 2.35 branch.)
>
> --
> Joseph S. Myers
> joseph@codesourcery.com
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list