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