[v2] LoongArch: Fix bfd ld failed test case

Message ID 20241211021742.2328291-1-cailulu@loongson.cn
State New
Headers
Series [v2] LoongArch: Fix bfd ld failed test case |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Lulu Cai Dec. 11, 2024, 2:17 a.m. UTC
  This test case requires host gcc, and different distributions have
different default configurations for gcc, which can cause address value
mismatches.
Therefore, it is fixed by passing consistent options and using regular
expressions.

---
Changes form v1:
  - Add a commit note.
---
 .../ld-loongarch-elf/call_undefweak.d         | 38 +++++++------------
 .../ld-loongarch-elf/ld-loongarch-elf.exp     |  2 +-
 2 files changed, 15 insertions(+), 25 deletions(-)
  

Patch

diff --git a/ld/testsuite/ld-loongarch-elf/call_undefweak.d b/ld/testsuite/ld-loongarch-elf/call_undefweak.d
index 4761651817c..6eedfed3046 100644
--- a/ld/testsuite/ld-loongarch-elf/call_undefweak.d
+++ b/ld/testsuite/ld-loongarch-elf/call_undefweak.d
@@ -1,26 +1,16 @@ 
 #...
-Disassembly of section \.plt:
-#...
-0+1200004d0 <fn2@plt>:
-   1200004d0:	1c00010f 	pcaddu12i   	\$t3, 8
-   1200004d4:	28ed01ef 	ld.d        	\$t3, \$t3, -1216
-   1200004d8:	4c0001ed 	jirl        	\$t1, \$t3, 0
-   1200004dc:	03400000 	nop
-
-Disassembly of section \.text:
-#...
-0+120000668 <main>:
-   120000668:	4c000000 	jr          	\$zero
-   12000066c:	53fe67ff 	b           	-412	# 1200004d0 <fn2@plt>
-   120000670:	4c000001 	jirl        	\$ra, \$zero, 0
-   120000674:	57fe5fff 	bl          	-420	# 1200004d0 <fn2@plt>
+[0-9a-f]+ <main>:
+   +[0-9a-f]+:	4c000000 	jr          	\$zero
+   +[0-9a-f]+:	........ 	b           	.*	# [0-9a-f]+ <fn2@plt>
+   +[0-9a-f]+:	4c000001 	jirl        	\$ra, \$zero, 0
+   +[0-9a-f]+:	........ 	bl          	.*	# [0-9a-f]+ <fn2@plt>
 
-0+120000678 <medium_call_nop>:
-   120000678:	1e000001 	pcaddu18i   	\$ra, 0
-   12000067c:	4c000001 	jirl        	\$ra, \$zero, 0
-   120000680:	1e000001 	pcaddu18i   	\$ra, 0
-   120000684:	4ffe5021 	jirl        	\$ra, \$ra, -432
-   120000688:	1e00000c 	pcaddu18i   	\$t0, 0
-   12000068c:	4c000000 	jr          	\$zero
-   120000690:	1e00000c 	pcaddu18i   	\$t0, 0
-   120000694:	4ffe4180 	jirl        	\$zero, \$t0, -448
+[0-9a-f]+ <medium_call_nop>:
+   +[0-9a-f]+:	1e000001 	pcaddu18i   	\$ra, 0
+   +[0-9a-f]+:	4c000001 	jirl        	\$ra, \$zero, 0
+   +[0-9a-f]+:	1e000001 	pcaddu18i   	\$ra, 0
+   +[0-9a-f]+:	........ 	jirl        	\$ra, \$ra, .*
+   +[0-9a-f]+:	1e00000c 	pcaddu18i   	\$t0, 0
+   +[0-9a-f]+:	4c000000 	jr          	\$zero
+   +[0-9a-f]+:	1e00000c 	pcaddu18i   	\$t0, 0
+   +[0-9a-f]+:	........ 	jirl        	\$zero, \$t0, .*
diff --git a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
index d7c2b311f2f..004c1994673 100644
--- a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
+++ b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp
@@ -147,7 +147,7 @@  if [istarget "loongarch64-*-*"] {
   run_cc_link_tests [list \
       [list \
 	  "call undefweak symbol" \
-	  "" "" \
+	  "-no-pie" "" \
 	  {call_undefweak.s} \
 	  {{objdump {-d} call_undefweak.d}} \
 	  "call_undefweak" \