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

01917d
commit 397998fc32a34d3c8993ef46da45c3957a4dd402
01917d
Author: Alan Modra <amodra@gmail.com>
01917d
Date:   Tue Jun 3 10:55:29 2014 +0930
01917d
01917d
    Support fusion for ELFv2 stubs
01917d
    
01917d
    Power8 fuses addis,addi and addis,ld sequences when the target of the
01917d
    addis is the same as the addi/ld.  Thus
01917d
        addis r12,r2,xxx@ha
01917d
        addi r12,r12,xxx@l / ld r12,xxx@l(r12)
01917d
    is faster than
01917d
        addis r11,r2,xxx@ha
01917d
        addi r12,r11,xxx@l / ld r12,xxx@l(r11)
01917d
    So use the form that allows fusion in plt call and branch stubs.
01917d
    
01917d
    bfd/
01917d
    	* elf64-ppc.c (ADDIS_R12_R2): Define.
01917d
    	(build_plt_stub): Support fusion on ELFv2 stub.
01917d
    	(ppc_build_one_stub): Likewise for plt branch stubs.
01917d
    gold/
01917d
    	* powerpc.cc (addis_12_2): Define.
01917d
    	(Stub_table::do_write): Support fusion on ELFv2 stubs.
01917d
    ld/testsuite/
01917d
    	* ld-powerpc/elfv2exe.d: Update for changed plt call stubs.
01917d
    gdb/
01917d
    	* ppc64-tdep.c (ppc64_standard_linkage8): New.
01917d
    	(ppc64_skip_trampoline_code): Recognise ELFv2 stub supporting fusion.
01917d
01917d
Index: gdb-7.6.1/bfd/elf64-ppc.c
01917d
===================================================================
01917d
--- gdb-7.6.1.orig/bfd/elf64-ppc.c
01917d
+++ gdb-7.6.1/bfd/elf64-ppc.c
01917d
@@ -175,6 +175,7 @@ static bfd_vma opd_entry_value
01917d
 
01917d
 #define LD_R2_0R1	0xe8410000	/* ld    %r2,0(%r1)      */
01917d
 
01917d
+#define ADDIS_R12_R2	0x3d820000	/* addis %r12,%r2,xxx@ha     */
01917d
 #define ADDIS_R12_R12	0x3d8c0000	/* addis %r12,%r12,xxx@ha */
01917d
 #define LD_R12_0R12	0xe98c0000	/* ld    %r12,xxx@l(%r12) */
01917d
 
