[Midnightbsd-cvs] src [11010] trunk/contrib/binutils: sync with freebsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Fri Jun 15 18:29:17 EDT 2018


Revision: 11010
          http://svnweb.midnightbsd.org/src/?rev=11010
Author:   laffer1
Date:     2018-06-15 18:29:16 -0400 (Fri, 15 Jun 2018)
Log Message:
-----------
sync with freebsd

Modified Paths:
--------------
    trunk/contrib/binutils/FREEBSD-Xlist
    trunk/contrib/binutils/FREEBSD-deletelist
    trunk/contrib/binutils/FREEBSD-upgrade
    trunk/contrib/binutils/bfd/ChangeLog
    trunk/contrib/binutils/bfd/bfd-in2.h
    trunk/contrib/binutils/bfd/config.bfd
    trunk/contrib/binutils/bfd/ecoff.c
    trunk/contrib/binutils/bfd/elf-bfd.h
    trunk/contrib/binutils/bfd/elf.c
    trunk/contrib/binutils/bfd/elf32-arm.c
    trunk/contrib/binutils/bfd/elf32-ppc.c
    trunk/contrib/binutils/bfd/elf64-ppc.c
    trunk/contrib/binutils/bfd/freebsd.h
    trunk/contrib/binutils/bfd/ihex.c
    trunk/contrib/binutils/bfd/libbfd.h
    trunk/contrib/binutils/bfd/peXXigen.c
    trunk/contrib/binutils/bfd/reloc.c
    trunk/contrib/binutils/bfd/section.c
    trunk/contrib/binutils/gas/config/atof-ieee.c
    trunk/contrib/binutils/gas/config/tc-arm.c
    trunk/contrib/binutils/gas/config/tc-ia64.c
    trunk/contrib/binutils/gas/config/tc-mips.c
    trunk/contrib/binutils/gas/config/tc-ppc.c
    trunk/contrib/binutils/gas/doc/c-arm.texi
    trunk/contrib/binutils/gas/doc/c-mips.texi
    trunk/contrib/binutils/gas/symbols.c
    trunk/contrib/binutils/include/elf/ChangeLog
    trunk/contrib/binutils/include/elf/arm.h
    trunk/contrib/binutils/include/elf/ppc.h
    trunk/contrib/binutils/include/elf/ppc64.h
    trunk/contrib/binutils/include/libiberty.h
    trunk/contrib/binutils/ld/Makefile.in
    trunk/contrib/binutils/ld/emulparams/elf32ppc_fbsd.sh
    trunk/contrib/binutils/ld/emulparams/elf64ppc_fbsd.sh
    trunk/contrib/binutils/ld/ld.texinfo
    trunk/contrib/binutils/opcodes/i386-dis.c
    trunk/contrib/binutils/opcodes/i386-opc.h
    trunk/contrib/binutils/opcodes/i386-opc.tbl
    trunk/contrib/binutils/opcodes/i386-tbl.h
    trunk/contrib/binutils/opcodes/ia64-asmtab.c
    trunk/contrib/binutils/opcodes/ppc-opc.c

Modified: trunk/contrib/binutils/FREEBSD-Xlist
===================================================================
--- trunk/contrib/binutils/FREEBSD-Xlist	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/FREEBSD-Xlist	2018-06-15 22:29:16 UTC (rev 11010)
@@ -1,4 +1,4 @@
-$FreeBSD: stable/11/contrib/binutils/FREEBSD-Xlist 77357 2001-05-28 17:48:04Z obrien $
+$FreeBSD: stable/10/contrib/binutils/FREEBSD-Xlist 77357 2001-05-28 17:48:04Z obrien $
 .cvsignore
 mkdep
 *-hp*

Modified: trunk/contrib/binutils/FREEBSD-deletelist
===================================================================
--- trunk/contrib/binutils/FREEBSD-deletelist	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/FREEBSD-deletelist	2018-06-15 22:29:16 UTC (rev 11010)
@@ -1,4 +1,4 @@
-$FreeBSD: stable/11/contrib/binutils/FREEBSD-deletelist 91056 2002-02-22 05:11:49Z obrien $
+$FreeBSD: stable/10/contrib/binutils/FREEBSD-deletelist 91056 2002-02-22 05:11:49Z obrien $
 CVS
 testsuite
 .cvsignore

Modified: trunk/contrib/binutils/FREEBSD-upgrade
===================================================================
--- trunk/contrib/binutils/FREEBSD-upgrade	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/FREEBSD-upgrade	2018-06-15 22:29:16 UTC (rev 11010)
@@ -1,4 +1,4 @@
-$FreeBSD: stable/11/contrib/binutils/FREEBSD-upgrade 92216 2002-03-13 07:16:00Z obrien $
+$FreeBSD: stable/10/contrib/binutils/FREEBSD-upgrade 92216 2002-03-13 07:16:00Z obrien $
 
 To get a copy of the Binutils source from the Sourceware CVS repository
 this command line was used:

Modified: trunk/contrib/binutils/bfd/ChangeLog
===================================================================
--- trunk/contrib/binutils/bfd/ChangeLog	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/bfd/ChangeLog	2018-06-15 22:29:16 UTC (rev 11010)
@@ -1,49 +1,3 @@
-2009-02-15  Alan Modra  <amodra at bigpond.net.au>
-
-	* elf64-ppc.c (struct _ppc64_elf_section_data): Delete t_symndx,
-	add toc.symndx and toc.add.
-	(ppc64_elf_check_relocs): Don't set htab->tls_get_addr here.
-	Set up toc.add.
-	(get_tls_mask): Add toc_addend param, set from toc.add.  Adjust all
-	callers.
-	(ppc64_elf_tls_setup): Set htab->tls_get_addr and tls_get_addr_fd.
-	(branch_reloc_hash_match): New function, extracted from..
-	(ppc64_elf_tls_optimize): ..here.
-	(ppc64_elf_relocate_section): Properly set addends when optimizing
-	tls sequences.  Avoid unnecessary reading and writing of insns.
-	Only redo reloc when symbol changed.  Bypass symbol checks when
-	using tlsld_got.
-	* elf32-ppc.c (ppc_elf_tls_setup): Correct comment.
-	(branch_reloc_hash_match): New function, extracted from..
-	(ppc_elf_tls_optimize): ..here.
-	(ppc_elf_relocate_section): Avoid unnecessary reading of insns.
-	Don't clear addend on zapped __tls_get_addr reloc.
-
-2008-08-11  Alan Modra  <amodra at bigpond.net.au>
-
-	* elf64-ppc.c (toc_adjusting_stub_needed): Any call via the plt
-	needs r2 valid, not just those to external syms.
-
-2007-11-06  Alan Modra  <amodra at bigpond.net.au>
-
-	* elf32-ppc.c (ppc_elf_check_relocs): Don't refcount tlsld_got here..
-	(ppc_elf_gc_sweep_hook): ..or here..
-	(ppc_elf_tls_optimize): ..or here.  Make two passes through the
-	relocs, ensuring that tls_get_addr calls follow gd and ld relocs.
-	(allocate_dynrelocs): Refcount tlsld_got here.
-	(ppc_elf_size_dynamic_sections): Call allocate_dynrelocs before
-	allocating tlsld_got.
-	(ppc_elf_relocate_section): Remove check that a tls_get_addr
-	call follows gd and ld relocs.
-
-2007-08-13  Alan Modra  <amodra at bigpond.net.au>
-
-	* elf64-ppc.c (ADDI_R12_R12, LD_R11_0R2, LD_R2_0R2): Define.
-	Update stub comments.
-	(build_plt_stub): Build two variants, one without "addis".
-	(ppc_build_one_stub): Build stubs without "addis" if possible.
-	(ppc_size_one_stub): Size new stubs.
-
 2007-07-02  Joseph Myers  <joseph at codesourcery.com>
 
 	* elfxx-mips.c (mips_elf_calculate_relocation): Handle

Modified: trunk/contrib/binutils/bfd/bfd-in2.h
===================================================================
--- trunk/contrib/binutils/bfd/bfd-in2.h	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/bfd/bfd-in2.h	2018-06-15 22:29:16 UTC (rev 11010)
@@ -1380,9 +1380,6 @@
   /* Nonzero if this section has TLS related relocations.  */
   unsigned int has_tls_reloc:1;
 
-  /* Nonzero if this section has a call to __tls_get_addr.  */
-  unsigned int has_tls_get_addr_call:1;
-
   /* Nonzero if this section has a gp reloc.  */
   unsigned int has_gp_reloc:1;
 
@@ -1643,11 +1640,11 @@
   /* segment_mark, sec_info_type, use_rela_p, has_tls_reloc,       */  \
      0,            0,             0,          0,                       \
                                                                        \
-  /* has_tls_get_addr_call, has_gp_reloc, need_finalize_relax,     */  \
-     0,                     0,            0,                           \
+  /* has_gp_reloc, need_finalize_relax, reloc_done,                */  \
+     0,            0,                   0,                             \
                                                                        \
-  /* reloc_done, vma, lma, size, rawsize                           */  \
-     0,          0,   0,   0,    0,                                    \
+  /* vma, lma, size, rawsize                                       */  \
+     0,   0,   0,    0,                                                \
                                                                        \
   /* output_offset, output_section,              alignment_power,  */  \
      0,             (struct bfd_section *) &SEC, 0,                    \
@@ -2899,8 +2896,6 @@
 
 /* PowerPC and PowerPC64 thread-local storage relocations.  */
   BFD_RELOC_PPC_TLS,
-  BFD_RELOC_PPC_TLSGD,
-  BFD_RELOC_PPC_TLSLD,
   BFD_RELOC_PPC_DTPMOD,
   BFD_RELOC_PPC_TPREL16,
   BFD_RELOC_PPC_TPREL16_LO,

Modified: trunk/contrib/binutils/bfd/config.bfd
===================================================================
--- trunk/contrib/binutils/bfd/config.bfd	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/bfd/config.bfd	2018-06-15 22:29:16 UTC (rev 11010)
@@ -273,11 +273,19 @@
     targ_defvec=bfd_elf32_littlearm_vec
     targ_selvecs=bfd_elf32_bigarm_vec
     ;;
-  arm*eb*-*-freebsd*)
+  armeb-*-freebsd*)
     targ_defvec=bfd_elf32_bigarm_vec
     targ_selvecs=bfd_elf32_littlearm_vec
     ;;
-  arm-*-elf | arm*-*-freebsd* | arm*-*-linux-* | arm*-*-conix* | \
+  armv6eb-*-freebsd*)
+    targ_defvec=bfd_elf32_bigarm_vec
+    targ_selvecs=bfd_elf32_littlearm_vec
+    ;;
+  armv6-*-freebsd*)
+    targ_defvec=bfd_elf32_littlearm_vec
+    targ_selvecs=bfd_elf32_bigarm_vec
+    ;;
+  arm-*-elf | arm-*-freebsd* | arm*-*-linux-* | arm*-*-conix* | \
   arm*-*-uclinux* | arm-*-kfreebsd*-gnu | \
   arm*-*-eabi* )
     targ_defvec=bfd_elf32_littlearm_vec

Modified: trunk/contrib/binutils/bfd/ecoff.c
===================================================================
--- trunk/contrib/binutils/bfd/ecoff.c	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/bfd/ecoff.c	2018-06-15 22:29:16 UTC (rev 11010)
@@ -58,10 +58,10 @@
      0,           0,                1,       0,
   /* segment_mark, sec_info_type, use_rela_p, has_tls_reloc,       */
      0,            0,             0,          0,
-  /* has_tls_get_addr_call, has_gp_reloc, need_finalize_relax,     */
-     0,	                    0,            0,
-  /* reloc_done, vma, lma, size, rawsize,                          */
-     0,          0,   0,   0,    0,
+  /* has_gp_reloc, need_finalize_relax, reloc_done,                */
+     0,            0,                   0,
+  /* vma, lma, size, rawsize,                                      */
+     0,   0,   0,    0,
   /* output_offset, output_section, alignment_power,               */
      0,             NULL,           0,
   /* relocation, orelocation, reloc_count, filepos, rel_filepos,   */

Modified: trunk/contrib/binutils/bfd/elf-bfd.h
===================================================================
--- trunk/contrib/binutils/bfd/elf-bfd.h	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/bfd/elf-bfd.h	2018-06-15 22:29:16 UTC (rev 11010)
@@ -1286,7 +1286,7 @@
 };
 
 /* The maximum number of known object attributes for any target.  */
-#define NUM_KNOWN_OBJ_ATTRIBUTES 71
+#define NUM_KNOWN_OBJ_ATTRIBUTES 32
 
 /* The value of an object attribute.  type & 1 indicates whether there
    is an integer value; type & 2 indicates whether there is a string

Modified: trunk/contrib/binutils/bfd/elf.c
===================================================================
--- trunk/contrib/binutils/bfd/elf.c	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/bfd/elf.c	2018-06-15 22:29:16 UTC (rev 11010)
@@ -20,7 +20,7 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
 
 
-/* $FreeBSD: stable/11/contrib/binutils/bfd/elf.c 295901 2016-02-22 22:16:32Z dim $ */
+/* $FreeBSD: stable/10/contrib/binutils/bfd/elf.c 296437 2016-03-07 07:49:01Z dim $ */
 
 
 /*

Modified: trunk/contrib/binutils/bfd/elf32-arm.c
===================================================================
--- trunk/contrib/binutils/bfd/elf32-arm.c	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/bfd/elf32-arm.c	2018-06-15 22:29:16 UTC (rev 11010)
@@ -59,6 +59,13 @@
 #define elf_info_to_howto               0
 #define elf_info_to_howto_rel           elf32_arm_info_to_howto
 
+#define ARM_ELF_ABI_VERSION		0
+#ifdef __FreeBSD__
+#define ARM_ELF_OS_ABI_VERSION		ELFOSABI_FREEBSD
+#else
+#define ARM_ELF_OS_ABI_VERSION		ELFOSABI_ARM
+#endif
+
 static struct elf_backend_data elf32_arm_vxworks_bed;
 
 /* Note: code such as elf32_arm_reloc_type_lookup expect to use e.g.
@@ -5793,7 +5800,7 @@
 	if (globals->use_rel)
 	  {
 	    addend = ((insn >> 4) & 0xf000) | (insn & 0xfff);
-	    signed_addend = (addend ^ 0x8000) - 0x8000;
+	    signed_addend = (addend ^ 0x10000) - 0x10000;
 	  }
 
 	value += signed_addend;
@@ -6787,22 +6794,9 @@
 	out_attr[Tag_ABI_VFP_args].i = in_attr[Tag_ABI_VFP_args].i;
       else if (in_attr[Tag_ABI_FP_number_model].i != 0)
 	{
-	  bfd *hasbfd, *hasnotbfd;
-	  
-	  if (in_attr[Tag_ABI_VFP_args].i)
-	    {
-	      hasbfd = ibfd;
-	      hasnotbfd = obfd;
-	    }
-	  else
-	    {
-	      hasbfd = obfd;
-	      hasnotbfd = ibfd;
-	    }
-
 	  _bfd_error_handler
 	    (_("ERROR: %B uses VFP register arguments, %B does not"),
-		hasbfd, hasnotbfd);
+	     ibfd, obfd);
 	  return FALSE;
 	}
     }
@@ -6809,9 +6803,6 @@
 
   for (i = 4; i < NUM_KNOWN_OBJ_ATTRIBUTES; i++)
     {
-      if (out_attr[i].type == 0)
-        out_attr[i].type = in_attr[i].type;
-
       /* Merge this attribute with existing attributes.  */
       switch (i)
 	{
@@ -6844,8 +6835,6 @@
 	case Tag_ABI_FP_number_model:
 	case Tag_ABI_align8_preserved:
 	case Tag_ABI_HardFP_use:
-	case Tag_CPU_unaligned_access:
-	case Tag_FP_HP_extension:
 	  /* Use the largest value specified.  */
 	  if (in_attr[i].i > out_attr[i].i)
 	    out_attr[i].i = in_attr[i].i;
@@ -6962,9 +6951,7 @@
 	    }
 	  break;
 	default: /* All known attributes should be explicitly covered.   */
-	  /* XXX Not now */
-	  /* abort (); */
-	  break;
+	  abort ();
 	}
     }
 
