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

2c2fa1
commit a078d95abc554b6c2572fcab5550591639b1c871
2c2fa1
Author: Alan Modra <amodra@gmail.com>
2c2fa1
Date:   Tue Oct 29 16:17:22 2013 +1030
2c2fa1
2c2fa1
    Support ELFv2 stack frame.
2c2fa1
    
2c2fa1
    The toc pointer save slot changes on ELFv2 from 40(1) to 24(1).
2c2fa1
    
2c2fa1
    	* elf64-ppc.c (STK_LR, STK_TOC, STK_LINKER): Define.
2c2fa1
    	(savegpr0_tail, restgpr0_tail, savefpr0_tail, restfpr0_tail)
2c2fa1
    	build_plt_stub, build_tls_get_addr_stub, ppc_build_one_stub,
2c2fa1
    	ppc64_elf_relocate_section): Use new defines.
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
@@ -130,6 +130,14 @@ static bfd_vma opd_entry_value
2c2fa1
 /* The initial size of the plt reserved for the dynamic linker.  */
2c2fa1
 #define PLT_INITIAL_ENTRY_SIZE(htab) (htab->opd_abi ? 24 : 16)
2c2fa1
 
2c2fa1
+/* Offsets to some stack save slots.  */
2c2fa1
+#define STK_LR 16
2c2fa1
+#define STK_TOC(htab) (htab->opd_abi ? 40 : 24)
2c2fa1
+/* This one is dodgy.  ABIv2 does not have a linker word, so use the
2c2fa1
+   CR save slot.  Used only by optimised __tls_get_addr call stub,
2c2fa1
+   relying on __tls_get_addr_opt not saving CR..  */
2c2fa1
+#define STK_LINKER(htab) (htab->opd_abi ? 32 : 8)
2c2fa1
+
2c2fa1
 /* TOC base pointers offset from start of TOC.  */
2c2fa1
 #define TOC_BASE_OFF	0x8000
2c2fa1
 
2c2fa1
@@ -140,7 +148,7 @@ static bfd_vma opd_entry_value
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 r11.  */
2c2fa1
-#define STD_R2_40R1	0xf8410028	/* std	 %r2,40(%r1)	     */
2c2fa1
+#define STD_R2_0R1	0xf8410000	/* std	 %r2,0+40(%r1)	     */
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
@@ -164,7 +172,7 @@ static bfd_vma opd_entry_value
2c2fa1
 #define LD_R11_0R2	0xe9620000	/* ld	 %r11,xxx+0(%r2) */
2c2fa1
 #define LD_R2_0R2	0xe8420000	/* ld	 %r2,xxx+0(%r2)  */
2c2fa1
 
2c2fa1
-#define LD_R2_40R1	0xe8410028	/* ld    %r2,40(%r1)     */
2c2fa1
+#define LD_R2_0R1	0xe8410000	/* ld    %r2,0(%r1)      */
2c2fa1
 
2c2fa1
 /* glink call stub instructions.  We enter with the index in R0.  */
2c2fa1
 #define GLINK_CALL_STUB_SIZE (16*4)
2c2fa1
@@ -6326,7 +6334,7 @@ static bfd_byte *
2c2fa1
 savegpr0_tail (bfd *abfd, bfd_byte *p, int r)
