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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [ld/] [testsuite/] [ld-pe/] [pe-run2.exp] - Blame information for rev 184

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

Line No. Rev Author Line
1 92 khays
# Expect script for complex PE tests that require a C compiler and the ability
2
# to run target executables natively, in addition to the just-built binutils.
3
#   Copyright 2006, 2007, 2009
4
#   Free Software Foundation, Inc.
5
#
6
# This file is part of the GNU Binutils.
7
#
8
# This program is free software; you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 3 of the License, or
11
# (at your option) any later version.
12
#
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
# GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License
19
# along with this program; if not, write to the Free Software
20
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21
# MA 02110-1301, USA.
22
#
23
# Based on the script pe-run.exp written by Pedro Alves.
24
# Written by Kai Tietz 
25
#
26
 
27
# Note:
28
#
29
# This test checks the "direct linking to a dll" functionality with stdcall
30
# and fastcall fixup.
31
#
32
# The test has 7 stages:
33
#
34
# 1. compile and link a test dll with ".dll" extension.
35
#
36
# 2. compile and link a test dll with ".sl" (i.e. != ".dll") extension.
37
#
38
# 3. compile and link a client application linking directly to the ".dll" dll built in 1.
39
#    This should produce no errors.
40
#
41
# 4. compile and link a client application linking directly to the ".sl" dll built in 2.
42
#    This should produce no errors.
43
#
44
# 5. compile and link a client application linking directly to a symlink into
45
#    the ".dll" dll built in 1.
46
#    This should produce no errors.
47
#
48
# 6. compile and link a client application linking directly to a symlink into
49
#    the ".sl" dll built in 1.
50
#    This should produce no errors.
51
#
52
# 7. run the produced executables
53
 
54
# This test can only be run on PE/COFF platforms.
55
if {![is_pecoff_format]} {
56
    return
57
}
58
 
59
# No compiler, no test.
60
if { [which $CC] == 0 } {
61
    untested "Direct linking to dll fastcall/stdcall test"
62
    return
63
}
64
 
65
set tmpdir tmpdir
66
 
67
proc test_direct2_link_dll {} {
68
    global CC
69
    global CFLAGS
70
    global srcdir
71
    global subdir
72
    global tmpdir
73
 
74
    # Compile the dll.
75
    if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/direct2_dll.c $tmpdir/direct2_dll.o ] {
76
        fail "compiling shared lib fastcall/stdcall"
77
    } elseif ![ld_simple_link "$CC -shared -Wl,--enable-stdcall-fixup -Wl,--kill-at " $tmpdir/direct2_dll.dll "$tmpdir/direct2_dll.o" ] {
78
        fail "linking shared lib (.dll) fastcall/stdcall"
79
    } elseif ![ld_simple_link "$CC -shared -Wl,--enable-stdcall-fixup -Wl,--kill-at " $tmpdir/direct2_dll.sl "$tmpdir/direct2_dll.o" ] {
80
        fail "linking shared lib (.sl) fastcall/stdcall"
81
    } else {
82
        # Compile and link the client program.
83
        if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/direct2_client.c $tmpdir/direct2_client.o ] {
84
            fail "compiling client fastcall/stdcall"
85
        } else {
86
            # Check linking directly to direct2_dll.dll.
87
            set msg "linking client (.dll) fastcall/stdcall"
88
            if [ld_simple_link "$CC -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_dll.exe \
89
              "$tmpdir/direct2_client.o $tmpdir/direct2_dll.dll" ] {
90
                pass $msg
91
            } else {
92
                fail $msg
93
            }
94
 
95
            # Check linking directly to direct2_dll.sl.
96
            set msg "linking client (.sl) fastcall/stdcall"
97
            if [ld_simple_link "$CC -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_sl.exe \
98
              "$tmpdir/direct2_client.o $tmpdir/direct2_dll.sl" ] {
99
                pass $msg
100
            } else {
101
                fail $msg
102
            }
103
 
104
            # Check dll direct linking through symlink to .dll.
105
            # Create symbolic link.
106
            catch "exec ln -fs direct2_dll.dll $tmpdir/libdirect2_dll.dll.a" ln_catch
107
            set msg "linking client (symlink -> .dll) fastcall/stdcall"
108
            if [ld_simple_link "$CC -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_symlink_dll.exe \
109
              "$tmpdir/direct2_client.o $tmpdir/libdirect2_dll.dll.a" ] {
110
                pass $msg
111
            } else {
112
                fail $msg
113
            }
114
 
115
            # Check dll direct linking through symlink to .sl.
116
            # Create symbolic link.
117
            catch "exec ln -fs direct2_dll.sl $tmpdir/libdirect2_sl.dll.a" ln_catch
118
            set msg "linking client (symlink -> .sl) fastcall/stdcall"
119
            if [ld_simple_link "$CC -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_symlink_sl.exe \
120
              "$tmpdir/direct2_client.o $tmpdir/libdirect2_sl.dll.a" ] {
121
                pass $msg
122
            } else {
123
                fail $msg
124
            }
125
        }
126
    }
127
}
128
 
129
proc directdll_execute {exe msg} {
130
    set expected ""
131
    catch "exec $exe" prog_output
132
    if [string match $expected $prog_output] then {
133
        pass $msg
134
    } else {
135
        verbose $prog_output
136
        fail $msg
137
    }
138
}
139
 
140
test_direct2_link_dll
141
 
142
# This is as far as we can go with a cross-compiler
143
if ![isnative] then {
144
    verbose "Not running natively, so cannot execute binaries"
145
    return
146
}
147
 
148
directdll_execute "$tmpdir/direct2_client_dll.exe" "running direct linked dll (.dll) fastcall/stdcall"
149
directdll_execute "$tmpdir/direct2_client_sl.exe" "running direct linked dll (.sl) fastcall/stdcall"
150
directdll_execute "$tmpdir/direct2_client_symlink_sl.exe" "running direct linked dll (symlink -> .sl) fastcall/stdcall"
151
directdll_execute "$tmpdir/direct2_client_symlink_dll.exe" "running direct linked dll (symlink -> .dll) fastcall/stdcall"

powered by: WebSVN 2.1.0

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