@@ -6978,8 +6965,7 @@
 
   for (; in_list; in_list = in_list->next)
     {
-      if ((in_list->tag & 128) < 64
-          && in_list->tag != Tag_Virtualization_use)
+      if ((in_list->tag & 128) < 64)
 	{
 	  _bfd_error_handler
 	    (_("Warning: %B: Unknown EABI object attribute %d"),
@@ -7713,26 +7699,12 @@
 		   refers to is in a different object.  We can't tell for
 		   sure yet, because something later might force the
 		   symbol local.  */
-		switch (r_type)
-		  {
-		    case R_ARM_ABS12:
-		    case R_ARM_ABS32:
-		    case R_ARM_ABS32_NOI:
-		    case R_ARM_REL32:
-		    case R_ARM_REL32_NOI:
-		    case R_ARM_MOVW_ABS_NC:
-		    case R_ARM_MOVT_ABS:
-		    case R_ARM_MOVW_PREL_NC:
-		    case R_ARM_MOVT_PREL:
-		    case R_ARM_THM_MOVW_ABS_NC:
-		    case R_ARM_THM_MOVT_ABS:
-		    case R_ARM_THM_MOVW_PREL_NC:
-		    case R_ARM_THM_MOVT_PREL:
-		      break;
-		    default:
-		      h->needs_plt = 1;
-		      break;
-		  }
+		if (r_type != R_ARM_ABS32
+                    && r_type != R_ARM_REL32
+                    && r_type != R_ARM_ABS32_NOI
+                    && r_type != R_ARM_REL32_NOI
+                    && r_type != R_ARM_ABS12)
+		  h->needs_plt = 1;
 
 		/* If we create a PLT entry, this relocation will reference
 		   it, even if it's an ABS32 relocation.  */
@@ -9370,8 +9342,11 @@
 
   i_ehdrp = elf_elfheader (abfd);
 
-  i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
-  i_ehdrp->e_ident[EI_ABIVERSION] = 0;
+  if (EF_ARM_EABI_VERSION (i_ehdrp->e_flags) == EF_ARM_EABI_UNKNOWN)
+    i_ehdrp->e_ident[EI_OSABI] = ARM_ELF_OS_ABI_VERSION;
+  else
+    i_ehdrp->e_ident[EI_OSABI] = 0;
+  i_ehdrp->e_ident[EI_ABIVERSION] = ARM_ELF_ABI_VERSION;
 
   if (link_info)
     {
@@ -9379,16 +9354,6 @@
       if (globals->byteswap_code)
 	i_ehdrp->e_flags |= EF_ARM_BE8;
     }
-
-  /*
-   * For EABI 5, we have to tag dynamic binaries and execs as either
-   * soft float or hard float.
-   */
-  if (EF_ARM_EABI_VERSION (i_ehdrp->e_flags) == EF_ARM_EABI_VER5 &&
-      (i_ehdrp->e_type == ET_DYN || i_ehdrp->e_type == ET_EXEC))
-    i_ehdrp->e_flags |=
-      bfd_elf_get_obj_attr_int (abfd, OBJ_ATTR_PROC, Tag_ABI_VFP_args) ?
-      EF_ARM_VFP_FLOAT : EF_ARM_SOFT_FLOAT;
 }
 
 static enum elf_reloc_type_class

Modified: trunk/contrib/binutils/bfd/elf32-ppc.c
===================================================================
--- trunk/contrib/binutils/bfd/elf32-ppc.c	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/bfd/elf32-ppc.c	2018-06-15 22:29:16 UTC (rev 11010)
@@ -746,7 +746,7 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Marker relocs for TLS.  */
+  /* Marker reloc for TLS.  */
   HOWTO (R_PPC_TLS,
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -761,34 +761,6 @@
 	 0,			/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  HOWTO (R_PPC_TLSGD,
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 32,			/* bitsize */
-	 FALSE,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc, /* special_function */
-	 "R_PPC_TLSGD",		/* name */
-	 FALSE,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0,			/* dst_mask */
-	 FALSE),		/* pcrel_offset */
-
-  HOWTO (R_PPC_TLSLD,
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 32,			/* bitsize */
-	 FALSE,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc, /* special_function */
-	 "R_PPC_TLSLD",		/* name */
-	 FALSE,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0,			/* dst_mask */
-	 FALSE),		/* pcrel_offset */
-
   /* Computes the load module index of the load module that contains the
      definition of its TLS sym.  */
   HOWTO (R_PPC_DTPMOD32,
@@ -1552,8 +1524,6 @@
     case BFD_RELOC_CTOR:		r = R_PPC_ADDR32;		break;
     case BFD_RELOC_PPC_TOC16:		r = R_PPC_TOC16;		break;
     case BFD_RELOC_PPC_TLS:		r = R_PPC_TLS;			break;
-    case BFD_RELOC_PPC_TLSGD:		r = R_PPC_TLSGD;		break;
-    case BFD_RELOC_PPC_TLSLD:		r = R_PPC_TLSLD;		break;
     case BFD_RELOC_PPC_DTPMOD:		r = R_PPC_DTPMOD32;		break;
     case BFD_RELOC_PPC_TPREL16:		r = R_PPC_TPREL16;		break;
     case BFD_RELOC_PPC_TPREL16_LO:	r = R_PPC_TPREL16_LO;		break;
@@ -2375,35 +2345,17 @@
   bfd_vma glink_offset;
 };
 
-/* Of those relocs that might be copied as dynamic relocs, this function
+/* Of those relocs that might be copied as dynamic relocs, this macro
    selects those that must be copied when linking a shared library,
    even when the symbol is local.  */
 
-static int
-must_be_dyn_reloc (struct bfd_link_info *info,
-		   enum elf_ppc_reloc_type r_type)
-{
-  switch (r_type)
-    {
-    default:
-      return 1;
+#define MUST_BE_DYN_RELOC(RTYPE)		\
+  ((RTYPE) != R_PPC_REL24			\
+   && (RTYPE) != R_PPC_REL14			\
+   && (RTYPE) != R_PPC_REL14_BRTAKEN		\
+   && (RTYPE) != R_PPC_REL14_BRNTAKEN		\
+   && (RTYPE) != R_PPC_REL32)
 
-    case R_PPC_REL24:
-    case R_PPC_REL14:
-    case R_PPC_REL14_BRTAKEN:
-    case R_PPC_REL14_BRNTAKEN:
-    case R_PPC_REL32:
-      return 0;
-
-    case R_PPC_TPREL32:
-    case R_PPC_TPREL16:
-    case R_PPC_TPREL16_LO:
-    case R_PPC_TPREL16_HI:
-    case R_PPC_TPREL16_HA:
-      return !info->executable;
-    }
-}
-
 /* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid
    copying dynamic variables from a shared lib into an app's dynbss
    section, and instead use a dynamic relocation to point into the
@@ -2469,7 +2421,7 @@
   /* The .got.plt section (VxWorks only)*/
   asection *sgotplt;
 
-  /* Shortcut to __tls_get_addr.  */
+  /* Shortcut to .__tls_get_addr.  */
   struct elf_link_hash_entry *tls_get_addr;
 
   /* The bfd that forced an old-style PLT.  */
@@ -3088,7 +3040,6 @@
   const Elf_Internal_Rela *rel;
   const Elf_Internal_Rela *rel_end;
   asection *got2, *sreloc;
-  struct elf_link_hash_entry *tga;
 
   if (info->relocatable)
     return TRUE;
@@ -3112,8 +3063,6 @@
     ppc_elf_howto_init ();
 
   htab = ppc_elf_hash_table (info);
-  tga = elf_link_hash_lookup (&htab->elf, "__tls_get_addr",
-			      FALSE, FALSE, TRUE);
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
   got2 = bfd_get_section_by_name (abfd, ".got2");
@@ -3125,7 +3074,7 @@
       unsigned long r_symndx;
       enum elf_ppc_reloc_type r_type;
       struct elf_link_hash_entry *h;
-      int tls_type;
+      int tls_type = 0;
 
       r_symndx = ELF32_R_SYM (rel->r_info);
       if (r_symndx < symtab_hdr->sh_info)
@@ -3152,48 +3101,14 @@
 	  BFD_ASSERT (h == htab->elf.hgot);
 	}
 
-      tls_type = 0;
       r_type = ELF32_R_TYPE (rel->r_info);
-      if (h != NULL && h == tga)
-	switch (r_type)
-	  {
-	  default:
-	    break;
-
-	  case R_PPC_PLTREL24:
-	  case R_PPC_LOCAL24PC:
-	  case R_PPC_REL24:
-	  case R_PPC_REL14:
-	  case R_PPC_REL14_BRTAKEN:
-	  case R_PPC_REL14_BRNTAKEN:
-	  case R_PPC_ADDR24:
-	  case R_PPC_ADDR14:
-	  case R_PPC_ADDR14_BRTAKEN:
-	  case R_PPC_ADDR14_BRNTAKEN:
-	    if (rel != relocs
-		&& (ELF32_R_TYPE (rel[-1].r_info) == R_PPC_TLSGD
-		    || ELF32_R_TYPE (rel[-1].r_info) == R_PPC_TLSLD))
-	      /* We have a new-style __tls_get_addr call with a marker
-		 reloc.  */
-	      ;
-	    else
-	      /* Mark this section as having an old-style call.  */
-	      sec->has_tls_get_addr_call = 1;
-	    break;
-	  }
-
       switch (r_type)
 	{
-	case R_PPC_TLSGD:
-	case R_PPC_TLSLD:
-	  /* These special tls relocs tie a call to __tls_get_addr with
-	     its parameter symbol.  */
-	  break;
-
 	case R_PPC_GOT_TLSLD16:
 	case R_PPC_GOT_TLSLD16_LO:
 	case R_PPC_GOT_TLSLD16_HI:
 	case R_PPC_GOT_TLSLD16_HA:
+	  htab->tlsld_got.refcount += 1;
 	  tls_type = TLS_TLS | TLS_LD;
 	  goto dogottls;
 
@@ -3208,7 +3123,7 @@
 	case R_PPC_GOT_TPREL16_LO:
 	case R_PPC_GOT_TPREL16_HI:
 	case R_PPC_GOT_TPREL16_HA:
-	  if (!info->executable)
+	  if (info->shared)
 	    info->flags |= DF_STATIC_TLS;
 	  tls_type = TLS_TLS | TLS_TPREL;
 	  goto dogottls;
@@ -3443,7 +3358,7 @@
 
 	  /* This refers only to functions defined in the shared library.  */
 	case R_PPC_LOCAL24PC:
-	  if (h != NULL && h == htab->elf.hgot && htab->plt_type == PLT_UNSET)
+	  if (h && h == htab->elf.hgot && htab->plt_type == PLT_UNSET)
 	    {
 	      htab->plt_type = PLT_OLD;
 	      htab->old_bfd = abfd;
@@ -3466,11 +3381,7 @@
 
 	  /* We shouldn't really be seeing these.  */
 	case R_PPC_TPREL32:
-	case R_PPC_TPREL16:
-	case R_PPC_TPREL16_LO:
-	case R_PPC_TPREL16_HI:
-	case R_PPC_TPREL16_HA:
-	  if (!info->executable)
+	  if (info->shared)
 	    info->flags |= DF_STATIC_TLS;
 	  goto dodyn;
 
@@ -3479,6 +3390,14 @@
 	case R_PPC_DTPREL32:
 	  goto dodyn;
 
+	case R_PPC_TPREL16:
+	case R_PPC_TPREL16_LO:
+	case R_PPC_TPREL16_HI:
+	case R_PPC_TPREL16_HA:
+	  if (info->shared)
+	    info->flags |= DF_STATIC_TLS;
+	  goto dodyn;
+
 	case R_PPC_REL32:
 	  if (h == NULL
 	      && got2 != NULL
@@ -3569,7 +3488,7 @@
 	     dynamic library if we manage to avoid copy relocs for the
 	     symbol.  */
 	  if ((info->shared
-	       && (must_be_dyn_reloc (info, r_type)
+	       && (MUST_BE_DYN_RELOC (r_type)
 		   || (h != NULL
 		       && (! info->symbolic
 			   || h->root.type == bfd_link_hash_defweak
@@ -3664,7 +3583,7 @@
 		}
 
 	      p->count += 1;
-	      if (!must_be_dyn_reloc (info, r_type))
+	      if (!MUST_BE_DYN_RELOC (r_type))
 		p->pc_count += 1;
 	    }
 
@@ -3984,6 +3903,9 @@
 	case R_PPC_GOT_TLSLD16_LO:
 	case R_PPC_GOT_TLSLD16_HI:
 	case R_PPC_GOT_TLSLD16_HA:
+	  htab->tlsld_got.refcount -= 1;
+	  /* Fall thru */
+
 	case R_PPC_GOT_TLSGD16:
 	case R_PPC_GOT_TLSGD16_LO:
 	case R_PPC_GOT_TLSGD16_HI:
@@ -4057,8 +3979,7 @@
   return TRUE;
 }
 

-/* Set plt output section type, htab->tls_get_addr, and call the
-   generic ELF tls_setup function.  */
+/* Set htab->tls_get_addr and call the generic ELF tls_setup function.  */
 
 asection *
 ppc_elf_tls_setup (bfd *obfd, struct bfd_link_info *info)
@@ -4079,43 +4000,6 @@
   return _bfd_elf_tls_setup (obfd, info);
 }
 
-/* Return TRUE iff REL is a branch reloc with a global symbol matching
-   HASH.  */
-
-static bfd_boolean
-branch_reloc_hash_match (const bfd *ibfd,
-			 const Elf_Internal_Rela *rel,
-			 const struct elf_link_hash_entry *hash)
-{
-  Elf_Internal_Shdr *symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
-  enum elf_ppc_reloc_type r_type = ELF32_R_TYPE (rel->r_info);
-  unsigned int r_symndx = ELF32_R_SYM (rel->r_info);
-
-  if (r_symndx >= symtab_hdr->sh_info
-      && (r_type == R_PPC_PLTREL24
-	  || r_type == R_PPC_LOCAL24PC
-	  || r_type == R_PPC_REL14
-	  || r_type == R_PPC_REL14_BRTAKEN
-	  || r_type == R_PPC_REL14_BRNTAKEN
-	  || r_type == R_PPC_REL24
-	  || r_type == R_PPC_ADDR24
-	  || r_type == R_PPC_ADDR14
-	  || r_type == R_PPC_ADDR14_BRTAKEN
-	  || r_type == R_PPC_ADDR14_BRNTAKEN))
-    {
-      struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (ibfd);
-      struct elf_link_hash_entry *h;
-
-      h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-      while (h->root.type == bfd_link_hash_indirect
-	     || h->root.type == bfd_link_hash_warning)
-	h = (struct elf_link_hash_entry *) h->root.u.i.link;
-      if (h == hash)
-	return TRUE;
-    }
-  return FALSE;
-}
-
 /* Run through all the TLS relocs looking for optimization
    opportunities.  */
 
@@ -4126,204 +4010,187 @@
   bfd *ibfd;
   asection *sec;
   struct ppc_elf_link_hash_table *htab;
-  int pass;
 
-  if (info->relocatable || !info->executable)
+  if (info->relocatable || info->shared)
     return TRUE;
 
   htab = ppc_elf_hash_table (info);
-  /* Make two passes through the relocs.  First time check that tls
-     relocs involved in setting up a tls_get_addr call are indeed
-     followed by such a call.  If they are not, exclude them from
-     the optimizations done on the second pass.  */
-  for (pass = 0; pass < 2; ++pass)
-    for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
-      {
-	Elf_Internal_Sym *locsyms = NULL;
-	Elf_Internal_Shdr *symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+  for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+    {
+      Elf_Internal_Sym *locsyms = NULL;
+      Elf_Internal_Shdr *symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
 
-	for (sec = ibfd->sections; sec != NULL; sec = sec->next)
-	  if (sec->has_tls_reloc && !bfd_is_abs_section (sec->output_section))
-	    {
-	      Elf_Internal_Rela *relstart, *rel, *relend;
+      for (sec = ibfd->sections; sec != NULL; sec = sec->next)
+	if (sec->has_tls_reloc && !bfd_is_abs_section (sec->output_section))
+	  {
+	    Elf_Internal_Rela *relstart, *rel, *relend;
+	    int expecting_tls_get_addr;
 
-	      /* Read the relocations.  */
-	      relstart = _bfd_elf_link_read_relocs (ibfd, sec, NULL, NULL,
-						    info->keep_memory);
-	      if (relstart == NULL)
-		return FALSE;
+	    /* Read the relocations.  */
+	    relstart = _bfd_elf_link_read_relocs (ibfd, sec, NULL, NULL,
+						  info->keep_memory);
+	    if (relstart == NULL)
+	      return FALSE;
 
-	      relend = relstart + sec->reloc_count;
-	      for (rel = relstart; rel < relend; rel++)
-		{
-		  enum elf_ppc_reloc_type r_type;
-		  unsigned long r_symndx;
-		  struct elf_link_hash_entry *h = NULL;
-		  char *tls_mask;
-		  char tls_set, tls_clear;
-		  bfd_boolean is_local;
-		  int expecting_tls_get_addr;
-		  bfd_signed_vma *got_count;
+	    expecting_tls_get_addr = 0;
+	    relend = relstart + sec->reloc_count;
+	    for (rel = relstart; rel < relend; rel++)
+	      {
+		enum elf_ppc_reloc_type r_type;
+		unsigned long r_symndx;
+		struct elf_link_hash_entry *h = NULL;
+		char *tls_mask;
+		char tls_set, tls_clear;
+		bfd_boolean is_local;
 
-		  r_symndx = ELF32_R_SYM (rel->r_info);
-		  if (r_symndx >= symtab_hdr->sh_info)
-		    {
-		      struct elf_link_hash_entry **sym_hashes;
+		r_symndx = ELF32_R_SYM (rel->r_info);
+		if (r_symndx >= symtab_hdr->sh_info)
+		  {
+		    struct elf_link_hash_entry **sym_hashes;
 
-		      sym_hashes = elf_sym_hashes (ibfd);
-		      h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-		      while (h->root.type == bfd_link_hash_indirect
-			     || h->root.type == bfd_link_hash_warning)
-			h = (struct elf_link_hash_entry *) h->root.u.i.link;
-		    }
+		    sym_hashes = elf_sym_hashes (ibfd);
+		    h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+		    while (h->root.type == bfd_link_hash_indirect
+			   || h->root.type == bfd_link_hash_warning)
+		      h = (struct elf_link_hash_entry *) h->root.u.i.link;
+		  }
 
-		  expecting_tls_get_addr = 0;
-		  is_local = FALSE;
-		  if (h == NULL
-		      || !h->def_dynamic)
-		    is_local = TRUE;
+		is_local = FALSE;
+		if (h == NULL
+		    || !h->def_dynamic)
+		  is_local = TRUE;
 
-		  r_type = ELF32_R_TYPE (rel->r_info);
-		  switch (r_type)
-		    {
-		    case R_PPC_GOT_TLSLD16:
-		    case R_PPC_GOT_TLSLD16_LO:
-		      expecting_tls_get_addr = 1;
-		      /* Fall thru */
+		r_type = ELF32_R_TYPE (rel->r_info);
+		switch (r_type)
+		  {
+		  case R_PPC_GOT_TLSLD16:
+		  case R_PPC_GOT_TLSLD16_LO:
+		  case R_PPC_GOT_TLSLD16_HI:
+		  case R_PPC_GOT_TLSLD16_HA:
+		    /* These relocs should never be against a symbol
+		       defined in a shared lib.  Leave them alone if
+		       that turns out to be the case.  */
+		    expecting_tls_get_addr = 0;
+		    htab->tlsld_got.refcount -= 1;
+		    if (!is_local)
+		      continue;
 
-		    case R_PPC_GOT_TLSLD16_HI:
-		    case R_PPC_GOT_TLSLD16_HA:
-		      /* These relocs should never be against a symbol
-			 defined in a shared lib.  Leave them alone if
-			 that turns out to be the case.  */
-		      if (!is_local)
-			continue;
+		    /* LD -> LE */
+		    tls_set = 0;
+		    tls_clear = TLS_LD;
+		    expecting_tls_get_addr = 1;
+		    break;
 
-		      /* LD -> LE */
+		  case R_PPC_GOT_TLSGD16:
+		  case R_PPC_GOT_TLSGD16_LO:
+		  case R_PPC_GOT_TLSGD16_HI:
+		  case R_PPC_GOT_TLSGD16_HA:
+		    if (is_local)
+		      /* GD -> LE */
 		      tls_set = 0;
-		      tls_clear = TLS_LD;
-		      break;
+		    else
+		      /* GD -> IE */
+		      tls_set = TLS_TLS | TLS_TPRELGD;
+		    tls_clear = TLS_GD;
+		    expecting_tls_get_addr = 1;
+		    break;
 
-		    case R_PPC_GOT_TLSGD16:
-		    case R_PPC_GOT_TLSGD16_LO:
-		      expecting_tls_get_addr = 1;
-		      /* Fall thru */
-
-		    case R_PPC_GOT_TLSGD16_HI:
-		    case R_PPC_GOT_TLSGD16_HA:
-		      if (is_local)
-			/* GD -> LE */
+		  case R_PPC_GOT_TPREL16:
+		  case R_PPC_GOT_TPREL16_LO:
+		  case R_PPC_GOT_TPREL16_HI:
+		  case R_PPC_GOT_TPREL16_HA:
+		    expecting_tls_get_addr = 0;
+		    if (is_local)
+		      {
+			/* IE -> LE */
 			tls_set = 0;
-		      else
-			/* GD -> IE */
-			tls_set = TLS_TLS | TLS_TPRELGD;
-		      tls_clear = TLS_GD;
-		      break;
-
-		    case R_PPC_GOT_TPREL16:
-		    case R_PPC_GOT_TPREL16_LO:
-		    case R_PPC_GOT_TPREL16_HI:
-		    case R_PPC_GOT_TPREL16_HA:
-		      if (is_local)
-			{
-			  /* IE -> LE */
-			  tls_set = 0;
-			  tls_clear = TLS_TPREL;
-			  break;
-			}
-		      else
-			continue;
-
-		    default:
+			tls_clear = TLS_TPREL;
+			break;
+		      }
+		    else
 		      continue;
-		    }
 
-		  if (pass == 0)
-		    {
-		      if (!expecting_tls_get_addr
-			  || !sec->has_tls_get_addr_call)
-			continue;
+		  case R_PPC_REL14:
+		  case R_PPC_REL14_BRTAKEN:
+		  case R_PPC_REL14_BRNTAKEN:
+		  case R_PPC_REL24:
+		    if (expecting_tls_get_addr
+			&& h != NULL
+			&& h == htab->tls_get_addr)
+		      {
+			struct plt_entry *ent = find_plt_ent (h, NULL, 0);
+			if (ent != NULL && ent->plt.refcount > 0)
+			  ent->plt.refcount -= 1;
+		      }
+		    expecting_tls_get_addr = 0;
+		    continue;
 
-		      if (rel + 1 < relend
-			  && branch_reloc_hash_match (ibfd, rel + 1,
-						      htab->tls_get_addr))
-			continue;
+		  default:
+		    expecting_tls_get_addr = 0;
+		    continue;
+		  }
 
-		      /* Uh oh, we didn't find the expected call.  We
-			 could just mark this symbol to exclude it
-			 from tls optimization but it's safer to skip
-			 the entire section.  */
-		      sec->has_tls_reloc = 0;
-		      break;
-		    }
+		if (h != NULL)
+		  {
+		    if (tls_set == 0)
+		      {
+			/* We managed to get rid of a got entry.  */
+			if (h->got.refcount > 0)
+			  h->got.refcount -= 1;
+		      }
+		    tls_mask = &ppc_elf_hash_entry (h)->tls_mask;
+		  }
+		else
+		  {
+		    Elf_Internal_Sym *sym;
+		    bfd_signed_vma *lgot_refs;
+		    char *lgot_masks;
 
-		  if (h != NULL)
-		    {
-		      tls_mask = &ppc_elf_hash_entry (h)->tls_mask;
-		      got_count = &h->got.refcount;
-		    }
-		  else
-		    {
-		      Elf_Internal_Sym *sym;
-		      bfd_signed_vma *lgot_refs;
-		      char *lgot_masks;
+		    if (locsyms == NULL)
+		      {
+			locsyms = (Elf_Internal_Sym *) symtab_hdr->contents;
+			if (locsyms == NULL)
+			  locsyms = bfd_elf_get_elf_syms (ibfd, symtab_hdr,
+							  symtab_hdr->sh_info,
+							  0, NULL, NULL, NULL);
+			if (locsyms == NULL)
+			  {
+			    if (elf_section_data (sec)->relocs != relstart)
+			      free (relstart);
+			    return FALSE;
+			  }
+		      }
+		    sym = locsyms + r_symndx;
+		    lgot_refs = elf_local_got_refcounts (ibfd);
+		    if (lgot_refs == NULL)
+		      abort ();
+		    if (tls_set == 0)
+		      {
+			/* We managed to get rid of a got entry.  */
+			if (lgot_refs[r_symndx] > 0)
+			  lgot_refs[r_symndx] -= 1;
+		      }
+		    lgot_masks = (char *) (lgot_refs + symtab_hdr->sh_info);
+		    tls_mask = &lgot_masks[r_symndx];
+		  }
 
-		      if (locsyms == NULL)
-			{
-			  locsyms = (Elf_Internal_Sym *) symtab_hdr->contents;
-			  if (locsyms == NULL)
-			    locsyms = bfd_elf_get_elf_syms (ibfd, symtab_hdr,
-							    symtab_hdr->sh_info,
-							    0, NULL, NULL, NULL);
-			  if (locsyms == NULL)
-			    {
-			      if (elf_section_data (sec)->relocs != relstart)
-				free (relstart);
-			      return FALSE;
-			    }
-			}
-		      sym = locsyms + r_symndx;
-		      lgot_refs = elf_local_got_refcounts (ibfd);
-		      if (lgot_refs == NULL)
-			abort ();
-		      lgot_masks = (char *) (lgot_refs + symtab_hdr->sh_info);
-		      tls_mask = &lgot_masks[r_symndx];
-		      got_count = &lgot_refs[r_symndx];
-		    }
+		*tls_mask |= tls_set;
+		*tls_mask &= ~tls_clear;
+	      }
 
-		  if (tls_set == 0)
-		    {
-		      /* We managed to get rid of a got entry.  */
-		      if (*got_count > 0)
-			*got_count -= 1;
-		    }
+	    if (elf_section_data (sec)->relocs != relstart)
+	      free (relstart);
+	  }
 
-		  if (expecting_tls_get_addr)
-		    {
-		      struct plt_entry *ent;
-
-		      ent = find_plt_ent (htab->tls_get_addr, NULL, 0);
-		      if (ent != NULL && ent->plt.refcount > 0)
-			ent->plt.refcount -= 1;
-		    }
-
-		  *tls_mask |= tls_set;
-		  *tls_mask &= ~tls_clear;
-		}
-
-	      if (elf_section_data (sec)->relocs != relstart)
-		free (relstart);
-	    }
-
-	if (locsyms != NULL
-	    && (symtab_hdr->contents != (unsigned char *) locsyms))
-	  {
-	    if (!info->keep_memory)
-	      free (locsyms);
-	    else
-	      symtab_hdr->contents = (unsigned char *) locsyms;
-	  }
-      }
+      if (locsyms != NULL
+	  && (symtab_hdr->contents != (unsigned char *) locsyms))
+	{
+	  if (!info->keep_memory)
+	    free (locsyms);
+	  else
+	    symtab_hdr->contents = (unsigned char *) locsyms;
+	}
+    }
   return TRUE;
 }
 

@@ -4748,11 +4615,8 @@
 
       if (eh->tls_mask == (TLS_TLS | TLS_LD)
 	  && !eh->elf.def_dynamic)
-	{
-	  /* If just an LD reloc, we'll just use htab->tlsld_got.offset.  */
-	  htab->tlsld_got.refcount += 1;
-	  eh->elf.got.offset = (bfd_vma) -1;
-	}
+	/* If just an LD reloc, we'll just use htab->tlsld_got.offset.  */
+	eh->elf.got.offset = (bfd_vma) -1;
       else
 	{
 	  bfd_boolean dyn;
@@ -4800,7 +4664,7 @@
   if (info->shared)
     {
       /* Relocs that use pc_count are those that appear on a call insn,
-	 or certain REL relocs (see must_be_dyn_reloc) that can be
+	 or certain REL relocs (see MUST_BE_DYN_RELOC) that can be
 	 generated via assembly.  We want calls to protected symbols to
 	 resolve directly to the function rather than going via the plt.
 	 If people want function pointer comparisons to work as expected
@@ -5027,9 +4891,6 @@
 	  *local_got = (bfd_vma) -1;
     }
 
-  /* Allocate space for global sym dynamic relocs.  */
-  elf_link_hash_traverse (elf_hash_table (info), allocate_dynrelocs, info);
-
   if (htab->tlsld_got.refcount > 0)
     {
       htab->tlsld_got.offset = allocate_got (htab, 8);
@@ -5039,6 +4900,9 @@
   else
     htab->tlsld_got.offset = (bfd_vma) -1;
 
+  /* Allocate space for global sym dynamic relocs.  */
+  elf_link_hash_traverse (elf_hash_table (info), allocate_dynrelocs, info);
+
   if (htab->got != NULL && htab->plt_type != PLT_VXWORKS)
     {
       unsigned int g_o_t = 32768;
@@ -5890,13 +5754,16 @@
 	 for the final instruction stream.  */
       tls_mask = 0;
       tls_gd = 0;
-      if (h != NULL)
-	tls_mask = ((struct ppc_elf_link_hash_entry *) h)->tls_mask;
-      else if (local_got_offsets != NULL)
+      if (IS_PPC_TLS_RELOC (r_type))
 	{
-	  char *lgot_masks;
-	  lgot_masks = (char *) (local_got_offsets + symtab_hdr->sh_info);
-	  tls_mask = lgot_masks[r_symndx];
+	  if (h != NULL)
+	    tls_mask = ((struct ppc_elf_link_hash_entry *) h)->tls_mask;
+	  else if (local_got_offsets != NULL)
+	    {
+	      char *lgot_masks;
+	      lgot_masks = (char *) (local_got_offsets + symtab_hdr->sh_info);
+	      tls_mask = lgot_masks[r_symndx];
+	    }
 	}
 
       /* Ensure reloc mapping code below stays sane.  */
@@ -6003,7 +5870,7 @@
 	case R_PPC_GOT_TLSGD16_LO:
 	  tls_gd = TLS_TPRELGD;
 	  if (tls_mask != 0 && (tls_mask & TLS_GD) == 0)
-	    goto tls_ldgd_opt;
+	    goto tls_get_addr_check;
 	  break;
 
 	case R_PPC_GOT_TLSLD16:
@@ -6010,142 +5877,80 @@
 	case R_PPC_GOT_TLSLD16_LO:
 	  if (tls_mask != 0 && (tls_mask & TLS_LD) == 0)
 	    {
-	      unsigned int insn1, insn2;
-	      bfd_vma offset;
+	    tls_get_addr_check:
+	      if (rel + 1 < relend)
+		{
+		  enum elf_ppc_reloc_type r_type2;
+		  unsigned long r_symndx2;
+		  struct elf_link_hash_entry *h2;
+		  bfd_vma insn1, insn2;
+		  bfd_vma offset;
 
-	    tls_ldgd_opt:
-	      offset = (bfd_vma) -1;
-	      /* If not using the newer R_PPC_TLSGD/LD to mark
-		 __tls_get_addr calls, we must trust that the call
-		 stays with its arg setup insns, ie. that the next
-		 reloc is the __tls_get_addr call associated with
-		 the current reloc.  Edit both insns.  */
-	      if (input_section->has_tls_get_addr_call
-		  && rel + 1 < relend
-		  && branch_reloc_hash_match (input_bfd, rel + 1,
-					      htab->tls_get_addr))
-		offset = rel[1].r_offset;
-	      if ((tls_mask & tls_gd) != 0)
-		{
-		  /* IE */
+		  /* The next instruction should be a call to
+		     __tls_get_addr.  Peek at the reloc to be sure.  */
+		  r_type2 = ELF32_R_TYPE (rel[1].r_info);
+		  r_symndx2 = ELF32_R_SYM (rel[1].r_info);
+		  if (r_symndx2 < symtab_hdr->sh_info
+		      || (r_type2 != R_PPC_REL14
+			  && r_type2 != R_PPC_REL14_BRTAKEN
+			  && r_type2 != R_PPC_REL14_BRNTAKEN
+			  && r_type2 != R_PPC_REL24
+			  && r_type2 != R_PPC_PLTREL24))
+		    break;
+
+		  h2 = sym_hashes[r_symndx2 - symtab_hdr->sh_info];
+		  while (h2->root.type == bfd_link_hash_indirect
+			 || h2->root.type == bfd_link_hash_warning)
+		    h2 = (struct elf_link_hash_entry *) h2->root.u.i.link;
+		  if (h2 == NULL || h2 != htab->tls_get_addr)
+		    break;
+
+		  /* OK, it checks out.  Replace the call.  */
+		  offset = rel[1].r_offset;
 		  insn1 = bfd_get_32 (output_bfd,
 				      contents + rel->r_offset - d_offset);
-		  insn1 &= (1 << 26) - 1;
-		  insn1 |= 32 << 26;	/* lwz */
-		  if (offset != (bfd_vma) -1)
+		  if ((tls_mask & tls_gd) != 0)
 		    {
-		      rel[1].r_info
-			= ELF32_R_INFO (ELF32_R_SYM (rel[1].r_info),
-					R_PPC_NONE);
+		      /* IE */
+		      insn1 &= (1 << 26) - 1;
+		      insn1 |= 32 << 26;	/* lwz */
 		      insn2 = 0x7c631214;	/* add 3,3,2 */
-		      bfd_put_32 (output_bfd, insn2, contents + offset);
+		      rel[1].r_info = ELF32_R_INFO (r_symndx2, R_PPC_NONE);
+		      rel[1].r_addend = 0;
+		      r_type = (((r_type - (R_PPC_GOT_TLSGD16 & 3)) & 3)
+				+ R_PPC_GOT_TPREL16);
+		      rel->r_info = ELF32_R_INFO (r_symndx, r_type);
 		    }
-		  r_type = (((r_type - (R_PPC_GOT_TLSGD16 & 3)) & 3)
-			    + R_PPC_GOT_TPREL16);
-		  rel->r_info = ELF32_R_INFO (r_symndx, r_type);
-		}
-	      else
-		{
-		  /* LE */
-		  insn1 = 0x3c620000;	/* addis 3,2,0 */
-		  if (tls_gd == 0)
+		  else
 		    {
-		      /* Was an LD reloc.  */
-		      for (r_symndx = 0;
-			   r_symndx < symtab_hdr->sh_info;
-			   r_symndx++)
-			if (local_sections[r_symndx] == sec)
-			  break;
-		      if (r_symndx >= symtab_hdr->sh_info)
-			r_symndx = 0;
-		      rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
-		      if (r_symndx != 0)
-			rel->r_addend -= (local_syms[r_symndx].st_value
-					  + sec->output_offset
-					  + sec->output_section->vma);
+		      /* LE */
+		      insn1 = 0x3c620000;	/* addis 3,2,0 */
+		      insn2 = 0x38630000;	/* addi 3,3,0 */
+		      if (tls_gd == 0)
+			{
+			  /* Was an LD reloc.  */
+			  r_symndx = 0;
+			  rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
+			}
+		      r_type = R_PPC_TPREL16_HA;
+		      rel->r_info = ELF32_R_INFO (r_symndx, r_type);
+		      rel[1].r_info = ELF32_R_INFO (r_symndx,
+						    R_PPC_TPREL16_LO);
+		      rel[1].r_offset += d_offset;
+		      rel[1].r_addend = rel->r_addend;
 		    }
-		  r_type = R_PPC_TPREL16_HA;
-		  rel->r_info = ELF32_R_INFO (r_symndx, r_type);
-		  if (offset != (bfd_vma) -1)
+		  bfd_put_32 (output_bfd, insn1, contents + rel->r_offset - d_offset);
+		  bfd_put_32 (output_bfd, insn2, contents + offset);
+		  if (tls_gd == 0)
 		    {
-		      rel[1].r_info = ELF32_R_INFO (r_symndx, R_PPC_TPREL16_LO);
-		      rel[1].r_offset = offset + d_offset;
-		      rel[1].r_addend = rel->r_addend;
-		      insn2 = 0x38630000;	/* addi 3,3,0 */
-		      bfd_put_32 (output_bfd, insn2, contents + offset);
+		      /* We changed the symbol on an LD reloc.  Start over
+			 in order to get h, sym, sec etc. right.  */
+		      rel--;
+		      continue;
 		    }
 		}
-	      bfd_put_32 (output_bfd, insn1,
-			  contents + rel->r_offset - d_offset);
-	      if (tls_gd == 0)
-		{
-		  /* We changed the symbol on an LD reloc.  Start over
-		     in order to get h, sym, sec etc. right.  */
-		  rel--;
-		  continue;
-		}
 	    }
 	  break;
-
-	case R_PPC_TLSGD:
-	  if (tls_mask != 0 && (tls_mask & TLS_GD) == 0)
-	    {
-	      unsigned int insn2;
-	      bfd_vma offset = rel->r_offset;
-
-	      if ((tls_mask & TLS_TPRELGD) != 0)
-		{
-		  /* IE */
-		  r_type = R_PPC_NONE;
-		  insn2 = 0x7c631214;	/* add 3,3,2 */
-		}
-	      else
-		{
-		  /* LE */
-		  r_type = R_PPC_TPREL16_LO;
-		  rel->r_offset += d_offset;
-		  insn2 = 0x38630000;	/* addi 3,3,0 */
-		}
-	      rel->r_info = ELF32_R_INFO (r_symndx, r_type);
-	      bfd_put_32 (output_bfd, insn2, contents + offset);
-	      /* Zap the reloc on the _tls_get_addr call too.  */
-	      BFD_ASSERT (offset == rel[1].r_offset);
-	      rel[1].r_info = ELF32_R_INFO (ELF32_R_SYM (rel[1].r_info),
-					    R_PPC_NONE);
-	    }
-	  break;
-
-	case R_PPC_TLSLD:
-	  if (tls_mask != 0 && (tls_mask & TLS_LD) == 0)
-	    {
-	      unsigned int insn2;
-
-	      for (r_symndx = 0;
-		   r_symndx < symtab_hdr->sh_info;
-		   r_symndx++)
-		if (local_sections[r_symndx] == sec)
-		  break;
-	      if (r_symndx >= symtab_hdr->sh_info)
-		r_symndx = 0;
-	      rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
-	      if (r_symndx != 0)
-		rel->r_addend -= (local_syms[r_symndx].st_value
-				  + sec->output_offset
-				  + sec->output_section->vma);
-
-	      rel->r_info = ELF32_R_INFO (r_symndx, R_PPC_TPREL16_LO);
-	      rel->r_offset += d_offset;
-	      insn2 = 0x38630000;	/* addi 3,3,0 */
-	      bfd_put_32 (output_bfd, insn2,
-			  contents + rel->r_offset - d_offset);
-	      /* Zap the reloc on the _tls_get_addr call too.  */
-	      BFD_ASSERT (rel->r_offset - d_offset == rel[1].r_offset);
-	      rel[1].r_info = ELF32_R_INFO (ELF32_R_SYM (rel[1].r_info),
-					    R_PPC_NONE);
-	      rel--;
-	      continue;
-	    }
-	  break;
 	}
 
       /* Handle other relocations that tweak non-addend part of insn.  */
@@ -6185,7 +5990,7 @@
       howto = NULL;
       if (r_type < R_PPC_max)
 	howto = ppc_elf_howto_table[r_type];
-      switch ((int) r_type)
+      switch (r_type)
 	{
 	default:
 	  (*_bfd_error_handler)
@@ -6198,8 +6003,6 @@
 
 	case R_PPC_NONE:
 	case R_PPC_TLS:
-	case R_PPC_TLSGD:
-	case R_PPC_TLSLD:
 	case R_PPC_EMB_MRKREF:
 	case R_PPC_GNU_VTINHERIT:
 	case R_PPC_GNU_VTENTRY:
@@ -6241,7 +6044,6 @@
 	case R_PPC_GOT16_LO:
 	case R_PPC_GOT16_HI:
 	case R_PPC_GOT16_HA:
-	  tls_mask = 0;
 	dogot:
 	  {
 	    /* Relocation is to the entry for this symbol in the global
@@ -6540,7 +6342,7 @@
 	       && (h == NULL
 		   || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
 		   || h->root.type != bfd_link_hash_undefweak)
-	       && (must_be_dyn_reloc (info, r_type)
+	       && (MUST_BE_DYN_RELOC (r_type)
 		   || !SYMBOL_CALLS_LOCAL (info, h)))
 	      || (ELIMINATE_COPY_RELOCS
 		  && !info->shared
@@ -6609,10 +6411,10 @@
 		    outrel.r_info = ELF32_R_INFO (0, R_PPC_RELATIVE);
 		  else
 		    {
-		      long indx = 0;
+		      long indx;
 
-		      if (r_symndx == 0 || bfd_is_abs_section (sec))
-			;
+		      if (bfd_is_abs_section (sec))
+			indx = 0;
 		      else if (sec == NULL || sec->owner == NULL)
 			{
 			  bfd_set_error (bfd_error_bad_value);
@@ -7770,7 +7572,7 @@
 #define TARGET_LITTLE_SYM	bfd_elf32_powerpcle_vec
 #define TARGET_LITTLE_NAME	"elf32-powerpcle"
 #define TARGET_BIG_SYM		bfd_elf32_powerpc_vec
-#define TARGET_BIG_NAME		"elf32-powerpc-freebsd"
+#define TARGET_BIG_NAME		"elf32-powerpc"
 #define ELF_ARCH		bfd_arch_powerpc
 #define ELF_MACHINE_CODE	EM_PPC
 #ifdef __QNXTARGET__

Modified: trunk/contrib/binutils/bfd/elf64-ppc.c
===================================================================
--- trunk/contrib/binutils/bfd/elf64-ppc.c	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/bfd/elf64-ppc.c	2018-06-15 22:29:16 UTC (rev 11010)
@@ -58,7 +58,7 @@
 #define TARGET_LITTLE_SYM	bfd_elf64_powerpcle_vec
 #define TARGET_LITTLE_NAME	"elf64-powerpcle"
 #define TARGET_BIG_SYM		bfd_elf64_powerpc_vec
-#define TARGET_BIG_NAME		"elf64-powerpc-freebsd"
+#define TARGET_BIG_NAME		"elf64-powerpc"
 #define ELF_ARCH		bfd_arch_powerpc
 #define ELF_MACHINE_CODE	EM_PPC64
 #define ELF_MAXPAGESIZE		0x10000
@@ -130,25 +130,21 @@
 
 /* .plt call stub instructions.  The normal stub is like this, but
    sometimes the .plt entry crosses a 64k boundary and we need to
-   insert an addi to adjust r12.  */
+   insert an addis to adjust r12.  */
 #define PLT_CALL_STUB_SIZE (7*4)
 #define ADDIS_R12_R2	0x3d820000	/* addis %r12,%r2,xxx at ha     */
 #define STD_R2_40R1	0xf8410028	/* std	 %r2,40(%r1)	     */
 #define LD_R11_0R12	0xe96c0000	/* ld	 %r11,xxx+0 at l(%r12)  */
+#define LD_R2_0R12	0xe84c0000	/* ld	 %r2,xxx+8 at l(%r12)   */
 #define MTCTR_R11	0x7d6903a6	/* mtctr %r11		     */
-#define LD_R2_0R12	0xe84c0000	/* ld	 %r2,xxx+8 at l(%r12)   */
 					/* ld	 %r11,xxx+16 at l(%r12) */
 #define BCTR		0x4e800420	/* bctr			     */
 
 
 #define ADDIS_R12_R12	0x3d8c0000	/* addis %r12,%r12,off at ha  */
-#define ADDI_R12_R12	0x398c0000	/* addi %r12,%r12,off at l  */
 #define ADDIS_R2_R2	0x3c420000	/* addis %r2,%r2,off at ha  */
 #define ADDI_R2_R2	0x38420000	/* addi  %r2,%r2,off at l   */
 
-#define LD_R11_0R2	0xe9620000	/* ld	 %r11,xxx+0(%r2) */
-#define LD_R2_0R2	0xe8420000	/* ld	 %r2,xxx+0(%r2)  */
-
 #define LD_R2_40R1	0xe8410028	/* ld    %r2,40(%r1)     */
 
 /* glink call stub instructions.  We enter with the index in R0.  */
@@ -1233,7 +1229,7 @@
 	 0xfffc,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Marker relocs for TLS.  */
+  /* Marker reloc for TLS.  */
   HOWTO (R_PPC64_TLS,
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1248,34 +1244,6 @@
 	 0,			/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  HOWTO (R_PPC64_TLSGD,
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 32,			/* bitsize */
-	 FALSE,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_PPC64_TLSGD",	/* name */
-	 FALSE,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0,			/* dst_mask */
-	 FALSE),		/* pcrel_offset */
-
-  HOWTO (R_PPC64_TLSLD,
-	 0,			/* rightshift */
-	 2,			/* size (0 = byte, 1 = short, 2 = long) */
-	 32,			/* bitsize */
-	 FALSE,			/* pc_relative */
-	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_PPC64_TLSLD",	/* name */
-	 FALSE,			/* partial_inplace */
-	 0,			/* src_mask */
-	 0,			/* dst_mask */
-	 FALSE),		/* pcrel_offset */
-
   /* Computes the load module index of the load module that contains the
      definition of its TLS sym.  */
   HOWTO (R_PPC64_DTPMOD64,
@@ -2057,10 +2025,6 @@
       break;
     case BFD_RELOC_PPC_TLS:			r = R_PPC64_TLS;
       break;
-    case BFD_RELOC_PPC_TLSGD:			r = R_PPC64_TLSGD;
-      break;
-    case BFD_RELOC_PPC_TLSLD:			r = R_PPC64_TLSLD;
-      break;
     case BFD_RELOC_PPC_DTPMOD:			r = R_PPC64_DTPMOD64;
       break;
     case BFD_RELOC_PPC_TPREL16:			r = R_PPC64_TPREL16;
@@ -2647,15 +2611,9 @@
     /* After editing .opd, adjust references to opd local syms.  */
     long *opd_adjust;
 
-    /* An array for toc sections, indexed by offset/8.  */
-    struct _toc_sec_data
-    {
-      /* Specifies the relocation symbol index used at a given toc offset.  */
-      unsigned *symndx;
-
-      /* And the relocation addend.  */
-      bfd_vma *add;
-    } toc;
+    /* An array for toc sections, indexed by offset/8.
+       Specifies the relocation symbol index used at a given toc offset.  */
+    unsigned *t_symndx;
   } u;
 
   enum _ppc64_sec_type sec_type:2;
@@ -3198,8 +3156,7 @@
   /* Unlike other ELF targets, we use separate GOT entries for the same
      symbol referenced from different input files.  This is to support
      automatic multiple TOC/GOT sections, where the TOC base can vary
-     from one input file to another.  FIXME: After group_sections we
-     ought to merge entries within the group.
+     from one input file to another.
 
      Point to the BFD owning this GOT entry.  */
   bfd *owner;
@@ -3230,39 +3187,15 @@
     } plt;
 };
 
-/* Of those relocs that might be copied as dynamic relocs, this function
+/* Of those relocs that might be copied as dynamic relocs, this macro
    selects those that must be copied when linking a shared library,
    even when the symbol is local.  */
 
-static int
-must_be_dyn_reloc (struct bfd_link_info *info,
-		   enum elf_ppc64_reloc_type r_type)
-{
-  switch (r_type)
-    {
-    default:
-      return 1;
+#define MUST_BE_DYN_RELOC(RTYPE)		\
+  ((RTYPE) != R_PPC64_REL32			\
+   && (RTYPE) != R_PPC64_REL64			\
+   && (RTYPE) != R_PPC64_REL30)
 
-    case R_PPC64_REL32:
-    case R_PPC64_REL64:
-    case R_PPC64_REL30:
-      return 0;
-
-    case R_PPC64_TPREL16:
-    case R_PPC64_TPREL16_LO:
-    case R_PPC64_TPREL16_HI:
-    case R_PPC64_TPREL16_HA:
-    case R_PPC64_TPREL16_DS:
-    case R_PPC64_TPREL16_LO_DS:
-    case R_PPC64_TPREL16_HIGHER:
-    case R_PPC64_TPREL16_HIGHERA:
-    case R_PPC64_TPREL16_HIGHEST:
-    case R_PPC64_TPREL16_HIGHESTA:
-    case R_PPC64_TPREL64:
-      return !info->executable;
-    }
-}
-
 /* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid
    copying dynamic variables from a shared lib into an app's dynbss
    section, and instead use a dynamic relocation to point into the
@@ -3301,12 +3234,13 @@
    ppc_stub_plt_call:
    Used to call a function in a shared library.  If it so happens that
    the plt entry referenced crosses a 64k boundary, then an extra
-   "addi %r12,%r12,xxx at toc@l" will be inserted before the "mtctr".
+   "addis %r12,%r12,1" will be inserted before the load at xxx+8 or
+   xxx+16 as appropriate.
    .	addis	%r12,%r2,xxx at toc@ha
    .	std	%r2,40(%r1)
    .	ld	%r11,xxx+0 at toc@l(%r12)
+   .	ld	%r2,xxx+8 at toc@l(%r12)
    .	mtctr	%r11
-   .	ld	%r2,xxx+8 at toc@l(%r12)
    .	ld	%r11,xxx+16 at toc@l(%r12)
    .	bctr
 
@@ -3326,9 +3260,6 @@
    .	addi	%r2,%r2,off at l
    .	mtctr	%r11
    .	bctr
-
-   In cases where the "addis" instruction would add zero, the "addis" is
-   omitted and following instructions modified slightly in some cases.
 */
 
 enum ppc_stub_type {
@@ -4462,7 +4393,6 @@
   const Elf_Internal_Rela *rel_end;
   asection *sreloc;
   asection **opd_sym_map;
-  struct elf_link_hash_entry *tga, *dottga;
 
   if (info->relocatable)
     return TRUE;
@@ -4477,10 +4407,6 @@
     return TRUE;
 
   htab = ppc_hash_table (info);
-  tga = elf_link_hash_lookup (&htab->elf, "__tls_get_addr",
-			      FALSE, FALSE, TRUE);
-  dottga = elf_link_hash_lookup (&htab->elf, ".__tls_get_addr",
-				 FALSE, FALSE, TRUE);
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
 
   sym_hashes = elf_sym_hashes (abfd);
@@ -4526,7 +4452,7 @@
       unsigned long r_symndx;
       struct elf_link_hash_entry *h;
       enum elf_ppc64_reloc_type r_type;
-      int tls_type;
+      int tls_type = 0;
       struct _ppc64_elf_section_data *ppc64_sec;
 
       r_symndx = ELF64_R_SYM (rel->r_info);
@@ -4540,46 +4466,14 @@
 	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
 	}
 
-      tls_type = 0;
       r_type = ELF64_R_TYPE (rel->r_info);
-      if (h != NULL && (h == tga || h == dottga))
-	switch (r_type)
-	  {
-	  default:
-	    break;
-
-	  case R_PPC64_REL24:
-	  case R_PPC64_REL14:
-	  case R_PPC64_REL14_BRTAKEN:
-	  case R_PPC64_REL14_BRNTAKEN:
-	  case R_PPC64_ADDR24:
-	  case R_PPC64_ADDR14:
-	  case R_PPC64_ADDR14_BRTAKEN:
-	  case R_PPC64_ADDR14_BRNTAKEN:
-	    if (rel != relocs
-		&& (ELF64_R_TYPE (rel[-1].r_info) == R_PPC64_TLSGD
-		    || ELF64_R_TYPE (rel[-1].r_info) == R_PPC64_TLSLD))
-	      /* We have a new-style __tls_get_addr call with a marker
-		 reloc.  */
-	      ;
-	    else
-	      /* Mark this section as having an old-style call.  */
-	      sec->has_tls_get_addr_call = 1;
-	    break;
-	  }
-
       switch (r_type)
 	{
-	case R_PPC64_TLSGD:
-	case R_PPC64_TLSLD:
-	  /* These special tls relocs tie a call to __tls_get_addr with
-	     its parameter symbol.  */
-	  break;
-
 	case R_PPC64_GOT_TLSLD16:
 	case R_PPC64_GOT_TLSLD16_LO:
 	case R_PPC64_GOT_TLSLD16_HI:
 	case R_PPC64_GOT_TLSLD16_HA:
+	  ppc64_tlsld_got (abfd)->refcount += 1;
 	  tls_type = TLS_TLS | TLS_LD;
 	  goto dogottls;
 
@@ -4594,7 +4488,7 @@
 	case R_PPC64_GOT_TPREL16_LO_DS:
 	case R_PPC64_GOT_TPREL16_HI:
 	case R_PPC64_GOT_TPREL16_HA:
-	  if (!info->executable)
+	  if (info->shared)
 	    info->flags |= DF_STATIC_TLS;
 	  tls_type = TLS_TLS | TLS_TPREL;
 	  goto dogottls;
@@ -4753,14 +4647,31 @@
 	      if (!update_plt_info (abfd, (struct ppc_link_hash_entry *) h,
 				    rel->r_addend))
 		return FALSE;
-	      if (h == tga || h == dottga)
+	      if (h == &htab->tls_get_addr->elf
+		  || h == &htab->tls_get_addr_fd->elf)
 		sec->has_tls_reloc = 1;
+	      else if (htab->tls_get_addr == NULL
+		       && CONST_STRNEQ (h->root.root.string, ".__tls_get_addr")
+		       && (h->root.root.string[15] == 0
+			   || h->root.root.string[15] == '@'))
+		{
+		  htab->tls_get_addr = (struct ppc_link_hash_entry *) h;
+		  sec->has_tls_reloc = 1;
+		}
+	      else if (htab->tls_get_addr_fd == NULL
+		       && CONST_STRNEQ (h->root.root.string, "__tls_get_addr")
+		       && (h->root.root.string[14] == 0
+			   || h->root.root.string[14] == '@'))
+		{
+		  htab->tls_get_addr_fd = (struct ppc_link_hash_entry *) h;
+		  sec->has_tls_reloc = 1;
+		}
 	    }
 	  break;
 
 	case R_PPC64_TPREL64:
 	  tls_type = TLS_EXPLICIT | TLS_TLS | TLS_TPREL;
-	  if (!info->executable)
+	  if (info->shared)
 	    info->flags |= DF_STATIC_TLS;
 	  goto dotlstoc;
 
@@ -4798,30 +4709,23 @@
 	  ppc64_sec = ppc64_elf_section_data (sec);
 	  if (ppc64_sec->sec_type != sec_toc)
 	    {
-	      bfd_size_type amt;
-
 	      /* One extra to simplify get_tls_mask.  */
-	      amt = sec->size * sizeof (unsigned) / 8 + sizeof (unsigned);
-	      ppc64_sec->u.toc.symndx = bfd_zalloc (abfd, amt);
-	      if (ppc64_sec->u.toc.symndx == NULL)
+	      bfd_size_type amt = sec->size * sizeof (unsigned) / 8 + 1;
+	      ppc64_sec->u.t_symndx = bfd_zalloc (abfd, amt);
+	      if (ppc64_sec->u.t_symndx == NULL)
 		return FALSE;
-	      amt = sec->size * sizeof (bfd_vma) / 8;
-	      ppc64_sec->u.toc.add = bfd_zalloc (abfd, amt);
-	      if (ppc64_sec->u.toc.add == NULL)
-		return FALSE;
 	      BFD_ASSERT (ppc64_sec->sec_type == sec_normal);
 	      ppc64_sec->sec_type = sec_toc;
 	    }
 	  BFD_ASSERT (rel->r_offset % 8 == 0);
-	  ppc64_sec->u.toc.symndx[rel->r_offset / 8] = r_symndx;
-	  ppc64_sec->u.toc.add[rel->r_offset / 8] = rel->r_addend;
+	  ppc64_sec->u.t_symndx[rel->r_offset / 8] = r_symndx;
 
 	  /* Mark the second slot of a GD or LD entry.
 	     -1 to indicate GD and -2 to indicate LD.  */
 	  if (tls_type == (TLS_EXPLICIT | TLS_TLS | TLS_GD))
-	    ppc64_sec->u.toc.symndx[rel->r_offset / 8 + 1] = -1;
+	    ppc64_sec->u.t_symndx[rel->r_offset / 8 + 1] = -1;
 	  else if (tls_type == (TLS_EXPLICIT | TLS_TLS | TLS_LD))
-	    ppc64_sec->u.toc.symndx[rel->r_offset / 8 + 1] = -2;
+	    ppc64_sec->u.t_symndx[rel->r_offset / 8 + 1] = -2;
 	  goto dodyn;
 
 	case R_PPC64_TPREL16:
@@ -4836,8 +4740,7 @@
 	case R_PPC64_TPREL16_HIGHESTA:
 	  if (info->shared)
 	    {
-	      if (!info->executable)
-		info->flags |= DF_STATIC_TLS;
+	      info->flags |= DF_STATIC_TLS;
 	      goto dodyn;
 	    }
 	  break;
@@ -4923,7 +4826,7 @@
 	     symbol.  */
 	dodyn:
 	  if ((info->shared
-	       && (must_be_dyn_reloc (info, r_type)
+	       && (MUST_BE_DYN_RELOC (r_type)
 		   || (h != NULL
 		       && (! info->symbolic
 			   || h->root.type == bfd_link_hash_defweak
@@ -5019,7 +4922,7 @@
 		}
 
 	      p->count += 1;
-	      if (!must_be_dyn_reloc (info, r_type))
+	      if (!MUST_BE_DYN_RELOC (r_type))
 		p->pc_count += 1;
 	    }
 	  break;
@@ -5394,6 +5297,7 @@
 	case R_PPC64_GOT_TLSLD16_LO:
 	case R_PPC64_GOT_TLSLD16_HI:
 	case R_PPC64_GOT_TLSLD16_HA:
+	  ppc64_tlsld_got (abfd)->refcount -= 1;
 	  tls_type = TLS_TLS | TLS_LD;
 	  goto dogot;
 
@@ -5738,8 +5642,6 @@
     {
       fh->elf.root.type = fh->oh->elf.root.type;
       fh->elf.forced_local = 1;
-      fh->elf.def_regular = fh->oh->elf.def_regular;
-      fh->elf.def_dynamic = fh->oh->elf.def_dynamic;
     }
 
   /* If this is a function code symbol, transfer dynamic linking
@@ -6183,12 +6085,9 @@
    type suitable for optimization, and 1 otherwise.  */
 
 static int
-get_tls_mask (char **tls_maskp,
-	      unsigned long *toc_symndx,
-	      bfd_vma *toc_addend,
+get_tls_mask (char **tls_maskp, unsigned long *toc_symndx,
 	      Elf_Internal_Sym **locsymsp,
-	      const Elf_Internal_Rela *rel,
-	      bfd *ibfd)
+	      const Elf_Internal_Rela *rel, bfd *ibfd)
 {
   unsigned long r_symndx;
   int next_r;
@@ -6216,14 +6115,12 @@
     off = sym->st_value;
   off += rel->r_addend;
   BFD_ASSERT (off % 8 == 0);
-  r_symndx = ppc64_elf_section_data (sec)->u.toc.symndx[off / 8];
-  next_r = ppc64_elf_section_data (sec)->u.toc.symndx[off / 8 + 1];
+  r_symndx = ppc64_elf_section_data (sec)->u.t_symndx[off / 8];
+  next_r = ppc64_elf_section_data (sec)->u.t_symndx[off / 8 + 1];
+  if (!get_sym_h (&h, &sym, &sec, tls_maskp, locsymsp, r_symndx, ibfd))
+    return 0;
   if (toc_symndx != NULL)
     *toc_symndx = r_symndx;
-  if (toc_addend != NULL)
-    *toc_addend = ppc64_elf_section_data (sec)->u.toc.add[off / 8];
-  if (!get_sym_h (&h, &sym, &sec, tls_maskp, locsymsp, r_symndx, ibfd))
-    return 0;
   if ((h == NULL
        || ((h->root.type == bfd_link_hash_defined
 	    || h->root.type == bfd_link_hash_defweak)
@@ -6363,7 +6260,7 @@
     }
 
   if ((info->shared
-       && (must_be_dyn_reloc (info, r_type)
+       && (MUST_BE_DYN_RELOC (r_type)
 	   || (h != NULL
 	       && (!info->symbolic
 		   || h->root.type == bfd_link_hash_defweak
@@ -6403,7 +6300,7 @@
     {
       if (p->sec == sec)
 	{
-	  if (!must_be_dyn_reloc (info, r_type))
+	  if (!MUST_BE_DYN_RELOC (r_type))
 	    p->pc_count -= 1;
 	  p->count -= 1;
 	  if (p->count == 0)
@@ -6840,49 +6737,36 @@
   struct ppc_link_hash_table *htab;
 
   htab = ppc_hash_table (info);
-  htab->tls_get_addr = ((struct ppc_link_hash_entry *)
-			elf_link_hash_lookup (&htab->elf, ".__tls_get_addr",
-					      FALSE, FALSE, TRUE));
-  htab->tls_get_addr_fd = ((struct ppc_link_hash_entry *)
-			   elf_link_hash_lookup (&htab->elf, "__tls_get_addr",
-						 FALSE, FALSE, TRUE));
-  return _bfd_elf_tls_setup (obfd, info);
-}
+  if (htab->tls_get_addr != NULL)
+    {
+      struct ppc_link_hash_entry *h = htab->tls_get_addr;
 
-/* Return TRUE iff REL is a branch reloc with a global symbol matching
-   HASH1 or HASH2.  */
+      while (h->elf.root.type == bfd_link_hash_indirect
+	     || h->elf.root.type == bfd_link_hash_warning)
+	h = (struct ppc_link_hash_entry *) h->elf.root.u.i.link;
 
-static bfd_boolean
-branch_reloc_hash_match (const bfd *ibfd,
-			 const Elf_Internal_Rela *rel,
-			 const struct ppc_link_hash_entry *hash1,
-			 const struct ppc_link_hash_entry *hash2)
-{
-  Elf_Internal_Shdr *symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
-  enum elf_ppc64_reloc_type r_type = ELF64_R_TYPE (rel->r_info);
-  unsigned int r_symndx = ELF64_R_SYM (rel->r_info);
+      htab->tls_get_addr = h;
 
-  if (r_symndx >= symtab_hdr->sh_info
-      && (r_type == R_PPC64_REL24
-	  || r_type == R_PPC64_REL14
-	  || r_type == R_PPC64_REL14_BRTAKEN
-	  || r_type == R_PPC64_REL14_BRNTAKEN
-	  || r_type == R_PPC64_ADDR24
-	  || r_type == R_PPC64_ADDR14
-	  || r_type == R_PPC64_ADDR14_BRTAKEN
-	  || r_type == R_PPC64_ADDR14_BRNTAKEN))
+      if (htab->tls_get_addr_fd == NULL
+	  && h->oh != NULL
+	  && h->oh->is_func_descriptor
+	  && (h->oh->elf.root.type == bfd_link_hash_defined
+	      || h->oh->elf.root.type == bfd_link_hash_defweak))
+	htab->tls_get_addr_fd = h->oh;
+    }
+
+  if (htab->tls_get_addr_fd != NULL)
     {
-      struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (ibfd);
-      struct elf_link_hash_entry *h;
+      struct ppc_link_hash_entry *h = htab->tls_get_addr_fd;
 
-      h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-      while (h->root.type == bfd_link_hash_indirect
-	     || h->root.type == bfd_link_hash_warning)
-	h = (struct elf_link_hash_entry *) h->root.u.i.link;
-      if (h == &hash1->elf || h == &hash2->elf)
-	return TRUE;
+      while (h->elf.root.type == bfd_link_hash_indirect
+	     || h->elf.root.type == bfd_link_hash_warning)
+	h = (struct ppc_link_hash_entry *) h->elf.root.u.i.link;
+
+      htab->tls_get_addr_fd = h;
     }
-  return FALSE;
+
+  return _bfd_elf_tls_setup (obfd, info);
 }
 
 /* Run through all the TLS relocs looking for optimization
@@ -6898,9 +6782,8 @@
   bfd *ibfd;
   asection *sec;
   struct ppc_link_hash_table *htab;
-  int pass;
 
-  if (info->relocatable || !info->executable)
+  if (info->relocatable || info->shared)
     return TRUE;
 
   htab = ppc_hash_table (info);
@@ -6910,358 +6793,320 @@
       asection *toc = bfd_get_section_by_name (ibfd, ".toc");
       unsigned char *toc_ref = NULL;
 
-      /* Look at all the sections for this file.  Make two passes over
-	 the relocs.  On the first pass, mark toc entries involved
-	 with tls relocs, and check that tls relocs involved in
-	 setting up a tls_get_addr call are indeed followed by such a
-	 call.  If they are not, exclude them from the optimizations
-	 done on the second pass.  */
-      for (pass = 0; pass < 2; ++pass)
-	for (sec = ibfd->sections; sec != NULL; sec = sec->next)
-	  if (sec->has_tls_reloc && !bfd_is_abs_section (sec->output_section))
-	    {
-	      Elf_Internal_Rela *relstart, *rel, *relend;
+      /* Look at all the sections for this file, with TOC last.  */
+      for (sec = (ibfd->sections == toc && toc && toc->next ? toc->next
+		  : ibfd->sections);
+	   sec != NULL;
+	   sec = (sec == toc ? NULL
+		  : sec->next == NULL ? toc
+		  : sec->next == toc && toc->next ? toc->next
+		  : sec->next))
+	if (sec->has_tls_reloc && !bfd_is_abs_section (sec->output_section))
+	  {
+	    Elf_Internal_Rela *relstart, *rel, *relend;
+	    int expecting_tls_get_addr;
+	    long toc_ref_index = 0;
 
-	      /* Read the relocations.  */
-	      relstart = _bfd_elf_link_read_relocs (ibfd, sec, NULL, NULL,
-						    info->keep_memory);
-	      if (relstart == NULL)
-		return FALSE;
+	    /* Read the relocations.  */
+	    relstart = _bfd_elf_link_read_relocs (ibfd, sec, NULL, NULL,
+						  info->keep_memory);
+	    if (relstart == NULL)
+	      return FALSE;
 
-	      relend = relstart + sec->reloc_count;
-	      for (rel = relstart; rel < relend; rel++)
-		{
-		  enum elf_ppc64_reloc_type r_type;
-		  unsigned long r_symndx;
-		  struct elf_link_hash_entry *h;
-		  Elf_Internal_Sym *sym;
-		  asection *sym_sec;
-		  char *tls_mask;
-		  char tls_set, tls_clear, tls_type = 0;
-		  bfd_vma value;
-		  bfd_boolean ok_tprel, is_local;
-		  long toc_ref_index = 0;
-		  int expecting_tls_get_addr = 0;
+	    expecting_tls_get_addr = 0;
+	    relend = relstart + sec->reloc_count;
+	    for (rel = relstart; rel < relend; rel++)
+	      {
+		enum elf_ppc64_reloc_type r_type;
+		unsigned long r_symndx;
+		struct elf_link_hash_entry *h;
+		Elf_Internal_Sym *sym;
+		asection *sym_sec;
+		char *tls_mask;
+		char tls_set, tls_clear, tls_type = 0;
+		bfd_vma value;
+		bfd_boolean ok_tprel, is_local;
 
-		  r_symndx = ELF64_R_SYM (rel->r_info);
-		  if (!get_sym_h (&h, &sym, &sym_sec, &tls_mask, &locsyms,
-				  r_symndx, ibfd))
-		    {
-		    err_free_rel:
-		      if (elf_section_data (sec)->relocs != relstart)
-			free (relstart);
-		      if (toc_ref != NULL)
-			free (toc_ref);
-		      if (locsyms != NULL
-			  && (elf_tdata (ibfd)->symtab_hdr.contents
-			      != (unsigned char *) locsyms))
-			free (locsyms);
-		      return FALSE;
-		    }
+		r_symndx = ELF64_R_SYM (rel->r_info);
+		if (!get_sym_h (&h, &sym, &sym_sec, &tls_mask, &locsyms,
+				r_symndx, ibfd))
+		  {
+		  err_free_rel:
+		    if (elf_section_data (sec)->relocs != relstart)
+		      free (relstart);
+		    if (toc_ref != NULL)
+		      free (toc_ref);
+		    if (locsyms != NULL
+			&& (elf_tdata (ibfd)->symtab_hdr.contents
+			    != (unsigned char *) locsyms))
+		      free (locsyms);
+		    return FALSE;
+		  }
 
-		  if (h != NULL)
-		    {
-		      if (h->root.type != bfd_link_hash_defined
-			  && h->root.type != bfd_link_hash_defweak)
-			continue;
-		      value = h->root.u.def.value;
-		    }
-		  else
-		    /* Symbols referenced by TLS relocs must be of type
-		       STT_TLS.  So no need for .opd local sym adjust.  */
-		    value = sym->st_value;
+		if (h != NULL)
+		  {
+		    if (h->root.type != bfd_link_hash_defined
+			&& h->root.type != bfd_link_hash_defweak)
+		      continue;
+		    value = h->root.u.def.value;
+		  }
+		else
+		  /* Symbols referenced by TLS relocs must be of type
+		     STT_TLS.  So no need for .opd local sym adjust.  */
+		  value = sym->st_value;
 
-		  ok_tprel = FALSE;
-		  is_local = FALSE;
-		  if (h == NULL
-		      || !h->def_dynamic)
-		    {
-		      is_local = TRUE;
-		      value += sym_sec->output_offset;
-		      value += sym_sec->output_section->vma;
-		      value -= htab->elf.tls_sec->vma;
-		      ok_tprel = (value + TP_OFFSET + ((bfd_vma) 1 << 31)
-				  < (bfd_vma) 1 << 32);
-		    }
+		ok_tprel = FALSE;
+		is_local = FALSE;
+		if (h == NULL
+		    || !h->def_dynamic)
+		  {
+		    is_local = TRUE;
+		    value += sym_sec->output_offset;
+		    value += sym_sec->output_section->vma;
+		    value -= htab->elf.tls_sec->vma;
+		    ok_tprel = (value + TP_OFFSET + ((bfd_vma) 1 << 31)
+				< (bfd_vma) 1 << 32);
+		  }
 
-		  r_type = ELF64_R_TYPE (rel->r_info);
-		  switch (r_type)
-		    {
-		    case R_PPC64_GOT_TLSLD16:
-		    case R_PPC64_GOT_TLSLD16_LO:
-		      expecting_tls_get_addr = 1;
-		      /* Fall thru */
+		r_type = ELF64_R_TYPE (rel->r_info);
+		switch (r_type)
+		  {
+		  case R_PPC64_GOT_TLSLD16:
+		  case R_PPC64_GOT_TLSLD16_LO:
+		  case R_PPC64_GOT_TLSLD16_HI:
+		  case R_PPC64_GOT_TLSLD16_HA:
+		    /* These relocs should never be against a symbol
+		       defined in a shared lib.  Leave them alone if
+		       that turns out to be the case.  */
+		    ppc64_tlsld_got (ibfd)->refcount -= 1;
+		    if (!is_local)
+		      continue;
 
-		    case R_PPC64_GOT_TLSLD16_HI:
-		    case R_PPC64_GOT_TLSLD16_HA:
-		      /* These relocs should never be against a symbol
-			 defined in a shared lib.  Leave them alone if
-			 that turns out to be the case.  */
-		      if (!is_local)
-			continue;
+		    /* LD -> LE */
+		    tls_set = 0;
+		    tls_clear = TLS_LD;
+		    tls_type = TLS_TLS | TLS_LD;
+		    expecting_tls_get_addr = 1;
+		    break;
 
-		      /* LD -> LE */
+		  case R_PPC64_GOT_TLSGD16:
+		  case R_PPC64_GOT_TLSGD16_LO:
+		  case R_PPC64_GOT_TLSGD16_HI:
+		  case R_PPC64_GOT_TLSGD16_HA:
+		    if (ok_tprel)
+		      /* GD -> LE */
 		      tls_set = 0;
-		      tls_clear = TLS_LD;
-		      tls_type = TLS_TLS | TLS_LD;
-		      break;
+		    else
+		      /* GD -> IE */
+		      tls_set = TLS_TLS | TLS_TPRELGD;
+		    tls_clear = TLS_GD;
+		    tls_type = TLS_TLS | TLS_GD;
+		    expecting_tls_get_addr = 1;
+		    break;
 
-		    case R_PPC64_GOT_TLSGD16:
-		    case R_PPC64_GOT_TLSGD16_LO:
-		      expecting_tls_get_addr = 1;
-		      /* Fall thru */
-
-		    case R_PPC64_GOT_TLSGD16_HI:
-		    case R_PPC64_GOT_TLSGD16_HA:
-		      if (ok_tprel)
-			/* GD -> LE */
+		  case R_PPC64_GOT_TPREL16_DS:
+		  case R_PPC64_GOT_TPREL16_LO_DS:
+		  case R_PPC64_GOT_TPREL16_HI:
+		  case R_PPC64_GOT_TPREL16_HA:
+		    expecting_tls_get_addr = 0;
+		    if (ok_tprel)
+		      {
+			/* IE -> LE */
 			tls_set = 0;
-		      else
-			/* GD -> IE */
-			tls_set = TLS_TLS | TLS_TPRELGD;
-		      tls_clear = TLS_GD;
-		      tls_type = TLS_TLS | TLS_GD;
-		      break;
-
-		    case R_PPC64_GOT_TPREL16_DS:
-		    case R_PPC64_GOT_TPREL16_LO_DS:
-		    case R_PPC64_GOT_TPREL16_HI:
-		    case R_PPC64_GOT_TPREL16_HA:
-		      if (ok_tprel)
-			{
-			  /* IE -> LE */
-			  tls_set = 0;
-			  tls_clear = TLS_TPREL;
-			  tls_type = TLS_TLS | TLS_TPREL;
-			  break;
-			}
+			tls_clear = TLS_TPREL;
+			tls_type = TLS_TLS | TLS_TPREL;
+			break;
+		      }
+		    else
 		      continue;
 
-		    case R_PPC64_TOC16:
-		    case R_PPC64_TOC16_LO:
-		    case R_PPC64_TLS:
-		    case R_PPC64_TLSGD:
-		    case R_PPC64_TLSLD:
-		      if (sym_sec == NULL || sym_sec != toc)
-			continue;
+		  case R_PPC64_REL14:
+		  case R_PPC64_REL14_BRTAKEN:
+		  case R_PPC64_REL14_BRNTAKEN:
+		  case R_PPC64_REL24:
+		    if (h != NULL
+			&& (h == &htab->tls_get_addr->elf
+			    || h == &htab->tls_get_addr_fd->elf))
+		      {
+			if (!expecting_tls_get_addr
+			    && rel != relstart
+			    && ((ELF64_R_TYPE (rel[-1].r_info)
+				 == R_PPC64_TOC16)
+				|| (ELF64_R_TYPE (rel[-1].r_info)
+				    == R_PPC64_TOC16_LO)))
+			  {
+			    /* Check for toc tls entries.  */
+			    char *toc_tls;
+			    int retval;
 
-		      /* Mark this toc entry as referenced by a TLS
-			 code sequence.  We can do that now in the
-			 case of R_PPC64_TLS, and after checking for
-			 tls_get_addr for the TOC16 relocs.  */
-		      if (toc_ref == NULL)
-			{
-			  toc_ref = bfd_zmalloc (toc->size / 8);
-			  if (toc_ref == NULL)
-			    goto err_free_rel;
-			}
-		      if (h != NULL)
-			value = h->root.u.def.value;
-		      else
-			value = sym->st_value;
-		      value += rel->r_addend;
-		      BFD_ASSERT (value < toc->size && value % 8 == 0);
-		      toc_ref_index = value / 8;
-		      if (r_type == R_PPC64_TLS
-			  || r_type == R_PPC64_TLSGD
-			  || r_type == R_PPC64_TLSLD)
-			{
-			  toc_ref[toc_ref_index] = 1;
-			  continue;
-			}
+			    retval = get_tls_mask (&toc_tls, NULL, &locsyms,
+						   rel - 1, ibfd);
+			    if (retval == 0)
+			      goto err_free_rel;
+			    if (retval > 1 && toc_tls != NULL)
+			      {
+				expecting_tls_get_addr = 1;
+				if (toc_ref != NULL)
+				  toc_ref[toc_ref_index] = 1;
+			      }
+			  }
 
-		      if (pass != 0 && toc_ref[toc_ref_index] == 0)
-			continue;
+			if (expecting_tls_get_addr)
+			  {
+			    struct plt_entry *ent;
+			    for (ent = h->plt.plist; ent; ent = ent->next)
+			      if (ent->addend == 0)
+				{
+				  if (ent->plt.refcount > 0)
+				    ent->plt.refcount -= 1;
+				  break;
+				}
+			  }
+		      }
+		    expecting_tls_get_addr = 0;
+		    continue;
 
-		      tls_set = 0;
-		      tls_clear = 0;
-		      expecting_tls_get_addr = 2;
-		      break;
+		  case R_PPC64_TOC16:
+		  case R_PPC64_TOC16_LO:
+		  case R_PPC64_TLS:
+		    expecting_tls_get_addr = 0;
+		    if (sym_sec == toc && toc != NULL)
+		      {
+			/* Mark this toc entry as referenced by a TLS
+			   code sequence.  We can do that now in the
+			   case of R_PPC64_TLS, and after checking for
+			   tls_get_addr for the TOC16 relocs.  */
+			if (toc_ref == NULL)
+			  {
+			    toc_ref = bfd_zmalloc (toc->size / 8);
+			    if (toc_ref == NULL)
+			      goto err_free_rel;
+			  }
+			if (h != NULL)
+			  value = h->root.u.def.value;
+			else
+			  value = sym->st_value;
+			value += rel->r_addend;
+			BFD_ASSERT (value < toc->size && value % 8 == 0);
+			toc_ref_index = value / 8;
+			if (r_type == R_PPC64_TLS)
+			  toc_ref[toc_ref_index] = 1;
+		      }
+		    continue;
 
-		    case R_PPC64_TPREL64:
-		      if (pass == 0
-			  || sec != toc
-			  || toc_ref == NULL
-			  || !toc_ref[rel->r_offset / 8])
-			continue;
-		      if (ok_tprel)
-			{
-			  /* IE -> LE */
-			  tls_set = TLS_EXPLICIT;
-			  tls_clear = TLS_TPREL;
-			  break;
-			}
+		  case R_PPC64_TPREL64:
+		    expecting_tls_get_addr = 0;
+		    if (sec != toc
+			|| toc_ref == NULL
+			|| !toc_ref[rel->r_offset / 8])
 		      continue;
+		    if (ok_tprel)
+		      {
+			/* IE -> LE */
+			tls_set = TLS_EXPLICIT;
+			tls_clear = TLS_TPREL;
+			break;
+		      }
+		    else
+		      continue;
 
-		    case R_PPC64_DTPMOD64:
-		      if (pass == 0
-			  || sec != toc
-			  || toc_ref == NULL
-			  || !toc_ref[rel->r_offset / 8])
-			continue;
-		      if (rel + 1 < relend
-			  && (rel[1].r_info
-			      == ELF64_R_INFO (r_symndx, R_PPC64_DTPREL64))
-			  && rel[1].r_offset == rel->r_offset + 8)
-			{
-			  if (ok_tprel)
-			    /* GD -> LE */
-			    tls_set = TLS_EXPLICIT | TLS_GD;
-			  else
-			    /* GD -> IE */
-			    tls_set = TLS_EXPLICIT | TLS_GD | TLS_TPRELGD;
-			  tls_clear = TLS_GD;
-			}
-		      else
-			{
-			  if (!is_local)
-			    continue;
-
-			  /* LD -> LE */
-			  tls_set = TLS_EXPLICIT;
-			  tls_clear = TLS_LD;
-			}
-		      break;
-
-		    default:
+		  case R_PPC64_DTPMOD64:
+		    expecting_tls_get_addr = 0;
+		    if (sec != toc
+			|| toc_ref == NULL
+			|| !toc_ref[rel->r_offset / 8])
 		      continue;
-		    }
-
-		  if (pass == 0)
-		    {
-		      if (!expecting_tls_get_addr
-			  || !sec->has_tls_get_addr_call)
-			continue;
-
-		      if (rel + 1 < relend
-			  && branch_reloc_hash_match (ibfd, rel + 1,
-						      htab->tls_get_addr,
-						      htab->tls_get_addr_fd))
-			{
-			  if (expecting_tls_get_addr == 2)
-			    {
-			      /* Check for toc tls entries.  */
-			      char *toc_tls;
-			      int retval;
-
-			      retval = get_tls_mask (&toc_tls, NULL, NULL,
-						     &locsyms,
-						     rel, ibfd);
-			      if (retval == 0)
-				goto err_free_rel;
-			      if (retval > 1 && toc_tls != NULL)
-				toc_ref[toc_ref_index] = 1;
-			    }
+		    if (rel + 1 < relend
+			&& (rel[1].r_info
+			    == ELF64_R_INFO (r_symndx, R_PPC64_DTPREL64))
+			&& rel[1].r_offset == rel->r_offset + 8)
+		      {
+			if (ok_tprel)
+			  /* GD -> LE */
+			  tls_set = TLS_EXPLICIT | TLS_GD;
+			else
+			  /* GD -> IE */
+			  tls_set = TLS_EXPLICIT | TLS_GD | TLS_TPRELGD;
+			tls_clear = TLS_GD;
+		      }
+		    else
+		      {
+			if (!is_local)
 			  continue;
-			}
 
-		      if (expecting_tls_get_addr != 1)
-			continue;
+			/* LD -> LE */
+			tls_set = TLS_EXPLICIT;
+			tls_clear = TLS_LD;
+		      }
+		    break;
 
-		      /* Uh oh, we didn't find the expected call.  We
-			 could just mark this symbol to exclude it
-			 from tls optimization but it's safer to skip
-			 the entire section.  */
-		      sec->has_tls_reloc = 0;
-		      break;
-		    }
-
-		  if (expecting_tls_get_addr)
-		    {
-		      struct plt_entry *ent;
-		      for (ent = htab->tls_get_addr->elf.plt.plist;
-			   ent != NULL;
-			   ent = ent->next)
-			if (ent->addend == 0)
-			  {
-			    if (ent->plt.refcount > 0)
-			      {
-				ent->plt.refcount -= 1;
-				expecting_tls_get_addr = 0;
-			      }
-			    break;
-			  }
-		    }
-
-		  if (expecting_tls_get_addr)
-		    {
-		      struct plt_entry *ent;
-		      for (ent = htab->tls_get_addr_fd->elf.plt.plist;
-			   ent != NULL;
-			   ent = ent->next)
-			if (ent->addend == 0)
-			  {
-			    if (ent->plt.refcount > 0)
-			      ent->plt.refcount -= 1;
-			    break;
-			  }
-		    }
-
-		  if (tls_clear == 0)
+		  default:
+		    expecting_tls_get_addr = 0;
 		    continue;
+		  }
 
-		  if ((tls_set & TLS_EXPLICIT) == 0)
-		    {
-		      struct got_entry *ent;
+		if ((tls_set & TLS_EXPLICIT) == 0)
+		  {
+		    struct got_entry *ent;
 
-		      /* Adjust got entry for this reloc.  */
-		      if (h != NULL)
-			ent = h->got.glist;
-		      else
-			ent = elf_local_got_ents (ibfd)[r_symndx];
+		    /* Adjust got entry for this reloc.  */
+		    if (h != NULL)
+		      ent = h->got.glist;
+		    else
+		      ent = elf_local_got_ents (ibfd)[r_symndx];
 
-		      for (; ent != NULL; ent = ent->next)
-			if (ent->addend == rel->r_addend
-			    && ent->owner == ibfd
-			    && ent->tls_type == tls_type)
-			  break;
-		      if (ent == NULL)
-			abort ();
+		    for (; ent != NULL; ent = ent->next)
+		      if (ent->addend == rel->r_addend
+			  && ent->owner == ibfd
+			  && ent->tls_type == tls_type)
+			break;
+		    if (ent == NULL)
+		      abort ();
 
-		      if (tls_set == 0)
-			{
-			  /* We managed to get rid of a got entry.  */
-			  if (ent->got.refcount > 0)
-			    ent->got.refcount -= 1;
-			}
-		    }
-		  else
-		    {
-		      /* If we got rid of a DTPMOD/DTPREL reloc pair then
-			 we'll lose one or two dyn relocs.  */
-		      if (!dec_dynrel_count (rel->r_info, sec, info,
-					     NULL, h, sym_sec))
-			return FALSE;
+		    if (tls_set == 0)
+		      {
+			/* We managed to get rid of a got entry.  */
+			if (ent->got.refcount > 0)
+			  ent->got.refcount -= 1;
+		      }
+		  }
+		else
+		  {
+		    /* If we got rid of a DTPMOD/DTPREL reloc pair then
+		       we'll lose one or two dyn relocs.  */
+		    if (!dec_dynrel_count (rel->r_info, sec, info,
+					   NULL, h, sym_sec))
+		      return FALSE;
 
-		      if (tls_set == (TLS_EXPLICIT | TLS_GD))
-			{
-			  if (!dec_dynrel_count ((rel + 1)->r_info, sec, info,
-						 NULL, h, sym_sec))
-			    return FALSE;
-			}
-		    }
+		    if (tls_set == (TLS_EXPLICIT | TLS_GD))
+		      {
+			if (!dec_dynrel_count ((rel + 1)->r_info, sec, info,
+					       NULL, h, sym_sec))
+			  return FALSE;
+		      }
+		  }
 
-		  *tls_mask |= tls_set;
-		  *tls_mask &= ~tls_clear;
-		}
+		*tls_mask |= tls_set;
+		*tls_mask &= ~tls_clear;
+	      }
 
-	      if (elf_section_data (sec)->relocs != relstart)
-		free (relstart);
-	    }
+	    if (elf_section_data (sec)->relocs != relstart)
+	      free (relstart);
+	  }
 
-	if (toc_ref != NULL)
-	  free (toc_ref);
+      if (toc_ref != NULL)
+	free (toc_ref);
 
-	if (locsyms != NULL
-	    && (elf_tdata (ibfd)->symtab_hdr.contents
-		!= (unsigned char *) locsyms))
-	  {
-	    if (!info->keep_memory)
-	      free (locsyms);
-	    else
-	      elf_tdata (ibfd)->symtab_hdr.contents = (unsigned char *) locsyms;
-	  }
-      }
+      if (locsyms != NULL
+	  && (elf_tdata (ibfd)->symtab_hdr.contents
+	      != (unsigned char *) locsyms))
+	{
+	  if (!info->keep_memory)
+	    free (locsyms);
+	  else
+	    elf_tdata (ibfd)->symtab_hdr.contents = (unsigned char *) locsyms;
+	}
+    }
   return TRUE;
 }
 
@@ -7835,8 +7680,7 @@
 	if ((gent->tls_type & TLS_LD) != 0
 	    && !h->def_dynamic)
 	  {
-	    ppc64_tlsld_got (gent->owner)->refcount += 1;
-	    gent->got.offset = (bfd_vma) -1;
+	    gent->got.offset = ppc64_tlsld_got (gent->owner)->offset;
 	    continue;
 	  }
 
@@ -7869,7 +7713,7 @@
   if (info->shared)
     {
       /* Relocs that use pc_count are those that appear on a call insn,
-	 or certain REL relocs (see must_be_dyn_reloc) that can be
+	 or certain REL relocs (see MUST_BE_DYN_RELOC) that can be
 	 generated via assembly.  We want calls to protected symbols to
 	 resolve directly to the function rather than going via the plt.
 	 If people want function pointer comparisons to work as expected
@@ -8020,6 +7864,20 @@
       if (!is_ppc64_elf_target (ibfd->xvec))
 	continue;
 
+      if (ppc64_tlsld_got (ibfd)->refcount > 0)
+	{
+	  s = ppc64_elf_tdata (ibfd)->got;
+	  ppc64_tlsld_got (ibfd)->offset = s->size;
+	  s->size += 16;
+	  if (info->shared)
+	    {
+	      srel = ppc64_elf_tdata (ibfd)->relgot;
+	      srel->size += sizeof (Elf64_External_Rela);
+	    }
+	}
+      else
+	ppc64_tlsld_got (ibfd)->offset = (bfd_vma) -1;
+
       for (s = ibfd->sections; s != NULL; s = s->next)
 	{
 	  struct ppc_dyn_relocs *p;
@@ -8063,8 +7921,14 @@
 	      {
 		if ((ent->tls_type & *lgot_masks & TLS_LD) != 0)
 		  {
-		    ppc64_tlsld_got (ibfd)->refcount += 1;
-		    ent->got.offset = (bfd_vma) -1;
+		    if (ppc64_tlsld_got (ibfd)->offset == (bfd_vma) -1)
+		      {
+			ppc64_tlsld_got (ibfd)->offset = s->size;
+			s->size += 16;
+			if (info->shared)
+			  srel->size += sizeof (Elf64_External_Rela);
+		      }
+		    ent->got.offset = ppc64_tlsld_got (ibfd)->offset;
 		  }
 		else
 		  {
@@ -8092,26 +7956,6 @@
      sym dynamic relocs.  */
   elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, info);
 
-  for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
-    {
-      if (!is_ppc64_elf_target (ibfd->xvec))
-	continue;
-
-      if (ppc64_tlsld_got (ibfd)->refcount > 0)
-	{
-	  s = ppc64_elf_tdata (ibfd)->got;
-	  ppc64_tlsld_got (ibfd)->offset = s->size;
-	  s->size += 16;
-	  if (info->shared)
-	    {
-	      asection *srel = ppc64_elf_tdata (ibfd)->relgot;
-	      srel->size += sizeof (Elf64_External_Rela);
-	    }
-	}
-      else
-	ppc64_tlsld_got (ibfd)->offset = (bfd_vma) -1;
-    }
-
   /* We now have determined the sizes of the various dynamic sections.
      Allocate memory for them.  */
   relocs = FALSE;
@@ -8346,35 +8190,19 @@
 #define PPC_HI(v) (((v) >> 16) & 0xffff)
 #define PPC_HA(v) PPC_HI ((v) + 0x8000)
 
-  if (PPC_HA (offset) != 0)
-    {
-      bfd_put_32 (obfd, ADDIS_R12_R2 | PPC_HA (offset), p),	p += 4;
-      bfd_put_32 (obfd, STD_R2_40R1, p),			p += 4;
-      bfd_put_32 (obfd, LD_R11_0R12 | PPC_LO (offset), p),	p += 4;
-      if (PPC_HA (offset + 16) != PPC_HA (offset))
-	{
-	  bfd_put_32 (obfd, ADDI_R12_R12 | PPC_LO (offset), p),	p += 4;
-	  offset = 0;
-	}
-      bfd_put_32 (obfd, MTCTR_R11, p),				p += 4;
-      bfd_put_32 (obfd, LD_R2_0R12 | PPC_LO (offset + 8), p),	p += 4;
-      bfd_put_32 (obfd, LD_R11_0R12 | PPC_LO (offset + 16), p),	p += 4;
-      bfd_put_32 (obfd, BCTR, p),				p += 4;
-    }
-  else
-    {
-      bfd_put_32 (obfd, STD_R2_40R1, p),			p += 4;
-      bfd_put_32 (obfd, LD_R11_0R2 | PPC_LO (offset), p),	p += 4;
-      if (PPC_HA (offset + 16) != PPC_HA (offset))
-	{
-	  bfd_put_32 (obfd, ADDI_R2_R2 | PPC_LO (offset), p),	p += 4;
-	  offset = 0;
-	}
-      bfd_put_32 (obfd, MTCTR_R11, p),				p += 4;
-      bfd_put_32 (obfd, LD_R11_0R2 | PPC_LO (offset + 16), p),	p += 4;
-      bfd_put_32 (obfd, LD_R2_0R2 | PPC_LO (offset + 8), p),	p += 4;
-      bfd_put_32 (obfd, BCTR, p),				p += 4;
-    }
+  bfd_put_32 (obfd, ADDIS_R12_R2 | PPC_HA (offset), p),	p += 4;
+  bfd_put_32 (obfd, STD_R2_40R1, p),			p += 4;
+  bfd_put_32 (obfd, LD_R11_0R12 | PPC_LO (offset), p),	p += 4;
+  if (PPC_HA (offset + 8) != PPC_HA (offset))
+    bfd_put_32 (obfd, ADDIS_R12_R12 | 1, p),		p += 4;
+  offset += 8;
+  bfd_put_32 (obfd, LD_R2_0R12 | PPC_LO (offset), p),	p += 4;
+  if (PPC_HA (offset + 8) != PPC_HA (offset))
+    bfd_put_32 (obfd, ADDIS_R12_R12 | 1, p),		p += 4;
+  offset += 8;
+  bfd_put_32 (obfd, MTCTR_R11, p),			p += 4;
+  bfd_put_32 (obfd, LD_R11_0R12 | PPC_LO (offset), p),	p += 4;
+  bfd_put_32 (obfd, BCTR, p),				p += 4;
   return p;
 }
 
@@ -8417,8 +8245,9 @@
 	      + stub_entry->stub_sec->output_offset
 	      + stub_entry->stub_sec->output_section->vma);
 
-      size = 4;
-      if (stub_entry->stub_type == ppc_stub_long_branch_r2off)
+      if (stub_entry->stub_type != ppc_stub_long_branch_r2off)
+	size = 4;
+      else
 	{
 	  bfd_vma r2off;
 
@@ -8426,16 +8255,12 @@
 		   - htab->stub_group[stub_entry->id_sec->id].toc_off);
 	  bfd_put_32 (htab->stub_bfd, STD_R2_40R1, loc);
 	  loc += 4;
-	  size = 12;
-	  if (PPC_HA (r2off) != 0)
-	    {
-	      size = 16;
-	      bfd_put_32 (htab->stub_bfd, ADDIS_R2_R2 | PPC_HA (r2off), loc);
-	      loc += 4;
-	    }
+	  bfd_put_32 (htab->stub_bfd, ADDIS_R2_R2 | PPC_HA (r2off), loc);
+	  loc += 4;
 	  bfd_put_32 (htab->stub_bfd, ADDI_R2_R2 | PPC_LO (r2off), loc);
 	  loc += 4;
-	  off -= size - 4;
+	  off -= 12;
+	  size = 16;
 	}
       bfd_put_32 (htab->stub_bfd, B_DOT | (off & 0x3fffffc), loc);
 
@@ -8592,18 +8417,10 @@
       indx = off;
       if (stub_entry->stub_type != ppc_stub_plt_branch_r2off)
 	{
-	  if (PPC_HA (indx) != 0)
-	    {
-	      size = 16;
-	      bfd_put_32 (htab->stub_bfd, ADDIS_R12_R2 | PPC_HA (indx), loc);
-	      loc += 4;
-	      bfd_put_32 (htab->stub_bfd, LD_R11_0R12 | PPC_LO (indx), loc);
-	    }
-	  else
-	    {
-	      size = 12;
-	      bfd_put_32 (htab->stub_bfd, LD_R11_0R2 | PPC_LO (indx), loc);
-	    }
+	  bfd_put_32 (htab->stub_bfd, ADDIS_R12_R2 | PPC_HA (indx), loc);
+	  loc += 4;
+	  bfd_put_32 (htab->stub_bfd, LD_R11_0R12 | PPC_LO (indx), loc);
+	  size = 16;
 	}
       else
 	{
@@ -8613,28 +8430,14 @@
 		   - htab->stub_group[stub_entry->id_sec->id].toc_off);
 	  bfd_put_32 (htab->stub_bfd, STD_R2_40R1, loc);
 	  loc += 4;
-	  size = 20;
-	  if (PPC_HA (indx) != 0)
-	    {
-	      size += 4;
-	      bfd_put_32 (htab->stub_bfd, ADDIS_R12_R2 | PPC_HA (indx), loc);
-	      loc += 4;
-	      bfd_put_32 (htab->stub_bfd, LD_R11_0R12 | PPC_LO (indx), loc);
-	      loc += 4;
-	    }
-	  else
-	    {
-	      bfd_put_32 (htab->stub_bfd, LD_R11_0R2 | PPC_LO (indx), loc);
-	      loc += 4;
-	    }
-
-	  if (PPC_HA (r2off) != 0)
-	    {
-	      size += 4;
-	      bfd_put_32 (htab->stub_bfd, ADDIS_R2_R2 | PPC_HA (r2off), loc);
-	      loc += 4;
-	    }
+	  bfd_put_32 (htab->stub_bfd, ADDIS_R12_R2 | PPC_HA (indx), loc);
+	  loc += 4;
+	  bfd_put_32 (htab->stub_bfd, LD_R11_0R12 | PPC_LO (indx), loc);
+	  loc += 4;
+	  bfd_put_32 (htab->stub_bfd, ADDIS_R2_R2 | PPC_HA (r2off), loc);
+	  loc += 4;
 	  bfd_put_32 (htab->stub_bfd, ADDI_R2_R2 | PPC_LO (r2off), loc);
+	  size = 28;
 	}
       loc += 4;
       bfd_put_32 (htab->stub_bfd, MTCTR_R11, loc);
@@ -8773,8 +8576,6 @@
 	      - htab->stub_group[stub_entry->id_sec->id].toc_off);
 
       size = PLT_CALL_STUB_SIZE;
-      if (PPC_HA (off) == 0)
-	size -= 4;
       if (PPC_HA (off + 16) != PPC_HA (off))
 	size += 4;
     }
@@ -8782,8 +8583,6 @@
     {
       /* ppc_stub_long_branch or ppc_stub_plt_branch, or their r2off
 	 variants.  */
-      bfd_vma r2off = 0;
-
       off = (stub_entry->target_value
 	     + stub_entry->target_section->output_offset
 	     + stub_entry->target_section->output_section->vma);
@@ -8799,12 +8598,8 @@
       size = 4;
       if (stub_entry->stub_type == ppc_stub_long_branch_r2off)
 	{
-	  r2off = (htab->stub_group[stub_entry->target_section->id].toc_off
-		   - htab->stub_group[stub_entry->id_sec->id].toc_off);
-	  size = 12;
-	  if (PPC_HA (r2off) != 0)
-	    size = 16;
-	  off -= size - 4;
+	  off -= 12;
+	  size = 16;
 	}
 
       /* If the branch offset if too big, use a ppc_stub_plt_branch.  */
@@ -8811,7 +8606,6 @@
       if (off + (1 << 25) >= (bfd_vma) (1 << 26))
 	{
 	  struct ppc_branch_hash_entry *br_entry;
-	  unsigned int indx;
 
 	  br_entry = ppc_branch_hash_lookup (&htab->branch_hash_table,
 					     stub_entry->root.string + 9,
@@ -8840,28 +8634,9 @@
 	    }
 
 	  stub_entry->stub_type += ppc_stub_plt_branch - ppc_stub_long_branch;
-	  off = (br_entry->offset
-		 + htab->brlt->output_offset
-		 + htab->brlt->output_section->vma
-		 - elf_gp (htab->brlt->output_section->owner)
-		 - htab->stub_group[stub_entry->id_sec->id].toc_off);
-
-	  indx = off;
-	  if (stub_entry->stub_type != ppc_stub_plt_branch_r2off)
-	    {
-	      size = 12;
-	      if (PPC_HA (indx) != 0)
-		size = 16;
-	    }
-	  else
-	    {
-	      size = 20;
-	      if (PPC_HA (indx) != 0)
-		size += 4;
-
-	      if (PPC_HA (r2off) != 0)
-		size += 4;
-	    }
+	  size = 16;
+	  if (stub_entry->stub_type != ppc_stub_plt_branch)
+	    size = 28;
 	}
       else if (info->emitrelocations)
 	{
@@ -9028,7 +8803,6 @@
       enum elf_ppc64_reloc_type r_type;
       unsigned long r_symndx;
       struct elf_link_hash_entry *h;
-      struct ppc_link_hash_entry *eh;
       Elf_Internal_Sym *sym;
       asection *sym_sec;
       long *opd_adjust;
@@ -9051,21 +8825,24 @@
 	}
 
       /* Calls to dynamic lib functions go through a plt call stub
-	 that uses r2.  */
-      eh = (struct ppc_link_hash_entry *) h;
-      if (eh != NULL
-	  && (eh->elf.plt.plist != NULL
-	      || (eh->oh != NULL
-		  && eh->oh->elf.plt.plist != NULL)))
+	 that uses r2.  Branches to undefined symbols might be a call
+	 using old-style dot symbols that can be satisfied by a plt
+	 call into a new-style dynamic library.  */
+      if (sym_sec == NULL)
 	{
-	  ret = 1;
-	  break;
+	  struct ppc_link_hash_entry *eh = (struct ppc_link_hash_entry *) h;
+	  if (eh != NULL
+	      && eh->oh != NULL
+	      && eh->oh->elf.plt.plist != NULL)
+	    {
+	      ret = 1;
+	      break;
+	    }
+
+	  /* Ignore other undefined symbols.  */
+	  continue;
 	}
 
-      if (sym_sec == NULL)
-	/* Ignore other undefined symbols.  */
-	continue;
-
       /* Assume branches to other sections not included in the link need
 	 stubs too, to cover -R and absolute syms.  */
       if (sym_sec->output_section == NULL)
@@ -9583,7 +9360,7 @@
 		      /* Get tls info.  */
 		      char *tls_mask;
 
-		      if (!get_tls_mask (&tls_mask, NULL, NULL, &local_syms,
+		      if (!get_tls_mask (&tls_mask, NULL, &local_syms,
 					 irela - 1, input_bfd))
 			goto error_ret_free_internal;
 		      if (*tls_mask != 0)
@@ -10061,7 +9838,6 @@
       struct ppc_link_hash_entry *fdh;
       const char *sym_name;
       unsigned long r_symndx, toc_symndx;
-      bfd_vma toc_addend;
       char tls_mask, tls_gd, tls_type;
       char sym_type;
       bfd_vma relocation;
@@ -10155,28 +9931,28 @@
       tls_mask = 0;
       tls_gd = 0;
       toc_symndx = 0;
-      if (h != NULL)
-	tls_mask = h->tls_mask;
-      else if (local_got_ents != NULL)
+      if (IS_PPC64_TLS_RELOC (r_type))
 	{
-	  char *lgot_masks;
-	  lgot_masks = (char *) (local_got_ents + symtab_hdr->sh_info);
-	  tls_mask = lgot_masks[r_symndx];
-	}
-      if (tls_mask == 0
-	  && (r_type == R_PPC64_TLS
-	      || r_type == R_PPC64_TLSGD
-	      || r_type == R_PPC64_TLSLD))
-	{
-	  /* Check for toc tls entries.  */
-	  char *toc_tls;
+	  if (h != NULL)
+	    tls_mask = h->tls_mask;
+	  else if (local_got_ents != NULL)
+	    {
+	      char *lgot_masks;
+	      lgot_masks = (char *) (local_got_ents + symtab_hdr->sh_info);
+	      tls_mask = lgot_masks[r_symndx];
+	    }
+	  if (tls_mask == 0 && r_type == R_PPC64_TLS)
+	    {
+	      /* Check for toc tls entries.  */
+	      char *toc_tls;
 
-	  if (!get_tls_mask (&toc_tls, &toc_symndx, &toc_addend,
-			     &local_syms, rel, input_bfd))
-	    return FALSE;
+	      if (!get_tls_mask (&toc_tls, &toc_symndx, &local_syms,
+				 rel, input_bfd))
+		return FALSE;
 
-	  if (toc_tls)
-	    tls_mask = *toc_tls;
+	      if (toc_tls)
+		tls_mask = *toc_tls;
+	    }
 	}
 
       /* Check that tls relocs are used with tls syms, and non-tls
@@ -10186,20 +9962,14 @@
 	  && (h == NULL
 	      || h->elf.root.type == bfd_link_hash_defined
 	      || h->elf.root.type == bfd_link_hash_defweak)
-	  && (IS_PPC64_TLS_RELOC (r_type)
-	      != (sym_type == STT_TLS
-		  || (sym_type == STT_SECTION
-		      && (sec->flags & SEC_THREAD_LOCAL) != 0))))
+	  && IS_PPC64_TLS_RELOC (r_type) != (sym_type == STT_TLS))
 	{
-	  if (tls_mask != 0
-	      && (r_type == R_PPC64_TLS
-		  || r_type == R_PPC64_TLSGD
-		  || r_type == R_PPC64_TLSLD))
+	  if (r_type == R_PPC64_TLS && tls_mask != 0)
 	    /* R_PPC64_TLS is OK against a symbol in the TOC.  */
 	    ;
 	  else
 	    (*_bfd_error_handler)
-	      (!IS_PPC64_TLS_RELOC (r_type)
+	      (sym_type == STT_TLS
 	       ? _("%B(%A+0x%lx): %s used with TLS symbol %s")
 	       : _("%B(%A+0x%lx): %s used with non-TLS symbol %s"),
 	       input_bfd,
@@ -10236,8 +10006,8 @@
 	    char *toc_tls;
 	    int retval;
 
-	    retval = get_tls_mask (&toc_tls, &toc_symndx, &toc_addend,
-				   &local_syms, rel, input_bfd);
+	    retval = get_tls_mask (&toc_tls, &toc_symndx, &local_syms,
+				   rel, input_bfd);
 	    if (retval == 0)
 	      return FALSE;
 
@@ -10259,12 +10029,12 @@
 		      {
 			tls_gd = TLS_TPRELGD;
 			if (tls_mask != 0 && (tls_mask & TLS_GD) == 0)
-			  goto tls_ldgd_opt;
+			  goto tls_get_addr_check;
 		      }
 		    else if (retval == 3)
 		      {
 			if (tls_mask != 0 && (tls_mask & TLS_LD) == 0)
-			  goto tls_ldgd_opt;
+			  goto tls_get_addr_check;
 		      }
 		  }
 	      }
@@ -10338,8 +10108,6 @@
 	      if (toc_symndx != 0)
 		{
 		  rel->r_info = ELF64_R_INFO (toc_symndx, r_type);
-		  rel->r_addend = toc_addend;
-		  rel->r_addend = toc_addend;
 		  /* We changed the symbol.  Start over in order to
 		     get h, sym, sec etc. right.  */
 		  rel--;
@@ -10379,7 +10147,7 @@
 	case R_PPC64_GOT_TLSGD16_LO:
 	  tls_gd = TLS_TPRELGD;
 	  if (tls_mask != 0 && (tls_mask & TLS_GD) == 0)
-	    goto tls_ldgd_opt;
+	    goto tls_get_addr_check;
 	  break;
 
 	case R_PPC64_GOT_TLSLD16:
@@ -10386,195 +10154,95 @@
 	case R_PPC64_GOT_TLSLD16_LO:
 	  if (tls_mask != 0 && (tls_mask & TLS_LD) == 0)
 	    {
-	      unsigned int insn1, insn2, insn3;
-	      bfd_vma offset;
+	    tls_get_addr_check:
+	      if (rel + 1 < relend)
+		{
+		  enum elf_ppc64_reloc_type r_type2;
+		  unsigned long r_symndx2;
+		  struct elf_link_hash_entry *h2;
+		  bfd_vma insn1, insn2, insn3;
+		  bfd_vma offset;
 
-	    tls_ldgd_opt:
-	      offset = (bfd_vma) -1;
-	      /* If not using the newer R_PPC64_TLSGD/LD to mark
-		 __tls_get_addr calls, we must trust that the call
-		 stays with its arg setup insns, ie. that the next
-		 reloc is the __tls_get_addr call associated with
-		 the current reloc.  Edit both insns.  */
-	      if (input_section->has_tls_get_addr_call
-		  && rel + 1 < relend
-		  && branch_reloc_hash_match (input_bfd, rel + 1,
-					      htab->tls_get_addr,
-					      htab->tls_get_addr_fd))
-		offset = rel[1].r_offset;
-	      if ((tls_mask & tls_gd) != 0)
-		{
-		  /* IE */
+		  /* The next instruction should be a call to
+		     __tls_get_addr.  Peek at the reloc to be sure.  */
+		  r_type2 = ELF64_R_TYPE (rel[1].r_info);
+		  r_symndx2 = ELF64_R_SYM (rel[1].r_info);
+		  if (r_symndx2 < symtab_hdr->sh_info
+		      || (r_type2 != R_PPC64_REL14
+			  && r_type2 != R_PPC64_REL14_BRTAKEN
+			  && r_type2 != R_PPC64_REL14_BRNTAKEN
+			  && r_type2 != R_PPC64_REL24))
+		    break;
+
+		  h2 = sym_hashes[r_symndx2 - symtab_hdr->sh_info];
+		  while (h2->root.type == bfd_link_hash_indirect
+			 || h2->root.type == bfd_link_hash_warning)
+		    h2 = (struct elf_link_hash_entry *) h2->root.u.i.link;
+		  if (h2 == NULL || (h2 != &htab->tls_get_addr->elf
+				     && h2 != &htab->tls_get_addr_fd->elf))
+		    break;
+
+		  /* OK, it checks out.  Replace the call.  */
+		  offset = rel[1].r_offset;
 		  insn1 = bfd_get_32 (output_bfd,
 				      contents + rel->r_offset - d_offset);
-		  insn1 &= (1 << 26) - (1 << 2);
-		  insn1 |= 58 << 26;	/* ld */
-		  insn2 = 0x7c636a14;	/* add 3,3,13 */
-		  if (offset != (bfd_vma) -1)
-		    rel[1].r_info = ELF64_R_INFO (ELF64_R_SYM (rel[1].r_info),
-						  R_PPC64_NONE);
-		  if ((tls_mask & TLS_EXPLICIT) == 0)
-		    r_type = (((r_type - (R_PPC64_GOT_TLSGD16 & 3)) & 3)
-			      + R_PPC64_GOT_TPREL16_DS);
-		  else
-		    r_type += R_PPC64_TOC16_DS - R_PPC64_TOC16;
-		  rel->r_info = ELF64_R_INFO (r_symndx, r_type);
-		}
-	      else
-		{
-		  /* LE */
-		  insn1 = 0x3c6d0000;	/* addis 3,13,0 */
-		  insn2 = 0x38630000;	/* addi 3,3,0 */
-		  if (tls_gd == 0)
+		  insn3 = bfd_get_32 (output_bfd,
+				      contents + offset + 4);
+		  if ((tls_mask & tls_gd) != 0)
 		    {
-		      /* Was an LD reloc.  */
-		      if (toc_symndx)
-			sec = local_sections[toc_symndx];
-		      for (r_symndx = 0;
-			   r_symndx < symtab_hdr->sh_info;
-			   r_symndx++)
-			if (local_sections[r_symndx] == sec)
-			  break;
-		      if (r_symndx >= symtab_hdr->sh_info)
-			r_symndx = 0;
-		      rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
-		      if (r_symndx != 0)
-			rel->r_addend -= (local_syms[r_symndx].st_value
-					  + sec->output_offset
-					  + sec->output_section->vma);
+		      /* IE */
+		      insn1 &= (1 << 26) - (1 << 2);
+		      insn1 |= 58 << 26;	/* ld */
+		      insn2 = 0x7c636a14;	/* add 3,3,13 */
+		      rel[1].r_info = ELF64_R_INFO (r_symndx2, R_PPC64_NONE);
+		      if ((tls_mask & TLS_EXPLICIT) == 0)
+			r_type = (((r_type - (R_PPC64_GOT_TLSGD16 & 3)) & 3)
+				  + R_PPC64_GOT_TPREL16_DS);
+		      else
+			r_type += R_PPC64_TOC16_DS - R_PPC64_TOC16;
+		      rel->r_info = ELF64_R_INFO (r_symndx, r_type);
 		    }
-		  else if (toc_symndx != 0)
+		  else
 		    {
-		      r_symndx = toc_symndx;
-		      rel->r_addend = toc_addend;
-		    }
-		  r_type = R_PPC64_TPREL16_HA;
-		  rel->r_info = ELF64_R_INFO (r_symndx, r_type);
-		  if (offset != (bfd_vma) -1)
-		    {
+		      /* LE */
+		      insn1 = 0x3c6d0000;	/* addis 3,13,0 */
+		      insn2 = 0x38630000;	/* addi 3,3,0 */
+		      if (tls_gd == 0)
+			{
+			  /* Was an LD reloc.  */
+			  r_symndx = 0;
+			  rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
+			  rel[1].r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
+			}
+		      else if (toc_symndx != 0)
+			r_symndx = toc_symndx;
+		      r_type = R_PPC64_TPREL16_HA;
+		      rel->r_info = ELF64_R_INFO (r_symndx, r_type);
 		      rel[1].r_info = ELF64_R_INFO (r_symndx,
 						    R_PPC64_TPREL16_LO);
-		      rel[1].r_offset = offset + d_offset;
-		      rel[1].r_addend = rel->r_addend;
+		      rel[1].r_offset += d_offset;
 		    }
-		}
-	      bfd_put_32 (output_bfd, insn1,
-			  contents + rel->r_offset - d_offset);
-	      if (offset != (bfd_vma) -1)
-		{
-		  insn3 = bfd_get_32 (output_bfd,
-				      contents + offset + 4);
 		  if (insn3 == NOP
 		      || insn3 == CROR_151515 || insn3 == CROR_313131)
 		    {
+		      insn3 = insn2;
+		      insn2 = NOP;
 		      rel[1].r_offset += 4;
-		      bfd_put_32 (output_bfd, insn2, contents + offset + 4);
-		      insn2 = NOP;
 		    }
+		  bfd_put_32 (output_bfd, insn1, contents + rel->r_offset - d_offset);
 		  bfd_put_32 (output_bfd, insn2, contents + offset);
-		}
-	      if ((tls_mask & tls_gd) == 0
-		  && (tls_gd == 0 || toc_symndx != 0))
-		{
-		  /* We changed the symbol.  Start over in order
-		     to get h, sym, sec etc. right.  */
-		  rel--;
-		  continue;
-		}
-	    }
-	  break;
-
-	case R_PPC64_TLSGD:
-	  if (tls_mask != 0 && (tls_mask & TLS_GD) == 0)
-	    {
-	      unsigned int insn2, insn3;
-	      bfd_vma offset = rel->r_offset;
-
-	      if ((tls_mask & TLS_TPRELGD) != 0)
-		{
-		  /* IE */
-		  r_type = R_PPC64_NONE;
-		  insn2 = 0x7c636a14;	/* add 3,3,13 */
-		}
-	      else
-		{
-		  /* LE */
-		  if (toc_symndx != 0)
+		  bfd_put_32 (output_bfd, insn3, contents + offset + 4);
+		  if (tls_gd == 0 || toc_symndx != 0)
 		    {
-		      r_symndx = toc_symndx;
-		      rel->r_addend = toc_addend;
+		      /* We changed the symbol.  Start over in order
+			 to get h, sym, sec etc. right.  */
+		      rel--;
+		      continue;
 		    }
-		  r_type = R_PPC64_TPREL16_LO;
-		  rel->r_offset = offset + d_offset;
-		  insn2 = 0x38630000;	/* addi 3,3,0 */
 		}
-	      rel->r_info = ELF64_R_INFO (r_symndx, r_type);
-	      /* Zap the reloc on the _tls_get_addr call too.  */
-	      BFD_ASSERT (offset == rel[1].r_offset);
-	      rel[1].r_info = ELF64_R_INFO (ELF64_R_SYM (rel[1].r_info),
-					    R_PPC64_NONE);
-	      insn3 = bfd_get_32 (output_bfd,
-				  contents + offset + 4);
-	      if (insn3 == NOP
-		  || insn3 == CROR_151515 || insn3 == CROR_313131)
-		{
-		  rel->r_offset += 4;
-		  bfd_put_32 (output_bfd, insn2, contents + offset + 4);
-		  insn2 = NOP;
-		}
-	      bfd_put_32 (output_bfd, insn2, contents + offset);
-	      if ((tls_mask & TLS_TPRELGD) == 0 && toc_symndx != 0)
-		{
-		  rel--;
-		  continue;
-		}
 	    }
 	  break;
 
-	case R_PPC64_TLSLD:
-	  if (tls_mask != 0 && (tls_mask & TLS_LD) == 0)
-	    {
-	      unsigned int insn2, insn3;
-	      bfd_vma offset = rel->r_offset;
-
-	      if (toc_symndx)
-		sec = local_sections[toc_symndx];
-	      for (r_symndx = 0;
-		   r_symndx < symtab_hdr->sh_info;
-		   r_symndx++)
-		if (local_sections[r_symndx] == sec)
-		  break;
-	      if (r_symndx >= symtab_hdr->sh_info)
-		r_symndx = 0;
-	      rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET;
-	      if (r_symndx != 0)
-		rel->r_addend -= (local_syms[r_symndx].st_value
-				  + sec->output_offset
-				  + sec->output_section->vma);
-
-	      r_type = R_PPC64_TPREL16_LO;
-	      rel->r_info = ELF64_R_INFO (r_symndx, r_type);
-	      rel->r_offset = offset + d_offset;
-	      /* Zap the reloc on the _tls_get_addr call too.  */
-	      BFD_ASSERT (offset == rel[1].r_offset);
-	      rel[1].r_info = ELF64_R_INFO (ELF64_R_SYM (rel[1].r_info),
-					    R_PPC64_NONE);
-	      insn2 = 0x38630000;	/* addi 3,3,0 */
-	      insn3 = bfd_get_32 (output_bfd,
-				  contents + offset + 4);
-	      if (insn3 == NOP
-		  || insn3 == CROR_151515 || insn3 == CROR_313131)
-		{
-		  rel->r_offset += 4;
-		  bfd_put_32 (output_bfd, insn2, contents + offset + 4);
-		  insn2 = NOP;
-		}
-	      bfd_put_32 (output_bfd, insn2, contents + offset);
-	      rel--;
-	      continue;
-	    }
-	  break;
-
 	case R_PPC64_DTPMOD64:
 	  if (rel + 1 < relend
 	      && rel[1].r_info == ELF64_R_INFO (r_symndx, R_PPC64_DTPREL64)
@@ -10828,8 +10496,6 @@
 
 	case R_PPC64_NONE:
 	case R_PPC64_TLS:
-	case R_PPC64_TLSGD:
-	case R_PPC64_TLSLD:
 	case R_PPC64_GNU_VTINHERIT:
 	case R_PPC64_GNU_VTENTRY:
 	  continue;
@@ -10944,8 +10610,7 @@
 
 		*offp = off | 1;
 		if ((info->shared || indx != 0)
-		    && (offp == &ppc64_tlsld_got (input_bfd)->offset
-			|| h == NULL
+		    && (h == NULL
 			|| ELF_ST_VISIBILITY (h->elf.other) == STV_DEFAULT
 			|| h->elf.root.type != bfd_link_hash_undefweak))
 		  {
@@ -11189,7 +10854,7 @@
 	       && (h == NULL
 		   || ELF_ST_VISIBILITY (h->elf.other) == STV_DEFAULT
 		   || h->elf.root.type != bfd_link_hash_undefweak)
-	       && (must_be_dyn_reloc (info, r_type)
+	       && (MUST_BE_DYN_RELOC (r_type)
 		   || !SYMBOL_CALLS_LOCAL (info, &h->elf)))
 	      || (ELIMINATE_COPY_RELOCS
 		  && !info->shared
@@ -11274,7 +10939,7 @@
 		    {
 		      long indx = 0;
 
-		      if (r_symndx == 0 || bfd_is_abs_section (sec))
+		      if (bfd_is_abs_section (sec))
 			;
 		      else if (sec == NULL || sec->owner == NULL)
 			{

Modified: trunk/contrib/binutils/bfd/freebsd.h
===================================================================
--- trunk/contrib/binutils/bfd/freebsd.h	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/bfd/freebsd.h	2018-06-15 22:29:16 UTC (rev 11010)
@@ -19,7 +19,7 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
    USA.  */
 
-/* $FreeBSD: stable/11/contrib/binutils/bfd/freebsd.h 218822 2011-02-18 20:54:12Z dim $ */
+/* $FreeBSD: stable/10/contrib/binutils/bfd/freebsd.h 218822 2011-02-18 20:54:12Z dim $ */
 
 /* FreeBSD QMAGIC files have the header in the text. */
 #define	N_HEADER_IN_TEXT(x)	1

Modified: trunk/contrib/binutils/bfd/ihex.c
===================================================================
--- trunk/contrib/binutils/bfd/ihex.c	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/bfd/ihex.c	2018-06-15 22:29:16 UTC (rev 11010)
@@ -320,7 +320,7 @@
 	    {
 	      if (! ISHEX (buf[i]))
 		{
-		  ihex_bad_byte (abfd, lineno, hdr[i], error);
+		  ihex_bad_byte (abfd, lineno, buf[i], error);
 		  goto error_return;
 		}
 	    }

Modified: trunk/contrib/binutils/bfd/libbfd.h
===================================================================
--- trunk/contrib/binutils/bfd/libbfd.h	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/bfd/libbfd.h	2018-06-15 22:29:16 UTC (rev 11010)
@@ -1169,8 +1169,6 @@
   "BFD_RELOC_PPC64_PLTGOT16_DS",
   "BFD_RELOC_PPC64_PLTGOT16_LO_DS",
   "BFD_RELOC_PPC_TLS",
-  "BFD_RELOC_PPC_TLSGD",
-  "BFD_RELOC_PPC_TLSLD",
   "BFD_RELOC_PPC_DTPMOD",
   "BFD_RELOC_PPC_TPREL16",
   "BFD_RELOC_PPC_TPREL16_LO",

Modified: trunk/contrib/binutils/bfd/peXXigen.c
===================================================================
--- trunk/contrib/binutils/bfd/peXXigen.c	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/bfd/peXXigen.c	2018-06-15 22:29:16 UTC (rev 11010)
@@ -448,6 +448,17 @@
   {
     int idx;
 
+    /* PR 17512: Corrupt PE binaries can cause seg-faults.  */
+    if (a->NumberOfRvaAndSizes > 16)
+      {
+       (*_bfd_error_handler)
+	  (_("%B: aout header specifies an invalid number of data-directory entries: %d"),
+	   abfd, a->NumberOfRvaAndSizes);
+	/* Paranoia: If the number is corrupt, then assume that the
+	   actual entries themselves might be corrupt as well.  */
+	a->NumberOfRvaAndSizes = 0;
+      }
+
     for (idx = 0; idx < 16; idx++)
       {
         /* If data directory is empty, rva also should be 0.  */
@@ -1428,6 +1439,15 @@
 	}
     }
 
+  /* PR 17512: Handle corrupt PE binaries.  */
+  if (datasize < 36)
+    {
+      fprintf (file,
+	       _("\nThere is an export table in %s, but it is too small (%d)\n"),
+	       section->name, (int) datasize);
+      return TRUE;
+    }
+
   fprintf (file, _("\nThere is an export table in %s at 0x%lx\n"),
 	   section->name, (unsigned long) addr);
 

Modified: trunk/contrib/binutils/bfd/reloc.c
===================================================================
--- trunk/contrib/binutils/bfd/reloc.c	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/bfd/reloc.c	2018-06-15 22:29:16 UTC (rev 11010)
@@ -2627,10 +2627,6 @@
 ENUM
   BFD_RELOC_PPC_TLS
 ENUMX
-  BFD_RELOC_PPC_TLSGD
-ENUMX
-  BFD_RELOC_PPC_TLSLD
-ENUMX
   BFD_RELOC_PPC_DTPMOD
 ENUMX
   BFD_RELOC_PPC_TPREL16

Modified: trunk/contrib/binutils/bfd/section.c
===================================================================
--- trunk/contrib/binutils/bfd/section.c	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/bfd/section.c	2018-06-15 22:29:16 UTC (rev 11010)
@@ -1,6 +1,6 @@
 /* Object file "section" support for the BFD library.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -382,9 +382,6 @@
 .  {* Nonzero if this section has TLS related relocations.  *}
 .  unsigned int has_tls_reloc:1;
 .
-.  {* Nonzero if this section has a call to __tls_get_addr.  *}
-.  unsigned int has_tls_get_addr_call:1;
-.
 .  {* Nonzero if this section has a gp reloc.  *}
 .  unsigned int has_gp_reloc:1;
 .
@@ -645,11 +642,11 @@
 .  {* segment_mark, sec_info_type, use_rela_p, has_tls_reloc,       *}	\
 .     0,            0,             0,          0,			\
 .									\
-.  {* has_tls_get_addr_call, has_gp_reloc, need_finalize_relax,     *}	\
-.     0,                     0,            0,				\
+.  {* has_gp_reloc, need_finalize_relax, reloc_done,                *}	\
+.     0,            0,                   0,				\
 .									\
-.  {* reloc_done, vma, lma, size, rawsize                           *}	\
-.     0,          0,   0,   0,    0,					\
+.  {* vma, lma, size, rawsize                                       *}	\
+.     0,   0,   0,    0,						\
 .									\
 .  {* output_offset, output_section,              alignment_power,  *}	\
 .     0,             (struct bfd_section *) &SEC, 0,			\

Modified: trunk/contrib/binutils/gas/config/atof-ieee.c
===================================================================
--- trunk/contrib/binutils/gas/config/atof-ieee.c	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/gas/config/atof-ieee.c	2018-06-15 22:29:16 UTC (rev 11010)
@@ -420,8 +420,7 @@
 		     - generic_floating_point_number.low);
 
   /* Seek (and forget) 1st significant bit.  */
-  for (exponent_skippage = 0; !next_bits (1); ++exponent_skippage)
-	;;
+  for (exponent_skippage = 0; !next_bits (1); ++exponent_skippage);;
   exponent_1 = (generic_floating_point_number.exponent
 		+ generic_floating_point_number.leader
 		+ 1

Modified: trunk/contrib/binutils/gas/config/tc-arm.c
===================================================================
--- trunk/contrib/binutils/gas/config/tc-arm.c	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/gas/config/tc-arm.c	2018-06-15 22:29:16 UTC (rev 11010)
@@ -4720,23 +4720,6 @@
 	      return PARSE_OPERAND_FAIL;
 	}
     }
-  else if (skip_past_char (&p, ':') == SUCCESS)
-    {
-      /* FIXME: '@' should be used here, but it's filtered out by generic
-         code before we get to see it here. This may be subject to
-         change.  */
-      expressionS exp;
-      my_get_expression (&exp, &p, GE_NO_PREFIX);
-      if (exp.X_op != O_constant)
-        {
-          inst.error = _("alignment must be constant");
-          return PARSE_OPERAND_FAIL;
-        }
-      inst.operands[i].imm = exp.X_add_number << 8;
-      inst.operands[i].immisalign = 1;
-      /* Alignments are not pre-indexes.  */
-      inst.operands[i].preind = 0;
-    }
 
   if (skip_past_char (&p, ']') == FAIL)
     {
@@ -5211,6 +5194,12 @@
               inst.operands[i].present = 1;
             }
         }
+      else if (parse_qfloat_immediate (&ptr, &inst.operands[i].imm) == SUCCESS)
+          /* Case 2: VMOV<c><q>.<dt> <Qd>, #<float-imm>
+             Case 3: VMOV<c><q>.<dt> <Dd>, #<float-imm>
+             Case 10: VMOV.F32 <Sd>, #<imm>
+             Case 11: VMOV.F64 <Dd>, #<imm>  */
+        inst.operands[i].immisfloat = 1;
       else if ((val = arm_typed_reg_parse (&ptr, REG_TYPE_NSDQ, &rtype,
                                            &optype)) != FAIL)
         {
@@ -5247,15 +5236,9 @@
               
               inst.operands[i].reg = val;
               inst.operands[i].isreg = 1;
-              inst.operands[i].present = 1;
+              inst.operands[i++].present = 1;
             }
         }
-      else if (parse_qfloat_immediate (&ptr, &inst.operands[i].imm) == SUCCESS)
-          /* Case 2: VMOV<c><q>.<dt> <Qd>, #<float-imm>
-             Case 3: VMOV<c><q>.<dt> <Dd>, #<float-imm>
-             Case 10: VMOV.F32 <Sd>, #<imm>
-             Case 11: VMOV.F64 <Dd>, #<imm>  */
-        inst.operands[i].immisfloat = 1;
       else if (parse_big_immediate (&ptr, i) == SUCCESS)
           /* Case 2: VMOV<c><q>.<dt> <Qd>, #<imm>
              Case 3: VMOV<c><q>.<dt> <Dd>, #<imm>  */
@@ -5337,7 +5320,7 @@
           inst.operands[i].isvec = 1;
           inst.operands[i].issingle = 1;
           inst.operands[i].vectype = optype;
-          inst.operands[i].present = 1;
+          inst.operands[i++].present = 1;
         }
     }
   else
@@ -6620,7 +6603,6 @@
   if (inst.operands[0].present)
     {
       constraint ((inst.instruction & 0xf0) != 0x40
-		  && (inst.instruction & 0xf0) != 0x50
 		  && inst.operands[0].imm != 0xf,
 		  "bad barrier type");
       inst.instruction |= inst.operands[0].imm;
@@ -14748,18 +14730,10 @@
 
 static struct asm_barrier_opt barrier_opt_names[] =
 {
-  { "sy",    0xf },
-  { "un",    0x7 },
-  { "st",    0xe },
-  { "unst",  0x6 },
-  { "ish",   0xb },
-  { "sh",    0xb },
-  { "ishst", 0xa },
-  { "shst",  0xa },
-  { "nsh",   0x7 },
-  { "nshst", 0x6 },
-  { "osh",   0x3 },
-  { "oshst", 0x2 }
+  { "sy",   0xf },
+  { "un",   0x7 },
+  { "st",   0xe },
+  { "unst", 0x6 }
 };
 
 /* Table of ARM-format instructions.	*/

Modified: trunk/contrib/binutils/gas/config/tc-ia64.c
===================================================================
--- trunk/contrib/binutils/gas/config/tc-ia64.c	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/gas/config/tc-ia64.c	2018-06-15 22:29:16 UTC (rev 11010)
@@ -11567,7 +11567,7 @@
     err = (*odesc->insert) (odesc, value, insn + slot);
 
   if (err)
-    as_bad_where (fix->fx_file, fix->fx_line, "%s", err);
+    as_bad_where (fix->fx_file, fix->fx_line, err);
 
   t0 = control_bits | (insn[0] << 5) | (insn[1] << 46);
   t1 = ((insn[1] >> 18) & 0x7fffff) | (insn[2] << 23);

Modified: trunk/contrib/binutils/gas/config/tc-mips.c
===================================================================
--- trunk/contrib/binutils/gas/config/tc-mips.c	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/gas/config/tc-mips.c	2018-06-15 22:29:16 UTC (rev 11010)
@@ -15156,7 +15156,6 @@
 
   /* Cavium Networks Octeon CPU core */
   { "octeon",         0,      ISA_MIPS64R2,   CPU_OCTEON },
-  { "octeon+",        0,      ISA_MIPS64R2,   CPU_OCTEON },
 
   /* End marker */
   { NULL, 0, 0, 0 }

Modified: trunk/contrib/binutils/gas/config/tc-ppc.c
===================================================================
--- trunk/contrib/binutils/gas/config/tc-ppc.c	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/gas/config/tc-ppc.c	2018-06-15 22:29:16 UTC (rev 11010)
@@ -1210,7 +1210,7 @@
   return "elf32-powerpc-vxworks";
 # else
   return (target_big_endian
-	  ? (ppc_obj64 ? "elf64-powerpc-freebsd" : "elf32-powerpc-freebsd")
+	  ? (ppc_obj64 ? "elf64-powerpc" : "elf32-powerpc")
 	  : (ppc_obj64 ? "elf64-powerpcle" : "elf32-powerpcle"));
 # endif
 #endif
@@ -2509,157 +2509,109 @@
 				     (char *) NULL, 0);
 	}
 #ifdef OBJ_ELF
-      else
+      else if ((reloc = ppc_elf_suffix (&str, &ex)) != BFD_RELOC_UNUSED)
 	{
-	  if (ex.X_op == O_symbol && str[0] == '(')
+	  /* Some TLS tweaks.  */
+	  switch (reloc)
 	    {
-	      const char *sym_name = S_GET_NAME (ex.X_add_symbol);
-	      if (sym_name[0] == '.')
-		++sym_name;
+	    default:
+	      break;
+	    case BFD_RELOC_PPC_TLS:
+	      insn = ppc_insert_operand (insn, operand, ppc_obj64 ? 13 : 2,
+					 (char *) NULL, 0);
+	      break;
+	  /* We'll only use the 32 (or 64) bit form of these relocations
+	     in constants.  Instructions get the 16 bit form.  */
+	    case BFD_RELOC_PPC_DTPREL:
+	      reloc = BFD_RELOC_PPC_DTPREL16;
+	      break;
+	    case BFD_RELOC_PPC_TPREL:
+	      reloc = BFD_RELOC_PPC_TPREL16;
+	      break;
+	    }
 
-	      if (strcasecmp (sym_name, "__tls_get_addr") == 0)
+	  /* For the absolute forms of branches, convert the PC
+	     relative form back into the absolute.  */
+	  if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0)
+	    {
+	      switch (reloc)
 		{
-		  expressionS tls_exp;
-
-		  hold = input_line_pointer;
-		  input_line_pointer = str + 1;
-		  expression (&tls_exp);
-		  if (tls_exp.X_op == O_symbol)
-		    {
-		      reloc = BFD_RELOC_UNUSED;
-		      if (strncasecmp (input_line_pointer, "@tlsgd)", 7) == 0)
-			{
-			  reloc = BFD_RELOC_PPC_TLSGD;
-			  input_line_pointer += 7;
-			}
-		      else if (strncasecmp (input_line_pointer, "@tlsld)", 7) == 0)
-			{
-			  reloc = BFD_RELOC_PPC_TLSLD;
-			  input_line_pointer += 7;
-			}
-		      if (reloc != BFD_RELOC_UNUSED)
-			{
-			  SKIP_WHITESPACE ();
-			  str = input_line_pointer;
-
-			  if (fc >= MAX_INSN_FIXUPS)
-			    as_fatal (_("too many fixups"));
-			  fixups[fc].exp = tls_exp;
-			  fixups[fc].opindex = *opindex_ptr;
-			  fixups[fc].reloc = reloc;
-			  ++fc;
-			}
-		    }
-		  input_line_pointer = hold;
+		case BFD_RELOC_PPC_B26:
+		  reloc = BFD_RELOC_PPC_BA26;
+		  break;
+		case BFD_RELOC_PPC_B16:
+		  reloc = BFD_RELOC_PPC_BA16;
+		  break;
+		case BFD_RELOC_PPC_B16_BRTAKEN:
+		  reloc = BFD_RELOC_PPC_BA16_BRTAKEN;
+		  break;
+		case BFD_RELOC_PPC_B16_BRNTAKEN:
+		  reloc = BFD_RELOC_PPC_BA16_BRNTAKEN;
+		  break;
+		default:
+		  break;
 		}
 	    }
 
-	  if ((reloc = ppc_elf_suffix (&str, &ex)) != BFD_RELOC_UNUSED)
+	  if (ppc_obj64
+	      && (operand->flags & (PPC_OPERAND_DS | PPC_OPERAND_DQ)) != 0)
 	    {
-	      /* Some TLS tweaks.  */
 	      switch (reloc)
 		{
-		default:
+		case BFD_RELOC_16:
+		  reloc = BFD_RELOC_PPC64_ADDR16_DS;
 		  break;
-
-		case BFD_RELOC_PPC_TLS:
-		  insn = ppc_insert_operand (insn, operand, ppc_obj64 ? 13 : 2,
-					     (char *) NULL, 0);
+		case BFD_RELOC_LO16:
+		  reloc = BFD_RELOC_PPC64_ADDR16_LO_DS;
 		  break;
-
-		  /* We'll only use the 32 (or 64) bit form of these relocations
-		     in constants.  Instructions get the 16 bit form.  */
-		case BFD_RELOC_PPC_DTPREL:
-		  reloc = BFD_RELOC_PPC_DTPREL16;
+		case BFD_RELOC_16_GOTOFF:
+		  reloc = BFD_RELOC_PPC64_GOT16_DS;
 		  break;
-		case BFD_RELOC_PPC_TPREL:
-		  reloc = BFD_RELOC_PPC_TPREL16;
+		case BFD_RELOC_LO16_GOTOFF:
+		  reloc = BFD_RELOC_PPC64_GOT16_LO_DS;
 		  break;
+		case BFD_RELOC_LO16_PLTOFF:
+		  reloc = BFD_RELOC_PPC64_PLT16_LO_DS;
+		  break;
+		case BFD_RELOC_16_BASEREL:
+		  reloc = BFD_RELOC_PPC64_SECTOFF_DS;
+		  break;
+		case BFD_RELOC_LO16_BASEREL:
+		  reloc = BFD_RELOC_PPC64_SECTOFF_LO_DS;
+		  break;
+		case BFD_RELOC_PPC_TOC16:
+		  reloc = BFD_RELOC_PPC64_TOC16_DS;
+		  break;
+		case BFD_RELOC_PPC64_TOC16_LO:
+		  reloc = BFD_RELOC_PPC64_TOC16_LO_DS;
+		  break;
+		case BFD_RELOC_PPC64_PLTGOT16:
+		  reloc = BFD_RELOC_PPC64_PLTGOT16_DS;
+		  break;
+		case BFD_RELOC_PPC64_PLTGOT16_LO:
+		  reloc = BFD_RELOC_PPC64_PLTGOT16_LO_DS;
+		  break;
+		case BFD_RELOC_PPC_DTPREL16:
+		  reloc = BFD_RELOC_PPC64_DTPREL16_DS;
+		  break;
+		case BFD_RELOC_PPC_DTPREL16_LO:
+		  reloc = BFD_RELOC_PPC64_DTPREL16_LO_DS;
+		  break;
+		case BFD_RELOC_PPC_TPREL16:
+		  reloc = BFD_RELOC_PPC64_TPREL16_DS;
+		  break;
+		case BFD_RELOC_PPC_TPREL16_LO:
+		  reloc = BFD_RELOC_PPC64_TPREL16_LO_DS;
+		  break;
+		case BFD_RELOC_PPC_GOT_DTPREL16:
+		case BFD_RELOC_PPC_GOT_DTPREL16_LO:
+		case BFD_RELOC_PPC_GOT_TPREL16:
+		case BFD_RELOC_PPC_GOT_TPREL16_LO:
+		  break;
+		default:
+		  as_bad (_("unsupported relocation for DS offset field"));
+		  break;
 		}
-
-	      /* For the absolute forms of branches, convert the PC
-		 relative form back into the absolute.  */
-	      if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0)
-		{
-		  switch (reloc)
-		    {
-		    case BFD_RELOC_PPC_B26:
-		      reloc = BFD_RELOC_PPC_BA26;
-		      break;
-		    case BFD_RELOC_PPC_B16:
-		      reloc = BFD_RELOC_PPC_BA16;
-		      break;
-		    case BFD_RELOC_PPC_B16_BRTAKEN:
-		      reloc = BFD_RELOC_PPC_BA16_BRTAKEN;
-		      break;
-		    case BFD_RELOC_PPC_B16_BRNTAKEN:
-		      reloc = BFD_RELOC_PPC_BA16_BRNTAKEN;
-		      break;
-		    default:
-		      break;
-		    }
-		}
-
-	      if (ppc_obj64
-		  && (operand->flags & (PPC_OPERAND_DS | PPC_OPERAND_DQ)) != 0)
-		{
-		  switch (reloc)
-		    {
-		    case BFD_RELOC_16:
-		      reloc = BFD_RELOC_PPC64_ADDR16_DS;
-		      break;
-		    case BFD_RELOC_LO16:
-		      reloc = BFD_RELOC_PPC64_ADDR16_LO_DS;
-		      break;
-		    case BFD_RELOC_16_GOTOFF:
-		      reloc = BFD_RELOC_PPC64_GOT16_DS;
-		      break;
-		    case BFD_RELOC_LO16_GOTOFF:
-		      reloc = BFD_RELOC_PPC64_GOT16_LO_DS;
-		      break;
-		    case BFD_RELOC_LO16_PLTOFF:
-		      reloc = BFD_RELOC_PPC64_PLT16_LO_DS;
-		      break;
-		    case BFD_RELOC_16_BASEREL:
-		      reloc = BFD_RELOC_PPC64_SECTOFF_DS;
-		      break;
-		    case BFD_RELOC_LO16_BASEREL:
-		      reloc = BFD_RELOC_PPC64_SECTOFF_LO_DS;
-		      break;
-		    case BFD_RELOC_PPC_TOC16:
-		      reloc = BFD_RELOC_PPC64_TOC16_DS;
-		      break;
-		    case BFD_RELOC_PPC64_TOC16_LO:
-		      reloc = BFD_RELOC_PPC64_TOC16_LO_DS;
-		      break;
-		    case BFD_RELOC_PPC64_PLTGOT16:
-		      reloc = BFD_RELOC_PPC64_PLTGOT16_DS;
-		      break;
-		    case BFD_RELOC_PPC64_PLTGOT16_LO:
-		      reloc = BFD_RELOC_PPC64_PLTGOT16_LO_DS;
-		      break;
-		    case BFD_RELOC_PPC_DTPREL16:
-		      reloc = BFD_RELOC_PPC64_DTPREL16_DS;
-		      break;
-		    case BFD_RELOC_PPC_DTPREL16_LO:
-		      reloc = BFD_RELOC_PPC64_DTPREL16_LO_DS;
-		      break;
-		    case BFD_RELOC_PPC_TPREL16:
-		      reloc = BFD_RELOC_PPC64_TPREL16_DS;
-		      break;
-		    case BFD_RELOC_PPC_TPREL16_LO:
-		      reloc = BFD_RELOC_PPC64_TPREL16_LO_DS;
-		      break;
-		    case BFD_RELOC_PPC_GOT_DTPREL16:
-		    case BFD_RELOC_PPC_GOT_DTPREL16_LO:
-		    case BFD_RELOC_PPC_GOT_TPREL16:
-		    case BFD_RELOC_PPC_GOT_TPREL16_LO:
-		      break;
-		    default:
-		      as_bad (_("unsupported relocation for DS offset field"));
-		      break;
-		    }
-		}
 	    }
 
 	  /* We need to generate a fixup for this expression.  */
@@ -2666,11 +2618,12 @@
 	  if (fc >= MAX_INSN_FIXUPS)
 	    as_fatal (_("too many fixups"));
 	  fixups[fc].exp = ex;
-	  fixups[fc].opindex = *opindex_ptr;
+	  fixups[fc].opindex = 0;
 	  fixups[fc].reloc = reloc;
 	  ++fc;
 	}
-#else /* OBJ_ELF */
+#endif /* OBJ_ELF */
+
       else
 	{
 	  /* We need to generate a fixup for this expression.  */
@@ -2681,7 +2634,6 @@
 	  fixups[fc].reloc = BFD_RELOC_UNUSED;
 	  ++fc;
 	}
-#endif /* OBJ_ELF */
 
       if (need_paren)
 	{
@@ -5956,8 +5908,6 @@
 	  break;
 
 	case BFD_RELOC_PPC_TLS:
-	case BFD_RELOC_PPC_TLSLD:
-	case BFD_RELOC_PPC_TLSGD:
 	  break;
 
 	case BFD_RELOC_PPC_DTPMOD:

Modified: trunk/contrib/binutils/gas/doc/c-arm.texi
===================================================================
--- trunk/contrib/binutils/gas/doc/c-arm.texi	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/gas/doc/c-arm.texi	2018-06-15 22:29:16 UTC (rev 11010)
@@ -317,6 +317,13 @@
 @cindex register names, ARM
 *TODO* Explain about ARM register naming, and the predefined names.
 
+ at node ARM Floating Point
+ at section Floating Point
+
+ at cindex floating point, ARM (@sc{ieee})
+ at cindex ARM floating point (@sc{ieee})
+The ARM family uses @sc{ieee} floating-point numbers.
+
 @node ARM-Relocations
 @subsection ARM relocation generation
 
@@ -358,13 +365,6 @@
         MOVT r0, #:upper16:foo
 @end smallexample
 
- at node ARM Floating Point
- at section Floating Point
-
- at cindex floating point, ARM (@sc{ieee})
- at cindex ARM floating point (@sc{ieee})
-The ARM family uses @sc{ieee} floating-point numbers.
-
 @node ARM Directives
 @section ARM Machine Directives
 

Modified: trunk/contrib/binutils/gas/doc/c-mips.texi
===================================================================
--- trunk/contrib/binutils/gas/doc/c-mips.texi	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/gas/doc/c-mips.texi	2018-06-15 22:29:16 UTC (rev 11010)
@@ -196,7 +196,7 @@
 instructions around accesses to the @samp{HI} and @samp{LO} registers.
 @samp{-no-m4650} turns off this option.
 
- at item -m3900
+ at itemx -m3900
 @itemx -no-m3900
 @itemx -m4100
 @itemx -no-m4100

Modified: trunk/contrib/binutils/gas/symbols.c
===================================================================
--- trunk/contrib/binutils/gas/symbols.c	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/gas/symbols.c	2018-06-15 22:29:16 UTC (rev 11010)
@@ -1666,8 +1666,7 @@
       *q = i % 10 + '0';
       i /= 10;
     }
-  while ((*p++ = *--q) != '\0')
-	;;
+  while ((*p++ = *--q) != '\0');;
 
   /* The label, as a '\0' ended string, starts at symbol_name_build.  */
   return symbol_name_build;
@@ -1838,8 +1837,7 @@
       *q = i % 10 + '0';
       i /= 10;
     }
-  while ((*p++ = *--q) != '\0')
-	;;
+  while ((*p++ = *--q) != '\0');;
 
   /* The label, as a '\0' ended string, starts at symbol_name_build.  */
   return (symbol_name_build);

Modified: trunk/contrib/binutils/include/elf/ChangeLog
===================================================================
--- trunk/contrib/binutils/include/elf/ChangeLog	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/include/elf/ChangeLog	2018-06-15 22:29:16 UTC (rev 11010)
@@ -1,8 +1,3 @@
-2009-03-04  Alan Modra  <amodra at bigpond.net.au>
-
-	* ppc.h (R_PPC_TLSGD, R_PPC_TLSLD): Add new relocs.
-	* ppc64.h (R_PPC64_TLSGD, R_PPC64_TLSLD): Add new relocs.
-
 2007-06-29  Joseph Myers  <joseph at codesourcery.com>
 
 	* ppc.h (Tag_GNU_Power_ABI_FP): Define.

Modified: trunk/contrib/binutils/include/elf/arm.h
===================================================================
--- trunk/contrib/binutils/include/elf/arm.h	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/include/elf/arm.h	2018-06-15 22:29:16 UTC (rev 11010)
@@ -271,12 +271,6 @@
   Tag_ABI_optimization_goals,
   Tag_ABI_FP_optimization_goals,
   /* 32 is generic.  */
-  Tag_CPU_unaligned_access = 34,
-  Tag_FP_HP_extension = 36,
-  Tag_ABI_FP_16bit_format = 38,
-  Tag_MPextension_use = 42,
-  Tag_DIV_use = 44,
-  Tag_Virtualization_use = 68,
 };
 
 #endif

Modified: trunk/contrib/binutils/include/elf/ppc.h
===================================================================
--- trunk/contrib/binutils/include/elf/ppc.h	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/include/elf/ppc.h	2018-06-15 22:29:16 UTC (rev 11010)
@@ -100,8 +100,6 @@
   RELOC_NUMBER (R_PPC_GOT_DTPREL16_LO,	 92)
   RELOC_NUMBER (R_PPC_GOT_DTPREL16_HI,	 93)
   RELOC_NUMBER (R_PPC_GOT_DTPREL16_HA,	 94)
-  RELOC_NUMBER (R_PPC_TLSGD,		 95)
-  RELOC_NUMBER (R_PPC_TLSLD,		 96)
 
 /* The remaining relocs are from the Embedded ELF ABI, and are not
    in the SVR4 ELF ABI.  */

Modified: trunk/contrib/binutils/include/elf/ppc64.h
===================================================================
--- trunk/contrib/binutils/include/elf/ppc64.h	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/include/elf/ppc64.h	2018-06-15 22:29:16 UTC (rev 11010)
@@ -1,5 +1,5 @@
 /* PPC64 ELF support for BFD.
-   Copyright 2003, 2005, 2009 Free Software Foundation, Inc.
+   Copyright 2003 Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
 
@@ -136,8 +136,6 @@
   RELOC_NUMBER (R_PPC64_DTPREL16_HIGHERA,  104)
   RELOC_NUMBER (R_PPC64_DTPREL16_HIGHEST,  105)
   RELOC_NUMBER (R_PPC64_DTPREL16_HIGHESTA, 106)
-  RELOC_NUMBER (R_PPC64_TLSGD,		   107)
-  RELOC_NUMBER (R_PPC64_TLSLD,		   108)
 
   /* These are GNU extensions to enable C++ vtable garbage collection.  */
   RELOC_NUMBER (R_PPC64_GNU_VTINHERIT,	   253)

Modified: trunk/contrib/binutils/include/libiberty.h
===================================================================
--- trunk/contrib/binutils/include/libiberty.h	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/include/libiberty.h	2018-06-15 22:29:16 UTC (rev 11010)
@@ -102,7 +102,7 @@
    is 1, we found it so don't provide any declaration at all.  */
 #if !HAVE_DECL_BASENAME
 #if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined(__NetBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__) || defined (__MINGW32__) || defined (HAVE_DECL_BASENAME)
-#include <libgen.h>
+extern char *basename (const char *);
 #else
 /* Do not allow basename to be used if there is no prototype seen.  We
    either need to use the above prototype or have one from

Modified: trunk/contrib/binutils/ld/Makefile.in
===================================================================
--- trunk/contrib/binutils/ld/Makefile.in	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/ld/Makefile.in	2018-06-15 22:29:16 UTC (rev 11010)
@@ -12,7 +12,7 @@
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
-# $FreeBSD: stable/11/contrib/binutils/ld/Makefile.in 218822 2011-02-18 20:54:12Z dim $
+# $FreeBSD: stable/10/contrib/binutils/ld/Makefile.in 218822 2011-02-18 20:54:12Z dim $
 
 @SET_MAKE@
 

Modified: trunk/contrib/binutils/ld/emulparams/elf32ppc_fbsd.sh
===================================================================
--- trunk/contrib/binutils/ld/emulparams/elf32ppc_fbsd.sh	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/ld/emulparams/elf32ppc_fbsd.sh	2018-06-15 22:29:16 UTC (rev 11010)
@@ -1,4 +1,2 @@
 . ${srcdir}/emulparams/elf32ppc.sh
 . ${srcdir}/emulparams/elf_fbsd.sh
-
-OUTPUT_FORMAT="elf32-powerpc-freebsd"

Modified: trunk/contrib/binutils/ld/emulparams/elf64ppc_fbsd.sh
===================================================================
--- trunk/contrib/binutils/ld/emulparams/elf64ppc_fbsd.sh	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/ld/emulparams/elf64ppc_fbsd.sh	2018-06-15 22:29:16 UTC (rev 11010)
@@ -1,4 +1,3 @@
 . ${srcdir}/emulparams/elf64ppc.sh
 . ${srcdir}/emulparams/elf_fbsd.sh
 
-OUTPUT_FORMAT="elf64-powerpc-freebsd"

Modified: trunk/contrib/binutils/ld/ld.texinfo
===================================================================
--- trunk/contrib/binutils/ld/ld.texinfo	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/ld/ld.texinfo	2018-06-15 22:29:16 UTC (rev 11010)
@@ -1725,7 +1725,7 @@
 
 @kindex --version-script=@var{version-scriptfile}
 @cindex version script, symbol versions
- at item --version-script=@var{version-scriptfile}
+ at itemx --version-script=@var{version-scriptfile}
 Specify the name of a version script to the linker.  This is typically
 used when creating shared libraries to specify additional information
 about the version hierarchy for the library being created.  This option

Modified: trunk/contrib/binutils/opcodes/i386-dis.c
===================================================================
--- trunk/contrib/binutils/opcodes/i386-dis.c	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/opcodes/i386-dis.c	2018-06-15 22:29:16 UTC (rev 11010)
@@ -85,7 +85,6 @@
 static void OP_XS (int, int);
 static void OP_M (int, int);
 static void OP_VMX (int, int);
-static void OP_VMX2 (int, int);
 static void OP_0fae (int, int);
 static void OP_0f07 (int, int);
 static void NOP_Fixup1 (int, int);
@@ -319,7 +318,6 @@
 #define EMC { OP_EMC, v_mode }
 #define MXC { OP_MXC, 0 }
 #define VM { OP_VMX, q_mode }
-#define VM2 { OP_VMX2, q_mode }
 #define OPSUF { OP_3DNowSuffix, 0 }
 #define OPSIMD { OP_SIMD_Suffix, 0 }
 #define XMM0 { XMM_Fixup, 0 }
@@ -1302,7 +1300,7 @@
   /* 70 */ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, /* 7f */
   /* 80 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 8f */
   /* 90 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 9f */
-  /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0, /* af */
+  /* a0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* af */
   /* b0 */ 0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0, /* bf */
   /* c0 */ 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
   /* d0 */ 0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, /* df */
@@ -1734,7 +1732,7 @@
     { "(bad)",	{ XX } },
     { "(bad)",	{ XX } },
     { "",	{ VM } },		/* See OP_VMX.  */
-    { "",	{ VM2 } },		/* See OP_VMX2.  */
+    { "vmptrst", { Mq } },
   },
   /* GRP11_C6 */
   {
@@ -1793,10 +1791,10 @@
   },
   /* GRP15 */
   {
-    { "fxsave",		{ { OP_0fae, v_mode } } },
-    { "fxrstor",	{ { OP_0fae, v_mode } } },
-    { "ldmxcsr",	{ { OP_0fae, v_mode } } },
-    { "stmxcsr",	{ { OP_0fae, v_mode } } },
+    { "fxsave",		{ Ev } },
+    { "fxrstor",	{ Ev } },
+    { "ldmxcsr",	{ Ev } },
+    { "stmxcsr",	{ Ev } },
     { "xsave",		{ Ev } },
     { "xrstor",		{ { OP_0fae, v_mode } } },
     { "xsaveopt",	{ { OP_0fae, v_mode } } },
@@ -3476,7 +3474,7 @@
  * The function returns the length of this instruction in bytes.
  */
 
-static int intel_syntax;
+static char intel_syntax;
 static char open_char;
 static char close_char;
 static char separator_char;
@@ -3549,7 +3547,7 @@
   else
     address_mode = mode_32bit;
 
-  if (intel_syntax == -1)
+  if (intel_syntax == (char) -1)
     intel_syntax = (info->mach == bfd_mach_i386_i386_intel_syntax
 		    || info->mach == bfd_mach_x86_64_intel_syntax);
 
@@ -4328,7 +4326,7 @@
 static void
 OP_ST (int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
 {
-  oappend (&"%st"[intel_syntax]);
+  oappend ("%st" + intel_syntax);
 }
 
 static void
@@ -4679,32 +4677,32 @@
   if (prefixes & PREFIX_CS)
     {
       used_prefixes |= PREFIX_CS;
-      oappend (&"%cs:"[intel_syntax]);
+      oappend ("%cs:" + intel_syntax);
     }
   if (prefixes & PREFIX_DS)
     {
       used_prefixes |= PREFIX_DS;
-      oappend (&"%ds:"[intel_syntax]);
+      oappend ("%ds:" + intel_syntax);
     }
   if (prefixes & PREFIX_SS)
     {
       used_prefixes |= PREFIX_SS;
-      oappend (&"%ss:"[intel_syntax]);
+      oappend ("%ss:" + intel_syntax);
     }
   if (prefixes & PREFIX_ES)
     {
       used_prefixes |= PREFIX_ES;
-      oappend (&"%es:"[intel_syntax]);
+      oappend ("%es:" + intel_syntax);
     }
   if (prefixes & PREFIX_FS)
     {
       used_prefixes |= PREFIX_FS;
-      oappend (&"%fs:"[intel_syntax]);
+      oappend ("%fs:" + intel_syntax);
     }
   if (prefixes & PREFIX_GS)
     {
       used_prefixes |= PREFIX_GS;
-      oappend (&"%gs:"[intel_syntax]);
+      oappend ("%gs:" + intel_syntax);
     }
 }
 
@@ -5476,7 +5474,7 @@
   op &= mask;
   scratchbuf[0] = '$';
   print_operand_value (scratchbuf + 1, 1, op);
-  oappend (&scratchbuf[intel_syntax]);
+  oappend (scratchbuf + intel_syntax);
   scratchbuf[0] = '\0';
 }
 
@@ -5527,7 +5525,7 @@
   op &= mask;
   scratchbuf[0] = '$';
   print_operand_value (scratchbuf + 1, 1, op);
-  oappend (&scratchbuf[intel_syntax]);
+  oappend (scratchbuf + intel_syntax);
   scratchbuf[0] = '\0';
 }
 
@@ -5577,7 +5575,7 @@
 
   scratchbuf[0] = '$';
   print_operand_value (scratchbuf + 1, 1, op);
-  oappend (&scratchbuf[intel_syntax]);
+  oappend (scratchbuf + intel_syntax);
 }
 
 static void
@@ -5757,7 +5755,7 @@
 	  intel_operand_size (b_mode, sizeflag);
 	}
     }
-  oappend (&"%es:"[intel_syntax]);
+  oappend ("%es:" + intel_syntax);
   ptr_reg (code, sizeflag);
 }
 
@@ -5807,7 +5805,7 @@
       add = 8;
     }
   sprintf (scratchbuf, "%%cr%d", modrm.reg + add);
-  oappend (&scratchbuf[intel_syntax]);
+  oappend (scratchbuf + intel_syntax);
 }
 
 static void
@@ -5828,7 +5826,7 @@
 OP_T (int dummy ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED)
 {
   sprintf (scratchbuf, "%%tr%d", modrm.reg);
-  oappend (&scratchbuf[intel_syntax]);
+  oappend (scratchbuf + intel_syntax);
 }
 
 static void
@@ -5854,7 +5852,7 @@
     }
   else
     sprintf (scratchbuf, "%%mm%d", modrm.reg);
-  oappend (&scratchbuf[intel_syntax]);
+  oappend (scratchbuf + intel_syntax);
 }
 
 static void
@@ -5865,7 +5863,7 @@
   if (rex & REX_R)
     add = 8;
   sprintf (scratchbuf, "%%xmm%d", modrm.reg + add);
-  oappend (&scratchbuf[intel_syntax]);
+  oappend (scratchbuf + intel_syntax);
 }
 
 static void
@@ -5897,7 +5895,7 @@
     }
   else
     sprintf (scratchbuf, "%%mm%d", modrm.rm);
-  oappend (&scratchbuf[intel_syntax]);
+  oappend (scratchbuf + intel_syntax);
 }
 
 /* cvt* are the only instructions in sse2 which have
@@ -5924,7 +5922,7 @@
   codep++;
   used_prefixes |= (prefixes & PREFIX_DATA);
   sprintf (scratchbuf, "%%mm%d", modrm.rm);
-  oappend (&scratchbuf[intel_syntax]);
+  oappend (scratchbuf + intel_syntax);
 }
 
 static void
@@ -5932,7 +5930,7 @@
 {
   used_prefixes |= (prefixes & PREFIX_DATA);
   sprintf (scratchbuf, "%%mm%d", modrm.reg);
-  oappend (&scratchbuf[intel_syntax]);
+  oappend (scratchbuf + intel_syntax);
 }
 
 static void
@@ -5952,7 +5950,7 @@
   MODRM_CHECK;
   codep++;
   sprintf (scratchbuf, "%%xmm%d", modrm.rm + add);
-  oappend (&scratchbuf[intel_syntax]);
+  oappend (scratchbuf + intel_syntax);
 }
 
 static void
@@ -5997,34 +5995,19 @@
 {
   if (modrm.mod == 3)
     {
-      if (modrm.reg >= 5 && modrm.reg <= 7 && modrm.rm == 0)
+      if (modrm.reg == 7)
+	strcpy (obuf + strlen (obuf) - sizeof ("clflush") + 1, "sfence");
+      else if (modrm.reg == 6)
+	strcpy (obuf + strlen (obuf) - sizeof ("xsaveopt") + 1, "mfence");
+      else if (modrm.reg == 5)
+	strcpy (obuf + strlen (obuf) - sizeof ("xrstor") + 1, "lfence");
+
+      if (modrm.reg < 5 || modrm.rm != 0)
 	{
-	  if (modrm.reg == 7)
-	    strcpy (obuf + strlen (obuf) - sizeof ("clflush") + 1, "sfence");
-	  else if (modrm.reg == 6)
-	    strcpy (obuf + strlen (obuf) - sizeof ("xsaveopt") + 1, "mfence");
-	  else if (modrm.reg == 5)
-	    strcpy (obuf + strlen (obuf) - sizeof ("xrstor") + 1, "lfence");
-	  bytemode = 0;
-	}
-      else if (modrm.reg <= 3 && (prefixes & PREFIX_REPZ) != 0)
-	{
-	  if (modrm.reg == 0)
-	    strcpy (obuf + strlen (obuf) - sizeof ("fxsave") + 1, "rdfsbase");
-	  else if (modrm.reg == 1)
-	    strcpy (obuf + strlen (obuf) - sizeof ("fxrstor") + 1, "rdgsbase");
-	  else if (modrm.reg == 2)
-	    strcpy (obuf + strlen (obuf) - sizeof ("ldmxcsr") + 1, "wrfsbase");
-	  else if (modrm.reg == 3)
-	    strcpy (obuf + strlen (obuf) - sizeof ("stmxcsr") + 1, "wrgsbase");
-	  used_prefixes |= PREFIX_REPZ;
-	  bytemode = dq_mode;
-	}
-      else
-	{
-	  BadOp ();
+	  BadOp ();	/* bad sfence, mfence, or lfence */
 	  return;
 	}
+      bytemode = 0;
     }
 
   OP_E (bytemode, sizeflag);
@@ -6484,21 +6467,6 @@
 }
 
 static void
-OP_VMX2 (int bytemode, int sizeflag)
-{
-  if (modrm.mod == 3)
-    {
-      strcpy (obuf, "rdseed");
-      OP_E (v_mode, sizeflag);
-    }
-  else
-    {
-      strcpy (obuf, "vmptrst");
-      OP_M (q_mode, sizeflag);
-    }
-}
-
-static void
 REP_Fixup (int bytemode, int sizeflag)
 {
   /* The 0xf3 prefix should be displayed as "rep" for ins, outs, movs,
@@ -6589,7 +6557,7 @@
 XMM_Fixup (int reg, int sizeflag ATTRIBUTE_UNUSED)
 {
   sprintf (scratchbuf, "%%xmm%d", reg);
-  oappend (&scratchbuf[intel_syntax]);
+  oappend (scratchbuf + intel_syntax);
 }
 
 static void

Modified: trunk/contrib/binutils/opcodes/i386-opc.h
===================================================================
--- trunk/contrib/binutils/opcodes/i386-opc.h	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/opcodes/i386-opc.h	2018-06-15 22:29:16 UTC (rev 11010)
@@ -81,7 +81,6 @@
 #define CpuPCLMUL   0x10000000	/* Carry-less Multiplication extensions */
 #define CpuRdRnd    0x20000000	/* Intel Random Number Generator extensions */
 #define CpuSMAP     0x40000000	/* Intel Supervisor Mode Access Prevention */
-#define CpuFSGSBase 0x80000000	/* Read/write fs/gs segment base registers */
 
 /* SSE4.1/4.2 Instructions required */
 #define CpuSSE4	     (CpuSSE4_1|CpuSSE4_2)
@@ -90,8 +89,7 @@
 #define CpuUnknownFlags (Cpu186|Cpu286|Cpu386|Cpu486|Cpu586|Cpu686 \
 	|CpuP4|CpuSledgehammer|CpuMMX|CpuMMX2|CpuSSE|CpuSSE2|CpuSSE3|CpuVMX \
 	|Cpu3dnow|Cpu3dnowA|CpuK6|CpuPadLock|CpuSVME|CpuSSSE3|CpuSSE4_1 \
-	|CpuSSE4_2|CpuABM|CpuSSE4a|CpuXSAVE|CpuAES|CpuPCLMUL|CpuRdRnd|CpuSMAP \
-	|CpuFSGSBase)
+	|CpuSSE4_2|CpuABM|CpuSSE4a|CpuXSAVE|CpuAES|CpuPCLMUL|CpuRdRnd|CpuSMAP)
 
   /* the bits in opcode_modifier are used to generate the final opcode from
      the base_opcode.  These bits also are used to detect alternate forms of

Modified: trunk/contrib/binutils/opcodes/i386-opc.tbl
===================================================================
--- trunk/contrib/binutils/opcodes/i386-opc.tbl	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/opcodes/i386-opc.tbl	2018-06-15 22:29:16 UTC (rev 11010)
@@ -1524,14 +1524,3 @@
 
 // Intel Random Number Generator extensions
 rdrand, 1, 0x0fc7, 0x6, CpuRdRnd, Modrm|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_xSuf, { Reg16|Reg32|Reg64 }
-rdseed, 1, 0x0fc7, 0x7, CpuRdRnd, Modrm|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_xSuf, { Reg16|Reg32|Reg64 }
-
-// Intel Supervisor Mode Access Prevention extensions
-clac, 0, 0x0f01, 0xca, CpuSMAP, NoSuf|ImmExt, { 0 }
-stac, 0, 0x0f01, 0xcb, CpuSMAP, NoSuf|ImmExt, { 0 }
-
-// Read/write fs/gs segment base registers
-rdfsbase, 1, 0xf30fae, 0x0, CpuFSGSBase|Cpu64, Modrm|No_bSuf|No_wSuf|No_sSuf|No_xSuf, { Reg32|Reg64 }
-rdgsbase, 1, 0xf30fae, 0x1, CpuFSGSBase|Cpu64, Modrm|No_bSuf|No_wSuf|No_sSuf|No_xSuf, { Reg32|Reg64 }
-wrfsbase, 1, 0xf30fae, 0x2, CpuFSGSBase|Cpu64, Modrm|No_bSuf|No_wSuf|No_sSuf|No_xSuf, { Reg32|Reg64 }
-wrgsbase, 1, 0xf30fae, 0x3, CpuFSGSBase|Cpu64, Modrm|No_bSuf|No_wSuf|No_sSuf|No_xSuf, { Reg32|Reg64 }

Modified: trunk/contrib/binutils/opcodes/i386-tbl.h
===================================================================
--- trunk/contrib/binutils/opcodes/i386-tbl.h	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/opcodes/i386-tbl.h	2018-06-15 22:29:16 UTC (rev 11010)
@@ -4391,9 +4391,6 @@
   {"rdrand", 1, 0x0fc7, 0x6, CpuRdRnd,
     Modrm|NoSuf,
     { Reg16|Reg32|Reg64 } },
-  {"rdseed", 1, 0x0fc7, 0x7, CpuRdRnd,
-    Modrm|NoSuf,
-    { Reg16|Reg32|Reg64 } },
 
   /* Intel Supervisor Mode Access Prevention extensions */
   {"clac", 0, 0x0f01, 0xca, CpuSMAP,
@@ -4400,20 +4397,6 @@
     NoSuf|ImmExt, { 0, 0, 0 } },
   {"stac", 0, 0x0f01, 0xcb, CpuSMAP,
     NoSuf|ImmExt, { 0, 0, 0 } },
