Enable dlltool --leading-underscore for targets other than x86

Alan Modra amodra@gmail.com
Thu Oct 3 04:30:44 GMT 2024


This also makes the dlltool tests run more PE targets, finding that
sh-pe dlltool reports "Machine 'sh' not supported".  I guess no one
cares about that.

	PR19459
	* dlltool.c (asm_prefix): Remove "mach" parameter.  Return
	leading_underscore independent of machine.
	(ASM_PREFIX): Adjust.
	* testsuite/binutils-all/dlltool.exp: Run on any target
	satisfying is_pecoff_format for which dlltool is built.
	Revert commit 0398b8d6c86a.  Remove target_xfail.

diff --git a/binutils/dlltool.c b/binutils/dlltool.c
index c7f4b154242..9acd080b7b6 100644
--- a/binutils/dlltool.c
+++ b/binutils/dlltool.c
@@ -903,11 +903,8 @@ rvabefore (int mach)
 }
 
 static const char *
-asm_prefix (int mach, const char *name)
+asm_prefix (const char *name)
 {
-  /* ??? --leading_underscore is only supported on x86.  */
-  if (!(mach == M386 || mach == MX86))
-    return "";
   /* Symbol names starting with ? do not have a leading underscore.  */
   if (name && *name == '?')
     return "";
@@ -925,7 +922,7 @@ asm_prefix (int mach, const char *name)
 #define ASM_ALIGN_SHORT		mtable[machine].how_align_short
 #define ASM_RVA_BEFORE		rvabefore (machine)
 #define ASM_RVA_AFTER		rvaafter (machine)
-#define ASM_PREFIX(NAME)	asm_prefix (machine, (NAME))
+#define ASM_PREFIX(NAME)	asm_prefix (NAME)
 #define ASM_ALIGN_LONG  	mtable[machine].how_align_long
 #define HOW_BFD_READ_TARGET	0  /* Always default.  */
 #define HOW_BFD_WRITE_TARGET	mtable[machine].how_bfd_target
diff --git a/binutils/testsuite/binutils-all/dlltool.exp b/binutils/testsuite/binutils-all/dlltool.exp
index ac1306bdf77..7bae86b61bc 100644
--- a/binutils/testsuite/binutils-all/dlltool.exp
+++ b/binutils/testsuite/binutils-all/dlltool.exp
@@ -14,29 +14,10 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
 
-if {![istarget "i*86-*-*"]
-    && ![istarget "x86_64-*-mingw*"]
-    && ![istarget "arm-*-pe*"]} {
+if { ![is_pecoff_format] } {
     return
 }
 
-if {![istarget "i*86-*-*pe*"] \
-    && ![istarget "i*86-*-cygwin*"] \
-    && ![istarget "i*86-*-mingw32*"] \
-    && ![istarget "arm-*-pe*"] \
-    && ![istarget "x86_64-*-mingw*"] } {
-    set target_xfail "yes"
-} else {
-    set target_xfail "no"
-}
-
-# PR 19459: The ARM does not support inserting a leading underscore.
-if { [istarget "arm-*-pe*"] } {
-    set target_no_leading_underscore "yes"
-} else {
-    set target_no_leading_underscore "no"
-}
-
 if {![info exists DLLTOOL]} then {
     return
 }
@@ -56,10 +37,6 @@ if ![string match "" $err] then {
     pass "dlltool (fastcall export)"
 }
 
-if { "$target_xfail" == "yes" } {
-    setup_xfail *-*
-}
-
 verbose "$DLLTOOL -l libversion.a --def $srcdir/$subdir/version.def $dlltool_gas_flag" 1
 catch "exec $DLLTOOL -l libersion.a --def $srcdir/$subdir/version.def $dlltool_gas_flag" err
 
@@ -71,10 +48,6 @@ if ![string match "" $err] then {
     pass "dlltool (version.dll)"
 }
 
-if { "$target_xfail" == "yes" } {
-    setup_xfail *-*
-}
-
 verbose "$DLLTOOL -p prefix --leading-underscore -l tmpdir/libalias.a -d $srcdir/$subdir/alias.def $dlltool_gas_flag" 1
 catch "exec $DLLTOOL -p prefix --leading-underscore -l tmpdir/libalias.a -d $srcdir/$subdir/alias.def $dlltool_gas_flag" err
 
@@ -88,11 +61,7 @@ if ![string match "" $err] then {
 pass "dlltool -p (execution)"
 
 set got [binutils_run $NM "tmpdir/libalias.a"]
-if { "$target_no_leading_underscore" == "yes" } {
-    set want "00000000 I __imp_prefixsymbol.*00000000 T prefixsymbol.*00000000 I __imp_symbol.*00000000 T symbol"
-} else {
-    set want "00000000 I __imp__prefix_symbol.*00000000 T _prefix_symbol.*00000000 I __imp__symbol.*00000000 T _symbol"
-}
+set want "00000000 I __imp__prefix_symbol.*00000000 T _prefix_symbol.*00000000 I __imp__symbol.*00000000 T _symbol"
 
 if [regexp $want $got] then {
     pass "dlltool -p (symbol names)"
@@ -122,11 +91,7 @@ if ![string match "" $err] then {
 pass "dlltool -p (execution) alias-2.def"
 
 set got [binutils_run $NM "tmpdir/libalias2.a"]
-if { "$target_no_leading_underscore" == "yes" } {
-    set want "00000000 I __imp_prefixsymbol.*00000000 T prefixsymbol.*00000000 I __imp_symbol.*00000000 T symbol"
-} else {
-    set want "00000000 I __imp__prefix_symbol.*00000000 T _prefix_symbol.*00000000 I __imp__symbol.*00000000 T _symbol"
-}
+set want "00000000 I __imp__prefix_symbol.*00000000 T _prefix_symbol.*00000000 I __imp__symbol.*00000000 T _symbol"
 
 if [regexp $want $got] then {
     pass "dlltool -p (symbol names) alias-2.def"
@@ -241,15 +206,7 @@ if ![string match "" $err] then {
 pass "dlltool -p (execution leading-underscore)"
 
 set got [binutils_run $NM "tmpdir/libalias_u.a"]
-if { "$target_no_leading_underscore" == "yes" } {
-    set want "00000000 I __imp_prefixsymbol.*00000000 T prefixsymbol.*00000000 I __imp_symbol.*00000000 T symbol"
-} else {
-    set want "00000000 I __imp__prefix_symbol.*00000000 T _prefix_symbol.*00000000 I __imp__symbol.*00000000 T _symbol"
-}
-
-if { "$target_xfail" == "yes" } {
-    setup_xfail *-*
-}
+set want "00000000 I __imp__prefix_symbol.*00000000 T _prefix_symbol.*00000000 I __imp__symbol.*00000000 T _symbol"
 
 if [regexp $want $got] then {
     pass "dlltool -p (symbol names leading underscore)"
@@ -279,11 +236,7 @@ if ![string match "" $err] then {
 pass "dlltool -p (execution leading underscore) alias-2.def"
 
 set got [binutils_run $NM "tmpdir/libalias_u2.a"]
-if { "$target_no_leading_underscore" == "yes" } {
-    set want "00000000 I __imp_prefixsymbol.*00000000 T prefixsymbol.*00000000 I __imp_symbol.*00000000 T symbol"
-} else {
-    set want "00000000 I __imp__prefix_symbol.*00000000 T _prefix_symbol.*00000000 I __imp__symbol.*00000000 T _symbol"
-}
+set want "00000000 I __imp__prefix_symbol.*00000000 T _prefix_symbol.*00000000 I __imp__symbol.*00000000 T _symbol"
 
 if [regexp $want $got] then {
     pass "dlltool -p (symbol names leading underscore) alias-2.def"

-- 
Alan Modra


More information about the Binutils mailing list