1 # 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.
6 # This file is part of the GNU Binutils.
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.
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.
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
,
23 # Based
on the script pe
-run.exp written by Pedro Alves.
24 # Written by Kai Tietz
<kai.tietz@onevision.com
>
29 # This test checks the
"direct linking to a dll" functionality with stdcall
32 # The test has
7 stages
:
34 #
1.
compile and link a test dll with
".dll" extension.
36 #
2.
compile and link a test dll with
".sl" (i.e. != ".dll") extension.
38 #
3.
compile and link a client application linking directly to the
".dll" dll built in 1.
39 # This should produce no errors.
41 #
4.
compile and link a client application linking directly to the
".sl" dll built in 2.
42 # This should produce no errors.
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.
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.
52 #
7. run the produced executables
54 # This test can only be run
on PE
/COFF platforms.
55 if {![is_pecoff_format
]} {
59 # No compiler
, no test.
60 if { [which $CC
] == 0 } {
61 untested
"Direct linking to dll fastcall/stdcall test"
67 proc test_direct2_link_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"
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"
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 --enable-auto-import" $tmpdir/direct2_client_dll.exe \
89 "$tmpdir/direct2_client.o $tmpdir/direct2_dll.dll" ] {
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" ] {
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" ] {
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" ] {
129 proc directdll_execute
{exe msg
} {
131 catch
"exec $exe" prog_output
132 if [string match $expected $prog_output
] then {
140 test_direct2_link_dll
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"
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"