From bb2c1d3b8febad6baf66cd1c222ef005b8b411d4 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 10 Jun 2021 06:29:08 -0700 Subject: [PATCH] x86: Update gas_bfd64_check to check 64-bit ELF assembler If assembler --help doesn't report --32/--64/--x32 generate 32bit/64bit/x32 code check if assembler is a 64-bit ELF binary for BFD64. * testsuite/gas/i386/i386.exp (gas_bfd64_check): Check 64-bit ELF assembler for BFD64. --- gas/testsuite/gas/i386/i386.exp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp index cf215117cad..53d69d8c80b 100644 --- a/gas/testsuite/gas/i386/i386.exp +++ b/gas/testsuite/gas/i386/i386.exp @@ -39,9 +39,27 @@ proc gas_32_check { } { proc gas_bfd64_check { } { global AS + global READELF + global base_dir + global AS_BFD64 - set status [gas_host_run "$AS --help" ""] - return [regexp "32bit/64bit/x32" [lindex $status 1]]; + # Set AS_BFD64 to "1" for assembler with BFD64. + if { ![info exists AS_CLASS] } then { + set status [gas_host_run "$AS --help" ""] + if { [regexp "32bit/64bit/x32" [lindex $status 1]] } then { + set AS_BFD64 1 + } else { + set REAL_AS [findfile $base_dir/.libs/as-new .libs/as-new $AS [transform as]] + set readelf_output [gas_host_run "$READELF -h $REAL_AS" ""] + if { [regexp {[ \t]+Class:[ \t]+ELF64} $readelf_output] } then { + set AS_BFD64 1 + } else { + set AS_BFD64 0 + } + } + } + + return $AS_BFD64 } if [gas_32_check] then { -- 2.31.1