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

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