[binutils-gdb] Pass -B to objcopy binary symbol test

Alan Modra amodra@sourceware.org
Thu Oct 30 23:33:41 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0bb5cbb9b4b24971af12561071047e5ec4a92772

commit 0bb5cbb9b4b24971af12561071047e5ec4a92772
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Oct 31 09:27:46 2025 +1030

    Pass -B to objcopy binary symbol test
    
    objcopy -I binary -O some_coff_target does not currently work without
    choosing a valid arch with -B.  This used to be the case for ELF
    targets too, until commit 6765ee1825d9.
    
            * testsuite/binutils-all/objcopy.exp (binary_symbol): Pass
            -B arch to objcopy.  Choose different output object files for
            the two tests.

Diff:
---
 binutils/testsuite/binutils-all/objcopy.exp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp
index fe915187f0e..e6fcf5f7f12 100644
--- a/binutils/testsuite/binutils-all/objcopy.exp
+++ b/binutils/testsuite/binutils-all/objcopy.exp
@@ -1613,10 +1613,12 @@ proc binary_symbol {name file args symbol} {
     set test "binary symbol ($name)"
 
     # detect a valid target, take the first supported
-    set target [lindex [split [binutils_run $OBJCOPY "--info"] \n] 1]
+    set inf [split [binutils_run $OBJCOPY "--info"] \n]
+    set target [lindex $inf 1]
+    set arch [string trim [lindex $inf 3]]
 
-    set out tmpdir/binary_symbol.o
-    set got [binutils_run $OBJCOPY "-I binary -O $target $args $file $out"]
+    set out tmpdir/binary_${name}.o
+    set got [binutils_run $OBJCOPY "-I binary -B $arch -O $target $args $file $out"]
 
     set expected [list "${symbol}_end" "${symbol}_size" "${symbol}_start"]


More information about the Binutils-cvs mailing list