daily update
[external/binutils.git] / ld / testsuite / ld-sh / sh.exp
index 41ca809..66bdc39 100644 (file)
@@ -1,19 +1,23 @@
 # Expect script for ld-sh tests
-#   Copyright 1995, 1996, 1997, 2001 Free Software Foundation, Inc.
+#   Copyright 1995, 1996, 1997, 2001, 2002, 2003, 2007
+#   Free Software Foundation, Inc.
 #
-# This file is free software; you can redistribute it and/or modify
+# This file is part of the GNU Binutils.
+#
+# This program 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,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
 #
 # Written by Ian Lance Taylor (ian@cygnus.com)
 #
@@ -25,6 +29,11 @@ if ![istarget sh*-*-*] {
     return
 }
 
+if { ([istarget sh64*-*-*] || [istarget sh5*-*-*])} {
+    # relaxing not supported on sh64 yet.
+    return
+}
+
 set testsimple "SH simple relaxing"
 
 if ![ld_assemble $as "-relax $srcdir/$subdir/sh1.s" tmpdir/sh1.o] {
@@ -32,7 +41,7 @@ if ![ld_assemble $as "-relax $srcdir/$subdir/sh1.s" tmpdir/sh1.o] {
 } else { if ![ld_simple_link $ld tmpdir/sh1 "-relax tmpdir/sh1.o"] {
     fail $testsimple
 } else {
-    if ![ld_nm $nm tmpdir/sh1] {
+    if ![ld_nm $nm "" tmpdir/sh1] {
        unresolved $testsimple
     } else {
        if {![info exists nm_output(bar)] \
@@ -56,7 +65,16 @@ if ![ld_assemble $as "-relax $srcdir/$subdir/sh1.s" tmpdir/sh1.o] {
 
 set testsrec "SH relaxing to S-records"
 
-if ![ld_simple_link $ld tmpdir/sh1.s1 "-relax --oformat srec tmpdir/sh1.o"] {
+if { [istarget sh*-linux-*] || [istarget sh-*-vxworks] } {
+    # On these "non-embedded" targets, the default ELF and srec start
+    # addresses will be SIZEOF_HEADERS bytes apart.  Ensure consistency
+    # by feeding the ELF start address to the srec link line.
+    catch "exec $objdump -x tmpdir/sh1 | grep start\\ address | sed s/start\\ address//" entry_addr
+    set srec_relax_arg "-Ttext $entry_addr -relax --oformat srec tmpdir/sh1.o"
+} else {
+    set srec_relax_arg "-relax --oformat srec tmpdir/sh1.o"
+}
+if ![ld_simple_link $ld tmpdir/sh1.s1 $srec_relax_arg ] {
     fail $testsrec
 } else {
     # The file name is embedded in the S-records, so create both
@@ -104,8 +122,15 @@ if { [which $CC] == 0 } {
     return
 }
 
-if {![ld_assemble $as "-relax $srcdir/$subdir/start.s" tmpdir/start.o] \
-     || ![ld_compile $CC "-O -mrelax $srcdir/$subdir/sh2.c" tmpdir/sh2.o]} {
+if [istarget sh*-linux-*] {
+    exec sed -e s/_main/main/ -e s/_trap/trap/ -e s/_stack/stack/ \
+           < $srcdir/$subdir/start.s >tmpdir/start.s
+} else {
+    exec cp $srcdir/$subdir/start.s tmpdir/start.s
+}
+
+if {![ld_assemble $as "-relax tmpdir/start.s" tmpdir/start.o] \
+    || ![ld_compile $CC "-O -mrelax $srcdir/$subdir/sh2.c" tmpdir/sh2.o]} {
     unresolved $testlink
     unresolved $testjsr
     unresolved $testrun