From fb6ac163adc48a20be9d0a8de4c691b73431d3dd Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Thu, 13 Jan 2022 12:51:12 +1030 Subject: [PATCH] testsuite supports_dt_relr Tidy, and fix "FAIL: Build dt-relr-glibc-1b.so" on all non-x86 linux targets. binutils/ * binutils-common.exp (supports_dt_relr): New proc. ld/ * testsuite/config/default.exp (DT_RELR_LDFLAGS, NO_DT_RELR_LDFLAGS), (DT_RELR_CC_LDFLAGS, NO_DT_RELR_CC_LDFLAGS): Use supports_dt_relr. * testsuite/ld-elf/dt-relr.exp: Don't run unless supports_dt_relr. * testsuite/ld-elf/dt-relr-1a.d: Likewise. * testsuite/ld-elf/dt-relr-1b.d: Likewise. * testsuite/ld-elf/dt-relr-1c.d: Likewise. * testsuite/ld-elf/dt-relr-2a.d: Likewise. * testsuite/ld-elf/dt-relr-2b.d: Likewise. * testsuite/ld-elf/dt-relr-2c.d: Likewise. * testsuite/ld-elf/dt-relr-2d.d: Likewise. * testsuite/ld-elf/dt-relr-2e.d: Likewise. * testsuite/ld-elf/dt-relr-2f.d: Likewise. * testsuite/ld-elf/dt-relr-2g.d: Likewise. * testsuite/ld-elf/dt-relr-2h.d: Likewise. * testsuite/ld-elf/dt-relr-3a.d: Likewise. * testsuite/ld-elf/dt-relr-3b.d: Likewise. --- binutils/testsuite/lib/binutils-common.exp | 10 ++++++++++ ld/testsuite/config/default.exp | 16 ++++------------ ld/testsuite/ld-elf/dt-relr-1a.d | 2 +- ld/testsuite/ld-elf/dt-relr-1b.d | 2 +- ld/testsuite/ld-elf/dt-relr-1c.d | 2 +- ld/testsuite/ld-elf/dt-relr-2a.d | 2 +- ld/testsuite/ld-elf/dt-relr-2b.d | 2 +- ld/testsuite/ld-elf/dt-relr-2c.d | 2 +- ld/testsuite/ld-elf/dt-relr-2d.d | 2 +- ld/testsuite/ld-elf/dt-relr-2e.d | 2 +- ld/testsuite/ld-elf/dt-relr-2f.d | 2 +- ld/testsuite/ld-elf/dt-relr-2g.d | 2 +- ld/testsuite/ld-elf/dt-relr-2h.d | 2 +- ld/testsuite/ld-elf/dt-relr-3a.d | 2 +- ld/testsuite/ld-elf/dt-relr-3b.d | 2 +- ld/testsuite/ld-elf/dt-relr.exp | 3 +-- 16 files changed, 28 insertions(+), 27 deletions(-) diff --git a/binutils/testsuite/lib/binutils-common.exp b/binutils/testsuite/lib/binutils-common.exp index 88fdc1a71c7..93603b0be68 100644 --- a/binutils/testsuite/lib/binutils-common.exp +++ b/binutils/testsuite/lib/binutils-common.exp @@ -427,6 +427,16 @@ proc supports_persistent_section {} { return 0; } +# Whether a target support DT_RELR sections. +proc supports_dt_relr {} { + if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) + && ([istarget *-*-linux*] + || [istarget *-*-gnu*]) } { + return 1 + } + return 0 +} + # Compare two files line-by-line. FILE_1 is the actual output and FILE_2 # is the expected output. Ignore blank lines in either file. # diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp index fb4f151eddc..2c3cec68434 100644 --- a/ld/testsuite/config/default.exp +++ b/ld/testsuite/config/default.exp @@ -314,9 +314,7 @@ if ![info exists LDFLAGS] then { } if { ![info exists DT_RELR_LDFLAGS] } then { - if { [istarget "i?86-*-linux*"] \ - || [istarget "x86_64-*-linux*"] \ - || [istarget "i?86-*-gnu**"] } then { + if { [supports_dt_relr] } then { set DT_RELR_LDFLAGS "-z pack-relative-relocs" } else { set DT_RELR_LDFLAGS {} @@ -324,9 +322,7 @@ if { ![info exists DT_RELR_LDFLAGS] } then { } if { ![info exists DT_RELR_CC_LDFLAGS] } then { - if { [istarget "i?86-*-linux*"] \ - || [istarget "x86_64-*-linux*"] \ - || [istarget "i?86-*-gnu**"] } then { + if { [supports_dt_relr] } then { set DT_RELR_CC_LDFLAGS "-Wl,-z,pack-relative-relocs" } else { set DT_RELR_CC_LDFLAGS {} @@ -334,9 +330,7 @@ if { ![info exists DT_RELR_CC_LDFLAGS] } then { } if { ![info exists NO_DT_RELR_LDFLAGS] } then { - if { [istarget "i?86-*-linux*"] \ - || [istarget "x86_64-*-linux*"] \ - || [istarget "i?86-*-gnu**"] } then { + if { [supports_dt_relr] } then { set NO_DT_RELR_LDFLAGS "-z nopack-relative-relocs" } else { set NO_DT_RELR_LDFLAGS {} @@ -344,9 +338,7 @@ if { ![info exists NO_DT_RELR_LDFLAGS] } then { } if { ![info exists NO_DT_RELR_CC_LDFLAGS] } then { - if { [istarget "i?86-*-linux*"] \ - || [istarget "x86_64-*-linux*"] \ - || [istarget "i?86-*-gnu**"] } then { + if { [supports_dt_relr] } then { set NO_DT_RELR_CC_LDFLAGS "-Wl,-z,nopack-relative-relocs" } else { set NO_DT_RELR_CC_LDFLAGS {} diff --git a/ld/testsuite/ld-elf/dt-relr-1a.d b/ld/testsuite/ld-elf/dt-relr-1a.d index 55c93cefb59..5280f628da7 100644 --- a/ld/testsuite/ld-elf/dt-relr-1a.d +++ b/ld/testsuite/ld-elf/dt-relr-1a.d @@ -1,7 +1,7 @@ #source: dt-relr-1.s #ld: -e _start $DT_RELR_LDFLAGS #readelf: -rW -d -#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* +#target: [supports_dt_relr] #... There is no dynamic section in this file. diff --git a/ld/testsuite/ld-elf/dt-relr-1b.d b/ld/testsuite/ld-elf/dt-relr-1b.d index 2b78f75d378..f9d75d3de12 100644 --- a/ld/testsuite/ld-elf/dt-relr-1b.d +++ b/ld/testsuite/ld-elf/dt-relr-1b.d @@ -1,7 +1,7 @@ #source: dt-relr-1.s #ld: -e _start -pie $DT_RELR_LDFLAGS #readelf: -rW -d -#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* +#target: [supports_dt_relr] #failif #... diff --git a/ld/testsuite/ld-elf/dt-relr-1c.d b/ld/testsuite/ld-elf/dt-relr-1c.d index 14f6cda6832..7e3d5207146 100644 --- a/ld/testsuite/ld-elf/dt-relr-1c.d +++ b/ld/testsuite/ld-elf/dt-relr-1c.d @@ -1,7 +1,7 @@ #source: dt-relr-1.s #ld: -shared $DT_RELR_LDFLAGS #readelf: -rW -d -#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* +#target: [supports_dt_relr] #failif #... diff --git a/ld/testsuite/ld-elf/dt-relr-2a.d b/ld/testsuite/ld-elf/dt-relr-2a.d index 31ef9e8e80e..eb00ea0c057 100644 --- a/ld/testsuite/ld-elf/dt-relr-2a.d +++ b/ld/testsuite/ld-elf/dt-relr-2a.d @@ -1,7 +1,7 @@ #source: dt-relr-2.s #ld: -e _start $DT_RELR_LDFLAGS #readelf: -rW -d -#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* +#target: [supports_dt_relr] #... There is no dynamic section in this file. diff --git a/ld/testsuite/ld-elf/dt-relr-2b.d b/ld/testsuite/ld-elf/dt-relr-2b.d index 7c401732a56..cea2931e37d 100644 --- a/ld/testsuite/ld-elf/dt-relr-2b.d +++ b/ld/testsuite/ld-elf/dt-relr-2b.d @@ -1,7 +1,7 @@ #source: dt-relr-2.s #ld: -e _start -pie $DT_RELR_LDFLAGS #readelf: -rW -d -#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* +#target: [supports_dt_relr] #... 0x[0-9a-f]+ \(RELR\) +0x[0-9a-f]+ diff --git a/ld/testsuite/ld-elf/dt-relr-2c.d b/ld/testsuite/ld-elf/dt-relr-2c.d index 63877b2f90f..73087a67533 100644 --- a/ld/testsuite/ld-elf/dt-relr-2c.d +++ b/ld/testsuite/ld-elf/dt-relr-2c.d @@ -1,7 +1,7 @@ #source: dt-relr-2.s #ld: -shared $DT_RELR_LDFLAGS #readelf: -rW -d -#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* +#target: [supports_dt_relr] #... 0x[0-9a-f]+ \(RELR\) +0x[0-9a-f]+ diff --git a/ld/testsuite/ld-elf/dt-relr-2d.d b/ld/testsuite/ld-elf/dt-relr-2d.d index e11528f395c..4987b0865a3 100644 --- a/ld/testsuite/ld-elf/dt-relr-2d.d +++ b/ld/testsuite/ld-elf/dt-relr-2d.d @@ -1,7 +1,7 @@ #source: dt-relr-2.s #ld: -e _start -pie $DT_RELR_LDFLAGS --no-relax #readelf: -rW -d -#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* +#target: [supports_dt_relr] #... 0x[0-9a-f]+ \(RELR\) +0x[0-9a-f]+ diff --git a/ld/testsuite/ld-elf/dt-relr-2e.d b/ld/testsuite/ld-elf/dt-relr-2e.d index 9cd268f9e73..24ce6cc0070 100644 --- a/ld/testsuite/ld-elf/dt-relr-2e.d +++ b/ld/testsuite/ld-elf/dt-relr-2e.d @@ -1,7 +1,7 @@ #source: dt-relr-2.s #ld: -e _start -pie $DT_RELR_LDFLAGS -z nocombreloc #readelf: -rW -d -#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* +#target: [supports_dt_relr] #... 0x[0-9a-f]+ \(RELR\) +0x[0-9a-f]+ diff --git a/ld/testsuite/ld-elf/dt-relr-2f.d b/ld/testsuite/ld-elf/dt-relr-2f.d index 4ad592f71fb..6e2d86b2a74 100644 --- a/ld/testsuite/ld-elf/dt-relr-2f.d +++ b/ld/testsuite/ld-elf/dt-relr-2f.d @@ -1,7 +1,7 @@ #source: dt-relr-2.s #ld: -r $DT_RELR_LDFLAGS #readelf: -rW -#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* +#target: [supports_dt_relr] #... Relocation section '\.rel(a|)\.data' at offset 0x[0-9a-f]+ contains 5 entries: diff --git a/ld/testsuite/ld-elf/dt-relr-2g.d b/ld/testsuite/ld-elf/dt-relr-2g.d index 78e370068af..bbdcf123286 100644 --- a/ld/testsuite/ld-elf/dt-relr-2g.d +++ b/ld/testsuite/ld-elf/dt-relr-2g.d @@ -1,7 +1,7 @@ #source: dt-relr-2.s #ld: -e _start -pie $NO_DT_RELR_LDFLAGS #readelf: -rW -d -#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* +#target: [supports_dt_relr] #failif #... diff --git a/ld/testsuite/ld-elf/dt-relr-2h.d b/ld/testsuite/ld-elf/dt-relr-2h.d index 312373fb179..3d0bdfc7103 100644 --- a/ld/testsuite/ld-elf/dt-relr-2h.d +++ b/ld/testsuite/ld-elf/dt-relr-2h.d @@ -1,7 +1,7 @@ #source: dt-relr-2.s #ld: -e _start -shared $NO_DT_RELR_LDFLAGS #readelf: -rW -d -#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* +#target: [supports_dt_relr] #failif #... diff --git a/ld/testsuite/ld-elf/dt-relr-3a.d b/ld/testsuite/ld-elf/dt-relr-3a.d index 5a8a014803d..44180a989ec 100644 --- a/ld/testsuite/ld-elf/dt-relr-3a.d +++ b/ld/testsuite/ld-elf/dt-relr-3a.d @@ -1,7 +1,7 @@ #source: dt-relr-3.s #ld: -e _start -pie $DT_RELR_LDFLAGS #readelf: -rW -d -#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* +#target: [supports_dt_relr] #failif #... diff --git a/ld/testsuite/ld-elf/dt-relr-3b.d b/ld/testsuite/ld-elf/dt-relr-3b.d index 6c38e6968dc..20d1f75fd41 100644 --- a/ld/testsuite/ld-elf/dt-relr-3b.d +++ b/ld/testsuite/ld-elf/dt-relr-3b.d @@ -1,7 +1,7 @@ #source: dt-relr-3.s #ld: -shared $DT_RELR_LDFLAGS #readelf: -rW -d -#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu* +#target: [supports_dt_relr] #failif #... diff --git a/ld/testsuite/ld-elf/dt-relr.exp b/ld/testsuite/ld-elf/dt-relr.exp index 51d21e400ab..280373ec17a 100644 --- a/ld/testsuite/ld-elf/dt-relr.exp +++ b/ld/testsuite/ld-elf/dt-relr.exp @@ -19,8 +19,7 @@ # MA 02110-1301, USA. # -# Linux tests. -if { ![istarget "*-*-linux*"] } { +if { ![supports_dt_relr] } { return } -- 2.30.2