svn commit: r275749 - in projects/clang350-import: bin/ps cddl/contrib/opensolaris/cmd/zfs contrib/binutils/bfd contrib/binutils/include/elf etc/mtree gnu/usr.bin/binutils/libbfd share/man/man4 sha...

Dimitry Andric dim at FreeBSD.org
Sat Dec 13 19:45:21 UTC 2014


Author: dim
Date: Sat Dec 13 19:45:18 2014
New Revision: 275749
URL: https://svnweb.freebsd.org/changeset/base/275749

Log:
  Merge ^/head r275715 through r275748.

Added:
  projects/clang350-import/share/man/man7/crypto.7
     - copied unchanged from r275748, head/share/man/man7/crypto.7
  projects/clang350-import/sys/crypto/aesni/aesni_ghash.c
     - copied unchanged from r275748, head/sys/crypto/aesni/aesni_ghash.c
  projects/clang350-import/sys/libkern/timingsafe_bcmp.c
     - copied unchanged from r275748, head/sys/libkern/timingsafe_bcmp.c
  projects/clang350-import/sys/opencrypto/gfmult.c
     - copied unchanged from r275748, head/sys/opencrypto/gfmult.c
  projects/clang350-import/sys/opencrypto/gfmult.h
     - copied unchanged from r275748, head/sys/opencrypto/gfmult.h
  projects/clang350-import/sys/opencrypto/gmac.c
     - copied unchanged from r275748, head/sys/opencrypto/gmac.c
  projects/clang350-import/sys/opencrypto/gmac.h
     - copied unchanged from r275748, head/sys/opencrypto/gmac.h
  projects/clang350-import/tests/sys/opencrypto/
     - copied from r275748, head/tests/sys/opencrypto/
