From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1256) id A74BB3870C2F; Fri, 28 Jul 2023 05:06:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A74BB3870C2F Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Maciej W. Rozycki To: bfd-cvs@sourceware.org Subject: [binutils-gdb] MIPS: Support `-gnuabi64' target triplet suffix for 64-bit Linux targets X-Act-Checkin: binutils-gdb X-Git-Author: YunQiang Su X-Git-Refname: refs/heads/master X-Git-Oldrev: 316be2b229f5bd07ebef48fd1d7b8cb103e4d815 X-Git-Newrev: 29c108c9610640439daa5244a573348b7c47d994 Message-Id: <20230728050659.A74BB3870C2F@sourceware.org> Date: Fri, 28 Jul 2023 05:06:59 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jul 2023 05:06:59 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D29c108c96106= 40439daa5244a573348b7c47d994 commit 29c108c9610640439daa5244a573348b7c47d994 Author: YunQiang Su Date: Fri Jul 28 06:00:37 2023 +0100 MIPS: Support `-gnuabi64' target triplet suffix for 64-bit Linux targets =20 Make the n64 ABI the default for 64-bit Linux targets specified with `-gnuabi64' suffix included in the target triplet, for configurations such as the Debian mips64el and mips64r6el ports. Adjust testsuite configuration accordingly. =20 There are the following regressions with the new target triplet: =20 mips64-linux-gnuabi64 +FAIL: readelf -S bintest mips64-linux-gnuabi64 +FAIL: MIPS reloc estimation 1 mips64el-linux-gnuabi64 +FAIL: readelf -S bintest mips64el-linux-gnuabi64 +FAIL: MIPS reloc estimation 1 =20 The `readelf' issue comes from a difference in section headers produced that the `binutils/testsuite/binutils-all/readelf.s-64' pattern template does not match. While there has been a precedent it does not appear to me that there is a clear advantage from adding more and more variations to the template rather than forking the existing template into multiple ones for a more exact match. So this is best deferred to a separate discussion. =20 The MIPS reloc estimation issue is an actual bug in `objdump', which discards a number of trailing entries from output here for n64 composed relocations: =20 DYNAMIC RELOCATION RECORDS OFFSET TYPE VALUE 0000000000000000 R_MIPS_NONE *ABS* 0000000000000000 R_MIPS_NONE *ABS* =20 and consequently `ld/testsuite/ld-mips-elf/reloc-estimate-1.d' does not match even though ELF output produced is correct according to `readelf': =20 Relocation section '.rel.dyn' at offset 0x10400 contains 2 entries: Offset Info Type Sym. Value Sym. Name 000000000000 000000000000 R_MIPS_NONE Type2: R_MIPS_NONE Type3: R_MIPS_NONE 000000010000 000300001203 R_MIPS_REL32 0000000000010010 foo@@V2 Type2: R_MIPS_64 Type3: R_MIPS_NONE =20 As a genuine bug this has to be handled separately. =20 Co-Authored by: Maciej W. Rozycki =20 bfd/ * config.bfd: Add `mips64*el-*-linux*-gnuabi64' and `mips64*-*-linux*-gnuabi64' targets. =20 binutils/ * testsuite/binutils-all/mips/mips.exp: Handle `*-*-*-gnuabi64' targets. * testsuite/binutils-all/objcopy.exp: Handle `mips64*-*-*-gnuabi64' targets. * testsuite/binutils-all/remove-relocs-01.d: Likewise. * testsuite/binutils-all/remove-relocs-04.d: Likewise. * testsuite/binutils-all/remove-relocs-05.d: Likewise. * testsuite/binutils-all/remove-relocs-06.d: Likewise. =20 gas/ * configure.ac: Handle `mips64*-linux-gnuabi64' targets. * configure: Regenerate. * testsuite/gas/mips/compact-eh-eb-7.d: Handle `mips64*-*-*-gnuabi64' targets. * testsuite/gas/mips/compact-eh-el-7.d: Likewise. =20 ld/ * configure.tgt: Add `mips64*el-*-linux-gnuabi64' and `mips64*-*-linux-gnuabi64' targets. * testsuite/ld-undefined/undefined.exp: Handle `mips64*-*-*-gnuabi64' targets. * testsuite/ld-mips-elf/attr-gnu-4-10.d: Likewise. * testsuite/ld-mips-elf/compact-eh6.d: Likewise. * testsuite/ld-mips-elf/mips-elf.exp: Handle `*-*-*-gnuabi64' targets. Diff: --- bfd/config.bfd | 10 ++++++++++ binutils/testsuite/binutils-all/mips/mips.exp | 18 ++++++++++++++---- binutils/testsuite/binutils-all/objcopy.exp | 3 ++- binutils/testsuite/binutils-all/remove-relocs-01.d | 2 +- binutils/testsuite/binutils-all/remove-relocs-04.d | 2 +- binutils/testsuite/binutils-all/remove-relocs-05.d | 2 +- binutils/testsuite/binutils-all/remove-relocs-06.d | 2 +- gas/configure | 6 +++--- gas/configure.ac | 6 +++--- gas/testsuite/gas/mips/compact-eh-eb-7.d | 2 +- gas/testsuite/gas/mips/compact-eh-el-7.d | 2 +- ld/configure.tgt | 10 ++++++++++ ld/testsuite/ld-mips-elf/attr-gnu-4-10.d | 2 +- ld/testsuite/ld-mips-elf/compact-eh6.d | 2 +- ld/testsuite/ld-mips-elf/mips-elf.exp | 21 ++++++++++++++++--= --- ld/testsuite/ld-undefined/undefined.exp | 3 ++- 16 files changed, 68 insertions(+), 25 deletions(-) diff --git a/bfd/config.bfd b/bfd/config.bfd index 54a30ef901f..3b39ff36c00 100644 --- a/bfd/config.bfd +++ b/bfd/config.bfd @@ -941,10 +941,20 @@ case "${targ}" in targ_defvec=3Dmips_elf32_be_vec targ_selvecs=3D"mips_elf32_le_vec mips_elf64_be_vec mips_elf64_le_vec = mips_ecoff_be_vec mips_ecoff_le_vec" ;; + mips64*el-*-linux*-gnuabi64) + targ_defvec=3Dmips_elf64_trad_le_vec + targ_selvecs=3D"mips_elf64_trad_be_vec mips_elf32_ntrad_le_vec mips_el= f32_ntrad_be_vec mips_elf32_trad_le_vec mips_elf32_trad_be_vec" + want64=3Dtrue + ;; mips64*el-*-linux*) targ_defvec=3Dmips_elf32_ntrad_le_vec targ_selvecs=3D"mips_elf32_ntrad_be_vec mips_elf32_trad_le_vec mips_el= f32_trad_be_vec mips_elf64_trad_le_vec mips_elf64_trad_be_vec" ;; + mips64*-*-linux*-gnuabi64) + targ_defvec=3Dmips_elf64_trad_be_vec + targ_selvecs=3D"mips_elf64_trad_le_vec mips_elf32_ntrad_be_vec mips_el= f32_ntrad_le_vec mips_elf32_trad_be_vec mips_elf32_trad_le_vec" + want64=3Dtrue + ;; mips64*-*-linux*) targ_defvec=3Dmips_elf32_ntrad_be_vec targ_selvecs=3D"mips_elf32_ntrad_le_vec mips_elf32_trad_be_vec mips_el= f32_trad_le_vec mips_elf64_trad_be_vec mips_elf64_trad_le_vec" diff --git a/binutils/testsuite/binutils-all/mips/mips.exp b/binutils/tests= uite/binutils-all/mips/mips.exp index 91bf3274592..fdab97180e3 100644 --- a/binutils/testsuite/binutils-all/mips/mips.exp +++ b/binutils/testsuite/binutils-all/mips/mips.exp @@ -125,13 +125,23 @@ if {[istarget *-*-openbsd*] } { if [istarget *el-*-*] { set abi_asflags(o32) -32 set abi_ldflags(o32) -melf32ltsmip - set abi_asflags(n64) "-march=3Dfrom-abi -64" - set abi_ldflags(n64) -melf64ltsmip + if [istarget *-*-*-gnuabi64] { + set abi_asflags(n32) "-march=3Dfrom-abi -n32" + set abi_ldflags(n32) -melf32ltsmipn32 + } else { + set abi_asflags(n64) "-march=3Dfrom-abi -64" + set abi_ldflags(n64) -melf64ltsmip + } } else { set abi_asflags(o32) -32 set abi_ldflags(o32) -melf32btsmip - set abi_asflags(n64) "-march=3Dfrom-abi -64" - set abi_ldflags(n64) -melf64btsmip + if [istarget *-*-*-gnuabi64] { + set abi_asflags(n32) "-march=3Dfrom-abi -n32" + set abi_ldflags(n32) -melf32btsmipn32 + } else { + set abi_asflags(n64) "-march=3Dfrom-abi -64" + set abi_ldflags(n64) -melf64btsmip + } } set irixemul 0 } elseif {[istarget *-*-linux*] } { diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsui= te/binutils-all/objcopy.exp index 41add0fecda..1145835d8b7 100644 --- a/binutils/testsuite/binutils-all/objcopy.exp +++ b/binutils/testsuite/binutils-all/objcopy.exp @@ -1269,7 +1269,8 @@ if [is_elf_format] { run_dump_test "strip-9" run_dump_test "strip-12" =20 - if { [istarget "mips64*-*-openbsd*"] } { + if { [istarget "mips64*-*-openbsd*"] \ + || [istarget "mips64*-*-*-gnuabi64"] } { set reloc_format mips64 } # A relocation type not supported by any target diff --git a/binutils/testsuite/binutils-all/remove-relocs-01.d b/binutils/= testsuite/binutils-all/remove-relocs-01.d index 702747bc3f3..aeceba117d1 100644 --- a/binutils/testsuite/binutils-all/remove-relocs-01.d +++ b/binutils/testsuite/binutils-all/remove-relocs-01.d @@ -2,7 +2,7 @@ #source: remove-relocs-01.s #objcopy: --remove-relocations=3D.data.relocs.01 #readelf: -r -#notarget: "mips64*-*-openbsd*" +#notarget: mips64*-*-openbsd* mips64*-*-*-gnuabi64 =20 Relocation section '\.rela?\.data\.relocs\.02' at offset 0x[0-9a-f]+ conta= ins 3 entries: .* diff --git a/binutils/testsuite/binutils-all/remove-relocs-04.d b/binutils/= testsuite/binutils-all/remove-relocs-04.d index 1b8eab39a1a..4ae7a90f0f1 100644 --- a/binutils/testsuite/binutils-all/remove-relocs-04.d +++ b/binutils/testsuite/binutils-all/remove-relocs-04.d @@ -2,7 +2,7 @@ #source: remove-relocs-01.s #objcopy: --remove-relocations=3D.data.relocs.0\[12\] #readelf: -r -#notarget: "mips64*-*-openbsd*" +#notarget: mips64*-*-openbsd* mips64*-*-*-gnuabi64 =20 Relocation section '\.rela?\.data\.relocs\.03' at offset 0x[0-9a-f]+ conta= ins 3 entries: .* diff --git a/binutils/testsuite/binutils-all/remove-relocs-05.d b/binutils/= testsuite/binutils-all/remove-relocs-05.d index a429182d258..0f3591786b3 100644 --- a/binutils/testsuite/binutils-all/remove-relocs-05.d +++ b/binutils/testsuite/binutils-all/remove-relocs-05.d @@ -2,7 +2,7 @@ #source: remove-relocs-01.s #objcopy: --remove-section=3D.rela.data.relocs.01 --remove-section=3D.rel.= data.relocs.01 #readelf: -r -#notarget: "mips64*-*-openbsd*" +#notarget: mips64*-*-openbsd* mips64*-*-*-gnuabi64 =20 Relocation section '\.rela?\.data\.relocs\.02' at offset 0x[0-9a-f]+ conta= ins 3 entries: .* diff --git a/binutils/testsuite/binutils-all/remove-relocs-06.d b/binutils/= testsuite/binutils-all/remove-relocs-06.d index 5214bc7297a..f530d300087 100644 --- a/binutils/testsuite/binutils-all/remove-relocs-06.d +++ b/binutils/testsuite/binutils-all/remove-relocs-06.d @@ -2,7 +2,7 @@ #source: remove-relocs-01.s #objcopy: --remove-relocations=3D.data.relocs.* --remove-relocations=3D!.d= ata.relocs.02 #readelf: -r -#notarget: "mips64*-*-openbsd*" +#notarget: mips64*-*-openbsd* mips64*-*-*-gnuabi64 =20 Relocation section '\.rela?\.data\.relocs\.02' at offset 0x[0-9a-f]+ conta= ins 3 entries: .* diff --git a/gas/configure b/gas/configure index e5023ff727f..aff5aec4625 100755 --- a/gas/configure +++ b/gas/configure @@ -12225,6 +12225,9 @@ _ACEOF esac # Decide which ABI to target by default. case ${target} in + mips64*-openbsd* | mips64*-linux-gnuabi64) + mips_default_abi=3DN64_ABI + ;; mips64*-linux* | mips-sgi-irix6* | mips64*-freebsd* \ | mips64*-kfreebsd*-gnu | mips64*-ps2-elf*) mips_default_abi=3DN32_ABI @@ -12232,9 +12235,6 @@ _ACEOF mips*-linux* | mips*-freebsd* | mips*-kfreebsd*-gnu) mips_default_abi=3DO32_ABI ;; - mips64*-openbsd*) - mips_default_abi=3DN64_ABI - ;; *) mips_default_abi=3DNO_ABI ;; diff --git a/gas/configure.ac b/gas/configure.ac index e8e8f31f79a..c3bd1178d41 100644 --- a/gas/configure.ac +++ b/gas/configure.ac @@ -394,6 +394,9 @@ changequote([,])dnl esac # Decide which ABI to target by default. case ${target} in + mips64*-openbsd* | mips64*-linux-gnuabi64) + mips_default_abi=3DN64_ABI + ;; mips64*-linux* | mips-sgi-irix6* | mips64*-freebsd* \ | mips64*-kfreebsd*-gnu | mips64*-ps2-elf*) mips_default_abi=3DN32_ABI @@ -401,9 +404,6 @@ changequote([,])dnl mips*-linux* | mips*-freebsd* | mips*-kfreebsd*-gnu) mips_default_abi=3DO32_ABI ;; - mips64*-openbsd*) - mips_default_abi=3DN64_ABI - ;; *) mips_default_abi=3DNO_ABI ;; diff --git a/gas/testsuite/gas/mips/compact-eh-eb-7.d b/gas/testsuite/gas/m= ips/compact-eh-eb-7.d index 6576e43bbdc..973e69fe31a 100644 --- a/gas/testsuite/gas/mips/compact-eh-eb-7.d +++ b/gas/testsuite/gas/mips/compact-eh-eb-7.d @@ -2,7 +2,7 @@ #name: Compact EH EB #7 with personality id and fallback FDE #source: compact-eh-7.s #as: -EB -mno-pdr -#notarget: mips64*-*-openbsd* +#notarget: mips64*-*-openbsd* mips64*-*-*-gnuabi64 =20 .*: file format.* =20 diff --git a/gas/testsuite/gas/mips/compact-eh-el-7.d b/gas/testsuite/gas/m= ips/compact-eh-el-7.d index 9a12da7676e..fb7dde9252f 100644 --- a/gas/testsuite/gas/mips/compact-eh-el-7.d +++ b/gas/testsuite/gas/mips/compact-eh-el-7.d @@ -2,7 +2,7 @@ #name: Compact EH EL #7 with personality id and fallback FDE #source: compact-eh-7.s #as: -EL -mno-pdr -#notarget: mips64*-*-openbsd* +#notarget: mips64*-*-openbsd* mips64*-*-*-gnuabi64 =20 .*: file format.* =20 diff --git a/ld/configure.tgt b/ld/configure.tgt index 34c9d67c365..c62b9581d9b 100644 --- a/ld/configure.tgt +++ b/ld/configure.tgt @@ -580,10 +580,20 @@ mips*-*-vxworks*) targ_emul=3Delf32ebmipvxworks ;; mips*-*-windiss) targ_emul=3Delf32mipswindiss ;; +mips64*el-*-linux-gnuabi64) + targ_emul=3Delf64ltsmip + targ_extra_emuls=3D"elf64btsmip elf32ltsmipn32 elf32btsmipn32 elf32ltsm= ip elf32btsmip" + targ_extra_libpath=3D$targ_extra_emuls + ;; mips64*el-*-linux-*) targ_emul=3Delf32ltsmipn32 targ_extra_emuls=3D"elf32btsmipn32 elf32ltsmip elf32btsmip elf64ltsmip = elf64btsmip" targ_extra_libpath=3D$targ_extra_emuls ;; +mips64*-*-linux-gnuabi64) + targ_emul=3Delf64btsmip + targ_extra_emuls=3D"elf64ltsmip elf32btsmipn32 elf32ltsmipn32 elf32btsm= ip elf32ltsmip" + targ_extra_libpath=3D$targ_extra_emuls + ;; mips64*-*-linux-*) targ_emul=3Delf32btsmipn32 targ_extra_emuls=3D"elf32ltsmipn32 elf32btsmip elf32ltsmip elf64btsmip = elf64ltsmip" targ_extra_libpath=3D$targ_extra_emuls diff --git a/ld/testsuite/ld-mips-elf/attr-gnu-4-10.d b/ld/testsuite/ld-mip= s-elf/attr-gnu-4-10.d index 2ddb3d36f40..fe39ece80f8 100644 --- a/ld/testsuite/ld-mips-elf/attr-gnu-4-10.d +++ b/ld/testsuite/ld-mips-elf/attr-gnu-4-10.d @@ -3,7 +3,7 @@ #as: -mpdr #ld: -r #readelf: -hA -#notarget: mips64*-*-openbsd* +#notarget: mips64*-*-openbsd* mips64*-*-*-gnuabi64 =20 ELF Header: Magic: .* diff --git a/ld/testsuite/ld-mips-elf/compact-eh6.d b/ld/testsuite/ld-mips-= elf/compact-eh6.d index e81285afc02..a4a6978ccbd 100644 --- a/ld/testsuite/ld-mips-elf/compact-eh6.d +++ b/ld/testsuite/ld-mips-elf/compact-eh6.d @@ -4,7 +4,7 @@ #as: -EB #readelf: -x .eh_frame_hdr #ld: -EB -e main -# +#notarget: mips64*-*-*-gnuabi64 =20 Hex dump of section \'\.eh_frame_hdr\': =20 diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-e= lf/mips-elf.exp index 8be2bfc7a1d..e123ef52b06 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -155,13 +155,23 @@ if {[istarget *-*-openbsd*] } { if [istarget *el-*-*] { set abi_asflags(o32) -32 set abi_ldflags(o32) -melf32ltsmip - set abi_asflags(n64) "-march=3Dfrom-abi -64" - set abi_ldflags(n64) -melf64ltsmip + if [istarget *-*-*-gnuabi64] { + set abi_asflags(n32) "-march=3Dfrom-abi -n32" + set abi_ldflags(n32) -melf32ltsmipn32 + } else { + set abi_asflags(n64) "-march=3Dfrom-abi -64" + set abi_ldflags(n64) -melf64ltsmip + } } else { set abi_asflags(o32) -32 set abi_ldflags(o32) -melf32btsmip - set abi_asflags(n64) "-march=3Dfrom-abi -64" - set abi_ldflags(n64) -melf64btsmip + if [istarget *-*-*-gnuabi64] { + set abi_asflags(n32) "-march=3Dfrom-abi -n32" + set abi_ldflags(n32) -melf32btsmipn32 + } else { + set abi_asflags(n64) "-march=3Dfrom-abi -64" + set abi_ldflags(n64) -melf64btsmip + } } set irixemul 0 } elseif {[istarget *-*-linux*] } { @@ -811,7 +821,8 @@ if { $linux_gnu } { run_dump_test "got-page-1" run_dump_test_n32 "got-page-2" run_dump_test_n64 "dyn-sec64" noarch - run_dump_test "got-page-3" + run_dump_test_o32 "got-page-3" + run_dump_test_n32 "got-page-3" [list [list name (n32)]] if $has_abi(o32) { run_ld_link_tests [subst { {"GOT page 4 (one file)" diff --git a/ld/testsuite/ld-undefined/undefined.exp b/ld/testsuite/ld-unde= fined/undefined.exp index 05b1131d5b4..c0479a22733 100644 --- a/ld/testsuite/ld-undefined/undefined.exp +++ b/ld/testsuite/ld-undefined/undefined.exp @@ -206,7 +206,8 @@ if { ![is_elf_format] || ![check_shared_lib_support]} t= hen { # triplets, and S+core targets using an extra R_SCORE_NONE # relocation, so adjust for that. switch -glob $target_triplet { - "mips64*-*-openbsd*" { + "mips64*-*-openbsd*" - + "mips64*-*-*-gnuabi64" { set none_count 6 set reloc_count 4 }