Blame SOURCES/gdb-rhbz1125820-ppc64le-enablement-07of37.patch

2c2fa1
commit 71a39c98f8bedad54818c62ab2d567b0e2de546b
2c2fa1
Author: Alan Modra <amodra@gmail.com>
2c2fa1
Date:   Tue Oct 29 12:39:30 2013 +1030
2c2fa1
2c2fa1
    Change plt stubs to have destination in r12.
2c2fa1
    
2c2fa1
    This change is to support the new ELFv2 ABI, which uses the value in
2c2fa1
    r12 on function entry to calculate the got/toc pointer.
2c2fa1
    
2c2fa1
    bfd/
2c2fa1
    	* elf64-ppc.c (build_plt_stub): Switch stubs to use r11 as base
2c2fa1
    	reg and r12 as destination.
2c2fa1
    	(ppc_build_one_stub): Likewise.
2c2fa1
    	(ppc64_elf_build_stubs): Likewise for glink.
2c2fa1
    ld/testsuite/
2c2fa1
    	* ld-powerpc/tls.s: Add proper .opd entry for _start.
2c2fa1
    	* ld-powerpc/tlstoc.s: Likewise.
2c2fa1
    	* ld-powerpc/relbrlt.d: Update for changed stubs.
2c2fa1
    	* ld-powerpc/tls.d: Update for changed stubs and _start .opd entry.
2c2fa1
    	* ld-powerpc/tls.g: Likewise.
2c2fa1
    	* ld-powerpc/tlsexe.d: Likewise.
2c2fa1
    	* ld-powerpc/tlsexe.g: Likewise.
2c2fa1
    	* ld-powerpc/tlsexe.r: Likewise.
2c2fa1
    	* ld-powerpc/tlsexetoc.d: Likewise.
2c2fa1
    	* ld-powerpc/tlsexetoc.g: Likewise.
2c2fa1
    	* ld-powerpc/tlsexetoc.r: Likewise.
2c2fa1
    	* ld-powerpc/tlsso.d: Likewise.
2c2fa1
    	* ld-powerpc/tlsso.g: Likewise.
2c2fa1
    	* ld-powerpc/tlsso.r: Likewise.
2c2fa1
    	* ld-powerpc/tlstoc.d: Likewise.
2c2fa1
    	* ld-powerpc/tlstoc.g: Likewise.
2c2fa1
    	* ld-powerpc/tlstocso.d: Likewise.
2c2fa1
    	* ld-powerpc/tlstocso.g: Likewise.
2c2fa1
    	* ld-powerpc/tlstocso.r: Likewise.
2c2fa1
2c2fa1
Index: gdb-7.6.1/bfd/elf64-ppc.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/bfd/elf64-ppc.c
2c2fa1
+++ gdb-7.6.1/bfd/elf64-ppc.c
2c2fa1
@@ -137,29 +137,29 @@ static bfd_vma opd_entry_value
2c2fa1
 
2c2fa1
 /* .plt call stub instructions.  The normal stub is like this, but
2c2fa1
    sometimes the .plt entry crosses a 64k boundary and we need to
2c2fa1
-   insert an addi to adjust r12.  */
2c2fa1
+   insert an addi to adjust r11.  */
2c2fa1
 #define PLT_CALL_STUB_SIZE (7*4)
2c2fa1
-#define ADDIS_R12_R2	0x3d820000	/* addis %r12,%r2,xxx@ha     */
2c2fa1
 #define STD_R2_40R1	0xf8410028	/* std	 %r2,40(%r1)	     */
