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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [ld/] [testsuite/] [ld-cygwin/] [exe-export.exp] - Blame information for rev 75

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

Line No. Rev Author Line
1 45 khays
# Expect script for export table in executables tests
2
#   Copyright 2003, 2005, 2007, 2009
3
#   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 Fabrizio Gennari 
23
# Based on auto-import.exp  by Ralf.Habacker@freenet.de
24
#
25
 
26
# This test can only be run on a cygwin platforms.
27
if {![istarget *-pc-cygwin]} {
28
    verbose "Not a cygwin target."
29
    return
30
}
31
 
32
# No compiler, no test.
33
if { [which $CC] == 0 } {
34
    untested "Exe export test (no compiler available)"
35
    return
36
}
37
 
38
proc run_dlltool { lib_file def_file } {
39
    global dlltool
40
    global base_dir
41
    global as
42
 
43
    if ![info exists dlltool] then {
44
        set dlltool [findfile $base_dir/../binutils/dlltool]
45
    }
46
 
47
    if { [which $dlltool] == 0 } then {
48
        verbose "$dlltool does not exist"
49
        return 0
50
    }
51
 
52
    verbose "$dlltool --as $as -l $lib_file -d $def_file"
53
    catch "exec $dlltool --as $as -l $lib_file -d $def_file" dlltool_output
54
 
55
    #remove empty lines
56
    regsub -all "\n+" $dlltool_output "" dlltool_output
57
 
58
    if [string match "" $dlltool_output] then {
59
        return 1
60
    }
61
 
62
    verbose -log "$dlltool_output"
63
    return 0
64
}
65
 
66
# ld_special_link
67
#       A copy of ld_simple_link (from ld-lib.exp) with extra
68
#       code to strip warnings about creating libraries.
69
#
70
proc ld_special_link { ld target objects } {
71
    global host_triplet
72
    global link_output
73
 
74
    if { [which $ld] == 0 } then {
75
        verbose "$ld does not exist"
76
        return 0
77
    }
78
 
79
    if [is_endian_output_format $objects] then {
80
        set flags [big_or_little_endian]
81
    } else {
82
        set flags ""
83
    }
84
 
85
    verbose -log "$ld $flags -o $target $objects"
86
    catch "exec $ld $flags -o $target $objects" link_output
87
 
88
    set exec_output [prune_warnings $link_output]
89
 
90
    # We don't care if we get a warning about a non-existent start
91
    # symbol, since the default linker script might use ENTRY.
92
    regsub -all "(^|\n)(\[^\n\]*: warning: cannot find entry symbol\[^\n\]*\n?)" $exec_output "\\1" exec_output
93
 
94
    # We don't care if we get a message about creating a library file.
95
    regsub -all "(^|\n)(Creating library file\[^\n\]*\n?)" $exec_output "\\1" exec_output
96
 
97
    if [string match "" $exec_output] then {
98
        return 1
99
    }
100
 
101
    verbose -log "$exec_output"
102
    return 0
103
}
104
 
105
set tmpdir tmpdir
106
 
107
# Set some libs needed for cygwin.
108
set MYLDFLAGS "-Wl,--out-implib,$tmpdir/testexe.lib -nostartfiles -nostdlib"
109
 
110
# Build an export library for testdll
111
if ![run_dlltool $tmpdir/testdll.lib $srcdir/$subdir/testdll.def] {
112
    fail "building an export library for the shared lib"
113
    return
114
}
115
 
116
# Compile the executable.
117
if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/testexe.c $tmpdir/testexe.o] {
118
    fail "compiling executable"
119
    return
120
}
121
 
122
if ![ld_special_link "$CC $LDFLAGS $MYLDFLAGS -e _testexe_main@16" $tmpdir/testexe.exe "$tmpdir/testexe.o $srcdir/$subdir/testexe.def $tmpdir/testdll.lib -lkernel32"] {
123
    fail "linking executable"
124
    return
125
}
126
 
127
# Compile the dll.
128
if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/testdll.c $tmpdir/testdll.o] {
129
    fail "compiling shared lib"
130
    return
131
}
132
 
133
if ![ld_special_link "$CC $LDFLAGS -nostartfiles -nostdlib -e _testdll_main@12" $tmpdir/testdll.dll "$tmpdir/testdll.o $srcdir/$subdir/testdll.def $tmpdir/testexe.lib"] {
134
    fail "linking shared lib"
135
    return
136
}
137
 
138
# This is as far as we can go with a cross-compiler
139
if ![isnative] then {
140
    verbose "Not running natively, so cannot execute binary"
141
    pass "Compile and link and executable with an export table"
142
    return
143
}
144
 
145
verbose -log "executing $tmpdir/testexe.exe"
146
catch "exec $tmpdir/testexe.exe" prog_output
147
 
148
set expected ""
149
if [string match $expected $prog_output] then {
150
    pass "export table in executable"
151
} else {
152
    verbose $prog_output
153
    fail "Output does not match expected string $expected"
154
}

powered by: WebSVN 2.1.0

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