Modified:
  projects/clang350-import/bin/ps/ps.1
  projects/clang350-import/cddl/contrib/opensolaris/cmd/zfs/zfs.8
  projects/clang350-import/contrib/binutils/bfd/ChangeLog
  projects/clang350-import/contrib/binutils/bfd/bfd-in2.h
  projects/clang350-import/contrib/binutils/bfd/ecoff.c
  projects/clang350-import/contrib/binutils/bfd/elf32-ppc.c
  projects/clang350-import/contrib/binutils/bfd/elf64-ppc.c
  projects/clang350-import/contrib/binutils/bfd/libbfd.h
  projects/clang350-import/contrib/binutils/bfd/reloc.c
  projects/clang350-import/contrib/binutils/bfd/section.c
  projects/clang350-import/contrib/binutils/include/elf/ChangeLog
  projects/clang350-import/contrib/binutils/include/elf/ppc.h
  projects/clang350-import/contrib/binutils/include/elf/ppc64.h
  projects/clang350-import/etc/mtree/BSD.tests.dist
  projects/clang350-import/gnu/usr.bin/binutils/libbfd/bfd.h
  projects/clang350-import/share/man/man4/crypto.4
  projects/clang350-import/share/man/man7/Makefile
  projects/clang350-import/share/man/man9/crypto.9
  projects/clang350-import/share/mk/bsd.opts.mk
  projects/clang350-import/share/mk/src.opts.mk
  projects/clang350-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
  projects/clang350-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_traverse.c
  projects/clang350-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode_sync.c
  projects/clang350-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c
  projects/clang350-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_prop.c
  projects/clang350-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c
  projects/clang350-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h
  projects/clang350-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
  projects/clang350-import/sys/conf/files
  projects/clang350-import/sys/conf/files.amd64
  projects/clang350-import/sys/conf/files.i386
  projects/clang350-import/sys/crypto/aesni/aesni.c
  projects/clang350-import/sys/crypto/aesni/aesni.h
  projects/clang350-import/sys/crypto/aesni/aesni_wrap.c
  projects/clang350-import/sys/crypto/via/padlock_hash.c
  projects/clang350-import/sys/dev/beri/virtio/virtio_mmio_platform.c
  projects/clang350-import/sys/dev/cxgbe/adapter.h
  projects/clang350-import/sys/dev/cxgbe/tom/t4_tom.h
  projects/clang350-import/sys/dev/virtio/mmio/virtio_mmio.c
  projects/clang350-import/sys/dev/virtio/mmio/virtio_mmio_if.m
  projects/clang350-import/sys/dev/virtio/virtio_bus_if.m
  projects/clang350-import/sys/dev/virtio/virtqueue.c
  projects/clang350-import/sys/geom/eli/g_eli_crypto.c
  projects/clang350-import/sys/geom/eli/g_eli_integrity.c
  projects/clang350-import/sys/geom/eli/g_eli_privacy.c
  projects/clang350-import/sys/kern/kern_exec.c
  projects/clang350-import/sys/kern/kern_exit.c
  projects/clang350-import/sys/kern/kern_fork.c
  projects/clang350-import/sys/kern/kern_proc.c
  projects/clang350-import/sys/kern/kern_sig.c
  projects/clang350-import/sys/kern/kern_thread.c
  projects/clang350-import/sys/kern/subr_clock.c
  projects/clang350-import/sys/kern/vfs_subr.c
  projects/clang350-import/sys/kern/vfs_vnops.c
  projects/clang350-import/sys/mips/rmi/dev/sec/rmisec.c
  projects/clang350-import/sys/modules/aesni/Makefile
  projects/clang350-import/sys/modules/crypto/Makefile
  projects/clang350-import/sys/net/if_dead.c
  projects/clang350-import/sys/netinet/sctp_input.c
  projects/clang350-import/sys/netinet/tcp_input.c
  projects/clang350-import/sys/netinet/udp_usrreq.c
  projects/clang350-import/sys/netinet6/ip6_forward.c
  projects/clang350-import/sys/netinet6/ip6_ipsec.c
  projects/clang350-import/sys/netinet6/raw_ip6.c
  projects/clang350-import/sys/netinet6/udp6_usrreq.c
  projects/clang350-import/sys/opencrypto/criov.c
  projects/clang350-import/sys/opencrypto/crypto.c
  projects/clang350-import/sys/opencrypto/cryptodev.c
  projects/clang350-import/sys/opencrypto/cryptodev.h
  projects/clang350-import/sys/opencrypto/cryptosoft.c
  projects/clang350-import/sys/opencrypto/xform.c
  projects/clang350-import/sys/opencrypto/xform.h
  projects/clang350-import/sys/rpc/svc.c
  projects/clang350-import/sys/sys/bufobj.h
  projects/clang350-import/sys/sys/libkern.h
  projects/clang350-import/sys/sys/proc.h
  projects/clang350-import/tests/sys/Makefile
  projects/clang350-import/usr.bin/mkimg/Makefile
  projects/clang350-import/usr.bin/mkimg/qcow.c
  projects/clang350-import/usr.sbin/autofs/autounmountd.8
  projects/clang350-import/usr.sbin/syslogd/syslogd.c
Directory Properties:
  projects/clang350-import/   (props changed)
  projects/clang350-import/cddl/   (props changed)
  projects/clang350-import/cddl/contrib/opensolaris/   (props changed)
  projects/clang350-import/cddl/contrib/opensolaris/cmd/zfs/   (props changed)
  projects/clang350-import/contrib/binutils/   (props changed)
  projects/clang350-import/contrib/llvm/   (props changed)
  projects/clang350-import/etc/   (props changed)
  projects/clang350-import/gnu/usr.bin/binutils/   (props changed)
  projects/clang350-import/share/   (props changed)
  projects/clang350-import/share/man/man4/   (props changed)
  projects/clang350-import/sys/   (props changed)
  projects/clang350-import/sys/cddl/contrib/opensolaris/   (props changed)
  projects/clang350-import/sys/conf/   (props changed)
  projects/clang350-import/usr.bin/mkimg/   (props changed)