2c2fa1
-#define LD_R11_0R12	0xe96c0000	/* ld	 %r11,xxx+0@l(%r12)  */
2c2fa1
-#define MTCTR_R11	0x7d6903a6	/* mtctr %r11		     */
2c2fa1
-#define LD_R2_0R12	0xe84c0000	/* ld	 %r2,xxx+8@l(%r12)   */
2c2fa1
-					/* ld	 %r11,xxx+16@l(%r12) */
2c2fa1
+#define ADDIS_R11_R2	0x3d620000	/* addis %r11,%r2,xxx@ha     */
2c2fa1
+#define LD_R12_0R11	0xe98b0000	/* ld	 %r12,xxx+0@l(%r11)  */
2c2fa1
+#define MTCTR_R12	0x7d8903a6	/* mtctr %r12		     */
2c2fa1
+#define LD_R2_0R11	0xe84b0000	/* ld	 %r2,xxx+8@l(%r11)   */
2c2fa1
+#define LD_R11_0R11	0xe96b0000	/* ld	 %r11,xxx+16@l(%r11) */
2c2fa1
 #define BCTR		0x4e800420	/* bctr			     */
2c2fa1
 
2c2fa1
-
2c2fa1
-#define ADDIS_R12_R12	0x3d8c0000	/* addis %r12,%r12,off@ha  */
2c2fa1
-#define ADDI_R12_R12	0x398c0000	/* addi %r12,%r12,off@l  */
2c2fa1
+#define ADDI_R11_R11	0x396b0000	/* addi %r11,%r11,off@l  */
2c2fa1
 #define ADDIS_R2_R2	0x3c420000	/* addis %r2,%r2,off@ha  */
2c2fa1
 #define ADDI_R2_R2	0x38420000	/* addi  %r2,%r2,off@l   */
2c2fa1
 
2c2fa1
-#define XOR_R11_R11_R11	0x7d6b5a78	/* xor   %r11,%r11,%r11  */
2c2fa1
-#define ADD_R12_R12_R11	0x7d8c5a14	/* add   %r12,%r12,%r11  */
2c2fa1
+#define XOR_R2_R12_R12	0x7d826278	/* xor   %r2,%r12,%r12   */
2c2fa1
+#define ADD_R11_R11_R2	0x7d6b1214	/* add   %r11,%r11,%r2   */
2c2fa1
+#define XOR_R11_R12_R12	0x7d8b6278	/* xor   %r11,%r12,%r12  */
2c2fa1
 #define ADD_R2_R2_R11	0x7c425a14	/* add   %r2,%r2,%r11    */
2c2fa1
 #define CMPLDI_R2_0	0x28220000	/* cmpldi %r2,0          */
2c2fa1
 #define BNECTR		0x4ca20420	/* bnectr+               */
2c2fa1
 #define BNECTR_P4	0x4ce20420	/* bnectr+               */
2c2fa1
 
2c2fa1
+#define LD_R12_0R2	0xe9820000	/* ld	 %r12,xxx+0(%r2) */
2c2fa1
 #define LD_R11_0R2	0xe9620000	/* ld	 %r11,xxx+0(%r2) */
2c2fa1
 #define LD_R2_0R2	0xe8420000	/* ld	 %r2,xxx+0(%r2)  */
2c2fa1
 
2c2fa1
@@ -174,13 +174,13 @@ static bfd_vma opd_entry_value
2c2fa1
 #define BCL_20_31	0x429f0005	/*  bcl 20,31,1f		*/
2c2fa1
 					/* 1:				*/
2c2fa1
 #define MFLR_R11	0x7d6802a6	/*  mflr %11			*/
2c2fa1
-#define LD_R2_M16R11	0xe84bfff0	/*  ld %2,(0b-1b)(%11)		*/
2c2fa1
+					/*  ld %2,(0b-1b)(%11)		*/
2c2fa1
 #define MTLR_R12	0x7d8803a6	/*  mtlr %12			*/
2c2fa1
-#define ADD_R12_R2_R11	0x7d825a14	/*  add %12,%2,%11		*/
2c2fa1
-					/*  ld %11,0(%12)		*/
2c2fa1
-					/*  ld %2,8(%12)		*/
2c2fa1
-					/*  mtctr %11			*/
2c2fa1
-					/*  ld %11,16(%12)		*/
2c2fa1
+#define ADD_R11_R2_R11	0x7d625a14	/*  add %11,%2,%11		*/
2c2fa1
+					/*  ld %12,0(%11)		*/
2c2fa1
+					/*  ld %2,8(%11)		*/
2c2fa1
+					/*  mtctr %12			*/
2c2fa1
+					/*  ld %11,16(%11)		*/
2c2fa1
 					/*  bctr			*/
