1 # Expect script for complex PE tests that require a C compiler
2 # in addition to the just-built binutils.
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,
24 # These tests can only be run on PE/COFF platforms.
25 if {![is_pecoff_format]} {
29 # No compiler, no test.
30 if { [which $CC] == 0 } {
31 untested "PE version scripts"
32 untested "aligned common tests"
33 # Add more "untested" directives here when adding more tests below.
37 proc build_basefile1_o {} {
43 # Compile the object file.
44 if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/basefile1.s tmpdir/basefile1.o] {
45 fail "compiling basefile1 object"
49 proc run_basefile_test { testname } {
56 if ![ld_simple_link "$LD -e start \
57 --base-file=tmpdir/$testname.base \
58 --export-all-symbols" tmpdir/$testname.dll \
59 "tmpdir/basefile1.o"] {
64 if { $verbose > 2 } then { verbose "output is [file_contents tmpdir/$testname.base]" 3 }
66 catch "exec wc -c tmpdir/$testname.base" err
68 if ![string match "0 tmpdir/$testname.base" [string trim $err]] then {
70 if { $verbose == 2 } then { verbose "$err" 2 }
78 proc build_vers_script_dll_o {} {
84 # Compile the object file.
85 if ![ld_compile "$CC $CFLAGS -shared" $srcdir/$subdir/vers-script-dll.c tmpdir/vers-script-dll.o] {
86 fail "compiling shared lib object"
90 proc run_ver_script_test { testname } {
96 if ![ld_simple_link "$CC -shared \
97 -Wl,--version-script,$srcdir/$subdir/$testname.ver \
98 -Wl,--output-def,tmpdir/$testname.def" tmpdir/$testname.dll \
99 "tmpdir/vers-script-dll.o"] {
103 if { $verbose > 2 } then { verbose "output is [file_contents tmpdir/$testname.def]" 3 }
104 if { [regexp_diff tmpdir/$testname.def $srcdir/$subdir/$testname.d] } then {
106 if { $verbose == 2 } then { verbose "output is [file_contents tmpdir/$testname.def]" 2 }
114 build_vers_script_dll_o
116 run_ver_script_test "vers-script-1"
117 run_ver_script_test "vers-script-2"
118 run_ver_script_test "vers-script-3"
119 run_ver_script_test "vers-script-4"
121 if {[istarget i*86-*-cygwin*]
122 || [istarget i*86-*-pe]
123 || [istarget i*86-*-mingw*]
124 || [istarget x86_64-*-mingw*] } {
127 run_basefile_test "basefile-secrel"
129 untested "PE basefile test"
133 {"aligned common 1" "" "" {aligncomm-1.c}
134 {{nm -C aligncomm.d}} "aligncomm-1.x"}
135 {"aligned common 2" "" "" {aligncomm-2.c}
136 {{nm -C aligncomm.d}} "aligncomm-2.x"}
137 {"aligned common 3" "" "" {aligncomm-3.c}
138 {{nm -C aligncomm.d}} "aligncomm-3.x"}
139 {"aligned common 4" "" "" {aligncomm-4.c}
140 {{nm -C aligncomm.d}} "aligncomm-4.x"}
143 run_ld_link_tests $align_tests