gdb: s390: Correct record/replay of may/mayr insn
[binutils-gdb.git] / ld / testsuite / ld-pe / pe-run2.exp
blob4bf1039995298c7b479bce0089e9c1cf22cb11b8
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 (C) 2006-2024 Free Software Foundation, Inc.
5 # This file is part of the GNU Binutils.
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.
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.
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.
22 # Based on the script pe-run.exp written by Pedro Alves.
23 # Written by Kai Tietz <kai.tietz@onevision.com>
26 # Note:
28 # This test checks the "direct linking to a dll" functionality with stdcall
29 # and fastcall fixup.
31 # The test has 7 stages:
33 # 1. compile and link a test dll with ".dll" extension.
35 # 2. compile and link a test dll with ".sl" (i.e. != ".dll") extension.
37 # 3. compile and link a client application linking directly to the ".dll" dll built in 1.
38 # This should produce no errors.
40 # 4. compile and link a client application linking directly to the ".sl" dll built in 2.
41 # This should produce no errors.
43 # 5. compile and link a client application linking directly to a symlink into
44 # the ".dll" dll built in 1.
45 # This should produce no errors.
47 # 6. compile and link a client application linking directly to a symlink into
48 # the ".sl" dll built in 1.
49 # This should produce no errors.
51 # 7. run the produced executables
53 # This test can only be run on PE/COFF platforms.
54 if {![is_pecoff_format]} {
55 return
58 # No compiler, no test.
59 if { ![check_compiler_available] } {
60 untested "Direct linking to dll fastcall/stdcall test"
61 return
64 set tmpdir tmpdir
66 proc test_direct2_link_dll {} {
67 global CC_FOR_TARGET
68 global CFLAGS_FOR_TARGET
69 global srcdir
70 global subdir
71 global tmpdir
73 # Compile the dll.
74 if ![ld_compile $CC_FOR_TARGET $srcdir/$subdir/direct2_dll.c $tmpdir/direct2_dll.o ] {
75 fail "compiling shared lib fastcall/stdcall"
76 } elseif ![ld_link "$CC_FOR_TARGET -shared -Wl,--enable-stdcall-fixup -Wl,--kill-at " $tmpdir/direct2_dll.dll "$tmpdir/direct2_dll.o" ] {
77 fail "linking shared lib (.dll) fastcall/stdcall"
78 } elseif ![ld_link "$CC_FOR_TARGET -shared -Wl,--enable-stdcall-fixup -Wl,--kill-at " $tmpdir/direct2_dll.sl "$tmpdir/direct2_dll.o" ] {
79 fail "linking shared lib (.sl) fastcall/stdcall"
80 } else {
81 # Compile and link the client program.
82 if ![ld_compile $CC_FOR_TARGET $srcdir/$subdir/direct2_client.c $tmpdir/direct2_client.o ] {
83 fail "compiling client fastcall/stdcall"
84 } else {
85 # Check linking directly to direct2_dll.dll.
86 set msg "linking client (.dll) fastcall/stdcall"
87 if [ld_link "$CC_FOR_TARGET $CFLAGS_FOR_TARGET -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_dll.exe \
88 "$tmpdir/direct2_client.o $tmpdir/direct2_dll.dll" ] {
89 pass $msg
90 } else {
91 fail $msg
94 # Check linking directly to direct2_dll.sl.
95 set msg "linking client (.sl) fastcall/stdcall"
96 if [ld_link "$CC_FOR_TARGET $CFLAGS_FOR_TARGET -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_sl.exe \
97 "$tmpdir/direct2_client.o $tmpdir/direct2_dll.sl" ] {
98 pass $msg
99 } else {
100 fail $msg
103 # Check dll direct linking through symlink to .dll.
104 # Create symbolic link.
105 catch "exec ln -fs direct2_dll.dll $tmpdir/libdirect2_dll.dll.a" ln_catch
106 set msg "linking client (symlink -> .dll) fastcall/stdcall"
107 if [ld_link "$CC_FOR_TARGET $CFLAGS_FOR_TARGET -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_symlink_dll.exe \
108 "$tmpdir/direct2_client.o $tmpdir/libdirect2_dll.dll.a" ] {
109 pass $msg
110 } else {
111 fail $msg
114 # Check dll direct linking through symlink to .sl.
115 # Create symbolic link.
116 catch "exec ln -fs direct2_dll.sl $tmpdir/libdirect2_sl.dll.a" ln_catch
117 set msg "linking client (symlink -> .sl) fastcall/stdcall"
118 if [ld_link "$CC_FOR_TARGET $CFLAGS_FOR_TARGET -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_symlink_sl.exe \
119 "$tmpdir/direct2_client.o $tmpdir/libdirect2_sl.dll.a" ] {
120 pass $msg
121 } else {
122 fail $msg
128 proc directdll_execute {exe msg} {
129 set expected ""
130 catch "exec $exe" prog_output
131 if [string match $expected $prog_output] then {
132 pass $msg
133 } else {
134 verbose $prog_output
135 fail $msg
139 test_direct2_link_dll
141 # This is as far as we can go with a cross-compiler
142 if ![isnative] then {
143 verbose "Not running natively, so cannot execute binaries"
144 return
147 directdll_execute "$tmpdir/direct2_client_dll.exe" "running direct linked dll (.dll) fastcall/stdcall"
148 directdll_execute "$tmpdir/direct2_client_sl.exe" "running direct linked dll (.sl) fastcall/stdcall"
149 directdll_execute "$tmpdir/direct2_client_symlink_sl.exe" "running direct linked dll (symlink -> .sl) fastcall/stdcall"
150 directdll_execute "$tmpdir/direct2_client_symlink_dll.exe" "running direct linked dll (symlink -> .dll) fastcall/stdcall"