Modified: projects/clang350-import/bin/ps/ps.1
==============================================================================
--- projects/clang350-import/bin/ps/ps.1	Sat Dec 13 19:17:28 2014	(r275748)
+++ projects/clang350-import/bin/ps/ps.1	Sat Dec 13 19:45:18 2014	(r275749)
@@ -29,7 +29,7 @@
 .\"     @(#)ps.1	8.3 (Berkeley) 4/18/94
 .\" $FreeBSD$
 .\"
-.Dd August 27, 2014
+.Dd December 9, 2014
 .Dt PS 1
 .Os
 .Sh NAME
@@ -332,6 +332,7 @@ the include file
 .It Dv "P_SINGLE_BOUNDARY" Ta No "0x400000" Ta "Threads should suspend at user boundary"
 .It Dv "P_HWPMC" Ta No "0x800000" Ta "Process is using HWPMCs"
 .It Dv "P_JAILED" Ta No "0x1000000" Ta "Process is in jail"
+.It Dv "P_TOTAL_STOP" Ta No "0x2000000" Ta "Stopped for system suspend"
 .It Dv "P_INEXEC" Ta No "0x4000000" Ta "Process is in execve()"
 .It Dv "P_STATCHILD" Ta No "0x8000000" Ta "Child process stopped or exited"
 .It Dv "P_INMEM" Ta No "0x10000000" Ta "Loaded into memory"

Modified: projects/clang350-import/cddl/contrib/opensolaris/cmd/zfs/zfs.8
==============================================================================
--- projects/clang350-import/cddl/contrib/opensolaris/cmd/zfs/zfs.8	Sat Dec 13 19:17:28 2014	(r275748)
+++ projects/clang350-import/cddl/contrib/opensolaris/cmd/zfs/zfs.8	Sat Dec 13 19:45:18 2014	(r275749)
@@ -23,15 +23,15 @@
 .\" Copyright (c) 2012, Glen Barber <gjb at FreeBSD.org>
 .\" Copyright (c) 2012, Bryan Drewery <bdrewery at FreeBSD.org>
 .\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
-.\" Copyright (c) 2013 Nexenta Systems, Inc. All Rights Reserved.
 .\" Copyright (c) 2014, Joyent, Inc. All rights reserved.
 .\" Copyright (c) 2013, Steven Hartland <smh at FreeBSD.org>
+.\" Copyright (c) 2014 Nexenta Systems, Inc. All Rights Reserved.
 .\" Copyright (c) 2014, Xin LI <delphij at FreeBSD.org>
 .\" Copyright (c) 2014, The FreeBSD Foundation, All Rights Reserved.
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 12, 2014
+.Dd December 12, 2014
 .Dt ZFS 8
 .Os
 .Sh NAME
@@ -3505,10 +3505,9 @@ are also displayed.
 .Bd -literal -offset 2n
 .Li # Ic zfs allow cindys create,destroy,mount,snapshot tank/cindys
 .Li # Ic zfs allow tank/cindys
--------------------------------------------------------------
-Local+Descendent permissions on (tank/cindys)
-          user cindys create,destroy,mount,snapshot
--------------------------------------------------------------
+---- Permissions on tank/cindys --------------------------------------
+Local+Descendent permissions:
+        user cindys create,destroy,mount,snapshot
 .Ed
 .It Sy Example 18 No Delegating Create Time Permissions on a Tn ZFS No Dataset
 .Pp
@@ -3524,12 +3523,11 @@ are also displayed.
 .Li # Ic zfs allow staff create,mount tank/users
 .Li # Ic zfs allow -c destroy tank/users
 .Li # Ic zfs allow tank/users
--------------------------------------------------------------
-Create time permissions on (tank/users)
-          create,destroy
-Local+Descendent permissions on (tank/users)
-          group staff create,mount
--------------------------------------------------------------
+---- Permissions on tank/users ---------------------------------------
+Permission sets:
+        destroy
+Local+Descendent permissions:
+        group staff create,mount
 .Ed
 .It Xo
 .Sy Example 19
@@ -3547,14 +3545,11 @@ are also displayed.
 .Li # Ic zfs allow -s @pset create,destroy,snapshot,mount tank/users
 .Li # Ic zfs allow staff @pset tank/users
 .Li # Ic zfs allow tank/users
