OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [ld/] [testsuite/] [ld-selective/] [selective.exp] - Blame information for rev 262

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 100 khays
# Expect script for LD selective linking tests
2
#   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009,
3
#   2010, 2011 Free Software Foundation, Inc.
4
#
5
# This file is part of the GNU Binutils.
6
#
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20
# MA 02110-1301, USA.
21
#
22
# Written by Catherine Moore (clm@cygnus.com)
23
# Make sure that constructors are handled correctly.
24
 
25
# Only ELF based ports support selective linking
26 163 khays
if { ![is_elf_format] || ![check_gc_sections_available] } {
27 100 khays
    return
28
}
29
 
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 {
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 a A::foo() B::foo()} {A::bar()} {mips*-*}}
45
  {selective5 C++ 4.cc {}       {start a A::bar()} {A::foo() B::foo()} {mips*-*}}
46
  {selective6 C++ 5.cc {}       {start a A::bar()}
47
    {A::foo() B::foo() dropme1() dropme2()} {*-*-*}}
48
}
49
 
50
set cflags "-w -O -ffunction-sections -fdata-sections"
51
set cxxflags "-fno-exceptions -fno-rtti"
52
set ldflags "--gc-sections -Bstatic"
53
 
54
if [istarget mips*-*] {
55
    # MIPS16 doesn't support PIC code.
56
    set cflags "-mno-abicalls $cflags"
57
    # MIPS ELF uses __start by default, we override it.
58
    set ldflags "-e _start $ldflags"
59
}
60
 
61
if [istarget sh64*-*-elf] {
62
    # This is what gcc passes to ld by default, plus switch to the
63
    # "usual" ELF _start (shelf32 normally uses just `start' for COFF
64
    # compatibility)
65
    set ldflags "-e _start -mshelf32 $ldflags"
66
}
67
 
68
# If we don't have g++ for the target, mark all tests as untested.
69
if { ![is_remote host] && [which $CXX] == 0 } {
70
    foreach testitem $seltests {
71
        untested "[lindex $testitem 0]"
72
    }
73
    return
74
}
75
 
