Update copyright years
[deliverable/binutils-gdb.git] / ld / testsuite / config / default.exp
index bdf3b0872cea867800254c8b70e12e118a7d2d79..9629ac3350ca0fa5d68c7cc21fa2eb67831286a2 100644 (file)
@@ -1,10 +1,11 @@
+# Basic expect script for LD Regression Tests
+#   Copyright (C) 1993-2014 Free Software Foundation, Inc.
 #
-# Expect script for LD Regression Tests
-#   Copyright (C) 1993 Free Software Foundation
+# This file is part of the GNU Binutils.
 #
 # This file is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
 # 
 # This program is distributed in the hope that it will be useful,
 # 
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
-#
-#      $Id$
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
 #
 # Written by Jeffrey Wheat (cassidy@cygnus.com)
 #
 
 if ![info exists ld] then {
-    set ld [findfile $objdir/ld.new $objdir/ld.new [transform ld]]
+    set ld [findfile $base_dir/ld-new $base_dir/ld-new [transform ld]]
 }
 
-# load the utility procedures
-load_lib ld.exp
+if ![info exists as] then {
+    set as [findfile $base_dir/../gas/as-new $base_dir/../gas/as-new [transform as]]
+}
 
-#
-# ld_version -- extract and print the version number of ld compiler (GCC)
-#
-proc ld_version {} {
-    global ld
-    default_ld_version $ld
+if ![info exists nm] then {
+    set nm [findfile $base_dir/../binutils/nm-new $base_dir/../binutils/nm-new [transform nm]]
 }
 
-#
-# ld_load 
-#      load the program, for now, we just execute it
-#
-proc ld_load { target1 target2 } {
-    global exec_output
+if ![info exists objdump] then {
+    set objdump [findfile $base_dir/../binutils/objdump]
+}
+
+if ![info exists objcopy] then {
+    set objcopy [findfile $base_dir/../binutils/objcopy]
+}
+
+if ![info exists ar] then {
+    set ar [findfile $base_dir/../binutils/ar]
+}
+
+if ![info exists strip] then {
+    set strip [findfile $base_dir/../binutils/strip-new $base_dir/../binutils/strip-new [transform strip]]
+}
+
+remote_exec host "mkdir -p tmpdir"
 
-    if ![file exists $target1] then {
-       unresolved "$target1 does not exist."
+# Make a symlink from tmpdir/as to the assembler in the build tree, so
+# that we can use a -B option to gcc to force it to use the newly
+# built assembler.
+if {![file isdirectory tmpdir/gas]} then {
+    catch "exec mkdir tmpdir/gas" status
+    catch "exec ln -s ../../../gas/as-new tmpdir/gas/as" status
+}
+set gcc_gas_flag "-B[pwd]/tmpdir/gas/"
+
+# Make a symlink from tmpdir/ld to the linker in the build tree, so
+# that we can use a -B option to gcc to force it to use the newly
+# built linker. 
+if {![file isdirectory tmpdir/ld]} then {
+    catch "exec mkdir tmpdir/ld" status
+    catch "exec ln -s ../../ld-new tmpdir/ld/ld" status
+    catch "exec ln -s ld tmpdir/ld/collect-ld" status
+}
+set gcc_ld_flag "-B[pwd]/tmpdir/ld/"
+
+# load the linker path
+if {[file exists tmpdir/libpath.exp]} {
+    load_lib tmpdir/libpath.exp
+
+    foreach dir $libpath {
+       set gcc_ld_flag "$gcc_ld_flag -L$dir"
     }
+}
+
+# The "make check" target in the Makefile passes in
+# "CC=$(CC_FOR_TARGET)".  But, if the user invokes runtest directly
+# (as when testing an installed linker), these flags may not be set.  
+if {![info exists CC]} {
+    set CC [find_gcc]
+}
+if {![info exists CFLAGS]} {
+    set CFLAGS "-g -O2"
+}
+if {![info exists CXX]} {
+    set CXX [find_g++]
+}
+if {![info exists CXXFLAGS]} {
+    set CXXFLAGS ""
+}
 
-    if ![file exists $target2] then {
-       unresolved "$target2 does not exist."
+# The mips64-*-linux-gnu compiler defaults to the N32 ABI after
+# installed, but to the O32 ABI in the build tree, because of some
+# specs-file hacks.  Make sure we use an ABI that is compatible with
+# the one we expect.
+if {[istarget mips64*-*-linux*] &&
+    (![board_info [target_info name] exists multilib_flags] ||
+     ![string match "*-mabi" [board_info [target_info name] multilib_flags]])
+   } {
+    append gcc_gas_flag " -mabi=n32"
+}
+
+# load the utility procedures
+load_lib ld-lib.exp
+
+proc get_link_files {varname} {
+    global $varname
+    global target_triplet
+    global srcdir
+    global CC
+    if ![info exists $varname] {
+       #configure.host returns variables that can be substituted into
+       #makefile rules, with embedded shell variable expansions.
+       #make wants $$shell_var, we want $shell_var ...
+       set cmd "host='$target_triplet' && . $srcdir/../configure.host && sed -e 's,\\\$\\\$,\$,g' <<EOF\n\$$varname\nEOF"
+       set status [catch "exec sh -c [list $cmd]" result]
+       if $status { error "Error getting native link files: $result" }
+       set cmd "CC='$CC' && eval echo \"$result\""
+       set status [catch "exec sh -c [list $cmd]" result]
+       if $status { error "Error getting native link files: $result" }
+       set $varname $result
+       send_log "$varname = $result\n"
     }
+}
+
+proc get_target_emul {} {
+    global target_triplet
+    global srcdir
+    set status [catch "exec sh -c \"targ='$target_triplet' && . $srcdir/../configure.tgt && echo \\\$targ_emul\"" result]
+    if $status { error "Error getting emulation name: $result" }
+    return $result
+}
 
-    set status [catch "exec cmp $target1 $target2" exec_output]
-    verbose "### COMPARE $target1 $target2\n"
-    if ![string match "" $exec_output] then {
-       send_log "$exec_output\n"
-       verbose "$exec_output" 1
-       return 1
-    } else {
-       return 0
+if [isnative] {
+    foreach x {HOSTING_CRT0 HOSTING_SCRT0 HOSTING_LIBS HOSTING_SLIBS} {
+       get_link_files $x
     }
+} else {
+    foreach x {HOSTING_CRT0 HOSTING_SCRT0 HOSTING_LIBS HOSTING_SLIBS} { set $x "" }
+}
+if ![info exists HOSTING_EMU] { set HOSTING_EMU "-m [get_target_emul]" }
+
+#
+# ld_version -- extract and print the version number of ld compiler (GCC)
+#
+proc ld_version {} {
+    global ld
+    default_ld_version $ld
 }
 
 #
@@ -113,15 +205,23 @@ proc ld_compile { cc source object } {
 #      assemble a file
 #
 proc ld_assemble { as source object } {
-       default_ld_assemble $as $source $object 
+       default_ld_assemble $as "" $source $object 
+}
+
+#
+# ld_assemble_flags
+#      assemble a file with extra flags
+#
+proc ld_assemble_flags { as flags source object } {
+       default_ld_assemble $as $flags $source $object 
 }
 
 #
 # ld_nm
 #      run nm on a file
 #
-proc ld_nm { nm object } {
-       default_ld_nm $nm $object
+proc ld_nm { nm nmflags object } {
+       default_ld_nm $nm $nmflags $object
 }
 
 #
@@ -132,3 +232,55 @@ proc ld_exec { target output } {
        default_ld_exec $target $output
 }
 
+# From gas-defs.exp, to support run_dump_test.
+if ![info exists AS] then {
+    set AS $as
+}
+
+if ![info exists GASP] then {
+    set GASP [findfile $base_dir/../gas/gasp-new $base_dir/../gas/gasp-new [transform gasp]]
+}
+
+if ![info exists ASFLAGS] then {
+    set ASFLAGS ""
+}
+
+if ![info exists OBJDUMP] then {
+    set OBJDUMP $objdump
+}
+
+if ![info exists OBJDUMPFLAGS] then {
+    set OBJDUMPFLAGS {}
+}
+
+if ![info exists NM] then {
+    set NM $nm
+}
+
+if ![info exists NMFLAGS] then {
+    set NMFLAGS {}
+}
+
+if ![info exists OBJCOPY] then {
+    set OBJCOPY $objcopy
+}
+
+if ![info exists OBJCOPYFLAGS] then {
+    set OBJCOPYFLAGS {}
+}
+
+if ![info exists READELF] then {
+    set READELF [findfile $base_dir/../binutils/readelf]
+}
+
+if ![info exists READELFFLAGS] then {
+    set READELFFLAGS {}
+}
+
+if ![info exists LD] then {
+    set LD [findfile $base_dir/ld-new ./ld-new [transform ld]]
+}
+
+if ![info exists LDFLAGS] then {
+    set LDFLAGS {}
+}
This page took 0.025281 seconds and 4 git commands to generate.