2c2fa1
 {
2c2fa1
   p = savegpr0 (abfd, p, r);
2c2fa1
-  bfd_put_32 (abfd, STD_R0_0R1 + 16, p);
2c2fa1
+  bfd_put_32 (abfd, STD_R0_0R1 + STK_LR, p);
2c2fa1
   p = p + 4;
2c2fa1
   bfd_put_32 (abfd, BLR, p);
2c2fa1
   return p + 4;
2c2fa1
@@ -6342,7 +6350,7 @@ restgpr0 (bfd *abfd, bfd_byte *p, int r)
2c2fa1
 static bfd_byte *
2c2fa1
 restgpr0_tail (bfd *abfd, bfd_byte *p, int r)
2c2fa1
 {
2c2fa1
-  bfd_put_32 (abfd, LD_R0_0R1 + 16, p);
2c2fa1
+  bfd_put_32 (abfd, LD_R0_0R1 + STK_LR, p);
2c2fa1
   p = p + 4;
2c2fa1
   p = restgpr0 (abfd, p, r);
2c2fa1
   bfd_put_32 (abfd, MTLR_R0, p);
2c2fa1
@@ -6397,7 +6405,7 @@ static bfd_byte *
2c2fa1
 savefpr0_tail (bfd *abfd, bfd_byte *p, int r)
2c2fa1
 {
2c2fa1
   p = savefpr (abfd, p, r);
2c2fa1
-  bfd_put_32 (abfd, STD_R0_0R1 + 16, p);
2c2fa1
+  bfd_put_32 (abfd, STD_R0_0R1 + STK_LR, p);
2c2fa1
   p = p + 4;
2c2fa1
   bfd_put_32 (abfd, BLR, p);
2c2fa1
   return p + 4;
2c2fa1
@@ -6413,7 +6421,7 @@ restfpr (bfd *abfd, bfd_byte *p, int r)
2c2fa1
 static bfd_byte *
2c2fa1
 restfpr0_tail (bfd *abfd, bfd_byte *p, int r)
2c2fa1
 {
2c2fa1
-  bfd_put_32 (abfd, LD_R0_0R1 + 16, p);
2c2fa1
+  bfd_put_32 (abfd, LD_R0_0R1 + STK_LR, p);
2c2fa1
   p = p + 4;
2c2fa1
   p = restfpr (abfd, p, r);
2c2fa1
   bfd_put_32 (abfd, MTLR_R0, p);
2c2fa1
@@ -9873,7 +9881,7 @@ build_plt_stub (struct ppc_link_hash_tab
2c2fa1
 	}
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, STD_R2_0R1 + STK_TOC (htab), 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 (plt_load_toc
2c2fa1
@@ -9927,7 +9935,7 @@ build_plt_stub (struct ppc_link_hash_tab
2c2fa1
 	}
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, STD_R2_0R1 + STK_TOC (htab), p),	p += 4;
2c2fa1
       bfd_put_32 (obfd, LD_R12_0R2 | PPC_LO (offset), p),	p += 4;
2c2fa1
       if (plt_load_toc
2c2fa1
 	  && PPC_HA (offset + 8 + 8 * plt_static_chain) != PPC_HA (offset))
2c2fa1
@@ -9968,11 +9976,9 @@ build_plt_stub (struct ppc_link_hash_tab
2c2fa1
 #define ADD_R3_R12_R13	0x7c6c6a14
2c2fa1
 #define BEQLR		0x4d820020
2c2fa1
 #define MR_R3_R0	0x7c030378
2c2fa1
-#define MFLR_R11	0x7d6802a6
2c2fa1
 #define STD_R11_0R1	0xf9610000
2c2fa1
 #define BCTRL		0x4e800421
2c2fa1
 #define LD_R11_0R1	0xe9610000
2c2fa1
-#define LD_R2_0R1	0xe8410000
2c2fa1
 #define MTLR_R11	0x7d6803a6
2c2fa1
 
2c2fa1
 static inline bfd_byte *
2c2fa1
@@ -9990,15 +9996,15 @@ build_tls_get_addr_stub (struct ppc_link
2c2fa1
   bfd_put_32 (obfd, BEQLR, p),			p += 4;
2c2fa1
   bfd_put_32 (obfd, MR_R3_R0, p),		p += 4;
2c2fa1
   bfd_put_32 (obfd, MFLR_R11, p),		p += 4;
2c2fa1
-  bfd_put_32 (obfd, STD_R11_0R1 + 32, p),	p += 4;
2c2fa1
+  bfd_put_32 (obfd, STD_R11_0R1 + STK_LINKER (htab), p), p += 4;
2c2fa1
 
2c2fa1
   if (r != NULL)
2c2fa1
     r[0].r_offset += 9 * 4;
2c2fa1
   p = build_plt_stub (htab, stub_entry, p, offset, r);
2c2fa1
   bfd_put_32 (obfd, BCTRL, p - 4);
2c2fa1
 
2c2fa1
-  bfd_put_32 (obfd, LD_R11_0R1 + 32, p),	p += 4;
2c2fa1
-  bfd_put_32 (obfd, LD_R2_0R1 + 40, p),		p += 4;
2c2fa1
+  bfd_put_32 (obfd, LD_R11_0R1 + STK_LINKER (htab), p),	p += 4;
2c2fa1
+  bfd_put_32 (obfd, LD_R2_0R1 + STK_TOC (htab), p),	p += 4;
2c2fa1
   bfd_put_32 (obfd, MTLR_R11, p),		p += 4;
2c2fa1
   bfd_put_32 (obfd, BLR, p),			p += 4;
2c2fa1
 
2c2fa1
@@ -10122,7 +10128,7 @@ ppc_build_one_stub (struct bfd_hash_entr
2c2fa1
 	      htab->stub_error = TRUE;
2c2fa1
 	      return FALSE;
2c2fa1
 	    }
2c2fa1
-	  bfd_put_32 (htab->stub_bfd, STD_R2_40R1, loc);
2c2fa1
+	  bfd_put_32 (htab->stub_bfd, STD_R2_0R1 + STK_TOC (htab), loc);
2c2fa1
 	  loc += 4;
2c2fa1
 	  size = 12;
2c2fa1
 	  if (PPC_HA (r2off) != 0)
2c2fa1
@@ -10318,7 +10324,7 @@ ppc_build_one_stub (struct bfd_hash_entr
2c2fa1
 	      return FALSE;
2c2fa1
 	    }
2c2fa1
 
2c2fa1
-	  bfd_put_32 (htab->stub_bfd, STD_R2_40R1, loc);
2c2fa1
+	  bfd_put_32 (htab->stub_bfd, STD_R2_0R1 + STK_TOC (htab), loc);
2c2fa1
 	  loc += 4;
2c2fa1
 	  size = 20;
2c2fa1
 	  if (PPC_HA (off) != 0)
2c2fa1
@@ -13113,7 +13119,8 @@ ppc64_elf_relocate_section (bfd *output_
2c2fa1
 	      insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
2c2fa1
 	      if (insn == NOP
2c2fa1
 		  || insn == CROR_151515 || insn == CROR_313131)
2c2fa1
-		bfd_put_32 (input_bfd, STD_R2_40R1,
2c2fa1
+		bfd_put_32 (input_bfd,
2c2fa1
+			    STD_R2_0R1 + STK_TOC (htab),
2c2fa1
 			    contents + rel->r_offset);
2c2fa1
 	    }
2c2fa1
 	  break;
2c2fa1
@@ -13172,7 +13179,8 @@ ppc64_elf_relocate_section (bfd *output_
2c2fa1
 			  /* Special stub used, leave nop alone.  */
2c2fa1
 			}
2c2fa1
 		      else
2c2fa1
-			bfd_put_32 (input_bfd, LD_R2_40R1,
2c2fa1
+			bfd_put_32 (input_bfd,
2c2fa1
+				    LD_R2_0R1 + STK_TOC (htab),
2c2fa1
 				    contents + rel->r_offset + 4);
2c2fa1
 		      can_plt_call = TRUE;
2c2fa1
 		    }