[binutils-gdb] LoongArch: Set the default ABI of loongarch*-elf targets to double-float

liu zhensong liuzhensong@sourceware.org
Sat Dec 13 02:17:56 GMT 2025


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

commit 2b0dfd375ecdb4ede71a15075c0d5a8e79c0d7fd
Author: Lulu Cai <cailulu@loongson.cn>
Date:   Thu Dec 11 15:40:58 2025 +0800

    LoongArch: Set the default ABI of loongarch*-elf targets to double-float
    
    The ABI setting for the elf target was ommitted in commit "db614f37cab".
    Set the default ABI for elf to double-float.
    
    In addition, test case failures caused by the loongarch*-elf linker not
    supporting relevant options have also been skipped.
    
    gas/
    
            * config/tc-loongarch.c (loongarch_after_parse_args): Set
              default ABI to double-float for other targets.
    
    ld/
    
            * testsuite/ld-loongarch-elf/la32.d: Skip tests when not
              supported.
            * testsuite/ld-loongarch-elf/ld-loongarch-elf.exp: Likewise.
            * testsuite/ld-loongarch-elf/relax.exp: Likewise.

Diff:
---
 gas/config/tc-loongarch.c                          |   3 +-
 ld/testsuite/ld-loongarch-elf/la32.d               |   1 +
 ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp |  26 ++--
 ld/testsuite/ld-loongarch-elf/relax.exp            | 136 +++++++++++----------
 4 files changed, 89 insertions(+), 77 deletions(-)

diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c
index e049427956c..beb41fc904a 100644
--- a/gas/config/tc-loongarch.c
+++ b/gas/config/tc-loongarch.c
@@ -314,7 +314,8 @@ loongarch_after_parse_args ()
       else if (strcmp (TARGET_OS, "linux-gnu") == 0)
 	LARCH_opts.ase_abi = EF_LOONGARCH_ABI_DOUBLE_FLOAT;
       else
-	as_fatal (_("unsupport TARGET_OS %s"), TARGET_OS);
+	/* To support lonngarch*-elf targets.  */
+	LARCH_opts.ase_abi = EF_LOONGARCH_ABI_DOUBLE_FLOAT;
     }
 
   /* Set eflags ABI version to v1 (ELF object file ABI 2.0).  */
diff --git a/ld/testsuite/ld-loongarch-elf/la32.d b/ld/testsuite/ld-loongarch-elf/la32.d
index 9f66b7bba8f..7d4e0e75fbe 100644
--- a/ld/testsuite/ld-loongarch-elf/la32.d
+++ b/ld/testsuite/ld-loongarch-elf/la32.d
@@ -1,6 +1,7 @@
 #as -mabi=ilp32d:
 #ld: -z norelro --hash-style=both -e0
 #objdump: -dr
+#skip: loongarch*-elf
 
 .*:[    ]+file format .*
 
