[PATCH] ld: Run ld-scripts/fill2 only for BFD64

H.J. Lu hjl.tools@gmail.com
Sat Dec 30 14:55:06 GMT 2023


FILL ($0001020304050607) in fil2.t has the value read by strtoul (via
scan_bfd_vma in ldlex.l), and strtoul returns -1 on overflow when BFD64
isn't defined.  Add is_bfd64 and don't run ld-scripts/fill2 if is_bfd64
returns 0.

	PR ld/31120
	* testsuite/config/default.exp (is_bfd64): New.
	* testsuite/ld-scripts/fill2.d (notarget): Add ![is_bfd64].
---
 ld/testsuite/config/default.exp | 23 +++++++++++++++++++++++
 ld/testsuite/ld-scripts/fill2.d |  2 +-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
index 5c925476e23..4b3e4706316 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -512,3 +512,26 @@ if {[file exists .libs/libdep.so]} {
 } else {
     set dep_plug_opt ""
 }
+
+# Return 1 if BFD64 is defined.
+proc is_bfd64 { } {
+    global IS_BFD64
+    if { ![info exists IS_BFD64] } then {
+	global CC
+	set fn "cs[pid].c"
+	set rfno "cs[pid].o"
+	set f [open $fn "w"]
+	puts $f "#include <config.h>"
+	puts $f "#include <bfd.h>"
+	puts $f "#ifndef BFD64"
+	puts $f "# error Failed"
+	puts $f "#endif"
+	close $f
+	set rfn [remote_download host $fn]
+	set IS_BFD64 [run_host_cmd_yesno "$CC" "-I../bfd -c $rfn -o $rfno"]
+	remote_file host delete $rfno
+	remote_file host delete $rfn
+	file delete $fn
+    }
+    return $IS_BFD64
+}
diff --git a/ld/testsuite/ld-scripts/fill2.d b/ld/testsuite/ld-scripts/fill2.d
index f913a82a017..05383b98fad 100644
--- a/ld/testsuite/ld-scripts/fill2.d
+++ b/ld/testsuite/ld-scripts/fill2.d
@@ -1,7 +1,7 @@
 #source: fill_0.s
 #ld: -T fill2.t
 #readelf: -x.foo
-#notarget: ![is_elf_format]
+#notarget: ![is_elf_format] ![is_bfd64]
 # See PR 30865 - a fill value expressed as a simple hexadecimal
 # number behaves differently from other fill values.
 
-- 
2.43.0



More information about the Binutils mailing list