Use is_pecoff_format in ld testsuite
authorAlan Modra <amodra@gmail.com>
Tue, 7 Jul 2020 03:28:12 +0000 (12:58 +0930)
committerAlan Modra <amodra@gmail.com>
Tue, 7 Jul 2020 08:56:34 +0000 (18:26 +0930)
--image-base 0 is not just for x86_64 mingw.  This patch fixes that,
and a case where a changed LDFLAGS leaked out of one script to the next.

* testsuite/ld-scripts/align.exp: Use is_pecoff_format.
* testsuite/ld-scripts/defined.exp: Likewise.
* testsuite/ld-scripts/provide.exp: Likewise.
* testsuite/ld-scripts/weak.exp: Likewise.
* testsuite/ld-scripts/empty-address.exp: Likewise.  Reset LDFLAGS
on exit.
* testsuite/ld-scripts/expr.exp: Set LDFLAGS earlier, and with
--image-base for PE.
* testsuite/ld-scripts/include.exp: Set LDFLAGS for PE.
* testsuite/ld-scripts/script.exp: Use is_pecoff_format, and
set LDFLAGS as well as flags.

ld/ChangeLog
ld/testsuite/ld-scripts/align.exp
ld/testsuite/ld-scripts/defined.exp
ld/testsuite/ld-scripts/empty-address.exp
ld/testsuite/ld-scripts/expr.exp
ld/testsuite/ld-scripts/include.exp
ld/testsuite/ld-scripts/provide.exp
ld/testsuite/ld-scripts/script.exp
ld/testsuite/ld-scripts/weak.exp

index 67bf035bdaa8893e87a6ab08071025da6a45ed3c..ce29d72249a410fb55b6da13f30aabc4d0af985e 100644 (file)
@@ -1,3 +1,17 @@
+2020-07-07  Alan Modra  <amodra@gmail.com>
+
+       * testsuite/ld-scripts/align.exp: Use is_pecoff_format.
+       * testsuite/ld-scripts/defined.exp: Likewise.
+       * testsuite/ld-scripts/provide.exp: Likewise.
+       * testsuite/ld-scripts/weak.exp: Likewise.
+       * testsuite/ld-scripts/empty-address.exp: Likewise.  Reset LDFLAGS
+       on exit.
+       * testsuite/ld-scripts/expr.exp: Set LDFLAGS earlier, and with
+       --image-base for PE.
+       * testsuite/ld-scripts/include.exp: Set LDFLAGS for PE.
+       * testsuite/ld-scripts/script.exp: Use is_pecoff_format, and
+       set LDFLAGS as well as flags.
+
 2020-07-07  Alan Modra  <amodra@gmail.com>
 
        * testsuite/ld-checks/checks.exp: Use is_xcoff_format.
index 1520fa333d2dce52151fef4504e4cbec13de7623..38172517302402e6685fdbc8779df3721b6ab1e0 100644 (file)
@@ -31,10 +31,10 @@ if ![ld_assemble $as $srcdir/$subdir/align.s tmpdir/align.o] {
     return
 }
 
-# mingw on x86_64 targets need to set the image base to 0 to avoid auto image-basing.
+# Avoid auto image-basing.
 set saved_LDFLAGS "$LDFLAGS"
