Even more hppa testsuite patches.
[platform/upstream/binutils.git] / ld / testsuite / ld-selective / selective.exp
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
23 if {[istarget "*-*-coff"]} {
24     return
25 }
26 if {[istarget "*-*-pe"]} {
27     return
28 }
29
30 set test1 "selective1"
31 set test2 "selective2"
32 set test3 "selective3"
33 set test4 "selective4"
34 set test5 "selective5"
35
36 set cflags "-w -O2 -ffunction-sections -fdata-sections"
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
46     return
47 }
48
49 setup_xfail "hppa*-*-*"
50
51 if { ![ld_compile "$CC $cflags" $srcdir/$subdir/1.c tmpdir/1.o]} {
52     unresolved $test1
53     return
54 }
55
56 if ![ld_simple_link $ld tmpdir/1.x "$ldflags tmpdir/1.o"] {
57     fail $test1
58 } else {
59     if ![ld_nm $nm tmpdir/1.x] {
60         unresolved $test1
61     } else {
62         if {[info exists nm_output(dropme1)]} {
63             send_log "dropme1 == $nm_output(dropme1)\n"
64             verbose "dropme1 == $nm_output(dropme1)"
65             fail $test1
66         } else {
67             if {[info exists nm_output(dropme2)]} {
68                 send_log "dropme2 == $nm_output(dropme2)\n"
69                 verbose "dropme2 == $nm_output(dropme2)"
70                 fail $test1
71             } else {
72                 pass $test1
73             }
74         }
75     }
76 }
77
78 setup_xfail "hppa*-*-*"
79
80 if { ![ld_compile "$CC $cflags" $srcdir/$subdir/2.c tmpdir/2.o]} {
81     unresolved $test2
82     return
83 }
84
85 if ![ld_simple_link $ld tmpdir/2.x "$ldflags tmpdir/2.o"] {
86     fail $test2
87 } else {
88     if ![ld_nm $nm tmpdir/2.x] {
89         unresolved $test2
90     } else {
91         if {[info exists nm_output(foo)] } {
92             send_log "foo == $nm_output(foo)\n"
93             verbose "foo == $nm_output(foo)"
94             fail $test2
95         } else {
96             pass $test2
97         }
98     }
99 }
100
101 if { ![ld_compile "$CC $cflags" $srcdir/$subdir/2.c tmpdir/2.o]} {
102     unresolved $test3
103     return
104 }
105
106 if ![ld_simple_link $ld tmpdir/2.x "$ldflags -u foo tmpdir/2.o"] {
107     fail $test3
108 } else {
109     if ![ld_nm $nm tmpdir/2.x] {
110         unresolved $test3
111     } else {
112         if {![info exists nm_output(foo)] } {
113             send_log "bad output from nm\n"
114             verbose "bad output from nm"
115             fail $test3
116         } else {
117             if {$nm_output(foo) == 0} {
118                 send_log "foo == $nm_output(foo)\n"
119                 verbose "foo == $nm_output(foo)"
120                 fail $test3
121             } else {
122                 pass $test3
123             }
124         }
125     }
126 }
127
128 setup_xfail "v850*-*-elf"
129
130 if { ![ld_compile "$CC $cflags $cxxflags" $srcdir/$subdir/3.cc tmpdir/3.o]} {
131     unresolved $test4
132     return
133 }
134
135 setup_xfail "v850*-*-elf"
136
137 if ![ld_simple_link $ld tmpdir/3.x "$ldflags tmpdir/3.o"] {
138    fail $test4
139 } else {
140     if ![ld_nm $nm tmpdir/3.x] {
141        unresolved $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 #note ld_nm trims leading `_' from _start
149             if ![info exists nm_output(start)] {
150                 send_log "_start missing\n"
151                 verbose "_start missing"
152                 fail $test4
153             } else {
154                 if ![info exists nm_output(foo__1A)] {
155                     send_log "foo__1A missing\n"
156                     verbose "foo_1A missing"
157                     fail $test4
158                 } else {
159                     if ![info exists nm_output(foo__1B)] {
160                         send_log "foo__1B missing\n"
161                         verbose "foo_1B missing"
162                         fail $test4
163                     } else {
164                         pass $test4
165                     }
166                 }
167             }
168         }
169     }
170 }
171
172 if { ![ld_compile "$CC $cflags $cxxflags" $srcdir/$subdir/4.cc tmpdir/4.o]} {
173     unresolved $test5
174     return
175 }
176
177 if ![ld_simple_link $ld tmpdir/4.x "$ldflags tmpdir/4.o"] {
178     fail $test5
179 } else {
180     if ![ld_nm $nm tmpdir/4.x] {
181         unresolved $test5
182     } else {
183         if {[info exists nm_output(foo__1B)]} {
184             send_log "foo__1B == $nm_output(foo__1B)\n"
185             verbose "foo__1B == $nm_output(foo__1B)"
186             fail $test5
187         } else {
188             if {[info exists nm_output(foo__1A)]} {
189                 send_log "foo__1A == $nm_output(foo__1A)\n"
190                 verbose "foo__1A == $nm_output(foo__1A)"
191                 fail $test5
192             } else {
193                 pass $test5
194             }
195         }
196     }
197 }