1 # Expect script
for LD selective linking tests
2 # Copyright
(C
) 1998, 1999 Free Software Foundation
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.
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.
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.
18 # Written by Catherine Moore
(clm@cygnus.com
)
19 # Make sure that constructors are handled correctly.
22 # COFF based ports
do not support selective linking
23 if {[istarget
"*-*-coff" "*-*-pe"]} {
27 set test1
"selective1"
28 set test2
"selective2"
29 set test3
"selective3"
30 set test4
"selective4"
31 set test5
"selective5"
32 set test6
"selective6"
34 set cflags
"-w -O2 -ffunction-sections -fdata-sections"
35 set cxxflags
"-fvtable-gc -fno-exceptions -fno-rtti"
36 set ldflags
"--gc-sections -Bstatic"
38 if { [which $CXX
] == 0 } {
48 if { ![ld_compile
"$CC $cflags" $srcdir/$subdir/1.c tmpdir/1.o]} {
53 if ![ld_simple_link $
ld tmpdir
/1.x
"$ldflags tmpdir/1.o"] {
56 if ![ld_nm $nm tmpdir
/1.x
] {
59 if {[info exists nm_output
(dropme1
)]} {
60 send_log
"dropme1 == $nm_output(dropme1)\n"
61 verbose
"dropme1 == $nm_output(dropme1)"
64 if {[info exists nm_output
(dropme2
)]} {
65 send_log
"dropme2 == $nm_output(dropme2)\n"
66 verbose
"dropme2 == $nm_output(dropme2)"
75 if { ![ld_compile
"$CC $cflags" $srcdir/$subdir/2.c tmpdir/2.o]} {
80 if ![ld_simple_link $
ld tmpdir
/2.x
"$ldflags tmpdir/2.o"] {
83 if ![ld_nm $nm tmpdir
/2.x
] {
86 if {[info exists nm_output
(foo
)] } {
87 send_log
"foo == $nm_output(foo)\n"
88 verbose
"foo== $nm_output(foo)"
96 if { ![ld_compile
"$CC $cflags" $srcdir/$subdir/2.c tmpdir/2.o]} {
101 if ![ld_simple_link $
ld tmpdir
/2.x
"$ldflags -u foo tmpdir/2.o"] {
104 if ![ld_nm $nm tmpdir
/2.x
] {
107 if {![info exists nm_output
(foo
)] } {
108 send_log
"bad output from nm\n"
109 verbose
"bad output from nm"
112 if {$nm_output
(foo
) == 0} {
113 send_log
"foo == $nm_output(foo)\n"
114 verbose
"foo== $nm_output(foo)"
123 setup_xfail
"v850*-*-elf"
125 if { ![ld_compile
"$CC $cflags $cxxflags" $srcdir/$subdir/3.cc tmpdir/3.o]} {
130 setup_xfail
"v850*-*-elf"
132 if ![ld_simple_link $
ld tmpdir
/3.x
"$ldflags tmpdir/3.o"] {
135 if ![ld_nm $nm tmpdir
/3.x
] {
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)"
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)"
154 if { ![ld_compile
"$CC $cflags $cxxflags" $srcdir/$subdir/4.cc tmpdir/4.o]} {
159 if ![ld_simple_link $
ld tmpdir
/4.x
"$ldflags tmpdir/4.o"] {
162 if ![ld_nm $nm tmpdir
/4.x
] {
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)"
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)"
181 setup_xfail
"v850*-*-elf"
183 if { ![ld_compile
"$CC $cflags $cxxflags" $srcdir/$subdir/5.cc tmpdir/5.o]} {
188 if ![ld_simple_link $
ld tmpdir
/5.x
"$ldflags tmpdir/5.o"] {
191 if ![ld_nm $nm tmpdir
/5.x
] {
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)"
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)"