1 # Expect script
for LD selective linking tests
2 # Copyright
(C
) 1998, 1999, 2000 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"]} {
26 if {[istarget
"*-*-pe"]} {
30 # List contains test
-items with three items followed by four lists
:
31 #
1:name 2:test
-type
(CC or C
++; add as needed
) 3:filename
4:ld-flags
32 #
5:must
-have
-symbols
6:must
-not
-have
-symbols
7:xfail
-targets.
34 #
If a must
(-not
)-have symbol is a list
, then that list must have two
35 # items
; the symbol
name and a value the symbol must
(not
) have.
37 # Note
: ld_nm trims leading `_
' from _start
39 # FIXME: Instead of table, read settings from each source-file.
41 {selective1 C 1.c {} {} {dropme1 dropme2} {}}
42 {selective2 C 2.c {} {} {foo} {}}
43 {selective3 C 2.c {-u foo} {foo} {{foo 0}} {}}
44 {selective4 C++ 3.cc {} {start foo__1A foo__1B} {bar__1A} {v850*-*-elf}}
45 {selective5 C++ 4.cc {} {} {foo__1B foo__1A} {}}
46 {selective6 C++ 5.cc {} {} {foo__1B foo__1A dropme1__Fv dropme2__Fv} {*-*-*}}
49 set cflags "-w -O2 -ffunction-sections -fdata-sections"
50 set cxxflags "-fvtable-gc -fno-exceptions -fno-rtti"
51 set ldflags "--gc-sections -Bstatic"
53 # If we don't have g
++ for the target
, mark all tests as untested.
54 if { [which $CXX
] == 0 } {
55 foreach testitem $seltests
{
56 untested
"[lindex $testitem 0]"
61 foreach testitem $seltests
{
62 set testname
[lindex $testitem
0]
63 set testtype
[lindex $testitem
1]
64 set testfile
[lindex $testitem
2]
65 set objfile
"tmpdir/[file rootname $testfile].o"
66 set ldfile
"tmpdir/[file rootname $testfile].x"
69 set ldargs
[lindex $testitem
3]
70 set mustsyms
[lindex $testitem
4]
71 set mustnotsyms
[lindex $testitem
5]
72 set xfails
[lindex $testitem
6]
74 foreach xfail_target $xfails
{
75 setup_xfail $xfail_target
78 # It
's either C or C++ at the moment.
79 if { $testtype == "C++" } {
80 set testflags "$cflags $cxxflags"
82 set testflags "$cflags"
85 # Note that we do not actually *use* CXX; we just add cxxflags for C++
86 # tests. It might have been a buglet originally; now I think better
88 if { ![ld_compile "$CC $testflags" $srcdir/$subdir/$testfile $objfile] } {
93 if ![ld_simple_link $ld $ldfile "$ldflags [join $ldargs] $objfile"] {
98 if ![ld_nm $nm $ldfile] {
103 # Check each mandated symbol and optionally mandated values.
104 foreach mustsym $mustsyms {
105 if { [llength [concat $mustsym]] == 1 } {
106 if { ![info exists nm_output($mustsym)] } {
107 verbose -log "$testname: missing $mustsym"
113 set mustsymname [lindex $mustsym 0]
114 set mustsymvalue [lindex $mustsym 1]
115 if { ![info exists nm_output($mustsymname)] } {
116 verbose -log "$testname: missing $mustsymname"
121 if { $nm_output($mustsymname) != $mustsymvalue } {
122 verbose -log "$testname: $mustsymname != $mustsymvalue"
123 verbose -log "is instead $nm_output($mustsymname)"
132 if { $failed != 0 } {
136 # Check each unwanted symbol, or that symbols do not have specific
138 foreach mustnotsym $mustnotsyms {
139 if { [llength [concat $mustnotsym]] == 1 } {
140 if { [info exists nm_output($mustnotsym)] } {
141 verbose -log "$testname: $mustnotsym == $nm_output($mustnotsym)"
147 set mustnotsymname [lindex $mustnotsym 0]
148 set mustnotsymvalue [lindex $mustnotsym 1]
149 if { [info exists nm_output($mustnotsymname)] \
150 && $nm_output($mustnotsymname) == $mustnotsymvalue} {
151 verbose -log "$testname: $mustnotsymname == $mustnotsymvalue"
159 if { $failed == 0 } {