-if [istarget "x86_64-*-mingw*"] then {
-  set LDFLAGS "$LDFLAGS --image-base 0"
+if { [is_pecoff_format] } then {
+    set LDFLAGS "$LDFLAGS --image-base 0"
 }
 
 if ![ld_link $ld tmpdir/align "$LDFLAGS -T $srcdir/$subdir/align.t tmpdir/align.o"] {
index 6889f04c167a30d53b7a46ca362d29699c5e4cb9..7a47030c70d235b764229a70cb563b2785009cd1 100644 (file)
@@ -28,8 +28,8 @@ if ![ld_assemble $as $srcdir/$subdir/defined.s tmpdir/def.o] {
 }
 
 set saved_LDFLAGS "$LDFLAGS"
-if [istarget "x86_64-*-mingw*"] then {
-  set LDFLAGS "$LDFLAGS --image-base 0"
+if { [is_pecoff_format] } then {
+    set LDFLAGS "$LDFLAGS --image-base 0"
 }
 
 if { ![ld_link $ld tmpdir/def "$LDFLAGS -T $srcdir/$subdir/defined.t tmpdir/def.o"] } {
index a505e57c78cba6babfe6e50ef0d54515e65b13df..d71202a303695e5fa8c76a78f6db69b59d3181db 100644 (file)
@@ -19,8 +19,9 @@
 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
 # MA 02110-1301, USA.
 
-if [istarget "x86_64-*-mingw*"] then {
-  set LDFLAGS "$LDFLAGS --image-base 0"
+set old_LDFLAGS $LDFLAGS
+if { [is_pecoff_format] } then {
+    set LDFLAGS "$LDFLAGS --image-base 0"
 }
 
 run_dump_test empty-address-1
@@ -29,3 +30,5 @@ run_dump_test empty-address-2b
 run_dump_test empty-address-3a
 run_dump_test empty-address-3b
 run_dump_test empty-address-3c
+
+set LDFLAGS $old_LDFLAGS
index 08bf0ab2eb2cb6ebe7a624b854815a37be2f91ea..7b1c62751d0eeb8c9a2c2820ef5512c2b6fd7bcd 100644 (file)
 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
 # MA 02110-1301, USA.
 
+set old_LDFLAGS $LDFLAGS
+if { [istarget spu*-*-*] } then {
+    set LDFLAGS "$LDFLAGS --no-overlays --local-store 0:0"
+} elseif { [is_pecoff_format] } then {
+    set LDFLAGS "$LDFLAGS --image-base 0"
+}
+
 run_dump_test expr1
 run_dump_test expr2
 run_dump_test sane1
 run_dump_test assign-loc
 run_dump_test pr14962
 run_dump_test pr14962-2
+run_dump_test pr18963
 run_dump_test pr22267
 
-set old_ldflags $LDFLAGS
-if { [istarget spu*-*-*] } {
-    set LDFLAGS "$LDFLAGS --no-overlays --local-store 0:0"
-}
-run_dump_test pr18963
-set LDFLAGS $old_ldflags
+set LDFLAGS $old_LDFLAGS
index d74f30e6d76c23938d73053725505bef6fb658a9..c7e2ee58a0366f9810bfe0f1204cc9a072c7d8c9 100644 (file)
@@ -23,8 +23,10 @@ if [is_aout_format] {
 }
 
 set old_ldflags $LDFLAGS
-if { [istarget spu*-*-*] } {
+if { [istarget spu*-*-*] } then {
     set LDFLAGS "$LDFLAGS --local-store 0:0 --no-overlays"
+} elseif { [is_pecoff_format] } then {
+    set LDFLAGS "$LDFLAGS --image-base 0"
 }
 
 set test_list [lsort [glob -nocomplain $srcdir/$subdir/include*.d]]
index a4aee5205b191aa805f4c2b6b4eed12ac254396f..34aed400a1e0975fea0e19b0c160041afa36a2da 100644 (file)
@@ -31,8 +31,8 @@ if {[istarget "powerpc*-*-aix*"] || [istarget "rs6000-*-aix*"] || [is_aout_forma
 }
 
 set saved_LDFLAGS "$LDFLAGS"
-if [istarget "x86_64-*-mingw*"] then {
-  set LDFLAGS "$LDFLAGS --image-base 0"
+if { [is_pecoff_format] } then {
+    set LDFLAGS "$LDFLAGS --image-base 0"
 }
 
 set test_list [lsort [glob -nocomplain $srcdir/$subdir/provide-*.d]]
index 42bd452d6a1d1a64f723c4ddc866d3b43ff24aec..108e53989fb6ef3cf7b2d8fc78f65a24727e3a4a 100644 (file)
@@ -183,13 +183,10 @@ proc extract_symbol_test { testfile testname } {
 
 # PE targets need to set the image base to 0 to avoid complications from nm.
 set flags ""
-if {[istarget "*-*-pe*"] \
-    || [istarget "*-*-cygwin*"] \
-    || [istarget "*-*-mingw*"] \
-    || [istarget "*-*-winnt*"] \
-    || [istarget "*-*-nt"] \
-    || [istarget "*-*-interix*"] } then {
-  set flags "--image-base 0"
+set old_LDFLAGS $LDFLAGS
+if { [is_pecoff_format] } then {
+    set flags "--image-base 0"
+    set LDFLAGS "$LDFLAGS --image-base 0"
 }
 
 if ![ld_link $ld tmpdir/script "$flags -T $srcdir/$subdir/script.t tmpdir/script.o"] {
@@ -235,3 +232,5 @@ run_dump_test "pr20302"
 run_dump_test "segment-start" {{name (default)}}
 run_dump_test "segment-start" {{name (overridden)} \
                               {ld -Ttext-segment=0x10000000}}
+
+set LDFLAGS $old_LDFLAGS
index b0ca4ab66e7a6437079d73dea62fc3ec33dc6e8f..57986a31d4a9a3ec266c879535dc1b5d6a4863eb 100644 (file)
@@ -44,8 +44,8 @@ if {! [ld_assemble $as $srcdir/$subdir/weak1.s tmpdir/weak1.o]
 }
 
 set saved_LDFLAGS "$LDFLAGS"
-if [istarget "x86_64-*-mingw*"] then {
-  set LDFLAGS "$LDFLAGS --image-base 0"
+if { [is_pecoff_format] } then {
+    set LDFLAGS "$LDFLAGS --image-base 0"
 }
 
 set weak_regexp_big \
This page took 0.028398 seconds and 4 git commands to generate.