OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [binutils-2.18.50/] [ld/] [testsuite/] [ld-sh/] [sh.exp] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
# Expect script for ld-sh tests
2
#   Copyright 1995, 1996, 1997, 2001, 2002, 2003, 2007
3
#   Free Software Foundation, Inc.
4
#
5
# This file is part of the GNU Binutils.
6
#
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20
# MA 02110-1301, USA.
21
#
22
# Written by Ian Lance Taylor (ian@cygnus.com)
23
#
24
 
25
# Test SH relaxing.  This tests the compiler and assembler as well as
26
# the linker.
27
 
28
if ![istarget sh*-*-*] {
29
    return
30
}
31
 
32
if { ([istarget sh64*-*-*] || [istarget sh5*-*-*])} {
33
    # relaxing not supported on sh64 yet.
34
    return
35
}
36
 
37
set testsimple "SH simple relaxing"
38
 
39
if ![ld_assemble $as "-relax $srcdir/$subdir/sh1.s" tmpdir/sh1.o] {
40
    unresolved $testsimple
41
} else { if ![ld_simple_link $ld tmpdir/sh1 "-relax tmpdir/sh1.o"] {
42
    fail $testsimple
43
} else {
44
    if ![ld_nm $nm "" tmpdir/sh1] {
45
        unresolved $testsimple
46
    } else {
47
        if {![info exists nm_output(bar)] \
48
             || ![info exists nm_output(foo)]} {
49
            send_log "bad output from nm\n"
50
            verbose "bad output from nm"
51
            fail $testsimple
52
        } else {
53
            if {$nm_output(bar) != $nm_output(foo) + 4} {
54
                send_log "foo == $nm_output(foo)\n"
55
                verbose "foo == $nm_output(foo)"
56
                send_log "bar == $nm_output(bar)\n"
57
                verbose "bar == $nm_output(bar)"
58
                fail $testsimple
59
            } else {
60
                pass $testsimple
61
            }
62
        }
63
    }
64
} }
65
 
66
set testsrec "SH relaxing to S-records"
67
 
68
if { [istarget sh*-linux-*] || [istarget sh-*-vxworks] } {
69
    # On these "non-embedded" targets, the default ELF and srec start
70
    # addresses will be SIZEOF_HEADERS bytes apart.  Ensure consistency
71
    # by feeding the ELF start address to the srec link line.
72
    catch "exec $objdump -x tmpdir/sh1 | grep start\\ address | sed s/start\\ address//" entry_addr
73
    set srec_relax_arg "-Ttext $entry_addr -relax --oformat srec tmpdir/sh1.o"
74
} else {
75
    set srec_relax_arg "-relax --oformat srec tmpdir/sh1.o"
76
}
77
if ![ld_simple_link $ld tmpdir/sh1.s1 $srec_relax_arg ] {
78
    fail $testsrec
79
} else {
80
    # The file name is embedded in the S-records, so create both
81
    # files with the same name.
82
    catch "exec rm -f tmpdir/sh1.s2" exec_output
83
    send_log "mv tmpdir/sh1.s1 tmpdir/sh1.s2\n"
84
    verbose "mv tmpdir/sh1.s1 tmpdir/sh1.s2"
85
    catch "exec mv tmpdir/sh1.s1 tmpdir/sh1.s2" exec_output
86
    if ![string match "" $exec_output] {
87
        send_log "$exec_output\n"
88
        verbose "$exec_output"
89
        unresolved $testsrec
90
    } else {
91
        send_log "$objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1"
92
        verbose "$objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1"
93
        catch "exec $objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1" exec_output
94
        if ![string match "" $exec_output] {
95
            send_log "$exec_output\n"
96
            verbose "$exec_output"
97
            unresolved $testsrec
98
        } else {
99
            send_log "cmp tmpdir/sh1.s1 tmpdir/sh1.s2\n"
100
            verbose "cmp tmpdir/sh1.s1 tmpdir/sh1.s2"
101
            catch "exec cmp tmpdir/sh1.s1 tmpdir/sh1.s2" exec_output
102
            set exec_output [prune_warnings $exec_output]
103
            if ![string match "" $exec_output] {
104
                send_log "$exec_output\n"
105
                verbose "$exec_output"
106
                fail $testsrec
107
            } else {
108
                pass $testsrec
109
            }
110
        }
111
    }
112
}
113
 
114
set testlink "SH relaxing"
115
set testjsr "SH confirm relaxing"
116
set testrun "SH relaxing execution"
117
 
118
if { [which $CC] == 0 } {
119
    untested $testlink
120
    untested $testjsr
121
    untested $testrun
122
    return
123
}
124
 
125
if [istarget sh*-linux-*] {
126
    exec sed -e s/_main/main/ -e s/_trap/trap/ -e s/_stack/stack/ \
127
            < $srcdir/$subdir/start.s >tmpdir/start.s
128
} else {
129
    exec cp $srcdir/$subdir/start.s tmpdir/start.s
130
}
131
 
132
if {![ld_assemble $as "-relax tmpdir/start.s" tmpdir/start.o] \
133
    || ![ld_compile $CC "-O -mrelax $srcdir/$subdir/sh2.c" tmpdir/sh2.o]} {
134
    unresolved $testlink
135
    unresolved $testjsr
136
    unresolved $testrun
137
    return
138
}
139
 
140
if ![ld_simple_link $ld tmpdir/sh2 "-relax tmpdir/start.o tmpdir/sh2.o"] {
141
    fail $testlink
142
    unresolved $testjsr
143
    unresolved $testrun
144
    return
145
}
146
 
147
pass $testlink
148
 
149
send_log "$objdump -d tmpdir/sh2\n"
150
verbose "$objdump -d tmpdir/sh2"
151
catch "exec $objdump -d tmpdir/sh2" exec_output
152
if [string match "*jsr*" $exec_output] {
153
    fail $testjsr
154
} else {
155
    pass $testjsr
156
}
157
 
158
if { ![info exists SIM] || [which $SIM] == 0 } {
159
    untested $testrun
160
    return
161
}
162
 
163
set status [catch "exec $SIM tmpdir/sh2" exec_output]
164
if { $status == 0 } {
165
    pass $testrun
166
} else {
167
    fail $testrun
168
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.