76
foreach testitem $seltests {
77
    set testname [lindex $testitem 0]
78
    set testtype [lindex $testitem 1]
79
    set testfile [lindex $testitem 2]
80
    set objfile "tmpdir/[file rootname $testfile].o"
81
    set ldfile "tmpdir/[file rootname $testfile].x"
82
    set failed 0
83
 
84
    set ldargs [lindex $testitem 3]
85
    set mustsyms [lindex $testitem 4]
86
    set mustnotsyms [lindex $testitem 5]
87
    set xfails [lindex $testitem 6]
88
 
89
    foreach xfail_target $xfails {
90
        setup_xfail $xfail_target
91
    }
92
 
93
    # It's either C or C++ at the moment.
94
    if { $testtype == "C++" } {
95
        set compiler "$CXX"
96
        # Starting with 3.4.0, -fvtable-gc is no longer supported and thus
97
        # the functionality we try to test for cannot be expected to work.
98
        set version [remote_exec host "$CXX -dumpversion"]
99
        set version [lindex $version 1]
100
        if [regexp "^(\[1-9\]\[0-9\]+|\[4-9\]|3.(\[1-9\]\[0-9\]+|\[4-9\]))\\." $version] {
101
            set testflags "$cflags $cxxflags"
102
            setup_xfail {*-*-*}
103
        } else {
104
            set testflags "$cflags $cxxflags -fvtable-gc"
105
        }
106
    } else {
107
        set testflags "$cflags"
108
        set compiler "$CC"
109
    }
110
 
111
    # Note that we do not actually *use* CXX; we just add cxxflags for C++
112
    # tests.  It might have been a buglet originally; now I think better
113
    # leave as is.
114
    if { ![ld_compile "$compiler $testflags" $srcdir/$subdir/$testfile $objfile] } {
115
        unresolved $testname
116
        continue
117
    }
118
 
119
    # V850 targets need libgcc.a
120
    if [istarget v850*-*-elf] {
121
        set libgcc [remote_exec host "$compiler -print-libgcc-file-name"]
122
        set libgcc [lindex $libgcc 1]
123
        regsub -all "\[\r\n\]" $libgcc "" libgcc
124
        set objfile "$objfile $libgcc"
125
    }
126
 
127
    # ARM targets need libgcc.a in THUMB mode so that __call_via_r3 is provided
128
    if {[istarget arm-*-*]} {
129
        set libgcc [remote_exec host "$compiler -print-libgcc-file-name"]
130
        set libgcc [lindex $libgcc 1]
131
        regsub -all "\[\r\n\]" $libgcc "" libgcc
132
        set objfile "$objfile $libgcc"
133
    }
134
 
135
    # HPPA linux targets need libgcc.a for millicode routines ($$dyncall).
136
    if [istarget hppa*-*-linux*] {
137
        set libgcc [remote_exec host "$compiler -print-libgcc-file-name"]
138
        set libgcc [lindex $libgcc 1]
139
        regsub -all "\[\r\n\]" $libgcc "" libgcc
140
        set objfile "$objfile $libgcc"
141
    }
142
 
143
    # m6811/m6812 code has references to soft registers.
144 166 khays
    if {[istarget m6811-*-*] || [istarget m6812-*-*] || [istarget m68hc1*-*-*]} {
145 100 khays
        set objfile "$objfile --defsym _.frame=0 --defsym _.d1=0"
146
        set objfile "$objfile --defsym _.d2=0"
147
    }
148
 
149
    if ![ld_simple_link $ld $ldfile "$ldflags [join $ldargs] $objfile"] {
150
        fail $testname
151
        continue
152
    }
153
 
154
    if ![ld_nm $nm --demangle $ldfile] {
155
        unresolved $testname
156
        continue
157
    }
158
 
159
    # Must make V2 demangled names look like V3
160
    foreach nm_output_key [array names nm_output] {
161
        if [regsub \\(void\\) $nm_output_key () new_nm_output_key] {
162
            set nm_output($new_nm_output_key) nm_output($nm_output_key)
163
        }
164
    }
165
 
166
    # Check each mandated symbol and optionally mandated values.
167
    foreach mustsym $mustsyms {
168
        if { [llength [concat $mustsym]] == 1 } {
169
            if { ![info exists nm_output($mustsym)] } {
170
                verbose -log "$testname: missing $mustsym"
171
                fail $testname
172
                set failed 1
173
                break
174
            }
175
        } {
176
            set mustsymname [lindex $mustsym 0]
177
            set mustsymvalue [lindex $mustsym 1]
178
            if { ![info exists nm_output($mustsymname)] } {
179
                verbose -log "$testname: missing $mustsymname"
180
                fail $testname
181
                set failed 1
182
                break
183
            } {
184
                if { $nm_output($mustsymname) != $mustsymvalue } {
185
                    verbose -log "$testname: $mustsymname != $mustsymvalue"
186
                    verbose -log "is instead $nm_output($mustsymname)"
187
                    fail $testname
188
                    set failed 1
189
                    break
190
                }
191
            }
192
        }
193
    }
194
 
195
    if { $failed != 0 } {
196
        continue
197
    }
198
 
199
    # Check each unwanted symbol, or that symbols do not have specific
200
    # values.
201
    foreach mustnotsym $mustnotsyms {
202
        if { [llength [concat $mustnotsym]] == 1 } {
203
            if { [info exists nm_output($mustnotsym)] } {
204
                verbose -log "$testname: $mustnotsym == $nm_output($mustnotsym)"
205
                fail $testname
206
                set failed 1
207
                break
208
            }
209
        } {
210
            set mustnotsymname [lindex $mustnotsym 0]
211
            set mustnotsymvalue [lindex $mustnotsym 1]
212
            if { [info exists nm_output($mustnotsymname)] \
213
                    && $nm_output($mustnotsymname) == $mustnotsymvalue} {
214
                verbose -log "$testname: $mustnotsymname == $mustnotsymvalue"
215
                fail $testname
216
                set failed 1
217
                break
218
            }
219
        }
220
    }
221
 
222
    if { $failed == 0 } {
223
        pass $testname
224
    }
225
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.