sim: testsuite: replace global_ld_options with LDFLAGS_FOR_TARGET

Only a few tests actually use global_ld_options, but we can replace the
sim-specific settings with the dejagnu common LDFLAGS_FOR_TARGET and get
the same result.
diff --git a/sim/testsuite/bpf/allinsn.exp b/sim/testsuite/bpf/allinsn.exp
index 2cca770..c138bb8 100644
--- a/sim/testsuite/bpf/allinsn.exp
+++ b/sim/testsuite/bpf/allinsn.exp
@@ -9,10 +9,8 @@
 	set global_sim_options "--memory-size=4Mb"
     }
 
-    global global_ld_options
-    if ![info exists global_ld_options] {
-        set global_ld_options "-Ttext=0x0"
-    }
+    global LDFLAGS_FOR_TARGET
+    set LDFLAGS_FOR_TARGET "-Ttext=0x0"
 
     foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.s]] {
 	# If we're only testing specific files and this isn't one of them,
diff --git a/sim/testsuite/cris/hw/rv-n-cris/rvc.exp b/sim/testsuite/cris/hw/rv-n-cris/rvc.exp
index 908d56a..8203363 100644
--- a/sim/testsuite/cris/hw/rv-n-cris/rvc.exp
+++ b/sim/testsuite/cris/hw/rv-n-cris/rvc.exp
@@ -21,7 +21,6 @@
 proc sim_has_rv_and_cris {} {
     global srcdir
     global subdir
-    global global_ld_options
     global global_sim_options
 
     # We need to assemble and link a trivial program and pass that, in
@@ -31,9 +30,6 @@
     # what we want to do it to run the simulator without affecting the
     # PASS/FAIL counters, and we can use e.g. run_sim_test for that.
 
-    if ![info exists global_ld_options] {
-        set global_ld_options ""
-    }
     if ![info exists global_sim_options] {
         set global_sim_options ""
     }
@@ -47,7 +43,7 @@
 	return 0
     }
 
-    set comp_output [target_link quit.o quit.x "$global_ld_options"]
+    set comp_output [target_link quit.o quit.x ""]
 
     if ![string match "" $comp_output] {
 	verbose -log "$comp_output" 3
@@ -114,12 +110,11 @@
 
 if [istarget cris*-*-*] {
     global ASFLAGS_FOR_TARGET
+    global LDFLAGS_FOR_TARGET
     set has_rv_and_cris [sim_has_rv_and_cris]
-    global global_ld_options
     global global_sim_options
 
     set saved_global_sim_options $global_sim_options
-    set saved_global_ld_options $global_ld_options
 
     # See the logic in sim-defs.exp for more details.
     set sim [board_info target sim]
@@ -162,7 +157,7 @@
 	    }
 
 	    set sim_defaults "--hw-file $srcdir/$subdir/std.dev"
-	    set ld_defaults "--section-start=.text=0"
+	    set LDFLAGS_FOR_TARGET "--section-start=.text=0"
 
 	    # We parse options an extra time besides in run_sim_test,
 	    # to determine if our defaults should be overridden.
@@ -178,10 +173,6 @@
 		if { $opt_name == "sim" && $opt_machs == "" } {
 		    set sim_defaults ""
 		}
-
-		if { $opt_name == "ld" && $opt_machs == "" } {
-		    set ld_defaults ""
-		}
 	    }
 
 	    set rvdummy_id -1
@@ -220,10 +211,8 @@
 	    # Unfortunately this seems like the only way to pass
 	    # additional sim, ld etc. options to run_sim_test.
 	    set global_sim_options "$saved_global_sim_options $sim_defaults"
-	    set global_ld_options "$saved_global_ld_options $ld_defaults"
 	    run_sim_test $src $mach
 	    set global_sim_options $saved_global_sim_options
-	    set global_ld_options $saved_global_ld_options
 
 	    # Stop the rvdummy, if it's still running.  We need to
 	    # wait on it anyway to avoid it turning into a zombie.
diff --git a/sim/testsuite/example-synacor/allinsn.exp b/sim/testsuite/example-synacor/allinsn.exp
index 0f8d856..4c8f653 100644
--- a/sim/testsuite/example-synacor/allinsn.exp
+++ b/sim/testsuite/example-synacor/allinsn.exp
@@ -4,7 +4,8 @@
     # All machines.
     set all_machs "example"
 
-    set global_ld_options "-Ttext=0"
+    global LDFLAGS_FOR_TARGET
+    set LDFLAGS_FOR_TARGET "-Ttext=0"
 
     foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.s]] {
 	# If we're only testing specific files and this isn't one of them,
@@ -15,5 +16,5 @@
 	run_sim_test $src $all_machs
     }
 