-
-  /* Read/write fs/gs segment base registers */
-  {"rdfsbase", 1, 0xf30fae, 0x0, CpuFSGSBase|Cpu64,
-    Modrm|No_bSuf|No_wSuf|No_sSuf|No_xSuf,
-    { Reg32|Reg64 } },
-  {"rdgsbase", 1, 0xf30fae, 0x1, CpuFSGSBase|Cpu64,
-    Modrm|No_bSuf|No_wSuf|No_sSuf|No_xSuf,
-    { Reg32|Reg64 } },
-  {"wrfsbase", 1, 0xf30fae, 0x2, CpuFSGSBase|Cpu64,
-    Modrm|No_bSuf|No_wSuf|No_sSuf|No_xSuf,
-    { Reg32|Reg64 } },
-  {"wrgsbase", 1, 0xf30fae, 0x3, CpuFSGSBase|Cpu64,
-    Modrm|No_bSuf|No_wSuf|No_sSuf|No_xSuf,
-    { Reg32|Reg64 } },
   
   { NULL, 0, 0, 0, 0, 0, { 0 } }
 };

Modified: trunk/contrib/binutils/opcodes/ia64-asmtab.c
===================================================================
--- trunk/contrib/binutils/opcodes/ia64-asmtab.c	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/opcodes/ia64-asmtab.c	2018-06-15 22:29:16 UTC (rev 11010)
@@ -82,7 +82,7 @@
   { "CPUID#", 7, 0, 5, -1, NULL, },
   { "CR[CMCV]", 27, 0, 3, 74, NULL, },
   { "CR[DCR]", 27, 0, 3, 0, NULL, },
