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

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