--------------------------------------------------------------
-Permission sets on (tank/users)
+---- Permissions on tank/users ---------------------------------------
+Permission sets:
         @pset create,destroy,mount,snapshot
-Create time permissions on (tank/users)
-        create,destroy
-Local+Descendent permissions on (tank/users)
-        group staff @pset,create,mount
--------------------------------------------------------------
+Local+Descendent permissions:
+        group staff @pset
 .Ed
 .It Sy Example 20 No Delegating Property Permissions on a Tn ZFS No Dataset
 .Pp
@@ -3566,16 +3561,15 @@ file system. The permissions on
 are also displayed.
 .Bd -literal -offset 2n
 .Li # Ic zfs allow cindys quota,reservation users/home
-.Li # Ic zfs allow cindys
--------------------------------------------------------------
-Local+Descendent permissions on (users/home)
+.Li # Ic zfs allow users/home
+---- Permissions on users/home ---------------------------------------
+Local+Descendent permissions:
         user cindys quota,reservation
--------------------------------------------------------------
 .Li # Ic su - cindys
 .Li cindys% Ic zfs set quota=10G users/home/marks
 .Li cindys% Ic zfs get quota users/home/marks
-NAME              PROPERTY  VALUE             SOURCE
-users/home/marks  quota     10G               local
+NAME              PROPERTY  VALUE  SOURCE
+users/home/marks  quota     10G    local
 .Ed
 .It Sy Example 21 No Removing ZFS Delegated Permissions on a Tn ZFS No Dataset
 .Pp
@@ -3589,14 +3583,11 @@ are also displayed.
 .Bd -literal -offset 2n
 .Li # Ic zfs unallow staff snapshot tank/users
 .Li # Ic zfs allow tank/users
--------------------------------------------------------------
-Permission sets on (tank/users)
+---- Permissions on tank/users ---------------------------------------
+Permission sets:
         @pset create,destroy,mount,snapshot
-Create time permissions on (tank/users)
-        create,destroy
-Local+Descendent permissions on (tank/users)
-        group staff @pset,create,mount
--------------------------------------------------------------
+Local+Descendent permissions:
+        group staff @pset
 .Ed
 .It Sy Example 22 Showing the differences between a snapshot and a ZFS Dataset
 .Pp

Modified: projects/clang350-import/contrib/binutils/bfd/ChangeLog
==============================================================================
--- projects/clang350-import/contrib/binutils/bfd/ChangeLog	Sat Dec 13 19:17:28 2014	(r275748)
+++ projects/clang350-import/contrib/binutils/bfd/ChangeLog	Sat Dec 13 19:45:18 2014	(r275749)
@@ -1,3 +1,49 @@
+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: projects/clang350-import/contrib/binutils/bfd/bfd-in2.h
==============================================================================
--- projects/clang350-import/contrib/binutils/bfd/bfd-in2.h	Sat Dec 13 19:17:28 2014	(r275748)
+++ projects/clang350-import/contrib/binutils/bfd/bfd-in2.h	Sat Dec 13 19:45:18 2014	(r275749)
@@ -1380,6 +1380,9 @@ typedef struct bfd_section
   /* 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;
 
@@ -1640,11 +1643,11 @@ extern asection bfd_ind_section;
   /* segment_mark, sec_info_type, use_rela_p, has_tls_reloc,       */  \
      0,            0,             0,          0,                       \
                                                                        \
-  /* has_gp_reloc, need_finalize_relax, reloc_done,                */  \
-     0,            0,                   0,                             \
+  /* has_tls_get_addr_call, has_gp_reloc, need_finalize_relax,     */  \
+     0,                     0,            0,                           \
                                                                        \
-  /* vma, lma, size, rawsize                                       */  \
-     0,   0,   0,    0,                                                \
+  /* reloc_done, vma, lma, size, rawsize                           */  \
+     0,          0,   0,   0,    0,                                    \
                                                                        \
   /* output_offset, output_section,              alignment_power,  */  \
      0,             (struct bfd_section *) &SEC, 0,                    \
