diff options
author | Richard Henderson <rth@redhat.com> | 1999-05-03 07:29:11 +0000 |
---|---|---|
committer | Richard Henderson <rth@redhat.com> | 1999-05-03 07:29:11 +0000 |
commit | 252b5132c753830d5fd56823373aed85f2a0db63 (patch) | |
tree | 1af963bfd8d3e55167b81def4207f175eaff3a56 /ld/testsuite/ld-sh | |
download | gdb-252b5132c753830d5fd56823373aed85f2a0db63.zip gdb-252b5132c753830d5fd56823373aed85f2a0db63.tar.gz gdb-252b5132c753830d5fd56823373aed85f2a0db63.tar.bz2 |
19990502 sourceware importbinu_ss_19990502
Diffstat (limited to 'ld/testsuite/ld-sh')
-rw-r--r-- | ld/testsuite/ld-sh/sh.exp | 143 | ||||
-rw-r--r-- | ld/testsuite/ld-sh/sh1.s | 13 | ||||
-rw-r--r-- | ld/testsuite/ld-sh/sh2.c | 120 | ||||
-rw-r--r-- | ld/testsuite/ld-sh/start.s | 27 |
4 files changed, 303 insertions, 0 deletions
diff --git a/ld/testsuite/ld-sh/sh.exp b/ld/testsuite/ld-sh/sh.exp new file mode 100644 index 0000000..c646d26 --- /dev/null +++ b/ld/testsuite/ld-sh/sh.exp @@ -0,0 +1,143 @@ +# Expect script for ld-sh tests +# Copyright (C) 1995, 1996, 1997 Free Software Foundation +# +# 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 +# (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. +# +# Written by Ian Lance Taylor (ian@cygnus.com) +# + +# Test SH relaxing. This tests the compiler and assembler as well as +# the linker. + +if ![istarget sh*-*-*] { + return +} + +set testsimple "SH simple relaxing" + +if ![ld_assemble $as "-relax $srcdir/$subdir/sh1.s" tmpdir/sh1.o] { + unresolved $testsimple +} else { if ![ld_simple_link $ld tmpdir/sh1 "-relax tmpdir/sh1.o"] { + fail $testsimple +} else { + if ![ld_nm $nm tmpdir/sh1] { + unresolved $testsimple + } else { + if {![info exists nm_output(bar)] \ + || ![info exists nm_output(foo)]} { + send_log "bad output from nm\n" + verbose "bad output from nm" + fail $testsimple + } else { + if {$nm_output(bar) != $nm_output(foo) + 4} { + send_log "foo == $nm_output(foo)\n" + verbose "foo == $nm_output(foo)" + send_log "bar == $nm_output(bar)\n" + verbose "bar == $nm_output(bar)" + fail $testsimple + } else { + pass $testsimple + } + } + } +} } + +set testsrec "SH relaxing to S-records" + +if ![ld_simple_link $ld tmpdir/sh1.s1 "-relax -oformat srec tmpdir/sh1.o"] { + fail $testsrec +} else { + # The file name is embedded in the S-records, so create both + # files with the same name. + catch "exec rm -f tmpdir/sh1.s2" exec_output + send_log "mv tmpdir/sh1.s1 tmpdir/sh1.s2\n" + verbose "mv tmpdir/sh1.s1 tmpdir/sh1.s2" + catch "exec mv tmpdir/sh1.s1 tmpdir/sh1.s2" exec_output + if ![string match "" $exec_output] { + send_log "$exec_output\n" + verbose "$exec_output" + unresolved $testsrec + } else { + send_log "$objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1" + 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] { + send_log "$exec_output\n" + verbose "$exec_output" + unresolved $testsrec + } else { + send_log "cmp tmpdir/sh1.s1 tmpdir/sh1.s2\n" + verbose "cmp tmpdir/sh1.s1 tmpdir/sh1.s2" + catch "exec cmp tmpdir/sh1.s1 tmpdir/sh1.s2" exec_output + set exec_output [prune_warnings $exec_output] + if ![string match "" $exec_output] { + send_log "$exec_output\n" + verbose "$exec_output" + fail $testsrec + } else { + pass $testsrec + } + } + } +} + +set testlink "SH relaxing" +set testjsr "SH confirm relaxing" +set testrun "SH relaxing execution" + +if { [which $CC] == 0 } { + untested $testlink + untested $testjsr + untested $testrun + 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]} { + unresolved $testlink + unresolved $testjsr + unresolved $testrun + return +} + +if ![ld_simple_link $ld tmpdir/sh2 "-relax tmpdir/start.o tmpdir/sh2.o"] { + fail $testlink + unresolved $testjsr + unresolved $testrun + return +} + +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] { + fail $testjsr +} else { + pass $testjsr +} + +if { ![info exists SIM] || [which $SIM] == 0 } { + untested $testrun + return +} + +set status [catch "exec $SIM tmpdir/sh2" exec_output] +if { $status == 0 } { + pass $testrun +} else { + fail $testrun +} diff --git a/ld/testsuite/ld-sh/sh1.s b/ld/testsuite/ld-sh/sh1.s new file mode 100644 index 0000000..d18e439 --- /dev/null +++ b/ld/testsuite/ld-sh/sh1.s @@ -0,0 +1,13 @@ + .text +foo: +L1: + mov.l L2,r0 + .uses L1 + jsr @r0 + rts + .align 2 +L2: + .long bar +bar: + rts + .align 4 diff --git a/ld/testsuite/ld-sh/sh2.c b/ld/testsuite/ld-sh/sh2.c new file mode 100644 index 0000000..527fe88 --- /dev/null +++ b/ld/testsuite/ld-sh/sh2.c @@ -0,0 +1,120 @@ +int global; + +extern void trap (int, int); +static void quit (int); +static int foo (int); + +int +main () +{ + if (foo (0) != 0 || global != 0) + quit (1); + if (foo (1) != 1 || global != 1) + quit (1); + if (foo (2) != 2 || global != 2) + quit (1); + if (foo (3) != 3 || global != 3) + quit (1); + if (foo (4) != 4 || global != 4) + quit (1); + if (foo (5) != 5 || global != 5) + quit (1); + if (foo (6) != 6 || global != 6) + quit (1); + if (foo (7) != 7 || global != 7) + quit (1); + if (foo (8) != 8 || global != 8) + quit (1); + quit (0); +} + +void +__main () +{ +} + +static void +quit (int status) +{ + trap (1, status); +} + +int +bar (int i) +{ + global = i; + return i; +} + +int +bar0 (int i) +{ + global = 0; + return i; +} + +int +bar1 (int i) +{ + global = 1; + return i; +} + +int +bar2 (int i) +{ + global = 2; + return i; +} + +int +bar3 (int i) +{ + global = 3; + return i; +} + +int +bar4 (int i) +{ + global = 4; + return i; +} + +int +bar5 (int i) +{ + global = 5; + return i; +} + +int +bar6 (int i) +{ + global = 6; + return i; +} + +int +bar7 (int i) +{ + global = 7; + return i; +} + +int +foo (int i) +{ + switch (i) + { + case 0: bar0 (0); return 0; + case 1: bar1 (1); return 1; + case 2: bar2 (2); return 2; + case 3: bar3 (3); return 3; + case 4: bar4 (4); return 4; + case 5: bar5 (5); return 5; + case 6: bar6 (6); return 6; + case 7: bar7 (7); return 7; + default: return bar (i); + } +} diff --git a/ld/testsuite/ld-sh/start.s b/ld/testsuite/ld-sh/start.s new file mode 100644 index 0000000..2af4c79 --- /dev/null +++ b/ld/testsuite/ld-sh/start.s @@ -0,0 +1,27 @@ + .section .text + .global start +start: + + mov.l stack_k,r15 + + ! call the mainline +L1: + mov.l main_k,r0 + .uses L1 + jsr @r0 + nop + + .align 2 +stack_k: + .long _stack +main_k: + .long _main + + .global _trap +_trap: + trapa #3 + rts + nop + + .section .stack +_stack: .long 0xdeaddead |