[PATCH 2/3] LD/testsuite: Implement target execution availability check

Maciej W. Rozycki macro@orcam.me.uk
Thu Feb 12 12:46:17 GMT 2026


From: Maciej W. Rozycki <macro@redhat.com>

Complementing `check_compiler_available' procedure for a compilation 
check implement `check_execution_available' that checks whether an 
executable built the same way can actually successfully run on the 
target.
---
 ld/testsuite/lib/ld-lib.exp |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

binutils-ld-test-execution-available.diff
Index: binutils-gdb/ld/testsuite/lib/ld-lib.exp
===================================================================
--- binutils-gdb.orig/ld/testsuite/lib/ld-lib.exp
+++ binutils-gdb/ld/testsuite/lib/ld-lib.exp
@@ -1314,6 +1314,33 @@ proc check_compiler_available { } {
     return $compiler_available_saved
 }
 
+# Return true if we can run a program built with the compiler.
+proc check_execution_available { } {
+    global execution_available_saved
+
+    if { ![info exists execution_available_saved] } {
+	set execution_available_saved 0
+
+	if { ![check_compiler_available] } {
+	    return 0
+	}
+
+	set binfile [make_dummy_target_executable]
+	if { $binfile == "" } {
+	    return 0
+	}
+
+	set status [lindex [remote_load target $binfile] 0]
+	remote_file host delete $binfile
+	if { $status != "pass" } {
+	    return 0
+	}
+
+	set execution_available_saved 1
+    }
+    return $execution_available_saved
+}
+
 # Returns 1 if plugin is enabled in gcc.  Returns 0 otherwise.
 proc check_gcc_plugin_enabled { } {
     global CC_FOR_TARGET


More information about the Binutils mailing list