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