This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: MIPS JAL/JALR to BAL transformation for Linux (o32 ABI)


Hi All,

  I tested a new target "mips64-linux-gnu" and found new LD test failures
due to my patch.  While fixing mismatching, I found one issue from a relaxation
test "relax-jalr-n32-shared.d".
Ex:
# relax-jalr.s
.globl __start
        .space 8
.ent __start
__start:
.Lstart:
        .space 16
        jal __start <------------ NOT relaxed
        .space 32
        jal __start <------------ NOT relaxed
        .space 64
        jal .Lstart <------------ relaxed
.end __start

# make objdump print ...
        .space 8

  The first two JALRs aren't relaxed in "_bfd_mips_relax_section" due to the check.
as follows.
/* If a symbol is undefined, or if it may be overridden,
   skip it.  */
if (! ((h->root.root.type == bfd_link_hash_defined
        || h->root.root.type == bfd_link_hash_defweak)
       && h->root.root.u.def.section)
    || (link_info->shared && ! link_info->symbolic
        && ! (h->root.elf_link_hash_flags & ELF_LINK_FORCED_LOCAL)))
  continue;

  But later, these two JALRs are transformed to BAL in "mips_elf_perform_relocation".
Is it safe to use BAL for the first two JALRs?
And, the relaxation code seems redundant, after we can do the same thing in
"mips_elf_perform_relocation".

  The patch to fix LD failures is attached.  Thanks!

Regards,
Chao-ying

2009-08-07  Chao-ying Fu  <fu@mips.com>

	* ld-mips-elf/elf-rel-got-n32.d,
	ld-mips-elf/elf-rel-got-n64-linux.d,
	ld-mips-elf/elf-rel-got-n64.d,
	ld-mips-elf/elf-rel-xgot-n32.d,
	ld-mips-elf/relax-jalr-n32-shared.d,
	ld-mips-elf/relax-jalr-n64-shared.d,
	ld-mips-elf/elf-rel-xgot-n64-linux.d,
	ld-mips-elf/elf-rel-xgot-n64.d: Change JALR to BAL.

Index: src/ld/testsuite/ld-mips-elf/elf-rel-got-n32.d
===================================================================
--- src.orig/ld/testsuite/ld-mips-elf/elf-rel-got-n32.d	2009-08-06 18:03:32.000000000 -0700
+++ src/ld/testsuite/ld-mips-elf/elf-rel-got-n32.d	2009-08-07 10:28:02.870923000 -0700
@@ -127,10 +127,10 @@ Disassembly of section \.text:
 10000260:	8f99805c 	lw	t9,-32676\(gp\)
 10000264:	8f998030 	lw	t9,-32720\(gp\)
 10000268:	8f99805c 	lw	t9,-32676\(gp\)
-1000026c:	0320f809 	jalr	t9
+1000026c:	0411ff90 	bal	100000b0 <fn>
 10000270:	00000000 	nop
 10000274:	8f998030 	lw	t9,-32720\(gp\)
-10000278:	0320f809 	jalr	t9
+10000278:	0411ff8d 	bal	100000b0 <fn>
 1000027c:	00000000 	nop
 10000280:	8f858068 	lw	a1,-32664\(gp\)
 10000284:	8f858068 	lw	a1,-32664\(gp\)
@@ -243,10 +243,10 @@ Disassembly of section \.text:
 10000430:	8f998060 	lw	t9,-32672\(gp\)
 10000434:	8f998048 	lw	t9,-32696\(gp\)
 10000438:	8f998060 	lw	t9,-32672\(gp\)
-1000043c:	0320f809 	jalr	t9
+1000043c:	0411001d 	bal	100004b4 <fn2>
 10000440:	00000000 	nop
 10000444:	8f998048 	lw	t9,-32696\(gp\)
-10000448:	0320f809 	jalr	t9
+10000448:	0411001a 	bal	100004b4 <fn2>
 1000044c:	00000000 	nop
 10000450:	1000ff17 	b	100000b0 <fn>
 10000454:	8f858064 	lw	a1,-32668\(gp\)
