* config/tc-mn10300.c (mn10300_force_relocation): Force a reloc to be generated for...
[external/binutils.git] / ld / testsuite / ld-mn10300 / mn10300.exp
1 # Expect script for ld-mn10300 tests
2 #   Copyright (C) 2007 Free Software Foundation
3 #
4 # This file is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 #
18
19 if {!([istarget "am3*-*-*"]) && !([istarget "mn10300*-*-*"]) } {
20     return
21 }
22
23 # Set up a list as described in ld-lib.exp
24
25 set mn10300_tests {
26     {
27         "am33 string merging"
28         "-relax -Ttext 0x8000074"
29         ""
30         { "i36434.s" "i36434-2.s" }
31         { {objdump -dz i36434.d} }
32         "i36434.x"
33     }
34     {
35         "difference of two same-section symbols"
36         "-Ttext 0"
37         ""
38         { "i112045-1.s" }
39         { {objdump -d i112045-1.d} }
40         "i112045-1.x"
41     }
42     {
43         "difference of two same-section symbols where the difference is held in another section"
44         "-relax -Ttext 100"
45         ""
46         { "i112045-3.s" }
47         { {objdump -D i112045-3.d} }
48         "i112045-3.x"
49     }
50     {
51         "relaxation and alignment directives"
52         "-relax -Ttext 100"
53         ""
54         { "i127740.s" }
55         { {objdump -d i127740.d} }
56         "i127740.x"
57     }
58     {
59         "adjustment of symbols due to relaxation"
60         "-Tdata 1f -Ttext 0 -relax"
61         ""
62         { "i135409-1.s" }
63         { {readelf --syms i135409-1.d} }
64         "i135409-1.x"
65     }
66     {
67         "adjustment of symbols due to relaxation (with alignment directives)"
68         "-Tdata 1f -Ttext 0 -relax"
69         ""
70         { "i135409-2.s" }
71         { {readelf --syms i135409-2.d} }
72         "i135409-2.x"
73     }
74     {
75         "adjustment of symbols due to relaxation (with a symbol in the deleted region)"
76         "-Tdata 1f -Ttext 0 -relax"
77         ""
78         { "i135409-3.s" }
79         { {objdump -d i135409-3.d} }
80         "i135409-3.x"
81     }
82 }
83
84 run_ld_link_tests $mn10300_tests
85
86 if {!([istarget "am3*-*-*"])} {
87     return
88 }
89
90 set am33_tests {
91     {
92         "difference of two same-section symbols (in a shared library)"
93         "-shared"
94         ""
95         { "i112045-2.s" }
96         { {objdump -R i112045-2.d} }
97         "i112045-2.x"
98     }
99 }
100
101 run_ld_link_tests $am33_tests
102
103 proc i126256-test { } {
104     global CC
105     global ld
106     global srcdir
107     global subdir
108
109     set tmpdir tmpdir
110     set testname "Seg fault whilst linking one shared library into another when relaxation is enabled."
111
112     if {![is_remote host] && [which $CC] == 0} then {
113         return
114     }
115
116     if { ![ld_compile "$CC -mrelax -fPIC" $srcdir/$subdir/i126256-1.c $tmpdir/i126256-1.o] } {
117         unresolved $testname
118         return
119     }
120
121     if { ![ld_compile "$CC -mrelax -fPIC" $srcdir/$subdir/i126256-2.c $tmpdir/i126256-2.o] } {
122         unresolved $testname
123         return
124     }
125     
126     if { ![ld_simple_link $ld $tmpdir/i126256-1.so "-shared $tmpdir/i126256-1.o -e 0"]} {
127         unresolved $testname
128         return
129     }
130
131     if { ![ld_simple_link $ld $tmpdir/i126256-2.so "--relax -shared $tmpdir/i126256-2.o $tmpdir/i126256-1.so -e 0"]} {
132         fail $testname
133         return
134     }
135
136     pass $testname
137 }
138
139 i126256-test