Blame SOURCES/binutils-2.27-ppc64-discarded-plt-sections.patch

be6651
diff -rup binutils.orig/bfd/elf64-ppc.c binutils-2.27/bfd/elf64-ppc.c
be6651
--- binutils.orig/bfd/elf64-ppc.c	2017-11-16 10:35:34.873666405 +0000
be6651
+++ binutils-2.27/bfd/elf64-ppc.c	2017-11-16 10:39:54.037530964 +0000
be6651
@@ -10105,6 +10105,10 @@ ppc64_elf_size_dynamic_sections (bfd *ou
6439d5
 	  continue;
6439d5
 	}
6439d5
 
6439d5
+      if (bfd_is_abs_section (s->output_section))
6439d5
+       _bfd_error_handler (_("warning: discarding dynamic section %s"),
6439d5
+                           s->name);
6439d5
+
6439d5
       if ((s->flags & SEC_HAS_CONTENTS) == 0)
6439d5
 	continue;
6439d5
 
be6651
@@ -10875,7 +10879,7 @@ ppc_build_one_stub (struct bfd_hash_entr
6439d5
 	      + htab->brlt->output_section->vma);
6439d5
 
6439d5
       off = (dest
6439d5
-	     - elf_gp (htab->brlt->output_section->owner)
6439d5
+	     - elf_gp (info->output_bfd)
be6651
 	     - htab->sec_info[stub_entry->group->link_sec->id].toc_off);
6439d5
 
6439d5
       if (off + 0x80008000 > 0xffffffff || (off & 7) != 0)
be6651
@@ -11025,7 +11029,7 @@ ppc_build_one_stub (struct bfd_hash_entr
6439d5
 	}
6439d5
 
6439d5
       off = (dest
6439d5
-	     - elf_gp (plt->output_section->owner)
6439d5
+	     - elf_gp (info->output_bfd)
be6651
 	     - htab->sec_info[stub_entry->group->link_sec->id].toc_off);
6439d5
 
6439d5
       if (off + 0x80008000 > 0xffffffff || (off & 7) != 0)
be6651
@@ -11172,7 +11176,7 @@ ppc_size_one_stub (struct bfd_hash_entry
6439d5
 	plt = htab->elf.iplt;
6439d5
       off += (plt->output_offset
6439d5
 	      + plt->output_section->vma
6439d5
-	      - elf_gp (plt->output_section->owner)
6439d5
+	      - elf_gp (info->output_bfd)
be6651
 	      - htab->sec_info[stub_entry->group->link_sec->id].toc_off);
6439d5
 
6439d5
       size = plt_stub_size (htab, stub_entry, off);
be6651
@@ -11266,7 +11270,7 @@ ppc_size_one_stub (struct bfd_hash_entry
6439d5
 	  off = (br_entry->offset
6439d5
 		 + htab->brlt->output_offset
6439d5
 		 + htab->brlt->output_section->vma
6439d5
-		 - elf_gp (htab->brlt->output_section->owner)
6439d5
+		 - elf_gp (info->output_bfd)
be6651
 		 - htab->sec_info[stub_entry->group->link_sec->id].toc_off);
6439d5
 
6439d5
 	  if (info->emitrelocations)
be6651
@@ -11386,7 +11390,7 @@ ppc64_elf_next_toc_section (struct bfd_l
6439d5
 	 output toc base plus 0x8000.  Making the input elf_gp an
6439d5
 	 offset allows us to move the toc as a whole without
6439d5
 	 recalculating input elf_gp.  */
6439d5
-      off = htab->toc_curr - elf_gp (isec->output_section->owner);
6439d5
+      off = htab->toc_curr - elf_gp (info->output_bfd);
6439d5
       off += TOC_BASE_OFF;
6439d5
 
6439d5
       /* Die if someone uses a linker script that doesn't keep input
be6651
@@ -11415,7 +11419,7 @@ ppc64_elf_next_toc_section (struct bfd_l
6439d5
     }
6439d5
   addr = (htab->toc_first_sec->output_offset
6439d5
 	  + htab->toc_first_sec->output_section->vma);
6439d5
-  off = addr - elf_gp (isec->output_section->owner) + TOC_BASE_OFF;
6439d5
+  off = addr - elf_gp (info->output_bfd) + TOC_BASE_OFF;
6439d5
   elf_gp (isec->owner) = off;
6439d5
 
6439d5
   return TRUE;
be6651
diff -rup binutils.orig/ld/testsuite/ld-elf/note-3.t binutils-2.27/ld/testsuite/ld-elf/note-3.t
be6651
--- binutils.orig/ld/testsuite/ld-elf/note-3.t	2017-11-16 10:35:35.670656893 +0000
be6651
+++ binutils-2.27/ld/testsuite/ld-elf/note-3.t	2017-11-16 10:59:06.352286215 +0000
6439d5
@@ -17,6 +17,7 @@ SECTIONS
6439d5
   
6439d5
   .dynstr : { *(.dynstr) }
6439d5
   .dynsym : { *(.dynsym) }
6439d5
+  .got : { *(.got .toc) *(.igot) }
6439d5
   .got.plt : { *(.got.plt) *(.igot.plt) }
6439d5
   /DISCARD/ : { *(*) }
6439d5
 }