Emit a warning when -z relro is unsupported
authorAlan Modra <amodra@gmail.com>
Thu, 18 Jun 2020 23:47:20 +0000 (09:17 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 19 Jun 2020 00:20:20 +0000 (09:50 +0930)
commit5fd104addfddb68844fb8df67be832ee98ad9888
treec8a0805ad47e7cdce9e7a8d3aff24eb4a158d335
parent753d1583f7e61ae4b6a016accaa65ab2ea776e41
Emit a warning when -z relro is unsupported

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.

binutils/
* testsuite/config/default.exp (ld_elf_shared_opt): Don't set.
* testsuite/lib/binutils-common.exp (check_relro_support): New proc.
(run_dump_test): Use check_relro_support to decide whether to pass
extra ld option "-z norelro".
ld/
* emultempl/elf.em (gld${EMULATION_NAME}_handle_option): Omit
-z relro and -z norelro when target support for GNU_RELRO is lacking.
(gld${EMULATION_NAME}_before_parse): Ignore RELRO default too.
* emultempl/aarch64elf.em (gld${EMULATION_NAME}_before_parse): Ignore
RELRO default when target support for GNU_RELRO is lacking.
* emultempl/armelf.em (gld${EMULATION_NAME}_before_parse): Likewise.
* emultempl/linux.em (gld${EMULATION_NAME}_before_parse): Likewise.
* emultempl/scoreelf.em (gld${EMULATION_NAME}_before_parse): Likewise.
* testsuite/config/default.exp (ld_elf_shared_opt): Don't set.
* testsuite/ld-elf/pr16322.d: xfail when no relro support.
* testsuite/ld-elf/pr22393-1a.d: Likewise.
* testsuite/ld-elf/pr22393-1b.d: Likewise.
* testsuite/ld-elf/shared.exp (pr20995-2.so, pr20995-2): Likewise.
* testsuite/lib/ld-lib.exp (run_ld_link_tests): Use check_relro_support
to decide whether to pass extra ld option "-z norelro".
15 files changed:
binutils/ChangeLog
binutils/testsuite/config/default.exp
binutils/testsuite/lib/binutils-common.exp
ld/ChangeLog
ld/emultempl/aarch64elf.em
ld/emultempl/armelf.em
ld/emultempl/elf.em
ld/emultempl/linux.em
ld/emultempl/scoreelf.em
ld/testsuite/config/default.exp
ld/testsuite/ld-elf/pr16322.d
ld/testsuite/ld-elf/pr22393-1a.d
ld/testsuite/ld-elf/pr22393-1b.d
ld/testsuite/ld-elf/shared.exp
ld/testsuite/lib/ld-lib.exp