Index: src/ld/testsuite/ld-mips-elf/elf-rel-got-n64-linux.d
===================================================================
--- src.orig/ld/testsuite/ld-mips-elf/elf-rel-got-n64-linux.d	2009-08-06 18:03:32.000000000 -0700
+++ src/ld/testsuite/ld-mips-elf/elf-rel-got-n64-linux.d	2009-08-07 10:28:02.877917000 -0700
@@ -129,10 +129,10 @@ Disassembly of section \.text:
    120000290:	df9980a8 	ld	t9,-32600\(gp\)
    120000294:	df998050 	ld	t9,-32688\(gp\)
    120000298:	df9980a8 	ld	t9,-32600\(gp\)
-   12000029c:	0320f809 	jalr	t9
+   12000029c:	0411ff90 	bal	1200000e0 <fn>
    1200002a0:	00000000 	nop
    1200002a4:	df998050 	ld	t9,-32688\(gp\)
-   1200002a8:	0320f809 	jalr	t9
+   1200002a8:	0411ff8d 	bal	1200000e0 <fn>
    1200002ac:	00000000 	nop
    1200002b0:	df8580c0 	ld	a1,-32576\(gp\)
    1200002b4:	df8580c0 	ld	a1,-32576\(gp\)
@@ -245,10 +245,10 @@ Disassembly of section \.text:
    120000460:	df9980b0 	ld	t9,-32592\(gp\)
    120000464:	df998080 	ld	t9,-32640\(gp\)
    120000468:	df9980b0 	ld	t9,-32592\(gp\)
-   12000046c:	0320f809 	jalr	t9
+   12000046c:	0411001d 	bal	1200004e4 <fn2>
    120000470:	00000000 	nop
    120000474:	df998080 	ld	t9,-32640\(gp\)
-   120000478:	0320f809 	jalr	t9
+   120000478:	0411001a 	bal	1200004e4 <fn2>
    12000047c:	00000000 	nop
    120000480:	1000ff17 	b	1200000e0 <fn>
    120000484:	df8580b8 	ld	a1,-32584\(gp\)
Index: src/ld/testsuite/ld-mips-elf/elf-rel-got-n64.d
===================================================================
--- src.orig/ld/testsuite/ld-mips-elf/elf-rel-got-n64.d	2009-08-06 18:03:32.000000000 -0700
+++ src/ld/testsuite/ld-mips-elf/elf-rel-got-n64.d	2009-08-07 10:28:02.899899000 -0700
@@ -128,10 +128,10 @@ Disassembly of section \.text:
     10000290:	df9980a8 	ld	t9,-32600\(gp\)
     10000294:	df998050 	ld	t9,-32688\(gp\)
     10000298:	df9980a8 	ld	t9,-32600\(gp\)
-    1000029c:	0320f809 	jalr	t9
+    1000029c:	0411ff90 	bar	1200000e0 <fn>
     100002a0:	00000000 	nop
     100002a4:	df998050 	ld	t9,-32688\(gp\)
-    100002a8:	0320f809 	jalr	t9
+    100002a8:	0411ff8d 	bal	1200000e0 <fn>
     100002ac:	00000000 	nop
     100002b0:	df8580c0 	ld	a1,-32576\(gp\)
     100002b4:	df8580c0 	ld	a1,-32576\(gp\)
@@ -244,10 +244,10 @@ Disassembly of section \.text:
     10000460:	df9980b0 	ld	t9,-32592\(gp\)
     10000464:	df998080 	ld	t9,-32640\(gp\)
     10000468:	df9980b0 	ld	t9,-32592\(gp\)
-    1000046c:	0320f809 	jalr	t9
+    1000046c:	0411001d 	bal	1200004e4 <fn2>
     10000470:	00000000 	nop
     10000474:	df998080 	ld	t9,-32640\(gp\)
