diff options
author | Alan Modra <amodra@gmail.com> | 2020-06-19 09:17:20 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-06-19 09:50:20 +0930 |
commit | 5fd104addfddb68844fb8df67be832ee98ad9888 (patch) | |
tree | c8a0805ad47e7cdce9e7a8d3aff24eb4a158d335 /ld/testsuite/ld-elf | |
parent | 753d1583f7e61ae4b6a016accaa65ab2ea776e41 (diff) | |
download | gdb-5fd104addfddb68844fb8df67be832ee98ad9888.zip gdb-5fd104addfddb68844fb8df67be832ee98ad9888.tar.gz gdb-5fd104addfddb68844fb8df67be832ee98ad9888.tar.bz2 |
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".
Diffstat (limited to 'ld/testsuite/ld-elf')
-rw-r--r-- | ld/testsuite/ld-elf/pr16322.d | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr22393-1a.d | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr22393-1b.d | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/shared.exp | 26 |
4 files changed, 14 insertions, 15 deletions
diff --git a/ld/testsuite/ld-elf/pr16322.d b/ld/testsuite/ld-elf/pr16322.d index 7bd1a6f..1e9175c 100644 --- a/ld/testsuite/ld-elf/pr16322.d +++ b/ld/testsuite/ld-elf/pr16322.d @@ -2,6 +2,7 @@ #readelf: -l --wide #target: *-*-linux-gnu *-*-gnu* *-*-nacl* arm*-*-uclinuxfdpiceabi #xfail: ![check_shared_lib_support] +#xfail: ![check_relro_support] #... GNU_RELRO .* diff --git a/ld/testsuite/ld-elf/pr22393-1a.d b/ld/testsuite/ld-elf/pr22393-1a.d index c08ecaa..2bfa403 100644 --- a/ld/testsuite/ld-elf/pr22393-1a.d +++ b/ld/testsuite/ld-elf/pr22393-1a.d @@ -3,6 +3,7 @@ #readelf: -l --wide #target: *-*-linux-gnu *-*-gnu* *-*-nacl* arm*-*-uclinuxfdpiceabi #xfail: ![check_shared_lib_support] +#xfail: ![check_relro_support] #failif #... diff --git a/ld/testsuite/ld-elf/pr22393-1b.d b/ld/testsuite/ld-elf/pr22393-1b.d index b0020a1..96d8bc0 100644 --- a/ld/testsuite/ld-elf/pr22393-1b.d +++ b/ld/testsuite/ld-elf/pr22393-1b.d @@ -3,6 +3,7 @@ #readelf: -l --wide #target: *-*-linux-gnu *-*-gnu* *-*-nacl* arm*-*-uclinuxfdpiceabi #xfail: ![check_shared_lib_support] +#xfail: ![check_relro_support] #failif #... diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp index 9d72cad..8f4ed71 100644 --- a/ld/testsuite/ld-elf/shared.exp +++ b/ld/testsuite/ld-elf/shared.exp @@ -454,16 +454,6 @@ run_ld_link_tests [list \ {pr20995b.s} {} "pr20995.so"] \ ] -# xfail on arm*-*-eabi*. The list can be enlarged to those targets that -# don't support GNU_RELRO. For more details, please see discussions at: -# https://sourceware.org/ml/binutils/2017-01/msg00441.html -run_ld_link_tests [list \ - [list "Build pr20995-2.so" \ - "-shared -z relro" "" "$AFLAGS_PIC" \ - {pr20995c.s} {{readelf {-l --wide} pr20995-2so.r}} "pr20995-2.so"] \ -] "tic6x-*-*" "arm*-*-eabi*" "hppa*64*-*-hpux*" "aarch64*-*-elf*" \ - "*-*-lynxos*" "arm*-*-nto*" "i?86-*-nto*" "sh*-*-nto*" - # These targets don't copy dynamic variables into .bss. setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*" # or don't have .data.rel.ro @@ -474,16 +464,22 @@ run_ld_link_tests [list \ "$LFLAGS" "tmpdir/pr20995.so" "$AFLAGS_NONPIC" \ {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995"]] -# xfail on arm*-*-eabi* is particularly because of no support of GNU_RELRO. -# Please see the link above for details. -setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*" "arm*-*-eabi*" -setup_xfail "hppa*64*-*-hpux*" "aarch64*-*-elf*" "tic6x-*-*" +# xfail on targets that don't support GNU_RELRO. +# For more details, please see discussions at: +# https://sourceware.org/ml/binutils/2017-01/msg00441.html +run_ld_link_tests [list \ + [list "Build pr20995-2.so" \ + "-shared -z relro" "" "$AFLAGS_PIC" \ + {pr20995c.s} {{readelf {-l --wide} pr20995-2so.r}} "pr20995-2.so"] \ +] {![check_relro_support]} + +setup_xfail alpha-*-* xtensa-*-* run_ld_link_tests [list \ [list \ "pr20995-2" \ "$LFLAGS" "tmpdir/pr20995-2.so" "$AFLAGS_NONPIC" \ {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995-2"] -] "*-*-lynxos*" "arm*-*-nto*" "i?86-*-nto*" "sh*-*-nto*" +] {![check_relro_support]} run_ld_link_tests [list \ [list "Build pr22374 shared library" \ |