-  { "CR[EOI]", 27, 0, 7, 67, "SC Section 5.8.3.4, \"End of External Interrupt Register (EOI - CR67)\" on page 2:119", },
+  { "CR[EOI]", 27, 0, 7, 67, "SC Section 5.8.3.4, \"End of External Interrupt Register (EOI \xD0 CR67)\" on page 2:119", },
   { "CR[GPTA]", 27, 0, 3, 9, NULL, },
   { "CR[IFA]", 27, 0, 1, 20, NULL, },
   { "CR[IFA]", 27, 0, 3, 20, NULL, },
@@ -103,13 +103,13 @@
   { "CR[ITM]", 27, 0, 3, 1, NULL, },
   { "CR[ITV]", 27, 0, 3, 72, NULL, },
   { "CR[IVA]", 27, 0, 4, 2, NULL, },
-  { "CR[IVR]", 27, 0, 7, 65, "SC Section 5.8.3.2, \"External Interrupt Vector Register (IVR - CR65)\" on page 2:118", },
-  { "CR[LID]", 27, 0, 7, 64, "SC Section 5.8.3.1, \"Local ID (LID - CR64)\" on page 2:117", },
+  { "CR[IVR]", 27, 0, 7, 65, "SC Section 5.8.3.2, \"External Interrupt Vector Register (IVR \xD0 CR65)\" on page 2:118", },
+  { "CR[LID]", 27, 0, 7, 64, "SC Section 5.8.3.1, \"Local ID (LID \xD0 CR64)\" on page 2:117", },
   { "CR[LRR%], % in 0 - 1", 9, 0, 3, -1, NULL, },
   { "CR[PMV]", 27, 0, 3, 73, NULL, },
   { "CR[PTA]", 27, 0, 3, 8, NULL, },
   { "CR[TPR]", 27, 0, 3, 66, NULL, },