-    unset global_ld_options
+    unset LDFLAGS_FOR_TARGET
 }
diff --git a/sim/testsuite/lib/sim-defs.exp b/sim/testsuite/lib/sim-defs.exp
index 68fe2ef..a9431fc 100644
--- a/sim/testsuite/lib/sim-defs.exp
+++ b/sim/testsuite/lib/sim-defs.exp
@@ -185,7 +185,6 @@
     global opts
     global cpu_option
     global cpu_option_sep
-    global global_ld_options
     global global_sim_options
 
     if ![file exists [sim_tool_path]] {
@@ -220,9 +219,6 @@
     set opts(kfail) ""
     set seen_output 0
 
-    if ![info exists global_ld_options] {
-        set global_ld_options ""
-    }
     if ![info exists global_sim_options] {
         set global_sim_options ""
     }
@@ -325,7 +321,7 @@
 	if ![info exists opts(ld,$mach)] {
 	    set opts(ld,$mach) $opts(ld)
 	}
-	regsub {(^ *| +)([^ ]+)} "$opts(ld,$mach) $global_ld_options" { -Wl,\2} c_ld_options
+	regsub {(^ *| +)([^ ]+)} "$opts(ld,$mach)" { -Wl,\2} c_ld_options
 
 	if ![info exists opts(cc,$mach)] {
 	    set opts(cc,$mach) $opts(cc)
@@ -351,7 +347,7 @@
 		continue
 	    }
 
-	    set comp_output [target_link ${name}.o ${name}.x "$opts(ld,$mach) $global_ld_options"]
+	    set comp_output [target_link ${name}.o ${name}.x "$opts(ld,$mach)"]
 	    set method "linking"
 	}
 
diff --git a/sim/testsuite/or1k/alltests.exp b/sim/testsuite/or1k/alltests.exp
index 365f391..701cca6 100644
--- a/sim/testsuite/or1k/alltests.exp
+++ b/sim/testsuite/or1k/alltests.exp
@@ -18,8 +18,8 @@
 if [istarget or1k*-*-*] {
     set all_machs "or1k"
 
-    global global_ld_options
-    set global_ld_options "-T $srcdir/$subdir/or1k-test.ld"
+    global LDFLAGS_FOR_TARGET
+    set LDFLAGS_FOR_TARGET "-T $srcdir/$subdir/or1k-test.ld"
 
     foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.S]] {
 
diff --git a/sim/testsuite/sh/allinsn.exp b/sim/testsuite/sh/allinsn.exp
index 233cd9a..05a28e0 100644
--- a/sim/testsuite/sh/allinsn.exp
+++ b/sim/testsuite/sh/allinsn.exp
@@ -3,12 +3,12 @@
 set all_machs "sh shdsp"
 
 global ASFLAGS_FOR_TARGET
-set global_ld_options ""
+global LDFLAGS_FOR_TARGET
 
 foreach opt $board_variant_list {
     switch "x$opt" {
 	x-ml { set ASFLAGS_FOR_TARGET "-little --defsym LITTLE=1"
-	       set global_ld_options "-EL" }
+	       set LDFLAGS_FOR_TARGET "-EL" }
     }
 }