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

01917d
commit 00f412ee52ff042dd349118443ef289175669b7d
01917d
Author: Alan Modra <amodra@gmail.com>
01917d
Date:   Tue Dec 3 17:48:31 2013 +1030
01917d
01917d
    More PowerPC64 ELFv2 --just-symbols fixes
01917d
    
01917d
    I don't know what I was thinking here to omit the save of r2.
01917d
    Possibly I was looking at -msave-toc-indirect code at the time, where
01917d
    r2 is saved in the function prologue.
01917d
    
01917d
    	* elf64-ppc.c (ppc_build_one_stub <ppc_stub_plt_branch_r2off>):
01917d
    	Don't omit saving of r2 for ELFv2.  Don't addi 2,2,0.
01917d
    	(ppc_size_one_stub <ppc_stub_plt_branch_r2off>): Adjust to suit.
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
@@ -10392,8 +10392,7 @@ ppc_build_one_stub (struct bfd_hash_entr
01917d
 	  r[0].r_offset = loc - stub_entry->stub_sec->contents;
01917d
 	  if (bfd_big_endian (info->output_bfd))
01917d
 	    r[0].r_offset += 2;
01917d
-	  if (stub_entry->stub_type == ppc_stub_plt_branch_r2off
01917d
-	      && htab->opd_abi)
01917d
+	  if (stub_entry->stub_type == ppc_stub_plt_branch_r2off)
01917d
 	    r[0].r_offset += 4;
01917d
 	  r[0].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_DS);
01917d
 	  r[0].r_addend = dest;
01917d
@@ -10406,8 +10405,7 @@ ppc_build_one_stub (struct bfd_hash_entr
01917d
 	    }
01917d
 	}
01917d
 
01917d
-      if (stub_entry->stub_type != ppc_stub_plt_branch_r2off
01917d
-	  || !htab->opd_abi)
01917d
+      if (stub_entry->stub_type != ppc_stub_plt_branch_r2off)
01917d
 	{
01917d
 	  if (PPC_HA (off) != 0)
01917d
 	    {
01917d
@@ -10426,7 +10424,7 @@ ppc_build_one_stub (struct bfd_hash_entr
01917d
 	{
01917d
 	  bfd_vma r2off = get_r2off (info, stub_entry);
01917d
 
01917d
-	  if (r2off == 0)
01917d
+	  if (r2off == 0 && htab->opd_abi)
01917d
 	    {
01917d
 	      htab->stub_error = TRUE;
01917d
 	      return FALSE;
01917d
@@ -10434,28 +10432,29 @@ ppc_build_one_stub (struct bfd_hash_entr
01917d
 
01917d
 	  bfd_put_32 (htab->stub_bfd, STD_R2_0R1 + STK_TOC (htab), loc);
01917d
 	  loc += 4;
01917d
-	  size = 20;
01917d
+	  size = 16;
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
 	      loc += 4;
01917d
 	      bfd_put_32 (htab->stub_bfd, LD_R12_0R11 | PPC_LO (off), loc);
01917d
-	      loc += 4;
01917d
 	    }
01917d
 	  else
01917d
-	    {
01917d
-	      bfd_put_32 (htab->stub_bfd, LD_R12_0R2 | PPC_LO (off), loc);
01917d
-	      loc += 4;
01917d
-	    }
01917d
+	    bfd_put_32 (htab->stub_bfd, LD_R12_0R2 | PPC_LO (off), loc);
01917d
 
01917d
 	  if (PPC_HA (r2off) != 0)
01917d
 	    {
01917d
 	      size += 4;
01917d
+	      loc += 4;
01917d
 	      bfd_put_32 (htab->stub_bfd, ADDIS_R2_R2 | PPC_HA (r2off), loc);
01917d
+	    }
01917d
+	  if (PPC_LO (r2off) != 0)
01917d
+	    {
01917d
+	      size += 4;
01917d
 	      loc += 4;
01917d
+	      bfd_put_32 (htab->stub_bfd, ADDI_R2_R2 | PPC_LO (r2off), loc);
01917d
 	    }
01917d
-	  bfd_put_32 (htab->stub_bfd, ADDI_R2_R2 | PPC_LO (r2off), loc);
01917d
 	}
01917d
       loc += 4;
01917d
       bfd_put_32 (htab->stub_bfd, MTCTR_R12, loc);
01917d
@@ -10749,8 +10748,7 @@ ppc_size_one_stub (struct bfd_hash_entry
01917d
 	      stub_entry->stub_sec->flags |= SEC_RELOC;
01917d
 	    }
01917d
 
01917d
-	  if (stub_entry->stub_type != ppc_stub_plt_branch_r2off
01917d
-	      || !htab->opd_abi)
01917d
+	  if (stub_entry->stub_type != ppc_stub_plt_branch_r2off)
01917d
 	    {
01917d
 	      size = 12;
01917d
 	      if (PPC_HA (off) != 0)
01917d
@@ -10758,12 +10756,14 @@ ppc_size_one_stub (struct bfd_hash_entry
01917d
 	    }
01917d
 	  else
01917d
 	    {
01917d
-	      size = 20;
01917d
+	      size = 16;
01917d
 	      if (PPC_HA (off) != 0)
01917d
 		size += 4;
01917d
 
01917d
 	      if (PPC_HA (r2off) != 0)
01917d
 		size += 4;
01917d
+	      if (PPC_LO (r2off) != 0)
01917d
+		size += 4;
01917d
 	    }
01917d
 	}
01917d
       else if (info->emitrelocations)