[AArch64] Also puts value in place for R_AARCH64_RELATIVE
[binutils-gdb.git] / ld / testsuite / ld-sh / sh.exp
index e2978603d5dfe7c6e41744062ff86e88d1ff8e69..4514a98fb93b9474365f5216b84fee9380a16ed4 100644 (file)
@@ -1,19 +1,22 @@
 # Expect script for ld-sh tests
-#   Copyright 1995, 1996, 1997, 2001 Free Software Foundation, Inc.
+#   Copyright (C) 1995-2016 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 +28,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] {
@@ -41,7 +49,7 @@ if ![ld_assemble $as "-relax $srcdir/$subdir/sh1.s" tmpdir/sh1.o] {
            verbose "bad output from nm"
            fail $testsimple
        } else {
-           if {$nm_output(bar) != $nm_output(foo) + 4} {
+           if {$nm_output(bar) != $nm_output(foo) + 0xc} {
                send_log "foo == $nm_output(foo)\n"
                verbose "foo == $nm_output(foo)"
                send_log "bar == $nm_output(bar)\n"
@@ -56,8 +64,10 @@ if ![ld_assemble $as "-relax $srcdir/$subdir/sh1.s" tmpdir/sh1.o] {
 
 set testsrec "SH relaxing to S-records"
 
-if [istarget sh*-linux-gnu] {
-    # This target needs the explicit entry address.
+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 {
@@ -77,7 +87,7 @@ if ![ld_simple_link $ld tmpdir/sh1.s1 $srec_relax_arg ] {
        verbose "$exec_output"
        unresolved $testsrec
     } else {
-       send_log "$objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1"
+       send_log "$objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1\n"
        verbose "$objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1"
        catch "exec $objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1" exec_output
        if ![string match "" $exec_output] {
@@ -100,6 +110,26 @@ if ![ld_simple_link $ld tmpdir/sh1.s1 $srec_relax_arg ] {
     }
 }
 
+set testadjsw8 "SH switch8 adjustment after relax"
+if ![ld_assemble $as "-relax $srcdir/$subdir/adjsw8.s" tmpdir/adjsw8.o] {
+    unresolved $testadjsw8
+} else {
+    if ![ld_simple_link $ld tmpdir/adjsw8 "-relax tmpdir/adjsw8.o"] {
+       fail $testadjsw8
+    } else {
+       send_log "exec $objdump -s tmpdir/adjsw8\n"
+       verbose "exec $objdump -s tmpdir/adjsw8"
+       catch "exec $objdump -s tmpdir/adjsw8" exec_output
+       if [string match "*04080c00*" $exec_output] {
+           pass $testadjsw8
+       } else {
+           send_log "bad switch table\n"
+           verbose "bad switch table"
+           fail $testadjsw8
+       }
+    }
+}
+
 set testlink "SH relaxing"
 set testjsr "SH confirm relaxing"
 set testrun "SH relaxing execution"
@@ -111,7 +141,7 @@ if { [which $CC] == 0 } {
     return
 }
 
-if [istarget sh*-linux-gnu] {
+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 {
@@ -119,7 +149,7 @@ if [istarget sh*-linux-gnu] {
 }
 
 if {![ld_assemble $as "-relax tmpdir/start.s" tmpdir/start.o] \
-    || ![ld_compile $CC "-O -mrelax $srcdir/$subdir/sh2.c" tmpdir/sh2.o]} {
+    || ![ld_compile $CC "-O -mrelax -foptimize-sibling-calls $srcdir/$subdir/sh2.c" tmpdir/sh2.o]} {
     unresolved $testlink
     unresolved $testjsr
     unresolved $testrun
@@ -138,7 +168,8 @@ pass $testlink
 send_log "$objdump -d tmpdir/sh2\n"
 verbose "$objdump -d tmpdir/sh2"
 catch "exec $objdump -d tmpdir/sh2" exec_output
-if [string match "*jsr*" $exec_output] {
+if {[string match "*jsr*" $exec_output]
+    || [string match "*jmp*" $exec_output]} {
     fail $testjsr
 } else {
     pass $testjsr