-    10000478:	0320f809 	jalr	t9
+    10000478:	0411001a 	bal	1200004e4 <fn2>
     1000047c:	00000000 	nop
     10000480:	1000ff17 	b	100000e0 <fn>
     10000484:	df8580b8 	ld	a1,-32584\(gp\)
Index: src/ld/testsuite/ld-mips-elf/elf-rel-xgot-n32.d
===================================================================
--- src.orig/ld/testsuite/ld-mips-elf/elf-rel-xgot-n32.d	2009-08-06 18:03:32.000000000 -0700
+++ src/ld/testsuite/ld-mips-elf/elf-rel-xgot-n32.d	2009-08-07 10:28:02.908884000 -0700
@@ -183,11 +183,11 @@ Disassembly of section \.text:
 10000340:	3c190000 	lui	t9,0x0
 10000344:	033cc821 	addu	t9,t9,gp
 10000348:	8f39802c 	lw	t9,-32724\(t9\)
-1000034c:	0320f809 	jalr	t9
+1000034c:	0411ff58 	bal	100000b0 <fn>
 10000350:	00000000 	nop
 10000354:	8f998020 	lw	t9,-32736\(gp\)
 10000358:	273900b0 	addiu	t9,t9,176
-1000035c:	0320f809 	jalr	t9
+1000035c:	0411ff54 	bal	100000b0 <fn>
 10000360:	00000000 	nop
 10000364:	3c050000 	lui	a1,0x0
 10000368:	00bc2821 	addu	a1,a1,gp
@@ -356,11 +356,11 @@ Disassembly of section \.text:
 100005f4:	3c190000 	lui	t9,0x0
 100005f8:	033cc821 	addu	t9,t9,gp
 100005fc:	8f398030 	lw	t9,-32720\(t9\)
-10000600:	0320f809 	jalr	t9
+10000600:	0411002b 	bal	100006b0 <fn2>
 10000604:	00000000 	nop
 10000608:	8f998020 	lw	t9,-32736\(gp\)
 1000060c:	273906b0 	addiu	t9,t9,1712
-10000610:	0320f809 	jalr	t9
+10000610:	04110027 	bal	100006b0 <fn2>
 10000614:	00000000 	nop
 10000618:	3c050000 	lui	a1,0x0
 1000061c:	00bc2821 	addu	a1,a1,gp
Index: src/ld/testsuite/ld-mips-elf/relax-jalr-n32-shared.d
===================================================================
--- src.orig/ld/testsuite/ld-mips-elf/relax-jalr-n32-shared.d	2009-08-06 18:03:32.000000000 -0700
+++ src/ld/testsuite/ld-mips-elf/relax-jalr-n32-shared.d	2009-08-07 10:28:02.913882000 -0700
@@ -10,11 +10,11 @@ Disassembly of section \.text:
 	\.\.\.
 	\.\.\.
 .*	lw	t9,.*
-.*	jalr	t9
+.*	bal	.* <__start>
 .*	nop
 	\.\.\.
 .*	lw	t9,.*
-.*	jalr	t9
+.*	bal	.* <__start>
 .*	nop
 	\.\.\.
 .*	lw	t9,.*
Index: src/ld/testsuite/ld-mips-elf/relax-jalr-n64-shared.d
===================================================================
--- src.orig/ld/testsuite/ld-mips-elf/relax-jalr-n64-shared.d	2009-08-06 18:03:32.000000000 -0700
+++ src/ld/testsuite/ld-mips-elf/relax-jalr-n64-shared.d	2009-08-07 10:28:02.919874000 -0700
@@ -10,11 +10,11 @@ Disassembly of section \.text:
 	\.\.\.
 	\.\.\.
 .*	ld	t9,.*
-.*	jalr	t9
+.*	bal	.* <__start>
 .*	nop
 	\.\.\.
 .*	ld	t9,.*
-.*	jalr	t9
+.*	bal	.* <__start>
 .*	nop
 	\.\.\.
 .*	ld	t9,.*