2c2fa1
 
2c2fa1
 /* Pad with this.  */
2c2fa1
@@ -3452,13 +3452,13 @@ ppc64_elf_get_synthetic_symtab (bfd *abf
2c2fa1
    .
2c2fa1
    .
2c2fa1
    .	.foo_stub:
2c2fa1
-   .		addis	12,2,Lfoo@toc@ha	# in practice, the call stub
2c2fa1
-   .		addi	12,12,Lfoo@toc@l	# is slightly optimized, but
2c2fa1
-   .		std	2,40(1)			# this is the general idea
2c2fa1
-   .		ld	11,0(12)
2c2fa1
-   .		ld	2,8(12)
2c2fa1
-   .		mtctr	11
2c2fa1
-   .		ld	11,16(12)
2c2fa1
+   .		std	2,40(1)			# in practice, the call stub
2c2fa1
+   .		addis	11,2,Lfoo@toc@ha	# is slightly optimized, but
2c2fa1
+   .		addi	11,11,Lfoo@toc@l	# this is the general idea
2c2fa1
+   .		ld	12,0(11)
2c2fa1
+   .		ld	2,8(11)
2c2fa1
+   .		mtctr	12
2c2fa1
+   .		ld	11,16(11)
2c2fa1
    .		bctr
2c2fa1
    .
2c2fa1
    .		.section .plt
2c2fa1
@@ -3548,21 +3548,21 @@ must_be_dyn_reloc (struct bfd_link_info
2c2fa1
    ppc_stub_plt_branch:
2c2fa1
    Similar to the above, but a 24 bit branch in the stub section won't
2c2fa1
    reach its destination.
2c2fa1
-   .	addis	%r12,%r2,xxx@toc@ha
2c2fa1
-   .	ld	%r11,xxx@toc@l(%r12)
2c2fa1
-   .	mtctr	%r11
2c2fa1
+   .	addis	%r11,%r2,xxx@toc@ha
2c2fa1
+   .	ld	%r12,xxx@toc@l(%r11)
2c2fa1
+   .	mtctr	%r12
2c2fa1
    .	bctr
2c2fa1
 
2c2fa1
    ppc_stub_plt_call:
2c2fa1
    Used to call a function in a shared library.  If it so happens that
2c2fa1
    the plt entry referenced crosses a 64k boundary, then an extra
2c2fa1
-   "addi %r12,%r12,xxx@toc@l" will be inserted before the "mtctr".
2c2fa1
-   .	addis	%r12,%r2,xxx@toc@ha
2c2fa1
+   "addi %r11,%r11,xxx@toc@l" will be inserted before the "mtctr".
2c2fa1
    .	std	%r2,40(%r1)
2c2fa1
-   .	ld	%r11,xxx+0@toc@l(%r12)
2c2fa1
-   .	mtctr	%r11
2c2fa1
-   .	ld	%r2,xxx+8@toc@l(%r12)
2c2fa1
-   .	ld	%r11,xxx+16@toc@l(%r12)
2c2fa1
+   .	addis	%r11,%r2,xxx@toc@ha
2c2fa1
+   .	ld	%r12,xxx+0@toc@l(%r11)
2c2fa1
+   .	mtctr	%r12
2c2fa1
+   .	ld	%r2,xxx+8@toc@l(%r11)
2c2fa1
+   .	ld	%r11,xxx+16@toc@l(%r11)
2c2fa1
    .	bctr
2c2fa1
 
2c2fa1
    ppc_stub_long_branch and ppc_stub_plt_branch may also have additional
2c2fa1
@@ -3575,11 +3575,11 @@ must_be_dyn_reloc (struct bfd_link_info
2c2fa1
 
2c2fa1
    A ppc_stub_plt_branch with an r2 offset looks like:
2c2fa1
    .	std	%r2,40(%r1)
2c2fa1
-   .	addis	%r12,%r2,xxx@toc@ha
2c2fa1
-   .	ld	%r11,xxx@toc@l(%r12)
2c2fa1
+   .	addis	%r11,%r2,xxx@toc@ha
2c2fa1
+   .	ld	%r12,xxx@toc@l(%r11)
2c2fa1
    .	addis	%r2,%r2,off@ha
2c2fa1
    .	addi	%r2,%r2,off@l
2c2fa1
-   .	mtctr	%r11
2c2fa1
+   .	mtctr	%r12
2c2fa1
    .	bctr
2c2fa1
 
2c2fa1
    In cases where the "addis" instruction would add zero, the "addis" is
2c2fa1
@@ -9569,9 +9569,9 @@ ppc_type_of_stub (asection *input_sec,
2c2fa1
    the appropriate glink entry if so.
2c2fa1
 
2c2fa1
    .	fake dep barrier	compare
2c2fa1
-   .	ld 11,xxx(2)		ld 11,xxx(2)
2c2fa1
-   .	mtctr 11		mtctr 11
2c2fa1
-   .	xor 11,11,11		ld 2,xxx+8(2)
2c2fa1
+   .	ld 12,xxx(2)		ld 12,xxx(2)
2c2fa1
+   .	mtctr 12		mtctr 12
2c2fa1
+   .	xor 11,12,12		ld 2,xxx+8(2)
2c2fa1
    .	add 2,2,11		cmpldi 2,0
2c2fa1
    .	ld 2,xxx+8(2)		bnectr+
2c2fa1
    .	bctr			b <glink_entry>
2c2fa1
@@ -9706,22 +9706,22 @@ build_plt_stub (struct ppc_link_hash_tab
2c2fa1
       if (ALWAYS_EMIT_R2SAVE
2c2fa1
 	  || stub_entry->stub_type == ppc_stub_plt_call_r2save)
2c2fa1
 	bfd_put_32 (obfd, STD_R2_40R1, p),			p += 4;
2c2fa1
-      bfd_put_32 (obfd, ADDIS_R12_R2 | PPC_HA (offset), p),	p += 4;
2c2fa1
-      bfd_put_32 (obfd, LD_R11_0R12 | PPC_LO (offset), p),	p += 4;
2c2fa1
+      bfd_put_32 (obfd, ADDIS_R11_R2 | PPC_HA (offset), p),	p += 4;
2c2fa1
+      bfd_put_32 (obfd, LD_R12_0R11 | PPC_LO (offset), p),	p += 4;
2c2fa1
       if (PPC_HA (offset + 8 + 8 * plt_static_chain) != PPC_HA (offset))
2c2fa1
 	{
2c2fa1
-	  bfd_put_32 (obfd, ADDI_R12_R12 | PPC_LO (offset), p),	p += 4;
2c2fa1
+	  bfd_put_32 (obfd, ADDI_R11_R11 | PPC_LO (offset), p),	p += 4;
2c2fa1
 	  offset = 0;
2c2fa1
 	}
2c2fa1
-      bfd_put_32 (obfd, MTCTR_R11, p),				p += 4;
2c2fa1
+      bfd_put_32 (obfd, MTCTR_R12, p),				p += 4;
2c2fa1
       if (use_fake_dep)
2c2fa1
 	{
2c2fa1
-	  bfd_put_32 (obfd, XOR_R11_R11_R11, p),		p += 4;
2c2fa1
-	  bfd_put_32 (obfd, ADD_R12_R12_R11, p),		p += 4;
2c2fa1
+	  bfd_put_32 (obfd, XOR_R2_R12_R12, p),			p += 4;
2c2fa1
+	  bfd_put_32 (obfd, ADD_R11_R11_R2, p),			p += 4;
2c2fa1
 	}
2c2fa1
-      bfd_put_32 (obfd, LD_R2_0R12 | PPC_LO (offset + 8), p),	p += 4;
2c2fa1
+      bfd_put_32 (obfd, LD_R2_0R11 | PPC_LO (offset + 8), p),	p += 4;
2c2fa1
       if (plt_static_chain)
2c2fa1
-	bfd_put_32 (obfd, LD_R11_0R12 | PPC_LO (offset + 16), p), p += 4;
2c2fa1
+	bfd_put_32 (obfd, LD_R11_0R11 | PPC_LO (offset + 16), p), p += 4;
2c2fa1
     }
2c2fa1
   else
2c2fa1
     {
2c2fa1
@@ -9753,16 +9753,16 @@ build_plt_stub (struct ppc_link_hash_tab
2c2fa1
       if (ALWAYS_EMIT_R2SAVE
2c2fa1
 	  || stub_entry->stub_type == ppc_stub_plt_call_r2save)
2c2fa1
 	bfd_put_32 (obfd, STD_R2_40R1, p),			p += 4;
2c2fa1
-      bfd_put_32 (obfd, LD_R11_0R2 | PPC_LO (offset), p),	p += 4;
2c2fa1
+      bfd_put_32 (obfd, LD_R12_0R2 | PPC_LO (offset), p),	p += 4;
2c2fa1
       if (PPC_HA (offset + 8 + 8 * plt_static_chain) != PPC_HA (offset))
2c2fa1
 	{
2c2fa1
 	  bfd_put_32 (obfd, ADDI_R2_R2 | PPC_LO (offset), p),	p += 4;
2c2fa1
 	  offset = 0;
2c2fa1
 	}
2c2fa1
-      bfd_put_32 (obfd, MTCTR_R11, p),				p += 4;
2c2fa1
+      bfd_put_32 (obfd, MTCTR_R12, p),				p += 4;
2c2fa1
       if (use_fake_dep)
2c2fa1
 	{
2c2fa1
-	  bfd_put_32 (obfd, XOR_R11_R11_R11, p),		p += 4;
2c2fa1
+	  bfd_put_32 (obfd, XOR_R11_R12_R12, p),		p += 4;
2c2fa1
 	  bfd_put_32 (obfd, ADD_R2_R2_R11, p),			p += 4;
2c2fa1
 	}
2c2fa1
       if (plt_static_chain)
2c2fa1
@@ -10111,14 +10111,14 @@ ppc_build_one_stub (struct bfd_hash_entr
2c2fa1
 	  if (PPC_HA (off) != 0)
2c2fa1
 	    {
2c2fa1
 	      size = 16;
2c2fa1
-	      bfd_put_32 (htab->stub_bfd, ADDIS_R12_R2 | PPC_HA (off), loc);
2c2fa1
+	      bfd_put_32 (htab->stub_bfd, ADDIS_R11_R2 | PPC_HA (off), loc);
2c2fa1
 	      loc += 4;
2c2fa1
-	      bfd_put_32 (htab->stub_bfd, LD_R11_0R12 | PPC_LO (off), loc);
2c2fa1
+	      bfd_put_32 (htab->stub_bfd, LD_R12_0R11 | PPC_LO (off), loc);
2c2fa1
 	    }
2c2fa1
 	  else
2c2fa1
 	    {
2c2fa1
 	      size = 12;
2c2fa1
-	      bfd_put_32 (htab->stub_bfd, LD_R11_0R2 | PPC_LO (off), loc);
2c2fa1
+	      bfd_put_32 (htab->stub_bfd, LD_R12_0R2 | PPC_LO (off), loc);
2c2fa1
 	    }
2c2fa1
 	}
2c2fa1
       else
2c2fa1
@@ -10137,14 +10137,14 @@ ppc_build_one_stub (struct bfd_hash_entr
2c2fa1
 	  if (PPC_HA (off) != 0)
2c2fa1
 	    {
2c2fa1
 	      size += 4;
2c2fa1
-	      bfd_put_32 (htab->stub_bfd, ADDIS_R12_R2 | PPC_HA (off), loc);
2c2fa1
+	      bfd_put_32 (htab->stub_bfd, ADDIS_R11_R2 | PPC_HA (off), loc);
2c2fa1
 	      loc += 4;
2c2fa1
-	      bfd_put_32 (htab->stub_bfd, LD_R11_0R12 | PPC_LO (off), loc);
2c2fa1
+	      bfd_put_32 (htab->stub_bfd, LD_R12_0R11 | PPC_LO (off), loc);
2c2fa1
 	      loc += 4;
2c2fa1
 	    }
2c2fa1
 	  else
2c2fa1
 	    {
2c2fa1
-	      bfd_put_32 (htab->stub_bfd, LD_R11_0R2 | PPC_LO (off), loc);
2c2fa1
+	      bfd_put_32 (htab->stub_bfd, LD_R12_0R2 | PPC_LO (off), loc);
2c2fa1
 	      loc += 4;
2c2fa1
 	    }
2c2fa1
 
2c2fa1
@@ -10157,7 +10157,7 @@ ppc_build_one_stub (struct bfd_hash_entr
2c2fa1
 	  bfd_put_32 (htab->stub_bfd, ADDI_R2_R2 | PPC_LO (r2off), loc);
2c2fa1
 	}
2c2fa1
       loc += 4;
2c2fa1
-      bfd_put_32 (htab->stub_bfd, MTCTR_R11, loc);
2c2fa1
+      bfd_put_32 (htab->stub_bfd, MTCTR_R12, loc);
2c2fa1
       loc += 4;
2c2fa1
       bfd_put_32 (htab->stub_bfd, BCTR, loc);
2c2fa1
       break;
2c2fa1
@@ -11909,19 +11909,19 @@ ppc64_elf_build_stubs (bfd_boolean emit_
2c2fa1
       p += 4;
2c2fa1
       bfd_put_32 (htab->glink->owner, MFLR_R11, p);
2c2fa1
       p += 4;
2c2fa1
-      bfd_put_32 (htab->glink->owner, LD_R2_M16R11, p);
2c2fa1
+      bfd_put_32 (htab->glink->owner, LD_R2_0R11 | (-16 & 0xfffc), p);
2c2fa1
       p += 4;
2c2fa1
       bfd_put_32 (htab->glink->owner, MTLR_R12, p);
2c2fa1
       p += 4;
2c2fa1
-      bfd_put_32 (htab->glink->owner, ADD_R12_R2_R11, p);
2c2fa1
+      bfd_put_32 (htab->glink->owner, ADD_R11_R2_R11, p);
2c2fa1
       p += 4;
2c2fa1
-      bfd_put_32 (htab->glink->owner, LD_R11_0R12, p);
2c2fa1
+      bfd_put_32 (htab->glink->owner, LD_R12_0R11, p);
2c2fa1
       p += 4;
2c2fa1
-      bfd_put_32 (htab->glink->owner, LD_R2_0R12 | 8, p);
2c2fa1
+      bfd_put_32 (htab->glink->owner, LD_R2_0R11 | 8, p);
2c2fa1
       p += 4;
2c2fa1
-      bfd_put_32 (htab->glink->owner, MTCTR_R11, p);
2c2fa1
+      bfd_put_32 (htab->glink->owner, MTCTR_R12, p);
2c2fa1
       p += 4;
2c2fa1
-      bfd_put_32 (htab->glink->owner, LD_R11_0R12 | 16, p);
2c2fa1
+      bfd_put_32 (htab->glink->owner, LD_R11_0R11 | 16, p);
2c2fa1
       p += 4;
2c2fa1
       bfd_put_32 (htab->glink->owner, BCTR, p);
2c2fa1
       p += 4;