Commit | Line | Data |
---|---|---|
252b5132 RH |
1 | # Expect script for LD selective linking tests |
2 | # Copyright (C) 1998, 1999 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 2 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 | # Written by Catherine Moore (clm@cygnus.com) | |
19 | # Make sure that constructors are handled correctly. | |
20 | ||
21 | ||
22 | # COFF based ports do not support selective linking | |
197d87f8 | 23 | if {[istarget "*-*-coff"]} { |
3017ff0e | 24 | return |
197d87f8 NC |
25 | } |
26 | if {[istarget "*-*-pe"]} { | |
3017ff0e | 27 | return |
252b5132 RH |
28 | } |
29 | ||
30 | set test1 "selective1" | |
31 | set test2 "selective2" | |
32 | set test3 "selective3" | |
33 | set test4 "selective4" | |
34 | set test5 "selective5" | |
252b5132 | 35 | |
3017ff0e | 36 | set cflags "-w -O2 -ffunction-sections -fdata-sections" |
252b5132 RH |
37 | set cxxflags "-fvtable-gc -fno-exceptions -fno-rtti" |
38 | set ldflags "--gc-sections -Bstatic" | |
39 | ||
40 | if { [which $CXX] == 0 } { | |
41 | untested $test1 | |
42 | untested $test2 | |
43 | untested $test3 | |
44 | untested $test4 | |
45 | untested $test5 | |
252b5132 RH |
46 | return |
47 | } | |
48 | ||
49 | if { ![ld_compile "$CC $cflags" $srcdir/$subdir/1.c tmpdir/1.o]} { | |
50 | unresolved $test1 | |
51 | return | |
52 | } | |
53 | ||
54 | if ![ld_simple_link $ld tmpdir/1.x "$ldflags tmpdir/1.o"] { | |
55 | fail $test1 | |
56 | } else { | |
57 | if ![ld_nm $nm tmpdir/1.x] { | |
58 | unresolved $test1 | |
59 | } else { | |
60 | if {[info exists nm_output(dropme1)]} { | |
3017ff0e AM |
61 | send_log "dropme1 == $nm_output(dropme1)\n" |
62 | verbose "dropme1 == $nm_output(dropme1)" | |
63 | fail $test1 | |
64 | } else { | |
65 | if {[info exists nm_output(dropme2)]} { | |
66 | send_log "dropme2 == $nm_output(dropme2)\n" | |
67 | verbose "dropme2 == $nm_output(dropme2)" | |
252b5132 RH |
68 | fail $test1 |
69 | } else { | |
3017ff0e | 70 | pass $test1 |
252b5132 RH |
71 | } |
72 | } | |
73 | } | |
3017ff0e | 74 | } |
252b5132 RH |
75 | |
76 | if { ![ld_compile "$CC $cflags" $srcdir/$subdir/2.c tmpdir/2.o]} { | |
77 | unresolved $test2 | |
78 | return | |
79 | } | |
80 | ||
81 | if ![ld_simple_link $ld tmpdir/2.x "$ldflags tmpdir/2.o"] { | |
82 | fail $test2 | |
83 | } else { | |
84 | if ![ld_nm $nm tmpdir/2.x] { | |
85 | unresolved $test2 | |
86 | } else { | |
87 | if {[info exists nm_output(foo)] } { | |
88 | send_log "foo == $nm_output(foo)\n" | |
e76e4c91 | 89 | verbose "foo == $nm_output(foo)" |
252b5132 RH |
90 | fail $test2 |
91 | } else { | |
92 | pass $test2 | |
3017ff0e AM |
93 | } |
94 | } | |
95 | } | |
252b5132 RH |
96 | |
97 | if { ![ld_compile "$CC $cflags" $srcdir/$subdir/2.c tmpdir/2.o]} { | |
98 | unresolved $test3 | |
99 | return | |
100 | } | |
101 | ||
102 | if ![ld_simple_link $ld tmpdir/2.x "$ldflags -u foo tmpdir/2.o"] { | |
103 | fail $test3 | |
104 | } else { | |
105 | if ![ld_nm $nm tmpdir/2.x] { | |
106 | unresolved $test3 | |
107 | } else { | |
108 | if {![info exists nm_output(foo)] } { | |
109 | send_log "bad output from nm\n" | |
110 | verbose "bad output from nm" | |
111 | fail $test3 | |
112 | } else { | |
113 | if {$nm_output(foo) == 0} { | |
114 | send_log "foo == $nm_output(foo)\n" | |
e76e4c91 | 115 | verbose "foo == $nm_output(foo)" |
252b5132 RH |
116 | fail $test3 |
117 | } else { | |
118 | pass $test3 | |
3017ff0e AM |
119 | } |
120 | } | |
121 | } | |
252b5132 RH |
122 | } |
123 | ||
124 | setup_xfail "v850*-*-elf" | |
125 | ||
126 | if { ![ld_compile "$CC $cflags $cxxflags" $srcdir/$subdir/3.cc tmpdir/3.o]} { | |
127 | unresolved $test4 | |
128 | return | |
129 | } | |
130 | ||
131 | setup_xfail "v850*-*-elf" | |
132 | ||
133 | if ![ld_simple_link $ld tmpdir/3.x "$ldflags tmpdir/3.o"] { | |
134 | fail $test4 | |
135 | } else { | |
136 | if ![ld_nm $nm tmpdir/3.x] { | |
137 | unresolved $test4 | |
138 | } else { | |
e76e4c91 AM |
139 | if [info exists nm_output(bar__1A)] { |
140 | send_log "bar__1A == $nm_output(bar__1A)\n" | |
141 | verbose "bar__1A == $nm_output(bar__1A)" | |
3017ff0e AM |
142 | fail $test4 |
143 | } else { | |
e76e4c91 AM |
144 | #note ld_nm trims leading `_' from _start |
145 | if ![info exists nm_output(start)] { | |
146 | send_log "_start missing\n" | |
147 | verbose "_start missing" | |
148 | fail $test4 | |
149 | } else { | |
150 | if ![info exists nm_output(foo__1A)] { | |
151 | send_log "foo__1A missing\n" | |
152 | verbose "foo_1A missing" | |
153 | fail $test4 | |
154 | } else { | |
155 | if ![info exists nm_output(foo__1B)] { | |
156 | send_log "foo__1B missing\n" | |
157 | verbose "foo_1B missing" | |
158 | fail $test4 | |
159 | } else { | |
160 | pass $test4 | |
161 | } | |
162 | } | |
163 | } | |
3017ff0e AM |
164 | } |
165 | } | |
252b5132 RH |
166 | } |
167 | ||
168 | if { ![ld_compile "$CC $cflags $cxxflags" $srcdir/$subdir/4.cc tmpdir/4.o]} { | |
169 | unresolved $test5 | |
170 | return | |
171 | } | |
172 | ||
173 | if ![ld_simple_link $ld tmpdir/4.x "$ldflags tmpdir/4.o"] { | |
174 | fail $test5 | |
175 | } else { | |
176 | if ![ld_nm $nm tmpdir/4.x] { | |
177 | unresolved $test5 | |
178 | } else { | |
3017ff0e | 179 | if {[info exists nm_output(foo__1B)]} { |
252b5132 RH |
180 | send_log "foo__1B == $nm_output(foo__1B)\n" |
181 | verbose "foo__1B == $nm_output(foo__1B)" | |
182 | fail $test5 | |
183 | } else { | |
3017ff0e | 184 | if {[info exists nm_output(foo__1A)]} { |
e76e4c91 | 185 | send_log "foo__1A == $nm_output(foo__1A)\n" |
252b5132 RH |
186 | verbose "foo__1A == $nm_output(foo__1A)" |
187 | fail $test5 | |
3017ff0e AM |
188 | } else { |
189 | pass $test5 | |
190 | } | |
252b5132 RH |
191 | } |
192 | } | |
193 | } |