#
 # Places a breakpoint in function 'breakpt' and then continues to the
 # breakpoint, at which point it runs 'info threads'.
-proc prepare_for_test { executable disable_multi_process } {
+proc prepare_for_test { executable target_executable disable_multi_process } {
     global GDBFLAGS
 
     save_vars { GDBFLAGS } {
     }
 
     # Start gdbserver and connect.
-    set res [gdbserver_start "" $executable]
+    set res [gdbserver_start "" $target_executable]
     set gdbserver_protocol [lindex $res 0]
     set gdbserver_gdbport [lindex $res 1]
     set res [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
 # we have multiple-threads.  EXECUTABLE is the binary under test, and
 # DISABLE_MULTI_PROCESS indicates if we should disable GDB's remote
 # multi-process support.
-proc run_exit_test { executable disable_multi_process } {
+proc run_exit_test { executable target_executable disable_multi_process } {
     global decimal
 
-    prepare_for_test ${executable} ${disable_multi_process}
+    prepare_for_test ${executable} $target_executable ${disable_multi_process}
 
     # Finally, continue until the process exits, ensure we don't see
     # any warnings between "Continuing." and the final process has
 # while we have multiple-threads.  EXECUTABLE is the binary under
 # test, and DISABLE_MULTI_PROCESS indicates if we should disable GDB's
 # remote multi-process support.
-proc run_signal_test { executable disable_multi_process } {
+proc run_signal_test { executable target_executable disable_multi_process } {
     global decimal gdb_prompt
 
-    prepare_for_test ${executable} ${disable_multi_process}
+    prepare_for_test ${executable} $target_executable ${disable_multi_process}
 
     set inf_pid [get_valueof "/d" "global_pid" "unknown"]
     gdb_assert ![string eq ${inf_pid} "unknown"] "read the pid"
        return -1
     }
 
+    set target_executable [gdb_remote_download target $executable]
+
     foreach_with_prefix multi_process { 0 1 } {
-       $func ${executable} ${multi_process}
+       $func ${executable} $target_executable ${multi_process}
     }
 }
 
     }
 }
 
+set target_binfile [gdb_remote_download target $binfile]
+
 # Make sure we're disconnected, in case we're testing with an
 # extended-remote board, therefore already connected.
 with_test_prefix "preparation" {
 with_test_prefix "first" {
     # Start GDBserver.
     set gdbserver_reconnect_p 1
-    set res [gdbserver_start "" $binfile]
+    set res [gdbserver_start "" $target_binfile]
     set gdbserver_protocol [lindex $res 0]
     set gdbserver_gdbport [lindex $res 1]
 
 
     return -1
 }
 
+set target_binfile [gdb_remote_download target $binfile]
+
 # Test running GDB without providing a local binary for it.  In order
 # to do that, we unset GDBFLAGS before running GDB.  We also start
 # gdbserver "by hand".  For more details about this test, see PR
     gdb_exit
     gdb_start
 
-    gdb_test_no_output "set remote exec-file $binfile" \
+    gdb_test_no_output "set remote exec-file $target_binfile" \
        "set remote exec-file"
 
     # Make sure we're disconnected, in case we're testing with an
 
     return -1
 }
 
+set target_binfile [gdb_remote_download target $binfile]
+
 # Run the tests with different features of GDBserver disabled.
 # TARGET_NON_STOP is passed to "maint set target-non-stop".
 proc run_test { target_non_stop disable_feature } {
     if { $disable_feature != "" } {
        set packet_arg "--disable-packet=${disable_feature}"
     }
-    set res [gdbserver_start $packet_arg $binfile]
+    set res [gdbserver_start $packet_arg $::target_binfile]
     set gdbserver_protocol [lindex $res 0]
     set gdbserver_gdbport [lindex $res 1]
 
 
     return -1
 }
 
+set target_binfile [gdb_remote_download target $binfile]
+
 # Run the tests with different features of GDBserver disabled.
 proc run_test { disable_feature target_nonstop } {
     global binfile gdb_prompt decimal GDBFLAGS
     if { $disable_feature != "" } {
        set packet_arg "--disable-packet=${disable_feature}"
     }
-    set res [gdbserver_start $packet_arg $binfile]
+    set res [gdbserver_start $packet_arg $::target_binfile]
     set gdbserver_protocol [lindex $res 0]
     set gdbserver_gdbport [lindex $res 1]
 
 
 # Don't use $binfile arg, to make sure we use the remote file target:$binfile.
 clean_restart
 
+set target_binfile [gdb_remote_download target $binfile]
+
 # Start gdbserver, and connect to it, twice.
 foreach_with_prefix session {first second} {
-    lassign [gdbserver_start "" "$binfile"] unused gdbserver_address
+    lassign [gdbserver_start "" "$target_binfile"] unused gdbserver_address
     gdb_test "disconnect"
     set res [gdb_target_cmd "remote" $gdbserver_address]
     gdb_assert { $res == 0 } "gdbserver started"