@@ -2896,6 +2899,8 @@ in the instruction.  */
 
 /* 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: projects/clang350-import/contrib/binutils/bfd/ecoff.c
==============================================================================
--- projects/clang350-import/contrib/binutils/bfd/ecoff.c	Sat Dec 13 19:17:28 2014	(r275748)
+++ projects/clang350-import/contrib/binutils/bfd/ecoff.c	Sat Dec 13 19:45:18 2014	(r275749)
@@ -58,10 +58,10 @@ static asection bfd_debug_section =
      0,           0,                1,       0,
   /* segment_mark, sec_info_type, use_rela_p, has_tls_reloc,       */
      0,            0,             0,          0,
-  /* has_gp_reloc, need_finalize_relax, reloc_done,                */
-     0,            0,                   0,
-  /* vma, lma, size, rawsize,                                      */
-     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,
   /* output_offset, output_section, alignment_power,               */
      0,             NULL,           0,
   /* relocation, orelocation, reloc_count, filepos, rel_filepos,   */

Modified: projects/clang350-import/contrib/binutils/bfd/elf32-ppc.c
==============================================================================
--- projects/clang350-import/contrib/binutils/bfd/elf32-ppc.c	Sat Dec 13 19:17:28 2014	(r275748)
+++ projects/clang350-import/contrib/binutils/bfd/elf32-ppc.c	Sat Dec 13 19:45:18 2014	(r275749)
@@ -746,7 +746,7 @@ static reloc_howto_type ppc_elf_howto_ra
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Marker reloc for TLS.  */
+  /* Marker relocs for TLS.  */
   HOWTO (R_PPC_TLS,
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -761,6 +761,34 @@ static reloc_howto_type ppc_elf_howto_ra
 	 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,
@@ -1524,6 +1552,8 @@ ppc_elf_reloc_type_lookup (bfd *abfd ATT
     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;
@@ -2345,16 +2375,34 @@ struct plt_entry
   bfd_vma glink_offset;
 };
 
-/* Of those relocs that might be copied as dynamic relocs, this macro
+/* Of those relocs that might be copied as dynamic relocs, this function
    selects those that must be copied when linking a shared library,
    even when the symbol is local.  */
 
-#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)
+static int
+must_be_dyn_reloc (struct bfd_link_info *info,
+		   enum elf_ppc_reloc_type r_type)
+{
+  switch (r_type)
+    {
+    default:
+      return 1;
+
+    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
@@ -2421,7 +2469,7 @@ struct ppc_elf_link_hash_table
   /* 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.  */
@@ -3040,6 +3088,7 @@ ppc_elf_check_relocs (bfd *abfd,
   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;
@@ -3063,6 +3112,8 @@ ppc_elf_check_relocs (bfd *abfd,
     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");
@@ -3074,7 +3125,7 @@ ppc_elf_check_relocs (bfd *abfd,
       unsigned long r_symndx;
       enum elf_ppc_reloc_type r_type;
       struct elf_link_hash_entry *h;
-      int tls_type = 0;
+      int tls_type;
 
       r_symndx = ELF32_R_SYM (rel->r_info);
       if (r_symndx < symtab_hdr->sh_info)
@@ -3101,14 +3152,48 @@ ppc_elf_check_relocs (bfd *abfd,
 	  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;
 
@@ -3123,7 +3208,7 @@ ppc_elf_check_relocs (bfd *abfd,
 	case R_PPC_GOT_TPREL16_LO:
 	case R_PPC_GOT_TPREL16_HI:
 	case R_PPC_GOT_TPREL16_HA:
-	  if (info->shared)
+	  if (!info->executable)
 	    info->flags |= DF_STATIC_TLS;
 	  tls_type = TLS_TLS | TLS_TPREL;
 	  goto dogottls;
@@ -3358,7 +3443,7 @@ ppc_elf_check_relocs (bfd *abfd,
 
 	  /* This refers only to functions defined in the shared library.  */
 	case R_PPC_LOCAL24PC:
-	  if (h && h == htab->elf.hgot && htab->plt_type == PLT_UNSET)
+	  if (h != NULL && h == htab->elf.hgot && htab->plt_type == PLT_UNSET)
 	    {
 	      htab->plt_type = PLT_OLD;
 	      htab->old_bfd = abfd;
@@ -3381,7 +3466,11 @@ ppc_elf_check_relocs (bfd *abfd,
 
 	  /* We shouldn't really be seeing these.  */
 	case R_PPC_TPREL32:
-	  if (info->shared)
+	case R_PPC_TPREL16:
+	case R_PPC_TPREL16_LO:
+	case R_PPC_TPREL16_HI:
+	case R_PPC_TPREL16_HA:
+	  if (!info->executable)
 	    info->flags |= DF_STATIC_TLS;
 	  goto dodyn;
 
@@ -3390,14 +3479,6 @@ ppc_elf_check_relocs (bfd *abfd,
 	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
@@ -3488,7 +3569,7 @@ ppc_elf_check_relocs (bfd *abfd,
 	     dynamic library if we manage to avoid copy relocs for the
 	     symbol.  */
 	  if ((info->shared
-	       && (MUST_BE_DYN_RELOC (r_type)
+	       && (must_be_dyn_reloc (info, r_type)
 		   || (h != NULL
 		       && (! info->symbolic
 			   || h->root.type == bfd_link_hash_defweak
@@ -3583,7 +3664,7 @@ ppc_elf_check_relocs (bfd *abfd,
 		}
 
 	      p->count += 1;
-	      if (!MUST_BE_DYN_RELOC (r_type))
+	      if (!must_be_dyn_reloc (info, r_type))
 		p->pc_count += 1;
 	    }
 
@@ -3903,9 +3984,6 @@ ppc_elf_gc_sweep_hook (bfd *abfd,
 	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:
@@ -3979,7 +4057,8 @@ ppc_elf_gc_sweep_hook (bfd *abfd,
   return TRUE;
 }
 

-/* Set htab->tls_get_addr and call the generic ELF tls_setup function.  */
+/* Set plt output section type, htab->tls_get_addr, and call the
+   generic ELF tls_setup function.  */
 
 asection *
 ppc_elf_tls_setup (bfd *obfd, struct bfd_link_info *info)
@@ -4000,6 +4079,43 @@ ppc_elf_tls_setup (bfd *obfd, struct bfd
   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.  */
 
@@ -4010,187 +4126,204 @@ ppc_elf_tls_optimize (bfd *obfd ATTRIBUT
   bfd *ibfd;
   asection *sec;
   struct ppc_elf_link_hash_table *htab;
+  int pass;
 
-  if (info->relocatable || info->shared)
+  if (info->relocatable || !info->executable)
     return TRUE;
 
   htab = ppc_elf_hash_table (info);
-  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;
-	    int expecting_tls_get_addr;
+  /* 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;
 
-	    /* Read the relocations.  */
-	    relstart = _bfd_elf_link_read_relocs (ibfd, sec, NULL, NULL,
-						  info->keep_memory);
-	    if (relstart == NULL)
-	      return FALSE;
+	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;
 
-	    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;
+	      /* Read the relocations.  */
+	      relstart = _bfd_elf_link_read_relocs (ibfd, sec, NULL, NULL,
+						    info->keep_memory);
+	      if (relstart == NULL)
+		return FALSE;
 
-		r_symndx = ELF32_R_SYM (rel->r_info);
-		if (r_symndx >= symtab_hdr->sh_info)
-		  {
-		    struct elf_link_hash_entry **sym_hashes;
+	      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;
 
-		    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;
-		  }
+		  r_symndx = ELF32_R_SYM (rel->r_info);
+		  if (r_symndx >= symtab_hdr->sh_info)
+		    {
+		      struct elf_link_hash_entry **sym_hashes;
 
-		is_local = FALSE;
-		if (h == NULL
-		    || !h->def_dynamic)
-		  is_local = TRUE;
+		      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;
+		    }
 
-		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;
+		  expecting_tls_get_addr = 0;
+		  is_local = FALSE;
+		  if (h == NULL
+		      || !h->def_dynamic)
+		    is_local = TRUE;
 
-		    /* LD -> LE */
-		    tls_set = 0;
-		    tls_clear = TLS_LD;
-		    expecting_tls_get_addr = 1;
-		    break;
+		  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 */
+
+		    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;
 
-		  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 */
+		      /* LD -> LE */
 		      tls_set = 0;
-		    else
-		      /* GD -> IE */
-		      tls_set = TLS_TLS | TLS_TPRELGD;
-		    tls_clear = TLS_GD;
-		    expecting_tls_get_addr = 1;
-		    break;
+		      tls_clear = TLS_LD;
+		      break;
 
-		  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 */
+		    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 */
 			tls_set = 0;
-			tls_clear = TLS_TPREL;
-			break;
-		      }
-		    else
+		      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:
 		      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 (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))
+			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;
+		    }
 
-		  default:
-		    expecting_tls_get_addr = 0;
-		    continue;
-		  }
+		  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 (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 (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];
+		    }
 
-		    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 (tls_set == 0)
+		    {
+		      /* We managed to get rid of a got entry.  */
+		      if (*got_count > 0)
+			*got_count -= 1;
+		    }
 
-		*tls_mask |= tls_set;
-		*tls_mask &= ~tls_clear;
-	      }
+		  if (expecting_tls_get_addr)
+		    {
+		      struct plt_entry *ent;
 
-	    if (elf_section_data (sec)->relocs != relstart)
-	      free (relstart);
-	  }
+		      ent = find_plt_ent (htab->tls_get_addr, NULL, 0);
+		      if (ent != NULL && ent->plt.refcount > 0)
+			ent->plt.refcount -= 1;
+		    }
 
-      if (locsyms != NULL
-	  && (symtab_hdr->contents != (unsigned char *) locsyms))
-	{
-	  if (!info->keep_memory)
-	    free (locsyms);
-	  else
-	    symtab_hdr->contents = (unsigned char *) locsyms;
-	}
-    }
+		  *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;
+	  }
+      }
   return TRUE;
 }
 

@@ -4615,8 +4748,11 @@ allocate_dynrelocs (struct elf_link_hash
 
       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.  */
-	eh->elf.got.offset = (bfd_vma) -1;
+	{
+	  /* 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;
+	}
       else
 	{
 	  bfd_boolean dyn;
@@ -4664,7 +4800,7 @@ allocate_dynrelocs (struct elf_link_hash
   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
@@ -4891,6 +5027,9 @@ ppc_elf_size_dynamic_sections (bfd *outp
 	  *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);
@@ -4900,9 +5039,6 @@ ppc_elf_size_dynamic_sections (bfd *outp
   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;
@@ -5754,16 +5890,13 @@ ppc_elf_relocate_section (bfd *output_bf
 	 for the final instruction stream.  */
       tls_mask = 0;
       tls_gd = 0;
-      if (IS_PPC_TLS_RELOC (r_type))
-	{
-	  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];
-	    }
+      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.  */
@@ -5870,85 +6003,147 @@ ppc_elf_relocate_section (bfd *output_bf
 	case R_PPC_GOT_TLSGD16_LO:
 	  tls_gd = TLS_TPRELGD;
 	  if (tls_mask != 0 && (tls_mask & TLS_GD) == 0)
-	    goto tls_get_addr_check;
+	    goto tls_ldgd_opt;
 	  break;
 
 	case R_PPC_GOT_TLSLD16:
 	case R_PPC_GOT_TLSLD16_LO:
 	  if (tls_mask != 0 && (tls_mask & TLS_LD) == 0)
 	    {
-	    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;
-
-		  /* The next instruction should be a call to
-		     __tls_get_addr.  Peek at the reloc to be sure.  */

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-projects mailing list