| 1 |
# Copyright (C) 2002-2020 Free Software Foundation, Inc. |
| 2 |
|
| 3 |
# This program is free software; you can redistribute it and/or modify |
| 4 |
# it under the terms of the GNU General Public License as published by |
| 5 |
# the Free Software Foundation; either version 3 of the License, or |
| 6 |
# (at your option) any later version. |
| 7 |
# |
| 8 |
# This program is distributed in the hope that it will be useful, |
| 9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
# GNU General Public License for more details. |
| 12 |
# |
| 13 |
# You should have received a copy of the GNU General Public License |
| 14 |
# along with this program; if not, write to the Free Software |
| 15 |
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. |
| 16 |
|
| 17 |
if {![istarget "i*86-*-*"] |
| 18 |
&& ![istarget "x86_64-*-mingw*"] |
| 19 |
&& ![istarget "arm-*-pe*"]} { |
| 20 |
return |
| 21 |
} |
| 22 |
|
| 23 |
if {![istarget "i*86-*-*pe*"] \ |
| 24 |
&& ![istarget "i*86-*-cygwin*"] \ |
| 25 |
&& ![istarget "i*86-*-mingw32*"] \ |
| 26 |
&& ![istarget "arm-*-pe*"] \ |
| 27 |
&& ![istarget "x86_64-*-mingw*"] } { |
| 28 |
set target_xfail "yes" |
| 29 |
} else { |
| 30 |
set target_xfail "no" |
| 31 |
} |
| 32 |
|
| 33 |
# PR 19459: The ARM does not support inserting a leading underscore. |
| 34 |
if { [istarget "arm-*-pe*"] } { |
| 35 |
set target_no_leading_underscore "yes" |
| 36 |
} else { |
| 37 |
set target_no_leading_underscore "no" |
| 38 |
} |
| 39 |
|
| 40 |
if {![info exists DLLTOOL]} then { |
| 41 |
return |
| 42 |
} |
| 43 |
|
| 44 |
if {[which $DLLTOOL] == 0} then { |
| 45 |
return |
| 46 |
} |
| 47 |
|
| 48 |
verbose "$DLLTOOL --leading-underscore -d $srcdir/$subdir/fastcall.def" 1 |
| 49 |
catch "exec $DLLTOOL --leading-underscore -d $srcdir/$subdir/fastcall.def" err |
| 50 |
|
| 51 |
if ![string match "" $err] then { |
| 52 |
send_log "$err\n" |
| 53 |
verbose "$err" 1 |
| 54 |
fail "dlltool (fastcall export)" |
| 55 |
} else { |
| 56 |
pass "dlltool (fastcall export)" |
| 57 |
} |
| 58 |
|
| 59 |
if { "$target_xfail" == "yes" } { |
| 60 |
setup_xfail *-* |
| 61 |
} |
| 62 |
|
| 63 |
verbose "$DLLTOOL -l libversion.a --def $srcdir/$subdir/version.def $dlltool_gas_flag" 1 |
| 64 |
catch "exec $DLLTOOL -l libersion.a --def $srcdir/$subdir/version.def $dlltool_gas_flag" err |
| 65 |
|
| 66 |
if ![string match "" $err] then { |
| 67 |
send_log "$err\n" |
| 68 |
verbose "$err" 1 |
| 69 |
fail "dlltool (version.dll)" |
| 70 |
} else { |
| 71 |
pass "dlltool (version.dll)" |
| 72 |
} |
| 73 |
|
| 74 |
if { "$target_xfail" == "yes" } { |
| 75 |
setup_xfail *-* |
| 76 |
} |
| 77 |
|
| 78 |
verbose "$DLLTOOL -p prefix --leading-underscore -l tmpdir/libalias.a -d $srcdir/$subdir/alias.def $dlltool_gas_flag" 1 |
| 79 |
catch "exec $DLLTOOL -p prefix --leading-underscore -l tmpdir/libalias.a -d $srcdir/$subdir/alias.def $dlltool_gas_flag" err |
| 80 |
|
| 81 |
if ![string match "" $err] then { |
| 82 |
send_log "$err\n" |
| 83 |
verbose "$err" 1 |
| 84 |
fail "dlltool -p (execution)" |
| 85 |
continue |
| 86 |
} |
| 87 |
|
| 88 |
pass "dlltool -p (execution)" |
| 89 |
|
| 90 |
set got [binutils_run $NM "tmpdir/libalias.a"] |
| 91 |
if { "$target_no_leading_underscore" == "yes" } { |
| 92 |
set want "00000000 I __imp_prefixsymbol.*00000000 T prefixsymbol.*00000000 I __imp_symbol.*00000000 T symbol" |
| 93 |
} else { |
| 94 |
set want "00000000 I __imp__prefix_symbol.*00000000 T _prefix_symbol.*00000000 I __imp__symbol.*00000000 T _symbol" |
| 95 |
} |
| 96 |
|
| 97 |
if [regexp $want $got] then { |
| 98 |
pass "dlltool -p (symbol names)" |
| 99 |
} else { |
| 100 |
fail "dlltool -p (symbol names)" |
| 101 |
} |
| 102 |
|
| 103 |
set got [binutils_run $OBJDUMP "-s -j .idata\$6 tmpdir/libalias.a"] |
| 104 |
set want "(Contents of section .idata\\\$6:.*\\.\\.symbol\\.\\..*){2,2}" |
| 105 |
|
| 106 |
if [regexp $want $got] then { |
| 107 |
pass "dlltool -p (import name)" |
| 108 |
} else { |
| 109 |
fail "dlltool -p (import name)" |
| 110 |
} |
| 111 |
|
| 112 |
verbose "$DLLTOOL -p prefix --leading-underscore -l tmpdir/libalias2.a -d $srcdir/$subdir/alias-2.def $dlltool_gas_flag" 1 |
| 113 |
catch "exec $DLLTOOL -p prefix --leading-underscore -l tmpdir/libalias2.a -d $srcdir/$subdir/alias-2.def $dlltool_gas_flag" err |
| 114 |
|
| 115 |
if ![string match "" $err] then { |
| 116 |
send_log "$err\n" |
| 117 |
verbose "$err" 1 |
| 118 |
fail "dlltool -p (execution) alias-2.def" |
| 119 |
continue |
| 120 |
} |
| 121 |
|
| 122 |
pass "dlltool -p (execution) alias-2.def" |
| 123 |
|
| 124 |
set got [binutils_run $NM "tmpdir/libalias2.a"] |
| 125 |
if { "$target_no_leading_underscore" == "yes" } { |
| 126 |
set want "00000000 I __imp_prefixsymbol.*00000000 T prefixsymbol.*00000000 I __imp_symbol.*00000000 T symbol" |
| 127 |
} else { |
| 128 |
set want "00000000 I __imp__prefix_symbol.*00000000 T _prefix_symbol.*00000000 I __imp__symbol.*00000000 T _symbol" |
| 129 |
} |
| 130 |
|
| 131 |
if [regexp $want $got] then { |
| 132 |
pass "dlltool -p (symbol names) alias-2.def" |
| 133 |
} else { |
| 134 |
fail "dlltool -p (symbol names) alias-2.def" |
| 135 |
} |
| 136 |
|
| 137 |
set got [binutils_run $OBJDUMP "-s -j .idata\$6 tmpdir/libalias2.a"] |
| 138 |
set want "(Contents of section .idata\\\$6:.*\\.\\.something\\..*){2,2}" |
| 139 |
|
| 140 |
if [regexp $want $got] then { |
| 141 |
pass "dlltool -p (import name) alias-2.def" |
| 142 |
} else { |
| 143 |
fail "dlltool -p (import name) alias-2.def" |
| 144 |
} |
| 145 |
|
| 146 |
# Here we test explicit without leading underscore |
| 147 |
|
| 148 |
verbose "$DLLTOOL --no-leading-underscore -d $srcdir/$subdir/fastcall.def" 1 |
| 149 |
catch "exec $DLLTOOL --no-leading-underscore -d $srcdir/$subdir/fastcall.def" err |
| 150 |
|
| 151 |
if ![string match "" $err] then { |
| 152 |
send_log "$err\n" |
| 153 |
verbose "$err" 1 |
| 154 |
fail "dlltool (fastcall export no leading underscore)" |
| 155 |
} else { |
| 156 |
pass "dlltool (fastcall export no leading underscore)" |
| 157 |
} |
| 158 |
|
| 159 |
verbose "$DLLTOOL --no-leading-underscore -p prefix -l tmpdir/libalias_nu.a -d $srcdir/$subdir/alias.def $dlltool_gas_flag" 1 |
| 160 |
catch "exec $DLLTOOL --no-leading-underscore -p prefix -l tmpdir/libalias_nu.a -d $srcdir/$subdir/alias.def $dlltool_gas_flag" err |
| 161 |
|
| 162 |
if ![string match "" $err] then { |
| 163 |
send_log "$err\n" |
| 164 |
verbose "$err" 1 |
| 165 |
fail "dlltool -p (execution no leading underscore)" |
| 166 |
continue |
| 167 |
} |
| 168 |
|
| 169 |
pass "dlltool -p (execution no leading underscore)" |
| 170 |
|
| 171 |
set got [binutils_run $NM "tmpdir/libalias_nu.a"] |
| 172 |
set want "00000000 I __imp_prefixsymbol.*00000000 T prefixsymbol.*00000000 I __imp_symbol.*00000000 T symbol" |
| 173 |
|
| 174 |
if [regexp $want $got] then { |
| 175 |
pass "dlltool -p (symbol names no leading underscore)" |
| 176 |
} else { |
| 177 |
fail "dlltool -p (symbol names no leading underscore)" |
| 178 |
} |
| 179 |
|
| 180 |
set got [binutils_run $OBJDUMP "-s -j .idata\$6 tmpdir/libalias_nu.a"] |
| 181 |
set want "(Contents of section .idata\\\$6:.*\\.\\.symbol\\.\\..*){2,2}" |
| 182 |
|
| 183 |
if [regexp $want $got] then { |
| 184 |
pass "dlltool -p (import name no leading underscore)" |
| 185 |
} else { |
| 186 |
fail "dlltool -p (import name no leading underscore)" |
| 187 |
} |
| 188 |
|
| 189 |
verbose "$DLLTOOL --no-leading-underscore -p prefix -l tmpdir/libalias_nu2.a -d $srcdir/$subdir/alias-2.def $dlltool_gas_flag" 1 |
| 190 |
catch "exec $DLLTOOL --no-leading-underscore -p prefix -l tmpdir/libalias_nu2.a -d $srcdir/$subdir/alias-2.def $dlltool_gas_flag" err |
| 191 |
|
| 192 |
if ![string match "" $err] then { |
| 193 |
send_log "$err\n" |
| 194 |
verbose "$err" 1 |
| 195 |
fail "dlltool -p (execution no leading underscore) alias-2.def" |
| 196 |
continue |
| 197 |
} |
| 198 |
|
| 199 |
pass "dlltool -p (execution no leading underscore) alias-2.def" |
| 200 |
|
| 201 |
set got [binutils_run $NM "tmpdir/libalias_nu2.a"] |
| 202 |
set want "00000000 I __imp_prefixsymbol.*00000000 T prefixsymbol.*00000000 I __imp_symbol.*00000000 T symbol" |
| 203 |
|
| 204 |
if [regexp $want $got] then { |
| 205 |
pass "dlltool -p (symbol names no leading underscore) alias-2.def" |
| 206 |
} else { |
| 207 |
fail "dlltool -p (symbol names no leading underscore) alias-2.def" |
| 208 |
} |
| 209 |
|
| 210 |
set got [binutils_run $OBJDUMP "-s -j .idata\$6 tmpdir/libalias_nu2.a"] |
| 211 |
set want "(Contents of section .idata\\\$6:.*\\.\\.something\\..*){2,2}" |
| 212 |
|
| 213 |
if [regexp $want $got] then { |
| 214 |
pass "dlltool -p (import name no leading underscore) alias-2.def" |
| 215 |
} else { |
| 216 |
fail "dlltool -p (import name no leading underscore) alias-2.def" |
| 217 |
} |
| 218 |
|
| 219 |
# Now we test with leading underscore |
| 220 |
verbose "$DLLTOOL --leading-underscore -d $srcdir/$subdir/fastcall.def" 1 |
| 221 |
catch "exec $DLLTOOL --leading-underscore -d $srcdir/$subdir/fastcall.def" err |
| 222 |
|
| 223 |
if ![string match "" $err] then { |
| 224 |
send_log "$err\n" |
| 225 |
verbose "$err" 1 |
| 226 |
fail "dlltool (fastcall export leading underscore)" |
| 227 |
} else { |
| 228 |
pass "dlltool (fastcall export leading underscore)" |
| 229 |
} |
| 230 |
|
| 231 |
verbose "$DLLTOOL --leading-underscore -p prefix -l tmpdir/libalias_u.a -d $srcdir/$subdir/alias.def $dlltool_gas_flag" 1 |
| 232 |
catch "exec $DLLTOOL --leading-underscore -p prefix -l tmpdir/libalias_u.a -d $srcdir/$subdir/alias.def $dlltool_gas_flag" err |
| 233 |
|
| 234 |
if ![string match "" $err] then { |
| 235 |
send_log "$err\n" |
| 236 |
verbose "$err" 1 |
| 237 |
fail "dlltool -p (execution leading underscore)" |
| 238 |
continue |
| 239 |
} |
| 240 |
|
| 241 |
pass "dlltool -p (execution leading-underscore)" |
| 242 |
|
| 243 |
set got [binutils_run $NM "tmpdir/libalias_u.a"] |
| 244 |
if { "$target_no_leading_underscore" == "yes" } { |
| 245 |
set want "00000000 I __imp_prefixsymbol.*00000000 T prefixsymbol.*00000000 I __imp_symbol.*00000000 T symbol" |
| 246 |
} else { |
| 247 |
set want "00000000 I __imp__prefix_symbol.*00000000 T _prefix_symbol.*00000000 I __imp__symbol.*00000000 T _symbol" |
| 248 |
} |
| 249 |
|
| 250 |
if { "$target_xfail" == "yes" } { |
| 251 |
setup_xfail *-* |
| 252 |
} |
| 253 |
|
| 254 |
if [regexp $want $got] then { |
| 255 |
pass "dlltool -p (symbol names leading underscore)" |
| 256 |
} else { |
| 257 |
fail "dlltool -p (symbol names leading underscore)" |
| 258 |
} |
| 259 |
|
| 260 |
set got [binutils_run $OBJDUMP "-s -j .idata\$6 tmpdir/libalias_u.a"] |
| 261 |
set want "(Contents of section .idata\\\$6:.*\\.\\.symbol\\..*){2,2}" |
| 262 |
|
| 263 |
if [regexp $want $got] then { |
| 264 |
pass "dlltool -p (import name leading underscore)" |
| 265 |
} else { |
| 266 |
fail "dlltool -p (import name leading underscore)" |
| 267 |
} |
| 268 |
|
| 269 |
verbose "$DLLTOOL --leading-underscore -p prefix -l tmpdir/libalias_u2.a -d $srcdir/$subdir/alias-2.def $dlltool_gas_flag" 1 |
| 270 |
catch "exec $DLLTOOL --leading-underscore -p prefix -l tmpdir/libalias_u2.a -d $srcdir/$subdir/alias-2.def $dlltool_gas_flag" err |
| 271 |
|
| 272 |
if ![string match "" $err] then { |
| 273 |
send_log "$err\n" |
| 274 |
verbose "$err" 1 |
| 275 |
fail "dlltool -p (execution) alias-2.def" |
| 276 |
continue |
| 277 |
} |
| 278 |
|
| 279 |
pass "dlltool -p (execution leading underscore) alias-2.def" |
| 280 |
|
| 281 |
set got [binutils_run $NM "tmpdir/libalias_u2.a"] |
| 282 |
if { "$target_no_leading_underscore" == "yes" } { |
| 283 |
set want "00000000 I __imp_prefixsymbol.*00000000 T prefixsymbol.*00000000 I __imp_symbol.*00000000 T symbol" |
| 284 |
} else { |
| 285 |
set want "00000000 I __imp__prefix_symbol.*00000000 T _prefix_symbol.*00000000 I __imp__symbol.*00000000 T _symbol" |
| 286 |
} |
| 287 |
|
| 288 |
if [regexp $want $got] then { |
| 289 |
pass "dlltool -p (symbol names leading underscore) alias-2.def" |
| 290 |
} else { |
| 291 |
fail "dlltool -p (symbol names leading underscore) alias-2.def" |
| 292 |
} |
| 293 |
|
| 294 |
set got [binutils_run $OBJDUMP "-s -j .idata\$6 tmpdir/libalias_u2.a"] |
| 295 |
set want "(Contents of section .idata\\\$6:.*\\.\\.something\\..*){2,2}" |
| 296 |
|
| 297 |
if [regexp $want $got] then { |
| 298 |
pass "dlltool -p (import name leading underscore) alias-2.def" |
| 299 |
} else { |
| 300 |
fail "dlltool -p (import name leading underscore) alias-2.def" |
| 301 |
} |