summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-08-19 13:15:06 +0930
committerAlan Modra <amodra@gmail.com>2021-08-24 20:39:29 +0930
commitd4f5b5e214d1a2a8456e71bd04cd3205d8839642 (patch)
tree6e334c50c2aa1633603a0661b52c32fe25f05bf2
parentee077885e5d182d0d9fba090f3505f16f640dff7 (diff)
downloadbinutils-gdb-d4f5b5e214d1a2a8456e71bd04cd3205d8839642.tar.gz
objdump -S test fail on mingw
FAIL: objdump -S FAIL: objdump --source-comment is seen on mingw for the simple reason that gcc adds a .exe suffix on the output file if not already present. Fix that, and tidy some objcopy tests. * testsuite/lib/binutils-common.exp (exeext): New proc. * testsuite/binutils-all/objcopy.exp (exe, test_prog): Use it here. (objcopy_remove_relocations_from_executable): Catch objcopy errors. Only run on ELF targets. * testsuite/binutils-all/objdump.exp (exe): Set variable. (test_build_id_debuglink, test_objdump_S): Use exe file suffix.
-rw-r--r--binutils/testsuite/binutils-all/objcopy.exp18
-rw-r--r--binutils/testsuite/binutils-all/objdump.exp15
-rw-r--r--binutils/testsuite/lib/binutils-common.exp12
3 files changed, 33 insertions, 12 deletions
diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp
index e1df9ff748d..88ed3100ed0 100644
--- a/binutils/testsuite/binutils-all/objcopy.exp
+++ b/binutils/testsuite/binutils-all/objcopy.exp
@@ -631,11 +631,8 @@ strip_test_with_saving_a_symbol
# Build a final executable.
-if { [istarget *-*-cygwin] || [istarget *-*-mingw*] } {
- set test_prog "testprog.exe"
-} else {
- set test_prog "testprog"
-}
+set exe [exeext]
+set test_prog "testprog${exe}"
proc copy_setup { } {
global srcdir
@@ -1342,6 +1339,13 @@ proc objcopy_remove_relocations_from_executable { } {
set out tmpdir/pr23611.out
set exec_output1 [binutils_run $OBJCOPY "-R .rela.plt -R .rela.dyn -R .rel.plt -R .rel.dyn $objfile $out"]
+
+ set exec_output1 [prune_warnings $exec_output1]
+ if ![string equal "" $exec_output1] {
+ fail $test
+ return
+ }
+
set exec_output2 [binutils_run $READELF "-S $out"]
if { [string match "*.rel.plt*" $exec_output2] || [string match "*.rela.plt*" $exec_output2] || [string match "*.rel.dyn*" $exec_output2] || [string match "*.rela.dyn*" $exec_output2] } {
fail $test
@@ -1350,7 +1354,9 @@ proc objcopy_remove_relocations_from_executable { } {
pass $test
}
-objcopy_remove_relocations_from_executable
+if [is_elf_format] {
+ objcopy_remove_relocations_from_executable
+}
run_dump_test "pr23633"
diff --git a/binutils/testsuite/binutils-all/objdump.exp b/binutils/testsuite/binutils-all/objdump.exp
index c9a7eec75ec..0b797f9e9b4 100644
--- a/binutils/testsuite/binutils-all/objdump.exp
+++ b/binutils/testsuite/binutils-all/objdump.exp
@@ -62,6 +62,7 @@ set obj o
if { [istarget "*-*-vms"] } then {
set obj obj
}
+set exe [exeext]
# The remaining tests require a test file.
@@ -519,6 +520,7 @@ proc test_build_id_debuglink {} {
global OBJCOPY
global OBJDUMP
global CFLAGS_FOR_TARGET
+ global exe
set test "build-id-debuglink"
@@ -528,7 +530,7 @@ proc test_build_id_debuglink {} {
}
set CFLAGS_FOR_TARGET "-g -Wl,--build-id=0x12345678abcdef01"
- if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog executable debug] != "" } {
+ if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog${exe} executable debug] != "" } {
unsupported "$test (build)"
return
}
@@ -539,12 +541,12 @@ proc test_build_id_debuglink {} {
unset CFLAGS_FOR_TARGET
}
- if { [binutils_run $STRIP "--strip-debug --remove-section=.comment tmpdir/testprog -o tmpdir/testprog.strip"] != "" } {
+ if { [binutils_run $STRIP "--strip-debug --remove-section=.comment tmpdir/testprog${exe} -o tmpdir/testprog.strip"] != "" } {
fail "$test (strip debug info)"
return
}
- if { [binutils_run $OBJCOPY "--only-keep-debug tmpdir/testprog tmpdir/testprog.debug"] != "" } {
+ if { [binutils_run $OBJCOPY "--only-keep-debug tmpdir/testprog${exe} tmpdir/testprog.debug"] != "" } {
fail "$test (create separate debug info file)"
return
}
@@ -813,15 +815,16 @@ proc test_objdump_S { } {
global subdir
global OBJDUMP
global OBJDUMPFLAGS
+ global exe
set test "objdump -S"
- if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog executable debug] != "" } {
+ if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog${exe} executable debug] != "" } {
unsupported "$test (build)"
return
}
- set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -D -S tmpdir/testprog"]
+ set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS -D -S tmpdir/testprog${exe}"]
set want "static int local = 2"
@@ -833,7 +836,7 @@ proc test_objdump_S { } {
set test "objdump --source-comment"
- set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble-all --source-comment=// tmpdir/testprog"]
+ set got [binutils_run $OBJDUMP "$OBJDUMPFLAGS --disassemble-all --source-comment=// tmpdir/testprog${exe}"]
set want "//static int local = 2"
diff --git a/binutils/testsuite/lib/binutils-common.exp b/binutils/testsuite/lib/binutils-common.exp
index d07b32c2e0e..0419b3b0b93 100644
--- a/binutils/testsuite/lib/binutils-common.exp
+++ b/binutils/testsuite/lib/binutils-common.exp
@@ -183,6 +183,18 @@ proc is_rela { binary_file } {
return 1
}
+# Return the file name suffix required for executables, if any.
+#
+proc exeext {} {
+ if { [istarget *-*-cygwin*]
+ || [istarget *-*-mingw*]
+ || [istarget *-*-msdos*]
+ || [istarget *-*-*vms*] } {
+ return ".exe"
+ }
+ return ""
+}
+
# True if the target matches TARGET, specified as a TCL procedure if
# in square brackets or as machine triplet otherwise.
#