01917d
@@ -9990,8 +9991,16 @@ build_plt_stub (struct ppc_link_hash_tab
01917d
       if (ALWAYS_EMIT_R2SAVE
01917d
 	  || stub_entry->stub_type == ppc_stub_plt_call_r2save)
01917d
 	bfd_put_32 (obfd, STD_R2_0R1 + STK_TOC (htab), p),	p += 4;
01917d
-      bfd_put_32 (obfd, ADDIS_R11_R2 | PPC_HA (offset), p),	p += 4;
01917d
-      bfd_put_32 (obfd, LD_R12_0R11 | PPC_LO (offset), p),	p += 4;
01917d
+      if (plt_load_toc)
01917d
+	{
01917d
+	  bfd_put_32 (obfd, ADDIS_R11_R2 | PPC_HA (offset), p),	p += 4;
01917d
+	  bfd_put_32 (obfd, LD_R12_0R11 | PPC_LO (offset), p),	p += 4;
01917d
+	}
01917d
+      else
01917d
+	{
01917d
+	  bfd_put_32 (obfd, ADDIS_R12_R2 | PPC_HA (offset), p),	p += 4;
01917d
+	  bfd_put_32 (obfd, LD_R12_0R12 | PPC_LO (offset), p),	p += 4;
01917d
+	}
01917d
       if (plt_load_toc
01917d
 	  && PPC_HA (offset + 8 + 8 * plt_static_chain) != PPC_HA (offset))
01917d
 	{
01917d
@@ -10410,9 +10419,9 @@ ppc_build_one_stub (struct bfd_hash_entr
01917d
 	  if (PPC_HA (off) != 0)
01917d
 	    {
01917d
 	      size = 16;
01917d
-	      bfd_put_32 (htab->stub_bfd, ADDIS_R11_R2 | PPC_HA (off), loc);
01917d
+	      bfd_put_32 (htab->stub_bfd, ADDIS_R12_R2 | PPC_HA (off), loc);
01917d
 	      loc += 4;
01917d
-	      bfd_put_32 (htab->stub_bfd, LD_R12_0R11 | PPC_LO (off), loc);
01917d
+	      bfd_put_32 (htab->stub_bfd, LD_R12_0R12 | PPC_LO (off), loc);
01917d
 	    }
01917d
 	  else
01917d
 	    {
01917d
@@ -10436,9 +10445,9 @@ ppc_build_one_stub (struct bfd_hash_entr
01917d
 	  if (PPC_HA (off) != 0)
01917d
 	    {
01917d
 	      size += 4;
01917d
-	      bfd_put_32 (htab->stub_bfd, ADDIS_R11_R2 | PPC_HA (off), loc);
01917d
+	      bfd_put_32 (htab->stub_bfd, ADDIS_R12_R2 | PPC_HA (off), loc);
01917d
 	      loc += 4;
01917d
-	      bfd_put_32 (htab->stub_bfd, LD_R12_0R11 | PPC_LO (off), loc);
01917d
+	      bfd_put_32 (htab->stub_bfd, LD_R12_0R12 | PPC_LO (off), loc);
01917d
 	    }
01917d
 	  else
01917d
 	    bfd_put_32 (htab->stub_bfd, LD_R12_0R2 | PPC_LO (off), loc);
01917d
Index: gdb-7.6.1/gdb/ppc64-tdep.c
01917d
===================================================================
01917d
--- gdb-7.6.1.orig/gdb/ppc64-tdep.c
01917d
+++ gdb-7.6.1/gdb/ppc64-tdep.c
01917d
@@ -303,6 +303,29 @@ static struct ppc_insn_pattern ppc64_sta
01917d
     { 0, 0, 0 }
01917d
   };
01917d
 
01917d
+/* ELFv2 PLT call stub to access PLT entries more than +/- 32k from r2,
01917d
+   supporting fusion.  */
01917d
+
01917d
+static struct ppc_insn_pattern ppc64_standard_linkage8[] =
01917d
+  {
01917d
+    /* std r2, 24(r1) <optional> */
01917d
+    { -1, insn_ds (62, 2, 1, 24, 0), 1 },
01917d
+
01917d
+    /* addis r12, r2, <any> */
01917d
+    { insn_d (-1, -1, -1, 0), insn_d (15, 12, 2, 0), 0 },
01917d
+
01917d
+    /* ld r12, <any>(r12) */
01917d
+    { insn_ds (-1, -1, -1, 0, -1), insn_ds (58, 12, 12, 0, 0), 0 },
01917d
+
01917d
+    /* mtctr r12 */
01917d
+    { insn_xfx (-1, -1, -1, -1), insn_xfx (31, 12, 9, 467), 0 },
01917d
+
01917d
+    /* bctr */
01917d
+    { -1, 0x4e800420, 0 },
01917d
+
01917d
+    { 0, 0, 0 }
01917d
+  };
01917d
+
01917d
 /* When the dynamic linker is doing lazy symbol resolution, the first
01917d
    call to a function in another object will go like this:
01917d
 
01917d
@@ -437,10 +460,14 @@ ppc64_skip_trampoline_code (struct frame
01917d
 				    ARRAY_SIZE (ppc64_standard_linkage4))),
01917d
 			  MAX (MAX (ARRAY_SIZE (ppc64_standard_linkage5),
01917d
 				    ARRAY_SIZE (ppc64_standard_linkage6)),
01917d
-			       ARRAY_SIZE (ppc64_standard_linkage7))) - 1];
01917d
+			       MAX (ARRAY_SIZE (ppc64_standard_linkage7),
01917d
+				    ARRAY_SIZE (ppc64_standard_linkage8))))
01917d
+		     - 1];
01917d
   CORE_ADDR target;
01917d
 
01917d
-  if (ppc_insns_match_pattern (frame, pc, ppc64_standard_linkage7, insns))
01917d
+  if (ppc_insns_match_pattern (frame, pc, ppc64_standard_linkage8, insns))
01917d
+    pc = ppc64_standard_linkage4_target (frame, pc, insns);
01917d
+  else if (ppc_insns_match_pattern (frame, pc, ppc64_standard_linkage7, insns))
01917d
     pc = ppc64_standard_linkage3_target (frame, pc, insns);
01917d
   else if (ppc_insns_match_pattern (frame, pc, ppc64_standard_linkage6, insns))
01917d
     pc = ppc64_standard_linkage4_target (frame, pc, insns);