-  { "CR[TPR]", 27, 0, 7, 66, "SC Section 5.8.3.3, \"Task Priority Register (TPR - CR66)\" on page 2:119", },
+  { "CR[TPR]", 27, 0, 7, 66, "SC Section 5.8.3.3, \"Task Priority Register (TPR \xD0 CR66)\" on page 2:119", },
   { "CR[TPR]", 27, 0, 1, 66, NULL, },
   { "CR%, % in 3-7, 10-15, 18, 26-63, 75-79, 82-127", 10, 0, 0, -1, NULL, },
   { "DBR#", 11, 0, 2, -1, NULL, },
@@ -282,7 +282,7 @@
   { "CPUID#", 7, 1, 0, -1, NULL, },
   { "CR[CMCV]", 27, 1, 2, 74, NULL, },
   { "CR[DCR]", 27, 1, 2, 0, NULL, },
-  { "CR[EOI]", 27, 1, 7, 67, "SC Section 5.8.3.4, \"End of External Interrupt Register (EOI - CR67)\" on page 2:119", },
+  { "CR[EOI]", 27, 1, 7, 67, "SC Section 5.8.3.4, \"End of External Interrupt Register (EOI \xD0 CR67)\" on page 2:119", },
   { "CR[GPTA]", 27, 1, 2, 9, NULL, },
   { "CR[IFA]", 27, 1, 2, 20, NULL, },
   { "CR[IFS]", 27, 1, 2, 23, NULL, },