diff --git a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
index 7b0b066190c..5c4bf3275eb 100644
--- a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
+++ b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
@@ -164,18 +164,20 @@ if [istarget "loongarch64-*-*"] {
   # Using DESC and IE to access the same tls symbol but with
   # -mno-relax requires allocating GOT entries for both DESC and IE,
   # not just IE
-  run_ld_link_tests [list \
-      [list \
-	  "desc and ie do not type transition" \
-	  "-pie -e0 --hash-style=both" "" \
-	  "-mno-relax" \
-	  {desc-ie-norelax.s} \
-	  {{objdump {-d} desc-ie-norelax.dd} \
-	   {readelf {-rW} desc-ie-norelax.rd} \
-	   {objdump {-sj.got} desc-ie-norelax.sd}} \
-	  "desc-ie-norelax" \
-      ] \
-  ] \
+  if [check_pie_support] {
+    run_ld_link_tests [list \
+	[list \
+	    "desc and ie do not type transition" \
+	    "-pie -e0 --hash-style=both" "" \
+	    "-mno-relax" \
+	    {desc-ie-norelax.s} \
+	    {{objdump {-d} desc-ie-norelax.dd} \
+	    {readelf {-rW} desc-ie-norelax.rd} \
+	    {objdump {-sj.got} desc-ie-norelax.sd}} \
+	    "desc-ie-norelax" \
+	] \
+    ] \
+  }
 
   run_ld_link_tests \
       [list \
diff --git a/ld/testsuite/ld-loongarch-elf/relax.exp b/ld/testsuite/ld-loongarch-elf/relax.exp
index 49e6b23b606..976ba8df045 100644
--- a/ld/testsuite/ld-loongarch-elf/relax.exp
+++ b/ld/testsuite/ld-loongarch-elf/relax.exp
@@ -51,66 +51,72 @@ if [istarget loongarch64-*-*] {
     run_dump_test "relax-align-ignore-start"
     run_partial_linking_align_test
 
-    run_ld_link_tests \
-      [list \
+    if [check_shared_lib_support] {
+      run_ld_link_tests \
 	[list \
-	"loongarch relax call36 .so build" \
-	"-shared" "" \
-	"" \
-	{relax-call36-so.s} \
-	{} \
-	"relax-call36.so" \
-	] \
-      ]
+	  [list \
+	  "loongarch relax call36 .so build" \
+	  "-shared" "" \
+	  "" \
+	  {relax-call36-so.s} \
+	  {} \
+	  "relax-call36.so" \
+	  ] \
+	]
 
-    if [file exist "tmpdir/relax-call36.so"] {
-      set objdump_output [run_host_cmd "objdump" "-d tmpdir/relax-call36.so"]
-      if { [ regexp "pcaddu18i" $objdump_output] } {
-	fail "loongarch relax call36 so"
-      } {
-	pass "loongarch relax call36 so"
+      if [file exist "tmpdir/relax-call36.so"] {
+	set objdump_output [run_host_cmd "objdump" "-d tmpdir/relax-call36.so"]
+	if { [ regexp "pcaddu18i" $objdump_output] } {
+	  fail "loongarch relax call36 so"
+	} {
+	  pass "loongarch relax call36 so"
+	}
       }
     }
 
-    run_ld_link_tests \
-      [list \
+    if [check_pie_support] {
+      run_ld_link_tests \
 	[list \
-	"loongarch relax call36 dyn exe build" \
-	"-pie -e 0" "" \
-	"" \
-	{relax-call36-exe.s} \
-	{} \
-	"relax-call36-d.exe" \
-	] \
-      ]
+	  [list \
+	  "loongarch relax call36 dyn exe build" \
+	  "-pie -e 0" "" \
+	  "" \
+	  {relax-call36-exe.s} \
+	  {} \
+	  "relax-call36-d.exe" \
+	  ] \
+	]
 
-    if [file exist "tmpdir/relax-call36-d.exe"] {
-      set objdump_output [run_host_cmd "objdump" "-d tmpdir/relax-call36-d.exe"]
-      if { [ regexp "pcaddu18i" $objdump_output] } {
-	fail "loongarch relax call36 dyn exe"
-      } {
-	pass "loongarch relax call36 dyn exe"
+      if [file exist "tmpdir/relax-call36-d.exe"] {
+	set objdump_output [run_host_cmd "objdump" "-d tmpdir/relax-call36-d.exe"]
+	if { [ regexp "pcaddu18i" $objdump_output] } {
+	  fail "loongarch relax call36 dyn exe"
+	} {
+	  pass "loongarch relax call36 dyn exe"
+	}
       }
     }
 
-    run_ld_link_tests \
-      [list \
+    if [check_pie_support] {
+      run_ld_link_tests \
 	[list \
-	"loongarch relax call36 dyn-pie exe build" \
-	"-pie -e 0" "" \
-	"" \
-	{relax-call36-exe.s} \
-	{} \
-	"relax-call36-dp.exe" \
-	] \
-      ]
+	  [list \
+	  "loongarch relax call36 dyn-pie exe build" \
+	  "-pie -e 0" "" \
+	  "" \
+	  {relax-call36-exe.s} \
+	  {} \
+	  "relax-call36-dp.exe" \
+	  ] \
+	]
 
-    if [file exist "tmpdir/relax-call36-dp.exe"] {
-      set objdump_output [run_host_cmd "objdump" "-d tmpdir/relax-call36-dp.exe"]
-      if { [ regexp "pcaddu18i" $objdump_output] } {
-	fail "loongarch relax call36 dyn-pie exe"
-      } {
-	pass "loongarch relax call36 dyn-pie exe"
+      if [file exist "tmpdir/relax-call36-dp.exe"] {
+	set objdump_output [run_host_cmd "objdump" "-d tmpdir/relax-call36-dp.exe"]
+	if { [ regexp "pcaddu18i" $objdump_output] } {
+	  fail "loongarch relax call36 dyn-pie exe"
+	} {
+	  pass "loongarch relax call36 dyn-pie exe"
+	}
       }
     }
 
@@ -135,24 +141,26 @@ if [istarget loongarch64-*-*] {
       }
     }
 
-    run_ld_link_tests \
-      [list \
+    if [check_pie_support] {
+      run_ld_link_tests \
 	[list \
-	"loongarch relax call36 static-pie exe build" \
-	"-static -pie --no-dynamic-linker -e 0" "" \
-	"" \
-	{relax-call36-exe.s} \
-	{} \
-	"relax-call36-sp.exe" \
-	] \
-      ]
+	  [list \
+	  "loongarch relax call36 static-pie exe build" \
+	  "-static -pie --no-dynamic-linker -e 0" "" \
+	  "" \
+	  {relax-call36-exe.s} \
+	  {} \
+	  "relax-call36-sp.exe" \
+	  ] \
+	]
 
-    if [file exist "tmpdir/relax-call36-sp.exe"] {
-      set objdump_output [run_host_cmd "objdump" "-d tmpdir/relax-call36-sp.exe"]
-      if { [ regexp "pcaddu18i" $objdump_output] } {
-	fail "loongarch relax call36 static-pie exe"
-      } {
-	pass "loongarch relax call36 static-pie exe"
+      if [file exist "tmpdir/relax-call36-sp.exe"] {
+	set objdump_output [run_host_cmd "objdump" "-d tmpdir/relax-call36-sp.exe"]
+	if { [ regexp "pcaddu18i" $objdump_output] } {
+	  fail "loongarch relax call36 static-pie exe"
+	} {
+	  pass "loongarch relax call36 static-pie exe"
+	}
       }
     }


More information about the Binutils-cvs mailing list