Remove unused file_string parameter in gdb_disassembly
[deliverable/binutils-gdb.git] / ld / testsuite / lib / ld-lib.exp
index d3bda4dc59204199acfdbd575866cde6e85172a4..a44358e0aaace22514f1b3a770ff4e9be1938136 100644 (file)
@@ -199,41 +199,9 @@ proc big_or_little_endian {} {
     return $flags
 }
 
-# Link a program using ld.
+# Link a program using ld
 #
 proc default_ld_link { ld target objects } {
-    global HOSTING_EMU
-    global HOSTING_CRT0
-    global HOSTING_SCRT0
-    global HOSTING_LIBS
-    global HOSTING_SLIBS
-    global LIBS
-    global host_triplet
-    global link_output
-    global exec_output
-
-    if { [ string match "* -pie *" $objects ] } {
-       set objs "$HOSTING_SCRT0 $objects"
-       set libs "$LIBS $HOSTING_SLIBS"
-    } else {
-       set objs "$HOSTING_CRT0 $objects"
-       set libs "$LIBS $HOSTING_LIBS"
-    }
-
-    if [is_endian_output_format $objects] then {
-       set flags [big_or_little_endian]
-    } else {
-       set flags ""
-    }
-
-    remote_file host delete $target
-
-    return [run_host_cmd_yesno "$ld" "$HOSTING_EMU $flags -o $target $objs $libs"]
-}
-
-# Link a program using ld, without including any libraries.
-#
-proc default_ld_simple_link { ld target objects } {
     global host_triplet
     global exec_output
 
@@ -409,7 +377,7 @@ proc default_ld_nm { nm nmflags object } {
 
 # Define various symbols needed when not linking against all
 # target libs.
-proc ld_simple_link_defsyms {} {
+proc ld_link_defsyms {} {
 
     set flags "--defsym __stack_chk_fail=0"
 
@@ -1269,7 +1237,7 @@ proc run_ld_link_tests { ldtests args } {
            if { ![ar_simple_create $ar $ld_options $binfile "$objfiles $ld_after"] } {
                set failed 1
            }
-       } elseif { ![ld_simple_link $ld $binfile "$ld_extra_opt -L$srcdir/$subdir $ld_options $objfiles $ld_after"] } {
+       } elseif { ![ld_link $ld $binfile "$ld_extra_opt -L$srcdir/$subdir $ld_options $objfiles $ld_after"] } {
            set maybe_failed 1
            set ld_output "$exec_output"
        }
@@ -1413,6 +1381,17 @@ proc run_ld_link_exec_tests { ldtests args } {
     global CXXFLAGS
     global errcnt
     global exec_output
+    global board_cflags
+
+    # When using GCC as the linker driver, we need to specify board cflags when
+    # linking because cflags may contain linker options.  For example when
+    # linker options are included in GCC spec files then we need the -specs
+    # option.
+    if [board_info [target_info name] exists cflags] {
+        set board_cflags " [board_info [target_info name] cflags]"
+    } else {
+       set board_cflags ""
+    }
 
     foreach testitem $ldtests {
        foreach target $args {
@@ -1446,33 +1425,33 @@ proc run_ld_link_exec_tests { ldtests args } {
            # incorrect section attributes and the assembler will warn
            # them.
            if { [ string match "c++" $lang ] } {
-               ld_compile "$CXX -c $CXXFLAGS $cflags" $srcdir/$subdir/$src_file $objfile
+               set cmd "$CXX -c $CXXFLAGS $cflags"
            } else {
-               ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/$src_file $objfile
+               set cmd "$CC -c $CFLAGS $cflags"
+           }
+           if ![ld_compile $cmd $srcdir/$subdir/$src_file $objfile] {
+               set failed 1
+               break
            }
        }
+       if { $failed != 0 } {
+           unresolved $testname
+           continue
+       }
 
-       # We have to use $CC to build PIE and shared library.
-       if { [ string match "c" $lang ] } {
-           set link_proc ld_simple_link
-           set link_cmd $CC
-       } elseif { [ string match "c++" $lang ] } {
-           set link_proc ld_simple_link
+       if { [ string match "c++" $lang ] } {
+           set link_proc ld_link
            set link_cmd $CXX
-       } elseif { [ string match "-shared" $ld_options ] \
-                  || [ string match "-pie" $ld_options ] } {
-           set link_proc ld_simple_link
-           set link_cmd $CC
        } else {
            set link_proc ld_link
-           set link_cmd $ld
+           set link_cmd $CC
        }
 
        if { $binfile eq "tmpdir/" } {
            # compile only
            pass $testname
            continue;
-       } elseif ![$link_proc $link_cmd $binfile "-L$srcdir/$subdir $ld_options $objfiles"] {
+       } elseif ![$link_proc $link_cmd $binfile "$board_cflags -L$srcdir/$subdir $ld_options $objfiles"] {
            set failed 1
        }
 
@@ -1486,7 +1465,7 @@ proc run_ld_link_exec_tests { ldtests args } {
            }
        }
 
-       if { $failed == 0 } {
+       if { $failed == 0 && [isnative] } {
            send_log "Running: $binfile > $binfile.out\n"
            verbose "Running: $binfile > $binfile.out"
            catch "exec $binfile > $binfile.out" exec_output
@@ -1511,6 +1490,8 @@ proc run_ld_link_exec_tests { ldtests args } {
 
        if { $failed != 0 } {
            fail $testname
+       } elseif ![isnative] {
+           unsupported $testname
        } else {
            set errcnt 0
            pass $testname
@@ -1587,10 +1568,18 @@ proc run_cc_link_tests { ldtests } {
            # incorrect section attributes and the assembler will warn
            # them.
            if { [ string match "c++" $lang ] } {
-               ld_compile "$CXX -c $CXXFLAGS $cflags" $srcdir/$subdir/$src_file $objfile
+               set cmd "$CXX -c $CXXFLAGS $cflags"
            } else {
-               ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/$src_file $objfile
+               set cmd "$CC -c $CFLAGS $cflags"
            }
+           if ![ld_compile $cmd $srcdir/$subdir/$src_file $objfile] {
+               set failed 1
+               break
+           }
+       }
+       if { $failed != 0 } {
+           unresolved $testname
+           continue
        }
 
        # Clear error and warning counts.
@@ -1609,7 +1598,7 @@ proc run_cc_link_tests { ldtests } {
                set failed 1
            }
        } else {
-           if { ![ld_simple_link $cc_cmd $binfile "$board_cflags -L$srcdir/$subdir $ldflags $objfiles"] } {
+           if { ![ld_link $cc_cmd $binfile "$board_cflags -L$srcdir/$subdir $ldflags $objfiles"] } {
                set failed 1
            }
 
This page took 0.025448 seconds and 4 git commands to generate.