Modified: trunk/contrib/binutils/opcodes/ppc-opc.c
===================================================================
--- trunk/contrib/binutils/opcodes/ppc-opc.c	2018-06-15 22:29:05 UTC (rev 11009)
+++ trunk/contrib/binutils/opcodes/ppc-opc.c	2018-06-15 22:29:16 UTC (rev 11010)
@@ -4268,11 +4268,6 @@
 { "stvx",    X(31, 231), X_MASK,	PPCVEC,		{ VS, RA, RB } },
 { "stvxl",   X(31, 487), X_MASK,	PPCVEC,		{ VS, RA, RB } },
 
-/* New VSX opcodes in POWER ISA 2.06 */
-/* XXX: only enough opcodes for FreeBSD kernel, remove and replace with real info */
-{ "stxvw4x", X(31, 908), X_MASK,	PPCVEC,		{ FRS, RA0, RB } },
-{ "lxvw4x",  X(31, 780), X_MASK,	PPCVEC,		{ FRT, RA0, RB } },
-
 /* New load/store left/right index vector instructions that are in the Cell only.  */
 { "lvlx",    X(31, 519), X_MASK,	CELL,		{ VD, RA0, RB } },
 { "lvlxl",   X(31, 775), X_MASK,	CELL,		{ VD, RA0, RB } },



More information about the Midnightbsd-cvs mailing list