]>
Commit | Line | Data |
---|---|---|
252b5132 | 1 | # Expect script for LD selective linking tests |
a2b64bed | 2 | # Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc. |
252b5132 RH |
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 | |
197d87f8 | 23 | if {[istarget "*-*-coff"]} { |
3017ff0e | 24 | return |
197d87f8 NC |
25 | } |
26 | if {[istarget "*-*-pe"]} { | |
3017ff0e | 27 | return |
252b5132 RH |
28 | } |
29 | ||
d63083ef HPN |
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. | |
33 | # | |
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. | |
36 | # | |
37 | # Note: ld_nm trims leading `_' from _start | |
38 | # | |
39 | # FIXME: Instead of table, read settings from each source-file. | |
40 | set seltests { | |
bbfebd39 L |
41 | {selective1 C 1.c {} {} {dropme1 dropme2} {alpha*-*}} |
42 | {selective2 C 2.c {} {} {foo} {alpha*-* mips*-*}} | |
66517a2f | 43 | {selective3 C 2.c {-u foo} {foo} {{foo 0}} {mips*-*}} |
e0d85c26 L |
44 | {selective4 C++ 3.cc {} {start a A::foo() B::foo()} {A::bar()} {alpha*-* mips*-*}} |
45 | {selective5 C++ 4.cc {} {start a A::bar()} {A::foo() B::foo()} {alpha*-* mips*-*}} | |
067f2074 AM |
46 | {selective6 C++ 5.cc {} {start a A::bar()} |
47 | {A::foo() B::foo() dropme1() dropme2()} {*-*-*}} | |
d63083ef | 48 | } |
252b5132 | 49 | |
44df2f94 | 50 | set cflags "-w -O -ffunction-sections -fdata-sections" |
252b5132 RH |
51 | set cxxflags "-fvtable-gc -fno-exceptions -fno-rtti" |
52 | set ldflags "--gc-sections -Bstatic" | |
53 | ||
d63083ef | 54 | # If we don't have g++ for the target, mark all tests as untested. |
252b5132 | 55 | if { [which $CXX] == 0 } { |
d63083ef | 56 | foreach testitem $seltests { |
4291c3fa | 57 | untested "[lindex $testitem 0]" |
252b5132 | 58 | } |
252b5132 RH |
59 | return |
60 | } | |
61 | ||
d63083ef HPN |
62 | foreach testitem $seltests { |
63 | set testname [lindex $testitem 0] | |
64 | set testtype [lindex $testitem 1] | |
65 | set testfile [lindex $testitem 2] | |
66 | set objfile "tmpdir/[file rootname $testfile].o" | |
67 | set ldfile "tmpdir/[file rootname $testfile].x" | |
68 | set failed 0 | |
69 | ||
70 | set ldargs [lindex $testitem 3] | |
71 | set mustsyms [lindex $testitem 4] | |
72 | set mustnotsyms [lindex $testitem 5] | |
73 | set xfails [lindex $testitem 6] | |
74 | ||
75 | foreach xfail_target $xfails { | |
76 | setup_xfail $xfail_target | |
3017ff0e | 77 | } |
252b5132 | 78 | |
d63083ef HPN |
79 | # It's either C or C++ at the moment. |
80 | if { $testtype == "C++" } { | |
81 | set testflags "$cflags $cxxflags" | |
82 | } { | |
83 | set testflags "$cflags" | |
84 | } | |
252b5132 | 85 | |
d63083ef HPN |
86 | # Note that we do not actually *use* CXX; we just add cxxflags for C++ |
87 | # tests. It might have been a buglet originally; now I think better | |
88 | # leave as is. | |
89 | if { ![ld_compile "$CC $testflags" $srcdir/$subdir/$testfile $objfile] } { | |
90 | unresolved $testname | |
91 | return | |
3017ff0e | 92 | } |
252b5132 | 93 | |
f6673641 NC |
94 | # V850 targets need libgcc.a |
95 | if [istarget v850*-*-elf] { | |
96 | set objfile "$objfile -L ../gcc -lgcc" | |
97 | } | |
98 | ||
fef67c28 SC |
99 | # m6811/m6812 code has references to soft registers. |
100 | if {[istarget m6811-*-*] || [istarget m6812-*-*]} { | |
101 | set objfile "$objfile --defsym _.frame=0 --defsym _.d1=0" | |
102 | set objfile "$objfile --defsym _.d2=0" | |
103 | } | |
104 | ||
d63083ef HPN |
105 | if ![ld_simple_link $ld $ldfile "$ldflags [join $ldargs] $objfile"] { |
106 | fail $testname | |
107 | continue | |
108 | } | |
252b5132 | 109 | |
067f2074 | 110 | if ![ld_nm $nm --demangle $ldfile] { |
d63083ef HPN |
111 | unresolved $testname |
112 | continue | |
113 | } | |
252b5132 | 114 | |
067f2074 AM |
115 | # Must make V2 demangled names look like V3 |
116 | foreach nm_output_key [array names nm_output] { | |
117 | if [regsub \\(void\\) $nm_output_key () new_nm_output_key] { | |
118 | set nm_output($new_nm_output_key) nm_output($nm_output_key) | |
119 | } | |
120 | } | |
121 | ||
d63083ef HPN |
122 | # Check each mandated symbol and optionally mandated values. |
123 | foreach mustsym $mustsyms { | |
124 | if { [llength [concat $mustsym]] == 1 } { | |
125 | if { ![info exists nm_output($mustsym)] } { | |
126 | verbose -log "$testname: missing $mustsym" | |
127 | fail $testname | |
128 | set failed 1 | |
129 | break | |
130 | } | |
131 | } { | |
132 | set mustsymname [lindex $mustsym 0] | |
133 | set mustsymvalue [lindex $mustsym 1] | |
134 | if { ![info exists nm_output($mustsymname)] } { | |
135 | verbose -log "$testname: missing $mustsymname" | |
136 | fail $testname | |
137 | set failed 1 | |
138 | break | |
139 | } { | |
140 | if { $nm_output($mustsymname) != $mustsymvalue } { | |
141 | verbose -log "$testname: $mustsymname != $mustsymvalue" | |
142 | verbose -log "is instead $nm_output($mustsymname)" | |
143 | fail $testname | |
144 | set failed 1 | |
145 | break | |
e76e4c91 AM |
146 | } |
147 | } | |
3017ff0e AM |
148 | } |
149 | } | |
252b5132 | 150 | |
d63083ef HPN |
151 | if { $failed != 0 } { |
152 | continue | |
153 | } | |
252b5132 | 154 | |
d63083ef HPN |
155 | # Check each unwanted symbol, or that symbols do not have specific |
156 | # values. | |
157 | foreach mustnotsym $mustnotsyms { | |
158 | if { [llength [concat $mustnotsym]] == 1 } { | |
159 | if { [info exists nm_output($mustnotsym)] } { | |
160 | verbose -log "$testname: $mustnotsym == $nm_output($mustnotsym)" | |
161 | fail $testname | |
162 | set failed 1 | |
163 | break | |
164 | } | |
165 | } { | |
166 | set mustnotsymname [lindex $mustnotsym 0] | |
167 | set mustnotsymvalue [lindex $mustnotsym 1] | |
168 | if { [info exists nm_output($mustnotsymname)] \ | |
169 | && $nm_output($mustnotsymname) == $mustnotsymvalue} { | |
170 | verbose -log "$testname: $mustnotsymname == $mustnotsymvalue" | |
171 | fail $testname | |
172 | set failed 1 | |
173 | break | |
3017ff0e | 174 | } |
252b5132 RH |
175 | } |
176 | } | |
bd0110a3 | 177 | |
d63083ef HPN |
178 | if { $failed == 0 } { |
179 | pass $testname | |
bd0110a3 HPN |
180 | } |
181 | } | |
182 |