Index: src/ld/testsuite/ld-mips-elf/elf-rel-xgot-n64-linux.d
===================================================================
--- src.orig/ld/testsuite/ld-mips-elf/elf-rel-xgot-n64-linux.d	2009-08-06 18:03:32.000000000 -0700
+++ src/ld/testsuite/ld-mips-elf/elf-rel-xgot-n64-linux.d	2009-08-07 10:28:02.925870000 -0700
@@ -185,11 +185,11 @@ Disassembly of section \.text:
    120000370:	3c190000 	lui	t9,0x0
    120000374:	033cc82d 	daddu	t9,t9,gp
    120000378:	df398048 	ld	t9,-32696\(t9\)
-   12000037c:	0320f809 	jalr	t9
+   12000037c:	0411ff58 	bal	1200000e0 <fn>
    120000380:	00000000 	nop
    120000384:	df998030 	ld	t9,-32720\(gp\)
    120000388:	673900e0 	daddiu	t9,t9,224
-   12000038c:	0320f809 	jalr	t9
+   12000038c:	0411ff54 	bal	1200000e0 <fn>
    120000390:	00000000 	nop
    120000394:	3c050000 	lui	a1,0x0
    120000398:	00bc282d 	daddu	a1,a1,gp
@@ -358,11 +358,11 @@ Disassembly of section \.text:
    120000624:	3c190000 	lui	t9,0x0
    120000628:	033cc82d 	daddu	t9,t9,gp
    12000062c:	df398050 	ld	t9,-32688\(t9\)
-   120000630:	0320f809 	jalr	t9
+   120000630:	0411002b 	bal	1200006e0 <fn2>
    120000634:	00000000 	nop
    120000638:	df998030 	ld	t9,-32720\(gp\)
    12000063c:	673906e0 	daddiu	t9,t9,1760
-   120000640:	0320f809 	jalr	t9
+   120000640:	04110027 	bal	1200006e0 <fn2>
    120000644:	00000000 	nop
    120000648:	3c050000 	lui	a1,0x0
    12000064c:	00bc282d 	daddu	a1,a1,gp
Index: src/ld/testsuite/ld-mips-elf/elf-rel-xgot-n64.d
===================================================================
--- src.orig/ld/testsuite/ld-mips-elf/elf-rel-xgot-n64.d	2009-08-07 10:24:52.000000000 -0700
+++ src/ld/testsuite/ld-mips-elf/elf-rel-xgot-n64.d	2009-08-07 10:36:28.332542000 -0700
@@ -184,11 +184,11 @@ Disassembly of section \.text:
     10000370:	3c190000 	lui	t9,0x0
     10000374:	033cc82d 	daddu	t9,t9,gp
     10000378:	df398048 	ld	t9,-32696\(t9\)
-    1000037c:	0320f809 	jalr	t9
+    1000037c:	0411ff58 	bal	100000e0 <fn>
     10000380:	00000000 	nop
     10000384:	df998030 	ld	t9,-32720\(gp\)
     10000388:	673900e0 	daddiu	t9,t9,224
-    1000038c:	0320f809 	jalr	t9
+    1000038c:	0411ff54 	bal	100000e0 <fn>
     10000390:	00000000 	nop
     10000394:	3c050000 	lui	a1,0x0
     10000398:	00bc282d 	daddu	a1,a1,gp
@@ -357,11 +357,11 @@ Disassembly of section \.text:
     10000624:	3c190000 	lui	t9,0x0
     10000628:	033cc82d 	daddu	t9,t9,gp
     1000062c:	df398050 	ld	t9,-32688\(t9\)
-    10000630:	0320f809 	jalr	t9
+    10000630:	0411002b 	bal	100006e0 <fn2>
     10000634:	00000000 	nop
     10000638:	df998030 	ld	t9,-32720\(gp\)
     1000063c:	673906e0 	daddiu	t9,t9,1760
-    10000640:	0320f809 	jalr	t9
+    10000640:	04110027 	bal	100006e0 <fn2>
     10000644:	00000000 	nop
     10000648:	3c050000 	lui	a1,0x0
     1000064c:	00bc282d 	daddu	a1,a1,gp


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]