19990502 sourceware import
[deliverable/binutils-gdb.git] / ld / testsuite / ld-selective / selective.exp
CommitLineData
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
23if {[istarget "*-*-coff" "*-*-pe"]} {
24 return
25}
26
27set test1 "selective1"
28set test2 "selective2"
29set test3 "selective3"
30set test4 "selective4"
31set test5 "selective5"
32set test6 "selective6"
33
34set cflags "-w -O2 -ffunction-sections -fdata-sections"
35set cxxflags "-fvtable-gc -fno-exceptions -fno-rtti"
36set ldflags "--gc-sections -Bstatic"
37
38if { [which $CXX] == 0 } {
39 untested $test1
40 untested $test2
41 untested $test3
42 untested $test4
43 untested $test5
44 untested $test6
45 return
46}
47
48if { ![ld_compile "$CC $cflags" $srcdir/$subdir/1.c tmpdir/1.o]} {
49 unresolved $test1
50 return
51}
52
53if ![ld_simple_link $ld tmpdir/1.x "$ldflags tmpdir/1.o"] {
54 fail $test1
55} else {
56 if ![ld_nm $nm tmpdir/1.x] {
57 unresolved $test1
58 } else {
59 if {[info exists nm_output(dropme1)]} {
60 send_log "dropme1 == $nm_output(dropme1)\n"
61 verbose "dropme1 == $nm_output(dropme1)"
62 fail $test1
63 } else {
64 if {[info exists nm_output(dropme2)]} {
65 send_log "dropme2 == $nm_output(dropme2)\n"
66 verbose "dropme2 == $nm_output(dropme2)"
67 fail $test1
68 } else {
69 pass $test1
70 }
71 }
72 }
73 }
74
75if { ![ld_compile "$CC $cflags" $srcdir/$subdir/2.c tmpdir/2.o]} {
76 unresolved $test2
77 return
78}
79
80if ![ld_simple_link $ld tmpdir/2.x "$ldflags tmpdir/2.o"] {
81 fail $test2
82} else {
83 if ![ld_nm $nm tmpdir/2.x] {
84 unresolved $test2
85 } else {
86 if {[info exists nm_output(foo)] } {
87 send_log "foo == $nm_output(foo)\n"
88 verbose "foo== $nm_output(foo)"
89 fail $test2
90 } else {
91 pass $test2
92 }
93 }
94 }
95
96if { ![ld_compile "$CC $cflags" $srcdir/$subdir/2.c tmpdir/2.o]} {
97 unresolved $test3
98 return
99}
100
101if ![ld_simple_link $ld tmpdir/2.x "$ldflags -u foo tmpdir/2.o"] {
102 fail $test3
103} else {
104 if ![ld_nm $nm tmpdir/2.x] {
105 unresolved $test3
106 } else {
107 if {![info exists nm_output(foo)] } {
108 send_log "bad output from nm\n"
109 verbose "bad output from nm"
110 fail $test3
111 } else {
112 if {$nm_output(foo) == 0} {
113 send_log "foo == $nm_output(foo)\n"
114 verbose "foo== $nm_output(foo)"
115 fail $test3
116 } else {
117 pass $test3
118 }
119 }
120 }
121}
122
123setup_xfail "v850*-*-elf"
124
125if { ![ld_compile "$CC $cflags $cxxflags" $srcdir/$subdir/3.cc tmpdir/3.o]} {
126 unresolved $test4
127 return
128}
129
130setup_xfail "v850*-*-elf"
131
132if ![ld_simple_link $ld tmpdir/3.x "$ldflags tmpdir/3.o"] {
133 fail $test4
134} else {
135 if ![ld_nm $nm tmpdir/3.x] {
136 unresolved $test4
137 } else {
138 if {[info exists nm_output(foo__1B)]} {
139 send_log "foo__1B == $nm_output(foo__1B)\n"
140 verbose "foo__1B == $nm_output(foo__1B)"
141 fail $test4
142 } else {
143 if {[ info exists nm_output(bar__1A)]} {
144 send_log "bar__1A== $nm_output(_bar__1A)\n"
145 verbose "bar__1A == $nm_output(_bar__1A)"
146 fail $test4
147 } else {
148 pass $test4
149 }
150 }
151 }
152}
153
154if { ![ld_compile "$CC $cflags $cxxflags" $srcdir/$subdir/4.cc tmpdir/4.o]} {
155 unresolved $test5
156 return
157}
158
159if ![ld_simple_link $ld tmpdir/4.x "$ldflags tmpdir/4.o"] {
160 fail $test5
161} else {
162 if ![ld_nm $nm tmpdir/4.x] {
163 unresolved $test5
164 } else {
165 if {[info exists nm_output(foo__1B)]} {
166 send_log "foo__1B == $nm_output(foo__1B)\n"
167 verbose "foo__1B == $nm_output(foo__1B)"
168 fail $test5
169 } else {
170 if {[info exists nm_output(foo__1A)]} {
171 send_log "foo__1A== $nm_output(foo__1A)\n"
172 verbose "foo__1A == $nm_output(foo__1A)"
173 fail $test5
174 } else {
175 pass $test5
176 }
177 }
178 }
179}
180
181setup_xfail "v850*-*-elf"
182
183if { ![ld_compile "$CC $cflags $cxxflags" $srcdir/$subdir/5.cc tmpdir/5.o]} {
184 unresolved $test6
185 return
186}
187
188if ![ld_simple_link $ld tmpdir/5.x "$ldflags tmpdir/5.o"] {
189 fail $test6
190} else {
191 if ![ld_nm $nm tmpdir/5.x] {
192 unresolved $test6
193 } else {
194 if {[info exists nm_output(foo__1B)] } {
195 send_log "foo__1B == $nm_output(foo__1B)\n"
196 verbose "foo__1B == $nm_output(foo__1B)"
197 fail $test6
198 } else {
199 if { [info exists nm_output(foo__1A)]} {
200 send_log "foo__1A== $nm_output(foo__1A)\n"
201 verbose "foo__1A == $nm_output(foo__1A)"
202 fail $test6
203 } else {
204 pass $test6
205 }
206 }
207 }
208}
This page took 0.048882 seconds and 4 git commands to generate.