Pull-in binutils 2.24 @ 68761544.

Also include 2 local patches -
a) revert one upstream CL - which causes unbootable kernel -
d2667025dd30611514810c28bee9709e4623012a.

b) allow incbin by default.

Performance test performed for three boards - parrot, daisy and x86-alex.
Bootperf testing
PerfV2
No noticeable change introduced in this CL.
Firmware test of samus(TOT now) passes.

Correctness test cleared for daisy/parrot/x86-alex.
cbuildbot chromiumos-sdk
cbuildbot --hwtest daisy-release daisy_sping-release lumpy-release x86-alex-release, bootperf/perfv2
                   duck-release beaglebone-release
TEST=list above
BUG=None
CQ-DEPEND=CL:200779
CQ-DEPEND=CL:210353

Change-Id: Ied5d9f35142d05ead2ee2ba8be80595426a4d477
Reviewed-on: https://chromium-review.googlesource.com/203470
Reviewed-by: Mike Frysinger <[email protected]>
Tested-by: Mike Frysinger <[email protected]>
Commit-Queue: Mike Frysinger <[email protected]>
diff --git a/ChangeLog b/ChangeLog
index e572d95..e41638b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,588 @@
+2013-11-23  Alan Modra  <[email protected]>
+
+	* config.sub, config.guess: Import from upstream.
+
+2013-09-20  Alan Modra  <[email protected]>
+
+	* libtool.m4 (_LT_ENABLE_LOCK <ld -m flags>): Remove non-canonical
+	ppc host match.  Support little-endian powerpc linux hosts.
+
+2013-08-16  Joel Brobecker  <[email protected]>
+
+	* src-release (VER): When using $(TOOL)/common/create-version.sh,
+	strip the "-cvs" suffix from the version number if present.
+
+2013-08-12  Jan-Benedict Glaw  <[email protected]>
+
+	* configure.ac: Sync with GCC repo.
+	* Makefile.def: Ditto.
+	* configure: Regenerate.
+	* Makefile.in: Ditto.
+
+2013-07-22  Joel Brobecker  <[email protected]>
+
+	* src-release (VER): Use $(TOOL)/common/create-version.sh
+	if it exists.
+
+2013-06-22  Richard Sandiford  <[email protected]>
+
+	* configure.ac (mips*-*-bsd*, mips*-*-ultrix*, mips*-*-osf*)
+	(mips*-*-ecoff*, mips*-*-pe*, mips*-*-irix* [v4 and earlier])
+	(mips*-*-lnews*, mips*-*-riscos*): Add gas and ld to noconfigdirs.
+	* configure: Regenerate.
+
+2013-06-01  George Thomas <[email protected]>
+
+	* include/opcode/avr.h: Rename AVR_ISA_XCH to AVR_ISA_RMW. Remove
+	from AVR_ISA_XMEGA and add new AVR_ISA_XMEGAU
+
+2013-05-06  Sandra Loosemore  <[email protected]>
+
+	* COPYING.NEWLIB: Add Altera Corporation copyright.
+
+2013-04-29  Jan-Benedict Glaw  <[email protected]>
+
+	* config.guess: Update from config repo.
+	* config.sub: Ditto.
+
+2013-04-22  Jan-Benedict Glaw  <[email protected]>
+
+	* Makefile.def: Sync with GCC.
+	* Makefile.in: Regenerate.
+
+2013-04-22  Jan-Benedict Glaw  <[email protected]>
+
+	* configure.ac: Sync with GCC.
+	* configure: Regenerate.
+
+2013-03-22  Mike Frysinger  <[email protected]>
+
+	* src-release (VER): Change bfd/configure.in sed to use the new
+	`bfd/configure --version` output.
+
+2013-02-15  Yufeng Zhang  <[email protected]>
+
+	* configure.ac: Sync with GCC repo.
+	* configure: Ditto.
+
+2013-02-05  Ian Lance Taylor  <[email protected]>
+
+	PR go/55969
+	* configure.ac: Disable libgo on some systems where it does not
+	work.
+	* configure: Rebuild.
+
+2013-02-05  Alan Modra  <[email protected]>
+
+	* configure: Regenerate after syncing config/.
+
+2013-01-15  Jan-Benedict Glaw  <[email protected]>
+
+	* configure.ac: Sync with GCC repo.
+	* configure: Ditto.
+	* Makefile.def: Ditto.
+	* Makefile.in: Ditto.
+
+2013-01-11  Joel Brobecker  <[email protected]>
+
+	Sync with GCC, merge:
+
+	2013-01-09  Jason Merrill  <[email protected]>
+
+	* .gitignore: Import from gdb repository.
+
+2013-01-11  Jan-Benedict Glaw  <[email protected]>
+
+	* config.sub: Update from config repo.
+
+2013-01-11  Eric Botcazou  <[email protected]>
+
+	* Makefile.tpl (BOOT_ADAFLAGS): Remove -gnata.
+	* Makefile.in: Regenerate.
+
+2013-01-09  H.J. Lu  <[email protected]>
+
+	* Makefile.def (configure-gcc): Depend on all-gmp.
+	(all-gcc): Remove dependency on all-gmp.
+	* Makefile.in: Regenerated.
+
+2013-01-08  Jan-Benedict Glaw  <[email protected]>
+
+	* config.guess: Update from config repo.
+	* config.sub: Ditto.
+
+2013-01-07  Jeff Johnston  <[email protected]>
+
+	* COPYING.LIBGLOSS: Remove license for mips/lsi33k-stub.h which no longer
+	exists and replace the new bfin license in its location.
+
+2013-01-07  H.J. Lu  <[email protected]>
+
+	PR gas/14899
+	* Makefile.def (dependencies): Make all-binutils, all-gprof,
+	all-ld and all-gold depend on all-gas.
+	* Makefile.in: Regenerated.
+
+2012-12-29  Ben Elliston  <[email protected]>
+
+	* config.guess: Update to 2012-12-29 version.
+	* config.sub: Likewise.
+
+2012-12-20  Jan-Benedict Glaw  <[email protected]>
+
+	* Makefile.def (install-target-libgo): Depend on
+	install-target-libatomic. Merged from GCC repo.
+	* Makefile.in: Regenerate.
+
+2012-12-17  Jeff Johnston  <[email protected]>
+
+	* COPYING.LIBGLOSS: Add license for bfin libgloss.
+
+2012-12-16  Thomas Schwinge  <[email protected]>
+
+	* configure.ac (ENABLE_GOLD): Consider *-*-gnu* targets ELF.
+	* configure: Regenerate.
+
+2012-12-11  H.J. Lu  <[email protected]>
+
+	* Makefile.def (target_modules): Add bootstrap=true and
+	raw_cxx=true to libsanitizer.
+	* configure.ac (bootstrap_target_libs): Add libsanitizer.
+	* Makefile.in: Regenerated.
+	* configure: Likewise.
+
+2012-12-08  Jan-Benedict Glaw  <[email protected]>
+
+	* config.sub: Merge from config repo.
+
+2012-11-30  Jan-Benedict Glaw  <[email protected]>
+
+	* configure.ac: Merge from GCC.
+	* Makefile.tpl: Ditto.
+	* Makefile.in: Ditto.
+	* configure: Ditto.
+
+2012-11-28  Jan-Benedict Glaw  <[email protected]>
+
+	* configure.ac (noconfigdirs): Merge from GCC.
+	* configure: Regenerate.
+
+2012-11-19  Jan-Benedict Glaw  <[email protected]>
+
+	* config.sub (arm): Merge from upstream: Handle armv[6-8] targets.
+
+2012-11-14  Roland McGrath  <[email protected]>
+
+	* configure.ac (ENABLE_GOLD): Consider *-*-nacl* targets ELF.
+	* configure: Regenerate.
+
+2012-11-13  Richard Henderson  <[email protected]>
+
+	* configure.ac: Move libsanitizer logic to subdirectory.
+	* configure: Regenerate.
+
+2012-11-13  Dodji Seketeli  <[email protected]>
+
+	* configure.ac: Enable libsanitizer just on x86 linux for now.
+	* configure: Re-generate.
+
+2012-11-13  David Edelsohn  <[email protected]>
+
+	* configure.ac: Merge libquadmath sections.
+	* configure: Regenerate.
+
+2012-11-12  Wei Mi <[email protected]>
+
+	* configure.ac: Add libsanitizer to target_libraries.
+	* Makefile.def: Ditto.
+	* configure: Regenerate.
+	* Makefile.in: Regenerate.
+
+2012-11-03  H.J. Lu  <[email protected]>
+
+	* configure: Regenerated.
+
+2012-11-03  Robert Mason  <[email protected]>
+
+	* configure.ac: add --disable-libstdcxx configure option
+	and handle defaulted state only for VxWorks, ARM-wince-pe and AVR.
+
+2012-10-24  Corinna Vinschen  <[email protected]>
+
+	* configure.ac (FLAGS_FOR_TARGET,target=cygwin): Fix for building
+	against Mingw64 w32api.
+	* configure: Regenerate.
+
+2012-10-23  Eric Botcazou  <[email protected]>
+
+	PR bootstrap/54820
+	* configure.ac (have_static_libs): Force 'no' for GCC version < 4.5.
+	* configure: Regenerate.
+
+2012-10-22  Eric Botcazou  <[email protected]>
+
+	PR bootstrap/54820
+	* Makefile.tpl (STAGE1_FLAGS_TO_PASS): New variable.
+	(all-[+prefix+][+module+]): Pass stage1_args to sub-makes.
+	(all-stage[+id+]-[+prefix+][+module+]): Likewise, if prev is false.
+	(clean-stage[+id+]-[+prefix+][+module+]): Likewise, if prev is false.
+	(host_modules): Set stage1_args to STAGE1_FLAGS_TO_PASS.
+	* Makefile.in: Regenerate.
+	* configure.ac (have_static_libs): New variable and associated check.
+	(stage1-ldflags): Move to after stage1_libs and set to -static-libstdc++
+	-static-libgcc if stage1_libs is empty and have_static_libs is yes.
+	* configure: Regenerate.
+
+2012-10-10  David Holsgrove  <[email protected]>
+
+	* config.guess, config.sub: Include updated version from
+	config-patches.  Adds microblaze little endian support.
+
+2012-09-28  Ian Lance Taylor  <[email protected]>
+
+	* Makefile.def: Make all-target-libgo depend on
+	all-target-libbacktrace.
+	* Makefile.in: Rebuild.
+
+2012-09-26  Ian Lance Taylor  <[email protected]>
+
+	* Makefile.def: Make all-gcc depend on all-libbacktrace.
+	* Makefile.in: Rebuild.
+
+2012-09-06  Diego Novillo  <[email protected]>
+
+	* configure.ac: Bump minimum GMP version to 4.2.3.
+	* configure: Re-generate.
+
+2012-09-05  Georg-Johann Lay  <[email protected]>
+
+	PR target/54461
+	* configure.ac (noconfigdirs,target=avr-*-*): Add target-newlib,
+	target-libgloss if not configured --with-avrlibc=no.
+	* configure: Regenerate.
+
+2012-09-04  Jason Merrill  <[email protected]>
+
+	* configure.ac: Fix --enable-languages=all.
+
+2012-09-03  Richard Guenther  <[email protected]>
+
+	PR bootstrap/54138
+	* configure.ac: Re-organize ISL / CLOOG checks to allow
+	disabling with either --without-isl or --without-cloog.
+	* configure: Regenerated.
+
+2012-09-03  Georg-Johann Lay  <[email protected]>
+
+	* configure.ac (noconfigdirs,target=avr): Add target-libquadmath.
+	* configure: Regenerate.
+
+2012-09-21  Steve Ellcey  <[email protected]>
+
+	* configure.ac: Add mips*-mti-elf* target.
+	* configure: Regenerate.
+
+2012-09-19  Ian Lance Taylor  <[email protected]>
+
+	* configure.ac (host_libs): Add libbacktrace.
+	(target_libraries): Add libbacktrace.
+	* Makefile.def (host_modules): Add libbacktrace.
+	(target_modules): Likewise.
+	* configure, Makefile.in: Rebuild.
+
+2012-09-15  Jiong Wang  <[email protected]>
+
+	* configure.ac (ENABLE_GOLD): support tilegx*
+	* configure: rebuild
+
+2012-09-14  David Edelsohn  <[email protected]>
+
+	PR target/38607
+	Merge upstream change.
+	* libtool.m4 (_LT_COMPILER_PIC): Add -fPIC to GCC and GXX for AIX.
+
+	* configure.ac: Add target-libquadmath to noconfigdirs for AIX.
+	Add libgomp*.o to compare_exclusions for AIX.
+	* configure: Regenerate.
+
+2012-08-26  H.J. Lu  <[email protected]>
+
+	PR binutils/4970
+	* Makefile.def (host_modules): Rmove lib_path=.libs from bfd
+	and opcodes.
+	* Makefile.in: Regenerated.
+
+2012-08-14   Diego Novillo  <[email protected]>
+
+	Merge from cxx-conversion branch.
+
+	* Makefile.tpl (STAGE[+id+]_CXXFLAGS): Remove
+	POSTSTAGE1_CONFIGURE_FLAGS.
+	* Makefile.in: Regenerate.
+	* configure.ac (ENABLE_BUILD_WITH_CXX): Remove.  Update all users.
+	Force C++ when bootstrapping.
+	* configure: Regenerate.
+
+2012-07-06  Richard Guenther  <[email protected]>
+
+	* Makefile.def (cloog): Pass $(HOST_GMPINC) and $(HOST_ISLINC)
+	as CPPFLAGS, pass path to built gmp as LDFLAGS, always use
+	--with-gmp=system.
+	* Makefile.in: Regenerated.
+	* configure: Likewise.
+
+2012-07-06  Richard Guenther  <[email protected]>
+
+	* configure.ac (extra_isl_gmp_configure_flags): Initialize and subst.
+	* Makefile.def (isl): Use extra_isl_gmp_configure_flags and
+	supply V=1 as extra_make_flags.
+	* configure: Regenerated.
+	* Makefile.in: Likewise.
+
+2012-07-03  Richard Guenther  <[email protected]>
+
+	* Makfile.def (isl): Remove not necessary extra_exports and
+	extra_make_flags.
+	(cloog): Use $$CPPFLAGS instead of ${CPPFLAGS}.
+	* Makefile.in: Regenerated.
+
+2012-07-03  Richard Guenther  <[email protected]>
+
+	* Makefile.def (cloog): Add V=1 to extra_make_flags.
+	* configure.ac: If either the ISL or the CLooG check failed
+	do not try to build in-tree versions.
+	* Makefile.in: Regenerated.
+	* configure: Regenerated.
+
+2012-07-02  Richard Guenther  <[email protected]>
+	Michael Matz  <[email protected]>
+	Tobias Grosser <[email protected]>
+	Sebastian Pop <[email protected]>
+
+	* Makefile.def: Add ISL host module, remove PPL host module.
+	Adjust ClooG host module to use the proper ISL.
+	* Makefile.tpl: Pass ISL include flags instead of PPL ones.
+	* configure.ac: Include config/isl.m4.  Add ISL host library,
+	remove PPL.  Remove PPL configury, add ISL configury, adjust
+	ClooG configury.
+	* Makefile.in: Regenerated.
+	* configure: Likewise.
+
+2012-07-02  Richard Guenther  <[email protected]>
+
+	Merge from graphite branch
+	2011-07-21  Tobias Grosser  <[email protected]>
+
+	* configure: Regenerated.
+	* config/cloog.m4: Remove support for CLooG-ppl and CLooG-parma,
+	both cloog.org and legacy versions. The only supported version will
+	be CLooG with the isl backend.
+
+	2011-07-21  Tobias Grosser  <[email protected]>
+
+	* configure: Regenerated.
+	* configure.ac: Require cloog isl 0.17.0
+
+	2011-07-21  Tobias Grosser  <[email protected]>
+
+	* configure: Regenerated.
+	* config/cloog.m4: Do not define CLOOG_ORG
+
+2012-06-29  Steven Bosscher  <[email protected]>
+
+	* configure.ac: Skip C if explicitly selected.
+	* configure: Regenerate.
+
+2012-06-28  Christophe Lyon <[email protected]>
+
+	* configure.ac (CFLAGS_FOR_TARGET, CXXFLAGS_FOR_TARGET): Make sure
+	they contain -O2.
+	* configure: Regenerate.
+
+2012-06-20  Jason Merrill  <[email protected]>
+
+	* Makefile.tpl (check-target-libgomp-c++): New.
+	(check-target-libitm-c++): New.
+	* Makefile.def (c++): Add them.
+	* Makefile.in: Regenerate.
+
+2012-05-16  Olivier Hainque  <[email protected]>
+
+	* Makefile.tpl (gcc-no-fixedincludes): Rename into ...
+	(gcc-install-no-fixedincludes): Now forwarder to local target in gcc/
+	(install-no-fixedincludes): Adjust accordingly.
+	* Makefile.in: Regenerate.
+
+2012-05-09  Nick Clifton  <[email protected]>
+	    Paul Smith  <[email protected]>
+
+	PR bootstrap/50461
+	* configure.ac (mpfr-dir): When using in-tree MPFR sources
+	allow for the fact that from release v3.1.0 of MPFR the source
+	files were moved into a src sub-directory.
+	* configure: Regenerate.
+
+2012-05-07  Janne Blomqvist  <[email protected]>
+
+	* configure.ac: Bump minimum MPFR version to 2.4.0.
+	* configure: Regenerated.
+
+2012-05-01  Richard Henderson  <[email protected]>
+
+	* Makefile.def (libatomic): New target_module.
+	* configure.ac (target_libraries): Add libatomic.
+	(noconfigdirs): Check if libatomic is supported.
+	* Makefile.in, configure: Rebuild.
+
+2012-05-15  H.J. Lu  <[email protected]>
+
+	Merge upstream change
+	* libtool.m4 (_LT_ENABLE_LOCK): Support x32.
+
+2011-11-21  Andreas Tobler  <[email protected]>
+
+	* libtool.m4: Additional FreeBSD 10 fixes.
+
+2012-06-28  Christophe Lyon <[email protected]>
+
+	* configure.ac (CFLAGS_FOR_TARGET, CXXFLAGS_FOR_TARGET): Make sure
+	they contain -O2.
+	* configure: Regenerate.
+
+2012-05-14  Catherine Moore  <[email protected]>
+
+	* NEWS:  Mention PowerPC VLE port.
+
+2012-05-11  Mike Frysinger  <[email protected]>
+
+	* MAINTAINERS (config/): Move to intl/ section.
+	(compile; depcomp; install-sh; missing; ylwrap): Likewise.
+
+2012-05-09  Nick Clifton  <[email protected]>
+	    Paul Smith  <[email protected]>
+
+	PR bootstrap/50461
+	* configure.ac (mpfr-dir): When using in-tree MPFR sources
+	allow for the fact that from release v3.1.0 of MPFR the source
+	files were moved into a src sub-directory.
+	* configure: Regenerate.
+
+2012-05-02  Roland McGrath  <[email protected]>
+
+	* configure.ac (ENABLE_GOLD): Consider *-*-nacl* targets ELF.
+	* configure: Regenerate.
+
+2012-04-25  Joel Brobecker  <[email protected]>
+
+	* config.sub: Update to 2012-04-18 version from official repo.
+
+2012-03-19  Tristan Gingold  <[email protected]>
+
+	* configure.ac (ia64*-*-*vms*): Add support for ld.
+	* configure: Regenerate.
+
+2012-03-14  Rainer Orth  <[email protected]>
+
+	* configure.ac (enable_libgomp): Remove *-*-irix6*.
+	(unsupported_languages): Remove mips-sgi-irix6.*.
+	(noconfigdirs): Don't add ${libgcj} for mips*-*-irix6*.
+	(with_stabs): Remove.
+	* configure: Regenerate.
+
+2012-03-12  Rainer Orth  <[email protected]>
+
+	* configure.ac (enable_libgomp): Remove *-*-osf*.
+	(with_stabs): Remove alpha*-*-osf*.
+	* configure: Regenerate.
+
+2012-03-09  Jeff Johnston  <[email protected]>
+
+	* COPYING.NEWLIB: Modify DJ Delorie license to include
+	modification rights in clause as permitted by DJ Delorie.
+	* COPYING.LIBGLOSS: Ditto.
+
+2012-03-09  Jeff Johnston  <[email protected]>
+
+	* COPYING.NEWLIB: Remove two unused licenses.
+
+2012-03-05  Tristan Gingold  <[email protected]>
+
+	* configure.ac: Enable gdb and readline for ia64*-*-*vms*.
+	* configure: Regenerate.
+
+2012-02-21  Joern Rennecke  <[email protected]>
+
+	* COPYING.NEWLIB: Add Adapteva notice.
+	* COPYING.LIBGLOSS: Add Adapteva notice.
+
+2011-12-18  Eric Botcazou  <[email protected]>
+
+	* configure: Regenerate.
+
+2011-12-15  Jeff Johnston  <[email protected]>
+
+	* COPYING.LIBGLOSS: Add GPL with exception license.
+
+2011-11-09  Roland McGrath  <[email protected]>
+
+	* configure.ac: Add tool checks for READELF and READELF_FOR_TARGET.
+	* configure: Rebuild.
+	* Makefile.def (flags_to_pass): Add READELF_FOR_TARGET.
+	* Makefile.tpl (READELF, READELF_FOR_TARGET): New variables.
+	(HOST_EXPORTS): Add READELF, READELF_FOR_TARGET.
+	(BASE_FLAGS_TO_PASS): Add READELF_FOR_TARGET.
+	(BASE_TARGET_EXPORTS, EXTRA_HOST_FLAGS, EXTRA_TARGET_FLAGS):
+	Add READELF.
+	* Makefile.in: Rebuild.
+
+2011-11-08  Richard Henderson  <[email protected]>
+
+	* configure.ac: Test for libitm directory present first.
+
+	* configure.ac: Adjust srcdir for running libitm/configure.tgt.
+
+	* configure.ac: Test libitm/configure.tgt to disable libitm.
+	* configure: Rebuild.
+
+2011-11-02  Rainer Orth  <[email protected]>
+
+	* Makefile.tpl (EXTRA_GCC_FLAGS): Remove LIBGCC2_CFLAGS,
+	LIBGCC2_DEBUG_CFLAGS, LIBGCC2_INCLUDES.
+	* Makefile.in: Regenerate.
+
+2011-11-01  DJ Delorie  <[email protected]>
+
+	* configure.ac (rl78-*-*) New case.
+	* configure: Regenerate.
+
+2011-11-01  DJ Delorie  <[email protected]>
+
+	* config.sub: Update to version 2011-10-29 (added rl78)
+
+2011-10-27  Nick Clifton  <[email protected]>
+
+	* config.sub: Import these changes from the config project:
+
+	2011-10-08  Joern Rennecke <[email protected]>
+	    Ben Elliston  <[email protected]>
+
+	* config.sub (epiphany): New.
+
+	2011-09-09  Linas Vepstas  <[email protected]>
+	    Ben Elliston  <[email protected]>
+
+	* config.sub (hexagon, hexagon-*): New.
+
+	2011-08-23  Roland McGrath  <[email protected]>
+
+	* config.sub: Rename 32eb to be32, 32el to le32, 64el to le64, and
+	64eb to be64.
+
+	2011-08-16  Roland McGrath  <[email protected]>
+
+	* config.sub (32eb, 32el, 64eb, 64el): New (pseudo-)CPUs.
+	(nacl): Grok as alias for 32el-unknown-nacl.
+
 2011-08-19  Joel Brobecker  <[email protected]>
 
 	* src-release (GDB_SUPPORT_DIRS): Add 'cpu'.
@@ -475,11 +1060,11 @@
 
 	* config.guess: Update to version 2011-02-02
 	* config.sub: Update to version 2011-02-24
-	
+
 2011-03-03  Sebastian Pop  <[email protected]>
 
-        * configure.ac: Adjust test of with_ppl.
-        * configure: Regenerated.
+	* configure.ac: Adjust test of with_ppl.
+	* configure: Regenerated.
 
 2011-03-02  Sebastian Pop  <[email protected]>
 
@@ -1086,11 +1671,11 @@
 	* lt~obsolete.m4: Likewise.
 
 2010-01-07  Kaveh R. Ghazi  <[email protected]>
-            Francois-Xavier Coudert  <[email protected]>
+	    Francois-Xavier Coudert  <[email protected]>
 
 	PR bootstrap/42424
 	* configure.ac: Include libtool m4 files.
-        (_LT_CHECK_OBJDIR): Call it.
+	(_LT_CHECK_OBJDIR): Call it.
 	(extra_mpc_mpfr_configure_flags, extra_mpc_gmp_configure_flags,
 	gmplibs, ppllibs, clooglibs): Use $lt_cv_objdir.
 
@@ -1503,8 +2088,8 @@
 2009-06-03  Jerome Guitton  <[email protected]>
 	    Ralf Wildenhues  <[email protected]>
 
-        * Makefile.tpl (all): Avoid a trailing backslash.
-        * Makefile.in: Regenerate.
+	* Makefile.tpl (all): Avoid a trailing backslash.
+	* Makefile.in: Regenerate.
 
 2009-06-03  Ben Elliston  <[email protected]>
 
@@ -3667,7 +4252,7 @@
 	non-ported target libraries in noconfigdirs.
 	<cris-*, crisv32-*> Ditto, except for non-aout, non-elf,
 	non-linux-gnu.  Remove libgcj_ex_libffi.
- 	<lang_frag loop>: Set add_this_lang=no if the language is in
+	<lang_frag loop>: Set add_this_lang=no if the language is in
 	unsupported_languages.
 	* configure: Regenerate.
 
@@ -4988,8 +5573,8 @@
 
 2003-12-21  Bernardo Innocenti  <[email protected]>
 
- 	* configure.in (*-*-uclinux): Exclude newlib, libgloss and rda.
- 	* configure: Regenerated.
+	* configure.in (*-*-uclinux): Exclude newlib, libgloss and rda.
+	* configure: Regenerated.
 
 2003-12-19  Nathanael Nerode  <[email protected]>
 
@@ -13078,8 +13663,8 @@
 
 Sun May  9 17:47:57 1993  Rob Savoye  (rob at darkstar.cygnus.com)
 
-       * Makefile.in: Use srcroot to find runtest rather than rootme.
-       Pass RUNTESTFLAGS and EXPECT down in BASE_FLAGS_TO_PASS.
+	* Makefile.in: Use srcroot to find runtest rather than rootme.
+	Pass RUNTESTFLAGS and EXPECT down in BASE_FLAGS_TO_PASS.
 
 Fri May  7 14:55:59 1993  Ian Lance Taylor  ([email protected])
 
diff --git a/MAINTAINERS b/MAINTAINERS
index 046c5ea..dd8601b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -49,7 +49,8 @@
 include/
 	See binutils/, gdb/, sid/, gcc/, libiberty/ etc.
 
-intl/; config.rhost; libiberty/; libiberty's part of include/ 
+intl/; config.rhost; libiberty/; libiberty's part of include/;
+compile; depcomp; install-sh; missing; ylwrap; config/
 	gcc: http://gcc.gnu.org
 	Changes need to be done in tandem with the official GCC
 	sources or submitted to the master file maintainer and brought
@@ -104,13 +105,6 @@
 	Any global maintainer can approve changes to these
 	files and directories.
 
-compile; depcomp; install-sh; missing; ylwrap;
-config/
-	Any global maintainer can approve changes to these
-	files and directories, but they should be aware
-	that they need to be kept in sync with their
-	counterparts in the GCC repository.
-
 modules file
 	If you understand the file format (or can cut-and-paste existing
 	entries), modify it. If it scares you, get someone who does
diff --git a/Makefile.def b/Makefile.def
index 2c119a0..3ba1a5b 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -4,8 +4,7 @@
 // Makefile.in is generated from Makefile.tpl by 'autogen Makefile.def'.
 // This file was originally written by Nathanael Nerode.
 //
-//   Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-//   Free Software Foundation
+//   Copyright 2002-2013 Free Software Foundation
 //
 // This file is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -61,13 +60,14 @@
 host_modules= { module= mpc; lib_path=.libs; bootstrap=true;
 		extra_configure_flags='--disable-shared @extra_mpc_gmp_configure_flags@ @extra_mpc_mpfr_configure_flags@';
 		no_install= true; };
-host_modules= { module= ppl; lib_path=src/.libs; bootstrap=true;
-		extra_configure_flags='--disable-shared --with-libgmp-prefix=$$r/$(HOST_SUBDIR)/gmp/ --with-libgmpxx-prefix=$$r/$(HOST_SUBDIR)/gmp/';
+host_modules= { module= isl; lib_path=.libs; bootstrap=true;
+		extra_configure_flags='--disable-shared @extra_isl_gmp_configure_flags@';
+		extra_make_flags='V=1';
 		no_install= true; };
 host_modules= { module= cloog; lib_path=.libs; bootstrap=true;
-		extra_configure_flags='--disable-shared --with-gmp-library=$$r/$(HOST_SUBDIR)/gmp/.libs --with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-bits=gmp --with-ppl';
-		extra_exports='CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}"; export CPPFLAGS; LDFLAGS="$$LDFLAGS ${HOST_PPLLIBS}"; export LDFLAGS; ';
-		extra_make_flags='CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS"';
+		extra_configure_flags='--disable-shared --with-gmp=system --with-bits=gmp --with-isl=system';
+		extra_exports='CPPFLAGS="$(HOST_GMPINC) $(HOST_ISLINC) $$CPPFLAGS"; export CPPFLAGS; LDFLAGS="-L$$r/$(HOST_SUBDIR)/gmp/.libs -L$$r/$(HOST_SUBDIR)/isl/.libs $$LDFLAGS"; export LDFLAGS; ';
+		extra_make_flags='CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1';
 		no_install= true; };
 host_modules= { module= libelf; lib_path=.libs; bootstrap=true;
 		extra_configure_flags='--disable-shared';
@@ -79,6 +79,7 @@
                 missing=mostlyclean; };
 host_modules= { module= itcl; };
 host_modules= { module= ld; bootstrap=true; };
+host_modules= { module= libbacktrace; bootstrap=true; };
 host_modules= { module= libcpp; bootstrap=true; };
 host_modules= { module= libdecnumber; bootstrap=true; };
 host_modules= { module= libgui; };
@@ -117,9 +118,18 @@
 		   lib_path=src/.libs;
 		   raw_cxx=true; };
 target_modules = { module= libmudflap; lib_path=.libs; };
+target_modules = { module= libsanitizer;
+		   bootstrap=true;
+		   lib_path=.libs;
+		   raw_cxx=true; };
+target_modules = { module= libvtv;
+		   bootstrap=true;
+		   lib_path=.libs;
+		   raw_cxx=true; };
 target_modules = { module= libssp; lib_path=.libs; };
 target_modules = { module= newlib; };
 target_modules = { module= libgcc; bootstrap=true; no_check=true; };
+target_modules = { module= libbacktrace; };
 target_modules = { module= libquadmath; };
 target_modules = { module= libgfortran; };
 target_modules = { module= libobjc; };
@@ -131,7 +141,7 @@
                    missing=maintainer-clean; };
 target_modules = { module= winsup; };
 target_modules = { module= libgloss; no_check=true; };
-target_modules = { module= libffi; };
+target_modules = { module= libffi; no_install=true; };
 target_modules = { module= libjava; raw_cxx=true;
                    extra_configure_flags="$(EXTRA_CONFIGARGS_LIBJAVA)"; };
 target_modules = { module= zlib; };
@@ -139,6 +149,8 @@
 target_modules = { module= rda; };
 target_modules = { module= libada; };
 target_modules = { module= libgomp; bootstrap= true; lib_path=.libs; };
+target_modules = { module= libitm; lib_path=.libs; };
+target_modules = { module= libatomic; lib_path=.libs; };
 
 // These are (some of) the make targets to be done in each subdirectory.
 // Not all; these are the ones which don't have special options.
@@ -259,6 +271,7 @@
 flags_to_pass = { flag= NM_FOR_TARGET ; };
 flags_to_pass = { flag= OBJDUMP_FOR_TARGET ; };
 flags_to_pass = { flag= RANLIB_FOR_TARGET ; };
+flags_to_pass = { flag= READELF_FOR_TARGET ; };
 flags_to_pass = { flag= STRIP_FOR_TARGET ; };
 flags_to_pass = { flag= WINDRES_FOR_TARGET ; };
 flags_to_pass = { flag= WINDMC_FOR_TARGET ; };
@@ -281,6 +294,7 @@
 
 // Host modules specific to gcc.
 dependencies = { module=configure-gcc; on=configure-intl; };
+dependencies = { module=configure-gcc; on=all-gmp; };
 dependencies = { module=configure-gcc; on=all-lto-plugin; };
 dependencies = { module=configure-gcc; on=all-binutils; };
 dependencies = { module=configure-gcc; on=all-gas; };
@@ -288,11 +302,9 @@
 dependencies = { module=configure-gcc; on=all-gold; };
 dependencies = { module=configure-gcc; on=all-libelf; };
 dependencies = { module=all-gcc; on=all-libiberty; hard=true; };
-dependencies = { module=all-gcc; on=all-gmp; };
 dependencies = { module=all-gcc; on=all-intl; };
 dependencies = { module=all-gcc; on=all-mpfr; };
 dependencies = { module=all-gcc; on=all-mpc; };
-dependencies = { module=all-gcc; on=all-ppl; };
 dependencies = { module=all-gcc; on=all-cloog; };
 dependencies = { module=all-gcc; on=all-build-texinfo; };
 dependencies = { module=all-gcc; on=all-build-bison; };
@@ -300,6 +312,7 @@
 dependencies = { module=all-gcc; on=all-build-libiberty; };
 dependencies = { module=all-gcc; on=all-build-fixincludes; };
 dependencies = { module=all-gcc; on=all-zlib; };
+dependencies = { module=all-gcc; on=all-libbacktrace; hard=true; };
 dependencies = { module=all-gcc; on=all-libcpp; hard=true; };
 dependencies = { module=all-gcc; on=all-libdecnumber; hard=true; };
 dependencies = { module=all-gcc; on=all-libiberty; };
@@ -312,6 +325,7 @@
 dependencies = { module=install-gcc ; on=install-fixincludes; };
 dependencies = { module=install-gcc ; on=install-lto-plugin; };
 dependencies = { module=install-strip-gcc ; on=install-strip-fixincludes; };
+dependencies = { module=install-strip-gcc ; on=install-strip-lto-plugin; };
 
 dependencies = { module=configure-libcpp; on=configure-libiberty; hard=true; };
 dependencies = { module=configure-libcpp; on=configure-intl; };
@@ -328,9 +342,9 @@
 
 dependencies = { module=configure-mpfr; on=all-gmp; };
 dependencies = { module=configure-mpc; on=all-mpfr; };
-dependencies = { module=configure-ppl; on=all-gmp; };
-dependencies = { module=configure-ppl; on=all-mpfr; };
-dependencies = { module=configure-cloog; on=all-ppl; };
+dependencies = { module=configure-isl; on=all-gmp; };
+dependencies = { module=configure-cloog; on=all-isl; };
+dependencies = { module=configure-cloog; on=all-gmp; };
 
 // Host modules specific to gdb.
 dependencies = { module=configure-gdb; on=all-intl; };
@@ -362,6 +376,9 @@
 dependencies = { module=configure-opcodes; on=configure-libiberty; hard=true; };
 dependencies = { module=all-opcodes; on=all-libiberty; };
 
+// We must build gas before binutils, gprof, ld and gold to avoid race
+// condition in the prev-gcc/as script during bootstrap of combined tree
+// with GCC and binutils.  See PR gas/14899 for details.
 dependencies = { module=configure-binutils; on=configure-intl; };
 dependencies = { module=all-binutils; on=all-libiberty; };
 dependencies = { module=all-binutils; on=all-opcodes; };
@@ -369,6 +386,7 @@
 dependencies = { module=all-binutils; on=all-build-flex; };
 dependencies = { module=all-binutils; on=all-build-bison; };
 dependencies = { module=all-binutils; on=all-intl; };
+dependencies = { module=all-binutils; on=all-gas; };
 
 // We put install-opcodes before install-binutils because the installed
 // binutils might be on PATH, and they might need the shared opcodes
@@ -390,6 +408,7 @@
 dependencies = { module=all-gprof; on=all-bfd; };
 dependencies = { module=all-gprof; on=all-opcodes; };
 dependencies = { module=all-gprof; on=all-intl; };
+dependencies = { module=all-gprof; on=all-gas; };
 dependencies = { module=configure-ld; on=configure-intl; };
 dependencies = { module=all-ld; on=all-libiberty; };
 dependencies = { module=all-ld; on=all-bfd; };
@@ -397,6 +416,7 @@
 dependencies = { module=all-ld; on=all-build-bison; };
 dependencies = { module=all-ld; on=all-build-flex; };
 dependencies = { module=all-ld; on=all-intl; };
+dependencies = { module=all-ld; on=all-gas; };
 dependencies = { module=install-ld; on=install-gold; };
 dependencies = { module=install-strip-ld; on=install-strip-gold; };
 dependencies = { module=configure-gold; on=configure-intl; };
@@ -404,6 +424,7 @@
 dependencies = { module=all-gold; on=all-intl; };
 dependencies = { module=all-gold; on=all-bfd; };
 dependencies = { module=all-gold; on=all-build-bison; };
+dependencies = { module=all-gold; on=all-gas; };
 dependencies = { module=check-gold; on=all-binutils; };
 dependencies = { module=check-gold; on=all-gas; };
 
@@ -470,6 +491,7 @@
 // environment (e.g. on libstdc++).  By default target modules depend
 // on libgcc and newlib/libgloss.
 lang_env_dependencies = { module=libjava; cxx=true; };
+lang_env_dependencies = { module=libitm; cxx=true; };
 lang_env_dependencies = { module=newlib; no_c=true; };
 lang_env_dependencies = { module=libgloss; no_c=true; };
 lang_env_dependencies = { module=libgcc; no_gcc=true; no_c=true; };
@@ -483,7 +505,9 @@
 dependencies = { module=all-target-fastjar; on=all-target-zlib; };
 dependencies = { module=configure-target-libgo; on=configure-target-libffi; };
 dependencies = { module=configure-target-libgo; on=all-target-libstdc++-v3; };
+dependencies = { module=all-target-libgo; on=all-target-libbacktrace; };
 dependencies = { module=all-target-libgo; on=all-target-libffi; };
+dependencies = { module=all-target-libgo; on=all-target-libatomic; };
 dependencies = { module=configure-target-libjava; on=configure-target-zlib; };
 dependencies = { module=configure-target-libjava; on=configure-target-boehm-gc; };
 dependencies = { module=configure-target-libjava; on=configure-target-libffi; };
@@ -494,11 +518,25 @@
 dependencies = { module=configure-target-libobjc; on=configure-target-boehm-gc; };
 dependencies = { module=all-target-libobjc; on=all-target-boehm-gc; };
 dependencies = { module=configure-target-libstdc++-v3; on=configure-target-libgomp; };
+dependencies = { module=configure-target-libsanitizer; on=all-target-libstdc++-v3; };
+dependencies = { module=configure-target-libvtv; on=all-target-libstdc++-v3; };
 // parallel_list.o and parallel_settings.o depend on omp.h, which is
 // generated by the libgomp configure.  Unfortunately, due to the use of
 //  recursive make, we can't be that specific.
 dependencies = { module=all-target-libstdc++-v3; on=configure-target-libgomp; };
 
+dependencies = { module=install-target-libgo; on=install-target-libatomic; };
+dependencies = { module=install-target-libgfortran; on=install-target-libquadmath; };
+dependencies = { module=install-target-libgfortran; on=install-target-libgcc; };
+dependencies = { module=install-target-libsanitizer; on=install-target-libstdc++-v3; };
+dependencies = { module=install-target-libsanitizer; on=install-target-libgcc; };
+dependencies = { module=install-target-libvtv; on=install-target-libstdc++-v3; };
+dependencies = { module=install-target-libvtv; on=install-target-libgcc; };
+dependencies = { module=install-target-libjava; on=install-target-libgcc; };
+dependencies = { module=install-target-libitm; on=install-target-libgcc; };
+dependencies = { module=install-target-libobjc; on=install-target-libgcc; };
+dependencies = { module=install-target-libstdc++-v3; on=install-target-libgcc; };
+
 // Target modules in the 'src' repository.
 lang_env_dependencies = { module=libtermcap; };
 lang_env_dependencies = { module=rda; };
@@ -511,9 +549,11 @@
 dependencies = { module=configure-target-libgfortran; on=all-target-libquadmath; };
 
 languages = { language=c;	gcc-check-target=check-gcc; };
-languages = { language=c++;	gcc-check-target="check-c++ check-c++0x";
+languages = { language=c++;	gcc-check-target=check-c++;
 				lib-check-target=check-target-libstdc++-v3;
-				lib-check-target=check-target-libmudflap-c++; };
+				lib-check-target=check-target-libmudflap-c++;
+				lib-check-target=check-target-libitm-c++;
+				lib-check-target=check-target-libgomp-c++; };
 languages = { language=fortran;	gcc-check-target=check-fortran;
 				lib-check-target=check-target-libquadmath;
 				lib-check-target=check-target-libgfortran; };
diff --git a/Makefile.in b/Makefile.in
index 7e4915c..a13771d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -3,7 +3,7 @@
 #
 # Makefile for directory with subdirs to build.
 #   Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-#   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+#   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 #   Free Software Foundation
 #
 # This file is free software; you can redistribute it and/or modify
@@ -206,6 +206,7 @@
 	WINDMC="$(WINDMC)"; export WINDMC; \
 	OBJCOPY="$(OBJCOPY)"; export OBJCOPY; \
 	OBJDUMP="$(OBJDUMP)"; export OBJDUMP; \
+	READELF="$(READELF)"; export READELF; \
 	AR_FOR_TARGET="$(AR_FOR_TARGET)"; export AR_FOR_TARGET; \
 	AS_FOR_TARGET="$(AS_FOR_TARGET)"; export AS_FOR_TARGET; \
 	GCC_FOR_TARGET="$(GCC_FOR_TARGET)"; export GCC_FOR_TARGET; \
@@ -213,12 +214,12 @@
 	NM_FOR_TARGET="$(NM_FOR_TARGET)"; export NM_FOR_TARGET; \
 	OBJDUMP_FOR_TARGET="$(OBJDUMP_FOR_TARGET)"; export OBJDUMP_FOR_TARGET; \
 	RANLIB_FOR_TARGET="$(RANLIB_FOR_TARGET)"; export RANLIB_FOR_TARGET; \
+	READELF_FOR_TARGET="$(READELF_FOR_TARGET)"; export READELF_FOR_TARGET; \
 	TOPLEVEL_CONFIGURE_ARGUMENTS="$(TOPLEVEL_CONFIGURE_ARGUMENTS)"; export TOPLEVEL_CONFIGURE_ARGUMENTS; \
 	HOST_LIBS="$(STAGE1_LIBS)"; export HOST_LIBS; \
 	GMPLIBS="$(HOST_GMPLIBS)"; export GMPLIBS; \
 	GMPINC="$(HOST_GMPINC)"; export GMPINC; \
-	PPLLIBS="$(HOST_PPLLIBS)"; export PPLLIBS; \
-	PPLINC="$(HOST_PPLINC)"; export PPLINC; \
+	ISLINC="$(HOST_ISLINC)"; export ISLINC; \
 	CLOOGLIBS="$(HOST_CLOOGLIBS)"; export CLOOGLIBS; \
 	CLOOGINC="$(HOST_CLOOGINC)"; export CLOOGINC; \
 	LIBELFLIBS="$(HOST_LIBELFLIBS)" ; export LIBELFLIBS; \
@@ -234,7 +235,7 @@
 @if target-libstdc++-v3-bootstrap
 # Override the above if we're bootstrapping C++.
 POSTSTAGE1_CXX_EXPORT = \
-	CXX="$(STAGE_CC_WRAPPER) $$r/$(HOST_SUBDIR)/prev-gcc/g++$(exeext) \
+	CXX="$(STAGE_CC_WRAPPER) $$r/$(HOST_SUBDIR)/prev-gcc/xg++$(exeext) \
 	  -B$$r/$(HOST_SUBDIR)/prev-gcc/ -B$(build_tooldir)/bin/ -nostdinc++ \
 	  -B$$r/prev-$(TARGET_SUBDIR)/libstdc++-v3/src/.libs \
 	  -B$$r/prev-$(TARGET_SUBDIR)/libstdc++-v3/libsupc++/.libs \
@@ -285,6 +286,7 @@
 	NM="$(COMPILER_NM_FOR_TARGET)"; export NM; \
 	OBJDUMP="$(OBJDUMP_FOR_TARGET)"; export OBJDUMP; \
 	RANLIB="$(RANLIB_FOR_TARGET)"; export RANLIB; \
+	READELF="$(READELF_FOR_TARGET)"; export READELF; \
 	STRIP="$(STRIP_FOR_TARGET)"; export STRIP; \
 	WINDRES="$(WINDRES_FOR_TARGET)"; export WINDRES; \
 	WINDMC="$(WINDMC_FOR_TARGET)"; export WINDMC; \
@@ -307,9 +309,8 @@
 HOST_GMPLIBS = @gmplibs@
 HOST_GMPINC = @gmpinc@
 
-# Where to find PPL
-HOST_PPLLIBS = @ppllibs@
-HOST_PPLINC = @pplinc@
+# Where to find ISL
+HOST_ISLINC = @islinc@
 
 # Where to find CLOOG
 HOST_CLOOGLIBS = @clooglibs@
@@ -363,7 +364,7 @@
 # here so that they can be overridden by Makefile fragments.
 BOOT_CFLAGS= -g -O2
 BOOT_LDFLAGS=
-BOOT_ADAFLAGS=-gnatpg -gnata
+BOOT_ADAFLAGS= -gnatpg
 
 AWK = @AWK@
 SED = @SED@
@@ -397,6 +398,7 @@
 NM = @NM@
 OBJDUMP = @OBJDUMP@
 RANLIB = @RANLIB@
+READELF = @READELF@
 STRIP = @STRIP@
 WINDRES = @WINDRES@
 WINDMC = @WINDMC@
@@ -418,7 +420,6 @@
 STAGE_CFLAGS = $(BOOT_CFLAGS)
 STAGE_TFLAGS = $(TFLAGS)
 STAGE_CONFIGURE_FLAGS=@stage2_werror_flag@
-POSTSTAGE1_CONFIGURE_FLAGS = @POSTSTAGE1_CONFIGURE_FLAGS@
 
 
 # Defaults for stage 1; some are overridden below.
@@ -429,10 +430,7 @@
 STAGE1_CXXFLAGS = $(STAGE1_CFLAGS)
 @endif target-libstdc++-v3-bootstrap
 STAGE1_TFLAGS = $(STAGE_TFLAGS)
-# STAGE1_CONFIGURE_FLAGS overridden below, so we can use
-# POSTSTAGE1_CONFIGURE_FLAGS here.
-STAGE1_CONFIGURE_FLAGS = \
-	$(STAGE_CONFIGURE_FLAGS) $(POSTSTAGE1_CONFIGURE_FLAGS)
+STAGE1_CONFIGURE_FLAGS = $(STAGE_CONFIGURE_FLAGS)
 
 # Defaults for stage 2; some are overridden below.
 STAGE2_CFLAGS = $(STAGE_CFLAGS)
@@ -442,10 +440,7 @@
 STAGE2_CXXFLAGS = $(STAGE2_CFLAGS)
 @endif target-libstdc++-v3-bootstrap
 STAGE2_TFLAGS = $(STAGE_TFLAGS)
-# STAGE1_CONFIGURE_FLAGS overridden below, so we can use
-# POSTSTAGE1_CONFIGURE_FLAGS here.
-STAGE2_CONFIGURE_FLAGS = \
-	$(STAGE_CONFIGURE_FLAGS) $(POSTSTAGE1_CONFIGURE_FLAGS)
+STAGE2_CONFIGURE_FLAGS = $(STAGE_CONFIGURE_FLAGS)
 
 # Defaults for stage 3; some are overridden below.
 STAGE3_CFLAGS = $(STAGE_CFLAGS)
@@ -455,10 +450,7 @@
 STAGE3_CXXFLAGS = $(STAGE3_CFLAGS)
 @endif target-libstdc++-v3-bootstrap
 STAGE3_TFLAGS = $(STAGE_TFLAGS)
-# STAGE1_CONFIGURE_FLAGS overridden below, so we can use
-# POSTSTAGE1_CONFIGURE_FLAGS here.
-STAGE3_CONFIGURE_FLAGS = \
-	$(STAGE_CONFIGURE_FLAGS) $(POSTSTAGE1_CONFIGURE_FLAGS)
+STAGE3_CONFIGURE_FLAGS = $(STAGE_CONFIGURE_FLAGS)
 
 # Defaults for stage 4; some are overridden below.
 STAGE4_CFLAGS = $(STAGE_CFLAGS)
@@ -468,10 +460,7 @@
 STAGE4_CXXFLAGS = $(STAGE4_CFLAGS)
 @endif target-libstdc++-v3-bootstrap
 STAGE4_TFLAGS = $(STAGE_TFLAGS)
-# STAGE1_CONFIGURE_FLAGS overridden below, so we can use
-# POSTSTAGE1_CONFIGURE_FLAGS here.
-STAGE4_CONFIGURE_FLAGS = \
-	$(STAGE_CONFIGURE_FLAGS) $(POSTSTAGE1_CONFIGURE_FLAGS)
+STAGE4_CONFIGURE_FLAGS = $(STAGE_CONFIGURE_FLAGS)
 
 # Defaults for stage profile; some are overridden below.
 STAGEprofile_CFLAGS = $(STAGE_CFLAGS)
@@ -481,10 +470,7 @@
 STAGEprofile_CXXFLAGS = $(STAGEprofile_CFLAGS)
 @endif target-libstdc++-v3-bootstrap
 STAGEprofile_TFLAGS = $(STAGE_TFLAGS)
-# STAGE1_CONFIGURE_FLAGS overridden below, so we can use
-# POSTSTAGE1_CONFIGURE_FLAGS here.
-STAGEprofile_CONFIGURE_FLAGS = \
-	$(STAGE_CONFIGURE_FLAGS) $(POSTSTAGE1_CONFIGURE_FLAGS)
+STAGEprofile_CONFIGURE_FLAGS = $(STAGE_CONFIGURE_FLAGS)
 
 # Defaults for stage feedback; some are overridden below.
 STAGEfeedback_CFLAGS = $(STAGE_CFLAGS)
@@ -494,10 +480,7 @@
 STAGEfeedback_CXXFLAGS = $(STAGEfeedback_CFLAGS)
 @endif target-libstdc++-v3-bootstrap
 STAGEfeedback_TFLAGS = $(STAGE_TFLAGS)
-# STAGE1_CONFIGURE_FLAGS overridden below, so we can use
-# POSTSTAGE1_CONFIGURE_FLAGS here.
-STAGEfeedback_CONFIGURE_FLAGS = \
-	$(STAGE_CONFIGURE_FLAGS) $(POSTSTAGE1_CONFIGURE_FLAGS)
+STAGEfeedback_CONFIGURE_FLAGS = $(STAGE_CONFIGURE_FLAGS)
 
 
 # Only build the C compiler for stage1, because that is the only one that
@@ -515,9 +498,6 @@
 #   the last argument when conflicting --enable arguments are passed.
 # * Likewise, we force-disable coverage flags, since the installed
 #   compiler probably has never heard of them.
-# * Don't remove this, because above we added
-#   POSTSTAGE1_CONFIGURE_FLAGS to STAGE_CONFIGURE_FLAGS, which
-#   we don't want for STAGE1_CONFIGURE_FLAGS.
 STAGE1_CONFIGURE_FLAGS = --disable-intermodule $(STAGE1_CHECKING) \
 	  --disable-coverage --enable-languages="$(STAGE1_LANGUAGES)"
 
@@ -555,6 +535,7 @@
 NM_FOR_TARGET=@NM_FOR_TARGET@
 OBJDUMP_FOR_TARGET=@OBJDUMP_FOR_TARGET@
 RANLIB_FOR_TARGET=@RANLIB_FOR_TARGET@
+READELF_FOR_TARGET=@READELF_FOR_TARGET@
 STRIP_FOR_TARGET=@STRIP_FOR_TARGET@
 WINDRES_FOR_TARGET=@WINDRES_FOR_TARGET@
 WINDMC_FOR_TARGET=@WINDMC_FOR_TARGET@
@@ -594,7 +575,7 @@
 
 # This is the list of directories that may be needed in RPATH_ENVVAR
 # so that programs built for the target machine work.
-TARGET_LIB_PATH = $(TARGET_LIB_PATH_libstdc++-v3)$(TARGET_LIB_PATH_libmudflap)$(TARGET_LIB_PATH_libssp)$(TARGET_LIB_PATH_libgomp)$(HOST_LIB_PATH_gcc)
+TARGET_LIB_PATH = $(TARGET_LIB_PATH_libstdc++-v3)$(TARGET_LIB_PATH_libmudflap)$(TARGET_LIB_PATH_libsanitizer)$(TARGET_LIB_PATH_libvtv)$(TARGET_LIB_PATH_libssp)$(TARGET_LIB_PATH_libgomp)$(TARGET_LIB_PATH_libitm)$(TARGET_LIB_PATH_libatomic)$(HOST_LIB_PATH_gcc)
 
 @if target-libstdc++-v3
 TARGET_LIB_PATH_libstdc++-v3 = $$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs:
@@ -604,6 +585,14 @@
 TARGET_LIB_PATH_libmudflap = $$r/$(TARGET_SUBDIR)/libmudflap/.libs:
 @endif target-libmudflap
 
+@if target-libsanitizer
+TARGET_LIB_PATH_libsanitizer = $$r/$(TARGET_SUBDIR)/libsanitizer/.libs:
+@endif target-libsanitizer
+
+@if target-libvtv
+TARGET_LIB_PATH_libvtv = $$r/$(TARGET_SUBDIR)/libvtv/.libs:
+@endif target-libvtv
+
 @if target-libssp
 TARGET_LIB_PATH_libssp = $$r/$(TARGET_SUBDIR)/libssp/.libs:
 @endif target-libssp
@@ -612,11 +601,19 @@
 TARGET_LIB_PATH_libgomp = $$r/$(TARGET_SUBDIR)/libgomp/.libs:
 @endif target-libgomp
 
+@if target-libitm
+TARGET_LIB_PATH_libitm = $$r/$(TARGET_SUBDIR)/libitm/.libs:
+@endif target-libitm
+
+@if target-libatomic
+TARGET_LIB_PATH_libatomic = $$r/$(TARGET_SUBDIR)/libatomic/.libs:
+@endif target-libatomic
+
 
 
 # This is the list of directories that may be needed in RPATH_ENVVAR
 # so that programs built for the host machine work.
-HOST_LIB_PATH = $(HOST_LIB_PATH_gmp)$(HOST_LIB_PATH_mpfr)$(HOST_LIB_PATH_mpc)$(HOST_LIB_PATH_ppl)$(HOST_LIB_PATH_cloog)$(HOST_LIB_PATH_libelf)
+HOST_LIB_PATH = $(HOST_LIB_PATH_gmp)$(HOST_LIB_PATH_mpfr)$(HOST_LIB_PATH_mpc)$(HOST_LIB_PATH_isl)$(HOST_LIB_PATH_cloog)$(HOST_LIB_PATH_libelf)
 
 # Define HOST_LIB_PATH_gcc here, for the sake of TARGET_LIB_PATH, ouch
 @if gcc
@@ -639,10 +636,10 @@
   $$r/$(HOST_SUBDIR)/mpc/.libs:$$r/$(HOST_SUBDIR)/prev-mpc/.libs:
 @endif mpc
 
-@if ppl
-HOST_LIB_PATH_ppl = \
-  $$r/$(HOST_SUBDIR)/ppl/src/.libs:$$r/$(HOST_SUBDIR)/prev-ppl/src/.libs:
-@endif ppl
+@if isl
+HOST_LIB_PATH_isl = \
+  $$r/$(HOST_SUBDIR)/isl/.libs:$$r/$(HOST_SUBDIR)/prev-isl/.libs:
+@endif isl
 
 @if cloog
 HOST_LIB_PATH_cloog = \
@@ -757,6 +754,7 @@
 	"NM_FOR_TARGET=$(NM_FOR_TARGET)" \
 	"OBJDUMP_FOR_TARGET=$(OBJDUMP_FOR_TARGET)" \
 	"RANLIB_FOR_TARGET=$(RANLIB_FOR_TARGET)" \
+	"READELF_FOR_TARGET=$(READELF_FOR_TARGET)" \
 	"STRIP_FOR_TARGET=$(STRIP_FOR_TARGET)" \
 	"WINDRES_FOR_TARGET=$(WINDRES_FOR_TARGET)" \
 	"WINDMC_FOR_TARGET=$(WINDMC_FOR_TARGET)" \
@@ -805,12 +803,19 @@
 	'NM=$(NM)' \
 	'OBJDUMP=$(OBJDUMP)' \
 	'RANLIB=$(RANLIB)' \
+	'READELF=$(READELF)' \
 	'STRIP=$(STRIP)' \
 	'WINDRES=$(WINDRES)' \
 	'WINDMC=$(WINDMC)'
 
 FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)
 
+# Flags to pass to stage1 or when not bootstrapping.
+
+STAGE1_FLAGS_TO_PASS = \
+	LDFLAGS="$${LDFLAGS}" \
+	HOST_LIBS="$${HOST_LIBS}"
+
 # Flags to pass to stage2 and later makes.
 
 POSTSTAGE1_FLAGS_TO_PASS = \
@@ -845,6 +850,7 @@
 	'NM=$(COMPILER_NM_FOR_TARGET)' \
 	'OBJDUMP=$$(OBJDUMP_FOR_TARGET)' \
 	'RANLIB=$$(RANLIB_FOR_TARGET)' \
+	'READELF=$$(READELF_FOR_TARGET)' \
 	'WINDRES=$$(WINDRES_FOR_TARGET)' \
 	'WINDMC=$$(WINDMC_FOR_TARGET)' \
 	'XGCC_FLAGS_FOR_TARGET=$(XGCC_FLAGS_FOR_TARGET)' \
@@ -861,10 +867,7 @@
 EXTRA_GCC_FLAGS = \
 	"GCC_FOR_TARGET=$(GCC_FOR_TARGET)" \
 	"`echo 'STMP_FIXPROTO=$(STMP_FIXPROTO)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
-	"`echo 'LIMITS_H_TEST=$(LIMITS_H_TEST)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
-	"`echo 'LIBGCC2_CFLAGS=$(LIBGCC2_CFLAGS)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
-	"`echo 'LIBGCC2_DEBUG_CFLAGS=$(LIBGCC2_DEBUG_CFLAGS)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
-	"`echo 'LIBGCC2_INCLUDES=$(LIBGCC2_INCLUDES)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`"
+	"`echo 'LIMITS_H_TEST=$(LIMITS_H_TEST)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`"
 
 GCC_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(EXTRA_GCC_FLAGS)
 
@@ -892,7 +895,7 @@
     maybe-configure-gmp \
     maybe-configure-mpfr \
     maybe-configure-mpc \
-    maybe-configure-ppl \
+    maybe-configure-isl \
     maybe-configure-cloog \
     maybe-configure-libelf \
     maybe-configure-gold \
@@ -901,6 +904,7 @@
     maybe-configure-tcl \
     maybe-configure-itcl \
     maybe-configure-ld \
+    maybe-configure-libbacktrace \
     maybe-configure-libcpp \
     maybe-configure-libdecnumber \
     maybe-configure-libgui \
@@ -924,9 +928,12 @@
 configure-target:  \
     maybe-configure-target-libstdc++-v3 \
     maybe-configure-target-libmudflap \
+    maybe-configure-target-libsanitizer \
+    maybe-configure-target-libvtv \
     maybe-configure-target-libssp \
     maybe-configure-target-newlib \
     maybe-configure-target-libgcc \
+    maybe-configure-target-libbacktrace \
     maybe-configure-target-libquadmath \
     maybe-configure-target-libgfortran \
     maybe-configure-target-libobjc \
@@ -940,7 +947,9 @@
     maybe-configure-target-boehm-gc \
     maybe-configure-target-rda \
     maybe-configure-target-libada \
-    maybe-configure-target-libgomp
+    maybe-configure-target-libgomp \
+    maybe-configure-target-libitm \
+    maybe-configure-target-libatomic
 
 # The target built for a native non-bootstrap build.
 .PHONY: all
@@ -1009,9 +1018,9 @@
 @if mpc-no-bootstrap
 all-host: maybe-all-mpc
 @endif mpc-no-bootstrap
-@if ppl-no-bootstrap
-all-host: maybe-all-ppl
-@endif ppl-no-bootstrap
+@if isl-no-bootstrap
+all-host: maybe-all-isl
+@endif isl-no-bootstrap
 @if cloog-no-bootstrap
 all-host: maybe-all-cloog
 @endif cloog-no-bootstrap
@@ -1030,6 +1039,9 @@
 @if ld-no-bootstrap
 all-host: maybe-all-ld
 @endif ld-no-bootstrap
+@if libbacktrace-no-bootstrap
+all-host: maybe-all-libbacktrace
+@endif libbacktrace-no-bootstrap
 @if libcpp-no-bootstrap
 all-host: maybe-all-libcpp
 @endif libcpp-no-bootstrap
@@ -1066,11 +1078,18 @@
 all-target: maybe-all-target-libstdc++-v3
 @endif target-libstdc++-v3-no-bootstrap
 all-target: maybe-all-target-libmudflap
+@if target-libsanitizer-no-bootstrap
+all-target: maybe-all-target-libsanitizer
+@endif target-libsanitizer-no-bootstrap
+@if target-libvtv-no-bootstrap
+all-target: maybe-all-target-libvtv
+@endif target-libvtv-no-bootstrap
 all-target: maybe-all-target-libssp
 all-target: maybe-all-target-newlib
 @if target-libgcc-no-bootstrap
 all-target: maybe-all-target-libgcc
 @endif target-libgcc-no-bootstrap
+all-target: maybe-all-target-libbacktrace
 all-target: maybe-all-target-libquadmath
 all-target: maybe-all-target-libgfortran
 all-target: maybe-all-target-libobjc
@@ -1087,6 +1106,8 @@
 @if target-libgomp-no-bootstrap
 all-target: maybe-all-target-libgomp
 @endif target-libgomp-no-bootstrap
+all-target: maybe-all-target-libitm
+all-target: maybe-all-target-libatomic
 
 # Do a target for all the subdirectories.  A ``make do-X'' will do a
 # ``make X'' in all subdirectories (because, in general, there is a
@@ -1119,7 +1140,7 @@
 info-host: maybe-info-gmp
 info-host: maybe-info-mpfr
 info-host: maybe-info-mpc
-info-host: maybe-info-ppl
+info-host: maybe-info-isl
 info-host: maybe-info-cloog
 info-host: maybe-info-libelf
 info-host: maybe-info-gold
@@ -1128,6 +1149,7 @@
 info-host: maybe-info-tcl
 info-host: maybe-info-itcl
 info-host: maybe-info-ld
+info-host: maybe-info-libbacktrace
 info-host: maybe-info-libcpp
 info-host: maybe-info-libdecnumber
 info-host: maybe-info-libgui
@@ -1152,9 +1174,12 @@
 
 info-target: maybe-info-target-libstdc++-v3
 info-target: maybe-info-target-libmudflap
+info-target: maybe-info-target-libsanitizer
+info-target: maybe-info-target-libvtv
 info-target: maybe-info-target-libssp
 info-target: maybe-info-target-newlib
 info-target: maybe-info-target-libgcc
+info-target: maybe-info-target-libbacktrace
 info-target: maybe-info-target-libquadmath
 info-target: maybe-info-target-libgfortran
 info-target: maybe-info-target-libobjc
@@ -1169,6 +1194,8 @@
 info-target: maybe-info-target-rda
 info-target: maybe-info-target-libada
 info-target: maybe-info-target-libgomp
+info-target: maybe-info-target-libitm
+info-target: maybe-info-target-libatomic
 
 .PHONY: do-dvi
 do-dvi:
@@ -1196,7 +1223,7 @@
 dvi-host: maybe-dvi-gmp
 dvi-host: maybe-dvi-mpfr
 dvi-host: maybe-dvi-mpc
-dvi-host: maybe-dvi-ppl
+dvi-host: maybe-dvi-isl
 dvi-host: maybe-dvi-cloog
 dvi-host: maybe-dvi-libelf
 dvi-host: maybe-dvi-gold
@@ -1205,6 +1232,7 @@
 dvi-host: maybe-dvi-tcl
 dvi-host: maybe-dvi-itcl
 dvi-host: maybe-dvi-ld
+dvi-host: maybe-dvi-libbacktrace
 dvi-host: maybe-dvi-libcpp
 dvi-host: maybe-dvi-libdecnumber
 dvi-host: maybe-dvi-libgui
@@ -1229,9 +1257,12 @@
 
 dvi-target: maybe-dvi-target-libstdc++-v3
 dvi-target: maybe-dvi-target-libmudflap
+dvi-target: maybe-dvi-target-libsanitizer
+dvi-target: maybe-dvi-target-libvtv
 dvi-target: maybe-dvi-target-libssp
 dvi-target: maybe-dvi-target-newlib
 dvi-target: maybe-dvi-target-libgcc
+dvi-target: maybe-dvi-target-libbacktrace
 dvi-target: maybe-dvi-target-libquadmath
 dvi-target: maybe-dvi-target-libgfortran
 dvi-target: maybe-dvi-target-libobjc
@@ -1246,6 +1277,8 @@
 dvi-target: maybe-dvi-target-rda
 dvi-target: maybe-dvi-target-libada
 dvi-target: maybe-dvi-target-libgomp
+dvi-target: maybe-dvi-target-libitm
+dvi-target: maybe-dvi-target-libatomic
 
 .PHONY: do-pdf
 do-pdf:
@@ -1273,7 +1306,7 @@
 pdf-host: maybe-pdf-gmp
 pdf-host: maybe-pdf-mpfr
 pdf-host: maybe-pdf-mpc
-pdf-host: maybe-pdf-ppl
+pdf-host: maybe-pdf-isl
 pdf-host: maybe-pdf-cloog
 pdf-host: maybe-pdf-libelf
 pdf-host: maybe-pdf-gold
@@ -1282,6 +1315,7 @@
 pdf-host: maybe-pdf-tcl
 pdf-host: maybe-pdf-itcl
 pdf-host: maybe-pdf-ld
+pdf-host: maybe-pdf-libbacktrace
 pdf-host: maybe-pdf-libcpp
 pdf-host: maybe-pdf-libdecnumber
 pdf-host: maybe-pdf-libgui
@@ -1306,9 +1340,12 @@
 
 pdf-target: maybe-pdf-target-libstdc++-v3
 pdf-target: maybe-pdf-target-libmudflap
+pdf-target: maybe-pdf-target-libsanitizer
+pdf-target: maybe-pdf-target-libvtv
 pdf-target: maybe-pdf-target-libssp
 pdf-target: maybe-pdf-target-newlib
 pdf-target: maybe-pdf-target-libgcc
+pdf-target: maybe-pdf-target-libbacktrace
 pdf-target: maybe-pdf-target-libquadmath
 pdf-target: maybe-pdf-target-libgfortran
 pdf-target: maybe-pdf-target-libobjc
@@ -1323,6 +1360,8 @@
 pdf-target: maybe-pdf-target-rda
 pdf-target: maybe-pdf-target-libada
 pdf-target: maybe-pdf-target-libgomp
+pdf-target: maybe-pdf-target-libitm
+pdf-target: maybe-pdf-target-libatomic
 
 .PHONY: do-html
 do-html:
@@ -1350,7 +1389,7 @@
 html-host: maybe-html-gmp
 html-host: maybe-html-mpfr
 html-host: maybe-html-mpc
-html-host: maybe-html-ppl
+html-host: maybe-html-isl
 html-host: maybe-html-cloog
 html-host: maybe-html-libelf
 html-host: maybe-html-gold
@@ -1359,6 +1398,7 @@
 html-host: maybe-html-tcl
 html-host: maybe-html-itcl
 html-host: maybe-html-ld
+html-host: maybe-html-libbacktrace
 html-host: maybe-html-libcpp
 html-host: maybe-html-libdecnumber
 html-host: maybe-html-libgui
@@ -1383,9 +1423,12 @@
 
 html-target: maybe-html-target-libstdc++-v3
 html-target: maybe-html-target-libmudflap
+html-target: maybe-html-target-libsanitizer
+html-target: maybe-html-target-libvtv
 html-target: maybe-html-target-libssp
 html-target: maybe-html-target-newlib
 html-target: maybe-html-target-libgcc
+html-target: maybe-html-target-libbacktrace
 html-target: maybe-html-target-libquadmath
 html-target: maybe-html-target-libgfortran
 html-target: maybe-html-target-libobjc
@@ -1400,6 +1443,8 @@
 html-target: maybe-html-target-rda
 html-target: maybe-html-target-libada
 html-target: maybe-html-target-libgomp
+html-target: maybe-html-target-libitm
+html-target: maybe-html-target-libatomic
 
 .PHONY: do-TAGS
 do-TAGS:
@@ -1427,7 +1472,7 @@
 TAGS-host: maybe-TAGS-gmp
 TAGS-host: maybe-TAGS-mpfr
 TAGS-host: maybe-TAGS-mpc
-TAGS-host: maybe-TAGS-ppl
+TAGS-host: maybe-TAGS-isl
 TAGS-host: maybe-TAGS-cloog
 TAGS-host: maybe-TAGS-libelf
 TAGS-host: maybe-TAGS-gold
@@ -1436,6 +1481,7 @@
 TAGS-host: maybe-TAGS-tcl
 TAGS-host: maybe-TAGS-itcl
 TAGS-host: maybe-TAGS-ld
+TAGS-host: maybe-TAGS-libbacktrace
 TAGS-host: maybe-TAGS-libcpp
 TAGS-host: maybe-TAGS-libdecnumber
 TAGS-host: maybe-TAGS-libgui
@@ -1460,9 +1506,12 @@
 
 TAGS-target: maybe-TAGS-target-libstdc++-v3
 TAGS-target: maybe-TAGS-target-libmudflap
+TAGS-target: maybe-TAGS-target-libsanitizer
+TAGS-target: maybe-TAGS-target-libvtv
 TAGS-target: maybe-TAGS-target-libssp
 TAGS-target: maybe-TAGS-target-newlib
 TAGS-target: maybe-TAGS-target-libgcc
+TAGS-target: maybe-TAGS-target-libbacktrace
 TAGS-target: maybe-TAGS-target-libquadmath
 TAGS-target: maybe-TAGS-target-libgfortran
 TAGS-target: maybe-TAGS-target-libobjc
@@ -1477,6 +1526,8 @@
 TAGS-target: maybe-TAGS-target-rda
 TAGS-target: maybe-TAGS-target-libada
 TAGS-target: maybe-TAGS-target-libgomp
+TAGS-target: maybe-TAGS-target-libitm
+TAGS-target: maybe-TAGS-target-libatomic
 
 .PHONY: do-install-info
 do-install-info:
@@ -1504,7 +1555,7 @@
 install-info-host: maybe-install-info-gmp
 install-info-host: maybe-install-info-mpfr
 install-info-host: maybe-install-info-mpc
-install-info-host: maybe-install-info-ppl
+install-info-host: maybe-install-info-isl
 install-info-host: maybe-install-info-cloog
 install-info-host: maybe-install-info-libelf
 install-info-host: maybe-install-info-gold
@@ -1513,6 +1564,7 @@
 install-info-host: maybe-install-info-tcl
 install-info-host: maybe-install-info-itcl
 install-info-host: maybe-install-info-ld
+install-info-host: maybe-install-info-libbacktrace
 install-info-host: maybe-install-info-libcpp
 install-info-host: maybe-install-info-libdecnumber
 install-info-host: maybe-install-info-libgui
@@ -1537,9 +1589,12 @@
 
 install-info-target: maybe-install-info-target-libstdc++-v3
 install-info-target: maybe-install-info-target-libmudflap
+install-info-target: maybe-install-info-target-libsanitizer
+install-info-target: maybe-install-info-target-libvtv
 install-info-target: maybe-install-info-target-libssp
 install-info-target: maybe-install-info-target-newlib
 install-info-target: maybe-install-info-target-libgcc
+install-info-target: maybe-install-info-target-libbacktrace
 install-info-target: maybe-install-info-target-libquadmath
 install-info-target: maybe-install-info-target-libgfortran
 install-info-target: maybe-install-info-target-libobjc
@@ -1554,6 +1609,8 @@
 install-info-target: maybe-install-info-target-rda
 install-info-target: maybe-install-info-target-libada
 install-info-target: maybe-install-info-target-libgomp
+install-info-target: maybe-install-info-target-libitm
+install-info-target: maybe-install-info-target-libatomic
 
 .PHONY: do-install-pdf
 do-install-pdf:
@@ -1581,7 +1638,7 @@
 install-pdf-host: maybe-install-pdf-gmp
 install-pdf-host: maybe-install-pdf-mpfr
 install-pdf-host: maybe-install-pdf-mpc
-install-pdf-host: maybe-install-pdf-ppl
+install-pdf-host: maybe-install-pdf-isl
 install-pdf-host: maybe-install-pdf-cloog
 install-pdf-host: maybe-install-pdf-libelf
 install-pdf-host: maybe-install-pdf-gold
@@ -1590,6 +1647,7 @@
 install-pdf-host: maybe-install-pdf-tcl
 install-pdf-host: maybe-install-pdf-itcl
 install-pdf-host: maybe-install-pdf-ld
+install-pdf-host: maybe-install-pdf-libbacktrace
 install-pdf-host: maybe-install-pdf-libcpp
 install-pdf-host: maybe-install-pdf-libdecnumber
 install-pdf-host: maybe-install-pdf-libgui
@@ -1614,9 +1672,12 @@
 
 install-pdf-target: maybe-install-pdf-target-libstdc++-v3
 install-pdf-target: maybe-install-pdf-target-libmudflap
+install-pdf-target: maybe-install-pdf-target-libsanitizer
+install-pdf-target: maybe-install-pdf-target-libvtv
 install-pdf-target: maybe-install-pdf-target-libssp
 install-pdf-target: maybe-install-pdf-target-newlib
 install-pdf-target: maybe-install-pdf-target-libgcc
+install-pdf-target: maybe-install-pdf-target-libbacktrace
 install-pdf-target: maybe-install-pdf-target-libquadmath
 install-pdf-target: maybe-install-pdf-target-libgfortran
 install-pdf-target: maybe-install-pdf-target-libobjc
@@ -1631,6 +1692,8 @@
 install-pdf-target: maybe-install-pdf-target-rda
 install-pdf-target: maybe-install-pdf-target-libada
 install-pdf-target: maybe-install-pdf-target-libgomp
+install-pdf-target: maybe-install-pdf-target-libitm
+install-pdf-target: maybe-install-pdf-target-libatomic
 
 .PHONY: do-install-html
 do-install-html:
@@ -1658,7 +1721,7 @@
 install-html-host: maybe-install-html-gmp
 install-html-host: maybe-install-html-mpfr
 install-html-host: maybe-install-html-mpc
-install-html-host: maybe-install-html-ppl
+install-html-host: maybe-install-html-isl
 install-html-host: maybe-install-html-cloog
 install-html-host: maybe-install-html-libelf
 install-html-host: maybe-install-html-gold
@@ -1667,6 +1730,7 @@
 install-html-host: maybe-install-html-tcl
 install-html-host: maybe-install-html-itcl
 install-html-host: maybe-install-html-ld
+install-html-host: maybe-install-html-libbacktrace
 install-html-host: maybe-install-html-libcpp
 install-html-host: maybe-install-html-libdecnumber
 install-html-host: maybe-install-html-libgui
@@ -1691,9 +1755,12 @@
 
 install-html-target: maybe-install-html-target-libstdc++-v3
 install-html-target: maybe-install-html-target-libmudflap
+install-html-target: maybe-install-html-target-libsanitizer
+install-html-target: maybe-install-html-target-libvtv
 install-html-target: maybe-install-html-target-libssp
 install-html-target: maybe-install-html-target-newlib
 install-html-target: maybe-install-html-target-libgcc
+install-html-target: maybe-install-html-target-libbacktrace
 install-html-target: maybe-install-html-target-libquadmath
 install-html-target: maybe-install-html-target-libgfortran
 install-html-target: maybe-install-html-target-libobjc
@@ -1708,6 +1775,8 @@
 install-html-target: maybe-install-html-target-rda
 install-html-target: maybe-install-html-target-libada
 install-html-target: maybe-install-html-target-libgomp
+install-html-target: maybe-install-html-target-libitm
+install-html-target: maybe-install-html-target-libatomic
 
 .PHONY: do-installcheck
 do-installcheck:
@@ -1735,7 +1804,7 @@
 installcheck-host: maybe-installcheck-gmp
 installcheck-host: maybe-installcheck-mpfr
 installcheck-host: maybe-installcheck-mpc
-installcheck-host: maybe-installcheck-ppl
+installcheck-host: maybe-installcheck-isl
 installcheck-host: maybe-installcheck-cloog
 installcheck-host: maybe-installcheck-libelf
 installcheck-host: maybe-installcheck-gold
@@ -1744,6 +1813,7 @@
 installcheck-host: maybe-installcheck-tcl
 installcheck-host: maybe-installcheck-itcl
 installcheck-host: maybe-installcheck-ld
+installcheck-host: maybe-installcheck-libbacktrace
 installcheck-host: maybe-installcheck-libcpp
 installcheck-host: maybe-installcheck-libdecnumber
 installcheck-host: maybe-installcheck-libgui
@@ -1768,9 +1838,12 @@
 
 installcheck-target: maybe-installcheck-target-libstdc++-v3
 installcheck-target: maybe-installcheck-target-libmudflap
+installcheck-target: maybe-installcheck-target-libsanitizer
+installcheck-target: maybe-installcheck-target-libvtv
 installcheck-target: maybe-installcheck-target-libssp
 installcheck-target: maybe-installcheck-target-newlib
 installcheck-target: maybe-installcheck-target-libgcc
+installcheck-target: maybe-installcheck-target-libbacktrace
 installcheck-target: maybe-installcheck-target-libquadmath
 installcheck-target: maybe-installcheck-target-libgfortran
 installcheck-target: maybe-installcheck-target-libobjc
@@ -1785,6 +1858,8 @@
 installcheck-target: maybe-installcheck-target-rda
 installcheck-target: maybe-installcheck-target-libada
 installcheck-target: maybe-installcheck-target-libgomp
+installcheck-target: maybe-installcheck-target-libitm
+installcheck-target: maybe-installcheck-target-libatomic
 
 .PHONY: do-mostlyclean
 do-mostlyclean:
@@ -1812,7 +1887,7 @@
 mostlyclean-host: maybe-mostlyclean-gmp
 mostlyclean-host: maybe-mostlyclean-mpfr
 mostlyclean-host: maybe-mostlyclean-mpc
-mostlyclean-host: maybe-mostlyclean-ppl
+mostlyclean-host: maybe-mostlyclean-isl
 mostlyclean-host: maybe-mostlyclean-cloog
 mostlyclean-host: maybe-mostlyclean-libelf
 mostlyclean-host: maybe-mostlyclean-gold
@@ -1821,6 +1896,7 @@
 mostlyclean-host: maybe-mostlyclean-tcl
 mostlyclean-host: maybe-mostlyclean-itcl
 mostlyclean-host: maybe-mostlyclean-ld
+mostlyclean-host: maybe-mostlyclean-libbacktrace
 mostlyclean-host: maybe-mostlyclean-libcpp
 mostlyclean-host: maybe-mostlyclean-libdecnumber
 mostlyclean-host: maybe-mostlyclean-libgui
@@ -1845,9 +1921,12 @@
 
 mostlyclean-target: maybe-mostlyclean-target-libstdc++-v3
 mostlyclean-target: maybe-mostlyclean-target-libmudflap
+mostlyclean-target: maybe-mostlyclean-target-libsanitizer
+mostlyclean-target: maybe-mostlyclean-target-libvtv
 mostlyclean-target: maybe-mostlyclean-target-libssp
 mostlyclean-target: maybe-mostlyclean-target-newlib
 mostlyclean-target: maybe-mostlyclean-target-libgcc
+mostlyclean-target: maybe-mostlyclean-target-libbacktrace
 mostlyclean-target: maybe-mostlyclean-target-libquadmath
 mostlyclean-target: maybe-mostlyclean-target-libgfortran
 mostlyclean-target: maybe-mostlyclean-target-libobjc
@@ -1862,6 +1941,8 @@
 mostlyclean-target: maybe-mostlyclean-target-rda
 mostlyclean-target: maybe-mostlyclean-target-libada
 mostlyclean-target: maybe-mostlyclean-target-libgomp
+mostlyclean-target: maybe-mostlyclean-target-libitm
+mostlyclean-target: maybe-mostlyclean-target-libatomic
 
 .PHONY: do-clean
 do-clean:
@@ -1889,7 +1970,7 @@
 clean-host: maybe-clean-gmp
 clean-host: maybe-clean-mpfr
 clean-host: maybe-clean-mpc
-clean-host: maybe-clean-ppl
+clean-host: maybe-clean-isl
 clean-host: maybe-clean-cloog
 clean-host: maybe-clean-libelf
 clean-host: maybe-clean-gold
@@ -1898,6 +1979,7 @@
 clean-host: maybe-clean-tcl
 clean-host: maybe-clean-itcl
 clean-host: maybe-clean-ld
+clean-host: maybe-clean-libbacktrace
 clean-host: maybe-clean-libcpp
 clean-host: maybe-clean-libdecnumber
 clean-host: maybe-clean-libgui
@@ -1922,9 +2004,12 @@
 
 clean-target: maybe-clean-target-libstdc++-v3
 clean-target: maybe-clean-target-libmudflap
+clean-target: maybe-clean-target-libsanitizer
+clean-target: maybe-clean-target-libvtv
 clean-target: maybe-clean-target-libssp
 clean-target: maybe-clean-target-newlib
 clean-target: maybe-clean-target-libgcc
+clean-target: maybe-clean-target-libbacktrace
 clean-target: maybe-clean-target-libquadmath
 clean-target: maybe-clean-target-libgfortran
 clean-target: maybe-clean-target-libobjc
@@ -1939,6 +2024,8 @@
 clean-target: maybe-clean-target-rda
 clean-target: maybe-clean-target-libada
 clean-target: maybe-clean-target-libgomp
+clean-target: maybe-clean-target-libitm
+clean-target: maybe-clean-target-libatomic
 
 .PHONY: do-distclean
 do-distclean:
@@ -1966,7 +2053,7 @@
 distclean-host: maybe-distclean-gmp
 distclean-host: maybe-distclean-mpfr
 distclean-host: maybe-distclean-mpc
-distclean-host: maybe-distclean-ppl
+distclean-host: maybe-distclean-isl
 distclean-host: maybe-distclean-cloog
 distclean-host: maybe-distclean-libelf
 distclean-host: maybe-distclean-gold
@@ -1975,6 +2062,7 @@
 distclean-host: maybe-distclean-tcl
 distclean-host: maybe-distclean-itcl
 distclean-host: maybe-distclean-ld
+distclean-host: maybe-distclean-libbacktrace
 distclean-host: maybe-distclean-libcpp
 distclean-host: maybe-distclean-libdecnumber
 distclean-host: maybe-distclean-libgui
@@ -1999,9 +2087,12 @@
 
 distclean-target: maybe-distclean-target-libstdc++-v3
 distclean-target: maybe-distclean-target-libmudflap
+distclean-target: maybe-distclean-target-libsanitizer
+distclean-target: maybe-distclean-target-libvtv
 distclean-target: maybe-distclean-target-libssp
 distclean-target: maybe-distclean-target-newlib
 distclean-target: maybe-distclean-target-libgcc
+distclean-target: maybe-distclean-target-libbacktrace
 distclean-target: maybe-distclean-target-libquadmath
 distclean-target: maybe-distclean-target-libgfortran
 distclean-target: maybe-distclean-target-libobjc
@@ -2016,6 +2107,8 @@
 distclean-target: maybe-distclean-target-rda
 distclean-target: maybe-distclean-target-libada
 distclean-target: maybe-distclean-target-libgomp
+distclean-target: maybe-distclean-target-libitm
+distclean-target: maybe-distclean-target-libatomic
 
 .PHONY: do-maintainer-clean
 do-maintainer-clean:
@@ -2043,7 +2136,7 @@
 maintainer-clean-host: maybe-maintainer-clean-gmp
 maintainer-clean-host: maybe-maintainer-clean-mpfr
 maintainer-clean-host: maybe-maintainer-clean-mpc
-maintainer-clean-host: maybe-maintainer-clean-ppl
+maintainer-clean-host: maybe-maintainer-clean-isl
 maintainer-clean-host: maybe-maintainer-clean-cloog
 maintainer-clean-host: maybe-maintainer-clean-libelf
 maintainer-clean-host: maybe-maintainer-clean-gold
@@ -2052,6 +2145,7 @@
 maintainer-clean-host: maybe-maintainer-clean-tcl
 maintainer-clean-host: maybe-maintainer-clean-itcl
 maintainer-clean-host: maybe-maintainer-clean-ld
+maintainer-clean-host: maybe-maintainer-clean-libbacktrace
 maintainer-clean-host: maybe-maintainer-clean-libcpp
 maintainer-clean-host: maybe-maintainer-clean-libdecnumber
 maintainer-clean-host: maybe-maintainer-clean-libgui
@@ -2076,9 +2170,12 @@
 
 maintainer-clean-target: maybe-maintainer-clean-target-libstdc++-v3
 maintainer-clean-target: maybe-maintainer-clean-target-libmudflap
+maintainer-clean-target: maybe-maintainer-clean-target-libsanitizer
+maintainer-clean-target: maybe-maintainer-clean-target-libvtv
 maintainer-clean-target: maybe-maintainer-clean-target-libssp
 maintainer-clean-target: maybe-maintainer-clean-target-newlib
 maintainer-clean-target: maybe-maintainer-clean-target-libgcc
+maintainer-clean-target: maybe-maintainer-clean-target-libbacktrace
 maintainer-clean-target: maybe-maintainer-clean-target-libquadmath
 maintainer-clean-target: maybe-maintainer-clean-target-libgfortran
 maintainer-clean-target: maybe-maintainer-clean-target-libobjc
@@ -2093,6 +2190,8 @@
 maintainer-clean-target: maybe-maintainer-clean-target-rda
 maintainer-clean-target: maybe-maintainer-clean-target-libada
 maintainer-clean-target: maybe-maintainer-clean-target-libgomp
+maintainer-clean-target: maybe-maintainer-clean-target-libitm
+maintainer-clean-target: maybe-maintainer-clean-target-libatomic
 
 
 # Here are the targets which correspond to the do-X targets.
@@ -2175,7 +2274,7 @@
     maybe-check-gmp \
     maybe-check-mpfr \
     maybe-check-mpc \
-    maybe-check-ppl \
+    maybe-check-isl \
     maybe-check-cloog \
     maybe-check-libelf \
     maybe-check-gold \
@@ -2184,6 +2283,7 @@
     maybe-check-tcl \
     maybe-check-itcl \
     maybe-check-ld \
+    maybe-check-libbacktrace \
     maybe-check-libcpp \
     maybe-check-libdecnumber \
     maybe-check-libgui \
@@ -2208,9 +2308,12 @@
 check-target:  \
     maybe-check-target-libstdc++-v3 \
     maybe-check-target-libmudflap \
+    maybe-check-target-libsanitizer \
+    maybe-check-target-libvtv \
     maybe-check-target-libssp \
     maybe-check-target-newlib \
     maybe-check-target-libgcc \
+    maybe-check-target-libbacktrace \
     maybe-check-target-libquadmath \
     maybe-check-target-libgfortran \
     maybe-check-target-libobjc \
@@ -2224,7 +2327,9 @@
     maybe-check-target-boehm-gc \
     maybe-check-target-rda \
     maybe-check-target-libada \
-    maybe-check-target-libgomp
+    maybe-check-target-libgomp \
+    maybe-check-target-libitm \
+    maybe-check-target-libatomic
 
 do-check:
 	@: $(MAKE); $(unstage)
@@ -2278,7 +2383,7 @@
     maybe-install-gmp \
     maybe-install-mpfr \
     maybe-install-mpc \
-    maybe-install-ppl \
+    maybe-install-isl \
     maybe-install-cloog \
     maybe-install-libelf \
     maybe-install-gold \
@@ -2287,6 +2392,7 @@
     maybe-install-tcl \
     maybe-install-itcl \
     maybe-install-ld \
+    maybe-install-libbacktrace \
     maybe-install-libcpp \
     maybe-install-libdecnumber \
     maybe-install-libgui \
@@ -2324,7 +2430,7 @@
     maybe-install-gmp \
     maybe-install-mpfr \
     maybe-install-mpc \
-    maybe-install-ppl \
+    maybe-install-isl \
     maybe-install-cloog \
     maybe-install-libelf \
     maybe-install-gold \
@@ -2333,6 +2439,7 @@
     maybe-install-tcl \
     maybe-install-itcl \
     maybe-install-ld \
+    maybe-install-libbacktrace \
     maybe-install-libcpp \
     maybe-install-libdecnumber \
     maybe-install-libgui \
@@ -2357,9 +2464,12 @@
 install-target:  \
     maybe-install-target-libstdc++-v3 \
     maybe-install-target-libmudflap \
+    maybe-install-target-libsanitizer \
+    maybe-install-target-libvtv \
     maybe-install-target-libssp \
     maybe-install-target-newlib \
     maybe-install-target-libgcc \
+    maybe-install-target-libbacktrace \
     maybe-install-target-libquadmath \
     maybe-install-target-libgfortran \
     maybe-install-target-libobjc \
@@ -2373,7 +2483,9 @@
     maybe-install-target-boehm-gc \
     maybe-install-target-rda \
     maybe-install-target-libada \
-    maybe-install-target-libgomp
+    maybe-install-target-libgomp \
+    maybe-install-target-libitm \
+    maybe-install-target-libatomic
 
 uninstall:
 	@echo "the uninstall target is not supported in this tree"
@@ -2390,11 +2502,12 @@
 		true ; \
 	fi
 
-# install-no-fixedincludes is used because Cygnus can not distribute
-# the fixed header files.
+# install-no-fixedincludes is used to allow the elaboration of binary packages
+# suitable for distribution, where we cannot include the fixed system header
+# files.
 .PHONY: install-no-fixedincludes
 install-no-fixedincludes: installdirs install-host-nogcc \
-	install-target gcc-no-fixedincludes
+	install-target gcc-install-no-fixedincludes
 
 .PHONY: install-strip
 install-strip:
@@ -2420,7 +2533,7 @@
     maybe-install-strip-gmp \
     maybe-install-strip-mpfr \
     maybe-install-strip-mpc \
-    maybe-install-strip-ppl \
+    maybe-install-strip-isl \
     maybe-install-strip-cloog \
     maybe-install-strip-libelf \
     maybe-install-strip-gold \
@@ -2429,6 +2542,7 @@
     maybe-install-strip-tcl \
     maybe-install-strip-itcl \
     maybe-install-strip-ld \
+    maybe-install-strip-libbacktrace \
     maybe-install-strip-libcpp \
     maybe-install-strip-libdecnumber \
     maybe-install-strip-libgui \
@@ -2453,9 +2567,12 @@
 install-strip-target:  \
     maybe-install-strip-target-libstdc++-v3 \
     maybe-install-strip-target-libmudflap \
+    maybe-install-strip-target-libsanitizer \
+    maybe-install-strip-target-libvtv \
     maybe-install-strip-target-libssp \
     maybe-install-strip-target-newlib \
     maybe-install-strip-target-libgcc \
+    maybe-install-strip-target-libbacktrace \
     maybe-install-strip-target-libquadmath \
     maybe-install-strip-target-libgfortran \
     maybe-install-strip-target-libobjc \
@@ -2469,7 +2586,9 @@
     maybe-install-strip-target-boehm-gc \
     maybe-install-strip-target-rda \
     maybe-install-strip-target-libada \
-    maybe-install-strip-target-libgomp
+    maybe-install-strip-target-libgomp \
+    maybe-install-strip-target-libitm \
+    maybe-install-strip-target-libatomic
 
 
 ### other supporting targets
@@ -2563,7 +2682,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(BUILD_EXPORTS)  \
 	(cd $(BUILD_SUBDIR)/libiberty && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_BUILD_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_BUILD_FLAGS)   \
 		$(TARGET-build-libiberty))
 @endif build-libiberty
 
@@ -2619,7 +2738,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(BUILD_EXPORTS)  \
 	(cd $(BUILD_SUBDIR)/bison && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_BUILD_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_BUILD_FLAGS)   \
 		$(TARGET-build-bison))
 @endif build-bison
 
@@ -2675,7 +2794,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(BUILD_EXPORTS)  \
 	(cd $(BUILD_SUBDIR)/flex && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_BUILD_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_BUILD_FLAGS)   \
 		$(TARGET-build-flex))
 @endif build-flex
 
@@ -2731,7 +2850,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(BUILD_EXPORTS)  \
 	(cd $(BUILD_SUBDIR)/m4 && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_BUILD_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_BUILD_FLAGS)   \
 		$(TARGET-build-m4))
 @endif build-m4
 
@@ -2787,7 +2906,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(BUILD_EXPORTS)  \
 	(cd $(BUILD_SUBDIR)/texinfo && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_BUILD_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_BUILD_FLAGS)   \
 		$(TARGET-build-texinfo))
 @endif build-texinfo
 
@@ -2843,7 +2962,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(BUILD_EXPORTS)  \
 	(cd $(BUILD_SUBDIR)/fixincludes && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_BUILD_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_BUILD_FLAGS)   \
 		$(TARGET-build-fixincludes))
 @endif build-fixincludes
 
@@ -3099,7 +3218,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/bfd && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-bfd))
 @endif bfd
 
@@ -3127,7 +3246,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS)   \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS)  \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-bfd)
 
@@ -3142,7 +3262,7 @@
 	fi; \
 	cd $(HOST_SUBDIR)/bfd && \
 	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		 clean
+	$(STAGE1_FLAGS_TO_PASS)  clean
 @endif bfd-bootstrap
 
 
@@ -3183,9 +3303,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/bfd && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif bfd-bootstrap
 
 
@@ -3226,9 +3344,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/bfd && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif bfd-bootstrap
 
 
@@ -3269,9 +3385,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/bfd && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif bfd-bootstrap
 
 
@@ -3312,9 +3426,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/bfd && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif bfd-bootstrap
 
 
@@ -3355,9 +3467,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/bfd && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif bfd-bootstrap
 
 
@@ -3980,7 +4090,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/opcodes && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-opcodes))
 @endif opcodes
 
@@ -4008,7 +4118,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS)   \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS)  \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-opcodes)
 
@@ -4023,7 +4134,7 @@
 	fi; \
 	cd $(HOST_SUBDIR)/opcodes && \
 	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		 clean
+	$(STAGE1_FLAGS_TO_PASS)  clean
 @endif opcodes-bootstrap
 
 
@@ -4064,9 +4175,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/opcodes && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif opcodes-bootstrap
 
 
@@ -4107,9 +4216,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/opcodes && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif opcodes-bootstrap
 
 
@@ -4150,9 +4257,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/opcodes && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif opcodes-bootstrap
 
 
@@ -4193,9 +4298,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/opcodes && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif opcodes-bootstrap
 
 
@@ -4236,9 +4339,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/opcodes && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif opcodes-bootstrap
 
 
@@ -4861,7 +4962,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/binutils && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-binutils))
 @endif binutils
 
@@ -4889,7 +4990,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS)   \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS)  \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-binutils)
 
@@ -4904,7 +5006,7 @@
 	fi; \
 	cd $(HOST_SUBDIR)/binutils && \
 	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		 clean
+	$(STAGE1_FLAGS_TO_PASS)  clean
 @endif binutils-bootstrap
 
 
@@ -4945,9 +5047,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/binutils && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif binutils-bootstrap
 
 
@@ -4988,9 +5088,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/binutils && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif binutils-bootstrap
 
 
@@ -5031,9 +5129,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/binutils && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif binutils-bootstrap
 
 
@@ -5074,9 +5170,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/binutils && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif binutils-bootstrap
 
 
@@ -5117,9 +5211,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/binutils && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif binutils-bootstrap
 
 
@@ -5546,7 +5638,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/bison && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-bison))
 @endif bison
 
@@ -5989,7 +6081,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/cgen && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-cgen))
 @endif cgen
 
@@ -6429,7 +6521,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/dejagnu && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-dejagnu))
 @endif dejagnu
 
@@ -6869,7 +6961,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/etc && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-etc))
 @endif etc
 
@@ -7309,7 +7401,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/fastjar && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-fastjar))
 @endif fastjar
 
@@ -7752,7 +7844,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/fixincludes && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-fixincludes))
 @endif fixincludes
 
@@ -8176,7 +8268,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/flex && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-flex))
 @endif flex
 
@@ -8815,7 +8907,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/gas && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-gas))
 @endif gas
 
@@ -8843,7 +8935,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS)   \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS)  \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-gas)
 
@@ -8858,7 +8951,7 @@
 	fi; \
 	cd $(HOST_SUBDIR)/gas && \
 	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		 clean
+	$(STAGE1_FLAGS_TO_PASS)  clean
 @endif gas-bootstrap
 
 
@@ -8899,9 +8992,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gas && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif gas-bootstrap
 
 
@@ -8942,9 +9033,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gas && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif gas-bootstrap
 
 
@@ -8985,9 +9074,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gas && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif gas-bootstrap
 
 
@@ -9028,9 +9115,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gas && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif gas-bootstrap
 
 
@@ -9071,9 +9156,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gas && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif gas-bootstrap
 
 
@@ -9696,7 +9779,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/gcc && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(EXTRA_GCC_FLAGS) \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS) $(EXTRA_GCC_FLAGS) \
 		$(TARGET-gcc))
 @endif gcc
 
@@ -9724,7 +9807,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS)  $(EXTRA_GCC_FLAGS) \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS) $(EXTRA_GCC_FLAGS) \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-gcc)
 
@@ -9739,7 +9823,7 @@
 	fi; \
 	cd $(HOST_SUBDIR)/gcc && \
 	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(EXTRA_GCC_FLAGS) clean
+	$(STAGE1_FLAGS_TO_PASS) $(EXTRA_GCC_FLAGS) clean
 @endif gcc-bootstrap
 
 
@@ -9780,9 +9864,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gcc && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		$(EXTRA_GCC_FLAGS) clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) $(EXTRA_GCC_FLAGS) clean
 @endif gcc-bootstrap
 
 
@@ -9823,9 +9905,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gcc && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		$(EXTRA_GCC_FLAGS) clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) $(EXTRA_GCC_FLAGS) clean
 @endif gcc-bootstrap
 
 
@@ -9866,9 +9946,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gcc && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		$(EXTRA_GCC_FLAGS) clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) $(EXTRA_GCC_FLAGS) clean
 @endif gcc-bootstrap
 
 
@@ -9909,9 +9987,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gcc && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		$(EXTRA_GCC_FLAGS) clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) $(EXTRA_GCC_FLAGS) clean
 @endif gcc-bootstrap
 
 
@@ -9952,9 +10028,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gcc && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		$(EXTRA_GCC_FLAGS) clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) $(EXTRA_GCC_FLAGS) clean
 @endif gcc-bootstrap
 
 
@@ -10583,7 +10657,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/gmp && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-gmp))
 @endif gmp
 
@@ -10611,7 +10685,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS)   \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS)  \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-gmp)
 
@@ -10626,7 +10701,7 @@
 	fi; \
 	cd $(HOST_SUBDIR)/gmp && \
 	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		 clean
+	$(STAGE1_FLAGS_TO_PASS)  clean
 @endif gmp-bootstrap
 
 
@@ -10667,9 +10742,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gmp && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif gmp-bootstrap
 
 
@@ -10710,9 +10783,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gmp && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif gmp-bootstrap
 
 
@@ -10753,9 +10824,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gmp && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif gmp-bootstrap
 
 
@@ -10796,9 +10865,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gmp && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif gmp-bootstrap
 
 
@@ -10839,9 +10906,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gmp && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif gmp-bootstrap
 
 
@@ -11458,7 +11523,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/mpfr && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-mpfr))
 @endif mpfr
 
@@ -11486,7 +11551,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS)   \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS)  \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-mpfr)
 
@@ -11501,7 +11567,7 @@
 	fi; \
 	cd $(HOST_SUBDIR)/mpfr && \
 	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		 clean
+	$(STAGE1_FLAGS_TO_PASS)  clean
 @endif mpfr-bootstrap
 
 
@@ -11542,9 +11608,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/mpfr && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif mpfr-bootstrap
 
 
@@ -11585,9 +11649,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/mpfr && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif mpfr-bootstrap
 
 
@@ -11628,9 +11690,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/mpfr && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif mpfr-bootstrap
 
 
@@ -11671,9 +11731,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/mpfr && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif mpfr-bootstrap
 
 
@@ -11714,9 +11772,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/mpfr && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif mpfr-bootstrap
 
 
@@ -12333,7 +12389,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/mpc && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-mpc))
 @endif mpc
 
@@ -12361,7 +12417,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS)   \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS)  \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-mpc)
 
@@ -12376,7 +12433,7 @@
 	fi; \
 	cd $(HOST_SUBDIR)/mpc && \
 	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		 clean
+	$(STAGE1_FLAGS_TO_PASS)  clean
 @endif mpc-bootstrap
 
 
@@ -12417,9 +12474,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/mpc && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif mpc-bootstrap
 
 
@@ -12460,9 +12515,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/mpc && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif mpc-bootstrap
 
 
@@ -12503,9 +12556,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/mpc && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif mpc-bootstrap
 
 
@@ -12546,9 +12597,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/mpc && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif mpc-bootstrap
 
 
@@ -12589,9 +12638,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/mpc && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif mpc-bootstrap
 
 
@@ -12959,276 +13006,276 @@
 
 
 
-.PHONY: configure-ppl maybe-configure-ppl
-maybe-configure-ppl:
+.PHONY: configure-isl maybe-configure-isl
+maybe-configure-isl:
 @if gcc-bootstrap
-configure-ppl: stage_current
+configure-isl: stage_current
 @endif gcc-bootstrap
-@if ppl
-maybe-configure-ppl: configure-ppl
-configure-ppl: 
+@if isl
+maybe-configure-isl: configure-isl
+configure-isl: 
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	test ! -f $(HOST_SUBDIR)/ppl/Makefile || exit 0; \
-	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/ppl ; \
+	test ! -f $(HOST_SUBDIR)/isl/Makefile || exit 0; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/isl ; \
 	$(HOST_EXPORTS)  \
-	echo Configuring in $(HOST_SUBDIR)/ppl; \
-	cd "$(HOST_SUBDIR)/ppl" || exit 1; \
+	echo Configuring in $(HOST_SUBDIR)/isl; \
+	cd "$(HOST_SUBDIR)/isl" || exit 1; \
 	case $(srcdir) in \
 	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
-	  *) topdir=`echo $(HOST_SUBDIR)/ppl/ | \
+	  *) topdir=`echo $(HOST_SUBDIR)/isl/ | \
 		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
 	esac; \
-	srcdiroption="--srcdir=$${topdir}/ppl"; \
-	libsrcdir="$$s/ppl"; \
+	srcdiroption="--srcdir=$${topdir}/isl"; \
+	libsrcdir="$$s/isl"; \
 	$(SHELL) $${libsrcdir}/configure \
 	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
-	  --target=${target_alias} $${srcdiroption} --disable-shared --with-libgmp-prefix=$$r/$(HOST_SUBDIR)/gmp/ --with-libgmpxx-prefix=$$r/$(HOST_SUBDIR)/gmp/ \
+	  --target=${target_alias} $${srcdiroption} --disable-shared @extra_isl_gmp_configure_flags@ \
 	  || exit 1
-@endif ppl
+@endif isl
 
 
 
-.PHONY: configure-stage1-ppl maybe-configure-stage1-ppl
-maybe-configure-stage1-ppl:
-@if ppl-bootstrap
-maybe-configure-stage1-ppl: configure-stage1-ppl
-configure-stage1-ppl:
+.PHONY: configure-stage1-isl maybe-configure-stage1-isl
+maybe-configure-stage1-isl:
+@if isl-bootstrap
+maybe-configure-stage1-isl: configure-stage1-isl
+configure-stage1-isl:
 	@[ $(current_stage) = stage1 ] || $(MAKE) stage1-start
-	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/ppl
+	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/isl
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGE1_TFLAGS)"; \
-	test ! -f $(HOST_SUBDIR)/ppl/Makefile || exit 0; \
+	test ! -f $(HOST_SUBDIR)/isl/Makefile || exit 0; \
 	$(HOST_EXPORTS) \
 	CFLAGS="$(STAGE1_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGE1_CXXFLAGS)"; export CXXFLAGS; \
 	LIBCFLAGS="$(LIBCFLAGS)"; export LIBCFLAGS;  \
-	echo Configuring stage 1 in $(HOST_SUBDIR)/ppl ; \
-	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/ppl ; \
-	cd $(HOST_SUBDIR)/ppl || exit 1; \
+	echo Configuring stage 1 in $(HOST_SUBDIR)/isl ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/isl ; \
+	cd $(HOST_SUBDIR)/isl || exit 1; \
 	case $(srcdir) in \
 	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
-	  *) topdir=`echo $(HOST_SUBDIR)/ppl/ | \
+	  *) topdir=`echo $(HOST_SUBDIR)/isl/ | \
 		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
 	esac; \
-	srcdiroption="--srcdir=$${topdir}/ppl"; \
-	libsrcdir="$$s/ppl"; \
+	srcdiroption="--srcdir=$${topdir}/isl"; \
+	libsrcdir="$$s/isl"; \
 	$(SHELL) $${libsrcdir}/configure \
 	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
 	  --target=${target_alias} $${srcdiroption} \
 	  $(STAGE1_CONFIGURE_FLAGS) \
-	  --disable-shared --with-libgmp-prefix=$$r/$(HOST_SUBDIR)/gmp/ --with-libgmpxx-prefix=$$r/$(HOST_SUBDIR)/gmp/
-@endif ppl-bootstrap
+	  --disable-shared @extra_isl_gmp_configure_flags@
+@endif isl-bootstrap
 
-.PHONY: configure-stage2-ppl maybe-configure-stage2-ppl
-maybe-configure-stage2-ppl:
-@if ppl-bootstrap
-maybe-configure-stage2-ppl: configure-stage2-ppl
-configure-stage2-ppl:
+.PHONY: configure-stage2-isl maybe-configure-stage2-isl
+maybe-configure-stage2-isl:
+@if isl-bootstrap
+maybe-configure-stage2-isl: configure-stage2-isl
+configure-stage2-isl:
 	@[ $(current_stage) = stage2 ] || $(MAKE) stage2-start
-	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/ppl
+	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/isl
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGE2_TFLAGS)"; \
-	test ! -f $(HOST_SUBDIR)/ppl/Makefile || exit 0; \
+	test ! -f $(HOST_SUBDIR)/isl/Makefile || exit 0; \
 	$(HOST_EXPORTS) \
 	$(POSTSTAGE1_HOST_EXPORTS) \
 	CFLAGS="$(STAGE2_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGE2_CXXFLAGS)"; export CXXFLAGS; \
 	LIBCFLAGS="$(STAGE2_CFLAGS)"; export LIBCFLAGS;  \
-	echo Configuring stage 2 in $(HOST_SUBDIR)/ppl ; \
-	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/ppl ; \
-	cd $(HOST_SUBDIR)/ppl || exit 1; \
+	echo Configuring stage 2 in $(HOST_SUBDIR)/isl ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/isl ; \
+	cd $(HOST_SUBDIR)/isl || exit 1; \
 	case $(srcdir) in \
 	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
-	  *) topdir=`echo $(HOST_SUBDIR)/ppl/ | \
+	  *) topdir=`echo $(HOST_SUBDIR)/isl/ | \
 		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
 	esac; \
-	srcdiroption="--srcdir=$${topdir}/ppl"; \
-	libsrcdir="$$s/ppl"; \
+	srcdiroption="--srcdir=$${topdir}/isl"; \
+	libsrcdir="$$s/isl"; \
 	$(SHELL) $${libsrcdir}/configure \
 	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
 	  --target=${target_alias} $${srcdiroption} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE2_CONFIGURE_FLAGS) \
-	  --disable-shared --with-libgmp-prefix=$$r/$(HOST_SUBDIR)/gmp/ --with-libgmpxx-prefix=$$r/$(HOST_SUBDIR)/gmp/
-@endif ppl-bootstrap
+	  --disable-shared @extra_isl_gmp_configure_flags@
+@endif isl-bootstrap
 
-.PHONY: configure-stage3-ppl maybe-configure-stage3-ppl
-maybe-configure-stage3-ppl:
-@if ppl-bootstrap
-maybe-configure-stage3-ppl: configure-stage3-ppl
-configure-stage3-ppl:
+.PHONY: configure-stage3-isl maybe-configure-stage3-isl
+maybe-configure-stage3-isl:
+@if isl-bootstrap
+maybe-configure-stage3-isl: configure-stage3-isl
+configure-stage3-isl:
 	@[ $(current_stage) = stage3 ] || $(MAKE) stage3-start
-	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/ppl
+	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/isl
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGE3_TFLAGS)"; \
-	test ! -f $(HOST_SUBDIR)/ppl/Makefile || exit 0; \
+	test ! -f $(HOST_SUBDIR)/isl/Makefile || exit 0; \
 	$(HOST_EXPORTS) \
 	$(POSTSTAGE1_HOST_EXPORTS) \
 	CFLAGS="$(STAGE3_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGE3_CXXFLAGS)"; export CXXFLAGS; \
 	LIBCFLAGS="$(STAGE3_CFLAGS)"; export LIBCFLAGS;  \
-	echo Configuring stage 3 in $(HOST_SUBDIR)/ppl ; \
-	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/ppl ; \
-	cd $(HOST_SUBDIR)/ppl || exit 1; \
+	echo Configuring stage 3 in $(HOST_SUBDIR)/isl ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/isl ; \
+	cd $(HOST_SUBDIR)/isl || exit 1; \
 	case $(srcdir) in \
 	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
-	  *) topdir=`echo $(HOST_SUBDIR)/ppl/ | \
+	  *) topdir=`echo $(HOST_SUBDIR)/isl/ | \
 		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
 	esac; \
-	srcdiroption="--srcdir=$${topdir}/ppl"; \
-	libsrcdir="$$s/ppl"; \
+	srcdiroption="--srcdir=$${topdir}/isl"; \
+	libsrcdir="$$s/isl"; \
 	$(SHELL) $${libsrcdir}/configure \
 	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
 	  --target=${target_alias} $${srcdiroption} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE3_CONFIGURE_FLAGS) \
-	  --disable-shared --with-libgmp-prefix=$$r/$(HOST_SUBDIR)/gmp/ --with-libgmpxx-prefix=$$r/$(HOST_SUBDIR)/gmp/
-@endif ppl-bootstrap
+	  --disable-shared @extra_isl_gmp_configure_flags@
+@endif isl-bootstrap
 
-.PHONY: configure-stage4-ppl maybe-configure-stage4-ppl
-maybe-configure-stage4-ppl:
-@if ppl-bootstrap
-maybe-configure-stage4-ppl: configure-stage4-ppl
-configure-stage4-ppl:
+.PHONY: configure-stage4-isl maybe-configure-stage4-isl
+maybe-configure-stage4-isl:
+@if isl-bootstrap
+maybe-configure-stage4-isl: configure-stage4-isl
+configure-stage4-isl:
 	@[ $(current_stage) = stage4 ] || $(MAKE) stage4-start
-	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/ppl
+	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/isl
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGE4_TFLAGS)"; \
-	test ! -f $(HOST_SUBDIR)/ppl/Makefile || exit 0; \
+	test ! -f $(HOST_SUBDIR)/isl/Makefile || exit 0; \
 	$(HOST_EXPORTS) \
 	$(POSTSTAGE1_HOST_EXPORTS) \
 	CFLAGS="$(STAGE4_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGE4_CXXFLAGS)"; export CXXFLAGS; \
 	LIBCFLAGS="$(STAGE4_CFLAGS)"; export LIBCFLAGS;  \
-	echo Configuring stage 4 in $(HOST_SUBDIR)/ppl ; \
-	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/ppl ; \
-	cd $(HOST_SUBDIR)/ppl || exit 1; \
+	echo Configuring stage 4 in $(HOST_SUBDIR)/isl ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/isl ; \
+	cd $(HOST_SUBDIR)/isl || exit 1; \
 	case $(srcdir) in \
 	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
-	  *) topdir=`echo $(HOST_SUBDIR)/ppl/ | \
+	  *) topdir=`echo $(HOST_SUBDIR)/isl/ | \
 		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
 	esac; \
-	srcdiroption="--srcdir=$${topdir}/ppl"; \
-	libsrcdir="$$s/ppl"; \
+	srcdiroption="--srcdir=$${topdir}/isl"; \
+	libsrcdir="$$s/isl"; \
 	$(SHELL) $${libsrcdir}/configure \
 	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
 	  --target=${target_alias} $${srcdiroption} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE4_CONFIGURE_FLAGS) \
-	  --disable-shared --with-libgmp-prefix=$$r/$(HOST_SUBDIR)/gmp/ --with-libgmpxx-prefix=$$r/$(HOST_SUBDIR)/gmp/
-@endif ppl-bootstrap
+	  --disable-shared @extra_isl_gmp_configure_flags@
+@endif isl-bootstrap
 
-.PHONY: configure-stageprofile-ppl maybe-configure-stageprofile-ppl
-maybe-configure-stageprofile-ppl:
-@if ppl-bootstrap
-maybe-configure-stageprofile-ppl: configure-stageprofile-ppl
-configure-stageprofile-ppl:
+.PHONY: configure-stageprofile-isl maybe-configure-stageprofile-isl
+maybe-configure-stageprofile-isl:
+@if isl-bootstrap
+maybe-configure-stageprofile-isl: configure-stageprofile-isl
+configure-stageprofile-isl:
 	@[ $(current_stage) = stageprofile ] || $(MAKE) stageprofile-start
-	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/ppl
+	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/isl
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGEprofile_TFLAGS)"; \
-	test ! -f $(HOST_SUBDIR)/ppl/Makefile || exit 0; \
+	test ! -f $(HOST_SUBDIR)/isl/Makefile || exit 0; \
 	$(HOST_EXPORTS) \
 	$(POSTSTAGE1_HOST_EXPORTS) \
 	CFLAGS="$(STAGEprofile_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGEprofile_CXXFLAGS)"; export CXXFLAGS; \
 	LIBCFLAGS="$(STAGEprofile_CFLAGS)"; export LIBCFLAGS;  \
-	echo Configuring stage profile in $(HOST_SUBDIR)/ppl ; \
-	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/ppl ; \
-	cd $(HOST_SUBDIR)/ppl || exit 1; \
+	echo Configuring stage profile in $(HOST_SUBDIR)/isl ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/isl ; \
+	cd $(HOST_SUBDIR)/isl || exit 1; \
 	case $(srcdir) in \
 	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
-	  *) topdir=`echo $(HOST_SUBDIR)/ppl/ | \
+	  *) topdir=`echo $(HOST_SUBDIR)/isl/ | \
 		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
 	esac; \
-	srcdiroption="--srcdir=$${topdir}/ppl"; \
-	libsrcdir="$$s/ppl"; \
+	srcdiroption="--srcdir=$${topdir}/isl"; \
+	libsrcdir="$$s/isl"; \
 	$(SHELL) $${libsrcdir}/configure \
 	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
 	  --target=${target_alias} $${srcdiroption} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEprofile_CONFIGURE_FLAGS) \
-	  --disable-shared --with-libgmp-prefix=$$r/$(HOST_SUBDIR)/gmp/ --with-libgmpxx-prefix=$$r/$(HOST_SUBDIR)/gmp/
-@endif ppl-bootstrap
+	  --disable-shared @extra_isl_gmp_configure_flags@
+@endif isl-bootstrap
 
-.PHONY: configure-stagefeedback-ppl maybe-configure-stagefeedback-ppl
-maybe-configure-stagefeedback-ppl:
-@if ppl-bootstrap
-maybe-configure-stagefeedback-ppl: configure-stagefeedback-ppl
-configure-stagefeedback-ppl:
+.PHONY: configure-stagefeedback-isl maybe-configure-stagefeedback-isl
+maybe-configure-stagefeedback-isl:
+@if isl-bootstrap
+maybe-configure-stagefeedback-isl: configure-stagefeedback-isl
+configure-stagefeedback-isl:
 	@[ $(current_stage) = stagefeedback ] || $(MAKE) stagefeedback-start
-	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/ppl
+	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/isl
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGEfeedback_TFLAGS)"; \
-	test ! -f $(HOST_SUBDIR)/ppl/Makefile || exit 0; \
+	test ! -f $(HOST_SUBDIR)/isl/Makefile || exit 0; \
 	$(HOST_EXPORTS) \
 	$(POSTSTAGE1_HOST_EXPORTS) \
 	CFLAGS="$(STAGEfeedback_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGEfeedback_CXXFLAGS)"; export CXXFLAGS; \
 	LIBCFLAGS="$(STAGEfeedback_CFLAGS)"; export LIBCFLAGS;  \
-	echo Configuring stage feedback in $(HOST_SUBDIR)/ppl ; \
-	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/ppl ; \
-	cd $(HOST_SUBDIR)/ppl || exit 1; \
+	echo Configuring stage feedback in $(HOST_SUBDIR)/isl ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/isl ; \
+	cd $(HOST_SUBDIR)/isl || exit 1; \
 	case $(srcdir) in \
 	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
-	  *) topdir=`echo $(HOST_SUBDIR)/ppl/ | \
+	  *) topdir=`echo $(HOST_SUBDIR)/isl/ | \
 		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
 	esac; \
-	srcdiroption="--srcdir=$${topdir}/ppl"; \
-	libsrcdir="$$s/ppl"; \
+	srcdiroption="--srcdir=$${topdir}/isl"; \
+	libsrcdir="$$s/isl"; \
 	$(SHELL) $${libsrcdir}/configure \
 	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
 	  --target=${target_alias} $${srcdiroption} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEfeedback_CONFIGURE_FLAGS) \
-	  --disable-shared --with-libgmp-prefix=$$r/$(HOST_SUBDIR)/gmp/ --with-libgmpxx-prefix=$$r/$(HOST_SUBDIR)/gmp/
-@endif ppl-bootstrap
+	  --disable-shared @extra_isl_gmp_configure_flags@
+@endif isl-bootstrap
 
 
 
 
 
-.PHONY: all-ppl maybe-all-ppl
-maybe-all-ppl:
+.PHONY: all-isl maybe-all-isl
+maybe-all-isl:
 @if gcc-bootstrap
-all-ppl: stage_current
+all-isl: stage_current
 @endif gcc-bootstrap
-@if ppl
-TARGET-ppl=all
-maybe-all-ppl: all-ppl
-all-ppl: configure-ppl
+@if isl
+TARGET-isl=all
+maybe-all-isl: all-isl
+all-isl: configure-isl
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
-	(cd $(HOST_SUBDIR)/ppl && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
-		$(TARGET-ppl))
-@endif ppl
+	(cd $(HOST_SUBDIR)/isl && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS) V=1 \
+		$(TARGET-isl))
+@endif isl
 
 
 
-.PHONY: all-stage1-ppl maybe-all-stage1-ppl
-.PHONY: clean-stage1-ppl maybe-clean-stage1-ppl
-maybe-all-stage1-ppl:
-maybe-clean-stage1-ppl:
-@if ppl-bootstrap
-maybe-all-stage1-ppl: all-stage1-ppl
-all-stage1: all-stage1-ppl
-TARGET-stage1-ppl = $(TARGET-ppl)
-all-stage1-ppl: configure-stage1-ppl
+.PHONY: all-stage1-isl maybe-all-stage1-isl
+.PHONY: clean-stage1-isl maybe-clean-stage1-isl
+maybe-all-stage1-isl:
+maybe-clean-stage1-isl:
+@if isl-bootstrap
+maybe-all-stage1-isl: all-stage1-isl
+all-stage1: all-stage1-isl
+TARGET-stage1-isl = $(TARGET-isl)
+all-stage1-isl: configure-stage1-isl
 	@[ $(current_stage) = stage1 ] || $(MAKE) stage1-start
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGE1_TFLAGS)"; \
 	$(HOST_EXPORTS)  \
-	cd $(HOST_SUBDIR)/ppl && \
+	cd $(HOST_SUBDIR)/isl && \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
 		CFLAGS="$(STAGE1_CFLAGS)" \
 		CXXFLAGS="$(STAGE1_CXXFLAGS)" \
@@ -13236,41 +13283,42 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS)   \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS) V=1 \
 		TFLAGS="$(STAGE1_TFLAGS)" \
-		$(TARGET-stage1-ppl)
+		$(TARGET-stage1-isl)
 
-maybe-clean-stage1-ppl: clean-stage1-ppl
-clean-stage1: clean-stage1-ppl
-clean-stage1-ppl:
+maybe-clean-stage1-isl: clean-stage1-isl
+clean-stage1: clean-stage1-isl
+clean-stage1-isl:
 	@if [ $(current_stage) = stage1 ]; then \
-	  [ -f $(HOST_SUBDIR)/ppl/Makefile ] || exit 0; \
+	  [ -f $(HOST_SUBDIR)/isl/Makefile ] || exit 0; \
 	else \
-	  [ -f $(HOST_SUBDIR)/stage1-ppl/Makefile ] || exit 0; \
+	  [ -f $(HOST_SUBDIR)/stage1-isl/Makefile ] || exit 0; \
 	  $(MAKE) stage1-start; \
 	fi; \
-	cd $(HOST_SUBDIR)/ppl && \
+	cd $(HOST_SUBDIR)/isl && \
 	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		 clean
-@endif ppl-bootstrap
+	$(STAGE1_FLAGS_TO_PASS) V=1 clean
+@endif isl-bootstrap
 
 
-.PHONY: all-stage2-ppl maybe-all-stage2-ppl
-.PHONY: clean-stage2-ppl maybe-clean-stage2-ppl
-maybe-all-stage2-ppl:
-maybe-clean-stage2-ppl:
-@if ppl-bootstrap
-maybe-all-stage2-ppl: all-stage2-ppl
-all-stage2: all-stage2-ppl
-TARGET-stage2-ppl = $(TARGET-ppl)
-all-stage2-ppl: configure-stage2-ppl
+.PHONY: all-stage2-isl maybe-all-stage2-isl
+.PHONY: clean-stage2-isl maybe-clean-stage2-isl
+maybe-all-stage2-isl:
+maybe-clean-stage2-isl:
+@if isl-bootstrap
+maybe-all-stage2-isl: all-stage2-isl
+all-stage2: all-stage2-isl
+TARGET-stage2-isl = $(TARGET-isl)
+all-stage2-isl: configure-stage2-isl
 	@[ $(current_stage) = stage2 ] || $(MAKE) stage2-start
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGE2_TFLAGS)"; \
 	$(HOST_EXPORTS) \
 	$(POSTSTAGE1_HOST_EXPORTS)  \
-	cd $(HOST_SUBDIR)/ppl && \
+	cd $(HOST_SUBDIR)/isl && \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
 		CFLAGS="$(STAGE2_CFLAGS)" \
 		CXXFLAGS="$(STAGE2_CXXFLAGS)" \
@@ -13278,42 +13326,40 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  \
+		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 \
 		TFLAGS="$(STAGE2_TFLAGS)" \
-		$(TARGET-stage2-ppl)
+		$(TARGET-stage2-isl)
 
-maybe-clean-stage2-ppl: clean-stage2-ppl
-clean-stage2: clean-stage2-ppl
-clean-stage2-ppl:
+maybe-clean-stage2-isl: clean-stage2-isl
+clean-stage2: clean-stage2-isl
+clean-stage2-isl:
 	@if [ $(current_stage) = stage2 ]; then \
-	  [ -f $(HOST_SUBDIR)/ppl/Makefile ] || exit 0; \
+	  [ -f $(HOST_SUBDIR)/isl/Makefile ] || exit 0; \
 	else \
-	  [ -f $(HOST_SUBDIR)/stage2-ppl/Makefile ] || exit 0; \
+	  [ -f $(HOST_SUBDIR)/stage2-isl/Makefile ] || exit 0; \
 	  $(MAKE) stage2-start; \
 	fi; \
-	cd $(HOST_SUBDIR)/ppl && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
-@endif ppl-bootstrap
+	cd $(HOST_SUBDIR)/isl && \
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 clean
+@endif isl-bootstrap
 
 
-.PHONY: all-stage3-ppl maybe-all-stage3-ppl
-.PHONY: clean-stage3-ppl maybe-clean-stage3-ppl
-maybe-all-stage3-ppl:
-maybe-clean-stage3-ppl:
-@if ppl-bootstrap
-maybe-all-stage3-ppl: all-stage3-ppl
-all-stage3: all-stage3-ppl
-TARGET-stage3-ppl = $(TARGET-ppl)
-all-stage3-ppl: configure-stage3-ppl
+.PHONY: all-stage3-isl maybe-all-stage3-isl
+.PHONY: clean-stage3-isl maybe-clean-stage3-isl
+maybe-all-stage3-isl:
+maybe-clean-stage3-isl:
+@if isl-bootstrap
+maybe-all-stage3-isl: all-stage3-isl
+all-stage3: all-stage3-isl
+TARGET-stage3-isl = $(TARGET-isl)
+all-stage3-isl: configure-stage3-isl
 	@[ $(current_stage) = stage3 ] || $(MAKE) stage3-start
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGE3_TFLAGS)"; \
 	$(HOST_EXPORTS) \
 	$(POSTSTAGE1_HOST_EXPORTS)  \
-	cd $(HOST_SUBDIR)/ppl && \
+	cd $(HOST_SUBDIR)/isl && \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
 		CFLAGS="$(STAGE3_CFLAGS)" \
 		CXXFLAGS="$(STAGE3_CXXFLAGS)" \
@@ -13321,42 +13367,40 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  \
+		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 \
 		TFLAGS="$(STAGE3_TFLAGS)" \
-		$(TARGET-stage3-ppl)
+		$(TARGET-stage3-isl)
 
-maybe-clean-stage3-ppl: clean-stage3-ppl
-clean-stage3: clean-stage3-ppl
-clean-stage3-ppl:
+maybe-clean-stage3-isl: clean-stage3-isl
+clean-stage3: clean-stage3-isl
+clean-stage3-isl:
 	@if [ $(current_stage) = stage3 ]; then \
-	  [ -f $(HOST_SUBDIR)/ppl/Makefile ] || exit 0; \
+	  [ -f $(HOST_SUBDIR)/isl/Makefile ] || exit 0; \
 	else \
-	  [ -f $(HOST_SUBDIR)/stage3-ppl/Makefile ] || exit 0; \
+	  [ -f $(HOST_SUBDIR)/stage3-isl/Makefile ] || exit 0; \
 	  $(MAKE) stage3-start; \
 	fi; \
-	cd $(HOST_SUBDIR)/ppl && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
-@endif ppl-bootstrap
+	cd $(HOST_SUBDIR)/isl && \
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 clean
+@endif isl-bootstrap
 
 
-.PHONY: all-stage4-ppl maybe-all-stage4-ppl
-.PHONY: clean-stage4-ppl maybe-clean-stage4-ppl
-maybe-all-stage4-ppl:
-maybe-clean-stage4-ppl:
-@if ppl-bootstrap
-maybe-all-stage4-ppl: all-stage4-ppl
-all-stage4: all-stage4-ppl
-TARGET-stage4-ppl = $(TARGET-ppl)
-all-stage4-ppl: configure-stage4-ppl
+.PHONY: all-stage4-isl maybe-all-stage4-isl
+.PHONY: clean-stage4-isl maybe-clean-stage4-isl
+maybe-all-stage4-isl:
+maybe-clean-stage4-isl:
+@if isl-bootstrap
+maybe-all-stage4-isl: all-stage4-isl
+all-stage4: all-stage4-isl
+TARGET-stage4-isl = $(TARGET-isl)
+all-stage4-isl: configure-stage4-isl
 	@[ $(current_stage) = stage4 ] || $(MAKE) stage4-start
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGE4_TFLAGS)"; \
 	$(HOST_EXPORTS) \
 	$(POSTSTAGE1_HOST_EXPORTS)  \
-	cd $(HOST_SUBDIR)/ppl && \
+	cd $(HOST_SUBDIR)/isl && \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
 		CFLAGS="$(STAGE4_CFLAGS)" \
 		CXXFLAGS="$(STAGE4_CXXFLAGS)" \
@@ -13364,42 +13408,40 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  \
+		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 \
 		TFLAGS="$(STAGE4_TFLAGS)" \
-		$(TARGET-stage4-ppl)
+		$(TARGET-stage4-isl)
 
-maybe-clean-stage4-ppl: clean-stage4-ppl
-clean-stage4: clean-stage4-ppl
-clean-stage4-ppl:
+maybe-clean-stage4-isl: clean-stage4-isl
+clean-stage4: clean-stage4-isl
+clean-stage4-isl:
 	@if [ $(current_stage) = stage4 ]; then \
-	  [ -f $(HOST_SUBDIR)/ppl/Makefile ] || exit 0; \
+	  [ -f $(HOST_SUBDIR)/isl/Makefile ] || exit 0; \
 	else \
-	  [ -f $(HOST_SUBDIR)/stage4-ppl/Makefile ] || exit 0; \
+	  [ -f $(HOST_SUBDIR)/stage4-isl/Makefile ] || exit 0; \
 	  $(MAKE) stage4-start; \
 	fi; \
-	cd $(HOST_SUBDIR)/ppl && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
-@endif ppl-bootstrap
+	cd $(HOST_SUBDIR)/isl && \
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 clean
+@endif isl-bootstrap
 
 
-.PHONY: all-stageprofile-ppl maybe-all-stageprofile-ppl
-.PHONY: clean-stageprofile-ppl maybe-clean-stageprofile-ppl
-maybe-all-stageprofile-ppl:
-maybe-clean-stageprofile-ppl:
-@if ppl-bootstrap
-maybe-all-stageprofile-ppl: all-stageprofile-ppl
-all-stageprofile: all-stageprofile-ppl
-TARGET-stageprofile-ppl = $(TARGET-ppl)
-all-stageprofile-ppl: configure-stageprofile-ppl
+.PHONY: all-stageprofile-isl maybe-all-stageprofile-isl
+.PHONY: clean-stageprofile-isl maybe-clean-stageprofile-isl
+maybe-all-stageprofile-isl:
+maybe-clean-stageprofile-isl:
+@if isl-bootstrap
+maybe-all-stageprofile-isl: all-stageprofile-isl
+all-stageprofile: all-stageprofile-isl
+TARGET-stageprofile-isl = $(TARGET-isl)
+all-stageprofile-isl: configure-stageprofile-isl
 	@[ $(current_stage) = stageprofile ] || $(MAKE) stageprofile-start
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGEprofile_TFLAGS)"; \
 	$(HOST_EXPORTS) \
 	$(POSTSTAGE1_HOST_EXPORTS)  \
-	cd $(HOST_SUBDIR)/ppl && \
+	cd $(HOST_SUBDIR)/isl && \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
 		CFLAGS="$(STAGEprofile_CFLAGS)" \
 		CXXFLAGS="$(STAGEprofile_CXXFLAGS)" \
@@ -13407,42 +13449,40 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  \
+		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 \
 		TFLAGS="$(STAGEprofile_TFLAGS)" \
-		$(TARGET-stageprofile-ppl)
+		$(TARGET-stageprofile-isl)
 
-maybe-clean-stageprofile-ppl: clean-stageprofile-ppl
-clean-stageprofile: clean-stageprofile-ppl
-clean-stageprofile-ppl:
+maybe-clean-stageprofile-isl: clean-stageprofile-isl
+clean-stageprofile: clean-stageprofile-isl
+clean-stageprofile-isl:
 	@if [ $(current_stage) = stageprofile ]; then \
-	  [ -f $(HOST_SUBDIR)/ppl/Makefile ] || exit 0; \
+	  [ -f $(HOST_SUBDIR)/isl/Makefile ] || exit 0; \
 	else \
-	  [ -f $(HOST_SUBDIR)/stageprofile-ppl/Makefile ] || exit 0; \
+	  [ -f $(HOST_SUBDIR)/stageprofile-isl/Makefile ] || exit 0; \
 	  $(MAKE) stageprofile-start; \
 	fi; \
-	cd $(HOST_SUBDIR)/ppl && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
-@endif ppl-bootstrap
+	cd $(HOST_SUBDIR)/isl && \
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 clean
+@endif isl-bootstrap
 
 
-.PHONY: all-stagefeedback-ppl maybe-all-stagefeedback-ppl
-.PHONY: clean-stagefeedback-ppl maybe-clean-stagefeedback-ppl
-maybe-all-stagefeedback-ppl:
-maybe-clean-stagefeedback-ppl:
-@if ppl-bootstrap
-maybe-all-stagefeedback-ppl: all-stagefeedback-ppl
-all-stagefeedback: all-stagefeedback-ppl
-TARGET-stagefeedback-ppl = $(TARGET-ppl)
-all-stagefeedback-ppl: configure-stagefeedback-ppl
+.PHONY: all-stagefeedback-isl maybe-all-stagefeedback-isl
+.PHONY: clean-stagefeedback-isl maybe-clean-stagefeedback-isl
+maybe-all-stagefeedback-isl:
+maybe-clean-stagefeedback-isl:
+@if isl-bootstrap
+maybe-all-stagefeedback-isl: all-stagefeedback-isl
+all-stagefeedback: all-stagefeedback-isl
+TARGET-stagefeedback-isl = $(TARGET-isl)
+all-stagefeedback-isl: configure-stagefeedback-isl
 	@[ $(current_stage) = stagefeedback ] || $(MAKE) stagefeedback-start
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGEfeedback_TFLAGS)"; \
 	$(HOST_EXPORTS) \
 	$(POSTSTAGE1_HOST_EXPORTS)  \
-	cd $(HOST_SUBDIR)/ppl && \
+	cd $(HOST_SUBDIR)/isl && \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
 		CFLAGS="$(STAGEfeedback_CFLAGS)" \
 		CXXFLAGS="$(STAGEfeedback_CXXFLAGS)" \
@@ -13450,80 +13490,78 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  \
+		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 \
 		TFLAGS="$(STAGEfeedback_TFLAGS)" \
-		$(TARGET-stagefeedback-ppl)
+		$(TARGET-stagefeedback-isl)
 
-maybe-clean-stagefeedback-ppl: clean-stagefeedback-ppl
-clean-stagefeedback: clean-stagefeedback-ppl
-clean-stagefeedback-ppl:
+maybe-clean-stagefeedback-isl: clean-stagefeedback-isl
+clean-stagefeedback: clean-stagefeedback-isl
+clean-stagefeedback-isl:
 	@if [ $(current_stage) = stagefeedback ]; then \
-	  [ -f $(HOST_SUBDIR)/ppl/Makefile ] || exit 0; \
+	  [ -f $(HOST_SUBDIR)/isl/Makefile ] || exit 0; \
 	else \
-	  [ -f $(HOST_SUBDIR)/stagefeedback-ppl/Makefile ] || exit 0; \
+	  [ -f $(HOST_SUBDIR)/stagefeedback-isl/Makefile ] || exit 0; \
 	  $(MAKE) stagefeedback-start; \
 	fi; \
-	cd $(HOST_SUBDIR)/ppl && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
-@endif ppl-bootstrap
+	cd $(HOST_SUBDIR)/isl && \
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) V=1 clean
+@endif isl-bootstrap
 
 
 
 
 
-.PHONY: check-ppl maybe-check-ppl
-maybe-check-ppl:
-@if ppl
-maybe-check-ppl: check-ppl
+.PHONY: check-isl maybe-check-isl
+maybe-check-isl:
+@if isl
+maybe-check-isl: check-isl
 
-check-ppl:
+check-isl:
 	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	(cd $(HOST_SUBDIR)/ppl && \
-	  $(MAKE) $(FLAGS_TO_PASS)  check)
+	(cd $(HOST_SUBDIR)/isl && \
+	  $(MAKE) $(FLAGS_TO_PASS) V=1 check)
 
-@endif ppl
+@endif isl
 
-.PHONY: install-ppl maybe-install-ppl
-maybe-install-ppl:
-@if ppl
-maybe-install-ppl: install-ppl
+.PHONY: install-isl maybe-install-isl
+maybe-install-isl:
+@if isl
+maybe-install-isl: install-isl
 
-install-ppl:
+install-isl:
 
-@endif ppl
+@endif isl
 
-.PHONY: install-strip-ppl maybe-install-strip-ppl
-maybe-install-strip-ppl:
-@if ppl
-maybe-install-strip-ppl: install-strip-ppl
+.PHONY: install-strip-isl maybe-install-strip-isl
+maybe-install-strip-isl:
+@if isl
+maybe-install-strip-isl: install-strip-isl
 
-install-strip-ppl:
+install-strip-isl:
 
-@endif ppl
+@endif isl
 
 # Other targets (info, dvi, pdf, etc.)
 
-.PHONY: maybe-info-ppl info-ppl
-maybe-info-ppl:
-@if ppl
-maybe-info-ppl: info-ppl
+.PHONY: maybe-info-isl info-isl
+maybe-info-isl:
+@if isl
+maybe-info-isl: info-isl
 
-info-ppl: \
-    configure-ppl 
-	@[ -f ./ppl/Makefile ] || exit 0; \
+info-isl: \
+    configure-isl 
+	@[ -f ./isl/Makefile ] || exit 0; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	for flag in $(EXTRA_HOST_FLAGS) V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
-	echo "Doing info in ppl" ; \
-	(cd $(HOST_SUBDIR)/ppl && \
+	echo "Doing info in isl" ; \
+	(cd $(HOST_SUBDIR)/isl && \
 	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
 	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
 	          "RANLIB=$${RANLIB}" \
@@ -13531,24 +13569,24 @@
 	          info) \
 	  || exit 1
 
-@endif ppl
+@endif isl
 
-.PHONY: maybe-dvi-ppl dvi-ppl
-maybe-dvi-ppl:
-@if ppl
-maybe-dvi-ppl: dvi-ppl
+.PHONY: maybe-dvi-isl dvi-isl
+maybe-dvi-isl:
+@if isl
+maybe-dvi-isl: dvi-isl
 
-dvi-ppl: \
-    configure-ppl 
-	@[ -f ./ppl/Makefile ] || exit 0; \
+dvi-isl: \
+    configure-isl 
+	@[ -f ./isl/Makefile ] || exit 0; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	for flag in $(EXTRA_HOST_FLAGS) V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
-	echo "Doing dvi in ppl" ; \
-	(cd $(HOST_SUBDIR)/ppl && \
+	echo "Doing dvi in isl" ; \
+	(cd $(HOST_SUBDIR)/isl && \
 	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
 	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
 	          "RANLIB=$${RANLIB}" \
@@ -13556,24 +13594,24 @@
 	          dvi) \
 	  || exit 1
 
-@endif ppl
+@endif isl
 
-.PHONY: maybe-pdf-ppl pdf-ppl
-maybe-pdf-ppl:
-@if ppl
-maybe-pdf-ppl: pdf-ppl
+.PHONY: maybe-pdf-isl pdf-isl
+maybe-pdf-isl:
+@if isl
+maybe-pdf-isl: pdf-isl
 
-pdf-ppl: \
-    configure-ppl 
-	@[ -f ./ppl/Makefile ] || exit 0; \
+pdf-isl: \
+    configure-isl 
+	@[ -f ./isl/Makefile ] || exit 0; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	for flag in $(EXTRA_HOST_FLAGS) V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
-	echo "Doing pdf in ppl" ; \
-	(cd $(HOST_SUBDIR)/ppl && \
+	echo "Doing pdf in isl" ; \
+	(cd $(HOST_SUBDIR)/isl && \
 	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
 	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
 	          "RANLIB=$${RANLIB}" \
@@ -13581,24 +13619,24 @@
 	          pdf) \
 	  || exit 1
 
-@endif ppl
+@endif isl
 
-.PHONY: maybe-html-ppl html-ppl
-maybe-html-ppl:
-@if ppl
-maybe-html-ppl: html-ppl
+.PHONY: maybe-html-isl html-isl
+maybe-html-isl:
+@if isl
+maybe-html-isl: html-isl
 
-html-ppl: \
-    configure-ppl 
-	@[ -f ./ppl/Makefile ] || exit 0; \
+html-isl: \
+    configure-isl 
+	@[ -f ./isl/Makefile ] || exit 0; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	for flag in $(EXTRA_HOST_FLAGS) V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
-	echo "Doing html in ppl" ; \
-	(cd $(HOST_SUBDIR)/ppl && \
+	echo "Doing html in isl" ; \
+	(cd $(HOST_SUBDIR)/isl && \
 	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
 	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
 	          "RANLIB=$${RANLIB}" \
@@ -13606,24 +13644,24 @@
 	          html) \
 	  || exit 1
 
-@endif ppl
+@endif isl
 
-.PHONY: maybe-TAGS-ppl TAGS-ppl
-maybe-TAGS-ppl:
-@if ppl
-maybe-TAGS-ppl: TAGS-ppl
+.PHONY: maybe-TAGS-isl TAGS-isl
+maybe-TAGS-isl:
+@if isl
+maybe-TAGS-isl: TAGS-isl
 
-TAGS-ppl: \
-    configure-ppl 
-	@[ -f ./ppl/Makefile ] || exit 0; \
+TAGS-isl: \
+    configure-isl 
+	@[ -f ./isl/Makefile ] || exit 0; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	for flag in $(EXTRA_HOST_FLAGS) V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
-	echo "Doing TAGS in ppl" ; \
-	(cd $(HOST_SUBDIR)/ppl && \
+	echo "Doing TAGS in isl" ; \
+	(cd $(HOST_SUBDIR)/isl && \
 	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
 	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
 	          "RANLIB=$${RANLIB}" \
@@ -13631,25 +13669,25 @@
 	          TAGS) \
 	  || exit 1
 
-@endif ppl
+@endif isl
 
-.PHONY: maybe-install-info-ppl install-info-ppl
-maybe-install-info-ppl:
-@if ppl
-maybe-install-info-ppl: install-info-ppl
+.PHONY: maybe-install-info-isl install-info-isl
+maybe-install-info-isl:
+@if isl
+maybe-install-info-isl: install-info-isl
 
-install-info-ppl: \
-    configure-ppl \
-    info-ppl 
-	@[ -f ./ppl/Makefile ] || exit 0; \
+install-info-isl: \
+    configure-isl \
+    info-isl 
+	@[ -f ./isl/Makefile ] || exit 0; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	for flag in $(EXTRA_HOST_FLAGS) V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
-	echo "Doing install-info in ppl" ; \
-	(cd $(HOST_SUBDIR)/ppl && \
+	echo "Doing install-info in isl" ; \
+	(cd $(HOST_SUBDIR)/isl && \
 	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
 	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
 	          "RANLIB=$${RANLIB}" \
@@ -13657,25 +13695,25 @@
 	          install-info) \
 	  || exit 1
 
-@endif ppl
+@endif isl
 
-.PHONY: maybe-install-pdf-ppl install-pdf-ppl
-maybe-install-pdf-ppl:
-@if ppl
-maybe-install-pdf-ppl: install-pdf-ppl
+.PHONY: maybe-install-pdf-isl install-pdf-isl
+maybe-install-pdf-isl:
+@if isl
+maybe-install-pdf-isl: install-pdf-isl
 
-install-pdf-ppl: \
-    configure-ppl \
-    pdf-ppl 
-	@[ -f ./ppl/Makefile ] || exit 0; \
+install-pdf-isl: \
+    configure-isl \
+    pdf-isl 
+	@[ -f ./isl/Makefile ] || exit 0; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	for flag in $(EXTRA_HOST_FLAGS) V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
-	echo "Doing install-pdf in ppl" ; \
-	(cd $(HOST_SUBDIR)/ppl && \
+	echo "Doing install-pdf in isl" ; \
+	(cd $(HOST_SUBDIR)/isl && \
 	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
 	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
 	          "RANLIB=$${RANLIB}" \
@@ -13683,25 +13721,25 @@
 	          install-pdf) \
 	  || exit 1
 
-@endif ppl
+@endif isl
 
-.PHONY: maybe-install-html-ppl install-html-ppl
-maybe-install-html-ppl:
-@if ppl
-maybe-install-html-ppl: install-html-ppl
+.PHONY: maybe-install-html-isl install-html-isl
+maybe-install-html-isl:
+@if isl
+maybe-install-html-isl: install-html-isl
 
-install-html-ppl: \
-    configure-ppl \
-    html-ppl 
-	@[ -f ./ppl/Makefile ] || exit 0; \
+install-html-isl: \
+    configure-isl \
+    html-isl 
+	@[ -f ./isl/Makefile ] || exit 0; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	for flag in $(EXTRA_HOST_FLAGS) V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
-	echo "Doing install-html in ppl" ; \
-	(cd $(HOST_SUBDIR)/ppl && \
+	echo "Doing install-html in isl" ; \
+	(cd $(HOST_SUBDIR)/isl && \
 	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
 	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
 	          "RANLIB=$${RANLIB}" \
@@ -13709,24 +13747,24 @@
 	          install-html) \
 	  || exit 1
 
-@endif ppl
+@endif isl
 
-.PHONY: maybe-installcheck-ppl installcheck-ppl
-maybe-installcheck-ppl:
-@if ppl
-maybe-installcheck-ppl: installcheck-ppl
+.PHONY: maybe-installcheck-isl installcheck-isl
+maybe-installcheck-isl:
+@if isl
+maybe-installcheck-isl: installcheck-isl
 
-installcheck-ppl: \
-    configure-ppl 
-	@[ -f ./ppl/Makefile ] || exit 0; \
+installcheck-isl: \
+    configure-isl 
+	@[ -f ./isl/Makefile ] || exit 0; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	for flag in $(EXTRA_HOST_FLAGS) V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
-	echo "Doing installcheck in ppl" ; \
-	(cd $(HOST_SUBDIR)/ppl && \
+	echo "Doing installcheck in isl" ; \
+	(cd $(HOST_SUBDIR)/isl && \
 	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
 	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
 	          "RANLIB=$${RANLIB}" \
@@ -13734,23 +13772,23 @@
 	          installcheck) \
 	  || exit 1
 
-@endif ppl
+@endif isl
 
-.PHONY: maybe-mostlyclean-ppl mostlyclean-ppl
-maybe-mostlyclean-ppl:
-@if ppl
-maybe-mostlyclean-ppl: mostlyclean-ppl
+.PHONY: maybe-mostlyclean-isl mostlyclean-isl
+maybe-mostlyclean-isl:
+@if isl
+maybe-mostlyclean-isl: mostlyclean-isl
 
-mostlyclean-ppl: 
-	@[ -f ./ppl/Makefile ] || exit 0; \
+mostlyclean-isl: 
+	@[ -f ./isl/Makefile ] || exit 0; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	for flag in $(EXTRA_HOST_FLAGS) V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
-	echo "Doing mostlyclean in ppl" ; \
-	(cd $(HOST_SUBDIR)/ppl && \
+	echo "Doing mostlyclean in isl" ; \
+	(cd $(HOST_SUBDIR)/isl && \
 	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
 	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
 	          "RANLIB=$${RANLIB}" \
@@ -13758,23 +13796,23 @@
 	          mostlyclean) \
 	  || exit 1
 
-@endif ppl
+@endif isl
 
-.PHONY: maybe-clean-ppl clean-ppl
-maybe-clean-ppl:
-@if ppl
-maybe-clean-ppl: clean-ppl
+.PHONY: maybe-clean-isl clean-isl
+maybe-clean-isl:
+@if isl
+maybe-clean-isl: clean-isl
 
-clean-ppl: 
-	@[ -f ./ppl/Makefile ] || exit 0; \
+clean-isl: 
+	@[ -f ./isl/Makefile ] || exit 0; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	for flag in $(EXTRA_HOST_FLAGS) V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
-	echo "Doing clean in ppl" ; \
-	(cd $(HOST_SUBDIR)/ppl && \
+	echo "Doing clean in isl" ; \
+	(cd $(HOST_SUBDIR)/isl && \
 	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
 	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
 	          "RANLIB=$${RANLIB}" \
@@ -13782,23 +13820,23 @@
 	          clean) \
 	  || exit 1
 
-@endif ppl
+@endif isl
 
-.PHONY: maybe-distclean-ppl distclean-ppl
-maybe-distclean-ppl:
-@if ppl
-maybe-distclean-ppl: distclean-ppl
+.PHONY: maybe-distclean-isl distclean-isl
+maybe-distclean-isl:
+@if isl
+maybe-distclean-isl: distclean-isl
 
-distclean-ppl: 
-	@[ -f ./ppl/Makefile ] || exit 0; \
+distclean-isl: 
+	@[ -f ./isl/Makefile ] || exit 0; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	for flag in $(EXTRA_HOST_FLAGS) V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
-	echo "Doing distclean in ppl" ; \
-	(cd $(HOST_SUBDIR)/ppl && \
+	echo "Doing distclean in isl" ; \
+	(cd $(HOST_SUBDIR)/isl && \
 	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
 	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
 	          "RANLIB=$${RANLIB}" \
@@ -13806,23 +13844,23 @@
 	          distclean) \
 	  || exit 1
 
-@endif ppl
+@endif isl
 
-.PHONY: maybe-maintainer-clean-ppl maintainer-clean-ppl
-maybe-maintainer-clean-ppl:
-@if ppl
-maybe-maintainer-clean-ppl: maintainer-clean-ppl
+.PHONY: maybe-maintainer-clean-isl maintainer-clean-isl
+maybe-maintainer-clean-isl:
+@if isl
+maybe-maintainer-clean-isl: maintainer-clean-isl
 
-maintainer-clean-ppl: 
-	@[ -f ./ppl/Makefile ] || exit 0; \
+maintainer-clean-isl: 
+	@[ -f ./isl/Makefile ] || exit 0; \
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	for flag in $(EXTRA_HOST_FLAGS) V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
-	echo "Doing maintainer-clean in ppl" ; \
-	(cd $(HOST_SUBDIR)/ppl && \
+	echo "Doing maintainer-clean in isl" ; \
+	(cd $(HOST_SUBDIR)/isl && \
 	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
 	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
 	          "RANLIB=$${RANLIB}" \
@@ -13830,7 +13868,7 @@
 	          maintainer-clean) \
 	  || exit 1
 
-@endif ppl
+@endif isl
 
 
 
@@ -13846,7 +13884,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	test ! -f $(HOST_SUBDIR)/cloog/Makefile || exit 0; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/cloog ; \
-	$(HOST_EXPORTS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}"; export CPPFLAGS; LDFLAGS="$$LDFLAGS ${HOST_PPLLIBS}"; export LDFLAGS;  \
+	$(HOST_EXPORTS) CPPFLAGS="$(HOST_GMPINC) $(HOST_ISLINC) $$CPPFLAGS"; export CPPFLAGS; LDFLAGS="-L$$r/$(HOST_SUBDIR)/gmp/.libs -L$$r/$(HOST_SUBDIR)/isl/.libs $$LDFLAGS"; export LDFLAGS;  \
 	echo Configuring in $(HOST_SUBDIR)/cloog; \
 	cd "$(HOST_SUBDIR)/cloog" || exit 1; \
 	case $(srcdir) in \
@@ -13858,7 +13896,7 @@
 	libsrcdir="$$s/cloog"; \
 	$(SHELL) $${libsrcdir}/configure \
 	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
-	  --target=${target_alias} $${srcdiroption} --disable-shared --with-gmp-library=$$r/$(HOST_SUBDIR)/gmp/.libs --with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-bits=gmp --with-ppl \
+	  --target=${target_alias} $${srcdiroption} --disable-shared --with-gmp=system --with-bits=gmp --with-isl=system \
 	  || exit 1
 @endif cloog
 
@@ -13878,7 +13916,7 @@
 	$(HOST_EXPORTS) \
 	CFLAGS="$(STAGE1_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGE1_CXXFLAGS)"; export CXXFLAGS; \
-	LIBCFLAGS="$(LIBCFLAGS)"; export LIBCFLAGS; CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}"; export CPPFLAGS; LDFLAGS="$$LDFLAGS ${HOST_PPLLIBS}"; export LDFLAGS;  \
+	LIBCFLAGS="$(LIBCFLAGS)"; export LIBCFLAGS; CPPFLAGS="$(HOST_GMPINC) $(HOST_ISLINC) $$CPPFLAGS"; export CPPFLAGS; LDFLAGS="-L$$r/$(HOST_SUBDIR)/gmp/.libs -L$$r/$(HOST_SUBDIR)/isl/.libs $$LDFLAGS"; export LDFLAGS;  \
 	echo Configuring stage 1 in $(HOST_SUBDIR)/cloog ; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/cloog ; \
 	cd $(HOST_SUBDIR)/cloog || exit 1; \
@@ -13893,7 +13931,7 @@
 	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
 	  --target=${target_alias} $${srcdiroption} \
 	  $(STAGE1_CONFIGURE_FLAGS) \
-	  --disable-shared --with-gmp-library=$$r/$(HOST_SUBDIR)/gmp/.libs --with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-bits=gmp --with-ppl
+	  --disable-shared --with-gmp=system --with-bits=gmp --with-isl=system
 @endif cloog-bootstrap
 
 .PHONY: configure-stage2-cloog maybe-configure-stage2-cloog
@@ -13911,7 +13949,7 @@
 	$(POSTSTAGE1_HOST_EXPORTS) \
 	CFLAGS="$(STAGE2_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGE2_CXXFLAGS)"; export CXXFLAGS; \
-	LIBCFLAGS="$(STAGE2_CFLAGS)"; export LIBCFLAGS; CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}"; export CPPFLAGS; LDFLAGS="$$LDFLAGS ${HOST_PPLLIBS}"; export LDFLAGS;  \
+	LIBCFLAGS="$(STAGE2_CFLAGS)"; export LIBCFLAGS; CPPFLAGS="$(HOST_GMPINC) $(HOST_ISLINC) $$CPPFLAGS"; export CPPFLAGS; LDFLAGS="-L$$r/$(HOST_SUBDIR)/gmp/.libs -L$$r/$(HOST_SUBDIR)/isl/.libs $$LDFLAGS"; export LDFLAGS;  \
 	echo Configuring stage 2 in $(HOST_SUBDIR)/cloog ; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/cloog ; \
 	cd $(HOST_SUBDIR)/cloog || exit 1; \
@@ -13927,7 +13965,7 @@
 	  --target=${target_alias} $${srcdiroption} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE2_CONFIGURE_FLAGS) \
-	  --disable-shared --with-gmp-library=$$r/$(HOST_SUBDIR)/gmp/.libs --with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-bits=gmp --with-ppl
+	  --disable-shared --with-gmp=system --with-bits=gmp --with-isl=system
 @endif cloog-bootstrap
 
 .PHONY: configure-stage3-cloog maybe-configure-stage3-cloog
@@ -13945,7 +13983,7 @@
 	$(POSTSTAGE1_HOST_EXPORTS) \
 	CFLAGS="$(STAGE3_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGE3_CXXFLAGS)"; export CXXFLAGS; \
-	LIBCFLAGS="$(STAGE3_CFLAGS)"; export LIBCFLAGS; CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}"; export CPPFLAGS; LDFLAGS="$$LDFLAGS ${HOST_PPLLIBS}"; export LDFLAGS;  \
+	LIBCFLAGS="$(STAGE3_CFLAGS)"; export LIBCFLAGS; CPPFLAGS="$(HOST_GMPINC) $(HOST_ISLINC) $$CPPFLAGS"; export CPPFLAGS; LDFLAGS="-L$$r/$(HOST_SUBDIR)/gmp/.libs -L$$r/$(HOST_SUBDIR)/isl/.libs $$LDFLAGS"; export LDFLAGS;  \
 	echo Configuring stage 3 in $(HOST_SUBDIR)/cloog ; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/cloog ; \
 	cd $(HOST_SUBDIR)/cloog || exit 1; \
@@ -13961,7 +13999,7 @@
 	  --target=${target_alias} $${srcdiroption} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE3_CONFIGURE_FLAGS) \
-	  --disable-shared --with-gmp-library=$$r/$(HOST_SUBDIR)/gmp/.libs --with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-bits=gmp --with-ppl
+	  --disable-shared --with-gmp=system --with-bits=gmp --with-isl=system
 @endif cloog-bootstrap
 
 .PHONY: configure-stage4-cloog maybe-configure-stage4-cloog
@@ -13979,7 +14017,7 @@
 	$(POSTSTAGE1_HOST_EXPORTS) \
 	CFLAGS="$(STAGE4_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGE4_CXXFLAGS)"; export CXXFLAGS; \
-	LIBCFLAGS="$(STAGE4_CFLAGS)"; export LIBCFLAGS; CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}"; export CPPFLAGS; LDFLAGS="$$LDFLAGS ${HOST_PPLLIBS}"; export LDFLAGS;  \
+	LIBCFLAGS="$(STAGE4_CFLAGS)"; export LIBCFLAGS; CPPFLAGS="$(HOST_GMPINC) $(HOST_ISLINC) $$CPPFLAGS"; export CPPFLAGS; LDFLAGS="-L$$r/$(HOST_SUBDIR)/gmp/.libs -L$$r/$(HOST_SUBDIR)/isl/.libs $$LDFLAGS"; export LDFLAGS;  \
 	echo Configuring stage 4 in $(HOST_SUBDIR)/cloog ; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/cloog ; \
 	cd $(HOST_SUBDIR)/cloog || exit 1; \
@@ -13995,7 +14033,7 @@
 	  --target=${target_alias} $${srcdiroption} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGE4_CONFIGURE_FLAGS) \
-	  --disable-shared --with-gmp-library=$$r/$(HOST_SUBDIR)/gmp/.libs --with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-bits=gmp --with-ppl
+	  --disable-shared --with-gmp=system --with-bits=gmp --with-isl=system
 @endif cloog-bootstrap
 
 .PHONY: configure-stageprofile-cloog maybe-configure-stageprofile-cloog
@@ -14013,7 +14051,7 @@
 	$(POSTSTAGE1_HOST_EXPORTS) \
 	CFLAGS="$(STAGEprofile_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGEprofile_CXXFLAGS)"; export CXXFLAGS; \
-	LIBCFLAGS="$(STAGEprofile_CFLAGS)"; export LIBCFLAGS; CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}"; export CPPFLAGS; LDFLAGS="$$LDFLAGS ${HOST_PPLLIBS}"; export LDFLAGS;  \
+	LIBCFLAGS="$(STAGEprofile_CFLAGS)"; export LIBCFLAGS; CPPFLAGS="$(HOST_GMPINC) $(HOST_ISLINC) $$CPPFLAGS"; export CPPFLAGS; LDFLAGS="-L$$r/$(HOST_SUBDIR)/gmp/.libs -L$$r/$(HOST_SUBDIR)/isl/.libs $$LDFLAGS"; export LDFLAGS;  \
 	echo Configuring stage profile in $(HOST_SUBDIR)/cloog ; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/cloog ; \
 	cd $(HOST_SUBDIR)/cloog || exit 1; \
@@ -14029,7 +14067,7 @@
 	  --target=${target_alias} $${srcdiroption} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEprofile_CONFIGURE_FLAGS) \
-	  --disable-shared --with-gmp-library=$$r/$(HOST_SUBDIR)/gmp/.libs --with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-bits=gmp --with-ppl
+	  --disable-shared --with-gmp=system --with-bits=gmp --with-isl=system
 @endif cloog-bootstrap
 
 .PHONY: configure-stagefeedback-cloog maybe-configure-stagefeedback-cloog
@@ -14047,7 +14085,7 @@
 	$(POSTSTAGE1_HOST_EXPORTS) \
 	CFLAGS="$(STAGEfeedback_CFLAGS)"; export CFLAGS; \
 	CXXFLAGS="$(STAGEfeedback_CXXFLAGS)"; export CXXFLAGS; \
-	LIBCFLAGS="$(STAGEfeedback_CFLAGS)"; export LIBCFLAGS; CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}"; export CPPFLAGS; LDFLAGS="$$LDFLAGS ${HOST_PPLLIBS}"; export LDFLAGS;  \
+	LIBCFLAGS="$(STAGEfeedback_CFLAGS)"; export LIBCFLAGS; CPPFLAGS="$(HOST_GMPINC) $(HOST_ISLINC) $$CPPFLAGS"; export CPPFLAGS; LDFLAGS="-L$$r/$(HOST_SUBDIR)/gmp/.libs -L$$r/$(HOST_SUBDIR)/isl/.libs $$LDFLAGS"; export LDFLAGS;  \
 	echo Configuring stage feedback in $(HOST_SUBDIR)/cloog ; \
 	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/cloog ; \
 	cd $(HOST_SUBDIR)/cloog || exit 1; \
@@ -14063,7 +14101,7 @@
 	  --target=${target_alias} $${srcdiroption} \
 	  --with-build-libsubdir=$(HOST_SUBDIR) \
 	  $(STAGEfeedback_CONFIGURE_FLAGS) \
-	  --disable-shared --with-gmp-library=$$r/$(HOST_SUBDIR)/gmp/.libs --with-gmp-include=$$r/$(HOST_SUBDIR)/gmp --with-bits=gmp --with-ppl
+	  --disable-shared --with-gmp=system --with-bits=gmp --with-isl=system
 @endif cloog-bootstrap
 
 
@@ -14081,9 +14119,9 @@
 all-cloog: configure-cloog
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(HOST_EXPORTS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}"; export CPPFLAGS; LDFLAGS="$$LDFLAGS ${HOST_PPLLIBS}"; export LDFLAGS;  \
+	$(HOST_EXPORTS) CPPFLAGS="$(HOST_GMPINC) $(HOST_ISLINC) $$CPPFLAGS"; export CPPFLAGS; LDFLAGS="-L$$r/$(HOST_SUBDIR)/gmp/.libs -L$$r/$(HOST_SUBDIR)/isl/.libs $$LDFLAGS"; export LDFLAGS;  \
 	(cd $(HOST_SUBDIR)/cloog && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS" \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1 \
 		$(TARGET-cloog))
 @endif cloog
 
@@ -14102,7 +14140,7 @@
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGE1_TFLAGS)"; \
-	$(HOST_EXPORTS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}"; export CPPFLAGS; LDFLAGS="$$LDFLAGS ${HOST_PPLLIBS}"; export LDFLAGS;  \
+	$(HOST_EXPORTS) CPPFLAGS="$(HOST_GMPINC) $(HOST_ISLINC) $$CPPFLAGS"; export CPPFLAGS; LDFLAGS="-L$$r/$(HOST_SUBDIR)/gmp/.libs -L$$r/$(HOST_SUBDIR)/isl/.libs $$LDFLAGS"; export LDFLAGS;  \
 	cd $(HOST_SUBDIR)/cloog && \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
 		CFLAGS="$(STAGE1_CFLAGS)" \
@@ -14111,7 +14149,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS)  CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS" \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1 \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-cloog)
 
@@ -14126,7 +14165,7 @@
 	fi; \
 	cd $(HOST_SUBDIR)/cloog && \
 	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS" clean
+	$(STAGE1_FLAGS_TO_PASS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1 clean
 @endif cloog-bootstrap
 
 
@@ -14144,7 +14183,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGE2_TFLAGS)"; \
 	$(HOST_EXPORTS) \
-	$(POSTSTAGE1_HOST_EXPORTS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}"; export CPPFLAGS; LDFLAGS="$$LDFLAGS ${HOST_PPLLIBS}"; export LDFLAGS;  \
+	$(POSTSTAGE1_HOST_EXPORTS) CPPFLAGS="$(HOST_GMPINC) $(HOST_ISLINC) $$CPPFLAGS"; export CPPFLAGS; LDFLAGS="-L$$r/$(HOST_SUBDIR)/gmp/.libs -L$$r/$(HOST_SUBDIR)/isl/.libs $$LDFLAGS"; export LDFLAGS;  \
 	cd $(HOST_SUBDIR)/cloog && \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
 		CFLAGS="$(STAGE2_CFLAGS)" \
@@ -14153,7 +14192,7 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS" \
+		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1 \
 		TFLAGS="$(STAGE2_TFLAGS)" \
 		$(TARGET-stage2-cloog)
 
@@ -14167,9 +14206,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/cloog && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS" clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1 clean
 @endif cloog-bootstrap
 
 
@@ -14187,7 +14224,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGE3_TFLAGS)"; \
 	$(HOST_EXPORTS) \
-	$(POSTSTAGE1_HOST_EXPORTS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}"; export CPPFLAGS; LDFLAGS="$$LDFLAGS ${HOST_PPLLIBS}"; export LDFLAGS;  \
+	$(POSTSTAGE1_HOST_EXPORTS) CPPFLAGS="$(HOST_GMPINC) $(HOST_ISLINC) $$CPPFLAGS"; export CPPFLAGS; LDFLAGS="-L$$r/$(HOST_SUBDIR)/gmp/.libs -L$$r/$(HOST_SUBDIR)/isl/.libs $$LDFLAGS"; export LDFLAGS;  \
 	cd $(HOST_SUBDIR)/cloog && \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
 		CFLAGS="$(STAGE3_CFLAGS)" \
@@ -14196,7 +14233,7 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS" \
+		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1 \
 		TFLAGS="$(STAGE3_TFLAGS)" \
 		$(TARGET-stage3-cloog)
 
@@ -14210,9 +14247,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/cloog && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS" clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1 clean
 @endif cloog-bootstrap
 
 
@@ -14230,7 +14265,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGE4_TFLAGS)"; \
 	$(HOST_EXPORTS) \
-	$(POSTSTAGE1_HOST_EXPORTS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}"; export CPPFLAGS; LDFLAGS="$$LDFLAGS ${HOST_PPLLIBS}"; export LDFLAGS;  \
+	$(POSTSTAGE1_HOST_EXPORTS) CPPFLAGS="$(HOST_GMPINC) $(HOST_ISLINC) $$CPPFLAGS"; export CPPFLAGS; LDFLAGS="-L$$r/$(HOST_SUBDIR)/gmp/.libs -L$$r/$(HOST_SUBDIR)/isl/.libs $$LDFLAGS"; export LDFLAGS;  \
 	cd $(HOST_SUBDIR)/cloog && \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
 		CFLAGS="$(STAGE4_CFLAGS)" \
@@ -14239,7 +14274,7 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS" \
+		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1 \
 		TFLAGS="$(STAGE4_TFLAGS)" \
 		$(TARGET-stage4-cloog)
 
@@ -14253,9 +14288,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/cloog && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS" clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1 clean
 @endif cloog-bootstrap
 
 
@@ -14273,7 +14306,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGEprofile_TFLAGS)"; \
 	$(HOST_EXPORTS) \
-	$(POSTSTAGE1_HOST_EXPORTS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}"; export CPPFLAGS; LDFLAGS="$$LDFLAGS ${HOST_PPLLIBS}"; export LDFLAGS;  \
+	$(POSTSTAGE1_HOST_EXPORTS) CPPFLAGS="$(HOST_GMPINC) $(HOST_ISLINC) $$CPPFLAGS"; export CPPFLAGS; LDFLAGS="-L$$r/$(HOST_SUBDIR)/gmp/.libs -L$$r/$(HOST_SUBDIR)/isl/.libs $$LDFLAGS"; export LDFLAGS;  \
 	cd $(HOST_SUBDIR)/cloog && \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
 		CFLAGS="$(STAGEprofile_CFLAGS)" \
@@ -14282,7 +14315,7 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS" \
+		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1 \
 		TFLAGS="$(STAGEprofile_TFLAGS)" \
 		$(TARGET-stageprofile-cloog)
 
@@ -14296,9 +14329,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/cloog && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS" clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1 clean
 @endif cloog-bootstrap
 
 
@@ -14316,7 +14347,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	TFLAGS="$(STAGEfeedback_TFLAGS)"; \
 	$(HOST_EXPORTS) \
-	$(POSTSTAGE1_HOST_EXPORTS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}"; export CPPFLAGS; LDFLAGS="$$LDFLAGS ${HOST_PPLLIBS}"; export LDFLAGS;  \
+	$(POSTSTAGE1_HOST_EXPORTS) CPPFLAGS="$(HOST_GMPINC) $(HOST_ISLINC) $$CPPFLAGS"; export CPPFLAGS; LDFLAGS="-L$$r/$(HOST_SUBDIR)/gmp/.libs -L$$r/$(HOST_SUBDIR)/isl/.libs $$LDFLAGS"; export LDFLAGS;  \
 	cd $(HOST_SUBDIR)/cloog && \
 	$(MAKE) $(BASE_FLAGS_TO_PASS) \
 		CFLAGS="$(STAGEfeedback_CFLAGS)" \
@@ -14325,7 +14356,7 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS" \
+		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1 \
 		TFLAGS="$(STAGEfeedback_TFLAGS)" \
 		$(TARGET-stagefeedback-cloog)
 
@@ -14339,9 +14370,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/cloog && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS" clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1 clean
 @endif cloog-bootstrap
 
 
@@ -14359,7 +14388,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
 	(cd $(HOST_SUBDIR)/cloog && \
-	  $(MAKE) $(FLAGS_TO_PASS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS" check)
+	  $(MAKE) $(FLAGS_TO_PASS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1 check)
 
 @endif cloog
 
@@ -14394,7 +14423,7 @@
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS"; do \
+	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
 	echo "Doing info in cloog" ; \
@@ -14419,7 +14448,7 @@
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS"; do \
+	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
 	echo "Doing dvi in cloog" ; \
@@ -14444,7 +14473,7 @@
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS"; do \
+	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
 	echo "Doing pdf in cloog" ; \
@@ -14469,7 +14498,7 @@
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS"; do \
+	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
 	echo "Doing html in cloog" ; \
@@ -14494,7 +14523,7 @@
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS"; do \
+	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
 	echo "Doing TAGS in cloog" ; \
@@ -14520,7 +14549,7 @@
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS"; do \
+	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
 	echo "Doing install-info in cloog" ; \
@@ -14546,7 +14575,7 @@
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS"; do \
+	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
 	echo "Doing install-pdf in cloog" ; \
@@ -14572,7 +14601,7 @@
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS"; do \
+	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
 	echo "Doing install-html in cloog" ; \
@@ -14597,7 +14626,7 @@
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS"; do \
+	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
 	echo "Doing installcheck in cloog" ; \
@@ -14621,7 +14650,7 @@
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS"; do \
+	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
 	echo "Doing mostlyclean in cloog" ; \
@@ -14645,7 +14674,7 @@
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS"; do \
+	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
 	echo "Doing clean in cloog" ; \
@@ -14669,7 +14698,7 @@
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS"; do \
+	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
 	echo "Doing distclean in cloog" ; \
@@ -14693,7 +14722,7 @@
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="${CPPFLAGS} ${HOST_PPLINC}" LDFLAGS="$$LDFLAGS"; do \
+	for flag in $(EXTRA_HOST_FLAGS) CPPFLAGS="$$CPPFLAGS" LDFLAGS="$$LDFLAGS" V=1; do \
 	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	done; \
 	echo "Doing maintainer-clean in cloog" ; \
@@ -14958,7 +14987,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/libelf && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-libelf))
 @endif libelf
 
@@ -14986,7 +15015,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS)   \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS)  \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-libelf)
 
@@ -15001,7 +15031,7 @@
 	fi; \
 	cd $(HOST_SUBDIR)/libelf && \
 	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		 clean
+	$(STAGE1_FLAGS_TO_PASS)  clean
 @endif libelf-bootstrap
 
 
@@ -15042,9 +15072,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libelf && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libelf-bootstrap
 
 
@@ -15085,9 +15113,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libelf && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libelf-bootstrap
 
 
@@ -15128,9 +15154,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libelf && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libelf-bootstrap
 
 
@@ -15171,9 +15195,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libelf && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libelf-bootstrap
 
 
@@ -15214,9 +15236,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libelf && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libelf-bootstrap
 
 
@@ -15827,7 +15847,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/gold && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-gold))
 @endif gold
 
@@ -15855,7 +15875,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS)   \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS)  \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-gold)
 
@@ -15870,7 +15891,7 @@
 	fi; \
 	cd $(HOST_SUBDIR)/gold && \
 	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		 clean
+	$(STAGE1_FLAGS_TO_PASS)  clean
 @endif gold-bootstrap
 
 
@@ -15911,9 +15932,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gold && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif gold-bootstrap
 
 
@@ -15954,9 +15973,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gold && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif gold-bootstrap
 
 
@@ -15997,9 +16014,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gold && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif gold-bootstrap
 
 
@@ -16040,9 +16055,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gold && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif gold-bootstrap
 
 
@@ -16083,9 +16096,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/gold && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif gold-bootstrap
 
 
@@ -16512,7 +16523,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/gprof && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-gprof))
 @endif gprof
 
@@ -17148,7 +17159,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/intl && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-intl))
 @endif intl
 
@@ -17176,7 +17187,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS)   \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS)  \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-intl)
 
@@ -17191,7 +17203,7 @@
 	fi; \
 	cd $(HOST_SUBDIR)/intl && \
 	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		 clean
+	$(STAGE1_FLAGS_TO_PASS)  clean
 @endif intl-bootstrap
 
 
@@ -17232,9 +17244,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/intl && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif intl-bootstrap
 
 
@@ -17275,9 +17285,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/intl && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif intl-bootstrap
 
 
@@ -17318,9 +17326,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/intl && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif intl-bootstrap
 
 
@@ -17361,9 +17367,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/intl && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif intl-bootstrap
 
 
@@ -17404,9 +17408,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/intl && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif intl-bootstrap
 
 
@@ -17833,7 +17835,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/tcl && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-tcl))
 @endif tcl
 
@@ -18258,7 +18260,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/itcl && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-itcl))
 @endif itcl
 
@@ -18894,7 +18896,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/ld && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-ld))
 @endif ld
 
@@ -18922,7 +18924,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS)   \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS)  \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-ld)
 
@@ -18937,7 +18940,7 @@
 	fi; \
 	cd $(HOST_SUBDIR)/ld && \
 	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		 clean
+	$(STAGE1_FLAGS_TO_PASS)  clean
 @endif ld-bootstrap
 
 
@@ -18978,9 +18981,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/ld && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif ld-bootstrap
 
 
@@ -19021,9 +19022,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/ld && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif ld-bootstrap
 
 
@@ -19064,9 +19063,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/ld && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif ld-bootstrap
 
 
@@ -19107,9 +19104,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/ld && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif ld-bootstrap
 
 
@@ -19150,9 +19145,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/ld && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif ld-bootstrap
 
 
@@ -19532,6 +19525,878 @@
 
 
 
+.PHONY: configure-libbacktrace maybe-configure-libbacktrace
+maybe-configure-libbacktrace:
+@if gcc-bootstrap
+configure-libbacktrace: stage_current
+@endif gcc-bootstrap
+@if libbacktrace
+maybe-configure-libbacktrace: configure-libbacktrace
+configure-libbacktrace: 
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	test ! -f $(HOST_SUBDIR)/libbacktrace/Makefile || exit 0; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/libbacktrace ; \
+	$(HOST_EXPORTS)  \
+	echo Configuring in $(HOST_SUBDIR)/libbacktrace; \
+	cd "$(HOST_SUBDIR)/libbacktrace" || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(HOST_SUBDIR)/libbacktrace/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libbacktrace"; \
+	libsrcdir="$$s/libbacktrace"; \
+	$(SHELL) $${libsrcdir}/configure \
+	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
+	  --target=${target_alias} $${srcdiroption}  \
+	  || exit 1
+@endif libbacktrace
+
+
+
+.PHONY: configure-stage1-libbacktrace maybe-configure-stage1-libbacktrace
+maybe-configure-stage1-libbacktrace:
+@if libbacktrace-bootstrap
+maybe-configure-stage1-libbacktrace: configure-stage1-libbacktrace
+configure-stage1-libbacktrace:
+	@[ $(current_stage) = stage1 ] || $(MAKE) stage1-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/libbacktrace
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE1_TFLAGS)"; \
+	test ! -f $(HOST_SUBDIR)/libbacktrace/Makefile || exit 0; \
+	$(HOST_EXPORTS) \
+	CFLAGS="$(STAGE1_CFLAGS)"; export CFLAGS; \
+	CXXFLAGS="$(STAGE1_CXXFLAGS)"; export CXXFLAGS; \
+	LIBCFLAGS="$(LIBCFLAGS)"; export LIBCFLAGS;  \
+	echo Configuring stage 1 in $(HOST_SUBDIR)/libbacktrace ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/libbacktrace ; \
+	cd $(HOST_SUBDIR)/libbacktrace || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(HOST_SUBDIR)/libbacktrace/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libbacktrace"; \
+	libsrcdir="$$s/libbacktrace"; \
+	$(SHELL) $${libsrcdir}/configure \
+	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
+	  --target=${target_alias} $${srcdiroption} \
+	  $(STAGE1_CONFIGURE_FLAGS)
+@endif libbacktrace-bootstrap
+
+.PHONY: configure-stage2-libbacktrace maybe-configure-stage2-libbacktrace
+maybe-configure-stage2-libbacktrace:
+@if libbacktrace-bootstrap
+maybe-configure-stage2-libbacktrace: configure-stage2-libbacktrace
+configure-stage2-libbacktrace:
+	@[ $(current_stage) = stage2 ] || $(MAKE) stage2-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/libbacktrace
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE2_TFLAGS)"; \
+	test ! -f $(HOST_SUBDIR)/libbacktrace/Makefile || exit 0; \
+	$(HOST_EXPORTS) \
+	$(POSTSTAGE1_HOST_EXPORTS) \
+	CFLAGS="$(STAGE2_CFLAGS)"; export CFLAGS; \
+	CXXFLAGS="$(STAGE2_CXXFLAGS)"; export CXXFLAGS; \
+	LIBCFLAGS="$(STAGE2_CFLAGS)"; export LIBCFLAGS;  \
+	echo Configuring stage 2 in $(HOST_SUBDIR)/libbacktrace ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/libbacktrace ; \
+	cd $(HOST_SUBDIR)/libbacktrace || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(HOST_SUBDIR)/libbacktrace/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libbacktrace"; \
+	libsrcdir="$$s/libbacktrace"; \
+	$(SHELL) $${libsrcdir}/configure \
+	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
+	  --target=${target_alias} $${srcdiroption} \
+	  --with-build-libsubdir=$(HOST_SUBDIR) \
+	  $(STAGE2_CONFIGURE_FLAGS)
+@endif libbacktrace-bootstrap
+
+.PHONY: configure-stage3-libbacktrace maybe-configure-stage3-libbacktrace
+maybe-configure-stage3-libbacktrace:
+@if libbacktrace-bootstrap
+maybe-configure-stage3-libbacktrace: configure-stage3-libbacktrace
+configure-stage3-libbacktrace:
+	@[ $(current_stage) = stage3 ] || $(MAKE) stage3-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/libbacktrace
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE3_TFLAGS)"; \
+	test ! -f $(HOST_SUBDIR)/libbacktrace/Makefile || exit 0; \
+	$(HOST_EXPORTS) \
+	$(POSTSTAGE1_HOST_EXPORTS) \
+	CFLAGS="$(STAGE3_CFLAGS)"; export CFLAGS; \
+	CXXFLAGS="$(STAGE3_CXXFLAGS)"; export CXXFLAGS; \
+	LIBCFLAGS="$(STAGE3_CFLAGS)"; export LIBCFLAGS;  \
+	echo Configuring stage 3 in $(HOST_SUBDIR)/libbacktrace ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/libbacktrace ; \
+	cd $(HOST_SUBDIR)/libbacktrace || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(HOST_SUBDIR)/libbacktrace/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libbacktrace"; \
+	libsrcdir="$$s/libbacktrace"; \
+	$(SHELL) $${libsrcdir}/configure \
+	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
+	  --target=${target_alias} $${srcdiroption} \
+	  --with-build-libsubdir=$(HOST_SUBDIR) \
+	  $(STAGE3_CONFIGURE_FLAGS)
+@endif libbacktrace-bootstrap
+
+.PHONY: configure-stage4-libbacktrace maybe-configure-stage4-libbacktrace
+maybe-configure-stage4-libbacktrace:
+@if libbacktrace-bootstrap
+maybe-configure-stage4-libbacktrace: configure-stage4-libbacktrace
+configure-stage4-libbacktrace:
+	@[ $(current_stage) = stage4 ] || $(MAKE) stage4-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/libbacktrace
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE4_TFLAGS)"; \
+	test ! -f $(HOST_SUBDIR)/libbacktrace/Makefile || exit 0; \
+	$(HOST_EXPORTS) \
+	$(POSTSTAGE1_HOST_EXPORTS) \
+	CFLAGS="$(STAGE4_CFLAGS)"; export CFLAGS; \
+	CXXFLAGS="$(STAGE4_CXXFLAGS)"; export CXXFLAGS; \
+	LIBCFLAGS="$(STAGE4_CFLAGS)"; export LIBCFLAGS;  \
+	echo Configuring stage 4 in $(HOST_SUBDIR)/libbacktrace ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/libbacktrace ; \
+	cd $(HOST_SUBDIR)/libbacktrace || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(HOST_SUBDIR)/libbacktrace/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libbacktrace"; \
+	libsrcdir="$$s/libbacktrace"; \
+	$(SHELL) $${libsrcdir}/configure \
+	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
+	  --target=${target_alias} $${srcdiroption} \
+	  --with-build-libsubdir=$(HOST_SUBDIR) \
+	  $(STAGE4_CONFIGURE_FLAGS)
+@endif libbacktrace-bootstrap
+
+.PHONY: configure-stageprofile-libbacktrace maybe-configure-stageprofile-libbacktrace
+maybe-configure-stageprofile-libbacktrace:
+@if libbacktrace-bootstrap
+maybe-configure-stageprofile-libbacktrace: configure-stageprofile-libbacktrace
+configure-stageprofile-libbacktrace:
+	@[ $(current_stage) = stageprofile ] || $(MAKE) stageprofile-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/libbacktrace
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGEprofile_TFLAGS)"; \
+	test ! -f $(HOST_SUBDIR)/libbacktrace/Makefile || exit 0; \
+	$(HOST_EXPORTS) \
+	$(POSTSTAGE1_HOST_EXPORTS) \
+	CFLAGS="$(STAGEprofile_CFLAGS)"; export CFLAGS; \
+	CXXFLAGS="$(STAGEprofile_CXXFLAGS)"; export CXXFLAGS; \
+	LIBCFLAGS="$(STAGEprofile_CFLAGS)"; export LIBCFLAGS;  \
+	echo Configuring stage profile in $(HOST_SUBDIR)/libbacktrace ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/libbacktrace ; \
+	cd $(HOST_SUBDIR)/libbacktrace || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(HOST_SUBDIR)/libbacktrace/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libbacktrace"; \
+	libsrcdir="$$s/libbacktrace"; \
+	$(SHELL) $${libsrcdir}/configure \
+	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
+	  --target=${target_alias} $${srcdiroption} \
+	  --with-build-libsubdir=$(HOST_SUBDIR) \
+	  $(STAGEprofile_CONFIGURE_FLAGS)
+@endif libbacktrace-bootstrap
+
+.PHONY: configure-stagefeedback-libbacktrace maybe-configure-stagefeedback-libbacktrace
+maybe-configure-stagefeedback-libbacktrace:
+@if libbacktrace-bootstrap
+maybe-configure-stagefeedback-libbacktrace: configure-stagefeedback-libbacktrace
+configure-stagefeedback-libbacktrace:
+	@[ $(current_stage) = stagefeedback ] || $(MAKE) stagefeedback-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/libbacktrace
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGEfeedback_TFLAGS)"; \
+	test ! -f $(HOST_SUBDIR)/libbacktrace/Makefile || exit 0; \
+	$(HOST_EXPORTS) \
+	$(POSTSTAGE1_HOST_EXPORTS) \
+	CFLAGS="$(STAGEfeedback_CFLAGS)"; export CFLAGS; \
+	CXXFLAGS="$(STAGEfeedback_CXXFLAGS)"; export CXXFLAGS; \
+	LIBCFLAGS="$(STAGEfeedback_CFLAGS)"; export LIBCFLAGS;  \
+	echo Configuring stage feedback in $(HOST_SUBDIR)/libbacktrace ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/libbacktrace ; \
+	cd $(HOST_SUBDIR)/libbacktrace || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(HOST_SUBDIR)/libbacktrace/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libbacktrace"; \
+	libsrcdir="$$s/libbacktrace"; \
+	$(SHELL) $${libsrcdir}/configure \
+	  $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \
+	  --target=${target_alias} $${srcdiroption} \
+	  --with-build-libsubdir=$(HOST_SUBDIR) \
+	  $(STAGEfeedback_CONFIGURE_FLAGS)
+@endif libbacktrace-bootstrap
+
+
+
+
+
+.PHONY: all-libbacktrace maybe-all-libbacktrace
+maybe-all-libbacktrace:
+@if gcc-bootstrap
+all-libbacktrace: stage_current
+@endif gcc-bootstrap
+@if libbacktrace
+TARGET-libbacktrace=all
+maybe-all-libbacktrace: all-libbacktrace
+all-libbacktrace: configure-libbacktrace
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(HOST_EXPORTS)  \
+	(cd $(HOST_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
+		$(TARGET-libbacktrace))
+@endif libbacktrace
+
+
+
+.PHONY: all-stage1-libbacktrace maybe-all-stage1-libbacktrace
+.PHONY: clean-stage1-libbacktrace maybe-clean-stage1-libbacktrace
+maybe-all-stage1-libbacktrace:
+maybe-clean-stage1-libbacktrace:
+@if libbacktrace-bootstrap
+maybe-all-stage1-libbacktrace: all-stage1-libbacktrace
+all-stage1: all-stage1-libbacktrace
+TARGET-stage1-libbacktrace = $(TARGET-libbacktrace)
+all-stage1-libbacktrace: configure-stage1-libbacktrace
+	@[ $(current_stage) = stage1 ] || $(MAKE) stage1-start
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE1_TFLAGS)"; \
+	$(HOST_EXPORTS)  \
+	cd $(HOST_SUBDIR)/libbacktrace && \
+	$(MAKE) $(BASE_FLAGS_TO_PASS) \
+		CFLAGS="$(STAGE1_CFLAGS)" \
+		CXXFLAGS="$(STAGE1_CXXFLAGS)" \
+		LIBCFLAGS="$(LIBCFLAGS)" \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS)  \
+		TFLAGS="$(STAGE1_TFLAGS)" \
+		$(TARGET-stage1-libbacktrace)
+
+maybe-clean-stage1-libbacktrace: clean-stage1-libbacktrace
+clean-stage1: clean-stage1-libbacktrace
+clean-stage1-libbacktrace:
+	@if [ $(current_stage) = stage1 ]; then \
+	  [ -f $(HOST_SUBDIR)/libbacktrace/Makefile ] || exit 0; \
+	else \
+	  [ -f $(HOST_SUBDIR)/stage1-libbacktrace/Makefile ] || exit 0; \
+	  $(MAKE) stage1-start; \
+	fi; \
+	cd $(HOST_SUBDIR)/libbacktrace && \
+	$(MAKE) $(EXTRA_HOST_FLAGS)  \
+	$(STAGE1_FLAGS_TO_PASS)  clean
+@endif libbacktrace-bootstrap
+
+
+.PHONY: all-stage2-libbacktrace maybe-all-stage2-libbacktrace
+.PHONY: clean-stage2-libbacktrace maybe-clean-stage2-libbacktrace
+maybe-all-stage2-libbacktrace:
+maybe-clean-stage2-libbacktrace:
+@if libbacktrace-bootstrap
+maybe-all-stage2-libbacktrace: all-stage2-libbacktrace
+all-stage2: all-stage2-libbacktrace
+TARGET-stage2-libbacktrace = $(TARGET-libbacktrace)
+all-stage2-libbacktrace: configure-stage2-libbacktrace
+	@[ $(current_stage) = stage2 ] || $(MAKE) stage2-start
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE2_TFLAGS)"; \
+	$(HOST_EXPORTS) \
+	$(POSTSTAGE1_HOST_EXPORTS)  \
+	cd $(HOST_SUBDIR)/libbacktrace && \
+	$(MAKE) $(BASE_FLAGS_TO_PASS) \
+		CFLAGS="$(STAGE2_CFLAGS)" \
+		CXXFLAGS="$(STAGE2_CXXFLAGS)" \
+		LIBCFLAGS="$(STAGE2_CFLAGS)" \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  \
+		TFLAGS="$(STAGE2_TFLAGS)" \
+		$(TARGET-stage2-libbacktrace)
+
+maybe-clean-stage2-libbacktrace: clean-stage2-libbacktrace
+clean-stage2: clean-stage2-libbacktrace
+clean-stage2-libbacktrace:
+	@if [ $(current_stage) = stage2 ]; then \
+	  [ -f $(HOST_SUBDIR)/libbacktrace/Makefile ] || exit 0; \
+	else \
+	  [ -f $(HOST_SUBDIR)/stage2-libbacktrace/Makefile ] || exit 0; \
+	  $(MAKE) stage2-start; \
+	fi; \
+	cd $(HOST_SUBDIR)/libbacktrace && \
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
+@endif libbacktrace-bootstrap
+
+
+.PHONY: all-stage3-libbacktrace maybe-all-stage3-libbacktrace
+.PHONY: clean-stage3-libbacktrace maybe-clean-stage3-libbacktrace
+maybe-all-stage3-libbacktrace:
+maybe-clean-stage3-libbacktrace:
+@if libbacktrace-bootstrap
+maybe-all-stage3-libbacktrace: all-stage3-libbacktrace
+all-stage3: all-stage3-libbacktrace
+TARGET-stage3-libbacktrace = $(TARGET-libbacktrace)
+all-stage3-libbacktrace: configure-stage3-libbacktrace
+	@[ $(current_stage) = stage3 ] || $(MAKE) stage3-start
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE3_TFLAGS)"; \
+	$(HOST_EXPORTS) \
+	$(POSTSTAGE1_HOST_EXPORTS)  \
+	cd $(HOST_SUBDIR)/libbacktrace && \
+	$(MAKE) $(BASE_FLAGS_TO_PASS) \
+		CFLAGS="$(STAGE3_CFLAGS)" \
+		CXXFLAGS="$(STAGE3_CXXFLAGS)" \
+		LIBCFLAGS="$(STAGE3_CFLAGS)" \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  \
+		TFLAGS="$(STAGE3_TFLAGS)" \
+		$(TARGET-stage3-libbacktrace)
+
+maybe-clean-stage3-libbacktrace: clean-stage3-libbacktrace
+clean-stage3: clean-stage3-libbacktrace
+clean-stage3-libbacktrace:
+	@if [ $(current_stage) = stage3 ]; then \
+	  [ -f $(HOST_SUBDIR)/libbacktrace/Makefile ] || exit 0; \
+	else \
+	  [ -f $(HOST_SUBDIR)/stage3-libbacktrace/Makefile ] || exit 0; \
+	  $(MAKE) stage3-start; \
+	fi; \
+	cd $(HOST_SUBDIR)/libbacktrace && \
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
+@endif libbacktrace-bootstrap
+
+
+.PHONY: all-stage4-libbacktrace maybe-all-stage4-libbacktrace
+.PHONY: clean-stage4-libbacktrace maybe-clean-stage4-libbacktrace
+maybe-all-stage4-libbacktrace:
+maybe-clean-stage4-libbacktrace:
+@if libbacktrace-bootstrap
+maybe-all-stage4-libbacktrace: all-stage4-libbacktrace
+all-stage4: all-stage4-libbacktrace
+TARGET-stage4-libbacktrace = $(TARGET-libbacktrace)
+all-stage4-libbacktrace: configure-stage4-libbacktrace
+	@[ $(current_stage) = stage4 ] || $(MAKE) stage4-start
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE4_TFLAGS)"; \
+	$(HOST_EXPORTS) \
+	$(POSTSTAGE1_HOST_EXPORTS)  \
+	cd $(HOST_SUBDIR)/libbacktrace && \
+	$(MAKE) $(BASE_FLAGS_TO_PASS) \
+		CFLAGS="$(STAGE4_CFLAGS)" \
+		CXXFLAGS="$(STAGE4_CXXFLAGS)" \
+		LIBCFLAGS="$(STAGE4_CFLAGS)" \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  \
+		TFLAGS="$(STAGE4_TFLAGS)" \
+		$(TARGET-stage4-libbacktrace)
+
+maybe-clean-stage4-libbacktrace: clean-stage4-libbacktrace
+clean-stage4: clean-stage4-libbacktrace
+clean-stage4-libbacktrace:
+	@if [ $(current_stage) = stage4 ]; then \
+	  [ -f $(HOST_SUBDIR)/libbacktrace/Makefile ] || exit 0; \
+	else \
+	  [ -f $(HOST_SUBDIR)/stage4-libbacktrace/Makefile ] || exit 0; \
+	  $(MAKE) stage4-start; \
+	fi; \
+	cd $(HOST_SUBDIR)/libbacktrace && \
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
+@endif libbacktrace-bootstrap
+
+
+.PHONY: all-stageprofile-libbacktrace maybe-all-stageprofile-libbacktrace
+.PHONY: clean-stageprofile-libbacktrace maybe-clean-stageprofile-libbacktrace
+maybe-all-stageprofile-libbacktrace:
+maybe-clean-stageprofile-libbacktrace:
+@if libbacktrace-bootstrap
+maybe-all-stageprofile-libbacktrace: all-stageprofile-libbacktrace
+all-stageprofile: all-stageprofile-libbacktrace
+TARGET-stageprofile-libbacktrace = $(TARGET-libbacktrace)
+all-stageprofile-libbacktrace: configure-stageprofile-libbacktrace
+	@[ $(current_stage) = stageprofile ] || $(MAKE) stageprofile-start
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGEprofile_TFLAGS)"; \
+	$(HOST_EXPORTS) \
+	$(POSTSTAGE1_HOST_EXPORTS)  \
+	cd $(HOST_SUBDIR)/libbacktrace && \
+	$(MAKE) $(BASE_FLAGS_TO_PASS) \
+		CFLAGS="$(STAGEprofile_CFLAGS)" \
+		CXXFLAGS="$(STAGEprofile_CXXFLAGS)" \
+		LIBCFLAGS="$(STAGEprofile_CFLAGS)" \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  \
+		TFLAGS="$(STAGEprofile_TFLAGS)" \
+		$(TARGET-stageprofile-libbacktrace)
+
+maybe-clean-stageprofile-libbacktrace: clean-stageprofile-libbacktrace
+clean-stageprofile: clean-stageprofile-libbacktrace
+clean-stageprofile-libbacktrace:
+	@if [ $(current_stage) = stageprofile ]; then \
+	  [ -f $(HOST_SUBDIR)/libbacktrace/Makefile ] || exit 0; \
+	else \
+	  [ -f $(HOST_SUBDIR)/stageprofile-libbacktrace/Makefile ] || exit 0; \
+	  $(MAKE) stageprofile-start; \
+	fi; \
+	cd $(HOST_SUBDIR)/libbacktrace && \
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
+@endif libbacktrace-bootstrap
+
+
+.PHONY: all-stagefeedback-libbacktrace maybe-all-stagefeedback-libbacktrace
+.PHONY: clean-stagefeedback-libbacktrace maybe-clean-stagefeedback-libbacktrace
+maybe-all-stagefeedback-libbacktrace:
+maybe-clean-stagefeedback-libbacktrace:
+@if libbacktrace-bootstrap
+maybe-all-stagefeedback-libbacktrace: all-stagefeedback-libbacktrace
+all-stagefeedback: all-stagefeedback-libbacktrace
+TARGET-stagefeedback-libbacktrace = $(TARGET-libbacktrace)
+all-stagefeedback-libbacktrace: configure-stagefeedback-libbacktrace
+	@[ $(current_stage) = stagefeedback ] || $(MAKE) stagefeedback-start
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGEfeedback_TFLAGS)"; \
+	$(HOST_EXPORTS) \
+	$(POSTSTAGE1_HOST_EXPORTS)  \
+	cd $(HOST_SUBDIR)/libbacktrace && \
+	$(MAKE) $(BASE_FLAGS_TO_PASS) \
+		CFLAGS="$(STAGEfeedback_CFLAGS)" \
+		CXXFLAGS="$(STAGEfeedback_CXXFLAGS)" \
+		LIBCFLAGS="$(STAGEfeedback_CFLAGS)" \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		$(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  \
+		TFLAGS="$(STAGEfeedback_TFLAGS)" \
+		$(TARGET-stagefeedback-libbacktrace)
+
+maybe-clean-stagefeedback-libbacktrace: clean-stagefeedback-libbacktrace
+clean-stagefeedback: clean-stagefeedback-libbacktrace
+clean-stagefeedback-libbacktrace:
+	@if [ $(current_stage) = stagefeedback ]; then \
+	  [ -f $(HOST_SUBDIR)/libbacktrace/Makefile ] || exit 0; \
+	else \
+	  [ -f $(HOST_SUBDIR)/stagefeedback-libbacktrace/Makefile ] || exit 0; \
+	  $(MAKE) stagefeedback-start; \
+	fi; \
+	cd $(HOST_SUBDIR)/libbacktrace && \
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
+@endif libbacktrace-bootstrap
+
+
+
+
+
+.PHONY: check-libbacktrace maybe-check-libbacktrace
+maybe-check-libbacktrace:
+@if libbacktrace
+maybe-check-libbacktrace: check-libbacktrace
+
+check-libbacktrace:
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(HOST_EXPORTS) \
+	(cd $(HOST_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(FLAGS_TO_PASS)  check)
+
+@endif libbacktrace
+
+.PHONY: install-libbacktrace maybe-install-libbacktrace
+maybe-install-libbacktrace:
+@if libbacktrace
+maybe-install-libbacktrace: install-libbacktrace
+
+install-libbacktrace: installdirs
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(HOST_EXPORTS) \
+	(cd $(HOST_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(FLAGS_TO_PASS)  install)
+
+@endif libbacktrace
+
+.PHONY: install-strip-libbacktrace maybe-install-strip-libbacktrace
+maybe-install-strip-libbacktrace:
+@if libbacktrace
+maybe-install-strip-libbacktrace: install-strip-libbacktrace
+
+install-strip-libbacktrace: installdirs
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(HOST_EXPORTS) \
+	(cd $(HOST_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(FLAGS_TO_PASS)  install-strip)
+
+@endif libbacktrace
+
+# Other targets (info, dvi, pdf, etc.)
+
+.PHONY: maybe-info-libbacktrace info-libbacktrace
+maybe-info-libbacktrace:
+@if libbacktrace
+maybe-info-libbacktrace: info-libbacktrace
+
+info-libbacktrace: \
+    configure-libbacktrace 
+	@[ -f ./libbacktrace/Makefile ] || exit 0; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(HOST_EXPORTS) \
+	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	echo "Doing info in libbacktrace" ; \
+	(cd $(HOST_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	          info) \
+	  || exit 1
+
+@endif libbacktrace
+
+.PHONY: maybe-dvi-libbacktrace dvi-libbacktrace
+maybe-dvi-libbacktrace:
+@if libbacktrace
+maybe-dvi-libbacktrace: dvi-libbacktrace
+
+dvi-libbacktrace: \
+    configure-libbacktrace 
+	@[ -f ./libbacktrace/Makefile ] || exit 0; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(HOST_EXPORTS) \
+	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	echo "Doing dvi in libbacktrace" ; \
+	(cd $(HOST_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	          dvi) \
+	  || exit 1
+
+@endif libbacktrace
+
+.PHONY: maybe-pdf-libbacktrace pdf-libbacktrace
+maybe-pdf-libbacktrace:
+@if libbacktrace
+maybe-pdf-libbacktrace: pdf-libbacktrace
+
+pdf-libbacktrace: \
+    configure-libbacktrace 
+	@[ -f ./libbacktrace/Makefile ] || exit 0; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(HOST_EXPORTS) \
+	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	echo "Doing pdf in libbacktrace" ; \
+	(cd $(HOST_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	          pdf) \
+	  || exit 1
+
+@endif libbacktrace
+
+.PHONY: maybe-html-libbacktrace html-libbacktrace
+maybe-html-libbacktrace:
+@if libbacktrace
+maybe-html-libbacktrace: html-libbacktrace
+
+html-libbacktrace: \
+    configure-libbacktrace 
+	@[ -f ./libbacktrace/Makefile ] || exit 0; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(HOST_EXPORTS) \
+	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	echo "Doing html in libbacktrace" ; \
+	(cd $(HOST_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	          html) \
+	  || exit 1
+
+@endif libbacktrace
+
+.PHONY: maybe-TAGS-libbacktrace TAGS-libbacktrace
+maybe-TAGS-libbacktrace:
+@if libbacktrace
+maybe-TAGS-libbacktrace: TAGS-libbacktrace
+
+TAGS-libbacktrace: \
+    configure-libbacktrace 
+	@[ -f ./libbacktrace/Makefile ] || exit 0; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(HOST_EXPORTS) \
+	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	echo "Doing TAGS in libbacktrace" ; \
+	(cd $(HOST_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	          TAGS) \
+	  || exit 1
+
+@endif libbacktrace
+
+.PHONY: maybe-install-info-libbacktrace install-info-libbacktrace
+maybe-install-info-libbacktrace:
+@if libbacktrace
+maybe-install-info-libbacktrace: install-info-libbacktrace
+
+install-info-libbacktrace: \
+    configure-libbacktrace \
+    info-libbacktrace 
+	@[ -f ./libbacktrace/Makefile ] || exit 0; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(HOST_EXPORTS) \
+	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	echo "Doing install-info in libbacktrace" ; \
+	(cd $(HOST_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	          install-info) \
+	  || exit 1
+
+@endif libbacktrace
+
+.PHONY: maybe-install-pdf-libbacktrace install-pdf-libbacktrace
+maybe-install-pdf-libbacktrace:
+@if libbacktrace
+maybe-install-pdf-libbacktrace: install-pdf-libbacktrace
+
+install-pdf-libbacktrace: \
+    configure-libbacktrace \
+    pdf-libbacktrace 
+	@[ -f ./libbacktrace/Makefile ] || exit 0; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(HOST_EXPORTS) \
+	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	echo "Doing install-pdf in libbacktrace" ; \
+	(cd $(HOST_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	          install-pdf) \
+	  || exit 1
+
+@endif libbacktrace
+
+.PHONY: maybe-install-html-libbacktrace install-html-libbacktrace
+maybe-install-html-libbacktrace:
+@if libbacktrace
+maybe-install-html-libbacktrace: install-html-libbacktrace
+
+install-html-libbacktrace: \
+    configure-libbacktrace \
+    html-libbacktrace 
+	@[ -f ./libbacktrace/Makefile ] || exit 0; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(HOST_EXPORTS) \
+	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	echo "Doing install-html in libbacktrace" ; \
+	(cd $(HOST_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	          install-html) \
+	  || exit 1
+
+@endif libbacktrace
+
+.PHONY: maybe-installcheck-libbacktrace installcheck-libbacktrace
+maybe-installcheck-libbacktrace:
+@if libbacktrace
+maybe-installcheck-libbacktrace: installcheck-libbacktrace
+
+installcheck-libbacktrace: \
+    configure-libbacktrace 
+	@[ -f ./libbacktrace/Makefile ] || exit 0; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(HOST_EXPORTS) \
+	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	echo "Doing installcheck in libbacktrace" ; \
+	(cd $(HOST_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	          installcheck) \
+	  || exit 1
+
+@endif libbacktrace
+
+.PHONY: maybe-mostlyclean-libbacktrace mostlyclean-libbacktrace
+maybe-mostlyclean-libbacktrace:
+@if libbacktrace
+maybe-mostlyclean-libbacktrace: mostlyclean-libbacktrace
+
+mostlyclean-libbacktrace: 
+	@[ -f ./libbacktrace/Makefile ] || exit 0; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(HOST_EXPORTS) \
+	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	echo "Doing mostlyclean in libbacktrace" ; \
+	(cd $(HOST_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	          mostlyclean) \
+	  || exit 1
+
+@endif libbacktrace
+
+.PHONY: maybe-clean-libbacktrace clean-libbacktrace
+maybe-clean-libbacktrace:
+@if libbacktrace
+maybe-clean-libbacktrace: clean-libbacktrace
+
+clean-libbacktrace: 
+	@[ -f ./libbacktrace/Makefile ] || exit 0; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(HOST_EXPORTS) \
+	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	echo "Doing clean in libbacktrace" ; \
+	(cd $(HOST_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	          clean) \
+	  || exit 1
+
+@endif libbacktrace
+
+.PHONY: maybe-distclean-libbacktrace distclean-libbacktrace
+maybe-distclean-libbacktrace:
+@if libbacktrace
+maybe-distclean-libbacktrace: distclean-libbacktrace
+
+distclean-libbacktrace: 
+	@[ -f ./libbacktrace/Makefile ] || exit 0; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(HOST_EXPORTS) \
+	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	echo "Doing distclean in libbacktrace" ; \
+	(cd $(HOST_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	          distclean) \
+	  || exit 1
+
+@endif libbacktrace
+
+.PHONY: maybe-maintainer-clean-libbacktrace maintainer-clean-libbacktrace
+maybe-maintainer-clean-libbacktrace:
+@if libbacktrace
+maybe-maintainer-clean-libbacktrace: maintainer-clean-libbacktrace
+
+maintainer-clean-libbacktrace: 
+	@[ -f ./libbacktrace/Makefile ] || exit 0; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(HOST_EXPORTS) \
+	for flag in $(EXTRA_HOST_FLAGS) ; do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	echo "Doing maintainer-clean in libbacktrace" ; \
+	(cd $(HOST_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	          maintainer-clean) \
+	  || exit 1
+
+@endif libbacktrace
+
+
+
 .PHONY: configure-libcpp maybe-configure-libcpp
 maybe-configure-libcpp:
 @if gcc-bootstrap
@@ -19775,7 +20640,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/libcpp && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-libcpp))
 @endif libcpp
 
@@ -19803,7 +20668,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS)   \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS)  \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-libcpp)
 
@@ -19818,7 +20684,7 @@
 	fi; \
 	cd $(HOST_SUBDIR)/libcpp && \
 	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		 clean
+	$(STAGE1_FLAGS_TO_PASS)  clean
 @endif libcpp-bootstrap
 
 
@@ -19859,9 +20725,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libcpp && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libcpp-bootstrap
 
 
@@ -19902,9 +20766,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libcpp && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libcpp-bootstrap
 
 
@@ -19945,9 +20807,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libcpp && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libcpp-bootstrap
 
 
@@ -19988,9 +20848,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libcpp && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libcpp-bootstrap
 
 
@@ -20031,9 +20889,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libcpp && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libcpp-bootstrap
 
 
@@ -20656,7 +21512,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/libdecnumber && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-libdecnumber))
 @endif libdecnumber
 
@@ -20684,7 +21540,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS)   \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS)  \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-libdecnumber)
 
@@ -20699,7 +21556,7 @@
 	fi; \
 	cd $(HOST_SUBDIR)/libdecnumber && \
 	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		 clean
+	$(STAGE1_FLAGS_TO_PASS)  clean
 @endif libdecnumber-bootstrap
 
 
@@ -20740,9 +21597,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libdecnumber && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libdecnumber-bootstrap
 
 
@@ -20783,9 +21638,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libdecnumber && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libdecnumber-bootstrap
 
 
@@ -20826,9 +21679,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libdecnumber && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libdecnumber-bootstrap
 
 
@@ -20869,9 +21720,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libdecnumber && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libdecnumber-bootstrap
 
 
@@ -20912,9 +21761,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libdecnumber && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libdecnumber-bootstrap
 
 
@@ -21341,7 +22188,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/libgui && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-libgui))
 @endif libgui
 
@@ -21983,7 +22830,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/libiberty && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-libiberty))
 @endif libiberty
 
@@ -22011,7 +22858,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS)   \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS)  \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-libiberty)
 
@@ -22026,7 +22874,7 @@
 	fi; \
 	cd $(HOST_SUBDIR)/libiberty && \
 	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		 clean
+	$(STAGE1_FLAGS_TO_PASS)  clean
 @endif libiberty-bootstrap
 
 
@@ -22067,9 +22915,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libiberty && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libiberty-bootstrap
 
 
@@ -22110,9 +22956,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libiberty && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libiberty-bootstrap
 
 
@@ -22153,9 +22997,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libiberty && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libiberty-bootstrap
 
 
@@ -22196,9 +23038,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libiberty && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libiberty-bootstrap
 
 
@@ -22239,9 +23079,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/libiberty && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif libiberty-bootstrap
 
 
@@ -22668,7 +23506,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/libiconv && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-libiconv))
 @endif libiconv
 
@@ -23045,7 +23883,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/m4 && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-m4))
 @endif m4
 
@@ -23485,7 +24323,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/readline && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-readline))
 @endif readline
 
@@ -23925,7 +24763,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/sid && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-sid))
 @endif sid
 
@@ -24365,7 +25203,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/sim && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-sim))
 @endif sim
 
@@ -24805,7 +25643,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/texinfo && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-texinfo))
 @endif texinfo
 
@@ -25429,7 +26267,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/zlib && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-zlib))
 @endif zlib
 
@@ -25457,7 +26295,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS)   \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS)  \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-zlib)
 
@@ -25472,7 +26311,7 @@
 	fi; \
 	cd $(HOST_SUBDIR)/zlib && \
 	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		 clean
+	$(STAGE1_FLAGS_TO_PASS)  clean
 @endif zlib-bootstrap
 
 
@@ -25513,9 +26352,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/zlib && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif zlib-bootstrap
 
 
@@ -25556,9 +26393,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/zlib && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif zlib-bootstrap
 
 
@@ -25599,9 +26434,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/zlib && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif zlib-bootstrap
 
 
@@ -25642,9 +26475,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/zlib && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif zlib-bootstrap
 
 
@@ -25685,9 +26516,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/zlib && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif zlib-bootstrap
 
 
@@ -26096,7 +26925,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/gdb && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-gdb))
 @endif gdb
 
@@ -26536,7 +27365,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/expect && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-expect))
 @endif expect
 
@@ -26976,7 +27805,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/guile && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-guile))
 @endif guile
 
@@ -27416,7 +28245,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/tk && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-tk))
 @endif tk
 
@@ -27856,7 +28685,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/libtermcap && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-libtermcap))
 @endif libtermcap
 
@@ -28230,7 +29059,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/utils && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-utils))
 @endif utils
 
@@ -28664,7 +29493,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/gnattools && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-gnattools))
 @endif gnattools
 
@@ -29306,7 +30135,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS)  \
 	(cd $(HOST_SUBDIR)/lto-plugin && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
 		$(TARGET-lto-plugin))
 @endif lto-plugin
 
@@ -29334,7 +30163,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_HOST_FLAGS)   \
+		$(EXTRA_HOST_FLAGS)  \
+		$(STAGE1_FLAGS_TO_PASS)  \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-lto-plugin)
 
@@ -29349,7 +30179,7 @@
 	fi; \
 	cd $(HOST_SUBDIR)/lto-plugin && \
 	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		 clean
+	$(STAGE1_FLAGS_TO_PASS)  clean
 @endif lto-plugin-bootstrap
 
 
@@ -29390,9 +30220,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/lto-plugin && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif lto-plugin-bootstrap
 
 
@@ -29433,9 +30261,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/lto-plugin && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif lto-plugin-bootstrap
 
 
@@ -29476,9 +30302,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/lto-plugin && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif lto-plugin-bootstrap
 
 
@@ -29519,9 +30343,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/lto-plugin && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif lto-plugin-bootstrap
 
 
@@ -29562,9 +30384,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(HOST_SUBDIR)/lto-plugin && \
-	$(MAKE) $(EXTRA_HOST_FLAGS)  \
-		$(POSTSTAGE1_FLAGS_TO_PASS)  \
-		 clean
+	$(MAKE) $(EXTRA_HOST_FLAGS) $(POSTSTAGE1_FLAGS_TO_PASS)  clean
 @endif lto-plugin-bootstrap
 
 
@@ -30280,7 +31100,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(RAW_CXX_TARGET_EXPORTS)  \
 	(cd $(TARGET_SUBDIR)/libstdc++-v3 && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   \
 		$(TARGET-target-libstdc++-v3))
 @endif target-libstdc++-v3
 
@@ -30308,7 +31128,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   \
+		$(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'  \
+		  \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-target-libstdc++-v3)
 
@@ -30323,7 +31144,7 @@
 	fi; \
 	cd $(TARGET_SUBDIR)/libstdc++-v3 && \
 	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'  \
-		 clean
+	  clean
 @endif target-libstdc++-v3-bootstrap
 
 
@@ -30364,9 +31185,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(TARGET_SUBDIR)/libstdc++-v3 && \
-	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'  \
-		  \
-		 clean
+	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   clean
 @endif target-libstdc++-v3-bootstrap
 
 
@@ -30407,9 +31226,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(TARGET_SUBDIR)/libstdc++-v3 && \
-	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'  \
-		  \
-		 clean
+	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   clean
 @endif target-libstdc++-v3-bootstrap
 
 
@@ -30450,9 +31267,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(TARGET_SUBDIR)/libstdc++-v3 && \
-	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'  \
-		  \
-		 clean
+	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   clean
 @endif target-libstdc++-v3-bootstrap
 
 
@@ -30493,9 +31308,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(TARGET_SUBDIR)/libstdc++-v3 && \
-	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'  \
-		  \
-		 clean
+	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   clean
 @endif target-libstdc++-v3-bootstrap
 
 
@@ -30536,9 +31349,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(TARGET_SUBDIR)/libstdc++-v3 && \
-	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'  \
-		  \
-		 clean
+	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   clean
 @endif target-libstdc++-v3-bootstrap
 
 
@@ -30995,7 +31806,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(NORMAL_TARGET_EXPORTS)  \
 	(cd $(TARGET_SUBDIR)/libmudflap && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
 		$(TARGET-target-libmudflap))
 @endif target-libmudflap
 
@@ -31391,6 +32202,1954 @@
 
 
 
+.PHONY: configure-target-libsanitizer maybe-configure-target-libsanitizer
+maybe-configure-target-libsanitizer:
+@if gcc-bootstrap
+configure-target-libsanitizer: stage_current
+@endif gcc-bootstrap
+@if target-libsanitizer
+maybe-configure-target-libsanitizer: configure-target-libsanitizer
+configure-target-libsanitizer: 
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	echo "Checking multilib configuration for libsanitizer..."; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libsanitizer ; \
+	$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libsanitizer/multilib.tmp 2> /dev/null ; \
+	if test -r $(TARGET_SUBDIR)/libsanitizer/multilib.out; then \
+	  if cmp -s $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; then \
+	    rm -f $(TARGET_SUBDIR)/libsanitizer/multilib.tmp; \
+	  else \
+	    rm -f $(TARGET_SUBDIR)/libsanitizer/Makefile; \
+	    mv $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; \
+	  fi; \
+	else \
+	  mv $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; \
+	fi; \
+	test ! -f $(TARGET_SUBDIR)/libsanitizer/Makefile || exit 0; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libsanitizer ; \
+	$(RAW_CXX_TARGET_EXPORTS)  \
+	echo Configuring in $(TARGET_SUBDIR)/libsanitizer; \
+	cd "$(TARGET_SUBDIR)/libsanitizer" || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(TARGET_SUBDIR)/libsanitizer/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libsanitizer"; \
+	libsrcdir="$$s/libsanitizer"; \
+	rm -f no-such-file || : ; \
+	CONFIG_SITE=no-such-file $(SHELL) $${libsrcdir}/configure \
+	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+	  --target=${target_alias} $${srcdiroption}  \
+	  || exit 1
+@endif target-libsanitizer
+
+
+
+.PHONY: configure-stage1-target-libsanitizer maybe-configure-stage1-target-libsanitizer
+maybe-configure-stage1-target-libsanitizer:
+@if target-libsanitizer-bootstrap
+maybe-configure-stage1-target-libsanitizer: configure-stage1-target-libsanitizer
+configure-stage1-target-libsanitizer:
+	@[ $(current_stage) = stage1 ] || $(MAKE) stage1-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libsanitizer
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE1_TFLAGS)"; \
+	echo "Checking multilib configuration for libsanitizer..."; \
+	$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libsanitizer/multilib.tmp 2> /dev/null ; \
+	if test -r $(TARGET_SUBDIR)/libsanitizer/multilib.out; then \
+	  if cmp -s $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; then \
+	    rm -f $(TARGET_SUBDIR)/libsanitizer/multilib.tmp; \
+	  else \
+	    rm -f $(TARGET_SUBDIR)/libsanitizer/Makefile; \
+	    mv $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; \
+	  fi; \
+	else \
+	  mv $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; \
+	fi; \
+	test ! -f $(TARGET_SUBDIR)/libsanitizer/Makefile || exit 0; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
+	CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \
+	LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)"; export LIBCFLAGS;  \
+	echo Configuring stage 1 in $(TARGET_SUBDIR)/libsanitizer ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libsanitizer ; \
+	cd $(TARGET_SUBDIR)/libsanitizer || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(TARGET_SUBDIR)/libsanitizer/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libsanitizer"; \
+	libsrcdir="$$s/libsanitizer"; \
+	$(SHELL) $${libsrcdir}/configure \
+	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+	  --target=${target_alias} $${srcdiroption} \
+	  $(STAGE1_CONFIGURE_FLAGS)
+@endif target-libsanitizer-bootstrap
+
+.PHONY: configure-stage2-target-libsanitizer maybe-configure-stage2-target-libsanitizer
+maybe-configure-stage2-target-libsanitizer:
+@if target-libsanitizer-bootstrap
+maybe-configure-stage2-target-libsanitizer: configure-stage2-target-libsanitizer
+configure-stage2-target-libsanitizer:
+	@[ $(current_stage) = stage2 ] || $(MAKE) stage2-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libsanitizer
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE2_TFLAGS)"; \
+	echo "Checking multilib configuration for libsanitizer..."; \
+	$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libsanitizer/multilib.tmp 2> /dev/null ; \
+	if test -r $(TARGET_SUBDIR)/libsanitizer/multilib.out; then \
+	  if cmp -s $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; then \
+	    rm -f $(TARGET_SUBDIR)/libsanitizer/multilib.tmp; \
+	  else \
+	    rm -f $(TARGET_SUBDIR)/libsanitizer/Makefile; \
+	    mv $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; \
+	  fi; \
+	else \
+	  mv $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; \
+	fi; \
+	test ! -f $(TARGET_SUBDIR)/libsanitizer/Makefile || exit 0; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	 \
+	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
+	CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \
+	LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)"; export LIBCFLAGS;  \
+	echo Configuring stage 2 in $(TARGET_SUBDIR)/libsanitizer ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libsanitizer ; \
+	cd $(TARGET_SUBDIR)/libsanitizer || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(TARGET_SUBDIR)/libsanitizer/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libsanitizer"; \
+	libsrcdir="$$s/libsanitizer"; \
+	$(SHELL) $${libsrcdir}/configure \
+	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+	  --target=${target_alias} $${srcdiroption} \
+	  --with-build-libsubdir=$(HOST_SUBDIR) \
+	  $(STAGE2_CONFIGURE_FLAGS)
+@endif target-libsanitizer-bootstrap
+
+.PHONY: configure-stage3-target-libsanitizer maybe-configure-stage3-target-libsanitizer
+maybe-configure-stage3-target-libsanitizer:
+@if target-libsanitizer-bootstrap
+maybe-configure-stage3-target-libsanitizer: configure-stage3-target-libsanitizer
+configure-stage3-target-libsanitizer:
+	@[ $(current_stage) = stage3 ] || $(MAKE) stage3-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libsanitizer
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE3_TFLAGS)"; \
+	echo "Checking multilib configuration for libsanitizer..."; \
+	$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libsanitizer/multilib.tmp 2> /dev/null ; \
+	if test -r $(TARGET_SUBDIR)/libsanitizer/multilib.out; then \
+	  if cmp -s $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; then \
+	    rm -f $(TARGET_SUBDIR)/libsanitizer/multilib.tmp; \
+	  else \
+	    rm -f $(TARGET_SUBDIR)/libsanitizer/Makefile; \
+	    mv $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; \
+	  fi; \
+	else \
+	  mv $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; \
+	fi; \
+	test ! -f $(TARGET_SUBDIR)/libsanitizer/Makefile || exit 0; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	 \
+	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
+	CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \
+	LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)"; export LIBCFLAGS;  \
+	echo Configuring stage 3 in $(TARGET_SUBDIR)/libsanitizer ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libsanitizer ; \
+	cd $(TARGET_SUBDIR)/libsanitizer || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(TARGET_SUBDIR)/libsanitizer/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libsanitizer"; \
+	libsrcdir="$$s/libsanitizer"; \
+	$(SHELL) $${libsrcdir}/configure \
+	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+	  --target=${target_alias} $${srcdiroption} \
+	  --with-build-libsubdir=$(HOST_SUBDIR) \
+	  $(STAGE3_CONFIGURE_FLAGS)
+@endif target-libsanitizer-bootstrap
+
+.PHONY: configure-stage4-target-libsanitizer maybe-configure-stage4-target-libsanitizer
+maybe-configure-stage4-target-libsanitizer:
+@if target-libsanitizer-bootstrap
+maybe-configure-stage4-target-libsanitizer: configure-stage4-target-libsanitizer
+configure-stage4-target-libsanitizer:
+	@[ $(current_stage) = stage4 ] || $(MAKE) stage4-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libsanitizer
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE4_TFLAGS)"; \
+	echo "Checking multilib configuration for libsanitizer..."; \
+	$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libsanitizer/multilib.tmp 2> /dev/null ; \
+	if test -r $(TARGET_SUBDIR)/libsanitizer/multilib.out; then \
+	  if cmp -s $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; then \
+	    rm -f $(TARGET_SUBDIR)/libsanitizer/multilib.tmp; \
+	  else \
+	    rm -f $(TARGET_SUBDIR)/libsanitizer/Makefile; \
+	    mv $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; \
+	  fi; \
+	else \
+	  mv $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; \
+	fi; \
+	test ! -f $(TARGET_SUBDIR)/libsanitizer/Makefile || exit 0; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	 \
+	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
+	CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \
+	LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)"; export LIBCFLAGS;  \
+	echo Configuring stage 4 in $(TARGET_SUBDIR)/libsanitizer ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libsanitizer ; \
+	cd $(TARGET_SUBDIR)/libsanitizer || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(TARGET_SUBDIR)/libsanitizer/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libsanitizer"; \
+	libsrcdir="$$s/libsanitizer"; \
+	$(SHELL) $${libsrcdir}/configure \
+	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+	  --target=${target_alias} $${srcdiroption} \
+	  --with-build-libsubdir=$(HOST_SUBDIR) \
+	  $(STAGE4_CONFIGURE_FLAGS)
+@endif target-libsanitizer-bootstrap
+
+.PHONY: configure-stageprofile-target-libsanitizer maybe-configure-stageprofile-target-libsanitizer
+maybe-configure-stageprofile-target-libsanitizer:
+@if target-libsanitizer-bootstrap
+maybe-configure-stageprofile-target-libsanitizer: configure-stageprofile-target-libsanitizer
+configure-stageprofile-target-libsanitizer:
+	@[ $(current_stage) = stageprofile ] || $(MAKE) stageprofile-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libsanitizer
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGEprofile_TFLAGS)"; \
+	echo "Checking multilib configuration for libsanitizer..."; \
+	$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libsanitizer/multilib.tmp 2> /dev/null ; \
+	if test -r $(TARGET_SUBDIR)/libsanitizer/multilib.out; then \
+	  if cmp -s $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; then \
+	    rm -f $(TARGET_SUBDIR)/libsanitizer/multilib.tmp; \
+	  else \
+	    rm -f $(TARGET_SUBDIR)/libsanitizer/Makefile; \
+	    mv $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; \
+	  fi; \
+	else \
+	  mv $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; \
+	fi; \
+	test ! -f $(TARGET_SUBDIR)/libsanitizer/Makefile || exit 0; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	 \
+	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
+	CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \
+	LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)"; export LIBCFLAGS;  \
+	echo Configuring stage profile in $(TARGET_SUBDIR)/libsanitizer ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libsanitizer ; \
+	cd $(TARGET_SUBDIR)/libsanitizer || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(TARGET_SUBDIR)/libsanitizer/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libsanitizer"; \
+	libsrcdir="$$s/libsanitizer"; \
+	$(SHELL) $${libsrcdir}/configure \
+	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+	  --target=${target_alias} $${srcdiroption} \
+	  --with-build-libsubdir=$(HOST_SUBDIR) \
+	  $(STAGEprofile_CONFIGURE_FLAGS)
+@endif target-libsanitizer-bootstrap
+
+.PHONY: configure-stagefeedback-target-libsanitizer maybe-configure-stagefeedback-target-libsanitizer
+maybe-configure-stagefeedback-target-libsanitizer:
+@if target-libsanitizer-bootstrap
+maybe-configure-stagefeedback-target-libsanitizer: configure-stagefeedback-target-libsanitizer
+configure-stagefeedback-target-libsanitizer:
+	@[ $(current_stage) = stagefeedback ] || $(MAKE) stagefeedback-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libsanitizer
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGEfeedback_TFLAGS)"; \
+	echo "Checking multilib configuration for libsanitizer..."; \
+	$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libsanitizer/multilib.tmp 2> /dev/null ; \
+	if test -r $(TARGET_SUBDIR)/libsanitizer/multilib.out; then \
+	  if cmp -s $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; then \
+	    rm -f $(TARGET_SUBDIR)/libsanitizer/multilib.tmp; \
+	  else \
+	    rm -f $(TARGET_SUBDIR)/libsanitizer/Makefile; \
+	    mv $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; \
+	  fi; \
+	else \
+	  mv $(TARGET_SUBDIR)/libsanitizer/multilib.tmp $(TARGET_SUBDIR)/libsanitizer/multilib.out; \
+	fi; \
+	test ! -f $(TARGET_SUBDIR)/libsanitizer/Makefile || exit 0; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	 \
+	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
+	CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \
+	LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)"; export LIBCFLAGS;  \
+	echo Configuring stage feedback in $(TARGET_SUBDIR)/libsanitizer ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libsanitizer ; \
+	cd $(TARGET_SUBDIR)/libsanitizer || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(TARGET_SUBDIR)/libsanitizer/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libsanitizer"; \
+	libsrcdir="$$s/libsanitizer"; \
+	$(SHELL) $${libsrcdir}/configure \
+	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+	  --target=${target_alias} $${srcdiroption} \
+	  --with-build-libsubdir=$(HOST_SUBDIR) \
+	  $(STAGEfeedback_CONFIGURE_FLAGS)
+@endif target-libsanitizer-bootstrap
+
+
+
+
+
+.PHONY: all-target-libsanitizer maybe-all-target-libsanitizer
+maybe-all-target-libsanitizer:
+@if gcc-bootstrap
+all-target-libsanitizer: stage_current
+@endif gcc-bootstrap
+@if target-libsanitizer
+TARGET-target-libsanitizer=all
+maybe-all-target-libsanitizer: all-target-libsanitizer
+all-target-libsanitizer: configure-target-libsanitizer
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS)  \
+	(cd $(TARGET_SUBDIR)/libsanitizer && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   \
+		$(TARGET-target-libsanitizer))
+@endif target-libsanitizer
+
+
+
+.PHONY: all-stage1-target-libsanitizer maybe-all-stage1-target-libsanitizer
+.PHONY: clean-stage1-target-libsanitizer maybe-clean-stage1-target-libsanitizer
+maybe-all-stage1-target-libsanitizer:
+maybe-clean-stage1-target-libsanitizer:
+@if target-libsanitizer-bootstrap
+maybe-all-stage1-target-libsanitizer: all-stage1-target-libsanitizer
+all-stage1: all-stage1-target-libsanitizer
+TARGET-stage1-target-libsanitizer = $(TARGET-target-libsanitizer)
+all-stage1-target-libsanitizer: configure-stage1-target-libsanitizer
+	@[ $(current_stage) = stage1 ] || $(MAKE) stage1-start
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE1_TFLAGS)"; \
+	$(RAW_CXX_TARGET_EXPORTS)  \
+	cd $(TARGET_SUBDIR)/libsanitizer && \
+	$(MAKE) $(BASE_FLAGS_TO_PASS) \
+		CFLAGS="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)" \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		$(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'  \
+		  \
+		TFLAGS="$(STAGE1_TFLAGS)" \
+		$(TARGET-stage1-target-libsanitizer)
+
+maybe-clean-stage1-target-libsanitizer: clean-stage1-target-libsanitizer
+clean-stage1: clean-stage1-target-libsanitizer
+clean-stage1-target-libsanitizer:
+	@if [ $(current_stage) = stage1 ]; then \
+	  [ -f $(TARGET_SUBDIR)/libsanitizer/Makefile ] || exit 0; \
+	else \
+	  [ -f $(TARGET_SUBDIR)/stage1-libsanitizer/Makefile ] || exit 0; \
+	  $(MAKE) stage1-start; \
+	fi; \
+	cd $(TARGET_SUBDIR)/libsanitizer && \
+	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'  \
+	  clean
+@endif target-libsanitizer-bootstrap
+
+
+.PHONY: all-stage2-target-libsanitizer maybe-all-stage2-target-libsanitizer
+.PHONY: clean-stage2-target-libsanitizer maybe-clean-stage2-target-libsanitizer
+maybe-all-stage2-target-libsanitizer:
+maybe-clean-stage2-target-libsanitizer:
+@if target-libsanitizer-bootstrap
+maybe-all-stage2-target-libsanitizer: all-stage2-target-libsanitizer
+all-stage2: all-stage2-target-libsanitizer
+TARGET-stage2-target-libsanitizer = $(TARGET-target-libsanitizer)
+all-stage2-target-libsanitizer: configure-stage2-target-libsanitizer
+	@[ $(current_stage) = stage2 ] || $(MAKE) stage2-start
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE2_TFLAGS)"; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	  \
+	cd $(TARGET_SUBDIR)/libsanitizer && \
+	$(MAKE) $(BASE_FLAGS_TO_PASS) \
+		CFLAGS="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)" \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		$(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   \
+		TFLAGS="$(STAGE2_TFLAGS)" \
+		$(TARGET-stage2-target-libsanitizer)
+
+maybe-clean-stage2-target-libsanitizer: clean-stage2-target-libsanitizer
+clean-stage2: clean-stage2-target-libsanitizer
+clean-stage2-target-libsanitizer:
+	@if [ $(current_stage) = stage2 ]; then \
+	  [ -f $(TARGET_SUBDIR)/libsanitizer/Makefile ] || exit 0; \
+	else \
+	  [ -f $(TARGET_SUBDIR)/stage2-libsanitizer/Makefile ] || exit 0; \
+	  $(MAKE) stage2-start; \
+	fi; \
+	cd $(TARGET_SUBDIR)/libsanitizer && \
+	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   clean
+@endif target-libsanitizer-bootstrap
+
+
+.PHONY: all-stage3-target-libsanitizer maybe-all-stage3-target-libsanitizer
+.PHONY: clean-stage3-target-libsanitizer maybe-clean-stage3-target-libsanitizer
+maybe-all-stage3-target-libsanitizer:
+maybe-clean-stage3-target-libsanitizer:
+@if target-libsanitizer-bootstrap
+maybe-all-stage3-target-libsanitizer: all-stage3-target-libsanitizer
+all-stage3: all-stage3-target-libsanitizer
+TARGET-stage3-target-libsanitizer = $(TARGET-target-libsanitizer)
+all-stage3-target-libsanitizer: configure-stage3-target-libsanitizer
+	@[ $(current_stage) = stage3 ] || $(MAKE) stage3-start
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE3_TFLAGS)"; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	  \
+	cd $(TARGET_SUBDIR)/libsanitizer && \
+	$(MAKE) $(BASE_FLAGS_TO_PASS) \
+		CFLAGS="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)" \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		$(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   \
+		TFLAGS="$(STAGE3_TFLAGS)" \
+		$(TARGET-stage3-target-libsanitizer)
+
+maybe-clean-stage3-target-libsanitizer: clean-stage3-target-libsanitizer
+clean-stage3: clean-stage3-target-libsanitizer
+clean-stage3-target-libsanitizer:
+	@if [ $(current_stage) = stage3 ]; then \
+	  [ -f $(TARGET_SUBDIR)/libsanitizer/Makefile ] || exit 0; \
+	else \
+	  [ -f $(TARGET_SUBDIR)/stage3-libsanitizer/Makefile ] || exit 0; \
+	  $(MAKE) stage3-start; \
+	fi; \
+	cd $(TARGET_SUBDIR)/libsanitizer && \
+	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   clean
+@endif target-libsanitizer-bootstrap
+
+
+.PHONY: all-stage4-target-libsanitizer maybe-all-stage4-target-libsanitizer
+.PHONY: clean-stage4-target-libsanitizer maybe-clean-stage4-target-libsanitizer
+maybe-all-stage4-target-libsanitizer:
+maybe-clean-stage4-target-libsanitizer:
+@if target-libsanitizer-bootstrap
+maybe-all-stage4-target-libsanitizer: all-stage4-target-libsanitizer
+all-stage4: all-stage4-target-libsanitizer
+TARGET-stage4-target-libsanitizer = $(TARGET-target-libsanitizer)
+all-stage4-target-libsanitizer: configure-stage4-target-libsanitizer
+	@[ $(current_stage) = stage4 ] || $(MAKE) stage4-start
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE4_TFLAGS)"; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	  \
+	cd $(TARGET_SUBDIR)/libsanitizer && \
+	$(MAKE) $(BASE_FLAGS_TO_PASS) \
+		CFLAGS="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)" \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		$(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   \
+		TFLAGS="$(STAGE4_TFLAGS)" \
+		$(TARGET-stage4-target-libsanitizer)
+
+maybe-clean-stage4-target-libsanitizer: clean-stage4-target-libsanitizer
+clean-stage4: clean-stage4-target-libsanitizer
+clean-stage4-target-libsanitizer:
+	@if [ $(current_stage) = stage4 ]; then \
+	  [ -f $(TARGET_SUBDIR)/libsanitizer/Makefile ] || exit 0; \
+	else \
+	  [ -f $(TARGET_SUBDIR)/stage4-libsanitizer/Makefile ] || exit 0; \
+	  $(MAKE) stage4-start; \
+	fi; \
+	cd $(TARGET_SUBDIR)/libsanitizer && \
+	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   clean
+@endif target-libsanitizer-bootstrap
+
+
+.PHONY: all-stageprofile-target-libsanitizer maybe-all-stageprofile-target-libsanitizer
+.PHONY: clean-stageprofile-target-libsanitizer maybe-clean-stageprofile-target-libsanitizer
+maybe-all-stageprofile-target-libsanitizer:
+maybe-clean-stageprofile-target-libsanitizer:
+@if target-libsanitizer-bootstrap
+maybe-all-stageprofile-target-libsanitizer: all-stageprofile-target-libsanitizer
+all-stageprofile: all-stageprofile-target-libsanitizer
+TARGET-stageprofile-target-libsanitizer = $(TARGET-target-libsanitizer)
+all-stageprofile-target-libsanitizer: configure-stageprofile-target-libsanitizer
+	@[ $(current_stage) = stageprofile ] || $(MAKE) stageprofile-start
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGEprofile_TFLAGS)"; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	  \
+	cd $(TARGET_SUBDIR)/libsanitizer && \
+	$(MAKE) $(BASE_FLAGS_TO_PASS) \
+		CFLAGS="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)" \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		$(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   \
+		TFLAGS="$(STAGEprofile_TFLAGS)" \
+		$(TARGET-stageprofile-target-libsanitizer)
+
+maybe-clean-stageprofile-target-libsanitizer: clean-stageprofile-target-libsanitizer
+clean-stageprofile: clean-stageprofile-target-libsanitizer
+clean-stageprofile-target-libsanitizer:
+	@if [ $(current_stage) = stageprofile ]; then \
+	  [ -f $(TARGET_SUBDIR)/libsanitizer/Makefile ] || exit 0; \
+	else \
+	  [ -f $(TARGET_SUBDIR)/stageprofile-libsanitizer/Makefile ] || exit 0; \
+	  $(MAKE) stageprofile-start; \
+	fi; \
+	cd $(TARGET_SUBDIR)/libsanitizer && \
+	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   clean
+@endif target-libsanitizer-bootstrap
+
+
+.PHONY: all-stagefeedback-target-libsanitizer maybe-all-stagefeedback-target-libsanitizer
+.PHONY: clean-stagefeedback-target-libsanitizer maybe-clean-stagefeedback-target-libsanitizer
+maybe-all-stagefeedback-target-libsanitizer:
+maybe-clean-stagefeedback-target-libsanitizer:
+@if target-libsanitizer-bootstrap
+maybe-all-stagefeedback-target-libsanitizer: all-stagefeedback-target-libsanitizer
+all-stagefeedback: all-stagefeedback-target-libsanitizer
+TARGET-stagefeedback-target-libsanitizer = $(TARGET-target-libsanitizer)
+all-stagefeedback-target-libsanitizer: configure-stagefeedback-target-libsanitizer
+	@[ $(current_stage) = stagefeedback ] || $(MAKE) stagefeedback-start
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGEfeedback_TFLAGS)"; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	  \
+	cd $(TARGET_SUBDIR)/libsanitizer && \
+	$(MAKE) $(BASE_FLAGS_TO_PASS) \
+		CFLAGS="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)" \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		$(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   \
+		TFLAGS="$(STAGEfeedback_TFLAGS)" \
+		$(TARGET-stagefeedback-target-libsanitizer)
+
+maybe-clean-stagefeedback-target-libsanitizer: clean-stagefeedback-target-libsanitizer
+clean-stagefeedback: clean-stagefeedback-target-libsanitizer
+clean-stagefeedback-target-libsanitizer:
+	@if [ $(current_stage) = stagefeedback ]; then \
+	  [ -f $(TARGET_SUBDIR)/libsanitizer/Makefile ] || exit 0; \
+	else \
+	  [ -f $(TARGET_SUBDIR)/stagefeedback-libsanitizer/Makefile ] || exit 0; \
+	  $(MAKE) stagefeedback-start; \
+	fi; \
+	cd $(TARGET_SUBDIR)/libsanitizer && \
+	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   clean
+@endif target-libsanitizer-bootstrap
+
+
+
+
+
+
+.PHONY: check-target-libsanitizer maybe-check-target-libsanitizer
+maybe-check-target-libsanitizer:
+@if target-libsanitizer
+maybe-check-target-libsanitizer: check-target-libsanitizer
+
+check-target-libsanitizer:
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	(cd $(TARGET_SUBDIR)/libsanitizer && \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS)  'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   check)
+
+@endif target-libsanitizer
+
+.PHONY: install-target-libsanitizer maybe-install-target-libsanitizer
+maybe-install-target-libsanitizer:
+@if target-libsanitizer
+maybe-install-target-libsanitizer: install-target-libsanitizer
+
+install-target-libsanitizer: installdirs
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	(cd $(TARGET_SUBDIR)/libsanitizer && \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS)  install)
+
+@endif target-libsanitizer
+
+.PHONY: install-strip-target-libsanitizer maybe-install-strip-target-libsanitizer
+maybe-install-strip-target-libsanitizer:
+@if target-libsanitizer
+maybe-install-strip-target-libsanitizer: install-strip-target-libsanitizer
+
+install-strip-target-libsanitizer: installdirs
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	(cd $(TARGET_SUBDIR)/libsanitizer && \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS)  install-strip)
+
+@endif target-libsanitizer
+
+# Other targets (info, dvi, pdf, etc.)
+
+.PHONY: maybe-info-target-libsanitizer info-target-libsanitizer
+maybe-info-target-libsanitizer:
+@if target-libsanitizer
+maybe-info-target-libsanitizer: info-target-libsanitizer
+
+info-target-libsanitizer: \
+    configure-target-libsanitizer 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libsanitizer/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing info in $(TARGET_SUBDIR)/libsanitizer" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libsanitizer && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           info) \
+	  || exit 1
+
+@endif target-libsanitizer
+
+.PHONY: maybe-dvi-target-libsanitizer dvi-target-libsanitizer
+maybe-dvi-target-libsanitizer:
+@if target-libsanitizer
+maybe-dvi-target-libsanitizer: dvi-target-libsanitizer
+
+dvi-target-libsanitizer: \
+    configure-target-libsanitizer 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libsanitizer/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing dvi in $(TARGET_SUBDIR)/libsanitizer" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libsanitizer && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           dvi) \
+	  || exit 1
+
+@endif target-libsanitizer
+
+.PHONY: maybe-pdf-target-libsanitizer pdf-target-libsanitizer
+maybe-pdf-target-libsanitizer:
+@if target-libsanitizer
+maybe-pdf-target-libsanitizer: pdf-target-libsanitizer
+
+pdf-target-libsanitizer: \
+    configure-target-libsanitizer 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libsanitizer/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing pdf in $(TARGET_SUBDIR)/libsanitizer" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libsanitizer && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           pdf) \
+	  || exit 1
+
+@endif target-libsanitizer
+
+.PHONY: maybe-html-target-libsanitizer html-target-libsanitizer
+maybe-html-target-libsanitizer:
+@if target-libsanitizer
+maybe-html-target-libsanitizer: html-target-libsanitizer
+
+html-target-libsanitizer: \
+    configure-target-libsanitizer 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libsanitizer/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing html in $(TARGET_SUBDIR)/libsanitizer" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libsanitizer && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           html) \
+	  || exit 1
+
+@endif target-libsanitizer
+
+.PHONY: maybe-TAGS-target-libsanitizer TAGS-target-libsanitizer
+maybe-TAGS-target-libsanitizer:
+@if target-libsanitizer
+maybe-TAGS-target-libsanitizer: TAGS-target-libsanitizer
+
+TAGS-target-libsanitizer: \
+    configure-target-libsanitizer 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libsanitizer/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing TAGS in $(TARGET_SUBDIR)/libsanitizer" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libsanitizer && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           TAGS) \
+	  || exit 1
+
+@endif target-libsanitizer
+
+.PHONY: maybe-install-info-target-libsanitizer install-info-target-libsanitizer
+maybe-install-info-target-libsanitizer:
+@if target-libsanitizer
+maybe-install-info-target-libsanitizer: install-info-target-libsanitizer
+
+install-info-target-libsanitizer: \
+    configure-target-libsanitizer \
+    info-target-libsanitizer 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libsanitizer/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing install-info in $(TARGET_SUBDIR)/libsanitizer" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libsanitizer && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           install-info) \
+	  || exit 1
+
+@endif target-libsanitizer
+
+.PHONY: maybe-install-pdf-target-libsanitizer install-pdf-target-libsanitizer
+maybe-install-pdf-target-libsanitizer:
+@if target-libsanitizer
+maybe-install-pdf-target-libsanitizer: install-pdf-target-libsanitizer
+
+install-pdf-target-libsanitizer: \
+    configure-target-libsanitizer \
+    pdf-target-libsanitizer 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libsanitizer/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing install-pdf in $(TARGET_SUBDIR)/libsanitizer" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libsanitizer && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           install-pdf) \
+	  || exit 1
+
+@endif target-libsanitizer
+
+.PHONY: maybe-install-html-target-libsanitizer install-html-target-libsanitizer
+maybe-install-html-target-libsanitizer:
+@if target-libsanitizer
+maybe-install-html-target-libsanitizer: install-html-target-libsanitizer
+
+install-html-target-libsanitizer: \
+    configure-target-libsanitizer \
+    html-target-libsanitizer 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libsanitizer/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing install-html in $(TARGET_SUBDIR)/libsanitizer" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libsanitizer && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           install-html) \
+	  || exit 1
+
+@endif target-libsanitizer
+
+.PHONY: maybe-installcheck-target-libsanitizer installcheck-target-libsanitizer
+maybe-installcheck-target-libsanitizer:
+@if target-libsanitizer
+maybe-installcheck-target-libsanitizer: installcheck-target-libsanitizer
+
+installcheck-target-libsanitizer: \
+    configure-target-libsanitizer 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libsanitizer/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing installcheck in $(TARGET_SUBDIR)/libsanitizer" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libsanitizer && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           installcheck) \
+	  || exit 1
+
+@endif target-libsanitizer
+
+.PHONY: maybe-mostlyclean-target-libsanitizer mostlyclean-target-libsanitizer
+maybe-mostlyclean-target-libsanitizer:
+@if target-libsanitizer
+maybe-mostlyclean-target-libsanitizer: mostlyclean-target-libsanitizer
+
+mostlyclean-target-libsanitizer: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libsanitizer/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing mostlyclean in $(TARGET_SUBDIR)/libsanitizer" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libsanitizer && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           mostlyclean) \
+	  || exit 1
+
+@endif target-libsanitizer
+
+.PHONY: maybe-clean-target-libsanitizer clean-target-libsanitizer
+maybe-clean-target-libsanitizer:
+@if target-libsanitizer
+maybe-clean-target-libsanitizer: clean-target-libsanitizer
+
+clean-target-libsanitizer: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libsanitizer/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing clean in $(TARGET_SUBDIR)/libsanitizer" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libsanitizer && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           clean) \
+	  || exit 1
+
+@endif target-libsanitizer
+
+.PHONY: maybe-distclean-target-libsanitizer distclean-target-libsanitizer
+maybe-distclean-target-libsanitizer:
+@if target-libsanitizer
+maybe-distclean-target-libsanitizer: distclean-target-libsanitizer
+
+distclean-target-libsanitizer: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libsanitizer/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing distclean in $(TARGET_SUBDIR)/libsanitizer" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libsanitizer && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           distclean) \
+	  || exit 1
+
+@endif target-libsanitizer
+
+.PHONY: maybe-maintainer-clean-target-libsanitizer maintainer-clean-target-libsanitizer
+maybe-maintainer-clean-target-libsanitizer:
+@if target-libsanitizer
+maybe-maintainer-clean-target-libsanitizer: maintainer-clean-target-libsanitizer
+
+maintainer-clean-target-libsanitizer: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libsanitizer/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing maintainer-clean in $(TARGET_SUBDIR)/libsanitizer" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libsanitizer && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           maintainer-clean) \
+	  || exit 1
+
+@endif target-libsanitizer
+
+
+
+
+
+.PHONY: configure-target-libvtv maybe-configure-target-libvtv
+maybe-configure-target-libvtv:
+@if gcc-bootstrap
+configure-target-libvtv: stage_current
+@endif gcc-bootstrap
+@if target-libvtv
+maybe-configure-target-libvtv: configure-target-libvtv
+configure-target-libvtv: 
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	echo "Checking multilib configuration for libvtv..."; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libvtv ; \
+	$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libvtv/multilib.tmp 2> /dev/null ; \
+	if test -r $(TARGET_SUBDIR)/libvtv/multilib.out; then \
+	  if cmp -s $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; then \
+	    rm -f $(TARGET_SUBDIR)/libvtv/multilib.tmp; \
+	  else \
+	    rm -f $(TARGET_SUBDIR)/libvtv/Makefile; \
+	    mv $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; \
+	  fi; \
+	else \
+	  mv $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; \
+	fi; \
+	test ! -f $(TARGET_SUBDIR)/libvtv/Makefile || exit 0; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libvtv ; \
+	$(RAW_CXX_TARGET_EXPORTS)  \
+	echo Configuring in $(TARGET_SUBDIR)/libvtv; \
+	cd "$(TARGET_SUBDIR)/libvtv" || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(TARGET_SUBDIR)/libvtv/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libvtv"; \
+	libsrcdir="$$s/libvtv"; \
+	rm -f no-such-file || : ; \
+	CONFIG_SITE=no-such-file $(SHELL) $${libsrcdir}/configure \
+	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+	  --target=${target_alias} $${srcdiroption}  \
+	  || exit 1
+@endif target-libvtv
+
+
+
+.PHONY: configure-stage1-target-libvtv maybe-configure-stage1-target-libvtv
+maybe-configure-stage1-target-libvtv:
+@if target-libvtv-bootstrap
+maybe-configure-stage1-target-libvtv: configure-stage1-target-libvtv
+configure-stage1-target-libvtv:
+	@[ $(current_stage) = stage1 ] || $(MAKE) stage1-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libvtv
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE1_TFLAGS)"; \
+	echo "Checking multilib configuration for libvtv..."; \
+	$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libvtv/multilib.tmp 2> /dev/null ; \
+	if test -r $(TARGET_SUBDIR)/libvtv/multilib.out; then \
+	  if cmp -s $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; then \
+	    rm -f $(TARGET_SUBDIR)/libvtv/multilib.tmp; \
+	  else \
+	    rm -f $(TARGET_SUBDIR)/libvtv/Makefile; \
+	    mv $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; \
+	  fi; \
+	else \
+	  mv $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; \
+	fi; \
+	test ! -f $(TARGET_SUBDIR)/libvtv/Makefile || exit 0; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
+	CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \
+	LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)"; export LIBCFLAGS;  \
+	echo Configuring stage 1 in $(TARGET_SUBDIR)/libvtv ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libvtv ; \
+	cd $(TARGET_SUBDIR)/libvtv || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(TARGET_SUBDIR)/libvtv/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libvtv"; \
+	libsrcdir="$$s/libvtv"; \
+	$(SHELL) $${libsrcdir}/configure \
+	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+	  --target=${target_alias} $${srcdiroption} \
+	  $(STAGE1_CONFIGURE_FLAGS)
+@endif target-libvtv-bootstrap
+
+.PHONY: configure-stage2-target-libvtv maybe-configure-stage2-target-libvtv
+maybe-configure-stage2-target-libvtv:
+@if target-libvtv-bootstrap
+maybe-configure-stage2-target-libvtv: configure-stage2-target-libvtv
+configure-stage2-target-libvtv:
+	@[ $(current_stage) = stage2 ] || $(MAKE) stage2-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libvtv
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE2_TFLAGS)"; \
+	echo "Checking multilib configuration for libvtv..."; \
+	$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libvtv/multilib.tmp 2> /dev/null ; \
+	if test -r $(TARGET_SUBDIR)/libvtv/multilib.out; then \
+	  if cmp -s $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; then \
+	    rm -f $(TARGET_SUBDIR)/libvtv/multilib.tmp; \
+	  else \
+	    rm -f $(TARGET_SUBDIR)/libvtv/Makefile; \
+	    mv $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; \
+	  fi; \
+	else \
+	  mv $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; \
+	fi; \
+	test ! -f $(TARGET_SUBDIR)/libvtv/Makefile || exit 0; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	 \
+	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
+	CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \
+	LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)"; export LIBCFLAGS;  \
+	echo Configuring stage 2 in $(TARGET_SUBDIR)/libvtv ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libvtv ; \
+	cd $(TARGET_SUBDIR)/libvtv || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(TARGET_SUBDIR)/libvtv/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libvtv"; \
+	libsrcdir="$$s/libvtv"; \
+	$(SHELL) $${libsrcdir}/configure \
+	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+	  --target=${target_alias} $${srcdiroption} \
+	  --with-build-libsubdir=$(HOST_SUBDIR) \
+	  $(STAGE2_CONFIGURE_FLAGS)
+@endif target-libvtv-bootstrap
+
+.PHONY: configure-stage3-target-libvtv maybe-configure-stage3-target-libvtv
+maybe-configure-stage3-target-libvtv:
+@if target-libvtv-bootstrap
+maybe-configure-stage3-target-libvtv: configure-stage3-target-libvtv
+configure-stage3-target-libvtv:
+	@[ $(current_stage) = stage3 ] || $(MAKE) stage3-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libvtv
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE3_TFLAGS)"; \
+	echo "Checking multilib configuration for libvtv..."; \
+	$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libvtv/multilib.tmp 2> /dev/null ; \
+	if test -r $(TARGET_SUBDIR)/libvtv/multilib.out; then \
+	  if cmp -s $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; then \
+	    rm -f $(TARGET_SUBDIR)/libvtv/multilib.tmp; \
+	  else \
+	    rm -f $(TARGET_SUBDIR)/libvtv/Makefile; \
+	    mv $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; \
+	  fi; \
+	else \
+	  mv $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; \
+	fi; \
+	test ! -f $(TARGET_SUBDIR)/libvtv/Makefile || exit 0; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	 \
+	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
+	CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \
+	LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)"; export LIBCFLAGS;  \
+	echo Configuring stage 3 in $(TARGET_SUBDIR)/libvtv ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libvtv ; \
+	cd $(TARGET_SUBDIR)/libvtv || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(TARGET_SUBDIR)/libvtv/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libvtv"; \
+	libsrcdir="$$s/libvtv"; \
+	$(SHELL) $${libsrcdir}/configure \
+	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+	  --target=${target_alias} $${srcdiroption} \
+	  --with-build-libsubdir=$(HOST_SUBDIR) \
+	  $(STAGE3_CONFIGURE_FLAGS)
+@endif target-libvtv-bootstrap
+
+.PHONY: configure-stage4-target-libvtv maybe-configure-stage4-target-libvtv
+maybe-configure-stage4-target-libvtv:
+@if target-libvtv-bootstrap
+maybe-configure-stage4-target-libvtv: configure-stage4-target-libvtv
+configure-stage4-target-libvtv:
+	@[ $(current_stage) = stage4 ] || $(MAKE) stage4-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libvtv
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE4_TFLAGS)"; \
+	echo "Checking multilib configuration for libvtv..."; \
+	$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libvtv/multilib.tmp 2> /dev/null ; \
+	if test -r $(TARGET_SUBDIR)/libvtv/multilib.out; then \
+	  if cmp -s $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; then \
+	    rm -f $(TARGET_SUBDIR)/libvtv/multilib.tmp; \
+	  else \
+	    rm -f $(TARGET_SUBDIR)/libvtv/Makefile; \
+	    mv $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; \
+	  fi; \
+	else \
+	  mv $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; \
+	fi; \
+	test ! -f $(TARGET_SUBDIR)/libvtv/Makefile || exit 0; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	 \
+	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
+	CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \
+	LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)"; export LIBCFLAGS;  \
+	echo Configuring stage 4 in $(TARGET_SUBDIR)/libvtv ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libvtv ; \
+	cd $(TARGET_SUBDIR)/libvtv || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(TARGET_SUBDIR)/libvtv/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libvtv"; \
+	libsrcdir="$$s/libvtv"; \
+	$(SHELL) $${libsrcdir}/configure \
+	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+	  --target=${target_alias} $${srcdiroption} \
+	  --with-build-libsubdir=$(HOST_SUBDIR) \
+	  $(STAGE4_CONFIGURE_FLAGS)
+@endif target-libvtv-bootstrap
+
+.PHONY: configure-stageprofile-target-libvtv maybe-configure-stageprofile-target-libvtv
+maybe-configure-stageprofile-target-libvtv:
+@if target-libvtv-bootstrap
+maybe-configure-stageprofile-target-libvtv: configure-stageprofile-target-libvtv
+configure-stageprofile-target-libvtv:
+	@[ $(current_stage) = stageprofile ] || $(MAKE) stageprofile-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libvtv
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGEprofile_TFLAGS)"; \
+	echo "Checking multilib configuration for libvtv..."; \
+	$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libvtv/multilib.tmp 2> /dev/null ; \
+	if test -r $(TARGET_SUBDIR)/libvtv/multilib.out; then \
+	  if cmp -s $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; then \
+	    rm -f $(TARGET_SUBDIR)/libvtv/multilib.tmp; \
+	  else \
+	    rm -f $(TARGET_SUBDIR)/libvtv/Makefile; \
+	    mv $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; \
+	  fi; \
+	else \
+	  mv $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; \
+	fi; \
+	test ! -f $(TARGET_SUBDIR)/libvtv/Makefile || exit 0; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	 \
+	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
+	CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \
+	LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)"; export LIBCFLAGS;  \
+	echo Configuring stage profile in $(TARGET_SUBDIR)/libvtv ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libvtv ; \
+	cd $(TARGET_SUBDIR)/libvtv || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(TARGET_SUBDIR)/libvtv/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libvtv"; \
+	libsrcdir="$$s/libvtv"; \
+	$(SHELL) $${libsrcdir}/configure \
+	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+	  --target=${target_alias} $${srcdiroption} \
+	  --with-build-libsubdir=$(HOST_SUBDIR) \
+	  $(STAGEprofile_CONFIGURE_FLAGS)
+@endif target-libvtv-bootstrap
+
+.PHONY: configure-stagefeedback-target-libvtv maybe-configure-stagefeedback-target-libvtv
+maybe-configure-stagefeedback-target-libvtv:
+@if target-libvtv-bootstrap
+maybe-configure-stagefeedback-target-libvtv: configure-stagefeedback-target-libvtv
+configure-stagefeedback-target-libvtv:
+	@[ $(current_stage) = stagefeedback ] || $(MAKE) stagefeedback-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libvtv
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGEfeedback_TFLAGS)"; \
+	echo "Checking multilib configuration for libvtv..."; \
+	$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libvtv/multilib.tmp 2> /dev/null ; \
+	if test -r $(TARGET_SUBDIR)/libvtv/multilib.out; then \
+	  if cmp -s $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; then \
+	    rm -f $(TARGET_SUBDIR)/libvtv/multilib.tmp; \
+	  else \
+	    rm -f $(TARGET_SUBDIR)/libvtv/Makefile; \
+	    mv $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; \
+	  fi; \
+	else \
+	  mv $(TARGET_SUBDIR)/libvtv/multilib.tmp $(TARGET_SUBDIR)/libvtv/multilib.out; \
+	fi; \
+	test ! -f $(TARGET_SUBDIR)/libvtv/Makefile || exit 0; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	 \
+	CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
+	CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \
+	LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)"; export LIBCFLAGS;  \
+	echo Configuring stage feedback in $(TARGET_SUBDIR)/libvtv ; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libvtv ; \
+	cd $(TARGET_SUBDIR)/libvtv || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(TARGET_SUBDIR)/libvtv/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libvtv"; \
+	libsrcdir="$$s/libvtv"; \
+	$(SHELL) $${libsrcdir}/configure \
+	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+	  --target=${target_alias} $${srcdiroption} \
+	  --with-build-libsubdir=$(HOST_SUBDIR) \
+	  $(STAGEfeedback_CONFIGURE_FLAGS)
+@endif target-libvtv-bootstrap
+
+
+
+
+
+.PHONY: all-target-libvtv maybe-all-target-libvtv
+maybe-all-target-libvtv:
+@if gcc-bootstrap
+all-target-libvtv: stage_current
+@endif gcc-bootstrap
+@if target-libvtv
+TARGET-target-libvtv=all
+maybe-all-target-libvtv: all-target-libvtv
+all-target-libvtv: configure-target-libvtv
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS)  \
+	(cd $(TARGET_SUBDIR)/libvtv && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   \
+		$(TARGET-target-libvtv))
+@endif target-libvtv
+
+
+
+.PHONY: all-stage1-target-libvtv maybe-all-stage1-target-libvtv
+.PHONY: clean-stage1-target-libvtv maybe-clean-stage1-target-libvtv
+maybe-all-stage1-target-libvtv:
+maybe-clean-stage1-target-libvtv:
+@if target-libvtv-bootstrap
+maybe-all-stage1-target-libvtv: all-stage1-target-libvtv
+all-stage1: all-stage1-target-libvtv
+TARGET-stage1-target-libvtv = $(TARGET-target-libvtv)
+all-stage1-target-libvtv: configure-stage1-target-libvtv
+	@[ $(current_stage) = stage1 ] || $(MAKE) stage1-start
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE1_TFLAGS)"; \
+	$(RAW_CXX_TARGET_EXPORTS)  \
+	cd $(TARGET_SUBDIR)/libvtv && \
+	$(MAKE) $(BASE_FLAGS_TO_PASS) \
+		CFLAGS="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)" \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		$(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'  \
+		  \
+		TFLAGS="$(STAGE1_TFLAGS)" \
+		$(TARGET-stage1-target-libvtv)
+
+maybe-clean-stage1-target-libvtv: clean-stage1-target-libvtv
+clean-stage1: clean-stage1-target-libvtv
+clean-stage1-target-libvtv:
+	@if [ $(current_stage) = stage1 ]; then \
+	  [ -f $(TARGET_SUBDIR)/libvtv/Makefile ] || exit 0; \
+	else \
+	  [ -f $(TARGET_SUBDIR)/stage1-libvtv/Makefile ] || exit 0; \
+	  $(MAKE) stage1-start; \
+	fi; \
+	cd $(TARGET_SUBDIR)/libvtv && \
+	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'  \
+	  clean
+@endif target-libvtv-bootstrap
+
+
+.PHONY: all-stage2-target-libvtv maybe-all-stage2-target-libvtv
+.PHONY: clean-stage2-target-libvtv maybe-clean-stage2-target-libvtv
+maybe-all-stage2-target-libvtv:
+maybe-clean-stage2-target-libvtv:
+@if target-libvtv-bootstrap
+maybe-all-stage2-target-libvtv: all-stage2-target-libvtv
+all-stage2: all-stage2-target-libvtv
+TARGET-stage2-target-libvtv = $(TARGET-target-libvtv)
+all-stage2-target-libvtv: configure-stage2-target-libvtv
+	@[ $(current_stage) = stage2 ] || $(MAKE) stage2-start
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE2_TFLAGS)"; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	  \
+	cd $(TARGET_SUBDIR)/libvtv && \
+	$(MAKE) $(BASE_FLAGS_TO_PASS) \
+		CFLAGS="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)" \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		$(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   \
+		TFLAGS="$(STAGE2_TFLAGS)" \
+		$(TARGET-stage2-target-libvtv)
+
+maybe-clean-stage2-target-libvtv: clean-stage2-target-libvtv
+clean-stage2: clean-stage2-target-libvtv
+clean-stage2-target-libvtv:
+	@if [ $(current_stage) = stage2 ]; then \
+	  [ -f $(TARGET_SUBDIR)/libvtv/Makefile ] || exit 0; \
+	else \
+	  [ -f $(TARGET_SUBDIR)/stage2-libvtv/Makefile ] || exit 0; \
+	  $(MAKE) stage2-start; \
+	fi; \
+	cd $(TARGET_SUBDIR)/libvtv && \
+	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   clean
+@endif target-libvtv-bootstrap
+
+
+.PHONY: all-stage3-target-libvtv maybe-all-stage3-target-libvtv
+.PHONY: clean-stage3-target-libvtv maybe-clean-stage3-target-libvtv
+maybe-all-stage3-target-libvtv:
+maybe-clean-stage3-target-libvtv:
+@if target-libvtv-bootstrap
+maybe-all-stage3-target-libvtv: all-stage3-target-libvtv
+all-stage3: all-stage3-target-libvtv
+TARGET-stage3-target-libvtv = $(TARGET-target-libvtv)
+all-stage3-target-libvtv: configure-stage3-target-libvtv
+	@[ $(current_stage) = stage3 ] || $(MAKE) stage3-start
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE3_TFLAGS)"; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	  \
+	cd $(TARGET_SUBDIR)/libvtv && \
+	$(MAKE) $(BASE_FLAGS_TO_PASS) \
+		CFLAGS="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)" \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		$(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   \
+		TFLAGS="$(STAGE3_TFLAGS)" \
+		$(TARGET-stage3-target-libvtv)
+
+maybe-clean-stage3-target-libvtv: clean-stage3-target-libvtv
+clean-stage3: clean-stage3-target-libvtv
+clean-stage3-target-libvtv:
+	@if [ $(current_stage) = stage3 ]; then \
+	  [ -f $(TARGET_SUBDIR)/libvtv/Makefile ] || exit 0; \
+	else \
+	  [ -f $(TARGET_SUBDIR)/stage3-libvtv/Makefile ] || exit 0; \
+	  $(MAKE) stage3-start; \
+	fi; \
+	cd $(TARGET_SUBDIR)/libvtv && \
+	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   clean
+@endif target-libvtv-bootstrap
+
+
+.PHONY: all-stage4-target-libvtv maybe-all-stage4-target-libvtv
+.PHONY: clean-stage4-target-libvtv maybe-clean-stage4-target-libvtv
+maybe-all-stage4-target-libvtv:
+maybe-clean-stage4-target-libvtv:
+@if target-libvtv-bootstrap
+maybe-all-stage4-target-libvtv: all-stage4-target-libvtv
+all-stage4: all-stage4-target-libvtv
+TARGET-stage4-target-libvtv = $(TARGET-target-libvtv)
+all-stage4-target-libvtv: configure-stage4-target-libvtv
+	@[ $(current_stage) = stage4 ] || $(MAKE) stage4-start
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE4_TFLAGS)"; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	  \
+	cd $(TARGET_SUBDIR)/libvtv && \
+	$(MAKE) $(BASE_FLAGS_TO_PASS) \
+		CFLAGS="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)" \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		$(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   \
+		TFLAGS="$(STAGE4_TFLAGS)" \
+		$(TARGET-stage4-target-libvtv)
+
+maybe-clean-stage4-target-libvtv: clean-stage4-target-libvtv
+clean-stage4: clean-stage4-target-libvtv
+clean-stage4-target-libvtv:
+	@if [ $(current_stage) = stage4 ]; then \
+	  [ -f $(TARGET_SUBDIR)/libvtv/Makefile ] || exit 0; \
+	else \
+	  [ -f $(TARGET_SUBDIR)/stage4-libvtv/Makefile ] || exit 0; \
+	  $(MAKE) stage4-start; \
+	fi; \
+	cd $(TARGET_SUBDIR)/libvtv && \
+	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   clean
+@endif target-libvtv-bootstrap
+
+
+.PHONY: all-stageprofile-target-libvtv maybe-all-stageprofile-target-libvtv
+.PHONY: clean-stageprofile-target-libvtv maybe-clean-stageprofile-target-libvtv
+maybe-all-stageprofile-target-libvtv:
+maybe-clean-stageprofile-target-libvtv:
+@if target-libvtv-bootstrap
+maybe-all-stageprofile-target-libvtv: all-stageprofile-target-libvtv
+all-stageprofile: all-stageprofile-target-libvtv
+TARGET-stageprofile-target-libvtv = $(TARGET-target-libvtv)
+all-stageprofile-target-libvtv: configure-stageprofile-target-libvtv
+	@[ $(current_stage) = stageprofile ] || $(MAKE) stageprofile-start
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGEprofile_TFLAGS)"; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	  \
+	cd $(TARGET_SUBDIR)/libvtv && \
+	$(MAKE) $(BASE_FLAGS_TO_PASS) \
+		CFLAGS="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)" \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		$(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   \
+		TFLAGS="$(STAGEprofile_TFLAGS)" \
+		$(TARGET-stageprofile-target-libvtv)
+
+maybe-clean-stageprofile-target-libvtv: clean-stageprofile-target-libvtv
+clean-stageprofile: clean-stageprofile-target-libvtv
+clean-stageprofile-target-libvtv:
+	@if [ $(current_stage) = stageprofile ]; then \
+	  [ -f $(TARGET_SUBDIR)/libvtv/Makefile ] || exit 0; \
+	else \
+	  [ -f $(TARGET_SUBDIR)/stageprofile-libvtv/Makefile ] || exit 0; \
+	  $(MAKE) stageprofile-start; \
+	fi; \
+	cd $(TARGET_SUBDIR)/libvtv && \
+	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   clean
+@endif target-libvtv-bootstrap
+
+
+.PHONY: all-stagefeedback-target-libvtv maybe-all-stagefeedback-target-libvtv
+.PHONY: clean-stagefeedback-target-libvtv maybe-clean-stagefeedback-target-libvtv
+maybe-all-stagefeedback-target-libvtv:
+maybe-clean-stagefeedback-target-libvtv:
+@if target-libvtv-bootstrap
+maybe-all-stagefeedback-target-libvtv: all-stagefeedback-target-libvtv
+all-stagefeedback: all-stagefeedback-target-libvtv
+TARGET-stagefeedback-target-libvtv = $(TARGET-target-libvtv)
+all-stagefeedback-target-libvtv: configure-stagefeedback-target-libvtv
+	@[ $(current_stage) = stagefeedback ] || $(MAKE) stagefeedback-start
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGEfeedback_TFLAGS)"; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	  \
+	cd $(TARGET_SUBDIR)/libvtv && \
+	$(MAKE) $(BASE_FLAGS_TO_PASS) \
+		CFLAGS="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS="$(LIBCFLAGS_FOR_TARGET)" \
+		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
+		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
+		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
+		$(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   \
+		TFLAGS="$(STAGEfeedback_TFLAGS)" \
+		$(TARGET-stagefeedback-target-libvtv)
+
+maybe-clean-stagefeedback-target-libvtv: clean-stagefeedback-target-libvtv
+clean-stagefeedback: clean-stagefeedback-target-libvtv
+clean-stagefeedback-target-libvtv:
+	@if [ $(current_stage) = stagefeedback ]; then \
+	  [ -f $(TARGET_SUBDIR)/libvtv/Makefile ] || exit 0; \
+	else \
+	  [ -f $(TARGET_SUBDIR)/stagefeedback-libvtv/Makefile ] || exit 0; \
+	  $(MAKE) stagefeedback-start; \
+	fi; \
+	cd $(TARGET_SUBDIR)/libvtv && \
+	$(MAKE) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   clean
+@endif target-libvtv-bootstrap
+
+
+
+
+
+
+.PHONY: check-target-libvtv maybe-check-target-libvtv
+maybe-check-target-libvtv:
+@if target-libvtv
+maybe-check-target-libvtv: check-target-libvtv
+
+check-target-libvtv:
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	(cd $(TARGET_SUBDIR)/libvtv && \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS)  'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   check)
+
+@endif target-libvtv
+
+.PHONY: install-target-libvtv maybe-install-target-libvtv
+maybe-install-target-libvtv:
+@if target-libvtv
+maybe-install-target-libvtv: install-target-libvtv
+
+install-target-libvtv: installdirs
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	(cd $(TARGET_SUBDIR)/libvtv && \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS)  install)
+
+@endif target-libvtv
+
+.PHONY: install-strip-target-libvtv maybe-install-strip-target-libvtv
+maybe-install-strip-target-libvtv:
+@if target-libvtv
+maybe-install-strip-target-libvtv: install-strip-target-libvtv
+
+install-strip-target-libvtv: installdirs
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	(cd $(TARGET_SUBDIR)/libvtv && \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS)  install-strip)
+
+@endif target-libvtv
+
+# Other targets (info, dvi, pdf, etc.)
+
+.PHONY: maybe-info-target-libvtv info-target-libvtv
+maybe-info-target-libvtv:
+@if target-libvtv
+maybe-info-target-libvtv: info-target-libvtv
+
+info-target-libvtv: \
+    configure-target-libvtv 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libvtv/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing info in $(TARGET_SUBDIR)/libvtv" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libvtv && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           info) \
+	  || exit 1
+
+@endif target-libvtv
+
+.PHONY: maybe-dvi-target-libvtv dvi-target-libvtv
+maybe-dvi-target-libvtv:
+@if target-libvtv
+maybe-dvi-target-libvtv: dvi-target-libvtv
+
+dvi-target-libvtv: \
+    configure-target-libvtv 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libvtv/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing dvi in $(TARGET_SUBDIR)/libvtv" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libvtv && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           dvi) \
+	  || exit 1
+
+@endif target-libvtv
+
+.PHONY: maybe-pdf-target-libvtv pdf-target-libvtv
+maybe-pdf-target-libvtv:
+@if target-libvtv
+maybe-pdf-target-libvtv: pdf-target-libvtv
+
+pdf-target-libvtv: \
+    configure-target-libvtv 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libvtv/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing pdf in $(TARGET_SUBDIR)/libvtv" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libvtv && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           pdf) \
+	  || exit 1
+
+@endif target-libvtv
+
+.PHONY: maybe-html-target-libvtv html-target-libvtv
+maybe-html-target-libvtv:
+@if target-libvtv
+maybe-html-target-libvtv: html-target-libvtv
+
+html-target-libvtv: \
+    configure-target-libvtv 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libvtv/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing html in $(TARGET_SUBDIR)/libvtv" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libvtv && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           html) \
+	  || exit 1
+
+@endif target-libvtv
+
+.PHONY: maybe-TAGS-target-libvtv TAGS-target-libvtv
+maybe-TAGS-target-libvtv:
+@if target-libvtv
+maybe-TAGS-target-libvtv: TAGS-target-libvtv
+
+TAGS-target-libvtv: \
+    configure-target-libvtv 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libvtv/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing TAGS in $(TARGET_SUBDIR)/libvtv" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libvtv && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           TAGS) \
+	  || exit 1
+
+@endif target-libvtv
+
+.PHONY: maybe-install-info-target-libvtv install-info-target-libvtv
+maybe-install-info-target-libvtv:
+@if target-libvtv
+maybe-install-info-target-libvtv: install-info-target-libvtv
+
+install-info-target-libvtv: \
+    configure-target-libvtv \
+    info-target-libvtv 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libvtv/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing install-info in $(TARGET_SUBDIR)/libvtv" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libvtv && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           install-info) \
+	  || exit 1
+
+@endif target-libvtv
+
+.PHONY: maybe-install-pdf-target-libvtv install-pdf-target-libvtv
+maybe-install-pdf-target-libvtv:
+@if target-libvtv
+maybe-install-pdf-target-libvtv: install-pdf-target-libvtv
+
+install-pdf-target-libvtv: \
+    configure-target-libvtv \
+    pdf-target-libvtv 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libvtv/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing install-pdf in $(TARGET_SUBDIR)/libvtv" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libvtv && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           install-pdf) \
+	  || exit 1
+
+@endif target-libvtv
+
+.PHONY: maybe-install-html-target-libvtv install-html-target-libvtv
+maybe-install-html-target-libvtv:
+@if target-libvtv
+maybe-install-html-target-libvtv: install-html-target-libvtv
+
+install-html-target-libvtv: \
+    configure-target-libvtv \
+    html-target-libvtv 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libvtv/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing install-html in $(TARGET_SUBDIR)/libvtv" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libvtv && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           install-html) \
+	  || exit 1
+
+@endif target-libvtv
+
+.PHONY: maybe-installcheck-target-libvtv installcheck-target-libvtv
+maybe-installcheck-target-libvtv:
+@if target-libvtv
+maybe-installcheck-target-libvtv: installcheck-target-libvtv
+
+installcheck-target-libvtv: \
+    configure-target-libvtv 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libvtv/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing installcheck in $(TARGET_SUBDIR)/libvtv" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libvtv && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           installcheck) \
+	  || exit 1
+
+@endif target-libvtv
+
+.PHONY: maybe-mostlyclean-target-libvtv mostlyclean-target-libvtv
+maybe-mostlyclean-target-libvtv:
+@if target-libvtv
+maybe-mostlyclean-target-libvtv: mostlyclean-target-libvtv
+
+mostlyclean-target-libvtv: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libvtv/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing mostlyclean in $(TARGET_SUBDIR)/libvtv" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libvtv && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           mostlyclean) \
+	  || exit 1
+
+@endif target-libvtv
+
+.PHONY: maybe-clean-target-libvtv clean-target-libvtv
+maybe-clean-target-libvtv:
+@if target-libvtv
+maybe-clean-target-libvtv: clean-target-libvtv
+
+clean-target-libvtv: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libvtv/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing clean in $(TARGET_SUBDIR)/libvtv" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libvtv && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           clean) \
+	  || exit 1
+
+@endif target-libvtv
+
+.PHONY: maybe-distclean-target-libvtv distclean-target-libvtv
+maybe-distclean-target-libvtv:
+@if target-libvtv
+maybe-distclean-target-libvtv: distclean-target-libvtv
+
+distclean-target-libvtv: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libvtv/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing distclean in $(TARGET_SUBDIR)/libvtv" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libvtv && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           distclean) \
+	  || exit 1
+
+@endif target-libvtv
+
+.PHONY: maybe-maintainer-clean-target-libvtv maintainer-clean-target-libvtv
+maybe-maintainer-clean-target-libvtv:
+@if target-libvtv
+maybe-maintainer-clean-target-libvtv: maintainer-clean-target-libvtv
+
+maintainer-clean-target-libvtv: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libvtv/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(RAW_CXX_TARGET_EXPORTS) \
+	echo "Doing maintainer-clean in $(TARGET_SUBDIR)/libvtv" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libvtv && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           maintainer-clean) \
+	  || exit 1
+
+@endif target-libvtv
+
+
+
+
+
 .PHONY: configure-target-libssp maybe-configure-target-libssp
 maybe-configure-target-libssp:
 @if gcc-bootstrap
@@ -31452,7 +34211,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(NORMAL_TARGET_EXPORTS)  \
 	(cd $(TARGET_SUBDIR)/libssp && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
 		$(TARGET-target-libssp))
 @endif target-libssp
 
@@ -31909,7 +34668,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(NORMAL_TARGET_EXPORTS)  \
 	(cd $(TARGET_SUBDIR)/newlib && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
 		$(TARGET-target-newlib))
 @endif target-newlib
 
@@ -32634,7 +35393,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(NORMAL_TARGET_EXPORTS)  \
 	(cd $(TARGET_SUBDIR)/libgcc && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
 		$(TARGET-target-libgcc))
 @endif target-libgcc
 
@@ -32662,7 +35421,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_TARGET_FLAGS)   \
+		$(EXTRA_TARGET_FLAGS)  \
+		  \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-target-libgcc)
 
@@ -32677,7 +35437,7 @@
 	fi; \
 	cd $(TARGET_SUBDIR)/libgcc && \
 	$(MAKE) $(EXTRA_TARGET_FLAGS)  \
-		 clean
+	  clean
 @endif target-libgcc-bootstrap
 
 
@@ -32718,9 +35478,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(TARGET_SUBDIR)/libgcc && \
-	$(MAKE) $(EXTRA_TARGET_FLAGS)  \
-		  \
-		 clean
+	$(MAKE) $(EXTRA_TARGET_FLAGS)   clean
 @endif target-libgcc-bootstrap
 
 
@@ -32761,9 +35519,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(TARGET_SUBDIR)/libgcc && \
-	$(MAKE) $(EXTRA_TARGET_FLAGS)  \
-		  \
-		 clean
+	$(MAKE) $(EXTRA_TARGET_FLAGS)   clean
 @endif target-libgcc-bootstrap
 
 
@@ -32804,9 +35560,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(TARGET_SUBDIR)/libgcc && \
-	$(MAKE) $(EXTRA_TARGET_FLAGS)  \
-		  \
-		 clean
+	$(MAKE) $(EXTRA_TARGET_FLAGS)   clean
 @endif target-libgcc-bootstrap
 
 
@@ -32847,9 +35601,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(TARGET_SUBDIR)/libgcc && \
-	$(MAKE) $(EXTRA_TARGET_FLAGS)  \
-		  \
-		 clean
+	$(MAKE) $(EXTRA_TARGET_FLAGS)   clean
 @endif target-libgcc-bootstrap
 
 
@@ -32890,9 +35642,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(TARGET_SUBDIR)/libgcc && \
-	$(MAKE) $(EXTRA_TARGET_FLAGS)  \
-		  \
-		 clean
+	$(MAKE) $(EXTRA_TARGET_FLAGS)   clean
 @endif target-libgcc-bootstrap
 
 
@@ -33283,6 +36033,463 @@
 
 
 
+.PHONY: configure-target-libbacktrace maybe-configure-target-libbacktrace
+maybe-configure-target-libbacktrace:
+@if gcc-bootstrap
+configure-target-libbacktrace: stage_current
+@endif gcc-bootstrap
+@if target-libbacktrace
+maybe-configure-target-libbacktrace: configure-target-libbacktrace
+configure-target-libbacktrace: 
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	echo "Checking multilib configuration for libbacktrace..."; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libbacktrace ; \
+	$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libbacktrace/multilib.tmp 2> /dev/null ; \
+	if test -r $(TARGET_SUBDIR)/libbacktrace/multilib.out; then \
+	  if cmp -s $(TARGET_SUBDIR)/libbacktrace/multilib.tmp $(TARGET_SUBDIR)/libbacktrace/multilib.out; then \
+	    rm -f $(TARGET_SUBDIR)/libbacktrace/multilib.tmp; \
+	  else \
+	    rm -f $(TARGET_SUBDIR)/libbacktrace/Makefile; \
+	    mv $(TARGET_SUBDIR)/libbacktrace/multilib.tmp $(TARGET_SUBDIR)/libbacktrace/multilib.out; \
+	  fi; \
+	else \
+	  mv $(TARGET_SUBDIR)/libbacktrace/multilib.tmp $(TARGET_SUBDIR)/libbacktrace/multilib.out; \
+	fi; \
+	test ! -f $(TARGET_SUBDIR)/libbacktrace/Makefile || exit 0; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libbacktrace ; \
+	$(NORMAL_TARGET_EXPORTS)  \
+	echo Configuring in $(TARGET_SUBDIR)/libbacktrace; \
+	cd "$(TARGET_SUBDIR)/libbacktrace" || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(TARGET_SUBDIR)/libbacktrace/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libbacktrace"; \
+	libsrcdir="$$s/libbacktrace"; \
+	rm -f no-such-file || : ; \
+	CONFIG_SITE=no-such-file $(SHELL) $${libsrcdir}/configure \
+	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+	  --target=${target_alias} $${srcdiroption}  \
+	  || exit 1
+@endif target-libbacktrace
+
+
+
+
+
+.PHONY: all-target-libbacktrace maybe-all-target-libbacktrace
+maybe-all-target-libbacktrace:
+@if gcc-bootstrap
+all-target-libbacktrace: stage_current
+@endif gcc-bootstrap
+@if target-libbacktrace
+TARGET-target-libbacktrace=all
+maybe-all-target-libbacktrace: all-target-libbacktrace
+all-target-libbacktrace: configure-target-libbacktrace
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS)  \
+	(cd $(TARGET_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
+		$(TARGET-target-libbacktrace))
+@endif target-libbacktrace
+
+
+
+
+
+.PHONY: check-target-libbacktrace maybe-check-target-libbacktrace
+maybe-check-target-libbacktrace:
+@if target-libbacktrace
+maybe-check-target-libbacktrace: check-target-libbacktrace
+
+check-target-libbacktrace:
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	(cd $(TARGET_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS)   check)
+
+@endif target-libbacktrace
+
+.PHONY: install-target-libbacktrace maybe-install-target-libbacktrace
+maybe-install-target-libbacktrace:
+@if target-libbacktrace
+maybe-install-target-libbacktrace: install-target-libbacktrace
+
+install-target-libbacktrace: installdirs
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	(cd $(TARGET_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS)  install)
+
+@endif target-libbacktrace
+
+.PHONY: install-strip-target-libbacktrace maybe-install-strip-target-libbacktrace
+maybe-install-strip-target-libbacktrace:
+@if target-libbacktrace
+maybe-install-strip-target-libbacktrace: install-strip-target-libbacktrace
+
+install-strip-target-libbacktrace: installdirs
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	(cd $(TARGET_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS)  install-strip)
+
+@endif target-libbacktrace
+
+# Other targets (info, dvi, pdf, etc.)
+
+.PHONY: maybe-info-target-libbacktrace info-target-libbacktrace
+maybe-info-target-libbacktrace:
+@if target-libbacktrace
+maybe-info-target-libbacktrace: info-target-libbacktrace
+
+info-target-libbacktrace: \
+    configure-target-libbacktrace 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libbacktrace/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing info in $(TARGET_SUBDIR)/libbacktrace" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           info) \
+	  || exit 1
+
+@endif target-libbacktrace
+
+.PHONY: maybe-dvi-target-libbacktrace dvi-target-libbacktrace
+maybe-dvi-target-libbacktrace:
+@if target-libbacktrace
+maybe-dvi-target-libbacktrace: dvi-target-libbacktrace
+
+dvi-target-libbacktrace: \
+    configure-target-libbacktrace 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libbacktrace/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing dvi in $(TARGET_SUBDIR)/libbacktrace" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           dvi) \
+	  || exit 1
+
+@endif target-libbacktrace
+
+.PHONY: maybe-pdf-target-libbacktrace pdf-target-libbacktrace
+maybe-pdf-target-libbacktrace:
+@if target-libbacktrace
+maybe-pdf-target-libbacktrace: pdf-target-libbacktrace
+
+pdf-target-libbacktrace: \
+    configure-target-libbacktrace 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libbacktrace/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing pdf in $(TARGET_SUBDIR)/libbacktrace" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           pdf) \
+	  || exit 1
+
+@endif target-libbacktrace
+
+.PHONY: maybe-html-target-libbacktrace html-target-libbacktrace
+maybe-html-target-libbacktrace:
+@if target-libbacktrace
+maybe-html-target-libbacktrace: html-target-libbacktrace
+
+html-target-libbacktrace: \
+    configure-target-libbacktrace 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libbacktrace/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing html in $(TARGET_SUBDIR)/libbacktrace" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           html) \
+	  || exit 1
+
+@endif target-libbacktrace
+
+.PHONY: maybe-TAGS-target-libbacktrace TAGS-target-libbacktrace
+maybe-TAGS-target-libbacktrace:
+@if target-libbacktrace
+maybe-TAGS-target-libbacktrace: TAGS-target-libbacktrace
+
+TAGS-target-libbacktrace: \
+    configure-target-libbacktrace 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libbacktrace/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing TAGS in $(TARGET_SUBDIR)/libbacktrace" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           TAGS) \
+	  || exit 1
+
+@endif target-libbacktrace
+
+.PHONY: maybe-install-info-target-libbacktrace install-info-target-libbacktrace
+maybe-install-info-target-libbacktrace:
+@if target-libbacktrace
+maybe-install-info-target-libbacktrace: install-info-target-libbacktrace
+
+install-info-target-libbacktrace: \
+    configure-target-libbacktrace \
+    info-target-libbacktrace 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libbacktrace/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing install-info in $(TARGET_SUBDIR)/libbacktrace" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           install-info) \
+	  || exit 1
+
+@endif target-libbacktrace
+
+.PHONY: maybe-install-pdf-target-libbacktrace install-pdf-target-libbacktrace
+maybe-install-pdf-target-libbacktrace:
+@if target-libbacktrace
+maybe-install-pdf-target-libbacktrace: install-pdf-target-libbacktrace
+
+install-pdf-target-libbacktrace: \
+    configure-target-libbacktrace \
+    pdf-target-libbacktrace 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libbacktrace/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing install-pdf in $(TARGET_SUBDIR)/libbacktrace" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           install-pdf) \
+	  || exit 1
+
+@endif target-libbacktrace
+
+.PHONY: maybe-install-html-target-libbacktrace install-html-target-libbacktrace
+maybe-install-html-target-libbacktrace:
+@if target-libbacktrace
+maybe-install-html-target-libbacktrace: install-html-target-libbacktrace
+
+install-html-target-libbacktrace: \
+    configure-target-libbacktrace \
+    html-target-libbacktrace 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libbacktrace/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing install-html in $(TARGET_SUBDIR)/libbacktrace" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           install-html) \
+	  || exit 1
+
+@endif target-libbacktrace
+
+.PHONY: maybe-installcheck-target-libbacktrace installcheck-target-libbacktrace
+maybe-installcheck-target-libbacktrace:
+@if target-libbacktrace
+maybe-installcheck-target-libbacktrace: installcheck-target-libbacktrace
+
+installcheck-target-libbacktrace: \
+    configure-target-libbacktrace 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libbacktrace/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing installcheck in $(TARGET_SUBDIR)/libbacktrace" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           installcheck) \
+	  || exit 1
+
+@endif target-libbacktrace
+
+.PHONY: maybe-mostlyclean-target-libbacktrace mostlyclean-target-libbacktrace
+maybe-mostlyclean-target-libbacktrace:
+@if target-libbacktrace
+maybe-mostlyclean-target-libbacktrace: mostlyclean-target-libbacktrace
+
+mostlyclean-target-libbacktrace: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libbacktrace/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing mostlyclean in $(TARGET_SUBDIR)/libbacktrace" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           mostlyclean) \
+	  || exit 1
+
+@endif target-libbacktrace
+
+.PHONY: maybe-clean-target-libbacktrace clean-target-libbacktrace
+maybe-clean-target-libbacktrace:
+@if target-libbacktrace
+maybe-clean-target-libbacktrace: clean-target-libbacktrace
+
+clean-target-libbacktrace: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libbacktrace/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing clean in $(TARGET_SUBDIR)/libbacktrace" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           clean) \
+	  || exit 1
+
+@endif target-libbacktrace
+
+.PHONY: maybe-distclean-target-libbacktrace distclean-target-libbacktrace
+maybe-distclean-target-libbacktrace:
+@if target-libbacktrace
+maybe-distclean-target-libbacktrace: distclean-target-libbacktrace
+
+distclean-target-libbacktrace: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libbacktrace/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing distclean in $(TARGET_SUBDIR)/libbacktrace" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           distclean) \
+	  || exit 1
+
+@endif target-libbacktrace
+
+.PHONY: maybe-maintainer-clean-target-libbacktrace maintainer-clean-target-libbacktrace
+maybe-maintainer-clean-target-libbacktrace:
+@if target-libbacktrace
+maybe-maintainer-clean-target-libbacktrace: maintainer-clean-target-libbacktrace
+
+maintainer-clean-target-libbacktrace: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libbacktrace/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing maintainer-clean in $(TARGET_SUBDIR)/libbacktrace" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libbacktrace && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           maintainer-clean) \
+	  || exit 1
+
+@endif target-libbacktrace
+
+
+
+
+
 .PHONY: configure-target-libquadmath maybe-configure-target-libquadmath
 maybe-configure-target-libquadmath:
 @if gcc-bootstrap
@@ -33344,7 +36551,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(NORMAL_TARGET_EXPORTS)  \
 	(cd $(TARGET_SUBDIR)/libquadmath && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
 		$(TARGET-target-libquadmath))
 @endif target-libquadmath
 
@@ -33801,7 +37008,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(NORMAL_TARGET_EXPORTS)  \
 	(cd $(TARGET_SUBDIR)/libgfortran && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
 		$(TARGET-target-libgfortran))
 @endif target-libgfortran
 
@@ -34258,7 +37465,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(NORMAL_TARGET_EXPORTS)  \
 	(cd $(TARGET_SUBDIR)/libobjc && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
 		$(TARGET-target-libobjc))
 @endif target-libobjc
 
@@ -34715,7 +37922,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(NORMAL_TARGET_EXPORTS)  \
 	(cd $(TARGET_SUBDIR)/libgo && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
 		$(TARGET-target-libgo))
 @endif target-libgo
 
@@ -35172,7 +38379,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(NORMAL_TARGET_EXPORTS)  \
 	(cd $(TARGET_SUBDIR)/libtermcap && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
 		$(TARGET-target-libtermcap))
 @endif target-libtermcap
 
@@ -35564,7 +38771,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(NORMAL_TARGET_EXPORTS)  \
 	(cd $(TARGET_SUBDIR)/winsup && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
 		$(TARGET-target-winsup))
 @endif target-winsup
 
@@ -36021,7 +39228,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(NORMAL_TARGET_EXPORTS)  \
 	(cd $(TARGET_SUBDIR)/libgloss && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
 		$(TARGET-target-libgloss))
 @endif target-libgloss
 
@@ -36473,7 +39680,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(NORMAL_TARGET_EXPORTS)  \
 	(cd $(TARGET_SUBDIR)/libffi && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
 		$(TARGET-target-libffi))
 @endif target-libffi
 
@@ -36501,13 +39708,8 @@
 @if target-libffi
 maybe-install-target-libffi: install-target-libffi
 
-install-target-libffi: installdirs
-	@: $(MAKE); $(unstage)
-	@r=`${PWD_COMMAND}`; export r; \
-	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(NORMAL_TARGET_EXPORTS) \
-	(cd $(TARGET_SUBDIR)/libffi && \
-	  $(MAKE) $(TARGET_FLAGS_TO_PASS)  install)
+# Dummy target for uninstallable.
+install-target-libffi:
 
 @endif target-libffi
 
@@ -36516,13 +39718,8 @@
 @if target-libffi
 maybe-install-strip-target-libffi: install-strip-target-libffi
 
-install-strip-target-libffi: installdirs
-	@: $(MAKE); $(unstage)
-	@r=`${PWD_COMMAND}`; export r; \
-	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-	$(NORMAL_TARGET_EXPORTS) \
-	(cd $(TARGET_SUBDIR)/libffi && \
-	  $(MAKE) $(TARGET_FLAGS_TO_PASS)  install-strip)
+# Dummy target for uninstallable.
+install-strip-target-libffi:
 
 @endif target-libffi
 
@@ -36930,7 +40127,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(RAW_CXX_TARGET_EXPORTS)  \
 	(cd $(TARGET_SUBDIR)/libjava && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS) 'CXX=$$(RAW_CXX_FOR_TARGET)' 'CXX_FOR_TARGET=$$(RAW_CXX_FOR_TARGET)'   \
 		$(TARGET-target-libjava))
 @endif target-libjava
 
@@ -37387,7 +40584,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(NORMAL_TARGET_EXPORTS)  \
 	(cd $(TARGET_SUBDIR)/zlib && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
 		$(TARGET-target-zlib))
 @endif target-zlib
 
@@ -37844,7 +41041,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(NORMAL_TARGET_EXPORTS)  \
 	(cd $(TARGET_SUBDIR)/boehm-gc && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
 		$(TARGET-target-boehm-gc))
 @endif target-boehm-gc
 
@@ -38301,7 +41498,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(NORMAL_TARGET_EXPORTS)  \
 	(cd $(TARGET_SUBDIR)/rda && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
 		$(TARGET-target-rda))
 @endif target-rda
 
@@ -38758,7 +41955,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(NORMAL_TARGET_EXPORTS)  \
 	(cd $(TARGET_SUBDIR)/libada && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
 		$(TARGET-target-libada))
 @endif target-libada
 
@@ -39483,7 +42680,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(NORMAL_TARGET_EXPORTS)  \
 	(cd $(TARGET_SUBDIR)/libgomp && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)  \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
 		$(TARGET-target-libgomp))
 @endif target-libgomp
 
@@ -39511,7 +42708,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		$(EXTRA_TARGET_FLAGS)   \
+		$(EXTRA_TARGET_FLAGS)  \
+		  \
 		TFLAGS="$(STAGE1_TFLAGS)" \
 		$(TARGET-stage1-target-libgomp)
 
@@ -39526,7 +42724,7 @@
 	fi; \
 	cd $(TARGET_SUBDIR)/libgomp && \
 	$(MAKE) $(EXTRA_TARGET_FLAGS)  \
-		 clean
+	  clean
 @endif target-libgomp-bootstrap
 
 
@@ -39567,9 +42765,7 @@
 	  $(MAKE) stage2-start; \
 	fi; \
 	cd $(TARGET_SUBDIR)/libgomp && \
-	$(MAKE) $(EXTRA_TARGET_FLAGS)  \
-		  \
-		 clean
+	$(MAKE) $(EXTRA_TARGET_FLAGS)   clean
 @endif target-libgomp-bootstrap
 
 
@@ -39610,9 +42806,7 @@
 	  $(MAKE) stage3-start; \
 	fi; \
 	cd $(TARGET_SUBDIR)/libgomp && \
-	$(MAKE) $(EXTRA_TARGET_FLAGS)  \
-		  \
-		 clean
+	$(MAKE) $(EXTRA_TARGET_FLAGS)   clean
 @endif target-libgomp-bootstrap
 
 
@@ -39653,9 +42847,7 @@
 	  $(MAKE) stage4-start; \
 	fi; \
 	cd $(TARGET_SUBDIR)/libgomp && \
-	$(MAKE) $(EXTRA_TARGET_FLAGS)  \
-		  \
-		 clean
+	$(MAKE) $(EXTRA_TARGET_FLAGS)   clean
 @endif target-libgomp-bootstrap
 
 
@@ -39696,9 +42888,7 @@
 	  $(MAKE) stageprofile-start; \
 	fi; \
 	cd $(TARGET_SUBDIR)/libgomp && \
-	$(MAKE) $(EXTRA_TARGET_FLAGS)  \
-		  \
-		 clean
+	$(MAKE) $(EXTRA_TARGET_FLAGS)   clean
 @endif target-libgomp-bootstrap
 
 
@@ -39739,9 +42929,7 @@
 	  $(MAKE) stagefeedback-start; \
 	fi; \
 	cd $(TARGET_SUBDIR)/libgomp && \
-	$(MAKE) $(EXTRA_TARGET_FLAGS)  \
-		  \
-		 clean
+	$(MAKE) $(EXTRA_TARGET_FLAGS)   clean
 @endif target-libgomp-bootstrap
 
 
@@ -40135,6 +43323,920 @@
 
 
 
+
+
+.PHONY: configure-target-libitm maybe-configure-target-libitm
+maybe-configure-target-libitm:
+@if gcc-bootstrap
+configure-target-libitm: stage_current
+@endif gcc-bootstrap
+@if target-libitm
+maybe-configure-target-libitm: configure-target-libitm
+configure-target-libitm: 
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	echo "Checking multilib configuration for libitm..."; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libitm ; \
+	$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libitm/multilib.tmp 2> /dev/null ; \
+	if test -r $(TARGET_SUBDIR)/libitm/multilib.out; then \
+	  if cmp -s $(TARGET_SUBDIR)/libitm/multilib.tmp $(TARGET_SUBDIR)/libitm/multilib.out; then \
+	    rm -f $(TARGET_SUBDIR)/libitm/multilib.tmp; \
+	  else \
+	    rm -f $(TARGET_SUBDIR)/libitm/Makefile; \
+	    mv $(TARGET_SUBDIR)/libitm/multilib.tmp $(TARGET_SUBDIR)/libitm/multilib.out; \
+	  fi; \
+	else \
+	  mv $(TARGET_SUBDIR)/libitm/multilib.tmp $(TARGET_SUBDIR)/libitm/multilib.out; \
+	fi; \
+	test ! -f $(TARGET_SUBDIR)/libitm/Makefile || exit 0; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libitm ; \
+	$(NORMAL_TARGET_EXPORTS)  \
+	echo Configuring in $(TARGET_SUBDIR)/libitm; \
+	cd "$(TARGET_SUBDIR)/libitm" || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(TARGET_SUBDIR)/libitm/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libitm"; \
+	libsrcdir="$$s/libitm"; \
+	rm -f no-such-file || : ; \
+	CONFIG_SITE=no-such-file $(SHELL) $${libsrcdir}/configure \
+	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+	  --target=${target_alias} $${srcdiroption}  \
+	  || exit 1
+@endif target-libitm
+
+
+
+
+
+.PHONY: all-target-libitm maybe-all-target-libitm
+maybe-all-target-libitm:
+@if gcc-bootstrap
+all-target-libitm: stage_current
+@endif gcc-bootstrap
+@if target-libitm
+TARGET-target-libitm=all
+maybe-all-target-libitm: all-target-libitm
+all-target-libitm: configure-target-libitm
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS)  \
+	(cd $(TARGET_SUBDIR)/libitm && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
+		$(TARGET-target-libitm))
+@endif target-libitm
+
+
+
+
+
+.PHONY: check-target-libitm maybe-check-target-libitm
+maybe-check-target-libitm:
+@if target-libitm
+maybe-check-target-libitm: check-target-libitm
+
+check-target-libitm:
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	(cd $(TARGET_SUBDIR)/libitm && \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS)   check)
+
+@endif target-libitm
+
+.PHONY: install-target-libitm maybe-install-target-libitm
+maybe-install-target-libitm:
+@if target-libitm
+maybe-install-target-libitm: install-target-libitm
+
+install-target-libitm: installdirs
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	(cd $(TARGET_SUBDIR)/libitm && \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS)  install)
+
+@endif target-libitm
+
+.PHONY: install-strip-target-libitm maybe-install-strip-target-libitm
+maybe-install-strip-target-libitm:
+@if target-libitm
+maybe-install-strip-target-libitm: install-strip-target-libitm
+
+install-strip-target-libitm: installdirs
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	(cd $(TARGET_SUBDIR)/libitm && \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS)  install-strip)
+
+@endif target-libitm
+
+# Other targets (info, dvi, pdf, etc.)
+
+.PHONY: maybe-info-target-libitm info-target-libitm
+maybe-info-target-libitm:
+@if target-libitm
+maybe-info-target-libitm: info-target-libitm
+
+info-target-libitm: \
+    configure-target-libitm 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libitm/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing info in $(TARGET_SUBDIR)/libitm" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libitm && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           info) \
+	  || exit 1
+
+@endif target-libitm
+
+.PHONY: maybe-dvi-target-libitm dvi-target-libitm
+maybe-dvi-target-libitm:
+@if target-libitm
+maybe-dvi-target-libitm: dvi-target-libitm
+
+dvi-target-libitm: \
+    configure-target-libitm 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libitm/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing dvi in $(TARGET_SUBDIR)/libitm" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libitm && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           dvi) \
+	  || exit 1
+
+@endif target-libitm
+
+.PHONY: maybe-pdf-target-libitm pdf-target-libitm
+maybe-pdf-target-libitm:
+@if target-libitm
+maybe-pdf-target-libitm: pdf-target-libitm
+
+pdf-target-libitm: \
+    configure-target-libitm 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libitm/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing pdf in $(TARGET_SUBDIR)/libitm" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libitm && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           pdf) \
+	  || exit 1
+
+@endif target-libitm
+
+.PHONY: maybe-html-target-libitm html-target-libitm
+maybe-html-target-libitm:
+@if target-libitm
+maybe-html-target-libitm: html-target-libitm
+
+html-target-libitm: \
+    configure-target-libitm 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libitm/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing html in $(TARGET_SUBDIR)/libitm" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libitm && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           html) \
+	  || exit 1
+
+@endif target-libitm
+
+.PHONY: maybe-TAGS-target-libitm TAGS-target-libitm
+maybe-TAGS-target-libitm:
+@if target-libitm
+maybe-TAGS-target-libitm: TAGS-target-libitm
+
+TAGS-target-libitm: \
+    configure-target-libitm 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libitm/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing TAGS in $(TARGET_SUBDIR)/libitm" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libitm && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           TAGS) \
+	  || exit 1
+
+@endif target-libitm
+
+.PHONY: maybe-install-info-target-libitm install-info-target-libitm
+maybe-install-info-target-libitm:
+@if target-libitm
+maybe-install-info-target-libitm: install-info-target-libitm
+
+install-info-target-libitm: \
+    configure-target-libitm \
+    info-target-libitm 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libitm/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing install-info in $(TARGET_SUBDIR)/libitm" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libitm && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           install-info) \
+	  || exit 1
+
+@endif target-libitm
+
+.PHONY: maybe-install-pdf-target-libitm install-pdf-target-libitm
+maybe-install-pdf-target-libitm:
+@if target-libitm
+maybe-install-pdf-target-libitm: install-pdf-target-libitm
+
+install-pdf-target-libitm: \
+    configure-target-libitm \
+    pdf-target-libitm 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libitm/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing install-pdf in $(TARGET_SUBDIR)/libitm" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libitm && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           install-pdf) \
+	  || exit 1
+
+@endif target-libitm
+
+.PHONY: maybe-install-html-target-libitm install-html-target-libitm
+maybe-install-html-target-libitm:
+@if target-libitm
+maybe-install-html-target-libitm: install-html-target-libitm
+
+install-html-target-libitm: \
+    configure-target-libitm \
+    html-target-libitm 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libitm/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing install-html in $(TARGET_SUBDIR)/libitm" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libitm && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           install-html) \
+	  || exit 1
+
+@endif target-libitm
+
+.PHONY: maybe-installcheck-target-libitm installcheck-target-libitm
+maybe-installcheck-target-libitm:
+@if target-libitm
+maybe-installcheck-target-libitm: installcheck-target-libitm
+
+installcheck-target-libitm: \
+    configure-target-libitm 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libitm/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing installcheck in $(TARGET_SUBDIR)/libitm" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libitm && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           installcheck) \
+	  || exit 1
+
+@endif target-libitm
+
+.PHONY: maybe-mostlyclean-target-libitm mostlyclean-target-libitm
+maybe-mostlyclean-target-libitm:
+@if target-libitm
+maybe-mostlyclean-target-libitm: mostlyclean-target-libitm
+
+mostlyclean-target-libitm: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libitm/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing mostlyclean in $(TARGET_SUBDIR)/libitm" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libitm && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           mostlyclean) \
+	  || exit 1
+
+@endif target-libitm
+
+.PHONY: maybe-clean-target-libitm clean-target-libitm
+maybe-clean-target-libitm:
+@if target-libitm
+maybe-clean-target-libitm: clean-target-libitm
+
+clean-target-libitm: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libitm/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing clean in $(TARGET_SUBDIR)/libitm" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libitm && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           clean) \
+	  || exit 1
+
+@endif target-libitm
+
+.PHONY: maybe-distclean-target-libitm distclean-target-libitm
+maybe-distclean-target-libitm:
+@if target-libitm
+maybe-distclean-target-libitm: distclean-target-libitm
+
+distclean-target-libitm: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libitm/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing distclean in $(TARGET_SUBDIR)/libitm" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libitm && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           distclean) \
+	  || exit 1
+
+@endif target-libitm
+
+.PHONY: maybe-maintainer-clean-target-libitm maintainer-clean-target-libitm
+maybe-maintainer-clean-target-libitm:
+@if target-libitm
+maybe-maintainer-clean-target-libitm: maintainer-clean-target-libitm
+
+maintainer-clean-target-libitm: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libitm/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing maintainer-clean in $(TARGET_SUBDIR)/libitm" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libitm && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           maintainer-clean) \
+	  || exit 1
+
+@endif target-libitm
+
+
+
+
+
+.PHONY: configure-target-libatomic maybe-configure-target-libatomic
+maybe-configure-target-libatomic:
+@if gcc-bootstrap
+configure-target-libatomic: stage_current
+@endif gcc-bootstrap
+@if target-libatomic
+maybe-configure-target-libatomic: configure-target-libatomic
+configure-target-libatomic: 
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	echo "Checking multilib configuration for libatomic..."; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libatomic ; \
+	$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libatomic/multilib.tmp 2> /dev/null ; \
+	if test -r $(TARGET_SUBDIR)/libatomic/multilib.out; then \
+	  if cmp -s $(TARGET_SUBDIR)/libatomic/multilib.tmp $(TARGET_SUBDIR)/libatomic/multilib.out; then \
+	    rm -f $(TARGET_SUBDIR)/libatomic/multilib.tmp; \
+	  else \
+	    rm -f $(TARGET_SUBDIR)/libatomic/Makefile; \
+	    mv $(TARGET_SUBDIR)/libatomic/multilib.tmp $(TARGET_SUBDIR)/libatomic/multilib.out; \
+	  fi; \
+	else \
+	  mv $(TARGET_SUBDIR)/libatomic/multilib.tmp $(TARGET_SUBDIR)/libatomic/multilib.out; \
+	fi; \
+	test ! -f $(TARGET_SUBDIR)/libatomic/Makefile || exit 0; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libatomic ; \
+	$(NORMAL_TARGET_EXPORTS)  \
+	echo Configuring in $(TARGET_SUBDIR)/libatomic; \
+	cd "$(TARGET_SUBDIR)/libatomic" || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(TARGET_SUBDIR)/libatomic/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	srcdiroption="--srcdir=$${topdir}/libatomic"; \
+	libsrcdir="$$s/libatomic"; \
+	rm -f no-such-file || : ; \
+	CONFIG_SITE=no-such-file $(SHELL) $${libsrcdir}/configure \
+	  $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
+	  --target=${target_alias} $${srcdiroption}  \
+	  || exit 1
+@endif target-libatomic
+
+
+
+
+
+.PHONY: all-target-libatomic maybe-all-target-libatomic
+maybe-all-target-libatomic:
+@if gcc-bootstrap
+all-target-libatomic: stage_current
+@endif gcc-bootstrap
+@if target-libatomic
+TARGET-target-libatomic=all
+maybe-all-target-libatomic: all-target-libatomic
+all-target-libatomic: configure-target-libatomic
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS)  \
+	(cd $(TARGET_SUBDIR)/libatomic && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)   \
+		$(TARGET-target-libatomic))
+@endif target-libatomic
+
+
+
+
+
+.PHONY: check-target-libatomic maybe-check-target-libatomic
+maybe-check-target-libatomic:
+@if target-libatomic
+maybe-check-target-libatomic: check-target-libatomic
+
+check-target-libatomic:
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	(cd $(TARGET_SUBDIR)/libatomic && \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS)   check)
+
+@endif target-libatomic
+
+.PHONY: install-target-libatomic maybe-install-target-libatomic
+maybe-install-target-libatomic:
+@if target-libatomic
+maybe-install-target-libatomic: install-target-libatomic
+
+install-target-libatomic: installdirs
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	(cd $(TARGET_SUBDIR)/libatomic && \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS)  install)
+
+@endif target-libatomic
+
+.PHONY: install-strip-target-libatomic maybe-install-strip-target-libatomic
+maybe-install-strip-target-libatomic:
+@if target-libatomic
+maybe-install-strip-target-libatomic: install-strip-target-libatomic
+
+install-strip-target-libatomic: installdirs
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	(cd $(TARGET_SUBDIR)/libatomic && \
+	  $(MAKE) $(TARGET_FLAGS_TO_PASS)  install-strip)
+
+@endif target-libatomic
+
+# Other targets (info, dvi, pdf, etc.)
+
+.PHONY: maybe-info-target-libatomic info-target-libatomic
+maybe-info-target-libatomic:
+@if target-libatomic
+maybe-info-target-libatomic: info-target-libatomic
+
+info-target-libatomic: \
+    configure-target-libatomic 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing info in $(TARGET_SUBDIR)/libatomic" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libatomic && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           info) \
+	  || exit 1
+
+@endif target-libatomic
+
+.PHONY: maybe-dvi-target-libatomic dvi-target-libatomic
+maybe-dvi-target-libatomic:
+@if target-libatomic
+maybe-dvi-target-libatomic: dvi-target-libatomic
+
+dvi-target-libatomic: \
+    configure-target-libatomic 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing dvi in $(TARGET_SUBDIR)/libatomic" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libatomic && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           dvi) \
+	  || exit 1
+
+@endif target-libatomic
+
+.PHONY: maybe-pdf-target-libatomic pdf-target-libatomic
+maybe-pdf-target-libatomic:
+@if target-libatomic
+maybe-pdf-target-libatomic: pdf-target-libatomic
+
+pdf-target-libatomic: \
+    configure-target-libatomic 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing pdf in $(TARGET_SUBDIR)/libatomic" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libatomic && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           pdf) \
+	  || exit 1
+
+@endif target-libatomic
+
+.PHONY: maybe-html-target-libatomic html-target-libatomic
+maybe-html-target-libatomic:
+@if target-libatomic
+maybe-html-target-libatomic: html-target-libatomic
+
+html-target-libatomic: \
+    configure-target-libatomic 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing html in $(TARGET_SUBDIR)/libatomic" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libatomic && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           html) \
+	  || exit 1
+
+@endif target-libatomic
+
+.PHONY: maybe-TAGS-target-libatomic TAGS-target-libatomic
+maybe-TAGS-target-libatomic:
+@if target-libatomic
+maybe-TAGS-target-libatomic: TAGS-target-libatomic
+
+TAGS-target-libatomic: \
+    configure-target-libatomic 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing TAGS in $(TARGET_SUBDIR)/libatomic" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libatomic && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           TAGS) \
+	  || exit 1
+
+@endif target-libatomic
+
+.PHONY: maybe-install-info-target-libatomic install-info-target-libatomic
+maybe-install-info-target-libatomic:
+@if target-libatomic
+maybe-install-info-target-libatomic: install-info-target-libatomic
+
+install-info-target-libatomic: \
+    configure-target-libatomic \
+    info-target-libatomic 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing install-info in $(TARGET_SUBDIR)/libatomic" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libatomic && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           install-info) \
+	  || exit 1
+
+@endif target-libatomic
+
+.PHONY: maybe-install-pdf-target-libatomic install-pdf-target-libatomic
+maybe-install-pdf-target-libatomic:
+@if target-libatomic
+maybe-install-pdf-target-libatomic: install-pdf-target-libatomic
+
+install-pdf-target-libatomic: \
+    configure-target-libatomic \
+    pdf-target-libatomic 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing install-pdf in $(TARGET_SUBDIR)/libatomic" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libatomic && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           install-pdf) \
+	  || exit 1
+
+@endif target-libatomic
+
+.PHONY: maybe-install-html-target-libatomic install-html-target-libatomic
+maybe-install-html-target-libatomic:
+@if target-libatomic
+maybe-install-html-target-libatomic: install-html-target-libatomic
+
+install-html-target-libatomic: \
+    configure-target-libatomic \
+    html-target-libatomic 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing install-html in $(TARGET_SUBDIR)/libatomic" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libatomic && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           install-html) \
+	  || exit 1
+
+@endif target-libatomic
+
+.PHONY: maybe-installcheck-target-libatomic installcheck-target-libatomic
+maybe-installcheck-target-libatomic:
+@if target-libatomic
+maybe-installcheck-target-libatomic: installcheck-target-libatomic
+
+installcheck-target-libatomic: \
+    configure-target-libatomic 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing installcheck in $(TARGET_SUBDIR)/libatomic" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libatomic && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           installcheck) \
+	  || exit 1
+
+@endif target-libatomic
+
+.PHONY: maybe-mostlyclean-target-libatomic mostlyclean-target-libatomic
+maybe-mostlyclean-target-libatomic:
+@if target-libatomic
+maybe-mostlyclean-target-libatomic: mostlyclean-target-libatomic
+
+mostlyclean-target-libatomic: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing mostlyclean in $(TARGET_SUBDIR)/libatomic" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libatomic && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           mostlyclean) \
+	  || exit 1
+
+@endif target-libatomic
+
+.PHONY: maybe-clean-target-libatomic clean-target-libatomic
+maybe-clean-target-libatomic:
+@if target-libatomic
+maybe-clean-target-libatomic: clean-target-libatomic
+
+clean-target-libatomic: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing clean in $(TARGET_SUBDIR)/libatomic" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libatomic && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           clean) \
+	  || exit 1
+
+@endif target-libatomic
+
+.PHONY: maybe-distclean-target-libatomic distclean-target-libatomic
+maybe-distclean-target-libatomic:
+@if target-libatomic
+maybe-distclean-target-libatomic: distclean-target-libatomic
+
+distclean-target-libatomic: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing distclean in $(TARGET_SUBDIR)/libatomic" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libatomic && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           distclean) \
+	  || exit 1
+
+@endif target-libatomic
+
+.PHONY: maybe-maintainer-clean-target-libatomic maintainer-clean-target-libatomic
+maybe-maintainer-clean-target-libatomic:
+@if target-libatomic
+maybe-maintainer-clean-target-libatomic: maintainer-clean-target-libatomic
+
+maintainer-clean-target-libatomic: 
+	@: $(MAKE); $(unstage)
+	@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
+	r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(NORMAL_TARGET_EXPORTS) \
+	echo "Doing maintainer-clean in $(TARGET_SUBDIR)/libatomic" ; \
+	for flag in $(EXTRA_TARGET_FLAGS); do \
+	  eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
+	done; \
+	(cd $(TARGET_SUBDIR)/libatomic && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
+	          "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
+	          "RANLIB=$${RANLIB}" \
+	          "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
+	           maintainer-clean) \
+	  || exit 1
+
+@endif target-libatomic
+
+
+
 @if target-libmudflap
 .PHONY: check-target-libmudflap-c++
 check-target-libmudflap-c++:
@@ -40142,6 +44244,20 @@
 
 @endif target-libmudflap
 
+@if target-libgomp
+.PHONY: check-target-libgomp-c++
+check-target-libgomp-c++:
+	$(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) c++.exp" check-target-libgomp
+
+@endif target-libgomp
+
+@if target-libitm
+.PHONY: check-target-libitm-c++
+check-target-libitm-c++:
+	$(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) c++.exp" check-target-libitm
+
+@endif target-libitm
+
 # ----------
 # GCC module
 # ----------
@@ -40175,8 +44291,8 @@
 	r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	$(HOST_EXPORTS) \
-	(cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) check-c++ check-c++0x);
-check-c++: check-gcc-c++ check-target-libstdc++-v3 check-target-libmudflap-c++
+	(cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) check-c++);
+check-c++: check-gcc-c++ check-target-libstdc++-v3 check-target-libmudflap-c++ check-target-libitm-c++ check-target-libgomp-c++
 
 .PHONY: check-gcc-fortran check-fortran
 check-gcc-fortran:
@@ -40227,25 +44343,16 @@
 check-go: check-gcc-go check-target-libgo
 
 
-# Install the gcc headers files, but not the fixed include files,
-# which Cygnus is not allowed to distribute.  This rule is very
-# dependent on the workings of the gcc Makefile.in.
-.PHONY: gcc-no-fixedincludes
-gcc-no-fixedincludes:
+# The gcc part of install-no-fixedincludes, which relies on an intimate
+# knowledge of how a number of gcc internal targets (inter)operate.  Delegate.
+.PHONY: gcc-install-no-fixedincludes
+gcc-install-no-fixedincludes:
 	@if [ -f ./gcc/Makefile ]; then \
-	  rm -rf gcc/tmp-include; \
-	  mv gcc/include gcc/tmp-include 2>/dev/null; \
-	  mkdir gcc/include; \
-	  cp $(srcdir)/gcc/gsyslimits.h gcc/include/syslimits.h; \
-	  touch gcc/stmp-fixinc gcc/include/fixed; \
-	  rm -f gcc/stmp-headers gcc/stmp-int-hdrs; \
 	  r=`${PWD_COMMAND}`; export r; \
-	  s=`cd $(srcdir); ${PWD_COMMAND}` ; export s; \
+	  s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	  $(HOST_EXPORTS) \
-	  (cd ./gcc && \
-	   $(MAKE) $(GCC_FLAGS_TO_PASS) install); \
-	  rm -rf gcc/include; \
-	  mv gcc/tmp-include gcc/include 2>/dev/null; \
+	  (cd ./gcc \
+	   && $(MAKE) $(GCC_FLAGS_TO_PASS) install-no-fixedincludes); \
 	else true; fi
 @endif gcc
 
@@ -40347,11 +44454,11 @@
 	  mkdir stage1-mpc; \
 	mv stage1-mpc mpc 
 @endif mpc
-@if ppl
-	@cd $(HOST_SUBDIR); [ -d stage1-ppl ] || \
-	  mkdir stage1-ppl; \
-	mv stage1-ppl ppl 
-@endif ppl
+@if isl
+	@cd $(HOST_SUBDIR); [ -d stage1-isl ] || \
+	  mkdir stage1-isl; \
+	mv stage1-isl isl 
+@endif isl
 @if cloog
 	@cd $(HOST_SUBDIR); [ -d stage1-cloog ] || \
 	  mkdir stage1-cloog; \
@@ -40377,6 +44484,11 @@
 	  mkdir stage1-ld; \
 	mv stage1-ld ld 
 @endif ld
+@if libbacktrace
+	@cd $(HOST_SUBDIR); [ -d stage1-libbacktrace ] || \
+	  mkdir stage1-libbacktrace; \
+	mv stage1-libbacktrace libbacktrace 
+@endif libbacktrace
 @if libcpp
 	@cd $(HOST_SUBDIR); [ -d stage1-libcpp ] || \
 	  mkdir stage1-libcpp; \
@@ -40447,11 +44559,11 @@
 	  cd $(HOST_SUBDIR); mv mpc stage1-mpc  ; \
 	fi
 @endif mpc
-@if ppl
-	@if test -d $(HOST_SUBDIR)/ppl ; then \
-	  cd $(HOST_SUBDIR); mv ppl stage1-ppl  ; \
+@if isl
+	@if test -d $(HOST_SUBDIR)/isl ; then \
+	  cd $(HOST_SUBDIR); mv isl stage1-isl  ; \
 	fi
-@endif ppl
+@endif isl
 @if cloog
 	@if test -d $(HOST_SUBDIR)/cloog ; then \
 	  cd $(HOST_SUBDIR); mv cloog stage1-cloog  ; \
@@ -40477,6 +44589,11 @@
 	  cd $(HOST_SUBDIR); mv ld stage1-ld  ; \
 	fi
 @endif ld
+@if libbacktrace
+	@if test -d $(HOST_SUBDIR)/libbacktrace ; then \
+	  cd $(HOST_SUBDIR); mv libbacktrace stage1-libbacktrace  ; \
+	fi
+@endif libbacktrace
 @if libcpp
 	@if test -d $(HOST_SUBDIR)/libcpp ; then \
 	  cd $(HOST_SUBDIR); mv libcpp stage1-libcpp  ; \
@@ -40598,12 +44715,12 @@
 	mv stage2-mpc mpc  ; \
 	mv stage1-mpc prev-mpc || test -f stage1-lean 
 @endif mpc
-@if ppl
-	@cd $(HOST_SUBDIR); [ -d stage2-ppl ] || \
-	  mkdir stage2-ppl; \
-	mv stage2-ppl ppl  ; \
-	mv stage1-ppl prev-ppl || test -f stage1-lean 
-@endif ppl
+@if isl
+	@cd $(HOST_SUBDIR); [ -d stage2-isl ] || \
+	  mkdir stage2-isl; \
+	mv stage2-isl isl  ; \
+	mv stage1-isl prev-isl || test -f stage1-lean 
+@endif isl
 @if cloog
 	@cd $(HOST_SUBDIR); [ -d stage2-cloog ] || \
 	  mkdir stage2-cloog; \
@@ -40634,6 +44751,12 @@
 	mv stage2-ld ld  ; \
 	mv stage1-ld prev-ld || test -f stage1-lean 
 @endif ld
+@if libbacktrace
+	@cd $(HOST_SUBDIR); [ -d stage2-libbacktrace ] || \
+	  mkdir stage2-libbacktrace; \
+	mv stage2-libbacktrace libbacktrace  ; \
+	mv stage1-libbacktrace prev-libbacktrace || test -f stage1-lean 
+@endif libbacktrace
 @if libcpp
 	@cd $(HOST_SUBDIR); [ -d stage2-libcpp ] || \
 	  mkdir stage2-libcpp; \
@@ -40718,12 +44841,12 @@
 	  mv prev-mpc stage1-mpc ; :  ; \
 	fi
 @endif mpc
-@if ppl
-	@if test -d $(HOST_SUBDIR)/ppl ; then \
-	  cd $(HOST_SUBDIR); mv ppl stage2-ppl ; \
-	  mv prev-ppl stage1-ppl ; :  ; \
+@if isl
+	@if test -d $(HOST_SUBDIR)/isl ; then \
+	  cd $(HOST_SUBDIR); mv isl stage2-isl ; \
+	  mv prev-isl stage1-isl ; :  ; \
 	fi
-@endif ppl
+@endif isl
 @if cloog
 	@if test -d $(HOST_SUBDIR)/cloog ; then \
 	  cd $(HOST_SUBDIR); mv cloog stage2-cloog ; \
@@ -40754,6 +44877,12 @@
 	  mv prev-ld stage1-ld ; :  ; \
 	fi
 @endif ld
+@if libbacktrace
+	@if test -d $(HOST_SUBDIR)/libbacktrace ; then \
+	  cd $(HOST_SUBDIR); mv libbacktrace stage2-libbacktrace ; \
+	  mv prev-libbacktrace stage1-libbacktrace ; :  ; \
+	fi
+@endif libbacktrace
 @if libcpp
 	@if test -d $(HOST_SUBDIR)/libcpp ; then \
 	  cd $(HOST_SUBDIR); mv libcpp stage2-libcpp ; \
@@ -40904,12 +45033,12 @@
 	mv stage3-mpc mpc  ; \
 	mv stage2-mpc prev-mpc || test -f stage2-lean 
 @endif mpc
-@if ppl
-	@cd $(HOST_SUBDIR); [ -d stage3-ppl ] || \
-	  mkdir stage3-ppl; \
-	mv stage3-ppl ppl  ; \
-	mv stage2-ppl prev-ppl || test -f stage2-lean 
-@endif ppl
+@if isl
+	@cd $(HOST_SUBDIR); [ -d stage3-isl ] || \
+	  mkdir stage3-isl; \
+	mv stage3-isl isl  ; \
+	mv stage2-isl prev-isl || test -f stage2-lean 
+@endif isl
 @if cloog
 	@cd $(HOST_SUBDIR); [ -d stage3-cloog ] || \
 	  mkdir stage3-cloog; \
@@ -40940,6 +45069,12 @@
 	mv stage3-ld ld  ; \
 	mv stage2-ld prev-ld || test -f stage2-lean 
 @endif ld
+@if libbacktrace
+	@cd $(HOST_SUBDIR); [ -d stage3-libbacktrace ] || \
+	  mkdir stage3-libbacktrace; \
+	mv stage3-libbacktrace libbacktrace  ; \
+	mv stage2-libbacktrace prev-libbacktrace || test -f stage2-lean 
+@endif libbacktrace
 @if libcpp
 	@cd $(HOST_SUBDIR); [ -d stage3-libcpp ] || \
 	  mkdir stage3-libcpp; \
@@ -41024,12 +45159,12 @@
 	  mv prev-mpc stage2-mpc ; :  ; \
 	fi
 @endif mpc
-@if ppl
-	@if test -d $(HOST_SUBDIR)/ppl ; then \
-	  cd $(HOST_SUBDIR); mv ppl stage3-ppl ; \
-	  mv prev-ppl stage2-ppl ; :  ; \
+@if isl
+	@if test -d $(HOST_SUBDIR)/isl ; then \
+	  cd $(HOST_SUBDIR); mv isl stage3-isl ; \
+	  mv prev-isl stage2-isl ; :  ; \
 	fi
-@endif ppl
+@endif isl
 @if cloog
 	@if test -d $(HOST_SUBDIR)/cloog ; then \
 	  cd $(HOST_SUBDIR); mv cloog stage3-cloog ; \
@@ -41060,6 +45195,12 @@
 	  mv prev-ld stage2-ld ; :  ; \
 	fi
 @endif ld
+@if libbacktrace
+	@if test -d $(HOST_SUBDIR)/libbacktrace ; then \
+	  cd $(HOST_SUBDIR); mv libbacktrace stage3-libbacktrace ; \
+	  mv prev-libbacktrace stage2-libbacktrace ; :  ; \
+	fi
+@endif libbacktrace
 @if libcpp
 	@if test -d $(HOST_SUBDIR)/libcpp ; then \
 	  cd $(HOST_SUBDIR); mv libcpp stage3-libcpp ; \
@@ -41266,12 +45407,12 @@
 	mv stage4-mpc mpc  ; \
 	mv stage3-mpc prev-mpc || test -f stage3-lean 
 @endif mpc
-@if ppl
-	@cd $(HOST_SUBDIR); [ -d stage4-ppl ] || \
-	  mkdir stage4-ppl; \
-	mv stage4-ppl ppl  ; \
-	mv stage3-ppl prev-ppl || test -f stage3-lean 
-@endif ppl
+@if isl
+	@cd $(HOST_SUBDIR); [ -d stage4-isl ] || \
+	  mkdir stage4-isl; \
+	mv stage4-isl isl  ; \
+	mv stage3-isl prev-isl || test -f stage3-lean 
+@endif isl
 @if cloog
 	@cd $(HOST_SUBDIR); [ -d stage4-cloog ] || \
 	  mkdir stage4-cloog; \
@@ -41302,6 +45443,12 @@
 	mv stage4-ld ld  ; \
 	mv stage3-ld prev-ld || test -f stage3-lean 
 @endif ld
+@if libbacktrace
+	@cd $(HOST_SUBDIR); [ -d stage4-libbacktrace ] || \
+	  mkdir stage4-libbacktrace; \
+	mv stage4-libbacktrace libbacktrace  ; \
+	mv stage3-libbacktrace prev-libbacktrace || test -f stage3-lean 
+@endif libbacktrace
 @if libcpp
 	@cd $(HOST_SUBDIR); [ -d stage4-libcpp ] || \
 	  mkdir stage4-libcpp; \
@@ -41386,12 +45533,12 @@
 	  mv prev-mpc stage3-mpc ; :  ; \
 	fi
 @endif mpc
-@if ppl
-	@if test -d $(HOST_SUBDIR)/ppl ; then \
-	  cd $(HOST_SUBDIR); mv ppl stage4-ppl ; \
-	  mv prev-ppl stage3-ppl ; :  ; \
+@if isl
+	@if test -d $(HOST_SUBDIR)/isl ; then \
+	  cd $(HOST_SUBDIR); mv isl stage4-isl ; \
+	  mv prev-isl stage3-isl ; :  ; \
 	fi
-@endif ppl
+@endif isl
 @if cloog
 	@if test -d $(HOST_SUBDIR)/cloog ; then \
 	  cd $(HOST_SUBDIR); mv cloog stage4-cloog ; \
@@ -41422,6 +45569,12 @@
 	  mv prev-ld stage3-ld ; :  ; \
 	fi
 @endif ld
+@if libbacktrace
+	@if test -d $(HOST_SUBDIR)/libbacktrace ; then \
+	  cd $(HOST_SUBDIR); mv libbacktrace stage4-libbacktrace ; \
+	  mv prev-libbacktrace stage3-libbacktrace ; :  ; \
+	fi
+@endif libbacktrace
 @if libcpp
 	@if test -d $(HOST_SUBDIR)/libcpp ; then \
 	  cd $(HOST_SUBDIR); mv libcpp stage4-libcpp ; \
@@ -41616,12 +45769,12 @@
 	mv stageprofile-mpc mpc  ; \
 	mv stage1-mpc prev-mpc || test -f stage1-lean 
 @endif mpc
-@if ppl
-	@cd $(HOST_SUBDIR); [ -d stageprofile-ppl ] || \
-	  mkdir stageprofile-ppl; \
-	mv stageprofile-ppl ppl  ; \
-	mv stage1-ppl prev-ppl || test -f stage1-lean 
-@endif ppl
+@if isl
+	@cd $(HOST_SUBDIR); [ -d stageprofile-isl ] || \
+	  mkdir stageprofile-isl; \
+	mv stageprofile-isl isl  ; \
+	mv stage1-isl prev-isl || test -f stage1-lean 
+@endif isl
 @if cloog
 	@cd $(HOST_SUBDIR); [ -d stageprofile-cloog ] || \
 	  mkdir stageprofile-cloog; \
@@ -41652,6 +45805,12 @@
 	mv stageprofile-ld ld  ; \
 	mv stage1-ld prev-ld || test -f stage1-lean 
 @endif ld
+@if libbacktrace
+	@cd $(HOST_SUBDIR); [ -d stageprofile-libbacktrace ] || \
+	  mkdir stageprofile-libbacktrace; \
+	mv stageprofile-libbacktrace libbacktrace  ; \
+	mv stage1-libbacktrace prev-libbacktrace || test -f stage1-lean 
+@endif libbacktrace
 @if libcpp
 	@cd $(HOST_SUBDIR); [ -d stageprofile-libcpp ] || \
 	  mkdir stageprofile-libcpp; \
@@ -41736,12 +45895,12 @@
 	  mv prev-mpc stage1-mpc ; :  ; \
 	fi
 @endif mpc
-@if ppl
-	@if test -d $(HOST_SUBDIR)/ppl ; then \
-	  cd $(HOST_SUBDIR); mv ppl stageprofile-ppl ; \
-	  mv prev-ppl stage1-ppl ; :  ; \
+@if isl
+	@if test -d $(HOST_SUBDIR)/isl ; then \
+	  cd $(HOST_SUBDIR); mv isl stageprofile-isl ; \
+	  mv prev-isl stage1-isl ; :  ; \
 	fi
-@endif ppl
+@endif isl
 @if cloog
 	@if test -d $(HOST_SUBDIR)/cloog ; then \
 	  cd $(HOST_SUBDIR); mv cloog stageprofile-cloog ; \
@@ -41772,6 +45931,12 @@
 	  mv prev-ld stage1-ld ; :  ; \
 	fi
 @endif ld
+@if libbacktrace
+	@if test -d $(HOST_SUBDIR)/libbacktrace ; then \
+	  cd $(HOST_SUBDIR); mv libbacktrace stageprofile-libbacktrace ; \
+	  mv prev-libbacktrace stage1-libbacktrace ; :  ; \
+	fi
+@endif libbacktrace
 @if libcpp
 	@if test -d $(HOST_SUBDIR)/libcpp ; then \
 	  cd $(HOST_SUBDIR); mv libcpp stageprofile-libcpp ; \
@@ -41899,12 +46064,12 @@
 	mv stagefeedback-mpc mpc  ; \
 	mv stageprofile-mpc prev-mpc || test -f stageprofile-lean 
 @endif mpc
-@if ppl
-	@cd $(HOST_SUBDIR); [ -d stagefeedback-ppl ] || \
-	  mkdir stagefeedback-ppl; \
-	mv stagefeedback-ppl ppl  ; \
-	mv stageprofile-ppl prev-ppl || test -f stageprofile-lean 
-@endif ppl
+@if isl
+	@cd $(HOST_SUBDIR); [ -d stagefeedback-isl ] || \
+	  mkdir stagefeedback-isl; \
+	mv stagefeedback-isl isl  ; \
+	mv stageprofile-isl prev-isl || test -f stageprofile-lean 
+@endif isl
 @if cloog
 	@cd $(HOST_SUBDIR); [ -d stagefeedback-cloog ] || \
 	  mkdir stagefeedback-cloog; \
@@ -41935,6 +46100,12 @@
 	mv stagefeedback-ld ld  ; \
 	mv stageprofile-ld prev-ld || test -f stageprofile-lean 
 @endif ld
+@if libbacktrace
+	@cd $(HOST_SUBDIR); [ -d stagefeedback-libbacktrace ] || \
+	  mkdir stagefeedback-libbacktrace; \
+	mv stagefeedback-libbacktrace libbacktrace  ; \
+	mv stageprofile-libbacktrace prev-libbacktrace || test -f stageprofile-lean 
+@endif libbacktrace
 @if libcpp
 	@cd $(HOST_SUBDIR); [ -d stagefeedback-libcpp ] || \
 	  mkdir stagefeedback-libcpp; \
@@ -42019,12 +46190,12 @@
 	  mv prev-mpc stageprofile-mpc ; :  ; \
 	fi
 @endif mpc
-@if ppl
-	@if test -d $(HOST_SUBDIR)/ppl ; then \
-	  cd $(HOST_SUBDIR); mv ppl stagefeedback-ppl ; \
-	  mv prev-ppl stageprofile-ppl ; :  ; \
+@if isl
+	@if test -d $(HOST_SUBDIR)/isl ; then \
+	  cd $(HOST_SUBDIR); mv isl stagefeedback-isl ; \
+	  mv prev-isl stageprofile-isl ; :  ; \
 	fi
-@endif ppl
+@endif isl
 @if cloog
 	@if test -d $(HOST_SUBDIR)/cloog ; then \
 	  cd $(HOST_SUBDIR); mv cloog stagefeedback-cloog ; \
@@ -42055,6 +46226,12 @@
 	  mv prev-ld stageprofile-ld ; :  ; \
 	fi
 @endif ld
+@if libbacktrace
+	@if test -d $(HOST_SUBDIR)/libbacktrace ; then \
+	  cd $(HOST_SUBDIR); mv libbacktrace stagefeedback-libbacktrace ; \
+	  mv prev-libbacktrace stageprofile-libbacktrace ; :  ; \
+	fi
+@endif libbacktrace
 @if libcpp
 	@if test -d $(HOST_SUBDIR)/libcpp ; then \
 	  cd $(HOST_SUBDIR); mv libcpp stagefeedback-libcpp ; \
@@ -42199,6 +46376,18 @@
 configure-stageprofile-target-libstdc++-v3: maybe-all-stageprofile-gcc
 configure-stagefeedback-target-libstdc++-v3: maybe-all-stagefeedback-gcc
 configure-target-libmudflap: stage_last
+configure-stage1-target-libsanitizer: maybe-all-stage1-gcc
+configure-stage2-target-libsanitizer: maybe-all-stage2-gcc
+configure-stage3-target-libsanitizer: maybe-all-stage3-gcc
+configure-stage4-target-libsanitizer: maybe-all-stage4-gcc
+configure-stageprofile-target-libsanitizer: maybe-all-stageprofile-gcc
+configure-stagefeedback-target-libsanitizer: maybe-all-stagefeedback-gcc
+configure-stage1-target-libvtv: maybe-all-stage1-gcc
+configure-stage2-target-libvtv: maybe-all-stage2-gcc
+configure-stage3-target-libvtv: maybe-all-stage3-gcc
+configure-stage4-target-libvtv: maybe-all-stage4-gcc
+configure-stageprofile-target-libvtv: maybe-all-stageprofile-gcc
+configure-stagefeedback-target-libvtv: maybe-all-stagefeedback-gcc
 configure-target-libssp: stage_last
 configure-target-newlib: stage_last
 configure-stage1-target-libgcc: maybe-all-stage1-gcc
@@ -42207,6 +46396,7 @@
 configure-stage4-target-libgcc: maybe-all-stage4-gcc
 configure-stageprofile-target-libgcc: maybe-all-stageprofile-gcc
 configure-stagefeedback-target-libgcc: maybe-all-stagefeedback-gcc
+configure-target-libbacktrace: stage_last
 configure-target-libquadmath: stage_last
 configure-target-libgfortran: stage_last
 configure-target-libobjc: stage_last
@@ -42226,14 +46416,19 @@
 configure-stage4-target-libgomp: maybe-all-stage4-gcc
 configure-stageprofile-target-libgomp: maybe-all-stageprofile-gcc
 configure-stagefeedback-target-libgomp: maybe-all-stagefeedback-gcc
+configure-target-libitm: stage_last
+configure-target-libatomic: stage_last
 @endif gcc-bootstrap
 
 @if gcc-no-bootstrap
 configure-target-libstdc++-v3: maybe-all-gcc
 configure-target-libmudflap: maybe-all-gcc
+configure-target-libsanitizer: maybe-all-gcc
+configure-target-libvtv: maybe-all-gcc
 configure-target-libssp: maybe-all-gcc
 configure-target-newlib: maybe-all-gcc
 configure-target-libgcc: maybe-all-gcc
+configure-target-libbacktrace: maybe-all-gcc
 configure-target-libquadmath: maybe-all-gcc
 configure-target-libgfortran: maybe-all-gcc
 configure-target-libobjc: maybe-all-gcc
@@ -42248,6 +46443,8 @@
 configure-target-rda: maybe-all-gcc
 configure-target-libada: maybe-all-gcc
 configure-target-libgomp: maybe-all-gcc
+configure-target-libitm: maybe-all-gcc
+configure-target-libatomic: maybe-all-gcc
 @endif gcc-no-bootstrap
 
 
@@ -42283,6 +46480,14 @@
 configure-stage4-gcc: maybe-configure-stage4-intl
 configure-stageprofile-gcc: maybe-configure-stageprofile-intl
 configure-stagefeedback-gcc: maybe-configure-stagefeedback-intl
+configure-gcc: maybe-all-gmp
+
+configure-stage1-gcc: maybe-all-stage1-gmp
+configure-stage2-gcc: maybe-all-stage2-gmp
+configure-stage3-gcc: maybe-all-stage3-gmp
+configure-stage4-gcc: maybe-all-stage4-gmp
+configure-stageprofile-gcc: maybe-all-stageprofile-gmp
+configure-stagefeedback-gcc: maybe-all-stagefeedback-gmp
 configure-gcc: maybe-all-lto-plugin
 
 configure-stage1-gcc: maybe-all-stage1-lto-plugin
@@ -42339,14 +46544,6 @@
 all-stage4-gcc: all-stage4-libiberty
 all-stageprofile-gcc: all-stageprofile-libiberty
 all-stagefeedback-gcc: all-stagefeedback-libiberty
-all-gcc: maybe-all-gmp
-
-all-stage1-gcc: maybe-all-stage1-gmp
-all-stage2-gcc: maybe-all-stage2-gmp
-all-stage3-gcc: maybe-all-stage3-gmp
-all-stage4-gcc: maybe-all-stage4-gmp
-all-stageprofile-gcc: maybe-all-stageprofile-gmp
-all-stagefeedback-gcc: maybe-all-stagefeedback-gmp
 all-gcc: maybe-all-intl
 
 all-stage1-gcc: maybe-all-stage1-intl
@@ -42371,14 +46568,6 @@
 all-stage4-gcc: maybe-all-stage4-mpc
 all-stageprofile-gcc: maybe-all-stageprofile-mpc
 all-stagefeedback-gcc: maybe-all-stagefeedback-mpc
-all-gcc: maybe-all-ppl
-
-all-stage1-gcc: maybe-all-stage1-ppl
-all-stage2-gcc: maybe-all-stage2-ppl
-all-stage3-gcc: maybe-all-stage3-ppl
-all-stage4-gcc: maybe-all-stage4-ppl
-all-stageprofile-gcc: maybe-all-stageprofile-ppl
-all-stagefeedback-gcc: maybe-all-stagefeedback-ppl
 all-gcc: maybe-all-cloog
 
 all-stage1-gcc: maybe-all-stage1-cloog
@@ -42435,6 +46624,14 @@
 all-stage4-gcc: maybe-all-stage4-zlib
 all-stageprofile-gcc: maybe-all-stageprofile-zlib
 all-stagefeedback-gcc: maybe-all-stagefeedback-zlib
+all-gcc: all-libbacktrace
+
+all-stage1-gcc: all-stage1-libbacktrace
+all-stage2-gcc: all-stage2-libbacktrace
+all-stage3-gcc: all-stage3-libbacktrace
+all-stage4-gcc: all-stage4-libbacktrace
+all-stageprofile-gcc: all-stageprofile-libbacktrace
+all-stagefeedback-gcc: all-stagefeedback-libbacktrace
 all-gcc: all-libcpp
 
 all-stage1-gcc: all-stage1-libcpp
@@ -42503,6 +46700,7 @@
 install-gcc: maybe-install-fixincludes
 install-gcc: maybe-install-lto-plugin
 install-strip-gcc: maybe-install-strip-fixincludes
+install-strip-gcc: maybe-install-strip-lto-plugin
 configure-libcpp: configure-libiberty
 
 configure-stage1-libcpp: configure-stage1-libiberty
@@ -42562,30 +46760,30 @@
 configure-stage4-mpc: maybe-all-stage4-mpfr
 configure-stageprofile-mpc: maybe-all-stageprofile-mpfr
 configure-stagefeedback-mpc: maybe-all-stagefeedback-mpfr
-configure-ppl: maybe-all-gmp
+configure-isl: maybe-all-gmp
 
-configure-stage1-ppl: maybe-all-stage1-gmp
-configure-stage2-ppl: maybe-all-stage2-gmp
-configure-stage3-ppl: maybe-all-stage3-gmp
-configure-stage4-ppl: maybe-all-stage4-gmp
-configure-stageprofile-ppl: maybe-all-stageprofile-gmp
-configure-stagefeedback-ppl: maybe-all-stagefeedback-gmp
-configure-ppl: maybe-all-mpfr
+configure-stage1-isl: maybe-all-stage1-gmp
+configure-stage2-isl: maybe-all-stage2-gmp
+configure-stage3-isl: maybe-all-stage3-gmp
+configure-stage4-isl: maybe-all-stage4-gmp
+configure-stageprofile-isl: maybe-all-stageprofile-gmp
+configure-stagefeedback-isl: maybe-all-stagefeedback-gmp
+configure-cloog: maybe-all-isl
 
-configure-stage1-ppl: maybe-all-stage1-mpfr
-configure-stage2-ppl: maybe-all-stage2-mpfr
-configure-stage3-ppl: maybe-all-stage3-mpfr
-configure-stage4-ppl: maybe-all-stage4-mpfr
-configure-stageprofile-ppl: maybe-all-stageprofile-mpfr
-configure-stagefeedback-ppl: maybe-all-stagefeedback-mpfr
-configure-cloog: maybe-all-ppl
+configure-stage1-cloog: maybe-all-stage1-isl
+configure-stage2-cloog: maybe-all-stage2-isl
+configure-stage3-cloog: maybe-all-stage3-isl
+configure-stage4-cloog: maybe-all-stage4-isl
+configure-stageprofile-cloog: maybe-all-stageprofile-isl
+configure-stagefeedback-cloog: maybe-all-stagefeedback-isl
+configure-cloog: maybe-all-gmp
 
-configure-stage1-cloog: maybe-all-stage1-ppl
-configure-stage2-cloog: maybe-all-stage2-ppl
-configure-stage3-cloog: maybe-all-stage3-ppl
-configure-stage4-cloog: maybe-all-stage4-ppl
-configure-stageprofile-cloog: maybe-all-stageprofile-ppl
-configure-stagefeedback-cloog: maybe-all-stagefeedback-ppl
+configure-stage1-cloog: maybe-all-stage1-gmp
+configure-stage2-cloog: maybe-all-stage2-gmp
+configure-stage3-cloog: maybe-all-stage3-gmp
+configure-stage4-cloog: maybe-all-stage4-gmp
+configure-stageprofile-cloog: maybe-all-stageprofile-gmp
+configure-stagefeedback-cloog: maybe-all-stagefeedback-gmp
 configure-gdb: maybe-all-intl
 configure-gdb: maybe-configure-sim
 configure-gdb: maybe-all-bfd
@@ -42707,6 +46905,14 @@
 all-stage4-binutils: maybe-all-stage4-intl
 all-stageprofile-binutils: maybe-all-stageprofile-intl
 all-stagefeedback-binutils: maybe-all-stagefeedback-intl
+all-binutils: maybe-all-gas
+
+all-stage1-binutils: maybe-all-stage1-gas
+all-stage2-binutils: maybe-all-stage2-gas
+all-stage3-binutils: maybe-all-stage3-gas
+all-stage4-binutils: maybe-all-stage4-gas
+all-stageprofile-binutils: maybe-all-stageprofile-gas
+all-stagefeedback-binutils: maybe-all-stagefeedback-gas
 install-binutils: maybe-install-opcodes
 install-strip-binutils: maybe-install-strip-opcodes
 install-opcodes: maybe-install-bfd
@@ -42756,6 +46962,7 @@
 all-gprof: maybe-all-bfd
 all-gprof: maybe-all-opcodes
 all-gprof: maybe-all-intl
+all-gprof: maybe-all-gas
 configure-ld: maybe-configure-intl
 
 configure-stage1-ld: maybe-configure-stage1-intl
@@ -42812,6 +47019,14 @@
 all-stage4-ld: maybe-all-stage4-intl
 all-stageprofile-ld: maybe-all-stageprofile-intl
 all-stagefeedback-ld: maybe-all-stagefeedback-intl
+all-ld: maybe-all-gas
+
+all-stage1-ld: maybe-all-stage1-gas
+all-stage2-ld: maybe-all-stage2-gas
+all-stage3-ld: maybe-all-stage3-gas
+all-stage4-ld: maybe-all-stage4-gas
+all-stageprofile-ld: maybe-all-stageprofile-gas
+all-stagefeedback-ld: maybe-all-stagefeedback-gas
 install-ld: maybe-install-gold
 install-strip-ld: maybe-install-strip-gold
 configure-gold: maybe-configure-intl
@@ -42854,6 +47069,14 @@
 all-stage4-gold: maybe-all-build-bison
 all-stageprofile-gold: maybe-all-build-bison
 all-stagefeedback-gold: maybe-all-build-bison
+all-gold: maybe-all-gas
+
+all-stage1-gold: maybe-all-stage1-gas
+all-stage2-gold: maybe-all-stage2-gas
+all-stage3-gold: maybe-all-stage3-gas
+all-stage4-gold: maybe-all-stage4-gas
+all-stageprofile-gold: maybe-all-stageprofile-gas
+all-stagefeedback-gold: maybe-all-stagefeedback-gas
 check-gold: maybe-all-binutils
 
 check-stage1-gold: maybe-all-stage1-binutils
@@ -42949,7 +47172,9 @@
 all-target-fastjar: maybe-all-target-zlib
 configure-target-libgo: maybe-configure-target-libffi
 configure-target-libgo: maybe-all-target-libstdc++-v3
+all-target-libgo: maybe-all-target-libbacktrace
 all-target-libgo: maybe-all-target-libffi
+all-target-libgo: maybe-all-target-libatomic
 configure-target-libjava: maybe-configure-target-zlib
 configure-target-libjava: maybe-configure-target-boehm-gc
 configure-target-libjava: maybe-configure-target-libffi
@@ -42967,6 +47192,22 @@
 configure-stage4-target-libstdc++-v3: maybe-configure-stage4-target-libgomp
 configure-stageprofile-target-libstdc++-v3: maybe-configure-stageprofile-target-libgomp
 configure-stagefeedback-target-libstdc++-v3: maybe-configure-stagefeedback-target-libgomp
+configure-target-libsanitizer: maybe-all-target-libstdc++-v3
+
+configure-stage1-target-libsanitizer: maybe-all-stage1-target-libstdc++-v3
+configure-stage2-target-libsanitizer: maybe-all-stage2-target-libstdc++-v3
+configure-stage3-target-libsanitizer: maybe-all-stage3-target-libstdc++-v3
+configure-stage4-target-libsanitizer: maybe-all-stage4-target-libstdc++-v3
+configure-stageprofile-target-libsanitizer: maybe-all-stageprofile-target-libstdc++-v3
+configure-stagefeedback-target-libsanitizer: maybe-all-stagefeedback-target-libstdc++-v3
+configure-target-libvtv: maybe-all-target-libstdc++-v3
+
+configure-stage1-target-libvtv: maybe-all-stage1-target-libstdc++-v3
+configure-stage2-target-libvtv: maybe-all-stage2-target-libstdc++-v3
+configure-stage3-target-libvtv: maybe-all-stage3-target-libstdc++-v3
+configure-stage4-target-libvtv: maybe-all-stage4-target-libstdc++-v3
+configure-stageprofile-target-libvtv: maybe-all-stageprofile-target-libstdc++-v3
+configure-stagefeedback-target-libvtv: maybe-all-stagefeedback-target-libstdc++-v3
 all-target-libstdc++-v3: maybe-configure-target-libgomp
 
 all-stage1-target-libstdc++-v3: maybe-configure-stage1-target-libgomp
@@ -42975,6 +47216,17 @@
 all-stage4-target-libstdc++-v3: maybe-configure-stage4-target-libgomp
 all-stageprofile-target-libstdc++-v3: maybe-configure-stageprofile-target-libgomp
 all-stagefeedback-target-libstdc++-v3: maybe-configure-stagefeedback-target-libgomp
+install-target-libgo: maybe-install-target-libatomic
+install-target-libgfortran: maybe-install-target-libquadmath
+install-target-libgfortran: maybe-install-target-libgcc
+install-target-libsanitizer: maybe-install-target-libstdc++-v3
+install-target-libsanitizer: maybe-install-target-libgcc
+install-target-libvtv: maybe-install-target-libstdc++-v3
+install-target-libvtv: maybe-install-target-libgcc
+install-target-libjava: maybe-install-target-libgcc
+install-target-libitm: maybe-install-target-libgcc
+install-target-libobjc: maybe-install-target-libgcc
+install-target-libstdc++-v3: maybe-install-target-libgcc
 all-target-libgloss: maybe-all-target-newlib
 all-target-winsup: maybe-all-target-libtermcap
 configure-target-newlib: maybe-all-binutils
@@ -42994,6 +47246,18 @@
 configure-stage4-target-libstdc++-v3: maybe-all-stage4-target-libgcc
 configure-stageprofile-target-libstdc++-v3: maybe-all-stageprofile-target-libgcc
 configure-stagefeedback-target-libstdc++-v3: maybe-all-stagefeedback-target-libgcc
+configure-stage1-target-libsanitizer: maybe-all-stage1-target-libgcc
+configure-stage2-target-libsanitizer: maybe-all-stage2-target-libgcc
+configure-stage3-target-libsanitizer: maybe-all-stage3-target-libgcc
+configure-stage4-target-libsanitizer: maybe-all-stage4-target-libgcc
+configure-stageprofile-target-libsanitizer: maybe-all-stageprofile-target-libgcc
+configure-stagefeedback-target-libsanitizer: maybe-all-stagefeedback-target-libgcc
+configure-stage1-target-libvtv: maybe-all-stage1-target-libgcc
+configure-stage2-target-libvtv: maybe-all-stage2-target-libgcc
+configure-stage3-target-libvtv: maybe-all-stage3-target-libgcc
+configure-stage4-target-libvtv: maybe-all-stage4-target-libgcc
+configure-stageprofile-target-libvtv: maybe-all-stageprofile-target-libgcc
+configure-stagefeedback-target-libvtv: maybe-all-stagefeedback-target-libgcc
 configure-stage1-target-libgomp: maybe-all-stage1-target-libgcc
 configure-stage2-target-libgomp: maybe-all-stage2-target-libgcc
 configure-stage3-target-libgomp: maybe-all-stage3-target-libgcc
@@ -43005,8 +47269,11 @@
 @if gcc-no-bootstrap
 configure-target-libstdc++-v3: maybe-all-target-libgcc
 configure-target-libmudflap: maybe-all-target-libgcc
+configure-target-libsanitizer: maybe-all-target-libgcc
+configure-target-libvtv: maybe-all-target-libgcc
 configure-target-libssp: maybe-all-target-libgcc
 configure-target-newlib: maybe-all-target-libgcc
+configure-target-libbacktrace: maybe-all-target-libgcc
 configure-target-libquadmath: maybe-all-target-libgcc
 configure-target-libgfortran: maybe-all-target-libgcc
 configure-target-libobjc: maybe-all-target-libgcc
@@ -43021,6 +47288,8 @@
 configure-target-rda: maybe-all-target-libgcc
 configure-target-libada: maybe-all-target-libgcc
 configure-target-libgomp: maybe-all-target-libgcc
+configure-target-libitm: maybe-all-target-libgcc
+configure-target-libatomic: maybe-all-target-libgcc
 @endif gcc-no-bootstrap
 
 
@@ -43028,10 +47297,16 @@
 
 configure-target-libmudflap: maybe-all-target-newlib maybe-all-target-libgloss
 
+configure-target-libsanitizer: maybe-all-target-newlib maybe-all-target-libgloss
+
+configure-target-libvtv: maybe-all-target-newlib maybe-all-target-libgloss
+
 configure-target-libssp: maybe-all-target-newlib maybe-all-target-libgloss
 
 
 
+configure-target-libbacktrace: maybe-all-target-newlib maybe-all-target-libgloss
+
 configure-target-libquadmath: maybe-all-target-newlib maybe-all-target-libgloss
 
 configure-target-libgfortran: maybe-all-target-newlib maybe-all-target-libgloss
@@ -43060,6 +47335,11 @@
 
 configure-target-libgomp: maybe-all-target-newlib maybe-all-target-libgloss
 
+configure-target-libitm: maybe-all-target-newlib maybe-all-target-libgloss
+configure-target-libitm: maybe-all-target-libstdc++-v3
+
+configure-target-libatomic: maybe-all-target-newlib maybe-all-target-libgloss
+
 
 CONFIGURE_GDB_TK = @CONFIGURE_GDB_TK@
 GDB_TK = @GDB_TK@
diff --git a/Makefile.tpl b/Makefile.tpl
index 4dd2391..3233a78 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -6,7 +6,7 @@
 #
 # Makefile for directory with subdirs to build.
 #   Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-#   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+#   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 #   Free Software Foundation
 #
 # This file is free software; you can redistribute it and/or modify
@@ -209,6 +209,7 @@
 	WINDMC="$(WINDMC)"; export WINDMC; \
 	OBJCOPY="$(OBJCOPY)"; export OBJCOPY; \
 	OBJDUMP="$(OBJDUMP)"; export OBJDUMP; \
+	READELF="$(READELF)"; export READELF; \
 	AR_FOR_TARGET="$(AR_FOR_TARGET)"; export AR_FOR_TARGET; \
 	AS_FOR_TARGET="$(AS_FOR_TARGET)"; export AS_FOR_TARGET; \
 	GCC_FOR_TARGET="$(GCC_FOR_TARGET)"; export GCC_FOR_TARGET; \
@@ -216,12 +217,12 @@
 	NM_FOR_TARGET="$(NM_FOR_TARGET)"; export NM_FOR_TARGET; \
 	OBJDUMP_FOR_TARGET="$(OBJDUMP_FOR_TARGET)"; export OBJDUMP_FOR_TARGET; \
 	RANLIB_FOR_TARGET="$(RANLIB_FOR_TARGET)"; export RANLIB_FOR_TARGET; \
+	READELF_FOR_TARGET="$(READELF_FOR_TARGET)"; export READELF_FOR_TARGET; \
 	TOPLEVEL_CONFIGURE_ARGUMENTS="$(TOPLEVEL_CONFIGURE_ARGUMENTS)"; export TOPLEVEL_CONFIGURE_ARGUMENTS; \
 	HOST_LIBS="$(STAGE1_LIBS)"; export HOST_LIBS; \
 	GMPLIBS="$(HOST_GMPLIBS)"; export GMPLIBS; \
 	GMPINC="$(HOST_GMPINC)"; export GMPINC; \
-	PPLLIBS="$(HOST_PPLLIBS)"; export PPLLIBS; \
-	PPLINC="$(HOST_PPLINC)"; export PPLINC; \
+	ISLINC="$(HOST_ISLINC)"; export ISLINC; \
 	CLOOGLIBS="$(HOST_CLOOGLIBS)"; export CLOOGLIBS; \
 	CLOOGINC="$(HOST_CLOOGINC)"; export CLOOGINC; \
 	LIBELFLIBS="$(HOST_LIBELFLIBS)" ; export LIBELFLIBS; \
@@ -237,7 +238,7 @@
 @if target-libstdc++-v3-bootstrap
 # Override the above if we're bootstrapping C++.
 POSTSTAGE1_CXX_EXPORT = \
-	CXX="$(STAGE_CC_WRAPPER) $$r/$(HOST_SUBDIR)/prev-gcc/g++$(exeext) \
+	CXX="$(STAGE_CC_WRAPPER) $$r/$(HOST_SUBDIR)/prev-gcc/xg++$(exeext) \
 	  -B$$r/$(HOST_SUBDIR)/prev-gcc/ -B$(build_tooldir)/bin/ -nostdinc++ \
 	  -B$$r/prev-$(TARGET_SUBDIR)/libstdc++-v3/src/.libs \
 	  -B$$r/prev-$(TARGET_SUBDIR)/libstdc++-v3/libsupc++/.libs \
@@ -288,6 +289,7 @@
 	NM="$(COMPILER_NM_FOR_TARGET)"; export NM; \
 	OBJDUMP="$(OBJDUMP_FOR_TARGET)"; export OBJDUMP; \
 	RANLIB="$(RANLIB_FOR_TARGET)"; export RANLIB; \
+	READELF="$(READELF_FOR_TARGET)"; export READELF; \
 	STRIP="$(STRIP_FOR_TARGET)"; export STRIP; \
 	WINDRES="$(WINDRES_FOR_TARGET)"; export WINDRES; \
 	WINDMC="$(WINDMC_FOR_TARGET)"; export WINDMC; \
@@ -310,9 +312,8 @@
 HOST_GMPLIBS = @gmplibs@
 HOST_GMPINC = @gmpinc@
 
-# Where to find PPL
-HOST_PPLLIBS = @ppllibs@
-HOST_PPLINC = @pplinc@
+# Where to find ISL
+HOST_ISLINC = @islinc@
 
 # Where to find CLOOG
 HOST_CLOOGLIBS = @clooglibs@
@@ -366,7 +367,7 @@
 # here so that they can be overridden by Makefile fragments.
 BOOT_CFLAGS= -g -O2
 BOOT_LDFLAGS=
-BOOT_ADAFLAGS=-gnatpg -gnata
+BOOT_ADAFLAGS= -gnatpg
 
 AWK = @AWK@
 SED = @SED@
@@ -400,6 +401,7 @@
 NM = @NM@
 OBJDUMP = @OBJDUMP@
 RANLIB = @RANLIB@
+READELF = @READELF@
 STRIP = @STRIP@
 WINDRES = @WINDRES@
 WINDMC = @WINDMC@
@@ -421,7 +423,6 @@
 STAGE_CFLAGS = $(BOOT_CFLAGS)
 STAGE_TFLAGS = $(TFLAGS)
 STAGE_CONFIGURE_FLAGS=@stage2_werror_flag@
-POSTSTAGE1_CONFIGURE_FLAGS = @POSTSTAGE1_CONFIGURE_FLAGS@
 
 [+ FOR bootstrap-stage +]
 # Defaults for stage [+id+]; some are overridden below.
@@ -432,10 +433,7 @@
 STAGE[+id+]_CXXFLAGS = $(STAGE[+id+]_CFLAGS)
 @endif target-libstdc++-v3-bootstrap
 STAGE[+id+]_TFLAGS = $(STAGE_TFLAGS)
-# STAGE1_CONFIGURE_FLAGS overridden below, so we can use
-# POSTSTAGE1_CONFIGURE_FLAGS here.
-STAGE[+id+]_CONFIGURE_FLAGS = \
-	$(STAGE_CONFIGURE_FLAGS) $(POSTSTAGE1_CONFIGURE_FLAGS)
+STAGE[+id+]_CONFIGURE_FLAGS = $(STAGE_CONFIGURE_FLAGS)
 [+ ENDFOR bootstrap-stage +]
 
 # Only build the C compiler for stage1, because that is the only one that
@@ -453,9 +451,6 @@
 #   the last argument when conflicting --enable arguments are passed.
 # * Likewise, we force-disable coverage flags, since the installed
 #   compiler probably has never heard of them.
-# * Don't remove this, because above we added
-#   POSTSTAGE1_CONFIGURE_FLAGS to STAGE[+id+]_CONFIGURE_FLAGS, which
-#   we don't want for STAGE1_CONFIGURE_FLAGS.
 STAGE1_CONFIGURE_FLAGS = --disable-intermodule $(STAGE1_CHECKING) \
 	  --disable-coverage --enable-languages="$(STAGE1_LANGUAGES)"
 
@@ -493,6 +488,7 @@
 NM_FOR_TARGET=@NM_FOR_TARGET@
 OBJDUMP_FOR_TARGET=@OBJDUMP_FOR_TARGET@
 RANLIB_FOR_TARGET=@RANLIB_FOR_TARGET@
+READELF_FOR_TARGET=@READELF_FOR_TARGET@
 STRIP_FOR_TARGET=@STRIP_FOR_TARGET@
 WINDRES_FOR_TARGET=@WINDRES_FOR_TARGET@
 WINDMC_FOR_TARGET=@WINDMC_FOR_TARGET@
@@ -612,12 +608,19 @@
 	'NM=$(NM)' \
 	'OBJDUMP=$(OBJDUMP)' \
 	'RANLIB=$(RANLIB)' \
+	'READELF=$(READELF)' \
 	'STRIP=$(STRIP)' \
 	'WINDRES=$(WINDRES)' \
 	'WINDMC=$(WINDMC)'
 
 FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS)
 
+# Flags to pass to stage1 or when not bootstrapping.
+
+STAGE1_FLAGS_TO_PASS = \
+	LDFLAGS="$${LDFLAGS}" \
+	HOST_LIBS="$${HOST_LIBS}"
+
 # Flags to pass to stage2 and later makes.
 
 POSTSTAGE1_FLAGS_TO_PASS = \
@@ -652,6 +655,7 @@
 	'NM=$(COMPILER_NM_FOR_TARGET)' \
 	'OBJDUMP=$$(OBJDUMP_FOR_TARGET)' \
 	'RANLIB=$$(RANLIB_FOR_TARGET)' \
+	'READELF=$$(READELF_FOR_TARGET)' \
 	'WINDRES=$$(WINDRES_FOR_TARGET)' \
 	'WINDMC=$$(WINDMC_FOR_TARGET)' \
 	'XGCC_FLAGS_FOR_TARGET=$(XGCC_FLAGS_FOR_TARGET)' \
@@ -668,10 +672,7 @@
 EXTRA_GCC_FLAGS = \
 	"GCC_FOR_TARGET=$(GCC_FOR_TARGET)" \
 	"`echo 'STMP_FIXPROTO=$(STMP_FIXPROTO)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
-	"`echo 'LIMITS_H_TEST=$(LIMITS_H_TEST)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
-	"`echo 'LIBGCC2_CFLAGS=$(LIBGCC2_CFLAGS)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
-	"`echo 'LIBGCC2_DEBUG_CFLAGS=$(LIBGCC2_DEBUG_CFLAGS)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
-	"`echo 'LIBGCC2_INCLUDES=$(LIBGCC2_INCLUDES)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`"
+	"`echo 'LIMITS_H_TEST=$(LIMITS_H_TEST)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`"
 
 GCC_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(EXTRA_GCC_FLAGS)
 
@@ -902,11 +903,12 @@
 		true ; \
 	fi
 
-# install-no-fixedincludes is used because Cygnus can not distribute
-# the fixed header files.
+# install-no-fixedincludes is used to allow the elaboration of binary packages
+# suitable for distribution, where we cannot include the fixed system header
+# files.
 .PHONY: install-no-fixedincludes
 install-no-fixedincludes: installdirs install-host-nogcc \
-	install-target gcc-no-fixedincludes
+	install-target gcc-install-no-fixedincludes
 
 .PHONY: install-strip
 install-strip:
@@ -1080,7 +1082,7 @@
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	[+exports+] [+extra_exports+] \
 	(cd [+subdir+]/[+module+] && \
-	  $(MAKE) $(BASE_FLAGS_TO_PASS) [+args+] [+extra_make_flags+] \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) [+args+] [+stage1_args+] [+extra_make_flags+] \
 		$(TARGET-[+prefix+][+module+]))
 @endif [+prefix+][+module+]
 
@@ -1113,9 +1115,8 @@
 		CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
 		CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
 		LIBCFLAGS_FOR_TARGET="$(LIBCFLAGS_FOR_TARGET)" \
-		[+args+] [+
-		IF prev +][+poststage1_args+][+ ENDIF prev
-		+] [+extra_make_flags+] \
+		[+args+] [+IF prev +][+poststage1_args+][+ ELSE prev +] \
+		[+stage1_args+][+ ENDIF prev +] [+extra_make_flags+] \
 		TFLAGS="$(STAGE[+id+]_TFLAGS)" \
 		$(TARGET-stage[+id+]-[+prefix+][+module+])
 
@@ -1129,9 +1130,8 @@
 	  $(MAKE) stage[+id+]-start; \
 	fi; \
 	cd [+subdir+]/[+module+] && \
-	$(MAKE) [+args+] [+ IF prev +] \
-		[+poststage1_args+] [+ ENDIF prev +] \
-		[+extra_make_flags+] clean
+	$(MAKE) [+args+] [+ IF prev +][+poststage1_args+][+ ELSE prev +] \
+	[+stage1_args+][+ ENDIF prev +] [+extra_make_flags+] clean
 @endif [+prefix+][+module+]-bootstrap
 
 [+ ENDFOR bootstrap_stage +]
@@ -1166,6 +1166,7 @@
        exports="$(HOST_EXPORTS)"
        poststage1_exports="$(POSTSTAGE1_HOST_EXPORTS)"
        args="$(EXTRA_HOST_FLAGS)"
+       stage1_args="$(STAGE1_FLAGS_TO_PASS)"
        poststage1_args="$(POSTSTAGE1_FLAGS_TO_PASS)" +]
 
 .PHONY: check-[+module+] maybe-check-[+module+]
@@ -1410,6 +1411,20 @@
 
 @endif target-libmudflap
 
+@if target-libgomp
+.PHONY: check-target-libgomp-c++
+check-target-libgomp-c++:
+	$(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) c++.exp" check-target-libgomp
+
+@endif target-libgomp
+
+@if target-libitm
+.PHONY: check-target-libitm-c++
+check-target-libitm-c++:
+	$(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) c++.exp" check-target-libitm
+
+@endif target-libitm
+
 # ----------
 # GCC module
 # ----------
@@ -1439,25 +1454,16 @@
 check-[+language+]: check-gcc-[+language+][+ FOR lib-check-target +] [+ lib-check-target +][+ ENDFOR lib-check-target +]
 [+ ENDFOR languages +]
 
-# Install the gcc headers files, but not the fixed include files,
-# which Cygnus is not allowed to distribute.  This rule is very
-# dependent on the workings of the gcc Makefile.in.
-.PHONY: gcc-no-fixedincludes
-gcc-no-fixedincludes:
+# The gcc part of install-no-fixedincludes, which relies on an intimate
+# knowledge of how a number of gcc internal targets (inter)operate.  Delegate.
+.PHONY: gcc-install-no-fixedincludes
+gcc-install-no-fixedincludes:
 	@if [ -f ./gcc/Makefile ]; then \
-	  rm -rf gcc/tmp-include; \
-	  mv gcc/include gcc/tmp-include 2>/dev/null; \
-	  mkdir gcc/include; \
-	  cp $(srcdir)/gcc/gsyslimits.h gcc/include/syslimits.h; \
-	  touch gcc/stmp-fixinc gcc/include/fixed; \
-	  rm -f gcc/stmp-headers gcc/stmp-int-hdrs; \
 	  r=`${PWD_COMMAND}`; export r; \
-	  s=`cd $(srcdir); ${PWD_COMMAND}` ; export s; \
+	  s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	  $(HOST_EXPORTS) \
-	  (cd ./gcc && \
-	   $(MAKE) $(GCC_FLAGS_TO_PASS) install); \
-	  rm -rf gcc/include; \
-	  mv gcc/tmp-include gcc/include 2>/dev/null; \
+	  (cd ./gcc \
+	   && $(MAKE) $(GCC_FLAGS_TO_PASS) install-no-fixedincludes); \
 	else true; fi
 @endif gcc
 
diff --git a/OWNERS b/OWNERS
deleted file mode 100644
index fdf94a7..0000000
--- a/OWNERS
+++ /dev/null
@@ -1,6 +0,0 @@
-set noparent
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
diff --git a/README.google b/README.google
index d6bc446..39998e0 100644
--- a/README.google
+++ b/README.google
@@ -1,4 +1,4 @@
-Patches applied to binutils-2.22:
+Patches applied to binutils-2.24:
 
 Please include a change to this file with each patch, *and* each
 subsequent modification of the patch.  Do NOT combine patch
@@ -17,35 +17,6 @@
 DO NOT add entries to the GNU ChangeLog files.
 
 gas/as.c
-  Status: local
-  Owner: eraman
-  Ignore --save-temps flag (to enable use of the GNU assembler with a
-  compiler that passes --save-temps for MAO).
-
-
-gold/dwarf_reader.cc
-gold/i386.cc
-gold/resolve.cc
-gold/x86_64.cc
-  Status: Upstream
-  Owner: ccoutant
-  Fix C++11 warnings about narrowing in initializers.
-  http://sourceware.org/ml/binutils-cvs/2011-12/msg00095.html
-
-gold/options.cc
-  Status: Backport
-  Owner: ccoutant
-  Backport dnovillo's patch to fix bug in option parsing.
-  http://sourceware.org/ml/binutils-cvs/2011-10/msg00006.html
-
-gold/testsuite/Makefile.am
-gold/testsuite/Makefile.in
-  Status: local
-  Owner: aaw
-  Disable the initpri3b test.  GCC 4.7 no longer executes functions from the
-  .ctors and .dtors sections when built against binutils-2.22.
-
-gas/as.c
 gas/as.h
 gas/doc/as.texinfo
 gas/read.c
@@ -54,9 +25,15 @@
   Owner: aaw
   Disable .incbin, unless explicitly enabled with new flag --allow-incbin.
 
-bfd/doc/bfd.info
 binutils/doc/Makefile.am
 binutils/doc/Makefile.in
+gas/doc/Makefile.am
+gas/doc/Makefile.in
+gprof/Makefile.am
+gprof/Makefile.in
+ld/Makefile.am
+ld/Makefile.in
+bfd/doc/bfd.info   # delete this and all following:
 binutils/doc/addr2line.1
 binutils/doc/ar.1
 binutils/doc/binutils.info
@@ -75,1016 +52,44 @@
 binutils/doc/windres.1
 etc/configure.info
 etc/standards.info
-gas/doc/Makefile.am
-gas/doc/Makefile.in
 gas/doc/as.1
 gas/doc/as.info
-gprof/Makefile.am
-gprof/Makefile.in
 gprof/gprof.1
 gprof/gprof.info
-ld/Makefile.am
-ld/Makefile.in
 ld/ld.1
 ld/ld.info
   Status: local
-  Owner: aaw
+  Owner: bmoses
   Remove all pre-formatted manual and info pages so that they will
   consistently be formatted during the build process.  When formatting them,
   pass --date=" " to pod2man to avoid including build dates.
 
-gas/config/tc-arm.c
-  Status: local workaround
-  Owner: kbaclawski
-  Fixed an uninitialized variable warning in line 6569 (under gcc 4.4.3), that
-  prevented arm-linux-gnueabi targeted cross compiler to build cleanly.
-
-ltmain.sh
-  Status: libtool 74c8993c178a1386ea5e2363a01d919738402f30 (not in binutils yet)
-  Owner: cgd
-  Sort output of 'find' to ensure deterministic builds.
-
-gold/Makefile.am
-gold/Makefile.in
-gold/configure
-gold/configure.ac
-gold/testsuite/Makefile.in
-  Status: Backport
-  Owner: simonb
-  Backport upstream fix that adds --with-gold-ldflags and --with-gold-ldadd.
-  http://sourceware.org/ml/binutils/2011-09/msg00123.html
-
-gold/gold.cc
-gold/options.cc
-gold/incremental.cc
-gold/symtab.cc
-  Status: Backport
-  Owner: ccoutant
-  Integrate CLs 55764 and 55815 from binutils-2.21.
-  (55764) Backport upstream patch to fix problem with incremental linking and
-  --gc-sections.
-  http://sourceware.org/ml/binutils-cvs/2011-09/msg00099.html
-  (55815) Backport upstream patch to fix problems with incremental linking and
-  shared libraries when all references to a PLT come from changed files.
-  Also fixes a problem when a changed object file references a versioned
-  symbol defined in an unchanged shared library.
-  http://sourceware.org/ml/binutils-cvs/2011-09/msg00124.html
-
-gold/gold.cc
-gold/plugin.cc
-gold/layout.cc
-gold/layout.h
-gold/plugin.cc
-gold/plugin.h
-gold/testsuite/Makefile.am
-gold/testsuite/Makefile.in
-gold/testsuite/plugin_final_layout.sh
-gold/testsuite/plugin_final_layout.cc
-gold/testsuite/plugin_section_order.c
-  Status: Backport
-  Owner: tmsriram
-  Integrate CL 55837 from binutils-2.21.
-  Backport upstream patch to fix a bug in plugin section order and delayed
-  layout.
-  http://www.cygwin.com/ml/binutils/2011-09/msg00265.html
-
-include/demangle.h
-libiberty/cp-demangle.c
-libiberty/testsuite/demangle-expected
-  Status: Backport
-  Owner: ppluzhnikov
-  Integrate CLs 55889 and 55914 from binutils-2.21.
-  For http://b/2713120, backport Cary's upstream fix to demangle cloned
-  functions.
-  http://gcc.gnu.org/ml/gcc-patches/2011-02/msg01545.html
-  http://gcc.gnu.org/viewcvs?view=revision&revision=179132
-
-gold/output.cc
-gold/output.h
-gold/powerpc.cc
-gold/sparc.cc
-gold/x86_64.cc
-  Status: Backport
-  Owner: ccoutant
-  [Originally backported to binutils-2.21 as part of CL 56015.]
-  Backport upstream patch for PR gold/13249 (gold creates incorrect RELATIVE
-  dynamic relocation for local IFUNC GOT entries).
-  http://sourceware.org/ml/binutils-cvs/2011-10/msg00040.html
-
-gold/fileread.cc
-gold/incremental.cc
-gold/incremental.h
-gold/output.cc
-gold/plugin.cc
-gold/readsyms.cc
-  Status: Backport
-  Owner: ccoutant
-  Integrate CLs 56018, 56036, 56110, 56146, 56151 from binutils-2.21.
-  (56018) Backport upstream patch to add support for --print-symbol-counts
-  for incremental links and plugins.
-  http://sourceware.org/ml/binutils-cvs/2011-10/msg00041.html
-  (56036) Backport upstream patch to fix problem with --incremental-base when
-  base file is too large.
-  http://sourceware.org/ml/binutils-cvs/2011-10/msg00055.html
-  (56110) Backport upstream patch to fix problem detecting truncated or
-  corrupt files.
-  http://sourceware.org/ml/binutils-cvs/2011-10/msg00078.html
-  (56146) Backport upstream patch to fix crash when member of lib group
-  can't be opened.
-  http://sourceware.org/ml/binutils-cvs/2011-10/msg00080.html
-  (56151) Backport upstream patch to fix problem detecting out-of-space
-  condition when calling posix_fallocate.
-  http://sourceware.org/ml/binutils-cvs/2011-10/msg00086.html
-
-gold/expression.cc
-gold/i386.cc
-gold/options.h
-gold/script.cc
-gold/script.h
-gold/script-sections.cc
-gold/symtab.cc
-gold/symtab.cc
-gold/symtab.h
-gold/x86_64.cc
-gold/testsuite/script_test_2.t
-  Status: Backport
-  Owner: ccoutant
-  Integrate CLs 56268, 56366, 56367, 56368, 56708 from binutils-2.21.
-  (56268) Add --no-gnu-unique option to disable STB_GNU_UNIQUE binding.
-  (Adapted from CL 49473.)
-  (56366) Backport upstream patch to fix internal error on TLS relocation.
-  http://sourceware.org/ml/binutils-cvs/2011-10/msg00186.html
-  (56367) Backport upstream patch to fix problems with assignment to dot in
-  linker scripts.
-  http://sourceware.org/ml/binutils-cvs/2011-10/msg00188.html
-  (56368) Backport upstream patch to not gc symbols that go into dynamic
-  symbol table.
-  http://cygwin.com/ml/binutils/2011-10/msg00306.html
-  (56708) Backport upstream patch to fix linker crash.
-  http://www.cygwin.com/ml/binutils-cvs/2011-10/msg00095.html
-
-gprof/hist.c
-  Status: Backport
-  Owner: carrot
-  Integrate CL 56274 from binutils-2.21.
-  Backport upstream patch to fix the out of range of an array index in gprof.
-  http://sourceware.org/bugzilla/show_bug.cgi?id=13325.
-
-binutils/Makefile.am
-binutils/Makefile.in
-  Status: Backport
-  Owner: yunlian
-  Integrate CL 56431 from binutils-2.21.
-  Backport upstream patch to fix out of treebuilding with syslex regens.
-  http://sourceware.org/ml/binutils-cvs/2011-10/msg00158.html
-
-gold/arm.cc
-  Status: Upstream
-  Owner: dougkwan
-  Integrate CL 58241 from binutils-2.21.
-  Fix PIE crashes on ARM.
-  http://sourceware.org/ml/binutils-cvs/2012-02/msg00012.html
-
-gas/config/tc-i386.c
-gas/config/tc-i386.h
+gas/testsuite/gas/aarch64/mapmisc.d
   Status: local
-  Owner: martint
-  Move types/enums/structs/macros used by MAO into header-file.
+  Owner: bmoses
+  Add "--allow-incbin" directive to avoid errors with .incbin patch.
 
-gold/dirsearch.cc
-gold/dirsearch.h
-gold/script.cc.cc
-gold/yyscript.y
-  Status: Backport
-  Owner: saugustine
-  Integrate CLs 56741, 56860 from binutils-2.21.
-  (56741) Backport upstream patch to fix INCLUDE syntax errors.
-  http://sourceware.org/ml/binutils/2011-11/msg00089.html
-  (56860) Backport upstream patch to implement INCLUDE directive.
-  http://sourceware.org/ml/binutils/2011-11/msg00165.html
-
-ld/lexsup.c
-  Status: Local
-  Owner: dougkwan
-  Add dummy --icf option to ld for gold compatibility.
-
-elfcpp/dwarf.h
-gold/dwarf_reader.cc
-gold/reduced_debug_output.cc
-  Status: Backport
-  Update DWARF enums with DWARF-4 and Fission extensions.
-  Fix bug in handling of DW_LNE_define_file opcode.
-  http://sourceware.org/ml/binutils-cvs/2012-03/msg00043.html
-  http://sourceware.org/ml/binutils-cvs/2012-03/msg00044.html
-
-gas/testsuite/gas/arm/mapmisc.d
-  Status: Google local
-  Owner: dougkwan
-  Integrate CL 55082 from binutils-2.21.
-  Enable .incbin to make test pass.
-
-gold/int_encoding.cc
-gold/int_encoding.h
-gold/testsuite/Makefile.am
-gold/testsuite/Makefile.in
-gold/testsuite/leb128_unittest.cc
-  Status: Backport
-  Owner: ccoutant
-  Port CL 58078 from binutils-2.21.
-  Add inlined fast path for decoding LEB128 numbers.
-  Backport from upstream patch:
-  http://sourceware.org/ml/binutils-cvs/2012-01/msg00118.html
-
-gold/arm.cc
-  Status: Backport
-  Owner: dougkwan
-  Backport fix from upstream for ARM regression.
-  http://sourceware.org/ml/binutils-cvs/2012-03/msg00059.html
-
-gold/arm.cc
-gold/gold.cc
-gold/target.h
-gold/testsuite/Makefile.am
-gold/testsuite/Makefile.in
-gold/testsuite/arm_exidx_test.s
-gold/testsuite/arm_exidx_test.sh
-  Status: Backport
-  Owner: dougkwan
-  Backport fix from upstream for __exidx_start & __exidx_end section
-  symbols on ARM.
-  http://sourceware.org/ml/binutils-cvs/2012-03/msg00086.html
-
-gold/arm.cc
-gold/layout.cc
-  Status: Backport
-  Owner: dougkwan
-  Backport fix from upstream for -z relro.
-  http://sourceware.org/ml/binutils-cvs/2012-03/msg00064.html
-  http://sourceware.org/ml/binutils-cvs/2012-03/msg00067.html
-
-gold/incremental.cc
-  Status: Local
-  Owner: ccoutant
-  Incremental linker performance:
-  Don't store section names in incremental info (unless debugging).
-
-gold/dwarf_reader.cc
-gold/dwarf_reader.h
-gold/gdb-index.cc
-gold/gdb-index.h
-gold/merge.cc
-gold/object.cc
-gold/object.h
-gold/readsyms.cc
-gold/testsuite/gdb_index_test.cc
-gold/testsuite/gdb_index_test_1.sh
-gold/testsuite/gdb_index_test_2.sh
-  Status: Backport
-  Owner: ccoutant
-  Backport support for pre-decompressed debug sections and --gdb-index option.
-  http://sourceware.org/ml/binutils-cvs/2012-02/msg00137.html
-  http://sourceware.org/ml/binutils-cvs/2012-03/msg00001.html
-  http://sourceware.org/ml/binutils-cvs/2012-03/msg00094.html
-
-gold/Makefile.am
-gold/Makefile.in
-gold/dynobj.h
-gold/incremental.cc
-gold/incremental.h
-gold/layout.cc
-gold/layout.h
-gold/main.cc
-gold/options.h
-gold/plugin.cc
-gold/plugin.h
-gold/reloc.h
-gold/testsuite/Makefile.am
-gold/testsuite/Makefile.in
-gold/testsuite/gdb_index_test.cc
-gold/testsuite/gdb_index_test_1.sh
-gold/testsuite/gdb_index_test_2.sh
-  Status: Backport
-  Owner: ccoutant
-  Checkin rest of above patch to support --gdb-index option.
-
-gold/gdb-index.cc
-  Status: Backport
-  Owner: ccoutant
-  Fix problem with --gdb-index where DW_AT_low_pc/high_pc is ignored.
-  http://sourceware.org/ml/binutils-cvs/2012-04/msg00031.html
-
-gold/archive.cc
-gold/options.h
-gold/symtab.cc
-  Status: Backport
-  Owner: ccoutant
-  Add --export-dynamic-symbol option.
-  http://sourceware.org/ml/binutils/2012-04/msg00128.html
-
-binutils/doc/binutils.texi
-binutils/objcopy.c
-  Status: Backport
-  Owner: ccoutant
-  Fix strip/objcopy to produce deterministic output when stripping archives.
-  http://sourceware.org/ml/binutils-cvs/2012-04/msg00102.html
-
-bfd/elfcode.h
-  Status: backport
-  Owner: ppluzhnikov
-  For b/6410576, backport fix for PR binutils/12451
-  http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elfcode.h.diff?cvsroot=src&r1=1.109&r2=1.111
-
-gold/options.cc
-  Status: Upstream
-  Owner: ccoutant
-  Integrate CL 58455 from binutils-2.21.
-  Backport fix for internal error when -pie and -static are both on.
-  http://sourceware.org/ml/binutils-cvs/2012-02/msg00074.html
-
-binutils/doc/binutils.texi
-binutils/dwarf.c
-binutils/dwarf.h
-binutils/objdump.c
-binutils/readelf.c
-include/dwarf2.h
-  Status: Upstream
-  Owner: ccoutant
-  Backport Fission support for objdump/readelf.
-  http://sourceware.org/ml/binutils-cvs/2012-01/msg00123.html
-  http://sourceware.org/ml/binutils-cvs/2012-01/msg00123.html
-  http://sourceware.org/ml/binutils-cvs/2012-05/msg00009.html
-  http://sourceware.org/ml/binutils-cvs/2012-05/msg00072.html
-
-binutils/doc/binutils.texi
-binutils/objcopy.c
-  Status: Upstream
-  Owner: ccoutant
-  Backport Fission support for objcopy/strip.
-  http://sourceware.org/ml/binutils-cvs/2012-05/msg00049.html
-
-gold/layout.cc
-gold/testsuite/relro_test.cc
-  Status: Backport
-  Owner: ccoutant
-  Backport fix for problem with -z relro.
-  http://sourceware.org/ml/binutils-cvs/2012-05/msg00087.html
-
-gold/symtab.cc
-  Status: Backport
-  Owner: ccoutant
-  Backport upstream patch to fix problem with --export-dynamic-symbol when
-  a versioned symbol is found in a shared object (b/6529486).
-  http://sourceware.org/ml/binutils/2012-05/msg00331.html
-
-gold/symtab.cc
-  Status: Backport
-  Owner: ccoutant
-  Update fix for b/6529486 to match upstream commit.
-  http://sourceware.org/ml/binutils-cvs/2012-05/msg00170.html
-
-ld/scripttempl/armbpabi.sc
-ld/scripttempl/elf.sc
-ld/scripttempl/elf64hppa.sc
-ld/scripttempl/elfxtensa.sc
-ld/scripttempl/mep.sc
-gold/layout.cc
-  Status: Backport
-  Owner: ccoutant
-  Backport gold and gnu ld fixes for problem with relro and symbols that
-  begin with "ro" (b/6543153).
-  http://sourceware.org/ml/binutils-cvs/2012-05/msg00173.html
-  http://sourceware.org/ml/binutils-cvs/2012-05/msg00176.html
-  http://sourceware.org/ml/binutils-cvs/2012-05/msg00177.html
-
-gold/dwarf_reader.cc
-gold/dwarf_reader.h
-gold/gdb-index.cc
-gold/testsuite/Makefile.am
-gold/testsuite/Makefile.in
-gold/testsuite/gdb_index_test_3.c
-gold/testsuite/gdb_index_test_3.sh
-  Status: Backport
-  Owner: ccoutant
-  Backport patches to support DW_AT_high_pc as a constant offset.
-  http://sourceware.org/ml/binutils-cvs/2012-05/msg00003.html
-  http://sourceware.org/ml/binutils-cvs/2012-05/msg00004.html
-
-gold/testsuite/gdb_index_test_3.sh
-  Status: Backport
-  Owner: ccoutant
-  Make shell script executable.
-
-gold/dynobj.cc
-  Status: Backport
-  Owner: ccoutant
-  Fix internal error with --output-symbol-counts.
-  http://sourceware.org/ml/binutils/2012-06/msg00035.html
-
-gold/options.h
-gold/output.cc
-  Status: Upstream
-  Add --[no-]posix-fallocate and --[no-]mmap-output-file options;
-  set --no-posix-fallocate as the default (b/4080187).
-
-gold/layout.cc
-gold/options.h
-  Status: Backport
-  Owner: ccoutant
-  Fix --strip-debug-gdb to work with compressed debug sections;
-  automatically strip pubnames, pubtypes and aranges sections when
-  generating .gdb_index; add .debug_macro to list of gdb sections.
-  http://sourceware.org/ml/binutils-cvs/2012-06/msg00026.html
-
-gold/gold.cc
-gold/layout.cc
-gold/layout.h
-gold/object.h
-gold/reloc.cc
-  Status: Local
-  Owner: ccoutant
-  Add --build-id=md5-incr option to implement incremental build-id
-  generation for incremental links.
-
+bfd/bfd-in.h
 bfd/bfd-in2.h
 bfd/bfd.c
-bfd/coff-rs6000.c
-bfd/coff64-rs6000.c
-bfd/coffgen.c
-bfd/dwarf2.c
-bfd/elf-bfd.h
-bfd/elf.c
-bfd/elf32-arm.c
-bfd/elf64-alpha.c
-bfd/elfxx-mips.c
-bfd/libbfd-in.h
-bfd/libbfd.c
-bfd/libbfd.h
-bfd/targets.c
-binutils/addr2line.c
-binutils/objdump.c
-  Status: Backport
-  Owner: tejohnson
-  Add a new interface bfd_find_nearest_line_discriminator() to
-  also return the discriminator (which was previously being ignored when
-  reading the dwarf), and also add support to print non-zero
-  discriminators along with the source position information from objdump
-  and addr2line.
-  http://sourceware.org/ml/binutils-cvs/2012-07/msg00089.html
+bfd/section.c
+  Status: backport
+  Owner: ppluzhnikov
+  Backport commit 27b829ee701e29804216b3803fbaeb629be27491:
+    Replace the various bfd_xxx_set macros with static inline functions,
+    so that we can avoid compile time warnings about comma expressions
+    with unused values.
 
-bfd/dwarf2.c
-  Status: Backport
-  Owner: tejohnson
-  Missing initialization caused failures for the mips target.
-  http://sourceware.org/ml/binutils-cvs/2012-07/msg00101.html
-
-gas/config/tc-i386.c
-gas/doc/c-i386.texi
-gas/testsuite/gas/i386/i386.exp
-gas/testsuite/gas/i386/vmfunc.d
-gas/testsuite/gas/i386/vmfunc.s
-gas/testsuite/gas/i386/x86-64-vmfunc.d
-opcodes/i386-dis.c
-opcodes/i386-gen.c
-opcodes/i386-init.h
-opcodes/i386-opc.h
-opcodes/i386-opc.tbl
-opcodes/i386-tbl.h
-  Status: Backport
-  Owner: eraman
-  Add vmfunc.
-  http://sourceware.org/ml/binutils-cvs/2012-01/msg00071.html
-
-gas/config/tc-i386.c
-gas/config/tc-i386.h
-gas/doc/c-i386.texi
-gas/testsuite/gas/i386/hle-intel.d
-gas/testsuite/gas/i386/hle.d
-gas/testsuite/gas/i386/hlebad.l
-gas/testsuite/gas/i386/hlebad.s
-gas/testsuite/gas/i386/rtm-intel.d
-gas/testsuite/gas/i386/rtm.d
-gas/testsuite/gas/i386/rtm.s
-gas/testsuite/gas/i386/x86-64-hle-intel.d
-gas/testsuite/gas/i386/x86-64-hle.d
-gas/testsuite/gas/i386/x86-64-hle.s
-gas/testsuite/gas/i386/x86-64-hlebad.l
-gas/testsuite/gas/i386/x86-64-hlebad.s
-gas/testsuite/gas/i386/x86-64-rtm-intel.d
-gas/testsuite/gas/i386/x86-64-rtm.d
-gas/testsuite/gas/i386/x86-64-rtm.s
-include/opcode/i386.h
-opcodes/i386-dis.c
-opcodes/i386-gen.c
-opcodes/i386-init.h
-opcodes/i386-opc.h
-opcodes/i386-opc.tbl
-opcodes/i386-tbl.h
-  Status: Backport
-  Owner: eraman
-  ImplementIntel Transactional Synchronization Extensions.
-  http://sourceware.org/ml/binutils-cvs/2012-02/msg00030.html
-
-gas/config/tc-i386.c
-opcodes/i386-opc.h
-  Status: Backport
-  Owner: eraman
-  Add HLEPrefixNone/HLEPrefixLock/HLEPrefixAny/HLEPrefixRelease.
-  http://sourceware.org/ml/binutils-cvs/2012-02/msg00103.html
-
-gold/configure
-gold/configure.ac
-gold/testsuite/Makefile.am
-gold/testsuite/Makefile.in
-gold/testsuite/gdb_index_test_1.sh
-gold/testsuite/gdb_index_test_2.sh
+gold/dwarf_reader.cc
+gold/dwarf_reader.h
+gold/gdb-index.cc
+gold/gdb-index.h
 gold/testsuite/gdb_index_test_3.sh
-gold/testsuite/gdb_index_test_4.sh
 gold/testsuite/gdb_index_test_comm.sh
-  Status: Backport
+  Status: backport
   Owner: ccoutant
-  Backport upstream configure change to disable gdb_index tests
-  where GCC is not recent enough.
-  http://sourceware.org/ml/binutils-cvs/2012-07/msg00072.html
-
-binutils/dwarf.c
-include/gdb/gdb-index.h
-  Status: Backport
-  Owner: saugustine
-  Backport change to display gdb_index v7.
-  http://sourceware.org/ml/binutils-cvs/2012-07/msg00007.html
-
-gold/symtab.cc
-  Status: Backport
-  Owner: ccoutant
-  Backport fix for internal error with --gc-sections and undefined
-  symbol named by --export-dynamic-symbol.
-  http://sourceware.org/ml/binutils-cvs/2012-08/msg00141.html
-
-gold/layout.cc
-  Status: Backport
-  Owner: ccoutant
-  Backport fix for internal error with --emit-relocs and GROUP sections.
-  http://sourceware.org/ml/binutils-cvs/2012-08/msg00146.html
-
-binutils/dwarf.c
-  Status: Upstream
-  Owner: dje
-  Pretty-print static/global flag of .gdb_index symbols.
-  http://sourceware.org/ml/binutils/2012-09/msg00114.html
-
-gold/gdb-index.cc
-gold/gdb-index.h
-  Status: Backport
-  Owner: saugustine
-  Backport fix for relobject/section/offset bug in pubnames reading.
-  http://sourceware.org/ml/binutils/2012-09/msg00092.html
-
-gold/gdb-index.cc
-gold/gdb-index.h
-  Status: Local
-  Owner: saugustine
-  Generate gdb-index from .debug_gnu_pubnames.
-
-bfd/elf64-ppc.c
-  Status: Backport
-  Owner: dougkwan
-  Backport upstream fix for b/7120813.
-  http://sourceware.org/ml/binutils-cvs/2012-09/msg00077.html
-
-bfd/dwarf2.c
-  Status: Backport
-  Owner: ccoutant
-  Backport upstream patch to support relative form of DW_AT_high_pc.
-  http://sourceware.org/ml/binutils-cvs/2012-04/msg00119.html
-
-bfd/elf-bfd.h
-bfd/elf.c
-bfd/elf64-ppc.c
-bfd/elfxx-target.h
-  Status: Backport
-  Owner: dougkwan
-  Backport upstream patch to fix addr2line on PowerPC64.
-  http://sourceware.org/ml/binutils-cvs/2012-01/msg00109.html
-
-bfd/elf64-ppc.c
-  Status: Backport
-  Owner: dougkwan
-  Backport upstream performance fix for PR 13897
-  http://sourceware.org/ml/binutils-cvs/2012-04/msg00038.html
-  http://sourceware.org/ml/binutils-cvs/2012-06/msg00004.html
-
-bfd/elf-bfd.h
-bfd/elf.c
-bfd/elf64-ppc.c
-  Status: Backport
-  Owner: dougwan
-  Backport a dependent change for PR 13897's fix.
-  http://sourceware.org/ml/binutils-cvs/2012-02/msg00026.html
-
-bfd/elf-bfd.h
-bfd/elf.c
-bfd/elf64-ppc.c
-  Status: Backport
-  Owner: dougwan
-  Backport last patch for upstream performance fix for PR 13897
-  http://sourceware.org/ml/binutils-cvs/2012-06/msg00011.html
-
-gold/layout.cc
-  Status: Local
-  Owner: ccoutant
-  Fix linker to strip .debug_gnu_pubnames/pubtypes when generating
-  .gdb_index.
-
-bfd/elf.c
-  Status: Backport
-  Owner: dje
-  Fix http://sourceware.org/bugzilla/show_bug.cgi?id=14662
-  to make strip remove .gdb_index.
-
-binutils/dwarf.h
-  Status: Backport
-  Owner: ccoutant
-  Add missing enum for gdb_index section.
-  http://sourceware.org/ml/binutils-cvs/2011-09/msg00130.html
-
-binutils/dwarf.c
-include/dwarf2.h
-  Status: Backport
-  Owner: ccoutant
-  Backport upstream patch to add readelf support for DW_OP_GNU_const_index.
-  http://sourceware.org/ml/binutils-cvs/2012-09/msg00036.html
-
-gold/layout.cc
-  Status: Backport
-  Owner: tmsriram
-  Keep SHF_EXCLUDE sections when doing relocatable links.
-  http://sourceware.org/ml/binutils/2012-10/msg00172.html
-
-binutils/dwarf.c
-binutils/dwarf.h
-binutils/elfcomm.c
-binutils/elfcomm.h
-binutils/objdump.c
-binutils/readelf.c
-  Status: Upstream
-  Backport patches to add readelf support for dwp files.
-  http://sourceware.org/ml/binutils-cvs/2012-02/msg00075.html
-  http://sourceware.org/ml/binutils/2012-10/msg00233.html
-
-gold/Makefile.am
-gold/Makefile.in
-gold/dwarf_reader.cc
-gold/dwarf_reader.h
-gold/dwp.cc
-gold/dwp.h
-gold/fileread.cc
-gold/fileread.h
-gold/gdb-index.cc
-gold/object.h
-gold/testsuite/Makefile.am
-gold/testsuite/Makefile.in
-gold/testsuite/dwp_test.h
-gold/testsuite/dwp_test_1.cc
-gold/testsuite/dwp_test_1.s
-gold/testsuite/dwp_test_1.sh
-gold/testsuite/dwp_test_1b.cc
-gold/testsuite/dwp_test_1b.s
-gold/testsuite/dwp_test_2.cc
-gold/testsuite/dwp_test_2.s
-gold/testsuite/dwp_test_2.sh
-gold/testsuite/dwp_test_main.cc
-gold/testsuite/dwp_test_main.s
-  Status: Upstream
-  Backport patches to add dwp utility to binutils/gold.
-  http://sourceware.org/ml/binutils/2012-10/msg00229.html
-  http://sourceware.org/ml/binutils/2012-10/msg00230.html
-  http://sourceware.org/ml/binutils/2012-10/msg00231.html
-  http://sourceware.org/ml/binutils/2012-10/msg00232.html
-  http://sourceware.org/ml/binutils/2012-10/msg00234.html
-  http://sourceware.org/ml/binutils/2012-10/msg00235.html
-
-gold/dwp.cc
-  Status: Upstream
-  Fix C++11 warning.
-
-gold/Makefile.am
-gold/Makefile.in
-  Status: Upstream
-  Add install commands for dwp utility.
-
-gas/as.c
-  Status: Backport
-  Owner: simonb
-  Backport upstream patch for as -statistics.
-  http://sourceware.org/ml/binutils/2012-10/msg00248.html
-
-binutils/objcopy.c
-binutils/testsuite/binutils-all/i386/compressed-1b.d
-binutils/testsuite/binutils-all/i386/compressed-1c.d
-binutils/testsuite/binutils-all/x86-64/compressed-1b.d
-binutils/testsuite/binutils-all/x86-64/compressed-1c.d
-  Status: Backport
-  Owner: ccoutant
-  Backport upstream patch to handle empty relocations sections properly
-  in objcopy.
-  http://sourceware.org/ml/binutils-cvs/2012-04/msg00049.html
-
-gold/dwarf_reader.cc
-gold/dwarf_reader.h
-  Status: Local
-  Owner: ccoutant
-  Fix DWARF reader to recognize compressed debug sections everywhere.
-  When reading GNU-style pubnames tables, read to end of table
-  instead of stopping when die_offset == 0.
-
-gold/dwarf_reader.cc
-  Status: Local
-  Owner: ccoutant
-  Fix "set but not used" error.
-
-ld/ldmain.c
-  Status: Backport
-  Owner: simonb
-  Backport upstream patch for ld -stats
-  http://sourceware.org/ml/binutils/2012-10/msg00378.html
-
-gold/arm.cc
-gold/common.cc
-gold/dwarf_reader.cc
-gold/ehframe.cc
-gold/incremental.cc
-gold/powerpc.cc
-  Status: Backport
-  Owner: saugustine
-  Backport upstream patch for unused typedefs
-  http://sourceware.org/ml/binutils/2012-07/msg00108.html
-
-gold/gold.cc
-gold/layout.cc
-gold/layout.h
-gold/object.cc
-gold/output.cc
-gold/plugin.cc
-gold/testsuite/Makefile.am
-gold/testsuite/Makefile.in
-gold/testsuite/plugin_final_layout.sh
-gold/testsuite/plugin_section_order.c
-include/plugin-api.h
-  Status: Backport
-  Owner: tmsriram
-  Backport upstream patch to enable plugin APIs to map specific
-  function sections to unique segments.
-  http://sourceware.org/ml/binutils/2012-08/msg00447.html
-
-Makefile.def
-Makefile.in
-  Status: Backport
-  Owner: shenhan
-  Backport upstream patch for PR binutils/4970.
-  http://sourceware.org/ml/binutils/2012-08/msg00451.html
-
-gold/dwp.cc
-  Status: Backport
-  Owner: ccoutant
-  Backport upstream patch to fix dwp internal error when adding
-  a duplicate CU.
-  http://sourceware.org/ml/binutils-cvs/2012-12/msg00082.html
-
-gold/layout.cc
-gold/layout.h
-gold/output.cc
-testsuite/Makefile.am
-testsuite/Makefile.in
-testsuite/text_section_grouping.cc
-testsuite/text_section_grouping.sh
-  Status:Backport
-  Owner:tmsriram
-  Backport patches http://sourceware.org/ml/binutils/2012-11/msg00319.html
-  and http://sourceware.org/ml/binutils/2012-12/msg00227.html to allow gold
-  to group ".text.hot", ".text.unlikely", ".text.startup" and ".text.exit"
-  sections by default.
-
-gold/output.cc
-  Status: Backport
-  Owner: ccoutant
-  Backport upstream patch to fix incremental update problem exposed by
-  text section reordering.
-  http://sourceware.org/ml/binutils-cvs/2013-01/msg00039.html
-
-gold/output.h
-gold/script-sections.cc
-gold/testsuite/Makefile.am
-gold/testsuite/Makefile.in
-  Status: Backport
-  Owner: tmsriram
-  Backport patch http://sourceware.org/ml/binutils/2013-01/msg00108.html
-  to allow linker scripts and section ordering to co-exist.
-
-gold/dwp.cc
-  Status: Backport
-  Owner: ccoutant
-  Backport patches to fix 32-bit build problem, check for bad fwrite return
-  value, and add --help option.
-  http://sourceware.org/ml/binutils-cvs/2012-10/msg00132.html
-  http://sourceware.org/ml/binutils-cvs/2012-10/msg00133.html
-  http://sourceware.org/ml/binutils-cvs/2012-10/msg00162.html
-
-gold/layout.cc
-gold/testsuite/plugin_final_layout.cc
-  Status: Backport
-  Owner: tmsriram
-  Backport patch http://sourceware.org/ml/binutils/2013-01/msg00252.html to
-  fix a bug in function reordering.
-
-gold/layout.cc
-gold/options.h
-gold/output.cc
-gold/output.h
-testsuite/Makefile.am
-testsuite/Makefile.in
-testsuite/text_section_grouping.sh
-  Status: Backport
-  Owner: tmsriram
-  Backport patch http://sourceware.org/ml/binutils/2013-01/msg00357.html to
-  fix a bug in default text section ordering in gold.
-
-binutils/dwarf.c
-  Status: Backport
-  Owner: ccoutant
-  Backport patches to fix problems with readelf dumping of loclists and
-  addr tables.
-  http://sourceware.org/ml/binutils/2013-01/msg00379.html
-  http://sourceware.org/ml/binutils/2013-01/msg00388.html
-
-gold/dwp.cc
-  Status: Backport
-  Owner: ccoutant
-  Backport patch to add --exec option to dwp.
-  http://sourceware.org/ml/binutils-cvs/2013-01/msg00181.html
-
-include/plugin-api.h
-  Status: Backport
-  Owner: tmsriram
-  Backport to get plugin-api.h in sync with upstream binutils.
-  http://sourceware.org/ml/binutils/2013-02/msg00136.html
-  http://sourceware.org/ml/binutils/2012-06/msg00129.html
-
-binutils/dwarf.c
-binutils/dwarf.h
-binutils/objdump.c
-binutils/readelf.c
-  Status: Local
-  Owner: saugustine
-  Dump new accelerator tables .debug_[names|typenames|namespaces].
-
-binutils/dwarf.c
-elfcpp/dwarf.h
-include/dwarf2.h
-  Status: Backport
-  Owner: ccoutant
-  Add support for version 2 DWARF package file format.
-  http://sourceware.org/ml/binutils-cvs/2013-03/msg00000.html
-  http://sourceware.org/ml/binutils-cvs/2013-03/msg00001.html
-  http://sourceware.org/ml/binutils-cvs/2013-03/msg00002.html
-
-gold/dwp.cc
-gold/fileread.cc
-gold/fileread.h
-  Status: Local
-  Owner: ccoutant
-  Make dwp print warning instead of fatal error when it can't open
-  an input .dwo file.
-
-gold/dwarf_reader.cc
-gold/object.cc
-gold/testsuite/gdb_index_test.cc
-gold/testsuite/gdb_index_test_comm.sh
-  Status: Backport
-  Owner: ccoutant
-  Backport patch to support new FORM codes in DWARF reader.
-  http://sourceware.org/ml/binutils-cvs/2012-09/msg00038.html
-
-gold/archive.cc
-  Status: Backport
-  Owner: tmsriram
-  Backport patch to make linker plugin APIs work with archives:
-  http://sourceware.org/ml/binutils/2013-03/msg00322.html 
-
-gold/layout.cc
-gold/script-sections.cc
-gold/symtab.cc
-gold/testsuite/Makefile.am
-gold/testsuite/Makefile.in
-gold/testsuite/script_test_11.c
-gold/testsuite/script_test_11.t
-  Status: Backport
-  Owner: ccoutant
-  Backport patches to fix problems with dot assignment in scripts
-  used with -r option.
-  http://sourceware.org/ml/binutils-cvs/2013-04/msg00069.html
-  http://sourceware.org/ml/binutils-cvs/2013-04/msg00070.html
-  http://sourceware.org/ml/binutils-cvs/2013-04/msg00071.html
-
-gold/layout.cc
-  Status: Local
-  Owner: tmsriram
-  Map input section name prefixes "_function_patch_prologue." and
-  "_function_patch_epilogue." to output section names 
-  "_function_patch_prologue" and "_function_patch_epilogue".
-  The compiler patch that creates these sections:
-  http://gcc.gnu.org/ml/gcc-patches/2013-04/msg01835.html
-
-gold/dwp.h
-gold/dwp.cc
-  Status: Local
-  Owner: ccoutant
-  Add --verify-only option to dwp.
-
-gold/object.cc
-gold/object.h
-gold/symtab.h
-gold/target-reloc.h
-gold/testsuite/Makefile.am
-gold/testsuite/Makefile.in
-gold/testsuite/debug_msg.sh
-gold/testsuite/missing_key_func.cc
-gold/testsuite/missing_key_func.sh
-  Status: Backport
-  Owner: ccoutant
-  Backport upstream patches to fix problem where non-function symbols
-  in error messages are labelled as "function", and to add an extra
-  line of info when vtable symbols are undefined.
-  http://sourceware.org/ml/binutils-cvs/2013-05/msg00099.html
-  http://sourceware.org/ml/binutils-cvs/2013-05/msg00100.html
-
-include/demangle.h
-libiberty/cp-demangle.c
-libiberty/testsuite/demangle-expected
-  Status: Backport
-  Owner: ccoutant
-  Backport demangler patches to sync binutils with GCC 4.8.
-  r179772 | ian | 2011-10-10 13:34:20 -0700 (Mon, 10 Oct 2011) | 5 lines
-  r180944 | jason | 2011-11-04 05:54:08 -0700 (Fri, 04 Nov 2011) | 20 lines
-  r181154 | aldyh | 2011-11-08 03:13:41 -0800 (Tue, 08 Nov 2011) | 2 lines
-  r182969 | jason | 2012-01-06 13:39:34 -0800 (Fri, 06 Jan 2012) | 3 lines
-  r182970 | jason | 2012-01-06 13:39:43 -0800 (Fri, 06 Jan 2012) | 32 lines
-  r183072 | jason | 2012-01-10 09:02:52 -0800 (Tue, 10 Jan 2012) | 2 lines
-  r185082 | jason | 2012-03-07 15:19:06 -0800 (Wed, 07 Mar 2012) | 2 lines
-  r185595 | jason | 2012-03-20 21:04:39 -0700 (Tue, 20 Mar 2012) | 6 lines
-  r187773 | tromey | 2012-05-22 06:55:02 -0700 (Tue, 22 May 2012) | 4 lines
-  r189630 | jason | 2012-07-18 12:51:36 -0700 (Wed, 18 Jul 2012) | 3 lines
-  r192211 | jason | 2012-10-08 07:45:37 -0700 (Mon, 08 Oct 2012) | 24 lines
-  r193367 | jason | 2012-11-09 08:14:37 -0800 (Fri, 09 Nov 2012) | 22 lines
-  r193401 | jason | 2012-11-10 18:11:15 -0800 (Sat, 10 Nov 2012) | 2 lines
-  r196065 | jason | 2013-02-14 17:26:44 -0800 (Thu, 14 Feb 2013) | 8 lines
-  r197436 | jason | 2013-04-03 10:24:12 -0700 (Wed, 03 Apr 2013) | 16 lines
-
-gold/dwarf_reader.cc
-gold/dwarf_reader.h
-  Status: Backport
-  Owner: ccoutant
-  Backport upstream patch to fix problem building gdb index on piii.
-  http://sourceware.org/ml/binutils-cvs/2013-07/msg00004.html
-
-gold/dwarf_reader.cc
-gold/dwarf_reader.h
-gold/gdb-index.cc
-gold/gdb-index.h
-gold/testsuite/Makefile.am
-gold/testsuite/Makefile.in
-  Status: local in two patches
-  Owner: saugustine
-  Newer editions of GCC generate DW_AT_gnu_pubnames attribute
-  with a DW_FORM_flag_present, rather than as
-  DW_FORM_sec_offset.  Add support for reading them as such.
-
-gold/resolve.cc
-gold/testsuite/Makefile.am
-gold/testsuite/Makefile.in
-gold/testsuite/plugin_test_tls.sh
-gold/testsuite/two_file_test_2_tls.cc
-gold/testsuite/two_file_test_tls.cc
-  Status: Backport
-  Owner: ccoutant
-  Backport patch to fix LTO problem with __thread variables.
-  http://sourceware.org/ml/binutils-cvs/2013-06/msg00058.html
-
-gold/Makefile.am
-gold/Makefile.in
-  Status: Backport
-  Owner: bmoses
-  Backport changes made to the (above-backported) dwp Makefile
-  targets during upstream review.  Namely, to put it in
-  bin_PROGRAMS so that it gets installed correctly when we are
-  building a cross-compiler.  See discussion here:
-  http://sourceware.org/ml/binutils/2012-10/msg00261.html
-  http://sourceware.org/ml/binutils/2012-10/msg00262.html
-
-binutils/dwarf.c
-  Status: Backport
-  Owner: saugustine
-  Backport handling for gdb_index version 8.
-  https://sourceware.org/ml/binutils/2013-01/msg00350.html
+  Backport upstream patch to add support for .gdb_index version 7.
+  https://sourceware.org/ml/binutils-cvs/2014-01/msg00156.html
 
 gold/configure.ac
 gold/configure
@@ -1098,24 +103,12 @@
   build tools, even if we are building for a non-native
   target.
 
-libiberty/cp-demangle.c
-libiberty/testsuite/demangle-expected
-  Status: Backport
-  Owner: ppluzhnikov
-  Backport cxxfilter fix for local source name demangling.
-  http://gcc.gnu.org/viewcvs/gcc?view=revision&revision=203476
-
-gas/write.c
-  Status: Backport
-  Owner: bmoses
-  Backport fix to avoid uninitialized variable warning.
-  https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=4fc0b46e62cec696390862c9eb7d80b35d24f0f8
-
 gold/options.cc
 gold/options.h
 gold/symtab.cc
 gold/symtab.h
 gold/testsuite/Makefile.am
+gold/testsuite/Makefile.in
 gold/testsuite/dynamic_list_2.cc
 gold/testsuite/dynamic_list_2.t
 gold/testsuite/dynamic_list_lib1.cc
@@ -1123,7 +116,6 @@
 gold/testsuite/gc_dynamic_list_test.c
 gold/testsuite/gc_dynamic_list_test.sh
 gold/testsuite/gc_dynamic_list_test.t
-gold/testsuite/Makefile.in
   Status: Backport
   Owner: ccoutant
   Fix problems with --dynamic-list option.
@@ -1159,6 +151,20 @@
   Backported from:
   https://sourceware.org/ml/binutils-cvs/2014-02/msg00031.html
 
+gold/testsuite/Makefile.am
+gold/testsuite/Makefile.in
+  Status: backport
+  Owner: ccoutant
+  Backport upstream patch to fix dependencies in gold testsuite.
+  https://sourceware.org/ml/binutils-cvs/2013-10/msg00022.html
+
+binutils/dwarf.c
+  Status: backport
+  Owner: ccoutant
+  Backport upstream patch to fix bogus complaint about corrupt attribute
+  when DW_FORM_flag_present falls at end of section.
+  https://sourceware.org/ml/binutils-cvs/2014-02/msg00054.html
+
 libiberty/cp-demangle.c
 libiberty/cp-demangle.h
 libiberty/testsuite/demangle-expected
@@ -1166,3 +172,64 @@
   Owner: ccoutant
   Fix demangler to handle conversion operators correctly.
   Backported from GCC trunk at r205292.
+
+gold/configure
+gold/configure.ac
+gold/testsuite/Makefile.am
+gold/testsuite/Makefile.in
+  Status: backport
+  Owner: ccoutant
+  Modify gold testsuite to disable plugins added by GCC driver.
+  https://sourceware.org/ml/binutils-cvs/2014-04/msg00010.html
+
+gold/icf.cc
+  Status: backport
+  Owner: tmsriram
+  Use references to reloc info vectors in icf.cc.  This also fixes
+  bug b/13588967
+  https://sourceware.org/ml/binutils/2014-04/msg00026.html
+
+gold/x86_64.cc
+  Status: backport
+  Owner: ccoutant
+  Add missing break statement (PR gold/16870).
+  https://sourceware.org/ml/binutils-cvs/2014-04/msg00141.html
+
+gold/options.h
+  Status: local
+  Owner: ccoutant
+  Make --disable-new-dtags the default.  See b/12844098.
+
+gold/gdb-index.cc
+  Status: backport
+  Owner: ccoutant
+  Don't complain about the source language when we have pubnames/pubtypes info.
+  https://sourceware.org/ml/binutils-cvs/2014-05/msg00025.html
+
+gold/layout.cc
+  Status: Local
+  Owner: ccoutant
+  Fix linker to strip .debug_gnu_pubnames/pubtypes when generating
+  .gdb_index.
+
+gold/arm.cc
+gold/i386.cc
+gold/powerpc.cc
+gold/sparc.cc
+gold/x86_64.cc
+gold/symtab.h
+testsuite/Makefile.am
+testsuite/Makefile.in
+testsuite/pie_copyrelocs_test.cc
+testsuite/pie_copyrelocs_shared_test.cc
+  Status: backport
+  Owner: tmsriram
+  Backport fix to allow copy relocations with pie links when possible.
+  https://sourceware.org/ml/binutils/2014-05/msg00092.html
+
+libiberty/configure.ac
+libiberty/configure
+  Status: backport
+  Owner: bmoses
+  Fix bug that prevented --enable-install-libiberty from working.
+  https://gcc.gnu.org/ml/gcc-patches/2014-01/msg00213.html
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 65db027..2c4719c 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,2699 +1,2785 @@
-2011-11-21  Tristan Gingold  <[email protected]>
+2013-12-02  Tristan Gingold  <[email protected]>
 
-	* configure.in: Bump version to 2.22
+	* configure.in: Bump version to 2.24
 	* Makefile.am (RELEASE): Set.
 	* configure, Makefile.in: Regenerate.
 
-2011-11-15  Maxim Kuvyrkov  <[email protected]>
+2013-11-26  Tristan Gingold  <[email protected]>
 
-	Backport from mainline:
-
-	2011-11-14  Maxim Kuvyrkov  <[email protected]>
-        * elfxx-mips.c (mips_n64_exe_plt0_entry): Use 64-bit move.
-
-2011-11-15  Alan Modra  <[email protected]>
-	    Andreas Tobler  <[email protected]>
-
-	* elflink.c (_bfd_elf_create_got_section): Replace
-	bfd_make_section_with_flags with bfd_make_section_anyway_with_flags.
-	(_bfd_elf_link_create_dynamic_sections): Likewise.
-	* elf32-ppc.c (ppc_elf_create_glink): Likewise.
-	(ppc_elf_create_dynamic_sections): Likewise.
-
-2011-11-09  Alan Modra  <[email protected]>
-
-	* elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Mark syms in
-	executables when export_dynamic.
-
-2011-11-08  Alan Modra  <[email protected]>
-
-	* elf64-ppc.c (struct ppc64_elf_obj_tdata): Rename
-	ha_relocs_not_using_r2 to unexpected_toc_insn.
-	(ok_lo_toc_insn): New function.
-	(ppc64_elf_edit_toc): Check insn on lo toc reloc.  Emit warning.
-	(ppc64_elf_relocate_section): Don't check insn on lo toc reloc here.
-	Handle addic on lo toc reloc.
-
-2011-10-25  Alan Modra  <[email protected]>
-
-	Apply mainline patches
-	2011-10-20  Alan Modra  <[email protected]>
-	* elf32-i386.c (i386_opcode16): Delete.
-	(elf_i386_check_tls_transition): Use memcmp to compare contents.
-	* elf64-x86-64.c (x86_64_opcode16, x86_64_opcode32): Delete.
-	(elf_x86_64_check_tls_transition): Use memcmp to compare contents.
-
-	2011-10-19  Alan Modra  <[email protected]>
-	PR ld/13311
-	* elflink.c (elf_link_output_extsym): Correct test for warning when
-	forced local executable syms are referenced from shared libraries.
-
-	2011-10-19  Alan Modra  <[email protected]>
-	PR ld/13254
-	* elflink.c (bfd_elf_final_link): Emit error_textrel error.
-
-	2011-10-17  Alan Modra  <[email protected]>
-	PR ld/12975
-	PR ld/13195
-	* elf64-ppc.c (ppc64_elf_gc_mark_dynamic_ref): Apply 2011-09-15
-	and 2011-09-29 bfd_elf_gc_mark_dynamic_ref_symbol changes here too.
-
-	2011-10-11  Alan Modra  <[email protected]>
-	PR binutils/13278
-	* archive.c (bfd_generic_archive_p): Only check first element
-	when target_defaulted.
-	(_bfd_construct_extended_name_table): Use ar_maxnamelen.
-	(_bfd_archive_bsd44_construct_extended_name_table): Likewise.
-
-	2011-10-11  Alan Modra  <[email protected]>
-	PR binutils/13257
-	* archive.c (_bfd_find_nested_archive, _bfd_get_elt_at_filepos): Open
-	thin archive element using container target if not defaulted.
-
-	2011-10-10  Alan Modra  <[email protected]>
-	* elf64-ppc.c (ppc64_elf_howto_table): Add R_PPC64_TOCSAVE entry.
-	(struct ppc_link_hash_table): Add tocsave_htab.
-	(struct tocsave_entry): New.
-	(tocsave_htab_hash, tocsave_htab_eq, tocsave_find): New functions.
-	(ppc64_elf_link_hash_table_create): Create tocsave_htab..
-	(ppc64_elf_link_hash_table_free): ..and delete it.
-	(build_plt_stub): Always put STD_R2_40R1 first.
-	(ppc64_elf_size_stubs): Check for R_PPC64_TOCSAVE following reloc
-	on plt call.  If present add prologue nop location to tocsave_htab.
-	(ppc64_elf_relocate_section): Convert prologue nop to std.  Skip
-	first insn of plt call stub when R_PPC64_TOCSAVE present.
-
-	2011-10-08  H.J. Lu  <[email protected]>
-	PR ld/13250
-	* elflink.c (elf_link_add_object_symbols): Preserve the maximum
-	alignment and size for common symbols.
-
-	2011-10-08  Alan Modra  <[email protected]>
-	PR ld/13229
-	PR ld/13244
-	* elflink.c (elf_link_add_object_symbols): Don't make IR symbols
-	dynamic.
-
-	2011-10-08  Alan Modra  <[email protected]>
-	* elflink.c (elf_link_output_extsym): Strip defined plugin symbols
-	even when strip_discarded is false.
-
-	2011-09-30  Alan Modra  <[email protected]>
-	PR ld/13235
-	* elf64-ppc.c (struct ppc64_elf_obj_tdata): Add ha_relocs_not_using_r2.
-	(ppc64_elf_edit_toc): Check HA relocs.
-	(ha_reloc_match): Delete function.
-	(ppc64_elf_relocate_section): Remove delayed HA nop optimization.
-	Instead do it and low part optimization based on
-	ha_relocs_not_using_r2.
-
-2011-10-18  David S. Miller  <[email protected]>
-
-	PR binutils/13301
-	* elfxx-sparc.c (sparc_elf_find_reloc_at_ofs): New function.
-	(_bfd_sparc_elf_relocate_section): Always move the __tls_get_addr
-	call delay slot instruction forward 4 bytes when performing
-	relaxation.
-
-2011-10-18  H.J. Lu  <[email protected]>
-
-	PR ld/13177
-	* elflink.c (elf_gc_sweep_symbol): Don't hide symbols without PLT
-	nor GOT references.
-
-2011-10-14  Hans-Peter Nilsson  <[email protected]>
-
-	* elf32-cris.c (cris_elf_gc_sweep_hook) <R_CRIS_16_GOTPLT>
-	<R_CRIS_32_GOTPLT>: Fix missing update of gotplt refcount for
-	global symbols.
-	<R_CRIS_8, R_CRIS_16, R_CRIS_32>: New cases for similar missing
-	updates of the plt refcount.
-	(elf_cris_adjust_gotplt_to_got): Assert integrity of the gotplt
-	refcount in relation to the plt refcount.
-
-2011-10-13  Richard Sandiford  <[email protected]>
-
-	* elf32-arm.c (elf32_arm_final_link_relocate): Mark PLT calls via
-	stubs as resolved.
-
-2011-09-29  H.J. Lu  <[email protected]>
-
-	PR ld/13195
-	* elflink.c (_bfd_elf_merge_symbol): Don't set dynamic_def when
-	clearing def_dynamic.
-	(elf_link_add_object_symbols): Likewise.  Set dynamic_def when
-	setting def_dynamic.
-	(bfd_elf_gc_mark_dynamic_ref_symbol): Check if a symbol is
-	versioned.
-
-2011-09-29  Alan Modra  <[email protected]>
-
-	PR ld/13233
-	* elflink.c (_bfd_elf_gc_mark_extra_sections): Mark single member
-	debug and special section groups.
-
-2011-09-26  Tristan Gingold  <[email protected]>
-
-	* configure.in: Bump version to 2.21.90
+	* configure.in: Bump version to 2.23.92
 	* configure: Regenerate.
 
-2011-09-21  David S. Miller  <[email protected]>
+2013-11-22  Cory Fields  <[email protected]>
 
-	* elfxx-sparc.c (_bfd_sparc_elf_merge_private_bfd_data): New.
-	* elfxx-sparc.h: Declare it.
-	* elf32-sparc.c (elf32_sparc_merge_private_bfd_data): Call it.
-	* elf64-sparc.c (elf64_sparc_merge_private_bfd_data): Likewise.
-
-2011-09-21  Tristan Gingold  <[email protected]>
-
-	* mach-o.c (bfd_mach_o_convert_section_name_to_bfd): Add comment.
-	Deals with size limited strings.
-	(bfd_mach_o_build_commands): Initialize more fields.
-
-2011-09-15  H.J. Lu  <[email protected]>
-
-	PR ld/13177
-	* elflink.c (elf_gc_sweep_symbol): Also hide symbols without PLT
-	nor GOT references.
-
-2011-09-15  H.J. Lu  <[email protected]>
-
-	PR ld/12975
-	* bfd-in.h (bfd_elf_size_dynamic_sections): Remove pointer
-	to struct bfd_elf_version_tree.
-
-	* elflink.c (elf_info_failed): Remove verdefs.
-	(_bfd_elf_export_symbol): Updated.
-	_bfd_elf_link_assign_sym_version): Likewise.
-	(bfd_elf_size_dynamic_sections): Remove pointer to struct
-	bfd_elf_version_tree.  Updated.
-	(bfd_elf_gc_mark_dynamic_ref_symbol): Check if a symbol is hidden
-	by linker script.
-
-	* linker.c (bfd_hide_sym_by_version): New.
-
-	* bfd-in2.h: Regenerated.
-
-2011-09-12  H.J. Lu  <[email protected]>
-
-	PR ld/13178
-	* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Use .got.plt
-	if there are no GOT relocations.
-
-2011-09-09  Kai Tietz  <[email protected]>
-
-	* peicode.h (pe_ILF_build_a_bfd): Don't remove leading underscore
-	for targets without symbol_leading_char.
-
-2011-09-08  Bernd Jendrissek  <[email protected]>
-
-	* bfdwin.c (bfd_get_file_window): Fix memory leak.
-
-2011-09-07  Alan Modra  <[email protected]>
-
-	PR ld/13131
-	* bfd/elf64-ppc.c (adjust_toc_syms): Ensure ppc64_elf_howto_table
-	is initialized.
-
-2011-09-06  Alan Modra  <[email protected]>
-
-	PR ld/13131
-	* elf64-ppc.c (adjust_toc_syms): Delete redundant code.
-	(ppc64_elf_edit_toc): Fix style nit.  Report some details
-	on linker failure due to reference in debug or non-alloc
-	sections to optimized away toc entry, and don't abort.
-
-2011-09-01  Christophe Lyon  <[email protected]>
-
-	* elf32-arm.c (elf32_arm_output_arch_local_syms): Skip excluded
-	sections.
-
-2011-08-26  Nick Clifton  <[email protected]>
-
-	* po/es.po: Updated Spanish translation.
-
-2011-08-19  Alan Modra  <[email protected]>
-
-	* elf64-ppc.c (ppc64_elf_edit_toc): Ignore can_optimize bit if
-	we haven't seen expected -mcmodel=medium/large code relocs.
-
-2011-08-18  Tristan Gingold  <[email protected]>
-
-	* mach-o.c (bfd_mach_o_read_segment): Initialize list.
-
-2011-08-17  Tristan Gingold  <[email protected]>
-
-	* mach-o.c (bfd_mach_o_write_section_32): Fix typo.
-
-2011-08-17  Alan Modra  <[email protected]>
-
-	PR ld/12762
-	* bfd-in.h (struct bfd_section_already_linked): Forward declare.
-	(_bfd_handle_already_linked): Declare.
-	* coff-alpha.c (_bfd_ecoff_section_already_linked): Define as
-	_bfd_coff_section_already_linked.
-	* coff-mips.c (_bfd_ecoff_section_already_linked): Likewise.
-	* coffcode.h (coff_section_already_linked): Likewise.
-	* cofflink.c (coff_link_add_symbols): Revert 2011-07-09 changes.
-	* elf-bfd.h: Likewise.
-	* libbfd-in.h: Likewise.
-	* targets.c: Likewise.
-	* linker.c (bfd_section_already_linked): Likewise.
-	(bfd_section_already_linked_table_lookup): Likewise.
-	(bfd_section_already_linked_table_insert): Likewise.
-	(_bfd_generic_section_already_linked): Likewise.  Call
-	_bfd_handle_already_linked.
-	(_bfd_handle_already_linked): New function, split out from..
-	* elflink.c (_bfd_elf_section_already_linked): ..here.  Revert
-	2011-07-09 changes.  Avoid unnecessary strcmp when matching
-	already_linked_list entries.  Match plugin linkonce section.
-	(section_signature): Delete.
-	* coffgen.c (_bfd_coff_section_already_linked): New function.
-	* libcoff-in.h (_bfd_coff_section_already_linked): Declare.
-	* libbfd.h: Regenerate.
+	* libcoff-in.h: Add insert_timestamp flag to the pe_data struct.
 	* libcoff.h: Regenerate.
-	* bfd-in2.h: Regenerate.
+	* peXXigen.c (_bfd_XXi_only_swap_filehdr_out): Only use a real
+	timestamp if --insert-timestamp was used.
 
-2011-08-14  Alan Modra  <[email protected]>
+2013-11-19  Roland McGrath  <[email protected]>
 
-	* elf32-ppc.c (ppc_elf_select_plt_layout): Force bss-plt when
-	shared and call to _mcount will go via plt.
+	* elf-nacl.c (nacl_modify_segment_map): Calculate SIZEOF_HEADERS
+	when not doing linking (i.e. INFO is a null pointer).
 
-2011-08-14  Alan Modra  <[email protected]>
+2013-11-18  Tristan Gingold  <[email protected]>
 
-	* elf64-ppc.c: Prefix all einfo error strings with "%P: ".
-	* elf32-ppc.c: Likewise.
-	(ppc_elf_select_plt_layout): Use einfo rather than info to report
-	forced bss-plt.
+	* configure.in: Bump version to 2.23.91
+	* configure: Regenerate.
 
-2011-08-12  H.J. Lu  <[email protected]>
+2013-11-17  H.J. Lu  <[email protected]>
 
-	PR ld/13082
-	* elf64-x86-64.c (x86_64_elf_howto_table): Add R_X86_64_RELATIVE64.
-	(elf_x86_64_relocate_section): Treat R_X86_64_64 like R_X86_64_32
-	and zero-extend it to 64bit if addend is zero for x32.  Generate
-	R_X86_64_RELATIVE64 for x32.
-
-2011-08-09  Matthew Gretton-Dann  <[email protected]>
-
-	* bfd-in.h (bfd_elf32_arm_set_target_relocs): Update prototype.
-	* bfd-in2.h (bfd_elf32_arm_set_target_relocs): Likewise.
-	* elf32-arm.c (elf32_arm_link_hash_table): New field.
-	(elf232_arm_link_hash_table_create): Initialise new field.
-	(check_use_blx): Change test depending on fix_arm1176.
-	(bfd_elf32_arm_set_target_relocs): Set fix_arm1176 from
-	command line options.
-
-2011-08-08  Tristan Gingold  <[email protected]>
-
-	* mach-o.c (struct mach_o_segment_name_xlat): Add comments.
-	(segsec_names_xlat): Reorder elements.
-	(bfd_mach_o_read_section_32): Fix typo.
-	(bfd_mach_o_read_section_64): Fix typo.
-
-2011-08-08  Tristan Gingold  <[email protected]>
-
-	* mach-o.h (BFD_MACH_O_SEGNAME_SIZE): New macro.
-	(BFD_MACH_O_SECTNAME_SIZE): Ditto.
-	(bfd_mach_o_section): Use them.  Add next field.
-	(bfd_mach_o_segment_command): Replace sections array by
-	sect_head and sect_tail.
-	(bfd_mach_o_get_mach_o_section): New macro.
-	(bfd_mach_o_lookup_section): Remove.
-	(bfd_mach_o_new_section_hook): New function.
-	* mach-o.c (bfd_mach_o_normalize_section_name): Use strncmp
-	instead of strcmp.
-	(bfd_mach_o_convert_section_name_to_bfd): Replaces section
-	parameter with segname and sectname parameters.  Adjust.
-	(bfd_mach_o_append_section_to_segment): New function.  Use a
-	linked list for Mach-O sections.
-	(bfd_mach_o_write_segment_32): Adjust.
-	(bfd_mach_o_write_segment_64): Ditto.
-	(bfd_mach_o_build_commands): Fix comment.  Adjust.
-	(bfd_mach_o_flatten_sections): Adjust.
-	(bfd_mach_o_print_section_map): Adjust.
-	(bfd_mach_o_set_section_flags_from_bfd): Ditto.
-	(bfd_mach_o_new_section_hook): New function.
-	(bfd_mach_o_init_section_from_mach_o): Ditto.
-	(bfd_mach_o_read_section_32): Remove section parameter.
-	Return a section instead.
-	(bfd_mach_o_read_section_64): Ditto.
-	(bfd_mach_o_read_section): Ditto.
-	(bfd_mach_o_make_bfd_section): Adjust.
-	(bfd_mach_o_read_segment): Adjust for new profile of
-	bfd_mach_o_read_section.
-	(bfd_mach_o_lookup_section): Remove.
-	* mach-o-target.c (bfd_mach_o_new_section_hook): Remove.
-
-2011-08-08  Tristan Gingold  <[email protected]>
-
-	* mach-o.h (bfd_mach_o_version_min_command): New structure.
-	(bfd_mach_o_load_command): Add version_min.
-	(mach_o_data_struct): Fix comment.
-	* mach-o.c (bfd_mach_o_read_version_min): New function.
-	(bfd_mach_o_read_command): Handle BFD_MACH_O_LC_FUNCTION_STARTS,
-	BFD_MACH_O_LC_VERSION_MIN_MACOSX and
-	BFD_MACH_O_LC_VERSION_MIN_IPHONEOS.
-	(bfd_mach_o_get_name_or_null): New function.
-	(bfd_mach_o_get_name): Use the above new one.
-	(bfd_mach_o_load_command_name): Add the above new commands.
-	(bfd_mach_o_bfd_print_private_bfd_data): Display numerically
-	unknown commands.  Handle BFD_MACH_O_LC_FUNCTION_STARTS,
-	BFD_MACH_O_LC_VERSION_MIN_MACOSX and
-	BFD_MACH_O_LC_VERSION_MIN_IPHONEOS.
-
-2011-08-08  Tristan Gingold  <[email protected]>
-
-	* mach-o.h: Move size macros to external.h
-	Move reloc macros to reloc.h and x86-64.h.
-	* mach-o-i386.c: Includes mach-o/reloc.h
-	* mach-o-x86-64.c: Ditto and includes mach-o/x86-64.h
-	* mach-o.c: Add includes.
-	(bfd_mach_o_write_header): Use structure from external.h to convert.
-	(bfd_mach_o_write_thread): Ditto.
-	(bfd_mach_o_write_relocs): Ditto.
-	(bfd_mach_o_write_section_32): Ditto.
-	(bfd_mach_o_write_section_64): Ditto.
-	(bfd_mach_o_write_segment_32): Ditto.
-	(bfd_mach_o_write_segment_64): Ditto.
-	(bfd_mach_o_write_symtab): Ditto.
-	(bfd_mach_o_write_contents): Ditto.
-	(bfd_mach_o_read_header): Ditto.
-	(bfd_mach_o_read_section_32): Ditto.
-	(bfd_mach_o_read_section_64): Ditto.
-	(bfd_mach_o_read_symtab_symbol): Ditto.
-	(bfd_mach_o_read_dylinker): Ditto.
-	(bfd_mach_o_read_dylib): Ditto.
-	(bfd_mach_o_read_dysymtab): Ditto.
-	(bfd_mach_o_read_symtab): Ditto.
-	(bfd_mach_o_read_linkedit): Ditto.
-	(bfd_mach_o_read_str): Ditto.
-	(bfd_mach_o_read_dyld_info): Ditto.
-	(bfd_mach_o_read_segment): Ditto.
-	(bfd_mach_o_read_command): Ditto.
-	(bfd_mach_o_archive_p): Ditto.
-	(bfd_mach_o_canonicalize_one_reloc): Ditto. Change the BUF parameter.
-	(bfd_mach_o_canonicalize_relocs): Adjust to call the above function.
-	(bfd_mach_o_read_dysymtab_symbol): Rename BUF variable.
-	(bfd_mach_o_read_uuid): Remove useless cast.  Use a macro instead
-	of an hard-coded value.
-
-2011-08-08  Tristan Gingold  <[email protected]>
-
-	* mach-o-x86-64.c (bfd_mach_o_x86_64_mkobject): Fix cut-and-past typos.
-	(bfd_mach_o_x86_64_swap_reloc_out): Handle BFD_RELOC_32_PCREL,
-	BFD_RELOC_MACH_O_X86_64_SUBTRACTOR64 and
-	BFD_RELOC_MACH_O_X86_64_GOT_LOAD.  Share common code.
-
-2011-08-08  Tristan Gingold  <[email protected]>
-
-	* mach-o.c (bfd_mach_o_normalize_section_name): New function.
-	(bfd_mach_o_convert_section_name_to_bfd): Use it.
-	(bfd_mach_o_get_section_type_from_name): New function.
-	(bfd_mach_o_get_section_attribute_from_name): Ditto.
-	* mach-o.h (bfd_mach_o_section): Move bfdsection field at the end.
-	Add comments.  Add prototypes for the above new functions.
-
-2011-08-05  Mark Kettenis  <[email protected]>
-
-	* netbsd-core.c (netbsd_core_vec): Init match_priority field.
-
-2011-08-05  Alan Modra  <[email protected]>
-
-	* elf64-ppc.c (maybe_strip_output): New function.
-	(ppc64_elf_size_stubs): Use it to strip .branch_lt and .eh_frame.
-
-2011-08-05  Alan Modra  <[email protected]>
-
-	PR ld/12762
-	* elflink.c (_bfd_elf_section_already_linked): Return matched
-	status.  Remove COFF comdat section handling.
-	* linker.c (_bfd_generic_section_already_linked): Return matched
-	status.  Don't set SEC_GROUP in l_flags for plugin entries.
-	(bfd_section_already_linked): Update prototype.
-	* targets.c (_section_already_linked): Likewise.
-	* elf-bfd.h (_bfd_elf_section_already_linked): Likewise.
-	* libbfd-in.h (_bfd_generic_section_already_linked): Likewise.
-	(_bfd_nolink_section_already_linked): Update.
-	* libbfd.h: Regenerate.
-	* bfd-in2.h: Regenerate.
-
-2011-08-05  Alan Modra  <[email protected]>
-
-	* elf32-ppc.c: Include dwarf2.h.
-	(struct ppc_elf_link_hash_table): Add glink_eh_frame.
-	(ppc_elf_create_glink): Create .eh_frame section.
-	(glink_eh_frame_cie): New array.
-	(ppc_elf_size_dynamic_sections): Size glink_eh_frame.
-	(ppc_elf_finish_dynamic_sections): Write glink_eh_frame.
-
-2011-08-04  Tristan Gingold  <[email protected]>
-
-	* vms-alpha.c (_bfd_vms_write_eeom): Round vms_linkage_index.
-	(_bfd_vms_write_etir): Initialize vms_linkage_index to 0.
-
-2011-08-03  Tristan Gingold  <[email protected]>
-
-	* mach-o.c (bfd_mach_o_canonicalize_symtab): Handle no symbols case.
-	(bfd_mach_o_read_symtab_symbols): Return if no symbols.
-
-2011-08-02  Maciej W. Rozycki  <[email protected]>
-
-	* elfxx-mips.c (check_4byte_branch): Remove function.
-	(check_relocated_bzc): New function.
-	(_bfd_mips_elf_relax_section): Permit the relaxation of LUI
-	instructions that immediately follow a compact branch
-	instruction.
-
-2011-08-02  Alan Modra  <[email protected]>
-
-	* elf64-ppc.c (build_plt_stub): Correct emitted relocs when no
-	plt_static_chain.
-	(ppc_build_one_stub): Adjust get_relocs call to suit..
-	(ppc_size_one_stub): ..and reloc sizing.  Correct plt size corner case.
-
-2011-08-01  H.J. Lu  <[email protected]>
-
-	PR ld/13048
-	* archures.c (bfd_mach_i386_intel_syntax): New.
-	(bfd_mach_i386_i8086): Updated.
-	(bfd_mach_i386_i386): Likewise.
-	(bfd_mach_x86_64): Likewise.
-	(bfd_mach_x64_32): Likewise.
-	(bfd_mach_i386_i386_intel_syntax): Likewise.
-	(bfd_mach_x86_64_intel_syntax): Likewise.
-	(bfd_mach_x64_32_intel_syntax): Likewise.
-	(bfd_mach_l1om): Likewise.
-	(bfd_mach_l1om_intel_syntax): Likewise.
-	(bfd_mach_k1om): Likewise.
-	(bfd_mach_k1om_intel_syntax): Likewise.
-
-	* bfd-in2.h: Regenerated.
-
-	* cpu-i386.c (bfd_i386_compatible): Check mach instead of
-	bits_per_address.
-	(bfd_x64_32_arch_intel_syntax): Set bits_per_address to 64.
-	(bfd_x64_32_arch): Likewise.
-
-	* elf64-x86-64.c: Include "libiberty.h".
-	(x86_64_elf_howto_table): Append x32 R_X86_64_32.
-	(elf_x86_64_rtype_to_howto): Support x32 R_X86_64_32.
-	(elf_x86_64_reloc_type_lookup): Likewise.
-	(elf_x86_64_reloc_name_lookup): Likewise.
+	* elf64-x86-64.c (x86_64_elf_howto_table): Add R_X86_64_PC32_BND
+	and R_X86_64_PLT32_BND.
+	(R_X86_64_standard): Replace R_X86_64_RELATIVE64 with
+	R_X86_64_PLT32_BND.
+	(IS_X86_64_PCREL_TYPE): Add R_X86_64_PLT32_BND.
+	(x86_64_reloc_map): Add BFD_RELOC_X86_64_PC32_BND and
+	BFD_RELOC_X86_64_PLT32_BND.
+	(elf_x86_64_check_relocs): Handle R_X86_64_PC32_BND and
+	R_X86_64_PLT32_BND.
+	(elf_x86_64_gc_sweep_hook): Likewise.
 	(elf_x86_64_relocate_section): Likewise.
-	(elf_x86_64_check_relocs): Allow R_X86_64_64 relocations for x32.
-
-2011-07-29  Maciej W. Rozycki  <[email protected]>
-
-	* elfxx-mips.c (check_br32): Fix return type.
-
-2011-07-29  Maciej W. Rozycki  <[email protected]>
-
-	* elfxx-mips.c (bz_insn_16): Correct opcode mask.
-
-2011-07-29  Maciej W. Rozycki  <[email protected]>
-
-	* elfxx-mips.c: Adjust comments throughout.
-	(mips_elf_relax_delete_bytes): Reshape code.
-	(_bfd_mips_elf_relax_section): Remove check for
-	R_MICROMIPS_GPREL16 relocations.  Reshape code.
-
-2011-07-28  Roland McGrath  <[email protected]>
-
-	* elf32-i386.c (NACL_PLT_ENTRY_SIZE, NACLMASK): New macros.
-	(elf_i386_nacl_plt0_entry): New variable.
-	(elf_i386_plt_entry): New variable.
-	(elf_i386_nacl_pic_plt0_entry): New variable.
-	(elf_i386_nacl_pic_plt_entry): New variable.
-	(elf_i386_nacl_plt, elf_i386_nacl_arch_bed): New variables.
-	(elf_backend_arch_data): New macro setting for elf_i386_nacl_vec stanza.
-	(elf_backend_plt_alignment): Likewise.
-
-	* config.bfd: Handle i[3-7]86-*-nacl*.
-	* elf32-i386.c (bfd_elf32_i386_nacl_vec): New backend vector stanza.
-	* targets.c: Support bfd_elf32_i386_nacl_vec.
-	* configure.in: Likewise.
-	* configure: Regenerated.
-
-	* elf32-i386.c (struct elf_i386_plt_layout): New type.
-	(GET_PLT_ENTRY_SIZE): New macro.
-	(elf_i386_plt): New variable.
-	(struct elf_i386_backend_data): New member `plt'.
-	(elf_i386_arch_bed): Add initializer for it.
-	(elf_i386_vxworks_arch_bed): Likewise.
-	(elf_i386_allocate_dynrelocs): Use GET_PLT_ENTRY_SIZE.
-	(elf_i386_plt_sym_val): Likewise.
-	(elf_i386_relocate_section): Likewise.
-	(elf_i386_finish_dynamic_symbol): Likewise.
-	Also use other elf_i386_plt_layout members for PLT details.
-	(elf_i386_finish_dynamic_sections): Likewise.
-
-	* elf32-i386.c (struct elf_i386_backend_data): New type.
-	(get_elf_i386_backend_data): New macro.
-	(elf_i386_arch_bed): New variable.
-	(elf_backend_arch_data): New macro.
-	(struct elf_i386_link_hash_table): Remove plt0_pad_byte and is_vxworks.
-	(elf_i386_link_hash_table_create): Don't initialize them.
-	(elf_i386_create_dynamic_sections): Find is_vxworks flags in
-	elf_i386_backend_data, not elf_i386_link_hash_table.
-	(elf_i386_adjust_dynamic_symbol): Likewise.
-	(elf_i386_allocate_dynrelocs): Likewise.
-	(elf_i386_readonly_dynrelocs): Likewise.
-	(elf_i386_size_dynamic_sections): Likewise.
-	(elf_i386_relocate_section): Likewise.
-	(elf_i386_finish_dynamic_symbol): Likewise.
-	(elf_i386_finish_dynamic_sections): Likewise.  Same for plt0_pad_byte.
-	(elf_i386_vxworks_link_hash_table_create): Function removed.
-	(elf_i386_vxworks_arch_bed): New variable.
-	(elf_backend_arch_data): New macro in elf32-i386-vxworks stanza.
-
-	* elf-bfd.h (elf_backend_data): New member arch_backend_data.
-	* elfxx-target.h (elf_backend_arch_data): New macro.
-	(elfNN_bed): Use it as initializer for the new member.
-
-2011-07-28  Mikulas Patocka  <[email protected]>
-
-	* elf64-hppa.c (elf_hppa_final_link_relocate): Fix handling of out
-	of range branches.
-
-2011-07-26  Jakub Jelinek  <[email protected]>
-
-	* dwarf2.c (dwarf_debug_sections): Add .debug_macro
-	and .zdebug_macro entry.
-	(dwarf_debug_section_enum): Add debug_macro.
-
-2011-07-26  Alan Modra  <[email protected]>
-
-	* elf64-ppc.c: Include dwarf2.h.
-	(struct ppc_link_hash_table): Add glink_eh_frame.
-	(create_linkage_sections): Create .eh_frame section.
-	(ppc64_elf_size_dynamic_sections): Arrange to drop unneeded
-	glink_eh_frame.
-	(glink_eh_frame_cie): New array.
-	(ppc64_elf_size_stubs): Size glink_eh_frame.
-	(ppc64_elf_build_stubs): Init glink_eh_frame contents.
-	(ppc64_elf_finish_dynamic_sections): Write glink_eh_frame.
-
-2011-07-25  Hans-Peter Nilsson  <[email protected]>
-
-	PR ld/12815
-	* elf64-mmix.c (struct _mmix_elf_section_data): New members
-	has_warned_bpo and has_warned_pushj.
-	(mmix_final_link_relocate): Remove PARAMS and PTR macros,
-	converting to ISO C.  Add new parameter error_message.  All
-	callers changed.
-	(mmix_elf_perform_relocation): Ditto.
-	<case R_MMIX_PUSHJ_STUBBABLE, case R_MMIX_BASE_PLUS_OFFSET>:
-	Handle the case where mmix_elf_check_common_relocs has not been
-	called, missing preparations for relocs of the respective type.
-
-2011-07-24  Chao-ying Fu  <[email protected]>
-	    Ilie Garbacea  <[email protected]>
-	    Maciej W. Rozycki  <[email protected]>
-	    Joseph Myers  <[email protected]>
-	    Catherine Moore  <[email protected]>
-	    Richard Sandiford  <[email protected]>
-
-	* archures.c (bfd_mach_mips_micromips): New macro.
-	* cpu-mips.c (I_micromips): New enum value.
-	(arch_info_struct): Add bfd_mach_mips_micromips.
-	* elfxx-mips.h (_bfd_mips_elf_is_target_special_symbol): New
-	prototype.
-	(_bfd_mips_elf_relax_section): Likewise.
-	(_bfd_mips16_elf_reloc_unshuffle): Rename to...
-	(_bfd_mips_elf_reloc_unshuffle): ... this.  Handle microMIPS
-	ASE.
-	(_bfd_mips16_elf_reloc_shuffle): Rename to...
-	(_bfd_mips_elf_reloc_shuffle): ... this.  Handle microMIPS ASE.
-	(gprel16_reloc_p): Handle microMIPS ASE.
-	(literal_reloc_p): New function.
-	* elf32-mips.c (elf_micromips_howto_table_rel): New variable.
-	(_bfd_mips_elf32_gprel16_reloc): Handle microMIPS ASE.
-	(mips16_gprel_reloc): Update for _bfd_mips_elf_reloc_unshuffle
-	and _bfd_mips_elf_reloc_shuffle changes.
-	(mips_elf_gprel32_reloc): Update comment.
-	(micromips_reloc_map): New variable.
-	(bfd_elf32_bfd_reloc_type_lookup): Handle microMIPS ASE.
-	(mips_elf32_rtype_to_howto): Likewise.
-	(mips_info_to_howto_rel): Likewise.
-	(bfd_elf32_bfd_is_target_special_symbol): Define.
-	(bfd_elf32_bfd_relax_section): Likewise.
-	* elf64-mips.c (micromips_elf64_howto_table_rel): New variable.
-	(micromips_elf64_howto_table_rela): Likewise.
-	(mips16_gprel_reloc): Update for _bfd_mips_elf_reloc_unshuffle
-	and _bfd_mips_elf_reloc_shuffle changes.
-	(micromips_reloc_map): Likewise.
-	(bfd_elf64_bfd_reloc_type_lookup): Handle microMIPS ASE.
-	(bfd_elf64_bfd_reloc_name_lookup): Likewise.
-	(mips_elf64_rtype_to_howto): Likewise.
-	(bfd_elf64_bfd_is_target_special_symbol): Define.
-	* elfn32-mips.c (elf_micromips_howto_table_rel): New variable.
-	(elf_micromips_howto_table_rela): Likewise.
-	(mips16_gprel_reloc): Update for _bfd_mips_elf_reloc_unshuffle
-	and _bfd_mips_elf_reloc_shuffle changes.
-	(micromips_reloc_map): Likewise.
-	(bfd_elf32_bfd_reloc_type_lookup): Handle microMIPS ASE.
-	(bfd_elf32_bfd_reloc_name_lookup): Likewise.
-	(mips_elf_n32_rtype_to_howto): Likewise.
-	(bfd_elf32_bfd_is_target_special_symbol): Define.
-	* elfxx-mips.c (LA25_LUI_MICROMIPS_1): New macro.
-	(LA25_LUI_MICROMIPS_2): Likewise.
-	(LA25_J_MICROMIPS_1, LA25_J_MICROMIPS_2): Likewise.
-	(LA25_ADDIU_MICROMIPS_1, LA25_ADDIU_MICROMIPS_2): Likewise.
-	(TLS_RELOC_P): Handle microMIPS ASE.
-	(mips_elf_create_stub_symbol): Adjust value of stub symbol if
-	target is a microMIPS function.
-	(micromips_reloc_p): New function.
-	(micromips_reloc_shuffle_p): Likewise.
-	(got16_reloc_p, call16_reloc_p): Handle microMIPS ASE.
-	(got_disp_reloc_p, got_page_reloc_p): New functions.
-	(got_ofst_reloc_p): Likewise.
-	(got_hi16_reloc_p, got_lo16_reloc_p): Likewise.
-	(call_hi16_reloc_p, call_lo16_reloc_p): Likewise.
-	(hi16_reloc_p, lo16_reloc_p, jal_reloc_p): Handle microMIPS ASE.
-	(micromips_branch_reloc_p): New function.
-	(tls_gd_reloc_p, tls_ldm_reloc_p): Likewise.
-	(tls_gottprel_reloc_p): Likewise.
-	(_bfd_mips16_elf_reloc_unshuffle): Rename to...
-	(_bfd_mips_elf_reloc_unshuffle): ... this.  Handle microMIPS
-	ASE.
-	(_bfd_mips16_elf_reloc_shuffle): Rename to...
-	(_bfd_mips_elf_reloc_shuffle): ... this.  Handle microMIPS ASE.
-	(_bfd_mips_elf_lo16_reloc): Handle microMIPS ASE.
-	(mips_tls_got_index, mips_elf_got_page): Likewise.
-	(mips_elf_create_local_got_entry): Likewise.
-	(mips_elf_relocation_needs_la25_stub): Likewise.
-	(mips_elf_calculate_relocation): Likewise.
-	(mips_elf_perform_relocation): Likewise.
-	(_bfd_mips_elf_symbol_processing): Likewise.
-	(_bfd_mips_elf_add_symbol_hook): Likewise.
-	(_bfd_mips_elf_link_output_symbol_hook): Likewise.
-	(mips_elf_add_lo16_rel_addend): Likewise.
-	(_bfd_mips_elf_check_relocs): Likewise.
-	(mips_elf_adjust_addend): Likewise.
-	(_bfd_mips_elf_relocate_section): Likewise.
-	(mips_elf_create_la25_stub): Likewise.
-	(_bfd_mips_vxworks_finish_dynamic_symbol): Likewise.
-	(_bfd_mips_elf_gc_sweep_hook): Likewise.
-	(_bfd_mips_elf_is_target_special_symbol): New function.
-	(mips_elf_relax_delete_bytes): Likewise.
-	(opcode_descriptor): New structure.
-	(RA): New macro.
-	(OP32_SREG, OP32_TREG, OP16_VALID_REG): Likewise.
-	(b_insns_32, bc_insn_32, bz_insn_32, bzal_insn_32): New variables.
-	(beq_insn_32): Likewise.
-	(b_insn_16, bz_insn_16): New variables.
-	(BZC32_REG_FIELD): New macro.
-	(bz_rs_insns_32, bz_rt_insns_32): New variables.
-	(bzc_insns_32, bz_insns_16):Likewise.
-	(BZ16_REG, BZ16_REG_FIELD): New macros.
-	(jal_insn_32_bd16, jal_insn_32_bd32): New variables.
-	(jal_x_insn_32_bd32): Likewise.
-	(j_insn_32, jalr_insn_32): Likewise.
-	(ds_insns_32_bd16, ds_insns_32_bd32): Likewise.
-	(jalr_insn_16_bd16, jalr_insn_16_bd32, jr_insn_16): Likewise.
-	(JR16_REG): New macro.
-	(ds_insns_16_bd16): New variable.
-	(lui_insn): Likewise.
-	(addiu_insn, addiupc_insn): Likewise.
-	(ADDIUPC_REG_FIELD): New macro.
-	(MOVE32_RD, MOVE32_RS): Likewise.
-	(MOVE16_RD_FIELD, MOVE16_RS_FIELD): Likewise.
-	(move_insns_32, move_insns_16): New variables.
-	(nop_insn_32, nop_insn_16): Likewise.
-	(MATCH): New macro.
-	(find_match): New function.
-	(check_br16_dslot, check_br32_dslot): Likewise.
-	(check_br16, check_br32): Likewise.
-	(IS_BITSIZE): New macro.
-	(check_4byte_branch): New function.
-	(_bfd_mips_elf_relax_section): Likewise.
-	(_bfd_mips_elf_merge_private_bfd_data): Disallow linking MIPS16
-	and microMIPS modules together.
-	(_bfd_mips_elf_print_private_bfd_data):	Handle microMIPS ASE.
-	* reloc.c (BFD_RELOC_MICROMIPS_7_PCREL_S1): New relocation.
-	(BFD_RELOC_MICROMIPS_10_PCREL_S1): Likewise.
-	(BFD_RELOC_MICROMIPS_16_PCREL_S1): Likewise.
-	(BFD_RELOC_MICROMIPS_GPREL16): Likewise.
-	(BFD_RELOC_MICROMIPS_JMP, BFD_RELOC_MICROMIPS_HI16): Likewise.
-	(BFD_RELOC_MICROMIPS_HI16_S): Likewise.
-	(BFD_RELOC_MICROMIPS_LO16): Likewise.
-	(BFD_RELOC_MICROMIPS_LITERAL): Likewise.
-	(BFD_RELOC_MICROMIPS_GOT16): Likewise.
-	(BFD_RELOC_MICROMIPS_CALL16): Likewise.
-	(BFD_RELOC_MICROMIPS_GOT_HI16): Likewise.
-	(BFD_RELOC_MICROMIPS_GOT_LO16): Likewise.
-	(BFD_RELOC_MICROMIPS_CALL_HI16): Likewise.
-	(BFD_RELOC_MICROMIPS_CALL_LO16): Likewise.
-	(BFD_RELOC_MICROMIPS_SUB): Likewise.
-	(BFD_RELOC_MICROMIPS_GOT_PAGE): Likewise.
-	(BFD_RELOC_MICROMIPS_GOT_OFST): Likewise.
-	(BFD_RELOC_MICROMIPS_GOT_DISP): Likewise.
-	(BFD_RELOC_MICROMIPS_HIGHEST): Likewise.
-	(BFD_RELOC_MICROMIPS_HIGHER): Likewise.
-	(BFD_RELOC_MICROMIPS_SCN_DISP): Likewise.
-	(BFD_RELOC_MICROMIPS_JALR): Likewise.
-	(BFD_RELOC_MICROMIPS_TLS_GD): Likewise.
-	(BFD_RELOC_MICROMIPS_TLS_LDM): Likewise.
-	(BFD_RELOC_MICROMIPS_TLS_DTPREL_HI16): Likewise.
-	(BFD_RELOC_MICROMIPS_TLS_DTPREL_LO16): Likewise.
-	(BFD_RELOC_MICROMIPS_TLS_GOTTPREL): Likewise.
-	(BFD_RELOC_MICROMIPS_TLS_TPREL_HI16): Likewise.
-	(BFD_RELOC_MICROMIPS_TLS_TPREL_LO16): Likewise.
-	* bfd-in2.h: Regenerate.
-	* libbfd.h: Regenerate.
-
-2011-07-22  H.J. Lu  <[email protected]>
-
-	* Makefile.am (ALL_MACHINES): Add cpu-k1om.lo.
-	(ALL_MACHINES_CFILES): Add cpu-k1om.c.
-	* Makefile.in: Regenerated.
-
-	* archures.c (bfd_architecture): Add bfd_arch_k1om.
-	(bfd_k1om_arch): New.
-	(bfd_archures_list): Add &bfd_k1om_arch.
+	* reloc.c (bfd_reloc_code_real): Add BFD_RELOC_X86_64_PC32_BND
+	and BFD_RELOC_X86_64_PLT32_BND.
 	* bfd-in2.h: Regenerated.
+	* libbfd.h: Likewise.
 
-	* config.bfd (targ64_selvecs): Add bfd_elf64_k1om_vec if
-	bfd_elf64_x86_64_vec is supported.  Add bfd_elf64_k1om_freebsd_vec
-	if bfd_elf64_x86_64_freebsd_vec is supported.
-	(targ_selvecs): Likewise.
+2013-11-15  Alan Modra  <[email protected]>
 
-	* configure.in: Support bfd_elf64_k1om_vec and
-	bfd_elf64_k1om_freebsd_vec.
-	* configure: Regenerated.
+	Apply changes from mainline to 2.24
+	2013-11-11  Alan Modra  <[email protected]>
+	* elf64-ppc.c (allocate_dynrelocs): Revert 2013-11-04 change.
 
-	* cpu-k1om.c: New.
+	2013-11-11  Ulrich Weigand  <[email protected]>
+	* elf64-ppc.c (ppc64_elf_edit_toc): Use SYMBOL_REFERENCES_LOCAL
+	here, not SYMBOL_CALLS_LOCAL.
+	(ppc64_elf_relocate_section): Likewise.
+	(size_global_entry_stubs): Set undefined symbols on their global
+	entry stubs here..
+	(build_global_entry_stubs): ..rather than here.
+	(ppc64_elf_build_stubs): Don't reset glink->size before calling
+	build_global_entry_stubs.
 
-	* elf64-x86-64.c (elf64_k1om_elf_object_p): New.
-	(bfd_elf64_k1om_vec): Likewise.
-	(bfd_elf64_k1om_freebsd_vec): Likewise.
+	2013-11-05  Alan Modra  <[email protected]>
+	* elf64-ppc.c (ppc64_elf_func_desc_adjust): Make .TOC. defined and
+	hidden.
+	(ppc64_elf_set_toc): Adjust.
 
-	* targets.c (bfd_elf64_k1om_vec): New.
-	(bfd_elf64_k1om_freebsd_vec): Likewise.
-	(_bfd_target_vector): Add bfd_elf64_k1om_vec and
-	bfd_elf64_k1om_freebsd_vec.
+	2013-11-05  Alan Modra  <[email protected]>
+	* elf64-ppc.c (struct ppc_link_hash_table): Remove got, plt, relplt,
+	iplt, reliplt.  Update all references to use elf.sgot, elf.splt,
+	elf.srelplt, elf.iplt and elf.irelplt.
 
-2011-07-20  Jan Kratochvil  <[email protected]>
+	2013-11-04  Alan Modra  <[email protected]>
+	* elf64-ppc.c (ppc64_elf_relocate_section): Edit global entry
+	prologue to non-PIC in non-PIC executables.
 
-	Fix false coff-go32-exe matches.
-	* coff-i386.c (TARGET_SYM) <_bfd_check_format>: Conditionally use
-	COFF_CHECK_FORMAT.
-	* coff-stgo32.c (go32_check_format): New forward declaration.
-	(COFF_CHECK_FORMAT): New defintion.
-	(go32_check_format): New function.
+	2013-11-04  Alan Modra  <[email protected]>
+	* elf64-ppc.c (ppc64_elf_copy_indirect_symbol): Copy
+	pointer_equality_needed flag.
+	(ppc64_elf_check_relocs): For ELFv2 arrange to emit plt
+	entries for references to functions in shared libraries on
+	non-call relocs.
+	(readonly_dynrelocs): Split into function of the same name and..
+	(maybe_set_textrel): ..this new function.  Update call.
+	(ppc64_elf_adjust_dynamic_symbol): Don't emit dynrelocs for
+	ELFv2 in most cases if we have a plt entry.  Use new
+	readonly_relocs.
+	(allocate_dynrelocs): For ELFv2, don't allocate dynreloc space
+	for ifunc in static executables.
+	(size_global_entry_stubs): New function.
+	(ppc64_elf_size_dynamic_sections): Call size_global_entry_stubs.
+	Save end of glink branch table.
+	(ppc64_elf_hash_symbol): New function.
+	(build_global_entry_stubs): New function.
+	(ppc64_elf_build_stubs): Call build_global_entry_stubs.  Adjust
+	glink sizing.
+	(ppc64_elf_relocate_section): Tidy plt16/32/64 reloc code.
+	(ppc64_elf_finish_dynamic_symbol): For ELFv2, adjust symbols
+	defined on plt code.
 
-2011-07-15  Alan Modra  <[email protected]>
+	2013-11-02  Alan Modra  <[email protected]>
+	* elf64-ppc.c (ppc64_elf_next_input_section): Always set toc_off
+	to value for object file.
 
-	* configure.in: Bump version.
-	* configure: Regenerate.
+	2013-10-30  Alan Modra  <[email protected]>
+	* elf32-ppc.c (ppc_elf_size_dynamic_sections): Use new DT_PPC_OPT
+	tag to specify tls optimisation.
+	* elf64-ppc.c (ppc64_elf_size_dynamic_sections): Likewise.
+	(ppc64_elf_finish_dynamic_sections): Specify whether multiple
+	toc pointers are used via DT_PPC64_OPT.
 
-2011-07-14  Alan Modra  <[email protected]>
+	2013-10-30  Alan Modra  <[email protected]>
+	* elf64-ppc.c (STK_LR, STK_TOC, STK_LINKER): Define.
+	(savegpr0_tail, restgpr0_tail, savefpr0_tail, restfpr0_tail)
+	build_plt_stub, build_tls_get_addr_stub, ppc_build_one_stub,
+	ppc64_elf_relocate_section): Use new defines.
 
-	* linker.c (_bfd_generic_section_already_linked): Set l_flags.
-	* elf-bfd.h (struct already_linked): Forward declare.
+	2013-10-30  Alan Modra  <[email protected]>
+	* elf64-ppc.c (PLT_ENTRY_SIZE, PLT_INITIAL_ENTRY_SIZE): Add htab
+	parameter and adjust for ELFv2.  Update all uses.
+	(PLT_CALL_STUB_SIZE): Delete.
+	(ppc64_elf_get_synthetic_symtab): Support new glink layout.
+	(allocate_dynrelocs): Likewise.
+	(plt_stub_size, build_plt_stub): Adjust for ELFv2.
+	(get_r2off): Return 0 for ELFv2 -R.
+	(ppc_build_one_stub, ppc_size_one_stub): Adjust for ELFv2.
+	(ppc64_elf_size_stubs): Likewise.
+	(ppc64_elf_build_stubs): Add new ELFv2 glink.
 
-2011-07-14  Alan Modra  <[email protected]>
-
-	* elflink.c (_bfd_elf_fix_symbol_flags): Loop on indirect syms.
-	(_bfd_elf_adjust_dynamic_symbol): Remove FIXME.
-
-2011-07-14  Alan Modra  <[email protected]>
-
-	* elf64-ppc.c (struct ppc_link_hash_table): Add plt_static_chain.
-	(build_plt_stub): Add plt_static_chain param, don't load r11 if false.
-	(build_tls_get_addr_stub): Likewise.
-	(ppc_build_one_stub): Update calls to above.
-	(ppc_size_one_stub): Adjust stub size.
-	(ppc64_elf_size_stubs): Add plt_static_chain param, save to htab.
-	* elf64-ppc.h (ppc64_elf_size_stubs): Update prototype.
-
-2011-07-12  Nick Clifton  <[email protected]>
-
-	* elf32-arm.c (elf32_arm_section_flags): Delete.
-	(elf_backend_section_flags): Remove.
-
-2011-07-11  H.J. Lu  <[email protected]>
-
-	PR ld/12982
-	* elflink.c (bfd_elf_size_dynamic_sections): Also skip BFD_PLUGIN
-	when setting stack_flags.
-
-2011-07-11  Catherine Moore  <[email protected]>
-
-	* aout-adobe.c (aout_32_bfd_lookup_section_flags): New definition.
-	* aout-target.h (MY_bfd_lookup_section_flags): New definition.
-	* aout-tic30.c (MY_bfd_lookup_section_flags): New definition.
-	* bfd-in2.h: Regenerated.
-	* bfd.c (bfd_lookup_section_flags): New definition.
-	* binary.c (binary_bfd_lookup_section_flags): New definition.
-	* bout.c (b_out_bfd_lookup_section_flags): New definition.
-	* coff-alpha.c (_bfd_ecoff_bfd_lookup_section_flags): New definition.
-	* coff-mips.c (_bfd_ecoff_bfd_lookup_section_flags): New definition.
-	* coff-rs6000.c (rs6000coff_vec): Include
-	bfd_generic_lookup_section_flags.
-	(pmac_xcoff_vec): Likewise.
-	* coffcode.h (coff_bfd_lookup_section_flags): New definition.
-	* coff64-rs6000.c (rs6000coff64_vec): Include
-	bfd_generic_lookup_section_flags.
-	(aix5coff64_vec): Likewise.
-	* ecoff.c (bfd_debug_section): Initialize flag_info field.
-	* elf-bfd.h (elf_backend_lookup_section_flags_hook): Declare.
-	(bfd_elf_lookup_section_flags): Declare.
-	* elflink.c (bfd_elf_lookup_section_flags): New function.
-	* elfxx-target.h (bfd_elfNN_bfd_lookup_section_flags): Define.
-	(elf_backend_lookup_section_flags_hook): Define.
-	(elf_backend_data): Add elf_backend_lookup_section_flags_hook.
-	* i386msdos.c (msdos_bfd_lookup_section_flags): New define.
-	* i386os9k.c (os9k_bfd_lookup_section_flags): New define.
-	* ieee.c (ieee_bfd_lookup_section_flags): New define.
-	* ihex.c (ihex_bfd_lookup_section_flags): New define.
-	* libbfd-in.h (_bfd_nolink_bfd_lookup_section_flags): Declare.
-	(bfd_generic_lookup_section_flags): Declare.
-	* libbfd.h: Regenerated.
-	* mach-o-target.c (bfd_mach_o_bfd_lookup_section_flags): New.
-	* mmo.c (mmo_bfd_lookup_section_flags): New definition.
-	* nlm-target.h (nlm_bfd_lookup_section_flags): New definition.
-	* oasys.c (oasys_bfd_lookup_section_flags): New definition.
-	* pef.c (bfd_pef_bfd_lookup_section_flags): New definition.
-	* plugin.c (bfd_plugin_bfd_lookup_section_flags): New definition.
-	* ppcboot.c (ppcboot_bfd_lookup_section_flags): New definition.
-	* reloc.c (bfd_generic_lookup_section_flags): New function.
-	* som.c (som_bfd_lookup_section_flags): New definition.
-	* srec.c (srec_bfd_lookup_section_flags): New definition.
-	* targets.c (flag_info): Declare.
-	(NAME##_bfd_lookup_section_flags): Add to LINK jump table.
-	(_bfd_lookup_section_flags): New.
-	* tekhex.c (tekhex_bfd_lookup_section_flags): New definition.
-	* versados.c (versados_bfd_lookup_section_flags): New definition.
-	* vms-alpha.c (alpha_vms_bfd_lookup_section_flag): New definition.
-	* xsym.c (bfd_sym_bfd_lookup_section_flags): New definition.
-
-2011-07-11  H.J. Lu  <[email protected]>
-
-	PR ld/12978
-	* elfnn-ia64.c (count_dyn_reloc): Fix a typo.
-
-2011-07-09  Alan Modra  <[email protected]>
-
-	PR ld/12942
-	* elflink.c (elf_link_add_object_symbols): Use elf_discarded_section
-	rather than kept_section to determine whether a symbol is from
-	a discarded section.
-	* cofflink.c (coff_link_add_symbols): Make symbols from discarded
-	sections appear undefined.
-
-2011-07-09  H.J. Lu  <[email protected]>
-
-	PR ld/12942
-	* elf-bfd.h (_bfd_elf_section_already_linked): Replace
-	"asection *" with "struct already_linked *".
-	* libbfd-in.h (_bfd_nolink_section_already_linked): Likewise.
-	(_bfd_generic_section_already_linked): Likewise.
-	(bfd_section_already_linked_table_insert): Likewise.
-	(struct already_linked): New.
-	(struct bfd_section_already_linked): Use it.
-	* elflink.c (_bfd_elf_section_already_linked): Replace.
-	"asection *" with "struct already_linked *".  Replace the plugin
-	dummy with the LTO output.
-	* linker.c (_bfd_generic_section_already_linked): Likewise.
-	* targets.c (struct already_linked): Add forward declaration.
-	(bfd_target): Replace "struct bfd_section *" with
-	"struct already_linked *" in _section_already_linked.
-	* bfd-in2.h: Regenerate.
-	* libbfd.h: Regenerate.
-
-2011-07-06  Tristan Gingold  <[email protected]>
-
-	* mach-o.h: Move loader related definitions to
-	include/mach-o/loader.h.  Include it.
-
-2011-07-05  H.J. Lu  <[email protected]>
-
-	* elf64-x86-64.c (elf_backend_post_process_headers): Always
-	define to _bfd_elf_set_osabi.
-
-2011-07-03  Samuel Thibault  <[email protected]>
-	    Thomas Schwinge  <[email protected]>
-
-	PR binutils/12913
-	* elf.c (_bfd_elf_set_osabi): Use ELFOSABI_GNU name instead of
-	ELFOSABI_LINUX alias.
-	* elf32-hppa.c: Likewise.
-	* elf32-i370.c: Likewise.
-	* elf64-hppa.c: Likewise.
-
-2011-07-01  Ian Lance Taylor  <[email protected]>
-
-	* elf32-i386.c (elf_i386_eh_frame_plt): Correct expression: change
-	DW_OP_lit3 to DW_OP_lit2.
-
-2011-07-01  Alan Modra  <[email protected]>
-
-	* elf32-ppc.c (ppc_elf_copy_indirect_symbol): Don't look at
-	dyn relocs when called to copy flags for a weak sym.
-	* elf64-ppc.c (ppc64_elf_copy_indirect_symbol): Likewise.
-	(ppc64_elf_merge_private_bfd_data): Delete.
-	(bfd_elf64_bfd_merge_private_bfd_data): Define as
-	_bfd_generic_verify_endian_match.
-
-2011-06-30  Bernd Schmidt  <[email protected]>
-
-	* bfd/elf32-tic6x.c (elf32_tic6x_set_osabi): Also set it if
-	link_info is NULL.
-
-2011-06-28  Tristan Gingold  <[email protected]>
-
-	* vms-alpha.c (vms_private_data_struct): Make vms_linkage_index
-	unsigned int.
-	(_bfd_vms_write_etir): Write linkage index from reloc.
-
-2011-06-28  Fawzi Mohamed <[email protected]>
-
-	* mach-o.c (bfd_mach_o_read_command): Also ignore
-	BFD_MACH_O_LC_ROUTINES_64.
-
-2011-06-27  Tristan Gingold  <[email protected]>
-
-	* vms-alpha.c (_bfd_vms_write_etir): Use 'section' to get current
-	section target index.
-
-2011-06-27  Nick Clifton  <[email protected]>
-
-	* cisco-core.c (cisco_core_little_vec): Add initialization of
-	match_priority field.
-
-2011-06-27  Tristan Gingold  <[email protected]>
-
-	* cache.c: Include bfd_stdint.h.
-	(cache_bmmap): Change profile.  Return region start and size.
-	* bfdio.c (struct bfd_iovec): Change bmmap profile.
-	(bfd_mmap): Change profile and adjust.   Update comment.
-	(memory_bmmap): Change profile.
-	* opncls.c (opncls_bmmap): Change profile.
-	* vms-lib.c (vms_lib_bmmap): Likewise.
-	* libbfd.h: Regenerate.
-	* bfd-in2.h: Regenerate.
-
-2011-06-27  Tristan Gingold  <[email protected]>
-
-	* vms-misc.c (vms_time_to_time_t): Adjust overflow detection.
-	Add comment.
-
-2011-06-25  H.J. Lu  <[email protected]>
-
-	* elf64-x86-64.c (elf_backend_post_process_headers): Don't
-	define for FreeBSD/x86-64 nor FreeBSD/L1OM.  Define for L1OM.
-
-2011-06-25  Jan Kratochvil  <[email protected]>
-
-	* elf64-x86-64.c (elf_x86_64_link_hash_table_create): Initialize
-	PLT_EH_FRAME.
-	* elf32-i386.c (elf_i386_link_hash_table): Likewise.
-
-2011-06-24  Richard Henderson  <[email protected]>
-
-	PR ld/12928
-	* elf64-alpha.c (elf64_alpha_relax_tls_get_addr): Recover the
-	tlsgd insn before swapping adjacent insns.
-
-2011-06-24  Tristan Gingold  <[email protected]>
-
-	* vms-alpha.c (alpha_vms_slurp_relocs): Add a guard for relocs in the
-	absolute section.
-
-2011-06-24  Alan Modra  <[email protected]>
-
-	PR ld/12921
-	* elf.c (assign_file_positions_for_load_sections): Don't align
-	sh_offset for all SHT_NOBITS sections here, just .tbss sections
-	that don't get a PT_LOAD.
-
-2011-06-22  Kaz Kojima  <[email protected]>
-
-	* elf32-sh.c (sh_elf_relocate_section): Allow R_SH_TLS_LE_32 for PIE.
-	(sh_elf_check_relocs): Likewise.
-
-2011-06-22  Richard Henderson  <[email protected]>
-
-	* elf64-alpha.c (elf64_alpha_check_relocs): No dynamic reloc for
-	TPREL in a PIE image.
-	(alpha_dynamic_entries_for_reloc): Likewise.
-	(elf64_alpha_relocate_section): Allow TPREL in PIE images.
-	(elf64_alpha_relax_got_load): Likewise.
-
-2011-06-22  Ramana Radhakrishnan  <[email protected]>
-
-	* elf32-arm.c (elf32_arm_final_link_relocate): Allow R_ARM_TLS_LE32
-	for PIE.
-
-2011-06-22  Alan Modra  <[email protected]>
-
-	* elflink.c (_bfd_elf_merge_symbol): Allow type changes for
-	plugin symbols.  Fix segfault on linker scrip defined syms.
-
-2011-06-20  Jakub Jelinek  <[email protected]>
-
-	PR ld/12570
-	* elf-eh-frame.c (_bfd_elf_parse_eh_frame): Allow no relocations
-	at all for linker created .eh_frame sections.
-	(_bfd_elf_discard_section_eh_frame): Handle linker created
-	.eh_frame sections with no relocations.
-	* elf64-x86-64.c: Include dwarf2.h.
-	(elf_x86_64_eh_frame_plt): New variable.
-	(PLT_CIE_LENGTH, PLT_FDE_LENGTH, PLT_FDE_START_OFFSET,
-	PLT_FDE_LEN_OFFSET): Define.
-	(struct elf_x86_64_link_hash_table): Add plt_eh_frame field.
-	(elf_x86_64_create_dynamic_sections): Create and fill in
-	.eh_frame section for .plt section.
-	(elf_x86_64_size_dynamic_sections): Write .plt section size
-	into .eh_frame FDE covering .plt section.
-	(elf_x86_64_finish_dynamic_sections): Write .plt section
-	start into .eh_frame FDE covering .plt section.  Call
-	_bfd_elf_write_section_eh_frame on htab->plt_eh_frame section.
-	(elf_backend_plt_alignment): Define to 4.
-	* elf32-i386.c: Include dwarf2.h.
-	(elf_i386_eh_frame_plt): New variable.
-	(PLT_CIE_LENGTH, PLT_FDE_LENGTH, PLT_FDE_START_OFFSET,
-	PLT_FDE_LEN_OFFSET): Define.
-	(struct elf_i386_link_hash_table): Add plt_eh_frame field.
-	(elf_i386_create_dynamic_sections): Create and fill in
-	.eh_frame section for .plt section.
-	(elf_i386_size_dynamic_sections): Write .plt section size
-	into .eh_frame FDE covering .plt section.
-	(elf_i386_finish_dynamic_sections): Write .plt section
-	start into .eh_frame FDE covering .plt section.  Call
-	_bfd_elf_write_section_eh_frame on htab->plt_eh_frame section.
-	(elf_backend_plt_alignment): Define to 4.
-
-2011-06-19  H.J. Lu  <[email protected]>
-
-	* elf64-x86-64.c (elf_backend_post_process_headers): Defined
-	for x32.
-
-2011-06-16  H.J. Lu  <[email protected]>
-
-	* elf64-x86-64.c: Include <stdarg.h> and CORE_HEADER if
-	CORE_HEADER is defined.
-	(elf_x86_64_write_core_note): New.
-	(elf_backend_write_core_note): Likewise.
-
-	* hosts/x86-64linux.h (uint64_t): New.
-	(user_regsx32_struct): Likewise.
-	(elf_gregx32_t): Likewise.
-	(ELF_NGREGX32): Likewise.
-	(elf_gregsetx32_t): Likewise.
-	(elf_prstatusx32): Likewise.
-	(prstatusx32_t): Likewise.
-	(user_fpregs32_struct): Removed.
-	(user_fpxregs32_struct): Likewise.
-	(user32): Likewise.
-	(elf_fpregset32_t): Likewise.
-	(elf_fpxregset32_t): Likewise.
-	(prgregset32_t): Likewise.
-	(prfpregset32_t): Likewise.
-
-2011-06-16  H.J. Lu  <[email protected]>
-
-	* elf64-x86-64.c (elf_x86_64_grok_prstatus): Support x32.
-	(elf_x86_64_grok_psinfo): Likewise.
-
-2011-06-16  Nick Clifton  <[email protected]>
-
-	* elf.c (elf_find_function): Fail if not provided with a symbol
-	table.
-
-2011-06-15  Ulrich Weigand  <[email protected]>
-
-	* elf-bfd.h (elfcore_write_arm_vfp): Add prototype.
-	* elf.c (elfcore_grok_arm_vfp): New function.
-	(elfcore_grok_note): Call it to handle NT_ARM_VFP notes.
-	(elfcore_write_arm_vfp): New function.
-	(elfcore_write_register_note): Call it to handle .reg-arm-vfp.
-
-2011-06-14  Richard Henderson  <[email protected]>
-
-	* elf64-alpha.c (elf64_alpha_copy_indirect_symbol): Rename from
-	elf64_alpha_merge_ind_symbols; adjust for the generic interface.
-	(elf64_alpha_always_size_sections): Don't call
-	elf64_alpha_merge_ind_symbols.
-	(elf_backend_copy_indirect_symbol): New.
-
-2011-06-14  Alan Modra  <[email protected]>
-
-	PR ld/12887
-	* elf-eh-frame.c (_bfd_elf_parse_eh_frame): Check sec_info_type
-	before doing anything.
-	(_bfd_elf_discard_section_eh_frame): Likewise.
-
-2011-06-14  Alan Modra  <[email protected]>
-
-	* Makefile.am: Formatting.
-	* Makefile.in: Regenerate.
-	* configure.in (bfd_elf64_tilegx_vec): Add elfxx-tilegx.lo.
-	* po/SRC-POTFILES.in: Regnerate.
-
-2011-06-14  Alan Modra  <[email protected]>
-
-	* elf32-tilepro.c (tilepro_elf_size_dynamic_sections): Don't use PTR.
-	(allocate_dynrelocs, readonly_dynrelocs): Replace PTR with void *.
-	Don't handle warning symbols here.
-	* elfxx-tilegx.c (tilegx_elf_size_dynamic_sections): As above.
-	(allocate_dynrelocs, readonly_dynrelocs): As above.
-
-2011-06-14  Alan Modra  <[email protected]>
-
-	PR ld/12851
-	* elflink.c (_bfd_elf_gc_mark_extra_sections): New function.
-	(elf_gc_sweep): Don't treat debug and sections like .comment
-	specially here.
-	(bfd_elf_gc_sections): Treat note sections as gc roots only when
-	not part of a group.  Always call gc_mark_extra_sections.
-	* elf-bfd.h (_bfd_elf_gc_mark_extra_sections): Declare.
-	* elfxx-target.h (elf_backend_gc_mark_extra_sections): Default to
-	_bfd_elf_gc_mark_extra_sections.
-	* elf32-arm.c (elf32_arm_gc_mark_extra_sections): Call
-	_bfd_elf_gc_mark_extra_sections.
-	* elf32-tic6x.c (elf32_tic6x_gc_mark_extra_sections): Likewise.
-
-2011-06-13  Nick Clifton  <[email protected]>
-
-	* elf32-tilepro.c (tilepro_elf_check_relocs): Delete unused local
-	variable 'local_got_offsets'.
-	* elfxx-tilegx.c (tilegx_elf_check_relocs): Likewise.
-	(tilegx_finish_dyn): Delete unused local variable 'abi_64_p'.
-
-2011-06-13  Walter Lee  <[email protected]>
-
-	* Makefile.am (ALL_MACHINES): Add cpu-tilegx.lo and cpu-tilepro.lo.
-	(ALL_MACHINE_CFILES): Add cpu-tilegx.c and cpu-tilepro.c.
-	(BFD32_BACKENDS): Add elf32-tilegx.lo, elf32-tilepro.lo,
-	and elfxx-tilegx.lo.
-	(BFD32_BACKENDS_CFILES): Add elf32-tilegx.c elf32-tilepro.c, and
-	elfxx-tilegx.c.
-	(BFD64_BACKENDS): Add elf64-tilegx.lo.
-	(BFD64_BACKENDS_CFILES): Add elf64-tilegx.c.
-	* Makefile.in: Regenerate.
-	* arctures.c (bfd_architecture): Define bfd_arch_tilepro,
-	bfd_arch_tilegx, bfd_mach_tilepro, bfd_mach_tilegx.
-	(bfd_arch_info): Add bfd_tilegx_arch, bfd_tilepro_arch.
-	(bfd_archures_list): Add bfd_tilegx_arch, bfd_tilepro_arch.
-	bfd-in2.h: Regenerate.
-	* config.bfd: Handle tilegx-*-* and tilepro-*-*.
-	* configure.in: Handle bfd_elf32_tilegx_vec, bfd_elf32_tilepro_vec,
-	and bfd_elf64_tilegx_vec.
-	* configure: Regenerate.
-	* elf-bfd.h (enum elf_target_id): Define TILEGX_ELF_DATA and
-	TILEPRO_ELF_DATA.
-	* libbfd.h: Regenerate.
-	* reloc.c: Add BFD_RELOC_TILEPRO_{COPY, GLOB_DAT, JMP_SLOT,
-	RELATIVE, BROFF_X1, JOFFLONG_X1, JOFFLONG_X1_PLT, IMM8_X0,
-	IMM8_Y0, IMM8_X1, IMM8_Y1, DEST_IMM8_X1, MT_IMM15_X1, MF_IMM15_X1,
-	IMM16_X0, IMM16_X1, IMM16_X0_LO, IMM16_X1_LO, IMM16_X0_HI,
-	IMM16_X1_HI, IMM16_X0_HA, IMM16_X1_HA, IMM16_X0_PCREL,
-	IMM16_X1_PCREL, IMM16_X0_LO_PCREL, IMM16_X1_LO_PCREL,
-	IMM16_X0_HI_PCREL, IMM16_X1_HI_PCREL, IMM16_X0_HA_PCREL,
-	IMM16_X1_HA_PCREL, IMM16_X0_GOT, IMM16_X1_GOT, IMM16_X0_GOT_LO,
-	IMM16_X1_GOT_LO, IMM16_X0_GOT_HI, IMM16_X1_GOT_HI,
-	IMM16_X0_GOT_HA, IMM16_X1_GOT_HA, MMSTART_X0, MMEND_X0,
-	MMSTART_X1, MMEND_X1, SHAMT_X0, SHAMT_X1, SHAMT_Y0, SHAMT_Y1,
-	IMM16_X0_TLS_GD, IMM16_X1_TLS_GD, IMM16_X0_TLS_GD_LO,
-	IMM16_X1_TLS_GD_LO, IMM16_X0_TLS_GD_HI, IMM16_X1_TLS_GD_HI,
-	IMM16_X0_TLS_GD_HA, IMM16_X1_TLS_GD_HA, IMM16_X0_TLS_IE,
-	IMM16_X1_TLS_IE, IMM16_X0_TLS_IE_LO, IMM16_X1_TLS_IE_LO,
-	IMM16_X0_TLS_IE_HI, IMM16_X1_TLS_IE_HI, IMM16_X0_TLS_IE_HA,
-	IMM16_X1_TLS_IE_HA, TLS_DTPMOD32, TLS_DTPOFF32, TLS_TPOFF32}
-	Add BFD_RELOC_TILEGX_{HW0, HW1, HW2, HW3, HW0_LAST, HW1_LAST,
-	HW2_LAST, COPY, GLOB_DAT, JMP_SLOT, RELATIVE, BROFF_X1,
-	JUMPOFF_X1, JUMPOFF_X1_PLT, IMM8_X0, IMM8_Y0, IMM8_X1, IMM8_Y1,
-	DEST_IMM8_X1, MT_IMM14_X1, MF_IMM14_X1, MMSTART_X0, MMEND_X0,
-	SHAMT_X0, SHAMT_X1, SHAMT_Y0, SHAMT_Y1, IMM16_X0_HW0,
-	IMM16_X1_HW0, IMM16_X0_HW1, IMM16_X1_HW1, IMM16_X0_HW2,
-	IMM16_X1_HW2, IMM16_X0_HW3, IMM16_X1_HW3, IMM16_X0_HW0_LAST,
-	IMM16_X1_HW0_LAST, IMM16_X0_HW1_LAST, IMM16_X1_HW1_LAST,
-	IMM16_X0_HW2_LAST, IMM16_X1_HW2_LAST, IMM16_X0_HW0_PCREL,
-	IMM16_X1_HW0_PCREL, IMM16_X0_HW1_PCREL, IMM16_X1_HW1_PCREL,
-	IMM16_X0_HW2_PCREL, IMM16_X1_HW2_PCREL, IMM16_X0_HW3_PCREL,
-	IMM16_X1_HW3_PCREL, IMM16_X0_HW0_LAST_PCREL,
-	IMM16_X1_HW0_LAST_PCREL, IMM16_X0_HW1_LAST_PCREL,
-	IMM16_X1_HW1_LAST_PCREL, IMM16_X0_HW2_LAST_PCREL,
-	IMM16_X1_HW2_LAST_PCREL, IMM16_X0_HW0_GOT, IMM16_X1_HW0_GOT,
-	IMM16_X0_HW1_GOT, IMM16_X1_HW1_GOT, IMM16_X0_HW2_GOT,
-	IMM16_X1_HW2_GOT, IMM16_X0_HW3_GOT, IMM16_X1_HW3_GOT,
-	IMM16_X0_HW0_LAST_GOT, IMM16_X1_HW0_LAST_GOT,
-	IMM16_X0_HW1_LAST_GOT, IMM16_X1_HW1_LAST_GOT,
-	IMM16_X0_HW2_LAST_GOT, IMM16_X1_HW2_LAST_GOT, IMM16_X0_HW0_TLS_GD,
-	IMM16_X1_HW0_TLS_GD, IMM16_X0_HW1_TLS_GD, IMM16_X1_HW1_TLS_GD,
-	IMM16_X0_HW2_TLS_GD, IMM16_X1_HW2_TLS_GD, IMM16_X0_HW3_TLS_GD,
-	IMM16_X1_HW3_TLS_GD, IMM16_X0_HW0_LAST_TLS_GD,
-	IMM16_X1_HW0_LAST_TLS_GD, IMM16_X0_HW1_LAST_TLS_GD,
-	IMM16_X1_HW1_LAST_TLS_GD, IMM16_X0_HW2_LAST_TLS_GD,
-	IMM16_X1_HW2_LAST_TLS_GD, IMM16_X0_HW0_TLS_IE,
-	IMM16_X1_HW0_TLS_IE, IMM16_X0_HW1_TLS_IE, IMM16_X1_HW1_TLS_IE,
-	IMM16_X0_HW2_TLS_IE, IMM16_X1_HW2_TLS_IE, IMM16_X0_HW3_TLS_IE,
-	IMM16_X1_HW3_TLS_IE, IMM16_X0_HW0_LAST_TLS_IE,
-	IMM16_X1_HW0_LAST_TLS_IE, IMM16_X0_HW1_LAST_TLS_IE,
-	IMM16_X1_HW1_LAST_TLS_IE, IMM16_X0_HW2_LAST_TLS_IE,
-	IMM16_X1_HW2_LAST_TLS_IE, TLS_DTPMOD64, TLS_DTPOFF64, TLS_TPOFF64,
-	TLS_DTPMOD32, TLS_DTPOFF32, TLS_TPOFF32}
-	* targets.c (bfd_elf32_tilegx_vec): Declare.
-	(bfd_elf32_tilepro_vec): Declare.
-	(bfd_elf64_tilegx_vec): Declare.
-	(bfd_target_vector): Add bfd_elf32_tilegx_vec, bfd_elf32_tilepro_vec,
-	and bfd_elf64_tilegx_vec.
-	* cpu-tilegx.c: New file.
-	* cpu-tilepro.c: New file.
-	* elf32-tilepro.h: New file.
-	* elf32-tilepro.c: New file.
-	* elf32-tilegx.c: New file.
-	* elf32-tilegx.h: New file.
-	* elf64-tilegx.c: New file.
-	* elf64-tilegx.h: New file.
-	* elfxx-tilegx.c: New file.
-	* elfxx-tilegx.h: New file.
-
-2011-06-13  Alan Modra  <[email protected]>
-
-	* linker.c (bfd_link_hash_traverse): Follow warning symbol link.
-	(_bfd_generic_link_write_global_symbol, fix_syms): Don't handle
-	warning symbols here.
-	* elf-m10300.c (elf32_mn10300_finish_hash_table_entry): Likewise.
-	* elf32-arm.c (allocate_dynrelocs_for_symbol,
-	elf32_arm_readonly_dynrelocs): Likewise.
-	* elf32-bfin.c (bfin_discard_copies): Likewise.
-	* elf32-cris.c (elf_cris_adjust_gotplt_to_got,
-	elf_cris_discard_excess_dso_dynamics,
-	elf_cris_discard_excess_program_dynamics): Likewise.
-	* elf32-hppa.c (allocate_plt_static, allocate_dynrelocs,
-	clobber_millicode_symbols, readonly_dynrelocs): Likewise.
-	* elf32-i370.c (i370_elf_adjust_dynindx): Likewise.
-	* elf32-i386.c (elf_i386_allocate_dynrelocs,
-	elf_i386_readonly_dynrelocs): Likewise.
-	* elf32-lm32.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
-	* elf32-m32c.c (m32c_relax_plt_check, m32c_relax_plt_realloc): Likewise.
-	* elf32-m32r.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
-	* elf32-m68k.c (elf_m68k_discard_copies): Likewise.
-	* elf32-microblaze.c (allocate_dynrelocs): Likewise.
-	* elf32-ppc.c (allocate_dynrelocs, maybe_set_textrel): Likewise.
-	* elf32-s390.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
-	* elf32-score.c (score_elf_sort_hash_table_f): Likewise.
-	* elf32-score7.c (score_elf_sort_hash_table_f): Likewise.
-	* elf32-sh.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
-	* elf32-tic6x.c (elf32_tic6x_allocate_dynrelocs,
-	elf32_tic6x_readonly_dynrelocs): Likewise.
-	* elf32-vax.c (elf_vax_discard_copies): Likewise.
-	* elf32-xstormy16.c (xstormy16_relax_plt_check,
-	xstormy16_relax_plt_realloc): Likewise.
-	* elf32-xtensa.c (elf_xtensa_allocate_dynrelocs): Likewise.
-	* elf64-alpha.c (elf64_alpha_output_extsym,
-	elf64_alpha_calc_got_offsets_for_symbol,
-	elf64_alpha_calc_dynrel_sizes, elf64_alpha_size_rela_got_1): Likewise.
-	* elf64-hppa.c (elf64_hppa_mark_exported_functions,
-	allocate_global_data_opd, elf64_hppa_mark_milli_and_exported_functions,
-	elf_hppa_unmark_useless_dynamic_symbols,
-	elf_hppa_remark_useless_dynamic_symbols): Likewise.
-	* elf64-ppc.c (ppc64_elf_gc_mark_dynamic_ref, func_desc_adjust,
-	adjust_opd_syms, adjust_toc_syms, allocate_dynrelocs,
-	readonly_dynrelocs, merge_global_got, reallocate_got,
-	undo_symbol_twiddle): Likewise.
-	* elf64-s390.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
-	* elf64-sh64.c (sh64_elf64_discard_copies): Likewise.
-	* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs,
-	elf_x86_64_readonly_dynrelocs): Likewise.
-	* elflink.c (elf_link_renumber_hash_table_dynsyms,
-	elf_link_renumber_local_hash_table_dynsyms, _bfd_elf_export_symbol,
-	_bfd_elf_link_find_version_dependencies,
-	_bfd_elf_link_assign_sym_version, _bfd_elf_adjust_dynamic_symbol,
-	_bfd_elf_link_sec_merge_syms, elf_adjust_dynstr_offsets,
-	elf_collect_hash_codes, elf_collect_gnu_hash_codes,
-	elf_renumber_gnu_hash_syms, elf_gc_sweep_symbol,
-	elf_gc_propagate_vtable_entries_used,
-	elf_gc_smash_unused_vtentry_relocs, bfd_elf_gc_mark_dynamic_ref_symbol,
-	elf_gc_allocate_got_offsets): Likewise.
-	* elfnn-ia64.c (elfNN_ia64_global_dyn_info_free,
-	elfNN_ia64_global_dyn_sym_thunk): Likewise.
-	* elfxx-mips.c (mips_elf_check_symbols, mips_elf_output_extsym,
-	mips_elf_sort_hash_table_f, allocate_dynrelocs): Likewise.
-	* elfxx-sparc.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
-	* i386linux.c (linux_tally_symbols): Likewise.
-	* m68klinux.c (linux_tally_symbols): Likewise.
-	* sparclinux.c (linux_tally_symbols): Likewise.
-	* sunos.c (sunos_scan_dynamic_symbol): Likewise.
-	* xcofflink.c (xcoff_post_gc_symbol): Likewise.
-
-	* elflink.c (elf_link_output_extsym): Make it a bfd_hash_traverse
-	function.  Update all callers.
-	* aoutx.h (aout_link_write_other_symbol): Likewise.
-	* pdp11.c (aout_link_write_other_symbol): Likewise.
-	* cofflink.c (_bfd_coff_write_global_sym): Likewise.
-	* ecoff.c (ecoff_link_write_external): Likewise.
-	* xcofflink.c (xcoff_write_global_symbol): Likewise.
-	* vms-alpha.c (alpha_vms_link_output_symbol): Likewise.  Handle
-	warning symbols.
-	* ecoff.c (ecoff_link_hash_traverse): Delete.
-	* coff-ppc.c (ppc_bfd_coff_final_link): Use bfd_hash_traverse for
-	_bfd_coff_write_global_sym.
-	* libcoff-in.h (_bfd_coff_write_global_sym): Update prototype.
-	* libcoff.h: Regenerate.
-
-2011-06-10  Nick Clifton  <[email protected]>
-
-	* elflink.c (_bfd_elf_link_create_dynamic_sections): If the
-	backend does not provide a function for creating dynamic sections
-	then fail.
-	(bfd_elf_final_link): Issue a warning message if a dynamic section
-	has the SHT_NOTE type.
-	(bfd_elf_final_link): Do not look for dynamic strings in a section
-	that does not have the SHT_STRTAB type or the name .dynstr.
-	* elf32-arm.c (elf32_arm_finish_dynamic_sections): Fail if the got
-	section is not in the output binary.
-	* elf32-hppa.c (elf32_hppa_finish_dynamic_sections): Likewise.
-
-2011-06-09  Tristan Gingold  <[email protected]>
-
-	* elfnn-ia64.c (elfNN_ia64_relax_section, elfNN_ia64_choose_gp)
-	(elfNN_ia64_relocate_section, elfNN_vms_object_p): Remove trailing
-	spaces.
-
-2011-06-09  Tristan Gingold  <[email protected]>
-
-	* bfd.c (bfd_get_sign_extend_vma): Handle aixcoff.
-
-2011-06-09  Nick Clifton  <[email protected]>
-
-	PR ld/12845
-	* elf.c (_bfd_elf_init_private_section_data): Add an assertion
-	that the output section has an allocated bfd_elf_section_data
-	structure.
-	* elfxx-mips.c (mips_elf_check_symbols): Do not create a stub for
-	symbols in sections that have been removed by garbage collection.
-
-2011-06-08  H.J. Lu  <[email protected]>
-
-	* elf64-x86-64.c (elf_x86_64_check_relocs): Allow R_X86_64_64
-	relocations in SEC_DEBUGGING sections when building shared
-	libraries.
-
-2011-06-08  H.J. Lu  <[email protected]>
-
-	PR ld/12851
-	* elflink.c (elf_gc_sweep): Don't check SHT_NOTE sections here.
-	(bfd_elf_gc_sections): Also check SHT_NOTE sections.
-
-2011-06-08  Tristan Gingold  <[email protected]>
-
-	* makefile.vms (OBJS): Add elfxx-ia64.obj
-	Remove vax case.
-
-2011-06-08  Alan Modra  <[email protected]>
-
-	* aix386-core.c, * cisco-core.c, * hpux-core.c, * osf-core.c,
-	* sco5-core.c: Init match_priority field.
-
-2011-06-08  Alan Modra  <[email protected]>
-
-	* elflink.c (_bfd_elf_archive_symbol_lookup): Follow warning and
-	indirect links here.
-
-2011-06-07  Joel Brobecker  <[email protected]>
-
-	* irix-core.c (irix_core_vec): Add match_priority field.
-
-2011-06-06  Alan Modra  <[email protected]>
-
-	* targets.c (bfd_target): Make ar_max_namelen an unsigned char.
-	Add match_priority.
-	* configure.in: Bump bfd version.
-	* elfcode.h (elf_object_p): Delete hacks preventing match of
-	EM_NONE and ELFOSABI_NONE targets when a better match exists.
-	* elfxx-target.h (elf_match_priority): Define and use.
-	* format.c (bfd_check_format_matches): Use target match_priority
-	to choose best of multiple matching targets.  In cases with multiple
-	matches rerun _bfd_check_format if we don't choose the last match.
-	* aout-adobe.c, * aout-arm.c, * aout-target.h, * aout-tic30.c,
-	* binary.c, * bout.c, * coff-alpha.c, * coff-i386.c, * coff-i860.c,
-	* coff-i960.c, * coff-ia64.c, * coff-mips.c, * coff-or32.c,
-	* coff-ppc.c, * coff-rs6000.c, * coff-sh.c, * coff-tic30.c,
-	* coff-tic54x.c, * coff-x86_64.c, * coff64-rs6000.c, * coffcode.h,
-	* i386msdos.c, * i386os9k.c, * ieee.c, * ihex.c, * mach-o-target.c,
-	* mipsbsd.c, * mmo.c, * nlm-target.h, * oasys.c, * pdp11.c,
-	* pe-mips.c, * pef.c, * plugin.c, * ppcboot.c, * som.c, * srec.c,
-	* tekhex.c, * trad-core.c, * verilog.c, * versados.c, * vms-alpha.c,
-	* vms-lib.c, * xsym.c: Init match_priority field.
-	* configure: Regenerate.
-	* bfd-in2.h: Regenerate.
-
-2011-06-04  H.J. Lu  <[email protected]>
-
-	PR ld/12842
-	* elfcode.h (elf_object_p): Revert the last change.
-
-2011-06-04  Alan Modra  <[email protected]>
-
-	* archures.c (bfd_arch_get_compatible): If one arch is unknown,
-	return the other arch.
-	* elfcode.h (elf_object_p): Allow explicit match to generic ELF
-	target.
-
-2011-06-03  Bertram Felgenhauer  <[email protected]>
-
-	PR ld/12682
-	* hash.c (higher_primer_number): Add more, small, prime numbers.
-	(bfd_hash_set_default_size): Likewise.
-
-2011-06-02  Nick Clifton  <[email protected]>
-
-	* coff-mcore.c: Fix spelling typo.
-	* coff-stgo32.c: Likewise.
-	* elf32-arm.c: Likewise.
-	* elf32-avr.c: Likewise.
-	* elf-m68hc1x.c: Likewise.
-	* elf32-mcore.c: Likewise.
-	* elf32-mep.c: Likewise.
-	* elf32-mt.c: Likewise.
-	* elf32-ppc.c: Likewise.
-	* elf32-xtensa.c: Likewise.
-	* elf64-ppc.c: Likewise.
-	* elfxx-mips.c: Likewise.
-	* netbsd.h: Likewise.
-	* nlmcode.h: Likewise.
-	* vms-alpha.c: Likewise.
-	* po/bfd.pot: Regenerate.
-	* po/SRC-POTFILES.in: Regenerate.
-
-2011-06-01  DJ Delorie  <[email protected]>
-
-	* config.bfd: Add bfd_elf32_rx_be_ns_vec.
-	* target.c: Likewise.
-	* configure.in: Likewise.
-	* configure.in: Regenerate.
-	* elf32-rx.c: Add elf32-rx-be-ns target.
-	(rx_elf_object_p): Never allow the be-ns target by default,
-	only allow it if the user requests it.
-
-2011-06-01  H.J. Lu  <[email protected]>
-
-	* elf32-i386.c (elf_i386_size_dynamic_sections): Properly warn
-	relocation in readonly section in a shared object.
-	* elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Likewise.
-
-2011-05-31  Nick Clifton  <[email protected]>
-
-	* archive.c (adjust_relative_path): Fix comment to prevent it
-	corrupting the auto-generated bfd.h.
-
-2011-05-31  Paul Brook  <[email protected]>
-
-	* elf32-arm.c (elf32_arm_final_link_relocate): Only do bl conversion
-	for known functions.
-	(elf32_arm_swap_symbol_in): Only set ST_BRANCH_TO_ARM for function
-	symbols.
-
-2011-05-31  Paul Brook  <[email protected]>
-
-	* elf32-arm.c (arm_stub_is_thumb): Add
-	arm_stub_long_branch_v4t_thumb_tls_pic.
-	(elf32_arm_final_link_relocate): TLS stubs are always ARM.
-	Handle Thumb stubs.
-
-2011-05-27  Nick Clifton  <[email protected]>
-
-	PR binutils/12710
-	* archive.c (_bfd_get_elt_at_filepos): Set correct error value if
-	unable to read a file pointed to by an entry in a thin archive.
-	(adjust_relative_path): Use lrealpath to canonicalize paths.
-	Handle the case where the reference path is above the current
-	path in the directory tree.
-
-2011-05-26  H.J. Lu  <[email protected]>
-
-	PR ld/12809
-	* elf64-x86-64.c (elf_x86_64_relocate_section): Handle
-	R_X86_64_TPOFF64 in executable.
-
-2011-05-26  Alan Modra  <[email protected]>
-
-	* elf-bfd.h (SYMBOL_REFERENCES_LOCAL): Remove most of comment.
-	* elflink.c (_bfd_elf_symbol_refs_local_p): Expand
-	local_protected comment.
-
-2011-05-25  Tristan Gingold  <[email protected]>
-
-	* configure.in (bfd_elf32_ia64_big_vec, bfd_elf32_ia64_hpux_big_vec)
-	(bfd_elf64_ia64_big_vec, bfd_elf64_ia64_hpux_big_vec)
-	(bfd_elf64_ia64_little_vec, bfd_elf64_ia64_vms_vec): Add elfxx-ia64.lo
-	* Makefile.am (BFD64_BACKENDS): Add elfxx-ia64.lo
-	(BFD64_BACKENDS_CFILES): Add elfxx-ia64.c
-	(elf32-ia64.c): Created from elfnn-ia64.c
-	(elf64-ia64.c): Likewise.
-	* elfxx-ia64.h: New file.
-	* elfxx-ia64.c: Split with elfnn-ia64.c.  Keep only the following
-	functions.Includes elfxx-ia64.h.
-	(elfNN_ia64_reloc): Renames to ia64_elf_reloc.  Adjust error message.
-	(IA64_HOWTO): Adjust.
-	(lookup_howto): Renames to ia64_elf_lookup_howto.  Make it public.
-	(elfNN_ia64_reloc_type_lookup): Renames to
-	ia64_elf_reloc_type_lookup. Make it public. Adjust calls.
-	(elfNN_ia64_reloc_name_lookup): Renames to
-	ia64_elf_reloc_name_lookup. Make it public.
-	(elfNN_ia64_relax_br): Renames to ia64_elf_relax_br.  Make it public.
-	(elfNN_ia64_relax_brl): Renames to ia64_elf_relax_brl. Make it
-	public.
-	(elfNN_ia64_relax_ldxmov): Renames to ia64_elf_relax_ldxmov.
-	Move it and make it public.  Move prototype to elfxx-ia64.h
-	(elfNN_ia64_install_value): Renames to ia64_elf_install_value.
-	Move prototype to elfxx-ia64.h
-	* elfnn-ia64.c: New file, split from elfxx-ia64.c.
-	(elfNN_ia64_info_to_howto): Adjust calls.
-	(elfNN_ia64_relax_section): Adjust calls.
-	(count_dyn_reloc): Fix typo.
-	(elfNN_ia64_relocate_section): Adjust calls.
-	(elfNN_ia64_finish_dynamic_symbol): Likewise.
-	(bfd_elfNN_bfd_reloc_type_lookup)
-	(bfd_elfNN_bfd_reloc_name_lookup): Adjust macros.
-	* configure: Regenerate.
-	* Makefile.in: Regenerate.
-
-2011-05-23  DJ Delorie  <[email protected]>
-
-	* elf32-rx.c (rx_elf_object_p): When reading an RX object in, undo
-	the vma/lma swapping done in elf32_rx_modify_program_headers.
-
-2011-05-23  Nick Clifton  <[email protected]>
-
-	* elf-m10300.c (mn10300_elf_mkobject): New function.
-	(bfd_elf32_mkobject): Define.
-
-2011-05-23  Alan Modra  <[email protected]>
-
-	* elf-bfd.h: Comment typo fix.
-	* elf32-ppc.c (struct ppc_elf_dyn_relocs): Delete.  Replace with
-	struct elf_dyn_relocs throughout.
-	* elf64-ppc.c (struct ppc_dyn_relocs): Likewise.
-
-2011-05-23  Alan Modra  <[email protected]>
-
-	* elf32-frv.c: Use info->callbacks->einfo throughout file in linker
-	functions rather than warning callback or _bfd_error_handler.
-	* elf32-ppc.c: Likewise.
-	* elf64-ppc.c: Likewise.
-	* elf32-ppc.c (ppc_elf_tls_optimize): Use %H in __tls_get_addr lost
-	arg error.
-	* elf64-ppc.c (ppc64_elf_tls_optimize): Likewise.
-
-2011-05-23  Alan Modra  <[email protected]>
-
-	PR 12763
-	* elf.c (assign_file_positions_for_load_sections): Set sh_offset for
-	.tbss, and page align same for all SHT_NOBITS sections.
-
-2011-05-21  Alan Modra  <[email protected]>
-
-	PR 12763
-	* elf.c (_bfd_elf_make_section_from_shdr): Set up TLS section LMAs
-	from PT_TLS header.
-	(_bfd_elf_map_sections_to_segments): Don't create a final PT_LOAD
-	segment if just for .tbss.
-	(assign_file_positions_for_load_sections): Don't report "can't
-	allocate in segment" errors for .tbss.
-	(assign_file_positions_for_non_load_sections): Don't set p_filesz
-	from SHT_NOBITS section filepos.
-
-2011-05-20  Bernd Schmidt  <[email protected]>
-
-	* elf32-tic6x.c (elf32_tic6x_howto_table): Add entries for
-	R_C6000_PCR_H16 and R_C6000_PCR_L16.
-	(elf32_tic6x_relocate_section): Handle them.
-
-2011-05-18  Nick Clifton  <[email protected]>
-
-	PR ld/12761
-	* elflink.c (elf_link_add_object_symbols): Process .gnu.warning
-	sections when building shared libraries.
-
-2011-05-18  RafaÅ‚ Krypa  <[email protected]>
-
-	PR ld/12778
-	* elf32-arm.c (elf32_arm_gc_sweep_hook): Use the computed dynamic
-	reloc pointer.
-
-2011-05-18  Tristan Gingold  <[email protected]>
-
-	* xcofflink.c (xcoff_link_add_symbols): Handle C_DWARF symbols.
-	(xcoff_sweep): Always keep dwarf sections.
-	(xcoff_link_input_bfd): Handle dwarf symbols and sections.
-
-2011-05-18  Tristan Gingold  <[email protected]>
-
-	* libxcoff.h (struct xcoff_dwsect_name): New type.
-	(XCOFF_DWSECT_NBR_NAMES): New macro.
-	(xcoff_dwsect_names): Declare.
-	* coffcode.h (sec_to_styp_flags): Handle xcoff dwarf sections.
-	(styp_to_sec_flags): Ditto.
-	(coff_new_section_hook): Ditto.
-	(coff_slurp_symbol_table): Handle C_DWARF and C_INFO.
-	* coff-rs6000.c (xcoff_dwsect_name): New variable.
-
-2011-05-17  Tomohiro Kashiwada  <[email protected]>
-
-	PR ld/12759
-	* elf32-rx.c (ignore_lma): New variable.
-	(bfd_elf32_rx_set_target_flags): Add ignore_lma parameter.
-	(rx_modify_program_headers): Only copy the LMA into the VMA if
-	ignore_lma is true.
-
-2011-05-17  Alan Modra  <[email protected]>
-
-	PR ld/12760
-	* coff-aux.c (coff_m68k_aux_link_add_one_symbol): Adjust "notice" call.
-	* elflink.c (elf_link_add_object_symbols): Likewise.
-	* linker.c (_bfd_generic_link_add_one_symbol): Likewise.
-
-2011-05-16  Alan Modra  <[email protected]>
-
-	* linker.c (_bfd_generic_link_add_one_symbol): Don't init u.undef.weak.
-
-2011-05-15  Richard Sandiford  <[email protected]>
-
-	* elfxx-mips.c (_bfd_mips_elf_check_relocs): Record both local and
-	global GOT entries for GOT_PAGE relocations against global symbols.
-
-2011-05-13  Bernd Schmidt  <[email protected]>
-
-	* config.bfd (tic6x-*-elf, tic6x-*-uclinux): New.
-	(tic6x-*-*): Replaced by these.
-	* elf32-tic6x.c (elf32_tic6x_set_osabi): New static function.
-	(elf32_tic6x_check_relocs): Create dynamic sections if -shared.
-	(elf_backend_relocs_compatible, elf_backend_post_process_headers):
-	Define.
-	(elf32_bed, TARGET_LITTLE_SYM, TARGET_LITTLE_NAME, TARGET_BIG_SYM,
-	TARGET_BIG_NAME, ELF_OSABI): Redefine twice, and include
-	"elf32-target.h" two more times.
-	* configure.in: Handle bfd_elf32_tic6x_linux_be_vec,
-	bfd_elf32_tic6x_linux_le_vec, bfd_elf32_tic6x_elf_be_vec and
-	bfd_elf32_tic6x_elf_le_vec.
-	* configure: Regenerate.
-
-2011-05-13  Jan Beulich  <[email protected]>
-
-	* config.bfd: Add targets x86_64-*-pe and x86_64-*-pep.
-
-2011-05-12  Jan Kratochvil  <[email protected]>
-
-	* config.in: Regenerated.
-	* configure: Regenerated.
-	* configure.in: New tests for HAVE_PRPSINFO_T_PR_PID,
-	HAVE_PRPSINFO32_T_PR_PID, HAVE_PSINFO_T_PR_PID and
-	HAVE_PSINFO32_T_PR_PID.
-	* elf.c (elfcore_grok_psinfo): Protect reading psinfo.pr_pid by
-	HAVE_PRPSINFO_T_PR_PID, HAVE_PRPSINFO32_T_PR_PID, HAVE_PSINFO_T_PR_PID
-	and HAVE_PSINFO32_T_PR_PID.
-	* hosts/x86-64linux.h (HAVE_PRPSINFO32_T_PR_PID): New redefinition.
-
-2011-05-10  Jan Kratochvil  <[email protected]>
-
-	* elf.c (elfcore_grok_psinfo): Initialize CORE_PID for both native and
-	32bit psinfo.
-	* elf32-ppc.c (ppc_elf_grok_psinfo): Initialize core_pid.
-	* elf64-ppc.c (ppc64_elf_grok_psinfo): Likewise.
-
-2011-05-09  Paul Brook  <[email protected]>
-
-	* bfd-in.h (elf32_tic6x_fix_exidx_coverage): Add prototype.
-	* bfd-in2.h: Regenerate.
-	* elf32-tic6x.c: Include limits.h.
-	(tic6x_unwind_edit_type, tic6x_unwind_table_edit,
-	_tic6x_elf_section_data): New.
-	(elf32_tic6x_section_data): Define.
-	(elf32_tic6x_new_section_hook): Allocate target specific data.
-	(elf32_tic6x_add_unwind_table_edit): New function.
-	(get_tic6x_elf_section_data, elf32_tic6x_adjust_exidx_size,
-	elf32_tic6x_insert_cantunwind_after, elf32_tic6x_add_low31,
-	elf32_tic6x_copy_exidx_entry): New functions.
-	(elf_backend_write_section): Define.
-
-2011-05-09  Paul Brook  <[email protected]>
-
-	* elf32-tic6x.c (is_tic6x_elf_unwind_section_name,
-	elf32_tic6x_fake_sections): New functions.
-	(elf_backend_fake_sections): Define.
-
-2011-05-09  Paul Brook  <[email protected]>
-
-	* elf32-tic6x.c (elf32_tic6x_gc_mark_extra_sections): New function.
-	(elf_backend_gc_mark_extra_sections): Define.
-
-2011-05-07  Dave Korn  <[email protected]>
-
-	PR ld/12365
-	* cofflink.c (bfd_coff_link_input_bfd): Check for and warn about
-	references to symbols defined in discarded sections.
-
-2011-05-07  Dave Korn  <[email protected]>
-
-	PR ld/12365
-	* coffgen.c (coff_write_symbol): Assume input section is its own
-	output section if output_section member not set.
-	(coff_write_alien_symbol): Likewise.
-
-2011-05-07  H.J. Lu  <[email protected]>
-
-	PR ld/12730
-	* elf.c (_bfd_elf_section_offset): Check SEC_ELF_REVERSE_COPY.
-
-	* elflink.c (elf_link_input_bfd): Reverse copy .ctors/.dtors
-	sections if needed.
-
-	* section.c (SEC_ELF_REVERSE_COPY): New.
-	* bfd-in2.h: Regenerated.
-
-2011-05-07  Anders Kaseorg  <[email protected]>
-
-	PR 12739
-	* libbfd.c (bfd_get_8, bfd_get_signed_8): Use const cast.
-	* bfd-in2.h: Regenerate.
-
-2011-05-06  Tristan Gingold  <[email protected]>
-
-	* vms-alpha.c (evax_section_flags): Remove SEC_IN_MEMORY.
-	(_bfd_vms_slurp_egsd): Rename old_flags to vms_flags.  Handle
-	any code section.  Add comments.
-	(alpha_vms_object_p): Use void * instead of PTR.
-	(alpha_vms_create_eisd_for_section): Fix test for setting DZRO.
-	(build_module_list): Guard against no DST section.  Add comments.
-	(alpha_vms_link_output_symbol): Discard undefined symbols.
-	(alpha_vms_get_section_contents): Simply memcpy if the section was
-	already loaded.  Fix typo.
-	(vms_new_section_hook): Use void * instead of PTR.
-	(vms_alpha_vec): Ditto.
-
-2011-05-06  Richard Sandiford  <[email protected]>
-
-	* elf32-arm.c (cortex_a8_erratum_scan): If the stub is a Thumb
-	branch to a PLT entry, redirect it to the PLT's Thumb entry point.
-
-2011-05-05  Bernd Schmidt  <[email protected]>
-
-	* elf32-tic6x.c (elf32_tic6x_final_link): New function.
-	(elf32_tic6x_merge_attributes): Do not warn for PID or PIC
-	mismatch.  Choose the lower of the two values.
-	(bfd_elf32_bfd_final_link): New macro.
-
-2011-04-28  Tristan Gingold  <[email protected]>
-
-	* coff-rs6000.c (_bfd_xcoff_swap_aux_in): Adjust for x_file.
-	(bfd_xcoff_swap_aux_out): Ditto.
-	* coff64-rs6000.c (_bfd_xcoff64_swap_aux_in): Ditto.
-	(bfd_xcoff64_swap_aux_out): Ditto.
-
-2011-05-04  Alan Modra  <[email protected]>
-
-	PR ld/12727
-	* elf64-ppc.c (ppc_build_one_stub <ppc_sub_plt_call>): Clear
-	was_undefined on dot-symbols.
-
-2011-05-03  Paul Brook  <[email protected]>
-
-
-	* elf32-tic6x.c (elf32_tic6x_howto_table,
-	elf32_tic6x_howto_table_rel, (elf32_tic6x_gc_sweep_hook,
-	elf32_tic6x_relocate_section, elf32_tic6x_check_relocs):
-	Add R_C6000_EHTYPE.
-
-2011-05-01  Alan Modra  <[email protected]>
-
-	PR ld/12718
-	* elf32-i386.c (elf_i386_check_relocs): Ensure dynobj set before
-	creating ifunc sections.
-	* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
-
-2011-04-30  H.J. Lu  <[email protected]>
-
-	* elf64-x86-64.c (elf_x86_64_merge_symbol): Correct parameter
-	names.
-
-2011-04-28  Tom Tromey  <[email protected]>
-
-	* bfdio.c (memory_bstat): Pass correct size to memset.
-
-2011-04-28  Mike Frysinger  <[email protected]>
-
-	* dwarf2.c (dwarf_debug_sections): Mark const.
-	* elf.c (special_sections): Likewise.
-	* libbfd-in.h (dwarf_debug_sections): Likewise.
-	* libbfd.h: Regenerate.
-
-2011-04-26  Kai Tietz  <[email protected]>
-
-	* coffcode.h (sec_to_styp_flags): Allow linkonce for
-	debugging sections.
-
-2011-04-26  Tristan Gingold  <[email protected]>
-
-	* coff64-rs6000.c: Convert to ISO-C.  Remove PARAMS and PTR macros.
-
-2011-04-24  Alan Modra  <[email protected]>
-
-	PR ld/12365
-	PR ld/12696
-	* coff-aux.c (coff_m68k_aux_link_add_one_symbol): Update "notice" call.
-	* linker.c (_bfd_link_hash_newfunc): Clear bitfields.
-	(_bfd_generic_link_add_one_symbol): Update "notice" call.
-	* elflink.c (_bfd_elf_merge_symbol): Don't skip weak redefs when
-	it is a redef of an IR symbol in a real BFD.
-
-2011-04-22  H.J. Lu  <[email protected]>
-
-	* elf32-i386.c (elf_i386_readonly_dynrelocs): Warn relocation
-	in readonly section in a shared object.
-	(elf_i386_size_dynamic_sections): Likewise.
-	* elf64-x86-64.c (elf_x86_64_readonly_dynrelocs): Likewise.
-	(elf_x86_64_size_dynamic_sections): Likewise.
-
-2011-04-21  H.J. Lu  <[email protected]>
-
-	PR ld/12694
-	* elf32-i386.c (elf_i386_readonly_dynrelocs): Skip local IFUNC
-	symbols.
-	* elf64-x86-64.c (elf_x86_64_readonly_dynrelocs): Likewise.
-
-2011-04-21  H.J. Lu  <[email protected]>
-
-	* elf32-i386.c (elf_i386_finish_dynamic_symbol): Return false
-	on dynamic symbol error.
-	* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Likewise.
-
-2011-04-20  Tristan Gingold  <[email protected]>
-
-	* config.bfd (alpha*-*-*vms*, ia64*-*-*vms*): Define targ_selvecs.
-
-2011-04-20  Alan Modra  <[email protected]>
-
-	* hash.c (bfd_default_hash_table_size): Make it an unsigned long.
-	(bfd_hash_table_init_n): Overflow checking.
-	(bfd_hash_set_default_size): Return current size.  Take unsigned long
-	arg.  Add 65537 to hash_size primes.
-	* bfd-in.h (bfd_hash_set_default_size): Update prototype.
-	* bfd-in2.h: Regenerate.
-
-2011-04-20  Jan Kratochvil  <[email protected]>
-
-	* elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): Fix +1 overrun of
-	memmove elements.
-
-2011-04-20  Alan Modra  <[email protected]>
-
-	* libbfd.c (bfd_log2): Do return rounded up value.
-	* elflink.c (bfd_elf_size_dynsym_hash_dynstr): Replace bfd_log2
-	call with expanded old round down version of the function.
-
-	* archive.c (_bfd_get_elt_at_filepos): Don't release n_nfd.
-	* elflink.c (elf_link_add_object_symbols): Delete redundant code.
-
-2011-04-20  Alan Modra  <[email protected]>
-
-	PR ld/12365
-	* elfcode.h (elf_slurp_symbol_table): Put common plugin IR symbols
-	in their own common section.
-	* elflink.c (elf_link_add_object_symbols): Likewise.
-	* linker.c (generic_link_check_archive_element): Don't lose flags
-	if common section is pre-existing.
-	(_bfd_generic_link_add_one_symbol): Likewise.
-
-2011-04-20  Alan Modra  <[email protected]>
-
-	PR ld/12365
-	* elflink.c (_bfd_elf_merge_symbol): Update multiple_common calls.
-	* linker.c (_bfd_generic_link_add_one_symbol): Likewise.  Call
-	multiple_definition regardless of allow_multiple_definition.
-	* simple.c (simple_dummy_multiple_definition): Update.
-	* xcofflink.c (xcoff_link_add_symbols): Update multiple_definition
+	2013-10-30  Alan Modra  <[email protected]>
+		    Ulrich Weigand  <[email protected]>
+	* elf64-ppc.c (struct ppc_stub_hash_entry): Add "other".
+	(stub_hash_newfunc): Init new ppc_stub_hash_entry field, and one
+	we forgot, "plt_ent".
+	(ppc64_elf_add_symbol_hook): Check ELFv1 objects don't have
+	st_other bits only valid in ELFv2.
+	(ppc64_elf_merge_symbol_attribute): New function.
+	(ppc_type_of_stub): Add local_off param to test branch range.
+	(ppc_build_one_stub): Adjust destinations for ELFv2 locals.
+	(ppc_size_one_stub, toc_adjusting_stub_needed): Similarly.
+	(ppc64_elf_size_stubs): Pass local_off to ppc_type_of_stub.
+	Set "other" field.
+	(ppc64_elf_relocate_section): Adjust destination for ELFv2 local
 	calls.
 
-2011-04-18  Tristan Gingold  <[email protected]>
+	2013-10-30  Alan Modra  <[email protected]>
+	* elf64-ppc.c (abiversion, set_abiversion): New functions.
+	(ppc64_elf_get_synthetic_symtab): Handle ELFv2 objects without .opd.
+	(struct ppc_link_hash_table): Add opd_abi.
+	(ppc64_elf_check_relocs): Check no .opd with ELFv2.
+	(ppc64_elf_merge_private_bfd_data): New function.
+	(ppc64_elf_print_private_bfd_data): New function.
+	(ppc64_elf_tls_setup): Set htab->opd_abi.
+	(ppc64_elf_size_dynamic_sections): Don't emit OPD related dynamic
+	tags for ELFv2.
+	(ppc_build_one_stub): Use R_PPC64_IRELATIVE for ELFv2 ifunc.
+	(ppc64_elf_finish_dynamic_symbol): Likewise
 
-	* coff-rs6000.c: Convert to ISO-C.  Remove PARAMS macro.
+	2013-10-30  Alan Modra  <[email protected]>
+	* elf64-ppc.c (build_plt_stub): Switch stubs to use r11 as base
+	reg and r12 as destination.
+	(ppc_build_one_stub): Likewise.
+	(ppc64_elf_build_stubs): Likewise for glink.
 
-2011-04-18  Alan Modra  <[email protected]>
-
-	PR ld/12365
-	PR ld/12672
-	* bfd.c (BFD_PLUGIN): Define.
-	(BFD_FLAGS_SAVED, BFD_FLAGS_FOR_BFD_USE_MASK): Add BFD_PLUGIN.
-	* bfd-in2.h: Regenerate.
-	* elflink.c (elf_link_output_extsym): Strip undefined plugin syms.
-	* opncls.c (bfd_make_readable): Don't lose original bfd flags.
-
-2011-04-17  Jan Kratochvil  <[email protected]>
-
-	* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Do not check for
-	SEC_LOAD.
-
-2011-04-15  Sergio Durigan Junior  <[email protected]>
-
-	* elf-bfd.h (struct sdt_note): New struct.
-	(struct elf_obj_tdata) <sdt_note_head>: New field.
-	* elf.c (elfobj_grok_stapsdt_note_1): New function.
-	(elfobj_grok_stapsdt_note): Likewise.
-	(elf_parse_notes): Added code to treat SystemTap note
-	sections.
-
-2011-04-12  Richard Henderson  <[email protected]>
-
-	* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Do not
-	exclude empty .got sections.
-
-2011-04-11  H.J. Lu  <[email protected]>
-
-	* elf32-i386.c (elf_i386_reloc_type_lookup): Fix the out of bound
-	array access for BFD_RELOC_386_IRELATIVE.
-
-2011-04-11  Bernd Schmidt  <[email protected]>
-
-	* elf32-tic6x.c (elf32_tic6x_check_relocs): Initialize pc_count field.
-
-2011-04-11  Mark Wielaard  <[email protected]>
-
-	PR 10549
-	* elf-bfd.h (has_ifunc_symbols): Renamed to has_gnu_symbols.
-	(has_gnu_symbols): Renamed from has_ifunc_symbols.
-	* elf.c (_bfd_elf_set_osabi): Use new has_gnu_symbols name.
-	* elf32-arm.c (elf32_arm_add_symbol_hook): Set has_gnu_symbols
-	also if STB_GNU_UNIQUE symbol binding was seen.
-	* elf32-i386.c (elf_i386_add_symbol_hook): Likewise.
-	* elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise.
-	* elf32-sparc.c (elf32_sparc_add_symbol_hook): Likewise.
-	* elf64-ppc.c (ppc64_elf_add_symbol_hook): Likewise.
-	* elf64-sparc.c (elf64_sparc_add_symbol_hook): Likewise.
-	* elf64-x86-64.c (elf_x86_64_add_symbol_hook): Likewise.
-
-2011-04-11  Alan Modra  <[email protected]>
-
-	* bfd-in.h (bfd_get_section_limit): Don't use rawsize with output
-	sections.
-	* libbfd.c (_bfd_generic_get_section_contents): Likewise.
-	(_bfd_generic_get_section_contents_in_window): Likewise.
-	* section.c (bfd_get_section_contents): Likewise.
-	* compress.c (bfd_get_full_section_contents): Likewise.
-	* elf32-rx.c (rx_final_link): Ignore rawsize.
-	* elf32-microblaze.c (microblaze_elf_relocate_section): Use correct
-	bfd with bfd_get_section_limit.
-	* elfxx-ia64.c (elfNN_ia64_choose_gp): Add "final" parameter.  Use
-	os->size during final link.  Update callers.
-	* bfd-in2.h: Regenerate.
-
-2011-04-10  Richard Sandiford  <[email protected]>
-
-	PR ld/12637
-	* elfxx-mips.c (mips_elf_merge_got_with): Use arg->global_count
-	as the number of global entries when merging with the primary GOT.
-
-2011-04-09  H.J. Lu  <[email protected]>
-
-	* elf32-i386.c: Update copyright year.
-	* elf64-x86-64.c: Likewise.
-
-2011-04-09  Kai Tietz  <[email protected]>
-
-	* peXXigen.c (_bfd_XXi_final_link_postscripte): Sort pdata in temporary
-	buffer and use rawsize for sorting.
-	* coffcode.h (coff_compute_section_file_positions): Set rawsize
-	before doing alignment.
-
-2011-04-09  H.J. Lu  <[email protected]>
-
-	* elf32-i386.c (elf_i386_relocate_section): Return relocation
-	error on unsupported relocation.
-	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
-
-2011-04-09  H.J. Lu  <[email protected]>
-
-	PR binutils/12657
-	* hosts/x86-64linux.h (elf_prstatus32): Replace __pid_t with
-	pid_t.
-
-2011-04-08  H.J. Lu  <[email protected]>
-
-	PR ld/12654
-	* elf32-i386.c (elf_i386_relocate_section): Check !executable
-	instead of shared for R_386_TLS_LDO_32.
-
-2011-04-08  Tristan Gingold  <[email protected]>
-
-	* Makefile.am (SOURCE_HFILES): Remove xcoff-target.h
-	* coff-pmac: Remove
-	* xcoff-target.h: Remove
-	* Makefile.in: Regenerate.
-
-2011-04-07  Cary Coutant  <[email protected]>
-
-	* dwarf2.c (scan_unit_for_symbols): Check for DW_AT_specification.
-
-2011-04-07  Paul Brook  <[email protected]>
-
-	* elf32-tic6x.c (elf32_tic6x_howto_table): R_C6000_PREL31 is
-	pc-relative.
-	(elf32_tic6x_howto_table_rel): Ditto.
-	(elf32_tic6x_relocate_section): Implement R_C6000_PREL31.
-	(elf32_tic6x_check_relocs): Ditto.
-
-2011-04-06  Joseph Myers  <[email protected]>
-
-	* config.bfd (thumb-*-oabi): Don't handle in list of obsolete
-	targets.
-	(strongarm*, thumb*, xscale*): Remove architectures.
-	(strongarm-*-kaos*, thumb-*-coff, thumb-*-elf, thumb-epoc-pe*,
-	thumb-*-pe*, strongarm-*-elf, strongarm-*-coff, xscale-*-elf,
-	xscale-*-coff): Remove targets.
-
-2011-04-01  Tristan Gingold  <[email protected]>
-
-	* elfxx-ia64.c: include bfd_stdint.h
-
-2011-03-31  Jan Kratochvil  <[email protected]>
-
-	* elf32-tic6x.c (elf32_tic6x_relocate_section): Remove unused variable
-	dynobj and its initialization.
-
-2011-03-31  Tristan Gingold  <[email protected]>
-
-	* makefile.vms (DEFS): Add HAVE_bfd_elf64_ia64_vms_vec.
-	* configure.com: Set BFD_HOST_64BIT_LONG_LONG and
-	BFD_HOST_LONG_LONG to 1.
-
-2011-03-31  Tristan Gingold  <[email protected]>
-
-	* vms-alpha.c (vms_get_remaining_object_record): Fix dec-c warning.
-	(_bfd_vms_write_etir): Ditto.
-	(_bfd_vms_slurp_etir): Avoid to use intptr_t
-	* configure.com: Generate bfd_stdint.h
-
-2011-03-31  Bernd Schmidt  <[email protected]>
-
-	* elf32-tic6x.h (struct elf32_tic6x_params): New.
-	(elf32_tic6x_setup): Declare.
-	* elf32-tic6x.c: Include <limits.h>.
-	(ELF_DYNAMIC_LINKER, DEFAULT_STACK_SIZE, PLT_ENTRY_SIZE): Define.
-	(struct elf32_tic6x_link_hash_table, struct elf32_link_hash_entry):
-	New structures.
-	(elf32_tic6x_link_hash_table, is_tic6x_elf): New macros.
-	(tic6x_elf_scom_section, tic6x_elf_scom_symbol,
-	tic6x_elf_scom_symbol_ptr): New static variables.
-	(elf32_tic6x_howto_table, elf32_tic6x_howto_table_rel,
-	elf32_tic6x_reloc_map): Add R_C6000_JUMP_SLOT, R_C6000_EHTYPE,
-	R_C6000_PCR_H16 and R_C6000_PCR_L16.
-	(elf32_tic6x_link_hash_newfunc, elf32_tic6x_link_hash_table_create,
-	elf32_tic6x_link_hash_table_free, elf32_tic6x_setup,
-	elf32_tic6x_using_dsbt, elf32_tic6x_install_rela,
-	elf32_tic6x_create_dynamic_sections, elf32_tic6x_make_got_dynreloc,
-	elf32_tic6x_finish_dynamic_symbol, elf32_tic6x_gc_sweep_hook,
-	elf32_tic6x_adjust_dynamic_symbol): New static functions.
-	(elf32_tic6x_relocate_section): For R_C6000_PCR_S21, convert branches
-	to weak symbols as required by the ABI.
-	Handle GOT and DSBT_INDEX relocs, and copy relocs to the output file
-	as needed when generating DSBT output.
-	(elf32_tic6x_check_relocs, elf32_tic6x_add_symbol_hook,
-	elf32_tic6x_symbol_processing, elf32_tic6x_section_from_bfd_section,
-	elf32_tic6x_allocate_dynrelocs, elf32_tic6x_size_dynamic_sections,
-	elf32_tic6x_always_size_sections, elf32_tic6x_modify_program_headers,
-	elf32_tic6x_finish_dynamic_sections, elf32_tic6x_plt_sym_val,
-	elf32_tic6x_copy_private_data, elf32_tic6x_link_omit_section_dynsym):
-	New static functions.
-	(ELF_MAXPAGESIZE): Define to 0x1000.
-	(bfd_elf32_bfd_copy_private_bfd_data,
-	bfd_elf32_bfd_link_hash_table_create,
-	bfd_elf32_bfd_link_hash_table_free, elf_backend_can_refcount,
-	elf_backend_want_got_plt, elf_backend_want_dynbss,
-	elf_backend_plt_readonly, elf_backend_got_header_size,
-	elf_backend_gc_sweep_hook, elf_backend_modify_program_headers,
-	elf_backend_create_dynamic_sections, elf_backend_adjust_dynamic_symbol,
-	elf_backend_check_relocs, elf_backend_add_symbol_hook,
-	elf_backend_symbol_processing, elf_backend_link_output_symbol_hook,
-	elf_backend_section_from_bfd_section,
-	elf_backend_finish_dynamic_symbol, elf_backend_always_size_sections,
-	elf32_tic6x_size_dynamic_sections, elf_backend_finish_dynamic_sections,
-	elf_backend_omit_section_dynsym, elf_backend_plt_sym_val): Define.
-
-	* bfd/reloc.c (BFD_RELOC_C6000_JUMP_SLOT, BFD_RELOC_C6000_EHTYPE,
-	BFD_RELOC_C6000_PCR_H16, BFD_RELOC_C6000_PCR_S16): Add.
-	* bfd/bfd-in2.h: Regenerate.
-	* bfd/libbfd.h: Regenerate.
-	* config.bfd: Accept tic6x-*-* instead of tic6x-*-elf.
-
-2011-03-31  Tristan Gingold  <[email protected]>
-
-	* coffcode.h (coff_slurp_symbol_table): Silently discard C_NULL
-	entry on xcoff when value is C_NULL_VALUE.
-
-2011-03-31  Tristan Gingold  <[email protected]>
-
-	* libcoff-in.h (exec_hdr): Remove.
-	* libcoff.h: Regenerate.
-
-2011-03-30  Nick Clifton  <[email protected]>
-
-	* po/da.po: Updated Danish translation.
-
-2011-03-29  Richard Henderson  <[email protected]>
-
-	* elf64-alpha.c (elf64_alpha_gc_mark_hook): New.
-	(elf64_alpha_gc_sweep_hook): New.
-	(elf_backend_gc_mark_hook, elf_backend_gc_sweep_hook): New.
-	(elf_backend_can_gc_sections): New.
-
-2011-03-26  John Marino  <[email protected]>
-
-	* config.bfd: Add x86_64-*-dragonfly*, fix i386-*-dragonfly*.
-	* configure.in: Delete unused bfd_elf32_i386_dragonfly_vec.
-	* configure: Regenerate.
-
-2011-03-25  Michael Snyder  <[email protected]>
-
-	* coffcode.h (coff_set_alignment_hook): Check return of bfd_seek.
-
-2011-03-25  Tristan Gingold  <[email protected]>
-
-	* vms-alpha.c (_bfd_vms_find_nearest_dst_line): Allow the use
-	of find_nearest_line on object files.
-
-2011-03-25  Tristan Gingold  <[email protected]>
-
-	* vms-alpha.c (evax_section_flags): Make $CODE$ section read-only.
-	Minor reordering.
-	(alpha_vms_create_eisd_for_section): Make code sections read-only.
-
-2011-03-24  Alan Modra  <[email protected]>
-
-	* elf32-ppc.c (ppc_elf_tls_optimize): Catch more cases where
-	old-style __tls_get_addr calls without marker relocs don't match
-	their arg setup insn one for one.  If such mismatches are found
-	report the reloc and don't do any tls optimization.
-	* elf64-ppc.c (ppc64_elf_tls_optimize): Likewise.
-
-2011-03-22  Eric B. Weddington  <[email protected]>
-
-	* bfd-in2.h: Regenerate.
-
-2011-03-22  Eric B. Weddington  <[email protected]>
-
-	* archures.c: Add AVR XMEGA architecture information.
-	* cpu-avr.c (arch_info_struct): Likewise.
-	* elf32-avr.c (bfd_elf_avr_final_write_processing): Likewise.
-	(elf32_avr_object_p): Likewise.
-
-2011-03-14  Richard Sandiford  <[email protected]>
-
-	* reloc.c (BFD_RELOC_ARM_IRELATIVE): New relocation.
-	* bfd-in2.h: Regenerate.
-	* elf32-arm.c (elf32_arm_howto_table_2): Rename existing definition
-	to elf32_arm_howto_table_3 and replace with a single R_ARM_IRELATIVE
-	entry.
-	(elf32_arm_howto_from_type): Update accordingly.
-	(elf32_arm_reloc_map): Map BFD_RELOC_ARM_IRELATIVE to R_ARM_IRELATIVE.
-	(elf32_arm_reloc_name_lookup): Handle elf32_arm_howto_table_3.
-	(arm_plt_info): New structure, split out from elf32_arm_link_hash_entry
-	with an extra noncall_refcount field.
-	(arm_local_iplt_info): New structure.
-	(elf_arm_obj_tdata): Add local_iplt.
-	(elf32_arm_local_iplt): New accessor macro.
-	(elf32_arm_link_hash_entry): Replace plt_thumb_refcount,
-	plt_maybe_thumb_refcount and plt_got_offset with an arm_plt_info.
-	Change tls_type to a bitfield and add is_iplt.
-	(elf32_arm_link_hash_newfunc): Update accordingly.
-	(elf32_arm_allocate_local_sym_info): New function.
-	(elf32_arm_create_local_iplt): Likewise.
-	(elf32_arm_get_plt_info): Likewise.
-	(elf32_arm_plt_needs_thumb_stub_p): Likewise.
-	(elf32_arm_get_local_dynreloc_list): Likewise.
-	(create_ifunc_sections): Likewise.
-	(elf32_arm_copy_indirect_symbol): Update after the changes to
-	elf32_arm_link_hash_entry.  Assert the is_iplt has not yet been set.
-	(arm_type_of_stub): Add an st_type argument.  Use elf32_arm_get_plt_info
-	to get PLT information.  Assert that all STT_GNU_IFUNC references
-	are turned into PLT references.
-	(arm_build_one_stub): Pass the symbol type to
-	elf32_arm_final_link_relocate.
-	(elf32_arm_size_stubs): Pass the symbol type to arm_type_of_stub.
-	(elf32_arm_allocate_irelocs): New function.
-	(elf32_arm_add_dynreloc): In static objects, use .rel.iplt for
-	all R_ARM_IRELATIVE.
-	(elf32_arm_allocate_plt_entry): New function.
-	(elf32_arm_populate_plt_entry): Likewise.
-	(elf32_arm_final_link_relocate): Add an st_type parameter.
-	Set srelgot to null for static objects.  Use separate variables
-	to record which st_value and st_type should be used when generating
-	a dynamic relocation.  Use elf32_arm_get_plt_info to find the
-	symbol's PLT information, setting has_iplt_entry, splt,
-	plt_offset and gotplt_offset accordingly.  Check whether
-	STT_GNU_IFUNC symbols should resolve to an .iplt entry, and change
-	the relocation target accordingly.  Broaden assert to include
-	.iplts.  Don't set sreloc for static relocations.  Assert that
-	we only generate dynamic R_ARM_RELATIVE relocations for R_ARM_ABS32
-	and R_ARM_ABS32_NOI.  Generate R_ARM_IRELATIVE relocations instead
-	of R_ARM_RELATIVE relocations if the target is an STT_GNU_IFUNC
-	symbol.  Pass the symbol type to arm_type_of_stub.  Conditionally
-	resolve GOT references to the .igot.plt entry.
-	(elf32_arm_relocate_section): Update the call to
-	elf32_arm_final_link_relocate.
-	(elf32_arm_gc_sweep_hook): Use elf32_arm_get_plt_info to get PLT
-	information.  Treat R_ARM_REL32 and R_ARM_REL32_NOI as call
-	relocations in shared libraries and relocatable executables.
-	Count non-call PLT references.  Use elf32_arm_get_local_dynreloc_list
-	to get the list of dynamic relocations for a local symbol.
-	(elf32_arm_check_relocs): Always create ifunc sections.  Set isym
-	at the same time as setting h.  Use elf32_arm_allocate_local_sym_info
-	to allocate local symbol information.  Treat R_ARM_REL32 and
-	R_ARM_REL32_NOI as call relocations in shared libraries and
-	relocatable executables.  Record PLT information for local
-	STT_GNU_IFUNC functions as well as global functions.   Count
-	non-call PLT references.  Use elf32_arm_get_local_dynreloc_list
-	to get the list of dynamic relocations for a local symbol.
-	(elf32_arm_adjust_dynamic_symbol): Handle STT_GNU_IFUNC symbols.
-	Don't remove STT_GNU_IFUNC PLTs unless all references have been
-	removed.  Update after the changes to elf32_arm_link_hash_entry.
-	(allocate_dynrelocs_for_symbol): Decide whether STT_GNU_IFUNC PLT
-	entries should live in .plt or .iplt.  Check whether the .igot.plt
-	and .got entries can be combined.  Use elf32_arm_allocate_plt_entry
-	to allocate .plt and .(i)got.plt entries.  Detect which .got
-	entries will need R_ARM_IRELATIVE relocations and use
-	elf32_arm_allocate_irelocs to allocate them.  Likewise other
-	non-.got dynamic relocations.
-	(elf32_arm_size_dynamic_sections): Allocate .iplt, .igot.plt
-	and dynamic relocations for local STT_GNU_IFUNC symbols.
-	Check whether the .igot.plt and .got entries can be combined.
-	Detect which .got entries will need R_ARM_IRELATIVE relocations
-	and use elf32_arm_allocate_irelocs to allocate them.  Use stashed
-	section pointers intead of strcmp checks.  Handle iplt and igotplt.
-	(elf32_arm_finish_dynamic_symbol): Use elf32_arm_populate_plt_entry
-	to fill in .plt, .got.plt and .rel(a).plt entries.  Point
-	STT_GNU_IFUNC symbols at an .iplt entry if non-call relocations
-	resolve to it.
-	(elf32_arm_output_plt_map_1): New function, split out from
-	elf32_arm_output_plt_map.  Handle .iplt entries.  Use
-	elf32_arm_plt_needs_thumb_stub_p.
-	(elf32_arm_output_plt_map): Call it.
-	(elf32_arm_output_arch_local_syms): Add mapping symbols for
-	local .iplt entries.
-	(elf32_arm_swap_symbol_in): Handle Thumb STT_GNU_IFUNC symbols.
-	(elf32_arm_swap_symbol_out): Likewise.
-	(elf32_arm_add_symbol_hook): New function.
-	(elf_backend_add_symbol_hook): Define for all targets.
-
-2011-03-14  Richard Sandiford  <[email protected]>
-
-	* elf-bfd.h (elf_link_hash_entry): Add target_internal.
-	* elf.c (swap_out_syms): Set st_target_internal for each
-	Elf_Internal_Sym.
-	* elfcode.h (elf_swap_symbol_in): Likewise.
-	* elf32-i370.c (i370_elf_finish_dynamic_sections): Likewise.
-	* elf32-sh-symbian.c (sh_symbian_relocate_section): Likewise.
-	* elf64-sparc.c (elf64_sparc_output_arch_syms): Likewise.
-	* elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Likewise.
-	* elflink.c (elf_link_output_extsym): Likewise.
-	(bfd_elf_final_link): Likewise.
-	(elf_link_add_object_symbols): Copy st_target_internal
-	to the hash table if we see a definition.
-	(_bfd_elf_copy_link_hash_symbol_type): Copy target_internal.
-	* elf32-arm.c (elf32_arm_stub_hash_entry): Replace st_type with
-	a branch_type field.
-	(a8_erratum_fix, a8_erratum_reloc): Likewise.
-	(arm_type_of_stub): Replace actual_st_type with an
-	actual_branch_type parameter.
-	(arm_build_one_stub): Use branch types rather than st_types to
-	determine the type of branch.
-	(cortex_a8_erratum_scan): Likewise.
-	(elf32_arm_size_stubs): Likewise.
-	(bfd_elf32_arm_process_before_allocation): Likewise.
-	(allocate_dynrelocs_for_symbol): Likewise.
-	(elf32_arm_finish_dynamic_sections): Likewise.
-	(elf32_arm_final_link_relocate): Replace sym_flags parameter with
-	a branch_type parameter.
-	(elf32_arm_relocate_section): Update call accordingly.
-	(elf32_arm_adjust_dynamic_symbol): Don't check STT_ARM_TFUNC.
-	(elf32_arm_output_map_sym): Initialize st_target_internal.
-	(elf32_arm_output_stub_sym): Likewise.
-	(elf32_arm_symbol_processing): Delete.
-	(elf32_arm_swap_symbol_in): Convert STT_ARM_TFUNCs into STT_FUNCs.
-	Use st_target_internal to record the branch type.
-	(elf32_arm_swap_symbol_out): Use st_target_internal to test for
-	Thumb functions.
-	(elf32_arm_is_function_type): Delete.
-	(elf_backend_symbol_processing): Likewise.
-	(elf_backend_is_function_type): Likewise.
-
-2011-03-14  Richard Sandiford  <[email protected]>
-
-	* elf32-arm.c (elf32_arm_check_relocs): Always assign a dynobj.
-	(elf32_arm_finish_dynamic_sections): Move sgot != NULL assertion
-	into the PLT block.
-
-2011-03-14  Richard Sandiford  <[email protected]>
-
-	* elf32-arm.c (elf32_arm_check_relocs): Use call_reloc_p,
-	may_need_local_target_p and may_become_dynamic_p to classify
-	the relocation type.  Don't check info->symbolic or h->def_regular
-	when deciding whether to record a potential dynamic reloc.
-	Don't treat potential dynamic relocs as PLT references.
-	(elf32_arm_gc_sweep_hook): Update to match.  Assert that we don't
-	try to make the PLT reference count go negative.
-
-2011-03-14  Richard Sandiford  <[email protected]>
-
-	* elf32-arm.c (elf32_arm_final_link_relocate): Always fill in the
-	GOT entry here, rather than leaving it to finish_dynamic_symbol.
-	Only create a dynamic relocation for local references if
-	info->shared.
-	(allocate_dynrelocs_for_symbol): Update dynamic relocation
-	allocation accordingly.
-	(elf32_arm_finish_dynamic_symbol): Don't initialise the GOT entry here.
-
-2011-03-14  Richard Sandiford  <[email protected]>
-
-	* elf32-arm.c (elf32_arm_allocate_dynrelocs): New function.
-	(elf32_arm_add_dynreloc): Likewise.
-	(elf32_arm_adjust_dynamic_symbol): Use elf32_arm_allocate_dynrelocs
-	to allocate dynamic relocations.
-	(elf32_arm_size_dynamic_sections): Likewise.
-	(allocate_dynrelocs): Likewise.  Rename to
-	allocate_dynrelocs_for_symbol.
-	(elf32_arm_final_link_relocate): Use elf32_arm_add_dynreloc to
-	create dynamic relocations.
-	(elf32_arm_finish_dynamic_symbol): Likewise.
-
-2011-03-12  H.J. Lu  <[email protected]>
-
-	* elf64-x86-64.c (elf_x86_64_check_tls_transition): Supprt TLS
-	x32 GD->IE and GD->LE transitions.
-	(elf_x86_64_relocate_section): Supprt TLS x32 GD->IE, GD->LE
-	and LD->LE transitions.
-
-2011-03-10  Alan Modra  <[email protected]>
-
-	* elf64-ppc.c (ppc64_elf_relocate_section): Provide section/offset
-	for LO_DS error message and correct multiple.
-
-2011-03-10  Alan Modra  <[email protected]>
-
-	* elf64-ppc.c (bfd_elf64_bfd_link_just_syms): Define.
-	(ppc64_elf_link_just_syms): New function.
-	(opd_entry_value): Don't assume big-endian host.
-	(get_r2off): New function.
-	(ppc_build_one_stub, ppc_size_one_stub): Use it here.
-
-2011-03-06  Michael Snyder  <[email protected]>
-
-	* compress.c (bfd_compress_section_contents): Check for out of mem.
-
-	* elf64-x86-64.c (elf_x86_64_relocate_section): Document
-	that case statement falls through intentionally.
-
-	* elf32-i386.c (elf_i386_relocate_section): Document fall through.
-
-2011-03-04  Alan Modra  <[email protected]>
-
-	* archive.c (bsd_write_armap): Don't call stat in deterministic
-	mode, and don't use st_mtime if stat returns error.
-
-2011-03-03  Michael Snyder  <[email protected]>
-
-	* elf64-x86-64.c (elf_x86_64_relocate_section): Remove dead code.
-
-	* coff-x86_64.c (coff_amd64_rtype_to_howto): Fencepost error.
-
-	* aoutx.h (aout_final_link): Use sizeof int not sizeof int*.
-	(aout_link_write_other_symbol): Missing break statement.
-
-	* dwarf2.c (scan_unit_for_symbols): Stop memory leak.
-
-	* archive.c (_bfd_slurp_extended_name_table): Fail if bfd_seek fails.
-
-2011-03-03  H.J. Lu  <[email protected]>
-
-	* elf64-x86-64.c (elf_x86_64_check_tls_transition): Supprt TLS
-	x32 IE->LE transition.
-	(elf_x86_64_relocate_section): Likewise.
-
-2011-03-02  Bernd Schmidt  <[email protected]>
-
-	* elflink.c (is_reloc_section): Remove function.
-	(get_dynamic_reloc_section_name): Construct string manually.
-
-2011-02-28  Kai Tietz  <[email protected]>
-
-	* archive.c (_bfd_find_nested_archive): Use filename_(n)cmp.
-	(adjust_relative_path): Likewise.
-	(_bfd_construct_extended_name_table): Likewise.
-	* corefile.c (generic_core_file_matches_executable_p): Likewise.
-	* elf32-bfin.c (bfinfdpic_relocate_section): Likewise.
-	* elf32-frv.c (elf32_frv_relocate_section): Likewise.
-	* elf32-spu.c (sort_bfds): Likewise.
-	(spu_elf_auto_overlay): Likewise.
-	* syms.c (_bfd_stab_section_find_nearest_line): Likewise.
-	* xcofflink.c (xcoff_set_import_path): Likewise.
-	* xtensa-isa.c (xtensa_regfile_lookup): Likewise.
-	(xtensa_regfile_lookup_shortname): Likewise.
-
-2011-02-28  Alan Modra  <[email protected]>
-
-	PR 12513
-	* archive.c (bfd_slurp_bsd_armap_f2): Sanity check parsed_size and
-	stringsize.  Properly sanity check symdef_count.  Remove redundant
-	bfd_release.
-
-2011-02-25  Rafael Ávila de Espíndola <[email protected]>
-
-	* plugin.c (bfd_plugin_object_p): Correctly set the filesize
-	and handle claim_file seeking. Only try to load the plugin once.
-
-2011-02-22  Andreas Schwab  <[email protected]>
-
-	* elf32-m68k.c (elf_m68k_finish_dynamic_symbol): For a TLS_GD
-	relocation read the value from the second GOT slot.
-
-2011-02-15  Tristan Gingold  <[email protected]>
-
-	* vms-alpha.c (alpha_vms_link_add_archive_symbols): Add a comment.
-
-2011-02-15  Alan Modra  <[email protected]>
-
-	* elf64-ppc.c (ppc64_elf_edit_toc): Reinstate second read of
-	toc relocs.  Fuss over free(NULL).
-
-2011-02-14  Mike Frysinger  <[email protected]>
-
-	* elflink.c (bfd_elf_size_dynamic_sections): Add
-	bfd_get_symbol_leading_char to the start of newname.
-
-2011-02-13  Ralf Wildenhues  <[email protected]>
-
-	* configure: Regenerate.
-
-2011-02-09  Alan Modra  <[email protected]>
-
-	* elf64-ppc.c (ppc64_elf_edit_toc): Don't free toc relocs until
-	we are done.  When optimising large toc, check that a global
-	symbol on a toc reloc is defined in a kept section.
-
-2011-02-08  Nick Clifton  <[email protected]>
-
-	PR binutils/12467
-	* elf.c (assign_file_positions_for_load_sections): Set the program
-	header offset and entry size to zero if there are no program
-	headers.
-
-2011-02-08  Alan Modra  <[email protected]>
-
-	* elf64-ppc.c (ppc64_elf_edit_toc): Don't segfault on NULL
-	local_syms when looking for local symbols in .toc.
-
-2011-02-01  Alan Modra  <[email protected]>
-
-	* elf64-ppc.c (ppc64_elf_next_input_section): Use elf_gp value
-	for toc pointer on any section having makes_toc_func_call set.
-	(check_pasted_section): Ensure pasted .init/.fini fragments use
-	the same toc if any has makes_toc_func_call set.
-
-2011-01-28  Joseph Myers  <[email protected]>
-
-	* elf32-ppc.c (ppc_elf_link_hash_newfunc): Initialize has_sda_refs
-	field.
-
-2011-01-22  Richard Sandiford  <[email protected]>
-
-	* elfxx-mips.c (_bfd_mips_elf_merge_private_bfd_data): Ignore
-	common sections too.
-
-2011-01-18  H.J. Lu  <[email protected]>
-
-	* elf64-x86-64.c (elf_backend_want_plt_sym): Redefine to 0 after
-	Solaris target.
-
-2011-01-18  Pierre Muller  <[email protected]>
-
-	Fix compilation for mingw64.
-	* coffcode.h (coff_slurp_symbol_table): Add intptr_t intermediate
-	typecast to avoid warning.
-	* elf32-rx.c: Add "bfd_stdint.h" include required for int32_t type
-	usage.
-	* elfxx-ia64.c (elfNN_ia64_relax_br): Use intptr_t typeacast instead
-	of long for pointer to avoid warning.
-	(elfNN_ia64_relax_brl): Idem.
-	(elfNN_ia64_install_value): Idem.
-	* vms-alpha.c (_bfd_vms_slurp_etir): Idem.
-
-2011-01-17  Richard Sandiford  <[email protected]>
-
-	* elf32-arm.c (elf32_arm_check_relocs): Check needs_plt rather than
-	h->needs_plt when deciding whether to record a possible dynamic reloc.
-
-2011-01-17  Richard Sandiford  <[email protected]>
-
-	* elf32-arm.c (elf32_arm_gc_sweep_hook): Remove all registered
-	dynamic relocs for the removed section.
-
-2011-01-15  H.J. Lu  <[email protected]>
-
-	* elf64-x86-64.c (elf_x86_64_check_relocs): Check invalid x32
-	relocations.
-
-2011-01-14  H.J. Lu  <[email protected]>
-
-	* elf64-x86-64.c (elf_x86_64_link_hash_table): Add pointer_r_type.
-	(elf_x86_64_link_hash_table_create): Set pointer_r_type.
-	(elf_x86_64_check_relocs): Handle R_X86_64_32 like R_X86_64_64
-	for ILP32.  Remove ABI_64_P PIC check for R_X86_64_8,
-	R_X86_64_16, R_X86_64_32 and R_X86_64_32S.
-	(elf_x86_64_relocate_section):  Handle R_X86_64_32 like R_X86_64_64
-	for ILP32.
-
-2011-01-14  Alan Modra  <[email protected]>
-
-	* bfd.c (bfd_perror): Flush stdout before and stderr after printing
-	error.
-	(_bfd_default_error_handler): Likewise.
-	* elf.c (print_segment_map): Likewise.
-	* libbfd.c (warn_deprecated): Likewise.
-	* som.c (som_sizeof_headers): No need to do so here.
-	* coff-i860.c: Replace use of printf for error messages with
-	_bfd_error_handler.
-	* coff-ppc.c: Likewise.
-	* coff-sh.c: Likewise.
-	* elf32-bfin.c: Likewise.
-	* elf32-dlx.c: Likewise.
-	* elf32-mep.c: Likewise.
-	* elf32-v850.c: Likewise.
-	* mach-o.c: Likewise.
-	* pef.c: Likewise.
-
-2011-01-13  H.J. Lu  <[email protected]>
-
-	* elf64-x86-64.c (elf_x86_64_link_hash_table): Remove
-	swap_reloca_out.
-	(elf_x86_64_link_hash_table_create): Don't set swap_reloca_out.
-	(elf_x86_64_check_relocs): Align relocation section to 4 byte
-	for 32bit.
-	(elf_x86_64_gc_sweep_hook): Replace ELF64_ST_TYPE with
-	ELF_ST_TYPE.
-	(elf_x86_64_finish_dynamic_symbol): Updated.
-	(elf_x86_64_finish_dynamic_sections): Don't use
-	Elf64_External_Dyn, bfd_elf64_swap_dyn_in, nor
-	bfd_elf64_swap_dyn_out.
-
-2011-01-14  J. Park  <[email protected]>
-
-	PR ld/12339
-	* elf32-arm.c (allocate_dynrelocs): Don't set up eh before
-	following bfd_link_hash_warning symbol link.
-
-2011-01-10  Nathan Sidwell  <[email protected]>
-	    Glauber de Oliveira Costa  <[email protected]>
-
-	* reloc.c (BFD_RELOC_ARM_TLS_GOTDESC, BFD_RELOC_ARM_TLS_CALL,
-	BFD_RELOC_ARM_THM_TLS_CALL, BFD_RELOC_ARM_TLS_DESCSEQ,
-	BFD_RELOC_ARM_THM_TLS_DESCSEQ, BFD_RELOC_ARM_TLS_DESC): New
-	relocations.
-	* libbfd.h: Rebuilt.
-	* bfd-in2.h: Rebuilt.
-	* elf32-arm.c (elf32_arm_howto_table_1): Add new relocations.
-	(elf32_arm_reloc_map): Likewise.
-	(tls_trampoline, dl_tlsdesc_lazy_trampoline): New PLT templates.
-	(elf32_arm_stub_long_branch_any_tls_pic,
-	elf32_arm_stub_long_branch_v4t_thumb_tls_pic): New stub templates.
-	(DEF_STUBS): Add new stubs.
-	(struct_elf_arm_obj_data): Add local_tlsdesc_gotent field.
-	(elf32_arm_local_tlsdesc_gotent): New.
-	(GOT_TLS_GDESC): New mask.
-	(GOT_TLS_GD_ANY): Define.
-	(struct elf32_arm_link_hash_entry): Add tlsdesc_got field.
-	(elf32_arm_compute_jump_table_size): New.
-	(struct elf32_arm_link_hash_table): Add next_tls_desc_index,
-	num_tls_desc, dt_tlsdesc_plt, dt_tlsdesc_got, tls_trampoline,
-	sgotplt_jump_table_size fields.
-	(elf32_arm_link_hash_newfunc): Initialize tlsdesc_got field.
-	(elf32_arm_link_hash_table_create): Initialize new fields.
-	(arm_type_of_stub): Check TLS desc relocs too.
-	(elf32_arm_stub_name): TLS desc relocs can be shared.
-	(elf32_arm_tls_transition): Determine relaxation.
-	(arm_stub_required_alignment): Add tls stubs.
-	(elf32_arm_size_stubs): Likewise.
-	(elf32_arm_tls_relax): Perform TLS relaxing.
-	(elf32_arm_final_link_relocate): Process TLS DESC relocations.
-	(IS_ARM_TLS_GNU_RELOC): New.
-	(IS_ARM_TLS_RELOC): Use it.
-	(elf32_arm_relocate_section): Perform TLS relaxing.
-	(elf32_arm_check_relocs): Anticipate TLS relaxing, process tls
-	desc relocations.
-	(allocate_dynrelocs): Allocate tls desc relcoations.
-	(elf32_arm_output_arch_local_syms): Emit tls trampoline mapping
-	symbols.
-	(elf32_arm_size_dynamic_sections): Allocate tls trampolines and
-	got slots.
-	(elf32_arm_always_size_sections): New. Create _TLS_MODULE_BASE
-	symbol.
-	(elf32_arm_finish_dynamic_symbol): Adjust.
-	(arm_put_trampoline): New.
-	(elf32_arm_finish_dynamic_sections): Emit new dynamic tags and tls
-	trampolines.
-	(elf_backend_always_size_sections): Define.
-
-2011-01-06  H.J. Lu  <[email protected]>
-
-	* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Optimized.
-
-2011-01-06  H.J. Lu  <[email protected]>
-
-	PR ld/12366
-	PR ld/12371
-	* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Properly
-	handle symbols marked with regular reference, but not non-GOT
-	reference when building shared library.
-
-	* elf32-i386.c (elf_i386_gc_sweep_hook): Properly handle
-	local and global STT_GNU_IFUNC symols when building shared
-	library.
-	* elf64-x86-64.c (elf_x86_64_gc_sweep_hook): Likewise.
-
-2011-01-05  DJ Delorie  <[email protected]>
-
-	* reloc.c: Add BFD_RELOC_RX_OP_NEG.
+	2013-10-30  Alan Modra  <[email protected]>
+	* reloc.c (BFD_RELOC_PPC64_ADDR16_HIGH, BFD_RELOC_PPC64_ADDR16_HIGHA,
+	BFD_RELOC_PPC64_TPREL16_HIGH, BFD_RELOC_PPC64_TPREL16_HIGHA,
+	BFD_RELOC_PPC64_DTPREL16_HIGH, BFD_RELOC_PPC64_DTPREL16_HIGHA): New.
+	* elf64-ppc.c (ppc64_elf_howto_raw): Add entries for new relocs.
+	Make all _HA and _HI relocs report signed overflow.
+	(ppc64_elf_reloc_type_lookup): Handle new relocs.
+	(must_be_dyn_reloc, ppc64_elf_check_relocs): Likewise.
+	(dec_dynrel_count, ppc64_elf_relocate_section): Likewise.
+	(ppc64_elf_relocate_section): Don't apply 0x8000 adjust to
+	R_PPC64_TPREL16_HIGHER, R_PPC64_TPREL16_HIGHEST,
+	R_PPC64_DTPREL16_HIGHER, and R_PPC64_DTPREL16_HIGHEST.
 	* libbfd.h: Regenerate.
 	* bfd-in2.h: Regenerate.
-	* elf32-rx.c: Add it to the list, corresponding to R_RX_OPneg.
 
-2011-01-03  H.J. Lu  <[email protected]>
+2013-11-13  Yufeng Zhang  <[email protected]>
 
-	* cpu-i386.c (bfd_i386_compatible): New.
-	(bfd_x64_32_arch_intel_syntax): Replace bfd_default_compatible
-	with bfd_i386_compatible.
-	(bfd_x86_64_arch_intel_syntax): Likewise.
-	(bfd_i386_arch_intel_syntax): Likewise.
-	(i8086_arch): Likewise.
-	(bfd_x64_32_arch): Likewise.
-	(bfd_x86_64_arch): Likewise.
-	(bfd_i386_arch): Likewise.
+	* elfnn-aarch64.c (elfNN_aarch64_howto_table): Use
+	R_AARCH64_TLS_DTPMOD64 instead of R_AARCH64_TLS_DTPMOD;
+	likewise for R_AARCH64_TLS_DTPREL and R_AARCH64_TLS_TPREL.
 
-For older changes see ChangeLog-2010
+2013-11-12  Matthew Leach  <[email protected]>
+
+	* elfxx-aarch64.c (_bfd_aarch64_elf_grok_prstatus): Fix hard-coded
+	size of struct elf_prstatus.
+
+2013-11-07  Roland McGrath  <[email protected]>
+
+	* archures.c (bfd_mach_i386_nacl): Fix definition so it doesn't
+	collide with bfd_mach_l1om.
+	* bfd-in2.h: Regenerate.
+
+	* elf32-i386.c (elf32_i386_nacl_elf_object_p): New function.
+	(elf_backend_object_p): Use that in elf32-i386-nacl definition.
+	* elf64-x86-64.c (elf64_x86_64_nacl_elf_object_p): New function.
+	(elf_backend_object_p): Use that in elf64-x86-64-nacl definition.
+	(elf32_x86_64_nacl_elf_object_p): New function.
+	(elf_backend_object_p): Use that in elf32-x86-64-nacl definition.
+
+2013-11-01  Roland McGrath  <[email protected]>
+
+	* elf-nacl.c (segment_eligible_for_headers): Drop requirement that
+	some section have SEC_HAS_CONTENTS set.  It's not set for
+	.note.gnu.build-id, and a segment of only read-only SHT_NOBITS
+	sections is implausible and not really supportable anyway.
+
+2013-10-29  Roland McGrath  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_nacl_plt0_entry): Correct 9-byte nop
+	sequence to match what the assembler generates.
+
+2013-10-17  Alan Modra  <[email protected]>
+
+	PR 16056
+	* elf.c (copy_elf_program_header): Only consider SEC_ALLOC sections
+	when finding lowest_section.
+
+2013-10-09  Roland McGrath  <[email protected]>
+
+	* elf64-alpha.c (elf64_alpha_relax_tls_get_addr): Cast switch
+	expression to int to silence over-eager compiler warnings.
+
+2013-10-09  Roland McGrath  <[email protected]>
+
+	* xcofflink.c (_bfd_xcoff_bfd_final_link): Don't touch EREL in
+	loop that doesn't use (or initialize) it.
+
+2013-10-09  Roland McGrath  <[email protected]>
+
+	* elfxx-tilegx.c (tilegx32_plt_tail_entry, tilegx32_plt_tail_entry):
+	Move second const qualifier so it applies to the pointer.
+
+2013-10-05  Gregory Fong  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_create_got_section): Hide
+	_GLOBAL_OFFSET_TABLE_.
+
+2013-10-04  Will Newton  <[email protected]>
+
+	* configure: Regenerate.
+	* configure.in: Build elf-ifunc.o for AArch64.
+	* elfnn-aarch64.c: Include objalloc.h.
+	(elfNN_aarch64_local_htab_hash): New function.
+	(elfNN_aarch64_local_htab_eq): New function.
+	(elfNN_aarch64_get_local_sym_hash): New function.
+	(elfNN_aarch64_link_hash_table_create): Initialize local STT_GNU_IFUNC
+	symbol hash.
+	(elfNN_aarch64_hash_table_free): Free local STT_GNU_IFUNC symbol hash.
+	(elfNN_aarch64_final_link_relocate): Add sym argument.  Add support
+	for handling STT_GNU_IFUNC symbols.
+	(elfNN_aarch64_gc_sweep_hook): Add support for garbage collecting
+	references to STT_GNU_IFUNC symbols.
+	(elfNN_aarch64_adjust_dynamic_symbol): Add support for handling
+	STT_GNU_IFUNC symbols.
+	(elfNN_aarch64_check_relocs): Add support for handling STT_GNU_IFUNC
+	symbols.  Ensure we don't increase plt.refcount from -1 to 0.
+	(elfNN_aarch64_post_process_headers): Call _bfd_elf_set_osabi.
+	(elfNN_aarch64_is_function_type): Remove function.
+	(elfNN_aarch64_allocate_dynrelocs): Handle STT_GNU_IFUNC symbols.
+	(elfNN_aarch64_allocate_ifunc_dynrelocs): New function.
+	(elfNN_aarch64_allocate_local_dynrelocs): New function.
+	(elfNN_aarch64_allocate_local_ifunc_dynrelocs): New function.
+	(elfNN_aarch64_size_dynamic_sections): Call
+	elfNN_aarch64_allocate_local_dynrelocs.
+	(elfNN_aarch64_create_small_pltn_entry): Add info argument.
+	Add support for creating .iplt entries for STT_GNU_IFUNC symbols.
+	(elfNN_aarch64_finish_dynamic_symbol): Add support for handling
+	STT_GNU_IFUNC symbols and .iplt.
+	(elfNN_aarch64_finish_local_dynamic_symbol): New function.
+	(elfNN_aarch64_finish_dynamic_sections): Call
+	elfNN_aarch64_finish_local_dynamic_symbol.
+
+2013-09-24  Alan Modra  <[email protected]>
+
+	* elf32-mips.c (ELF_OSABI): Undef for vxworks.
+
+2013-09-20  Alan Modra  <[email protected]>
+
+	* configure: Regenerate.
+
+2013-09-18  Tristan Gingold  <[email protected]>
+
+	* configure.in: Bump version to 2.23.90
+	* configure: Regenerate.
+
+2013-09-17  Doug Gilmore  <[email protected]>
+
+	* elfxx-mips.c (_bfd_mips_elf_print_private_bfd_data): Handle
+	EF_MIPS_FP64.
+
+2013-08-31  John David Anglin  <[email protected]>
+
+	* elf64-hppa.c (elf_hppa_final_link_relocate): Add missing '%' to
+	format string.
+
+2013-08-29  Jakub Jelinek  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_check_tls_transition): Allow
+	64-bit -mcmodel=large -fpic TLS GD and LD sequences.
+	(elf_x86_64_relocate_section): Handle -mcmodel=large -fpic
+	TLS GD and LD sequences in GD->LE, GD->IE and LD->LE transitions.
+
+2013-08-27  Alan Modra  <[email protected]>
+
+	* elf-bfd.h (struct elf_backend_data): Remove as_needed_cleanup.
+	Add notice_as_needed.
+	* elf64-ppc.c (elf_backend_as_needed_cleanup): Don't define.
+	(elf_backend_notice_as_needed): Define.
+	(ppc64_elf_as_needed_cleanup): Rename and adjust..
+	(ppc64_elf_notice_as_needed): ..to this.
+	* elflink.c (_bfd_elf_notice_as_needed): New function, extracted..
+	(elf_link_add_object_symbols): ..from here.
+	* elfxx-target.h (elf_backend_as_needed_cleanup): Don't define.
+	(elf_backend_notice_as_needed): Define..
+	(elfNN_bed): ..and use here.
+
+2013-08-26  Roland McGrath  <[email protected]>
+
+	* archures.c (bfd_mach_i386_nacl, bfd_mach_i386_i386_nacl): New macros.
+	(bfd_mach_x86_64_nacl, bfd_mach_x64_32_nacl): New macros.
+	* cpu-i386.c (bfd_arch_i386_onebyte_nop_fill): New function.
+	(bfd_i386_nacl_arch): New variable.
+	(bfd_x86_64_nacl_arch, bfd_x64_32_nacl_arch): New variables.
+	(bfd_x64_32_arch_intel_syntax): Link them into the list.
+	* bfd-in2.h: Regenerate.
+
+2013-08-26  Roland McGrath  <[email protected]>
+
+	* elf-nacl.c (nacl_modify_segment_map): Fix logic reordering the
+	elf_segment_map list.  If an executable segment is page-aligned
+	but does not end with a full page, then append a fake section into
+	the segment map entry that pads out the page.
+	(nacl_final_write_processing): New function.  Write the code fill
+	laid out in nacl_modify_segment_map.
+	* elf-nacl.h: Declare it.
+	* elf32-arm.c (elf32_arm_nacl_final_write_processing): New function.
+	(elf_backend_final_write_processing): Define it for NaCl backend.
+	* elf32-i386.c (elf_backend_final_write_processing): Likewise.
+	* elf64-x86-64.c (elf_backend_final_write_processing): Likewise.
+
+	* elf-nacl.c (segment_eligible_for_headers): Rename MAXPAGESIZE
+	parameter to MINPAGESIZE.
+	(nacl_modify_segment_map): Use minpagesize instead of maxpagesize.
+
+	* elf32-arm.c (ELF_MINPAGESIZE, ELF_COMMONPAGESIZE): #undef for NaCl.
+
+2013-08-24  Maciej W. Rozycki  <[email protected]>
+
+	* elf32-tilepro.c (tilepro_elf_finish_dynamic_sections): Don't
+	set GOT's entry size if there is no ELF section data.
+	* elf64-s390.c (elf_s390_finish_dynamic_sections): Likewise.
+	* elfxx-sparc.c (_bfd_sparc_elf_finish_dynamic_sections):
+	Likewise.
+
+2013-08-23  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (get_elf_x86_64_arch_data): New.
+	(get_elf_x86_64_backend_data): Use it.
+	(elf_x86_64_size_dynamic_sections): Likewise.
+
+2013-08-23  Yuri Chornoivan  <[email protected]>
+
+	PR binutils/15834
+	* bfdio.c: Fix typos.
+	* elf32-spu.c: Likewise.
+	* elfnn-aarch64.c: Likewise.
+
+2013-08-21  Tristan Gingold  <[email protected]>
+
+	* coff-rs6000.c (_bfd_xcoff_sizeof_headers): Also count
+	.ovrflo sections.
+	* coffcode.h (coff_compute_section_file_positions): Force
+	match between file offset and vma offset.
+
+2013-08-21  Alan Modra  <[email protected]>
+
+	* elflink.c (_bfd_elf_merge_symbol): Set *poldbfd, *poldweak,
+	and *poldalignment before exiting when !relocs_compatible.
+
+2013-08-21  Alan Modra  <[email protected]>
+
+	* elflink.c (_bfd_elf_define_linkage_sym): Don't set STV_INTERNAL
+	symbols to STV_HIDDEN.
+
+2013-08-14  John Tytgat  <[email protected]>
+
+	PR ld/15787
+	* elf32-arm.c (elf32_arm_final_link_relocate): Use origin of output
+	segment containing the relocating symbol instead of assuming 0 for
+	sb group relocations.
+
+2013-08-09  Nick Clifton  <[email protected]>
+
+	* elf32-rl78.c (rl78_elf_merge_private_bfd_data): Complain if G10
+	flag bits do not match.
+	(rl78_elf_print_private_bfd_data): Describe G10 flag.
+
+2013-08-05  John Tytgat  <[email protected]>
+
+	* po/BLD-POTFILES.in: Regenerate.
+	* po/SRC-POTFILES.in: Likewise.
+
+2013-07-31  John Tytgat  <[email protected]>
+
+	PR ld/15787
+	* elf32-arm.c (elf32_arm_final_link_relocate): Base SB on the
+	output section VMA.
+
+2013-07-28  Maciej W. Rozycki  <[email protected]>
+
+	* elf64-hppa.c (elf64_hppa_finish_dynamic_sections)
+	<DT_HP_LOAD_MAP>: Return unsuccessfully if there's no `.data'
+	section.
+
+2013-07-27  Andrew Pinski  <[email protected]>
+
+	* elfnn-aarch64.c (elfNN_aarch64_check_relocs):
+	Use the correct alignment for
+	_bfd_elf_make_dynamic_reloc_section for ILP32.
+
+2013-07-27  Andrew Pinski  <[email protected]>
+
+	* elfnn-aarch64.c (elfNN_aarch64_howto_from_bfd_reloc): Handle
+	BFD_RELOC_AARCH64_NONE explicitly.
+
+2013-07-27  Maciej W. Rozycki  <[email protected]>
+
+	* elf32-vax.c (elf_vax_finish_dynamic_sections): Don't set GOT's
+	entry size if there is no ELF section data.
+
+2013-07-27  Maciej W. Rozycki  <[email protected]>
+
+	* elf32-vax.c (elf_vax_check_relocs) <R_VAX_GOT32, R_VAX_PLT32>:
+	Don't check symbol visibility here.  Remove a check already
+	asserted for.
+	(elf_vax_instantiate_got_entries): Use SYMBOL_REFERENCES_LOCAL
+	instead of individual checks.
+	(elf_vax_relocate_section) <R_VAX_GOT32, R_VAX_PLT32>: Only
+	check the offset to decide if produce a GOT or PLT entry.
+	Remove redundant assertions.  Remove code to produce GOT entries
+	for local symbols.  Remove a duplicate comment and add a comment
+	on GOT relocations.
+	(elf_vax_finish_dynamic_symbol): Remove code to produce RELATIVE
+	dynamic relocs.
+
+2013-07-27  Maciej W. Rozycki  <[email protected]>
+
+	* elf32-vax.c (elf_vax_always_size_sections): Correct a comment
+	typo.
+
+2013-07-27  Maciej W. Rozycki  <[email protected]>
+
+	* elf32-vax.c (elf_vax_discard_got_entries): New function.
+	(elf_vax_always_size_sections): Likewise.
+	(elf_vax_size_dynamic_sections): Remove code moved to
+	elf_vax_always_size_sections.  Make comment on
+	elf_vax_instantiate_got_entries match reality.
+	(elf_vax_instantiate_got_entries): Assert that rather than check
+	if dynobj is null.  Don't check for dynamic_sections_created.
+	Make function description match reality.
+	(elf_backend_always_size_sections): New macro.
+
+2013-07-25  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (struct ppc64_elf_obj_tdata): Replace opd_relocs
+	with a union.
+	(opd_entry_value): Cache .opd section contents.
+	(ppc64_elf_relocate_section): Adjust.
+
+2013-07-25  Alan Modra  <[email protected]>
+
+	PR ld/15762
+	PR ld/12761
+	* elflink.c (elf_link_add_object_symbols): Correct test in
+	last patch.  Remove unnecessary code.
+
+2013-07-24  Tristan Gingold  <[email protected]>
+
+	* coff-rs6000.c (xcoff_howto_table): Fix masks and pc_relative for
+	R_RBR.  Add numbers in comments.
+	(_bfd_xcoff_reloc_type_lookup): Handle BFD_RELOC_PPC_B16.
+	* coff64-rs6000.c: Likewise.
+
+2013-07-20  Alan Modra  <[email protected]>
+
+	PR ld/15762
+	PR ld/12761
+	* elflink.c (elf_link_add_object_symbols): Don't clobber
+	.gnu.warning.symbol sections when shared.
+
+2013-07-19  Nick Clifton  <[email protected]>
+
+	* elf32-rx.c (rx_elf_relocate_section): Fix typo: move
+	saw_subtract from R_RX_OPdiv to R_RX_OPneg.
+
+2013-07-18  Travis Snoozy  <[email protected]>
+
+	PR ld/15721
+	* elf32-msp430.c (R_MSP430_10_PCREL): Use 10-bit source and
+	destination masks.
+	* R_MSP430_2X_PCREL: Likewise.
+	* R_MSP430X_10_PCREL: Likewise.
+	* R_MSP430X_2X_PCREL: Likewise.
+
+2013-07-18  Terry Guo  <[email protected]>
+
+	* elf32-arm.c (arm_type_of_stub): Don't use ST_BRANCH_TO_ARM for
+	thumb only targets.
+	(elf32_arm_final_link_relocate): Likewise.
+
+2013-07-18  Bill Neubauer  <[email protected]>
+
+	* mach-o.c (mach_o_section_name_xlat dw): Add entry for
+	.debug_gdb_scripts
+
+2013-07-18  Roland McGrath  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_stub_long_branch_arm_nacl): New variable.
+	(elf32_arm_stub_long_branch_arm_nacl_pic): New variable.
+	(arm_build_one_stub): Increase MAXRELOCS to 3.
+	(arm_type_of_stub): Use them if GLOBALS->nacl_p.
+	(struct elf32_arm_link_hash_table): Give add_stub_section member's
+	pointee type a third argument.
+	(elf32_arm_create_or_find_stub_sec): Update caller.
+	(elf32_arm_size_stubs): Update argument type.
+	* bfd-in.h (elf32_arm_size_stubs): Update decl.
+	* bfd-in2.h: Regenerate.
+	* libbfd.h: Regenerate.
+
+2013-07-15  Maciej W. Rozycki  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_merge_obj_attributes): Replace hardcoded
+	magic numbers with enum values.
+
+2013-07-12  Roland McGrath  <[email protected]>
+
+	* reloc.c: Add BFD_RELOC_390_PC12DBL, BFD_RELOC_390_PLT12DBL,
+	BFD_RELOC_390_PC24DBL, BFD_RELOC_390_PLT24DBL (should have
+	been added here with 2013-07-05 elf32-s390.c change).
+	* bfd-in2.h: Regenerate (no-op).
+	* libbfd.h: Regenerate (no-op).
+
+2013-07-12  Maciej W. Rozycki  <[email protected]>
+
+	* elfxx-mips.c (_bfd_mips_elf_merge_private_bfd_data): Handle
+	EF_MIPS_NAN2008.
+	(_bfd_mips_elf_print_private_bfd_data): Likewise.
+
+2013-07-09  Tristan Gingold  <[email protected]>
+
+	* vms-alpha.c (struct vms_private_data_struct): Remove
+	flag_hash_long_names and flag_show_after_trunc.
+	(hash_string): Remove.
+	(_bfd_vms_length_hash_symbol): Remove.
+	(alpha_vms_write_exec): Remove call to _bfd_vms_length_hash_symbol.
+	(_bfd_vms_write_egsd): Likewise.  Rewrite condition.
+	(_bfd_vms_write_ehdr): Remove code that set removed flags.
+	(_bfd_vms_write_etir): Remove call to _bfd_vms_length_hash_symbol.
+	(vms_bfd_is_local_label_name): Remove trace call.
+
+2013-07-09  Tristan Gingold  <[email protected]>
+
+	* hosts/alphavms.h: Include config.h and ansidecl.h, remove useless
+	macros.
+	* configure.com: Adjust to match changes in configure.
+	* makefile.vms (OBJS): Update list.
+
+2013-07-05  Tristan Gingold  <[email protected]>
+
+	* coffcode.h (coff_write_object_contents): Use ".ovrflo" name for
+	overflow sections.
+
+2013-07-05  Andreas Krebbel  <[email protected]>
+
+	* elf32-s390.c: Add new relocation definitions R_390_PC12DBL,
+	R_390_PLT12DBL, R_390_PC24DBL, and R_390_PLT24DBL.
+	(elf_s390_reloc_type_lookup, elf_s390_check_relocs)
+	(elf_s390_gc_sweep_hook, elf_s390_relocate_section): Support new
+	relocations.
+	* elf64-s390.c: See elf32-s390.c
+	* bfd-in2.h: Add new relocs to enum bfd_reloc_code_real.
+	* libbfd.h: Add new reloc strings.
+
+2013-07-03  Marcus Shawcroft  <[email protected]>
+
+	* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Reorder case
+	values.
+	(elfNN_aarch64_relocate_section): Likewise.
+	(elfNN_aarch64_gc_sweep_hook): Likewise.
+	(elfNN_aarch64_check_relocs): Likewise.
+
+2013-07-03  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (ppc64_elf_func_desc_adjust): Don't hide .TOC.
+	when relocatable.  Don't change root.type or type here.
+	(ppc64_elf_set_toc): Set type of .TOC. to STT_OBJECT.
+
+2013-07-03  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (struct ppc_stub_hash_entry): Delete "addend".
+	(ppc64_elf_size_stubs): Don't set "addend".
+	(ppc64_elf_relocate_section): Don't allow calls via
+	toc-adjusting stubs without a following nop even in an
+	executable, except for self-calls and both libc_start_main
+	and .libc_start_main.
+
+2013-07-03  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (ppc64_elf_func_desc_adjust): Hide ".TOC.".
+
+2013-07-02  Tristan Gingold  <[email protected]>
+
+	* coff-rs6000.c (xcoff_find_nearest_line_discriminator): Add missing
+	line.
+
+2013-07-02  Tristan Gingold  <[email protected]>
+
+	* vms-alpha.c (_bfd_generic_find_nearest_line_discriminator): Define.
+	(_bfd_vms_find_nearest_line_discriminator): New function.
+
+2013-07-02  Tristan Gingold  <[email protected]>
+
+	* coff-rs6000.c (xcoff_create_csect_from_smclas): Handle more smclas.
+
+2013-07-02  Tristan Gingold  <[email protected]>
+
+	* coff-rs6000.c (xcoff_find_nearest_line_discriminator): New function.
+	(rs6000coff_vec): Reference it.
+
+2013-07-02  Marcus Shawcroft  <[email protected]>
+
+	* elfnn-aarch64.c (aarch64_elf_create_got_section): New.
+	(elfNN_aarch64_check_relocs): Use aarch64_elf_create_got_section.
+	(elfNN_aarch64_create_dynamic_sections): Do not define
+	_GLOBAL_OFFSET_TABLE_; call aarch64_elf_create_got_section.
+
+2013-07-02  Marcus Shawcroft  <[email protected]>
+
+	* ld-aarch64/emit-relocs-309-low.d: Adjust .text address.
+	* ld-aarch64/emit-relocs-309-up.d: Adjust .got address.
+	* ld-aarch64/emit-relocs-312.d: Adjust offsets into .got.
+	* ld-aarch64/tls-relax-all.d: Likewise.
+	* ld-aarch64/gc-got-relocs.d: Adjust expected .got content.
+	* ld-aarch64/gc-tls-relocs.d: Likewise.
+	* ld-aarch64/tls-relax-gd-ie.d: Likewise.
+	* ld-aarch64/tls-relax-gdesc-ie-2.d: Likewise.
+	* ld-aarch64/tls-relax-gdesc-ie.d: Likewise.
+
+2013-07-02  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (ppc64_elf_relocate_section): Set "relocation" for
+	.TOC. after relocatable check.
+
+2013-07-01  Alan Modra  <[email protected]>
+
+	* elf64-ppc.h (ppc64_elf_toc): Delete.
+	(ppc64_elf_set_toc): Declare.
+	* elf64-ppc.c (ppc64_elf_toc_reloc): Replace call to ppc64_elf_toc
+	with call the ppc64_elf_set_toc.
+	(ppc64_elf_toc_ha_reloc, ppc64_elf_toc64_reloc): Likewise.
+	(ppc64_elf_start_multitoc_partition): Likewise.
+	(struct ppc_link_hash_table): Delete dot_toc_dot.  Replace all uses
+	with elf.hgot.
+	(ppc64_elf_process_dot_syms): Don't make a fake function descriptor
+	for ".TOC.".
+	(ppc64_elf_check_relocs): Mark sections with a reference to .TOC.
+	as needing a toc pointer.
+	(ppc64_elf_size_stubs): Don't set dot_toc_dot here.
+	(ppc64_elf_set_toc): Rename from ppc64_elf_toc.  Add info param.
+	Set elf.hgot value.
+
+2013-06-28  H.J. Lu  <[email protected]>
+
+	PR ld/15685
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Handle
+	R_X86_64_DTPOFF64.
+
+2013-06-28  Nick Clifton  <[email protected]>
+
+	PR ld/15302
+	* elf32-arm.c (allocate_dynrelocs_for_symbol): Revert previous patch.
+
+2013-06-27  Marcus Shawcroft  <[email protected]>
+
+	* elfnn-aarch64.c (elfNN_aarch64_check_relocs): Reserve one slot
+	in sgot.
+	(elfNN_aarch64_finish_dynamic_sections): Place the &_DYNAMIC reference
+	in sgot[0] rather than sgotplt[0].
+
+2013-06-26  Yufeng Zhang  <[email protected]>
+
+	* Makefile.am (elf32-aarch64.c): Add a #line cpp directive at the
+	beginning of the generated file.
+	(elf64-aarch64.c): Likewise.
+	* Makefile.in: Re-generated.
+
+2013-06-26  Yufeng Zhang  <[email protected]>
+
+	* Makefile.am (BFD64_BACKENDS): Add elfxx-aarch64.c.
+	(BFD64_BACKENDS_CFILES): Add elfxx-aarch64.lo.
+	* Makefile.in: Re-generated.
+	* configure.in (bfd_elf64_bigaarch64_vec): Add elfxx-aarch64.lo.
+	(bfd_elf64_littleaarch64_vec): Likewise.
+	(bfd_elf32_bigaarch64_vec): Likewise.
+	(bfd_elf32_littleaarch64_vec): Likewise.
+	* configure: Re-generated.
+	* elfxx-aarch64.c: New file; split from elf64-aarch64.c.
+	* elfxx-aarch64.h: New file.
+	* elfnn-aarch64.c: Include "elfxx-aarch64.h"; move the following
+	stuff to elfxx-aarch64.c.
+	(bfd_elf_aarch64_put_addend): Removed.
+	(PG_OFFSET, PG): Likewise.
+	(elfNN_aarch64_small_plt0_entry): Support ELF32.
+	(elfNN_aarch64_tlsdesc_small_plt_entry): Likewise.
+	(elf64_aarch64_grok_prstatus): Removed.
+	(elf_backend_grok_prstatus): Removed.
+	(insn32): Likewise.
+	(aarch64_unsigned_overflow): Likewise.
+	(aarch64_signed_overflow): Likewise.
+	(aarch64_resolve_relocation): Likewise.
+	(MASK): Likewise.
+	(decode_branch_ofs_26): Likewise.
+	(decode_cond_branch_ofs_19): Likewise.
+	(decode_ld_lit_ofs_19): Likewise.
+	(decode_tst_branch_ofs_14): Likewise.
+	(decode_movw_imm): Likewise.
+	(decode_adr_imm): Likewise.
+	(decode_add_imm): Likewise.
+	(reencode_branch_ofs_26): Likewise.
+	(reencode_cond_branch_ofs_19): Likewise.
+	(reencode_ld_lit_ofs_19): Likewise.
+	(reencode_tst_branch_ofs_14): Likewise.
+	(reencode_movw_imm): Likewise.
+	(reencode_adr_imm): Likewise.
+	(reencode_ldst_pos_imm): Likewise.
+	(reencode_add_imm): Likewise.
+	(reencode_movzn_to_movz): Likewise.
+	(reencode_movzn_to_movn): Likewise.
+	(aarch64_relocate): Update to call the new function names in
+	elfxx-aarch64.c.
+	(aarch64_calculate_got_entry_vma): Likewise.
+	(elfNN_aarch64_final_link_relocate): Likewise.
+	(elf64_aarch64_update_plt_entry): Likewise; change the type of the
+	parameter 'r_type' to bfd_reloc_code_real_type; rename to ...
+	(elf_aarch64_update_plt_entry): ... this.
+	(elfNN_aarch64_create_small_pltn_entry): Update.
+	(elfNN_aarch64_init_small_plt0_entry): Remove plt_got_base; add
+	bfd_vma plt_got_2nd_ent; update to call elf_aarch64_update_plt_entry.
+	(elfNN_aarch64_finish_dynamic_sections): Add plt_entry; update to
+	call elf_aarch64_update_plt_entry.
+
+2013-06-26  Yufeng Zhang  <[email protected]>
+
+	* bfd-in2.h: Re-generated.
+	* elfnn-aarch64.c (HOWTO64, HOWTO32): New define.
+	(IS_AARCH64_TLS_RELOC): Change to be based on the
+	bfd reloc enumerators.
+	(IS_AARCH64_TLSDESC_RELOC): Likewise.
+	(PG, PG_OFFSET): Cast literal to bfd_vma.
+	(elf64_aarch64_howto_table): Removed.
+	(elf64_aarch64_howto_dynrelocs): Removed.
+	(elf64_aarch64_tls_howto_table): Removed.
+	(elf64_aarch64_tlsdesc_howto_table): Removed.
+	(elfNN_aarch64_howto_table): New table to host all howto entires..
+	(R_AARCH64_*): Replaced by AARCH64_R (*) and AARCH64_R_STR (*).
+	(elfNN_aarch64_bfd_reloc_from_howto): New function.
+	(elfNN_aarch64_bfd_reloc_from_type): Ditto.
+	(struct elf_aarch64_reloc_map): New.
+	(elf_aarch64_reloc_map): New table.
+	(elfNN_aarch64_howto_from_bfd_reloc): New function.
+	(elfNN_aarch64_howto_from_type): Update to look up the new table
+	elfNN_aarch64_howto_table.
+	(struct elf64_aarch64_reloc_map): Remove.
+	(elf64_aarch64_reloc_map): Remove.
+	(elfNN_aarch64_reloc_type_lookup): Change to call
+	elfNN_aarch64_howto_from_bfd_reloc.
+	(elfNN_aarch64_reloc_name_lookup): Change to look up the new table
+	elfNN_aarch64_howto_table.
+	(aarch64_resolve_relocation): Refactor to switch on the bfd
+	reloc enumerators.
+	(bfd_elf_aarch64_put_addend): Likewise.
+	(elfNN_aarch64_final_link_relocate): Likewise.
+	(aarch64_tls_transition_without_check): Likewise.
+	(aarch64_reloc_got_type): Likewise.
+	(aarch64_can_relax_tls): Likewise.
+	(aarch64_tls_transition): Likewise.
+	(elfNN_aarch64_tls_relax): Likewise.
+	(elfNN_aarch64_final_link_relocate): Likewise.
+	(elfNN_aarch64_relocate_section): Likewise.
+	(elfNN_aarch64_gc_sweep_hook): Likewise.
+	(elfNN_aarch64_check_relocs): Likewise.
+	(aarch64_tls_transition): Change to return a bfd reloc enumerator.
+	* libbfd.h: Re-generated.
+	* reloc.c: Re-order the AArch64 bfd reloc enumerators.
+	(BFD_RELOC_AARCH64_RELOC_START)
+	(BFD_RELOC_AARCH64_RELOC_END)
+	(BFD_RELOC_AARCH64_LD_GOT_LO12_NC)
+	(BFD_RELOC_AARCH64_LD32_GOT_LO12_NC)
+	(BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC)
+	(BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC)
+	(BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC)
+	(BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC)
+	(BFD_RELOC_AARCH64_IRELATIVE): New relocs.
+
+2013-06-26  Yufeng Zhang  <[email protected]>
+
+	* Makefile.am (BFD64_BACKENDS): Add elf32-aarch64.lo.
+	(BUILD_CFILES): Add elf32-aarch64.c.
+	(elf32-aarch64.c): New rule for generating from elfnn-aarch64.c.
+	* Makefile.in: Re-generated.
+	* archures.c (bfd_mach_aarch64_ilp32): New define.
+	* bfd-in.h (bfd_elf32_aarch64_init_maps): New declaration.
+	(bfd_elf32_aarch64_set_options): Ditto.
+	(elf32_aarch64_setup_section_lists): Ditto.
+	(elf32_aarch64_next_input_section): Ditto.
+	(elf32_aarch64_size_stubs): Ditto.
+	(elf32_aarch64_build_stubs): Ditto.
+	* bfd-in2.h: Re-generated.
+	* config.bfd (aarch64-*-elf): Add bfd_elf32_littleaarch64_vec
+	and bfd_elf32_bigaarch64_vec.
+	(aarch64-*-linux*): Likewise.
+	(aarch64_be-*-elf): Likewise.
+	(aarch64_be-*-linux*): Likewise.
+	* configure.in (bfd_elf32_bigaarch64_vec)
+	(bfd_elf32_littleaarch64_vec): New.
+	* configure: Re-generated.
+	* cpu-aarch64.c (compatible): Don't allow mixing ilp32 objects with
+	lp64 ones.
+	(bfd_aarch64_arch_ilp32): New.
+	(bfd_aarch64_arch): Link to bfd_aarch64_arch_ilp32.
+	* elfnn-aarch64.c (ARCH_SIZE): New define.
+	(AARCH64_R, AARCH64_R_STR, LOG_FILE_ALIGN): New defines.
+	(GOT_ENTRY_SIZE): Re-define as (ARCH_SIZE / 8).
+	(elf64_aarch64_*): Rename to elfNN_aarch64_*.
+	(ELF64_R_*): Rename to ELFNN_R_*.
+	Plus other paramaterization.
+	* targets.c (bfd_elf32_bigaarch64_vec, bfd_elf32_littleaarch64_vec):
+	New declarations.
+	(_bfd_target_vector): Add bfd_elf32_bigaarch64_vec and
+	bfd_elf32_littleaarch64_vec.
+
+2013-06-26  Yufeng Zhang  <[email protected]>
+
+	* Makefile.am (BFD64_BACKENDS_CFILES): Remove elf64-aarch64.c.
+	(BUILD_CFILES): Add elf64-aarch64.c.
+	(elf64-aarch64.c): New rule for generating from elfnn-aarch64.c.
+	* Makefile.in: Re-generated.
+	* elf64-aarch64.c: Rename to ...
+	* elfnn-aarch64.c: ... this.
+
+2013-06-25  Maciej W. Rozycki  <[email protected]>
+            Paul Brook  <[email protected]>
+
+	* elfxx-mips.h (_bfd_mips_elf_insn32): New prototype.
+	* elfxx-mips.c (mips_elf_link_hash_table): Add insn32 member.
+	(STUB_MOVE32_MICROMIPS, STUB_JALR32_MICROMIPS): New macros.
+	(MICROMIPS_INSN32_FUNCTION_STUB_NORMAL_SIZE): Likewise.
+	(MICROMIPS_INSN32_FUNCTION_STUB_BIG_SIZE): Likewise.
+	(micromips_insn32_o32_exec_plt0_entry): New variable.
+	(micromips_insn32_o32_exec_plt_entry): Likewise.
+	(_bfd_mips_elf_adjust_dynamic_symbol): Handle insn32 mode.
+	(mips_elf_estimate_stub_size): Likewise.
+	(_bfd_mips_elf_size_dynamic_sections): Likewise.
+	(_bfd_mips_elf_finish_dynamic_symbol): Likewise.
+	(mips_finish_exec_plt): Likewise.
+	(_bfd_mips_elf_relax_section): Likewise.
+	(_bfd_mips_elf_insn32): New function.
+	(_bfd_mips_elf_get_synthetic_symtab): Handle insn32 PLT.
+
+2013-06-24  Maciej W. Rozycki  <[email protected]>
+
+	* elfxx-mips.h (_bfd_mips_elf_get_synthetic_symtab): New
+	prototype.
+	* elf32-mips.c (elf_backend_plt_sym_val): Remove macro.
+	(bfd_elf32_get_synthetic_symtab): New macro.
+	* elfxx-mips.c (plt_entry): New structure.
+	(mips_elf_link_hash_entry): Add use_plt_entry member.
+	(mips_elf_link_hash_table): Rename plt_entry_size member to
+	plt_mips_entry_size.  Add plt_comp_entry_size, plt_mips_offset,
+	plt_comp_offset, plt_got_index entries and plt_header_is_comp
+	members.
+	(STUB_LW_MICROMIPS, STUB_MOVE_MICROMIPS): New macros.
+	(STUB_LUI_MICROMIPS, STUB_JALR_MICROMIPS): Likewise.
+	(STUB_ORI_MICROMIPS, STUB_LI16U_MICROMIPS): Likewise.
+	(STUB_LI16S_MICROMIPS): Likewise.
+	(MICROMIPS_FUNCTION_STUB_NORMAL_SIZE): Likewise.
+	(MICROMIPS_FUNCTION_STUB_BIG_SIZE): Likewise.
+	(micromips_o32_exec_plt0_entry): New variable.
+	(mips16_o32_exec_plt_entry): Likewise.
+	(micromips_o32_exec_plt_entry): Likewise.
+	(mips_elf_link_hash_newfunc): Initialize use_plt_entry.
+	(mips_elf_output_extsym): Update to use gotplt_union's plist
+	member rather than offset.
+	(mips_elf_gotplt_index): Likewise.  Remove the VxWorks
+	restriction.  Use MIPS_ELF_GOT_SIZE to calculate GOT address.
+	(mips_elf_count_got_symbols): Update to use gotplt_union's plist
+	member rather than offset.
+	(mips_elf_calculate_relocation): Handle MIPS16/microMIPS PLT
+	entries.
+	(_bfd_mips_elf_create_dynamic_sections): Don't set PLT sizes
+	here.
+	(mips_elf_make_plt_record): New function.
+	(_bfd_mips_elf_check_relocs): Update comment.  Record occurences
+	of JAL relocations that might need a PLT entry.
+	(_bfd_mips_elf_adjust_dynamic_symbol): Update to use
+	gotplt_union's plist member rather than offset.  Set individual
+	PLT entry sizes here.  Handle MIPS16/microMIPS PLT entries.
+	Don't set the symbol's value in the symbol table for PLT
+	references here.  Don't set the PLT or PLT GOT section sizes
+	here.
+	(mips_elf_estimate_stub_size): Handle microMIPS stubs.
+	(mips_elf_allocate_lazy_stub): Likewise.
+	(mips_elf_lay_out_lazy_stubs): Likewise.  Define a _MIPS_STUBS_
+	magic symbol.
+	(mips_elf_set_plt_sym_value): New function.
+	(_bfd_mips_elf_size_dynamic_sections): Set PLT header size and
+	PLT and PLT GOT section sizes here.  Set the symbol values in
+	the symbol table for PLT references here.  Handle microMIPS
+	annotation of the _PROCEDURE_LINKAGE_TABLE_ magic symbol.
+	(_bfd_mips_elf_finish_dynamic_symbol): Update to use
+	gotplt_union's plist member rather than offset.  Handle
+	MIPS16/microMIPS PLT entries.  Handle microMIPS stubs.
+	(_bfd_mips_vxworks_finish_dynamic_symbol): Update to use
+	gotplt_union's plist member rather than offset.  Use
+	MIPS_ELF_GOT_SIZE to calculate GOT address.
+	(mips_finish_exec_plt): Handle microMIPS PLT.  Return status.
+	(_bfd_mips_elf_finish_dynamic_sections): Handle result from
+	mips_finish_exec_plt.
+	(_bfd_mips_elf_link_hash_table_create): Update to use
+	gotplt_union's plist member rather than offset.
+	(_bfd_mips_elf_get_synthetic_symtab): New function.
+
+2013-06-24  Wawa  <[email protected]>
+
+	PR 15657
+	* hash.c (_bfd_stringtab_add): Copy the string if COPY is true.
+
+2013-06-23  Richard Sandiford  <[email protected]>
+
+	* Makefile.am (BFD32_BACKENDS, BFD32_BACKENDS_CFILES): Move MIPS ELF
+	files to...
+	(BFD64_BACKENDS, BFD64_BACKENDS_CFILES): ...here.
+	* Makefile.in: Regenerate.
+	* config.bfd: Enclose all MIPS ELF targets in #ifdef BFD64.
+	Set want64 to true for them at the end.
+	* targets.c (_bfd_target_vector): Protect MIPS ELF targets with
+	#ifdef BFD64.
+
+2013-06-22  Sandra Loosemore  <[email protected]>
+
+	* elf32-nios2.c (nios2_elf32_finish_dynamic_sections): Don't
+	set sh_entsize for PLT section.
+
+2013-06-20  Yufeng Zhang  <[email protected]>
+
+	* bfd-in.h (bfd_elf64_aarch64_set_options): Add 'extern'.
+	* bfd-in2.h: Re-generated.
+	* elf64-aarch64.c (RELOC_SECTION): Removed.
+	(SWAP_RELOC_IN, SWAP_RELOC_OUT): Ditto.
+	(AARCH64_ELF_OS_ABI_VERSION): Ditto.
+	(elf64_aarch64_link_hash_traverse): Ditto.
+	(elf64_aarch64_size_stubs): Change 'Aarch64' to 'AArch64' in the
+	comment.
+
+2013-06-19  Will Newton  <[email protected]>
+
+	* configure: Regenerated.
+	* configure.in: Remove aarch64 dependency on elf-ifunc.c.
+	* elf64-aarch64.c: Remove objalloc.h include.
+	(elf64_aarch64_howto_dynrelocs): Remove R_AARCH64_IRELATIVE howto.
+	(struct elf64_aarch64_link_hash_table): Remove ifunc related
+	members. (elf_aarch64_local_htab_hash): Remove function.
+	(elf_aarch64_local_htab_eq): Remove function.
+	(elf_aarch64_get_local_sym_hash): Remove function.
+	(elf64_aarch64_link_hash_table_create): Remove local hash
+	table initialization.
+	(elf64_aarch64_final_link_relocate): Remove sym argument and
+	handling of ifunc symbols.
+	(elf64_aarch64_relocate_section): Don't pass sym argument to
+	elf64_aarch64_final_link_relocate.
+	(elf64_aarch64_gc_sweep_hook): Remove handling of ifunc symbols.
+	(elf64_aarch64_adjust_dynamic_symbol): Likewise.
+	(elf64_aarch64_check_relocs): Likewise.
+	(elf64_aarch64_post_process_headers): Remove call to
+	_bfd_elf_set_osabi.
+	(elf64_aarch64_is_function_type): New function.
+	(elf64_aarch64_allocate_dynrelocs): Remove handling of ifunc
+	symbols. (elf_aarch64_allocate_local_dynrelocs): Remove function.
+	(elf64_aarch64_size_dynamic_sections): Remove call to
+	elf_aarch64_allocate_local_dynrelocs.
+	(elf64_aarch64_create_small_pltn_entry): Remove info argument.
+	Remove creation of R_AARCH64_IRELATIVE dynamic relocs.
+	(elf64_aarch64_finish_dynamic_symbol): Remove handling of ifunc
+	symbols. (elf_aarch64_finish_local_dynamic_symbol): Remove
+	function. (elf64_aarch64_finish_dynamic_sections): Remove call to
+	elf_aarch64_finish_local_dynamic_symbol.
+	(elf64_aarch64_add_symbol_hook): Remove function.
+
+2013-06-14  Yufeng Zhang  <[email protected]>
+
+	* elf64-aarch64.c (elf64_aarch64_final_link_relocate): Call
+	aarch64_resolve_relocation and bfd_elf_aarch64_put_addend to
+	handle the relocations of R_AARCH64_JUMP26, R_AARCH64_CALL26,
+	R_AARCH64_LD64_GOT_LO12_NC, R_AARCH64_ADR_GOT_PAGE and
+	R_AARCH64_GOT_LD_PREL19.
+
+2013-06-13  Terry Guo  <[email protected]>
+
+	PR ld/15302
+	* elf32-arm.c (allocate_dynrelocs_for_symbol): Transform
+	ST_BRANCH_TO_ARM into ST_BRANCH_TO_THUMB if the target only
+	supports thumb instructions.
+
+2013-06-11  DJ Delorie  <[email protected]>
+
+	* elf32-rl78.c (rl78_elf_relocate_section): Fix OPsub math.
+
+2013-06-11  Will Newton  <[email protected]>
+
+	* elf64-aarch64.c (elf_aarch64_get_local_sym_hash): Use
+	ELF64_R_SYM instead of ELF32_R_SYM.
+
+2013-06-11  Nick Clifton  <[email protected]>
+
+	* elf32-rl78.c (rl78_elf_finish_dynamic_sections): Onlly run
+	checks if the dynamic sections have been created and relaxation
+	has not been performed.
+
+2013-06-07  Will Newton  <[email protected]>
+
+	* configure: Regenerate.
+	* configure.in: Build elf-ifunc.o for AArch64.
+	* elf64-aarch64.c: Include objalloc.h.
+	(elf64_aarch64_howto_dynrelocs): Add R_AARCH64_IRELATIVE howto.
+	(struct elf64_aarch64_link_hash_table): Add members for handling
+	R_AARCH64_IRELATIVE relocations.
+	(elf_aarch64_local_htab_hash): New function.
+	(elf_aarch64_local_htab_eq): New function.
+	(elf_aarch64_get_local_sym_hash): New function.
+	(elf64_aarch64_link_hash_table_create): Initialize local STT_GNU_IFUNC
+	symbol hash.
+	(elf64_aarch64_hash_table_free): Free local STT_GNU_IFUNC symbol hash.
+	(elf64_aarch64_final_link_relocate): Add sym argument.  Add support
+	for handling STT_GNU_IFUNC symbols.
+	(elf64_aarch64_gc_sweep_hook): Add support for garbage collecting
+	references to STT_GNU_IFUNC symbols.
+	(elf64_aarch64_adjust_dynamic_symbol): Add support for handling
+	STT_GNU_IFUNC symbols.
+	(elf64_aarch64_check_relocs): Add support for handling STT_GNU_IFUNC
+	symbols.  Ensure we don't increase plt.refcount from -1 to 0.
+	(elf64_aarch64_post_process_headers): Call _bfd_elf_set_osabi.
+	(elf64_aarch64_is_function_type): Remove function.
+	(elf64_aarch64_allocate_dynrelocs): Call
+	_bfd_elf_allocate_ifunc_dyn_relocs for STT_GNU_IFUNC symbols.
+	(elf_aarch64_allocate_local_dynrelocs): New function.
+	(elf64_aarch64_size_dynamic_sections): Call
+	elf_aarch64_allocate_local_dynrelocs.  Initialize next_irelative_index.
+	(elf64_aarch64_create_small_pltn_entry): Add info argument.
+	Add support for creating .iplt entries for STT_GNU_IFUNC symbols.
+	(elf64_aarch64_finish_dynamic_symbol): Add support for handling
+	STT_GNU_IFUNC symbols and .iplt.
+	(elf_aarch64_finish_local_dynamic_symbol): New function.
+	(elf64_aarch64_finish_dynamic_sections): Call
+	elf_aarch64_finish_local_dynamic_symbol.
+	(elf64_aarch64_add_symbol_hook): New function.
+
+2013-06-03  Alan Modra  <[email protected]>
+
+	* syms.c (_bfd_stab_section_find_nearest_line): Add last_str
+	var.  Use it with last_stab.
+
+2013-05-30  Paul Brook  <[email protected]>
+
+	* bfd-in2.h: Regenerate.
+	* elf32-mips.c (elf_mips_eh_howto): New.
+	(bfd_elf32_bfd_reloc_type_lookup ): Support BFD_RELOC_MIPS_EH.
+	(bfd_elf32_bfd_reloc_name_lookup): Likewise.
+	(mips_elf32_rtype_to_howto): Support R_MIPS_EH.
+	* elf64-mips.c (elf_mips_eh_howto): New.
+	(bfd_elf64_bfd_reloc_type_lookup): Support BFD_RELOC_MIPS_EH.
+	(bfd_elf64_bfd_reloc_name_lookup): Likewise.
+	(mips_elf64_rtype_to_howto): Support R_MIPS_EH.
+	* libbfd.h: Regenerate.
+	* reloc.c (BFD_RELOC_MIPS_EH): New.
+
+2013-05-29  Nick Clifton  <[email protected]>
+
+	* dwarf2.c (struct dwarf2_debug): Add fields for handling
+	alternate debug info source.
+	(dwarf_debug_sections): Add entries for alternate .debug_str and
+	.debug_info sections.
+	(dwarf_debug_section_enum): Likewise.
+	(read_alt_indirect_string): New function.  Handles a
+	DW_FORM_GNU_strp_alt attribute.
+	(read_alt_indirect_ref): New function.  Handles a
+	DW_FORM_GNU_ref_alt attribute.
+	(read_attribute_value): Process DW_FORM_GNU_ref_alt and
+	DW_FORM_GNU_strp_alt.
+	(find_abstract_instance_name): Handle DW_FORM_GNU_ref_alt
+	attributes.
+	(_bfd_dwarf2_cleanup_debug_info): Free alternate debug info
+	sources.
+	* opncls.c (GNU_DEBUGALTLINK): Define.
+	(bfd_get_alt_debug_link_info): New function.
+	(separate_alt_debug_file_exists): New function.
+	(find_separate_debug_file): Add parameters for fetch and check
+	functions.
+	(bfd_follow_gnu_debugaltlink): New function.
+	* bfd-in2.h: Regenerate.
+
+2013-05-28  Yufeng Zhang  <[email protected]>
+
+	* reloc.c (BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE): Rename to ...
+	(BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21): ... this.
+	(BFD_RELOC_AARCH64_TLSDESC_LD64_PREL19): Rename to ...
+	(BFD_RELOC_AARCH64_TLSDESC_LD_PREL19): ...  this.
+	* bfd-in2.h: Regenerate.
+	* libbfd.h: Regenerate.
+	* elf64-aarch64.c (IS_AARCH64_TLSDESC_RELOC): Update to use
+	the correct names.
+	(elf64_aarch64_tlsdesc_howto_table): Likewise.
+	(elf64_aarch64_reloc_map): Likewise.
+	(aarch64_resolve_relocation): Likewise.
+	(bfd_elf_aarch64_put_addend): Likewise.
+	(aarch64_tls_transition_without_check): Likewise.
+	(aarch64_reloc_got_type): Likewise.
+	(elf64_aarch64_final_link_relocate): Likewise.
+	(elf64_aarch64_tls_relax): Likewise.
+	(elf64_aarch64_relocate_section): Likewise.
+	(elf64_aarch64_gc_sweep_hook): Likewise.
+	(elf64_aarch64_check_relocs): Likewise.
+
+2013-05-26  Mark Wielaard  <[email protected]>
+
+	* cache.c (BFD_CACHE_MAX_OPEN): Remove define.
+	(max_open_files): New static int initialized to zero.
+	(bfd_cache_max_open): New static function to set and return
+	max_open_files.
+	(bfd_cache_init): Use bfd_cache_max_open.
+	(bfd_open_file): Likewise.
+	* configure.in (AC_CHECK_HEADERS): Add sys/resource.h.
+	(AC_CHECK_FUNCS): Add getrlimit.
+	* configure: Regenerated.
+	* config.in: Likewise.
+	* sysdep.h: Check and include sys/resource.h for getrlimit.
+
+2013-05-23  Alan Modra  <[email protected]>
+
+	* format.c (bfd_check_format_matches): Don't match a target in
+	targ_selvecs if some other target is a better match.  If
+	targets implement match priority, fall back to the first of
+	the best matches.
+
+2013-05-22  Eric Herman  <[email protected]>
+
+	PR binutils/15462
+	* elfxx-mips.c (_bfd_mips_elf_relocate_section): Warning fix.
+
+2013-05-22  Ralf Dreesen  <[email protected]>
+
+	PR binutils/15474
+	* srec.c (srec_set_section_contents): Properly convert size
+	and offset to address when octets_per_byte is not unity.
+
+2013-05-20  Maciej W. Rozycki  <[email protected]>
+
+	* elf32-vax.c (elf_vax_instantiate_got_entries): Only set the
+	refcount member of the gotplt_union when resetting the reference
+	count.  Adjust comment.
+
+2013-05-20  Will Newton  <[email protected]>
+
+	* elf64-aarch64.c (elf64_aarch64_link_hash_entry): Remove
+	relocs_copied member.
+	(elf64_aarch64_link_hash_newfunc): Remove initialization of
+	relocs_copied member.
+	(elf64_aarch64_copy_indirect_symbol): Remove code to copy
+	relocs_copied member.
+
+2013-05-19  Maciej W. Rozycki  <[email protected]>
+
+	* elf32-vax.c (elf_vax_adjust_dynamic_symbol): Convert K&R
+	function definition.
+
+2013-05-16  Cary Coutant  <[email protected]>
+
+	* ecoff.c (ecoff_link_check_archive_element): Add initializers for
+	external_ext_size and esize.
+
+2013-05-16  Tristan Gingold  <[email protected]>
+
+	* coff-rs6000.c (_bfd_xcoff_reloc_type_lookup): Handle BFD_RELOC_16.
+	* coff64-rs6000.c (xcoff64_reloc_type_lookup): Likewise.
+
+2013-05-15  Andreas Schwab  <[email protected]>
+
+	* elf64-aarch64.c (elf_backend_default_execstack): Define to 0.
+
+2013-05-10  Joel Brobecker  <[email protected]>
+
+	* coffcode.h (styp_to_sec_flags) [RS6000COFF_C]: Add handling
+	of STYP_EXCEPT, STYP_LOADER and STYP_TYPCHK sections.
+
+2013-05-09  Joel Brobecker  <[email protected]>
+
+	* bfd.c (_bfd_default_error_handler): Replace use of putc
+	by fputc.  Add comment explaining why.
+
+2013-05-09  Alan Modra  <[email protected]>
+
+	* elflink.c (elf_link_add_object_symbols): Don't omit reading
+	of symbols when hashes already exist.
+
+2013-05-07  Will Newton  <[email protected]>
+
+	* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Add a
+	plt_header_size argument for ports where it differs from
+	plt_entry_size.
+	* elf-bfd.h: Likewise.
+	* elf32-i386.c: Pass plt_header_size to
+	_bfd_elf_allocate_ifunc_dyn_relocs.
+	* elf64-x86-64.c: Likewise.
+
+2013-05-07  Will Newton  <[email protected]>
+
+	* elf-ifunc.c (_bfd_elf_create_ifunc_dyn_reloc): Remove unused
+	function.
+	* elf-bfd.h: Likewise.
+
+2013-05-06  Paul Brook  <[email protected]>
+
+	* elf64-mips.c (elf_mips_gnu_pcrel32): New.
+	(bfd_elf64_bfd_reloc_type_lookup, bfd_elf64_bfd_reloc_name_lookup,
+	mips_elf64_rtype_to_howto): Handle R_MIPS_PC32.
+	* elfn32-mips.c (elf_mips_gnu_pcrel32): New.
+	(bfd_elfn32_bfd_reloc_type_lookup, bfd_elfn32_bfd_reloc_name_lookup,
+	mips_elfn32_rtype_to_howto): Handle R_MIPS_PC32.
+
+2013-05-06  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (opd_entry_value): Handle case where symbol
+	hashes are not available.
+
+2013-05-06  Alan Modra  <[email protected]>
+
+	* elflink.c (elf_link_add_object_symbols): Don't save symbol
+	hashes around loading as-needed library.  Zero them on allocation,
+	and restore to initial all-zero state if library not needed.
+	Arrange to reuse hashes if we load library again later.
+
+2013-05-04  Richard Sandiford  <[email protected]>
+
+	* elf32-mips.c (elf_mips_copy_howto, elf_mips_jump_slot_howto):
+	Use _bfd_mips_elf_generic_reloc instead of bfd_elf_generic_reloc.
+	* elfn32-mips.c: Likewise.
+	* elf64-mips.c: Likewise.
+
+2013-05-02  Nick Clifton  <[email protected]>
+
+	* archures.c: Add some more MSP430 machine numbers.
+	* config.bfd (msp430): Define targ_selvecs.
+	* configure.in: Add bfd_elf32_msp430_ti_vec.
+	* cpu-msp430.c: Add some more MSP430 machine numbers.
+	* elf32-msp430.c Add support for MSP430X relocations.
+	Add support for TI compiler generated relocations.
+	Add support for sym_diff relocations.
+	Add support for relaxing out of range short branches into long
+	branches.
+	Add support for MSP430 attribute section.
+	* reloc.c: Add MSP430X relocations.
+	* targets.c: Add bfd_elf32_msp430_ti_vec.
+	* bfd-in2.h: Regenerate.
+	* configure: Regenerate.
+	* libbfd.h: Regenerate.
+
+2013-05-01  Maciej W. Rozycki  <[email protected]>
+
+	* config.bfd: Replace alpha*-*-linuxecoff* pattern with
+	alpha*-*-linux*ecoff*.
+
+2013-04-30  Olaf Flebbe  <[email protected]>
+
+	PR binutils/15417
+	* elflink.c (elf_link_add_object_symbols): Initialise 'idx' to
+	zero.
+
+2013-04-30  Alan Modra  <[email protected]>
+
+	* elflink.c (bfd_elf_record_link_assignment): Dont make
+	STV_INTERNAL symbols STV_HIDDEN.
+
+2013-04-29  Nick Clifton  <[email protected]>
+
+	* elflink.c (_bfd_elf_gc_mark_extra_sections): Remove mark from
+	fragmented .debug_line sections associated with unmarked code
+	sections.
+
+2013-04-29  Will Newton  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_populate_plt_entry): Call
+	elf32_arm_add_dynreloc when emitting R_ARM_IRELATIVE relocs.
+
+2013-04-29  Will Newton  <[email protected]>
+
+	* elf64-aarch64.c (elf64_aarch64_check_relocs): Move relocation
+	error check up and add error message.
+
+2013-04-26  Will Newton  <[email protected]>
+
+	* elf64-aarch64.c (elf64_aarch64_check_relocs): Remove dead code.
+
+2013-04-25  Alan Modra  <[email protected]>
+
+	* config.bfd: Add powerpc64le-linux.
+
+2013-04-24  H.J. Lu  <[email protected]>
+
+	* config.bfd (targ_selvecs): Add bfd_elf32_x86_64_vec for
+	x86_64-*-elf*.
+
+2013-04-24  Roland McGrath  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_allocate_plt_entry): If HTAB->nacl_p,
+	allocate space for PLT header even if IS_IPLT_ENTRY.
+	(arm_nacl_put_plt0): New function, broken out of ...
+	(elf32_arm_finish_dynamic_sections): ... here.  Call it.
+	If HTAB->nacl_p, set up the PLT header in .iplt too.
+	(elf32_arm_output_arch_local_syms): If HTAB->nacl_p, write
+	a mapping symbol for the start of .iplt too.
+
+2013-04-19  Luca Pizzamiglio  <[email protected]>
+
+	* ecoff.c (_bfd_ecoff_sizeof_headers): Cast the return value of
+	BFD_ALIGN to int.
+	* elf32-tic6x.c (elf32_tic6x_size_dynamic_sections): Remove unused
+	variables.
+	* elf32-v850.c (v850_elf_relax_section): Redefine the type of 'i'
+	to bfd_vma.
+	* vms-alpha.c (evax_bfd_print_etir): Initialize sec_len.
+
+2013-04-22  Alan Modra  <[email protected]>
+
+	PR ld/15382
+	* elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): Don't multiply
+	sh_size or reloc_count adjustment by count.
+
+2013-04-22  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (ppc64_elf_check_relocs): Don't call
+	create_linkage_sections here..
+	(ppc64_elf_init_stub_bfd): ..do so here.  Return status.
+	(create_linkage_sections): Move earlier in file.
+	(ppc64_elf_setup_section_lists): Remove now useless htab->brlt test.
+	* elf64-ppc.h (ppc64_elf_init_stub_bfd): Update proto.
+
+2013-04-19  Nick Clifton  <[email protected]>
+
+	PR binutils/15356
+	* compress.c (decompress_contents): Always call inflateEnd, even
+	when another inflation operation fails.
+
+2013-04-17  H.J. Lu  <[email protected]>
+
+	* elf-ifunc.c: Update copyright year.
+
+2013-04-17 Luca Pizzamiglio  <[email protected]>
+
+	* coffcode.h: Added a cast to void when a bfd_set_section_*()
+	macro's return value is ignored.
+	* elf32-hppa.c: Likewise.
+	* elf32-tic6x.c: Likewise.
+	* mach-o.c: Likewise.
+	* mmo.c: Likewise.
+	* opncls.c: Likewise.
+	* peicode.h: Likewise.
+	* elf32-m32r.c: Check return value of bfd_set_section_*().
+	* elfnn-ia64.c: Likewise.
+	* elfxx-mips.c: Likewise.
+	* vms-alpha.c: Likewise.
+
+2013-04-15  H.J. Lu  <[email protected]>
+
+	PR ld/15371
+	* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Check
+	regular reference without non-GOT reference when building
+	shared library.
+
+2013-04-15  Alan Modra  <[email protected]>
+
+	* archive.c (_bfd_archive_close_and_cleanup): Clear parent
+	cache slot for archives.
+
+2013-04-14  Hans-Peter Nilsson  <[email protected]>
+
+	* mmo.c (mmo_write_chunk): Break out abfd->tdata.mmo_data to new
+	local variable mmop.
+
+2013-04-09  Senthil Kumar Selvaraj  <[email protected]>
+
+	PR ld/12494
+	* elf32-avr.c: Consider all sections to determine if linker
+	relaxation can safely delete a ret after a call/jmp
+
+2013-04-09  Mingjie Xing  <[email protected]>
+
+	* bfd.c (typedef bfd, Error reporting, Miscellaneous): Add
+	INODEs.
+
+2013-04-08  Tom Tromey  <[email protected]>
+
+	* som.c (bfd_section_from_som_symbol): No longer static.
+	* som.h (bfd_section_from_som_symbol): Declare.
+
+2013-04-06  Alan Modra  <[email protected]>
+
+	* elf32-ppc.c (ppc_elf_check_relocs): Use SYMBOLIC_BIND.
+	* elf64-ppc.c (ppc64_elf_check_relocs, dec_dynrel_count): Likewise.
+
+2013-04-05  Nick Clifton  <[email protected]>
+
+	* elflink.c (elf_link_add_object_symbols): Revert accidental commit.
+
+2013-04-04  Alan Modra  <[email protected]>
+
+	* bfd.c (bfd_error_type, bfd_errmsgs): Add bfd_error_missing_dso.
+	* bfd-in2.h: Regenerate.
+	* elflink.c (elf_link_add_object_symbols): Use new error.
+
+2013-04-03  Nick Clifton  <[email protected]>
+
+	* elf32-v850.c (v850_elf_is_target_special_symbol): New function.
+	(bfd_elf32_bfd_is_target_special_symbol): Define.
+
+2013-04-03   Venkataramanan Kumar  <[email protected]>
+
+	* elf64-aarch64.c (elf64_aarch64_gc_sweep_hook): Use
+	elf64_aarch64_locals to get local GOT reference counts.
+
+2013-04-02  DJ Delorie  <[email protected]>
+
+	* elf32-rl78.c (GET_RELOC): Assert that there are relocs to get.
+	(rl78_elf_relax_section): Only fetch the next reloc if there is
+	one expected.
+
+2013-03-30  Alan Modra  <[email protected]>
+
+	PR ld/15323
+	* elf-m10300.c (mn10300_elf_check_relocs): Set non_ir_ref for
+	global symbols referenced by relocs.
+	* elf32-arm.c (elf32_arm_check_relocs): Likewise.
+	* elf32-bfin.c (bfin_check_relocs): Likewise.
+	* elf32-cr16.c (cr16_elf_check_relocs): Likewise.
+	* elf32-cris.c (cris_elf_check_relocs): Likewise.
+	* elf32-d10v.c (elf32_d10v_check_relocs): Likewise.
+	* elf32-dlx.c (elf32_dlx_check_relocs): Likewise.
+	* elf32-fr30.c (fr30_elf_check_relocs): Likewise.
+	* elf32-frv.c (elf32_frv_check_relocs): Likewise.
+	* elf32-hppa.c (elf32_hppa_check_relocs): Likewise.
+	* elf32-i370.c (i370_elf_check_relocs): Likewise.
+	* elf32-iq2000.c (iq2000_elf_check_relocs): Likewise.
+	* elf32-lm32.c (lm32_elf_check_relocs): Likewise.
+	* elf32-m32c.c (m32c_elf_check_relocs): Likewise.
+	* elf32-m32r.c (m32r_elf_check_relocs): Likewise.
+	* elf32-m68hc1x.c (elf32_m68hc11_check_relocs): Likewise.
+	* elf32-m68k.c (elf_m68k_check_relocs): Likewise.
+	* elf32-mcore.c (mcore_elf_check_relocs): Likewise.
+	* elf32-metag.c (elf_metag_check_relocs): Likewise.
+	* elf32-microblaze.c (microblaze_elf_check_relocs): Likewise.
+	* elf32-moxie.c (moxie_elf_check_relocs): Likewise.
+	* elf32-msp430.c (elf32_msp430_check_relocs): Likewise.
+	* elf32-mt.c (mt_elf_check_relocs): Likewise.
+	* elf32-nios2.c (nios2_elf32_check_relocs): Likewise.
+	* elf32-openrisc.c (openrisc_elf_check_relocs): Likewise.
+	* elf32-ppc.c (ppc_elf_check_relocs): Likewise.
+	* elf32-rl78.c (rl78_elf_check_relocs): Likewise.
+	* elf32-s390.c (elf_s390_check_relocs): Likewise.
+	* elf32-score.c (s3_bfd_score_elf_check_relocs): Likewise.
+	* elf32-score7.c (s7_bfd_score_elf_check_relocs): Likewise.
+	* elf32-sh.c (sh_elf_check_relocs): Likewise.
+	* elf32-tic6x.c (elf32_tic6x_check_relocs): Likewise.
+	* elf32-tilepro.c (tilepro_elf_check_relocs): Likewise.
+	* elf32-v850.c (v850_elf_check_relocs): Likewise.
+	* elf32-vax.c (elf_vax_check_relocs): Likewise.
+	* elf32-xstormy16.c (xstormy16_elf_check_relocs): Likewise.
+	* elf32-xtensa.c (elf_xtensa_check_relocs): Likewise.
+	* elf64-aarch64.c (elf64_aarch64_check_relocs): Likewise.
+	* elf64-alpha.c (elf64_alpha_check_relocs): Likewise.
+	* elf64-hppa.c (elf64_hppa_check_relocs): Likewise.
+	* elf64-ia64-vms.c (elf64_ia64_check_relocs): Likewise.
+	* elf64-mmix.c (mmix_elf_check_relocs): Likewise.
+	* elf64-ppc.c (ppc64_elf_check_relocs): Likewise.
+	* elf64-s390.c (elf_s390_check_relocs): Likewise.
+	* elf64-sh64.c (sh_elf64_check_relocs): Likewise.
+	* elfnn-ia64.c (elfNN_ia64_check_relocs): Likewise.
+	* elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Likewise.
+	* elfxx-tilegx.c (tilegx_elf_check_relocs): Likewise.
+	* elfxx-mips.c (_bfd_mips_elf_check_relocs): Likewise.  Don't
+	test indirect/warning links for NULL.
+
+2013-03-29  H.J. Lu  <[email protected]>
+
+	PR ld/15323
+	* elf32-i386.c (elf_i386_check_relocs): Set non_ir_ref if a
+	symbol is referenced by a non-shared object.
+	* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
+
+2013-03-28  Joe Seymour  <[email protected]>
+
+	* elf32-sh.c (sh_elf_relocate_section): Suppress warnings for
+	R_SH_REL32 relocations against undefined weak symbols.
+
+2013-03-28  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (struct ppc_dyn_relocs): New.
+	(ppc64_elf_check_relocs): Separate dynrel counts for local syms
+	into ifunc and non-ifunc.
+	(dec_dynrel_count): Pass in sym rather than sym_sec.  Handle
+	separate ifunc/non-ifunc dynrel counts.
+	(allocate_got): Always use reliplt for ifunc.
+	(allocate_dynrelocs): Likewise.
+	(ppc64_elf_size_dynamic_sections): Likewise.
+	(ppc64_elf_layout_multitoc): Likewise.
+	(ppc64_elf_relocate_section): Likewise.
+
+2013-03-28  Alan Modra  <[email protected]>
+
+	* elf32-ppc.c (struct ppc_dyn_relocs): New.
+	(ppc_elf_check_relocs): Separate dynrel counts for local syms
+	into ifunc and non-ifunc.
+	(allocate_dynrelocs): Always put ifunc relocs into reliplt.
+	(ppc_elf_size_dynamic_sections): Likewise.
+	(ppc_elf_relocate_section): Likewise.
+
+2013-03-28  Alan Modra  <[email protected]>
+
+	* elf-bfd.h (enum elf_reloc_type_class): Add reloc_class_ifunc.
+	(struct elf_backend_data <elf_backed_reloc_type_class>): Add
+	bfd_link_info* and asection* params.
+	(_bfd_elf_reloc_type_class): Likewise.
+	* elf.c (_bfd_elf_reloc_type_class): Likewise.
+	* elflink.c (elf_link_sort_cmp2): Sort first on reloc class.
+	(elf_link_sort_relocs): Update elf_backed_reloc_type_class call.
+	* elf32-ppc.c (ppc_elf_reloc_type_class): Return reloc_class_ifunc
+	for any reliplt reloc.  Don't return reloc_class_plt for
+	R_PPC_REL24 and R_PPC_ADDR24.
+	* elf64-ppc.c (allocate_got): Formatting.
+	(ppc64_elf_reloc_type_class): Return reloc_class_ifunc for any
+	reliplt reloc.
+	* elf-m10300.c, * elf32-arm.c, * elf32-bfin.c, * elf32-cr16.c,
+	* elf32-cris.c, * elf32-hppa.c, * elf32-i386.c, * elf32-lm32.c,
+	* elf32-m32r.c, * elf32-m68k.c, * elf32-metag.c, * elf32-nios2.c,
+	* elf32-s390.c, * elf32-sh.c, * elf32-sparc.c, * elf32-tilepro.c,
+	* elf32-vax.c, * elf32-xtensa.c, * elf64-aarch64.c, * elf64-alpha.c,
+	* elf64-hppa.c, * elf64-ia64-vms.c, * elf64-s390.c, * elf64-sparc.c,
+	* elf64-x86-64.c, * elfnn-ia64.c, * elfxx-tilegx.c, * elfxx-tilegx.h:
+	Add extra params to the various reloc_type_class functions.
+
+2013-03-27  Alan Modra  <[email protected]>
+
+	* elf32-ppc.c (ppc_elf_check_relocs): Set PLT_IFUNC in local got
+	masks for all local ifunc syms.
+	(allocate_dynrelocs): Don't use htab->relgot for ifunc.
+	(ppc_elf_size_dynamic_sections): Likewise.
+	(ppc_elf_relocate_section): Likewise.
+
+2013-03-27  Will Newton  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_final_link_relocate): Avoid emitting a
+	dynamic reloc for symbols with dynindx == -1.
+	(allocate_dynrelocs_for_symbol): Avoid allocating space for a
+	dynamic reloc for symbols with dynindx == -1.
+
+2013-03-27  Will Newton  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_final_link_relocate): Avoid emitting a
+	dynamic reloc for non-default visibility undefined weaks.
+	(allocate_dynrelocs_for_symbol): Avoid allocating space for a
+	dynamic reloc for non-default visibility undefined weaks.
+
+2013-03-26  Alan Modra  <[email protected]>
+
+	* elflink.c (_bfd_elf_add_default_symbol): Preserve section
+	over _bfd_elf_merge_symbol calls.
+
+2013-03-26  Alan Modra  <[email protected]>
+
+	* elflink.c (elf_link_add_object_symbols): Add assertion for
+	common override alignment check code.  Formatting.
+
+2013-03-25  Alan Modra  <[email protected]>
+
+	* elflink.c (_bfd_elf_merge_symbol): Set old_alignment for
+	usual common symbols as well as for dynamic.  Add poldbfd param.
+	Save old bfd.  Adjust callers.
+	(_bfd_elf_add_default_symbol): Add poldbfd param.  Pass "section"
+	and "value" by value, not pointer.  Adjust caller.
+	(elf_link_add_object_symbols): Combine undef_bfd and old_bfd vars.
+	Delete code to set same.  Use old_bfd and old_alignment from
+	_bfd_elf_merge_symbol instead.  Add default symbol before
+	alignment and size checks.  Wrap overlong lines.
+
+2013-03-25  Alan Modra  <[email protected]>
+
+	* elflink.c (_bfd_elf_add_default_symbol): Delete "override" param.
+	(elf_link_add_object_symbols): Don't call _bfd_elf_add_default_symbol
+	when override is true.
+
+2013-03-25  Alan Modra  <[email protected]>
+
+	* elflink.c (_bfd_elf_merge_symbol): Use local var holding value
+	of *sym_hash.
+
+2013-03-25  Alan Modra  <[email protected]>
+
+	* elflink.c (_bfd_elf_merge_symbol): Don't discard TLS symbols here.
+	Wrap long lines.
+	(elf_link_add_object_symbols): Discard TLS symbols for --just-syms
+	early in symbol loop.
+
+2013-03-25  Alan Modra  <[email protected]>
+
+	* elf-bfd.h (struct elf_backend_data <merge_symbol>): Update proto.
+	(_bfd_elf_init_reloc_shdr): Delete.
+	* elf.c (_bfd_elf_init_reloc_shdr): Make static.
+	* elf64-x86-64.c (elf_x86_64_merge_symbol): Trim parameters to
+	just what is needed.
+	* elflink.c (_bfd_elf_merge_symbol): Update bed->merge_symbol call.
+
+2013-03-23  Alan Modra  <[email protected]>
+
+	* elf-bfd.h (_bfd_elf_merge_symbol): Delete declaration.
+	* elflink.c (_bfd_elf_merge_symbol): Make static.
+	* elf32-sh-symbian.c (sh_symbian_relocate_section): Don't call
+	_bfd_elf_merge_symbol, call _bfd_generic_link_add_one_symbol.
+
+2013-03-23  Alan Modra  <[email protected]>
+
+	PR ld/15270
+	* elflink.c (elf_link_add_object_symbols): Don't set def_regular
+	or ref_regular for BFD_PLUGIN owned syms, or have them affect
+	def_dynamic/ref_dynamic.
+	(_bfd_elf_fix_symbol_flags): Don't set def_regular for BFD_PLUGIN
+	owned syms.
+
+2013-03-22  David S. Miller  <[email protected]>
+
+	* elfxx-sparc.c (_bfd_sparc_elf_merge_private_bfd_data): Set type of
+	hwcaps attribute.
+
+2013-03-22  Achille Fouilleul  <[email protected]>
+
+	PR ld/14902
+	* elf32-h8300.c (elf32_h8_relax_delete_bytes): Fix off by one
+	errors adjusting relocs and symbols.
+
+2013-03-21  Michael Schewe  <[email protected]>
+
+	* elf32-h8300 (h8_relax_section): Add new relaxation of mov
+	@(disp:32,ERx) to mov @(disp:16,ERx).
+	(R_H8_DISP32A16): New reloc.
+	Comments added and corrected.
+	* reloc.c (BFD_RELOC_H8_DISP32A16): New reloc.
+	* bfd-in2.h: Regenerate.
+	* libbfd.h: Regenerate.
+
+2013-03-21  Kai Tietz  <[email protected]>
+
+	* coffgen.c (coff_real_object_p): Make global.
+	* peicode.h (coff_real_object_p): Add prototype.
+	(FILHDR): Defined for COFF_IMAGE_WITH_PE as
+	external_PEI_IMAGE_hdr structure.
+	(coff_swap_filehdr_in): Handle variable header-size.
+	* peXXigen.c (_bfd_XXi_swap_aouthdr_in): Just handle amount
+	of directory-entiries as specified in pe-header.
+
+2013-03-21  Nick Clifton  <[email protected]>
+
+	PR sim/15286
+	* elf32-arm.c (bfd_arm_get_mach_from_attributes): Identify XScale,
+	iWMMXt and iWMMXt2 processors from attributes.
+
+2013-03-20  Alan Modra  <[email protected]>
+
+	* elflink.c (_bfd_elf_make_dynamic_reloc_section): Override
+	sh_type according to is_rela.
+
+2013-03-18  Alan Modra  <[email protected]>
+
+	PR ld/12549
+	* elflink.c (elf_link_add_object_symbols): Exclude weak refs when
+	considering whether an --as-needed library is needed.
+
+2013-03-14  Tom Tromey  <[email protected]>
+
+	* opncls.c (bfd_get_debug_link_info): Rename from
+	get_debug_link_info.  Export.  Update comment.
+	(find_separate_debug_file): Update.
+	* bfd-in2.h: Rebuild.
+
+2013-03-08  Venkataramanan Kumar  <[email protected]>
+
+	* elf64-aarch64.c (elf_backend_can_gc_sections): Enable gc-section
+	support.
+	(elf64_aarch64_gc_sweep_hook): Handle GOT, TLS and PLT related
+	relocs.
+
+2013-03-08  Andreas Arnez  <[email protected]>
+
+	* elf-bfd.h (elfcore_write_s390_tdb): Add prototype.
+	* elf.c (elfcore_write_s390_tdb): New function.
+	(elfcore_write_register_note): Call it.
+	(elfcore_grok_s390_tdb): New function.
+	(elfcore_grok_note): Call it.
+
+2013-03-08  Maciej W. Rozycki  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_allocate_lazy_stub): Correct data type.
+
+2013-03-05  Corinna Vinschen  <[email protected]>
+
+	* config.bfd: Add x86_64-*-cygwin to list of supported targets.
+
+2013-03-04  Alan Modra  <[email protected]>
+
+	* elf32-ppc.c (ppc_elf_relocate_section <R_PPC_PLTREL24>): Adjust
+	non-zero addends when relocatable, rather than addends >= 32768.
+	Always zero "addend" before applying relocation.
+
+2013-03-04  Nick Clifton  <[email protected]>
+
+	* archive64.c (bfd_elf64_archive_write_armap): Fix calculation of
+	file pointer offsets for thin archives.
+
+2013-02-28  Nathan Sidwell  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_size_dynamic_sections): Don't call
+	elf32_arm_allocate_dynrelocs for source reloc for non-dynamic link.
+
+2013-02-27  DJ Delorie  <[email protected]>
+
+	* reloc.c (BFD_RELOC_RL78_CODE): Add.
+	* libbfd.h: Regenerate.
+	* bfd-in2.h: Regenerate.
+	* elf32-rl78.c (rl78_elf_relocate_section): Handle weak code
+	references in compuated relocs.
+
+2013-02-26  Anthony Green  <[email protected]>
+
+	* config.bfd: Extend moxie-rtems target triplet name support.
+
+2013-02-21  H.J. Lu  <[email protected]>
+
+	PR ld/15167
+	* elf64-ia64-vms.c (elf64_vms_link_add_object_symbols): Set
+	unique_global only for definition.
+	* elflink.c (_bfd_elf_merge_symbol): Don't set unique_global
+	here.
+	(elf_link_add_object_symbols): Set unique_global only
+	for definition.
+
+2013-02-21  Alan Modra  <[email protected]>
+
+	* elf-bfd.h (struct elf_build_id): Extracted from..
+	(struct elf_build_id_info): ..here.  Delete.
+	(struct output_elf_obj_tdata): New, extracted from..
+	(struct elf_obj_tdata): ..here.  Reorganize for better packing.
+	Add "o" field.
+	(elf_program_header_size): Reference tdata->o.
+	(elf_seg_map, elf_next_file_pos, elf_eh_frame_hdr, elf_linker,
+	elf_stack_flags, elf_shstrtab, elf_strtab_sec, elf_shstrtab_sec,
+	elf_section_syms, elf_num_section_syms, elf_flags_init): Likewise.
+	* elf.c (bfd_elf_allocate_object): Allocate output_elf_obj_tdata
+	when opening bfd in any mode that might write.
+	(_bfd_elf_write_object_contents): Use build_id field in
+	output_elf_obj_tdata.
+	(_bfd_elf_close_and_cleanup): Tweak elf_shstrtab test.
+	(elfobj_grok_gnu_build_id): Adjust for elf_tdata changes.
+
+2013-02-21  Alan Modra  <[email protected]>
+
+	* elf-bfd.h (struct core_elf_obj_tdata): New.
+	(struct elf_obj_tdata): Delete core_signal, core_pid, core_lwpid,
+	core_program, and core_command.  Add "core".
+	* elf.c (bfd_elf_mkcorefile): Allocate "core" struct.
+	Update all refs to tdata core fields.
+	* elf32-am33lin.c, * elf32-arm.c, * elf32-cris.c, * elf32-frv.c,
+	* elf32-hppa.c, * elf32-i386.c, * elf32-m68k.c, * elf32-mips.c,
+	* elf32-nios2.c, * elf32-ppc.c, * elf32-s390.c, * elf32-score.c,
+	* elf32-score7.c, * elf32-sh.c, * elf32-sparc.c, * elf32-tilegx.c,
+	* elf32-tilepro.c, * elf32-xtensa.c, * elf64-aarch64.c,
+	* elf64-hppa.c, * elf64-mips.c, * elf64-ppc.c, * elf64-tilegx.c,
+	* elf64-x86-64.c, * elfcore.h, * elfn32-mips.c: Update all refs
+	to tdata core fields.
+
+2013-02-21  Alan Modra  <[email protected]>
+
+	* elf-bfd.h (struct elf_obj_tdata): Rename segment_map to seg_map.
+	Delete num_locals and num_globals.
+	(elf_num_locals, elf_num_globals): Don't define.
+	(elf_seg_map, elf_next_file_pos, elf_eh_frame_hdr, elf_linker,
+	elf_stack_flags, elf_strtab_sec, elf_shstrtab_sec): Define.
+	* bfd.c, * elf-eh-frame.c, * elf-nacl.c, * elf-vxworks.c, * elf.c,
+	* elf32-arm.c, * elf32-lm32.c, * elf32-ppc.c, * elf32-rx.c,
+	* elf32-spu.c, * elf64-hppa.c, * elfcode.h, * elflink.c,
+	* elfnn-ia64.c, * elfxx-mips.c: Use newly defined elf_obj_tdata
+	accessor macros.
+	* elf.c (elf_map_symbols): Add pnum_locals param.  Return
+	number of locals syms via new param.
+	(swap_out_syms): Adjust to suit elf_map_symbols change.
+
+2013-02-19  Maciej W. Rozycki  <[email protected]>
+
+	* elfxx-mips.c (_bfd_mips_elf_finish_dynamic_symbol): Also clear
+	STO_MICROMIPS annotation.
+
+2013-02-19  Alan Modra  <[email protected]>
+
+	* configure.in: Bump version to 2.23.52.
+	* elf-bfd.h (struct elf_build_id_info): New.
+	(struct elf_obj_tdata): Delete after_write_object_contents,
+	after_write_object_contents_info and build_id_size.  Make build_id
+	a pointer to struct elf_build_id_info.
+	* elf.c (_bfd_elf_write_object_contents): Style.  Update
+	after_write_ibject_contents invocation.
+	(elfobj_grok_gnu_build_id): Update for new build_id struct.  Don't
+	allow zero size notes.
+	* configure: Regenerate.
+
+2013-02-18  Maciej W. Rozycki  <[email protected]>
+
+	* elf64-mips.c (micromips_elf64_howto_table_rel): Add
+	R_MICROMIPS_SCN_DISP and R_MICROMIPS_JALR.
+	(micromips_elf64_howto_table_rela): Likewise.
+	(micromips_reloc_map): Add BFD_RELOC_MICROMIPS_JALR.
+	* elfn32-mips.c (elf_micromips_howto_table_rel): Add
+	R_MICROMIPS_SCN_DISP and R_MICROMIPS_JALR.
+	(elf_micromips_howto_table_rela): Likewise.
+	(micromips_reloc_map): Add BFD_RELOC_MICROMIPS_JALR.
+
+2013-02-18  Paul Brook  <[email protected]>
+
+	* elfxx-mips.c (MICROMIPS_P): New macro.
+	(_bfd_mips_elf_symbol_processing): Use it.
+
+2013-02-18  Maciej W. Rozycki  <[email protected]>
+
+	* elfxx-mips.c (_bfd_mips_elf_create_dynamic_sections): Clarify
+	comment on _PROCEDURE_LINKAGE_TABLE_ creation.
+
+2013-02-18  Alan Modra  <[email protected]>
+
+	PR ld/12549
+	* elf-bfd.h (_bfd_elf_strtab_clear_refs): Delete.
+	(_bfd_elf_strtab_clear_all_refs): Declare.
+	(_bfd_elf_strtab_resize): Declare.
+	* elf-strtab.c (_bfd_elf_strtab_clear_refs): Delete.
+	(_bfd_elf_strtab_clear_all_refs): New function.
+	(_bfd_elf_strtab_resize): Likewise.
+	* elflink.c (elf_link_add_object_symbols): Use _bfd_elf_strtab_resize.
+
+2013-02-18  Alan Modra  <[email protected]>
+
+	* elf-bfd.h (struct elf_obj_tdata): Move find_line_info, local_stubs,
+	local_call_stubs, elf_data_symbol, elf_text_symbol, elf_data_section,
+	and elf_text_section to..
+	* elfxx-mips.c (struct mips_elf_obj_tdata): ..here.  Update all refs.
+	* elf64-alpha.c (struct mips_elf_find_line): Rename to..
+	(struct alpha_elf_find_line): ..this.
+	(struct alpha_elf_obj_tdata): Add find_line_info, update refs.
+
+2013-02-16  H.J. Lu  <[email protected]>
+
+	PR ld/15146
+	* elflink.c (elf_link_add_object_symbols): Don't add DT_NEEDED
+	for references from the dummy bfd.
+
+2013-02-16  H.J. Lu  <[email protected]>
+
+	PR ld/15149
+	* elflink.c (elf_link_add_object_symbols): Also track weak
+	references.
+
+2013-02-15  H.J. Lu  <[email protected]>
+
+	PR binutils/15151
+	* archive.c (_bfd_find_nested_archive): Don't allow a nested
+	archive pointing to itself.
+	(_bfd_get_elt_at_filepos): Revert the last 2 changes.
+
+2013-02-15  Nick Clifton  <[email protected]>
+
+	PR binutils/15140
+	* archive.c (_bfd_get_elt_at_filepos): Prevent an infinite loop
+	accessing a corrupt nested archive.
+
+2013-02-13  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_got_page_ref): New structure.
+	(mips_got_page_entry): Use a section rather than a (bfd, symndx)
+	pair to represent the anchor point.
+	(mips_got_info): Add a got_page_refs field.
+	(mips_elf_link_hash_table): Add a sym_cache field.
+	(mips_got_page_ref_hash, mips_got_page_ref_eq): New functions.
+	(mips_got_page_entry_hash, mips_got_page_entry_eq): Update for
+	new anchor representation.
+	(mips_elf_create_got_info): Create got_page_refs rather than
+	got_page_entries.
+	(mips_elf_record_got_page_ref): New function.
+	(mips_elf_pages_for_range): Move further down file.
+	(mips_elf_record_got_page_entry): Likewise.  Take a got as argument.
+	Use a section rather than a (bfd, symndx) pair to represent the
+	anchor point.
+	(mips_elf_resolve_got_page_ref): New function.
+	(mips_elf_resolve_final_got_entries): Use it to populate
+	got_page_entries.
+	(_bfd_mips_elf_check_relocs): Call mips_elf_record_got_page_ref
+	rather than mips_elf_record_got_page_entry.  Only nullify h
+	afterwards.
+	(mips_elf_lay_out_got): Call mips_elf_resolve_final_got_entries
+	earlier.
+
+2013-02-12  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_lay_out_got): Count VxWorks GOT relocs
+	in g->relocs.
+
+2013-02-12  Alan Modra  <[email protected]>
+
+	* elfxx-target.h (bfd_elfNN_bfd_link_hash_table_free): Provide
+	suitable definition when using generic linker hash table.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_count_got_entries): Delete.
+	(mips_elf_check_recreate_got, mips_elf_recreate_got): Take a
+	mips_elf_traverse_got_arg.  Count GOT entries.
+	(mips_elf_resolve_final_got_entries): Take the bfd_link_info
+	as argument.  Update after above changes.
+	(mips_elf_merge_got, mips_elf_lay_out_got): Don't call
+	mips_elf_count_got_entries.  Update the calls to
+	mips_elf_resolve_final_got_entries.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_got_tls_type): New enum.
+	(mips_got_entry): Add tls_initialized.
+	(mips_elf_got_entry_hash, mips_elf_got_entry_eq, mips_tls_got_relocs)
+	(mips_elf_count_got_entry, mips_elf_initialize_tls_index): Remove
+	GOT_TLS_TYPE masks.
+	(mips_elf_reloc_tls_type, mips_tls_got_entries)
+	(mips_elf_record_global_got_symbol, mips_elf_initialize_tls_index)
+	(_bfd_mips_elf_finish_dynamic_symbol): Use GOT_TLS_NONE rather
+	than GOT_NORMAL.
+	(mips_elf_initialize_tls_slots): Replace got_offset and tls_type_p
+	arguments with a GOT entry.  Remove GOT_TLS_TYPE masks.  Use
+	tls_initialized rather than GOT_TLS_DONE.
+	(mips_tls_got_index): Delete.
+	(mips_elf_local_got_index, mips_elf_global_got_index): Use
+	mips_elf_initialize_tls_slots rather than mips_tls_got_index.
+	(mips_elf_record_got_entry): Initialize tls_initialized.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_got_entry): Remove tls_ldm_offset.
+	(mips_elf_link_hash_entry): Remove tls_ie_type, tls_gd_type,
+	tls_ie_got_offset and tls_gd_got_offset.
+	(mips_elf_link_hash_newfunc): Remove initialization.
+	(mips_elf_create_got_info): Likewise.
+	(mips_elf_count_local_got_entries, mips_elf_count_global_tls_entries)
+	(mips_tls_single_got_index): Delete.
+	(mips_elf_local_got_index): Always use the GOT entry to track
+	GOT indices.
+	(mips_elf_global_got_index): Likewise.
+	(mips_elf_create_local_got_entry): Assert that TLS entries have
+	already been allocated.
+	(mips_elf_record_global_got_symbol): Don't initialize
+	tls_ie_type or tls_gd_type.
+	(mips_elf_count_got_symbols): Only count reloc-only GOT entries here.
+	(mips_elf_initialize_tls_index): Allocate a GOT index for every TLS
+	entry.
+	(mips_elf_lay_out_got): Use mips_elf_count_got_entries to count
+	the GOT entries.
+	(_bfd_mips_elf_finish_dynamic_symbol): Assert that TLS GOT offsets
+	have been allocated.
+	(_bfd_mips_elf_copy_indirect_symbol): Remove handling of
+	tls_ie_type and tls_gd_type.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_create_local_got_entry): Tidy.  Avoid
+	aliasing violation.  Check for htab allocation failures.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_primary_global_got_index): New function,
+	split out from...
+	(mips_elf_global_got_index): ...here.  Reorder arguments so that
+	the output bfd and info come first.
+	(mips_elf_calculate_relocation): Update the call to
+	mips_elf_global_got_index accordingly.
+	(_bfd_mips_elf_finish_dynamic_symbol): Use
+	mips_elf_primary_global_got_index rather than
+	mips_elf_global_got_index.
+	(_bfd_mips_vxworks_finish_dynamic_symbol): Likewise.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_got_entry): Update comments.
+	(mips_elf_multi_got_entry_eq): Rename to...
+	(mips_elf_got_entry_eq): ...this, deleting the old definition.
+	(mips_elf_create_got_info): Remove master_got_p argument.
+	Always use mips_elf_got_entry_eq.
+	(mips_elf_bfd_got, mips_elf_multi_got, mips_elf_create_got_section):
+	Update calls accordingly.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_got_info): Remove bfd2got.
+	(mips_elf_bfd2got_hash): Delete.
+	(mips_elf_got_per_bfd_arg): Remove bfd2got.
+	(mips_elf_replace_bfd_got, mips_elf_count_got_entries): New functions.
+	(mips_elf_global_got_index, mips_elf_create_local_got_entry): Use
+	g->next to test for the multigot case.  Use mips_elf_bfd_got rather
+	than mips_elf_got_for_ibfd.
+	(mips_elf_bfd2got_entry_hash, mips_elf_bfd2got_entry_eq)
+	(mips_elf_got_for_ibfd, mips_elf_get_got_for_bfd): Delete.
+	(mips_elf_make_got_per_bfd): Replace with...
+	(mips_elf_add_got_entry): ...this new function.
+	(mips_elf_make_got_pages_per_bfd): Replace with...
+	(mips_elf_add_got_page_entry): ...this new function.
+	(mips_elf_merge_got_with): Replace bfd2got argument with separate
+	bfd and GOT arguments.  Use mips_elf_add_got_entry and
+	mips_elf_add_got_page_entry instead of mips_elf_make_got_per_bfd
+	and mips_elf_make_got_pages_per_bfd.  Use mips_elf_replace_bfd_got
+	to set the BFD's GOT and free the old table.
+	(mips_elf_merge_got): Replace bfd2got argument with separate
+	bfd and GOT arguments.  Apply mips_elf_resolve_final_got_entries.
+	Use mips_elf_count_got_entries to count the number of entries in
+	each GOT.  Update the calls to mips_elf_merge_got_with.
+	(mips_elf_adjust_gp): Use g->next to test for the multigot case.
+	Use mips_elf_bfd_got rather than mips_elf_got_for_ibfd.
+	(mips_elf_multi_got): Don't create the bfd2got hash table.
+	Replace hash table traversal with a walk over the input bfds,
+	updating the call to mips_elf_merge_got.  Use mips_elf_replace_bfd_got
+	to set the output bfd's GOT.
+	(mips_elf_lay_out_got): Rename "sub" to "ibfd".  Record that all
+	bfds use the master GOT in the single-GOT case.
+	(_bfd_mips_elf_finish_dynamic_sections): Use mips_elf_bfd_got
+	rather than mips_elf_got_for_ibfd.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_obj_tdata): Add a got field.
+	(mips_elf_bfd_got, mips_elf_record_got_entry): New functions.
+	(mips_elf_record_global_got_symbol): Update the hash entry before
+	adding the mips_got_entry.  Use mips_elf_record_got_entry to do
+	the latter.
+	(mips_elf_record_local_got_symbol): Use mips_elf_record_got_entry.
+	(mips_elf_record_got_page_entry): Record the entry in both the
+	master and bfd GOTs.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_recreate_got): Don't change the entry;
+	create another one if necessary.
+	(mips_elf_set_gotidx): New function.
+	(mips_elf_set_global_gotidx): Use it.
+	(mips_elf_initialize_tls_index): Likewise.  Take a
+	mips_elf_traverse_got_arg as argument.
+	(mips_elf_lay_out_got): Update use of mips_elf_initialize_tls_index.
+	(mips_elf_multi_got): Likewise.  Cope with error returns from
+	mips_elf_set_global_gotidx.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_got_info): Add relocs field.
+	(mips_elf_set_global_got_offset_arg, mips_elf_count_tls_arg): Replace
+	with...
+	(mips_elf_traverse_got_arg): ...this new structure.
+	(mips_elf_count_local_tls_relocs): Delete.
+	(mips_elf_count_global_tls_relocs): Likewise.
+	(mips_elf_count_got_entry): New function.
+	(mips_elf_count_local_got_entries): Likewise.
+	(mips_elf_count_global_tls_entries): Take a mips_elf_traverse_got_arg
+	rather than a mips_elf_count_tls_arg.  Count both relocs and entries.
+	(mips_elf_record_local_got_symbol): Don't count got entries here.
+	(mips_elf_make_got_per_bfd): Use mips_elf_count_got_entry.
+	(mips_elf_set_global_got_offset): Split into...
+	(mips_elf_set_global_got_area, mips_elf_set_global_gotidx): ...these
+	new functions.  Take a mips_elf_traverse_got_arg rather than a
+	mips_elf_set_global_got_offset_arg.  Don't count TLS relocs here.
+	Use g->relocs to record the number of relocs needed for global GOT
+	entries.
+	(mips_elf_multi_got): Use mips_elf_traverse_got_arg rather than
+	mips_elf_set_global_got_offset_arg.  Use the relocs field to count
+	relocations.  Update for above function split.
+	(mips_elf_lay_out_got): Use mips_elf_count_local_got_entries
+	to count both the number of GOT entries and the number of TLS
+	relocs required by local entries.  Likewise
+	mips_elf_count_global_tls_entries and global entries.
+	Remove uses of mips_elf_count_local_tls_relocs and
+	mips_elf_count_global_tls_relocs.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_got_entry): Update comment above tls_type entry
+	to say that each structure represents only one type of TLS reference.
+	(GOT_TLS_TYPE): New define.
+	(mips_elf_link_hash_entry): Temporarily split tls_type and
+	tls_got_offset into two variables each.
+	(mips_elf_link_hash_newfunc): Update accordingly.
+	(mips_elf_got_entry_eq, mips_elf_got_entry_hash)
+	(mips_elf_multi_got_entry_eq): Require the tls_type to be the same.
+	(mips_elf_reloc_tls_type, mips_tls_got_entries): New functions.
+	(mips_tls_got_relocs): Use a switch statement.
+	(mips_elf_count_global_tls_entries): Handle the new hash entry fields.
+	(mips_elf_initialize_tls_slots): Use a switch statement.  Avoid
+	local "offset" variable.
+	(mips_tls_got_index): Remove r_type argument and assert.  Remove
+	code that handled entries with two TLS types; always use the
+	original got_index instead.
+	(mips_tls_single_got_index): New function.
+	(mips_elf_local_got_index): Use entry->tls_type to check for
+	TLS entries.  Use mips_tls_single_got_index.  Update call to
+	mips_tls_got_index.
+	(mips_elf_global_got_index): Use mips_elf_reloc_tls_type.
+	Use p->tls_type to check for TLS entries.  Update call to
+	mips_tls_got_index.  Use mips_tls_single_got_index.
+	(mips_elf_create_local_got_entry): Use mips_elf_reloc_tls_type.
+	Use entry.tls_type to check for TLS entries.
+	(mips_elf_record_global_got_symbol): Replace tls_flag argument
+	with r_type argument.  Use mips_elf_reloc_tls_type.
+	Set up the new hash entry fields.
+	(mips_elf_record_local_got_symbol): Replace tls_flag argument
+	with r_type argument.  Use mips_elf_reloc_tls_type and
+	mips_tls_got_entries.  Remove code that handled entries
+	with multiple TLS types.
+	(mips_elf_make_got_per_bfd): Use mips_tls_got_entries.
+	(mips_elf_initialize_tls_index): Handle new hash entry fields.
+	Use equality rather than masks when checking for specific TLS types.
+	Use mips_tls_got_entries.  Remove code that handled entries
+	with multiple TLS types.
+	(mips_elf_calculate_relocation): Use TLS_RELOC_P instead of
+	testing the hash table entry.
+	(_bfd_mips_elf_check_relocs): Update calls to
+	mips_elf_record_global_got_symbol and mips_elf_record_local_got_symbol.
+	(_bfd_mips_elf_finish_dynamic_symbol): Don't check h->type.
+	(_bfd_mips_elf_copy_indirect_symbol): Handle new hash entry fields.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_multi_got_entry_hash): Rename to...
+	(mips_elf_got_entry_hash): ...this, deleting the old version.
+	(mips_elf_create_got_info): Use mips_elf_got_entry_hash for
+	both types of GOT.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_create_got_info): New function.
+	(mips_elf_get_got_for_bfd, mips_elf_multi_got): Use it.
+	(mips_elf_create_got_section): Likewise.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_record_local_got_symbol): Always set
+	gotidx to -1.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_multi_got): Simplify size calculation.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_got_info): Move global_gotsym to...
+	(mips_elf_link_hash_table): ...here.  Update rest of file accordingly.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_count_global_tls_entries)
+	(mips_elf_count_global_tls_relocs): Don't count indirect or
+	warning symbols.
+	(mips_elf_multi_got, mips_elf_lay_out_got): Assert that the right
+	number of TLS entries were allocated.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_sort_hash_table_f): Remove asserts.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_merge_got_with): Only use arg->global_count
+	if there are TLS relocations.
+
+2013-02-11  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_recreate_got): Remove free.
+	(mips_elf_resolve_final_got_entries): Remove bogus comment.
+
+2013-02-11  Alan Modra  <[email protected]>
+
+	* elfcode.h (elf_checksum_contents): Free contents.
+	* elf-bfd.h (_bfd_elf_link_hash_table_free): Declare.
+	* elflink.c (_bfd_elf_link_hash_table_free): New function.
+	(elf_final_link_free): New function, extracted from..
+	(bfd_elf_final_link): ..here.  Always call
+	_bfd_elf_write_section_eh_frame_hdr.
+	* elfxx-target.h (bfd_elfNN_bfd_link_hash_table_free): Default to
+	_bfd_elf_link_hash_table_free.
+	* libbfd-in.h (_bfd_merge_sections_free): Declare.
+	* libbfd.h: Regenerate.
+	* merge.c (_bfd_merge_sections_free): New function.
+	* elf-eh-frame.c (_bfd_elf_write_section_eh_frame_hdr): Free
+	hdr_info->array.
+	* elf-m10300.c (elf32_mn10300_link_hash_table_free): Call
+	_bfd_elf_link_hash_table_free.
+	* elf32-arm.c (elf32_arm_link_hash_table_free): Likewise.
+	* elf32-avr.c (elf32_avr_link_hash_table_free): Likewise.
+	* elf32-hppa.c (elf32_hppa_link_hash_table_free): Likewise.
+	* elf32-i386.c (elf_i386_link_hash_table_free): Likewise.
+	* elf32-m68hc1x.c (m68hc11_elf_hash_table_free): Likewise.
+	* elf32-m68k.c (elf_m68k_link_hash_table_free): Likewise.
+	* elf32-metag.c (elf_metag_link_hash_table_free): Likewise.
+	* elf32-xgate.c (xgate_elf_bfd_link_hash_table_free): Likewise.
+	* elf64-aarch64.c (elf64_aarch64_link_hash_table_free): Likewise.
+	* elf64-ia64-vms.c (elf64_ia64_hash_table_free): Likewise.
+	* elf64-ppc.c (ppc64_elf_link_hash_table_free): Likewise.
+	* elf64-x86-64.c (elf_x86_64_link_hash_table_free): Likewise.
+	* elfnn-ia64.c (elfNN_ia64_hash_table_free): Likewise.
+	* elf32-cr16.c (elf32_cr16_link_hash_table_free): Delete.
+	(bfd_elf32_bfd_link_hash_table_free): Don't define.
+	* elf32-tic6x.c (elf32_tic6x_link_hash_table_free): Delete.
+	(bfd_elf32_bfd_link_hash_table_free): Dont' define.
+
+2013-02-10  Alan Modra  <[email protected]>
+
+	* coff-arm.c (coff_arm_link_hash_table_create): Use bfd_zmalloc.
+	* coff-h8300.c (h8300_coff_link_hash_table_create): Likewise.
+	* m68klinux.c (linux_link_hash_table_create): Likewise.
+	* sparclinux.c (linux_link_hash_table_create): Likewise.
+	* sunos.c (sunos_link_hash_table_create): Likewise.
+	* xcofflink.c (_bfd_xcoff_bfd_link_hash_table_create): Likewise.
+	* elf-m10300.c (elf32_mn10300_link_hash_table_create): Likewise.
+	* elf32-arm.c (elf32_arm_link_hash_table_create): Likewise.
+	* elf32-avr.c (elf32_avr_link_hash_table_create): Likewise.
+	* elf32-cr16.c (elf32_cr16_link_hash_table_create): Likewise.
+	* elf32-cris.c (elf_cris_link_hash_table_create): Likewise.
+	* elf32-hppa.c (elf32_hppa_link_hash_table_create): Likewise.
+	* elf32-i386.c (elf_i386_link_hash_table_create): Likewise.
+	* elf32-lm32.c (lm32_elf_link_hash_table_create): Likewise.
+	* elf32-m32r.c (m32r_elf_link_hash_table_create): Likewise.
+	* elf32-m68hc1x.c (m68hc11_elf_hash_table_create): Likewise.
+	* elf32-m68k.c (elf_m68k_link_hash_table_create): Likewise.
+	* elf32-metag.c (elf_metag_link_hash_table_create): Likewise.
+	* elf32-nios2.c (nios2_elf32_link_hash_table_create): Likewise.
+	* elf32-s390.c (elf_s390_link_hash_table_create): Likewise.
+	* elf32-score.c (elf32_score_link_hash_table_create): Likewise.
+	* elf32-spu.c (spu_elf_link_hash_table_create): Likewise.
+	* elf32-tic6x.c (elf32_tic6x_link_hash_table_create): Likewise.
+	* elf32-vax.c (elf_vax_link_hash_table_create): Likewise.
+	* elf32-xgate.c (xgate_elf_bfd_link_hash_table_create): Likewise.
+	* elf32-xtensa.c (elf_xtensa_link_hash_table_create): Likewise.
+	* elf64-aarch64.c (elf64_aarch64_link_hash_table_create): Likewise.
+	* elf64-s390.c (elf_s390_link_hash_table_create): Likewise.
+	* elf64-sh64.c (sh64_elf64_link_hash_table_create): Likewise.
+	* elf64-x86-64.c (elf_x86_64_link_hash_table_create): Likewise.
+	* elfxx-mips.c (_bfd_mips_elf_link_hash_table_create): Likewise.
+	* elflink.c (_bfd_elf_link_hash_table_create): Likewise.
+	(_bfd_elf_link_hash_table_init): Assume zero fill table on entry.
+
+2013-02-10  Alan Modra  <[email protected]>
+
+	* i386linux.c (linux_link_hash_table_create): Allocate table
+	with bfd_zmalloc, not bfd_alloc.
+	* pdp11.c (link_hash_table_create): Allocate table with
+	bfd_malloc, not bfd_alloc.
+	* elf32-bfin.c (bfinfdpic_elf_link_hash_table_create): Allocate table
+	with bfd_zmalloc, not bfd_zalloc.
+	(bfin_link_hash_table_create): Likewise.
+	* elf32-frv.c (frvfdpic_elf_link_hash_table_create): Likewise.
+	* elf64-hppa.c (elf64_hppa_hash_table_create): Likewise.
+
+2013-02-10  Alan Modra  <[email protected]>
+
+	PR ld/15113
+	* elf32-sh.c (sh_elf_link_hash_table_create): Use bfd_zmalloc.
+
+2013-02-08  Markos Chandras  <[email protected]>
+
+	* elf32-metag.c: Use bfd_get_linker_section to get SEC_LINKER_CREATED
+	sections.
+	(elf_metag_adjust_dynamic_symbol): Don't error on zero size dynbss
+	symbol.
+
+2013-02-08  Yufeng Zhang  <[email protected]>
+
+	* elf64-aarch64.c (elf64_aarch64_grok_prstatus): Change 'size' from
+	288 to 272.
+
+2013-02-08  Alan Modra  <[email protected]>
+
+	PR binutils/15106
+	* elf-bfd.h (struct elf_obj_tdata): Add elf_find_function_cache.
+	* elf.c (elf_find_function): Revert last change.  Use new
+	tdata field rather than static vars for cache.
+
+2013-02-07  H.J. Lu  <[email protected]>
+
+	PR ld/15107
+	* elflink.c (elf_link_output_extsym): Set STB_GNU_UNIQUE only if
+	symbol is defined in regular object.
+
+2013-02-07  Roberto Agostino Vitillo  <[email protected]>
+
+	PR binutils/15106
+	* elf.c (elf_find_function): Don't cache if symbols change.
+
+2013-02-07  Alan Modra  <[email protected]>
+
+	PR binutils/14873
+	* elf-attrs.c (_bfd_elf_copy_obj_attributes): Don't attempt to
+	copy attributes from or to non-ELF.
+
+2013-02-06  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_allocate_dynrelocs): Don't clear pc_count
+	for non-zero TLS symbol.
+	(elf_i386_relocate_section): Don't resolve size relocation against
+	non-zero TLS symbol.
+	* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): Don't clear
+	pc_count for non-zero TLS symbol.
+	(elf_x86_64_relocate_section): Don't resolve size relocation
+	against non-zero TLS symbol.
+
+2013-02-06  Sandra Loosemore  <[email protected]>
+	    Andrew Jenner <[email protected]>
+
+	Based on patches from Altera Corporation.
+
+	* Makefile.am (ALL_MACHINES): Add cpu-nios2.lo.
+	(ALL_MACHINES_CFILES): Add cpu-nios2.c.
+	(BFD_BACKENDS): Add elf32-nios2.lo.
+	(BFD32_BACKENDS_CFILES): Add elf32-nios2.c.
+	* Makefile.in: Regenerated.
+	* configure.in: Add entries for bfd_elf32_bignios2_vec and
+	bfd_elf32_littlenios2_vec.
+	* configure: Regenerated.
+	* config.bfd: Add cases for nios2.
+	* archures.c (enum bfd_architecture): Add bfd_arch_nios2.
+	(bfd_mach_nios2): Define.
+	(bfd_nios2_arch): Declare.
+	(bfd_archures_list): Add bfd_nios2_arch.
+	* targets.c (bfd_elf32_bignios2_vec): Declare.
+	(bfd_elf32_littlenios2_vec): Declare.
+	(_bfd_target_vector): Add entries for bfd_elf32_bignios2_vec and
+	bfd_elf32_littlenios2_vec.
+	* elf-bfd.h (enum elf_target_id): Add NIOS2_ELF_DATA.
+	* reloc.c (enum bfd_reloc_code_real): Add Nios II relocations.
+	* bfd-in2.h: Regenerated.
+	* libbfd.h: Regenerated.
+	* cpu-nios2.c: New file.
+	* elf32-nios2.c: New file.
+
+2013-02-06  Alan Modra  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_final_link_relocate): Only test for
+	stubs in stub_bfd.
+
+2013-02-06  Alan Modra  <[email protected]>
+
+	* Makefile.am (SOURCE_HFILES): Add `elf-linux-psinfo.h'.
+	* Makefile.in: Regenerate.
+
+2013-02-04  Sergio Durigan Junior  <[email protected]>
+	    Pedro Alves  <[email protected]>
+
+	* Makefile.in (SOURCE_HFILES): Add `elf-linux-psinfo.h'.
+	* elf-bfd.h (elf_internal_linux_prpsinfo): New structure
+	declaration.
+	(elfcore_write_linux_prpsinfo32, elfcore_write_linux_prpsinfo64)
+	(elfcore_write_ppc32_linux_prpsinfo32): New declarations.
+	* elf-linux-psinfo.h: New file.
+	* elf.c: Include elf-linux-psinfo.h.
+	(elfcore_write_linux_prpsinfo32, elfcore_write_linux_prpsinfo64):
+	New functions.
+	* elf32-ppc.c: Include `elf-linux-psinfo.h'.
+	(elf_external_ppc_linux_prpsinfo32): New structure declaration.
+	(PPC_LINUX_PRPSINFO32_SWAP_FIELDS): New macro.
+	(elfcore_write_ppc_linux_prpsinfo32): New function.
+
+2013-02-04  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_scan_start_address): Do not fail if no
+	start address.
+
+2013-02-04  Alan Modra  <[email protected]>
+
+	* Makefile.am (BFD64_BACKENDS): Remove elf-nacl.lo.
+	(BFD64_BACKENDS_CFILES): Remove elf-nacl.c.
+	* Makefile.in: Regenerate.
+	* po/SRC-POTFILES.in: Regenerate.
+
+2013-02-04  Alan Modra  <[email protected]>
+
+	* coff-tic54x.c (SWAP_OUT_RELOC_EXTRA): Delete.
+	* coff-tic80.c (SWAP_OUT_RELOC_EXTRA): Delete.
+
+2013-02-01  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (dec_dynrel_count): Don't error when elf_gc_sweep_symbol
+	clears def_regular.
+
+2013-01-31  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_scan): Call bfd_mach_o_flatten_sections
+	earlier.  Fix status checking of bfd_mach_o_scan_start_address.
+	(bfd_mach_o_scan_start_address): Handle LC_MAIN.
+
+2013-01-31  Alan Modra  <[email protected]>
+	    David S. Miller  <[email protected]>
+
+	PR ld/15056
+	* elfxx-sparc.c (_bfd_sparc_elf_gc_mark_hook): Handle implicit
+	references to __tls_get_addr.
+	* elf32-tilpro.c (tilepro_elf_gc_mark_hook): Likewise.  Correct
+	vtinherit and vtentry reloc handling too.
+	* elfxx-tilegx.c (tilegx_elf_gc_mark_hook): As for tilepro.
+
+2013-01-31  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (ppc_stub_name): Trim off trailing "+0".
+
+2013-01-31  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (build_plt_stub): Correct plt stub branch to glink.
+
+2013-01-28  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c: Use %T to print symbols names and remove redundant
+	"relocation" in error messages throughout file.
+	(ppc64_elf_relocate_section): Remove sibling call error message,
+	replace with "call lacks nop".  Specially report errors for
+	branches to function entry points via OPD lookup and branches
+	to stubs.  Remove NULL symbol handling now done by %T.
+
+2013-01-28  Alan Modra  <[email protected]>
+
+	* archive.c (bfd_generic_archive_p): Return target and keep
+	ardata on partial matches.
+	* format.c (bfd_check_format_matches): Adjust for above
+	change.  Remove bfd_error_file_ambiguously_recognized dead
+	code.
+
+2013-01-26  Alan Modra  <[email protected]>
+
+	* bfd.c (struct bfd_preserve, bfd_preserve_save, bfd_preserve_restore,
+	bfd_preserve_finish): Move to..
+	* format.c: ..here, splitting out..
+	(bfd_reinit): ..this.  New function.
+	(bfd_check_format_matches): Use bfd_preserve_save/restore to
+	keep bfd state for a match.
+	* elfcode.h (elf_object_p): Don't use bfd_preserve_save/restore.
+	* elfcore.h (elf_core_file_p): Likewise.
+	* mach-o.c (bfd_mach_o_header_p): Likewise.
+	* pef.c (bfd_pef_object_p, bfd_pef_xlib_object_p): Likewise.
+	* xsym.c (bfd_sym_object_p): Likewise.
+	* mmo.c (mmo_scan): Clear abfd->symcount.
+	* opncls.c (_bfd_new_bfd): Use a smaller section hash table.
+	* section.c (bfd_section_list_clear): Clear section_htab.count.
+	* bfd-in2.h: Regenerate.
+
+2013-01-25  Michael Schewe  <[email protected]>
+
+	* elf32-h8300.c (elf32_h8_relax_section): When checking for a
+	second reloc, make sure that the reloc potentially exists first.
+
+2013-01-24  Nick Clifton  <[email protected]>
+
+	* archures.c: Add bfd_mach_v850e3v5.
+	* bfd-in2.h: Regenerate.
+	* cpu-v850.c: Add entries for v850e2v5 and v850e3v5.
+	* cpu-v850_rh850.c: Likewise.
+	* elf32-v850.c: Add support for v850e3v5 architecture.
+
+2013-01-23  Markos Chandras  <[email protected]>
+
+	* elf32-metag.c: Error on HIADDR16/LOADDR16 in shared link.
+
+2013-01-23  Leif Ekblad  <[email protected]>
+
+	* config.bfd (x86_64-*-rdos*): Remove targ_selvecs.
+
+2013-01-18  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_allocate_dynrelocs): Clear pc_count for
+	non-zero TLS symbol.
+	(elf_i386_relocate_section): Resolve size relocation against
+	non-zero TLS symbol.
+	* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): Clear pc_count
+	for non-zero TLS symbol.
+	(elf_x86_64_relocate_section): Resolve size relocation against
+	non-zero TLS symbol.
+
+2013-01-18  Mike Frysinger  <[email protected]>
+
+	* elflink.c (bfd_elf_size_dynamic_sections): Only add DT_RPATH
+	when new_dtags is false.  Only add DT_RUNPATH when new_dtags is
+	true.
+
+2013-01-17  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_check_relocs): Count size relocation as
+	PC-relative relocation.
+	* elf64-x86-64.c (elf_x86_64_check_relocs): Count size relocation
+	as PC-relative relocation.
+
+2013-01-16  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_check_relocs): Update R_386_SIZE32
+	check.
+	(elf_i386_relocate_section): Don't check TLS for R_386_SIZE32.
+
+	* elf64-x86-64.c (elf_x86_64_check_relocs): Update R_X86_64_SIZE32
+	and R_X86_64_SIZE64 check.
+	(elf_x86_64_relocate_section): Don't check TLS for R_X86_64_SIZE32
+	nor R_X86_64_SIZE64.
+
+2013-01-16  H.J. Lu  <[email protected]>
+
+	* bfd-in2.h: Regenerated.
+	* libbfd.h: Likewise.
+
+	* elf32-i386.c (elf_howto_table): Fill R_386_SIZE32 entry.
+	(elf_i386_reloc_type_lookup): Support BFD_RELOC_SIZE32.
+	(elf_i386_check_relocs): Handle R_386_SIZE32.
+	(elf_i386_gc_sweep_hook): Likewise.
+	(elf_i386_relocate_section): Likewise.
+
+	* elf64-x86-64.c (x86_64_elf_howto_table): Fill R_X86_64_SIZE32
+	and R_X86_64_SIZE64 entries.
+	(x86_64_reloc_map): Add BFD_RELOC_SIZE32 and BFD_RELOC_SIZE64,
+	(elf_x86_64_rtype_to_howto): Handle R_X86_64_SIZE32 for x32.
+	(elf_x86_64_reloc_name_lookup): Likewise.
+	(elf_x86_64_check_relocs): Handle R_X86_64_SIZE32 and
+	R_X86_64_SIZE64.
+	(elf_x86_64_gc_sweep_hook): Likewise.
+	(elf_x86_64_relocate_section): Likewise.
+
+	* reloc.c (bfd_reloc_code_type): Add BFD_RELOC_SIZE32 and
+	BFD_RELOC_SIZE64.
+
+2013-01-15  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (R_X86_64_standard): Replace R_X86_64_IRELATIVE
+	with R_X86_64_RELATIVE64.
+
+2013-01-15  Nick Clifton  <[email protected]>
+
+	* elf32-msp430.c: Fix spelling typo.
+
+2013-01-15  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (ppc64_elf_size_stubs): Default shared libs to
+	plt-thread-safe.
+
+2013-01-14  Alan Modra  <[email protected]>
+
+	PR binutils/14813
+	* bfdio.c (struct bfd_iovec <bclose>): Revert 2012-11-06.
+	(memory_bclose): Likewise.  Return 0 on success.
+	* cache.c (cache_bclose): Likewise.
+	* opncls.c (opncls_bclose, bfd_close): Likewise.
+	* vms-lib.c (vms_lib_bclose): Likewise.
+	* libbfd.h: Regenerate.
+
+2013-01-13  Alan Modra  <[email protected]>
+
+	* elf-bfd.h (struct elf_link_hash_entry): Delete dynamic_weak.
+	Add ref_dynamic_nonweak.
+	* elflink.c (_bfd_elf_mark_dynamic_def_weak): Delete.
+	(_bfd_elf_merge_symbol): Don't call above function.  Move
+	setting of ref_dynamic_nonweak and dynamic_def earlier.  Don't
+	clear dynamic_def.
+	(elf_link_add_object_symbols): Delete redundant "override" test.
+	Don't set dynamic_def here.
+	(elf_link_output_extsym): Update.
+
+2013-01-12  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_check_relocs): Set bfd errror for
+	normal and TLS symbol access.
+	* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
+
+2013-01-12  Alan Modra  <[email protected]>
+
+	* elf-bfd.h (_bfd_elf_strtab_refcount): Declare.
+	* elf-strtab.c (_bfd_elf_strtab_refcount): New function.
+	* elflink.c (elf_add_dt_needed_tag): Use _bfd_elf_strtab_refcount.
+
+2013-01-12  Alan Modra  <[email protected]>
+
+	PR ld/12549
+	* elf-bfd.h (_bfd_elf_strtab_clear_refs): Declare.
+	(_bfd_elf_strtab_clear_all_refs): Define.
+	* elf-strtab.c (_bfd_elf_strtab_clear_refs): New function.
+	(_bfd_elf_strtab_clear_all_refs): Delete.
+	* elflink.c (elf_link_add_object_symbols): Clear out added
+	strtab refs.  Correct handling of warning common symbols.
+
+2013-01-10  H.J. Lu  <[email protected]>
+
+	* aout0.c: Remove trailing white spaces.
+	* archive.c: Likewise.
+	* archures.c: Likewise.
+	* bfd-in.h: Likewise.
+	* bfd-in2.h: Likewise.
+	* coff-alpha.c: Likewise.
+	* coff-i860.c: Likewise.
+	* coff-mips.c: Likewise.
+	* coff-ppc.c: Likewise.
+	* coff-tic80.c: Likewise.
+	* coff-x86_64.c: Likewise.
+	* coff-z80.c: Likewise.
+	* coffcode.h: Likewise.
+	* coffgen.c: Likewise.
+	* cofflink.c: Likewise.
+	* compress.c: Likewise.
+	* corefile.c: Likewise.
+	* cpu-arm.c: Likewise.
+	* cpu-avr.c: Likewise.
+	* cpu-bfin.c: Likewise.
+	* cpu-cr16.c: Likewise.
+	* cpu-cr16c.c: Likewise.
+	* cpu-crx.c: Likewise.
+	* cpu-h8300.c: Likewise.
+	* cpu-i386.c: Likewise.
+	* cpu-lm32.c: Likewise.
+	* cpu-m68k.c: Likewise.
+	* cpu-moxie.c: Likewise.
+	* cpu-msp430.c: Likewise.
+	* cpu-sh.c: Likewise.
+	* cpu-xc16x.c: Likewise.
+	* dwarf2.c: Likewise.
+	* ecofflink.c: Likewise.
+	* ecoffswap.h: Likewise.
+	* elf-ifunc.c: Likewise.
+	* elf-m10300.c: Likewise.
+	* elf-vxworks.c: Likewise.
+	* elf32-avr.c: Likewise.
+	* elf32-avr.h: Likewise.
+	* elf32-cr16.c: Likewise.
+	* elf32-cr16c.c: Likewise.
+	* elf32-cris.c: Likewise.
+	* elf32-crx.c: Likewise.
+	* elf32-frv.c: Likewise.
+	* elf32-hppa.c: Likewise.
+	* elf32-i860.c: Likewise.
+	* elf32-ip2k.c: Likewise.
+	* elf32-iq2000.c: Likewise.
+	* elf32-m32c.c: Likewise.
+	* elf32-m68hc1x.c: Likewise.
+	* elf32-msp430.c: Likewise.
+	* elf32-mt.c: Likewise.
+	* elf32-ppc.c: Likewise.
+	* elf32-rl78.c: Likewise.
+	* elf32-s390.c: Likewise.
+	* elf32-score.h: Likewise.
+	* elf32-sh-symbian.c: Likewise.
+	* elf32-sh.c: Likewise.
+	* elf32-spu.c: Likewise.
+	* elf32-tic6x.c: Likewise.
+	* elf32-v850.c: Likewise.
+	* elf32-xc16x.c: Likewise.
+	* elf32-xtensa.c: Likewise.
+	* elf64-alpha.c: Likewise.
+	* elf64-hppa.c: Likewise.
+	* elf64-ppc.c: Likewise.
+	* elf64-s390.c: Likewise.
+	* elfcore.h: Likewise.
+	* elflink.c: Likewise.
+	* elfxx-mips.c: Likewise.
+	* elfxx-sparc.c: Likewise.
+	* elfxx-tilegx.c: Likewise.
+	* ieee.c: Likewise.
+	* libcoff.h: Likewise.
+	* libpei.h: Likewise.
+	* libxcoff.h: Likewise.
+	* linker.c: Likewise.
+	* mach-o-i386.c: Likewise.
+	* mach-o-target.c: Likewise.
+	* mach-o.c: Likewise.
+	* mach-o.h: Likewise.
+	* mmo.c: Likewise.
+	* opncls.c: Likewise.
+	* pdp11.c: Likewise.
+	* pe-x86_64.c: Likewise.
+	* peXXigen.c: Likewise.
+	* pef-traceback.h: Likewise.
+	* pei-x86_64.c: Likewise.
+	* peicode.h: Likewise.
+	* plugin.c: Likewise.
+	* reloc.c: Likewise.
+	* riscix.c: Likewise.
+	* section.c: Likewise.
+	* som.c: Likewise.
+	* syms.c: Likewise.
+	* tekhex.c: Likewise.
+	* ticoff.h: Likewise.
+	* vaxbsd.c: Likewise.
+	* xcofflink.c: Likewise.
+	* xtensa-isa.c: Likewise.
+
+2013-01-10  Will Newton <[email protected]>
+
+	* Makefile.am: Add Meta.
+	* Makefile.in: Regenerate.
+	* archures.c (bfd_mach_metag): New.
+	* bfd-in2.h: Regenerate.
+	* config.bfd: Add Meta.
+	* configure: Regenerate.
+	* configure.in: Add Meta.
+	* cpu-metag.c: New file.
+	* elf-bfd.h: Add Meta.
+	* elf32-metag.c: New file.
+	* elf32-metag.h: New file.
+	* libbfd.h: Regenerate.
+	* reloc.c: Add Meta relocations.
+	* targets.c: Add Meta.
+
+2013-01-08  Yufeng Zhang  <[email protected]>
+
+	* elf-bfd.h (elfcore_write_aarch_tls): Add prototype.
+	(elfcore_write_aarch_hw_break): Likewise.
+	(elfcore_write_aarch_hw_watch): Likewise.
+	* elf.c (elfcore_grok_aarch_tls): New function.
+	(elfcore_grok_aarch_hw_break): Likewise.
+	(elfcore_grok_aarch_hw_watch): Likewise.
+	(elfcore_grok_note): Call the new functions to handle the
+	corresponding notes.
+	(elfcore_write_aarch_tls): New function.
+	(elfcore_write_aarch_hw_break): Likewise.
+	(elfcore_write_aarch_hw_watch): Likewise.
+	(elfcore_write_register_note): Call the new functions to handle the
+	corresponding pseudo sections.
+
+2013-01-07  Tom Tromey  <[email protected]>
+
+	* section.c (_bfd_std_section): Rename from std_section.
+	(bfd_com_section_ptr, bfd_und_section_ptr, bfd_abs_section_ptr)
+	(STD_SECTION): Update.
+	* bfd-in2.h: Rebuild.
+
+2013-01-04  Juergen Urban <[email protected]>
+
+	* archures.c (bfd_mach_mips5900): Define.
+	* bfd-in2.h: Regenerate.
+	* config.bfd: Add mips64-ps2-elf and mips-ps2-elf targets.
+	* cpu-mips.c: Add support for MIPS r5900.
+	* elfxx-mips.c: Add support for MIPS r5900 (extension of r4000).
+
+2013-01-03  Nickolai Zeldovich  <[email protected]>
+	    Nick Clifton  <[email protected]>
+
+	* elflink.c (get_value): Prevent the use of an undefined shift
+	operation.  Add sanity checks.
+
+2013-01-02  Kaushik Phatak  <[email protected]>
+
+	* config.bfd (cr16*-*-uclinux*): New target support.
+
+
+For older changes see ChangeLog-2012
 
+Copyright (C) 2013 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
+
 Local Variables:
 mode: change-log
 left-margin: 8
diff --git a/bfd/ChangeLog-0001 b/bfd/ChangeLog-0001
index b5a3475..63015db 100644
--- a/bfd/ChangeLog-0001
+++ b/bfd/ChangeLog-0001
@@ -9584,6 +9584,12 @@
 
 For older changes see ChangeLog-9899
 
+Copyright (C) 2002 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
+
 Local Variables:
 mode: change-log
 left-margin: 8
diff --git a/bfd/ChangeLog-0203 b/bfd/ChangeLog-0203
index 1b1abb1..20b0e30 100644
--- a/bfd/ChangeLog-0203
+++ b/bfd/ChangeLog-0203
@@ -1303,7 +1303,7 @@
 	(elf32_hppa_check_relocs): Don't set SEC_HAS_GOT_REF flag.
 	(elf32_hppa_size_stubs): Pass info to hppa_type_of_stub.
 	(final_link_relocate): Change all DLTIND relocs to DPREL relocs in a
-	non-shared link.  Convert instructions that use the the linkage table
+	non-shared link.  Convert instructions that use the linkage table
 	pointer, or a facsimile thereof, to use the global data pointer when
 	the reloc has been changed.
 
@@ -11397,6 +11397,12 @@
 
 For older changes see ChangeLog-0001
 
+Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
+
 Local Variables:
 mode: change-log
 left-margin: 8
diff --git a/bfd/ChangeLog-2004 b/bfd/ChangeLog-2004
index 0c47096..09d816f 100644
--- a/bfd/ChangeLog-2004
+++ b/bfd/ChangeLog-2004
@@ -5055,6 +5055,12 @@
 
 For older changes see ChangeLog-0203
 
+Copyright (C) 2004 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
+
 Local Variables:
 mode: change-log
 left-margin: 8
diff --git a/bfd/ChangeLog-2005 b/bfd/ChangeLog-2005
index 95746fc..7c9b0d3 100644
--- a/bfd/ChangeLog-2005
+++ b/bfd/ChangeLog-2005
@@ -5261,6 +5261,12 @@
 
 For older changes see ChangeLog-2004
 
+Copyright (C) 2005 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
+
 Local Variables:
 mode: change-log
 left-margin: 8
diff --git a/bfd/ChangeLog-2006 b/bfd/ChangeLog-2006
index 82216d6..dc15581 100644
--- a/bfd/ChangeLog-2006
+++ b/bfd/ChangeLog-2006
@@ -30,7 +30,7 @@
 	EF_M68K_CPU32_FIDO_A.
 
 2006-12-25  Mei Ligang  <[email protected]>
-	
+
 	* elf32-score.c (score_elf_got_lo16_reloc): Change some variables
 	type from unsigned to signed.
 	(score_elf_final_link_relocate): Fix bugs of handling relocation
@@ -3593,6 +3593,12 @@
 
 For older changes see ChangeLog-2005
 
+Copyright (C) 2006 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
+
 Local Variables:
 mode: change-log
 left-margin: 8
diff --git a/bfd/ChangeLog-2007 b/bfd/ChangeLog-2007
index be94259..85076b9 100644
--- a/bfd/ChangeLog-2007
+++ b/bfd/ChangeLog-2007
@@ -23,7 +23,7 @@
 	* elf32-frv.c (_frvfdpic_osec_to_segment): Use new function.
 	* elf32-hppa.c (hppa_record_segment_addr): Use new function.
 	* elfxx-ia64.c (elfNN_ia64_relocate_section): Use new function.
-	
+
 2007-12-28  John David Anglin  <[email protected]>
 
 	PR binutils/5146
@@ -65,7 +65,7 @@
 
 	* elf32-xtensa.c (relax_section): Update DIFF relocations in the
 	same way as other relocations.
-	
+
 2007-12-18  Daniel Jacobowitz  <[email protected]>
 
 	* section.c (BFD_FAKE_SECTION): Update.
@@ -91,7 +91,7 @@
 	when clearing the removed flag.
 	(_bfd_elf_eh_frame_section_offset): Remove offsets_adjusted handling.
 	(_bfd_elf_write_section_eh_frame): Likewise.  Apply output_offsets
-	where appropriate.  
+	where appropriate.
 
 2007-12-15  Richard Sandiford  <[email protected]>
 
@@ -229,7 +229,7 @@
 	(elf_xtensa_relocate_section): Check for R_XTENSA_32_PCREL for dynamic
 	symbols.
 	(check_section_ebb_pcrels_fit): Ignore R_XTENSA_32_PCREL relocations.
-	
+
 2007-12-05  Alan Modra  <[email protected]>
 
 	* elf32-spu.c (spu_elf_size_stubs): Do consider branches to
@@ -262,7 +262,7 @@
 	and Loongson-2F flags.
 	(mips_set_isa_flags): Likewise.
 	(mips_mach_extensions): Add Loongson-2E and Loongson-2F
-	entries. 
+	entries.
 
 2007-11-29  Nick Clifton  <[email protected]>
 
@@ -491,7 +491,7 @@
 	* elf-m10300.h: Handle R_MN10300_ALIGN relocs.
 	(mn10300_elf_relax_delete_bytes): Honour R_MN10300_ALIGN relocs.
 	Re-fix off by one error in comparisons.
-  
+
 2007-10-25  Pedro Alves  <[email protected]>
 
 	* bfd-in.h (STRING_COMMA_LEN): Don't handle NULL STR case.
@@ -538,7 +538,7 @@
 	(mn10300_elf_check_relocs): Do not create dynamic relocs for
 	symbol differences or relocations against absolute symbols.
 	(mn10300_elf_final_link_relocate): Likewise.
-	Handle R_MN10300_SYM_DIFF relocs. 
+	Handle R_MN10300_SYM_DIFF relocs.
 	(mn10300_elf_relocate_section): Fix for creating local copys of
 	dynamic relocs.
 	(mn10300_elf_relax_delete_bytes): Adjust symbols at the end of the
@@ -575,23 +575,23 @@
 
 	* elf32-xtensa.c (relax_section): Check for a reference to a discarded
 	DWARF section and anticipate its replacement with the kept section.
-	
+
 2007-10-16  Bob Wilson  <[email protected]>
 
 	* elf32-xtensa.c (elf_xtensa_discard_info_for_section): Remove
 	unnecessary size variables.  Set sec->rawsize.
 	(relax_section, relax_property_section): Likewise.
-	
+
 2007-10-16  Bob Wilson  <[email protected]>
 
 	* section.c (struct bfd_section): Clarify comment for rawsize field.
 	* bfd-in2.h: Regenerate.
-	
+
 2007-10-16  Bob Wilson  <[email protected]>
 
 	* elflink.c (_bfd_elf_check_kept_section): Use the section rawsize
 	values if they are set.
-	
+
 2007-10-16  Nick Clifton  <[email protected]>
 
 	PR 5146
@@ -613,7 +613,7 @@
 	the type of emitted common symbols to STT_COMMON.
 	* elfcode.h (elf_slurp_symbol_table): Accept STT_COMMON symbol
 	types.
-	
+
 2007-10-15  Alan Modra  <[email protected]>
 
 	* coff-arm.c (arm_emit_base_file_entry): Check fwrite return value.
@@ -653,7 +653,7 @@
 	segment only when needed.
 
 2007-10-05  Bob Wilson  <[email protected]>
-	
+
 	* elf32-xtensa.c (relax_section): Call pin_internal_relocs when
 	changing a relocation's offset.  Adjust call to translate_reloc.  Do
 	not add a fix record for a DIFF reloc.  For other relocs, only add a
@@ -665,21 +665,21 @@
 	assertion.  Compute separate offset adjustments for the base symbol
 	and the addend, and set the new relocation's addend correctly.  Return
 	the new target section.
-	
+
 2007-10-05  Bob Wilson  <[email protected]>
-	
+
 	* elf32-xtensa.c (elf_xtensa_relocate_section): Remove updates of
 	r_type and howto after calling do_fix_for_relocateable_link and
 	do_fix_for_final_link.
-	
+
 2007-10-05  Bob Wilson  <[email protected]>
-	
+
 	* elf32-xtensa.c (removed_by_actions): New.
 	(offset_with_removed_text): Reimplement using removed_by_actions.
 	(offset_with_removed_text_before_fill): Delete.
 	(relax_property_section): Use removed_by_actions.  Rearrange logic.
 	(relax_section_symbols): Likewise.
-	
+
 2007-10-04  Bob Wilson  <[email protected]>
 
 	* elf32-xtensa.c (reloc_bfd_fix_struct): Delete target_abfd field.
@@ -860,7 +860,7 @@
 	* Makefile.in: Regenerate.
 	* arange-set.c: New file.
 	* arange-set.h: New file.
-	* dwarf2.c: Include arange-set.h.  
+	* dwarf2.c: Include arange-set.h.
 	(struct dwarf2_debug) Add new fields comp_unit_count and
 	comp_unit_arange_set.
 	(struct comp_unit) Replace field arange with a new field arange_set.
@@ -893,8 +893,8 @@
 
 2007-09-21  Olivier Hainque  <[email protected]>
 	    Tristan Gingold  <[email protected]>
-	
-	* syms.c (_bfd_stab_section_find_nearest_line): Look at the 
+
+	* syms.c (_bfd_stab_section_find_nearest_line): Look at the
         specific SOM sections for stabs if the regular ones are not found.
 	* som.h (struct somdata): Add a line_info field, to be used by
         som_find_nearest_line.
@@ -949,7 +949,7 @@
 	PT_GNU_RELRO segment for copying executable/shared library.
 	(rewrite_elf_program_header): Remove PT_GNU_RELRO segment.
 	(copy_elf_program_header): Set p_size and p_size_valid fields for
-	PT_GNU_RELRO segment. 
+	PT_GNU_RELRO segment.
 
 2007-09-17  Nick Clifton  <[email protected]>
 
@@ -1035,7 +1035,7 @@
 
 2007-09-04  Michael Snyder  <[email protected]>
 
-	* elf32-bfin.c (howto_table): Cut and paste error?  
+	* elf32-bfin.c (howto_table): Cut and paste error?
 	Name field of reloc is wrong.
 
 2007-09-04  Alan Modra  <[email protected]>
@@ -1319,7 +1319,7 @@
 	(elf32_arm_gc_sweep_hook): Call check_use_blx.  Update plt counts
 	for R_ARM_THM_JUMP24 and R_ARM_THM_JUMP19.
 	(elf32_arm_check_relocs): Update plt counts for R_ARM_THM_JUMP24
-	and R_ARM_THM_JUMP19.  
+	and R_ARM_THM_JUMP19.
 	(allocate_dynrelocs): Use plt_maybe_thumb_refcount.
 	(elf32_arm_finish_dynamic_symbol): Ditto.
 	(elf32_arm_output_plt_map): Ditto.
@@ -1412,7 +1412,7 @@
 
 	* coff-i386.c (coff_i386_rtype_to_howto): Guard against null.
 
-	* linker.c (bfd_section_already_linked_table_insert): Change 
+	* linker.c (bfd_section_already_linked_table_insert): Change
 	return type from void to boolean.  Return FALSE on failure.
 	(_bfd_generic_section_already_linked): Test return value of
 	bfd_section_already_linked_table_insert, call fatal on error.
@@ -1435,10 +1435,10 @@
 	* linker.c (already_linked_newfunc): Check for NULL return from
 	bfd_hash_allocate.
 
-	* coffgen.c (fixup_symbol_value): Guard against null; 
+	* coffgen.c (fixup_symbol_value): Guard against null;
 	bfd_is_com_section will dereference the section pointer.
 
-	* syms.c (bfd_decode_symclass): Guard against NULL, since 
+	* syms.c (bfd_decode_symclass): Guard against NULL, since
 	bfd_is_com_section dereferences the pointer.
 
 	* srec.c (srec_scan): Check for EOF (critical because return value
@@ -1452,7 +1452,7 @@
 
 	* tekhex.c (first_phase): Check return value for null.
 
-	* elf.c (_bfd_elf_get_synthetic_symtab): Remove meaningless 
+	* elf.c (_bfd_elf_get_synthetic_symtab): Remove meaningless
 	pointer increment.
 
 2007-07-26  Alan Modra  <[email protected]>
@@ -3553,6 +3553,12 @@
 
 For older changes see ChangeLog-2006
 
+Copyright (C) 2007 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
+
 Local Variables:
 mode: change-log
 left-margin: 8
diff --git a/bfd/ChangeLog-2008 b/bfd/ChangeLog-2008
index eb63e09..b61a790 100644
--- a/bfd/ChangeLog-2008
+++ b/bfd/ChangeLog-2008
@@ -22,7 +22,7 @@
 	PR ld/7036
 	* elfxx-ia64.c (elfNN_ia64_relax_section): Assume linker will
 	always insert 32byte between the .plt and .text sections after
-	the the first relaxation pass.
+	the first relaxation pass.
 
 2008-12-23  Nick Clifton  <[email protected]>
 
@@ -3378,6 +3378,12 @@
 
 For older changes see ChangeLog-2007
 
+Copyright (C) 2008 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
+
 Local Variables:
 mode: change-log
 left-margin: 8
diff --git a/bfd/ChangeLog-2009 b/bfd/ChangeLog-2009
index cc33261..a3f7b24 100644
--- a/bfd/ChangeLog-2009
+++ b/bfd/ChangeLog-2009
@@ -408,7 +408,8 @@
 	PR binutils/10802
 	* opncls.c (_maybe_make_executable): Make DYNAMIC files executable.
 
-2009-10-19  Hans-Peter Nilsson  <[email protected]>
+2009-10-19  Edgar E. Iglesias  <[email protected]>
+	    Hans-Peter Nilsson  <[email protected]>
 
 	* elf32-cris.c (cris_elf_relocate_section) <case R_CRIS_32_DTPREL>:
 	Don't subtract the size of the TLS block for non-shared objects
@@ -3606,7 +3607,7 @@
 	(bfd_xcoff_set_archive_import_path): Likewise.
 	(xcoff_set_import_path): Move earlier in file.
 	(xcoff_link_add_dynamic_symbols): Set the import path of a non-archive
-	object to the the directory part of the bfd's filename.  Get the
+	object to the directory part of the bfd's filename.  Get the
 	import path and filename of an archive object from the archive's
 	xcoff_tdata, initializing it if necessary.  Update use of
 	import_file_id.
@@ -5146,6 +5147,12 @@
 
 For older changes see ChangeLog-2008
 
+Copyright (C) 2009 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
+
 Local Variables:
 mode: change-log
 left-margin: 8
diff --git a/bfd/ChangeLog-2010 b/bfd/ChangeLog-2010
index c486f58..4dd4cb1 100644
--- a/bfd/ChangeLog-2010
+++ b/bfd/ChangeLog-2010
@@ -1173,11 +1173,11 @@
 
 	* elf64-x86-64.c (elf64_x86_64_grok_prstatus): Write the LWPID to
 	elf_tdata's core_lwpid instead of to core_pid.
-	(elf64_x86_64_grok_psinfo): Extract the the main process's PID,
+	(elf64_x86_64_grok_psinfo): Extract the main process's PID,
 	and store it in elf_tdata's core_pid field.
 	* elf32-i386.c (elf_i386_grok_prstatus): Write the LWPID to
 	elf_tdata's core_lwpid instead of to core_pid.
-	(elf_i386_grok_psinfo): Extract the the main process's PID, and
+	(elf_i386_grok_psinfo): Extract the main process's PID, and
 	store it in elf_tdata's core_pid field.
 
 	* elf32-am33lin.c (elf32_am33lin_grok_prstatus): Write the LWPID
@@ -3554,6 +3554,12 @@
 
 For older changes see ChangeLog-2009
 
+Copyright (C) 2010 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
+
 Local Variables:
 mode: change-log
 left-margin: 8
diff --git a/bfd/ChangeLog-2011 b/bfd/ChangeLog-2011
new file mode 100644
index 0000000..e4e2cc0
--- /dev/null
+++ b/bfd/ChangeLog-2011
@@ -0,0 +1,3389 @@
+2011-12-24  Jan Kratochvil  <[email protected]>
+
+	* elf32-rl78.c (rl78_elf_relocate_section, rl78_dump_symtab)
+	(rl78_elf_relax_section): Remove debug prints.
+
+2011-12-23  Jan Kratochvil  <[email protected]>
+
+	* elf32-rl78.c (rl78_elf_relocate_section, rl78_elf_relax_section): Use
+	BFD_VMA_FMT.
+
+2011-12-23  Jan Kratochvil  <[email protected]>
+
+	* elf32-rl78.c (prev_alignment, sec_start): Remove unused variables.
+
+2011-12-23  Tristan Gingold  <[email protected]>
+
+	* vms-lib.c (vms_traverse_index): Move pointer update code.
+
+2011-12-22  DJ Delorie  <[email protected]>
+
+	* elf32-rl78.c (rl78_elf_howto_table): Add R_RL78_RH_RELAX.
+	(rl78_reloc_map): Add BFD_RELOC_RL78_RELAX.
+	(rl78_elf_relocate_section): Add R_RL78_RH_RELAX, R_RL78_RH_SFR,
+	and R_RL78_RH_SADDR.
+	(rl78_elf_finish_dynamic_sections): Only validate PLT section if
+	we didn't relax anything, as relaxing might remove a PLT reference
+	after we've set up the table.
+	(elf32_rl78_relax_delete_bytes): New.
+	(reloc_bubblesort): New.
+	(rl78_offset_for_reloc): New.
+	(relax_addr16): New.
+	(rl78_elf_relax_section): Add support for relaxing long
+	instructions into short ones.
+
+2011-12-22  Martin Schwidefsky  <[email protected]>
+
+	* elf32-s390.c (elf_s390_relocate_section): Add check for debugging
+	section in LD to LE linker relaxation for R_390_TLS_LDO32.
+	* elf64-s390.c (elf_s390_relocate_section): Likewise for
+	R_390_TLS_LDO64.
+
+2011-12-21  Ulrich Weigand  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_nabi_grok_psinfo): Fill in core_pid.
+
+2011-12-19  Iain Sandoe  <[email protected]>
+
+	* mach-o-i386.c (bfd_mach_o_section_type_valid_for_tgt): Define NULL.
+	* mach-o-target.c (bfd_mach_o_backend_data): Initialize
+	bfd_mach_o_section_type_valid_for_tgt
+	* mach-o-x86-64.c (bfd_mach_o_section_type_valid_for_x86_64): New.
+	(bfd_mach_o_section_type_valid_for_tgt): Set to
+	bfd_mach_o_section_type_valid_for_x86_64.
+	* mach-o.c (bfd_mach_o_section_type_name): Reorder and eliminate dup.
+	(bfd_mach_o_section_attribute_name): Reorder.
+	(bfd_mach_o_get_section_type_from_name): If the target has defined a
+	validator for section types, then use it.
+	* mach-o.h (bfd_mach_o_get_section_type_from_name): Alter declaration
+	to include the bfd.
+
+2011-12-19  Chung-Lin Tang  <[email protected]>
+
+	* reloc.c (BFD_RELOC_MIPS16_TLS_GD,BFD_RELOC_MIPS16_TLS_LDM,
+	BFD_RELOC_MIPS16_TLS_DTPREL_HI16,BFD_RELOC_MIPS16_TLS_DTPREL_LO16,
+	BFD_RELOC_MIPS16_TLS_GOTTPREL,BFD_RELOC_MIPS16_TLS_TPREL_HI16,
+	BFD_RELOC_MIPS16_TLS_TPREL_LO16): New relocations for MIPS16 TLS.
+	* bfd-in2.h (bfd_reloc_code_real): Regenerate.
+	* libbfd.h (bfd_reloc_code_real_names): Regenerate.
+	* elf32-mips.c (elf_mips16_howto_table_rel): Add R_MIPS16_TLS_*
+	entries.
+	(mips16_reloc_map): Add BFD_RELOC_MIPS16_TLS_* to R_MIPS16_TLS_*
+	mappings.
+	* elfn32-mips.c (elf_mips16_howto_table_rel,
+	elf_mips16_howto_table_rela): Add R_MIPS16_TLS_* entries.
+	(mips16_reloc_map): Add BFD_RELOC_MIPS16_TLS_* to R_MIPS16_TLS_*
+	mappings.
+	* elf64-mips.c (mips16_elf64_howto_table_rel,
+	mips16_elf64_howto_table_rela): Add R_MIPS16_TLS_* entries.
+	(mips16_reloc_map): Add BFD_RELOC_MIPS16_TLS_* to R_MIPS16_TLS_*
+	mappings.
+	* elfxx-mips.c (TLS_RELOC_P,mips16_reloc_p,
+	_bfd_mips_elf_check_relocs): Add cases for R_MIPS16_TLS_* relocations.
+	(tls_gd_reloc_p): Add R_MIPS16_TLS_GD case.
+	(tls_ldm_reloc_p): Add R_MIPS16_TLS_LDM case.
+	(tls_gottprel_reloc_p): Add R_MIPS16_TLS_GOTTPREL case.
+	(mips_elf_calculate_relocation): Add cases for R_MIPS16_TLS_*,
+	R_MIPS_TLS_DTPREL32/64, and R_MIPS_TLS_TPREL32/64 relocations.
+
+2011-12-19  Chung-Lin Tang  <[email protected]>
+	    Catherine Moore  <[email protected]>
+	    Sandra Loosemore  <[email protected]>
+	    Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_local_pic_function_p): Return true when
+	H is a MIPS16 function with a kept 32-bit stub. Update comments.
+	(mips_elf_get_la25_target): New function.
+	(mips_elf_add_la25_intro): Change to use mips_elf_get_la25_target().
+	(mips_elf_add_la25_stub): Move compute of use_trampoline_p down,
+	change to use mips_elf_get_la25_target().
+	(mips_elf_relocation_needs_la25_stub): Add target_is_16_bit_code_p
+	parameter, add switch case for R_MIPS16_26.
+	(mips_elf_calculate_relocation): Redirect relocation to point to the
+	LA25 stub if it exists, instead of the MIPS16 stub. Update arguments
+	of call to mips_elf_relocation_needs_la25_stub(), don't use la25 stub
+	for mips16->mips16 calls.
+	(_bfd_mips_elf_check_relocs): Update arguments of call to
+	mips_elf_relocation_needs_la25_stub().
+	(mips_elf_create_la25_stub): Change to use mips_elf_get_la25_target().
+
+2011-12-16  Shinichiro Hamaji  <[email protected]>
+
+	* mach-o-i386.c (TARGET_PRIORITY): Define as 0 (top priority)
+	* mach-o-target.c (TARGET_NAME): Use TARGET_PRIORITY
+	* mach-o-x86-64.c (TARGET_PRIORITY): Define as 0 (top priority)
+	* mach-o.c (bfd_mach_o_header_p): Remove special handling for
+	mach-o-i386.
+	(TARGET_PRIORITY) Set 1 for mach-o-be and mach-o-le, and set 0 for
+	mach-o-fat.
+
+2011-12-15  Kevin Buettner  <[email protected]>
+
+	* elf32-am33lin.c (elf32_am33lin_grok_prstatus): Add case
+	to correspond to a smaller ELF_NGREG defined by the kernel.
+
+2011-12-15  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (ELF32_DYNAMIC_INTERPRETER): Set to
+	 "/lib/ldx32.so.1".
+
+2011-12-15  Iain Sandoe  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_mkobject_init): Initialize dyn_reloc_cache.
+	(bfd_mach_o_close_and_cleanup): Only cleanup Mach-O private data
+	for object files.
+
+2011-12-15  Shinichiro Hamaji  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_canonicalize_reloc): Update relocation
+	table only when there isn't the cahce.
+	(bfd_mach_o_get_dynamic_reloc_upper_bound): Need one more space
+	for a pointer for the watchdog.
+	(bfd_mach_o_canonicalize_dynamic_reloc): Utilize cache like
+	bfd_mach_o_canonicalize_reloc.
+	(bfd_mach_o_close_and_cleanup): Call bfd_mach_o_free_cached_info.
+	(bfd_mach_o_free_cached_info): Free up cache data.
+	* mach-o.h (reloc_cache): A place to store cache of dynamic relocs.
+	(bfd_mach_o_free_cached_info): Add declaration.
+
+2011-12-15  Iain Sandoe  <[email protected]>
+
+	* mach-o-target.c (bfd_mach_o_bfd_set_private_flags): Use
+	bfd_mach_o_bfd_set_private_flags.
+	* mach-o.c (bfd_mach_o_bfd_set_private_flags): New.
+	* mach-o.h (bfd_mach_o_bfd_set_private_flags): Declare.
+
+2011-12-14  Nick Clifton  <[email protected]>
+
+	PR ld/12451
+	* elfcode.h (elf_checksum_contents): Read in the section's
+	contents if they are not already available, and the section
+	actually has some contents.
+
+	* compress.c (bfd_get_full_section_contents): Use zmalloc to
+	allocate the buffers so that excess bytes are guaranteed to be
+	zero.
+
+2011-12-14  Iain Sandoe  <[email protected]>
+
+	* mach-o-i386.c (text_section_names_xlat): New table.
+	(data_section_names_xlat): Likewise.
+	(import_section_names_xlat): Likewise.
+	(mach_o_i386_segsec_names_xlat): Likewise.
+	(bfd_mach_o_tgt_seg_table): Use new tables.
+	* mach-o-x86-64.c (bfd_mach_o_tgt_seg_table): Set NULL.
+	* mach-o.c (mach_o_section_name_xlat, mach_o_segment_name_xlat):
+	Move to mach-o.h as   typedefs.
+	(text_section_names_xlat): Update for current GCC usage.
+	(data_section_names_xlat): Likewise.
+	(dwarf_section_names_xlat): Likewise.
+	(objc_section_names_xlat): New table.
+	(segsec_names_xlat): Add objc table.
+	(bfd_mach_o_normalize_section_name):  Replace with...
+	(bfd_mach_o_section_data_for_mach_sect): New.
+	(bfd_mach_o_section_data_for_bfd_name): New.
+	(bfd_mach_o_section_data_for_bfd_name): Update to use additional data.
+	(bfd_mach_o_convert_section_name_to_mach_o): Likewise.
+	(bfd_mach_o_bfd_copy_private_section_data): Implement.
+	(bfd_mach_o_write_symtab): Write a zero-length string as the first entry
+	for compatibility with system tools.
+	(bfd_mach_o_build_commands): Update section alignment info.
+	(bfd_mach_o_new_section_hook): Use translation table data to define
+	default section flags, type, attributes and alignment, when available.
+	(bfd_mach_o_init_section_from_mach_o): Add TODO comment.
+	(bfd_mach_o_section_type_name): Add 'symbol_stubs'.
+	(bfd_mach_o_section_attribute_name): Add 'self_modifying_code'.
+	(bfd_mach_o_get_section_type_from_name): Change "not-found" return
+	value.
+	(bfd_mach_o_tgt_seg_table): Set default NULL.
+	* mach-o.h (bfd_mach_o_segment_command):  Use define for name length.
+	(bfd_mach_o_backend_data): Move until after contents are defined.
+	(bfd_mach_o_normalize_section_name): Remove.
+	(bfd_mach_o_convert_section_name_to_bfd): Declare.
+	(mach_o_section_name_xlat): Declare.
+	(mach_o_segment_name_xlat): Declare.
+	(bfd_mach_o_section_data_for_mach_sect): Declare.
+	(bfd_mach_o_section_data_for_bfd_name): Declare.
+
+2011-12-13  Shinichiro Hamaji  <[email protected]>
+
+	* dwarf2.c (bfd_dwarf2_cleanup_debug_info): Accept stash as an
+	argument like other functions to support formats other than ELF.
+	* elf-bfd.h (bfd_dwarf2_cleanup_debug_info): Move to bfd-in.h.
+	* elf.c (_bfd_elf_close_and_cleanup): Pass dwarf2_find_line_info
+	in tdata as a parameter.
+	* libbfd-in.h (bfd_dwarf2_cleanup_debug_info): Move from
+	elf-bfd.h.
+	* libbfd.h (bfd_dwarf2_cleanup_debug_info): Regenerate.
+	* mach-o-target.c (bfd_mach_o_close_and_cleanup): Remove the
+	fallback macro.
+	(bfd_mach_o_find_nearest_line): Likewise.
+	* mach-o.c (bfd_mach_o_find_nearest_line): Add the definition
+	which calls _bfd_dwarf2_find_nearest_line.
+	(bfd_mach_o_close_and_cleanup): Likewise.
+	* mach-o.h (mach_o_data_struct): Add dwarf2_find_line_info.
+	(bfd_mach_o_find_nearest_line): Add declaration.
+	(bfd_mach_o_close_and_cleanup): Add declaration.
+
+2011-12-13  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_read_symtab_symbols): Make global.  Remove
+	prototype.
+	(bfd_mach_o_section_get_entry_size): Make global.
+	(bfd_mach_o_section_get_nbr_indirect): Likewise.
+	(bfd_mach_o_read_symtab_strtab): Likewise.
+	(struct bfd_mach_o_xlat_name): Move to mach-o.h
+	(bfd_mach_o_print_flags): Move to binutils/od-macho.c
+	(bfd_mach_o_get_name_of_null, bfd_mach_o_get_name): Likewise.
+	(bfd_mach_o_cpu_name, bfd_mach_o_filetype_name): Likewise.
+	(bfd_mach_o_header_flags_name): Likewise.
+	(bfd_mach_o_load_command_name): Likewise.
+	(bfd_mach_o_print_private_header): Likewise.
+	(bfd_mach_o_print_section_map, bfd_mach_o_print_section): Likwise.
+	(bfd_mach_o_print_segment, bfd_mach_o_print_dysymtab): Likewise.
+	(bfd_mach_o_print_dyld_info): Likewise.
+	(bfd_mach_o_print_private_bfd_data): Remove.
+	(bfd_mach_o_type_name): Make global.
+	(bfd_mach_o_section_attribute_name): Likewise.
+	* mach-o.h (bfd_mach_o_xlat_name): Added.
+	(bfd_mach_o_section_get_nbr_indirect)
+	(bfd_mach_o_section_get_entry_size)
+	(bfd_mach_o_read_symtab_symbols)
+	(bfd_mach_o_read_symtab_strtab)
+	(bfd_mach_o_section_attribute_name)
+	(bfd_mach_o_section_type_name): Likewise.
+	* mach-o-target.c (bfd_mach_o_bfd_print_private_bfd_data): Define.
+
+2011-12-13  Chung-Lin Tang  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_calculate_relocation): Correct
+	R_MIPS16_HI16/R_MIPS16_LO16 handling of two cleared lower bits,
+	update comments.
+
+2011-12-12  Iain Sandoe  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_read_section_32): Null-terminate sectname.
+	(bfd_mach_o_read_section_64): Likewise.
+
+2011-12-11  John Davis Anglin  <[email protected]>
+
+	PR binutils/13476
+	* elf32-hppa.c (final_link_relocate): Convert R_PARISC_TLS_GD21L,
+	R_PARISC_TLS_LDM21L and R_PARISC_TLS_IE21L relocations to
+	R_PARISC_DPREL21L when not doing a shared link.  Likewise convert
+	R_PARISC_TLS_GD14R, R_PARISC_TLS_LDM14R and R_PARISC_TLS_IE14R to
+	R_PARISC_DPREL14R.  Handle R_PARISC_TLS_GD21L, R_PARISC_TLS_LDM21L
+	and R_PARISC_TLS_IE21L with R_PARISC_DLTIND21L.
+
+2011-12-10  David Daney  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_link_hash_table.rld_value): Remove.
+	(mips_elf_link_hash_table.rld_symbol): New field;
+	(MIPS_ELF_RLD_MAP_SIZE): New macro.
+	(_bfd_mips_elf_add_symbol_hook): Remember __rld_obj_head symbol
+	in rld_symbol.
+	(_bfd_mips_elf_create_dynamic_sections): Remember __rld_map symbol
+	in rld_symbol.
+	(_bfd_mips_elf_size_dynamic_sections): Set correct size for .rld_map.
+	(_bfd_mips_elf_finish_dynamic_symbol): Remove .rld_map handling.
+	(_bfd_mips_elf_finish_dynamic_sections): Use rld_symbol to
+	calculate DT_MIPS_RLD_MAP value.
+	(_bfd_mips_elf_link_hash_table_create): Initialize rld_symbol,
+	quit initializing rld_value.
+
+2011-12-08  Andrew Pinski  <[email protected]>
+            Adam Nemet  <[email protected]>
+
+	* archures.c (bfd_mach_mips_octeon2): New macro
+	* bfd-in2.h: Regenerate.
+	* cpu-mips.c (I_mipsocteon2): New enum value.
+	(arch_info_struct): Add bfd_mach_mips_octeon2.
+	* elfxx-mips.c (_bfd_elf_mips_mach): Support E_MIPS_MACH_OCTEON2.
+	(mips_set_isa_flags): Add bfd_mach_mips_octeon2.
+	(mips_mach_extensions): Add bfd_mach_mips_octeon2.
+
+2011-12-07  Alan Modra  <[email protected]>
+
+	PR ld/12772
+	* elflink.c (elf_gc_sweep_symbol): Discard unmarked symbols
+	defined in shared libraries.
+
+2011-12-07  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_canonicalize_symtab): Fix indentation.
+	Adjust the condition.
+	(bfd_mach_o_read_symtab_symbol): Now returns a bfd_boolean.
+	Adjust return statements.
+	(bfd_mach_o_read_symtab_strtab): Likewise.
+	(bfd_mach_o_read_symtab_symbols): Likewise.
+	(bfd_mach_o_scan_start_address): Likewise.  Make it static.
+	(bfd_mach_o_scan): Likewise.
+	(bfd_mach_o_read_dysymtab_symbol): Remove unused function.
+	(bfd_mach_o_header_p): Adjust call.
+	(bfd_mach_o_cpu_name): Make it const.
+	(bfd_mach_o_filetype_name): Likewise.
+	(bfd_mach_o_header_flags_name): Likewise.
+	(bfd_mach_o_section_type_name): Likewise.
+	(bfd_mach_o_section_attribute_name): Likewise.
+	(bfd_mach_o_load_command_name): Likewise.
+	(bfd_mach_o_get_section_type_from_name): Add a const qualifier
+	after above change.
+	(bfd_mach_o_get_section_attribute_from_name): Likewise.
+	* mach-o.h (bfd_mach_o_read_dysymtab_symbol)
+	(bfd_mach_o_scan_start_address, bfd_mach_o_scan): Remove.
+
+2011-12-06  Ulrich Weigand  <[email protected]>
+
+	* elf-bfd.h (elfcore_write_s390_last_break): Add prototype.
+	(elfcore_write_s390_system_call): Likewise.
+	* elf.c (elfcore_write_s390_last_break): New function.
+	(elfcore_write_s390_system_call): Likewise.
+	(elfcore_write_register_note): Call them.
+	(elfcore_grok_s390_last_break): New function.
+	(elfcore_grok_s390_system_call): Likewise.
+	(elfcore_grok_note): Call them.
+
+2011-12-05  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_read_symtab_symbol): Accept indirect symbols.
+
+2011-12-05  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_write_contents): Handle LC_LOAD_UPWARD_DYLIB.
+	(bfd_mach_o_read_dylib): Likewise.
+	(bfd_mach_o_read_command): Likewise.
+	(bfd_mach_o_bfd_print_private_bfd_data): Likewise.
+
+2011-12-05  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_read_command): Add the bfd in the error
+	message.
+	(bfd_mach_o_openr_next_archived_file): Use arch name as member name.
+	(bfd_mach_o_fat_extract): Ditto.
+
+2011-12-03  Alan Modra  <[email protected]>
+
+	PR ld/13468
+	* elflink.c (bfd_elf_final_link): Don't segfault when checking
+	for DT_TEXTREL and .dynamic does not exist.
+
+2011-12-03  Alan Modra  <[email protected]>
+
+	PR ld/13470
+	* elf32-ppc.c (ppc_elf_copy_indirect_symbol): Revert substantive
+	change in 2011-07-01 commit.  Comment.
+	* elf64-ppc.c (ppc64_elf_copy_indirect_symbol): Likewise.
+
+2011-12-01  Mikael Pettersson  <[email protected]>
+
+	* elf32-m68k.c (elf_m68k_check_relocs) <R_68K_8, R68K_16, R_68K_32>: For
+	non-SEC_ALLOC sections break before GOT and PLT accounting.
+
+2011-12-01  Hans-Peter Nilsson  <[email protected]>
+
+	* elf32-cris.c (cris_elf_check_relocs) <plt accounting for
+	R_CRIS_8, R_CRIS_16, and R_CRIS_32>: Move early break for
+	non-SEC_ALLOC sections before GOT and PLT accounting.
+
+2011-11-29  Andrew Pinski  <[email protected]>
+
+	* archures.c (bfd_mach_mips_octeonp): New macro.
+	* bfd-in2.h: Regenerate.
+	* bfd/cpu-mips.c (I_mipsocteonp): New enum value.
+	(arch_info_struct): Add bfd_mach_mips_octeonp.
+	* elfxx-mips.c (mips_set_isa_flags): Add bfd_mach_mips_octeonp.
+	(mips_mach_extensions): Add bfd_mach_mips_octeonp.
+
+2011-11-23  Tristan Gingold  <[email protected]>
+
+	* vms-lib.c (get_idxlen): Add comments.  Fix type in sizeof.
+	(vms_write_index): Add comments.
+
+2011-11-22  DJ Delorie  <[email protected]>
+
+	* elf32-rx.c (rx_elf_object_p): Add more checks for "scanning" to
+	avoid using the special non-swapping target when not explicitly
+	requested.
+
+2011-11-22  Daniel Calcoen  <[email protected]>
+
+	* elf32-rx.c (rx_elf_object_p): Correct typo: lma->vma.
+
+2011-11-22  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_print_symbol): Display COM for common
+	symbols.  Print section name in brackets.
+
+2011-11-21  Andreas Tobler  <[email protected]>
+
+	* config.bfd: Add vectors for powerpc and powerpc64-freebsd.
+	* configure.in (TDEFINES): Add rules for powerpc*-freebsd.
+	* configure: Regenerate.
+	* elf32-ppc.c: Add powerpc-freebsd definitions.
+	* elf64-ppc.c: Add powerpc64-freebsd definitions.
+	* targets.c: Add bits for powerpc and powerpc64-freebsd.
+
+2011-11-17  Philipp Thomas  <[email protected]>
+
+	* elf32-arm.c (elf32_thumb_to_arm_stub): Sync message so that it
+	needs to be translated only once.
+
+2011-11-16  Maciej W. Rozycki  <[email protected]>
+
+	* elf64-mips.c (mips_elf64_howto_table_rela): Set src_mask to
+	zero throughout.
+	(mips16_elf64_howto_table_rela): Likewise.
+	(micromips_elf64_howto_table_rela): Likewise.
+	* elfn32-mips.c (elf_mips_howto_table_rela): Likewise.
+	(elf_mips16_howto_table_rela): Likewise.
+	(elf_micromips_howto_table_rela): Likewise.
+
+2011-11-15  Alan Modra  <[email protected]>
+	    Andreas Tobler  <[email protected]>
+
+	* elflink.c (_bfd_elf_create_got_section): Replace
+	bfd_make_section_with_flags with bfd_make_section_anyway_with_flags.
+	(_bfd_elf_link_create_dynamic_sections): Likewise.
+	* elf32-ppc.c (ppc_elf_create_glink): Likewise.
+	(ppc_elf_create_dynamic_sections): Likewise.
+
+2011-11-14  Maxim Kuvyrkov  <[email protected]>
+
+	* elfxx-mips.c (mips_n64_exec_plt0_entry): Use 64-bit move.
+
+2011-11-08  Nick Clifton  <[email protected]>
+
+	* elf-m10300.c (mn10300_elf_relax_section): Fix check for an
+	immediate move into an address register.
+
+2011-11-09  Alan Modra  <[email protected]>
+
+	* elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Mark syms in
+	executables when export_dynamic.
+
+2011-11-08  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (struct ppc64_elf_obj_tdata): Rename
+	ha_relocs_not_using_r2 to unexpected_toc_insn.
+	(ok_lo_toc_insn): New function.
+	(ppc64_elf_edit_toc): Check insn on lo toc reloc.  Emit warning.
+	(ppc64_elf_relocate_section): Don't check insn on lo toc reloc here.
+	Handle addic on lo toc reloc.
+
+2011-11-06  John David Anglin  <[email protected]>
+
+	PR ld/13387
+	* elf32-hppa.c (elf32_hppa_hide_symbol): Make STT_GNU_IFUNC symbol
+	go through PLT.  Reset plt field with init_plt_offset.
+	(elf32_hppa_adjust_dynamic_symbol): Ensure that a PLT slot is
+	allocated for symbols referenced by a plabel.
+
+2011-11-02  DJ Delorie  <[email protected]>
+
+	* elf32-rl78.c (rl78_elf_merge_private_bfd_data): Delete unused
+	variable.
+
+2011-11-02  Jan Beulich  <[email protected]>
+
+	* coffgen.c (coff_write_alien_symbol): Make public. Add 'struct
+	internal_syment *' parameter. Extend 'dummy' to an array with two
+	elements. Set n_numaux early. Handle BSF_FILE.
+	(coff_write_symbols): Pass NULL as new third argument to
+	coff_write_alien_symbol().
+	* cofflink.c (_bfd_coff_final_link): Don't use COFF-specific
+	obj_raw_syment_count() on non-COFF input BFD. Insert local symbols
+	from non-COFF input BFDs.
+	* libcoff-in.h (coff_write_alien_symbol): Declare.
+	* libcoff.h (coff_write_alien_symbol): Re-generate.
+
+2011-11-01  DJ Delorie  <[email protected]>
+
+	* Makefile.am (ALL_MACHINES): Add cpu-rl78.lo.
+	(ALL_MACHINES_CFILES): Add cpu-rl78.c.
+	(BFD32_BACKENDS): Add elf32-rl78.lo.
+	(BFD32_BACKENDS_CFILES): Add elf32-rl78.c.
+	(Makefile.in): Regenerate.
+	* archures.c (bfd_architecture): Define bfd_arch_rl78.
+	(bfd_archures_list): Add bfd_rl78_arch.
+	* config.bfd: Add rl78-*-elf.
+	* configure.in: Add bfd_elf32_rl78_vec.
+	* reloc.c (bfd_reloc_code_type): Add BFD_RELOC_RL78_* relocations.
+	* targets.c (bfd_target_vector): Add bfd_elf32_rl78_vec.
+	* Makefile.in: Regenerate.
+	* bfd-in2.h: Regenerate.
+	* configure: Regenerate.
+	* libbfd.h: Regenerate.
+	* cpu-rl78.c: New file.
+	* elf32-rl78.c: New file.
+
+2011-10-26  Nick Clifton  <[email protected]>
+
+	PR ld/13049
+	* elf64-ppc.c (STUB_SUFFIX): Revert previous delta.
+	* elf32-hppa.c (STUB_SUFFIX): Likewise.
+
+2011-10-25  Joern Rennecke  <[email protected]>
+
+	* Makefile.am (ALL_MACHINES): Add cpu-epiphany.lo.
+	(ALL_MACHINES_CFILES): Add cpu-epiphany.c.
+	(BFD32_BACKENDS): Add elf32-epiphany.lo.
+	(BFD32_BACKENDS_CFILES): Add elf32-epiphany.c.
+	* archures.c (bfd_arch_epiphany): Add.
+	(bfd_mach_epiphany16, bfd_mach_epiphany32): Define.
+	(bfd_epiphany_arch): Declare.
+	(bfd_archures_list): Add &bfd_epiphany_arch.
+	* config.bfd (epiphany-*-elf): New target case.
+	* configure.in (bfd_elf32_epiphany_vec): New target vector case.
+	* reloc.c (BFD_RELOC_EPIPHANY_SIMM8): New relocation.
+	(BFD_RELOC_EPIPHANY_SIMM24, BFD_RELOC_EPIPHANY_HIGH): Likewise.
+	(BFD_RELOC_EPIPHANY_LOW, BFD_RELOC_EPIPHANY_SIMM11): Likewise.
+	(BFD_RELOC_EPIPHANY_IMM11, BFD_RELOC_EPIPHANY_IMM8): Likewise.
+	* targets.c (bfd_elf32_epiphany_vec): Declare.
+	(_bfd_target_vector): Add bfd_elf32_epiphany_vec.
+	* Makefile.in: Regenerate.
+	* bfd-in2.h: Regenerate.
+	* configure: Regenerate.
+	* libbfd.h: Regenerate.
+	* po/SRC-POTFILES.in: Regenerate.
+	* po/bfd.pot: Regenerate.
+	* cpu-epiphany.c: New file.
+	* elf32-epiphany.c: New file.
+
+2011-10-24  Maciej W. Rozycki  <[email protected]>
+
+	* elfxx-mips.c (_bfd_mips_elf_symbol_processing): Remove
+	assertions.
+
+2011-10-24  Eugeniy Meshcheryakov  <[email protected]>
+
+	PR ld/13273
+	* elf32-arm.c (elf32_arm_merge_eabi_attributes): Do not warn about
+	identical TAG_PCS_config attributes.
+
+2011-10-24  Nick Clifton  <[email protected]>
+
+	* po/ja.po: Updated Japanese translation.
+
+2011-10-24  Pau Garcia i Quiles  <[email protected]>
+
+	PR binutils/13292
+	* bfd-in.h: Include <sys/stat.h> rather than forward defining
+	struct stat.
+	* bfd-in2.h: Regenerate.
+
+2011-10-21  H.J. Lu  <[email protected]>
+
+	PR ld/13302
+	* elf32-i386.c (elf_i386_relocate_section): Replace
+	R_386_IRELATIVE with R_386_RELATIVE.
+
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Replace
+	R_X86_64_IRELATIVE with R_X86_64_RELATIVE.
+
+2011-10-21  H.J. Lu  <[email protected]>.
+
+	* elf32-i386.c (elf_i386_relocate_section): Fix a typo in
+	comments.
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
+
+2011-10-21  H.J. Lu  <[email protected]>
+
+	PR ld/13302
+	* elf32-i386.c (elf_i386_link_hash_table): Add next_jump_slot_index
+	and next_irelative_index.
+	(elf_i386_link_hash_table_create): Initialize next_jump_slot_index
+	and next_irelative_index.
+	(elf_i386_allocate_dynrelocs): Increment reloc_count instead of
+	next_tls_desc_index.
+	(elf_i386_size_dynamic_sections): Set next_tls_desc_index and
+	next_irelative_index from reloc_count.
+	(elf_i386_finish_dynamic_symbol): Put R_386_IRELATIVE after
+	R_386_JUMP_SLOT.
+
+	* elf64-x86-64.c (elf_x86_64_link_hash_table): Add
+	next_jump_slot_index and next_irelative_index.
+	(elf_x86_64_link_hash_table_create): Initialize
+	next_jump_slot_index and next_irelative_index.
+	(elf_x86_64_size_dynamic_sections): Set next_irelative_index
+	from reloc_count.
+	(elf_x86_64_finish_dynamic_symbol): Put R_X86_64_IRELATIVE after
+	R_X86_64_JUMP_SLOT.
+
+2011-10-20  Nick Clifton  <[email protected]>
+
+	PR ld/13049
+	* elf32-arm.c (STUB_SUFFIX): Avoid collision with user namespace
+	symbol names.
+	* elf64-ppc.c (STUB_SUFFIX): Likewise.
+	* elf32-hppa.c (STUB_SUFFIX): Likewise.
+
+2011-10-20  Alan Modra  <[email protected]>
+
+	* elf32-i386.c (i386_opcode16): Delete.
+	(elf_i386_check_tls_transition): Use memcmp to compare contents.
+	* elf64-x86-64.c (x86_64_opcode16, x86_64_opcode32): Delete.
+	(elf_x86_64_check_tls_transition): Use memcmp to compare contents.
+
+2011-10-19  Alan Modra  <[email protected]>
+
+	PR ld/13177
+	* elflink.c (_bfd_elf_gc_mark_rsec): Set symbol "mark".
+	(elf_gc_sweep_symbol): Don't test plt/got refcounts, instead test
+	"mark".  Hide undefweak too.  Clear def_regular and ref_regular.
+	* elf-m10300.c (mn10300_elf_relocate_section): Ignore unresolved
+	reloc errors from garbage-collected code.
+	* elf32-arm.c (elf32_arm_relocate_section): Likewise.
+	* elf32-bfin.c (bfin_relocate_section): Likewise.
+	(bfinfdpic_relocate_section): Likewise.
+	* elf32-cris.c (cris_elf_relocate_section): Likewise.
+	* elf32-frv.c (elf32_frv_relocate_section): Likewise.
+	* elf32-i386.c (elf_i386_relocate_section): Likewise.
+	* elf32-m32r.c (m32r_elf_relocate_section): Likewise.
+	* elf32-m68k.c (elf_m68k_relocate_section): Likewise.
+	* elf32-ppc.c (ppc_elf_relocate_section): Likewise.
+	* elf32-s390.c (elf_s390_relocate_section): Likewise.
+	* elf32-sh.c (sh_elf_relocate_section): Likewise.
+	* elf32-spu.c (spu_elf_relocate_section): Likewise.
+	* elf32-tilepro.c (tilepro_elf_relocate_section): Likewise.
+	* elf32-xtensa.c (elf_xtensa_relocate_section): Likewise.
+	* elf64-alpha.c (elf64_alpha_relocate_section): Likewise.
+	* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
+	* elf64-s390.c (elf_s390_relocate_section): Likewise.
+	* elf64-sh64.c (sh_elf64_relocate_section): Likewise.
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
+	* elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Likewise.
+	* elfxx-tilegx.c (tilegx_elf_relocate_section): Likewise.
+
+2011-10-19  Alan Modra  <[email protected]>
+
+	PR ld/13311
+	* elflink.c (elf_link_output_extsym): Correct test for warning when
+	forced local executable syms are referenced from shared libraries.
+
+2011-10-19  Alan Modra  <[email protected]>
+
+	PR ld/13254
+	* elflink.c (bfd_elf_final_link): Emit error_textrel error.
+
+2011-10-18  David S. Miller  <[email protected]>
+
+	PR binutils/13301
+	* elfxx-sparc.c (sparc_elf_find_reloc_at_ofs): New function.
+	(_bfd_sparc_elf_relocate_section): Always move the __tls_get_addr
+	call delay slot instruction forward 4 bytes when performing
+	relaxation.
+
+2011-10-17  Alan Modra  <[email protected]>
+
+	PR ld/12975
+	PR ld/13195
+	* elf64-ppc.c (ppc64_elf_gc_mark_dynamic_ref): Apply 2011-09-15
+	and 2011-09-29 bfd_elf_gc_mark_dynamic_ref_symbol changes here too.
+
+2011-10-14  Hans-Peter Nilsson  <[email protected]>
+
+	* elf32-cris.c (cris_elf_gc_sweep_hook) <R_CRIS_16_GOTPLT>
+	<R_CRIS_32_GOTPLT>: Fix missing update of gotplt refcount for
+	global symbols.
+	<R_CRIS_8, R_CRIS_16, R_CRIS_32>: New cases for similar missing
+	updates of the plt refcount.
+	(elf_cris_adjust_gotplt_to_got): Assert integrity of the gotplt
+	refcount in relation to the plt refcount.
+
+2011-10-13  Richard Sandiford  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_final_link_relocate): Mark PLT calls via
+	stubs as resolved.
+
+2011-10-11  Alan Modra  <[email protected]>
+
+	PR binutils/13278
+	* archive.c (bfd_generic_archive_p): Only check first element
+	when target_defaulted.
+	(_bfd_construct_extended_name_table): Use ar_maxnamelen.
+	(_bfd_archive_bsd44_construct_extended_name_table): Likewise.
+
+2011-10-11  Alan Modra  <[email protected]>
+
+	PR binutils/13257
+	* archive.c (_bfd_find_nested_archive, _bfd_get_elt_at_filepos): Open
+	thin archive element using container target if not defaulted.
+
+2011-10-10  Nick Clifton  <[email protected]>
+
+	* po/es.po: Updated Spanish translation.
+	* po/fi.po: Updated Finnish translation.
+	* po/fr.po: Updated French translation.
+	* po/ru.po: Updated Russian translation.
+
+2011-10-10  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (ppc64_elf_howto_table): Add R_PPC64_TOCSAVE entry.
+	(struct ppc_link_hash_table): Add tocsave_htab.
+	(struct tocsave_entry): New.
+	(tocsave_htab_hash, tocsave_htab_eq, tocsave_find): New functions.
+	(ppc64_elf_link_hash_table_create): Create tocsave_htab..
+	(ppc64_elf_link_hash_table_free): ..and delete it.
+	(build_plt_stub): Always put STD_R2_40R1 first.
+	(ppc64_elf_size_stubs): Check for R_PPC64_TOCSAVE following reloc
+	on plt call.  If present add prologue nop location to tocsave_htab.
+	(ppc64_elf_relocate_section): Convert prologue nop to std.  Skip
+	first insn of plt call stub when R_PPC64_TOCSAVE present.
+
+2011-10-08  H.J. Lu  <[email protected]>
+
+	PR ld/13250
+	* elflink.c (elf_link_add_object_symbols): Preserve the maximum
+	alignment and size for common symbols.
+
+2011-10-08  Alan Modra  <[email protected]>
+
+	PR ld/13229
+	PR ld/13244
+	* elflink.c (elf_link_add_object_symbols): Don't make IR symbols
+	dynamic.
+
+2011-10-08  Alan Modra  <[email protected]>
+
+	PR ld/13229
+	* elflink.c (elf_link_output_extsym): Strip defined plugin symbols
+	even when strip_discarded is false.
+
+2011-10-05  Kai Tietz  <[email protected]>
+
+	* coffgen.c (coff_write_alien_symbol): Don't write
+	symbol for discarded sections, if strip_discarded isn't
+	explicit set to false.
+	(coff_write_native_symbol): Likewise.
+
+2011-10-05  DJ Delorie  <[email protected]>
+	    Nick Clifton  <[email protected]>
+
+	* elf32-rx.c: Add support for PID mode.
+	(rx_elf_relocate_section): Add checks for unsafe PID relocations.
+	Include addend in R_RX_SYM relocations.
+
+2011-09-30  Tristan Gingold  <[email protected]>
+
+	* dwarf2.c (struct dwarf2_debug): Add field debug_sections.
+	(read_section): Add sec argument. Adjust the code to get section
+	names from it.
+	(read_indirect_string): Adjust call to read_section.
+	(read_abbrevs): Ditto.
+	(decode_line_info): Ditto.
+	(read_debug_ranges): Ditto.
+	(DWARF2_DEBUG_INFO, DWARF2_COMPRESSED_DEBUG_INFO): Remove.
+	(find_debug_info): Add debug_sections parameter.  Use it instead
+	the above macros.
+	(place_sections): Get section names from stash.
+	(find_line): Add debug_sections argument.  Initialize
+	debug_sections field of stash from it.
+	Adjust calls to find_debug_info.
+	(_bfd_dwarf2_find_nearest_line): Add debug_sections argument.
+	Adjust call to find_line.
+	(_bfd_dwarf2_find_line): Adjust call to find_line.
+	* libcoff-in.h (struct dwarf_debug_section): New declaration.
+	(coff_find_nearest_line_with_names): Likewise.
+	* libcoff.h: Regenerate.
+	* libbfd-in.h (struct dwarf_debug_section): Move declaration.
+	(dwarf_debug_sections): Likewise.
+	(_bfd_dwarf2_find_nearest_line): Add debug_sections argument.
+	* libbfd.h: Regenerate.
+	* elf.c (_bfd_elf_find_nearest_line): Adjust call to
+	_bfd_dwarf2_find_nearest_line.
+	* elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Ditto.
+	* elf64-alpha.c (elf64_alpha_find_nearest_line): Ditto.
+	* elf32-arm.c (elf32_arm_find_nearest_line): Ditto.
+	* coffgen.c (coff_find_nearest_line_with_names): New function.
+	(coff_find_nearest_line): Calls coff_find_nearest_line_with_names.
+	* coff-rs6000.c (xcoff_debug_sections): New constant.
+	(xcoff_find_nearest_line): New function.
+	(rs6000coff_vec): Use xcoff_find_nearest_line.
+	(pmac_xcoff_vec): Ditto.
+
+2011-09-30  Alan Modra  <[email protected]>
+
+	PR ld/13235
+	* elf64-ppc.c (struct ppc64_elf_obj_tdata): Add ha_relocs_not_using_r2.
+	(ppc64_elf_edit_toc): Check HA relocs.
+	(ha_reloc_match): Delete function.
+	(ppc64_elf_relocate_section): Remove delayed HA nop optimization.
+	Instead do it and low part optimization based on
+	ha_relocs_not_using_r2.
+
+2011-09-29  Alan Modra  <[email protected]>
+
+	PR ld/13233
+	* elflink.c (_bfd_elf_gc_mark_extra_sections): Mark single member
+	debug and special section groups.
+
+2011-09-29  H.J. Lu  <[email protected]>
+
+	PR ld/13195
+	* elflink.c (_bfd_elf_merge_symbol): Don't set dynamic_def when
+	clearing def_dynamic.
+	(elf_link_add_object_symbols): Likewise.  Set dynamic_def when
+	setting def_dynamic.
+	(bfd_elf_gc_mark_dynamic_ref_symbol): Check if a symbol is
+	versioned.
+
+2011-09-27  Kai Tietz  <[email protected]>
+
+	* coffcode.h (sec_to_styp_flags): Handle
+	SEC_LINK_DUPLICATES_SAME_CONTENTS, and
+	SEC_LINK_DUPLICATES_SAME_SIZE.
+
+2011-09-22  Tristan Gingold  <[email protected]>
+
+	* configure.in: Bump version to 2.22.51
+	* configure: Regenerate.
+
+2011-09-21  David S. Miller  <[email protected]>
+
+	* elfxx-sparc.c (_bfd_sparc_elf_merge_private_bfd_data): New.
+	* elfxx-sparc.h: Declare it.
+	* elf32-sparc.c (elf32_sparc_merge_private_bfd_data): Call it.
+	* elf64-sparc.c (elf64_sparc_merge_private_bfd_data): Likewise.
+
+2011-09-21  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_convert_section_name_to_bfd): Add comment.
+	Deals with size limited strings.
+	(bfd_mach_o_build_commands): Initialize more fields.
+
+2011-09-15  H.J. Lu  <[email protected]>
+
+	PR ld/13177
+	* elflink.c (elf_gc_sweep_symbol): Also hide symbols without PLT
+	nor GOT references.
+
+2011-09-15  H.J. Lu  <[email protected]>
+
+	PR ld/12975
+	* bfd-in.h (bfd_elf_size_dynamic_sections): Remove pointer
+	to struct bfd_elf_version_tree.
+
+	* elflink.c (elf_info_failed): Remove verdefs.
+	(_bfd_elf_export_symbol): Updated.
+	_bfd_elf_link_assign_sym_version): Likewise.
+	(bfd_elf_size_dynamic_sections): Remove pointer to struct
+	bfd_elf_version_tree.  Updated.
+	(bfd_elf_gc_mark_dynamic_ref_symbol): Check if a symbol is hidden
+	by linker script.
+
+	* linker.c (bfd_hide_sym_by_version): New.
+
+	* bfd-in2.h: Regenerated.
+
+2011-09-12  H.J. Lu  <[email protected]>
+
+	PR ld/13178
+	* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Use .got.plt
+	if there are no GOT relocations.
+
+2011-09-09  Kai Tietz  <[email protected]>
+
+	* peicode.h (pe_ILF_build_a_bfd): Don't remove leading underscore
+	for targets without symbol_leading_char.
+
+2011-09-08  Bernd Jendrissek  <[email protected]>
+
+	* bfdwin.c (bfd_get_file_window): Fix memory leak.
+
+2011-09-07  Alan Modra  <[email protected]>
+
+	PR ld/13131
+	* bfd/elf64-ppc.c (adjust_toc_syms): Ensure ppc64_elf_howto_table
+	is initialized.
+
+2011-09-06  Alan Modra  <[email protected]>
+
+	PR ld/13131
+	* elf64-ppc.c (adjust_toc_syms): Delete redundant code.
+	(ppc64_elf_edit_toc): Fix style nit.  Report some details
+	on linker failure due to reference in debug or non-alloc
+	sections to optimized away toc entry, and don't abort.
+
+2011-09-01  Christophe Lyon  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_output_arch_local_syms): Skip excluded
+	sections.
+
+2011-08-26  Nick Clifton  <[email protected]>
+
+	* po/es.po: Updated Spanish translation.
+
+2011-08-19  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (ppc64_elf_edit_toc): Ignore can_optimize bit if
+	we haven't seen expected -mcmodel=medium/large code relocs.
+
+2011-08-18  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_read_segment): Initialize list.
+
+2011-08-17  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_write_section_32): Fix typo.
+
+2011-08-17  Alan Modra  <[email protected]>
+
+	PR ld/12762
+	* bfd-in.h (struct bfd_section_already_linked): Forward declare.
+	(_bfd_handle_already_linked): Declare.
+	* coff-alpha.c (_bfd_ecoff_section_already_linked): Define as
+	_bfd_coff_section_already_linked.
+	* coff-mips.c (_bfd_ecoff_section_already_linked): Likewise.
+	* coffcode.h (coff_section_already_linked): Likewise.
+	* cofflink.c (coff_link_add_symbols): Revert 2011-07-09 changes.
+	* elf-bfd.h: Likewise.
+	* libbfd-in.h: Likewise.
+	* targets.c: Likewise.
+	* linker.c (bfd_section_already_linked): Likewise.
+	(bfd_section_already_linked_table_lookup): Likewise.
+	(bfd_section_already_linked_table_insert): Likewise.
+	(_bfd_generic_section_already_linked): Likewise.  Call
+	_bfd_handle_already_linked.
+	(_bfd_handle_already_linked): New function, split out from..
+	* elflink.c (_bfd_elf_section_already_linked): ..here.  Revert
+	2011-07-09 changes.  Avoid unnecessary strcmp when matching
+	already_linked_list entries.  Match plugin linkonce section.
+	(section_signature): Delete.
+	* coffgen.c (_bfd_coff_section_already_linked): New function.
+	* libcoff-in.h (_bfd_coff_section_already_linked): Declare.
+	* libbfd.h: Regenerate.
+	* libcoff.h: Regenerate.
+	* bfd-in2.h: Regenerate.
+
+2011-08-14  Alan Modra  <[email protected]>
+
+	* elf32-ppc.c (ppc_elf_select_plt_layout): Force bss-plt when
+	shared and call to _mcount will go via plt.
+
+2011-08-14  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c: Prefix all einfo error strings with "%P: ".
+	* elf32-ppc.c: Likewise.
+	(ppc_elf_select_plt_layout): Use einfo rather than info to report
+	forced bss-plt.
+
+2011-08-12  H.J. Lu  <[email protected]>
+
+	PR ld/13082
+	* elf64-x86-64.c (x86_64_elf_howto_table): Add R_X86_64_RELATIVE64.
+	(elf_x86_64_relocate_section): Treat R_X86_64_64 like R_X86_64_32
+	and zero-extend it to 64bit if addend is zero for x32.  Generate
+	R_X86_64_RELATIVE64 for x32.
+
+2011-08-09  Matthew Gretton-Dann  <[email protected]>
+
+	* bfd-in.h (bfd_elf32_arm_set_target_relocs): Update prototype.
+	* bfd-in2.h (bfd_elf32_arm_set_target_relocs): Likewise.
+	* elf32-arm.c (elf32_arm_link_hash_table): New field.
+	(elf232_arm_link_hash_table_create): Initialise new field.
+	(check_use_blx): Change test depending on fix_arm1176.
+	(bfd_elf32_arm_set_target_relocs): Set fix_arm1176 from
+	command line options.
+
+2011-08-08  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (struct mach_o_segment_name_xlat): Add comments.
+	(segsec_names_xlat): Reorder elements.
+	(bfd_mach_o_read_section_32): Fix typo.
+	(bfd_mach_o_read_section_64): Fix typo.
+
+2011-08-08  Tristan Gingold  <[email protected]>
+
+	* mach-o.h (BFD_MACH_O_SEGNAME_SIZE): New macro.
+	(BFD_MACH_O_SECTNAME_SIZE): Ditto.
+	(bfd_mach_o_section): Use them.  Add next field.
+	(bfd_mach_o_segment_command): Replace sections array by
+	sect_head and sect_tail.
+	(bfd_mach_o_get_mach_o_section): New macro.
+	(bfd_mach_o_lookup_section): Remove.
+	(bfd_mach_o_new_section_hook): New function.
+	* mach-o.c (bfd_mach_o_normalize_section_name): Use strncmp
+	instead of strcmp.
+	(bfd_mach_o_convert_section_name_to_bfd): Replaces section
+	parameter with segname and sectname parameters.  Adjust.
+	(bfd_mach_o_append_section_to_segment): New function.  Use a
+	linked list for Mach-O sections.
+	(bfd_mach_o_write_segment_32): Adjust.
+	(bfd_mach_o_write_segment_64): Ditto.
+	(bfd_mach_o_build_commands): Fix comment.  Adjust.
+	(bfd_mach_o_flatten_sections): Adjust.
+	(bfd_mach_o_print_section_map): Adjust.
+	(bfd_mach_o_set_section_flags_from_bfd): Ditto.
+	(bfd_mach_o_new_section_hook): New function.
+	(bfd_mach_o_init_section_from_mach_o): Ditto.
+	(bfd_mach_o_read_section_32): Remove section parameter.
+	Return a section instead.
+	(bfd_mach_o_read_section_64): Ditto.
+	(bfd_mach_o_read_section): Ditto.
+	(bfd_mach_o_make_bfd_section): Adjust.
+	(bfd_mach_o_read_segment): Adjust for new profile of
+	bfd_mach_o_read_section.
+	(bfd_mach_o_lookup_section): Remove.
+	* mach-o-target.c (bfd_mach_o_new_section_hook): Remove.
+
+2011-08-08  Tristan Gingold  <[email protected]>
+
+	* mach-o.h (bfd_mach_o_version_min_command): New structure.
+	(bfd_mach_o_load_command): Add version_min.
+	(mach_o_data_struct): Fix comment.
+	* mach-o.c (bfd_mach_o_read_version_min): New function.
+	(bfd_mach_o_read_command): Handle BFD_MACH_O_LC_FUNCTION_STARTS,
+	BFD_MACH_O_LC_VERSION_MIN_MACOSX and
+	BFD_MACH_O_LC_VERSION_MIN_IPHONEOS.
+	(bfd_mach_o_get_name_or_null): New function.
+	(bfd_mach_o_get_name): Use the above new one.
+	(bfd_mach_o_load_command_name): Add the above new commands.
+	(bfd_mach_o_bfd_print_private_bfd_data): Display numerically
+	unknown commands.  Handle BFD_MACH_O_LC_FUNCTION_STARTS,
+	BFD_MACH_O_LC_VERSION_MIN_MACOSX and
+	BFD_MACH_O_LC_VERSION_MIN_IPHONEOS.
+
+2011-08-08  Tristan Gingold  <[email protected]>
+
+	* mach-o.h: Move size macros to external.h
+	Move reloc macros to reloc.h and x86-64.h.
+	* mach-o-i386.c: Includes mach-o/reloc.h
+	* mach-o-x86-64.c: Ditto and includes mach-o/x86-64.h
+	* mach-o.c: Add includes.
+	(bfd_mach_o_write_header): Use structure from external.h to convert.
+	(bfd_mach_o_write_thread): Ditto.
+	(bfd_mach_o_write_relocs): Ditto.
+	(bfd_mach_o_write_section_32): Ditto.
+	(bfd_mach_o_write_section_64): Ditto.
+	(bfd_mach_o_write_segment_32): Ditto.
+	(bfd_mach_o_write_segment_64): Ditto.
+	(bfd_mach_o_write_symtab): Ditto.
+	(bfd_mach_o_write_contents): Ditto.
+	(bfd_mach_o_read_header): Ditto.
+	(bfd_mach_o_read_section_32): Ditto.
+	(bfd_mach_o_read_section_64): Ditto.
+	(bfd_mach_o_read_symtab_symbol): Ditto.
+	(bfd_mach_o_read_dylinker): Ditto.
+	(bfd_mach_o_read_dylib): Ditto.
+	(bfd_mach_o_read_dysymtab): Ditto.
+	(bfd_mach_o_read_symtab): Ditto.
+	(bfd_mach_o_read_linkedit): Ditto.
+	(bfd_mach_o_read_str): Ditto.
+	(bfd_mach_o_read_dyld_info): Ditto.
+	(bfd_mach_o_read_segment): Ditto.
+	(bfd_mach_o_read_command): Ditto.
+	(bfd_mach_o_archive_p): Ditto.
+	(bfd_mach_o_canonicalize_one_reloc): Ditto. Change the BUF parameter.
+	(bfd_mach_o_canonicalize_relocs): Adjust to call the above function.
+	(bfd_mach_o_read_dysymtab_symbol): Rename BUF variable.
+	(bfd_mach_o_read_uuid): Remove useless cast.  Use a macro instead
+	of an hard-coded value.
+
+2011-08-08  Tristan Gingold  <[email protected]>
+
+	* mach-o-x86-64.c (bfd_mach_o_x86_64_mkobject): Fix cut-and-past typos.
+	(bfd_mach_o_x86_64_swap_reloc_out): Handle BFD_RELOC_32_PCREL,
+	BFD_RELOC_MACH_O_X86_64_SUBTRACTOR64 and
+	BFD_RELOC_MACH_O_X86_64_GOT_LOAD.  Share common code.
+
+2011-08-08  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_normalize_section_name): New function.
+	(bfd_mach_o_convert_section_name_to_bfd): Use it.
+	(bfd_mach_o_get_section_type_from_name): New function.
+	(bfd_mach_o_get_section_attribute_from_name): Ditto.
+	* mach-o.h (bfd_mach_o_section): Move bfdsection field at the end.
+	Add comments.  Add prototypes for the above new functions.
+
+2011-08-05  Mark Kettenis  <[email protected]>
+
+	* netbsd-core.c (netbsd_core_vec): Init match_priority field.
+
+2011-08-05  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (maybe_strip_output): New function.
+	(ppc64_elf_size_stubs): Use it to strip .branch_lt and .eh_frame.
+
+2011-08-05  Alan Modra  <[email protected]>
+
+	PR ld/12762
+	* elflink.c (_bfd_elf_section_already_linked): Return matched
+	status.  Remove COFF comdat section handling.
+	* linker.c (_bfd_generic_section_already_linked): Return matched
+	status.  Don't set SEC_GROUP in l_flags for plugin entries.
+	(bfd_section_already_linked): Update prototype.
+	* targets.c (_section_already_linked): Likewise.
+	* elf-bfd.h (_bfd_elf_section_already_linked): Likewise.
+	* libbfd-in.h (_bfd_generic_section_already_linked): Likewise.
+	(_bfd_nolink_section_already_linked): Update.
+	* libbfd.h: Regenerate.
+	* bfd-in2.h: Regenerate.
+
+2011-08-05  Alan Modra  <[email protected]>
+
+	* elf32-ppc.c: Include dwarf2.h.
+	(struct ppc_elf_link_hash_table): Add glink_eh_frame.
+	(ppc_elf_create_glink): Create .eh_frame section.
+	(glink_eh_frame_cie): New array.
+	(ppc_elf_size_dynamic_sections): Size glink_eh_frame.
+	(ppc_elf_finish_dynamic_sections): Write glink_eh_frame.
+
+2011-08-04  Tristan Gingold  <[email protected]>
+
+	* vms-alpha.c (_bfd_vms_write_eeom): Round vms_linkage_index.
+	(_bfd_vms_write_etir): Initialize vms_linkage_index to 0.
+
+2011-08-03  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_canonicalize_symtab): Handle no symbols case.
+	(bfd_mach_o_read_symtab_symbols): Return if no symbols.
+
+2011-08-02  Maciej W. Rozycki  <[email protected]>
+
+	* elfxx-mips.c (check_4byte_branch): Remove function.
+	(check_relocated_bzc): New function.
+	(_bfd_mips_elf_relax_section): Permit the relaxation of LUI
+	instructions that immediately follow a compact branch
+	instruction.
+
+2011-08-02  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (build_plt_stub): Correct emitted relocs when no
+	plt_static_chain.
+	(ppc_build_one_stub): Adjust get_relocs call to suit..
+	(ppc_size_one_stub): ..and reloc sizing.  Correct plt size corner case.
+
+2011-08-01  H.J. Lu  <[email protected]>
+
+	PR ld/13048
+	* archures.c (bfd_mach_i386_intel_syntax): New.
+	(bfd_mach_i386_i8086): Updated.
+	(bfd_mach_i386_i386): Likewise.
+	(bfd_mach_x86_64): Likewise.
+	(bfd_mach_x64_32): Likewise.
+	(bfd_mach_i386_i386_intel_syntax): Likewise.
+	(bfd_mach_x86_64_intel_syntax): Likewise.
+	(bfd_mach_x64_32_intel_syntax): Likewise.
+	(bfd_mach_l1om): Likewise.
+	(bfd_mach_l1om_intel_syntax): Likewise.
+	(bfd_mach_k1om): Likewise.
+	(bfd_mach_k1om_intel_syntax): Likewise.
+
+	* bfd-in2.h: Regenerated.
+
+	* cpu-i386.c (bfd_i386_compatible): Check mach instead of
+	bits_per_address.
+	(bfd_x64_32_arch_intel_syntax): Set bits_per_address to 64.
+	(bfd_x64_32_arch): Likewise.
+
+	* elf64-x86-64.c: Include "libiberty.h".
+	(x86_64_elf_howto_table): Append x32 R_X86_64_32.
+	(elf_x86_64_rtype_to_howto): Support x32 R_X86_64_32.
+	(elf_x86_64_reloc_type_lookup): Likewise.
+	(elf_x86_64_reloc_name_lookup): Likewise.
+	(elf_x86_64_relocate_section): Likewise.
+	(elf_x86_64_check_relocs): Allow R_X86_64_64 relocations for x32.
+
+2011-07-29  Maciej W. Rozycki  <[email protected]>
+
+	* elfxx-mips.c (check_br32): Fix return type.
+
+2011-07-29  Maciej W. Rozycki  <[email protected]>
+
+	* elfxx-mips.c (bz_insn_16): Correct opcode mask.
+
+2011-07-29  Maciej W. Rozycki  <[email protected]>
+
+	* elfxx-mips.c: Adjust comments throughout.
+	(mips_elf_relax_delete_bytes): Reshape code.
+	(_bfd_mips_elf_relax_section): Remove check for
+	R_MICROMIPS_GPREL16 relocations.  Reshape code.
+
+2011-07-28  Roland McGrath  <[email protected]>
+
+	* elf32-i386.c (NACL_PLT_ENTRY_SIZE, NACLMASK): New macros.
+	(elf_i386_nacl_plt0_entry): New variable.
+	(elf_i386_plt_entry): New variable.
+	(elf_i386_nacl_pic_plt0_entry): New variable.
+	(elf_i386_nacl_pic_plt_entry): New variable.
+	(elf_i386_nacl_plt, elf_i386_nacl_arch_bed): New variables.
+	(elf_backend_arch_data): New macro setting for elf_i386_nacl_vec stanza.
+	(elf_backend_plt_alignment): Likewise.
+
+	* config.bfd: Handle i[3-7]86-*-nacl*.
+	* elf32-i386.c (bfd_elf32_i386_nacl_vec): New backend vector stanza.
+	* targets.c: Support bfd_elf32_i386_nacl_vec.
+	* configure.in: Likewise.
+	* configure: Regenerated.
+
+	* elf32-i386.c (struct elf_i386_plt_layout): New type.
+	(GET_PLT_ENTRY_SIZE): New macro.
+	(elf_i386_plt): New variable.
+	(struct elf_i386_backend_data): New member `plt'.
+	(elf_i386_arch_bed): Add initializer for it.
+	(elf_i386_vxworks_arch_bed): Likewise.
+	(elf_i386_allocate_dynrelocs): Use GET_PLT_ENTRY_SIZE.
+	(elf_i386_plt_sym_val): Likewise.
+	(elf_i386_relocate_section): Likewise.
+	(elf_i386_finish_dynamic_symbol): Likewise.
+	Also use other elf_i386_plt_layout members for PLT details.
+	(elf_i386_finish_dynamic_sections): Likewise.
+
+	* elf32-i386.c (struct elf_i386_backend_data): New type.
+	(get_elf_i386_backend_data): New macro.
+	(elf_i386_arch_bed): New variable.
+	(elf_backend_arch_data): New macro.
+	(struct elf_i386_link_hash_table): Remove plt0_pad_byte and is_vxworks.
+	(elf_i386_link_hash_table_create): Don't initialize them.
+	(elf_i386_create_dynamic_sections): Find is_vxworks flags in
+	elf_i386_backend_data, not elf_i386_link_hash_table.
+	(elf_i386_adjust_dynamic_symbol): Likewise.
+	(elf_i386_allocate_dynrelocs): Likewise.
+	(elf_i386_readonly_dynrelocs): Likewise.
+	(elf_i386_size_dynamic_sections): Likewise.
+	(elf_i386_relocate_section): Likewise.
+	(elf_i386_finish_dynamic_symbol): Likewise.
+	(elf_i386_finish_dynamic_sections): Likewise.  Same for plt0_pad_byte.
+	(elf_i386_vxworks_link_hash_table_create): Function removed.
+	(elf_i386_vxworks_arch_bed): New variable.
+	(elf_backend_arch_data): New macro in elf32-i386-vxworks stanza.
+
+	* elf-bfd.h (elf_backend_data): New member arch_backend_data.
+	* elfxx-target.h (elf_backend_arch_data): New macro.
+	(elfNN_bed): Use it as initializer for the new member.
+
+2011-07-28  Mikulas Patocka  <[email protected]>
+
+	* elf64-hppa.c (elf_hppa_final_link_relocate): Fix handling of out
+	of range branches.
+
+2011-07-26  Jakub Jelinek  <[email protected]>
+
+	* dwarf2.c (dwarf_debug_sections): Add .debug_macro
+	and .zdebug_macro entry.
+	(dwarf_debug_section_enum): Add debug_macro.
+
+2011-07-26  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c: Include dwarf2.h.
+	(struct ppc_link_hash_table): Add glink_eh_frame.
+	(create_linkage_sections): Create .eh_frame section.
+	(ppc64_elf_size_dynamic_sections): Arrange to drop unneeded
+	glink_eh_frame.
+	(glink_eh_frame_cie): New array.
+	(ppc64_elf_size_stubs): Size glink_eh_frame.
+	(ppc64_elf_build_stubs): Init glink_eh_frame contents.
+	(ppc64_elf_finish_dynamic_sections): Write glink_eh_frame.
+
+2011-07-25  Hans-Peter Nilsson  <[email protected]>
+
+	PR ld/12815
+	* elf64-mmix.c (struct _mmix_elf_section_data): New members
+	has_warned_bpo and has_warned_pushj.
+	(mmix_final_link_relocate): Remove PARAMS and PTR macros,
+	converting to ISO C.  Add new parameter error_message.  All
+	callers changed.
+	(mmix_elf_perform_relocation): Ditto.
+	<case R_MMIX_PUSHJ_STUBBABLE, case R_MMIX_BASE_PLUS_OFFSET>:
+	Handle the case where mmix_elf_check_common_relocs has not been
+	called, missing preparations for relocs of the respective type.
+
+2011-07-24  Chao-ying Fu  <[email protected]>
+	    Ilie Garbacea  <[email protected]>
+	    Maciej W. Rozycki  <[email protected]>
+	    Joseph Myers  <[email protected]>
+	    Catherine Moore  <[email protected]>
+	    Richard Sandiford  <[email protected]>
+
+	* archures.c (bfd_mach_mips_micromips): New macro.
+	* cpu-mips.c (I_micromips): New enum value.
+	(arch_info_struct): Add bfd_mach_mips_micromips.
+	* elfxx-mips.h (_bfd_mips_elf_is_target_special_symbol): New
+	prototype.
+	(_bfd_mips_elf_relax_section): Likewise.
+	(_bfd_mips16_elf_reloc_unshuffle): Rename to...
+	(_bfd_mips_elf_reloc_unshuffle): ... this.  Handle microMIPS
+	ASE.
+	(_bfd_mips16_elf_reloc_shuffle): Rename to...
+	(_bfd_mips_elf_reloc_shuffle): ... this.  Handle microMIPS ASE.
+	(gprel16_reloc_p): Handle microMIPS ASE.
+	(literal_reloc_p): New function.
+	* elf32-mips.c (elf_micromips_howto_table_rel): New variable.
+	(_bfd_mips_elf32_gprel16_reloc): Handle microMIPS ASE.
+	(mips16_gprel_reloc): Update for _bfd_mips_elf_reloc_unshuffle
+	and _bfd_mips_elf_reloc_shuffle changes.
+	(mips_elf_gprel32_reloc): Update comment.
+	(micromips_reloc_map): New variable.
+	(bfd_elf32_bfd_reloc_type_lookup): Handle microMIPS ASE.
+	(mips_elf32_rtype_to_howto): Likewise.
+	(mips_info_to_howto_rel): Likewise.
+	(bfd_elf32_bfd_is_target_special_symbol): Define.
+	(bfd_elf32_bfd_relax_section): Likewise.
+	* elf64-mips.c (micromips_elf64_howto_table_rel): New variable.
+	(micromips_elf64_howto_table_rela): Likewise.
+	(mips16_gprel_reloc): Update for _bfd_mips_elf_reloc_unshuffle
+	and _bfd_mips_elf_reloc_shuffle changes.
+	(micromips_reloc_map): Likewise.
+	(bfd_elf64_bfd_reloc_type_lookup): Handle microMIPS ASE.
+	(bfd_elf64_bfd_reloc_name_lookup): Likewise.
+	(mips_elf64_rtype_to_howto): Likewise.
+	(bfd_elf64_bfd_is_target_special_symbol): Define.
+	* elfn32-mips.c (elf_micromips_howto_table_rel): New variable.
+	(elf_micromips_howto_table_rela): Likewise.
+	(mips16_gprel_reloc): Update for _bfd_mips_elf_reloc_unshuffle
+	and _bfd_mips_elf_reloc_shuffle changes.
+	(micromips_reloc_map): Likewise.
+	(bfd_elf32_bfd_reloc_type_lookup): Handle microMIPS ASE.
+	(bfd_elf32_bfd_reloc_name_lookup): Likewise.
+	(mips_elf_n32_rtype_to_howto): Likewise.
+	(bfd_elf32_bfd_is_target_special_symbol): Define.
+	* elfxx-mips.c (LA25_LUI_MICROMIPS_1): New macro.
+	(LA25_LUI_MICROMIPS_2): Likewise.
+	(LA25_J_MICROMIPS_1, LA25_J_MICROMIPS_2): Likewise.
+	(LA25_ADDIU_MICROMIPS_1, LA25_ADDIU_MICROMIPS_2): Likewise.
+	(TLS_RELOC_P): Handle microMIPS ASE.
+	(mips_elf_create_stub_symbol): Adjust value of stub symbol if
+	target is a microMIPS function.
+	(micromips_reloc_p): New function.
+	(micromips_reloc_shuffle_p): Likewise.
+	(got16_reloc_p, call16_reloc_p): Handle microMIPS ASE.
+	(got_disp_reloc_p, got_page_reloc_p): New functions.
+	(got_ofst_reloc_p): Likewise.
+	(got_hi16_reloc_p, got_lo16_reloc_p): Likewise.
+	(call_hi16_reloc_p, call_lo16_reloc_p): Likewise.
+	(hi16_reloc_p, lo16_reloc_p, jal_reloc_p): Handle microMIPS ASE.
+	(micromips_branch_reloc_p): New function.
+	(tls_gd_reloc_p, tls_ldm_reloc_p): Likewise.
+	(tls_gottprel_reloc_p): Likewise.
+	(_bfd_mips16_elf_reloc_unshuffle): Rename to...
+	(_bfd_mips_elf_reloc_unshuffle): ... this.  Handle microMIPS
+	ASE.
+	(_bfd_mips16_elf_reloc_shuffle): Rename to...
+	(_bfd_mips_elf_reloc_shuffle): ... this.  Handle microMIPS ASE.
+	(_bfd_mips_elf_lo16_reloc): Handle microMIPS ASE.
+	(mips_tls_got_index, mips_elf_got_page): Likewise.
+	(mips_elf_create_local_got_entry): Likewise.
+	(mips_elf_relocation_needs_la25_stub): Likewise.
+	(mips_elf_calculate_relocation): Likewise.
+	(mips_elf_perform_relocation): Likewise.
+	(_bfd_mips_elf_symbol_processing): Likewise.
+	(_bfd_mips_elf_add_symbol_hook): Likewise.
+	(_bfd_mips_elf_link_output_symbol_hook): Likewise.
+	(mips_elf_add_lo16_rel_addend): Likewise.
+	(_bfd_mips_elf_check_relocs): Likewise.
+	(mips_elf_adjust_addend): Likewise.
+	(_bfd_mips_elf_relocate_section): Likewise.
+	(mips_elf_create_la25_stub): Likewise.
+	(_bfd_mips_vxworks_finish_dynamic_symbol): Likewise.
+	(_bfd_mips_elf_gc_sweep_hook): Likewise.
+	(_bfd_mips_elf_is_target_special_symbol): New function.
+	(mips_elf_relax_delete_bytes): Likewise.
+	(opcode_descriptor): New structure.
+	(RA): New macro.
+	(OP32_SREG, OP32_TREG, OP16_VALID_REG): Likewise.
+	(b_insns_32, bc_insn_32, bz_insn_32, bzal_insn_32): New variables.
+	(beq_insn_32): Likewise.
+	(b_insn_16, bz_insn_16): New variables.
+	(BZC32_REG_FIELD): New macro.
+	(bz_rs_insns_32, bz_rt_insns_32): New variables.
+	(bzc_insns_32, bz_insns_16):Likewise.
+	(BZ16_REG, BZ16_REG_FIELD): New macros.
+	(jal_insn_32_bd16, jal_insn_32_bd32): New variables.
+	(jal_x_insn_32_bd32): Likewise.
+	(j_insn_32, jalr_insn_32): Likewise.
+	(ds_insns_32_bd16, ds_insns_32_bd32): Likewise.
+	(jalr_insn_16_bd16, jalr_insn_16_bd32, jr_insn_16): Likewise.
+	(JR16_REG): New macro.
+	(ds_insns_16_bd16): New variable.
+	(lui_insn): Likewise.
+	(addiu_insn, addiupc_insn): Likewise.
+	(ADDIUPC_REG_FIELD): New macro.
+	(MOVE32_RD, MOVE32_RS): Likewise.
+	(MOVE16_RD_FIELD, MOVE16_RS_FIELD): Likewise.
+	(move_insns_32, move_insns_16): New variables.
+	(nop_insn_32, nop_insn_16): Likewise.
+	(MATCH): New macro.
+	(find_match): New function.
+	(check_br16_dslot, check_br32_dslot): Likewise.
+	(check_br16, check_br32): Likewise.
+	(IS_BITSIZE): New macro.
+	(check_4byte_branch): New function.
+	(_bfd_mips_elf_relax_section): Likewise.
+	(_bfd_mips_elf_merge_private_bfd_data): Disallow linking MIPS16
+	and microMIPS modules together.
+	(_bfd_mips_elf_print_private_bfd_data):	Handle microMIPS ASE.
+	* reloc.c (BFD_RELOC_MICROMIPS_7_PCREL_S1): New relocation.
+	(BFD_RELOC_MICROMIPS_10_PCREL_S1): Likewise.
+	(BFD_RELOC_MICROMIPS_16_PCREL_S1): Likewise.
+	(BFD_RELOC_MICROMIPS_GPREL16): Likewise.
+	(BFD_RELOC_MICROMIPS_JMP, BFD_RELOC_MICROMIPS_HI16): Likewise.
+	(BFD_RELOC_MICROMIPS_HI16_S): Likewise.
+	(BFD_RELOC_MICROMIPS_LO16): Likewise.
+	(BFD_RELOC_MICROMIPS_LITERAL): Likewise.
+	(BFD_RELOC_MICROMIPS_GOT16): Likewise.
+	(BFD_RELOC_MICROMIPS_CALL16): Likewise.
+	(BFD_RELOC_MICROMIPS_GOT_HI16): Likewise.
+	(BFD_RELOC_MICROMIPS_GOT_LO16): Likewise.
+	(BFD_RELOC_MICROMIPS_CALL_HI16): Likewise.
+	(BFD_RELOC_MICROMIPS_CALL_LO16): Likewise.
+	(BFD_RELOC_MICROMIPS_SUB): Likewise.
+	(BFD_RELOC_MICROMIPS_GOT_PAGE): Likewise.
+	(BFD_RELOC_MICROMIPS_GOT_OFST): Likewise.
+	(BFD_RELOC_MICROMIPS_GOT_DISP): Likewise.
+	(BFD_RELOC_MICROMIPS_HIGHEST): Likewise.
+	(BFD_RELOC_MICROMIPS_HIGHER): Likewise.
+	(BFD_RELOC_MICROMIPS_SCN_DISP): Likewise.
+	(BFD_RELOC_MICROMIPS_JALR): Likewise.
+	(BFD_RELOC_MICROMIPS_TLS_GD): Likewise.
+	(BFD_RELOC_MICROMIPS_TLS_LDM): Likewise.
+	(BFD_RELOC_MICROMIPS_TLS_DTPREL_HI16): Likewise.
+	(BFD_RELOC_MICROMIPS_TLS_DTPREL_LO16): Likewise.
+	(BFD_RELOC_MICROMIPS_TLS_GOTTPREL): Likewise.
+	(BFD_RELOC_MICROMIPS_TLS_TPREL_HI16): Likewise.
+	(BFD_RELOC_MICROMIPS_TLS_TPREL_LO16): Likewise.
+	* bfd-in2.h: Regenerate.
+	* libbfd.h: Regenerate.
+
+2011-07-22  H.J. Lu  <[email protected]>
+
+	* Makefile.am (ALL_MACHINES): Add cpu-k1om.lo.
+	(ALL_MACHINES_CFILES): Add cpu-k1om.c.
+	* Makefile.in: Regenerated.
+
+	* archures.c (bfd_architecture): Add bfd_arch_k1om.
+	(bfd_k1om_arch): New.
+	(bfd_archures_list): Add &bfd_k1om_arch.
+	* bfd-in2.h: Regenerated.
+
+	* config.bfd (targ64_selvecs): Add bfd_elf64_k1om_vec if
+	bfd_elf64_x86_64_vec is supported.  Add bfd_elf64_k1om_freebsd_vec
+	if bfd_elf64_x86_64_freebsd_vec is supported.
+	(targ_selvecs): Likewise.
+
+	* configure.in: Support bfd_elf64_k1om_vec and
+	bfd_elf64_k1om_freebsd_vec.
+	* configure: Regenerated.
+
+	* cpu-k1om.c: New.
+
+	* elf64-x86-64.c (elf64_k1om_elf_object_p): New.
+	(bfd_elf64_k1om_vec): Likewise.
+	(bfd_elf64_k1om_freebsd_vec): Likewise.
+
+	* targets.c (bfd_elf64_k1om_vec): New.
+	(bfd_elf64_k1om_freebsd_vec): Likewise.
+	(_bfd_target_vector): Add bfd_elf64_k1om_vec and
+	bfd_elf64_k1om_freebsd_vec.
+
+2011-07-20  Jan Kratochvil  <[email protected]>
+
+	Fix false coff-go32-exe matches.
+	* coff-i386.c (TARGET_SYM) <_bfd_check_format>: Conditionally use
+	COFF_CHECK_FORMAT.
+	* coff-stgo32.c (go32_check_format): New forward declaration.
+	(COFF_CHECK_FORMAT): New defintion.
+	(go32_check_format): New function.
+
+2011-07-15  Alan Modra  <[email protected]>
+
+	* configure.in: Bump version.
+	* configure: Regenerate.
+
+2011-07-14  Alan Modra  <[email protected]>
+
+	* linker.c (_bfd_generic_section_already_linked): Set l_flags.
+	* elf-bfd.h (struct already_linked): Forward declare.
+
+2011-07-14  Alan Modra  <[email protected]>
+
+	* elflink.c (_bfd_elf_fix_symbol_flags): Loop on indirect syms.
+	(_bfd_elf_adjust_dynamic_symbol): Remove FIXME.
+
+2011-07-14  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (struct ppc_link_hash_table): Add plt_static_chain.
+	(build_plt_stub): Add plt_static_chain param, don't load r11 if false.
+	(build_tls_get_addr_stub): Likewise.
+	(ppc_build_one_stub): Update calls to above.
+	(ppc_size_one_stub): Adjust stub size.
+	(ppc64_elf_size_stubs): Add plt_static_chain param, save to htab.
+	* elf64-ppc.h (ppc64_elf_size_stubs): Update prototype.
+
+2011-07-12  Nick Clifton  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_section_flags): Delete.
+	(elf_backend_section_flags): Remove.
+
+2011-07-11  H.J. Lu  <[email protected]>
+
+	PR ld/12982
+	* elflink.c (bfd_elf_size_dynamic_sections): Also skip BFD_PLUGIN
+	when setting stack_flags.
+
+2011-07-11  Catherine Moore  <[email protected]>
+
+	* aout-adobe.c (aout_32_bfd_lookup_section_flags): New definition.
+	* aout-target.h (MY_bfd_lookup_section_flags): New definition.
+	* aout-tic30.c (MY_bfd_lookup_section_flags): New definition.
+	* bfd-in2.h: Regenerated.
+	* bfd.c (bfd_lookup_section_flags): New definition.
+	* binary.c (binary_bfd_lookup_section_flags): New definition.
+	* bout.c (b_out_bfd_lookup_section_flags): New definition.
+	* coff-alpha.c (_bfd_ecoff_bfd_lookup_section_flags): New definition.
+	* coff-mips.c (_bfd_ecoff_bfd_lookup_section_flags): New definition.
+	* coff-rs6000.c (rs6000coff_vec): Include
+	bfd_generic_lookup_section_flags.
+	(pmac_xcoff_vec): Likewise.
+	* coffcode.h (coff_bfd_lookup_section_flags): New definition.
+	* coff64-rs6000.c (rs6000coff64_vec): Include
+	bfd_generic_lookup_section_flags.
+	(aix5coff64_vec): Likewise.
+	* ecoff.c (bfd_debug_section): Initialize flag_info field.
+	* elf-bfd.h (elf_backend_lookup_section_flags_hook): Declare.
+	(bfd_elf_lookup_section_flags): Declare.
+	* elflink.c (bfd_elf_lookup_section_flags): New function.
+	* elfxx-target.h (bfd_elfNN_bfd_lookup_section_flags): Define.
+	(elf_backend_lookup_section_flags_hook): Define.
+	(elf_backend_data): Add elf_backend_lookup_section_flags_hook.
+	* i386msdos.c (msdos_bfd_lookup_section_flags): New define.
+	* i386os9k.c (os9k_bfd_lookup_section_flags): New define.
+	* ieee.c (ieee_bfd_lookup_section_flags): New define.
+	* ihex.c (ihex_bfd_lookup_section_flags): New define.
+	* libbfd-in.h (_bfd_nolink_bfd_lookup_section_flags): Declare.
+	(bfd_generic_lookup_section_flags): Declare.
+	* libbfd.h: Regenerated.
+	* mach-o-target.c (bfd_mach_o_bfd_lookup_section_flags): New.
+	* mmo.c (mmo_bfd_lookup_section_flags): New definition.
+	* nlm-target.h (nlm_bfd_lookup_section_flags): New definition.
+	* oasys.c (oasys_bfd_lookup_section_flags): New definition.
+	* pef.c (bfd_pef_bfd_lookup_section_flags): New definition.
+	* plugin.c (bfd_plugin_bfd_lookup_section_flags): New definition.
+	* ppcboot.c (ppcboot_bfd_lookup_section_flags): New definition.
+	* reloc.c (bfd_generic_lookup_section_flags): New function.
+	* som.c (som_bfd_lookup_section_flags): New definition.
+	* srec.c (srec_bfd_lookup_section_flags): New definition.
+	* targets.c (flag_info): Declare.
+	(NAME##_bfd_lookup_section_flags): Add to LINK jump table.
+	(_bfd_lookup_section_flags): New.
+	* tekhex.c (tekhex_bfd_lookup_section_flags): New definition.
+	* versados.c (versados_bfd_lookup_section_flags): New definition.
+	* vms-alpha.c (alpha_vms_bfd_lookup_section_flag): New definition.
+	* xsym.c (bfd_sym_bfd_lookup_section_flags): New definition.
+
+2011-07-11  H.J. Lu  <[email protected]>
+
+	PR ld/12978
+	* elfnn-ia64.c (count_dyn_reloc): Fix a typo.
+
+2011-07-09  Alan Modra  <[email protected]>
+
+	PR ld/12942
+	* elflink.c (elf_link_add_object_symbols): Use elf_discarded_section
+	rather than kept_section to determine whether a symbol is from
+	a discarded section.
+	* cofflink.c (coff_link_add_symbols): Make symbols from discarded
+	sections appear undefined.
+
+2011-07-09  H.J. Lu  <[email protected]>
+
+	PR ld/12942
+	* elf-bfd.h (_bfd_elf_section_already_linked): Replace
+	"asection *" with "struct already_linked *".
+	* libbfd-in.h (_bfd_nolink_section_already_linked): Likewise.
+	(_bfd_generic_section_already_linked): Likewise.
+	(bfd_section_already_linked_table_insert): Likewise.
+	(struct already_linked): New.
+	(struct bfd_section_already_linked): Use it.
+	* elflink.c (_bfd_elf_section_already_linked): Replace.
+	"asection *" with "struct already_linked *".  Replace the plugin
+	dummy with the LTO output.
+	* linker.c (_bfd_generic_section_already_linked): Likewise.
+	* targets.c (struct already_linked): Add forward declaration.
+	(bfd_target): Replace "struct bfd_section *" with
+	"struct already_linked *" in _section_already_linked.
+	* bfd-in2.h: Regenerate.
+	* libbfd.h: Regenerate.
+
+2011-07-06  Tristan Gingold  <[email protected]>
+
+	* mach-o.h: Move loader related definitions to
+	include/mach-o/loader.h.  Include it.
+
+2011-07-05  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (elf_backend_post_process_headers): Always
+	define to _bfd_elf_set_osabi.
+
+2011-07-03  Samuel Thibault  <[email protected]>
+	    Thomas Schwinge  <[email protected]>
+
+	PR binutils/12913
+	* elf.c (_bfd_elf_set_osabi): Use ELFOSABI_GNU name instead of
+	ELFOSABI_LINUX alias.
+	* elf32-hppa.c: Likewise.
+	* elf32-i370.c: Likewise.
+	* elf64-hppa.c: Likewise.
+
+2011-07-01  Ian Lance Taylor  <[email protected]>
+
+	* elf32-i386.c (elf_i386_eh_frame_plt): Correct expression: change
+	DW_OP_lit3 to DW_OP_lit2.
+
+2011-07-01  Alan Modra  <[email protected]>
+
+	* elf32-ppc.c (ppc_elf_copy_indirect_symbol): Don't look at
+	dyn relocs when called to copy flags for a weak sym.
+	* elf64-ppc.c (ppc64_elf_copy_indirect_symbol): Likewise.
+	(ppc64_elf_merge_private_bfd_data): Delete.
+	(bfd_elf64_bfd_merge_private_bfd_data): Define as
+	_bfd_generic_verify_endian_match.
+
+2011-06-30  Bernd Schmidt  <[email protected]>
+
+	* bfd/elf32-tic6x.c (elf32_tic6x_set_osabi): Also set it if
+	link_info is NULL.
+
+2011-06-28  Tristan Gingold  <[email protected]>
+
+	* vms-alpha.c (vms_private_data_struct): Make vms_linkage_index
+	unsigned int.
+	(_bfd_vms_write_etir): Write linkage index from reloc.
+
+2011-06-28  Fawzi Mohamed <[email protected]>
+
+	* mach-o.c (bfd_mach_o_read_command): Also ignore
+	BFD_MACH_O_LC_ROUTINES_64.
+
+2011-06-27  Tristan Gingold  <[email protected]>
+
+	* vms-alpha.c (_bfd_vms_write_etir): Use 'section' to get current
+	section target index.
+
+2011-06-27  Nick Clifton  <[email protected]>
+
+	* cisco-core.c (cisco_core_little_vec): Add initialization of
+	match_priority field.
+
+2011-06-27  Tristan Gingold  <[email protected]>
+
+	* cache.c: Include bfd_stdint.h.
+	(cache_bmmap): Change profile.  Return region start and size.
+	* bfdio.c (struct bfd_iovec): Change bmmap profile.
+	(bfd_mmap): Change profile and adjust.   Update comment.
+	(memory_bmmap): Change profile.
+	* opncls.c (opncls_bmmap): Change profile.
+	* vms-lib.c (vms_lib_bmmap): Likewise.
+	* libbfd.h: Regenerate.
+	* bfd-in2.h: Regenerate.
+
+2011-06-27  Tristan Gingold  <[email protected]>
+
+	* vms-misc.c (vms_time_to_time_t): Adjust overflow detection.
+	Add comment.
+
+2011-06-25  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (elf_backend_post_process_headers): Don't
+	define for FreeBSD/x86-64 nor FreeBSD/L1OM.  Define for L1OM.
+
+2011-06-25  Jan Kratochvil  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_link_hash_table_create): Initialize
+	PLT_EH_FRAME.
+	* elf32-i386.c (elf_i386_link_hash_table): Likewise.
+
+2011-06-24  Richard Henderson  <[email protected]>
+
+	PR ld/12928
+	* elf64-alpha.c (elf64_alpha_relax_tls_get_addr): Recover the
+	tlsgd insn before swapping adjacent insns.
+
+2011-06-24  Tristan Gingold  <[email protected]>
+
+	* vms-alpha.c (alpha_vms_slurp_relocs): Add a guard for relocs in the
+	absolute section.
+
+2011-06-24  Alan Modra  <[email protected]>
+
+	PR ld/12921
+	* elf.c (assign_file_positions_for_load_sections): Don't align
+	sh_offset for all SHT_NOBITS sections here, just .tbss sections
+	that don't get a PT_LOAD.
+
+2011-06-22  Kaz Kojima  <[email protected]>
+
+	* elf32-sh.c (sh_elf_relocate_section): Allow R_SH_TLS_LE_32 for PIE.
+	(sh_elf_check_relocs): Likewise.
+
+2011-06-22  Richard Henderson  <[email protected]>
+
+	* elf64-alpha.c (elf64_alpha_check_relocs): No dynamic reloc for
+	TPREL in a PIE image.
+	(alpha_dynamic_entries_for_reloc): Likewise.
+	(elf64_alpha_relocate_section): Allow TPREL in PIE images.
+	(elf64_alpha_relax_got_load): Likewise.
+
+2011-06-22  Ramana Radhakrishnan  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_final_link_relocate): Allow R_ARM_TLS_LE32
+	for PIE.
+
+2011-06-22  Alan Modra  <[email protected]>
+
+	* elflink.c (_bfd_elf_merge_symbol): Allow type changes for
+	plugin symbols.  Fix segfault on linker scrip defined syms.
+
+2011-06-20  Jakub Jelinek  <[email protected]>
+
+	PR ld/12570
+	* elf-eh-frame.c (_bfd_elf_parse_eh_frame): Allow no relocations
+	at all for linker created .eh_frame sections.
+	(_bfd_elf_discard_section_eh_frame): Handle linker created
+	.eh_frame sections with no relocations.
+	* elf64-x86-64.c: Include dwarf2.h.
+	(elf_x86_64_eh_frame_plt): New variable.
+	(PLT_CIE_LENGTH, PLT_FDE_LENGTH, PLT_FDE_START_OFFSET,
+	PLT_FDE_LEN_OFFSET): Define.
+	(struct elf_x86_64_link_hash_table): Add plt_eh_frame field.
+	(elf_x86_64_create_dynamic_sections): Create and fill in
+	.eh_frame section for .plt section.
+	(elf_x86_64_size_dynamic_sections): Write .plt section size
+	into .eh_frame FDE covering .plt section.
+	(elf_x86_64_finish_dynamic_sections): Write .plt section
+	start into .eh_frame FDE covering .plt section.  Call
+	_bfd_elf_write_section_eh_frame on htab->plt_eh_frame section.
+	(elf_backend_plt_alignment): Define to 4.
+	* elf32-i386.c: Include dwarf2.h.
+	(elf_i386_eh_frame_plt): New variable.
+	(PLT_CIE_LENGTH, PLT_FDE_LENGTH, PLT_FDE_START_OFFSET,
+	PLT_FDE_LEN_OFFSET): Define.
+	(struct elf_i386_link_hash_table): Add plt_eh_frame field.
+	(elf_i386_create_dynamic_sections): Create and fill in
+	.eh_frame section for .plt section.
+	(elf_i386_size_dynamic_sections): Write .plt section size
+	into .eh_frame FDE covering .plt section.
+	(elf_i386_finish_dynamic_sections): Write .plt section
+	start into .eh_frame FDE covering .plt section.  Call
+	_bfd_elf_write_section_eh_frame on htab->plt_eh_frame section.
+	(elf_backend_plt_alignment): Define to 4.
+
+2011-06-19  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (elf_backend_post_process_headers): Defined
+	for x32.
+
+2011-06-16  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c: Include <stdarg.h> and CORE_HEADER if
+	CORE_HEADER is defined.
+	(elf_x86_64_write_core_note): New.
+	(elf_backend_write_core_note): Likewise.
+
+	* hosts/x86-64linux.h (uint64_t): New.
+	(user_regsx32_struct): Likewise.
+	(elf_gregx32_t): Likewise.
+	(ELF_NGREGX32): Likewise.
+	(elf_gregsetx32_t): Likewise.
+	(elf_prstatusx32): Likewise.
+	(prstatusx32_t): Likewise.
+	(user_fpregs32_struct): Removed.
+	(user_fpxregs32_struct): Likewise.
+	(user32): Likewise.
+	(elf_fpregset32_t): Likewise.
+	(elf_fpxregset32_t): Likewise.
+	(prgregset32_t): Likewise.
+	(prfpregset32_t): Likewise.
+
+2011-06-16  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_grok_prstatus): Support x32.
+	(elf_x86_64_grok_psinfo): Likewise.
+
+2011-06-16  Nick Clifton  <[email protected]>
+
+	* elf.c (elf_find_function): Fail if not provided with a symbol
+	table.
+
+2011-06-15  Ulrich Weigand  <[email protected]>
+
+	* elf-bfd.h (elfcore_write_arm_vfp): Add prototype.
+	* elf.c (elfcore_grok_arm_vfp): New function.
+	(elfcore_grok_note): Call it to handle NT_ARM_VFP notes.
+	(elfcore_write_arm_vfp): New function.
+	(elfcore_write_register_note): Call it to handle .reg-arm-vfp.
+
+2011-06-14  Richard Henderson  <[email protected]>
+
+	* elf64-alpha.c (elf64_alpha_copy_indirect_symbol): Rename from
+	elf64_alpha_merge_ind_symbols; adjust for the generic interface.
+	(elf64_alpha_always_size_sections): Don't call
+	elf64_alpha_merge_ind_symbols.
+	(elf_backend_copy_indirect_symbol): New.
+
+2011-06-14  Alan Modra  <[email protected]>
+
+	PR ld/12887
+	* elf-eh-frame.c (_bfd_elf_parse_eh_frame): Check sec_info_type
+	before doing anything.
+	(_bfd_elf_discard_section_eh_frame): Likewise.
+
+2011-06-14  Alan Modra  <[email protected]>
+
+	* Makefile.am: Formatting.
+	* Makefile.in: Regenerate.
+	* configure.in (bfd_elf64_tilegx_vec): Add elfxx-tilegx.lo.
+	* po/SRC-POTFILES.in: Regnerate.
+
+2011-06-14  Alan Modra  <[email protected]>
+
+	* elf32-tilepro.c (tilepro_elf_size_dynamic_sections): Don't use PTR.
+	(allocate_dynrelocs, readonly_dynrelocs): Replace PTR with void *.
+	Don't handle warning symbols here.
+	* elfxx-tilegx.c (tilegx_elf_size_dynamic_sections): As above.
+	(allocate_dynrelocs, readonly_dynrelocs): As above.
+
+2011-06-14  Alan Modra  <[email protected]>
+
+	PR ld/12851
+	* elflink.c (_bfd_elf_gc_mark_extra_sections): New function.
+	(elf_gc_sweep): Don't treat debug and sections like .comment
+	specially here.
+	(bfd_elf_gc_sections): Treat note sections as gc roots only when
+	not part of a group.  Always call gc_mark_extra_sections.
+	* elf-bfd.h (_bfd_elf_gc_mark_extra_sections): Declare.
+	* elfxx-target.h (elf_backend_gc_mark_extra_sections): Default to
+	_bfd_elf_gc_mark_extra_sections.
+	* elf32-arm.c (elf32_arm_gc_mark_extra_sections): Call
+	_bfd_elf_gc_mark_extra_sections.
+	* elf32-tic6x.c (elf32_tic6x_gc_mark_extra_sections): Likewise.
+
+2011-06-13  Nick Clifton  <[email protected]>
+
+	* elf32-tilepro.c (tilepro_elf_check_relocs): Delete unused local
+	variable 'local_got_offsets'.
+	* elfxx-tilegx.c (tilegx_elf_check_relocs): Likewise.
+	(tilegx_finish_dyn): Delete unused local variable 'abi_64_p'.
+
+2011-06-13  Walter Lee  <[email protected]>
+
+	* Makefile.am (ALL_MACHINES): Add cpu-tilegx.lo and cpu-tilepro.lo.
+	(ALL_MACHINE_CFILES): Add cpu-tilegx.c and cpu-tilepro.c.
+	(BFD32_BACKENDS): Add elf32-tilegx.lo, elf32-tilepro.lo,
+	and elfxx-tilegx.lo.
+	(BFD32_BACKENDS_CFILES): Add elf32-tilegx.c elf32-tilepro.c, and
+	elfxx-tilegx.c.
+	(BFD64_BACKENDS): Add elf64-tilegx.lo.
+	(BFD64_BACKENDS_CFILES): Add elf64-tilegx.c.
+	* Makefile.in: Regenerate.
+	* arctures.c (bfd_architecture): Define bfd_arch_tilepro,
+	bfd_arch_tilegx, bfd_mach_tilepro, bfd_mach_tilegx.
+	(bfd_arch_info): Add bfd_tilegx_arch, bfd_tilepro_arch.
+	(bfd_archures_list): Add bfd_tilegx_arch, bfd_tilepro_arch.
+	bfd-in2.h: Regenerate.
+	* config.bfd: Handle tilegx-*-* and tilepro-*-*.
+	* configure.in: Handle bfd_elf32_tilegx_vec, bfd_elf32_tilepro_vec,
+	and bfd_elf64_tilegx_vec.
+	* configure: Regenerate.
+	* elf-bfd.h (enum elf_target_id): Define TILEGX_ELF_DATA and
+	TILEPRO_ELF_DATA.
+	* libbfd.h: Regenerate.
+	* reloc.c: Add BFD_RELOC_TILEPRO_{COPY, GLOB_DAT, JMP_SLOT,
+	RELATIVE, BROFF_X1, JOFFLONG_X1, JOFFLONG_X1_PLT, IMM8_X0,
+	IMM8_Y0, IMM8_X1, IMM8_Y1, DEST_IMM8_X1, MT_IMM15_X1, MF_IMM15_X1,
+	IMM16_X0, IMM16_X1, IMM16_X0_LO, IMM16_X1_LO, IMM16_X0_HI,
+	IMM16_X1_HI, IMM16_X0_HA, IMM16_X1_HA, IMM16_X0_PCREL,
+	IMM16_X1_PCREL, IMM16_X0_LO_PCREL, IMM16_X1_LO_PCREL,
+	IMM16_X0_HI_PCREL, IMM16_X1_HI_PCREL, IMM16_X0_HA_PCREL,
+	IMM16_X1_HA_PCREL, IMM16_X0_GOT, IMM16_X1_GOT, IMM16_X0_GOT_LO,
+	IMM16_X1_GOT_LO, IMM16_X0_GOT_HI, IMM16_X1_GOT_HI,
+	IMM16_X0_GOT_HA, IMM16_X1_GOT_HA, MMSTART_X0, MMEND_X0,
+	MMSTART_X1, MMEND_X1, SHAMT_X0, SHAMT_X1, SHAMT_Y0, SHAMT_Y1,
+	IMM16_X0_TLS_GD, IMM16_X1_TLS_GD, IMM16_X0_TLS_GD_LO,
+	IMM16_X1_TLS_GD_LO, IMM16_X0_TLS_GD_HI, IMM16_X1_TLS_GD_HI,
+	IMM16_X0_TLS_GD_HA, IMM16_X1_TLS_GD_HA, IMM16_X0_TLS_IE,
+	IMM16_X1_TLS_IE, IMM16_X0_TLS_IE_LO, IMM16_X1_TLS_IE_LO,
+	IMM16_X0_TLS_IE_HI, IMM16_X1_TLS_IE_HI, IMM16_X0_TLS_IE_HA,
+	IMM16_X1_TLS_IE_HA, TLS_DTPMOD32, TLS_DTPOFF32, TLS_TPOFF32}
+	Add BFD_RELOC_TILEGX_{HW0, HW1, HW2, HW3, HW0_LAST, HW1_LAST,
+	HW2_LAST, COPY, GLOB_DAT, JMP_SLOT, RELATIVE, BROFF_X1,
+	JUMPOFF_X1, JUMPOFF_X1_PLT, IMM8_X0, IMM8_Y0, IMM8_X1, IMM8_Y1,
+	DEST_IMM8_X1, MT_IMM14_X1, MF_IMM14_X1, MMSTART_X0, MMEND_X0,
+	SHAMT_X0, SHAMT_X1, SHAMT_Y0, SHAMT_Y1, IMM16_X0_HW0,
+	IMM16_X1_HW0, IMM16_X0_HW1, IMM16_X1_HW1, IMM16_X0_HW2,
+	IMM16_X1_HW2, IMM16_X0_HW3, IMM16_X1_HW3, IMM16_X0_HW0_LAST,
+	IMM16_X1_HW0_LAST, IMM16_X0_HW1_LAST, IMM16_X1_HW1_LAST,
+	IMM16_X0_HW2_LAST, IMM16_X1_HW2_LAST, IMM16_X0_HW0_PCREL,
+	IMM16_X1_HW0_PCREL, IMM16_X0_HW1_PCREL, IMM16_X1_HW1_PCREL,
+	IMM16_X0_HW2_PCREL, IMM16_X1_HW2_PCREL, IMM16_X0_HW3_PCREL,
+	IMM16_X1_HW3_PCREL, IMM16_X0_HW0_LAST_PCREL,
+	IMM16_X1_HW0_LAST_PCREL, IMM16_X0_HW1_LAST_PCREL,
+	IMM16_X1_HW1_LAST_PCREL, IMM16_X0_HW2_LAST_PCREL,
+	IMM16_X1_HW2_LAST_PCREL, IMM16_X0_HW0_GOT, IMM16_X1_HW0_GOT,
+	IMM16_X0_HW1_GOT, IMM16_X1_HW1_GOT, IMM16_X0_HW2_GOT,
+	IMM16_X1_HW2_GOT, IMM16_X0_HW3_GOT, IMM16_X1_HW3_GOT,
+	IMM16_X0_HW0_LAST_GOT, IMM16_X1_HW0_LAST_GOT,
+	IMM16_X0_HW1_LAST_GOT, IMM16_X1_HW1_LAST_GOT,
+	IMM16_X0_HW2_LAST_GOT, IMM16_X1_HW2_LAST_GOT, IMM16_X0_HW0_TLS_GD,
+	IMM16_X1_HW0_TLS_GD, IMM16_X0_HW1_TLS_GD, IMM16_X1_HW1_TLS_GD,
+	IMM16_X0_HW2_TLS_GD, IMM16_X1_HW2_TLS_GD, IMM16_X0_HW3_TLS_GD,
+	IMM16_X1_HW3_TLS_GD, IMM16_X0_HW0_LAST_TLS_GD,
+	IMM16_X1_HW0_LAST_TLS_GD, IMM16_X0_HW1_LAST_TLS_GD,
+	IMM16_X1_HW1_LAST_TLS_GD, IMM16_X0_HW2_LAST_TLS_GD,
+	IMM16_X1_HW2_LAST_TLS_GD, IMM16_X0_HW0_TLS_IE,
+	IMM16_X1_HW0_TLS_IE, IMM16_X0_HW1_TLS_IE, IMM16_X1_HW1_TLS_IE,
+	IMM16_X0_HW2_TLS_IE, IMM16_X1_HW2_TLS_IE, IMM16_X0_HW3_TLS_IE,
+	IMM16_X1_HW3_TLS_IE, IMM16_X0_HW0_LAST_TLS_IE,
+	IMM16_X1_HW0_LAST_TLS_IE, IMM16_X0_HW1_LAST_TLS_IE,
+	IMM16_X1_HW1_LAST_TLS_IE, IMM16_X0_HW2_LAST_TLS_IE,
+	IMM16_X1_HW2_LAST_TLS_IE, TLS_DTPMOD64, TLS_DTPOFF64, TLS_TPOFF64,
+	TLS_DTPMOD32, TLS_DTPOFF32, TLS_TPOFF32}
+	* targets.c (bfd_elf32_tilegx_vec): Declare.
+	(bfd_elf32_tilepro_vec): Declare.
+	(bfd_elf64_tilegx_vec): Declare.
+	(bfd_target_vector): Add bfd_elf32_tilegx_vec, bfd_elf32_tilepro_vec,
+	and bfd_elf64_tilegx_vec.
+	* cpu-tilegx.c: New file.
+	* cpu-tilepro.c: New file.
+	* elf32-tilepro.h: New file.
+	* elf32-tilepro.c: New file.
+	* elf32-tilegx.c: New file.
+	* elf32-tilegx.h: New file.
+	* elf64-tilegx.c: New file.
+	* elf64-tilegx.h: New file.
+	* elfxx-tilegx.c: New file.
+	* elfxx-tilegx.h: New file.
+
+2011-06-13  Alan Modra  <[email protected]>
+
+	* linker.c (bfd_link_hash_traverse): Follow warning symbol link.
+	(_bfd_generic_link_write_global_symbol, fix_syms): Don't handle
+	warning symbols here.
+	* elf-m10300.c (elf32_mn10300_finish_hash_table_entry): Likewise.
+	* elf32-arm.c (allocate_dynrelocs_for_symbol,
+	elf32_arm_readonly_dynrelocs): Likewise.
+	* elf32-bfin.c (bfin_discard_copies): Likewise.
+	* elf32-cris.c (elf_cris_adjust_gotplt_to_got,
+	elf_cris_discard_excess_dso_dynamics,
+	elf_cris_discard_excess_program_dynamics): Likewise.
+	* elf32-hppa.c (allocate_plt_static, allocate_dynrelocs,
+	clobber_millicode_symbols, readonly_dynrelocs): Likewise.
+	* elf32-i370.c (i370_elf_adjust_dynindx): Likewise.
+	* elf32-i386.c (elf_i386_allocate_dynrelocs,
+	elf_i386_readonly_dynrelocs): Likewise.
+	* elf32-lm32.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
+	* elf32-m32c.c (m32c_relax_plt_check, m32c_relax_plt_realloc): Likewise.
+	* elf32-m32r.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
+	* elf32-m68k.c (elf_m68k_discard_copies): Likewise.
+	* elf32-microblaze.c (allocate_dynrelocs): Likewise.
+	* elf32-ppc.c (allocate_dynrelocs, maybe_set_textrel): Likewise.
+	* elf32-s390.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
+	* elf32-score.c (score_elf_sort_hash_table_f): Likewise.
+	* elf32-score7.c (score_elf_sort_hash_table_f): Likewise.
+	* elf32-sh.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
+	* elf32-tic6x.c (elf32_tic6x_allocate_dynrelocs,
+	elf32_tic6x_readonly_dynrelocs): Likewise.
+	* elf32-vax.c (elf_vax_discard_copies): Likewise.
+	* elf32-xstormy16.c (xstormy16_relax_plt_check,
+	xstormy16_relax_plt_realloc): Likewise.
+	* elf32-xtensa.c (elf_xtensa_allocate_dynrelocs): Likewise.
+	* elf64-alpha.c (elf64_alpha_output_extsym,
+	elf64_alpha_calc_got_offsets_for_symbol,
+	elf64_alpha_calc_dynrel_sizes, elf64_alpha_size_rela_got_1): Likewise.
+	* elf64-hppa.c (elf64_hppa_mark_exported_functions,
+	allocate_global_data_opd, elf64_hppa_mark_milli_and_exported_functions,
+	elf_hppa_unmark_useless_dynamic_symbols,
+	elf_hppa_remark_useless_dynamic_symbols): Likewise.
+	* elf64-ppc.c (ppc64_elf_gc_mark_dynamic_ref, func_desc_adjust,
+	adjust_opd_syms, adjust_toc_syms, allocate_dynrelocs,
+	readonly_dynrelocs, merge_global_got, reallocate_got,
+	undo_symbol_twiddle): Likewise.
+	* elf64-s390.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
+	* elf64-sh64.c (sh64_elf64_discard_copies): Likewise.
+	* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs,
+	elf_x86_64_readonly_dynrelocs): Likewise.
+	* elflink.c (elf_link_renumber_hash_table_dynsyms,
+	elf_link_renumber_local_hash_table_dynsyms, _bfd_elf_export_symbol,
+	_bfd_elf_link_find_version_dependencies,
+	_bfd_elf_link_assign_sym_version, _bfd_elf_adjust_dynamic_symbol,
+	_bfd_elf_link_sec_merge_syms, elf_adjust_dynstr_offsets,
+	elf_collect_hash_codes, elf_collect_gnu_hash_codes,
+	elf_renumber_gnu_hash_syms, elf_gc_sweep_symbol,
+	elf_gc_propagate_vtable_entries_used,
+	elf_gc_smash_unused_vtentry_relocs, bfd_elf_gc_mark_dynamic_ref_symbol,
+	elf_gc_allocate_got_offsets): Likewise.
+	* elfnn-ia64.c (elfNN_ia64_global_dyn_info_free,
+	elfNN_ia64_global_dyn_sym_thunk): Likewise.
+	* elfxx-mips.c (mips_elf_check_symbols, mips_elf_output_extsym,
+	mips_elf_sort_hash_table_f, allocate_dynrelocs): Likewise.
+	* elfxx-sparc.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
+	* i386linux.c (linux_tally_symbols): Likewise.
+	* m68klinux.c (linux_tally_symbols): Likewise.
+	* sparclinux.c (linux_tally_symbols): Likewise.
+	* sunos.c (sunos_scan_dynamic_symbol): Likewise.
+	* xcofflink.c (xcoff_post_gc_symbol): Likewise.
+
+	* elflink.c (elf_link_output_extsym): Make it a bfd_hash_traverse
+	function.  Update all callers.
+	* aoutx.h (aout_link_write_other_symbol): Likewise.
+	* pdp11.c (aout_link_write_other_symbol): Likewise.
+	* cofflink.c (_bfd_coff_write_global_sym): Likewise.
+	* ecoff.c (ecoff_link_write_external): Likewise.
+	* xcofflink.c (xcoff_write_global_symbol): Likewise.
+	* vms-alpha.c (alpha_vms_link_output_symbol): Likewise.  Handle
+	warning symbols.
+	* ecoff.c (ecoff_link_hash_traverse): Delete.
+	* coff-ppc.c (ppc_bfd_coff_final_link): Use bfd_hash_traverse for
+	_bfd_coff_write_global_sym.
+	* libcoff-in.h (_bfd_coff_write_global_sym): Update prototype.
+	* libcoff.h: Regenerate.
+
+2011-06-10  Nick Clifton  <[email protected]>
+
+	* elflink.c (_bfd_elf_link_create_dynamic_sections): If the
+	backend does not provide a function for creating dynamic sections
+	then fail.
+	(bfd_elf_final_link): Issue a warning message if a dynamic section
+	has the SHT_NOTE type.
+	(bfd_elf_final_link): Do not look for dynamic strings in a section
+	that does not have the SHT_STRTAB type or the name .dynstr.
+	* elf32-arm.c (elf32_arm_finish_dynamic_sections): Fail if the got
+	section is not in the output binary.
+	* elf32-hppa.c (elf32_hppa_finish_dynamic_sections): Likewise.
+
+2011-06-09  Tristan Gingold  <[email protected]>
+
+	* elfnn-ia64.c (elfNN_ia64_relax_section, elfNN_ia64_choose_gp)
+	(elfNN_ia64_relocate_section, elfNN_vms_object_p): Remove trailing
+	spaces.
+
+2011-06-09  Tristan Gingold  <[email protected]>
+
+	* bfd.c (bfd_get_sign_extend_vma): Handle aixcoff.
+
+2011-06-09  Nick Clifton  <[email protected]>
+
+	PR ld/12845
+	* elf.c (_bfd_elf_init_private_section_data): Add an assertion
+	that the output section has an allocated bfd_elf_section_data
+	structure.
+	* elfxx-mips.c (mips_elf_check_symbols): Do not create a stub for
+	symbols in sections that have been removed by garbage collection.
+
+2011-06-08  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_check_relocs): Allow R_X86_64_64
+	relocations in SEC_DEBUGGING sections when building shared
+	libraries.
+
+2011-06-08  H.J. Lu  <[email protected]>
+
+	PR ld/12851
+	* elflink.c (elf_gc_sweep): Don't check SHT_NOTE sections here.
+	(bfd_elf_gc_sections): Also check SHT_NOTE sections.
+
+2011-06-08  Tristan Gingold  <[email protected]>
+
+	* makefile.vms (OBJS): Add elfxx-ia64.obj
+	Remove vax case.
+
+2011-06-08  Alan Modra  <[email protected]>
+
+	* aix386-core.c, * cisco-core.c, * hpux-core.c, * osf-core.c,
+	* sco5-core.c: Init match_priority field.
+
+2011-06-08  Alan Modra  <[email protected]>
+
+	* elflink.c (_bfd_elf_archive_symbol_lookup): Follow warning and
+	indirect links here.
+
+2011-06-07  Joel Brobecker  <[email protected]>
+
+	* irix-core.c (irix_core_vec): Add match_priority field.
+
+2011-06-06  Alan Modra  <[email protected]>
+
+	* targets.c (bfd_target): Make ar_max_namelen an unsigned char.
+	Add match_priority.
+	* configure.in: Bump bfd version.
+	* elfcode.h (elf_object_p): Delete hacks preventing match of
+	EM_NONE and ELFOSABI_NONE targets when a better match exists.
+	* elfxx-target.h (elf_match_priority): Define and use.
+	* format.c (bfd_check_format_matches): Use target match_priority
+	to choose best of multiple matching targets.  In cases with multiple
+	matches rerun _bfd_check_format if we don't choose the last match.
+	* aout-adobe.c, * aout-arm.c, * aout-target.h, * aout-tic30.c,
+	* binary.c, * bout.c, * coff-alpha.c, * coff-i386.c, * coff-i860.c,
+	* coff-i960.c, * coff-ia64.c, * coff-mips.c, * coff-or32.c,
+	* coff-ppc.c, * coff-rs6000.c, * coff-sh.c, * coff-tic30.c,
+	* coff-tic54x.c, * coff-x86_64.c, * coff64-rs6000.c, * coffcode.h,
+	* i386msdos.c, * i386os9k.c, * ieee.c, * ihex.c, * mach-o-target.c,
+	* mipsbsd.c, * mmo.c, * nlm-target.h, * oasys.c, * pdp11.c,
+	* pe-mips.c, * pef.c, * plugin.c, * ppcboot.c, * som.c, * srec.c,
+	* tekhex.c, * trad-core.c, * verilog.c, * versados.c, * vms-alpha.c,
+	* vms-lib.c, * xsym.c: Init match_priority field.
+	* configure: Regenerate.
+	* bfd-in2.h: Regenerate.
+
+2011-06-04  H.J. Lu  <[email protected]>
+
+	PR ld/12842
+	* elfcode.h (elf_object_p): Revert the last change.
+
+2011-06-04  Alan Modra  <[email protected]>
+
+	* archures.c (bfd_arch_get_compatible): If one arch is unknown,
+	return the other arch.
+	* elfcode.h (elf_object_p): Allow explicit match to generic ELF
+	target.
+
+2011-06-03  Bertram Felgenhauer  <[email protected]>
+
+	PR ld/12682
+	* hash.c (higher_primer_number): Add more, small, prime numbers.
+	(bfd_hash_set_default_size): Likewise.
+
+2011-06-02  Nick Clifton  <[email protected]>
+
+	* coff-mcore.c: Fix spelling typo.
+	* coff-stgo32.c: Likewise.
+	* elf32-arm.c: Likewise.
+	* elf32-avr.c: Likewise.
+	* elf-m68hc1x.c: Likewise.
+	* elf32-mcore.c: Likewise.
+	* elf32-mep.c: Likewise.
+	* elf32-mt.c: Likewise.
+	* elf32-ppc.c: Likewise.
+	* elf32-xtensa.c: Likewise.
+	* elf64-ppc.c: Likewise.
+	* elfxx-mips.c: Likewise.
+	* netbsd.h: Likewise.
+	* nlmcode.h: Likewise.
+	* vms-alpha.c: Likewise.
+	* po/bfd.pot: Regenerate.
+	* po/SRC-POTFILES.in: Regenerate.
+
+2011-06-01  DJ Delorie  <[email protected]>
+
+	* config.bfd: Add bfd_elf32_rx_be_ns_vec.
+	* target.c: Likewise.
+	* configure.in: Likewise.
+	* configure.in: Regenerate.
+	* elf32-rx.c: Add elf32-rx-be-ns target.
+	(rx_elf_object_p): Never allow the be-ns target by default,
+	only allow it if the user requests it.
+
+2011-06-01  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_size_dynamic_sections): Properly warn
+	relocation in readonly section in a shared object.
+	* elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Likewise.
+
+2011-05-31  Nick Clifton  <[email protected]>
+
+	* archive.c (adjust_relative_path): Fix comment to prevent it
+	corrupting the auto-generated bfd.h.
+
+2011-05-31  Paul Brook  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_final_link_relocate): Only do bl conversion
+	for known functions.
+	(elf32_arm_swap_symbol_in): Only set ST_BRANCH_TO_ARM for function
+	symbols.
+
+2011-05-31  Paul Brook  <[email protected]>
+
+	* elf32-arm.c (arm_stub_is_thumb): Add
+	arm_stub_long_branch_v4t_thumb_tls_pic.
+	(elf32_arm_final_link_relocate): TLS stubs are always ARM.
+	Handle Thumb stubs.
+
+2011-05-27  Nick Clifton  <[email protected]>
+
+	PR binutils/12710
+	* archive.c (_bfd_get_elt_at_filepos): Set correct error value if
+	unable to read a file pointed to by an entry in a thin archive.
+	(adjust_relative_path): Use lrealpath to canonicalize paths.
+	Handle the case where the reference path is above the current
+	path in the directory tree.
+
+2011-05-26  H.J. Lu  <[email protected]>
+
+	PR ld/12809
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Handle
+	R_X86_64_TPOFF64 in executable.
+
+2011-05-26  Alan Modra  <[email protected]>
+
+	* elf-bfd.h (SYMBOL_REFERENCES_LOCAL): Remove most of comment.
+	* elflink.c (_bfd_elf_symbol_refs_local_p): Expand
+	local_protected comment.
+
+2011-05-25  Tristan Gingold  <[email protected]>
+
+	* configure.in (bfd_elf32_ia64_big_vec, bfd_elf32_ia64_hpux_big_vec)
+	(bfd_elf64_ia64_big_vec, bfd_elf64_ia64_hpux_big_vec)
+	(bfd_elf64_ia64_little_vec, bfd_elf64_ia64_vms_vec): Add elfxx-ia64.lo
+	* Makefile.am (BFD64_BACKENDS): Add elfxx-ia64.lo
+	(BFD64_BACKENDS_CFILES): Add elfxx-ia64.c
+	(elf32-ia64.c): Created from elfnn-ia64.c
+	(elf64-ia64.c): Likewise.
+	* elfxx-ia64.h: New file.
+	* elfxx-ia64.c: Split with elfnn-ia64.c.  Keep only the following
+	functions.Includes elfxx-ia64.h.
+	(elfNN_ia64_reloc): Renames to ia64_elf_reloc.  Adjust error message.
+	(IA64_HOWTO): Adjust.
+	(lookup_howto): Renames to ia64_elf_lookup_howto.  Make it public.
+	(elfNN_ia64_reloc_type_lookup): Renames to
+	ia64_elf_reloc_type_lookup. Make it public. Adjust calls.
+	(elfNN_ia64_reloc_name_lookup): Renames to
+	ia64_elf_reloc_name_lookup. Make it public.
+	(elfNN_ia64_relax_br): Renames to ia64_elf_relax_br.  Make it public.
+	(elfNN_ia64_relax_brl): Renames to ia64_elf_relax_brl. Make it
+	public.
+	(elfNN_ia64_relax_ldxmov): Renames to ia64_elf_relax_ldxmov.
+	Move it and make it public.  Move prototype to elfxx-ia64.h
+	(elfNN_ia64_install_value): Renames to ia64_elf_install_value.
+	Move prototype to elfxx-ia64.h
+	* elfnn-ia64.c: New file, split from elfxx-ia64.c.
+	(elfNN_ia64_info_to_howto): Adjust calls.
+	(elfNN_ia64_relax_section): Adjust calls.
+	(count_dyn_reloc): Fix typo.
+	(elfNN_ia64_relocate_section): Adjust calls.
+	(elfNN_ia64_finish_dynamic_symbol): Likewise.
+	(bfd_elfNN_bfd_reloc_type_lookup)
+	(bfd_elfNN_bfd_reloc_name_lookup): Adjust macros.
+	* configure: Regenerate.
+	* Makefile.in: Regenerate.
+
+2011-05-23  DJ Delorie  <[email protected]>
+
+	* elf32-rx.c (rx_elf_object_p): When reading an RX object in, undo
+	the vma/lma swapping done in elf32_rx_modify_program_headers.
+
+2011-05-23  Nick Clifton  <[email protected]>
+
+	* elf-m10300.c (mn10300_elf_mkobject): New function.
+	(bfd_elf32_mkobject): Define.
+
+2011-05-23  Alan Modra  <[email protected]>
+
+	* elf-bfd.h: Comment typo fix.
+	* elf32-ppc.c (struct ppc_elf_dyn_relocs): Delete.  Replace with
+	struct elf_dyn_relocs throughout.
+	* elf64-ppc.c (struct ppc_dyn_relocs): Likewise.
+
+2011-05-23  Alan Modra  <[email protected]>
+
+	* elf32-frv.c: Use info->callbacks->einfo throughout file in linker
+	functions rather than warning callback or _bfd_error_handler.
+	* elf32-ppc.c: Likewise.
+	* elf64-ppc.c: Likewise.
+	* elf32-ppc.c (ppc_elf_tls_optimize): Use %H in __tls_get_addr lost
+	arg error.
+	* elf64-ppc.c (ppc64_elf_tls_optimize): Likewise.
+
+2011-05-23  Alan Modra  <[email protected]>
+
+	PR 12763
+	* elf.c (assign_file_positions_for_load_sections): Set sh_offset for
+	.tbss, and page align same for all SHT_NOBITS sections.
+
+2011-05-21  Alan Modra  <[email protected]>
+
+	PR 12763
+	* elf.c (_bfd_elf_make_section_from_shdr): Set up TLS section LMAs
+	from PT_TLS header.
+	(_bfd_elf_map_sections_to_segments): Don't create a final PT_LOAD
+	segment if just for .tbss.
+	(assign_file_positions_for_load_sections): Don't report "can't
+	allocate in segment" errors for .tbss.
+	(assign_file_positions_for_non_load_sections): Don't set p_filesz
+	from SHT_NOBITS section filepos.
+
+2011-05-20  Bernd Schmidt  <[email protected]>
+
+	* elf32-tic6x.c (elf32_tic6x_howto_table): Add entries for
+	R_C6000_PCR_H16 and R_C6000_PCR_L16.
+	(elf32_tic6x_relocate_section): Handle them.
+
+2011-05-18  Nick Clifton  <[email protected]>
+
+	PR ld/12761
+	* elflink.c (elf_link_add_object_symbols): Process .gnu.warning
+	sections when building shared libraries.
+
+2011-05-18  RafaÅ‚ Krypa  <[email protected]>
+
+	PR ld/12778
+	* elf32-arm.c (elf32_arm_gc_sweep_hook): Use the computed dynamic
+	reloc pointer.
+
+2011-05-18  Tristan Gingold  <[email protected]>
+
+	* xcofflink.c (xcoff_link_add_symbols): Handle C_DWARF symbols.
+	(xcoff_sweep): Always keep dwarf sections.
+	(xcoff_link_input_bfd): Handle dwarf symbols and sections.
+
+2011-05-18  Tristan Gingold  <[email protected]>
+
+	* libxcoff.h (struct xcoff_dwsect_name): New type.
+	(XCOFF_DWSECT_NBR_NAMES): New macro.
+	(xcoff_dwsect_names): Declare.
+	* coffcode.h (sec_to_styp_flags): Handle xcoff dwarf sections.
+	(styp_to_sec_flags): Ditto.
+	(coff_new_section_hook): Ditto.
+	(coff_slurp_symbol_table): Handle C_DWARF and C_INFO.
+	* coff-rs6000.c (xcoff_dwsect_name): New variable.
+
+2011-05-17  Tomohiro Kashiwada  <[email protected]>
+
+	PR ld/12759
+	* elf32-rx.c (ignore_lma): New variable.
+	(bfd_elf32_rx_set_target_flags): Add ignore_lma parameter.
+	(rx_modify_program_headers): Only copy the LMA into the VMA if
+	ignore_lma is true.
+
+2011-05-17  Alan Modra  <[email protected]>
+
+	PR ld/12760
+	* coff-aux.c (coff_m68k_aux_link_add_one_symbol): Adjust "notice" call.
+	* elflink.c (elf_link_add_object_symbols): Likewise.
+	* linker.c (_bfd_generic_link_add_one_symbol): Likewise.
+
+2011-05-16  Alan Modra  <[email protected]>
+
+	* linker.c (_bfd_generic_link_add_one_symbol): Don't init u.undef.weak.
+
+2011-05-15  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (_bfd_mips_elf_check_relocs): Record both local and
+	global GOT entries for GOT_PAGE relocations against global symbols.
+
+2011-05-13  Bernd Schmidt  <[email protected]>
+
+	* config.bfd (tic6x-*-elf, tic6x-*-uclinux): New.
+	(tic6x-*-*): Replaced by these.
+	* elf32-tic6x.c (elf32_tic6x_set_osabi): New static function.
+	(elf32_tic6x_check_relocs): Create dynamic sections if -shared.
+	(elf_backend_relocs_compatible, elf_backend_post_process_headers):
+	Define.
+	(elf32_bed, TARGET_LITTLE_SYM, TARGET_LITTLE_NAME, TARGET_BIG_SYM,
+	TARGET_BIG_NAME, ELF_OSABI): Redefine twice, and include
+	"elf32-target.h" two more times.
+	* configure.in: Handle bfd_elf32_tic6x_linux_be_vec,
+	bfd_elf32_tic6x_linux_le_vec, bfd_elf32_tic6x_elf_be_vec and
+	bfd_elf32_tic6x_elf_le_vec.
+	* configure: Regenerate.
+
+2011-05-13  Jan Beulich  <[email protected]>
+
+	* config.bfd: Add targets x86_64-*-pe and x86_64-*-pep.
+
+2011-05-12  Jan Kratochvil  <[email protected]>
+
+	* config.in: Regenerated.
+	* configure: Regenerated.
+	* configure.in: New tests for HAVE_PRPSINFO_T_PR_PID,
+	HAVE_PRPSINFO32_T_PR_PID, HAVE_PSINFO_T_PR_PID and
+	HAVE_PSINFO32_T_PR_PID.
+	* elf.c (elfcore_grok_psinfo): Protect reading psinfo.pr_pid by
+	HAVE_PRPSINFO_T_PR_PID, HAVE_PRPSINFO32_T_PR_PID, HAVE_PSINFO_T_PR_PID
+	and HAVE_PSINFO32_T_PR_PID.
+	* hosts/x86-64linux.h (HAVE_PRPSINFO32_T_PR_PID): New redefinition.
+
+2011-05-10  Jan Kratochvil  <[email protected]>
+
+	* elf.c (elfcore_grok_psinfo): Initialize CORE_PID for both native and
+	32bit psinfo.
+	* elf32-ppc.c (ppc_elf_grok_psinfo): Initialize core_pid.
+	* elf64-ppc.c (ppc64_elf_grok_psinfo): Likewise.
+
+2011-05-09  Paul Brook  <[email protected]>
+
+	* bfd-in.h (elf32_tic6x_fix_exidx_coverage): Add prototype.
+	* bfd-in2.h: Regenerate.
+	* elf32-tic6x.c: Include limits.h.
+	(tic6x_unwind_edit_type, tic6x_unwind_table_edit,
+	_tic6x_elf_section_data): New.
+	(elf32_tic6x_section_data): Define.
+	(elf32_tic6x_new_section_hook): Allocate target specific data.
+	(elf32_tic6x_add_unwind_table_edit): New function.
+	(get_tic6x_elf_section_data, elf32_tic6x_adjust_exidx_size,
+	elf32_tic6x_insert_cantunwind_after, elf32_tic6x_add_low31,
+	elf32_tic6x_copy_exidx_entry): New functions.
+	(elf_backend_write_section): Define.
+
+2011-05-09  Paul Brook  <[email protected]>
+
+	* elf32-tic6x.c (is_tic6x_elf_unwind_section_name,
+	elf32_tic6x_fake_sections): New functions.
+	(elf_backend_fake_sections): Define.
+
+2011-05-09  Paul Brook  <[email protected]>
+
+	* elf32-tic6x.c (elf32_tic6x_gc_mark_extra_sections): New function.
+	(elf_backend_gc_mark_extra_sections): Define.
+
+2011-05-07  Dave Korn  <[email protected]>
+
+	PR ld/12365
+	* cofflink.c (bfd_coff_link_input_bfd): Check for and warn about
+	references to symbols defined in discarded sections.
+
+2011-05-07  Dave Korn  <[email protected]>
+
+	PR ld/12365
+	* coffgen.c (coff_write_symbol): Assume input section is its own
+	output section if output_section member not set.
+	(coff_write_alien_symbol): Likewise.
+
+2011-05-07  H.J. Lu  <[email protected]>
+
+	PR ld/12730
+	* elf.c (_bfd_elf_section_offset): Check SEC_ELF_REVERSE_COPY.
+
+	* elflink.c (elf_link_input_bfd): Reverse copy .ctors/.dtors
+	sections if needed.
+
+	* section.c (SEC_ELF_REVERSE_COPY): New.
+	* bfd-in2.h: Regenerated.
+
+2011-05-07  Anders Kaseorg  <[email protected]>
+
+	PR 12739
+	* libbfd.c (bfd_get_8, bfd_get_signed_8): Use const cast.
+	* bfd-in2.h: Regenerate.
+
+2011-05-06  Tristan Gingold  <[email protected]>
+
+	* vms-alpha.c (evax_section_flags): Remove SEC_IN_MEMORY.
+	(_bfd_vms_slurp_egsd): Rename old_flags to vms_flags.  Handle
+	any code section.  Add comments.
+	(alpha_vms_object_p): Use void * instead of PTR.
+	(alpha_vms_create_eisd_for_section): Fix test for setting DZRO.
+	(build_module_list): Guard against no DST section.  Add comments.
+	(alpha_vms_link_output_symbol): Discard undefined symbols.
+	(alpha_vms_get_section_contents): Simply memcpy if the section was
+	already loaded.  Fix typo.
+	(vms_new_section_hook): Use void * instead of PTR.
+	(vms_alpha_vec): Ditto.
+
+2011-05-06  Richard Sandiford  <[email protected]>
+
+	* elf32-arm.c (cortex_a8_erratum_scan): If the stub is a Thumb
+	branch to a PLT entry, redirect it to the PLT's Thumb entry point.
+
+2011-05-05  Bernd Schmidt  <[email protected]>
+
+	* elf32-tic6x.c (elf32_tic6x_final_link): New function.
+	(elf32_tic6x_merge_attributes): Do not warn for PID or PIC
+	mismatch.  Choose the lower of the two values.
+	(bfd_elf32_bfd_final_link): New macro.
+
+2011-04-28  Tristan Gingold  <[email protected]>
+
+	* coff-rs6000.c (_bfd_xcoff_swap_aux_in): Adjust for x_file.
+	(bfd_xcoff_swap_aux_out): Ditto.
+	* coff64-rs6000.c (_bfd_xcoff64_swap_aux_in): Ditto.
+	(bfd_xcoff64_swap_aux_out): Ditto.
+
+2011-05-04  Alan Modra  <[email protected]>
+
+	PR ld/12727
+	* elf64-ppc.c (ppc_build_one_stub <ppc_sub_plt_call>): Clear
+	was_undefined on dot-symbols.
+
+2011-05-03  Paul Brook  <[email protected]>
+
+
+	* elf32-tic6x.c (elf32_tic6x_howto_table,
+	elf32_tic6x_howto_table_rel, (elf32_tic6x_gc_sweep_hook,
+	elf32_tic6x_relocate_section, elf32_tic6x_check_relocs):
+	Add R_C6000_EHTYPE.
+
+2011-05-01  Alan Modra  <[email protected]>
+
+	PR ld/12718
+	* elf32-i386.c (elf_i386_check_relocs): Ensure dynobj set before
+	creating ifunc sections.
+	* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
+
+2011-04-30  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_merge_symbol): Correct parameter
+	names.
+
+2011-04-28  Tom Tromey  <[email protected]>
+
+	* bfdio.c (memory_bstat): Pass correct size to memset.
+
+2011-04-28  Mike Frysinger  <[email protected]>
+
+	* dwarf2.c (dwarf_debug_sections): Mark const.
+	* elf.c (special_sections): Likewise.
+	* libbfd-in.h (dwarf_debug_sections): Likewise.
+	* libbfd.h: Regenerate.
+
+2011-04-26  Kai Tietz  <[email protected]>
+
+	* coffcode.h (sec_to_styp_flags): Allow linkonce for
+	debugging sections.
+
+2011-04-26  Tristan Gingold  <[email protected]>
+
+	* coff64-rs6000.c: Convert to ISO-C.  Remove PARAMS and PTR macros.
+
+2011-04-24  Alan Modra  <[email protected]>
+
+	PR ld/12365
+	PR ld/12696
+	* coff-aux.c (coff_m68k_aux_link_add_one_symbol): Update "notice" call.
+	* linker.c (_bfd_link_hash_newfunc): Clear bitfields.
+	(_bfd_generic_link_add_one_symbol): Update "notice" call.
+	* elflink.c (_bfd_elf_merge_symbol): Don't skip weak redefs when
+	it is a redef of an IR symbol in a real BFD.
+
+2011-04-22  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_readonly_dynrelocs): Warn relocation
+	in readonly section in a shared object.
+	(elf_i386_size_dynamic_sections): Likewise.
+	* elf64-x86-64.c (elf_x86_64_readonly_dynrelocs): Likewise.
+	(elf_x86_64_size_dynamic_sections): Likewise.
+
+2011-04-21  H.J. Lu  <[email protected]>
+
+	PR ld/12694
+	* elf32-i386.c (elf_i386_readonly_dynrelocs): Skip local IFUNC
+	symbols.
+	* elf64-x86-64.c (elf_x86_64_readonly_dynrelocs): Likewise.
+
+2011-04-21  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_finish_dynamic_symbol): Return false
+	on dynamic symbol error.
+	* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Likewise.
+
+2011-04-20  Tristan Gingold  <[email protected]>
+
+	* config.bfd (alpha*-*-*vms*, ia64*-*-*vms*): Define targ_selvecs.
+
+2011-04-20  Alan Modra  <[email protected]>
+
+	* hash.c (bfd_default_hash_table_size): Make it an unsigned long.
+	(bfd_hash_table_init_n): Overflow checking.
+	(bfd_hash_set_default_size): Return current size.  Take unsigned long
+	arg.  Add 65537 to hash_size primes.
+	* bfd-in.h (bfd_hash_set_default_size): Update prototype.
+	* bfd-in2.h: Regenerate.
+
+2011-04-20  Jan Kratochvil  <[email protected]>
+
+	* elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): Fix +1 overrun of
+	memmove elements.
+
+2011-04-20  Alan Modra  <[email protected]>
+
+	* libbfd.c (bfd_log2): Do return rounded up value.
+	* elflink.c (bfd_elf_size_dynsym_hash_dynstr): Replace bfd_log2
+	call with expanded old round down version of the function.
+
+	* archive.c (_bfd_get_elt_at_filepos): Don't release n_nfd.
+	* elflink.c (elf_link_add_object_symbols): Delete redundant code.
+
+2011-04-20  Alan Modra  <[email protected]>
+
+	PR ld/12365
+	* elfcode.h (elf_slurp_symbol_table): Put common plugin IR symbols
+	in their own common section.
+	* elflink.c (elf_link_add_object_symbols): Likewise.
+	* linker.c (generic_link_check_archive_element): Don't lose flags
+	if common section is pre-existing.
+	(_bfd_generic_link_add_one_symbol): Likewise.
+
+2011-04-20  Alan Modra  <[email protected]>
+
+	PR ld/12365
+	* elflink.c (_bfd_elf_merge_symbol): Update multiple_common calls.
+	* linker.c (_bfd_generic_link_add_one_symbol): Likewise.  Call
+	multiple_definition regardless of allow_multiple_definition.
+	* simple.c (simple_dummy_multiple_definition): Update.
+	* xcofflink.c (xcoff_link_add_symbols): Update multiple_definition
+	calls.
+
+2011-04-18  Tristan Gingold  <[email protected]>
+
+	* coff-rs6000.c: Convert to ISO-C.  Remove PARAMS macro.
+
+2011-04-18  Alan Modra  <[email protected]>
+
+	PR ld/12365
+	PR ld/12672
+	* bfd.c (BFD_PLUGIN): Define.
+	(BFD_FLAGS_SAVED, BFD_FLAGS_FOR_BFD_USE_MASK): Add BFD_PLUGIN.
+	* bfd-in2.h: Regenerate.
+	* elflink.c (elf_link_output_extsym): Strip undefined plugin syms.
+	* opncls.c (bfd_make_readable): Don't lose original bfd flags.
+
+2011-04-17  Jan Kratochvil  <[email protected]>
+
+	* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Do not check for
+	SEC_LOAD.
+
+2011-04-15  Sergio Durigan Junior  <[email protected]>
+
+	* elf-bfd.h (struct sdt_note): New struct.
+	(struct elf_obj_tdata) <sdt_note_head>: New field.
+	* elf.c (elfobj_grok_stapsdt_note_1): New function.
+	(elfobj_grok_stapsdt_note): Likewise.
+	(elf_parse_notes): Added code to treat SystemTap note
+	sections.
+
+2011-04-12  Richard Henderson  <[email protected]>
+
+	* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Do not
+	exclude empty .got sections.
+
+2011-04-11  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_reloc_type_lookup): Fix the out of bound
+	array access for BFD_RELOC_386_IRELATIVE.
+
+2011-04-11  Bernd Schmidt  <[email protected]>
+
+	* elf32-tic6x.c (elf32_tic6x_check_relocs): Initialize pc_count field.
+
+2011-04-11  Mark Wielaard  <[email protected]>
+
+	PR 10549
+	* elf-bfd.h (has_ifunc_symbols): Renamed to has_gnu_symbols.
+	(has_gnu_symbols): Renamed from has_ifunc_symbols.
+	* elf.c (_bfd_elf_set_osabi): Use new has_gnu_symbols name.
+	* elf32-arm.c (elf32_arm_add_symbol_hook): Set has_gnu_symbols
+	also if STB_GNU_UNIQUE symbol binding was seen.
+	* elf32-i386.c (elf_i386_add_symbol_hook): Likewise.
+	* elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise.
+	* elf32-sparc.c (elf32_sparc_add_symbol_hook): Likewise.
+	* elf64-ppc.c (ppc64_elf_add_symbol_hook): Likewise.
+	* elf64-sparc.c (elf64_sparc_add_symbol_hook): Likewise.
+	* elf64-x86-64.c (elf_x86_64_add_symbol_hook): Likewise.
+
+2011-04-11  Alan Modra  <[email protected]>
+
+	* bfd-in.h (bfd_get_section_limit): Don't use rawsize with output
+	sections.
+	* libbfd.c (_bfd_generic_get_section_contents): Likewise.
+	(_bfd_generic_get_section_contents_in_window): Likewise.
+	* section.c (bfd_get_section_contents): Likewise.
+	* compress.c (bfd_get_full_section_contents): Likewise.
+	* elf32-rx.c (rx_final_link): Ignore rawsize.
+	* elf32-microblaze.c (microblaze_elf_relocate_section): Use correct
+	bfd with bfd_get_section_limit.
+	* elfxx-ia64.c (elfNN_ia64_choose_gp): Add "final" parameter.  Use
+	os->size during final link.  Update callers.
+	* bfd-in2.h: Regenerate.
+
+2011-04-10  Richard Sandiford  <[email protected]>
+
+	PR ld/12637
+	* elfxx-mips.c (mips_elf_merge_got_with): Use arg->global_count
+	as the number of global entries when merging with the primary GOT.
+
+2011-04-09  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c: Update copyright year.
+	* elf64-x86-64.c: Likewise.
+
+2011-04-09  Kai Tietz  <[email protected]>
+
+	* peXXigen.c (_bfd_XXi_final_link_postscripte): Sort pdata in temporary
+	buffer and use rawsize for sorting.
+	* coffcode.h (coff_compute_section_file_positions): Set rawsize
+	before doing alignment.
+
+2011-04-09  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_relocate_section): Return relocation
+	error on unsupported relocation.
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
+
+2011-04-09  H.J. Lu  <[email protected]>
+
+	PR binutils/12657
+	* hosts/x86-64linux.h (elf_prstatus32): Replace __pid_t with
+	pid_t.
+
+2011-04-08  H.J. Lu  <[email protected]>
+
+	PR ld/12654
+	* elf32-i386.c (elf_i386_relocate_section): Check !executable
+	instead of shared for R_386_TLS_LDO_32.
+
+2011-04-08  Tristan Gingold  <[email protected]>
+
+	* Makefile.am (SOURCE_HFILES): Remove xcoff-target.h
+	* coff-pmac: Remove
+	* xcoff-target.h: Remove
+	* Makefile.in: Regenerate.
+
+2011-04-07  Cary Coutant  <[email protected]>
+
+	* dwarf2.c (scan_unit_for_symbols): Check for DW_AT_specification.
+
+2011-04-07  Paul Brook  <[email protected]>
+
+	* elf32-tic6x.c (elf32_tic6x_howto_table): R_C6000_PREL31 is
+	pc-relative.
+	(elf32_tic6x_howto_table_rel): Ditto.
+	(elf32_tic6x_relocate_section): Implement R_C6000_PREL31.
+	(elf32_tic6x_check_relocs): Ditto.
+
+2011-04-06  Joseph Myers  <[email protected]>
+
+	* config.bfd (thumb-*-oabi): Don't handle in list of obsolete
+	targets.
+	(strongarm*, thumb*, xscale*): Remove architectures.
+	(strongarm-*-kaos*, thumb-*-coff, thumb-*-elf, thumb-epoc-pe*,
+	thumb-*-pe*, strongarm-*-elf, strongarm-*-coff, xscale-*-elf,
+	xscale-*-coff): Remove targets.
+
+2011-04-01  Tristan Gingold  <[email protected]>
+
+	* elfxx-ia64.c: include bfd_stdint.h
+
+2011-03-31  Jan Kratochvil  <[email protected]>
+
+	* elf32-tic6x.c (elf32_tic6x_relocate_section): Remove unused variable
+	dynobj and its initialization.
+
+2011-03-31  Tristan Gingold  <[email protected]>
+
+	* makefile.vms (DEFS): Add HAVE_bfd_elf64_ia64_vms_vec.
+	* configure.com: Set BFD_HOST_64BIT_LONG_LONG and
+	BFD_HOST_LONG_LONG to 1.
+
+2011-03-31  Tristan Gingold  <[email protected]>
+
+	* vms-alpha.c (vms_get_remaining_object_record): Fix dec-c warning.
+	(_bfd_vms_write_etir): Ditto.
+	(_bfd_vms_slurp_etir): Avoid to use intptr_t
+	* configure.com: Generate bfd_stdint.h
+
+2011-03-31  Bernd Schmidt  <[email protected]>
+
+	* elf32-tic6x.h (struct elf32_tic6x_params): New.
+	(elf32_tic6x_setup): Declare.
+	* elf32-tic6x.c: Include <limits.h>.
+	(ELF_DYNAMIC_LINKER, DEFAULT_STACK_SIZE, PLT_ENTRY_SIZE): Define.
+	(struct elf32_tic6x_link_hash_table, struct elf32_link_hash_entry):
+	New structures.
+	(elf32_tic6x_link_hash_table, is_tic6x_elf): New macros.
+	(tic6x_elf_scom_section, tic6x_elf_scom_symbol,
+	tic6x_elf_scom_symbol_ptr): New static variables.
+	(elf32_tic6x_howto_table, elf32_tic6x_howto_table_rel,
+	elf32_tic6x_reloc_map): Add R_C6000_JUMP_SLOT, R_C6000_EHTYPE,
+	R_C6000_PCR_H16 and R_C6000_PCR_L16.
+	(elf32_tic6x_link_hash_newfunc, elf32_tic6x_link_hash_table_create,
+	elf32_tic6x_link_hash_table_free, elf32_tic6x_setup,
+	elf32_tic6x_using_dsbt, elf32_tic6x_install_rela,
+	elf32_tic6x_create_dynamic_sections, elf32_tic6x_make_got_dynreloc,
+	elf32_tic6x_finish_dynamic_symbol, elf32_tic6x_gc_sweep_hook,
+	elf32_tic6x_adjust_dynamic_symbol): New static functions.
+	(elf32_tic6x_relocate_section): For R_C6000_PCR_S21, convert branches
+	to weak symbols as required by the ABI.
+	Handle GOT and DSBT_INDEX relocs, and copy relocs to the output file
+	as needed when generating DSBT output.
+	(elf32_tic6x_check_relocs, elf32_tic6x_add_symbol_hook,
+	elf32_tic6x_symbol_processing, elf32_tic6x_section_from_bfd_section,
+	elf32_tic6x_allocate_dynrelocs, elf32_tic6x_size_dynamic_sections,
+	elf32_tic6x_always_size_sections, elf32_tic6x_modify_program_headers,
+	elf32_tic6x_finish_dynamic_sections, elf32_tic6x_plt_sym_val,
+	elf32_tic6x_copy_private_data, elf32_tic6x_link_omit_section_dynsym):
+	New static functions.
+	(ELF_MAXPAGESIZE): Define to 0x1000.
+	(bfd_elf32_bfd_copy_private_bfd_data,
+	bfd_elf32_bfd_link_hash_table_create,
+	bfd_elf32_bfd_link_hash_table_free, elf_backend_can_refcount,
+	elf_backend_want_got_plt, elf_backend_want_dynbss,
+	elf_backend_plt_readonly, elf_backend_got_header_size,
+	elf_backend_gc_sweep_hook, elf_backend_modify_program_headers,
+	elf_backend_create_dynamic_sections, elf_backend_adjust_dynamic_symbol,
+	elf_backend_check_relocs, elf_backend_add_symbol_hook,
+	elf_backend_symbol_processing, elf_backend_link_output_symbol_hook,
+	elf_backend_section_from_bfd_section,
+	elf_backend_finish_dynamic_symbol, elf_backend_always_size_sections,
+	elf32_tic6x_size_dynamic_sections, elf_backend_finish_dynamic_sections,
+	elf_backend_omit_section_dynsym, elf_backend_plt_sym_val): Define.
+
+	* bfd/reloc.c (BFD_RELOC_C6000_JUMP_SLOT, BFD_RELOC_C6000_EHTYPE,
+	BFD_RELOC_C6000_PCR_H16, BFD_RELOC_C6000_PCR_S16): Add.
+	* bfd/bfd-in2.h: Regenerate.
+	* bfd/libbfd.h: Regenerate.
+	* config.bfd: Accept tic6x-*-* instead of tic6x-*-elf.
+
+2011-03-31  Tristan Gingold  <[email protected]>
+
+	* coffcode.h (coff_slurp_symbol_table): Silently discard C_NULL
+	entry on xcoff when value is C_NULL_VALUE.
+
+2011-03-31  Tristan Gingold  <[email protected]>
+
+	* libcoff-in.h (exec_hdr): Remove.
+	* libcoff.h: Regenerate.
+
+2011-03-30  Nick Clifton  <[email protected]>
+
+	* po/da.po: Updated Danish translation.
+
+2011-03-29  Richard Henderson  <[email protected]>
+
+	* elf64-alpha.c (elf64_alpha_gc_mark_hook): New.
+	(elf64_alpha_gc_sweep_hook): New.
+	(elf_backend_gc_mark_hook, elf_backend_gc_sweep_hook): New.
+	(elf_backend_can_gc_sections): New.
+
+2011-03-26  John Marino  <[email protected]>
+
+	* config.bfd: Add x86_64-*-dragonfly*, fix i386-*-dragonfly*.
+	* configure.in: Delete unused bfd_elf32_i386_dragonfly_vec.
+	* configure: Regenerate.
+
+2011-03-25  Michael Snyder  <[email protected]>
+
+	* coffcode.h (coff_set_alignment_hook): Check return of bfd_seek.
+
+2011-03-25  Tristan Gingold  <[email protected]>
+
+	* vms-alpha.c (_bfd_vms_find_nearest_dst_line): Allow the use
+	of find_nearest_line on object files.
+
+2011-03-25  Tristan Gingold  <[email protected]>
+
+	* vms-alpha.c (evax_section_flags): Make $CODE$ section read-only.
+	Minor reordering.
+	(alpha_vms_create_eisd_for_section): Make code sections read-only.
+
+2011-03-24  Alan Modra  <[email protected]>
+
+	* elf32-ppc.c (ppc_elf_tls_optimize): Catch more cases where
+	old-style __tls_get_addr calls without marker relocs don't match
+	their arg setup insn one for one.  If such mismatches are found
+	report the reloc and don't do any tls optimization.
+	* elf64-ppc.c (ppc64_elf_tls_optimize): Likewise.
+
+2011-03-22  Eric B. Weddington  <[email protected]>
+
+	* bfd-in2.h: Regenerate.
+
+2011-03-22  Eric B. Weddington  <[email protected]>
+
+	* archures.c: Add AVR XMEGA architecture information.
+	* cpu-avr.c (arch_info_struct): Likewise.
+	* elf32-avr.c (bfd_elf_avr_final_write_processing): Likewise.
+	(elf32_avr_object_p): Likewise.
+
+2011-03-14  Richard Sandiford  <[email protected]>
+
+	* reloc.c (BFD_RELOC_ARM_IRELATIVE): New relocation.
+	* bfd-in2.h: Regenerate.
+	* elf32-arm.c (elf32_arm_howto_table_2): Rename existing definition
+	to elf32_arm_howto_table_3 and replace with a single R_ARM_IRELATIVE
+	entry.
+	(elf32_arm_howto_from_type): Update accordingly.
+	(elf32_arm_reloc_map): Map BFD_RELOC_ARM_IRELATIVE to R_ARM_IRELATIVE.
+	(elf32_arm_reloc_name_lookup): Handle elf32_arm_howto_table_3.
+	(arm_plt_info): New structure, split out from elf32_arm_link_hash_entry
+	with an extra noncall_refcount field.
+	(arm_local_iplt_info): New structure.
+	(elf_arm_obj_tdata): Add local_iplt.
+	(elf32_arm_local_iplt): New accessor macro.
+	(elf32_arm_link_hash_entry): Replace plt_thumb_refcount,
+	plt_maybe_thumb_refcount and plt_got_offset with an arm_plt_info.
+	Change tls_type to a bitfield and add is_iplt.
+	(elf32_arm_link_hash_newfunc): Update accordingly.
+	(elf32_arm_allocate_local_sym_info): New function.
+	(elf32_arm_create_local_iplt): Likewise.
+	(elf32_arm_get_plt_info): Likewise.
+	(elf32_arm_plt_needs_thumb_stub_p): Likewise.
+	(elf32_arm_get_local_dynreloc_list): Likewise.
+	(create_ifunc_sections): Likewise.
+	(elf32_arm_copy_indirect_symbol): Update after the changes to
+	elf32_arm_link_hash_entry.  Assert the is_iplt has not yet been set.
+	(arm_type_of_stub): Add an st_type argument.  Use elf32_arm_get_plt_info
+	to get PLT information.  Assert that all STT_GNU_IFUNC references
+	are turned into PLT references.
+	(arm_build_one_stub): Pass the symbol type to
+	elf32_arm_final_link_relocate.
+	(elf32_arm_size_stubs): Pass the symbol type to arm_type_of_stub.
+	(elf32_arm_allocate_irelocs): New function.
+	(elf32_arm_add_dynreloc): In static objects, use .rel.iplt for
+	all R_ARM_IRELATIVE.
+	(elf32_arm_allocate_plt_entry): New function.
+	(elf32_arm_populate_plt_entry): Likewise.
+	(elf32_arm_final_link_relocate): Add an st_type parameter.
+	Set srelgot to null for static objects.  Use separate variables
+	to record which st_value and st_type should be used when generating
+	a dynamic relocation.  Use elf32_arm_get_plt_info to find the
+	symbol's PLT information, setting has_iplt_entry, splt,
+	plt_offset and gotplt_offset accordingly.  Check whether
+	STT_GNU_IFUNC symbols should resolve to an .iplt entry, and change
+	the relocation target accordingly.  Broaden assert to include
+	.iplts.  Don't set sreloc for static relocations.  Assert that
+	we only generate dynamic R_ARM_RELATIVE relocations for R_ARM_ABS32
+	and R_ARM_ABS32_NOI.  Generate R_ARM_IRELATIVE relocations instead
+	of R_ARM_RELATIVE relocations if the target is an STT_GNU_IFUNC
+	symbol.  Pass the symbol type to arm_type_of_stub.  Conditionally
+	resolve GOT references to the .igot.plt entry.
+	(elf32_arm_relocate_section): Update the call to
+	elf32_arm_final_link_relocate.
+	(elf32_arm_gc_sweep_hook): Use elf32_arm_get_plt_info to get PLT
+	information.  Treat R_ARM_REL32 and R_ARM_REL32_NOI as call
+	relocations in shared libraries and relocatable executables.
+	Count non-call PLT references.  Use elf32_arm_get_local_dynreloc_list
+	to get the list of dynamic relocations for a local symbol.
+	(elf32_arm_check_relocs): Always create ifunc sections.  Set isym
+	at the same time as setting h.  Use elf32_arm_allocate_local_sym_info
+	to allocate local symbol information.  Treat R_ARM_REL32 and
+	R_ARM_REL32_NOI as call relocations in shared libraries and
+	relocatable executables.  Record PLT information for local
+	STT_GNU_IFUNC functions as well as global functions.   Count
+	non-call PLT references.  Use elf32_arm_get_local_dynreloc_list
+	to get the list of dynamic relocations for a local symbol.
+	(elf32_arm_adjust_dynamic_symbol): Handle STT_GNU_IFUNC symbols.
+	Don't remove STT_GNU_IFUNC PLTs unless all references have been
+	removed.  Update after the changes to elf32_arm_link_hash_entry.
+	(allocate_dynrelocs_for_symbol): Decide whether STT_GNU_IFUNC PLT
+	entries should live in .plt or .iplt.  Check whether the .igot.plt
+	and .got entries can be combined.  Use elf32_arm_allocate_plt_entry
+	to allocate .plt and .(i)got.plt entries.  Detect which .got
+	entries will need R_ARM_IRELATIVE relocations and use
+	elf32_arm_allocate_irelocs to allocate them.  Likewise other
+	non-.got dynamic relocations.
+	(elf32_arm_size_dynamic_sections): Allocate .iplt, .igot.plt
+	and dynamic relocations for local STT_GNU_IFUNC symbols.
+	Check whether the .igot.plt and .got entries can be combined.
+	Detect which .got entries will need R_ARM_IRELATIVE relocations
+	and use elf32_arm_allocate_irelocs to allocate them.  Use stashed
+	section pointers intead of strcmp checks.  Handle iplt and igotplt.
+	(elf32_arm_finish_dynamic_symbol): Use elf32_arm_populate_plt_entry
+	to fill in .plt, .got.plt and .rel(a).plt entries.  Point
+	STT_GNU_IFUNC symbols at an .iplt entry if non-call relocations
+	resolve to it.
+	(elf32_arm_output_plt_map_1): New function, split out from
+	elf32_arm_output_plt_map.  Handle .iplt entries.  Use
+	elf32_arm_plt_needs_thumb_stub_p.
+	(elf32_arm_output_plt_map): Call it.
+	(elf32_arm_output_arch_local_syms): Add mapping symbols for
+	local .iplt entries.
+	(elf32_arm_swap_symbol_in): Handle Thumb STT_GNU_IFUNC symbols.
+	(elf32_arm_swap_symbol_out): Likewise.
+	(elf32_arm_add_symbol_hook): New function.
+	(elf_backend_add_symbol_hook): Define for all targets.
+
+2011-03-14  Richard Sandiford  <[email protected]>
+
+	* elf-bfd.h (elf_link_hash_entry): Add target_internal.
+	* elf.c (swap_out_syms): Set st_target_internal for each
+	Elf_Internal_Sym.
+	* elfcode.h (elf_swap_symbol_in): Likewise.
+	* elf32-i370.c (i370_elf_finish_dynamic_sections): Likewise.
+	* elf32-sh-symbian.c (sh_symbian_relocate_section): Likewise.
+	* elf64-sparc.c (elf64_sparc_output_arch_syms): Likewise.
+	* elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Likewise.
+	* elflink.c (elf_link_output_extsym): Likewise.
+	(bfd_elf_final_link): Likewise.
+	(elf_link_add_object_symbols): Copy st_target_internal
+	to the hash table if we see a definition.
+	(_bfd_elf_copy_link_hash_symbol_type): Copy target_internal.
+	* elf32-arm.c (elf32_arm_stub_hash_entry): Replace st_type with
+	a branch_type field.
+	(a8_erratum_fix, a8_erratum_reloc): Likewise.
+	(arm_type_of_stub): Replace actual_st_type with an
+	actual_branch_type parameter.
+	(arm_build_one_stub): Use branch types rather than st_types to
+	determine the type of branch.
+	(cortex_a8_erratum_scan): Likewise.
+	(elf32_arm_size_stubs): Likewise.
+	(bfd_elf32_arm_process_before_allocation): Likewise.
+	(allocate_dynrelocs_for_symbol): Likewise.
+	(elf32_arm_finish_dynamic_sections): Likewise.
+	(elf32_arm_final_link_relocate): Replace sym_flags parameter with
+	a branch_type parameter.
+	(elf32_arm_relocate_section): Update call accordingly.
+	(elf32_arm_adjust_dynamic_symbol): Don't check STT_ARM_TFUNC.
+	(elf32_arm_output_map_sym): Initialize st_target_internal.
+	(elf32_arm_output_stub_sym): Likewise.
+	(elf32_arm_symbol_processing): Delete.
+	(elf32_arm_swap_symbol_in): Convert STT_ARM_TFUNCs into STT_FUNCs.
+	Use st_target_internal to record the branch type.
+	(elf32_arm_swap_symbol_out): Use st_target_internal to test for
+	Thumb functions.
+	(elf32_arm_is_function_type): Delete.
+	(elf_backend_symbol_processing): Likewise.
+	(elf_backend_is_function_type): Likewise.
+
+2011-03-14  Richard Sandiford  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_check_relocs): Always assign a dynobj.
+	(elf32_arm_finish_dynamic_sections): Move sgot != NULL assertion
+	into the PLT block.
+
+2011-03-14  Richard Sandiford  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_check_relocs): Use call_reloc_p,
+	may_need_local_target_p and may_become_dynamic_p to classify
+	the relocation type.  Don't check info->symbolic or h->def_regular
+	when deciding whether to record a potential dynamic reloc.
+	Don't treat potential dynamic relocs as PLT references.
+	(elf32_arm_gc_sweep_hook): Update to match.  Assert that we don't
+	try to make the PLT reference count go negative.
+
+2011-03-14  Richard Sandiford  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_final_link_relocate): Always fill in the
+	GOT entry here, rather than leaving it to finish_dynamic_symbol.
+	Only create a dynamic relocation for local references if
+	info->shared.
+	(allocate_dynrelocs_for_symbol): Update dynamic relocation
+	allocation accordingly.
+	(elf32_arm_finish_dynamic_symbol): Don't initialise the GOT entry here.
+
+2011-03-14  Richard Sandiford  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_allocate_dynrelocs): New function.
+	(elf32_arm_add_dynreloc): Likewise.
+	(elf32_arm_adjust_dynamic_symbol): Use elf32_arm_allocate_dynrelocs
+	to allocate dynamic relocations.
+	(elf32_arm_size_dynamic_sections): Likewise.
+	(allocate_dynrelocs): Likewise.  Rename to
+	allocate_dynrelocs_for_symbol.
+	(elf32_arm_final_link_relocate): Use elf32_arm_add_dynreloc to
+	create dynamic relocations.
+	(elf32_arm_finish_dynamic_symbol): Likewise.
+
+2011-03-12  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_check_tls_transition): Supprt TLS
+	x32 GD->IE and GD->LE transitions.
+	(elf_x86_64_relocate_section): Supprt TLS x32 GD->IE, GD->LE
+	and LD->LE transitions.
+
+2011-03-10  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (ppc64_elf_relocate_section): Provide section/offset
+	for LO_DS error message and correct multiple.
+
+2011-03-10  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (bfd_elf64_bfd_link_just_syms): Define.
+	(ppc64_elf_link_just_syms): New function.
+	(opd_entry_value): Don't assume big-endian host.
+	(get_r2off): New function.
+	(ppc_build_one_stub, ppc_size_one_stub): Use it here.
+
+2011-03-06  Michael Snyder  <[email protected]>
+
+	* compress.c (bfd_compress_section_contents): Check for out of mem.
+
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Document
+	that case statement falls through intentionally.
+
+	* elf32-i386.c (elf_i386_relocate_section): Document fall through.
+
+2011-03-04  Alan Modra  <[email protected]>
+
+	* archive.c (bsd_write_armap): Don't call stat in deterministic
+	mode, and don't use st_mtime if stat returns error.
+
+2011-03-03  Michael Snyder  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Remove dead code.
+
+	* coff-x86_64.c (coff_amd64_rtype_to_howto): Fencepost error.
+
+	* aoutx.h (aout_final_link): Use sizeof int not sizeof int*.
+	(aout_link_write_other_symbol): Missing break statement.
+
+	* dwarf2.c (scan_unit_for_symbols): Stop memory leak.
+
+	* archive.c (_bfd_slurp_extended_name_table): Fail if bfd_seek fails.
+
+2011-03-03  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_check_tls_transition): Supprt TLS
+	x32 IE->LE transition.
+	(elf_x86_64_relocate_section): Likewise.
+
+2011-03-02  Bernd Schmidt  <[email protected]>
+
+	* elflink.c (is_reloc_section): Remove function.
+	(get_dynamic_reloc_section_name): Construct string manually.
+
+2011-02-28  Kai Tietz  <[email protected]>
+
+	* archive.c (_bfd_find_nested_archive): Use filename_(n)cmp.
+	(adjust_relative_path): Likewise.
+	(_bfd_construct_extended_name_table): Likewise.
+	* corefile.c (generic_core_file_matches_executable_p): Likewise.
+	* elf32-bfin.c (bfinfdpic_relocate_section): Likewise.
+	* elf32-frv.c (elf32_frv_relocate_section): Likewise.
+	* elf32-spu.c (sort_bfds): Likewise.
+	(spu_elf_auto_overlay): Likewise.
+	* syms.c (_bfd_stab_section_find_nearest_line): Likewise.
+	* xcofflink.c (xcoff_set_import_path): Likewise.
+	* xtensa-isa.c (xtensa_regfile_lookup): Likewise.
+	(xtensa_regfile_lookup_shortname): Likewise.
+
+2011-02-28  Alan Modra  <[email protected]>
+
+	PR 12513
+	* archive.c (bfd_slurp_bsd_armap_f2): Sanity check parsed_size and
+	stringsize.  Properly sanity check symdef_count.  Remove redundant
+	bfd_release.
+
+2011-02-25  Rafael Ávila de Espíndola <[email protected]>
+
+	* plugin.c (bfd_plugin_object_p): Correctly set the filesize
+	and handle claim_file seeking. Only try to load the plugin once.
+
+2011-02-22  Andreas Schwab  <[email protected]>
+
+	* elf32-m68k.c (elf_m68k_finish_dynamic_symbol): For a TLS_GD
+	relocation read the value from the second GOT slot.
+
+2011-02-15  Tristan Gingold  <[email protected]>
+
+	* vms-alpha.c (alpha_vms_link_add_archive_symbols): Add a comment.
+
+2011-02-15  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (ppc64_elf_edit_toc): Reinstate second read of
+	toc relocs.  Fuss over free(NULL).
+
+2011-02-14  Mike Frysinger  <[email protected]>
+
+	* elflink.c (bfd_elf_size_dynamic_sections): Add
+	bfd_get_symbol_leading_char to the start of newname.
+
+2011-02-13  Ralf Wildenhues  <[email protected]>
+
+	* configure: Regenerate.
+
+2011-02-09  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (ppc64_elf_edit_toc): Don't free toc relocs until
+	we are done.  When optimising large toc, check that a global
+	symbol on a toc reloc is defined in a kept section.
+
+2011-02-08  Nick Clifton  <[email protected]>
+
+	PR binutils/12467
+	* elf.c (assign_file_positions_for_load_sections): Set the program
+	header offset and entry size to zero if there are no program
+	headers.
+
+2011-02-08  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (ppc64_elf_edit_toc): Don't segfault on NULL
+	local_syms when looking for local symbols in .toc.
+
+2011-02-01  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (ppc64_elf_next_input_section): Use elf_gp value
+	for toc pointer on any section having makes_toc_func_call set.
+	(check_pasted_section): Ensure pasted .init/.fini fragments use
+	the same toc if any has makes_toc_func_call set.
+
+2011-01-28  Joseph Myers  <[email protected]>
+
+	* elf32-ppc.c (ppc_elf_link_hash_newfunc): Initialize has_sda_refs
+	field.
+
+2011-01-22  Richard Sandiford  <[email protected]>
+
+	* elfxx-mips.c (_bfd_mips_elf_merge_private_bfd_data): Ignore
+	common sections too.
+
+2011-01-18  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (elf_backend_want_plt_sym): Redefine to 0 after
+	Solaris target.
+
+2011-01-18  Pierre Muller  <[email protected]>
+
+	Fix compilation for mingw64.
+	* coffcode.h (coff_slurp_symbol_table): Add intptr_t intermediate
+	typecast to avoid warning.
+	* elf32-rx.c: Add "bfd_stdint.h" include required for int32_t type
+	usage.
+	* elfxx-ia64.c (elfNN_ia64_relax_br): Use intptr_t typeacast instead
+	of long for pointer to avoid warning.
+	(elfNN_ia64_relax_brl): Idem.
+	(elfNN_ia64_install_value): Idem.
+	* vms-alpha.c (_bfd_vms_slurp_etir): Idem.
+
+2011-01-17  Richard Sandiford  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_check_relocs): Check needs_plt rather than
+	h->needs_plt when deciding whether to record a possible dynamic reloc.
+
+2011-01-17  Richard Sandiford  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_gc_sweep_hook): Remove all registered
+	dynamic relocs for the removed section.
+
+2011-01-15  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_check_relocs): Check invalid x32
+	relocations.
+
+2011-01-14  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_link_hash_table): Add pointer_r_type.
+	(elf_x86_64_link_hash_table_create): Set pointer_r_type.
+	(elf_x86_64_check_relocs): Handle R_X86_64_32 like R_X86_64_64
+	for ILP32.  Remove ABI_64_P PIC check for R_X86_64_8,
+	R_X86_64_16, R_X86_64_32 and R_X86_64_32S.
+	(elf_x86_64_relocate_section):  Handle R_X86_64_32 like R_X86_64_64
+	for ILP32.
+
+2011-01-14  Alan Modra  <[email protected]>
+
+	* bfd.c (bfd_perror): Flush stdout before and stderr after printing
+	error.
+	(_bfd_default_error_handler): Likewise.
+	* elf.c (print_segment_map): Likewise.
+	* libbfd.c (warn_deprecated): Likewise.
+	* som.c (som_sizeof_headers): No need to do so here.
+	* coff-i860.c: Replace use of printf for error messages with
+	_bfd_error_handler.
+	* coff-ppc.c: Likewise.
+	* coff-sh.c: Likewise.
+	* elf32-bfin.c: Likewise.
+	* elf32-dlx.c: Likewise.
+	* elf32-mep.c: Likewise.
+	* elf32-v850.c: Likewise.
+	* mach-o.c: Likewise.
+	* pef.c: Likewise.
+
+2011-01-13  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_link_hash_table): Remove
+	swap_reloca_out.
+	(elf_x86_64_link_hash_table_create): Don't set swap_reloca_out.
+	(elf_x86_64_check_relocs): Align relocation section to 4 byte
+	for 32bit.
+	(elf_x86_64_gc_sweep_hook): Replace ELF64_ST_TYPE with
+	ELF_ST_TYPE.
+	(elf_x86_64_finish_dynamic_symbol): Updated.
+	(elf_x86_64_finish_dynamic_sections): Don't use
+	Elf64_External_Dyn, bfd_elf64_swap_dyn_in, nor
+	bfd_elf64_swap_dyn_out.
+
+2011-01-14  J. Park  <[email protected]>
+
+	PR ld/12339
+	* elf32-arm.c (allocate_dynrelocs): Don't set up eh before
+	following bfd_link_hash_warning symbol link.
+
+2011-01-10  Nathan Sidwell  <[email protected]>
+	    Glauber de Oliveira Costa  <[email protected]>
+
+	* reloc.c (BFD_RELOC_ARM_TLS_GOTDESC, BFD_RELOC_ARM_TLS_CALL,
+	BFD_RELOC_ARM_THM_TLS_CALL, BFD_RELOC_ARM_TLS_DESCSEQ,
+	BFD_RELOC_ARM_THM_TLS_DESCSEQ, BFD_RELOC_ARM_TLS_DESC): New
+	relocations.
+	* libbfd.h: Rebuilt.
+	* bfd-in2.h: Rebuilt.
+	* elf32-arm.c (elf32_arm_howto_table_1): Add new relocations.
+	(elf32_arm_reloc_map): Likewise.
+	(tls_trampoline, dl_tlsdesc_lazy_trampoline): New PLT templates.
+	(elf32_arm_stub_long_branch_any_tls_pic,
+	elf32_arm_stub_long_branch_v4t_thumb_tls_pic): New stub templates.
+	(DEF_STUBS): Add new stubs.
+	(struct_elf_arm_obj_data): Add local_tlsdesc_gotent field.
+	(elf32_arm_local_tlsdesc_gotent): New.
+	(GOT_TLS_GDESC): New mask.
+	(GOT_TLS_GD_ANY): Define.
+	(struct elf32_arm_link_hash_entry): Add tlsdesc_got field.
+	(elf32_arm_compute_jump_table_size): New.
+	(struct elf32_arm_link_hash_table): Add next_tls_desc_index,
+	num_tls_desc, dt_tlsdesc_plt, dt_tlsdesc_got, tls_trampoline,
+	sgotplt_jump_table_size fields.
+	(elf32_arm_link_hash_newfunc): Initialize tlsdesc_got field.
+	(elf32_arm_link_hash_table_create): Initialize new fields.
+	(arm_type_of_stub): Check TLS desc relocs too.
+	(elf32_arm_stub_name): TLS desc relocs can be shared.
+	(elf32_arm_tls_transition): Determine relaxation.
+	(arm_stub_required_alignment): Add tls stubs.
+	(elf32_arm_size_stubs): Likewise.
+	(elf32_arm_tls_relax): Perform TLS relaxing.
+	(elf32_arm_final_link_relocate): Process TLS DESC relocations.
+	(IS_ARM_TLS_GNU_RELOC): New.
+	(IS_ARM_TLS_RELOC): Use it.
+	(elf32_arm_relocate_section): Perform TLS relaxing.
+	(elf32_arm_check_relocs): Anticipate TLS relaxing, process tls
+	desc relocations.
+	(allocate_dynrelocs): Allocate tls desc relcoations.
+	(elf32_arm_output_arch_local_syms): Emit tls trampoline mapping
+	symbols.
+	(elf32_arm_size_dynamic_sections): Allocate tls trampolines and
+	got slots.
+	(elf32_arm_always_size_sections): New. Create _TLS_MODULE_BASE
+	symbol.
+	(elf32_arm_finish_dynamic_symbol): Adjust.
+	(arm_put_trampoline): New.
+	(elf32_arm_finish_dynamic_sections): Emit new dynamic tags and tls
+	trampolines.
+	(elf_backend_always_size_sections): Define.
+
+2011-01-06  H.J. Lu  <[email protected]>
+
+	* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Optimized.
+
+2011-01-06  H.J. Lu  <[email protected]>
+
+	PR ld/12366
+	PR ld/12371
+	* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Properly
+	handle symbols marked with regular reference, but not non-GOT
+	reference when building shared library.
+
+	* elf32-i386.c (elf_i386_gc_sweep_hook): Properly handle
+	local and global STT_GNU_IFUNC symols when building shared
+	library.
+	* elf64-x86-64.c (elf_x86_64_gc_sweep_hook): Likewise.
+
+2011-01-05  DJ Delorie  <[email protected]>
+
+	* reloc.c: Add BFD_RELOC_RX_OP_NEG.
+	* libbfd.h: Regenerate.
+	* bfd-in2.h: Regenerate.
+	* elf32-rx.c: Add it to the list, corresponding to R_RX_OPneg.
+
+2011-01-03  H.J. Lu  <[email protected]>
+
+	* cpu-i386.c (bfd_i386_compatible): New.
+	(bfd_x64_32_arch_intel_syntax): Replace bfd_default_compatible
+	with bfd_i386_compatible.
+	(bfd_x86_64_arch_intel_syntax): Likewise.
+	(bfd_i386_arch_intel_syntax): Likewise.
+	(i8086_arch): Likewise.
+	(bfd_x64_32_arch): Likewise.
+	(bfd_x86_64_arch): Likewise.
+	(bfd_i386_arch): Likewise.
+
+For older changes see ChangeLog-2010
+
+Copyright (C) 2011 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
+
+Local Variables:
+mode: change-log
+left-margin: 8
+fill-column: 74
+version-control: never
+End:
diff --git a/bfd/ChangeLog-2012 b/bfd/ChangeLog-2012
new file mode 100644
index 0000000..7d82ace
--- /dev/null
+++ b/bfd/ChangeLog-2012
@@ -0,0 +1,3300 @@
+2012-12-23  Mike Frysinger  <[email protected]>
+
+	* config.bfd (i[3-7]86-*-linux-*): Add x86_64pei_vec to
+	targ64_selvecs.
+
+2012-12-21  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Check
+	R_X86_64_standard instead of R_X86_64_max for unrecognized
+	relocation.
+
+2012-12-21  H.J. Lu  <[email protected]>
+
+	PR ld/14980
+	* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Properly
+	adjust h->plt.refcount.
+	* elf64-x86-64.c (elf_x86_64_adjust_dynamic_symbol): Likewise.
+
+2012-12-19  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_relocate_section): Replace
+	bfd_elf32_swap_reloc_out with elf_append_rel.
+	(elf_i386_finish_dynamic_symbol): Likewise.
+
+	* elflink.c (elf_append_rel): Call swap_reloc_out instead of
+	swap_reloca_out.
+
+2012-12-18  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_finish_dynamic_symbol): Reindent.
+
+2012-12-18  Edgar E. Iglesias <[email protected]>
+
+	PR ld/14736
+	* elf32-microblaze.c (calc_fixup): Add end range.
+
+2012-12-18  Alan Modra  <[email protected]>
+
+	* elf.c (swap_out_syms): Set shndx to SHN_ABS when not one of
+	the special MAP_* values.
+
+2012-12-17  Roland McGrath  <[email protected]>
+	    Alan Modra  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_size_stubs): Skip input BFDs that are
+	not ARM ELF.
+
+2012-12-17  Nick Clifton  <[email protected]>
+
+	* MAINTAINERS: Add copyright notice.
+	* Makefile.am: Likewise.
+	* PORTING: Likewise.
+	* README: Likewise.
+	* TODO: Likewise.
+	* acinclude.m4: Likewise.
+	* bfd.m4: Likewise.
+	* config.bfd: Likewise.
+	* configure.com: Likewise.
+	* configure.host: Likewise.
+	* configure.in: Likewise.
+	* makefile.vms: Likewise.
+	* warning.m4: Likewise.
+	* elf64-hppa.c: Fix copyright notice.
+	* Makefile.in: Regenerate.
+
+2012-12-16  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_check_relocs): Don't check IFUNC
+	relocations here.
+	* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
+
+2012-12-16  H.J. Lu  <[email protected]>
+
+	PR ld/14968
+	* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Also check
+	local IFUNC references.
+	* elf64-x86-64.c (elf_x86_64_adjust_dynamic_symbol): Likewise.
+
+2012-12-14  Tom Tromey  <[email protected]>
+
+	* elf.c (elfcore_grok_note) <NT_FILE>: New case.
+
+2012-12-13  H.J. Lu  <[email protected]>
+
+	PR ld/14956
+	* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Check local
+	IFUNC calls.
+	* elf64-x86-64.c (elf_x86_64_adjust_dynamic_symbol): Likewise.
+
+2012-12-10  Edgar E. Iglesias <[email protected]>
+
+	* reloc.c (MICROBLAZE): Document new relocations
+	* bfd-in2.h: Regenerated
+	* libbfd.h: Regenerated
+	* elf32-microblaze.c (microblaze_elf_howto_raw): Add TLS relocations
+	(microblaze_elf_reloc_type_lookup): Likewise
+	(elf32_mb_link_hash_entry): define TLS reference types
+	(elf32_mb_link_hash_table): add TLS Local dynamic GOT entry
+	#define has_tls_reloc if section has TLS relocs
+	(dtprel_base), (check_unique_offset): New
+	(microblaze_elf_output_dynamic_relocation): output simple
+	dynamic relocation into SRELOC.
+	(microblaze_elf_relocate_section): Accommodate TLS relocations.
+	(microblaze_elf_check_relocs): Likewise
+	(update_local_sym_info): New
+	(microblaze_elf_copy_indirect_symbol): Add tls_mask.
+	(allocate_dynrelocs): Handle TLS symbol
+	(microblaze_elf_size_dynamic_sections): Set size and offset
+	(microblaze_elf_finish_dynamic_symbol): Use
+	microblaze_elf_output_dynamic_relocation
+
+2012-12-09  H.J. Lu  <[email protected]>
+
+	PR binutils/14933
+	* archive.c (bsd_write_armap): Properly check indicies bigger
+	than 4Gb.
+
+2012-12-07  Alan Modra  <[email protected]>
+
+	PR ld/14926
+	* elf.c (_bfd_elf_map_sections_to_segments): Include elf header
+	size when determining phdr_in_segment.
+
+2012-12-06  Yufeng Zhang  <[email protected]>
+
+	* elf64-aarch64.c (elf64_aarch64_grok_prstatus): New function.
+	(elf_backend_grok_prstatus): Define to elf64_aarch64_grok_prstatus.
+
+2012-12-06  Alan Modra  <[email protected]>
+
+	* elfxx-mips.c (allocate_dynrelocs): Correct test for symbol
+	defined in a regular file to include common symbols.
+
+2012-12-05  Leif Ekblad  <[email protected]>
+
+	* config.bfd: Add x86_64-*-rdos.
+
+2012-12-05  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (build_plt_stub): Fix off by one error in branch
+	to glink.
+
+2012-12-03  Maciej W. Rozycki  <[email protected]>
+
+	PR ld/10629
+	* elfxx-mips.c (mips_elf_link_hash_table): Update comment for
+	use_rld_obj_head.
+	(_bfd_mips_elf_create_dynamic_sections): Always create a
+	.rld_map section if no __rld_obj_head symbol has been seen.
+
+2012-12-03  Maciej W. Rozycki  <[email protected]>
+
+	* elf32-mips.c (mips_elf32_object_p): Return right away when the
+	ABI is not compatible.
+	* elfn32-mips.c (mips_elf_n32_object_p): Likewise.
+
+2012-12-03  Maciej W. Rozycki  <[email protected]>
+
+	* elf32-tilepro.c (tilepro_elf_mkobject): New function.
+	(bfd_elf32_mkobject): New macro.
+
+2012-12-03  Maciej W. Rozycki  <[email protected]>
+
+	* elf32-mips.c (bfd_elf32_mkobject): New macro.
+	* elf64-mips.c (bfd_elf64_mkobject): Likewise.
+	* elfn32-mips.c (bfd_elf32_mkobject): Likewise.
+	* elfxx-mips.h (_bfd_mips_elf_mkobject): New prototype.
+	* elfxx-mips.c (mips_elf_obj_tdata): New struct.
+	(mips_elf_tdata): New macro.
+	(_bfd_mips_elf_mkobject): New function.
+	(mips_elf_merge_obj_attributes): Report the originating input BFD
+	on attribute conflicts.
+
+2012-12-03  Maciej W. Rozycki  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_merge_obj_attributes): Correct messages
+	for the -mdouble-float and -msingle-float cases throughout; make
+	all the messages report the output file consistently on the
+	left-hand side.
+
+2012-11-29  Roland McGrath  <[email protected]>
+
+	* elf-nacl.c (segment_eligible_for_headers): Disallow writable segments.
+
+2012-11-26  Roland McGrath  <[email protected]>
+
+	* elf-nacl.c (nacl_modify_segment_map): Don't crash when INFO is null.
+
+2012-11-21  H.J. Lu  <[email protected]>
+
+	PR binutils/14493
+	* elf.c (copy_elf_program_header): When rewriting program
+	header, set the output maxpagesize to the maximum alignment
+	of input PT_LOAD segments.
+
+2012-11-21  Roland McGrath  <[email protected]>
+
+	* elf-nacl.c (segment_nonexecutable_and_has_contents): Renamed to ...
+	(segment_eligible_for_headers): ... this.  Take new arguments
+	MAXPAGESIZE and SIZEOF_HEADERS.  Return false if the first section's
+	start address doesn't leave space for the headers.
+	(nacl_modify_segment_map): Update caller.
+
+2012-11-20  H.J. Lu  <[email protected]>
+
+	PR ld/14862
+	* elf-bfd.h (elf_link_hash_entry): Remove ref_dynamic_nonweak
+	added by accident.
+	(elf_link_add_object_symbols): Don't set nor check
+	ref_dynamic_nonweak.
+
+2012-11-20  Alan Modra  <[email protected]>
+
+	* elf32-rx.c (rx_elf_print_private_bfd_data): Warning fix.
+
+2012-11-16  Joey Ye  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_final_link_relocate
+	<case R_ARM_THM_ALU_PREL_11_0, case R_ARM_THM_PC12>): Align address of
+	the place being relocated.
+	(elf32_arm_final_link_relocate, case R_ARM_THM_PC8): Align address
+	of the place being relocated and truncate addend.
+	(Pa): New macro.
+
+2012-11-14  Roland McGrath  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_nacl_plt0_entry): Use bic rather than bfc
+	instruction for data sandboxing.
+
+2012-11-14  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_read_main)
+	(bfd_mach_o_read_source_version): New functions.
+	(bfd_mach_o_read_command): Handle BFD_MACH_O_LC_DATA_IN_CODE,
+	BFD_MACH_O_LC_DYLIB_CODE_SIGN_DRS, BFD_MACH_O_LC_MAIN,
+	BFD_MACH_O_LC_SOURCE_VERSION.
+	* mach-o.h (bfd_mach_o_main_command)
+	(bfd_mach_o_source_version_command): New types.
+	(bfd_mach_o_load_command): Add fields for these new types.
+
+2012-11-14  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_canonicalize_one_reloc): Add a special
+	handling for non-scattered pairs.  Update comments.
+
+2012-11-13  Joe Seymour  <[email protected]>
+
+	* elf.c (rewrite_elf_program_header): Allocate elf_segment_map
+	with bfd_zalloc, instead of bfd_alloc.
+
+2012-11-09  Nick Clifton  <[email protected]>
+
+	* Makefile.am (ALL_MACHINES): Add cpu-v850-rh850.lo.
+	(ALL_MACHINES_CFILES): Add cpu-v850-rh850.c.
+	* archures.c (bfd_arch_info): Add bfd_v850_rh850_arch.
+	* config.bfd: Likewise.
+	* configure.in: Add bfd_elf32_v850_rh850_vec.
+	* cpu-v850.c: Update printed description.
+	* cpu-v850_rh850.c: New file.
+	* elf32-v850.c (v850_elf_check_relocs): Add support for RH850 ABI
+	relocs.
+	(v850_elf_perform_relocation): Likewise.
+	(v850_elf_final_link_relocate): Likewise.
+	(v850_elf_relocate_section): Likewise.
+	(v850_elf_relax_section): Likewise.
+	(v800_elf_howto_table): New.
+	(v850_elf_object_p): Add support for RH850 ABI values.
+	(v850_elf_final_write_processing): Likewise.
+	(v850_elf_merge_private_bfd_data): Likewise.
+	(v850_elf_print_private_bfd_data): Likewise.
+	(v800_elf_reloc_map): New.
+	(v800_elf_reloc_type_lookup): New.
+	(v800_elf_reloc_name_lookup): New.
+	(v800_elf_info_to_howto): New.
+	(bfd_elf32_v850_rh850_vec): New.
+	(bfd_arch_v850_rh850): New.
+	* targets.c (_bfd_targets): Add bfd_elf32_v850_rh850_vec.
+	* Makefile.in: Regenerate.
+	* bfd-in2.h: Regenerate.
+	* configure: Regenerate.
+
+	* elf32-rx.c (describe_flags): New function.  Returns a buffer
+	containing a description of the E_FLAG_RX_... values set.
+	(rx_elf_merge_private_bfd_data): Use it.
+	(rx_elf_print_private_bfd_data): Likewise.
+	(elf32_rx_machine): Skip EF_RX_CPU_RX check.
+	(elf32_rx_special_sections): Define.
+	(elf_backend_special_sections): Define.
+
+2012-11-09  Edgar E. Iglesias <[email protected]>
+
+	* config.bfd: Add microblazeel-*-*
+	* configure.in: Likewise.
+	* configure: Regenerate.
+	* elf32-microblaze.c (microblaze_elf_relocate_section): Add endian awareness.
+	(microblaze_elf_merge_private_bfd_data): New.
+	(microblaze_bfd_write_imm_value_32): New.
+	(microblaze_bfd_write_imm_value_64): New.
+	(microblaze_elf_relax_section): Add endian awareness.
+	(microblaze_elf_add_symbol_hook): Define TARGET_LITTLE_NAME,
+	TARGET_LITTLE_SYM and bfd_elf32_bfd_merge_private_bfd_data.
+	* targets.c: Add bfd target bfd_elf32_microblazeel_vec.
+
+2012-11-09  H.J. Lu  <[email protected]>
+
+	* aout-tic30.c (MY_final_link_callback): Remove trailing
+	redundant `;'.
+	* coff-h8500.c (extra_case): Likewise.
+	(bfd_coff_reloc16_get_value): Likewise.
+	* dwarf2.c (_bfd_dwarf2_cleanup_debug_info): Likewise.
+	* elf.c (_bfd_elf_slurp_version_tables): Likewise.
+	* elf32-frv.c (elf32_frv_relocate_section): Likewise.
+	* elf32-v850.c (v850_elf_perform_relocation): Likewise.
+	* opncls.c (bfd_calc_gnu_debuglink_crc32): Likewise.
+	* plugin.c (add_symbols): Likewise.
+	* reloc.c (bfd_check_overflow): Likewise.
+	* vms-lib.c (_bfd_vms_lib_archive_p): Likewise.
+
+2012-11-08  Tom Tromey  <[email protected]>
+
+	* elf.c (elfcore_grok_note) <NT_SIGINFO>: New case; make
+	pseudosection.
+
+2012-11-08  Alan Modra  <[email protected]>
+
+	* aclocal.m4: Regenerate.
+	* Makefile.in: Regenerate.
+	* po/SRC-POTFILES.in: Regenerate.
+
+2012-11-07  H.J. Lu  <[email protected]>
+
+	* section.c (bfd_get_section_contents): Replace memcpy
+	with memmove.
+
+2012-11-07  Hans-Peter Nilsson  <[email protected]>
+
+	PR binutils/14481
+	* aout-target.h (MY_close_and_cleanup): Make local function
+	instead of alias of MY_bfd_free_cached_info.  Also call
+	_bfd_generic_close_and_cleanup.
+
+2012-11-06  H.J. Lu  <[email protected]>
+
+	PR binutils/14813
+	* bfdio.c (bfd_iovec): Change return type of bclose to
+	bfd_boolean.
+	(memory_bclose): Change return type to bfd_boolean.
+	* cache.c (cache_bclose): Likewise.
+	* opncls.c (opncls_bclose): Likewise.  Return TRUE on success.
+	* vms-lib.c (vms_lib_bclose): Likewise.  Return TRUE.
+	* libbfd.h: Regenerated.
+
+2012-11-06  Tristan Gingold  <[email protected]>
+
+	* coff-x86_64.c (_bfd_generic_find_nearest_line_discriminator):
+	Define as coff_find_nearest_line_discriminator.
+
+2012-11-06  Alan Modra  <[email protected]>
+
+	PR binutils/14567
+	* opncls.c (opncls_iovec): Forward declare.
+	(_bfd_new_bfd_contained_in): If using opncls_iovec, copy iostream
+	to new bfd.
+
+2012-11-06  Alan Modra  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_close_and_cleanup): Don't call
+	_bfd_generic_close_and_cleanup for mach_o_fat archives.
+
+2012-11-06  Alan Modra  <[email protected]>
+
+	* coff-tic4x.c (tic4x_coff0_vec, tic4x_coff0_beh_vec,
+	tic4x_coff1_vec, tic4x_coff1_beh_vec, tic4x_coff2_vec,
+	tic4x_coff2_beh_vec): Allow SEC_CODE and SEC_READONLY in
+	section flags.
+	* coff-ppc.c (TARGET_LITTLE_SYM): Likewise.
+	(TARGET_BIG_SYM): Likewise.
+
+2012-11-06  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (struct ppc_link_hash_table): Add dot_toc_dot.
+	(ppc64_elf_size_stubs): Lookup ".TOC.".
+	(ppc64_elf_relocate_section): Resolve special symbol ".TOC.".
+
+2012-11-06  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (maybe_strip_output): Heed SEC_KEEP.
+
+2012-11-05  Andreas Krebbel  <[email protected]>
+
+	PR target/14788
+	* elf32-s390.c (elf_s390_relocate_section): Set elf.dynobj for
+	local ifunc symbols.
+	* elf64-s390.c (elf_s390_relocate_section): Likewise.
+
+2012-11-05  Alan Modra  <[email protected]>
+
+	* configure.in: Apply 2012-09-10 change to config.in here.
+
+2012-11-05  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (ppc64_elf_edit_toc): Clear "repeat" inside
+	loop.  Really mark toc entry referring to another toc entry
+	only if the first is used.
+
+2012-10-30  H.J. Lu  <[email protected]>
+
+	* configure.in: Also handle --enable-64-bit-bfd when setting
+	CORE_HEADER for 'i[3-7]86-*-linux-*'.
+
+2012-10-30  Steve McIntyre  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_print_private_bfd_data): Recognise and
+	display the new ARM hard-float/soft-float ABI flags for EABI_VER5
+	(elf32_arm_post_process_headers): Add the hard-float/soft-float
+	ABI flag as appropriate for ET_DYN/ET_EXEC in EABI_VER5.
+
+2012-10-30  Yao Qi  <[email protected]>
+	    H.J. Lu  <[email protected]>
+
+	* configure.in: Set CORE_HEADER to hosts/x86-64linux.h for
+	'i[3-7]86-*-linux-*' if x86_64-*linux is enabled.
+	* configure: Regenerated.
+
+	* elf64-x86-64.c (elf_x86_64_write_core_note): Replace type
+	'prpsinfo_t' and 'prstatus_t' with 'prpsinfo64_t' and
+	'prstatus64_t' respectively.
+
+	* hosts/x86-64linux.h (a8_uint64_t): New.
+	(user_regsx32_struct): Renamed to ...
+	(user_regs64_struct): This.  Replace uint64_t with a8_uint64_t.
+	(elf_gregx32_t): Renamed to ...
+	(elf_greg64_t): This.  Replace uint64_t with a8_uint64_t.
+	(ELF_NGREGX32): Removed.
+	(ELF_NGREG64): New.
+	(elf_gregx32_t): Removed.
+	(elf_greg64_t): New.
+	(struct prstatus64_timeval): New.
+	(elf_prstatusx32): Replace elf_gregsetx32_t with elf_gregset64_t.
+	(elf_prstatus64): New.
+	(elf_prpsinfo64): New.
+	(prstatus64_t, prpsinfo64_t): New typedef.
+
+2012-10-29  Sean Keys <[email protected]>
+
+	* elf32-xgate.c(elf_xgate_howto_table): Fix src and dest mask for
+	R_XGATE_16
+
+2012-10-29  Alan Modra  <[email protected]>
+
+	* elf32-ppc.c (ppc_elf_howto_raw): Correct dst_mask in
+	R_PPC_VLE_LO16A, R_PPC_VLE_HI16A, R_PPC_VLE_HA16A,
+	R_PPC_VLE_SDAREL_LO16A, R_PPC_VLE_SDAREL_HI16A,
+	R_PPC_VLE_SDAREL_HA16A reloc howtos.
+
+2012-10-26  Nick Clifton  <[email protected]>
+
+	* po/uk.po: Updated Ukranian translation.
+
+2012-10-26  Alan Modra  <[email protected]>
+
+	PR gas/14758
+	* elf32-ppc.c (ppc_elf_reloc_type_lookup): Decode ppc64 _DS
+	bfd_reloc values.  Map to corresponding D-form relocs.
+	(is_insn_ds_form, is_insn_qs_form): New functions.
+	(ppc_elf_relocate_section): Validate insn with DS-form or DQ-form
+	fields using D-form reloc.
+
+2012-10-25  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_size_dynamic_sections): Replace
+	_GLOBAL_OFFSET_TABLE_ lookup with htab->elf.hgot.
+	* elf64-x86-64.c (elf_x86_64_size_dynamic_sections): Likewise.
+
+2012-10-24  H.J. Lu  <[email protected]>
+
+	* compress.c (bfd_is_section_compressed): Don't decompress the
+	section.
+
+2012-10-23  Nathan Sidwell  <[email protected]>
+
+	* bfd-in.h (bfd_elf_stack_segment_size): Declare.
+	* bfd-in2.h: Rebuilt.
+	* elfxx-target.h (elf_backend_stack_align): New.
+	(elfNN_bed): Add it.
+	* elf-bfd.h (struct elf_backend_data): Add stack_align field.
+	* elf.c (bfd_elf_map_sections_to_segments): Pay attention to
+	stack_align and stacksize for PT_GNU_STACK segment.
+	(assign_file_positions_for_non_load_sections): Set p_memsz for
+	PT_GNU_STACK segment.
+	(copy_elf_program_header): Copy PT_GNU_STACK size.
+	* elflink.c (bfd_elf_stack_segment_size): New function, taken from
+	uclinux backends.
+	(bfd_elf_size_dynamic_sections): Determine
+	PT_GNU_STACK requirements after calling backend.  Pay attention to
+	stacksize.
+	* elf32-bfin.c (elf32_bfinfdpic_always_size_sections): Call
+	bfd_elf_stack_segment_size.
+	(elf32_bfinfdpic_modify_program_headers): Delete.
+	(elf32_bfingfdpic_copy_private_bfd_data): Don't copy PT_GNU_STACK
+	here.
+	(elf_backend_stack_align): Override.
+	(elf_backend_modify_program_headers): Don't override.
+	* elf32-frv.c (frvfdpic_always_size_sections): Call
+	bfd_elf_stack_segment_size.
+	(elf32_frvfdpic_modify_program_headers): Delete.
+	(elf32_frvfdpic_copy_private_bfd_data): Don't copy PT_GNU_STACK
+	here.
+	(elf_backend_stack_align): Override.
+	(elf_backend_modify_program_headers): Don't override.
+	* elf32-lm32.c (lm32_elf_always_size_sections): Leave
+	PT_GNU_STACK creation to underlying elf support.  Check
+	__stacksize here for backwards compatibility, and set it if
+	needed.
+	(lm32_elf_modify_segment_map): Delete.
+	(lm32_elf_modify_program_headers): Delete.
+	(elf_backend_stack_align): Override.
+	(elf_backend_modify_segment_map): Don't override.
+	(elf_backend_modify_program_headers): Don't override.
+	* elf32-sh.c (sh_elf_always_size_sections): Call
+	bfd_elf_stack_segment_size.
+	(sh_elf_modify_program_headers): Delete.
+	(sh_elf_copy_private_data): Don't copy PT_GNU_STACK
+	here.
+	(elf_backend_stack_align): Override.
+	(elf_backend_modify_program_headers): Don't override.
+	* elf32-tic6x.c (elf32_tic6x_always_size_sections): Call
+	bfd_elf_stack_segment_size.
+	(elf32_tic6x_modify_program_headers): Delete.
+	(elf32_tic6x_copy_private_data): Delete.
+	(elf_backend_stack_align): Override.
+	(bfd_elf32_bfd_copy_private_bfd_data): Don't override.
+	(elf_backend_modify_program_headers): Don't override.
+
+2012-10-22  Alan Modra  <[email protected]>
+
+	* cache.c (cache_bmmap): Don't use void* arithmetic.
+
+2012-10-21  Alan Modra  <[email protected]>
+
+	* compress.c (bfd_cache_section_contents): New function.
+	* bfd-in2.h: Regenerate.
+
+2012-10-21  Hans-Peter Nilsson  <[email protected]>
+
+	* linker.c (_bfd_generic_link_output_symbols): Handle a
+	no-longer-global symbol entered through a plugin.
+
+2012-10-20  Alan Modra  <[email protected]>
+
+	* compress.c: Reinstate 2012-10-19 change.
+	(bfd_get_full_section_contents): Don't free unless we alloc.
+	Use proper decompress size.  Delete some vars, rename others.
+
+2012-10-19  Tom Tromey  <[email protected]>
+
+	* compress.c: Revert previous patch.
+
+2012-10-19  Tom Tromey  <[email protected]>
+
+	* compress.c (bfd_get_full_section_contents): Don't cache
+	decompressed contents.
+
+2012-10-18  Kai Tietz  <[email protected]>
+
+	PR binutils/14067
+	* coff-i386.c (bfd_target): Add section flag SEC_EXCLUDE.
+	Allow BFD_COMPRESS and BFD_DECOMPRESS flags.
+	* coff-x86_64.c: Likewise.
+	* coffcode.h (DOT_ZDEBUG): New define.
+	(sec_to_styp_flags): Check for .zdebug.
+	(styp_to_sec_flags): Likewise.
+	* coffgen.c (make_a_section): Handle .debug_* section
+	compression/decompression flags.
+	* cofflink.c (mark_relocs): Ignore relocations
+	for a section, which isn't marked as used.
+	(_bfd_coff_link_input_bfd): Add support of compressed
+	debug sections.
+	* compress.c (decompress_contents): Loop as long
+	as there is input available and there is room for
+	output.
+	* bfd/pe-arm.c: Add .zdebug_ partial match entry.
+	* pe-i386.c: Likewise.
+	* pe-x86_64.c: Likewise.
+	* peXXigen.c (_bfd_XXi_swap_aouthdr_out): Don't clear all
+	data-directories as this might destroy content.
+
+	* coff-i386.c (_bfd_generic_find_nearest_line_discriminator):
+	define as coff_find_nearest_line_discriminator.
+	* libcoff-in.h (coff_find_nearest_line_discriminator): New
+	* libcoff.h: Regenerated.
+	* coff-x86_64.c: Likewise.
+	* coffgen.c (coff_find_nearest_line_discriminator): New function.
+	prototype.
+
+2012-10-16  Joel Brobecker  <[email protected]>
+
+	* coff64-rs6000.c (rs6000coff64_vec): Set _close_and_cleanup
+	field to _bfd_archive_close_and_cleanup.
+	(aix5coff64_vec): Likewise.
+
+2012-10-16  Joel Brobecker  <[email protected]>
+
+	* coff-rs6000.c (rs6000coff_vec): Set _close_and_cleanup
+	field to _bfd_archive_close_and_cleanup.
+	(pmac_xcoff_vec): Likewise.
+
+2012-10-16  Sofiane Naci  <[email protected]>
+
+	* elf64-aarch64.c (elf64_aarch64_tls_howto_table): Fix shift value for
+	R_AARCH64_TLSIE_LD_GOTTPREL_PREL19, R_AARCH64_TLSLE_MOVW_TPREL_G2,
+	R_AARCH64_TLSLE_MOVW_TPREL_G1, R_AARCH64_TLSLE_MOVW_TPREL_G1_NC,
+	R_AARCH64_TLSLE_ADD_TPREL_HI12.
+	(elf64_aarch64_tlsdesc_howto_table): Fix shift value for
+	R_AARCH64_TLSDESC_LD64_PREL19 and R_AARCH64_TLSDESC_OFF_G1.
+	(elf64_aarch64_final_link_relocate): Add signed_addend when resolving
+	AARCH64_TLSLE_*_TPREL_* relocations.
+
+2012-10-16  Alan Modra  <[email protected]>
+
+	* elf32-xtensa.c (free_section_cache): Renamed from
+	clear_section_cache.  Don't zero cache.
+	(section_cache_section): Remove ineffectual zero of cache.
+	Call init_section_cache instead.
+
+2012-10-15  Doug Evans  <[email protected]>
+
+	* elf.c (special_sections_d): Add comment.
+
+2012-10-13  H.J. Lu  <[email protected]>
+
+	PR bfd/14430
+	* Makefile.am (LIBDL): Replace -ldl with @lt_cv_dlopen_libs@.
+	* configure.in (lt_cv_dlopen_libs): AC_SUBST.
+	* Makefile.in: Regenerated.
+	* configure: Likewise.
+
+2012-10-08  Alan Modra  <[email protected]>
+
+	PR binutils/14662
+	* elf.c (_bfd_elf_make_section_from_shdr): Treat .gdb_index as
+	SEC_DEBUGGING.
+
+2012-09-20  Walter Lee  <[email protected]>
+
+	* elf32-tilepro.c (tilepro_elf_relocate_section): Adjust got
+	relocations with value of hgot.
+	* elfxx-tilegx.c (tilegx_elf_relocate_section): Ditto.
+
+2012-09-19  Steve Ellcey  <[email protected]>
+
+	* config.bfd: Add mips*-mti-elf* target.
+
+2012-09-18  H.J. Lu  <[email protected]>
+
+	PR ld/14591
+	* elf-bfd.h (_bfd_elf_merge_symbol): Add an argument to return
+	if the old symbol is weak.
+
+	* elf32-sh-symbian.c (sh_symbian_relocate_section): Update
+	_bfd_elf_merge_symbol call.
+
+	* elflink.c (_bfd_elf_merge_symbol): Add an argument to return
+	if the old symbol is weak.
+	(_bfd_elf_add_default_symbol): Update _bfd_elf_merge_symbol
+	call.
+	(elf_link_add_object_symbols): Don't update symbol type from a
+	weak definition.  Update symbol type from a common symbol when
+	overriding a weak symbol.
+
+2012-09-17  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_convert_mov_to_lea): Ignore discarded
+	section.
+	* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Likewise.
+
+2012-09-17  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_finish_dynamic_symbol): Replace return
+	FALSE with abort.
+	* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Likewise.
+
+2012-09-17  Walter Lee  <[email protected]>
+
+	* elf32-tilepro.c (tilepro_elf_relocate_section): Remove unused
+	got_base variable.
+	* elfxx-tilegx.c (tilegx_elf_relocate_section): Ditto.
+
+2012-09-17  Walter Lee  <[email protected]>
+
+	* elf32-tilepro.c (tilepro_elf_relocate_section): Fix computation
+	of got relocations for when .got.plt section is merged with .got.
+	* elfxx-tilegx.c (tilegx_elf_relocate_section): Ditto.
+
+2012-09-14  David Edelsohn  <[email protected]>
+
+	* configure: Regenerate.
+
+2012-09-13  Anthony Green  <[email protected]>
+
+	* targets.c (bfd_elf32_bigmoxie_vec, bfd_elf32_littlemoxie_vec):
+	Define.
+	(bfd_elf32_moxie_vec): Remove.
+	* config.bfd, configure.in: Add bi-endian support for moxie.
+	* configure: Rebuilt.
+	* elf32-moxie.c (TARGET_LITTLE_NAME, TARGET_LITTLE_SYM): Define.
+	(TARGET_BIG_NAME, TARGET_BIG_SYM): Update for bi-endian support.
+
+2012-09-12  Doug Kwan  <[email protected]>
+
+	* elf64-ppc.c (ppc64_elf_relocate_section): Use pre-adjusted
+	relocation for stub lookup.
+
+2012-09-12  Chris Schlumberger-Socha  <[email protected]>
+
+	* bfd-in2.h: Regenerated.
+	* elf64-aarch64.c
+	(elf64_aarch64_howto_table): Add R_AARCH64_GOT_LD_PREL19 reloc to HOWTO.
+	(elf64_aarch64_reloc_map): Add reloc entry.
+	(aarch64_resolve_relocation): Likewise.
+	(bfd_elf_aarch64_put_addend): Likewise.
+	(aarch64_reloc_got_type): Likewise.
+	(elf64_aarch64_final_link_relocate): Likewise.
+	(lf64_aarch64_check_relocs): Likewise.
+	(elf64_aarch64_check_relocs): New case for R_AARCH64_ADR_PREL_LO21
+	reloc.
+	* libbfd.h: Regenerated.
+	* reloc.c (R_AARCH64_GOT_LD_PREL19): New reloc.
+
+2012-09-10  Matthias Klose  <[email protected]>
+
+	* config.in: Disable sanity check for kfreebsd.
+
+2012-09-10  H.J. Lu  <[email protected]>
+
+	* configure: Regenerated.
+
+2012-09-04  Sergey A. Guriev <[email protected]>
+
+	* cpu-ia64-opc.c (ins_cnt6a): New function.
+	(ext_cnt6a): Ditto.
+	(ins_strd5b): Ditto.
+	(ext_strd5b): Ditto.
+	(elf64_ia64_operands): Add new operand types.
+
+2012-09-04  H.J. Lu  <[email protected]>
+
+	PR binutils/14493
+	* elf.c (ignore_section_sym): Also ignore section symbols without
+	a BFD section.
+
+2012-09-03  Andreas Krebbel  <[email protected]>
+
+	* elf32-s390.c (elf_s390_relocate_section): Handle PLTOFF for
+	local and global ifunc symbols.
+	* elf64-s390.c (elf_s390_relocate_section): Likewise.
+
+2012-09-02  H.J. Lu  <[email protected]>
+
+	* elf-bfd.h (elf_link_hash_table): Add hdynamic for the
+	_DYNAMIC symbol.
+
+	* elflink.c (_bfd_elf_link_create_dynamic_sections): Set
+	hdynamic.
+
+	* elf-m10300.c (_bfd_mn10300_elf_finish_dynamic_symbol): Check
+	hdynamic instead of "_DYNAMIC".
+	* elf32-arm.c (elf32_arm_finish_dynamic_symbol): Likewise.
+	* elf32-cr16.c (elf32_arm_finish_dynamic_symbol): Likewise.
+	* elf32-cris.c (elf_cris_finish_dynamic_symbol): Likewise.
+	* elf32-hppa.c (elf32_hppa_finish_dynamic_symbol): Likewise.
+	* elf32-i386.c (elf_i386_convert_mov_to_lea): Likewise.
+	* elf32-lm32.c (lm32_elf_finish_dynamic_symbol): Likewise.
+	* elf32-m32r.c (m32r_elf_finish_dynamic_symbol): Likewise.
+	* elf32-s390.c (elf_s390_finish_dynamic_symbol): Likewise.
+	* elf32-sh.c (sh_elf_finish_dynamic_symbol): Likewise.
+	* elf32-tic6x.c (elf32_tic6x_finish_dynamic_symbol): Likewise.
+	* elf32-tilepro.c (tilepro_elf_finish_dynamic_symbol): Likewise.
+	* elf32-vax.c (elf_vax_finish_dynamic_symbol): Likewise.
+	* elf32-xtensa.c (elf_xtensa_finish_dynamic_symbol): Likewise.
+	* elf64-aarch64.c elf64_aarch64_finish_dynamic_symbol(): Likewise.
+	* elf64-alpha.c (elf64_alpha_finish_dynamic_symbol): Likewise.
+	* elf64-ia64-vms.c (elf64_ia64_finish_dynamic_symbol): Likewise.
+	* elf64-s390.c (elf_s390_finish_dynamic_symbol): Likewise.
+	* elf64-sh64.c (sh64_elf64_finish_dynamic_symbol): Likewise.
+	* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Likewise.
+	* elfnn-ia64.c (elfNN_ia64_finish_dynamic_symbol): Likewise.
+	* elfxx-mips.c (_bfd_mips_elf_finish_dynamic_symbol): Likewise.
+	* elfxx-sparc.c (_bfd_sparc_elf_finish_dynamic_symbol): Likewise.
+	* elfxx-tilegx.c (tilegx_elf_finish_dynamic_symbol): Likewise.
+
+	* elf32-microblaze.c (microblaze_elf_finish_dynamic_symbol): Check
+	hdynamic, hgot, hplt instead of _DYNAMIC, _GLOBAL_OFFSET_TABLE_,
+	_PROCEDURE_LINKAGE_TABLE_.
+	* elf32-score.c (s3_bfd_score_elf_finish_dynamic_symbol): Likewise.
+	* elf32-score7.c (s7_bfd_score_elf_finish_dynamic_symbol): Likewise.
+
+2012-08-31  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_convert_mov_to_lea): Don't optimize
+	_DYNAMIC.
+	* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Likewise.
+
+2012-08-31  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_convert_mov_to_lea): New.
+	(elf_i386_size_dynamic_sections): Use it on input sections.
+	(elf_i386_relocate_section): Don't convert
+	"mov foo@GOT(%reg), %reg" to "lea foo@GOTOFF(%reg), %reg"
+	for local symbols here.
+
+	* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): New.
+	(elf_x86_64_size_dynamic_sections): Use it on input sections.
+	(elf_x86_64_relocate_section): Don't convert
+	"mov foo@GOTPCREL(%rip), %reg" to "lea foo(%rip), %reg"
+	for local symbols here.
+
+2012-08-30  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_relocate_section): Convert
+	"mov foo@GOT(%reg), %reg" to "lea foo@GOTOFF(%reg), %reg"
+	for local symbols.
+
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Convert
+	"mov foo@GOTPCREL(%rip), %reg" to "lea foo(%rip), %reg"
+	for local symbols.
+
+2012-08-31  Alan Modra  <[email protected]>
+
+	PR ld/14464
+	* elf64-ppc.c (ppc64_elf_relocate_section): Map symbols defined
+	by a linker script in .opd to corresponding input .opd section.
+
+2012-08-28  Maciej W. Rozycki  <[email protected]>
+
+	* elf32-ppc.c (ppc_elf_relocate_section): Assert that dynindx is
+	not minus one.
+	* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
+
+2012-08-28  Maciej W. Rozycki  <[email protected]>
+
+	* elflink.c (_bfd_elf_merge_symbol): Also override the version
+	a dynamic symbol defaulted to if preempted with a hidden or
+	internal definition.
+
+2012-08-28  Walter Lee  <[email protected]>
+
+	* elf32-tilepro.c (allocate_dynrelocs): Use PLT_ENTRY_SIZE as size
+	of header.
+	(tilepro_plt_entry_build): Account for new header size.
+	(tilepro_elf_finish_dynamic_sections): Ditto.
+	(tilepro_elf_plt_sym_val): Ditto.
+	* elfxx-tilegx.c (allocate_dynrelocs): Use PLT_ENTRY_SIZE as size
+	of header + tail.
+	(tilegx_elf_finish_dynamic_sections): Account for new padding.
+
+2012-08-27  Walter Lee  <[email protected]>
+
+	* reloc.c (Add BFD_RELOC_TILEGX_IMM16_X0_HW0_PLT_PCREL,
+	BFD_RELOC_TILEGX_IMM16_X1_HW0_PLT_PCREL,
+	BFD_RELOC_TILEGX_IMM16_X0_HW1_PLT_PCREL,
+	BFD_RELOC_TILEGX_IMM16_X1_HW1_PLT_PCREL,
+	BFD_RELOC_TILEGX_IMM16_X0_HW2_PLT_PCREL,
+	BFD_RELOC_TILEGX_IMM16_X1_HW2_PLT_PCREL,
+	BFD_RELOC_TILEGX_IMM16_X0_HW3_PLT_PCREL,
+	BFD_RELOC_TILEGX_IMM16_X1_HW3_PLT_PCREL,
+	BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL,
+	BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL,
+	BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL,
+	BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL,
+	BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL,
+	BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL): new relocations.
+	* elfxx-tilegx.c (tilegx_elf_howto_table): Handle new relocations.
+	(tilegx_reloc_map): Ditto.
+	(reloc_to_create_func): Ditto.
+	(tilegx_elf_check_relocs): Ditto.
+	(tilegx_elf_gc_sweep_hook): Ditto.
+	(tilegx_elf_relocate_section): Ditto.
+	* libbfd.h: Regenerate.
+	* bfd-in2.h: Regenerate.
+
+2012-08-24  Matthew Gretton-Dann  <[email protected]>
+
+	* elf32-arm.c (v8): New array.
+	(tag_cpu_arch_combine): Add support for ARMv8 attributes.
+	(elf32_arm_merge_eabi_attributes): Likewise.
+	(VFP_VERSION_COUNT): New define.
+
+2012-08-20  Tom Tromey  <[email protected]>
+
+	* vms-lib.c (_bfd_vms_lib_get_module): Use bfd_zmalloc for
+	areltdata.
+	* opncls.c (_bfd_delete_bfd): Free arelt_data.
+	* mach-o.c (bfd_mach_o_fat_member_init): Use bfd_zmalloc for
+	areltdata.
+	* ecoff.c (_bfd_ecoff_slurp_armap): Use free for mapdata.
+	* coff-rs6000.c (_bfd_xcoff_read_ar_hdr): Use bfd_zmalloc for
+	areltdata.
+	(xcoff_write_archive_contents_old): Likewise.
+	(xcoff_write_archive_contents_big): Likewise.
+	* archive64.c (bfd_elf64_archive_slurp_armap): Use free for
+	areltdata.
+	* archive.c (_bfd_generic_read_ar_hdr_mag): Use bfd_zmalloc and
+	free for areltdata.
+	(_bfd_get_elt_at_filepos): Likewise.  Clear n_nfd->arelt_data on
+	failure.
+	(do_slurp_bsd_armap): Use bfd_zmalloc and free for areltdata.
+	(do_slurp_coff_armap): Likewise.
+	(_bfd_slurp_extended_name_table): Likewise.
+	(bfd_slurp_bsd_armap_f2): Likewise.  Don't leak 'mapdata'.
+
+2012-08-17  Nick Clifton  <[email protected]>
+
+	* po/vi.po: Updated Vietnamese translation.
+
+2012-08-17  Yuri Chornoivan  <[email protected]>
+
+	* elf-bfd.h, * elf32-ppc.c, * elf64-ia64-vms.c, * elfnn-ia64.c,
+	* elfxx-mips.c, * vms-alpha.c: Typo fixes.
+
+2012-08-17  Alan Modra  <[email protected]>
+
+	PR binutils/14475:
+	* archive.c (bfd_ar_hdr_from_filesystem): Revert last change.
+	Instead malloc areltdata.
+
+2012-08-16  Tom Tromey  <[email protected]>
+
+	PR binutils/14475:
+	* archive.c (bfd_ar_hdr_from_filesystem): Allocate areltdata on
+	'member' BFD.  Don't try to free 'ared'.
+
+2012-08-14  Nick Clifton  <[email protected]>
+
+	* po/uk.po: Updated Ukranian translation.
+
+2012-08-13  Maciej W. Rozycki  <[email protected]>
+
+	* elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Look up
+	the options section in the output rather than input BFD to
+	decide if to add a DT_MIPS_OPTIONS tag.
+
+2012-08-13  Maciej W. Rozycki  <[email protected]>
+
+	* config.bfd: Wrap mips*el-*-linux* and mips*-*-linux* into
+	#ifdef BFD64.
+
+2012-08-13  Ian Bolton  <[email protected]>
+            Laurent Desnogues  <[email protected]>
+            Jim MacArthur  <[email protected]>
+            Marcus Shawcroft  <[email protected]>
+            Nigel Stephens  <[email protected]>
+            Ramana Radhakrishnan  <[email protected]>
+            Richard Earnshaw  <[email protected]>
+            Sofiane Naci  <[email protected]>
+            Tejas Belagod  <[email protected]>
+            Yufeng Zhang  <[email protected]>
+
+	* Makefile.am: Add AArch64 files.
+	* Makefile.in: Regenerate.
+	* archures.c (bfd_aarch64_arch): New declaration.
+	(bfd_archures_list): Use bfd_archures_list.
+	* bfd-in.h (bfd_elf64_aarch64_init_maps): New declaration.
+	(bfd_aarch64_process_before_allocation): New declaration.
+	(bfd_elf64_aarch64_process_before_allocation): New declaration.
+	(bfd_elf64_aarch64_set_options): New declaration.
+	(bfd_elf64_aarch64_add_glue_sections_to_bfd): New declaration.
+	(BFD_AARCH64_SPECIAL_SYM_TYPE_MAP): New definition.
+	(BFD_AARCH64_SPECIAL_SYM_TYPE_TAG): New definition.
+	(BFD_AARCH64_SPECIAL_SYM_TYPE_OTHER): New definition.
+	(BFD_AARCH64_SPECIAL_SYM_TYPE_ANY): New definition.
+	(bfd_is_aarch64_special_symbol_name): New declaration.
+	(bfd_aarch64_merge_machines): New declaration.
+	(bfd_aarch64_update_notes): New declaration.
+	(int bfd_aarch64_get_mach_from_notes): New declaration.
+	(elf64_aarch64_setup_section_lists): New declaration.
+	(elf64_aarch64_next_input_section): New declaration.
+	(elf64_aarch64_size_stubs): New declaration.
+	(elf64_aarch64_build_stubs): New declaration.
+	* config.bfd: Add AArch64.
+	* configure.in: Add AArch64.
+	* configure: Regenerate.
+	* cpu-aarch64.c: New file.
+	* elf-bfd.h: Add AArch64.
+	* bfd-in2.h: Regenerate.
+	* libbfd.h: Regenerate.
+	* elf64-aarch64.c: New file.
+	* reloc.c: Add AArch64 relocations.
+	* targets.c: Add AArch64.
+	* po/SRC-POTFILES.in: Regenerate.
+
+2012-08-13  Maciej W. Rozycki  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_calculate_relocation): Fix the handling
+	of protected symbols.
+
+2012-08-10  Alan Modra  <[email protected]>
+
+	PR binutils/14444
+	* elf.c (IS_VALID_GROUP_SECTION_HEADER) Add minsize param.
+	(setup_group): Adjust uses.
+	(bfd_section_from_shdr): Allow SHT_GROUP sections with just a flag
+	word.
+
+2012-08-09  Nick Clifton  <[email protected]>
+
+	* po/vi.po: Updated Vietnamese translation.
+
+2012-08-09  Maciej W. Rozycki  <[email protected]>
+
+	* elfxx-mips.c (LA25_LUI_MICROMIPS_1, LA25_LUI_MICROMIPS_2):
+	Remove macros, folding them into...
+	(LA25_LUI_MICROMIPS): ... this new macro.
+	(LA25_J_MICROMIPS_1, LA25_J_MICROMIPS_2): Likewise into...
+	(LA25_J_MICROMIPS): ... this new macro.
+	(LA25_ADDIU_MICROMIPS_1, LA25_ADDIU_MICROMIPS_2): Likewise
+	into...
+	(LA25_ADDIU_MICROMIPS): ... this new macro.
+	(bfd_put_micromips_32, bfd_get_micromips_32): New functions.
+	(mips_elf_create_la25_stub): Use them.
+	(check_br32_dslot, check_br32, check_relocated_bzc): Likewise.
+	(_bfd_mips_elf_relax_section): Likewise.
+
+2012-08-09  Alan Modra  <[email protected]>
+	    Tom Tromey  <[email protected]>
+
+	* archive.c (SECTION Archives): Update documentation.
+	(_bfd_delete_archive_data): Remove.
+	(_bfd_add_bfd_to_archive_cache): Set 'parent_cache' and 'key'.
+	(archive_close_worker, _bfd_archive_close_and_cleanup): New
+	functions.
+	* libbfd-in.h (struct areltdata <parent_cache, key>): New fields.
+	(_bfd_delete_archive_data): Don't declare.
+	(_bfd_archive_close_and_cleanup): Declare.
+	(_bfd_generic_close_and_cleanup): Redefine.
+	* libbfd.h: Rebuild.
+	* opncls.c (_bfd_delete_bfd): Don't call _bfd_delete_archive_data.
+	(bfd_close): Don't close nested thin archives here.
+
+2012-08-07  Tom Tromey  <[email protected]>
+
+	* archive.c (_bfd_delete_archive_data): New function.
+	* libbfd-in.h (_bfd_delete_archive_data): Declare.
+	* libbfd.h: Rebuild.
+	* opncls.c (_bfd_delete_bfd): Call _bfd_delete_archive_data.
+
+2012-08-07  Nick Clifton  <[email protected]>
+
+	* po/uk.po: Updated Ukranian translation.
+
+2012-08-06  Maciej W. Rozycki  <[email protected]>
+
+	* elflink.c (bfd_elf_record_link_assignment): Remove --defsym
+	symbols special case.
+
+2012-08-05  Maciej W. Rozycki  <[email protected]>
+
+	* elf32-vax.c (elf_vax_adjust_dynamic_symbol): Don't allocate
+	PLT slots for local symbols.
+
+2012-08-03  Maciej W. Rozycki  <[email protected]>
+
+	* elf64-mips.c (mips16_elf64_howto_table_rela): Correct src_mask
+	field initializers throughout.
+	* elfn32-mips.c (elf_mips16_howto_table_rela): Likewise.
+
+2012-08-03  Maciej W. Rozycki  <[email protected]>
+
+	* elfxx-mips.c (mips_elf_perform_relocation): Update the
+	cross-mode jump message.
+
+2012-08-03  Maciej W. Rozycki  <[email protected]>
+
+	* elfxx-mips.c (_bfd_mips_elf_size_dynamic_sections): Update the
+	comment on DT_MIPS_RLD_MAP.
+
+2012-08-03  Tom Tromey  <[email protected]>
+
+	* opncls.c (_bfd_delete_bfd): Now static.
+	* libbfd-in.h (_bfd_delete_bfd): Don't declare.
+	* libbfd.h: Rebuild.
+
+2012-08-02  Sean Keys  <[email protected]>
+
+	* elf32-m68hc1x.c (elf32_m68hc11_relocate_section): Modified
+	conditional statment to allow suppression of mismatched bank
+	warning.
+
+2012-08-01  Alan Modra  <[email protected]>
+
+	* dwarf2.c (struct dwarf2_debug): Add close_on_cleanup.
+	(_bfd_dwarf2_slurp_debug_info): Set close_on_cleanup if we open
+	gnu_debuglink bfd.
+	(_bfd_dwarf2_cleanup_debug_info): Act on close_on_cleanup.
+
+2012-07-30  Nick Clifton  <[email protected]>
+
+	* po/bfd.pot: Updated template.
+	* po/es.po: Updated Spanish translation.
+	* po/fi.po: Updated Finnish translation.
+	* po/fr.po: Updated French translation.
+	* po/ru.po: Updated Russian translation.
+	* po/uk.po: Updated Ukranian translation.
+
+2012-07-27  Mike Frysinger  <[email protected]>
+
+	* configure.in (AC_INIT): Call with the args bfd and 2.22.52.
+	(AM_INIT_AUTOMAKE): Remove args.
+	* configure: Regenerate.
+
+2012-07-27  Andreas Krebbel  <[email protected]>
+
+	* cpu-s390.c (bfd_s390_64_arch, bfd_s390_arch): Pick the default
+	arch depending on the target size.
+
+2012-07-27  Tristan Gingold  <[email protected]>
+
+	* configure.in: Bump version to 2.23.51
+	* configure: Regenerate.
+
+2012-07-26  Teresa Johnson  <[email protected]>
+
+	* bfd/dwarf2.c (find_line): Initialize discriminator_ptr
+	if it is non-NULL.
+
+2012-07-26  Meador Inge  <[email protected]>
+	    Nick Clifton  <[email protected]>
+
+	PR ld/14397
+	* elf32-arm.c (elf32_arm_finish_dynamic_sections): Report an error
+	if a required section is missing from the linker script.
+
+2012-07-24  Jan Waclawek <[email protected]>
+	PR 13899
+	* elf32-avr.c (elf32_avr_relax_delete_bytes): Call
+	_bfd_elf_link_read_relocs with keep_memory as TRUE.
+
+2012-07-24  Teresa Johnson  <[email protected]>
+
+	* bfd.c (bfd_find_nearest_line_discriminator): New macro.
+	* coff-rs6000.c: Init _bfd_find_nearest_line_discriminator.
+	* coff64-rs6000.c: Likewise.
+	* dwarf2.c (struct line_info): Add discriminator field.
+	(add_line_info): Fill in new discriminator field.
+	(decode_line_info): Record discriminator information instead
+	of ignoring it.
+	(lookup_address_in_line_info_table): Return discriminator field if
+	requested.
+	(comp_unit_find_nearest_line): Add discriminator argument.
+	(find_line): Likewise.
+	(_bfd_dwarf2_find_nearest_line): Likewise.
+	(_bfd_dwarf2_find_line): Likewise.
+	* elf-bfd.h (_bfd_elf_find_nearest_line_discriminator): New.
+	(_bfd_elf_find_line_discriminator): Likewise.
+	(_bfd_generic_find_nearest_line_discriminator): Likewise. Defined.
+	* elf.c (_bfd_elf_find_nearest_line): Change to a wrapper
+	that invokes _bfd_elf_find_nearest_line_discriminator with correct
+	arguments.
+	(_bfd_elf_find_nearest_line_discriminator): New.
+	(_bfd_elf_find_line): Change to a wrapper
+	that invokes _bfd_elf_find_line_discriminator with correct
+	arguments.
+	(_bfd_elf_find_line_discriminator): New.
+	* coffgen.c (coff_find_nearest_line_with_names): Handle
+	new discriminator argument.
+	* elf32-arm.c (elf32_arm_find_nearest_line): Likewise.
+	* elf64-alpha.c (elf64_alpha_find_nearest_line): Likewise.
+	* elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Likewise.
+	* mach-o.c (bfd_mach_o_find_nearest_line): Likewise.
+	* libbfd-in.h (_bfd_dwarf2_find_nearest_line): Add discriminator
+	argument.
+	(_bfd_dwarf2_find_line): Likewise.
+	(_bfd_generic_find_nearest_line_discriminator): New.
+	* libbfd.c (_bfd_generic_find_nearest_line_discriminator): New.
+	* bfd-in2.h: Regenerated.
+	* libbfd.h: Likewise.
+	* targets.c (BFD_JUMP_TABLE_SYMBOLS): Initialize
+	_bfd_find_nearest_line_discriminator with
+	_bfd_generic_find_nearest_line_discriminator.
+	(bfd_target): Add _bfd_find_nearest_line_discriminator.
+
+2012-07-24  Sean Keys  <[email protected]>
+
+	* elf32-m68hc1x.c (elf32_m68hc11_relocate_section): Added code
+	that enables the linker to offset addresses, when linking against
+	symbols from the XGATE processor and vice versa.
+
+2012-07-23  Nick Clifton  <[email protected]>
+
+	* cisco-core.c (cisco_core_file_failing_command): Make static.
+	(cisco_core_file_failing_signal): Make static.
+
+2012-07-18  H.J. Lu  <[email protected]>
+
+	* bfd-in2.h: Regenerated.
+
+2012-07-18  Nicolàs Alejandro Di Risio <[email protected]>
+
+	PR binutils/14335
+	* section.c: Fix a typo in comments.
+
+2012-07-13  Andreas Krebbel  <[email protected]>
+
+	* elf64-s390.c: Include elf-s390-common.c.
+	(R_390_IRELATIVE): New reloc.
+	(elf_s390_reloc_type_lookup): Support R_390_IRELATIVE.
+	(RELA_ENTRY_SIZE): New macro.
+	(elf_s390_link_hash_entry): New fields ifunc_resolver_address and
+	*ifunc_resolver_section.
+	(struct plt_entry): New struct.
+	(struct elf_s390_obj_tdata): New field local_plt.
+	(elf_s390_local_plt): New macro.
+	(struct elf_s390_link_hash_table): New field irelifunc.
+	(ELF64): New macro.
+	(link_hash_newfunc): Initialize new fields.
+	(elf_s390_check_relocs): Handle IFUNC symbols.
+	(elf_s390_adjust_dynamic_symbol): Don't do anything for IFUNC
+	symbols.
+	(allocate_dynrelocs): Call s390_elf_allocate_ifunc_dyn_relocs for
+	IFUNC symbols.
+	(elf_s390_size_dynamic_sections): Handle IFUNC symbols.
+	(elf_s390_relocate_section): Likewise.
+	(elf_s390_finish_dynamic_symbol): Likewise.
+	(elf_s390_finish_dynamic_sections): Handle local IFUNC symbols.
+	(elf_s390_finish_ifunc_symbol): New function.
+	(elf_s390_gc_sweep_hook): Handle local plt entries.
+	(elf_backend_add_symbol_hook): Define.
+	* elf32-s390.c: See elf64-s390.c changes.
+	* elf-s390-common.c: New file.
+	* bfd-in2.h (BFD_RELOC_390_IRELATIVE): New enum field.
+	* libbfd.h (BFD_RELOC_390_IRELATIVE): New entry for
+	BFD_RELOC_390_IRELATIVE.
+	* reloc.c (BFD_RELOC_390_IRELATIVE): Document new relocation.
+
+2012-07-13  Nick Clifton  <[email protected]>
+
+	* aix386-core.c: Remove use of PTR and PARAMS macros.
+	* archive.c: Likewise.
+	* cache.c: Likewise.
+	* cisco-core.c: Likewise.
+	* coff-alpha.c: Likewise.
+	* coff-apollo.c: Likewise.
+	* coff-aux.c: Likewise.
+	* coff-h8300.c: Likewise.
+	* coff-h8500.c: Likewise.
+	* coff-i386.c: Likewise.
+	* coff-i960.c: Likewise.
+	* coff-ia64.c: Likewise.
+	* coff-m68k.c: Likewise.
+	* coff-m88k.c: Likewise.
+	* coff-mcore.c: Likewise.
+	* coff-mips.c: Likewise.
+	* coff-or32.c: Likewise.
+	* coff-ppc.c: Likewise.
+	* coff-rs6000.c: Likewise.
+	* coff-sh.c: Likewise.
+	* coff-sparc.c: Likewise.
+	* coff-stgo32.c: Likewise.
+	* coff-tic30.c: Likewise.
+	* coff-tic4x.c: Likewise.
+	* coff-tic54x.c: Likewise.
+	* coff-tic80.c: Likewise.
+	* coff-w65.c: Likewise.
+	* cofflink.c: Likewise.
+	* cpu-arc.c: Likewise.
+	* cpu-cris.c: Likewise.
+	* cpu-h8500.c: Likewise.
+	* cpu-i960.c: Likewise.
+	* cpu-msp430.c: Likewise.
+	* cpu-ns32k.c: Likewise.
+	* cpu-powerpc.c: Likewise.
+	* cpu-rs6000.c: Likewise.
+	* cpu-tic4x.c: Likewise.
+	* cpu-w65.c: Likewise.
+	* ecoff.c: Likewise.
+	* ecofflink.c: Likewise.
+	* elf-m10200.c: Likewise.
+	* elf32-bfin.c: Likewise.
+	* elf32-cris.c: Likewise.
+	* elf32-crx.c: Likewise.
+	* elf32-fr30.c: Likewise.
+	* elf32-frv.c: Likewise.
+	* elf32-h8300.c: Likewise.
+	* elf32-i960.c: Likewise.
+	* elf32-m32c.c: Likewise.
+	* elf32-m68hc11.c: Likewise.
+	* elf32-m68hc12.c: Likewise.
+	* elf32-m68hc1x.c: Likewise.
+	* elf32-m68k.c: Likewise.
+	* elf32-mcore.c: Likewise.
+	* elf32-rl78.c: Likewise.
+	* elf32-rx.c: Likewise.
+	* elf32-s390.c: Likewise.
+	* elf32-vax.c: Likewise.
+	* elf64-alpha.c: Likewise.
+	* elf64-mmix.c: Likewise.
+	* elf64-s390.c: Likewise.
+	* elf64-sparc.c: Likewise.
+	* elfnn-ia64.c: Likewise.
+	* elfxx-mips.c: Likewise.
+	* elfxx-sparc.c: Likewise.
+	* hash.c: Likewise.
+	* hp300hpux.c: Likewise.
+	* hppabsd-core.c: Likewise.
+	* hpux-core.c: Likewise.
+	* i386dynix.c: Likewise.
+	* i386linux.c: Likewise.
+	* i386lynx.c: Likewise.
+	* i386mach3.c: Likewise.
+	* i386msdos.c: Likewise.
+	* i386os9k.c: Likewise.
+	* irix-core.c: Likewise.
+	* lynx-core.c: Likewise.
+	* m68klinux.c: Likewise.
+	* mach-o.h: Likewise.
+	* mipsbsd.c: Likewise.
+	* netbsd-core.c: Likewise.
+	* nlm32-i386.c: Likewise.
+	* osf-core.c: Likewise.
+	* pc532-mach.c: Likewise.
+	* pef.c: Likewise.
+	* ppcboot.c: Likewise.
+	* ptrace-core.c: Likewise.
+	* reloc16.c: Likewise.
+	* sco5-core.c: Likewise.
+	* som.h: Likewise.
+	* sparclinux.c: Likewise.
+	* sparclynx.c: Likewise.
+	* ticoff.h: Likewise.
+	* trad-core.c: Likewise.
+	* vms-lib.c: Likewise.
+	* xsym.h: Likewise.
+
+2012-07-09  Alan Modra  <[email protected]>
+
+	PR ld/14323
+	* elflink.c (elf_sort_symbol): Sort by size too.
+	(elf_link_add_object_symbols <weakdefs>): Simplify binary search.
+	Do not depend on ordering of symbol aliases.  Match largest size.
+
+2012-07-03  H.J. Lu  <[email protected]>
+
+	* elf.c (assign_section_numbers): Check if number of sections
+	>= SHN_LORESERVE.
+	* elfcode.h (elf_object_p): Likewise.
+
+2012-07-03  Nick Clifton  <[email protected]>
+
+	* archive.c (bsd_write_armap): Catch attempts to create an archive
+	with indicies bigger than 4Gb.
+	(coff_write_armap): Likewise.
+
+2012-07-03  H.J. Lu  <[email protected]>
+
+	PR binutils/14319
+	* elf.c (_bfd_elf_make_section_from_shdr): Don't compress empty
+	debug section.
+
+2012-07-03  H.J. Lu  <[email protected]>
+
+	PR ld/3351
+	* elflink.c (_bfd_elf_update_dynamic_flags): New.
+	(_bfd_elf_merge_symbol): Update both real and indirect symbol
+	dynamic flags.
+	(_bfd_elf_add_default_symbol): Make the real symbol dynamic if
+	the indirect symbol is defined in a shared library.
+	(elf_link_add_object_symbols): Likewise.  If the indirect
+	symbol has been forced local, don't make the real symbol
+	dynamic.
+	(elf_link_check_versioned_symbol): Check indirect symbol.
+	(elf_link_output_extsym): Use real symbol definition when
+	reporting indirect symbol error.  Check version info for
+	dynamic versioned symbol.
+
+2012-07-03  Alan Modra  <[email protected]>
+
+	PR ld/14207
+	* elf.c (assign_file_positions_for_load_sections): Remove assertions
+	that only PT_LOAD headers include file header and section headers.
+	(assign_file_positions_for_non_load_sections): Similarly don't
+	assert PT_GNU_RELRO header does not include file and section headers.
+	Compare first section vma rather than PT_LOAD p_vaddr against
+	relro_start when looking for PT_LOAD covering PT_GNU_RELRO.  Replace
+	abort with assertion.
+
+2012-07-02  Alan Modra  <[email protected]>
+
+	* elf32-m32c.c (m32c_elf_check_relocs): Use bfd_make_section
+	"anyway" variant when creating .plt.
+	(m32c_elf_relax_plt_section): Remove redundant test and unused param.
+	(m32c_elf_relax_section): Test SEC_LINKER_CREATED before calling
+	m32c_elf_relax_plt_section.
+	* elfxx-mips.c (mips_elf_create_got_section): Use make anyway variant
+	when creating .got and .got.plt.
+	(_bfd_mips_elf_final_link): Likewise for .rtproc, and use
+	bfd_get_linker_section.
+	* sunos.c: Similarly throughout.
+
+2012-07-01  Andreas Schwab  <[email protected]>
+
+	* elf.c (_bfd_elf_make_section_from_shdr): Fix typo in error
+	message.
+
+2012-06-29  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Return FALSE
+	on unresolvable relocation.
+
+2012-06-29  H.J. Lu  <[email protected]>
+
+	* archive.c (_bfd_compute_and_write_armap): Simplify global
+	symbol handling.
+
+2012-06-29  Nick Clifton  <[email protected]>
+
+	PR ld/14189
+	* elf32-arm.c (elf32_arm_check_relocs): Do not increment refcount
+	for locally bound symbols.
+
+2012-06-29  Alan Modra  <[email protected]>
+
+	* section.c (bfd_get_linker_section): New function.
+	* elf32-arm.c: When retrieving SEC_LINKER_CREATED sections, use
+	the above throughout rather than bfd_get_section_by_name.  Use
+	bfd_make_section_anyway rather than bfd_make_section when creating
+	them.
+	* elf32-bfin.c: Likewise.
+	* elf32-cr16.c: Likewise.
+	* elf32-cris.c: Likewise.
+	* elf32-frv.c: Likewise.
+	* elf32-hppa.c: Likewise.
+	* elf32-i370.c: Likewise.
+	* elf32-i386.c: Likewise.
+	* elf32-lm32.c: Likewise.
+	* elf32-m32c.c: Likewise.
+	* elf32-m32r.c: Likewise.
+	* elf32-m68k.c: Likewise.
+	* elf32-microblaze.c: Likewise.
+	* elf32-ppc.c: Likewise.
+	* elf32-rl78.c: Likewise.
+	* elf32-s390.c: Likewise.
+	* elf32-score.c: Likewise.
+	* elf32-score7.c: Likewise.
+	* elf32-sh.c: Likewise.
+	* elf32-tic6x.c: Likewise.
+	* elf32-tilepro.c: Likewise.
+	* elf32-vax.c: Likewise.
+	* elf32-xstormy16.c: Likewise.
+	* elf32-xtensa.c: Likewise.
+	* elf64-alpha.c: Likewise.
+	* elf64-hppa.c: Likewise.
+	* elf64-ia64-vms.c: Likewise.
+	* elf64-ppc.c: Likewise.
+	* elf64-s390.c: Likewise.
+	* elf64-sh64.c: Likewise.
+	* elf64-sparc.c: Likewise.
+	* elf64-x86-64.c: Likewise.
+	* elfnn-ia64.c: Likewise.
+	* elfxx-mips.c: Likewise.
+	* elfxx-sparc.c: Likewise.
+	* elfxx-tilegx.c: Likewise.
+	* elflink.c: Likewise.
+	* elf-vxworks.c: Likewise.
+	* elf-m10300.c: Likewise.  Also make use of htab plt, got and
+	gotplt shortcuts.
+	* bfd-in2.h: Regenerate.
+	* elf32-lm32.c (lm32_elf_check_relocs): Use the correct bfd when
+	calling create_rofixup_section.
+	* elflink.c (bfd_elf_final_link): Simplify test for .dynstr.
+
+2012-06-29  Alan Modra  <[email protected]>
+
+	* elf32-sh.c (sh_elf_create_dynamic_sections): Don't create .rela
+	section for bss type sections, except for .rela.bss.
+	* elf-m10300.c (_bfd_mn10300_elf_create_dynamic_sections): Likewise.
+	* elf32-cr16.c (_bfd_cr16_elf_create_dynamic_sections): Likewise.
+	* elf32-lm32.c (lm32_elf_create_dynamic_sections): Likewise.
+	* elf32-m32r.c (m32r_elf_create_dynamic_sections): Likewise.
+	* elf64-sh64.c (sh64_elf64_create_dynamic_sections): Likewise.
+
+2012-06-28  Roland McGrath  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_populate_plt_entry): Use int32_t for
+	displacement calculation in nacl_p case.
+
+2012-06-28  Nick Clifton  <[email protected]>
+
+	* po/uk.po: New Ukranian translation.
+	* configure.in (ALL_LINGUAS): Add uk.
+	* configure: Regenerate.
+
+2012-06-26  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (ppc64_elf_next_toc_section): Don't error if input
+	file has multiple .got/.toc sections and all don't fit in
+	current toc group.
+
+2012-06-22  Roland McGrath  <[email protected]>
+
+	* elf.c (assign_file_positions_for_non_load_sections): Define
+	__ehdr_start symbol if it's referenced and there's a PT_LOAD
+	segment that covers both the file and program headers.
+
+2012-06-22  Andreas Schwab  <[email protected]>
+
+	* elf32-m68k.c (elf_m68k_finish_dynamic_symbol): Don't make
+	_GLOBAL_OFFSET_TABLE_ and _DYNAMIC absolute.
+
+2012-06-22  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c (ppc64_elf_func_desc_adjust): Don't emit out-of-line
+	save/restore functions when relocatable.  Make "funcs" static.
+
+2012-06-18  Hans-Peter Nilsson  <[email protected]>
+
+	* elf32-cris.c (cris_elf_plt_sym_val): Rewrite to work in presence
+	of merged .got and .got.plt entries.
+
+2012-06-18  John Szakmeister  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_final_link_relocate): Correct return value.
+
+2012-06-17  Hans-Peter Nilsson  <[email protected]>
+
+	* elf32-cris.c (cris_elf_relocate_section): <R_CRIS_32_IE>
+	<R_CRIS_32_GOT_TPREL, R_CRIS_16_GOT_TPREL>: Handle references to
+	thread common symbols.
+
+2012-06-13  Nick Clifton  <[email protected]>
+
+	* elf32-arm.c (bfd_arm_get_mach_from_attributes): New function.
+	(elf32_arm_object_p): If the machine number could not be deduced
+	from the notes, call bfd_arm_get_mach_from_attributes to get the
+	number from the attributes.
+
+2012-06-12  H.J. Lu  <[email protected]>
+
+	PR bfd/14207
+	* elf.c (assign_file_positions_for_non_load_sections): Abort if
+	PT_GNU_RELRO segment doesn't fit in PT_LOAD segment.
+
+2012-06-12  Alan Modra  <[email protected]>
+
+	PR ld/14207
+	* elf.c (_bfd_elf_map_sections_to_segments): Disregard bss type
+	sections at end of PT_LOAD segment when searching for segment
+	that contains end of relro extent.
+
+2012-06-11  H.J. Lu  <[email protected]>
+
+	* elf.c (assign_file_positions_for_non_load_sections): Reindent.
+
+2012-06-11  H.J. Lu  <[email protected]>
+
+	* elf.c (_bfd_elf_map_sections_to_segments): Reindent.
+
+2012-06-06  Alan Modra  <[email protected]>
+
+	* elflink.c (elf_link_input_bfd): Provide a file symbol for
+	each input file with local syms, if the input lacks such.
+	(bfd_elf_final_link): Add a file symbol to mark end of locals
+	for which we can associate with input files.
+	(struct elf_final_link_info): Add filesym_count field.
+	(struct elf_outext_info): Add need_second_pass and second_pass.
+	(elf_link_output_extsym): Detect symbols defined in the output
+	file, emit them on second pass over locals.
+
+2012-06-04  Jan Kratochvil  <[email protected]>
+
+	* bfd-in.h (bfd_elf_bfd_from_remote_memory): Make LEN argument
+	of target_read_memory as bfd_size_type.
+	* bfd-in2.h: Regenerate.
+	* elf-bfd.h (elf_backend_bfd_from_remote_memory): Make LEN
+	argument of target_read_memory as bfd_size_type.
+	(_bfd_elf32_bfd_from_remote_memory): Likewise.
+	(_bfd_elf64_bfd_from_remote_memory): Likewise.
+	* elf.c (bfd_elf_bfd_from_remote_memory): Likewise.
+	* elfcode.h (NAME(_bfd_elf,bfd_from_remote_memory)): Likewise.
+
+2012-06-03  Alan Modra  <[email protected]>
+
+	PR binutils/13897
+	* elf.c (elf_find_function): Cache last function sym info.
+	(_bfd_elf_maybe_function_sym): Return function size, pass in
+	section of interest.
+	* elf-bfd.h (struct elf_backend_data <maybe_function_sym>): Likewise.
+	(_bfd_elf_maybe_function_sym): Likewise.
+	* elf64-ppc.c (ppc64_elf_maybe_function_sym): Likewise.
+	(opd_entry_value): Add in_code_sec param.  Revert caching code.
+	Return -1 if in_code_sec and function found in wrong section.
+	Update all calls.
+
+2012-06-01  Siddhesh Poyarekar  <[email protected]>
+
+	* bfd-in.h (bfd_elf_bfd_from_remote_memory): Make LEN argument
+	of target_read_memory as size_t.
+	* bfd-in2.h: Regenerate.
+	* elf-bfd.h (elf_backend_bfd_from_remote_memory): Make LEN
+	argument of target_read_memory as size_t.
+	(_bfd_elf32_bfd_from_remote_memory): Likewise.
+	(_bfd_elf64_bfd_from_remote_memory): Likewise.
+	* elf.c (bfd_elf_bfd_from_remote_memory): Likewise.
+	* elfcode.h (NAME(_bfd_elf,bfd_from_remote_memory)): Likewise.
+
+2012-06-01  Alan Modra  <[email protected]>
+
+	PR binutils/13897
+	* elf64-ppc.c (opd_entry_value): Rewrite cache code.
+
+2012-05-29  Tom Tromey  <[email protected]>
+
+	* opncls.c (bfd_fopen): Always close fd on failure.
+	(bfd_fdopenr): Likewise.
+
+2012-05-27  Alan Modra  <[email protected]>
+
+	PR ld/14170
+	* elflink.c (_bfd_elf_merge_symbol): When a symbol defined in
+	a dynamic library finds a new instance with non-default
+	visibility in a regular object, correctly handle symbols
+	already on the undefs list and undo dynamic symbol state when
+	the new symbol is hidden or internal.
+
+2012-05-25  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_create_dynamic_sections): Don't use
+	dynamic_sec_flags to create PLT .eh_frame section.
+	* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Likewise.
+
+2012-05-25  Alan Modra  <[email protected]>
+
+	PR ld/13909
+	* elf-eh-frame.c (_bfd_elf_eh_frame_present): New function.
+	(_bfd_elf_maybe_strip_eh_frame_hdr): Use it here.
+	* elf-bfd.h (_bfd_elf_eh_frame_present): Declare.
+	* elflink.c (bfd_elf_size_dynamic_sections): Let the backend
+	size dynamic sections before stripping eh_frame_hdr.
+	(bfd_elf_gc_sections): Handle multiple .eh_frame sections.
+	* elf32-ppc.c (ppc_elf_size_dynamic_sections): Drop glink_eh_frame
+	if no other .eh_frame sections exist.
+	* elf64-ppc.c (ppc64_elf_size_stubs): Likewise.
+	* elf32-i386.c (elf_i386_create_dynamic_sections): Don't size
+	or alloc plt_eh_frame here..
+	(elf_i386_size_dynamic_sections): ..do it here instead.  Don't
+	specially keep sgotplt, iplt, tgotplt, sdynbss for symbols.
+	(elf_i386_finish_dynamic_sections): Check plt_eh_frame->contents
+	before writing plt offset.
+	* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Don't size
+	or alloc plt_eh_frame here..
+	(elf_x86_64_size_dynamic_sections): ..do it here instead.
+	(elf_x86_64_finish_dynamic_sections): Check plt_eh_frame->contents
+	before writing plt offset.
+
+2012-05-24  Alan Modra  <[email protected]>
+
+	PR ld/14158
+	* elf64-ppc.c (ppc64_elf_size_stubs): Round up glink_eh_frame
+	size to output section alignment.
+	(ppc64_elf_build_stubs): Likewise, and extend last FDE to cover.
+
+2012-05-23  Alan Modra  <[email protected]>
+
+	* elf-eh-frame.c (_bfd_elf_maybe_strip_eh_frame_hdr): Handle
+	BFDs with multiple .eh_frame sections.
+
+2012-05-23  Alan Modra  <[email protected]>
+
+	PR ld/13909
+	* elflink.c (bfd_elf_discard_info): Don't ignore dynamic BFDs.
+
+2012-05-22  H.J. Lu  <[email protected]>
+
+	PR ld/13909
+	* elf32-i386.c (elf_i386_create_dynamic_sections): Revert the
+	last change.
+	* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Likewise.
+
+2012-05-22  Alan Modra  <[email protected]>
+
+	* elflink.c (bfd_elf_discard_info): Look for next .eh_frame if
+	first one is zero size or discarded.
+	* elf32-ppc.c (ppc_elf_size_dynamic_sections): Set most of
+	glink_eh_frame contents here..
+	(ppc_elf_finish_dynamic_sections): ..rather than here.  Just set
+	offset to .glink.
+
+2012-05-22  H.J. Lu  <[email protected]>
+
+	PR ld/13909
+	* elf32-i386.c (elf_i386_create_dynamic_sections): Create PLT
+	eh_frame section if there is an input .eh_frame section.
+	* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Likewise.
+
+2012-05-22  H.J. Lu  <[email protected]>
+
+	PR ld/14105
+	* elf32-i386.c (elf_i386_create_dynamic_sections): Always
+	create PLT eh_frame section with SEC_LINKER_CREATED.
+	* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Likewise.
+
+2012-05-22  Alan Modra  <[email protected]>
+
+	* elflink.c (bfd_elf_discard_info): Handle multiple .eh_frame
+	sections attached to a BFD.
+	* section.c (bfd_get_section_by_name): Rewrite description.
+	(bfd_get_next_section_by_name): New function.
+	* bfd-in2.h: Regenerate.
+
+2012-05-21  Andreas Schwab  <[email protected]>
+
+	* elf32-m68k.c (elf_m68k_grok_prstatus): New function.
+	(elf_m68k_grok_psinfo): New function.
+	(elf_backend_grok_prstatus): Define.
+	(elf_backend_grok_psinfo): Define.
+
+2012-05-19  Maciej W. Rozycki  <[email protected]>
+
+	* elf64-mips.c (elf_backend_got_header_size): Correct definition.
+	* elfxx-mips.c (_bfd_mips_elf_adjust_dynamic_symbol): Use the ELF
+	backend's GOT header size instead of hardcoding it.
+
+2012-05-19  Maciej W. Rozycki  <[email protected]>
+
+	* elf32-vax.c (elf_vax_relocate_section)
+	<R_VAX_8, R_VAX_16, R_VAX_32>: Don't check if info->shared again.
+
+2012-05-19  Maciej W. Rozycki  <[email protected]>
+
+	* elf32-vax.c (elf_vax_relocate_section)
+	<R_VAX_8, R_VAX_16, R_VAX_32>: Use section flags rather than
+	its name as the check for text sections.
+
+2012-05-19  Maciej W. Rozycki  <[email protected]>
+
+	* elf64-mips.c (mips_elf64_be_swap_reloc_out): Also make sure
+	the third reloc offset is the same as the first.
+
+2012-05-19  Alan Modra  <[email protected]>
+
+	* elf32-ppc.h (has_vle_insns, is_ppc_vle): Delete.
+	(has_tls_reloc, has_tls_get_addr_call): Move back to..
+	* elf32-ppc.c: ..here.
+	(ppc_elf_section_flags, elf_backend_section_flags): Delete.
+	(ppc_elf_modify_segment_map): Use ELF sh_flags to detect VLE sections.
+
+2012-05-18  H.J. Lu  <[email protected]>
+
+	* elf32-i386.c (elf_i386_finish_dynamic_symbol): Don't make
+	_DYNAMIC nor _GLOBAL_OFFSET_TABLE_ absolute.
+	* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Likewise.
+
+2012-05-18  Roland McGrath  <[email protected]>
+
+	* archive.c (_bfd_generic_read_ar_hdr_mag): Fix last change so as
+	not to clobber the ar_fmag field stored in ARED->arch_header.
+
+2012-05-18  Pedro Alves  <[email protected]>
+
+	* mach-o.h: Don't include sysdep.h.
+
+2012-05-18  Nick Clifton  <[email protected]>
+
+	PR 14072
+	* bfd-in.h: Check for PACKAGE or PACKAGE_VERSION before
+	complaining about config.h not having been included.
+	* bfd-in2.h: Regenerate.
+
+2012-05-18  Andreas Schwab  <[email protected]>
+
+	* aclocal.m4: Regenerate.
+	* Makefile.in: Regenerate.
+
+2012-05-17  Daniel Richard G.  <[email protected]>
+	    Nick Clifton  <[email protected]>
+
+	PR 14072
+	* configure.in: Add check that sysdep.h has been included before
+	any system header files.
+	* configure: Regenerate.
+	* config.in: Regenerate.
+	* aclocal.m4: Regenerate.
+	* bfd-in.h: Generate an error if included before config.h.
+	* sysdep.h: Likewise.
+	* bfd-in2.h: Regenerate.
+	* compress.c: Remove #include "config.h".
+	* plugin.c: Likewise.
+	* elf32-m68hc1x.c: Include sysdep.h before alloca-conf.h.
+	* elf64-hppa.c: Likewise.
+	* som.c: Likewise.
+	* xsymc.c: Likewise.
+
+2012-05-17  Maciej W. Rozycki  <[email protected]>
+	    Alan Modra  <[email protected]>
+
+	* elf.c (ignore_section_sym): Correct comment.  Don't return
+	true for absolute section.
+	(elf_map_symbols): Move stray comment.  Adjust for above change.
+	Don't discard global section symbols.
+
+2012-05-17  Alan Modra  <[email protected]>
+
+	* elf32-ppc.c (ppc_elf_finish_dynamic_symbol): Don't make _DYNAMIC,
+	_GLOBAL_OFFSET_TABLE_ or _PROCEDURE_LINKAGE_TABLE_ absolute.
+	* elf64-ppc.c (ppc64_elf_finish_dynamic_symbol): Don't make _DYNAMIC
+	absolute.
+
+2012-05-17  Alan Modra  <[email protected]>
+
+	* elf32-ppc.c (has_tls_reloc, has_tls_get_addr_call, has_vle_insns,
+	is_ppc_vle): Move to..
+	* elf32-ppc.h: ..here, making is_ppc_vle a macro.
+
+2012-05-16  Sergio Durigan Junior  <[email protected]>
+
+	* bfd-in.h (bfd_get_section_name, bfd_get_section_vma,
+	bfd_get_section_lma, bfd_get_section_alignment,
+	bfd_get_section_flags, bfd_get_section_userdata): Rewrite macros
+	in order to use the `bfd' argument.
+	* bfd-in2.h: Regenerate.
+	* elf-vxworks.c (elf_vxworks_finish_dynamic_entry): Pass proper `bfd'
+	as the first argument for `bfd_get_section_alignment'.
+	* elf32-arm.c (create_ifunc_sections): Likewise, for
+	`bfd_set_section_alignment'.
+	* elf32-m32r.c (m32r_elf_relocate_section): Likewise, for
+	`bfd_get_section_name'.
+	* elf32-microblaze.c (microblaze_elf_relocate_section): Likewise.
+	* elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise.
+	(ppc_elf_relocate_section): Likewise.
+	* elf64-mmix.c (mmix_final_link_relocate): Likewise, for
+	`bfd_get_section_vma'.
+	* elf64-ppc.c (create_linkage_sections): Likewise, for
+	`bfd_set_section_alignment'.
+
+2012-05-16  Georg-Johann Lay  <[email protected]>
+
+	PR target/13503
+	* reloc.c: Rename BFD_RELOC_AVR_8_HHI to BFD_RELOC_AVR_8_HLO.
+	* bfd-in2.h: Regenerate.
+	* libbfd.h: Regenerate.
+	* elf32-avr.c (elf_avr_howto_table): Rename R_AVR_8_HHI8 to
+	R_AVR_8_HLO8.
+	(avr_reloc_map): Likewise.
+
+2012-05-16  Daniel Richard G.  <[email protected]>
+
+	PR binutils/13558
+	* bfd/aout-cris.c: Include sysdep.h before bfd.h.
+	* bfd/aout-ns32k.c: Likewise.
+	* bfd/aout-sparcle.c: Likewise.
+	* bfd/aout0.c: Likewise.
+	* bfd/bfd-in2.h: Likewise.
+	* bfd/coff-stgo32.c: Likewise.
+	* bfd/cpu-lm32.c: Likewise.
+	* bfd/cpu-microblaze.c: Likewise.
+	* bfd/cpu-score.c: Likewise.
+	* bfd/cpu-tilegx.c: Likewise.
+	* bfd/cpu-tilepro.c: Likewise.
+	* bfd/elf32-lm32.c: Likewise.
+	* bfd/elf32-microblaze.c: Likewise.
+	* bfd/elf32-score7.c: Likewise.
+	* bfd/elf32-tilepro.c: Likewise.
+	* bfd/elfxx-tilegx.c: Likewise.
+	* bfd/mach-o.h: Likewise.
+	* bfd/nlm32-ppc.c: Likewise.
+	* bfd/ns32knetbsd.c: Likewise.
+	* bfd/pef.h: Likewise.
+	* bfd/plugin.c: Likewise.
+	* bfd/stab-syms.c: Likewise.
+	* bfd/sunos.c: Likewise.
+	* bfd/syms.c: Likewise.
+	* bfd/xsym.h: Likewise.
+
+2012-05-16  Alan Modra  <[email protected]>
+
+	* elflink.c: Rename flaginfo to flinfo throughout, except..
+	(bfd_elf_lookup_section_flags): ..here, rename finfo to flaginfo.
+	Formatting, style.  Simplify flag match.
+
+2012-05-16  Alan Modra  <[email protected]>
+
+	* dwarf2.c: Formatting.
+	(arange_add): Pass in unit rather than bfd.  Update callers.
+	Ignore empty ranges.  Don't ask for cleared memory.
+	(parse_comp_unit): Only set unit->base_address if processing
+	DW_TAG_compile_unit.
+	(find_debug_info): Optimise section lookup.
+	(place_sections): Use bfd_alloc for stash->adjusted_sections.
+	(find_line): Match previously parsed comp unit addresses as we
+	do for newly parsed comp units.
+
+2012-05-16  Alan Modra  <[email protected]>
+
+	* archive.c (_bfd_generic_read_ar_hdr_mag):  Ensure sscanf
+	stops at end of ar_size field.
+
+2012-05-16  Alan Modra  <[email protected]>
+
+	PR ld/13962
+	PR ld/7023
+	* elf.c (bfd_section_from_shdr): Fail when .dynsym sh_info is
+	out of range.  As a special case, fix sh_info for zero sh_size.
+	Do the same for .symtab.
+
+2012-05-15  James Murray <[email protected]>
+	    Stephane Carrez <[email protected]>
+
+	* archures.c: Add bfd_arch_m9s12x and bfd_arch_m9s12xg.
+	* config.bfd: Likewise.
+	* cpu-m9s12x.c: New.
+	* cpu-m9s12xg.c: New.
+	* elf32-m68hc12.c: Add S12X and XGATE co-processor support.
+	Add option to offset S12 addresses into XGATE memory space.
+	Fix carry bug in IMM16 (IMM8 low/high) relocate.
+	* Makefile.am (ALL_MACHINES): Add cpu-m9s12x and cpu-m9s12xg.
+	(ALL_MACHINES_CFILES): Likewise.
+	* reloc.c: Add S12X relocs.
+	* Makefile.in: Regenerate.
+	* bfd-in2.h: Regenerate.
+	* libbfd.h: Regenerate.
+
+2012-05-14  James Lemke  <[email protected]>
+	    Catherine Moore  <[email protected]>
+
+	* bfd.c (bfd_lookup_section_flags): Add section parm.
+	* ecoff.c (bfd_debug_section): Remove flag_info initializer.
+	* elf-bfd.h (bfd_elf_section_data): Move in section_flag_info.
+	(bfd_elf_lookup_section_flags): Add section parm.
+	* elf32-ppc.c (is_ppc_vle): New function.
+	(ppc_elf_modify_segment_map): New function.
+	(elf_backend_modify_segment_map): Define.
+	(has_vle_insns): New define.
+	* elf32-ppc.h (ppc_elf_modify_segment_map): Declare.
+	* elflink.c (bfd_elf_lookup_section_flags): Add return value & parm.
+	Move in logic to omit / include a section.
+	* libbfd-in.h (bfd_link_info): Add section parm.
+	(bfd_generic_lookup_section_flags): Likewise.
+	* reloc.c (bfd_generic_lookup_section_flags): Likewise.
+	* section.c (bfd_section): Move out section_flag_info.
+	(BFD_FAKE_SECTION): Remove flag_info initializer.
+	* targets.c (_bfd_lookup_section_flags): Add section parm.
+
+2012-05-14  Catherine Moore  <[email protected]>
+
+	* archures.c (bfd_mach_ppc_vle): New.
+	* bfd-in2.h: Regenerated.
+	* cpu-powerpc.c (bfd_powerpc_archs): New entry for vle.
+	* elf32-ppc.c (split16_format_type): New enumeration.
+	(ppc_elf_vle_split16): New function.
+	(HOWTO): Add entries for R_PPC_VLE relocations.
+	(ppc_elf_reloc_type_lookup): Handle PPC_VLE relocations.
+	(ppc_elf_section_flags): New function.
+	(ppc_elf_lookup_section_flags): New function.
+	(ppc_elf_section_processing): New function.
+	(ppc_elf_check_relocs): Handle PPC_VLE relocations.
+	(ppc_elf_relocation_section): Likewise.
+	(elf_backend_lookup_section_flags_hook): Define.
+	(elf_backend_section_flags): Define.
+	(elf_backend_section_processing): Define.
+	* elf32-ppc.h (ppc_elf_section_processing): Declare.
+	* libbfd.h: Regenerated.
+	* reloc.c (BFD_RELOC_PPC_VLE_REL8, BFD_RELOC_PPC_VLE_REL15,
+	BFD_RELOC_PPC_VLE_REL24, BFD_RELOC_PPC_VLE_LO16A,
+	BFD_RELOC_PPC_VLE_LO16D, BFD_RELOC_PPC_VLE_HI16A,
+	BFD_RELOC_PPC_VLE_HI16D, BFD_RELOC_PPC_VLE_HA16A,
+	BFD_RELOC_PPC_VLE_HA16D, BFD_RELOC_PPC_VLE_SDA21,
+	BFD_RELOC_PPC_VLE_SDA21_LO, BFD_RELOC_PPC_VLE_SDAREL_LO16A,
+	BFD_RELOC_PPC_VLE_SDAREL_LO16D, BFD_RELOC_PPC_VLE_SDAREL_HI16A,
+	BFD_RELOC_PPC_VLE_SDAREL_HI16D, BFD_RELOC_PPC_VLE_SDAREL_HA16A,
+	BFD_RELOC_PPC_VLE_SDAREL_HA16D): New bfd relocations.
+
+2012-05-11  Georg-Johann Lay  <[email protected]>
+
+	PR target/13503
+	* reloc.c: Add new ENUM for BFD_RELOC_AVR_8_LO,
+	BFD_RELOC_AVR_8_HI, BFD_RELOC_AVR_8_HHI.
+	* bfd-in2.h: Regenerate.
+	* libbfd.h: Regenerate.
+	* elf32-avr.c (elf_avr_howto_table): Add entries for
+	R_AVR_8_LO8, R_AVR_8_HI8, R_AVR_8_HHI8.
+	(avr_reloc_map): Add RELOC mappings for R_AVR_8_LO8, R_AVR_8_HI8,
+	R_AVR_8_HHI8.
+
+2012-05-10  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Use int in x32
+	addend overflow check.
+
+2012-05-10  DJ Delorie  <[email protected]>
+
+	* elf32-rx.c (rx_elf_object_p): Ignore empty segments.
+
+2012-05-10  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Display signed
+	hex number in x32 addend overflow check.
+
+2012-05-10  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_reloc_type_class): Handle
+	R_X86_64_RELATIVE64.
+
+2012-05-09  H.J. Lu  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Check addend
+	overflow for R_X86_64_RELATIVE64.
+
+2012-05-08  Ben Cheng  <[email protected]>
+
+	* elf.c: Preserve the original p_align and p_flags if they are
+	valid.
+
+2012-05-07  Alan Modra  <[email protected]>
+
+	* elf64-ia64-vms.c (elf64_ia64_relocate_section): Update
+	RELOC_AGAINST_DISCARDED_SECTION invocation.
+
+2012-05-07  Hans-Peter Nilsson  <[email protected]>
+
+	* elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): Declare and use
+	local variable i_ instead of assuming and using a variable i.
+
+2012-05-07  Maciej W. Rozycki  <[email protected]>
+
+	* elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): Handle compound
+	relocations.
+	* elfxx-mips.c (mips_reloc_against_discarded_section): New
+	function.
+	(_bfd_mips_elf_relocate_section): Call it, in place of
+	RELOC_AGAINST_DISCARDED_SECTION.
+	* elf-m10200.c (mn10200_elf_relocate_section): Update arguments
+	to RELOC_AGAINST_DISCARDED_SECTION.
+	* elf-m10300.c (mn10300_elf_relocate_section): Likewise.
+	* elf32-arm.c (elf32_arm_relocate_section): Likewise.
+	* elf32-avr.c (elf32_avr_relocate_section): Likewise.
+	* elf32-bfin.c (bfin_relocate_section): Likewise.
+	(bfinfdpic_relocate_section): Likewise.
+	* elf32-cr16.c (elf32_cr16_relocate_section): Likewise.
+	* elf32-cr16c.c (elf32_cr16c_relocate_section): Likewise.
+	* elf32-cris.c (cris_elf_relocate_section): Likewise.
+	* elf32-crx.c (elf32_crx_relocate_section): Likewise.
+	* elf32-d10v.c (elf32_d10v_relocate_section): Likewise.
+	* elf32-epiphany.c (epiphany_elf_relocate_section): Likewise.
+	* elf32-fr30.c (fr30_elf_relocate_section): Likewise.
+	* elf32-frv.c (elf32_frv_relocate_section): Likewise.
+	* elf32-h8300.c (elf32_h8_relocate_section): Likewise.
+	* elf32-hppa.c (elf32_hppa_relocate_section): Likewise.
+	* elf32-i370.c (i370_elf_relocate_section): Likewise.
+	* elf32-i386.c (elf_i386_relocate_section): Likewise.
+	* elf32-i860.c (elf32_i860_relocate_section): Likewise.
+	* elf32-ip2k.c (ip2k_elf_relocate_section): Likewise.
+	* elf32-iq2000.c (iq2000_elf_relocate_section): Likewise.
+	* elf32-lm32.c (lm32_elf_relocate_section): Likewise.
+	* elf32-m32c.c (m32c_elf_relocate_section): Likewise.
+	* elf32-m32r.c (m32r_elf_relocate_section): Likewise.
+	* elf32-m68hc1x.c (elf32_m68hc11_relocate_section): Likewise.
+	* elf32-m68k.c (elf_m68k_relocate_section): Likewise.
+	* elf32-mcore.c (mcore_elf_relocate_section): Likewise.
+	* elf32-mep.c (mep_elf_relocate_section): Likewise.
+	* elf32-moxie.c (moxie_elf_relocate_section): Likewise.
+	* elf32-msp430.c (elf32_msp430_relocate_section): Likewise.
+	* elf32-mt.c (mt_elf_relocate_section): Likewise.
+	* elf32-openrisc.c (openrisc_elf_relocate_section): Likewise.
+	* elf32-ppc.c (ppc_elf_relocate_section): Likewise.
+	* elf32-rl78.c (rl78_elf_relocate_section): Likewise.
+	* elf32-rx.c (rx_elf_relocate_section): Likewise.
+	* elf32-s390.c (elf_s390_relocate_section): Likewise.
+	* elf32-score.c (s3_bfd_score_elf_relocate_section): Likewise.
+	* elf32-score7.c (s7_bfd_score_elf_relocate_section): Likewise.
+	* elf32-sh.c (sh_elf_relocate_section): Likewise.
+	* elf32-spu.c (spu_elf_relocate_section): Likewise.
+	* elf32-tic6x.c (elf32_tic6x_relocate_section): Likewise.
+	* elf32-tilepro.c (tilepro_elf_relocate_section): Likewise.
+	* elf32-v850.c (v850_elf_relocate_section): Likewise.
+	* elf32-vax.c (elf_vax_relocate_section): Likewise.
+	* elf32-xc16x.c (elf32_xc16x_relocate_section): Likewise.
+	* elf32-xstormy16.c (xstormy16_elf_relocate_section): Likewise.
+	* elf32-xtensa.c (elf_xtensa_relocate_section): Likewise.
+	* elf64-alpha.c (elf64_alpha_relocate_section_r): Likewise.
+	(elf64_alpha_relocate_section): Likewise.
+	* elf64-hppa.c (elf64_hppa_relocate_section): Likewise.
+	* elf64-mmix.c (mmix_elf_relocate_section): Likewise.
+	* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
+	* elf64-s390.c (elf_s390_relocate_section): Likewise.
+	* elf64-sh64.c (sh_elf64_relocate_section): Likewise.
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
+	* elfnn-ia64.c (elfNN_ia64_relocate_section): Likewise.
+	* elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Likewise.
+	* elfxx-tilegx.c (tilegx_elf_relocate_section): Likewise.
+
+2012-05-05  Alan Modra  <[email protected]>
+
+	PR ld/14052
+	PR ld/13621
+	* linker.c (_bfd_nearby_section): Revert 2012-02-13 change.
+
+2012-05-05  Alan Modra  <[email protected]>
+
+	* aout-arm.c: Replace all uses of bfd_abs_section, bfd_com_section,
+	bfd_und_section and bfd_ind_section with their _ptr variants, or
+	use corresponding bfd_is_* macros.
+	* aout-ns32k.c: Likewise.
+	* aout-tic30.c: Likewise.
+	* coff-arm.c: Likewise.
+	* coff-tic54x.c: Likewise.
+	* cpu-ns32k.c: Likewise.
+	* elf-attrs.c: Likewise.
+	* elfcode.h: Likewise.
+	* peicode.h: Likewise.
+	* reloc.c: Likewise.
+	* riscix.c: Likewise.
+	* versados.c: Likewise.
+	* section.c: Likewise.
+	(bfd_abs_section, bfd_ind_section, bfd_com_section,
+	bfd_ind_section): Delete.
+	(std_section): New array replacing above.
+	(bfd_abs_section_ptr, bfd_ind_section_ptr, bfd_com_section_ptr,
+	bfd_ind_section_ptr, STD_SECTION): Update.
+	(BFD_FAKE_SECTION, GLOBAL_SYM_INIT): Remove unnecessary casts.
+	* bfd-in2.h: Regenerate.
+
+2012-05-03  Sean Keys  <[email protected]>
+
+	* cpu-xgate.c: New file. Added XGATE support.
+	* archures.c (bfd_architecture): Add XGATE architecture.
+	(bfd_archures_list): Add reference to XGATE architecture info.
+	* elf-bfd.h (prep_headers): Handle bfd_arch_xgate.
+	* reloc.c: Add various XGATE relocation enums.
+	* targets.c (bfd_elf32_xgate_vec): Declare and add to target vector
+	list.
+	* Makefile.am: Add support for XGATE elf.
+	* configure.in: Ditto.
+	* config.bfd: Ditto.
+	* Makefile.in: Regenerate.
+	* configure: Ditto.
+	* bfd-in2.h: Ditto.
+	* libbfd.h: Ditto.
+	Added files for XGATE relocations.
+	* elf32-xgate.c: Created minimal relocation file.
+	* elf32-xgate.h: Created minimal header file for elf32-xgate.
+
+2012-05-03  Tristan Gingold  <[email protected]>
+
+	* dwarf2.c (decode_line_info): Ignore
+	DW_LNE_HP_source_file_correlation.
+
+2012-05-01  Nick Clifton  <[email protected]>
+
+	PR binutils/13121
+	* aoutx.h: Rename 'finfo' to 'flaginfo' to avoid conflicts with
+	AIX system headers.
+	* coff-ppc.c: Likewise.
+	* cofflink.c: Likewise.
+	* elf32-arm.c: Likewise.
+	* elf64-sparc.c: Likewise.
+	* elflink.c: Likewise.
+	* pdp11.c: Likewise.
+	* rescoff.c: Likewise.
+
+2012-04-26  Mark Wielaard  <[email protected]>
+
+	* dwarf2.c (scan_unit_for_symbols): Account for DW_AT_high_pc
+	possibly being relative to DW_AT_low_pc.
+	(parse_comp_unit): Likewise.
+
+2012-04-26  Andreas Schwab  <[email protected]>
+
+	* elf32-m68k.c (elf_m68k_check_relocs): Mark non-GOT references
+	also when generating PIE.
+	(elf_m68k_discard_copies): Mark undefined weak symbols referenced
+	by relocations as dynamic.
+
+2012-04-26  Hans-Peter Nilsson  <[email protected]>
+
+	Provide a way for programs to recognize BFD_ASSERT calls.
+	* bfd.c (bfd_assert_handler_type): New API type.
+	(bfd_set_assert_handler, bfd_get_assert_handler): New API functions.
+	(_bfd_assert_handler): New variable.
+	(_bfd_default_assert_handler): New function.
+	(bfd_assert): Call _bfd_assert_handler, not _bfd_error_handler.
+	* libbfd-in.h (_bfd_assert_handler): Declare.
+	* libbfd.h, bfd-in2.h: Regenerate.
+
+2012-04-24  Hans-Peter Nilsson  <[email protected]>
+
+	PR ld/13990
+	* elf32-arm.c (elf32_arm_gc_sweep_hook): Handle a forced-local
+	symbol, where PLT refcount is set to -1.
+
+2012-04-24  Alan Modra  <[email protected]>
+
+	PR ld/13991
+	* elf-bfd.h (_bfd_elf_link_just_syms): Define as
+	_bfd_generic_link_just_syms.
+	* elflink.c (_bfd_elf_link_just_syms): Delete.
+	* linker.c (_bfd_generic_link_just_syms): Set sec_info_type.
+
+	* bfd-in.h (discarded_section): Renamed from elf_discarded_section.
+	* section.c (SEC_INFO_TYPE_NONE, SEC_INFO_TYPE_STABS,
+	SEC_INFO_TYPE_MERGE, SEC_INFO_TYPE_EH_FRAME,
+	SEC_INFO_TYPE_JUST_SYMS): Renamed from corresponding ELF_INFO_TYPE.
+	* elf-eh-frame.c, * elf-m10200.c, * elf-m10300.c,
+	* elf.c, * elf32-arm.c, * elf32-avr.c, * elf32-bfin.c,
+	* elf32-cr16.c, * elf32-cr16c.c, * elf32-cris.c,
+	* elf32-crx.c, * elf32-d10v.c, * elf32-epiphany.c,
+	* elf32-fr30.c, * elf32-frv.c, * elf32-h8300.c,
+	* elf32-hppa.c, * elf32-i370.c, * elf32-i386.c,
+	* elf32-i860.c, * elf32-ip2k.c, * elf32-iq2000.c,
+	* elf32-lm32.c, * elf32-m32c.c, * elf32-m32r.c,
+	* elf32-m68hc1x.c, * elf32-m68k.c, * elf32-mcore.c,
+	* elf32-mep.c, * elf32-moxie.c, * elf32-msp430.c,
+	* elf32-mt.c, * elf32-openrisc.c, * elf32-ppc.c,
+	* elf32-rl78.c, * elf32-rx.c, * elf32-s390.c,
+	* elf32-score.c, * elf32-score7.c, * elf32-sh.c,
+	* elf32-spu.c, * elf32-tic6x.c, * elf32-tilepro.c,
+	* elf32-v850.c, * elf32-vax.c, * elf32-xc16x.c,
+	* elf32-xstormy16.c, * elf32-xtensa.c, * elf64-alpha.c,
+	* elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mmix.c,
+	* elf64-ppc.c, * elf64-s390.c, * elf64-sh64.c,
+	* elf64-x86-64.c, * elflink.c, * elfnn-ia64.c,
+	* elfxx-mips.c, * elfxx-sparc.c, * elfxx-tilegx.c,
+	* reloc.c: Update all references.
+	* bfd-in2.h: Regenerate.
+
+2012-04-20  Andreas Krebbel  <[email protected]>
+
+	* elf32-s390.c (ELF_DYNAMIC_INTERPRETER): Set to the GCC default.
+	* elf64-s390.c (ELF_DYNAMIC_INTERPRETER): Set to the GCC default.
+
+2012-04-19  Thomas Schwinge  <[email protected]>
+
+	* elf32-sh.c (elf_sh_link_hash_entry): Specify an enum identifier for
+	got_type.
+	(allocate_dynrelocs, sh_elf_relocate_section, sh_elf_check_relocs): Use
+	it.
+
+2012-04-17  Kaz Kojima  <[email protected]>
+
+	* elf32-sh.c (allocate_dynrelocs): Don't allocate dynamic
+	relocations when LE conversion happens on the IE tls symbol.
+
+2012-04-17  Roland McGrath  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_nacl_plt0_entry): Fix nop padding
+	so that 32-byte boundary is a proper instruction boundary.
+
+2012-04-17  Tristan Gingold  <[email protected]>
+
+	* vms-lib.c (_bfd_vms_lib_get_module): Append .obj extension to
+	member of an object archive.<
+
+2012-04-17  Tristan Gingold  <[email protected]>
+
+	* vms-lib.c (MAX_EKEYLEN): Define.
+	(MAX_KEYLEN): Fix value.
+	(vms_write_index): Add comments and fix indentation.
+	Adjust comparaison.  Add assertions.  Free kbn_blk.
+	(_bfd_vms_lib_write_archive_contents): Use MAX_EKEYLEN.
+	Compense MAX_KEYLEN adjustment.
+
+2012-04-16  Maciej W. Rozycki  <[email protected]>
+
+	* elfxx-mips.c (mips16_stub_symndx): Handle n64 compound relocs.
+	(_bfd_mips_elf_check_relocs): Update accordingly.
+
+2012-04-13  Alan Modra  <[email protected]>
+
+	PR ld/13947
+	* elflink.c (bfd_elf_final_link): Set reloc_count to 0 for
+	reloc sections.
+
+2012-04-12  David S. Miller  <[email protected]>
+
+	* reloc.c (BFD_RELOC_SPARC_H34, BFD_RELOC_SPARC_SIZE32,
+	BFD_RELOC_SPARC_SIZE64, BFD_RELOC_SPARC_WDISP10): New relocs.
+	* libbfd.h: Regenerate.
+	* bfd-in2.h: Likewise.
+	* elfxx-sparc.c (sparc_elf_wdisp10_reloc): New function.
+	(_bfd_sparc_elf_howto_table): Add entries for R_SPARC_H34,
+	R_SPARC_SIZE32, R_SPARC_64, and R_SPARC_WDISP10.
+	(_bfd_sparc_elf_reloc_type_lookup): Handle new relocs.
+	(_bfd_sparc_elf_check_relocs): Likewise.
+	(_bfd_sparc_elf_gc_sweep_hook): Likewise.
+	(_bfd_sparc_elf_relocate_section): Likewise.
+
+2012-04-12  Roland McGrath  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_nacl_plt0_entry, elf32_arm_nacl_plt_entry):
+	New variables.
+	(struct elf32_arm_link_hash_table): New member `nacl_p'.
+	(elf32_arm_link_hash_table_create): Initialize it.
+	(elf32_arm_nacl_link_hash_table_create): New function.
+	(arm_movw_immediate, arm_movt_immediate): New functions.
+	(elf32_arm_populate_plt_entry): Test HTAB->nacl_p.
+	(elf32_arm_finish_dynamic_sections): Likewise.
+	(elf32_arm_output_plt_map_1): Likewise.
+	(bfd_elf32_littlearm_nacl_vec, bfd_elf32_bigarm_nacl_vec):
+	New backend vector stanza.
+	(elf32_arm_nacl_modify_segment_map): New function.
+	* config.bfd: Handle arm-*-nacl*, armeb-*-nacl*.
+	* targets.c: Support bfd_elf32_{big,little}_nacl_vec.
+	* configure.in: Likewise.
+	(bfd_elf32_bigarm_nacl_vec): Add elf-nacl.lo here.
+	(bfd_elf32_littlearm_nacl_vec): Likewise.
+	(bfd_elf32_bigarm_vec, bfd_elf32_littlearm_vec): Likewise.
+	(bfd_elf32_bigarm_symbian_vec): Likewise.
+	(bfd_elf32_littlearm_symbian_vec): Likewise.
+	(bfd_elf32_bigarm_vxworks_vec): Likewise.
+	(bfd_elf32_littlearm_vxworks_vec): Likewise.
+	* configure: Regenerated.
+
+2012-04-12  Tristan Gingold  <[email protected]>
+
+	* elflink.c (elf_link_output_extsym): Add a guard.
+	(bfd_elf_final_link): Remove assertion.
+	(bfd_elf_final_link): Add a guard.
+	* elfnn-ia64.c (INCLUDE_IA64_VMS): Removed.
+	(elfNN_vms_section_from_shdr, elfNN_vms_object_p)
+	(elfNN_vms_post_process_headers, elfNN_vms_section_processing)
+	(elfNN_vms_final_write_processing, elfNN_vms_close_and_cleanup):
+	Remove.
+	(elfNN-ia64-vms target): Move to ...
+	* elf64-ia64-vms.c: New file.
+	* configure.in (bfd_elf64_ia64_vms_vec): Add elf64-ia64-vms.lo
+	* Makefile.am (BFD64_BACKENDS): Add elf64-ia64-vms.lo.
+	(BFD64_BACKENDS_CFILES): Ad elf64-ia64-vms.c.
+	* configure: Regenerate.
+	* Makefile.in: Regenerate.
+
+2012-04-11  Nick Clifton  <[email protected]>
+
+	PR binutils/13897
+	* elf64-ppc.c (opd_entry_value): When dealing with sections
+	without relocs, keep the last section loaded in order to avoid
+	unnecessary reloads.
+
+2012-04-09  Roland McGrath  <[email protected]>
+
+	* elf.c (_bfd_elf_map_sections_to_segments): Set INFO->user_phdrs.
+	* elf-nacl.c (nacl_modify_segment_map): Do nothing if INFO->user_phdrs.
+	(nacl_modify_program_headers): Likewise.
+
+2012-04-03  Roland McGrath  <[email protected]>
+
+	* elf-nacl.c: New file.
+	* elf-nacl.h: New file.
+	* elf32-i386.c (elf_backend_modify_segment_map): Define for
+	bfd_elf32_i386_nacl_vec.
+	(elf_backend_modify_program_headers): Likewise.
+	* elf64-x86-64.c (elf_backend_modify_segment_map): Define for
+	bfd_elf64_x86_64_nacl_vec and bfd_elf32_x86_64_nacl_vec.
+	(elf_backend_modify_program_headers): Likewise.
+	* Makefile.am (BFD32_BACKENDS, BFD64_BACKENDS): Add elf-nacl.lo here.
+	(BFD32_BACKENDS_CFILES, BFD64_BACKENDS_CFILES): Add elf-nacl.c here.
+	* Makefile.in: Regenerated.
+	* configure.in (bfd_elf64_x86_64_nacl_vec): Add elf-nacl.o to tb here.
+	(bfd_elf32_x86_64_nacl_vec): Likewise.
+	(bfd_elf64_x86_64_vec, bfd_elf32_x86_64_vec): Likewise.
+	(bfd_elf64_x86_64_freebsd_vec, bfd_elf64_x86_64_sol2_vec): Likewise.
+	(bfd_elf64_l1om_vec, bfd_elf64_l1om_freebsd_vec): Likewise.
+	(bfd_elf64_k1om_vec, bfd_elf64_k1om_freebsd_vec): Likewise.
+	(bfd_elf32_i386_nacl_vec): Likewise.
+	(bfd_elf32_i386_sol2_vec, bfd_elf32_i386_freebsd_vec): Likewise.
+	(bfd_elf32_i386_vxworks_vec, bfd_elf32_i386_vec): Likewise.
+	* configure: Regenerated.
+
+2012-03-31  Andreas Schwab  <[email protected]>
+
+	* elf32-m68k.c (elf_m68k_relocate_section): Allow
+	R_68K_TLS_LE{8,16,32} for PIE.
+
+2012-03-30  Andreas Krebbel  <[email protected]>
+
+	* elf64-s390.c: Fix several comments regarding PLT entry
+	description.
+	* elf32-s390.c: Likewise.
+
+2012-03-30  Andreas Krebbel  <[email protected]>
+
+	* elf64-s390.c: Use the section pointer shortcuts in
+	elf_link_hash_table and remove them from the target specific
+	variant.
+	* elf32-s390.c: Likewise.
+
+2012-03-30  Andreas Krebbel  <[email protected]>
+
+	* elf64-s390.c (elf_s390x_plt_entry, elf_s390x_first_plt_entry):
+	New definitions.
+	(PLT_PIC_ENTRY_WORD*, PLT_PIC12_ENTRY_WORD*): Remove.
+	(elf_s390_finish_dynamic_symbol): Use memcpy instead of bfd_put_32.
+	(elf_s390_finish_dynamic_sections): Likewise.
+	* elf32-s390.c (elf_s390_plt_entry, elf_s390_plt_pic_entry)
+	(elf_s390_plt_pic12_entry, elf_s390_plt_pic16_entry)
+	(elf_s390_plt_first_entry, elf_s390_plt_pic_first_entry): New definitions.
+	(PLT_PIC16_ENTRY_WORD*, PLT_ENTRY_WORD*)
+	(PLT_PIC_FIRST_ENTRY_WORD*, PLT_FIRST_ENTRY_WORD*): Remove.
+
+2012-03-30  Andreas Krebbel  <[email protected]>
+
+	* elf32-s390.c (struct elf_s390_dyn_relocs): Remove.
+	Rename all occurrences in the file to elf_dyn_relocs.
+	* elf64-s390.c: Likewise.
+
+2012-03-30  Alan Modra  <[email protected]>
+
+	* elflink.c (_bfd_elf_gc_mark_reloc): Don't delve into dynamic
+	libraries.
+
+2012-03-29  Alan Modra  <[email protected]>
+
+	* bfd-in.h (bfd_get_arch_size, bfd_get_sign_extend_vma): Delete.
+	* bfd-in2.h: Regenerate.
+
+2012-03-23  Alan Modra  <[email protected]>
+
+	* elf.c (assign_file_positions_for_non_load_sections): Don't warn
+	on empty alloc sections.
+
+2012-03-23  Alan Modra  <[email protected]>
+
+	* linker.c (_bfd_nearby_section): New function, split out from..
+	(fix_syms): ..here.
+	* bfd-in.h (_bfd_nearby_section): Declare.
+	* bfd-in2.h: Regenerate.
+	* elflink.c (elf_link_input_bfd): Don't use text_index_section or
+	data_index_section with ld -q or ld -r output relocs against
+	stripped output sections.  Instead use _bfd_nearby_section.
+
+2012-03-23  Alan Modra  <[email protected]>
+
+	PR binutils/13894
+	* elf64-ppc.c (opd_entry_value): Read full symbol table when
+	sym hashes unavailable.
+
+2012-03-21  Eliot Dresselhaus  <[email protected]>
+
+	* elf32-tic6x.c (elf32_tic6x_merge_private_bfd_data): Return TRUE
+	for non-C6X objects.
+
+2012-03-20  Kai Tietz  <[email protected]>
+
+	PR ld/12742
+	* configure.in (AC_CHECK_HEADERS): Test for windows.h and dlfcn.h.
+	* plugin.c: Guard include of dlfcn.h if HAVE_DLFCN_H is defined.
+	Add windows.h header include if HAVE_WINDOWS_H is defined.
+	(dlerror): New static function if windows variant is used instead
+	of dlfcn.h.
+	(dlclose): Likewise.
+	(dlopen): Likewise.
+	(dlsym): Likewise.
+	* configure: Regenerated.
+	* config.in: Regenerated.
+
+2012-03-20  H.J. Lu  <[email protected]>
+
+	PR ld/13880
+	* elf32-i386.c (elf_i386_relocate_section): Don't issue an error
+	for R_386_GOTOFF relocation against protected function if
+	SYMBOLIC_BIND is true.
+
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Don't issue an
+	error for R_X86_64_GOTOFF64 relocation against protected function
+	when building executable or SYMBOLIC_BIND is true.
+
+2012-03-16  Roland McGrath  <[email protected]>
+
+	* config.bfd: Handle x86_64-*-nacl*.
+	* elf64-x86-64.c (bfd_elf64_x86_64_nacl_vec): New backend vector stanza.
+	(bfd_elf32_x86_64_nacl_vec): Likewise.
+	* targets.c: Support them.
+	* configure.in: Likewise.
+	* configure: Regenerated.
+
+2012-03-16  Matthew Gretton-Dann  <[email protected]>
+
+	* elf32-arm.c (elf32_arm_attributes_accept_div): New function.
+	(elf32_arm_attributes_forbid_div): Likewise.
+	(elf32_arm_merge_eabi_attributes): Correct handling of
+	Tag_DIV_use.
+
+2012-03-15  Roland McGrath  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_create_dynamic_sections): Use
+	elf_x86_64_backend_data parameters for plt_eh_frame.
+
+	* elf64-x86-64.c (struct elf_x86_64_backend_data): New type.
+	(get_elf_x86_64_backend_data, GET_PLT_ENTRY_SIZE): New macros.
+	(elf_x86_64_arch_bed): New variable.
+	(elf_backend_arch_data): New macro.
+	(elf_x86_64_adjust_dynamic_symbol): Use GET_PLT_ENTRY_SIZE.
+	(elf_x86_64_allocate_dynrelocs): Likewise.
+	(elf_x86_64_relocate_section): Likewise.
+	(elf_x86_64_plt_sym_val): Likewise.
+	(elf_x86_64_finish_dynamic_symbol): Use elf_x86_64_backend_data
+	parameters for PLT details.
+	(elf_x86_64_finish_dynamic_sections): Likewise.
+
+2012-03-14  Roland McGrath  <[email protected]>
+
+	* elf32-i386.c (elf_i386_nacl_pic_plt0_entry): Initialize up
+	to the full size, padding out with nop instructions.
+
+2012-03-12  Alan Modra  <[email protected]>
+
+	* elf-m10300.c (_bfd_mn10300_elf_adjust_dynamic_symbol): Don't warn
+	on zero size dynbss symbol.
+	* elf32-arm.c (elf32_arm_adjust_dynamic_symbol): Likewise.
+	* elf32-cr16.c (_bfd_cr16_elf_adjust_dynamic_symbol): Likewise.
+	* elf32-cris.c (elf_cris_adjust_dynamic_symbol): Likewise.
+	* elf32-hppa.c (elf32_hppa_adjust_dynamic_symbol): Likewise.
+	* elf32-i370.c (i370_elf_adjust_dynamic_symbol): Likewise.
+	* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Likewise.
+	* elf32-lm32.c (lm32_elf_adjust_dynamic_symbol): Likewise.
+	* elf32-m32r.c (m32r_elf_adjust_dynamic_symbol): Likewise.
+	* elf32-m68k.c (elf_m68k_adjust_dynamic_symbol): Likewise.
+	* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Likewise.
+	* elf32-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
+	* elf32-sh.c (sh_elf_adjust_dynamic_symbol): Likewise.
+	* elf32-tic6x.c (elf32_tic6x_adjust_dynamic_symbol): Likewise.
+	* elf32-tilepro.c (tilepro_elf_adjust_dynamic_symbol): Likewise.
+	* elf32-vax.c (elf_vax_adjust_dynamic_symbol): Likewise.
+	* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Likewise.
+	* elf64-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
+	* elf64-sh64.c (sh64_elf64_adjust_dynamic_symbol): Likewise.
+	* elf64-x86-64.c (elf_x86_64_adjust_dynamic_symbol): Likewise.
+	* elfxx-sparc.c (_bfd_sparc_elf_adjust_dynamic_symbol): Likewise.
+	* elfxx-tilegx.c (tilegx_elf_adjust_dynamic_symbol): Likewise.
+
+2012-03-10  Edmar Wienskoski  <[email protected]>
+
+	* archures.c: Add bfd_mach_ppc_e5500 and bfd_mach_ppc_e6500.
+	* bfd-in2.h: Regenerate.
+	* cpu-powerpc.c (bfd_powerpc_archs): Add entries for
+	bfd_mach_ppc_e5500 and bfd_mach_ppc_e6500.
+
+2012-03-09  H.J. Lu  <[email protected]>
+
+	PR ld/13817
+	* elf32-i386.c (elf_i386_relocate_section): Restore
+	R_386_IRELATIVE.
+
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Restore
+	R_X86_64_IRELATIVE.
+
+2012-03-08  Tristan Gingold  <[email protected]>
+
+	* vms-lib.c (_bfd_vms_lib_write_archive_contents): Set maximum
+	keylen according to archive kind.  Set nextvbn and nextrfa lhd
+	fields.  Add comments.
+
+2012-03-07  Nick Clifton  <[email protected]>
+
+	* elf-m10300.c (elf32_mn10300_link_hash_entry): Add tls_type
+	field.
+	(elf32_mn10300_link_hash_table): Add tls_ldm_got entry;
+	(elf_mn10300_tdata): Define.
+	(elf_mn10300_local_got_tls_type): Define.
+	(elf_mn10300_howto_table): Add entries for R_MN10300_TLS_GD,
+	R_MN10300_TLS_LD, R_MN10300_TLS_LDO, R_MN10300_TLS_GOTIE,
+	R_MN10300_TLS_IE, R_MN10300_TLS_LE, R_MN10300_TLS_DPTMOD,
+	R_MN10300_TLS_DTPOFF, R_MN10300_TLS_TPOFF relocs.
+	(mn10300_reloc_map): Likewise.
+	(elf_mn10300_tls_transition): New function.
+	(dtpoff, tpoff, mn10300_do_tls_transition): New functions.
+	(mn10300_elf_check_relocs): Add TLS support.
+	(mn10300_elf_final_link_relocate): Likewise.
+	(mn10300_elf_relocate_section): Likewise.
+	(mn10300_elf_relax_section): Likewise.
+	(elf32_mn10300_link_hash_newfunc): Initialise new field.
+	(_bfd_mn10300_copy_indirect_symbol): New function.
+	(elf32_mn10300_link_hash_table_create): Initialise new fields.
+	(_bfd_mn10300_elf_size_dynamic_sections): Add TLS support.
+	(_bfd_mn10300_elf_finish_dynamic_symbol): Likewise.
+	(_bfd_mn10300_elf_reloc_type_class): Allocate an
+	elf_mn10300_obj_tdata structure.
+	(elf_backend_copy_indirect_symbol): Define.
+	* reloc.c (BFD_MN10300_TLS_GD, BFD_MN10300_TLS_LD,
+	BFD_MN10300_TLS_LDO, BFD_MN10300_TLS_GOTIE, BFD_MN10300_TLS_IE,
+	BFD_MN10300_TLS_LE, BFD_MN10300_TLS_DPTMOD,
+	BFD_MN10300_TLS_DTPOFF, BFD_MN10300_TLS_TPOFF): New relocations.
+	(BFD_RELOC_MN10300_32_PCREL, BFD_RELOC_MN10300_16_PCREL): Move to
+	alongside other MN10300 relocations.
+	* bfd-in2.h: Regenerate.
+	* libbfd.h: Regenerate.
+
+2012-03-06  Jakub Jelinek  <[email protected]>
+
+	* elf64-x86-64.c (elf_x86_64_relocate_section): For R_X86_64_RELATIVE
+	set relocate to TRUE.
+
+2012-03-05  Rainer Orth  <[email protected]>
+
+	PR ld/12152
+	* elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Also ignore
+	overflows for R_SPARC_UA32 in .stab sections.
+
+2012-03-01  Alan Modra  <[email protected]>
+
+	* elfxx-tilegx.c (tilegx_elf_relocate_section): Silence bogus warning.
+
+2012-02-27  Alan Modra  <[email protected]>
+
+	* elf32-sh.c (sh_elf_osec_to_segment): Check for elf flavour bfd
+	before calling elf specific function.
+	(sh_elf_osec_readonly_p): Test for error return from above.
+
+2012-02-27  Alan Modra  <[email protected]>
+
+	* elf32-spu.c (build_stub): Fix malloc under-allocation.
+
+2012-02-25  Walter Lee  <[email protected]>
+	* reloc.c: Add BFD_RELOC_TILEPRO_TLS_GD_CALL,
+	BFD_RELOC_TILEPRO_IMM8_X0_TLS_GD_ADD,
+	BFD_RELOC_TILEPRO_IMM8_X1_TLS_GD_ADD,
+	BFD_RELOC_TILEPRO_IMM8_Y0_TLS_GD_ADD,
+	BFD_RELOC_TILEPRO_IMM8_Y1_TLS_GD_ADD,
+	BFD_RELOC_TILEPRO_TLS_IE_LOAD, BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE,
+	BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE,
+	BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_LO,
+	BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_LO,
+	BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_HI,
+	BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_HI,
+	BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_HA,
+	BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_HA,
+	BFD_RELOC_TILEGX_IMM16_X0_HW0_TLS_LE,
+	BFD_RELOC_TILEGX_IMM16_X1_HW0_TLS_LE,
+	BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_TLS_LE,
+	BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_TLS_LE,
+	BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_TLS_LE,
+	BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_TLS_LE,
+	BFD_RELOC_TILEGX_TLS_GD_CALL, BFD_RELOC_TILEGX_IMM8_X0_TLS_GD_ADD,
+	BFD_RELOC_TILEGX_IMM8_X1_TLS_GD_ADD,
+	BFD_RELOC_TILEGX_IMM8_Y0_TLS_GD_ADD,
+	BFD_RELOC_TILEGX_IMM8_Y1_TLS_GD_ADD, BFD_RELOC_TILEGX_TLS_IE_LOAD,
+	BFD_RELOC_TILEGX_IMM8_X0_TLS_ADD,
+	BFD_RELOC_TILEGX_IMM8_X1_TLS_ADD,
+	BFD_RELOC_TILEGX_IMM8_Y0_TLS_ADD, BFD_RELOC_TILEGX_IMM8_Y1_TLS_ADD.
+	Delete BFD_RELOC_TILEGX_IMM16_X0_HW1_GOT,
+	BFD_RELOC_TILEGX_IMM16_X1_HW1_GOT,
+	BFD_RELOC_TILEGX_IMM16_X0_HW2_GOT,
+	BFD_RELOC_TILEGX_IMM16_X1_HW2_GOT,
+	BFD_RELOC_TILEGX_IMM16_X0_HW3_GOT,
+	BFD_RELOC_TILEGX_IMM16_X1_HW3_GOT,
+	BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_GOT,
+	BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_GOT,
+	BFD_RELOC_TILEGX_IMM16_X0_HW1_TLS_GD,
+	BFD_RELOC_TILEGX_IMM16_X1_HW1_TLS_GD,
+	BFD_RELOC_TILEGX_IMM16_X0_HW2_TLS_GD,
+	BFD_RELOC_TILEGX_IMM16_X1_HW2_TLS_GD,
+	BFD_RELOC_TILEGX_IMM16_X0_HW3_TLS_GD,
+	BFD_RELOC_TILEGX_IMM16_X1_HW3_TLS_GD,
+	BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_TLS_GD,
+	BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_TLS_GD,
+	BFD_RELOC_TILEGX_IMM16_X0_HW1_TLS_IE,
+	BFD_RELOC_TILEGX_IMM16_X1_HW1_TLS_IE,
+	BFD_RELOC_TILEGX_IMM16_X0_HW2_TLS_IE,
+	BFD_RELOC_TILEGX_IMM16_X1_HW2_TLS_IE,
+	BFD_RELOC_TILEGX_IMM16_X0_HW3_TLS_IE,
+	BFD_RELOC_TILEGX_IMM16_X1_HW3_TLS_IE,
+	BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_TLS_IE,
+	BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_TLS_IE.
+	* elf32-tilepro.c (tilepro_elf_howto_table): Update tilepro
+	relocations.
+	(tilepro_reloc_map): Ditto.
+	(tilepro_info_to_howto_rela): Ditto.
+	(reloc_to_create_func): Ditto.
+	(tilepro_tls_translate_to_le): New.
+	(tilepro_tls_translate_to_ie): New.
+	(tilepro_elf_tls_transition): New.
+	(tilepro_elf_check_relocs): Handle new tls relocations.
+	(tilepro_elf_gc_sweep_hook): Ditto.
+	(allocate_dynrelocs): Ditto.
+	(tilepro_elf_relocate_section): Ditto.
+	(tilepro_replace_insn): New.
+	(insn_mask_X1): New.
+	(insn_mask_X0_no_dest_no_srca): New
+	(insn_mask_X1_no_dest_no_srca): New
+	(insn_mask_Y0_no_dest_no_srca): New
+	(insn_mask_Y1_no_dest_no_srca): New
+	(srca_mask_X0): New
+	(srca_mask_X1): New
+	(insn_tls_le_move_X1): New
+	(insn_tls_le_move_zero_X0X1): New
+	(insn_tls_ie_lw_X1): New
+	(insn_tls_ie_add_X0X1): New
+	(insn_tls_ie_add_Y0Y1): New
+	(insn_tls_gd_add_X0X1): New
+	(insn_tls_gd_add_Y0Y1): New
+	* elfxx-tilegx.c (tilegx_elf_howto_table): Update tilegx
+	relocations.
+	(tilegx_reloc_map): Ditto.
+	(tilegx_info_to_howto_rela): Ditto.
+	(reloc_to_create_func): Ditto.
+	(tilegx_elf_link_hash_table): New field disable_le_transition.
+	(tilegx_tls_translate_to_le): New.
+	(tilegx_tls_translate_to_ie): New.
+	(tilegx_elf_tls_transition): New.
+	(tilegx_elf_check_relocs): Handle new tls relocations.
+	(tilegx_elf_gc_sweep_hook): Ditto.
+	(allocate_dynrelocs): Ditto.
+	(tilegx_elf_relocate_section): Ditto.
+	(tilegx_copy_bits): New.
+	(tilegx_replace_insn): New.
+	(insn_mask_X1): New.
+	(insn_mask_X0_no_dest_no_srca): New.
+	(insn_mask_X1_no_dest_no_srca): New.
+	(insn_mask_Y0_no_dest_no_srca): New.
+	(insn_mask_Y1_no_dest_no_srca): New.
+	(insn_mask_X0_no_operand): New.
+	(insn_mask_X1_no_operand): New.
+	(insn_mask_Y0_no_operand): New.
+	(insn_mask_Y1_no_operand): New.
+	(insn_tls_ie_ld_X1): New.
+	(insn_tls_ie_ld4s_X1): New.
+	(insn_tls_ie_add_X0X1): New.
+	(insn_tls_ie_add_Y0Y1): New.
+	(insn_tls_ie_addx_X0X1): New.
+	(insn_tls_ie_addx_Y0Y1): New.
+	(insn_tls_gd_add_X0X1): New.
+	(insn_tls_gd_add_Y0Y1): New.
+	(insn_move_X0X1): New.
+	(insn_move_Y0Y1): New.
+	(insn_add_X0X1): New.
+	(insn_add_Y0Y1): New.
+	(insn_addx_X0X1): New.
+	(insn_addx_Y0Y1): New.
+	* libbfd.h: Regenerate.
+	* bfd-in2.h: Regenerate.
+
+2012-02-25  Walter Lee  <[email protected]>
+
+	* config.bfd (tilegx-*-*): rename little endian vector; add big
+	endian vector.
+	(tilegxbe-*-*): New case.
+	* configure.in (bfd_elf32_tilegx_vec): Rename...
+	(bfd_elf32_tilegx_le_vec): ... to this.
+	(bfd_elf32_tilegx_be_vec): New vector.
+	(bfd_elf64_tilegx_vec): Rename...
+	(bfd_elf64_tilegx_le_vec): ... to this.
+	(bfd_elf64_tilegx_be_vec): New vector.
+	* configure: Regenerate.
+	* elf32-tilegx.c (TARGET_LITTLE_SYM): Rename.
+	(TARGET_LITTLE_NAME): Ditto.
+	(TARGET_BIG_SYM): Define.
+	(TARGET_BIG_NAME): Define.
+	* elf64-tilegx.c (TARGET_LITTLE_SYM): Rename.
+	(TARGET_LITTLE_NAME): Ditto.
+	(TARGET_BIG_SYM): Define.
+	(TARGET_BIG_NAME): Define.
+	* targets.c (bfd_elf32_tilegx_vec): Rename...
+	(bfd_elf32_tilegx_le_vec): ... to this.
+	(bfd_elf32_tilegx_be_vec): Declare.
+	(bfd_elf64_tilegx_vec): Rename...
+	(bfd_elf64_tilegx_le_vec): ... to this.
+	(bfd_elf64_tilegx_be_vec): Declare.
+	(_bfd_target_vector): Add / rename above vectors.
+	* arctures.c (bfd_architecture): Define bfd_mach_tilegx32.
+	* bfd-in2.h: Regenerate.
+	* cpu-tilegx.c (bfd_tilegx32_arch): define.
+	(bfd_tilegx_arch): link to bfd_tilegx32_arch.
+
+2012-02-24  Nick Clifton  <[email protected]>
+
+	PR ld/13730
+	* reloc.c (bfd_generic_get_relocated_section_contents): Issue an
+	error message instead of aborting, when an outofrange reloc is
+	encountered.
+
+2012-02-23  Iain Sandoe  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_swap_in_non_scattered_reloc): New.
+	(bfd_mach_o_canonicalize_one_reloc):  Swap non-scattered reloc
+	bit-fields when target and host differ in endian-ness.  When
+	PAIRs are non-scattered	find the 'symbol' from the preceding
+	reloc.  Add FIXME re. reloc symbols on section boundaries.
+	(bfd_mach_o_swap_out_non_scattered_reloc): New.
+	(bfd_mach_o_write_relocs): Use bfd_mach_o_encode_non_scattered_reloc.
+
+2012-02-17  Iain Sandoe  <[email protected]>
+
+	* mach-o-i386.c (i386_howto_table): Add support for 16 bit
+	sect-diffs.
+	(bfd_mach_o_i386_swap_reloc_in): Handle 16bit sect-diffs.
+	(bfd_mach_o_i386_swap_reloc_out): Likewise.
+
+2012-02-17  Tristan Gingold  <[email protected]>
+
+	* reloc.c (BFD_RELOC_MACH_O_LOCAL_SECTDIFF):
+	* libbfd.h: Regenerated.
+	* bfd-in2.h: Likewise.
+	* mach-o-i386.c (i386_howto_table): Include local sectdiff.
+	(bfd_mach_o_i386_swap_reloc_in): Update for local sectdiff.
+	(bfd_mach_o_i386_swap_reloc_out): Likewise.
+
+2012-02-17  Andreas Krebbel  <[email protected]>
+
+	* elf32-s390.c (elf_s390_relocate_section): Support basr in the
+	GD->LE and LD->LE optimizations.
+
+2012-02-16  Alan Modra  <[email protected]>
+
+	PR binutils/13355
+	* elf32-rx.c (elf32_rx_relax_section): Correct width check.
+
+2012-02-13  Richard Henderson  <[email protected]>
+
+	PR ld/13621
+	* linker.c (fix_syms): Force symbols outside any section into
+	bfd_abs_section_ptr.
+
+2012-02-13  Alan Modra  <[email protected]>
+
+	* elf32-m68hc1x.c (elf32_m68hc11_merge_symbol_attribute): New function.
+	* elf32-m68hc1x.h (elf32_m68hc11_merge_symbol_attribute): Declare.
+	* elf32-m68hc11.c (elf_backend_merge_symbol_attribute): Define.
+	* elf32-m68hc12.c (elf_backend_merge_symbol_attribute): Define.
+
+2012-02-11  Jan Kratochvil  <[email protected]>
+	    Nick Clifton  <[email protected]>
+
+	* oasys.c (oasys_write_header): Fix compilation warning on zero-sized
+	memset.
+
+2012-02-10  Iain Sandoe  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_build_seg_command): Count zerofill section
+	vma additions in their logical, rather than physical order.
+
+2012-02-10  Iain Sandoe  <[email protected]>
+
+	* mach-o.c (mach_o_section_name_xlat): Correct eh-frame section
+	parameters.
+	* mach-o-x86-64.c (text_section_names_xlat): New.
+	(mach_o_x86_64_segsec_names_xlat): New.
+	(bfd_mach_o_tgt_seg_table): Define to mach_o_x86_64_segsec_names_xlat.
+	* mach-o-i386.c (text_section_names_xlat): Correct section parameters.
+
+2012-02-10  Tristan Gingold  <[email protected]>
+
+	* elfnn-ia64.c (elfNN_vms_object_p): Change comparison operator
+	to avoid infinite loop.  Add comments.
+
+2012-02-09  H.J. Lu  <[email protected]>
+
+	PR ld/13675
+	* cpu-i386.c (bfd_arch_i386_fill): Updated to support multi byte
+	nop instructions.
+	(bfd_arch_i386_short_nop_fill): New.
+	(bfd_arch_i386_long_nop_fill): Likewise.
+	Use bfd_arch_i386_short_nop_fill in 32bit bfd_arch_info
+	initializers.  Use bfd_arch_i386_long_nop_fill on 64bit
+	bfd_arch_info initializers.
+
+	* cpu-k1om.c (bfd_arch_i386_fill): Renamed to ...
+	(bfd_arch_i386_short_nop_fill): This.
+	Update bfd_arch_info initializers.
+	* cpu-l1om.c: Likewise.
+
+2012-02-08  Alan Modra  <[email protected]>
+
+	* elflink.c (_bfd_elf_gc_mark_rsec): Mark weakdef syms too.
+	(_bfd_elf_fix_symbol_flags): When a weakdef is def_regular, clear
+	the correct h->u.weakdef.
+
+2012-02-07  Alan Modra  <[email protected]>
+
+	* elf.c (elf_find_function): Don't use internal_elf_sym.
+	(_bfd_elf_maybe_function_sym): Likewise.  Replace elf_symbol_type
+	parameter with asymbol.
+	* elf64-ppc.c (ppc64_elf_maybe_function_sym): Likewise.
+	* elf-bfd.h (_bfd_elf_maybe_function_sym): Update prototype.
+	(struct elf_backend_data <maybe_function_sym>): Likewise.
+
+2012-02-02  Vidya Praveen ([email protected])
+
+	PR bfd/13410
+	* elf32-avr.c (elf32_avr_relax_section): Correct the
+	condition that qualifies the candidates for relaxation.
+
+2012-02-02  Tristan Gingold  <[email protected]>
+
+	* bfdio.c (real_fopen): Remove unused vms_modes variable.
+
+2012-02-02  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_read_header): Silent uninitialized
+	variable warning.
+
+2012-02-02  Tristan Gingold  <[email protected]>
+
+	* archive.c (bfd_slurp_armap): Fix thinko in cast.
+
+2012-01-31  H.J. Lu  <[email protected]>
+
+	PR ld/13616
+	* archures.c (bfd_arch_info): Add fill.
+	(bfd_default_arch_struct): Add bfd_arch_default_fill.
+	(bfd_arch_default_fill): New.
+
+	* configure.in: Set bfd version to 2.22.52.
+	* configure: Regenerated.
+
+	* cpu-alpha.c: Add bfd_arch_default_fill to bfd_arch_info
+	initializer.
+	* cpu-arc.c: Likewise.
+	* cpu-arm.c: Likewise.
+	* cpu-avr.c: Likewise.
+	* cpu-bfin.c: Likewise.
+	* cpu-cr16.c: Likewise.
+	* cpu-cr16c.c: Likewise.
+	* cpu-cris.c: Likewise.
+	* cpu-crx.c: Likewise.
+	* cpu-d10v.c: Likewise.
+	* cpu-d30v.c: Likewise.
+	* cpu-dlx.c: Likewise.
+	* cpu-epiphany.c: Likewise.
+	* cpu-fr30.c: Likewise.
+	* cpu-frv.c: Likewise.
+	* cpu-h8300.c: Likewise.
+	* cpu-h8500.c: Likewise.
+	* cpu-hppa.c: Likewise.
+	* cpu-i370.c: Likewise.
+	* cpu-i860.c: Likewise.
+	* cpu-i960.c: Likewise.
+	* cpu-ia64.c: Likewise.
+	* cpu-ip2k.c: Likewise.
+	* cpu-iq2000.c: Likewise.
+	* cpu-lm32.c: Likewise.
+	* cpu-m10200.c: Likewise.
+	* cpu-m10300.c: Likewise.
+	* cpu-m32c.c: Likewise.
+	* cpu-m32r.c: Likewise.
+	* cpu-m68hc11.c: Likewise.
+	* cpu-m68hc12.c: Likewise.
+	* cpu-m68k.c: Likewise.
+	* cpu-m88k.c: Likewise.
+	* cpu-mcore.c: Likewise.
+	* cpu-mep.c: Likewise.
+	* cpu-microblaze.c: Likewise.
+	* cpu-mips.c: Likewise.
+	* cpu-mmix.c: Likewise.
+	* cpu-moxie.c: Likewise.
+	* cpu-msp430.c: Likewise.
+	* cpu-mt.c: Likewise.
+	* cpu-ns32k.c: Likewise.
+	* cpu-openrisc.c: Likewise.
+	* cpu-or32.c: Likewise.
+	* cpu-pdp11.c: Likewise.
+	* cpu-pj.c: Likewise.
+	* cpu-plugin.c: Likewise.
+	* cpu-powerpc.c: Likewise.
+	* cpu-rl78.c: Likewise.
+	* cpu-rs6000.c: Likewise.
+	* cpu-rx.c: Likewise.
+	* cpu-s390.c: Likewise.
+	* cpu-score.c: Likewise.
+	* cpu-sh.c: Likewise.
+	* cpu-sparc.c: Likewise.
+	* cpu-spu.c: Likewise.
+	* cpu-tic30.c: Likewise.
+	* cpu-tic4x.c: Likewise.
+	* cpu-tic54x.c: Likewise.
+	* cpu-tic6x.c: Likewise.
+	* cpu-tic80.c: Likewise.
+	* cpu-tilegx.c: Likewise.
+	* cpu-tilepro.c: Likewise.
+	* cpu-v850.c: Likewise.
+	* cpu-vax.c: Likewise.
+	* cpu-w65.c: Likewise.
+	* cpu-we32k.c: Likewise.
+	* cpu-xc16x.c: Likewise.
+	* cpu-xstormy16.c: Likewise.
+	* cpu-xtensa.c: Likewise.
+	* cpu-z80.c: Likewise.
+	* cpu-z8k.c: Likewise.
+
+	* cpu-i386.c: Include "libiberty.h".
+	(bfd_arch_i386_fill): New.
+	Add bfd_arch_i386_fill to  bfd_arch_info initializer.
+
+	* cpu-k1om.c: Add bfd_arch_i386_fill to  bfd_arch_info initializer.
+	* cpu-l1om.c: Likewise.
+
+	* linker.c (default_data_link_order): Call abfd->arch_info->fill
+	if fill size is 0.
+
+	* bfd-in2.h: Regenerated.
+
+2012-01-27  Michael Eager  <[email protected]>
+
+	* elf32-microblaze.c (create_got_section):
+	Reuse existing .rela.got section.
+
+2012-01-23  Alan Modra  <[email protected]>
+
+	* elf-bfd.h: Formatting.
+	(struct elf_backend_data): Add "maybe_function_sym".
+	(_bfd_elf_maybe_function_sym): Declare.
+	* elfxx-target.h (elf_backend_maybe_function_sym): Define.
+	(elfNN_bed): Init new field.
+	* elf.c (elf_find_function): Use maybe_function_sym.
+	(_bfd_elf_maybe_function_sym): New function.
+	* elf64-ppc.c (elf_backend_maybe_function_sym): Define.
+	(ppc64_elf_maybe_function_sym): New function.
+
+2012-01-20  Francois Gouget  <[email protected]>
+
+	PR binutils/13534
+	* archive.c (_bfd_ar_sizepad): New function. Correctly install and
+	pad the size field in an archive header.
+	(_bfd_generic_read_ar_hdr_mag): Use the correct type and scan
+	function for the archive size field.
+	(bfd_generic_openr_next_archived_file): Likewise.
+	(do_slurp_coff_armap): Likewise.
+	(_bfd_write_archive_contents): Likewise.
+	(_bfd_bsd44_write_ar_hdr): Use the new function.
+	(bfd_ar_hdr_from_filesystem): Likewise.
+	(_bfd_write_archive_contents): Likewise.
+	(bsd_write_armap): Likewise.
+	(coff_write_armap): Likewise.
+	* archive64.c (bfd_elf64_archive_write_armap): Likewise.
+	* bfdio.c (bfd_bread): Use correct type for archive element
+	sizes.
+	* ar.c (open_inarch): Likewise.
+	(extract_file): Likewise.
+	* libbfd-in.h (struct areltdata): Use correct types for
+	parsed_size and extra_size fields.
+	Prototype _bfd_ar_sizepad function.
+	* libbfd.h: Regenerate.
+
+2012-01-20  Ulrich Weigand  <[email protected]>
+
+	* elf.c (elfcore_write_prpsinfo): Provide unconditionally.
+	Return NULL if core file generation is unsupported.
+	(elfcore_write_prstatus): Likewise.
+	* elf32-arm.c (elf32_arm_nabi_write_core_note): New function.
+	(elf_backend_write_core_note): Define.
+
+2012-01-19  Tristan Gingold  <[email protected]>
+
+	* pef.c: Add a comment.
+	* xsym.c: Likewise.
+
+2012-01-17  Alan Modra  <[email protected]>
+
+	* elf32-ppc.c (ppc_elf_write_core_note <NT_PRPSINFO>): Don't leave
+	trailing garbage in the note.
+	* elf64-ppc.c (ppc64_elf_write_core_note <NT_PRPSINFO>): Likewise.
+
+2012-01-16  Daniel Green  <[email protected]>
+
+	PR ld/13491
+	* coff-i386.c (coff_i386_rtype_to_howto <R_SECREL32>): Test
+	h->root.type not h->type.
+	* coff-x86_64.c (coff_amd64_rtype_to_howto <R_AMD64_SECREL>): Likewise.
+
+2012-01-13  Iain Sandoe  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_build_dysymtab_command): Handle absolute
+	indirect symbols.
+
+2012-01-13  Iain Sandoe  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_write_relocs): Move computation of relocs file
+	position from here... to (bfd_mach_o_build_seg_command): Here.
+
+2012-01-12  Iain Sandoe  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_count_indirect_symbols): New.
+	(bfd_mach_o_build_dysymtab_command): Populate indirect symbol table.
+	* mach-o.h (bfd_mach_o_asymbol): Move declaration to start of the
+	file. (bfd_mach_o_section): Add indirect_syms field.
+
+2012-01-11  Iain Sandoe  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_build_seg_command): Separate computation of
+	vmsize from filesize.  Don't compute offsets or file sizes for
+	zerofill sections.
+
+2012-01-11  Iain Sandoe  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_build_commands): Make the building of each
+	command type independent.
+
+2012-01-11  Alan Modra  <[email protected]>
+
+	* elf64-ppc.c: Define more insns used in plt call stubs.
+	(ppc64_elf_brtaken_reloc): Assume isa version 2 or above.
+	(ppc64_elf_relocate_section): Likewise.
+	(enum ppc_stub_type): Add ppc_stub_plt_call_r2save.
+	(struct ppc_link_hash_table): Increase size of stub_count array.
+	Add plt_stub_align and plt_thread_safe.
+	(ALWAYS_USE_FAKE_DEP, ALWAYS_EMIT_R2SAVE): Define.
+	(plt_stub_size, plt_stub_pad): New functions.
+	(build_plt_stub): Emit barriers for power7 thread safety.  Don't
+	emit needless save of r2.
+	(build_tls_get_addr_stub): Adjust params.
+	(ppc_build_one_stub): Handle ppc_stub_plt_call_r2save and aligning
+	plt stubs.  Adjust build_*plt_stub calls.
+	(ppc_size_one_stub): Similarly.
+	(ppc64_elf_size_stubs): Accept plt_thread_safe and plt_stub_align
+	params.  Choose default for plt_thread_safe based on existence of
+	calls to thread creation functions.  Modify plt_call to
+	plt_call_r2save when no tocsave reloc found.  Align tail of stub
+	sections.
+	(ppc64_elf_build_stubs): Align tail of stub sections.  Adjust
+	output of stub statistics.
+	(ppc64_elf_relocate_section): Handle ppc_stub_plt_call_r2save.
+	* elf64-ppc.h (ppc64_elf_size_stubs): Update prototype.
+
+2012-01-10  H.J. Lu  <[email protected]>
+
+	PR ld/13581
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Remove ABI_64_P
+	check on R_X86_64_PCXX.
+
+2012-01-10  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_build_commands): Avoid uninitialized false
+	warning.
+
+2012-01-10  Tristan Gingold  <[email protected]>
+
+	* bfdio.c (bfd_tell): Handle nested archives.
+	(bfd_seek): Ditto.
+	* cache.c (bfd_cache_lookup_worker): Ditto.
+	* archive.c (_bfd_get_elt_at_filepos): Remove code dealing with
+	nested archives.
+	(bfd_generic_openr_next_archived_file): Likewise.
+
+2012-01-09  Iain Sandoe  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_bfd_copy_private_symbol_data): Implement.
+	(bfd_mach_o_write_symtab): Remove handling for indirect syms.
+	(bfd_mach_o_primary_symbol_sort_key): Likewise.
+	(bfd_mach_o_cf_symbols): Likewise.
+	(bfd_mach_o_sort_symbol_table): Remove.
+	(bfd_mach_o_mangle_symbols): Adjust arguments, remove handling
+	for indirect and dysymtab counts.  Do the symbol sorting here.
+	(bfd_mach_o_build_dysymtab_command): Count the symbol types here.
+	Make the indirect symbols a TODO.
+	(bfd_mach_o_build_commands): Adjust call to bfd_mach_o_mangle_symbols.
+	(bfd_mach_o_make_empty_symbol): Specifically flag unset symbols with
+	a non-zero value.
+	(bfd_mach_o_read_symtab_symbol): Record the symbol index.
+	(bfd_mach_o_read_symtab_symbol): Adjust recording of global status.
+	* mach-o.h (mach_o_data_struct): Remove indirect and dysymtab entries.
+	(IS_MACHO_INDIRECT): Remove.
+	(SYM_MACHO_FIELDS_UNSET, SYM_MACHO_FIELDS_NOT_VALIDATED): New.
+
+2012-01-06  Nick Clifton  <[email protected]>
+
+	PR binutils/13121
+	* reloc.c (bfd_generic_lookup_section_flags): Rename 'finfo' to
+	'flaginfo' to avoid conflicts with AIX system headers.
+
+2012-01-06  Tristan Gingold  <[email protected]>
+
+	* bfdio.c (bfd_bread): Use arelt_size macro.
+
+2012-01-06  Tristan Gingold  <[email protected]>
+
+	* config.bfd (i[3-7]86-*-darwin*): Define targ64_selvecs.
+
+2012-01-05  Nick Clifton  <[email protected]>
+
+	PR ld/12161
+	* elf32-avr.c (elf32_avr_relax_delete_bytes): Read in relocs if
+	necessary.
+
+2012-01-05  Jan Kratochvil  <[email protected]>
+
+	Fix zero registers core files when built by gcc-4.7.
+	* elf64-x86-64.c (elf_x86_64_write_core_note): Remove variables p and
+	size.  Call elfcore_write_note for the local variables.  Remove the
+	final elfcore_write_note call.  Add NOTREACHED comments.
+
+2012-01-04  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_fat_stat_arch_elt): New function.
+	(bfd_mach_o_generic_stat_arch_elt): Adjust.
+
+2012-01-04  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_fat_member_init): New function.
+	(bfd_mach_o_openr_next_archived_file): Reindent.
+	Adjust to call bfd_mach_o_fat_member_init.
+	(bfd_mach_o_fat_extract): Adjust to call bfd_mach_o_fat_member_init.
+
+2012-01-04  Tristan Gingold  <[email protected]>
+
+	* mach-o-x86-64.c (bfd_mach_o_x86_64_swap_reloc_out): Handle
+	BFD_RELOC_32, BFD_RELOC_MACH_O_X86_64_PCREL32_1,
+	BFD_RELOC_MACH_O_X86_64_PCREL32_2,
+	BFD_RELOC_MACH_O_X86_64_PCREL32_4,
+	BFD_RELOC_MACH_O_X86_64_BRANCH32,
+	BFD_RELOC_MACH_O_X86_64_SUBTRACTOR32,
+	BFD_RELOC_MACH_O_X86_64_GOT.
+
+2012-01-04  Tristan Gingold  <[email protected]>
+
+	* mach-o.h (bfd_mach_o_fvmlib_command): New structure.
+	(bfd_mach_o_load_command): Add fvmlib field.
+
+	* mach-o.c (bfd_mach_o_read_fvmlib): New function.
+	(bfd_mach_o_read_command): Handle fvmlib.
+
+2012-01-04  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_convert_architecture): Reindent.
+	Decode msubtype for ARM.
+
+2012-01-04  Tristan Gingold  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_get_synthetic_symtab): Add comments.
+
+2012-01-04  Tristan Gingold  <[email protected]>
+
+	* mach-o.h: Reindent header.
+	(bfd_mach_o_encryption_info_command): New structure.
+	(bfd_mach_o_load_command): Add encryption_info field.
+
+	* mach-o.c (bfd_mach_o_read_encryption_info): New function.
+	(bfd_mach_o_read_command): Handle BFD_MACH_O_LC_ENCRYPTION_INFO.
+	(bfd_mach_o_read_command): Adjust error message.
+
+2012-01-04  Shinichiro Hamaji  <[email protected]>
+
+	* dwarf2.c (_bfd_dwarf2_slurp_debug_info): Factor out the part
+	which reads DWARF2 and stores in stash from find_line.
+	(find_line) Call _bfd_dwarf2_slurp_debug_info.
+	* libbfd-in.h (_bfd_dwarf2_slurp_debug_info): Add declaration.
+	* libbfd.h (_bfd_dwarf2_slurp_debug_info): Regenerate.
+	* mach-o.c (dsym_subdir): The name of subdir where debug
+	information may be stored.
+	(bfd_mach_o_lookup_uuid_command): New. Lookup a load command whose
+	type is UUID.
+	(bfd_mach_o_dsym_for_uuid_p): New. Check if the specified BFD is
+	corresponding to the executable.
+	(bfd_mach_o_find_dsym): New. Find a debug information BFD in the
+	specified binary file.
+	(bfd_mach_o_follow_dsym): New. Find a debug information BFD for
+	the original BFD.
+	(bfd_mach_o_find_nearest_line): Check dSYM files for Mach-O
+	executables, dylibs, and bundles.
+	(bfd_mach_o_close_and_cleanup): Clean up BFDs for the dSYM file.
+	* mach-o.h (dsym_bfd): The BFD of the dSYM file.
+
+2012-01-03  Iain Sandoe  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_mangle_symbols): Put in the section index
+	for stabd symbols.
+	(bfd_mach_o_primary_symbol_sort_key): Adjust for stabs.
+	(bfd_mach_o_cf_symbols): Likewise.
+
+2012-01-03  Iain Sandoe  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_mangle_symbols): Correct typo.
+
+2012-01-03  Iain Sandoe  <[email protected]>
+
+	* mach-o.c (bfd_mach_o_write_symtab): Fill in the string table index
+	as the value of an indirect symbol.  Keep the string table index in
+	non-indirect syms for reference.
+	(bfd_mach_o_write_dysymtab): New.
+	(bfd_mach_o_primary_symbol_sort_key): New.
+	(bfd_mach_o_cf_symbols): New.
+	(bfd_mach_o_sort_symbol_table): New.
+	(bfd_mach_o_mangle_symbols): Return early if no symbols.  Sort symbols.
+	If we are emitting a dysymtab, process indirect symbols and count the
+	number of each other kind.
+	(bfd_mach_o_mangle_sections): New.
+	(bfd_mach_o_write_contents): Split out some pre-requisite code into
+	the command builder. Write dysymtab if the command is present.
+	(bfd_mach_o_count_sections_for_seg): New.
+	(bfd_mach_o_build_seg_command): New.
+	(bfd_mach_o_build_dysymtab_command): New.
+	(bfd_mach_o_build_commands): Reorganize to support the fact that some
+	commands are optional and should not be emitted if there are no
+	sections or symbols.
+	(bfd_mach_o_set_section_contents): Amend comment.
+	* mach-o.h: Amend and add to comments.
+	(mach_o_data_struct): Add fields for dysymtab symbols counts and a
+	pointer to the indirects, when present.
+	(bfd_mach_o_should_emit_dysymtab): New macro.
+	(IS_MACHO_INDIRECT): Likewise.
+
+For older changes see ChangeLog-2011
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
+
+Local Variables:
+mode: change-log
+left-margin: 8
+fill-column: 74
+version-control: never
+End:
diff --git a/bfd/ChangeLog-9193 b/bfd/ChangeLog-9193
index 01863de..31aa237 100644
--- a/bfd/ChangeLog-9193
+++ b/bfd/ChangeLog-9193
@@ -7840,6 +7840,12 @@
 	(_write_symbol_table):  Initialize <idx> counter.
 	(foop):  Eliminate debugging code.
 
+Copyright (C) 1991-1993 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
+
 Local Variables:
 mode: change-log
 left-margin: 8
diff --git a/bfd/ChangeLog-9495 b/bfd/ChangeLog-9495
index a208f42..1af501c 100644
--- a/bfd/ChangeLog-9495
+++ b/bfd/ChangeLog-9495
@@ -10035,6 +10035,12 @@
 
 For older changes see ChangeLog-9193
 
+Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
+
 Local Variables:
 mode: change-log
 left-margin: 8
diff --git a/bfd/ChangeLog-9697 b/bfd/ChangeLog-9697
index e9a5c1d..add810b 100644
--- a/bfd/ChangeLog-9697
+++ b/bfd/ChangeLog-9697
@@ -6721,6 +6721,12 @@
 
 For older changes see ChangeLog-9495
 
+Copyright (C) 1996,1997 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
+
 Local Variables:
 mode: change-log
 left-margin: 8
diff --git a/bfd/ChangeLog-9899 b/bfd/ChangeLog-9899
index 6d7f5cd..fdc2d89 100644
--- a/bfd/ChangeLog-9899
+++ b/bfd/ChangeLog-9899
@@ -5591,6 +5591,12 @@
 
 For older changes see ChangeLog-9697
 
+Copyright (C) 1998,1999 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
+
 Local Variables:
 mode: change-log
 left-margin: 8
diff --git a/bfd/MAINTAINERS b/bfd/MAINTAINERS
index d59a3bd..e7d8ff8 100644
--- a/bfd/MAINTAINERS
+++ b/bfd/MAINTAINERS
@@ -1 +1,7 @@
 See ../binutils/MAINTAINERS
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
diff --git a/bfd/Makefile.am b/bfd/Makefile.am
index ea4fd28..c645563 100644
--- a/bfd/Makefile.am
+++ b/bfd/Makefile.am
@@ -1,4 +1,21 @@
 ## Process this file with automake to generate Makefile.in
+#
+#   Copyright 2012 Free Software Foundation
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+#
 
 AUTOMAKE_OPTIONS = 1.11 no-dist foreign
 ACLOCAL_AMFLAGS = -I . -I .. -I ../config
@@ -35,7 +52,7 @@
 AM_CPPFLAGS = -DBINDIR='"$(bindir)"'
 if PLUGINS
 bfdinclude_HEADERS += $(INCDIR)/plugin-api.h
-LIBDL = -ldl
+LIBDL = @lt_cv_dlopen_libs@
 endif
 
 # bfd.h goes here, for now
@@ -71,6 +88,7 @@
 # This list is alphabetized to make it easier to keep in sync
 # with the decls and initializer in archures.c.
 ALL_MACHINES = \
+	cpu-aarch64.lo \
 	cpu-alpha.lo \
 	cpu-arc.lo \
 	cpu-arm.lo \
@@ -83,6 +101,7 @@
 	cpu-d10v.lo \
 	cpu-d30v.lo \
 	cpu-dlx.lo \
+	cpu-epiphany.lo \
 	cpu-fr30.lo \
 	cpu-frv.lo \
 	cpu-h8300.lo \
@@ -104,16 +123,20 @@
 	cpu-m32r.lo \
 	cpu-m68hc11.lo \
 	cpu-m68hc12.lo \
+	cpu-m9s12x.lo \
+	cpu-m9s12xg.lo \
 	cpu-m68k.lo \
 	cpu-m88k.lo \
 	cpu-mcore.lo \
 	cpu-mep.lo \
+	cpu-metag.lo \
 	cpu-microblaze.lo \
 	cpu-mips.lo \
 	cpu-mmix.lo \
 	cpu-moxie.lo \
 	cpu-msp430.lo \
 	cpu-mt.lo \
+	cpu-nios2.lo \
 	cpu-ns32k.lo \
 	cpu-openrisc.lo \
 	cpu-or32.lo \
@@ -122,6 +145,7 @@
 	cpu-plugin.lo \
 	cpu-powerpc.lo \
 	cpu-rs6000.lo \
+	cpu-rl78.lo \
 	cpu-rx.lo \
 	cpu-s390.lo \
 	cpu-score.lo \
@@ -136,16 +160,19 @@
 	cpu-tilegx.lo \
 	cpu-tilepro.lo \
 	cpu-v850.lo \
+	cpu-v850_rh850.lo \
 	cpu-vax.lo \
 	cpu-w65.lo \
 	cpu-we32k.lo \
 	cpu-xc16x.lo \
+	cpu-xgate.lo \
 	cpu-xstormy16.lo \
 	cpu-xtensa.lo \
 	cpu-z80.lo \
 	cpu-z8k.lo
 
 ALL_MACHINES_CFILES = \
+	cpu-aarch64.c \
 	cpu-alpha.c \
 	cpu-arc.c \
 	cpu-arm.c \
@@ -158,6 +185,7 @@
 	cpu-d10v.c \
 	cpu-d30v.c \
 	cpu-dlx.c \
+	cpu-epiphany.c \
 	cpu-fr30.c \
 	cpu-frv.c \
 	cpu-h8300.c \
@@ -179,10 +207,13 @@
 	cpu-m32r.c \
 	cpu-m68hc11.c \
 	cpu-m68hc12.c \
+	cpu-m9s12x.c \
+	cpu-m9s12xg.c \
 	cpu-m68k.c \
 	cpu-m88k.c \
 	cpu-mcore.c \
 	cpu-mep.c \
+	cpu-metag.c \
 	cpu-microblaze.c \
 	cpu-mips.c \
 	cpu-mmix.c \
@@ -190,6 +221,7 @@
 	cpu-msp430.c \
 	cpu-mt.c \
 	cpu-ns32k.c \
+	cpu-nios2.c \
 	cpu-openrisc.c \
 	cpu-or32.c \
 	cpu-pdp11.c \
@@ -197,6 +229,7 @@
 	cpu-plugin.c \
 	cpu-powerpc.c \
 	cpu-rs6000.c \
+	cpu-rl78.c \
 	cpu-rx.c \
 	cpu-s390.c \
 	cpu-score.c \
@@ -211,10 +244,12 @@
 	cpu-tilegx.c \
 	cpu-tilepro.c \
 	cpu-v850.c \
+	cpu-v850_rh850.c \
 	cpu-vax.c \
 	cpu-w65.c \
 	cpu-we32k.c \
 	cpu-xc16x.c \
+	cpu-xgate.c \
 	cpu-xstormy16.c \
 	cpu-xtensa.c \
 	cpu-z80.c \
@@ -271,6 +306,7 @@
 	elf-ifunc.lo \
 	elf-m10200.lo \
 	elf-m10300.lo \
+	elf-nacl.lo \
 	elf-strtab.lo \
 	elf-vxworks.lo \
 	elf.lo \
@@ -286,6 +322,7 @@
 	elf32-d10v.lo \
 	elf32-d30v.lo \
 	elf32-dlx.lo \
+	elf32-epiphany.lo \
 	elf32-fr30.lo \
 	elf32-frv.lo \
 	elf32-gen.lo \
@@ -307,15 +344,17 @@
 	elf32-m88k.lo \
 	elf32-mcore.lo \
 	elf32-mep.lo \
+	elf32-metag.lo \
 	elf32-microblaze.lo \
-	elf32-mips.lo \
 	elf32-moxie.lo \
 	elf32-msp430.lo \
 	elf32-mt.lo \
+	elf32-nios2.lo \
 	elf32-openrisc.lo \
 	elf32-or32.lo \
 	elf32-pj.lo \
 	elf32-ppc.lo \
+	elf32-rl78.lo \
 	elf32-rx.lo \
 	elf32-s390.lo \
 	elf32-sh-symbian.lo \
@@ -330,11 +369,11 @@
 	elf32-v850.lo \
 	elf32-vax.lo \
 	elf32-xc16x.lo \
+	elf32-xgate.lo \
 	elf32-xstormy16.lo \
 	elf32-xtensa.lo \
 	elf32.lo \
 	elflink.lo \
-	elfxx-mips.lo \
 	elfxx-sparc.lo \
 	elfxx-tilegx.lo \
 	epoc-pe-arm.lo \
@@ -455,6 +494,7 @@
 	elf-ifunc.c \
 	elf-m10200.c \
 	elf-m10300.c \
+	elf-nacl.c \
 	elf-strtab.c \
 	elf-vxworks.c \
 	elf.c \
@@ -470,6 +510,7 @@
 	elf32-d10v.c \
 	elf32-d30v.c \
 	elf32-dlx.c \
+	elf32-epiphany.c \
 	elf32-fr30.c \
 	elf32-frv.c \
 	elf32-gen.c \
@@ -491,15 +532,17 @@
 	elf32-m88k.c \
 	elf32-mcore.c \
 	elf32-mep.c \
+	elf32-metag.c \
 	elf32-microblaze.c \
-	elf32-mips.c \
 	elf32-moxie.c \
 	elf32-msp430.c \
 	elf32-mt.c \
+	elf32-nios2.c \
 	elf32-openrisc.c \
 	elf32-or32.c \
 	elf32-pj.c \
 	elf32-ppc.c \
+	elf32-rl78.c \
 	elf32-rx.c \
 	elf32-s390.c \
 	elf32-sh-symbian.c \
@@ -514,11 +557,11 @@
 	elf32-v850.c \
 	elf32-vax.c \
 	elf32-xc16x.c \
+	elf32-xgate.c \
 	elf32-xstormy16.c \
 	elf32-xtensa.c \
 	elf32.c \
 	elflink.c \
-	elfxx-mips.c \
 	elfxx-sparc.c \
 	elfxx-tilegx.c \
 	epoc-pe-arm.c \
@@ -595,6 +638,9 @@
 # elf32-ia64.c requires a 64-bit bfd_vma, and hence can not be put in
 # BFD32_BACKENDS.
 BFD64_BACKENDS = \
+	elf32-aarch64.lo \
+	elf64-aarch64.lo \
+	elfxx-aarch64.lo \
 	aix5ppc-core.lo \
 	aout64.lo \
 	coff-alpha.lo \
@@ -602,12 +648,14 @@
 	coff64-rs6000.lo \
 	demo64.lo \
 	elf32-ia64.lo \
+	elf32-mips.lo \
 	elf32-score.lo \
 	elf32-score7.lo \
 	elf64-alpha.lo \
 	elf64-gen.lo \
 	elf64-hppa.lo \
 	elf64-ia64.lo \
+	elf64-ia64-vms.lo \
 	elf64-mips.lo \
 	elf64-mmix.lo \
 	elf64-ppc.lo \
@@ -619,6 +667,7 @@
 	elf64.lo \
 	elfn32-mips.lo \
 	elfxx-ia64.lo \
+	elfxx-mips.lo \
 	mach-o-x86-64.lo \
 	mmo.lo \
 	nlm32-alpha.lo \
@@ -637,11 +686,13 @@
 	coff-x86_64.c \
 	coff64-rs6000.c \
 	demo64.c \
+	elf32-mips.c \
 	elf32-score.c \
 	elf32-score7.c \
 	elf64-alpha.c \
 	elf64-gen.c \
 	elf64-hppa.c \
+	elf64-ia64-vms.c \
 	elf64-mips.c \
 	elf64-mmix.c \
 	elf64-ppc.c \
@@ -652,7 +703,9 @@
 	elf64-x86-64.c \
 	elf64.c \
 	elfn32-mips.c \
+	elfxx-aarch64.c \
 	elfxx-ia64.c \
+	elfxx-mips.c \
 	mach-o-x86-64.c \
 	mmo.c \
 	nlm32-alpha.c \
@@ -713,6 +766,7 @@
 	$(OPTIONAL_BACKENDS_CFILES)
 
 BUILD_CFILES = \
+	elf32-aarch64.c elf64-aarch64.c \
 	elf32-ia64.c elf64-ia64.c peigen.c pepigen.c pex64igen.c
 
 CFILES = $(SOURCE_CFILES) $(BUILD_CFILES)
@@ -720,7 +774,7 @@
 ## This is a list of all .h files which are in the source tree.
 SOURCE_HFILES = \
 	aout-target.h aoutf1.h aoutx.h coffcode.h coffswap.h ecoffswap.h \
-	elf-bfd.h elf-hppa.h elf32-hppa.h \
+	elf-bfd.h elf-hppa.h elf-linux-psinfo.h elf32-hppa.h \
 	elf64-hppa.h elfcode.h elfcore.h \
 	freebsd.h genlink.h go32stub.h \
 	libaout.h libbfd.h libcoff.h libecoff.h libhppa.h libieee.h \
@@ -861,6 +915,18 @@
 	sed -e s/NN/64/g < $(srcdir)/elfxx-target.h > elf64-target.new
 	mv -f elf64-target.new elf64-target.h
 
+elf32-aarch64.c : elfnn-aarch64.c
+	rm -f elf32-aarch64.c
+	echo "#line 1 \"$(srcdir)/elfnn-aarch64.c\"" > elf32-aarch64.new
+	sed -e s/NN/32/g < $(srcdir)/elfnn-aarch64.c >> elf32-aarch64.new
+	mv -f elf32-aarch64.new elf32-aarch64.c
+
+elf64-aarch64.c : elfnn-aarch64.c
+	rm -f elf64-aarch64.c
+	echo "#line 1 \"$(srcdir)/elfnn-aarch64.c\"" > elf64-aarch64.new
+	sed -e s/NN/64/g < $(srcdir)/elfnn-aarch64.c >> elf64-aarch64.new
+	mv -f elf64-aarch64.new elf64-aarch64.c
+
 elf32-ia64.c : elfnn-ia64.c
 	rm -f elf32-ia64.c
 	sed -e s/NN/32/g < $(srcdir)/elfnn-ia64.c > elf32-ia64.new
diff --git a/bfd/Makefile.in b/bfd/Makefile.in
index 741809c..78d2d2c 100644
--- a/bfd/Makefile.in
+++ b/bfd/Makefile.in
@@ -15,6 +15,24 @@
 
 @SET_MAKE@
 
+#
+#   Copyright 2012 Free Software Foundation
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+#
+
 
 
 VPATH = @srcdir@
@@ -293,6 +311,7 @@
 libexecdir = @libexecdir@
 localedir = @localedir@
 localstatedir = @localstatedir@
+lt_cv_dlopen_libs = @lt_cv_dlopen_libs@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
@@ -336,7 +355,7 @@
 @INSTALL_LIBBFD_FALSE@noinst_LTLIBRARIES = libbfd.la
 AM_CFLAGS = $(WARN_CFLAGS)
 AM_CPPFLAGS = -DBINDIR='"$(bindir)"'
-@PLUGINS_TRUE@LIBDL = -ldl
+@PLUGINS_TRUE@LIBDL = @lt_cv_dlopen_libs@
 
 # bfd.h goes here, for now
 BFD_H = bfd.h
@@ -370,6 +389,7 @@
 # This list is alphabetized to make it easier to keep in sync
 # with the decls and initializer in archures.c.
 ALL_MACHINES = \
+	cpu-aarch64.lo \
 	cpu-alpha.lo \
 	cpu-arc.lo \
 	cpu-arm.lo \
@@ -382,6 +402,7 @@
 	cpu-d10v.lo \
 	cpu-d30v.lo \
 	cpu-dlx.lo \
+	cpu-epiphany.lo \
 	cpu-fr30.lo \
 	cpu-frv.lo \
 	cpu-h8300.lo \
@@ -403,16 +424,20 @@
 	cpu-m32r.lo \
 	cpu-m68hc11.lo \
 	cpu-m68hc12.lo \
+	cpu-m9s12x.lo \
+	cpu-m9s12xg.lo \
 	cpu-m68k.lo \
 	cpu-m88k.lo \
 	cpu-mcore.lo \
 	cpu-mep.lo \
+	cpu-metag.lo \
 	cpu-microblaze.lo \
 	cpu-mips.lo \
 	cpu-mmix.lo \
 	cpu-moxie.lo \
 	cpu-msp430.lo \
 	cpu-mt.lo \
+	cpu-nios2.lo \
 	cpu-ns32k.lo \
 	cpu-openrisc.lo \
 	cpu-or32.lo \
@@ -421,6 +446,7 @@
 	cpu-plugin.lo \
 	cpu-powerpc.lo \
 	cpu-rs6000.lo \
+	cpu-rl78.lo \
 	cpu-rx.lo \
 	cpu-s390.lo \
 	cpu-score.lo \
@@ -435,16 +461,19 @@
 	cpu-tilegx.lo \
 	cpu-tilepro.lo \
 	cpu-v850.lo \
+	cpu-v850_rh850.lo \
 	cpu-vax.lo \
 	cpu-w65.lo \
 	cpu-we32k.lo \
 	cpu-xc16x.lo \
+	cpu-xgate.lo \
 	cpu-xstormy16.lo \
 	cpu-xtensa.lo \
 	cpu-z80.lo \
 	cpu-z8k.lo
 
 ALL_MACHINES_CFILES = \
+	cpu-aarch64.c \
 	cpu-alpha.c \
 	cpu-arc.c \
 	cpu-arm.c \
@@ -457,6 +486,7 @@
 	cpu-d10v.c \
 	cpu-d30v.c \
 	cpu-dlx.c \
+	cpu-epiphany.c \
 	cpu-fr30.c \
 	cpu-frv.c \
 	cpu-h8300.c \
@@ -478,10 +508,13 @@
 	cpu-m32r.c \
 	cpu-m68hc11.c \
 	cpu-m68hc12.c \
+	cpu-m9s12x.c \
+	cpu-m9s12xg.c \
 	cpu-m68k.c \
 	cpu-m88k.c \
 	cpu-mcore.c \
 	cpu-mep.c \
+	cpu-metag.c \
 	cpu-microblaze.c \
 	cpu-mips.c \
 	cpu-mmix.c \
@@ -489,6 +522,7 @@
 	cpu-msp430.c \
 	cpu-mt.c \
 	cpu-ns32k.c \
+	cpu-nios2.c \
 	cpu-openrisc.c \
 	cpu-or32.c \
 	cpu-pdp11.c \
@@ -496,6 +530,7 @@
 	cpu-plugin.c \
 	cpu-powerpc.c \
 	cpu-rs6000.c \
+	cpu-rl78.c \
 	cpu-rx.c \
 	cpu-s390.c \
 	cpu-score.c \
@@ -510,10 +545,12 @@
 	cpu-tilegx.c \
 	cpu-tilepro.c \
 	cpu-v850.c \
+	cpu-v850_rh850.c \
 	cpu-vax.c \
 	cpu-w65.c \
 	cpu-we32k.c \
 	cpu-xc16x.c \
+	cpu-xgate.c \
 	cpu-xstormy16.c \
 	cpu-xtensa.c \
 	cpu-z80.c \
@@ -571,6 +608,7 @@
 	elf-ifunc.lo \
 	elf-m10200.lo \
 	elf-m10300.lo \
+	elf-nacl.lo \
 	elf-strtab.lo \
 	elf-vxworks.lo \
 	elf.lo \
@@ -586,6 +624,7 @@
 	elf32-d10v.lo \
 	elf32-d30v.lo \
 	elf32-dlx.lo \
+	elf32-epiphany.lo \
 	elf32-fr30.lo \
 	elf32-frv.lo \
 	elf32-gen.lo \
@@ -607,15 +646,17 @@
 	elf32-m88k.lo \
 	elf32-mcore.lo \
 	elf32-mep.lo \
+	elf32-metag.lo \
 	elf32-microblaze.lo \
-	elf32-mips.lo \
 	elf32-moxie.lo \
 	elf32-msp430.lo \
 	elf32-mt.lo \
+	elf32-nios2.lo \
 	elf32-openrisc.lo \
 	elf32-or32.lo \
 	elf32-pj.lo \
 	elf32-ppc.lo \
+	elf32-rl78.lo \
 	elf32-rx.lo \
 	elf32-s390.lo \
 	elf32-sh-symbian.lo \
@@ -630,11 +671,11 @@
 	elf32-v850.lo \
 	elf32-vax.lo \
 	elf32-xc16x.lo \
+	elf32-xgate.lo \
 	elf32-xstormy16.lo \
 	elf32-xtensa.lo \
 	elf32.lo \
 	elflink.lo \
-	elfxx-mips.lo \
 	elfxx-sparc.lo \
 	elfxx-tilegx.lo \
 	epoc-pe-arm.lo \
@@ -755,6 +796,7 @@
 	elf-ifunc.c \
 	elf-m10200.c \
 	elf-m10300.c \
+	elf-nacl.c \
 	elf-strtab.c \
 	elf-vxworks.c \
 	elf.c \
@@ -770,6 +812,7 @@
 	elf32-d10v.c \
 	elf32-d30v.c \
 	elf32-dlx.c \
+	elf32-epiphany.c \
 	elf32-fr30.c \
 	elf32-frv.c \
 	elf32-gen.c \
@@ -791,15 +834,17 @@
 	elf32-m88k.c \
 	elf32-mcore.c \
 	elf32-mep.c \
+	elf32-metag.c \
 	elf32-microblaze.c \
-	elf32-mips.c \
 	elf32-moxie.c \
 	elf32-msp430.c \
 	elf32-mt.c \
+	elf32-nios2.c \
 	elf32-openrisc.c \
 	elf32-or32.c \
 	elf32-pj.c \
 	elf32-ppc.c \
+	elf32-rl78.c \
 	elf32-rx.c \
 	elf32-s390.c \
 	elf32-sh-symbian.c \
@@ -814,11 +859,11 @@
 	elf32-v850.c \
 	elf32-vax.c \
 	elf32-xc16x.c \
+	elf32-xgate.c \
 	elf32-xstormy16.c \
 	elf32-xtensa.c \
 	elf32.c \
 	elflink.c \
-	elfxx-mips.c \
 	elfxx-sparc.c \
 	elfxx-tilegx.c \
 	epoc-pe-arm.c \
@@ -896,6 +941,9 @@
 # elf32-ia64.c requires a 64-bit bfd_vma, and hence can not be put in
 # BFD32_BACKENDS.
 BFD64_BACKENDS = \
+	elf32-aarch64.lo \
+	elf64-aarch64.lo \
+	elfxx-aarch64.lo \
 	aix5ppc-core.lo \
 	aout64.lo \
 	coff-alpha.lo \
@@ -903,12 +951,14 @@
 	coff64-rs6000.lo \
 	demo64.lo \
 	elf32-ia64.lo \
+	elf32-mips.lo \
 	elf32-score.lo \
 	elf32-score7.lo \
 	elf64-alpha.lo \
 	elf64-gen.lo \
 	elf64-hppa.lo \
 	elf64-ia64.lo \
+	elf64-ia64-vms.lo \
 	elf64-mips.lo \
 	elf64-mmix.lo \
 	elf64-ppc.lo \
@@ -920,6 +970,7 @@
 	elf64.lo \
 	elfn32-mips.lo \
 	elfxx-ia64.lo \
+	elfxx-mips.lo \
 	mach-o-x86-64.lo \
 	mmo.lo \
 	nlm32-alpha.lo \
@@ -938,11 +989,13 @@
 	coff-x86_64.c \
 	coff64-rs6000.c \
 	demo64.c \
+	elf32-mips.c \
 	elf32-score.c \
 	elf32-score7.c \
 	elf64-alpha.c \
 	elf64-gen.c \
 	elf64-hppa.c \
+	elf64-ia64-vms.c \
 	elf64-mips.c \
 	elf64-mmix.c \
 	elf64-ppc.c \
@@ -953,7 +1006,9 @@
 	elf64-x86-64.c \
 	elf64.c \
 	elfn32-mips.c \
+	elfxx-aarch64.c \
 	elfxx-ia64.c \
+	elfxx-mips.c \
 	mach-o-x86-64.c \
 	mmo.c \
 	nlm32-alpha.c \
@@ -1016,12 +1071,13 @@
 	$(OPTIONAL_BACKENDS_CFILES)
 
 BUILD_CFILES = \
+	elf32-aarch64.c elf64-aarch64.c \
 	elf32-ia64.c elf64-ia64.c peigen.c pepigen.c pex64igen.c
 
 CFILES = $(SOURCE_CFILES) $(BUILD_CFILES)
 SOURCE_HFILES = \
 	aout-target.h aoutf1.h aoutx.h coffcode.h coffswap.h ecoffswap.h \
-	elf-bfd.h elf-hppa.h elf32-hppa.h \
+	elf-bfd.h elf-hppa.h elf-linux-psinfo.h elf32-hppa.h \
 	elf64-hppa.h elfcode.h elfcore.h \
 	freebsd.h genlink.h go32stub.h \
 	libaout.h libbfd.h libcoff.h libecoff.h libhppa.h libieee.h \
@@ -1248,6 +1304,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cofflink.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compress.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/corefile.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-aarch64.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-alpha.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-arc.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-arm.Plo@am__quote@
@@ -1260,6 +1317,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-d10v.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-d30v.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-dlx.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-epiphany.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-fr30.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-frv.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-h8300.Plo@am__quote@
@@ -1283,14 +1341,18 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-m68hc12.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-m68k.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-m88k.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-m9s12x.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-m9s12xg.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-mcore.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-mep.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-metag.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-microblaze.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-mips.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-mmix.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-moxie.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-msp430.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-mt.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-nios2.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-ns32k.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-openrisc.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-or32.Plo@am__quote@
@@ -1298,6 +1360,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-pj.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-plugin.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-powerpc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-rl78.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-rs6000.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-rx.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-s390.Plo@am__quote@
@@ -1313,10 +1376,12 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-tilegx.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-tilepro.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-v850.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-v850_rh850.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-vax.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-w65.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-we32k.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-xc16x.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-xgate.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-xstormy16.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-xtensa.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-z80.Plo@am__quote@
@@ -1331,9 +1396,11 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf-ifunc.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf-m10200.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf-m10300.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf-nacl.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf-strtab.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf-vxworks.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-aarch64.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-am33lin.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-arc.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-arm.Plo@am__quote@
@@ -1346,6 +1413,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-d10v.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-d30v.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-dlx.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-epiphany.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-fr30.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-frv.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-gen.Plo@am__quote@
@@ -1368,15 +1436,18 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-m88k.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-mcore.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-mep.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-metag.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-microblaze.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-mips.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-moxie.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-msp430.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-mt.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-nios2.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-openrisc.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-or32.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-pj.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-ppc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-rl78.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-rx.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-s390.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-score.Plo@am__quote@
@@ -1393,12 +1464,15 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-v850.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-vax.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-xc16x.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-xgate.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-xstormy16.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-xtensa.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-aarch64.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-alpha.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-gen.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-hppa.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-ia64-vms.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-ia64.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-mips.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64-mmix.Plo@am__quote@
@@ -1411,6 +1485,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf64.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elflink.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfn32-mips.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfxx-aarch64.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfxx-ia64.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfxx-mips.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfxx-sparc.Plo@am__quote@
@@ -1919,6 +1994,18 @@
 	sed -e s/NN/64/g < $(srcdir)/elfxx-target.h > elf64-target.new
 	mv -f elf64-target.new elf64-target.h
 
+elf32-aarch64.c : elfnn-aarch64.c
+	rm -f elf32-aarch64.c
+	echo "#line 1 \"$(srcdir)/elfnn-aarch64.c\"" > elf32-aarch64.new
+	sed -e s/NN/32/g < $(srcdir)/elfnn-aarch64.c >> elf32-aarch64.new
+	mv -f elf32-aarch64.new elf32-aarch64.c
+
+elf64-aarch64.c : elfnn-aarch64.c
+	rm -f elf64-aarch64.c
+	echo "#line 1 \"$(srcdir)/elfnn-aarch64.c\"" > elf64-aarch64.new
+	sed -e s/NN/64/g < $(srcdir)/elfnn-aarch64.c >> elf64-aarch64.new
+	mv -f elf64-aarch64.new elf64-aarch64.c
+
 elf32-ia64.c : elfnn-ia64.c
 	rm -f elf32-ia64.c
 	sed -e s/NN/32/g < $(srcdir)/elfnn-ia64.c > elf32-ia64.new
diff --git a/bfd/PORTING b/bfd/PORTING
index c8bfd77..b820525 100644
--- a/bfd/PORTING
+++ b/bfd/PORTING
@@ -81,3 +81,9 @@
 TARGETNAME
 	The name of the target, for run-time lookups.
 	Usually "a.out-<target>"
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
diff --git a/bfd/README b/bfd/README
index fe6b6f3..5ecfd29 100644
--- a/bfd/README
+++ b/bfd/README
@@ -47,3 +47,9 @@
 
 Bug reports without patches will be remembered, but they may never get
 fixed until somebody volunteers to fix them.
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
diff --git a/bfd/TODO b/bfd/TODO
index 7a12735..012d624 100644
--- a/bfd/TODO
+++ b/bfd/TODO
@@ -19,7 +19,9 @@
      the stupid quips and fill in all the blanks.
 
  o - upgrade the reloc handling as per Steve's suggestion.
+
+Copyright (C) 2012 Free Software Foundation, Inc.
 
-
-
-
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
diff --git a/bfd/acinclude.m4 b/bfd/acinclude.m4
index d9813bd..3518592 100644
--- a/bfd/acinclude.m4
+++ b/bfd/acinclude.m4
@@ -1,3 +1,21 @@
+dnl
+dnl   Copyright 2012 Free Software Foundation
+dnl
+dnl This file is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3 of the License, or
+dnl (at your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; see the file COPYING3.  If not see
+dnl <http://www.gnu.org/licenses/>.
+dnl
+
 sinclude([../config/zlib.m4])
 
 dnl See whether we need to use fopen-bin.h rather than fopen-same.h.
diff --git a/bfd/aix386-core.c b/bfd/aix386-core.c
index 121d623..947ab80 100644
--- a/bfd/aix386-core.c
+++ b/bfd/aix386-core.c
@@ -2,7 +2,7 @@
    This was based on trad-core.c, which was written by John Gilmore of
         Cygnus Support.
    Copyright 1988, 1989, 1991, 1992, 1993, 1994, 1996, 1998, 1999, 2000,
-   2001, 2002, 2004, 2005, 2006, 2007, 2010, 2011
+   2001, 2002, 2004, 2005, 2006, 2007, 2010, 2011, 2012
    Free Software Foundation, Inc.
    Written by Minh Tran-Le <[email protected]>.
    Converted to back end form by Ian Lance Taylor <[email protected]>.
@@ -59,32 +59,31 @@
     (((bfd)->tdata.trad_core_data)->reg2_section)
 
 /* These are stored in the bfd's tdata.  */
-struct trad_core_struct {
+struct trad_core_struct
+{
   struct corehdr *hdr;		/* core file header */
   asection *reg_section;
   asection *reg2_section;
   asection *sections[MAX_CORE_SEGS];
 };
 
-static void swap_abort PARAMS ((void));
-
 static const bfd_target *
-aix386_core_file_p (abfd)
-     bfd *abfd;
+aix386_core_file_p (bfd *abfd)
 {
   int i, n;
   unsigned char longbuf[4];	/* Raw bytes of various header fields */
   bfd_size_type core_size = sizeof (struct corehdr);
   bfd_size_type amt;
   struct corehdr *core;
-  struct mergem {
+  struct mergem
+  {
     struct trad_core_struct coredata;
     struct corehdr internal_core;
   } *mergem;
   flagword flags;
 
   amt = sizeof (longbuf);
-  if (bfd_bread ((PTR) longbuf, amt, abfd) != amt)
+  if (bfd_bread (longbuf, amt, abfd) != amt)
     {
       if (bfd_get_error () != bfd_error_system_call)
 	bfd_set_error (bfd_error_wrong_format);
@@ -104,7 +103,7 @@
 
   core = &mergem->internal_core;
 
-  if ((bfd_bread ((PTR) core, core_size, abfd)) != core_size)
+  if ((bfd_bread (core, core_size, abfd)) != core_size)
     {
       if (bfd_get_error () != bfd_error_system_call)
 	bfd_set_error (bfd_error_wrong_format);
@@ -196,15 +195,13 @@
 }
 
 static char *
-aix386_core_file_failing_command (abfd)
-     bfd *abfd;
+aix386_core_file_failing_command (bfd *abfd)
 {
   return core_hdr (abfd)->cd_comm;
 }
 
 static int
-aix386_core_file_failing_signal (abfd)
-     bfd *abfd;
+aix386_core_file_failing_signal (bfd *abfd)
 {
   return core_hdr (abfd)->cd_cursig;
 }
@@ -216,7 +213,7 @@
 /* If somebody calls any byte-swapping routines, shoot them.  */
 
 static void
-swap_abort ()
+swap_abort (void)
 {
   /* This way doesn't require any declaration for ANSI to fuck up.  */
   abort ();
@@ -229,7 +226,8 @@
 #define	NO_PUT64 ((void (*) (bfd_uint64_t, void *)) swap_abort)
 #define	NO_GETS64 ((bfd_int64_t (*) (const void *)) swap_abort)
 
-const bfd_target aix386_core_vec = {
+const bfd_target aix386_core_vec =
+{
   "aix386-core",
   bfd_target_unknown_flavour,
   BFD_ENDIAN_BIG,		/* target byte order */
@@ -269,5 +267,5 @@
 
   NULL,
 
-  (PTR) 0
+  NULL
 };
diff --git a/bfd/aout-arm.c b/bfd/aout-arm.c
index fd93603..9eb9488 100644
--- a/bfd/aout-arm.c
+++ b/bfd/aout-arm.c
@@ -1,6 +1,6 @@
 /* BFD back-end for raw ARM a.out binaries.
    Copyright 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005,
-   2007, 2009, 2010, 2011 Free Software Foundation, Inc.
+   2007, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
    Contributed by Richard Earnshaw ([email protected])
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -247,7 +247,7 @@
   bfd_reloc_status_type flag = bfd_reloc_ok;
 
   /* If this is an undefined symbol, return error.  */
-  if (symbol->section == &bfd_und_section
+  if (bfd_is_und_section (symbol->section)
       && (symbol->flags & BSF_WEAK) == 0)
     return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined;
 
@@ -409,10 +409,10 @@
      check for that here.  */
 
   if (bfd_is_com_section (output_section)
-      || output_section == &bfd_abs_section
-      || output_section == &bfd_und_section)
+      || bfd_is_abs_section (output_section)
+      || bfd_is_und_section (output_section))
     {
-      if (bfd_abs_section.symbol == sym)
+      if (bfd_abs_section_ptr->symbol == sym)
 	{
 	  /* Whoops, looked like an abs symbol, but is really an offset
 	     from the abs section.  */
diff --git a/bfd/aout-cris.c b/bfd/aout-cris.c
index f1f3060..3e3d21a 100644
--- a/bfd/aout-cris.c
+++ b/bfd/aout-cris.c
@@ -1,5 +1,5 @@
 /* BFD backend for CRIS a.out binaries.
-   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2009
+   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2009, 2012
    Free Software Foundation, Inc.
    Contributed by Axis Communications AB.
    Written by Hans-Peter Nilsson.
@@ -66,6 +66,7 @@
 #define MY(OP) CONCAT2 (cris_aout_,OP)
 #define NAME(x, y) CONCAT3 (cris_aout,_32_,y)
 
+#include "sysdep.h"
 #include "bfd.h"
 
 /* Version 1 of the header.  */
diff --git a/bfd/aout-ns32k.c b/bfd/aout-ns32k.c
index 9a0737d..75886bc 100644
--- a/bfd/aout-ns32k.c
+++ b/bfd/aout-ns32k.c
@@ -1,6 +1,6 @@
 /* BFD back-end for ns32k a.out-ish binaries.
    Copyright 1990, 1991, 1992, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-   2002, 2003, 2005, 2006, 2007, 2010 Free Software Foundation, Inc.
+   2002, 2003, 2005, 2006, 2007, 2010, 2012 Free Software Foundation, Inc.
    Contributed by Ian Dall ([email protected]).
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -20,6 +20,7 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
+#include "sysdep.h"
 #include "bfd.h"
 #include "aout/aout64.h"
 #include "ns32k.h"
@@ -303,10 +304,10 @@
      from the abs section, or as a symbol which has an abs value.
      Check for that here.  */
   if (bfd_is_com_section (output_section)
-      || output_section == &bfd_abs_section
-      || output_section == &bfd_und_section)
+      || bfd_is_abs_section (output_section)
+      || bfd_is_und_section (output_section))
     {
-      if (bfd_abs_section.symbol == sym)
+      if (bfd_abs_section_ptr->symbol == sym)
 	{
 	  /* Whoops, looked like an abs symbol, but is really an offset
 	     from the abs section.  */
diff --git a/bfd/aout-sparcle.c b/bfd/aout-sparcle.c
index afcc342..e050423 100644
--- a/bfd/aout-sparcle.c
+++ b/bfd/aout-sparcle.c
@@ -1,5 +1,5 @@
 /* BFD backend for sparc little-endian aout binaries.
-   Copyright 1996, 2001, 2005, 2007 Free Software Foundation, Inc.
+   Copyright 1996, 2001, 2005, 2007, 2012 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -25,6 +25,7 @@
    the tokens.  */
 #define MY(OP) CONCAT2 (sparcle_aout_,OP)
 
+#include "sysdep.h"
 #include "bfd.h"
 #include "bfdlink.h"
 #include "libaout.h"
diff --git a/bfd/aout-target.h b/bfd/aout-target.h
index f6e8bd2..1ffef87 100644
--- a/bfd/aout-target.h
+++ b/bfd/aout-target.h
@@ -577,7 +577,18 @@
 #endif
 
 #ifndef MY_close_and_cleanup
-#define MY_close_and_cleanup MY_bfd_free_cached_info
+
+/* Handle closing of a BFD including the resource-releasing parts.  */
+
+static bfd_boolean
+MY_close_and_cleanup (bfd *abfd)
+{
+  if (!MY_bfd_free_cached_info (abfd))
+    return FALSE;
+
+  return _bfd_generic_close_and_cleanup (abfd);
+}
+
 #endif
 
 #ifndef MY_get_dynamic_symtab_upper_bound
diff --git a/bfd/aout-tic30.c b/bfd/aout-tic30.c
index 0b01177..d8ce9be 100644
--- a/bfd/aout-tic30.c
+++ b/bfd/aout-tic30.c
@@ -1,6 +1,6 @@
 /* BFD back-end for TMS320C30 a.out binaries.
    Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2009,
-   2010, 2011
+   2010, 2011, 2012
    Free Software Foundation, Inc.
    Contributed by Steven Haworth ([email protected])
 
@@ -189,7 +189,7 @@
   bfd_vma relocation;
 
   /* Make sure that the symbol's section is defined.  */
-  if (symbol->section == &bfd_und_section && (symbol->flags & BSF_WEAK) == 0)
+  if (bfd_is_und_section (symbol->section) && (symbol->flags & BSF_WEAK) == 0)
     return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined;
   /* Get the size of the input section and turn it into the TMS320C30
      32-bit address format.  */
@@ -214,7 +214,7 @@
   bfd_vma relocation;
 
   /* Make sure that the symbol's section is defined.  */
-  if (symbol->section == &bfd_und_section && (symbol->flags & BSF_WEAK) == 0)
+  if (bfd_is_und_section (symbol->section) && (symbol->flags & BSF_WEAK) == 0)
     return output_bfd ? bfd_reloc_ok : bfd_reloc_undefined;
   /* Get the size of the input section and turn it into the TMS320C30
      32-bit address format.  */
@@ -701,7 +701,7 @@
 
   *ptreloff = obj_datasec (abfd)->filepos + execp->a_data;
   *pdreloff = *ptreloff + execp->a_trsize;
-  *psymoff = *pdreloff + execp->a_drsize;;
+  *psymoff = *pdreloff + execp->a_drsize;
 }
 
 #endif
diff --git a/bfd/aout0.c b/bfd/aout0.c
index e87af00..be73fa0 100644
--- a/bfd/aout0.c
+++ b/bfd/aout0.c
@@ -1,10 +1,10 @@
 /* BFD backend for SunOS style a.out with flags set to 0
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 2001, 2005, 2007
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 2001, 2005, 2007, 2012
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
-   
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
@@ -27,6 +27,7 @@
    the tokens.  */
 #define MY(OP) CONCAT2 (aout0_big_,OP)
 
+#include "sysdep.h"
 #include "bfd.h"
 
 #define MY_exec_hdr_flags 0
diff --git a/bfd/aoutx.h b/bfd/aoutx.h
index 1efb715..1e0ad38 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -3554,7 +3554,7 @@
 aout_link_write_other_symbol (struct bfd_hash_entry *bh, void *data)
 {
   struct aout_link_hash_entry *h = (struct aout_link_hash_entry *) bh;
-  struct aout_final_link_info *finfo = (struct aout_final_link_info *) data;
+  struct aout_final_link_info *flaginfo = (struct aout_final_link_info *) data;
   bfd *output_bfd;
   int type;
   bfd_vma val;
@@ -3569,12 +3569,12 @@
 	return TRUE;
     }
 
-  output_bfd = finfo->output_bfd;
+  output_bfd = flaginfo->output_bfd;
 
   if (aout_backend_info (output_bfd)->write_dynamic_symbol != NULL)
     {
       if (! ((*aout_backend_info (output_bfd)->write_dynamic_symbol)
-	     (output_bfd, finfo->info, h)))
+	     (output_bfd, flaginfo->info, h)))
 	{
 	  /* FIXME: No way to handle errors.  */
 	  abort ();
@@ -3588,9 +3588,9 @@
 
   /* An indx of -2 means the symbol must be written.  */
   if (h->indx != -2
-      && (finfo->info->strip == strip_all
-	  || (finfo->info->strip == strip_some
-	      && bfd_hash_lookup (finfo->info->keep_hash, h->root.root.string,
+      && (flaginfo->info->strip == strip_all
+	  || (flaginfo->info->strip == strip_some
+	      && bfd_hash_lookup (flaginfo->info->keep_hash, h->root.root.string,
 				  FALSE, FALSE) == NULL)))
     return TRUE;
 
@@ -3648,7 +3648,7 @@
   H_PUT_8 (output_bfd, type, outsym.e_type);
   H_PUT_8 (output_bfd, 0, outsym.e_other);
   H_PUT_16 (output_bfd, 0, outsym.e_desc);
-  indx = add_to_stringtab (output_bfd, finfo->strtab, h->root.root.string,
+  indx = add_to_stringtab (output_bfd, flaginfo->strtab, h->root.root.string,
 			   FALSE);
   if (indx == - (bfd_size_type) 1)
     /* FIXME: No way to handle errors.  */
@@ -3658,12 +3658,12 @@
   PUT_WORD (output_bfd, val, outsym.e_value);
 
   amt = EXTERNAL_NLIST_SIZE;
-  if (bfd_seek (output_bfd, finfo->symoff, SEEK_SET) != 0
+  if (bfd_seek (output_bfd, flaginfo->symoff, SEEK_SET) != 0
       || bfd_bwrite ((void *) &outsym, amt, output_bfd) != amt)
     /* FIXME: No way to handle errors.  */
     abort ();
 
-  finfo->symoff += EXTERNAL_NLIST_SIZE;
+  flaginfo->symoff += EXTERNAL_NLIST_SIZE;
   h->indx = obj_aout_external_sym_count (output_bfd);
   ++obj_aout_external_sym_count (output_bfd);
 
@@ -3673,7 +3673,7 @@
 /* Handle a link order which is supposed to generate a reloc.  */
 
 static bfd_boolean
-aout_link_reloc_link_order (struct aout_final_link_info *finfo,
+aout_link_reloc_link_order (struct aout_final_link_info *flaginfo,
 			    asection *o,
 			    struct bfd_link_order *p)
 {
@@ -3696,7 +3696,7 @@
 	r_index = N_ABS | N_EXT;
       else
 	{
-	  BFD_ASSERT (pr->u.section->owner == finfo->output_bfd);
+	  BFD_ASSERT (pr->u.section->owner == flaginfo->output_bfd);
 	  r_index = pr->u.section->target_index;
 	}
     }
@@ -3707,7 +3707,7 @@
       BFD_ASSERT (p->type == bfd_symbol_reloc_link_order);
       r_extern = 1;
       h = ((struct aout_link_hash_entry *)
-	   bfd_wrapped_link_hash_lookup (finfo->output_bfd, finfo->info,
+	   bfd_wrapped_link_hash_lookup (flaginfo->output_bfd, flaginfo->info,
 					 pr->u.name, FALSE, FALSE, TRUE));
       if (h != NULL
 	  && h->indx >= 0)
@@ -3720,37 +3720,37 @@
 	     symbol.  */
 	  h->indx = -2;
 	  h->written = FALSE;
-	  if (!aout_link_write_other_symbol (&h->root.root, finfo))
+	  if (!aout_link_write_other_symbol (&h->root.root, flaginfo))
 	    return FALSE;
 	  r_index = h->indx;
 	}
       else
 	{
-	  if (! ((*finfo->info->callbacks->unattached_reloc)
-		 (finfo->info, pr->u.name, NULL, NULL, (bfd_vma) 0)))
+	  if (! ((*flaginfo->info->callbacks->unattached_reloc)
+		 (flaginfo->info, pr->u.name, NULL, NULL, (bfd_vma) 0)))
 	    return FALSE;
 	  r_index = 0;
 	}
     }
 
-  howto = bfd_reloc_type_lookup (finfo->output_bfd, pr->reloc);
+  howto = bfd_reloc_type_lookup (flaginfo->output_bfd, pr->reloc);
   if (howto == 0)
     {
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
     }
 
-  if (o == obj_textsec (finfo->output_bfd))
-    reloff_ptr = &finfo->treloff;
-  else if (o == obj_datasec (finfo->output_bfd))
-    reloff_ptr = &finfo->dreloff;
+  if (o == obj_textsec (flaginfo->output_bfd))
+    reloff_ptr = &flaginfo->treloff;
+  else if (o == obj_datasec (flaginfo->output_bfd))
+    reloff_ptr = &flaginfo->dreloff;
   else
     abort ();
 
-  if (obj_reloc_entry_size (finfo->output_bfd) == RELOC_STD_SIZE)
+  if (obj_reloc_entry_size (flaginfo->output_bfd) == RELOC_STD_SIZE)
     {
 #ifdef MY_put_reloc
-      MY_put_reloc (finfo->output_bfd, r_extern, r_index, p->offset, howto,
+      MY_put_reloc (flaginfo->output_bfd, r_extern, r_index, p->offset, howto,
 		    &srel);
 #else
       {
@@ -3766,8 +3766,8 @@
 	r_relative = (howto->type & 32) != 0;
 	r_length = howto->size;
 
-	PUT_WORD (finfo->output_bfd, p->offset, srel.r_address);
-	if (bfd_header_big_endian (finfo->output_bfd))
+	PUT_WORD (flaginfo->output_bfd, p->offset, srel.r_address);
+	if (bfd_header_big_endian (flaginfo->output_bfd))
 	  {
 	    srel.r_index[0] = r_index >> 16;
 	    srel.r_index[1] = r_index >> 8;
@@ -3813,7 +3813,7 @@
 	  buf = (bfd_byte *) bfd_zmalloc (size);
 	  if (buf == NULL)
 	    return FALSE;
-	  r = MY_relocate_contents (howto, finfo->output_bfd,
+	  r = MY_relocate_contents (howto, flaginfo->output_bfd,
 				    (bfd_vma) pr->addend, buf);
 	  switch (r)
 	    {
@@ -3823,10 +3823,10 @@
 	    case bfd_reloc_outofrange:
 	      abort ();
 	    case bfd_reloc_overflow:
-	      if (! ((*finfo->info->callbacks->reloc_overflow)
-		     (finfo->info, NULL,
+	      if (! ((*flaginfo->info->callbacks->reloc_overflow)
+		     (flaginfo->info, NULL,
 		      (p->type == bfd_section_reloc_link_order
-		       ? bfd_section_name (finfo->output_bfd,
+		       ? bfd_section_name (flaginfo->output_bfd,
 					   pr->u.section)
 		       : pr->u.name),
 		      howto->name, pr->addend, NULL, NULL, (bfd_vma) 0)))
@@ -3836,7 +3836,7 @@
 		}
 	      break;
 	    }
-	  ok = bfd_set_section_contents (finfo->output_bfd, o, (void *) buf,
+	  ok = bfd_set_section_contents (flaginfo->output_bfd, o, (void *) buf,
 					 (file_ptr) p->offset, size);
 	  free (buf);
 	  if (! ok)
@@ -3846,12 +3846,12 @@
   else
     {
 #ifdef MY_put_ext_reloc
-      MY_put_ext_reloc (finfo->output_bfd, r_extern, r_index, p->offset,
+      MY_put_ext_reloc (flaginfo->output_bfd, r_extern, r_index, p->offset,
 			howto, &erel, pr->addend);
 #else
-      PUT_WORD (finfo->output_bfd, p->offset, erel.r_address);
+      PUT_WORD (flaginfo->output_bfd, p->offset, erel.r_address);
 
-      if (bfd_header_big_endian (finfo->output_bfd))
+      if (bfd_header_big_endian (flaginfo->output_bfd))
 	{
 	  erel.r_index[0] = r_index >> 16;
 	  erel.r_index[1] = r_index >> 8;
@@ -3870,25 +3870,25 @@
 	      | (howto->type << RELOC_EXT_BITS_TYPE_SH_LITTLE);
 	}
 
-      PUT_WORD (finfo->output_bfd, (bfd_vma) pr->addend, erel.r_addend);
+      PUT_WORD (flaginfo->output_bfd, (bfd_vma) pr->addend, erel.r_addend);
 #endif /* MY_put_ext_reloc */
 
       rel_ptr = (void *) &erel;
     }
 
-  amt = obj_reloc_entry_size (finfo->output_bfd);
-  if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0
-      || bfd_bwrite (rel_ptr, amt, finfo->output_bfd) != amt)
+  amt = obj_reloc_entry_size (flaginfo->output_bfd);
+  if (bfd_seek (flaginfo->output_bfd, *reloff_ptr, SEEK_SET) != 0
+      || bfd_bwrite (rel_ptr, amt, flaginfo->output_bfd) != amt)
     return FALSE;
 
-  *reloff_ptr += obj_reloc_entry_size (finfo->output_bfd);
+  *reloff_ptr += obj_reloc_entry_size (flaginfo->output_bfd);
 
   /* Assert that the relocs have not run into the symbols, and that n
      the text relocs have not run into the data relocs.  */
-  BFD_ASSERT (*reloff_ptr <= obj_sym_filepos (finfo->output_bfd)
-	      && (reloff_ptr != &finfo->treloff
+  BFD_ASSERT (*reloff_ptr <= obj_sym_filepos (flaginfo->output_bfd)
+	      && (reloff_ptr != &flaginfo->treloff
 		  || (*reloff_ptr
-		      <= obj_datasec (finfo->output_bfd)->rel_filepos)));
+		      <= obj_datasec (flaginfo->output_bfd)->rel_filepos)));
 
   return TRUE;
 }
@@ -3913,7 +3913,7 @@
 /* Relocate an a.out section using standard a.out relocs.  */
 
 static bfd_boolean
-aout_link_input_section_std (struct aout_final_link_info *finfo,
+aout_link_input_section_std (struct aout_final_link_info *flaginfo,
 			     bfd *input_bfd,
 			     asection *input_section,
 			     struct reloc_std_external *relocs,
@@ -3934,18 +3934,18 @@
   struct reloc_std_external *rel;
   struct reloc_std_external *rel_end;
 
-  output_bfd = finfo->output_bfd;
+  output_bfd = flaginfo->output_bfd;
   check_dynamic_reloc = aout_backend_info (output_bfd)->check_dynamic_reloc;
 
   BFD_ASSERT (obj_reloc_entry_size (input_bfd) == RELOC_STD_SIZE);
   BFD_ASSERT (input_bfd->xvec->header_byteorder
 	      == output_bfd->xvec->header_byteorder);
 
-  relocatable = finfo->info->relocatable;
+  relocatable = flaginfo->info->relocatable;
   syms = obj_aout_external_syms (input_bfd);
   strings = obj_aout_external_strings (input_bfd);
   sym_hashes = obj_aout_sym_hashes (input_bfd);
-  symbol_map = finfo->symbol_map;
+  symbol_map = flaginfo->symbol_map;
 
   reloc_count = rel_size / RELOC_STD_SIZE;
   rel = relocs;
@@ -4014,7 +4014,7 @@
 
       if (howto == NULL)
 	{
-	  (*finfo->info->callbacks->einfo)
+	  (*flaginfo->info->callbacks->einfo)
 	    (_("%P: %B: unexpected relocation type\n"), input_bfd);
 	  bfd_set_error (bfd_error_bad_value);
 	  return FALSE;
@@ -4079,7 +4079,7 @@
 			      h->indx = -2;
 			      h->written = FALSE;
 			      if (!aout_link_write_other_symbol (&h->root.root,
-								 finfo))
+								 flaginfo))
 				return FALSE;
 			    }
 			  r_index = h->indx;
@@ -4090,8 +4090,8 @@
 
 			  name = strings + GET_WORD (input_bfd,
 						     syms[r_index].e_strx);
-			  if (! ((*finfo->info->callbacks->unattached_reloc)
-				 (finfo->info, name, input_bfd, input_section,
+			  if (! ((*flaginfo->info->callbacks->unattached_reloc)
+				 (flaginfo->info, name, input_bfd, input_section,
 				  r_addr)))
 			    return FALSE;
 			  r_index = 0;
@@ -4197,7 +4197,7 @@
 	      bfd_boolean skip;
 
 	      if (! ((*check_dynamic_reloc)
-		     (finfo->info, input_bfd, input_section, h,
+		     (flaginfo->info, input_bfd, input_section, h,
 		      (void *) rel, contents, &skip, &relocation)))
 		return FALSE;
 	      if (skip)
@@ -4207,7 +4207,7 @@
 	  /* Now warn if a global symbol is undefined.  We could not
              do this earlier, because check_dynamic_reloc might want
              to skip this reloc.  */
-	  if (hundef && ! finfo->info->shared && ! r_baserel)
+	  if (hundef && ! flaginfo->info->shared && ! r_baserel)
 	    {
 	      const char *name;
 
@@ -4215,8 +4215,8 @@
 		name = h->root.root.string;
 	      else
 		name = strings + GET_WORD (input_bfd, syms[r_index].e_strx);
-	      if (! ((*finfo->info->callbacks->undefined_symbol)
-		     (finfo->info, name, input_bfd, input_section,
+	      if (! ((*flaginfo->info->callbacks->undefined_symbol)
+		     (flaginfo->info, name, input_bfd, input_section,
 		     r_addr, TRUE)))
 		return FALSE;
 	    }
@@ -4250,8 +4250,8 @@
 		    s = aout_reloc_index_to_section (input_bfd, r_index);
 		    name = bfd_section_name (input_bfd, s);
 		  }
-		if (! ((*finfo->info->callbacks->reloc_overflow)
-		       (finfo->info, (h ? &h->root : NULL), name,
+		if (! ((*flaginfo->info->callbacks->reloc_overflow)
+		       (flaginfo->info, (h ? &h->root : NULL), name,
 			howto->name, (bfd_vma) 0, input_bfd,
 			input_section, r_addr)))
 		  return FALSE;
@@ -4267,7 +4267,7 @@
 /* Relocate an a.out section using extended a.out relocs.  */
 
 static bfd_boolean
-aout_link_input_section_ext (struct aout_final_link_info *finfo,
+aout_link_input_section_ext (struct aout_final_link_info *flaginfo,
 			     bfd *input_bfd,
 			     asection *input_section,
 			     struct reloc_ext_external *relocs,
@@ -4288,18 +4288,18 @@
   struct reloc_ext_external *rel;
   struct reloc_ext_external *rel_end;
 
-  output_bfd = finfo->output_bfd;
+  output_bfd = flaginfo->output_bfd;
   check_dynamic_reloc = aout_backend_info (output_bfd)->check_dynamic_reloc;
 
   BFD_ASSERT (obj_reloc_entry_size (input_bfd) == RELOC_EXT_SIZE);
   BFD_ASSERT (input_bfd->xvec->header_byteorder
 	      == output_bfd->xvec->header_byteorder);
 
-  relocatable = finfo->info->relocatable;
+  relocatable = flaginfo->info->relocatable;
   syms = obj_aout_external_syms (input_bfd);
   strings = obj_aout_external_strings (input_bfd);
   sym_hashes = obj_aout_sym_hashes (input_bfd);
-  symbol_map = finfo->symbol_map;
+  symbol_map = flaginfo->symbol_map;
 
   reloc_count = rel_size / RELOC_EXT_SIZE;
   rel = relocs;
@@ -4340,7 +4340,7 @@
 
       if (r_type >= TABLE_SIZE (howto_table_ext))
 	{
-	  (*finfo->info->callbacks->einfo)
+	  (*flaginfo->info->callbacks->einfo)
 	    (_("%P: %B: unexpected relocation type\n"), input_bfd);
 	  bfd_set_error (bfd_error_bad_value);
 	  return FALSE;
@@ -4421,7 +4421,7 @@
 			      h->indx = -2;
 			      h->written = FALSE;
 			      if (!aout_link_write_other_symbol (&h->root.root,
-								 finfo))
+								 flaginfo))
 				return FALSE;
 			    }
 			  r_index = h->indx;
@@ -4432,8 +4432,8 @@
 
 			  name = strings + GET_WORD (input_bfd,
 						     syms[r_index].e_strx);
-			  if (! ((*finfo->info->callbacks->unattached_reloc)
-				 (finfo->info, name, input_bfd, input_section,
+			  if (! ((*flaginfo->info->callbacks->unattached_reloc)
+				 (flaginfo->info, name, input_bfd, input_section,
 				  r_addr)))
 			    return FALSE;
 			  r_index = 0;
@@ -4600,7 +4600,7 @@
 	      bfd_boolean skip;
 
 	      if (! ((*check_dynamic_reloc)
-		     (finfo->info, input_bfd, input_section, h,
+		     (flaginfo->info, input_bfd, input_section, h,
 		      (void *) rel, contents, &skip, &relocation)))
 		return FALSE;
 	      if (skip)
@@ -4611,7 +4611,7 @@
              do this earlier, because check_dynamic_reloc might want
              to skip this reloc.  */
 	  if (hundef
-	      && ! finfo->info->shared
+	      && ! flaginfo->info->shared
 	      && r_type != (unsigned int) RELOC_BASE10
 	      && r_type != (unsigned int) RELOC_BASE13
 	      && r_type != (unsigned int) RELOC_BASE22)
@@ -4622,8 +4622,8 @@
 		name = h->root.root.string;
 	      else
 		name = strings + GET_WORD (input_bfd, syms[r_index].e_strx);
-	      if (! ((*finfo->info->callbacks->undefined_symbol)
-		     (finfo->info, name, input_bfd, input_section,
+	      if (! ((*flaginfo->info->callbacks->undefined_symbol)
+		     (flaginfo->info, name, input_bfd, input_section,
 		     r_addr, TRUE)))
 		return FALSE;
 	    }
@@ -4669,8 +4669,8 @@
 			s = aout_reloc_index_to_section (input_bfd, r_index);
 			name = bfd_section_name (input_bfd, s);
 		      }
-		    if (! ((*finfo->info->callbacks->reloc_overflow)
-			   (finfo->info, (h ? &h->root : NULL), name,
+		    if (! ((*flaginfo->info->callbacks->reloc_overflow)
+			   (flaginfo->info, (h ? &h->root : NULL), name,
 			    howto_table_ext[r_type].name,
 			    r_addend, input_bfd, input_section, r_addr)))
 		      return FALSE;
@@ -4687,7 +4687,7 @@
 /* Link an a.out section into the output file.  */
 
 static bfd_boolean
-aout_link_input_section (struct aout_final_link_info *finfo,
+aout_link_input_section (struct aout_final_link_info *flaginfo,
 			 bfd *input_bfd,
 			 asection *input_section,
 			 file_ptr *reloff_ptr,
@@ -4699,7 +4699,7 @@
   /* Get the section contents.  */
   input_size = input_section->size;
   if (! bfd_get_section_contents (input_bfd, input_section,
-				  (void *) finfo->contents,
+				  (void *) flaginfo->contents,
 				  (file_ptr) 0, input_size))
     return FALSE;
 
@@ -4709,7 +4709,7 @@
     relocs = aout_section_data (input_section)->relocs;
   else
     {
-      relocs = finfo->relocs;
+      relocs = flaginfo->relocs;
       if (rel_size > 0)
 	{
 	  if (bfd_seek (input_bfd, input_section->rel_filepos, SEEK_SET) != 0
@@ -4721,44 +4721,44 @@
   /* Relocate the section contents.  */
   if (obj_reloc_entry_size (input_bfd) == RELOC_STD_SIZE)
     {
-      if (! aout_link_input_section_std (finfo, input_bfd, input_section,
+      if (! aout_link_input_section_std (flaginfo, input_bfd, input_section,
 					 (struct reloc_std_external *) relocs,
-					 rel_size, finfo->contents))
+					 rel_size, flaginfo->contents))
 	return FALSE;
     }
   else
     {
-      if (! aout_link_input_section_ext (finfo, input_bfd, input_section,
+      if (! aout_link_input_section_ext (flaginfo, input_bfd, input_section,
 					 (struct reloc_ext_external *) relocs,
-					 rel_size, finfo->contents))
+					 rel_size, flaginfo->contents))
 	return FALSE;
     }
 
   /* Write out the section contents.  */
-  if (! bfd_set_section_contents (finfo->output_bfd,
+  if (! bfd_set_section_contents (flaginfo->output_bfd,
 				  input_section->output_section,
-				  (void *) finfo->contents,
+				  (void *) flaginfo->contents,
 				  (file_ptr) input_section->output_offset,
 				  input_size))
     return FALSE;
 
   /* If we are producing relocatable output, the relocs were
      modified, and we now write them out.  */
-  if (finfo->info->relocatable && rel_size > 0)
+  if (flaginfo->info->relocatable && rel_size > 0)
     {
-      if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0)
+      if (bfd_seek (flaginfo->output_bfd, *reloff_ptr, SEEK_SET) != 0)
 	return FALSE;
-      if (bfd_bwrite (relocs, rel_size, finfo->output_bfd) != rel_size)
+      if (bfd_bwrite (relocs, rel_size, flaginfo->output_bfd) != rel_size)
 	return FALSE;
       *reloff_ptr += rel_size;
 
       /* Assert that the relocs have not run into the symbols, and
 	 that if these are the text relocs they have not run into the
 	 data relocs.  */
-      BFD_ASSERT (*reloff_ptr <= obj_sym_filepos (finfo->output_bfd)
-		  && (reloff_ptr != &finfo->treloff
+      BFD_ASSERT (*reloff_ptr <= obj_sym_filepos (flaginfo->output_bfd)
+		  && (reloff_ptr != &flaginfo->treloff
 		      || (*reloff_ptr
-			  <= obj_datasec (finfo->output_bfd)->rel_filepos)));
+			  <= obj_datasec (flaginfo->output_bfd)->rel_filepos)));
     }
 
   return TRUE;
@@ -4768,7 +4768,7 @@
    symbol indices into a symbol_map.  */
 
 static bfd_boolean
-aout_link_write_symbols (struct aout_final_link_info *finfo, bfd *input_bfd)
+aout_link_write_symbols (struct aout_final_link_info *flaginfo, bfd *input_bfd)
 {
   bfd *output_bfd;
   bfd_size_type sym_count;
@@ -4784,25 +4784,25 @@
   bfd_boolean pass;
   bfd_boolean skip_next;
 
-  output_bfd = finfo->output_bfd;
+  output_bfd = flaginfo->output_bfd;
   sym_count = obj_aout_external_sym_count (input_bfd);
   strings = obj_aout_external_strings (input_bfd);
-  strip = finfo->info->strip;
-  discard = finfo->info->discard;
-  outsym = finfo->output_syms;
+  strip = flaginfo->info->strip;
+  discard = flaginfo->info->discard;
+  outsym = flaginfo->output_syms;
 
   /* First write out a symbol for this object file, unless we are
      discarding such symbols.  */
   if (strip != strip_all
       && (strip != strip_some
-	  || bfd_hash_lookup (finfo->info->keep_hash, input_bfd->filename,
+	  || bfd_hash_lookup (flaginfo->info->keep_hash, input_bfd->filename,
 			      FALSE, FALSE) != NULL)
       && discard != discard_all)
     {
       H_PUT_8 (output_bfd, N_TEXT, outsym->e_type);
       H_PUT_8 (output_bfd, 0, outsym->e_other);
       H_PUT_16 (output_bfd, 0, outsym->e_desc);
-      strtab_index = add_to_stringtab (output_bfd, finfo->strtab,
+      strtab_index = add_to_stringtab (output_bfd, flaginfo->strtab,
 				       input_bfd->filename, FALSE);
       if (strtab_index == (bfd_size_type) -1)
 	return FALSE;
@@ -4821,7 +4821,7 @@
   sym = obj_aout_external_syms (input_bfd);
   sym_end = sym + sym_count;
   sym_hash = obj_aout_sym_hashes (input_bfd);
-  symbol_map = finfo->symbol_map;
+  symbol_map = flaginfo->symbol_map;
   memset (symbol_map, 0, (size_t) sym_count * sizeof *symbol_map);
   for (; sym < sym_end; sym++, sym_hash++, symbol_map++)
     {
@@ -4920,7 +4920,7 @@
 		skip = TRUE;
 	      break;
 	    case strip_some:
-	      if (bfd_hash_lookup (finfo->info->keep_hash, name, FALSE, FALSE)
+	      if (bfd_hash_lookup (flaginfo->info->keep_hash, name, FALSE, FALSE)
 		  == NULL)
 		skip = TRUE;
 	      break;
@@ -5148,8 +5148,8 @@
 	      /* If we have already included a header file with the
                  same value, then replace this one with an N_EXCL
                  symbol.  */
-	      copy = (bfd_boolean) (! finfo->info->keep_memory);
-	      incl_entry = aout_link_includes_lookup (&finfo->includes,
+	      copy = (bfd_boolean) (! flaginfo->info->keep_memory);
+	      incl_entry = aout_link_includes_lookup (&flaginfo->includes,
 						      name, TRUE, copy);
 	      if (incl_entry == NULL)
 		return FALSE;
@@ -5161,7 +5161,7 @@
 		  /* This is the first time we have seen this header
                      file with this set of stabs strings.  */
 		  t = (struct aout_link_includes_totals *)
-                      bfd_hash_allocate (&finfo->includes.root,
+                      bfd_hash_allocate (&flaginfo->includes.root,
 					 sizeof *t);
 		  if (t == NULL)
 		    return FALSE;
@@ -5210,7 +5210,7 @@
       H_PUT_8 (output_bfd, H_GET_8 (input_bfd, sym->e_other), outsym->e_other);
       H_PUT_16 (output_bfd, H_GET_16 (input_bfd, sym->e_desc), outsym->e_desc);
       copy = FALSE;
-      if (! finfo->info->keep_memory)
+      if (! flaginfo->info->keep_memory)
 	{
 	  /* name points into a string table which we are going to
 	     free.  If there is a hash table entry, use that string.
@@ -5220,7 +5220,7 @@
 	  else
 	    copy = TRUE;
 	}
-      strtab_index = add_to_stringtab (output_bfd, finfo->strtab,
+      strtab_index = add_to_stringtab (output_bfd, flaginfo->strtab,
 				       name, copy);
       if (strtab_index == (bfd_size_type) -1)
 	return FALSE;
@@ -5232,18 +5232,18 @@
     }
 
   /* Write out the output symbols we have just constructed.  */
-  if (outsym > finfo->output_syms)
+  if (outsym > flaginfo->output_syms)
     {
       bfd_size_type outsym_size;
 
-      if (bfd_seek (output_bfd, finfo->symoff, SEEK_SET) != 0)
+      if (bfd_seek (output_bfd, flaginfo->symoff, SEEK_SET) != 0)
 	return FALSE;
-      outsym_size = outsym - finfo->output_syms;
+      outsym_size = outsym - flaginfo->output_syms;
       outsym_size *= EXTERNAL_NLIST_SIZE;
-      if (bfd_bwrite ((void *) finfo->output_syms, outsym_size, output_bfd)
+      if (bfd_bwrite ((void *) flaginfo->output_syms, outsym_size, output_bfd)
 	  != outsym_size)
 	return FALSE;
-      finfo->symoff += outsym_size;
+      flaginfo->symoff += outsym_size;
     }
 
   return TRUE;
@@ -5252,7 +5252,7 @@
 /* Link an a.out input BFD into the output file.  */
 
 static bfd_boolean
-aout_link_input_bfd (struct aout_final_link_info *finfo, bfd *input_bfd)
+aout_link_input_bfd (struct aout_final_link_info *flaginfo, bfd *input_bfd)
 {
   BFD_ASSERT (bfd_get_format (input_bfd) == bfd_object);
 
@@ -5260,16 +5260,16 @@
   if ((input_bfd->flags & DYNAMIC) != 0
       && aout_backend_info (input_bfd)->link_dynamic_object != NULL)
     return ((*aout_backend_info (input_bfd)->link_dynamic_object)
-	    (finfo->info, input_bfd));
+	    (flaginfo->info, input_bfd));
 
   /* Get the symbols.  We probably have them already, unless
-     finfo->info->keep_memory is FALSE.  */
+     flaginfo->info->keep_memory is FALSE.  */
   if (! aout_get_external_symbols (input_bfd))
     return FALSE;
 
   /* Write out the symbols and get a map of the new indices.  The map
-     is placed into finfo->symbol_map.  */
-  if (! aout_link_write_symbols (finfo, input_bfd))
+     is placed into flaginfo->symbol_map.  */
+  if (! aout_link_write_symbols (flaginfo, input_bfd))
     return FALSE;
 
   /* Relocate and write out the sections.  These functions use the
@@ -5278,17 +5278,17 @@
      link, which will normally be the case.  */
   if (obj_textsec (input_bfd)->linker_mark)
     {
-      if (! aout_link_input_section (finfo, input_bfd,
+      if (! aout_link_input_section (flaginfo, input_bfd,
 				     obj_textsec (input_bfd),
-				     &finfo->treloff,
+				     &flaginfo->treloff,
 				     exec_hdr (input_bfd)->a_trsize))
 	return FALSE;
     }
   if (obj_datasec (input_bfd)->linker_mark)
     {
-      if (! aout_link_input_section (finfo, input_bfd,
+      if (! aout_link_input_section (flaginfo, input_bfd,
 				     obj_datasec (input_bfd),
-				     &finfo->dreloff,
+				     &flaginfo->dreloff,
 				     exec_hdr (input_bfd)->a_drsize))
 	return FALSE;
     }
@@ -5296,7 +5296,7 @@
   /* If we are not keeping memory, we don't need the symbols any
      longer.  We still need them if we are keeping memory, because the
      strings in the hash table point into them.  */
-  if (! finfo->info->keep_memory)
+  if (! flaginfo->info->keep_memory)
     {
       if (! aout_link_free_symbols (input_bfd))
 	return FALSE;
diff --git a/bfd/archive.c b/bfd/archive.c
index 3e333c7..32b07a7 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -1,7 +1,5 @@
 /* BFD back-end for archive files (libraries).
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright 1990-2013 Free Software Foundation, Inc.
    Written by Cygnus Support.  Mostly Gumby Henkel-Wallace's fault.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -42,11 +40,17 @@
 	have to read the entire archive if you don't want
 	to!  Read it until you find what you want.
 
+	A BFD returned by <<bfd_openr_next_archived_file>> can be
+	closed manually with <<bfd_close>>.  If you do not close it,
+	then a second iteration through the members of an archive may
+	return the same BFD.  If you close the archive BFD, then all
+	the member BFDs will automatically be closed as well.
+
 	Archive contents of output BFDs are chained through the
-	<<next>> pointer in a BFD.  The first one is findable through
-	the <<archive_head>> slot of the archive.  Set it with
-	<<bfd_set_archive_head>> (q.v.).  A given BFD may be in only one
-	open output archive at a time.
+	<<archive_next>> pointer in a BFD.  The first one is findable
+	through the <<archive_head>> slot of the archive.  Set it with
+	<<bfd_set_archive_head>> (q.v.).  A given BFD may be in only
+	one open output archive at a time.
 
 	As expected, the BFD archive code is more general than the
 	archive code of any given environment.  BFD archives may
@@ -147,7 +151,8 @@
    it's generally short enough to search linearly.
    Note that the pointers here point to the front of the ar_hdr, not
    to the front of the contents!  */
-struct ar_cache {
+struct ar_cache
+{
   file_ptr ptr;
   bfd *arbfd;
 };
@@ -168,6 +173,7 @@
 {
   static char buf[20];
   size_t len;
+
   snprintf (buf, sizeof (buf), fmt, val);
   len = strlen (buf);
   if (len < n)
@@ -178,6 +184,29 @@
   else
     memcpy (p, buf, n);
 }
+
+bfd_boolean
+_bfd_ar_sizepad (char *p, size_t n, bfd_size_type size)
+{
+  static char buf[21];
+  size_t len;
+
+  snprintf (buf, sizeof (buf), "%-10" BFD_VMA_FMT "u", size);
+  len = strlen (buf);
+  if (len > n)
+    {
+      bfd_set_error (bfd_error_file_too_big);
+      return FALSE;
+    }
+  if (len < n)
+    {
+      memcpy (p, buf, len);
+      memset (p + len, ' ', n - len);
+    }
+  else
+    memcpy (p, buf, n);
+  return TRUE;
+}
 
 bfd_boolean
 _bfd_generic_mkarchive (bfd *abfd)
@@ -273,6 +302,7 @@
 {
   htab_t hash_table = bfd_ardata (arch_bfd)->cache;
   struct ar_cache m;
+
   m.ptr = filepos;
 
   if (hash_table)
@@ -288,7 +318,7 @@
 }
 
 static hashval_t
-hash_file_ptr (const PTR p)
+hash_file_ptr (const void * p)
 {
   return (hashval_t) (((struct ar_cache *) p)->ptr);
 }
@@ -296,7 +326,7 @@
 /* Returns non-zero if P1 and P2 are equal.  */
 
 static int
-eq_file_ptr (const PTR p1, const PTR p2)
+eq_file_ptr (const void * p1, const void * p2)
 {
   struct ar_cache *arc1 = (struct ar_cache *) p1;
   struct ar_cache *arc2 = (struct ar_cache *) p2;
@@ -336,6 +366,10 @@
   cache->arbfd = new_elt;
   *htab_find_slot (hash_table, (const void *) cache, INSERT) = cache;
 
+  /* Provide a means of accessing this from child.  */
+  arch_eltdata (new_elt)->parent_cache = hash_table;
+  arch_eltdata (new_elt)->key = filepos;
+
   return TRUE;
 }
 
@@ -345,12 +379,19 @@
   bfd *abfd;
   const char *target;
 
+  /* PR 15140: Don't allow a nested archive pointing to itself.  */
+  if (filename_cmp (filename, arch_bfd->filename) == 0)
+    {
+      bfd_set_error (bfd_error_malformed_archive);
+      return NULL;
+    }
+
   for (abfd = arch_bfd->nested_archives;
        abfd != NULL;
        abfd = abfd->archive_next)
     {
       if (filename_cmp (filename, abfd->filename) == 0)
-        return abfd;
+	return abfd;
     }
   target = NULL;
   if (!arch_bfd->target_defaulted)
@@ -390,10 +431,10 @@
       file_ptr origin = strtol (endp + 1, NULL, 10);
 
       if (errno != 0)
-        {
-          bfd_set_error (bfd_error_malformed_archive);
-          return NULL;
-        }
+	{
+	  bfd_set_error (bfd_error_malformed_archive);
+	  return NULL;
+	}
       *originp = origin;
     }
   else
@@ -424,7 +465,7 @@
 {
   struct ar_hdr hdr;
   char *hdrp = (char *) &hdr;
-  size_t parsed_size;
+  bfd_size_type parsed_size;
   struct areltdata *ared;
   char *filename = NULL;
   bfd_size_type namelen = 0;
@@ -432,6 +473,8 @@
   char *allocptr = 0;
   file_ptr origin = 0;
   unsigned int extra_size = 0;
+  char fmag_save;
+  int scan;
 
   if (bfd_bread (hdrp, sizeof (struct ar_hdr), abfd) != sizeof (struct ar_hdr))
     {
@@ -448,8 +491,11 @@
     }
 
   errno = 0;
-  parsed_size = strtol (hdr.ar_size, NULL, 10);
-  if (errno != 0)
+  fmag_save = hdr.ar_fmag[0];
+  hdr.ar_fmag[0] = 0;
+  scan = sscanf (hdr.ar_size, "%" BFD_VMA_FMT "u", &parsed_size);
+  hdr.ar_fmag[0] = fmag_save;
+  if (scan != 1)
     {
       bfd_set_error (bfd_error_malformed_archive);
       return NULL;
@@ -476,7 +522,7 @@
       parsed_size -= namelen;
       extra_size = namelen;
 
-      allocptr = (char *) bfd_zalloc (abfd, allocsize);
+      allocptr = (char *) bfd_zmalloc (allocsize);
       if (allocptr == NULL)
 	return NULL;
       filename = (allocptr
@@ -484,6 +530,7 @@
 		  + sizeof (struct ar_hdr));
       if (bfd_bread (filename, namelen, abfd) != namelen)
 	{
+	  free (allocptr);
 	  if (bfd_get_error () != bfd_error_system_call)
 	    bfd_set_error (bfd_error_no_more_archived_files);
 	  return NULL;
@@ -519,7 +566,7 @@
 
   if (!allocptr)
     {
-      allocptr = (char *) bfd_zalloc (abfd, allocsize);
+      allocptr = (char *) bfd_zmalloc (allocsize);
       if (allocptr == NULL)
 	return NULL;
     }
@@ -581,12 +628,6 @@
   bfd *n_nfd;
   char *filename;
 
-  if (archive->my_archive)
-    {
-      filepos += archive->origin;
-      archive = archive->my_archive;
-    }
-
   n_nfd = _bfd_look_for_bfd_in_cache (archive, filepos);
   if (n_nfd)
     return n_nfd;
@@ -605,35 +646,38 @@
 
       /* This is a proxy entry for an external file.  */
       if (! IS_ABSOLUTE_PATH (filename))
-        {
-          filename = _bfd_append_relative_path (archive, filename);
-          if (filename == NULL)
-            return NULL;
-        }
+	{
+	  filename = _bfd_append_relative_path (archive, filename);
+	  if (filename == NULL)
+	    {
+	      free (new_areldata);
+	      return NULL;
+	    }
+	}
 
       if (new_areldata->origin > 0)
-        {
-          /* This proxy entry refers to an element of a nested archive.
-             Locate the member of that archive and return a bfd for it.  */
-          bfd *ext_arch = _bfd_find_nested_archive (archive, filename);
+	{
+	  /* This proxy entry refers to an element of a nested archive.
+	     Locate the member of that archive and return a bfd for it.  */
+	  bfd *ext_arch = _bfd_find_nested_archive (archive, filename);
 
-          if (ext_arch == NULL
-              || ! bfd_check_format (ext_arch, bfd_archive))
-            {
-              bfd_release (archive, new_areldata);
-              return NULL;
-            }
-          n_nfd = _bfd_get_elt_at_filepos (ext_arch, new_areldata->origin);
-          if (n_nfd == NULL)
-            {
-              bfd_release (archive, new_areldata);
-              return NULL;
-            }
-          n_nfd->proxy_origin = bfd_tell (archive);
-          return n_nfd;
-        }
+	  if (ext_arch == NULL
+	      || ! bfd_check_format (ext_arch, bfd_archive))
+	    {
+	      free (new_areldata);
+	      return NULL;
+	    }
+	  n_nfd = _bfd_get_elt_at_filepos (ext_arch, new_areldata->origin);
+	  if (n_nfd == NULL)
+	    {
+	      free (new_areldata);
+	      return NULL;
+	    }
+	  n_nfd->proxy_origin = bfd_tell (archive);
+	  return n_nfd;
+	}
       /* It's not an element of a nested archive;
-         open the external file as a bfd.  */
+	 open the external file as a bfd.  */
       target = NULL;
       if (!archive->target_defaulted)
 	target = archive->xvec->name;
@@ -648,7 +692,7 @@
 
   if (n_nfd == NULL)
     {
-      bfd_release (archive, new_areldata);
+      free (new_areldata);
       return NULL;
     }
 
@@ -672,7 +716,8 @@
   if (_bfd_add_bfd_to_archive_cache (archive, filepos, n_nfd))
     return n_nfd;
 
-  bfd_release (archive, new_areldata);
+  free (new_areldata);
+  n_nfd->arelt_data = NULL;
   return NULL;
 }
 
@@ -727,13 +772,11 @@
     filestart = bfd_ardata (archive)->first_file_filepos;
   else
     {
-      unsigned int size = arelt_size (last_file);
+      bfd_size_type size = arelt_size (last_file);
 
       filestart = last_file->proxy_origin;
       if (! bfd_is_thin_archive (archive))
-        filestart += size;
-      if (archive->my_archive)
-	filestart -= archive->origin;
+	filestart += size;
       /* Pad to an even boundary...
 	 Note that last_file->origin can be odd in the case of
 	 BSD-4.4-style element with a long odd size.  */
@@ -814,11 +857,7 @@
 	  first->target_defaulted = FALSE;
 	  if (bfd_check_format (first, bfd_object)
 	      && first->xvec != abfd->xvec)
-	    {
-	      bfd_set_error (bfd_error_wrong_object_format);
-	      bfd_ardata (abfd) = tdata_hold;
-	      return NULL;
-	    }
+	    bfd_set_error (bfd_error_wrong_object_format);
 	  /* And we ought to close `first' here too.  */
 	}
     }
@@ -861,7 +900,7 @@
   if (mapdata == NULL)
     return FALSE;
   parsed_size = mapdata->parsed_size;
-  bfd_release (abfd, mapdata);	/* Don't need it any more.  */
+  free (mapdata);
 
   raw_armap = (bfd_byte *) bfd_zalloc (abfd, parsed_size);
   if (raw_armap == NULL)
@@ -925,7 +964,7 @@
   struct artdata *ardata = bfd_ardata (abfd);
   char *stringbase;
   bfd_size_type stringsize;
-  unsigned int parsed_size;
+  bfd_size_type parsed_size;
   carsym *carsyms;
   bfd_size_type nsymz;		/* Number of symbols in armap.  */
   bfd_vma (*swap) (const void *);
@@ -937,7 +976,7 @@
   if (mapdata == NULL)
     return FALSE;
   parsed_size = mapdata->parsed_size;
-  bfd_release (abfd, mapdata);	/* Don't need it any more.  */
+  free (mapdata);
 
   if (bfd_bread (int_buf, 4, abfd) != 4)
     {
@@ -979,7 +1018,7 @@
     return FALSE;
 
   ardata->symdefs = (struct carsym *) bfd_zalloc (abfd,
-                                                  carsym_size + stringsize + 1);
+						  carsym_size + stringsize + 1);
   if (ardata->symdefs == NULL)
     return FALSE;
   carsyms = ardata->symdefs;
@@ -1030,7 +1069,7 @@
 	    ardata->first_file_filepos +=
 	      (tmp->parsed_size + sizeof (struct ar_hdr) + 1) & ~(unsigned) 1;
 	  }
-	bfd_release (abfd, tmp);
+	free (tmp);
       }
   }
 
@@ -1079,21 +1118,21 @@
   else if (CONST_STRNEQ (nextname, "#1/20           "))
     {
       /* Mach-O has a special name for armap when the map is sorted by name.
-         However because this name has a space it is slightly more difficult
-         to check it.  */
+	 However because this name has a space it is slightly more difficult
+	 to check it.  */
       struct ar_hdr hdr;
       char extname[21];
 
       if (bfd_bread (&hdr, sizeof (hdr), abfd) != sizeof (hdr))
-        return FALSE;
+	return FALSE;
       /* Read the extended name.  We know its length.  */
       if (bfd_bread (extname, 20, abfd) != 20)
-        return FALSE;
-      if (bfd_seek (abfd, (file_ptr) -(sizeof (hdr) + 20), SEEK_CUR) != 0)
-        return FALSE;
+	return FALSE;
+      if (bfd_seek (abfd, -(file_ptr) (sizeof (hdr) + 20), SEEK_CUR) != 0)
+	return FALSE;
       if (CONST_STRNEQ (extname, "__.SYMDEF SORTED")
-          || CONST_STRNEQ (extname, "__.SYMDEF"))
-        return do_slurp_bsd_armap (abfd);
+	  || CONST_STRNEQ (extname, "__.SYMDEF"))
+	return do_slurp_bsd_armap (abfd);
     }
 
   bfd_has_map (abfd) = FALSE;
@@ -1147,15 +1186,17 @@
 
   if (mapdata->parsed_size < HPUX_SYMDEF_COUNT_SIZE + BSD_STRING_COUNT_SIZE)
     {
+      free (mapdata);
     wrong_format:
       bfd_set_error (bfd_error_wrong_format);
     byebye:
-      bfd_release (abfd, mapdata);
       return FALSE;
     }
   left = mapdata->parsed_size - HPUX_SYMDEF_COUNT_SIZE - BSD_STRING_COUNT_SIZE;
 
   amt = mapdata->parsed_size;
+  free (mapdata);
+
   raw_armap = (bfd_byte *) bfd_zalloc (abfd, amt);
   if (raw_armap == NULL)
     goto byebye;
@@ -1250,14 +1291,14 @@
 
       amt = namedata->parsed_size;
       if (amt + 1 == 0)
-        goto byebye;
+	goto byebye;
 
       bfd_ardata (abfd)->extended_names_size = amt;
       bfd_ardata (abfd)->extended_names = (char *) bfd_zalloc (abfd, amt + 1);
       if (bfd_ardata (abfd)->extended_names == NULL)
 	{
 	byebye:
-	  bfd_release (abfd, namedata);
+	  free (namedata);
 	  return FALSE;
 	}
 
@@ -1276,7 +1317,7 @@
 	 trailing '/'.  DOS/NT created archive often have \ in them
 	 We'll fix all problems here..  */
       {
-        char *ext_names = bfd_ardata (abfd)->extended_names;
+	char *ext_names = bfd_ardata (abfd)->extended_names;
 	char *temp = ext_names;
 	char *limit = temp + namedata->parsed_size;
 	for (; temp < limit; ++temp)
@@ -1294,8 +1335,7 @@
       bfd_ardata (abfd)->first_file_filepos +=
 	(bfd_ardata (abfd)->first_file_filepos) % 2;
 
-      /* FIXME, we can't release namedata here because it was allocated
-	 below extended_names on the objalloc...  */
+      free (namedata);
     }
   return TRUE;
 }
@@ -1366,7 +1406,7 @@
    the autogenerated bfd.h header...
 
    Note - the string is returned in a static buffer.  */
-   
+
 static const char *
 adjust_relative_path (const char * path, const char * ref_path)
 {
@@ -1389,7 +1429,7 @@
 
   rpath = lrealpath (ref_path);
   refp = rpath == NULL ? ref_path : rpath;
- 
+
   /* Remove common leading path elements.  */
   for (;;)
     {
@@ -1415,7 +1455,7 @@
       {
 	/* PR 12710:  If the path element is "../" then instead of
 	   inserting "../" we need to insert the name of the directory
-	   at the current level.  */	
+	   at the current level.  */
 	if (refp > ref_path + 1
 	    && refp[-1] == '.'
 	    && refp[-2] == '.')
@@ -1426,7 +1466,7 @@
 
   /* If the lrealpath calls above succeeded then we should never
      see dir_up and dir_down both being non-zero.  */
-  
+
   len += 3 * dir_up;
 
   if (dir_down)
@@ -1531,40 +1571,40 @@
       unsigned int thislen;
 
       if (bfd_is_thin_archive (abfd))
-        {
-          const char *filename = current->filename;
+	{
+	  const char *filename = current->filename;
 
-          /* If the element being added is a member of another archive
-             (i.e., we are flattening), use the containing archive's name.  */
-          if (current->my_archive
-              && ! bfd_is_thin_archive (current->my_archive))
-            filename = current->my_archive->filename;
+	  /* If the element being added is a member of another archive
+	     (i.e., we are flattening), use the containing archive's name.  */
+	  if (current->my_archive
+	      && ! bfd_is_thin_archive (current->my_archive))
+	    filename = current->my_archive->filename;
 
-          /* If the path is the same as the previous path seen,
-             reuse it.  This can happen when flattening a thin
-             archive that contains other archives.  */
-          if (last_filename && filename_cmp (last_filename, filename) == 0)
-            continue;
+	  /* If the path is the same as the previous path seen,
+	     reuse it.  This can happen when flattening a thin
+	     archive that contains other archives.  */
+	  if (last_filename && filename_cmp (last_filename, filename) == 0)
+	    continue;
 
-          last_filename = filename;
+	  last_filename = filename;
 
-          /* If the path is relative, adjust it relative to
-             the containing archive. */
-          if (! IS_ABSOLUTE_PATH (filename)
-              && ! IS_ABSOLUTE_PATH (abfd->filename))
-            normal = adjust_relative_path (filename, abfd->filename);
-          else
-            normal = filename;
+	  /* If the path is relative, adjust it relative to
+	     the containing archive. */
+	  if (! IS_ABSOLUTE_PATH (filename)
+	      && ! IS_ABSOLUTE_PATH (abfd->filename))
+	    normal = adjust_relative_path (filename, abfd->filename);
+	  else
+	    normal = filename;
 
-          /* In a thin archive, always store the full pathname
-             in the extended name table.  */
-          total_namelen += strlen (normal) + 1;
+	  /* In a thin archive, always store the full pathname
+	     in the extended name table.  */
+	  total_namelen += strlen (normal) + 1;
 	  if (trailing_slash)
 	    /* Leave room for trailing slash.  */
 	    ++total_namelen;
 
-          continue;
-        }
+	  continue;
+	}
 
       normal = normalize (current, current->filename);
       if (normal == NULL)
@@ -1594,7 +1634,7 @@
 		  && hdr->ar_name[thislen] != ar_padchar (current)))
 	    {
 	      /* Must have been using extended format even though it
-	         didn't need to.  Fix it to use normal format.  */
+		 didn't need to.  Fix it to use normal format.  */
 	      memcpy (hdr->ar_name, normal, thislen);
 	      if (thislen < maxname
 		  || (thislen == maxname && thislen < sizeof hdr->ar_name))
@@ -1626,31 +1666,31 @@
       const char *filename = current->filename;
 
       if (bfd_is_thin_archive (abfd))
-        {
-          /* If the element being added is a member of another archive
-             (i.e., we are flattening), use the containing archive's name.  */
-          if (current->my_archive
-              && ! bfd_is_thin_archive (current->my_archive))
-            filename = current->my_archive->filename;
-          /* If the path is the same as the previous path seen,
-             reuse it.  This can happen when flattening a thin
-             archive that contains other archives.
-             If the path is relative, adjust it relative to
-             the containing archive.  */
-          if (last_filename && filename_cmp (last_filename, filename) == 0)
-            normal = last_filename;
-          else if (! IS_ABSOLUTE_PATH (filename)
-                   && ! IS_ABSOLUTE_PATH (abfd->filename))
-            normal = adjust_relative_path (filename, abfd->filename);
-          else
-            normal = filename;
-        }
+	{
+	  /* If the element being added is a member of another archive
+	     (i.e., we are flattening), use the containing archive's name.  */
+	  if (current->my_archive
+	      && ! bfd_is_thin_archive (current->my_archive))
+	    filename = current->my_archive->filename;
+	  /* If the path is the same as the previous path seen,
+	     reuse it.  This can happen when flattening a thin
+	     archive that contains other archives.
+	     If the path is relative, adjust it relative to
+	     the containing archive.  */
+	  if (last_filename && filename_cmp (last_filename, filename) == 0)
+	    normal = last_filename;
+	  else if (! IS_ABSOLUTE_PATH (filename)
+		   && ! IS_ABSOLUTE_PATH (abfd->filename))
+	    normal = adjust_relative_path (filename, abfd->filename);
+	  else
+	    normal = filename;
+	}
       else
-        {
-          normal = normalize (current, filename);
-          if (normal == NULL)
-            return FALSE;
-        }
+	{
+	  normal = normalize (current, filename);
+	  if (normal == NULL)
+	    return FALSE;
+	}
 
       thislen = strlen (normal);
       if (thislen > maxname || bfd_is_thin_archive (abfd))
@@ -1661,16 +1701,16 @@
 	  struct ar_hdr *hdr = arch_hdr (current);
 	  if (normal == last_filename)
 	    stroff = last_stroff;
-          else
-            {
+	  else
+	    {
 	      strcpy (strptr, normal);
 	      if (! trailing_slash)
-	        strptr[thislen] = ARFMAG[1];
+		strptr[thislen] = ARFMAG[1];
 	      else
-	        {
-	          strptr[thislen] = '/';
-	          strptr[thislen + 1] = ARFMAG[1];
-	        }
+		{
+		  strptr[thislen] = '/';
+		  strptr[thislen + 1] = ARFMAG[1];
+		}
 	      stroff = strptr - *tabloc;
 	      last_stroff = stroff;
 	    }
@@ -1678,19 +1718,19 @@
 	  if (bfd_is_thin_archive (abfd) && current->origin > 0)
 	    {
 	      int len = snprintf (hdr->ar_name + 1, maxname - 1, "%-ld:",
-	                          stroff);
+				  stroff);
 	      _bfd_ar_spacepad (hdr->ar_name + 1 + len, maxname - 1 - len,
-                                "%-ld",
-                                current->origin - sizeof (struct ar_hdr));
+				"%-ld",
+				current->origin - sizeof (struct ar_hdr));
 	    }
 	  else
-            _bfd_ar_spacepad (hdr->ar_name + 1, maxname - 1, "%-ld", stroff);
-          if (normal != last_filename)
-            {
+	    _bfd_ar_spacepad (hdr->ar_name + 1, maxname - 1, "%-ld", stroff);
+	  if (normal != last_filename)
+	    {
 	      strptr += thislen + 1;
 	      if (trailing_slash)
-	        ++strptr;
-              last_filename = filename;
+		++strptr;
+	      last_filename = filename;
 	    }
 	}
     }
@@ -1703,9 +1743,9 @@
 
 bfd_boolean
 _bfd_archive_bsd44_construct_extended_name_table (bfd *abfd,
-                                                  char **tabloc,
-                                                  bfd_size_type *tablen,
-                                                  const char **name)
+						  char **tabloc,
+						  bfd_size_type *tablen,
+						  const char **name)
 {
   unsigned int maxname = ar_maxnamelen (abfd);
   bfd *current;
@@ -1726,16 +1766,16 @@
 	return FALSE;
 
       for (len = 0; normal[len]; len++)
-        if (normal[len] == ' ')
-          has_space = 1;
+	if (normal[len] == ' ')
+	  has_space = 1;
 
       if (len > maxname || has_space)
 	{
-          struct ar_hdr *hdr = arch_hdr (current);
+	  struct ar_hdr *hdr = arch_hdr (current);
 
-          len = (len + 3) & ~3;
-          arch_eltdata (current)->extra_size = len;
-          _bfd_ar_spacepad (hdr->ar_name, maxname, "#1/%lu", len);
+	  len = (len + 3) & ~3;
+	  arch_eltdata (current)->extra_size = len;
+	  _bfd_ar_spacepad (hdr->ar_name, maxname, "#1/%lu", len);
 	}
     }
 
@@ -1770,27 +1810,29 @@
 
       BFD_ASSERT (padded_len == arch_eltdata (abfd)->extra_size);
 
-      _bfd_ar_spacepad (hdr->ar_size, sizeof (hdr->ar_size), "%-10ld",
-                        arch_eltdata (abfd)->parsed_size + padded_len);
+      if (!_bfd_ar_sizepad (hdr->ar_size, sizeof (hdr->ar_size),
+			    arch_eltdata (abfd)->parsed_size + padded_len))
+	return FALSE;
 
       if (bfd_bwrite (hdr, sizeof (*hdr), archive) != sizeof (*hdr))
-        return FALSE;
+	return FALSE;
 
       if (bfd_bwrite (fullname, len, archive) != len)
-        return FALSE;
-      if (len & 3)
-        {
-          static const char pad[3] = { 0, 0, 0 };
+	return FALSE;
 
-          len = 4 - (len & 3);
-          if (bfd_bwrite (pad, len, archive) != len)
-            return FALSE;
-        }
+      if (len & 3)
+	{
+	  static const char pad[3] = { 0, 0, 0 };
+
+	  len = 4 - (len & 3);
+	  if (bfd_bwrite (pad, len, archive) != len)
+	    return FALSE;
+	}
     }
   else
     {
       if (bfd_bwrite (hdr, sizeof (*hdr), archive) != sizeof (*hdr))
-        return FALSE;
+	return FALSE;
     }
   return TRUE;
 }
@@ -1861,7 +1903,7 @@
     }
 
   amt = sizeof (struct ar_hdr) + sizeof (struct areltdata);
-  ared = (struct areltdata *) bfd_zalloc (abfd, amt);
+  ared = (struct areltdata *) bfd_zmalloc (amt);
   if (ared == NULL)
     return NULL;
   hdr = (struct ar_hdr *) (((char *) ared) + sizeof (struct areltdata));
@@ -1870,7 +1912,7 @@
   memset (hdr, ' ', sizeof (struct ar_hdr));
 
   _bfd_ar_spacepad (hdr->ar_date, sizeof (hdr->ar_date), "%-12ld",
-                    status.st_mtime);
+		    status.st_mtime);
 #ifdef HPUX_LARGE_AR_IDS
   /* HP has a very "special" way to handle UID/GID's with numeric values
      > 99999.  */
@@ -1879,7 +1921,7 @@
   else
 #endif
     _bfd_ar_spacepad (hdr->ar_uid, sizeof (hdr->ar_uid), "%ld",
-                      status.st_uid);
+		      status.st_uid);
 #ifdef HPUX_LARGE_AR_IDS
   /* HP has a very "special" way to handle UID/GID's with numeric values
      > 99999.  */
@@ -1888,11 +1930,14 @@
   else
 #endif
     _bfd_ar_spacepad (hdr->ar_gid, sizeof (hdr->ar_gid), "%ld",
-                      status.st_gid);
+		      status.st_gid);
   _bfd_ar_spacepad (hdr->ar_mode, sizeof (hdr->ar_mode), "%-8lo",
-                    status.st_mode);
-  _bfd_ar_spacepad (hdr->ar_size, sizeof (hdr->ar_size), "%-10ld",
-                    status.st_size);
+		    status.st_mode);
+  if (!_bfd_ar_sizepad (hdr->ar_size, sizeof (hdr->ar_size), status.st_size))
+    {
+      free (ared);
+      return NULL;
+    }
   memcpy (hdr->ar_fmag, ARFMAG, 2);
   ared->parsed_size = status.st_size;
   ared->arch_header = (char *) hdr;
@@ -2132,8 +2177,9 @@
       memset (&hdr, ' ', sizeof (struct ar_hdr));
       memcpy (hdr.ar_name, ename, strlen (ename));
       /* Round size up to even number in archive header.  */
-      _bfd_ar_spacepad (hdr.ar_size, sizeof (hdr.ar_size), "%-10ld",
-                        (elength + 1) & ~(bfd_size_type) 1);
+      if (!_bfd_ar_sizepad (hdr.ar_size, sizeof (hdr.ar_size),
+			    (elength + 1) & ~(bfd_size_type) 1))
+	return FALSE;
       memcpy (hdr.ar_fmag, ARFMAG, 2);
       if ((bfd_bwrite (&hdr, sizeof (struct ar_hdr), arch)
 	   != sizeof (struct ar_hdr))
@@ -2151,13 +2197,13 @@
        current = current->archive_next)
     {
       char buffer[DEFAULT_BUFFERSIZE];
-      unsigned int remaining = arelt_size (current);
+      bfd_size_type remaining = arelt_size (current);
 
       /* Write ar header.  */
       if (!_bfd_write_ar_hdr (arch, current))
-        return FALSE;
+	return FALSE;
       if (bfd_is_thin_archive (arch))
-        continue;
+	continue;
       if (bfd_seek (current, (file_ptr) 0, SEEK_SET) != 0)
 	goto input_err;
 
@@ -2282,16 +2328,16 @@
 		goto error_return;
 
 	      /* Now map over all the symbols, picking out the ones we
-                 want.  */
+		 want.  */
 	      for (src_count = 0; src_count < symcount; src_count++)
 		{
 		  flagword flags = (syms[src_count])->flags;
 		  asection *sec = syms[src_count]->section;
 
-		  if ((flags & BSF_GLOBAL
-		       || flags & BSF_WEAK
-		       || flags & BSF_INDIRECT
-		       || flags & BSF_GNU_UNIQUE
+		  if (((flags & (BSF_GLOBAL
+				 | BSF_WEAK
+				 | BSF_INDIRECT
+				 | BSF_GNU_UNIQUE)) != 0
 		       || bfd_is_com_section (sec))
 		      && ! bfd_is_und_section (sec))
 		    {
@@ -2316,7 +2362,7 @@
 		      if (map[orl_count].name == NULL)
 			goto error_return;
 		      *(map[orl_count].name) = (char *) bfd_alloc (arch,
-                                                                   namelen + 1);
+								   namelen + 1);
 		      if (*(map[orl_count].name) == NULL)
 			goto error_return;
 		      strcpy (*(map[orl_count].name), syms[src_count]->name);
@@ -2406,10 +2452,11 @@
   bfd_ardata (arch)->armap_datepos = (SARMAG
 				      + offsetof (struct ar_hdr, ar_date[0]));
   _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld",
-                    bfd_ardata (arch)->armap_timestamp);
+		    bfd_ardata (arch)->armap_timestamp);
   _bfd_ar_spacepad (hdr.ar_uid, sizeof (hdr.ar_uid), "%ld", uid);
   _bfd_ar_spacepad (hdr.ar_gid, sizeof (hdr.ar_gid), "%ld", gid);
-  _bfd_ar_spacepad (hdr.ar_size, sizeof (hdr.ar_size), "%-10ld", mapsize);
+  if (!_bfd_ar_sizepad (hdr.ar_size, sizeof (hdr.ar_size), mapsize))
+    return FALSE;
   memcpy (hdr.ar_fmag, ARFMAG, 2);
   if (bfd_bwrite (&hdr, sizeof (struct ar_hdr), arch)
       != sizeof (struct ar_hdr))
@@ -2420,22 +2467,33 @@
 
   for (count = 0; count < orl_count; count++)
     {
+      unsigned int offset;
       bfd_byte buf[BSD_SYMDEF_SIZE];
 
       if (map[count].u.abfd != last_elt)
 	{
 	  do
 	    {
-              struct areltdata *ared = arch_eltdata (current);
+	      struct areltdata *ared = arch_eltdata (current);
 
 	      firstreal += (ared->parsed_size + ared->extra_size
-                            + sizeof (struct ar_hdr));
+			    + sizeof (struct ar_hdr));
 	      firstreal += firstreal % 2;
 	      current = current->archive_next;
 	    }
 	  while (current != map[count].u.abfd);
 	}
 
+      /* The archive file format only has 4 bytes to store the offset
+	 of the member.  Check to make sure that firstreal has not grown
+	 too big.  */
+      offset = (unsigned int) firstreal;
+      if (firstreal != (file_ptr) offset)
+	{
+	  bfd_set_error (bfd_error_file_truncated);
+	  return FALSE;
+	}
+
       last_elt = current;
       H_PUT_32 (arch, map[count].namidx, buf);
       H_PUT_32 (arch, firstreal, buf + BSD_SYMDEF_OFFSET_SIZE);
@@ -2503,7 +2561,7 @@
   /* Prepare an ASCII version suitable for writing.  */
   memset (hdr.ar_date, ' ', sizeof (hdr.ar_date));
   _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld",
-                    bfd_ardata (arch)->armap_timestamp);
+		    bfd_ardata (arch)->armap_timestamp);
 
   /* Write it into the file.  */
   bfd_ardata (arch)->armap_datepos = (SARMAG
@@ -2547,7 +2605,7 @@
   unsigned int ranlibsize = (symbol_count * 4) + 4;
   unsigned int stringsize = stridx;
   unsigned int mapsize = stringsize + ranlibsize;
-  unsigned int archive_member_file_ptr;
+  file_ptr archive_member_file_ptr;
   bfd *current = arch->archive_head;
   unsigned int count;
   struct ar_hdr hdr;
@@ -2564,11 +2622,11 @@
 
   memset (&hdr, ' ', sizeof (struct ar_hdr));
   hdr.ar_name[0] = '/';
-  _bfd_ar_spacepad (hdr.ar_size, sizeof (hdr.ar_size), "%-10ld",
-                    mapsize);
+  if (!_bfd_ar_sizepad (hdr.ar_size, sizeof (hdr.ar_size), mapsize))
+    return FALSE;
   _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld",
-                    ((arch->flags & BFD_DETERMINISTIC_OUTPUT) == 0
-                     ? time (NULL) : 0));
+		    ((arch->flags & BFD_DETERMINISTIC_OUTPUT) == 0
+		     ? time (NULL) : 0));
   /* This, at least, is what Intel coff sets the values to.  */
   _bfd_ar_spacepad (hdr.ar_uid, sizeof (hdr.ar_uid), "%ld", 0);
   _bfd_ar_spacepad (hdr.ar_gid, sizeof (hdr.ar_gid), "%ld", 0);
@@ -2598,18 +2656,26 @@
 
       while (count < symbol_count && map[count].u.abfd == current)
 	{
-	  if (!bfd_write_bigendian_4byte_int (arch, archive_member_file_ptr))
+	  unsigned int offset = (unsigned int) archive_member_file_ptr;
+
+	  /* Catch an attempt to grow an archive past its 4Gb limit.  */
+	  if (archive_member_file_ptr != (file_ptr) offset)
+	    {
+	      bfd_set_error (bfd_error_file_truncated);
+	      return FALSE;
+	    }
+	  if (!bfd_write_bigendian_4byte_int (arch, offset))
 	    return FALSE;
 	  count++;
 	}
       archive_member_file_ptr += sizeof (struct ar_hdr);
       if (! bfd_is_thin_archive (arch))
-        {
-          /* Add size of this archive entry.  */
-          archive_member_file_ptr += arelt_size (current);
-          /* Remember about the even alignment.  */
-          archive_member_file_ptr += archive_member_file_ptr % 2;
-        }
+	{
+	  /* Add size of this archive entry.  */
+	  archive_member_file_ptr += arelt_size (current);
+	  /* Remember about the even alignment.  */
+	  archive_member_file_ptr += archive_member_file_ptr % 2;
+	}
       current = current->archive_next;
     }
 
@@ -2632,3 +2698,58 @@
 
   return TRUE;
 }
+
+static int
+archive_close_worker (void **slot, void *inf ATTRIBUTE_UNUSED)
+{
+  struct ar_cache *ent = (struct ar_cache *) *slot;
+
+  bfd_close_all_done (ent->arbfd);
+  return 1;
+}
+
+bfd_boolean
+_bfd_archive_close_and_cleanup (bfd *abfd)
+{
+  if (bfd_read_p (abfd) && abfd->format == bfd_archive)
+    {
+      bfd *nbfd;
+      bfd *next;
+      htab_t htab;
+
+      /* Close nested archives (if this bfd is a thin archive).  */
+      for (nbfd = abfd->nested_archives; nbfd; nbfd = next)
+	{
+	  next = nbfd->archive_next;
+	  bfd_close (nbfd);
+	}
+
+      htab = bfd_ardata (abfd)->cache;
+      if (htab)
+	{
+	  htab_traverse_noresize (htab, archive_close_worker, NULL);
+	  htab_delete (htab);
+	  bfd_ardata (abfd)->cache = NULL;
+	}
+    }
+  if (arch_eltdata (abfd) != NULL)
+    {
+      struct areltdata *ared = arch_eltdata (abfd);
+      htab_t htab = (htab_t) ared->parent_cache;
+
+      if (htab)
+	{
+	  struct ar_cache ent;
+	  void **slot;
+
+	  ent.ptr = ared->key;
+	  slot = htab_find_slot (htab, &ent, NO_INSERT);
+	  if (slot != NULL)
+	    {
+	      BFD_ASSERT (((struct ar_cache *) *slot)->arbfd == abfd);
+	      htab_clear_slot (htab, slot);
+	    }
+	}
+    }
+  return TRUE;
+}
diff --git a/bfd/archive64.c b/bfd/archive64.c
index bbc4c3f..be64e0d 100644
--- a/bfd/archive64.c
+++ b/bfd/archive64.c
@@ -1,6 +1,5 @@
-/* MIPS-specific support for 64-bit ELF
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007,
-   2010  Free Software Foundation, Inc.
+/* Support for 64-bit ELF archives.
+   Copyright 1996-2013 Free Software Foundation, Inc.
    Ian Lance Taylor, Cygnus Support
    Linker support added by Mark Mitchell, CodeSourcery, LLC.
    <[email protected]>
@@ -77,7 +76,7 @@
   if (mapdata == NULL)
     return FALSE;
   parsed_size = mapdata->parsed_size;
-  bfd_release (abfd, mapdata);
+  free (mapdata);
 
   if (bfd_bread (int_buf, 8, abfd) != 8)
     {
@@ -169,8 +168,8 @@
 
   memset (&hdr, ' ', sizeof (struct ar_hdr));
   memcpy (hdr.ar_name, "/SYM64/", strlen ("/SYM64/"));
-  _bfd_ar_spacepad (hdr.ar_size, sizeof (hdr.ar_size), "%-10ld",
-                    mapsize);
+  if (!_bfd_ar_sizepad (hdr.ar_size, sizeof (hdr.ar_size), mapsize))
+    return FALSE;
   _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld",
                     time (NULL));
   /* This, at least, is what Intel coff sets the values to.: */
@@ -200,7 +199,7 @@
        current = current->archive_next)
     {
       /* For each symbol which is used defined in this object, write out
-	 the object file's address in the archive */
+	 the object file's address in the archive.  */
 
       for (;
 	   count < symbol_count && map[count].u.abfd == current;
@@ -210,9 +209,11 @@
 	  if (bfd_bwrite (buf, 8, arch) != 8)
 	    return FALSE;
 	}
+
       /* Add size of this archive entry */
-      archive_member_file_ptr += (arelt_size (current)
-				  + sizeof (struct ar_hdr));
+      archive_member_file_ptr += sizeof (struct ar_hdr);
+      if (! bfd_is_thin_archive (arch))
+	archive_member_file_ptr += arelt_size (current);
       /* remember about the even alignment */
       archive_member_file_ptr += archive_member_file_ptr % 2;
     }
diff --git a/bfd/archures.c b/bfd/archures.c
index 44850e7..97c540a 100644
--- a/bfd/archures.c
+++ b/bfd/archures.c
@@ -1,7 +1,5 @@
 /* BFD library support routines for architectures.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright 1990-2013 Free Software Foundation, Inc.
    Hacked by John Gilmore and Steve Chamberlain of Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -145,7 +143,7 @@
 .#define bfd_mach_sparc_64bit_p(mach) \
 .  ((mach) >= bfd_mach_sparc_v9 && (mach) != bfd_mach_sparc_v8plusb)
 .  bfd_arch_spu,       {* PowerPC SPU *}
-.#define bfd_mach_spu		256 
+.#define bfd_mach_spu		256
 .  bfd_arch_mips,      {* MIPS Rxxxx *}
 .#define bfd_mach_mips3000		3000
 .#define bfd_mach_mips3900		3900
@@ -161,6 +159,7 @@
 .#define bfd_mach_mips5000		5000
 .#define bfd_mach_mips5400		5400
 .#define bfd_mach_mips5500		5500
+.#define bfd_mach_mips5900		5900
 .#define bfd_mach_mips6000		6000
 .#define bfd_mach_mips7000		7000
 .#define bfd_mach_mips8000		8000
@@ -176,6 +175,8 @@
 .#define bfd_mach_mips_loongson_3a      3003
 .#define bfd_mach_mips_sb1              12310201 {* octal 'SB', 01 *}
 .#define bfd_mach_mips_octeon		6501
+.#define bfd_mach_mips_octeonp		6601
+.#define bfd_mach_mips_octeon2		6502
 .#define bfd_mach_mips_xlr              887682   {* decimal 'XLR'  *}
 .#define bfd_mach_mipsisa32             32
 .#define bfd_mach_mipsisa32r2           33
@@ -197,6 +198,10 @@
 .  bfd_arch_k1om,   {* Intel K1OM *}
 .#define bfd_mach_k1om			(1 << 6)
 .#define bfd_mach_k1om_intel_syntax	(bfd_mach_k1om | bfd_mach_i386_intel_syntax)
+.#define bfd_mach_i386_nacl		(1 << 7)
+.#define bfd_mach_i386_i386_nacl	(bfd_mach_i386_i386 | bfd_mach_i386_nacl)
+.#define bfd_mach_x86_64_nacl		(bfd_mach_x86_64 | bfd_mach_i386_nacl)
+.#define bfd_mach_x64_32_nacl		(bfd_mach_x64_32 | bfd_mach_i386_nacl)
 .  bfd_arch_we32k,     {* AT&T WE32xxx *}
 .  bfd_arch_tahoe,     {* CCI/Harris Tahoe *}
 .  bfd_arch_i860,      {* Intel 860 *}
@@ -239,7 +244,10 @@
 .#define bfd_mach_ppc_e500      500
 .#define bfd_mach_ppc_e500mc    5001
 .#define bfd_mach_ppc_e500mc64  5005
+.#define bfd_mach_ppc_e5500     5006
+.#define bfd_mach_ppc_e6500     5007
 .#define bfd_mach_ppc_titan     83
+.#define bfd_mach_ppc_vle       84
 .  bfd_arch_rs6000,    {* IBM RS/6000 *}
 .#define bfd_mach_rs6k		6000
 .#define bfd_mach_rs6k_rs1	6001
@@ -261,6 +269,8 @@
 .#define bfd_mach_m6812_default 0
 .#define bfd_mach_m6812         1
 .#define bfd_mach_m6812s        2
+.  bfd_arch_m9s12x,   {* Freescale S12X *}
+.  bfd_arch_m9s12xg,  {* Freescale XGATE *}
 .  bfd_arch_z8k,       {* Zilog Z8000 *}
 .#define bfd_mach_z8001		1
 .#define bfd_mach_z8002		2
@@ -316,11 +326,13 @@
 .  bfd_arch_tic6x,     {* Texas Instruments TMS320C6X *}
 .  bfd_arch_tic80,     {* TI TMS320c80 (MVP) *}
 .  bfd_arch_v850,      {* NEC V850 *}
+.  bfd_arch_v850_rh850,{* NEC V850 (using RH850 ABI) *}
 .#define bfd_mach_v850          1
 .#define bfd_mach_v850e 	'E'
 .#define bfd_mach_v850e1        '1'
 .#define bfd_mach_v850e2        0x4532
 .#define bfd_mach_v850e2v3      0x45325633
+.#define bfd_mach_v850e3v5      0x45335635 {* ('E'|'3'|'V'|'5') *}
 .  bfd_arch_arc,       {* ARC Cores *}
 .#define bfd_mach_arc_5         5
 .#define bfd_mach_arc_6         6
@@ -356,6 +368,8 @@
 .#define bfd_mach_mep		1
 .#define bfd_mach_mep_h1	0x6831
 .#define bfd_mach_mep_c5	0x6335
+.  bfd_arch_metag,
+.#define bfd_mach_metag		1
 .  bfd_arch_ia64,      {* HP/Intel ia64 *}
 .#define bfd_mach_ia64_elf64	64
 .#define bfd_mach_ia64_elf32	32
@@ -365,6 +379,9 @@
 . bfd_arch_iq2000,     {* Vitesse IQ2000.  *}
 .#define bfd_mach_iq2000        1
 .#define bfd_mach_iq10          2
+.  bfd_arch_epiphany,	{* Adapteva EPIPHANY *}
+.#define bfd_mach_epiphany16	1
+.#define bfd_mach_epiphany32	2
 .  bfd_arch_mt,
 .#define bfd_mach_ms1           1
 .#define bfd_mach_mrisc2        2
@@ -400,12 +417,14 @@
 .#define bfd_mach_cris_v0_v10	255
 .#define bfd_mach_cris_v32	32
 .#define bfd_mach_cris_v10_v32	1032
+.  bfd_arch_rl78,
+.#define bfd_mach_rl78	0x75
 .  bfd_arch_rx,        {* Renesas RX.  *}
 .#define bfd_mach_rx            0x75
 .  bfd_arch_s390,      {* IBM s390 *}
 .#define bfd_mach_s390_31       31
 .#define bfd_mach_s390_64       64
-.  bfd_arch_score,     {* Sunplus score *} 
+.  bfd_arch_score,     {* Sunplus score *}
 .#define bfd_mach_score3         3
 .#define bfd_mach_score7         7
 .  bfd_arch_openrisc,  {* OpenRISC *}
@@ -420,7 +439,12 @@
 .#define bfd_mach_msp14          14
 .#define bfd_mach_msp15          15
 .#define bfd_mach_msp16          16
+.#define bfd_mach_msp20          20
 .#define bfd_mach_msp21          21
+.#define bfd_mach_msp22          22
+.#define bfd_mach_msp23          23
+.#define bfd_mach_msp24          24
+.#define bfd_mach_msp26          26
 .#define bfd_mach_msp31          31
 .#define bfd_mach_msp32          32
 .#define bfd_mach_msp33          33
@@ -428,10 +452,16 @@
 .#define bfd_mach_msp42          42
 .#define bfd_mach_msp43          43
 .#define bfd_mach_msp44          44
+.#define bfd_mach_msp430x        45
+.#define bfd_mach_msp46          46
+.#define bfd_mach_msp47          47
+.#define bfd_mach_msp54          54
 .  bfd_arch_xc16x,     {* Infineon's XC16X Series.               *}
 .#define bfd_mach_xc16x         1
 .#define bfd_mach_xc16xl        2
-.#define bfd_mach_xc16xs         3
+.#define bfd_mach_xc16xs        3
+.  bfd_arch_xgate,   {* Freescale XGATE *}
+.#define bfd_mach_xgate         1
 .  bfd_arch_xtensa,    {* Tensilica's Xtensa cores.  *}
 .#define bfd_mach_xtensa	1
 .  bfd_arch_z80,
@@ -446,6 +476,12 @@
 .  bfd_arch_tilegx, {* Tilera TILE-Gx *}
 .#define bfd_mach_tilepro   1
 .#define bfd_mach_tilegx    1
+.#define bfd_mach_tilegx32  2
+.  bfd_arch_aarch64,   {* AArch64  *}
+.#define bfd_mach_aarch64 0
+.#define bfd_mach_aarch64_ilp32	32
+.  bfd_arch_nios2,
+.#define bfd_mach_nios2	0
 .  bfd_arch_last
 .  };
 */
@@ -478,12 +514,19 @@
 .
 .  bfd_boolean (*scan) (const struct bfd_arch_info *, const char *);
 .
+.  {* Allocate via bfd_malloc and return a fill buffer of size COUNT.  If
+.     IS_BIGENDIAN is TRUE, the order of bytes is big endian.  If CODE is
+.     TRUE, the buffer contains code.  *}
+.  void *(*fill) (bfd_size_type count, bfd_boolean is_bigendian,
+.		  bfd_boolean code);
+.
 .  const struct bfd_arch_info *next;
 .}
 .bfd_arch_info_type;
 .
 */
 
+extern const bfd_arch_info_type bfd_aarch64_arch;
 extern const bfd_arch_info_type bfd_alpha_arch;
 extern const bfd_arch_info_type bfd_arc_arch;
 extern const bfd_arch_info_type bfd_arm_arch;
@@ -496,6 +539,7 @@
 extern const bfd_arch_info_type bfd_d10v_arch;
 extern const bfd_arch_info_type bfd_d30v_arch;
 extern const bfd_arch_info_type bfd_dlx_arch;
+extern const bfd_arch_info_type bfd_epiphany_arch;
 extern const bfd_arch_info_type bfd_fr30_arch;
 extern const bfd_arch_info_type bfd_frv_arch;
 extern const bfd_arch_info_type bfd_h8300_arch;
@@ -515,10 +559,13 @@
 extern const bfd_arch_info_type bfd_m32r_arch;
 extern const bfd_arch_info_type bfd_m68hc11_arch;
 extern const bfd_arch_info_type bfd_m68hc12_arch;
+extern const bfd_arch_info_type bfd_m9s12x_arch;
+extern const bfd_arch_info_type bfd_m9s12xg_arch;
 extern const bfd_arch_info_type bfd_m68k_arch;
 extern const bfd_arch_info_type bfd_m88k_arch;
 extern const bfd_arch_info_type bfd_mcore_arch;
 extern const bfd_arch_info_type bfd_mep_arch;
+extern const bfd_arch_info_type bfd_metag_arch;
 extern const bfd_arch_info_type bfd_mips_arch;
 extern const bfd_arch_info_type bfd_microblaze_arch;
 extern const bfd_arch_info_type bfd_mmix_arch;
@@ -527,6 +574,7 @@
 extern const bfd_arch_info_type bfd_moxie_arch;
 extern const bfd_arch_info_type bfd_msp430_arch;
 extern const bfd_arch_info_type bfd_mt_arch;
+extern const bfd_arch_info_type bfd_nios2_arch;
 extern const bfd_arch_info_type bfd_ns32k_arch;
 extern const bfd_arch_info_type bfd_openrisc_arch;
 extern const bfd_arch_info_type bfd_or32_arch;
@@ -536,6 +584,7 @@
 extern const bfd_arch_info_type bfd_powerpc_archs[];
 #define bfd_powerpc_arch bfd_powerpc_archs[0]
 extern const bfd_arch_info_type bfd_rs6000_arch;
+extern const bfd_arch_info_type bfd_rl78_arch;
 extern const bfd_arch_info_type bfd_rx_arch;
 extern const bfd_arch_info_type bfd_s390_arch;
 extern const bfd_arch_info_type bfd_score_arch;
@@ -550,12 +599,14 @@
 extern const bfd_arch_info_type bfd_tilegx_arch;
 extern const bfd_arch_info_type bfd_tilepro_arch;
 extern const bfd_arch_info_type bfd_v850_arch;
+extern const bfd_arch_info_type bfd_v850_rh850_arch;
 extern const bfd_arch_info_type bfd_vax_arch;
 extern const bfd_arch_info_type bfd_w65_arch;
 extern const bfd_arch_info_type bfd_we32k_arch;
 extern const bfd_arch_info_type bfd_xstormy16_arch;
 extern const bfd_arch_info_type bfd_xtensa_arch;
 extern const bfd_arch_info_type bfd_xc16x_arch;
+extern const bfd_arch_info_type bfd_xgate_arch;
 extern const bfd_arch_info_type bfd_z80_arch;
 extern const bfd_arch_info_type bfd_z8k_arch;
 
@@ -564,6 +615,7 @@
 #ifdef SELECT_ARCHITECTURES
     SELECT_ARCHITECTURES,
 #else
+    &bfd_aarch64_arch,
     &bfd_alpha_arch,
     &bfd_arc_arch,
     &bfd_arm_arch,
@@ -576,6 +628,7 @@
     &bfd_d10v_arch,
     &bfd_d30v_arch,
     &bfd_dlx_arch,
+    &bfd_epiphany_arch,
     &bfd_fr30_arch,
     &bfd_frv_arch,
     &bfd_h8300_arch,
@@ -595,10 +648,13 @@
     &bfd_m32r_arch,
     &bfd_m68hc11_arch,
     &bfd_m68hc12_arch,
+    &bfd_m9s12x_arch,
+    &bfd_m9s12xg_arch,
     &bfd_m68k_arch,
     &bfd_m88k_arch,
     &bfd_mcore_arch,
     &bfd_mep_arch,
+    &bfd_metag_arch,
     &bfd_microblaze_arch,
     &bfd_mips_arch,
     &bfd_mmix_arch,
@@ -607,12 +663,14 @@
     &bfd_moxie_arch,
     &bfd_msp430_arch,
     &bfd_mt_arch,
+    &bfd_nios2_arch,
     &bfd_ns32k_arch,
     &bfd_openrisc_arch,
     &bfd_or32_arch,
     &bfd_pdp11_arch,
     &bfd_powerpc_arch,
     &bfd_rs6000_arch,
+    &bfd_rl78_arch,
     &bfd_rx_arch,
     &bfd_s390_arch,
     &bfd_score_arch,
@@ -627,12 +685,14 @@
     &bfd_tilegx_arch,
     &bfd_tilepro_arch,
     &bfd_v850_arch,
+    &bfd_v850_rh850_arch,
     &bfd_vax_arch,
     &bfd_w65_arch,
     &bfd_we32k_arch,
     &bfd_xstormy16_arch,
     &bfd_xtensa_arch,
     &bfd_xc16x_arch,
+    &bfd_xgate_arch,
     &bfd_z80_arch,
     &bfd_z8k_arch,
 #endif
@@ -803,6 +863,7 @@
   32, 32, 8, bfd_arch_unknown, 0, "unknown", "unknown", 2, TRUE,
   bfd_default_compatible,
   bfd_default_scan,
+  bfd_arch_default_fill,
   0,
 };
 
@@ -1298,3 +1359,29 @@
     return ap->bits_per_byte / 8;
   return 1;
 }
+
+/*
+INTERNAL_FUNCTION
+	bfd_arch_default_fill
+
+SYNOPSIS
+	void *bfd_arch_default_fill (bfd_size_type count,
+				     bfd_boolean is_bigendian,
+				     bfd_boolean code);
+
+DESCRIPTION
+	Allocate via bfd_malloc and return a fill buffer of size COUNT.
+	If IS_BIGENDIAN is TRUE, the order of bytes is big endian.  If
+	CODE is TRUE, the buffer contains code.
+*/
+
+void *
+bfd_arch_default_fill (bfd_size_type count,
+		       bfd_boolean is_bigendian ATTRIBUTE_UNUSED,
+		       bfd_boolean code ATTRIBUTE_UNUSED)
+{
+  void *fill = bfd_malloc (count);
+  if (fill != NULL)
+    memset (fill, 0, count);
+  return fill;
+}
diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index a477b49..c7c5a7d 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -1,8 +1,6 @@
 /* Main header file for the bfd library -- portable access to object files.
 
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright 1990-2013 Free Software Foundation, Inc.
 
    Contributed by Cygnus Support.
 
@@ -25,12 +23,19 @@
 #ifndef __BFD_H_SEEN__
 #define __BFD_H_SEEN__
 
+/* PR 14072: Ensure that config.h is included first.  */
+#if !defined PACKAGE && !defined PACKAGE_VERSION
+#error config.h must be included before this header
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 #include "ansidecl.h"
 #include "symcat.h"
+#include <sys/stat.h>
+
 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
 #ifndef SABER
 /* This hack is to avoid a problem with some strict ANSI C preprocessors.
@@ -55,7 +60,7 @@
    problem for example when trying to use STRING_COMMA_LEN to build
    the arguments to the strncmp() macro.  Hence this alternative
    definition of strncmp is provided here.
-   
+
    Note - these macros do NOT work if STR2 is not a constant string.  */
 #define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
   /* strcpy() can have a similar problem, but since we know we are
@@ -271,38 +276,33 @@
 
 typedef struct bfd_section *sec_ptr;
 
-#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
-#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
-#define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0)
-#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
+#define bfd_get_section_name(bfd, ptr) ((void) bfd, (ptr)->name)
+#define bfd_get_section_vma(bfd, ptr) ((void) bfd, (ptr)->vma)
+#define bfd_get_section_lma(bfd, ptr) ((void) bfd, (ptr)->lma)
+#define bfd_get_section_alignment(bfd, ptr) ((void) bfd, \
+					     (ptr)->alignment_power)
 #define bfd_section_name(bfd, ptr) ((ptr)->name)
 #define bfd_section_size(bfd, ptr) ((ptr)->size)
 #define bfd_get_section_size(ptr) ((ptr)->size)
 #define bfd_section_vma(bfd, ptr) ((ptr)->vma)
 #define bfd_section_lma(bfd, ptr) ((ptr)->lma)
 #define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
-#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0)
-#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
+#define bfd_get_section_flags(bfd, ptr) ((void) bfd, (ptr)->flags)
+#define bfd_get_section_userdata(bfd, ptr) ((void) bfd, (ptr)->userdata)
 
 #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
 
-#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
-#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
-#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
 /* Find the address one past the end of SEC.  */
 #define bfd_get_section_limit(bfd, sec) \
   (((bfd)->direction != write_direction && (sec)->rawsize != 0	\
     ? (sec)->rawsize : (sec)->size) / bfd_octets_per_byte (bfd))
 
 /* Return TRUE if input section SEC has been discarded.  */
-#define elf_discarded_section(sec)				\
+#define discarded_section(sec)				\
   (!bfd_is_abs_section (sec)					\
    && bfd_is_abs_section ((sec)->output_section)		\
-   && (sec)->sec_info_type != ELF_INFO_TYPE_MERGE		\
-   && (sec)->sec_info_type != ELF_INFO_TYPE_JUST_SYMS)
-
-/* Forward define.  */
-struct stat;
+   && (sec)->sec_info_type != SEC_INFO_TYPE_MERGE		\
+   && (sec)->sec_info_type != SEC_INFO_TYPE_JUST_SYMS)
 
 typedef enum bfd_print_symbol
 {
@@ -514,8 +514,6 @@
 
 #define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
 
-#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE)
-
 extern bfd_boolean bfd_cache_close
   (bfd *abfd);
 /* NB: This declaration should match the autogenerated one in libbfd.h.  */
@@ -643,6 +641,8 @@
   (bfd *, struct bfd_link_info *);
 extern bfd_boolean bfd_elf_get_bfd_needed_list
   (bfd *, struct bfd_link_needed_list **);
+extern bfd_boolean bfd_elf_stack_segment_size (bfd *, struct bfd_link_info *,
+					       const char *, bfd_vma);
 extern bfd_boolean bfd_elf_size_dynamic_sections
   (bfd *, const char *, const char *, const char *, const char *, const char *,
    const char * const *, struct bfd_link_info *, struct bfd_section **);
@@ -693,19 +693,15 @@
    the remote memory.  */
 extern bfd *bfd_elf_bfd_from_remote_memory
   (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
-   int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr, int len));
-
-/* Return the arch_size field of an elf bfd, or -1 if not elf.  */
-extern int bfd_get_arch_size
-  (bfd *);
-
-/* Return TRUE if address "naturally" sign extends, or -1 if not elf.  */
-extern int bfd_get_sign_extend_vma
-  (bfd *);
+   int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr,
+			      bfd_size_type len));
 
 extern struct bfd_section *_bfd_elf_tls_setup
   (bfd *, struct bfd_link_info *);
 
+extern struct bfd_section *
+_bfd_nearby_section (bfd *, struct bfd_section *, bfd_vma);
+
 extern void _bfd_fix_excluded_sec_syms
   (bfd *, struct bfd_link_info *);
 
@@ -908,7 +904,8 @@
   (struct bfd_link_info *, struct bfd_section *);
 extern bfd_boolean elf32_arm_size_stubs
   (bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
-   struct bfd_section * (*) (const char *, struct bfd_section *), void (*) (void));
+   struct bfd_section * (*) (const char *, struct bfd_section *, unsigned int),
+   void (*) (void));
 extern bfd_boolean elf32_arm_build_stubs
   (struct bfd_link_info *);
 
@@ -927,6 +924,50 @@
 extern unsigned int _bfd_elf_ppc_at_tprel_transform
   (unsigned int, unsigned int);
 
+extern void bfd_elf64_aarch64_init_maps
+  (bfd *);
+
+extern void bfd_elf32_aarch64_init_maps
+  (bfd *);
+
+extern void bfd_elf64_aarch64_set_options
+  (bfd *, struct bfd_link_info *, int, int, int);
+
+extern void bfd_elf32_aarch64_set_options
+  (bfd *, struct bfd_link_info *, int, int, int);
+
+/* ELF AArch64 mapping symbol support.  */
+#define BFD_AARCH64_SPECIAL_SYM_TYPE_MAP	(1 << 0)
+#define BFD_AARCH64_SPECIAL_SYM_TYPE_TAG	(1 << 1)
+#define BFD_AARCH64_SPECIAL_SYM_TYPE_OTHER	(1 << 2)
+#define BFD_AARCH64_SPECIAL_SYM_TYPE_ANY	(~0)
+extern bfd_boolean bfd_is_aarch64_special_symbol_name
+  (const char * name, int type);
+
+/* AArch64 stub generation support for ELF64.  Called from the linker.  */
+extern int elf64_aarch64_setup_section_lists
+  (bfd *, struct bfd_link_info *);
+extern void elf64_aarch64_next_input_section
+  (struct bfd_link_info *, struct bfd_section *);
+extern bfd_boolean elf64_aarch64_size_stubs
+  (bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
+   struct bfd_section * (*) (const char *, struct bfd_section *),
+   void (*) (void));
+extern bfd_boolean elf64_aarch64_build_stubs
+  (struct bfd_link_info *);
+/* AArch64 stub generation support for ELF32.  Called from the linker.  */
+extern int elf32_aarch64_setup_section_lists
+  (bfd *, struct bfd_link_info *);
+extern void elf32_aarch64_next_input_section
+  (struct bfd_link_info *, struct bfd_section *);
+extern bfd_boolean elf32_aarch64_size_stubs
+  (bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
+   struct bfd_section * (*) (const char *, struct bfd_section *),
+   void (*) (void));
+extern bfd_boolean elf32_aarch64_build_stubs
+  (struct bfd_link_info *);
+
+
 /* TI COFF load page support.  */
 extern void bfd_ticoff_set_section_load_page
   (struct bfd_section *, int);
@@ -962,6 +1003,5 @@
   long symbol;
 };
 
-extern struct coff_comdat_info *bfd_coff_get_comdat_section
+extern struct coff_comdat_info * bfd_coff_get_comdat_section
   (bfd *, struct bfd_section *);
-
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 523ad9c..99c5bf8 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -7,9 +7,7 @@
 
 /* Main header file for the bfd library -- portable access to object files.
 
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright 1990-2013 Free Software Foundation, Inc.
 
    Contributed by Cygnus Support.
 
@@ -32,12 +30,19 @@
 #ifndef __BFD_H_SEEN__
 #define __BFD_H_SEEN__
 
+/* PR 14072: Ensure that config.h is included first.  */
+#if !defined PACKAGE && !defined PACKAGE_VERSION
+#error config.h must be included before this header
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 #include "ansidecl.h"
 #include "symcat.h"
+#include <sys/stat.h>
+
 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
 #ifndef SABER
 /* This hack is to avoid a problem with some strict ANSI C preprocessors.
@@ -62,7 +67,7 @@
    problem for example when trying to use STRING_COMMA_LEN to build
    the arguments to the strncmp() macro.  Hence this alternative
    definition of strncmp is provided here.
-   
+
    Note - these macros do NOT work if STR2 is not a constant string.  */
 #define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
   /* strcpy() can have a similar problem, but since we know we are
@@ -278,38 +283,33 @@
 
 typedef struct bfd_section *sec_ptr;
 
-#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0)
-#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0)
-#define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0)
-#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
+#define bfd_get_section_name(bfd, ptr) ((void) bfd, (ptr)->name)
+#define bfd_get_section_vma(bfd, ptr) ((void) bfd, (ptr)->vma)
+#define bfd_get_section_lma(bfd, ptr) ((void) bfd, (ptr)->lma)
+#define bfd_get_section_alignment(bfd, ptr) ((void) bfd, \
+					     (ptr)->alignment_power)
 #define bfd_section_name(bfd, ptr) ((ptr)->name)
 #define bfd_section_size(bfd, ptr) ((ptr)->size)
 #define bfd_get_section_size(ptr) ((ptr)->size)
 #define bfd_section_vma(bfd, ptr) ((ptr)->vma)
 #define bfd_section_lma(bfd, ptr) ((ptr)->lma)
 #define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
-#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0)
-#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
+#define bfd_get_section_flags(bfd, ptr) ((void) bfd, (ptr)->flags)
+#define bfd_get_section_userdata(bfd, ptr) ((void) bfd, (ptr)->userdata)
 
 #define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
 
-#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
-#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
-#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
 /* Find the address one past the end of SEC.  */
 #define bfd_get_section_limit(bfd, sec) \
   (((bfd)->direction != write_direction && (sec)->rawsize != 0	\
     ? (sec)->rawsize : (sec)->size) / bfd_octets_per_byte (bfd))
 
 /* Return TRUE if input section SEC has been discarded.  */
-#define elf_discarded_section(sec)				\
+#define discarded_section(sec)				\
   (!bfd_is_abs_section (sec)					\
    && bfd_is_abs_section ((sec)->output_section)		\
-   && (sec)->sec_info_type != ELF_INFO_TYPE_MERGE		\
-   && (sec)->sec_info_type != ELF_INFO_TYPE_JUST_SYMS)
-
-/* Forward define.  */
-struct stat;
+   && (sec)->sec_info_type != SEC_INFO_TYPE_MERGE		\
+   && (sec)->sec_info_type != SEC_INFO_TYPE_JUST_SYMS)
 
 typedef enum bfd_print_symbol
 {
@@ -521,8 +521,6 @@
 
 #define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char)
 
-#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = bool), TRUE)
-
 extern bfd_boolean bfd_cache_close
   (bfd *abfd);
 /* NB: This declaration should match the autogenerated one in libbfd.h.  */
@@ -650,6 +648,8 @@
   (bfd *, struct bfd_link_info *);
 extern bfd_boolean bfd_elf_get_bfd_needed_list
   (bfd *, struct bfd_link_needed_list **);
+extern bfd_boolean bfd_elf_stack_segment_size (bfd *, struct bfd_link_info *,
+					       const char *, bfd_vma);
 extern bfd_boolean bfd_elf_size_dynamic_sections
   (bfd *, const char *, const char *, const char *, const char *, const char *,
    const char * const *, struct bfd_link_info *, struct bfd_section **);
@@ -700,19 +700,15 @@
    the remote memory.  */
 extern bfd *bfd_elf_bfd_from_remote_memory
   (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
-   int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr, int len));
-
-/* Return the arch_size field of an elf bfd, or -1 if not elf.  */
-extern int bfd_get_arch_size
-  (bfd *);
-
-/* Return TRUE if address "naturally" sign extends, or -1 if not elf.  */
-extern int bfd_get_sign_extend_vma
-  (bfd *);
+   int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr,
+			      bfd_size_type len));
 
 extern struct bfd_section *_bfd_elf_tls_setup
   (bfd *, struct bfd_link_info *);
 
+extern struct bfd_section *
+_bfd_nearby_section (bfd *, struct bfd_section *, bfd_vma);
+
 extern void _bfd_fix_excluded_sec_syms
   (bfd *, struct bfd_link_info *);
 
@@ -915,7 +911,8 @@
   (struct bfd_link_info *, struct bfd_section *);
 extern bfd_boolean elf32_arm_size_stubs
   (bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
-   struct bfd_section * (*) (const char *, struct bfd_section *), void (*) (void));
+   struct bfd_section * (*) (const char *, struct bfd_section *, unsigned int),
+   void (*) (void));
 extern bfd_boolean elf32_arm_build_stubs
   (struct bfd_link_info *);
 
@@ -934,6 +931,50 @@
 extern unsigned int _bfd_elf_ppc_at_tprel_transform
   (unsigned int, unsigned int);
 
+extern void bfd_elf64_aarch64_init_maps
+  (bfd *);
+
+extern void bfd_elf32_aarch64_init_maps
+  (bfd *);
+
+extern void bfd_elf64_aarch64_set_options
+  (bfd *, struct bfd_link_info *, int, int, int);
+
+extern void bfd_elf32_aarch64_set_options
+  (bfd *, struct bfd_link_info *, int, int, int);
+
+/* ELF AArch64 mapping symbol support.  */
+#define BFD_AARCH64_SPECIAL_SYM_TYPE_MAP	(1 << 0)
+#define BFD_AARCH64_SPECIAL_SYM_TYPE_TAG	(1 << 1)
+#define BFD_AARCH64_SPECIAL_SYM_TYPE_OTHER	(1 << 2)
+#define BFD_AARCH64_SPECIAL_SYM_TYPE_ANY	(~0)
+extern bfd_boolean bfd_is_aarch64_special_symbol_name
+  (const char * name, int type);
+
+/* AArch64 stub generation support for ELF64.  Called from the linker.  */
+extern int elf64_aarch64_setup_section_lists
+  (bfd *, struct bfd_link_info *);
+extern void elf64_aarch64_next_input_section
+  (struct bfd_link_info *, struct bfd_section *);
+extern bfd_boolean elf64_aarch64_size_stubs
+  (bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
+   struct bfd_section * (*) (const char *, struct bfd_section *),
+   void (*) (void));
+extern bfd_boolean elf64_aarch64_build_stubs
+  (struct bfd_link_info *);
+/* AArch64 stub generation support for ELF32.  Called from the linker.  */
+extern int elf32_aarch64_setup_section_lists
+  (bfd *, struct bfd_link_info *);
+extern void elf32_aarch64_next_input_section
+  (struct bfd_link_info *, struct bfd_section *);
+extern bfd_boolean elf32_aarch64_size_stubs
+  (bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
+   struct bfd_section * (*) (const char *, struct bfd_section *),
+   void (*) (void));
+extern bfd_boolean elf32_aarch64_build_stubs
+  (struct bfd_link_info *);
+
+
 /* TI COFF load page support.  */
 extern void bfd_ticoff_set_section_load_page
   (struct bfd_section *, int);
@@ -969,9 +1010,8 @@
   long symbol;
 };
 
-extern struct coff_comdat_info *bfd_coff_get_comdat_section
+extern struct coff_comdat_info * bfd_coff_get_comdat_section
   (bfd *, struct bfd_section *);
-
 /* Extracted from init.c.  */
 void bfd_init (void);
 
@@ -984,7 +1024,7 @@
 
 bfd *bfd_fdopenr (const char *filename, const char *target, int fd);
 
-bfd *bfd_openstreamr (const char *, const char *, void *);
+bfd *bfd_openstreamr (const char * filename, const char * target, void * stream);
 
 bfd *bfd_openr_iovec (const char *filename, const char *target,
     void *(*open_func) (struct bfd *nbfd,
@@ -1020,8 +1060,14 @@
 unsigned long bfd_calc_gnu_debuglink_crc32
    (unsigned long crc, const unsigned char *buf, bfd_size_type len);
 
+char *bfd_get_debug_link_info (bfd *abfd, unsigned long *crc32_out);
+
+char *bfd_get_alt_debug_link_info (bfd *abfd, unsigned long *crc32_out);
+
 char *bfd_follow_gnu_debuglink (bfd *abfd, const char *dir);
 
+char *bfd_follow_gnu_debugaltlink (bfd *abfd, const char *dir);
+
 struct bfd_section *bfd_create_gnu_debuglink_section
    (bfd *abfd, const char *filename);
 
@@ -1384,11 +1430,11 @@
 
   /* Type of sec_info information.  */
   unsigned int sec_info_type:3;
-#define ELF_INFO_TYPE_NONE      0
-#define ELF_INFO_TYPE_STABS     1
-#define ELF_INFO_TYPE_MERGE     2
-#define ELF_INFO_TYPE_EH_FRAME  3
-#define ELF_INFO_TYPE_JUST_SYMS 4
+#define SEC_INFO_TYPE_NONE      0
+#define SEC_INFO_TYPE_STABS     1
+#define SEC_INFO_TYPE_MERGE     2
+#define SEC_INFO_TYPE_EH_FRAME  3
+#define SEC_INFO_TYPE_JUST_SYMS 4
 
   /* Nonzero if this section uses RELA relocations, rather than REL.  */
   unsigned int use_rela_p:1;
@@ -1518,9 +1564,6 @@
   /* The BFD which owns the section.  */
   bfd *owner;
 
-  /* INPUT_SECTION_FLAGS if specified in the linker script.  */
-  struct flag_info *section_flag_info;
-
   /* A symbol which points at this section only.  */
   struct bfd_symbol *symbol;
   struct bfd_symbol **symbol_ptr_ptr;
@@ -1536,40 +1579,63 @@
 } asection;
 
 /* Relax table contains information about instructions which can
-   be removed by relaxation -- replacing a long address with a 
+   be removed by relaxation -- replacing a long address with a
    short address.  */
 struct relax_table {
   /* Address where bytes may be deleted. */
   bfd_vma addr;
-  
+
   /* Number of bytes to be deleted.  */
   int size;
 };
 
+/* Note: the following are provided as inline functions rather than macros
+   because not all callers use the return value.  A macro implementation
+   would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some
+   compilers will complain about comma expressions that have no effect.  */
+static inline bfd_boolean
+bfd_set_section_userdata (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, void * val)
+{
+  ptr->userdata = val;
+  return TRUE;
+}
+
+static inline bfd_boolean
+bfd_set_section_vma (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, bfd_vma val)
+{
+  ptr->vma = ptr->lma = val;
+  ptr->user_set_vma = TRUE;
+  return TRUE;
+}
+
+static inline bfd_boolean
+bfd_set_section_alignment (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, unsigned int val)
+{
+  ptr->alignment_power = val;
+  return TRUE;
+}
+
 /* These sections are global, and are managed by BFD.  The application
    and target back end are not permitted to change the values in
-   these sections.  New code should use the section_ptr macros rather
-   than referring directly to the const sections.  The const sections
-   may eventually vanish.  */
+   these sections.  */
+extern asection _bfd_std_section[4];
+
 #define BFD_ABS_SECTION_NAME "*ABS*"
 #define BFD_UND_SECTION_NAME "*UND*"
 #define BFD_COM_SECTION_NAME "*COM*"
 #define BFD_IND_SECTION_NAME "*IND*"
 
-/* The absolute section.  */
-extern asection bfd_abs_section;
-#define bfd_abs_section_ptr ((asection *) &bfd_abs_section)
-#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr)
-/* Pointer to the undefined section.  */
-extern asection bfd_und_section;
-#define bfd_und_section_ptr ((asection *) &bfd_und_section)
-#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr)
 /* Pointer to the common section.  */
-extern asection bfd_com_section;
-#define bfd_com_section_ptr ((asection *) &bfd_com_section)
+#define bfd_com_section_ptr (&_bfd_std_section[0])
+/* Pointer to the undefined section.  */
+#define bfd_und_section_ptr (&_bfd_std_section[1])
+/* Pointer to the absolute section.  */
+#define bfd_abs_section_ptr (&_bfd_std_section[2])
 /* Pointer to the indirect section.  */
-extern asection bfd_ind_section;
-#define bfd_ind_section_ptr ((asection *) &bfd_ind_section)
+#define bfd_ind_section_ptr (&_bfd_std_section[3])
+
+#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr)
+#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr)
 #define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr)
 
 #define bfd_is_const_section(SEC)              \
@@ -1684,8 +1750,8 @@
   /* vma, lma, size, rawsize, compressed_size, relax, relax_count, */  \
      0,   0,   0,    0,       0,               0,     0,               \
                                                                        \
-  /* output_offset, output_section,              alignment_power,  */  \
-     0,             (struct bfd_section *) &SEC, 0,                    \
+  /* output_offset, output_section, alignment_power,               */  \
+     0,             &SEC,           0,                                 \
                                                                        \
   /* relocation, orelocation, reloc_count, filepos, rel_filepos,   */  \
      NULL,       NULL,        0,           0,       0,                 \
@@ -1699,9 +1765,6 @@
   /* target_index, used_by_bfd, constructor_chain, owner,          */  \
      0,            NULL,        NULL,              NULL,               \
                                                                        \
-  /* flag_info,                                                    */  \
-     NULL,                                                             \
-                                                                       \
   /* symbol,                    symbol_ptr_ptr,                    */  \
      (struct bfd_symbol *) SYM, &SEC.symbol,                           \
                                                                        \
@@ -1713,6 +1776,10 @@
 
 asection *bfd_get_section_by_name (bfd *abfd, const char *name);
 
+asection *bfd_get_next_section_by_name (asection *sec);
+
+asection *bfd_get_linker_section (bfd *abfd, const char *name);
+
 asection *bfd_get_section_by_name_if
    (bfd *abfd,
     const char *name,
@@ -1852,7 +1919,7 @@
 #define bfd_mach_sparc_64bit_p(mach) \
   ((mach) >= bfd_mach_sparc_v9 && (mach) != bfd_mach_sparc_v8plusb)
   bfd_arch_spu,       /* PowerPC SPU */
-#define bfd_mach_spu           256 
+#define bfd_mach_spu           256
   bfd_arch_mips,      /* MIPS Rxxxx */
 #define bfd_mach_mips3000              3000
 #define bfd_mach_mips3900              3900
@@ -1868,6 +1935,7 @@
 #define bfd_mach_mips5000              5000
 #define bfd_mach_mips5400              5400
 #define bfd_mach_mips5500              5500
+#define bfd_mach_mips5900              5900
 #define bfd_mach_mips6000              6000
 #define bfd_mach_mips7000              7000
 #define bfd_mach_mips8000              8000
@@ -1883,6 +1951,8 @@
 #define bfd_mach_mips_loongson_3a      3003
 #define bfd_mach_mips_sb1              12310201 /* octal 'SB', 01 */
 #define bfd_mach_mips_octeon           6501
+#define bfd_mach_mips_octeonp          6601
+#define bfd_mach_mips_octeon2          6502
 #define bfd_mach_mips_xlr              887682   /* decimal 'XLR'  */
 #define bfd_mach_mipsisa32             32
 #define bfd_mach_mipsisa32r2           33
@@ -1904,6 +1974,10 @@
   bfd_arch_k1om,   /* Intel K1OM */
 #define bfd_mach_k1om                  (1 << 6)
 #define bfd_mach_k1om_intel_syntax     (bfd_mach_k1om | bfd_mach_i386_intel_syntax)
+#define bfd_mach_i386_nacl             (1 << 7)
+#define bfd_mach_i386_i386_nacl        (bfd_mach_i386_i386 | bfd_mach_i386_nacl)
+#define bfd_mach_x86_64_nacl           (bfd_mach_x86_64 | bfd_mach_i386_nacl)
+#define bfd_mach_x64_32_nacl           (bfd_mach_x64_32 | bfd_mach_i386_nacl)
   bfd_arch_we32k,     /* AT&T WE32xxx */
   bfd_arch_tahoe,     /* CCI/Harris Tahoe */
   bfd_arch_i860,      /* Intel 860 */
@@ -1946,7 +2020,10 @@
 #define bfd_mach_ppc_e500      500
 #define bfd_mach_ppc_e500mc    5001
 #define bfd_mach_ppc_e500mc64  5005
+#define bfd_mach_ppc_e5500     5006
+#define bfd_mach_ppc_e6500     5007
 #define bfd_mach_ppc_titan     83
+#define bfd_mach_ppc_vle       84
   bfd_arch_rs6000,    /* IBM RS/6000 */
 #define bfd_mach_rs6k          6000
 #define bfd_mach_rs6k_rs1      6001
@@ -1968,6 +2045,8 @@
 #define bfd_mach_m6812_default 0
 #define bfd_mach_m6812         1
 #define bfd_mach_m6812s        2
+  bfd_arch_m9s12x,   /* Freescale S12X */
+  bfd_arch_m9s12xg,  /* Freescale XGATE */
   bfd_arch_z8k,       /* Zilog Z8000 */
 #define bfd_mach_z8001         1
 #define bfd_mach_z8002         2
@@ -2023,11 +2102,13 @@
   bfd_arch_tic6x,     /* Texas Instruments TMS320C6X */
   bfd_arch_tic80,     /* TI TMS320c80 (MVP) */
   bfd_arch_v850,      /* NEC V850 */
+  bfd_arch_v850_rh850,/* NEC V850 (using RH850 ABI) */
 #define bfd_mach_v850          1
 #define bfd_mach_v850e         'E'
 #define bfd_mach_v850e1        '1'
 #define bfd_mach_v850e2        0x4532
 #define bfd_mach_v850e2v3      0x45325633
+#define bfd_mach_v850e3v5      0x45335635 /* ('E'|'3'|'V'|'5') */
   bfd_arch_arc,       /* ARC Cores */
 #define bfd_mach_arc_5         5
 #define bfd_mach_arc_6         6
@@ -2063,6 +2144,8 @@
 #define bfd_mach_mep           1
 #define bfd_mach_mep_h1        0x6831
 #define bfd_mach_mep_c5        0x6335
+  bfd_arch_metag,
+#define bfd_mach_metag         1
   bfd_arch_ia64,      /* HP/Intel ia64 */
 #define bfd_mach_ia64_elf64    64
 #define bfd_mach_ia64_elf32    32
@@ -2072,6 +2155,9 @@
  bfd_arch_iq2000,     /* Vitesse IQ2000.  */
 #define bfd_mach_iq2000        1
 #define bfd_mach_iq10          2
+  bfd_arch_epiphany,   /* Adapteva EPIPHANY */
+#define bfd_mach_epiphany16    1
+#define bfd_mach_epiphany32    2
   bfd_arch_mt,
 #define bfd_mach_ms1           1
 #define bfd_mach_mrisc2        2
@@ -2107,12 +2193,14 @@
 #define bfd_mach_cris_v0_v10   255
 #define bfd_mach_cris_v32      32
 #define bfd_mach_cris_v10_v32  1032
+  bfd_arch_rl78,
+#define bfd_mach_rl78  0x75
   bfd_arch_rx,        /* Renesas RX.  */
 #define bfd_mach_rx            0x75
   bfd_arch_s390,      /* IBM s390 */
 #define bfd_mach_s390_31       31
 #define bfd_mach_s390_64       64
-  bfd_arch_score,     /* Sunplus score */ 
+  bfd_arch_score,     /* Sunplus score */
 #define bfd_mach_score3         3
 #define bfd_mach_score7         7
   bfd_arch_openrisc,  /* OpenRISC */
@@ -2127,7 +2215,12 @@
 #define bfd_mach_msp14          14
 #define bfd_mach_msp15          15
 #define bfd_mach_msp16          16
+#define bfd_mach_msp20          20
 #define bfd_mach_msp21          21
+#define bfd_mach_msp22          22
+#define bfd_mach_msp23          23
+#define bfd_mach_msp24          24
+#define bfd_mach_msp26          26
 #define bfd_mach_msp31          31
 #define bfd_mach_msp32          32
 #define bfd_mach_msp33          33
@@ -2135,10 +2228,16 @@
 #define bfd_mach_msp42          42
 #define bfd_mach_msp43          43
 #define bfd_mach_msp44          44
+#define bfd_mach_msp430x        45
+#define bfd_mach_msp46          46
+#define bfd_mach_msp47          47
+#define bfd_mach_msp54          54
   bfd_arch_xc16x,     /* Infineon's XC16X Series.               */
 #define bfd_mach_xc16x         1
 #define bfd_mach_xc16xl        2
-#define bfd_mach_xc16xs         3
+#define bfd_mach_xc16xs        3
+  bfd_arch_xgate,   /* Freescale XGATE */
+#define bfd_mach_xgate         1
   bfd_arch_xtensa,    /* Tensilica's Xtensa cores.  */
 #define bfd_mach_xtensa        1
   bfd_arch_z80,
@@ -2153,6 +2252,12 @@
   bfd_arch_tilegx, /* Tilera TILE-Gx */
 #define bfd_mach_tilepro   1
 #define bfd_mach_tilegx    1
+#define bfd_mach_tilegx32  2
+  bfd_arch_aarch64,   /* AArch64  */
+#define bfd_mach_aarch64 0
+#define bfd_mach_aarch64_ilp32 32
+  bfd_arch_nios2,
+#define bfd_mach_nios2 0
   bfd_arch_last
   };
 
@@ -2175,6 +2280,12 @@
 
   bfd_boolean (*scan) (const struct bfd_arch_info *, const char *);
 
+  /* Allocate via bfd_malloc and return a fill buffer of size COUNT.  If
+     IS_BIGENDIAN is TRUE, the order of bytes is big endian.  If CODE is
+     TRUE, the buffer contains code.  */
+  void *(*fill) (bfd_size_type count, bfd_boolean is_bigendian,
+                 bfd_boolean code);
+
   const struct bfd_arch_info *next;
 }
 bfd_arch_info_type;
@@ -2472,6 +2583,10 @@
   BFD_RELOC_HI16_S_PLTOFF,
   BFD_RELOC_8_PLTOFF,
 
+/* Size relocations.  */
+  BFD_RELOC_SIZE32,
+  BFD_RELOC_SIZE64,
+
 /* Relocations used by 68K ELF.  */
   BFD_RELOC_68K_GLOB_DAT,
   BFD_RELOC_68K_JMP_SLOT,
@@ -2585,6 +2700,10 @@
   BFD_RELOC_SPARC_M44,
   BFD_RELOC_SPARC_L44,
   BFD_RELOC_SPARC_REGISTER,
+  BFD_RELOC_SPARC_H34,
+  BFD_RELOC_SPARC_SIZE32,
+  BFD_RELOC_SPARC_SIZE64,
+  BFD_RELOC_SPARC_WDISP10,
 
 /* SPARC little endian relocation  */
   BFD_RELOC_SPARC_REV32,
@@ -2780,6 +2899,15 @@
 /* MIPS16 low 16 bits.  */
   BFD_RELOC_MIPS16_LO16,
 
+/* MIPS16 TLS relocations  */
+  BFD_RELOC_MIPS16_TLS_GD,
+  BFD_RELOC_MIPS16_TLS_LDM,
+  BFD_RELOC_MIPS16_TLS_DTPREL_HI16,
+  BFD_RELOC_MIPS16_TLS_DTPREL_LO16,
+  BFD_RELOC_MIPS16_TLS_GOTTPREL,
+  BFD_RELOC_MIPS16_TLS_TPREL_HI16,
+  BFD_RELOC_MIPS16_TLS_TPREL_LO16,
+
 /* Relocation against a MIPS literal section.  */
   BFD_RELOC_MIPS_LITERAL,
   BFD_RELOC_MICROMIPS_LITERAL,
@@ -2851,6 +2979,7 @@
   BFD_RELOC_MICROMIPS_TLS_TPREL_HI16,
   BFD_RELOC_MIPS_TLS_TPREL_LO16,
   BFD_RELOC_MICROMIPS_TLS_TPREL_LO16,
+  BFD_RELOC_MIPS_EH,
 
 
 /* MIPS ELF relocations (VxWorks and PLT extensions).  */
@@ -2941,6 +3070,25 @@
 relaxation.  */
   BFD_RELOC_MN10300_ALIGN,
 
+/* Various TLS-related relocations.  */
+  BFD_RELOC_MN10300_TLS_GD,
+  BFD_RELOC_MN10300_TLS_LD,
+  BFD_RELOC_MN10300_TLS_LDO,
+  BFD_RELOC_MN10300_TLS_GOTIE,
+  BFD_RELOC_MN10300_TLS_IE,
+  BFD_RELOC_MN10300_TLS_LE,
+  BFD_RELOC_MN10300_TLS_DTPMOD,
+  BFD_RELOC_MN10300_TLS_DTPOFF,
+  BFD_RELOC_MN10300_TLS_TPOFF,
+
+/* This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the
+instruction.  */
+  BFD_RELOC_MN10300_32_PCREL,
+
+/* This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the
+instruction.  */
+  BFD_RELOC_MN10300_16_PCREL,
+
 
 /* i386/elf relocations  */
   BFD_RELOC_386_GOT32,
@@ -2996,6 +3144,8 @@
   BFD_RELOC_X86_64_TLSDESC_CALL,
   BFD_RELOC_X86_64_TLSDESC,
   BFD_RELOC_X86_64_IRELATIVE,
+  BFD_RELOC_X86_64_PC32_BND,
+  BFD_RELOC_X86_64_PLT32_BND,
 
 /* ns32k relocations  */
   BFD_RELOC_NS32K_IMM_8,
@@ -3054,6 +3204,23 @@
   BFD_RELOC_PPC_EMB_RELST_HA,
   BFD_RELOC_PPC_EMB_BIT_FLD,
   BFD_RELOC_PPC_EMB_RELSDA,
+  BFD_RELOC_PPC_VLE_REL8,
+  BFD_RELOC_PPC_VLE_REL15,
+  BFD_RELOC_PPC_VLE_REL24,
+  BFD_RELOC_PPC_VLE_LO16A,
+  BFD_RELOC_PPC_VLE_LO16D,
+  BFD_RELOC_PPC_VLE_HI16A,
+  BFD_RELOC_PPC_VLE_HI16D,
+  BFD_RELOC_PPC_VLE_HA16A,
+  BFD_RELOC_PPC_VLE_HA16D,
+  BFD_RELOC_PPC_VLE_SDA21,
+  BFD_RELOC_PPC_VLE_SDA21_LO,
+  BFD_RELOC_PPC_VLE_SDAREL_LO16A,
+  BFD_RELOC_PPC_VLE_SDAREL_LO16D,
+  BFD_RELOC_PPC_VLE_SDAREL_HI16A,
+  BFD_RELOC_PPC_VLE_SDAREL_HI16D,
+  BFD_RELOC_PPC_VLE_SDAREL_HA16A,
+  BFD_RELOC_PPC_VLE_SDAREL_HA16D,
   BFD_RELOC_PPC64_HIGHER,
   BFD_RELOC_PPC64_HIGHER_S,
   BFD_RELOC_PPC64_HIGHEST,
@@ -3077,6 +3244,8 @@
   BFD_RELOC_PPC64_TOC16_LO_DS,
   BFD_RELOC_PPC64_PLTGOT16_DS,
   BFD_RELOC_PPC64_PLTGOT16_LO_DS,
+  BFD_RELOC_PPC64_ADDR16_HIGH,
+  BFD_RELOC_PPC64_ADDR16_HIGHA,
 
 /* PowerPC and PowerPC64 thread-local storage relocations.  */
   BFD_RELOC_PPC_TLS,
@@ -3121,6 +3290,10 @@
   BFD_RELOC_PPC64_DTPREL16_HIGHERA,
   BFD_RELOC_PPC64_DTPREL16_HIGHEST,
   BFD_RELOC_PPC64_DTPREL16_HIGHESTA,
+  BFD_RELOC_PPC64_TPREL16_HIGH,
+  BFD_RELOC_PPC64_TPREL16_HIGHA,
+  BFD_RELOC_PPC64_DTPREL16_HIGH,
+  BFD_RELOC_PPC64_DTPREL16_HIGHA,
 
 /* IBM 370/390 relocations  */
   BFD_RELOC_I370_D12,
@@ -3776,14 +3949,6 @@
 /* start data in text.  */
   BFD_RELOC_V850_DATA,
 
-/* This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the
-instruction.  */
-  BFD_RELOC_MN10300_32_PCREL,
-
-/* This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the
-instruction.  */
-  BFD_RELOC_MN10300_16_PCREL,
-
 /* This is a 8bit DP reloc for the tms320c30, where the most
 significant 8 bits of a 24 bit word are placed into the least
 significant 8 bits of the opcode.  */
@@ -3906,6 +4071,46 @@
   BFD_RELOC_MEP_GNU_VTENTRY,
 
 
+/* Imagination Technologies Meta relocations.  */
+  BFD_RELOC_METAG_HIADDR16,
+  BFD_RELOC_METAG_LOADDR16,
+  BFD_RELOC_METAG_RELBRANCH,
+  BFD_RELOC_METAG_GETSETOFF,
+  BFD_RELOC_METAG_HIOG,
+  BFD_RELOC_METAG_LOOG,
+  BFD_RELOC_METAG_REL8,
+  BFD_RELOC_METAG_REL16,
+  BFD_RELOC_METAG_HI16_GOTOFF,
+  BFD_RELOC_METAG_LO16_GOTOFF,
+  BFD_RELOC_METAG_GETSET_GOTOFF,
+  BFD_RELOC_METAG_GETSET_GOT,
+  BFD_RELOC_METAG_HI16_GOTPC,
+  BFD_RELOC_METAG_LO16_GOTPC,
+  BFD_RELOC_METAG_HI16_PLT,
+  BFD_RELOC_METAG_LO16_PLT,
+  BFD_RELOC_METAG_RELBRANCH_PLT,
+  BFD_RELOC_METAG_GOTOFF,
+  BFD_RELOC_METAG_PLT,
+  BFD_RELOC_METAG_COPY,
+  BFD_RELOC_METAG_JMP_SLOT,
+  BFD_RELOC_METAG_RELATIVE,
+  BFD_RELOC_METAG_GLOB_DAT,
+  BFD_RELOC_METAG_TLS_GD,
+  BFD_RELOC_METAG_TLS_LDM,
+  BFD_RELOC_METAG_TLS_LDO_HI16,
+  BFD_RELOC_METAG_TLS_LDO_LO16,
+  BFD_RELOC_METAG_TLS_LDO,
+  BFD_RELOC_METAG_TLS_IE,
+  BFD_RELOC_METAG_TLS_IENONPIC,
+  BFD_RELOC_METAG_TLS_IENONPIC_HI16,
+  BFD_RELOC_METAG_TLS_IENONPIC_LO16,
+  BFD_RELOC_METAG_TLS_TPOFF,
+  BFD_RELOC_METAG_TLS_DTPMOD,
+  BFD_RELOC_METAG_TLS_DTPOFF,
+  BFD_RELOC_METAG_TLS_LE,
+  BFD_RELOC_METAG_TLS_LE_HI16,
+  BFD_RELOC_METAG_TLS_LE_LO16,
+
 /* These are relocations for the GETA instruction.  */
   BFD_RELOC_MMIX_GETA,
   BFD_RELOC_MMIX_GETA_1,
@@ -4005,7 +4210,7 @@
 command address) into 8 bit immediate value of LDI insn.  */
   BFD_RELOC_AVR_LO8_LDI_PM,
 
-/* This is a 16 bit reloc for the AVR that stores 8 bit value 
+/* This is a 16 bit reloc for the AVR that stores 8 bit value
 (command address) into 8 bit immediate value of LDI insn. If the address
 is beyond the 128k boundary, the linker inserts a jump stub for this reloc
 in the lower 128k.  */
@@ -4055,6 +4260,53 @@
 instructions  */
   BFD_RELOC_AVR_6_ADIW,
 
+/* This is a 8 bit reloc for the AVR that stores bits 0..7 of a symbol
+in .byte lo8(symbol)  */
+  BFD_RELOC_AVR_8_LO,
+
+/* This is a 8 bit reloc for the AVR that stores bits 8..15 of a symbol
+in .byte hi8(symbol)  */
+  BFD_RELOC_AVR_8_HI,
+
+/* This is a 8 bit reloc for the AVR that stores bits 16..23 of a symbol
+in .byte hlo8(symbol)  */
+  BFD_RELOC_AVR_8_HLO,
+
+/* Renesas RL78 Relocations.  */
+  BFD_RELOC_RL78_NEG8,
+  BFD_RELOC_RL78_NEG16,
+  BFD_RELOC_RL78_NEG24,
+  BFD_RELOC_RL78_NEG32,
+  BFD_RELOC_RL78_16_OP,
+  BFD_RELOC_RL78_24_OP,
+  BFD_RELOC_RL78_32_OP,
+  BFD_RELOC_RL78_8U,
+  BFD_RELOC_RL78_16U,
+  BFD_RELOC_RL78_24U,
+  BFD_RELOC_RL78_DIR3U_PCREL,
+  BFD_RELOC_RL78_DIFF,
+  BFD_RELOC_RL78_GPRELB,
+  BFD_RELOC_RL78_GPRELW,
+  BFD_RELOC_RL78_GPRELL,
+  BFD_RELOC_RL78_SYM,
+  BFD_RELOC_RL78_OP_SUBTRACT,
+  BFD_RELOC_RL78_OP_NEG,
+  BFD_RELOC_RL78_OP_AND,
+  BFD_RELOC_RL78_OP_SHRA,
+  BFD_RELOC_RL78_ABS8,
+  BFD_RELOC_RL78_ABS16,
+  BFD_RELOC_RL78_ABS16_REV,
+  BFD_RELOC_RL78_ABS32,
+  BFD_RELOC_RL78_ABS32_REV,
+  BFD_RELOC_RL78_ABS16U,
+  BFD_RELOC_RL78_ABS16UW,
+  BFD_RELOC_RL78_ABS16UL,
+  BFD_RELOC_RL78_RELAX,
+  BFD_RELOC_RL78_HI16,
+  BFD_RELOC_RL78_HI8,
+  BFD_RELOC_RL78_LO16,
+  BFD_RELOC_RL78_CODE,
+
 /* Renesas RX Relocations.  */
   BFD_RELOC_RX_NEG8,
   BFD_RELOC_RX_NEG16,
@@ -4111,12 +4363,24 @@
 /* 16 bit GOT offset.  */
   BFD_RELOC_390_GOT16,
 
+/* PC relative 12 bit shifted by 1.  */
+  BFD_RELOC_390_PC12DBL,
+
+/* 12 bit PC rel. PLT shifted by 1.  */
+  BFD_RELOC_390_PLT12DBL,
+
 /* PC relative 16 bit shifted by 1.  */
   BFD_RELOC_390_PC16DBL,
 
 /* 16 bit PC rel. PLT shifted by 1.  */
   BFD_RELOC_390_PLT16DBL,
 
+/* PC relative 24 bit shifted by 1.  */
+  BFD_RELOC_390_PC24DBL,
+
+/* 24 bit PC rel. PLT shifted by 1.  */
+  BFD_RELOC_390_PLT24DBL,
+
 /* PC relative 32 bit shifted by 1.  */
   BFD_RELOC_390_PC32DBL,
 
@@ -4190,6 +4454,9 @@
   BFD_RELOC_390_GOTPLT20,
   BFD_RELOC_390_TLS_GOTIE20,
 
+/* STT_GNU_IFUNC relocation.  */
+  BFD_RELOC_390_IRELATIVE,
+
 /* Score relocations
 Low 16 bit for load/store  */
   BFD_RELOC_SCORE_GPREL15,
@@ -4404,6 +4671,83 @@
 This is the 5 bits of a value.  */
   BFD_RELOC_M68HC12_5B,
 
+/* Freescale XGATE reloc.
+This reloc marks the beginning of a bra/jal instruction.  */
+  BFD_RELOC_XGATE_RL_JUMP,
+
+/* Freescale XGATE reloc.
+This reloc marks a group of several instructions that gcc generates
+and for which the linker relaxation pass can modify and/or remove
+some of them.  */
+  BFD_RELOC_XGATE_RL_GROUP,
+
+/* Freescale XGATE reloc.
+This is the 16-bit lower part of an address.  It is used for the '16-bit'
+instructions.  */
+  BFD_RELOC_XGATE_LO16,
+
+/* Freescale XGATE reloc.  */
+  BFD_RELOC_XGATE_GPAGE,
+
+/* Freescale XGATE reloc.  */
+  BFD_RELOC_XGATE_24,
+
+/* Freescale XGATE reloc.
+This is a 9-bit pc-relative reloc.  */
+  BFD_RELOC_XGATE_PCREL_9,
+
+/* Freescale XGATE reloc.
+This is a 10-bit pc-relative reloc.  */
+  BFD_RELOC_XGATE_PCREL_10,
+
+/* Freescale XGATE reloc.
+This is the 16-bit lower part of an address.  It is used for the '16-bit'
+instructions.  */
+  BFD_RELOC_XGATE_IMM8_LO,
+
+/* Freescale XGATE reloc.
+This is the 16-bit higher part of an address.  It is used for the '16-bit'
+instructions.  */
+  BFD_RELOC_XGATE_IMM8_HI,
+
+/* Freescale XGATE reloc.
+This is a 3-bit pc-relative reloc.  */
+  BFD_RELOC_XGATE_IMM3,
+
+/* Freescale XGATE reloc.
+This is a 4-bit pc-relative reloc.  */
+  BFD_RELOC_XGATE_IMM4,
+
+/* Freescale XGATE reloc.
+This is a 5-bit pc-relative reloc.  */
+  BFD_RELOC_XGATE_IMM5,
+
+/* Motorola 68HC12 reloc.
+This is the 9 bits of a value.  */
+  BFD_RELOC_M68HC12_9B,
+
+/* Motorola 68HC12 reloc.
+This is the 16 bits of a value.  */
+  BFD_RELOC_M68HC12_16B,
+
+/* Motorola 68HC12/XGATE reloc.
+This is a PCREL9 branch.  */
+  BFD_RELOC_M68HC12_9_PCREL,
+
+/* Motorola 68HC12/XGATE reloc.
+This is a PCREL10 branch.  */
+  BFD_RELOC_M68HC12_10_PCREL,
+
+/* Motorola 68HC12/XGATE reloc.
+This is the 8 bit low part of an absolute address and immediately precedes
+a matching HI8XG part.  */
+  BFD_RELOC_M68HC12_LO8XG,
+
+/* Motorola 68HC12/XGATE reloc.
+This is the 8 bit high part of an absolute address and immediately follows
+a matching LO8XG part.  */
+  BFD_RELOC_M68HC12_HI8XG,
+
 /* NS CR16C Relocations.  */
   BFD_RELOC_16C_NUM08,
   BFD_RELOC_16C_NUM08_C,
@@ -4601,6 +4945,7 @@
   BFD_RELOC_H8_DIR24A8,
   BFD_RELOC_H8_DIR24R8,
   BFD_RELOC_H8_DIR32A16,
+  BFD_RELOC_H8_DISP32A16,
 
 /* Sony Xstormy16 Relocations.  */
   BFD_RELOC_XSTORMY16_REL_12,
@@ -4649,6 +4994,57 @@
   BFD_RELOC_MSP430_16_BYTE,
   BFD_RELOC_MSP430_2X_PCREL,
   BFD_RELOC_MSP430_RL_PCREL,
+  BFD_RELOC_MSP430_ABS8,
+  BFD_RELOC_MSP430X_PCR20_EXT_SRC,
+  BFD_RELOC_MSP430X_PCR20_EXT_DST,
+  BFD_RELOC_MSP430X_PCR20_EXT_ODST,
+  BFD_RELOC_MSP430X_ABS20_EXT_SRC,
+  BFD_RELOC_MSP430X_ABS20_EXT_DST,
+  BFD_RELOC_MSP430X_ABS20_EXT_ODST,
+  BFD_RELOC_MSP430X_ABS20_ADR_SRC,
+  BFD_RELOC_MSP430X_ABS20_ADR_DST,
+  BFD_RELOC_MSP430X_PCR16,
+  BFD_RELOC_MSP430X_PCR20_CALL,
+  BFD_RELOC_MSP430X_ABS16,
+  BFD_RELOC_MSP430_ABS_HI16,
+  BFD_RELOC_MSP430_PREL31,
+  BFD_RELOC_MSP430_SYM_DIFF,
+
+/* Relocations used by the Altera Nios II core.  */
+  BFD_RELOC_NIOS2_S16,
+  BFD_RELOC_NIOS2_U16,
+  BFD_RELOC_NIOS2_CALL26,
+  BFD_RELOC_NIOS2_IMM5,
+  BFD_RELOC_NIOS2_CACHE_OPX,
+  BFD_RELOC_NIOS2_IMM6,
+  BFD_RELOC_NIOS2_IMM8,
+  BFD_RELOC_NIOS2_HI16,
+  BFD_RELOC_NIOS2_LO16,
+  BFD_RELOC_NIOS2_HIADJ16,
+  BFD_RELOC_NIOS2_GPREL,
+  BFD_RELOC_NIOS2_UJMP,
+  BFD_RELOC_NIOS2_CJMP,
+  BFD_RELOC_NIOS2_CALLR,
+  BFD_RELOC_NIOS2_ALIGN,
+  BFD_RELOC_NIOS2_GOT16,
+  BFD_RELOC_NIOS2_CALL16,
+  BFD_RELOC_NIOS2_GOTOFF_LO,
+  BFD_RELOC_NIOS2_GOTOFF_HA,
+  BFD_RELOC_NIOS2_PCREL_LO,
+  BFD_RELOC_NIOS2_PCREL_HA,
+  BFD_RELOC_NIOS2_TLS_GD16,
+  BFD_RELOC_NIOS2_TLS_LDM16,
+  BFD_RELOC_NIOS2_TLS_LDO16,
+  BFD_RELOC_NIOS2_TLS_IE16,
+  BFD_RELOC_NIOS2_TLS_LE16,
+  BFD_RELOC_NIOS2_TLS_DTPMOD,
+  BFD_RELOC_NIOS2_TLS_DTPREL,
+  BFD_RELOC_NIOS2_TLS_TPREL,
+  BFD_RELOC_NIOS2_COPY,
+  BFD_RELOC_NIOS2_GLOB_DAT,
+  BFD_RELOC_NIOS2_JUMP_SLOT,
+  BFD_RELOC_NIOS2_RELATIVE,
+  BFD_RELOC_NIOS2_GOTOFF,
 
 /* IQ2000 Relocations.  */
   BFD_RELOC_IQ2000_OFFSET_16,
@@ -4770,6 +5166,9 @@
 BFD_RELOC_MACH_O_PAIR.  */
   BFD_RELOC_MACH_O_SECTDIFF,
 
+/* Like BFD_RELOC_MACH_O_SECTDIFF but with a local symbol.  */
+  BFD_RELOC_MACH_O_LOCAL_SECTDIFF,
+
 /* Pair of relocation.  Contains the first symbol.  */
   BFD_RELOC_MACH_O_PAIR,
 
@@ -4800,52 +5199,52 @@
 /* Same as BFD_RELOC_32_PCREL but with an implicit -4 addend.  */
   BFD_RELOC_MACH_O_X86_64_PCREL32_4,
 
-/* This is a 32 bit reloc for the microblaze that stores the 
+/* This is a 32 bit reloc for the microblaze that stores the
 low 16 bits of a value  */
   BFD_RELOC_MICROBLAZE_32_LO,
 
-/* This is a 32 bit pc-relative reloc for the microblaze that 
+/* This is a 32 bit pc-relative reloc for the microblaze that
 stores the low 16 bits of a value  */
   BFD_RELOC_MICROBLAZE_32_LO_PCREL,
 
-/* This is a 32 bit reloc for the microblaze that stores a 
+/* This is a 32 bit reloc for the microblaze that stores a
 value relative to the read-only small data area anchor  */
   BFD_RELOC_MICROBLAZE_32_ROSDA,
 
-/* This is a 32 bit reloc for the microblaze that stores a 
+/* This is a 32 bit reloc for the microblaze that stores a
 value relative to the read-write small data area anchor  */
   BFD_RELOC_MICROBLAZE_32_RWSDA,
 
-/* This is a 32 bit reloc for the microblaze to handle 
+/* This is a 32 bit reloc for the microblaze to handle
 expressions of the form "Symbol Op Symbol"  */
   BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM,
 
-/* This is a 64 bit reloc that stores the 32 bit pc relative 
-value in two words (with an imm instruction).  No relocation is 
+/* This is a 64 bit reloc that stores the 32 bit pc relative
+value in two words (with an imm instruction).  No relocation is
 done here - only used for relaxing  */
   BFD_RELOC_MICROBLAZE_64_NONE,
 
-/* This is a 64 bit reloc that stores the 32 bit pc relative 
+/* This is a 64 bit reloc that stores the 32 bit pc relative
 value in two words (with an imm instruction).  The relocation is
 PC-relative GOT offset  */
   BFD_RELOC_MICROBLAZE_64_GOTPC,
 
-/* This is a 64 bit reloc that stores the 32 bit pc relative 
+/* This is a 64 bit reloc that stores the 32 bit pc relative
 value in two words (with an imm instruction).  The relocation is
 GOT offset  */
   BFD_RELOC_MICROBLAZE_64_GOT,
 
-/* This is a 64 bit reloc that stores the 32 bit pc relative 
+/* This is a 64 bit reloc that stores the 32 bit pc relative
 value in two words (with an imm instruction).  The relocation is
 PC-relative offset into PLT  */
   BFD_RELOC_MICROBLAZE_64_PLT,
 
-/* This is a 64 bit reloc that stores the 32 bit GOT relative 
+/* This is a 64 bit reloc that stores the 32 bit GOT relative
 value in two words (with an imm instruction).  The relocation is
 relative offset from _GLOBAL_OFFSET_TABLE_  */
   BFD_RELOC_MICROBLAZE_64_GOTOFF,
 
-/* This is a 32 bit reloc that stores the 32 bit GOT relative 
+/* This is a 32 bit reloc that stores the 32 bit GOT relative
 value in a word.  The relocation is relative offset from  */
   BFD_RELOC_MICROBLAZE_32_GOTOFF,
 
@@ -4853,6 +5252,325 @@
 the dynamic object into the runtime process image.  */
   BFD_RELOC_MICROBLAZE_COPY,
 
+/* Unused Reloc  */
+  BFD_RELOC_MICROBLAZE_64_TLS,
+
+/* This is a 64 bit reloc that stores the 32 bit GOT relative value
+of the GOT TLS GD info entry in two words (with an imm instruction). The
+relocation is GOT offset.  */
+  BFD_RELOC_MICROBLAZE_64_TLSGD,
+
+/* This is a 64 bit reloc that stores the 32 bit GOT relative value
+of the GOT TLS LD info entry in two words (with an imm instruction). The
+relocation is GOT offset.  */
+  BFD_RELOC_MICROBLAZE_64_TLSLD,
+
+/* This is a 32 bit reloc that stores the Module ID to GOT(n).  */
+  BFD_RELOC_MICROBLAZE_32_TLSDTPMOD,
+
+/* This is a 32 bit reloc that stores TLS offset to GOT(n+1).  */
+  BFD_RELOC_MICROBLAZE_32_TLSDTPREL,
+
+/* This is a 32 bit reloc for storing TLS offset to two words (uses imm
+instruction)  */
+  BFD_RELOC_MICROBLAZE_64_TLSDTPREL,
+
+/* This is a 64 bit reloc that stores 32-bit thread pointer relative offset
+to two words (uses imm instruction).  */
+  BFD_RELOC_MICROBLAZE_64_TLSGOTTPREL,
+
+/* This is a 64 bit reloc that stores 32-bit thread pointer relative offset
+to two words (uses imm instruction).  */
+  BFD_RELOC_MICROBLAZE_64_TLSTPREL,
+
+/* AArch64 pseudo relocation code to mark the start of the AArch64
+relocation enumerators.  N.B. the order of the enumerators is
+important as several tables in the AArch64 bfd backend are indexed
+by these enumerators; make sure they are all synced.  */
+  BFD_RELOC_AARCH64_RELOC_START,
+
+/* AArch64 null relocation code.  */
+  BFD_RELOC_AARCH64_NONE,
+
+/* Basic absolute relocations of N bits.  These are equivalent to
+BFD_RELOC_N and they were added to assist the indexing of the howto
+table.  */
+  BFD_RELOC_AARCH64_64,
+  BFD_RELOC_AARCH64_32,
+  BFD_RELOC_AARCH64_16,
+
+/* PC-relative relocations.  These are equivalent to BFD_RELOC_N_PCREL
+and they were added to assist the indexing of the howto table.  */
+  BFD_RELOC_AARCH64_64_PCREL,
+  BFD_RELOC_AARCH64_32_PCREL,
+  BFD_RELOC_AARCH64_16_PCREL,
+
+/* AArch64 MOV[NZK] instruction with most significant bits 0 to 15
+of an unsigned address/value.  */
+  BFD_RELOC_AARCH64_MOVW_G0,
+
+/* AArch64 MOV[NZK] instruction with less significant bits 0 to 15 of
+an address/value.  No overflow checking.  */
+  BFD_RELOC_AARCH64_MOVW_G0_NC,
+
+/* AArch64 MOV[NZK] instruction with most significant bits 16 to 31
+of an unsigned address/value.  */
+  BFD_RELOC_AARCH64_MOVW_G1,
+
+/* AArch64 MOV[NZK] instruction with less significant bits 16 to 31
+of an address/value.  No overflow checking.  */
+  BFD_RELOC_AARCH64_MOVW_G1_NC,
+
+/* AArch64 MOV[NZK] instruction with most significant bits 32 to 47
+of an unsigned address/value.  */
+  BFD_RELOC_AARCH64_MOVW_G2,
+
+/* AArch64 MOV[NZK] instruction with less significant bits 32 to 47
+of an address/value.  No overflow checking.  */
+  BFD_RELOC_AARCH64_MOVW_G2_NC,
+
+/* AArch64 MOV[NZK] instruction with most signficant bits 48 to 64
+of a signed or unsigned address/value.  */
+  BFD_RELOC_AARCH64_MOVW_G3,
+
+/* AArch64 MOV[NZ] instruction with most significant bits 0 to 15
+of a signed value.  Changes instruction to MOVZ or MOVN depending on the
+value's sign.  */
+  BFD_RELOC_AARCH64_MOVW_G0_S,
+
+/* AArch64 MOV[NZ] instruction with most significant bits 16 to 31
+of a signed value.  Changes instruction to MOVZ or MOVN depending on the
+value's sign.  */
+  BFD_RELOC_AARCH64_MOVW_G1_S,
+
+/* AArch64 MOV[NZ] instruction with most significant bits 32 to 47
+of a signed value.  Changes instruction to MOVZ or MOVN depending on the
+value's sign.  */
+  BFD_RELOC_AARCH64_MOVW_G2_S,
+
+/* AArch64 Load Literal instruction, holding a 19 bit pc-relative word
+offset.  The lowest two bits must be zero and are not stored in the
+instruction, giving a 21 bit signed byte offset.  */
+  BFD_RELOC_AARCH64_LD_LO19_PCREL,
+
+/* AArch64 ADR instruction, holding a simple 21 bit pc-relative byte offset.  */
+  BFD_RELOC_AARCH64_ADR_LO21_PCREL,
+
+/* AArch64 ADRP instruction, with bits 12 to 32 of a pc-relative page
+offset, giving a 4KB aligned page base address.  */
+  BFD_RELOC_AARCH64_ADR_HI21_PCREL,
+
+/* AArch64 ADRP instruction, with bits 12 to 32 of a pc-relative page
+offset, giving a 4KB aligned page base address, but with no overflow
+checking.  */
+  BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL,
+
+/* AArch64 ADD immediate instruction, holding bits 0 to 11 of the address.
+Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.  */
+  BFD_RELOC_AARCH64_ADD_LO12,
+
+/* AArch64 8-bit load/store instruction, holding bits 0 to 11 of the
+address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.  */
+  BFD_RELOC_AARCH64_LDST8_LO12,
+
+/* AArch64 14 bit pc-relative test bit and branch.
+The lowest two bits must be zero and are not stored in the instruction,
+giving a 16 bit signed byte offset.  */
+  BFD_RELOC_AARCH64_TSTBR14,
+
+/* AArch64 19 bit pc-relative conditional branch and compare & branch.
+The lowest two bits must be zero and are not stored in the instruction,
+giving a 21 bit signed byte offset.  */
+  BFD_RELOC_AARCH64_BRANCH19,
+
+/* AArch64 26 bit pc-relative unconditional branch.
+The lowest two bits must be zero and are not stored in the instruction,
+giving a 28 bit signed byte offset.  */
+  BFD_RELOC_AARCH64_JUMP26,
+
+/* AArch64 26 bit pc-relative unconditional branch and link.
+The lowest two bits must be zero and are not stored in the instruction,
+giving a 28 bit signed byte offset.  */
+  BFD_RELOC_AARCH64_CALL26,
+
+/* AArch64 16-bit load/store instruction, holding bits 0 to 11 of the
+address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.  */
+  BFD_RELOC_AARCH64_LDST16_LO12,
+
+/* AArch64 32-bit load/store instruction, holding bits 0 to 11 of the
+address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.  */
+  BFD_RELOC_AARCH64_LDST32_LO12,
+
+/* AArch64 64-bit load/store instruction, holding bits 0 to 11 of the
+address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.  */
+  BFD_RELOC_AARCH64_LDST64_LO12,
+
+/* AArch64 128-bit load/store instruction, holding bits 0 to 11 of the
+address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.  */
+  BFD_RELOC_AARCH64_LDST128_LO12,
+
+/* AArch64 Load Literal instruction, holding a 19 bit PC relative word
+offset of the global offset table entry for a symbol.  The lowest two
+bits must be zero and are not stored in the instruction, giving a 21
+bit signed byte offset.  This relocation type requires signed overflow
+checking.  */
+  BFD_RELOC_AARCH64_GOT_LD_PREL19,
+
+/* Get to the page base of the global offset table entry for a symbol as
+part of an ADRP instruction using a 21 bit PC relative value.Used in
+conjunction with BFD_RELOC_AARCH64_LD64_GOT_LO12_NC.  */
+  BFD_RELOC_AARCH64_ADR_GOT_PAGE,
+
+/* Unsigned 12 bit byte offset for 64 bit load/store from the page of
+the GOT entry for this symbol.  Used in conjunction with
+BFD_RELOC_AARCH64_ADR_GOTPAGE.  Valid in LP64 ABI only.  */
+  BFD_RELOC_AARCH64_LD64_GOT_LO12_NC,
+
+/* Unsigned 12 bit byte offset for 32 bit load/store from the page of
+the GOT entry for this symbol.  Used in conjunction with
+BFD_RELOC_AARCH64_ADR_GOTPAGE.  Valid in ILP32 ABI only.  */
+  BFD_RELOC_AARCH64_LD32_GOT_LO12_NC,
+
+/* Get to the page base of the global offset table entry for a symbols
+tls_index structure as part of an adrp instruction using a 21 bit PC
+relative value.  Used in conjunction with
+BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC.  */
+  BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21,
+
+/* Unsigned 12 bit byte offset to global offset table entry for a symbols
+tls_index structure.  Used in conjunction with
+BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21.  */
+  BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC,
+
+/* AArch64 TLS INITIAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1,
+
+/* AArch64 TLS INITIAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC,
+
+/* AArch64 TLS INITIAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21,
+
+/* AArch64 TLS INITIAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC,
+
+/* AArch64 TLS INITIAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC,
+
+/* AArch64 TLS INITIAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19,
+
+/* AArch64 TLS LOCAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2,
+
+/* AArch64 TLS LOCAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1,
+
+/* AArch64 TLS LOCAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC,
+
+/* AArch64 TLS LOCAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0,
+
+/* AArch64 TLS LOCAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC,
+
+/* AArch64 TLS LOCAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12,
+
+/* AArch64 TLS LOCAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12,
+
+/* AArch64 TLS LOCAL EXEC relocation.  */
+  BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC,
+
+/* AArch64 TLS DESC relocation.  */
+  BFD_RELOC_AARCH64_TLSDESC_LD_PREL19,
+
+/* AArch64 TLS DESC relocation.  */
+  BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21,
+
+/* AArch64 TLS DESC relocation.  */
+  BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21,
+
+/* AArch64 TLS DESC relocation.  */
+  BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC,
+
+/* AArch64 TLS DESC relocation.  */
+  BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC,
+
+/* AArch64 TLS DESC relocation.  */
+  BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC,
+
+/* AArch64 TLS DESC relocation.  */
+  BFD_RELOC_AARCH64_TLSDESC_OFF_G1,
+
+/* AArch64 TLS DESC relocation.  */
+  BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC,
+
+/* AArch64 TLS DESC relocation.  */
+  BFD_RELOC_AARCH64_TLSDESC_LDR,
+
+/* AArch64 TLS DESC relocation.  */
+  BFD_RELOC_AARCH64_TLSDESC_ADD,
+
+/* AArch64 TLS DESC relocation.  */
+  BFD_RELOC_AARCH64_TLSDESC_CALL,
+
+/* AArch64 TLS relocation.  */
+  BFD_RELOC_AARCH64_COPY,
+
+/* AArch64 TLS relocation.  */
+  BFD_RELOC_AARCH64_GLOB_DAT,
+
+/* AArch64 TLS relocation.  */
+  BFD_RELOC_AARCH64_JUMP_SLOT,
+
+/* AArch64 TLS relocation.  */
+  BFD_RELOC_AARCH64_RELATIVE,
+
+/* AArch64 TLS relocation.  */
+  BFD_RELOC_AARCH64_TLS_DTPMOD,
+
+/* AArch64 TLS relocation.  */
+  BFD_RELOC_AARCH64_TLS_DTPREL,
+
+/* AArch64 TLS relocation.  */
+  BFD_RELOC_AARCH64_TLS_TPREL,
+
+/* AArch64 TLS relocation.  */
+  BFD_RELOC_AARCH64_TLSDESC,
+
+/* AArch64 support for STT_GNU_IFUNC.  */
+  BFD_RELOC_AARCH64_IRELATIVE,
+
+/* AArch64 pseudo relocation code to mark the end of the AArch64
+relocation enumerators that have direct mapping to ELF reloc codes.
+There are a few more enumerators after this one; those are mainly
+used by the AArch64 assembler for the internal fixup or to select
+one of the above enumerators.  */
+  BFD_RELOC_AARCH64_RELOC_END,
+
+/* AArch64 pseudo relocation code to be used internally by the AArch64
+assembler and not (currently) written to any object files.  */
+  BFD_RELOC_AARCH64_GAS_INTERNAL_FIXUP,
+
+/* AArch64 unspecified load/store instruction, holding bits 0 to 11 of the
+address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.  */
+  BFD_RELOC_AARCH64_LDST_LO12,
+
+/* AArch64 pseudo relocation code to be used internally by the AArch64
+assembler and not (currently) written to any object files.  */
+  BFD_RELOC_AARCH64_LD_GOT_LO12_NC,
+
+/* AArch64 pseudo relocation code to be used internally by the AArch64
+assembler and not (currently) written to any object files.  */
+  BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC,
+
+/* AArch64 pseudo relocation code to be used internally by the AArch64
+assembler and not (currently) written to any object files.  */
+  BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC,
+
 /* Tilera TILEPro Relocations.  */
   BFD_RELOC_TILEPRO_COPY,
   BFD_RELOC_TILEPRO_GLOB_DAT,
@@ -4900,6 +5618,12 @@
   BFD_RELOC_TILEPRO_SHAMT_X1,
   BFD_RELOC_TILEPRO_SHAMT_Y0,
   BFD_RELOC_TILEPRO_SHAMT_Y1,
+  BFD_RELOC_TILEPRO_TLS_GD_CALL,
+  BFD_RELOC_TILEPRO_IMM8_X0_TLS_GD_ADD,
+  BFD_RELOC_TILEPRO_IMM8_X1_TLS_GD_ADD,
+  BFD_RELOC_TILEPRO_IMM8_Y0_TLS_GD_ADD,
+  BFD_RELOC_TILEPRO_IMM8_Y1_TLS_GD_ADD,
+  BFD_RELOC_TILEPRO_TLS_IE_LOAD,
   BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD,
   BFD_RELOC_TILEPRO_IMM16_X1_TLS_GD,
   BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD_LO,
@@ -4919,6 +5643,14 @@
   BFD_RELOC_TILEPRO_TLS_DTPMOD32,
   BFD_RELOC_TILEPRO_TLS_DTPOFF32,
   BFD_RELOC_TILEPRO_TLS_TPOFF32,
+  BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE,
+  BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE,
+  BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_LO,
+  BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_LO,
+  BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_HI,
+  BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_HI,
+  BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_HA,
+  BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_HA,
 
 /* Tilera TILE-Gx Relocations.  */
   BFD_RELOC_TILEGX_HW0,
@@ -4978,52 +5710,79 @@
   BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_PCREL,
   BFD_RELOC_TILEGX_IMM16_X0_HW0_GOT,
   BFD_RELOC_TILEGX_IMM16_X1_HW0_GOT,
-  BFD_RELOC_TILEGX_IMM16_X0_HW1_GOT,
-  BFD_RELOC_TILEGX_IMM16_X1_HW1_GOT,
-  BFD_RELOC_TILEGX_IMM16_X0_HW2_GOT,
-  BFD_RELOC_TILEGX_IMM16_X1_HW2_GOT,
-  BFD_RELOC_TILEGX_IMM16_X0_HW3_GOT,
-  BFD_RELOC_TILEGX_IMM16_X1_HW3_GOT,
+  BFD_RELOC_TILEGX_IMM16_X0_HW0_PLT_PCREL,
+  BFD_RELOC_TILEGX_IMM16_X1_HW0_PLT_PCREL,
+  BFD_RELOC_TILEGX_IMM16_X0_HW1_PLT_PCREL,
+  BFD_RELOC_TILEGX_IMM16_X1_HW1_PLT_PCREL,
+  BFD_RELOC_TILEGX_IMM16_X0_HW2_PLT_PCREL,
+  BFD_RELOC_TILEGX_IMM16_X1_HW2_PLT_PCREL,
   BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_GOT,
   BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_GOT,
   BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_GOT,
   BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_GOT,
-  BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_GOT,
-  BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_GOT,
+  BFD_RELOC_TILEGX_IMM16_X0_HW3_PLT_PCREL,
+  BFD_RELOC_TILEGX_IMM16_X1_HW3_PLT_PCREL,
   BFD_RELOC_TILEGX_IMM16_X0_HW0_TLS_GD,
   BFD_RELOC_TILEGX_IMM16_X1_HW0_TLS_GD,
-  BFD_RELOC_TILEGX_IMM16_X0_HW1_TLS_GD,
-  BFD_RELOC_TILEGX_IMM16_X1_HW1_TLS_GD,
-  BFD_RELOC_TILEGX_IMM16_X0_HW2_TLS_GD,
-  BFD_RELOC_TILEGX_IMM16_X1_HW2_TLS_GD,
-  BFD_RELOC_TILEGX_IMM16_X0_HW3_TLS_GD,
-  BFD_RELOC_TILEGX_IMM16_X1_HW3_TLS_GD,
+  BFD_RELOC_TILEGX_IMM16_X0_HW0_TLS_LE,
+  BFD_RELOC_TILEGX_IMM16_X1_HW0_TLS_LE,
+  BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_TLS_LE,
+  BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_TLS_LE,
+  BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_TLS_LE,
+  BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_TLS_LE,
   BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_TLS_GD,
   BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_TLS_GD,
   BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_TLS_GD,
   BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_TLS_GD,
-  BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_TLS_GD,
-  BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_TLS_GD,
   BFD_RELOC_TILEGX_IMM16_X0_HW0_TLS_IE,
   BFD_RELOC_TILEGX_IMM16_X1_HW0_TLS_IE,
-  BFD_RELOC_TILEGX_IMM16_X0_HW1_TLS_IE,
-  BFD_RELOC_TILEGX_IMM16_X1_HW1_TLS_IE,
-  BFD_RELOC_TILEGX_IMM16_X0_HW2_TLS_IE,
-  BFD_RELOC_TILEGX_IMM16_X1_HW2_TLS_IE,
-  BFD_RELOC_TILEGX_IMM16_X0_HW3_TLS_IE,
-  BFD_RELOC_TILEGX_IMM16_X1_HW3_TLS_IE,
+  BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL,
+  BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL,
+  BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL,
+  BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL,
+  BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL,
+  BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL,
   BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_TLS_IE,
   BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_TLS_IE,
   BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_TLS_IE,
   BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_TLS_IE,
-  BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_TLS_IE,
-  BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_TLS_IE,
   BFD_RELOC_TILEGX_TLS_DTPMOD64,
   BFD_RELOC_TILEGX_TLS_DTPOFF64,
   BFD_RELOC_TILEGX_TLS_TPOFF64,
   BFD_RELOC_TILEGX_TLS_DTPMOD32,
   BFD_RELOC_TILEGX_TLS_DTPOFF32,
   BFD_RELOC_TILEGX_TLS_TPOFF32,
+  BFD_RELOC_TILEGX_TLS_GD_CALL,
+  BFD_RELOC_TILEGX_IMM8_X0_TLS_GD_ADD,
+  BFD_RELOC_TILEGX_IMM8_X1_TLS_GD_ADD,
+  BFD_RELOC_TILEGX_IMM8_Y0_TLS_GD_ADD,
+  BFD_RELOC_TILEGX_IMM8_Y1_TLS_GD_ADD,
+  BFD_RELOC_TILEGX_TLS_IE_LOAD,
+  BFD_RELOC_TILEGX_IMM8_X0_TLS_ADD,
+  BFD_RELOC_TILEGX_IMM8_X1_TLS_ADD,
+  BFD_RELOC_TILEGX_IMM8_Y0_TLS_ADD,
+  BFD_RELOC_TILEGX_IMM8_Y1_TLS_ADD,
+
+/* Adapteva EPIPHANY - 8 bit signed pc-relative displacement  */
+  BFD_RELOC_EPIPHANY_SIMM8,
+
+/* Adapteva EPIPHANY - 24 bit signed pc-relative displacement  */
+  BFD_RELOC_EPIPHANY_SIMM24,
+
+/* Adapteva EPIPHANY - 16 most-significant bits of absolute address  */
+  BFD_RELOC_EPIPHANY_HIGH,
+
+/* Adapteva EPIPHANY - 16 least-significant bits of absolute address  */
+  BFD_RELOC_EPIPHANY_LOW,
+
+/* Adapteva EPIPHANY - 11 bit signed number - add/sub immediate  */
+  BFD_RELOC_EPIPHANY_SIMM11,
+
+/* Adapteva EPIPHANY - 11 bit sign-magnitude number (ld/st displacement)  */
+  BFD_RELOC_EPIPHANY_IMM11,
+
+/* Adapteva EPIPHANY - 8 bit immediate for 16 bit mov instruction.  */
+  BFD_RELOC_EPIPHANY_IMM8,
   BFD_RELOC_UNUSED };
 typedef enum bfd_reloc_code_real bfd_reloc_code_real_type;
 reloc_howto_type *bfd_reloc_type_lookup
@@ -5497,6 +6256,14 @@
   unsigned int selective_search : 1;
 };
 
+/* See note beside bfd_set_section_userdata.  */
+static inline bfd_boolean
+bfd_set_cacheable (bfd * abfd, bfd_boolean val)
+{
+  abfd->cacheable = val;
+  return TRUE;
+}
+
 typedef enum bfd_error
 {
   bfd_error_no_error = 0,
@@ -5510,6 +6277,7 @@
   bfd_error_no_armap,
   bfd_error_no_more_archived_files,
   bfd_error_malformed_archive,
+  bfd_error_missing_dso,
   bfd_error_file_not_recognized,
   bfd_error_file_ambiguously_recognized,
   bfd_error_no_contents,
@@ -5539,6 +6307,15 @@
 
 bfd_error_handler_type bfd_get_error_handler (void);
 
+typedef void (*bfd_assert_handler_type) (const char *bfd_formatmsg,
+                                         const char *bfd_version,
+                                         const char *bfd_file,
+                                         int bfd_line);
+
+bfd_assert_handler_type bfd_set_assert_handler (bfd_assert_handler_type);
+
+bfd_assert_handler_type bfd_get_assert_handler (void);
+
 long bfd_get_reloc_upper_bound (bfd *abfd, asection *sect);
 
 long bfd_canonicalize_reloc
@@ -5624,8 +6401,8 @@
 #define bfd_gc_sections(abfd, link_info) \
        BFD_SEND (abfd, _bfd_gc_sections, (abfd, link_info))
 
-#define bfd_lookup_section_flags(link_info, flag_info) \
-       BFD_SEND (abfd, _bfd_lookup_section_flags, (link_info, flag_info))
+#define bfd_lookup_section_flags(link_info, flag_info, section) \
+       BFD_SEND (abfd, _bfd_lookup_section_flags, (link_info, flag_info, section))
 
 #define bfd_merge_sections(abfd, link_info) \
        BFD_SEND (abfd, _bfd_merge_sections, (abfd, link_info))
@@ -5679,24 +6456,6 @@
 
 bfd_boolean bfd_alt_mach_code (bfd *abfd, int alternative);
 
-struct bfd_preserve
-{
-  void *marker;
-  void *tdata;
-  flagword flags;
-  const struct bfd_arch_info *arch_info;
-  struct bfd_section *sections;
-  struct bfd_section *section_last;
-  unsigned int section_count;
-  struct bfd_hash_table section_htab;
-};
-
-bfd_boolean bfd_preserve_save (bfd *, struct bfd_preserve *);
-
-void bfd_preserve_restore (bfd *, struct bfd_preserve *);
-
-void bfd_preserve_finish (bfd *, struct bfd_preserve *);
-
 bfd_vma bfd_emul_get_maxpagesize (const char *);
 
 void bfd_emul_set_maxpagesize (const char *, bfd_vma);
@@ -6105,8 +6864,9 @@
   bfd_boolean (*_bfd_gc_sections) (bfd *, struct bfd_link_info *);
 
   /* Sets the bitmask of allowed and disallowed section flags.  */
-  void (*_bfd_lookup_section_flags) (struct bfd_link_info *,
-                                     struct flag_info *);
+  bfd_boolean (*_bfd_lookup_section_flags) (struct bfd_link_info *,
+                                            struct flag_info *,
+                                            asection *);
 
   /* Attempt to merge SEC_MERGE sections.  */
   bfd_boolean (*_bfd_merge_sections) (bfd *, struct bfd_link_info *);
@@ -6222,6 +6982,9 @@
 bfd_boolean bfd_get_full_section_contents
    (bfd *abfd, asection *section, bfd_byte **ptr);
 
+void bfd_cache_section_contents
+   (asection *sec, void *contents);
+
 bfd_boolean bfd_is_section_compressed
    (bfd *abfd, asection *section);
 
diff --git a/bfd/bfd.c b/bfd/bfd.c
index 2871e2e..2d174f3 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1,7 +1,5 @@
 /* Generic BFD library interface and support routines.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright 1990-2013 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -22,6 +20,9 @@
    MA 02110-1301, USA.  */
 
 /*
+INODE
+typedef bfd, Error reporting, BFD front end, BFD front end
+
 SECTION
 	<<typedef bfd>>
 
@@ -310,6 +311,14 @@
 .  unsigned int selective_search : 1;
 .};
 .
+.{* See note beside bfd_set_section_userdata.  *}
+.static inline bfd_boolean
+.bfd_set_cacheable (bfd * abfd, bfd_boolean val)
+.{
+.  abfd->cacheable = val;
+.  return TRUE;
+.}
+.
 */
 
 #include "sysdep.h"
@@ -340,6 +349,9 @@
    where it is needed.  The typedef's used are defined in bfd.h */
 
 /*
+INODE
+Error reporting, Miscellaneous, typedef bfd, BFD front end
+
 SECTION
 	Error reporting
 
@@ -374,6 +386,7 @@
 .  bfd_error_no_armap,
 .  bfd_error_no_more_archived_files,
 .  bfd_error_malformed_archive,
+.  bfd_error_missing_dso,
 .  bfd_error_file_not_recognized,
 .  bfd_error_file_ambiguously_recognized,
 .  bfd_error_no_contents,
@@ -406,6 +419,7 @@
   N_("Archive has no index; run ranlib to add one"),
   N_("No more archived files"),
   N_("Malformed archive"),
+  N_("DSO missing from command line"),
   N_("File format not recognized"),
   N_("File format is ambiguous"),
   N_("Section has no contents"),
@@ -727,7 +741,9 @@
   vfprintf (stderr, new_fmt, ap);
   va_end (ap);
 
-  putc ('\n', stderr);
+  /* On AIX, putc is implemented as a macro that triggers a -Wunused-value
+     warning, so use the fputc function to avoid it.  */
+  fputc ('\n', stderr);
   fflush (stderr);
 }
 
@@ -797,8 +813,93 @@
 {
   return _bfd_error_handler;
 }
+
+/*
+SUBSECTION
+	BFD assert handler
+
+	If BFD finds an internal inconsistency, the bfd assert
+	handler is called with information on the BFD version, BFD
+	source file and line.  If this happens, most programs linked
+	against BFD are expected to want to exit with an error, or mark
+	the current BFD operation as failed, so it is recommended to
+	override the default handler, which just calls
+	_bfd_error_handler and continues.
+
+CODE_FRAGMENT
+.
+.typedef void (*bfd_assert_handler_type) (const char *bfd_formatmsg,
+.                                         const char *bfd_version,
+.                                         const char *bfd_file,
+.                                         int bfd_line);
+.
+*/
+
+/* Note the use of bfd_ prefix on the parameter names above: we want to
+   show which one is the message and which is the version by naming the
+   parameters, but avoid polluting the program-using-bfd namespace as
+   the typedef is visible in the exported headers that the program
+   includes.  Below, it's just for consistency.  */
+
+static void
+_bfd_default_assert_handler (const char *bfd_formatmsg,
+			     const char *bfd_version,
+			     const char *bfd_file,
+			     int bfd_line)
+
+{
+  (*_bfd_error_handler) (bfd_formatmsg, bfd_version, bfd_file, bfd_line);
+}
+
+/* Similar to _bfd_error_handler, a program can decide to exit on an
+   internal BFD error.  We use a non-variadic type to simplify passing
+   on parameters to other functions, e.g. _bfd_error_handler.  */
+
+bfd_assert_handler_type _bfd_assert_handler = _bfd_default_assert_handler;
+
+/*
+FUNCTION
+	bfd_set_assert_handler
+
+SYNOPSIS
+	bfd_assert_handler_type bfd_set_assert_handler (bfd_assert_handler_type);
+
+DESCRIPTION
+	Set the BFD assert handler function.  Returns the previous
+	function.
+*/
+
+bfd_assert_handler_type
+bfd_set_assert_handler (bfd_assert_handler_type pnew)
+{
+  bfd_assert_handler_type pold;
+
+  pold = _bfd_assert_handler;
+  _bfd_assert_handler = pnew;
+  return pold;
+}
+
+/*
+FUNCTION
+	bfd_get_assert_handler
+
+SYNOPSIS
+	bfd_assert_handler_type bfd_get_assert_handler (void);
+
+DESCRIPTION
+	Return the BFD assert handler function.
+*/
+
+bfd_assert_handler_type
+bfd_get_assert_handler (void)
+{
+  return _bfd_assert_handler;
+}
 
 /*
+INODE
+Miscellaneous, Memory Usage, Error reporting, BFD front end
+
 SECTION
 	Miscellaneous
 
@@ -942,8 +1043,8 @@
 void
 bfd_assert (const char *file, int line)
 {
-  (*_bfd_error_handler) (_("BFD %s assertion fail %s:%d"),
-			 BFD_VERSION_STRING, file, line);
+  (*_bfd_assert_handler) (_("BFD %s assertion fail %s:%d"),
+			  BFD_VERSION_STRING, file, line);
 }
 
 /* A more or less friendly abort message.  In libbfd.h abort is
@@ -1379,8 +1480,8 @@
 .#define bfd_gc_sections(abfd, link_info) \
 .	BFD_SEND (abfd, _bfd_gc_sections, (abfd, link_info))
 .
-.#define bfd_lookup_section_flags(link_info, flag_info) \
-.	BFD_SEND (abfd, _bfd_lookup_section_flags, (link_info, flag_info))
+.#define bfd_lookup_section_flags(link_info, flag_info, section) \
+.	BFD_SEND (abfd, _bfd_lookup_section_flags, (link_info, flag_info, section))
 .
 .#define bfd_merge_sections(abfd, link_info) \
 .	BFD_SEND (abfd, _bfd_merge_sections, (abfd, link_info))
@@ -1498,7 +1599,7 @@
   if (count > 0)
     memcpy (m->sections, secs, count * sizeof (asection *));
 
-  for (pm = &elf_tdata (abfd)->segment_map; *pm != NULL; pm = &(*pm)->next)
+  for (pm = &elf_seg_map (abfd); *pm != NULL; pm = &(*pm)->next)
     ;
   *pm = m;
 
@@ -1605,128 +1706,6 @@
 }
 
 /*
-CODE_FRAGMENT
-
-.struct bfd_preserve
-.{
-.  void *marker;
-.  void *tdata;
-.  flagword flags;
-.  const struct bfd_arch_info *arch_info;
-.  struct bfd_section *sections;
-.  struct bfd_section *section_last;
-.  unsigned int section_count;
-.  struct bfd_hash_table section_htab;
-.};
-.
-*/
-
-/*
-FUNCTION
-	bfd_preserve_save
-
-SYNOPSIS
-	bfd_boolean bfd_preserve_save (bfd *, struct bfd_preserve *);
-
-DESCRIPTION
-	When testing an object for compatibility with a particular
-	target back-end, the back-end object_p function needs to set
-	up certain fields in the bfd on successfully recognizing the
-	object.  This typically happens in a piecemeal fashion, with
-	failures possible at many points.  On failure, the bfd is
-	supposed to be restored to its initial state, which is
-	virtually impossible.  However, restoring a subset of the bfd
-	state works in practice.  This function stores the subset and
-	reinitializes the bfd.
-
-*/
-
-bfd_boolean
-bfd_preserve_save (bfd *abfd, struct bfd_preserve *preserve)
-{
-  preserve->tdata = abfd->tdata.any;
-  preserve->arch_info = abfd->arch_info;
-  preserve->flags = abfd->flags;
-  preserve->sections = abfd->sections;
-  preserve->section_last = abfd->section_last;
-  preserve->section_count = abfd->section_count;
-  preserve->section_htab = abfd->section_htab;
-
-  if (! bfd_hash_table_init (&abfd->section_htab, bfd_section_hash_newfunc,
-			     sizeof (struct section_hash_entry)))
-    return FALSE;
-
-  abfd->tdata.any = NULL;
-  abfd->arch_info = &bfd_default_arch_struct;
-  abfd->flags &= BFD_FLAGS_SAVED;
-  abfd->sections = NULL;
-  abfd->section_last = NULL;
-  abfd->section_count = 0;
-
-  return TRUE;
-}
-
-/*
-FUNCTION
-	bfd_preserve_restore
-
-SYNOPSIS
-	void bfd_preserve_restore (bfd *, struct bfd_preserve *);
-
-DESCRIPTION
-	This function restores bfd state saved by bfd_preserve_save.
-	If MARKER is non-NULL in struct bfd_preserve then that block
-	and all subsequently bfd_alloc'd memory is freed.
-
-*/
-
-void
-bfd_preserve_restore (bfd *abfd, struct bfd_preserve *preserve)
-{
-  bfd_hash_table_free (&abfd->section_htab);
-
-  abfd->tdata.any = preserve->tdata;
-  abfd->arch_info = preserve->arch_info;
-  abfd->flags = preserve->flags;
-  abfd->section_htab = preserve->section_htab;
-  abfd->sections = preserve->sections;
-  abfd->section_last = preserve->section_last;
-  abfd->section_count = preserve->section_count;
-
-  /* bfd_release frees all memory more recently bfd_alloc'd than
-     its arg, as well as its arg.  */
-  if (preserve->marker != NULL)
-    {
-      bfd_release (abfd, preserve->marker);
-      preserve->marker = NULL;
-    }
-}
-
-/*
-FUNCTION
-	bfd_preserve_finish
-
-SYNOPSIS
-	void bfd_preserve_finish (bfd *, struct bfd_preserve *);
-
-DESCRIPTION
-	This function should be called when the bfd state saved by
-	bfd_preserve_save is no longer needed.  ie. when the back-end
-	object_p function returns with success.
-
-*/
-
-void
-bfd_preserve_finish (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_preserve *preserve)
-{
-  /* It would be nice to be able to free more memory here, eg. old
-     tdata, but that's not possible since these blocks are sitting
-     inside bfd_alloc'd memory.  The section hash is on a separate
-     objalloc.  */
-  bfd_hash_table_free (&preserve->section_htab);
-}
-
-/*
 FUNCTION
 	bfd_emul_get_maxpagesize
 
diff --git a/bfd/bfd.m4 b/bfd/bfd.m4
index 394c41a..7f86aab 100644
--- a/bfd/bfd.m4
+++ b/bfd/bfd.m4
@@ -1,5 +1,21 @@
 dnl This file was derived from acinclude.m4.
-
+dnl
+dnl   Copyright 2012 Free Software Foundation
+dnl
+dnl This file is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3 of the License, or
+dnl (at your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; see the file COPYING3.  If not see
+dnl <http://www.gnu.org/licenses/>.
+dnl
 
 dnl Check for existence of a type $1 in sys/procfs.h
 
diff --git a/bfd/bfdio.c b/bfd/bfdio.c
index 841c781..363402e 100644
--- a/bfd/bfdio.c
+++ b/bfd/bfdio.c
@@ -1,8 +1,6 @@
 /* Low-level I/O routines for BFDs.
 
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011
-   Free Software Foundation, Inc.
+   Copyright 1990-2013 Free Software Foundation, Inc.
 
    Written by Cygnus Support.
 
@@ -87,10 +85,9 @@
 real_fopen (const char *filename, const char *modes)
 {
 #ifdef VMS
-  char vms_modes[4];
   char *vms_attr;
 
-  /* On VMS, fopen allows file attributes as optionnal arguments.
+  /* On VMS, fopen allows file attributes as optional arguments.
      We need to use them but we'd better to use the common prototype.
      In fopen-vms.h, they are separated from the mode with a comma.
      Split here.  */
@@ -185,7 +182,8 @@
      this element.  */
   if (abfd->arelt_data != NULL)
     {
-      size_t maxbytes = ((struct areltdata *) abfd->arelt_data)->parsed_size;
+      bfd_size_type maxbytes = arelt_size (abfd);
+
       if (abfd->where + size > maxbytes)
         {
           if (abfd->where >= maxbytes)
@@ -233,10 +231,14 @@
 
   if (abfd->iovec)
     {
+      bfd *parent_bfd = abfd;
       ptr = abfd->iovec->btell (abfd);
 
-      if (abfd->my_archive)
-	ptr -= abfd->origin;
+      while (parent_bfd->my_archive != NULL)
+	{
+	  ptr -= parent_bfd->origin;
+	  parent_bfd = parent_bfd->my_archive;
+	}
     }
   else
     ptr = 0;
@@ -308,8 +310,16 @@
     }
 
   file_position = position;
-  if (direction == SEEK_SET && abfd->my_archive != NULL)
-    file_position += abfd->origin;
+  if (direction == SEEK_SET)
+    {
+      bfd *parent_bfd = abfd;
+
+      while (parent_bfd->my_archive != NULL)
+        {
+          file_position += parent_bfd->origin;
+          parent_bfd = parent_bfd->my_archive;
+        }
+    }
 
   if (abfd->iovec)
     result = abfd->iovec->bseek (abfd, file_position, direction);
@@ -574,7 +584,7 @@
   free (bim);
   abfd->iostream = NULL;
 
-  return TRUE;
+  return 0;
 }
 
 static int
diff --git a/bfd/cache.c b/bfd/cache.c
index 5ddbbe4..4d46936 100644
--- a/bfd/cache.c
+++ b/bfd/cache.c
@@ -31,7 +31,7 @@
 	regard to the underlying operating system's file descriptor
 	limit (often as low as 20 open files).  The module in
 	<<cache.c>> maintains a least recently used list of
-	<<BFD_CACHE_MAX_OPEN>> files, and exports the name
+	<<bfd_cache_max_open>> files, and exports the name
 	<<bfd_cache_lookup>>, which runs around and makes sure that
 	the required BFD is open. If not, then it chooses a file to
 	close, closes it and opens the one wanted, returning its file
@@ -67,9 +67,35 @@
 };
 
 /* The maximum number of files which the cache will keep open at
-   one time.  */
+   one time.  When needed call bfd_cache_max_open to initialize.  */
 
-#define BFD_CACHE_MAX_OPEN 10
+static int max_open_files = 0;
+
+/* Set max_open_files, if not already set, to 12.5% of the allowed open
+   file descriptors, but at least 10, and return the value.  */
+static int
+bfd_cache_max_open (void)
+{
+  if (max_open_files == 0)
+    {
+      int max;
+#ifdef HAVE_GETRLIMIT
+      struct rlimit rlim;
+      if (getrlimit (RLIMIT_NOFILE, &rlim) == 0
+	  && rlim.rlim_cur != RLIM_INFINITY)
+	max = rlim.rlim_cur / 8;
+      else
+#endif /* HAVE_GETRLIMIT */
+#ifdef _SC_OPEN_MAX
+	max = sysconf (_SC_OPEN_MAX) / 8;
+#else
+	max = 10;
+#endif /* _SC_OPEN_MAX */
+      max_open_files = max < 10 ? 10 : max;
+    }
+
+  return max_open_files;
+}
 
 /* The number of BFD files we have open.  */
 
@@ -187,7 +213,7 @@
 /* Called when the macro <<bfd_cache_lookup>> fails to find a
    quick answer.  Find a file descriptor for @var{abfd}.  If
    necessary, it open it.  If there are already more than
-   <<BFD_CACHE_MAX_OPEN>> files open, it tries to close one first, to
+   <<bfd_cache_max_open>> files open, it tries to close one first, to
    avoid running out of file descriptors.  It will return NULL
    if it is unable to (re)open the @var{abfd}.  */
 
@@ -198,7 +224,7 @@
   if ((abfd->flags & BFD_IN_MEMORY) != 0)
     abort ();
 
-  if (abfd->my_archive)
+  while (abfd->my_archive)
     abfd = abfd->my_archive;
 
   if (abfd->iostream != NULL)
@@ -362,7 +388,7 @@
 static int
 cache_bclose (struct bfd *abfd)
 {
-  return bfd_cache_close (abfd);
+  return bfd_cache_close (abfd) - 1;
 }
 
 static int
@@ -437,7 +463,7 @@
         {
           *map_addr = ret;
           *map_len = pg_len;
-          ret += offset & pagesize_m1;
+          ret = (char *) ret + (offset & pagesize_m1);
         }
     }
 #endif
@@ -466,7 +492,7 @@
 bfd_cache_init (bfd *abfd)
 {
   BFD_ASSERT (abfd->iostream != NULL);
-  if (open_files >= BFD_CACHE_MAX_OPEN)
+  if (open_files >= bfd_cache_max_open ())
     {
       if (! close_one ())
 	return FALSE;
@@ -553,7 +579,7 @@
 {
   abfd->cacheable = TRUE;	/* Allow it to be closed later.  */
 
-  if (open_files >= BFD_CACHE_MAX_OPEN)
+  if (open_files >= bfd_cache_max_open ())
     {
       if (! close_one ())
 	return NULL;
@@ -563,15 +589,15 @@
     {
     case read_direction:
     case no_direction:
-      abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_RB);
+      abfd->iostream = real_fopen (abfd->filename, FOPEN_RB);
       break;
     case both_direction:
     case write_direction:
       if (abfd->opened_once)
 	{
-	  abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_RUB);
+	  abfd->iostream = real_fopen (abfd->filename, FOPEN_RUB);
 	  if (abfd->iostream == NULL)
-	    abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_WUB);
+	    abfd->iostream = real_fopen (abfd->filename, FOPEN_WUB);
 	}
       else
 	{
@@ -601,7 +627,7 @@
 	  if (stat (abfd->filename, &s) == 0 && s.st_size != 0)
 	    unlink_if_ordinary (abfd->filename);
 #endif
-	  abfd->iostream = (PTR) real_fopen (abfd->filename, FOPEN_WUB);
+	  abfd->iostream = real_fopen (abfd->filename, FOPEN_WUB);
 	  abfd->opened_once = TRUE;
 	}
       break;
diff --git a/bfd/cisco-core.c b/bfd/cisco-core.c
index 40eaca9..5d0454c 100644
--- a/bfd/cisco-core.c
+++ b/bfd/cisco-core.c
@@ -1,6 +1,6 @@
 /* BFD back-end for CISCO crash dumps.
    Copyright 1994, 1997, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007,
-   2010, 2011
+   2010, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -38,7 +38,8 @@
 # define SIGBUS 10
 #endif
 
-int crash_info_locs[] = {
+int crash_info_locs[] =
+{
   0x0250,	/* mips, ppc, x86, i960 */
   0x0400,	/* m68k, mips, x86, i960 */
   0x0FFC,	/* m68k, mips, ppc, x86, i960 */
@@ -50,13 +51,15 @@
 #define CRASH_MAGIC	0xdead1234
 #define MASK_ADDR(x)	((x) & 0x0fffffff)	/* Mask crash info address */
 
-typedef enum {
-    CRASH_REASON_NOTCRASHED = 0,
-    CRASH_REASON_EXCEPTION = 1,
-    CRASH_REASON_CORRUPT = 2,
+typedef enum
+{
+  CRASH_REASON_NOTCRASHED = 0,
+  CRASH_REASON_EXCEPTION = 1,
+  CRASH_REASON_CORRUPT = 2,
 } crashreason;
 
-typedef struct {
+typedef struct
+{
   char magic[4];		/* Magic number */
   char version[4];		/* Version number */
   char reason[4];		/* Crash reason */
@@ -73,10 +76,6 @@
   int sig;
 };
 
-static const bfd_target *cisco_core_file_validate PARAMS ((bfd *, int));
-static const bfd_target *cisco_core_file_p PARAMS ((bfd *));
-char *cisco_core_file_failing_command PARAMS ((bfd *));
-int cisco_core_file_failing_signal PARAMS ((bfd *));
 #define cisco_core_file_matches_executable_p generic_core_file_matches_executable_p
 #define cisco_core_file_pid _bfd_nocore_core_file_pid
 
@@ -84,9 +83,7 @@
    CRASH_INFO_LOC.  */
 
 static const bfd_target *
-cisco_core_file_validate (abfd, crash_info_loc)
-     bfd *abfd;
-     int crash_info_loc;
+cisco_core_file_validate (bfd *abfd, int crash_info_loc)
 {
   char buf[4];
   unsigned int crashinfo_offset;
@@ -292,8 +289,7 @@
 }
 
 static const bfd_target *
-cisco_core_file_p (abfd)
-     bfd *abfd;
+cisco_core_file_p (bfd *abfd)
 {
   int *crash_info_locp;
   const bfd_target *target = NULL;
@@ -307,16 +303,14 @@
   return (target);
 }
 
-char *
-cisco_core_file_failing_command (abfd)
-     bfd *abfd ATTRIBUTE_UNUSED;
+static char *
+cisco_core_file_failing_command (bfd *abfd ATTRIBUTE_UNUSED)
 {
   return NULL;
 }
 
-int
-cisco_core_file_failing_signal (abfd)
-     bfd *abfd ATTRIBUTE_UNUSED;
+static int
+cisco_core_file_failing_signal (bfd *abfd ATTRIBUTE_UNUSED)
 {
   return abfd->tdata.cisco_core_data->sig;
 }
@@ -324,7 +318,7 @@
 extern const bfd_target cisco_core_little_vec;
 
 const bfd_target cisco_core_big_vec =
-  {
+{
     "cisco-ios-core-big",
     bfd_target_unknown_flavour,
     BFD_ENDIAN_BIG,		/* target byte order */
@@ -371,11 +365,11 @@
 
     & cisco_core_little_vec,
 
-    (PTR) 0			/* backend_data */
+    NULL	/* backend_data */
 };
 
 const bfd_target cisco_core_little_vec =
-  {
+{
     "cisco-ios-core-little",
     bfd_target_unknown_flavour,
     BFD_ENDIAN_LITTLE,		/* target byte order */
@@ -422,5 +416,5 @@
 
     &cisco_core_big_vec,
 
-    (PTR) 0			/* backend_data */
+    NULL			/* backend_data */
 };
diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c
index 4466e4d..028e703 100644
--- a/bfd/coff-alpha.c
+++ b/bfd/coff-alpha.c
@@ -1,6 +1,6 @@
 /* BFD back-end for ALPHA Extended-Coff files.
    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
+   2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
    Modified from coff-mips.c by Steve Chamberlain <[email protected]> and
    Ian Lance Taylor <[email protected]>.
@@ -37,40 +37,7 @@
 
 /* Prototypes for static functions.  */
 
-static const bfd_target *alpha_ecoff_object_p
-  PARAMS ((bfd *));
-static bfd_boolean alpha_ecoff_bad_format_hook
-  PARAMS ((bfd *abfd, PTR filehdr));
-static PTR alpha_ecoff_mkobject_hook
-  PARAMS ((bfd *, PTR filehdr, PTR aouthdr));
-static void alpha_ecoff_swap_reloc_in
-  PARAMS ((bfd *, PTR, struct internal_reloc *));
-static void alpha_ecoff_swap_reloc_out
-  PARAMS ((bfd *, const struct internal_reloc *, PTR));
-static void alpha_adjust_reloc_in
-  PARAMS ((bfd *, const struct internal_reloc *, arelent *));
-static void alpha_adjust_reloc_out
-  PARAMS ((bfd *, const arelent *, struct internal_reloc *));
-static reloc_howto_type *alpha_bfd_reloc_type_lookup
-  PARAMS ((bfd *, bfd_reloc_code_real_type));
-static bfd_byte *alpha_ecoff_get_relocated_section_contents
-  PARAMS ((bfd *abfd, struct bfd_link_info *, struct bfd_link_order *,
-	   bfd_byte *data, bfd_boolean relocatable, asymbol **symbols));
-static bfd_vma alpha_convert_external_reloc
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, struct external_reloc *,
-	   struct ecoff_link_hash_entry *));
-static bfd_boolean alpha_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, PTR));
-static bfd_boolean alpha_adjust_headers
-  PARAMS ((bfd *, struct internal_filehdr *, struct internal_aouthdr *));
-static PTR alpha_ecoff_read_ar_hdr
-  PARAMS ((bfd *));
-static bfd *alpha_ecoff_get_elt_at_filepos
-  PARAMS ((bfd *, file_ptr));
-static bfd *alpha_ecoff_openr_next_archived_file
-  PARAMS ((bfd *, bfd *));
-static bfd *alpha_ecoff_get_elt_at_index
-  PARAMS ((bfd *, symindex));
+
 
 /* ECOFF has COFF sections, but the debugging information is stored in
    a completely different format.  ECOFF targets use some of the
@@ -128,18 +95,14 @@
 
 /* How to process the various reloc types.  */
 
-static bfd_reloc_status_type reloc_nil
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-
 static bfd_reloc_status_type
-reloc_nil (abfd, reloc, sym, data, sec, output_bfd, error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc ATTRIBUTE_UNUSED;
-     asymbol *sym ATTRIBUTE_UNUSED;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *sec ATTRIBUTE_UNUSED;
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     char **error_message ATTRIBUTE_UNUSED;
+reloc_nil (bfd *abfd ATTRIBUTE_UNUSED,
+	   arelent *reloc ATTRIBUTE_UNUSED,
+	   asymbol *sym ATTRIBUTE_UNUSED,
+	   void * data ATTRIBUTE_UNUSED,
+	   asection *sec ATTRIBUTE_UNUSED,
+	   bfd *output_bfd ATTRIBUTE_UNUSED,
+	   char **error_message ATTRIBUTE_UNUSED)
 {
   return bfd_reloc_ok;
 }
@@ -438,8 +401,7 @@
 /* Recognize an Alpha ECOFF file.  */
 
 static const bfd_target *
-alpha_ecoff_object_p (abfd)
-     bfd *abfd;
+alpha_ecoff_object_p (bfd *abfd)
 {
   static const bfd_target *ret;
 
@@ -477,9 +439,8 @@
 /* See whether the magic number matches.  */
 
 static bfd_boolean
-alpha_ecoff_bad_format_hook (abfd, filehdr)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     PTR filehdr;
+alpha_ecoff_bad_format_hook (bfd *abfd ATTRIBUTE_UNUSED,
+			     void * filehdr)
 {
   struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
 
@@ -498,13 +459,10 @@
 /* This is a hook called by coff_real_object_p to create any backend
    specific information.  */
 
-static PTR
-alpha_ecoff_mkobject_hook (abfd, filehdr, aouthdr)
-     bfd *abfd;
-     PTR filehdr;
-     PTR aouthdr;
+static void *
+alpha_ecoff_mkobject_hook (bfd *abfd, void * filehdr, void * aouthdr)
 {
-  PTR ecoff;
+  void * ecoff;
 
   ecoff = _bfd_ecoff_mkobject_hook (abfd, filehdr, aouthdr);
 
@@ -534,10 +492,9 @@
 /* Swap a reloc in.  */
 
 static void
-alpha_ecoff_swap_reloc_in (abfd, ext_ptr, intern)
-     bfd *abfd;
-     PTR ext_ptr;
-     struct internal_reloc *intern;
+alpha_ecoff_swap_reloc_in (bfd *abfd,
+			   void * ext_ptr,
+			   struct internal_reloc *intern)
 {
   const RELOC *ext = (RELOC *) ext_ptr;
 
@@ -582,10 +539,9 @@
 /* Swap a reloc out.  */
 
 static void
-alpha_ecoff_swap_reloc_out (abfd, intern, dst)
-     bfd *abfd;
-     const struct internal_reloc *intern;
-     PTR dst;
+alpha_ecoff_swap_reloc_out (bfd *abfd,
+			    const struct internal_reloc *intern,
+			    void * dst)
 {
   RELOC *ext = (RELOC *) dst;
   long symndx;
@@ -637,10 +593,9 @@
    this backend routine.  It must fill in the howto field.  */
 
 static void
-alpha_adjust_reloc_in (abfd, intern, rptr)
-     bfd *abfd;
-     const struct internal_reloc *intern;
-     arelent *rptr;
+alpha_adjust_reloc_in (bfd *abfd,
+		       const struct internal_reloc *intern,
+		       arelent *rptr)
 {
   if (intern->r_type > ALPHA_R_GPVALUE)
     {
@@ -729,10 +684,9 @@
    not need to undo.  */
 
 static void
-alpha_adjust_reloc_out (abfd, rel, intern)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     const arelent *rel;
-     struct internal_reloc *intern;
+alpha_adjust_reloc_out (bfd *abfd ATTRIBUTE_UNUSED,
+			const arelent *rel,
+			struct internal_reloc *intern)
 {
   switch (intern->r_type)
     {
@@ -771,14 +725,12 @@
    assembler is going to handle this.  */
 
 static bfd_byte *
-alpha_ecoff_get_relocated_section_contents (abfd, link_info, link_order,
-					    data, relocatable, symbols)
-     bfd *abfd;
-     struct bfd_link_info *link_info;
-     struct bfd_link_order *link_order;
-     bfd_byte *data;
-     bfd_boolean relocatable;
-     asymbol **symbols;
+alpha_ecoff_get_relocated_section_contents (bfd *abfd,
+					    struct bfd_link_info *link_info,
+					    struct bfd_link_order *link_order,
+					    bfd_byte *data,
+					    bfd_boolean relocatable,
+					    asymbol **symbols)
 {
   bfd *input_bfd = link_order->u.indirect.section->owner;
   asection *input_section = link_order->u.indirect.section;
@@ -1195,9 +1147,8 @@
 /* Get the howto structure for a generic reloc type.  */
 
 static reloc_howto_type *
-alpha_bfd_reloc_type_lookup (abfd, code)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+alpha_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+			     bfd_reloc_code_real_type code)
 {
   int alpha_type;
 
@@ -1268,12 +1219,11 @@
    relocation amount.  */
 
 static bfd_vma
-alpha_convert_external_reloc (output_bfd, info, input_bfd, ext_rel, h)
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     struct external_reloc *ext_rel;
-     struct ecoff_link_hash_entry *h;
+alpha_convert_external_reloc (bfd *output_bfd ATTRIBUTE_UNUSED,
+			      struct bfd_link_info *info,
+			      bfd *input_bfd,
+			      struct external_reloc *ext_rel,
+			      struct ecoff_link_hash_entry *h)
 {
   unsigned long r_symndx;
   bfd_vma relocation;
@@ -1385,14 +1335,12 @@
    could be combined somehow.  */
 
 static bfd_boolean
-alpha_relocate_section (output_bfd, info, input_bfd, input_section,
-			contents, external_relocs)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     PTR external_relocs;
+alpha_relocate_section (bfd *output_bfd,
+			struct bfd_link_info *info,
+			bfd *input_bfd,
+			asection *input_section,
+			bfd_byte *contents,
+			void * external_relocs)
 {
   asection **symndx_to_section, *lita_sec;
   struct ecoff_link_hash_entry **sym_hashes;
@@ -1562,14 +1510,14 @@
 	     input_bfd);
 	  bfd_set_error (bfd_error_bad_value);
 	  continue;
-	  
+
 	case ALPHA_R_GPRELLOW:
 	  (*_bfd_error_handler)
 	    (_("%B: unsupported relocation: ALPHA_R_GPRELLOW"),
 	     input_bfd);
 	  bfd_set_error (bfd_error_bad_value);
 	  continue;
-	  
+
 	default:
 	  (*_bfd_error_handler)
 	    (_("%B: unknown relocation type %d"),
@@ -2042,10 +1990,9 @@
    sets the dynamic bits in the file header.  */
 
 static bfd_boolean
-alpha_adjust_headers (abfd, fhdr, ahdr)
-     bfd *abfd;
-     struct internal_filehdr *fhdr;
-     struct internal_aouthdr *ahdr ATTRIBUTE_UNUSED;
+alpha_adjust_headers (bfd *abfd,
+		      struct internal_filehdr *fhdr,
+		      struct internal_aouthdr *ahdr ATTRIBUTE_UNUSED)
 {
   if ((abfd->flags & (DYNAMIC | EXEC_P)) == (DYNAMIC | EXEC_P))
     fhdr->f_flags |= F_ALPHA_CALL_SHARED;
@@ -2077,9 +2024,8 @@
 /* Read an archive header.  This is like the standard routine, but it
    also accepts ARFZMAG.  */
 
-static PTR
-alpha_ecoff_read_ar_hdr (abfd)
-     bfd *abfd;
+static void *
+alpha_ecoff_read_ar_hdr (bfd *abfd)
 {
   struct areltdata *ret;
   struct ar_hdr *h;
@@ -2103,16 +2049,14 @@
       ret->parsed_size = H_GET_64 (abfd, ab);
     }
 
-  return (PTR) ret;
+  return ret;
 }
 
 /* Get an archive element at a specified file position.  This is where
    we uncompress the archive element if necessary.  */
 
 static bfd *
-alpha_ecoff_get_elt_at_filepos (archive, filepos)
-     bfd *archive;
-     file_ptr filepos;
+alpha_ecoff_get_elt_at_filepos (bfd *archive, file_ptr filepos)
 {
   bfd *nbfd = NULL;
   struct areltdata *tdata;
@@ -2225,7 +2169,7 @@
   nbfd->mtime = strtol (hdr->ar_date, (char **) NULL, 10);
 
   nbfd->flags |= BFD_IN_MEMORY;
-  nbfd->iostream = (PTR) bim;
+  nbfd->iostream = bim;
   nbfd->iovec = &_bfd_memory_iovec;
   nbfd->origin = 0;
   BFD_ASSERT (! nbfd->cacheable);
@@ -2243,9 +2187,7 @@
 /* Open the next archived file.  */
 
 static bfd *
-alpha_ecoff_openr_next_archived_file (archive, last_file)
-     bfd *archive;
-     bfd *last_file;
+alpha_ecoff_openr_next_archived_file (bfd *archive, bfd *last_file)
 {
   file_ptr filestart;
 
@@ -2291,16 +2233,16 @@
 {
   /* COFF backend structure.  */
   {
-    (void (*) PARAMS ((bfd *,PTR,int,int,int,int,PTR))) bfd_void, /* aux_in */
-    (void (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* sym_in */
-    (void (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* lineno_in */
-    (unsigned (*) PARAMS ((bfd *,PTR,int,int,int,int,PTR)))bfd_void,/*aux_out*/
-    (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* sym_out */
-    (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* lineno_out */
-    (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* reloc_out */
+    (void (*) (bfd *,void *,int,int,int,int,void *)) bfd_void, /* aux_in */
+    (void (*) (bfd *,void *,void *)) bfd_void, /* sym_in */
+    (void (*) (bfd *,void *,void *)) bfd_void, /* lineno_in */
+    (unsigned (*) (bfd *,void *,int,int,int,int,void *)) bfd_void,/*aux_out*/
+    (unsigned (*) (bfd *,void *,void *)) bfd_void, /* sym_out */
+    (unsigned (*) (bfd *,void *,void *)) bfd_void, /* lineno_out */
+    (unsigned (*) (bfd *,void *,void *)) bfd_void, /* reloc_out */
     alpha_ecoff_swap_filehdr_out, alpha_ecoff_swap_aouthdr_out,
     alpha_ecoff_swap_scnhdr_out,
-    FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, TRUE, 
+    FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, TRUE,
     ECOFF_NO_LONG_SECTION_NAMES, 4, FALSE, 2,
     alpha_ecoff_swap_filehdr_in, alpha_ecoff_swap_aouthdr_in,
     alpha_ecoff_swap_scnhdr_in, NULL,
@@ -2448,5 +2390,5 @@
 
   NULL,
 
-  (PTR) &alpha_ecoff_backend_data
+  & alpha_ecoff_backend_data
 };
diff --git a/bfd/coff-apollo.c b/bfd/coff-apollo.c
index e177099..46cf5ea 100644
--- a/bfd/coff-apollo.c
+++ b/bfd/coff-apollo.c
@@ -1,6 +1,6 @@
 /* BFD back-end for Apollo 68000 COFF binaries.
    Copyright 1990, 1991, 1992, 1993, 1994, 1999, 2000, 2001, 2002, 2003,
-   2005, 2007, 2008  Free Software Foundation, Inc.
+   2005, 2007, 2008, 2012  Free Software Foundation, Inc.
    By Troy Rollo ([email protected])
    Based on m68k standard COFF version Written by Cygnus Support.
 
@@ -52,14 +52,12 @@
 
 /* Turn a howto into a reloc number.  */
 
-extern void apollo_rtype2howto PARAMS ((arelent *, int));
-extern int  apollo_howto2rtype PARAMS ((reloc_howto_type *));
+extern void apollo_rtype2howto (arelent *, int);
+extern int  apollo_howto2rtype (reloc_howto_type *);
 #ifndef ONLY_DECLARE_RELOCS
 
 void
-apollo_rtype2howto (internal, relocentry)
-     arelent *internal;
-     int relocentry;
+apollo_rtype2howto (arelent *internal, int relocentry)
 {
   switch (relocentry)
     {
@@ -74,8 +72,7 @@
 }
 
 int
-apollo_howto2rtype (internal)
-     reloc_howto_type *internal;
+apollo_howto2rtype (reloc_howto_type *internal)
 {
   if (internal->pc_relative)
     {
diff --git a/bfd/coff-arm.c b/bfd/coff-arm.c
index bdadfb2..efcf522 100644
--- a/bfd/coff-arm.c
+++ b/bfd/coff-arm.c
@@ -1,6 +1,6 @@
 /* BFD back-end for ARM COFF files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -599,7 +599,7 @@
   bfd_reloc_status_type flag = bfd_reloc_ok;
 
   /* If this is an undefined symbol, return error.  */
-  if (symbol->section == &bfd_und_section
+  if (bfd_is_und_section (symbol->section)
       && (symbol->flags & BSF_WEAK) == 0)
     return output_bfd ? bfd_reloc_continue : bfd_reloc_undefined;
 
@@ -687,7 +687,7 @@
     }
 
   /* If this is an undefined symbol, return error.  */
-  if (symbol->section == &bfd_und_section
+  if (bfd_is_und_section (symbol->section)
       && (symbol->flags & BSF_WEAK) == 0)
     return output_bfd ? bfd_reloc_continue : bfd_reloc_undefined;
 
@@ -918,7 +918,7 @@
   struct coff_arm_link_hash_table * ret;
   bfd_size_type amt = sizeof (struct coff_arm_link_hash_table);
 
-  ret = bfd_malloc (amt);
+  ret = bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
 
@@ -931,10 +931,6 @@
       return NULL;
     }
 
-  ret->thumb_glue_size   = 0;
-  ret->arm_glue_size     = 0;
-  ret->bfd_of_glue_owner = NULL;
-
   return & ret->root.root;
 }
 
diff --git a/bfd/coff-aux.c b/bfd/coff-aux.c
index 84805a8..852f585 100644
--- a/bfd/coff-aux.c
+++ b/bfd/coff-aux.c
@@ -1,5 +1,5 @@
 /* BFD back-end for Apple M68K COFF A/UX 3.x files.
-   Copyright 1996, 1997, 2000, 2002, 2005, 2007, 2008, 2011
+   Copyright 1996, 1997, 2000, 2002, 2005, 2007, 2008, 2011, 2012
    Free Software Foundation, Inc.
    Written by Richard Henderson <[email protected]>.
 
@@ -42,12 +42,12 @@
 #include "sysdep.h"
 #include "bfd.h"
 
-static bfd_boolean coff_m68k_aux_link_add_one_symbol
-  PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword,
-           asection *, bfd_vma, const char *, bfd_boolean, bfd_boolean,
-           struct bfd_link_hash_entry **));
-
 #define coff_link_add_one_symbol coff_m68k_aux_link_add_one_symbol
+static bfd_boolean
+coff_m68k_aux_link_add_one_symbol
+  (struct bfd_link_info *, bfd *, const char *, flagword, asection *,
+   bfd_vma, const char *, bfd_boolean, bfd_boolean,
+   struct bfd_link_hash_entry **);
 
 #ifndef bfd_pe_print_pdata
 #define bfd_pe_print_pdata	NULL
@@ -63,18 +63,16 @@
    what you include in the shared object.  */
 
 static bfd_boolean
-coff_m68k_aux_link_add_one_symbol (info, abfd, name, flags, section, value,
-				   string, copy, collect, hashp)
-     struct bfd_link_info *info;
-     bfd *abfd;
-     const char *name;
-     flagword flags;
-     asection *section;
-     bfd_vma value;
-     const char *string;
-     bfd_boolean copy;
-     bfd_boolean collect;
-     struct bfd_link_hash_entry **hashp;
+coff_m68k_aux_link_add_one_symbol (struct bfd_link_info *info,
+				   bfd *abfd,
+				   const char *name,
+				   flagword flags,
+				   asection *section,
+				   bfd_vma value,
+				   const char *string,
+				   bfd_boolean copy,
+				   bfd_boolean collect,
+				   struct bfd_link_hash_entry **hashp)
 {
   struct bfd_link_hash_entry *h;
 
diff --git a/bfd/coff-h8300.c b/bfd/coff-h8300.c
index e2a10a6..1e34275 100644
--- a/bfd/coff-h8300.c
+++ b/bfd/coff-h8300.c
@@ -1,6 +1,6 @@
 /* BFD back-end for Renesas H8/300 COFF binaries.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2012
    Free Software Foundation, Inc.
    Written by Steve Chamberlain, <[email protected]>.
 
@@ -60,28 +60,6 @@
     unsigned int offset;
   };
 
-static struct bfd_hash_entry *
-funcvec_hash_newfunc
-  (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
-
-static bfd_reloc_status_type special
-  (bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **);
-static int select_reloc
-  (reloc_howto_type *);
-static void rtype2howto
-  (arelent *, struct internal_reloc *);
-static void reloc_processing
-  (arelent *, struct internal_reloc *, asymbol **, bfd *, asection *);
-static bfd_boolean h8300_symbol_address_p
-  (bfd *, asection *, bfd_vma);
-static int h8300_reloc16_estimate
-  (bfd *, asection *, arelent *, unsigned int,
-   struct bfd_link_info *);
-static void h8300_reloc16_extra_cases
-  (bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *,
-   bfd_byte *, unsigned int *, unsigned int *);
-static bfd_boolean h8300_bfd_link_add_symbols
-  (bfd *, struct bfd_link_info *);
 
 /* To lookup a value in the function vector hash table.  */
 #define funcvec_hash_lookup(table, string, create, copy) \
@@ -195,7 +173,7 @@
   struct h8300_coff_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct h8300_coff_link_hash_table);
 
-  ret = (struct h8300_coff_link_hash_table *) bfd_malloc (amt);
+  ret = (struct h8300_coff_link_hash_table *) bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
   if (!_bfd_link_hash_table_init (&ret->root.root, abfd,
@@ -206,11 +184,6 @@
       return NULL;
     }
 
-  /* Initialize our data.  */
-  ret->vectors_sec = NULL;
-  ret->funcvec_hash_table = NULL;
-
-  /* OK.  Everything's initialized, return the base pointer.  */
   return &ret->root.root;
 }
 
@@ -224,13 +197,13 @@
    the addend until the final link.  */
 
 static bfd_reloc_status_type
-special (bfd *abfd ATTRIBUTE_UNUSED,
-	 arelent *reloc_entry ATTRIBUTE_UNUSED,
-	 asymbol *symbol ATTRIBUTE_UNUSED,
-	 PTR data ATTRIBUTE_UNUSED,
-	 asection *input_section ATTRIBUTE_UNUSED,
-	 bfd *output_bfd,
-	 char **error_message ATTRIBUTE_UNUSED)
+special (bfd *      abfd ATTRIBUTE_UNUSED,
+	 arelent *  reloc_entry ATTRIBUTE_UNUSED,
+	 asymbol *  symbol ATTRIBUTE_UNUSED,
+	 void *     data ATTRIBUTE_UNUSED,
+	 asection * input_section ATTRIBUTE_UNUSED,
+	 bfd *      output_bfd,
+	 char **    error_message ATTRIBUTE_UNUSED)
 {
   if (output_bfd == (bfd *) NULL)
     return bfd_reloc_continue;
@@ -240,7 +213,8 @@
   return bfd_reloc_ok;
 }
 
-static reloc_howto_type howto_table[] = {
+static reloc_howto_type howto_table[] =
+{
   HOWTO (R_RELBYTE, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, special, "8", FALSE, 0x000000ff, 0x000000ff, FALSE),
   HOWTO (R_RELWORD, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, special, "16", FALSE, 0x0000ffff, 0x0000ffff, FALSE),
   HOWTO (R_RELLONG, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, special, "32", FALSE, 0xffffffff, 0xffffffff, FALSE),
diff --git a/bfd/coff-h8500.c b/bfd/coff-h8500.c
index 139a8ed..9b64599 100644
--- a/bfd/coff-h8500.c
+++ b/bfd/coff-h8500.c
@@ -1,6 +1,6 @@
 /* BFD back-end for Renesas H8/500 COFF binaries.
    Copyright 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005, 2007, 2008  Free Software Foundation, Inc.
+   2005, 2007, 2008, 2012  Free Software Foundation, Inc.
    Contributed by Cygnus Support.
    Written by Steve Chamberlain, <[email protected]>.
 
@@ -29,10 +29,6 @@
 #include "coff/internal.h"
 #include "libcoff.h"
 
-static int  coff_h8500_select_reloc PARAMS ((reloc_howto_type *));
-static void rtype2howto      PARAMS ((arelent *, struct internal_reloc *));
-static void reloc_processing PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
-static void extra_case       PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *, bfd_byte *, unsigned int *, unsigned int *));
 
 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
 
@@ -73,8 +69,7 @@
 /* Turn a howto into a reloc number.  */
 
 static int
-coff_h8500_select_reloc (howto)
-     reloc_howto_type *howto;
+coff_h8500_select_reloc (reloc_howto_type *howto)
 {
   return howto->type;
 }
@@ -96,9 +91,7 @@
 /* Code to turn a r_type into a howto ptr, uses the above howto table.  */
 
 static void
-rtype2howto (internal, dst)
-     arelent * internal;
-     struct internal_reloc *dst;
+rtype2howto (arelent * internal, struct internal_reloc *dst)
 {
   switch (dst->r_type)
     {
@@ -145,12 +138,12 @@
 #define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
  reloc_processing(relent, reloc, symbols, abfd, section)
 
-static void reloc_processing (relent, reloc, symbols, abfd, section)
-     arelent * relent;
-     struct internal_reloc *reloc;
-     asymbol ** symbols;
-     bfd * abfd;
-     asection * section;
+static void
+reloc_processing (arelent * relent,
+		  struct internal_reloc *reloc,
+		  asymbol ** symbols,
+		  bfd * abfd,
+		  asection * section)
 {
   relent->address = reloc->r_vaddr;
   rtype2howto (relent, reloc);
@@ -165,14 +158,13 @@
 }
 
 static void
-extra_case (in_abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)
-     bfd *in_abfd;
-     struct bfd_link_info *link_info;
-     struct bfd_link_order *link_order;
-     arelent *reloc;
-     bfd_byte *data;
-     unsigned int *src_ptr;
-     unsigned int *dst_ptr;
+extra_case (bfd *in_abfd,
+	    struct bfd_link_info *link_info,
+	    struct bfd_link_order *link_order,
+	    arelent *reloc,
+	    bfd_byte *data,
+	    unsigned int *src_ptr,
+	    unsigned int *dst_ptr)
 {
   bfd_byte *d = data+*dst_ptr;
   asection *input_section = link_order->u.indirect.section;
@@ -230,7 +222,7 @@
 	v = (v & 0x00ffffff) | (o & 0xff00000);
 	bfd_put_32 (in_abfd, (bfd_vma) v, data  + *dst_ptr -1);
 	(*dst_ptr) += 3;
-	(*src_ptr) += 3;;
+	(*src_ptr) += 3;
       }
       break;
     case R_H8500_IMM32:
@@ -238,7 +230,7 @@
 	int v = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
 	bfd_put_32 (in_abfd, (bfd_vma) v, data  + *dst_ptr);
 	(*dst_ptr) += 4;
-	(*src_ptr) += 4;;
+	(*src_ptr) += 4;
       }
       break;
 
diff --git a/bfd/coff-i386.c b/bfd/coff-i386.c
index 2f17a55..af92b40 100644
--- a/bfd/coff-i386.c
+++ b/bfd/coff-i386.c
@@ -1,6 +1,6 @@
 /* BFD back-end for Intel 386 COFF files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
+   2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -43,8 +43,6 @@
 
 #include "libcoff.h"
 
-static bfd_reloc_status_type coff_i386_reloc
-  (bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **);
 static reloc_howto_type *coff_i386_rtype_to_howto
   (bfd *, asection *, struct internal_reloc *,
    struct coff_link_hash_entry *, struct internal_syment *,
@@ -67,15 +65,13 @@
    reloc type to make any required adjustments.  */
 
 static bfd_reloc_status_type
-coff_i386_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
-		 error_message)
-     bfd *abfd;
-     arelent *reloc_entry;
-     asymbol *symbol;
-     PTR data;
-     asection *input_section ATTRIBUTE_UNUSED;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+coff_i386_reloc (bfd *abfd,
+		 arelent *reloc_entry,
+		 asymbol *symbol,
+		 void * data,
+		 asection *input_section ATTRIBUTE_UNUSED,
+		 bfd *output_bfd,
+		 char **error_message ATTRIBUTE_UNUSED)
 {
   symvalue diff;
 
@@ -189,11 +185,8 @@
 /* Return TRUE if this relocation should appear in the output .reloc
    section.  */
 
-static bfd_boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *));
-
-static bfd_boolean in_reloc_p (abfd, howto)
-     bfd * abfd ATTRIBUTE_UNUSED;
-     reloc_howto_type *howto;
+static bfd_boolean in_reloc_p (bfd * abfd ATTRIBUTE_UNUSED,
+			       reloc_howto_type *howto)
 {
   return ! howto->pc_relative && howto->type != R_IMAGEBASE
 	 && howto->type != R_SECREL32;
@@ -413,22 +406,15 @@
    and the regular routine is that we don't want to do anything for a
    relocatable link.  */
 
-static bfd_boolean coff_pe_i386_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
-	   struct internal_reloc *, struct internal_syment *, asection **));
-
 static bfd_boolean
-coff_pe_i386_relocate_section (output_bfd, info, input_bfd,
-			       input_section, contents, relocs, syms,
-			       sections)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     struct internal_reloc *relocs;
-     struct internal_syment *syms;
-     asection **sections;
+coff_pe_i386_relocate_section (bfd *output_bfd,
+			       struct bfd_link_info *info,
+			       bfd *input_bfd,
+			       asection *input_section,
+			       bfd_byte *contents,
+			       struct internal_reloc *relocs,
+			       struct internal_syment *syms,
+			       asection **sections)
 {
   if (info->relocatable)
     return TRUE;
@@ -445,13 +431,12 @@
 /* Convert an rtype to howto for the COFF backend linker.  */
 
 static reloc_howto_type *
-coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *sec;
-     struct internal_reloc *rel;
-     struct coff_link_hash_entry *h;
-     struct internal_syment *sym;
-     bfd_vma *addendp;
+coff_i386_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+			  asection *sec,
+			  struct internal_reloc *rel,
+			  struct coff_link_hash_entry *h,
+			  struct internal_syment *sym,
+			  bfd_vma *addendp)
 {
   reloc_howto_type *howto;
 
@@ -528,8 +513,8 @@
     {
       bfd_vma osect_vma;
 
-      if (h && (h->type == bfd_link_hash_defined
-		|| h->type == bfd_link_hash_defweak))
+      if (h && (h->root.type == bfd_link_hash_defined
+		|| h->root.type == bfd_link_hash_defweak))
 	osect_vma = h->root.u.def.section->output_section->vma;
       else
 	{
@@ -556,9 +541,8 @@
 #define coff_bfd_reloc_name_lookup coff_i386_reloc_name_lookup
 
 static reloc_howto_type *
-coff_i386_reloc_type_lookup (abfd, code)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+coff_i386_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+			     bfd_reloc_code_real_type code)
 {
   switch (code)
     {
@@ -608,13 +592,8 @@
    a leading dot for local labels, so if TARGET_UNDERSCORE is defined
    we treat all symbols starting with L as local.  */
 
-static bfd_boolean coff_i386_is_local_label_name
-  PARAMS ((bfd *, const char *));
-
 static bfd_boolean
-coff_i386_is_local_label_name (abfd, name)
-     bfd *abfd;
-     const char *name;
+coff_i386_is_local_label_name (bfd *abfd, const char *name)
 {
   if (name[0] == 'L')
     return TRUE;
@@ -628,6 +607,9 @@
 
 #include "coffcode.h"
 
+#define _bfd_generic_find_nearest_line_discriminator \
+	coff_find_nearest_line_discriminator
+
 const bfd_target
 #ifdef TARGET_SYM
   TARGET_SYM =
@@ -646,13 +628,13 @@
 
   (HAS_RELOC | EXEC_P |		/* object flags */
    HAS_LINENO | HAS_DEBUG |
-   HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+   HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS ),
 
   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
 #ifdef COFF_WITH_PE
-   | SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY
+   | SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY | SEC_DEBUGGING
 #endif
-   | SEC_CODE | SEC_DATA),
+   | SEC_CODE | SEC_DATA | SEC_EXCLUDE ),
 
 #ifdef TARGET_UNDERSCORE
   TARGET_UNDERSCORE,		/* leading underscore */
diff --git a/bfd/coff-i860.c b/bfd/coff-i860.c
index 9eb39a5..79b4a7e 100644
--- a/bfd/coff-i860.c
+++ b/bfd/coff-i860.c
@@ -131,7 +131,7 @@
   return bfd_reloc_continue;
 }
 
-/* This is just a temporary measure until we teach bfd to generate 
+/* This is just a temporary measure until we teach bfd to generate
    these relocations.  */
 
 static bfd_reloc_status_type
diff --git a/bfd/coff-i960.c b/bfd/coff-i960.c
index 928315f..5205caf 100644
--- a/bfd/coff-i960.c
+++ b/bfd/coff-i960.c
@@ -1,6 +1,6 @@
 /* BFD back-end for Intel 960 COFF files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005, 2007, 2008, 2009, 2011
+   2002, 2003, 2004, 2005, 2007, 2008, 2009, 2011, 2012
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -36,22 +36,6 @@
 
 #include "libcoff.h"		/* To allow easier abstraction-breaking.  */
 
-static bfd_boolean coff_i960_is_local_label_name
-  PARAMS ((bfd *, const char *));
-static bfd_reloc_status_type optcall_callback
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static bfd_reloc_status_type coff_i960_relocate
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static reloc_howto_type *coff_i960_reloc_type_lookup
-  PARAMS ((bfd *, bfd_reloc_code_real_type));
-static bfd_boolean coff_i960_start_final_link
-  PARAMS ((bfd *, struct bfd_link_info *));
-static bfd_boolean coff_i960_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
-	   struct internal_reloc *, struct internal_syment *, asection **));
-static bfd_boolean coff_i960_adjust_symndx
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
-	   struct internal_reloc *, bfd_boolean *));
 
 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
 #define COFF_ALIGN_IN_SECTION_HEADER 1
@@ -68,9 +52,7 @@
 /* This set of local label names is taken from gas.  */
 
 static bfd_boolean
-coff_i960_is_local_label_name (abfd, name)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     const char *name;
+coff_i960_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED, const char *name)
 {
   return (name[0] == 'L'
 	  || (name[0] == '.'
@@ -108,15 +90,13 @@
 #define BAL_MASK 0x00ffffff
 
 static bfd_reloc_status_type
-optcall_callback (abfd, reloc_entry, symbol_in, data,
-		  input_section, ignore_bfd, error_message)
-     bfd *abfd;
-     arelent *reloc_entry;
-     asymbol *symbol_in;
-     PTR data;
-     asection *input_section;
-     bfd *ignore_bfd ATTRIBUTE_UNUSED;
-     char **error_message;
+optcall_callback (bfd *abfd,
+		  arelent *reloc_entry,
+		  asymbol *symbol_in,
+		  void * data,
+		  asection *input_section,
+		  bfd *ignore_bfd ATTRIBUTE_UNUSED,
+		  char **error_message)
 {
   /* This item has already been relocated correctly, but we may be
    * able to patch in yet better code - done by digging out the
@@ -198,15 +178,13 @@
    COFF specific backend linker.  */
 
 static bfd_reloc_status_type
-coff_i960_relocate (abfd, reloc_entry, symbol, data, input_section,
-		    output_bfd, error_message)
-     bfd *abfd;
-     arelent *reloc_entry;
-     asymbol *symbol;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *input_section ATTRIBUTE_UNUSED;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+coff_i960_relocate (bfd *abfd,
+		    arelent *reloc_entry,
+		    asymbol *symbol,
+		    void * data ATTRIBUTE_UNUSED,
+		    asection *input_section ATTRIBUTE_UNUSED,
+		    bfd *output_bfd,
+		    char **error_message ATTRIBUTE_UNUSED)
 {
   asection *osec;
 
@@ -261,11 +239,11 @@
       if (coff_section_data (output_bfd, osec) == NULL)
 	{
 	  bfd_size_type amt = sizeof (struct coff_section_tdata);
-	  osec->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
+	  osec->used_by_bfd = bfd_zalloc (abfd, amt);
 	  if (osec->used_by_bfd == NULL)
 	    return bfd_reloc_overflow;
 	}
-      coff_section_data (output_bfd, osec)->tdata = (PTR) syms;
+      coff_section_data (output_bfd, osec)->tdata = syms;
     }
 
   /* Let bfd_perform_relocation do its thing, which will include
@@ -285,9 +263,8 @@
 	 optcall_callback, "optcall", TRUE, 0x00ffffff, 0x00ffffff, 0);
 
 static reloc_howto_type *
-coff_i960_reloc_type_lookup (abfd, code)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+coff_i960_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+			     bfd_reloc_code_real_type code)
 {
   switch (code)
     {
@@ -341,9 +318,7 @@
    necessary symbols.  */
 
 static bfd_boolean
-coff_i960_start_final_link (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info;
+coff_i960_start_final_link (bfd *abfd, struct bfd_link_info *info)
 {
   bfd_size_type symesz = bfd_coff_symesz (abfd);
   asection *o;
@@ -370,7 +345,7 @@
       isym.n_sclass = C_STAT;
       isym.n_numaux = 0;
 
-      bfd_coff_swap_sym_out (abfd, (PTR) &isym, (PTR) esym);
+      bfd_coff_swap_sym_out (abfd, &isym, esym);
 
       if (bfd_bwrite (esym, symesz, abfd) != symesz)
 	{
@@ -389,16 +364,14 @@
 /* The reloc processing routine for the optimized COFF linker.  */
 
 static bfd_boolean
-coff_i960_relocate_section (output_bfd, info, input_bfd, input_section,
-			    contents, relocs, syms, sections)
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     struct internal_reloc *relocs;
-     struct internal_syment *syms;
-     asection **sections;
+coff_i960_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
+			    struct bfd_link_info *info,
+			    bfd *input_bfd,
+			    asection *input_section,
+			    bfd_byte *contents,
+			    struct internal_reloc *relocs,
+			    struct internal_syment *syms,
+			    asection **sections)
 {
   struct internal_reloc *rel;
   struct internal_reloc *relend;
@@ -530,9 +503,9 @@
 		    BFD_ASSERT (sym->n_numaux == 2);
 		    esyms = (bfd_byte *) obj_coff_external_syms (input_bfd);
 		    esyms += (symndx + 2) * bfd_coff_symesz (input_bfd);
-		    bfd_coff_swap_aux_in (input_bfd, (PTR) esyms, sym->n_type,
+		    bfd_coff_swap_aux_in (input_bfd, esyms, sym->n_type,
 					  sym->n_sclass, 1, sym->n_numaux,
-					  (PTR) &aux);
+					  &aux);
 		    olf = aux.x_bal.x_balntry;
 		  }
 
@@ -601,13 +574,12 @@
    for the section.  */
 
 static bfd_boolean
-coff_i960_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
-     bfd *obfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     bfd *ibfd;
-     asection *sec ATTRIBUTE_UNUSED;
-     struct internal_reloc *irel;
-     bfd_boolean *adjustedp;
+coff_i960_adjust_symndx (bfd *obfd ATTRIBUTE_UNUSED,
+			 struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			 bfd *ibfd,
+			 asection *sec ATTRIBUTE_UNUSED,
+			 struct internal_reloc *irel,
+			 bfd_boolean *adjustedp)
 {
   struct coff_link_hash_entry *h;
 
diff --git a/bfd/coff-ia64.c b/bfd/coff-ia64.c
index 86e7617..3f172bd 100644
--- a/bfd/coff-ia64.c
+++ b/bfd/coff-ia64.c
@@ -1,5 +1,5 @@
 /* BFD back-end for HP/Intel IA-64 COFF files.
-   Copyright 1999, 2000, 2001, 2002, 2005, 2007, 2008, 2009, 2011
+   Copyright 1999, 2000, 2001, 2002, 2005, 2007, 2008, 2009, 2011, 2012
    Free Software Foundation, Inc.
    Contributed by David Mosberger <[email protected]>
 
@@ -54,12 +54,9 @@
 /* Return TRUE if this relocation should
    appear in the output .reloc section.  */
 
-static bfd_boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *));
-
 static bfd_boolean
-in_reloc_p(abfd, howto)
-     bfd * abfd ATTRIBUTE_UNUSED;
-     reloc_howto_type *howto ATTRIBUTE_UNUSED;
+in_reloc_p (bfd * abfd ATTRIBUTE_UNUSED,
+	    reloc_howto_type *howto ATTRIBUTE_UNUSED)
 {
   return FALSE;			/* We don't do relocs for now...  */
 }
@@ -71,11 +68,8 @@
 
 #include "coffcode.h"
 
-static const bfd_target *ia64coff_object_p PARAMS ((bfd *));
-
 static const bfd_target *
-ia64coff_object_p (abfd)
-     bfd *abfd;
+ia64coff_object_p (bfd *abfd)
 {
 #ifdef COFF_IMAGE_WITH_PE
   {
diff --git a/bfd/coff-m68k.c b/bfd/coff-m68k.c
index b53cc5f..5287beb 100644
--- a/bfd/coff-m68k.c
+++ b/bfd/coff-m68k.c
@@ -1,6 +1,6 @@
 /* BFD back-end for Motorola 68000 COFF binaries.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999,
-   2000, 2001, 2002, 2003, 2005, 2007, 2008
+   2000, 2001, 2002, 2003, 2005, 2007, 2008, 2012
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -60,25 +60,19 @@
 #define RELOC_SPECIAL_FN 0
 #else
 static bfd_reloc_status_type m68kcoff_common_addend_special_fn
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static reloc_howto_type *m68kcoff_common_addend_rtype_to_howto
-  PARAMS ((bfd *, asection *, struct internal_reloc *,
-	   struct coff_link_hash_entry *, struct internal_syment *,
-	   bfd_vma *));
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+
 #define RELOC_SPECIAL_FN m68kcoff_common_addend_special_fn
 #endif
 
-static bfd_boolean m68k_coff_is_local_label_name
-  PARAMS ((bfd *, const char *));
+static bfd_boolean m68k_coff_is_local_label_name (bfd *, const char *);
 
 /* On the delta, a symbol starting with L% is local.  We won't see
    such a symbol on other platforms, so it should be safe to always
    consider it local here.  */
 
 static bfd_boolean
-m68k_coff_is_local_label_name (abfd, name)
-     bfd *abfd;
-     const char *name;
+m68k_coff_is_local_label_name (bfd *abfd, const char *name)
 {
   if (name[0] == 'L' && name[1] == '%')
     return TRUE;
@@ -121,12 +115,11 @@
 /* Turn a howto into a reloc number */
 
 #ifdef ONLY_DECLARE_RELOCS
-extern void m68k_rtype2howto PARAMS ((arelent *internal, int relocentry));
-extern int m68k_howto2rtype PARAMS ((reloc_howto_type *));
-extern reloc_howto_type *m68k_reloc_type_lookup
-  PARAMS ((bfd *, bfd_reloc_code_real_type));
-extern reloc_howto_type *m68k_reloc_name_lookup
-  PARAMS ((bfd *, const char *));
+extern void m68k_rtype2howto (arelent *internal, int relocentry);
+extern int m68k_howto2rtype (reloc_howto_type *);
+extern reloc_howto_type * m68k_reloc_type_lookup
+  (bfd *, bfd_reloc_code_real_type);
+extern reloc_howto_type * m68k_reloc_name_lookup (bfd *, const char *);
 #else
 
 #ifdef STATIC_RELOCS
@@ -135,16 +128,13 @@
 #define STAT_REL
 #endif
 
-STAT_REL reloc_howto_type * m68k_reloc_type_lookup PARAMS ((bfd *, bfd_reloc_code_real_type));
-STAT_REL reloc_howto_type * m68k_reloc_name_lookup PARAMS ((bfd *, const char *));
-STAT_REL int m68k_howto2rtype PARAMS ((reloc_howto_type *));
-STAT_REL void m68k_rtype2howto PARAMS ((arelent *, int));
-
+STAT_REL void m68k_rtype2howto (arelent *, int);
+STAT_REL int  m68k_howto2rtype (reloc_howto_type *);
+STAT_REL reloc_howto_type * m68k_reloc_type_lookup (bfd *, bfd_reloc_code_real_type);
+STAT_REL reloc_howto_type * m68k_reloc_name_lookup (bfd *, const char *);
 
 STAT_REL void
-m68k_rtype2howto(internal, relocentry)
-     arelent *internal;
-     int relocentry;
+m68k_rtype2howto (arelent *internal, int relocentry)
 {
   switch (relocentry)
     {
@@ -159,8 +149,7 @@
 }
 
 STAT_REL int
-m68k_howto2rtype (internal)
-     reloc_howto_type *internal;
+m68k_howto2rtype (reloc_howto_type * internal)
 {
   if (internal->pc_relative)
     {
@@ -184,9 +173,8 @@
 }
 
 STAT_REL reloc_howto_type *
-m68k_reloc_type_lookup (abfd, code)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+m68k_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+			bfd_reloc_code_real_type code)
 {
   switch (code)
     {
@@ -235,19 +223,13 @@
 
 #define coff_rtype_to_howto m68kcoff_rtype_to_howto
 
-static reloc_howto_type *m68kcoff_rtype_to_howto
-  PARAMS ((bfd *, asection *, struct internal_reloc *,
-	   struct coff_link_hash_entry *, struct internal_syment *,
-	   bfd_vma *));
-
 static reloc_howto_type *
-m68kcoff_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *sec;
-     struct internal_reloc *rel;
-     struct coff_link_hash_entry *h ATTRIBUTE_UNUSED;
-     struct internal_syment *sym ATTRIBUTE_UNUSED;
-     bfd_vma *addendp;
+m68kcoff_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+			 asection *sec,
+			 struct internal_reloc *rel,
+			 struct coff_link_hash_entry *h ATTRIBUTE_UNUSED,
+			 struct internal_syment *sym ATTRIBUTE_UNUSED,
+			 bfd_vma *addendp)
 {
   arelent relent;
   reloc_howto_type *howto;
@@ -279,15 +261,13 @@
    reloc type to make any required adjustments.  */
 
 static bfd_reloc_status_type
-m68kcoff_common_addend_special_fn (abfd, reloc_entry, symbol, data,
-				   input_section, output_bfd, error_message)
-     bfd *abfd;
-     arelent *reloc_entry;
-     asymbol *symbol;
-     PTR data;
-     asection *input_section ATTRIBUTE_UNUSED;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+m68kcoff_common_addend_special_fn (bfd *abfd,
+				   arelent *reloc_entry,
+				   asymbol *symbol,
+				   void * data,
+				   asection *input_section ATTRIBUTE_UNUSED,
+				   bfd *output_bfd,
+				   char **error_message ATTRIBUTE_UNUSED)
 {
   symvalue diff;
 
@@ -402,13 +382,12 @@
    adjust common symbols.  */
 
 static reloc_howto_type *
-m68kcoff_common_addend_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *sec;
-     struct internal_reloc *rel;
-     struct coff_link_hash_entry *h;
-     struct internal_syment *sym;
-     bfd_vma *addendp;
+m68kcoff_common_addend_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+				       asection *sec,
+				       struct internal_reloc *rel,
+				       struct coff_link_hash_entry *h,
+				       struct internal_syment *sym,
+				       bfd_vma *addendp)
 {
   arelent relent;
   reloc_howto_type *howto;
@@ -456,12 +435,11 @@
    objects, and before the final_link entry point is called.  */
 
 bfd_boolean
-bfd_m68k_coff_create_embedded_relocs (abfd, info, datasec, relsec, errmsg)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     asection *datasec;
-     asection *relsec;
-     char **errmsg;
+bfd_m68k_coff_create_embedded_relocs (bfd *abfd,
+				      struct bfd_link_info *info,
+				      asection *datasec,
+				      asection *relsec,
+				      char **errmsg)
 {
   char *extsyms;
   bfd_size_type symesz;
diff --git a/bfd/coff-m88k.c b/bfd/coff-m88k.c
index 3855b52..e51bd05 100644
--- a/bfd/coff-m88k.c
+++ b/bfd/coff-m88k.c
@@ -1,6 +1,6 @@
 /* BFD back-end for Motorola 88000 COFF "Binary Compatibility Standard" files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2005, 2007, 2008   Free Software Foundation, Inc.
+   2001, 2002, 2003, 2005, 2007, 2008, 2012   Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -28,12 +28,8 @@
 #include "coff/internal.h"
 #include "libcoff.h"
 
-static bfd_boolean m88k_is_local_label_name PARAMS ((bfd *, const char *));
 static bfd_reloc_status_type m88k_special_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));
-static void reloc_processing
-  PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 
 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
 
@@ -45,23 +41,19 @@
 #define coff_bfd_is_local_label_name m88k_is_local_label_name
 
 static bfd_boolean
-m88k_is_local_label_name (abfd, name)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     const char *name;
+m88k_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED, const char *name)
 {
   return name[0] == '@';
 }
 
 static bfd_reloc_status_type
-m88k_special_reloc (abfd, reloc_entry, symbol, data,
-		    input_section, output_bfd, error_message)
-     bfd *abfd;
-     arelent *reloc_entry;
-     asymbol *symbol;
-     PTR data;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+m88k_special_reloc (bfd *abfd,
+		    arelent *reloc_entry,
+		    asymbol *symbol,
+		    void * data,
+		    asection *input_section,
+		    bfd *output_bfd,
+		    char **error_message ATTRIBUTE_UNUSED)
 {
   reloc_howto_type *howto = reloc_entry->howto;
 
@@ -236,9 +228,7 @@
 /* Code to turn an external r_type into a pointer to an entry in the
    above howto table.  */
 static void
-rtype2howto (cache_ptr, dst)
-     arelent *cache_ptr;
-     struct internal_reloc *dst;
+rtype2howto (arelent *cache_ptr, struct internal_reloc *dst)
 {
   if (dst->r_type >= R_PCR16L && dst->r_type <= R_VRT32)
     {
@@ -260,12 +250,11 @@
   reloc_processing(relent, reloc, symbols, abfd, section)
 
 static void
-reloc_processing (relent, reloc, symbols, abfd, section)
-     arelent *relent;
-     struct internal_reloc *reloc;
-     asymbol **symbols;
-     bfd *abfd;
-     asection *section;
+reloc_processing (arelent *relent,
+		  struct internal_reloc *reloc,
+		  asymbol **symbols,
+		  bfd *abfd,
+		  asection *section)
 {
   relent->address = reloc->r_vaddr;
   rtype2howto (relent, reloc);
diff --git a/bfd/coff-mcore.c b/bfd/coff-mcore.c
index 27b2ec3..9431e46 100644
--- a/bfd/coff-mcore.c
+++ b/bfd/coff-mcore.c
@@ -1,5 +1,5 @@
 /* BFD back-end for Motorola MCore COFF/PE
-   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2010, 2011
+   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -39,19 +39,10 @@
 /* This file is compiled more than once, but we only compile the
    final_link routine once.  */
 extern bfd_boolean mcore_bfd_coff_final_link
-  PARAMS ((bfd *, struct bfd_link_info *));
+  (bfd *, struct bfd_link_info *);
 static bfd_reloc_status_type mcore_coff_unsupported_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static bfd_boolean coff_mcore_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
-	   struct internal_reloc *, struct internal_syment *, asection **));
-static reloc_howto_type *mcore_coff_reloc_type_lookup
-  PARAMS ((bfd *, bfd_reloc_code_real_type));
-static reloc_howto_type *coff_mcore_rtype_to_howto
-  PARAMS ((bfd *, asection *, struct internal_reloc *,
-	   struct coff_link_hash_entry *, struct internal_syment *,
-	   bfd_vma *));
-static bfd_boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *));
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+
 
 /* The NT loader points the toc register to &toc + 32768, in order to
    use the complete range of a 16-bit displacement. We have to adjust
@@ -241,15 +232,13 @@
 }
 
 static bfd_reloc_status_type
-mcore_coff_unsupported_reloc (abfd, reloc_entry, symbol, data, input_section,
-			   output_bfd, error_message)
-     bfd * abfd;
-     arelent * reloc_entry;
-     asymbol * symbol ATTRIBUTE_UNUSED;
-     PTR data ATTRIBUTE_UNUSED;
-     asection * input_section ATTRIBUTE_UNUSED;
-     bfd * output_bfd ATTRIBUTE_UNUSED;
-     char ** error_message ATTRIBUTE_UNUSED;
+mcore_coff_unsupported_reloc (bfd * abfd,
+			      arelent * reloc_entry,
+			      asymbol * symbol ATTRIBUTE_UNUSED,
+			      void * data ATTRIBUTE_UNUSED,
+			      asection * input_section ATTRIBUTE_UNUSED,
+			      bfd * output_bfd ATTRIBUTE_UNUSED,
+			      char ** error_message ATTRIBUTE_UNUSED)
 {
   BFD_ASSERT (reloc_entry->howto != (reloc_howto_type *)0);
 
@@ -266,9 +255,8 @@
  case bfd_rtype: return & mcore_coff_howto_table [mcore_rtype]
 
 static reloc_howto_type *
-mcore_coff_reloc_type_lookup (abfd, code)
-     bfd * abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+mcore_coff_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
+			      bfd_reloc_code_real_type code)
 {
   switch (code)
     {
@@ -307,13 +295,12 @@
   (cache_ptr)->howto = mcore_coff_howto_table + (dst)->r_type;
 
 static reloc_howto_type *
-coff_mcore_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
-     bfd * abfd ATTRIBUTE_UNUSED;
-     asection * sec;
-     struct internal_reloc * rel;
-     struct coff_link_hash_entry * h ATTRIBUTE_UNUSED;
-     struct internal_syment * sym;
-     bfd_vma * addendp;
+coff_mcore_rtype_to_howto (bfd * abfd ATTRIBUTE_UNUSED,
+			   asection * sec,
+			   struct internal_reloc * rel,
+			   struct coff_link_hash_entry * h ATTRIBUTE_UNUSED,
+			   struct internal_syment * sym,
+			   bfd_vma * addendp)
 {
   reloc_howto_type * howto;
 
@@ -348,25 +335,21 @@
    This function is referenced in pe_mkobject in peicode.h.  */
 
 static bfd_boolean
-in_reloc_p (abfd, howto)
-     bfd * abfd ATTRIBUTE_UNUSED;
-     reloc_howto_type * howto;
+in_reloc_p (bfd * abfd ATTRIBUTE_UNUSED, reloc_howto_type * howto)
 {
   return ! howto->pc_relative && howto->type != IMAGE_REL_MCORE_RVA;
 }
 
 /* The reloc processing routine for the optimized COFF linker.  */
 static bfd_boolean
-coff_mcore_relocate_section (output_bfd, info, input_bfd, input_section,
-			   contents, relocs, syms, sections)
-     bfd * output_bfd;
-     struct bfd_link_info * info;
-     bfd * input_bfd;
-     asection * input_section;
-     bfd_byte * contents;
-     struct internal_reloc * relocs;
-     struct internal_syment * syms;
-     asection ** sections;
+coff_mcore_relocate_section (bfd * output_bfd,
+			     struct bfd_link_info * info,
+			     bfd * input_bfd,
+			     asection * input_section,
+			     bfd_byte * contents,
+			     struct internal_reloc * relocs,
+			     struct internal_syment * syms,
+			     asection ** sections)
 {
   struct internal_reloc * rel;
   struct internal_reloc * relend;
diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c
index 4048ca8..ec4d1a5 100644
--- a/bfd/coff-mips.c
+++ b/bfd/coff-mips.c
@@ -1,6 +1,6 @@
 /* BFD back-end for MIPS Extended-Coff files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2011
+   2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2011, 2012
    Free Software Foundation, Inc.
    Original version by Per Bothner.
    Full support added by Ian Lance Taylor, [email protected].
@@ -35,37 +35,19 @@
 #include "libecoff.h"
 
 /* Prototypes for static functions.  */
+static bfd_reloc_status_type
+mips_generic_reloc
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_reloc_status_type
+mips_refhi_reloc
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_reloc_status_type
+mips_reflo_reloc
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_reloc_status_type
+mips_gprel_reloc
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 
-static bfd_boolean mips_ecoff_bad_format_hook
-  PARAMS ((bfd *abfd, PTR filehdr));
-static void mips_ecoff_swap_reloc_in
-  PARAMS ((bfd *, PTR, struct internal_reloc *));
-static void mips_ecoff_swap_reloc_out
-  PARAMS ((bfd *, const struct internal_reloc *, PTR));
-static void mips_adjust_reloc_in
-  PARAMS ((bfd *, const struct internal_reloc *, arelent *));
-static void mips_adjust_reloc_out
-  PARAMS ((bfd *, const arelent *, struct internal_reloc *));
-static bfd_reloc_status_type mips_generic_reloc
-  PARAMS ((bfd *abfd, arelent *reloc, asymbol *symbol, PTR data,
-	   asection *section, bfd *output_bfd, char **error));
-static bfd_reloc_status_type mips_refhi_reloc
-  PARAMS ((bfd *abfd, arelent *reloc, asymbol *symbol, PTR data,
-	   asection *section, bfd *output_bfd, char **error));
-static bfd_reloc_status_type mips_reflo_reloc
-  PARAMS ((bfd *abfd, arelent *reloc, asymbol *symbol, PTR data,
-	   asection *section, bfd *output_bfd, char **error));
-static bfd_reloc_status_type mips_gprel_reloc
-  PARAMS ((bfd *abfd, arelent *reloc, asymbol *symbol, PTR data,
-	   asection *section, bfd *output_bfd, char **error));
-static void mips_relocate_hi
-  PARAMS ((struct internal_reloc *refhi, struct internal_reloc *reflo,
-	   bfd *input_bfd, asection *input_section, bfd_byte *contents,
-	   bfd_vma relocation));
-static bfd_boolean mips_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, PTR));
-static reloc_howto_type *mips_bfd_reloc_type_lookup
-  PARAMS ((bfd *, bfd_reloc_code_real_type));
 
 /* ECOFF has COFF sections, but the debugging information is stored in
    a completely different format.  ECOFF targets use some of the
@@ -79,12 +61,12 @@
 #define NO_COFF_RELOCS
 #define NO_COFF_SYMBOLS
 #define NO_COFF_LINENOS
-#define coff_swap_filehdr_in mips_ecoff_swap_filehdr_in
+#define coff_swap_filehdr_in  mips_ecoff_swap_filehdr_in
 #define coff_swap_filehdr_out mips_ecoff_swap_filehdr_out
-#define coff_swap_aouthdr_in mips_ecoff_swap_aouthdr_in
+#define coff_swap_aouthdr_in  mips_ecoff_swap_aouthdr_in
 #define coff_swap_aouthdr_out mips_ecoff_swap_aouthdr_out
-#define coff_swap_scnhdr_in mips_ecoff_swap_scnhdr_in
-#define coff_swap_scnhdr_out mips_ecoff_swap_scnhdr_out
+#define coff_swap_scnhdr_in   mips_ecoff_swap_scnhdr_in
+#define coff_swap_scnhdr_out  mips_ecoff_swap_scnhdr_out
 
 #include "coffswap.h"
 
@@ -253,9 +235,7 @@
 /* See whether the magic number matches.  */
 
 static bfd_boolean
-mips_ecoff_bad_format_hook (abfd, filehdr)
-     bfd *abfd;
-     PTR filehdr;
+mips_ecoff_bad_format_hook (bfd * abfd, void * filehdr)
 {
   struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
 
@@ -287,10 +267,9 @@
 /* Swap a reloc in.  */
 
 static void
-mips_ecoff_swap_reloc_in (abfd, ext_ptr, intern)
-     bfd *abfd;
-     PTR ext_ptr;
-     struct internal_reloc *intern;
+mips_ecoff_swap_reloc_in (bfd *  abfd,
+			  void * ext_ptr,
+			  struct internal_reloc *intern)
 {
   const RELOC *ext = (RELOC *) ext_ptr;
 
@@ -326,10 +305,9 @@
 /* Swap a reloc out.  */
 
 static void
-mips_ecoff_swap_reloc_out (abfd, intern, dst)
-     bfd *abfd;
-     const struct internal_reloc *intern;
-     PTR dst;
+mips_ecoff_swap_reloc_out (bfd * abfd,
+			   const struct internal_reloc * intern,
+			   void * dst)
 {
   RELOC *ext = (RELOC *) dst;
   long r_symndx;
@@ -367,10 +345,9 @@
    this backend routine.  It must fill in the howto field.  */
 
 static void
-mips_adjust_reloc_in (abfd, intern, rptr)
-     bfd *abfd;
-     const struct internal_reloc *intern;
-     arelent *rptr;
+mips_adjust_reloc_in (bfd *abfd,
+		      const struct internal_reloc *intern,
+		      arelent *rptr)
 {
   if (intern->r_type > MIPS_R_PCREL16)
     abort ();
@@ -392,10 +369,9 @@
    are needed for MIPS.  */
 
 static void
-mips_adjust_reloc_out (abfd, rel, intern)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     const arelent *rel ATTRIBUTE_UNUSED;
-     struct internal_reloc *intern ATTRIBUTE_UNUSED;
+mips_adjust_reloc_out (bfd *abfd ATTRIBUTE_UNUSED,
+		       const arelent *rel ATTRIBUTE_UNUSED,
+		       struct internal_reloc *intern ATTRIBUTE_UNUSED)
 {
 }
 
@@ -411,20 +387,13 @@
    relocatable output against an external symbol.  */
 
 static bfd_reloc_status_type
-mips_generic_reloc (abfd,
-		    reloc_entry,
-		    symbol,
-		    data,
-		    input_section,
-		    output_bfd,
-		    error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc_entry;
-     asymbol *symbol;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+mips_generic_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+		    arelent *reloc_entry,
+		    asymbol *symbol,
+		    void * data ATTRIBUTE_UNUSED,
+		    asection *input_section,
+		    bfd *output_bfd,
+		    char **error_message ATTRIBUTE_UNUSED)
 {
   if (output_bfd != (bfd *) NULL
       && (symbol->flags & BSF_SECTION_SYM) == 0
@@ -458,20 +427,13 @@
 static struct mips_hi *mips_refhi_list;
 
 static bfd_reloc_status_type
-mips_refhi_reloc (abfd,
-		  reloc_entry,
-		  symbol,
-		  data,
-		  input_section,
-		  output_bfd,
-		  error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc_entry;
-     asymbol *symbol;
-     PTR data;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+mips_refhi_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+		  arelent *reloc_entry,
+		  asymbol *symbol,
+		  void * data,
+		  asection *input_section,
+		  bfd *output_bfd,
+		  char **error_message ATTRIBUTE_UNUSED)
 {
   bfd_reloc_status_type ret;
   bfd_vma relocation;
@@ -524,20 +486,13 @@
    relocation described above.  */
 
 static bfd_reloc_status_type
-mips_reflo_reloc (abfd,
-		  reloc_entry,
-		  symbol,
-		  data,
-		  input_section,
-		  output_bfd,
-		  error_message)
-     bfd *abfd;
-     arelent *reloc_entry;
-     asymbol *symbol;
-     PTR data;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message;
+mips_reflo_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+		  arelent *reloc_entry,
+		  asymbol *symbol,
+		  void * data,
+		  asection *input_section,
+		  bfd *output_bfd,
+		  char **error_message ATTRIBUTE_UNUSED)
 {
   if (mips_refhi_list != NULL)
     {
@@ -592,20 +547,13 @@
    the offset from the gp register.  */
 
 static bfd_reloc_status_type
-mips_gprel_reloc (abfd,
-		  reloc_entry,
-		  symbol,
-		  data,
-		  input_section,
-		  output_bfd,
-		  error_message)
-     bfd *abfd;
-     arelent *reloc_entry;
-     asymbol *symbol;
-     PTR data;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message;
+mips_gprel_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+		  arelent *reloc_entry,
+		  asymbol *symbol,
+		  void * data,
+		  asection *input_section,
+		  bfd *output_bfd,
+		  char **error_message ATTRIBUTE_UNUSED)
 {
   bfd_boolean relocatable;
   bfd_vma gp;
@@ -732,9 +680,8 @@
 /* Get the howto structure for a generic reloc type.  */
 
 static reloc_howto_type *
-mips_bfd_reloc_type_lookup (abfd, code)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+mips_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+			    bfd_reloc_code_real_type code)
 {
   int mips_type;
 
@@ -794,14 +741,12 @@
    instructions.  */
 
 static void
-mips_relocate_hi (refhi, reflo, input_bfd, input_section, contents,
-		  relocation)
-     struct internal_reloc *refhi;
-     struct internal_reloc *reflo;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     bfd_vma relocation;
+mips_relocate_hi (struct internal_reloc *refhi,
+		  struct internal_reloc *reflo,
+		  bfd *input_bfd,
+		  asection *input_section,
+		  bfd_byte *contents,
+		  bfd_vma relocation)
 {
   unsigned long insn;
   unsigned long val;
@@ -841,14 +786,12 @@
 /* Relocate a section while linking a MIPS ECOFF file.  */
 
 static bfd_boolean
-mips_relocate_section (output_bfd, info, input_bfd, input_section,
-		       contents, external_relocs)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     PTR external_relocs;
+mips_relocate_section (bfd *output_bfd,
+		       struct bfd_link_info *info,
+		       bfd *input_bfd,
+		       asection *input_section,
+		       bfd_byte *contents,
+		       void * external_relocs)
 {
   asection **symndx_to_section;
   struct ecoff_link_hash_entry **sym_hashes;
@@ -928,7 +871,7 @@
       bfd_reloc_status_type r;
 
       if (! got_lo)
-	mips_ecoff_swap_reloc_in (input_bfd, (PTR) ext_rel, &int_rel);
+	mips_ecoff_swap_reloc_in (input_bfd, ext_rel, &int_rel);
       else
 	{
 	  int_rel = lo_int_rel;
@@ -951,7 +894,7 @@
 	       lo_ext_rel < ext_rel_end;
 	       lo_ext_rel++)
 	    {
-	      mips_ecoff_swap_reloc_in (input_bfd, (PTR) lo_ext_rel,
+	      mips_ecoff_swap_reloc_in (input_bfd, lo_ext_rel,
 					&lo_int_rel);
 	      if (lo_int_rel.r_type != int_rel.r_type)
 		break;
@@ -1190,7 +1133,7 @@
 			      - input_section->vma);
 
 	  /* Save the changed reloc information.  */
-	  mips_ecoff_swap_reloc_out (input_bfd, &int_rel, (PTR) ext_rel);
+	  mips_ecoff_swap_reloc_out (input_bfd, &int_rel, ext_rel);
 	}
       else
 	{
@@ -1303,16 +1246,16 @@
 {
   /* COFF backend structure.  */
   {
-    (void (*) PARAMS ((bfd *,PTR,int,int,int,int,PTR))) bfd_void, /* aux_in */
-    (void (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* sym_in */
-    (void (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* lineno_in */
-    (unsigned (*) PARAMS ((bfd *,PTR,int,int,int,int,PTR)))bfd_void,/*aux_out*/
-    (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* sym_out */
-    (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* lineno_out */
-    (unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* reloc_out */
+    (void (*) (bfd *,void *,int,int,int,int,void *)) bfd_void, /* aux_in */
+    (void (*) (bfd *,void *,void *)) bfd_void, /* sym_in */
+    (void (*) (bfd *,void *,void *)) bfd_void, /* lineno_in */
+    (unsigned (*) (bfd *,void *,int,int,int,int,void *)) bfd_void,/*aux_out*/
+    (unsigned (*) (bfd *,void *,void *)) bfd_void, /* sym_out */
+    (unsigned (*) (bfd *,void *,void *)) bfd_void, /* lineno_out */
+    (unsigned (*) (bfd *,void *,void *)) bfd_void, /* reloc_out */
     mips_ecoff_swap_filehdr_out, mips_ecoff_swap_aouthdr_out,
     mips_ecoff_swap_scnhdr_out,
-    FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, TRUE, 
+    FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, TRUE,
     ECOFF_NO_LONG_SECTION_NAMES, 4, FALSE, 2,
     mips_ecoff_swap_filehdr_in, mips_ecoff_swap_aouthdr_in,
     mips_ecoff_swap_scnhdr_in, NULL,
@@ -1466,7 +1409,7 @@
 
   & ecoff_big_vec,
 
-  (PTR) &mips_ecoff_backend_data
+  & mips_ecoff_backend_data
 };
 
 const bfd_target ecoff_big_vec =
@@ -1510,7 +1453,7 @@
 
   & ecoff_little_vec,
 
-  (PTR) &mips_ecoff_backend_data
+  & mips_ecoff_backend_data
 };
 
 const bfd_target ecoff_biglittle_vec =
@@ -1555,5 +1498,5 @@
 
   NULL,
 
-  (PTR) &mips_ecoff_backend_data
+  & mips_ecoff_backend_data
 };
diff --git a/bfd/coff-or32.c b/bfd/coff-or32.c
index a9683df..18835e1 100644
--- a/bfd/coff-or32.c
+++ b/bfd/coff-or32.c
@@ -1,5 +1,5 @@
 /* BFD back-end for OpenRISC 1000 COFF binaries.
-   Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011
+   Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012
    Free Software Foundation, Inc.
    Contributed by Ivan Guzvinec  <[email protected]>
 
@@ -29,18 +29,8 @@
 #include "coff/internal.h"
 #include "libcoff.h"
 
-static long get_symbol_value
-  PARAMS ((asymbol *));
 static bfd_reloc_status_type or32_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static bfd_boolean coff_or32_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
-	   struct internal_reloc *, struct internal_syment *, asection **));
-static bfd_boolean coff_or32_adjust_symndx
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
-	   struct internal_reloc *, bfd_boolean *));
-static void reloc_processing
-  PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 
 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
 
@@ -61,8 +51,7 @@
 /* Provided the symbol, returns the value reffed.  */
 
 static long
-get_symbol_value (symbol)
-     asymbol *symbol;
+get_symbol_value (asymbol *symbol)
 {
   long relocation = 0;
 
@@ -79,15 +68,13 @@
 /* This function is in charge of performing all the or32 relocations.  */
 
 static bfd_reloc_status_type
-or32_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
-            error_message)
-     bfd *abfd;
-     arelent *reloc_entry;
-     asymbol *symbol_in;
-     PTR data;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message;
+or32_reloc (bfd *abfd,
+	    arelent *reloc_entry,
+	    asymbol *symbol_in,
+	    void * data,
+	    asection *input_section,
+	    bfd *output_bfd,
+	    char **error_message)
 {
   /* The consth relocation comes in two parts, we have to remember
      the state between calls, in these variables.  */
@@ -289,12 +276,11 @@
   reloc_processing (relent, reloc, symbols, abfd, section)
 
 static void
-reloc_processing (relent,reloc, symbols, abfd, section)
-     arelent *relent;
-     struct internal_reloc *reloc;
-     asymbol **symbols;
-     bfd *abfd;
-     asection *section;
+reloc_processing (arelent *relent,
+		  struct internal_reloc *reloc,
+		  asymbol **symbols,
+		  bfd *abfd,
+		  asection *section)
 {
   static bfd_vma ihihalf_vaddr = (bfd_vma) -1;
 
@@ -333,16 +319,14 @@
 /* The reloc processing routine for the optimized COFF linker.  */
 
 static bfd_boolean
-coff_or32_relocate_section (output_bfd, info, input_bfd, input_section,
-                            contents, relocs, syms, sections)
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     struct internal_reloc *relocs;
-     struct internal_syment *syms;
-     asection **sections;
+coff_or32_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
+			    struct bfd_link_info *info,
+			    bfd *input_bfd,
+			    asection *input_section,
+			    bfd_byte *contents,
+			    struct internal_reloc *relocs,
+			    struct internal_syment *syms,
+			    asection **sections)
 {
   struct internal_reloc *rel;
   struct internal_reloc *relend;
@@ -554,13 +538,12 @@
    is actually an addend, not a symbol index at all.  */
 
 static bfd_boolean
-coff_or32_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp)
-     bfd *obfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     bfd *ibfd ATTRIBUTE_UNUSED;
-     asection *sec ATTRIBUTE_UNUSED;
-     struct internal_reloc *irel;
-     bfd_boolean *adjustedp;
+coff_or32_adjust_symndx (bfd *obfd ATTRIBUTE_UNUSED,
+			 struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			 bfd *ibfd ATTRIBUTE_UNUSED,
+			 asection *sec ATTRIBUTE_UNUSED,
+			 struct internal_reloc *irel,
+			 bfd_boolean *adjustedp)
 {
   if (irel->r_type == R_IHCONST)
     *adjustedp = TRUE;
diff --git a/bfd/coff-ppc.c b/bfd/coff-ppc.c
index b37a224..eb1aa81 100644
--- a/bfd/coff-ppc.c
+++ b/bfd/coff-ppc.c
@@ -1,7 +1,7 @@
 /* BFD back-end for PowerPC Microsoft Portable Executable files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
+   2012  Free Software Foundation, Inc.
 
    Original version pieced together by Kim Knuttila ([email protected])
 
@@ -52,9 +52,8 @@
 
 /* This file is compiled more than once, but we only compile the
    final_link routine once.  */
-extern bfd_boolean ppc_bfd_coff_final_link
-  PARAMS ((bfd *, struct bfd_link_info *));
-extern void dump_toc PARAMS ((PTR));
+extern bfd_boolean ppc_bfd_coff_final_link (bfd *, struct bfd_link_info *);
+extern void dump_toc (void *);
 
 /* The toc is a set of bfd_vma fields. We use the fact that valid
    addresses are even (i.e. the bit representing "1" is off) to allow
@@ -123,26 +122,12 @@
   struct coff_link_hash_table root; /* First entry, as required.  */
 };
 
-static struct bfd_hash_entry *ppc_coff_link_hash_newfunc
-  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
-	   const char *));
-static struct bfd_link_hash_table *ppc_coff_link_hash_table_create
-  PARAMS ((bfd *));
-static bfd_boolean coff_ppc_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
-	   struct internal_reloc *, struct internal_syment *, asection **));
-static reloc_howto_type *coff_ppc_rtype_to_howto
-  PARAMS ((bfd *, asection *, struct internal_reloc *,
-	   struct coff_link_hash_entry *, struct internal_syment *,
-	   bfd_vma *));
-
 /* Routine to create an entry in the link hash table.  */
 
 static struct bfd_hash_entry *
-ppc_coff_link_hash_newfunc (entry, table, string)
-     struct bfd_hash_entry *entry;
-     struct bfd_hash_table *table;
-     const char *string;
+ppc_coff_link_hash_newfunc (struct bfd_hash_entry * entry,
+			    struct bfd_hash_table * table,
+			    const char * string)
 {
   struct ppc_coff_link_hash_entry *ret =
     (struct ppc_coff_link_hash_entry *) entry;
@@ -180,9 +165,10 @@
 static bfd_boolean
 ppc_coff_link_hash_table_init (struct ppc_coff_link_hash_table *table,
 			       bfd *abfd,
-			       struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *,
-								  struct bfd_hash_table *,
-								  const char *),
+			       struct bfd_hash_entry *(*newfunc)
+			         (struct bfd_hash_entry *,
+				  struct bfd_hash_table *,
+				  const char *),
 			       unsigned int entsize)
 {
   return _bfd_coff_link_hash_table_init (&table->root, abfd, newfunc, entsize);
@@ -191,8 +177,7 @@
 /* Create a PE linker hash table.  */
 
 static struct bfd_link_hash_table *
-ppc_coff_link_hash_table_create (abfd)
-     bfd *abfd;
+ppc_coff_link_hash_table_create (bfd *abfd)
 {
   struct ppc_coff_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct ppc_coff_link_hash_table);
@@ -314,60 +299,24 @@
 /* Static helper functions to make relocation work.  */
 /* (Work In Progress) */
 
-static bfd_reloc_status_type ppc_refhi_reloc PARAMS ((bfd *abfd,
-						      arelent *reloc,
-						      asymbol *symbol,
-						      PTR data,
-						      asection *section,
-						      bfd *output_bfd,
-						      char **error));
-static bfd_reloc_status_type ppc_pair_reloc PARAMS ((bfd *abfd,
-						     arelent *reloc,
-						     asymbol *symbol,
-						     PTR data,
-						     asection *section,
-						     bfd *output_bfd,
-						     char **error));
-
-static bfd_reloc_status_type ppc_toc16_reloc PARAMS ((bfd *abfd,
-						      arelent *reloc,
-						      asymbol *symbol,
-						      PTR data,
-						      asection *section,
-						      bfd *output_bfd,
-						      char **error));
+static bfd_reloc_status_type ppc_refhi_reloc
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_reloc_status_type ppc_pair_reloc
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_reloc_status_type ppc_toc16_reloc
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_reloc_status_type ppc_section_reloc
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_reloc_status_type ppc_secrel_reloc
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_reloc_status_type ppc_imglue_reloc
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 
-static bfd_reloc_status_type ppc_section_reloc PARAMS ((bfd *abfd,
-							arelent *reloc,
-							asymbol *symbol,
-							PTR data,
-							asection *section,
-							bfd *output_bfd,
-							char **error));
-
-static bfd_reloc_status_type ppc_secrel_reloc PARAMS ((bfd *abfd,
-						       arelent *reloc,
-						       asymbol *symbol,
-						       PTR data,
-						       asection *section,
-						       bfd *output_bfd,
-						       char **error));
-
-static bfd_reloc_status_type ppc_imglue_reloc PARAMS ((bfd *abfd,
-						       arelent *reloc,
-						       asymbol *symbol,
-						       PTR data,
-						       asection *section,
-						       bfd *output_bfd,
-						       char **error));
-
-static bfd_boolean in_reloc_p PARAMS((bfd *abfd, reloc_howto_type *howto));
-
 /* FIXME: It'll take a while to get through all of these. I only need a few to
    get us started, so those I'll make sure work. Those marked FIXME are either
    completely unverified or have a specific unknown marked in the comment.  */
 
-/* Relocation entries for Windows/NT on PowerPC.                             
+/* Relocation entries for Windows/NT on PowerPC.
 
    From the document "" we find the following listed as used relocs:
 
@@ -816,15 +765,11 @@
 extern struct list_ele *head;
 extern struct list_ele *tail;
 
-static void record_toc
-  PARAMS ((asection *, bfd_signed_vma, enum ref_category, const char *));
-
 static void
-record_toc (toc_section, our_toc_offset, cat, name)
-     asection *toc_section;
-     bfd_signed_vma our_toc_offset;
-     enum ref_category cat;
-     const char *name;
+record_toc (asection *toc_section,
+	    bfd_signed_vma our_toc_offset,
+	    enum ref_category cat,
+	    const char *name)
 {
   /* Add this entry to our toc addr-offset-name list.  */
   bfd_size_type amt = sizeof (struct list_ele);
@@ -852,19 +797,13 @@
 
 #ifdef COFF_IMAGE_WITH_PE
 
-static bfd_boolean ppc_record_toc_entry
-  PARAMS ((bfd *, struct bfd_link_info *, asection *, int, enum toc_type));
-static void ppc_mark_symbol_as_glue
-  PARAMS ((bfd *, int, struct internal_reloc *));
-
 /* Record a toc offset against a symbol.  */
 static bfd_boolean
-ppc_record_toc_entry(abfd, info, sec, sym, toc_kind)
-     bfd *abfd;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     asection *sec ATTRIBUTE_UNUSED;
-     int sym;
-     enum toc_type toc_kind ATTRIBUTE_UNUSED;
+ppc_record_toc_entry (bfd *abfd,
+		      struct bfd_link_info *info ATTRIBUTE_UNUSED,
+		      asection *sec ATTRIBUTE_UNUSED,
+		      int sym,
+		      enum toc_type toc_kind ATTRIBUTE_UNUSED)
 {
   struct ppc_coff_link_hash_entry *h;
   int *local_syms;
@@ -937,10 +876,9 @@
 
 /* Record a toc offset against a symbol.  */
 static void
-ppc_mark_symbol_as_glue(abfd, sym, rel)
-     bfd *abfd;
-     int sym;
-     struct internal_reloc *rel;
+ppc_mark_symbol_as_glue (bfd *abfd,
+			 int sym,
+			 struct internal_reloc *rel)
 {
   struct ppc_coff_link_hash_entry *h;
 
@@ -959,9 +897,9 @@
 /* Return TRUE if this relocation should
    appear in the output .reloc section.  */
 
-static bfd_boolean in_reloc_p(abfd, howto)
-     bfd * abfd ATTRIBUTE_UNUSED;
-     reloc_howto_type *howto;
+static bfd_boolean
+in_reloc_p (bfd * abfd ATTRIBUTE_UNUSED,
+	    reloc_howto_type *howto)
 {
   return
     (! howto->pc_relative)
@@ -993,16 +931,14 @@
 /* The reloc processing routine for the optimized COFF linker.  */
 
 static bfd_boolean
-coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section,
-			   contents, relocs, syms, sections)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     struct internal_reloc *relocs;
-     struct internal_syment *syms;
-     asection **sections;
+coff_ppc_relocate_section (bfd *output_bfd,
+			   struct bfd_link_info *info,
+			   bfd *input_bfd,
+			   asection *input_section,
+			   bfd_byte *contents,
+			   struct internal_reloc *relocs,
+			   struct internal_syment *syms,
+			   asection **sections)
 {
   struct internal_reloc *rel;
   struct internal_reloc *relend;
@@ -1264,7 +1200,7 @@
 	  {
 	    /* To solve this, we need to know whether or not the symbol
 	       appearing on the call instruction is a glue function or not.
-	       A glue function must announce itself via a IMGLUE reloc, and 
+	       A glue function must announce itself via a IMGLUE reloc, and
 	       the reloc contains the required toc restore instruction.  */
 	    DUMP_RELOC2 (howto->name, rel);
 
@@ -1523,8 +1459,7 @@
 h3 = N_(" Offset  spelling                   (if present)\n");
 
 void
-dump_toc (vfile)
-     PTR vfile;
+dump_toc (void * vfile)
 {
   FILE *file = (FILE *) vfile;
   struct list_ele *t;
@@ -1570,8 +1505,7 @@
 }
 
 bfd_boolean
-ppc_allocate_toc_section (info)
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
+ppc_allocate_toc_section (struct bfd_link_info *info ATTRIBUTE_UNUSED)
 {
   asection *s;
   bfd_byte *foo;
@@ -1601,9 +1535,8 @@
 }
 
 bfd_boolean
-ppc_process_before_allocation (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info;
+ppc_process_before_allocation (bfd *abfd,
+			       struct bfd_link_info *info)
 {
   asection *sec;
   struct internal_reloc *i, *rel;
@@ -1664,15 +1597,13 @@
 #endif
 
 static bfd_reloc_status_type
-ppc_refhi_reloc (abfd, reloc_entry, symbol, data,
-		 input_section, output_bfd, error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc_entry ATTRIBUTE_UNUSED;
-     asymbol *symbol ATTRIBUTE_UNUSED;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *input_section ATTRIBUTE_UNUSED;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+ppc_refhi_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+		 arelent *reloc_entry ATTRIBUTE_UNUSED,
+		 asymbol *symbol ATTRIBUTE_UNUSED,
+		 void * data ATTRIBUTE_UNUSED,
+		 asection *input_section ATTRIBUTE_UNUSED,
+		 bfd *output_bfd,
+		 char **error_message ATTRIBUTE_UNUSED)
 {
   UN_IMPL("REFHI");
   DUMP_RELOC("REFHI",reloc_entry);
@@ -1684,15 +1615,13 @@
 }
 
 static bfd_reloc_status_type
-ppc_pair_reloc (abfd, reloc_entry, symbol, data,
-		input_section, output_bfd, error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc_entry ATTRIBUTE_UNUSED;
-     asymbol *symbol ATTRIBUTE_UNUSED;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *input_section ATTRIBUTE_UNUSED;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+ppc_pair_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+		arelent *reloc_entry ATTRIBUTE_UNUSED,
+		asymbol *symbol ATTRIBUTE_UNUSED,
+		void * data ATTRIBUTE_UNUSED,
+		asection *input_section ATTRIBUTE_UNUSED,
+		bfd *output_bfd,
+		char **error_message ATTRIBUTE_UNUSED)
 {
   UN_IMPL("PAIR");
   DUMP_RELOC("PAIR",reloc_entry);
@@ -1702,17 +1631,15 @@
 
   return bfd_reloc_undefined;
 }
-
+
 static bfd_reloc_status_type
-ppc_toc16_reloc (abfd, reloc_entry, symbol, data,
-		 input_section, output_bfd, error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc_entry ATTRIBUTE_UNUSED;
-     asymbol *symbol ATTRIBUTE_UNUSED;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *input_section ATTRIBUTE_UNUSED;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+ppc_toc16_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+		 arelent *reloc_entry ATTRIBUTE_UNUSED,
+		 asymbol *symbol ATTRIBUTE_UNUSED,
+		 void * data ATTRIBUTE_UNUSED,
+		 asection *input_section ATTRIBUTE_UNUSED,
+		 bfd *output_bfd,
+		 char **error_message ATTRIBUTE_UNUSED)
 {
   UN_IMPL ("TOCREL16");
   DUMP_RELOC ("TOCREL16",reloc_entry);
@@ -1724,15 +1651,13 @@
 }
 
 static bfd_reloc_status_type
-ppc_secrel_reloc (abfd, reloc_entry, symbol, data,
-		  input_section, output_bfd, error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc_entry ATTRIBUTE_UNUSED;
-     asymbol *symbol ATTRIBUTE_UNUSED;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *input_section ATTRIBUTE_UNUSED;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+ppc_secrel_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+		  arelent *reloc_entry ATTRIBUTE_UNUSED,
+		  asymbol *symbol ATTRIBUTE_UNUSED,
+		  void * data ATTRIBUTE_UNUSED,
+		  asection *input_section ATTRIBUTE_UNUSED,
+		  bfd *output_bfd,
+		  char **error_message ATTRIBUTE_UNUSED)
 {
   UN_IMPL("SECREL");
   DUMP_RELOC("SECREL",reloc_entry);
@@ -1744,15 +1669,13 @@
 }
 
 static bfd_reloc_status_type
-ppc_section_reloc (abfd, reloc_entry, symbol, data,
-		   input_section, output_bfd, error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc_entry ATTRIBUTE_UNUSED;
-     asymbol *symbol ATTRIBUTE_UNUSED;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *input_section ATTRIBUTE_UNUSED;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+ppc_section_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+		   arelent *reloc_entry ATTRIBUTE_UNUSED,
+		   asymbol *symbol ATTRIBUTE_UNUSED,
+		   void * data ATTRIBUTE_UNUSED,
+		   asection *input_section ATTRIBUTE_UNUSED,
+		   bfd *output_bfd,
+		   char **error_message ATTRIBUTE_UNUSED)
 {
   UN_IMPL("SECTION");
   DUMP_RELOC("SECTION",reloc_entry);
@@ -1764,15 +1687,14 @@
 }
 
 static bfd_reloc_status_type
-ppc_imglue_reloc (abfd, reloc_entry, symbol, data,
-		  input_section, output_bfd, error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc_entry ATTRIBUTE_UNUSED;
-     asymbol *symbol ATTRIBUTE_UNUSED;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *input_section ATTRIBUTE_UNUSED;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+ppc_imglue_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+		  arelent *reloc_entry ATTRIBUTE_UNUSED,
+		  asymbol *symbol ATTRIBUTE_UNUSED,
+		  void * data ATTRIBUTE_UNUSED,
+		  asection *input_section ATTRIBUTE_UNUSED,
+		  bfd *output_bfd,
+		  char **error_message ATTRIBUTE_UNUSED)
+
 {
   UN_IMPL("IMGLUE");
   DUMP_RELOC("IMGLUE",reloc_entry);
@@ -1789,12 +1711,9 @@
 /* FIXME: There is a possibility that when we read in a reloc from a file,
           that there are some bits encoded in the upper portion of the
 	  type field. Not yet implemented.  */
-static void ppc_coff_rtype2howto PARAMS ((arelent *, struct internal_reloc *));
 
 static void
-ppc_coff_rtype2howto (relent, internal)
-     arelent *relent;
-     struct internal_reloc *internal;
+ppc_coff_rtype2howto (arelent *relent, struct internal_reloc *internal)
 {
   /* We can encode one of three things in the type field, aside from the
      type:
@@ -1854,13 +1773,12 @@
 }
 
 static reloc_howto_type *
-coff_ppc_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *sec;
-     struct internal_reloc *rel;
-     struct coff_link_hash_entry *h ATTRIBUTE_UNUSED;
-     struct internal_syment *sym ATTRIBUTE_UNUSED;
-     bfd_vma *addendp;
+coff_ppc_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+			 asection *sec,
+			 struct internal_reloc *rel,
+			 struct coff_link_hash_entry *h ATTRIBUTE_UNUSED,
+			 struct internal_syment *sym ATTRIBUTE_UNUSED,
+			 bfd_vma *addendp)
 {
   reloc_howto_type *howto;
 
@@ -1929,13 +1847,9 @@
 #define HOW2MAP(bfd_rtype,ppc_rtype)  \
  case bfd_rtype: return &ppc_coff_howto_table[ppc_rtype]
 
-static reloc_howto_type *ppc_coff_reloc_type_lookup
-PARAMS ((bfd *, bfd_reloc_code_real_type));
-
 static reloc_howto_type *
-ppc_coff_reloc_type_lookup (abfd, code)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+ppc_coff_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+			    bfd_reloc_code_real_type code)
 {
   switch (code)
     {
@@ -2012,12 +1926,8 @@
 
 #ifndef COFF_IMAGE_WITH_PE
 
-static bfd_boolean ppc_do_last PARAMS ((bfd *));
-static bfd *ppc_get_last PARAMS ((void));
-
 static bfd_boolean
-ppc_do_last (abfd)
-     bfd *abfd;
+ppc_do_last (bfd *abfd)
 {
   if (abfd == bfd_of_toc_owner)
     return TRUE;
@@ -2026,7 +1936,7 @@
 }
 
 static bfd *
-ppc_get_last()
+ppc_get_last (void)
 {
   return bfd_of_toc_owner;
 }
@@ -2045,12 +1955,10 @@
 /* Do the final link step.  */
 
 bfd_boolean
-ppc_bfd_coff_final_link (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info;
+ppc_bfd_coff_final_link (bfd *abfd, struct bfd_link_info *info)
 {
   bfd_size_type symesz;
-  struct coff_final_link_info finfo;
+  struct coff_final_link_info flaginfo;
   bfd_boolean debug_merge_allocated;
   asection *o;
   struct bfd_link_order *p;
@@ -2070,29 +1978,29 @@
 
   symesz = bfd_coff_symesz (abfd);
 
-  finfo.info = info;
-  finfo.output_bfd = abfd;
-  finfo.strtab = NULL;
-  finfo.section_info = NULL;
-  finfo.last_file_index = -1;
-  finfo.last_bf_index = -1;
-  finfo.internal_syms = NULL;
-  finfo.sec_ptrs = NULL;
-  finfo.sym_indices = NULL;
-  finfo.outsyms = NULL;
-  finfo.linenos = NULL;
-  finfo.contents = NULL;
-  finfo.external_relocs = NULL;
-  finfo.internal_relocs = NULL;
+  flaginfo.info = info;
+  flaginfo.output_bfd = abfd;
+  flaginfo.strtab = NULL;
+  flaginfo.section_info = NULL;
+  flaginfo.last_file_index = -1;
+  flaginfo.last_bf_index = -1;
+  flaginfo.internal_syms = NULL;
+  flaginfo.sec_ptrs = NULL;
+  flaginfo.sym_indices = NULL;
+  flaginfo.outsyms = NULL;
+  flaginfo.linenos = NULL;
+  flaginfo.contents = NULL;
+  flaginfo.external_relocs = NULL;
+  flaginfo.internal_relocs = NULL;
   debug_merge_allocated = FALSE;
 
   coff_data (abfd)->link_info = info;
 
-  finfo.strtab = _bfd_stringtab_init ();
-  if (finfo.strtab == NULL)
+  flaginfo.strtab = _bfd_stringtab_init ();
+  if (flaginfo.strtab == NULL)
     goto error_return;
 
-  if (! coff_debug_merge_hash_table_init (&finfo.debug_merge))
+  if (! coff_debug_merge_hash_table_init (&flaginfo.debug_merge))
     goto error_return;
   debug_merge_allocated = TRUE;
 
@@ -2171,15 +2079,15 @@
          the target_index fields are 1 based.  */
       amt = abfd->section_count + 1;
       amt *= sizeof (struct coff_link_section_info);
-      finfo.section_info = (struct coff_link_section_info *) bfd_malloc (amt);
+      flaginfo.section_info = (struct coff_link_section_info *) bfd_malloc (amt);
 
-      if (finfo.section_info == NULL)
+      if (flaginfo.section_info == NULL)
 	goto error_return;
 
       for (i = 0; i <= abfd->section_count; i++)
 	{
-	  finfo.section_info[i].relocs = NULL;
-	  finfo.section_info[i].rel_hashes = NULL;
+	  flaginfo.section_info[i].relocs = NULL;
+	  flaginfo.section_info[i].rel_hashes = NULL;
 	}
     }
 
@@ -2217,14 +2125,14 @@
 	  BFD_ASSERT (info->relocatable);
 	  amt = o->reloc_count;
 	  amt *= sizeof (struct internal_reloc);
-	  finfo.section_info[o->target_index].relocs =
+	  flaginfo.section_info[o->target_index].relocs =
 	    (struct internal_reloc *) bfd_malloc (amt);
 	  amt = o->reloc_count;
 	  amt *= sizeof (struct coff_link_hash_entry *);
-	  finfo.section_info[o->target_index].rel_hashes =
+	  flaginfo.section_info[o->target_index].rel_hashes =
 	    (struct coff_link_hash_entry **) bfd_malloc (amt);
-	  if (finfo.section_info[o->target_index].relocs == NULL
-	      || finfo.section_info[o->target_index].rel_hashes == NULL)
+	  if (flaginfo.section_info[o->target_index].relocs == NULL
+	      || flaginfo.section_info[o->target_index].rel_hashes == NULL)
 	    goto error_return;
 
 	  if (o->reloc_count > max_output_reloc_count)
@@ -2255,31 +2163,31 @@
 
   /* Allocate some buffers used while linking.  */
   amt = max_sym_count * sizeof (struct internal_syment);
-  finfo.internal_syms = (struct internal_syment *) bfd_malloc (amt);
+  flaginfo.internal_syms = (struct internal_syment *) bfd_malloc (amt);
   amt = max_sym_count * sizeof (asection *);
-  finfo.sec_ptrs = (asection **) bfd_malloc (amt);
+  flaginfo.sec_ptrs = (asection **) bfd_malloc (amt);
   amt = max_sym_count * sizeof (long);
-  finfo.sym_indices = (long *) bfd_malloc (amt);
+  flaginfo.sym_indices = (long *) bfd_malloc (amt);
   amt = (max_sym_count + 1) * symesz;
-  finfo.outsyms = (bfd_byte *) bfd_malloc (amt);
+  flaginfo.outsyms = (bfd_byte *) bfd_malloc (amt);
   amt = max_lineno_count * bfd_coff_linesz (abfd);
-  finfo.linenos = (bfd_byte *) bfd_malloc (amt);
-  finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
-  finfo.external_relocs = (bfd_byte *) bfd_malloc (max_reloc_count * relsz);
+  flaginfo.linenos = (bfd_byte *) bfd_malloc (amt);
+  flaginfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
+  flaginfo.external_relocs = (bfd_byte *) bfd_malloc (max_reloc_count * relsz);
   if (! info->relocatable)
     {
       amt = max_reloc_count * sizeof (struct internal_reloc);
-      finfo.internal_relocs = (struct internal_reloc *) bfd_malloc (amt);
+      flaginfo.internal_relocs = (struct internal_reloc *) bfd_malloc (amt);
     }
-  if ((finfo.internal_syms == NULL && max_sym_count > 0)
-      || (finfo.sec_ptrs == NULL && max_sym_count > 0)
-      || (finfo.sym_indices == NULL && max_sym_count > 0)
-      || finfo.outsyms == NULL
-      || (finfo.linenos == NULL && max_lineno_count > 0)
-      || (finfo.contents == NULL && max_contents_size > 0)
-      || (finfo.external_relocs == NULL && max_reloc_count > 0)
+  if ((flaginfo.internal_syms == NULL && max_sym_count > 0)
+      || (flaginfo.sec_ptrs == NULL && max_sym_count > 0)
+      || (flaginfo.sym_indices == NULL && max_sym_count > 0)
+      || flaginfo.outsyms == NULL
+      || (flaginfo.linenos == NULL && max_lineno_count > 0)
+      || (flaginfo.contents == NULL && max_contents_size > 0)
+      || (flaginfo.external_relocs == NULL && max_reloc_count > 0)
       || (! info->relocatable
-	  && finfo.internal_relocs == NULL
+	  && flaginfo.internal_relocs == NULL
 	  && max_reloc_count > 0))
     goto error_return;
 
@@ -2311,7 +2219,7 @@
 	      if (! sub->output_has_begun)
 #endif
 		{
-		  if (! _bfd_coff_link_input_bfd (&finfo, sub))
+		  if (! _bfd_coff_link_input_bfd (&flaginfo, sub))
 		    goto error_return;
 		  sub->output_has_begun = TRUE;
 		}
@@ -2319,7 +2227,7 @@
 	  else if (p->type == bfd_section_reloc_link_order
 		   || p->type == bfd_symbol_reloc_link_order)
 	    {
-	      if (! _bfd_coff_reloc_link_order (abfd, &finfo, o, p))
+	      if (! _bfd_coff_reloc_link_order (abfd, &flaginfo, o, p))
 		goto error_return;
 	    }
 	  else
@@ -2335,7 +2243,7 @@
     bfd* last_one = ppc_get_last();
     if (last_one)
       {
-	if (! _bfd_coff_link_input_bfd (&finfo, last_one))
+	if (! _bfd_coff_link_input_bfd (&flaginfo, last_one))
 	  goto error_return;
       }
     last_one->output_has_begun = TRUE;
@@ -2343,73 +2251,73 @@
 #endif
 
   /* Free up the buffers used by _bfd_coff_link_input_bfd.  */
-  coff_debug_merge_hash_table_free (&finfo.debug_merge);
+  coff_debug_merge_hash_table_free (&flaginfo.debug_merge);
   debug_merge_allocated = FALSE;
 
-  if (finfo.internal_syms != NULL)
+  if (flaginfo.internal_syms != NULL)
     {
-      free (finfo.internal_syms);
-      finfo.internal_syms = NULL;
+      free (flaginfo.internal_syms);
+      flaginfo.internal_syms = NULL;
     }
-  if (finfo.sec_ptrs != NULL)
+  if (flaginfo.sec_ptrs != NULL)
     {
-      free (finfo.sec_ptrs);
-      finfo.sec_ptrs = NULL;
+      free (flaginfo.sec_ptrs);
+      flaginfo.sec_ptrs = NULL;
     }
-  if (finfo.sym_indices != NULL)
+  if (flaginfo.sym_indices != NULL)
     {
-      free (finfo.sym_indices);
-      finfo.sym_indices = NULL;
+      free (flaginfo.sym_indices);
+      flaginfo.sym_indices = NULL;
     }
-  if (finfo.linenos != NULL)
+  if (flaginfo.linenos != NULL)
     {
-      free (finfo.linenos);
-      finfo.linenos = NULL;
+      free (flaginfo.linenos);
+      flaginfo.linenos = NULL;
     }
-  if (finfo.contents != NULL)
+  if (flaginfo.contents != NULL)
     {
-      free (finfo.contents);
-      finfo.contents = NULL;
+      free (flaginfo.contents);
+      flaginfo.contents = NULL;
     }
-  if (finfo.external_relocs != NULL)
+  if (flaginfo.external_relocs != NULL)
     {
-      free (finfo.external_relocs);
-      finfo.external_relocs = NULL;
+      free (flaginfo.external_relocs);
+      flaginfo.external_relocs = NULL;
     }
-  if (finfo.internal_relocs != NULL)
+  if (flaginfo.internal_relocs != NULL)
     {
-      free (finfo.internal_relocs);
-      finfo.internal_relocs = NULL;
+      free (flaginfo.internal_relocs);
+      flaginfo.internal_relocs = NULL;
     }
 
   /* The value of the last C_FILE symbol is supposed to be the symbol
      index of the first external symbol.  Write it out again if
      necessary.  */
-  if (finfo.last_file_index != -1
-      && (unsigned int) finfo.last_file.n_value != obj_raw_syment_count (abfd))
+  if (flaginfo.last_file_index != -1
+      && (unsigned int) flaginfo.last_file.n_value != obj_raw_syment_count (abfd))
     {
       file_ptr pos;
 
-      finfo.last_file.n_value = obj_raw_syment_count (abfd);
-      bfd_coff_swap_sym_out (abfd, (PTR) &finfo.last_file,
-			     (PTR) finfo.outsyms);
-      pos = obj_sym_filepos (abfd) + finfo.last_file_index * symesz;
+      flaginfo.last_file.n_value = obj_raw_syment_count (abfd);
+      bfd_coff_swap_sym_out (abfd, &flaginfo.last_file,
+			     flaginfo.outsyms);
+      pos = obj_sym_filepos (abfd) + flaginfo.last_file_index * symesz;
       if (bfd_seek (abfd, pos, SEEK_SET) != 0
-	  || bfd_bwrite (finfo.outsyms, symesz, abfd) != symesz)
+	  || bfd_bwrite (flaginfo.outsyms, symesz, abfd) != symesz)
 	return FALSE;
     }
 
   /* Write out the global symbols.  */
-  finfo.failed = FALSE;
-  bfd_hash_traverse (&info->hash->table, _bfd_coff_write_global_sym, &finfo);
-  if (finfo.failed)
+  flaginfo.failed = FALSE;
+  bfd_hash_traverse (&info->hash->table, _bfd_coff_write_global_sym, &flaginfo);
+  if (flaginfo.failed)
     goto error_return;
 
   /* The outsyms buffer is used by _bfd_coff_write_global_sym.  */
-  if (finfo.outsyms != NULL)
+  if (flaginfo.outsyms != NULL)
     {
-      free (finfo.outsyms);
-      finfo.outsyms = NULL;
+      free (flaginfo.outsyms);
+      flaginfo.outsyms = NULL;
     }
 
   if (info->relocatable)
@@ -2432,9 +2340,9 @@
 	  if (o->reloc_count == 0)
 	    continue;
 
-	  irel = finfo.section_info[o->target_index].relocs;
+	  irel = flaginfo.section_info[o->target_index].relocs;
 	  irelend = irel + o->reloc_count;
-	  rel_hash = finfo.section_info[o->target_index].rel_hashes;
+	  rel_hash = flaginfo.section_info[o->target_index].rel_hashes;
 	  erel = external_relocs;
 	  for (; irel < irelend; irel++, rel_hash++, erel += relsz)
 	    {
@@ -2443,12 +2351,12 @@
 		  BFD_ASSERT ((*rel_hash)->indx >= 0);
 		  irel->r_symndx = (*rel_hash)->indx;
 		}
-	      bfd_coff_swap_reloc_out (abfd, (PTR) irel, (PTR) erel);
+	      bfd_coff_swap_reloc_out (abfd, irel, erel);
 	    }
 
 	  amt = relsz * o->reloc_count;
 	  if (bfd_seek (abfd, o->rel_filepos, SEEK_SET) != 0
-	      || bfd_bwrite ((PTR) external_relocs, amt, abfd) != amt)
+	      || bfd_bwrite (external_relocs, amt, abfd) != amt)
 	    goto error_return;
 	}
 
@@ -2457,19 +2365,19 @@
     }
 
   /* Free up the section information.  */
-  if (finfo.section_info != NULL)
+  if (flaginfo.section_info != NULL)
     {
       unsigned int i;
 
       for (i = 0; i < abfd->section_count; i++)
 	{
-	  if (finfo.section_info[i].relocs != NULL)
-	    free (finfo.section_info[i].relocs);
-	  if (finfo.section_info[i].rel_hashes != NULL)
-	    free (finfo.section_info[i].rel_hashes);
+	  if (flaginfo.section_info[i].relocs != NULL)
+	    free (flaginfo.section_info[i].relocs);
+	  if (flaginfo.section_info[i].rel_hashes != NULL)
+	    free (flaginfo.section_info[i].rel_hashes);
 	}
-      free (finfo.section_info);
-      finfo.section_info = NULL;
+      free (flaginfo.section_info);
+      flaginfo.section_info = NULL;
     }
 
   /* If we have optimized stabs strings, output them.  */
@@ -2490,7 +2398,7 @@
 
 #if STRING_SIZE_SIZE == 4
       H_PUT_32 (abfd,
-		_bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
+		_bfd_stringtab_size (flaginfo.strtab) + STRING_SIZE_SIZE,
 		strbuf);
 #else
  #error Change H_PUT_32 above
@@ -2500,11 +2408,11 @@
 	  != STRING_SIZE_SIZE)
 	return FALSE;
 
-      if (! _bfd_stringtab_emit (abfd, finfo.strtab))
+      if (! _bfd_stringtab_emit (abfd, flaginfo.strtab))
 	return FALSE;
     }
 
-  _bfd_stringtab_free (finfo.strtab);
+  _bfd_stringtab_free (flaginfo.strtab);
 
   /* Setting bfd_get_symcount to 0 will cause write_object_contents to
      not try to write out the symbols.  */
@@ -2514,38 +2422,38 @@
 
  error_return:
   if (debug_merge_allocated)
-    coff_debug_merge_hash_table_free (&finfo.debug_merge);
-  if (finfo.strtab != NULL)
-    _bfd_stringtab_free (finfo.strtab);
-  if (finfo.section_info != NULL)
+    coff_debug_merge_hash_table_free (&flaginfo.debug_merge);
+  if (flaginfo.strtab != NULL)
+    _bfd_stringtab_free (flaginfo.strtab);
+  if (flaginfo.section_info != NULL)
     {
       unsigned int i;
 
       for (i = 0; i < abfd->section_count; i++)
 	{
-	  if (finfo.section_info[i].relocs != NULL)
-	    free (finfo.section_info[i].relocs);
-	  if (finfo.section_info[i].rel_hashes != NULL)
-	    free (finfo.section_info[i].rel_hashes);
+	  if (flaginfo.section_info[i].relocs != NULL)
+	    free (flaginfo.section_info[i].relocs);
+	  if (flaginfo.section_info[i].rel_hashes != NULL)
+	    free (flaginfo.section_info[i].rel_hashes);
 	}
-      free (finfo.section_info);
+      free (flaginfo.section_info);
     }
-  if (finfo.internal_syms != NULL)
-    free (finfo.internal_syms);
-  if (finfo.sec_ptrs != NULL)
-    free (finfo.sec_ptrs);
-  if (finfo.sym_indices != NULL)
-    free (finfo.sym_indices);
-  if (finfo.outsyms != NULL)
-    free (finfo.outsyms);
-  if (finfo.linenos != NULL)
-    free (finfo.linenos);
-  if (finfo.contents != NULL)
-    free (finfo.contents);
-  if (finfo.external_relocs != NULL)
-    free (finfo.external_relocs);
-  if (finfo.internal_relocs != NULL)
-    free (finfo.internal_relocs);
+  if (flaginfo.internal_syms != NULL)
+    free (flaginfo.internal_syms);
+  if (flaginfo.sec_ptrs != NULL)
+    free (flaginfo.sec_ptrs);
+  if (flaginfo.sym_indices != NULL)
+    free (flaginfo.sym_indices);
+  if (flaginfo.outsyms != NULL)
+    free (flaginfo.outsyms);
+  if (flaginfo.linenos != NULL)
+    free (flaginfo.linenos);
+  if (flaginfo.contents != NULL)
+    free (flaginfo.contents);
+  if (flaginfo.external_relocs != NULL)
+    free (flaginfo.external_relocs);
+  if (flaginfo.internal_relocs != NULL)
+    free (flaginfo.internal_relocs);
   if (external_relocs != NULL)
     free (external_relocs);
   return FALSE;
@@ -2572,10 +2480,11 @@
    HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
 
 #ifndef COFF_WITH_PE
-  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY
+   | SEC_RELOC),		/* section flags */
 #else
-  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
-   | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
+  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY
+   | SEC_RELOC | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
 #endif
 
   0,				/* leading char */
@@ -2632,10 +2541,11 @@
    HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
 
 #ifndef COFF_WITH_PE
-  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY
+   | SEC_RELOC),		/* section flags */
 #else
-  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* section flags */
-   | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
+  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY
+   | SEC_RELOC | SEC_LINK_ONCE | SEC_LINK_DUPLICATES),
 #endif
 
   0,				/* leading char */
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index 035812e..0386e9a 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -1,6 +1,6 @@
 /* BFD back-end for IBM RS/6000 "XCOFF" files.
    Copyright 1990-1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-   2008, 2009, 2010, 2011
+   2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
    Written by Metin G. Ozisik, Mimi Phuong-Thao Vo, and John Gilmore.
    Archive support from Damon A. Permezel.
@@ -24,6 +24,7 @@
    MA 02110-1301, USA.  */
 
 #include "sysdep.h"
+#include "libiberty.h"
 #include "bfd.h"
 #include "bfdlink.h"
 #include "libbfd.h"
@@ -40,20 +41,20 @@
   (bfd *, bfd_reloc_code_real_type);
 extern bfd_boolean _bfd_xcoff_slurp_armap (bfd *);
 extern const bfd_target *_bfd_xcoff_archive_p (bfd *);
-extern PTR _bfd_xcoff_read_ar_hdr (bfd *);
+extern void * _bfd_xcoff_read_ar_hdr (bfd *);
 extern bfd *_bfd_xcoff_openr_next_archived_file (bfd *, bfd *);
 extern int _bfd_xcoff_stat_arch_elt (bfd *, struct stat *);
 extern bfd_boolean _bfd_xcoff_write_armap
   (bfd *, unsigned int, struct orl *, unsigned int, int);
 extern bfd_boolean _bfd_xcoff_write_archive_contents (bfd *);
 extern int _bfd_xcoff_sizeof_headers (bfd *, struct bfd_link_info *);
-extern void _bfd_xcoff_swap_sym_in (bfd *, PTR, PTR);
-extern unsigned int _bfd_xcoff_swap_sym_out (bfd *, PTR, PTR);
-extern void _bfd_xcoff_swap_aux_in (bfd *, PTR, int, int, int, int, PTR);
+extern void _bfd_xcoff_swap_sym_in (bfd *, void *, void *);
+extern unsigned int _bfd_xcoff_swap_sym_out (bfd *, void *, void *);
+extern void _bfd_xcoff_swap_aux_in (bfd *, void *, int, int, int, int, void *);
 extern unsigned int _bfd_xcoff_swap_aux_out
-  (bfd *, PTR, int, int, int, int, PTR);
-static void xcoff_swap_reloc_in (bfd *, PTR, PTR);
-static unsigned int xcoff_swap_reloc_out (bfd *, PTR, PTR);
+  (bfd *, void *, int, int, int, int, void *);
+static void xcoff_swap_reloc_in (bfd *, void *, void *);
+static unsigned int xcoff_swap_reloc_out (bfd *, void *, void *);
 
 /* Forward declare xcoff_rtype2howto for coffcode.h macro.  */
 void xcoff_rtype2howto (arelent *, struct internal_reloc *);
@@ -129,12 +130,12 @@
   (bfd *, unsigned int, struct orl *, unsigned int, int);
 static bfd_boolean xcoff_write_archive_contents_old (bfd *);
 static bfd_boolean xcoff_write_archive_contents_big (bfd *);
-static void xcoff_swap_ldhdr_in (bfd *, const PTR, struct internal_ldhdr *);
-static void xcoff_swap_ldhdr_out (bfd *, const struct internal_ldhdr *, PTR);
-static void xcoff_swap_ldsym_in (bfd *, const PTR, struct internal_ldsym *);
-static void xcoff_swap_ldsym_out (bfd *, const struct internal_ldsym *, PTR);
-static void xcoff_swap_ldrel_in (bfd *, const PTR, struct internal_ldrel *);
-static void xcoff_swap_ldrel_out (bfd *, const struct internal_ldrel *, PTR);
+static void xcoff_swap_ldhdr_in (bfd *, const void *, struct internal_ldhdr *);
+static void xcoff_swap_ldhdr_out (bfd *, const struct internal_ldhdr *, void *);
+static void xcoff_swap_ldsym_in (bfd *, const void *, struct internal_ldsym *);
+static void xcoff_swap_ldsym_out (bfd *, const struct internal_ldsym *, void *);
+static void xcoff_swap_ldrel_in (bfd *, const void *, struct internal_ldrel *);
+static void xcoff_swap_ldrel_out (bfd *, const struct internal_ldrel *, void *);
 static bfd_boolean xcoff_ppc_relocate_section
   (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
    struct internal_reloc *, struct internal_syment *, asection **);
@@ -405,9 +406,70 @@
 {
   return FALSE;
 }
+
+static const struct dwarf_debug_section xcoff_debug_sections[] =
+{
+  { ".dwabrev",		NULL },
+  { ".dwarnge",		NULL },
+  { NULL,	NULL }, /* .debug_frame */
+  { ".dwinfo",		NULL },
+  { ".dwline",		NULL },
+  { NULL,	NULL }, /* .debug_loc */
+  { NULL,	NULL }, /* .debug_macinfo */
+  { NULL,	NULL }, /* .debug_macro */
+  { ".dwpbnms",		NULL },
+  { ".dwpbtyp",		NULL },
+  { ".dwrnges",		NULL },
+  { NULL,	NULL }, /* .debug_static_func */
+  { NULL,	NULL }, /* .debug_static_vars */
+  { ".dwstr",	NULL },
+  { NULL,	NULL }, /* .debug_types */
+  /* GNU DWARF 1 extensions */
+  { NULL,	NULL }, /* .debug_sfnames */
+  { NULL,	NULL }, /* .debug_srcinfo */
+  /* SGI/MIPS DWARF 2 extensions */
+  { NULL,	NULL }, /* .debug_funcnames */
+  { NULL,	NULL }, /* .debug_typenames */
+  { NULL,	NULL }, /* .debug_varnames */
+  { NULL,	NULL }, /* .debug_weaknames */
+  { NULL,	NULL },
+};
+
+static bfd_boolean
+xcoff_find_nearest_line (bfd *abfd,
+                         asection *section,
+                         asymbol **symbols,
+                         bfd_vma offset,
+                         const char **filename_ptr,
+                         const char **functionname_ptr,
+                         unsigned int *line_ptr)
+{
+  return coff_find_nearest_line_with_names (abfd, xcoff_debug_sections,
+                                            section, symbols, offset,
+                                            filename_ptr, functionname_ptr,
+                                            line_ptr);
+}
+
+static bfd_boolean
+xcoff_find_nearest_line_discriminator (bfd *abfd,
+                                      asection *section,
+                                      asymbol **symbols,
+                                      bfd_vma offset,
+                                      const char **filename_ptr,
+                                      const char **functionname_ptr,
+                                      unsigned int *line_ptr,
+                                      unsigned int *discriminator)
+{
+  *discriminator = 0;
+  return coff_find_nearest_line_with_names (abfd, xcoff_debug_sections,
+                                            section, symbols, offset,
+                                            filename_ptr, functionname_ptr,
+                                            line_ptr);
+}
+
 
 void
-_bfd_xcoff_swap_sym_in (bfd *abfd, PTR ext1, PTR in1)
+_bfd_xcoff_swap_sym_in (bfd *abfd, void * ext1, void * in1)
 {
   SYMENT *ext = (SYMENT *)ext1;
   struct internal_syment * in = (struct internal_syment *)in1;
@@ -430,7 +492,7 @@
 }
 
 unsigned int
-_bfd_xcoff_swap_sym_out (bfd *abfd, PTR inp, PTR extp)
+_bfd_xcoff_swap_sym_out (bfd *abfd, void * inp, void * extp)
 {
   struct internal_syment *in = (struct internal_syment *)inp;
   SYMENT *ext =(SYMENT *)extp;
@@ -454,8 +516,8 @@
 }
 
 void
-_bfd_xcoff_swap_aux_in (bfd *abfd, PTR ext1, int type, int in_class,
-                        int indx, int numaux, PTR in1)
+_bfd_xcoff_swap_aux_in (bfd *abfd, void * ext1, int type, int in_class,
+                        int indx, int numaux, void * in1)
 {
   AUXENT * ext = (AUXENT *)ext1;
   union internal_auxent *in = (union internal_auxent *)in1;
@@ -564,15 +626,15 @@
 }
 
 unsigned int
-_bfd_xcoff_swap_aux_out (bfd *abfd, PTR inp, int type, int in_class,
+_bfd_xcoff_swap_aux_out (bfd *abfd, void * inp, int type, int in_class,
                          int indx ATTRIBUTE_UNUSED,
                          int numaux ATTRIBUTE_UNUSED,
-                         PTR extp)
+                         void * extp)
 {
   union internal_auxent *in = (union internal_auxent *)inp;
   AUXENT *ext = (AUXENT *)extp;
 
-  memset ((PTR)ext, 0, bfd_coff_auxesz (abfd));
+  memset (ext, 0, bfd_coff_auxesz (abfd));
   switch (in_class)
     {
     case C_FILE:
@@ -669,7 +731,7 @@
 
 reloc_howto_type xcoff_howto_table[] =
 {
-  /* Standard 32 bit relocation.  */
+  /* 0x00: Standard 32 bit relocation.  */
   HOWTO (R_POS,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -684,7 +746,7 @@
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 32 bit relocation, but store negative value.  */
+  /* 0x01: 32 bit relocation, but store negative value.  */
   HOWTO (R_NEG,			/* type */
 	 0,			/* rightshift */
 	 -2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -699,7 +761,7 @@
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 32 bit PC relative relocation.  */
+  /* 0x02: 32 bit PC relative relocation.  */
   HOWTO (R_REL,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -714,7 +776,7 @@
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 16 bit TOC relative relocation.  */
+  /* 0x03: 16 bit TOC relative relocation.  */
   HOWTO (R_TOC,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -729,7 +791,7 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* I don't really know what this is.  */
+  /* 0x04: I don't really know what this is.  */
   HOWTO (R_RTB,			/* type */
 	 1,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -744,7 +806,7 @@
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* External TOC relative symbol.  */
+  /* 0x05: External TOC relative symbol.  */
   HOWTO (R_GL,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -759,7 +821,7 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Local TOC relative symbol.	 */
+  /* 0x06: Local TOC relative symbol.	 */
   HOWTO (R_TCL,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -776,7 +838,7 @@
 
   EMPTY_HOWTO (7),
 
-  /* Non modifiable absolute branch.  */
+  /* 0x08: Non modifiable absolute branch.  */
   HOWTO (R_BA,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -793,7 +855,7 @@
 
   EMPTY_HOWTO (9),
 
-  /* Non modifiable relative branch.  */
+  /* 0x0a: Non modifiable relative branch.  */
   HOWTO (R_BR,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -810,7 +872,7 @@
 
   EMPTY_HOWTO (0xb),
 
-  /* Indirect load.  */
+  /* 0x0c: Indirect load.  */
   HOWTO (R_RL,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -825,7 +887,7 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Load address.  */
+  /* 0x0d: Load address.  */
   HOWTO (R_RLA,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -842,7 +904,7 @@
 
   EMPTY_HOWTO (0xe),
 
-  /* Non-relocating reference.  Bitsize is 1 so that r_rsize is 0.  */
+  /* 0x0f: Non-relocating reference.  Bitsize is 1 so that r_rsize is 0.  */
   HOWTO (R_REF,			/* type */
 	 0,			/* rightshift */
 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -860,7 +922,7 @@
   EMPTY_HOWTO (0x10),
   EMPTY_HOWTO (0x11),
 
-  /* TOC relative indirect load.  */
+  /* 0x12: TOC relative indirect load.  */
   HOWTO (R_TRL,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -875,7 +937,7 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* TOC relative load address.  */
+  /* 0x13: TOC relative load address.  */
   HOWTO (R_TRLA,		/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -890,7 +952,7 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable relative branch.  */
+  /* 0x14: Modifiable relative branch.  */
   HOWTO (R_RRTBI,		 /* type */
 	 1,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -905,7 +967,7 @@
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable absolute branch.  */
+  /* 0x15: Modifiable absolute branch.  */
   HOWTO (R_RRTBA,		 /* type */
 	 1,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -920,7 +982,7 @@
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable call absolute indirect.  */
+  /* 0x16: Modifiable call absolute indirect.  */
   HOWTO (R_CAI,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -935,7 +997,7 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable call relative.  */
+  /* 0x17: Modifiable call relative.  */
   HOWTO (R_CREL,		/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -950,7 +1012,7 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch absolute.  */
+  /* 0x18: Modifiable branch absolute.  */
   HOWTO (R_RBA,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -965,7 +1027,7 @@
 	 0x03fffffc,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch absolute.  */
+  /* 0x19: Modifiable branch absolute.  */
   HOWTO (R_RBAC,		/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -980,7 +1042,7 @@
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch relative.  */
+  /* 0x1a: Modifiable branch relative.  */
   HOWTO (R_RBR,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -995,7 +1057,7 @@
 	 0x03fffffc,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch absolute.  */
+  /* 0x1b: Modifiable branch absolute.  */
   HOWTO (R_RBRC,		/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1010,7 +1072,7 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 16 bit Non modifiable absolute branch.  */
+  /* 0x1c: 16 bit Non modifiable absolute branch.  */
   HOWTO (R_BA,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1025,22 +1087,22 @@
 	 0xfffc,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch relative.  */
+  /* 0x1d: Modifiable branch relative.  */
   HOWTO (R_RBR,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
 	 16,			/* bitsize */
-	 FALSE,			/* pc_relative */
+	 TRUE,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_signed, /* complain_on_overflow */
 	 0,			/* special_function */
 	 "R_RBR_16",		/* name */
 	 TRUE,			/* partial_inplace */
-	 0xffff,		/* src_mask */
-	 0xffff,		/* dst_mask */
+	 0xfffc,		/* src_mask */
+	 0xfffc,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch relative.  */
+  /* 0x1e: Modifiable branch relative.  */
   HOWTO (R_RBA,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1054,7 +1116,6 @@
 	 0xffff,		/* src_mask */
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
-
 };
 
 void
@@ -1102,6 +1163,11 @@
       return &xcoff_howto_table[8];
     case BFD_RELOC_PPC_TOC16:
       return &xcoff_howto_table[3];
+    case BFD_RELOC_16:
+      /* Note that this relocation is only internally used by gas.  */
+      return &xcoff_howto_table[0xc];
+    case BFD_RELOC_PPC_B16:
+      return &xcoff_howto_table[0x1d];
     case BFD_RELOC_32:
     case BFD_RELOC_CTOR:
       return &xcoff_howto_table[0];
@@ -1219,7 +1285,7 @@
 	return FALSE;
 
       /* The symbol table starts with a normal archive header.  */
-      if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR, abfd)
+      if (bfd_bread (&hdr, (bfd_size_type) SIZEOF_AR_HDR, abfd)
 	  != SIZEOF_AR_HDR)
 	return FALSE;
 
@@ -1235,7 +1301,7 @@
       contents = (bfd_byte *) bfd_alloc (abfd, sz);
       if (contents == NULL)
 	return FALSE;
-      if (bfd_bread ((PTR) contents, sz, abfd) != sz)
+      if (bfd_bread (contents, sz, abfd) != sz)
 	return FALSE;
 
       /* The symbol table starts with a four byte count.  */
@@ -1274,7 +1340,7 @@
 	return FALSE;
 
       /* The symbol table starts with a normal archive header.  */
-      if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd)
+      if (bfd_bread (&hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd)
 	  != SIZEOF_AR_HDR_BIG)
 	return FALSE;
 
@@ -1293,7 +1359,7 @@
       contents = (bfd_byte *) bfd_alloc (abfd, sz);
       if (contents == NULL)
 	return FALSE;
-      if (bfd_bread ((PTR) contents, sz, abfd) != sz)
+      if (bfd_bread (contents, sz, abfd) != sz)
 	return FALSE;
 
       /* The symbol table starts with an eight byte count.  */
@@ -1346,7 +1412,7 @@
   char magic[SXCOFFARMAG];
   bfd_size_type amt = SXCOFFARMAG;
 
-  if (bfd_bread ((PTR) magic, amt, abfd) != amt)
+  if (bfd_bread (magic, amt, abfd) != amt)
     {
       if (bfd_get_error () != bfd_error_system_call)
 	bfd_set_error (bfd_error_wrong_format);
@@ -1385,7 +1451,7 @@
 
       /* Now read the rest of the file header.  */
       amt = SIZEOF_AR_FILE_HDR - SXCOFFARMAG;
-      if (bfd_bread ((PTR) &hdr.memoff, amt, abfd) != amt)
+      if (bfd_bread (&hdr.memoff, amt, abfd) != amt)
 	{
 	  if (bfd_get_error () != bfd_error_system_call)
 	    bfd_set_error (bfd_error_wrong_format);
@@ -1412,7 +1478,7 @@
 
       /* Now read the rest of the file header.  */
       amt = SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG;
-      if (bfd_bread ((PTR) &hdr.memoff, amt, abfd) != amt)
+      if (bfd_bread (&hdr.memoff, amt, abfd) != amt)
 	{
 	  if (bfd_get_error () != bfd_error_system_call)
 	    bfd_set_error (bfd_error_wrong_format);
@@ -1445,14 +1511,14 @@
 
 /* Read the archive header in an XCOFF archive.  */
 
-PTR
+void *
 _bfd_xcoff_read_ar_hdr (bfd *abfd)
 {
   bfd_size_type namlen;
   struct areltdata *ret;
   bfd_size_type amt = sizeof (struct areltdata);
 
-  ret = (struct areltdata *) bfd_alloc (abfd, amt);
+  ret = (struct areltdata *) bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
 
@@ -1461,7 +1527,7 @@
       struct xcoff_ar_hdr hdr;
       struct xcoff_ar_hdr *hdrp;
 
-      if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR, abfd)
+      if (bfd_bread (&hdr, (bfd_size_type) SIZEOF_AR_HDR, abfd)
 	  != SIZEOF_AR_HDR)
 	{
 	  free (ret);
@@ -1493,7 +1559,7 @@
       struct xcoff_ar_hdr_big hdr;
       struct xcoff_ar_hdr_big *hdrp;
 
-      if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd)
+      if (bfd_bread (&hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd)
 	  != SIZEOF_AR_HDR_BIG)
 	{
 	  free (ret);
@@ -1528,7 +1594,7 @@
   if (bfd_seek (abfd, (file_ptr) ((namlen & 1) + SXCOFFARFMAG), SEEK_CUR) != 0)
     return NULL;
 
-  return (PTR) ret;
+  return ret;
 }
 
 /* Open the next element in an XCOFF archive.  */
@@ -1669,7 +1735,7 @@
     if (*p == '\0')
       *p = ' ';
 
-  if (bfd_bwrite ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR, abfd)
+  if (bfd_bwrite (&hdr, (bfd_size_type) SIZEOF_AR_HDR, abfd)
       != SIZEOF_AR_HDR
       || (bfd_bwrite (XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG, abfd)
 	  != SXCOFFARFMAG))
@@ -2069,7 +2135,7 @@
       total_namlen += strlen (normalize_filename (sub)) + 1;
       if (sub->arelt_data == NULL)
 	{
-	  sub->arelt_data = bfd_zalloc (sub, sizeof (struct areltdata));
+	  sub->arelt_data = bfd_zmalloc (sizeof (struct areltdata));
 	  if (sub->arelt_data == NULL)
 	    return FALSE;
 	}
@@ -2186,20 +2252,20 @@
     if (*p == '\0')
       *p = ' ';
 
-  if ((bfd_bwrite ((PTR) &ahdr, (bfd_size_type) SIZEOF_AR_HDR, abfd)
+  if ((bfd_bwrite (&ahdr, (bfd_size_type) SIZEOF_AR_HDR, abfd)
        != SIZEOF_AR_HDR)
-      || (bfd_bwrite ((PTR) XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG, abfd)
+      || (bfd_bwrite (XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG, abfd)
 	  != SXCOFFARFMAG))
     return FALSE;
 
   sprintf (decbuf, "%-12ld", (long) count);
-  if (bfd_bwrite ((PTR) decbuf, (bfd_size_type) XCOFFARMAG_ELEMENT_SIZE, abfd)
+  if (bfd_bwrite (decbuf, (bfd_size_type) XCOFFARMAG_ELEMENT_SIZE, abfd)
       != XCOFFARMAG_ELEMENT_SIZE)
     return FALSE;
   for (i = 0; i < (size_t) count; i++)
     {
       sprintf (decbuf, "%-12ld", (long) offsets[i]);
-      if (bfd_bwrite ((PTR) decbuf, (bfd_size_type) XCOFFARMAG_ELEMENT_SIZE,
+      if (bfd_bwrite (decbuf, (bfd_size_type) XCOFFARMAG_ELEMENT_SIZE,
 		      abfd) != XCOFFARMAG_ELEMENT_SIZE)
 	return FALSE;
     }
@@ -2210,7 +2276,7 @@
 
       name = normalize_filename (sub);
       namlen = strlen (name);
-      if (bfd_bwrite ((PTR) name, namlen + 1, abfd) != namlen + 1)
+      if (bfd_bwrite (name, namlen + 1, abfd) != namlen + 1)
 	return FALSE;
     }
 
@@ -2224,7 +2290,7 @@
     {
       BFD_ASSERT (nextoff == bfd_tell (abfd));
       sprintf (fhdr.symoff, "%ld", (long) nextoff);
-      bfd_ardata (abfd)->tdata = (PTR) &fhdr;
+      bfd_ardata (abfd)->tdata = &fhdr;
       if (! _bfd_compute_and_write_armap (abfd, 0))
 	return FALSE;
     }
@@ -2237,7 +2303,7 @@
       *p = ' ';
 
   if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
-      || (bfd_bwrite ((PTR) &fhdr, (bfd_size_type) SIZEOF_AR_FILE_HDR, abfd)
+      || (bfd_bwrite (&fhdr, (bfd_size_type) SIZEOF_AR_FILE_HDR, abfd)
 	  != SIZEOF_AR_FILE_HDR))
     return FALSE;
 
@@ -2285,7 +2351,7 @@
       if (current_bfd->arelt_data == NULL)
 	{
 	  size = sizeof (struct areltdata);
-	  current_bfd->arelt_data = bfd_zalloc (current_bfd, size);
+	  current_bfd->arelt_data = bfd_zmalloc (size);
 	  if (current_bfd->arelt_data == NULL)
 	    return FALSE;
 	}
@@ -2465,7 +2531,7 @@
       /* Save nextoff in fhdr.symoff so the armap routine can use it.  */
       PRINT20 (fhdr.symoff, nextoff);
 
-      bfd_ardata (abfd)->tdata = (PTR) &fhdr;
+      bfd_ardata (abfd)->tdata = &fhdr;
       if (! _bfd_compute_and_write_armap (abfd, 0))
 	return FALSE;
     }
@@ -2473,7 +2539,7 @@
   /* Write out the archive file header.  */
 
   if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
-      || (bfd_bwrite ((PTR) &fhdr, (bfd_size_type) SIZEOF_AR_FILE_HDR_BIG,
+      || (bfd_bwrite (&fhdr, (bfd_size_type) SIZEOF_AR_FILE_HDR_BIG,
 		      abfd) != SIZEOF_AR_FILE_HDR_BIG))
     return FALSE;
 
@@ -2504,6 +2570,60 @@
   else
     size += SMALL_AOUTSZ;
   size += abfd->section_count * SCNHSZ;
+
+  if (info->strip != strip_all)
+    {
+      /* There can be additional sections just for dealing with overflow in
+	 reloc and lineno counts. But the numbers of relocs and lineno aren't
+	 known when bfd_sizeof_headers is called, so we compute them by
+	 summing the numbers from input sections.  */
+      struct nbr_reloc_lineno
+      {
+	unsigned int reloc_count;
+	unsigned int lineno_count;
+      };
+      struct nbr_reloc_lineno *n_rl;
+      bfd *sub;
+      int max_index;
+      asection *s;
+
+      /* Although the number of sections is known, the maximum value of
+	 section->index isn't (because some sections may have been removed).
+	 Don't try to renumber sections, just compute the upper bound.  */
+      max_index = 0;
+      for (s = abfd->sections; s != NULL; s = s->next)
+	if (s->index > max_index)
+	  max_index = s->index;
+
+      /* Allocate the per section counters. It could be possible to use a
+	 preallocated array as the number of sections is limited on XCOFF,
+	 but this creates a maintainance issue.  */
+      n_rl = bfd_zmalloc ((max_index + 1) * sizeof (*n_rl));
+      if (n_rl == NULL)
+	return -1;
+
+      /* Sum.  */
+      for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+	for (s = sub->sections; s != NULL; s = s->next)
+	  {
+	    struct nbr_reloc_lineno *e = &n_rl[s->output_section->index];
+	    e->reloc_count += s->reloc_count;
+	    e->lineno_count += s->lineno_count;
+	  }
+
+      /* Add the size of a section for each section with an overflow.  */
+      for (s = abfd->sections; s != NULL; s = s->next)
+	{
+	  struct nbr_reloc_lineno *e = &n_rl[s->index];
+
+	  if (e->reloc_count >= 0xffff
+	      || (e->lineno_count >= 0xffff && info->strip != strip_debugger))
+	    size += SCNHSZ;
+	}
+
+      free (n_rl);
+    }
+
   return size;
 }
 
@@ -2515,7 +2635,7 @@
 /* Swap in the ldhdr structure.  */
 
 static void
-xcoff_swap_ldhdr_in (bfd *abfd, const PTR s, struct internal_ldhdr *dst)
+xcoff_swap_ldhdr_in (bfd *abfd, const void * s, struct internal_ldhdr *dst)
 {
   const struct external_ldhdr *src = (const struct external_ldhdr *) s;
 
@@ -2532,7 +2652,7 @@
 /* Swap out the ldhdr structure.  */
 
 static void
-xcoff_swap_ldhdr_out (bfd *abfd, const struct internal_ldhdr *src, PTR d)
+xcoff_swap_ldhdr_out (bfd *abfd, const struct internal_ldhdr *src, void * d)
 {
   struct external_ldhdr *dst = (struct external_ldhdr *) d;
 
@@ -2549,7 +2669,7 @@
 /* Swap in the ldsym structure.  */
 
 static void
-xcoff_swap_ldsym_in (bfd *abfd, const PTR s, struct internal_ldsym *dst)
+xcoff_swap_ldsym_in (bfd *abfd, const void * s, struct internal_ldsym *dst)
 {
   const struct external_ldsym *src = (const struct external_ldsym *) s;
 
@@ -2570,7 +2690,7 @@
 /* Swap out the ldsym structure.  */
 
 static void
-xcoff_swap_ldsym_out (bfd *abfd, const struct internal_ldsym *src, PTR d)
+xcoff_swap_ldsym_out (bfd *abfd, const struct internal_ldsym *src, void * d)
 {
   struct external_ldsym *dst = (struct external_ldsym *) d;
 
@@ -2591,7 +2711,7 @@
 }
 
 static void
-xcoff_swap_reloc_in (bfd *abfd, PTR s, PTR d)
+xcoff_swap_reloc_in (bfd *abfd, void * s, void * d)
 {
   struct external_reloc *src = (struct external_reloc *) s;
   struct internal_reloc *dst = (struct internal_reloc *) d;
@@ -2605,7 +2725,7 @@
 }
 
 static unsigned int
-xcoff_swap_reloc_out (bfd *abfd, PTR s, PTR d)
+xcoff_swap_reloc_out (bfd *abfd, void * s, void * d)
 {
   struct internal_reloc *src = (struct internal_reloc *) s;
   struct external_reloc *dst = (struct external_reloc *) d;
@@ -2621,7 +2741,7 @@
 /* Swap in the ldrel structure.  */
 
 static void
-xcoff_swap_ldrel_in (bfd *abfd, const PTR s, struct internal_ldrel *dst)
+xcoff_swap_ldrel_in (bfd *abfd, const void * s, struct internal_ldrel *dst)
 {
   const struct external_ldrel *src = (const struct external_ldrel *) s;
 
@@ -2634,7 +2754,7 @@
 /* Swap out the ldrel structure.  */
 
 static void
-xcoff_swap_ldrel_out (bfd *abfd, const struct internal_ldrel *src, PTR d)
+xcoff_swap_ldrel_out (bfd *abfd, const struct internal_ldrel *src, void * d)
 {
   struct external_ldrel *dst = (struct external_ldrel *) d;
 
@@ -3493,14 +3613,14 @@
 
   /* .sv64 = x_smclas == 17
      This is an invalid csect for 32 bit apps.  */
-  static const char *names[19] =
-  {
-    ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo",
-    ".sv", ".bs", ".ds", ".uc", ".ti", ".tb", NULL, ".tc0",
-    ".td", NULL, ".sv3264"
-  };
-
-  if ((19 >= aux->x_csect.x_smclas)
+  static const char * const names[] =
+    {
+      ".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo", /* 0 - 7 */
+      ".sv", ".bs", ".ds", ".uc", ".ti", ".tb", NULL, ".tc0", /* 8 - 15 */
+      ".td", NULL, ".sv3264", NULL, ".tl", ".ul", ".te"
+    };
+  
+  if ((aux->x_csect.x_smclas < ARRAY_SIZE (names))
       && (NULL != names[aux->x_csect.x_smclas]))
     {
       return_value = bfd_make_section_anyway
@@ -4032,7 +4152,7 @@
     },
 
     /* Generic */
-    bfd_true,
+    _bfd_archive_close_and_cleanup,
     bfd_true,
     coff_new_section_hook,
     _bfd_generic_get_section_contents,
@@ -4073,8 +4193,8 @@
     _bfd_xcoff_is_local_label_name,
     coff_bfd_is_target_special_symbol,
     coff_get_lineno,
-    coff_find_nearest_line,
-    _bfd_generic_find_nearest_line_discriminator,
+    xcoff_find_nearest_line,
+    xcoff_find_nearest_line_discriminator,
     _bfd_generic_find_line,
     coff_find_inliner_info,
     coff_bfd_make_debug_symbol,
@@ -4120,7 +4240,7 @@
     /* Opposite endian version, none exists */
     NULL,
 
-    (void *) &bfd_xcoff_backend_data,
+    & bfd_xcoff_backend_data,
   };
 
 /* xcoff-powermac target
@@ -4288,7 +4408,7 @@
     },
 
     /* Generic */
-    bfd_true,
+    _bfd_archive_close_and_cleanup,
     bfd_true,
     coff_new_section_hook,
     _bfd_generic_get_section_contents,
@@ -4329,7 +4449,7 @@
     _bfd_xcoff_is_local_label_name,
     coff_bfd_is_target_special_symbol,
     coff_get_lineno,
-    coff_find_nearest_line,
+    xcoff_find_nearest_line,
     _bfd_generic_find_nearest_line_discriminator,
     _bfd_generic_find_line,
     coff_find_inliner_info,
@@ -4376,5 +4496,5 @@
     /* Opposite endian version, none exists */
     NULL,
 
-    (void *) &bfd_pmac_xcoff_backend_data,
+    & bfd_pmac_xcoff_backend_data,
   };
diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c
index e707add..f5e07a5 100644
--- a/bfd/coff-sh.c
+++ b/bfd/coff-sh.c
@@ -1,6 +1,6 @@
 /* BFD back-end for Renesas Super-H COFF binaries.
    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011
+   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012
    Free Software Foundation, Inc.
    Contributed by Cygnus Support.
    Written by Steve Chamberlain, <[email protected]>.
@@ -38,9 +38,9 @@
 
 #ifndef COFF_IMAGE_WITH_PE
 static bfd_boolean sh_align_load_span
-  PARAMS ((bfd *, asection *, bfd_byte *,
-	   bfd_boolean (*) (bfd *, asection *, PTR, bfd_byte *, bfd_vma),
-	   PTR, bfd_vma **, bfd_vma *, bfd_vma, bfd_vma, bfd_boolean *));
+  (bfd *, asection *, bfd_byte *,
+   bfd_boolean (*) (bfd *, asection *, void *, bfd_byte *, bfd_vma),
+   void *, bfd_vma **, bfd_vma *, bfd_vma, bfd_vma, bfd_boolean *);
 
 #define _bfd_sh_align_load_span sh_align_load_span
 #endif
@@ -56,28 +56,6 @@
 #include "libcoff.h"
 
 /* Internal functions.  */
-static bfd_reloc_status_type sh_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static long get_symbol_value PARAMS ((asymbol *));
-static bfd_boolean sh_relax_section
-  PARAMS ((bfd *, asection *, struct bfd_link_info *, bfd_boolean *));
-static bfd_boolean sh_relax_delete_bytes
-  PARAMS ((bfd *, asection *, bfd_vma, int));
-#ifndef COFF_IMAGE_WITH_PE
-static const struct sh_opcode *sh_insn_info PARAMS ((unsigned int));
-#endif
-static bfd_boolean sh_align_loads
-  PARAMS ((bfd *, asection *, struct internal_reloc *, bfd_byte *,
-	   bfd_boolean *));
-static bfd_boolean sh_swap_insns
-  PARAMS ((bfd *, asection *, PTR, bfd_byte *, bfd_vma));
-static bfd_boolean sh_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
-	   struct internal_reloc *, struct internal_syment *, asection **));
-static bfd_byte *sh_coff_get_relocated_section_contents
-  PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
-	   bfd_byte *, bfd_boolean, asymbol **));
-static reloc_howto_type * sh_coff_reloc_type_lookup PARAMS ((bfd *, bfd_reloc_code_real_type));
 
 #ifdef COFF_WITH_PE
 /* Can't build import tables with 2**4 alignment.  */
@@ -96,17 +74,27 @@
 #define COFF_LONG_FILENAMES
 
 #ifdef COFF_WITH_PE
-static bfd_boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *));
 /* Return TRUE if this relocation should
    appear in the output .reloc section.  */
-static bfd_boolean in_reloc_p (abfd, howto)
-     bfd * abfd ATTRIBUTE_UNUSED;
-     reloc_howto_type * howto;
+
+static bfd_boolean
+in_reloc_p (bfd * abfd ATTRIBUTE_UNUSED,
+	    reloc_howto_type * howto)
 {
   return ! howto->pc_relative && howto->type != R_SH_IMAGEBASE;
 }
 #endif
 
+static bfd_reloc_status_type
+sh_reloc (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_boolean
+sh_relocate_section (bfd *, struct bfd_link_info *, bfd *, asection *,
+		     bfd_byte *, struct internal_reloc *,
+		     struct internal_syment *, asection **);
+static bfd_boolean
+sh_align_loads (bfd *, asection *, struct internal_reloc *,
+		bfd_byte *, bfd_boolean *);
+
 /* The supported relocations.  There are a lot of relocations defined
    in coff/internal.h which we do not expect to ever see.  */
 static reloc_howto_type sh_coff_howtos[] =
@@ -407,8 +395,7 @@
 /* Get the value of a symbol, when performing a relocation.  */
 
 static long
-get_symbol_value (symbol)
-     asymbol *symbol;
+get_symbol_value (asymbol *symbol)
 {
   bfd_vma relocation;
 
@@ -426,16 +413,15 @@
 /* Convert an rtype to howto for the COFF backend linker.
    Copied from coff-i386.  */
 #define coff_rtype_to_howto coff_sh_rtype_to_howto
-static reloc_howto_type * coff_sh_rtype_to_howto PARAMS ((bfd *, asection *, struct internal_reloc *, struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *));
+
 
 static reloc_howto_type *
-coff_sh_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
-     bfd * abfd ATTRIBUTE_UNUSED;
-     asection * sec;
-     struct internal_reloc * rel;
-     struct coff_link_hash_entry * h;
-     struct internal_syment * sym;
-     bfd_vma * addendp;
+coff_sh_rtype_to_howto (bfd * abfd ATTRIBUTE_UNUSED,
+			asection * sec,
+			struct internal_reloc * rel,
+			struct coff_link_hash_entry * h,
+			struct internal_syment * sym,
+			bfd_vma * addendp)
 {
   reloc_howto_type * howto;
 
@@ -508,9 +494,8 @@
 #define coff_bfd_reloc_name_lookup sh_coff_reloc_name_lookup
 
 static reloc_howto_type *
-sh_coff_reloc_type_lookup (abfd, code)
-     bfd * abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+sh_coff_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
+			   bfd_reloc_code_real_type code)
 {
   unsigned int i;
 
@@ -575,15 +560,13 @@
 /* This is the howto function for the SH relocations.  */
 
 static bfd_reloc_status_type
-sh_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
-	  error_message)
-     bfd *abfd;
-     arelent *reloc_entry;
-     asymbol *symbol_in;
-     PTR data;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+sh_reloc (bfd *      abfd,
+	  arelent *  reloc_entry,
+	  asymbol *  symbol_in,
+	  void *     data,
+	  asection * input_section,
+	  bfd *      output_bfd,
+	  char **    error_message ATTRIBUTE_UNUSED)
 {
   unsigned long insn;
   bfd_vma sym_value;
@@ -673,6 +656,9 @@
 
 #include "coffcode.h"
 
+static bfd_boolean
+sh_relax_delete_bytes (bfd *, asection *, bfd_vma, int);
+
 /* This function handles relaxing on the SH.
 
    Function calls on the SH look like this:
@@ -717,11 +703,10 @@
    can, by swapping them with one of the adjacent instructions.  */
 
 static bfd_boolean
-sh_relax_section (abfd, sec, link_info, again)
-     bfd *abfd;
-     asection *sec;
-     struct bfd_link_info *link_info;
-     bfd_boolean *again;
+sh_relax_section (bfd *abfd,
+		  asection *sec,
+		  struct bfd_link_info *link_info,
+		  bfd_boolean *again)
 {
   struct internal_reloc *internal_relocs;
   bfd_boolean have_code;
@@ -738,7 +723,7 @@
   if (coff_section_data (abfd, sec) == NULL)
     {
       bfd_size_type amt = sizeof (struct coff_section_tdata);
-      sec->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
+      sec->used_by_bfd = bfd_zalloc (abfd, amt);
       if (sec->used_by_bfd == NULL)
 	return FALSE;
     }
@@ -1074,11 +1059,10 @@
 /* Delete some bytes from a section while relaxing.  */
 
 static bfd_boolean
-sh_relax_delete_bytes (abfd, sec, addr, count)
-     bfd *abfd;
-     asection *sec;
-     bfd_vma addr;
-     int count;
+sh_relax_delete_bytes (bfd *abfd,
+		       asection *sec,
+		       bfd_vma addr,
+		       int count)
 {
   bfd_byte *contents;
   struct internal_reloc *irel, *irelend;
@@ -1470,7 +1454,7 @@
     {
       struct internal_syment isym;
 
-      bfd_coff_swap_sym_in (abfd, (PTR) esym, (PTR) &isym);
+      bfd_coff_swap_sym_in (abfd, esym, &isym);
 
       if (isym.n_scnum == sec->target_index
 	  && (bfd_vma) isym.n_value > addr
@@ -1478,7 +1462,7 @@
 	{
 	  isym.n_value -= count;
 
-	  bfd_coff_swap_sym_out (abfd, (PTR) &isym, (PTR) esym);
+	  bfd_coff_swap_sym_out (abfd, &isym, esym);
 
 	  if (*sym_hash != NULL)
 	    {
@@ -1628,24 +1612,6 @@
 #define MAP(a) a, sizeof a / sizeof a[0]
 
 #ifndef COFF_IMAGE_WITH_PE
-static bfd_boolean sh_insn_uses_reg
-  PARAMS ((unsigned int, const struct sh_opcode *, unsigned int));
-static bfd_boolean sh_insn_sets_reg
-  PARAMS ((unsigned int, const struct sh_opcode *, unsigned int));
-static bfd_boolean sh_insn_uses_or_sets_reg
-  PARAMS ((unsigned int, const struct sh_opcode *, unsigned int));
-static bfd_boolean sh_insn_uses_freg
-  PARAMS ((unsigned int, const struct sh_opcode *, unsigned int));
-static bfd_boolean sh_insn_sets_freg
-  PARAMS ((unsigned int, const struct sh_opcode *, unsigned int));
-static bfd_boolean sh_insn_uses_or_sets_freg
-  PARAMS ((unsigned int, const struct sh_opcode *, unsigned int));
-static bfd_boolean sh_insns_conflict
-  PARAMS ((unsigned int, const struct sh_opcode *, unsigned int,
-	   const struct sh_opcode *));
-static bfd_boolean sh_load_use
-  PARAMS ((unsigned int, const struct sh_opcode *, unsigned int,
-	   const struct sh_opcode *));
 
 /* The opcode maps.  */
 
@@ -2054,8 +2020,7 @@
    recognized.  */
 
 static const struct sh_opcode *
-sh_insn_info (insn)
-     unsigned int insn;
+sh_insn_info (unsigned int insn)
 {
   const struct sh_major_opcode *maj;
   const struct sh_minor_opcode *min, *minend;
@@ -2082,27 +2047,12 @@
   return NULL;
 }
 
-/* See whether an instruction uses or sets a general purpose register */
-
-static bfd_boolean
-sh_insn_uses_or_sets_reg (insn, op, reg)
-     unsigned int insn;
-     const struct sh_opcode *op;
-     unsigned int reg;
-{
-  if (sh_insn_uses_reg (insn, op, reg))
-    return TRUE;
-
-  return sh_insn_sets_reg (insn, op, reg);
-}
-
 /* See whether an instruction uses a general purpose register.  */
 
 static bfd_boolean
-sh_insn_uses_reg (insn, op, reg)
-     unsigned int insn;
-     const struct sh_opcode *op;
-     unsigned int reg;
+sh_insn_uses_reg (unsigned int insn,
+		  const struct sh_opcode *op,
+		  unsigned int reg)
 {
   unsigned int f;
 
@@ -2128,10 +2078,9 @@
 /* See whether an instruction sets a general purpose register.  */
 
 static bfd_boolean
-sh_insn_sets_reg (insn, op, reg)
-     unsigned int insn;
-     const struct sh_opcode *op;
-     unsigned int reg;
+sh_insn_sets_reg (unsigned int insn,
+		  const struct sh_opcode *op,
+		  unsigned int reg)
 {
   unsigned int f;
 
@@ -2152,27 +2101,25 @@
   return FALSE;
 }
 
-/* See whether an instruction uses or sets a floating point register */
+/* See whether an instruction uses or sets a general purpose register */
 
 static bfd_boolean
-sh_insn_uses_or_sets_freg (insn, op, reg)
-     unsigned int insn;
-     const struct sh_opcode *op;
-     unsigned int reg;
+sh_insn_uses_or_sets_reg (unsigned int insn,
+			  const struct sh_opcode *op,
+			  unsigned int reg)
 {
-  if (sh_insn_uses_freg (insn, op, reg))
+  if (sh_insn_uses_reg (insn, op, reg))
     return TRUE;
 
-  return sh_insn_sets_freg (insn, op, reg);
+  return sh_insn_sets_reg (insn, op, reg);
 }
 
 /* See whether an instruction uses a floating point register.  */
 
 static bfd_boolean
-sh_insn_uses_freg (insn, op, freg)
-     unsigned int insn;
-     const struct sh_opcode *op;
-     unsigned int freg;
+sh_insn_uses_freg (unsigned int insn,
+		   const struct sh_opcode *op,
+		   unsigned int freg)
 {
   unsigned int f;
 
@@ -2203,10 +2150,9 @@
 /* See whether an instruction sets a floating point register.  */
 
 static bfd_boolean
-sh_insn_sets_freg (insn, op, freg)
-     unsigned int insn;
-     const struct sh_opcode *op;
-     unsigned int freg;
+sh_insn_sets_freg (unsigned int insn,
+		   const struct sh_opcode *op,
+		   unsigned int freg)
 {
   unsigned int f;
 
@@ -2228,17 +2174,29 @@
   return FALSE;
 }
 
+/* See whether an instruction uses or sets a floating point register */
+
+static bfd_boolean
+sh_insn_uses_or_sets_freg (unsigned int insn,
+			   const struct sh_opcode *op,
+			   unsigned int reg)
+{
+  if (sh_insn_uses_freg (insn, op, reg))
+    return TRUE;
+
+  return sh_insn_sets_freg (insn, op, reg);
+}
+
 /* See whether instructions I1 and I2 conflict, assuming I1 comes
    before I2.  OP1 and OP2 are the corresponding sh_opcode structures.
    This should return TRUE if there is a conflict, or FALSE if the
    instructions can be swapped safely.  */
 
 static bfd_boolean
-sh_insns_conflict (i1, op1, i2, op2)
-     unsigned int i1;
-     const struct sh_opcode *op1;
-     unsigned int i2;
-     const struct sh_opcode *op2;
+sh_insns_conflict (unsigned int i1,
+		   const struct sh_opcode *op1,
+		   unsigned int i2,
+		   const struct sh_opcode *op2)
 {
   unsigned int f1, f2;
 
@@ -2300,11 +2258,10 @@
    TRUE if I1 loads a register which I2 uses.  */
 
 static bfd_boolean
-sh_load_use (i1, op1, i2, op2)
-     unsigned int i1;
-     const struct sh_opcode *op1;
-     unsigned int i2;
-     const struct sh_opcode *op2;
+sh_load_use (unsigned int i1,
+	     const struct sh_opcode *op1,
+	     unsigned int i2,
+	     const struct sh_opcode *op2)
 {
   unsigned int f1;
 
@@ -2346,18 +2303,16 @@
 static
 #endif
 bfd_boolean
-_bfd_sh_align_load_span (abfd, sec, contents, swap, relocs,
-			 plabel, label_end, start, stop, pswapped)
-     bfd *abfd;
-     asection *sec;
-     bfd_byte *contents;
-     bfd_boolean (*swap) PARAMS ((bfd *, asection *, PTR, bfd_byte *, bfd_vma));
-     PTR relocs;
-     bfd_vma **plabel;
-     bfd_vma *label_end;
-     bfd_vma start;
-     bfd_vma stop;
-     bfd_boolean *pswapped;
+_bfd_sh_align_load_span (bfd *abfd,
+			 asection *sec,
+			 bfd_byte *contents,
+			 bfd_boolean (*swap) (bfd *, asection *, void *, bfd_byte *, bfd_vma),
+			 void * relocs,
+			 bfd_vma **plabel,
+			 bfd_vma *label_end,
+			 bfd_vma start,
+			 bfd_vma stop,
+			 bfd_boolean *pswapped)
 {
   int dsp = (abfd->arch_info->mach == bfd_mach_sh_dsp
 	     || abfd->arch_info->mach == bfd_mach_sh3_dsp);
@@ -2557,91 +2512,14 @@
 }
 #endif /* not COFF_IMAGE_WITH_PE */
 
-/* Look for loads and stores which we can align to four byte
-   boundaries.  See the longer comment above sh_relax_section for why
-   this is desirable.  This sets *PSWAPPED if some instruction was
-   swapped.  */
-
-static bfd_boolean
-sh_align_loads (abfd, sec, internal_relocs, contents, pswapped)
-     bfd *abfd;
-     asection *sec;
-     struct internal_reloc *internal_relocs;
-     bfd_byte *contents;
-     bfd_boolean *pswapped;
-{
-  struct internal_reloc *irel, *irelend;
-  bfd_vma *labels = NULL;
-  bfd_vma *label, *label_end;
-  bfd_size_type amt;
-
-  *pswapped = FALSE;
-
-  irelend = internal_relocs + sec->reloc_count;
-
-  /* Get all the addresses with labels on them.  */
-  amt = (bfd_size_type) sec->reloc_count * sizeof (bfd_vma);
-  labels = (bfd_vma *) bfd_malloc (amt);
-  if (labels == NULL)
-    goto error_return;
-  label_end = labels;
-  for (irel = internal_relocs; irel < irelend; irel++)
-    {
-      if (irel->r_type == R_SH_LABEL)
-	{
-	  *label_end = irel->r_vaddr - sec->vma;
-	  ++label_end;
-	}
-    }
-
-  /* Note that the assembler currently always outputs relocs in
-     address order.  If that ever changes, this code will need to sort
-     the label values and the relocs.  */
-
-  label = labels;
-
-  for (irel = internal_relocs; irel < irelend; irel++)
-    {
-      bfd_vma start, stop;
-
-      if (irel->r_type != R_SH_CODE)
-	continue;
-
-      start = irel->r_vaddr - sec->vma;
-
-      for (irel++; irel < irelend; irel++)
-	if (irel->r_type == R_SH_DATA)
-	  break;
-      if (irel < irelend)
-	stop = irel->r_vaddr - sec->vma;
-      else
-	stop = sec->size;
-
-      if (! _bfd_sh_align_load_span (abfd, sec, contents, sh_swap_insns,
-				     (PTR) internal_relocs, &label,
-				     label_end, start, stop, pswapped))
-	goto error_return;
-    }
-
-  free (labels);
-
-  return TRUE;
-
- error_return:
-  if (labels != NULL)
-    free (labels);
-  return FALSE;
-}
-
 /* Swap two SH instructions.  */
 
 static bfd_boolean
-sh_swap_insns (abfd, sec, relocs, contents, addr)
-     bfd *abfd;
-     asection *sec;
-     PTR relocs;
-     bfd_byte *contents;
-     bfd_vma addr;
+sh_swap_insns (bfd *      abfd,
+	       asection * sec,
+	       void *     relocs,
+	       bfd_byte * contents,
+	       bfd_vma    addr)
 {
   struct internal_reloc *internal_relocs = (struct internal_reloc *) relocs;
   unsigned short i1, i2;
@@ -2764,21 +2642,94 @@
 
   return TRUE;
 }
+
+/* Look for loads and stores which we can align to four byte
+   boundaries.  See the longer comment above sh_relax_section for why
+   this is desirable.  This sets *PSWAPPED if some instruction was
+   swapped.  */
+
+static bfd_boolean
+sh_align_loads (bfd *abfd,
+		asection *sec,
+		struct internal_reloc *internal_relocs,
+		bfd_byte *contents,
+		bfd_boolean *pswapped)
+{
+  struct internal_reloc *irel, *irelend;
+  bfd_vma *labels = NULL;
+  bfd_vma *label, *label_end;
+  bfd_size_type amt;
+
+  *pswapped = FALSE;
+
+  irelend = internal_relocs + sec->reloc_count;
+
+  /* Get all the addresses with labels on them.  */
+  amt = (bfd_size_type) sec->reloc_count * sizeof (bfd_vma);
+  labels = (bfd_vma *) bfd_malloc (amt);
+  if (labels == NULL)
+    goto error_return;
+  label_end = labels;
+  for (irel = internal_relocs; irel < irelend; irel++)
+    {
+      if (irel->r_type == R_SH_LABEL)
+	{
+	  *label_end = irel->r_vaddr - sec->vma;
+	  ++label_end;
+	}
+    }
+
+  /* Note that the assembler currently always outputs relocs in
+     address order.  If that ever changes, this code will need to sort
+     the label values and the relocs.  */
+
+  label = labels;
+
+  for (irel = internal_relocs; irel < irelend; irel++)
+    {
+      bfd_vma start, stop;
+
+      if (irel->r_type != R_SH_CODE)
+	continue;
+
+      start = irel->r_vaddr - sec->vma;
+
+      for (irel++; irel < irelend; irel++)
+	if (irel->r_type == R_SH_DATA)
+	  break;
+      if (irel < irelend)
+	stop = irel->r_vaddr - sec->vma;
+      else
+	stop = sec->size;
+
+      if (! _bfd_sh_align_load_span (abfd, sec, contents, sh_swap_insns,
+				     internal_relocs, &label,
+				     label_end, start, stop, pswapped))
+	goto error_return;
+    }
+
+  free (labels);
+
+  return TRUE;
+
+ error_return:
+  if (labels != NULL)
+    free (labels);
+  return FALSE;
+}
 
 /* This is a modification of _bfd_coff_generic_relocate_section, which
    will handle SH relaxing.  */
 
 static bfd_boolean
-sh_relocate_section (output_bfd, info, input_bfd, input_section, contents,
-		     relocs, syms, sections)
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     struct internal_reloc *relocs;
-     struct internal_syment *syms;
-     asection **sections;
+sh_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
+		     struct bfd_link_info *info,
+		     bfd *input_bfd,
+		     asection *input_section,
+		     bfd_byte *contents,
+		     struct internal_reloc *relocs,
+		     struct internal_syment *syms,
+		     asection **sections)
 {
   struct internal_reloc *rel;
   struct internal_reloc *relend;
@@ -2942,14 +2893,12 @@
    which uses sh_relocate_section.  */
 
 static bfd_byte *
-sh_coff_get_relocated_section_contents (output_bfd, link_info, link_order,
-					data, relocatable, symbols)
-     bfd *output_bfd;
-     struct bfd_link_info *link_info;
-     struct bfd_link_order *link_order;
-     bfd_byte *data;
-     bfd_boolean relocatable;
-     asymbol **symbols;
+sh_coff_get_relocated_section_contents (bfd *output_bfd,
+					struct bfd_link_info *link_info,
+					struct bfd_link_order *link_order,
+					bfd_byte *data,
+					bfd_boolean relocatable,
+					asymbol **symbols)
 {
   asection *input_section = link_order->u.indirect.section;
   bfd *input_bfd = input_section->owner;
@@ -3006,7 +2955,7 @@
       esymend = esym + obj_raw_syment_count (input_bfd) * symesz;
       while (esym < esymend)
 	{
-	  bfd_coff_swap_sym_in (input_bfd, (PTR) esym, (PTR) isymp);
+	  bfd_coff_swap_sym_in (input_bfd, esym, isymp);
 
 	  if (isymp->n_scnum != 0)
 	    *secpp = coff_section_from_bfd_index (input_bfd, isymp->n_scnum);
@@ -3073,8 +3022,7 @@
 #endif
 
 #ifndef TARGET_SHL_SYM
-static const bfd_target * coff_small_object_p PARAMS ((bfd *));
-static bfd_boolean coff_small_new_section_hook PARAMS ((bfd *, asection *));
+
 /* Some people want versions of the SH COFF target which do not align
    to 16 byte boundaries.  We implement that by adding a couple of new
    target vectors.  These are just like the ones above, but they
@@ -3090,8 +3038,7 @@
    Otherwise we won't recognize the non default endianness.  */
 
 static const bfd_target *
-coff_small_object_p (abfd)
-     bfd *abfd;
+coff_small_object_p (bfd *abfd)
 {
   if (abfd->target_defaulted)
     {
@@ -3104,9 +3051,7 @@
 /* Set the section alignment for the small versions.  */
 
 static bfd_boolean
-coff_small_new_section_hook (abfd, section)
-     bfd *abfd;
-     asection *section;
+coff_small_new_section_hook (bfd *abfd, asection *section)
 {
   if (! coff_new_section_hook (abfd, section))
     return FALSE;
@@ -3212,7 +3157,7 @@
 
   & shlcoff_small_vec,
 
-  (PTR) &bfd_coff_small_swap_table
+  & bfd_coff_small_swap_table
 };
 
 const bfd_target shlcoff_small_vec =
@@ -3257,6 +3202,6 @@
 
   & shcoff_small_vec,
 
-  (PTR) &bfd_coff_small_swap_table
+  & bfd_coff_small_swap_table
 };
 #endif
diff --git a/bfd/coff-sparc.c b/bfd/coff-sparc.c
index a9a699a..d3802c0 100644
--- a/bfd/coff-sparc.c
+++ b/bfd/coff-sparc.c
@@ -1,6 +1,6 @@
 /* BFD back-end for Sparc COFF files.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001,
-   2002, 2003, 2005, 2007, 2008  Free Software Foundation, Inc.
+   2002, 2003, 2005, 2007, 2008, 2012  Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -34,11 +34,6 @@
 /* The page size is a guess based on ELF.  */
 #define COFF_PAGE_SIZE 0x10000
 
-
-static reloc_howto_type *coff_sparc_reloc_type_lookup
-  PARAMS ((bfd *, bfd_reloc_code_real_type));
-static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));
-
 enum reloc_type
   {
     R_SPARC_NONE = 0,
@@ -58,20 +53,15 @@
   };
 
 /* This is stolen pretty directly from elf.c.  */
-static bfd_reloc_status_type
-bfd_coff_generic_reloc PARAMS ((bfd *, arelent *, asymbol *, PTR,
-				asection *, bfd *, char **));
 
 static bfd_reloc_status_type
-bfd_coff_generic_reloc (abfd, reloc_entry, symbol, data, input_section,
-			output_bfd, error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc_entry;
-     asymbol *symbol;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+bfd_coff_generic_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+			arelent *reloc_entry,
+			asymbol *symbol,
+			void * data ATTRIBUTE_UNUSED,
+			asection *input_section,
+			bfd *output_bfd,
+			char **error_message ATTRIBUTE_UNUSED)
 {
   if (output_bfd != (bfd *) NULL
       && (symbol->flags & BSF_SECTION_SYM) == 0)
@@ -111,7 +101,8 @@
   HOWTO(R_SPARC_UA32,    0,0,00,FALSE,0,complain_overflow_dont,    bfd_coff_generic_reloc,"R_SPARC_UA32",    FALSE,0,0x00000000,TRUE),
 };
 
-struct coff_reloc_map {
+struct coff_reloc_map
+{
   bfd_reloc_code_real_type bfd_reloc_val;
   unsigned char coff_reloc_val;
 };
@@ -145,9 +136,8 @@
 };
 
 static reloc_howto_type *
-coff_sparc_reloc_type_lookup (abfd, code)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+coff_sparc_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+			      bfd_reloc_code_real_type code)
 {
   unsigned int i;
   for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct coff_reloc_map); i++)
@@ -178,9 +168,7 @@
 #define coff_bfd_reloc_name_lookup coff_sparc_reloc_name_lookup
 
 static void
-rtype2howto (cache_ptr, dst)
-     arelent *cache_ptr;
-     struct internal_reloc *dst;
+rtype2howto (arelent *cache_ptr, struct internal_reloc *dst)
 {
   BFD_ASSERT (dst->r_type < (unsigned int) R_SPARC_max);
   cache_ptr->howto = &coff_sparc_howto_table[dst->r_type];
diff --git a/bfd/coff-stgo32.c b/bfd/coff-stgo32.c
index c10194e..882ddd2 100644
--- a/bfd/coff-stgo32.c
+++ b/bfd/coff-stgo32.c
@@ -1,6 +1,6 @@
 /* BFD back-end for Intel 386 COFF files (DJGPP variant with a stub).
    Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2005, 2006, 2007, 2009,
-   2011  Free Software Foundation, Inc.
+   2011, 2012  Free Software Foundation, Inc.
    Written by Robert Hoehne.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -54,35 +54,34 @@
 { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi"), \
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
 
+#include "sysdep.h"
 #include "bfd.h"
 
-/* At first the prototypes.  */
-
-static void
-adjust_filehdr_in_post PARAMS ((bfd *, PTR, PTR));
-static void
-adjust_filehdr_out_pre PARAMS ((bfd *, PTR, PTR));
-static void
-adjust_filehdr_out_post PARAMS ((bfd *, PTR, PTR));
-static void
-adjust_scnhdr_in_post PARAMS ((bfd *, PTR, PTR));
-static void
-adjust_scnhdr_out_pre PARAMS ((bfd *, PTR, PTR));
-static void
-adjust_scnhdr_out_post PARAMS ((bfd *, PTR, PTR));
-static void
-adjust_aux_in_post PARAMS ((bfd *, PTR, int, int, int, int, PTR));
-static void
-adjust_aux_out_pre PARAMS ((bfd *, PTR, int, int, int, int, PTR));
-static void
-adjust_aux_out_post PARAMS ((bfd *, PTR, int, int, int, int, PTR));
-static void
-create_go32_stub PARAMS ((bfd *));
-
 /* All that ..._PRE and ...POST functions are called from the corresponding
    coff_swap... functions. The ...PRE functions are called at the beginning
    of the function and the ...POST functions at the end of the swap routines.  */
 
+static void
+adjust_filehdr_in_post  (bfd *, void *, void *);
+static void
+adjust_filehdr_out_pre  (bfd *, void *, void *);
+static void
+adjust_filehdr_out_post  (bfd *, void *, void *);
+static void
+adjust_scnhdr_in_post  (bfd *, void *, void *);
+static void
+adjust_scnhdr_out_pre  (bfd *, void *, void *);
+static void
+adjust_scnhdr_out_post (bfd *, void *, void *);
+static void
+adjust_aux_in_post (bfd *, void *, int, int, int, int, void *);
+static void
+adjust_aux_out_pre (bfd *, void *, int, int, int, int, void *);
+static void
+adjust_aux_out_post (bfd *, void *, int, int, int, int, void *);
+static void
+create_go32_stub (bfd *);
+
 #define COFF_ADJUST_FILEHDR_IN_POST adjust_filehdr_in_post
 #define COFF_ADJUST_FILEHDR_OUT_PRE adjust_filehdr_out_pre
 #define COFF_ADJUST_FILEHDR_OUT_POST adjust_filehdr_out_post
@@ -95,12 +94,12 @@
 #define COFF_ADJUST_AUX_OUT_PRE adjust_aux_out_pre
 #define COFF_ADJUST_AUX_OUT_POST adjust_aux_out_post
 
-static const bfd_target *go32_check_format (bfd *abfd);
+static const bfd_target *go32_check_format (bfd *);
 
 #define COFF_CHECK_FORMAT go32_check_format
 
 static bfd_boolean
-  go32_stubbed_coff_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
+  go32_stubbed_coff_bfd_copy_private_bfd_data (bfd *, bfd *);
 
 #define coff_bfd_copy_private_bfd_data go32_stubbed_coff_bfd_copy_private_bfd_data
 
@@ -132,10 +131,9 @@
   if (val != 0) val += diff
 
 static void
-adjust_filehdr_in_post  (abfd, src, dst)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     PTR src;
-     PTR dst;
+adjust_filehdr_in_post  (bfd *  abfd ATTRIBUTE_UNUSED,
+			 void * src,
+			 void * dst)
 {
   FILHDR *filehdr_src = (FILHDR *) src;
   struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
@@ -150,10 +148,7 @@
 }
 
 static void
-adjust_filehdr_out_pre  (abfd, in, out)
-     bfd *abfd;
-     PTR in;
-     PTR out;
+adjust_filehdr_out_pre  (bfd * abfd, void * in, void * out)
 {
   struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
   FILHDR *filehdr_out = (FILHDR *) out;
@@ -172,10 +167,9 @@
 }
 
 static void
-adjust_filehdr_out_post  (abfd, in, out)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     PTR in;
-     PTR out ATTRIBUTE_UNUSED;
+adjust_filehdr_out_post  (bfd *  abfd ATTRIBUTE_UNUSED,
+			  void * in,
+			  void * out ATTRIBUTE_UNUSED)
 {
   struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
   /* Undo the above change.  */
@@ -183,10 +177,9 @@
 }
 
 static void
-adjust_scnhdr_in_post  (abfd, ext, in)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     PTR ext ATTRIBUTE_UNUSED;
-     PTR in;
+adjust_scnhdr_in_post  (bfd *  abfd ATTRIBUTE_UNUSED,
+			void * ext ATTRIBUTE_UNUSED,
+			void * in)
 {
   struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
 
@@ -196,10 +189,9 @@
 }
 
 static void
-adjust_scnhdr_out_pre  (abfd, in, out)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     PTR in;
-     PTR out ATTRIBUTE_UNUSED;
+adjust_scnhdr_out_pre  (bfd *  abfd ATTRIBUTE_UNUSED,
+			void * in,
+			void * out ATTRIBUTE_UNUSED)
 {
   struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
 
@@ -209,10 +201,9 @@
 }
 
 static void
-adjust_scnhdr_out_post (abfd, in, out)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     PTR in;
-     PTR out ATTRIBUTE_UNUSED;
+adjust_scnhdr_out_post (bfd *  abfd ATTRIBUTE_UNUSED,
+			void * in,
+			void * out ATTRIBUTE_UNUSED)
 {
   struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
 
@@ -222,14 +213,13 @@
 }
 
 static void
-adjust_aux_in_post  (abfd, ext1, type, in_class, indx, numaux, in1)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     PTR ext1 ATTRIBUTE_UNUSED;
-     int type;
-     int in_class;
-     int indx ATTRIBUTE_UNUSED;
-     int numaux ATTRIBUTE_UNUSED;
-     PTR in1;
+adjust_aux_in_post (bfd * abfd ATTRIBUTE_UNUSED,
+		    void * ext1 ATTRIBUTE_UNUSED,
+		    int type,
+		    int in_class,
+		    int indx ATTRIBUTE_UNUSED,
+		    int numaux ATTRIBUTE_UNUSED,
+		    void * in1)
 {
   union internal_auxent *in = (union internal_auxent *) in1;
 
@@ -241,14 +231,13 @@
 }
 
 static void
-adjust_aux_out_pre  (abfd, inp, type, in_class, indx, numaux, extp)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     PTR inp;
-     int type;
-     int in_class;
-     int indx ATTRIBUTE_UNUSED;
-     int numaux ATTRIBUTE_UNUSED;
-     PTR extp ATTRIBUTE_UNUSED;
+adjust_aux_out_pre (bfd *abfd ATTRIBUTE_UNUSED,
+		    void * inp,
+		    int type,
+		    int in_class,
+		    int indx ATTRIBUTE_UNUSED,
+		    int numaux ATTRIBUTE_UNUSED,
+		    void * extp ATTRIBUTE_UNUSED)
 {
   union internal_auxent *in = (union internal_auxent *) inp;
 
@@ -260,14 +249,13 @@
 }
 
 static void
-adjust_aux_out_post (abfd, inp, type, in_class, indx, numaux, extp)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     PTR inp;
-     int type;
-     int in_class;
-     int indx ATTRIBUTE_UNUSED;
-     int numaux ATTRIBUTE_UNUSED;
-     PTR extp ATTRIBUTE_UNUSED;
+adjust_aux_out_post (bfd *abfd ATTRIBUTE_UNUSED,
+		     void * inp,
+		     int type,
+		     int in_class,
+		     int indx ATTRIBUTE_UNUSED,
+		     int numaux ATTRIBUTE_UNUSED,
+		     void * extp ATTRIBUTE_UNUSED)
 {
   union internal_auxent *in = (union internal_auxent *) inp;
 
@@ -291,8 +279,7 @@
    is taken.  */
 
 static void
-create_go32_stub (abfd)
-     bfd *abfd;
+create_go32_stub (bfd *abfd)
 {
   /* Do it only once.  */
   if (coff_data (abfd)->go32stub == NULL)
@@ -393,9 +380,7 @@
    to the new obfd.  */
 
 static bfd_boolean
-go32_stubbed_coff_bfd_copy_private_bfd_data  (ibfd, obfd)
-     bfd *ibfd;
-     bfd *obfd;
+go32_stubbed_coff_bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
 {
   /* Check if both are the same targets.  */
   if (ibfd->xvec != obfd->xvec)
diff --git a/bfd/coff-tic30.c b/bfd/coff-tic30.c
index 497d340..de09b30 100644
--- a/bfd/coff-tic30.c
+++ b/bfd/coff-tic30.c
@@ -1,5 +1,5 @@
 /* BFD back-end for TMS320C30 coff binaries.
-   Copyright 1998, 1999, 2000, 2001, 2002, 2005, 2007, 2008, 2011
+   Copyright 1998, 1999, 2000, 2001, 2002, 2005, 2007, 2008, 2011, 2012
    Free Software Foundation, Inc.
    Contributed by Steven Haworth ([email protected])
 
@@ -28,12 +28,6 @@
 #include "coff/internal.h"
 #include "libcoff.h"
 
-static int  coff_tic30_select_reloc PARAMS ((reloc_howto_type *));
-static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));
-static void reloc_processing PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
-
-reloc_howto_type * tic30_coff_reloc_type_lookup PARAMS ((bfd *, bfd_reloc_code_real_type));
-
 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
 
 reloc_howto_type tic30_coff_howto_table[] =
@@ -59,10 +53,9 @@
    map to the howto table entries that match those in both the aout
    and coff implementations.  */
 
-reloc_howto_type *
-tic30_coff_reloc_type_lookup (abfd, code)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+static reloc_howto_type *
+tic30_coff_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+			      bfd_reloc_code_real_type code)
 {
   switch (code)
     {
@@ -104,8 +97,7 @@
 /* Turn a howto into a reloc number.  */
 
 static int
-coff_tic30_select_reloc (howto)
-     reloc_howto_type *howto;
+coff_tic30_select_reloc (reloc_howto_type *howto)
 {
   return howto->type;
 }
@@ -125,9 +117,7 @@
 /* Code to turn a r_type into a howto ptr, uses the above howto table.  */
 
 static void
-rtype2howto (internal, dst)
-     arelent *internal;
-     struct internal_reloc *dst;
+rtype2howto (arelent *internal, struct internal_reloc *dst)
 {
   switch (dst->r_type)
     {
@@ -163,12 +153,11 @@
  reloc_processing(relent, reloc, symbols, abfd, section)
 
 static void
-reloc_processing (relent, reloc, symbols, abfd, section)
-     arelent *relent;
-     struct internal_reloc *reloc;
-     asymbol **symbols;
-     bfd *abfd;
-     asection *section;
+reloc_processing (arelent *relent,
+		  struct internal_reloc *reloc,
+		  asymbol **symbols,
+		  bfd *abfd,
+		  asection *section)
 {
   relent->address = reloc->r_vaddr;
   rtype2howto (relent, reloc);
diff --git a/bfd/coff-tic4x.c b/bfd/coff-tic4x.c
index 4259dd9..c59894a 100644
--- a/bfd/coff-tic4x.c
+++ b/bfd/coff-tic4x.c
@@ -1,6 +1,6 @@
 /* BFD back-end for TMS320C4X coff binaries.
    Copyright 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2005, 2007,
-   2008  Free Software Foundation, Inc.
+   2008, 2012  Free Software Foundation, Inc.
 
    Contributed by Michael Hayes ([email protected])
 
@@ -32,26 +32,19 @@
 #undef  F_LSYMS
 #define	F_LSYMS		F_LSYMS_TICOFF
 
-static bfd_boolean ticoff_bfd_is_local_label_name
-    PARAMS ((bfd *, const char *));
-static bfd_reloc_status_type tic4x_relocation
-    PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char ** ));
-static reloc_howto_type *tic4x_coff_reloc_type_lookup
-    PARAMS ((bfd *, bfd_reloc_code_real_type ));
-static void tic4x_lookup_howto
-    PARAMS ((arelent *, struct internal_reloc * ));
-static reloc_howto_type *coff_tic4x_rtype_to_howto
-    PARAMS ((bfd *, asection *, struct internal_reloc *, struct coff_link_hash_entry *, struct internal_syment *, bfd_vma * ));
-static void tic4x_reloc_processing
-    PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection * ));
-
+static reloc_howto_type *
+coff_tic4x_rtype_to_howto (bfd *, asection *, struct internal_reloc *,
+			   struct coff_link_hash_entry *,
+			   struct internal_syment *,  bfd_vma *);
+static void
+tic4x_reloc_processing (arelent *, struct internal_reloc *,
+			asymbol **, bfd *, asection *);
 
 /* Replace the stock _bfd_coff_is_local_label_name to recognize TI COFF local
    labels.  */
 static bfd_boolean
-ticoff_bfd_is_local_label_name (abfd, name)
-  bfd *abfd ATTRIBUTE_UNUSED;
-  const char *name;
+ticoff_bfd_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED,
+				const char *name)
 {
   if (TICOFF_LOCAL_LABEL_P(name))
     return TRUE;
@@ -79,15 +72,13 @@
 #include "coffcode.h"
 
 static bfd_reloc_status_type
-tic4x_relocation (abfd, reloc_entry, symbol, data, input_section,
-		  output_bfd, error_message)
-  bfd *abfd ATTRIBUTE_UNUSED;
-  arelent *reloc_entry;
-  asymbol *symbol ATTRIBUTE_UNUSED;
-  PTR data ATTRIBUTE_UNUSED;
-  asection *input_section;
-  bfd *output_bfd;
-  char **error_message ATTRIBUTE_UNUSED;
+tic4x_relocation (bfd *abfd ATTRIBUTE_UNUSED,
+		  arelent *reloc_entry,
+		  asymbol *symbol ATTRIBUTE_UNUSED,
+		  void * data ATTRIBUTE_UNUSED,
+		  asection *input_section,
+		  bfd *output_bfd,
+		  char **error_message ATTRIBUTE_UNUSED)
 {
   if (output_bfd != (bfd *) NULL)
     {
@@ -128,9 +119,8 @@
    bfd/reloc.c) to map to the howto table entries.  */
 
 static reloc_howto_type *
-tic4x_coff_reloc_type_lookup (abfd, code)
-    bfd *abfd ATTRIBUTE_UNUSED;
-    bfd_reloc_code_real_type code;
+tic4x_coff_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+			      bfd_reloc_code_real_type code)
 {
   unsigned int type;
   unsigned int i;
@@ -176,9 +166,8 @@
    Called after some initial checking by the tic4x_rtype_to_howto fn
    below.  */
 static void
-tic4x_lookup_howto (internal, dst)
-     arelent *internal;
-     struct internal_reloc *dst;
+tic4x_lookup_howto (arelent *internal,
+		    struct internal_reloc *dst)
 {
   unsigned int i;
   int bank = (dst->r_symndx == -1) ? HOWTO_BANK : 0;
@@ -198,13 +187,12 @@
 }
 
 static reloc_howto_type *
-coff_tic4x_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *sec;
-     struct internal_reloc *rel;
-     struct coff_link_hash_entry *h ATTRIBUTE_UNUSED;
-     struct internal_syment *sym ATTRIBUTE_UNUSED;
-     bfd_vma *addendp;
+coff_tic4x_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+			   asection *sec,
+			   struct internal_reloc *rel,
+			   struct coff_link_hash_entry *h ATTRIBUTE_UNUSED,
+			   struct internal_syment *sym ATTRIBUTE_UNUSED,
+			   bfd_vma *addendp)
 {
   arelent genrel;
 
@@ -221,12 +209,11 @@
 
 
 static void
-tic4x_reloc_processing (relent, reloc, symbols, abfd, section)
-     arelent *relent;
-     struct internal_reloc *reloc;
-     asymbol **symbols;
-     bfd *abfd;
-     asection *section;
+tic4x_reloc_processing (arelent *relent,
+			struct internal_reloc *reloc,
+			asymbol **symbols,
+			bfd *abfd,
+			asection *section)
 {
   asymbol *ptr;
 
@@ -274,19 +261,31 @@
 
 
 /* TI COFF v0, DOS tools (little-endian headers).  */
-CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff0_vec, "coff0-tic4x", HAS_LOAD_PAGE, 0, '_', NULL, (PTR)&ticoff0_swap_table);
+CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff0_vec, "coff0-tic4x",
+			      HAS_LOAD_PAGE, SEC_CODE | SEC_READONLY, '_',
+			      NULL, &ticoff0_swap_table);
 
 /* TI COFF v0, SPARC tools (big-endian headers).  */
-CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff0_beh_vec, "coff0-beh-tic4x", HAS_LOAD_PAGE, 0, '_', &tic4x_coff0_vec, (PTR)&ticoff0_swap_table);
+CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff0_beh_vec, "coff0-beh-tic4x",
+			      HAS_LOAD_PAGE, SEC_CODE | SEC_READONLY, '_',
+			      &tic4x_coff0_vec, &ticoff0_swap_table);
 
 /* TI COFF v1, DOS tools (little-endian headers).  */
-CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff1_vec, "coff1-tic4x", HAS_LOAD_PAGE, 0, '_', &tic4x_coff0_beh_vec, (PTR)&ticoff1_swap_table);
+CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff1_vec, "coff1-tic4x",
+			      HAS_LOAD_PAGE, SEC_CODE | SEC_READONLY, '_',
+			      &tic4x_coff0_beh_vec, &ticoff1_swap_table);
 
 /* TI COFF v1, SPARC tools (big-endian headers).  */
-CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff1_beh_vec, "coff1-beh-tic4x", HAS_LOAD_PAGE, 0, '_', &tic4x_coff1_vec, (PTR)&ticoff1_swap_table);
+CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff1_beh_vec, "coff1-beh-tic4x",
+			      HAS_LOAD_PAGE, SEC_CODE | SEC_READONLY, '_',
+			      &tic4x_coff1_vec, &ticoff1_swap_table);
 
 /* TI COFF v2, TI DOS tools output (little-endian headers).  */
-CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff2_vec, "coff2-tic4x", HAS_LOAD_PAGE, 0, '_', &tic4x_coff1_beh_vec, COFF_SWAP_TABLE);
+CREATE_LITTLE_COFF_TARGET_VEC(tic4x_coff2_vec, "coff2-tic4x",
+			      HAS_LOAD_PAGE, SEC_CODE | SEC_READONLY, '_',
+			      &tic4x_coff1_beh_vec, COFF_SWAP_TABLE);
 
 /* TI COFF v2, TI SPARC tools output (big-endian headers).  */
-CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff2_beh_vec, "coff2-beh-tic4x", HAS_LOAD_PAGE, 0, '_', &tic4x_coff2_vec, COFF_SWAP_TABLE);
+CREATE_BIGHDR_COFF_TARGET_VEC(tic4x_coff2_beh_vec, "coff2-beh-tic4x",
+			      HAS_LOAD_PAGE, SEC_CODE | SEC_READONLY, '_',
+			      &tic4x_coff2_vec, COFF_SWAP_TABLE);
diff --git a/bfd/coff-tic54x.c b/bfd/coff-tic54x.c
index 3c353da..8efdc20 100644
--- a/bfd/coff-tic54x.c
+++ b/bfd/coff-tic54x.c
@@ -1,5 +1,5 @@
 /* BFD back-end for TMS320C54X coff binaries.
-   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2011
+   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2011, 2012
    Free Software Foundation, Inc.
    Contributed by Timothy Wall ([email protected])
 
@@ -31,22 +31,9 @@
 #undef  F_LSYMS
 #define	F_LSYMS		F_LSYMS_TICOFF
 
-static void tic54x_reloc_processing
-  PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
-static bfd_reloc_status_type tic54x_relocation
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static bfd_boolean tic54x_set_section_contents
-  PARAMS ((bfd *, sec_ptr, const PTR, file_ptr, bfd_size_type));
-static reloc_howto_type *coff_tic54x_rtype_to_howto
-  PARAMS ((bfd *, asection *, struct internal_reloc *, struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *));
-static bfd_boolean tic54x_set_arch_mach
-  PARAMS ((bfd *, enum bfd_architecture, unsigned long));
-static reloc_howto_type * tic54x_coff_reloc_type_lookup
-  PARAMS ((bfd *, bfd_reloc_code_real_type));
-static void tic54x_lookup_howto
-  PARAMS ((arelent *, struct internal_reloc *));
-static bfd_boolean ticoff_bfd_is_local_label_name
-  PARAMS ((bfd *, const char *));
+static void
+tic54x_reloc_processing (arelent *, struct internal_reloc *,
+			 asymbol **, bfd *, asection *);
 
 /* 32-bit operations
    The octet order is screwy.  words are LSB first (LS octet, actually), but
@@ -97,26 +84,24 @@
 #define coff_set_section_load_page bfd_ticoff_set_section_load_page
 
 void
-bfd_ticoff_set_section_load_page (sect, page)
-  asection *sect;
-  int page;
+bfd_ticoff_set_section_load_page (asection *sect,
+				  int page)
 {
   sect->lma = (sect->lma & ADDR_MASK) | PG_TO_FLAG(page);
 }
 
 int
-bfd_ticoff_get_section_load_page (sect)
-  asection *sect;
+bfd_ticoff_get_section_load_page (asection *sect)
 {
   int page;
 
   /* Provide meaningful defaults for predefined sections.  */
-  if (sect == &bfd_com_section)
+  if (sect == bfd_com_section_ptr)
     page = PG_DATA;
 
-  else if (sect == &bfd_und_section
-      || sect == &bfd_abs_section
-      || sect == &bfd_ind_section)
+  else if (bfd_is_und_section (sect)
+	   || bfd_is_abs_section (sect)
+	   || bfd_is_ind_section (sect))
     page = PG_PROG;
 
   else
@@ -129,10 +114,9 @@
    (e.g. binary).  */
 
 static bfd_boolean
-tic54x_set_arch_mach (abfd, arch, machine)
-     bfd *abfd;
-     enum bfd_architecture arch;
-     unsigned long machine;
+tic54x_set_arch_mach (bfd *abfd,
+		      enum bfd_architecture arch,
+		      unsigned long machine)
 {
   if (arch == bfd_arch_unknown)
     arch = bfd_arch_tic54x;
@@ -144,15 +128,13 @@
 }
 
 static bfd_reloc_status_type
-tic54x_relocation (abfd, reloc_entry, symbol, data, input_section,
-                   output_bfd, error_message)
-  bfd *abfd ATTRIBUTE_UNUSED;
-  arelent *reloc_entry;
-  asymbol *symbol ATTRIBUTE_UNUSED;
-  PTR data ATTRIBUTE_UNUSED;
-  asection *input_section;
-  bfd *output_bfd;
-  char **error_message ATTRIBUTE_UNUSED;
+tic54x_relocation (bfd *abfd ATTRIBUTE_UNUSED,
+		   arelent *reloc_entry,
+		   asymbol *symbol ATTRIBUTE_UNUSED,
+		   void * data ATTRIBUTE_UNUSED,
+		   asection *input_section,
+		   bfd *output_bfd,
+		   char **error_message ATTRIBUTE_UNUSED)
 {
   if (output_bfd != (bfd *) NULL)
     {
@@ -234,10 +216,9 @@
 /* For the case statement use the code values used tc_gen_reloc (defined in
    bfd/reloc.c) to map to the howto table entries.  */
 
-reloc_howto_type *
-tic54x_coff_reloc_type_lookup (abfd, code)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+static reloc_howto_type *
+tic54x_coff_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+			       bfd_reloc_code_real_type code)
 {
   switch (code)
     {
@@ -280,9 +261,8 @@
    Called after some initial checking by the tic54x_rtype_to_howto fn below.  */
 
 static void
-tic54x_lookup_howto (internal, dst)
-     arelent *internal;
-     struct internal_reloc *dst;
+tic54x_lookup_howto (arelent *internal,
+		     struct internal_reloc *dst)
 {
   unsigned i;
   int bank = (dst->r_symndx == -1) ? HOWTO_BANK : 0;
@@ -307,13 +287,12 @@
 #define coff_rtype_to_howto coff_tic54x_rtype_to_howto
 
 static reloc_howto_type *
-coff_tic54x_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *sec;
-     struct internal_reloc *rel;
-     struct coff_link_hash_entry *h ATTRIBUTE_UNUSED;
-     struct internal_syment *sym ATTRIBUTE_UNUSED;
-     bfd_vma *addendp;
+coff_tic54x_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+			    asection *sec,
+			    struct internal_reloc *rel,
+			    struct coff_link_hash_entry *h ATTRIBUTE_UNUSED,
+			    struct internal_syment *sym ATTRIBUTE_UNUSED,
+			    bfd_vma *addendp)
 {
   arelent genrel;
 
@@ -334,9 +313,8 @@
    labels.  */
 
 static bfd_boolean
-ticoff_bfd_is_local_label_name (abfd, name)
-  bfd *abfd ATTRIBUTE_UNUSED;
-  const char *name;
+ticoff_bfd_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED,
+				const char *name)
 {
   if (TICOFF_LOCAL_LABEL_P(name))
     return TRUE;
@@ -345,15 +323,6 @@
 
 #define coff_bfd_is_local_label_name ticoff_bfd_is_local_label_name
 
-/* Clear the r_reserved field in relocs.  */
-#define SWAP_OUT_RELOC_EXTRA(abfd,src,dst) \
-  do \
-    { \
-      dst->r_reserved[0] = 0; \
-      dst->r_reserved[1] = 0; \
-    } \
-  while (0)
-
 /* Customize coffcode.h; the default coff_ functions are set up to use COFF2;
    coff_bad_format_hook uses BADMAG, so set that for COFF2.  The COFF1
    and COFF0 vectors use custom _bad_format_hook procs instead of setting
@@ -367,24 +336,22 @@
 #include "coffcode.h"
 
 static bfd_boolean
-tic54x_set_section_contents (abfd, section, location, offset, bytes_to_do)
-     bfd *abfd;
-     sec_ptr section;
-     const PTR location;
-     file_ptr offset;
-     bfd_size_type bytes_to_do;
+tic54x_set_section_contents (bfd *abfd,
+			     sec_ptr section,
+			     const void * location,
+			     file_ptr offset,
+			     bfd_size_type bytes_to_do)
 {
   return coff_set_section_contents (abfd, section, location,
                                     offset, bytes_to_do);
 }
 
 static void
-tic54x_reloc_processing (relent, reloc, symbols, abfd, section)
-     arelent *relent;
-     struct internal_reloc *reloc;
-     asymbol **symbols;
-     bfd *abfd;
-     asection *section;
+tic54x_reloc_processing (arelent *relent,
+			 struct internal_reloc *reloc,
+			 asymbol **symbols,
+			 bfd *abfd,
+			 asection *section)
 {
   asymbol *ptr;
 
@@ -472,7 +439,7 @@
     BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
     NULL,
 
-    (PTR) & ticoff0_swap_table
+    & ticoff0_swap_table
   };
 
 /* TI COFF v0, SPARC tools (big-endian headers).  */
@@ -518,7 +485,7 @@
 
     & tic54x_coff0_vec,
 
-    (PTR) & ticoff0_swap_table
+    & ticoff0_swap_table
   };
 
 /* TI COFF v1, DOS tools (little-endian headers).  */
@@ -564,7 +531,7 @@
 
     & tic54x_coff0_beh_vec,
 
-    (PTR) & ticoff1_swap_table
+    & ticoff1_swap_table
 };
 
 /* TI COFF v1, SPARC tools (big-endian headers).  */
@@ -610,7 +577,7 @@
 
     & tic54x_coff1_vec,
 
-    (PTR) & ticoff1_swap_table
+    & ticoff1_swap_table
   };
 
 /* TI COFF v2, TI DOS tools output (little-endian headers).  */
diff --git a/bfd/coff-tic80.c b/bfd/coff-tic80.c
index 6455e49..c8fa5c0 100644
--- a/bfd/coff-tic80.c
+++ b/bfd/coff-tic80.c
@@ -1,6 +1,6 @@
 /* BFD back-end for Texas Instruments TMS320C80 Multimedia Video Processor (MVP).
-   Copyright 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
-   Free Software Foundation, Inc.
+   Copyright 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008,
+   2012  Free Software Foundation, Inc.
 
    Written by Fred Fish ([email protected])
 
@@ -32,7 +32,7 @@
 /* Newlib-based hosts define _CONST as a STDC-safe alias for const,
   but to the tic80 toolchain it means something altogether different.
   Since sysdep.h will have pulled in stdio.h and hence _ansi.h which
-  contains this definition, we must undef it before including the 
+  contains this definition, we must undef it before including the
   tic80-specific definition. */
 #undef _CONST
 #endif /* _CONST */
@@ -47,23 +47,15 @@
 #define GET_SCNHDR_FLAGS H_GET_16
 #define PUT_SCNHDR_FLAGS H_PUT_16
 
-static void rtype2howto
-  PARAMS ((arelent *cache_ptr, struct internal_reloc *dst));
 static bfd_reloc_status_type ppbase_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 static bfd_reloc_status_type glob15_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 static bfd_reloc_status_type glob16_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 static bfd_reloc_status_type local16_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static bfd_boolean coff_tic80_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
-	   struct internal_reloc *, struct internal_syment *, asection **));
-static reloc_howto_type * coff_tic80_rtype_to_howto
-  PARAMS ((bfd *, asection *, struct internal_reloc *,
-	   struct coff_link_hash_entry *, struct internal_syment *,
-	   bfd_vma *));
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+
 
 static reloc_howto_type tic80_howto_table[] =
 {
@@ -370,15 +362,13 @@
    relocations.  */
 
 static bfd_reloc_status_type
-ppbase_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
-	      error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc_entry ATTRIBUTE_UNUSED;
-     asymbol *symbol_in ATTRIBUTE_UNUSED;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *input_section ATTRIBUTE_UNUSED;
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     char **error_message ATTRIBUTE_UNUSED;
+ppbase_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+	      arelent *reloc_entry ATTRIBUTE_UNUSED,
+	      asymbol *symbol_in ATTRIBUTE_UNUSED,
+	      void * data ATTRIBUTE_UNUSED,
+	      asection *input_section ATTRIBUTE_UNUSED,
+	      bfd *output_bfd ATTRIBUTE_UNUSED,
+	      char **error_message ATTRIBUTE_UNUSED)
 {
   /* FIXME.  */
   abort ();
@@ -387,15 +377,13 @@
 /* This special function is used for the global 15 bit relocations.  */
 
 static bfd_reloc_status_type
-glob15_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
-	      error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc_entry ATTRIBUTE_UNUSED;
-     asymbol *symbol_in ATTRIBUTE_UNUSED;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *input_section ATTRIBUTE_UNUSED;
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     char **error_message ATTRIBUTE_UNUSED;
+glob15_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+	      arelent *reloc_entry ATTRIBUTE_UNUSED,
+	      asymbol *symbol_in ATTRIBUTE_UNUSED,
+	      void * data ATTRIBUTE_UNUSED,
+	      asection *input_section ATTRIBUTE_UNUSED,
+	      bfd *output_bfd ATTRIBUTE_UNUSED,
+	      char **error_message ATTRIBUTE_UNUSED)
 {
   /* FIXME.  */
   abort ();
@@ -404,15 +392,13 @@
 /* This special function is used for the global 16 bit relocations.  */
 
 static bfd_reloc_status_type
-glob16_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
-	      error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc_entry ATTRIBUTE_UNUSED;
-     asymbol *symbol_in ATTRIBUTE_UNUSED;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *input_section ATTRIBUTE_UNUSED;
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     char **error_message ATTRIBUTE_UNUSED;
+glob16_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+	      arelent *reloc_entry ATTRIBUTE_UNUSED,
+	      asymbol *symbol_in ATTRIBUTE_UNUSED,
+	      void * data ATTRIBUTE_UNUSED,
+	      asection *input_section ATTRIBUTE_UNUSED,
+	      bfd *output_bfd ATTRIBUTE_UNUSED,
+	      char **error_message ATTRIBUTE_UNUSED)
 {
   /* FIXME.  */
   abort ();
@@ -421,15 +407,13 @@
 /* This special function is used for the local 16 bit relocations.  */
 
 static bfd_reloc_status_type
-local16_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
-	      error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc_entry ATTRIBUTE_UNUSED;
-     asymbol *symbol_in ATTRIBUTE_UNUSED;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *input_section ATTRIBUTE_UNUSED;
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     char **error_message ATTRIBUTE_UNUSED;
+local16_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+	       arelent *reloc_entry ATTRIBUTE_UNUSED,
+	       asymbol *symbol_in ATTRIBUTE_UNUSED,
+	       void * data ATTRIBUTE_UNUSED,
+	       asection *input_section ATTRIBUTE_UNUSED,
+	       bfd *output_bfd ATTRIBUTE_UNUSED,
+	       char **error_message ATTRIBUTE_UNUSED)
 {
   /* FIXME.  */
   abort ();
@@ -440,9 +424,7 @@
    to generate an output file.  */
 
 static void
-rtype2howto (cache_ptr, dst)
-     arelent *cache_ptr;
-     struct internal_reloc *dst;
+rtype2howto (arelent *cache_ptr, struct internal_reloc *dst)
 {
   unsigned int i;
 
@@ -464,13 +446,12 @@
 #define coff_rtype_to_howto coff_tic80_rtype_to_howto
 
 static reloc_howto_type *
-coff_tic80_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *sec;
-     struct internal_reloc *rel;
-     struct coff_link_hash_entry *h ATTRIBUTE_UNUSED;
-     struct internal_syment *sym ATTRIBUTE_UNUSED;
-     bfd_vma *addendp;
+coff_tic80_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+			   asection *sec,
+			   struct internal_reloc *rel,
+			   struct coff_link_hash_entry *h ATTRIBUTE_UNUSED,
+			   struct internal_syment *sym ATTRIBUTE_UNUSED,
+			   bfd_vma *addendp)
 {
   arelent genrel;
 
@@ -495,17 +476,14 @@
    of this is a copy of _bfd_coff_generic_relocate_section.  */
 
 static bfd_boolean
-coff_tic80_relocate_section (output_bfd, info, input_bfd,
-			     input_section, contents, relocs, syms,
-			     sections)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     struct internal_reloc *relocs;
-     struct internal_syment *syms;
-     asection **sections;
+coff_tic80_relocate_section (bfd *output_bfd,
+			     struct bfd_link_info *info,
+			     bfd *input_bfd,
+			     asection *input_section,
+			     bfd_byte *contents,
+			     struct internal_reloc *relocs,
+			     struct internal_syment *syms,
+			     asection **sections)
 {
   struct internal_reloc *rel;
   struct internal_reloc *relend;
@@ -722,15 +700,6 @@
   return TRUE;
 }
 
-/* Clear the r_reserved field in relocs.  */
-#define SWAP_OUT_RELOC_EXTRA(abfd,src,dst) \
-  do \
-    { \
-      dst->r_reserved[0] = 0; \
-      dst->r_reserved[1] = 0; \
-    } \
-  while (0)
-
 #define TIC80COFF 1		/* Customize coffcode.h */
 #undef C_AUTOARG		/* Clashes with TIc80's C_UEXT */
 #undef C_LASTENT		/* Clashes with TIc80's C_STATLAB */
diff --git a/bfd/coff-w65.c b/bfd/coff-w65.c
index 308d448..71d946c 100644
--- a/bfd/coff-w65.c
+++ b/bfd/coff-w65.c
@@ -1,6 +1,6 @@
 /* BFD back-end for WDC 65816 COFF binaries.
    Copyright 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2006, 2007, 2008  Free Software Foundation, Inc.
+   2006, 2007, 2008, 2012  Free Software Foundation, Inc.
    Written by Steve Chamberlain, <[email protected]>.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -28,16 +28,10 @@
 #include "coff/internal.h"
 #include "libcoff.h"
 
-static int  select_reloc              PARAMS ((reloc_howto_type *));
-static void rtype2howto               PARAMS ((arelent *, struct internal_reloc *));
-static void reloc_processing          PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
-static int  w65_reloc16_estimate    PARAMS ((bfd *, asection *, arelent *, unsigned int, struct bfd_link_info *));
-static void w65_reloc16_extra_cases PARAMS ((bfd *,struct bfd_link_info *, struct bfd_link_order *, arelent *, bfd_byte *, unsigned int *, unsigned int *));
-
 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
 static reloc_howto_type howto_table[] =
-  {
-    HOWTO (R_W65_ABS8,    0,  0, 8,  FALSE, 0, complain_overflow_bitfield, 0, "abs8", TRUE, 0x000000ff, 0x000000ff, FALSE),
+{
+  HOWTO (R_W65_ABS8,    0,  0, 8,  FALSE, 0, complain_overflow_bitfield, 0, "abs8", TRUE, 0x000000ff, 0x000000ff, FALSE),
     HOWTO (R_W65_ABS16,   1,  0, 16, FALSE, 0, complain_overflow_bitfield, 0, "abs16", TRUE, 0x0000ffff, 0x0000ffff, FALSE),
     HOWTO (R_W65_ABS24,   0,  2, 32, FALSE, 0, complain_overflow_bitfield, 0, "abs24", TRUE, 0x00ffffff, 0x00ffffff, FALSE),
     HOWTO (R_W65_ABS8S8,  0,  0, 8,  FALSE, 0, complain_overflow_bitfield, 0, ">abs8", TRUE, 0x000000ff, 0x000000ff, FALSE),
@@ -66,8 +60,7 @@
   dst->r_stuff[1] = 'C';
 
 static int
-select_reloc (howto)
-     reloc_howto_type *howto;
+select_reloc (reloc_howto_type *howto)
 {
   return howto->type ;
 }
@@ -75,9 +68,8 @@
 /* Code to turn a r_type into a howto ptr, uses the above howto table.  */
 
 static void
-rtype2howto (internal, dst)
-     arelent *internal;
-     struct internal_reloc *dst;
+rtype2howto (arelent *internal,
+	     struct internal_reloc *dst)
 {
   internal->howto = howto_table + dst->r_type - 1;
 }
@@ -93,12 +85,11 @@
  reloc_processing(relent, reloc, symbols, abfd, section)
 
 static void
-reloc_processing (relent, reloc, symbols, abfd, section)
-     arelent * relent;
-     struct internal_reloc *reloc;
-     asymbol ** symbols;
-     bfd * abfd;
-     asection * section;
+reloc_processing (arelent * relent,
+		  struct internal_reloc *reloc,
+		  asymbol ** symbols,
+		  bfd * abfd,
+		  asection * section)
 {
   relent->address = reloc->r_vaddr;
   rtype2howto (relent, reloc);
@@ -115,21 +106,20 @@
 }
 
 static int
-w65_reloc16_estimate (abfd, input_section, reloc, shrink, link_info)
-     bfd *abfd;
-     asection *input_section;
-     arelent *reloc;
-     unsigned int shrink;
-     struct bfd_link_info *link_info;
+w65_reloc16_estimate (bfd *abfd,
+		      asection *input_section,
+		      arelent *reloc,
+		      unsigned int shrink,
+		      struct bfd_link_info *link_info)
 {
   bfd_vma value;
   bfd_vma dot;
   bfd_vma gap;
 
   /* The address of the thing to be relocated will have moved back by
-   the size of the shrink  - but we don't change reloc->address here,
-   since we need it to know where the relocation lives in the source
-   uncooked section.  */
+     the size of the shrink  - but we don't change reloc->address here,
+     since we need it to know where the relocation lives in the source
+     uncooked section.  */
 
   /*  reloc->address -= shrink;   conceptual */
 
@@ -222,15 +212,13 @@
    R_MOV24B1		R_MOV24B2	24 or 8 bit reloc for mov.b  */
 
 static void
-w65_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
-			   dst_ptr)
-     bfd *abfd;
-     struct bfd_link_info *link_info;
-     struct bfd_link_order *link_order;
-     arelent *reloc;
-     bfd_byte *data;
-     unsigned int *src_ptr;
-     unsigned int *dst_ptr;
+w65_reloc16_extra_cases (bfd *abfd,
+			 struct bfd_link_info *link_info,
+			 struct bfd_link_order *link_order,
+			 arelent *reloc,
+			 bfd_byte *data,
+			 unsigned int *src_ptr,
+			 unsigned int *dst_ptr)
 {
   unsigned int src_address = *src_ptr;
   unsigned int dst_address = *dst_ptr;
diff --git a/bfd/coff-x86_64.c b/bfd/coff-x86_64.c
index d8a8a2e..946880e 100644
--- a/bfd/coff-x86_64.c
+++ b/bfd/coff-x86_64.c
@@ -18,7 +18,7 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.
-   
+
    Written by Kai Tietz, OneVision Software GmbH&CoKg.  */
 
 #ifndef COFF_WITH_pex64
@@ -619,7 +619,8 @@
     {
       bfd_vma osect_vma;
 
-      if (h && (h->type == bfd_link_hash_defined || h->type == bfd_link_hash_defweak))
+      if (h && (h->root.type == bfd_link_hash_defined
+		|| h->root.type == bfd_link_hash_defweak))
 	osect_vma = h->root.u.def.section->output_section->vma;
       else
 	{
@@ -730,6 +731,9 @@
 #define amd64coff_object_p coff_object_p
 #endif
 
+#define _bfd_generic_find_nearest_line_discriminator \
+	coff_find_nearest_line_discriminator
+
 const bfd_target
 #ifdef TARGET_SYM
   TARGET_SYM =
@@ -748,13 +752,13 @@
 
   (HAS_RELOC | EXEC_P |		/* Object flags.  */
    HAS_LINENO | HAS_DEBUG |
-   HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
+   HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS),
 
   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* Section flags.  */
 #if defined(COFF_WITH_PE)
-   | SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY
+   | SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY | SEC_DEBUGGING
 #endif
-   | SEC_CODE | SEC_DATA),
+   | SEC_CODE | SEC_DATA | SEC_EXCLUDE ),
 
 #ifdef TARGET_UNDERSCORE
   TARGET_UNDERSCORE,		/* Leading underscore.  */
diff --git a/bfd/coff-z80.c b/bfd/coff-z80.c
index 05008cd..6af3e19 100644
--- a/bfd/coff-z80.c
+++ b/bfd/coff-z80.c
@@ -4,7 +4,7 @@
 
    This file is part of BFD, the Binary File Descriptor library.
 
-   This program is free software; you can redistribute it and/or modify 
+   This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
@@ -50,12 +50,12 @@
        FALSE);
 
 static reloc_howto_type r_jr =
-HOWTO (R_JR, 0, 0, 8, TRUE, 0, 
+HOWTO (R_JR, 0, 0, 8, TRUE, 0,
        complain_overflow_signed, 0, "r_jr", FALSE, 0, 0xFF,
        FALSE);
 
 static reloc_howto_type r_off8 =
-HOWTO (R_OFF8, 0, 0, 8, FALSE, 0, 
+HOWTO (R_OFF8, 0, 0, 8, FALSE, 0,
        complain_overflow_signed, 0,"r_off8", FALSE, 0, 0xff,
        FALSE);
 
@@ -284,6 +284,6 @@
 #define coff_bfd_relax_section bfd_coff_reloc16_relax_section
 
 CREATE_LITTLE_COFF_TARGET_VEC (z80coff_vec, "coff-z80", 0,
-			       SEC_CODE | SEC_DATA, '\0', NULL, 
+			       SEC_CODE | SEC_DATA, '\0', NULL,
 			       COFF_SWAP_TABLE)
 
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index 0821b6f..6c92e26 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -1373,7 +1373,7 @@
 
 reloc_howto_type xcoff64_howto_table[] =
 {
-  /* Standard 64 bit relocation.  */
+  /* 0x00: Standard 64 bit relocation.  */
   HOWTO (R_POS,			/* type */
 	 0,			/* rightshift */
 	 4,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1388,7 +1388,7 @@
 	 MINUS_ONE,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 64 bit relocation, but store negative value.  */
+  /* 0x01: 64 bit relocation, but store negative value.  */
   HOWTO (R_NEG,			/* type */
 	 0,			/* rightshift */
 	 -4,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1403,7 +1403,7 @@
 	 MINUS_ONE,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 32 bit PC relative relocation.  */
+  /* 0x02: 32 bit PC relative relocation.  */
   HOWTO (R_REL,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1418,7 +1418,7 @@
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 16 bit TOC relative relocation.  */
+  /* 0x03: 16 bit TOC relative relocation.  */
   HOWTO (R_TOC,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1433,7 +1433,7 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* I don't really know what this is.	*/
+  /* 0x04: I don't really know what this is.	*/
   HOWTO (R_RTB,			/* type */
 	 1,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1448,7 +1448,7 @@
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* External TOC relative symbol.  */
+  /* 0x05: External TOC relative symbol.  */
   HOWTO (R_GL,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1463,7 +1463,7 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Local TOC relative symbol.	 */
+  /* 0x06: Local TOC relative symbol.	 */
   HOWTO (R_TCL,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1480,7 +1480,7 @@
 
   EMPTY_HOWTO (7),
 
-  /* Non modifiable absolute branch.  */
+  /* 0x08: Non modifiable absolute branch.  */
   HOWTO (R_BA,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1497,7 +1497,7 @@
 
   EMPTY_HOWTO (9),
 
-  /* Non modifiable relative branch.  */
+  /* 0x0a: Non modifiable relative branch.  */
   HOWTO (R_BR,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1514,7 +1514,7 @@
 
   EMPTY_HOWTO (0xb),
 
-  /* Indirect load.  */
+  /* 0x0c: Indirect load.  */
   HOWTO (R_RL,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1529,7 +1529,7 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Load address.  */
+  /* 0x0d: Load address.  */
   HOWTO (R_RLA,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1546,7 +1546,7 @@
 
   EMPTY_HOWTO (0xe),
 
-  /* Non-relocating reference.  Bitsize is 1 so that r_rsize is 0.  */
+  /* 0x0f: Non-relocating reference.  Bitsize is 1 so that r_rsize is 0.  */
   HOWTO (R_REF,			/* type */
 	 0,			/* rightshift */
 	 0,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1564,7 +1564,7 @@
   EMPTY_HOWTO (0x10),
   EMPTY_HOWTO (0x11),
 
-  /* TOC relative indirect load.  */
+  /* 0x12: TOC relative indirect load.  */
   HOWTO (R_TRL,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1579,7 +1579,7 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* TOC relative load address.	 */
+  /* 0x13: TOC relative load address.	 */
   HOWTO (R_TRLA,		/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1594,7 +1594,7 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable relative branch.  */
+  /* 0x14: Modifiable relative branch.  */
   HOWTO (R_RRTBI,		/* type */
 	 1,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1609,7 +1609,7 @@
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable absolute branch.  */
+  /* 0x15: Modifiable absolute branch.  */
   HOWTO (R_RRTBA,		/* type */
 	 1,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1624,7 +1624,7 @@
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable call absolute indirect.	 */
+  /* 0x16: Modifiable call absolute indirect.	 */
   HOWTO (R_CAI,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1639,7 +1639,7 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable call relative.	*/
+  /* 0x17: Modifiable call relative.	*/
   HOWTO (R_CREL,		/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1654,7 +1654,7 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch absolute.  */
+  /* 0x18: Modifiable branch absolute.  */
   HOWTO (R_RBA,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1669,7 +1669,7 @@
 	 0x03fffffc,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch absolute.  */
+  /* 0x19: Modifiable branch absolute.  */
   HOWTO (R_RBAC,		/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1684,7 +1684,7 @@
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch relative.  */
+  /* 0x1a: Modifiable branch relative.  */
   HOWTO (R_RBR,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1699,7 +1699,7 @@
 	 0x03fffffc,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch absolute.  */
+  /* 0x1b: Modifiable branch absolute.  */
   HOWTO (R_RBRC,		/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1714,6 +1714,7 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
+  /* 0x1c: Standard 32 bit relocation.  */
   HOWTO (R_POS,			/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1728,7 +1729,7 @@
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* 16 bit Non modifiable absolute branch.  */
+  /* 0x1d: 16 bit Non modifiable absolute branch.  */
   HOWTO (R_BA,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1743,22 +1744,22 @@
 	 0xfffc,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch relative.  */
+  /* 0x1e: Modifiable branch relative.  */
   HOWTO (R_RBR,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
 	 16,			/* bitsize */
-	 FALSE,			/* pc_relative */
+	 TRUE,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_signed, /* complain_on_overflow */
 	 0,			/* special_function */
 	 "R_RBR_16",		/* name */
 	 TRUE,			/* partial_inplace */
-	 0xffff,		/* src_mask */
-	 0xffff,		/* dst_mask */
+	 0xfffc,		/* src_mask */
+	 0xfffc,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* Modifiable branch absolute.  */
+  /* 0x1f: Modifiable branch absolute.  */
   HOWTO (R_RBA,			/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1826,6 +1827,11 @@
       return &xcoff64_howto_table[8];
     case BFD_RELOC_PPC_TOC16:
       return &xcoff64_howto_table[3];
+    case BFD_RELOC_16:
+      /* Note that this relocation is only internally used by gas.  */
+      return &xcoff64_howto_table[0xc];
+    case BFD_RELOC_PPC_B16:
+      return &xcoff64_howto_table[0x1e];
     case BFD_RELOC_32:
     case BFD_RELOC_CTOR:
       return &xcoff64_howto_table[0x1c];
@@ -2668,7 +2674,7 @@
     },
 
     /* Generic */
-    bfd_true,
+    _bfd_archive_close_and_cleanup,
     bfd_true,
     coff_new_section_hook,
     _bfd_generic_get_section_contents,
@@ -2926,7 +2932,7 @@
     },
 
     /* Generic */
-    bfd_true,
+    _bfd_archive_close_and_cleanup,
     bfd_true,
     coff_new_section_hook,
     _bfd_generic_get_section_contents,
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index 6f9685b..542b5b7 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -1,7 +1,5 @@
 /* Support for the generic parts of most COFF variants, for BFD.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright 1990-2013 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -119,11 +117,11 @@
 
 	The Microsoft PE variants of the Coff object file format add
 	an extension to support the use of long section names.  This
-	extension is defined in section 4 of the Microsoft PE/COFF 
+	extension is defined in section 4 of the Microsoft PE/COFF
 	specification (rev 8.1).  If a section name is too long to fit
 	into the section header's @code{s_name} field, it is instead
 	placed into the string table, and the @code{s_name} field is
-	filled with a slash ("/") followed by the ASCII decimal 
+	filled with a slash ("/") followed by the ASCII decimal
 	representation of the offset of the full name relative to the
 	string table base.
 
@@ -140,11 +138,11 @@
 	expecting the MS standard format may become confused; @file{PEview} is
 	one known example.
 
-	The functionality is supported in BFD by code implemented under 
+	The functionality is supported in BFD by code implemented under
 	the control of the macro @code{COFF_LONG_SECTION_NAMES}.  If not
 	defined, the format does not support long section names in any way.
-	If defined, it is used to initialise a flag, 
-	@code{_bfd_coff_long_section_names}, and a hook function pointer, 
+	If defined, it is used to initialise a flag,
+	@code{_bfd_coff_long_section_names}, and a hook function pointer,
 	@code{_bfd_coff_set_long_section_names}, in the Coff backend data
 	structure.  The flag controls the generation of long section names
 	in output BFDs at runtime; if it is false, as it will be by default
@@ -153,7 +151,7 @@
 	points to a function that allows the value of the flag to be altered
 	at runtime, on formats that support long section names at all; on
 	other formats it points to a stub that returns an error indication.
-	
+
 	With input BFDs, the flag is set according to whether any long section
 	names are detected while reading the section headers.  For a completely
 	new BFD, the flag is set to the default for the target format.  This
@@ -372,6 +370,7 @@
 #define STRING_SIZE_SIZE 4
 
 #define DOT_DEBUG	".debug"
+#define DOT_ZDEBUG	".zdebug"
 #define GNU_LINKONCE_WI ".gnu.linkonce.wi."
 #define GNU_LINKONCE_WT ".gnu.linkonce.wt."
 #define DOT_RELOC	".reloc"
@@ -545,7 +544,8 @@
       styp_flags = STYP_LIT;
 #endif /* _LIT */
     }
-  else if (CONST_STRNEQ (sec_name, DOT_DEBUG))
+  else if (CONST_STRNEQ (sec_name, DOT_DEBUG)
+           || CONST_STRNEQ (sec_name, DOT_ZDEBUG))
     {
       /* Handle the XCOFF debug section and DWARF2 debug sections.  */
       if (!sec_name[6])
@@ -652,6 +652,7 @@
   bfd_boolean is_dbg = FALSE;
 
   if (CONST_STRNEQ (sec_name, DOT_DEBUG)
+      || CONST_STRNEQ (sec_name, DOT_ZDEBUG)
 #ifdef COFF_LONG_SECTION_NAMES
       || CONST_STRNEQ (sec_name, GNU_LINKONCE_WI)
       || CONST_STRNEQ (sec_name, GNU_LINKONCE_WT)
@@ -670,7 +671,9 @@
   /* FIXME: There is no gas syntax to specify the debug section flag.  */
   if (is_dbg)
     {
-      sec_flags &= (SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD);
+      sec_flags &= (SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD
+      		    | SEC_LINK_DUPLICATES_SAME_CONTENTS
+      		    | SEC_LINK_DUPLICATES_SAME_SIZE);
       sec_flags |= SEC_DEBUGGING | SEC_READONLY;
     }
 
@@ -698,7 +701,11 @@
   /* skip SORT */
   if (sec_flags & SEC_LINK_ONCE)
     styp_flags |= IMAGE_SCN_LNK_COMDAT;
-  /* skip LINK_DUPLICATES */
+  if ((sec_flags
+       & (SEC_LINK_DUPLICATES_DISCARD | SEC_LINK_DUPLICATES_SAME_CONTENTS
+          | SEC_LINK_DUPLICATES_SAME_SIZE)) != 0)
+    styp_flags |= IMAGE_SCN_LNK_COMDAT;
+
   /* skip LINKER_CREATED */
 
   if ((sec_flags & SEC_COFF_NOREAD) == 0)
@@ -788,6 +795,12 @@
   else if (styp_flags & STYP_PAD)
     sec_flags = 0;
 #ifdef RS6000COFF_C
+  else if (styp_flags & STYP_EXCEPT)
+    sec_flags |= SEC_LOAD;
+  else if (styp_flags & STYP_LOADER)
+    sec_flags |= SEC_LOAD;
+  else if (styp_flags & STYP_TYPCHK)
+    sec_flags |= SEC_LOAD;
   else if (styp_flags & STYP_DWARF)
     sec_flags |= SEC_DEBUGGING;
 #endif
@@ -815,6 +828,7 @@
 	sec_flags |= SEC_ALLOC;
     }
   else if (CONST_STRNEQ (name, DOT_DEBUG)
+	   || CONST_STRNEQ (name, DOT_ZDEBUG)
 #ifdef _COMMENT
 	   || strcmp (name, _COMMENT) == 0
 #endif
@@ -1152,6 +1166,7 @@
   bfd_boolean is_dbg = FALSE;
 
   if (CONST_STRNEQ (name, DOT_DEBUG)
+      || CONST_STRNEQ (name, DOT_ZDEBUG)
 #ifdef COFF_LONG_SECTION_NAMES
       || CONST_STRNEQ (name, GNU_LINKONCE_WI)
       || CONST_STRNEQ (name, GNU_LINKONCE_WT)
@@ -1374,7 +1389,7 @@
 .  bfd_boolean _bfd_coff_long_section_names;
 .  bfd_boolean (*_bfd_coff_set_long_section_names)
 .    (bfd *, int);
-.  
+.
 .  unsigned int _bfd_coff_default_section_alignment_power;
 .  bfd_boolean _bfd_coff_force_symnames_in_strings;
 .  unsigned int _bfd_coff_debug_string_prefix_length;
@@ -3348,36 +3363,38 @@
 	     padding the previous section up if necessary.  */
 	  old_sofar = sofar;
 
+	  sofar = BFD_ALIGN (sofar, 1 << current->alignment_power);
+
 #ifdef RS6000COFF_C
-	  /* AIX loader checks the text section alignment of (vma - filepos)
-	     So even though the filepos may be aligned wrt the o_algntext, for
-	     AIX executables, this check fails. This shows up when a native
-	     AIX executable is stripped with gnu strip because the default vma
-	     of native is 0x10000150 but default for gnu is 0x10000140.  Gnu
-	     stripped gnu excutable passes this check because the filepos is
-	     0x0140.  This problem also show up with 64 bit shared objects. The
-	     data section must also be aligned.  */
+	  /* Make sure the file offset and the vma of .text/.data are at the
+	     same page offset, so that the file can be mmap'ed without being
+	     relocated.  Failing that, AIX is able to load and execute the
+	     program, but it will be silently relocated (possible as
+	     executables are PIE).  But the relocation is slightly costly and
+	     complexify the use of addr2line or gdb.  So better to avoid it,
+	     like does the native linker.  Usually gnu ld makes sure that
+	     the vma of .text is the file offset so this issue shouldn't
+	     appear unless you are stripping such an executable.
+
+	     AIX loader checks the text section alignment of (vma - filepos),
+	     and the native linker doesn't try to align the text sections.
+	     For example:
+
+	     0 .text         000054cc  10000128  10000128  00000128  2**5
+                             CONTENTS, ALLOC, LOAD, CODE
+	  */
+
 	  if (!strcmp (current->name, _TEXT)
 	      || !strcmp (current->name, _DATA))
 	    {
-	      bfd_vma pad;
-	      bfd_vma align;
+	      bfd_vma align = 4096;
+	      bfd_vma sofar_off = sofar % align;
+	      bfd_vma vma_off = current->vma % align;
 
-	      sofar = BFD_ALIGN (sofar, 1 << current->alignment_power);
-
-	      align = 1 << current->alignment_power;
-	      pad = abs (current->vma - sofar) % align;
-
-	      if (pad)
-		{
-		  pad = align - pad;
-		  sofar += pad;
-		}
-	    }
-	  else
-#else
-	    {
-	      sofar = BFD_ALIGN (sofar, 1 << current->alignment_power);
+	      if (vma_off > sofar_off)
+		sofar += vma_off - sofar_off;
+	      else if (vma_off < sofar_off)
+		sofar += align + vma_off - sofar_off;
 	    }
 #endif
 	  if (previous != NULL)
@@ -3436,7 +3453,7 @@
 	 incremented in coff_set_section_contents.  This is right for
 	 SVR3.2.  */
       if (strcmp (current->name, _LIB) == 0)
-	bfd_set_section_vma (abfd, current, 0);
+	(void) bfd_set_section_vma (abfd, current, 0);
 #endif
 
 #ifdef ALIGN_SECTIONS_IN_FILE
@@ -3938,7 +3955,7 @@
 	  bfd_size_type amt;
 
 	  internal_f.f_nscns++;
-	  strncpy (&(scnhdr.s_name[0]), current->name, 8);
+	  memcpy (scnhdr.s_name, ".ovrflo", 8);
 	  scnhdr.s_paddr = current->reloc_count;
 	  scnhdr.s_vaddr = current->lineno_count;
 	  scnhdr.s_size = 0;
diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index a9f3b47..07a527d 100644
--- a/bfd/coffgen.c
+++ b/bfd/coffgen.c
@@ -91,7 +91,7 @@
              don't know the length of the string table.  */
 	  strings += strindex;
 	  name = (char *) bfd_alloc (abfd,
-                                     (bfd_size_type) strlen (strings) + 1);
+                                     (bfd_size_type) strlen (strings) + 1 + 1);
 	  if (name == NULL)
 	    return FALSE;
 	  strcpy (name, strings);
@@ -102,7 +102,7 @@
     {
       /* Assorted wastage to null-terminate the name, thanks AT&T! */
       name = (char *) bfd_alloc (abfd,
-                                 (bfd_size_type) sizeof (hdr->s_name) + 1);
+                                 (bfd_size_type) sizeof (hdr->s_name) + 1 + 1);
       if (name == NULL)
 	return FALSE;
       strncpy (name, (char *) &hdr->s_name[0], sizeof (hdr->s_name));
@@ -146,13 +146,87 @@
   if (hdr->s_scnptr != 0)
     return_section->flags |= SEC_HAS_CONTENTS;
 
+  /* Compress/decompress DWARF debug sections with names: .debug_* and
+     .zdebug_*, after the section flags is set.  */
+  if ((flags & SEC_DEBUGGING)
+      && ((name[1] == 'd' && name[6] == '_')
+	  || (name[1] == 'z' && name[7] == '_')))
+    {
+      enum { nothing, compress, decompress } action = nothing;
+      char *new_name = NULL;
+
+      if (bfd_is_section_compressed (abfd, return_section))
+	{
+	  /* Compressed section.  Check if we should decompress.  */
+	  if ((abfd->flags & BFD_DECOMPRESS))
+	    action = decompress;
+	}
+      else if (!bfd_is_section_compressed (abfd, return_section))
+	{
+	  /* Normal section.  Check if we should compress.  */
+	  if ((abfd->flags & BFD_COMPRESS) && return_section->size != 0)
+	    action = compress;
+	}
+
+      switch (action)
+	{
+	case nothing:
+	  break;
+	case compress:
+	  if (!bfd_init_section_compress_status (abfd, return_section))
+	    {
+	      (*_bfd_error_handler)
+		(_("%B: unable to initialize compress status for section %s"),
+		 abfd, name);
+	      return FALSE;
+	    }
+	  if (name[1] != 'z')
+	    {
+	      unsigned int len = strlen (name);
+
+	      new_name = bfd_alloc (abfd, len + 2);
+	      if (new_name == NULL)
+		return FALSE;
+	      new_name[0] = '.';
+	      new_name[1] = 'z';
+	      memcpy (new_name + 2, name + 1, len);
+	    }
+	  break;
+	case decompress:
+	  if (!bfd_init_section_decompress_status (abfd, return_section))
+	    {
+	      (*_bfd_error_handler)
+		(_("%B: unable to initialize decompress status for section %s"),
+		 abfd, name);
+	      return FALSE;
+	    }
+	  if (name[1] == 'z')
+	    {
+	      unsigned int len = strlen (name);
+
+	      new_name = bfd_alloc (abfd, len);
+	      if (new_name == NULL)
+		return FALSE;
+	      new_name[0] = '.';
+	      memcpy (new_name + 1, name + 2, len - 1);
+	    }
+	  break;
+	}
+      if (new_name != NULL)
+	bfd_rename_section (abfd, return_section, new_name);
+    }
+
   return result;
 }
 
 /* Read in a COFF object and make it into a BFD.  This is used by
    ECOFF as well.  */
-
-static const bfd_target *
+const bfd_target *
+coff_real_object_p (bfd *,
+                    unsigned,
+                    struct internal_filehdr *,
+                    struct internal_aouthdr *);
+const bfd_target *
 coff_real_object_p (bfd *abfd,
 		    unsigned nscns,
 		    struct internal_filehdr *internal_f,
@@ -577,7 +651,7 @@
 		    struct internal_syment *syment)
 {
   /* Normalize the symbol flags.  */
-  if (coff_symbol_ptr->symbol.section 
+  if (coff_symbol_ptr->symbol.section
       && bfd_is_com_section (coff_symbol_ptr->symbol.section))
     {
       /* A common symbol is undefined with a value.  */
@@ -983,23 +1057,36 @@
    file originally.  This symbol may have been created by the linker,
    or we may be linking a non COFF file to a COFF file.  */
 
-static bfd_boolean
+bfd_boolean
 coff_write_alien_symbol (bfd *abfd,
 			 asymbol *symbol,
+			 struct internal_syment *isym,
 			 bfd_vma *written,
 			 bfd_size_type *string_size_p,
 			 asection **debug_string_section_p,
 			 bfd_size_type *debug_string_size_p)
 {
   combined_entry_type *native;
-  combined_entry_type dummy;
+  combined_entry_type dummy[2];
   asection *output_section = symbol->section->output_section
 			       ? symbol->section->output_section
 			       : symbol->section;
+  struct bfd_link_info *link_info = coff_data (abfd)->link_info;
+  bfd_boolean ret;
 
-  native = &dummy;
+  if ((!link_info || link_info->strip_discarded)
+      && !bfd_is_abs_section (symbol->section)
+      && symbol->section->output_section == bfd_abs_section_ptr)
+    {
+      symbol->name = "";
+      if (isym != NULL)
+        memset (isym, 0, sizeof(*isym));
+      return TRUE;
+    }
+  native = dummy;
   native->u.syment.n_type = T_NULL;
   native->u.syment.n_flags = 0;
+  native->u.syment.n_numaux = 0;
   if (bfd_is_und_section (symbol->section))
     {
       native->u.syment.n_scnum = N_UNDEF;
@@ -1010,6 +1097,11 @@
       native->u.syment.n_scnum = N_UNDEF;
       native->u.syment.n_value = symbol->value;
     }
+  else if (symbol->flags & BSF_FILE)
+    {
+      native->u.syment.n_scnum = N_DEBUG;
+      native->u.syment.n_numaux = 1;
+    }
   else if (symbol->flags & BSF_DEBUGGING)
     {
       /* There isn't much point to writing out a debugging symbol
@@ -1017,6 +1109,8 @@
          format.  So, we just ignore them.  We must clobber the symbol
          name to keep it from being put in the string table.  */
       symbol->name = "";
+      if (isym != NULL)
+        memset (isym, 0, sizeof(*isym));
       return TRUE;
     }
   else
@@ -1037,16 +1131,20 @@
     }
 
   native->u.syment.n_type = 0;
-  if (symbol->flags & BSF_LOCAL)
+  if (symbol->flags & BSF_FILE)
+    native->u.syment.n_sclass = C_FILE;
+  else if (symbol->flags & BSF_LOCAL)
     native->u.syment.n_sclass = C_STAT;
   else if (symbol->flags & BSF_WEAK)
     native->u.syment.n_sclass = obj_pe (abfd) ? C_NT_WEAK : C_WEAKEXT;
   else
     native->u.syment.n_sclass = C_EXT;
-  native->u.syment.n_numaux = 0;
 
-  return coff_write_symbol (abfd, symbol, native, written, string_size_p,
-			    debug_string_section_p, debug_string_size_p);
+  ret = coff_write_symbol (abfd, symbol, native, written, string_size_p,
+			   debug_string_section_p, debug_string_size_p);
+  if (isym != NULL)
+    *isym = native->u.syment;
+  return ret;
 }
 
 /* Write a native symbol to a COFF file.  */
@@ -1061,6 +1159,15 @@
 {
   combined_entry_type *native = symbol->native;
   alent *lineno = symbol->lineno;
+  struct bfd_link_info *link_info = coff_data (abfd)->link_info;
+
+  if ((!link_info || link_info->strip_discarded)
+      && !bfd_is_abs_section (symbol->symbol.section)
+      && symbol->symbol.section->output_section == bfd_abs_section_ptr)
+    {
+      symbol->symbol.name = "";
+      return TRUE;
+    }
 
   /* If this symbol has an associated line number, we must store the
      symbol index in the line number field.  We also tag the auxent to
@@ -1153,8 +1260,8 @@
       if (c_symbol == (coff_symbol_type *) NULL
 	  || c_symbol->native == (combined_entry_type *) NULL)
 	{
-	  if (!coff_write_alien_symbol (abfd, symbol, &written, &string_size,
-					&debug_string_section,
+	  if (!coff_write_alien_symbol (abfd, symbol, NULL, &written,
+					&string_size, &debug_string_section,
 					&debug_string_size))
 	    return FALSE;
 	}
@@ -1416,7 +1523,7 @@
   /* Otherwise patch up.  */
 #define N_TMASK coff_data  (abfd)->local_n_tmask
 #define N_BTSHFT coff_data (abfd)->local_n_btshft
-  
+
   if ((ISFCN (type) || ISTAG (n_sclass) || n_sclass == C_BLOCK
        || n_sclass == C_FCN)
       && auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l > 0)
@@ -1839,7 +1946,7 @@
   new_symbol->lineno = NULL;
   new_symbol->done_lineno = FALSE;
   new_symbol->symbol.the_bfd = abfd;
-  
+
   return & new_symbol->symbol;
 }
 
@@ -2085,13 +2192,14 @@
    nearest to the wanted location.  */
 
 bfd_boolean
-coff_find_nearest_line (bfd *abfd,
-			asection *section,
-			asymbol **symbols,
-			bfd_vma offset,
-			const char **filename_ptr,
-			const char **functionname_ptr,
-			unsigned int *line_ptr)
+coff_find_nearest_line_with_names (bfd *abfd,
+                                   const struct dwarf_debug_section *debug_sections,
+                                   asection *section,
+                                   asymbol **symbols,
+                                   bfd_vma offset,
+                                   const char **filename_ptr,
+                                   const char **functionname_ptr,
+                                   unsigned int *line_ptr)
 {
   bfd_boolean found;
   unsigned int i;
@@ -2116,7 +2224,8 @@
     return TRUE;
 
   /* Also try examining DWARF2 debugging information.  */
-  if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
+  if (_bfd_dwarf2_find_nearest_line (abfd, debug_sections,
+                                     section, symbols, offset,
 				     filename_ptr, functionname_ptr,
 				     line_ptr, NULL, 0,
 				     &coff_data(abfd)->dwarf2_find_line_info))
@@ -2299,6 +2408,39 @@
 }
 
 bfd_boolean
+coff_find_nearest_line (bfd *abfd,
+			asection *section,
+			asymbol **symbols,
+			bfd_vma offset,
+			const char **filename_ptr,
+			const char **functionname_ptr,
+			unsigned int *line_ptr)
+{
+  return coff_find_nearest_line_with_names (abfd, dwarf_debug_sections,
+                                            section, symbols, offset,
+                                            filename_ptr, functionname_ptr,
+                                            line_ptr);
+}
+
+bfd_boolean
+coff_find_nearest_line_discriminator (bfd *abfd,
+				      asection *section,
+				      asymbol **symbols,
+				      bfd_vma offset,
+				      const char **filename_ptr,
+				      const char **functionname_ptr,
+				      unsigned int *line_ptr,
+				      unsigned int *discriminator)
+{
+  *discriminator = 0;
+  return coff_find_nearest_line_with_names (abfd, dwarf_debug_sections,
+                                            section, symbols, offset,
+                                            filename_ptr, functionname_ptr,
+                                            line_ptr);
+}
+
+
+bfd_boolean
 coff_find_inliner_info (bfd *abfd,
 			const char **filename_ptr,
 			const char **functionname_ptr,
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index bca1364..948b4cd 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -605,7 +605,7 @@
 	{
 	  bfd_size_type string_offset = 0;
 	  asection *stab;
-	  
+
 	  for (stab = abfd->sections; stab; stab = stab->next)
 	    if (CONST_STRNEQ (stab->name, ".stab")
 		&& (!stab->name[5]
@@ -614,7 +614,7 @@
 	      struct coff_link_hash_table *table;
 	      struct coff_section_tdata *secdata
 		= coff_section_data (abfd, stab);
-	      
+
 	      if (secdata == NULL)
 		{
 		  amt = sizeof (struct coff_section_tdata);
@@ -651,7 +651,7 @@
 		      struct bfd_link_info *info)
 {
   bfd_size_type symesz;
-  struct coff_final_link_info finfo;
+  struct coff_final_link_info flaginfo;
   bfd_boolean debug_merge_allocated;
   bfd_boolean long_section_names;
   asection *o;
@@ -672,30 +672,30 @@
 
   symesz = bfd_coff_symesz (abfd);
 
-  finfo.info = info;
-  finfo.output_bfd = abfd;
-  finfo.strtab = NULL;
-  finfo.section_info = NULL;
-  finfo.last_file_index = -1;
-  finfo.last_bf_index = -1;
-  finfo.internal_syms = NULL;
-  finfo.sec_ptrs = NULL;
-  finfo.sym_indices = NULL;
-  finfo.outsyms = NULL;
-  finfo.linenos = NULL;
-  finfo.contents = NULL;
-  finfo.external_relocs = NULL;
-  finfo.internal_relocs = NULL;
-  finfo.global_to_static = FALSE;
+  flaginfo.info = info;
+  flaginfo.output_bfd = abfd;
+  flaginfo.strtab = NULL;
+  flaginfo.section_info = NULL;
+  flaginfo.last_file_index = -1;
+  flaginfo.last_bf_index = -1;
+  flaginfo.internal_syms = NULL;
+  flaginfo.sec_ptrs = NULL;
+  flaginfo.sym_indices = NULL;
+  flaginfo.outsyms = NULL;
+  flaginfo.linenos = NULL;
+  flaginfo.contents = NULL;
+  flaginfo.external_relocs = NULL;
+  flaginfo.internal_relocs = NULL;
+  flaginfo.global_to_static = FALSE;
   debug_merge_allocated = FALSE;
 
   coff_data (abfd)->link_info = info;
 
-  finfo.strtab = _bfd_stringtab_init ();
-  if (finfo.strtab == NULL)
+  flaginfo.strtab = _bfd_stringtab_init ();
+  if (flaginfo.strtab == NULL)
     goto error_return;
 
-  if (! coff_debug_merge_hash_table_init (&finfo.debug_merge))
+  if (! coff_debug_merge_hash_table_init (&flaginfo.debug_merge))
     goto error_return;
   debug_merge_allocated = TRUE;
 
@@ -775,7 +775,7 @@
              coff_write_object_contents which puts the string index
              into the s_name field of the section header.  That is why
              we pass hash as FALSE.  */
-	  if (_bfd_stringtab_add (finfo.strtab, o->name, FALSE, FALSE)
+	  if (_bfd_stringtab_add (flaginfo.strtab, o->name, FALSE, FALSE)
 	      == (bfd_size_type) -1)
 	    goto error_return;
 	  long_section_names = TRUE;
@@ -792,13 +792,13 @@
          the target_index fields are 1 based.  */
       amt = abfd->section_count + 1;
       amt *= sizeof (struct coff_link_section_info);
-      finfo.section_info = (struct coff_link_section_info *) bfd_malloc (amt);
-      if (finfo.section_info == NULL)
+      flaginfo.section_info = (struct coff_link_section_info *) bfd_malloc (amt);
+      if (flaginfo.section_info == NULL)
 	goto error_return;
       for (i = 0; i <= abfd->section_count; i++)
 	{
-	  finfo.section_info[i].relocs = NULL;
-	  finfo.section_info[i].rel_hashes = NULL;
+	  flaginfo.section_info[i].relocs = NULL;
+	  flaginfo.section_info[i].rel_hashes = NULL;
 	}
     }
 
@@ -835,14 +835,14 @@
 	  BFD_ASSERT (info->relocatable);
 	  amt = o->reloc_count;
 	  amt *= sizeof (struct internal_reloc);
-	  finfo.section_info[o->target_index].relocs =
+	  flaginfo.section_info[o->target_index].relocs =
               (struct internal_reloc *) bfd_malloc (amt);
 	  amt = o->reloc_count;
 	  amt *= sizeof (struct coff_link_hash_entry *);
-	  finfo.section_info[o->target_index].rel_hashes =
+	  flaginfo.section_info[o->target_index].rel_hashes =
               (struct coff_link_hash_entry **) bfd_malloc (amt);
-	  if (finfo.section_info[o->target_index].relocs == NULL
-	      || finfo.section_info[o->target_index].rel_hashes == NULL)
+	  if (flaginfo.section_info[o->target_index].relocs == NULL
+	      || flaginfo.section_info[o->target_index].rel_hashes == NULL)
 	    goto error_return;
 
 	  if (o->reloc_count > max_output_reloc_count)
@@ -866,38 +866,38 @@
       size_t sz;
 
       sub->output_has_begun = FALSE;
-      sz = obj_raw_syment_count (sub);
+      sz = bfd_family_coff (sub) ? obj_raw_syment_count (sub) : 2;
       if (sz > max_sym_count)
 	max_sym_count = sz;
     }
 
   /* Allocate some buffers used while linking.  */
   amt = max_sym_count * sizeof (struct internal_syment);
-  finfo.internal_syms = (struct internal_syment *) bfd_malloc (amt);
+  flaginfo.internal_syms = (struct internal_syment *) bfd_malloc (amt);
   amt = max_sym_count * sizeof (asection *);
-  finfo.sec_ptrs = (asection **) bfd_malloc (amt);
+  flaginfo.sec_ptrs = (asection **) bfd_malloc (amt);
   amt = max_sym_count * sizeof (long);
-  finfo.sym_indices = (long int *) bfd_malloc (amt);
-  finfo.outsyms = (bfd_byte *) bfd_malloc ((max_sym_count + 1) * symesz);
+  flaginfo.sym_indices = (long int *) bfd_malloc (amt);
+  flaginfo.outsyms = (bfd_byte *) bfd_malloc ((max_sym_count + 1) * symesz);
   amt = max_lineno_count * bfd_coff_linesz (abfd);
-  finfo.linenos = (bfd_byte *) bfd_malloc (amt);
-  finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
+  flaginfo.linenos = (bfd_byte *) bfd_malloc (amt);
+  flaginfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
   amt = max_reloc_count * relsz;
-  finfo.external_relocs = (bfd_byte *) bfd_malloc (amt);
+  flaginfo.external_relocs = (bfd_byte *) bfd_malloc (amt);
   if (! info->relocatable)
     {
       amt = max_reloc_count * sizeof (struct internal_reloc);
-      finfo.internal_relocs = (struct internal_reloc *) bfd_malloc (amt);
+      flaginfo.internal_relocs = (struct internal_reloc *) bfd_malloc (amt);
     }
-  if ((finfo.internal_syms == NULL && max_sym_count > 0)
-      || (finfo.sec_ptrs == NULL && max_sym_count > 0)
-      || (finfo.sym_indices == NULL && max_sym_count > 0)
-      || finfo.outsyms == NULL
-      || (finfo.linenos == NULL && max_lineno_count > 0)
-      || (finfo.contents == NULL && max_contents_size > 0)
-      || (finfo.external_relocs == NULL && max_reloc_count > 0)
+  if ((flaginfo.internal_syms == NULL && max_sym_count > 0)
+      || (flaginfo.sec_ptrs == NULL && max_sym_count > 0)
+      || (flaginfo.sym_indices == NULL && max_sym_count > 0)
+      || flaginfo.outsyms == NULL
+      || (flaginfo.linenos == NULL && max_lineno_count > 0)
+      || (flaginfo.contents == NULL && max_contents_size > 0)
+      || (flaginfo.external_relocs == NULL && max_reloc_count > 0)
       || (! info->relocatable
-	  && finfo.internal_relocs == NULL
+	  && flaginfo.internal_relocs == NULL
 	  && max_reloc_count > 0))
     goto error_return;
 
@@ -922,9 +922,9 @@
 	      && bfd_family_coff (p->u.indirect.section->owner))
 	    {
 	      sub = p->u.indirect.section->owner;
-	      if (! bfd_coff_link_output_has_begun (sub, & finfo))
+	      if (! bfd_coff_link_output_has_begun (sub, & flaginfo))
 		{
-		  if (! _bfd_coff_link_input_bfd (&finfo, sub))
+		  if (! _bfd_coff_link_input_bfd (&flaginfo, sub))
 		    goto error_return;
 		  sub->output_has_begun = TRUE;
 		}
@@ -932,7 +932,7 @@
 	  else if (p->type == bfd_section_reloc_link_order
 		   || p->type == bfd_symbol_reloc_link_order)
 	    {
-	      if (! _bfd_coff_reloc_link_order (abfd, &finfo, o, p))
+	      if (! _bfd_coff_reloc_link_order (abfd, &flaginfo, o, p))
 		goto error_return;
 	    }
 	  else
@@ -943,65 +943,151 @@
 	}
     }
 
-  if (! bfd_coff_final_link_postscript (abfd, & finfo))
+  if (flaginfo.info->strip != strip_all && flaginfo.info->discard != discard_all)
+    {
+      /* Add local symbols from foreign inputs.  */
+      for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+	{
+	  unsigned int i;
+
+	  if (bfd_family_coff (sub) || ! bfd_get_outsymbols (sub))
+	    continue;
+	  for (i = 0; i < bfd_get_symcount (sub); ++i)
+	    {
+	      asymbol *sym = bfd_get_outsymbols (sub) [i];
+	      file_ptr pos;
+	      struct internal_syment isym;
+	      bfd_size_type string_size = 0;
+	      bfd_vma written = 0;
+	      bfd_boolean rewrite = FALSE;
+
+	      if (! (sym->flags & BSF_LOCAL)
+		  || (sym->flags & (BSF_SECTION_SYM | BSF_DEBUGGING_RELOC
+				    | BSF_THREAD_LOCAL | BSF_RELC | BSF_SRELC
+				    | BSF_SYNTHETIC))
+		  || ((sym->flags & BSF_DEBUGGING)
+		      && ! (sym->flags & BSF_FILE)))
+		continue;
+
+	      /* See if we are discarding symbols with this name.  */
+	      if ((flaginfo.info->strip == strip_some
+		   && (bfd_hash_lookup (flaginfo.info->keep_hash,
+					bfd_asymbol_name(sym), FALSE, FALSE)
+		       == NULL))
+		  || (((flaginfo.info->discard == discard_sec_merge
+			&& (bfd_get_section (sym)->flags & SEC_MERGE)
+			&& ! flaginfo.info->relocatable)
+		       || flaginfo.info->discard == discard_l)
+		      && bfd_is_local_label_name (sub, bfd_asymbol_name(sym))))
+		continue;
+
+	      pos = obj_sym_filepos (abfd) + obj_raw_syment_count (abfd)
+					     * symesz;
+	      if (bfd_seek (abfd, pos, SEEK_SET) != 0)
+		goto error_return;
+	      if (! coff_write_alien_symbol(abfd, sym, &isym, &written,
+					    &string_size, NULL, NULL))
+		goto error_return;
+
+	      if (string_size)
+		{
+		  bfd_boolean hash = ! (abfd->flags & BFD_TRADITIONAL_FORMAT);
+		  bfd_size_type indx;
+
+		  indx = _bfd_stringtab_add (flaginfo.strtab,
+					     bfd_asymbol_name (sym), hash,
+					     FALSE);
+		  if (indx == (bfd_size_type) -1)
+		    goto error_return;
+		  isym._n._n_n._n_offset = STRING_SIZE_SIZE + indx;
+		  bfd_coff_swap_sym_out (abfd, &isym, flaginfo.outsyms);
+		  rewrite = TRUE;
+		}
+
+	      if (isym.n_sclass == C_FILE)
+		{
+		  if (flaginfo.last_file_index != -1)
+		    {
+		      flaginfo.last_file.n_value = obj_raw_syment_count (abfd);
+		      bfd_coff_swap_sym_out (abfd, &flaginfo.last_file,
+					     flaginfo.outsyms);
+		      pos = obj_sym_filepos (abfd) + flaginfo.last_file_index
+						     * symesz;
+		      rewrite = TRUE;
+		    }
+		  flaginfo.last_file_index = obj_raw_syment_count (abfd);
+		  flaginfo.last_file = isym;
+		}
+
+	      if (rewrite
+		  && (bfd_seek (abfd, pos, SEEK_SET) != 0
+		      || bfd_bwrite (flaginfo.outsyms, symesz, abfd) != symesz))
+		goto error_return;
+
+	      obj_raw_syment_count (abfd) += written;
+	    }
+	}
+    }
+
+  if (! bfd_coff_final_link_postscript (abfd, & flaginfo))
     goto error_return;
 
   /* Free up the buffers used by _bfd_coff_link_input_bfd.  */
 
-  coff_debug_merge_hash_table_free (&finfo.debug_merge);
+  coff_debug_merge_hash_table_free (&flaginfo.debug_merge);
   debug_merge_allocated = FALSE;
 
-  if (finfo.internal_syms != NULL)
+  if (flaginfo.internal_syms != NULL)
     {
-      free (finfo.internal_syms);
-      finfo.internal_syms = NULL;
+      free (flaginfo.internal_syms);
+      flaginfo.internal_syms = NULL;
     }
-  if (finfo.sec_ptrs != NULL)
+  if (flaginfo.sec_ptrs != NULL)
     {
-      free (finfo.sec_ptrs);
-      finfo.sec_ptrs = NULL;
+      free (flaginfo.sec_ptrs);
+      flaginfo.sec_ptrs = NULL;
     }
-  if (finfo.sym_indices != NULL)
+  if (flaginfo.sym_indices != NULL)
     {
-      free (finfo.sym_indices);
-      finfo.sym_indices = NULL;
+      free (flaginfo.sym_indices);
+      flaginfo.sym_indices = NULL;
     }
-  if (finfo.linenos != NULL)
+  if (flaginfo.linenos != NULL)
     {
-      free (finfo.linenos);
-      finfo.linenos = NULL;
+      free (flaginfo.linenos);
+      flaginfo.linenos = NULL;
     }
-  if (finfo.contents != NULL)
+  if (flaginfo.contents != NULL)
     {
-      free (finfo.contents);
-      finfo.contents = NULL;
+      free (flaginfo.contents);
+      flaginfo.contents = NULL;
     }
-  if (finfo.external_relocs != NULL)
+  if (flaginfo.external_relocs != NULL)
     {
-      free (finfo.external_relocs);
-      finfo.external_relocs = NULL;
+      free (flaginfo.external_relocs);
+      flaginfo.external_relocs = NULL;
     }
-  if (finfo.internal_relocs != NULL)
+  if (flaginfo.internal_relocs != NULL)
     {
-      free (finfo.internal_relocs);
-      finfo.internal_relocs = NULL;
+      free (flaginfo.internal_relocs);
+      flaginfo.internal_relocs = NULL;
     }
 
   /* The value of the last C_FILE symbol is supposed to be the symbol
      index of the first external symbol.  Write it out again if
      necessary.  */
-  if (finfo.last_file_index != -1
-      && (unsigned int) finfo.last_file.n_value != obj_raw_syment_count (abfd))
+  if (flaginfo.last_file_index != -1
+      && (unsigned int) flaginfo.last_file.n_value != obj_raw_syment_count (abfd))
     {
       file_ptr pos;
 
-      finfo.last_file.n_value = obj_raw_syment_count (abfd);
-      bfd_coff_swap_sym_out (abfd, &finfo.last_file,
-			     finfo.outsyms);
+      flaginfo.last_file.n_value = obj_raw_syment_count (abfd);
+      bfd_coff_swap_sym_out (abfd, &flaginfo.last_file,
+			     flaginfo.outsyms);
 
-      pos = obj_sym_filepos (abfd) + finfo.last_file_index * symesz;
+      pos = obj_sym_filepos (abfd) + flaginfo.last_file_index * symesz;
       if (bfd_seek (abfd, pos, SEEK_SET) != 0
-	  || bfd_bwrite (finfo.outsyms, symesz, abfd) != symesz)
+	  || bfd_bwrite (flaginfo.outsyms, symesz, abfd) != symesz)
 	return FALSE;
     }
 
@@ -1010,24 +1096,24 @@
      static.  */
   if (info->task_link)
     {
-      finfo.failed = FALSE;
+      flaginfo.failed = FALSE;
       coff_link_hash_traverse (coff_hash_table (info),
-			       _bfd_coff_write_task_globals, &finfo);
-      if (finfo.failed)
+			       _bfd_coff_write_task_globals, &flaginfo);
+      if (flaginfo.failed)
 	goto error_return;
     }
 
   /* Write out the global symbols.  */
-  finfo.failed = FALSE;
-  bfd_hash_traverse (&info->hash->table, _bfd_coff_write_global_sym, &finfo);
-  if (finfo.failed)
+  flaginfo.failed = FALSE;
+  bfd_hash_traverse (&info->hash->table, _bfd_coff_write_global_sym, &flaginfo);
+  if (flaginfo.failed)
     goto error_return;
 
   /* The outsyms buffer is used by _bfd_coff_write_global_sym.  */
-  if (finfo.outsyms != NULL)
+  if (flaginfo.outsyms != NULL)
     {
-      free (finfo.outsyms);
-      finfo.outsyms = NULL;
+      free (flaginfo.outsyms);
+      flaginfo.outsyms = NULL;
     }
 
   if (info->relocatable && max_output_reloc_count > 0)
@@ -1050,9 +1136,9 @@
 	  if (o->reloc_count == 0)
 	    continue;
 
-	  irel = finfo.section_info[o->target_index].relocs;
+	  irel = flaginfo.section_info[o->target_index].relocs;
 	  irelend = irel + o->reloc_count;
-	  rel_hash = finfo.section_info[o->target_index].rel_hashes;
+	  rel_hash = flaginfo.section_info[o->target_index].rel_hashes;
 	  erel = external_relocs;
 	  for (; irel < irelend; irel++, rel_hash++, erel += relsz)
 	    {
@@ -1073,10 +1159,10 @@
 		 elsewhere. */
 	      struct internal_reloc incount;
 	      bfd_byte *excount = (bfd_byte *)bfd_malloc (relsz);
-	      
+
 	      memset (&incount, 0, sizeof (incount));
 	      incount.r_vaddr = o->reloc_count + 1;
-	      bfd_coff_swap_reloc_out (abfd, (PTR) &incount, (PTR) excount);
+	      bfd_coff_swap_reloc_out (abfd, &incount, excount);
 	      if (bfd_bwrite (excount, relsz, abfd) != relsz)
 		/* We'll leak, but it's an error anyway. */
 		goto error_return;
@@ -1093,19 +1179,19 @@
     }
 
   /* Free up the section information.  */
-  if (finfo.section_info != NULL)
+  if (flaginfo.section_info != NULL)
     {
       unsigned int i;
 
       for (i = 0; i < abfd->section_count; i++)
 	{
-	  if (finfo.section_info[i].relocs != NULL)
-	    free (finfo.section_info[i].relocs);
-	  if (finfo.section_info[i].rel_hashes != NULL)
-	    free (finfo.section_info[i].rel_hashes);
+	  if (flaginfo.section_info[i].relocs != NULL)
+	    free (flaginfo.section_info[i].relocs);
+	  if (flaginfo.section_info[i].rel_hashes != NULL)
+	    free (flaginfo.section_info[i].rel_hashes);
 	}
-      free (finfo.section_info);
-      finfo.section_info = NULL;
+      free (flaginfo.section_info);
+      flaginfo.section_info = NULL;
     }
 
   /* If we have optimized stabs strings, output them.  */
@@ -1126,7 +1212,7 @@
 
 #if STRING_SIZE_SIZE == 4
       H_PUT_32 (abfd,
-		_bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
+		_bfd_stringtab_size (flaginfo.strtab) + STRING_SIZE_SIZE,
 		strbuf);
 #else
  #error Change H_PUT_32 above
@@ -1136,13 +1222,13 @@
 	  != STRING_SIZE_SIZE)
 	return FALSE;
 
-      if (! _bfd_stringtab_emit (abfd, finfo.strtab))
+      if (! _bfd_stringtab_emit (abfd, flaginfo.strtab))
 	return FALSE;
 
       obj_coff_strings_written (abfd) = TRUE;
     }
 
-  _bfd_stringtab_free (finfo.strtab);
+  _bfd_stringtab_free (flaginfo.strtab);
 
   /* Setting bfd_get_symcount to 0 will cause write_object_contents to
      not try to write out the symbols.  */
@@ -1152,38 +1238,38 @@
 
  error_return:
   if (debug_merge_allocated)
-    coff_debug_merge_hash_table_free (&finfo.debug_merge);
-  if (finfo.strtab != NULL)
-    _bfd_stringtab_free (finfo.strtab);
-  if (finfo.section_info != NULL)
+    coff_debug_merge_hash_table_free (&flaginfo.debug_merge);
+  if (flaginfo.strtab != NULL)
+    _bfd_stringtab_free (flaginfo.strtab);
+  if (flaginfo.section_info != NULL)
     {
       unsigned int i;
 
       for (i = 0; i < abfd->section_count; i++)
 	{
-	  if (finfo.section_info[i].relocs != NULL)
-	    free (finfo.section_info[i].relocs);
-	  if (finfo.section_info[i].rel_hashes != NULL)
-	    free (finfo.section_info[i].rel_hashes);
+	  if (flaginfo.section_info[i].relocs != NULL)
+	    free (flaginfo.section_info[i].relocs);
+	  if (flaginfo.section_info[i].rel_hashes != NULL)
+	    free (flaginfo.section_info[i].rel_hashes);
 	}
-      free (finfo.section_info);
+      free (flaginfo.section_info);
     }
-  if (finfo.internal_syms != NULL)
-    free (finfo.internal_syms);
-  if (finfo.sec_ptrs != NULL)
-    free (finfo.sec_ptrs);
-  if (finfo.sym_indices != NULL)
-    free (finfo.sym_indices);
-  if (finfo.outsyms != NULL)
-    free (finfo.outsyms);
-  if (finfo.linenos != NULL)
-    free (finfo.linenos);
-  if (finfo.contents != NULL)
-    free (finfo.contents);
-  if (finfo.external_relocs != NULL)
-    free (finfo.external_relocs);
-  if (finfo.internal_relocs != NULL)
-    free (finfo.internal_relocs);
+  if (flaginfo.internal_syms != NULL)
+    free (flaginfo.internal_syms);
+  if (flaginfo.sec_ptrs != NULL)
+    free (flaginfo.sec_ptrs);
+  if (flaginfo.sym_indices != NULL)
+    free (flaginfo.sym_indices);
+  if (flaginfo.outsyms != NULL)
+    free (flaginfo.outsyms);
+  if (flaginfo.linenos != NULL)
+    free (flaginfo.linenos);
+  if (flaginfo.contents != NULL)
+    free (flaginfo.contents);
+  if (flaginfo.external_relocs != NULL)
+    free (flaginfo.external_relocs);
+  if (flaginfo.internal_relocs != NULL)
+    free (flaginfo.internal_relocs);
   if (external_relocs != NULL)
     free (external_relocs);
   return FALSE;
@@ -1325,7 +1411,7 @@
    that symbol.  */
 
 static void
-mark_relocs (struct coff_final_link_info *finfo, bfd *input_bfd)
+mark_relocs (struct coff_final_link_info *flaginfo, bfd *input_bfd)
 {
   asection * a;
 
@@ -1338,7 +1424,8 @@
       struct internal_reloc *	irel;
       struct internal_reloc *	irelend;
 
-      if ((a->flags & SEC_RELOC) == 0 || a->reloc_count  < 1)
+      if ((a->flags & SEC_RELOC) == 0 || a->reloc_count  < 1
+	  || a->linker_mark == 0)
 	continue;
       /* Don't mark relocs in excluded sections.  */
       if (a->output_section == bfd_abs_section_ptr)
@@ -1347,11 +1434,11 @@
       /* Read in the relocs.  */
       internal_relocs = _bfd_coff_read_internal_relocs
 	(input_bfd, a, FALSE,
-	 finfo->external_relocs,
-	 finfo->info->relocatable,
-	 (finfo->info->relocatable
-	  ? (finfo->section_info[ a->output_section->target_index ].relocs + a->output_section->reloc_count)
-	  : finfo->internal_relocs)
+	 flaginfo->external_relocs,
+	 flaginfo->info->relocatable,
+	 (flaginfo->info->relocatable
+	  ? (flaginfo->section_info[ a->output_section->target_index ].relocs + a->output_section->reloc_count)
+	  : flaginfo->internal_relocs)
 	);
 
       if (internal_relocs == NULL)
@@ -1365,7 +1452,7 @@
 	 in the relocation table.  This will then be picked up in the
 	 skip/don't-skip pass.  */
       for (; irel < irelend; irel++)
-	finfo->sym_indices[ irel->r_symndx ] = -1;
+	flaginfo->sym_indices[ irel->r_symndx ] = -1;
     }
 }
 
@@ -1373,7 +1460,7 @@
    handles all the sections and relocations of the input file at once.  */
 
 bfd_boolean
-_bfd_coff_link_input_bfd (struct coff_final_link_info *finfo, bfd *input_bfd)
+_bfd_coff_link_input_bfd (struct coff_final_link_info *flaginfo, bfd *input_bfd)
 {
   unsigned int n_tmask = coff_data (input_bfd)->local_n_tmask;
   unsigned int n_btshft = coff_data (input_bfd)->local_n_btshft;
@@ -1399,7 +1486,7 @@
 
   /* Move all the symbols to the output file.  */
 
-  output_bfd = finfo->output_bfd;
+  output_bfd = flaginfo->output_bfd;
   strings = NULL;
   syment_base = obj_raw_syment_count (output_bfd);
   isymesz = bfd_coff_symesz (input_bfd);
@@ -1408,7 +1495,7 @@
   BFD_ASSERT (linesz == bfd_coff_linesz (output_bfd));
 
   copy = FALSE;
-  if (! finfo->info->keep_memory)
+  if (! flaginfo->info->keep_memory)
     copy = TRUE;
   hash = TRUE;
   if ((output_bfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
@@ -1419,27 +1506,27 @@
 
   esym = (bfd_byte *) obj_coff_external_syms (input_bfd);
   esym_end = esym + obj_raw_syment_count (input_bfd) * isymesz;
-  isymp = finfo->internal_syms;
-  secpp = finfo->sec_ptrs;
-  indexp = finfo->sym_indices;
+  isymp = flaginfo->internal_syms;
+  secpp = flaginfo->sec_ptrs;
+  indexp = flaginfo->sym_indices;
   output_index = syment_base;
-  outsym = finfo->outsyms;
+  outsym = flaginfo->outsyms;
 
   if (coff_data (output_bfd)->pe
-      && ! process_embedded_commands (output_bfd, finfo->info, input_bfd))
+      && ! process_embedded_commands (output_bfd, flaginfo->info, input_bfd))
     return FALSE;
 
   /* If we are going to perform relocations and also strip/discard some
      symbols then we must make sure that we do not strip/discard those
      symbols that are going to be involved in the relocations.  */
-  if ((   finfo->info->strip   != strip_none
-       || finfo->info->discard != discard_none)
-      && finfo->info->relocatable)
+  if ((   flaginfo->info->strip   != strip_none
+       || flaginfo->info->discard != discard_none)
+      && flaginfo->info->relocatable)
     {
       /* Mark the symbol array as 'not-used'.  */
       memset (indexp, 0, obj_raw_syment_count (input_bfd) * sizeof * indexp);
 
-      mark_relocs (finfo, input_bfd);
+      mark_relocs (flaginfo, input_bfd);
     }
 
   while (esym < esym_end)
@@ -1479,9 +1566,9 @@
 
       /* Extract the flag indicating if this symbol is used by a
          relocation.  */
-      if ((finfo->info->strip != strip_none
-	   || finfo->info->discard != discard_none)
-	  && finfo->info->relocatable)
+      if ((flaginfo->info->strip != strip_none
+	   || flaginfo->info->discard != discard_none)
+	  && flaginfo->info->relocatable)
 	dont_skip_symbol = *indexp;
       else
 	dont_skip_symbol = FALSE;
@@ -1493,7 +1580,7 @@
       add = 1 + isym.n_numaux;
 
       /* If we are stripping all symbols, we want to skip this one.  */
-      if (finfo->info->strip == strip_all && ! dont_skip_symbol)
+      if (flaginfo->info->strip == strip_all && ! dont_skip_symbol)
 	skip = TRUE;
 
       if (! skip)
@@ -1523,7 +1610,7 @@
 	    case COFF_SYMBOL_LOCAL:
 	      /* This is a local symbol.  Skip it if we are discarding
                  local symbols.  */
-	      if (finfo->info->discard == discard_all && ! dont_skip_symbol)
+	      if (flaginfo->info->discard == discard_all && ! dont_skip_symbol)
 		skip = TRUE;
 	      break;
 	    }
@@ -1548,7 +1635,7 @@
          for some types of debugging symbols; I don't know if this is
          a bug or not.  In any case, we handle it here.  */
       if (! skip
-	  && finfo->info->strip == strip_debugger
+	  && flaginfo->info->strip == strip_debugger
 	  && ! dont_skip_symbol
 	  && (isym.n_scnum == N_DEBUG
 	      || (isym.n_scnum == N_ABS
@@ -1566,8 +1653,8 @@
       /* If some symbols are stripped based on the name, work out the
 	 name and decide whether to skip this symbol.  */
       if (! skip
-	  && (finfo->info->strip == strip_some
-	      || finfo->info->discard == discard_l))
+	  && (flaginfo->info->strip == strip_some
+	      || flaginfo->info->discard == discard_l))
 	{
 	  const char *name;
 	  char buf[SYMNMLEN + 1];
@@ -1577,11 +1664,11 @@
 	    return FALSE;
 
 	  if (! dont_skip_symbol
-	      && ((finfo->info->strip == strip_some
-		   && (bfd_hash_lookup (finfo->info->keep_hash, name, FALSE,
+	      && ((flaginfo->info->strip == strip_some
+		   && (bfd_hash_lookup (flaginfo->info->keep_hash, name, FALSE,
 				    FALSE) == NULL))
 		   || (! global
-		       && finfo->info->discard == discard_l
+		       && flaginfo->info->discard == discard_l
 		       && bfd_is_local_label_name (input_bfd, name))))
 	    skip = TRUE;
 	}
@@ -1589,7 +1676,7 @@
       /* If this is an enum, struct, or union tag, see if we have
          already output an identical type.  */
       if (! skip
-	  && (finfo->output_bfd->flags & BFD_TRADITIONAL_FORMAT) == 0
+	  && (flaginfo->output_bfd->flags & BFD_TRADITIONAL_FORMAT) == 0
 	  && (isym.n_sclass == C_ENTAG
 	      || isym.n_sclass == C_STRTAG
 	      || isym.n_sclass == C_UNTAG)
@@ -1616,7 +1703,7 @@
 		  && (name[1] == '~' || name[1] == '.' || name[1] == '$')))
 	    name = "";
 
-	  mh = coff_debug_merge_hash_lookup (&finfo->debug_merge, name,
+	  mh = coff_debug_merge_hash_lookup (&flaginfo->debug_merge, name,
 					     TRUE, TRUE);
 	  if (mh == NULL)
 	    return FALSE;
@@ -1693,7 +1780,7 @@
 			      (bfd_byte *) obj_coff_external_syms (input_bfd))
 			     / (long) isymesz)))
 		    {
-		      (*epp)->tagndx = finfo->sym_indices[indx];
+		      (*epp)->tagndx = flaginfo->sym_indices[indx];
 		      if ((*epp)->tagndx < 0)
 			(*epp)->tagndx = 0;
 		    }
@@ -1772,7 +1859,7 @@
 	      name = _bfd_coff_internal_syment_name (input_bfd, &isym, NULL);
 	      if (name == NULL)
 		return FALSE;
-	      indx = _bfd_stringtab_add (finfo->strtab, name, hash, copy);
+	      indx = _bfd_stringtab_add (flaginfo->strtab, name, hash, copy);
 	      if (indx == (bfd_size_type) -1)
 		return FALSE;
 	      isym._n._n_n._n_offset = STRING_SIZE_SIZE + indx;
@@ -1827,7 +1914,7 @@
 		isym.n_value += (*secpp)->output_offset;
 		if (! obj_pe (input_bfd))
 		  isym.n_value -= (*secpp)->vma;
-		if (! obj_pe (finfo->output_bfd))
+		if (! obj_pe (flaginfo->output_bfd))
 		  isym.n_value += (*secpp)->output_section->vma;
 	      }
 	    break;
@@ -1842,19 +1929,19 @@
 		 it).  We try to get this right, below, just before we
 		 write the symbols out, but in the general case we may
 		 have to write the symbol out twice.  */
-	      if (finfo->last_file_index != -1
-		  && finfo->last_file.n_value != (bfd_vma) output_index)
+	      if (flaginfo->last_file_index != -1
+		  && flaginfo->last_file.n_value != (bfd_vma) output_index)
 		{
 		  /* We must correct the value of the last C_FILE
                      entry.  */
-		  finfo->last_file.n_value = output_index;
-		  if ((bfd_size_type) finfo->last_file_index >= syment_base)
+		  flaginfo->last_file.n_value = output_index;
+		  if ((bfd_size_type) flaginfo->last_file_index >= syment_base)
 		    {
 		      /* The last C_FILE symbol is in this input file.  */
 		      bfd_coff_swap_sym_out (output_bfd,
-					     &finfo->last_file,
-					     (finfo->outsyms
-					      + ((finfo->last_file_index
+					     &flaginfo->last_file,
+					     (flaginfo->outsyms
+					      + ((flaginfo->last_file_index
 						  - syment_base)
 						 * osymesz)));
 		    }
@@ -1866,23 +1953,23 @@
 			 symbol.  We need to write it out again.  We
 			 borrow *outsym temporarily.  */
 		      bfd_coff_swap_sym_out (output_bfd,
-					     &finfo->last_file, outsym);
+					     &flaginfo->last_file, outsym);
 		      pos = obj_sym_filepos (output_bfd);
-		      pos += finfo->last_file_index * osymesz;
+		      pos += flaginfo->last_file_index * osymesz;
 		      if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
 			  || bfd_bwrite (outsym, osymesz, output_bfd) != osymesz)
 			return FALSE;
 		    }
 		}
 
-	      finfo->last_file_index = output_index;
-	      finfo->last_file = isym;
+	      flaginfo->last_file_index = output_index;
+	      flaginfo->last_file = isym;
 	      break;
 	    }
 
 	  /* If doing task linking, convert normal global function symbols to
 	     static functions.  */
-	  if (finfo->info->task_link && IS_EXTERNAL (input_bfd, isym))
+	  if (flaginfo->info->task_link && IS_EXTERNAL (input_bfd, isym))
 	    isym.n_sclass = C_STAT;
 
 	  /* Output the symbol.  */
@@ -1928,10 +2015,10 @@
      already decided which symbols we are going to keep.  */
   esym = (bfd_byte *) obj_coff_external_syms (input_bfd);
   esym_end = esym + obj_raw_syment_count (input_bfd) * isymesz;
-  isymp = finfo->internal_syms;
-  indexp = finfo->sym_indices;
+  isymp = flaginfo->internal_syms;
+  indexp = flaginfo->sym_indices;
   sym_hash = obj_coff_sym_hashes (input_bfd);
-  outsym = finfo->outsyms;
+  outsym = flaginfo->outsyms;
 
   while (esym < esym_end)
     {
@@ -2002,7 +2089,7 @@
 			    return FALSE;
 			}
 		      filename = strings + auxp->x_file.x_n.x_offset;
-		      indx = _bfd_stringtab_add (finfo->strtab, filename,
+		      indx = _bfd_stringtab_add (flaginfo->strtab, filename,
 						 hash, copy);
 		      if (indx == (bfd_size_type) -1)
 			return FALSE;
@@ -2027,15 +2114,15 @@
                              the index of the next symbol we are going
                              to include.  I don't know if this is
                              entirely right.  */
-			  while ((finfo->sym_indices[indx] < 0
-				  || ((bfd_size_type) finfo->sym_indices[indx]
+			  while ((flaginfo->sym_indices[indx] < 0
+				  || ((bfd_size_type) flaginfo->sym_indices[indx]
 				      < syment_base))
 				 && indx < obj_raw_syment_count (input_bfd))
 			    ++indx;
 			  if (indx >= obj_raw_syment_count (input_bfd))
 			    indx = output_index;
 			  else
-			    indx = finfo->sym_indices[indx];
+			    indx = flaginfo->sym_indices[indx];
 			  auxp->x_sym.x_fcnary.x_fcn.x_endndx.l = indx;
 			}
 		    }
@@ -2045,7 +2132,7 @@
 		    {
 		      long symindx;
 
-		      symindx = finfo->sym_indices[indx];
+		      symindx = flaginfo->sym_indices[indx];
 		      if (symindx < 0)
 			auxp->x_sym.x_tagndx.l = 0;
 		      else
@@ -2065,12 +2152,12 @@
 		      && isymp->_n._n_name[2] == 'f'
 		      && isymp->_n._n_name[3] == '\0')
 		    {
-		      if (finfo->last_bf_index != -1)
+		      if (flaginfo->last_bf_index != -1)
 			{
-			  finfo->last_bf.x_sym.x_fcnary.x_fcn.x_endndx.l =
+			  flaginfo->last_bf.x_sym.x_fcnary.x_fcn.x_endndx.l =
 			    *indexp;
 
-			  if ((bfd_size_type) finfo->last_bf_index
+			  if ((bfd_size_type) flaginfo->last_bf_index
 			      >= syment_base)
 			    {
 			      void *auxout;
@@ -2079,13 +2166,13 @@
 				 file.  This will only happen if the
 				 assembler did not set up the .bf
 				 endndx symbols correctly.  */
-			      auxout = (finfo->outsyms
-					+ ((finfo->last_bf_index
+			      auxout = (flaginfo->outsyms
+					+ ((flaginfo->last_bf_index
 					    - syment_base)
 					   * osymesz));
 
 			      bfd_coff_swap_aux_out (output_bfd,
-						     &finfo->last_bf,
+						     &flaginfo->last_bf,
 						     isymp->n_type,
 						     isymp->n_sclass,
 						     0, isymp->n_numaux,
@@ -2101,13 +2188,13 @@
                                  temporarily.  FIXME: This case should
                                  be made faster.  */
 			      bfd_coff_swap_aux_out (output_bfd,
-						     &finfo->last_bf,
+						     &flaginfo->last_bf,
 						     isymp->n_type,
 						     isymp->n_sclass,
 						     0, isymp->n_numaux,
 						     outsym);
 			      pos = obj_sym_filepos (output_bfd);
-			      pos += finfo->last_bf_index * osymesz;
+			      pos += flaginfo->last_bf_index * osymesz;
 			      if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
 				  || (bfd_bwrite (outsym, osymesz, output_bfd)
 				      != osymesz))
@@ -2116,14 +2203,14 @@
 			}
 
 		      if (auxp->x_sym.x_fcnary.x_fcn.x_endndx.l != 0)
-			finfo->last_bf_index = -1;
+			flaginfo->last_bf_index = -1;
 		      else
 			{
 			  /* The endndx field of this aux entry must
                              be updated with the symbol number of the
                              next .bf symbol.  */
-			  finfo->last_bf = *auxp;
-			  finfo->last_bf_index = (((outsym - finfo->outsyms)
+			  flaginfo->last_bf = *auxp;
+			  flaginfo->last_bf_index = (((outsym - flaginfo->outsyms)
 						   / osymesz)
 						  + syment_base);
 			}
@@ -2148,8 +2235,8 @@
     }
 
   /* Relocate the line numbers, unless we are stripping them.  */
-  if (finfo->info->strip == strip_none
-      || finfo->info->strip == strip_some)
+  if (flaginfo->info->strip == strip_none
+      || flaginfo->info->strip == strip_some)
     {
       for (o = input_bfd->sections; o != NULL; o = o->next)
 	{
@@ -2175,13 +2262,13 @@
 	    continue;
 
 	  if (bfd_seek (input_bfd, o->line_filepos, SEEK_SET) != 0
-	      || bfd_bread (finfo->linenos, linesz * o->lineno_count,
+	      || bfd_bread (flaginfo->linenos, linesz * o->lineno_count,
 			   input_bfd) != linesz * o->lineno_count)
 	    return FALSE;
 
 	  offset = o->output_section->vma + o->output_offset - o->vma;
-	  eline = finfo->linenos;
-	  oeline = finfo->linenos;
+	  eline = flaginfo->linenos;
+	  oeline = flaginfo->linenos;
 	  elineend = eline + linesz * o->lineno_count;
 	  skipping = FALSE;
 	  for (; eline < elineend; eline += linesz)
@@ -2198,7 +2285,7 @@
 		{
 		  long indx;
 
-		  indx = finfo->sym_indices[iline.l_addr.l_symndx];
+		  indx = flaginfo->sym_indices[iline.l_addr.l_symndx];
 
 		  if (indx < 0)
 		    {
@@ -2224,7 +2311,7 @@
 			 of the line numbers rather than an absolute
 			 file index.  */
 		      bfd_coff_swap_sym_in (output_bfd,
-					    (finfo->outsyms
+					    (flaginfo->outsyms
 					     + ((indx - syment_base)
 						* osymesz)), &is);
 		      if ((ISFCN (is.n_type)
@@ -2233,7 +2320,7 @@
 			{
 			  void *auxptr;
 
-			  auxptr = (finfo->outsyms
+			  auxptr = (flaginfo->outsyms
 				    + ((indx - syment_base + 1)
 				       * osymesz));
 			  bfd_coff_swap_aux_in (output_bfd, auxptr,
@@ -2242,7 +2329,7 @@
 			  ia.x_sym.x_fcnary.x_fcn.x_lnnoptr =
 			    (o->output_section->line_filepos
 			     + o->output_section->lineno_count * linesz
-			     + eline - finfo->linenos);
+			     + eline - flaginfo->linenos);
 			  bfd_coff_swap_aux_out (output_bfd, &ia,
 						 is.n_type, is.n_sclass, 0,
 						 is.n_numaux, auxptr);
@@ -2263,9 +2350,9 @@
 
 	  pos = o->output_section->line_filepos;
 	  pos += o->output_section->lineno_count * linesz;
-	  amt = oeline - finfo->linenos;
+	  amt = oeline - flaginfo->linenos;
 	  if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
-	      || bfd_bwrite (finfo->linenos, amt, output_bfd) != amt)
+	      || bfd_bwrite (flaginfo->linenos, amt, output_bfd) != amt)
 	    return FALSE;
 
 	  o->output_section->lineno_count += amt / linesz;
@@ -2276,30 +2363,30 @@
      symbol will be the first symbol in the next input file.  In the
      normal case, this will save us from writing out the C_FILE symbol
      again.  */
-  if (finfo->last_file_index != -1
-      && (bfd_size_type) finfo->last_file_index >= syment_base)
+  if (flaginfo->last_file_index != -1
+      && (bfd_size_type) flaginfo->last_file_index >= syment_base)
     {
-      finfo->last_file.n_value = output_index;
-      bfd_coff_swap_sym_out (output_bfd, &finfo->last_file,
-			     (finfo->outsyms
-			      + ((finfo->last_file_index - syment_base)
+      flaginfo->last_file.n_value = output_index;
+      bfd_coff_swap_sym_out (output_bfd, &flaginfo->last_file,
+			     (flaginfo->outsyms
+			      + ((flaginfo->last_file_index - syment_base)
 				 * osymesz)));
     }
 
   /* Write the modified symbols to the output file.  */
-  if (outsym > finfo->outsyms)
+  if (outsym > flaginfo->outsyms)
     {
       file_ptr pos;
       bfd_size_type amt;
 
       pos = obj_sym_filepos (output_bfd) + syment_base * osymesz;
-      amt = outsym - finfo->outsyms;
+      amt = outsym - flaginfo->outsyms;
       if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
-	  || bfd_bwrite (finfo->outsyms, amt, output_bfd) != amt)
+	  || bfd_bwrite (flaginfo->outsyms, amt, output_bfd) != amt)
 	return FALSE;
 
       BFD_ASSERT ((obj_raw_syment_count (output_bfd)
-		   + (outsym - finfo->outsyms) / osymesz)
+		   + (outsym - flaginfo->outsyms) / osymesz)
 		  == output_index);
 
       obj_raw_syment_count (output_bfd) = output_index;
@@ -2340,10 +2427,9 @@
 	contents = secdata->contents;
       else
 	{
-	  bfd_size_type x = o->rawsize ? o->rawsize : o->size;
-	  if (! bfd_get_section_contents (input_bfd, o, finfo->contents, 0, x))
+	  contents = flaginfo->contents;
+	  if (! bfd_get_full_section_contents (input_bfd, o, &contents))
 	    return FALSE;
-	  contents = finfo->contents;
 	}
 
       if ((o->flags & SEC_RELOC) != 0)
@@ -2355,13 +2441,14 @@
 	  /* Read in the relocs.  */
 	  target_index = o->output_section->target_index;
 	  internal_relocs = (_bfd_coff_read_internal_relocs
-			     (input_bfd, o, FALSE, finfo->external_relocs,
-			      finfo->info->relocatable,
-			      (finfo->info->relocatable
-			       ? (finfo->section_info[target_index].relocs
+			     (input_bfd, o, FALSE, flaginfo->external_relocs,
+			      flaginfo->info->relocatable,
+			      (flaginfo->info->relocatable
+			       ? (flaginfo->section_info[target_index].relocs
 				  + o->output_section->reloc_count)
-			       : finfo->internal_relocs)));
-	  if (internal_relocs == NULL)
+			       : flaginfo->internal_relocs)));
+	  if (internal_relocs == NULL
+	      && o->reloc_count > 0)
 	    return FALSE;
 
 	  /* Run through the relocs looking for relocs against symbols
@@ -2387,7 +2474,7 @@
 		continue;
 	      /* Complain if definition comes from an excluded section.  */
 	      if (ps->flags & SEC_EXCLUDE)
-		(*finfo->info->callbacks->einfo)
+		(*flaginfo->info->callbacks->einfo)
 		  (_("%X`%s' referenced in section `%A' of %B: "
 		     "defined in discarded section `%A' of %B\n"),
 		   h->root.root.string, o, input_bfd, ps, ps->owner);
@@ -2395,15 +2482,15 @@
 
 	  /* Call processor specific code to relocate the section
              contents.  */
-	  if (! bfd_coff_relocate_section (output_bfd, finfo->info,
+	  if (! bfd_coff_relocate_section (output_bfd, flaginfo->info,
 					   input_bfd, o,
 					   contents,
 					   internal_relocs,
-					   finfo->internal_syms,
-					   finfo->sec_ptrs))
+					   flaginfo->internal_syms,
+					   flaginfo->sec_ptrs))
 	    return FALSE;
 
-	  if (finfo->info->relocatable)
+	  if (flaginfo->info->relocatable)
 	    {
 	      bfd_vma offset;
 	      struct internal_reloc *irelend;
@@ -2412,7 +2499,7 @@
 	      offset = o->output_section->vma + o->output_offset - o->vma;
 	      irel = internal_relocs;
 	      irelend = irel + o->reloc_count;
-	      rel_hash = (finfo->section_info[target_index].rel_hashes
+	      rel_hash = (flaginfo->section_info[target_index].rel_hashes
 			  + o->output_section->reloc_count);
 	      for (; irel < irelend; irel++, rel_hash++)
 		{
@@ -2429,7 +2516,7 @@
 
 		  if (adjust_symndx)
 		    {
-		      if (! (*adjust_symndx) (output_bfd, finfo->info,
+		      if (! (*adjust_symndx) (output_bfd, flaginfo->info,
 					      input_bfd, o, irel,
 					      &adjusted))
 			return FALSE;
@@ -2459,7 +2546,7 @@
 		    {
 		      long indx;
 
-		      indx = finfo->sym_indices[irel->r_symndx];
+		      indx = flaginfo->sym_indices[irel->r_symndx];
 		      if (indx != -1)
 			irel->r_symndx = indx;
 		      else
@@ -2472,15 +2559,15 @@
                              stripping.  This should have been handled
 			     by the 'dont_skip_symbol' code in the while
 			     loop at the top of this function.  */
-			  is = finfo->internal_syms + irel->r_symndx;
+			  is = flaginfo->internal_syms + irel->r_symndx;
 
 			  name = (_bfd_coff_internal_syment_name
 				  (input_bfd, is, buf));
 			  if (name == NULL)
 			    return FALSE;
 
-			  if (! ((*finfo->info->callbacks->unattached_reloc)
-				 (finfo->info, name, input_bfd, o,
+			  if (! ((*flaginfo->info->callbacks->unattached_reloc)
+				 (flaginfo->info, name, input_bfd, o,
 				  irel->r_vaddr)))
 			    return FALSE;
 			}
@@ -2502,13 +2589,13 @@
       else
 	{
 	  if (! (_bfd_write_section_stabs
-		 (output_bfd, &coff_hash_table (finfo->info)->stab_info,
+		 (output_bfd, &coff_hash_table (flaginfo->info)->stab_info,
 		  o, &secdata->stab_info, contents)))
 	    return FALSE;
 	}
     }
 
-  if (! finfo->info->keep_memory
+  if (! flaginfo->info->keep_memory
       && ! _bfd_coff_free_symbols (input_bfd))
     return FALSE;
 
@@ -2521,14 +2608,14 @@
 _bfd_coff_write_global_sym (struct bfd_hash_entry *bh, void *data)
 {
   struct coff_link_hash_entry *h = (struct coff_link_hash_entry *) bh;
-  struct coff_final_link_info *finfo = (struct coff_final_link_info *) data;
+  struct coff_final_link_info *flaginfo = (struct coff_final_link_info *) data;
   bfd *output_bfd;
   struct internal_syment isym;
   bfd_size_type symesz;
   unsigned int i;
   file_ptr pos;
 
-  output_bfd = finfo->output_bfd;
+  output_bfd = flaginfo->output_bfd;
 
   if (h->root.type == bfd_link_hash_warning)
     {
@@ -2541,9 +2628,9 @@
     return TRUE;
 
   if (h->indx != -2
-      && (finfo->info->strip == strip_all
-	  || (finfo->info->strip == strip_some
-	      && (bfd_hash_lookup (finfo->info->keep_hash,
+      && (flaginfo->info->strip == strip_all
+	  || (flaginfo->info->strip == strip_some
+	      && (bfd_hash_lookup (flaginfo->info->keep_hash,
 				   h->root.root.string, FALSE, FALSE)
 		  == NULL))))
     return TRUE;
@@ -2574,7 +2661,7 @@
 	  isym.n_scnum = sec->target_index;
 	isym.n_value = (h->root.u.def.value
 			+ h->root.u.def.section->output_offset);
-	if (! obj_pe (finfo->output_bfd))
+	if (! obj_pe (flaginfo->output_bfd))
 	  isym.n_value += sec->vma;
       }
       break;
@@ -2599,11 +2686,11 @@
       hash = TRUE;
       if ((output_bfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
 	hash = FALSE;
-      indx = _bfd_stringtab_add (finfo->strtab, h->root.root.string, hash,
+      indx = _bfd_stringtab_add (flaginfo->strtab, h->root.root.string, hash,
 				 FALSE);
       if (indx == (bfd_size_type) -1)
 	{
-	  finfo->failed = TRUE;
+	  flaginfo->failed = TRUE;
 	  return FALSE;
 	}
       isym._n._n_n._n_zeroes = 0;
@@ -2620,7 +2707,7 @@
      defined globals to statics, then do that conversion now.  If the
      symbol is not being converted, just ignore it and it will be
      output during a later pass.  */
-  if (finfo->global_to_static)
+  if (flaginfo->global_to_static)
     {
       if (! IS_EXTERNAL (output_bfd, isym))
 	return TRUE;
@@ -2631,23 +2718,23 @@
   /* When a weak symbol is not overridden by a strong one,
      turn it into an external symbol when not building a
      shared or relocatable object.  */
-  if (! finfo->info->shared
-      && ! finfo->info->relocatable
-      && IS_WEAK_EXTERNAL (finfo->output_bfd, isym))
+  if (! flaginfo->info->shared
+      && ! flaginfo->info->relocatable
+      && IS_WEAK_EXTERNAL (flaginfo->output_bfd, isym))
     isym.n_sclass = C_EXT;
 
   isym.n_numaux = h->numaux;
 
-  bfd_coff_swap_sym_out (output_bfd, &isym, finfo->outsyms);
+  bfd_coff_swap_sym_out (output_bfd, &isym, flaginfo->outsyms);
 
   symesz = bfd_coff_symesz (output_bfd);
 
   pos = obj_sym_filepos (output_bfd);
   pos += obj_raw_syment_count (output_bfd) * symesz;
   if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
-      || bfd_bwrite (finfo->outsyms, symesz, output_bfd) != symesz)
+      || bfd_bwrite (flaginfo->outsyms, symesz, output_bfd) != symesz)
     {
-      finfo->failed = TRUE;
+      flaginfo->failed = TRUE;
       return FALSE;
     }
 
@@ -2685,7 +2772,7 @@
                  not matter.  FIXME: Why not?  */
 	      if (sec->reloc_count > 0xffff
 		  && (! obj_pe (output_bfd)
-		      || finfo->info->relocatable))
+		      || flaginfo->info->relocatable))
 		(*_bfd_error_handler)
 		  (_("%s: %s: reloc overflow: 0x%lx > 0xffff"),
 		   bfd_get_filename (output_bfd),
@@ -2694,7 +2781,7 @@
 
 	      if (sec->lineno_count > 0xffff
 		  && (! obj_pe (output_bfd)
-		      || finfo->info->relocatable))
+		      || flaginfo->info->relocatable))
 		(*_bfd_error_handler)
 		  (_("%s: warning: %s: line number overflow: 0x%lx > 0xffff"),
 		   bfd_get_filename (output_bfd),
@@ -2711,10 +2798,10 @@
 
       bfd_coff_swap_aux_out (output_bfd, auxp, isym.n_type,
 			     isym.n_sclass, (int) i, isym.n_numaux,
-			     finfo->outsyms);
-      if (bfd_bwrite (finfo->outsyms, symesz, output_bfd) != symesz)
+			     flaginfo->outsyms);
+      if (bfd_bwrite (flaginfo->outsyms, symesz, output_bfd) != symesz)
 	{
-	  finfo->failed = TRUE;
+	  flaginfo->failed = TRUE;
 	  return FALSE;
 	}
       ++obj_raw_syment_count (output_bfd);
@@ -2730,7 +2817,7 @@
 bfd_boolean
 _bfd_coff_write_task_globals (struct coff_link_hash_entry *h, void *data)
 {
-  struct coff_final_link_info *finfo = (struct coff_final_link_info *) data;
+  struct coff_final_link_info *flaginfo = (struct coff_final_link_info *) data;
   bfd_boolean rtnval = TRUE;
   bfd_boolean save_global_to_static;
 
@@ -2743,10 +2830,10 @@
 	{
 	case bfd_link_hash_defined:
 	case bfd_link_hash_defweak:
-	  save_global_to_static = finfo->global_to_static;
-	  finfo->global_to_static = TRUE;
+	  save_global_to_static = flaginfo->global_to_static;
+	  flaginfo->global_to_static = TRUE;
 	  rtnval = _bfd_coff_write_global_sym (&h->root.root, data);
-	  finfo->global_to_static = save_global_to_static;
+	  flaginfo->global_to_static = save_global_to_static;
 	  break;
 	default:
 	  break;
@@ -2759,7 +2846,7 @@
 
 bfd_boolean
 _bfd_coff_reloc_link_order (bfd *output_bfd,
-			    struct coff_final_link_info *finfo,
+			    struct coff_final_link_info *flaginfo,
 			    asection *output_section,
 			    struct bfd_link_order *link_order)
 {
@@ -2798,8 +2885,8 @@
 	case bfd_reloc_outofrange:
 	  abort ();
 	case bfd_reloc_overflow:
-	  if (! ((*finfo->info->callbacks->reloc_overflow)
-		 (finfo->info, NULL,
+	  if (! ((*flaginfo->info->callbacks->reloc_overflow)
+		 (flaginfo->info, NULL,
 		  (link_order->type == bfd_section_reloc_link_order
 		   ? bfd_section_name (output_bfd,
 				       link_order->u.reloc.p->u.section)
@@ -2822,9 +2909,9 @@
 
   /* Store the reloc information in the right place.  It will get
      swapped and written out at the end of the final_link routine.  */
-  irel = (finfo->section_info[output_section->target_index].relocs
+  irel = (flaginfo->section_info[output_section->target_index].relocs
 	  + output_section->reloc_count);
-  rel_hash_ptr = (finfo->section_info[output_section->target_index].rel_hashes
+  rel_hash_ptr = (flaginfo->section_info[output_section->target_index].rel_hashes
 		  + output_section->reloc_count);
 
   memset (irel, 0, sizeof (struct internal_reloc));
@@ -2847,7 +2934,7 @@
       struct coff_link_hash_entry *h;
 
       h = ((struct coff_link_hash_entry *)
-	   bfd_wrapped_link_hash_lookup (output_bfd, finfo->info,
+	   bfd_wrapped_link_hash_lookup (output_bfd, flaginfo->info,
 					 link_order->u.reloc.p->u.name,
 					 FALSE, FALSE, TRUE));
       if (h != NULL)
@@ -2865,8 +2952,8 @@
 	}
       else
 	{
-	  if (! ((*finfo->info->callbacks->unattached_reloc)
-		 (finfo->info, link_order->u.reloc.p->u.name, (bfd *) NULL,
+	  if (! ((*flaginfo->info->callbacks->unattached_reloc)
+		 (flaginfo->info, link_order->u.reloc.p->u.name, (bfd *) NULL,
 		  (asection *) NULL, (bfd_vma) 0)))
 	    return FALSE;
 	  irel->r_symndx = 0;
diff --git a/bfd/compress.c b/bfd/compress.c
index a82a8bc..46c2bcb 100644
--- a/bfd/compress.c
+++ b/bfd/compress.c
@@ -1,5 +1,5 @@
 /* Compressed section support (intended for debug sections).
-   Copyright 2008, 2010, 2011
+   Copyright 2008, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -19,7 +19,6 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "config.h"
 #include "sysdep.h"
 #include "bfd.h"
 #include "libbfd.h"
@@ -46,19 +45,20 @@
   strm.next_in = (Bytef*) compressed_buffer + 12;
   strm.avail_out = uncompressed_size;
 
+  BFD_ASSERT (Z_OK == 0);
   rc = inflateInit (&strm);
-  while (strm.avail_in > 0)
+  while (strm.avail_in > 0 && strm.avail_out > 0)
     {
       if (rc != Z_OK)
-	return FALSE;
+	break;
       strm.next_out = ((Bytef*) uncompressed_buffer
                        + (uncompressed_size - strm.avail_out));
       rc = inflate (&strm, Z_FINISH);
       if (rc != Z_STREAM_END)
-	return FALSE;
+	break;
       rc = inflateReset (&strm);
     }
-  rc = inflateEnd (&strm);
+  rc |= inflateEnd (&strm);
   return rc == Z_OK && strm.avail_out == 0;
 }
 #endif
@@ -80,7 +80,7 @@
 	field was allocated using bfd_malloc() or equivalent.  If zlib
 	is not installed on this machine, the input is unmodified.
 
-	Return @code{TRUE} if the full section contents is compressed 
+	Return @code{TRUE} if the full section contents is compressed
 	successfully.
 */
 
@@ -149,7 +149,7 @@
 DESCRIPTION
 	Read all data from @var{section} in BFD @var{abfd}, decompress
 	if needed, and store in @var{*ptr}.  If @var{*ptr} is NULL,
-	return @var{*ptr} with memory malloc'd by this function.  
+	return @var{*ptr} with memory malloc'd by this function.
 
 	Return @code{TRUE} if the full section contents is retrieved
 	successfully.
@@ -162,11 +162,9 @@
   bfd_byte *p = *ptr;
 #ifdef HAVE_ZLIB_H
   bfd_boolean ret;
-  bfd_size_type compressed_size;
-  bfd_size_type uncompressed_size;
-  bfd_size_type rawsize;
+  bfd_size_type save_size;
+  bfd_size_type save_rawsize;
   bfd_byte *compressed_buffer;
-  bfd_byte *uncompressed_buffer;
 #endif
 
   if (abfd->direction != write_direction && sec->rawsize != 0)
@@ -200,45 +198,44 @@
       return FALSE;
 #else
       /* Read in the full compressed section contents.  */
-      uncompressed_size = sec->size;
-      compressed_size = sec->compressed_size;
-      compressed_buffer = (bfd_byte *) bfd_malloc (compressed_size);
+      compressed_buffer = (bfd_byte *) bfd_malloc (sec->compressed_size);
       if (compressed_buffer == NULL)
 	return FALSE;
-      rawsize = sec->rawsize;
+      save_rawsize = sec->rawsize;
+      save_size = sec->size;
       /* Clear rawsize, set size to compressed size and set compress_status
 	 to COMPRESS_SECTION_NONE.  If the compressed size is bigger than
 	 the uncompressed size, bfd_get_section_contents will fail.  */
       sec->rawsize = 0;
-      sec->size = compressed_size;
+      sec->size = sec->compressed_size;
       sec->compress_status = COMPRESS_SECTION_NONE;
       ret = bfd_get_section_contents (abfd, sec, compressed_buffer,
-				      0, compressed_size);
+				      0, sec->compressed_size);
       /* Restore rawsize and size.  */
-      sec->rawsize = rawsize;
-      sec->size = uncompressed_size;
+      sec->rawsize = save_rawsize;
+      sec->size = save_size;
       sec->compress_status = DECOMPRESS_SECTION_SIZED;
       if (!ret)
 	goto fail_compressed;
 
-      uncompressed_buffer = (bfd_byte *) bfd_malloc (uncompressed_size);
-      if (uncompressed_buffer == NULL)
+      if (p == NULL)
+	p = (bfd_byte *) bfd_malloc (sz);
+      if (p == NULL)
 	goto fail_compressed;
 
-      if (!decompress_contents (compressed_buffer, compressed_size,
-				uncompressed_buffer, uncompressed_size))
+      if (!decompress_contents (compressed_buffer, sec->compressed_size, p, sz))
 	{
 	  bfd_set_error (bfd_error_bad_value);
-	  free (uncompressed_buffer);
+	  if (p != *ptr)
+	    free (p);
 	fail_compressed:
 	  free (compressed_buffer);
 	  return FALSE;
 	}
 
       free (compressed_buffer);
-      sec->contents = uncompressed_buffer;
-      sec->compress_status = COMPRESS_SECTION_DONE;
-      /* Fall thru */
+      *ptr = p;
+      return TRUE;
 #endif
 
     case COMPRESS_SECTION_DONE:
@@ -259,6 +256,29 @@
 
 /*
 FUNCTION
+	bfd_cache_section_contents
+
+SYNOPSIS
+	void bfd_cache_section_contents
+	  (asection *sec, void *contents);
+
+DESCRIPTION
+	Stash @var(contents) so any following reads of @var(sec) do
+	not need to decompress again.
+*/
+
+void
+bfd_cache_section_contents (asection *sec, void *contents)
+{
+  if (sec->compress_status == DECOMPRESS_SECTION_SIZED)
+    sec->compress_status = COMPRESS_SECTION_DONE;
+  sec->contents = contents;
+  sec->flags |= SEC_IN_MEMORY;
+}
+
+
+/*
+FUNCTION
 	bfd_is_section_compressed
 
 SYNOPSIS
@@ -273,11 +293,20 @@
 bfd_is_section_compressed (bfd *abfd, sec_ptr sec)
 {
   bfd_byte compressed_buffer [12];
+  unsigned int saved = sec->compress_status;
+  bfd_boolean compressed;
+
+  /* Don't decompress the section.  */
+  sec->compress_status = COMPRESS_SECTION_NONE;
 
   /* Read the zlib header.  In this case, it should be "ZLIB" followed
      by the uncompressed section size, 8 bytes in big-endian order.  */
-  return (bfd_get_section_contents (abfd, sec, compressed_buffer, 0, 12)
-	  && CONST_STRNEQ ((char*) compressed_buffer, "ZLIB"));
+  compressed = (bfd_get_section_contents (abfd, sec, compressed_buffer, 0, 12)
+		&& CONST_STRNEQ ((char*) compressed_buffer, "ZLIB"));
+
+  /* Restore compress_status.  */
+  sec->compress_status = saved;
+  return compressed;
 }
 
 /*
diff --git a/bfd/config.bfd b/bfd/config.bfd
index 3b9872a..5324d39 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -1,4 +1,21 @@
 # config.bfd
+#
+#   Copyright 2012, 2013 Free Software Foundation
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+#
 # Convert a canonical host type into a BFD host type.
 # Set shell variable targ to canonical target name, and run
 # using ``. config.bfd''.
@@ -69,6 +86,7 @@
 
 targ_cpu=`echo $targ | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
 case "${targ_cpu}" in
+aarch64*)	 targ_archs="bfd_aarch64_arch bfd_arm_arch";;
 alpha*)		 targ_archs=bfd_alpha_arch ;;
 am34*|am33_2.0*) targ_archs=bfd_mn10300_arch ;;
 arm*)		 targ_archs=bfd_arm_arch ;;
@@ -85,12 +103,13 @@
 i[3-7]86)	 targ_archs=bfd_i386_arch ;;
 i370)		 targ_archs=bfd_i370_arch ;;
 lm32)	         targ_archs=bfd_lm32_arch ;;
-m6811*|m68hc11*) targ_archs="bfd_m68hc11_arch bfd_m68hc12_arch" ;;
-m6812*|m68hc12*) targ_archs="bfd_m68hc12_arch bfd_m68hc11_arch" ;;
+m6811*|m68hc11*) targ_archs="bfd_m68hc11_arch bfd_m68hc12_arch bfd_m9s12x_arch bfd_m9s12xg_arch" ;;
+m6812*|m68hc12*) targ_archs="bfd_m68hc12_arch bfd_m68hc11_arch bfd_m9s12x_arch bfd_m9s12xg_arch" ;;
 m68*)		 targ_archs=bfd_m68k_arch ;;
 m88*)		 targ_archs=bfd_m88k_arch ;;
 microblaze*)	 targ_archs=bfd_microblaze_arch ;;
 mips*)		 targ_archs=bfd_mips_arch ;;
+nios2*)          targ_archs=bfd_nios2_arch ;;
 or32*)		 targ_archs=bfd_or32_arch ;;
 pdp11*)		 targ_archs=bfd_pdp11_arch ;;
 pj*)		 targ_archs="bfd_pj_arch bfd_i386_arch";;
@@ -102,9 +121,10 @@
 spu*)            targ_archs=bfd_spu_arch ;;
 tilegx*)	 targ_archs=bfd_tilegx_arch ;;
 tilepro*)	 targ_archs=bfd_tilepro_arch ;;
-v850*)		 targ_archs=bfd_v850_arch ;;
+v850*)		 targ_archs="bfd_v850_arch bfd_v850_rh850_arch" ;;
 x86_64*)	 targ_archs=bfd_i386_arch ;;
 xtensa*)	 targ_archs=bfd_xtensa_arch ;;
+xgate)		 targ_archs=bfd_xgate_arch ;;
 z80|r800)	 targ_archs=bfd_z80_arch ;;
 z8k*)		 targ_archs=bfd_z8k_arch ;;
 *)		 targ_archs=bfd_${targ_cpu}_arch ;;
@@ -142,6 +162,26 @@
 
 # START OF targmatch.h
 #ifdef BFD64
+  aarch64-*-elf)
+    targ_defvec=bfd_elf64_littleaarch64_vec
+    targ_selvecs="bfd_elf64_bigaarch64_vec bfd_elf32_littleaarch64_vec bfd_elf32_bigaarch64_vec bfd_elf32_littlearm_vec bfd_elf32_bigarm_vec"
+    want64=true
+    ;;
+  aarch64_be-*-elf)
+    targ_defvec=bfd_elf64_bigaarch64_vec
+    targ_selvecs="bfd_elf64_littleaarch64_vec bfd_elf32_littleaarch64_vec bfd_elf32_bigaarch64_vec bfd_elf32_bigarm_vec bfd_elf32_littlearm_vec"
+    want64=true
+    ;;
+  aarch64-*-linux*)
+    targ_defvec=bfd_elf64_littleaarch64_vec
+    targ_selvecs="bfd_elf64_bigaarch64_vec bfd_elf32_littleaarch64_vec bfd_elf32_bigaarch64_vec bfd_elf32_littlearm_vec bfd_elf32_bigarm_vec"
+    want64=true
+    ;;
+  aarch64_be-*-linux*)
+    targ_defvec=bfd_elf64_bigaarch64_vec
+    targ_selvecs="bfd_elf64_littleaarch64_vec bfd_elf32_littleaarch64_vec bfd_elf32_bigaarch64_vec bfd_elf32_bigarm_vec bfd_elf32_littlearm_vec"
+    want64=true
+    ;;
   alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
     targ_defvec=bfd_elf64_alpha_freebsd_vec
     targ_selvecs="bfd_elf64_alpha_vec ecoffalpha_little_vec"
@@ -162,7 +202,7 @@
     targ_selvecs=nlm32_alpha_vec
     want64=true
     ;;
-  alpha*-*-linuxecoff*)
+  alpha*-*-linux*ecoff*)
     targ_defvec=ecoffalpha_little_vec
     targ_selvecs=bfd_elf64_alpha_vec
     want64=true
@@ -216,6 +256,18 @@
     targ_selvecs=bfd_elf32_bigarc_vec
     ;;
 
+  arm-*-nacl*)
+    targ_defvec=bfd_elf32_littlearm_nacl_vec
+    targ_selvecs="bfd_elf32_bigarm_nacl_vec bfd_elf32_i386_nacl_vec"
+    targ64_selvecs="bfd_elf32_x86_64_nacl_vec bfd_elf64_x86_64_nacl_vec"
+    targ_archs="$targ_archs bfd_i386_arch"
+    ;;
+  armeb-*-nacl*)
+    targ_defvec=bfd_elf32_bigarm_nacl_vec
+    targ_selvecs="bfd_elf32_littlearm_nacl_vec bfd_elf32_i386_nacl_vec"
+    targ64_selvecs="bfd_elf32_x86_64_nacl_vec bfd_elf64_x86_64_nacl_vec"
+    targ_archs="$targ_archs bfd_i386_arch"
+    ;;
   armeb-*-netbsdelf*)
     targ_defvec=bfd_elf32_bigarm_vec
     targ_selvecs="bfd_elf32_littlearm_vec armnetbsd_vec"
@@ -327,7 +379,7 @@
     targ_underscore=yes
     ;;
 
-  cr16-*-elf*)
+  cr16-*-elf* | cr16*-*-uclinux*)
     targ_defvec=bfd_elf32_cr16_vec
     targ_underscore=yes
     ;;
@@ -361,6 +413,10 @@
     targ_defvec=bfd_elf32_d30v_vec
     ;;
 
+  epiphany-*-elf)
+    targ_defvec=bfd_elf32_epiphany_vec
+    ;;
+
   fido-*-elf* )
     targ_defvec=bfd_elf32_m68k_vec
     targ_selvecs="m68kcoff_vec ieee_vec"
@@ -380,8 +436,9 @@
     targ_selvecs=bfd_elf32_frv_vec
     ;;
 
-  moxie-*-elf | moxie-*-rtems | moxie-*-uclinux)
-    targ_defvec=bfd_elf32_moxie_vec
+  moxie-*-elf | moxie-*-rtems* | moxie-*-uclinux)
+    targ_defvec=bfd_elf32_bigmoxie_vec
+    targ_selvecs=bfd_elf32_littlemoxie_vec
     ;;
 
   h8300*-*-rtemscoff*)
@@ -503,9 +560,10 @@
   i[3-7]86-*-darwin* | i[3-7]86-*-macos10* | i[3-7]86-*-rhapsody*)
     targ_defvec=mach_o_i386_vec
     targ_selvecs="mach_o_le_vec mach_o_be_vec mach_o_fat_vec pef_vec pef_xlib_vec sym_vec"
+    targ64_selvecs=mach_o_x86_64_vec
     targ_archs="$targ_archs bfd_powerpc_arch bfd_rs6000_arch"
     ;;
- i[3-7]86-sequent-bsd*)
+  i[3-7]86-sequent-bsd*)
     targ_defvec=i386dynix_vec
     targ_underscore=yes
     ;;
@@ -564,11 +622,13 @@
   i[3-7]86-*-linux-*)
     targ_defvec=bfd_elf32_i386_vec
     targ_selvecs="i386linux_vec i386pei_vec"
-    targ64_selvecs="bfd_elf64_x86_64_vec bfd_elf32_x86_64_vec bfd_elf64_l1om_vec bfd_elf64_k1om_vec"
+    targ64_selvecs="bfd_elf64_x86_64_vec bfd_elf32_x86_64_vec x86_64pei_vec bfd_elf64_l1om_vec bfd_elf64_k1om_vec"
     ;;
   i[3-7]86-*-nacl*)
     targ_defvec=bfd_elf32_i386_nacl_vec
-    targ_selvecs="bfd_elf32_i386_vec"
+    targ_selvecs="bfd_elf32_bigarm_nacl_vec bfd_elf32_littlearm_nacl_vec"
+    targ64_selvecs="bfd_elf64_x86_64_nacl_vec bfd_elf32_x86_64_nacl_vec"
+    targ_archs="$targ_archs bfd_arm_arch"
     ;;
 #ifdef BFD64
   x86_64-*-darwin*)
@@ -584,7 +644,7 @@
     ;;
   x86_64-*-elf*)
     targ_defvec=bfd_elf64_x86_64_vec
-    targ_selvecs="bfd_elf32_i386_vec bfd_elf64_l1om_vec bfd_elf64_k1om_vec i386coff_vec"
+    targ_selvecs="bfd_elf32_i386_vec bfd_elf32_x86_64_vec bfd_elf64_l1om_vec bfd_elf64_k1om_vec"
     want64=true
     ;;
   x86_64-*-dragonfly*)
@@ -607,12 +667,22 @@
     targ_selvecs="bfd_elf32_i386_vec bfd_elf32_x86_64_vec i386linux_vec i386pei_vec x86_64pei_vec bfd_elf64_l1om_vec bfd_elf64_k1om_vec"
     want64=true
     ;;
-  x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep)
+  x86_64-*-nacl*)
+    targ_defvec=bfd_elf32_x86_64_nacl_vec
+    targ_selvecs="bfd_elf32_i386_nacl_vec bfd_elf64_x86_64_nacl_vec bfd_elf32_bigarm_nacl_vec bfd_elf32_littlearm_nacl_vec"
+    targ_archs="$targ_archs bfd_arm_arch"
+    want64=true
+    ;;
+  x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep | x86_64-*-cygwin)
     targ_defvec=x86_64pe_vec
     targ_selvecs="x86_64pe_vec x86_64pei_vec bfd_elf64_x86_64_vec bfd_elf64_l1om_vec bfd_elf64_k1om_vec i386pe_vec i386pei_vec bfd_elf32_i386_vec"
     want64=true
     targ_underscore=no
     ;;
+  x86_64-*-rdos*)
+    targ_defvec=bfd_elf64_x86_64_vec
+    want64=true
+    ;;
 #endif
   i[3-7]86-*-lynxos*)
     targ_defvec=bfd_elf32_i386_vec
@@ -868,14 +938,26 @@
     targ_selvecs=bfd_elf32_mep_little_vec
     ;;
 
+  metag-*-*)
+    targ_defvec=bfd_elf32_metag_vec
+    targ_underscore=yes
+    ;;
+
+  microblazeel*-*)
+    targ_defvec=bfd_elf32_microblazeel_vec
+    targ_selvecs=bfd_elf32_microblaze_vec
+    ;;
+
   microblaze*-*)
     targ_defvec=bfd_elf32_microblaze_vec
+    targ_selvecs=bfd_elf32_microblazeel_vec
     ;;
 
   mips*-big-*)
     targ_defvec=ecoff_big_vec
     targ_selvecs=ecoff_little_vec
     ;;
+#ifdef BFD64
   mips*el-*-netbsd*)
     targ_defvec=bfd_elf32_tradlittlemips_vec
     targ_selvecs="bfd_elf32_tradbigmips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec ecoff_little_vec ecoff_big_vec"
@@ -884,6 +966,7 @@
     targ_defvec=bfd_elf32_tradbigmips_vec
     targ_selvecs="bfd_elf32_tradlittlemips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec ecoff_big_vec ecoff_little_vec"
     ;;
+#endif
   mips*-dec-* | mips*el-*-ecoff*)
     targ_defvec=ecoff_little_vec
     targ_selvecs=ecoff_big_vec
@@ -896,13 +979,20 @@
   mips*-*-irix6*)
     targ_defvec=bfd_elf32_nbigmips_vec
     targ_selvecs="bfd_elf32_nlittlemips_vec bfd_elf32_bigmips_vec bfd_elf32_littlemips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec"
-    want64=true
     ;;
-#endif
+  mips64*-ps2-elf*)
+    targ_defvec=bfd_elf32_nlittlemips_vec
+    targ_selvecs="bfd_elf32_nlittlemips_vec bfd_elf32_nbigmips_vec bfd_elf32_bigmips_vec bfd_elf32_littlemips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec"
+    ;;
+  mips*-ps2-elf*)
+    targ_defvec=bfd_elf32_littlemips_vec
+    targ_selvecs="bfd_elf32_bigmips_vec bfd_elf32_littlemips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec"
+    ;;
   mips*-*-irix5*)
     targ_defvec=bfd_elf32_bigmips_vec
     targ_selvecs="bfd_elf32_littlemips_vec ecoff_big_vec ecoff_little_vec"
     ;;
+#endif
   mips*-sgi-* | mips*-*-bsd*)
     targ_defvec=ecoff_big_vec
     targ_selvecs=ecoff_little_vec
@@ -911,10 +1001,12 @@
     targ_defvec=ecoff_biglittle_vec
     targ_selvecs="ecoff_little_vec ecoff_big_vec"
     ;;
+#ifdef BFD64
   mips*-*-sysv4*)
     targ_defvec=bfd_elf32_tradbigmips_vec
     targ_selvecs="bfd_elf32_tradlittlemips_vec ecoff_big_vec ecoff_little_vec"
     ;;
+#endif
   mips*-*-sysv* | mips*-*-riscos*)
     targ_defvec=ecoff_big_vec
     targ_selvecs=ecoff_little_vec
@@ -923,23 +1015,18 @@
   mips*el-*-vxworks*)
     targ_defvec=bfd_elf32_littlemips_vxworks_vec
     targ_selvecs="bfd_elf32_littlemips_vec bfd_elf32_bigmips_vxworks_vec bfd_elf32_bigmips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec"
-    want64=true
     ;;
   mips*-*-vxworks*)
     targ_defvec=bfd_elf32_bigmips_vxworks_vec
     targ_selvecs="bfd_elf32_bigmips_vec bfd_elf32_littlemips_vxworks_vec bfd_elf32_bigmips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec"
-    want64=true
     ;;
-#endif
   mips*el-sde-elf*)
     targ_defvec=bfd_elf32_tradlittlemips_vec
     targ_selvecs="bfd_elf32_tradbigmips_vec bfd_elf32_ntradbigmips_vec bfd_elf32_ntradlittlemips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec"
-    want64=true
     ;;
-  mips*-sde-elf*)
+  mips*-sde-elf* | mips*-mti-elf*)
     targ_defvec=bfd_elf32_tradbigmips_vec
     targ_selvecs="bfd_elf32_tradlittlemips_vec bfd_elf32_ntradbigmips_vec bfd_elf32_ntradlittlemips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec"
-    want64=true
     ;;
   mips*el-*-elf* | mips*el-*-vxworks* | mips*-*-chorus*)
     targ_defvec=bfd_elf32_littlemips_vec
@@ -953,13 +1040,10 @@
     targ_defvec=bfd_elf32_bigmips_vec
     targ_selvecs="bfd_elf32_littlemips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec"
     ;;
-#ifdef BFD64
   mips64*-*-openbsd*)
     targ_defvec=bfd_elf64_tradbigmips_vec
     targ_selvecs="bfd_elf32_ntradlittlemips_vec bfd_elf32_ntradbigmips_vec bfd_elf32_tradlittlemips_vec bfd_elf32_tradbigmips_vec bfd_elf64_tradlittlemips_vec"
-    want64=true
     ;;
-#endif
   mips*el-*-openbsd*)
     targ_defvec=bfd_elf32_littlemips_vec
     targ_selvecs="bfd_elf32_bigmips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec ecoff_little_vec ecoff_big_vec"
@@ -968,36 +1052,28 @@
     targ_defvec=bfd_elf32_bigmips_vec
     targ_selvecs="bfd_elf32_littlemips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec ecoff_big_vec ecoff_little_vec"
     ;;
-#ifdef BFD64
   mips64*el-*-linux*)
     targ_defvec=bfd_elf32_ntradlittlemips_vec
     targ_selvecs="bfd_elf32_ntradbigmips_vec bfd_elf32_tradlittlemips_vec bfd_elf32_tradbigmips_vec bfd_elf64_tradlittlemips_vec bfd_elf64_tradbigmips_vec"
-    want64=true
     ;;
   mips64*-*-linux*)
     targ_defvec=bfd_elf32_ntradbigmips_vec
     targ_selvecs="bfd_elf32_ntradlittlemips_vec bfd_elf32_tradbigmips_vec bfd_elf32_tradlittlemips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec"
-    want64=true
     ;;
-#endif
   mips*el-*-linux*)
     targ_defvec=bfd_elf32_tradlittlemips_vec
     targ_selvecs="bfd_elf32_tradbigmips_vec ecoff_little_vec ecoff_big_vec bfd_elf32_ntradlittlemips_vec bfd_elf64_tradlittlemips_vec bfd_elf32_ntradbigmips_vec bfd_elf64_tradbigmips_vec"
-    want64=true
     ;;
   mips*-*-linux*)
     targ_defvec=bfd_elf32_tradbigmips_vec
     targ_selvecs="bfd_elf32_tradlittlemips_vec ecoff_big_vec ecoff_little_vec bfd_elf32_ntradbigmips_vec bfd_elf64_tradbigmips_vec bfd_elf32_ntradlittlemips_vec bfd_elf64_tradlittlemips_vec"
-    want64=true
     ;;
-#ifdef BFD64
   mips64*el-*-freebsd* | mips64*el-*-kfreebsd*-gnu)
     # FreeBSD vectors
     targ_defvec=bfd_elf32_ntradlittlemips_freebsd_vec
     targ_selvecs="bfd_elf32_ntradbigmips_freebsd_vec bfd_elf32_tradlittlemips_freebsd_vec bfd_elf32_tradbigmips_freebsd_vec bfd_elf64_tradlittlemips_freebsd_vec bfd_elf64_tradbigmips_freebsd_vec"
     # Generic vectors
     targ_selvecs="${targ_selvecs} bfd_elf32_ntradlittlemips_vec bfd_elf32_ntradbigmips_vec bfd_elf32_tradlittlemips_vec bfd_elf32_tradbigmips_vec bfd_elf64_tradlittlemips_vec bfd_elf64_tradbigmips_vec"
-    want64=true
     ;;
   mips64*-*-freebsd* | mips64*-*-kfreebsd*-gnu)
     # FreeBSD vectors
@@ -1005,16 +1081,13 @@
     targ_selvecs="bfd_elf32_ntradlittlemips_freebsd_vec bfd_elf32_tradbigmips_freebsd_vec bfd_elf32_tradlittlemips_freebsd_vec bfd_elf64_tradbigmips_freebsd_vec bfd_elf64_tradlittlemips_freebsd_vec"
     # Generic vectors
     targ_selvecs="${targ_selvecs} bfd_elf32_ntradbigmips_vec bfd_elf32_ntradlittlemips_vec bfd_elf32_tradbigmips_vec bfd_elf32_tradlittlemips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec"
-    want64=true
     ;;
-#endif
   mips*el-*-freebsd* | mips*el-*-kfreebsd*-gnu)
     # FreeBSD vectors
     targ_defvec=bfd_elf32_tradlittlemips_freebsd_vec
     targ_selvecs="bfd_elf32_tradbigmips_freebsd_vec bfd_elf32_ntradlittlemips_freebsd_vec bfd_elf64_tradlittlemips_freebsd_vec bfd_elf32_ntradbigmips_freebsd_vec bfd_elf64_tradbigmips_freebsd_vec"
     # Generic vectors
     targ_selvecs="${targ_selvecs} bfd_elf32_tradlittlemips_vec bfd_elf32_tradbigmips_vec bfd_elf32_ntradlittlemips_vec bfd_elf64_tradlittlemips_vec bfd_elf32_ntradbigmips_vec bfd_elf64_tradbigmips_vec"
-    want64=true
     ;;
   mips*-*-freebsd* | mips*-*-kfreebsd*-gnu)
     # FreeBSD vectors
@@ -1022,9 +1095,7 @@
     targ_selvecs="bfd_elf32_tradlittlemips_freebsd_vec bfd_elf32_ntradbigmips_freebsd_vec bfd_elf64_tradbigmips_freebsd_vec bfd_elf32_ntradlittlemips_freebsd_vec bfd_elf64_tradlittlemips_freebsd_vec"
     # Generic vectors
     targ_selvecs="${targ_selvecs} bfd_elf32_tradbigmips_vec bfd_elf32_tradlittlemips_vec bfd_elf32_ntradbigmips_vec bfd_elf64_tradbigmips_vec bfd_elf32_ntradlittlemips_vec bfd_elf64_tradlittlemips_vec"
-    want64=true
     ;;
-#ifdef BFD64
   mmix-*-*)
     targ_defvec=bfd_elf64_mmix_vec
     targ_selvecs=bfd_mmo_vec
@@ -1046,6 +1117,7 @@
 
   msp430-*-*)
     targ_defvec=bfd_elf32_msp430_vec
+    targ_selvecs=bfd_elf32_msp430_ti_vec
     ;;
 
   ns32k-pc532-mach* | ns32k-pc532-ux*)
@@ -1057,6 +1129,21 @@
     targ_underscore=yes
     ;;
 
+  nios2eb-*-*)
+    targ_defvec=bfd_elf32_bignios2_vec
+    targ_selvecs=bfd_elf32_littlenios2_vec
+    ;;
+
+  nios2el-*-*)
+    targ_defvec=bfd_elf32_littlenios2_vec
+    targ_selvecs=bfd_elf32_bignios2_vec
+    ;;
+
+  nios2-*-*)
+    targ_defvec=bfd_elf32_littlenios2_vec
+    targ_selvecs=bfd_elf32_bignios2_vec
+    ;;
+
   openrisc-*-elf)
     targ_defvec=bfd_elf32_openrisc_vec
     ;;
@@ -1128,18 +1215,29 @@
     targ_selvecs=rs6000coff_vec
     want64=true
     ;;
+  powerpc64-*-freebsd*)
+    targ_defvec=bfd_elf64_powerpc_freebsd_vec
+    targ_selvecs="bfd_elf64_powerpc_vec bfd_elf32_powerpc_vec bfd_elf32_powerpc_freebsd_vec bfd_elf32_powerpcle_vec rs6000coff_vec rs6000coff64_vec aix5coff64_vec"
+    want64=true
+    ;;
   powerpc64-*-elf* | powerpc-*-elf64* | powerpc64-*-linux* | \
   powerpc64-*-*bsd*)
     targ_defvec=bfd_elf64_powerpc_vec
     targ_selvecs="bfd_elf64_powerpcle_vec bfd_elf32_powerpc_vec bfd_elf32_powerpcle_vec rs6000coff_vec rs6000coff64_vec aix5coff64_vec"
     want64=true
     ;;
-  powerpc64le-*-elf* | powerpcle-*-elf64*)
+  powerpc64le-*-elf* | powerpcle-*-elf64* | powerpc64le-*-linux* | \
+  powerpc64le-*-*bsd*)
     targ_defvec=bfd_elf64_powerpcle_vec
     targ_selvecs="bfd_elf64_powerpc_vec bfd_elf32_powerpcle_vec bfd_elf32_powerpc_vec rs6000coff_vec rs6000coff64_vec aix5coff64_vec"
     want64=true
     ;;
 #endif
+  powerpc-*-*freebsd*)
+    targ_defvec=bfd_elf32_powerpc_freebsd_vec
+    targ_selvecs="rs6000coff_vec bfd_elf32_powerpc_vec bfd_elf32_powerpcle_vec ppcboot_vec"
+    targ64_selvecs="bfd_elf64_powerpc_vec bfd_elf64_powerpcle_vec bfd_elf64_powerpc_freebsd_vec"
+    ;;
   powerpc-*-*bsd* | powerpc-*-elf* | powerpc-*-sysv4* | powerpc-*-eabi* | \
   powerpc-*-solaris2* | powerpc-*-linux-* | powerpc-*-rtems* | \
   powerpc-*-chorus*)
@@ -1193,6 +1291,10 @@
     targ_selvecs="bfd_powerpcle_pei_vec bfd_powerpc_pei_vec bfd_powerpcle_pe_vec bfd_powerpc_pe_vec"
     ;;
 
+  rl78-*-elf)
+    targ_defvec=bfd_elf32_rl78_vec
+    ;;
+
   rx-*-elf)
     targ_defvec=bfd_elf32_rx_le_vec
     targ_selvecs="bfd_elf32_rx_be_vec bfd_elf32_rx_le_vec bfd_elf32_rx_be_ns_vec"
@@ -1488,8 +1590,12 @@
 
 #ifdef BFD64
   tilegx-*-*)
-    targ_defvec=bfd_elf64_tilegx_vec
-    targ_selvecs=bfd_elf32_tilegx_vec
+    targ_defvec=bfd_elf64_tilegx_le_vec
+    targ_selvecs="bfd_elf64_tilegx_be_vec bfd_elf32_tilegx_be_vec bfd_elf32_tilegx_le_vec"
+    ;;
+  tilegxbe-*-*)
+    targ_defvec=bfd_elf64_tilegx_be_vec
+    targ_selvecs="bfd_elf64_tilegx_le_vec bfd_elf32_tilegx_be_vec bfd_elf32_tilegx_le_vec"
     ;;
 #endif
 
@@ -1499,6 +1605,7 @@
 
   v850*-*-*)
     targ_defvec=bfd_elf32_v850_vec
+    targ_selvecs="bfd_elf32_v850_rh850_vec"
     ;;
 
   vax-*-netbsdelf*)
@@ -1533,7 +1640,12 @@
   w65-*-*)
     targ_defvec=w65_vec
     ;;
-
+    
+  xgate-*-*)
+    targ_defvec=bfd_elf32_xgate_vec
+    targ_selvecs="bfd_elf32_xgate_vec"
+    ;;
+ 	
   xstormy16-*-elf)
     targ_defvec=bfd_elf32_xstormy16_vec
     ;;
@@ -1582,6 +1694,13 @@
     ;;
 esac
 
+# All MIPS ELF targets need a 64-bit bfd_vma.
+case "${targ_defvec} ${targ_selvecs}" in
+  *elf*mips*)
+    want64=true
+    ;;
+esac
+
 case "${host64}${want64}" in
   *true*)
     targ_selvecs="${targ_selvecs} ${targ64_selvecs}"
diff --git a/bfd/config.in b/bfd/config.in
index 98157e1..65fb044 100644
--- a/bfd/config.in
+++ b/bfd/config.in
@@ -1,5 +1,12 @@
 /* config.in.  Generated from configure.in by autoheader.  */
 
+/* Check that config.h is #included before system headers
+    (this works only for glibc, but that should be enough).  */
+#if defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__CONFIG_H__)
+#  error config.h must be #included before system headers
+#endif
+#define __CONFIG_H__ 1
+
 /* Name of host specific core header file to include in elf.c. */
 #undef CORE_HEADER
 
@@ -105,6 +112,9 @@
 /* Define to 1 if you have the `getpagesize' function. */
 #undef HAVE_GETPAGESIZE
 
+/* Define to 1 if you have the `getrlimit' function. */
+#undef HAVE_GETRLIMIT
+
 /* Define to 1 if you have the `getuid' function. */
 #undef HAVE_GETUID
 
@@ -227,6 +237,9 @@
 /* Define to 1 if you have the <sys/procfs.h> header file. */
 #undef HAVE_SYS_PROCFS_H
 
+/* Define to 1 if you have the <sys/resource.h> header file. */
+#undef HAVE_SYS_RESOURCE_H
+
 /* Define to 1 if you have the <sys/stat.h> header file. */
 #undef HAVE_SYS_STAT_H
 
@@ -245,6 +258,9 @@
 /* Define if <sys/procfs.h> has win32_pstatus_t. */
 #undef HAVE_WIN32_PSTATUS_T
 
+/* Define to 1 if you have the <windows.h> header file. */
+#undef HAVE_WINDOWS_H
+
 /* Define to 1 if you have the <zlib.h> header file. */
 #undef HAVE_ZLIB_H
 
diff --git a/bfd/configure b/bfd/configure
index bc242b9..90cd397 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.64.
+# Generated by GNU Autoconf 2.64 for bfd 2.24.
 #
 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
 # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software
@@ -554,12 +554,12 @@
 MAKEFLAGS=
 
 # Identity of this package.
-PACKAGE_NAME=
-PACKAGE_TARNAME=
-PACKAGE_VERSION=
-PACKAGE_STRING=
-PACKAGE_BUGREPORT=
-PACKAGE_URL=
+PACKAGE_NAME='bfd'
+PACKAGE_TARNAME='bfd'
+PACKAGE_VERSION='2.24'
+PACKAGE_STRING='bfd 2.24'
+PACKAGE_BUGREPORT=''
+PACKAGE_URL=''
 
 ac_unique_file="libbfd.c"
 # Factoring default headers for most tests.
@@ -606,6 +606,7 @@
 tdefaults
 bfd_ufile_ptr
 bfd_file_ptr
+lt_cv_dlopen_libs
 supports_plugins
 bfd_default_target_size
 bfd_machines
@@ -847,7 +848,7 @@
 localstatedir='${prefix}/var'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
-docdir='${datarootdir}/doc/${PACKAGE}'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
 infodir='${datarootdir}/info'
 htmldir='${docdir}'
 dvidir='${docdir}'
@@ -1348,7 +1349,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures this package to adapt to many kinds of systems.
+\`configure' configures bfd 2.24 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1396,7 +1397,7 @@
   --infodir=DIR           info documentation [DATAROOTDIR/info]
   --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
   --mandir=DIR            man documentation [DATAROOTDIR/man]
-  --docdir=DIR            documentation root [DATAROOTDIR/doc/PACKAGE]
+  --docdir=DIR            documentation root [DATAROOTDIR/doc/bfd]
   --htmldir=DIR           html documentation [DOCDIR]
   --dvidir=DIR            dvi documentation [DOCDIR]
   --pdfdir=DIR            pdf documentation [DOCDIR]
@@ -1418,7 +1419,9 @@
 fi
 
 if test -n "$ac_init_help"; then
-
+  case $ac_init_help in
+     short | recursive ) echo "Configuration of bfd 2.24:";;
+   esac
   cat <<\_ACEOF
 
 Optional Features:
@@ -1538,7 +1541,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-configure
+bfd configure 2.24
 generated by GNU Autoconf 2.64
 
 Copyright (C) 2009 Free Software Foundation, Inc.
@@ -2180,7 +2183,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by $as_me, which was
+It was created by bfd $as_me 2.24, which was
 generated by GNU Autoconf 2.64.  Invocation command line was
 
   $ $0 $@
@@ -3987,8 +3990,8 @@
 
 
 # Define the identity of the package.
- PACKAGE=bfd
- VERSION=2.22
+ PACKAGE='bfd'
+ VERSION='2.24'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -7203,7 +7206,7 @@
   rm -rf conftest*
   ;;
 
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
   # Find out which ABI we are using.
   echo 'int i;' > conftest.$ac_ext
@@ -7219,9 +7222,19 @@
 	    LD="${LD-ld} -m elf_i386_fbsd"
 	    ;;
 	  x86_64-*linux*)
-	    LD="${LD-ld} -m elf_i386"
+	    case `/usr/bin/file conftest.o` in
+	      *x86-64*)
+		LD="${LD-ld} -m elf32_x86_64"
+		;;
+	      *)
+		LD="${LD-ld} -m elf_i386"
+		;;
+	    esac
 	    ;;
-	  ppc64-*linux*|powerpc64-*linux*)
+	  powerpc64le-*linux*)
+	    LD="${LD-ld} -m elf32lppclinux"
+	    ;;
+	  powerpc64-*linux*)
 	    LD="${LD-ld} -m elf32ppclinux"
 	    ;;
 	  s390x-*linux*)
@@ -7240,7 +7253,10 @@
 	  x86_64-*linux*)
 	    LD="${LD-ld} -m elf_x86_64"
 	    ;;
-	  ppc*-*linux*|powerpc*-*linux*)
+	  powerpcle-*linux*)
+	    LD="${LD-ld} -m elf64lppc"
+	    ;;
+	  powerpc-*linux*)
 	    LD="${LD-ld} -m elf64ppc"
 	    ;;
 	  s390*-*linux*|s390*-*tpf*)
@@ -8458,6 +8474,7 @@
 	# AIX 5 now supports IA64 processor
 	lt_prog_compiler_static='-Bstatic'
       fi
+      lt_prog_compiler_pic='-fPIC'
       ;;
 
     amigaos*)
@@ -9639,7 +9656,7 @@
       ;;
 
     # Unfortunately, older versions of FreeBSD 2 do not have this feature.
-    freebsd2*)
+    freebsd2.*)
       archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
       hardcode_direct=yes
       hardcode_minus_L=yes
@@ -10552,7 +10569,7 @@
     objformat=`/usr/bin/objformat`
   else
     case $host_os in
-    freebsd[123]*) objformat=aout ;;
+    freebsd[23].*) objformat=aout ;;
     *) objformat=elf ;;
     esac
   fi
@@ -10570,7 +10587,7 @@
   esac
   shlibpath_var=LD_LIBRARY_PATH
   case $host_os in
-  freebsd2*)
+  freebsd2.*)
     shlibpath_overrides_runpath=yes
     ;;
   freebsd3.[01]* | freebsdelf3.[01]*)
@@ -11404,7 +11421,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11407 "configure"
+#line 11424 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11510,7 +11527,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11513 "configure"
+#line 11530 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12217,6 +12234,9 @@
 ac_config_headers="$ac_config_headers config.h:config.in"
 
 
+# PR 14072
+
+
 if test -z "$target" ; then
     as_fn_error "Unrecognized target system type; please check config.sub." "$LINENO" 5
 fi
@@ -12316,7 +12336,7 @@
 
 # host stuff:
 
-ALL_LINGUAS="fr tr ja es sv da zh_CN ro rw vi fi id ru"
+ALL_LINGUAS="fr tr ja es sv da zh_CN ro rw vi fi id ru uk"
 # If we haven't got the data from the intl directory,
 # assume NLS is disabled.
 USE_NLS=no
@@ -12894,7 +12914,7 @@
 
 done
 
-for ac_header in fcntl.h sys/file.h sys/time.h sys/stat.h
+for ac_header in fcntl.h sys/file.h sys/time.h sys/stat.h sys/resource.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -13508,6 +13528,22 @@
 
 fi
 
+
+for ac_header in windows.h dlfcn.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether string.h and strings.h may both be included" >&5
 $as_echo_n "checking whether string.h and strings.h may both be included... " >&6; }
 if test "${gcc_cv_header_string+set}" = set; then :
@@ -13553,12 +13589,14 @@
 fi
 done
 
-for ac_func in strtoull
+for ac_func in strtoull getrlimit
 do :
-  ac_fn_c_check_func "$LINENO" "strtoull" "ac_cv_func_strtoull"
-if test "x$ac_cv_func_strtoull" = x""yes; then :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
   cat >>confdefs.h <<_ACEOF
-#define HAVE_STRTOULL 1
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
 
 fi
@@ -13897,6 +13935,10 @@
   i[3-7]86-*-linux-*)
 	COREFILE=trad-core.lo
 	TRAD_HEADER='"hosts/i386linux.h"'
+	case "$enable_targets"-"$want64" in
+	*x86_64-*linux*|*-true)
+	  CORE_HEADER='"hosts/x86-64linux.h"'
+	esac
 	;;
   i[3-7]86-*-isc*)	COREFILE=trad-core.lo ;;
   i[3-7]86-*-aix*)	COREFILE=aix386-core.lo ;;
@@ -15184,14 +15226,17 @@
     bfd_elf32_bfinfdpic_vec)	tb="$tb elf32-bfin.lo elf32.lo $elf" ;;
     bfd_elf32_big_generic_vec) 	tb="$tb elf32-gen.lo elf32.lo $elf" ;;
     bfd_elf32_bigarc_vec)	tb="$tb elf32-arc.lo elf32.lo $elf" ;;
-    bfd_elf32_bigarm_vec)	tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;;
+    bfd_elf32_bigarm_vec)	tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;;
+    bfd_elf32_bigarm_nacl_vec)	tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;;
     bfd_elf32_bigarm_symbian_vec)
-                                tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;;
+                                tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;;
     bfd_elf32_bigarm_vxworks_vec)
-                                tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;;
+                                tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;;
     bfd_elf32_bigmips_vec) 	tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;;
     bfd_elf32_bigmips_vxworks_vec)
 			 	tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;;
+    bfd_elf32_bigmoxie_vec)	tb="$tb elf32-moxie.lo elf32.lo $elf" ;;
+    bfd_elf32_bignios2_vec)	tb="$tb elf32-nios2.lo elf32.lo $elf" ;;
     bfd_elf32_cr16_vec)		tb="$tb elf32-cr16.lo elf32.lo $elf" ;;
     bfd_elf32_cr16c_vec)	tb="$tb elf32-cr16c.lo elf32.lo $elf" ;;
     bfd_elf32_cris_vec)		tb="$tb elf32-cris.lo elf32.lo $elf" ;;
@@ -15199,20 +15244,20 @@
     bfd_elf32_d10v_vec)		tb="$tb elf32-d10v.lo elf32.lo $elf" ;;
     bfd_elf32_d30v_vec)		tb="$tb elf32-d30v.lo elf32.lo $elf" ;;
     bfd_elf32_dlx_big_vec)	tb="$tb elf32-dlx.lo elf32.lo $elf" ;;
+    bfd_elf32_epiphany_vec)	tb="$tb elf32-epiphany.lo elf32.lo $elf" ;;
     bfd_elf32_fr30_vec)		tb="$tb elf32-fr30.lo elf32.lo $elf" ;;
     bfd_elf32_frv_vec)		tb="$tb elf32-frv.lo elf32.lo $elf" ;;
     bfd_elf32_frvfdpic_vec)	tb="$tb elf32-frv.lo elf32.lo $elf" ;;
-    bfd_elf32_moxie_vec)	tb="$tb elf32-moxie.lo elf32.lo $elf" ;;
     bfd_elf32_h8300_vec)	tb="$tb elf32-h8300.lo elf32.lo $elf" ;;
     bfd_elf32_hppa_linux_vec)	tb="$tb elf32-hppa.lo elf32.lo $elf" ;;
     bfd_elf32_hppa_nbsd_vec)	tb="$tb elf32-hppa.lo elf32.lo $elf" ;;
     bfd_elf32_hppa_vec)		tb="$tb elf32-hppa.lo elf32.lo $elf" ;;
     bfd_elf32_i370_vec)		tb="$tb elf32-i370.lo elf32.lo $elf" ;;
-    bfd_elf32_i386_sol2_vec)	tb="$tb elf32-i386.lo elf-ifunc.lo elf-vxworks.lo elf32.lo $elf" ;;
-    bfd_elf32_i386_freebsd_vec)	tb="$tb elf32-i386.lo elf-ifunc.lo elf-vxworks.lo elf32.lo $elf" ;;
-    bfd_elf32_i386_nacl_vec)	tb="$tb elf32-i386.lo elf-ifunc.lo elf-vxworks.lo elf32.lo $elf" ;;
-    bfd_elf32_i386_vxworks_vec)	tb="$tb elf32-i386.lo elf-ifunc.lo elf-vxworks.lo elf32.lo $elf" ;;
-    bfd_elf32_i386_vec)		tb="$tb elf32-i386.lo elf-ifunc.lo elf-vxworks.lo elf32.lo $elf" ;;
+    bfd_elf32_i386_sol2_vec)	tb="$tb elf32-i386.lo elf-ifunc.lo elf-nacl.lo elf-vxworks.lo elf32.lo $elf" ;;
+    bfd_elf32_i386_freebsd_vec)	tb="$tb elf32-i386.lo elf-ifunc.lo elf-nacl.lo elf-vxworks.lo elf32.lo $elf" ;;
+    bfd_elf32_i386_nacl_vec)	tb="$tb elf32-i386.lo elf-ifunc.lo elf-nacl.lo elf-vxworks.lo elf32.lo $elf" ;;
+    bfd_elf32_i386_vxworks_vec)	tb="$tb elf32-i386.lo elf-ifunc.lo elf-nacl.lo elf-vxworks.lo elf32.lo $elf" ;;
+    bfd_elf32_i386_vec)		tb="$tb elf32-i386.lo elf-ifunc.lo elf-nacl.lo elf-vxworks.lo elf32.lo $elf" ;;
     bfd_elf32_i860_little_vec)	tb="$tb elf32-i860.lo elf32.lo $elf" ;;
     bfd_elf32_i860_vec)		tb="$tb elf32-i860.lo elf32.lo $elf" ;;
     bfd_elf32_i960_vec)		tb="$tb elf32-i960.lo elf32.lo $elf" ;;
@@ -15225,13 +15270,16 @@
     bfd_elf32_little_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;;
     bfd_elf32_littlearc_vec)	tb="$tb elf32-arc.lo elf32.lo $elf" ;;
     bfd_elf32_littlearm_symbian_vec)
-                                tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;;
+                                tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;;
     bfd_elf32_littlearm_vxworks_vec)
-                                tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;;
-    bfd_elf32_littlearm_vec)	tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;;
+                                tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;;
+    bfd_elf32_littlearm_vec)	tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;;
+    bfd_elf32_littlearm_nacl_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;;
     bfd_elf32_littlemips_vec) 	tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;;
     bfd_elf32_littlemips_vxworks_vec)
 			 	tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;;
+    bfd_elf32_littlemoxie_vec)	tb="$tb elf32-moxie.lo elf32.lo $elf" ;;
+    bfd_elf32_littlenios2_vec)	tb="$tb elf32-nios2.lo elf32.lo $elf" ;;
     bfd_elf32_m32c_vec)         tb="$tb elf32-m32c.lo elf32.lo $elf" ;;
     bfd_elf32_m32r_vec)		tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
     bfd_elf32_m32rle_vec)       tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
@@ -15245,11 +15293,14 @@
     bfd_elf32_mcore_little_vec)	tb="$tb elf32-mcore.lo elf32.lo $elf" ;;
     bfd_elf32_mep_vec)		tb="$tb elf32-mep.lo elf32.lo $elf" ;;
     bfd_elf32_mep_little_vec)	tb="$tb elf32-mep.lo elf32.lo $elf" ;;
+    bfd_elf32_metag_vec)	tb="$tb elf32-metag.lo elf32.lo $elf" ;;
+    bfd_elf32_microblazeel_vec)	tb="$tb elf32-microblaze.lo elf32.lo $elf" ;;
     bfd_elf32_microblaze_vec)	tb="$tb elf32-microblaze.lo elf32.lo $elf" ;;
     bfd_elf32_mn10200_vec)	tb="$tb elf-m10200.lo elf32.lo $elf" ;;
     bfd_elf32_mn10300_vec)	tb="$tb elf-m10300.lo elf32.lo $elf" ;;
     bfd_elf32_mt_vec)           tb="$tb elf32-mt.lo elf32.lo $elf" ;;
     bfd_elf32_msp430_vec)	tb="$tb elf32-msp430.lo elf32.lo $elf" ;;
+    bfd_elf32_msp430_ti_vec)	tb="$tb elf32-msp430.lo elf32.lo $elf" ;;
     bfd_elf32_nbigmips_vec)	tb="$tb elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
     bfd_elf32_nlittlemips_vec)	tb="$tb elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
     bfd_elf32_ntradbigmips_vec | bfd_elf32_ntradbigmips_freebsd_vec)
@@ -15262,7 +15313,9 @@
     bfd_elf32_pjl_vec)          tb="$tb elf32-pj.lo elf32.lo $elf";;
     bfd_elf32_powerpc_vec)	tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;;
     bfd_elf32_powerpcle_vec)	tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;;
+    bfd_elf32_powerpc_freebsd_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;;
     bfd_elf32_powerpc_vxworks_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;;
+    bfd_elf32_rl78_vec)         tb="$tb elf32-rl78.lo $elf" ;;
     bfd_elf32_rx_le_vec)        tb="$tb elf32-rx.lo elf32.lo $elf" ;;
     bfd_elf32_rx_be_vec)        tb="$tb elf32-rx.lo elf32.lo $elf" ;;
     bfd_elf32_rx_be_ns_vec)     tb="$tb elf32-rx.lo elf32.lo $elf" ;;
@@ -15299,7 +15352,8 @@
     bfd_elf32_tic6x_linux_le_vec) tb="$tb elf32-tic6x.lo elf32.lo $elf" ;;
     bfd_elf32_tic6x_elf_be_vec) tb="$tb elf32-tic6x.lo elf32.lo $elf" ;;
     bfd_elf32_tic6x_elf_le_vec) tb="$tb elf32-tic6x.lo elf32.lo $elf" ;;
-    bfd_elf32_tilegx_vec)	tb="$tb elf32-tilegx.lo elfxx-tilegx.lo elf32.lo $elf" ; target_size=32 ;;
+    bfd_elf32_tilegx_be_vec)	tb="$tb elf32-tilegx.lo elfxx-tilegx.lo elf32.lo $elf" ; target_size=32 ;;
+    bfd_elf32_tilegx_le_vec)	tb="$tb elf32-tilegx.lo elfxx-tilegx.lo elf32.lo $elf" ; target_size=32 ;;
     bfd_elf32_tilepro_vec)	tb="$tb elf32-tilepro.lo elf32.lo $elf" ;;
     bfd_elf32_tradbigmips_vec | bfd_elf32_tradbigmips_freebsd_vec)
 				tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;;
@@ -15307,13 +15361,17 @@
 				tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;;
     bfd_elf32_us_cris_vec)	tb="$tb elf32-cris.lo elf32.lo $elf" ;;
     bfd_elf32_v850_vec)		tb="$tb elf32-v850.lo elf32.lo $elf" ;;
+    bfd_elf32_v850_rh850_vec)	tb="$tb elf32-v850.lo elf32.lo $elf" ;;
     bfd_elf32_vax_vec)		tb="$tb elf32-vax.lo elf32.lo $elf" ;;
     bfd_elf32_xstormy16_vec)	tb="$tb elf32-xstormy16.lo elf32.lo $elf" ;;
     bfd_elf32_xc16x_vec)		tb="$tb elf32-xc16x.lo elf32.lo $elf" ;;
+    bfd_elf32_xgate_vec)  	tb="$tb elf32-xgate.lo elf32.lo $elf" ;;
     bfd_elf32_xtensa_le_vec)	tb="$tb xtensa-isa.lo xtensa-modules.lo elf32-xtensa.lo elf32.lo $elf" ;;
     bfd_elf32_xtensa_be_vec)	tb="$tb xtensa-isa.lo xtensa-modules.lo elf32-xtensa.lo elf32.lo $elf" ;;
     bfd_elf64_alpha_freebsd_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_alpha_vec)	tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf64_bigaarch64_vec)	tb="$tb elf64-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf32_bigaarch64_vec)	tb="$tb elf32-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf32.lo $elf"; target_size=64 ;;
     bfd_elf64_big_generic_vec) 	tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_bigmips_vec) 	tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
     bfd_elf64_hppa_linux_vec)	tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;;
@@ -15321,12 +15379,15 @@
     bfd_elf64_ia64_big_vec)	tb="$tb elf64-ia64.lo elfxx-ia64.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_ia64_hpux_big_vec) tb="$tb elf64-ia64.lo elfxx-ia64.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_ia64_little_vec)	tb="$tb elf64-ia64.lo elfxx-ia64.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_ia64_vms_vec)	tb="$tb elf64-ia64.lo elfxx-ia64.lo  elf64.lo vms-lib.lo vms-misc.lo $elf"; target_size=64 ;;
+    bfd_elf64_ia64_vms_vec)	tb="$tb elf64-ia64-vms.lo elf64-ia64.lo elfxx-ia64.lo elf64.lo vms-lib.lo vms-misc.lo $elf"; target_size=64 ;;
+    bfd_elf64_littleaarch64_vec)tb="$tb elf64-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf32_littleaarch64_vec)tb="$tb elf32-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf32.lo $elf"; target_size=64 ;;
     bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_littlemips_vec) 	tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
     bfd_elf64_mmix_vec) 	tb="$tb elf64-mmix.lo elf64.lo $elf" target_size=64 ;;
     bfd_elf64_powerpc_vec)	tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_powerpcle_vec)	tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;;
+    bfd_elf64_powerpc_freebsd_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;;
     bfd_elf64_s390_vec)		tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_sh64_vec)		tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
     bfd_elf64_sh64l_vec)	tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
@@ -15337,19 +15398,22 @@
     bfd_elf64_sparc_vec)	tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_sparc_freebsd_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_sparc_sol2_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_tilegx_vec)	tb="$tb elf64-tilegx.lo elfxx-tilegx.lo elf64.lo $elf" ; target_size=64 ;;
+    bfd_elf64_tilegx_be_vec)	tb="$tb elf64-tilegx.lo elfxx-tilegx.lo elf64.lo $elf" ; target_size=64 ;;
+    bfd_elf64_tilegx_le_vec)	tb="$tb elf64-tilegx.lo elfxx-tilegx.lo elf64.lo $elf" ; target_size=64 ;;
     bfd_elf64_tradbigmips_vec | bfd_elf64_tradbigmips_freebsd_vec)
 				tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
     bfd_elf64_tradlittlemips_vec | bfd_elf64_tradlittlemips_freebsd_vec)
 				tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
-    bfd_elf64_x86_64_freebsd_vec) tb="$tb elf64-x86-64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_x86_64_sol2_vec)  tb="$tb elf64-x86-64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_x86_64_vec)	tb="$tb elf64-x86-64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf32_x86_64_vec)	tb="$tb elf64-x86-64.lo elf-ifunc.lo elf64.lo elf32.lo $elf"; target_size=64 ;;
-    bfd_elf64_l1om_vec)		tb="$tb elf64-x86-64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_l1om_freebsd_vec) tb="$tb elf64-x86-64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_k1om_vec)		tb="$tb elf64-x86-64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_k1om_freebsd_vec) tb="$tb elf64-x86-64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf64_x86_64_freebsd_vec) tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf64_x86_64_nacl_vec)	tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf64_x86_64_sol2_vec)  tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf64_x86_64_vec)	tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf32_x86_64_vec)	tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo elf32.lo $elf"; target_size=64 ;;
+    bfd_elf32_x86_64_nacl_vec)	tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo elf32.lo $elf"; target_size=64 ;;
+    bfd_elf64_l1om_vec)		tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf64_l1om_freebsd_vec) tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf64_k1om_vec)		tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf64_k1om_freebsd_vec) tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo $elf"; target_size=64 ;;
     bfd_mmo_vec)		tb="$tb mmo.lo" target_size=64 ;;
     bfd_powerpc_pe_vec)         tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;;
     bfd_powerpc_pei_vec)        tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;;
@@ -15590,6 +15654,7 @@
 fi
 
 
+
 # Determine the host dependant file_ptr a.k.a. off_t type.  In order
 # prefer: off64_t - if ftello64 and fseeko64, off_t - if ftello and
 # fseeko, long.  This assumes that sizeof off_t is .ge. sizeof long.
@@ -16416,7 +16481,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by $as_me, which was
+This file was extended by bfd $as_me 2.24, which was
 generated by GNU Autoconf 2.64.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -16480,7 +16545,7 @@
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_version="\\
-config.status
+bfd config.status 2.24
 configured by $0, generated by GNU Autoconf 2.64,
   with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 
@@ -18744,4 +18809,3 @@
 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
 fi
 
-
diff --git a/bfd/configure.com b/bfd/configure.com
index a19dadd..e1c3242 100644
--- a/bfd/configure.com
+++ b/bfd/configure.com
@@ -7,6 +7,22 @@
 $! Written by Klaus K"ampf ([email protected])
 $! Rewritten by Tristan Gingold ([email protected])
 $!
+$!   Copyright 2012 Free Software Foundation
+$!
+$! This file is free software; you can redistribute it and/or modify
+$! it under the terms of the GNU General Public License as published by
+$! the Free Software Foundation; either version 3 of the License, or
+$! (at your option) any later version.
+$! 
+$! This program is distributed in the hope that it will be useful,
+$! but WITHOUT ANY WARRANTY; without even the implied warranty of
+$! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+$! GNU General Public License for more details.
+$! 
+$! You should have received a copy of the GNU General Public License
+$! along with this program; see the file COPYING3.  If not see
+$! <http://www.gnu.org/licenses/>.
+$!
 $ arch=F$GETSYI("ARCH_NAME")
 $ arch=F$EDIT(arch,"LOWERCASE")
 $if arch .eqs. "alpha" then target = "alpha"
@@ -28,26 +44,10 @@
 !
 !
    set (success,off);
-   vfile := CREATE_BUFFER("vfile", "CONFIGURE.IN");
-   rang := CREATE_RANGE(BEGINNING_OF(vfile), END_OF(vfile));
-   match_pos := SEARCH_QUIETLY('AM_INIT_AUTOMAKE(bfd, ', FORWARD, EXACT, rang);
-   IF match_pos <> 0 THEN;
-     POSITION(BEGINNING_OF(match_pos));
-     ERASE(match_pos);
-     vers := CURRENT_LINE-")";
-   ELSE;
-     vers := "unknown";
-   ENDIF;
 
    file := CREATE_BUFFER("file", GET_INFO(COMMAND_LINE, "file_name"));
    rang := CREATE_RANGE(BEGINNING_OF(file), END_OF(file));
 
-   match_pos := SEARCH_QUIETLY('@VERSION@', FORWARD, EXACT, rang);
-   IF match_pos <> 0 THEN;
-      POSITION(BEGINNING_OF(match_pos));
-      ERASE(match_pos);
-      COPY_TEXT(vers);
-   ENDIF;
    match_pos := SEARCH_QUIETLY('@wordsize@', FORWARD, EXACT, rang);
    IF match_pos <> 0 THEN;
       POSITION(BEGINNING_OF(match_pos));
@@ -82,27 +82,25 @@
    IF match_pos <> 0 THEN;
       POSITION(BEGINNING_OF(match_pos));
       ERASE(match_pos);
-      COPY_TEXT('__DECC');
-      SPLIT_LINE;
-      COPY_TEXT('#include <ints.h>');
+      COPY_TEXT('1');
    ENDIF;
    match_pos := SEARCH_QUIETLY('@BFD_HOST_64_BIT@', FORWARD, EXACT, rang);
    IF match_pos <> 0 THEN;
       POSITION(BEGINNING_OF(match_pos));
       ERASE(match_pos);
-      COPY_TEXT('int64');
+      COPY_TEXT('__int64');
    ENDIF;
    match_pos := SEARCH_QUIETLY('@BFD_HOST_U_64_BIT@', FORWARD, EXACT, rang);
    IF match_pos <> 0 THEN;
       POSITION(BEGINNING_OF(match_pos));
       ERASE(match_pos);
-      COPY_TEXT('uint64');
+      COPY_TEXT('unsigned __int64');
    ENDIF;
    match_pos := SEARCH_QUIETLY('@BFD_HOSTPTR_T@', FORWARD, EXACT, rang);
    IF match_pos <> 0 THEN;
       POSITION(BEGINNING_OF(match_pos));
       ERASE(match_pos);
-      COPY_TEXT('uint64');
+      COPY_TEXT('unsigned __int64');
    ENDIF;
    match_pos := SEARCH_QUIETLY('@bfd_file_ptr@', FORWARD, EXACT, rang);
    IF match_pos <> 0 THEN;
@@ -142,26 +140,10 @@
 !
 !
    set (success,off);
-   vfile := CREATE_BUFFER("vfile", "CONFIGURE.IN");
-   rang := CREATE_RANGE(BEGINNING_OF(vfile), END_OF(vfile));
-   match_pos := SEARCH_QUIETLY('AM_INIT_AUTOMAKE(bfd, ', FORWARD, EXACT, rang);
-   IF match_pos <> 0 THEN;
-     POSITION(BEGINNING_OF(match_pos));
-     ERASE(match_pos);
-     vers := CURRENT_LINE-")";
-   ELSE;
-     vers := "unknown";
-   ENDIF;
 
    file := CREATE_BUFFER("file", GET_INFO(COMMAND_LINE, "file_name"));
    rang := CREATE_RANGE(BEGINNING_OF(file), END_OF(file));
 
-   match_pos := SEARCH_QUIETLY('@VERSION@', FORWARD, EXACT, rang);
-   IF match_pos <> 0 THEN;
-      POSITION(BEGINNING_OF(match_pos));
-      ERASE(match_pos);
-      COPY_TEXT(vers);
-   ENDIF;
    match_pos := SEARCH_QUIETLY('@wordsize@', FORWARD, EXACT, rang);
    IF match_pos <> 0 THEN;
       POSITION(BEGINNING_OF(match_pos));
@@ -213,11 +195,11 @@
    set (success,off);
    vfile := CREATE_BUFFER("vfile", "configure.in");
    rang := CREATE_RANGE(BEGINNING_OF(vfile), END_OF(vfile));
-   match_pos := SEARCH_QUIETLY('AM_INIT_AUTOMAKE(bfd, ', FORWARD, EXACT, rang);
+   match_pos := SEARCH_QUIETLY('AC_INIT([bfd], [', FORWARD, EXACT, rang);
    IF match_pos <> 0 THEN;
      POSITION(BEGINNING_OF(match_pos));
      ERASE(match_pos);
-     vers := CURRENT_LINE-")";
+     vers := CURRENT_LINE-"])";
    ELSE;
      vers := "unknown";
    ENDIF;
@@ -324,6 +306,20 @@
 #define HAVE_UNISTD_H 1
 /* Disable NLS  */
 #undef ENABLE_NLS
+/* Name of package */
+#define PACKAGE "bfd"
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "bfd"
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "bfd"
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "bfd"
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "(package version)"
 $!
 $ write sys$output "Copy sysdep.h"
 $ copy [.hosts]alphavms.h sysdep.h
@@ -365,9 +361,6 @@
    WRITE_FILE(file, GET_INFO(COMMAND_LINE, "output_file"));
    QUIT
 $  EOD
-$ write sys$output "Generate elf64-ia64.c from elfxx-ia64.c"
-$ edit/tpu/nojournal/nosection/nodisplay/command=substxx.tpu -
-        []elfXX-ia64.c /output=[]elf64-ia64.c
 $ write sys$output "Generate elf64-target.h from elfxx-target.h"
 $ edit/tpu/nojournal/nosection/nodisplay/command=substxx.tpu -
         []elfXX-target.h /output=[]elf64-target.h
diff --git a/bfd/configure.host b/bfd/configure.host
index 7c63de5..7868c24 100644
--- a/bfd/configure.host
+++ b/bfd/configure.host
@@ -1,3 +1,20 @@
+#
+#   Copyright 2012 Free Software Foundation
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+#
 # This file is a shell script that overrides some of the tools and
 # flags used on a host specific basis.
 
diff --git a/bfd/configure.in b/bfd/configure.in
index 435aaaa..0e88d78 100644
--- a/bfd/configure.in
+++ b/bfd/configure.in
@@ -1,14 +1,30 @@
 dnl Process this file with autoconf to produce a configure script.
 dnl
+dnl   Copyright 2012-2013 Free Software Foundation
+dnl
+dnl This file is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3 of the License, or
+dnl (at your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; see the file COPYING3.  If not see
+dnl <http://www.gnu.org/licenses/>.
+dnl
 
 AC_PREREQ(2.59)
-AC_INIT
+AC_INIT([bfd], [2.24])
 AC_CONFIG_SRCDIR([libbfd.c])
 
 AC_CANONICAL_TARGET
 AC_ISC_POSIX
 
-AM_INIT_AUTOMAKE(bfd, 2.22)
+AM_INIT_AUTOMAKE
 
 dnl These must be called before LT_INIT, because it may want
 dnl to call AC_CHECK_PROG.
@@ -109,7 +125,7 @@
   AC_DEFINE(USE_STT_COMMON, 1,
     [Define if we may generate symbols with ELF's STT_COMMON type])
 fi
-	 
+
 ACX_PKGVERSION([GNU Binutils])
 ACX_BUGURL([http://www.sourceware.org/bugzilla/])
 
@@ -117,6 +133,15 @@
 
 AC_CONFIG_HEADERS(config.h:config.in)
 
+# PR 14072
+AH_VERBATIM([00_CONFIG_H_CHECK],
+[/* Check that config.h is #included before system headers
+    (this works only for glibc, but that should be enough).  */
+#if defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__CONFIG_H__)
+#  error config.h must be #included before system headers
+#endif
+#define __CONFIG_H__ 1])
+
 if test -z "$target" ; then
     AC_MSG_ERROR(Unrecognized target system type; please check config.sub.)
 fi
@@ -132,7 +157,7 @@
 
 # host stuff:
 
-ALL_LINGUAS="fr tr ja es sv da zh_CN ro rw vi fi id ru"
+ALL_LINGUAS="fr tr ja es sv da zh_CN ro rw vi fi id ru uk"
 ZW_GNU_GETTEXT_SISTER_DIR
 AM_PO_SUBDIRS
 
@@ -186,13 +211,16 @@
 BFD_CC_FOR_BUILD
 
 AC_CHECK_HEADERS(alloca.h stddef.h string.h strings.h stdlib.h time.h unistd.h)
-AC_CHECK_HEADERS(fcntl.h sys/file.h sys/time.h sys/stat.h)
+AC_CHECK_HEADERS(fcntl.h sys/file.h sys/time.h sys/stat.h sys/resource.h)
 GCC_HEADER_STDINT(bfd_stdint.h)
 AC_HEADER_TIME
 AC_HEADER_DIRENT
+
+AC_CHECK_HEADERS(windows.h dlfcn.h)
+
 ACX_HEADER_STRING
 AC_CHECK_FUNCS(fcntl getpagesize setitimer sysconf fdopen getuid getgid fileno)
-AC_CHECK_FUNCS(strtoull)
+AC_CHECK_FUNCS(strtoull getrlimit)
 
 AC_CHECK_DECLS(basename)
 AC_CHECK_DECLS(ftello)
@@ -319,6 +347,10 @@
 changequote([,])dnl
 	COREFILE=trad-core.lo
 	TRAD_HEADER='"hosts/i386linux.h"'
+	case "$enable_targets"-"$want64" in
+	*x86_64-*linux*|*-true)
+	  CORE_HEADER='"hosts/x86-64linux.h"'
+	esac
 	;;
 changequote(,)dnl
   i[3-7]86-*-isc*)	COREFILE=trad-core.lo ;;
@@ -683,35 +715,38 @@
     bfd_elf32_bfinfdpic_vec)	tb="$tb elf32-bfin.lo elf32.lo $elf" ;;
     bfd_elf32_big_generic_vec) 	tb="$tb elf32-gen.lo elf32.lo $elf" ;;
     bfd_elf32_bigarc_vec)	tb="$tb elf32-arc.lo elf32.lo $elf" ;;
-    bfd_elf32_bigarm_vec)	tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;;
-    bfd_elf32_bigarm_symbian_vec)	
-                                tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;;
-    bfd_elf32_bigarm_vxworks_vec)	
-                                tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;;
+    bfd_elf32_bigarm_vec)	tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;;
+    bfd_elf32_bigarm_nacl_vec)	tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;;
+    bfd_elf32_bigarm_symbian_vec)
+                                tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;;
+    bfd_elf32_bigarm_vxworks_vec)
+                                tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;;
     bfd_elf32_bigmips_vec) 	tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;;
     bfd_elf32_bigmips_vxworks_vec)
 			 	tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;;
+    bfd_elf32_bigmoxie_vec)	tb="$tb elf32-moxie.lo elf32.lo $elf" ;;
+    bfd_elf32_bignios2_vec)	tb="$tb elf32-nios2.lo elf32.lo $elf" ;;
     bfd_elf32_cr16_vec)		tb="$tb elf32-cr16.lo elf32.lo $elf" ;;
     bfd_elf32_cr16c_vec)	tb="$tb elf32-cr16c.lo elf32.lo $elf" ;;
     bfd_elf32_cris_vec)		tb="$tb elf32-cris.lo elf32.lo $elf" ;;
-    bfd_elf32_crx_vec)          tb="$tb elf32-crx.lo elf32.lo $elf" ;;    
+    bfd_elf32_crx_vec)          tb="$tb elf32-crx.lo elf32.lo $elf" ;;
     bfd_elf32_d10v_vec)		tb="$tb elf32-d10v.lo elf32.lo $elf" ;;
     bfd_elf32_d30v_vec)		tb="$tb elf32-d30v.lo elf32.lo $elf" ;;
     bfd_elf32_dlx_big_vec)	tb="$tb elf32-dlx.lo elf32.lo $elf" ;;
+    bfd_elf32_epiphany_vec)	tb="$tb elf32-epiphany.lo elf32.lo $elf" ;;
     bfd_elf32_fr30_vec)		tb="$tb elf32-fr30.lo elf32.lo $elf" ;;
     bfd_elf32_frv_vec)		tb="$tb elf32-frv.lo elf32.lo $elf" ;;
     bfd_elf32_frvfdpic_vec)	tb="$tb elf32-frv.lo elf32.lo $elf" ;;
-    bfd_elf32_moxie_vec)	tb="$tb elf32-moxie.lo elf32.lo $elf" ;;
     bfd_elf32_h8300_vec)	tb="$tb elf32-h8300.lo elf32.lo $elf" ;;
     bfd_elf32_hppa_linux_vec)	tb="$tb elf32-hppa.lo elf32.lo $elf" ;;
     bfd_elf32_hppa_nbsd_vec)	tb="$tb elf32-hppa.lo elf32.lo $elf" ;;
     bfd_elf32_hppa_vec)		tb="$tb elf32-hppa.lo elf32.lo $elf" ;;
     bfd_elf32_i370_vec)		tb="$tb elf32-i370.lo elf32.lo $elf" ;;
-    bfd_elf32_i386_sol2_vec)	tb="$tb elf32-i386.lo elf-ifunc.lo elf-vxworks.lo elf32.lo $elf" ;;
-    bfd_elf32_i386_freebsd_vec)	tb="$tb elf32-i386.lo elf-ifunc.lo elf-vxworks.lo elf32.lo $elf" ;;
-    bfd_elf32_i386_nacl_vec)	tb="$tb elf32-i386.lo elf-ifunc.lo elf-vxworks.lo elf32.lo $elf" ;;
-    bfd_elf32_i386_vxworks_vec)	tb="$tb elf32-i386.lo elf-ifunc.lo elf-vxworks.lo elf32.lo $elf" ;;
-    bfd_elf32_i386_vec)		tb="$tb elf32-i386.lo elf-ifunc.lo elf-vxworks.lo elf32.lo $elf" ;;
+    bfd_elf32_i386_sol2_vec)	tb="$tb elf32-i386.lo elf-ifunc.lo elf-nacl.lo elf-vxworks.lo elf32.lo $elf" ;;
+    bfd_elf32_i386_freebsd_vec)	tb="$tb elf32-i386.lo elf-ifunc.lo elf-nacl.lo elf-vxworks.lo elf32.lo $elf" ;;
+    bfd_elf32_i386_nacl_vec)	tb="$tb elf32-i386.lo elf-ifunc.lo elf-nacl.lo elf-vxworks.lo elf32.lo $elf" ;;
+    bfd_elf32_i386_vxworks_vec)	tb="$tb elf32-i386.lo elf-ifunc.lo elf-nacl.lo elf-vxworks.lo elf32.lo $elf" ;;
+    bfd_elf32_i386_vec)		tb="$tb elf32-i386.lo elf-ifunc.lo elf-nacl.lo elf-vxworks.lo elf32.lo $elf" ;;
     bfd_elf32_i860_little_vec)	tb="$tb elf32-i860.lo elf32.lo $elf" ;;
     bfd_elf32_i860_vec)		tb="$tb elf32-i860.lo elf32.lo $elf" ;;
     bfd_elf32_i960_vec)		tb="$tb elf32-i960.lo elf32.lo $elf" ;;
@@ -724,13 +759,16 @@
     bfd_elf32_little_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;;
     bfd_elf32_littlearc_vec)	tb="$tb elf32-arc.lo elf32.lo $elf" ;;
     bfd_elf32_littlearm_symbian_vec)
-                                tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;;
+                                tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;;
     bfd_elf32_littlearm_vxworks_vec)
-                                tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;;
-    bfd_elf32_littlearm_vec)	tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;;
+                                tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;;
+    bfd_elf32_littlearm_vec)	tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;;
+    bfd_elf32_littlearm_nacl_vec) tb="$tb elf32-arm.lo elf32.lo elf-nacl.lo elf-vxworks.lo $elf" ;;
     bfd_elf32_littlemips_vec) 	tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;;
     bfd_elf32_littlemips_vxworks_vec)
 			 	tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;;
+    bfd_elf32_littlemoxie_vec)	tb="$tb elf32-moxie.lo elf32.lo $elf" ;;
+    bfd_elf32_littlenios2_vec)	tb="$tb elf32-nios2.lo elf32.lo $elf" ;;
     bfd_elf32_m32c_vec)         tb="$tb elf32-m32c.lo elf32.lo $elf" ;;
     bfd_elf32_m32r_vec)		tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
     bfd_elf32_m32rle_vec)       tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
@@ -744,11 +782,14 @@
     bfd_elf32_mcore_little_vec)	tb="$tb elf32-mcore.lo elf32.lo $elf" ;;
     bfd_elf32_mep_vec)		tb="$tb elf32-mep.lo elf32.lo $elf" ;;
     bfd_elf32_mep_little_vec)	tb="$tb elf32-mep.lo elf32.lo $elf" ;;
+    bfd_elf32_metag_vec)	tb="$tb elf32-metag.lo elf32.lo $elf" ;;
+    bfd_elf32_microblazeel_vec)	tb="$tb elf32-microblaze.lo elf32.lo $elf" ;;
     bfd_elf32_microblaze_vec)	tb="$tb elf32-microblaze.lo elf32.lo $elf" ;;
     bfd_elf32_mn10200_vec)	tb="$tb elf-m10200.lo elf32.lo $elf" ;;
     bfd_elf32_mn10300_vec)	tb="$tb elf-m10300.lo elf32.lo $elf" ;;
     bfd_elf32_mt_vec)           tb="$tb elf32-mt.lo elf32.lo $elf" ;;
     bfd_elf32_msp430_vec)	tb="$tb elf32-msp430.lo elf32.lo $elf" ;;
+    bfd_elf32_msp430_ti_vec)	tb="$tb elf32-msp430.lo elf32.lo $elf" ;;
     bfd_elf32_nbigmips_vec)	tb="$tb elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
     bfd_elf32_nlittlemips_vec)	tb="$tb elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
     bfd_elf32_ntradbigmips_vec | bfd_elf32_ntradbigmips_freebsd_vec)
@@ -761,7 +802,9 @@
     bfd_elf32_pjl_vec)          tb="$tb elf32-pj.lo elf32.lo $elf";;
     bfd_elf32_powerpc_vec)	tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;;
     bfd_elf32_powerpcle_vec)	tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;;
+    bfd_elf32_powerpc_freebsd_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;;
     bfd_elf32_powerpc_vxworks_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;;
+    bfd_elf32_rl78_vec)         tb="$tb elf32-rl78.lo $elf" ;;
     bfd_elf32_rx_le_vec)        tb="$tb elf32-rx.lo elf32.lo $elf" ;;
     bfd_elf32_rx_be_vec)        tb="$tb elf32-rx.lo elf32.lo $elf" ;;
     bfd_elf32_rx_be_ns_vec)     tb="$tb elf32-rx.lo elf32.lo $elf" ;;
@@ -798,7 +841,8 @@
     bfd_elf32_tic6x_linux_le_vec) tb="$tb elf32-tic6x.lo elf32.lo $elf" ;;
     bfd_elf32_tic6x_elf_be_vec) tb="$tb elf32-tic6x.lo elf32.lo $elf" ;;
     bfd_elf32_tic6x_elf_le_vec) tb="$tb elf32-tic6x.lo elf32.lo $elf" ;;
-    bfd_elf32_tilegx_vec)	tb="$tb elf32-tilegx.lo elfxx-tilegx.lo elf32.lo $elf" ; target_size=32 ;;
+    bfd_elf32_tilegx_be_vec)	tb="$tb elf32-tilegx.lo elfxx-tilegx.lo elf32.lo $elf" ; target_size=32 ;;
+    bfd_elf32_tilegx_le_vec)	tb="$tb elf32-tilegx.lo elfxx-tilegx.lo elf32.lo $elf" ; target_size=32 ;;
     bfd_elf32_tilepro_vec)	tb="$tb elf32-tilepro.lo elf32.lo $elf" ;;
     bfd_elf32_tradbigmips_vec | bfd_elf32_tradbigmips_freebsd_vec)
 				tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;;
@@ -806,13 +850,17 @@
 				tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;;
     bfd_elf32_us_cris_vec)	tb="$tb elf32-cris.lo elf32.lo $elf" ;;
     bfd_elf32_v850_vec)		tb="$tb elf32-v850.lo elf32.lo $elf" ;;
+    bfd_elf32_v850_rh850_vec)	tb="$tb elf32-v850.lo elf32.lo $elf" ;;
     bfd_elf32_vax_vec)		tb="$tb elf32-vax.lo elf32.lo $elf" ;;
     bfd_elf32_xstormy16_vec)	tb="$tb elf32-xstormy16.lo elf32.lo $elf" ;;
     bfd_elf32_xc16x_vec)		tb="$tb elf32-xc16x.lo elf32.lo $elf" ;;
+    bfd_elf32_xgate_vec)  	tb="$tb elf32-xgate.lo elf32.lo $elf" ;;
     bfd_elf32_xtensa_le_vec)	tb="$tb xtensa-isa.lo xtensa-modules.lo elf32-xtensa.lo elf32.lo $elf" ;;
     bfd_elf32_xtensa_be_vec)	tb="$tb xtensa-isa.lo xtensa-modules.lo elf32-xtensa.lo elf32.lo $elf" ;;
     bfd_elf64_alpha_freebsd_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_alpha_vec)	tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf64_bigaarch64_vec)	tb="$tb elf64-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf32_bigaarch64_vec)	tb="$tb elf32-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf32.lo $elf"; target_size=64 ;;
     bfd_elf64_big_generic_vec) 	tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_bigmips_vec) 	tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
     bfd_elf64_hppa_linux_vec)	tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;;
@@ -820,12 +868,15 @@
     bfd_elf64_ia64_big_vec)	tb="$tb elf64-ia64.lo elfxx-ia64.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_ia64_hpux_big_vec) tb="$tb elf64-ia64.lo elfxx-ia64.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_ia64_little_vec)	tb="$tb elf64-ia64.lo elfxx-ia64.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_ia64_vms_vec)	tb="$tb elf64-ia64.lo elfxx-ia64.lo  elf64.lo vms-lib.lo vms-misc.lo $elf"; target_size=64 ;;
+    bfd_elf64_ia64_vms_vec)	tb="$tb elf64-ia64-vms.lo elf64-ia64.lo elfxx-ia64.lo elf64.lo vms-lib.lo vms-misc.lo $elf"; target_size=64 ;;    
+    bfd_elf64_littleaarch64_vec)tb="$tb elf64-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf32_littleaarch64_vec)tb="$tb elf32-aarch64.lo elfxx-aarch64.lo elf-ifunc.lo elf32.lo $elf"; target_size=64 ;;
     bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_littlemips_vec) 	tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
     bfd_elf64_mmix_vec) 	tb="$tb elf64-mmix.lo elf64.lo $elf" target_size=64 ;;
     bfd_elf64_powerpc_vec)	tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_powerpcle_vec)	tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;;
+    bfd_elf64_powerpc_freebsd_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;;
     bfd_elf64_s390_vec)		tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_sh64_vec)		tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
     bfd_elf64_sh64l_vec)	tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;;
@@ -836,19 +887,22 @@
     bfd_elf64_sparc_vec)	tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_sparc_freebsd_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;;
     bfd_elf64_sparc_sol2_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_tilegx_vec)	tb="$tb elf64-tilegx.lo elfxx-tilegx.lo elf64.lo $elf" ; target_size=64 ;;
+    bfd_elf64_tilegx_be_vec)	tb="$tb elf64-tilegx.lo elfxx-tilegx.lo elf64.lo $elf" ; target_size=64 ;;
+    bfd_elf64_tilegx_le_vec)	tb="$tb elf64-tilegx.lo elfxx-tilegx.lo elf64.lo $elf" ; target_size=64 ;;
     bfd_elf64_tradbigmips_vec | bfd_elf64_tradbigmips_freebsd_vec)
 				tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
     bfd_elf64_tradlittlemips_vec | bfd_elf64_tradlittlemips_freebsd_vec)
 				tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
-    bfd_elf64_x86_64_freebsd_vec) tb="$tb elf64-x86-64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_x86_64_sol2_vec)  tb="$tb elf64-x86-64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_x86_64_vec)	tb="$tb elf64-x86-64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf32_x86_64_vec)	tb="$tb elf64-x86-64.lo elf-ifunc.lo elf64.lo elf32.lo $elf"; target_size=64 ;;
-    bfd_elf64_l1om_vec)		tb="$tb elf64-x86-64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_l1om_freebsd_vec) tb="$tb elf64-x86-64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_k1om_vec)		tb="$tb elf64-x86-64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
-    bfd_elf64_k1om_freebsd_vec) tb="$tb elf64-x86-64.lo elf-ifunc.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf64_x86_64_freebsd_vec) tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf64_x86_64_nacl_vec)	tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf64_x86_64_sol2_vec)  tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf64_x86_64_vec)	tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf32_x86_64_vec)	tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo elf32.lo $elf"; target_size=64 ;;
+    bfd_elf32_x86_64_nacl_vec)	tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo elf32.lo $elf"; target_size=64 ;;
+    bfd_elf64_l1om_vec)		tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf64_l1om_freebsd_vec) tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf64_k1om_vec)		tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo $elf"; target_size=64 ;;
+    bfd_elf64_k1om_freebsd_vec) tb="$tb elf64-x86-64.lo elf-ifunc.lo elf-nacl.lo elf64.lo $elf"; target_size=64 ;;
     bfd_mmo_vec)		tb="$tb mmo.lo" target_size=64 ;;
     bfd_powerpc_pe_vec)         tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;;
     bfd_powerpc_pei_vec)        tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;;
@@ -1074,6 +1128,7 @@
   supports_plugins=0
 fi
 AC_SUBST(supports_plugins)
+AC_SUBST(lt_cv_dlopen_libs)
 
 # Determine the host dependant file_ptr a.k.a. off_t type.  In order
 # prefer: off64_t - if ftello64 and fseeko64, off_t - if ftello and
@@ -1144,4 +1199,3 @@
 AC_SUBST(pdfdir)
 
 AC_OUTPUT
-
diff --git a/bfd/corefile.c b/bfd/corefile.c
index bba0d1c..8d62938 100644
--- a/bfd/corefile.c
+++ b/bfd/corefile.c
@@ -169,7 +169,7 @@
      of the const char * returned by bfd_core_file_failing_command to a
      non-const char *.  In this case, the assignement does not lead to
      breaking the const, as we're only reading the string.  */
-     
+
   core = (char *) bfd_core_file_failing_command (core_bfd);
   if (core == NULL)
     return TRUE;
@@ -185,7 +185,7 @@
   last_slash = strrchr (exec, '/');
   if (last_slash != NULL)
     exec = last_slash + 1;
-  
+
   return filename_cmp (exec, core) == 0;
 }
 
diff --git a/bfd/cpu-aarch64.c b/bfd/cpu-aarch64.c
new file mode 100644
index 0000000..9ec18a0
--- /dev/null
+++ b/bfd/cpu-aarch64.c
@@ -0,0 +1,127 @@
+/* BFD support for AArch64.
+   Copyright 2009, 2010, 2011, 2012  Free Software Foundation, Inc.
+   Contributed by ARM Ltd.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; see the file COPYING3. If not,
+   see <http://www.gnu.org/licenses/>.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libbfd.h"
+#include "libiberty.h"
+
+/* This routine is provided two arch_infos and works out which Aarch64
+   machine which would be compatible with both and returns a pointer
+   to its info structure.  */
+
+static const bfd_arch_info_type *
+compatible (const bfd_arch_info_type * a, const bfd_arch_info_type * b)
+{
+  /* If a & b are for different architecture we can do nothing.  */
+  if (a->arch != b->arch)
+    return NULL;
+
+  /* If a & b are for the same machine then all is well.  */
+  if (a->mach == b->mach)
+    return a;
+
+  /* Don't allow mixing ilp32 with lp64.  */
+  if ((a->mach & bfd_mach_aarch64_ilp32) != (b->mach & bfd_mach_aarch64_ilp32))
+    return NULL;
+
+  /* Otherwise if either a or b is the 'default' machine
+     then it can be polymorphed into the other.  */
+  if (a->the_default)
+    return b;
+
+  if (b->the_default)
+    return a;
+
+  /* So far all newer cores are
+     supersets of previous cores.  */
+  if (a->mach < b->mach)
+    return b;
+  else if (a->mach > b->mach)
+    return a;
+
+  /* Never reached!  */
+  return NULL;
+}
+
+static struct
+{
+  unsigned int mach;
+  char *name;
+}
+processors[] =
+{
+  /* These two are example CPUs supported in GCC, once we have real
+     CPUs they will be removed.  */
+  { bfd_mach_aarch64, "example-1" },
+  { bfd_mach_aarch64, "example-2" }
+};
+
+static bfd_boolean
+scan (const struct bfd_arch_info *info, const char *string)
+{
+  int i;
+
+  /* First test for an exact match.  */
+  if (strcasecmp (string, info->printable_name) == 0)
+    return TRUE;
+
+  /* Next check for a processor name instead of an Architecture name.  */
+  for (i = sizeof (processors) / sizeof (processors[0]); i--;)
+    {
+      if (strcasecmp (string, processors[i].name) == 0)
+	break;
+    }
+
+  if (i != -1 && info->mach == processors[i].mach)
+    return TRUE;
+
+  /* Finally check for the default architecture.  */
+  if (strcasecmp (string, "aarch64") == 0)
+    return info->the_default;
+
+  return FALSE;
+}
+
+#define N(NUMBER, PRINT, DEFAULT, NEXT)				\
+  { 64, 64, 8, bfd_arch_aarch64, NUMBER,			\
+    "aarch64", PRINT, 4, DEFAULT, compatible, scan,		\
+    bfd_arch_default_fill, NEXT }
+
+static const bfd_arch_info_type bfd_aarch64_arch_ilp32 =
+  N (bfd_mach_aarch64_ilp32, "aarch64:ilp32", FALSE, NULL);
+
+const bfd_arch_info_type bfd_aarch64_arch =
+  N (0, "aarch64", TRUE, &bfd_aarch64_arch_ilp32);
+
+bfd_boolean
+bfd_is_aarch64_special_symbol_name (const char *name, int type)
+{
+  if (!name || name[0] != '$')
+    return FALSE;
+  if (name[1] == 'x' || name[1] == 'd')
+    type &= BFD_AARCH64_SPECIAL_SYM_TYPE_MAP;
+  else if (name[1] == 'm' || name[1] == 'f' || name[1] == 'p')
+    type &= BFD_AARCH64_SPECIAL_SYM_TYPE_TAG;
+  else
+    return FALSE;
+
+  return (type != 0 && (name[2] == 0 || name[2] == '.'));
+}
diff --git a/bfd/cpu-alpha.c b/bfd/cpu-alpha.c
index 9456b65..902eb8d 100644
--- a/bfd/cpu-alpha.c
+++ b/bfd/cpu-alpha.c
@@ -36,6 +36,7 @@
     DEFAULT,						\
     bfd_default_compatible, 				\
     bfd_default_scan,					\
+    bfd_arch_default_fill,				\
     NEXT,						\
   }
 
diff --git a/bfd/cpu-arc.c b/bfd/cpu-arc.c
index 820c948..02b4d98 100644
--- a/bfd/cpu-arc.c
+++ b/bfd/cpu-arc.c
@@ -1,5 +1,5 @@
 /* BFD support for the ARC processor
-   Copyright 1994, 1995, 1997, 2001, 2002, 2005, 2007
+   Copyright 1994, 1995, 1997, 2001, 2002, 2005, 2007, 2012
    Free Software Foundation, Inc.
    Contributed by Doug Evans ([email protected]).
 
@@ -37,6 +37,7 @@
     default_p,				\
     bfd_default_compatible,		\
     bfd_default_scan,			\
+    bfd_arch_default_fill,		\
     next,				\
   }
 
@@ -57,11 +58,10 @@
 /* Given cpu type NAME, return its bfd_mach_arc_xxx value.
    Returns -1 if not found.  */
 
-int arc_get_mach PARAMS ((char *));
+int arc_get_mach (char *);
 
 int
-arc_get_mach (name)
-     char *name;
+arc_get_mach (char *name)
 {
   const bfd_arch_info_type *p;
 
diff --git a/bfd/cpu-arm.c b/bfd/cpu-arm.c
index 2238720..4f18336 100644
--- a/bfd/cpu-arm.c
+++ b/bfd/cpu-arm.c
@@ -124,7 +124,8 @@
 }
 
 #define N(number, print, default, next)  \
-{  32, 32, 8, bfd_arch_arm, number, "arm", print, 4, default, compatible, scan, next }
+{  32, 32, 8, bfd_arch_arm, number, "arm", print, 4, default, compatible, \
+   scan, bfd_arch_default_fill, next }
 
 static const bfd_arch_info_type arch_info_struct[] =
 {
@@ -251,10 +252,10 @@
 	return FALSE;
     }
   else
-    { 
+    {
       if (namesz != ((strlen (expected_name) + 1 + 3) & ~3))
 	return FALSE;
-      
+
       if (strcmp (descr, expected_name) != 0)
 	return FALSE;
 
diff --git a/bfd/cpu-avr.c b/bfd/cpu-avr.c
index 07ba6dc..8083538 100644
--- a/bfd/cpu-avr.c
+++ b/bfd/cpu-avr.c
@@ -54,7 +54,7 @@
 
       if (a->mach <= b->mach)
        return b;
-       
+
       if (a->mach >= b->mach)
        return a;
     }
@@ -63,7 +63,7 @@
     return a;
   if (a->mach == bfd_mach_avr25 && b->mach == bfd_mach_avr2)
     return b;
-    
+
   if (a->mach == bfd_mach_avr3 && b->mach == bfd_mach_avr31)
     return a;
   if (a->mach == bfd_mach_avr31 && b->mach == bfd_mach_avr3)
@@ -96,6 +96,7 @@
   default,			/* Is this the default ?  */	\
   compatible,							\
   bfd_default_scan,						\
+  bfd_arch_default_fill,					\
   next								\
 }
 
@@ -111,7 +112,7 @@
   N (16, bfd_mach_avr25, "avr:25", FALSE, & arch_info_struct[3]),
 
   /* Classic, > 8K, <= 64K.  */
-  /* TODO:  addr_bits should be 16, but set to 22 for some following 
+  /* TODO:  addr_bits should be 16, but set to 22 for some following
      version of GCC (from 4.3) for backward compatibility.  */
   N (22, bfd_mach_avr3, "avr:3", FALSE, & arch_info_struct[4]),
 
@@ -125,37 +126,37 @@
   N (16, bfd_mach_avr4, "avr:4", FALSE, & arch_info_struct[7]),
 
   /* Enhanced, > 8K, <= 64K.  */
-  /* TODO:  addr_bits should be 16, but set to 22 for some following 
+  /* TODO:  addr_bits should be 16, but set to 22 for some following
      version of GCC (from 4.3) for backward compatibility.  */
   N (22, bfd_mach_avr5, "avr:5", FALSE, & arch_info_struct[8]),
-  
+
   /* Enhanced, == 128K.  */
   N (22, bfd_mach_avr51, "avr:51", FALSE, & arch_info_struct[9]),
 
   /* 3-Byte PC.  */
   N (22, bfd_mach_avr6, "avr:6", FALSE, & arch_info_struct[10]),
-  
+
   /* Xmega 1 */
   N (24, bfd_mach_avrxmega1, "avr:101", FALSE, & arch_info_struct[11]),
 
   /* Xmega 2 */
   N (24, bfd_mach_avrxmega2, "avr:102", FALSE, & arch_info_struct[12]),
-  
+
   /* Xmega 3 */
   N (24, bfd_mach_avrxmega3, "avr:103", FALSE, & arch_info_struct[13]),
-  
+
   /* Xmega 4 */
   N (24, bfd_mach_avrxmega4, "avr:104", FALSE, & arch_info_struct[14]),
-  
+
   /* Xmega 5 */
   N (24, bfd_mach_avrxmega5, "avr:105", FALSE, & arch_info_struct[15]),
-  
+
   /* Xmega 6 */
   N (24, bfd_mach_avrxmega6, "avr:106", FALSE, & arch_info_struct[16]),
-  
+
   /* Xmega 7 */
   N (24, bfd_mach_avrxmega7, "avr:107", FALSE, NULL)
-  
+
 };
 
 const bfd_arch_info_type bfd_avr_arch =
diff --git a/bfd/cpu-bfin.c b/bfd/cpu-bfin.c
index 37e314b..e2e7f89 100644
--- a/bfd/cpu-bfin.c
+++ b/bfd/cpu-bfin.c
@@ -34,7 +34,8 @@
     "bfin",        	/* Arch printable name.  */
     4,                	/* Section align power.  */
     TRUE,             	/* The one and only.  */
-    bfd_default_compatible, 
-    bfd_default_scan ,
+    bfd_default_compatible,
+    bfd_default_scan,
+    bfd_arch_default_fill,
     0,
   };
diff --git a/bfd/cpu-cr16.c b/bfd/cpu-cr16.c
index 6c77738..3e54eaa 100644
--- a/bfd/cpu-cr16.c
+++ b/bfd/cpu-cr16.c
@@ -34,7 +34,8 @@
     "cr16",           /* Printable name.  */
     1,                /* Unsigned int section alignment power.  */
     TRUE,             /* The one and only.  */
-    bfd_default_compatible, 
-    bfd_default_scan ,
+    bfd_default_compatible,
+    bfd_default_scan,
+    bfd_arch_default_fill,
     0,
   };
diff --git a/bfd/cpu-cr16c.c b/bfd/cpu-cr16c.c
index e8ee1db..943edfd 100644
--- a/bfd/cpu-cr16c.c
+++ b/bfd/cpu-cr16c.c
@@ -33,7 +33,8 @@
     "cr16c",
     1,
     TRUE, 	/* The one and only.  */
-    bfd_default_compatible, 
-    bfd_default_scan ,
+    bfd_default_compatible,
+    bfd_default_scan,
+    bfd_arch_default_fill,
     0,
   };
diff --git a/bfd/cpu-cris.c b/bfd/cpu-cris.c
index c77e8f5..045425d 100644
--- a/bfd/cpu-cris.c
+++ b/bfd/cpu-cris.c
@@ -1,5 +1,5 @@
 /* BFD support for the Axis CRIS architecture.
-   Copyright 2000, 2002, 2004, 2005, 2007
+   Copyright 2000, 2002, 2004, 2005, 2007, 2012
    Free Software Foundation, Inc.
    Contributed by Axis Communications AB.
    Written by Hans-Peter Nilsson.
@@ -30,12 +30,11 @@
    there's a compatible subset for which we provide an arch_info.  */
 
 static const bfd_arch_info_type * get_compatible
-  PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
+  (const bfd_arch_info_type *, const bfd_arch_info_type *);
 
 static const bfd_arch_info_type *
-get_compatible (a,b)
-     const bfd_arch_info_type *a;
-     const bfd_arch_info_type *b;
+get_compatible (const bfd_arch_info_type *a,
+		const bfd_arch_info_type *b)
 {
   /* Arches must match.  */
   if (a->arch != b->arch)
@@ -69,7 +68,7 @@
 
 #define N(NUMBER, PRINT, NEXT)  \
  { 32, 32, 8, bfd_arch_cris, NUMBER, "cris", PRINT, 1, FALSE, \
-   get_compatible, bfd_default_scan, NEXT }
+   get_compatible, bfd_default_scan, bfd_arch_default_fill, NEXT }
 
 static const bfd_arch_info_type bfd_cris_arch_compat_v10_v32 =
  N (bfd_mach_cris_v10_v32, "cris:common_v10_v32", NULL);
@@ -98,6 +97,7 @@
 				   bfd_arch_info_type.  */
   bfd_default_scan,		/* Check if a bfd_arch_info_type is a
 				   match.  */
+  bfd_arch_default_fill,	/* Default fill.  */
   &bfd_cris_arch_v32		/* Pointer to next bfd_arch_info_type in
 				   the same family.  */
 };
diff --git a/bfd/cpu-crx.c b/bfd/cpu-crx.c
index 3201c3c..631c5fa 100644
--- a/bfd/cpu-crx.c
+++ b/bfd/cpu-crx.c
@@ -34,7 +34,8 @@
     "crx", 	/* Printable name.  */
     1,      	/* Unsigned int section alignment power.  */
     TRUE, 	/* The one and only.  */
-    bfd_default_compatible, 
-    bfd_default_scan ,
+    bfd_default_compatible,
+    bfd_default_scan,
+    bfd_arch_default_fill,
     0,
   };
diff --git a/bfd/cpu-d10v.c b/bfd/cpu-d10v.c
index b161115..7bc208e 100644
--- a/bfd/cpu-d10v.c
+++ b/bfd/cpu-d10v.c
@@ -37,6 +37,7 @@
   FALSE,
   bfd_default_compatible,
   bfd_default_scan,
+  bfd_arch_default_fill,
   0,
 };
 
@@ -53,6 +54,7 @@
   FALSE,
   bfd_default_compatible,
   bfd_default_scan,
+  bfd_arch_default_fill,
   & d10v_ts3_info,
 };
 
@@ -69,5 +71,6 @@
   TRUE,
   bfd_default_compatible,
   bfd_default_scan,
+  bfd_arch_default_fill,
   & d10v_ts2_info,
 };
diff --git a/bfd/cpu-d30v.c b/bfd/cpu-d30v.c
index d528e9b..69515eb 100644
--- a/bfd/cpu-d30v.c
+++ b/bfd/cpu-d30v.c
@@ -36,5 +36,6 @@
     TRUE,
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     0,
 };
diff --git a/bfd/cpu-dlx.c b/bfd/cpu-dlx.c
index fda48dc..2c17849 100644
--- a/bfd/cpu-dlx.c
+++ b/bfd/cpu-dlx.c
@@ -35,6 +35,7 @@
     4,
     TRUE, /* The one and only.  */
     bfd_default_compatible,
-    bfd_default_scan ,
+    bfd_default_scan,
+    bfd_arch_default_fill,
     0,
 };
diff --git a/bfd/cpu-epiphany.c b/bfd/cpu-epiphany.c
new file mode 100644
index 0000000..9cf723e
--- /dev/null
+++ b/bfd/cpu-epiphany.c
@@ -0,0 +1,58 @@
+/* BFD support for the Adapteva EPIPHANY processor.
+   Copyright 2009, 2011 Free Software Foundation, Inc.
+   Contributed by Embecosm on behalf of Adapteva, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_epiphany16_arch =
+{
+  32,				/* Bits per word */
+  32,				/* Bits per address.  */
+  8,				/* Bits per byte.  */
+  bfd_arch_epiphany,		/* Architecture.  */
+  bfd_mach_epiphany16,		/* Machine.  */
+  "epiphany",			/* Architecture name.  */
+  "epiphany16",			/* Machine name.  */
+  1,				/* Section align power.  */
+  FALSE,			/* The default ?  */
+  bfd_default_compatible,	/* Architecture comparison fn.  */
+  bfd_default_scan,		/* String to architecture convert fn.  */
+  bfd_arch_default_fill,	/* Default fill.  */
+  NULL				/* Next in list.  */
+};
+
+const bfd_arch_info_type bfd_epiphany_arch =
+{
+  32,				/* Bits per word - not really true.  */
+  32,				/* Bits per address.  */
+  8,				/* Bits per byte.  */
+  bfd_arch_epiphany,		/* Architecture.  */
+  bfd_mach_epiphany32,		/* Machine.  */
+  "epiphany",			/* Architecture name.  */
+  "epiphany32",			/* Machine name.  */
+  2,				/* Section align power.  */
+  TRUE,				/* The default ?  */
+  bfd_default_compatible,	/* Architecture comparison fn.  */
+  bfd_default_scan,		/* String to architecture convert fn.  */
+  bfd_arch_default_fill,	/* Default fill.  */
+  & bfd_epiphany16_arch	/* Next in list.  */
+};
diff --git a/bfd/cpu-fr30.c b/bfd/cpu-fr30.c
index b60e43e..dc2e5fa 100644
--- a/bfd/cpu-fr30.c
+++ b/bfd/cpu-fr30.c
@@ -35,5 +35,6 @@
   TRUE,				/* the default ? */
   bfd_default_compatible,	/* architecture comparison fn */
   bfd_default_scan,		/* string to architecture convert fn */
+  bfd_arch_default_fill,	/* Default fill.  */
   NULL				/* next in list */
 };
diff --git a/bfd/cpu-frv.c b/bfd/cpu-frv.c
index fd2aedb..ac4d898 100644
--- a/bfd/cpu-frv.c
+++ b/bfd/cpu-frv.c
@@ -35,6 +35,7 @@
   DEFAULT,			/* is this the default? */		\
   bfd_default_compatible,	/* architecture comparison fn */	\
   bfd_default_scan,		/* string to architecture convert fn */	\
+  bfd_arch_default_fill,	/* Default fill.  */			\
   NEXT				/* next in list */			\
 }
 
diff --git a/bfd/cpu-h8300.c b/bfd/cpu-h8300.c
index 0fd77d6..5f33856 100644
--- a/bfd/cpu-h8300.c
+++ b/bfd/cpu-h8300.c
@@ -83,7 +83,7 @@
 
 	  return (info->mach == bfd_mach_h8300sx);
 	}
-      
+
       return (info->mach == bfd_mach_h8300s);
     }
   else
@@ -127,6 +127,7 @@
   FALSE,			/* the default machine */
   compatible,
   h8300_scan,
+  bfd_arch_default_fill,
   0
 };
 
@@ -143,6 +144,7 @@
   FALSE,			/* the default machine */
   compatible,
   h8300_scan,
+  bfd_arch_default_fill,
   &h8300sxn_info_struct
 };
 
@@ -159,6 +161,7 @@
   FALSE,			/* The default machine.  */
   compatible,
   h8300_scan,
+  bfd_arch_default_fill,
   &h8300sx_info_struct
 };
 
@@ -175,6 +178,7 @@
   FALSE,			/* The default machine.  */
   compatible,
   h8300_scan,
+  bfd_arch_default_fill,
   &h8300sn_info_struct
 };
 
@@ -191,6 +195,7 @@
   FALSE,			/* The default machine.  */
   compatible,
   h8300_scan,
+  bfd_arch_default_fill,
   & h8300hn_info_struct
 };
 
@@ -207,6 +212,7 @@
   FALSE,			/* The default machine.  */
   compatible,
   h8300_scan,
+  bfd_arch_default_fill,
   &h8300s_info_struct
 };
 
@@ -223,6 +229,7 @@
   TRUE,				/* The default machine.  */
   compatible,
   h8300_scan,
+  bfd_arch_default_fill,
   &h8300h_info_struct
 };
 
diff --git a/bfd/cpu-h8500.c b/bfd/cpu-h8500.c
index 362d369..1312831 100644
--- a/bfd/cpu-h8500.c
+++ b/bfd/cpu-h8500.c
@@ -1,5 +1,5 @@
 /* BFD library support routines for the H8/500 architecture.
-   Copyright 1993, 1995, 1999, 2000, 2001, 2002, 2003, 2005, 2007
+   Copyright 1993, 1995, 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2012
    Free Software Foundation, Inc.
    Hacked by Steve Chamberlain of Cygnus Support.
 
@@ -25,12 +25,11 @@
 #include "libbfd.h"
 
 static bfd_boolean scan_mach
-  PARAMS ((const struct bfd_arch_info *, const char *));
+  (const struct bfd_arch_info *, const char *);
 
 static bfd_boolean
-scan_mach (info, string)
-     const struct bfd_arch_info *info ATTRIBUTE_UNUSED;
-     const char *string;
+scan_mach (const struct bfd_arch_info *info ATTRIBUTE_UNUSED,
+	   const char *string)
 {
   if (strcmp (string,"h8/500") == 0)
     return TRUE;
@@ -56,5 +55,6 @@
   TRUE,				/* the default machine */
   bfd_default_compatible,
   scan_mach,
+  bfd_arch_default_fill,
   0,
 };
diff --git a/bfd/cpu-hppa.c b/bfd/cpu-hppa.c
index 034e321..885a11a 100644
--- a/bfd/cpu-hppa.c
+++ b/bfd/cpu-hppa.c
@@ -35,7 +35,8 @@
   3,
   TRUE,				/* Unless we use 1.1 specific features */
   bfd_default_compatible,
-  bfd_default_scan ,
+  bfd_default_scan,
+  bfd_arch_default_fill,
   0,
 };
 
@@ -52,7 +53,8 @@
   3,
   FALSE,			/* Unless we use 1.1 specific features */
   bfd_default_compatible,
-  bfd_default_scan ,
+  bfd_default_scan,
+  bfd_arch_default_fill,
   &bfd_hppa10_arch,
 };
 
@@ -69,7 +71,8 @@
   3,
   FALSE,			/* Unless we use 1.1 specific features */
   bfd_default_compatible,
-  bfd_default_scan ,
+  bfd_default_scan,
+  bfd_arch_default_fill,
   &bfd_hppa20_arch,
 };
 
@@ -85,6 +88,7 @@
   3,
   FALSE,			/* 1.1 specific features used */
   bfd_default_compatible,
-  bfd_default_scan ,
+  bfd_default_scan,
+  bfd_arch_default_fill,
   &bfd_hppa20w_arch,
 };
diff --git a/bfd/cpu-i370.c b/bfd/cpu-i370.c
index d12b9ae..99daf88 100644
--- a/bfd/cpu-i370.c
+++ b/bfd/cpu-i370.c
@@ -40,6 +40,7 @@
     FALSE, 	/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &arch_info_struct[1]
   },
   {
@@ -54,6 +55,7 @@
     FALSE, 	/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     0
   },
 };
@@ -71,5 +73,6 @@
   TRUE, 	/* The default.  */
   bfd_default_compatible,
   bfd_default_scan,
+  bfd_arch_default_fill,
   & arch_info_struct[0]
 };
diff --git a/bfd/cpu-i386.c b/bfd/cpu-i386.c
index f98c0e5..2a6bb97 100644
--- a/bfd/cpu-i386.c
+++ b/bfd/cpu-i386.c
@@ -1,6 +1,6 @@
 /* BFD support for the Intel 386 architecture.
    Copyright 1992, 1994, 1995, 1996, 1998, 2000, 2001, 2002, 2004, 2005,
-   2007, 2009, 2010, 2011
+   2007, 2009, 2010, 2011, 2013
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -23,6 +23,10 @@
 #include "sysdep.h"
 #include "bfd.h"
 #include "libbfd.h"
+#include "libiberty.h"
+
+extern void * bfd_arch_i386_short_nop_fill (bfd_size_type, bfd_boolean,
+					    bfd_boolean);
 
 static const bfd_arch_info_type *
 bfd_i386_compatible (const bfd_arch_info_type *a,
@@ -38,6 +42,148 @@
   return compat;
 }
 
+/* Fill the buffer with zero or nop instruction if CODE is TRUE.  Use
+   multi byte nop instructions if LONG_NOP is TRUE.  */
+
+static void *
+bfd_arch_i386_fill (bfd_size_type count, bfd_boolean code,
+		    bfd_boolean long_nop)
+{
+  /* nop */
+  static const char nop_1[] = { 0x90 };
+  /* xchg %ax,%ax */
+  static const char nop_2[] = { 0x66, 0x90 };
+  /* nopl (%[re]ax) */
+  static const char nop_3[] = { 0x0f, 0x1f, 0x00 };
+  /* nopl 0(%[re]ax) */
+  static const char nop_4[] = { 0x0f, 0x1f, 0x40, 0x00 };
+  /* nopl 0(%[re]ax,%[re]ax,1) */
+  static const char nop_5[] = { 0x0f, 0x1f, 0x44, 0x00, 0x00 };
+  /* nopw 0(%[re]ax,%[re]ax,1) */
+  static const char nop_6[] = { 0x66, 0x0f, 0x1f, 0x44, 0x00, 0x00 };
+  /* nopl 0L(%[re]ax) */
+  static const char nop_7[] = { 0x0f, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00 };
+  /* nopl 0L(%[re]ax,%[re]ax,1) */
+  static const char nop_8[] =
+    { 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00};
+  /* nopw 0L(%[re]ax,%[re]ax,1) */
+  static const char nop_9[] =
+    { 0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00 };
+  /* nopw %cs:0L(%[re]ax,%[re]ax,1) */
+  static const char nop_10[] =
+    { 0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00 };
+  static const char *const nops[] =
+    { nop_1, nop_2, nop_3, nop_4, nop_5,
+      nop_6, nop_7, nop_8, nop_9, nop_10 };
+  bfd_size_type nop_size = long_nop ? ARRAY_SIZE (nops) : 2;
+
+  void *fill = bfd_malloc (count);
+  if (fill == NULL)
+    return fill;
+
+  if (code)
+    {
+      bfd_byte *p = fill;
+      while (count >= nop_size)
+	{
+	  memcpy (p, nops[nop_size - 1], nop_size);
+	  p += nop_size;
+	  count -= nop_size;
+	}
+      if (count != 0)
+	memcpy (p, nops[count - 1], count);
+    }
+  else
+    memset (fill, 0, count);
+
+  return fill;
+}
+
+/* Fill the buffer with zero or short nop instruction if CODE is TRUE.  */
+
+void *
+bfd_arch_i386_short_nop_fill (bfd_size_type count,
+			      bfd_boolean is_bigendian ATTRIBUTE_UNUSED,
+			      bfd_boolean code)
+{
+  return bfd_arch_i386_fill (count, code, FALSE);
+}
+
+/* Fill the buffer with zero or long nop instruction if CODE is TRUE.  */
+
+static void *
+bfd_arch_i386_long_nop_fill (bfd_size_type count,
+			     bfd_boolean is_bigendian ATTRIBUTE_UNUSED,
+			     bfd_boolean code)
+{
+  return bfd_arch_i386_fill (count, code, TRUE);
+}
+
+/* Fill the buffer with zero, or one-byte nop instructions if CODE is TRUE.  */
+
+static void *
+bfd_arch_i386_onebyte_nop_fill (bfd_size_type count,
+				bfd_boolean is_bigendian ATTRIBUTE_UNUSED,
+				bfd_boolean code)
+{
+  void *fill = bfd_malloc (count);
+  if (fill != NULL)
+    memset (fill, code ? 0x90 : 0, count);
+  return fill;
+}
+
+
+static const bfd_arch_info_type bfd_x64_32_nacl_arch =
+{
+  64, /* 64 bits in a word */
+  64, /* 64 bits in an address */
+  8,  /* 8 bits in a byte */
+  bfd_arch_i386,
+  bfd_mach_x64_32_nacl,
+  "i386",
+  "i386:x64-32:nacl",
+  3,
+  FALSE,
+  bfd_i386_compatible,
+  bfd_default_scan,
+  bfd_arch_i386_onebyte_nop_fill,
+  NULL
+};
+
+static const bfd_arch_info_type bfd_x86_64_nacl_arch =
+{
+  64, /* 64 bits in a word */
+  64, /* 64 bits in an address */
+  8,  /* 8 bits in a byte */
+  bfd_arch_i386,
+  bfd_mach_x86_64_nacl,
+  "i386",
+  "i386:x86-64:nacl",
+  3,
+  FALSE,
+  bfd_i386_compatible,
+  bfd_default_scan,
+  bfd_arch_i386_onebyte_nop_fill,
+  &bfd_x64_32_nacl_arch
+};
+
+const bfd_arch_info_type bfd_i386_nacl_arch =
+{
+  32,	/* 32 bits in a word */
+  32,	/* 32 bits in an address */
+  8,	/* 8 bits in a byte */
+  bfd_arch_i386,
+  bfd_mach_i386_i386_nacl,
+  "i386",
+  "i386:nacl",
+  3,
+  TRUE,
+  bfd_i386_compatible,
+  bfd_default_scan,
+  bfd_arch_i386_onebyte_nop_fill,
+  &bfd_x86_64_nacl_arch
+};
+
 static const bfd_arch_info_type bfd_x64_32_arch_intel_syntax =
 {
   64, /* 64 bits in a word */
@@ -51,7 +197,8 @@
   FALSE,
   bfd_i386_compatible,
   bfd_default_scan,
-  0
+  bfd_arch_i386_long_nop_fill,
+  &bfd_i386_nacl_arch
 };
 
 static const bfd_arch_info_type bfd_x86_64_arch_intel_syntax =
@@ -67,6 +214,7 @@
   FALSE,
   bfd_i386_compatible,
   bfd_default_scan,
+  bfd_arch_i386_long_nop_fill,
   &bfd_x64_32_arch_intel_syntax,
 };
 
@@ -83,6 +231,7 @@
   TRUE,
   bfd_i386_compatible,
   bfd_default_scan,
+  bfd_arch_i386_short_nop_fill,
   &bfd_x86_64_arch_intel_syntax
 };
 
@@ -99,6 +248,7 @@
   FALSE,
   bfd_i386_compatible,
   bfd_default_scan,
+  bfd_arch_i386_short_nop_fill,
   &bfd_i386_arch_intel_syntax
 };
 
@@ -115,6 +265,7 @@
   FALSE,
   bfd_i386_compatible,
   bfd_default_scan,
+  bfd_arch_i386_long_nop_fill,
   &i8086_arch
 };
 
@@ -131,6 +282,7 @@
   FALSE,
   bfd_i386_compatible,
   bfd_default_scan,
+  bfd_arch_i386_long_nop_fill,
   &bfd_x64_32_arch
 };
 
@@ -147,5 +299,6 @@
   TRUE,
   bfd_i386_compatible,
   bfd_default_scan,
+  bfd_arch_i386_short_nop_fill,
   &bfd_x86_64_arch
 };
diff --git a/bfd/cpu-i860.c b/bfd/cpu-i860.c
index ae9ebcd..77c5e84 100644
--- a/bfd/cpu-i860.c
+++ b/bfd/cpu-i860.c
@@ -38,5 +38,6 @@
     TRUE,			/* Is this the default architecture? */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     0,				/* Next in list */
   };
diff --git a/bfd/cpu-i960.c b/bfd/cpu-i960.c
index c7d9231..9c4a974 100644
--- a/bfd/cpu-i960.c
+++ b/bfd/cpu-i960.c
@@ -1,6 +1,6 @@
 /* BFD library support routines for the i960 architecture.
    Copyright 1990, 1991, 1993, 1994, 1996, 1999, 2000, 2001, 2002, 2005, 2006,
-   2007 Free Software Foundation, Inc.
+   2007, 2012 Free Software Foundation, Inc.
    Hacked by Steve Chamberlain of Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -24,19 +24,13 @@
 #include "bfd.h"
 #include "libbfd.h"
 
-static bfd_boolean scan_960_mach
-  PARAMS ((const bfd_arch_info_type *, const char *));
-static const bfd_arch_info_type *compatible
-  PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
-
 /* This routine is provided a string, and tries to work out if it
    could possibly refer to the i960 machine pointed at in the
    info_struct pointer */
 
 static bfd_boolean
-scan_960_mach (ap, string)
-     const bfd_arch_info_type *ap;
-     const char *string;
+scan_960_mach (const bfd_arch_info_type *ap,
+	       const char *string)
 {
   unsigned long machine;
   int fail_because_not_80960 = FALSE;
@@ -117,9 +111,8 @@
    to its info structure */
 
 static const bfd_arch_info_type *
-compatible (a,b)
-     const bfd_arch_info_type *a;
-     const bfd_arch_info_type *b;
+compatible (const bfd_arch_info_type *a,
+	    const bfd_arch_info_type *b)
 {
 
   /* The i960 has distinct subspecies which may not interbreed:
@@ -156,17 +149,14 @@
     };
 
   if (a->arch != b->arch || matrix[a->mach][b->mach] == ERROR)
-    {
     return NULL;
-    }
-  else
-    {
-    return (a->mach  ==  matrix[a->mach][b->mach]) ?  a : b;
-    }
+
+  return (a->mach  ==  matrix[a->mach][b->mach]) ?  a : b;
 }
 
 #define N(a,b,d,n) \
-{ 32, 32, 8,bfd_arch_i960,a,"i960",b,3,d,compatible,scan_960_mach,n,}
+{ 32, 32, 8,bfd_arch_i960,a,"i960",b,3,d,compatible,scan_960_mach, \
+  bfd_arch_default_fill, n,}
 
 static const bfd_arch_info_type arch_info_struct[] =
 {
diff --git a/bfd/cpu-ia64-opc.c b/bfd/cpu-ia64-opc.c
index b797e44..dcc318e 100644
--- a/bfd/cpu-ia64-opc.c
+++ b/bfd/cpu-ia64-opc.c
@@ -380,6 +380,46 @@
 }
 
 static const char*
+ins_cnt6a (const struct ia64_operand *self, ia64_insn value,
+	    ia64_insn *code)
+{
+  if (value < 1 || value > 64)
+    return "value must be between 1 and 64";
+  return ins_immu (self, value - 1, code);
+}
+
+static const char*
+ext_cnt6a (const struct ia64_operand *self, ia64_insn code,
+	    ia64_insn *valuep)
+{
+  const char *result;
+
+  result = ext_immu (self, code, valuep);
+  if (result)
+    return result;
+
+  *valuep = *valuep + 1;
+  return 0;
+}
+
+static const char*
+ins_strd5b (const struct ia64_operand *self, ia64_insn value,
+	    ia64_insn *code)
+{
+  if (  value & 0x3f )
+    return "value must be a multiple of 64";
+  return ins_imms_scaled (self, value, code, 6);
+}
+
+static const char*
+ext_strd5b (const struct ia64_operand *self, ia64_insn code,
+	    ia64_insn *valuep)
+{
+  return ext_imms_scaled (self, code, valuep, 6);
+}
+
+
+static const char*
 ins_inc3 (const struct ia64_operand *self, ia64_insn value, ia64_insn *code)
 {
   BFD_HOST_64_BIT val = value;
@@ -480,6 +520,8 @@
       "a general register" },
     { REG, ins_reg,   ext_reg,	 "r", {{ 2, 20}}, 0,		/* R3_2 */
       "a general register r0-r3" },
+    { REG, ins_reg,   ext_reg,	 "dahr", {{ 3, 23}}, 0,		/* DAHR */
+      "a dahr register dahr0-7" },
 
     /* memory operands: */
     { IND, ins_reg,   ext_reg,	"",      {{7, 20}}, 0,		/* MR3 */
@@ -504,6 +546,8 @@
       "a pmc register" },
     { IND, ins_reg,   ext_reg,	"pmd",   {{7, 20}}, 0,		/* PMD_R3 */
       "a pmd register" },
+    { IND, ins_reg,   ext_reg,	"dahr",  {{7, 20}}, 0,		/* DAHR_R3 */
+      "a dahr register" },
     { IND, ins_reg,   ext_reg,	"rr",    {{7, 20}}, 0,		/* RR_R3 */
       "an rr register" },
 
@@ -568,9 +612,15 @@
     { ABS, ins_imms,  ext_imms, 0,				/* IMM14 */
       {{ 7, 13}, { 6, 27}, { 1, 36}}, SDEC,
       "a 14-bit integer (-8192-8191)" },
+    { ABS, ins_immu,  ext_immu,  0,				/* IMMU16 */
+      {{4,  6}, {11, 12}, { 1, 36}}, UDEC,
+      "a 16-bit unsigned" },
     { ABS, ins_imms1, ext_imms1, 0,				/* IMM17 */
       {{ 7,  6}, { 8, 24}, { 1, 36}}, 0,
       "a 17-bit integer (-65536-65535)" },
+    { ABS, ins_immu,  ext_immu,  0,				/* IMMU19 */
+      {{4,  6}, {14, 12}, { 1, 36}}, UDEC,
+      "a 19-bit unsigned" },
     { ABS, ins_immu,  ext_immu,  0, {{20,  6}, { 1, 36}}, 0,	/* IMMU21 */
       "a 21-bit unsigned" },
     { ABS, ins_imms,  ext_imms,  0,				/* IMM22 */
@@ -613,4 +663,8 @@
 
     { ABS, ins_const, ext_const, 0, {{0, 0}}, 0,		/* LDXMOV */
       "ldxmov target" },
+    { ABS, ins_cnt6a, ext_cnt6a, 0, {{6, 6}}, UDEC,		/* CNT6a */
+      "lfetch count" },
+    { ABS, ins_strd5b, ext_strd5b, 0, {{5, 13}}, SDEC,		/* STRD5b*/
+      "lfetch stride" },
   };
diff --git a/bfd/cpu-ia64.c b/bfd/cpu-ia64.c
index c97de1a..4ea37c7 100644
--- a/bfd/cpu-ia64.c
+++ b/bfd/cpu-ia64.c
@@ -35,7 +35,8 @@
     3,	/* log2 of section alignment */
     TRUE, /* the one and only */
     bfd_default_compatible,
-    bfd_default_scan ,
+    bfd_default_scan,
+    bfd_arch_default_fill,
     0,
   };
 
@@ -51,7 +52,8 @@
     3,	/* log2 of section alignment */
     TRUE, /* the one and only */
     bfd_default_compatible,
-    bfd_default_scan ,
+    bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_ia64_elf32_arch,
   };
 
diff --git a/bfd/cpu-ip2k.c b/bfd/cpu-ip2k.c
index 0b959bd..d8eaf3c 100644
--- a/bfd/cpu-ip2k.c
+++ b/bfd/cpu-ip2k.c
@@ -35,6 +35,7 @@
   FALSE,		        /* The default ?  */
   bfd_default_compatible,	/* Architecture comparison fn.  */
   bfd_default_scan,		/* String to architecture convert fn.  */
+  bfd_arch_default_fill,	/* Default fill.  */
   NULL				/* Next in list.  */
 };
 
@@ -51,5 +52,6 @@
   TRUE,				/* The default ?  */
   bfd_default_compatible,	/* Architecture comparison fn.  */
   bfd_default_scan,		/* String to architecture convert fn.  */
+  bfd_arch_default_fill,	/* Default fill.  */
   & bfd_ip2k_nonext_arch	/* Next in list.  */
 };
diff --git a/bfd/cpu-iq2000.c b/bfd/cpu-iq2000.c
index 72d8363..648380e 100644
--- a/bfd/cpu-iq2000.c
+++ b/bfd/cpu-iq2000.c
@@ -36,6 +36,7 @@
     FALSE,			/* the default ? */
     bfd_default_compatible,	/* architecture comparison fn */
     bfd_default_scan,		/* string to architecture convert fn */
+    bfd_arch_default_fill,	/* Default fill.  */
     NULL			/* next in list */
   }
 };
@@ -53,5 +54,6 @@
   TRUE,				/* the default ? */
   bfd_default_compatible,	/* architecture comparison fn */
   bfd_default_scan,		/* string to architecture convert fn */
+  bfd_arch_default_fill,	/* Default fill.  */
   &arch_info_struct[0],		/* next in list */
 };
diff --git a/bfd/cpu-k1om.c b/bfd/cpu-k1om.c
index fa030ae..54b6e58 100644
--- a/bfd/cpu-k1om.c
+++ b/bfd/cpu-k1om.c
@@ -23,6 +23,9 @@
 #include "bfd.h"
 #include "libbfd.h"
 
+extern void * bfd_arch_i386_short_nop_fill (bfd_size_type, bfd_boolean,
+					    bfd_boolean);
+
 static const bfd_arch_info_type bfd_k1om_arch_intel_syntax =
 {
   64, /* 64 bits in a word */
@@ -36,6 +39,7 @@
   TRUE,
   bfd_default_compatible,
   bfd_default_scan,
+  bfd_arch_i386_short_nop_fill,
   0
 };
 
@@ -52,5 +56,6 @@
   TRUE,
   bfd_default_compatible,
   bfd_default_scan,
+  bfd_arch_i386_short_nop_fill,
   &bfd_k1om_arch_intel_syntax
 };
diff --git a/bfd/cpu-l1om.c b/bfd/cpu-l1om.c
index c1057c4..46ac3a0 100644
--- a/bfd/cpu-l1om.c
+++ b/bfd/cpu-l1om.c
@@ -23,6 +23,9 @@
 #include "bfd.h"
 #include "libbfd.h"
 
+extern void * bfd_arch_i386_short_nop_fill (bfd_size_type, bfd_boolean,
+					    bfd_boolean);
+
 static const bfd_arch_info_type bfd_l1om_arch_intel_syntax =
 {
   64, /* 64 bits in a word */
@@ -36,6 +39,7 @@
   TRUE,
   bfd_default_compatible,
   bfd_default_scan,
+  bfd_arch_i386_short_nop_fill,
   0
 };
 
@@ -52,5 +56,6 @@
   TRUE,
   bfd_default_compatible,
   bfd_default_scan,
+  bfd_arch_i386_short_nop_fill,
   &bfd_l1om_arch_intel_syntax
 };
diff --git a/bfd/cpu-lm32.c b/bfd/cpu-lm32.c
index 227612f..d0fd93a 100644
--- a/bfd/cpu-lm32.c
+++ b/bfd/cpu-lm32.c
@@ -1,5 +1,5 @@
 /* BFD support for the Lattice Mico32 architecture.
-   Copyright 2008 Free Software Foundation, Inc.
+   Copyright 2008, 2012 Free Software Foundation, Inc.
    Contributed by Jon Beniston <[email protected]>
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -19,16 +19,16 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 
-const bfd_arch_info_type bfd_lm32_arch = 
+const bfd_arch_info_type bfd_lm32_arch =
 {
     32,                           /* Bits in word.  */
     32,                           /* Bits in address.  */
     8,                            /* Bits in byte.  */
-    bfd_arch_lm32,                /* Enum bfd_architecture.  */ 
+    bfd_arch_lm32,                /* Enum bfd_architecture.  */
     bfd_mach_lm32,                /* Machine number.  */
     "lm32",                       /* Architecture name.  */
     "lm32",                       /* Printable name.  */
@@ -36,6 +36,7 @@
     TRUE,                         /* Is this the default machine for the target.  */
     bfd_default_compatible,       /* Function callback to test if two files have compatible machines.  */
     bfd_default_scan,
+    bfd_arch_default_fill,
     NULL                          /* Next.  */
 };
 
diff --git a/bfd/cpu-m10200.c b/bfd/cpu-m10200.c
index 218891d..f42a5ea 100644
--- a/bfd/cpu-m10200.c
+++ b/bfd/cpu-m10200.c
@@ -34,6 +34,7 @@
     2,
     TRUE, /* the one and only */
     bfd_default_compatible,
-    bfd_default_scan ,
+    bfd_default_scan,
+    bfd_arch_default_fill,
     0,
   };
diff --git a/bfd/cpu-m10300.c b/bfd/cpu-m10300.c
index 7f89665..6fd8c67 100644
--- a/bfd/cpu-m10300.c
+++ b/bfd/cpu-m10300.c
@@ -36,6 +36,7 @@
     FALSE,
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     0,
   };
 
@@ -52,6 +53,7 @@
     FALSE,
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_am33_2_arch,
   };
 
@@ -68,5 +70,6 @@
     TRUE, /* the one and only */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_am33_arch,
   };
diff --git a/bfd/cpu-m32c.c b/bfd/cpu-m32c.c
index d2f9cb1..9c26938 100644
--- a/bfd/cpu-m32c.c
+++ b/bfd/cpu-m32c.c
@@ -49,6 +49,7 @@
     FALSE,			/* the default ? */
     bfd_default_compatible,	/* architecture comparison fn */
     m32c_scan,			/* string to architecture convert fn */
+    bfd_arch_default_fill,	/* Default fill.  */
     NULL			/* next in list */
   },
 };
@@ -66,5 +67,6 @@
   TRUE,				/* The default ?  */
   bfd_default_compatible,	/* Architecture comparison fn.  */
   m32c_scan,			/* String to architecture convert fn.  */
+  bfd_arch_default_fill,	/* Default fill.  */
   &arch_info_struct[0],		/* Next in list.  */
 };
diff --git a/bfd/cpu-m32r.c b/bfd/cpu-m32r.c
index 8180d6c..8f373b4 100644
--- a/bfd/cpu-m32r.c
+++ b/bfd/cpu-m32r.c
@@ -25,7 +25,7 @@
 
 #define N(number, print, default, next)  \
 {  32, 32, 8, bfd_arch_m32r, number, "m32r", print, 4, default, \
-     bfd_default_compatible, bfd_default_scan, next }
+     bfd_default_compatible, bfd_default_scan, bfd_arch_default_fill, next }
 
 #define M32R2_NEXT   & arch_info_struct [1]
 #define NEXT         & arch_info_struct [0]
diff --git a/bfd/cpu-m68hc11.c b/bfd/cpu-m68hc11.c
index 313d820..7f3c074 100644
--- a/bfd/cpu-m68hc11.c
+++ b/bfd/cpu-m68hc11.c
@@ -35,5 +35,6 @@
     TRUE,
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     0,
 };
diff --git a/bfd/cpu-m68hc12.c b/bfd/cpu-m68hc12.c
index 2a115b9..2dbf627 100644
--- a/bfd/cpu-m68hc12.c
+++ b/bfd/cpu-m68hc12.c
@@ -35,6 +35,7 @@
     TRUE,
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     0,
 };
 
@@ -51,5 +52,6 @@
     TRUE,
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_m68hc12s_arch,
 };
diff --git a/bfd/cpu-m68k.c b/bfd/cpu-m68k.c
index ec9bccd..4c7b845 100644
--- a/bfd/cpu-m68k.c
+++ b/bfd/cpu-m68k.c
@@ -30,7 +30,8 @@
 		     const bfd_arch_info_type *b);
 
 #define N(name, print,d,next)  \
-{  32, 32, 8, bfd_arch_m68k, name, "m68k",print,2,d,bfd_m68k_compatible,bfd_default_scan, next, }
+{  32, 32, 8, bfd_arch_m68k, name, "m68k",print,2,d,bfd_m68k_compatible, \
+   bfd_default_scan, bfd_arch_default_fill, next, }
 
 static const bfd_arch_info_type arch_info_struct[] =
   {
@@ -110,7 +111,7 @@
 
 /* Table indexed by bfd_mach_arch number indicating which
    architectural features are supported.  */
-static const unsigned m68k_arch_features[] = 
+static const unsigned m68k_arch_features[] =
 {
   0,
   m68000|m68881|m68851,
@@ -185,7 +186,7 @@
        ix++)
     {
       unsigned this_extra, this_missing;
-      
+
       if (m68k_arch_features[ix] == features)
 	return ix;
       this_extra = bit_count (m68k_arch_features[ix] & ~features);
@@ -194,7 +195,7 @@
 	  extra = this_extra;
 	  superset = ix;
 	}
-      
+
       this_missing = bit_count (features & ~m68k_arch_features[ix]);
       if (this_missing < missing)
 	{
@@ -219,7 +220,7 @@
     return b;
   if (!b->mach)
     return a;
-  
+
   if (a->mach <= bfd_mach_m68060 && b->mach <= bfd_mach_m68060)
     /* Merge m68k machine. */
     return a->mach > b->mach ? a : b;
diff --git a/bfd/cpu-m88k.c b/bfd/cpu-m88k.c
index 7e7c18d..d345902 100644
--- a/bfd/cpu-m88k.c
+++ b/bfd/cpu-m88k.c
@@ -36,6 +36,7 @@
     3,
     TRUE, /* the one and only */
     bfd_default_compatible,
-    bfd_default_scan ,
+    bfd_default_scan,
+    bfd_arch_default_fill,
     0,
   };
diff --git a/bfd/cpu-m9s12x.c b/bfd/cpu-m9s12x.c
new file mode 100644
index 0000000..d224b83
--- /dev/null
+++ b/bfd/cpu-m9s12x.c
@@ -0,0 +1,41 @@
+/* BFD support for the Freescale 9S12X processor
+   Copyright 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_m9s12x_arch =
+{
+    16,	/* 16 bits in a word.  */
+    32,	/* 16 bits in an address.  */
+    8,	/* 8 bits in a byte.  */
+    bfd_arch_m9s12x,
+    0,
+    "m9s12x",
+    "m9s12x",
+    4, /* Section alignment power.  */
+    TRUE,
+    bfd_default_compatible,
+    bfd_default_scan,
+    bfd_arch_default_fill,
+    0,
+};
+
diff --git a/bfd/cpu-m9s12xg.c b/bfd/cpu-m9s12xg.c
new file mode 100644
index 0000000..6958a13
--- /dev/null
+++ b/bfd/cpu-m9s12xg.c
@@ -0,0 +1,41 @@
+/* BFD support for the Freescale 9S12-XGATE co-processor
+   Copyright 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_m9s12xg_arch =
+{
+    16,	/* 16 bits in a word.  */
+    32,	/* 16 bits in an address.  */
+    8,	/* 8 bits in a byte.  */
+    bfd_arch_m9s12xg,
+    0,
+    "m9s12xg",
+    "m9s12xg",
+    4, /* Section alignment power.  */
+    TRUE,
+    bfd_default_compatible,
+    bfd_default_scan,
+    bfd_arch_default_fill,
+    0,
+};
+
diff --git a/bfd/cpu-mcore.c b/bfd/cpu-mcore.c
index c01dd10..80b3290 100644
--- a/bfd/cpu-mcore.c
+++ b/bfd/cpu-mcore.c
@@ -35,5 +35,6 @@
   TRUE,		  		/* Is this the default architecture ? */
   bfd_default_compatible,	/* Architecture comparison function */
   bfd_default_scan,	   	/* String to architecture conversion */
+  bfd_arch_default_fill,	/* Default fill.  */
   NULL			   	/* Next in list */
 };
diff --git a/bfd/cpu-mep.c b/bfd/cpu-mep.c
index 7ac871f..94cb080 100644
--- a/bfd/cpu-mep.c
+++ b/bfd/cpu-mep.c
@@ -22,7 +22,8 @@
 #include "libbfd.h"
 
 #define MA(x, n, def, y) { 32, 32, 8, bfd_arch_mep, x, "mep", n, \
-	2, def, bfd_default_compatible, bfd_default_scan, y }
+	2, def, bfd_default_compatible, bfd_default_scan, \
+	bfd_arch_default_fill, y }
 
 static const bfd_arch_info_type bfd_c5_arch = MA (bfd_mach_mep_c5, "c5", FALSE, NULL);
 static const bfd_arch_info_type bfd_h1_arch = MA (bfd_mach_mep_h1, "h1", FALSE, & bfd_c5_arch);
diff --git a/bfd/cpu-metag.c b/bfd/cpu-metag.c
new file mode 100644
index 0000000..a8dbfaa
--- /dev/null
+++ b/bfd/cpu-metag.c
@@ -0,0 +1,41 @@
+/* BFD support for the Imagination Technologies Meta processor.
+   Copyright (C) 2013 Free Software Foundation, Inc.
+   Contributed by Imagination Technologies Ltd.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_metag_arch =
+{
+  32,				/* Bits per word.  */
+  32,				/* Bits per address.  */
+  8,				/* Bits per byte.  */
+  bfd_arch_metag,		/* Architecture.  */
+  bfd_mach_metag,		/* Machine.  */
+  "metag",			/* Architecture name.  */
+  "metag",			/* Printable name.  */
+  4,				/* Section align power.  */
+  TRUE,				/* The default ?  */
+  bfd_default_compatible,	/* Architecture comparison fn.  */
+  bfd_default_scan,		/* String to architecture convert fn.  */
+  bfd_arch_default_fill,	/* Default fill.  */
+  NULL				/* Next in list.  */
+};
diff --git a/bfd/cpu-microblaze.c b/bfd/cpu-microblaze.c
index 45a4a2b..2cf6bc6 100644
--- a/bfd/cpu-microblaze.c
+++ b/bfd/cpu-microblaze.c
@@ -1,6 +1,6 @@
 /* BFD Xilinx MicroBlaze architecture definition
 
-   Copyright 2009 Free Software Foundation, Inc.
+   Copyright 2009, 2012 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -19,8 +19,8 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 
 const bfd_arch_info_type bfd_microblaze_arch =
@@ -36,5 +36,6 @@
   TRUE,		  		/* Is this the default architecture ?  */
   bfd_default_compatible,	/* Architecture comparison function.  */
   bfd_default_scan,	   	/* String to architecture conversion.  */
+  bfd_arch_default_fill,	/* Default fill.  */
   NULL			   	/* Next in list.  */
 };
diff --git a/bfd/cpu-mips.c b/bfd/cpu-mips.c
index 42d43a9..59a7c16 100644
--- a/bfd/cpu-mips.c
+++ b/bfd/cpu-mips.c
@@ -1,6 +1,7 @@
 /* bfd back-end for mips support
    Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001,
-   2002, 2003, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
+   2002, 2003, 2004, 2005, 2007, 2008, 2009, 2013
+   Free Software Foundation, Inc.
    Written by Steve Chamberlain of Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -55,6 +56,7 @@
     DEFAULT,						\
     mips_compatible,					\
     bfd_default_scan,					\
+    bfd_arch_default_fill,				\
     NEXT,						\
   }
 
@@ -74,6 +76,7 @@
   I_mips5000,
   I_mips5400,
   I_mips5500,
+  I_mips5900,
   I_mips6000,
   I_mips7000,
   I_mips8000,
@@ -93,6 +96,8 @@
   I_loongson_2f,
   I_loongson_3a,
   I_mipsocteon,
+  I_mipsocteonp,
+  I_mipsocteon2,
   I_xlr,
   I_micromips
 };
@@ -115,6 +120,7 @@
   N (64, 64, bfd_mach_mips5000, "mips:5000",      FALSE, NN(I_mips5000)),
   N (64, 64, bfd_mach_mips5400, "mips:5400",      FALSE, NN(I_mips5400)),
   N (64, 64, bfd_mach_mips5500, "mips:5500",      FALSE, NN(I_mips5500)),
+  N (64, 32, bfd_mach_mips5900, "mips:5900",      FALSE, NN(I_mips5900)),
   N (32, 32, bfd_mach_mips6000, "mips:6000",      FALSE, NN(I_mips6000)),
   N (64, 64, bfd_mach_mips7000, "mips:7000",      FALSE, NN(I_mips7000)),
   N (64, 64, bfd_mach_mips8000, "mips:8000",      FALSE, NN(I_mips8000)),
@@ -134,6 +140,8 @@
   N (64, 64, bfd_mach_mips_loongson_2f, "mips:loongson_2f",       FALSE, NN(I_loongson_2f)),
   N (64, 64, bfd_mach_mips_loongson_3a, "mips:loongson_3a",       FALSE, NN(I_loongson_3a)),
   N (64, 64, bfd_mach_mips_octeon,"mips:octeon",  FALSE, NN(I_mipsocteon)),
+  N (64, 64, bfd_mach_mips_octeonp,"mips:octeon+",  FALSE, NN(I_mipsocteonp)),
+  N (64, 64, bfd_mach_mips_octeon2,"mips:octeon2",  FALSE, NN(I_mipsocteon2)),
   N (64, 64, bfd_mach_mips_xlr, "mips:xlr",       FALSE, NN(I_xlr)),
   N (64, 64, bfd_mach_mips_micromips,"mips:micromips",FALSE,0)
 };
diff --git a/bfd/cpu-mmix.c b/bfd/cpu-mmix.c
index 6cf8753..f706b49 100644
--- a/bfd/cpu-mmix.c
+++ b/bfd/cpu-mmix.c
@@ -38,5 +38,6 @@
    TRUE,			/* This is the default architecture.  */
    bfd_default_compatible,	/* Architecture comparison function.  */
    bfd_default_scan,		/* String to architecture conversion.  */
+   bfd_arch_default_fill,	/* Default fill.  */
    NULL				/* Next in list.  */
 };
diff --git a/bfd/cpu-moxie.c b/bfd/cpu-moxie.c
index 39debbc..103a56a 100644
--- a/bfd/cpu-moxie.c
+++ b/bfd/cpu-moxie.c
@@ -34,7 +34,8 @@
     "moxie",          /* Printable name.  */
     2,                /* Unsigned int section alignment power.  */
     TRUE,             /* The one and only.  */
-    bfd_default_compatible, 
-    bfd_default_scan ,
+    bfd_default_compatible,
+    bfd_default_scan,
+    bfd_arch_default_fill,
     0,
   };
diff --git a/bfd/cpu-msp430.c b/bfd/cpu-msp430.c
index 63c301a..73b6e66 100644
--- a/bfd/cpu-msp430.c
+++ b/bfd/cpu-msp430.c
@@ -1,5 +1,5 @@
 /* BFD library support routines for the MSP architecture.
-   Copyright (C) 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2002-2013 Free Software Foundation, Inc.
    Contributed by Dmitry Diky <[email protected]>
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -23,8 +23,23 @@
 #include "bfd.h"
 #include "libbfd.h"
 
-static const bfd_arch_info_type *compatible
-  PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
+/* This routine is provided two arch_infos and works out which MSP
+   machine which would be compatible with both and returns a pointer
+   to its info structure.  */
+
+static const bfd_arch_info_type *
+compatible (const bfd_arch_info_type * a,
+	    const bfd_arch_info_type * b)
+{
+  /* If a & b are for different architectures we can do nothing.  */
+  if (a->arch != b->arch)
+    return NULL;
+
+  if (a->mach <= b->mach)
+    return b;
+
+  return a;
+}
 
 #define N(addr_bits, machine, print, default, next)		\
 {								\
@@ -39,6 +54,7 @@
   default,			/* The default machine.  */	\
   compatible,							\
   bfd_default_scan,						\
+  bfd_arch_default_fill,					\
   next								\
 }
 
@@ -61,53 +77,62 @@
 
   /* msp430x15x.  */
   N (16, bfd_mach_msp15, "msp:15", FALSE, & arch_info_struct[6]),
-  
+
   /* msp430x16x.  */
   N (16, bfd_mach_msp16, "msp:16", FALSE, & arch_info_struct[7]),
 
+  /* msp430x20x.  */
+  N (16, bfd_mach_msp20, "msp:20", FALSE, & arch_info_struct[8]),
+
   /* msp430x21x.  */
-  N (16, bfd_mach_msp21, "msp:21", FALSE, & arch_info_struct[8]),
+  N (16, bfd_mach_msp21, "msp:21", FALSE, & arch_info_struct[9]),
+
+  /* msp430x22x.  */
+  N (16, bfd_mach_msp22, "msp:22", FALSE, & arch_info_struct[10]),
+
+  /* msp430x23x.  */
+  N (16, bfd_mach_msp23, "msp:23", FALSE, & arch_info_struct[11]),
+
+  /* msp430x24x.  */
+  N (16, bfd_mach_msp24, "msp:24", FALSE, & arch_info_struct[12]),
+
+  /* msp430x26x.  */
+  N (16, bfd_mach_msp26, "msp:26", FALSE, & arch_info_struct[13]),
 
   /* msp430x31x.  */
-  N (16, bfd_mach_msp31, "msp:31", FALSE, & arch_info_struct[9]), 
+  N (16, bfd_mach_msp31, "msp:31", FALSE, & arch_info_struct[14]),
 
   /* msp430x32x.  */
-  N (16, bfd_mach_msp32, "msp:32", FALSE, & arch_info_struct[10]), 
+  N (16, bfd_mach_msp32, "msp:32", FALSE, & arch_info_struct[15]),
 
   /* msp430x33x.  */
-  N (16, bfd_mach_msp33, "msp:33", FALSE, & arch_info_struct[11]),
-  
+  N (16, bfd_mach_msp33, "msp:33", FALSE, & arch_info_struct[16]),
+
   /* msp430x41x.  */
-  N (16, bfd_mach_msp41, "msp:41", FALSE, & arch_info_struct[12]),
+  N (16, bfd_mach_msp41, "msp:41", FALSE, & arch_info_struct[17]),
 
   /* msp430x42x.  */
-  N (16, bfd_mach_msp42, "msp:42", FALSE, & arch_info_struct[13]),
+  N (16, bfd_mach_msp42, "msp:42", FALSE, & arch_info_struct[18]),
 
   /* msp430x43x.  */
-  N (16, bfd_mach_msp43, "msp:43", FALSE, & arch_info_struct[14]),
+  N (16, bfd_mach_msp43, "msp:43", FALSE, & arch_info_struct[19]),
 
   /* msp430x44x.  */
-  N (16, bfd_mach_msp43, "msp:44", FALSE, NULL)
+  N (16, bfd_mach_msp43, "msp:44", FALSE, & arch_info_struct[20]),
+
+  /* msp430x46x.  */
+  N (16, bfd_mach_msp46, "msp:46", FALSE, & arch_info_struct[21]),
+
+  /* msp430x47x.  */
+  N (16, bfd_mach_msp47, "msp:47", FALSE, & arch_info_struct[22]),
+
+  /* msp430x54x.  */
+  N (16, bfd_mach_msp54, "msp:54", FALSE, & arch_info_struct[23]),
+
+  N (32, bfd_mach_msp430x, "msp:430X", FALSE, NULL)
+
 };
 
 const bfd_arch_info_type bfd_msp430_arch =
   N (16, bfd_mach_msp14, "msp:14", TRUE, & arch_info_struct[0]);
 
-/* This routine is provided two arch_infos and works out which MSP
-   machine which would be compatible with both and returns a pointer
-   to its info structure.  */
-
-static const bfd_arch_info_type *
-compatible (a,b)
-     const bfd_arch_info_type * a;
-     const bfd_arch_info_type * b;
-{
-  /* If a & b are for different architectures we can do nothing.  */
-  if (a->arch != b->arch)
-    return NULL;
-
-  if (a->mach <= b->mach)
-    return b;
-
-  return a;
-}
diff --git a/bfd/cpu-mt.c b/bfd/cpu-mt.c
index 519871d..0ec10c8 100644
--- a/bfd/cpu-mt.c
+++ b/bfd/cpu-mt.c
@@ -36,6 +36,7 @@
   FALSE,		        /* The default ?  */
   bfd_default_compatible,	/* Architecture comparison fn.  */
   bfd_default_scan,		/* String to architecture convert fn.  */
+  bfd_arch_default_fill,	/* Default fill.  */
   &arch_info_struct[1]          /* Next in list.  */
 },
 {
@@ -50,6 +51,7 @@
   FALSE,		        /* The default ?  */
   bfd_default_compatible,	/* Architecture comparison fn.  */
   bfd_default_scan,		/* String to architecture convert fn.  */
+  bfd_arch_default_fill,	/* Default fill.  */
   NULL				/* Next in list.  */
 },
 };
@@ -67,6 +69,7 @@
   TRUE,		        	/* The default ?  */
   bfd_default_compatible,	/* Architecture comparison fn.  */
   bfd_default_scan,		/* String to architecture convert fn.  */
+  bfd_arch_default_fill,	/* Default fill.  */
   &arch_info_struct[0]		/* Next in list.  */
 };
 
diff --git a/bfd/cpu-nios2.c b/bfd/cpu-nios2.c
new file mode 100644
index 0000000..fa4c859
--- /dev/null
+++ b/bfd/cpu-nios2.c
@@ -0,0 +1,44 @@
+/* BFD support for the Altera Nios II processor.
+   Copyright (C) 2012, 2013 Free Software Foundation, Inc.
+   Contributed by Nigel Gray ([email protected]).
+   Contributed by Mentor Graphics, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libbfd.h"
+
+#define N(BITS_WORD, BITS_ADDR, NUMBER, PRINT, DEFAULT, NEXT)		\
+  {							\
+    BITS_WORD, /*  bits in a word */			\
+    BITS_ADDR, /* bits in an address */			\
+    8,	/* 8 bits in a byte */				\
+    bfd_arch_nios2,					\
+    NUMBER,						\
+    "nios2",						\
+    PRINT,						\
+    3,							\
+    DEFAULT,						\
+    bfd_default_compatible,				\
+    bfd_default_scan,					\
+    bfd_arch_default_fill,			       	\
+    NEXT						\
+  }
+
+const bfd_arch_info_type bfd_nios2_arch = N (32, 32, 0, "nios2", TRUE, NULL);
diff --git a/bfd/cpu-ns32k.c b/bfd/cpu-ns32k.c
index 216b248..48a6bc6 100644
--- a/bfd/cpu-ns32k.c
+++ b/bfd/cpu-ns32k.c
@@ -1,6 +1,6 @@
 /* BFD support for the ns32k architecture.
    Copyright 1990, 1991, 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005, 2007 Free Software Foundation, Inc.
+   2004, 2005, 2007, 2012 Free Software Foundation, Inc.
    Almost totally rewritten by Ian Dall from initial work
    by Andrew Cagney.
 
@@ -27,7 +27,8 @@
 #include "ns32k.h"
 
 #define N(machine, printable, d, next)  \
-{  32, 32, 8, bfd_arch_ns32k, machine, "ns32k",printable,3,d,bfd_default_compatible,bfd_default_scan, next, }
+{  32, 32, 8, bfd_arch_ns32k, machine, "ns32k",printable,3,d, \
+   bfd_default_compatible,bfd_default_scan,bfd_arch_default_fill,next, }
 
 static const bfd_arch_info_type arch_info_struct[] =
 {
@@ -37,16 +38,8 @@
 const bfd_arch_info_type bfd_ns32k_arch =
   N(32032,"ns32k:32032",FALSE, &arch_info_struct[0]);
 
-static bfd_reloc_status_type do_ns32k_reloc
-  PARAMS ((bfd *, arelent *, struct bfd_symbol *, PTR, asection *,
-	   bfd *, char **,
-	   bfd_vma (*) (bfd_byte *, int),
-	   void (*) (bfd_vma, bfd_byte *, int)));
-
 bfd_vma
-_bfd_ns32k_get_displacement (buffer, size)
-     bfd_byte *buffer;
-     int size;
+_bfd_ns32k_get_displacement (bfd_byte *buffer, int size)
 {
   bfd_signed_vma value;
 
@@ -77,10 +70,7 @@
 }
 
 void
-_bfd_ns32k_put_displacement (value, buffer, size)
-     bfd_vma value;
-     bfd_byte *buffer;
-     int size;
+_bfd_ns32k_put_displacement (bfd_vma value, bfd_byte *buffer, int size)
 {
   switch (size)
     {
@@ -108,9 +98,7 @@
 }
 
 bfd_vma
-_bfd_ns32k_get_immediate (buffer, size)
-     bfd_byte *buffer;
-     int size;
+_bfd_ns32k_get_immediate (bfd_byte *buffer, int size)
 {
   bfd_vma value = 0;
 
@@ -131,10 +119,7 @@
 }
 
 void
-_bfd_ns32k_put_immediate (value, buffer, size)
-     bfd_vma value;
-     bfd_byte *buffer;
-     int size;
+_bfd_ns32k_put_immediate (bfd_vma value, bfd_byte *buffer, int size)
 {
   buffer += size - 1;
   switch (size)
@@ -155,17 +140,15 @@
    needs to be!  */
 
 static bfd_reloc_status_type
-do_ns32k_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd,
-		error_message, get_data, put_data)
-     bfd *abfd;
-     arelent *reloc_entry;
-     struct bfd_symbol *symbol;
-     PTR data;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
-     bfd_vma (*get_data) PARAMS ((bfd_byte *, int));
-     void (*put_data) PARAMS ((bfd_vma, bfd_byte *, int));
+do_ns32k_reloc (bfd *      abfd,
+		arelent *  reloc_entry,
+		struct bfd_symbol * symbol,
+		void *     data,
+		asection * input_section,
+		bfd *      output_bfd,
+		char **    error_message ATTRIBUTE_UNUSED,
+		bfd_vma (* get_data) (bfd_byte *, int),
+		void (*    put_data) (bfd_vma, bfd_byte *, int))
 {
   int overflow = 0;
   bfd_vma relocation;
@@ -176,7 +159,7 @@
   asection *reloc_target_output_section;
   bfd_byte *location;
 
-  if ((symbol->section == &bfd_abs_section)
+  if (bfd_is_abs_section (symbol->section)
       && output_bfd != (bfd *) NULL)
     {
       reloc_entry->address += input_section->output_offset;
@@ -186,7 +169,7 @@
   /* If we are not producing relocatable output, return an error if
      the symbol is not defined.  An undefined weak symbol is
      considered to have a value of zero (SVR4 ABI, p. 4-27).  */
-  if (symbol->section == &bfd_und_section
+  if (bfd_is_und_section (symbol->section)
       && (symbol->flags & BSF_WEAK) == 0
       && output_bfd == (bfd *) NULL)
     flag = bfd_reloc_undefined;
@@ -582,14 +565,12 @@
 /* Relocate a given location using a given value and howto.  */
 
 bfd_reloc_status_type
-_bfd_do_ns32k_reloc_contents (howto, input_bfd, relocation, location,
-			      get_data, put_data)
-     reloc_howto_type *howto;
-     bfd *input_bfd ATTRIBUTE_UNUSED;
-     bfd_vma relocation;
-     bfd_byte *location;
-     bfd_vma (*get_data) PARAMS ((bfd_byte *, int));
-     void (*put_data) PARAMS ((bfd_vma, bfd_byte *, int));
+_bfd_do_ns32k_reloc_contents (reloc_howto_type *howto,
+			      bfd *input_bfd ATTRIBUTE_UNUSED,
+			      bfd_vma relocation,
+			      bfd_byte *location,
+			      bfd_vma (*get_data) (bfd_byte *, int),
+			      void (*put_data) (bfd_vma, bfd_byte *, int))
 {
   int size;
   bfd_vma x;
@@ -757,15 +738,13 @@
 }
 
 bfd_reloc_status_type
-_bfd_ns32k_reloc_disp (abfd, reloc_entry, symbol, data, input_section,
-		       output_bfd, error_message)
-     bfd *abfd;
-     arelent *reloc_entry;
-     struct bfd_symbol *symbol;
-     PTR data;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message;
+_bfd_ns32k_reloc_disp (bfd *abfd,
+		       arelent *reloc_entry,
+		       struct bfd_symbol *symbol,
+		       void * data,
+		       asection *input_section,
+		       bfd *output_bfd,
+		       char **error_message)
 {
   return do_ns32k_reloc (abfd, reloc_entry, symbol, data, input_section,
 			 output_bfd, error_message,
@@ -774,15 +753,13 @@
 }
 
 bfd_reloc_status_type
-_bfd_ns32k_reloc_imm (abfd, reloc_entry, symbol, data, input_section,
-		      output_bfd, error_message)
-     bfd *abfd;
-     arelent *reloc_entry;
-     struct bfd_symbol *symbol;
-     PTR data;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message;
+_bfd_ns32k_reloc_imm (bfd *abfd,
+		      arelent *reloc_entry,
+		      struct bfd_symbol *symbol,
+		      void * data,
+		      asection *input_section,
+		      bfd *output_bfd,
+		      char **error_message)
 {
   return do_ns32k_reloc (abfd, reloc_entry, symbol, data, input_section,
 			 output_bfd, error_message, _bfd_ns32k_get_immediate,
@@ -790,15 +767,13 @@
 }
 
 bfd_reloc_status_type
-_bfd_ns32k_final_link_relocate (howto, input_bfd, input_section, contents,
-				address, value, addend)
-     reloc_howto_type *howto;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     bfd_vma address;
-     bfd_vma value;
-     bfd_vma addend;
+_bfd_ns32k_final_link_relocate (reloc_howto_type *howto,
+				bfd *input_bfd,
+				asection *input_section,
+				bfd_byte *contents,
+				bfd_vma address,
+				bfd_vma value,
+				bfd_vma addend)
 {
   bfd_vma relocation;
 
diff --git a/bfd/cpu-openrisc.c b/bfd/cpu-openrisc.c
index a430349..8e3e878 100644
--- a/bfd/cpu-openrisc.c
+++ b/bfd/cpu-openrisc.c
@@ -36,6 +36,7 @@
     DEFAULT,                                                  \
     bfd_default_compatible,                                   \
     bfd_default_scan,                                         \
+    bfd_arch_default_fill,				      \
     NEXT,                                                     \
   }
 
diff --git a/bfd/cpu-or32.c b/bfd/cpu-or32.c
index b9803ed..34ea52b 100644
--- a/bfd/cpu-or32.c
+++ b/bfd/cpu-or32.c
@@ -35,7 +35,8 @@
     4,
     TRUE,         /* The one and only.  */
     bfd_default_compatible,
-    bfd_default_scan ,
+    bfd_default_scan,
+    bfd_arch_default_fill,
     0,
   };
 
diff --git a/bfd/cpu-pdp11.c b/bfd/cpu-pdp11.c
index 3147f56..57c3068 100644
--- a/bfd/cpu-pdp11.c
+++ b/bfd/cpu-pdp11.c
@@ -34,7 +34,8 @@
     1,		/* aligment = 16 bit */
     TRUE, /* the one and only */
     bfd_default_compatible,
-    bfd_default_scan ,
+    bfd_default_scan,
+    bfd_arch_default_fill,
     0,
   };
 
diff --git a/bfd/cpu-pj.c b/bfd/cpu-pj.c
index bb5c85b..3576227 100644
--- a/bfd/cpu-pj.c
+++ b/bfd/cpu-pj.c
@@ -37,5 +37,6 @@
   TRUE,				/* the default machine */
   bfd_default_compatible,
   bfd_default_scan,
+  bfd_arch_default_fill,
   0
 };
diff --git a/bfd/cpu-plugin.c b/bfd/cpu-plugin.c
index f0f7dbd..6b25c58 100644
--- a/bfd/cpu-plugin.c
+++ b/bfd/cpu-plugin.c
@@ -36,5 +36,6 @@
   TRUE,
   bfd_default_compatible,
   bfd_default_scan,
+  bfd_arch_default_fill,
   0
 };
diff --git a/bfd/cpu-powerpc.c b/bfd/cpu-powerpc.c
index 9bd60af..3e9acf1 100644
--- a/bfd/cpu-powerpc.c
+++ b/bfd/cpu-powerpc.c
@@ -1,6 +1,6 @@
 /* BFD PowerPC CPU definition
-   Copyright 1994, 1995, 1996, 2000, 2001, 2002, 2003, 2005, 2007, 2008, 2010
-   Free Software Foundation, Inc.
+   Copyright 1994, 1995, 1996, 2000, 2001, 2002, 2003, 2005, 2007, 2008,
+   2010, 2012 Free Software Foundation, Inc.
    Contributed by Ian Lance Taylor, Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -26,13 +26,9 @@
 
 /* The common PowerPC architecture is compatible with the RS/6000.  */
 
-static const bfd_arch_info_type *powerpc_compatible
-  PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
-
 static const bfd_arch_info_type *
-powerpc_compatible (a,b)
-     const bfd_arch_info_type *a;
-     const bfd_arch_info_type *b;
+powerpc_compatible (const bfd_arch_info_type *a,
+		    const bfd_arch_info_type *b)
 {
   BFD_ASSERT (a->arch == bfd_arch_powerpc);
   switch (b->arch)
@@ -65,6 +61,7 @@
     TRUE, /* default for 64 bit target */
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[1]
   },
   /* elf32-ppc:ppc_elf_object_p relies on the default 32 bit arch
@@ -81,6 +78,7 @@
     FALSE,
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[2],
   },
 #else
@@ -97,6 +95,7 @@
     TRUE, /* default for 32 bit target */
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[1],
   },
   /* elf64-ppc:ppc64_elf_object_p relies on the default 64 bit arch
@@ -113,6 +112,7 @@
     FALSE,
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[2]
   },
 #endif
@@ -128,6 +128,7 @@
     FALSE, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[3]
   },
   {
@@ -142,6 +143,7 @@
     FALSE, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[4]
   },
   {
@@ -156,6 +158,7 @@
     FALSE, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[5]
   },
   {
@@ -170,6 +173,7 @@
     FALSE, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[6]
   },
   {
@@ -184,6 +188,7 @@
     FALSE, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[7]
   },
   {
@@ -198,6 +203,7 @@
     FALSE, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[8]
   },
   {
@@ -212,6 +218,7 @@
     FALSE, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[9]
   },
   {
@@ -226,6 +233,7 @@
     FALSE, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[10]
   },
   {
@@ -240,6 +248,7 @@
     FALSE, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[11]
   },
   {
@@ -254,6 +263,7 @@
     FALSE, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[12]
   },
   {
@@ -268,6 +278,7 @@
     FALSE, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[13]
   },
   {
@@ -282,6 +293,7 @@
     FALSE,
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[14]
   },
   {
@@ -296,6 +308,7 @@
     FALSE, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[15]
   },
   {
@@ -310,6 +323,7 @@
     FALSE, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[16]
   },
   {
@@ -324,6 +338,7 @@
     FALSE, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[17]
   },
   {
@@ -338,6 +353,7 @@
     FALSE, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_powerpc_archs[18]
   },
   {
@@ -352,6 +368,52 @@
     FALSE, /* not the default */
     powerpc_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
+    &bfd_powerpc_archs[19]
+  },
+  {
+    16, /* 16 or 32 bits in a word */
+    32, /* 32 bits in an address */
+    8,  /* 8 bits in a byte */
+    bfd_arch_powerpc,
+    bfd_mach_ppc_vle,
+    "powerpc",
+    "powerpc:vle",
+    3,
+    FALSE, /* not the default */
+    powerpc_compatible,
+    bfd_default_scan,
+    bfd_arch_default_fill,
+    &bfd_powerpc_archs[20]
+  },
+  {
+    64, /* 64 bits in a word */
+    64, /* 64 bits in an address */
+    8,  /* 8 bits in a byte */
+    bfd_arch_powerpc,
+    bfd_mach_ppc_e5500,
+    "powerpc",
+    "powerpc:e5500",
+    3,
+    FALSE, /* not the default */
+    powerpc_compatible,
+    bfd_default_scan,
+    bfd_arch_default_fill,
+    &bfd_powerpc_archs[21]
+  },
+  {
+    64, /* 64 bits in a word */
+    64, /* 64 bits in an address */
+    8,  /* 8 bits in a byte */
+    bfd_arch_powerpc,
+    bfd_mach_ppc_e6500,
+    "powerpc",
+    "powerpc:e6500",
+    3,
+    FALSE, /* not the default */
+    powerpc_compatible,
+    bfd_default_scan,
+    bfd_arch_default_fill,
     0
   }
 };
diff --git a/bfd/cpu-rl78.c b/bfd/cpu-rl78.c
new file mode 100644
index 0000000..6fb72e6
--- /dev/null
+++ b/bfd/cpu-rl78.c
@@ -0,0 +1,40 @@
+/* BFD support for the RL78 processor.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_rl78_arch =
+{
+  32,				/* Bits per word.  */
+  32,				/* Bits per address.  */
+  8,				/* Bits per byte.  */
+  bfd_arch_rl78,		/* Architecture.  */
+  bfd_mach_rl78,		/* Machine.  */
+  "rl78",			/* Architecture name.  */
+  "rl78",			/* Printable name.  */
+  4,				/* Section align power.  */
+  TRUE,				/* The default ?  */
+  bfd_default_compatible,	/* Architecture comparison fn.  */
+  bfd_default_scan,		/* String to architecture convert fn.  */
+  bfd_arch_default_fill,	/* Default fill.  */
+  NULL				/* Next in list.  */
+};
diff --git a/bfd/cpu-rs6000.c b/bfd/cpu-rs6000.c
index 91d0431..ba1df36 100644
--- a/bfd/cpu-rs6000.c
+++ b/bfd/cpu-rs6000.c
@@ -1,5 +1,5 @@
 /* BFD back-end for rs6000 support
-   Copyright 1990, 1991, 1993, 1995, 2000, 2002, 2003, 2005, 2007
+   Copyright 1990, 1991, 1993, 1995, 2000, 2002, 2003, 2005, 2007, 2012
    Free Software Foundation, Inc.
    Written by Mimi Phuong-Thao Vo of IBM
    and John Gilmore of Cygnus Support.
@@ -28,13 +28,9 @@
 /* The RS/6000 architecture is compatible with the PowerPC common
    architecture.  */
 
-static const bfd_arch_info_type *rs6000_compatible
-  PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
-
 static const bfd_arch_info_type *
-rs6000_compatible (a,b)
-     const bfd_arch_info_type *a;
-     const bfd_arch_info_type *b;
+rs6000_compatible (const bfd_arch_info_type *a,
+		   const bfd_arch_info_type *b)
 {
   BFD_ASSERT (a->arch == bfd_arch_rs6000);
   switch (b->arch)
@@ -65,6 +61,7 @@
     FALSE, /* not the default */
     rs6000_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &arch_info_struct[1]
   },
   {
@@ -79,6 +76,7 @@
     FALSE, /* not the default */
     rs6000_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &arch_info_struct[2]
   },
   {
@@ -93,6 +91,7 @@
     FALSE, /* not the default */
     rs6000_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     0
   }
 };
@@ -110,5 +109,6 @@
     TRUE, /* the default */
     rs6000_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &arch_info_struct[0]
   };
diff --git a/bfd/cpu-rx.c b/bfd/cpu-rx.c
index 92eebb0..31489ad 100644
--- a/bfd/cpu-rx.c
+++ b/bfd/cpu-rx.c
@@ -36,6 +36,7 @@
     FALSE,			/* The default ?  */
     bfd_default_compatible,	/* Architecture comparison fn.  */
     bfd_default_scan,		/* String to architecture convert fn.  */
+    bfd_arch_default_fill,	/* Default fill.  */
     NULL			/* Next in list.  */
   },
 };
@@ -53,5 +54,6 @@
   TRUE,				/* The default ?  */
   bfd_default_compatible,	/* Architecture comparison fn.  */
   bfd_default_scan,		/* String to architecture convert fn.  */
+  bfd_arch_default_fill,	/* Default fill.  */
   & arch_info_struct[0],	/* Next in list.  */
 };
diff --git a/bfd/cpu-s390.c b/bfd/cpu-s390.c
index 805e825..1cd3af1 100644
--- a/bfd/cpu-s390.c
+++ b/bfd/cpu-s390.c
@@ -33,9 +33,14 @@
     "s390",
     "s390:64-bit",
     3, /* section alignment power */
+#if BFD_DEFAULT_TARGET_SIZE == 64
     TRUE, /* the default */
+#else
+    FALSE, /* the default */
+#endif
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     NULL
 };
 
@@ -49,8 +54,13 @@
     "s390",
     "s390:31-bit",
     3, /* section alignment power */
+#if BFD_DEFAULT_TARGET_SIZE == 64
+    FALSE, /* the default */
+#else
     TRUE, /* the default */
+#endif
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &bfd_s390_64_arch
 };
diff --git a/bfd/cpu-score.c b/bfd/cpu-score.c
index 0ed4095..329c97c 100644
--- a/bfd/cpu-score.c
+++ b/bfd/cpu-score.c
@@ -1,5 +1,5 @@
 /* BFD support for the score processor
-   Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+   Copyright 2006, 2007, 2008, 2009, 2012 Free Software Foundation, Inc.
    Contributed by
    Brain.lin ([email protected])
    Mei Ligang ([email protected])
@@ -22,8 +22,8 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 
 /* This routine is provided two arch_infos and works out which Score
@@ -56,6 +56,7 @@
   default,			/* The default machine.  */	\
   compatible,							\
   bfd_default_scan,						\
+  bfd_arch_default_fill,					\
   next								\
 }
 
diff --git a/bfd/cpu-sh.c b/bfd/cpu-sh.c
index af97a47..6ca7840 100644
--- a/bfd/cpu-sh.c
+++ b/bfd/cpu-sh.c
@@ -61,6 +61,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH2_NEXT
   },
   {
@@ -75,6 +76,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH2E_NEXT
   },
   {
@@ -89,6 +91,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH_DSP_NEXT
   },
   {
@@ -103,6 +106,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH3_NEXT
   },
   {
@@ -117,6 +121,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH3_NOMMU_NEXT
   },
   {
@@ -131,6 +136,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH3_DSP_NEXT
   },
   {
@@ -145,6 +151,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH3E_NEXT
   },
   {
@@ -159,6 +166,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH4_NEXT
   },
   {
@@ -173,6 +181,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH4A_NEXT
   },
   {
@@ -187,6 +196,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH4AL_DSP_NEXT
   },
   {
@@ -201,6 +211,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH4_NOFPU_NEXT
   },
   {
@@ -215,6 +226,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH4_NOMMU_NOFPU_NEXT
   },
   {
@@ -229,6 +241,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH4A_NOFPU_NEXT
   },
   {
@@ -243,6 +256,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH2A_NEXT
   },
   {
@@ -257,6 +271,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH2A_NOFPU_NEXT
   },
   {
@@ -271,6 +286,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH2A_NOFPU_OR_SH4_NOMMU_NOFPU_NEXT
   },
   {
@@ -285,6 +301,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH2A_NOFPU_OR_SH3_NOMMU_NEXT
   },
   {
@@ -299,6 +316,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH2A_OR_SH4_NEXT
   },
   {
@@ -313,6 +331,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH2A_OR_SH3E_NEXT
   },
   {
@@ -327,6 +346,7 @@
     FALSE,			/* Not the default.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     SH64_NEXT
   },
 };
@@ -344,6 +364,7 @@
   TRUE,				/* The default machine.  */
   bfd_default_compatible,
   bfd_default_scan,
+  bfd_arch_default_fill,
   SH_NEXT
 };
 
@@ -367,7 +388,7 @@
   { bfd_mach_sh2a_nofpu_or_sh3_nommu,               arch_sh2a_nofpu_or_sh3_nommu,         arch_sh2a_nofpu_or_sh3_nommu_up },
   { bfd_mach_sh2a_or_sh4,     arch_sh2a_or_sh4,     arch_sh2a_or_sh4_up },
   { bfd_mach_sh2a_or_sh3e,    arch_sh2a_or_sh3e,    arch_sh2a_or_sh3e_up },
-  
+
   { bfd_mach_sh3,             arch_sh3,             arch_sh3_up },
   { bfd_mach_sh3_nommu,       arch_sh3_nommu,       arch_sh3_nommu_up },
   { bfd_mach_sh3_dsp,         arch_sh3_dsp,         arch_sh3_dsp_up },
@@ -520,6 +541,6 @@
 
   bfd_default_set_arch_mach (obfd, bfd_arch_sh,
 			     sh_get_bfd_mach_from_arch_set (merged_arch));
-  
+
   return TRUE;
 }
diff --git a/bfd/cpu-sparc.c b/bfd/cpu-sparc.c
index f86ccc5..ccdd7d1 100644
--- a/bfd/cpu-sparc.c
+++ b/bfd/cpu-sparc.c
@@ -37,6 +37,7 @@
     FALSE,
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &arch_info_struct[1],
   },
   {
@@ -51,6 +52,7 @@
     FALSE,
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &arch_info_struct[2],
   },
   {
@@ -65,6 +67,7 @@
     FALSE,
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &arch_info_struct[3],
   },
   {
@@ -79,6 +82,7 @@
     FALSE,
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &arch_info_struct[4],
   },
   {
@@ -93,6 +97,7 @@
     FALSE,
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &arch_info_struct[5],
   },
   {
@@ -107,6 +112,7 @@
     FALSE,
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &arch_info_struct[6],
   },
   {
@@ -121,6 +127,7 @@
     FALSE,
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &arch_info_struct[7],
   },
   {
@@ -135,6 +142,7 @@
     FALSE,
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &arch_info_struct[8],
   },
   {
@@ -149,6 +157,7 @@
     FALSE,
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     0,
   }
 };
@@ -166,5 +175,6 @@
     TRUE, /* the default */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     &arch_info_struct[0],
   };
diff --git a/bfd/cpu-spu.c b/bfd/cpu-spu.c
index 64ba357..b3dfc62 100644
--- a/bfd/cpu-spu.c
+++ b/bfd/cpu-spu.c
@@ -49,6 +49,7 @@
     TRUE, 		/* the default machine for the architecture */
     spu_compatible,	/* the spu is only compatible with itself, see above */
     bfd_default_scan,
+    bfd_arch_default_fill,
     0,			/* next -- there are none! */
   }
 };
diff --git a/bfd/cpu-tic30.c b/bfd/cpu-tic30.c
index e08cf47..a9d291d 100644
--- a/bfd/cpu-tic30.c
+++ b/bfd/cpu-tic30.c
@@ -35,5 +35,6 @@
   TRUE,				/* the one and only */
   bfd_default_compatible,
   bfd_default_scan,
+  bfd_arch_default_fill,
   0,
 };
diff --git a/bfd/cpu-tic4x.c b/bfd/cpu-tic4x.c
index bd8b8f4..a90594c 100644
--- a/bfd/cpu-tic4x.c
+++ b/bfd/cpu-tic4x.c
@@ -1,5 +1,6 @@
 /* bfd back-end for TMS320C[34]x support
-   Copyright 1996, 1997, 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
+   Copyright 1996, 1997, 2002, 2003, 2005, 2007, 2012
+   Free Software Foundation, Inc.
 
    Contributed by Michael Hayes ([email protected])
 
@@ -24,14 +25,9 @@
 #include "bfd.h"
 #include "libbfd.h"
 
-static bfd_boolean tic4x_scan
-    PARAMS ((const struct bfd_arch_info *, const char * ));
-
-
 static bfd_boolean
-tic4x_scan (info, string)
-     const struct bfd_arch_info *info;
-     const char *string;
+tic4x_scan (const struct bfd_arch_info *info,
+	    const char *string)
 {
   /* Allow strings of form [ti][Cc][34][0-9], let's not be too picky
      about strange numbered machines in C3x or C4x series.  */
@@ -64,6 +60,7 @@
     FALSE,			/* Not the default architecture.  */
     bfd_default_compatible,
     tic4x_scan,
+    bfd_arch_default_fill,
     0
   };
 
@@ -80,6 +77,7 @@
     TRUE,			/* The default architecture.  */
     bfd_default_compatible,
     tic4x_scan,
+    bfd_arch_default_fill,
     &bfd_tic3x_arch,
   };
 
diff --git a/bfd/cpu-tic54x.c b/bfd/cpu-tic54x.c
index b7e316c..95d990e 100644
--- a/bfd/cpu-tic54x.c
+++ b/bfd/cpu-tic54x.c
@@ -35,5 +35,6 @@
   TRUE,				/* the one and only */
   bfd_default_compatible,
   bfd_default_scan,
+  bfd_arch_default_fill,
   0,
 };
diff --git a/bfd/cpu-tic6x.c b/bfd/cpu-tic6x.c
index 163f4b3..d5a9cb9 100644
--- a/bfd/cpu-tic6x.c
+++ b/bfd/cpu-tic6x.c
@@ -36,5 +36,6 @@
     TRUE, /* Default machine for this architecture.  */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     0,
   };
diff --git a/bfd/cpu-tic80.c b/bfd/cpu-tic80.c
index f030ce1..c11233d 100644
--- a/bfd/cpu-tic80.c
+++ b/bfd/cpu-tic80.c
@@ -35,6 +35,7 @@
     2,				/* section alignment power */
     TRUE,			/* default machine for architecture */
     bfd_default_compatible,
-    bfd_default_scan ,
+    bfd_default_scan,
+    bfd_arch_default_fill,
     NULL,				/* Pointer to next in chain */
   };
diff --git a/bfd/cpu-tilegx.c b/bfd/cpu-tilegx.c
index aa2fe80..11234ec 100644
--- a/bfd/cpu-tilegx.c
+++ b/bfd/cpu-tilegx.c
@@ -1,5 +1,5 @@
 /* BFD support for the TILE-Gx processor.
-   Copyright 2011 Free Software Foundation, Inc.
+   Copyright 2011, 2012 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -18,10 +18,27 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 
+const bfd_arch_info_type bfd_tilegx32_arch =
+  {
+    32, /* 32 bits in a word */
+    32, /* 32 bits in an address */
+    8,  /* 8 bits in a byte */
+    bfd_arch_tilegx,
+    bfd_mach_tilegx32,
+    "tilegx32",
+    "tilegx32",
+    3,
+    FALSE,
+    bfd_default_compatible,
+    bfd_default_scan,
+    bfd_arch_default_fill,
+    0,
+  };
+
 const bfd_arch_info_type bfd_tilegx_arch =
   {
     64, /* 64 bits in a word */
@@ -35,5 +52,6 @@
     TRUE,
     bfd_default_compatible,
     bfd_default_scan,
-    0,
+    bfd_arch_default_fill,
+    &bfd_tilegx32_arch,
   };
diff --git a/bfd/cpu-tilepro.c b/bfd/cpu-tilepro.c
index cadd006..4066fc1 100644
--- a/bfd/cpu-tilepro.c
+++ b/bfd/cpu-tilepro.c
@@ -1,5 +1,5 @@
 /* BFD support for the TILEPro processor.
-   Copyright 2011 Free Software Foundation, Inc.
+   Copyright 2011, 2012 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -18,8 +18,8 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 
 const bfd_arch_info_type bfd_tilepro_arch =
@@ -35,5 +35,6 @@
     TRUE,
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     0,
   };
diff --git a/bfd/cpu-v850.c b/bfd/cpu-v850.c
index 6ebc96c..c2f52f1 100644
--- a/bfd/cpu-v850.c
+++ b/bfd/cpu-v850.c
@@ -1,6 +1,5 @@
 /* BFD support for the NEC V850 processor
-   Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2005, 2007,
-   2010  Free Software Foundation, Inc.
+   Copyright 1996-2013 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -25,16 +24,18 @@
 #include "safe-ctype.h"
 
 #define N(number, print, default, next)  \
-{  32, 32, 8, bfd_arch_v850, number, "v850", print, 2, default, \
-     bfd_default_compatible, bfd_default_scan, next }
+{  32, 32, 8, bfd_arch_v850, number, "v850", print " (using old gcc ABI)", 2, default, \
+   bfd_default_compatible, bfd_default_scan, bfd_arch_default_fill, next }
 
 #define NEXT NULL
 
 static const bfd_arch_info_type arch_info_struct[] =
 {
-  N (bfd_mach_v850e2v3, "v850e2v3", 	FALSE, & arch_info_struct[1]),
-  N (bfd_mach_v850e2,   "v850e2", 	FALSE, & arch_info_struct[2]),
-  N (bfd_mach_v850e1,   "v850e1",  	FALSE, & arch_info_struct[3]),
+  N (bfd_mach_v850e3v5, "v850e3v5", 	FALSE, & arch_info_struct[1]),
+  N (bfd_mach_v850e3v5, "v850e2v4", 	FALSE, & arch_info_struct[2]),
+  N (bfd_mach_v850e2v3, "v850e2v3", 	FALSE, & arch_info_struct[3]),
+  N (bfd_mach_v850e2,   "v850e2", 	FALSE, & arch_info_struct[4]),
+  N (bfd_mach_v850e1,   "v850e1",  	FALSE, & arch_info_struct[5]),
   N (bfd_mach_v850e,    "v850e",   	FALSE, NULL)
 };
 
diff --git a/bfd/cpu-v850_rh850.c b/bfd/cpu-v850_rh850.c
new file mode 100644
index 0000000..9402f23
--- /dev/null
+++ b/bfd/cpu-v850_rh850.c
@@ -0,0 +1,41 @@
+/* BFD support for the NEC V850 processor with the RH850 ABI.
+   Copyright 2012-2013  Free Software Foundation, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libbfd.h"
+#include "safe-ctype.h"
+
+#define R(number, print, default, next)  \
+{  32, 32, 8, bfd_arch_v850_rh850, number, "v850", print, 2, default, \
+   bfd_default_compatible, bfd_default_scan, bfd_arch_default_fill, next }
+
+static const bfd_arch_info_type arch_info_struct[] =
+{
+  R (bfd_mach_v850e3v5, "v850e3v5", 	FALSE, & arch_info_struct[1]),
+  R (bfd_mach_v850e3v5, "v850e2v4", 	FALSE, & arch_info_struct[2]),
+  R (bfd_mach_v850e2v3, "v850e2v3", 	FALSE, & arch_info_struct[3]),
+  R (bfd_mach_v850e2,   "v850e2", 	FALSE, & arch_info_struct[4]),
+  R (bfd_mach_v850e1,   "v850e1",  	FALSE, & arch_info_struct[5]),
+  R (bfd_mach_v850e,    "v850e",   	FALSE, NULL)
+};
+
+const bfd_arch_info_type bfd_v850_rh850_arch =
+  R (bfd_mach_v850,     "v850-rh850",   TRUE,  & arch_info_struct[0]);
diff --git a/bfd/cpu-vax.c b/bfd/cpu-vax.c
index c9d9c8d..9e2b19d 100644
--- a/bfd/cpu-vax.c
+++ b/bfd/cpu-vax.c
@@ -37,5 +37,6 @@
     TRUE, /* the one and only */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     0,
   };
diff --git a/bfd/cpu-w65.c b/bfd/cpu-w65.c
index e5e78d9..8b0618b 100644
--- a/bfd/cpu-w65.c
+++ b/bfd/cpu-w65.c
@@ -1,5 +1,5 @@
 /* BFD library support routines for the WDC 65816 architecture.
-   Copyright 1995, 1999, 2000, 2001, 2002, 2005, 2007
+   Copyright 1995, 1999, 2000, 2001, 2002, 2005, 2007, 2012
    Free Software Foundation, Inc.
    Hacked by Steve Chamberlain of Cygnus Support.
 
@@ -24,13 +24,9 @@
 #include "bfd.h"
 #include "libbfd.h"
 
-static bfd_boolean scan_mach
-  PARAMS ((const struct bfd_arch_info *, const char *));
-
 static bfd_boolean
-scan_mach (info, string)
-     const struct bfd_arch_info *info ATTRIBUTE_UNUSED;
-     const char *string;
+scan_mach (const struct bfd_arch_info *info ATTRIBUTE_UNUSED,
+	   const char *string)
 {
   if (strcmp(string,"w65") == 0)
     return TRUE;
@@ -52,5 +48,6 @@
   TRUE,				/* the default machine */
   bfd_default_compatible,
   scan_mach,
+  bfd_arch_default_fill,
   0,
 };
diff --git a/bfd/cpu-we32k.c b/bfd/cpu-we32k.c
index d93d76a..99a8ff0 100644
--- a/bfd/cpu-we32k.c
+++ b/bfd/cpu-we32k.c
@@ -36,5 +36,6 @@
     TRUE, /* the one and only */
     bfd_default_compatible,
     bfd_default_scan ,
+    bfd_arch_default_fill,
     0,
   };
diff --git a/bfd/cpu-xc16x.c b/bfd/cpu-xc16x.c
index 552952c..3c74232 100644
--- a/bfd/cpu-xc16x.c
+++ b/bfd/cpu-xc16x.c
@@ -1,6 +1,6 @@
 /* BFD support for the Infineon XC16X Microcontroller.
    Copyright 2006, 2007 Free Software Foundation, Inc.
-   Contributed by KPIT Cummins Infosystems 
+   Contributed by KPIT Cummins Infosystems
 
    This file is part of BFD, the Binary File Descriptor library.
    Contributed by Anil Paranjpe([email protected])
@@ -37,6 +37,7 @@
   TRUE,				/* The default ?  */
   bfd_default_compatible,	/* Architecture comparison fn.  */
   bfd_default_scan,		/* String to architecture convert fn.  */
+  bfd_arch_default_fill,	/* Default fill.  */
   NULL				/* Next in list.  */
 };
 
@@ -53,6 +54,7 @@
   TRUE,				/* The default ?  */
   bfd_default_compatible,	/* Architecture comparison fn.  */
   bfd_default_scan,		/* String to architecture convert fn.  */
+  bfd_arch_default_fill,	/* Default fill.  */
   & xc16xs_info_struct		/* Next in list.  */
 };
 
@@ -69,5 +71,6 @@
   TRUE,				/* The default ?  */
   bfd_default_compatible,	/* Architecture comparison fn.  */
   bfd_default_scan,		/* String to architecture convert fn.  */
+  bfd_arch_default_fill,	/* Default fill.  */
   & xc16xl_info_struct		/* Next in list.  */
 };
diff --git a/bfd/cpu-xgate.c b/bfd/cpu-xgate.c
new file mode 100644
index 0000000..11653fa
--- /dev/null
+++ b/bfd/cpu-xgate.c
@@ -0,0 +1,40 @@
+/* BFD support for the Freescale XGATE processor
+   Copyright 2010, 2011, 2012 Free Software Foundation, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libbfd.h"
+
+const bfd_arch_info_type bfd_xgate_arch =
+{
+    16, /* 16 bits in a word.  */
+    32, /* 32 bits used as 16 bit address and PPAGE value.  */
+    8,  /* 8 bits in a byte.  */
+    bfd_arch_xgate,
+    bfd_mach_xgate,
+    "xgate",
+    "xgate",
+    4, 	/* Section alignment power.  */
+    TRUE,
+    bfd_default_compatible,
+    bfd_default_scan,
+    bfd_arch_default_fill,
+    0,
+};
diff --git a/bfd/cpu-xstormy16.c b/bfd/cpu-xstormy16.c
index d1c7e56..94de989 100644
--- a/bfd/cpu-xstormy16.c
+++ b/bfd/cpu-xstormy16.c
@@ -35,5 +35,6 @@
   TRUE,				/* the default ? */
   bfd_default_compatible,	/* architecture comparison fn */
   bfd_default_scan,		/* string to architecture convert fn */
+  bfd_arch_default_fill,	/* Default fill.  */
   NULL				/* next in list */
 };
diff --git a/bfd/cpu-xtensa.c b/bfd/cpu-xtensa.c
index ee3767a..5c1008e 100644
--- a/bfd/cpu-xtensa.c
+++ b/bfd/cpu-xtensa.c
@@ -35,5 +35,6 @@
   TRUE,				/* The default?  */
   bfd_default_compatible,	/* Architecture comparison fn.  */
   bfd_default_scan,		/* String to architecture convert fn.  */
+  bfd_arch_default_fill,	/* Default fill.  */
   NULL				/* Next in list.  */
 };
diff --git a/bfd/cpu-z80.c b/bfd/cpu-z80.c
index 5da39f1..a46f71d 100644
--- a/bfd/cpu-z80.c
+++ b/bfd/cpu-z80.c
@@ -42,7 +42,7 @@
 
 #define N(name,print,default,next)  \
 { 16, 16, 8, bfd_arch_z80, name, "z80", print, 0, default, \
-    compatible, bfd_default_scan, next }
+  compatible, bfd_default_scan, bfd_arch_default_fill, next }
 
 #define M(n) &arch_info_struct[n]
 
diff --git a/bfd/cpu-z8k.c b/bfd/cpu-z8k.c
index 6e910e9..fd34218 100644
--- a/bfd/cpu-z8k.c
+++ b/bfd/cpu-z8k.c
@@ -38,11 +38,12 @@
 static const bfd_arch_info_type arch_info_struct[] =
 {
   { 32, 16, 8, bfd_arch_z8k, bfd_mach_z8002, "z8k", "z8002", 1, FALSE,
-    compatible, bfd_default_scan, 0 }
+    compatible, bfd_default_scan, bfd_arch_default_fill, 0 }
 };
 
 const bfd_arch_info_type bfd_z8k_arch =
 {
   32, 32, 8, bfd_arch_z8k, bfd_mach_z8001, "z8k", "z8001", 1, TRUE,
-  compatible, bfd_default_scan, &arch_info_struct[0]
+  compatible, bfd_default_scan, bfd_arch_default_fill,
+  &arch_info_struct[0]
 };
diff --git a/bfd/doc/ChangeLog b/bfd/doc/ChangeLog
index 87e2a2e..c33eb3b 100644
--- a/bfd/doc/ChangeLog
+++ b/bfd/doc/ChangeLog
@@ -1,3 +1,32 @@
+2013-04-15  Alan Modra  <[email protected]>
+
+	* Makefile.am ($(MKDOC)): Append $(EXEEXT_FOR_BUILD) to temp file.
+	* Makefile.in: Regenerate.
+
+2013-04-09  Mingjie Xing  <[email protected]>
+
+	* bfd.texinfo (typedef bfd, Error reporting, Miscellaneous):
+	Add menu items.
+
+2013-01-07  Patrice Dumas  <[email protected]>
+
+	* bfd.texinfo: Replace @ with @@ when it is part of the text.
+
+2012-12-17  Nick Clifton  <[email protected]>
+
+	* Makefile.am: Add copyright notice.
+	* bfdsumm.texi: Likewise.
+	* makefile.vms: Likewise.
+	* Makefile.in: Regenerate.
+
+2012-11-08  Alan Modra  <[email protected]>
+
+	* Makefile.in: Regenerate.
+
+2012-02-27  Alan Modra  <[email protected]>
+
+	* chew.c (print_stack_level, main): Use %ld to print stack delta.
+
 2010-10-28  Matthias Klose  <[email protected]>
 
 	* bfd.texinfo: Add directory section for info document.
@@ -234,6 +263,12 @@
 
 For older changes see ChangeLog-9103
 
+Copyright (C) 2004-2012 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
+
 Local Variables:
 mode: change-log
 left-margin: 8
diff --git a/bfd/doc/ChangeLog-9103 b/bfd/doc/ChangeLog-9103
index 3636ed8..0b5d836 100644
--- a/bfd/doc/ChangeLog-9103
+++ b/bfd/doc/ChangeLog-9103
@@ -589,6 +589,12 @@
 	  and mandir now keyed off datadir by default.
 
 
+Copyright (C) 1991-2003 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
+
 Local Variables:
 version-control: never
 End:
diff --git a/bfd/doc/Makefile.am b/bfd/doc/Makefile.am
index 7476ee5..670d69a 100644
--- a/bfd/doc/Makefile.am
+++ b/bfd/doc/Makefile.am
@@ -1,4 +1,21 @@
 ## Process this file with automake to generate Makefile.in
+#
+#   Copyright 2012 Free Software Foundation
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+#
 
 AUTOMAKE_OPTIONS = 1.9 cygnus
 
@@ -60,9 +77,9 @@
 	-I$(srcdir)/../../intl -I../../intl
 
 $(MKDOC): $(srcdir)/chew.c
-	$(CC_FOR_BUILD) -o chew.$$$$ $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) \
-	  $(H_CFLAGS) $(AM_CPPFLAGS) $(srcdir)/chew.c; \
-	$(SHELL) $(srcdir)/../../move-if-change chew.$$$$ $(MKDOC)
+	$(CC_FOR_BUILD) -o chw$$$$$(EXEEXT_FOR_BUILD) $(CFLAGS_FOR_BUILD) \
+	  $(LDFLAGS_FOR_BUILD) $(H_CFLAGS) $(AM_CPPFLAGS) $(srcdir)/chew.c; \
+	$(SHELL) $(srcdir)/../../move-if-change chw$$$$$(EXEEXT_FOR_BUILD) $(MKDOC)
 
 protos: libbfd.h libcoff.h bfd.h
 
diff --git a/bfd/doc/Makefile.in b/bfd/doc/Makefile.in
index 68e17f7..5156ba7 100644
--- a/bfd/doc/Makefile.in
+++ b/bfd/doc/Makefile.in
@@ -14,6 +14,24 @@
 # PARTICULAR PURPOSE.
 
 @SET_MAKE@
+
+#
+#   Copyright 2012 Free Software Foundation
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+#
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
@@ -247,6 +265,7 @@
 libexecdir = @libexecdir@
 localedir = @localedir@
 localstatedir = @localstatedir@
+lt_cv_dlopen_libs = @lt_cv_dlopen_libs@
 mandir = @mandir@
 mkdir_p = @mkdir_p@
 oldincludedir = @oldincludedir@
@@ -757,9 +776,9 @@
 
 
 $(MKDOC): $(srcdir)/chew.c
-	$(CC_FOR_BUILD) -o chew.$$$$ $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) \
-	  $(H_CFLAGS) $(AM_CPPFLAGS) $(srcdir)/chew.c; \
-	$(SHELL) $(srcdir)/../../move-if-change chew.$$$$ $(MKDOC)
+	$(CC_FOR_BUILD) -o chw$$$$$(EXEEXT_FOR_BUILD) $(CFLAGS_FOR_BUILD) \
+	  $(LDFLAGS_FOR_BUILD) $(H_CFLAGS) $(AM_CPPFLAGS) $(srcdir)/chew.c; \
+	$(SHELL) $(srcdir)/../../move-if-change chw$$$$$(EXEEXT_FOR_BUILD) $(MKDOC)
 
 protos: libbfd.h libcoff.h bfd.h
 
diff --git a/bfd/doc/archive.texi b/bfd/doc/archive.texi
index 3d0a97d..cfb391c 100644
--- a/bfd/doc/archive.texi
+++ b/bfd/doc/archive.texi
@@ -18,11 +18,17 @@
 have to read the entire archive if you don't want
 to!  Read it until you find what you want.
 
+A BFD returned by @code{bfd_openr_next_archived_file} can be
+closed manually with @code{bfd_close}.  If you do not close it,
+then a second iteration through the members of an archive may
+return the same BFD.  If you close the archive BFD, then all
+the member BFDs will automatically be closed as well.
+
 Archive contents of output BFDs are chained through the
-@code{next} pointer in a BFD.  The first one is findable through
-the @code{archive_head} slot of the archive.  Set it with
-@code{bfd_set_archive_head} (q.v.).  A given BFD may be in only one
-open output archive at a time.
+@code{archive_next} pointer in a BFD.  The first one is findable
+through the @code{archive_head} slot of the archive.  Set it with
+@code{bfd_set_archive_head} (q.v.).  A given BFD may be in only
+one open output archive at a time.
 
 As expected, the BFD archive code is more general than the
 archive code of any given environment.  BFD archives may
diff --git a/bfd/doc/archures.texi b/bfd/doc/archures.texi
index 683d165..b91c27c 100644
--- a/bfd/doc/archures.texi
+++ b/bfd/doc/archures.texi
@@ -110,7 +110,7 @@
 #define bfd_mach_sparc_64bit_p(mach) \
   ((mach) >= bfd_mach_sparc_v9 && (mach) != bfd_mach_sparc_v8plusb)
   bfd_arch_spu,       /* PowerPC SPU */
-#define bfd_mach_spu           256 
+#define bfd_mach_spu           256
   bfd_arch_mips,      /* MIPS Rxxxx */
 #define bfd_mach_mips3000              3000
 #define bfd_mach_mips3900              3900
@@ -126,6 +126,7 @@
 #define bfd_mach_mips5000              5000
 #define bfd_mach_mips5400              5400
 #define bfd_mach_mips5500              5500
+#define bfd_mach_mips5900              5900
 #define bfd_mach_mips6000              6000
 #define bfd_mach_mips7000              7000
 #define bfd_mach_mips8000              8000
@@ -141,6 +142,8 @@
 #define bfd_mach_mips_loongson_3a      3003
 #define bfd_mach_mips_sb1              12310201 /* octal 'SB', 01 */
 #define bfd_mach_mips_octeon           6501
+#define bfd_mach_mips_octeonp          6601
+#define bfd_mach_mips_octeon2          6502
 #define bfd_mach_mips_xlr              887682   /* decimal 'XLR'  */
 #define bfd_mach_mipsisa32             32
 #define bfd_mach_mipsisa32r2           33
@@ -162,6 +165,10 @@
   bfd_arch_k1om,   /* Intel K1OM */
 #define bfd_mach_k1om                  (1 << 6)
 #define bfd_mach_k1om_intel_syntax     (bfd_mach_k1om | bfd_mach_i386_intel_syntax)
+#define bfd_mach_i386_nacl             (1 << 7)
+#define bfd_mach_i386_i386_nacl        (bfd_mach_i386_i386 | bfd_mach_i386_nacl)
+#define bfd_mach_x86_64_nacl           (bfd_mach_x86_64 | bfd_mach_i386_nacl)
+#define bfd_mach_x64_32_nacl           (bfd_mach_x64_32 | bfd_mach_i386_nacl)
   bfd_arch_we32k,     /* AT&T WE32xxx */
   bfd_arch_tahoe,     /* CCI/Harris Tahoe */
   bfd_arch_i860,      /* Intel 860 */
@@ -204,7 +211,10 @@
 #define bfd_mach_ppc_e500      500
 #define bfd_mach_ppc_e500mc    5001
 #define bfd_mach_ppc_e500mc64  5005
+#define bfd_mach_ppc_e5500     5006
+#define bfd_mach_ppc_e6500     5007
 #define bfd_mach_ppc_titan     83
+#define bfd_mach_ppc_vle       84
   bfd_arch_rs6000,    /* IBM RS/6000 */
 #define bfd_mach_rs6k          6000
 #define bfd_mach_rs6k_rs1      6001
@@ -226,6 +236,8 @@
 #define bfd_mach_m6812_default 0
 #define bfd_mach_m6812         1
 #define bfd_mach_m6812s        2
+  bfd_arch_m9s12x,   /* Freescale S12X */
+  bfd_arch_m9s12xg,  /* Freescale XGATE */
   bfd_arch_z8k,       /* Zilog Z8000 */
 #define bfd_mach_z8001         1
 #define bfd_mach_z8002         2
@@ -281,11 +293,13 @@
   bfd_arch_tic6x,     /* Texas Instruments TMS320C6X */
   bfd_arch_tic80,     /* TI TMS320c80 (MVP) */
   bfd_arch_v850,      /* NEC V850 */
+  bfd_arch_v850_rh850,/* NEC V850 (using RH850 ABI) */
 #define bfd_mach_v850          1
 #define bfd_mach_v850e         'E'
 #define bfd_mach_v850e1        '1'
 #define bfd_mach_v850e2        0x4532
 #define bfd_mach_v850e2v3      0x45325633
+#define bfd_mach_v850e3v5      0x45335635 /* ('E'|'3'|'V'|'5') */
   bfd_arch_arc,       /* ARC Cores */
 #define bfd_mach_arc_5         5
 #define bfd_mach_arc_6         6
@@ -321,6 +335,8 @@
 #define bfd_mach_mep           1
 #define bfd_mach_mep_h1        0x6831
 #define bfd_mach_mep_c5        0x6335
+  bfd_arch_metag,
+#define bfd_mach_metag         1
   bfd_arch_ia64,      /* HP/Intel ia64 */
 #define bfd_mach_ia64_elf64    64
 #define bfd_mach_ia64_elf32    32
@@ -330,6 +346,9 @@
  bfd_arch_iq2000,     /* Vitesse IQ2000.  */
 #define bfd_mach_iq2000        1
 #define bfd_mach_iq10          2
+  bfd_arch_epiphany,   /* Adapteva EPIPHANY */
+#define bfd_mach_epiphany16    1
+#define bfd_mach_epiphany32    2
   bfd_arch_mt,
 #define bfd_mach_ms1           1
 #define bfd_mach_mrisc2        2
@@ -365,12 +384,14 @@
 #define bfd_mach_cris_v0_v10   255
 #define bfd_mach_cris_v32      32
 #define bfd_mach_cris_v10_v32  1032
+  bfd_arch_rl78,
+#define bfd_mach_rl78  0x75
   bfd_arch_rx,        /* Renesas RX.  */
 #define bfd_mach_rx            0x75
   bfd_arch_s390,      /* IBM s390 */
 #define bfd_mach_s390_31       31
 #define bfd_mach_s390_64       64
-  bfd_arch_score,     /* Sunplus score */ 
+  bfd_arch_score,     /* Sunplus score */
 #define bfd_mach_score3         3
 #define bfd_mach_score7         7
   bfd_arch_openrisc,  /* OpenRISC */
@@ -385,7 +406,12 @@
 #define bfd_mach_msp14          14
 #define bfd_mach_msp15          15
 #define bfd_mach_msp16          16
+#define bfd_mach_msp20          20
 #define bfd_mach_msp21          21
+#define bfd_mach_msp22          22
+#define bfd_mach_msp23          23
+#define bfd_mach_msp24          24
+#define bfd_mach_msp26          26
 #define bfd_mach_msp31          31
 #define bfd_mach_msp32          32
 #define bfd_mach_msp33          33
@@ -393,10 +419,16 @@
 #define bfd_mach_msp42          42
 #define bfd_mach_msp43          43
 #define bfd_mach_msp44          44
+#define bfd_mach_msp430x        45
+#define bfd_mach_msp46          46
+#define bfd_mach_msp47          47
+#define bfd_mach_msp54          54
   bfd_arch_xc16x,     /* Infineon's XC16X Series.               */
 #define bfd_mach_xc16x         1
 #define bfd_mach_xc16xl        2
-#define bfd_mach_xc16xs         3
+#define bfd_mach_xc16xs        3
+  bfd_arch_xgate,   /* Freescale XGATE */
+#define bfd_mach_xgate         1
   bfd_arch_xtensa,    /* Tensilica's Xtensa cores.  */
 #define bfd_mach_xtensa        1
   bfd_arch_z80,
@@ -411,6 +443,12 @@
   bfd_arch_tilegx, /* Tilera TILE-Gx */
 #define bfd_mach_tilepro   1
 #define bfd_mach_tilegx    1
+#define bfd_mach_tilegx32  2
+  bfd_arch_aarch64,   /* AArch64  */
+#define bfd_mach_aarch64 0
+#define bfd_mach_aarch64_ilp32 32
+  bfd_arch_nios2,
+#define bfd_mach_nios2 0
   bfd_arch_last
   @};
 @end example
@@ -442,6 +480,12 @@
 
   bfd_boolean (*scan) (const struct bfd_arch_info *, const char *);
 
+  /* Allocate via bfd_malloc and return a fill buffer of size COUNT.  If
+     IS_BIGENDIAN is TRUE, the order of bytes is big endian.  If CODE is
+     TRUE, the buffer contains code.  */
+  void *(*fill) (bfd_size_type count, bfd_boolean is_bigendian,
+                 bfd_boolean code);
+
   const struct bfd_arch_info *next;
 @}
 bfd_arch_info_type;
@@ -647,3 +691,16 @@
 This routine is provided for those cases where a bfd * is not
 available
 
+@findex bfd_arch_default_fill
+@subsubsection @code{bfd_arch_default_fill}
+@strong{Synopsis}
+@example
+void *bfd_arch_default_fill (bfd_size_type count,
+    bfd_boolean is_bigendian,
+    bfd_boolean code);
+@end example
+@strong{Description}@*
+Allocate via bfd_malloc and return a fill buffer of size COUNT.
+If IS_BIGENDIAN is TRUE, the order of bytes is big endian.  If
+CODE is TRUE, the buffer contains code.
+
diff --git a/bfd/doc/bfd.texinfo b/bfd/doc/bfd.texinfo
index 45ffa73..ec709c1 100644
--- a/bfd/doc/bfd.texinfo
+++ b/bfd/doc/bfd.texinfo
@@ -1,8 +1,6 @@
 \input texinfo.tex
 @setfilename bfd.info
-@c Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1997, 2000,
-@c 2001, 2002, 2003, 2006, 2007, 2008, 2009
-@c Free Software Foundation, Inc.
+@c Copyright 1988-2013 Free Software Foundation, Inc.
 @c 
 @synindex fn cp
 
@@ -16,7 +14,7 @@
 @copying
 This file documents the BFD library.
 
-Copyright @copyright{} 1991, 2000, 2001, 2003, 2006, 2007, 2008 Free Software Foundation, Inc.
+Copyright @copyright{} 1991 - 2013 Free Software Foundation, Inc.
 
 Permission is granted to copy, distribute and/or modify this document
 under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -64,7 +62,7 @@
 @end tex
 
 @vskip 0pt plus 1filll
-Copyright @copyright{} 1991, 2001, 2003, 2006, 2008 Free Software Foundation, Inc.
+Copyright @copyright{} 1991 - 2013 Free Software Foundation, Inc.
 
       Permission is granted to copy, distribute and/or modify this document
       under the terms of the GNU Free Documentation License, Version 1.3
@@ -196,10 +194,11 @@
 
 @node BFD front end, BFD back ends, Overview, Top
 @chapter BFD Front End
-@include bfdt.texi
-@include bfdio.texi
 
 @menu
+* typedef bfd::
+* Error reporting::
+* Miscellaneous::
 * Memory Usage::
 * Initialization::
 * Sections::
@@ -217,7 +216,10 @@
 * Hash Tables::
 @end menu
 
-@node Memory Usage, Initialization, BFD front end, BFD front end
+@include bfdt.texi
+@include bfdio.texi
+
+@node Memory Usage, Initialization, Miscellaneous, BFD front end
 @section Memory Usage
 BFD keeps all of its internal structures in obstacks. There is one obstack
 per open BFD file, into which the current state is stored. When a BFD is
@@ -322,7 +324,7 @@
 @printindex cp
 
 @tex
-% I think something like @colophon should be in texinfo.  In the
+% I think something like @@colophon should be in texinfo.  In the
 % meantime:
 \long\def\colophon{\hbox to0pt{}\vfill
 \centerline{The body of this manual is set in}
@@ -333,7 +335,7 @@
 \centerline{{\sl\fontname\tensl\/}}
 \centerline{are used for emphasis.}\vfill}
 \page\colophon
-% Blame: [email protected], 28mar91.
+% Blame: doc@@cygnus.com, 28mar91.
 @end tex
 
 @bye
diff --git a/bfd/doc/bfdsumm.texi b/bfd/doc/bfdsumm.texi
index 77a5f09..0cd0252 100644
--- a/bfd/doc/bfdsumm.texi
+++ b/bfd/doc/bfdsumm.texi
@@ -1,4 +1,7 @@
 @c This summary of BFD is shared by the BFD and LD docs.
+@c Copyright 2012
+@c Free Software Foundation, Inc.
+
 When an object file is opened, BFD subroutines automatically determine
 the format of the input object file.  They then build a descriptor in
 memory with pointers to routines that will be used to access elements of
diff --git a/bfd/doc/bfdt.texi b/bfd/doc/bfdt.texi
index 8b82750..a4ef522 100644
--- a/bfd/doc/bfdt.texi
+++ b/bfd/doc/bfdt.texi
@@ -1,3 +1,4 @@
+@node typedef bfd, Error reporting, BFD front end, BFD front end
 @section @code{typedef bfd}
 A BFD has type @code{bfd}; objects of this type are the
 cornerstone of any application using BFD. Using BFD
@@ -286,6 +287,7 @@
 @};
 
 @end example
+@node Error reporting, Miscellaneous, typedef bfd, BFD front end
 @section Error reporting
 Most BFD functions return nonzero on success (check their
 individual documentation for precise semantics).  On an error,
@@ -317,6 +319,7 @@
   bfd_error_no_armap,
   bfd_error_no_more_archived_files,
   bfd_error_malformed_archive,
+  bfd_error_missing_dso,
   bfd_error_file_not_recognized,
   bfd_error_file_ambiguously_recognized,
   bfd_error_no_contents,
@@ -419,6 +422,44 @@
 @strong{Description}@*
 Return the BFD error handler function.
 
+@subsection BFD assert handler
+If BFD finds an internal inconsistency, the bfd assert
+handler is called with information on the BFD version, BFD
+source file and line.  If this happens, most programs linked
+against BFD are expected to want to exit with an error, or mark
+the current BFD operation as failed, so it is recommended to
+override the default handler, which just calls
+_bfd_error_handler and continues.
+
+
+@example
+
+typedef void (*bfd_assert_handler_type) (const char *bfd_formatmsg,
+                                         const char *bfd_version,
+                                         const char *bfd_file,
+                                         int bfd_line);
+
+@end example
+@findex bfd_set_assert_handler
+@subsubsection @code{bfd_set_assert_handler}
+@strong{Synopsis}
+@example
+bfd_assert_handler_type bfd_set_assert_handler (bfd_assert_handler_type);
+@end example
+@strong{Description}@*
+Set the BFD assert handler function.  Returns the previous
+function.
+
+@findex bfd_get_assert_handler
+@subsubsection @code{bfd_get_assert_handler}
+@strong{Synopsis}
+@example
+bfd_assert_handler_type bfd_get_assert_handler (void);
+@end example
+@strong{Description}@*
+Return the BFD assert handler function.
+
+@node Miscellaneous, Memory Usage, Error reporting, BFD front end
 @section Miscellaneous
 
 
@@ -681,6 +722,11 @@
        BFD_SEND (abfd, _bfd_find_nearest_line, \
                  (abfd, sec, syms, off, file, func, line))
 
+#define bfd_find_nearest_line_discriminator(abfd, sec, syms, off, file, func, \
+                                            line, disc) \
+       BFD_SEND (abfd, _bfd_find_nearest_line_discriminator, \
+                 (abfd, sec, syms, off, file, func, line, disc))
+
 #define bfd_find_line(abfd, syms, sym, file, line) \
        BFD_SEND (abfd, _bfd_find_line, \
                  (abfd, syms, sym, file, line))
@@ -713,8 +759,8 @@
 #define bfd_gc_sections(abfd, link_info) \
        BFD_SEND (abfd, _bfd_gc_sections, (abfd, link_info))
 
-#define bfd_lookup_section_flags(link_info, flag_info) \
-       BFD_SEND (abfd, _bfd_lookup_section_flags, (link_info, flag_info))
+#define bfd_lookup_section_flags(link_info, flag_info, section) \
+       BFD_SEND (abfd, _bfd_lookup_section_flags, (link_info, flag_info, section))
 
 #define bfd_merge_sections(abfd, link_info) \
        BFD_SEND (abfd, _bfd_merge_sections, (abfd, link_info))
@@ -781,60 +827,6 @@
 only ELF supports this feature, with up to two alternate
 machine codes.
 
-
-@example
-struct bfd_preserve
-@{
-  void *marker;
-  void *tdata;
-  flagword flags;
-  const struct bfd_arch_info *arch_info;
-  struct bfd_section *sections;
-  struct bfd_section *section_last;
-  unsigned int section_count;
-  struct bfd_hash_table section_htab;
-@};
-
-@end example
-@findex bfd_preserve_save
-@subsubsection @code{bfd_preserve_save}
-@strong{Synopsis}
-@example
-bfd_boolean bfd_preserve_save (bfd *, struct bfd_preserve *);
-@end example
-@strong{Description}@*
-When testing an object for compatibility with a particular
-target back-end, the back-end object_p function needs to set
-up certain fields in the bfd on successfully recognizing the
-object.  This typically happens in a piecemeal fashion, with
-failures possible at many points.  On failure, the bfd is
-supposed to be restored to its initial state, which is
-virtually impossible.  However, restoring a subset of the bfd
-state works in practice.  This function stores the subset and
-reinitializes the bfd.
-
-@findex bfd_preserve_restore
-@subsubsection @code{bfd_preserve_restore}
-@strong{Synopsis}
-@example
-void bfd_preserve_restore (bfd *, struct bfd_preserve *);
-@end example
-@strong{Description}@*
-This function restores bfd state saved by bfd_preserve_save.
-If MARKER is non-NULL in struct bfd_preserve then that block
-and all subsequently bfd_alloc'd memory is freed.
-
-@findex bfd_preserve_finish
-@subsubsection @code{bfd_preserve_finish}
-@strong{Synopsis}
-@example
-void bfd_preserve_finish (bfd *, struct bfd_preserve *);
-@end example
-@strong{Description}@*
-This function should be called when the bfd state saved by
-bfd_preserve_save is no longer needed.  ie. when the back-end
-object_p function returns with success.
-
 @findex bfd_emul_get_maxpagesize
 @subsubsection @code{bfd_emul_get_maxpagesize}
 @strong{Synopsis}
diff --git a/bfd/doc/bfdver.texi b/bfd/doc/bfdver.texi
index 0529522..3dedf6f 100644
--- a/bfd/doc/bfdver.texi
+++ b/bfd/doc/bfdver.texi
@@ -1,4 +1,4 @@
-@set VERSION 2.22
+@set VERSION 2.24
 @set VERSION_PACKAGE (GNU Binutils) 
-@set UPDATED November 2011
+@set UPDATED December 2013
 @set BUGURL @uref{http://www.sourceware.org/bugzilla/}
diff --git a/bfd/doc/cache.texi b/bfd/doc/cache.texi
index 5820a2a..05b627e 100644
--- a/bfd/doc/cache.texi
+++ b/bfd/doc/cache.texi
@@ -4,7 +4,7 @@
 regard to the underlying operating system's file descriptor
 limit (often as low as 20 open files).  The module in
 @code{cache.c} maintains a least recently used list of
-@code{BFD_CACHE_MAX_OPEN} files, and exports the name
+@code{bfd_cache_max_open} files, and exports the name
 @code{bfd_cache_lookup}, which runs around and makes sure that
 the required BFD is open. If not, then it chooses a file to
 close, closes it and opens the one wanted, returning its file
diff --git a/bfd/doc/chew.c b/bfd/doc/chew.c
index 2276c8a..f949e1f 100644
--- a/bfd/doc/chew.c
+++ b/bfd/doc/chew.c
@@ -1,6 +1,6 @@
 /* chew
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2001,
-   2002, 2003, 2005, 2007, 2009
+   2002, 2003, 2005, 2007, 2009, 2012
    Free Software Foundation, Inc.
    Contributed by steve chamberlain @cygnus
 
@@ -476,8 +476,8 @@
 static void
 print_stack_level ()
 {
-  fprintf (stderr, "current string stack depth = %d, ", tos - stack);
-  fprintf (stderr, "current integer stack depth = %d\n", isp - istack);
+  fprintf (stderr, "current string stack depth = %ld, ", tos - stack);
+  fprintf (stderr, "current integer stack depth = %ld\n", isp - istack);
   pc++;
 }
 
@@ -1563,7 +1563,7 @@
   write_buffer (stack + 0, stdout);
   if (tos != stack)
     {
-      fprintf (stderr, "finishing with current stack level %d\n",
+      fprintf (stderr, "finishing with current stack level %ld\n",
 	       tos - stack);
       return 1;
     }
diff --git a/bfd/doc/coffcode.texi b/bfd/doc/coffcode.texi
index e487d84..0be85e7 100644
--- a/bfd/doc/coffcode.texi
+++ b/bfd/doc/coffcode.texi
@@ -85,11 +85,11 @@
 
 The Microsoft PE variants of the Coff object file format add
 an extension to support the use of long section names.  This
-extension is defined in section 4 of the Microsoft PE/COFF 
+extension is defined in section 4 of the Microsoft PE/COFF
 specification (rev 8.1).  If a section name is too long to fit
 into the section header's @code{s_name} field, it is instead
 placed into the string table, and the @code{s_name} field is
-filled with a slash ("/") followed by the ASCII decimal 
+filled with a slash ("/") followed by the ASCII decimal
 representation of the offset of the full name relative to the
 string table base.
 
@@ -106,11 +106,11 @@
 expecting the MS standard format may become confused; @file{PEview} is
 one known example.
 
-The functionality is supported in BFD by code implemented under 
+The functionality is supported in BFD by code implemented under
 the control of the macro @code{COFF_LONG_SECTION_NAMES}.  If not
 defined, the format does not support long section names in any way.
-If defined, it is used to initialise a flag, 
-@code{_bfd_coff_long_section_names}, and a hook function pointer, 
+If defined, it is used to initialise a flag,
+@code{_bfd_coff_long_section_names}, and a hook function pointer,
 @code{_bfd_coff_set_long_section_names}, in the Coff backend data
 structure.  The flag controls the generation of long section names
 in output BFDs at runtime; if it is false, as it will be by default
@@ -119,6 +119,7 @@
 points to a function that allows the value of the flag to be altered
 at runtime, on formats that support long section names at all; on
 other formats it points to a stub that returns an error indication.
+
 With input BFDs, the flag is set according to whether any long section
 names are detected while reading the section headers.  For a completely
 new BFD, the flag is set to the default for the target format.  This
@@ -389,7 +390,7 @@
   bfd_boolean _bfd_coff_long_section_names;
   bfd_boolean (*_bfd_coff_set_long_section_names)
     (bfd *, int);
-  
+
   unsigned int _bfd_coff_default_section_alignment_power;
   bfd_boolean _bfd_coff_force_symnames_in_strings;
   unsigned int _bfd_coff_debug_string_prefix_length;
diff --git a/bfd/doc/linker.texi b/bfd/doc/linker.texi
index eae1662..8cc22ba 100644
--- a/bfd/doc/linker.texi
+++ b/bfd/doc/linker.texi
@@ -405,8 +405,8 @@
 
 @end example
 
-@findex bfd_find_version_for_sym 
-@subsubsection @code{bfd_find_version_for_sym }
+@findex bfd_find_version_for_sym
+@subsubsection @code{bfd_find_version_for_sym}
 @strong{Synopsis}
 @example
 struct bfd_elf_version_tree * bfd_find_version_for_sym
diff --git a/bfd/doc/makefile.vms b/bfd/doc/makefile.vms
index a0857c0..267af6b 100644
--- a/bfd/doc/makefile.vms
+++ b/bfd/doc/makefile.vms
@@ -1,3 +1,20 @@
+#   Copyright 2012 Free Software Foundation
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+#
+
 CFLAGS = /noopt/include=([],[-],[-.-.include])
 LDFLAGS = /nomap
 LDLIBS = ,sys$$library:vaxcrtl.olb/lib
diff --git a/bfd/doc/opncls.texi b/bfd/doc/opncls.texi
index eddf66a..d56f4cb 100644
--- a/bfd/doc/opncls.texi
+++ b/bfd/doc/opncls.texi
@@ -21,7 +21,7 @@
 Return a pointer to the created BFD.  If @var{fd} is not -1,
 then @code{fdopen} is used to open the file; otherwise, @code{fopen}
 is used.  @var{mode} is passed directly to @code{fopen} or
-@code{fdopen}. 
+@code{fdopen}.
 
 Calls @code{bfd_find_target}, so @var{target} is interpreted as by
 that function.
@@ -32,6 +32,8 @@
 are @code{bfd_error_no_memory}, @code{bfd_error_invalid_target} or
 @code{system_call} error.
 
+On error, @var{fd} is always closed.
+
 @findex bfd_openr
 @subsubsection @code{bfd_openr}
 @strong{Synopsis}
@@ -73,6 +75,8 @@
 Possible errors are @code{bfd_error_no_memory},
 @code{bfd_error_invalid_target} and @code{bfd_error_system_call}.
 
+On error, @var{fd} is closed.
+
 @findex bfd_openstreamr
 @subsubsection @code{bfd_openstreamr}
 @strong{Synopsis}
@@ -284,16 +288,31 @@
 @strong{Returns}@*
 Return the updated CRC32 value.
 
-@findex get_debug_link_info
-@subsubsection @code{get_debug_link_info}
+@findex bfd_get_debug_link_info
+@subsubsection @code{bfd_get_debug_link_info}
 @strong{Synopsis}
 @example
-char *get_debug_link_info (bfd *abfd, unsigned long *crc32_out);
+char *bfd_get_debug_link_info (bfd *abfd, unsigned long *crc32_out);
 @end example
 @strong{Description}@*
 fetch the filename and CRC32 value for any separate debuginfo
 associated with @var{abfd}. Return NULL if no such info found,
-otherwise return filename and update @var{crc32_out}.
+otherwise return filename and update @var{crc32_out}.  The
+returned filename is allocated with @code{malloc}; freeing it
+is the responsibility of the caller.
+
+@findex bfd_get_alt_debug_link_info
+@subsubsection @code{bfd_get_alt_debug_link_info}
+@strong{Synopsis}
+@example
+char *bfd_get_alt_debug_link_info (bfd *abfd, unsigned long *crc32_out);
+@end example
+@strong{Description}@*
+Fetch the filename and BuildID value for any alternate debuginfo
+associated with @var{abfd}.  Return NULL if no such info found,
+otherwise return filename and update @var{buildid_out}.  The
+returned filename is allocated with @code{malloc}; freeing it
+is the responsibility of the caller.
 
 @findex separate_debug_file_exists
 @subsubsection @code{separate_debug_file_exists}
@@ -306,6 +325,17 @@
 Checks to see if @var{name} is a file and if its contents
 match @var{crc32}.
 
+@findex separate_alt_debug_file_exists
+@subsubsection @code{separate_alt_debug_file_exists}
+@strong{Synopsis}
+@example
+bfd_boolean separate_alt_debug_file_exists
+   (char *name, unsigned long crc32);
+@end example
+@strong{Description}@*
+Checks to see if @var{name} is a file and if its BuildID
+matches @var{buildid}.
+
 @findex find_separate_debug_file
 @subsubsection @code{find_separate_debug_file}
 @strong{Synopsis}
@@ -313,12 +343,14 @@
 char *find_separate_debug_file (bfd *abfd);
 @end example
 @strong{Description}@*
-Searches @var{abfd} for a reference to separate debugging
-information, scans various locations in the filesystem, including
-the file tree rooted at @var{debug_file_directory}, and returns a
-filename of such debugging information if the file is found and has
-matching CRC32.  Returns NULL if no reference to debugging file
-exists, or file cannot be found.
+Searches @var{abfd} for a section called @var{section_name} which
+is expected to contain a reference to a file containing separate
+debugging information.  The function scans various locations in
+the filesystem, including the file tree rooted at
+@var{debug_file_directory}, and returns the first matching
+filename that it finds.  If @var{check_crc} is TRUE then the
+contents of the file must also match the CRC value contained in
+@var{section_name}.  Returns NULL if no valid file could be found.
 
 @findex bfd_follow_gnu_debuglink
 @subsubsection @code{bfd_follow_gnu_debuglink}
@@ -343,6 +375,29 @@
 otherwise a pointer to a heap-allocated string containing the
 filename.  The caller is responsible for freeing this string.
 
+@findex bfd_follow_gnu_debugaltlink
+@subsubsection @code{bfd_follow_gnu_debugaltlink}
+@strong{Synopsis}
+@example
+char *bfd_follow_gnu_debugaltlink (bfd *abfd, const char *dir);
+@end example
+@strong{Description}@*
+Takes a BFD and searches it for a .gnu_debugaltlink section.  If this
+section is found, it examines the section for the name of a file
+containing auxiliary debugging information.  It then searches the
+filesystem for this file in a set of standard locations, including
+the directory tree rooted at @var{dir}, and if found returns the
+full filename.
+
+If @var{dir} is NULL, it will search a default path configured into
+libbfd at build time.  [FIXME: This feature is not currently
+implemented].
+
+@strong{Returns}@*
+@code{NULL} on any errors or failure to locate the debug file,
+otherwise a pointer to a heap-allocated string containing the
+filename.  The caller is responsible for freeing this string.
+
 @findex bfd_create_gnu_debuglink_section
 @subsubsection @code{bfd_create_gnu_debuglink_section}
 @strong{Synopsis}
diff --git a/bfd/doc/reloc.texi b/bfd/doc/reloc.texi
index 566a8e0..331f631 100644
--- a/bfd/doc/reloc.texi
+++ b/bfd/doc/reloc.texi
@@ -550,6 +550,10 @@
 @deffnx {} BFD_RELOC_8_PLTOFF
 For ELF.
 @end deffn
+@deffn {} BFD_RELOC_SIZE32
+@deffnx {} BFD_RELOC_SIZE64
+Size relocations.
+@end deffn
 @deffn {} BFD_RELOC_68K_GLOB_DAT
 @deffnx {} BFD_RELOC_68K_JMP_SLOT
 @deffnx {} BFD_RELOC_68K_RELATIVE
@@ -662,6 +666,10 @@
 @deffnx {} BFD_RELOC_SPARC_M44
 @deffnx {} BFD_RELOC_SPARC_L44
 @deffnx {} BFD_RELOC_SPARC_REGISTER
+@deffnx {} BFD_RELOC_SPARC_H34
+@deffnx {} BFD_RELOC_SPARC_SIZE32
+@deffnx {} BFD_RELOC_SPARC_SIZE64
+@deffnx {} BFD_RELOC_SPARC_WDISP10
 SPARC64 relocations
 @end deffn
 @deffn {} BFD_RELOC_SPARC_REV32
@@ -858,6 +866,15 @@
 @deffn {} BFD_RELOC_MIPS16_LO16
 MIPS16 low 16 bits.
 @end deffn
+@deffn {} BFD_RELOC_MIPS16_TLS_GD
+@deffnx {} BFD_RELOC_MIPS16_TLS_LDM
+@deffnx {} BFD_RELOC_MIPS16_TLS_DTPREL_HI16
+@deffnx {} BFD_RELOC_MIPS16_TLS_DTPREL_LO16
+@deffnx {} BFD_RELOC_MIPS16_TLS_GOTTPREL
+@deffnx {} BFD_RELOC_MIPS16_TLS_TPREL_HI16
+@deffnx {} BFD_RELOC_MIPS16_TLS_TPREL_LO16
+MIPS16 TLS relocations
+@end deffn
 @deffn {} BFD_RELOC_MIPS_LITERAL
 @deffnx {} BFD_RELOC_MICROMIPS_LITERAL
 Relocation against a MIPS literal section.
@@ -928,6 +945,7 @@
 @deffnx {} BFD_RELOC_MICROMIPS_TLS_TPREL_HI16
 @deffnx {} BFD_RELOC_MIPS_TLS_TPREL_LO16
 @deffnx {} BFD_RELOC_MICROMIPS_TLS_TPREL_LO16
+@deffnx {} BFD_RELOC_MIPS_EH
 MIPS ELF relocations.
 @end deffn
 @deffn {} BFD_RELOC_MIPS_COPY
@@ -1015,6 +1033,25 @@
 be honoured at the offset's location, regardless of linker
 relaxation.
 @end deffn
+@deffn {} BFD_RELOC_MN10300_TLS_GD
+@deffnx {} BFD_RELOC_MN10300_TLS_LD
+@deffnx {} BFD_RELOC_MN10300_TLS_LDO
+@deffnx {} BFD_RELOC_MN10300_TLS_GOTIE
+@deffnx {} BFD_RELOC_MN10300_TLS_IE
+@deffnx {} BFD_RELOC_MN10300_TLS_LE
+@deffnx {} BFD_RELOC_MN10300_TLS_DTPMOD
+@deffnx {} BFD_RELOC_MN10300_TLS_DTPOFF
+@deffnx {} BFD_RELOC_MN10300_TLS_TPOFF
+Various TLS-related relocations.
+@end deffn
+@deffn {} BFD_RELOC_MN10300_32_PCREL
+This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the
+instruction.
+@end deffn
+@deffn {} BFD_RELOC_MN10300_16_PCREL
+This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the
+instruction.
+@end deffn
 @deffn {} BFD_RELOC_386_GOT32
 @deffnx {} BFD_RELOC_386_PLT32
 @deffnx {} BFD_RELOC_386_COPY
@@ -1068,6 +1105,8 @@
 @deffnx {} BFD_RELOC_X86_64_TLSDESC_CALL
 @deffnx {} BFD_RELOC_X86_64_TLSDESC
 @deffnx {} BFD_RELOC_X86_64_IRELATIVE
+@deffnx {} BFD_RELOC_X86_64_PC32_BND
+@deffnx {} BFD_RELOC_X86_64_PLT32_BND
 x86-64/elf relocations
 @end deffn
 @deffn {} BFD_RELOC_NS32K_IMM_8
@@ -1126,6 +1165,23 @@
 @deffnx {} BFD_RELOC_PPC_EMB_RELST_HA
 @deffnx {} BFD_RELOC_PPC_EMB_BIT_FLD
 @deffnx {} BFD_RELOC_PPC_EMB_RELSDA
+@deffnx {} BFD_RELOC_PPC_VLE_REL8
+@deffnx {} BFD_RELOC_PPC_VLE_REL15
+@deffnx {} BFD_RELOC_PPC_VLE_REL24
+@deffnx {} BFD_RELOC_PPC_VLE_LO16A
+@deffnx {} BFD_RELOC_PPC_VLE_LO16D
+@deffnx {} BFD_RELOC_PPC_VLE_HI16A
+@deffnx {} BFD_RELOC_PPC_VLE_HI16D
+@deffnx {} BFD_RELOC_PPC_VLE_HA16A
+@deffnx {} BFD_RELOC_PPC_VLE_HA16D
+@deffnx {} BFD_RELOC_PPC_VLE_SDA21
+@deffnx {} BFD_RELOC_PPC_VLE_SDA21_LO
+@deffnx {} BFD_RELOC_PPC_VLE_SDAREL_LO16A
+@deffnx {} BFD_RELOC_PPC_VLE_SDAREL_LO16D
+@deffnx {} BFD_RELOC_PPC_VLE_SDAREL_HI16A
+@deffnx {} BFD_RELOC_PPC_VLE_SDAREL_HI16D
+@deffnx {} BFD_RELOC_PPC_VLE_SDAREL_HA16A
+@deffnx {} BFD_RELOC_PPC_VLE_SDAREL_HA16D
 @deffnx {} BFD_RELOC_PPC64_HIGHER
 @deffnx {} BFD_RELOC_PPC64_HIGHER_S
 @deffnx {} BFD_RELOC_PPC64_HIGHEST
@@ -1149,6 +1205,8 @@
 @deffnx {} BFD_RELOC_PPC64_TOC16_LO_DS
 @deffnx {} BFD_RELOC_PPC64_PLTGOT16_DS
 @deffnx {} BFD_RELOC_PPC64_PLTGOT16_LO_DS
+@deffnx {} BFD_RELOC_PPC64_ADDR16_HIGH
+@deffnx {} BFD_RELOC_PPC64_ADDR16_HIGHA
 Power(rs6000) and PowerPC relocations.
 @end deffn
 @deffn {} BFD_RELOC_PPC_TLS
@@ -1193,6 +1251,10 @@
 @deffnx {} BFD_RELOC_PPC64_DTPREL16_HIGHERA
 @deffnx {} BFD_RELOC_PPC64_DTPREL16_HIGHEST
 @deffnx {} BFD_RELOC_PPC64_DTPREL16_HIGHESTA
+@deffnx {} BFD_RELOC_PPC64_TPREL16_HIGH
+@deffnx {} BFD_RELOC_PPC64_TPREL16_HIGHA
+@deffnx {} BFD_RELOC_PPC64_DTPREL16_HIGH
+@deffnx {} BFD_RELOC_PPC64_DTPREL16_HIGHA
 PowerPC and PowerPC64 thread-local storage relocations.
 @end deffn
 @deffn {} BFD_RELOC_I370_D12
@@ -1849,14 +1911,6 @@
 @deffn {} BFD_RELOC_V850_DATA
 start data in text.
 @end deffn
-@deffn {} BFD_RELOC_MN10300_32_PCREL
-This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the
-instruction.
-@end deffn
-@deffn {} BFD_RELOC_MN10300_16_PCREL
-This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the
-instruction.
-@end deffn
 @deffn {} BFD_RELOC_TIC30_LDP
 This is a 8bit DP reloc for the tms320c30, where the most
 significant 8 bits of a 24 bit word are placed into the least
@@ -1978,6 +2032,46 @@
 @deffnx {} BFD_RELOC_MEP_GNU_VTENTRY
 Toshiba Media Processor Relocations.
 @end deffn
+@deffn {} BFD_RELOC_METAG_HIADDR16
+@deffnx {} BFD_RELOC_METAG_LOADDR16
+@deffnx {} BFD_RELOC_METAG_RELBRANCH
+@deffnx {} BFD_RELOC_METAG_GETSETOFF
+@deffnx {} BFD_RELOC_METAG_HIOG
+@deffnx {} BFD_RELOC_METAG_LOOG
+@deffnx {} BFD_RELOC_METAG_REL8
+@deffnx {} BFD_RELOC_METAG_REL16
+@deffnx {} BFD_RELOC_METAG_HI16_GOTOFF
+@deffnx {} BFD_RELOC_METAG_LO16_GOTOFF
+@deffnx {} BFD_RELOC_METAG_GETSET_GOTOFF
+@deffnx {} BFD_RELOC_METAG_GETSET_GOT
+@deffnx {} BFD_RELOC_METAG_HI16_GOTPC
+@deffnx {} BFD_RELOC_METAG_LO16_GOTPC
+@deffnx {} BFD_RELOC_METAG_HI16_PLT
+@deffnx {} BFD_RELOC_METAG_LO16_PLT
+@deffnx {} BFD_RELOC_METAG_RELBRANCH_PLT
+@deffnx {} BFD_RELOC_METAG_GOTOFF
+@deffnx {} BFD_RELOC_METAG_PLT
+@deffnx {} BFD_RELOC_METAG_COPY
+@deffnx {} BFD_RELOC_METAG_JMP_SLOT
+@deffnx {} BFD_RELOC_METAG_RELATIVE
+@deffnx {} BFD_RELOC_METAG_GLOB_DAT
+@deffnx {} BFD_RELOC_METAG_TLS_GD
+@deffnx {} BFD_RELOC_METAG_TLS_LDM
+@deffnx {} BFD_RELOC_METAG_TLS_LDO_HI16
+@deffnx {} BFD_RELOC_METAG_TLS_LDO_LO16
+@deffnx {} BFD_RELOC_METAG_TLS_LDO
+@deffnx {} BFD_RELOC_METAG_TLS_IE
+@deffnx {} BFD_RELOC_METAG_TLS_IENONPIC
+@deffnx {} BFD_RELOC_METAG_TLS_IENONPIC_HI16
+@deffnx {} BFD_RELOC_METAG_TLS_IENONPIC_LO16
+@deffnx {} BFD_RELOC_METAG_TLS_TPOFF
+@deffnx {} BFD_RELOC_METAG_TLS_DTPMOD
+@deffnx {} BFD_RELOC_METAG_TLS_DTPOFF
+@deffnx {} BFD_RELOC_METAG_TLS_LE
+@deffnx {} BFD_RELOC_METAG_TLS_LE_HI16
+@deffnx {} BFD_RELOC_METAG_TLS_LE_LO16
+Imagination Technologies Meta relocations.
+@end deffn
 @deffn {} BFD_RELOC_MMIX_GETA
 @deffnx {} BFD_RELOC_MMIX_GETA_1
 @deffnx {} BFD_RELOC_MMIX_GETA_2
@@ -2078,7 +2172,7 @@
 command address) into 8 bit immediate value of LDI insn.
 @end deffn
 @deffn {} BFD_RELOC_AVR_LO8_LDI_GS
-This is a 16 bit reloc for the AVR that stores 8 bit value 
+This is a 16 bit reloc for the AVR that stores 8 bit value
 (command address) into 8 bit immediate value of LDI insn. If the address
 is beyond the 128k boundary, the linker inserts a jump stub for this reloc
 in the lower 128k.
@@ -2127,6 +2221,53 @@
 This is a 6 bit reloc for the AVR that stores offset for adiw/sbiw
 instructions
 @end deffn
+@deffn {} BFD_RELOC_AVR_8_LO
+This is a 8 bit reloc for the AVR that stores bits 0..7 of a symbol
+in .byte lo8(symbol)
+@end deffn
+@deffn {} BFD_RELOC_AVR_8_HI
+This is a 8 bit reloc for the AVR that stores bits 8..15 of a symbol
+in .byte hi8(symbol)
+@end deffn
+@deffn {} BFD_RELOC_AVR_8_HLO
+This is a 8 bit reloc for the AVR that stores bits 16..23 of a symbol
+in .byte hlo8(symbol)
+@end deffn
+@deffn {} BFD_RELOC_RL78_NEG8
+@deffnx {} BFD_RELOC_RL78_NEG16
+@deffnx {} BFD_RELOC_RL78_NEG24
+@deffnx {} BFD_RELOC_RL78_NEG32
+@deffnx {} BFD_RELOC_RL78_16_OP
+@deffnx {} BFD_RELOC_RL78_24_OP
+@deffnx {} BFD_RELOC_RL78_32_OP
+@deffnx {} BFD_RELOC_RL78_8U
+@deffnx {} BFD_RELOC_RL78_16U
+@deffnx {} BFD_RELOC_RL78_24U
+@deffnx {} BFD_RELOC_RL78_DIR3U_PCREL
+@deffnx {} BFD_RELOC_RL78_DIFF
+@deffnx {} BFD_RELOC_RL78_GPRELB
+@deffnx {} BFD_RELOC_RL78_GPRELW
+@deffnx {} BFD_RELOC_RL78_GPRELL
+@deffnx {} BFD_RELOC_RL78_SYM
+@deffnx {} BFD_RELOC_RL78_OP_SUBTRACT
+@deffnx {} BFD_RELOC_RL78_OP_NEG
+@deffnx {} BFD_RELOC_RL78_OP_AND
+@deffnx {} BFD_RELOC_RL78_OP_SHRA
+@deffnx {} BFD_RELOC_RL78_ABS8
+@deffnx {} BFD_RELOC_RL78_ABS16
+@deffnx {} BFD_RELOC_RL78_ABS16_REV
+@deffnx {} BFD_RELOC_RL78_ABS32
+@deffnx {} BFD_RELOC_RL78_ABS32_REV
+@deffnx {} BFD_RELOC_RL78_ABS16U
+@deffnx {} BFD_RELOC_RL78_ABS16UW
+@deffnx {} BFD_RELOC_RL78_ABS16UL
+@deffnx {} BFD_RELOC_RL78_RELAX
+@deffnx {} BFD_RELOC_RL78_HI16
+@deffnx {} BFD_RELOC_RL78_HI8
+@deffnx {} BFD_RELOC_RL78_LO16
+@deffnx {} BFD_RELOC_RL78_CODE
+Renesas RL78 Relocations.
+@end deffn
 @deffn {} BFD_RELOC_RX_NEG8
 @deffnx {} BFD_RELOC_RX_NEG16
 @deffnx {} BFD_RELOC_RX_NEG24
@@ -2183,12 +2324,24 @@
 @deffn {} BFD_RELOC_390_GOT16
 16 bit GOT offset.
 @end deffn
+@deffn {} BFD_RELOC_390_PC12DBL
+PC relative 12 bit shifted by 1.
+@end deffn
+@deffn {} BFD_RELOC_390_PLT12DBL
+12 bit PC rel. PLT shifted by 1.
+@end deffn
 @deffn {} BFD_RELOC_390_PC16DBL
 PC relative 16 bit shifted by 1.
 @end deffn
 @deffn {} BFD_RELOC_390_PLT16DBL
 16 bit PC rel. PLT shifted by 1.
 @end deffn
+@deffn {} BFD_RELOC_390_PC24DBL
+PC relative 24 bit shifted by 1.
+@end deffn
+@deffn {} BFD_RELOC_390_PLT24DBL
+24 bit PC rel. PLT shifted by 1.
+@end deffn
 @deffn {} BFD_RELOC_390_PC32DBL
 PC relative 32 bit shifted by 1.
 @end deffn
@@ -2262,6 +2415,9 @@
 @deffnx {} BFD_RELOC_390_TLS_GOTIE20
 Long displacement extension.
 @end deffn
+@deffn {} BFD_RELOC_390_IRELATIVE
+STT_GNU_IFUNC relocation.
+@end deffn
 @deffn {} BFD_RELOC_SCORE_GPREL15
 Score relocations
 Low 16 bit for load/store
@@ -2476,6 +2632,83 @@
 Motorola 68HC12 reloc.
 This is the 5 bits of a value.
 @end deffn
+@deffn {} BFD_RELOC_XGATE_RL_JUMP
+Freescale XGATE reloc.
+This reloc marks the beginning of a bra/jal instruction.
+@end deffn
+@deffn {} BFD_RELOC_XGATE_RL_GROUP
+Freescale XGATE reloc.
+This reloc marks a group of several instructions that gcc generates
+and for which the linker relaxation pass can modify and/or remove
+some of them.
+@end deffn
+@deffn {} BFD_RELOC_XGATE_LO16
+Freescale XGATE reloc.
+This is the 16-bit lower part of an address.  It is used for the '16-bit'
+instructions.
+@end deffn
+@deffn {} BFD_RELOC_XGATE_GPAGE
+Freescale XGATE reloc.
+@end deffn
+@deffn {} BFD_RELOC_XGATE_24
+Freescale XGATE reloc.
+@end deffn
+@deffn {} BFD_RELOC_XGATE_PCREL_9
+Freescale XGATE reloc.
+This is a 9-bit pc-relative reloc.
+@end deffn
+@deffn {} BFD_RELOC_XGATE_PCREL_10
+Freescale XGATE reloc.
+This is a 10-bit pc-relative reloc.
+@end deffn
+@deffn {} BFD_RELOC_XGATE_IMM8_LO
+Freescale XGATE reloc.
+This is the 16-bit lower part of an address.  It is used for the '16-bit'
+instructions.
+@end deffn
+@deffn {} BFD_RELOC_XGATE_IMM8_HI
+Freescale XGATE reloc.
+This is the 16-bit higher part of an address.  It is used for the '16-bit'
+instructions.
+@end deffn
+@deffn {} BFD_RELOC_XGATE_IMM3
+Freescale XGATE reloc.
+This is a 3-bit pc-relative reloc.
+@end deffn
+@deffn {} BFD_RELOC_XGATE_IMM4
+Freescale XGATE reloc.
+This is a 4-bit pc-relative reloc.
+@end deffn
+@deffn {} BFD_RELOC_XGATE_IMM5
+Freescale XGATE reloc.
+This is a 5-bit pc-relative reloc.
+@end deffn
+@deffn {} BFD_RELOC_M68HC12_9B
+Motorola 68HC12 reloc.
+This is the 9 bits of a value.
+@end deffn
+@deffn {} BFD_RELOC_M68HC12_16B
+Motorola 68HC12 reloc.
+This is the 16 bits of a value.
+@end deffn
+@deffn {} BFD_RELOC_M68HC12_9_PCREL
+Motorola 68HC12/XGATE reloc.
+This is a PCREL9 branch.
+@end deffn
+@deffn {} BFD_RELOC_M68HC12_10_PCREL
+Motorola 68HC12/XGATE reloc.
+This is a PCREL10 branch.
+@end deffn
+@deffn {} BFD_RELOC_M68HC12_LO8XG
+Motorola 68HC12/XGATE reloc.
+This is the 8 bit low part of an absolute address and immediately precedes
+a matching HI8XG part.
+@end deffn
+@deffn {} BFD_RELOC_M68HC12_HI8XG
+Motorola 68HC12/XGATE reloc.
+This is the 8 bit high part of an absolute address and immediately follows
+a matching LO8XG part.
+@end deffn
 @deffn {} BFD_RELOC_16C_NUM08
 @deffnx {} BFD_RELOC_16C_NUM08_C
 @deffnx {} BFD_RELOC_16C_NUM16
@@ -2672,6 +2905,7 @@
 @deffnx {} BFD_RELOC_H8_DIR24A8
 @deffnx {} BFD_RELOC_H8_DIR24R8
 @deffnx {} BFD_RELOC_H8_DIR32A16
+@deffnx {} BFD_RELOC_H8_DISP32A16
 H8 elf Relocations.
 @end deffn
 @deffn {} BFD_RELOC_XSTORMY16_REL_12
@@ -2719,8 +2953,59 @@
 @deffnx {} BFD_RELOC_MSP430_16_BYTE
 @deffnx {} BFD_RELOC_MSP430_2X_PCREL
 @deffnx {} BFD_RELOC_MSP430_RL_PCREL
+@deffnx {} BFD_RELOC_MSP430_ABS8
+@deffnx {} BFD_RELOC_MSP430X_PCR20_EXT_SRC
+@deffnx {} BFD_RELOC_MSP430X_PCR20_EXT_DST
+@deffnx {} BFD_RELOC_MSP430X_PCR20_EXT_ODST
+@deffnx {} BFD_RELOC_MSP430X_ABS20_EXT_SRC
+@deffnx {} BFD_RELOC_MSP430X_ABS20_EXT_DST
+@deffnx {} BFD_RELOC_MSP430X_ABS20_EXT_ODST
+@deffnx {} BFD_RELOC_MSP430X_ABS20_ADR_SRC
+@deffnx {} BFD_RELOC_MSP430X_ABS20_ADR_DST
+@deffnx {} BFD_RELOC_MSP430X_PCR16
+@deffnx {} BFD_RELOC_MSP430X_PCR20_CALL
+@deffnx {} BFD_RELOC_MSP430X_ABS16
+@deffnx {} BFD_RELOC_MSP430_ABS_HI16
+@deffnx {} BFD_RELOC_MSP430_PREL31
+@deffnx {} BFD_RELOC_MSP430_SYM_DIFF
 msp430 specific relocation codes
 @end deffn
+@deffn {} BFD_RELOC_NIOS2_S16
+@deffnx {} BFD_RELOC_NIOS2_U16
+@deffnx {} BFD_RELOC_NIOS2_CALL26
+@deffnx {} BFD_RELOC_NIOS2_IMM5
+@deffnx {} BFD_RELOC_NIOS2_CACHE_OPX
+@deffnx {} BFD_RELOC_NIOS2_IMM6
+@deffnx {} BFD_RELOC_NIOS2_IMM8
+@deffnx {} BFD_RELOC_NIOS2_HI16
+@deffnx {} BFD_RELOC_NIOS2_LO16
+@deffnx {} BFD_RELOC_NIOS2_HIADJ16
+@deffnx {} BFD_RELOC_NIOS2_GPREL
+@deffnx {} BFD_RELOC_NIOS2_UJMP
+@deffnx {} BFD_RELOC_NIOS2_CJMP
+@deffnx {} BFD_RELOC_NIOS2_CALLR
+@deffnx {} BFD_RELOC_NIOS2_ALIGN
+@deffnx {} BFD_RELOC_NIOS2_GOT16
+@deffnx {} BFD_RELOC_NIOS2_CALL16
+@deffnx {} BFD_RELOC_NIOS2_GOTOFF_LO
+@deffnx {} BFD_RELOC_NIOS2_GOTOFF_HA
+@deffnx {} BFD_RELOC_NIOS2_PCREL_LO
+@deffnx {} BFD_RELOC_NIOS2_PCREL_HA
+@deffnx {} BFD_RELOC_NIOS2_TLS_GD16
+@deffnx {} BFD_RELOC_NIOS2_TLS_LDM16
+@deffnx {} BFD_RELOC_NIOS2_TLS_LDO16
+@deffnx {} BFD_RELOC_NIOS2_TLS_IE16
+@deffnx {} BFD_RELOC_NIOS2_TLS_LE16
+@deffnx {} BFD_RELOC_NIOS2_TLS_DTPMOD
+@deffnx {} BFD_RELOC_NIOS2_TLS_DTPREL
+@deffnx {} BFD_RELOC_NIOS2_TLS_TPREL
+@deffnx {} BFD_RELOC_NIOS2_COPY
+@deffnx {} BFD_RELOC_NIOS2_GLOB_DAT
+@deffnx {} BFD_RELOC_NIOS2_JUMP_SLOT
+@deffnx {} BFD_RELOC_NIOS2_RELATIVE
+@deffnx {} BFD_RELOC_NIOS2_GOTOFF
+Relocations used by the Altera Nios II core.
+@end deffn
 @deffn {} BFD_RELOC_IQ2000_OFFSET_16
 @deffnx {} BFD_RELOC_IQ2000_OFFSET_21
 @deffnx {} BFD_RELOC_IQ2000_UHI16
@@ -2841,6 +3126,9 @@
 Difference between two section addreses.  Must be followed by a
 BFD_RELOC_MACH_O_PAIR.
 @end deffn
+@deffn {} BFD_RELOC_MACH_O_LOCAL_SECTDIFF
+Like BFD_RELOC_MACH_O_SECTDIFF but with a local symbol.
+@end deffn
 @deffn {} BFD_RELOC_MACH_O_PAIR
 Pair of relocation.  Contains the first symbol.
 @end deffn
@@ -2872,58 +3160,377 @@
 Same as BFD_RELOC_32_PCREL but with an implicit -4 addend.
 @end deffn
 @deffn {} BFD_RELOC_MICROBLAZE_32_LO
-This is a 32 bit reloc for the microblaze that stores the 
+This is a 32 bit reloc for the microblaze that stores the
 low 16 bits of a value
 @end deffn
 @deffn {} BFD_RELOC_MICROBLAZE_32_LO_PCREL
-This is a 32 bit pc-relative reloc for the microblaze that 
+This is a 32 bit pc-relative reloc for the microblaze that
 stores the low 16 bits of a value
 @end deffn
 @deffn {} BFD_RELOC_MICROBLAZE_32_ROSDA
-This is a 32 bit reloc for the microblaze that stores a 
+This is a 32 bit reloc for the microblaze that stores a
 value relative to the read-only small data area anchor
 @end deffn
 @deffn {} BFD_RELOC_MICROBLAZE_32_RWSDA
-This is a 32 bit reloc for the microblaze that stores a 
+This is a 32 bit reloc for the microblaze that stores a
 value relative to the read-write small data area anchor
 @end deffn
 @deffn {} BFD_RELOC_MICROBLAZE_32_SYM_OP_SYM
-This is a 32 bit reloc for the microblaze to handle 
+This is a 32 bit reloc for the microblaze to handle
 expressions of the form "Symbol Op Symbol"
 @end deffn
 @deffn {} BFD_RELOC_MICROBLAZE_64_NONE
-This is a 64 bit reloc that stores the 32 bit pc relative 
-value in two words (with an imm instruction).  No relocation is 
+This is a 64 bit reloc that stores the 32 bit pc relative
+value in two words (with an imm instruction).  No relocation is
 done here - only used for relaxing
 @end deffn
 @deffn {} BFD_RELOC_MICROBLAZE_64_GOTPC
-This is a 64 bit reloc that stores the 32 bit pc relative 
+This is a 64 bit reloc that stores the 32 bit pc relative
 value in two words (with an imm instruction).  The relocation is
 PC-relative GOT offset
 @end deffn
 @deffn {} BFD_RELOC_MICROBLAZE_64_GOT
-This is a 64 bit reloc that stores the 32 bit pc relative 
+This is a 64 bit reloc that stores the 32 bit pc relative
 value in two words (with an imm instruction).  The relocation is
 GOT offset
 @end deffn
 @deffn {} BFD_RELOC_MICROBLAZE_64_PLT
-This is a 64 bit reloc that stores the 32 bit pc relative 
+This is a 64 bit reloc that stores the 32 bit pc relative
 value in two words (with an imm instruction).  The relocation is
 PC-relative offset into PLT
 @end deffn
 @deffn {} BFD_RELOC_MICROBLAZE_64_GOTOFF
-This is a 64 bit reloc that stores the 32 bit GOT relative 
+This is a 64 bit reloc that stores the 32 bit GOT relative
 value in two words (with an imm instruction).  The relocation is
 relative offset from _GLOBAL_OFFSET_TABLE_
 @end deffn
 @deffn {} BFD_RELOC_MICROBLAZE_32_GOTOFF
-This is a 32 bit reloc that stores the 32 bit GOT relative 
+This is a 32 bit reloc that stores the 32 bit GOT relative
 value in a word.  The relocation is relative offset from
 @end deffn
 @deffn {} BFD_RELOC_MICROBLAZE_COPY
 This is used to tell the dynamic linker to copy the value out of
 the dynamic object into the runtime process image.
 @end deffn
+@deffn {} BFD_RELOC_MICROBLAZE_64_TLS
+Unused Reloc
+@end deffn
+@deffn {} BFD_RELOC_MICROBLAZE_64_TLSGD
+This is a 64 bit reloc that stores the 32 bit GOT relative value
+of the GOT TLS GD info entry in two words (with an imm instruction). The
+relocation is GOT offset.
+@end deffn
+@deffn {} BFD_RELOC_MICROBLAZE_64_TLSLD
+This is a 64 bit reloc that stores the 32 bit GOT relative value
+of the GOT TLS LD info entry in two words (with an imm instruction). The
+relocation is GOT offset.
+@end deffn
+@deffn {} BFD_RELOC_MICROBLAZE_32_TLSDTPMOD
+This is a 32 bit reloc that stores the Module ID to GOT(n).
+@end deffn
+@deffn {} BFD_RELOC_MICROBLAZE_32_TLSDTPREL
+This is a 32 bit reloc that stores TLS offset to GOT(n+1).
+@end deffn
+@deffn {} BFD_RELOC_MICROBLAZE_64_TLSDTPREL
+This is a 32 bit reloc for storing TLS offset to two words (uses imm
+instruction)
+@end deffn
+@deffn {} BFD_RELOC_MICROBLAZE_64_TLSGOTTPREL
+This is a 64 bit reloc that stores 32-bit thread pointer relative offset
+to two words (uses imm instruction).
+@end deffn
+@deffn {} BFD_RELOC_MICROBLAZE_64_TLSTPREL
+This is a 64 bit reloc that stores 32-bit thread pointer relative offset
+to two words (uses imm instruction).
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_RELOC_START
+AArch64 pseudo relocation code to mark the start of the AArch64
+relocation enumerators.  N.B. the order of the enumerators is
+important as several tables in the AArch64 bfd backend are indexed
+by these enumerators; make sure they are all synced.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_NONE
+AArch64 null relocation code.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_64
+@deffnx {} BFD_RELOC_AARCH64_32
+@deffnx {} BFD_RELOC_AARCH64_16
+Basic absolute relocations of N bits.  These are equivalent to
+BFD_RELOC_N and they were added to assist the indexing of the howto
+table.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_64_PCREL
+@deffnx {} BFD_RELOC_AARCH64_32_PCREL
+@deffnx {} BFD_RELOC_AARCH64_16_PCREL
+PC-relative relocations.  These are equivalent to BFD_RELOC_N_PCREL
+and they were added to assist the indexing of the howto table.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_MOVW_G0
+AArch64 MOV[NZK] instruction with most significant bits 0 to 15
+of an unsigned address/value.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_MOVW_G0_NC
+AArch64 MOV[NZK] instruction with less significant bits 0 to 15 of
+an address/value.  No overflow checking.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_MOVW_G1
+AArch64 MOV[NZK] instruction with most significant bits 16 to 31
+of an unsigned address/value.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_MOVW_G1_NC
+AArch64 MOV[NZK] instruction with less significant bits 16 to 31
+of an address/value.  No overflow checking.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_MOVW_G2
+AArch64 MOV[NZK] instruction with most significant bits 32 to 47
+of an unsigned address/value.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_MOVW_G2_NC
+AArch64 MOV[NZK] instruction with less significant bits 32 to 47
+of an address/value.  No overflow checking.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_MOVW_G3
+AArch64 MOV[NZK] instruction with most signficant bits 48 to 64
+of a signed or unsigned address/value.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_MOVW_G0_S
+AArch64 MOV[NZ] instruction with most significant bits 0 to 15
+of a signed value.  Changes instruction to MOVZ or MOVN depending on the
+value's sign.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_MOVW_G1_S
+AArch64 MOV[NZ] instruction with most significant bits 16 to 31
+of a signed value.  Changes instruction to MOVZ or MOVN depending on the
+value's sign.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_MOVW_G2_S
+AArch64 MOV[NZ] instruction with most significant bits 32 to 47
+of a signed value.  Changes instruction to MOVZ or MOVN depending on the
+value's sign.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_LD_LO19_PCREL
+AArch64 Load Literal instruction, holding a 19 bit pc-relative word
+offset.  The lowest two bits must be zero and are not stored in the
+instruction, giving a 21 bit signed byte offset.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_ADR_LO21_PCREL
+AArch64 ADR instruction, holding a simple 21 bit pc-relative byte offset.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_ADR_HI21_PCREL
+AArch64 ADRP instruction, with bits 12 to 32 of a pc-relative page
+offset, giving a 4KB aligned page base address.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL
+AArch64 ADRP instruction, with bits 12 to 32 of a pc-relative page
+offset, giving a 4KB aligned page base address, but with no overflow
+checking.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_ADD_LO12
+AArch64 ADD immediate instruction, holding bits 0 to 11 of the address.
+Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_LDST8_LO12
+AArch64 8-bit load/store instruction, holding bits 0 to 11 of the
+address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TSTBR14
+AArch64 14 bit pc-relative test bit and branch.
+The lowest two bits must be zero and are not stored in the instruction,
+giving a 16 bit signed byte offset.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_BRANCH19
+AArch64 19 bit pc-relative conditional branch and compare & branch.
+The lowest two bits must be zero and are not stored in the instruction,
+giving a 21 bit signed byte offset.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_JUMP26
+AArch64 26 bit pc-relative unconditional branch.
+The lowest two bits must be zero and are not stored in the instruction,
+giving a 28 bit signed byte offset.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_CALL26
+AArch64 26 bit pc-relative unconditional branch and link.
+The lowest two bits must be zero and are not stored in the instruction,
+giving a 28 bit signed byte offset.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_LDST16_LO12
+AArch64 16-bit load/store instruction, holding bits 0 to 11 of the
+address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_LDST32_LO12
+AArch64 32-bit load/store instruction, holding bits 0 to 11 of the
+address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_LDST64_LO12
+AArch64 64-bit load/store instruction, holding bits 0 to 11 of the
+address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_LDST128_LO12
+AArch64 128-bit load/store instruction, holding bits 0 to 11 of the
+address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_GOT_LD_PREL19
+AArch64 Load Literal instruction, holding a 19 bit PC relative word
+offset of the global offset table entry for a symbol.  The lowest two
+bits must be zero and are not stored in the instruction, giving a 21
+bit signed byte offset.  This relocation type requires signed overflow
+checking.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_ADR_GOT_PAGE
+Get to the page base of the global offset table entry for a symbol as
+part of an ADRP instruction using a 21 bit PC relative value.Used in
+conjunction with BFD_RELOC_AARCH64_LD64_GOT_LO12_NC.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_LD64_GOT_LO12_NC
+Unsigned 12 bit byte offset for 64 bit load/store from the page of
+the GOT entry for this symbol.  Used in conjunction with
+BFD_RELOC_AARCH64_ADR_GOTPAGE.  Valid in LP64 ABI only.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_LD32_GOT_LO12_NC
+Unsigned 12 bit byte offset for 32 bit load/store from the page of
+the GOT entry for this symbol.  Used in conjunction with
+BFD_RELOC_AARCH64_ADR_GOTPAGE.  Valid in ILP32 ABI only.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21
+Get to the page base of the global offset table entry for a symbols
+tls_index structure as part of an adrp instruction using a 21 bit PC
+relative value.  Used in conjunction with
+BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC
+Unsigned 12 bit byte offset to global offset table entry for a symbols
+tls_index structure.  Used in conjunction with
+BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1
+AArch64 TLS INITIAL EXEC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC
+AArch64 TLS INITIAL EXEC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21
+AArch64 TLS INITIAL EXEC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC
+AArch64 TLS INITIAL EXEC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC
+AArch64 TLS INITIAL EXEC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19
+AArch64 TLS INITIAL EXEC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2
+AArch64 TLS LOCAL EXEC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1
+AArch64 TLS LOCAL EXEC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC
+AArch64 TLS LOCAL EXEC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0
+AArch64 TLS LOCAL EXEC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC
+AArch64 TLS LOCAL EXEC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12
+AArch64 TLS LOCAL EXEC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12
+AArch64 TLS LOCAL EXEC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC
+AArch64 TLS LOCAL EXEC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSDESC_LD_PREL19
+AArch64 TLS DESC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21
+AArch64 TLS DESC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21
+AArch64 TLS DESC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC
+AArch64 TLS DESC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC
+AArch64 TLS DESC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC
+AArch64 TLS DESC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSDESC_OFF_G1
+AArch64 TLS DESC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC
+AArch64 TLS DESC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSDESC_LDR
+AArch64 TLS DESC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSDESC_ADD
+AArch64 TLS DESC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSDESC_CALL
+AArch64 TLS DESC relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_COPY
+AArch64 TLS relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_GLOB_DAT
+AArch64 TLS relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_JUMP_SLOT
+AArch64 TLS relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_RELATIVE
+AArch64 TLS relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLS_DTPMOD
+AArch64 TLS relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLS_DTPREL
+AArch64 TLS relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLS_TPREL
+AArch64 TLS relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSDESC
+AArch64 TLS relocation.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_IRELATIVE
+AArch64 support for STT_GNU_IFUNC.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_RELOC_END
+AArch64 pseudo relocation code to mark the end of the AArch64
+relocation enumerators that have direct mapping to ELF reloc codes.
+There are a few more enumerators after this one; those are mainly
+used by the AArch64 assembler for the internal fixup or to select
+one of the above enumerators.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_GAS_INTERNAL_FIXUP
+AArch64 pseudo relocation code to be used internally by the AArch64
+assembler and not (currently) written to any object files.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_LDST_LO12
+AArch64 unspecified load/store instruction, holding bits 0 to 11 of the
+address.  Used in conjunction with BFD_RELOC_AARCH64_ADR_HI21_PCREL.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_LD_GOT_LO12_NC
+AArch64 pseudo relocation code to be used internally by the AArch64
+assembler and not (currently) written to any object files.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC
+AArch64 pseudo relocation code to be used internally by the AArch64
+assembler and not (currently) written to any object files.
+@end deffn
+@deffn {} BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC
+AArch64 pseudo relocation code to be used internally by the AArch64
+assembler and not (currently) written to any object files.
+@end deffn
 @deffn {} BFD_RELOC_TILEPRO_COPY
 @deffnx {} BFD_RELOC_TILEPRO_GLOB_DAT
 @deffnx {} BFD_RELOC_TILEPRO_JMP_SLOT
@@ -2970,6 +3577,12 @@
 @deffnx {} BFD_RELOC_TILEPRO_SHAMT_X1
 @deffnx {} BFD_RELOC_TILEPRO_SHAMT_Y0
 @deffnx {} BFD_RELOC_TILEPRO_SHAMT_Y1
+@deffnx {} BFD_RELOC_TILEPRO_TLS_GD_CALL
+@deffnx {} BFD_RELOC_TILEPRO_IMM8_X0_TLS_GD_ADD
+@deffnx {} BFD_RELOC_TILEPRO_IMM8_X1_TLS_GD_ADD
+@deffnx {} BFD_RELOC_TILEPRO_IMM8_Y0_TLS_GD_ADD
+@deffnx {} BFD_RELOC_TILEPRO_IMM8_Y1_TLS_GD_ADD
+@deffnx {} BFD_RELOC_TILEPRO_TLS_IE_LOAD
 @deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD
 @deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_TLS_GD
 @deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD_LO
@@ -2989,6 +3602,14 @@
 @deffnx {} BFD_RELOC_TILEPRO_TLS_DTPMOD32
 @deffnx {} BFD_RELOC_TILEPRO_TLS_DTPOFF32
 @deffnx {} BFD_RELOC_TILEPRO_TLS_TPOFF32
+@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE
+@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE
+@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_LO
+@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_LO
+@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_HI
+@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_HI
+@deffnx {} BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_HA
+@deffnx {} BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_HA
 Tilera TILEPro Relocations.
 @end deffn
 @deffn {} BFD_RELOC_TILEGX_HW0
@@ -3048,54 +3669,81 @@
 @deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_PCREL
 @deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_GOT
 @deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_GOT
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW1_GOT
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW1_GOT
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW2_GOT
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW2_GOT
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW3_GOT
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW3_GOT
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_PLT_PCREL
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_PLT_PCREL
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW1_PLT_PCREL
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW1_PLT_PCREL
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW2_PLT_PCREL
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW2_PLT_PCREL
 @deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_GOT
 @deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_GOT
 @deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_GOT
 @deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_GOT
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_GOT
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_GOT
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW3_PLT_PCREL
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW3_PLT_PCREL
 @deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_TLS_GD
 @deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_TLS_GD
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW1_TLS_GD
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW1_TLS_GD
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW2_TLS_GD
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW2_TLS_GD
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW3_TLS_GD
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW3_TLS_GD
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_TLS_LE
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_TLS_LE
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
 @deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
 @deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_TLS_GD
 @deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_TLS_GD
 @deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_TLS_GD
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_TLS_GD
 @deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_TLS_IE
 @deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_TLS_IE
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW1_TLS_IE
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW1_TLS_IE
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW2_TLS_IE
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW2_TLS_IE
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW3_TLS_IE
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW3_TLS_IE
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL
+@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL
 @deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
 @deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
 @deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_TLS_IE
 @deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_TLS_IE
-@deffnx {} BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_TLS_IE
 @deffnx {} BFD_RELOC_TILEGX_TLS_DTPMOD64
 @deffnx {} BFD_RELOC_TILEGX_TLS_DTPOFF64
 @deffnx {} BFD_RELOC_TILEGX_TLS_TPOFF64
 @deffnx {} BFD_RELOC_TILEGX_TLS_DTPMOD32
 @deffnx {} BFD_RELOC_TILEGX_TLS_DTPOFF32
 @deffnx {} BFD_RELOC_TILEGX_TLS_TPOFF32
+@deffnx {} BFD_RELOC_TILEGX_TLS_GD_CALL
+@deffnx {} BFD_RELOC_TILEGX_IMM8_X0_TLS_GD_ADD
+@deffnx {} BFD_RELOC_TILEGX_IMM8_X1_TLS_GD_ADD
+@deffnx {} BFD_RELOC_TILEGX_IMM8_Y0_TLS_GD_ADD
+@deffnx {} BFD_RELOC_TILEGX_IMM8_Y1_TLS_GD_ADD
+@deffnx {} BFD_RELOC_TILEGX_TLS_IE_LOAD
+@deffnx {} BFD_RELOC_TILEGX_IMM8_X0_TLS_ADD
+@deffnx {} BFD_RELOC_TILEGX_IMM8_X1_TLS_ADD
+@deffnx {} BFD_RELOC_TILEGX_IMM8_Y0_TLS_ADD
+@deffnx {} BFD_RELOC_TILEGX_IMM8_Y1_TLS_ADD
 Tilera TILE-Gx Relocations.
 @end deffn
+@deffn {} BFD_RELOC_EPIPHANY_SIMM8
+Adapteva EPIPHANY - 8 bit signed pc-relative displacement
+@end deffn
+@deffn {} BFD_RELOC_EPIPHANY_SIMM24
+Adapteva EPIPHANY - 24 bit signed pc-relative displacement
+@end deffn
+@deffn {} BFD_RELOC_EPIPHANY_HIGH
+Adapteva EPIPHANY - 16 most-significant bits of absolute address
+@end deffn
+@deffn {} BFD_RELOC_EPIPHANY_LOW
+Adapteva EPIPHANY - 16 least-significant bits of absolute address
+@end deffn
+@deffn {} BFD_RELOC_EPIPHANY_SIMM11
+Adapteva EPIPHANY - 11 bit signed number - add/sub immediate
+@end deffn
+@deffn {} BFD_RELOC_EPIPHANY_IMM11
+Adapteva EPIPHANY - 11 bit sign-magnitude number (ld/st displacement)
+@end deffn
+@deffn {} BFD_RELOC_EPIPHANY_IMM8
+Adapteva EPIPHANY - 8 bit immediate for 16 bit mov instruction.
+@end deffn
 
 @example
 
@@ -3164,12 +3812,13 @@
 @subsubsection @code{bfd_generic_lookup_section_flags}
 @strong{Synopsis}
 @example
-void bfd_generic_lookup_section_flags
-   (struct bfd_link_info *, struct flag_info *);
+bfd_boolean bfd_generic_lookup_section_flags
+   (struct bfd_link_info *, struct flag_info *, asection *);
 @end example
 @strong{Description}@*
 Provides default handling for section flags lookup
 -- i.e., does nothing.
+Returns FALSE if the section should be omitted, otherwise TRUE.
 
 @findex bfd_generic_merge_sections
 @subsubsection @code{bfd_generic_merge_sections}
diff --git a/bfd/doc/section.texi b/bfd/doc/section.texi
index 5013701..60b62cf 100644
--- a/bfd/doc/section.texi
+++ b/bfd/doc/section.texi
@@ -339,11 +339,11 @@
 
   /* Type of sec_info information.  */
   unsigned int sec_info_type:3;
-#define ELF_INFO_TYPE_NONE      0
-#define ELF_INFO_TYPE_STABS     1
-#define ELF_INFO_TYPE_MERGE     2
-#define ELF_INFO_TYPE_EH_FRAME  3
-#define ELF_INFO_TYPE_JUST_SYMS 4
+#define SEC_INFO_TYPE_NONE      0
+#define SEC_INFO_TYPE_STABS     1
+#define SEC_INFO_TYPE_MERGE     2
+#define SEC_INFO_TYPE_EH_FRAME  3
+#define SEC_INFO_TYPE_JUST_SYMS 4
 
   /* Nonzero if this section uses RELA relocations, rather than REL.  */
   unsigned int use_rela_p:1;
@@ -473,9 +473,6 @@
   /* The BFD which owns the section.  */
   bfd *owner;
 
-  /* INPUT_SECTION_FLAGS if specified in the linker script.  */
-  struct flag_info *section_flag_info;
-
   /* A symbol which points at this section only.  */
   struct bfd_symbol *symbol;
   struct bfd_symbol **symbol_ptr_ptr;
@@ -491,40 +488,37 @@
 @} asection;
 
 /* Relax table contains information about instructions which can
-   be removed by relaxation -- replacing a long address with a 
+   be removed by relaxation -- replacing a long address with a
    short address.  */
 struct relax_table @{
   /* Address where bytes may be deleted. */
   bfd_vma addr;
-  
+
   /* Number of bytes to be deleted.  */
   int size;
 @};
 
 /* These sections are global, and are managed by BFD.  The application
    and target back end are not permitted to change the values in
-   these sections.  New code should use the section_ptr macros rather
-   than referring directly to the const sections.  The const sections
-   may eventually vanish.  */
+   these sections.  */
+extern asection _bfd_std_section[4];
+
 #define BFD_ABS_SECTION_NAME "*ABS*"
 #define BFD_UND_SECTION_NAME "*UND*"
 #define BFD_COM_SECTION_NAME "*COM*"
 #define BFD_IND_SECTION_NAME "*IND*"
 
-/* The absolute section.  */
-extern asection bfd_abs_section;
-#define bfd_abs_section_ptr ((asection *) &bfd_abs_section)
-#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr)
-/* Pointer to the undefined section.  */
-extern asection bfd_und_section;
-#define bfd_und_section_ptr ((asection *) &bfd_und_section)
-#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr)
 /* Pointer to the common section.  */
-extern asection bfd_com_section;
-#define bfd_com_section_ptr ((asection *) &bfd_com_section)
+#define bfd_com_section_ptr (&_bfd_std_section[0])
+/* Pointer to the undefined section.  */
+#define bfd_und_section_ptr (&_bfd_std_section[1])
+/* Pointer to the absolute section.  */
+#define bfd_abs_section_ptr (&_bfd_std_section[2])
 /* Pointer to the indirect section.  */
-extern asection bfd_ind_section;
-#define bfd_ind_section_ptr ((asection *) &bfd_ind_section)
+#define bfd_ind_section_ptr (&_bfd_std_section[3])
+
+#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr)
+#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr)
 #define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr)
 
 #define bfd_is_const_section(SEC)              \
@@ -639,8 +633,8 @@
   /* vma, lma, size, rawsize, compressed_size, relax, relax_count, */  \
      0,   0,   0,    0,       0,               0,     0,               \
                                                                        \
-  /* output_offset, output_section,              alignment_power,  */  \
-     0,             (struct bfd_section *) &SEC, 0,                    \
+  /* output_offset, output_section, alignment_power,               */  \
+     0,             &SEC,           0,                                 \
                                                                        \
   /* relocation, orelocation, reloc_count, filepos, rel_filepos,   */  \
      NULL,       NULL,        0,           0,       0,                 \
@@ -654,9 +648,6 @@
   /* target_index, used_by_bfd, constructor_chain, owner,          */  \
      0,            NULL,        NULL,              NULL,               \
                                                                        \
-  /* flag_info,                                                    */  \
-     NULL,                                                             \
-                                                                       \
   /* symbol,                    symbol_ptr_ptr,                    */  \
      (struct bfd_symbol *) SYM, &SEC.symbol,                           \
                                                                        \
@@ -687,14 +678,29 @@
 asection *bfd_get_section_by_name (bfd *abfd, const char *name);
 @end example
 @strong{Description}@*
-Run through @var{abfd} and return the one of the
-@code{asection}s whose name matches @var{name}, otherwise @code{NULL}.
-@xref{Sections}, for more information.
+Return the most recently created section attached to @var{abfd}
+named @var{name}.  Return NULL if no such section exists.
 
-This should only be used in special cases; the normal way to process
-all sections of a given name is to use @code{bfd_map_over_sections} and
-@code{strcmp} on the name (or better yet, base it on the section flags
-or something else) for each section.
+@findex bfd_get_next_section_by_name
+@subsubsection @code{bfd_get_next_section_by_name}
+@strong{Synopsis}
+@example
+asection *bfd_get_next_section_by_name (asection *sec);
+@end example
+@strong{Description}@*
+Given @var{sec} is a section returned by @code{bfd_get_section_by_name},
+return the next most recently created section attached to the same
+BFD with the same name.  Return NULL if no such section exists.
+
+@findex bfd_get_linker_section
+@subsubsection @code{bfd_get_linker_section}
+@strong{Synopsis}
+@example
+asection *bfd_get_linker_section (bfd *abfd, const char *name);
+@end example
+@strong{Description}@*
+Return the linker created section attached to @var{abfd}
+named @var{name}.  Return NULL if no such section exists.
 
 @findex bfd_get_section_by_name_if
 @subsubsection @code{bfd_get_section_by_name_if}
@@ -881,7 +887,7 @@
 alternative would be to use a loop:
 
 @example
-          section *p;
+          asection *p;
           for (p = abfd->sections; p != NULL; p = p->next)
              func (abfd, p, ...)
 @end example
diff --git a/bfd/doc/syms.texi b/bfd/doc/syms.texi
index d5dc659..6834d10 100644
--- a/bfd/doc/syms.texi
+++ b/bfd/doc/syms.texi
@@ -49,7 +49,7 @@
 
          if (storage_needed == 0)
            return;
-         
+
          symbol_table = xmalloc (storage_needed);
            ...
          number_of_symbols =
@@ -78,6 +78,7 @@
 example showing the creation of a symbol table with only one element:
 
 @example
+       #include "sysdep.h"
        #include "bfd.h"
        int main (void)
        @{
diff --git a/bfd/doc/targets.texi b/bfd/doc/targets.texi
index b25f2f8..890f31b 100644
--- a/bfd/doc/targets.texi
+++ b/bfd/doc/targets.texi
@@ -339,6 +339,7 @@
   NAME##_bfd_is_target_special_symbol, \
   NAME##_get_lineno, \
   NAME##_find_nearest_line, \
+  _bfd_generic_find_nearest_line_discriminator, \
   _bfd_generic_find_line, \
   NAME##_find_inliner_info, \
   NAME##_bfd_make_debug_symbol, \
@@ -362,6 +363,9 @@
   bfd_boolean (*_bfd_find_nearest_line)
     (bfd *, struct bfd_section *, struct bfd_symbol **, bfd_vma,
      const char **, const char **, unsigned int *);
+  bfd_boolean (*_bfd_find_nearest_line_discriminator)
+    (bfd *, struct bfd_section *, struct bfd_symbol **, bfd_vma,
+     const char **, const char **, unsigned int *, unsigned int *);
   bfd_boolean (*_bfd_find_line)
     (bfd *, struct bfd_symbol **, struct bfd_symbol *,
      const char **, unsigned int *);
@@ -467,8 +471,9 @@
   bfd_boolean (*_bfd_gc_sections) (bfd *, struct bfd_link_info *);
 
   /* Sets the bitmask of allowed and disallowed section flags.  */
-  void (*_bfd_lookup_section_flags) (struct bfd_link_info *,
-                                     struct flag_info *);
+  bfd_boolean (*_bfd_lookup_section_flags) (struct bfd_link_info *,
+                                            struct flag_info *,
+                                            asection *);
 
   /* Attempt to merge SEC_MERGE sections.  */
   bfd_boolean (*_bfd_merge_sections) (bfd *, struct bfd_link_info *);
diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c
index 6dec4c1..c9349da 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -1,6 +1,5 @@
 /* DWARF 2 support.
-   Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+   Copyright 1994-2013 Free Software Foundation, Inc.
 
    Adapted from gdb/dwarf2read.c by Gavin Koch of Cygnus Solutions
    ([email protected]).
@@ -90,6 +89,9 @@
   /* Last comp unit in list above.  */
   struct comp_unit *last_comp_unit;
 
+  /* Names of the debug sections.  */
+  const struct dwarf_debug_section *debug_sections;
+
   /* The next unread compilation unit within the .debug_info section.
      Zero indicates that the .debug_info section has not been loaded
      into a buffer yet.  */
@@ -105,6 +107,16 @@
   asection *sec;
   bfd_byte *sec_info_ptr;
 
+  /* Support for alternate debug info sections created by the DWZ utility:
+     This includes a pointer to an alternate bfd which contains *extra*,
+     possibly duplicate debug sections, and pointers to the loaded
+     .debug_str and .debug_info sections from this bfd.  */
+  bfd *          alt_bfd_ptr;
+  bfd_byte *     alt_dwarf_str_buffer;
+  bfd_size_type  alt_dwarf_str_size;
+  bfd_byte *     alt_dwarf_info_buffer;
+  bfd_size_type  alt_dwarf_info_size;
+
   /* A pointer to the memory block allocated for info_ptr.  Neither
      info_ptr nor sec_info_ptr are guaranteed to stay pointing to the
      beginning of the malloc block.  This is used only to free the
@@ -170,6 +182,9 @@
 #define STASH_INFO_HASH_OFF        0
 #define STASH_INFO_HASH_ON         1
 #define STASH_INFO_HASH_DISABLED   2
+
+  /* True if we opened bfd_ptr.  */
+  bfd_boolean close_on_cleanup;
 };
 
 struct arange
@@ -284,6 +299,7 @@
   { ".debug_aranges",		".zdebug_aranges" },
   { ".debug_frame",		".zdebug_frame" },
   { ".debug_info",		".zdebug_info" },
+  { ".debug_info",		".zdebug_info" },
   { ".debug_line",		".zdebug_line" },
   { ".debug_loc",		".zdebug_loc" },
   { ".debug_macinfo",		".zdebug_macinfo" },
@@ -294,6 +310,7 @@
   { ".debug_static_func",	".zdebug_static_func" },
   { ".debug_static_vars",	".zdebug_static_vars" },
   { ".debug_str",		".zdebug_str", },
+  { ".debug_str",		".zdebug_str", },
   { ".debug_types",		".zdebug_types" },
   /* GNU DWARF 1 extensions */
   { ".debug_sfnames",		".zdebug_sfnames" },
@@ -306,12 +323,15 @@
   { NULL,			NULL },
 };
 
+/* NB/ Numbers in this enum must match up with indicies
+   into the dwarf_debug_sections[] array above.  */
 enum dwarf_debug_section_enum
 {
   debug_abbrev = 0,
   debug_aranges,
   debug_frame,
   debug_info,
+  debug_info_alt,
   debug_line,
   debug_loc,
   debug_macinfo,
@@ -322,6 +342,7 @@
   debug_static_func,
   debug_static_vars,
   debug_str,
+  debug_str_alt,
   debug_types,
   debug_sfnames,
   debug_srcinfo,
@@ -402,8 +423,8 @@
 {
   struct info_hash_table *hash_table;
 
-  hash_table = (struct info_hash_table *)
-      bfd_alloc (abfd, sizeof (struct info_hash_table));
+  hash_table = ((struct info_hash_table *)
+		bfd_alloc (abfd, sizeof (struct info_hash_table)));
   if (!hash_table)
     return hash_table;
 
@@ -469,27 +490,29 @@
 
 static bfd_boolean
 read_section (bfd *           abfd,
-	      enum dwarf_debug_section_enum sec,
+	      const struct dwarf_debug_section *sec,
 	      asymbol **      syms,
 	      bfd_uint64_t    offset,
 	      bfd_byte **     section_buffer,
 	      bfd_size_type * section_size)
 {
   asection *msec;
-  const char *section_name = dwarf_debug_sections[sec].uncompressed_name;
+  const char *section_name = sec->uncompressed_name;
 
-  /* read_section is a noop if the section has already been read.  */
-  if (!*section_buffer)
+  /* The section may have already been read.  */
+  if (*section_buffer == NULL)
     {
       msec = bfd_get_section_by_name (abfd, section_name);
       if (! msec)
 	{
-	  section_name = dwarf_debug_sections[sec].compressed_name;
-	  msec = bfd_get_section_by_name (abfd, section_name);
+	  section_name = sec->compressed_name;
+          if (section_name != NULL)
+            msec = bfd_get_section_by_name (abfd, section_name);
 	}
       if (! msec)
 	{
-	  (*_bfd_error_handler) (_("Dwarf Error: Can't find %s section."), section_name);
+	  (*_bfd_error_handler) (_("Dwarf Error: Can't find %s section."),
+                                 sec->uncompressed_name);
 	  bfd_set_error (bfd_error_bad_value);
 	  return FALSE;
 	}
@@ -498,7 +521,7 @@
       if (syms)
 	{
 	  *section_buffer
-	      = bfd_simple_get_relocated_section_contents (abfd, msec, NULL, syms);
+	    = bfd_simple_get_relocated_section_contents (abfd, msec, NULL, syms);
 	  if (! *section_buffer)
 	    return FALSE;
 	}
@@ -517,7 +540,8 @@
      that the client wants.  Validate it here to avoid trouble later.  */
   if (offset != 0 && offset >= *section_size)
     {
-      (*_bfd_error_handler) (_("Dwarf Error: Offset (%lu) greater than or equal to %s size (%lu)."),
+      (*_bfd_error_handler) (_("Dwarf Error: Offset (%lu)"
+			       " greater than or equal to %s size (%lu)."),
 			     (long) offset, section_name, *section_size);
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
@@ -606,7 +630,8 @@
 
   *bytes_read_ptr = unit->offset_size;
 
-  if (! read_section (unit->abfd, debug_str, stash->syms, offset,
+  if (! read_section (unit->abfd, &stash->debug_sections[debug_str],
+                      stash->syms, offset,
 		      &stash->dwarf_str_buffer, &stash->dwarf_str_size))
     return NULL;
 
@@ -616,6 +641,104 @@
   return str;
 }
 
+/* Like read_indirect_string but uses a .debug_str located in
+   an alternate filepointed to by the .gnu_debuglink section.
+   Used to impement DW_FORM_GNU_strp_alt.  */
+
+static char *
+read_alt_indirect_string (struct comp_unit * unit,
+			  bfd_byte *         buf,
+			  unsigned int *     bytes_read_ptr)
+{
+  bfd_uint64_t offset;
+  struct dwarf2_debug *stash = unit->stash;
+  char *str;
+
+  if (unit->offset_size == 4)
+    offset = read_4_bytes (unit->abfd, buf);
+  else
+    offset = read_8_bytes (unit->abfd, buf);
+
+  *bytes_read_ptr = unit->offset_size;
+
+  if (stash->alt_bfd_ptr == NULL)
+    {
+      bfd *  debug_bfd;
+      char * debug_filename = bfd_follow_gnu_debugaltlink (unit->abfd, DEBUGDIR);
+
+      if (debug_filename == NULL)
+	return NULL;
+
+      if ((debug_bfd = bfd_openr (debug_filename, NULL)) == NULL
+	  || ! bfd_check_format (debug_bfd, bfd_object))
+	{
+	  if (debug_bfd)
+	    bfd_close (debug_bfd);
+
+	  /* FIXME: Should we report our failure to follow the debuglink ?  */
+	  free (debug_filename);
+	  return NULL;
+	}
+      stash->alt_bfd_ptr = debug_bfd;
+    }
+  
+  if (! read_section (unit->stash->alt_bfd_ptr,
+		      stash->debug_sections + debug_str_alt,
+		      NULL, /* FIXME: Do we need to load alternate symbols ?  */
+		      offset,
+		      &stash->alt_dwarf_str_buffer,
+		      &stash->alt_dwarf_str_size))
+    return NULL;
+
+  str = (char *) stash->alt_dwarf_str_buffer + offset;
+  if (*str == '\0')
+    return NULL;
+
+  return str;
+}
+
+/* Resolve an alternate reference from UNIT at OFFSET.
+   Returns a pointer into the loaded alternate CU upon success
+   or NULL upon failure.  */
+
+static bfd_byte *
+read_alt_indirect_ref (struct comp_unit * unit,
+		       bfd_uint64_t       offset)
+{
+  struct dwarf2_debug *stash = unit->stash;
+
+  if (stash->alt_bfd_ptr == NULL)
+    {
+      bfd *  debug_bfd;
+      char * debug_filename = bfd_follow_gnu_debugaltlink (unit->abfd, DEBUGDIR);
+
+      if (debug_filename == NULL)
+	return FALSE;
+
+      if ((debug_bfd = bfd_openr (debug_filename, NULL)) == NULL
+	  || ! bfd_check_format (debug_bfd, bfd_object))
+	{
+	  if (debug_bfd)
+	    bfd_close (debug_bfd);
+
+	  /* FIXME: Should we report our failure to follow the debuglink ?  */
+	  free (debug_filename);
+	  return NULL;
+	}
+      stash->alt_bfd_ptr = debug_bfd;
+    }
+  
+  if (! read_section (unit->stash->alt_bfd_ptr,
+		      stash->debug_sections + debug_info_alt,
+		      NULL, /* FIXME: Do we need to load alternate symbols ?  */
+		      offset,
+		      &stash->alt_dwarf_info_buffer,
+		      &stash->alt_dwarf_info_size))
+    return NULL;
+
+  return stash->alt_dwarf_info_buffer + offset;
+}
+
 static bfd_uint64_t
 read_address (struct comp_unit *unit, bfd_byte *buf)
 {
@@ -688,7 +811,8 @@
   unsigned int abbrev_form, hash_number;
   bfd_size_type amt;
 
-  if (! read_section (abfd, debug_abbrev, stash->syms, offset,
+  if (! read_section (abfd, &stash->debug_sections[debug_abbrev],
+                      stash->syms, offset,
 		      &stash->dwarf_abbrev_buffer, &stash->dwarf_abbrev_size))
     return NULL;
 
@@ -818,6 +942,7 @@
       attr->u.val = read_address (unit, info_ptr);
       info_ptr += unit->addr_size;
       break;
+    case DW_FORM_GNU_ref_alt:
     case DW_FORM_sec_offset:
       if (unit->offset_size == 4)
 	attr->u.val = read_4_bytes (unit->abfd, info_ptr);
@@ -867,6 +992,10 @@
       attr->u.str = read_indirect_string (unit, info_ptr, &bytes_read);
       info_ptr += bytes_read;
       break;
+    case DW_FORM_GNU_strp_alt:
+      attr->u.str = read_alt_indirect_string (unit, info_ptr, &bytes_read);
+      info_ptr += bytes_read;
+      break;
     case DW_FORM_exprloc:
     case DW_FORM_block:
       amt = sizeof (struct dwarf_block);
@@ -939,7 +1068,7 @@
       info_ptr = read_attribute_value (attr, form, unit, info_ptr);
       break;
     default:
-      (*_bfd_error_handler) (_("Dwarf Error: Invalid or unhandled FORM value: %u."),
+      (*_bfd_error_handler) (_("Dwarf Error: Invalid or unhandled FORM value: %#x."),
 			     form);
       bfd_set_error (bfd_error_bad_value);
       return NULL;
@@ -1008,20 +1137,27 @@
 /* Remember some information about each function.  If the function is
    inlined (DW_TAG_inlined_subroutine) it may have two additional
    attributes, DW_AT_call_file and DW_AT_call_line, which specify the
-   source code location where this function was inlined. */
+   source code location where this function was inlined.  */
 
 struct funcinfo
 {
-  struct funcinfo *prev_func;		/* Pointer to previous function in list of all functions */
-  struct funcinfo *caller_func;		/* Pointer to function one scope higher */
-  char *caller_file;			/* Source location file name where caller_func inlines this func */
-  int caller_line;			/* Source location line number where caller_func inlines this func */
-  char *file;				/* Source location file name */
-  int line;				/* Source location line number */
+  /* Pointer to previous function in list of all functions.  */
+  struct funcinfo *prev_func;
+  /* Pointer to function one scope higher.  */
+  struct funcinfo *caller_func;
+  /* Source location file name where caller_func inlines this func.  */
+  char *caller_file;
+  /* Source location line number where caller_func inlines this func.  */
+  int caller_line;
+  /* Source location file name.  */
+  char *file;
+  /* Source location line number.  */
+  int line;
   int tag;
   char *name;
   struct arange arange;
-  asection *sec;			/* Where the symbol is defined */
+  /* Where the symbol is defined.  */
+  asection *sec;
 };
 
 struct varinfo
@@ -1244,12 +1380,16 @@
 }
 
 static bfd_boolean
-arange_add (bfd *abfd, struct arange *first_arange,
+arange_add (const struct comp_unit *unit, struct arange *first_arange,
 	    bfd_vma low_pc, bfd_vma high_pc)
 {
   struct arange *arange;
 
-  /* If the first arange is empty, use it. */
+  /* Ignore empty ranges.  */
+  if (low_pc == high_pc)
+    return TRUE;
+
+  /* If the first arange is empty, use it.  */
   if (first_arange->high == 0)
     {
       first_arange->low = low_pc;
@@ -1277,7 +1417,7 @@
 
   /* Need to allocate a new arange and insert it into the arange list.
      Order isn't significant, so just insert after the first arange. */
-  arange = (struct arange *) bfd_zalloc (abfd, sizeof (*arange));
+  arange = (struct arange *) bfd_alloc (unit->abfd, sizeof (*arange));
   if (arange == NULL)
     return FALSE;
   arange->low = low_pc;
@@ -1397,9 +1537,11 @@
   unsigned int i, bytes_read, offset_size;
   char *cur_file, *cur_dir;
   unsigned char op_code, extended_op, adj_opcode;
+  unsigned int exop_len;
   bfd_size_type amt;
 
-  if (! read_section (abfd, debug_line, stash->syms, unit->line_offset,
+  if (! read_section (abfd, &stash->debug_sections[debug_line],
+                      stash->syms, unit->line_offset,
 		      &stash->dwarf_line_buffer, &stash->dwarf_line_size))
     return NULL;
 
@@ -1577,15 +1719,15 @@
 	      /* Special operand.  */
 	      adj_opcode = op_code - lh.opcode_base;
 	      if (lh.maximum_ops_per_insn == 1)
-		address += (adj_opcode / lh.line_range)
-			   * lh.minimum_instruction_length;
+		address += (adj_opcode / lh.line_range
+			    * lh.minimum_instruction_length);
 	      else
 		{
-		  address += ((op_index + (adj_opcode / lh.line_range))
-			      / lh.maximum_ops_per_insn)
-			     * lh.minimum_instruction_length;
-		  op_index = (op_index + (adj_opcode / lh.line_range))
-			     % lh.maximum_ops_per_insn;
+		  address += ((op_index + adj_opcode / lh.line_range)
+			      / lh.maximum_ops_per_insn
+			      * lh.minimum_instruction_length);
+		  op_index = ((op_index + adj_opcode / lh.line_range)
+			      % lh.maximum_ops_per_insn);
 		}
 	      line += lh.line_base + (adj_opcode % lh.line_range);
 	      /* Append row to matrix using current values.  */
@@ -1601,8 +1743,8 @@
 	  else switch (op_code)
 	    {
 	    case DW_LNS_extended_op:
-	      /* Ignore length.  */
-	      line_ptr += 1;
+	      exop_len = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+	      line_ptr += bytes_read;
 	      extended_op = read_1_byte (abfd, line_ptr);
 	      line_ptr += 1;
 
@@ -1618,7 +1760,7 @@
 		    low_pc = address;
 		  if (address > high_pc)
 		    high_pc = address;
-		  if (!arange_add (unit->abfd, &unit->arange, low_pc, high_pc))
+		  if (!arange_add (unit, &unit->arange, low_pc, high_pc))
 		    goto line_fail;
 		  break;
 		case DW_LNE_set_address:
@@ -1657,8 +1799,12 @@
                       read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
 		  line_ptr += bytes_read;
 		  break;
+		case DW_LNE_HP_source_file_correlation:
+		  line_ptr += exop_len - 1;
+		  break;
 		default:
-		  (*_bfd_error_handler) (_("Dwarf Error: mangled line number section."));
+		  (*_bfd_error_handler)
+		    (_("Dwarf Error: mangled line number section."));
 		  bfd_set_error (bfd_error_bad_value);
 		line_fail:
 		  if (filename != NULL)
@@ -1678,15 +1824,15 @@
 	      break;
 	    case DW_LNS_advance_pc:
 	      if (lh.maximum_ops_per_insn == 1)
-		address += lh.minimum_instruction_length
-			   * read_unsigned_leb128 (abfd, line_ptr,
-						   &bytes_read);
+		address += (lh.minimum_instruction_length
+			    * read_unsigned_leb128 (abfd, line_ptr,
+						    &bytes_read));
 	      else
 		{
 		  bfd_vma adjust = read_unsigned_leb128 (abfd, line_ptr,
 							 &bytes_read);
-		  address = ((op_index + adjust) / lh.maximum_ops_per_insn)
-			    * lh.minimum_instruction_length;
+		  address = ((op_index + adjust) / lh.maximum_ops_per_insn
+			     * lh.minimum_instruction_length);
 		  op_index = (op_index + adjust) % lh.maximum_ops_per_insn;
 		}
 	      line_ptr += bytes_read;
@@ -1719,13 +1865,14 @@
 	      break;
 	    case DW_LNS_const_add_pc:
 	      if (lh.maximum_ops_per_insn == 1)
-		address += lh.minimum_instruction_length
-			   * ((255 - lh.opcode_base) / lh.line_range);
+		address += (lh.minimum_instruction_length
+			    * ((255 - lh.opcode_base) / lh.line_range));
 	      else
 		{
 		  bfd_vma adjust = ((255 - lh.opcode_base) / lh.line_range);
-		  address += lh.minimum_instruction_length
-			     * ((op_index + adjust) / lh.maximum_ops_per_insn);
+		  address += (lh.minimum_instruction_length
+			      * ((op_index + adjust)
+				 / lh.maximum_ops_per_insn));
 		  op_index = (op_index + adjust) % lh.maximum_ops_per_insn;
 		}
 	      break;
@@ -1822,7 +1969,8 @@
 read_debug_ranges (struct comp_unit *unit)
 {
   struct dwarf2_debug *stash = unit->stash;
-  return read_section (unit->abfd, debug_ranges, stash->syms, 0,
+  return read_section (unit->abfd, &stash->debug_sections[debug_ranges],
+                       stash->syms, 0,
 		       &stash->dwarf_ranges_buffer, &stash->dwarf_ranges_size);
 }
 
@@ -1853,8 +2001,9 @@
 	{
 	  if (addr >= arange->low && addr < arange->high)
 	    {
-	      if (!best_fit ||
-		  ((arange->high - arange->low) < (best_fit->arange.high - best_fit->arange.low)))
+	      if (!best_fit
+		  || (arange->high - arange->low
+		      < best_fit->arange.high - best_fit->arange.low))
 		best_fit = each_func;
 	    }
 	}
@@ -1902,8 +2051,8 @@
 	      && each_func->name
 	      && strcmp (name, each_func->name) == 0
 	      && (!best_fit
-		  || ((arange->high - arange->low)
-		      < (best_fit->arange.high - best_fit->arange.low))))
+		  || (arange->high - arange->low
+		      < best_fit->arange.high - best_fit->arange.low)))
 	    best_fit = each_func;
 	}
     }
@@ -1965,7 +2114,7 @@
   struct abbrev_info *abbrev;
   bfd_uint64_t die_ref = attr_ptr->u.val;
   struct attribute attr;
-  char *name = 0;
+  char *name = NULL;
 
   /* DW_FORM_ref_addr can reference an entry in a different CU. It
      is an offset from the .debug_info section, not the current CU.  */
@@ -1978,8 +2127,20 @@
 
       info_ptr = unit->sec_info_ptr + die_ref;
     }
-  else 
+  else if (attr_ptr->form == DW_FORM_GNU_ref_alt)
+    {
+      info_ptr = read_alt_indirect_ref (unit, die_ref);
+      if (info_ptr == NULL)
+	{
+	  (*_bfd_error_handler)
+	    (_("Dwarf Error: Unable to read alt ref %u."), die_ref);
+	  bfd_set_error (bfd_error_bad_value);
+	  return name;
+	}
+    }
+  else
     info_ptr = unit->info_ptr_unit + die_ref;
+
   abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
   info_ptr += bytes_read;
 
@@ -1988,8 +2149,8 @@
       abbrev = lookup_abbrev (abbrev_number, unit->abbrevs);
       if (! abbrev)
 	{
-	  (*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %u."),
-				 abbrev_number);
+	  (*_bfd_error_handler)
+	    (_("Dwarf Error: Could not find abbrev number %u."), abbrev_number);
 	  bfd_set_error (bfd_error_bad_value);
 	}
       else
@@ -2054,7 +2215,7 @@
 	base_address = high_pc;
       else
 	{
-	  if (!arange_add (unit->abfd, arange,
+	  if (!arange_add (unit, arange,
 			   base_address + low_pc, base_address + high_pc))
 	    return FALSE;
 	}
@@ -2080,7 +2241,7 @@
      can use to set the caller_func field.  */
   nested_funcs_size = 32;
   nested_funcs = (struct funcinfo **)
-      bfd_malloc (nested_funcs_size * sizeof (struct funcinfo *));
+    bfd_malloc (nested_funcs_size * sizeof (struct funcinfo *));
   if (nested_funcs == NULL)
     return FALSE;
   nested_funcs[nesting_level] = 0;
@@ -2284,7 +2445,7 @@
 
       if (func && high_pc != 0)
 	{
-	  if (!arange_add (unit->abfd, &func->arange, low_pc, high_pc))
+	  if (!arange_add (unit, &func->arange, low_pc, high_pc))
 	    goto fail;
 	}
 
@@ -2298,8 +2459,8 @@
 
 	      nested_funcs_size *= 2;
 	      tmp = (struct funcinfo **)
-                 bfd_realloc (nested_funcs,
-                              (nested_funcs_size * sizeof (struct funcinfo *)));
+		bfd_realloc (nested_funcs,
+			     nested_funcs_size * sizeof (struct funcinfo *));
 	      if (tmp == NULL)
 		goto fail;
 	      nested_funcs = tmp;
@@ -2360,23 +2521,29 @@
 
   if (version != 2 && version != 3 && version != 4)
     {
-      (*_bfd_error_handler) (_("Dwarf Error: found dwarf version '%u', this reader only handles version 2, 3 and 4 information."), version);
+      (*_bfd_error_handler)
+	(_("Dwarf Error: found dwarf version '%u', this reader"
+	   " only handles version 2, 3 and 4 information."), version);
       bfd_set_error (bfd_error_bad_value);
       return 0;
     }
 
   if (addr_size > sizeof (bfd_vma))
     {
-      (*_bfd_error_handler) (_("Dwarf Error: found address size '%u', this reader can not handle sizes greater than '%u'."),
-			 addr_size,
-			 (unsigned int) sizeof (bfd_vma));
+      (*_bfd_error_handler)
+	(_("Dwarf Error: found address size '%u', this reader"
+	   " can not handle sizes greater than '%u'."),
+	 addr_size,
+	 (unsigned int) sizeof (bfd_vma));
       bfd_set_error (bfd_error_bad_value);
       return 0;
     }
 
   if (addr_size != 2 && addr_size != 4 && addr_size != 8)
     {
-      (*_bfd_error_handler) ("Dwarf Error: found address size '%u', this reader can only handle address sizes '2', '4' and '8'.", addr_size);
+      (*_bfd_error_handler)
+	("Dwarf Error: found address size '%u', this reader"
+	 " can only handle address sizes '2', '4' and '8'.", addr_size);
       bfd_set_error (bfd_error_bad_value);
       return 0;
     }
@@ -2384,14 +2551,14 @@
   /* Read the abbrevs for this compilation unit into a table.  */
   abbrevs = read_abbrevs (abfd, abbrev_offset, stash);
   if (! abbrevs)
-      return 0;
+    return 0;
 
   abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
   info_ptr += bytes_read;
   if (! abbrev_number)
     {
       (*_bfd_error_handler) (_("Dwarf Error: Bad abbrev number: %u."),
-			 abbrev_number);
+			     abbrev_number);
       bfd_set_error (bfd_error_bad_value);
       return 0;
     }
@@ -2400,7 +2567,7 @@
   if (! abbrev)
     {
       (*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %u."),
-			 abbrev_number);
+			     abbrev_number);
       bfd_set_error (bfd_error_bad_value);
       return 0;
     }
@@ -2443,7 +2610,8 @@
 	  /* If the compilation unit DIE has a DW_AT_low_pc attribute,
 	     this is the base address to use when reading location
 	     lists or range lists. */
-	  unit->base_address = low_pc;
+	  if (abbrev->tag == DW_TAG_compile_unit)
+	    unit->base_address = low_pc;
 	  break;
 
 	case DW_AT_high_pc:
@@ -2480,7 +2648,7 @@
     high_pc += low_pc;
   if (high_pc != 0)
     {
-      if (!arange_add (unit->abfd, &unit->arange, low_pc, high_pc))
+      if (!arange_add (unit, &unit->arange, low_pc, high_pc))
 	return NULL;
     }
 
@@ -2739,35 +2907,56 @@
 /* Locate a section in a BFD containing debugging info.  The search starts
    from the section after AFTER_SEC, or from the first section in the BFD if
    AFTER_SEC is NULL.  The search works by examining the names of the
-   sections.  There are two permissiable names.  The first is .debug_info.
-   This is the standard DWARF2 name.  The second is a prefix .gnu.linkonce.wi.
+   sections.  There are three permissiable names.  The first two are given
+   by DEBUG_SECTIONS[debug_info] (whose standard DWARF2 names are .debug_info
+   and .zdebug_info).  The third is a prefix .gnu.linkonce.wi.
    This is a variation on the .debug_info section which has a checksum
    describing the contents appended onto the name.  This allows the linker to
    identify and discard duplicate debugging sections for different
    compilation units.  */
-#define DWARF2_DEBUG_INFO ".debug_info"
-#define DWARF2_COMPRESSED_DEBUG_INFO ".zdebug_info"
 #define GNU_LINKONCE_INFO ".gnu.linkonce.wi."
 
 static asection *
-find_debug_info (bfd *abfd, asection *after_sec)
+find_debug_info (bfd *abfd, const struct dwarf_debug_section *debug_sections,
+                 asection *after_sec)
 {
-  asection * msec;
+  asection *msec;
+  const char *look;
 
-  msec = after_sec != NULL ? after_sec->next : abfd->sections;
-
-  while (msec)
+  if (after_sec == NULL)
     {
-      if (strcmp (msec->name, DWARF2_DEBUG_INFO) == 0)
+      look = debug_sections[debug_info].uncompressed_name;
+      msec = bfd_get_section_by_name (abfd, look);
+      if (msec != NULL)
 	return msec;
 
-      if (strcmp (msec->name, DWARF2_COMPRESSED_DEBUG_INFO) == 0)
+      look = debug_sections[debug_info].compressed_name;
+      if (look != NULL)
+	{
+	  msec = bfd_get_section_by_name (abfd, look);
+	  if (msec != NULL)
+	    return msec;
+	}
+
+      for (msec = abfd->sections; msec != NULL; msec = msec->next)
+	if (CONST_STRNEQ (msec->name, GNU_LINKONCE_INFO))
+	  return msec;
+
+      return NULL;
+    }
+
+  for (msec = after_sec->next; msec != NULL; msec = msec->next)
+    {
+      look = debug_sections[debug_info].uncompressed_name;
+      if (strcmp (msec->name, look) == 0)
+	return msec;
+
+      look = debug_sections[debug_info].compressed_name;
+      if (look != NULL && strcmp (msec->name, look) == 0)
 	return msec;
 
       if (CONST_STRNEQ (msec->name, GNU_LINKONCE_INFO))
 	return msec;
-
-      msec = msec->next;
     }
 
   return NULL;
@@ -2808,7 +2997,9 @@
       asection *sect;
       bfd_vma last_vma = 0, last_dwarf = 0;
       bfd_size_type amt;
+      const char *debug_info_name;
 
+      debug_info_name = stash->debug_sections[debug_info].uncompressed_name;
       i = 0;
       for (sect = abfd->sections; sect != NULL; sect = sect->next)
 	{
@@ -2821,7 +3012,7 @@
 	  /* We need to adjust the VMAs of any .debug_info sections.
 	     Skip compressed ones, since no relocations could target
 	     them - they should not appear in object files anyway.  */
-	  if (strcmp (sect->name, DWARF2_DEBUG_INFO) == 0)
+	  if (strcmp (sect->name, debug_info_name) == 0)
 	    is_debug_info = 1;
 	  else if (CONST_STRNEQ (sect->name, GNU_LINKONCE_INFO))
 	    is_debug_info = 1;
@@ -2839,7 +3030,7 @@
 	}
 
       amt = i * sizeof (struct adjusted_section);
-      p = (struct adjusted_section *) bfd_zalloc (abfd, amt);
+      p = (struct adjusted_section *) bfd_alloc (abfd, amt);
       if (! p)
 	return FALSE;
 
@@ -2857,7 +3048,7 @@
 	  /* We need to adjust the VMAs of any .debug_info sections.
 	     Skip compressed ones, since no relocations could target
 	     them - they should not appear in object files anyway.  */
-	  if (strcmp (sect->name, DWARF2_DEBUG_INFO) == 0)
+	  if (strcmp (sect->name, debug_info_name) == 0)
 	    is_debug_info = 1;
 	  else if (CONST_STRNEQ (sect->name, GNU_LINKONCE_INFO))
 	    is_debug_info = 1;
@@ -2933,8 +3124,8 @@
 	      && addr >= arange->low
 	      && addr < arange->high
 	      && (!best_fit
-		  || ((arange->high - arange->low)
-		      < (best_fit->arange.high - best_fit->arange.low))))
+		  || (arange->high - arange->low
+		      < best_fit->arange.high - best_fit->arange.low)))
 	    best_fit = each_func;
 	}
     }
@@ -3125,6 +3316,122 @@
 				   filename_ptr, linenumber_ptr);
 }
 
+/* Read debug information from DEBUG_BFD when DEBUG_BFD is specified.
+   If DEBUG_BFD is not specified, we read debug information from ABFD
+   or its gnu_debuglink. The results will be stored in PINFO.
+   The function returns TRUE iff debug information is ready.  */
+
+bfd_boolean
+_bfd_dwarf2_slurp_debug_info (bfd *abfd, bfd *debug_bfd,
+                              const struct dwarf_debug_section *debug_sections,
+                              asymbol **symbols,
+                              void **pinfo)
+{
+  bfd_size_type amt = sizeof (struct dwarf2_debug);
+  bfd_size_type total_size;
+  asection *msec;
+  struct dwarf2_debug *stash = (struct dwarf2_debug *) *pinfo;
+
+  if (stash != NULL)
+    return TRUE;
+
+  stash = (struct dwarf2_debug *) bfd_zalloc (abfd, amt);
+  if (! stash)
+    return FALSE;
+  stash->debug_sections = debug_sections;
+  stash->syms = symbols;
+
+  *pinfo = stash;
+
+  if (debug_bfd == NULL)
+    debug_bfd = abfd;
+
+  msec = find_debug_info (debug_bfd, debug_sections, NULL);
+  if (msec == NULL && abfd == debug_bfd)
+    {
+      char * debug_filename = bfd_follow_gnu_debuglink (abfd, DEBUGDIR);
+
+      if (debug_filename == NULL)
+	/* No dwarf2 info, and no gnu_debuglink to follow.
+	   Note that at this point the stash has been allocated, but
+	   contains zeros.  This lets future calls to this function
+	   fail more quickly.  */
+	return FALSE;
+
+      if ((debug_bfd = bfd_openr (debug_filename, NULL)) == NULL
+	  || ! bfd_check_format (debug_bfd, bfd_object)
+	  || (msec = find_debug_info (debug_bfd,
+				      debug_sections, NULL)) == NULL)
+	{
+	  if (debug_bfd)
+	    bfd_close (debug_bfd);
+	  /* FIXME: Should we report our failure to follow the debuglink ?  */
+	  free (debug_filename);
+	  return FALSE;
+	}
+      stash->close_on_cleanup = TRUE;
+    }
+  stash->bfd_ptr = debug_bfd;
+
+  /* There can be more than one DWARF2 info section in a BFD these
+     days.  First handle the easy case when there's only one.  If
+     there's more than one, try case two: none of the sections is
+     compressed.  In that case, read them all in and produce one
+     large stash.  We do this in two passes - in the first pass we
+     just accumulate the section sizes, and in the second pass we
+     read in the section's contents.  (The allows us to avoid
+     reallocing the data as we add sections to the stash.)  If
+     some or all sections are compressed, then do things the slow
+     way, with a bunch of reallocs.  */
+
+  if (! find_debug_info (debug_bfd, debug_sections, msec))
+    {
+      /* Case 1: only one info section.  */
+      total_size = msec->size;
+      if (! read_section (debug_bfd, &stash->debug_sections[debug_info],
+			  symbols, 0,
+			  &stash->info_ptr_memory, &total_size))
+	return FALSE;
+    }
+  else
+    {
+      /* Case 2: multiple sections.  */
+      for (total_size = 0;
+	   msec;
+	   msec = find_debug_info (debug_bfd, debug_sections, msec))
+	total_size += msec->size;
+
+      stash->info_ptr_memory = (bfd_byte *) bfd_malloc (total_size);
+      if (stash->info_ptr_memory == NULL)
+	return FALSE;
+
+      total_size = 0;
+      for (msec = find_debug_info (debug_bfd, debug_sections, NULL);
+	   msec;
+	   msec = find_debug_info (debug_bfd, debug_sections, msec))
+	{
+	  bfd_size_type size;
+
+	  size = msec->size;
+	  if (size == 0)
+	    continue;
+
+	  if (!(bfd_simple_get_relocated_section_contents
+		(debug_bfd, msec, stash->info_ptr_memory + total_size,
+		 symbols)))
+	    return FALSE;
+
+	  total_size += size;
+	}
+    }
+
+  stash->info_ptr = stash->info_ptr_memory;
+  stash->info_ptr_end = stash->info_ptr + total_size;
+  stash->sec = find_debug_info (debug_bfd, debug_sections, NULL);
+  stash->sec_info_ptr = stash->info_ptr;
+  return TRUE;
+}
+
 /* Find the source code location of SYMBOL.  If SYMBOL is NULL
    then find the nearest source code location corresponding to
    the address SECTION + OFFSET.
@@ -3132,12 +3439,14 @@
    FILENAME_PTR and LINENUMBER_PTR.  In the case where SYMBOL was
    NULL the FUNCTIONNAME_PTR is also filled in.
    SYMBOLS contains the symbol table for ABFD.
+   DEBUG_SECTIONS contains the name of the dwarf debug sections.
    ADDR_SIZE is the number of bytes in the initial .debug_info length
    field and in the abbreviation offset, or zero to indicate that the
    default value should be used.  */
 
 static bfd_boolean
 find_line (bfd *abfd,
+           const struct dwarf_debug_section *debug_sections,
 	   asection *section,
 	   bfd_vma offset,
 	   asymbol *symbol,
@@ -3164,17 +3473,19 @@
   bfd_vma found = FALSE;
   bfd_boolean do_line;
 
+  *filename_ptr = NULL;
+  if (functionname_ptr != NULL)
+    *functionname_ptr = NULL;
+  *linenumber_ptr = 0;
+  if (discriminator_ptr)
+    *discriminator_ptr = 0;
+
+  if (! _bfd_dwarf2_slurp_debug_info (abfd, NULL,
+				      debug_sections, symbols, pinfo))
+    return FALSE;
+
   stash = (struct dwarf2_debug *) *pinfo;
 
-  if (! stash)
-    {
-      bfd_size_type amt = sizeof (struct dwarf2_debug);
-
-      stash = (struct dwarf2_debug *) bfd_zalloc (abfd, amt);
-      if (! stash)
-	return FALSE;
-    }
-
   /* In a relocatable file, 2 functions may have the same address.
      We change the section vma so that they won't overlap.  */
   if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
@@ -3203,108 +3514,11 @@
     addr += section->output_section->vma + section->output_offset;
   else
     addr += section->vma;
-  *filename_ptr = NULL;
-  if (! do_line)
-    *functionname_ptr = NULL;
-  *linenumber_ptr = 0;
-  if (discriminator_ptr)
-    *discriminator_ptr = 0;
-
-  if (! *pinfo)
-    {
-      bfd *debug_bfd;
-      bfd_size_type total_size;
-      asection *msec;
-
-      *pinfo = stash;
-
-      msec = find_debug_info (abfd, NULL);
-      if (msec == NULL)
-	{
-	  char * debug_filename = bfd_follow_gnu_debuglink (abfd, DEBUGDIR);
-
-	  if (debug_filename == NULL)
-	    /* No dwarf2 info, and no gnu_debuglink to follow.
-	       Note that at this point the stash has been allocated, but
-	       contains zeros.  This lets future calls to this function
-	       fail more quickly.  */
-	    goto done;
-
-	  if ((debug_bfd = bfd_openr (debug_filename, NULL)) == NULL
-	      || ! bfd_check_format (debug_bfd, bfd_object)
-	      || (msec = find_debug_info (debug_bfd, NULL)) == NULL)
-	    {
-	      if (debug_bfd)
-		bfd_close (debug_bfd);
-	      /* FIXME: Should we report our failure to follow the debuglink ?  */
-	      free (debug_filename);
-	      goto done;
-	    }
-	}
-      else
-	debug_bfd = abfd;
-
-      /* There can be more than one DWARF2 info section in a BFD these
-	 days.  First handle the easy case when there's only one.  If
-	 there's more than one, try case two: none of the sections is
-	 compressed.  In that case, read them all in and produce one
-	 large stash.  We do this in two passes - in the first pass we
-	 just accumulate the section sizes, and in the second pass we
-	 read in the section's contents.  (The allows us to avoid
-	 reallocing the data as we add sections to the stash.)  If
-	 some or all sections are compressed, then do things the slow
-	 way, with a bunch of reallocs.  */
-
-      if (! find_debug_info (debug_bfd, msec))
-	{
-	  /* Case 1: only one info section.  */
-	  total_size = msec->size;
-	  if (! read_section (debug_bfd, debug_info, symbols, 0,
-			      &stash->info_ptr_memory, &total_size))
-	    goto done;
-	}
-      else
-	{
-	  /* Case 2: multiple sections.  */
-	  for (total_size = 0; msec; msec = find_debug_info (debug_bfd, msec))
-	    total_size += msec->size;
-
-	  stash->info_ptr_memory = (bfd_byte *) bfd_malloc (total_size);
-	  if (stash->info_ptr_memory == NULL)
-	    goto done;
-
-	  total_size = 0;
-	  for (msec = find_debug_info (debug_bfd, NULL);
-	       msec;
-	       msec = find_debug_info (debug_bfd, msec))
-	    {
-	      bfd_size_type size;
-
-	      size = msec->size;
-	      if (size == 0)
-		continue;
-
-	      if (!(bfd_simple_get_relocated_section_contents
-		    (debug_bfd, msec, stash->info_ptr_memory + total_size,
-		     symbols)))
-		goto done;
-
-	      total_size += size;
-	    }
-	}
-
-      stash->info_ptr = stash->info_ptr_memory;
-      stash->info_ptr_end = stash->info_ptr + total_size;
-      stash->sec = find_debug_info (debug_bfd, NULL);
-      stash->sec_info_ptr = stash->info_ptr;
-      stash->syms = symbols;
-      stash->bfd_ptr = debug_bfd;
-    }
 
   /* A null info_ptr indicates that there is no dwarf2 info
      (or that an error occured while setting up the stash).  */
   if (! stash->info_ptr)
-    goto done;
+    return FALSE;
 
   stash->inliner_chain = NULL;
 
@@ -3334,6 +3548,7 @@
 	  /* Check the previously read comp. units first.  */
 	  for (each = stash->all_comp_units; each; each = each->next_unit)
 	    if ((symbol->flags & BSF_FUNCTION) == 0
+		|| each->arange.high == 0
 		|| comp_unit_contains_address (each, addr))
 	      {
 		found = comp_unit_find_line (each, symbol, addr, filename_ptr,
@@ -3347,7 +3562,8 @@
     {
       for (each = stash->all_comp_units; each; each = each->next_unit)
 	{
-	  found = (comp_unit_contains_address (each, addr)
+	  found = ((each->arange.high == 0
+		    || comp_unit_contains_address (each, addr))
 		   && comp_unit_find_nearest_line (each, addr,
 						   filename_ptr,
 						   functionname_ptr,
@@ -3422,10 +3638,10 @@
 	    stash->all_comp_units->prev_unit = each;
 	  else
 	    stash->last_comp_unit = each;
-	  
+
 	  each->next_unit = stash->all_comp_units;
 	  stash->all_comp_units = each;
-	  
+
 	  /* DW_AT_low_pc and DW_AT_high_pc are optional for
 	     compilation units.  If we don't have them (i.e.,
 	     unit->high == 0), we need to consult the line info table
@@ -3452,7 +3668,8 @@
 	  if ((bfd_vma) (stash->info_ptr - stash->sec_info_ptr)
 	      == stash->sec->size)
 	    {
-	      stash->sec = find_debug_info (stash->bfd_ptr, stash->sec);
+	      stash->sec = find_debug_info (stash->bfd_ptr, debug_sections,
+                                            stash->sec);
 	      stash->sec_info_ptr = stash->info_ptr;
 	    }
 
@@ -3461,7 +3678,7 @@
 	}
     }
 
-done:
+ done:
   if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
     unset_sections (stash);
 
@@ -3473,6 +3690,7 @@
 
 bfd_boolean
 _bfd_dwarf2_find_nearest_line (bfd *abfd,
+                               const struct dwarf_debug_section *debug_sections,
 			       asection *section,
 			       asymbol **symbols,
 			       bfd_vma offset,
@@ -3483,8 +3701,8 @@
 			       unsigned int addr_size,
 			       void **pinfo)
 {
-  return find_line (abfd, section, offset, NULL, symbols, filename_ptr,
-		    functionname_ptr, linenumber_ptr,
+  return find_line (abfd, debug_sections, section, offset, NULL, symbols,
+                    filename_ptr, functionname_ptr, linenumber_ptr,
                     discriminator_ptr, addr_size, pinfo);
 }
 
@@ -3501,8 +3719,8 @@
 		       unsigned int addr_size,
 		       void **pinfo)
 {
-  return find_line (abfd, NULL, 0, symbol, symbols, filename_ptr,
-		    NULL, linenumber_ptr, discriminator_ptr,
+  return find_line (abfd, dwarf_debug_sections, NULL, 0, symbol, symbols,
+                    filename_ptr, NULL, linenumber_ptr, discriminator_ptr,
                     addr_size, pinfo);
 }
 
@@ -3534,17 +3752,12 @@
 }
 
 void
-_bfd_dwarf2_cleanup_debug_info (bfd *abfd)
+_bfd_dwarf2_cleanup_debug_info (bfd *abfd, void **pinfo)
 {
+  struct dwarf2_debug *stash = (struct dwarf2_debug *) *pinfo;
   struct comp_unit *each;
-  struct dwarf2_debug *stash;
 
-  if (abfd == NULL || elf_tdata (abfd) == NULL)
-    return;
-
-  stash = (struct dwarf2_debug *) elf_tdata (abfd)->dwarf2_find_line_info;
-
-  if (stash == NULL)
+  if (abfd == NULL || stash == NULL)
     return;
 
   for (each = stash->all_comp_units; each; each = each->next_unit)
@@ -3609,4 +3822,12 @@
     free (stash->dwarf_ranges_buffer);
   if (stash->info_ptr_memory)
     free (stash->info_ptr_memory);
+  if (stash->close_on_cleanup)
+    bfd_close (stash->bfd_ptr);
+  if (stash->alt_dwarf_str_buffer)
+    free (stash->alt_dwarf_str_buffer);
+  if (stash->alt_dwarf_info_buffer)
+    free (stash->alt_dwarf_info_buffer);
+  if (stash->alt_bfd_ptr)
+    bfd_close (stash->alt_bfd_ptr);
 }
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index b76266d..7bfb333 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -1,7 +1,5 @@
 /* Generic ECOFF (Extended-COFF) routines.
-   Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright 1990-2013 Free Software Foundation, Inc.
    Original version by Per Bothner.
    Full support added by Ian Lance Taylor, [email protected].
 
@@ -73,8 +71,6 @@
      0,       NULL,         0,
   /* target_index, used_by_bfd, constructor_chain, owner,          */
      0,            NULL,        NULL,              NULL,
-  /* flag_info,                                                    */
-     NULL,
   /* symbol,                                                       */
      NULL,
   /* symbol_ptr_ptr,                                               */
@@ -236,9 +232,7 @@
 }
 
 bfd_boolean
-_bfd_ecoff_no_long_sections (abfd, enable)
-     bfd *abfd;
-     int enable;
+_bfd_ecoff_no_long_sections (bfd *abfd, int enable)
 {
   (void) abfd;
   (void) enable;
@@ -1892,7 +1886,7 @@
   ret = (bfd_coff_filhsz (abfd)
 	 + bfd_coff_aoutsz (abfd)
 	 + c * bfd_coff_scnhsz (abfd));
-  return BFD_ALIGN (ret, 16);
+  return (int) BFD_ALIGN (ret, 16);
 }
 
 /* Get the contents of a section.  */
@@ -2908,7 +2902,7 @@
   if (mapdata == NULL)
     return FALSE;
   parsed_size = mapdata->parsed_size;
-  bfd_release (abfd, (void *) mapdata);
+  free (mapdata);
 
   raw_armap = (char *) bfd_alloc (abfd, parsed_size);
   if (raw_armap == NULL)
@@ -3567,9 +3561,9 @@
   void (* const swap_ext_in) (bfd *, void *, EXTR *)
     = backend->debug_swap.swap_ext_in;
   HDRR *symhdr;
-  bfd_size_type external_ext_size;
+  bfd_size_type external_ext_size = 0;
   void * external_ext = NULL;
-  bfd_size_type esize;
+  bfd_size_type esize = 0;
   char *ssext = NULL;
   char *ext_ptr;
   char *ext_end;
diff --git a/bfd/ecofflink.c b/bfd/ecofflink.c
index 25b67fa..e48fcc8 100644
--- a/bfd/ecofflink.c
+++ b/bfd/ecofflink.c
@@ -1,6 +1,6 @@
 /* Routines to link ECOFF debugging information.
    Copyright 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
+   2004, 2005, 2006, 2007, 2008, 2009, 2012  Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support, <[email protected]>.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -33,28 +33,6 @@
 #include "libcoff.h"
 #include "libecoff.h"
 
-static bfd_boolean ecoff_add_bytes
-  PARAMS ((char **buf, char **bufend, size_t need));
-static struct bfd_hash_entry *string_hash_newfunc
-  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *,
-	   const char *));
-static void ecoff_align_debug
-  PARAMS ((bfd *abfd, struct ecoff_debug_info *debug,
-	   const struct ecoff_debug_swap *swap));
-static bfd_boolean ecoff_write_symhdr
-  PARAMS ((bfd *, struct ecoff_debug_info *, const struct ecoff_debug_swap *,
-	   file_ptr where));
-static int cmp_fdrtab_entry
-  PARAMS ((const PTR, const PTR));
-static bfd_boolean mk_fdrtab
-  PARAMS ((bfd *, struct ecoff_debug_info * const,
-	   const struct ecoff_debug_swap * const, struct ecoff_find_line *));
-static long fdrtab_lookup
-  PARAMS ((struct ecoff_find_line *, bfd_vma));
-static bfd_boolean lookup_line
-  PARAMS ((bfd *, struct ecoff_debug_info * const,
-	   const struct ecoff_debug_swap * const, struct ecoff_find_line *));
-
 /* Routines to swap auxiliary information in and out.  I am assuming
    that the auxiliary information format is always going to be target
    independent.  */
@@ -64,51 +42,52 @@
    info comes from the file header record (fh-fBigendian).  */
 
 void
-_bfd_ecoff_swap_tir_in (bigend, ext_copy, intern)
-     int bigend;
-     const struct tir_ext *ext_copy;
-     TIR *intern;
+_bfd_ecoff_swap_tir_in (int bigend, const struct tir_ext *ext_copy,
+			TIR *intern)
 {
   struct tir_ext ext[1];
 
   *ext = *ext_copy;		/* Make it reasonable to do in-place.  */
 
   /* now the fun stuff...  */
-  if (bigend) {
-    intern->fBitfield   = 0 != (ext->t_bits1[0] & TIR_BITS1_FBITFIELD_BIG);
-    intern->continued   = 0 != (ext->t_bits1[0] & TIR_BITS1_CONTINUED_BIG);
-    intern->bt          = (ext->t_bits1[0] & TIR_BITS1_BT_BIG)
-			>>		    TIR_BITS1_BT_SH_BIG;
-    intern->tq4         = (ext->t_tq45[0] & TIR_BITS_TQ4_BIG)
-			>>		    TIR_BITS_TQ4_SH_BIG;
-    intern->tq5         = (ext->t_tq45[0] & TIR_BITS_TQ5_BIG)
-			>>		    TIR_BITS_TQ5_SH_BIG;
-    intern->tq0         = (ext->t_tq01[0] & TIR_BITS_TQ0_BIG)
-			>>		    TIR_BITS_TQ0_SH_BIG;
-    intern->tq1         = (ext->t_tq01[0] & TIR_BITS_TQ1_BIG)
-			>>		    TIR_BITS_TQ1_SH_BIG;
-    intern->tq2         = (ext->t_tq23[0] & TIR_BITS_TQ2_BIG)
-			>>		    TIR_BITS_TQ2_SH_BIG;
-    intern->tq3         = (ext->t_tq23[0] & TIR_BITS_TQ3_BIG)
-			>>		    TIR_BITS_TQ3_SH_BIG;
-  } else {
-    intern->fBitfield   = 0 != (ext->t_bits1[0] & TIR_BITS1_FBITFIELD_LITTLE);
-    intern->continued   = 0 != (ext->t_bits1[0] & TIR_BITS1_CONTINUED_LITTLE);
-    intern->bt          = (ext->t_bits1[0] & TIR_BITS1_BT_LITTLE)
-			>>		    TIR_BITS1_BT_SH_LITTLE;
-    intern->tq4         = (ext->t_tq45[0] & TIR_BITS_TQ4_LITTLE)
-			>>		    TIR_BITS_TQ4_SH_LITTLE;
-    intern->tq5         = (ext->t_tq45[0] & TIR_BITS_TQ5_LITTLE)
-			>>		    TIR_BITS_TQ5_SH_LITTLE;
-    intern->tq0         = (ext->t_tq01[0] & TIR_BITS_TQ0_LITTLE)
-			>>		    TIR_BITS_TQ0_SH_LITTLE;
-    intern->tq1         = (ext->t_tq01[0] & TIR_BITS_TQ1_LITTLE)
-			>>		    TIR_BITS_TQ1_SH_LITTLE;
-    intern->tq2         = (ext->t_tq23[0] & TIR_BITS_TQ2_LITTLE)
-			>>		    TIR_BITS_TQ2_SH_LITTLE;
-    intern->tq3         = (ext->t_tq23[0] & TIR_BITS_TQ3_LITTLE)
-			>>		    TIR_BITS_TQ3_SH_LITTLE;
-  }
+  if (bigend)
+    {
+      intern->fBitfield   = 0 != (ext->t_bits1[0] & TIR_BITS1_FBITFIELD_BIG);
+      intern->continued   = 0 != (ext->t_bits1[0] & TIR_BITS1_CONTINUED_BIG);
+      intern->bt          = (ext->t_bits1[0] & TIR_BITS1_BT_BIG)
+                          >>                   TIR_BITS1_BT_SH_BIG;
+      intern->tq4         = (ext->t_tq45[0] & TIR_BITS_TQ4_BIG)
+			  >>		      TIR_BITS_TQ4_SH_BIG;
+      intern->tq5         = (ext->t_tq45[0] & TIR_BITS_TQ5_BIG)
+			  >>		      TIR_BITS_TQ5_SH_BIG;
+      intern->tq0         = (ext->t_tq01[0] & TIR_BITS_TQ0_BIG)
+			  >>		      TIR_BITS_TQ0_SH_BIG;
+      intern->tq1         = (ext->t_tq01[0] & TIR_BITS_TQ1_BIG)
+			  >>		      TIR_BITS_TQ1_SH_BIG;
+      intern->tq2         = (ext->t_tq23[0] & TIR_BITS_TQ2_BIG)
+			  >>		      TIR_BITS_TQ2_SH_BIG;
+      intern->tq3         = (ext->t_tq23[0] & TIR_BITS_TQ3_BIG)
+			  >>		      TIR_BITS_TQ3_SH_BIG;
+    }
+  else
+    {
+      intern->fBitfield   = 0 != (ext->t_bits1[0] & TIR_BITS1_FBITFIELD_LITTLE);
+      intern->continued   = 0 != (ext->t_bits1[0] & TIR_BITS1_CONTINUED_LITTLE);
+      intern->bt          = (ext->t_bits1[0] & TIR_BITS1_BT_LITTLE)
+			  >>		    TIR_BITS1_BT_SH_LITTLE;
+      intern->tq4         = (ext->t_tq45[0] & TIR_BITS_TQ4_LITTLE)
+			  >>		    TIR_BITS_TQ4_SH_LITTLE;
+      intern->tq5         = (ext->t_tq45[0] & TIR_BITS_TQ5_LITTLE)
+			  >>		    TIR_BITS_TQ5_SH_LITTLE;
+      intern->tq0         = (ext->t_tq01[0] & TIR_BITS_TQ0_LITTLE)
+			  >>		    TIR_BITS_TQ0_SH_LITTLE;
+      intern->tq1         = (ext->t_tq01[0] & TIR_BITS_TQ1_LITTLE)
+			  >>		    TIR_BITS_TQ1_SH_LITTLE;
+      intern->tq2         = (ext->t_tq23[0] & TIR_BITS_TQ2_LITTLE)
+			  >>		    TIR_BITS_TQ2_SH_LITTLE;
+      intern->tq3         = (ext->t_tq23[0] & TIR_BITS_TQ3_LITTLE)
+			  >>		    TIR_BITS_TQ3_SH_LITTLE;
+    }
 
 #ifdef TEST
   if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
@@ -121,51 +100,53 @@
    info comes from the file header record (fh-fBigendian).  */
 
 void
-_bfd_ecoff_swap_tir_out (bigend, intern_copy, ext)
-     int bigend;
-     const TIR *intern_copy;
-     struct tir_ext *ext;
+_bfd_ecoff_swap_tir_out (int bigend,
+			 const TIR *intern_copy,
+			 struct tir_ext *ext)
 {
   TIR intern[1];
 
   *intern = *intern_copy;	/* Make it reasonable to do in-place.  */
 
   /* now the fun stuff...  */
-  if (bigend) {
-    ext->t_bits1[0] = ((intern->fBitfield ? TIR_BITS1_FBITFIELD_BIG : 0)
+  if (bigend)
+    {
+      ext->t_bits1[0] = ((intern->fBitfield ? TIR_BITS1_FBITFIELD_BIG : 0)
 		       | (intern->continued ? TIR_BITS1_CONTINUED_BIG : 0)
 		       | ((intern->bt << TIR_BITS1_BT_SH_BIG)
 			  & TIR_BITS1_BT_BIG));
-    ext->t_tq45[0] = (((intern->tq4 << TIR_BITS_TQ4_SH_BIG)
+      ext->t_tq45[0] = (((intern->tq4 << TIR_BITS_TQ4_SH_BIG)
 		       & TIR_BITS_TQ4_BIG)
 		      | ((intern->tq5 << TIR_BITS_TQ5_SH_BIG)
 			 & TIR_BITS_TQ5_BIG));
-    ext->t_tq01[0] = (((intern->tq0 << TIR_BITS_TQ0_SH_BIG)
+      ext->t_tq01[0] = (((intern->tq0 << TIR_BITS_TQ0_SH_BIG)
 		       & TIR_BITS_TQ0_BIG)
 		      | ((intern->tq1 << TIR_BITS_TQ1_SH_BIG)
 			 & TIR_BITS_TQ1_BIG));
-    ext->t_tq23[0] = (((intern->tq2 << TIR_BITS_TQ2_SH_BIG)
+      ext->t_tq23[0] = (((intern->tq2 << TIR_BITS_TQ2_SH_BIG)
 		       & TIR_BITS_TQ2_BIG)
 		      | ((intern->tq3 << TIR_BITS_TQ3_SH_BIG)
 			 & TIR_BITS_TQ3_BIG));
-  } else {
-    ext->t_bits1[0] = ((intern->fBitfield ? TIR_BITS1_FBITFIELD_LITTLE : 0)
+    }
+  else
+    {
+      ext->t_bits1[0] = ((intern->fBitfield ? TIR_BITS1_FBITFIELD_LITTLE : 0)
 		       | (intern->continued ? TIR_BITS1_CONTINUED_LITTLE : 0)
 		       | ((intern->bt << TIR_BITS1_BT_SH_LITTLE)
 			  & TIR_BITS1_BT_LITTLE));
-    ext->t_tq45[0] = (((intern->tq4 << TIR_BITS_TQ4_SH_LITTLE)
+      ext->t_tq45[0] = (((intern->tq4 << TIR_BITS_TQ4_SH_LITTLE)
 		       & TIR_BITS_TQ4_LITTLE)
 		      | ((intern->tq5 << TIR_BITS_TQ5_SH_LITTLE)
 			 & TIR_BITS_TQ5_LITTLE));
-    ext->t_tq01[0] = (((intern->tq0 << TIR_BITS_TQ0_SH_LITTLE)
+      ext->t_tq01[0] = (((intern->tq0 << TIR_BITS_TQ0_SH_LITTLE)
 		       & TIR_BITS_TQ0_LITTLE)
 		      | ((intern->tq1 << TIR_BITS_TQ1_SH_LITTLE)
 			 & TIR_BITS_TQ1_LITTLE));
-    ext->t_tq23[0] = (((intern->tq2 << TIR_BITS_TQ2_SH_LITTLE)
+      ext->t_tq23[0] = (((intern->tq2 << TIR_BITS_TQ2_SH_LITTLE)
 		       & TIR_BITS_TQ2_LITTLE)
 		      | ((intern->tq3 << TIR_BITS_TQ3_SH_LITTLE)
 			 & TIR_BITS_TQ3_LITTLE));
-  }
+    }
 
 #ifdef TEST
   if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
@@ -177,34 +158,36 @@
    big-endian or little-endian format.*/
 
 void
-_bfd_ecoff_swap_rndx_in (bigend, ext_copy, intern)
-     int bigend;
-     const struct rndx_ext *ext_copy;
-     RNDXR *intern;
+_bfd_ecoff_swap_rndx_in (int bigend,
+			 const struct rndx_ext *ext_copy,
+			 RNDXR *intern)
 {
   struct rndx_ext ext[1];
 
   *ext = *ext_copy;		/* Make it reasonable to do in-place.  */
 
   /* now the fun stuff...  */
-  if (bigend) {
-    intern->rfd   = (ext->r_bits[0] << RNDX_BITS0_RFD_SH_LEFT_BIG)
+  if (bigend)
+    {
+      intern->rfd   = (ext->r_bits[0] << RNDX_BITS0_RFD_SH_LEFT_BIG)
 		  | ((ext->r_bits[1] & RNDX_BITS1_RFD_BIG)
 		    		    >> RNDX_BITS1_RFD_SH_BIG);
-    intern->index = ((ext->r_bits[1] & RNDX_BITS1_INDEX_BIG)
+      intern->index = ((ext->r_bits[1] & RNDX_BITS1_INDEX_BIG)
 		    		    << RNDX_BITS1_INDEX_SH_LEFT_BIG)
 		  | (ext->r_bits[2] << RNDX_BITS2_INDEX_SH_LEFT_BIG)
 		  | (ext->r_bits[3] << RNDX_BITS3_INDEX_SH_LEFT_BIG);
-  } else {
-    intern->rfd   = (ext->r_bits[0] << RNDX_BITS0_RFD_SH_LEFT_LITTLE)
+    }
+  else
+    {
+      intern->rfd   = (ext->r_bits[0] << RNDX_BITS0_RFD_SH_LEFT_LITTLE)
 		  | ((ext->r_bits[1] & RNDX_BITS1_RFD_LITTLE)
 		    		    << RNDX_BITS1_RFD_SH_LEFT_LITTLE);
-    intern->index = ((ext->r_bits[1] & RNDX_BITS1_INDEX_LITTLE)
+      intern->index = ((ext->r_bits[1] & RNDX_BITS1_INDEX_LITTLE)
 		    		    >> RNDX_BITS1_INDEX_SH_LITTLE)
 		  | (ext->r_bits[2] << RNDX_BITS2_INDEX_SH_LEFT_LITTLE)
 		  | ((unsigned int) ext->r_bits[3]
 		     << RNDX_BITS3_INDEX_SH_LEFT_LITTLE);
-  }
+    }
 
 #ifdef TEST
   if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
@@ -216,33 +199,35 @@
    big-endian or little-endian format.*/
 
 void
-_bfd_ecoff_swap_rndx_out (bigend, intern_copy, ext)
-     int bigend;
-     const RNDXR *intern_copy;
-     struct rndx_ext *ext;
+_bfd_ecoff_swap_rndx_out (int bigend,
+			  const RNDXR *intern_copy,
+			  struct rndx_ext *ext)
 {
   RNDXR intern[1];
 
   *intern = *intern_copy;	/* Make it reasonable to do in-place.  */
 
   /* now the fun stuff...  */
-  if (bigend) {
-    ext->r_bits[0] = intern->rfd >> RNDX_BITS0_RFD_SH_LEFT_BIG;
-    ext->r_bits[1] = (((intern->rfd << RNDX_BITS1_RFD_SH_BIG)
+  if (bigend)
+    {
+      ext->r_bits[0] = intern->rfd >> RNDX_BITS0_RFD_SH_LEFT_BIG;
+      ext->r_bits[1] = (((intern->rfd << RNDX_BITS1_RFD_SH_BIG)
 		       & RNDX_BITS1_RFD_BIG)
 		      | ((intern->index >> RNDX_BITS1_INDEX_SH_LEFT_BIG)
 			 & RNDX_BITS1_INDEX_BIG));
-    ext->r_bits[2] = intern->index >> RNDX_BITS2_INDEX_SH_LEFT_BIG;
-    ext->r_bits[3] = intern->index >> RNDX_BITS3_INDEX_SH_LEFT_BIG;
-  } else {
-    ext->r_bits[0] = intern->rfd >> RNDX_BITS0_RFD_SH_LEFT_LITTLE;
-    ext->r_bits[1] = (((intern->rfd >> RNDX_BITS1_RFD_SH_LEFT_LITTLE)
+      ext->r_bits[2] = intern->index >> RNDX_BITS2_INDEX_SH_LEFT_BIG;
+      ext->r_bits[3] = intern->index >> RNDX_BITS3_INDEX_SH_LEFT_BIG;
+    }
+  else
+    {
+      ext->r_bits[0] = intern->rfd >> RNDX_BITS0_RFD_SH_LEFT_LITTLE;
+      ext->r_bits[1] = (((intern->rfd >> RNDX_BITS1_RFD_SH_LEFT_LITTLE)
 		       & RNDX_BITS1_RFD_LITTLE)
 		      | ((intern->index << RNDX_BITS1_INDEX_SH_LITTLE)
 			 & RNDX_BITS1_INDEX_LITTLE));
-    ext->r_bits[2] = intern->index >> RNDX_BITS2_INDEX_SH_LEFT_LITTLE;
-    ext->r_bits[3] = intern->index >> RNDX_BITS3_INDEX_SH_LEFT_LITTLE;
-  }
+      ext->r_bits[2] = intern->index >> RNDX_BITS2_INDEX_SH_LEFT_LITTLE;
+      ext->r_bits[3] = intern->index >> RNDX_BITS3_INDEX_SH_LEFT_LITTLE;
+    }
 
 #ifdef TEST
   if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
@@ -256,10 +241,7 @@
 /* Add bytes to a buffer.  Return success.  */
 
 static bfd_boolean
-ecoff_add_bytes (buf, bufend, need)
-     char **buf;
-     char **bufend;
-     size_t need;
+ecoff_add_bytes (char **buf, char **bufend, size_t need)
 {
   size_t have;
   size_t want;
@@ -303,10 +285,9 @@
 /* Routine to create an entry in a string hash table.  */
 
 static struct bfd_hash_entry *
-string_hash_newfunc (entry, table, string)
-     struct bfd_hash_entry *entry;
-     struct bfd_hash_table *table;
-     const char *string;
+string_hash_newfunc (struct bfd_hash_entry *entry,
+		     struct bfd_hash_table *table,
+		     const char *string)
 {
   struct string_hash_entry *ret = (struct string_hash_entry *) entry;
 
@@ -360,7 +341,7 @@
 	  file_ptr offset;
 	} file;
       /* The data to be written out.  */
-      PTR memory;
+      void * memory;
     } u;
 };
 
@@ -402,18 +383,13 @@
 
 /* Add a file entry to a shuffle list.  */
 
-static bfd_boolean add_file_shuffle
-  PARAMS ((struct accumulate *, struct shuffle **, struct shuffle **,
-	   bfd *, file_ptr, unsigned long));
-
 static bfd_boolean
-add_file_shuffle (ainfo, head, tail, input_bfd, offset, size)
-     struct accumulate *ainfo;
-     struct shuffle **head;
-     struct shuffle **tail;
-     bfd *input_bfd;
-     file_ptr offset;
-     unsigned long size;
+add_file_shuffle (struct accumulate *ainfo,
+		  struct shuffle **head,
+		  struct shuffle **tail,
+		  bfd *input_bfd,
+		  file_ptr offset,
+		  unsigned long size)
 {
   struct shuffle *n;
 
@@ -453,17 +429,12 @@
 
 /* Add a memory entry to a shuffle list.  */
 
-static bfd_boolean add_memory_shuffle
-  PARAMS ((struct accumulate *, struct shuffle **head, struct shuffle **tail,
-	   bfd_byte *data, unsigned long size));
-
 static bfd_boolean
-add_memory_shuffle (ainfo, head, tail, data, size)
-     struct accumulate *ainfo;
-     struct shuffle **head;
-     struct shuffle **tail;
-     bfd_byte *data;
-     unsigned long size;
+add_memory_shuffle (struct accumulate *ainfo,
+		    struct shuffle **head,
+		    struct shuffle **tail,
+		    bfd_byte *data,
+		    unsigned long size)
 {
   struct shuffle *n;
 
@@ -477,7 +448,7 @@
   n->next = NULL;
   n->size = size;
   n->filep = FALSE;
-  n->u.memory = (PTR) data;
+  n->u.memory = data;
   if (*head == (struct shuffle *) NULL)
     *head = n;
   if (*tail != (struct shuffle *) NULL)
@@ -489,12 +460,11 @@
 /* Initialize the FDR hash table.  This returns a handle which is then
    passed in to bfd_ecoff_debug_accumulate, et. al.  */
 
-PTR
-bfd_ecoff_debug_init (output_bfd, output_debug, output_swap, info)
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     struct ecoff_debug_info *output_debug;
-     const struct ecoff_debug_swap *output_swap ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info;
+void *
+bfd_ecoff_debug_init (bfd *output_bfd ATTRIBUTE_UNUSED,
+		      struct ecoff_debug_info *output_debug,
+		      const struct ecoff_debug_swap *output_swap ATTRIBUTE_UNUSED,
+		      struct bfd_link_info *info)
 {
   struct accumulate *ainfo;
   bfd_size_type amt = sizeof (struct accumulate);
@@ -544,18 +514,17 @@
       return NULL;
     }
 
-  return (PTR) ainfo;
+  return ainfo;
 }
 
 /* Free the accumulated debugging information.  */
 
 void
-bfd_ecoff_debug_free (handle, output_bfd, output_debug, output_swap, info)
-     PTR handle;
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     struct ecoff_debug_info *output_debug ATTRIBUTE_UNUSED;
-     const struct ecoff_debug_swap *output_swap ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info;
+bfd_ecoff_debug_free (void * handle,
+		      bfd *output_bfd ATTRIBUTE_UNUSED,
+		      struct ecoff_debug_info *output_debug ATTRIBUTE_UNUSED,
+		      const struct ecoff_debug_swap *output_swap ATTRIBUTE_UNUSED,
+		      struct bfd_link_info *info)
 {
   struct accumulate *ainfo = (struct accumulate *) handle;
 
@@ -578,28 +547,25 @@
    bfd_ecoff_debug_init.  */
 
 bfd_boolean
-bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap,
-			    input_bfd, input_debug, input_swap,
-			    info)
-     PTR handle;
-     bfd *output_bfd;
-     struct ecoff_debug_info *output_debug;
-     const struct ecoff_debug_swap *output_swap;
-     bfd *input_bfd;
-     struct ecoff_debug_info *input_debug;
-     const struct ecoff_debug_swap *input_swap;
-     struct bfd_link_info *info;
+bfd_ecoff_debug_accumulate (void * handle,
+			    bfd *output_bfd,
+			    struct ecoff_debug_info *output_debug,
+			    const struct ecoff_debug_swap *output_swap,
+			    bfd *input_bfd,
+			    struct ecoff_debug_info *input_debug,
+			    const struct ecoff_debug_swap *input_swap,
+			    struct bfd_link_info *info)
 {
   struct accumulate *ainfo = (struct accumulate *) handle;
-  void (* const swap_sym_in) PARAMS ((bfd *, PTR, SYMR *))
+  void (* const swap_sym_in) (bfd *, void *, SYMR *)
     = input_swap->swap_sym_in;
-  void (* const swap_rfd_in) PARAMS ((bfd *, PTR, RFDT *))
+  void (* const swap_rfd_in) (bfd *, void *, RFDT *)
     = input_swap->swap_rfd_in;
-  void (* const swap_sym_out) PARAMS ((bfd *, const SYMR *, PTR))
+  void (* const swap_sym_out) (bfd *, const SYMR *, void *)
     = output_swap->swap_sym_out;
-  void (* const swap_fdr_out) PARAMS ((bfd *, const FDR *, PTR))
+  void (* const swap_fdr_out) (bfd *, const FDR *, void *)
     = output_swap->swap_fdr_out;
-  void (* const swap_rfd_out) PARAMS ((bfd *, const RFDT *, PTR))
+  void (* const swap_rfd_out) (bfd *, const RFDT *, void *)
     = output_swap->swap_rfd_out;
   bfd_size_type external_pdr_size = output_swap->external_pdr_size;
   bfd_size_type external_sym_size = output_swap->external_sym_size;
@@ -627,7 +593,7 @@
 
   /* Use section_adjust to hold the value to add to a symbol in a
      particular section.  */
-  memset ((PTR) section_adjust, 0, sizeof section_adjust);
+  memset (section_adjust, 0, sizeof section_adjust);
 
 #define SET(name, indx) \
   sec = bfd_get_section_by_name (input_bfd, name); \
@@ -697,7 +663,7 @@
       if (input_debug->fdr != (FDR *) NULL)
 	fdr = *(FDR *) fdr_ptr;
       else
-	(*input_swap->swap_fdr_in) (input_bfd, (PTR) fdr_ptr, &fdr);
+	(*input_swap->swap_fdr_in) (input_bfd, fdr_ptr, &fdr);
 
       /* See if this FDR can be merged with an existing one.  */
       if (fdr.cbLine == 0 && fdr.rss != -1 && fdr.fMerge)
@@ -729,8 +695,7 @@
 	  if (fh->val != -1)
 	    {
 	      input_debug->ifdmap[i] = fh->val;
-	      (*swap_rfd_out) (output_bfd, input_debug->ifdmap + i,
-			       (PTR) rfd_out);
+	      (*swap_rfd_out) (output_bfd, input_debug->ifdmap + i, rfd_out);
 
 	      /* Don't copy this FDR.  */
 	      continue;
@@ -740,7 +705,7 @@
 	}
 
       input_debug->ifdmap[i] = output_symhdr->ifdMax + copied;
-      (*swap_rfd_out) (output_bfd, input_debug->ifdmap + i, (PTR) rfd_out);
+      (*swap_rfd_out) (output_bfd, input_debug->ifdmap + i, rfd_out);
       ++copied;
     }
 
@@ -758,10 +723,10 @@
     {
       RFDT rfd;
 
-      (*swap_rfd_in) (input_bfd, (PTR) rfd_in, &rfd);
+      (*swap_rfd_in) (input_bfd, rfd_in, &rfd);
       BFD_ASSERT (rfd >= 0 && rfd < input_symhdr->ifdMax);
       rfd = input_debug->ifdmap[rfd];
-      (*swap_rfd_out) (output_bfd, &rfd, (PTR) rfd_out);
+      (*swap_rfd_out) (output_bfd, &rfd, rfd_out);
       rfd_out += external_rfd_size;
     }
 
@@ -798,7 +763,7 @@
       if (input_debug->fdr != (FDR *) NULL)
 	fdr = *(FDR *) fdr_ptr;
       else
-	(*input_swap->swap_fdr_in) (input_bfd, (PTR) fdr_ptr, &fdr);
+	(*input_swap->swap_fdr_in) (input_bfd, fdr_ptr, &fdr);
 
       /* FIXME: It is conceivable that this FDR points to the .init or
 	 .fini section, in which case this will not do the right
@@ -825,7 +790,7 @@
 	{
 	  SYMR internal_sym;
 
-	  (*swap_sym_in) (input_bfd, (PTR) lraw_src, &internal_sym);
+	  (*swap_sym_in) (input_bfd, lraw_src, &internal_sym);
 
 	  BFD_ASSERT (internal_sym.sc != scCommon
 		      && internal_sym.sc != scSCommon);
@@ -1007,8 +972,8 @@
 	    {
 	      PDR pdr;
 
-	      (*input_swap->swap_pdr_in) (input_bfd, (PTR) in, &pdr);
-	      (*output_swap->swap_pdr_out) (output_bfd, &pdr, (PTR) out);
+	      (*input_swap->swap_pdr_in) (input_bfd, in, &pdr);
+	      (*output_swap->swap_pdr_out) (output_bfd, &pdr, out);
 	    }
 
 	  /* Swap over the optimization information.  */
@@ -1031,8 +996,8 @@
 	    {
 	      OPTR opt;
 
-	      (*input_swap->swap_opt_in) (input_bfd, (PTR) in, &opt);
-	      (*output_swap->swap_opt_out) (output_bfd, &opt, (PTR) out);
+	      (*input_swap->swap_opt_in) (input_bfd, in, &opt);
+	      (*output_swap->swap_opt_out) (output_bfd, &opt, out);
 	    }
 	}
 
@@ -1064,17 +1029,12 @@
 /* Add a string to the debugging information we are accumulating.
    Return the offset from the fdr string base.  */
 
-static long ecoff_add_string
-  PARAMS ((struct accumulate *, struct bfd_link_info *,
-	   struct ecoff_debug_info *, FDR *fdr, const char *string));
-
 static long
-ecoff_add_string (ainfo, info, debug, fdr, string)
-     struct accumulate *ainfo;
-     struct bfd_link_info *info;
-     struct ecoff_debug_info *debug;
-     FDR *fdr;
-     const char *string;
+ecoff_add_string (struct accumulate *ainfo,
+		  struct bfd_link_info *info,
+		  struct ecoff_debug_info *debug,
+		  FDR *fdr,
+		  const char *string)
 {
   HDRR *symhdr;
   size_t len;
@@ -1118,17 +1078,15 @@
 /* Add debugging information from a non-ECOFF file.  */
 
 bfd_boolean
-bfd_ecoff_debug_accumulate_other (handle, output_bfd, output_debug,
-				  output_swap, input_bfd, info)
-     PTR handle;
-     bfd *output_bfd;
-     struct ecoff_debug_info *output_debug;
-     const struct ecoff_debug_swap *output_swap;
-     bfd *input_bfd;
-     struct bfd_link_info *info;
+bfd_ecoff_debug_accumulate_other (void * handle,
+				  bfd *output_bfd,
+				  struct ecoff_debug_info *output_debug,
+				  const struct ecoff_debug_swap *output_swap,
+				  bfd *input_bfd,
+				  struct bfd_link_info *info)
 {
   struct accumulate *ainfo = (struct accumulate *) handle;
-  void (* const swap_sym_out) PARAMS ((bfd *, const SYMR *, PTR))
+  void (* const swap_sym_out) (bfd *, const SYMR *, void *)
     = output_swap->swap_sym_out;
   HDRR *output_symhdr = &output_debug->symbolic_header;
   FDR fdr;
@@ -1138,9 +1096,9 @@
   asymbol **sym_end;
   long symsize;
   long symcount;
-  PTR external_fdr;
+  void * external_fdr;
 
-  memset ((PTR) &fdr, 0, sizeof fdr);
+  memset (&fdr, 0, sizeof fdr);
 
   sec = bfd_get_section_by_name (input_bfd, ".text");
   if (sec != NULL)
@@ -1177,11 +1135,11 @@
   for (sym_ptr = symbols; sym_ptr != sym_end; sym_ptr++)
     {
       SYMR internal_sym;
-      PTR external_sym;
+      void * external_sym;
 
       if (((*sym_ptr)->flags & BSF_EXPORT) != 0)
 	continue;
-      memset ((PTR) &internal_sym, 0, sizeof internal_sym);
+      memset (&internal_sym, 0, sizeof internal_sym);
       internal_sym.iss = ecoff_add_string (ainfo, info, output_debug, &fdr,
 					   (*sym_ptr)->name);
 
@@ -1198,8 +1156,8 @@
       internal_sym.sc = scUndefined;
       internal_sym.index = indexNil;
 
-      external_sym = (PTR) objalloc_alloc (ainfo->memory,
-					   output_swap->external_sym_size);
+      external_sym = objalloc_alloc (ainfo->memory,
+				     output_swap->external_sym_size);
       if (!external_sym)
 	{
 	  bfd_set_error (bfd_error_no_memory);
@@ -1213,14 +1171,14 @@
       ++output_symhdr->isymMax;
     }
 
-  bfd_release (output_bfd, (PTR) symbols);
+  bfd_release (output_bfd, symbols);
 
   /* Leave everything else in the FDR zeroed out.  This will cause
      the lang field to be langC.  The fBigendian field will
      indicate little endian format, but it doesn't matter because
      it only applies to aux fields and there are none.  */
-  external_fdr = (PTR) objalloc_alloc (ainfo->memory,
-				       output_swap->external_fdr_size);
+  external_fdr = objalloc_alloc (ainfo->memory,
+				 output_swap->external_fdr_size);
   if (!external_fdr)
     {
       bfd_set_error (bfd_error_no_memory);
@@ -1242,14 +1200,12 @@
    this interface, so that must be changed to do something else.  */
 
 bfd_boolean
-bfd_ecoff_debug_externals (abfd, debug, swap, relocatable, get_extr,
-			   set_index)
-     bfd *abfd;
-     struct ecoff_debug_info *debug;
-     const struct ecoff_debug_swap *swap;
-     bfd_boolean relocatable;
-     bfd_boolean (*get_extr) PARAMS ((asymbol *, EXTR *));
-     void (*set_index) PARAMS ((asymbol *, bfd_size_type));
+bfd_ecoff_debug_externals (bfd *abfd,
+			   struct ecoff_debug_info *debug,
+			   const struct ecoff_debug_swap *swap,
+			   bfd_boolean relocatable,
+			   bfd_boolean (*get_extr) (asymbol *, EXTR *),
+			   void (*set_index) (asymbol *, bfd_size_type))
 {
   HDRR * const symhdr = &debug->symbolic_header;
   asymbol **sym_ptr_ptr;
@@ -1311,15 +1267,14 @@
 /* Add a single external symbol to the debugging information.  */
 
 bfd_boolean
-bfd_ecoff_debug_one_external (abfd, debug, swap, name, esym)
-     bfd *abfd;
-     struct ecoff_debug_info *debug;
-     const struct ecoff_debug_swap *swap;
-     const char *name;
-     EXTR *esym;
+bfd_ecoff_debug_one_external (bfd *abfd,
+			      struct ecoff_debug_info *debug,
+			      const struct ecoff_debug_swap *swap,
+			      const char *name,
+			      EXTR *esym)
 {
   const bfd_size_type external_ext_size = swap->external_ext_size;
-  void (* const swap_ext_out) PARAMS ((bfd *, const EXTR *, PTR))
+  void (* const swap_ext_out) (bfd *, const EXTR *, void *)
     = swap->swap_ext_out;
   HDRR * const symhdr = &debug->symbolic_header;
   size_t namelen;
@@ -1365,10 +1320,9 @@
 /* Align the ECOFF debugging information.  */
 
 static void
-ecoff_align_debug (abfd, debug, swap)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     struct ecoff_debug_info *debug;
-     const struct ecoff_debug_swap *swap;
+ecoff_align_debug (bfd *abfd ATTRIBUTE_UNUSED,
+		   struct ecoff_debug_info *debug,
+		   const struct ecoff_debug_swap *swap)
 {
   HDRR * const symhdr = &debug->symbolic_header;
   bfd_size_type debug_align, aux_align, rfd_align;
@@ -1383,7 +1337,7 @@
   if (add != debug_align)
     {
       if (debug->line != (unsigned char *) NULL)
-	memset ((PTR) (debug->line + symhdr->cbLine), 0, add);
+	memset ((debug->line + symhdr->cbLine), 0, add);
       symhdr->cbLine += add;
     }
 
@@ -1391,7 +1345,7 @@
   if (add != debug_align)
     {
       if (debug->ss != (char *) NULL)
-	memset ((PTR) (debug->ss + symhdr->issMax), 0, add);
+	memset ((debug->ss + symhdr->issMax), 0, add);
       symhdr->issMax += add;
     }
 
@@ -1399,7 +1353,7 @@
   if (add != debug_align)
     {
       if (debug->ssext != (char *) NULL)
-	memset ((PTR) (debug->ssext + symhdr->issExtMax), 0, add);
+	memset ((debug->ssext + symhdr->issExtMax), 0, add);
       symhdr->issExtMax += add;
     }
 
@@ -1407,7 +1361,7 @@
   if (add != aux_align)
     {
       if (debug->external_aux != (union aux_ext *) NULL)
-	memset ((PTR) (debug->external_aux + symhdr->iauxMax), 0,
+	memset ((debug->external_aux + symhdr->iauxMax), 0,
 		add * sizeof (union aux_ext));
       symhdr->iauxMax += add;
     }
@@ -1415,9 +1369,9 @@
   add = rfd_align - (symhdr->crfd & (rfd_align - 1));
   if (add != rfd_align)
     {
-      if (debug->external_rfd != (PTR) NULL)
-	memset ((PTR) ((char *) debug->external_rfd
-		       + symhdr->crfd * swap->external_rfd_size),
+      if (debug->external_rfd != NULL)
+	memset (((char *) debug->external_rfd
+		 + symhdr->crfd * swap->external_rfd_size),
 		0, (size_t) (add * swap->external_rfd_size));
       symhdr->crfd += add;
     }
@@ -1426,10 +1380,9 @@
 /* Return the size required by the ECOFF debugging information.  */
 
 bfd_size_type
-bfd_ecoff_debug_size (abfd, debug, swap)
-     bfd *abfd;
-     struct ecoff_debug_info *debug;
-     const struct ecoff_debug_swap *swap;
+bfd_ecoff_debug_size (bfd *abfd,
+		      struct ecoff_debug_info *debug,
+		      const struct ecoff_debug_swap *swap)
 {
   bfd_size_type tot;
 
@@ -1461,11 +1414,10 @@
    correctly.  */
 
 static bfd_boolean
-ecoff_write_symhdr (abfd, debug, swap, where)
-     bfd *abfd;
-     struct ecoff_debug_info *debug;
-     const struct ecoff_debug_swap *swap;
-     file_ptr where;
+ecoff_write_symhdr (bfd *abfd,
+		    struct ecoff_debug_info *debug,
+		    const struct ecoff_debug_swap *swap,
+		    file_ptr where)
 {
   HDRR * const symhdr = &debug->symbolic_header;
   char *buff = NULL;
@@ -1528,11 +1480,10 @@
    symbolic header.  */
 
 bfd_boolean
-bfd_ecoff_write_debug (abfd, debug, swap, where)
-     bfd *abfd;
-     struct ecoff_debug_info *debug;
-     const struct ecoff_debug_swap *swap;
-     file_ptr where;
+bfd_ecoff_write_debug (bfd *abfd,
+		       struct ecoff_debug_info *debug,
+		       const struct ecoff_debug_swap *swap,
+		       file_ptr where)
 {
   HDRR * const symhdr = &debug->symbolic_header;
 
@@ -1542,7 +1493,7 @@
 #define WRITE(ptr, count, size, offset) \
   BFD_ASSERT (symhdr->offset == 0 \
 	      || (bfd_vma) bfd_tell (abfd) == symhdr->offset); \
-  if (bfd_bwrite ((PTR) debug->ptr, (bfd_size_type) size * symhdr->count, abfd)\
+  if (bfd_bwrite (debug->ptr, (bfd_size_type) size * symhdr->count, abfd)\
       != size * symhdr->count) \
     return FALSE;
 
@@ -1565,18 +1516,14 @@
 
 /* Write out a shuffle list.  */
 
-static bfd_boolean ecoff_write_shuffle
-  PARAMS ((bfd *, const struct ecoff_debug_swap *, struct shuffle *,
-	   PTR space));
 
 static bfd_boolean
-ecoff_write_shuffle (abfd, swap, shuffle, space)
-     bfd *abfd;
-     const struct ecoff_debug_swap *swap;
-     struct shuffle *shuffle;
-     PTR space;
+ecoff_write_shuffle (bfd *abfd,
+		     const struct ecoff_debug_swap *swap,
+		     struct shuffle *shuffle,
+		     void * space)
 {
-  register struct shuffle *l;
+  struct shuffle *l;
   unsigned long total;
 
   total = 0;
@@ -1609,7 +1556,7 @@
       if (s == NULL && i != 0)
 	return FALSE;
 
-      if (bfd_bwrite ((PTR) s, (bfd_size_type) i, abfd) != i)
+      if (bfd_bwrite (s, (bfd_size_type) i, abfd) != i)
 	{
 	  free (s);
 	  return FALSE;
@@ -1624,23 +1571,22 @@
    information.  */
 
 bfd_boolean
-bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where)
-     PTR handle;
-     bfd *abfd;
-     struct ecoff_debug_info *debug;
-     const struct ecoff_debug_swap *swap;
-     struct bfd_link_info *info;
-     file_ptr where;
+bfd_ecoff_write_accumulated_debug (void * handle,
+				   bfd *abfd,
+				   struct ecoff_debug_info *debug,
+				   const struct ecoff_debug_swap *swap,
+				   struct bfd_link_info *info,
+				   file_ptr where)
 {
   struct accumulate *ainfo = (struct accumulate *) handle;
-  PTR space = NULL;
+  void * space = NULL;
   bfd_size_type amt;
 
   if (! ecoff_write_symhdr (abfd, debug, swap, where))
     goto error_return;
 
   amt = ainfo->largest_file_shuffle;
-  space = (PTR) bfd_malloc (amt);
+  space = bfd_malloc (amt);
   if (space == NULL && ainfo->largest_file_shuffle != 0)
     goto error_return;
 
@@ -1667,7 +1613,7 @@
 
       BFD_ASSERT (ainfo->ss == (struct shuffle *) NULL);
       null = 0;
-      if (bfd_bwrite ((PTR) &null, (bfd_size_type) 1, abfd) != 1)
+      if (bfd_bwrite (&null, (bfd_size_type) 1, abfd) != 1)
 	goto error_return;
       total = 1;
       BFD_ASSERT (ainfo->ss_hash == NULL || ainfo->ss_hash->val == 1);
@@ -1679,7 +1625,7 @@
 
 	  len = strlen (sh->root.string);
 	  amt = len + 1;
-	  if (bfd_bwrite ((PTR) sh->root.string, amt, abfd) != amt)
+	  if (bfd_bwrite (sh->root.string, amt, abfd) != amt)
 	    goto error_return;
 	  total += len + 1;
 	}
@@ -1694,7 +1640,7 @@
 	  if (s == NULL && i != 0)
 	    goto error_return;
 
-	  if (bfd_bwrite ((PTR) s, (bfd_size_type) i, abfd) != i)
+	  if (bfd_bwrite (s, (bfd_size_type) i, abfd) != i)
 	    {
 	      free (s);
 	      goto error_return;
@@ -1719,7 +1665,7 @@
       if (s == NULL && i != 0)
 	goto error_return;
 
-      if (bfd_bwrite ((PTR) s, (bfd_size_type) i, abfd) != i)
+      if (bfd_bwrite (s, (bfd_size_type) i, abfd) != i)
 	{
 	  free (s);
 	  goto error_return;
@@ -1755,9 +1701,7 @@
 /* Compare FDR entries.  This is called via qsort.  */
 
 static int
-cmp_fdrtab_entry (leftp, rightp)
-     const PTR leftp;
-     const PTR rightp;
+cmp_fdrtab_entry (const void * leftp, const void * rightp)
 {
   const struct ecoff_fdrtab_entry *lp =
     (const struct ecoff_fdrtab_entry *) leftp;
@@ -1778,11 +1722,10 @@
    search.  */
 
 static bfd_boolean
-mk_fdrtab (abfd, debug_info, debug_swap, line_info)
-     bfd *abfd;
-     struct ecoff_debug_info * const debug_info;
-     const struct ecoff_debug_swap * const debug_swap;
-     struct ecoff_find_line *line_info;
+mk_fdrtab (bfd *abfd,
+	   struct ecoff_debug_info * const debug_info,
+	   const struct ecoff_debug_swap * const debug_swap,
+	   struct ecoff_find_line *line_info)
 {
   struct ecoff_fdrtab_entry *tab;
   FDR *fdr_ptr;
@@ -1845,7 +1788,7 @@
 	     'lookup_line'.  */
 	  /* The address of the first PDR is the offset of that
 	     procedure relative to the beginning of file FDR.  */
-	  tab->base_addr = fdr_ptr->adr; 
+	  tab->base_addr = fdr_ptr->adr;
 	}
       else
 	{
@@ -1861,7 +1804,7 @@
      The table is mostly sorted already, but there are cases (e.g.,
      static functions in include files), where this does not hold.
      Use "odump -PFv" to verify...  */
-  qsort ((PTR) line_info->fdrtab, (size_t) len,
+  qsort (line_info->fdrtab, (size_t) len,
 	 sizeof (struct ecoff_fdrtab_entry), cmp_fdrtab_entry);
 
   return TRUE;
@@ -1870,9 +1813,7 @@
 /* Return index of first FDR that covers to OFFSET.  */
 
 static long
-fdrtab_lookup (line_info, offset)
-     struct ecoff_find_line *line_info;
-     bfd_vma offset;
+fdrtab_lookup (struct ecoff_find_line *line_info, bfd_vma offset)
 {
   long low, high, len;
   long mid = -1;
@@ -1920,11 +1861,10 @@
    LINE_INFO->cache.  */
 
 static bfd_boolean
-lookup_line (abfd, debug_info, debug_swap, line_info)
-     bfd *abfd;
-     struct ecoff_debug_info * const debug_info;
-     const struct ecoff_debug_swap * const debug_swap;
-     struct ecoff_find_line *line_info;
+lookup_line (bfd *abfd,
+	     struct ecoff_debug_info * const debug_info,
+	     const struct ecoff_debug_swap * const debug_swap,
+	     struct ecoff_find_line *line_info)
 {
   struct ecoff_fdrtab_entry *tab;
   bfd_vma offset;
@@ -1947,7 +1887,7 @@
   i = fdrtab_lookup (line_info, offset);
   if (i < 0)
     return FALSE;		/* no FDR, no fun...  */
-  
+
   /* eraxxon: 'fdrtab_lookup' doesn't give what we want, at least for Compaq's
      C++ compiler 6.2.  Consider three FDRs with starting addresses of x, y,
      and z, respectively, such that x < y < z.  Assume further that
@@ -2112,7 +2052,7 @@
 	 read stabs FDRs as ECOFF ones.  However, I don't think this will
 	 harm anything.  */
       i = 0;
-      
+
       /* Search FDR list starting at tab[i] for the PDR that best matches
          OFFSET.  Normally, the FDR list is only one entry long.  */
       best_fdr = NULL;
@@ -2130,7 +2070,7 @@
 	  pdr_ptr = ((char *) debug_info->external_pdr
 		     + fdr_ptr->ipdFirst * external_pdr_size);
 	  pdr_end = pdr_ptr + fdr_ptr->cpd * external_pdr_size;
-	  (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr);
+	  (*debug_swap->swap_pdr_in) (abfd, pdr_ptr, &pdr);
 	  /* Find PDR that is closest to OFFSET.  If pdr.prof is set,
 	     the procedure entry-point *may* be 0x10 below pdr.adr.  We
 	     simply pretend that pdr.prof *implies* a lower entry-point.
@@ -2139,7 +2079,7 @@
 	  for (pdr_hold = NULL;
 	       pdr_ptr < pdr_end;
 	       (pdr_ptr += external_pdr_size,
-		(*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr)))
+		(*debug_swap->swap_pdr_in) (abfd, pdr_ptr, &pdr)))
 	    {
 	      if (offset >= (pdr.adr - 0x10 * pdr.prof))
 		{
@@ -2157,7 +2097,7 @@
 
 	  if (!best_pdr || (min_dist >= 0 && min_dist < best_dist))
 	    {
-	      best_dist = (bfd_vma) min_dist;  
+	      best_dist = (bfd_vma) min_dist;
 	      best_fdr = fdr_ptr;
 	      best_pdr = pdr_hold;
 	    }
@@ -2173,7 +2113,7 @@
       /* Phew, finally we got something that we can hold onto.  */
       fdr_ptr = best_fdr;
       pdr_ptr = best_pdr;
-      (*debug_swap->swap_pdr_in) (abfd, (PTR) pdr_ptr, &pdr);
+      (*debug_swap->swap_pdr_in) (abfd, pdr_ptr, &pdr);
       /* Now we can look for the actual line number.  The line numbers
          are stored in a very funky format, which I won't try to
          describe.  The search is bounded by the end of the FDRs line
@@ -2418,17 +2358,15 @@
 /* Do the work of find_nearest_line.  */
 
 bfd_boolean
-_bfd_ecoff_locate_line (abfd, section, offset, debug_info, debug_swap,
-			line_info, filename_ptr, functionname_ptr, retline_ptr)
-     bfd *abfd;
-     asection *section;
-     bfd_vma offset;
-     struct ecoff_debug_info * const debug_info;
-     const struct ecoff_debug_swap * const debug_swap;
-     struct ecoff_find_line *line_info;
-     const char **filename_ptr;
-     const char **functionname_ptr;
-     unsigned int *retline_ptr;
+_bfd_ecoff_locate_line (bfd *abfd,
+			asection *section,
+			bfd_vma offset,
+			struct ecoff_debug_info * const debug_info,
+			const struct ecoff_debug_swap * const debug_swap,
+			struct ecoff_find_line *line_info,
+			const char **filename_ptr,
+			const char **functionname_ptr,
+			unsigned int *retline_ptr)
 {
   offset += section->vma;
 
@@ -2464,13 +2402,8 @@
 
 /* Collect a shuffle into a memory buffer.  */
 
-static bfd_boolean ecoff_collect_shuffle
-  PARAMS ((struct shuffle *, bfd_byte *));
-
 static bfd_boolean
-ecoff_collect_shuffle (l, buff)
-     struct shuffle *l;
-     bfd_byte *buff;
+ecoff_collect_shuffle (struct shuffle *l, bfd_byte *buff)
 {
   unsigned long total;
 
@@ -2496,9 +2429,8 @@
 /* Copy PDR information into a memory buffer.  */
 
 bfd_boolean
-_bfd_ecoff_get_accumulated_pdr (handle, buff)
-     PTR handle;
-     bfd_byte *buff;
+_bfd_ecoff_get_accumulated_pdr (void * handle,
+				bfd_byte *buff)
 {
   struct accumulate *ainfo = (struct accumulate *) handle;
 
@@ -2508,9 +2440,7 @@
 /* Copy symbol information into a memory buffer.  */
 
 bfd_boolean
-_bfd_ecoff_get_accumulated_sym (handle, buff)
-     PTR handle;
-     bfd_byte *buff;
+_bfd_ecoff_get_accumulated_sym (void * handle, bfd_byte *buff)
 {
   struct accumulate *ainfo = (struct accumulate *) handle;
 
@@ -2520,9 +2450,7 @@
 /* Copy the string table into a memory buffer.  */
 
 bfd_boolean
-_bfd_ecoff_get_accumulated_ss (handle, buff)
-     PTR handle;
-     bfd_byte *buff;
+_bfd_ecoff_get_accumulated_ss (void * handle, bfd_byte *buff)
 {
   struct accumulate *ainfo = (struct accumulate *) handle;
   struct string_hash_entry *sh;
@@ -2541,7 +2469,7 @@
       size_t len;
 
       len = strlen (sh->root.string);
-      memcpy (buff, (PTR) sh->root.string, len + 1);
+      memcpy (buff, sh->root.string, len + 1);
       total += len + 1;
       buff += len + 1;
     }
diff --git a/bfd/ecoffswap.h b/bfd/ecoffswap.h
index 3cf917c..3306e6b 100644
--- a/bfd/ecoffswap.h
+++ b/bfd/ecoffswap.h
@@ -451,7 +451,7 @@
 #if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
   if (intern->iss == (signed long) 0xffffffff)
     intern->iss = -1;
-#endif  
+#endif
 
   /* Now the fun stuff...  */
   if (bfd_header_big_endian (abfd))
diff --git a/bfd/elf-attrs.c b/bfd/elf-attrs.c
index 569e846..9a6ff6f 100644
--- a/bfd/elf-attrs.c
+++ b/bfd/elf-attrs.c
@@ -1,5 +1,5 @@
 /* ELF attributes support (based on ARM EABI attributes).
-   Copyright 2005, 2006, 2007, 2009, 2010
+   Copyright 2005, 2006, 2007, 2009, 2010, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -347,6 +347,10 @@
   int i;
   int vendor;
 
+  if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+    return;
+
   for (vendor = OBJ_ATTR_FIRST; vendor <= OBJ_ATTR_LAST; vendor++)
     {
       in_attr
@@ -428,7 +432,7 @@
   bfd_byte *contents;
   bfd_byte *p;
   bfd_vma len;
-  const char *std_section;
+  const char *std_sec;
 
   contents = (bfd_byte *) bfd_malloc (hdr->sh_size);
   if (!contents)
@@ -440,7 +444,7 @@
       return;
     }
   p = contents;
-  std_section = get_elf_backend_data (abfd)->obj_attrs_vendor;
+  std_sec = get_elf_backend_data (abfd)->obj_attrs_vendor;
   if (*(p++) == 'A')
     {
       len = hdr->sh_size - 1;
@@ -455,11 +459,11 @@
 	  if (section_len > len)
 	    section_len = len;
 	  len -= section_len;
-	  namelen = strlen ((char *)p) + 1;
+	  namelen = strlen ((char *) p) + 1;
 	  section_len -= namelen + 4;
-	  if (std_section && strcmp ((char *)p, std_section) == 0)
+	  if (std_sec && strcmp ((char *) p, std_sec) == 0)
 	    vendor = OBJ_ATTR_PROC;
-	  else if (strcmp ((char *)p, "gnu") == 0)
+	  else if (strcmp ((char *) p, "gnu") == 0)
 	    vendor = OBJ_ATTR_GNU;
 	  else
 	    {
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 935718f..add80b3 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -1,7 +1,5 @@
 /* BFD back-end data structures for ELF files.
-   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-   Free Software Foundation, Inc.
+   Copyright 1992-2013 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -191,8 +189,8 @@
      FIXME: There is no real need for this field if def_dynamic is never
      cleared and all places that test def_dynamic also test def_regular.  */
   unsigned int dynamic_def : 1;
-  /* Symbol is weak in all shared objects.  */
-  unsigned int dynamic_weak : 1;
+  /* Symbol has a non-weak reference from a shared object.  */
+  unsigned int ref_dynamic_nonweak : 1;
   /* Symbol is referenced with a relocation where C/C++ pointer equality
      matters.  */
   unsigned int pointer_equality_needed : 1;
@@ -402,7 +400,8 @@
    one line.  */
 enum elf_target_id
 {
-  ALPHA_ELF_DATA = 1,
+  AARCH64_ELF_DATA = 1,
+  ALPHA_ELF_DATA,
   ARM_ELF_DATA,
   AVR_ELF_DATA,
   BFIN_ELF_DATA,
@@ -416,9 +415,11 @@
   M32R_ELF_DATA,
   M68HC11_ELF_DATA,
   M68K_ELF_DATA,
+  METAG_ELF_DATA,
   MICROBLAZE_ELF_DATA,
   MIPS_ELF_DATA,
   MN10300_ELF_DATA,
+  NIOS2_ELF_DATA,
   PPC32_ELF_DATA,
   PPC64_ELF_DATA,
   S390_ELF_DATA,
@@ -428,6 +429,7 @@
   TIC6X_ELF_DATA,
   X86_64_ELF_DATA,
   XTENSA_ELF_DATA,
+  XGATE_ELF_DATA,
   TILEGX_ELF_DATA,
   TILEPRO_ELF_DATA,
   GENERIC_ELF_DATA
@@ -496,6 +498,9 @@
   /* The _PROCEDURE_LINKAGE_TABLE_ symbol.  */
   struct elf_link_hash_entry *hplt;
 
+  /* The _DYNAMIC symbol.  */
+  struct elf_link_hash_entry *hdynamic;
+
   /* A pointer to information used to merge SEC_MERGE sections.  */
   void *merge_info;
 
@@ -636,7 +641,8 @@
   reloc_class_normal,
   reloc_class_relative,
   reloc_class_plt,
-  reloc_class_copy
+  reloc_class_copy,
+  reloc_class_ifunc
 };
 
 struct elf_reloc_cookie
@@ -875,12 +881,12 @@
   bfd_boolean (*check_directives)
     (bfd *abfd, struct bfd_link_info *info);
 
-  /* The AS_NEEDED_CLEANUP function is called once per --as-needed
-     input file that was not needed by the add_symbols phase of the
-     ELF backend linker.  The function must undo any target specific
-     changes in the symbol hash table.  */
-  bfd_boolean (*as_needed_cleanup)
-    (bfd *abfd, struct bfd_link_info *info);
+  /* The NOTICE_AS_NEEDED function is called as the linker is about to
+     handle an as-needed lib (ACT = notice_as_needed), and after the
+     linker has decided to keep the lib (ACT = notice_needed) or when
+     the lib is not needed (ACT = notice_not_needed).  */
+  bfd_boolean (*notice_as_needed)
+    (bfd *abfd, struct bfd_link_info *info, enum notice_asneeded_action act);
 
   /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend
      linker for every symbol which is defined by a dynamic object and
@@ -1123,7 +1129,7 @@
 
   /* This function returns class of a reloc type.  */
   enum elf_reloc_type_class (*elf_backend_reloc_type_class)
-    (const Elf_Internal_Rela *);
+  (const struct bfd_link_info *, const asection *, const Elf_Internal_Rela *);
 
   /* This function, if defined, removes information about discarded functions
      from other sections which mention them.  */
@@ -1185,7 +1191,8 @@
      see elf.c, elfcode.h.  */
   bfd *(*elf_backend_bfd_from_remote_memory)
      (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
-      int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr, int len));
+      int (*target_read_memory) (bfd_vma vma, bfd_byte *myaddr,
+				 bfd_size_type len));
 
   /* This function is used by `_bfd_elf_get_synthetic_symtab';
      see elf.c.  */
@@ -1201,19 +1208,10 @@
   asection *(*common_section) (asection *);
 
   /* Return TRUE if we can merge 2 definitions.  */
-  bfd_boolean (*merge_symbol) (struct bfd_link_info *,
-			       struct elf_link_hash_entry **,
-			       struct elf_link_hash_entry *,
-			       Elf_Internal_Sym *, asection **,
-			       bfd_vma *, unsigned int *,
-			       bfd_boolean *, bfd_boolean *,
-			       bfd_boolean *, bfd_boolean *,
-			       bfd_boolean *, bfd_boolean *,
-			       bfd_boolean *, bfd_boolean *,
-			       bfd *, asection **,
-			       bfd_boolean *, bfd_boolean *,
-			       bfd_boolean *, bfd_boolean *,
-			       bfd *, asection **);
+  bfd_boolean (*merge_symbol) (struct elf_link_hash_entry *,
+			       const Elf_Internal_Sym *, asection **,
+			       bfd_boolean, bfd_boolean,
+			       bfd *, const asection *);
 
   /* Return TRUE if symbol should be hashed in the `.gnu.hash' section.  */
   bfd_boolean (*elf_hash_symbol) (struct elf_link_hash_entry *);
@@ -1279,6 +1277,9 @@
   /* This is non-zero if static TLS segments require a special alignment.  */
   unsigned static_tls_alignment;
 
+  /* Alignment for the PT_GNU_STACK segment. */
+  unsigned stack_align;
+
   /* This is TRUE if the linker should act like collect and gather
      global constructors and destructors by name.  This is TRUE for
      MIPS ELF because the Irix 5 tools can not handle the .init
@@ -1367,6 +1368,9 @@
   /* The ELF header for this section.  */
   Elf_Internal_Shdr this_hdr;
 
+  /* INPUT_SECTION_FLAGS if specified in the linker script.  */
+  struct flag_info *section_flag_info;
+
   /* Information about the REL and RELA reloc sections associated
      with this section, if any.  */
   struct bfd_elf_section_reloc_data rel, rela;
@@ -1498,6 +1502,64 @@
   bfd_byte data[1];
 };
 
+/* NT_GNU_BUILD_ID note type info for input BFDs.  */
+struct elf_build_id
+{
+  size_t size;
+  bfd_byte data[1];
+};
+
+/* tdata information grabbed from an elf core file.  */
+struct core_elf_obj_tdata
+{
+  int signal;
+  int pid;
+  int lwpid;
+  char* program;
+  char* command;
+};
+
+/* Extra tdata information held for output ELF BFDs.  */
+struct output_elf_obj_tdata
+{
+  struct elf_segment_map *seg_map;
+  struct elf_strtab_hash *strtab_ptr;
+
+  /* STT_SECTION symbols for each section */
+  asymbol **section_syms;
+
+  /* Used to determine if PT_GNU_EH_FRAME segment header should be
+     created.  */
+  asection *eh_frame_hdr;
+
+  /* NT_GNU_BUILD_ID note type info.  */
+  struct
+  {
+    bfd_boolean (*after_write_object_contents) (bfd *);
+    const char *style;
+    asection *sec;
+  } build_id;
+
+  /* Records the result of `get_program_header_size'.  */
+  bfd_size_type program_header_size;
+
+  /* Used when laying out sections.  */
+  file_ptr next_file_pos;
+
+  int num_section_syms;
+  unsigned int shstrtab_section, strtab_section;
+
+  /* Segment flags for the PT_GNU_STACK segment.  */
+  unsigned int stack_flags;
+
+  /* This is set to TRUE if the object was created by the backend
+     linker.  */
+  bfd_boolean linker;
+
+  /* Used to determine if the e_flags field has been initialized */
+  bfd_boolean flags_init;
+};
+
 /* Some private data is stashed away for future use using the tdata pointer
    in the bfd structure.  */
 
@@ -1506,13 +1568,6 @@
   Elf_Internal_Ehdr elf_header[1];	/* Actual data, but ref like ptr */
   Elf_Internal_Shdr **elf_sect_ptr;
   Elf_Internal_Phdr *phdr;
-  struct elf_segment_map *segment_map;
-  struct elf_strtab_hash *strtab_ptr;
-  int num_locals;
-  int num_globals;
-  unsigned int num_elf_sections;	/* elf_sect_ptr size */
-  int num_section_syms;
-  asymbol **section_syms;		/* STT_SECTION symbols for each section */
   Elf_Internal_Shdr symtab_hdr;
   Elf_Internal_Shdr shstrtab_hdr;
   Elf_Internal_Shdr strtab_hdr;
@@ -1522,20 +1577,9 @@
   Elf_Internal_Shdr dynverref_hdr;
   Elf_Internal_Shdr dynverdef_hdr;
   Elf_Internal_Shdr symtab_shndx_hdr;
-  unsigned int symtab_section, shstrtab_section;
-  unsigned int strtab_section, dynsymtab_section;
-  unsigned int symtab_shndx_section;
-  unsigned int dynversym_section, dynverdef_section, dynverref_section;
-  file_ptr next_file_pos;
   bfd_vma gp;				/* The gp value */
   unsigned int gp_size;			/* The gp size */
-
-  /* Information grabbed from an elf core file.  */
-  int core_signal;
-  int core_pid;
-  int core_lwpid;
-  char* core_program;
-  char* core_command;
+  unsigned int num_elf_sections;	/* elf_sect_ptr size */
 
   /* A mapping from external symbols to entries in the linker hash
      table, used when linking.  This is indexed by the symbol index
@@ -1566,36 +1610,17 @@
      are used by a dynamic object.  */
   const char *dt_audit;
 
-  /* Records the result of `get_program_header_size'.  */
-  bfd_size_type program_header_size;
-
   /* Used by find_nearest_line entry point.  */
   void *line_info;
 
-  /* Used by MIPS ELF find_nearest_line entry point.  The structure
-     could be included directly in this one, but there's no point to
-     wasting the memory just for the infrequently called
-     find_nearest_line.  */
-  struct mips_elf_find_line *find_line_info;
-
   /* A place to stash dwarf1 info for this bfd.  */
   struct dwarf1_debug *dwarf1_find_line_info;
 
   /* A place to stash dwarf2 info for this bfd.  */
   void *dwarf2_find_line_info;
 
-  /* An array of stub sections indexed by symbol number, used by the
-     MIPS ELF linker.  FIXME: We should figure out some way to only
-     include this field for a MIPS ELF target.  */
-  asection **local_stubs;
-  asection **local_call_stubs;
-
-  /* Used to determine if PT_GNU_EH_FRAME segment header should be
-     created.  */
-  asection *eh_frame_hdr;
-
-  Elf_Internal_Shdr **group_sect_ptr;
-  int num_group;
+  /* Stash away info for yet another find line/function variant.  */
+  void *elf_find_function_cache;
 
   /* Number of symbol version definitions we are about to emit.  */
   unsigned int cverdefs;
@@ -1603,34 +1628,44 @@
   /* Number of symbol version references we are about to emit.  */
   unsigned int cverrefs;
 
-  /* Segment flags for the PT_GNU_STACK segment.  */
-  unsigned int stack_flags;
-
   /* Symbol version definitions in external objects.  */
   Elf_Internal_Verdef *verdef;
 
   /* Symbol version references to external objects.  */
   Elf_Internal_Verneed *verref;
 
-  /* The Irix 5 support uses two virtual sections, which represent
-     text/data symbols defined in dynamic objects.  */
-  asymbol *elf_data_symbol;
-  asymbol *elf_text_symbol;
-  asection *elf_data_section;
-  asection *elf_text_section;
-
   /* A pointer to the .eh_frame section.  */
   asection *eh_frame_section;
 
+  /* Symbol buffer.  */
+  void *symbuf;
+
+  obj_attribute known_obj_attributes[2][NUM_KNOWN_OBJ_ATTRIBUTES];
+  obj_attribute_list *other_obj_attributes[2];
+
+  /* NT_GNU_BUILD_ID note type.  */
+  struct elf_build_id *build_id;
+
+  /* Linked-list containing information about every Systemtap section
+     found in the object file.  Each section corresponds to one entry
+     in the list.  */
+  struct sdt_note *sdt_note_head;
+
+  Elf_Internal_Shdr **group_sect_ptr;
+  int num_group;
+
+  unsigned int symtab_section, symtab_shndx_section, dynsymtab_section;
+  unsigned int dynversym_section, dynverdef_section, dynverref_section;
+
+  /* An identifier used to distinguish different target
+     specific extensions to this structure.  */
+  enum elf_target_id object_id;
+
   /* Whether a dyanmic object was specified normally on the linker
      command line, or was specified when --as-needed was in effect,
      or was found via a DT_NEEDED entry.  */
   enum dynamic_lib_link_class dyn_lib_class;
 
-  /* This is set to TRUE if the object was created by the backend
-     linker.  */
-  bfd_boolean linker;
-
   /* Irix 5 often screws up the symbol table, sorting local symbols
      after global symbols.  This flag is set if the symbol table in
      this BFD appears to be screwed up.  If it is, we ignore the
@@ -1638,48 +1673,35 @@
      symbols.  */
   bfd_boolean bad_symtab;
 
-  /* Used to determine if the e_flags field has been initialized */
-  bfd_boolean flags_init;
-
-  /* Symbol buffer.  */
-  void *symbuf;
-
-  obj_attribute known_obj_attributes[2][NUM_KNOWN_OBJ_ATTRIBUTES];
-  obj_attribute_list *other_obj_attributes[2];
-
-  /* Called at the end of _bfd_elf_write_object_contents if not NULL.  */
-  bfd_boolean (*after_write_object_contents) (bfd *);
-  void *after_write_object_contents_info;
-
-  /* NT_GNU_BUILD_ID note type.  */
-  bfd_size_type build_id_size;
-  bfd_byte *build_id;
-
-  /* Linked-list containing information about every Systemtap section
-     found in the object file.  Each section corresponds to one entry
-     in the list.  */
-  struct sdt_note *sdt_note_head;
-
   /* True if the bfd contains symbols that have the STT_GNU_IFUNC
      symbol type or STB_GNU_UNIQUE binding.  Used to set the osabi
      field in the ELF header structure.  */
   bfd_boolean has_gnu_symbols;
 
-  /* An identifier used to distinguish different target
-     specific extensions to this structure.  */
-  enum elf_target_id object_id;
+  /* Information grabbed from an elf core file.  */
+  struct core_elf_obj_tdata *core;
+
+  /* More information held for output ELF BFDs.  */
+  struct output_elf_obj_tdata *o;
 };
 
 #define elf_tdata(bfd)		((bfd) -> tdata.elf_obj_data)
 
 #define elf_object_id(bfd)	(elf_tdata(bfd) -> object_id)
-#define elf_program_header_size(bfd) (elf_tdata(bfd) -> program_header_size)
+#define elf_program_header_size(bfd) (elf_tdata(bfd) -> o->program_header_size)
 #define elf_elfheader(bfd)	(elf_tdata(bfd) -> elf_header)
 #define elf_elfsections(bfd)	(elf_tdata(bfd) -> elf_sect_ptr)
 #define elf_numsections(bfd)	(elf_tdata(bfd) -> num_elf_sections)
-#define elf_shstrtab(bfd)	(elf_tdata(bfd) -> strtab_ptr)
+#define elf_seg_map(bfd)	(elf_tdata(bfd) -> o->seg_map)
+#define elf_next_file_pos(bfd)	(elf_tdata(bfd) -> o->next_file_pos)
+#define elf_eh_frame_hdr(bfd)	(elf_tdata(bfd) -> o->eh_frame_hdr)
+#define elf_linker(bfd)		(elf_tdata(bfd) -> o->linker)
+#define elf_stack_flags(bfd)	(elf_tdata(bfd) -> o->stack_flags)
+#define elf_shstrtab(bfd)	(elf_tdata(bfd) -> o->strtab_ptr)
 #define elf_onesymtab(bfd)	(elf_tdata(bfd) -> symtab_section)
 #define elf_symtab_shndx(bfd)	(elf_tdata(bfd) -> symtab_shndx_section)
+#define elf_strtab_sec(bfd)	(elf_tdata(bfd) -> o->strtab_section)
+#define elf_shstrtab_sec(bfd)	(elf_tdata(bfd) -> o->shstrtab_section)
 #define elf_symtab_hdr(bfd)	(elf_tdata(bfd) -> symtab_hdr)
 #define elf_dynsymtab(bfd)	(elf_tdata(bfd) -> dynsymtab_section)
 #define elf_dynversym(bfd)	(elf_tdata(bfd) -> dynversym_section)
@@ -1687,10 +1709,8 @@
 #define elf_dynverref(bfd)	(elf_tdata(bfd) -> dynverref_section)
 #define elf_eh_frame_section(bfd) \
 				(elf_tdata(bfd) -> eh_frame_section)
-#define elf_num_locals(bfd)	(elf_tdata(bfd) -> num_locals)
-#define elf_num_globals(bfd)	(elf_tdata(bfd) -> num_globals)
-#define elf_section_syms(bfd)	(elf_tdata(bfd) -> section_syms)
-#define elf_num_section_syms(bfd) (elf_tdata(bfd) -> num_section_syms)
+#define elf_section_syms(bfd)	(elf_tdata(bfd) -> o->section_syms)
+#define elf_num_section_syms(bfd) (elf_tdata(bfd) -> o->num_section_syms)
 #define core_prpsinfo(bfd)	(elf_tdata(bfd) -> prpsinfo)
 #define core_prstatus(bfd)	(elf_tdata(bfd) -> prstatus)
 #define elf_gp(bfd)		(elf_tdata(bfd) -> gp)
@@ -1703,7 +1723,7 @@
 #define elf_dt_audit(bfd)	(elf_tdata(bfd) -> dt_audit)
 #define elf_dyn_lib_class(bfd)	(elf_tdata(bfd) -> dyn_lib_class)
 #define elf_bad_symtab(bfd)	(elf_tdata(bfd) -> bad_symtab)
-#define elf_flags_init(bfd)	(elf_tdata(bfd) -> flags_init)
+#define elf_flags_init(bfd)	(elf_tdata(bfd) -> o->flags_init)
 #define elf_known_obj_attributes(bfd) (elf_tdata (bfd) -> known_obj_attributes)
 #define elf_other_obj_attributes(bfd) (elf_tdata (bfd) -> other_obj_attributes)
 #define elf_known_obj_attributes_proc(bfd) \
@@ -1758,7 +1778,8 @@
   (bfd *input_bfd, struct bfd_link_info *info, asection *eh_frame_section);
 
 extern enum elf_reloc_type_class _bfd_elf_reloc_type_class
-  (const Elf_Internal_Rela *);
+  (const struct bfd_link_info *, const asection *,
+   const Elf_Internal_Rela *);
 extern bfd_vma _bfd_elf_rela_local_sym
   (bfd *, Elf_Internal_Sym *, asection **, Elf_Internal_Rela *);
 extern bfd_vma _bfd_elf_rel_local_sym
@@ -1787,6 +1808,8 @@
   (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
 extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
   (bfd *);
+extern void _bfd_elf_link_hash_table_free
+  (struct bfd_link_hash_table *);
 extern void _bfd_elf_link_hash_copy_indirect
   (struct bfd_link_info *, struct elf_link_hash_entry *,
    struct elf_link_hash_entry *);
@@ -1813,8 +1836,7 @@
   (bfd *, asection *, void *);
 extern asection *_bfd_elf_check_kept_section
   (asection *, struct bfd_link_info *);
-extern void _bfd_elf_link_just_syms
-  (asection *, struct bfd_link_info *);
+#define _bfd_elf_link_just_syms _bfd_generic_link_just_syms
 extern void _bfd_elf_copy_link_hash_symbol_type
   (bfd *, struct bfd_link_hash_entry *, struct bfd_link_hash_entry *);
 extern bfd_boolean _bfd_elf_size_group_sections
@@ -1890,8 +1912,6 @@
   (bfd *, struct bfd_link_info *);
 extern bfd_boolean _bfd_elf_new_section_hook
   (bfd *, asection *);
-extern bfd_boolean _bfd_elf_init_reloc_shdr
-  (bfd *, struct bfd_elf_section_reloc_data *, asection *, bfd_boolean);
 extern const struct bfd_elf_special_section *_bfd_elf_get_special_section
   (const char *, const struct bfd_elf_special_section *, unsigned int);
 extern const struct bfd_elf_special_section *_bfd_elf_get_sec_type_attr
@@ -1926,8 +1946,12 @@
   (struct elf_strtab_hash *, bfd_size_type);
 extern void _bfd_elf_strtab_delref
   (struct elf_strtab_hash *, bfd_size_type);
+extern unsigned int _bfd_elf_strtab_refcount
+  (struct elf_strtab_hash *, bfd_size_type);
 extern void _bfd_elf_strtab_clear_all_refs
-  (struct elf_strtab_hash *);
+  (struct elf_strtab_hash *tab);
+extern void _bfd_elf_strtab_restore_size
+  (struct elf_strtab_hash *, bfd_size_type);
 extern bfd_size_type _bfd_elf_strtab_size
   (struct elf_strtab_hash *);
 extern bfd_size_type _bfd_elf_strtab_offset
@@ -1955,15 +1979,11 @@
   (bfd *, struct bfd_link_info *, asection *, bfd_byte *);
 extern bfd_boolean _bfd_elf_write_section_eh_frame_hdr
   (bfd *, struct bfd_link_info *);
+extern bfd_boolean _bfd_elf_eh_frame_present
+  (struct bfd_link_info *);
 extern bfd_boolean _bfd_elf_maybe_strip_eh_frame_hdr
   (struct bfd_link_info *);
 
-extern bfd_boolean _bfd_elf_merge_symbol
-  (bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *,
-   asection **, bfd_vma *, unsigned int *,
-   struct elf_link_hash_entry **, bfd_boolean *,
-   bfd_boolean *, bfd_boolean *, bfd_boolean *);
-
 extern bfd_boolean _bfd_elf_hash_symbol (struct elf_link_hash_entry *);
 
 extern long _bfd_elf_link_lookup_local_dynindx
@@ -2119,6 +2139,8 @@
 
 extern bfd_boolean _bfd_elf_relocs_compatible
   (const bfd_target *, const bfd_target *);
+extern bfd_boolean _bfd_elf_notice_as_needed
+  (bfd *, struct bfd_link_info *, enum notice_asneeded_action);
 
 extern struct elf_link_hash_entry *_bfd_elf_archive_symbol_lookup
   (bfd *, struct bfd_link_info *, const char *);
@@ -2145,9 +2167,6 @@
 extern asection *_bfd_elf_common_section
   (asection *);
 
-extern void _bfd_dwarf2_cleanup_debug_info
-  (bfd *);
-
 extern bfd_vma _bfd_elf_default_got_elt_size
 (bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, bfd *,
  unsigned long);
@@ -2218,8 +2237,8 @@
 
 extern int bfd_elf_get_default_section_type (flagword);
 
-extern void bfd_elf_lookup_section_flags
-  (struct bfd_link_info *, struct flag_info *);
+extern bfd_boolean bfd_elf_lookup_section_flags
+  (struct bfd_link_info *, struct flag_info *, asection *);
 
 extern Elf_Internal_Phdr * _bfd_elf_find_segment_containing_section
   (bfd * abfd, asection * section);
@@ -2253,19 +2272,67 @@
   (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_s390_prefix
   (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_s390_last_break
+  (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_s390_system_call
+  (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_s390_tdb
+  (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_arm_vfp
   (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_aarch_tls
+  (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_aarch_hw_break
+  (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_aarch_hw_watch
+  (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_lwpstatus
   (bfd *, char *, int *, long, int, const void *);
 extern char *elfcore_write_register_note
   (bfd *, char *, int *, const char *, const void *, int);
 
+/* Internal structure which holds information to be included in the
+   PRPSINFO section of Linux core files.
+
+   This is an "internal" structure in the sense that it should be used
+   to pass information to BFD (via the `elfcore_write_linux_prpsinfo'
+   function), so things like endianess shouldn't be an issue.  This
+   structure will eventually be converted in one of the
+   `elf_external_linux_*' structures and written out to an output bfd
+   by one of the functions declared below.  */
+
+struct elf_internal_linux_prpsinfo
+  {
+    char pr_state;			/* Numeric process state.  */
+    char pr_sname;			/* Char for pr_state.  */
+    char pr_zomb;			/* Zombie.  */
+    char pr_nice;			/* Nice val.  */
+    unsigned long pr_flag;		/* Flags.  */
+    unsigned int pr_uid;
+    unsigned int pr_gid;
+    int pr_pid, pr_ppid, pr_pgrp, pr_sid;
+    char pr_fname[16 + 1];		/* Filename of executable.  */
+    char pr_psargs[80 + 1];		/* Initial part of arg list.  */
+  };
+
+/* Linux/most 32-bit archs.  */
+extern char *elfcore_write_linux_prpsinfo32
+  (bfd *, char *, int *, const struct elf_internal_linux_prpsinfo *);
+
+/* Linux/most 64-bit archs.  */
+extern char *elfcore_write_linux_prpsinfo64
+  (bfd *, char *, int *, const struct elf_internal_linux_prpsinfo *);
+
+/* Linux/PPC32 uses different layout compared to most archs.  */
+extern char *elfcore_write_ppc_linux_prpsinfo32
+  (bfd *, char *, int *, const struct elf_internal_linux_prpsinfo *);
+
 extern bfd *_bfd_elf32_bfd_from_remote_memory
   (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
-   int (*target_read_memory) (bfd_vma, bfd_byte *, int));
+   int (*target_read_memory) (bfd_vma, bfd_byte *, bfd_size_type));
 extern bfd *_bfd_elf64_bfd_from_remote_memory
   (bfd *templ, bfd_vma ehdr_vma, bfd_vma *loadbasep,
-   int (*target_read_memory) (bfd_vma, bfd_byte *, int));
+   int (*target_read_memory) (bfd_vma, bfd_byte *, bfd_size_type));
 
 extern bfd_vma bfd_elf_obj_attr_size (bfd *);
 extern void bfd_elf_set_obj_attr_contents (bfd *, bfd_byte *, bfd_vma);
@@ -2313,12 +2380,9 @@
 
 extern bfd_boolean _bfd_elf_create_ifunc_sections
   (bfd *, struct bfd_link_info *);
-extern asection * _bfd_elf_create_ifunc_dyn_reloc
-  (bfd *, struct bfd_link_info *, asection *sec, asection *sreloc,
-   struct elf_dyn_relocs **);
 extern bfd_boolean _bfd_elf_allocate_ifunc_dyn_relocs
   (struct bfd_link_info *, struct elf_link_hash_entry *,
-   struct elf_dyn_relocs **, unsigned int, unsigned int);
+   struct elf_dyn_relocs **, unsigned int, unsigned int, unsigned int);
 
 extern void elf_append_rela (bfd *, asection *, Elf_Internal_Rela *);
 extern void elf_append_rel (bfd *, asection *, Elf_Internal_Rela *);
@@ -2415,10 +2479,12 @@
    link, we remove such relocations.  Otherwise, we just want the
    section contents zeroed and avoid any special processing.  */
 #define RELOC_AGAINST_DISCARDED_SECTION(info, input_bfd, input_section,	\
-					rel, relend, howto, contents)	\
+					rel, count, relend,		\
+					howto, index, contents)		\
   {									\
+    int i_;								\
     _bfd_clear_contents (howto, input_bfd, input_section,		\
-			 contents + rel->r_offset);			\
+			 contents + rel[index].r_offset);		\
 									\
     if (info->relocatable						\
 	&& (input_section->flags & SEC_DEBUGGING))			\
@@ -2436,21 +2502,26 @@
 	    rel_hdr = _bfd_elf_single_rel_hdr (input_section);		\
 	    rel_hdr->sh_size -= rel_hdr->sh_entsize;			\
 									\
-	    memmove (rel, rel + 1, (relend - rel - 1) * sizeof (*rel));	\
+	    memmove (rel, rel + count,					\
+		     (relend - rel - count) * sizeof (*rel));		\
 									\
 	    input_section->reloc_count--;				\
-	    relend--;							\
+	    relend -= count;						\
 	    rel--;							\
 	    continue;							\
 	  }								\
       }									\
 									\
-    rel->r_info = 0;							\
-    rel->r_addend = 0;							\
+    for (i_ = 0; i_ < count; i_++)					\
+      {									\
+	rel[i_].r_info = 0;						\
+	rel[i_].r_addend = 0;						\
+      }									\
+    rel += count - 1;							\
     continue;								\
   }
 
-/* Will a symbol be bound to the the definition within the shared
+/* Will a symbol be bound to the definition within the shared
    library, if any.  A unique symbol can never be bound locally.  */
 #define SYMBOLIC_BIND(INFO, H) \
     (!(H)->unique_global \
diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
index 54142b2..832a991 100644
--- a/bfd/elf-eh-frame.c
+++ b/bfd/elf-eh-frame.c
@@ -1,6 +1,6 @@
 /* .eh_frame section optimization.
-   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
+   2012 Free Software Foundation, Inc.
    Written by Jakub Jelinek <[email protected]>.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -491,7 +491,7 @@
     return;
 
   if (sec->size == 0
-      || sec->sec_info_type != ELF_INFO_TYPE_NONE)
+      || sec->sec_info_type != SEC_INFO_TYPE_NONE)
     {
       /* This file does not contain .eh_frame information.  */
       return;
@@ -904,7 +904,7 @@
   BFD_ASSERT (cie_count == num_cies);
 
   elf_section_data (sec)->sec_info = sec_info;
-  sec->sec_info_type = ELF_INFO_TYPE_EH_FRAME;
+  sec->sec_info_type = SEC_INFO_TYPE_EH_FRAME;
   if (hdr_info->merge_cies)
     {
       sec_info->cies = local_cies;
@@ -1137,7 +1137,7 @@
   struct eh_frame_hdr_info *hdr_info;
   unsigned int ptr_size, offset;
 
-  if (sec->sec_info_type != ELF_INFO_TYPE_EH_FRAME)
+  if (sec->sec_info_type != SEC_INFO_TYPE_EH_FRAME)
     return FALSE;
 
   sec_info = (struct eh_frame_sec_info *) elf_section_data (sec)->sec_info;
@@ -1243,10 +1243,30 @@
   if (hdr_info->table)
     sec->size += 4 + hdr_info->fde_count * 8;
 
-  elf_tdata (abfd)->eh_frame_hdr = sec;
+  elf_eh_frame_hdr (abfd) = sec;
   return TRUE;
 }
 
+/* Return true if there is at least one non-empty .eh_frame section in
+   input files.  Can only be called after ld has mapped input to
+   output sections, and before sections are stripped.  */
+bfd_boolean
+_bfd_elf_eh_frame_present (struct bfd_link_info *info)
+{
+  asection *eh = bfd_get_section_by_name (info->output_bfd, ".eh_frame");
+
+  if (eh == NULL)
+    return FALSE;
+
+  /* Count only sections which have at least a single CIE or FDE.
+     There cannot be any CIE or FDE <= 8 bytes.  */
+  for (eh = eh->map_head.s; eh != NULL; eh = eh->map_head.s)
+    if (eh->size > 8)
+      return TRUE;
+
+  return FALSE;
+}
+
 /* This function is called from size_dynamic_sections.
    It needs to decide whether .eh_frame_hdr should be output or not,
    because when the dynamic symbol table has been sized it is too late
@@ -1255,8 +1275,6 @@
 bfd_boolean
 _bfd_elf_maybe_strip_eh_frame_hdr (struct bfd_link_info *info)
 {
-  asection *o;
-  bfd *abfd;
   struct elf_link_hash_table *htab;
   struct eh_frame_hdr_info *hdr_info;
 
@@ -1265,24 +1283,9 @@
   if (hdr_info->hdr_sec == NULL)
     return TRUE;
 
-  if (bfd_is_abs_section (hdr_info->hdr_sec->output_section))
-    {
-      hdr_info->hdr_sec = NULL;
-      return TRUE;
-    }
-
-  abfd = NULL;
-  if (info->eh_frame_hdr)
-    for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link_next)
-      {
-	/* Count only sections which have at least a single CIE or FDE.
-	   There cannot be any CIE or FDE <= 8 bytes.  */
-	o = bfd_get_section_by_name (abfd, ".eh_frame");
-	if (o && o->size > 8 && !bfd_is_abs_section (o->output_section))
-	  break;
-      }
-
-  if (abfd == NULL)
+  if (bfd_is_abs_section (hdr_info->hdr_sec->output_section)
+      || !info->eh_frame_hdr
+      || !_bfd_elf_eh_frame_present (info))
     {
       hdr_info->hdr_sec->flags |= SEC_EXCLUDE;
       hdr_info->hdr_sec = NULL;
@@ -1307,7 +1310,7 @@
   struct eh_frame_sec_info *sec_info;
   unsigned int lo, hi, mid;
 
-  if (sec->sec_info_type != ELF_INFO_TYPE_EH_FRAME)
+  if (sec->sec_info_type != SEC_INFO_TYPE_EH_FRAME)
     return offset;
   sec_info = (struct eh_frame_sec_info *) elf_section_data (sec)->sec_info;
 
@@ -1395,7 +1398,7 @@
   unsigned int ptr_size;
   struct eh_cie_fde *ent;
 
-  if (sec->sec_info_type != ELF_INFO_TYPE_EH_FRAME)
+  if (sec->sec_info_type != SEC_INFO_TYPE_EH_FRAME)
     /* FIXME: octets_per_byte.  */
     return bfd_set_section_contents (abfd, sec->output_section, contents,
 				     sec->output_offset, sec->size);
@@ -1767,74 +1770,81 @@
   struct elf_link_hash_table *htab;
   struct eh_frame_hdr_info *hdr_info;
   asection *sec;
-  bfd_byte *contents;
-  asection *eh_frame_sec;
-  bfd_size_type size;
-  bfd_boolean retval;
-  bfd_vma encoded_eh_frame;
+  bfd_boolean retval = TRUE;
 
   htab = elf_hash_table (info);
   hdr_info = &htab->eh_info;
   sec = hdr_info->hdr_sec;
-  if (sec == NULL)
-    return TRUE;
 
-  size = EH_FRAME_HDR_SIZE;
-  if (hdr_info->array && hdr_info->array_count == hdr_info->fde_count)
-    size += 4 + hdr_info->fde_count * 8;
-  contents = (bfd_byte *) bfd_malloc (size);
-  if (contents == NULL)
-    return FALSE;
-
-  eh_frame_sec = bfd_get_section_by_name (abfd, ".eh_frame");
-  if (eh_frame_sec == NULL)
+  if (info->eh_frame_hdr && sec != NULL)
     {
-      free (contents);
-      return FALSE;
-    }
+      bfd_byte *contents;
+      asection *eh_frame_sec;
+      bfd_size_type size;
+      bfd_vma encoded_eh_frame;
 
-  memset (contents, 0, EH_FRAME_HDR_SIZE);
-  contents[0] = 1;				/* Version.  */
-  contents[1] = get_elf_backend_data (abfd)->elf_backend_encode_eh_address
-    (abfd, info, eh_frame_sec, 0, sec, 4,
-     &encoded_eh_frame);			/* .eh_frame offset.  */
+      size = EH_FRAME_HDR_SIZE;
+      if (hdr_info->array && hdr_info->array_count == hdr_info->fde_count)
+	size += 4 + hdr_info->fde_count * 8;
+      contents = (bfd_byte *) bfd_malloc (size);
+      if (contents == NULL)
+	return FALSE;
 
-  if (hdr_info->array && hdr_info->array_count == hdr_info->fde_count)
-    {
-      contents[2] = DW_EH_PE_udata4;		/* FDE count encoding.  */
-      contents[3] = DW_EH_PE_datarel | DW_EH_PE_sdata4; /* Search table enc.  */
-    }
-  else
-    {
-      contents[2] = DW_EH_PE_omit;
-      contents[3] = DW_EH_PE_omit;
-    }
-  bfd_put_32 (abfd, encoded_eh_frame, contents + 4);
-
-  if (contents[2] != DW_EH_PE_omit)
-    {
-      unsigned int i;
-
-      bfd_put_32 (abfd, hdr_info->fde_count, contents + EH_FRAME_HDR_SIZE);
-      qsort (hdr_info->array, hdr_info->fde_count, sizeof (*hdr_info->array),
-	     vma_compare);
-      for (i = 0; i < hdr_info->fde_count; i++)
+      eh_frame_sec = bfd_get_section_by_name (abfd, ".eh_frame");
+      if (eh_frame_sec == NULL)
 	{
-	  bfd_put_32 (abfd,
-		      hdr_info->array[i].initial_loc
-		      - sec->output_section->vma,
-		      contents + EH_FRAME_HDR_SIZE + i * 8 + 4);
-	  bfd_put_32 (abfd,
-		      hdr_info->array[i].fde - sec->output_section->vma,
-		      contents + EH_FRAME_HDR_SIZE + i * 8 + 8);
+	  free (contents);
+	  return FALSE;
 	}
-    }
 
-  /* FIXME: octets_per_byte.  */
-  retval = bfd_set_section_contents (abfd, sec->output_section,
-				     contents, (file_ptr) sec->output_offset,
-				     sec->size);
-  free (contents);
+      memset (contents, 0, EH_FRAME_HDR_SIZE);
+      /* Version.  */
+      contents[0] = 1;
+      /* .eh_frame offset.  */
+      contents[1] = get_elf_backend_data (abfd)->elf_backend_encode_eh_address
+	(abfd, info, eh_frame_sec, 0, sec, 4, &encoded_eh_frame);
+
+      if (hdr_info->array && hdr_info->array_count == hdr_info->fde_count)
+	{
+	  /* FDE count encoding.  */
+	  contents[2] = DW_EH_PE_udata4;
+	  /* Search table encoding.  */
+	  contents[3] = DW_EH_PE_datarel | DW_EH_PE_sdata4;
+	}
+      else
+	{
+	  contents[2] = DW_EH_PE_omit;
+	  contents[3] = DW_EH_PE_omit;
+	}
+      bfd_put_32 (abfd, encoded_eh_frame, contents + 4);
+
+      if (contents[2] != DW_EH_PE_omit)
+	{
+	  unsigned int i;
+
+	  bfd_put_32 (abfd, hdr_info->fde_count, contents + EH_FRAME_HDR_SIZE);
+	  qsort (hdr_info->array, hdr_info->fde_count,
+		 sizeof (*hdr_info->array), vma_compare);
+	  for (i = 0; i < hdr_info->fde_count; i++)
+	    {
+	      bfd_put_32 (abfd,
+			  hdr_info->array[i].initial_loc
+			  - sec->output_section->vma,
+			  contents + EH_FRAME_HDR_SIZE + i * 8 + 4);
+	      bfd_put_32 (abfd,
+			  hdr_info->array[i].fde - sec->output_section->vma,
+			  contents + EH_FRAME_HDR_SIZE + i * 8 + 8);
+	    }
+	}
+
+      /* FIXME: octets_per_byte.  */
+      retval = bfd_set_section_contents (abfd, sec->output_section, contents,
+					 (file_ptr) sec->output_offset,
+					 sec->size);
+      free (contents);
+    }
+  if (hdr_info->array != NULL)
+    free (hdr_info->array);
   return retval;
 }
 
diff --git a/bfd/elf-ifunc.c b/bfd/elf-ifunc.c
index 3ba96c7..8d48e66 100644
--- a/bfd/elf-ifunc.c
+++ b/bfd/elf-ifunc.c
@@ -1,5 +1,5 @@
 /* ELF STT_GNU_IFUNC support.
-   Copyright 2009
+   Copyright 2009-2013
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -104,51 +104,6 @@
   return TRUE;
 }
 
-/* For a STT_GNU_IFUNC symbol, create a dynamic reloc section, SRELOC,
-   for the input section, SEC, and append this reloc to HEAD.  */
-
-asection *
-_bfd_elf_create_ifunc_dyn_reloc (bfd *abfd, struct bfd_link_info *info,
-				 asection *sec, asection *sreloc,
-				 struct elf_dyn_relocs **head)
-{
-  struct elf_dyn_relocs *p;
-  struct elf_link_hash_table *htab = elf_hash_table (info);
-
-  if (sreloc == NULL)
-    {
-      const struct elf_backend_data *bed = get_elf_backend_data (abfd);
-
-      if (htab->dynobj == NULL)
-	htab->dynobj = abfd;
-
-      sreloc = _bfd_elf_make_dynamic_reloc_section (sec, htab->dynobj,
-						    bed->s->log_file_align,
-						    abfd,
-						    bed->rela_plts_and_copies_p); 
-      if (sreloc == NULL)
-	return NULL;
-    }
-		      
-  p = *head;
-  if (p == NULL || p->sec != sec)
-    {
-      bfd_size_type amt = sizeof *p;
-
-      p = ((struct elf_dyn_relocs *) bfd_alloc (htab->dynobj, amt));
-      if (p == NULL)
-	return NULL;
-      p->next = *head;
-      *head = p;
-      p->sec = sec;
-      p->count = 0;
-      p->pc_count = 0;
-    }
-  p->count += 1;
-
-  return sreloc;
-}
-
 /* Allocate space in .plt, .got and associated reloc sections for
    dynamic relocs against a STT_GNU_IFUNC symbol definition.  */
 
@@ -157,6 +112,7 @@
 				    struct elf_link_hash_entry *h,
 				    struct elf_dyn_relocs **head,
 				    unsigned int plt_entry_size,
+				    unsigned int plt_header_size,
 				    unsigned int got_entry_size)
 {
   asection *plt, *gotplt, *relplt;
@@ -175,7 +131,7 @@
 	  || info->export_dynamic)
       && h->pointer_equality_needed)
     {
-      info->callbacks->einfo 
+      info->callbacks->einfo
 	(_("%F%P: dynamic STT_GNU_IFUNC symbol `%s' with pointer "
 	   "equality in `%B' can not be used when making an "
 	   "executable; recompile with -fPIE and relink with -pie\n"),
@@ -187,23 +143,20 @@
 
   htab = elf_hash_table (info);
 
+  /* When building shared library, we need to handle the case where it is
+     marked with regular reference, but not non-GOT reference since the
+     non-GOT reference bit may not be set here.  */
+  if (info->shared && !h->non_got_ref && h->ref_regular)
+    for (p = *head; p != NULL; p = p->next)
+      if (p->count)
+	{
+	  h->non_got_ref = 1;
+	  goto keep;
+	}
+
   /* Support garbage collection against STT_GNU_IFUNC symbols.  */
   if (h->plt.refcount <= 0 && h->got.refcount <= 0)
     {
-      /* When building shared library, we need to handle the case
-         where it is marked with regular reference, but not non-GOT
-	 reference.  It may happen if we didn't see STT_GNU_IFUNC
-	 symbol at the time when checking relocations.  */
-      if (info->shared
-	  && !h->non_got_ref
-	  && h->ref_regular)
-	for (p = *head; p != NULL; p = p->next)
-	  if (p->count)
-	    {
-	      h->non_got_ref = 1;
-	      goto keep;
-	    }
-
       h->got = htab->init_got_offset;
       h->plt = htab->init_plt_offset;
       *head = NULL;
@@ -241,7 +194,7 @@
       /* If this is the first .plt entry, make room for the special
 	 first entry.  */
       if (plt->size == 0)
-	plt->size += plt_entry_size;
+	plt->size += plt_header_size;
     }
   else
     {
@@ -251,7 +204,7 @@
     }
 
   /* Don't update value of STT_GNU_IFUNC symbol to PLT.  We need
-     the original value for R_*_IRELATIVE.  */  
+     the original value for R_*_IRELATIVE.  */
   h->plt.offset = plt->size;
 
   /* Make room for this entry in the .plt/.iplt section.  */
diff --git a/bfd/elf-linux-psinfo.h b/bfd/elf-linux-psinfo.h
new file mode 100644
index 0000000..c965284
--- /dev/null
+++ b/bfd/elf-linux-psinfo.h
@@ -0,0 +1,127 @@
+/* Definitions for PRPSINFO structures under ELF on GNU/Linux.
+   Copyright 2013 Free Software Foundation, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#ifndef ELF_LINUX_PSINFO_H
+#define ELF_LINUX_PSINFO_H
+
+/* The PRPSINFO structures defined below are used by most
+   architectures, although some of them define their own versions
+   (like e.g., PPC).  */
+
+/* External 32-bit structure for PRPSINFO.  This structure is
+   ABI-defined, thus we choose to use char arrays here in order to
+   avoid dealing with different types in different architectures.
+
+   This structure will ultimately be written in the corefile's note
+   section, as the PRPSINFO.  */
+
+struct elf_external_linux_prpsinfo32
+  {
+    char pr_state;			/* Numeric process state.  */
+    char pr_sname;			/* Char for pr_state.  */
+    char pr_zomb;			/* Zombie.  */
+    char pr_nice;			/* Nice val.  */
+    char pr_flag[4];			/* Flags.  */
+    char pr_uid[2];
+    char pr_gid[2];
+    char pr_pid[4];
+    char pr_ppid[4];
+    char pr_pgrp[4];
+    char pr_sid[4];
+    char pr_fname[16];			/* Filename of executable.  */
+    char pr_psargs[80];			/* Initial part of arg list.  */
+  };
+
+/* Helper macro to swap (properly handling endianess) things from the
+   `elf_internal_linux_prpsinfo' structure to the
+   `elf_external_linux_prpsinfo32' structure.
+
+   Note that FROM should be a pointer, and TO should be the explicit
+   type.  */
+
+#define LINUX_PRPSINFO32_SWAP_FIELDS(abfd, from, to)			\
+  do									\
+    {									\
+      H_PUT_8 (abfd, from->pr_state, &to.pr_state);			\
+      H_PUT_8 (abfd, from->pr_sname, &to.pr_sname);			\
+      H_PUT_8 (abfd, from->pr_zomb, &to.pr_zomb);			\
+      H_PUT_8 (abfd, from->pr_nice, &to.pr_nice);			\
+      H_PUT_32 (abfd, from->pr_flag, to.pr_flag);			\
+      H_PUT_16 (abfd, from->pr_uid, to.pr_uid);				\
+      H_PUT_16 (abfd, from->pr_gid, to.pr_gid);				\
+      H_PUT_32 (abfd, from->pr_pid, to.pr_pid);				\
+      H_PUT_32 (abfd, from->pr_ppid, to.pr_ppid);			\
+      H_PUT_32 (abfd, from->pr_pgrp, to.pr_pgrp);			\
+      H_PUT_32 (abfd, from->pr_sid, to.pr_sid);				\
+      strncpy (to.pr_fname, from->pr_fname, sizeof (to.pr_fname));	\
+      strncpy (to.pr_psargs, from->pr_psargs, sizeof (to.pr_psargs));	\
+    } while (0)
+
+/* External 64-bit structure for PRPSINFO.  This structure is
+   ABI-defined, thus we choose to use char arrays here in order to
+   avoid dealing with different types in different architectures.
+
+   This structure will ultimately be written in the corefile's note
+   section, as the PRPSINFO.  */
+
+struct elf_external_linux_prpsinfo64
+  {
+    char pr_state;			/* Numeric process state.  */
+    char pr_sname;			/* Char for pr_state.  */
+    char pr_zomb;			/* Zombie.  */
+    char pr_nice;			/* Nice val.  */
+    char pr_flag[8];			/* Flags.  */
+    char gap[4];
+    char pr_uid[4];
+    char pr_gid[4];
+    char pr_pid[4];
+    char pr_ppid[4];
+    char pr_pgrp[4];
+    char pr_sid[4];
+    char pr_fname[16];			/* Filename of executable.  */
+    char pr_psargs[80];			/* Initial part of arg list.  */
+  };
+
+/* Helper macro to swap (properly handling endianess) things from the
+   `elf_internal_linux_prpsinfo' structure to the
+   `elf_external_linux_prpsinfo64' structure.
+
+   Note that FROM should be a pointer, and TO should be the explicit
+   type.  */
+
+#define LINUX_PRPSINFO64_SWAP_FIELDS(abfd, from, to)			\
+  do									\
+    {									\
+      H_PUT_8 (abfd, from->pr_state, &to.pr_state);			\
+      H_PUT_8 (abfd, from->pr_sname, &to.pr_sname);			\
+      H_PUT_8 (abfd, from->pr_zomb, &to.pr_zomb);			\
+      H_PUT_8 (abfd, from->pr_nice, &to.pr_nice);			\
+      H_PUT_64 (abfd, from->pr_flag, to.pr_flag);			\
+      H_PUT_32 (abfd, from->pr_uid, to.pr_uid);				\
+      H_PUT_32 (abfd, from->pr_gid, to.pr_gid);				\
+      H_PUT_32 (abfd, from->pr_pid, to.pr_pid);				\
+      H_PUT_32 (abfd, from->pr_ppid, to.pr_ppid);			\
+      H_PUT_32 (abfd, from->pr_pgrp, to.pr_pgrp);			\
+      H_PUT_32 (abfd, from->pr_sid, to.pr_sid);				\
+      strncpy (to.pr_fname, from->pr_fname, sizeof (to.pr_fname));	\
+      strncpy (to.pr_psargs, from->pr_psargs, sizeof (to.pr_psargs));	\
+    } while (0)
+
+#endif
diff --git a/bfd/elf-m10200.c b/bfd/elf-m10200.c
index a38f4db..f427f97 100644
--- a/bfd/elf-m10200.c
+++ b/bfd/elf-m10200.c
@@ -1,6 +1,6 @@
 /* Matsushita 10200 specific support for 32-bit ELF
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2007, 2010
+   2007, 2010, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -25,29 +25,13 @@
 #include "libbfd.h"
 #include "elf-bfd.h"
 
-static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
-  PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
-static void mn10200_info_to_howto
-  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
-static bfd_boolean mn10200_elf_relax_delete_bytes
-  PARAMS ((bfd *, asection *, bfd_vma, int));
-static bfd_boolean mn10200_elf_symbol_address_p
-  PARAMS ((bfd *, asection *, Elf_Internal_Sym *, bfd_vma));
-static bfd_reloc_status_type mn10200_elf_final_link_relocate
-  PARAMS ((reloc_howto_type *, bfd *, bfd *, asection *,
-	   bfd_byte *, bfd_vma, bfd_vma, bfd_vma,
-	   struct bfd_link_info *, asection *, int));
-static bfd_boolean mn10200_elf_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
-	   bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *,
-	   asection **));
-static bfd_boolean mn10200_elf_relax_section
-  PARAMS ((bfd *, asection *, struct bfd_link_info *, bfd_boolean *));
-static bfd_byte * mn10200_elf_get_relocated_section_contents
-  PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
-	   bfd_byte *, bfd_boolean, asymbol **));
+static bfd_boolean
+mn10200_elf_relax_delete_bytes (bfd *, asection *, bfd_vma, int);
+static bfd_boolean
+mn10200_elf_symbol_address_p (bfd *, asection *, Elf_Internal_Sym *, bfd_vma);
 
-enum reloc_type {
+enum reloc_type
+{
   R_MN10200_NONE = 0,
   R_MN10200_32,
   R_MN10200_16,
@@ -59,7 +43,8 @@
   R_MN10200_MAX
 };
 
-static reloc_howto_type elf_mn10200_howto_table[] = {
+static reloc_howto_type elf_mn10200_howto_table[] =
+{
   /* Dummy relocation.  Does nothing.  */
   HOWTO (R_MN10200_NONE,
 	 0,
@@ -175,12 +160,14 @@
 	 TRUE),
 };
 
-struct mn10200_reloc_map {
+struct mn10200_reloc_map
+{
   bfd_reloc_code_real_type bfd_reloc_val;
   unsigned char elf_reloc_val;
 };
 
-static const struct mn10200_reloc_map mn10200_reloc_map[] = {
+static const struct mn10200_reloc_map mn10200_reloc_map[] =
+{
   { BFD_RELOC_NONE    , R_MN10200_NONE   , },
   { BFD_RELOC_32      , R_MN10200_32     , },
   { BFD_RELOC_16      , R_MN10200_16     , },
@@ -192,9 +179,8 @@
 };
 
 static reloc_howto_type *
-bfd_elf32_bfd_reloc_type_lookup (abfd, code)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+				 bfd_reloc_code_real_type code)
 {
   unsigned int i;
 
@@ -229,10 +215,9 @@
 /* Set the howto pointer for an MN10200 ELF reloc.  */
 
 static void
-mn10200_info_to_howto (abfd, cache_ptr, dst)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *cache_ptr;
-     Elf_Internal_Rela *dst;
+mn10200_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+		       arelent *cache_ptr,
+		       Elf_Internal_Rela *dst)
 {
   unsigned int r_type;
 
@@ -244,20 +229,17 @@
 /* Perform a relocation as part of a final link.  */
 
 static bfd_reloc_status_type
-mn10200_elf_final_link_relocate (howto, input_bfd, output_bfd,
-				 input_section, contents, offset, value,
-				 addend, info, sym_sec, is_local)
-     reloc_howto_type *howto;
-     bfd *input_bfd;
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     asection *input_section;
-     bfd_byte *contents;
-     bfd_vma offset;
-     bfd_vma value;
-     bfd_vma addend;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     asection *sym_sec ATTRIBUTE_UNUSED;
-     int is_local ATTRIBUTE_UNUSED;
+mn10200_elf_final_link_relocate (reloc_howto_type *howto,
+				 bfd *input_bfd,
+				 bfd *output_bfd ATTRIBUTE_UNUSED,
+				 asection *input_section,
+				 bfd_byte *contents,
+				 bfd_vma offset,
+				 bfd_vma value,
+				 bfd_vma addend,
+				 struct bfd_link_info *info ATTRIBUTE_UNUSED,
+				 asection *sym_sec ATTRIBUTE_UNUSED,
+				 int is_local ATTRIBUTE_UNUSED)
 {
   unsigned long r_type = howto->type;
   bfd_byte *hit_data = contents + offset;
@@ -347,16 +329,14 @@
 
 /* Relocate an MN10200 ELF section.  */
 static bfd_boolean
-mn10200_elf_relocate_section (output_bfd, info, input_bfd, input_section,
-			      contents, relocs, local_syms, local_sections)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     Elf_Internal_Rela *relocs;
-     Elf_Internal_Sym *local_syms;
-     asection **local_sections;
+mn10200_elf_relocate_section (bfd *output_bfd,
+			      struct bfd_link_info *info,
+			      bfd *input_bfd,
+			      asection *input_section,
+			      bfd_byte *contents,
+			      Elf_Internal_Rela *relocs,
+			      Elf_Internal_Sym *local_syms,
+			      asection **local_sections)
 {
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
@@ -401,9 +381,9 @@
 				   unresolved_reloc, warned);
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -475,6 +455,78 @@
   return TRUE;
 }
 
+/* Delete some bytes from a section while relaxing.  */
+
+static bfd_boolean
+mn10200_elf_relax_delete_bytes (bfd *abfd, asection *sec,
+				bfd_vma addr, int count)
+{
+  Elf_Internal_Shdr *symtab_hdr;
+  unsigned int sec_shndx;
+  bfd_byte *contents;
+  Elf_Internal_Rela *irel, *irelend;
+  bfd_vma toaddr;
+  Elf_Internal_Sym *isym;
+  Elf_Internal_Sym *isymend;
+  struct elf_link_hash_entry **sym_hashes;
+  struct elf_link_hash_entry **end_hashes;
+  unsigned int symcount;
+
+  sec_shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
+
+  contents = elf_section_data (sec)->this_hdr.contents;
+
+  toaddr = sec->size;
+
+  irel = elf_section_data (sec)->relocs;
+  irelend = irel + sec->reloc_count;
+
+  /* Actually delete the bytes.  */
+  memmove (contents + addr, contents + addr + count,
+	   (size_t) (toaddr - addr - count));
+  sec->size -= count;
+
+  /* Adjust all the relocs.  */
+  for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++)
+    {
+      /* Get the new reloc address.  */
+      if ((irel->r_offset > addr
+	   && irel->r_offset < toaddr))
+	irel->r_offset -= count;
+    }
+
+  /* Adjust the local symbols defined in this section.  */
+  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+  isym = (Elf_Internal_Sym *) symtab_hdr->contents;
+  for (isymend = isym + symtab_hdr->sh_info; isym < isymend; isym++)
+    {
+      if (isym->st_shndx == sec_shndx
+	  && isym->st_value > addr
+	  && isym->st_value < toaddr)
+	isym->st_value -= count;
+    }
+
+  /* Now adjust the global symbols defined in this section.  */
+  symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)
+	      - symtab_hdr->sh_info);
+  sym_hashes = elf_sym_hashes (abfd);
+  end_hashes = sym_hashes + symcount;
+  for (; sym_hashes < end_hashes; sym_hashes++)
+    {
+      struct elf_link_hash_entry *sym_hash = *sym_hashes;
+      if ((sym_hash->root.type == bfd_link_hash_defined
+	   || sym_hash->root.type == bfd_link_hash_defweak)
+	  && sym_hash->root.u.def.section == sec
+	  && sym_hash->root.u.def.value > addr
+	  && sym_hash->root.u.def.value < toaddr)
+	{
+	  sym_hash->root.u.def.value -= count;
+	}
+    }
+
+  return TRUE;
+}
+
 /* This function handles relaxing for the mn10200.
 
    There are quite a few relaxing opportunities available on the mn10200:
@@ -505,11 +557,10 @@
 	and somewhat more difficult to support.  */
 
 static bfd_boolean
-mn10200_elf_relax_section (abfd, sec, link_info, again)
-     bfd *abfd;
-     asection *sec;
-     struct bfd_link_info *link_info;
-     bfd_boolean *again;
+mn10200_elf_relax_section (bfd *abfd,
+			   asection *sec,
+			   struct bfd_link_info *link_info,
+			   bfd_boolean *again)
 {
   Elf_Internal_Shdr *symtab_hdr;
   Elf_Internal_Rela *internal_relocs;
@@ -533,7 +584,7 @@
 
   /* Get a copy of the native relocations.  */
   internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
 		      link_info->keep_memory));
   if (internal_relocs == NULL)
     goto error_return;
@@ -1174,89 +1225,13 @@
   return FALSE;
 }
 
-/* Delete some bytes from a section while relaxing.  */
-
-static bfd_boolean
-mn10200_elf_relax_delete_bytes (abfd, sec, addr, count)
-     bfd *abfd;
-     asection *sec;
-     bfd_vma addr;
-     int count;
-{
-  Elf_Internal_Shdr *symtab_hdr;
-  unsigned int sec_shndx;
-  bfd_byte *contents;
-  Elf_Internal_Rela *irel, *irelend;
-  bfd_vma toaddr;
-  Elf_Internal_Sym *isym;
-  Elf_Internal_Sym *isymend;
-  struct elf_link_hash_entry **sym_hashes;
-  struct elf_link_hash_entry **end_hashes;
-  unsigned int symcount;
-
-  sec_shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
-
-  contents = elf_section_data (sec)->this_hdr.contents;
-
-  toaddr = sec->size;
-
-  irel = elf_section_data (sec)->relocs;
-  irelend = irel + sec->reloc_count;
-
-  /* Actually delete the bytes.  */
-  memmove (contents + addr, contents + addr + count,
-	   (size_t) (toaddr - addr - count));
-  sec->size -= count;
-
-  /* Adjust all the relocs.  */
-  for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++)
-    {
-      /* Get the new reloc address.  */
-      if ((irel->r_offset > addr
-	   && irel->r_offset < toaddr))
-	irel->r_offset -= count;
-    }
-
-  /* Adjust the local symbols defined in this section.  */
-  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
-  isym = (Elf_Internal_Sym *) symtab_hdr->contents;
-  for (isymend = isym + symtab_hdr->sh_info; isym < isymend; isym++)
-    {
-      if (isym->st_shndx == sec_shndx
-	  && isym->st_value > addr
-	  && isym->st_value < toaddr)
-	isym->st_value -= count;
-    }
-
-  /* Now adjust the global symbols defined in this section.  */
-  symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)
-	      - symtab_hdr->sh_info);
-  sym_hashes = elf_sym_hashes (abfd);
-  end_hashes = sym_hashes + symcount;
-  for (; sym_hashes < end_hashes; sym_hashes++)
-    {
-      struct elf_link_hash_entry *sym_hash = *sym_hashes;
-      if ((sym_hash->root.type == bfd_link_hash_defined
-	   || sym_hash->root.type == bfd_link_hash_defweak)
-	  && sym_hash->root.u.def.section == sec
-	  && sym_hash->root.u.def.value > addr
-	  && sym_hash->root.u.def.value < toaddr)
-	{
-	  sym_hash->root.u.def.value -= count;
-	}
-    }
-
-  return TRUE;
-}
-
 /* Return TRUE if a symbol exists at the given address, else return
    FALSE.  */
 static bfd_boolean
-mn10200_elf_symbol_address_p (abfd, sec, isym, addr)
-     bfd *abfd;
-     asection *sec;
-     Elf_Internal_Sym *isym;
-     bfd_vma addr;
+mn10200_elf_symbol_address_p (bfd *abfd,
+			      asection *sec,
+			      Elf_Internal_Sym *isym,
+			      bfd_vma addr)
 {
   Elf_Internal_Shdr *symtab_hdr;
   unsigned int sec_shndx;
@@ -1297,14 +1272,12 @@
    which uses mn10200_elf_relocate_section.  */
 
 static bfd_byte *
-mn10200_elf_get_relocated_section_contents (output_bfd, link_info, link_order,
-					    data, relocatable, symbols)
-     bfd *output_bfd;
-     struct bfd_link_info *link_info;
-     struct bfd_link_order *link_order;
-     bfd_byte *data;
-     bfd_boolean relocatable;
-     asymbol **symbols;
+mn10200_elf_get_relocated_section_contents (bfd *output_bfd,
+					    struct bfd_link_info *link_info,
+					    struct bfd_link_order *link_order,
+					    bfd_byte *data,
+					    bfd_boolean relocatable,
+					    asymbol **symbols)
 {
   Elf_Internal_Shdr *symtab_hdr;
   asection *input_section = link_order->u.indirect.section;
@@ -1336,7 +1309,7 @@
       bfd_size_type amt;
 
       internal_relocs = (_bfd_elf_link_read_relocs
-			 (input_bfd, input_section, (PTR) NULL,
+			 (input_bfd, input_section, NULL,
 			  (Elf_Internal_Rela *) NULL, FALSE));
       if (internal_relocs == NULL)
 	goto error_return;
diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c
index 8276a2f..c0a9309 100644
--- a/bfd/elf-m10300.c
+++ b/bfd/elf-m10300.c
@@ -1,6 +1,6 @@
 /* Matsushita 10300 specific support for 32-bit ELF
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+   2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -69,6 +69,14 @@
 
   /* Calculated value.  */
   bfd_vma value;
+
+#define GOT_UNKNOWN	0
+#define GOT_NORMAL	1
+#define GOT_TLS_GD	2
+#define GOT_TLS_LD	3
+#define GOT_TLS_IE	4
+  /* Used to distinguish GOT entries for TLS types from normal GOT entries.  */
+  unsigned char tls_type;
 };
 
 /* We derive a hash table from the main elf linker hash table so
@@ -87,8 +95,31 @@
   /* Random linker state flags.  */
 #define MN10300_HASH_ENTRIES_INITIALIZED 0x1
   char flags;
+  struct
+  {
+    bfd_signed_vma  refcount;
+    bfd_vma         offset;
+    char            got_allocated;
+    char            rel_emitted;
+  } tls_ldm_got;
 };
 
+#define elf_mn10300_hash_entry(ent) ((struct elf32_mn10300_link_hash_entry *)(ent))
+
+struct elf_mn10300_obj_tdata
+{
+  struct elf_obj_tdata root;
+
+  /* tls_type for each local got entry.  */
+  char * local_got_tls_type;
+};
+
+#define elf_mn10300_tdata(abfd) \
+  ((struct elf_mn10300_obj_tdata *) (abfd)->tdata.any)
+
+#define elf_mn10300_local_got_tls_type(abfd) \
+  (elf_mn10300_tdata (abfd)->local_got_tls_type)
+
 #ifndef streq
 #define streq(a, b) (strcmp ((a),(b)) == 0)
 #endif
@@ -448,16 +479,132 @@
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  EMPTY_HOWTO (24),
-  EMPTY_HOWTO (25),
-  EMPTY_HOWTO (26),
-  EMPTY_HOWTO (27),
-  EMPTY_HOWTO (28),
-  EMPTY_HOWTO (29),
-  EMPTY_HOWTO (30),
-  EMPTY_HOWTO (31),
-  EMPTY_HOWTO (32),
-  
+  HOWTO (R_MN10300_TLS_GD,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* */
+	 "R_MN10300_TLS_GD",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_MN10300_TLS_LD,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* */
+	 "R_MN10300_TLS_LD",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_MN10300_TLS_LDO,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* */
+	 "R_MN10300_TLS_LDO",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_MN10300_TLS_GOTIE,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* */
+	 "R_MN10300_TLS_GOTIE",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_MN10300_TLS_IE,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* */
+	 "R_MN10300_TLS_IE",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_MN10300_TLS_LE,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* */
+	 "R_MN10300_TLS_LE",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_MN10300_TLS_DTPMOD,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* */
+	 "R_MN10300_TLS_DTPMOD",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_MN10300_TLS_DTPOFF,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* */
+	 "R_MN10300_TLS_DTPOFF",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_MN10300_TLS_TPOFF,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* */
+	 "R_MN10300_TLS_TPOFF",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
   HOWTO (R_MN10300_SYM_DIFF,	/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -519,6 +666,15 @@
   { BFD_RELOC_MN10300_GLOB_DAT, R_MN10300_GLOB_DAT },
   { BFD_RELOC_MN10300_JMP_SLOT, R_MN10300_JMP_SLOT },
   { BFD_RELOC_MN10300_RELATIVE, R_MN10300_RELATIVE },
+  { BFD_RELOC_MN10300_TLS_GD, R_MN10300_TLS_GD },
+  { BFD_RELOC_MN10300_TLS_LD, R_MN10300_TLS_LD },
+  { BFD_RELOC_MN10300_TLS_LDO, R_MN10300_TLS_LDO },
+  { BFD_RELOC_MN10300_TLS_GOTIE, R_MN10300_TLS_GOTIE },
+  { BFD_RELOC_MN10300_TLS_IE, R_MN10300_TLS_IE },
+  { BFD_RELOC_MN10300_TLS_LE, R_MN10300_TLS_LE },
+  { BFD_RELOC_MN10300_TLS_DTPMOD, R_MN10300_TLS_DTPMOD },
+  { BFD_RELOC_MN10300_TLS_DTPOFF, R_MN10300_TLS_DTPOFF },
+  { BFD_RELOC_MN10300_TLS_TPOFF, R_MN10300_TLS_TPOFF },
   { BFD_RELOC_MN10300_SYM_DIFF, R_MN10300_SYM_DIFF },
   { BFD_RELOC_MN10300_ALIGN, R_MN10300_ALIGN }
 };
@@ -534,10 +690,12 @@
   asection * s;
   struct elf_link_hash_entry * h;
   const struct elf_backend_data * bed = get_elf_backend_data (abfd);
+  struct elf_link_hash_table *htab;
   int ptralign;
 
   /* This function may be called more than once.  */
-  if (bfd_get_section_by_name (abfd, ".got") != NULL)
+  htab = elf_hash_table (info);
+  if (htab->sgot != NULL)
     return TRUE;
 
   switch (bed->s->arch_size)
@@ -565,7 +723,8 @@
   if (bed->plt_readonly)
     pltflags |= SEC_READONLY;
 
-  s = bfd_make_section_with_flags (abfd, ".plt", pltflags);
+  s = bfd_make_section_anyway_with_flags (abfd, ".plt", pltflags);
+  htab->splt = s;
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
     return FALSE;
@@ -576,19 +735,21 @@
     {
       h = _bfd_elf_define_linkage_sym (abfd, info, s,
 				       "_PROCEDURE_LINKAGE_TABLE_");
-      elf_hash_table (info)->hplt = h;
+      htab->hplt = h;
       if (h == NULL)
 	return FALSE;
     }
 
-  s = bfd_make_section_with_flags (abfd, ".got", flags);
+  s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
+  htab->sgot = s;
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, ptralign))
     return FALSE;
 
   if (bed->want_got_plt)
     {
-      s = bfd_make_section_with_flags (abfd, ".got.plt", flags);
+      s = bfd_make_section_anyway_with_flags (abfd, ".got.plt", flags);
+      htab->sgotplt = s;
       if (s == NULL
 	  || ! bfd_set_section_alignment (abfd, s, ptralign))
 	return FALSE;
@@ -599,7 +760,7 @@
      because we don't want to define the symbol if we are not creating
      a global offset table.  */
   h = _bfd_elf_define_linkage_sym (abfd, info, s, "_GLOBAL_OFFSET_TABLE_");
-  elf_hash_table (info)->hgot = h;
+  htab->hgot = h;
   if (h == NULL)
     return FALSE;
 
@@ -650,6 +811,223 @@
   cache_ptr->howto = elf_mn10300_howto_table + r_type;
 }
 
+static int
+elf_mn10300_tls_transition (struct bfd_link_info *        info,
+			    int                           r_type,
+			    struct elf_link_hash_entry *  h,
+			    asection *                    sec,
+			    bfd_boolean                   counting)
+{
+  bfd_boolean is_local;
+
+  if (r_type == R_MN10300_TLS_GD
+      && h != NULL
+      && elf_mn10300_hash_entry (h)->tls_type == GOT_TLS_IE)
+    return R_MN10300_TLS_GOTIE;
+
+  if (info->shared)
+    return r_type;
+
+  if (! (sec->flags & SEC_CODE))
+    return r_type;
+
+  if (! counting && h != NULL && ! elf_hash_table (info)->dynamic_sections_created)
+    is_local = TRUE;
+  else
+    is_local = SYMBOL_CALLS_LOCAL (info, h);
+
+  /* For the main program, these are the transitions we do.  */
+  switch (r_type)
+    {
+    case R_MN10300_TLS_GD: return is_local ? R_MN10300_TLS_LE : R_MN10300_TLS_GOTIE;
+    case R_MN10300_TLS_LD: return R_MN10300_NONE;
+    case R_MN10300_TLS_LDO: return R_MN10300_TLS_LE;
+    case R_MN10300_TLS_IE:
+    case R_MN10300_TLS_GOTIE: return is_local ? R_MN10300_TLS_LE : r_type;
+    }
+
+  return r_type;
+}
+
+/* Return the relocation value for @tpoff relocation
+   if STT_TLS virtual address is ADDRESS.  */
+
+static bfd_vma
+dtpoff (struct bfd_link_info * info, bfd_vma address)
+{
+  struct elf_link_hash_table *htab = elf_hash_table (info);
+
+  /* If tls_sec is NULL, we should have signalled an error already.  */
+  if (htab->tls_sec == NULL)
+    return 0;
+  return address - htab->tls_sec->vma;
+}
+
+/* Return the relocation value for @tpoff relocation
+   if STT_TLS virtual address is ADDRESS.  */
+
+static bfd_vma
+tpoff (struct bfd_link_info * info, bfd_vma address)
+{
+  struct elf_link_hash_table *htab = elf_hash_table (info);
+
+  /* If tls_sec is NULL, we should have signalled an error already.  */
+  if (htab->tls_sec == NULL)
+    return 0;
+  return address - (htab->tls_size + htab->tls_sec->vma);
+}
+
+/* Returns nonzero if there's a R_MN10300_PLT32 reloc that we now need
+   to skip, after this one.  The actual value is the offset between
+   this reloc and the PLT reloc.  */
+
+static int
+mn10300_do_tls_transition (bfd *         input_bfd,
+			   unsigned int  r_type,
+			   unsigned int  tls_r_type,
+			   bfd_byte *    contents,
+			   bfd_vma       offset)
+{
+  bfd_byte *op = contents + offset;
+  int gotreg = 0;
+
+#define TLS_PAIR(r1,r2) ((r1) * R_MN10300_MAX + (r2))
+
+  /* This is common to all GD/LD transitions, so break it out.  */
+  if (r_type == R_MN10300_TLS_GD
+      || r_type == R_MN10300_TLS_LD)
+    {
+      op -= 2;
+      /* mov imm,d0.  */
+      BFD_ASSERT (bfd_get_8 (input_bfd, op) == 0xFC);
+      BFD_ASSERT (bfd_get_8 (input_bfd, op + 1) == 0xCC);
+      /* add aN,d0.  */
+      BFD_ASSERT (bfd_get_8 (input_bfd, op + 6) == 0xF1);
+      gotreg = (bfd_get_8 (input_bfd, op + 7) & 0x0c) >> 2;
+      /* Call.  */
+      BFD_ASSERT (bfd_get_8 (input_bfd, op + 8) == 0xDD);
+    }
+
+  switch (TLS_PAIR (r_type, tls_r_type))
+    {
+    case TLS_PAIR (R_MN10300_TLS_GD, R_MN10300_TLS_GOTIE):
+      {
+	/* Keep track of which register we put GOTptr in.  */
+	/* mov (_x@indntpoff,a2),a0.  */
+	memcpy (op, "\xFC\x20\x00\x00\x00\x00", 6);
+	op[1] |= gotreg;
+	/* add e2,a0.  */
+	memcpy (op+6, "\xF9\x78\x28", 3);
+	/* or  0x00000000, d0 - six byte nop.  */
+	memcpy (op+9, "\xFC\xE4\x00\x00\x00\x00", 6);
+      }
+      return 7;
+
+    case TLS_PAIR (R_MN10300_TLS_GD, R_MN10300_TLS_LE):
+      {
+	/* Register is *always* a0.  */
+	/* mov _x@tpoff,a0.  */
+	memcpy (op, "\xFC\xDC\x00\x00\x00\x00", 6);
+	/* add e2,a0.  */
+	memcpy (op+6, "\xF9\x78\x28", 3);
+	/* or  0x00000000, d0 - six byte nop.  */
+	memcpy (op+9, "\xFC\xE4\x00\x00\x00\x00", 6);
+      }
+      return 7;
+    case TLS_PAIR (R_MN10300_TLS_LD, R_MN10300_NONE):
+      {
+	/* Register is *always* a0.  */
+	/* mov e2,a0.  */
+	memcpy (op, "\xF5\x88", 2);
+	/* or  0x00000000, d0 - six byte nop.  */
+	memcpy (op+2, "\xFC\xE4\x00\x00\x00\x00", 6);
+	/* or  0x00000000, e2 - seven byte nop.  */
+	memcpy (op+8, "\xFE\x19\x22\x00\x00\x00\x00", 7);
+      }
+      return 7;
+
+    case TLS_PAIR (R_MN10300_TLS_LDO, R_MN10300_TLS_LE):
+      /* No changes needed, just the reloc change.  */
+      return 0;
+
+    /*  These are a little tricky, because we have to detect which
+	opcode is being used (they're different sizes, with the reloc
+	at different offsets within the opcode) and convert each
+	accordingly, copying the operands as needed.  The conversions
+	we do are as follows (IE,GOTIE,LE):
+
+	           1111 1100  1010 01Dn  [-- abs32 --]  MOV (x@indntpoff),Dn
+	           1111 1100  0000 DnAm  [-- abs32 --]  MOV (x@gotntpoff,Am),Dn
+	           1111 1100  1100 11Dn  [-- abs32 --]  MOV x@tpoff,Dn
+
+	           1111 1100  1010 00An  [-- abs32 --]  MOV (x@indntpoff),An
+	           1111 1100  0010 AnAm  [-- abs32 --]  MOV (x@gotntpoff,Am),An
+	           1111 1100  1101 11An  [-- abs32 --]  MOV x@tpoff,An
+
+	1111 1110  0000 1110  Rnnn Xxxx  [-- abs32 --]  MOV (x@indntpoff),Rn
+	1111 1110  0000 1010  Rnnn Rmmm  [-- abs32 --]  MOV (x@indntpoff,Rm),Rn
+	1111 1110  0000 1000  Rnnn Xxxx  [-- abs32 --]  MOV x@tpoff,Rn
+
+	Since the GOT pointer is always $a2, we assume the last
+	normally won't happen, but let's be paranoid and plan for the
+	day that GCC optimizes it somewhow.  */
+
+    case TLS_PAIR (R_MN10300_TLS_IE, R_MN10300_TLS_LE):
+      if (op[-2] == 0xFC)
+	{
+	  op -= 2;
+	  if ((op[1] & 0xFC) == 0xA4) /* Dn */
+	    {
+	      op[1] &= 0x03; /* Leaves Dn.  */
+	      op[1] |= 0xCC;
+	    }
+	  else /* An */
+	    {
+	      op[1] &= 0x03; /* Leaves An. */
+	      op[1] |= 0xDC;
+	    }
+	}
+      else if (op[-3] == 0xFE)
+	op[-2] = 0x08;
+      else
+	abort ();
+      break;
+
+    case TLS_PAIR (R_MN10300_TLS_GOTIE, R_MN10300_TLS_LE):
+      if (op[-2] == 0xFC)
+	{
+	  op -= 2;
+	  if ((op[1] & 0xF0) == 0x00) /* Dn */
+	    {
+	      op[1] &= 0x0C; /* Leaves Dn.  */
+	      op[1] >>= 2;
+	      op[1] |= 0xCC;
+	    }
+	  else /* An */
+	    {
+	      op[1] &= 0x0C; /* Leaves An.  */
+	      op[1] >>= 2;
+	      op[1] |= 0xDC;
+	    }
+	}
+      else if (op[-3] == 0xFE)
+	op[-2] = 0x08;
+      else
+	abort ();
+      break;
+
+    default:
+      (*_bfd_error_handler)
+	(_("%s: Unsupported transition from %s to %s"),
+	 bfd_get_filename (input_bfd),
+	 elf_mn10300_howto_table[r_type].name,
+	 elf_mn10300_howto_table[tls_r_type].name);
+      break;
+    }
+#undef TLS_PAIR
+  return 0;
+}
+
 /* Look through the relocs for a section during the first phase.
    Since we don't do .gots or .plts, we just need to consider the
    virtual table relocs for gc.  */
@@ -660,6 +1038,7 @@
 			  asection *sec,
 			  const Elf_Internal_Rela *relocs)
 {
+  struct elf32_mn10300_link_hash_table * htab = elf32_mn10300_hash_table (info);
   bfd_boolean sym_diff_reloc_seen;
   Elf_Internal_Shdr *symtab_hdr;
   Elf_Internal_Sym * isymbuf = NULL;
@@ -694,6 +1073,7 @@
       struct elf_link_hash_entry *h;
       unsigned long r_symndx;
       unsigned int r_type;
+      int tls_type = GOT_NORMAL;
 
       r_symndx = ELF32_R_SYM (rel->r_info);
       if (r_symndx < symtab_hdr->sh_info)
@@ -704,9 +1084,14 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       r_type = ELF32_R_TYPE (rel->r_info);
+      r_type = elf_mn10300_tls_transition (info, r_type, h, sec, TRUE);
 
       /* Some relocs require a global offset table.  */
       if (dynobj == NULL)
@@ -721,6 +1106,10 @@
 	    case R_MN10300_GOTOFF16:
 	    case R_MN10300_GOTPC32:
 	    case R_MN10300_GOTPC16:
+	    case R_MN10300_TLS_GD:
+	    case R_MN10300_TLS_LD:
+	    case R_MN10300_TLS_GOTIE:
+	    case R_MN10300_TLS_IE:
 	      elf_hash_table (info)->dynobj = dynobj = abfd;
 	      if (! _bfd_mn10300_elf_create_got_section (dynobj, info))
 		goto fail;
@@ -749,53 +1138,101 @@
 	    goto fail;
 	  break;
 
+	case R_MN10300_TLS_LD:
+	  htab->tls_ldm_got.refcount ++;
+	  tls_type = GOT_TLS_LD;
+
+	  if (htab->tls_ldm_got.got_allocated)
+	    break;
+	  goto create_got;
+
+	case R_MN10300_TLS_IE:
+	case R_MN10300_TLS_GOTIE:
+	  if (info->shared)
+	    info->flags |= DF_STATIC_TLS;
+	  /* Fall through */
+
+	case R_MN10300_TLS_GD:
 	case R_MN10300_GOT32:
 	case R_MN10300_GOT24:
 	case R_MN10300_GOT16:
+	create_got:
 	  /* This symbol requires a global offset table entry.  */
 
+	  switch (r_type)
+	    {
+	    case R_MN10300_TLS_IE:
+	    case R_MN10300_TLS_GOTIE: tls_type = GOT_TLS_IE; break;
+	    case R_MN10300_TLS_GD:    tls_type = GOT_TLS_GD; break;
+	    default:                  tls_type = GOT_NORMAL; break;
+	    }
+
 	  if (sgot == NULL)
 	    {
-	      sgot = bfd_get_section_by_name (dynobj, ".got");
+	      sgot = htab->root.sgot;
 	      BFD_ASSERT (sgot != NULL);
 	    }
 
 	  if (srelgot == NULL
 	      && (h != NULL || info->shared))
 	    {
-	      srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+	      srelgot = bfd_get_linker_section (dynobj, ".rela.got");
 	      if (srelgot == NULL)
 		{
-		  srelgot = bfd_make_section_with_flags (dynobj,
-							 ".rela.got",
-							 (SEC_ALLOC
-							  | SEC_LOAD
-							  | SEC_HAS_CONTENTS
-							  | SEC_IN_MEMORY
-							  | SEC_LINKER_CREATED
-							  | SEC_READONLY));
+		  flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+				    | SEC_IN_MEMORY | SEC_LINKER_CREATED
+				    | SEC_READONLY);
+		  srelgot = bfd_make_section_anyway_with_flags (dynobj,
+								".rela.got",
+								flags);
 		  if (srelgot == NULL
 		      || ! bfd_set_section_alignment (dynobj, srelgot, 2))
 		    goto fail;
 		}
 	    }
 
-	  if (h != NULL)
+	  if (r_type == R_MN10300_TLS_LD)
 	    {
+	      htab->tls_ldm_got.offset = sgot->size;
+	      htab->tls_ldm_got.got_allocated ++;
+	    }
+	  else if (h != NULL)
+	    {
+	      if (elf_mn10300_hash_entry (h)->tls_type != tls_type
+		  && elf_mn10300_hash_entry (h)->tls_type != GOT_UNKNOWN)
+		{
+		  if (tls_type == GOT_TLS_IE
+		      && elf_mn10300_hash_entry (h)->tls_type == GOT_TLS_GD)
+		    /* No change - this is ok.  */;
+		  else if (tls_type == GOT_TLS_GD
+		      && elf_mn10300_hash_entry (h)->tls_type == GOT_TLS_IE)
+		    /* Transition GD->IE.  */
+		    tls_type = GOT_TLS_IE;
+		  else
+		    (*_bfd_error_handler)
+		      (_("%B: %s' accessed both as normal and thread local symbol"),
+		       abfd, h ? h->root.root.string : "<local>");
+		}
+
+	      elf_mn10300_hash_entry (h)->tls_type = tls_type;
+
 	      if (h->got.offset != (bfd_vma) -1)
 		/* We have already allocated space in the .got.  */
 		break;
 
 	      h->got.offset = sgot->size;
 
-	      /* Make sure this symbol is output as a dynamic symbol.  */
-	      if (h->dynindx == -1)
+	      if (ELF_ST_VISIBILITY (h->other) != STV_INTERNAL
+		  /* Make sure this symbol is output as a dynamic symbol.  */
+		  && h->dynindx == -1)
 		{
 		  if (! bfd_elf_link_record_dynamic_symbol (info, h))
 		    goto fail;
 		}
 
 	      srelgot->size += sizeof (Elf32_External_Rela);
+	      if (r_type == R_MN10300_TLS_GD)
+		srelgot->size += sizeof (Elf32_External_Rela);
 	    }
 	  else
 	    {
@@ -806,13 +1243,15 @@
 		  size_t       size;
 		  unsigned int i;
 
-		  size = symtab_hdr->sh_info * sizeof (bfd_vma);
+		  size = symtab_hdr->sh_info * (sizeof (bfd_vma) + sizeof (char));
 		  local_got_offsets = bfd_alloc (abfd, size);
 
 		  if (local_got_offsets == NULL)
 		    goto fail;
 
 		  elf_local_got_offsets (abfd) = local_got_offsets;
+		  elf_mn10300_local_got_tls_type (abfd)
+		      = (char *) (local_got_offsets + symtab_hdr->sh_info);
 
 		  for (i = 0; i < symtab_hdr->sh_info; i++)
 		    local_got_offsets[i] = (bfd_vma) -1;
@@ -825,14 +1264,26 @@
 	      local_got_offsets[r_symndx] = sgot->size;
 
 	      if (info->shared)
-		/* If we are generating a shared object, we need to
-		   output a R_MN10300_RELATIVE reloc so that the dynamic
-		   linker can adjust this GOT entry.  */
-		srelgot->size += sizeof (Elf32_External_Rela);
+		{
+		  /* If we are generating a shared object, we need to
+		     output a R_MN10300_RELATIVE reloc so that the dynamic
+		     linker can adjust this GOT entry.  */
+		  srelgot->size += sizeof (Elf32_External_Rela);
+
+		  if (r_type == R_MN10300_TLS_GD)
+		    /* And a R_MN10300_TLS_DTPOFF reloc as well.  */
+		    srelgot->size += sizeof (Elf32_External_Rela);
+		}
+
+	      elf_mn10300_local_got_tls_type (abfd) [r_symndx] = tls_type;
 	    }
 
 	  sgot->size += 4;
-	  break;
+	  if (r_type == R_MN10300_TLS_GD
+	      || r_type == R_MN10300_TLS_LD)
+	    sgot->size += 4;
+
+	  goto need_shared_relocs;
 
 	case R_MN10300_PLT32:
 	case R_MN10300_PLT16:
@@ -873,6 +1324,7 @@
 	  if (h != NULL)
 	    h->non_got_ref = 1;
 
+	need_shared_relocs:
 	  /* If we are creating a shared library, then we
 	     need to copy the reloc into the shared library.  */
 	  if (info->shared
@@ -981,6 +1433,7 @@
 				 asection *sym_sec ATTRIBUTE_UNUSED,
 				 int is_local ATTRIBUTE_UNUSED)
 {
+  struct elf32_mn10300_link_hash_table * htab = elf32_mn10300_hash_table (info);
   static asection *  sym_diff_section;
   static bfd_vma     sym_diff_value;
   bfd_boolean is_sym_diff_reloc;
@@ -1012,6 +1465,17 @@
 	  && h != NULL
 	  && ! SYMBOL_REFERENCES_LOCAL (info, h))
 	return bfd_reloc_dangerous;
+    case R_MN10300_GOT32:
+      /* Issue 2052223:
+	 Taking the address of a protected function in a shared library
+	 is illegal.  Issue an error message here.  */
+      if (info->shared
+	  && (input_section->flags & SEC_ALLOC) != 0
+	  && h != NULL
+	  && ELF_ST_VISIBILITY (h->other) == STV_PROTECTED
+	  && (h->type == STT_FUNC || h->type == STT_GNU_IFUNC)
+	  && ! SYMBOL_REFERENCES_LOCAL (info, h))
+	return bfd_reloc_dangerous;
     }
 
   is_sym_diff_reloc = FALSE;
@@ -1208,9 +1672,11 @@
       return bfd_reloc_ok;
 
     case R_MN10300_GOTPC32:
+      if (dynobj == NULL)
+	return bfd_reloc_dangerous;
+
       /* Use global offset table as symbol value.  */
-      value = bfd_get_section_by_name (dynobj,
-				       ".got")->output_section->vma;
+      value = htab->root.sgot->output_section->vma;
       value -= (input_section->output_section->vma
 		+ input_section->output_offset);
       value -= offset;
@@ -1220,9 +1686,11 @@
       return bfd_reloc_ok;
 
     case R_MN10300_GOTPC16:
+      if (dynobj == NULL)
+	return bfd_reloc_dangerous;
+
       /* Use global offset table as symbol value.  */
-      value = bfd_get_section_by_name (dynobj,
-				       ".got")->output_section->vma;
+      value = htab->root.sgot->output_section->vma;
       value -= (input_section->output_section->vma
 		+ input_section->output_offset);
       value -= offset;
@@ -1235,16 +1703,20 @@
       return bfd_reloc_ok;
 
     case R_MN10300_GOTOFF32:
-      value -= bfd_get_section_by_name (dynobj,
-					".got")->output_section->vma;
+      if (dynobj == NULL)
+	return bfd_reloc_dangerous;
+
+      value -= htab->root.sgot->output_section->vma;
       value += addend;
 
       bfd_put_32 (input_bfd, value, hit_data);
       return bfd_reloc_ok;
 
     case R_MN10300_GOTOFF24:
-      value -= bfd_get_section_by_name (dynobj,
-					".got")->output_section->vma;
+      if (dynobj == NULL)
+	return bfd_reloc_dangerous;
+
+      value -= htab->root.sgot->output_section->vma;
       value += addend;
 
       if ((long) value > 0x7fffff || (long) value < -0x800000)
@@ -1256,8 +1728,10 @@
       return bfd_reloc_ok;
 
     case R_MN10300_GOTOFF16:
-      value -= bfd_get_section_by_name (dynobj,
-					".got")->output_section->vma;
+      if (dynobj == NULL)
+	return bfd_reloc_dangerous;
+
+      value -= htab->root.sgot->output_section->vma;
       value += addend;
 
       if ((long) value > 0x7fff || (long) value < -0x8000)
@@ -1272,8 +1746,10 @@
 	  && ELF_ST_VISIBILITY (h->other) != STV_HIDDEN
 	  && h->plt.offset != (bfd_vma) -1)
 	{
-	  splt = bfd_get_section_by_name (dynobj, ".plt");
+	  if (dynobj == NULL)
+	    return bfd_reloc_dangerous;
 
+	  splt = htab->root.splt;
 	  value = (splt->output_section->vma
 		   + splt->output_offset
 		   + h->plt.offset) - value;
@@ -1293,8 +1769,10 @@
 	  && ELF_ST_VISIBILITY (h->other) != STV_HIDDEN
 	  && h->plt.offset != (bfd_vma) -1)
 	{
-	  splt = bfd_get_section_by_name (dynobj, ".plt");
+	  if (dynobj == NULL)
+	    return bfd_reloc_dangerous;
 
+	  splt = htab->root.splt;
 	  value = (splt->output_section->vma
 		   + splt->output_offset
 		   + h->plt.offset) - value;
@@ -1311,41 +1789,100 @@
       bfd_put_16 (input_bfd, value, hit_data);
       return bfd_reloc_ok;
 
+    case R_MN10300_TLS_LDO:
+      value = dtpoff (info, value);
+      bfd_put_32 (input_bfd, value + addend, hit_data);
+      return bfd_reloc_ok;
+
+    case R_MN10300_TLS_LE:
+      value = tpoff (info, value);
+      bfd_put_32 (input_bfd, value + addend, hit_data);
+      return bfd_reloc_ok;
+
+    case R_MN10300_TLS_LD:
+      if (dynobj == NULL)
+	return bfd_reloc_dangerous;
+
+      sgot = htab->root.sgot;
+      BFD_ASSERT (sgot != NULL);
+      value = htab->tls_ldm_got.offset + sgot->output_offset;
+      bfd_put_32 (input_bfd, value, hit_data);
+
+      if (!htab->tls_ldm_got.rel_emitted)
+	{
+	  asection * srelgot = bfd_get_linker_section (dynobj, ".rela.got");
+	  Elf_Internal_Rela rel;
+
+	  BFD_ASSERT (srelgot != NULL);
+	  htab->tls_ldm_got.rel_emitted ++;
+	  rel.r_offset = (sgot->output_section->vma
+			  + sgot->output_offset
+			  + htab->tls_ldm_got.offset);
+	  bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + htab->tls_ldm_got.offset);
+	  bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + htab->tls_ldm_got.offset+4);
+	  rel.r_info = ELF32_R_INFO (0, R_MN10300_TLS_DTPMOD);
+	  rel.r_addend = 0;
+	  bfd_elf32_swap_reloca_out (output_bfd, & rel,
+				     (bfd_byte *) ((Elf32_External_Rela *) srelgot->contents
+						   + srelgot->reloc_count));
+	  ++ srelgot->reloc_count;
+	}
+
+      return bfd_reloc_ok;
+
+    case R_MN10300_TLS_GOTIE:
+      value = tpoff (info, value);
+      /* Fall Through.  */
+
+    case R_MN10300_TLS_GD:
+    case R_MN10300_TLS_IE:
     case R_MN10300_GOT32:
     case R_MN10300_GOT24:
     case R_MN10300_GOT16:
-      {
-	sgot = bfd_get_section_by_name (dynobj, ".got");
+      if (dynobj == NULL)
+	return bfd_reloc_dangerous;
 
-	  if (h != NULL)
-	    {
-	      bfd_vma off;
+      sgot = htab->root.sgot;
+      if (r_type == R_MN10300_TLS_GD)
+	value = dtpoff (info, value);
 
-	      off = h->got.offset;
-	      BFD_ASSERT (off != (bfd_vma) -1);
+      if (h != NULL)
+	{
+	  bfd_vma off;
 
-	      if (! elf_hash_table (info)->dynamic_sections_created
-		  || SYMBOL_REFERENCES_LOCAL (info, h))
-		/* This is actually a static link, or it is a
-		   -Bsymbolic link and the symbol is defined
-		   locally, or the symbol was forced to be local
-		   because of a version file.  We must initialize
-		   this entry in the global offset table.
+	  off = h->got.offset;
+	  /* Offsets in the GOT are allocated in check_relocs
+	     which is not called for shared libraries... */
+	  if (off == (bfd_vma) -1)
+	    off = 0;
 
-		   When doing a dynamic link, we create a .rela.got
-		   relocation entry to initialize the value.  This
-		   is done in the finish_dynamic_symbol routine.  */
-		bfd_put_32 (output_bfd, value,
-			    sgot->contents + off);
+	  if (sgot->contents != NULL
+	      && (! elf_hash_table (info)->dynamic_sections_created
+		  || SYMBOL_REFERENCES_LOCAL (info, h)))
+	    /* This is actually a static link, or it is a
+	       -Bsymbolic link and the symbol is defined
+	       locally, or the symbol was forced to be local
+	       because of a version file.  We must initialize
+	       this entry in the global offset table.
 
-	      value = sgot->output_offset + off;
-	    }
+	       When doing a dynamic link, we create a .rela.got
+	       relocation entry to initialize the value.  This
+	       is done in the finish_dynamic_symbol routine.  */
+	    bfd_put_32 (output_bfd, value,
+			sgot->contents + off);
+
+	  value = sgot->output_offset + off;
+	}
+      else
+	{
+	  bfd_vma off;
+
+	  off = elf_local_got_offsets (input_bfd)[symndx];
+
+	  if (off & 1)
+	    bfd_put_32 (output_bfd, value, sgot->contents + (off & ~ 1));
 	  else
 	    {
-	      bfd_vma off;
-
-	      off = elf_local_got_offsets (input_bfd)[symndx];
-
 	      bfd_put_32 (output_bfd, value, sgot->contents + off);
 
 	      if (info->shared)
@@ -1353,28 +1890,64 @@
 		  asection * srelgot;
 		  Elf_Internal_Rela outrel;
 
-		  srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+		  srelgot = bfd_get_linker_section (dynobj, ".rela.got");
 		  BFD_ASSERT (srelgot != NULL);
 
 		  outrel.r_offset = (sgot->output_section->vma
 				     + sgot->output_offset
 				     + off);
-		  outrel.r_info = ELF32_R_INFO (0, R_MN10300_RELATIVE);
+		  switch (r_type)
+		    {
+		    case R_MN10300_TLS_GD:
+		      outrel.r_info = ELF32_R_INFO (0, R_MN10300_TLS_DTPOFF);
+		      outrel.r_offset = (sgot->output_section->vma
+					 + sgot->output_offset
+					 + off + 4);
+		      bfd_elf32_swap_reloca_out (output_bfd, & outrel,
+						 (bfd_byte *) (((Elf32_External_Rela *)
+								srelgot->contents)
+							       + srelgot->reloc_count));
+		      ++ srelgot->reloc_count;
+		      outrel.r_info = ELF32_R_INFO (0, R_MN10300_TLS_DTPMOD);
+		      break;
+		    case R_MN10300_TLS_GOTIE:
+		    case R_MN10300_TLS_IE:
+		      outrel.r_info = ELF32_R_INFO (0, R_MN10300_TLS_TPOFF);
+		      break;
+		    default:
+		      outrel.r_info = ELF32_R_INFO (0, R_MN10300_RELATIVE);
+		      break;
+		    }
+
 		  outrel.r_addend = value;
 		  bfd_elf32_swap_reloca_out (output_bfd, &outrel,
 					     (bfd_byte *) (((Elf32_External_Rela *)
 							    srelgot->contents)
 							   + srelgot->reloc_count));
 		  ++ srelgot->reloc_count;
+		  elf_local_got_offsets (input_bfd)[symndx] |= 1;
 		}
 
-	      value = sgot->output_offset + off;
+	      value = sgot->output_offset + (off & ~(bfd_vma) 1);
 	    }
-      }
+	}
 
       value += addend;
 
-      if (r_type == R_MN10300_GOT32)
+      if (r_type == R_MN10300_TLS_IE)
+	{
+	  value += sgot->output_section->vma;
+	  bfd_put_32 (input_bfd, value, hit_data);
+	  return bfd_reloc_ok;
+	}
+      else if (r_type == R_MN10300_TLS_GOTIE
+	       || r_type == R_MN10300_TLS_GD
+	       || r_type == R_MN10300_TLS_LD)
+	{
+	  bfd_put_32 (input_bfd, value, hit_data);
+	  return bfd_reloc_ok;
+	}
+      else if (r_type == R_MN10300_GOT32)
 	{
 	  bfd_put_32 (input_bfd, value, hit_data);
 	  return bfd_reloc_ok;
@@ -1419,6 +1992,7 @@
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
   Elf_Internal_Rela *rel, *relend;
+  Elf_Internal_Rela * trel;
 
   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
@@ -1435,7 +2009,12 @@
       struct elf32_mn10300_link_hash_entry *h;
       bfd_vma relocation;
       bfd_reloc_status_type r;
+      int tls_r_type;
+      bfd_boolean unresolved_reloc = FALSE;
+      bfd_boolean warned;
+      struct elf_link_hash_entry * hh;
 
+      relocation = 0;
       r_symndx = ELF32_R_SYM (rel->r_info);
       r_type = ELF32_R_TYPE (rel->r_info);
       howto = elf_mn10300_howto_table + r_type;
@@ -1449,6 +2028,35 @@
       sym = NULL;
       sec = NULL;
       if (r_symndx < symtab_hdr->sh_info)
+	hh = NULL;
+      else
+	{
+	  RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
+				   r_symndx, symtab_hdr, sym_hashes,
+				   hh, sec, relocation,
+				   unresolved_reloc, warned);
+	}
+      h = elf_mn10300_hash_entry (hh);
+
+      tls_r_type = elf_mn10300_tls_transition (info, r_type, hh, input_section, 0);
+      if (tls_r_type != r_type)
+	{
+	  bfd_boolean had_plt;
+
+	  had_plt = mn10300_do_tls_transition (input_bfd, r_type, tls_r_type,
+					       contents, rel->r_offset);
+	  r_type = tls_r_type;
+	  howto = elf_mn10300_howto_table + r_type;
+
+	  if (had_plt)
+	    for (trel = rel+1; trel < relend; trel++)
+	      if ((ELF32_R_TYPE (trel->r_info) == R_MN10300_PLT32
+		   || ELF32_R_TYPE (trel->r_info) == R_MN10300_PCREL32)
+		  && rel->r_offset + had_plt == trel->r_offset)
+		trel->r_info = ELF32_R_INFO (0, R_MN10300_NONE);
+	}
+
+      if (r_symndx < symtab_hdr->sh_info)
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections[r_symndx];
@@ -1456,17 +2064,6 @@
 	}
       else
 	{
-	  bfd_boolean unresolved_reloc;
-	  bfd_boolean warned;
-	  struct elf_link_hash_entry *hh;
-
-	  RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
-				   r_symndx, symtab_hdr, sym_hashes,
-				   hh, sec, relocation,
-				   unresolved_reloc, warned);
-
-	  h = (struct elf32_mn10300_link_hash_entry *) hh;
-
 	  if ((h->root.root.type == bfd_link_hash_defined
 	      || h->root.root.type == bfd_link_hash_defweak)
 	      && (   r_type == R_MN10300_GOTPC32
@@ -1478,6 +2075,10 @@
 		      && h->root.plt.offset != (bfd_vma) -1)
 		  || ((   r_type == R_MN10300_GOT32
 		       || r_type == R_MN10300_GOT24
+		       || r_type == R_MN10300_TLS_GD
+		       || r_type == R_MN10300_TLS_LD
+		       || r_type == R_MN10300_TLS_GOTIE
+		       || r_type == R_MN10300_TLS_IE
 		       || r_type == R_MN10300_GOT16)
 		      && elf_hash_table (info)->dynamic_sections_created
 		      && !SYMBOL_REFERENCES_LOCAL (info, hh))
@@ -1499,7 +2100,10 @@
 	       obscure cases sec->output_section will be NULL.  */
 	    relocation = 0;
 
-	  else if (!info->relocatable && unresolved_reloc)
+	  else if (!info->relocatable && unresolved_reloc
+		   && _bfd_elf_section_offset (output_bfd, info, input_section,
+					       rel->r_offset) != (bfd_vma) -1)
+
 	    (*_bfd_error_handler)
 	      (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
 	       input_bfd,
@@ -1509,9 +2113,9 @@
 	       h->root.root.root.string);
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -1568,6 +2172,9 @@
 	      if (r_type == R_MN10300_PCREL32)
 		msg = _("error: inappropriate relocation type for shared"
 			" library (did you forget -fpic?)");
+	      else if (r_type == R_MN10300_GOT32)
+		msg = _("%B: taking the address of protected function"
+			" '%s' cannot be done when making a shared library");
 	      else
 		msg = _("internal error: suspicious relocation type used"
 			" in shared library");
@@ -1578,11 +2185,9 @@
 	      /* Fall through.  */
 
 	    common_error:
-	      if (!((*info->callbacks->warning)
-		    (info, msg, name, input_bfd, input_section,
-		     rel->r_offset)))
-		return FALSE;
-	      break;
+	      _bfd_error_handler (msg, input_bfd, name);
+	      bfd_set_error (bfd_error_bad_value);
+	      return FALSE;
 	    }
 	}
     }
@@ -1824,7 +2429,7 @@
 	 serve to keep the section artifically inflated.  */
       if (ELF32_R_TYPE ((irelend - 1)->r_info) == (int) R_MN10300_ALIGN)
 	--irelend;
-      
+
       /* The deletion must stop at the next ALIGN reloc for an aligment
 	 power larger than, or not a multiple of, the number of bytes we
 	 are deleting.  */
@@ -2578,6 +3183,7 @@
 		    {
 		      int bytes = 0;
 		      bfd_vma symval;
+		      struct elf_link_hash_entry **hh;
 
 		      /* Note that we've changed things.  */
 		      elf_section_data (section)->relocs = internal_relocs;
@@ -2608,6 +3214,25 @@
 							   bytes))
 			goto error_return;
 
+		      /* There may be other C++ functions symbols with the same
+			 address.  If so then mark these as having had their
+			 prologue bytes deleted as well.  */
+		      for (hh = elf_sym_hashes (input_bfd); hh < end_hashes; hh++)
+			{
+			  struct elf32_mn10300_link_hash_entry *h;
+
+			  h = (struct elf32_mn10300_link_hash_entry *) * hh;
+
+			  if (h != sym_hash
+			      && (h->root.root.type == bfd_link_hash_defined
+				  || h->root.root.type == bfd_link_hash_defweak)
+			      && h->root.root.u.def.section == section
+			      && ! (h->flags & MN10300_CONVERT_CALL_TO_CALLS)
+			      && h->root.root.u.def.value == symval
+			      && h->root.type == STT_FUNC)
+			    h->flags |= MN10300_DELETED_PROLOGUE_BYTES;
+			}
+
 		      /* Something changed.  Not strictly necessary, but
 			 may lead to more relaxing opportunities.  */
 		      *again = TRUE;
@@ -2763,7 +3388,7 @@
 						      isym->st_name);
 
 	  if ((sym_sec->flags & SEC_MERGE)
-	      && sym_sec->sec_info_type == ELF_INFO_TYPE_MERGE)
+	      && sym_sec->sec_info_type == SEC_INFO_TYPE_MERGE)
 	    {
 	      symval = isym->st_value;
 
@@ -2859,9 +3484,7 @@
 	    {
 	      asection * splt;
 
-	      splt = bfd_get_section_by_name (elf_hash_table (link_info)
-					      ->dynobj, ".plt");
-
+	      splt = hash_table->root.splt;
 	      value = ((splt->output_section->vma
 			+ splt->output_offset
 			+ h->root.plt.offset)
@@ -3301,9 +3924,7 @@
 	    {
 	      asection * sgot;
 
-	      sgot = bfd_get_section_by_name (elf_hash_table (link_info)
-					      ->dynobj, ".got");
-
+	      sgot = hash_table->root.sgot;
 	      if (ELF32_R_TYPE (irel->r_info) == (int) R_MN10300_GOT32)
 		{
 		  value = sgot->output_offset;
@@ -3601,8 +4222,8 @@
 			&& (value & 0x8000))
 		      continue;
 
-		    /* mov imm16, an zero-extends the immediate.  */
-		    if (code == 0xdc
+		    /* "mov imm16, an" zero-extends the immediate.  */
+		    if ((code & 0xfc) == 0xdc
 			&& (long) value < 0)
 		      continue;
 
@@ -3946,11 +4567,38 @@
       ret->movm_stack_size = 0;
       ret->flags = 0;
       ret->value = 0;
+      ret->tls_type = GOT_UNKNOWN;
     }
 
   return (struct bfd_hash_entry *) ret;
 }
 
+static void
+_bfd_mn10300_copy_indirect_symbol (struct bfd_link_info *        info,
+				   struct elf_link_hash_entry *  dir,
+				   struct elf_link_hash_entry *  ind)
+{
+  struct elf32_mn10300_link_hash_entry * edir;
+  struct elf32_mn10300_link_hash_entry * eind;
+
+  edir = elf_mn10300_hash_entry (dir);
+  eind = elf_mn10300_hash_entry (ind);
+
+  if (ind->root.type == bfd_link_hash_indirect
+      && dir->got.refcount <= 0)
+    {
+      edir->tls_type = eind->tls_type;
+      eind->tls_type = GOT_UNKNOWN;
+    }
+  edir->direct_calls = eind->direct_calls;
+  edir->stack_size = eind->stack_size;
+  edir->movm_args = eind->movm_args;
+  edir->movm_stack_size = eind->movm_stack_size;
+  edir->flags = eind->flags;
+
+  _bfd_elf_link_hash_copy_indirect (info, dir, ind);
+}
+
 /* Create an mn10300 ELF linker hash table.  */
 
 static struct bfd_link_hash_table *
@@ -3959,7 +4607,7 @@
   struct elf32_mn10300_link_hash_table *ret;
   bfd_size_type amt = sizeof (* ret);
 
-  ret = bfd_malloc (amt);
+  ret = bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
 
@@ -3972,9 +4620,10 @@
       return NULL;
     }
 
-  ret->flags = 0;
+  ret->tls_ldm_got.offset = -1;
+
   amt = sizeof (struct elf_link_hash_table);
-  ret->static_hash_table = bfd_malloc (amt);
+  ret->static_hash_table = bfd_zmalloc (amt);
   if (ret->static_hash_table == NULL)
     {
       free (ret);
@@ -4001,9 +4650,9 @@
   struct elf32_mn10300_link_hash_table *ret
     = (struct elf32_mn10300_link_hash_table *) hash;
 
-  _bfd_generic_link_hash_table_free
+  _bfd_elf_link_hash_table_free
     ((struct bfd_link_hash_table *) ret->static_hash_table);
-  _bfd_generic_link_hash_table_free
+  _bfd_elf_link_hash_table_free
     ((struct bfd_link_hash_table *) ret);
 }
 
@@ -4151,6 +4800,7 @@
   flagword   flags;
   asection * s;
   const struct elf_backend_data * bed = get_elf_backend_data (abfd);
+  struct elf32_mn10300_link_hash_table *htab = elf32_mn10300_hash_table (info);
   int ptralign = 0;
 
   switch (bed->s->arch_size)
@@ -4173,10 +4823,11 @@
   flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
 	   | SEC_LINKER_CREATED);
 
-  s = bfd_make_section_with_flags (abfd,
-				   (bed->default_use_rela_p
-				    ? ".rela.plt" : ".rel.plt"),
-				   flags | SEC_READONLY);
+  s = bfd_make_section_anyway_with_flags (abfd,
+					  (bed->default_use_rela_p
+					   ? ".rela.plt" : ".rel.plt"),
+					  flags | SEC_READONLY);
+  htab->root.srelplt = s;
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, ptralign))
     return FALSE;
@@ -4184,32 +4835,6 @@
   if (! _bfd_mn10300_elf_create_got_section (abfd, info))
     return FALSE;
 
-  {
-    const char * secname;
-    char *       relname;
-    flagword     secflags;
-    asection *   sec;
-
-    for (sec = abfd->sections; sec; sec = sec->next)
-      {
-	secflags = bfd_get_section_flags (abfd, sec);
-	if ((secflags & (SEC_DATA | SEC_LINKER_CREATED))
-	    || ((secflags & SEC_HAS_CONTENTS) != SEC_HAS_CONTENTS))
-	  continue;
-
-	secname = bfd_get_section_name (abfd, sec);
-	relname = bfd_malloc (strlen (secname) + 6);
-	strcpy (relname, ".rela");
-	strcat (relname, secname);
-
-	s = bfd_make_section_with_flags (abfd, relname,
-					 flags | SEC_READONLY);
-	if (s == NULL
-	    || ! bfd_set_section_alignment (abfd, s, ptralign))
-	  return FALSE;
-      }
-  }
-
   if (bed->want_dynbss)
     {
       /* The .dynbss section is a place to put symbols which are defined
@@ -4218,8 +4843,8 @@
 	 image and use a R_*_COPY reloc to tell the dynamic linker to
 	 initialize them at run time.  The linker script puts the .dynbss
 	 section into the .bss section of the final image.  */
-      s = bfd_make_section_with_flags (abfd, ".dynbss",
-				       SEC_ALLOC | SEC_LINKER_CREATED);
+      s = bfd_make_section_anyway_with_flags (abfd, ".dynbss",
+					      SEC_ALLOC | SEC_LINKER_CREATED);
       if (s == NULL)
 	return FALSE;
 
@@ -4236,10 +4861,10 @@
 	 copy relocs.  */
       if (! info->shared)
 	{
-	  s = bfd_make_section_with_flags (abfd,
-					   (bed->default_use_rela_p
-					    ? ".rela.bss" : ".rel.bss"),
-					   flags | SEC_READONLY);
+	  s = bfd_make_section_anyway_with_flags (abfd,
+						  (bed->default_use_rela_p
+						   ? ".rela.bss" : ".rel.bss"),
+						  flags | SEC_READONLY);
 	  if (s == NULL
 	      || ! bfd_set_section_alignment (abfd, s, ptralign))
 	    return FALSE;
@@ -4259,10 +4884,11 @@
 _bfd_mn10300_elf_adjust_dynamic_symbol (struct bfd_link_info * info,
 					struct elf_link_hash_entry * h)
 {
+  struct elf32_mn10300_link_hash_table *htab = elf32_mn10300_hash_table (info);
   bfd * dynobj;
   asection * s;
 
-  dynobj = elf_hash_table (info)->dynobj;
+  dynobj = htab->root.dynobj;
 
   /* Make sure we know what is going on here.  */
   BFD_ASSERT (dynobj != NULL
@@ -4298,7 +4924,7 @@
 	    return FALSE;
 	}
 
-      s = bfd_get_section_by_name (dynobj, ".plt");
+      s = htab->root.splt;
       BFD_ASSERT (s != NULL);
 
       /* If this is the first .plt entry, make room for the special
@@ -4325,12 +4951,12 @@
 
       /* We also need to make an entry in the .got.plt section, which
 	 will be placed in the .got section by the linker script.  */
-      s = bfd_get_section_by_name (dynobj, ".got.plt");
+      s = htab->root.sgotplt;
       BFD_ASSERT (s != NULL);
       s->size += 4;
 
       /* We also need to make an entry in the .rela.plt section.  */
-      s = bfd_get_section_by_name (dynobj, ".rela.plt");
+      s = bfd_get_linker_section (dynobj, ".rela.plt");
       BFD_ASSERT (s != NULL);
       s->size += sizeof (Elf32_External_Rela);
 
@@ -4364,13 +4990,6 @@
   if (!h->non_got_ref)
     return TRUE;
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-			     h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -4381,18 +5000,18 @@
      both the dynamic object and the regular object will refer to the
      same memory location for the variable.  */
 
-  s = bfd_get_section_by_name (dynobj, ".dynbss");
+  s = bfd_get_linker_section (dynobj, ".dynbss");
   BFD_ASSERT (s != NULL);
 
   /* We must generate a R_MN10300_COPY reloc to tell the dynamic linker to
      copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rela.bss section we are going to use.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       asection * srel;
 
-      srel = bfd_get_section_by_name (dynobj, ".rela.bss");
+      srel = bfd_get_linker_section (dynobj, ".rela.bss");
       BFD_ASSERT (srel != NULL);
       srel->size += sizeof (Elf32_External_Rela);
       h->needs_copy = 1;
@@ -4407,13 +5026,14 @@
 _bfd_mn10300_elf_size_dynamic_sections (bfd * output_bfd,
 					struct bfd_link_info * info)
 {
+  struct elf32_mn10300_link_hash_table *htab = elf32_mn10300_hash_table (info);
   bfd * dynobj;
   asection * s;
   bfd_boolean plt;
   bfd_boolean relocs;
   bfd_boolean reltext;
 
-  dynobj = elf_hash_table (info)->dynobj;
+  dynobj = htab->root.dynobj;
   BFD_ASSERT (dynobj != NULL);
 
   if (elf_hash_table (info)->dynamic_sections_created)
@@ -4421,7 +5041,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
@@ -4434,11 +5054,18 @@
 	 not actually use these entries.  Reset the size of .rela.got,
 	 which will cause it to get stripped from the output file
 	 below.  */
-      s = bfd_get_section_by_name (dynobj, ".rela.got");
+      s = htab->root.sgot;
       if (s != NULL)
 	s->size = 0;
     }
 
+  if (htab->tls_ldm_got.refcount > 0)
+    {
+      s = bfd_get_linker_section (dynobj, ".rela.got");
+      BFD_ASSERT (s != NULL);
+      s->size += sizeof (Elf32_External_Rela);
+    }
+
   /* The check_relocs and adjust_dynamic_symbol entry points have
      determined the sizes of the various dynamic sections.  Allocate
      memory for them.  */
@@ -4577,9 +5204,10 @@
 					struct elf_link_hash_entry * h,
 					Elf_Internal_Sym * sym)
 {
+  struct elf32_mn10300_link_hash_table *htab = elf32_mn10300_hash_table (info);
   bfd * dynobj;
 
-  dynobj = elf_hash_table (info)->dynobj;
+  dynobj = htab->root.dynobj;
 
   if (h->plt.offset != (bfd_vma) -1)
     {
@@ -4595,9 +5223,9 @@
 
       BFD_ASSERT (h->dynindx != -1);
 
-      splt = bfd_get_section_by_name (dynobj, ".plt");
-      sgot = bfd_get_section_by_name (dynobj, ".got.plt");
-      srel = bfd_get_section_by_name (dynobj, ".rela.plt");
+      splt = htab->root.splt;
+      sgot = htab->root.sgotplt;
+      srel = bfd_get_linker_section (dynobj, ".rela.plt");
       BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
 
       /* Get the index in the procedure linkage table which
@@ -4674,39 +5302,72 @@
       Elf_Internal_Rela rel;
 
       /* This symbol has an entry in the global offset table.  Set it up.  */
-      sgot = bfd_get_section_by_name (dynobj, ".got");
-      srel = bfd_get_section_by_name (dynobj, ".rela.got");
+      sgot = htab->root.sgot;
+      srel = bfd_get_linker_section (dynobj, ".rela.got");
       BFD_ASSERT (sgot != NULL && srel != NULL);
 
       rel.r_offset = (sgot->output_section->vma
 		      + sgot->output_offset
 		      + (h->got.offset & ~1));
 
-      /* If this is a -Bsymbolic link, and the symbol is defined
-	 locally, we just want to emit a RELATIVE reloc.  Likewise if
-	 the symbol was forced to be local because of a version file.
-	 The entry in the global offset table will already have been
-	 initialized in the relocate_section function.  */
-      if (info->shared
-	  && (info->symbolic || h->dynindx == -1)
-	  && h->def_regular)
+      switch (elf_mn10300_hash_entry (h)->tls_type)
 	{
-	  rel.r_info = ELF32_R_INFO (0, R_MN10300_RELATIVE);
-	  rel.r_addend = (h->root.u.def.value
-			  + h->root.u.def.section->output_section->vma
-			  + h->root.u.def.section->output_offset);
-	}
-      else
-	{
+	case GOT_TLS_GD:
 	  bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset);
-	  rel.r_info = ELF32_R_INFO (h->dynindx, R_MN10300_GLOB_DAT);
+	  bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset + 4);
+	  rel.r_info = ELF32_R_INFO (h->dynindx, R_MN10300_TLS_DTPMOD);
 	  rel.r_addend = 0;
+	  bfd_elf32_swap_reloca_out (output_bfd, & rel,
+				     (bfd_byte *) ((Elf32_External_Rela *) srel->contents
+						   + srel->reloc_count));
+	  ++ srel->reloc_count;
+	  rel.r_info = ELF32_R_INFO (h->dynindx, R_MN10300_TLS_DTPOFF);
+	  rel.r_offset += 4;
+	  rel.r_addend = 0;
+	  break;
+
+	case GOT_TLS_IE:
+	  /* We originally stored the addend in the GOT, but at this
+	     point, we want to move it to the reloc instead as that's
+	     where the dynamic linker wants it.  */
+	  rel.r_addend = bfd_get_32 (output_bfd, sgot->contents + h->got.offset);
+	  bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset);
+	  if (h->dynindx == -1)
+	    rel.r_info = ELF32_R_INFO (0, R_MN10300_TLS_TPOFF);
+	  else
+	    rel.r_info = ELF32_R_INFO (h->dynindx, R_MN10300_TLS_TPOFF);
+	  break;
+
+	default:
+	  /* If this is a -Bsymbolic link, and the symbol is defined
+	     locally, we just want to emit a RELATIVE reloc.  Likewise if
+	     the symbol was forced to be local because of a version file.
+	     The entry in the global offset table will already have been
+	     initialized in the relocate_section function.  */
+	  if (info->shared
+	      && (info->symbolic || h->dynindx == -1)
+	      && h->def_regular)
+	    {
+	      rel.r_info = ELF32_R_INFO (0, R_MN10300_RELATIVE);
+	      rel.r_addend = (h->root.u.def.value
+			      + h->root.u.def.section->output_section->vma
+			      + h->root.u.def.section->output_offset);
+	    }
+	  else
+	    {
+	      bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset);
+	      rel.r_info = ELF32_R_INFO (h->dynindx, R_MN10300_GLOB_DAT);
+	      rel.r_addend = 0;
+	    }
 	}
 
-      bfd_elf32_swap_reloca_out (output_bfd, &rel,
-				 (bfd_byte *) ((Elf32_External_Rela *) srel->contents
-					       + srel->reloc_count));
-      ++ srel->reloc_count;
+      if (ELF32_R_TYPE (rel.r_info) != R_MN10300_NONE)
+	{
+	  bfd_elf32_swap_reloca_out (output_bfd, &rel,
+				     (bfd_byte *) ((Elf32_External_Rela *) srel->contents
+						   + srel->reloc_count));
+	  ++ srel->reloc_count;
+	}
     }
 
   if (h->needs_copy)
@@ -4719,8 +5380,7 @@
 		  && (h->root.type == bfd_link_hash_defined
 		      || h->root.type == bfd_link_hash_defweak));
 
-      s = bfd_get_section_by_name (h->root.u.def.section->owner,
-				   ".rela.bss");
+      s = bfd_get_linker_section (dynobj, ".rela.bss");
       BFD_ASSERT (s != NULL);
 
       rel.r_offset = (h->root.u.def.value
@@ -4735,7 +5395,7 @@
     }
 
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
-  if (streq (h->root.root.string, "_DYNAMIC")
+  if (h == elf_hash_table (info)->hdynamic
       || h == elf_hash_table (info)->hgot)
     sym->st_shndx = SHN_ABS;
 
@@ -4751,12 +5411,12 @@
   bfd *      dynobj;
   asection * sgot;
   asection * sdyn;
+  struct elf32_mn10300_link_hash_table *htab = elf32_mn10300_hash_table (info);
 
-  dynobj = elf_hash_table (info)->dynobj;
-
-  sgot = bfd_get_section_by_name (dynobj, ".got.plt");
+  dynobj = htab->root.dynobj;
+  sgot = htab->root.sgotplt;
   BFD_ASSERT (sgot != NULL);
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (elf_hash_table (info)->dynamic_sections_created)
     {
@@ -4821,7 +5481,7 @@
 	}
 
       /* Fill in the first entry in the procedure linkage table.  */
-      splt = bfd_get_section_by_name (dynobj, ".plt");
+      splt = htab->root.splt;
       if (splt && splt->size > 0)
 	{
 	  if (info->shared)
@@ -4843,6 +5503,14 @@
 	  /* UnixWare sets the entsize of .plt to 4, although that doesn't
 	     really seem like the right value.  */
 	  elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4;
+
+	  /* UnixWare sets the entsize of .plt to 4, but this is incorrect
+	     as it means that the size of the PLT0 section (15 bytes) is not
+	     a multiple of the sh_entsize.  Some ELF tools flag this as an
+	     error.  We could pad PLT0 to 16 bytes, but that would introduce
+	     compatibilty issues with previous toolchains, so instead we
+	     just set the entry size to 1.  */
+	  elf_section_data (splt->output_section)->this_hdr.sh_entsize = 1;
 	}
     }
 
@@ -4868,7 +5536,9 @@
    properly.  */
 
 static enum elf_reloc_type_class
-_bfd_mn10300_elf_reloc_type_class (const Elf_Internal_Rela *rela)
+_bfd_mn10300_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+				   const asection *rel_sec ATTRIBUTE_UNUSED,
+				   const Elf_Internal_Rela *rela)
 {
   switch ((int) ELF32_R_TYPE (rela->r_info))
     {
@@ -4884,12 +5554,7 @@
 static bfd_boolean
 mn10300_elf_mkobject (bfd *abfd)
 {
-  /* We do not actually need any extra room in the bfd elf data structure.
-     But we do need the object_id of the structure to be set to
-     MN10300_ELF_DATA so that elflink.c:elf_link_add_object_symols() will call
-     our mn10300_elf_check_relocs function which will then allocate space in
-     the .got section for any GOT based relocs.  */
-  return bfd_elf_allocate_object (abfd, sizeof (struct elf_obj_tdata),
+  return bfd_elf_allocate_object (abfd, sizeof (struct elf_mn10300_obj_tdata),
 				  MN10300_ELF_DATA);
 }
 
@@ -4945,7 +5610,8 @@
   _bfd_mn10300_elf_finish_dynamic_symbol
 #define elf_backend_finish_dynamic_sections \
   _bfd_mn10300_elf_finish_dynamic_sections
-
+#define elf_backend_copy_indirect_symbol \
+  _bfd_mn10300_copy_indirect_symbol
 #define elf_backend_reloc_type_class \
   _bfd_mn10300_elf_reloc_type_class
 
diff --git a/bfd/elf-nacl.c b/bfd/elf-nacl.c
new file mode 100644
index 0000000..944aa34
--- /dev/null
+++ b/bfd/elf-nacl.c
@@ -0,0 +1,355 @@
+/* Native Client support for ELF
+   Copyright 2012, 2013 Free Software Foundation, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf-nacl.h"
+#include "elf/common.h"
+#include "elf/internal.h"
+
+static bfd_boolean
+segment_executable (struct elf_segment_map *seg)
+{
+  if (seg->p_flags_valid)
+    return (seg->p_flags & PF_X) != 0;
+  else
+    {
+      /* The p_flags value has not been computed yet,
+	 so we have to look through the sections.  */
+      unsigned int i;
+      for (i = 0; i < seg->count; ++i)
+	if (seg->sections[i]->flags & SEC_CODE)
+	  return TRUE;
+    }
+  return FALSE;
+}
+
+/* Determine if this segment is eligible to receive the file and program
+   headers.  It must be read-only and non-executable.
+   Its first section must start far enough past the page boundary to
+   allow space for the headers.  */
+static bfd_boolean
+segment_eligible_for_headers (struct elf_segment_map *seg,
+			      bfd_vma minpagesize, bfd_vma sizeof_headers)
+{
+  unsigned int i;
+  if (seg->count == 0 || seg->sections[0]->lma % minpagesize < sizeof_headers)
+    return FALSE;
+  for (i = 0; i < seg->count; ++i)
+    {
+      if ((seg->sections[i]->flags & (SEC_CODE|SEC_READONLY)) != SEC_READONLY)
+	return FALSE;
+    }
+  return TRUE;
+}
+
+
+/* We permute the segment_map to get BFD to do the file layout we want:
+   The first non-executable PT_LOAD segment appears first in the file
+   and contains the ELF file header and phdrs.  */
+bfd_boolean
+nacl_modify_segment_map (bfd *abfd, struct bfd_link_info *info)
+{
+  const struct elf_backend_data *const bed = get_elf_backend_data (abfd);
+  struct elf_segment_map **m = &elf_seg_map (abfd);
+  struct elf_segment_map **first_load = NULL;
+  struct elf_segment_map **last_load = NULL;
+  bfd_boolean moved_headers = FALSE;
+  int sizeof_headers;
+
+  if (info != NULL && info->user_phdrs)
+    /* The linker script used PHDRS explicitly, so don't change what the
+       user asked for.  */
+    return TRUE;
+
+  if (info != NULL)
+    /* We're doing linking, so evalute SIZEOF_HEADERS as in a linker script.  */
+    sizeof_headers = bfd_sizeof_headers (abfd, info);
+  else
+    {
+      /* We're not doing linking, so this is objcopy or suchlike.
+	 We just need to collect the size of the existing headers.  */
+      struct elf_segment_map *seg;
+      sizeof_headers = bed->s->sizeof_ehdr;
+      for (seg = *m; seg != NULL; seg = seg->next)
+	sizeof_headers += bed->s->sizeof_phdr;
+    }
+
+  while (*m != NULL)
+    {
+      struct elf_segment_map *seg = *m;
+
+      if (seg->p_type == PT_LOAD)
+	{
+	  bfd_boolean executable = segment_executable (seg);
+
+	  if (executable
+	      && seg->count > 0
+	      && seg->sections[0]->vma % bed->minpagesize == 0)
+	    {
+	      asection *lastsec = seg->sections[seg->count - 1];
+	      bfd_vma end = lastsec->vma + lastsec->size;
+	      if (end % bed->minpagesize != 0)
+		{
+		  /* This is an executable segment that starts on a page
+		     boundary but does not end on a page boundary.  Fill
+		     it out to a whole page with code fill (the tail of
+		     the segment will not be within any section).  Thus
+		     the entire code segment can be mapped from the file
+		     as whole pages and that mapping will contain only
+		     valid instructions.
+
+		     To accomplish this, we must fake out the code in
+		     assign_file_positions_for_load_sections (elf.c) so
+		     that it advances past the rest of the final page,
+		     rather than trying to put the next (unaligned, or
+		     unallocated) section.  We do this by appending a
+		     dummy section record to this element in the segment
+		     map.  No such output section ever actually exists,
+		     but this gets the layout logic to advance the file
+		     positions past this partial page.  Since we are
+		     lying to BFD like this, nothing will ever know to
+		     write the section contents.  So we do that by hand
+		     after the fact, in nacl_final_write_processing, below.  */
+
+		  struct elf_segment_map *newseg;
+		  asection *sec;
+		  struct bfd_elf_section_data *secdata;
+
+		  BFD_ASSERT (!seg->p_size_valid);
+
+		  secdata = bfd_zalloc (abfd, sizeof *secdata);
+		  if (secdata == NULL)
+		    return FALSE;
+
+		  sec = bfd_zalloc (abfd, sizeof *sec);
+		  if (sec == NULL)
+		    return FALSE;
+
+		  /* Fill in only the fields that actually affect the logic
+		     in assign_file_positions_for_load_sections.  */
+		  sec->vma = end;
+		  sec->lma = lastsec->lma + lastsec->size;
+		  sec->size = bed->minpagesize - (end % bed->minpagesize);
+		  sec->flags = (SEC_ALLOC | SEC_LOAD
+				| SEC_READONLY | SEC_CODE | SEC_LINKER_CREATED);
+		  sec->used_by_bfd = secdata;
+
+		  secdata->this_hdr.sh_type = SHT_PROGBITS;
+		  secdata->this_hdr.sh_flags = SHF_ALLOC | SHF_EXECINSTR;
+		  secdata->this_hdr.sh_addr = sec->vma;
+		  secdata->this_hdr.sh_size = sec->size;
+
+		  newseg = bfd_alloc (abfd,
+				      sizeof *newseg + ((seg->count + 1)
+							* sizeof (asection *)));
+		  if (newseg == NULL)
+		    return FALSE;
+		  memcpy (newseg, seg,
+			  sizeof *newseg + (seg->count * sizeof (asection *)));
+		  newseg->sections[newseg->count++] = sec;
+		  *m = seg = newseg;
+		}
+	    }
+
+	  /* First, we're just finding the earliest PT_LOAD.
+	     By the normal rules, this will be the lowest-addressed one.
+	     We only have anything interesting to do if it's executable.  */
+	  last_load = m;
+	  if (first_load == NULL)
+	    {
+	      if (!executable)
+		goto next;
+	      first_load = m;
+	    }
+	  /* Now that we've noted the first PT_LOAD, we're looking for
+	     the first non-executable PT_LOAD with a nonempty p_filesz.  */
+	  else if (!moved_headers
+		   && segment_eligible_for_headers (seg, bed->minpagesize,
+						    sizeof_headers))
+	    {
+	      /* This is the one we were looking for!
+
+		 First, clear the flags on previous segments that
+		 say they include the file header and phdrs.  */
+	      struct elf_segment_map *prevseg;
+	      for (prevseg = *first_load;
+		   prevseg != seg;
+		   prevseg = prevseg->next)
+		if (prevseg->p_type == PT_LOAD)
+		  {
+		    prevseg->includes_filehdr = 0;
+		    prevseg->includes_phdrs = 0;
+		  }
+
+	      /* This segment will include those headers instead.  */
+	      seg->includes_filehdr = 1;
+	      seg->includes_phdrs = 1;
+
+	      moved_headers = TRUE;
+	    }
+	}
+
+    next:
+      m = &seg->next;
+    }
+
+  if (first_load != last_load && moved_headers)
+    {
+      /* Now swap the first and last PT_LOAD segments'
+	 positions in segment_map.  */
+      struct elf_segment_map *first = *first_load;
+      struct elf_segment_map *last = *last_load;
+      *first_load = first->next;
+      first->next = last->next;
+      last->next = first;
+    }
+
+  return TRUE;
+}
+
+/* After nacl_modify_segment_map has done its work, the file layout has
+   been done as we wanted.  But the PT_LOAD phdrs are no longer in the
+   proper order for the ELF rule that they must appear in ascending address
+   order.  So find the two segments we swapped before, and swap them back.  */
+bfd_boolean
+nacl_modify_program_headers (bfd *abfd, struct bfd_link_info *info)
+{
+  struct elf_segment_map **m = &elf_seg_map (abfd);
+  Elf_Internal_Phdr *phdr = elf_tdata (abfd)->phdr;
+  Elf_Internal_Phdr *p = phdr;
+
+  if (info != NULL && info->user_phdrs)
+    /* The linker script used PHDRS explicitly, so don't change what the
+       user asked for.  */
+    return TRUE;
+
+  /* Find the PT_LOAD that contains the headers (should be the first).  */
+  while (*m != NULL)
+    {
+      if ((*m)->p_type == PT_LOAD && (*m)->includes_filehdr)
+	break;
+
+      m = &(*m)->next;
+      ++p;
+    }
+
+  if (*m != NULL)
+    {
+      struct elf_segment_map **first_load_seg = m;
+      Elf_Internal_Phdr *first_load_phdr = p;
+      struct elf_segment_map **next_load_seg = NULL;
+      Elf_Internal_Phdr *next_load_phdr = NULL;
+
+      /* Now move past that first one and find the PT_LOAD that should be
+	 before it by address order.  */
+
+      m = &(*m)->next;
+      ++p;
+
+      while (*m != NULL)
+	{
+	  if (p->p_type == PT_LOAD && p->p_vaddr < first_load_phdr->p_vaddr)
+	    {
+	      next_load_seg = m;
+	      next_load_phdr = p;
+	      break;
+	    }
+
+	  m = &(*m)->next;
+	  ++p;
+	}
+
+      /* Swap their positions in the segment_map back to how they used to be.
+	 The phdrs have already been set up by now, so we have to slide up
+	 the earlier ones to insert the one that should be first.  */
+      if (next_load_seg != NULL)
+	{
+	  Elf_Internal_Phdr move_phdr;
+	  struct elf_segment_map *first_seg = *first_load_seg;
+	  struct elf_segment_map *next_seg = *next_load_seg;
+	  struct elf_segment_map *first_next = first_seg->next;
+	  struct elf_segment_map *next_next = next_seg->next;
+
+	  if (next_load_seg == &first_seg->next)
+	    {
+	      *first_load_seg = next_seg;
+	      next_seg->next = first_seg;
+	      first_seg->next = next_next;
+	    }
+	  else
+	    {
+	      *first_load_seg = first_next;
+	      *next_load_seg = next_next;
+
+	      first_seg->next = *next_load_seg;
+	      *next_load_seg = first_seg;
+
+	      next_seg->next = *first_load_seg;
+	      *first_load_seg = next_seg;
+	    }
+
+	  move_phdr = *next_load_phdr;
+	  memmove (first_load_phdr + 1, first_load_phdr,
+		   (next_load_phdr - first_load_phdr) * sizeof move_phdr);
+	  *first_load_phdr = move_phdr;
+	}
+    }
+
+  return TRUE;
+}
+
+void
+nacl_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED)
+{
+  struct elf_segment_map *seg;
+  for (seg = elf_seg_map (abfd); seg != NULL; seg = seg->next)
+    if (seg->p_type == PT_LOAD
+	&& seg->count > 1
+	&& seg->sections[seg->count - 1]->owner == NULL)
+      {
+	/* This is a fake section added in nacl_modify_segment_map, above.
+	   It's not a real BFD section, so nothing wrote its contents.
+	   Now write out its contents.  */
+
+	asection *sec = seg->sections[seg->count - 1];
+	char *fill;
+
+	BFD_ASSERT (sec->flags & SEC_LINKER_CREATED);
+	BFD_ASSERT (sec->flags & SEC_CODE);
+	BFD_ASSERT (sec->size > 0);
+
+	fill = abfd->arch_info->fill (sec->size, bfd_big_endian (abfd), TRUE);
+
+	if (fill == NULL
+	    || bfd_seek (abfd, sec->filepos, SEEK_SET) != 0
+	    || bfd_bwrite (fill, sec->size, abfd) != sec->size)
+	  {
+	    /* We don't have a proper way to report an error here.  So
+	       instead fudge things so that elf_write_shdrs_and_ehdr will
+	       fail.  */
+	    elf_elfheader (abfd)->e_shoff = (file_ptr) -1;
+	  }
+
+	free (fill);
+      }
+}
diff --git a/bfd/elf-nacl.h b/bfd/elf-nacl.h
new file mode 100644
index 0000000..87719ef
--- /dev/null
+++ b/bfd/elf-nacl.h
@@ -0,0 +1,25 @@
+/* Native Client support for ELF
+   Copyright 2012, 2013 Free Software Foundation, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.  */
+
+#include "bfd.h"
+
+bfd_boolean nacl_modify_segment_map (bfd *, struct bfd_link_info *);
+bfd_boolean nacl_modify_program_headers (bfd *, struct bfd_link_info *);
+void nacl_final_write_processing (bfd *, bfd_boolean linker);
diff --git a/bfd/elf-s390-common.c b/bfd/elf-s390-common.c
new file mode 100644
index 0000000..691f751
--- /dev/null
+++ b/bfd/elf-s390-common.c
@@ -0,0 +1,243 @@
+/* IBM S/390-specific support for ELF 32 and 64 bit functions
+   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
+   2011, 2012 Free Software Foundation, Inc.
+   Contributed by Andreas Krebbel.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+
+/* Return TRUE if H is an IFUNC symbol.  Simply checking for the
+   symbol type might not be enough since it might get changed to
+   STT_FUNC for pointer equality reasons.  */
+static inline bfd_boolean
+s390_is_ifunc_symbol_p (struct elf_link_hash_entry *h)
+{
+  struct elf_s390_link_hash_entry *eh = (struct elf_s390_link_hash_entry*)h;
+  return h->type == STT_GNU_IFUNC || eh->ifunc_resolver_address != 0;
+}
+
+/* Create sections needed by STT_GNU_IFUNC symbol.  */
+
+static bfd_boolean
+s390_elf_create_ifunc_sections (bfd *abfd, struct bfd_link_info *info)
+{
+  flagword flags;
+  asection *s;
+  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+  struct elf_link_hash_table *htab = elf_hash_table (info);
+
+  if (htab->iplt != NULL)
+    return TRUE;
+
+  flags = bed->dynamic_sec_flags;
+
+  if (info->shared)
+    {
+      s = bfd_make_section_with_flags (abfd, ".rela.ifunc",
+				       flags | SEC_READONLY);
+      if (s == NULL
+	  || ! bfd_set_section_alignment (abfd, s,
+					  bed->s->log_file_align))
+	return FALSE;
+      htab->irelifunc = s;
+    }
+
+  /* Create .iplt, .rel[a].iplt, and .igot.plt.  */
+  s = bfd_make_section_with_flags (abfd, ".iplt",
+				   flags | SEC_CODE | SEC_READONLY);
+  if (s == NULL
+      || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
+    return FALSE;
+  htab->iplt = s;
+
+  s = bfd_make_section_with_flags (abfd, ".rela.iplt", flags | SEC_READONLY);
+  if (s == NULL
+      || ! bfd_set_section_alignment (abfd, s,
+				      bed->s->log_file_align))
+    return FALSE;
+  htab->irelplt = s;
+
+  s = bfd_make_section_with_flags (abfd, ".igot.plt", flags);
+  if (s == NULL
+      || !bfd_set_section_alignment (abfd, s,
+				     bed->s->log_file_align))
+    return FALSE;
+  htab->igotplt = s;
+
+  return TRUE;
+}
+
+
+/* Allocate space in .plt, .got and associated reloc sections for
+   dynamic relocs against a STT_GNU_IFUNC symbol definition.  */
+
+static bfd_boolean
+s390_elf_allocate_ifunc_dyn_relocs (struct bfd_link_info *info,
+				    struct elf_link_hash_entry *h,
+				    struct elf_dyn_relocs **head)
+{
+  struct elf_dyn_relocs *p;
+  struct elf_link_hash_table *htab;
+  struct elf_s390_link_hash_entry *eh = (struct elf_s390_link_hash_entry*)h;
+
+  htab = elf_hash_table (info);
+  eh->ifunc_resolver_address = h->root.u.def.value;
+  eh->ifunc_resolver_section = h->root.u.def.section;
+
+  /* Support garbage collection against STT_GNU_IFUNC symbols.  */
+  if (h->plt.refcount <= 0 && h->got.refcount <= 0)
+    {
+      /* When building shared library, we need to handle the case
+         where it is marked with regular reference, but not non-GOT
+	 reference.  It may happen if we didn't see STT_GNU_IFUNC
+	 symbol at the time when checking relocations.  */
+      if (info->shared
+	  && !h->non_got_ref
+	  && h->ref_regular)
+	for (p = *head; p != NULL; p = p->next)
+	  if (p->count)
+	    {
+	      h->non_got_ref = 1;
+	      goto keep;
+	    }
+
+      h->got = htab->init_got_offset;
+      h->plt = htab->init_plt_offset;
+      *head = NULL;
+      return TRUE;
+    }
+
+  /* Return and discard space for dynamic relocations against it if
+     it is never referenced in a non-shared object.  */
+  if (!h->ref_regular)
+    {
+      if (h->plt.refcount > 0
+	  || h->got.refcount > 0)
+	abort ();
+      h->got = htab->init_got_offset;
+      h->plt = htab->init_plt_offset;
+      *head = NULL;
+      return TRUE;
+    }
+
+keep:
+  /* Without checking h->plt.refcount here we allocate a PLT slot.
+     When setting plt.refcount in check_relocs it might not have been
+     known that this will be an IFUNC symol.  */
+  h->plt.offset = htab->iplt->size;
+  h->needs_plt = 1;
+  htab->iplt->size += PLT_ENTRY_SIZE;
+  htab->igotplt->size += GOT_ENTRY_SIZE;
+  htab->irelplt->size += RELA_ENTRY_SIZE;
+  htab->irelplt->reloc_count++;
+
+  /* In order to make pointer equality work with IFUNC symbols defined
+     in a non-PIE executable and referenced in a shared lib, we turn
+     the symbol into a STT_FUNC symbol and make the symbol value to
+     point to the IPLT slot.  That way the referencing shared lib will
+     always get the PLT slot address when resolving the respective
+     R_390_GLOB_DAT/R_390_64 relocs on that symbol.  */
+  if (info->executable && !info->shared && h->def_regular && h->ref_dynamic)
+    {
+      h->root.u.def.section = htab->iplt;
+      h->root.u.def.value = h->plt.offset;
+      h->size = PLT_ENTRY_SIZE;
+      h->type = STT_FUNC;
+    }
+
+  /* We need dynamic relocation for STT_GNU_IFUNC symbol only when
+     there is a non-GOT reference in a shared object.  */
+  if (!info->shared || !h->non_got_ref)
+    *head = NULL;
+
+  /* Finally, allocate space.  */
+  p = *head;
+  if (p != NULL)
+    {
+      bfd_size_type count = 0;
+      do
+	{
+	  count += p->count;
+	  p = p->next;
+	}
+      while (p != NULL);
+      htab->irelifunc->size += count * RELA_ENTRY_SIZE;
+    }
+
+  /* Decide whether the got.iplt slot can be used.  This has to be
+     avoided if the values in the GOT slots could differ for pointer
+     equality reasons.  */
+  if (h->got.refcount <= 0
+      || (info->shared
+	  && (h->dynindx == -1 || h->forced_local))
+      || (info->executable && info->shared)
+      || htab->sgot == NULL)
+    {
+      /* Use .got.iplt.  */
+      h->got.offset = (bfd_vma) -1;
+    }
+  else
+    {
+      h->got.offset = htab->sgot->size;
+      htab->sgot->size += GOT_ENTRY_SIZE;
+      if (info->shared)
+	htab->srelgot->size += RELA_ENTRY_SIZE;
+    }
+
+  return TRUE;
+}
+
+static bfd_boolean
+elf_s390_allocate_local_syminfo (bfd *abfd, Elf_Internal_Shdr *symtab_hdr)
+{
+  bfd_size_type size;
+
+  size = symtab_hdr->sh_info;
+  size *= (sizeof (bfd_signed_vma)       /* local got */
+	   + sizeof (struct plt_entry)   /* local plt */
+	   + sizeof(char));              /* local tls type */
+  elf_local_got_refcounts (abfd) = ((bfd_signed_vma *)
+				    bfd_zalloc (abfd, size));
+  if (elf_local_got_refcounts (abfd) == NULL)
+    return FALSE;
+  elf_s390_local_plt (abfd)
+    = (struct plt_entry*)(elf_local_got_refcounts (abfd)
+			  + symtab_hdr->sh_info);
+  elf_s390_local_got_tls_type (abfd)
+    = (char *) (elf_s390_local_plt (abfd) + symtab_hdr->sh_info);
+
+  return TRUE;
+}
+
+/* Pick ELFOSABI_GNU if IFUNC symbols are used.  */
+
+static bfd_boolean
+elf_s390_add_symbol_hook (bfd *abfd,
+			  struct bfd_link_info *info,
+			  Elf_Internal_Sym *sym,
+			  const char **namep ATTRIBUTE_UNUSED,
+			  flagword *flagsp ATTRIBUTE_UNUSED,
+			  asection **secp ATTRIBUTE_UNUSED,
+			  bfd_vma *valp ATTRIBUTE_UNUSED)
+{
+  if ((abfd->flags & DYNAMIC) == 0
+      && ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC)
+    elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE;
+
+  return TRUE;
+}
diff --git a/bfd/elf-strtab.c b/bfd/elf-strtab.c
index 7d2fad4..61cedae 100644
--- a/bfd/elf-strtab.c
+++ b/bfd/elf-strtab.c
@@ -201,15 +201,41 @@
   --tab->array[idx]->refcount;
 }
 
+unsigned int
+_bfd_elf_strtab_refcount (struct elf_strtab_hash *tab, bfd_size_type idx)
+{
+  return tab->array[idx]->refcount;
+}
+
 void
 _bfd_elf_strtab_clear_all_refs (struct elf_strtab_hash *tab)
 {
   bfd_size_type idx;
 
-  for (idx = 1; idx < tab->size; ++idx)
+  for (idx = 1; idx < tab->size; idx++)
     tab->array[idx]->refcount = 0;
 }
 
+/* Downsizes strtab.  Entries from IDX up to the current size are
+   removed from the array.  */
+void
+_bfd_elf_strtab_restore_size (struct elf_strtab_hash *tab, bfd_size_type idx)
+{
+  bfd_size_type curr_size = tab->size;
+
+  BFD_ASSERT (tab->sec_size == 0);
+  BFD_ASSERT (idx <= curr_size);
+  tab->size = idx;
+  for (; idx < curr_size; ++idx)
+    {
+      /* We don't remove entries from the hash table, just set their
+	 REFCOUNT to zero.  Setting LEN zero will result in the size
+	 growing if the entry is added again.  See _bfd_elf_strtab_add.  */
+      tab->array[idx]->refcount = 0;
+      tab->array[idx]->len = 0;
+    }
+}
+
 bfd_size_type
 _bfd_elf_strtab_size (struct elf_strtab_hash *tab)
 {
diff --git a/bfd/elf-vxworks.c b/bfd/elf-vxworks.c
index 06edf8d..bb9dbbb 100644
--- a/bfd/elf-vxworks.c
+++ b/bfd/elf-vxworks.c
@@ -1,5 +1,5 @@
 /* VxWorks support for ELF
-   Copyright 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+   Copyright 2005, 2006, 2007, 2009, 2012 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -91,12 +91,13 @@
 
   if (!info->shared)
     {
-      s = bfd_make_section_with_flags (dynobj,
-				       bed->default_use_rela_p
-				       ? ".rela.plt.unloaded"
-				       : ".rel.plt.unloaded",
-				       SEC_HAS_CONTENTS | SEC_IN_MEMORY
-				       | SEC_READONLY | SEC_LINKER_CREATED);
+      s = bfd_make_section_anyway_with_flags (dynobj,
+					      bed->default_use_rela_p
+					      ? ".rela.plt.unloaded"
+					      : ".rel.plt.unloaded",
+					      SEC_HAS_CONTENTS | SEC_IN_MEMORY
+					      | SEC_READONLY
+					      | SEC_LINKER_CREATED);
       if (s == NULL
 	  || !bfd_set_section_alignment (dynobj, s, bed->s->log_file_align))
 	return FALSE;
@@ -194,7 +195,7 @@
 		{
 		  asection *sec = (*hash_ptr)->root.u.def.section;
 		  int this_idx = sec->output_section->target_index;
-		  
+
 		  irela[j].r_info
 		    = ELF32_R_INFO (this_idx, ELF32_R_TYPE (irela[j].r_info));
 		  irela[j].r_addend += (*hash_ptr)->root.u.def.value;
@@ -226,7 +227,7 @@
   if (!sec)
     return;
   d = elf_section_data (sec);
-  d->this_hdr.sh_link = elf_tdata (abfd)->symtab_section;
+  d->this_hdr.sh_link = elf_onesymtab (abfd);
   sec = bfd_get_section_by_name (abfd, ".plt");
   if (sec)
     d->this_hdr.sh_info = elf_section_data (sec)->this_idx;
@@ -261,33 +262,34 @@
 elf_vxworks_finish_dynamic_entry (bfd *output_bfd, Elf_Internal_Dyn *dyn)
 {
   asection *sec;
-  
+
   switch (dyn->d_tag)
     {
     default:
       return FALSE;
-      
+
     case DT_VX_WRS_TLS_DATA_START:
       sec = bfd_get_section_by_name (output_bfd, ".tls_data");
       dyn->d_un.d_ptr = sec->vma;
       break;
-      
+
     case DT_VX_WRS_TLS_DATA_SIZE:
       sec = bfd_get_section_by_name (output_bfd, ".tls_data");
       dyn->d_un.d_val = sec->size;
       break;
-      
+
     case DT_VX_WRS_TLS_DATA_ALIGN:
       sec = bfd_get_section_by_name (output_bfd, ".tls_data");
       dyn->d_un.d_val
-	= (bfd_size_type)1 << bfd_get_section_alignment (abfd, sec);
+	= (bfd_size_type)1 << bfd_get_section_alignment (output_bfd,
+							 sec);
       break;
-      
+
     case DT_VX_WRS_TLS_VARS_START:
       sec = bfd_get_section_by_name (output_bfd, ".tls_vars");
       dyn->d_un.d_ptr = sec->vma;
       break;
-      
+
     case DT_VX_WRS_TLS_VARS_SIZE:
       sec = bfd_get_section_by_name (output_bfd, ".tls_vars");
       dyn->d_un.d_val = sec->size;
diff --git a/bfd/elf.c b/bfd/elf.c
index 93b518d..8df38ee 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1,8 +1,6 @@
 /* ELF executable support for BFD.
 
-   Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-   Free Software Foundation, Inc.
+   Copyright 1993-2013 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -44,6 +42,7 @@
 #include "elf-bfd.h"
 #include "libiberty.h"
 #include "safe-ctype.h"
+#include "elf-linux-psinfo.h"
 
 #ifdef CORE_HEADER
 #include CORE_HEADER
@@ -244,7 +243,14 @@
     return FALSE;
 
   elf_object_id (abfd) = object_id;
-  elf_program_header_size (abfd) = (bfd_size_type) -1;
+  if (abfd->direction != read_direction)
+    {
+      struct output_elf_obj_tdata *o = bfd_zalloc (abfd, sizeof *o);
+      if (o == NULL)
+	return FALSE;
+      elf_tdata (abfd)->o = o;
+      elf_program_header_size (abfd) = (bfd_size_type) -1;
+    }
   return TRUE;
 }
 
@@ -261,7 +267,10 @@
 bfd_elf_mkcorefile (bfd *abfd)
 {
   /* I think this can be done just like an object file.  */
-  return abfd->xvec->_bfd_set_format[(int) bfd_object] (abfd);
+  if (!abfd->xvec->_bfd_set_format[(int) bfd_object] (abfd))
+    return FALSE;
+  elf_tdata (abfd)->core = bfd_zalloc (abfd, sizeof (*elf_tdata (abfd)->core));
+  return elf_tdata (abfd)->core != NULL;
 }
 
 static char *
@@ -545,9 +554,9 @@
       shnum = elf_numsections (abfd);
       num_group = 0;
 
-#define IS_VALID_GROUP_SECTION_HEADER(shdr)		\
+#define IS_VALID_GROUP_SECTION_HEADER(shdr, minsize)	\
 	(   (shdr)->sh_type == SHT_GROUP		\
-	 && (shdr)->sh_size >= (2 * GRP_ENTRY_SIZE)	\
+	 && (shdr)->sh_size >= minsize			\
 	 && (shdr)->sh_entsize == GRP_ENTRY_SIZE	\
 	 && ((shdr)->sh_size % GRP_ENTRY_SIZE) == 0)
 
@@ -555,7 +564,7 @@
 	{
 	  Elf_Internal_Shdr *shdr = elf_elfsections (abfd)[i];
 
-	  if (IS_VALID_GROUP_SECTION_HEADER (shdr))
+	  if (IS_VALID_GROUP_SECTION_HEADER (shdr, 2 * GRP_ENTRY_SIZE))
 	    num_group += 1;
 	}
 
@@ -581,7 +590,7 @@
 	    {
 	      Elf_Internal_Shdr *shdr = elf_elfsections (abfd)[i];
 
-	      if (IS_VALID_GROUP_SECTION_HEADER (shdr))
+	      if (IS_VALID_GROUP_SECTION_HEADER (shdr, 2 * GRP_ENTRY_SIZE))
 		{
 		  unsigned char *src;
 		  Elf_Internal_Group *dest;
@@ -1005,7 +1014,7 @@
       else
 	{
 	  /* Normal section.  Check if we should compress.  */
-	  if ((abfd->flags & BFD_COMPRESS))
+	  if ((abfd->flags & BFD_COMPRESS) && newsect->size != 0)
 	    action = compress;
 	}
 
@@ -1018,7 +1027,7 @@
 	  if (!bfd_init_section_compress_status (abfd, newsect))
 	    {
 	      (*_bfd_error_handler)
-		(_("%B: unable to initialize commpress status for section %s"),
+		(_("%B: unable to initialize compress status for section %s"),
 		 abfd, name);
 	      return FALSE;
 	    }
@@ -1038,7 +1047,7 @@
 	  if (!bfd_init_section_decompress_status (abfd, newsect))
 	    {
 	      (*_bfd_error_handler)
-		(_("%B: unable to initialize decommpress status for section %s"),
+		(_("%B: unable to initialize decompress status for section %s"),
 		 abfd, name);
 	      return FALSE;
 	    }
@@ -1434,9 +1443,9 @@
 	bfd_fprintf_vma (abfd, file, val);
 
 	/* If we have version information, print it.  */
-	if (elf_tdata (abfd)->dynversym_section != 0
-	    && (elf_tdata (abfd)->dynverdef_section != 0
-		|| elf_tdata (abfd)->dynverref_section != 0))
+	if (elf_dynversym (abfd) != 0
+	    && (elf_dynverdef (abfd) != 0
+		|| elf_dynverref (abfd) != 0))
 	  {
 	    unsigned int vernum;
 	    const char *version_string;
@@ -1626,7 +1635,15 @@
       if (hdr->sh_entsize != bed->s->sizeof_sym)
 	return FALSE;
       if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size)
-	return FALSE;
+	{
+	  if (hdr->sh_size != 0)
+	    return FALSE;
+	  /* Some assemblers erroneously set sh_info to one with a
+	     zero sh_size.  ld sees this as a global symbol count
+	     of (unsigned) -1.  Fix it here.  */
+	  hdr->sh_info = 0;
+	  return TRUE;
+	}
       BFD_ASSERT (elf_onesymtab (abfd) == 0);
       elf_onesymtab (abfd) = shindex;
       elf_tdata (abfd)->symtab_hdr = *hdr;
@@ -1679,6 +1696,16 @@
 
       if (hdr->sh_entsize != bed->s->sizeof_sym)
 	return FALSE;
+      if (hdr->sh_info * hdr->sh_entsize > hdr->sh_size)
+	{
+	  if (hdr->sh_size != 0)
+	    return FALSE;
+	  /* Some linkers erroneously set sh_info to one with a
+	     zero sh_size.  ld sees this as a global symbol count
+	     of (unsigned) -1.  Fix it here.  */
+	  hdr->sh_info = 0;
+	  return TRUE;
+	}
       BFD_ASSERT (elf_dynsymtab (abfd) == 0);
       elf_dynsymtab (abfd) = shindex;
       elf_tdata (abfd)->dynsymtab_hdr = *hdr;
@@ -1891,7 +1918,7 @@
       return TRUE;
 
     case SHT_GROUP:
-      if (! IS_VALID_GROUP_SECTION_HEADER (hdr))
+      if (! IS_VALID_GROUP_SECTION_HEADER (hdr, GRP_ENTRY_SIZE))
 	return FALSE;
       if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
 	return FALSE;
@@ -2043,6 +2070,9 @@
 {
   { STRING_COMMA_LEN (".data"),         -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
   { STRING_COMMA_LEN (".data1"),         0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
+  /* There are more DWARF sections than these, but they needn't be added here
+     unless you have to cope with broken compilers that don't emit section
+     attributes or you want to help the user writing assembler.  */
   { STRING_COMMA_LEN (".debug"),         0, SHT_PROGBITS, 0 },
   { STRING_COMMA_LEN (".debug_line"),    0, SHT_PROGBITS, 0 },
   { STRING_COMMA_LEN (".debug_info"),    0, SHT_PROGBITS, 0 },
@@ -2491,7 +2521,7 @@
    USE_RELA_P is TRUE, we use RELA relocations; otherwise, we use REL
    relocations.  */
 
-bfd_boolean
+static bfd_boolean
 _bfd_elf_init_reloc_shdr (bfd *abfd,
 			  struct bfd_elf_section_reloc_data *reldata,
 			  asection *asect,
@@ -2507,7 +2537,7 @@
   rel_hdr = bfd_zalloc (abfd, amt);
   reldata->hdr = rel_hdr;
 
-  amt = sizeof ".rela" + strlen (asect->name);      
+  amt = sizeof ".rela" + strlen (asect->name);
   name = (char *) bfd_alloc (abfd, amt);
   if (name == NULL)
     return FALSE;
@@ -2951,9 +2981,9 @@
 	d->rela.idx = 0;
     }
 
-  t->shstrtab_section = section_number++;
+  elf_shstrtab_sec (abfd) = section_number++;
   _bfd_elf_strtab_addref (elf_shstrtab (abfd), t->shstrtab_hdr.sh_name);
-  elf_elfheader (abfd)->e_shstrndx = t->shstrtab_section;
+  elf_elfheader (abfd)->e_shstrndx = elf_shstrtab_sec (abfd);
 
   need_symtab = (bfd_get_symcount (abfd) > 0
 		|| (link_info == NULL
@@ -2961,21 +2991,28 @@
 			== HAS_RELOC)));
   if (need_symtab)
     {
-      t->symtab_section = section_number++;
+      elf_onesymtab (abfd) = section_number++;
       _bfd_elf_strtab_addref (elf_shstrtab (abfd), t->symtab_hdr.sh_name);
       if (section_number > ((SHN_LORESERVE - 2) & 0xFFFF))
 	{
-	  t->symtab_shndx_section = section_number++;
+	  elf_symtab_shndx (abfd) = section_number++;
 	  t->symtab_shndx_hdr.sh_name
 	    = (unsigned int) _bfd_elf_strtab_add (elf_shstrtab (abfd),
 						  ".symtab_shndx", FALSE);
 	  if (t->symtab_shndx_hdr.sh_name == (unsigned int) -1)
 	    return FALSE;
 	}
-      t->strtab_section = section_number++;
+      elf_strtab_sec (abfd) = section_number++;
       _bfd_elf_strtab_addref (elf_shstrtab (abfd), t->strtab_hdr.sh_name);
     }
 
+  if (section_number >= SHN_LORESERVE)
+    {
+      _bfd_error_handler (_("%B: too many sections: %u"),
+			  abfd, section_number);
+      return FALSE;
+    }
+
   _bfd_elf_strtab_finalize (elf_shstrtab (abfd));
   t->shstrtab_hdr.sh_size = _bfd_elf_strtab_size (elf_shstrtab (abfd));
 
@@ -2999,17 +3036,17 @@
 
   elf_elfsections (abfd) = i_shdrp;
 
-  i_shdrp[t->shstrtab_section] = &t->shstrtab_hdr;
+  i_shdrp[elf_shstrtab_sec (abfd)] = &t->shstrtab_hdr;
   if (need_symtab)
     {
-      i_shdrp[t->symtab_section] = &t->symtab_hdr;
+      i_shdrp[elf_onesymtab (abfd)] = &t->symtab_hdr;
       if (elf_numsections (abfd) > (SHN_LORESERVE & 0xFFFF))
 	{
-	  i_shdrp[t->symtab_shndx_section] = &t->symtab_shndx_hdr;
-	  t->symtab_shndx_hdr.sh_link = t->symtab_section;
+	  i_shdrp[elf_symtab_shndx (abfd)] = &t->symtab_shndx_hdr;
+	  t->symtab_shndx_hdr.sh_link = elf_onesymtab (abfd);
 	}
-      i_shdrp[t->strtab_section] = &t->strtab_hdr;
-      t->symtab_hdr.sh_link = t->strtab_section;
+      i_shdrp[elf_strtab_sec (abfd)] = &t->strtab_hdr;
+      t->symtab_hdr.sh_link = elf_strtab_sec (abfd);
     }
 
   for (sec = abfd->sections; sec; sec = sec->next)
@@ -3032,12 +3069,12 @@
 	 the relocation entries apply.  */
       if (d->rel.idx != 0)
 	{
-	  d->rel.hdr->sh_link = t->symtab_section;
+	  d->rel.hdr->sh_link = elf_onesymtab (abfd);
 	  d->rel.hdr->sh_info = d->this_idx;
 	}
       if (d->rela.idx != 0)
 	{
-	  d->rela.hdr->sh_link = t->symtab_section;
+	  d->rela.hdr->sh_link = elf_onesymtab (abfd);
 	  d->rela.hdr->sh_info = d->this_idx;
 	}
 
@@ -3051,7 +3088,7 @@
 	      if (link_info != NULL)
 		{
 		  /* Check discarded linkonce section.  */
-		  if (elf_discarded_section (s))
+		  if (discarded_section (s))
 		    {
 		      asection *kept;
 		      (*_bfd_error_handler)
@@ -3192,7 +3229,7 @@
 	  break;
 
 	case SHT_GROUP:
-	  d->this_hdr.sh_link = t->symtab_section;
+	  d->this_hdr.sh_link = elf_onesymtab (abfd);
 	}
     }
 
@@ -3205,9 +3242,6 @@
   return TRUE;
 }
 
-/* Map symbol from it's internal number to the external number, moving
-   all local symbols to be at the head of the list.  */
-
 static bfd_boolean
 sym_is_global (bfd *abfd, asymbol *sym)
 {
@@ -3222,19 +3256,31 @@
 }
 
 /* Don't output section symbols for sections that are not going to be
-   output.  */
+   output, that are duplicates or there is no BFD section.  */
 
 static bfd_boolean
 ignore_section_sym (bfd *abfd, asymbol *sym)
 {
-  return ((sym->flags & BSF_SECTION_SYM) != 0
-	  && !(sym->section->owner == abfd
+  elf_symbol_type *type_ptr;
+
+  if ((sym->flags & BSF_SECTION_SYM) == 0)
+    return FALSE;
+
+  type_ptr = elf_symbol_from (abfd, sym);
+  return ((type_ptr != NULL
+	   && type_ptr->internal_elf_sym.st_shndx != 0
+	   && bfd_is_abs_section (sym->section))
+	  || !(sym->section->owner == abfd
 	       || (sym->section->output_section->owner == abfd
-		   && sym->section->output_offset == 0)));
+		   && sym->section->output_offset == 0)
+	       || bfd_is_abs_section (sym->section)));
 }
 
+/* Map symbol from it's internal number to the external number, moving
+   all local symbols to be at the head of the list.  */
+
 static bfd_boolean
-elf_map_symbols (bfd *abfd)
+elf_map_symbols (bfd *abfd, unsigned int *pnum_locals)
 {
   unsigned int symcount = bfd_get_symcount (abfd);
   asymbol **syms = bfd_get_outsymbols (abfd);
@@ -3274,7 +3320,8 @@
 
       if ((sym->flags & BSF_SECTION_SYM) != 0
 	  && sym->value == 0
-	  && !ignore_section_sym (abfd, sym))
+	  && !ignore_section_sym (abfd, sym)
+	  && !bfd_is_abs_section (sym->section))
 	{
 	  asection *sec = sym->section;
 
@@ -3288,12 +3335,10 @@
   /* Classify all of the symbols.  */
   for (idx = 0; idx < symcount; idx++)
     {
-      if (ignore_section_sym (abfd, syms[idx]))
-	continue;
-      if (!sym_is_global (abfd, syms[idx]))
-	num_locals++;
-      else
+      if (sym_is_global (abfd, syms[idx]))
 	num_globals++;
+      else if (!ignore_section_sym (abfd, syms[idx]))
+	num_locals++;
     }
 
   /* We will be adding a section symbol for each normal BFD section.  Most
@@ -3323,12 +3368,12 @@
       asymbol *sym = syms[idx];
       unsigned int i;
 
-      if (ignore_section_sym (abfd, sym))
-	continue;
-      if (!sym_is_global (abfd, sym))
+      if (sym_is_global (abfd, sym))
+	i = num_locals + num_globals2++;
+      else if (!ignore_section_sym (abfd, sym))
 	i = num_locals2++;
       else
-	i = num_locals + num_globals2++;
+	continue;
       new_syms[i] = sym;
       sym->udata.i = i + 1;
     }
@@ -3351,8 +3396,7 @@
 
   bfd_set_symtab (abfd, new_syms, num_locals + num_globals);
 
-  elf_num_locals (abfd) = num_locals;
-  elf_num_globals (abfd) = num_globals;
+  *pnum_locals = num_locals;
   return TRUE;
 }
 
@@ -3463,7 +3507,7 @@
       file_ptr off;
       Elf_Internal_Shdr *hdr;
 
-      off = elf_tdata (abfd)->next_file_pos;
+      off = elf_next_file_pos (abfd);
 
       hdr = &elf_tdata (abfd)->symtab_hdr;
       off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE);
@@ -3475,7 +3519,7 @@
       hdr = &elf_tdata (abfd)->strtab_hdr;
       off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE);
 
-      elf_tdata (abfd)->next_file_pos = off;
+      elf_next_file_pos (abfd) = off;
 
       /* Now that we know where the .strtab section goes, write it
 	 out.  */
@@ -3526,13 +3570,13 @@
       ++segs;
     }
 
-  if (elf_tdata (abfd)->eh_frame_hdr)
+  if (elf_eh_frame_hdr (abfd))
     {
       /* We need a PT_GNU_EH_FRAME segment.  */
       ++segs;
     }
 
-  if (elf_tdata (abfd)->stack_flags)
+  if (elf_stack_flags (abfd))
     {
       /* We need a PT_GNU_STACK segment.  */
       ++segs;
@@ -3594,8 +3638,7 @@
   struct elf_segment_map *m;
   Elf_Internal_Phdr *p;
 
-  for (m = elf_tdata (abfd)->segment_map,
-	 p = elf_tdata (abfd)->phdr;
+  for (m = elf_seg_map (abfd), p = elf_tdata (abfd)->phdr;
        m != NULL;
        m = m->next, p++)
     {
@@ -3679,7 +3722,7 @@
      sections from the segment map.  We also remove excluded
      sections.  Finally, any PT_LOAD segment without sections is
      removed.  */
-  m = &elf_tdata (abfd)->segment_map;
+  m = &elf_seg_map (abfd);
   while (*m)
     {
       unsigned int i, new_count;
@@ -3723,7 +3766,11 @@
   const struct elf_backend_data *bed = get_elf_backend_data (abfd);
   bfd_boolean no_user_phdrs;
 
-  no_user_phdrs = elf_tdata (abfd)->segment_map == NULL;
+  no_user_phdrs = elf_seg_map (abfd) == NULL;
+
+  if (info != NULL)
+    info->user_phdrs = !no_user_phdrs;
+
   if (no_user_phdrs && bfd_count_sections (abfd) != 0)
     {
       asection *s;
@@ -3830,10 +3877,11 @@
 	 program headers we will need.  */
       if (count > 0)
 	{
-	  bfd_size_type phdr_size = elf_tdata (abfd)->program_header_size;
+	  bfd_size_type phdr_size = elf_program_header_size (abfd);
 
 	  if (phdr_size == (bfd_size_type) -1)
 	    phdr_size = get_program_header_size (abfd, info);
+	  phdr_size += bed->s->sizeof_ehdr;
 	  if ((abfd->flags & D_PAGED) == 0
 	      || (sections[0]->lma & addr_mask) < phdr_size
 	      || ((sections[0]->lma & addr_mask) % maxpagesize
@@ -4074,7 +4122,7 @@
 
       /* If there is a .eh_frame_hdr section, throw in a PT_GNU_EH_FRAME
 	 segment.  */
-      eh_frame_hdr = elf_tdata (abfd)->eh_frame_hdr;
+      eh_frame_hdr = elf_eh_frame_hdr (abfd);
       if (eh_frame_hdr != NULL
 	  && (eh_frame_hdr->output_section->flags & SEC_LOAD) != 0)
 	{
@@ -4091,7 +4139,7 @@
 	  pm = &m->next;
 	}
 
-      if (elf_tdata (abfd)->stack_flags)
+      if (elf_stack_flags (abfd))
 	{
 	  amt = sizeof (struct elf_segment_map);
 	  m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
@@ -4099,8 +4147,15 @@
 	    goto error_return;
 	  m->next = NULL;
 	  m->p_type = PT_GNU_STACK;
-	  m->p_flags = elf_tdata (abfd)->stack_flags;
+	  m->p_flags = elf_stack_flags (abfd);
+	  m->p_align = bed->stack_align;
 	  m->p_flags_valid = 1;
+	  m->p_align_valid = m->p_align != 0;
+	  if (info->stacksize > 0)
+	    {
+	      m->p_size = info->stacksize;
+	      m->p_size_valid = 1;
+	    }
 
 	  *pm = m;
 	  pm = &m->next;
@@ -4110,18 +4165,25 @@
 	{
 	  for (m = mfirst; m != NULL; m = m->next)
 	    {
-	      if (m->p_type == PT_LOAD)
+	      if (m->p_type == PT_LOAD
+		  && m->count != 0
+		  && m->sections[0]->vma >= info->relro_start
+		  && m->sections[0]->vma < info->relro_end)
 		{
-		  asection *last = m->sections[m->count - 1];
-		  bfd_vma vaddr = m->sections[0]->vma;
-		  bfd_vma filesz = last->vma - vaddr + last->size;
+		  i = m->count;
+		  while (--i != (unsigned) -1)
+		    if ((m->sections[i]->flags & (SEC_LOAD | SEC_HAS_CONTENTS))
+			== (SEC_LOAD | SEC_HAS_CONTENTS))
+		      break;
 
-		  if (vaddr < info->relro_end
-		      && vaddr >= info->relro_start
-		      && (vaddr + filesz) >= info->relro_end)
+		  if (i == (unsigned) -1)
+		    continue;
+
+		  if (m->sections[i]->vma + m->sections[i]->size
+		      >= info->relro_end)
 		    break;
 		}
-	      }
+	    }
 
 	  /* Make a PT_GNU_RELRO segment only when it isn't empty.  */
 	  if (m != NULL)
@@ -4141,15 +4203,15 @@
 	}
 
       free (sections);
-      elf_tdata (abfd)->segment_map = mfirst;
+      elf_seg_map (abfd) = mfirst;
     }
 
   if (!elf_modify_segment_map (abfd, info, no_user_phdrs))
     return FALSE;
 
-  for (count = 0, m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+  for (count = 0, m = elf_seg_map (abfd); m != NULL; m = m->next)
     ++count;
-  elf_tdata (abfd)->program_header_size = count * bed->s->sizeof_phdr;
+  elf_program_header_size (abfd) = count * bed->s->sizeof_phdr;
 
   return TRUE;
 
@@ -4313,7 +4375,7 @@
     return FALSE;
 
   alloc = 0;
-  for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+  for (m = elf_seg_map (abfd); m != NULL; m = m->next)
     {
       ++alloc;
       if (m->header_size)
@@ -4331,35 +4393,35 @@
       elf_elfheader (abfd)->e_phoff = 0;
       elf_elfheader (abfd)->e_phentsize = 0;
     }
-  
+
   elf_elfheader (abfd)->e_phnum = alloc;
 
-  if (elf_tdata (abfd)->program_header_size == (bfd_size_type) -1)
-    elf_tdata (abfd)->program_header_size = alloc * bed->s->sizeof_phdr;
+  if (elf_program_header_size (abfd) == (bfd_size_type) -1)
+    elf_program_header_size (abfd) = alloc * bed->s->sizeof_phdr;
   else
-    BFD_ASSERT (elf_tdata (abfd)->program_header_size
+    BFD_ASSERT (elf_program_header_size (abfd)
 		>= alloc * bed->s->sizeof_phdr);
 
   if (alloc == 0)
     {
-      elf_tdata (abfd)->next_file_pos = bed->s->sizeof_ehdr;
+      elf_next_file_pos (abfd) = bed->s->sizeof_ehdr;
       return TRUE;
     }
 
-  /* We're writing the size in elf_tdata (abfd)->program_header_size,
+  /* We're writing the size in elf_program_header_size (abfd),
      see assign_file_positions_except_relocs, so make sure we have
      that amount allocated, with trailing space cleared.
-     The variable alloc contains the computed need, while elf_tdata
-     (abfd)->program_header_size contains the size used for the
+     The variable alloc contains the computed need, while
+     elf_program_header_size (abfd) contains the size used for the
      layout.
      See ld/emultempl/elf-generic.em:gld${EMULATION_NAME}_map_segments
      where the layout is forced to according to a larger size in the
      last iterations for the testcase ld-elf/header.  */
-  BFD_ASSERT (elf_tdata (abfd)->program_header_size % bed->s->sizeof_phdr
+  BFD_ASSERT (elf_program_header_size (abfd) % bed->s->sizeof_phdr
 	      == 0);
   phdrs = (Elf_Internal_Phdr *)
      bfd_zalloc2 (abfd,
-                  (elf_tdata (abfd)->program_header_size / bed->s->sizeof_phdr),
+                  (elf_program_header_size (abfd) / bed->s->sizeof_phdr),
                   sizeof (Elf_Internal_Phdr));
   elf_tdata (abfd)->phdr = phdrs;
   if (phdrs == NULL)
@@ -4377,7 +4439,7 @@
     header_pad -= off;
   off += header_pad;
 
-  for (m = elf_tdata (abfd)->segment_map, p = phdrs, j = 0;
+  for (m = elf_seg_map (abfd), p = phdrs, j = 0;
        m != NULL;
        m = m->next, p++, j++)
     {
@@ -4526,8 +4588,6 @@
 	  p->p_memsz = bed->s->sizeof_ehdr;
 	  if (m->count > 0)
 	    {
-	      BFD_ASSERT (p->p_type == PT_LOAD);
-
 	      if (p->p_vaddr < (bfd_vma) off)
 		{
 		  (*_bfd_error_handler)
@@ -4554,7 +4614,6 @@
 
 	      if (m->count > 0)
 		{
-		  BFD_ASSERT (p->p_type == PT_LOAD);
 		  p->p_vaddr -= off - p->p_offset;
 		  if (!m->p_paddr_valid)
 		    p->p_paddr -= off - p->p_offset;
@@ -4761,7 +4820,7 @@
 	}
     }
 
-  elf_tdata (abfd)->next_file_pos = off;
+  elf_next_file_pos (abfd) = off;
   return TRUE;
 }
 
@@ -4777,6 +4836,7 @@
   Elf_Internal_Phdr *phdrs;
   Elf_Internal_Phdr *p;
   struct elf_segment_map *m;
+  struct elf_segment_map *hdrs_segment;
   bfd_vma filehdr_vaddr, filehdr_paddr;
   bfd_vma phdrs_vaddr, phdrs_paddr;
   file_ptr off;
@@ -4786,10 +4846,9 @@
 
   i_shdrpp = elf_elfsections (abfd);
   num_sec = elf_numsections (abfd);
-  off = elf_tdata (abfd)->next_file_pos;
+  off = elf_next_file_pos (abfd);
   for (i = 1, hdrpp = i_shdrpp + 1; i < num_sec; i++, hdrpp++)
     {
-      struct elf_obj_tdata *tdata = elf_tdata (abfd);
       Elf_Internal_Shdr *hdr;
 
       hdr = *hdrpp;
@@ -4800,12 +4859,13 @@
 	BFD_ASSERT (hdr->sh_offset == hdr->bfd_section->filepos);
       else if ((hdr->sh_flags & SHF_ALLOC) != 0)
 	{
-	  (*_bfd_error_handler)
-	    (_("%B: warning: allocated section `%s' not in segment"),
-	     abfd,
-	     (hdr->bfd_section == NULL
-	      ? "*unknown*"
-	      : hdr->bfd_section->name));
+	  if (hdr->sh_size != 0)
+	    (*_bfd_error_handler)
+	      (_("%B: warning: allocated section `%s' not in segment"),
+	       abfd,
+	       (hdr->bfd_section == NULL
+		? "*unknown*"
+		: hdr->bfd_section->name));
 	  /* We don't need to page align empty sections.  */
 	  if ((abfd->flags & D_PAGED) != 0 && hdr->sh_size != 0)
 	    off += vma_page_aligned_bias (hdr->sh_addr, off,
@@ -4818,9 +4878,9 @@
 	}
       else if (((hdr->sh_type == SHT_REL || hdr->sh_type == SHT_RELA)
 		&& hdr->bfd_section == NULL)
-	       || hdr == i_shdrpp[tdata->symtab_section]
-	       || hdr == i_shdrpp[tdata->symtab_shndx_section]
-	       || hdr == i_shdrpp[tdata->strtab_section])
+	       || hdr == i_shdrpp[elf_onesymtab (abfd)]
+	       || hdr == i_shdrpp[elf_symtab_shndx (abfd)]
+	       || hdr == i_shdrpp[elf_strtab_sec (abfd)])
 	hdr->sh_offset = -1;
       else
 	off = _bfd_elf_assign_file_position_for_section (hdr, off, TRUE);
@@ -4833,10 +4893,9 @@
   filehdr_paddr = 0;
   phdrs_vaddr = bed->maxpagesize + bed->s->sizeof_ehdr;
   phdrs_paddr = 0;
+  hdrs_segment = NULL;
   phdrs = elf_tdata (abfd)->phdr;
-  for (m = elf_tdata (abfd)->segment_map, p = phdrs;
-       m != NULL;
-       m = m->next, p++)
+  for (m = elf_seg_map (abfd), p = phdrs; m != NULL; m = m->next, p++)
     {
       ++count;
       if (p->p_type != PT_LOAD)
@@ -4853,34 +4912,85 @@
 	  phdrs_paddr = p->p_paddr;
 	  if (m->includes_filehdr)
 	    {
+	      hdrs_segment = m;
 	      phdrs_vaddr += bed->s->sizeof_ehdr;
 	      phdrs_paddr += bed->s->sizeof_ehdr;
 	    }
 	}
     }
 
-  for (m = elf_tdata (abfd)->segment_map, p = phdrs;
-       m != NULL;
-       m = m->next, p++)
+  if (hdrs_segment != NULL && link_info != NULL)
+    {
+      /* There is a segment that contains both the file headers and the
+	 program headers, so provide a symbol __ehdr_start pointing there.
+	 A program can use this to examine itself robustly.  */
+
+      struct elf_link_hash_entry *hash
+	= elf_link_hash_lookup (elf_hash_table (link_info), "__ehdr_start",
+				FALSE, FALSE, TRUE);
+      /* If the symbol was referenced and not defined, define it.  */
+      if (hash != NULL
+	  && (hash->root.type == bfd_link_hash_new
+	      || hash->root.type == bfd_link_hash_undefined
+	      || hash->root.type == bfd_link_hash_undefweak
+	      || hash->root.type == bfd_link_hash_common))
+	{
+	  asection *s = NULL;
+	  if (hdrs_segment->count != 0)
+	    /* The segment contains sections, so use the first one.  */
+	    s = hdrs_segment->sections[0];
+	  else
+	    /* Use the first (i.e. lowest-addressed) section in any segment.  */
+	    for (m = elf_seg_map (abfd); m != NULL; m = m->next)
+	      if (m->count != 0)
+		{
+		  s = m->sections[0];
+		  break;
+		}
+
+	  if (s != NULL)
+	    {
+	      hash->root.u.def.value = filehdr_vaddr - s->vma;
+	      hash->root.u.def.section = s;
+	    }
+	  else
+	    {
+	      hash->root.u.def.value = filehdr_vaddr;
+	      hash->root.u.def.section = bfd_abs_section_ptr;
+	    }
+
+	  hash->root.type = bfd_link_hash_defined;
+	  hash->def_regular = 1;
+	  hash->non_elf = 0;
+	}
+    }
+
+  for (m = elf_seg_map (abfd), p = phdrs; m != NULL; m = m->next, p++)
     {
       if (p->p_type == PT_GNU_RELRO)
 	{
 	  const Elf_Internal_Phdr *lp;
-
-	  BFD_ASSERT (!m->includes_filehdr && !m->includes_phdrs);
+	  struct elf_segment_map *lm;
 
 	  if (link_info != NULL)
 	    {
 	      /* During linking the range of the RELRO segment is passed
 		 in link_info.  */
-	      for (lp = phdrs; lp < phdrs + count; ++lp)
+	      for (lm = elf_seg_map (abfd), lp = phdrs;
+		   lm != NULL;
+		   lm = lm->next, lp++)
 		{
 		  if (lp->p_type == PT_LOAD
-		      && lp->p_vaddr >= link_info->relro_start
 		      && lp->p_vaddr < link_info->relro_end
-		      && lp->p_vaddr + lp->p_filesz >= link_info->relro_end)
+		      && lp->p_vaddr + lp->p_filesz >= link_info->relro_end
+		      && lm->count != 0
+		      && lm->sections[0]->vma >= link_info->relro_start)
 		    break;
 		}
+
+	      /* PR ld/14207.  If the RELRO segment doesn't fit in the
+		 LOAD segment, it should be removed.  */
+	      BFD_ASSERT (lm != NULL);
 	    }
 	  else
 	    {
@@ -4906,10 +5016,11 @@
 	      else
 		abort ();
 	      p->p_memsz = p->p_filesz;
-	      /* Preserve the alignment and flags if they are valid. The gold
-		 linker generates RW/4 for the PT_GNU_RELRO section. It is
-		 better for objcopy/strip to honor these attributes otherwise
-		 gdb will choke when using separate debug files. */
+	      /* Preserve the alignment and flags if they are valid. The
+	         gold linker generates RW/4 for the PT_GNU_RELRO section.
+		 It is better for objcopy/strip to honor these attributes
+		 otherwise gdb will choke when using separate debug files.
+	       */
 	      if (!m->p_align_valid)
 		p->p_align = 1;
 	      if (!m->p_flags_valid)
@@ -4921,6 +5032,11 @@
 	      p->p_type = PT_NULL;
 	    }
 	}
+      else if (p->p_type == PT_GNU_STACK)
+	{
+	  if (m->p_size_valid)
+	    p->p_memsz = m->p_size;
+	}
       else if (m->count != 0)
 	{
 	  if (p->p_type != PT_LOAD
@@ -4958,7 +5074,7 @@
 	}
     }
 
-  elf_tdata (abfd)->next_file_pos = off;
+  elf_next_file_pos (abfd) = off;
 
   return TRUE;
 }
@@ -5007,9 +5123,9 @@
 	  hdr = *hdrpp;
 	  if (((hdr->sh_type == SHT_REL || hdr->sh_type == SHT_RELA)
 	       && hdr->bfd_section == NULL)
-	      || i == tdata->symtab_section
-	      || i == tdata->symtab_shndx_section
-	      || i == tdata->strtab_section)
+	      || i == elf_onesymtab (abfd)
+	      || i == elf_symtab_shndx (abfd)
+	      || i == elf_strtab_sec (abfd))
 	    {
 	      hdr->sh_offset = -1;
 	    }
@@ -5037,12 +5153,12 @@
 	}
 
       /* Write out the program headers.  */
-      alloc = tdata->program_header_size / bed->s->sizeof_phdr;
+      alloc = elf_program_header_size (abfd) / bed->s->sizeof_phdr;
       if (bfd_seek (abfd, (bfd_signed_vma) bed->s->sizeof_ehdr, SEEK_SET) != 0
 	  || bed->s->write_out_phdrs (abfd, tdata->phdr, alloc) != 0)
 	return FALSE;
 
-      off = tdata->next_file_pos;
+      off = elf_next_file_pos (abfd);
     }
 
   /* Place the section headers.  */
@@ -5050,7 +5166,7 @@
   i_ehdrp->e_shoff = off;
   off += i_ehdrp->e_shnum * i_ehdrp->e_shentsize;
 
-  tdata->next_file_pos = off;
+  elf_next_file_pos (abfd) = off;
 
   return TRUE;
 }
@@ -5153,7 +5269,7 @@
   unsigned int i, num_sec;
   Elf_Internal_Shdr **shdrpp;
 
-  off = elf_tdata (abfd)->next_file_pos;
+  off = elf_next_file_pos (abfd);
 
   num_sec = elf_numsections (abfd);
   for (i = 1, shdrpp = elf_elfsections (abfd) + 1; i < num_sec; i++, shdrpp++)
@@ -5166,7 +5282,7 @@
 	off = _bfd_elf_assign_file_position_for_section (shdrp, off, TRUE);
     }
 
-  elf_tdata (abfd)->next_file_pos = off;
+  elf_next_file_pos (abfd) = off;
 }
 
 bfd_boolean
@@ -5176,6 +5292,7 @@
   Elf_Internal_Shdr **i_shdrp;
   bfd_boolean failed;
   unsigned int count, num_sec;
+  struct elf_obj_tdata *t;
 
   if (! abfd->output_has_begun
       && ! _bfd_elf_compute_section_file_positions (abfd, NULL))
@@ -5207,21 +5324,21 @@
     }
 
   /* Write out the section header names.  */
+  t = elf_tdata (abfd);
   if (elf_shstrtab (abfd) != NULL
-      && (bfd_seek (abfd, elf_tdata (abfd)->shstrtab_hdr.sh_offset, SEEK_SET) != 0
+      && (bfd_seek (abfd, t->shstrtab_hdr.sh_offset, SEEK_SET) != 0
 	  || !_bfd_elf_strtab_emit (abfd, elf_shstrtab (abfd))))
     return FALSE;
 
   if (bed->elf_backend_final_write_processing)
-    (*bed->elf_backend_final_write_processing) (abfd,
-						elf_tdata (abfd)->linker);
+    (*bed->elf_backend_final_write_processing) (abfd, elf_linker (abfd));
 
   if (!bed->s->write_shdrs_and_ehdr (abfd))
     return FALSE;
 
   /* This is last since write_shdrs_and_ehdr can touch i_shdrp[0].  */
-  if (elf_tdata (abfd)->after_write_object_contents)
-    return (*elf_tdata (abfd)->after_write_object_contents) (abfd);
+  if (t->o->build_id.after_write_object_contents != NULL)
+    return (*t->o->build_id.after_write_object_contents) (abfd);
 
   return TRUE;
 }
@@ -5413,7 +5530,7 @@
        1. It is within the address space of the segment -- we use the LMA
 	  if that is set for the segment and the VMA otherwise,
        2. It is an allocated section or a NOTE section in a PT_NOTE
-	  segment.         
+	  segment.
        3. There is an output section associated with it,
        4. The section has not already been allocated to a previous segment.
        5. PT_GNU_STACK segments do not include any sections.
@@ -5930,7 +6047,7 @@
 		 and carry on looping.  */
 	      amt = sizeof (struct elf_segment_map);
 	      amt += ((bfd_size_type) section_count - 1) * sizeof (asection *);
-	      map = (struct elf_segment_map *) bfd_alloc (obfd, amt);
+	      map = (struct elf_segment_map *) bfd_zalloc (obfd, amt);
 	      if (map == NULL)
 		{
 		  free (sections);
@@ -5955,7 +6072,7 @@
       free (sections);
     }
 
-  elf_tdata (obfd)->segment_map = map_first;
+  elf_seg_map (obfd) = map_first;
 
   /* If we had to estimate the number of program headers that were
      going to be needed, then check our estimate now and adjust
@@ -6065,12 +6182,15 @@
       map->p_align_valid = 1;
       map->p_vaddr_offset = 0;
 
-      if (map->p_type == PT_GNU_RELRO)
+      if (map->p_type == PT_GNU_RELRO
+	  || map->p_type == PT_GNU_STACK)
 	{
 	  /* The PT_GNU_RELRO segment may contain the first a few
 	     bytes in the .got.plt section even if the whole .got.plt
 	     section isn't in the PT_GNU_RELRO segment.  We won't
-	     change the size of the PT_GNU_RELRO segment.  */
+	     change the size of the PT_GNU_RELRO segment.
+	     Similarly, PT_GNU_STACK size is significant on uclinux
+	     systems.    */
 	  map->p_size = segment->p_memsz;
 	  map->p_size_valid = 1;
 	}
@@ -6106,12 +6226,13 @@
 	      if (ELF_SECTION_IN_SEGMENT (this_hdr, segment))
 		{
 		  map->sections[isec++] = section->output_section;
-		  if (section->lma < lowest_section->lma)
-		    lowest_section = section;
 		  if ((section->flags & SEC_ALLOC) != 0)
 		    {
 		      bfd_vma seg_off;
 
+		      if (section->lma < lowest_section->lma)
+			lowest_section = section;
+
 		      /* Section lmas are set up from PT_LOAD header
 			 p_paddr in _bfd_elf_make_section_from_shdr.
 			 If this header has a p_paddr that disagrees
@@ -6133,7 +6254,7 @@
       if (map->includes_filehdr && lowest_section != NULL)
 	/* We need to keep the space used by the headers fixed.  */
 	map->header_size = lowest_section->vma - segment->p_vaddr;
-      
+
       if (!map->includes_phdrs
 	  && !map->includes_filehdr
 	  && map->p_paddr_valid)
@@ -6146,7 +6267,7 @@
       pointer_to_map = &map->next;
     }
 
-  elf_tdata (obfd)->segment_map = map_first;
+  elf_seg_map (obfd) = map_first;
   return TRUE;
 }
 
@@ -6240,6 +6361,26 @@
     }
 
 rewrite:
+  if (ibfd->xvec == obfd->xvec)
+    {
+      /* When rewriting program header, set the output maxpagesize to
+	 the maximum alignment of input PT_LOAD segments.  */
+      Elf_Internal_Phdr *segment;
+      unsigned int i;
+      unsigned int num_segments = elf_elfheader (ibfd)->e_phnum;
+      bfd_vma maxpagesize = 0;
+
+      for (i = 0, segment = elf_tdata (ibfd)->phdr;
+	   i < num_segments;
+	   i++, segment++)
+	if (segment->p_type == PT_LOAD
+	    && maxpagesize < segment->p_align)
+	  maxpagesize = segment->p_align;
+
+      if (maxpagesize != get_elf_backend_data (obfd)->maxpagesize)
+	bfd_emul_set_maxpagesize (bfd_get_target (obfd), maxpagesize);
+    }
+
   return rewrite_elf_program_header (ibfd, obfd);
 }
 
@@ -6417,7 +6558,7 @@
      entry point, because the latter is called after the section
      contents have been set, which means that the program headers have
      already been worked out.  */
-  if (elf_tdata (obfd)->segment_map == NULL && elf_tdata (ibfd)->phdr != NULL)
+  if (elf_seg_map (obfd) == NULL && elf_tdata (ibfd)->phdr != NULL)
     {
       if (! copy_private_bfd_data (ibfd, obfd))
 	return FALSE;
@@ -6465,11 +6606,11 @@
 	shndx = MAP_ONESYMTAB;
       else if (shndx == elf_dynsymtab (ibfd))
 	shndx = MAP_DYNSYMTAB;
-      else if (shndx == elf_tdata (ibfd)->strtab_section)
+      else if (shndx == elf_strtab_sec (ibfd))
 	shndx = MAP_STRTAB;
-      else if (shndx == elf_tdata (ibfd)->shstrtab_section)
+      else if (shndx == elf_shstrtab_sec (ibfd))
 	shndx = MAP_SHSTRTAB;
-      else if (shndx == elf_tdata (ibfd)->symtab_shndx_section)
+      else if (shndx == elf_symtab_shndx (ibfd))
 	shndx = MAP_SYM_SHNDX;
       osym->internal_elf_sym.st_shndx = shndx;
     }
@@ -6494,10 +6635,11 @@
   bfd_byte *outbound_syms;
   bfd_byte *outbound_shndx;
   int idx;
+  unsigned int num_locals;
   bfd_size_type amt;
   bfd_boolean name_local_sections;
 
-  if (!elf_map_symbols (abfd))
+  if (!elf_map_symbols (abfd, &num_locals))
     return FALSE;
 
   /* Dump out the symtabs.  */
@@ -6511,7 +6653,7 @@
   symtab_hdr->sh_type = SHT_SYMTAB;
   symtab_hdr->sh_entsize = bed->s->sizeof_sym;
   symtab_hdr->sh_size = symtab_hdr->sh_entsize * (symcount + 1);
-  symtab_hdr->sh_info = elf_num_locals (abfd) + 1;
+  symtab_hdr->sh_info = num_locals + 1;
   symtab_hdr->sh_addralign = (bfd_vma) 1 << bed->s->log_file_align;
 
   symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr;
@@ -6645,15 +6787,16 @@
 		  shndx = elf_dynsymtab (abfd);
 		  break;
 		case MAP_STRTAB:
-		  shndx = elf_tdata (abfd)->strtab_section;
+		  shndx = elf_strtab_sec (abfd);
 		  break;
 		case MAP_SHSTRTAB:
-		  shndx = elf_tdata (abfd)->shstrtab_section;
+		  shndx = elf_shstrtab_sec (abfd);
 		  break;
 		case MAP_SYM_SHNDX:
-		  shndx = elf_tdata (abfd)->symtab_shndx_section;
+		  shndx = elf_symtab_shndx (abfd);
 		  break;
 		default:
+		  shndx = SHN_ABS;
 		  break;
 		}
 	    }
@@ -7246,7 +7389,7 @@
       Elf_Internal_Verdef *iverdef;
       Elf_Internal_Verdaux *iverdaux;
 
-      iverdef = &elf_tdata (abfd)->verdef[freeidx - 1];;
+      iverdef = &elf_tdata (abfd)->verdef[freeidx - 1];
 
       iverdef->vd_version = VER_DEF_CURRENT;
       iverdef->vd_flags = 0;
@@ -7364,18 +7507,29 @@
 		   const char **filename_ptr,
 		   const char **functionname_ptr)
 {
-  static asection *last_section;
-  static asymbol *func;
-  static const char *filename;
-  static bfd_size_type func_size;
+  struct elf_find_function_cache
+  {
+    asection *last_section;
+    asymbol *func;
+    const char *filename;
+    bfd_size_type func_size;
+  } *cache;
 
   if (symbols == NULL)
     return FALSE;
 
-  if (last_section != section
-      || func == NULL
-      || offset < func->value
-      || offset >= func->value + func_size)
+  cache = elf_tdata (abfd)->elf_find_function_cache;
+  if (cache == NULL)
+    {
+      cache = bfd_zalloc (abfd, sizeof (*cache));
+      elf_tdata (abfd)->elf_find_function_cache = cache;
+      if (cache == NULL)
+	return FALSE;
+    }
+  if (cache->last_section != section
+      || cache->func == NULL
+      || offset < cache->func->value
+      || offset >= cache->func->value + cache->func_size)
     {
       asymbol *file;
       bfd_vma low_func;
@@ -7391,13 +7545,13 @@
       enum { nothing_seen, symbol_seen, file_after_symbol_seen } state;
       const struct elf_backend_data *bed = get_elf_backend_data (abfd);
 
-      filename = NULL;
-      func = NULL;
       file = NULL;
       low_func = 0;
       state = nothing_seen;
-      func_size = 0;
-      last_section = section;
+      cache->filename = NULL;
+      cache->func = NULL;
+      cache->func_size = 0;
+      cache->last_section = section;
 
       for (p = symbols; *p != NULL; p++)
 	{
@@ -7418,29 +7572,29 @@
 	      && code_off <= offset
 	      && (code_off > low_func
 		  || (code_off == low_func
-		      && size > func_size)))
+		      && size > cache->func_size)))
 	    {
-	      func = sym;
-	      func_size = size;
+	      cache->func = sym;
+	      cache->func_size = size;
+	      cache->filename = NULL;
 	      low_func = code_off;
-	      filename = NULL;
 	      if (file != NULL
 		  && ((sym->flags & BSF_LOCAL) != 0
 		      || state != file_after_symbol_seen))
-		filename = bfd_asymbol_name (file);
+		cache->filename = bfd_asymbol_name (file);
 	    }
 	  if (state == nothing_seen)
 	    state = symbol_seen;
 	}
     }
 
-  if (func == NULL)
+  if (cache->func == NULL)
     return FALSE;
 
   if (filename_ptr)
-    *filename_ptr = filename;
+    *filename_ptr = cache->filename;
   if (functionname_ptr)
-    *functionname_ptr = bfd_asymbol_name (func);
+    *functionname_ptr = bfd_asymbol_name (cache->func);
 
   return TRUE;
 }
@@ -7488,7 +7642,8 @@
       return TRUE;
     }
 
-  if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
+  if (_bfd_dwarf2_find_nearest_line (abfd, dwarf_debug_sections,
+                                     section, symbols, offset,
 				     filename_ptr, functionname_ptr,
 				     line_ptr, discriminator_ptr, 0,
 				     &elf_tdata (abfd)->dwarf2_find_line_info))
@@ -7569,21 +7724,21 @@
 
   if (!info->relocatable)
     {
-      bfd_size_type phdr_size = elf_tdata (abfd)->program_header_size;
+      bfd_size_type phdr_size = elf_program_header_size (abfd);
 
       if (phdr_size == (bfd_size_type) -1)
 	{
 	  struct elf_segment_map *m;
 
 	  phdr_size = 0;
-	  for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+	  for (m = elf_seg_map (abfd); m != NULL; m = m->next)
 	    phdr_size += bed->s->sizeof_phdr;
 
 	  if (phdr_size == 0)
 	    phdr_size = get_program_header_size (abfd, info);
 	}
 
-      elf_tdata (abfd)->program_header_size = phdr_size;
+      elf_program_header_size (abfd) = phdr_size;
       ret += phdr_size;
     }
 
@@ -7720,11 +7875,12 @@
 bfd_boolean
 _bfd_elf_close_and_cleanup (bfd *abfd)
 {
-  if (bfd_get_format (abfd) == bfd_object)
+  struct elf_obj_tdata *tdata = elf_tdata (abfd);
+  if (bfd_get_format (abfd) == bfd_object && tdata != NULL)
     {
-      if (elf_tdata (abfd) != NULL && elf_shstrtab (abfd) != NULL)
+      if (elf_tdata (abfd)->o != NULL && elf_shstrtab (abfd) != NULL)
 	_bfd_elf_strtab_free (elf_shstrtab (abfd));
-      _bfd_dwarf2_cleanup_debug_info (abfd);
+      _bfd_dwarf2_cleanup_debug_info (abfd, &tdata->dwarf2_find_line_info);
     }
 
   return _bfd_generic_close_and_cleanup (abfd);
@@ -7764,9 +7920,9 @@
 {
   int pid;
 
-  pid = elf_tdata (abfd)->core_lwpid;
+  pid = elf_tdata (abfd)->core->lwpid;
   if (pid == 0)
-    pid = elf_tdata (abfd)->core_pid;
+    pid = elf_tdata (abfd)->core->pid;
 
   return pid;
 }
@@ -7856,10 +8012,10 @@
 
       /* Do not overwrite the core signal if it
 	 has already been set by another thread.  */
-      if (elf_tdata (abfd)->core_signal == 0)
-	elf_tdata (abfd)->core_signal = prstat.pr_cursig;
-      if (elf_tdata (abfd)->core_pid == 0)
-	elf_tdata (abfd)->core_pid = prstat.pr_pid;
+      if (elf_tdata (abfd)->core->signal == 0)
+	elf_tdata (abfd)->core->signal = prstat.pr_cursig;
+      if (elf_tdata (abfd)->core->pid == 0)
+	elf_tdata (abfd)->core->pid = prstat.pr_pid;
 
       /* pr_who exists on:
 	 solaris 2.5+
@@ -7868,9 +8024,9 @@
 	 linux 2.[01]
 	 */
 #if defined (HAVE_PRSTATUS_T_PR_WHO)
-      elf_tdata (abfd)->core_lwpid = prstat.pr_who;
+      elf_tdata (abfd)->core->lwpid = prstat.pr_who;
 #else
-      elf_tdata (abfd)->core_lwpid = prstat.pr_pid;
+      elf_tdata (abfd)->core->lwpid = prstat.pr_pid;
 #endif
     }
 #if defined (HAVE_PRSTATUS32_T)
@@ -7885,10 +8041,10 @@
 
       /* Do not overwrite the core signal if it
 	 has already been set by another thread.  */
-      if (elf_tdata (abfd)->core_signal == 0)
-	elf_tdata (abfd)->core_signal = prstat.pr_cursig;
-      if (elf_tdata (abfd)->core_pid == 0)
-	elf_tdata (abfd)->core_pid = prstat.pr_pid;
+      if (elf_tdata (abfd)->core->signal == 0)
+	elf_tdata (abfd)->core->signal = prstat.pr_cursig;
+      if (elf_tdata (abfd)->core->pid == 0)
+	elf_tdata (abfd)->core->pid = prstat.pr_pid;
 
       /* pr_who exists on:
 	 solaris 2.5+
@@ -7897,9 +8053,9 @@
 	 linux 2.[01]
 	 */
 #if defined (HAVE_PRSTATUS32_T_PR_WHO)
-      elf_tdata (abfd)->core_lwpid = prstat.pr_who;
+      elf_tdata (abfd)->core->lwpid = prstat.pr_who;
 #else
-      elf_tdata (abfd)->core_lwpid = prstat.pr_pid;
+      elf_tdata (abfd)->core->lwpid = prstat.pr_pid;
 #endif
     }
 #endif /* HAVE_PRSTATUS32_T */
@@ -8005,11 +8161,47 @@
 }
 
 static bfd_boolean
+elfcore_grok_s390_last_break (bfd *abfd, Elf_Internal_Note *note)
+{
+  return elfcore_make_note_pseudosection (abfd, ".reg-s390-last-break", note);
+}
+
+static bfd_boolean
+elfcore_grok_s390_system_call (bfd *abfd, Elf_Internal_Note *note)
+{
+  return elfcore_make_note_pseudosection (abfd, ".reg-s390-system-call", note);
+}
+
+static bfd_boolean
+elfcore_grok_s390_tdb (bfd *abfd, Elf_Internal_Note *note)
+{
+  return elfcore_make_note_pseudosection (abfd, ".reg-s390-tdb", note);
+}
+
+static bfd_boolean
 elfcore_grok_arm_vfp (bfd *abfd, Elf_Internal_Note *note)
 {
   return elfcore_make_note_pseudosection (abfd, ".reg-arm-vfp", note);
 }
 
+static bfd_boolean
+elfcore_grok_aarch_tls (bfd *abfd, Elf_Internal_Note *note)
+{
+  return elfcore_make_note_pseudosection (abfd, ".reg-aarch-tls", note);
+}
+
+static bfd_boolean
+elfcore_grok_aarch_hw_break (bfd *abfd, Elf_Internal_Note *note)
+{
+  return elfcore_make_note_pseudosection (abfd, ".reg-aarch-hw-break", note);
+}
+
+static bfd_boolean
+elfcore_grok_aarch_hw_watch (bfd *abfd, Elf_Internal_Note *note)
+{
+  return elfcore_make_note_pseudosection (abfd, ".reg-aarch-hw-watch", note);
+}
+
 #if defined (HAVE_PRPSINFO_T)
 typedef prpsinfo_t   elfcore_psinfo_t;
 #if defined (HAVE_PRPSINFO32_T)		/* Sparc64 cross Sparc32 */
@@ -8061,13 +8253,13 @@
       memcpy (&psinfo, note->descdata, sizeof (psinfo));
 
 #if defined (HAVE_PSINFO_T_PR_PID) || defined (HAVE_PRPSINFO_T_PR_PID)
-      elf_tdata (abfd)->core_pid = psinfo.pr_pid;
+      elf_tdata (abfd)->core->pid = psinfo.pr_pid;
 #endif
-      elf_tdata (abfd)->core_program
+      elf_tdata (abfd)->core->program
 	= _bfd_elfcore_strndup (abfd, psinfo.pr_fname,
 				sizeof (psinfo.pr_fname));
 
-      elf_tdata (abfd)->core_command
+      elf_tdata (abfd)->core->command
 	= _bfd_elfcore_strndup (abfd, psinfo.pr_psargs,
 				sizeof (psinfo.pr_psargs));
     }
@@ -8080,13 +8272,13 @@
       memcpy (&psinfo, note->descdata, sizeof (psinfo));
 
 #if defined (HAVE_PSINFO32_T_PR_PID) || defined (HAVE_PRPSINFO32_T_PR_PID)
-      elf_tdata (abfd)->core_pid = psinfo.pr_pid;
+      elf_tdata (abfd)->core->pid = psinfo.pr_pid;
 #endif
-      elf_tdata (abfd)->core_program
+      elf_tdata (abfd)->core->program
 	= _bfd_elfcore_strndup (abfd, psinfo.pr_fname,
 				sizeof (psinfo.pr_fname));
 
-      elf_tdata (abfd)->core_command
+      elf_tdata (abfd)->core->command
 	= _bfd_elfcore_strndup (abfd, psinfo.pr_psargs,
 				sizeof (psinfo.pr_psargs));
     }
@@ -8104,7 +8296,7 @@
      implementations, so strip it off if it exists.  */
 
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
@@ -8129,7 +8321,7 @@
 
       memcpy (&pstat, note->descdata, sizeof (pstat));
 
-      elf_tdata (abfd)->core_pid = pstat.pr_pid;
+      elf_tdata (abfd)->core->pid = pstat.pr_pid;
     }
 #if defined (HAVE_PSTATUS32_T)
   else if (note->descsz == sizeof (pstatus32_t))
@@ -8139,7 +8331,7 @@
 
       memcpy (&pstat, note->descdata, sizeof (pstat));
 
-      elf_tdata (abfd)->core_pid = pstat.pr_pid;
+      elf_tdata (abfd)->core->pid = pstat.pr_pid;
     }
 #endif
   /* Could grab some more details from the "representative"
@@ -8169,11 +8361,11 @@
 
   memcpy (&lwpstat, note->descdata, sizeof (lwpstat));
 
-  elf_tdata (abfd)->core_lwpid = lwpstat.pr_lwpid;
+  elf_tdata (abfd)->core->lwpid = lwpstat.pr_lwpid;
   /* Do not overwrite the core signal if it has already been set by
      another thread.  */
-  if (elf_tdata (abfd)->core_signal == 0)
-    elf_tdata (abfd)->core_signal = lwpstat.pr_cursig;
+  if (elf_tdata (abfd)->core->signal == 0)
+    elf_tdata (abfd)->core->signal = lwpstat.pr_cursig;
 
   /* Make a ".reg/999" section.  */
 
@@ -8256,11 +8448,11 @@
   switch (type)
     {
     case 1 /* NOTE_INFO_PROCESS */:
-      /* FIXME: need to add ->core_command.  */
+      /* FIXME: need to add ->core->command.  */
       /* process_info.pid */
-      elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 8);
+      elf_tdata (abfd)->core->pid = bfd_get_32 (abfd, note->descdata + 8);
       /* process_info.signal */
-      elf_tdata (abfd)->core_signal = bfd_get_32 (abfd, note->descdata + 12);
+      elf_tdata (abfd)->core->signal = bfd_get_32 (abfd, note->descdata + 12);
       break;
 
     case 2 /* NOTE_INFO_THREAD */:
@@ -8429,6 +8621,27 @@
       else
         return TRUE;
 
+    case NT_S390_LAST_BREAK:
+      if (note->namesz == 6
+          && strcmp (note->namedata, "LINUX") == 0)
+        return elfcore_grok_s390_last_break (abfd, note);
+      else
+        return TRUE;
+
+    case NT_S390_SYSTEM_CALL:
+      if (note->namesz == 6
+          && strcmp (note->namedata, "LINUX") == 0)
+        return elfcore_grok_s390_system_call (abfd, note);
+      else
+        return TRUE;
+
+    case NT_S390_TDB:
+      if (note->namesz == 6
+          && strcmp (note->namedata, "LINUX") == 0)
+        return elfcore_grok_s390_tdb (abfd, note);
+      else
+        return TRUE;
+
     case NT_ARM_VFP:
       if (note->namesz == 6
 	  && strcmp (note->namedata, "LINUX") == 0)
@@ -8436,6 +8649,27 @@
       else
 	return TRUE;
 
+    case NT_ARM_TLS:
+      if (note->namesz == 6
+	  && strcmp (note->namedata, "LINUX") == 0)
+	return elfcore_grok_aarch_tls (abfd, note);
+      else
+	return TRUE;
+
+    case NT_ARM_HW_BREAK:
+      if (note->namesz == 6
+	  && strcmp (note->namedata, "LINUX") == 0)
+	return elfcore_grok_aarch_hw_break (abfd, note);
+      else
+	return TRUE;
+
+    case NT_ARM_HW_WATCH:
+      if (note->namesz == 6
+	  && strcmp (note->namedata, "LINUX") == 0)
+	return elfcore_grok_aarch_hw_watch (abfd, note);
+      else
+	return TRUE;
+
     case NT_PRPSINFO:
     case NT_PSINFO:
       if (bed->elf_backend_grok_psinfo)
@@ -8460,18 +8694,32 @@
 
 	return TRUE;
       }
+
+    case NT_FILE:
+      return elfcore_make_note_pseudosection (abfd, ".note.linuxcore.file",
+					      note);
+
+    case NT_SIGINFO:
+      return elfcore_make_note_pseudosection (abfd, ".note.linuxcore.siginfo",
+					      note);
     }
 }
 
 static bfd_boolean
 elfobj_grok_gnu_build_id (bfd *abfd, Elf_Internal_Note *note)
 {
-  elf_tdata (abfd)->build_id_size = note->descsz;
-  elf_tdata (abfd)->build_id = (bfd_byte *) bfd_alloc (abfd, note->descsz);
-  if (elf_tdata (abfd)->build_id == NULL)
+  struct elf_obj_tdata *t;
+
+  if (note->descsz == 0)
     return FALSE;
 
-  memcpy (elf_tdata (abfd)->build_id, note->descdata, note->descsz);
+  t = elf_tdata (abfd);
+  t->build_id = bfd_alloc (abfd, sizeof (*t->build_id) - 1 + note->descsz);
+  if (t->build_id == NULL)
+    return FALSE;
+
+  t->build_id->size = note->descsz;
+  memcpy (t->build_id->data, note->descdata, note->descsz);
 
   return TRUE;
 }
@@ -8536,15 +8784,15 @@
 elfcore_grok_netbsd_procinfo (bfd *abfd, Elf_Internal_Note *note)
 {
   /* Signal number at offset 0x08. */
-  elf_tdata (abfd)->core_signal
+  elf_tdata (abfd)->core->signal
     = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + 0x08);
 
   /* Process ID at offset 0x50. */
-  elf_tdata (abfd)->core_pid
+  elf_tdata (abfd)->core->pid
     = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + 0x50);
 
   /* Command name at 0x7c (max 32 bytes, including nul). */
-  elf_tdata (abfd)->core_command
+  elf_tdata (abfd)->core->command
     = _bfd_elfcore_strndup (abfd, note->descdata + 0x7c, 31);
 
   return elfcore_make_note_pseudosection (abfd, ".note.netbsdcore.procinfo",
@@ -8557,7 +8805,7 @@
   int lwp;
 
   if (elfcore_netbsd_get_lwpid (note, &lwp))
-    elf_tdata (abfd)->core_lwpid = lwp;
+    elf_tdata (abfd)->core->lwpid = lwp;
 
   if (note->type == NT_NETBSDCORE_PROCINFO)
     {
@@ -8620,15 +8868,15 @@
 elfcore_grok_openbsd_procinfo (bfd *abfd, Elf_Internal_Note *note)
 {
   /* Signal number at offset 0x08. */
-  elf_tdata (abfd)->core_signal
+  elf_tdata (abfd)->core->signal
     = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + 0x08);
 
   /* Process ID at offset 0x20. */
-  elf_tdata (abfd)->core_pid
+  elf_tdata (abfd)->core->pid
     = bfd_h_get_32 (abfd, (bfd_byte *) note->descdata + 0x20);
 
   /* Command name at 0x48 (max 32 bytes, including nul). */
-  elf_tdata (abfd)->core_command
+  elf_tdata (abfd)->core->command
     = _bfd_elfcore_strndup (abfd, note->descdata + 0x48, 31);
 
   return TRUE;
@@ -8691,7 +8939,7 @@
   unsigned flags;
 
   /* nto_procfs_status 'pid' field is at offset 0.  */
-  elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, (bfd_byte *) ddata);
+  elf_tdata (abfd)->core->pid = bfd_get_32 (abfd, (bfd_byte *) ddata);
 
   /* nto_procfs_status 'tid' field is at offset 4.  Pass it back.  */
   *tid = bfd_get_32 (abfd, (bfd_byte *) ddata + 4);
@@ -8702,15 +8950,15 @@
   /* nto_procfs_status 'what' field is at offset 14.  */
   if ((sig = bfd_get_16 (abfd, (bfd_byte *) ddata + 14)) > 0)
     {
-      elf_tdata (abfd)->core_signal = sig;
-      elf_tdata (abfd)->core_lwpid = *tid;
+      elf_tdata (abfd)->core->signal = sig;
+      elf_tdata (abfd)->core->lwpid = *tid;
     }
 
   /* _DEBUG_FLAG_CURTID (current thread) is 0x80.  Some cores
      do not come from signals so we make sure we set the current
      thread just in case.  */
   if (flags & 0x00000080)
-    elf_tdata (abfd)->core_lwpid = *tid;
+    elf_tdata (abfd)->core->lwpid = *tid;
 
   /* Make a ".qnx_core_status/%d" section.  */
   sprintf (buf, ".qnx_core_status/%ld", *tid);
@@ -8758,7 +9006,7 @@
   sect->alignment_power = 2;
 
   /* This is the current thread.  */
-  if (elf_tdata (abfd)->core_lwpid == tid)
+  if (elf_tdata (abfd)->core->lwpid == tid)
     return elfcore_maybe_make_sect (abfd, base, sect);
 
   return TRUE;
@@ -8885,7 +9133,6 @@
   return buf;
 }
 
-#if defined (HAVE_PRPSINFO_T) || defined (HAVE_PSINFO_T)
 char *
 elfcore_write_prpsinfo (bfd  *abfd,
 			char *buf,
@@ -8893,7 +9140,6 @@
 			const char *fname,
 			const char *psargs)
 {
-  const char *note_name = "CORE";
   const struct elf_backend_data *bed = get_elf_backend_data (abfd);
 
   if (bed->elf_backend_write_core_note != NULL)
@@ -8905,6 +9151,7 @@
 	return ret;
     }
 
+#if defined (HAVE_PRPSINFO_T) || defined (HAVE_PSINFO_T)
 #if defined (HAVE_PRPSINFO32_T) || defined (HAVE_PSINFO32_T)
   if (bed->s->elfclass == ELFCLASS32)
     {
@@ -8920,7 +9167,7 @@
       strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
       strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
       return elfcore_write_note (abfd, buf, bufsiz,
-				 note_name, note_type, &data, sizeof (data));
+				 "CORE", note_type, &data, sizeof (data));
     }
   else
 #endif
@@ -8937,12 +9184,42 @@
       strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
       strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
       return elfcore_write_note (abfd, buf, bufsiz,
-				 note_name, note_type, &data, sizeof (data));
+				 "CORE", note_type, &data, sizeof (data));
     }
-}
 #endif	/* PSINFO_T or PRPSINFO_T */
 
-#if defined (HAVE_PRSTATUS_T)
+  free (buf);
+  return NULL;
+}
+
+char *
+elfcore_write_linux_prpsinfo32
+  (bfd *abfd, char *buf, int *bufsiz,
+   const struct elf_internal_linux_prpsinfo *prpsinfo)
+{
+  struct elf_external_linux_prpsinfo32 data;
+
+  memset (&data, 0, sizeof (data));
+  LINUX_PRPSINFO32_SWAP_FIELDS (abfd, prpsinfo, data);
+
+  return elfcore_write_note (abfd, buf, bufsiz, "CORE", NT_PRPSINFO,
+			     &data, sizeof (data));
+}
+
+char *
+elfcore_write_linux_prpsinfo64
+  (bfd *abfd, char *buf, int *bufsiz,
+   const struct elf_internal_linux_prpsinfo *prpsinfo)
+{
+  struct elf_external_linux_prpsinfo64 data;
+
+  memset (&data, 0, sizeof (data));
+  LINUX_PRPSINFO64_SWAP_FIELDS (abfd, prpsinfo, data);
+
+  return elfcore_write_note (abfd, buf, bufsiz,
+			     "CORE", NT_PRPSINFO, &data, sizeof (data));
+}
+
 char *
 elfcore_write_prstatus (bfd *abfd,
 			char *buf,
@@ -8951,7 +9228,6 @@
 			int cursig,
 			const void *gregs)
 {
-  const char *note_name = "CORE";
   const struct elf_backend_data *bed = get_elf_backend_data (abfd);
 
   if (bed->elf_backend_write_core_note != NULL)
@@ -8964,6 +9240,7 @@
 	return ret;
     }
 
+#if defined (HAVE_PRSTATUS_T)
 #if defined (HAVE_PRSTATUS32_T)
   if (bed->s->elfclass == ELFCLASS32)
     {
@@ -8973,7 +9250,7 @@
       prstat.pr_pid = pid;
       prstat.pr_cursig = cursig;
       memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
-      return elfcore_write_note (abfd, buf, bufsiz, note_name,
+      return elfcore_write_note (abfd, buf, bufsiz, "CORE",
 				 NT_PRSTATUS, &prstat, sizeof (prstat));
     }
   else
@@ -8985,12 +9262,15 @@
       prstat.pr_pid = pid;
       prstat.pr_cursig = cursig;
       memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
-      return elfcore_write_note (abfd, buf, bufsiz, note_name,
+      return elfcore_write_note (abfd, buf, bufsiz, "CORE",
 				 NT_PRSTATUS, &prstat, sizeof (prstat));
     }
-}
 #endif /* HAVE_PRSTATUS_T */
 
+  free (buf);
+  return NULL;
+}
+
 #if defined (HAVE_LWPSTATUS_T)
 char *
 elfcore_write_lwpstatus (bfd *abfd,
@@ -9190,6 +9470,44 @@
 }
 
 char *
+elfcore_write_s390_last_break (bfd *abfd,
+			       char *buf,
+			       int *bufsiz,
+			       const void *s390_last_break,
+			       int size)
+{
+  char *note_name = "LINUX";
+  return elfcore_write_note (abfd, buf, bufsiz,
+                             note_name, NT_S390_LAST_BREAK,
+			     s390_last_break, size);
+}
+
+char *
+elfcore_write_s390_system_call (bfd *abfd,
+				char *buf,
+				int *bufsiz,
+				const void *s390_system_call,
+				int size)
+{
+  char *note_name = "LINUX";
+  return elfcore_write_note (abfd, buf, bufsiz,
+                             note_name, NT_S390_SYSTEM_CALL,
+			     s390_system_call, size);
+}
+
+char *
+elfcore_write_s390_tdb (bfd *abfd,
+			char *buf,
+			int *bufsiz,
+			const void *s390_tdb,
+			int size)
+{
+  char *note_name = "LINUX";
+  return elfcore_write_note (abfd, buf, bufsiz,
+                             note_name, NT_S390_TDB, s390_tdb, size);
+}
+
+char *
 elfcore_write_arm_vfp (bfd *abfd,
 		       char *buf,
 		       int *bufsiz,
@@ -9202,6 +9520,42 @@
 }
 
 char *
+elfcore_write_aarch_tls (bfd *abfd,
+		       char *buf,
+		       int *bufsiz,
+		       const void *aarch_tls,
+		       int size)
+{
+  char *note_name = "LINUX";
+  return elfcore_write_note (abfd, buf, bufsiz,
+			     note_name, NT_ARM_TLS, aarch_tls, size);
+}
+
+char *
+elfcore_write_aarch_hw_break (bfd *abfd,
+			    char *buf,
+			    int *bufsiz,
+			    const void *aarch_hw_break,
+			    int size)
+{
+  char *note_name = "LINUX";
+  return elfcore_write_note (abfd, buf, bufsiz,
+			     note_name, NT_ARM_HW_BREAK, aarch_hw_break, size);
+}
+
+char *
+elfcore_write_aarch_hw_watch (bfd *abfd,
+			    char *buf,
+			    int *bufsiz,
+			    const void *aarch_hw_watch,
+			    int size)
+{
+  char *note_name = "LINUX";
+  return elfcore_write_note (abfd, buf, bufsiz,
+			     note_name, NT_ARM_HW_WATCH, aarch_hw_watch, size);
+}
+
+char *
 elfcore_write_register_note (bfd *abfd,
 			     char *buf,
 			     int *bufsiz,
@@ -9231,8 +9585,20 @@
     return elfcore_write_s390_ctrs (abfd, buf, bufsiz, data, size);
   if (strcmp (section, ".reg-s390-prefix") == 0)
     return elfcore_write_s390_prefix (abfd, buf, bufsiz, data, size);
+  if (strcmp (section, ".reg-s390-last-break") == 0)
+    return elfcore_write_s390_last_break (abfd, buf, bufsiz, data, size);
+  if (strcmp (section, ".reg-s390-system-call") == 0)
+    return elfcore_write_s390_system_call (abfd, buf, bufsiz, data, size);
+  if (strcmp (section, ".reg-s390-tdb") == 0)
+    return elfcore_write_s390_tdb (abfd, buf, bufsiz, data, size);
   if (strcmp (section, ".reg-arm-vfp") == 0)
     return elfcore_write_arm_vfp (abfd, buf, bufsiz, data, size);
+  if (strcmp (section, ".reg-aarch-tls") == 0)
+    return elfcore_write_aarch_tls (abfd, buf, bufsiz, data, size);
+  if (strcmp (section, ".reg-aarch-hw-break") == 0)
+    return elfcore_write_aarch_hw_break (abfd, buf, bufsiz, data, size);
+  if (strcmp (section, ".reg-aarch-hw-watch") == 0)
+    return elfcore_write_aarch_hw_watch (abfd, buf, bufsiz, data, size);
   return NULL;
 }
 
@@ -9391,7 +9757,9 @@
 }
 
 enum elf_reloc_type_class
-_bfd_elf_reloc_type_class (const Elf_Internal_Rela *rela ATTRIBUTE_UNUSED)
+_bfd_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			   const asection *rel_sec ATTRIBUTE_UNUSED,
+			   const Elf_Internal_Rela *rela ATTRIBUTE_UNUSED)
 {
   return reloc_class_normal;
 }
@@ -9413,7 +9781,7 @@
 		+ sym->st_value);
   if ((sec->flags & SEC_MERGE)
       && ELF_ST_TYPE (sym->st_info) == STT_SECTION
-      && sec->sec_info_type == ELF_INFO_TYPE_MERGE)
+      && sec->sec_info_type == SEC_INFO_TYPE_MERGE)
     {
       rel->r_addend =
 	_bfd_merged_section_offset (abfd, psec,
@@ -9444,7 +9812,7 @@
 {
   asection *sec = *psec;
 
-  if (sec->sec_info_type != ELF_INFO_TYPE_MERGE)
+  if (sec->sec_info_type != SEC_INFO_TYPE_MERGE)
     return sym->st_value + addend;
 
   return _bfd_merged_section_offset (abfd, psec,
@@ -9460,10 +9828,10 @@
 {
   switch (sec->sec_info_type)
     {
-    case ELF_INFO_TYPE_STABS:
+    case SEC_INFO_TYPE_STABS:
       return _bfd_stab_section_offset (sec, elf_section_data (sec)->sec_info,
 				       offset);
-    case ELF_INFO_TYPE_EH_FRAME:
+    case SEC_INFO_TYPE_EH_FRAME:
       return _bfd_elf_eh_frame_section_offset (abfd, info, sec, offset);
     default:
       if ((sec->flags & SEC_ELF_REVERSE_COPY) != 0)
@@ -9494,7 +9862,7 @@
   (bfd *templ,
    bfd_vma ehdr_vma,
    bfd_vma *loadbasep,
-   int (*target_read_memory) (bfd_vma, bfd_byte *, int))
+   int (*target_read_memory) (bfd_vma, bfd_byte *, bfd_size_type))
 {
   return (*get_elf_backend_data (templ)->elf_backend_bfd_from_remote_memory)
     (templ, ehdr_vma, loadbasep, target_read_memory);
@@ -9599,7 +9967,7 @@
       if (p->addend != 0)
 	{
 	  char buf[30], *a;
-	  
+
 	  memcpy (names, "+0x", sizeof ("+0x") - 1);
 	  names += sizeof ("+0x") - 1;
 	  bfd_sprintf_vma (abfd, buf, p->addend);
diff --git a/bfd/elf32-am33lin.c b/bfd/elf32-am33lin.c
index 177a714..f23ef8e 100644
--- a/bfd/elf32-am33lin.c
+++ b/bfd/elf32-am33lin.c
@@ -50,12 +50,13 @@
       default:
 	return FALSE;
 
+      case 184:
       case 188:		/* Linux/am33 */
 	/* pr_cursig */
-	elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+	elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
 
 	/* pr_pid */
-	elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
+	elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
 
 	/* pr_reg */
 	offset = 72;
@@ -78,9 +79,9 @@
 	return FALSE;
 
       case 124:		/* Linux/am33 elf_prpsinfo */
-	elf_tdata (abfd)->core_program
+	elf_tdata (abfd)->core->program
 	 = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
-	elf_tdata (abfd)->core_command
+	elf_tdata (abfd)->core->command
 	 = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
     }
 
@@ -89,7 +90,7 @@
      implementations, so strip it off if it exists.  */
 
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 9550393..5af1643 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -1,6 +1,5 @@
 /* 32-bit ELF support for ARM
-   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-   2008, 2009, 2010, 2011  Free Software Foundation, Inc.
+   Copyright 1998-2013 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -23,9 +22,11 @@
 #include <limits.h>
 
 #include "bfd.h"
+#include "bfd_stdint.h"
 #include "libiberty.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
+#include "elf-nacl.h"
 #include "elf-vxworks.h"
 #include "elf/arm.h"
 
@@ -61,6 +62,9 @@
 #define ARM_ELF_ABI_VERSION		0
 #define ARM_ELF_OS_ABI_VERSION		ELFOSABI_ARM
 
+/* The Adjusted Place, as defined by AAELF.  */
+#define Pa(X) ((X) & 0xfffffffc)
+
 static bfd_boolean elf32_arm_write_section (bfd *output_bfd,
 					    struct bfd_link_info *link_info,
 					    asection *sec,
@@ -322,160 +326,160 @@
   /* Dynamic TLS relocations.  */
 
   HOWTO (R_ARM_TLS_DTPMOD32,	/* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         32,                    /* bitsize */
-         FALSE,                 /* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_bitfield,/* complain_on_overflow */
-         bfd_elf_generic_reloc, /* special_function */
-         "R_ARM_TLS_DTPMOD32",	/* name */
-         TRUE,			/* partial_inplace */
-         0xffffffff,		/* src_mask */
-         0xffffffff,		/* dst_mask */
-         FALSE),                /* pcrel_offset */
+	 0,                     /* rightshift */
+	 2,                     /* size (0 = byte, 1 = short, 2 = long) */
+	 32,                    /* bitsize */
+	 FALSE,                 /* pc_relative */
+	 0,                     /* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_ARM_TLS_DTPMOD32",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),                /* pcrel_offset */
 
   HOWTO (R_ARM_TLS_DTPOFF32,	/* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         32,                    /* bitsize */
-         FALSE,                 /* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_bitfield,/* complain_on_overflow */
-         bfd_elf_generic_reloc, /* special_function */
-         "R_ARM_TLS_DTPOFF32",	/* name */
-         TRUE,			/* partial_inplace */
-         0xffffffff,		/* src_mask */
-         0xffffffff,		/* dst_mask */
-         FALSE),                /* pcrel_offset */
+	 0,                     /* rightshift */
+	 2,                     /* size (0 = byte, 1 = short, 2 = long) */
+	 32,                    /* bitsize */
+	 FALSE,                 /* pc_relative */
+	 0,                     /* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_ARM_TLS_DTPOFF32",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),                /* pcrel_offset */
 
   HOWTO (R_ARM_TLS_TPOFF32,	/* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         32,                    /* bitsize */
-         FALSE,                 /* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_bitfield,/* complain_on_overflow */
-         bfd_elf_generic_reloc, /* special_function */
-         "R_ARM_TLS_TPOFF32",	/* name */
-         TRUE,			/* partial_inplace */
-         0xffffffff,		/* src_mask */
-         0xffffffff,		/* dst_mask */
-         FALSE),                /* pcrel_offset */
+	 0,                     /* rightshift */
+	 2,                     /* size (0 = byte, 1 = short, 2 = long) */
+	 32,                    /* bitsize */
+	 FALSE,                 /* pc_relative */
+	 0,                     /* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_ARM_TLS_TPOFF32",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),                /* pcrel_offset */
 
   /* Relocs used in ARM Linux */
 
   HOWTO (R_ARM_COPY,		/* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         32,                    /* bitsize */
-         FALSE,                 /* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_bitfield,/* complain_on_overflow */
-         bfd_elf_generic_reloc, /* special_function */
-         "R_ARM_COPY",		/* name */
-         TRUE,			/* partial_inplace */
-         0xffffffff,		/* src_mask */
-         0xffffffff,		/* dst_mask */
-         FALSE),                /* pcrel_offset */
+	 0,                     /* rightshift */
+	 2,                     /* size (0 = byte, 1 = short, 2 = long) */
+	 32,                    /* bitsize */
+	 FALSE,                 /* pc_relative */
+	 0,                     /* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_ARM_COPY",		/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),                /* pcrel_offset */
 
   HOWTO (R_ARM_GLOB_DAT,	/* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         32,                    /* bitsize */
-         FALSE,                 /* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_bitfield,/* complain_on_overflow */
-         bfd_elf_generic_reloc, /* special_function */
-         "R_ARM_GLOB_DAT",	/* name */
-         TRUE,			/* partial_inplace */
-         0xffffffff,		/* src_mask */
-         0xffffffff,		/* dst_mask */
-         FALSE),                /* pcrel_offset */
+	 0,                     /* rightshift */
+	 2,                     /* size (0 = byte, 1 = short, 2 = long) */
+	 32,                    /* bitsize */
+	 FALSE,                 /* pc_relative */
+	 0,                     /* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_ARM_GLOB_DAT",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),                /* pcrel_offset */
 
   HOWTO (R_ARM_JUMP_SLOT,	/* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         32,                    /* bitsize */
-         FALSE,                 /* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_bitfield,/* complain_on_overflow */
-         bfd_elf_generic_reloc, /* special_function */
-         "R_ARM_JUMP_SLOT",	/* name */
-         TRUE,			/* partial_inplace */
-         0xffffffff,		/* src_mask */
-         0xffffffff,		/* dst_mask */
-         FALSE),                /* pcrel_offset */
+	 0,                     /* rightshift */
+	 2,                     /* size (0 = byte, 1 = short, 2 = long) */
+	 32,                    /* bitsize */
+	 FALSE,                 /* pc_relative */
+	 0,                     /* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_ARM_JUMP_SLOT",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),                /* pcrel_offset */
 
   HOWTO (R_ARM_RELATIVE,	/* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         32,                    /* bitsize */
-         FALSE,                 /* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_bitfield,/* complain_on_overflow */
-         bfd_elf_generic_reloc, /* special_function */
-         "R_ARM_RELATIVE",	/* name */
-         TRUE,			/* partial_inplace */
-         0xffffffff,		/* src_mask */
-         0xffffffff,		/* dst_mask */
-         FALSE),                /* pcrel_offset */
+	 0,                     /* rightshift */
+	 2,                     /* size (0 = byte, 1 = short, 2 = long) */
+	 32,                    /* bitsize */
+	 FALSE,                 /* pc_relative */
+	 0,                     /* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_ARM_RELATIVE",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),                /* pcrel_offset */
 
   HOWTO (R_ARM_GOTOFF32,	/* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         32,                    /* bitsize */
-         FALSE,                 /* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_bitfield,/* complain_on_overflow */
-         bfd_elf_generic_reloc, /* special_function */
-         "R_ARM_GOTOFF32",	/* name */
-         TRUE,			/* partial_inplace */
-         0xffffffff,		/* src_mask */
-         0xffffffff,		/* dst_mask */
-         FALSE),                /* pcrel_offset */
+	 0,                     /* rightshift */
+	 2,                     /* size (0 = byte, 1 = short, 2 = long) */
+	 32,                    /* bitsize */
+	 FALSE,                 /* pc_relative */
+	 0,                     /* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_ARM_GOTOFF32",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),                /* pcrel_offset */
 
   HOWTO (R_ARM_GOTPC,		/* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         32,                    /* bitsize */
-         TRUE,			/* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_bitfield,/* complain_on_overflow */
-         bfd_elf_generic_reloc, /* special_function */
-         "R_ARM_GOTPC",		/* name */
-         TRUE,			/* partial_inplace */
-         0xffffffff,		/* src_mask */
-         0xffffffff,		/* dst_mask */
-         TRUE),			/* pcrel_offset */
+	 0,                     /* rightshift */
+	 2,                     /* size (0 = byte, 1 = short, 2 = long) */
+	 32,                    /* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,                     /* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_ARM_GOTPC",		/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
 
   HOWTO (R_ARM_GOT32,		/* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         32,                    /* bitsize */
-         FALSE,			/* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_bitfield,/* complain_on_overflow */
-         bfd_elf_generic_reloc, /* special_function */
-         "R_ARM_GOT32",		/* name */
-         TRUE,			/* partial_inplace */
-         0xffffffff,		/* src_mask */
-         0xffffffff,		/* dst_mask */
-         FALSE),		/* pcrel_offset */
+	 0,                     /* rightshift */
+	 2,                     /* size (0 = byte, 1 = short, 2 = long) */
+	 32,                    /* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,                     /* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_ARM_GOT32",		/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
 
   HOWTO (R_ARM_PLT32,		/* type */
-         2,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         24,                    /* bitsize */
-         TRUE,			/* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_bitfield,/* complain_on_overflow */
-         bfd_elf_generic_reloc, /* special_function */
-         "R_ARM_PLT32",		/* name */
-         FALSE,			/* partial_inplace */
-         0x00ffffff,		/* src_mask */
-         0x00ffffff,		/* dst_mask */
-         TRUE),			/* pcrel_offset */
+	 2,                     /* rightshift */
+	 2,                     /* size (0 = byte, 1 = short, 2 = long) */
+	 24,                    /* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,                     /* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_ARM_PLT32",		/* name */
+	 FALSE,			/* partial_inplace */
+	 0x00ffffff,		/* src_mask */
+	 0x00ffffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
 
   HOWTO (R_ARM_CALL,		/* type */
 	 2,			/* rightshift */
@@ -1482,33 +1486,33 @@
 
   /* GNU extension to record C++ vtable member usage */
   HOWTO (R_ARM_GNU_VTENTRY,     /* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         0,                     /* bitsize */
-         FALSE,                 /* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_dont, /* complain_on_overflow */
-         _bfd_elf_rel_vtable_reloc_fn,  /* special_function */
-         "R_ARM_GNU_VTENTRY",   /* name */
-         FALSE,                 /* partial_inplace */
-         0,                     /* src_mask */
-         0,                     /* dst_mask */
-         FALSE),                /* pcrel_offset */
+	 0,                     /* rightshift */
+	 2,                     /* size (0 = byte, 1 = short, 2 = long) */
+	 0,                     /* bitsize */
+	 FALSE,                 /* pc_relative */
+	 0,                     /* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 _bfd_elf_rel_vtable_reloc_fn,  /* special_function */
+	 "R_ARM_GNU_VTENTRY",   /* name */
+	 FALSE,                 /* partial_inplace */
+	 0,                     /* src_mask */
+	 0,                     /* dst_mask */
+	 FALSE),                /* pcrel_offset */
 
   /* GNU extension to record C++ vtable hierarchy */
   HOWTO (R_ARM_GNU_VTINHERIT, /* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         0,                     /* bitsize */
-         FALSE,                 /* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_dont, /* complain_on_overflow */
-         NULL,                  /* special_function */
-         "R_ARM_GNU_VTINHERIT", /* name */
-         FALSE,                 /* partial_inplace */
-         0,                     /* src_mask */
-         0,                     /* dst_mask */
-         FALSE),                /* pcrel_offset */
+	 0,                     /* rightshift */
+	 2,                     /* size (0 = byte, 1 = short, 2 = long) */
+	 0,                     /* bitsize */
+	 FALSE,                 /* pc_relative */
+	 0,                     /* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 NULL,                  /* special_function */
+	 "R_ARM_GNU_VTINHERIT", /* name */
+	 FALSE,                 /* partial_inplace */
+	 0,                     /* src_mask */
+	 0,                     /* dst_mask */
+	 FALSE),                /* pcrel_offset */
 
   HOWTO (R_ARM_THM_JUMP11,	/* type */
 	 1,			/* rightshift */
@@ -1540,74 +1544,74 @@
 
   /* TLS relocations */
   HOWTO (R_ARM_TLS_GD32,	/* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         32,                    /* bitsize */
-         FALSE,                 /* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_bitfield,/* complain_on_overflow */
-         NULL,			/* special_function */
-         "R_ARM_TLS_GD32",	/* name */
-         TRUE,			/* partial_inplace */
-         0xffffffff,		/* src_mask */
-         0xffffffff,		/* dst_mask */
-         FALSE),                /* pcrel_offset */
+	 0,                     /* rightshift */
+	 2,                     /* size (0 = byte, 1 = short, 2 = long) */
+	 32,                    /* bitsize */
+	 FALSE,                 /* pc_relative */
+	 0,                     /* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 NULL,			/* special_function */
+	 "R_ARM_TLS_GD32",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),                /* pcrel_offset */
 
   HOWTO (R_ARM_TLS_LDM32,	/* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         32,                    /* bitsize */
-         FALSE,                 /* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_bitfield,/* complain_on_overflow */
-         bfd_elf_generic_reloc, /* special_function */
-         "R_ARM_TLS_LDM32",	/* name */
-         TRUE,			/* partial_inplace */
-         0xffffffff,		/* src_mask */
-         0xffffffff,		/* dst_mask */
-         FALSE),                /* pcrel_offset */
+	 0,                     /* rightshift */
+	 2,                     /* size (0 = byte, 1 = short, 2 = long) */
+	 32,                    /* bitsize */
+	 FALSE,                 /* pc_relative */
+	 0,                     /* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_ARM_TLS_LDM32",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),                /* pcrel_offset */
 
   HOWTO (R_ARM_TLS_LDO32,	/* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         32,                    /* bitsize */
-         FALSE,                 /* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_bitfield,/* complain_on_overflow */
-         bfd_elf_generic_reloc, /* special_function */
-         "R_ARM_TLS_LDO32",	/* name */
-         TRUE,			/* partial_inplace */
-         0xffffffff,		/* src_mask */
-         0xffffffff,		/* dst_mask */
-         FALSE),                /* pcrel_offset */
+	 0,                     /* rightshift */
+	 2,                     /* size (0 = byte, 1 = short, 2 = long) */
+	 32,                    /* bitsize */
+	 FALSE,                 /* pc_relative */
+	 0,                     /* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_ARM_TLS_LDO32",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),                /* pcrel_offset */
 
   HOWTO (R_ARM_TLS_IE32,	/* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         32,                    /* bitsize */
-         FALSE,                  /* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_bitfield,/* complain_on_overflow */
-         NULL,			/* special_function */
-         "R_ARM_TLS_IE32",	/* name */
-         TRUE,			/* partial_inplace */
-         0xffffffff,		/* src_mask */
-         0xffffffff,		/* dst_mask */
-         FALSE),                /* pcrel_offset */
+	 0,                     /* rightshift */
+	 2,                     /* size (0 = byte, 1 = short, 2 = long) */
+	 32,                    /* bitsize */
+	 FALSE,                  /* pc_relative */
+	 0,                     /* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 NULL,			/* special_function */
+	 "R_ARM_TLS_IE32",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),                /* pcrel_offset */
 
   HOWTO (R_ARM_TLS_LE32,	/* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         32,                    /* bitsize */
-         FALSE,                 /* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_bitfield,/* complain_on_overflow */
-         bfd_elf_generic_reloc, /* special_function */
-         "R_ARM_TLS_LE32",	/* name */
-         TRUE,			/* partial_inplace */
-         0xffffffff,		/* src_mask */
-         0xffffffff,		/* dst_mask */
-         FALSE),                /* pcrel_offset */
+	 0,                     /* rightshift */
+	 2,                     /* size (0 = byte, 1 = short, 2 = long) */
+	 32,                    /* bitsize */
+	 FALSE,                 /* pc_relative */
+	 0,                     /* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_ARM_TLS_LE32",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),                /* pcrel_offset */
 
   HOWTO (R_ARM_TLS_LDO12,	/* type */
 	 0,			/* rightshift */
@@ -1691,18 +1695,18 @@
 static reloc_howto_type elf32_arm_howto_table_2[1] =
 {
   HOWTO (R_ARM_IRELATIVE,	/* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         32,                    /* bitsize */
-         FALSE,                 /* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_bitfield,/* complain_on_overflow */
-         bfd_elf_generic_reloc, /* special_function */
-         "R_ARM_IRELATIVE",	/* name */
-         TRUE,			/* partial_inplace */
-         0xffffffff,		/* src_mask */
-         0xffffffff,		/* dst_mask */
-         FALSE)			/* pcrel_offset */
+	 0,                     /* rightshift */
+	 2,                     /* size (0 = byte, 1 = short, 2 = long) */
+	 32,                    /* bitsize */
+	 FALSE,                 /* pc_relative */
+	 0,                     /* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_ARM_IRELATIVE",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE)			/* pcrel_offset */
 };
 
 /* 249-255 extended, currently unused, relocations:  */
@@ -1940,10 +1944,10 @@
 
       case 148:		/* Linux/ARM 32-bit.  */
 	/* pr_cursig */
-	elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+	elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
 
 	/* pr_pid */
-	elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
+	elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
 
 	/* pr_reg */
 	offset = 72;
@@ -1966,9 +1970,11 @@
 	return FALSE;
 
       case 124:		/* Linux/ARM elf_prpsinfo.  */
-	elf_tdata (abfd)->core_program
+	elf_tdata (abfd)->core->pid
+	 = bfd_get_32 (abfd, note->descdata + 12);
+	elf_tdata (abfd)->core->program
 	 = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
-	elf_tdata (abfd)->core_command
+	elf_tdata (abfd)->core->command
 	 = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
     }
 
@@ -1976,7 +1982,7 @@
      onto the end of the args in some (at least one anyway)
      implementations, so strip it off if it exists.  */
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
@@ -1986,6 +1992,54 @@
   return TRUE;
 }
 
+static char *
+elf32_arm_nabi_write_core_note (bfd *abfd, char *buf, int *bufsiz,
+				int note_type, ...)
+{
+  switch (note_type)
+    {
+    default:
+      return NULL;
+
+    case NT_PRPSINFO:
+      {
+	char data[124];
+	va_list ap;
+
+	va_start (ap, note_type);
+	memset (data, 0, sizeof (data));
+	strncpy (data + 28, va_arg (ap, const char *), 16);
+	strncpy (data + 44, va_arg (ap, const char *), 80);
+	va_end (ap);
+
+	return elfcore_write_note (abfd, buf, bufsiz,
+				   "CORE", note_type, data, sizeof (data));
+      }
+
+    case NT_PRSTATUS:
+      {
+	char data[148];
+	va_list ap;
+	long pid;
+	int cursig;
+	const void *greg;
+
+	va_start (ap, note_type);
+	memset (data, 0, sizeof (data));
+	pid = va_arg (ap, long);
+	bfd_put_32 (abfd, pid, data + 24);
+	cursig = va_arg (ap, int);
+	bfd_put_16 (abfd, cursig, data + 12);
+	greg = va_arg (ap, const void *);
+	memcpy (data + 72, greg, 72);
+	va_end (ap);
+
+	return elfcore_write_note (abfd, buf, bufsiz,
+				   "CORE", note_type, data, sizeof (data));
+      }
+    }
+}
+
 #define TARGET_LITTLE_SYM               bfd_elf32_littlearm_vec
 #define TARGET_LITTLE_NAME              "elf32-littlearm"
 #define TARGET_BIG_SYM                  bfd_elf32_bigarm_vec
@@ -1993,6 +2047,7 @@
 
 #define elf_backend_grok_prstatus	elf32_arm_nabi_grok_prstatus
 #define elf_backend_grok_psinfo		elf32_arm_nabi_grok_psinfo
+#define elf_backend_write_core_note	elf32_arm_nabi_write_core_note
 
 typedef unsigned long int insn32;
 typedef unsigned short int insn16;
@@ -2027,24 +2082,24 @@
 #define ELF_DYNAMIC_INTERPRETER     "/usr/lib/ld.so.1"
 
 static const unsigned long tls_trampoline [] =
-  {
-    0xe08e0000,		/* add r0, lr, r0 */
-    0xe5901004,		/* ldr r1, [r0,#4] */
-    0xe12fff11,		/* bx  r1 */
-  };
+{
+  0xe08e0000,		/* add r0, lr, r0 */
+  0xe5901004,		/* ldr r1, [r0,#4] */
+  0xe12fff11,		/* bx  r1 */
+};
 
 static const unsigned long dl_tlsdesc_lazy_trampoline [] =
-  {
-    0xe52d2004, /*	push    {r2}			*/
-    0xe59f200c, /*      ldr     r2, [pc, #3f - . - 8]	*/
-    0xe59f100c, /*      ldr     r1, [pc, #4f - . - 8]	*/
-    0xe79f2002, /* 1:   ldr     r2, [pc, r2]		*/
-    0xe081100f, /* 2:   add     r1, pc			*/
-    0xe12fff12, /*      bx      r2			*/
-    0x00000014, /* 3:   .word  _GLOBAL_OFFSET_TABLE_ - 1b - 8
-		   		+ dl_tlsdesc_lazy_resolver(GOT)   */
-    0x00000018, /* 4:   .word  _GLOBAL_OFFSET_TABLE_ - 2b - 8 */ 
-  };
+{
+  0xe52d2004, /*	push    {r2}			*/
+  0xe59f200c, /*      ldr     r2, [pc, #3f - . - 8]	*/
+  0xe59f100c, /*      ldr     r1, [pc, #4f - . - 8]	*/
+  0xe79f2002, /* 1:   ldr     r2, [pc, r2]		*/
+  0xe081100f, /* 2:   add     r1, pc			*/
+  0xe12fff12, /*      bx      r2			*/
+  0x00000014, /* 3:   .word  _GLOBAL_OFFSET_TABLE_ - 1b - 8
+				+ dl_tlsdesc_lazy_resolver(GOT)   */
+  0x00000018, /* 4:   .word  _GLOBAL_OFFSET_TABLE_ - 2b - 8 */
+};
 
 #ifdef FOUR_WORD_PLT
 
@@ -2053,22 +2108,22 @@
    called before the relocation has been set up calls the dynamic
    linker first.  */
 static const bfd_vma elf32_arm_plt0_entry [] =
-  {
-    0xe52de004,		/* str   lr, [sp, #-4]! */
-    0xe59fe010,		/* ldr   lr, [pc, #16]  */
-    0xe08fe00e,		/* add   lr, pc, lr     */
-    0xe5bef008,		/* ldr   pc, [lr, #8]!  */
-  };
+{
+  0xe52de004,		/* str   lr, [sp, #-4]! */
+  0xe59fe010,		/* ldr   lr, [pc, #16]  */
+  0xe08fe00e,		/* add   lr, pc, lr     */
+  0xe5bef008,		/* ldr   pc, [lr, #8]!  */
+};
 
 /* Subsequent entries in a procedure linkage table look like
    this.  */
 static const bfd_vma elf32_arm_plt_entry [] =
-  {
-    0xe28fc600,		/* add   ip, pc, #NN	*/
-    0xe28cca00,		/* add	 ip, ip, #NN	*/
-    0xe5bcf000,		/* ldr	 pc, [ip, #NN]! */
-    0x00000000,		/* unused		*/
-  };
+{
+  0xe28fc600,		/* add   ip, pc, #NN	*/
+  0xe28cca00,		/* add	 ip, ip, #NN	*/
+  0xe5bcf000,		/* ldr	 pc, [ip, #NN]! */
+  0x00000000,		/* unused		*/
+};
 
 #else
 
@@ -2077,72 +2132,111 @@
    called before the relocation has been set up calls the dynamic
    linker first.  */
 static const bfd_vma elf32_arm_plt0_entry [] =
-  {
-    0xe52de004,		/* str   lr, [sp, #-4]! */
-    0xe59fe004,		/* ldr   lr, [pc, #4]   */
-    0xe08fe00e,		/* add   lr, pc, lr     */
-    0xe5bef008,		/* ldr   pc, [lr, #8]!  */
-    0x00000000,		/* &GOT[0] - .          */
-  };
+{
+  0xe52de004,		/* str   lr, [sp, #-4]! */
+  0xe59fe004,		/* ldr   lr, [pc, #4]   */
+  0xe08fe00e,		/* add   lr, pc, lr     */
+  0xe5bef008,		/* ldr   pc, [lr, #8]!  */
+  0x00000000,		/* &GOT[0] - .          */
+};
 
 /* Subsequent entries in a procedure linkage table look like
    this.  */
 static const bfd_vma elf32_arm_plt_entry [] =
-  {
-    0xe28fc600,		/* add   ip, pc, #0xNN00000 */
-    0xe28cca00,		/* add	 ip, ip, #0xNN000   */
-    0xe5bcf000,		/* ldr	 pc, [ip, #0xNNN]!  */
-  };
+{
+  0xe28fc600,		/* add   ip, pc, #0xNN00000 */
+  0xe28cca00,		/* add	 ip, ip, #0xNN000   */
+  0xe5bcf000,		/* ldr	 pc, [ip, #0xNNN]!  */
+};
 
 #endif
 
 /* The format of the first entry in the procedure linkage table
    for a VxWorks executable.  */
 static const bfd_vma elf32_arm_vxworks_exec_plt0_entry[] =
-  {
-    0xe52dc008,	        /* str    ip,[sp,#-8]!			*/
-    0xe59fc000,         /* ldr    ip,[pc]			*/
-    0xe59cf008,         /* ldr    pc,[ip,#8]			*/
-    0x00000000,         /* .long  _GLOBAL_OFFSET_TABLE_		*/
-  };
+{
+  0xe52dc008,	        /* str    ip,[sp,#-8]!			*/
+  0xe59fc000,   	/* ldr    ip,[pc]			*/
+  0xe59cf008,   	/* ldr    pc,[ip,#8]			*/
+  0x00000000,   	/* .long  _GLOBAL_OFFSET_TABLE_		*/
+};
 
 /* The format of subsequent entries in a VxWorks executable.  */
 static const bfd_vma elf32_arm_vxworks_exec_plt_entry[] =
-  {
-    0xe59fc000,         /* ldr    ip,[pc]			*/
-    0xe59cf000,         /* ldr    pc,[ip]			*/
-    0x00000000,         /* .long  @got				*/
-    0xe59fc000,         /* ldr    ip,[pc]			*/
-    0xea000000,         /* b      _PLT				*/
-    0x00000000,         /* .long  @pltindex*sizeof(Elf32_Rela)	*/
-  };
+{
+  0xe59fc000,         /* ldr    ip,[pc]			*/
+  0xe59cf000,         /* ldr    pc,[ip]			*/
+  0x00000000,         /* .long  @got				*/
+  0xe59fc000,         /* ldr    ip,[pc]			*/
+  0xea000000,         /* b      _PLT				*/
+  0x00000000,         /* .long  @pltindex*sizeof(Elf32_Rela)	*/
+};
 
 /* The format of entries in a VxWorks shared library.  */
 static const bfd_vma elf32_arm_vxworks_shared_plt_entry[] =
-  {
-    0xe59fc000,         /* ldr    ip,[pc]			*/
-    0xe79cf009,         /* ldr    pc,[ip,r9]			*/
-    0x00000000,         /* .long  @got				*/
-    0xe59fc000,         /* ldr    ip,[pc]			*/
-    0xe599f008,         /* ldr    pc,[r9,#8]			*/
-    0x00000000,         /* .long  @pltindex*sizeof(Elf32_Rela)	*/
-  };
+{
+  0xe59fc000,         /* ldr    ip,[pc]			*/
+  0xe79cf009,         /* ldr    pc,[ip,r9]			*/
+  0x00000000,         /* .long  @got				*/
+  0xe59fc000,         /* ldr    ip,[pc]			*/
+  0xe599f008,         /* ldr    pc,[r9,#8]			*/
+  0x00000000,         /* .long  @pltindex*sizeof(Elf32_Rela)	*/
+};
 
 /* An initial stub used if the PLT entry is referenced from Thumb code.  */
 #define PLT_THUMB_STUB_SIZE 4
 static const bfd_vma elf32_arm_plt_thumb_stub [] =
-  {
-    0x4778,		/* bx pc */
-    0x46c0		/* nop   */
-  };
+{
+  0x4778,		/* bx pc */
+  0x46c0		/* nop   */
+};
 
 /* The entries in a PLT when using a DLL-based target with multiple
    address spaces.  */
 static const bfd_vma elf32_arm_symbian_plt_entry [] =
-  {
-    0xe51ff004,         /* ldr   pc, [pc, #-4] */
-    0x00000000,         /* dcd   R_ARM_GLOB_DAT(X) */
-  };
+{
+  0xe51ff004,         /* ldr   pc, [pc, #-4] */
+  0x00000000,         /* dcd   R_ARM_GLOB_DAT(X) */
+};
+
+/* The first entry in a procedure linkage table looks like
+   this.  It is set up so that any shared library function that is
+   called before the relocation has been set up calls the dynamic
+   linker first.  */
+static const bfd_vma elf32_arm_nacl_plt0_entry [] =
+{
+  /* First bundle: */
+  0xe300c000,		/* movw	ip, #:lower16:&GOT[2]-.+8	*/
+  0xe340c000,		/* movt	ip, #:upper16:&GOT[2]-.+8	*/
+  0xe08cc00f,		/* add	ip, ip, pc			*/
+  0xe52dc008,		/* str	ip, [sp, #-8]!			*/
+  /* Second bundle: */
+  0xe3ccc103,		/* bic	ip, ip, #0xc0000000		*/
+  0xe59cc000,		/* ldr	ip, [ip]			*/
+  0xe3ccc13f,		/* bic	ip, ip, #0xc000000f		*/
+  0xe12fff1c,		/* bx	ip				*/
+  /* Third bundle: */
+  0xe320f000,		/* nop					*/
+  0xe320f000,		/* nop					*/
+  0xe320f000,		/* nop					*/
+  /* .Lplt_tail: */
+  0xe50dc004,		/* str	ip, [sp, #-4]			*/
+  /* Fourth bundle: */
+  0xe3ccc103,		/* bic	ip, ip, #0xc0000000		*/
+  0xe59cc000,		/* ldr	ip, [ip]			*/
+  0xe3ccc13f,		/* bic	ip, ip, #0xc000000f		*/
+  0xe12fff1c,		/* bx	ip				*/
+};
+#define ARM_NACL_PLT_TAIL_OFFSET	(11 * 4)
+
+/* Subsequent entries in a procedure linkage table look like this.  */
+static const bfd_vma elf32_arm_nacl_plt_entry [] =
+{
+  0xe300c000,		/* movw	ip, #:lower16:&GOT[n]-.+8	*/
+  0xe340c000,		/* movt	ip, #:upper16:&GOT[n]-.+8	*/
+  0xe08cc00f,		/* add	ip, ip, pc			*/
+  0xea000000,		/* b	.Lplt_tail			*/
+};
 
 #define ARM_MAX_FWD_BRANCH_OFFSET  ((((1 << 23) - 1) << 2) + 8)
 #define ARM_MAX_BWD_BRANCH_OFFSET  ((-((1 << 23) << 2)) + 8)
@@ -2152,12 +2246,12 @@
 #define THM2_MAX_BWD_BRANCH_OFFSET (-(1 << 24) + 4)
 
 enum stub_insn_type
-  {
-    THUMB16_TYPE = 1,
-    THUMB32_TYPE,
-    ARM_TYPE,
-    DATA_TYPE
-  };
+{
+  THUMB16_TYPE = 1,
+  THUMB32_TYPE,
+  ARM_TYPE,
+  DATA_TYPE
+};
 
 #define THUMB16_INSN(X)		{(X), THUMB16_TYPE, R_ARM_NONE, 0}
 /* A bit of a hack.  A Thumb conditional branch, in which the proper condition
@@ -2171,192 +2265,242 @@
 
 typedef struct
 {
-  bfd_vma data;
-  enum stub_insn_type type;
-  unsigned int r_type;
-  int reloc_addend;
+  bfd_vma              data;
+  enum stub_insn_type  type;
+  unsigned int         r_type;
+  int                  reloc_addend;
 }  insn_sequence;
 
 /* Arm/Thumb -> Arm/Thumb long branch stub. On V5T and above, use blx
    to reach the stub if necessary.  */
 static const insn_sequence elf32_arm_stub_long_branch_any_any[] =
-  {
-    ARM_INSN(0xe51ff004),            /* ldr   pc, [pc, #-4] */
-    DATA_WORD(0, R_ARM_ABS32, 0),    /* dcd   R_ARM_ABS32(X) */
-  };
+{
+  ARM_INSN (0xe51ff004),            /* ldr   pc, [pc, #-4] */
+  DATA_WORD (0, R_ARM_ABS32, 0),    /* dcd   R_ARM_ABS32(X) */
+};
 
 /* V4T Arm -> Thumb long branch stub. Used on V4T where blx is not
    available.  */
 static const insn_sequence elf32_arm_stub_long_branch_v4t_arm_thumb[] =
-  {
-    ARM_INSN(0xe59fc000),            /* ldr   ip, [pc, #0] */
-    ARM_INSN(0xe12fff1c),            /* bx    ip */
-    DATA_WORD(0, R_ARM_ABS32, 0),    /* dcd   R_ARM_ABS32(X) */
-  };
+{
+  ARM_INSN (0xe59fc000),            /* ldr   ip, [pc, #0] */
+  ARM_INSN (0xe12fff1c),            /* bx    ip */
+  DATA_WORD (0, R_ARM_ABS32, 0),    /* dcd   R_ARM_ABS32(X) */
+};
 
 /* Thumb -> Thumb long branch stub. Used on M-profile architectures.  */
 static const insn_sequence elf32_arm_stub_long_branch_thumb_only[] =
-  {
-    THUMB16_INSN(0xb401),             /* push {r0} */
-    THUMB16_INSN(0x4802),             /* ldr  r0, [pc, #8] */
-    THUMB16_INSN(0x4684),             /* mov  ip, r0 */
-    THUMB16_INSN(0xbc01),             /* pop  {r0} */
-    THUMB16_INSN(0x4760),             /* bx   ip */
-    THUMB16_INSN(0xbf00),             /* nop */
-    DATA_WORD(0, R_ARM_ABS32, 0),     /* dcd  R_ARM_ABS32(X) */
-  };
+{
+  THUMB16_INSN (0xb401),             /* push {r0} */
+  THUMB16_INSN (0x4802),             /* ldr  r0, [pc, #8] */
+  THUMB16_INSN (0x4684),             /* mov  ip, r0 */
+  THUMB16_INSN (0xbc01),             /* pop  {r0} */
+  THUMB16_INSN (0x4760),             /* bx   ip */
+  THUMB16_INSN (0xbf00),             /* nop */
+  DATA_WORD (0, R_ARM_ABS32, 0),     /* dcd  R_ARM_ABS32(X) */
+};
 
 /* V4T Thumb -> Thumb long branch stub. Using the stack is not
    allowed.  */
 static const insn_sequence elf32_arm_stub_long_branch_v4t_thumb_thumb[] =
-  {
-    THUMB16_INSN(0x4778),             /* bx   pc */
-    THUMB16_INSN(0x46c0),             /* nop */
-    ARM_INSN(0xe59fc000),             /* ldr  ip, [pc, #0] */
-    ARM_INSN(0xe12fff1c),             /* bx   ip */
-    DATA_WORD(0, R_ARM_ABS32, 0),     /* dcd  R_ARM_ABS32(X) */
-  };
+{
+  THUMB16_INSN (0x4778),             /* bx   pc */
+  THUMB16_INSN (0x46c0),             /* nop */
+  ARM_INSN (0xe59fc000),             /* ldr  ip, [pc, #0] */
+  ARM_INSN (0xe12fff1c),             /* bx   ip */
+  DATA_WORD (0, R_ARM_ABS32, 0),     /* dcd  R_ARM_ABS32(X) */
+};
 
 /* V4T Thumb -> ARM long branch stub. Used on V4T where blx is not
    available.  */
 static const insn_sequence elf32_arm_stub_long_branch_v4t_thumb_arm[] =
-  {
-    THUMB16_INSN(0x4778),             /* bx   pc */
-    THUMB16_INSN(0x46c0),             /* nop   */
-    ARM_INSN(0xe51ff004),             /* ldr   pc, [pc, #-4] */
-    DATA_WORD(0, R_ARM_ABS32, 0),     /* dcd   R_ARM_ABS32(X) */
-  };
+{
+  THUMB16_INSN (0x4778),             /* bx   pc */
+  THUMB16_INSN (0x46c0),             /* nop   */
+  ARM_INSN (0xe51ff004),             /* ldr   pc, [pc, #-4] */
+  DATA_WORD (0, R_ARM_ABS32, 0),     /* dcd   R_ARM_ABS32(X) */
+};
 
 /* V4T Thumb -> ARM short branch stub. Shorter variant of the above
    one, when the destination is close enough.  */
 static const insn_sequence elf32_arm_stub_short_branch_v4t_thumb_arm[] =
-  {
-    THUMB16_INSN(0x4778),             /* bx   pc */
-    THUMB16_INSN(0x46c0),             /* nop   */
-    ARM_REL_INSN(0xea000000, -8),     /* b    (X-8) */
-  };
+{
+  THUMB16_INSN (0x4778),             /* bx   pc */
+  THUMB16_INSN (0x46c0),             /* nop   */
+  ARM_REL_INSN (0xea000000, -8),     /* b    (X-8) */
+};
 
 /* ARM/Thumb -> ARM long branch stub, PIC.  On V5T and above, use
    blx to reach the stub if necessary.  */
 static const insn_sequence elf32_arm_stub_long_branch_any_arm_pic[] =
-  {
-    ARM_INSN(0xe59fc000),             /* ldr   ip, [pc] */
-    ARM_INSN(0xe08ff00c),             /* add   pc, pc, ip */
-    DATA_WORD(0, R_ARM_REL32, -4),    /* dcd   R_ARM_REL32(X-4) */
-  };
+{
+  ARM_INSN (0xe59fc000),             /* ldr   ip, [pc] */
+  ARM_INSN (0xe08ff00c),             /* add   pc, pc, ip */
+  DATA_WORD (0, R_ARM_REL32, -4),    /* dcd   R_ARM_REL32(X-4) */
+};
 
 /* ARM/Thumb -> Thumb long branch stub, PIC.  On V5T and above, use
    blx to reach the stub if necessary.  We can not add into pc;
    it is not guaranteed to mode switch (different in ARMv6 and
    ARMv7).  */
 static const insn_sequence elf32_arm_stub_long_branch_any_thumb_pic[] =
-  {
-    ARM_INSN(0xe59fc004),             /* ldr   ip, [pc, #4] */
-    ARM_INSN(0xe08fc00c),             /* add   ip, pc, ip */
-    ARM_INSN(0xe12fff1c),             /* bx    ip */
-    DATA_WORD(0, R_ARM_REL32, 0),     /* dcd   R_ARM_REL32(X) */
-  };
+{
+  ARM_INSN (0xe59fc004),             /* ldr   ip, [pc, #4] */
+  ARM_INSN (0xe08fc00c),             /* add   ip, pc, ip */
+  ARM_INSN (0xe12fff1c),             /* bx    ip */
+  DATA_WORD (0, R_ARM_REL32, 0),     /* dcd   R_ARM_REL32(X) */
+};
 
 /* V4T ARM -> ARM long branch stub, PIC.  */
 static const insn_sequence elf32_arm_stub_long_branch_v4t_arm_thumb_pic[] =
-  {
-    ARM_INSN(0xe59fc004),             /* ldr   ip, [pc, #4] */
-    ARM_INSN(0xe08fc00c),             /* add   ip, pc, ip */
-    ARM_INSN(0xe12fff1c),             /* bx    ip */
-    DATA_WORD(0, R_ARM_REL32, 0),     /* dcd   R_ARM_REL32(X) */
-  };
+{
+  ARM_INSN (0xe59fc004),             /* ldr   ip, [pc, #4] */
+  ARM_INSN (0xe08fc00c),             /* add   ip, pc, ip */
+  ARM_INSN (0xe12fff1c),             /* bx    ip */
+  DATA_WORD (0, R_ARM_REL32, 0),     /* dcd   R_ARM_REL32(X) */
+};
 
 /* V4T Thumb -> ARM long branch stub, PIC.  */
 static const insn_sequence elf32_arm_stub_long_branch_v4t_thumb_arm_pic[] =
-  {
-    THUMB16_INSN(0x4778),             /* bx   pc */
-    THUMB16_INSN(0x46c0),             /* nop  */
-    ARM_INSN(0xe59fc000),             /* ldr  ip, [pc, #0] */
-    ARM_INSN(0xe08cf00f),             /* add  pc, ip, pc */
-    DATA_WORD(0, R_ARM_REL32, -4),     /* dcd  R_ARM_REL32(X) */
-  };
+{
+  THUMB16_INSN (0x4778),             /* bx   pc */
+  THUMB16_INSN (0x46c0),             /* nop  */
+  ARM_INSN (0xe59fc000),             /* ldr  ip, [pc, #0] */
+  ARM_INSN (0xe08cf00f),             /* add  pc, ip, pc */
+  DATA_WORD (0, R_ARM_REL32, -4),     /* dcd  R_ARM_REL32(X) */
+};
 
 /* Thumb -> Thumb long branch stub, PIC. Used on M-profile
    architectures.  */
 static const insn_sequence elf32_arm_stub_long_branch_thumb_only_pic[] =
-  {
-    THUMB16_INSN(0xb401),             /* push {r0} */
-    THUMB16_INSN(0x4802),             /* ldr  r0, [pc, #8] */
-    THUMB16_INSN(0x46fc),             /* mov  ip, pc */
-    THUMB16_INSN(0x4484),             /* add  ip, r0 */
-    THUMB16_INSN(0xbc01),             /* pop  {r0} */
-    THUMB16_INSN(0x4760),             /* bx   ip */
-    DATA_WORD(0, R_ARM_REL32, 4),     /* dcd  R_ARM_REL32(X) */
-  };
+{
+  THUMB16_INSN (0xb401),             /* push {r0} */
+  THUMB16_INSN (0x4802),             /* ldr  r0, [pc, #8] */
+  THUMB16_INSN (0x46fc),             /* mov  ip, pc */
+  THUMB16_INSN (0x4484),             /* add  ip, r0 */
+  THUMB16_INSN (0xbc01),             /* pop  {r0} */
+  THUMB16_INSN (0x4760),             /* bx   ip */
+  DATA_WORD (0, R_ARM_REL32, 4),     /* dcd  R_ARM_REL32(X) */
+};
 
 /* V4T Thumb -> Thumb long branch stub, PIC. Using the stack is not
    allowed.  */
 static const insn_sequence elf32_arm_stub_long_branch_v4t_thumb_thumb_pic[] =
-  {
-    THUMB16_INSN(0x4778),             /* bx   pc */
-    THUMB16_INSN(0x46c0),             /* nop */
-    ARM_INSN(0xe59fc004),             /* ldr  ip, [pc, #4] */
-    ARM_INSN(0xe08fc00c),             /* add   ip, pc, ip */
-    ARM_INSN(0xe12fff1c),             /* bx   ip */
-    DATA_WORD(0, R_ARM_REL32, 0),     /* dcd  R_ARM_REL32(X) */
-  };
+{
+  THUMB16_INSN (0x4778),             /* bx   pc */
+  THUMB16_INSN (0x46c0),             /* nop */
+  ARM_INSN (0xe59fc004),             /* ldr  ip, [pc, #4] */
+  ARM_INSN (0xe08fc00c),             /* add   ip, pc, ip */
+  ARM_INSN (0xe12fff1c),             /* bx   ip */
+  DATA_WORD (0, R_ARM_REL32, 0),     /* dcd  R_ARM_REL32(X) */
+};
 
 /* Thumb2/ARM -> TLS trampoline.  Lowest common denominator, which is a
    long PIC stub.  We can use r1 as a scratch -- and cannot use ip.  */
 static const insn_sequence elf32_arm_stub_long_branch_any_tls_pic[] =
 {
-    ARM_INSN(0xe59f1000),             /* ldr   r1, [pc] */
-    ARM_INSN(0xe08ff001),             /* add   pc, pc, r1 */
-    DATA_WORD(0, R_ARM_REL32, -4),    /* dcd   R_ARM_REL32(X-4) */
+  ARM_INSN (0xe59f1000),             /* ldr   r1, [pc] */
+  ARM_INSN (0xe08ff001),             /* add   pc, pc, r1 */
+  DATA_WORD (0, R_ARM_REL32, -4),    /* dcd   R_ARM_REL32(X-4) */
 };
 
 /* V4T Thumb -> TLS trampoline.  lowest common denominator, which is a
    long PIC stub.  We can use r1 as a scratch -- and cannot use ip.  */
 static const insn_sequence elf32_arm_stub_long_branch_v4t_thumb_tls_pic[] =
 {
-    THUMB16_INSN(0x4778),             /* bx   pc */
-    THUMB16_INSN(0x46c0),             /* nop */
-    ARM_INSN(0xe59f1000),             /* ldr  r1, [pc, #0] */
-    ARM_INSN(0xe081f00f),             /* add  pc, r1, pc */
-    DATA_WORD(0, R_ARM_REL32, -4),    /* dcd  R_ARM_REL32(X) */
+  THUMB16_INSN (0x4778),             /* bx   pc */
+  THUMB16_INSN (0x46c0),             /* nop */
+  ARM_INSN (0xe59f1000),             /* ldr  r1, [pc, #0] */
+  ARM_INSN (0xe081f00f),             /* add  pc, r1, pc */
+  DATA_WORD (0, R_ARM_REL32, -4),    /* dcd  R_ARM_REL32(X) */
 };
 
+/* NaCl ARM -> ARM long branch stub.  */
+static const insn_sequence elf32_arm_stub_long_branch_arm_nacl[] =
+{
+  ARM_INSN (0xe59fc00c),		/* ldr	ip, [pc, #12] */
+  ARM_INSN (0xe3ccc13f),		/* bic	ip, ip, #0xc000000f */
+  ARM_INSN (0xe12fff1c),                /* bx	ip */
+  ARM_INSN (0xe320f000),                /* nop */
+  ARM_INSN (0xe125be70),                /* bkpt	0x5be0 */
+  DATA_WORD (0, R_ARM_ABS32, 0),        /* dcd	R_ARM_ABS32(X) */
+  DATA_WORD (0, R_ARM_NONE, 0),         /* .word 0 */
+  DATA_WORD (0, R_ARM_NONE, 0),         /* .word 0 */
+};
+
+/* NaCl ARM -> ARM long branch stub, PIC.  */
+static const insn_sequence elf32_arm_stub_long_branch_arm_nacl_pic[] =
+{
+  ARM_INSN (0xe59fc00c),		/* ldr	ip, [pc, #12] */
+  ARM_INSN (0xe08cc00f),                /* add	ip, ip, pc */
+  ARM_INSN (0xe3ccc13f),		/* bic	ip, ip, #0xc000000f */
+  ARM_INSN (0xe12fff1c),                /* bx	ip */
+  ARM_INSN (0xe125be70),                /* bkpt	0x5be0 */
+  DATA_WORD (0, R_ARM_REL32, 8),        /* dcd	R_ARM_REL32(X+8) */
+  DATA_WORD (0, R_ARM_NONE, 0),         /* .word 0 */
+  DATA_WORD (0, R_ARM_NONE, 0),         /* .word 0 */
+};
+
+
 /* Cortex-A8 erratum-workaround stubs.  */
 
 /* Stub used for conditional branches (which may be beyond +/-1MB away, so we
    can't use a conditional branch to reach this stub).  */
 
 static const insn_sequence elf32_arm_stub_a8_veneer_b_cond[] =
-  {
-    THUMB16_BCOND_INSN(0xd001),         /* b<cond>.n true.  */
-    THUMB32_B_INSN(0xf000b800, -4),     /* b.w insn_after_original_branch.  */
-    THUMB32_B_INSN(0xf000b800, -4)      /* true: b.w original_branch_dest.  */
-  };
+{
+  THUMB16_BCOND_INSN (0xd001),         /* b<cond>.n true.  */
+  THUMB32_B_INSN (0xf000b800, -4),     /* b.w insn_after_original_branch.  */
+  THUMB32_B_INSN (0xf000b800, -4)      /* true: b.w original_branch_dest.  */
+};
 
 /* Stub used for b.w and bl.w instructions.  */
 
 static const insn_sequence elf32_arm_stub_a8_veneer_b[] =
-  {
-    THUMB32_B_INSN(0xf000b800, -4)	/* b.w original_branch_dest.  */
-  };
+{
+  THUMB32_B_INSN (0xf000b800, -4)	/* b.w original_branch_dest.  */
+};
 
 static const insn_sequence elf32_arm_stub_a8_veneer_bl[] =
-  {
-    THUMB32_B_INSN(0xf000b800, -4)	/* b.w original_branch_dest.  */
-  };
+{
+  THUMB32_B_INSN (0xf000b800, -4)	/* b.w original_branch_dest.  */
+};
 
 /* Stub used for Thumb-2 blx.w instructions.  We modified the original blx.w
    instruction (which switches to ARM mode) to point to this stub.  Jump to the
    real destination using an ARM-mode branch.  */
 
 static const insn_sequence elf32_arm_stub_a8_veneer_blx[] =
-  {
-    ARM_REL_INSN(0xea000000, -8)	/* b original_branch_dest.  */
-  };
+{
+  ARM_REL_INSN (0xea000000, -8)	/* b original_branch_dest.  */
+};
 
-/* Section name for stubs is the associated section name plus this
-   string.  */
-#define STUB_SUFFIX ".stub"
+/* For each section group there can be a specially created linker section
+   to hold the stubs for that group.  The name of the stub section is based
+   upon the name of another section within that group with the suffix below
+   applied.
+
+   PR 13049: STUB_SUFFIX used to be ".stub", but this allowed the user to
+   create what appeared to be a linker stub section when it actually
+   contained user code/data.  For example, consider this fragment:
+
+     const char * stubborn_problems[] = { "np" };
+
+   If this is compiled with "-fPIC -fdata-sections" then gcc produces a
+   section called:
+
+     .data.rel.local.stubborn_problems
+
+   This then causes problems in arm32_arm_build_stubs() as it triggers:
+
+      // Ignore non-stub sections.
+      if (!strstr (stub_sec->name, STUB_SUFFIX))
+	continue;
+
+   And so the section would be ignored instead of being processed.  Hence
+   the change in definition of STUB_SUFFIX to a name that cannot be a valid
+   C identifier.  */
+#define STUB_SUFFIX ".__stub"
 
 /* One entry per long/short branch stub defined above.  */
 #define DEF_STUBS \
@@ -2374,13 +2518,16 @@
   DEF_STUB(long_branch_thumb_only_pic) \
   DEF_STUB(long_branch_any_tls_pic) \
   DEF_STUB(long_branch_v4t_thumb_tls_pic) \
+  DEF_STUB(long_branch_arm_nacl) \
+  DEF_STUB(long_branch_arm_nacl_pic) \
   DEF_STUB(a8_veneer_b_cond) \
   DEF_STUB(a8_veneer_b) \
   DEF_STUB(a8_veneer_bl) \
   DEF_STUB(a8_veneer_blx)
 
 #define DEF_STUB(x) arm_stub_##x,
-enum elf32_arm_stub_type {
+enum elf32_arm_stub_type
+{
   arm_stub_none,
   DEF_STUBS
   /* Note the first a8_veneer type */
@@ -2395,7 +2542,8 @@
 } stub_def;
 
 #define DEF_STUB(x) {elf32_arm_stub_##x, ARRAY_SIZE(elf32_arm_stub_##x)},
-static const stub_def stub_definitions[] = {
+static const stub_def stub_definitions[] =
+{
   {NULL, 0},
   DEF_STUBS
 };
@@ -2548,7 +2696,8 @@
    relaxing which we can refresh easily, then create stubs for each potentially
    erratum-triggering instruction once we've settled on a solution.  */
 
-struct a8_erratum_fix {
+struct a8_erratum_fix
+{
   bfd *input_bfd;
   asection *section;
   bfd_vma offset;
@@ -2562,7 +2711,8 @@
 /* A table of relocs applied to branches which might trigger Cortex-A8
    erratum.  */
 
-struct a8_erratum_reloc {
+struct a8_erratum_reloc
+{
   bfd_vma from;
   bfd_vma destination;
   struct elf32_arm_link_hash_entry *hash;
@@ -2577,7 +2727,8 @@
 
 /* ARM-specific information about a PLT entry, over and above the usual
    gotplt_union.  */
-struct arm_plt_info {
+struct arm_plt_info
+{
   /* We reference count Thumb references to a PLT entry separately,
      so that we can emit the Thumb trampoline only if needed.  */
   bfd_signed_vma thumb_refcount;
@@ -2600,7 +2751,8 @@
 };
 
 /* Information about an .iplt entry for a local STT_GNU_IFUNC symbol.  */
-struct arm_local_iplt_info {
+struct arm_local_iplt_info
+{
   /* The information that is usually found in the generic ELF part of
      the hash table entry.  */
   union gotplt_union root;
@@ -2661,14 +2813,14 @@
 
 /* Arm ELF linker hash entry.  */
 struct elf32_arm_link_hash_entry
-  {
-    struct elf_link_hash_entry root;
+{
+  struct elf_link_hash_entry root;
 
-    /* Track dynamic relocs copied for this symbol.  */
-    struct elf_dyn_relocs *dyn_relocs;
+  /* Track dynamic relocs copied for this symbol.  */
+  struct elf_dyn_relocs *dyn_relocs;
 
-    /* ARM-specific PLT information.  */
-    struct arm_plt_info plt;
+  /* ARM-specific PLT information.  */
+  struct arm_plt_info plt;
 
 #define GOT_UNKNOWN	0
 #define GOT_NORMAL	1
@@ -2676,25 +2828,25 @@
 #define GOT_TLS_IE	4
 #define GOT_TLS_GDESC	8
 #define GOT_TLS_GD_ANY_P(type)	((type & GOT_TLS_GD) || (type & GOT_TLS_GDESC))
-    unsigned int tls_type : 8;
+  unsigned int tls_type : 8;
 
-    /* True if the symbol's PLT entry is in .iplt rather than .plt.  */
-    unsigned int is_iplt : 1;
+  /* True if the symbol's PLT entry is in .iplt rather than .plt.  */
+  unsigned int is_iplt : 1;
 
-    unsigned int unused : 23;
+  unsigned int unused : 23;
 
-    /* Offset of the GOTPLT entry reserved for the TLS descriptor,
-       starting at the end of the jump table.  */
-    bfd_vma tlsdesc_got;
+  /* Offset of the GOTPLT entry reserved for the TLS descriptor,
+     starting at the end of the jump table.  */
+  bfd_vma tlsdesc_got;
 
-    /* The symbol marking the real symbol location for exported thumb
-       symbols with Arm stubs.  */
-    struct elf_link_hash_entry *export_glue;
+  /* The symbol marking the real symbol location for exported thumb
+     symbols with Arm stubs.  */
+  struct elf_link_hash_entry *export_glue;
 
-   /* A pointer to the most recently used stub hash entry against this
+  /* A pointer to the most recently used stub hash entry against this
      symbol.  */
-    struct elf32_arm_stub_hash_entry *stub_cache;
-  };
+  struct elf32_arm_stub_hash_entry *stub_cache;
+};
 
 /* Traverse an arm ELF linker hash table.  */
 #define elf32_arm_link_hash_traverse(table, func, info)			\
@@ -2804,6 +2956,9 @@
   /* True if the target system is Symbian OS.  */
   int symbian_p;
 
+  /* True if the target system is Native Client.  */
+  int nacl_p;
+
   /* True if the target uses REL relocations.  */
   int use_rel;
 
@@ -2828,7 +2983,7 @@
 
   /* The offset into sgot of the GOT entry used by the PLT entry
      above.  */
-  bfd_vma dt_tlsdesc_got;    
+  bfd_vma dt_tlsdesc_got;
 
   /* Offset in .plt section of tls_arm_trampoline.  */
   bfd_vma tls_trampoline;
@@ -2857,7 +3012,7 @@
   bfd *stub_bfd;
 
   /* Linker call-backs.  */
-  asection * (*add_stub_section) (const char *, asection *);
+  asection * (*add_stub_section) (const char *, asection *, unsigned int);
   void (*layout_sections_again) (void);
 
   /* Array to keep track of which stub sections have been created, and
@@ -2877,8 +3032,8 @@
 
 static struct bfd_hash_entry *
 elf32_arm_link_hash_newfunc (struct bfd_hash_entry * entry,
-                             struct bfd_hash_table * table,
-                             const char * string)
+			     struct bfd_hash_table * table,
+			     const char * string)
 {
   struct elf32_arm_link_hash_entry * ret =
     (struct elf32_arm_link_hash_entry *) entry;
@@ -2887,7 +3042,7 @@
      subclass.  */
   if (ret == NULL)
     ret = (struct elf32_arm_link_hash_entry *)
-        bfd_hash_allocate (table, sizeof (struct elf32_arm_link_hash_entry));
+	bfd_hash_allocate (table, sizeof (struct elf32_arm_link_hash_entry));
   if (ret == NULL)
     return (struct bfd_hash_entry *) ret;
 
@@ -3061,7 +3216,7 @@
   if (entry == NULL)
     {
       entry = (struct bfd_hash_entry *)
-          bfd_hash_allocate (table, sizeof (struct elf32_arm_stub_hash_entry));
+	  bfd_hash_allocate (table, sizeof (struct elf32_arm_stub_hash_entry));
       if (entry == NULL)
 	return entry;
     }
@@ -3124,7 +3279,7 @@
   bfd *dynobj;
   asection *s;
   flagword flags;
-  
+
   htab = elf32_arm_hash_table (info);
   dynobj = htab->root.dynobj;
   bed = get_elf_backend_data (dynobj);
@@ -3132,27 +3287,28 @@
 
   if (htab->root.iplt == NULL)
     {
-      s = bfd_make_section_with_flags (dynobj, ".iplt",
-				       flags | SEC_READONLY | SEC_CODE);
+      s = bfd_make_section_anyway_with_flags (dynobj, ".iplt",
+					      flags | SEC_READONLY | SEC_CODE);
       if (s == NULL
-	  || !bfd_set_section_alignment (abfd, s, bed->plt_alignment))
+	  || !bfd_set_section_alignment (dynobj, s, bed->plt_alignment))
 	return FALSE;
       htab->root.iplt = s;
     }
 
   if (htab->root.irelplt == NULL)
     {
-      s = bfd_make_section_with_flags (dynobj, RELOC_SECTION (htab, ".iplt"),
-				       flags | SEC_READONLY);
+      s = bfd_make_section_anyway_with_flags (dynobj,
+					      RELOC_SECTION (htab, ".iplt"),
+					      flags | SEC_READONLY);
       if (s == NULL
-	  || !bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
+	  || !bfd_set_section_alignment (dynobj, s, bed->s->log_file_align))
 	return FALSE;
       htab->root.irelplt = s;
     }
 
   if (htab->root.igotplt == NULL)
     {
-      s = bfd_make_section_with_flags (dynobj, ".igot.plt", flags);
+      s = bfd_make_section_anyway_with_flags (dynobj, ".igot.plt", flags);
       if (s == NULL
 	  || !bfd_set_section_alignment (dynobj, s, bed->s->log_file_align))
 	return FALSE;
@@ -3180,10 +3336,10 @@
   if (!_bfd_elf_create_dynamic_sections (dynobj, info))
     return FALSE;
 
-  htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
+  htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
   if (!info->shared)
-    htab->srelbss = bfd_get_section_by_name (dynobj,
-					     RELOC_SECTION (htab, ".bss"));
+    htab->srelbss = bfd_get_linker_section (dynobj,
+					    RELOC_SECTION (htab, ".bss"));
 
   if (htab->vxworks_p)
     {
@@ -3289,7 +3445,7 @@
   struct elf32_arm_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf32_arm_link_hash_table);
 
-  ret = (struct elf32_arm_link_hash_table *) bfd_malloc (amt);
+  ret = (struct elf32_arm_link_hash_table *) bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
 
@@ -3302,27 +3458,7 @@
       return NULL;
     }
 
-  ret->sdynbss = NULL;
-  ret->srelbss = NULL;
-  ret->srelplt2 = NULL;
-  ret->dt_tlsdesc_plt = 0;
-  ret->dt_tlsdesc_got = 0;
-  ret->tls_trampoline = 0;
-  ret->next_tls_desc_index = 0;
-  ret->num_tls_desc = 0;
-  ret->thumb_glue_size = 0;
-  ret->arm_glue_size = 0;
-  ret->bx_glue_size = 0;
-  memset (ret->bx_glue_offset, 0, sizeof (ret->bx_glue_offset));
   ret->vfp11_fix = BFD_ARM_VFP11_FIX_NONE;
-  ret->vfp11_erratum_glue_size = 0;
-  ret->num_vfp11_fixes = 0;
-  ret->fix_cortex_a8 = 0;
-  ret->fix_arm1176 = 0;
-  ret->bfd_of_glue_owner = NULL;
-  ret->byteswap_code = 0;
-  ret->target1_is_rel = 0;
-  ret->target2_reloc = R_ARM_NONE;
 #ifdef FOUR_WORD_PLT
   ret->plt_header_size = 16;
   ret->plt_entry_size = 16;
@@ -3330,22 +3466,8 @@
   ret->plt_header_size = 20;
   ret->plt_entry_size = 12;
 #endif
-  ret->fix_v4bx = 0;
-  ret->use_blx = 0;
-  ret->vxworks_p = 0;
-  ret->symbian_p = 0;
   ret->use_rel = 1;
-  ret->sym_cache.abfd = NULL;
   ret->obfd = abfd;
-  ret->tls_ldm_got.refcount = 0;
-  ret->stub_bfd = NULL;
-  ret->add_stub_section = NULL;
-  ret->layout_sections_again = NULL;
-  ret->stub_group = NULL;
-  ret->top_id = 0;
-  ret->bfd_count = 0;
-  ret->top_index = 0;
-  ret->input_list = NULL;
 
   if (!bfd_hash_table_init (&ret->stub_hash_table, stub_hash_newfunc,
 			    sizeof (struct elf32_arm_stub_hash_entry)))
@@ -3366,7 +3488,7 @@
     = (struct elf32_arm_link_hash_table *) hash;
 
   bfd_hash_table_free (&ret->stub_hash_table);
-  _bfd_generic_link_hash_table_free (hash);
+  _bfd_elf_link_hash_table_free (hash);
 }
 
 /* Determine if we're dealing with a Thumb only architecture.  */
@@ -3487,6 +3609,12 @@
 
   r_type = ELF32_R_TYPE (rel->r_info);
 
+  /* ST_BRANCH_TO_ARM is nonsense to thumb-only targets when we
+     are considering a function call relocation.  */
+  if (thumb_only && (r_type == R_ARM_THM_CALL || r_type == R_ARM_THM_JUMP24)
+      && branch_type == ST_BRANCH_TO_ARM)
+    branch_type = ST_BRANCH_TO_THUMB;
+
   /* For TLS call relocs, it is the caller's responsibility to provide
      the address of the appropriate trampoline.  */
   if (r_type != R_ARM_TLS_CALL
@@ -3502,7 +3630,7 @@
       else
 	splt = globals->root.splt;
       if (splt != NULL)
-	{	
+	{
 	  use_plt = 1;
 
 	  /* Note when dealing with PLT entries: the main PLT stub is in
@@ -3531,11 +3659,11 @@
     {
       /* Handle cases where:
 	 - this call goes too far (different Thumb/Thumb2 max
-           distance)
+	   distance)
 	 - it's a Thumb->Arm call and blx is not available, or it's a
-           Thumb->Arm branch (not bl). A stub is needed in this case,
-           but only if this call is not through a PLT entry. Indeed,
-           PLT stubs handle mode switching already.
+	   Thumb->Arm branch (not bl). A stub is needed in this case,
+	   but only if this call is not through a PLT entry. Indeed,
+	   PLT stubs handle mode switching already.
       */
       if ((!thumb2
 	    && (branch_offset > THM_MAX_FWD_BRANCH_OFFSET
@@ -3557,7 +3685,7 @@
 		  stub_type = (info->shared | globals->pic_veneer)
 		    /* PIC stubs.  */
 		    ? ((globals->use_blx
-			&& (r_type ==R_ARM_THM_CALL))
+			&& (r_type == R_ARM_THM_CALL))
 		       /* V5T and above. Stub starts with ARM code, so
 			  we must be able to switch mode before
 			  reaching it, which is only possible for 'bl'
@@ -3568,7 +3696,7 @@
 
 		    /* non-PIC stubs.  */
 		    : ((globals->use_blx
-			&& (r_type ==R_ARM_THM_CALL))
+			&& (r_type == R_ARM_THM_CALL))
 		       /* V5T and above.  */
 		       ? arm_stub_long_branch_any_any
 		       /* V4T.  */
@@ -3679,9 +3807,13 @@
 		? (r_type == R_ARM_TLS_CALL
 		   /* TLS PIC Stub */
 		   ? arm_stub_long_branch_any_tls_pic
-		   : arm_stub_long_branch_any_arm_pic)
+		   : (globals->nacl_p
+		      ? arm_stub_long_branch_arm_nacl_pic
+		      : arm_stub_long_branch_any_arm_pic))
 		/* non-PIC stubs.  */
-		: arm_stub_long_branch_any_any;
+		: (globals->nacl_p
+		   ? arm_stub_long_branch_arm_nacl
+		   : arm_stub_long_branch_any_any);
 	    }
 	}
     }
@@ -3786,7 +3918,7 @@
 }
 
 /* Find or create a stub section.  Returns a pointer to the stub section, and
-   the section to which the stub section will be attached (in *LINK_SEC_P). 
+   the section to which the stub section will be attached (in *LINK_SEC_P).
    LINK_SEC_P may be NULL.  */
 
 static asection *
@@ -3797,7 +3929,9 @@
   asection *stub_sec;
 
   link_sec = htab->stub_group[section->id].link_sec;
+  BFD_ASSERT (link_sec != NULL);
   stub_sec = htab->stub_group[section->id].stub_sec;
+
   if (stub_sec == NULL)
     {
       stub_sec = htab->stub_group[link_sec->id].stub_sec;
@@ -3815,17 +3949,18 @@
 
 	  memcpy (s_name, link_sec->name, namelen);
 	  memcpy (s_name + namelen, STUB_SUFFIX, sizeof (STUB_SUFFIX));
-	  stub_sec = (*htab->add_stub_section) (s_name, link_sec);
+	  stub_sec = (*htab->add_stub_section) (s_name, link_sec,
+						htab->nacl_p ? 4 : 3);
 	  if (stub_sec == NULL)
 	    return NULL;
 	  htab->stub_group[link_sec->id].stub_sec = stub_sec;
 	}
       htab->stub_group[section->id].stub_sec = stub_sec;
     }
-  
+
   if (link_sec_p)
     *link_sec_p = link_sec;
-  
+
   return stub_sec;
 }
 
@@ -3893,7 +4028,7 @@
    model, return the new reloc type.  */
 
 static unsigned
-elf32_arm_tls_transition (struct bfd_link_info *info, int r_type, 
+elf32_arm_tls_transition (struct bfd_link_info *info, int r_type,
 			  struct elf_link_hash_entry *h)
 {
   int is_local = (h == NULL);
@@ -3901,7 +4036,7 @@
   if (info->shared || (h && h->root.type == bfd_link_hash_undefweak))
     return r_type;
 
-  /* We do not support relaxations for Old TLS models.  */ 
+  /* We do not support relaxations for Old TLS models.  */
   switch (r_type)
     {
     case R_ARM_TLS_GOTDESC:
@@ -3947,7 +4082,11 @@
     case arm_stub_long_branch_v4t_thumb_tls_pic:
     case arm_stub_a8_veneer_blx:
       return 4;
-    
+
+    case arm_stub_long_branch_arm_nacl:
+    case arm_stub_long_branch_arm_nacl_pic:
+      return 16;
+
     default:
       abort ();  /* Should be unreachable.  */
     }
@@ -3957,7 +4096,7 @@
 arm_build_one_stub (struct bfd_hash_entry *gen_entry,
 		    void * in_arg)
 {
-#define MAXRELOCS 2
+#define MAXRELOCS 3
   struct elf32_arm_stub_hash_entry *stub_entry;
   struct elf32_arm_link_hash_table *globals;
   struct bfd_link_info *info;
@@ -4012,11 +4151,11 @@
 	    bfd_vma data = (bfd_vma) template_sequence[i].data;
 	    if (template_sequence[i].reloc_addend != 0)
 	      {
-                /* We've borrowed the reloc_addend field to mean we should
-                   insert a condition code into this (Thumb-1 branch)
-                   instruction.  See THUMB16_BCOND_INSN.  */
-                BFD_ASSERT ((data & 0xff00) == 0xd000);
-                data |= ((stub_entry->orig_insn >> 22) & 0xf) << 8;
+		/* We've borrowed the reloc_addend field to mean we should
+		   insert a condition code into this (Thumb-1 branch)
+		   instruction.  See THUMB16_BCOND_INSN.  */
+		BFD_ASSERT ((data & 0xff00) == 0xd000);
+		data |= ((stub_entry->orig_insn >> 22) & 0xf) << 8;
 	      }
 	    bfd_put_16 (stub_bfd, data, loc + size);
 	    size += 2;
@@ -4029,13 +4168,13 @@
 		      loc + size);
 	  bfd_put_16 (stub_bfd, template_sequence[i].data & 0xffff,
 		      loc + size + 2);
-          if (template_sequence[i].r_type != R_ARM_NONE)
-            {
-              stub_reloc_idx[nrelocs] = i;
-              stub_reloc_offset[nrelocs++] = size;
-            }
-          size += 4;
-          break;
+	  if (template_sequence[i].r_type != R_ARM_NONE)
+	    {
+	      stub_reloc_idx[nrelocs] = i;
+	      stub_reloc_offset[nrelocs++] = size;
+	    }
+	  size += 4;
+	  break;
 
 	case ARM_TYPE:
 	  bfd_put_32 (stub_bfd, template_sequence[i].data,
@@ -4093,7 +4232,7 @@
 
 	rel.r_offset = stub_entry->stub_offset + stub_reloc_offset[i];
 	rel.r_info = ELF32_R_INFO (0,
-                                   template_sequence[stub_reloc_idx[i]].r_type);
+				   template_sequence[stub_reloc_idx[i]].r_type);
 	rel.r_addend = template_sequence[stub_reloc_idx[i]].reloc_addend;
 
 	if (stub_entry->stub_type == arm_stub_a8_veneer_b_cond && i == 0)
@@ -4126,7 +4265,7 @@
 
 	rel.r_offset = stub_entry->stub_offset + stub_reloc_offset[i];
 	rel.r_info = ELF32_R_INFO (0,
-                                   template_sequence[stub_reloc_idx[i]].r_type);
+				   template_sequence[stub_reloc_idx[i]].r_type);
 	rel.r_addend = 0;
 
 	elf32_arm_final_link_relocate (elf32_arm_howto_from_type
@@ -4356,15 +4495,15 @@
 #define NEXT_SEC PREV_SEC
       head = NULL;
       while (tail != NULL)
-        {
-          /* Pop from tail.  */
-          asection *item = tail;
-          tail = PREV_SEC (item);
+	{
+	  /* Pop from tail.  */
+	  asection *item = tail;
+	  tail = PREV_SEC (item);
 
-          /* Push on head.  */
-          NEXT_SEC (item) = head;
-          head = item;
-        }
+	  /* Push on head.  */
+	  NEXT_SEC (item) = head;
+	  head = item;
+	}
 
       while (head != NULL)
 	{
@@ -4483,65 +4622,65 @@
       bfd_vma base_vma;
 
       if (elf_section_type (section) != SHT_PROGBITS
-          || (elf_section_flags (section) & SHF_EXECINSTR) == 0
-          || (section->flags & SEC_EXCLUDE) != 0
-          || (section->sec_info_type == ELF_INFO_TYPE_JUST_SYMS)
-          || (section->output_section == bfd_abs_section_ptr))
-        continue;
+	  || (elf_section_flags (section) & SHF_EXECINSTR) == 0
+	  || (section->flags & SEC_EXCLUDE) != 0
+	  || (section->sec_info_type == SEC_INFO_TYPE_JUST_SYMS)
+	  || (section->output_section == bfd_abs_section_ptr))
+	continue;
 
       base_vma = section->output_section->vma + section->output_offset;
 
       if (elf_section_data (section)->this_hdr.contents != NULL)
-        contents = elf_section_data (section)->this_hdr.contents;
+	contents = elf_section_data (section)->this_hdr.contents;
       else if (! bfd_malloc_and_get_section (input_bfd, section, &contents))
-        return TRUE;
+	return TRUE;
 
       sec_data = elf32_arm_section_data (section);
 
       for (span = 0; span < sec_data->mapcount; span++)
-        {
-          unsigned int span_start = sec_data->map[span].vma;
-          unsigned int span_end = (span == sec_data->mapcount - 1)
-            ? section->size : sec_data->map[span + 1].vma;
-          unsigned int i;
-          char span_type = sec_data->map[span].type;
-          bfd_boolean last_was_32bit = FALSE, last_was_branch = FALSE;
+	{
+	  unsigned int span_start = sec_data->map[span].vma;
+	  unsigned int span_end = (span == sec_data->mapcount - 1)
+	    ? section->size : sec_data->map[span + 1].vma;
+	  unsigned int i;
+	  char span_type = sec_data->map[span].type;
+	  bfd_boolean last_was_32bit = FALSE, last_was_branch = FALSE;
 
-          if (span_type != 't')
-            continue;
+	  if (span_type != 't')
+	    continue;
 
-          /* Span is entirely within a single 4KB region: skip scanning.  */
-          if (((base_vma + span_start) & ~0xfff)
+	  /* Span is entirely within a single 4KB region: skip scanning.  */
+	  if (((base_vma + span_start) & ~0xfff)
 	      == ((base_vma + span_end) & ~0xfff))
-            continue;
+	    continue;
 
-          /* Scan for 32-bit Thumb-2 branches which span two 4K regions, where:
+	  /* Scan for 32-bit Thumb-2 branches which span two 4K regions, where:
 
-               * The opcode is BLX.W, BL.W, B.W, Bcc.W
-               * The branch target is in the same 4KB region as the
-                 first half of the branch.
-               * The instruction before the branch is a 32-bit
-                 length non-branch instruction.  */
-          for (i = span_start; i < span_end;)
-            {
-              unsigned int insn = bfd_getl16 (&contents[i]);
-              bfd_boolean insn_32bit = FALSE, is_blx = FALSE, is_b = FALSE;
+	       * The opcode is BLX.W, BL.W, B.W, Bcc.W
+	       * The branch target is in the same 4KB region as the
+		 first half of the branch.
+	       * The instruction before the branch is a 32-bit
+		 length non-branch instruction.  */
+	  for (i = span_start; i < span_end;)
+	    {
+	      unsigned int insn = bfd_getl16 (&contents[i]);
+	      bfd_boolean insn_32bit = FALSE, is_blx = FALSE, is_b = FALSE;
 	      bfd_boolean is_bl = FALSE, is_bcc = FALSE, is_32bit_branch;
 
-              if ((insn & 0xe000) == 0xe000 && (insn & 0x1800) != 0x0000)
-                insn_32bit = TRUE;
+	      if ((insn & 0xe000) == 0xe000 && (insn & 0x1800) != 0x0000)
+		insn_32bit = TRUE;
 
 	      if (insn_32bit)
-	        {
-                  /* Load the rest of the insn (in manual-friendly order).  */
-                  insn = (insn << 16) | bfd_getl16 (&contents[i + 2]);
+		{
+		  /* Load the rest of the insn (in manual-friendly order).  */
+		  insn = (insn << 16) | bfd_getl16 (&contents[i + 2]);
 
-        	  /* Encoding T4: B<c>.W.  */
-        	  is_b = (insn & 0xf800d000) == 0xf0009000;
-        	  /* Encoding T1: BL<c>.W.  */
-        	  is_bl = (insn & 0xf800d000) == 0xf000d000;
-        	  /* Encoding T2: BLX<c>.W.  */
-        	  is_blx = (insn & 0xf800d000) == 0xf000c000;
+		  /* Encoding T4: B<c>.W.  */
+		  is_b = (insn & 0xf800d000) == 0xf0009000;
+		  /* Encoding T1: BL<c>.W.  */
+		  is_bl = (insn & 0xf800d000) == 0xf000d000;
+		  /* Encoding T2: BLX<c>.W.  */
+		  is_blx = (insn & 0xf800d000) == 0xf000c000;
 		  /* Encoding T3: B<c>.W (not permitted in IT block).  */
 		  is_bcc = (insn & 0xf800d000) == 0xf0008000
 			   && (insn & 0x07f00000) != 0x03800000;
@@ -4549,25 +4688,25 @@
 
 	      is_32bit_branch = is_b || is_bl || is_blx || is_bcc;
 
-              if (((base_vma + i) & 0xfff) == 0xffe
+	      if (((base_vma + i) & 0xfff) == 0xffe
 		  && insn_32bit
 		  && is_32bit_branch
 		  && last_was_32bit
 		  && ! last_was_branch)
-                {
-                  bfd_signed_vma offset = 0;
-                  bfd_boolean force_target_arm = FALSE;
+		{
+		  bfd_signed_vma offset = 0;
+		  bfd_boolean force_target_arm = FALSE;
 		  bfd_boolean force_target_thumb = FALSE;
-                  bfd_vma target;
-                  enum elf32_arm_stub_type stub_type = arm_stub_none;
-                  struct a8_erratum_reloc key, *found;
-                  bfd_boolean use_plt = FALSE;
+		  bfd_vma target;
+		  enum elf32_arm_stub_type stub_type = arm_stub_none;
+		  struct a8_erratum_reloc key, *found;
+		  bfd_boolean use_plt = FALSE;
 
-                  key.from = base_vma + i;
-                  found = (struct a8_erratum_reloc *)
-                      bsearch (&key, a8_relocs, num_a8_relocs,
-                               sizeof (struct a8_erratum_reloc),
-                               &a8_reloc_compare);
+		  key.from = base_vma + i;
+		  found = (struct a8_erratum_reloc *)
+		      bsearch (&key, a8_relocs, num_a8_relocs,
+			       sizeof (struct a8_erratum_reloc),
+			       &a8_reloc_compare);
 
 		  if (found)
 		    {
@@ -4575,7 +4714,7 @@
 		      struct elf_link_hash_entry *entry;
 
 		      /* We don't care about the error returned from this
-		         function, only if there is glue or not.  */
+			 function, only if there is glue or not.  */
 		      entry = find_thumb_glue (info, found->sym_name,
 					       &error_message);
 
@@ -4597,7 +4736,7 @@
 			}
 		    }
 
-                  /* Check if we have an offending branch instruction.  */
+		  /* Check if we have an offending branch instruction.  */
 
 		  if (found && found->non_a8_stub)
 		    /* We've already made a stub for this instruction, e.g.
@@ -4605,46 +4744,46 @@
 		       stub will suffice to work around the A8 erratum (see
 		       setting of always_after_branch above).  */
 		    ;
-                  else if (is_bcc)
-                    {
-                      offset = (insn & 0x7ff) << 1;
-                      offset |= (insn & 0x3f0000) >> 4;
-                      offset |= (insn & 0x2000) ? 0x40000 : 0;
-                      offset |= (insn & 0x800) ? 0x80000 : 0;
-                      offset |= (insn & 0x4000000) ? 0x100000 : 0;
-                      if (offset & 0x100000)
-                        offset |= ~ ((bfd_signed_vma) 0xfffff);
-                      stub_type = arm_stub_a8_veneer_b_cond;
-                    }
-                  else if (is_b || is_bl || is_blx)
-                    {
-                      int s = (insn & 0x4000000) != 0;
-                      int j1 = (insn & 0x2000) != 0;
-                      int j2 = (insn & 0x800) != 0;
-                      int i1 = !(j1 ^ s);
-                      int i2 = !(j2 ^ s);
+		  else if (is_bcc)
+		    {
+		      offset = (insn & 0x7ff) << 1;
+		      offset |= (insn & 0x3f0000) >> 4;
+		      offset |= (insn & 0x2000) ? 0x40000 : 0;
+		      offset |= (insn & 0x800) ? 0x80000 : 0;
+		      offset |= (insn & 0x4000000) ? 0x100000 : 0;
+		      if (offset & 0x100000)
+			offset |= ~ ((bfd_signed_vma) 0xfffff);
+		      stub_type = arm_stub_a8_veneer_b_cond;
+		    }
+		  else if (is_b || is_bl || is_blx)
+		    {
+		      int s = (insn & 0x4000000) != 0;
+		      int j1 = (insn & 0x2000) != 0;
+		      int j2 = (insn & 0x800) != 0;
+		      int i1 = !(j1 ^ s);
+		      int i2 = !(j2 ^ s);
 
-                      offset = (insn & 0x7ff) << 1;
-                      offset |= (insn & 0x3ff0000) >> 4;
-                      offset |= i2 << 22;
-                      offset |= i1 << 23;
-                      offset |= s << 24;
-                      if (offset & 0x1000000)
-                        offset |= ~ ((bfd_signed_vma) 0xffffff);
+		      offset = (insn & 0x7ff) << 1;
+		      offset |= (insn & 0x3ff0000) >> 4;
+		      offset |= i2 << 22;
+		      offset |= i1 << 23;
+		      offset |= s << 24;
+		      if (offset & 0x1000000)
+			offset |= ~ ((bfd_signed_vma) 0xffffff);
 
-                      if (is_blx)
-                        offset &= ~ ((bfd_signed_vma) 3);
+		      if (is_blx)
+			offset &= ~ ((bfd_signed_vma) 3);
 
-                      stub_type = is_blx ? arm_stub_a8_veneer_blx :
-                        is_bl ? arm_stub_a8_veneer_bl : arm_stub_a8_veneer_b;
-                    }
+		      stub_type = is_blx ? arm_stub_a8_veneer_blx :
+			is_bl ? arm_stub_a8_veneer_bl : arm_stub_a8_veneer_b;
+		    }
 
-                  if (stub_type != arm_stub_none)
-                    {
-                      bfd_vma pc_for_insn = base_vma + i + 4;
+		  if (stub_type != arm_stub_none)
+		    {
+		      bfd_vma pc_for_insn = base_vma + i + 4;
 
 		      /* The original instruction is a BL, but the target is
-		         an ARM instruction.  If we were not making a stub,
+			 an ARM instruction.  If we were not making a stub,
 			 the BL would have been converted to a BLX.  Use the
 			 BLX stub instead in that case.  */
 		      if (htab->use_blx && force_target_arm
@@ -4665,43 +4804,43 @@
 			  is_bl = TRUE;
 			}
 
-                      if (is_blx)
-                        pc_for_insn &= ~ ((bfd_vma) 3);
+		      if (is_blx)
+			pc_for_insn &= ~ ((bfd_vma) 3);
 
-                      /* If we found a relocation, use the proper destination,
-		         not the offset in the (unrelocated) instruction.
+		      /* If we found a relocation, use the proper destination,
+			 not the offset in the (unrelocated) instruction.
 			 Note this is always done if we switched the stub type
 			 above.  */
-                      if (found)
-                        offset =
+		      if (found)
+			offset =
 			  (bfd_signed_vma) (found->destination - pc_for_insn);
 
-                      /* If the stub will use a Thumb-mode branch to a
-                         PLT target, redirect it to the preceding Thumb
-                         entry point.  */
-                      if (stub_type != arm_stub_a8_veneer_blx && use_plt)
-                        offset -= PLT_THUMB_STUB_SIZE;
+		      /* If the stub will use a Thumb-mode branch to a
+			 PLT target, redirect it to the preceding Thumb
+			 entry point.  */
+		      if (stub_type != arm_stub_a8_veneer_blx && use_plt)
+			offset -= PLT_THUMB_STUB_SIZE;
 
-                      target = pc_for_insn + offset;
+		      target = pc_for_insn + offset;
 
-                      /* The BLX stub is ARM-mode code.  Adjust the offset to
-		         take the different PC value (+8 instead of +4) into
+		      /* The BLX stub is ARM-mode code.  Adjust the offset to
+			 take the different PC value (+8 instead of +4) into
 			 account.  */
-                      if (stub_type == arm_stub_a8_veneer_blx)
-                        offset += 4;
+		      if (stub_type == arm_stub_a8_veneer_blx)
+			offset += 4;
 
-                      if (((base_vma + i) & ~0xfff) == (target & ~0xfff))
-                        {
-                          char *stub_name = NULL;
+		      if (((base_vma + i) & ~0xfff) == (target & ~0xfff))
+			{
+			  char *stub_name = NULL;
 
-                          if (num_a8_fixes == a8_fix_table_size)
-                            {
-                              a8_fix_table_size *= 2;
-                              a8_fixes = (struct a8_erratum_fix *)
-                                  bfd_realloc (a8_fixes,
-                                               sizeof (struct a8_erratum_fix)
-                                               * a8_fix_table_size);
-                            }
+			  if (num_a8_fixes == a8_fix_table_size)
+			    {
+			      a8_fix_table_size *= 2;
+			      a8_fixes = (struct a8_erratum_fix *)
+				  bfd_realloc (a8_fixes,
+					       sizeof (struct a8_erratum_fix)
+					       * a8_fix_table_size);
+			    }
 
 			  if (num_a8_fixes < prev_num_a8_fixes)
 			    {
@@ -4726,29 +4865,29 @@
 				sprintf (stub_name, "%x:%x", section->id, i);
 			    }
 
-                          a8_fixes[num_a8_fixes].input_bfd = input_bfd;
-                          a8_fixes[num_a8_fixes].section = section;
-                          a8_fixes[num_a8_fixes].offset = i;
-                          a8_fixes[num_a8_fixes].addend = offset;
-                          a8_fixes[num_a8_fixes].orig_insn = insn;
-                          a8_fixes[num_a8_fixes].stub_name = stub_name;
-                          a8_fixes[num_a8_fixes].stub_type = stub_type;
-                          a8_fixes[num_a8_fixes].branch_type =
+			  a8_fixes[num_a8_fixes].input_bfd = input_bfd;
+			  a8_fixes[num_a8_fixes].section = section;
+			  a8_fixes[num_a8_fixes].offset = i;
+			  a8_fixes[num_a8_fixes].addend = offset;
+			  a8_fixes[num_a8_fixes].orig_insn = insn;
+			  a8_fixes[num_a8_fixes].stub_name = stub_name;
+			  a8_fixes[num_a8_fixes].stub_type = stub_type;
+			  a8_fixes[num_a8_fixes].branch_type =
 			    is_blx ? ST_BRANCH_TO_ARM : ST_BRANCH_TO_THUMB;
 
-                          num_a8_fixes++;
-                        }
-                    }
-                }
+			  num_a8_fixes++;
+			}
+		    }
+		}
 
-              i += insn_32bit ? 4 : 2;
-              last_was_32bit = insn_32bit;
+	      i += insn_32bit ? 4 : 2;
+	      last_was_32bit = insn_32bit;
 	      last_was_branch = is_32bit_branch;
-            }
-        }
+	    }
+	}
 
       if (elf_section_data (section)->this_hdr.contents == NULL)
-        free (contents);
+	free (contents);
     }
 
   *a8_fixes_p = a8_fixes;
@@ -4769,7 +4908,8 @@
 		      bfd *stub_bfd,
 		      struct bfd_link_info *info,
 		      bfd_signed_vma group_size,
-		      asection * (*add_stub_section) (const char *, asection *),
+		      asection * (*add_stub_section) (const char *, asection *,
+						      unsigned int),
 		      void (*layout_sections_again) (void))
 {
   bfd_size_type stub_group_size;
@@ -4786,9 +4926,9 @@
   if (htab->fix_cortex_a8)
     {
       a8_fixes = (struct a8_erratum_fix *)
-          bfd_zmalloc (sizeof (struct a8_erratum_fix) * a8_fix_table_size);
+	  bfd_zmalloc (sizeof (struct a8_erratum_fix) * a8_fix_table_size);
       a8_relocs = (struct a8_erratum_reloc *)
-          bfd_zmalloc (sizeof (struct a8_erratum_reloc) * a8_reloc_table_size);
+	  bfd_zmalloc (sizeof (struct a8_erratum_reloc) * a8_reloc_table_size);
     }
 
   /* Propagate mach to stub bfd, because it may not have been
@@ -4856,6 +4996,9 @@
 	  asection *section;
 	  Elf_Internal_Sym *local_syms = NULL;
 
+	  if (!is_arm_elf (input_bfd))
+	    continue;
+
 	  num_a8_relocs = 0;
 
 	  /* We'll need the symbol table in a second.  */
@@ -4920,13 +5063,13 @@
 			free (internal_relocs);
 		      goto error_ret_free_local;
 		    }
-		  
+
 		  hash = NULL;
 		  if (r_indx >= symtab_hdr->sh_info)
 		    hash = elf32_arm_hash_entry
 		      (elf_sym_hashes (input_bfd)
 		       [r_indx - symtab_hdr->sh_info]);
-		  
+
 		  /* Only look for stubs on branch instructions, or
 		     non-relaxed TLSCALL  */
 		  if ((r_type != (unsigned int) R_ARM_CALL)
@@ -4952,7 +5095,7 @@
 		  sym_value = 0;
 		  destination = 0;
 		  sym_name = NULL;
-		  
+
 		  if (r_type == (unsigned int) R_ARM_TLS_CALL
 		      || r_type == (unsigned int) R_ARM_THM_TLS_CALL)
 		    {
@@ -5127,99 +5270,99 @@
 			  goto error_ret_free_internal;
 			}
 
-                      stub_entry->target_value = sym_value;
-                      stub_entry->target_section = sym_sec;
-                      stub_entry->stub_type = stub_type;
-                      stub_entry->h = hash;
-                      stub_entry->branch_type = branch_type;
+		      stub_entry->target_value = sym_value;
+		      stub_entry->target_section = sym_sec;
+		      stub_entry->stub_type = stub_type;
+		      stub_entry->h = hash;
+		      stub_entry->branch_type = branch_type;
 
-                      if (sym_name == NULL)
-                	sym_name = "unnamed";
-                      stub_entry->output_name = (char *)
-                          bfd_alloc (htab->stub_bfd,
-                                     sizeof (THUMB2ARM_GLUE_ENTRY_NAME)
-                                     + strlen (sym_name));
-                      if (stub_entry->output_name == NULL)
-                	{
-                          free (stub_name);
-                          goto error_ret_free_internal;
-                	}
+		      if (sym_name == NULL)
+			sym_name = "unnamed";
+		      stub_entry->output_name = (char *)
+			  bfd_alloc (htab->stub_bfd,
+				     sizeof (THUMB2ARM_GLUE_ENTRY_NAME)
+				     + strlen (sym_name));
+		      if (stub_entry->output_name == NULL)
+			{
+			  free (stub_name);
+			  goto error_ret_free_internal;
+			}
 
-                      /* For historical reasons, use the existing names for
-                	 ARM-to-Thumb and Thumb-to-ARM stubs.  */
-                      if ((r_type == (unsigned int) R_ARM_THM_CALL
+		      /* For historical reasons, use the existing names for
+			 ARM-to-Thumb and Thumb-to-ARM stubs.  */
+		      if ((r_type == (unsigned int) R_ARM_THM_CALL
 			   || r_type == (unsigned int) R_ARM_THM_JUMP24)
 			  && branch_type == ST_BRANCH_TO_ARM)
-                	sprintf (stub_entry->output_name,
-                        	 THUMB2ARM_GLUE_ENTRY_NAME, sym_name);
-                      else if ((r_type == (unsigned int) R_ARM_CALL
+			sprintf (stub_entry->output_name,
+				 THUMB2ARM_GLUE_ENTRY_NAME, sym_name);
+		      else if ((r_type == (unsigned int) R_ARM_CALL
 			       || r_type == (unsigned int) R_ARM_JUMP24)
 			       && branch_type == ST_BRANCH_TO_THUMB)
-                	sprintf (stub_entry->output_name,
-                        	 ARM2THUMB_GLUE_ENTRY_NAME, sym_name);
-                      else
-                	sprintf (stub_entry->output_name, STUB_ENTRY_NAME,
-                        	 sym_name);
+			sprintf (stub_entry->output_name,
+				 ARM2THUMB_GLUE_ENTRY_NAME, sym_name);
+		      else
+			sprintf (stub_entry->output_name, STUB_ENTRY_NAME,
+				 sym_name);
 
-                      stub_changed = TRUE;
-                    }
-                  while (0);
+		      stub_changed = TRUE;
+		    }
+		  while (0);
 
-                  /* Look for relocations which might trigger Cortex-A8
-                     erratum.  */
-                  if (htab->fix_cortex_a8
-                      && (r_type == (unsigned int) R_ARM_THM_JUMP24
-                          || r_type == (unsigned int) R_ARM_THM_JUMP19
-                          || r_type == (unsigned int) R_ARM_THM_CALL
-                          || r_type == (unsigned int) R_ARM_THM_XPC22))
-                    {
-                      bfd_vma from = section->output_section->vma
-                                     + section->output_offset
-                                     + irela->r_offset;
+		  /* Look for relocations which might trigger Cortex-A8
+		     erratum.  */
+		  if (htab->fix_cortex_a8
+		      && (r_type == (unsigned int) R_ARM_THM_JUMP24
+			  || r_type == (unsigned int) R_ARM_THM_JUMP19
+			  || r_type == (unsigned int) R_ARM_THM_CALL
+			  || r_type == (unsigned int) R_ARM_THM_XPC22))
+		    {
+		      bfd_vma from = section->output_section->vma
+				     + section->output_offset
+				     + irela->r_offset;
 
-                      if ((from & 0xfff) == 0xffe)
-                        {
-                          /* Found a candidate.  Note we haven't checked the
-                             destination is within 4K here: if we do so (and
-                             don't create an entry in a8_relocs) we can't tell
-                             that a branch should have been relocated when
-                             scanning later.  */
-                          if (num_a8_relocs == a8_reloc_table_size)
-                            {
-                              a8_reloc_table_size *= 2;
-                              a8_relocs = (struct a8_erratum_reloc *)
-                                  bfd_realloc (a8_relocs,
-                                               sizeof (struct a8_erratum_reloc)
-                                               * a8_reloc_table_size);
-                            }
+		      if ((from & 0xfff) == 0xffe)
+			{
+			  /* Found a candidate.  Note we haven't checked the
+			     destination is within 4K here: if we do so (and
+			     don't create an entry in a8_relocs) we can't tell
+			     that a branch should have been relocated when
+			     scanning later.  */
+			  if (num_a8_relocs == a8_reloc_table_size)
+			    {
+			      a8_reloc_table_size *= 2;
+			      a8_relocs = (struct a8_erratum_reloc *)
+				  bfd_realloc (a8_relocs,
+					       sizeof (struct a8_erratum_reloc)
+					       * a8_reloc_table_size);
+			    }
 
-                          a8_relocs[num_a8_relocs].from = from;
-                          a8_relocs[num_a8_relocs].destination = destination;
-                          a8_relocs[num_a8_relocs].r_type = r_type;
-                          a8_relocs[num_a8_relocs].branch_type = branch_type;
-                          a8_relocs[num_a8_relocs].sym_name = sym_name;
-                          a8_relocs[num_a8_relocs].non_a8_stub = created_stub;
-                          a8_relocs[num_a8_relocs].hash = hash;
+			  a8_relocs[num_a8_relocs].from = from;
+			  a8_relocs[num_a8_relocs].destination = destination;
+			  a8_relocs[num_a8_relocs].r_type = r_type;
+			  a8_relocs[num_a8_relocs].branch_type = branch_type;
+			  a8_relocs[num_a8_relocs].sym_name = sym_name;
+			  a8_relocs[num_a8_relocs].non_a8_stub = created_stub;
+			  a8_relocs[num_a8_relocs].hash = hash;
 
-                          num_a8_relocs++;
-                        }
-                    }
+			  num_a8_relocs++;
+			}
+		    }
 		}
 
-              /* We're done with the internal relocs, free them.  */
-              if (elf_section_data (section)->relocs == NULL)
-                free (internal_relocs);
-            }
+	      /* We're done with the internal relocs, free them.  */
+	      if (elf_section_data (section)->relocs == NULL)
+		free (internal_relocs);
+	    }
 
-          if (htab->fix_cortex_a8)
+	  if (htab->fix_cortex_a8)
 	    {
-              /* Sort relocs which might apply to Cortex-A8 erratum.  */
-              qsort (a8_relocs, num_a8_relocs,
+	      /* Sort relocs which might apply to Cortex-A8 erratum.  */
+	      qsort (a8_relocs, num_a8_relocs,
 		     sizeof (struct a8_erratum_reloc),
-                     &a8_reloc_compare);
+		     &a8_reloc_compare);
 
-              /* Scan for branches which might trigger Cortex-A8 erratum.  */
-              if (cortex_a8_erratum_scan (input_bfd, info, &a8_fixes,
+	      /* Scan for branches which might trigger Cortex-A8 erratum.  */
+	      if (cortex_a8_erratum_scan (input_bfd, info, &a8_fixes,
 					  &num_a8_fixes, &a8_fix_table_size,
 					  a8_relocs, num_a8_relocs,
 					  prev_num_a8_fixes, &stub_changed)
@@ -5229,7 +5372,7 @@
 	}
 
       if (prev_num_a8_fixes != num_a8_fixes)
-        stub_changed = TRUE;
+	stub_changed = TRUE;
 
       if (!stub_changed)
 	break;
@@ -5251,18 +5394,18 @@
 
       /* Add Cortex-A8 erratum veneers to stub section sizes too.  */
       if (htab->fix_cortex_a8)
-        for (i = 0; i < num_a8_fixes; i++)
-          {
+	for (i = 0; i < num_a8_fixes; i++)
+	  {
 	    stub_sec = elf32_arm_create_or_find_stub_sec (NULL,
 			 a8_fixes[i].section, htab);
 
 	    if (stub_sec == NULL)
 	      goto error_ret_free_local;
 
-            stub_sec->size
-              += find_stub_size_and_template (a8_fixes[i].stub_type, NULL,
-                                              NULL);
-          }
+	    stub_sec->size
+	      += find_stub_size_and_template (a8_fixes[i].stub_type, NULL,
+					      NULL);
+	  }
 
 
       /* Ask the linker to do its stuff.  */
@@ -5273,47 +5416,47 @@
   if (htab->fix_cortex_a8)
     {
       for (i = 0; i < num_a8_fixes; i++)
-        {
-          struct elf32_arm_stub_hash_entry *stub_entry;
-          char *stub_name = a8_fixes[i].stub_name;
-          asection *section = a8_fixes[i].section;
-          unsigned int section_id = a8_fixes[i].section->id;
-          asection *link_sec = htab->stub_group[section_id].link_sec;
-          asection *stub_sec = htab->stub_group[section_id].stub_sec;
-          const insn_sequence *template_sequence;
-          int template_size, size = 0;
+	{
+	  struct elf32_arm_stub_hash_entry *stub_entry;
+	  char *stub_name = a8_fixes[i].stub_name;
+	  asection *section = a8_fixes[i].section;
+	  unsigned int section_id = a8_fixes[i].section->id;
+	  asection *link_sec = htab->stub_group[section_id].link_sec;
+	  asection *stub_sec = htab->stub_group[section_id].stub_sec;
+	  const insn_sequence *template_sequence;
+	  int template_size, size = 0;
 
-          stub_entry = arm_stub_hash_lookup (&htab->stub_hash_table, stub_name,
-                                             TRUE, FALSE);
-          if (stub_entry == NULL)
-            {
-              (*_bfd_error_handler) (_("%s: cannot create stub entry %s"),
-                                     section->owner,
-                                     stub_name);
-              return FALSE;
-            }
+	  stub_entry = arm_stub_hash_lookup (&htab->stub_hash_table, stub_name,
+					     TRUE, FALSE);
+	  if (stub_entry == NULL)
+	    {
+	      (*_bfd_error_handler) (_("%s: cannot create stub entry %s"),
+				     section->owner,
+				     stub_name);
+	      return FALSE;
+	    }
 
-          stub_entry->stub_sec = stub_sec;
-          stub_entry->stub_offset = 0;
-          stub_entry->id_sec = link_sec;
-          stub_entry->stub_type = a8_fixes[i].stub_type;
-          stub_entry->target_section = a8_fixes[i].section;
-          stub_entry->target_value = a8_fixes[i].offset;
-          stub_entry->target_addend = a8_fixes[i].addend;
-          stub_entry->orig_insn = a8_fixes[i].orig_insn;
+	  stub_entry->stub_sec = stub_sec;
+	  stub_entry->stub_offset = 0;
+	  stub_entry->id_sec = link_sec;
+	  stub_entry->stub_type = a8_fixes[i].stub_type;
+	  stub_entry->target_section = a8_fixes[i].section;
+	  stub_entry->target_value = a8_fixes[i].offset;
+	  stub_entry->target_addend = a8_fixes[i].addend;
+	  stub_entry->orig_insn = a8_fixes[i].orig_insn;
 	  stub_entry->branch_type = a8_fixes[i].branch_type;
 
-          size = find_stub_size_and_template (a8_fixes[i].stub_type,
-                                              &template_sequence,
-                                              &template_size);
+	  size = find_stub_size_and_template (a8_fixes[i].stub_type,
+					      &template_sequence,
+					      &template_size);
 
-          stub_entry->stub_size = size;
-          stub_entry->stub_template = template_sequence;
-          stub_entry->stub_template_size = template_size;
-        }
+	  stub_entry->stub_size = size;
+	  stub_entry->stub_template = template_sequence;
+	  stub_entry->stub_template_size = template_size;
+	}
 
       /* Stash the Cortex-A8 erratum fix array for use later in
-         elf32_arm_write_section().  */
+	 elf32_arm_write_section().  */
       htab->a8_erratum_fixes = a8_fixes;
       htab->num_a8_erratum_fixes = num_a8_fixes;
     }
@@ -5393,7 +5536,7 @@
     return NULL;
 
   tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen (name)
-                                  + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1);
+				  + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1);
 
   BFD_ASSERT (tmp_name);
 
@@ -5429,7 +5572,7 @@
     return NULL;
 
   tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen (name)
-                                  + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1);
+				  + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1);
 
   BFD_ASSERT (tmp_name);
 
@@ -5496,12 +5639,12 @@
      nop                                ldr  r6, __func_addr
      .arm                               mov  lr, pc
      b func                             bx   r6
-                                        .arm
-		 		    ;; back_to_thumb       
-                 		        ldmia r13! {r6, lr}
- 				        bx    lr           
-                                    __func_addr:
-                                        .word        func  */
+					.arm
+				    ;; back_to_thumb
+					ldmia r13! {r6, lr}
+					bx    lr
+				    __func_addr:
+					.word        func  */
 
 #define THUMB2ARM_GLUE_SIZE 8
 static const insn16 t2a1_bx_pc_insn = 0x4778;
@@ -5527,7 +5670,7 @@
       /* Do not include empty glue sections in the output.  */
       if (abfd != NULL)
 	{
-	  s = bfd_get_section_by_name (abfd, name);
+	  s = bfd_get_linker_section (abfd, name);
 	  if (s != NULL)
 	    s->flags |= SEC_EXCLUDE;
 	}
@@ -5536,7 +5679,7 @@
 
   BFD_ASSERT (abfd != NULL);
 
-  s = bfd_get_section_by_name (abfd, name);
+  s = bfd_get_linker_section (abfd, name);
   BFD_ASSERT (s != NULL);
 
   contents = (bfd_byte *) bfd_alloc (abfd, size);
@@ -5592,13 +5735,13 @@
   BFD_ASSERT (globals != NULL);
   BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
 
-  s = bfd_get_section_by_name
+  s = bfd_get_linker_section
     (globals->bfd_of_glue_owner, ARM2THUMB_GLUE_SECTION_NAME);
 
   BFD_ASSERT (s != NULL);
 
   tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen (name)
-                                  + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1);
+				  + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1);
 
   BFD_ASSERT (tmp_name);
 
@@ -5668,7 +5811,7 @@
   if (globals->bx_glue_offset[reg])
     return;
 
-  s = bfd_get_section_by_name
+  s = bfd_get_linker_section
     (globals->bfd_of_glue_owner, ARM_BX_GLUE_SECTION_NAME);
 
   BFD_ASSERT (s != NULL);
@@ -5689,8 +5832,8 @@
   bh = NULL;
   val = globals->bx_glue_size;
   _bfd_generic_link_add_one_symbol (link_info, globals->bfd_of_glue_owner,
-                                    tmp_name, BSF_FUNCTION | BSF_LOCAL, s, val,
-                                    NULL, TRUE, FALSE, &bh);
+				    tmp_name, BSF_FUNCTION | BSF_LOCAL, s, val,
+				    NULL, TRUE, FALSE, &bh);
 
   myh = (struct elf_link_hash_entry *) bh;
   myh->type = ELF_ST_INFO (STB_LOCAL, STT_FUNC);
@@ -5713,7 +5856,7 @@
   if (sec_data->map == NULL)
     {
       sec_data->map = (elf32_arm_section_map *)
-          bfd_malloc (sizeof (elf32_arm_section_map));
+	  bfd_malloc (sizeof (elf32_arm_section_map));
       sec_data->mapcount = 0;
       sec_data->mapsize = 1;
     }
@@ -5724,8 +5867,8 @@
     {
       sec_data->mapsize *= 2;
       sec_data->map = (elf32_arm_section_map *)
-          bfd_realloc_or_free (sec_data->map, sec_data->mapsize
-                               * sizeof (elf32_arm_section_map));
+	  bfd_realloc_or_free (sec_data->map, sec_data->mapsize
+			       * sizeof (elf32_arm_section_map));
     }
 
   if (sec_data->map)
@@ -5741,10 +5884,10 @@
 
 static bfd_vma
 record_vfp11_erratum_veneer (struct bfd_link_info *link_info,
-                             elf32_vfp11_erratum_list *branch,
-                             bfd *branch_bfd,
-                             asection *branch_sec,
-                             unsigned int offset)
+			     elf32_vfp11_erratum_list *branch,
+			     bfd *branch_bfd,
+			     asection *branch_sec,
+			     unsigned int offset)
 {
   asection *s;
   struct elf32_arm_link_hash_table *hash_table;
@@ -5759,7 +5902,7 @@
   BFD_ASSERT (hash_table != NULL);
   BFD_ASSERT (hash_table->bfd_of_glue_owner != NULL);
 
-  s = bfd_get_section_by_name
+  s = bfd_get_linker_section
     (hash_table->bfd_of_glue_owner, VFP11_ERRATUM_VENEER_SECTION_NAME);
 
   sec_data = elf32_arm_section_data (s);
@@ -5767,7 +5910,7 @@
   BFD_ASSERT (s != NULL);
 
   tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen
-                                  (VFP11_ERRATUM_VENEER_ENTRY_NAME) + 10);
+				  (VFP11_ERRATUM_VENEER_ENTRY_NAME) + 10);
 
   BFD_ASSERT (tmp_name);
 
@@ -5782,8 +5925,8 @@
   bh = NULL;
   val = hash_table->vfp11_erratum_glue_size;
   _bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner,
-                                    tmp_name, BSF_FUNCTION | BSF_LOCAL, s, val,
-                                    NULL, TRUE, FALSE, &bh);
+				    tmp_name, BSF_FUNCTION | BSF_LOCAL, s, val,
+				    NULL, TRUE, FALSE, &bh);
 
   myh = (struct elf_link_hash_entry *) bh;
   myh->type = ELF_ST_INFO (STB_LOCAL, STT_FUNC);
@@ -5830,20 +5973,20 @@
     {
       bh = NULL;
       /* FIXME: Creates an ARM symbol.  Thumb mode will need attention if it
-         ever requires this erratum fix.  */
+	 ever requires this erratum fix.  */
       _bfd_generic_link_add_one_symbol (link_info,
 					hash_table->bfd_of_glue_owner, "$a",
 					BSF_LOCAL, s, 0, NULL,
-                                        TRUE, FALSE, &bh);
+					TRUE, FALSE, &bh);
 
       myh = (struct elf_link_hash_entry *) bh;
       myh->type = ELF_ST_INFO (STB_LOCAL, STT_NOTYPE);
       myh->forced_local = 1;
 
       /* The elf32_arm_init_maps function only cares about symbols from input
-         BFDs.  We must make a note of this generated mapping symbol
-         ourselves so that code byteswapping works properly in
-         elf32_arm_write_section.  */
+	 BFDs.  We must make a note of this generated mapping symbol
+	 ourselves so that code byteswapping works properly in
+	 elf32_arm_write_section.  */
       elf32_arm_section_map_add (s, 'a', 0);
     }
 
@@ -5866,12 +6009,12 @@
 {
   asection * sec;
 
-  sec = bfd_get_section_by_name (abfd, name);
+  sec = bfd_get_linker_section (abfd, name);
   if (sec != NULL)
     /* Already made.  */
     return TRUE;
 
-  sec = bfd_make_section_with_flags (abfd, name, ARM_GLUE_SECTION_FLAGS);
+  sec = bfd_make_section_anyway_with_flags (abfd, name, ARM_GLUE_SECTION_FLAGS);
 
   if (sec == NULL
       || !bfd_set_section_alignment (abfd, sec, 2))
@@ -5936,7 +6079,7 @@
 {
   int cpu_arch;
 
-  cpu_arch = bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC, 
+  cpu_arch = bfd_elf_get_obj_attr_int (globals->obfd, OBJ_ATTR_PROC,
 				       Tag_CPU_arch);
 
   if (globals->fix_arm1176)
@@ -6076,8 +6219,8 @@
 	    {
 	    case R_ARM_PC24:
 	      /* This one is a call from arm code.  We need to look up
-	         the target of the call.  If it is a thumb target, we
-	         insert glue.  */
+		 the target of the call.  If it is a thumb target, we
+		 insert glue.  */
 	      if (h->target_internal == ST_BRANCH_TO_THUMB)
 		record_arm_to_thumb_glue (link_info, h);
 	      break;
@@ -6149,15 +6292,15 @@
       const char *name;
 
       if (sec != NULL
-          && ELF_ST_BIND (isym->st_info) == STB_LOCAL)
-        {
-          name = bfd_elf_string_from_elf_section (abfd,
-            hdr->sh_link, isym->st_name);
+	  && ELF_ST_BIND (isym->st_info) == STB_LOCAL)
+	{
+	  name = bfd_elf_string_from_elf_section (abfd,
+	    hdr->sh_link, isym->st_name);
 
-          if (bfd_is_arm_special_symbol_name (name,
+	  if (bfd_is_arm_special_symbol_name (name,
 					      BFD_ARM_SPECIAL_SYM_TYPE_MAP))
-            elf32_arm_section_map_add (sec, name[1], isym->st_value);
-        }
+	    elf32_arm_section_map_add (sec, name[1], isym->st_value);
+	}
     }
 }
 
@@ -6199,17 +6342,17 @@
   if (out_attr[Tag_CPU_arch].i >= TAG_CPU_ARCH_V7)
     {
       switch (globals->vfp11_fix)
-        {
-        case BFD_ARM_VFP11_FIX_DEFAULT:
-        case BFD_ARM_VFP11_FIX_NONE:
-          globals->vfp11_fix = BFD_ARM_VFP11_FIX_NONE;
-          break;
+	{
+	case BFD_ARM_VFP11_FIX_DEFAULT:
+	case BFD_ARM_VFP11_FIX_NONE:
+	  globals->vfp11_fix = BFD_ARM_VFP11_FIX_NONE;
+	  break;
 
-        default:
-          /* Give a warning, but do as the user requests anyway.  */
-          (*_bfd_error_handler) (_("%B: warning: selected VFP11 erratum "
-            "workaround is not necessary for target architecture"), obfd);
-        }
+	default:
+	  /* Give a warning, but do as the user requests anyway.  */
+	  (*_bfd_error_handler) (_("%B: warning: selected VFP11 erratum "
+	    "workaround is not necessary for target architecture"), obfd);
+	}
     }
   else if (globals->vfp11_fix == BFD_ARM_VFP11_FIX_DEFAULT)
     /* For earlier architectures, we might need the workaround, but do not
@@ -6241,7 +6384,7 @@
 
 static unsigned int
 bfd_arm_vfp11_regno (unsigned int insn, bfd_boolean is_double, unsigned int rx,
-                     unsigned int x)
+		     unsigned int x)
 {
   if (is_double)
     return (((insn >> rx) & 0xf) | (((insn >> x) & 1) << 4)) + 32;
@@ -6273,15 +6416,15 @@
       unsigned int reg = regs[i];
 
       if (reg < 32 && (wmask & (1 << reg)) != 0)
-        return TRUE;
+	return TRUE;
 
       reg -= 32;
 
       if (reg >= 16)
-        continue;
+	continue;
 
       if ((wmask & (3 << (reg * 2))) != 0)
-        return TRUE;
+	return TRUE;
     }
 
   return FALSE;
@@ -6297,7 +6440,7 @@
 
 static enum bfd_arm_vfp11_pipe
 bfd_arm_vfp11_insn_decode (unsigned int insn, unsigned int *destmask, int *regs,
-                           int *numregs)
+			   int *numregs)
 {
   enum bfd_arm_vfp11_pipe vpipe = VFP11_BAD;
   bfd_boolean is_double = ((insn & 0xf00) == 0xb00) ? 1 : 0;
@@ -6309,96 +6452,96 @@
       unsigned int fm = bfd_arm_vfp11_regno (insn, is_double, 0, 5);
 
       pqrs = ((insn & 0x00800000) >> 20)
-           | ((insn & 0x00300000) >> 19)
-           | ((insn & 0x00000040) >> 6);
+	   | ((insn & 0x00300000) >> 19)
+	   | ((insn & 0x00000040) >> 6);
 
       switch (pqrs)
-        {
-        case 0: /* fmac[sd].  */
-        case 1: /* fnmac[sd].  */
-        case 2: /* fmsc[sd].  */
-        case 3: /* fnmsc[sd].  */
-          vpipe = VFP11_FMAC;
-          bfd_arm_vfp11_write_mask (destmask, fd);
-          regs[0] = fd;
-          regs[1] = bfd_arm_vfp11_regno (insn, is_double, 16, 7);  /* Fn.  */
-          regs[2] = fm;
-          *numregs = 3;
-          break;
+	{
+	case 0: /* fmac[sd].  */
+	case 1: /* fnmac[sd].  */
+	case 2: /* fmsc[sd].  */
+	case 3: /* fnmsc[sd].  */
+	  vpipe = VFP11_FMAC;
+	  bfd_arm_vfp11_write_mask (destmask, fd);
+	  regs[0] = fd;
+	  regs[1] = bfd_arm_vfp11_regno (insn, is_double, 16, 7);  /* Fn.  */
+	  regs[2] = fm;
+	  *numregs = 3;
+	  break;
 
-        case 4: /* fmul[sd].  */
-        case 5: /* fnmul[sd].  */
-        case 6: /* fadd[sd].  */
-        case 7: /* fsub[sd].  */
-          vpipe = VFP11_FMAC;
-          goto vfp_binop;
+	case 4: /* fmul[sd].  */
+	case 5: /* fnmul[sd].  */
+	case 6: /* fadd[sd].  */
+	case 7: /* fsub[sd].  */
+	  vpipe = VFP11_FMAC;
+	  goto vfp_binop;
 
-        case 8: /* fdiv[sd].  */
-          vpipe = VFP11_DS;
-          vfp_binop:
-          bfd_arm_vfp11_write_mask (destmask, fd);
-          regs[0] = bfd_arm_vfp11_regno (insn, is_double, 16, 7);   /* Fn.  */
-          regs[1] = fm;
-          *numregs = 2;
-          break;
+	case 8: /* fdiv[sd].  */
+	  vpipe = VFP11_DS;
+	  vfp_binop:
+	  bfd_arm_vfp11_write_mask (destmask, fd);
+	  regs[0] = bfd_arm_vfp11_regno (insn, is_double, 16, 7);   /* Fn.  */
+	  regs[1] = fm;
+	  *numregs = 2;
+	  break;
 
-        case 15: /* extended opcode.  */
-          {
-            unsigned int extn = ((insn >> 15) & 0x1e)
-                              | ((insn >> 7) & 1);
+	case 15: /* extended opcode.  */
+	  {
+	    unsigned int extn = ((insn >> 15) & 0x1e)
+			      | ((insn >> 7) & 1);
 
-            switch (extn)
-              {
-              case 0: /* fcpy[sd].  */
-              case 1: /* fabs[sd].  */
-              case 2: /* fneg[sd].  */
-              case 8: /* fcmp[sd].  */
-              case 9: /* fcmpe[sd].  */
-              case 10: /* fcmpz[sd].  */
-              case 11: /* fcmpez[sd].  */
-              case 16: /* fuito[sd].  */
-              case 17: /* fsito[sd].  */
-              case 24: /* ftoui[sd].  */
-              case 25: /* ftouiz[sd].  */
-              case 26: /* ftosi[sd].  */
-              case 27: /* ftosiz[sd].  */
-                /* These instructions will not bounce due to underflow.  */
-                *numregs = 0;
-                vpipe = VFP11_FMAC;
-                break;
+	    switch (extn)
+	      {
+	      case 0: /* fcpy[sd].  */
+	      case 1: /* fabs[sd].  */
+	      case 2: /* fneg[sd].  */
+	      case 8: /* fcmp[sd].  */
+	      case 9: /* fcmpe[sd].  */
+	      case 10: /* fcmpz[sd].  */
+	      case 11: /* fcmpez[sd].  */
+	      case 16: /* fuito[sd].  */
+	      case 17: /* fsito[sd].  */
+	      case 24: /* ftoui[sd].  */
+	      case 25: /* ftouiz[sd].  */
+	      case 26: /* ftosi[sd].  */
+	      case 27: /* ftosiz[sd].  */
+		/* These instructions will not bounce due to underflow.  */
+		*numregs = 0;
+		vpipe = VFP11_FMAC;
+		break;
 
-              case 3: /* fsqrt[sd].  */
-                /* fsqrt cannot underflow, but it can (perhaps) overwrite
-                   registers to cause the erratum in previous instructions.  */
-                bfd_arm_vfp11_write_mask (destmask, fd);
-                vpipe = VFP11_DS;
-                break;
+	      case 3: /* fsqrt[sd].  */
+		/* fsqrt cannot underflow, but it can (perhaps) overwrite
+		   registers to cause the erratum in previous instructions.  */
+		bfd_arm_vfp11_write_mask (destmask, fd);
+		vpipe = VFP11_DS;
+		break;
 
-              case 15: /* fcvt{ds,sd}.  */
-                {
-                  int rnum = 0;
+	      case 15: /* fcvt{ds,sd}.  */
+		{
+		  int rnum = 0;
 
-                  bfd_arm_vfp11_write_mask (destmask, fd);
+		  bfd_arm_vfp11_write_mask (destmask, fd);
 
 		  /* Only FCVTSD can underflow.  */
-                  if ((insn & 0x100) != 0)
-                    regs[rnum++] = fm;
+		  if ((insn & 0x100) != 0)
+		    regs[rnum++] = fm;
 
-                  *numregs = rnum;
+		  *numregs = rnum;
 
-                  vpipe = VFP11_FMAC;
-                }
-                break;
+		  vpipe = VFP11_FMAC;
+		}
+		break;
 
-              default:
-                return VFP11_BAD;
-              }
-          }
-          break;
+	      default:
+		return VFP11_BAD;
+	      }
+	  }
+	  break;
 
-        default:
-          return VFP11_BAD;
-        }
+	default:
+	  return VFP11_BAD;
+	}
     }
   /* Two-register transfer.  */
   else if ((insn & 0x0fe00ed0) == 0x0c400a10)
@@ -6407,13 +6550,13 @@
 
       if ((insn & 0x100000) == 0)
 	{
-          if (is_double)
-            bfd_arm_vfp11_write_mask (destmask, fm);
-          else
-            {
-              bfd_arm_vfp11_write_mask (destmask, fm);
-              bfd_arm_vfp11_write_mask (destmask, fm + 1);
-            }
+	  if (is_double)
+	    bfd_arm_vfp11_write_mask (destmask, fm);
+	  else
+	    {
+	      bfd_arm_vfp11_write_mask (destmask, fm);
+	      bfd_arm_vfp11_write_mask (destmask, fm + 1);
+	    }
 	}
 
       vpipe = VFP11_LS;
@@ -6424,32 +6567,32 @@
       unsigned int puw = ((insn >> 21) & 0x1) | (((insn >> 23) & 3) << 1);
 
       switch (puw)
-        {
-        case 0: /* Two-reg transfer.  We should catch these above.  */
-          abort ();
+	{
+	case 0: /* Two-reg transfer.  We should catch these above.  */
+	  abort ();
 
-        case 2: /* fldm[sdx].  */
-        case 3:
-        case 5:
-          {
-            unsigned int i, offset = insn & 0xff;
+	case 2: /* fldm[sdx].  */
+	case 3:
+	case 5:
+	  {
+	    unsigned int i, offset = insn & 0xff;
 
-            if (is_double)
-              offset >>= 1;
+	    if (is_double)
+	      offset >>= 1;
 
-            for (i = fd; i < fd + offset; i++)
-              bfd_arm_vfp11_write_mask (destmask, i);
-          }
-          break;
+	    for (i = fd; i < fd + offset; i++)
+	      bfd_arm_vfp11_write_mask (destmask, i);
+	  }
+	  break;
 
-        case 4: /* fld[sd].  */
-        case 6:
-          bfd_arm_vfp11_write_mask (destmask, fd);
-          break;
+	case 4: /* fld[sd].  */
+	case 6:
+	  bfd_arm_vfp11_write_mask (destmask, fd);
+	  break;
 
-        default:
-          return VFP11_BAD;
-        }
+	default:
+	  return VFP11_BAD;
+	}
 
       vpipe = VFP11_LS;
     }
@@ -6460,18 +6603,18 @@
       unsigned int fn = bfd_arm_vfp11_regno (insn, is_double, 16, 7);
 
       switch (opcode)
-        {
-        case 0: /* fmsr/fmdlr.  */
-        case 1: /* fmdhr.  */
-          /* Mark fmdhr and fmdlr as writing to the whole of the DP
-             destination register.  I don't know if this is exactly right,
-             but it is the conservative choice.  */
-          bfd_arm_vfp11_write_mask (destmask, fn);
-          break;
+	{
+	case 0: /* fmsr/fmdlr.  */
+	case 1: /* fmdhr.  */
+	  /* Mark fmdhr and fmdlr as writing to the whole of the DP
+	     destination register.  I don't know if this is exactly right,
+	     but it is the conservative choice.  */
+	  bfd_arm_vfp11_write_mask (destmask, fn);
+	  break;
 
-        case 7: /* fmxr.  */
-          break;
-        }
+	case 7: /* fmxr.  */
+	  break;
+	}
 
       vpipe = VFP11_LS;
     }
@@ -6505,23 +6648,23 @@
      The states transition as follows:
 
        0 -> 1 (vector) or 0 -> 2 (scalar)
-           A VFP FMAC-pipeline instruction has been seen. Fill
-           regs[0]..regs[numregs-1] with its input operands. Remember this
-           instruction in 'first_fmac'.
+	   A VFP FMAC-pipeline instruction has been seen. Fill
+	   regs[0]..regs[numregs-1] with its input operands. Remember this
+	   instruction in 'first_fmac'.
 
        1 -> 2
-           Any instruction, except for a VFP instruction which overwrites
-           regs[*].
+	   Any instruction, except for a VFP instruction which overwrites
+	   regs[*].
 
        1 -> 3 [ -> 0 ]  or
        2 -> 3 [ -> 0 ]
-           A VFP instruction has been seen which overwrites any of regs[*].
-           We must make a veneer!  Reset state to 0 before examining next
-           instruction.
+	   A VFP instruction has been seen which overwrites any of regs[*].
+	   We must make a veneer!  Reset state to 0 before examining next
+	   instruction.
 
        2 -> 0
-           If we fail to match anything in state 2, reset to state 0 and reset
-           the instruction pointer to the instruction after 'first_fmac'.
+	   If we fail to match anything in state 2, reset to state 0 and reset
+	   the instruction pointer to the instruction after 'first_fmac'.
 
      If the VFP11 vector mode is in use, there must be at least two unrelated
      instructions between anti-dependent VFP11 instructions to properly avoid
@@ -6552,19 +6695,19 @@
       struct _arm_elf_section_data *sec_data;
 
       /* If we don't have executable progbits, we're not interested in this
-         section.  Also skip if section is to be excluded.  */
+	 section.  Also skip if section is to be excluded.  */
       if (elf_section_type (sec) != SHT_PROGBITS
-          || (elf_section_flags (sec) & SHF_EXECINSTR) == 0
-          || (sec->flags & SEC_EXCLUDE) != 0
-	  || sec->sec_info_type == ELF_INFO_TYPE_JUST_SYMS
+	  || (elf_section_flags (sec) & SHF_EXECINSTR) == 0
+	  || (sec->flags & SEC_EXCLUDE) != 0
+	  || sec->sec_info_type == SEC_INFO_TYPE_JUST_SYMS
 	  || sec->output_section == bfd_abs_section_ptr
-          || strcmp (sec->name, VFP11_ERRATUM_VENEER_SECTION_NAME) == 0)
-        continue;
+	  || strcmp (sec->name, VFP11_ERRATUM_VENEER_SECTION_NAME) == 0)
+	continue;
 
       sec_data = elf32_arm_section_data (sec);
 
       if (sec_data->mapcount == 0)
-        continue;
+	continue;
 
       if (elf_section_data (sec)->this_hdr.contents != NULL)
 	contents = elf_section_data (sec)->this_hdr.contents;
@@ -6575,122 +6718,122 @@
 	     elf32_arm_compare_mapping);
 
       for (span = 0; span < sec_data->mapcount; span++)
-        {
-          unsigned int span_start = sec_data->map[span].vma;
-          unsigned int span_end = (span == sec_data->mapcount - 1)
+	{
+	  unsigned int span_start = sec_data->map[span].vma;
+	  unsigned int span_end = (span == sec_data->mapcount - 1)
 				  ? sec->size : sec_data->map[span + 1].vma;
-          char span_type = sec_data->map[span].type;
+	  char span_type = sec_data->map[span].type;
 
-          /* FIXME: Only ARM mode is supported at present.  We may need to
-             support Thumb-2 mode also at some point.  */
-          if (span_type != 'a')
-            continue;
+	  /* FIXME: Only ARM mode is supported at present.  We may need to
+	     support Thumb-2 mode also at some point.  */
+	  if (span_type != 'a')
+	    continue;
 
-          for (i = span_start; i < span_end;)
-            {
-              unsigned int next_i = i + 4;
-              unsigned int insn = bfd_big_endian (abfd)
-                ? (contents[i] << 24)
-                  | (contents[i + 1] << 16)
-                  | (contents[i + 2] << 8)
-                  | contents[i + 3]
-                : (contents[i + 3] << 24)
-                  | (contents[i + 2] << 16)
-                  | (contents[i + 1] << 8)
-                  | contents[i];
-              unsigned int writemask = 0;
-              enum bfd_arm_vfp11_pipe vpipe;
+	  for (i = span_start; i < span_end;)
+	    {
+	      unsigned int next_i = i + 4;
+	      unsigned int insn = bfd_big_endian (abfd)
+		? (contents[i] << 24)
+		  | (contents[i + 1] << 16)
+		  | (contents[i + 2] << 8)
+		  | contents[i + 3]
+		: (contents[i + 3] << 24)
+		  | (contents[i + 2] << 16)
+		  | (contents[i + 1] << 8)
+		  | contents[i];
+	      unsigned int writemask = 0;
+	      enum bfd_arm_vfp11_pipe vpipe;
 
-              switch (state)
-                {
-                case 0:
-                  vpipe = bfd_arm_vfp11_insn_decode (insn, &writemask, regs,
-                                                    &numregs);
-                  /* I'm assuming the VFP11 erratum can trigger with denorm
-                     operands on either the FMAC or the DS pipeline. This might
-                     lead to slightly overenthusiastic veneer insertion.  */
-                  if (vpipe == VFP11_FMAC || vpipe == VFP11_DS)
-                    {
-                      state = use_vector ? 1 : 2;
-                      first_fmac = i;
-                      veneer_of_insn = insn;
-                    }
-                  break;
+	      switch (state)
+		{
+		case 0:
+		  vpipe = bfd_arm_vfp11_insn_decode (insn, &writemask, regs,
+						    &numregs);
+		  /* I'm assuming the VFP11 erratum can trigger with denorm
+		     operands on either the FMAC or the DS pipeline. This might
+		     lead to slightly overenthusiastic veneer insertion.  */
+		  if (vpipe == VFP11_FMAC || vpipe == VFP11_DS)
+		    {
+		      state = use_vector ? 1 : 2;
+		      first_fmac = i;
+		      veneer_of_insn = insn;
+		    }
+		  break;
 
-                case 1:
-                  {
-                    int other_regs[3], other_numregs;
-                    vpipe = bfd_arm_vfp11_insn_decode (insn, &writemask,
+		case 1:
+		  {
+		    int other_regs[3], other_numregs;
+		    vpipe = bfd_arm_vfp11_insn_decode (insn, &writemask,
 						      other_regs,
-                                                      &other_numregs);
-                    if (vpipe != VFP11_BAD
-                        && bfd_arm_vfp11_antidependency (writemask, regs,
+						      &other_numregs);
+		    if (vpipe != VFP11_BAD
+			&& bfd_arm_vfp11_antidependency (writemask, regs,
 							 numregs))
-                      state = 3;
-                    else
-                      state = 2;
-                  }
-                  break;
+		      state = 3;
+		    else
+		      state = 2;
+		  }
+		  break;
 
-                case 2:
-                  {
-                    int other_regs[3], other_numregs;
-                    vpipe = bfd_arm_vfp11_insn_decode (insn, &writemask,
+		case 2:
+		  {
+		    int other_regs[3], other_numregs;
+		    vpipe = bfd_arm_vfp11_insn_decode (insn, &writemask,
 						      other_regs,
-                                                      &other_numregs);
-                    if (vpipe != VFP11_BAD
-                        && bfd_arm_vfp11_antidependency (writemask, regs,
+						      &other_numregs);
+		    if (vpipe != VFP11_BAD
+			&& bfd_arm_vfp11_antidependency (writemask, regs,
 							 numregs))
-                      state = 3;
-                    else
-                      {
-                        state = 0;
-                        next_i = first_fmac + 4;
-                      }
-                  }
-                  break;
+		      state = 3;
+		    else
+		      {
+			state = 0;
+			next_i = first_fmac + 4;
+		      }
+		  }
+		  break;
 
-                case 3:
-                  abort ();  /* Should be unreachable.  */
-                }
+		case 3:
+		  abort ();  /* Should be unreachable.  */
+		}
 
-              if (state == 3)
-                {
-                  elf32_vfp11_erratum_list *newerr =(elf32_vfp11_erratum_list *)
-                      bfd_zmalloc (sizeof (elf32_vfp11_erratum_list));
+	      if (state == 3)
+		{
+		  elf32_vfp11_erratum_list *newerr =(elf32_vfp11_erratum_list *)
+		      bfd_zmalloc (sizeof (elf32_vfp11_erratum_list));
 
-                  elf32_arm_section_data (sec)->erratumcount += 1;
+		  elf32_arm_section_data (sec)->erratumcount += 1;
 
-                  newerr->u.b.vfp_insn = veneer_of_insn;
+		  newerr->u.b.vfp_insn = veneer_of_insn;
 
-                  switch (span_type)
-                    {
-                    case 'a':
-                      newerr->type = VFP11_ERRATUM_BRANCH_TO_ARM_VENEER;
-                      break;
+		  switch (span_type)
+		    {
+		    case 'a':
+		      newerr->type = VFP11_ERRATUM_BRANCH_TO_ARM_VENEER;
+		      break;
 
-                    default:
-                      abort ();
-                    }
+		    default:
+		      abort ();
+		    }
 
-                  record_vfp11_erratum_veneer (link_info, newerr, abfd, sec,
+		  record_vfp11_erratum_veneer (link_info, newerr, abfd, sec,
 					       first_fmac);
 
-                  newerr->vma = -1;
+		  newerr->vma = -1;
 
-                  newerr->next = sec_data->erratumlist;
-                  sec_data->erratumlist = newerr;
+		  newerr->next = sec_data->erratumlist;
+		  sec_data->erratumlist = newerr;
 
-                  state = 0;
-                }
+		  state = 0;
+		}
 
-              i = next_i;
-            }
-        }
+	      i = next_i;
+	    }
+	}
 
       if (contents != NULL
-          && elf_section_data (sec)->this_hdr.contents != contents)
-        free (contents);
+	  && elf_section_data (sec)->this_hdr.contents != contents)
+	free (contents);
       contents = NULL;
     }
 
@@ -6727,7 +6870,7 @@
     return;
 
   tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen
-                                  (VFP11_ERRATUM_VENEER_ENTRY_NAME) + 10);
+				  (VFP11_ERRATUM_VENEER_ENTRY_NAME) + 10);
 
   for (sec = abfd->sections; sec != NULL; sec = sec->next)
     {
@@ -6735,56 +6878,56 @@
       elf32_vfp11_erratum_list *errnode = sec_data->erratumlist;
 
       for (; errnode != NULL; errnode = errnode->next)
-        {
-          struct elf_link_hash_entry *myh;
-          bfd_vma vma;
+	{
+	  struct elf_link_hash_entry *myh;
+	  bfd_vma vma;
 
-          switch (errnode->type)
-            {
-            case VFP11_ERRATUM_BRANCH_TO_ARM_VENEER:
-            case VFP11_ERRATUM_BRANCH_TO_THUMB_VENEER:
-              /* Find veneer symbol.  */
-              sprintf (tmp_name, VFP11_ERRATUM_VENEER_ENTRY_NAME,
+	  switch (errnode->type)
+	    {
+	    case VFP11_ERRATUM_BRANCH_TO_ARM_VENEER:
+	    case VFP11_ERRATUM_BRANCH_TO_THUMB_VENEER:
+	      /* Find veneer symbol.  */
+	      sprintf (tmp_name, VFP11_ERRATUM_VENEER_ENTRY_NAME,
 		       errnode->u.b.veneer->u.v.id);
 
-              myh = elf_link_hash_lookup
-                (&(globals)->root, tmp_name, FALSE, FALSE, TRUE);
+	      myh = elf_link_hash_lookup
+		(&(globals)->root, tmp_name, FALSE, FALSE, TRUE);
 
-              if (myh == NULL)
-                (*_bfd_error_handler) (_("%B: unable to find VFP11 veneer "
-                			 "`%s'"), abfd, tmp_name);
-
-              vma = myh->root.u.def.section->output_section->vma
-                    + myh->root.u.def.section->output_offset
-                    + myh->root.u.def.value;
-
-              errnode->u.b.veneer->vma = vma;
-              break;
-
-	    case VFP11_ERRATUM_ARM_VENEER:
-            case VFP11_ERRATUM_THUMB_VENEER:
-              /* Find return location.  */
-              sprintf (tmp_name, VFP11_ERRATUM_VENEER_ENTRY_NAME "_r",
-                       errnode->u.v.id);
-
-              myh = elf_link_hash_lookup
-                (&(globals)->root, tmp_name, FALSE, FALSE, TRUE);
-
-              if (myh == NULL)
-                (*_bfd_error_handler) (_("%B: unable to find VFP11 veneer "
+	      if (myh == NULL)
+		(*_bfd_error_handler) (_("%B: unable to find VFP11 veneer "
 					 "`%s'"), abfd, tmp_name);
 
-              vma = myh->root.u.def.section->output_section->vma
-                    + myh->root.u.def.section->output_offset
-                    + myh->root.u.def.value;
+	      vma = myh->root.u.def.section->output_section->vma
+		    + myh->root.u.def.section->output_offset
+		    + myh->root.u.def.value;
 
-              errnode->u.v.branch->vma = vma;
-              break;
+	      errnode->u.b.veneer->vma = vma;
+	      break;
 
-            default:
-              abort ();
-            }
-        }
+	    case VFP11_ERRATUM_ARM_VENEER:
+	    case VFP11_ERRATUM_THUMB_VENEER:
+	      /* Find return location.  */
+	      sprintf (tmp_name, VFP11_ERRATUM_VENEER_ENTRY_NAME "_r",
+		       errnode->u.v.id);
+
+	      myh = elf_link_hash_lookup
+		(&(globals)->root, tmp_name, FALSE, FALSE, TRUE);
+
+	      if (myh == NULL)
+		(*_bfd_error_handler) (_("%B: unable to find VFP11 veneer "
+					 "`%s'"), abfd, tmp_name);
+
+	      vma = myh->root.u.def.section->output_section->vma
+		    + myh->root.u.def.section->output_offset
+		    + myh->root.u.def.value;
+
+	      errnode->u.v.branch->vma = vma;
+	      break;
+
+	    default:
+	      abort ();
+	    }
+	}
     }
 
   free (tmp_name);
@@ -6798,9 +6941,9 @@
 				 struct bfd_link_info *link_info,
 				 int target1_is_rel,
 				 char * target2_type,
-                                 int fix_v4bx,
+				 int fix_v4bx,
 				 int use_blx,
-                                 bfd_arm_vfp11_fix vfp11_fix,
+				 bfd_arm_vfp11_fix vfp11_fix,
 				 int no_enum_warn, int no_wchar_warn,
 				 int pic_veneer, int fix_cortex_a8,
 				 int fix_arm1176)
@@ -6891,8 +7034,8 @@
 
   my_offset = myh->root.u.def.value;
 
-  s = bfd_get_section_by_name (globals->bfd_of_glue_owner,
-			       THUMB2ARM_GLUE_SECTION_NAME);
+  s = bfd_get_linker_section (globals->bfd_of_glue_owner,
+			      THUMB2ARM_GLUE_SECTION_NAME);
 
   BFD_ASSERT (s != NULL);
   BFD_ASSERT (s->contents != NULL);
@@ -6906,7 +7049,7 @@
 	{
 	  (*_bfd_error_handler)
 	    (_("%B(%s): warning: interworking not enabled.\n"
-	       "  first occurrence: %B: thumb call to arm"),
+	       "  first occurrence: %B: Thumb call to ARM"),
 	     sym_sec->owner, input_bfd, name);
 
 	  return FALSE;
@@ -7081,8 +7224,8 @@
   BFD_ASSERT (globals != NULL);
   BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
 
-  s = bfd_get_section_by_name (globals->bfd_of_glue_owner,
-			       ARM2THUMB_GLUE_SECTION_NAME);
+  s = bfd_get_linker_section (globals->bfd_of_glue_owner,
+			      ARM2THUMB_GLUE_SECTION_NAME);
   BFD_ASSERT (s != NULL);
   BFD_ASSERT (s->contents != NULL);
   BFD_ASSERT (s->output_section != NULL);
@@ -7135,8 +7278,8 @@
   BFD_ASSERT (globals != NULL);
   BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
 
-  s = bfd_get_section_by_name (globals->bfd_of_glue_owner,
-			       ARM2THUMB_GLUE_SECTION_NAME);
+  s = bfd_get_linker_section (globals->bfd_of_glue_owner,
+			      ARM2THUMB_GLUE_SECTION_NAME);
   BFD_ASSERT (s != NULL);
   BFD_ASSERT (s->contents != NULL);
   BFD_ASSERT (s->output_section != NULL);
@@ -7170,8 +7313,8 @@
   BFD_ASSERT (globals != NULL);
   BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
 
-  s = bfd_get_section_by_name (globals->bfd_of_glue_owner,
-			       ARM_BX_GLUE_SECTION_NAME);
+  s = bfd_get_linker_section (globals->bfd_of_glue_owner,
+			      ARM_BX_GLUE_SECTION_NAME);
   BFD_ASSERT (s != NULL);
   BFD_ASSERT (s->contents != NULL);
   BFD_ASSERT (s->output_section != NULL);
@@ -7295,6 +7438,10 @@
       splt = htab->root.iplt;
       sgotplt = htab->root.igotplt;
 
+      /* NaCl uses a special first entry in .iplt too.  */
+      if (htab->nacl_p && splt->size == 0)
+	splt->size += htab->plt_header_size;
+
       /* Allocate room for an R_ARM_IRELATIVE relocation in .rel.iplt.  */
       elf32_arm_allocate_irelocs (info, htab->root.irelplt, 1);
     }
@@ -7327,6 +7474,18 @@
     }
 }
 
+static bfd_vma
+arm_movw_immediate (bfd_vma value)
+{
+  return (value & 0x00000fff) | ((value & 0x0000f000) << 4);
+}
+
+static bfd_vma
+arm_movt_immediate (bfd_vma value)
+{
+  return ((value & 0x0fff0000) >> 16) | ((value & 0xf0000000) >> 12);
+}
+
 /* Fill in a PLT entry and its associated GOT slot.  If DYNINDX == -1,
    the entry lives in .iplt and resolves to (*SYM_VALUE)().
    Otherwise, DYNINDX is the index of the symbol in the dynamic
@@ -7487,6 +7646,45 @@
 	  rel.r_addend = 0;
 	  SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc);
 	}
+      else if (htab->nacl_p)
+	{
+	  /* Calculate the displacement between the PLT slot and the
+	     common tail that's part of the special initial PLT slot.  */
+	  int32_t tail_displacement
+	    = ((splt->output_section->vma + splt->output_offset
+		+ ARM_NACL_PLT_TAIL_OFFSET)
+	       - (plt_address + htab->plt_entry_size + 4));
+	  BFD_ASSERT ((tail_displacement & 3) == 0);
+	  tail_displacement >>= 2;
+
+	  BFD_ASSERT ((tail_displacement & 0xff000000) == 0
+		      || (-tail_displacement & 0xff000000) == 0);
+
+	  /* Calculate the displacement between the PLT slot and the entry
+	     in the GOT.  The offset accounts for the value produced by
+	     adding to pc in the penultimate instruction of the PLT stub.  */
+	  got_displacement = (got_address
+			      - (plt_address + htab->plt_entry_size));
+
+	  /* NaCl does not support interworking at all.  */
+	  BFD_ASSERT (!elf32_arm_plt_needs_thumb_stub_p (info, arm_plt));
+
+	  put_arm_insn (htab, output_bfd,
+			elf32_arm_nacl_plt_entry[0]
+			| arm_movw_immediate (got_displacement),
+			ptr + 0);
+	  put_arm_insn (htab, output_bfd,
+			elf32_arm_nacl_plt_entry[1]
+			| arm_movt_immediate (got_displacement),
+			ptr + 4);
+	  put_arm_insn (htab, output_bfd,
+			elf32_arm_nacl_plt_entry[2],
+			ptr + 8);
+	  put_arm_insn (htab, output_bfd,
+			elf32_arm_nacl_plt_entry[3]
+			| (tail_displacement & 0x00ffffff),
+			ptr + 12);
+	}
       else
 	{
 	  /* Calculate the displacement between the PLT slot and the
@@ -7545,8 +7743,13 @@
 		  sgot->contents + got_offset);
     }
 
-  loc = srel->contents + plt_index * RELOC_SIZE (htab);
-  SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc);
+  if (dynindx == -1)
+    elf32_arm_add_dynreloc (output_bfd, info, srel, &rel);
+  else
+    {
+      loc = srel->contents + plt_index * RELOC_SIZE (htab);
+      SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc);
+    }
 }
 
 /* Some relocations map to different relocations depending on the
@@ -7627,18 +7830,18 @@
    the pre-relaxed code.  It would be nice if the relocs were updated
    to match the optimization.   */
 
-static bfd_reloc_status_type 
+static bfd_reloc_status_type
 elf32_arm_tls_relax (struct elf32_arm_link_hash_table *globals,
-		     bfd *input_bfd, asection *input_sec, bfd_byte *contents, 
+		     bfd *input_bfd, asection *input_sec, bfd_byte *contents,
 		     Elf_Internal_Rela *rel, unsigned long is_local)
 {
   unsigned long insn;
-  
+
   switch (ELF32_R_TYPE (rel->r_info))
     {
     default:
       return bfd_reloc_notsupported;
-      
+
     case R_ARM_TLS_GOTDESC:
       if (is_local)
 	insn = 0;
@@ -7694,7 +7897,7 @@
 	  return bfd_reloc_notsupported;
 	}
       break;
-      
+
     case R_ARM_TLS_DESCSEQ:
       /* arm insn.  */
       insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
@@ -7740,7 +7943,7 @@
       insn = is_local ? 0xe1a00000 : 0xe79f0000;
       bfd_put_32 (input_bfd, insn, contents + rel->r_offset);
       break;
-      
+
     case R_ARM_THM_TLS_CALL:
       /* GD->IE relaxation */
       if (!is_local)
@@ -7752,7 +7955,7 @@
       else
 	/* nop; nop */
 	insn = 0xbf00bf00;
-	
+
       bfd_put_16 (input_bfd, insn >> 16, contents + rel->r_offset);
       bfd_put_16 (input_bfd, insn & 0xffff, contents + rel->r_offset + 2);
       break;
@@ -7780,28 +7983,28 @@
 
       /* Calculate which part of the value to mask.  */
       if (residual == 0)
-        shift = 0;
+	shift = 0;
       else
-        {
-          int msb;
+	{
+	  int msb;
 
-          /* Determine the most significant bit in the residual and
-             align the resulting value to a 2-bit boundary.  */
-          for (msb = 30; msb >= 0; msb -= 2)
-            if (residual & (3 << msb))
-              break;
+	  /* Determine the most significant bit in the residual and
+	     align the resulting value to a 2-bit boundary.  */
+	  for (msb = 30; msb >= 0; msb -= 2)
+	    if (residual & (3 << msb))
+	      break;
 
-          /* The desired shift is now (msb - 6), or zero, whichever
-             is the greater.  */
-          shift = msb - 6;
-          if (shift < 0)
-            shift = 0;
-        }
+	  /* The desired shift is now (msb - 6), or zero, whichever
+	     is the greater.  */
+	  shift = msb - 6;
+	  if (shift < 0)
+	    shift = 0;
+	}
 
       /* Calculate g_n in 32-bit as well as encoded constant+rotation form.  */
       g_n = residual & (0xff << shift);
       encoded_g_n = (g_n >> shift)
-                    | ((g_n <= 0xff ? 0 : (32 - shift) / 2) << 8);
+		    | ((g_n <= 0xff ? 0 : (32 - shift) / 2) << 8);
 
       /* Calculate the residual for the next time around.  */
       residual &= ~g_n;
@@ -7926,6 +8129,14 @@
   else
     addend = signed_addend = rel->r_addend;
 
+  /* ST_BRANCH_TO_ARM is nonsense to thumb-only targets when we
+     are resolving a function call relocation.  */
+  if (using_thumb_only (globals)
+      && (r_type == R_ARM_THM_CALL
+	  || r_type == R_ARM_THM_JUMP24)
+      && branch_type == ST_BRANCH_TO_ARM)
+    branch_type = ST_BRANCH_TO_THUMB;
+
   /* Record the symbol information that should be used in dynamic
      relocations.  */
   dynreloc_st_type = st_type;
@@ -8013,7 +8224,7 @@
 	 branches in this object should go to it, except if the PLT is too
 	 far away, in which case a long branch stub should be inserted.  */
       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_ABS32_NOI && r_type != R_ARM_REL32_NOI
 	   && r_type != R_ARM_CALL
 	   && r_type != R_ARM_JUMP24
 	   && r_type != R_ARM_PLT32)
@@ -8044,7 +8255,8 @@
 			  ".tls_vars") == 0)
 	  && ((r_type != R_ARM_REL32 && r_type != R_ARM_REL32_NOI)
 	      || !SYMBOL_CALLS_LOCAL (info, h))
-	  && (!strstr (input_section->name, STUB_SUFFIX))
+	  && !(input_bfd == globals->stub_bfd
+	       && strstr (input_section->name, STUB_SUFFIX))
 	  && (h == NULL
 	      || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
 	      || h->root.type != bfd_link_hash_undefweak)
@@ -8220,7 +8432,6 @@
 		{
 		  /* The target is out of reach, so redirect the
 		     branch to the local stub for this function.  */
-
 		  stub_entry = elf32_arm_get_stub_entry (input_section,
 							 sym_sec, h,
 							 rel, globals,
@@ -8430,36 +8641,36 @@
 	bfd_signed_vma relocation;
 
 	insn = (bfd_get_16 (input_bfd, hit_data) << 16)
-             | bfd_get_16 (input_bfd, hit_data + 2);
+	     | bfd_get_16 (input_bfd, hit_data + 2);
 
-        if (globals->use_rel)
-          {
-            signed_addend = (insn & 0xff) | ((insn & 0x7000) >> 4)
-                          | ((insn & (1 << 26)) >> 15);
-            if (insn & 0xf00000)
-              signed_addend = -signed_addend;
-          }
+	if (globals->use_rel)
+	  {
+	    signed_addend = (insn & 0xff) | ((insn & 0x7000) >> 4)
+			  | ((insn & (1 << 26)) >> 15);
+	    if (insn & 0xf00000)
+	      signed_addend = -signed_addend;
+	  }
 
 	relocation = value + signed_addend;
-	relocation -= (input_section->output_section->vma
-		       + input_section->output_offset
-		       + rel->r_offset);
+	relocation -= Pa (input_section->output_section->vma
+			  + input_section->output_offset
+			  + rel->r_offset);
 
-        value = abs (relocation);
+	value = abs (relocation);
 
-        if (value >= 0x1000)
-          return bfd_reloc_overflow;
+	if (value >= 0x1000)
+	  return bfd_reloc_overflow;
 
 	insn = (insn & 0xfb0f8f00) | (value & 0xff)
-             | ((value & 0x700) << 4)
-             | ((value & 0x800) << 15);
-        if (relocation < 0)
-          insn |= 0xa00000;
+	     | ((value & 0x700) << 4)
+	     | ((value & 0x800) << 15);
+	if (relocation < 0)
+	  insn |= 0xa00000;
 
 	bfd_put_16 (input_bfd, insn >> 16, hit_data);
 	bfd_put_16 (input_bfd, insn & 0xffff, hit_data + 2);
 
-        return bfd_reloc_ok;
+	return bfd_reloc_ok;
       }
 
     case R_ARM_THM_PC8:
@@ -8472,15 +8683,15 @@
 
 	insn = bfd_get_16 (input_bfd, hit_data);
 
-        if (globals->use_rel)
-	  addend = (insn & 0x00ff) << 2;
+	if (globals->use_rel)
+	  addend = ((((insn & 0x00ff) << 2) + 4) & 0x3ff) -4;
 
 	relocation = value + addend;
-	relocation -= (input_section->output_section->vma
-		       + input_section->output_offset
-		       + rel->r_offset);
+	relocation -= Pa (input_section->output_section->vma
+			  + input_section->output_offset
+			  + rel->r_offset);
 
-        value = abs (relocation);
+	value = abs (relocation);
 
 	/* We do not check for overflow of this reloc.  Although strictly
 	   speaking this is incorrect, it appears to be necessary in order
@@ -8493,7 +8704,7 @@
 
 	bfd_put_16 (input_bfd, insn, hit_data);
 
-        return bfd_reloc_ok;
+	return bfd_reloc_ok;
       }
 
     case R_ARM_THM_PC12:
@@ -8503,33 +8714,33 @@
 	bfd_signed_vma relocation;
 
 	insn = (bfd_get_16 (input_bfd, hit_data) << 16)
-             | bfd_get_16 (input_bfd, hit_data + 2);
+	     | bfd_get_16 (input_bfd, hit_data + 2);
 
-        if (globals->use_rel)
-          {
-            signed_addend = insn & 0xfff;
-            if (!(insn & (1 << 23)))
-              signed_addend = -signed_addend;
-          }
+	if (globals->use_rel)
+	  {
+	    signed_addend = insn & 0xfff;
+	    if (!(insn & (1 << 23)))
+	      signed_addend = -signed_addend;
+	  }
 
 	relocation = value + signed_addend;
-	relocation -= (input_section->output_section->vma
-		       + input_section->output_offset
-		       + rel->r_offset);
+	relocation -= Pa (input_section->output_section->vma
+			  + input_section->output_offset
+			  + rel->r_offset);
 
-        value = abs (relocation);
+	value = abs (relocation);
 
-        if (value >= 0x1000)
-          return bfd_reloc_overflow;
+	if (value >= 0x1000)
+	  return bfd_reloc_overflow;
 
 	insn = (insn & 0xff7ff000) | value;
-        if (relocation >= 0)
-          insn |= (1 << 23);
+	if (relocation >= 0)
+	  insn |= (1 << 23);
 
 	bfd_put_16 (input_bfd, insn >> 16, hit_data);
 	bfd_put_16 (input_bfd, insn & 0xffff, hit_data + 2);
 
-        return bfd_reloc_ok;
+	return bfd_reloc_ok;
       }
 
     case R_ARM_THM_XPC22:
@@ -8538,7 +8749,7 @@
       /* Thumb BL (branch long instruction).  */
       {
 	bfd_vma relocation;
-        bfd_vma reloc_sign;
+	bfd_vma reloc_sign;
 	bfd_boolean overflow = FALSE;
 	bfd_vma upper_insn = bfd_get_16 (input_bfd, hit_data);
 	bfd_vma lower_insn = bfd_get_16 (input_bfd, hit_data + 2);
@@ -8570,20 +8781,20 @@
 	  }
 
 	/* Fetch the addend.  We use the Thumb-2 encoding (backwards compatible
-           with Thumb-1) involving the J1 and J2 bits.  */
+	   with Thumb-1) involving the J1 and J2 bits.  */
 	if (globals->use_rel)
 	  {
-            bfd_vma s = (upper_insn & (1 << 10)) >> 10;
-            bfd_vma upper = upper_insn & 0x3ff;
-            bfd_vma lower = lower_insn & 0x7ff;
+	    bfd_vma s = (upper_insn & (1 << 10)) >> 10;
+	    bfd_vma upper = upper_insn & 0x3ff;
+	    bfd_vma lower = lower_insn & 0x7ff;
 	    bfd_vma j1 = (lower_insn & (1 << 13)) >> 13;
 	    bfd_vma j2 = (lower_insn & (1 << 11)) >> 11;
-            bfd_vma i1 = j1 ^ s ? 0 : 1;
-            bfd_vma i2 = j2 ^ s ? 0 : 1;
+	    bfd_vma i1 = j1 ^ s ? 0 : 1;
+	    bfd_vma i2 = j2 ^ s ? 0 : 1;
 
-            addend = (i1 << 23) | (i2 << 22) | (upper << 12) | (lower << 1);
-            /* Sign extend.  */
-            addend = (addend | ((s ? 0 : 1) << 24)) - (1 << 24);
+	    addend = (i1 << 23) | (i2 << 22) | (upper << 12) | (lower << 1);
+	    /* Sign extend.  */
+	    addend = (addend | ((s ? 0 : 1) << 24)) - (1 << 24);
 
 	    signed_addend = addend;
 	  }
@@ -8740,14 +8951,14 @@
 	/* Put RELOCATION back into the insn.  Assumes two's complement.
 	   We use the Thumb-2 encoding, which is safe even if dealing with
 	   a Thumb-1 instruction by virtue of our overflow check above.  */
-        reloc_sign = (signed_check < 0) ? 1 : 0;
+	reloc_sign = (signed_check < 0) ? 1 : 0;
 	upper_insn = (upper_insn & ~(bfd_vma) 0x7ff)
-                     | ((relocation >> 12) & 0x3ff)
-                     | (reloc_sign << 10);
+		     | ((relocation >> 12) & 0x3ff)
+		     | (reloc_sign << 10);
 	lower_insn = (lower_insn & ~(bfd_vma) 0x2fff)
-                     | (((!((relocation >> 23) & 1)) ^ reloc_sign) << 13)
-                     | (((!((relocation >> 22) & 1)) ^ reloc_sign) << 11)
-                     | ((relocation >> 1) & 0x7ff);
+		     | (((!((relocation >> 23) & 1)) ^ reloc_sign) << 13)
+		     | (((!((relocation >> 22) & 1)) ^ reloc_sign) << 11)
+		     | ((relocation >> 1) & 0x7ff);
 
 	/* Put the relocated value back in the object file:  */
 	bfd_put_16 (input_bfd, upper_insn, hit_data);
@@ -8801,7 +9012,7 @@
 	/* ??? Should handle interworking?  GCC might someday try to
 	   use this for tail calls.  */
 
-      	relocation = value + signed_addend;
+	relocation = value + signed_addend;
 	relocation -= (input_section->output_section->vma
 		       + input_section->output_offset
 		       + rel->r_offset);
@@ -8916,11 +9127,11 @@
 
     case R_ARM_GOTOFF32:
       /* Relocation is relative to the start of the
-         global offset table.  */
+	 global offset table.  */
 
       BFD_ASSERT (sgot != NULL);
       if (sgot == NULL)
-        return bfd_reloc_notsupported;
+	return bfd_reloc_notsupported;
 
       /* If we are addressing a Thumb function, we need to adjust the
 	 address by one, so that attempts to call the function pointer will
@@ -8929,10 +9140,10 @@
 	value += 1;
 
       /* Note that sgot->output_offset is not involved in this
-         calculation.  We always want the start of .got.  If we
-         define _GLOBAL_OFFSET_TABLE in a different way, as is
-         permitted by the ABI, we might have to change this
-         calculation.  */
+	 calculation.  We always want the start of .got.  If we
+	 define _GLOBAL_OFFSET_TABLE in a different way, as is
+	 permitted by the ABI, we might have to change this
+	 calculation.  */
       value -= sgot->output_section->vma;
       return _bfd_final_link_relocate (howto, input_bfd, input_section,
 				       contents, rel->r_offset, value,
@@ -8943,7 +9154,7 @@
       BFD_ASSERT (sgot != NULL);
 
       if (sgot == NULL)
-        return bfd_reloc_notsupported;
+	return bfd_reloc_notsupported;
 
       *unresolved_reloc_p = FALSE;
       value = sgot->output_section->vma;
@@ -8954,7 +9165,7 @@
     case R_ARM_GOT32:
     case R_ARM_GOT_PREL:
       /* Relocation is to the entry for this symbol in the
-         global offset table.  */
+	 global offset table.  */
       if (sgot == NULL)
 	return bfd_reloc_notsupported;
 
@@ -8989,7 +9200,7 @@
 	    {
 	      Elf_Internal_Rela outrel;
 
-	      if (!SYMBOL_REFERENCES_LOCAL (info, h))
+	      if (h->dynindx != -1 && !SYMBOL_REFERENCES_LOCAL (info, h))
 		{
 		  /* If the symbol doesn't resolve locally in a static
 		     object, we have an undefined reference.  If the
@@ -9007,11 +9218,13 @@
 	      else
 		{
 		  if (dynreloc_st_type == STT_GNU_IFUNC)
- 		    outrel.r_info = ELF32_R_INFO (0, R_ARM_IRELATIVE);
-		  else if (info->shared)
- 		    outrel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE);
- 		  else
- 		    outrel.r_info = 0;
+		    outrel.r_info = ELF32_R_INFO (0, R_ARM_IRELATIVE);
+		  else if (info->shared &&
+			   (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+			    || h->root.type != bfd_link_hash_undefweak))
+		    outrel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE);
+		  else
+		    outrel.r_info = 0;
 		  outrel.r_addend = dynreloc_value;
 		}
 
@@ -9064,7 +9277,7 @@
 				     + sgot->output_offset
 				     + off);
 		  if (dynreloc_st_type == STT_GNU_IFUNC)
- 		    outrel.r_info = ELF32_R_INFO (0, R_ARM_IRELATIVE);
+		    outrel.r_info = ELF32_R_INFO (0, R_ARM_IRELATIVE);
 		  else
 		    outrel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE);
 		  elf32_arm_add_dynreloc (output_bfd, info, srelgot, &outrel);
@@ -9174,9 +9387,9 @@
 	  }
 
 	/* Linker relaxations happens from one of the
-	   R_ARM_{GOTDESC,CALL,DESCSEQ} relocations to IE or LE.  */ 
+	   R_ARM_{GOTDESC,CALL,DESCSEQ} relocations to IE or LE.  */
 	if (ELF32_R_TYPE(rel->r_info) != r_type)
-	  tls_type = GOT_TLS_IE; 
+	  tls_type = GOT_TLS_IE;
 
 	BFD_ASSERT (tls_type != GOT_UNKNOWN);
 
@@ -9210,20 +9423,20 @@
 		BFD_ASSERT ((h && (h->root.type == bfd_link_hash_undefweak))
 			    || info->shared);
 		BFD_ASSERT (globals->sgotplt_jump_table_size + offplt + 8
-                            <= globals->root.sgotplt->size);
+			    <= globals->root.sgotplt->size);
 
 		outrel.r_addend = 0;
 		outrel.r_offset = (globals->root.sgotplt->output_section->vma
 				   + globals->root.sgotplt->output_offset
 				   + offplt
 				   + globals->sgotplt_jump_table_size);
-		
+
 		outrel.r_info = ELF32_R_INFO (indx, R_ARM_TLS_DESC);
 		sreloc = globals->root.srelplt;
 		loc = sreloc->contents;
 		loc += globals->next_tls_desc_index++ * RELOC_SIZE (globals);
 		BFD_ASSERT (loc + RELOC_SIZE (globals)
-		   	   <= sreloc->contents + sreloc->size);
+			   <= sreloc->contents + sreloc->size);
 
 		SWAP_RELOC_OUT (globals) (output_bfd, &outrel, loc);
 
@@ -9231,17 +9444,17 @@
 		   the relocation index and the top bit set, or zero,
 		   if we're binding now.  For locals, it gets the
 		   symbol's offset in the tls section.  */
-	    	bfd_put_32 (output_bfd,
+		bfd_put_32 (output_bfd,
 			    !h ? value - elf_hash_table (info)->tls_sec->vma
 			    : info->flags & DF_BIND_NOW ? 0
 			    : 0x80000000 | ELF32_R_SYM (outrel.r_info),
-			    globals->root.sgotplt->contents + offplt +
-			    globals->sgotplt_jump_table_size);
-		
+			    globals->root.sgotplt->contents + offplt
+			    + globals->sgotplt_jump_table_size);
+
 		/* Second word in the relocation is always zero.  */
-	    	bfd_put_32 (output_bfd, 0,
-			    globals->root.sgotplt->contents + offplt +
-			    globals->sgotplt_jump_table_size + 4);
+		bfd_put_32 (output_bfd, 0,
+			    globals->root.sgotplt->contents + offplt
+			    + globals->sgotplt_jump_table_size + 4);
 	      }
 	    if (tls_type & GOT_TLS_GD)
 	      {
@@ -9361,9 +9574,10 @@
 	    if (ELF32_R_TYPE(rel->r_info) == R_ARM_TLS_CALL)
 	      {
 		unsigned long inst;
-		
-		offset -= (input_section->output_section->vma +
-			   input_section->output_offset + rel->r_offset + 8);
+
+		offset -= (input_section->output_section->vma
+			   + input_section->output_offset
+			   + rel->r_offset + 8);
 
 		inst = offset >> 2;
 		inst &= 0x00ffffff;
@@ -9376,10 +9590,10 @@
 		unsigned upper_insn, lower_insn;
 		unsigned neg;
 
-		offset -= (input_section->output_section->vma + 
-			   input_section->output_offset
+		offset -= (input_section->output_section->vma
+			   + input_section->output_offset
 			   + rel->r_offset + 4);
-	    
+
 		if (stub_type != arm_stub_none
 		    && arm_stub_is_thumb (stub_type))
 		  {
@@ -9412,11 +9626,11 @@
 	  {
 	    unsigned long data, insn;
 	    unsigned thumb;
-	    
+
 	    data = bfd_get_32 (input_bfd, hit_data);
 	    thumb = data & 1;
 	    data &= ~1u;
-	    
+
 	    if (thumb)
 	      {
 		insn = bfd_get_16 (input_bfd, contents + rel->r_offset - data);
@@ -9453,7 +9667,7 @@
 		  case 0xe0:	/* add */
 		    value = -8;
 		    break;
-		    
+
 		  default:
 		    (*_bfd_error_handler)
 		      (_("%B(%A+0x%lx):unexpected ARM instruction '0x%x' referenced by TLS_GOTDESC"),
@@ -9462,7 +9676,7 @@
 		    return bfd_reloc_notsupported;
 		  }
 	      }
- 
+
 	    value += ((globals->root.sgotplt->output_section->vma
 		       + globals->root.sgotplt->output_offset + off)
 		      - (input_section->output_section->vma
@@ -9488,7 +9702,7 @@
 	    (_("%B(%A+0x%lx): R_ARM_TLS_LE32 relocation not permitted in shared object"),
 	     input_bfd, input_section,
 	     (long) rel->r_offset, howto->name);
-	  return (bfd_reloc_status_type) FALSE;
+	  return bfd_reloc_notsupported;
 	}
       else
 	value = tpoff (info, value);
@@ -9554,13 +9768,13 @@
 		    + input_section->output_offset + rel->r_offset);
 
 	if (r_type == R_ARM_MOVW_BREL && value >= 0x10000)
-          return bfd_reloc_overflow;
+	  return bfd_reloc_overflow;
 
 	if (branch_type == ST_BRANCH_TO_THUMB)
 	  value |= 1;
 
 	if (r_type == R_ARM_MOVT_ABS || r_type == R_ARM_MOVT_PREL
-            || r_type == R_ARM_MOVT_BREL)
+	    || r_type == R_ARM_MOVT_BREL)
 	  value >>= 16;
 
 	insn &= 0xfff0f000;
@@ -9604,13 +9818,13 @@
 		    + input_section->output_offset + rel->r_offset);
 
 	if (r_type == R_ARM_THM_MOVW_BREL && value >= 0x10000)
-          return bfd_reloc_overflow;
+	  return bfd_reloc_overflow;
 
 	if (branch_type == ST_BRANCH_TO_THUMB)
 	  value |= 1;
 
 	if (r_type == R_ARM_THM_MOVT_ABS || r_type == R_ARM_THM_MOVT_PREL
-            || r_type == R_ARM_THM_MOVT_BREL)
+	    || r_type == R_ARM_THM_MOVT_BREL)
 	  value >>= 16;
 
 	insn &= 0xfbf08f00;
@@ -9636,129 +9850,127 @@
     case R_ARM_ALU_SB_G2:
       {
 	bfd_vma insn = bfd_get_32 (input_bfd, hit_data);
-        bfd_vma pc = input_section->output_section->vma
+	bfd_vma pc = input_section->output_section->vma
 		     + input_section->output_offset + rel->r_offset;
-        /* sb should be the origin of the *segment* containing the symbol.
-           It is not clear how to obtain this OS-dependent value, so we
-           make an arbitrary choice of zero.  */
-        bfd_vma sb = 0;
-        bfd_vma residual;
-        bfd_vma g_n;
+	/* sb is the origin of the *segment* containing the symbol.  */
+	bfd_vma sb = sym_sec ? sym_sec->output_section->vma : 0;
+	bfd_vma residual;
+	bfd_vma g_n;
 	bfd_signed_vma signed_value;
-        int group = 0;
+	int group = 0;
 
-        /* Determine which group of bits to select.  */
-        switch (r_type)
-          {
-          case R_ARM_ALU_PC_G0_NC:
-          case R_ARM_ALU_PC_G0:
-          case R_ARM_ALU_SB_G0_NC:
-          case R_ARM_ALU_SB_G0:
-            group = 0;
-            break;
+	/* Determine which group of bits to select.  */
+	switch (r_type)
+	  {
+	  case R_ARM_ALU_PC_G0_NC:
+	  case R_ARM_ALU_PC_G0:
+	  case R_ARM_ALU_SB_G0_NC:
+	  case R_ARM_ALU_SB_G0:
+	    group = 0;
+	    break;
 
-          case R_ARM_ALU_PC_G1_NC:
-          case R_ARM_ALU_PC_G1:
-          case R_ARM_ALU_SB_G1_NC:
-          case R_ARM_ALU_SB_G1:
-            group = 1;
-            break;
+	  case R_ARM_ALU_PC_G1_NC:
+	  case R_ARM_ALU_PC_G1:
+	  case R_ARM_ALU_SB_G1_NC:
+	  case R_ARM_ALU_SB_G1:
+	    group = 1;
+	    break;
 
-          case R_ARM_ALU_PC_G2:
-          case R_ARM_ALU_SB_G2:
-            group = 2;
-            break;
+	  case R_ARM_ALU_PC_G2:
+	  case R_ARM_ALU_SB_G2:
+	    group = 2;
+	    break;
 
-          default:
-            abort ();
-          }
+	  default:
+	    abort ();
+	  }
 
-        /* If REL, extract the addend from the insn.  If RELA, it will
-           have already been fetched for us.  */
+	/* If REL, extract the addend from the insn.  If RELA, it will
+	   have already been fetched for us.  */
 	if (globals->use_rel)
-          {
-            int negative;
-            bfd_vma constant = insn & 0xff;
-            bfd_vma rotation = (insn & 0xf00) >> 8;
+	  {
+	    int negative;
+	    bfd_vma constant = insn & 0xff;
+	    bfd_vma rotation = (insn & 0xf00) >> 8;
 
-            if (rotation == 0)
-              signed_addend = constant;
-            else
-              {
-                /* Compensate for the fact that in the instruction, the
-                   rotation is stored in multiples of 2 bits.  */
-                rotation *= 2;
+	    if (rotation == 0)
+	      signed_addend = constant;
+	    else
+	      {
+		/* Compensate for the fact that in the instruction, the
+		   rotation is stored in multiples of 2 bits.  */
+		rotation *= 2;
 
-                /* Rotate "constant" right by "rotation" bits.  */
-                signed_addend = (constant >> rotation) |
-                                (constant << (8 * sizeof (bfd_vma) - rotation));
-              }
+		/* Rotate "constant" right by "rotation" bits.  */
+		signed_addend = (constant >> rotation) |
+				(constant << (8 * sizeof (bfd_vma) - rotation));
+	      }
 
-            /* Determine if the instruction is an ADD or a SUB.
-               (For REL, this determines the sign of the addend.)  */
-            negative = identify_add_or_sub (insn);
-            if (negative == 0)
-              {
-                (*_bfd_error_handler)
-                  (_("%B(%A+0x%lx): Only ADD or SUB instructions are allowed for ALU group relocations"),
-                  input_bfd, input_section,
-                  (long) rel->r_offset, howto->name);
-                return bfd_reloc_overflow;
-    	      }
+	    /* Determine if the instruction is an ADD or a SUB.
+	       (For REL, this determines the sign of the addend.)  */
+	    negative = identify_add_or_sub (insn);
+	    if (negative == 0)
+	      {
+		(*_bfd_error_handler)
+		  (_("%B(%A+0x%lx): Only ADD or SUB instructions are allowed for ALU group relocations"),
+		  input_bfd, input_section,
+		  (long) rel->r_offset, howto->name);
+		return bfd_reloc_overflow;
+	      }
 
-            signed_addend *= negative;
-          }
+	    signed_addend *= negative;
+	  }
 
 	/* Compute the value (X) to go in the place.  */
-        if (r_type == R_ARM_ALU_PC_G0_NC
-            || r_type == R_ARM_ALU_PC_G1_NC
-            || r_type == R_ARM_ALU_PC_G0
-            || r_type == R_ARM_ALU_PC_G1
-            || r_type == R_ARM_ALU_PC_G2)
-          /* PC relative.  */
-          signed_value = value - pc + signed_addend;
-        else
-          /* Section base relative.  */
-          signed_value = value - sb + signed_addend;
+	if (r_type == R_ARM_ALU_PC_G0_NC
+	    || r_type == R_ARM_ALU_PC_G1_NC
+	    || r_type == R_ARM_ALU_PC_G0
+	    || r_type == R_ARM_ALU_PC_G1
+	    || r_type == R_ARM_ALU_PC_G2)
+	  /* PC relative.  */
+	  signed_value = value - pc + signed_addend;
+	else
+	  /* Section base relative.  */
+	  signed_value = value - sb + signed_addend;
 
-        /* If the target symbol is a Thumb function, then set the
-           Thumb bit in the address.  */
+	/* If the target symbol is a Thumb function, then set the
+	   Thumb bit in the address.  */
 	if (branch_type == ST_BRANCH_TO_THUMB)
 	  signed_value |= 1;
 
-        /* Calculate the value of the relevant G_n, in encoded
-           constant-with-rotation format.  */
-        g_n = calculate_group_reloc_mask (abs (signed_value), group,
-                                          &residual);
+	/* Calculate the value of the relevant G_n, in encoded
+	   constant-with-rotation format.  */
+	g_n = calculate_group_reloc_mask (abs (signed_value), group,
+					  &residual);
 
-        /* Check for overflow if required.  */
-        if ((r_type == R_ARM_ALU_PC_G0
-             || r_type == R_ARM_ALU_PC_G1
-             || r_type == R_ARM_ALU_PC_G2
-             || r_type == R_ARM_ALU_SB_G0
-             || r_type == R_ARM_ALU_SB_G1
-             || r_type == R_ARM_ALU_SB_G2) && residual != 0)
-          {
-            (*_bfd_error_handler)
-              (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
-              input_bfd, input_section,
-              (long) rel->r_offset, abs (signed_value), howto->name);
-            return bfd_reloc_overflow;
-          }
+	/* Check for overflow if required.  */
+	if ((r_type == R_ARM_ALU_PC_G0
+	     || r_type == R_ARM_ALU_PC_G1
+	     || r_type == R_ARM_ALU_PC_G2
+	     || r_type == R_ARM_ALU_SB_G0
+	     || r_type == R_ARM_ALU_SB_G1
+	     || r_type == R_ARM_ALU_SB_G2) && residual != 0)
+	  {
+	    (*_bfd_error_handler)
+	      (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
+	      input_bfd, input_section,
+	      (long) rel->r_offset, abs (signed_value), howto->name);
+	    return bfd_reloc_overflow;
+	  }
 
-        /* Mask out the value and the ADD/SUB part of the opcode; take care
-           not to destroy the S bit.  */
-        insn &= 0xff1ff000;
+	/* Mask out the value and the ADD/SUB part of the opcode; take care
+	   not to destroy the S bit.  */
+	insn &= 0xff1ff000;
 
-        /* Set the opcode according to whether the value to go in the
-           place is negative.  */
-        if (signed_value < 0)
-          insn |= 1 << 22;
-        else
-          insn |= 1 << 23;
+	/* Set the opcode according to whether the value to go in the
+	   place is negative.  */
+	if (signed_value < 0)
+	  insn |= 1 << 22;
+	else
+	  insn |= 1 << 23;
 
-        /* Encode the offset.  */
-        insn |= g_n;
+	/* Encode the offset.  */
+	insn |= g_n;
 
 	bfd_put_32 (input_bfd, insn, hit_data);
       }
@@ -9772,76 +9984,77 @@
     case R_ARM_LDR_SB_G2:
       {
 	bfd_vma insn = bfd_get_32 (input_bfd, hit_data);
-        bfd_vma pc = input_section->output_section->vma
+	bfd_vma pc = input_section->output_section->vma
 		     + input_section->output_offset + rel->r_offset;
-        bfd_vma sb = 0; /* See note above.  */
-        bfd_vma residual;
+	/* sb is the origin of the *segment* containing the symbol.  */
+	bfd_vma sb = sym_sec ? sym_sec->output_section->vma : 0;
+	bfd_vma residual;
 	bfd_signed_vma signed_value;
-        int group = 0;
+	int group = 0;
 
-        /* Determine which groups of bits to calculate.  */
-        switch (r_type)
-          {
-          case R_ARM_LDR_PC_G0:
-          case R_ARM_LDR_SB_G0:
-            group = 0;
-            break;
+	/* Determine which groups of bits to calculate.  */
+	switch (r_type)
+	  {
+	  case R_ARM_LDR_PC_G0:
+	  case R_ARM_LDR_SB_G0:
+	    group = 0;
+	    break;
 
-          case R_ARM_LDR_PC_G1:
-          case R_ARM_LDR_SB_G1:
-            group = 1;
-            break;
+	  case R_ARM_LDR_PC_G1:
+	  case R_ARM_LDR_SB_G1:
+	    group = 1;
+	    break;
 
-          case R_ARM_LDR_PC_G2:
-          case R_ARM_LDR_SB_G2:
-            group = 2;
-            break;
+	  case R_ARM_LDR_PC_G2:
+	  case R_ARM_LDR_SB_G2:
+	    group = 2;
+	    break;
 
-          default:
-            abort ();
-          }
+	  default:
+	    abort ();
+	  }
 
-        /* If REL, extract the addend from the insn.  If RELA, it will
-           have already been fetched for us.  */
+	/* If REL, extract the addend from the insn.  If RELA, it will
+	   have already been fetched for us.  */
 	if (globals->use_rel)
-          {
-            int negative = (insn & (1 << 23)) ? 1 : -1;
-            signed_addend = negative * (insn & 0xfff);
-          }
+	  {
+	    int negative = (insn & (1 << 23)) ? 1 : -1;
+	    signed_addend = negative * (insn & 0xfff);
+	  }
 
 	/* Compute the value (X) to go in the place.  */
-        if (r_type == R_ARM_LDR_PC_G0
-            || r_type == R_ARM_LDR_PC_G1
-            || r_type == R_ARM_LDR_PC_G2)
-          /* PC relative.  */
-          signed_value = value - pc + signed_addend;
-        else
-          /* Section base relative.  */
-          signed_value = value - sb + signed_addend;
+	if (r_type == R_ARM_LDR_PC_G0
+	    || r_type == R_ARM_LDR_PC_G1
+	    || r_type == R_ARM_LDR_PC_G2)
+	  /* PC relative.  */
+	  signed_value = value - pc + signed_addend;
+	else
+	  /* Section base relative.  */
+	  signed_value = value - sb + signed_addend;
 
-        /* Calculate the value of the relevant G_{n-1} to obtain
-           the residual at that stage.  */
-        calculate_group_reloc_mask (abs (signed_value), group - 1, &residual);
+	/* Calculate the value of the relevant G_{n-1} to obtain
+	   the residual at that stage.  */
+	calculate_group_reloc_mask (abs (signed_value), group - 1, &residual);
 
-        /* Check for overflow.  */
-        if (residual >= 0x1000)
-          {
-            (*_bfd_error_handler)
-              (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
-              input_bfd, input_section,
-              (long) rel->r_offset, abs (signed_value), howto->name);
-            return bfd_reloc_overflow;
-          }
+	/* Check for overflow.  */
+	if (residual >= 0x1000)
+	  {
+	    (*_bfd_error_handler)
+	      (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
+	      input_bfd, input_section,
+	      (long) rel->r_offset, abs (signed_value), howto->name);
+	    return bfd_reloc_overflow;
+	  }
 
-        /* Mask out the value and U bit.  */
-        insn &= 0xff7ff000;
+	/* Mask out the value and U bit.  */
+	insn &= 0xff7ff000;
 
-        /* Set the U bit if the value to go in the place is non-negative.  */
-        if (signed_value >= 0)
-          insn |= 1 << 23;
+	/* Set the U bit if the value to go in the place is non-negative.  */
+	if (signed_value >= 0)
+	  insn |= 1 << 23;
 
-        /* Encode the offset.  */
-        insn |= residual;
+	/* Encode the offset.  */
+	insn |= residual;
 
 	bfd_put_32 (input_bfd, insn, hit_data);
       }
@@ -9855,76 +10068,77 @@
     case R_ARM_LDRS_SB_G2:
       {
 	bfd_vma insn = bfd_get_32 (input_bfd, hit_data);
-        bfd_vma pc = input_section->output_section->vma
+	bfd_vma pc = input_section->output_section->vma
 		     + input_section->output_offset + rel->r_offset;
-        bfd_vma sb = 0; /* See note above.  */
-        bfd_vma residual;
+	/* sb is the origin of the *segment* containing the symbol.  */
+	bfd_vma sb = sym_sec ? sym_sec->output_section->vma : 0;
+	bfd_vma residual;
 	bfd_signed_vma signed_value;
-        int group = 0;
+	int group = 0;
 
-        /* Determine which groups of bits to calculate.  */
-        switch (r_type)
-          {
-          case R_ARM_LDRS_PC_G0:
-          case R_ARM_LDRS_SB_G0:
-            group = 0;
-            break;
+	/* Determine which groups of bits to calculate.  */
+	switch (r_type)
+	  {
+	  case R_ARM_LDRS_PC_G0:
+	  case R_ARM_LDRS_SB_G0:
+	    group = 0;
+	    break;
 
-          case R_ARM_LDRS_PC_G1:
-          case R_ARM_LDRS_SB_G1:
-            group = 1;
-            break;
+	  case R_ARM_LDRS_PC_G1:
+	  case R_ARM_LDRS_SB_G1:
+	    group = 1;
+	    break;
 
-          case R_ARM_LDRS_PC_G2:
-          case R_ARM_LDRS_SB_G2:
-            group = 2;
-            break;
+	  case R_ARM_LDRS_PC_G2:
+	  case R_ARM_LDRS_SB_G2:
+	    group = 2;
+	    break;
 
-          default:
-            abort ();
-          }
+	  default:
+	    abort ();
+	  }
 
-        /* If REL, extract the addend from the insn.  If RELA, it will
-           have already been fetched for us.  */
+	/* If REL, extract the addend from the insn.  If RELA, it will
+	   have already been fetched for us.  */
 	if (globals->use_rel)
-          {
-            int negative = (insn & (1 << 23)) ? 1 : -1;
-            signed_addend = negative * (((insn & 0xf00) >> 4) + (insn & 0xf));
-          }
+	  {
+	    int negative = (insn & (1 << 23)) ? 1 : -1;
+	    signed_addend = negative * (((insn & 0xf00) >> 4) + (insn & 0xf));
+	  }
 
 	/* Compute the value (X) to go in the place.  */
-        if (r_type == R_ARM_LDRS_PC_G0
-            || r_type == R_ARM_LDRS_PC_G1
-            || r_type == R_ARM_LDRS_PC_G2)
-          /* PC relative.  */
-          signed_value = value - pc + signed_addend;
-        else
-          /* Section base relative.  */
-          signed_value = value - sb + signed_addend;
+	if (r_type == R_ARM_LDRS_PC_G0
+	    || r_type == R_ARM_LDRS_PC_G1
+	    || r_type == R_ARM_LDRS_PC_G2)
+	  /* PC relative.  */
+	  signed_value = value - pc + signed_addend;
+	else
+	  /* Section base relative.  */
+	  signed_value = value - sb + signed_addend;
 
-        /* Calculate the value of the relevant G_{n-1} to obtain
-           the residual at that stage.  */
-        calculate_group_reloc_mask (abs (signed_value), group - 1, &residual);
+	/* Calculate the value of the relevant G_{n-1} to obtain
+	   the residual at that stage.  */
+	calculate_group_reloc_mask (abs (signed_value), group - 1, &residual);
 
-        /* Check for overflow.  */
-        if (residual >= 0x100)
-          {
-            (*_bfd_error_handler)
-              (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
-              input_bfd, input_section,
-              (long) rel->r_offset, abs (signed_value), howto->name);
-            return bfd_reloc_overflow;
-          }
+	/* Check for overflow.  */
+	if (residual >= 0x100)
+	  {
+	    (*_bfd_error_handler)
+	      (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
+	      input_bfd, input_section,
+	      (long) rel->r_offset, abs (signed_value), howto->name);
+	    return bfd_reloc_overflow;
+	  }
 
-        /* Mask out the value and U bit.  */
-        insn &= 0xff7ff0f0;
+	/* Mask out the value and U bit.  */
+	insn &= 0xff7ff0f0;
 
-        /* Set the U bit if the value to go in the place is non-negative.  */
-        if (signed_value >= 0)
-          insn |= 1 << 23;
+	/* Set the U bit if the value to go in the place is non-negative.  */
+	if (signed_value >= 0)
+	  insn |= 1 << 23;
 
-        /* Encode the offset.  */
-        insn |= ((residual & 0xf0) << 4) | (residual & 0xf);
+	/* Encode the offset.  */
+	insn |= ((residual & 0xf0) << 4) | (residual & 0xf);
 
 	bfd_put_32 (input_bfd, insn, hit_data);
       }
@@ -9938,78 +10152,79 @@
     case R_ARM_LDC_SB_G2:
       {
 	bfd_vma insn = bfd_get_32 (input_bfd, hit_data);
-        bfd_vma pc = input_section->output_section->vma
+	bfd_vma pc = input_section->output_section->vma
 		     + input_section->output_offset + rel->r_offset;
-        bfd_vma sb = 0; /* See note above.  */
-        bfd_vma residual;
+	/* sb is the origin of the *segment* containing the symbol.  */
+	bfd_vma sb = sym_sec ? sym_sec->output_section->vma : 0;
+	bfd_vma residual;
 	bfd_signed_vma signed_value;
-        int group = 0;
+	int group = 0;
 
-        /* Determine which groups of bits to calculate.  */
-        switch (r_type)
-          {
-          case R_ARM_LDC_PC_G0:
-          case R_ARM_LDC_SB_G0:
-            group = 0;
-            break;
+	/* Determine which groups of bits to calculate.  */
+	switch (r_type)
+	  {
+	  case R_ARM_LDC_PC_G0:
+	  case R_ARM_LDC_SB_G0:
+	    group = 0;
+	    break;
 
-          case R_ARM_LDC_PC_G1:
-          case R_ARM_LDC_SB_G1:
-            group = 1;
-            break;
+	  case R_ARM_LDC_PC_G1:
+	  case R_ARM_LDC_SB_G1:
+	    group = 1;
+	    break;
 
-          case R_ARM_LDC_PC_G2:
-          case R_ARM_LDC_SB_G2:
-            group = 2;
-            break;
+	  case R_ARM_LDC_PC_G2:
+	  case R_ARM_LDC_SB_G2:
+	    group = 2;
+	    break;
 
-          default:
-            abort ();
-          }
+	  default:
+	    abort ();
+	  }
 
-        /* If REL, extract the addend from the insn.  If RELA, it will
-           have already been fetched for us.  */
+	/* If REL, extract the addend from the insn.  If RELA, it will
+	   have already been fetched for us.  */
 	if (globals->use_rel)
-          {
-            int negative = (insn & (1 << 23)) ? 1 : -1;
-            signed_addend = negative * ((insn & 0xff) << 2);
-          }
+	  {
+	    int negative = (insn & (1 << 23)) ? 1 : -1;
+	    signed_addend = negative * ((insn & 0xff) << 2);
+	  }
 
 	/* Compute the value (X) to go in the place.  */
-        if (r_type == R_ARM_LDC_PC_G0
-            || r_type == R_ARM_LDC_PC_G1
-            || r_type == R_ARM_LDC_PC_G2)
-          /* PC relative.  */
-          signed_value = value - pc + signed_addend;
-        else
-          /* Section base relative.  */
-          signed_value = value - sb + signed_addend;
+	if (r_type == R_ARM_LDC_PC_G0
+	    || r_type == R_ARM_LDC_PC_G1
+	    || r_type == R_ARM_LDC_PC_G2)
+	  /* PC relative.  */
+	  signed_value = value - pc + signed_addend;
+	else
+	  /* Section base relative.  */
+	  signed_value = value - sb + signed_addend;
 
-        /* Calculate the value of the relevant G_{n-1} to obtain
-           the residual at that stage.  */
-        calculate_group_reloc_mask (abs (signed_value), group - 1, &residual);
+	/* Calculate the value of the relevant G_{n-1} to obtain
+	   the residual at that stage.  */
+	calculate_group_reloc_mask (abs (signed_value), group - 1, &residual);
 
-        /* Check for overflow.  (The absolute value to go in the place must be
-           divisible by four and, after having been divided by four, must
-           fit in eight bits.)  */
-        if ((residual & 0x3) != 0 || residual >= 0x400)
-          {
-            (*_bfd_error_handler)
-              (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
-              input_bfd, input_section,
-              (long) rel->r_offset, abs (signed_value), howto->name);
-            return bfd_reloc_overflow;
-          }
+	/* Check for overflow.  (The absolute value to go in the place must be
+	   divisible by four and, after having been divided by four, must
+	   fit in eight bits.)  */
+	if ((residual & 0x3) != 0 || residual >= 0x400)
+	  {
+	    (*_bfd_error_handler)
+	      (_("%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"),
+	      input_bfd, input_section,
+	      (long) rel->r_offset, abs (signed_value), howto->name);
+	    return bfd_reloc_overflow;
+	  }
 
-        /* Mask out the value and U bit.  */
-        insn &= 0xff7fff00;
+	/* Mask out the value and U bit.  */
+	insn &= 0xff7fff00;
 
-        /* Set the U bit if the value to go in the place is non-negative.  */
-        if (signed_value >= 0)
-          insn |= 1 << 23;
+	/* Set the U bit if the value to go in the place is non-negative.  */
+	if (signed_value >= 0)
+	  insn |= 1 << 23;
 
-        /* Encode the offset.  */
-        insn |= residual >> 2;
+	/* Encode the offset.  */
+	insn |= residual >> 2;
 
 	bfd_put_32 (input_bfd, insn, hit_data);
       }
@@ -10161,8 +10376,8 @@
       r_type   = arm_real_reloc_type (globals, r_type);
 
       if (   r_type == R_ARM_GNU_VTENTRY
-          || r_type == R_ARM_GNU_VTINHERIT)
-        continue;
+	  || r_type == R_ARM_GNU_VTINHERIT)
+	continue;
 
       bfd_reloc.howto = elf32_arm_howto_from_type (r_type);
       howto = bfd_reloc.howto;
@@ -10196,7 +10411,7 @@
 		   rel->r_offset, TRUE))
 		return FALSE;
 	    }
-	  
+
 	  if (globals->use_rel)
 	    {
 	      relocation = (sec->output_section->vma
@@ -10305,9 +10520,9 @@
 	  sym_type = h->type;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	{
@@ -10355,13 +10570,13 @@
 	}
 
       /* We call elf32_arm_final_link_relocate unless we're completely
-         done, i.e., the relaxation produced the final output we want,
-         and we won't let anybody mess with it. Also, we have to do
-         addend adjustments in case of a R_ARM_TLS_GOTDESC relocation
-         both in relaxed and non-relaxed cases */
+	 done, i.e., the relaxation produced the final output we want,
+	 and we won't let anybody mess with it. Also, we have to do
+	 addend adjustments in case of a R_ARM_TLS_GOTDESC relocation
+	 both in relaxed and non-relaxed cases */
      if ((elf32_arm_tls_transition (info, r_type, h) != (unsigned)r_type)
 	 || (IS_ARM_TLS_GNU_RELOC (r_type)
-	     && !((h ? elf32_arm_hash_entry (h)->tls_type : 
+	     && !((h ? elf32_arm_hash_entry (h)->tls_type :
 		   elf32_arm_local_got_tls_type (input_bfd)[r_symndx])
 		  & GOT_TLS_GDESC)))
        {
@@ -10373,7 +10588,7 @@
        }
      else
        r = bfd_reloc_continue;
-     
+
      if (r == bfd_reloc_continue)
        r = elf32_arm_final_link_relocate (howto, input_bfd, output_bfd,
 					  input_section, contents, rel,
@@ -10386,10 +10601,10 @@
 	 because such sections are not SEC_ALLOC and thus ld.so will
 	 not process them.  */
       if (unresolved_reloc
-          && !((input_section->flags & SEC_DEBUGGING) != 0
-               && h->def_dynamic)
+	  && !((input_section->flags & SEC_DEBUGGING) != 0
+	       && h->def_dynamic)
 	  && _bfd_elf_section_offset (output_bfd, info, input_section,
-                                      rel->r_offset) != (bfd_vma) -1)
+				      rel->r_offset) != (bfd_vma) -1)
 	{
 	  (*_bfd_error_handler)
 	    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
@@ -10469,11 +10684,11 @@
 {
   arm_unwind_table_edit *new_edit = (arm_unwind_table_edit *)
       xmalloc (sizeof (arm_unwind_table_edit));
-  
+
   new_edit->type = type;
   new_edit->linked_section = linked_section;
   new_edit->index = tindex;
-  
+
   if (tindex > 0)
     {
       new_edit->next = NULL;
@@ -10531,16 +10746,15 @@
 
 /* Scan .ARM.exidx tables, and create a list describing edits which should be
    made to those tables, such that:
-   
+
      1. Regions without unwind data are marked with EXIDX_CANTUNWIND entries.
      2. Duplicate entries are merged together (EXIDX_CANTUNWIND, or unwind
-        codes which have been inlined into the index).
+	codes which have been inlined into the index).
 
    If MERGE_EXIDX_ENTRIES is false, duplicate entries are not merged.
 
    The edits are applied when the tables are written
-   (in elf32_arm_write_section).
-*/
+   (in elf32_arm_write_section).  */
 
 bfd_boolean
 elf32_arm_fix_exidx_coverage (asection **text_section_order,
@@ -10559,27 +10773,27 @@
   for (inp = info->input_bfds; inp != NULL; inp = inp->link_next)
     {
       asection *sec;
-      
+
       for (sec = inp->sections; sec != NULL; sec = sec->next)
-        {
+	{
 	  struct bfd_elf_section_data *elf_sec = elf_section_data (sec);
 	  Elf_Internal_Shdr *hdr = &elf_sec->this_hdr;
-	  
+
 	  if (!hdr || hdr->sh_type != SHT_ARM_EXIDX)
 	    continue;
-	  
+
 	  if (elf_sec->linked_to)
 	    {
 	      Elf_Internal_Shdr *linked_hdr
-	        = &elf_section_data (elf_sec->linked_to)->this_hdr;
+		= &elf_section_data (elf_sec->linked_to)->this_hdr;
 	      struct _arm_elf_section_data *linked_sec_arm_data
-	        = get_arm_elf_section_data (linked_hdr->bfd_section);
+		= get_arm_elf_section_data (linked_hdr->bfd_section);
 
 	      if (linked_sec_arm_data == NULL)
-	        continue;
+		continue;
 
 	      /* Link this .ARM.exidx section back from the text section it
-	         describes.  */
+		 describes.  */
 	      linked_sec_arm_data->u.text.arm_exidx_sec = sec;
 	    }
 	}
@@ -10604,7 +10818,7 @@
       bfd *ibfd;
 
       if (arm_data == NULL)
-        continue;
+	continue;
 
       exidx_sec = arm_data->u.text.arm_exidx_sec;
       if (exidx_sec == NULL)
@@ -10628,14 +10842,14 @@
 
       hdr = &elf_section_data (exidx_sec)->this_hdr;
       if (hdr->sh_type != SHT_ARM_EXIDX)
-        continue;
-      
+	continue;
+
       exidx_arm_data = get_arm_elf_section_data (exidx_sec);
       if (exidx_arm_data == NULL)
-        continue;
-      
+	continue;
+
       ibfd = exidx_sec->owner;
-	  
+
       if (hdr->contents != NULL)
 	contents = hdr->contents;
       else if (! bfd_malloc_and_get_section (ibfd, exidx_sec, &contents))
@@ -10682,12 +10896,12 @@
 
       /* Free contents if we allocated it ourselves.  */
       if (contents != hdr->contents)
-        free (contents);
+	free (contents);
 
       /* Record edits to be applied later (in elf32_arm_write_section).  */
       exidx_arm_data->u.exidx.unwind_edit_list = unwind_edit_head;
       exidx_arm_data->u.exidx.unwind_edit_tail = unwind_edit_tail;
-	  
+
       if (deleted_exidx_bytes > 0)
 	adjust_exidx_size(exidx_sec, -deleted_exidx_bytes);
 
@@ -10708,7 +10922,7 @@
 {
   asection *sec, *osec;
 
-  sec = bfd_get_section_by_name (ibfd, name);
+  sec = bfd_get_linker_section (ibfd, name);
   if (sec == NULL || (sec->flags & SEC_EXCLUDE) != 0)
     return TRUE;
 
@@ -10781,6 +10995,57 @@
   return TRUE;
 }
 
+/* Return a best guess for the machine number based on the attributes.  */
+
+static unsigned int
+bfd_arm_get_mach_from_attributes (bfd * abfd)
+{
+  int arch = bfd_elf_get_obj_attr_int (abfd, OBJ_ATTR_PROC, Tag_CPU_arch);
+
+  switch (arch)
+    {
+    case TAG_CPU_ARCH_V4: return bfd_mach_arm_4;
+    case TAG_CPU_ARCH_V4T: return bfd_mach_arm_4T;
+    case TAG_CPU_ARCH_V5T: return bfd_mach_arm_5T;
+
+    case TAG_CPU_ARCH_V5TE:
+      {
+	char * name;
+
+	BFD_ASSERT (Tag_CPU_name < NUM_KNOWN_OBJ_ATTRIBUTES);
+	name = elf_known_obj_attributes (abfd) [OBJ_ATTR_PROC][Tag_CPU_name].s;
+
+	if (name)
+	  {
+	    if (strcmp (name, "IWMMXT2") == 0)
+	      return bfd_mach_arm_iWMMXt2;
+
+	    if (strcmp (name, "IWMMXT") == 0)
+	      return bfd_mach_arm_iWMMXt;
+
+	    if (strcmp (name, "XSCALE") == 0)
+	      {
+		int wmmx;
+
+		BFD_ASSERT (Tag_WMMX_arch < NUM_KNOWN_OBJ_ATTRIBUTES);
+		wmmx = elf_known_obj_attributes (abfd) [OBJ_ATTR_PROC][Tag_WMMX_arch].i;
+		switch (wmmx)
+		  {
+		  case 1: return bfd_mach_arm_iWMMXt;
+		  case 2: return bfd_mach_arm_iWMMXt2;
+		  default: return bfd_mach_arm_XScale;
+		  }
+	      }
+	  }
+
+	return bfd_mach_arm_5TE;
+      }
+
+    default:
+      return bfd_mach_arm_unknown;
+    }
+}
+
 /* Set the right machine number.  */
 
 static bfd_boolean
@@ -10790,15 +11055,15 @@
 
   mach = bfd_arm_get_mach_from_notes (abfd, ARM_NOTE_SECTION);
 
-  if (mach != bfd_mach_arm_unknown)
-    bfd_default_set_arch_mach (abfd, bfd_arch_arm, mach);
+  if (mach == bfd_mach_arm_unknown)
+    {
+      if (elf_elfheader (abfd)->e_flags & EF_ARM_MAVERICK_FLOAT)
+	mach = bfd_mach_arm_ep9312;
+      else
+	mach = bfd_arm_get_mach_from_attributes (abfd);
+    }
 
-  else if (elf_elfheader (abfd)->e_flags & EF_ARM_MAVERICK_FLOAT)
-    bfd_default_set_arch_mach (abfd, bfd_arch_arm, bfd_mach_arm_ep9312);
-
-  else
-    bfd_default_set_arch_mach (abfd, bfd_arch_arm, mach);
-
+  bfd_default_set_arch_mach (abfd, bfd_arch_arm, mach);
   return TRUE;
 }
 
@@ -10858,7 +11123,7 @@
 	return FALSE;
 
       /* If the src and dest have different interworking flags
-         then turn off the interworking bit.  */
+	 then turn off the interworking bit.  */
       if ((in_flags & EF_ARM_INTERWORK) != (out_flags & EF_ARM_INTERWORK))
 	{
 	  if (out_flags & EF_ARM_INTERWORK)
@@ -11112,6 +11377,24 @@
       T(V7E_M),  /* V6S_M.  */
       T(V7E_M)   /* V7E_M.  */
     };
+  const int v8[] =
+    {
+      T(V8),		/* PRE_V4.  */
+      T(V8),		/* V4.  */
+      T(V8),		/* V4T.  */
+      T(V8),		/* V5T.  */
+      T(V8),		/* V5TE.  */
+      T(V8),		/* V5TEJ.  */
+      T(V8),		/* V6.  */
+      T(V8),		/* V6KZ.  */
+      T(V8),		/* V6T2.  */
+      T(V8),		/* V6K.  */
+      T(V8),		/* V7.  */
+      T(V8),		/* V6_M.  */
+      T(V8),		/* V6S_M.  */
+      T(V8),		/* V7E_M.  */
+      T(V8)		/* V8.  */
+    };
   const int v4t_plus_v6_m[] =
     {
       -1,		/* PRE_V4.  */
@@ -11128,6 +11411,7 @@
       T(V6_M),		/* V6_M.  */
       T(V6S_M),		/* V6S_M.  */
       T(V7E_M),		/* V7E_M.  */
+      T(V8),		/* V8.  */
       T(V4T_PLUS_V6_M)	/* V4T plus V6_M.  */
     };
   const int *comb[] =
@@ -11138,6 +11422,7 @@
       v6_m,
       v6s_m,
       v7e_m,
+      v8,
       /* Pseudo-architecture.  */
       v4t_plus_v6_m
     };
@@ -11193,6 +11478,46 @@
 #undef T
 }
 
+/* Query attributes object to see if integer divide instructions may be
+   present in an object.  */
+static bfd_boolean
+elf32_arm_attributes_accept_div (const obj_attribute *attr)
+{
+  int arch = attr[Tag_CPU_arch].i;
+  int profile = attr[Tag_CPU_arch_profile].i;
+
+  switch (attr[Tag_DIV_use].i)
+    {
+    case 0:
+      /* Integer divide allowed if instruction contained in archetecture.  */
+      if (arch == TAG_CPU_ARCH_V7 && (profile == 'R' || profile == 'M'))
+	return TRUE;
+      else if (arch >= TAG_CPU_ARCH_V7E_M)
+	return TRUE;
+      else
+	return FALSE;
+
+    case 1:
+      /* Integer divide explicitly prohibited.  */
+      return FALSE;
+
+    default:
+      /* Unrecognised case - treat as allowing divide everywhere.  */
+    case 2:
+      /* Integer divide allowed in ARM state.  */
+      return TRUE;
+    }
+}
+
+/* Query attributes object to see if integer divide instructions are
+   forbidden to be in the object.  This is not the inverse of
+   elf32_arm_attributes_accept_div.  */
+static bfd_boolean
+elf32_arm_attributes_forbid_div (const obj_attribute *attr)
+{
+  return attr[Tag_DIV_use].i == 1;
+}
+
 /* Merge EABI object attributes from IBFD into OBFD.  Raise an error if there
    are conflicting attributes.  */
 
@@ -11230,7 +11555,7 @@
 	{
 	  if (out_attr[Tag_MPextension_use].i != 0
 	      && out_attr[Tag_MPextension_use_legacy].i
-	        != out_attr[Tag_MPextension_use].i)
+		!= out_attr[Tag_MPextension_use].i)
 	    {
 	      _bfd_error_handler
 		(_("Error: %B has both the current and legacy "
@@ -11299,7 +11624,8 @@
 		"ARM v6K",
 		"ARM v7",
 		"ARM v6-M",
-		"ARM v6S-M"
+		"ARM v6S-M",
+		"ARM v8"
 	    };
 
 	    /* Merge Tag_CPU_arch and Tag_also_compatible_with.  */
@@ -11417,7 +11743,7 @@
 	      /* 0 will merge with anything.
 		 'A' and 'S' merge to 'A'.
 		 'R' and 'S' merge to 'R'.
-	         'M' and 'A|R|S' is an error.  */
+		 'M' and 'A|R|S' is an error.  */
 	      if (out_attr[i].i == 0
 		  || (out_attr[i].i == 'S'
 		      && (in_attr[i].i == 'A' || in_attr[i].i == 'R')))
@@ -11444,11 +11770,12 @@
 		 when it's 0.  It might mean absence of FP hardware if
 		 Tag_FP_arch is zero, otherwise it is effectively SP + DP.  */
 
+#define VFP_VERSION_COUNT 8
 	      static const struct
 	      {
 		  int ver;
 		  int regs;
-	      } vfp_versions[7] =
+	      } vfp_versions[VFP_VERSION_COUNT] =
 		{
 		  {0, 0},
 		  {1, 16},
@@ -11456,7 +11783,8 @@
 		  {3, 32},
 		  {3, 16},
 		  {4, 32},
-		  {4, 16}
+		  {4, 16},
+		  {8, 32}
 		};
 	      int ver;
 	      int regs;
@@ -11496,9 +11824,10 @@
 
 	      /* Now we can handle Tag_FP_arch.  */
 
-	      /* Values greater than 6 aren't defined, so just pick the
-	         biggest */
-	      if (in_attr[i].i > 6 && in_attr[i].i > out_attr[i].i)
+	      /* Values of VFP_VERSION_COUNT or more aren't defined, so just
+		 pick the biggest.  */
+	      if (in_attr[i].i >= VFP_VERSION_COUNT
+		  && in_attr[i].i > out_attr[i].i)
 		{
 		  out_attr[i] = in_attr[i];
 		  break;
@@ -11512,8 +11841,8 @@
 	      if (regs < vfp_versions[out_attr[i].i].regs)
 		regs = vfp_versions[out_attr[i].i].regs;
 	      /* This assumes all possible supersets are also a valid
-	         options.  */
-	      for (newval = 6; newval > 0; newval--)
+		 options.  */
+	      for (newval = VFP_VERSION_COUNT - 1; newval > 0; newval--)
 		{
 		  if (regs == vfp_versions[newval].regs
 		      && ver == vfp_versions[newval].ver)
@@ -11525,10 +11854,10 @@
 	case Tag_PCS_config:
 	  if (out_attr[i].i == 0)
 	    out_attr[i].i = in_attr[i].i;
-	  else if (in_attr[i].i != 0 && out_attr[i].i != 0)
+	  else if (in_attr[i].i != 0 && out_attr[i].i != in_attr[i].i)
 	    {
 	      /* It's sometimes ok to mix different configs, so this is only
-	         a warning.  */
+		 a warning.  */
 	      _bfd_error_handler
 		(_("Warning: %B: Conflicting platform configuration"), ibfd);
 	    }
@@ -11634,29 +11963,22 @@
 	  break;
 
 	case Tag_DIV_use:
-	  /* This tag is set to zero if we can use UDIV and SDIV in Thumb
-	     mode on a v7-M or v7-R CPU; to one if we can not use UDIV or
-	     SDIV at all; and to two if we can use UDIV or SDIV on a v7-A
-	     CPU.  We will merge as follows: If the input attribute's value
-	     is one then the output attribute's value remains unchanged.  If
-	     the input attribute's value is zero or two then if the output
-	     attribute's value is one the output value is set to the input
-	     value, otherwise the output value must be the same as the
-	     inputs.  */ 
-	  if (in_attr[i].i != 1 && out_attr[i].i != 1) 
-	    { 
-	      if (in_attr[i].i != out_attr[i].i)
-		{
-		  _bfd_error_handler
-		    (_("DIV usage mismatch between %B and %B"),
-		     ibfd, obfd); 
-		  result = FALSE;
-		}
-	    } 
-
-	  if (in_attr[i].i != 1)
-	    out_attr[i].i = in_attr[i].i; 
-	  
+	  /* A value of zero on input means that the divide instruction may
+	     be used if available in the base architecture as specified via
+	     Tag_CPU_arch and Tag_CPU_arch_profile.  A value of 1 means that
+	     the user did not want divide instructions.  A value of 2
+	     explicitly means that divide instructions were allowed in ARM
+	     and Thumb state.  */
+	  if (in_attr[i].i == out_attr[i].i)
+	    /* Do nothing.  */ ;
+	  else if (elf32_arm_attributes_forbid_div (in_attr)
+		   && !elf32_arm_attributes_accept_div (out_attr))
+	    out_attr[i].i = 1;
+	  else if (elf32_arm_attributes_forbid_div (out_attr)
+		   && elf32_arm_attributes_accept_div (in_attr))
+	    out_attr[i].i = in_attr[i].i;
+	  else if (in_attr[i].i == 2)
+	    out_attr[i].i = in_attr[i].i;
 	  break;
 
 	case Tag_MPextension_use_legacy:
@@ -11668,7 +11990,7 @@
 		{
 		  _bfd_error_handler
 		    (_("%B has has both the current and legacy "
-		       "Tag_MPextension_use attributes"), 
+		       "Tag_MPextension_use attributes"),
 		     ibfd);
 		  result = FALSE;
 		}
@@ -11838,6 +12160,15 @@
 
     case EF_ARM_EABI_VER5:
       fprintf (file, _(" [Version5 EABI]"));
+
+      if (flags & EF_ARM_ABI_FLOAT_SOFT)
+	fprintf (file, _(" [soft-float ABI]"));
+
+      if (flags & EF_ARM_ABI_FLOAT_HARD)
+	fprintf (file, _(" [hard-float ABI]"));
+
+      flags &= ~(EF_ARM_ABI_FLOAT_SOFT | EF_ARM_ABI_FLOAT_HARD);
+
     eabi:
       if (flags & EF_ARM_BE8)
 	fprintf (file, _(" [BE8]"));
@@ -12048,8 +12379,19 @@
       if (may_need_local_target_p
 	  && elf32_arm_get_plt_info (abfd, eh, r_symndx, &root_plt, &arm_plt))
 	{
-	  BFD_ASSERT (root_plt->refcount > 0);
-	  root_plt->refcount -= 1;
+	  /* If PLT refcount book-keeping is wrong and too low, we'll
+	     see a zero value (going to -1) for the root PLT reference
+	     count.  */
+	  if (root_plt->refcount >= 0)
+	    {
+	      BFD_ASSERT (root_plt->refcount != 0);
+	      root_plt->refcount -= 1;
+	    }
+	  else
+	    /* A value of -1 means the symbol has become local, forced
+	       or seeing a hidden definition.  Any other negative value
+	       is an error.  */
+	    BFD_ASSERT (root_plt->refcount == -1);
 
 	  if (!call_reloc_p)
 	    arm_plt->noncall_refcount--;
@@ -12142,7 +12484,7 @@
   symtab_hdr = & elf_symtab_hdr (abfd);
   sym_hashes = elf_sym_hashes (abfd);
   nsyms = NUM_SHDR_ENTRIES (symtab_hdr);
-  
+
   rel_end = relocs + sec->reloc_count;
   for (rel = relocs; rel < rel_end; rel++)
     {
@@ -12185,6 +12527,10 @@
 	      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;
+
+	      /* PR15323, ref flags aren't set for references in the
+		 same object.  */
+	      h->root.non_ir_ref = 1;
 	    }
 	}
 
@@ -12197,7 +12543,7 @@
       /* Could be done earlier, if h were already available.  */
       r_type = elf32_arm_tls_transition (info, r_type, h);
       switch (r_type)
-        {
+	{
 	  case R_ARM_GOT32:
 	  case R_ARM_GOT_PREL:
 	  case R_ARM_TLS_GD32:
@@ -12214,14 +12560,14 @@
 	      switch (r_type)
 		{
 		case R_ARM_TLS_GD32: tls_type = GOT_TLS_GD; break;
-		  
+
 		case R_ARM_TLS_IE32: tls_type = GOT_TLS_IE; break;
-		  
+
 		case R_ARM_TLS_GOTDESC:
 		case R_ARM_TLS_CALL: case R_ARM_THM_TLS_CALL:
 		case R_ARM_TLS_DESCSEQ: case R_ARM_THM_TLS_DESCSEQ:
 		  tls_type = GOT_TLS_GDESC; break;
-		  
+
 		default: tls_type = GOT_NORMAL; break;
 		}
 
@@ -12240,7 +12586,7 @@
 		}
 
 	      /* If a variable is accessed with both tls methods, two
-	         slots may be created.  */
+		 slots may be created.  */
 	      if (GOT_TLS_GD_ANY_P (old_tls_type)
 		  && GOT_TLS_GD_ANY_P (tls_type))
 		tls_type |= old_tls_type;
@@ -12253,9 +12599,9 @@
 		tls_type |= old_tls_type;
 
 	      /* If the symbol is accessed in both IE and GDESC
-	         method, we're able to relax. Turn off the GDESC flag,
-	         without messing up with any other kind of tls types
-	         that may be involved */
+		 method, we're able to relax. Turn off the GDESC flag,
+		 without messing up with any other kind of tls types
+		 that may be involved */
 	      if ((tls_type & GOT_TLS_IE) && (tls_type & GOT_TLS_GDESC))
 		tls_type &= ~GOT_TLS_GDESC;
 
@@ -12352,22 +12698,22 @@
 	      may_need_local_target_p = TRUE;
 	    break;
 
-        /* This relocation describes the C++ object vtable hierarchy.
-           Reconstruct it for later use during GC.  */
-        case R_ARM_GNU_VTINHERIT:
-          if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
-            return FALSE;
-          break;
+	/* This relocation describes the C++ object vtable hierarchy.
+	   Reconstruct it for later use during GC.  */
+	case R_ARM_GNU_VTINHERIT:
+	  if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+	    return FALSE;
+	  break;
 
-        /* This relocation describes which C++ vtable entries are actually
-           used.  Record for later use during GC.  */
-        case R_ARM_GNU_VTENTRY:
-          BFD_ASSERT (h != NULL);
-          if (h != NULL
-              && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
-            return FALSE;
-          break;
-        }
+	/* This relocation describes which C++ vtable entries are actually
+	   used.  Record for later use during GC.  */
+	case R_ARM_GNU_VTENTRY:
+	  BFD_ASSERT (h != NULL);
+	  if (h != NULL
+	      && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
+	    return FALSE;
+	  break;
+	}
 
       if (h != NULL)
 	{
@@ -12410,7 +12756,8 @@
 
 	  /* If the symbol is a function that doesn't bind locally,
 	     this relocation will need a PLT entry.  */
-	  root_plt->refcount += 1;
+	  if (root_plt->refcount != -1)
+	    root_plt->refcount += 1;
 
 	  if (!call_reloc_p)
 	    arm_plt->noncall_refcount++;
@@ -12623,7 +12970,8 @@
 
   /* We skip _bfd_dwarf1_find_nearest_line since no known ARM toolchain uses it.  */
 
-  if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
+  if (_bfd_dwarf2_find_nearest_line (abfd, dwarf_debug_sections,
+				     section, symbols, offset,
 				     filename_ptr, functionname_ptr,
 				     line_ptr, NULL, 0,
 				     & elf_tdata (abfd)->dwarf2_find_line_info))
@@ -12770,13 +13118,6 @@
   if (info->shared || globals->root.is_relocatable_executable)
     return TRUE;
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-			     h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -12786,18 +13127,18 @@
      determine the address it must put in the global offset table, so
      both the dynamic object and the regular object will refer to the
      same memory location for the variable.  */
-  s = bfd_get_section_by_name (dynobj, ".dynbss");
+  s = bfd_get_linker_section (dynobj, ".dynbss");
   BFD_ASSERT (s != NULL);
 
   /* We must generate a R_ARM_COPY reloc to tell the dynamic linker to
      copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rel(a).bss section we are going to use.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       asection *srel;
 
-      srel = bfd_get_section_by_name (dynobj, RELOC_SECTION (globals, ".bss"));
+      srel = bfd_get_linker_section (dynobj, RELOC_SECTION (globals, ".bss"));
       elf32_arm_allocate_dynrelocs (info, srel, 1);
       h->needs_copy = 1;
     }
@@ -12941,18 +13282,18 @@
 	    s->size += 4;
 	  else
 	    {
-              if (tls_type & GOT_TLS_GDESC)
-	        {
+	      if (tls_type & GOT_TLS_GDESC)
+		{
 		  /* R_ARM_TLS_DESC needs 2 GOT slots.  */
-	          eh->tlsdesc_got
+		  eh->tlsdesc_got
 		    = (htab->root.sgotplt->size
 		       - elf32_arm_compute_jump_table_size (htab));
-	          htab->root.sgotplt->size += 8;
-	          h->got.offset = (bfd_vma) -2;
+		  htab->root.sgotplt->size += 8;
+		  h->got.offset = (bfd_vma) -2;
 		  /* plt.got_offset needs to know there's a TLS_DESC
 		     reloc in the middle of .got.plt.  */
-                  htab->num_tls_desc++;
-	        }
+		  htab->num_tls_desc++;
+		}
 
 	      if (tls_type & GOT_TLS_GD)
 		{
@@ -12987,7 +13328,7 @@
 	      if (tls_type & GOT_TLS_GD)
 		elf32_arm_allocate_dynrelocs (info, htab->root.srelgot, 1);
 
-	      if (tls_type & GOT_TLS_GDESC) 
+	      if (tls_type & GOT_TLS_GDESC)
 		{
 		  elf32_arm_allocate_dynrelocs (info, htab->root.srelplt, 1);
 		  /* GDESC needs a trampoline to jump to.  */
@@ -12996,10 +13337,10 @@
 
 	      /* Only GD needs it.  GDESC just emits one relocation per
 		 2 entries.  */
-	      if ((tls_type & GOT_TLS_GD) && indx != 0)  
+	      if ((tls_type & GOT_TLS_GD) && indx != 0)
 		elf32_arm_allocate_dynrelocs (info, htab->root.srelgot, 1);
 	    }
-	  else if (!SYMBOL_REFERENCES_LOCAL (info, h))
+	  else if (indx != -1 && !SYMBOL_REFERENCES_LOCAL (info, h))
 	    {
 	      if (htab->root.dynamic_sections_created)
 		/* Reserve room for the GOT entry's R_ARM_GLOB_DAT relocation.  */
@@ -13011,7 +13352,8 @@
 	       they all resolve dynamically instead.  Reserve room for the
 	       GOT entry's R_ARM_IRELATIVE relocation.  */
 	    elf32_arm_allocate_irelocs (info, htab->root.srelgot, 1);
-	  else if (info->shared)
+	  else if (info->shared && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+				    || h->root.type != bfd_link_hash_undefweak))
 	    /* Reserve room for the GOT entry's R_ARM_RELATIVE relocation.  */
 	    elf32_arm_allocate_dynrelocs (info, htab->root.srelgot, 1);
 	}
@@ -13064,11 +13406,11 @@
   if (info->shared || htab->root.is_relocatable_executable)
     {
       /* The only relocs that use pc_count are R_ARM_REL32 and
-         R_ARM_REL32_NOI, which will appear on something like
-         ".long foo - .".  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 then they
-         should avoid writing assembly like ".long foo - .".  */
+	 R_ARM_REL32_NOI, which will appear on something like
+	 ".long foo - .".  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 then they
+	 should avoid writing assembly like ".long foo - .".  */
       if (SYMBOL_CALLS_LOCAL (info, h))
 	{
 	  struct elf_dyn_relocs **pp;
@@ -13098,7 +13440,7 @@
 	}
 
       /* Also discard relocs on undefined weak syms with non-default
-         visibility.  */
+	 visibility.  */
       if (eh->dyn_relocs != NULL
 	  && h->root.type == bfd_link_hash_undefweak)
 	{
@@ -13239,7 +13581,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
@@ -13269,7 +13611,7 @@
 	  struct elf_dyn_relocs *p;
 
 	  for (p = (struct elf_dyn_relocs *)
-                   elf_section_data (s)->local_dynrel; p != NULL; p = p->next)
+		   elf_section_data (s)->local_dynrel; p != NULL; p = p->next)
 	    {
 	      if (!bfd_is_abs_section (p->sec)
 		  && bfd_is_abs_section (p->sec->output_section))
@@ -13365,7 +13707,7 @@
 		  *local_got = (bfd_vma) -2;
 		  /* plt.got_offset needs to know there's a TLS_DESC
 		     reloc in the middle of .got.plt.  */
-                  htab->num_tls_desc++;
+		  htab->num_tls_desc++;
 		}
 	      if (*local_tls_type & GOT_TLS_IE)
 		s->size += 4;
@@ -13389,14 +13731,18 @@
 		  && (local_iplt == NULL
 		      || local_iplt->arm.noncall_refcount == 0))
 		elf32_arm_allocate_irelocs (info, srel, 1);
-	      else if ((info->shared && !(*local_tls_type & GOT_TLS_GDESC))
-		       || *local_tls_type & GOT_TLS_GD)
-		elf32_arm_allocate_dynrelocs (info, srel, 1);
-
-	      if (info->shared && *local_tls_type & GOT_TLS_GDESC)
+	      else if (info->shared || output_bfd->flags & DYNAMIC)
 		{
-		  elf32_arm_allocate_dynrelocs (info, htab->root.srelplt, 1);
-		  htab->tls_trampoline = -1;
+		  if ((info->shared && !(*local_tls_type & GOT_TLS_GDESC))
+		      || *local_tls_type & GOT_TLS_GD)
+		    elf32_arm_allocate_dynrelocs (info, srel, 1);
+
+		  if (info->shared && *local_tls_type & GOT_TLS_GDESC)
+		    {
+		      elf32_arm_allocate_dynrelocs (info,
+						    htab->root.srelplt, 1);
+		      htab->tls_trampoline = -1;
+		    }
 		}
 	    }
 	  else
@@ -13431,8 +13777,8 @@
 
       if (!bfd_elf32_arm_process_before_allocation (ibfd, info)
 	  || !bfd_elf32_arm_vfp11_erratum_scan (ibfd, info))
-        /* xgettext:c-format */
-        _bfd_error_handler (_("Errors encountered processing file %s"),
+	/* xgettext:c-format */
+	_bfd_error_handler (_("Errors encountered processing file %s"),
 			    ibfd->filename);
     }
 
@@ -13451,12 +13797,12 @@
     {
       if (htab->root.splt->size == 0)
 	htab->root.splt->size += htab->plt_header_size;
-      
+
       htab->tls_trampoline = htab->root.splt->size;
       htab->root.splt->size += htab->plt_entry_size;
-      
+
       /* If we're not using lazy TLS relocations, don't generate the
-         PLT and GOT entries they require.  */
+	 PLT and GOT entries they require.  */
       if (!(info->flags & DF_BIND_NOW))
 	{
 	  htab->dt_tlsdesc_got = htab->root.sgot->size;
@@ -13562,9 +13908,9 @@
 	    return FALSE;
 
 	  if (htab->dt_tlsdesc_plt &&
-		(!add_dynamic_entry (DT_TLSDESC_PLT,0) 
+		(!add_dynamic_entry (DT_TLSDESC_PLT,0)
 		 || !add_dynamic_entry (DT_TLSDESC_GOT,0)))
-	    return FALSE; 
+	    return FALSE;
 	}
 
       if (relocs)
@@ -13610,7 +13956,7 @@
 
 static bfd_boolean
 elf32_arm_always_size_sections (bfd *output_bfd,
-	                        struct bfd_link_info *info)
+				struct bfd_link_info *info)
 {
   asection *tls_sec;
 
@@ -13627,22 +13973,22 @@
 	(elf_hash_table (info), "_TLS_MODULE_BASE_", TRUE, TRUE, FALSE);
 
       if (tlsbase)
-        {
-          struct bfd_link_hash_entry *bh = NULL;
+	{
+	  struct bfd_link_hash_entry *bh = NULL;
 	  const struct elf_backend_data *bed
-            = get_elf_backend_data (output_bfd);
+	    = get_elf_backend_data (output_bfd);
 
-          if (!(_bfd_generic_link_add_one_symbol
+	  if (!(_bfd_generic_link_add_one_symbol
 		(info, output_bfd, "_TLS_MODULE_BASE_", BSF_LOCAL,
 		 tls_sec, 0, NULL, FALSE,
 		 bed->collect, &bh)))
 	    return FALSE;
-	  
-      	  tlsbase->type = STT_TLS;
-          tlsbase = (struct elf_link_hash_entry *)bh;
-          tlsbase->def_regular = 1;
-          tlsbase->other = STV_HIDDEN;
-          (*bed->elf_backend_hide_symbol) (info, tlsbase, TRUE);
+
+	  tlsbase->type = STT_TLS;
+	  tlsbase = (struct elf_link_hash_entry *)bh;
+	  tlsbase->def_regular = 1;
+	  tlsbase->other = STV_HIDDEN;
+	  (*bed->elf_backend_hide_symbol) (info, tlsbase, TRUE);
 	}
     }
   return TRUE;
@@ -13725,7 +14071,7 @@
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  On VxWorks,
      the _GLOBAL_OFFSET_TABLE_ symbol is not absolute: it is relative
      to the ".got" section.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+  if (h == htab->root.hdynamic
       || (!htab->vxworks_p && h == htab->root.hgot))
     sym->st_shndx = SHN_ABS;
 
@@ -13738,7 +14084,7 @@
 		    const unsigned long *template, unsigned count)
 {
   unsigned ix;
-  
+
   for (ix = 0; ix != count; ix++)
     {
       unsigned long insn = template[ix];
@@ -13750,6 +14096,38 @@
     }
 }
 
+/* Install the special first PLT entry for elf32-arm-nacl.  Unlike
+   other variants, NaCl needs this entry in a static executable's
+   .iplt too.  When we're handling that case, GOT_DISPLACEMENT is
+   zero.  For .iplt really only the last bundle is useful, and .iplt
+   could have a shorter first entry, with each individual PLT entry's
+   relative branch calculated differently so it targets the last
+   bundle instead of the instruction before it (labelled .Lplt_tail
+   above).  But it's simpler to keep the size and layout of PLT0
+   consistent with the dynamic case, at the cost of some dead code at
+   the start of .iplt and the one dead store to the stack at the start
+   of .Lplt_tail.  */
+static void
+arm_nacl_put_plt0 (struct elf32_arm_link_hash_table *htab, bfd *output_bfd,
+		   asection *plt, bfd_vma got_displacement)
+{
+  unsigned int i;
+
+  put_arm_insn (htab, output_bfd,
+		elf32_arm_nacl_plt0_entry[0]
+		| arm_movw_immediate (got_displacement),
+		plt->contents + 0);
+  put_arm_insn (htab, output_bfd,
+		elf32_arm_nacl_plt0_entry[1]
+		| arm_movt_immediate (got_displacement),
+		plt->contents + 4);
+
+  for (i = 2; i < ARRAY_SIZE (elf32_arm_nacl_plt0_entry); ++i)
+    put_arm_insn (htab, output_bfd,
+		  elf32_arm_nacl_plt0_entry[i],
+		  plt->contents + (i * 4));
+}
+
 /* Finish up the dynamic sections.  */
 
 static bfd_boolean
@@ -13771,7 +14149,7 @@
      Catch this here so that we do not seg-fault later on.  */
   if (sgot != NULL && bfd_is_abs_section (sgot->output_section))
     return FALSE;
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (elf_hash_table (info)->dynamic_sections_created)
     {
@@ -13829,7 +14207,14 @@
 	      name = RELOC_SECTION (htab, ".plt");
 	    get_vma:
 	      s = bfd_get_section_by_name (output_bfd, name);
-	      BFD_ASSERT (s != NULL);
+	      if (s == NULL)
+		{
+		  /* PR ld/14397: Issue an error message if a required section is missing.  */
+		  (*_bfd_error_handler)
+		    (_("error: required section '%s' not found in the linker script"), name);
+		  bfd_set_error (bfd_error_invalid_operation);
+		  return FALSE;
+		}
 	      if (!htab->symbian_p)
 		dyn.d_un.d_ptr = s->vma;
 	      else
@@ -13908,16 +14293,16 @@
 	      break;
 
 	    case DT_TLSDESC_PLT:
-              s = htab->root.splt;
+	      s = htab->root.splt;
 	      dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset
 				+ htab->dt_tlsdesc_plt);
 	      bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
 	      break;
 
 	    case DT_TLSDESC_GOT:
-              s = htab->root.sgot;
+	      s = htab->root.sgot;
 	      dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset
-		      		+ htab->dt_tlsdesc_got);
+				+ htab->dt_tlsdesc_got);
 	      bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
 	      break;
 
@@ -13980,6 +14365,9 @@
 	      SWAP_RELOC_OUT (htab) (output_bfd, &rel,
 				     htab->srelplt2->contents);
 	    }
+	  else if (htab->nacl_p)
+	    arm_nacl_put_plt0 (htab, output_bfd, splt,
+			       got_address + 8 - (plt_address + 16));
 	  else
 	    {
 	      got_displacement = got_address - (plt_address + 16);
@@ -14018,7 +14406,7 @@
 	  bfd_vma plt_address
 	    = splt->output_section->vma + splt->output_offset;
 
-	  arm_put_trampoline (htab, output_bfd, 
+	  arm_put_trampoline (htab, output_bfd,
 			      splt->contents + htab->dt_tlsdesc_plt,
 			      dl_tlsdesc_lazy_trampoline, 6);
 
@@ -14035,13 +14423,13 @@
 
       if (htab->tls_trampoline)
 	{
-	  arm_put_trampoline (htab, output_bfd, 
+	  arm_put_trampoline (htab, output_bfd,
 			      splt->contents + htab->tls_trampoline,
 			      tls_trampoline, 3);
 #ifdef FOUR_WORD_PLT
 	  bfd_put_32 (output_bfd, 0x00000000,
 		      splt->contents + htab->tls_trampoline + 12);
-#endif 
+#endif
 	}
 
       if (htab->vxworks_p && !info->shared && htab->root.splt->size > 0)
@@ -14072,6 +14460,10 @@
 	}
     }
 
+  if (htab->nacl_p && htab->root.iplt != NULL && htab->root.iplt->size > 0)
+    /* NaCl uses a special first entry in .iplt too.  */
+    arm_nacl_put_plt0 (htab, output_bfd, htab->root.iplt, 0);
+
   /* Fill in the first three entries in the global offset table.  */
   if (sgot)
     {
@@ -14113,10 +14505,22 @@
       if (globals != NULL && globals->byteswap_code)
 	i_ehdrp->e_flags |= EF_ARM_BE8;
     }
+
+  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)))
+    {
+      int abi = bfd_elf_get_obj_attr_int (abfd, OBJ_ATTR_PROC, Tag_ABI_VFP_args);
+      if (abi)
+	i_ehdrp->e_flags |= EF_ARM_ABI_FLOAT_HARD;
+      else
+	i_ehdrp->e_flags |= EF_ARM_ABI_FLOAT_SOFT;
+    }
 }
 
 static enum elf_reloc_type_class
-elf32_arm_reloc_type_class (const Elf_Internal_Rela *rela)
+elf32_arm_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			    const asection *rel_sec ATTRIBUTE_UNUSED,
+			    const Elf_Internal_Rela *rela)
 {
   switch ((int) ELF32_R_TYPE (rela->r_info))
     {
@@ -14208,7 +14612,7 @@
 
 typedef struct
 {
-  void *finfo;
+  void *flaginfo;
   struct bfd_link_info *info;
   asection *sec;
   int sec_shndx;
@@ -14243,7 +14647,7 @@
   sym.st_shndx = osi->sec_shndx;
   sym.st_target_internal = 0;
   elf32_arm_section_map_add (osi->sec, names[type][1], offset);
-  return osi->func (osi->finfo, names[type], &sym, osi->sec, NULL) == 1;
+  return osi->func (osi->flaginfo, names[type], &sym, osi->sec, NULL) == 1;
 }
 
 /* Output mapping symbols for the PLT entry described by ROOT_PLT and ARM_PLT.
@@ -14297,6 +14701,11 @@
       if (!elf32_arm_output_map_sym (osi, ARM_MAP_DATA, addr + 20))
 	return FALSE;
     }
+  else if (htab->nacl_p)
+    {
+      if (!elf32_arm_output_map_sym (osi, ARM_MAP_ARM, addr))
+	return FALSE;
+    }
   else
     {
       bfd_boolean thumb_stub_p;
@@ -14365,7 +14774,7 @@
   sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FUNC);
   sym.st_shndx = osi->sec_shndx;
   sym.st_target_internal = 0;
-  return osi->func (osi->finfo, name, &sym, osi->sec, NULL) == 1;
+  return osi->func (osi->flaginfo, name, &sym, osi->sec, NULL) == 1;
 }
 
 static bfd_boolean
@@ -14477,7 +14886,7 @@
 static bfd_boolean
 elf32_arm_output_arch_local_syms (bfd *output_bfd,
 				  struct bfd_link_info *info,
-				  void *finfo,
+				  void *flaginfo,
 				  int (*func) (void *, const char *,
 					       Elf_Internal_Sym *,
 					       asection *,
@@ -14495,7 +14904,7 @@
 
   check_use_blx (htab);
 
-  osi.finfo = finfo;
+  osi.flaginfo = flaginfo;
   osi.info = info;
   osi.func = func;
 
@@ -14532,8 +14941,8 @@
   /* ARM->Thumb glue.  */
   if (htab->arm_glue_size > 0)
     {
-      osi.sec = bfd_get_section_by_name (htab->bfd_of_glue_owner,
-					 ARM2THUMB_GLUE_SECTION_NAME);
+      osi.sec = bfd_get_linker_section (htab->bfd_of_glue_owner,
+					ARM2THUMB_GLUE_SECTION_NAME);
 
       osi.sec_shndx = _bfd_elf_section_from_bfd_section
 	  (output_bfd, osi.sec->output_section);
@@ -14555,8 +14964,8 @@
   /* Thumb->ARM glue.  */
   if (htab->thumb_glue_size > 0)
     {
-      osi.sec = bfd_get_section_by_name (htab->bfd_of_glue_owner,
-					 THUMB2ARM_GLUE_SECTION_NAME);
+      osi.sec = bfd_get_linker_section (htab->bfd_of_glue_owner,
+					THUMB2ARM_GLUE_SECTION_NAME);
 
       osi.sec_shndx = _bfd_elf_section_from_bfd_section
 	  (output_bfd, osi.sec->output_section);
@@ -14572,8 +14981,8 @@
   /* ARMv4 BX veneers.  */
   if (htab->bx_glue_size > 0)
     {
-      osi.sec = bfd_get_section_by_name (htab->bfd_of_glue_owner,
-					 ARM_BX_GLUE_SECTION_NAME);
+      osi.sec = bfd_get_linker_section (htab->bfd_of_glue_owner,
+					ARM_BX_GLUE_SECTION_NAME);
 
       osi.sec_shndx = _bfd_elf_section_from_bfd_section
 	  (output_bfd, osi.sec->output_section);
@@ -14623,6 +15032,11 @@
 		return FALSE;
 	    }
 	}
+      else if (htab->nacl_p)
+	{
+	  if (!elf32_arm_output_map_sym (&osi, ARM_MAP_ARM, 0))
+	    return FALSE;
+	}
       else if (!htab->symbian_p)
 	{
 	  if (!elf32_arm_output_map_sym (&osi, ARM_MAP_ARM, 0))
@@ -14633,6 +15047,15 @@
 #endif
 	}
     }
+  if (htab->nacl_p && htab->root.iplt && htab->root.iplt->size > 0)
+    {
+      /* NaCl uses a special first entry in .iplt too.  */
+      osi.sec = htab->root.iplt;
+      osi.sec_shndx = (_bfd_elf_section_from_bfd_section
+		       (output_bfd, osi.sec->output_section));
+      if (!elf32_arm_output_map_sym (&osi, ARM_MAP_ARM, 0))
+	return FALSE;
+    }
   if ((htab->root.splt && htab->root.splt->size > 0)
       || (htab->root.iplt && htab->root.iplt->size > 0))
     {
@@ -14662,7 +15085,7 @@
       /* Mapping symbols for the lazy tls trampoline.  */
       if (!elf32_arm_output_map_sym (&osi, ARM_MAP_ARM, htab->dt_tlsdesc_plt))
 	return FALSE;
-       
+
       if (!elf32_arm_output_map_sym (&osi, ARM_MAP_DATA,
 				     htab->dt_tlsdesc_plt + 24))
 	return FALSE;
@@ -14676,9 +15099,9 @@
       if (!elf32_arm_output_map_sym (&osi, ARM_MAP_DATA,
 				     htab->tls_trampoline + 12))
 	return FALSE;
-#endif 
+#endif
     }
-  
+
   return TRUE;
 }
 
@@ -14741,23 +15164,24 @@
 {
   unsigned long first_word = bfd_get_32 (output_bfd, from);
   unsigned long second_word = bfd_get_32 (output_bfd, from + 4);
-  
+
   /* High bit of first word is supposed to be zero.  */
   if ((first_word & 0x80000000ul) == 0)
     first_word = offset_prel31 (first_word, offset);
-  
+
   /* If the high bit of the first word is clear, and the bit pattern is not 0x1
      (EXIDX_CANTUNWIND), this is an offset to an .ARM.extab entry.  */
   if ((second_word != 0x1) && ((second_word & 0x80000000ul) == 0))
     second_word = offset_prel31 (second_word, offset);
-  
+
   bfd_put_32 (output_bfd, first_word, to);
   bfd_put_32 (output_bfd, second_word, to + 4);
 }
 
 /* Data for make_branch_to_a8_stub().  */
 
-struct a8_branch_to_stub_data {
+struct a8_branch_to_stub_data
+{
   asection *writing_section;
   bfd_byte *contents;
 };
@@ -14768,7 +15192,7 @@
 
 static bfd_boolean
 make_branch_to_a8_stub (struct bfd_hash_entry *gen_entry,
-                       void *in_arg)
+		       void *in_arg)
 {
   struct elf32_arm_stub_hash_entry *stub_entry;
   struct a8_branch_to_stub_data *data;
@@ -14907,82 +15331,82 @@
       unsigned int endianflip = bfd_big_endian (output_bfd) ? 3 : 0;
 
       for (errnode = arm_data->erratumlist; errnode != 0;
-           errnode = errnode->next)
-        {
-          bfd_vma target = errnode->vma - offset;
+	   errnode = errnode->next)
+	{
+	  bfd_vma target = errnode->vma - offset;
 
-          switch (errnode->type)
-            {
-            case VFP11_ERRATUM_BRANCH_TO_ARM_VENEER:
-              {
-                bfd_vma branch_to_veneer;
-                /* Original condition code of instruction, plus bit mask for
-                   ARM B instruction.  */
-                unsigned int insn = (errnode->u.b.vfp_insn & 0xf0000000)
-                                  | 0x0a000000;
+	  switch (errnode->type)
+	    {
+	    case VFP11_ERRATUM_BRANCH_TO_ARM_VENEER:
+	      {
+		bfd_vma branch_to_veneer;
+		/* Original condition code of instruction, plus bit mask for
+		   ARM B instruction.  */
+		unsigned int insn = (errnode->u.b.vfp_insn & 0xf0000000)
+				  | 0x0a000000;
 
 		/* The instruction is before the label.  */
 		target -= 4;
 
 		/* Above offset included in -4 below.  */
 		branch_to_veneer = errnode->u.b.veneer->vma
-                                   - errnode->vma - 4;
+				   - errnode->vma - 4;
 
 		if ((signed) branch_to_veneer < -(1 << 25)
 		    || (signed) branch_to_veneer >= (1 << 25))
 		  (*_bfd_error_handler) (_("%B: error: VFP11 veneer out of "
 					   "range"), output_bfd);
 
-                insn |= (branch_to_veneer >> 2) & 0xffffff;
-                contents[endianflip ^ target] = insn & 0xff;
-                contents[endianflip ^ (target + 1)] = (insn >> 8) & 0xff;
-                contents[endianflip ^ (target + 2)] = (insn >> 16) & 0xff;
-                contents[endianflip ^ (target + 3)] = (insn >> 24) & 0xff;
-              }
-              break;
+		insn |= (branch_to_veneer >> 2) & 0xffffff;
+		contents[endianflip ^ target] = insn & 0xff;
+		contents[endianflip ^ (target + 1)] = (insn >> 8) & 0xff;
+		contents[endianflip ^ (target + 2)] = (insn >> 16) & 0xff;
+		contents[endianflip ^ (target + 3)] = (insn >> 24) & 0xff;
+	      }
+	      break;
 
 	    case VFP11_ERRATUM_ARM_VENEER:
-              {
-                bfd_vma branch_from_veneer;
-                unsigned int insn;
+	      {
+		bfd_vma branch_from_veneer;
+		unsigned int insn;
 
-                /* Take size of veneer into account.  */
-                branch_from_veneer = errnode->u.v.branch->vma
-                                     - errnode->vma - 12;
+		/* Take size of veneer into account.  */
+		branch_from_veneer = errnode->u.v.branch->vma
+				     - errnode->vma - 12;
 
 		if ((signed) branch_from_veneer < -(1 << 25)
 		    || (signed) branch_from_veneer >= (1 << 25))
 		  (*_bfd_error_handler) (_("%B: error: VFP11 veneer out of "
 					   "range"), output_bfd);
 
-                /* Original instruction.  */
-                insn = errnode->u.v.branch->u.b.vfp_insn;
-                contents[endianflip ^ target] = insn & 0xff;
-                contents[endianflip ^ (target + 1)] = (insn >> 8) & 0xff;
-                contents[endianflip ^ (target + 2)] = (insn >> 16) & 0xff;
-                contents[endianflip ^ (target + 3)] = (insn >> 24) & 0xff;
+		/* Original instruction.  */
+		insn = errnode->u.v.branch->u.b.vfp_insn;
+		contents[endianflip ^ target] = insn & 0xff;
+		contents[endianflip ^ (target + 1)] = (insn >> 8) & 0xff;
+		contents[endianflip ^ (target + 2)] = (insn >> 16) & 0xff;
+		contents[endianflip ^ (target + 3)] = (insn >> 24) & 0xff;
 
-                /* Branch back to insn after original insn.  */
-                insn = 0xea000000 | ((branch_from_veneer >> 2) & 0xffffff);
-                contents[endianflip ^ (target + 4)] = insn & 0xff;
-                contents[endianflip ^ (target + 5)] = (insn >> 8) & 0xff;
-                contents[endianflip ^ (target + 6)] = (insn >> 16) & 0xff;
-                contents[endianflip ^ (target + 7)] = (insn >> 24) & 0xff;
-              }
-              break;
+		/* Branch back to insn after original insn.  */
+		insn = 0xea000000 | ((branch_from_veneer >> 2) & 0xffffff);
+		contents[endianflip ^ (target + 4)] = insn & 0xff;
+		contents[endianflip ^ (target + 5)] = (insn >> 8) & 0xff;
+		contents[endianflip ^ (target + 6)] = (insn >> 16) & 0xff;
+		contents[endianflip ^ (target + 7)] = (insn >> 24) & 0xff;
+	      }
+	      break;
 
-            default:
-              abort ();
-            }
-        }
+	    default:
+	      abort ();
+	    }
+	}
     }
 
   if (arm_data->elf.this_hdr.sh_type == SHT_ARM_EXIDX)
     {
       arm_unwind_table_edit *edit_node
-        = arm_data->u.exidx.unwind_edit_list;
+	= arm_data->u.exidx.unwind_edit_list;
       /* Now, sec->size is the size of the section we will write.  The original
-         size (before we merged duplicate entries and inserted EXIDX_CANTUNWIND
+	 size (before we merged duplicate entries and inserted EXIDX_CANTUNWIND
 	 markers) was sec->rawsize.  (This isn't the case if we perform no
 	 edits, then rawsize will be zero and we should use size).  */
       bfd_byte *edited_contents = (bfd_byte *) bfd_malloc (sec->size);
@@ -14991,13 +15415,13 @@
       bfd_vma add_to_offsets = 0;
 
       for (in_index = 0, out_index = 0; in_index * 8 < input_size || edit_node;)
-        {
+	{
 	  if (edit_node)
 	    {
 	      unsigned int edit_index = edit_node->index;
-	      
+
 	      if (in_index < edit_index && in_index * 8 < input_size)
-	        {
+		{
 		  copy_exidx_entry (output_bfd, edited_contents + out_index * 8,
 				    contents + in_index * 8, add_to_offsets);
 		  out_index++;
@@ -15006,22 +15430,22 @@
 	      else if (in_index == edit_index
 		       || (in_index * 8 >= input_size
 			   && edit_index == UINT_MAX))
-	        {
+		{
 		  switch (edit_node->type)
 		    {
 		    case DELETE_EXIDX_ENTRY:
 		      in_index++;
 		      add_to_offsets += 8;
 		      break;
-		    
+
 		    case INSERT_EXIDX_CANTUNWIND_AT_END:
 		      {
-		        asection *text_sec = edit_node->linked_section;
+			asection *text_sec = edit_node->linked_section;
 			bfd_vma text_offset = text_sec->output_section->vma
 					      + text_sec->output_offset
 					      + text_sec->size;
 			bfd_vma exidx_offset = offset + out_index * 8;
-		        unsigned long prel31_offset;
+			unsigned long prel31_offset;
 
 			/* Note: this is meant to be equivalent to an
 			   R_ARM_PREL31 relocation.  These synthetic
@@ -15043,7 +15467,7 @@
 		      }
 		      break;
 		    }
-		  
+
 		  edit_node = edit_node->next;
 		}
 	    }
@@ -15086,45 +15510,45 @@
 
       ptr = map[0].vma;
       for (i = 0; i < mapcount; i++)
-        {
-          if (i == mapcount - 1)
+	{
+	  if (i == mapcount - 1)
 	    end = sec->size;
-          else
-            end = map[i + 1].vma;
+	  else
+	    end = map[i + 1].vma;
 
-          switch (map[i].type)
+	  switch (map[i].type)
 	    {
 	    case 'a':
 	      /* Byte swap code words.  */
 	      while (ptr + 3 < end)
-	        {
-	          tmp = contents[ptr];
-	          contents[ptr] = contents[ptr + 3];
-	          contents[ptr + 3] = tmp;
-	          tmp = contents[ptr + 1];
-	          contents[ptr + 1] = contents[ptr + 2];
-	          contents[ptr + 2] = tmp;
-	          ptr += 4;
-	        }
+		{
+		  tmp = contents[ptr];
+		  contents[ptr] = contents[ptr + 3];
+		  contents[ptr + 3] = tmp;
+		  tmp = contents[ptr + 1];
+		  contents[ptr + 1] = contents[ptr + 2];
+		  contents[ptr + 2] = tmp;
+		  ptr += 4;
+		}
 	      break;
 
 	    case 't':
 	      /* Byte swap code halfwords.  */
 	      while (ptr + 1 < end)
-	        {
-	          tmp = contents[ptr];
-	          contents[ptr] = contents[ptr + 1];
-	          contents[ptr + 1] = tmp;
-	          ptr += 2;
-	        }
+		{
+		  tmp = contents[ptr];
+		  contents[ptr] = contents[ptr + 1];
+		  contents[ptr + 1] = tmp;
+		  ptr += 2;
+		}
 	      break;
 
 	    case 'd':
 	      /* Leave data alone.  */
 	      break;
 	    }
-          ptr = end;
-        }
+	  ptr = end;
+	}
     }
 
   free (map);
@@ -15193,17 +15617,17 @@
       if (ELF_ST_TYPE (src->st_info) != STT_GNU_IFUNC)
 	newsym.st_info = ELF_ST_INFO (ELF_ST_BIND (src->st_info), STT_FUNC);
       if (newsym.st_shndx != SHN_UNDEF)
-        {
-          /* Do this only for defined symbols. At link type, the static
-             linker will simulate the work of dynamic linker of resolving
-             symbols and will carry over the thumbness of found symbols to
-             the output symbol table. It's not clear how it happens, but
-             the thumbness of undefined symbols can well be different at
-             runtime, and writing '1' for them will be confusing for users
-             and possibly for dynamic linker itself.
-          */
-          newsym.st_value |= 1;
-        }
+	{
+	  /* Do this only for defined symbols. At link type, the static
+	     linker will simulate the work of dynamic linker of resolving
+	     symbols and will carry over the thumbness of found symbols to
+	     the output symbol table. It's not clear how it happens, but
+	     the thumbness of undefined symbols can well be different at
+	     runtime, and writing '1' for them will be confusing for users
+	     and possibly for dynamic linker itself.
+	  */
+	  newsym.st_value |= 1;
+	}
 
       src = &newsym;
     }
@@ -15225,21 +15649,21 @@
       /* If there is already a PT_ARM_EXIDX header, then we do not
 	 want to add another one.  This situation arises when running
 	 "strip"; the input binary already has the header.  */
-      m = elf_tdata (abfd)->segment_map;
+      m = elf_seg_map (abfd);
       while (m && m->p_type != PT_ARM_EXIDX)
 	m = m->next;
       if (!m)
 	{
 	  m = (struct elf_segment_map *)
-              bfd_zalloc (abfd, sizeof (struct elf_segment_map));
+	      bfd_zalloc (abfd, sizeof (struct elf_segment_map));
 	  if (m == NULL)
 	    return FALSE;
 	  m->p_type = PT_ARM_EXIDX;
 	  m->count = 1;
 	  m->sections[0] = sec;
 
-	  m->next = elf_tdata (abfd)->segment_map;
-	  elf_tdata (abfd)->segment_map = m;
+	  m->next = elf_seg_map (abfd);
+	  elf_seg_map (abfd) = m;
 	}
     }
 
@@ -15333,7 +15757,7 @@
 #define bfd_elf32_bfd_link_hash_table_create    elf32_arm_link_hash_table_create
 #define bfd_elf32_bfd_link_hash_table_free      elf32_arm_hash_table_free
 #define bfd_elf32_bfd_reloc_type_lookup		elf32_arm_reloc_type_lookup
-#define bfd_elf32_bfd_reloc_name_lookup	elf32_arm_reloc_name_lookup
+#define bfd_elf32_bfd_reloc_name_lookup		elf32_arm_reloc_name_lookup
 #define bfd_elf32_find_nearest_line	        elf32_arm_find_nearest_line
 #define bfd_elf32_find_inliner_info	        elf32_arm_find_inliner_info
 #define bfd_elf32_new_section_hook		elf32_arm_new_section_hook
@@ -15387,11 +15811,98 @@
 #define elf_backend_obj_attrs_arg_type		elf32_arm_obj_attrs_arg_type
 #undef  elf_backend_obj_attrs_section_type
 #define elf_backend_obj_attrs_section_type	SHT_ARM_ATTRIBUTES
-#define elf_backend_obj_attrs_order	elf32_arm_obj_attrs_order
-#define elf_backend_obj_attrs_handle_unknown elf32_arm_obj_attrs_handle_unknown
+#define elf_backend_obj_attrs_order		elf32_arm_obj_attrs_order
+#define elf_backend_obj_attrs_handle_unknown 	elf32_arm_obj_attrs_handle_unknown
 
 #include "elf32-target.h"
 
+/* Native Client targets.  */
+
+#undef	TARGET_LITTLE_SYM
+#define TARGET_LITTLE_SYM		bfd_elf32_littlearm_nacl_vec
+#undef	TARGET_LITTLE_NAME
+#define TARGET_LITTLE_NAME		"elf32-littlearm-nacl"
+#undef	TARGET_BIG_SYM
+#define TARGET_BIG_SYM			bfd_elf32_bigarm_nacl_vec
+#undef	TARGET_BIG_NAME
+#define TARGET_BIG_NAME			"elf32-bigarm-nacl"
+
+/* Like elf32_arm_link_hash_table_create -- but overrides
+   appropriately for NaCl.  */
+
+static struct bfd_link_hash_table *
+elf32_arm_nacl_link_hash_table_create (bfd *abfd)
+{
+  struct bfd_link_hash_table *ret;
+
+  ret = elf32_arm_link_hash_table_create (abfd);
+  if (ret)
+    {
+      struct elf32_arm_link_hash_table *htab
+	= (struct elf32_arm_link_hash_table *) ret;
+
+      htab->nacl_p = 1;
+
+      htab->plt_header_size = 4 * ARRAY_SIZE (elf32_arm_nacl_plt0_entry);
+      htab->plt_entry_size = 4 * ARRAY_SIZE (elf32_arm_nacl_plt_entry);
+    }
+  return ret;
+}
+
+/* Since NaCl doesn't use the ARM-specific unwind format, we don't
+   really need to use elf32_arm_modify_segment_map.  But we do it
+   anyway just to reduce gratuitous differences with the stock ARM backend.  */
+
+static bfd_boolean
+elf32_arm_nacl_modify_segment_map (bfd *abfd, struct bfd_link_info *info)
+{
+  return (elf32_arm_modify_segment_map (abfd, info)
+	  && nacl_modify_segment_map (abfd, info));
+}
+
+static void
+elf32_arm_nacl_final_write_processing (bfd *abfd, bfd_boolean linker)
+{
+  elf32_arm_final_write_processing (abfd, linker);
+  nacl_final_write_processing (abfd, linker);
+}
+
+
+#undef	elf32_bed
+#define elf32_bed			elf32_arm_nacl_bed
+#undef  bfd_elf32_bfd_link_hash_table_create
+#define bfd_elf32_bfd_link_hash_table_create	\
+  elf32_arm_nacl_link_hash_table_create
+#undef	elf_backend_plt_alignment
+#define elf_backend_plt_alignment	4
+#undef	elf_backend_modify_segment_map
+#define	elf_backend_modify_segment_map		elf32_arm_nacl_modify_segment_map
+#undef	elf_backend_modify_program_headers
+#define	elf_backend_modify_program_headers	nacl_modify_program_headers
+#undef  elf_backend_final_write_processing
+#define elf_backend_final_write_processing	elf32_arm_nacl_final_write_processing
+
+#undef	ELF_MAXPAGESIZE
+#define ELF_MAXPAGESIZE			0x10000
+#undef	ELF_MINPAGESIZE
+#undef	ELF_COMMONPAGESIZE
+
+
+#include "elf32-target.h"
+
+/* Reset to defaults.  */
+#undef	elf_backend_plt_alignment
+#undef	elf_backend_modify_segment_map
+#define elf_backend_modify_segment_map		elf32_arm_modify_segment_map
+#undef	elf_backend_modify_program_headers
+#undef  elf_backend_final_write_processing
+#define elf_backend_final_write_processing	elf32_arm_final_write_processing
+#undef	ELF_MINPAGESIZE
+#define ELF_MINPAGESIZE			0x1000
+#undef	ELF_COMMONPAGESIZE
+#define ELF_COMMONPAGESIZE		0x1000
+
+
 /* VxWorks Targets.  */
 
 #undef  TARGET_LITTLE_SYM
@@ -15501,8 +16012,8 @@
 	 flags then do not bother setting the flags for the output
 	 architecture, instead allow future merges to do this.  If no
 	 future merges ever set these flags then they will retain their
-         uninitialised values, which surprise surprise, correspond
-         to the default values.  */
+	 uninitialised values, which surprise surprise, correspond
+	 to the default values.  */
       if (bfd_get_arch_info (ibfd)->the_default
 	  && elf_elfheader (ibfd)->e_flags == 0)
 	return TRUE;
@@ -15550,7 +16061,7 @@
 	      if ((bfd_get_section_flags (ibfd, sec)
 		   & (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS))
 		  == (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS))
-	    	only_data_sections = FALSE;
+		only_data_sections = FALSE;
 
 	      null_input_bfd = FALSE;
 	      break;
@@ -15765,15 +16276,15 @@
   dynsec = bfd_get_section_by_name (abfd, ".dynamic");
   if (dynsec)
     {
-      for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+      for (m = elf_seg_map (abfd); m != NULL; m = m->next)
 	if (m->p_type == PT_DYNAMIC)
 	  break;
 
       if (m == NULL)
 	{
 	  m = _bfd_elf_make_dynamic_segment (abfd, dynsec);
-	  m->next = elf_tdata (abfd)->segment_map;
-	  elf_tdata (abfd)->segment_map = m;
+	  m->next = elf_seg_map (abfd);
+	  elf_seg_map (abfd) = m;
 	}
     }
 
diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c
index 6d20aef..43100cd 100644
--- a/bfd/elf32-avr.c
+++ b/bfd/elf32-avr.c
@@ -1,6 +1,5 @@
 /* AVR-specific support for 32-bit ELF
-   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-   2010, 2011  Free Software Foundation, Inc.
+   Copyright 1999-2013 Free Software Foundation, Inc.
    Contributed by Denis Chertykov <[email protected]>
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -516,6 +515,48 @@
 	 0x000000ff,		/* src_mask */
 	 0x000000ff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
+  /* lo8-part to use in  .byte lo8(sym).  */
+  HOWTO (R_AVR_8_LO8,		/* type */
+	 0,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 8,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_AVR_8_LO8",		/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffff,		/* src_mask */
+	 0xffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+  /* hi8-part to use in  .byte hi8(sym).  */
+  HOWTO (R_AVR_8_HI8,		/* type */
+	 8,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 8,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_AVR_8_HI8",		/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffff,		/* src_mask */
+	 0xffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+  /* hlo8-part to use in  .byte hlo8(sym).  */
+  HOWTO (R_AVR_8_HLO8,		/* type */
+	 16,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 8,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_AVR_8_HLO8",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffff,		/* src_mask */
+	 0xffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
 };
 
 /* Map BFD reloc types to AVR ELF reloc types.  */
@@ -554,7 +595,10 @@
   { BFD_RELOC_AVR_LDI,              R_AVR_LDI  },
   { BFD_RELOC_AVR_6,                R_AVR_6    },
   { BFD_RELOC_AVR_6_ADIW,           R_AVR_6_ADIW },
-  { BFD_RELOC_8,                    R_AVR_8 }
+  { BFD_RELOC_8,                    R_AVR_8 },
+  { BFD_RELOC_AVR_8_LO,             R_AVR_8_LO8 },
+  { BFD_RELOC_AVR_8_HI,             R_AVR_8_HI8 },
+  { BFD_RELOC_AVR_8_HLO,            R_AVR_8_HLO8 }
 };
 
 /* Meant to be filled one day with the wrap around address for the
@@ -626,7 +670,7 @@
   struct elf32_avr_link_hash_table *htab;
   bfd_size_type amt = sizeof (*htab);
 
-  htab = bfd_malloc (amt);
+  htab = bfd_zmalloc (amt);
   if (htab == NULL)
     return NULL;
 
@@ -644,15 +688,6 @@
                             sizeof (struct elf32_avr_stub_hash_entry)))
     return NULL;
 
-  htab->stub_bfd = NULL;
-  htab->stub_sec = NULL;
-
-  /* Initialize the address mapping table.  */
-  htab->amt_stub_offsets = NULL;
-  htab->amt_destination_addr = NULL;
-  htab->amt_entry_cnt = 0;
-  htab->amt_max_entry_cnt = 0;
-
   return &htab->etab.root;
 }
 
@@ -671,7 +706,7 @@
     free (htab->amt_destination_addr);
 
   bfd_hash_table_free (&htab->bstab);
-  _bfd_generic_link_hash_table_free (btab);
+  _bfd_elf_link_hash_table_free (btab);
 }
 
 /* Calculates the effective distance of a pc relative jump/call.  */
@@ -1189,9 +1224,9 @@
 	  name = h->root.root.string;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -1503,11 +1538,18 @@
        bfd_vma symval;
        bfd_vma shrinked_insn_address;
 
+       if (isec->reloc_count == 0)
+	 continue;
+
        shrinked_insn_address = (sec->output_section->vma
                                 + sec->output_offset + addr - count);
 
-       irelend = elf_section_data (isec)->relocs + isec->reloc_count;
-       for (irel = elf_section_data (isec)->relocs;
+       irel = elf_section_data (isec)->relocs;
+       /* PR 12161: Read in the relocs for this section if necessary.  */
+       if (irel == NULL)
+         irel = _bfd_elf_link_read_relocs (abfd, isec, NULL, NULL, TRUE);
+
+       for (irelend = irel + isec->reloc_count;
             irel < irelend;
             irel++)
          {
@@ -1649,6 +1691,16 @@
   Elf_Internal_Sym *isymbuf = NULL;
   struct elf32_avr_link_hash_table *htab;
 
+  /* If 'shrinkable' is FALSE, do not shrink by deleting bytes while
+     relaxing. Such shrinking can cause issues for the sections such
+     as .vectors and .jumptables. Instead the unused bytes should be
+     filled with nop instructions. */
+  bfd_boolean shrinkable = TRUE;
+
+  if (!strcmp (sec->name,".vectors")
+      || !strcmp (sec->name,".jumptables"))
+    shrinkable = FALSE;
+
   if (link_info->relocatable)
     (*link_info->callbacks->einfo)
       (_("%P%F: --relax and -r may not be used together\n"));
@@ -1805,10 +1857,16 @@
             /* Compute the distance from this insn to the branch target.  */
             gap = value - dot;
 
-            /* If the distance is within -4094..+4098 inclusive, then we can
-               relax this jump/call.  +4098 because the call/jump target
-               will be closer after the relaxation.  */
-            if ((int) gap >= -4094 && (int) gap <= 4098)
+            /* Check if the gap falls in the range that can be accommodated
+               in 13bits signed (It is 12bits when encoded, as we deal with
+               word addressing). */
+            if (!shrinkable && ((int) gap >= -4096 && (int) gap <= 4095))
+              distance_short_enough = 1;
+            /* If shrinkable, then we can check for a range of distance which
+               is two bytes farther on both the directions because the call
+               or jump target will be closer by two bytes after the
+               relaxation. */
+            else if (shrinkable && ((int) gap >= -4094 && (int) gap <= 4097))
               distance_short_enough = 1;
 
             /* Here we handle the wrap-around case.  E.g. for a 16k device
@@ -1882,11 +1940,9 @@
                 irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
                                              R_AVR_13_PCREL);
 
-                /* Check for the vector section. There we don't want to
-                   modify the ordering!  */
-
-                if (!strcmp (sec->name,".vectors")
-                    || !strcmp (sec->name,".jumptables"))
+                /* We should not modify the ordering if 'shrinkable' is
+                   FALSE. */
+                if (!shrinkable)
                   {
                     /* Let's insert a nop.  */
                     bfd_put_8 (abfd, 0x00, contents + irel->r_offset + 2);
@@ -2080,6 +2136,7 @@
 			  irel->r_offset + insn_size;
                         Elf_Internal_Sym *isym, *isymend;
                         unsigned int sec_shndx;
+			struct bfd_section *isec;
 
                         sec_shndx =
 			  _bfd_elf_section_from_bfd_section (abfd, sec);
@@ -2130,80 +2187,85 @@
 				}
 			    }
 			}
+
 			/* Now we check for relocations pointing to ret.  */
-			{
-			  Elf_Internal_Rela *rel;
-			  Elf_Internal_Rela *relend;
+			for (isec = abfd->sections; isec && deleting_ret_is_safe; isec = isec->next)
+			  {
+			    Elf_Internal_Rela *rel;
+			    Elf_Internal_Rela *relend;
+              
+			    rel = elf_section_data (isec)->relocs;
+			    if (rel == NULL)
+			      rel = _bfd_elf_link_read_relocs (abfd, isec, NULL, NULL, TRUE);
 
-			  relend = elf_section_data (sec)->relocs
-			    + sec->reloc_count;
+			    relend = rel + isec->reloc_count;
 
-			  for (rel = elf_section_data (sec)->relocs;
-			       rel < relend; rel++)
-			    {
-			      bfd_vma reloc_target = 0;
+			    for (; rel && rel < relend; rel++)
+			      {
+				bfd_vma reloc_target = 0;
 
-			      /* Read this BFD's local symbols if we haven't
-				 done so already.  */
-			      if (isymbuf == NULL && symtab_hdr->sh_info != 0)
-				{
-				  isymbuf = (Elf_Internal_Sym *)
-				    symtab_hdr->contents;
-				  if (isymbuf == NULL)
-				    isymbuf = bfd_elf_get_elf_syms
-				      (abfd,
-				       symtab_hdr,
-				       symtab_hdr->sh_info, 0,
-				       NULL, NULL, NULL);
-				  if (isymbuf == NULL)
+				/* Read this BFD's local symbols if we haven't
+				   done so already.  */
+				if (isymbuf == NULL && symtab_hdr->sh_info != 0)
+				  {
+				    isymbuf = (Elf_Internal_Sym *)
+				      symtab_hdr->contents;
+				    if (isymbuf == NULL)
+				      isymbuf = bfd_elf_get_elf_syms
+					(abfd,
+					 symtab_hdr,
+					 symtab_hdr->sh_info, 0,
+					 NULL, NULL, NULL);
+				    if (isymbuf == NULL)
+				      break;
+				  }
+
+				/* Get the value of the symbol referred to
+				   by the reloc.  */
+				if (ELF32_R_SYM (rel->r_info)
+				    < symtab_hdr->sh_info)
+				  {
+				    /* A local symbol.  */
+				    asection *sym_sec;
+
+				    isym = isymbuf
+				      + ELF32_R_SYM (rel->r_info);
+				    sym_sec = bfd_section_from_elf_index
+				      (abfd, isym->st_shndx);
+				    symval = isym->st_value;
+
+				    /* If the reloc is absolute, it will not
+				       have a symbol or section associated
+				       with it.  */
+
+				    if (sym_sec)
+				      {
+					symval +=
+					  sym_sec->output_section->vma
+					  + sym_sec->output_offset;
+					reloc_target = symval + rel->r_addend;
+				      }
+				    else
+				      {
+					reloc_target = symval + rel->r_addend;
+					/* Reference symbol is absolute.  */
+				      }
+				  }
+				/* else ... reference symbol is extern.  */
+
+				if (address_of_ret == reloc_target)
+				  {
+				    deleting_ret_is_safe = 0;
+				    if (debug_relax)
+				      printf ("ret from "
+					      "rjmp/jmp ret sequence at address"
+					      " 0x%x could not be deleted. ret"
+					      " is target of a relocation.\n",
+					      (int) address_of_ret);
 				    break;
-				}
-
-			      /* Get the value of the symbol referred to
-				 by the reloc.  */
-			      if (ELF32_R_SYM (rel->r_info)
-				  < symtab_hdr->sh_info)
-				{
-				  /* A local symbol.  */
-				  asection *sym_sec;
-
-				  isym = isymbuf
-				    + ELF32_R_SYM (rel->r_info);
-				  sym_sec = bfd_section_from_elf_index
-				    (abfd, isym->st_shndx);
-				  symval = isym->st_value;
-
-				  /* If the reloc is absolute, it will not
-				     have a symbol or section associated
-				     with it.  */
-
-				  if (sym_sec)
-				    {
-				      symval +=
-					sym_sec->output_section->vma
-					+ sym_sec->output_offset;
-				      reloc_target = symval + rel->r_addend;
-				    }
-				  else
-				    {
-				      reloc_target = symval + rel->r_addend;
-				      /* Reference symbol is absolute.  */
-				    }
-				}
-			      /* else ... reference symbol is extern.  */
-
-			      if (address_of_ret == reloc_target)
-				{
-				  deleting_ret_is_safe = 0;
-				  if (debug_relax)
-				    printf ("ret from "
-					    "rjmp/jmp ret sequence at address"
-					    " 0x%x could not be deleted. ret"
-					    " is target of a relocation.\n",
-					    (int) address_of_ret);
-				}
-			    }
-			}
+				  }
+			      }
+			  }
 
 			if (deleting_ret_is_safe)
 			  {
@@ -2224,7 +2286,6 @@
 			    break;
 			  }
                       }
-
                   }
               }
             break;
diff --git a/bfd/elf32-avr.h b/bfd/elf32-avr.h
index 5ca1fdf..5eeca86 100644
--- a/bfd/elf32-avr.h
+++ b/bfd/elf32-avr.h
@@ -17,7 +17,7 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, 
+   Foundation, Inc., 51 Franklin Street - Fifth Floor,
    Boston, MA 02110-1301, USA.  */
 
 
diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c
index b112dfc..d3d0f1c 100644
--- a/bfd/elf32-bfin.c
+++ b/bfd/elf32-bfin.c
@@ -1,5 +1,5 @@
 /* ADI Blackfin BFD support for 32-bit ELF.
-   Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -34,7 +34,7 @@
      bfd *abfd ATTRIBUTE_UNUSED,
      arelent *reloc_entry ATTRIBUTE_UNUSED,
      asymbol *symbol ATTRIBUTE_UNUSED,
-     PTR data ATTRIBUTE_UNUSED,
+     void * data ATTRIBUTE_UNUSED,
      asection *input_section ATTRIBUTE_UNUSED,
      bfd *output_bfd ATTRIBUTE_UNUSED,
      char **error_message ATTRIBUTE_UNUSED)
@@ -48,7 +48,7 @@
 bfin_pcrel24_reloc (bfd *abfd,
                     arelent *reloc_entry,
                     asymbol *symbol,
-                    PTR data,
+                    void * data,
                     asection *input_section,
                     bfd *output_bfd,
                     char **error_message ATTRIBUTE_UNUSED)
@@ -145,7 +145,7 @@
 bfin_imm16_reloc (bfd *abfd,
      		  arelent *reloc_entry,
      		  asymbol *symbol,
-     		  PTR data,
+     		  void * data,
      		  asection *input_section,
      		  bfd *output_bfd,
      		  char **error_message ATTRIBUTE_UNUSED)
@@ -217,7 +217,7 @@
 bfin_byte4_reloc (bfd *abfd,
                   arelent *reloc_entry,
                   asymbol *symbol,
-                  PTR data,
+                  void * data,
                   asection *input_section,
                   bfd *output_bfd,
                   char **error_message ATTRIBUTE_UNUSED)
@@ -283,7 +283,7 @@
 bfin_bfd_reloc (bfd *abfd,
 		arelent *reloc_entry,
      		asymbol *symbol,
-     		PTR data,
+     		void * data,
      		asection *input_section,
      		bfd *output_bfd,
      		char **error_message ATTRIBUTE_UNUSED)
@@ -1109,7 +1109,7 @@
 /* Given a bfin relocation type, return the howto.  */
 static reloc_howto_type *
 bfin_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
-			    unsigned int r_type)
+			unsigned int r_type)
 {
   if (r_type <= BFIN_RELOC_MAX)
     return &bfin_howto_table [r_type];
@@ -1139,9 +1139,7 @@
 /* Return TRUE if the name is a local label.
    bfin local labels begin with L$.  */
 static bfd_boolean
-bfin_is_local_label_name (
-     bfd *abfd,
-     const char *label)
+bfin_is_local_label_name (bfd *abfd, const char *label)
 {
   if (label[0] == 'L' && label[1] == '$' )
     return TRUE;
@@ -1167,6 +1165,7 @@
   const Elf_Internal_Rela *rel_end;
   asection *sgot;
   asection *srelgot;
+
   if (info->relocatable)
     return TRUE;
 
@@ -1188,7 +1187,13 @@
       if (r_symndx < symtab_hdr->sh_info)
 	h = NULL;
       else
-	h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+	{
+	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
+	}
 
       switch (ELF32_R_TYPE (rel->r_info))
 	{
@@ -1224,20 +1229,21 @@
 
 	  if (sgot == NULL)
 	    {
-	      sgot = bfd_get_section_by_name (dynobj, ".got");
+	      sgot = bfd_get_linker_section (dynobj, ".got");
 	      BFD_ASSERT (sgot != NULL);
 	    }
 
 	  if (srelgot == NULL && (h != NULL || info->shared))
 	    {
-	      srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+	      srelgot = bfd_get_linker_section (dynobj, ".rela.got");
 	      if (srelgot == NULL)
 		{
 		  flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
 				    | SEC_IN_MEMORY | SEC_LINKER_CREATED
 				    | SEC_READONLY);
-		  srelgot = bfd_make_section_with_flags (dynobj, ".rela.got",
-							 flags);
+		  srelgot = bfd_make_section_anyway_with_flags (dynobj,
+								".rela.got",
+								flags);
 		  if (srelgot == NULL
 		      || !bfd_set_section_alignment (dynobj, srelgot, 2))
 		    return FALSE;
@@ -1301,7 +1307,9 @@
 }
 
 static enum elf_reloc_type_class
-elf32_bfin_reloc_type_class (const Elf_Internal_Rela * rela)
+elf32_bfin_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			     const asection *rel_sec ATTRIBUTE_UNUSED,
+			     const Elf_Internal_Rela * rela)
 {
   switch ((int) ELF32_R_TYPE (rela->r_info))
     {
@@ -1444,9 +1452,9 @@
 				   unresolved_reloc, warned);
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -1483,7 +1491,7 @@
 
 	    if (sgot == NULL)
 	      {
-		sgot = bfd_get_section_by_name (dynobj, ".got");
+		sgot = bfd_get_linker_section (dynobj, ".got");
 		BFD_ASSERT (sgot != NULL);
 	      }
 
@@ -1547,7 +1555,7 @@
 			Elf_Internal_Rela outrel;
 			bfd_byte *loc;
 
-			s = bfd_get_section_by_name (dynobj, ".rela.got");
+			s = bfd_get_linker_section (dynobj, ".rela.got");
 			BFD_ASSERT (s != NULL);
 
 			outrel.r_offset = (sgot->output_section->vma
@@ -1585,7 +1593,9 @@
          because such sections are not SEC_ALLOC and thus ld.so will
          not process them.  */
       if (unresolved_reloc
-	  && !((input_section->flags & SEC_DEBUGGING) != 0 && h->def_dynamic))
+	  && !((input_section->flags & SEC_DEBUGGING) != 0 && h->def_dynamic)
+	  && _bfd_elf_section_offset (output_bfd, info, input_section,
+				      rel->r_offset) != (bfd_vma) -1)
 	{
 	  (*_bfd_error_handler)
 	    (_("%B(%A+0x%lx): unresolvable relocation against symbol `%s'"),
@@ -1674,8 +1684,8 @@
   sym_hashes = elf_sym_hashes (abfd);
   local_got_refcounts = elf_local_got_refcounts (abfd);
 
-  sgot = bfd_get_section_by_name (dynobj, ".got");
-  srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+  sgot = bfd_get_linker_section (dynobj, ".got");
+  srelgot = bfd_get_linker_section (dynobj, ".rela.got");
 
   relend = relocs + sec->reloc_count;
   for (rel = relocs; rel < relend; rel++)
@@ -1819,7 +1829,7 @@
   struct bfinfdpic_elf_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct bfinfdpic_elf_link_hash_table);
 
-  ret = bfd_zalloc (abfd, amt);
+  ret = bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
 
@@ -1994,10 +2004,10 @@
    for memory allocation purposes.  */
 inline static struct bfinfdpic_relocs_info *
 bfinfdpic_relocs_info_for_global (struct htab *ht,
-				 bfd *abfd,
-				 struct elf_link_hash_entry *h,
-				 bfd_vma addend,
-				 enum insert_option insert)
+				  bfd *abfd,
+				  struct elf_link_hash_entry *h,
+				  bfd_vma addend,
+				  enum insert_option insert)
 {
   struct bfinfdpic_relocs_info entry;
 
@@ -2032,7 +2042,7 @@
 
 inline static void
 bfinfdpic_pic_merge_early_relocs_info (struct bfinfdpic_relocs_info *e2,
-				      struct bfinfdpic_relocs_info const *e1)
+				       struct bfinfdpic_relocs_info const *e1)
 {
   e2->got17m4 |= e1->got17m4;
   e2->gothilo |= e1->gothilo;
@@ -2098,7 +2108,7 @@
 
 static bfd_vma
 _bfinfdpic_add_rofixup (bfd *output_bfd, asection *rofixup, bfd_vma offset,
-		       struct bfinfdpic_relocs_info *entry)
+			struct bfinfdpic_relocs_info *entry)
 {
   bfd_vma fixup_offset;
 
@@ -2153,9 +2163,8 @@
 					asection *sec,
 					Elf_Internal_Sym *sym,
 					bfd_vma addend)
-
 {
-  bfd_vma fd_lazy_rel_offset = (bfd_vma)-1;
+  bfd_vma fd_lazy_rel_offset = (bfd_vma) -1;
   int dynindx = -1;
 
   if (entry->done)
@@ -2663,9 +2672,9 @@
 	  osec = sec;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -2731,7 +2740,9 @@
 	default:
 	non_fdpic:
 	  picrel = NULL;
-	  if (h && ! BFINFDPIC_SYM_LOCAL (info, h))
+	  if (h && ! BFINFDPIC_SYM_LOCAL (info, h)
+	      && _bfd_elf_section_offset (output_bfd, info, input_section,
+					  rel->r_offset) != (bfd_vma) -1)
 	    {
 	      info->callbacks->warning
 		(info, _("relocation references symbol not defined in the module"),
@@ -3383,8 +3394,8 @@
   int ptralign;
 
   /* This function may be called more than once.  */
-  s = bfd_get_section_by_name (abfd, ".got");
-  if (s != NULL && (s->flags & SEC_LINKER_CREATED) != 0)
+  s = bfd_get_linker_section (abfd, ".got");
+  if (s != NULL)
     return TRUE;
 
   /* Machine specific: although pointers are 32-bits wide, we want the
@@ -3397,14 +3408,14 @@
 	   | SEC_LINKER_CREATED);
   pltflags = flags;
 
-  s = bfd_make_section_with_flags (abfd, ".got", flags);
+  s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
   if (s == NULL
       || !bfd_set_section_alignment (abfd, s, ptralign))
     return FALSE;
 
   if (bed->want_got_plt)
     {
-      s = bfd_make_section_with_flags (abfd, ".got.plt", flags);
+      s = bfd_make_section_anyway_with_flags (abfd, ".got.plt", flags);
       if (s == NULL
 	  || !bfd_set_section_alignment (abfd, s, ptralign))
 	return FALSE;
@@ -3442,8 +3453,8 @@
       if (! bfinfdpic_relocs_info (info))
 	return FALSE;
 
-      s = bfd_make_section_with_flags (abfd, ".rel.got",
-				       (flags | SEC_READONLY));
+      s = bfd_make_section_anyway_with_flags (abfd, ".rel.got",
+					      (flags | SEC_READONLY));
       if (s == NULL
 	  || ! bfd_set_section_alignment (abfd, s, 2))
 	return FALSE;
@@ -3451,8 +3462,8 @@
       bfinfdpic_gotrel_section (info) = s;
 
       /* Machine-specific.  */
-      s = bfd_make_section_with_flags (abfd, ".rofixup",
-				       (flags | SEC_READONLY));
+      s = bfd_make_section_anyway_with_flags (abfd, ".rofixup",
+					      (flags | SEC_READONLY));
       if (s == NULL
 	  || ! bfd_set_section_alignment (abfd, s, 2))
 	return FALSE;
@@ -3466,7 +3477,7 @@
   if (bed->plt_readonly)
     pltflags |= SEC_READONLY;
 
-  s = bfd_make_section_with_flags (abfd, ".plt", pltflags);
+  s = bfd_make_section_anyway_with_flags (abfd, ".plt", pltflags);
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
     return FALSE;
@@ -3493,7 +3504,8 @@
     }
 
   /* Blackfin-specific: we want rel relocations for the plt.  */
-  s = bfd_make_section_with_flags (abfd, ".rel.plt", flags | SEC_READONLY);
+  s = bfd_make_section_anyway_with_flags (abfd, ".rel.plt",
+					  flags | SEC_READONLY);
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
     return FALSE;
@@ -3539,27 +3551,27 @@
 	 image and use a R_*_COPY reloc to tell the dynamic linker to
 	 initialize them at run time.  The linker script puts the .dynbss
 	 section into the .bss section of the final image.  */
-      s = bfd_make_section_with_flags (abfd, ".dynbss",
-				       SEC_ALLOC | SEC_LINKER_CREATED);
+      s = bfd_make_section_anyway_with_flags (abfd, ".dynbss",
+					      SEC_ALLOC | SEC_LINKER_CREATED);
       if (s == NULL)
 	return FALSE;
 
       /* The .rel[a].bss section holds copy relocs.  This section is not
-     normally needed.  We need to create it here, though, so that the
-     linker will map it to an output section.  We can't just create it
-     only if we need it, because we will not know whether we need it
-     until we have seen all the input files, and the first time the
-     main linker code calls BFD after examining all the input files
-     (size_dynamic_sections) the input sections have already been
-     mapped to the output sections.  If the section turns out not to
-     be needed, we can discard it later.  We will never need this
-     section when generating a shared object, since they do not use
-     copy relocs.  */
+	 normally needed.  We need to create it here, though, so that the
+	 linker will map it to an output section.  We can't just create it
+	 only if we need it, because we will not know whether we need it
+	 until we have seen all the input files, and the first time the
+	 main linker code calls BFD after examining all the input files
+	 (size_dynamic_sections) the input sections have already been
+	 mapped to the output sections.  If the section turns out not to
+	 be needed, we can discard it later.  We will never need this
+	 section when generating a shared object, since they do not use
+	 copy relocs.  */
       if (! info->shared)
 	{
-	  s = bfd_make_section_with_flags (abfd,
-					   ".rela.bss",
-					   flags | SEC_READONLY);
+	  s = bfd_make_section_anyway_with_flags (abfd,
+						  ".rela.bss",
+						  flags | SEC_READONLY);
 	  if (s == NULL
 	      || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
 	    return FALSE;
@@ -4242,7 +4254,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (bfd_byte *) ELF_DYNAMIC_INTERPRETER;
@@ -4292,11 +4304,11 @@
 	  return FALSE;
     }
 
-  s = bfd_get_section_by_name (dynobj, ".dynbss");
+  s = bfd_get_linker_section (dynobj, ".dynbss");
   if (s && s->size == 0)
     s->flags |= SEC_EXCLUDE;
 
-  s = bfd_get_section_by_name (dynobj, ".rela.bss");
+  s = bfd_get_linker_section (dynobj, ".rela.bss");
   if (s && s->size == 0)
     s->flags |= SEC_EXCLUDE;
 
@@ -4307,35 +4319,10 @@
 elf32_bfinfdpic_always_size_sections (bfd *output_bfd,
 				     struct bfd_link_info *info)
 {
-  if (!info->relocatable)
-    {
-      struct elf_link_hash_entry *h;
-
-      /* Force a PT_GNU_STACK segment to be created.  */
-      if (! elf_tdata (output_bfd)->stack_flags)
-	elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X;
-
-      /* Define __stacksize if it's not defined yet.  */
-      h = elf_link_hash_lookup (elf_hash_table (info), "__stacksize",
-				FALSE, FALSE, FALSE);
-      if (! h || h->root.type != bfd_link_hash_defined
-	  || h->type != STT_OBJECT
-	  || !h->def_regular)
-	{
-	  struct bfd_link_hash_entry *bh = NULL;
-
-	  if (!(_bfd_generic_link_add_one_symbol
-		(info, output_bfd, "__stacksize",
-		 BSF_GLOBAL, bfd_abs_section_ptr, DEFAULT_STACK_SIZE,
-		 (const char *) NULL, FALSE,
-		 get_elf_backend_data (output_bfd)->collect, &bh)))
-	    return FALSE;
-
-	  h = (struct elf_link_hash_entry *) bh;
-	  h->def_regular = 1;
-	  h->type = STT_OBJECT;
-	}
-    }
+  if (!info->relocatable
+      && !bfd_elf_stack_segment_size (output_bfd, info,
+				      "__stacksize", DEFAULT_STACK_SIZE))
+    return FALSE;
 
   return TRUE;
 }
@@ -4344,9 +4331,8 @@
    subtract it from the relocation or fixup count.  */
 static bfd_boolean
 _bfinfdpic_check_discarded_relocs (bfd *abfd, asection *sec,
-				  struct bfd_link_info *info,
-				  
-				  bfd_boolean *changed)
+				   struct bfd_link_info *info,
+				   bfd_boolean *changed)
 {
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
@@ -4429,7 +4415,7 @@
 
   /* Account for relaxation of .eh_frame section.  */
   for (s = ibfd->sections; s; s = s->next)
-    if (s->sec_info_type == ELF_INFO_TYPE_EH_FRAME)
+    if (s->sec_info_type == SEC_INFO_TYPE_EH_FRAME)
       {
 	if (!_bfinfdpic_check_discarded_relocs (ibfd, s, info, &changed))
 	  return FALSE;
@@ -4457,51 +4443,6 @@
 }
 
 static bfd_boolean
-elf32_bfinfdpic_modify_program_headers (bfd *output_bfd,
-					struct bfd_link_info *info)
-{
-  struct elf_obj_tdata *tdata = elf_tdata (output_bfd);
-  struct elf_segment_map *m;
-  Elf_Internal_Phdr *p;
-
-  /* objcopy and strip preserve what's already there using
-     elf32_bfinfdpic_copy_private_bfd_data ().  */
-  if (! info)
-    return TRUE;
-
-  for (p = tdata->phdr, m = tdata->segment_map; m != NULL; m = m->next, p++)
-    if (m->p_type == PT_GNU_STACK)
-      break;
-
-  if (m)
-    {
-      struct elf_link_hash_entry *h;
-
-      /* Obtain the pointer to the __stacksize symbol.  */
-      h = elf_link_hash_lookup (elf_hash_table (info), "__stacksize",
-				FALSE, FALSE, FALSE);
-      if (h)
-	{
-	  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;
-	  BFD_ASSERT (h->root.type == bfd_link_hash_defined);
-	}
-
-      /* Set the header p_memsz from the symbol value.  We
-	 intentionally ignore the symbol section.  */
-      if (h && h->root.type == bfd_link_hash_defined)
-	p->p_memsz = h->root.u.def.value;
-      else
-	p->p_memsz = DEFAULT_STACK_SIZE;
-
-      p->p_align = 8;
-    }
-
-  return TRUE;
-}
-
-static bfd_boolean
 elf32_bfinfdpic_finish_dynamic_sections (bfd *output_bfd,
 					struct bfd_link_info *info)
 {
@@ -4542,7 +4483,7 @@
 		      * sizeof (Elf32_External_Rel)));
     }
 
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (elf_hash_table (info)->dynamic_sections_created)
     {
@@ -4594,9 +4535,8 @@
    regular object.  */
 
 static bfd_boolean
-elf32_bfinfdpic_adjust_dynamic_symbol
-(struct bfd_link_info *info,
- struct elf_link_hash_entry *h)
+elf32_bfinfdpic_adjust_dynamic_symbol (struct bfd_link_info *info,
+				       struct elf_link_hash_entry *h)
 {
   bfd * dynobj;
 
@@ -5015,8 +4955,6 @@
 static bfd_boolean
 elf32_bfinfdpic_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
 {
-  unsigned i;
-
   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
     return TRUE;
@@ -5028,38 +4966,13 @@
       || ! elf_tdata (obfd) || ! elf_tdata (obfd)->phdr)
     return TRUE;
 
-  /* Copy the stack size.  */
-  for (i = 0; i < elf_elfheader (ibfd)->e_phnum; i++)
-    if (elf_tdata (ibfd)->phdr[i].p_type == PT_GNU_STACK)
-      {
-	Elf_Internal_Phdr *iphdr = &elf_tdata (ibfd)->phdr[i];
-
-	for (i = 0; i < elf_elfheader (obfd)->e_phnum; i++)
-	  if (elf_tdata (obfd)->phdr[i].p_type == PT_GNU_STACK)
-	    {
-	      memcpy (&elf_tdata (obfd)->phdr[i], iphdr, sizeof (*iphdr));
-
-	      /* Rewrite the phdrs, since we're only called after they
-		 were first written.  */
-	      if (bfd_seek (obfd, (bfd_signed_vma) get_elf_backend_data (obfd)
-			    ->s->sizeof_ehdr, SEEK_SET) != 0
-		  || get_elf_backend_data (obfd)->s
-		  ->write_out_phdrs (obfd, elf_tdata (obfd)->phdr,
-				     elf_elfheader (obfd)->e_phnum) != 0)
-		return FALSE;
-	      break;
-	    }
-
-	break;
-      }
-
   return TRUE;
 }
 
 
 /* Display the flags field.  */
 static bfd_boolean
-elf32_bfin_print_private_bfd_data (bfd * abfd, PTR ptr)
+elf32_bfin_print_private_bfd_data (bfd * abfd, void * ptr)
 {
   FILE *file = (FILE *) ptr;
   flagword flags;
@@ -5183,7 +5096,7 @@
   struct bfin_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct bfin_link_hash_table);
 
-  ret = bfd_zalloc (abfd, amt);
+  ret = bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
 
@@ -5207,14 +5120,14 @@
 
 static bfd_boolean
 bfin_finish_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
-				  struct bfd_link_info *info)
+			      struct bfd_link_info *info)
 {
   bfd *dynobj;
   asection *sdyn;
 
   dynobj = elf_hash_table (info)->dynobj;
 
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (elf_hash_table (info)->dynamic_sections_created)
     {
@@ -5241,9 +5154,9 @@
 
 static bfd_boolean
 bfin_finish_dynamic_symbol (bfd * output_bfd,
-				struct bfd_link_info *info,
-				struct elf_link_hash_entry *h,
-				Elf_Internal_Sym * sym)
+			    struct bfd_link_info *info,
+			    struct elf_link_hash_entry *h,
+			    Elf_Internal_Sym * sym)
 {
   bfd *dynobj;
 
@@ -5259,8 +5172,8 @@
       /* This symbol has an entry in the global offset table.
          Set it up.  */
 
-      sgot = bfd_get_section_by_name (dynobj, ".got");
-      srela = bfd_get_section_by_name (dynobj, ".rela.got");
+      sgot = bfd_get_linker_section (dynobj, ".got");
+      srela = bfd_get_linker_section (dynobj, ".rela.got");
       BFD_ASSERT (sgot != NULL && srela != NULL);
 
       rela.r_offset = (sgot->output_section->vma
@@ -5318,7 +5231,7 @@
 
 static bfd_boolean
 bfin_adjust_dynamic_symbol (struct bfd_link_info *info,
-				struct elf_link_hash_entry *h)
+			    struct elf_link_hash_entry *h)
 {
   bfd *dynobj;
   asection *s;
@@ -5372,7 +5285,7 @@
      both the dynamic object and the regular object will refer to the
      same memory location for the variable.  */
 
-  s = bfd_get_section_by_name (dynobj, ".dynbss");
+  s = bfd_get_linker_section (dynobj, ".dynbss");
   BFD_ASSERT (s != NULL);
 
   /* We must generate a R_68K_COPY reloc to tell the dynamic linker to
@@ -5383,7 +5296,7 @@
     {
       asection *srel;
 
-      srel = bfd_get_section_by_name (dynobj, ".rela.bss");
+      srel = bfd_get_linker_section (dynobj, ".rela.bss");
       BFD_ASSERT (srel != NULL);
       srel->size += sizeof (Elf32_External_Rela);
       h->needs_copy = 1;
@@ -5446,7 +5359,7 @@
    case.  */
 
 static bfd_boolean
-bfin_discard_copies (struct elf_link_hash_entry *h, PTR inf)
+bfin_discard_copies (struct elf_link_hash_entry *h, void * inf)
 {
   struct bfd_link_info *info = (struct bfd_link_info *) inf;
   struct bfin_pcrel_relocs_copied *s;
@@ -5477,7 +5390,7 @@
 
 static bfd_boolean
 bfin_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
-				struct bfd_link_info *info)
+			    struct bfd_link_info *info)
 {
   bfd *dynobj;
   asection *s;
@@ -5491,7 +5404,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
@@ -5504,7 +5417,7 @@
          not actually use these entries.  Reset the size of .rela.got,
          which will cause it to get stripped from the output file
          below.  */
-      s = bfd_get_section_by_name (dynobj, ".rela.got");
+      s = bfd_get_linker_section (dynobj, ".rela.got");
       if (s != NULL)
 	s->size = 0;
     }
@@ -5517,7 +5430,7 @@
      will not fill them in in the relocate_section routine.  */
   if (info->shared)
     elf_link_hash_traverse (elf_hash_table (info),
-			    bfin_discard_copies, (PTR) info);
+			    bfin_discard_copies, info);
 
   /* The check_relocs and adjust_dynamic_symbol entry points have
      determined the sizes of the various dynamic sections.  Allocate
@@ -5628,16 +5541,12 @@
    after the add_symbols entry point has been called for all the
    objects, and before the final_link entry point is called.  */
 
-bfd_boolean bfd_bfin_elf32_create_embedded_relocs
-  PARAMS ((bfd *, struct bfd_link_info *, asection *, asection *, char **));
-
 bfd_boolean
-bfd_bfin_elf32_create_embedded_relocs (
-     bfd *abfd,
-     struct bfd_link_info *info,
-     asection *datasec,
-     asection *relsec,
-     char **errmsg)
+bfd_bfin_elf32_create_embedded_relocs (bfd *abfd,
+				       struct bfd_link_info *info,
+				       asection *datasec,
+				       asection *relsec,
+				       char **errmsg)
 {
   Elf_Internal_Shdr *symtab_hdr;
   Elf_Internal_Sym *isymbuf = NULL;
@@ -5657,7 +5566,7 @@
 
   /* Get a copy of the native relocations.  */
   internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, datasec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+		     (abfd, datasec, NULL, (Elf_Internal_Rela *) NULL,
 		      info->keep_memory));
   if (internal_relocs == NULL)
     goto error_return;
@@ -5804,6 +5713,7 @@
 #define elf_backend_final_write_processing \
                                         elf32_bfin_final_write_processing
 #define elf_backend_reloc_type_class    elf32_bfin_reloc_type_class
+#define elf_backend_stack_align		8
 #define elf_backend_can_gc_sections 1
 #define elf_backend_special_sections	elf32_bfin_special_sections
 #define elf_backend_can_refcount 1
@@ -5839,9 +5749,6 @@
 #undef elf_backend_always_size_sections
 #define elf_backend_always_size_sections \
 		elf32_bfinfdpic_always_size_sections
-#undef elf_backend_modify_program_headers
-#define elf_backend_modify_program_headers \
-		elf32_bfinfdpic_modify_program_headers
 #undef bfd_elf32_bfd_copy_private_bfd_data
 #define bfd_elf32_bfd_copy_private_bfd_data \
 		elf32_bfinfdpic_copy_private_bfd_data
diff --git a/bfd/elf32-cr16.c b/bfd/elf32-cr16.c
index 0118131..8ed5af1 100644
--- a/bfd/elf32-cr16.c
+++ b/bfd/elf32-cr16.c
@@ -1,5 +1,5 @@
 /* BFD back-end for National Semiconductor's CR16 ELF
-   Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+   Copyright 2007, 2008, 2009, 2010, 2012 Free Software Foundation, Inc.
    Written by M R Swami Reddy.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -585,7 +585,7 @@
   int ptralign;
 
   /* This function may be called more than once.  */
-  if (bfd_get_section_by_name (abfd, ".got") != NULL)
+  if (bfd_get_linker_section (abfd, ".got") != NULL)
     return TRUE;
 
   switch (bed->s->arch_size)
@@ -606,14 +606,14 @@
   flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
            | SEC_LINKER_CREATED);
 
-  s = bfd_make_section_with_flags (abfd, ".got", flags);
+  s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, ptralign))
     return FALSE;
 
   if (bed->want_got_plt)
     {
-      s = bfd_make_section_with_flags (abfd, ".got.plt", flags);
+      s = bfd_make_section_anyway_with_flags (abfd, ".got.plt", flags);
       if (s == NULL
           || ! bfd_set_section_alignment (abfd, s, ptralign))
         return FALSE;
@@ -725,6 +725,10 @@
           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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
         }
 
       /* Some relocs require a global offset table.  */
@@ -752,24 +756,22 @@
 
           if (sgot == NULL)
             {
-              sgot = bfd_get_section_by_name (dynobj, ".got");
+              sgot = bfd_get_linker_section (dynobj, ".got");
               BFD_ASSERT (sgot != NULL);
             }
 
           if (srelgot == NULL
               && (h != NULL || info->executable))
             {
-              srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+              srelgot = bfd_get_linker_section (dynobj, ".rela.got");
               if (srelgot == NULL)
                 {
-                  srelgot = bfd_make_section_with_flags (dynobj,
-                                                         ".rela.got",
-                                                         (SEC_ALLOC
-                                                          | SEC_LOAD
-                                                          | SEC_HAS_CONTENTS
-                                                          | SEC_IN_MEMORY
-                                                          | SEC_LINKER_CREATED
-                                                          | SEC_READONLY));
+		  flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+				    | SEC_IN_MEMORY | SEC_LINKER_CREATED
+				    | SEC_READONLY);
+		  srelgot = bfd_make_section_anyway_with_flags (dynobj,
+								".rela.got",
+								flags);
                   if (srelgot == NULL
                       || ! bfd_set_section_alignment (dynobj, srelgot, 2))
                     goto fail;
@@ -914,7 +916,7 @@
        /* We only care about the addend, where the difference between
           expressions is kept.  */
        Rvalue = 0;
-       
+
      default:
        break;
     }
@@ -1045,9 +1047,9 @@
                         | ((Rvalue >> 16) & 0xf)), hit_data);
             bfd_put_16 (input_bfd, (Rvalue) & 0xffff, hit_data + 2);
           }
-        else if (r_type == R_CR16_GOT_REGREL20) 
+        else if (r_type == R_CR16_GOT_REGREL20)
           {
-            asection * sgot = bfd_get_section_by_name (dynobj, ".got");
+            asection * sgot = bfd_get_linker_section (dynobj, ".got");
 
             if (h != NULL)
               {
@@ -1062,7 +1064,7 @@
                        -Bsymbolic link and the symbol is defined
                        locally, or the symbol was forced to be local
                        because of a version file.  We must initialize
-                       this entry in the global offset table. 
+                       this entry in the global offset table.
                        When doing a dynamic link, we create a .rela.got
                        relocation entry to initialize the value.  This
                        is done in the finish_dynamic_symbol routine.  */
@@ -1082,7 +1084,7 @@
 
              Rvalue += addend;
 
-             /* REVISIT: if ((long) Rvalue > 0xffffff || 
+             /* REVISIT: if ((long) Rvalue > 0xffffff ||
                                     (long) Rvalue < -0x800000).  */
              if ((long) Rvalue > 0xffffff || (long) Rvalue < 0)
                return bfd_reloc_overflow;
@@ -1096,7 +1098,7 @@
         else if (r_type == R_CR16_GOTC_REGREL20)
           {
              asection * sgot;
-             sgot = bfd_get_section_by_name (dynobj, ".got");
+             sgot = bfd_get_linker_section (dynobj, ".got");
 
              if (h != NULL)
                {
@@ -1113,7 +1115,7 @@
                     -Bsymbolic link and the symbol is defined
                      locally, or the symbol was forced to be local
                      because of a version file.  We must initialize
-                     this entry in the global offset table. 
+                     this entry in the global offset table.
                      When doing a dynamic link, we create a .rela.got
                      relocation entry to initialize the value.  This
                      is done in the finish_dynamic_symbol routine.  */
@@ -1144,7 +1146,7 @@
                Rvalue += Rvalue1;
 
               /* Check for range.  */
-             /* REVISIT: if ((long) Rvalue > 0xffffff 
+             /* REVISIT: if ((long) Rvalue > 0xffffff
                              || (long) Rvalue < -0x800000).  */
              if ((long) Rvalue > 0xffffff || (long) Rvalue < 0)
                return bfd_reloc_overflow;
@@ -1226,7 +1228,7 @@
               }
             else if (r_type == R_CR16_NUM32)
               {
-                 Rvalue1 = (bfd_get_32 (input_bfd, hit_data)); 
+                 Rvalue1 = (bfd_get_32 (input_bfd, hit_data));
 
                  /* Add or subtract the offset value */
                  if (Rvalue1 & 0x80000000)
@@ -1311,7 +1313,7 @@
                   && ELF32_R_TYPE (irel->r_info) != (int) R_CR16_SWITCH16
                   && ELF32_R_TYPE (irel->r_info) != (int) R_CR16_SWITCH32)
                  continue;
-        
+
               r_symndx = ELF32_R_SYM (irel->r_info);
               rsym = (Elf_Internal_Sym *) symtab_hdr->contents + r_symndx;
 
@@ -1431,9 +1433,9 @@
                                    unresolved_reloc, warned);
         }
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
         continue;
@@ -1662,7 +1664,7 @@
   struct elf_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_link_hash_table);
 
-  ret = (struct elf_link_hash_table *) bfd_malloc (amt);
+  ret = (struct elf_link_hash_table *) bfd_zmalloc (amt);
   if (ret == (struct elf_link_hash_table *) NULL)
     return NULL;
 
@@ -1678,18 +1680,6 @@
   return &ret->root;
 }
 
-/* Free an cr16 ELF linker hash table.  */
-
-static void
-elf32_cr16_link_hash_table_free (struct bfd_link_hash_table *hash)
-{
-  struct elf_link_hash_table *ret
-    = (struct elf_link_hash_table *) hash;
-
-  _bfd_generic_link_hash_table_free
-    ((struct bfd_link_hash_table *) ret);
-}
-
 static unsigned long
 elf_cr16_mach (flagword flags)
 {
@@ -1983,7 +1973,7 @@
           bfd_vma value = symval;
           unsigned short is_add_mov = 0;
           bfd_vma value1 = 0;
-          
+
           /* Get the existing value from the mcode */
           value1 = ((bfd_get_32 (abfd, contents + irel->r_offset + 2) >> 16)
                    |(((bfd_get_32 (abfd, contents + irel->r_offset + 2) & 0xffff) << 16)));
@@ -1998,7 +1988,7 @@
 
               /* Verify it's a 'arithmetic ADDD or MOVD instruction'.
                  For ADDD and MOVD only, convert to IMM32 -> IMM20.  */
-     
+
               if (((code & 0xfff0) == 0x0070) || ((code & 0xfff0) == 0x0020))
                  is_add_mov = 1;
 
@@ -2018,7 +2008,7 @@
 
                   bfd_put_8 (abfd, (code & 0xf) << 4, contents + irel->r_offset);
 
-                  /* If existing value is nagavive adjust approriately 
+                  /* If existing value is nagavive adjust approriately
                      place the 16-20bits (ie 4 bit) in new opcode,
                      as the 0xffffxxxx, the higher 2 byte values removed. */
                   if (value1 & 0x80000000)
@@ -2042,7 +2032,7 @@
             }
 
           /* See if the value will fit in 16 bits.  */
-          if ((!is_add_mov) 
+          if ((!is_add_mov)
               && ((long)(value + value1) < 0x7fff && (long)(value + value1) > 0))
             {
               unsigned short code;
@@ -2067,7 +2057,7 @@
 
               bfd_put_8 (abfd, 0xb0 | (code & 0xf), contents + irel->r_offset);
 
-              /* If existing value is nagavive adjust approriately 
+              /* If existing value is nagavive adjust approriately
                  place the 12-16bits (ie 4 bit) in new opcode,
                  as the 0xfffffxxx, the higher 2 byte values removed. */
               if (value1 & 0x80000000)
@@ -2094,7 +2084,7 @@
 #if 0
       /* Try to turn a 16bit immediate address into a 4bit
          immediate address.  */
-      if ((ELF32_R_TYPE (irel->r_info) == (int) R_CR16_IMM20) 
+      if ((ELF32_R_TYPE (irel->r_info) == (int) R_CR16_IMM20)
           || (ELF32_R_TYPE (irel->r_info) == (int) R_CR16_IMM16))
         {
           bfd_vma value = symval;
@@ -2202,7 +2192,7 @@
       else
        /* Cache the section contents for elf_link_input_bfd.  */
        elf_section_data (sec)->this_hdr.contents = contents;
-       
+
     }
 
   if (internal_relocs != NULL
@@ -2278,10 +2268,10 @@
   flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
            | SEC_LINKER_CREATED);
 
-  s = bfd_make_section_with_flags (abfd,
-                                   (bed->default_use_rela_p
-                                    ? ".rela.plt" : ".rel.plt"),
-                                   flags | SEC_READONLY);
+  s = bfd_make_section_anyway_with_flags (abfd,
+					  (bed->default_use_rela_p
+					   ? ".rela.plt" : ".rel.plt"),
+					  flags | SEC_READONLY);
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, ptralign))
     return FALSE;
@@ -2289,32 +2279,6 @@
   if (! _bfd_cr16_elf_create_got_section (abfd, info))
     return FALSE;
 
-  {
-    const char * secname;
-    char *       relname;
-    flagword     secflags;
-    asection *   sec;
-
-    for (sec = abfd->sections; sec; sec = sec->next)
-      {
-        secflags = bfd_get_section_flags (abfd, sec);
-        if ((secflags & (SEC_DATA | SEC_LINKER_CREATED))
-            || ((secflags & SEC_HAS_CONTENTS) != SEC_HAS_CONTENTS))
-          continue;
-
-        secname = bfd_get_section_name (abfd, sec);
-        relname = (char *) bfd_malloc (strlen (secname) + 6);
-        strcpy (relname, ".rela");
-        strcat (relname, secname);
-
-        s = bfd_make_section_with_flags (abfd, relname,
-                                         flags | SEC_READONLY);
-        if (s == NULL
-            || ! bfd_set_section_alignment (abfd, s, ptralign))
-          return FALSE;
-      }
-  }
-
   if (bed->want_dynbss)
     {
       /* The .dynbss section is a place to put symbols which are defined
@@ -2323,8 +2287,8 @@
          image and use a R_*_COPY reloc to tell the dynamic linker to
          initialize them at run time.  The linker script puts the .dynbss
          section into the .bss section of the final image.  */
-      s = bfd_make_section_with_flags (abfd, ".dynbss",
-                                       SEC_ALLOC | SEC_LINKER_CREATED);
+      s = bfd_make_section_anyway_with_flags (abfd, ".dynbss",
+					      SEC_ALLOC | SEC_LINKER_CREATED);
       if (s == NULL)
         return FALSE;
 
@@ -2341,10 +2305,10 @@
          copy relocs.  */
       if (! info->executable)
         {
-          s = bfd_make_section_with_flags (abfd,
-                                           (bed->default_use_rela_p
-                                            ? ".rela.bss" : ".rel.bss"),
-                                           flags | SEC_READONLY);
+          s = bfd_make_section_anyway_with_flags (abfd,
+						  (bed->default_use_rela_p
+						   ? ".rela.bss" : ".rel.bss"),
+						  flags | SEC_READONLY);
           if (s == NULL
               || ! bfd_set_section_alignment (abfd, s, ptralign))
             return FALSE;
@@ -2406,13 +2370,13 @@
       /* We also need to make an entry in the .got.plt section, which
          will be placed in the .got section by the linker script.  */
 
-      s = bfd_get_section_by_name (dynobj, ".got.plt");
+      s = bfd_get_linker_section (dynobj, ".got.plt");
       BFD_ASSERT (s != NULL);
       s->size += 4;
 
       /* We also need to make an entry in the .rela.plt section.  */
 
-      s = bfd_get_section_by_name (dynobj, ".rela.plt");
+      s = bfd_get_linker_section (dynobj, ".rela.plt");
       BFD_ASSERT (s != NULL);
       s->size += sizeof (Elf32_External_Rela);
 
@@ -2446,13 +2410,6 @@
   if (!h->non_got_ref)
     return TRUE;
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-                             h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -2463,18 +2420,18 @@
      both the dynamic object and the regular object will refer to the
      same memory location for the variable.  */
 
-  s = bfd_get_section_by_name (dynobj, ".dynbss");
+  s = bfd_get_linker_section (dynobj, ".dynbss");
   BFD_ASSERT (s != NULL);
 
   /* We must generate a R_CR16_COPY reloc to tell the dynamic linker to
      copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rela.bss section we are going to use.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       asection * srel;
 
-      srel = bfd_get_section_by_name (dynobj, ".rela.bss");
+      srel = bfd_get_linker_section (dynobj, ".rela.bss");
       BFD_ASSERT (srel != NULL);
       srel->size += sizeof (Elf32_External_Rela);
       h->needs_copy = 1;
@@ -2504,7 +2461,7 @@
       if (info->executable)
         {
 #if 0
-          s = bfd_get_section_by_name (dynobj, ".interp");
+          s = bfd_get_linker_section (dynobj, ".interp");
           BFD_ASSERT (s != NULL);
           s->size = sizeof ELF_DYNAMIC_INTERPRETER;
           s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
@@ -2518,7 +2475,7 @@
          not actually use these entries.  Reset the size of .rela.got,
          which will cause it to get stripped from the output file
          below.  */
-      s = bfd_get_section_by_name (dynobj, ".rela.got");
+      s = bfd_get_linker_section (dynobj, ".rela.got");
       if (s != NULL)
         s->size = 0;
     }
@@ -2673,8 +2630,8 @@
 
       /* This symbol has an entry in the global offset table.  Set it up.  */
 
-      sgot = bfd_get_section_by_name (dynobj, ".got");
-      srel = bfd_get_section_by_name (dynobj, ".rela.got");
+      sgot = bfd_get_linker_section (dynobj, ".got");
+      srel = bfd_get_linker_section (dynobj, ".rela.got");
       BFD_ASSERT (sgot != NULL && srel != NULL);
 
       rel.r_offset = (sgot->output_section->vma
@@ -2718,8 +2675,7 @@
                   && (h->root.type == bfd_link_hash_defined
                       || h->root.type == bfd_link_hash_defweak));
 
-      s = bfd_get_section_by_name (h->root.u.def.section->owner,
-                                   ".rela.bss");
+      s = bfd_get_linker_section (dynobj, ".rela.bss");
       BFD_ASSERT (s != NULL);
 
       rel.r_offset = (h->root.u.def.value
@@ -2734,7 +2690,7 @@
     }
 
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+  if (h == elf_hash_table (info)->hdynamic
       || h == elf_hash_table (info)->hgot)
     sym->st_shndx = SHN_ABS;
 
@@ -2753,9 +2709,9 @@
 
   dynobj = elf_hash_table (info)->dynobj;
 
-  sgot = bfd_get_section_by_name (dynobj, ".got.plt");
+  sgot = bfd_get_linker_section (dynobj, ".got.plt");
   BFD_ASSERT (sgot != NULL);
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (elf_hash_table (info)->dynamic_sections_created)
     {
@@ -2964,7 +2920,9 @@
    properly.  */
 
 static enum elf_reloc_type_class
-_bfd_cr16_elf_reloc_type_class (const Elf_Internal_Rela *rela)
+_bfd_cr16_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+				const asection *rel_sec ATTRIBUTE_UNUSED,
+				const Elf_Internal_Rela *rela)
 {
   switch ((int) ELF32_R_TYPE (rela->r_info))
     {
@@ -3009,8 +2967,6 @@
 
 #define bfd_elf32_bfd_link_hash_table_create \
                                   elf32_cr16_link_hash_table_create
-#define bfd_elf32_bfd_link_hash_table_free \
-                                  elf32_cr16_link_hash_table_free
 
 #define elf_backend_create_dynamic_sections \
                                   _bfd_cr16_elf_create_dynamic_sections
diff --git a/bfd/elf32-cr16c.c b/bfd/elf32-cr16c.c
index ca2d7cb..4231a42 100644
--- a/bfd/elf32-cr16c.c
+++ b/bfd/elf32-cr16c.c
@@ -1,5 +1,5 @@
 /* BFD back-end for National Semiconductor's CR16C ELF
-   Copyright 2004, 2005, 2006, 2007, 2009, 2010
+   Copyright 2004, 2005, 2006, 2007, 2009, 2010, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -29,14 +29,14 @@
 
 #define USE_REL	1	/* CR16C uses REL relocations instead of RELA.  */
 
-/* The following definition is based on EMPTY_HOWTO macro, 
+/* The following definition is based on EMPTY_HOWTO macro,
    but also initiates the "name" field in HOWTO struct.  */
 #define ONLY_NAME_HOWTO(C) \
   HOWTO ((C), 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL, \
 	  STRINGX(C), FALSE, 0, 0, FALSE)
 
 /* reloc_map_index array maps CRASM relocation type into a BFD
-   relocation enum. The array's indices are synchronized with 
+   relocation enum. The array's indices are synchronized with
    RINDEX_16C_* indices, created in include/elf/cr16c.h.
    The array is used in:
    1. elf32-cr16c.c : elf_cr16c_reloc_type_lookup().
@@ -723,9 +723,9 @@
 				   unresolved_reloc, warned);
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	{
diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c
index 243a8ec..f40a079 100644
--- a/bfd/elf32-cris.c
+++ b/bfd/elf32-cris.c
@@ -1,6 +1,6 @@
 /* CRIS-specific support for 32-bit ELF.
    Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-   2010, 2011 Free Software Foundation, Inc.
+   2010, 2011, 2012 Free Software Foundation, Inc.
    Contributed by Axis Communications AB.
    Written by Hans-Peter Nilsson, based on elf32-fr30.c
    PIC and shlib bits based primarily on elf32-m68k.c and elf32-i386.c.
@@ -29,73 +29,13 @@
 #include "elf/cris.h"
 #include <limits.h>
 
+bfd_reloc_status_type
+cris_elf_pcrel_reloc (bfd *, arelent *, asymbol *, void *,
+		      asection *, bfd *, char **);
+static bfd_boolean
+cris_elf_set_mach_from_flags (bfd *, unsigned long);
+
 /* Forward declarations.  */
-static reloc_howto_type * cris_reloc_type_lookup
-  PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
-
-static void cris_info_to_howto_rela
-  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
-
-static bfd_reloc_status_type cris_elf_pcrel_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-
-static bfd_boolean cris_elf_grok_prstatus
-  PARAMS ((bfd *abfd, Elf_Internal_Note *note));
-
-static bfd_boolean cris_elf_grok_psinfo
-  PARAMS ((bfd *abfd, Elf_Internal_Note *note));
-
-static bfd_boolean cris_elf_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
-	   Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
-
-static bfd_reloc_status_type cris_final_link_relocate
-  PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
-	   Elf_Internal_Rela *, bfd_vma));
-
-static bfd_boolean cris_elf_object_p PARAMS ((bfd *));
-
-static void cris_elf_final_write_processing PARAMS ((bfd *, bfd_boolean));
-
-static bfd_boolean cris_elf_set_mach_from_flags
-  PARAMS ((bfd *, unsigned long int));
-
-static bfd_boolean cris_elf_print_private_bfd_data PARAMS ((bfd *, PTR));
-
-static bfd_boolean cris_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *));
-static bfd_boolean cris_elf_copy_private_bfd_data PARAMS ((bfd *, bfd *));
-
-struct elf_cris_link_hash_entry;
-static bfd_boolean elf_cris_discard_excess_dso_dynamics
-  PARAMS ((struct elf_cris_link_hash_entry *, PTR));
-static bfd_boolean elf_cris_discard_excess_program_dynamics
-  PARAMS ((struct elf_cris_link_hash_entry *, PTR));
-static bfd_boolean elf_cris_adjust_gotplt_to_got
-  PARAMS ((struct elf_cris_link_hash_entry *, PTR));
-static bfd_boolean elf_cris_try_fold_plt_to_got
-  PARAMS ((struct elf_cris_link_hash_entry *, PTR));
-static struct bfd_hash_entry *elf_cris_link_hash_newfunc
-  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static struct bfd_link_hash_table *elf_cris_link_hash_table_create
-  PARAMS ((bfd *));
-static bfd_boolean elf_cris_adjust_dynamic_symbol
-  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
-static bfd_boolean cris_elf_check_relocs
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-	   const Elf_Internal_Rela *));
-
-static bfd_boolean elf_cris_size_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-static bfd_boolean elf_cris_finish_dynamic_symbol
-  PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
-	   Elf_Internal_Sym *));
-static bfd_boolean elf_cris_finish_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-static void elf_cris_hide_symbol
-  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean));
-static enum elf_reloc_type_class elf_cris_reloc_type_class
-  PARAMS ((const Elf_Internal_Rela *));
-
 static reloc_howto_type cris_elf_howto_table [] =
 {
   /* This reloc does nothing.  */
@@ -485,9 +425,8 @@
 };
 
 static reloc_howto_type *
-cris_reloc_type_lookup (abfd, code)
-     bfd * abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+cris_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
+			bfd_reloc_code_real_type code)
 {
   unsigned int i;
 
@@ -516,10 +455,9 @@
 /* Set the howto pointer for an CRIS ELF reloc.  */
 
 static void
-cris_info_to_howto_rela (abfd, cache_ptr, dst)
-     bfd * abfd ATTRIBUTE_UNUSED;
-     arelent * cache_ptr;
-     Elf_Internal_Rela * dst;
+cris_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
+			 arelent * cache_ptr,
+			 Elf_Internal_Rela * dst)
 {
   enum elf_cris_reloc_type r_type;
 
@@ -529,15 +467,13 @@
 }
 
 bfd_reloc_status_type
-cris_elf_pcrel_reloc (abfd, reloc_entry, symbol, data, input_section,
-		      output_bfd, error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc_entry;
-     asymbol *symbol;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+cris_elf_pcrel_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+		      arelent *reloc_entry,
+		      asymbol *symbol,
+		      void * data ATTRIBUTE_UNUSED,
+		      asection *input_section,
+		      bfd *output_bfd,
+		      char **error_message ATTRIBUTE_UNUSED)
 {
   /* By default (using only bfd_elf_generic_reloc when linking to
      non-ELF formats) PC-relative relocs are relative to the beginning
@@ -562,9 +498,7 @@
    changes, while still keeping Linux/CRIS and Linux/CRISv32 code apart.  */
 
 static bfd_boolean
-cris_elf_grok_prstatus (abfd, note)
-     bfd *abfd;
-     Elf_Internal_Note *note;
+cris_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
 {
   int offset;
   size_t size;
@@ -577,10 +511,10 @@
 
       case 202:		/* Linux/CRISv32 */
 	/* pr_cursig */
-	elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+	elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
 
 	/* pr_pid */
-	elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 22);
+	elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 22);
 
 	/* pr_reg */
 	offset = 70;
@@ -596,10 +530,10 @@
 
       case 214:		/* Linux/CRIS */
 	/* pr_cursig */
-	elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+	elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
 
 	/* pr_pid */
-	elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 22);
+	elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 22);
 
 	/* pr_reg */
 	offset = 70;
@@ -614,9 +548,7 @@
 }
 
 static bfd_boolean
-cris_elf_grok_psinfo (abfd, note)
-     bfd *abfd;
-     Elf_Internal_Note *note;
+cris_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
 {
   if (bfd_get_mach (abfd) == bfd_mach_cris_v32)
     switch (note->descsz)
@@ -625,9 +557,9 @@
 	return FALSE;
 
       case 124:		/* Linux/CRISv32 elf_prpsinfo */
-	elf_tdata (abfd)->core_program
+	elf_tdata (abfd)->core->program
 	  = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
-	elf_tdata (abfd)->core_command
+	elf_tdata (abfd)->core->command
 	  = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
       }
   else
@@ -637,9 +569,9 @@
 	return FALSE;
 
       case 124:		/* Linux/CRIS elf_prpsinfo */
-	elf_tdata (abfd)->core_program
+	elf_tdata (abfd)->core->program
 	  = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
-	elf_tdata (abfd)->core_command
+	elf_tdata (abfd)->core->command
 	  = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
       }
 
@@ -648,7 +580,7 @@
      implementations, so strip it off if it exists.  */
 
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
@@ -848,6 +780,13 @@
   bfd_signed_vma dtp_refcount;
 };
 
+static bfd_boolean
+elf_cris_discard_excess_dso_dynamics (struct elf_cris_link_hash_entry *,
+				      void * );
+static bfd_boolean
+elf_cris_discard_excess_program_dynamics (struct elf_cris_link_hash_entry *,
+					  void *);
+
 /* The local_got_refcounts and local_got_offsets are a multiple of
    LSNUM in size, namely LGOT_ALLOC_NELTS_FOR(LSNUM) (plus one for the
    refcount for GOT itself, see code), with the summary / group offset
@@ -945,7 +884,7 @@
   struct elf_cris_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_cris_link_hash_table);
 
-  ret = ((struct elf_cris_link_hash_table *) bfd_malloc (amt));
+  ret = ((struct elf_cris_link_hash_table *) bfd_zmalloc (amt));
   if (ret == (struct elf_cris_link_hash_table *) NULL)
     return NULL;
 
@@ -962,9 +901,6 @@
      are used for run-time symbol evaluation.  */
   ret->next_gotplt_entry = 12;
 
-  /* We haven't seen any R_CRIS_nn_GOT_TPREL initially.  */
-  ret->dtpmod_refcount = 0;
-
   return &ret->root.root;
 }
 
@@ -972,14 +908,12 @@
    routines, with a few tweaks.  */
 
 static bfd_reloc_status_type
-cris_final_link_relocate (howto, input_bfd, input_section, contents, rel,
-			  relocation)
-     reloc_howto_type *  howto;
-     bfd *               input_bfd;
-     asection *          input_section;
-     bfd_byte *          contents;
-     Elf_Internal_Rela * rel;
-     bfd_vma             relocation;
+cris_final_link_relocate (reloc_howto_type *  howto,
+			  bfd *               input_bfd,
+			  asection *          input_section,
+			  bfd_byte *          contents,
+			  Elf_Internal_Rela * rel,
+			  bfd_vma             relocation)
 {
   bfd_reloc_status_type r;
   enum elf_cris_reloc_type r_type = ELF32_R_TYPE (rel->r_info);
@@ -1065,8 +999,8 @@
 
   if (dynobj != NULL)
     {
-      splt = bfd_get_section_by_name (dynobj, ".plt");
-      sgot = bfd_get_section_by_name (dynobj, ".got");
+      splt = bfd_get_linker_section (dynobj, ".plt");
+      sgot = bfd_get_linker_section (dynobj, ".got");
     }
 
   for (rel = relocs; rel < relend; rel ++)
@@ -1166,7 +1100,11 @@
 		      || r_type == R_CRIS_16_PCREL
 		      || r_type == R_CRIS_32_PCREL))
 		relocation = 0;
-	      else if (!info->relocatable && unresolved_reloc)
+	      else if (!info->relocatable && unresolved_reloc
+		       && (_bfd_elf_section_offset (output_bfd, info,
+						    input_section,
+						    rel->r_offset)
+			   != (bfd_vma) -1))
 		{
 		  _bfd_error_handler
 		    (_("%B, section %A: unresolvable relocation %s against symbol `%s'"),
@@ -1180,9 +1118,9 @@
 	    }
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -1200,7 +1138,7 @@
 	      && ((struct elf_cris_link_hash_entry *) h)->gotplt_offset != 0)
 	    {
 	      asection *sgotplt
-		= bfd_get_section_by_name (dynobj, ".got.plt");
+		= bfd_get_linker_section (dynobj, ".got.plt");
 	      bfd_vma got_offset;
 
 	      BFD_ASSERT (h->dynindx != -1);
@@ -1332,7 +1270,7 @@
 
 			if (srelgot == NULL)
 			  srelgot
-			    = bfd_get_section_by_name (dynobj, ".rela.got");
+			    = bfd_get_linker_section (dynobj, ".rela.got");
 			BFD_ASSERT (srelgot != NULL);
 
 			outrel.r_offset = (sgot->output_section->vma
@@ -1648,7 +1586,7 @@
 	  if (htab->dtpmod_refcount > 0
 	      && (input_section->flags & SEC_ALLOC) != 0)
 	    {
-	      asection *sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
+	      asection *sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
 	      BFD_ASSERT (sgotplt != NULL);
 
 	      if (info->shared)
@@ -1657,7 +1595,7 @@
 		  bfd_byte *loc;
 
 		  if (srelgot == NULL)
-		    srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+		    srelgot = bfd_get_linker_section (dynobj, ".rela.got");
 		  BFD_ASSERT (srelgot != NULL);
 		  loc = srelgot->contents;
 		  loc += srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
@@ -1801,7 +1739,7 @@
 		  bfd_put_32 (output_bfd, 0, sgot->contents + off + 4);
 
 		  if (srelgot == NULL)
-		    srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+		    srelgot = bfd_get_linker_section (dynobj, ".rela.got");
 		  BFD_ASSERT (srelgot != NULL);
 
 		  if (h != NULL && h->dynindx != -1)
@@ -1873,7 +1811,8 @@
 	      return FALSE;
 	    }
 
-	  if (!info->shared && (h == NULL || h->def_regular))
+	  if (!info->shared
+	      && (h == NULL || h->def_regular || ELF_COMMON_DEF_P (h)))
 	    {
 	      /* Known contents of the GOT.  */
 	      bfd_vma off;
@@ -1932,7 +1871,7 @@
 		    local_got_offsets[r_symndx] |= 1;
 
 		  if (srelgot == NULL)
-		    srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+		    srelgot = bfd_get_linker_section (dynobj, ".rela.got");
 		  BFD_ASSERT (srelgot != NULL);
 
 		  if (h != NULL && h->dynindx != -1)
@@ -2188,9 +2127,9 @@
 
       BFD_ASSERT (h->dynindx != -1);
 
-      splt = bfd_get_section_by_name (dynobj, ".plt");
-      sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
-      srela = bfd_get_section_by_name (dynobj, ".rela.plt");
+      splt = bfd_get_linker_section (dynobj, ".plt");
+      sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
+      srela = bfd_get_linker_section (dynobj, ".rela.plt");
       BFD_ASSERT (splt != NULL && sgotplt != NULL
 		  && (! has_gotplt || srela != NULL));
 
@@ -2287,8 +2226,8 @@
 
       /* This symbol has an entry in the global offset table.  Set it up.  */
 
-      sgot = bfd_get_section_by_name (dynobj, ".got");
-      srela = bfd_get_section_by_name (dynobj, ".rela.got");
+      sgot = bfd_get_linker_section (dynobj, ".got");
+      srela = bfd_get_linker_section (dynobj, ".rela.got");
       BFD_ASSERT (sgot != NULL && srela != NULL);
 
       rela.r_offset = (sgot->output_section->vma
@@ -2333,8 +2272,7 @@
 		  && (h->root.type == bfd_link_hash_defined
 		      || h->root.type == bfd_link_hash_defweak));
 
-      s = bfd_get_section_by_name (h->root.u.def.section->owner,
-				   ".rela.bss");
+      s = bfd_get_linker_section (dynobj, ".rela.bss");
       BFD_ASSERT (s != NULL);
 
       rela.r_offset = (h->root.u.def.value
@@ -2347,7 +2285,7 @@
     }
 
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+  if (h == elf_hash_table (info)->hdynamic
       || h == elf_hash_table (info)->hgot)
     sym->st_shndx = SHN_ABS;
 
@@ -2359,9 +2297,8 @@
    computed.  */
 
 static bfd_boolean
-elf_cris_finish_dynamic_sections (output_bfd, info)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
+elf_cris_finish_dynamic_sections (bfd *output_bfd,
+				  struct bfd_link_info *info)
 {
   bfd *dynobj;
   asection *sgot;
@@ -2369,16 +2306,16 @@
 
   dynobj = elf_hash_table (info)->dynobj;
 
-  sgot = bfd_get_section_by_name (dynobj, ".got.plt");
+  sgot = bfd_get_linker_section (dynobj, ".got.plt");
   BFD_ASSERT (sgot != NULL);
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       asection *splt;
       Elf32_External_Dyn *dyncon, *dynconend;
 
-      splt = bfd_get_section_by_name (dynobj, ".plt");
+      splt = bfd_get_linker_section (dynobj, ".plt");
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       dyncon = (Elf32_External_Dyn *) sdyn->contents;
@@ -2556,8 +2493,8 @@
   sym_hashes = elf_sym_hashes (abfd);
   local_got_refcounts = elf_local_got_refcounts (abfd);
 
-  sgot = bfd_get_section_by_name (dynobj, ".got");
-  srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+  sgot = bfd_get_linker_section (dynobj, ".got");
+  srelgot = bfd_get_linker_section (dynobj, ".rela.got");
 
   relend = relocs + sec->reloc_count;
   for (rel = relocs; rel < relend; rel++)
@@ -2714,16 +2651,64 @@
 /* The elf_backend_plt_sym_val hook function.  */
 
 static bfd_vma
-cris_elf_plt_sym_val (bfd_vma i, const asection *plt,
-		      const arelent *rel ATTRIBUTE_UNUSED)
+cris_elf_plt_sym_val (bfd_vma i ATTRIBUTE_UNUSED, const asection *plt,
+		      const arelent *rel)
 {
   bfd_size_type plt_entry_size;
+  bfd_size_type pltoffs;
+  bfd *abfd = plt->owner;
 
+  /* Same for CRIS and CRIS v32; see elf_cris_(|pic_)plt_entry(|_v32)[].  */
+  bfd_size_type plt_entry_got_offset = 2;
+  bfd_size_type plt_sec_size;
+  bfd_size_type got_vma_for_dyn;
+  asection *got;
+
+  /* FIXME: the .got section should be readily available also when
+     we're not linking.  */
+  if ((got = bfd_get_section_by_name (abfd, ".got")) == NULL)
+    return (bfd_vma) -1;
+
+  plt_sec_size =  bfd_section_size (plt->owner, plt);
   plt_entry_size
-    = (bfd_get_mach (plt->owner) == bfd_mach_cris_v32
+    = (bfd_get_mach (abfd) == bfd_mach_cris_v32
        ? PLT_ENTRY_SIZE_V32 : PLT_ENTRY_SIZE);
 
-  return plt->vma + (i + 1) * plt_entry_size;
+  /* Data in PLT is GOT-relative for DYN, but absolute for EXE.  */
+  got_vma_for_dyn = (abfd->flags & EXEC_P) ? 0 : got->vma;
+
+  /* Because we can have merged GOT entries; a single .got entry for
+     both GOT and the PLT part of the GOT (.got.plt), the index of the
+     reloc in .rela.plt is not the same as the index in the PLT.
+     Instead, we have to hunt down the GOT offset in the PLT that
+     corresponds to that of this reloc.  Unfortunately, we will only
+     be called for the .rela.plt relocs, so we'll miss synthetic
+     symbols for .plt entries with merged GOT entries.  (FIXME:
+     fixable by providing our own bfd_elf32_get_synthetic_symtab.
+     Doesn't seem worthwile at time of this writing.)  FIXME: we've
+     gone from O(1) to O(N) (N number of PLT entries) for finding each
+     PLT address.  Shouldn't matter in practice though.  */
+
+  for (pltoffs = plt_entry_size;
+       pltoffs < plt_sec_size;
+       pltoffs += plt_entry_size)
+    {
+      bfd_size_type got_offset;
+      bfd_byte gotoffs_raw[4];
+
+      if (!bfd_get_section_contents (abfd, (asection *) plt, gotoffs_raw,
+				     pltoffs + plt_entry_got_offset,
+				     sizeof (gotoffs_raw)))
+	return (bfd_vma) -1;
+
+      got_offset = bfd_get_32 (abfd, gotoffs_raw);
+      if (got_offset + got_vma_for_dyn == rel->address)
+	return plt->vma + pltoffs;
+    }
+
+  /* While it's tempting to BFD_ASSERT that we shouldn't get here,
+     that'd not be graceful behavior for invalid input.  */
+  return (bfd_vma) -1;
 }
 
 /* Make sure we emit a GOT entry if the symbol was supposed to have a PLT
@@ -2734,9 +2719,7 @@
    created (we're only linking static objects).  */
 
 static bfd_boolean
-elf_cris_adjust_gotplt_to_got (h, p)
-     struct elf_cris_link_hash_entry *h;
-     PTR p;
+elf_cris_adjust_gotplt_to_got (struct elf_cris_link_hash_entry *h, void * p)
 {
   struct bfd_link_info *info = (struct bfd_link_info *) p;
 
@@ -2766,8 +2749,8 @@
       asection *srelgot;
 
       BFD_ASSERT (dynobj != NULL);
-      sgot = bfd_get_section_by_name (dynobj, ".got");
-      srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+      sgot = bfd_get_linker_section (dynobj, ".got");
+      srelgot = bfd_get_linker_section (dynobj, ".rela.got");
 
       /* Put accurate refcounts there.  */
       h->root.got.refcount += h->gotplt_refcount;
@@ -2814,9 +2797,7 @@
    elf_cris_hide_symbol.  */
 
 static bfd_boolean
-elf_cris_try_fold_plt_to_got (h, p)
-     struct elf_cris_link_hash_entry *h;
-     PTR p;
+elf_cris_try_fold_plt_to_got (struct elf_cris_link_hash_entry *h, void * p)
 {
   struct bfd_link_info *info = (struct bfd_link_info *) p;
 
@@ -2848,10 +2829,9 @@
    entry.  */
 
 static void
-elf_cris_hide_symbol (info, h, force_local)
-     struct bfd_link_info *info;
-     struct elf_link_hash_entry *h;
-     bfd_boolean force_local;
+elf_cris_hide_symbol (struct bfd_link_info *info,
+		      struct elf_link_hash_entry *h,
+		      bfd_boolean force_local)
 {
   elf_cris_adjust_gotplt_to_got ((struct elf_cris_link_hash_entry *) h, info);
 
@@ -2945,7 +2925,7 @@
 	    return FALSE;
 	}
 
-      s = bfd_get_section_by_name (dynobj, ".plt");
+      s = bfd_get_linker_section (dynobj, ".plt");
       BFD_ASSERT (s != NULL);
 
       /* If this is the first .plt entry, make room for the special
@@ -3004,13 +2984,13 @@
 	= htab->next_gotplt_entry;
       htab->next_gotplt_entry += 4;
 
-      s = bfd_get_section_by_name (dynobj, ".got.plt");
+      s = bfd_get_linker_section (dynobj, ".got.plt");
       BFD_ASSERT (s != NULL);
       s->size += 4;
 
       /* We also need to make an entry in the .rela.plt section.  */
 
-      s = bfd_get_section_by_name (dynobj, ".rela.plt");
+      s = bfd_get_linker_section (dynobj, ".rela.plt");
       BFD_ASSERT (s != NULL);
       s->size += sizeof (Elf32_External_Rela);
 
@@ -3048,13 +3028,6 @@
   if (!h->non_got_ref)
     return TRUE;
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-			     h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -3065,18 +3038,18 @@
      both the dynamic object and the regular object will refer to the
      same memory location for the variable.  */
 
-  s = bfd_get_section_by_name (dynobj, ".dynbss");
+  s = bfd_get_linker_section (dynobj, ".dynbss");
   BFD_ASSERT (s != NULL);
 
   /* We must generate a R_CRIS_COPY reloc to tell the dynamic linker to
      copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rela.bss section we are going to use.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       asection *srel;
 
-      srel = bfd_get_section_by_name (dynobj, ".rela.bss");
+      srel = bfd_get_linker_section (dynobj, ".rela.bss");
       BFD_ASSERT (srel != NULL);
       srel->size += sizeof (Elf32_External_Rela);
       h->needs_copy = 1;
@@ -3204,6 +3177,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       r_type = ELF32_R_TYPE (rel->r_info);
@@ -3267,7 +3244,7 @@
 	    }
 
 	  if (sgot == NULL)
-	    sgot = bfd_get_section_by_name (dynobj, ".got");
+	    sgot = bfd_get_linker_section (dynobj, ".got");
 
 	  if (local_got_refcounts == NULL)
 	    {
@@ -3327,17 +3304,15 @@
 	  if (srelgot == NULL
 	      && (h != NULL || info->shared))
 	    {
-	      srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+	      srelgot = bfd_get_linker_section (dynobj, ".rela.got");
 	      if (srelgot == NULL)
 		{
-		  srelgot = bfd_make_section_with_flags (dynobj,
-							 ".rela.got",
-							 (SEC_ALLOC
-							  | SEC_LOAD
-							  | SEC_HAS_CONTENTS
-							  | SEC_IN_MEMORY
-							  | SEC_LINKER_CREATED
-							  | SEC_READONLY));
+		  flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+				    | SEC_IN_MEMORY | SEC_LINKER_CREATED
+				    | SEC_READONLY);
+		  srelgot = bfd_make_section_anyway_with_flags (dynobj,
+								".rela.got",
+								flags);
 		  if (srelgot == NULL
 		      || !bfd_set_section_alignment (dynobj, srelgot, 2))
 		    return FALSE;
@@ -3579,6 +3554,12 @@
 		 sec,
 		 cris_elf_howto_table[r_type].name);
 	    }
+
+	  /* We don't need to handle relocs into sections not going into
+	     the "real" output.  */
+	  if ((sec->flags & SEC_ALLOC) == 0)
+	    break;
+
 	  if (h != NULL)
 	    {
 	      h->non_got_ref = 1;
@@ -3608,11 +3589,6 @@
 	  if (! info->shared)
 	    break;
 
-	  /* We don't need to handle relocs into sections not going into
-	     the "real" output.  */
-	  if ((sec->flags & SEC_ALLOC) == 0)
-	    break;
-
 	  /* We may need to create a reloc section in the dynobj and made room
 	     for this reloc.  */
 	  if (sreloc == NULL)
@@ -3782,7 +3758,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
@@ -3799,7 +3775,7 @@
 	 not actually use these entries.  Reset the size of .rela.got,
 	 which will cause it to get stripped from the output file
 	 below.  */
-      s = bfd_get_section_by_name (dynobj, ".rela.got");
+      s = bfd_get_linker_section (dynobj, ".rela.got");
       if (s != NULL)
 	s->size = 0;
     }
@@ -3958,9 +3934,8 @@
    relocate_section routine.  */
 
 static bfd_boolean
-elf_cris_discard_excess_dso_dynamics (h, inf)
-     struct elf_cris_link_hash_entry *h;
-     PTR inf;
+elf_cris_discard_excess_dso_dynamics (struct elf_cris_link_hash_entry *h,
+				      void * inf)
 {
   struct elf_cris_pcrel_relocs_copied *s;
   struct bfd_link_info *info = (struct bfd_link_info *) inf;
@@ -4014,9 +3989,8 @@
    in the .got, but which we found we do not have to resolve at run-time.  */
 
 static bfd_boolean
-elf_cris_discard_excess_program_dynamics (h, inf)
-     struct elf_cris_link_hash_entry *h;
-     PTR inf;
+elf_cris_discard_excess_program_dynamics (struct elf_cris_link_hash_entry *h,
+					  void * inf)
 {
   struct bfd_link_info *info = (struct bfd_link_info *) inf;
 
@@ -4039,7 +4013,7 @@
 
 	  BFD_ASSERT (dynobj != NULL);
 
-	  srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+	  srelgot = bfd_get_linker_section (dynobj, ".rela.got");
 
 	  BFD_ASSERT (srelgot != NULL);
 
@@ -4069,8 +4043,7 @@
    underscores on symbols.  */
 
 static bfd_boolean
-cris_elf_object_p (abfd)
-     bfd *abfd;
+cris_elf_object_p (bfd *abfd)
 {
   if (! cris_elf_set_mach_from_flags (abfd, elf_elfheader (abfd)->e_flags))
     return FALSE;
@@ -4085,9 +4058,8 @@
    flags from mach type.  */
 
 static void
-cris_elf_final_write_processing (abfd, linker)
-     bfd *abfd;
-     bfd_boolean linker ATTRIBUTE_UNUSED;
+cris_elf_final_write_processing (bfd *abfd,
+				 bfd_boolean linker ATTRIBUTE_UNUSED)
 {
   unsigned long e_flags = elf_elfheader (abfd)->e_flags;
 
@@ -4120,9 +4092,8 @@
 /* Set the mach type from e_flags value.  */
 
 static bfd_boolean
-cris_elf_set_mach_from_flags (abfd, flags)
-     bfd *abfd;
-     unsigned long flags;
+cris_elf_set_mach_from_flags (bfd *abfd,
+			      unsigned long flags)
 {
   switch (flags & EF_CRIS_VARIANT_MASK)
     {
@@ -4152,9 +4123,7 @@
 /* Display the flags field.  */
 
 static bfd_boolean
-cris_elf_print_private_bfd_data (abfd, ptr)
-     bfd *abfd;
-     PTR ptr;
+cris_elf_print_private_bfd_data (bfd *abfd, void * ptr)
 {
   FILE *file = (FILE *) ptr;
 
@@ -4180,9 +4149,7 @@
 /* Don't mix files with and without a leading underscore.  */
 
 static bfd_boolean
-cris_elf_merge_private_bfd_data (ibfd, obfd)
-     bfd *ibfd;
-     bfd *obfd;
+cris_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
 {
   int imach, omach;
 
@@ -4259,9 +4226,7 @@
 /* Do side-effects of e_flags copying to obfd.  */
 
 static bfd_boolean
-cris_elf_copy_private_bfd_data (ibfd, obfd)
-     bfd *ibfd;
-     bfd *obfd;
+cris_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
 {
   /* Call the base function.  */
   if (!_bfd_elf_copy_private_bfd_data (ibfd, obfd))
@@ -4280,8 +4245,9 @@
 }
 
 static enum elf_reloc_type_class
-elf_cris_reloc_type_class (rela)
-     const Elf_Internal_Rela *rela;
+elf_cris_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			   const asection *rel_sec ATTRIBUTE_UNUSED,
+			   const Elf_Internal_Rela *rela)
 {
   enum elf_cris_reloc_type r_type = ELF32_R_TYPE (rela->r_info);
   switch (r_type)
diff --git a/bfd/elf32-crx.c b/bfd/elf32-crx.c
index d48932d..601f715 100644
--- a/bfd/elf32-crx.c
+++ b/bfd/elf32-crx.c
@@ -1,5 +1,5 @@
 /* BFD back-end for National Semiconductor's CRX ELF
-   Copyright 2004, 2005, 2006, 2007, 2009, 2010
+   Copyright 2004, 2005, 2006, 2007, 2009, 2010, 2012
    Free Software Foundation, Inc.
    Written by Tomer Levi, NSC, Israel.
 
@@ -332,7 +332,7 @@
 	 0x0,  			/* src_mask */
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
- 
+
   /* An 8 bit switch table entry.  This is generated for an expression
      such as ``.byte L1 - L2''.  The offset holds the difference
      between the reloc address and L2.  */
@@ -475,10 +475,10 @@
      case R_CRX_SWITCH8:
      case R_CRX_SWITCH16:
      case R_CRX_SWITCH32:
-       /* We only care about the addend, where the difference between 
+       /* We only care about the addend, where the difference between
 	  expressions is kept.  */
        Rvalue = 0;
-       
+
      default:
        break;
     }
@@ -585,7 +585,7 @@
 /* Delete some bytes from a section while relaxing.  */
 
 static bfd_boolean
-elf32_crx_relax_delete_bytes (struct bfd_link_info *link_info, bfd *abfd, 
+elf32_crx_relax_delete_bytes (struct bfd_link_info *link_info, bfd *abfd,
 			      asection *sec, bfd_vma addr, int count)
 {
   Elf_Internal_Shdr *symtab_hdr;
@@ -632,7 +632,7 @@
 	  && isym->st_value > addr
 	  && isym->st_value < toaddr)
 	{
-	  /* Adjust the addend of SWITCH relocations in this section, 
+	  /* Adjust the addend of SWITCH relocations in this section,
 	     which reference this local symbol.  */
 	  for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++)
 	    {
@@ -677,22 +677,22 @@
     {
       struct elf_link_hash_entry *sym_hash = *sym_hashes;
 
-      /* The '--wrap SYMBOL' option is causing a pain when the object file, 
-	 containing the definition of __wrap_SYMBOL, includes a direct 
-	 call to SYMBOL as well. Since both __wrap_SYMBOL and SYMBOL reference 
-	 the same symbol (which is __wrap_SYMBOL), but still exist as two 
-	 different symbols in 'sym_hashes', we don't want to adjust 
-	 the global symbol __wrap_SYMBOL twice.  
+      /* The '--wrap SYMBOL' option is causing a pain when the object file,
+	 containing the definition of __wrap_SYMBOL, includes a direct
+	 call to SYMBOL as well. Since both __wrap_SYMBOL and SYMBOL reference
+	 the same symbol (which is __wrap_SYMBOL), but still exist as two
+	 different symbols in 'sym_hashes', we don't want to adjust
+	 the global symbol __wrap_SYMBOL twice.
 	 This check is only relevant when symbols are being wrapped.  */
       if (link_info->wrap_hash != NULL)
 	{
 	  struct elf_link_hash_entry **cur_sym_hashes;
-	  
+
 	  /* Loop only over the symbols whom been already checked.  */
-	  for (cur_sym_hashes = start_hashes; cur_sym_hashes < sym_hashes; 
+	  for (cur_sym_hashes = start_hashes; cur_sym_hashes < sym_hashes;
 	       cur_sym_hashes++)
 	    {
-	      /* If the current symbol is identical to 'sym_hash', that means 
+	      /* If the current symbol is identical to 'sym_hash', that means
 		 the symbol was already adjusted (or at least checked).  */
 	      if (*cur_sym_hashes == sym_hash)
 		break;
@@ -754,7 +754,7 @@
       bfd_size_type amt;
 
       internal_relocs = (_bfd_elf_link_read_relocs
-			 (input_bfd, input_section, (PTR) NULL,
+			 (input_bfd, input_section, NULL,
 			  (Elf_Internal_Rela *) NULL, FALSE));
       if (internal_relocs == NULL)
 	goto error_return;
@@ -873,9 +873,9 @@
 				   unresolved_reloc, warned);
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -984,7 +984,7 @@
 
   /* Get a copy of the native relocations.  */
   internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
 		      link_info->keep_memory));
   if (internal_relocs == NULL)
     goto error_return;
diff --git a/bfd/elf32-d10v.c b/bfd/elf32-d10v.c
index 7d65395..f75c16a 100644
--- a/bfd/elf32-d10v.c
+++ b/bfd/elf32-d10v.c
@@ -1,6 +1,6 @@
 /* D10V-specific support for 32-bit ELF
    Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007 Free Software Foundation, Inc.
+   2007, 2010, 2012 Free Software Foundation, Inc.
    Contributed by Martin Hunt ([email protected]).
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -287,6 +287,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       switch (ELF32_R_TYPE (rel->r_info))
@@ -463,9 +467,9 @@
 				   unresolved_reloc, warned);
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
diff --git a/bfd/elf32-dlx.c b/bfd/elf32-dlx.c
index 29b8910..1379d3d 100644
--- a/bfd/elf32-dlx.c
+++ b/bfd/elf32-dlx.c
@@ -451,6 +451,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       switch (ELF32_R_TYPE (rel->r_info))
diff --git a/bfd/elf32-epiphany.c b/bfd/elf32-epiphany.c
new file mode 100644
index 0000000..b427ef3
--- /dev/null
+++ b/bfd/elf32-epiphany.c
@@ -0,0 +1,608 @@
+/* Adapteva epiphany specific support for 32-bit ELF
+   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2011, 2012
+   Free Software Foundation, Inc.
+   Contributed by Embecosm on behalf of Adapteva, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf/epiphany.h"
+#include "libiberty.h"
+
+/* Struct used to pass miscellaneous paramaters which
+   helps to avoid overly long parameter lists.  */
+struct misc
+{
+  Elf_Internal_Shdr *  symtab_hdr;
+  Elf_Internal_Rela *  irelbase;
+  bfd_byte *           contents;
+  Elf_Internal_Sym *   isymbuf;
+};
+
+struct epiphany_opcode
+{
+  unsigned short opcode;
+  unsigned short mask;
+};
+
+static bfd_boolean epiphany_relaxed = FALSE;
+
+/* Relocation tables.  */
+static reloc_howto_type epiphany_elf_howto_table [] =
+{
+#define AHOW(t,rs,s,bs,pr,bp,co,name,sm,dm)	\
+    HOWTO(t,                    /* type */ \
+	  rs,                   /* rightshift */ \
+	  s,                    /* size (0 = byte, 1 = short, 2 = long) */ \
+	  bs,                   /* bitsize */ \
+	  pr,                   /* pc_relative */ \
+	  bp,                   /* bitpos */ \
+	  co,			/* complain_on_overflow */	       \
+	  bfd_elf_generic_reloc,/* special_function */ \
+	  name,                 /* name */ \
+	  FALSE,                /* partial_inplace */ \
+	  sm,                   /* src_mask */ \
+	  dm,                   /* dst_mask */ \
+	  pr)                   /* pcrel_offset */
+
+  /* This reloc does nothing.  */
+  AHOW (R_EPIPHANY_NONE,    0, 0,32, FALSE, 0, complain_overflow_dont,     "R_EPIPHANY_NONE",        0,          0),
+
+  /* 8 bit absolute (not likely) */
+  AHOW (R_EPIPHANY_8,       0, 0, 8, FALSE, 0, complain_overflow_bitfield, "R_EPIPHANY_8",      0x000000ff, 0x000000ff),
+  /* 16 bit absolute */
+  AHOW (R_EPIPHANY_16,      0, 1,16, FALSE, 0, complain_overflow_bitfield, "R_EPIPHANY_16",     0x0000ffff, 0x00ff1fe0),
+  /* A 32 bit absolute relocation.  */
+  AHOW (R_EPIPHANY_32,      0, 2,32, FALSE, 0, complain_overflow_dont,     "R_EPIPHANY_32",     0xffffffff, 0xffffffff),
+
+  /*  8 bit relative relocation */
+  HOWTO ( R_EPIPHANY_8_PCREL,  0, 0,  8, TRUE, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_EPIPHANY_8_PCREL", FALSE, 0x000000ff, 0x000000ff, FALSE),
+  /* 16 bit relative relocation */
+  HOWTO ( R_EPIPHANY_16_PCREL, 0, 1, 16, TRUE, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_EPIPHANY_8_PCREL", FALSE, 0x000000ff, 0x000000ff, FALSE),
+  /* 32 bit relative relocation */
+  HOWTO ( R_EPIPHANY_32_PCREL, 0, 2, 32, TRUE, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_EPIPHANY_8_PCREL", FALSE, 0x000000ff, 0x000000ff, FALSE),
+
+  /* 8 bit pc-relative relocation */
+  AHOW (R_EPIPHANY_SIMM8,   1, 0, 8,  TRUE, 8, complain_overflow_signed,   "R_EPIPHANY_SIMM8",   0x000000ff, 0x0000ff00),
+  /* 24 bit pc-relative relocation */
+  AHOW (R_EPIPHANY_SIMM24,  1, 2,24,  TRUE, 8, complain_overflow_signed,   "R_EPIPHANY_SIMM24",  0x00ffffff, 0xffffff00),
+
+  /* %HIGH(EA) */
+  AHOW (R_EPIPHANY_HIGH,    0, 2,16, FALSE, 0, complain_overflow_dont,     "R_EPIPHANY_HIGH",    0x0ff01fe0, 0x0ff01fe0),
+
+  /* %LOW(EA) */
+  AHOW (R_EPIPHANY_LOW,     0, 2,16, FALSE, 0, complain_overflow_dont,	"R_EPIPHANY_LOW",     0x0ff01fe0, 0x0ff01fe0),
+
+  /* simm11 */
+  AHOW (R_EPIPHANY_SIMM11,  0, 2,11, FALSE, 0, complain_overflow_bitfield, "R_EPIPHANY_SIMM11",  0x00ff0380, 0x00ff0380),
+  /* imm12 - sign-magnitude */
+  AHOW (R_EPIPHANY_IMM11,   0, 2,11, FALSE, 0, complain_overflow_bitfield, "R_EPIPHANY_IMM12",   0x00ff0380, 0x00ff0380),
+  /* imm8 */
+  AHOW (R_EPIPHANY_IMM8,    0, 1, 8, FALSE, 8, complain_overflow_signed,   "R_EPIPHANY_IMM8",    0x0000ff00, 0x0000ff00)
+
+
+};
+#undef AHOW
+
+/* Map BFD reloc types to EPIPHANY ELF reloc types.  */
+
+static reloc_howto_type *
+epiphany_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
+			    bfd_reloc_code_real_type code)
+{
+  /* Note that the epiphany_elf_howto_table is indxed by the R_
+     constants.  Thus, the order that the howto records appear in the
+     table *must* match the order of the relocation types defined in
+     include/elf/epiphany.h.  */
+
+  switch (code)
+    {
+    case BFD_RELOC_NONE:
+      return &epiphany_elf_howto_table[ (int) R_EPIPHANY_NONE];
+
+    case BFD_RELOC_EPIPHANY_SIMM8:
+      return &epiphany_elf_howto_table[ (int) R_EPIPHANY_SIMM8];
+    case BFD_RELOC_EPIPHANY_SIMM24:
+      return &epiphany_elf_howto_table[ (int) R_EPIPHANY_SIMM24];
+
+    case BFD_RELOC_8_PCREL:
+      return &epiphany_elf_howto_table[ (int) R_EPIPHANY_8_PCREL];
+    case BFD_RELOC_16_PCREL:
+      return &epiphany_elf_howto_table[ (int) R_EPIPHANY_16_PCREL];
+    case BFD_RELOC_32_PCREL:
+      return &epiphany_elf_howto_table[ (int) R_EPIPHANY_32_PCREL];
+
+    case BFD_RELOC_8:
+      return &epiphany_elf_howto_table[ (int) R_EPIPHANY_8];
+    case BFD_RELOC_16:
+      return &epiphany_elf_howto_table[ (int) R_EPIPHANY_16];
+    case BFD_RELOC_32:
+      return &epiphany_elf_howto_table[ (int) R_EPIPHANY_32];
+
+    case BFD_RELOC_EPIPHANY_HIGH:
+      return & epiphany_elf_howto_table[ (int) R_EPIPHANY_HIGH];
+    case BFD_RELOC_EPIPHANY_LOW:
+      return & epiphany_elf_howto_table[ (int) R_EPIPHANY_LOW];
+
+    case BFD_RELOC_EPIPHANY_SIMM11:
+      return & epiphany_elf_howto_table[ (int) R_EPIPHANY_SIMM11];
+    case BFD_RELOC_EPIPHANY_IMM11:
+      return & epiphany_elf_howto_table[ (int) R_EPIPHANY_IMM11];
+
+    case BFD_RELOC_EPIPHANY_IMM8:
+      return & epiphany_elf_howto_table[ (int) R_EPIPHANY_IMM8];
+
+    default:
+      /* Pacify gcc -Wall.  */
+      return NULL;
+    }
+  return NULL;
+}
+
+static reloc_howto_type *
+epiphany_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
+{
+  unsigned int i;
+
+  for (i = 0; i < ARRAY_SIZE (epiphany_elf_howto_table); i++)
+    if (epiphany_elf_howto_table[i].name != NULL
+	&& strcasecmp (epiphany_elf_howto_table[i].name, r_name) == 0)
+      return &epiphany_elf_howto_table[i];
+
+  return NULL;
+}
+
+#define PAGENO(ABSADDR) ((ABSADDR) & 0xFFFFC000)
+#define BASEADDR(SEC)	((SEC)->output_section->vma + (SEC)->output_offset)
+
+/* This function handles relaxing for the epiphany.
+   Dummy placeholder for future optimizations.  */
+
+static bfd_boolean
+epiphany_elf_relax_section (bfd *abfd, asection *sec,
+			    struct bfd_link_info *link_info,
+			    bfd_boolean *again)
+{
+  Elf_Internal_Shdr *symtab_hdr;
+  Elf_Internal_Rela *internal_relocs;
+  bfd_byte *contents = NULL;
+  Elf_Internal_Sym *isymbuf = NULL;
+  static asection * first_section = NULL;
+  static unsigned long search_addr;
+  static unsigned long page_start = 0;
+  static unsigned long page_end = 0;
+  static unsigned int pass = 0;
+  static bfd_boolean new_pass = FALSE;
+  static bfd_boolean changed = FALSE;
+  struct misc misc ATTRIBUTE_UNUSED;
+  asection *stab;
+
+  /* Assume nothing changes.  */
+  *again = FALSE;
+
+  if (first_section == NULL)
+    {
+      epiphany_relaxed = TRUE;
+      first_section = sec;
+    }
+
+  if (first_section == sec)
+    {
+      pass++;
+      new_pass = TRUE;
+    }
+
+  /* We don't have to do anything for a relocatable link,
+     if this section does not have relocs, or if this is
+     not a code section.  */
+  if (link_info->relocatable
+      || (sec->flags & SEC_RELOC) == 0
+      || sec->reloc_count == 0
+      || (sec->flags & SEC_CODE) == 0)
+    return TRUE;
+
+  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+
+  internal_relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL,
+					       link_info->keep_memory);
+  if (internal_relocs == NULL)
+    goto error_return;
+
+  /* Make sure the stac.rela stuff gets read in.  */
+  stab = bfd_get_section_by_name (abfd, ".stab");
+
+  if (stab)
+    {
+      /* So stab does exits.  */
+      Elf_Internal_Rela * irelbase ATTRIBUTE_UNUSED;
+
+      irelbase = _bfd_elf_link_read_relocs (abfd, stab, NULL, NULL,
+					    link_info->keep_memory);
+    }
+
+  /* Get section contents cached copy if it exists.  */
+  if (contents == NULL)
+    {
+      /* Get cached copy if it exists.  */
+      if (elf_section_data (sec)->this_hdr.contents != NULL)
+	contents = elf_section_data (sec)->this_hdr.contents;
+      else
+	{
+	  /* Go get them off disk.  */
+	  if (!bfd_malloc_and_get_section (abfd, sec, &contents))
+	    goto error_return;
+	}
+    }
+
+  /* Read this BFD's symbols cached copy if it exists.  */
+  if (isymbuf == NULL && symtab_hdr->sh_info != 0)
+    {
+      isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
+      if (isymbuf == NULL)
+	isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
+					symtab_hdr->sh_info, 0,
+					NULL, NULL, NULL);
+      if (isymbuf == NULL)
+	goto error_return;
+    }
+
+  misc.symtab_hdr = symtab_hdr;
+  misc.isymbuf = isymbuf;
+  misc.irelbase = internal_relocs;
+  misc.contents = contents;
+
+  /* This is where all the relaxation actually get done.  */
+  if ((pass == 1) || (new_pass && !changed))
+    {
+      /* On the first pass we simply search for the lowest page that
+	 we havn't relaxed yet. Note that the pass count is reset
+	 each time a page is complete in order to move on to the next page.
+	 If we can't find any more pages then we are finished.  */
+      if (new_pass)
+	{
+	  pass = 1;
+	  new_pass = FALSE;
+	  changed = TRUE; /* Pre-initialize to break out of pass 1.  */
+	  search_addr = 0xFFFFFFFF;
+	}
+
+      if ((BASEADDR (sec) + sec->size < search_addr)
+	  && (BASEADDR (sec) + sec->size > page_end))
+	{
+	  if (BASEADDR (sec) <= page_end)
+	    search_addr = page_end + 1;
+	  else
+	    search_addr = BASEADDR (sec);
+
+	  /* Found a page => more work to do.  */
+	  *again = TRUE;
+	}
+    }
+  else
+    {
+      if (new_pass)
+	{
+	  new_pass = FALSE;
+	  changed = FALSE;
+	  page_start = PAGENO (search_addr);
+	  page_end = page_start | 0x00003FFF;
+	}
+
+      /* Only process sections in range.  */
+      if ((BASEADDR (sec) + sec->size >= page_start)
+	  && (BASEADDR (sec) <= page_end))
+	{
+#if 0
+	  if (!epiphany_elf_relax_section_page (abfd, sec, &changed, &misc,
+						page_start, page_end))
+#endif
+	    return FALSE;
+	}
+      *again = TRUE;
+    }
+
+  /* Perform some house keeping after relaxing the section.  */
+
+  if (isymbuf != NULL
+      && symtab_hdr->contents != (unsigned char *) isymbuf)
+    {
+      if (! link_info->keep_memory)
+	free (isymbuf);
+      else
+	symtab_hdr->contents = (unsigned char *) isymbuf;
+    }
+
+  if (contents != NULL
+      && elf_section_data (sec)->this_hdr.contents != contents)
+    {
+      if (! link_info->keep_memory)
+	free (contents);
+      else
+	{
+	  /* Cache the section contents for elf_link_input_bfd.  */
+	  elf_section_data (sec)->this_hdr.contents = contents;
+	}
+    }
+
+  if (internal_relocs != NULL
+      && elf_section_data (sec)->relocs != internal_relocs)
+    free (internal_relocs);
+
+  return TRUE;
+
+ error_return:
+  if (isymbuf != NULL
+      && symtab_hdr->contents != (unsigned char *) isymbuf)
+    free (isymbuf);
+  if (contents != NULL
+      && elf_section_data (sec)->this_hdr.contents != contents)
+    free (contents);
+  if (internal_relocs != NULL
+      && elf_section_data (sec)->relocs != internal_relocs)
+    free (internal_relocs);
+  return FALSE;
+}
+
+/* Set the howto pointer for a EPIPHANY ELF reloc.  */
+
+static void
+epiphany_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
+			     arelent * cache_ptr,
+			     Elf_Internal_Rela * dst)
+{
+  unsigned int r_type;
+
+  r_type = ELF32_R_TYPE (dst->r_info);
+  cache_ptr->howto = & epiphany_elf_howto_table [r_type];
+}
+
+/* Perform a single relocation.
+   By default we use the standard BFD routines.  */
+
+static bfd_reloc_status_type
+epiphany_final_link_relocate (reloc_howto_type *  howto,
+			      bfd *               input_bfd,
+			      asection *          input_section,
+			      bfd_byte *          contents,
+			      Elf_Internal_Rela * rel,
+			      bfd_vma             relocation)
+{
+  switch (howto->type)
+    {
+      /* Handle 16 bit immediates.  */
+    case R_EPIPHANY_HIGH:
+      relocation += rel->r_addend;
+      relocation >>= 16;
+      goto common;
+
+    case R_EPIPHANY_LOW:
+      relocation += rel->r_addend;
+    common:
+      relocation = ((relocation & 0xff00L) << 12)
+	| ((relocation & 0x00ffL) << 5);
+      /* Sanity check the address.  */
+      if (rel->r_offset > bfd_get_section_limit (input_bfd, input_section))
+	return bfd_reloc_outofrange;
+
+      return _bfd_relocate_contents (howto, input_bfd, relocation,
+				     contents + rel->r_offset);
+
+    case R_EPIPHANY_SIMM11:
+      relocation += rel->r_addend;
+      /* Check signed overflow.  */
+      if ((int)relocation > 1023 || (int)relocation < -1024)
+	return bfd_reloc_outofrange;
+      goto disp11;
+
+    case R_EPIPHANY_IMM11:
+      relocation += rel->r_addend;
+      if ((unsigned int) relocation > 0x7ff)
+	return bfd_reloc_outofrange;
+    disp11:
+      relocation = ((relocation & 7) << 5)
+	|| ((relocation & 0x7f8 )  << 13);
+      return _bfd_relocate_contents (howto, input_bfd, relocation,
+				     contents + rel->r_offset);
+
+      /* Pass others through.  */
+    default:
+      break;
+    }
+
+  /* Only install relocation if above tests did not disqualify it.  */
+  return _bfd_final_link_relocate (howto, input_bfd, input_section,
+				   contents, rel->r_offset,
+				   relocation, rel->r_addend);
+}
+
+/* Relocate an EPIPHANY ELF section.
+
+   The RELOCATE_SECTION function is called by the new ELF backend linker
+   to handle the relocations for a section.
+
+   The relocs are always passed as Rela structures; if the section
+   actually uses Rel structures, the r_addend field will always be
+   zero.
+
+   This function is responsible for adjusting the section contents as
+   necessary, and (if using Rela relocs and generating a relocatable
+   output file) adjusting the reloc addend as necessary.
+
+   This function does not have to worry about setting the reloc
+   address or the reloc symbol index.
+
+   LOCAL_SYMS is a pointer to the swapped in local symbols.
+
+   LOCAL_SECTIONS is an array giving the section in the input file
+   corresponding to the st_shndx field of each local symbol.
+
+   The global hash table entry for the global symbols can be found
+   via elf_sym_hashes (input_bfd).
+
+   When generating relocatable output, this function must handle
+   STB_LOCAL/STT_SECTION symbols specially.  The output symbol is
+   going to be the section symbol corresponding to the output
+   section, which means that the addend must be adjusted
+   accordingly.  */
+
+static bfd_boolean
+epiphany_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
+			       struct bfd_link_info *info,
+			       bfd *input_bfd,
+			       asection *input_section,
+			       bfd_byte *contents,
+			       Elf_Internal_Rela *relocs,
+			       Elf_Internal_Sym *local_syms,
+			       asection **local_sections)
+{
+  Elf_Internal_Shdr *symtab_hdr;
+  struct elf_link_hash_entry **sym_hashes;
+  Elf_Internal_Rela *rel;
+  Elf_Internal_Rela *relend;
+
+  symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
+  sym_hashes = elf_sym_hashes (input_bfd);
+  relend     = relocs + input_section->reloc_count;
+
+  for (rel = relocs; rel < relend; rel ++)
+    {
+      reloc_howto_type *           howto;
+      unsigned long                r_symndx;
+      Elf_Internal_Sym *           sym;
+      asection *                   sec;
+      struct elf_link_hash_entry * h;
+      bfd_vma                      relocation;
+      bfd_reloc_status_type        r;
+      const char *                 name = NULL;
+      int                          r_type ATTRIBUTE_UNUSED;
+
+      r_type = ELF32_R_TYPE (rel->r_info);
+      r_symndx = ELF32_R_SYM (rel->r_info);
+      howto  = epiphany_elf_howto_table + ELF32_R_TYPE (rel->r_info);
+      h      = NULL;
+      sym    = NULL;
+      sec    = NULL;
+
+      if (r_symndx < symtab_hdr->sh_info)
+	{
+	  sym = local_syms + r_symndx;
+	  sec = local_sections [r_symndx];
+	  relocation = BASEADDR (sec) + sym->st_value;
+
+	  name = bfd_elf_string_from_elf_section
+	    (input_bfd, symtab_hdr->sh_link, sym->st_name);
+	  name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name;
+	}
+      else
+	{
+	  bfd_boolean warned ATTRIBUTE_UNUSED;
+	  bfd_boolean unresolved_reloc ATTRIBUTE_UNUSED;
+
+	  RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
+				   r_symndx, symtab_hdr, sym_hashes,
+				   h, sec, relocation,
+				   unresolved_reloc, warned);
+
+	  name = h->root.root.string;
+	}
+
+      if (sec != NULL && discarded_section (sec))
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, 1, relend, howto, 0, contents);
+
+      if (info->relocatable)
+	continue;
+
+      /* Finally, the sole EPIPHANY-specific part.  */
+      r = epiphany_final_link_relocate (howto, input_bfd, input_section,
+				     contents, rel, relocation);
+
+      if (r != bfd_reloc_ok)
+	{
+	  const char * msg = NULL;
+
+	  switch (r)
+	    {
+	    case bfd_reloc_overflow:
+	      r = info->callbacks->reloc_overflow
+		(info, (h ? &h->root : NULL), name, howto->name,
+		 (bfd_vma) 0, input_bfd, input_section, rel->r_offset);
+	      break;
+
+	    case bfd_reloc_undefined:
+	      r = info->callbacks->undefined_symbol
+		(info, name, input_bfd, input_section, rel->r_offset, TRUE);
+	      break;
+
+	    case bfd_reloc_outofrange:
+	      msg = _("internal error: out of range error");
+	      break;
+
+	      /* This is how epiphany_final_link_relocate tells us of a
+		 non-kosher reference between insn & data address spaces.  */
+	    case bfd_reloc_notsupported:
+	      if (sym != NULL) /* Only if it's not an unresolved symbol.  */
+		 msg = _("unsupported relocation between data/insn address spaces");
+	      break;
+
+	    case bfd_reloc_dangerous:
+	      msg = _("internal error: dangerous relocation");
+	      break;
+
+	    default:
+	      msg = _("internal error: unknown error");
+	      break;
+	    }
+
+	  if (msg)
+	    r = info->callbacks->warning
+	      (info, msg, name, input_bfd, input_section, rel->r_offset);
+
+	  if (! r)
+	    return FALSE;
+	}
+    }
+
+  return TRUE;
+}
+
+/* We only have a little-endian target.  */
+#define TARGET_LITTLE_SYM	 bfd_elf32_epiphany_vec
+#define TARGET_LITTLE_NAME  "elf32-epiphany"
+
+#define ELF_ARCH	 bfd_arch_epiphany
+#define ELF_MACHINE_CODE EM_ADAPTEVA_EPIPHANY
+
+#define ELF_MAXPAGESIZE  0x8000 /* No pages on the EPIPHANY.  */
+
+#define elf_info_to_howto_rel			NULL
+#define elf_info_to_howto			epiphany_info_to_howto_rela
+
+#define elf_backend_can_gc_sections     	1
+#define elf_backend_rela_normal			1
+#define elf_backend_relocate_section		epiphany_elf_relocate_section
+
+#define elf_symbol_leading_char			'_'
+#define bfd_elf32_bfd_reloc_type_lookup		epiphany_reloc_type_lookup
+#define bfd_elf32_bfd_reloc_name_lookup		epiphany_reloc_name_lookup
+#define bfd_elf32_bfd_relax_section		epiphany_elf_relax_section
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-fr30.c b/bfd/elf32-fr30.c
index 97b0d29..3aed435 100644
--- a/bfd/elf32-fr30.c
+++ b/bfd/elf32-fr30.c
@@ -1,5 +1,6 @@
 /* FR30-specific support for 32-bit ELF.
-   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+   2010, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -26,23 +27,12 @@
 #include "elf/fr30.h"
 
 /* Forward declarations.  */
-static bfd_reloc_status_type fr30_elf_i20_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static bfd_reloc_status_type fr30_elf_i32_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static reloc_howto_type * fr30_reloc_type_lookup
-  PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
-static void fr30_info_to_howto_rela
-  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
-static bfd_boolean fr30_elf_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
-	   Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
-static bfd_reloc_status_type fr30_final_link_relocate
-  PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
-	   Elf_Internal_Rela *, bfd_vma));
-static bfd_boolean fr30_elf_check_relocs
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-	   const Elf_Internal_Rela *));
+static bfd_reloc_status_type
+fr30_elf_i20_reloc (bfd *, arelent *, asymbol *, void * data,
+		    asection *, bfd *, char **error_message);
+static bfd_reloc_status_type
+fr30_elf_i32_reloc (bfd *, arelent *, asymbol *, void *,
+		    asection *, bfd *, char **);
 
 static reloc_howto_type fr30_elf_howto_table [] =
 {
@@ -244,15 +234,13 @@
 /* Utility to actually perform an R_FR30_20 reloc.  */
 
 static bfd_reloc_status_type
-fr30_elf_i20_reloc (abfd, reloc_entry, symbol, data,
-		    input_section, output_bfd, error_message)
-     bfd *abfd;
-     arelent *reloc_entry;
-     asymbol *symbol;
-     PTR data;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+fr30_elf_i20_reloc (bfd *abfd,
+		    arelent *reloc_entry,
+		    asymbol *symbol,
+		    void * data,
+		    asection *input_section,
+		    bfd *output_bfd,
+		    char **error_message ATTRIBUTE_UNUSED)
 {
   bfd_vma relocation;
   unsigned long x;
@@ -290,15 +278,13 @@
 /* Utility to actually perform a R_FR30_48 reloc.  */
 
 static bfd_reloc_status_type
-fr30_elf_i32_reloc (abfd, reloc_entry, symbol, data,
-		    input_section, output_bfd, error_message)
-     bfd *abfd;
-     arelent *reloc_entry;
-     asymbol *symbol;
-     PTR data;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+fr30_elf_i32_reloc (bfd *abfd,
+		    arelent *reloc_entry,
+		    asymbol *symbol,
+		    void * data,
+		    asection *input_section,
+		    bfd *output_bfd,
+		    char **error_message ATTRIBUTE_UNUSED)
 {
   bfd_vma relocation;
 
@@ -353,9 +339,8 @@
 };
 
 static reloc_howto_type *
-fr30_reloc_type_lookup (abfd, code)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+fr30_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+			bfd_reloc_code_real_type code)
 {
   unsigned int i;
 
@@ -385,10 +370,9 @@
 /* Set the howto pointer for an FR30 ELF reloc.  */
 
 static void
-fr30_info_to_howto_rela (abfd, cache_ptr, dst)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *cache_ptr;
-     Elf_Internal_Rela *dst;
+fr30_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
+			 arelent *cache_ptr,
+			 Elf_Internal_Rela *dst)
 {
   unsigned int r_type;
 
@@ -401,14 +385,12 @@
    routines, but a few relocs, we have to do them ourselves.  */
 
 static bfd_reloc_status_type
-fr30_final_link_relocate (howto, input_bfd, input_section, contents, rel,
-			  relocation)
-     reloc_howto_type *howto;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     Elf_Internal_Rela *rel;
-     bfd_vma relocation;
+fr30_final_link_relocate (reloc_howto_type *howto,
+			  bfd *input_bfd,
+			  asection *input_section,
+			  bfd_byte *contents,
+			  Elf_Internal_Rela *rel,
+			  bfd_vma relocation)
 {
   bfd_reloc_status_type r = bfd_reloc_ok;
   bfd_vma x;
@@ -510,16 +492,14 @@
    accordingly.  */
 
 static bfd_boolean
-fr30_elf_relocate_section (output_bfd, info, input_bfd, input_section,
-			   contents, relocs, local_syms, local_sections)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     Elf_Internal_Rela *relocs;
-     Elf_Internal_Sym *local_syms;
-     asection **local_sections;
+fr30_elf_relocate_section (bfd *output_bfd,
+			   struct bfd_link_info *info,
+			   bfd *input_bfd,
+			   asection *input_section,
+			   bfd_byte *contents,
+			   Elf_Internal_Rela *relocs,
+			   Elf_Internal_Sym *local_syms,
+			   asection **local_sections)
 {
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
@@ -577,9 +557,9 @@
 	  name = h->root.root.string;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -660,11 +640,10 @@
    virtual table relocs for gc.  */
 
 static bfd_boolean
-fr30_elf_check_relocs (abfd, info, sec, relocs)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     asection *sec;
-     const Elf_Internal_Rela *relocs;
+fr30_elf_check_relocs (bfd *abfd,
+		       struct bfd_link_info *info,
+		       asection *sec,
+		       const Elf_Internal_Rela *relocs)
 {
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
@@ -692,6 +671,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       switch (ELF32_R_TYPE (rel->r_info))
diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c
index 7f3c4dd..788c299 100644
--- a/bfd/elf32-frv.c
+++ b/bfd/elf32-frv.c
@@ -1,5 +1,5 @@
 /* FRV-specific support for 32-bit ELF.
-   Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -28,56 +28,7 @@
 #include "hashtab.h"
 
 /* Forward declarations.  */
-static bfd_reloc_status_type elf32_frv_relocate_lo16
-  PARAMS ((bfd *,  Elf_Internal_Rela *, bfd_byte *, bfd_vma));
-static bfd_reloc_status_type elf32_frv_relocate_hi16
-  PARAMS ((bfd *,  Elf_Internal_Rela *, bfd_byte *, bfd_vma));
-static bfd_reloc_status_type elf32_frv_relocate_label24
-  PARAMS ((bfd *, asection *, Elf_Internal_Rela *, bfd_byte *, bfd_vma));
-static bfd_reloc_status_type elf32_frv_relocate_gprel12
-  PARAMS ((struct bfd_link_info *, bfd *, asection *, Elf_Internal_Rela *,
-	   bfd_byte *, bfd_vma));
-static bfd_reloc_status_type elf32_frv_relocate_gprelu12
-  PARAMS ((struct bfd_link_info *, bfd *, asection *, Elf_Internal_Rela *,
-	   bfd_byte *, bfd_vma));
-static bfd_reloc_status_type elf32_frv_relocate_gprello
-  PARAMS ((struct bfd_link_info *, bfd *, asection *, Elf_Internal_Rela *,
-	   bfd_byte *, bfd_vma));
-static bfd_reloc_status_type elf32_frv_relocate_gprelhi
-  PARAMS ((struct bfd_link_info *, bfd *, asection *, Elf_Internal_Rela *,
-	   bfd_byte *, bfd_vma));
-static reloc_howto_type *frv_reloc_type_lookup
-  PARAMS ((bfd *, bfd_reloc_code_real_type));
-static void frv_info_to_howto_rela
-  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
-static bfd_boolean elf32_frv_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
-	   Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
-static bfd_boolean elf32_frv_add_symbol_hook
-  PARAMS (( bfd *, struct bfd_link_info *, Elf_Internal_Sym *,
-	    const char **, flagword *, asection **, bfd_vma *));
-static bfd_reloc_status_type frv_final_link_relocate
-  PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
-	   Elf_Internal_Rela *, bfd_vma));
-static bfd_boolean elf32_frv_check_relocs
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-	   const Elf_Internal_Rela *));
-static int elf32_frv_machine
-  PARAMS ((bfd *));
-static bfd_boolean elf32_frv_object_p
-  PARAMS ((bfd *));
-static bfd_boolean frv_elf_set_private_flags
-  PARAMS ((bfd *, flagword));
-static bfd_boolean frv_elf_copy_private_bfd_data
-  PARAMS ((bfd *, bfd *));
-static bfd_boolean frv_elf_merge_private_bfd_data
-  PARAMS ((bfd *, bfd *));
-static bfd_boolean frv_elf_print_private_bfd_data
-  PARAMS ((bfd *, PTR));
-static bfd_boolean elf32_frv_grok_prstatus (bfd * abfd,
-					    Elf_Internal_Note * note);
-static bfd_boolean elf32_frv_grok_psinfo (bfd * abfd,
-					  Elf_Internal_Note * note);
+
 
 static reloc_howto_type elf32_frv_howto_table [] =
 {
@@ -1001,7 +952,7 @@
   struct frvfdpic_elf_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct frvfdpic_elf_link_hash_table);
 
-  ret = bfd_zalloc (abfd, amt);
+  ret = bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
 
@@ -2176,14 +2127,12 @@
 /* Handle an FRV small data reloc.  */
 
 static bfd_reloc_status_type
-elf32_frv_relocate_gprel12 (info, input_bfd, input_section, relocation,
-			    contents, value)
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     Elf_Internal_Rela *relocation;
-     bfd_byte *contents;
-     bfd_vma value;
+elf32_frv_relocate_gprel12 (struct bfd_link_info *info,
+			    bfd *input_bfd,
+			    asection *input_section,
+			    Elf_Internal_Rela *relocation,
+			    bfd_byte *contents,
+			    bfd_vma value)
 {
   bfd_vma insn;
   bfd_vma gp;
@@ -2215,14 +2164,12 @@
 /* Handle an FRV small data reloc. for the u12 field.  */
 
 static bfd_reloc_status_type
-elf32_frv_relocate_gprelu12 (info, input_bfd, input_section, relocation,
-			     contents, value)
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     Elf_Internal_Rela *relocation;
-     bfd_byte *contents;
-     bfd_vma value;
+elf32_frv_relocate_gprelu12 (struct bfd_link_info *info,
+			     bfd *input_bfd,
+			     asection *input_section,
+			     Elf_Internal_Rela *relocation,
+			     bfd_byte *contents,
+			     bfd_vma value)
 {
   bfd_vma insn;
   bfd_vma gp;
@@ -2257,11 +2204,10 @@
 /* Handle an FRV ELF HI16 reloc.  */
 
 static bfd_reloc_status_type
-elf32_frv_relocate_hi16 (input_bfd, relhi, contents, value)
-     bfd *input_bfd;
-     Elf_Internal_Rela *relhi;
-     bfd_byte *contents;
-     bfd_vma value;
+elf32_frv_relocate_hi16 (bfd *input_bfd,
+			 Elf_Internal_Rela *relhi,
+			 bfd_byte *contents,
+			 bfd_vma value)
 {
   bfd_vma insn;
 
@@ -2280,11 +2226,10 @@
 
 }
 static bfd_reloc_status_type
-elf32_frv_relocate_lo16 (input_bfd, rello, contents, value)
-     bfd *input_bfd;
-     Elf_Internal_Rela *rello;
-     bfd_byte *contents;
-     bfd_vma value;
+elf32_frv_relocate_lo16 (bfd *input_bfd,
+			 Elf_Internal_Rela *rello,
+			 bfd_byte *contents,
+			 bfd_vma value)
 {
   bfd_vma insn;
 
@@ -2305,12 +2250,11 @@
 /* Perform the relocation for the CALL label24 instruction.  */
 
 static bfd_reloc_status_type
-elf32_frv_relocate_label24 (input_bfd, input_section, rello, contents, value)
-     bfd *input_bfd;
-     asection *input_section;
-     Elf_Internal_Rela *rello;
-     bfd_byte *contents;
-     bfd_vma value;
+elf32_frv_relocate_label24 (bfd *input_bfd,
+			    asection *input_section,
+			    Elf_Internal_Rela *rello,
+			    bfd_byte *contents,
+			    bfd_vma value)
 {
   bfd_vma insn;
   bfd_vma label6;
@@ -2348,14 +2292,12 @@
 }
 
 static bfd_reloc_status_type
-elf32_frv_relocate_gprelhi (info, input_bfd, input_section, relocation,
-			    contents, value)
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     Elf_Internal_Rela *relocation;
-     bfd_byte *contents;
-     bfd_vma value;
+elf32_frv_relocate_gprelhi (struct bfd_link_info *info,
+			    bfd *input_bfd,
+			    asection *input_section,
+			    Elf_Internal_Rela *relocation,
+			    bfd_byte *contents,
+			    bfd_vma value)
 {
   bfd_vma insn;
   bfd_vma gp;
@@ -2383,14 +2325,12 @@
 }
 
 static bfd_reloc_status_type
-elf32_frv_relocate_gprello (info, input_bfd, input_section, relocation,
-			    contents, value)
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     Elf_Internal_Rela *relocation;
-     bfd_byte *contents;
-     bfd_vma value;
+elf32_frv_relocate_gprello (struct bfd_link_info *info,
+			    bfd *input_bfd,
+			    asection *input_section,
+			    Elf_Internal_Rela *relocation,
+			    bfd_byte *contents,
+			    bfd_vma value)
 {
   bfd_vma insn;
   bfd_vma gp;
@@ -2419,9 +2359,8 @@
 }
 
 static reloc_howto_type *
-frv_reloc_type_lookup (abfd, code)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+frv_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+		       bfd_reloc_code_real_type code)
 {
   switch (code)
     {
@@ -2601,10 +2540,9 @@
 /* Set the howto pointer for an FRV ELF reloc.  */
 
 static void
-frv_info_to_howto_rela (abfd, cache_ptr, dst)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *cache_ptr;
-     Elf_Internal_Rela *dst;
+frv_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
+			arelent *cache_ptr,
+			Elf_Internal_Rela *dst)
 {
   unsigned int r_type;
 
@@ -2665,14 +2603,12 @@
    routines, but a few relocs, we have to do them ourselves.  */
 
 static bfd_reloc_status_type
-frv_final_link_relocate (howto, input_bfd, input_section, contents, rel,
-			 relocation)
-     reloc_howto_type *howto;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     Elf_Internal_Rela *rel;
-     bfd_vma relocation;
+frv_final_link_relocate (reloc_howto_type *howto,
+			 bfd *input_bfd,
+			 asection *input_section,
+			 bfd_byte *contents,
+			 Elf_Internal_Rela *rel,
+			 bfd_vma relocation)
 {
   return _bfd_final_link_relocate (howto, input_bfd, input_section,
 				   contents, rel->r_offset, relocation,
@@ -2711,16 +2647,14 @@
    accordingly.  */
 
 static bfd_boolean
-elf32_frv_relocate_section (output_bfd, info, input_bfd, input_section,
-			    contents, relocs, local_syms, local_sections)
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     Elf_Internal_Rela *relocs;
-     Elf_Internal_Sym *local_syms;
-     asection **local_sections;
+elf32_frv_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
+			    struct bfd_link_info *info,
+			    bfd *input_bfd,
+			    asection *input_section,
+			    bfd_byte *contents,
+			    Elf_Internal_Rela *relocs,
+			    Elf_Internal_Sym *local_syms,
+			    asection **local_sections)
 {
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
@@ -2812,9 +2746,9 @@
 	  name = h->root.root.string;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -2896,7 +2830,10 @@
 	default:
 	non_fdpic:
 	  picrel = NULL;
-	  if (h && ! FRVFDPIC_SYM_LOCAL (info, h))
+	  if (h
+	      && ! FRVFDPIC_SYM_LOCAL (info, h)
+	      && _bfd_elf_section_offset (output_bfd, info, input_section,
+					  rel->r_offset) != (bfd_vma) -1)
 	    {
 	      info->callbacks->einfo
 		(_("%H: relocation references symbol"
@@ -3426,7 +3363,7 @@
 		   with ldi @(grB, #gottlsoff12(symbol+offset), grC.
 		   Preserve the packing bit.  */
 		insn = (insn & (unsigned long)0xfe03f000)
-		  | (unsigned long)0x00c80000;;
+		  | (unsigned long)0x00c80000;
 		bfd_put_32 (input_bfd, insn, contents + rel->r_offset);
 
 		r_type = R_FRV_GOTTLSOFF12;
@@ -4156,14 +4093,13 @@
    file.  We use it to put .comm items in .scomm, and not .comm.  */
 
 static bfd_boolean
-elf32_frv_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     Elf_Internal_Sym *sym;
-     const char **namep ATTRIBUTE_UNUSED;
-     flagword *flagsp ATTRIBUTE_UNUSED;
-     asection **secp;
-     bfd_vma *valp;
+elf32_frv_add_symbol_hook (bfd *abfd,
+			   struct bfd_link_info *info,
+			   Elf_Internal_Sym *sym,
+			   const char **namep ATTRIBUTE_UNUSED,
+			   flagword *flagsp ATTRIBUTE_UNUSED,
+			   asection **secp,
+			   bfd_vma *valp)
 {
   if (sym->st_shndx == SHN_COMMON
       && !info->relocatable
@@ -4231,8 +4167,8 @@
   int offset;
 
   /* This function may be called more than once.  */
-  s = bfd_get_section_by_name (abfd, ".got");
-  if (s != NULL && (s->flags & SEC_LINKER_CREATED) != 0)
+  s = bfd_get_linker_section (abfd, ".got");
+  if (s != NULL)
     return TRUE;
 
   /* Machine specific: although pointers are 32-bits wide, we want the
@@ -4245,14 +4181,14 @@
 	   | SEC_LINKER_CREATED);
   pltflags = flags;
 
-  s = bfd_make_section_with_flags (abfd, ".got", flags);
+  s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
   if (s == NULL
       || !bfd_set_section_alignment (abfd, s, ptralign))
     return FALSE;
 
   if (bed->want_got_plt)
     {
-      s = bfd_make_section_with_flags (abfd, ".got.plt", flags);
+      s = bfd_make_section_anyway_with_flags (abfd, ".got.plt", flags);
       if (s == NULL
 	  || !bfd_set_section_alignment (abfd, s, ptralign))
 	return FALSE;
@@ -4290,8 +4226,8 @@
       if (! frvfdpic_relocs_info (info))
 	return FALSE;
 
-      s = bfd_make_section_with_flags (abfd, ".rel.got",
-				       (flags | SEC_READONLY));
+      s = bfd_make_section_anyway_with_flags (abfd, ".rel.got",
+					      (flags | SEC_READONLY));
       if (s == NULL
 	  || ! bfd_set_section_alignment (abfd, s, 2))
 	return FALSE;
@@ -4299,8 +4235,8 @@
       frvfdpic_gotrel_section (info) = s;
 
       /* Machine-specific.  */
-      s = bfd_make_section_with_flags (abfd, ".rofixup",
-				       (flags | SEC_READONLY));
+      s = bfd_make_section_anyway_with_flags (abfd, ".rofixup",
+					      (flags | SEC_READONLY));
       if (s == NULL
 	  || ! bfd_set_section_alignment (abfd, s, 2))
 	return FALSE;
@@ -4348,7 +4284,7 @@
   if (bed->plt_readonly)
     pltflags |= SEC_READONLY;
 
-  s = bfd_make_section_with_flags (abfd, ".plt", pltflags);
+  s = bfd_make_section_anyway_with_flags (abfd, ".plt", pltflags);
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
     return FALSE;
@@ -4367,8 +4303,8 @@
     }
 
   /* FRV-specific: we want rel relocations for the plt.  */
-  s = bfd_make_section_with_flags (abfd, ".rel.plt",
-				   flags | SEC_READONLY);
+  s = bfd_make_section_anyway_with_flags (abfd, ".rel.plt",
+					  flags | SEC_READONLY);
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
     return FALSE;
@@ -4415,8 +4351,8 @@
 	 image and use a R_*_COPY reloc to tell the dynamic linker to
 	 initialize them at run time.  The linker script puts the .dynbss
 	 section into the .bss section of the final image.  */
-      s = bfd_make_section_with_flags (abfd, ".dynbss",
-				       SEC_ALLOC | SEC_LINKER_CREATED);
+      s = bfd_make_section_anyway_with_flags (abfd, ".dynbss",
+					      SEC_ALLOC | SEC_LINKER_CREATED);
       if (s == NULL)
 	return FALSE;
 
@@ -4433,10 +4369,10 @@
      copy relocs.  */
       if (! info->shared)
 	{
-	  s = bfd_make_section_with_flags (abfd,
-					   (bed->default_use_rela_p
-					    ? ".rela.bss" : ".rel.bss"),
-					   flags | SEC_READONLY);
+	  s = bfd_make_section_anyway_with_flags (abfd,
+						  (bed->default_use_rela_p
+						   ? ".rela.bss" : ".rel.bss"),
+						  flags | SEC_READONLY);
 	  if (s == NULL
 	      || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
 	    return FALSE;
@@ -5501,7 +5437,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (bfd_byte *) ELF_DYNAMIC_INTERPRETER;
@@ -5558,36 +5494,10 @@
 elf32_frvfdpic_always_size_sections (bfd *output_bfd,
 				     struct bfd_link_info *info)
 {
-  if (!info->relocatable)
-    {
-      struct elf_link_hash_entry *h;
-
-      /* Force a PT_GNU_STACK segment to be created.  */
-      if (! elf_tdata (output_bfd)->stack_flags)
-	elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X;
-
-      /* Define __stacksize if it's not defined yet.  */
-      h = elf_link_hash_lookup (elf_hash_table (info), "__stacksize",
-				FALSE, FALSE, FALSE);
-      if (! h || h->root.type != bfd_link_hash_defined
-	  || h->type != STT_OBJECT
-	  || !h->def_regular)
-	{
-	  struct bfd_link_hash_entry *bh = NULL;
-
-	  if (!(_bfd_generic_link_add_one_symbol
-		(info, output_bfd, "__stacksize",
-		 BSF_GLOBAL, bfd_abs_section_ptr, DEFAULT_STACK_SIZE,
-		 (const char *) NULL, FALSE,
-		 get_elf_backend_data (output_bfd)->collect, &bh)))
-	    return FALSE;
-
-	  h = (struct elf_link_hash_entry *) bh;
-	  h->def_regular = 1;
-	  h->type = STT_OBJECT;
-	  /* This one must NOT be hidden.  */
-	}
-    }
+  if (!info->relocatable
+      && !bfd_elf_stack_segment_size (output_bfd, info,
+				      "__stacksize", DEFAULT_STACK_SIZE))
+    return FALSE;
 
   return TRUE;
 }
@@ -5597,7 +5507,7 @@
 static bfd_boolean
 _frvfdpic_check_discarded_relocs (bfd *abfd, asection *sec,
 				  struct bfd_link_info *info,
-				  
+
 				  bfd_boolean *changed)
 {
   Elf_Internal_Shdr *symtab_hdr;
@@ -5678,7 +5588,7 @@
 
   /* Account for relaxation of .eh_frame section.  */
   for (s = ibfd->sections; s; s = s->next)
-    if (s->sec_info_type == ELF_INFO_TYPE_EH_FRAME)
+    if (s->sec_info_type == SEC_INFO_TYPE_EH_FRAME)
       {
 	if (!_frvfdpic_check_discarded_relocs (ibfd, s, info, &changed))
 	  return FALSE;
@@ -5784,51 +5694,6 @@
   return TRUE;
 }
 
-static bfd_boolean
-elf32_frvfdpic_modify_program_headers (bfd *output_bfd,
-				       struct bfd_link_info *info)
-{
-  struct elf_obj_tdata *tdata = elf_tdata (output_bfd);
-  struct elf_segment_map *m;
-  Elf_Internal_Phdr *p;
-
-  /* objcopy and strip preserve what's already there using
-     elf32_frvfdpic_copy_private_bfd_data ().  */
-  if (! info)
-    return TRUE;
-
-  for (p = tdata->phdr, m = tdata->segment_map; m != NULL; m = m->next, p++)
-    if (m->p_type == PT_GNU_STACK)
-      break;
-
-  if (m)
-    {
-      struct elf_link_hash_entry *h;
-
-      /* Obtain the pointer to the __stacksize symbol.  */
-      h = elf_link_hash_lookup (elf_hash_table (info), "__stacksize",
-				FALSE, FALSE, FALSE);
-      if (h)
-	{
-	  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;
-	  BFD_ASSERT (h->root.type == bfd_link_hash_defined);
-	}
-
-      /* Set the header p_memsz from the symbol value.  We
-	 intentionally ignore the symbol section.  */
-      if (h && h->root.type == bfd_link_hash_defined)
-	p->p_memsz = h->root.u.def.value;
-      else
-	p->p_memsz = DEFAULT_STACK_SIZE;
-
-      p->p_align = 8;
-    }
-
-  return TRUE;
-}
-
 /* Fill in code and data in dynamic sections.  */
 
 static bfd_boolean
@@ -5910,7 +5775,7 @@
       Elf32_External_Dyn * dyncon;
       Elf32_External_Dyn * dynconend;
 
-      sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+      sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
       BFD_ASSERT (sdyn != NULL);
 
@@ -6147,11 +6012,10 @@
    Given infinite time and money... :-)  */
 
 static bfd_boolean
-elf32_frv_check_relocs (abfd, info, sec, relocs)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     asection *sec;
-     const Elf_Internal_Rela *relocs;
+elf32_frv_check_relocs (bfd *abfd,
+			struct bfd_link_info *info,
+			asection *sec,
+			const Elf_Internal_Rela *relocs)
 {
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
@@ -6182,6 +6046,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       switch (ELF32_R_TYPE (rel->r_info))
@@ -6407,8 +6275,7 @@
 /* Return the machine subcode from the ELF e_flags header.  */
 
 static int
-elf32_frv_machine (abfd)
-     bfd *abfd;
+elf32_frv_machine (bfd *abfd)
 {
   switch (elf_elfheader (abfd)->e_flags & EF_FRV_CPU_MASK)
     {
@@ -6429,8 +6296,7 @@
 /* Set the right machine number for a FRV ELF file.  */
 
 static bfd_boolean
-elf32_frv_object_p (abfd)
-     bfd *abfd;
+elf32_frv_object_p (bfd *abfd)
 {
   bfd_default_set_arch_mach (abfd, bfd_arch_frv, elf32_frv_machine (abfd));
   return (((elf_elfheader (abfd)->e_flags & EF_FRV_FDPIC) != 0)
@@ -6440,9 +6306,7 @@
 /* Function to set the ELF flag bits.  */
 
 static bfd_boolean
-frv_elf_set_private_flags (abfd, flags)
-     bfd *abfd;
-     flagword flags;
+frv_elf_set_private_flags (bfd *abfd, flagword flags)
 {
   elf_elfheader (abfd)->e_flags = flags;
   elf_flags_init (abfd) = TRUE;
@@ -6452,9 +6316,7 @@
 /* Copy backend specific data from one object module to another.  */
 
 static bfd_boolean
-frv_elf_copy_private_bfd_data (ibfd, obfd)
-     bfd *ibfd;
-     bfd *obfd;
+frv_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
 {
   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
@@ -6502,8 +6364,6 @@
 static bfd_boolean
 elf32_frvfdpic_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
 {
-  unsigned i;
-
   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
     return TRUE;
@@ -6515,31 +6375,6 @@
       || ! elf_tdata (obfd) || ! elf_tdata (obfd)->phdr)
     return TRUE;
 
-  /* Copy the stack size.  */
-  for (i = 0; i < elf_elfheader (ibfd)->e_phnum; i++)
-    if (elf_tdata (ibfd)->phdr[i].p_type == PT_GNU_STACK)
-      {
-	Elf_Internal_Phdr *iphdr = &elf_tdata (ibfd)->phdr[i];
-
-	for (i = 0; i < elf_elfheader (obfd)->e_phnum; i++)
-	  if (elf_tdata (obfd)->phdr[i].p_type == PT_GNU_STACK)
-	    {
-	      memcpy (&elf_tdata (obfd)->phdr[i], iphdr, sizeof (*iphdr));
-
-	      /* Rewrite the phdrs, since we're only called after they
-		 were first written.  */
-	      if (bfd_seek (obfd, (bfd_signed_vma) get_elf_backend_data (obfd)
-			    ->s->sizeof_ehdr, SEEK_SET) != 0
-		  || get_elf_backend_data (obfd)->s
-		  ->write_out_phdrs (obfd, elf_tdata (obfd)->phdr,
-				     elf_elfheader (obfd)->e_phnum) != 0)
-		return FALSE;
-	      break;
-	    }
-
-	break;
-      }
-
   return TRUE;
 }
 
@@ -6547,9 +6382,7 @@
    object file when linking.  */
 
 static bfd_boolean
-frv_elf_merge_private_bfd_data (ibfd, obfd)
-     bfd *ibfd;
-     bfd *obfd;
+frv_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
 {
   flagword old_flags, old_partial;
   flagword new_flags, new_partial;
@@ -6817,10 +6650,8 @@
 }
 
 
-bfd_boolean
-frv_elf_print_private_bfd_data (abfd, ptr)
-     bfd *abfd;
-     PTR ptr;
+static bfd_boolean
+frv_elf_print_private_bfd_data (bfd *abfd, void * ptr)
 {
   FILE *file = (FILE *) ptr;
   flagword flags;
@@ -6917,12 +6748,12 @@
          hardcoded offsets and sizes listed below (and contained within
 	 this lexical block) refer to fields in the target's elf_prstatus
 	 struct.  */
-      case 268:	
+      case 268:
 	/* `pr_cursig' is at offset 12.  */
-	elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+	elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
 
 	/* `pr_pid' is at offset 24.  */
-	elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
+	elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
 
 	/* `pr_reg' is at offset 72.  */
 	offset = 72;
@@ -6933,7 +6764,7 @@
 	   and `pr_interp_fdpic_loadmap', both of which (by design)
 	   immediately follow `pr_reg'.  This will allow these fields to
 	   be viewed by GDB as registers.
-	   
+
 	   `pr_reg' is 184 bytes long.  `pr_exec_fdpic_loadmap' and
 	   `pr_interp_fdpic_loadmap' are 4 bytes each.  */
 	raw_size = 184 + 4 + 4;
@@ -6958,11 +6789,11 @@
       case 124:
 
 	/* `pr_fname' is found at offset 28 and is 16 bytes long.  */
-	elf_tdata (abfd)->core_program
+	elf_tdata (abfd)->core->program
 	  = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
 
 	/* `pr_psargs' is found at offset 44 and is 80 bytes long.  */
-	elf_tdata (abfd)->core_command
+	elf_tdata (abfd)->core->command
 	  = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
     }
 
@@ -6971,7 +6802,7 @@
      implementations, so strip it off if it exists.  */
 
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
@@ -6995,6 +6826,7 @@
 #define elf_backend_object_p			elf32_frv_object_p
 #define elf_backend_add_symbol_hook             elf32_frv_add_symbol_hook
 
+#define elf_backend_stack_align			8
 #define elf_backend_can_gc_sections		1
 #define elf_backend_rela_normal			1
 
@@ -7039,9 +6871,6 @@
 #undef elf_backend_always_size_sections
 #define elf_backend_always_size_sections \
 		elf32_frvfdpic_always_size_sections
-#undef elf_backend_modify_program_headers
-#define elf_backend_modify_program_headers \
-		elf32_frvfdpic_modify_program_headers
 #undef bfd_elf32_bfd_copy_private_bfd_data
 #define bfd_elf32_bfd_copy_private_bfd_data \
 		elf32_frvfdpic_copy_private_bfd_data
diff --git a/bfd/elf32-h8300.c b/bfd/elf32-h8300.c
index 95d3983..67bca3f 100644
--- a/bfd/elf32-h8300.c
+++ b/bfd/elf32-h8300.c
@@ -1,6 +1,5 @@
 /* BFD back-end for Renesas H8/300 ELF binaries.
-   Copyright 1993, 1995, 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007, 2009, 2010 Free Software Foundation, Inc.
+   Copyright 1993-2013 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -52,12 +51,13 @@
    bfd_byte *, Elf_Internal_Rela *,
    Elf_Internal_Sym *, asection **);
 static bfd_reloc_status_type special
-  (bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **);
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 
 /* This does not include any relocation information, but should be
    good enough for GDB or objdump to read the file.  */
 
-static reloc_howto_type h8_elf_howto_table[] = {
+static reloc_howto_type h8_elf_howto_table[] =
+{
 #define R_H8_NONE_X 0
   HOWTO (R_H8_NONE,		/* type */
 	 0,			/* rightshift */
@@ -184,7 +184,21 @@
 	 0,			/* src_mask */
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
-#define R_H8_PCREL16_X (R_H8_DIR32A16_X + 1)
+#define R_H8_DISP32A16_X (R_H8_DIR32A16_X + 1)
+  HOWTO (R_H8_DISP32A16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 special,		/* special_function */
+	 "R_H8_DISP32A16",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+#define R_H8_PCREL16_X (R_H8_DISP32A16_X + 1)
   HOWTO (R_H8_PCREL16,		/* type */
 	 0,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -233,6 +247,7 @@
   { BFD_RELOC_H8_DIR24A8, R_H8_DIR24A8_X },
   { BFD_RELOC_H8_DIR24R8, R_H8_DIR24R8_X },
   { BFD_RELOC_H8_DIR32A16, R_H8_DIR32A16_X },
+  { BFD_RELOC_H8_DISP32A16, R_H8_DISP32A16_X },
   { BFD_RELOC_16_PCREL, R_H8_PCREL16_X },
   { BFD_RELOC_8_PCREL, R_H8_PCREL8_X },
 };
@@ -304,7 +319,7 @@
 special (bfd *abfd ATTRIBUTE_UNUSED,
 	 arelent *reloc_entry ATTRIBUTE_UNUSED,
 	 asymbol *symbol ATTRIBUTE_UNUSED,
-	 PTR data ATTRIBUTE_UNUSED,
+	 void * data ATTRIBUTE_UNUSED,
 	 asection *input_section ATTRIBUTE_UNUSED,
 	 bfd *output_bfd,
 	 char **error_message ATTRIBUTE_UNUSED)
@@ -337,6 +352,7 @@
 
     case R_H8_DIR32:
     case R_H8_DIR32A16:
+    case R_H8_DISP32A16:
     case R_H8_DIR24A8:
       value += addend;
       bfd_put_32 (input_bfd, value, hit_data);
@@ -460,9 +476,9 @@
 				   unresolved_reloc, warned);
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -669,7 +685,9 @@
      bset:24/32	     ->    bset:16                2 bytes
      (also applicable to other bit manipulation instructions)
 
-     mov.[bwl]:24/32 ->    mov.[bwl]:16           2 bytes */
+     mov.[bwl]:24/32 ->    mov.[bwl]:16           2 bytes
+
+     mov.[bwl] @(displ:24/32+ERx) -> mov.[bwl] @(displ:16+ERx)  4 bytes.  */
 
 static bfd_boolean
 elf32_h8_relax_section (bfd *abfd, asection *sec,
@@ -699,7 +717,7 @@
 
   /* Get a copy of the native relocations.  */
   internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
 		      link_info->keep_memory));
   if (internal_relocs == NULL)
     goto error_return;
@@ -724,13 +742,19 @@
 	 some long jumps created by the compiler.  */
       if (irel != internal_relocs)
 	last_reloc = irel - 1;
-
-      if (ELF32_R_TYPE (irel->r_info) != R_H8_DIR24R8
-	  && ELF32_R_TYPE (irel->r_info) != R_H8_PCREL16
-	  && ELF32_R_TYPE (irel->r_info) != R_H8_DIR16A8
-	  && ELF32_R_TYPE (irel->r_info) != R_H8_DIR24A8
-	  && ELF32_R_TYPE (irel->r_info) != R_H8_DIR32A16)
-	continue;
+      
+      switch(ELF32_R_TYPE (irel->r_info))
+	{
+	case R_H8_DIR24R8:
+	case R_H8_PCREL16:
+	case R_H8_DIR16A8:
+	case R_H8_DIR24A8:
+	case R_H8_DIR32A16:
+	case R_H8_DISP32A16:
+	  break;
+	default:
+	  continue;
+	}
 
       /* Get the section contents if we haven't done so already.  */
       if (contents == NULL)
@@ -806,8 +830,8 @@
 	 the linker is run.  */
       switch (ELF32_R_TYPE (irel->r_info))
 	{
-        /* Try to turn a 24-bit absolute branch/call into an 8-bit
-	   pc-relative branch/call.  */
+	  /* Try to turn a 24-bit absolute branch/call into an 8-bit
+	     pc-relative branch/call.  */
 	case R_H8_DIR24R8:
 	  {
 	    bfd_vma value = symval + irel->r_addend;
@@ -847,19 +871,19 @@
 		   Only perform this optimisation for jumps (code 0x5a) not
 		   subroutine calls, as otherwise it could transform:
 
-		   	             mov.w   r0,r0
-		   	             beq     .L1
-		         	     jsr     @_bar
-		              .L1:   rts
-		              _bar:  rts
+		   mov.w   r0,r0
+		   beq     .L1
+		   jsr     @_bar
+		   .L1:   rts
+		   _bar:  rts
 		   into:
-		   	             mov.w   r0,r0
-			             bne     _bar
-			             rts
-			      _bar:  rts
+		   mov.w   r0,r0
+		   bne     _bar
+		   rts
+		   _bar:  rts
 
 		   which changes the call (jsr) into a branch (bne).  */
-		if (code == 0x5a
+		if (code == 0x5a	/* jmp24.  */
 		    && (int) gap <= 130
 		    && (int) gap >= -128
 		    && last_reloc
@@ -903,7 +927,7 @@
 			code ^= 1;
 			bfd_put_8 (abfd,
 				   code,
-			contents + last_reloc->r_offset - 1);
+				   contents + last_reloc->r_offset - 1);
 
 			/* Delete four bytes of data.  */
 			if (!elf32_h8_relax_delete_bytes (abfd, sec,
@@ -917,11 +941,11 @@
 		  }
 
 		if (code == 0x5e)
-		  /* This is jsr.  */
-		  bfd_put_8 (abfd, 0x55, contents + irel->r_offset - 1);
+		  /* This is jsr24  */
+		  bfd_put_8 (abfd, 0x55, contents + irel->r_offset - 1);	/* bsr8. */
 		else if (code == 0x5a)
-		  /* This is jmp.  */
-		  bfd_put_8 (abfd, 0x40, contents + irel->r_offset - 1);
+		  /* This is jmp24  */
+		  bfd_put_8 (abfd, 0x40, contents + irel->r_offset - 1);	/* bra8. */
 		else
 		  abort ();
 
@@ -941,8 +965,8 @@
 	    break;
 	  }
 
-	/* Try to turn a 16-bit pc-relative branch into a 8-bit pc-relative
-	   branch.  */
+	  /* Try to turn a 16-bit pc-relative branch into a 8-bit pc-relative
+	     branch.  */
 	case R_H8_PCREL16:
 	  {
 	    bfd_vma value = symval + irel->r_addend;
@@ -979,18 +1003,18 @@
 		       contains the condition code.  */
 		    code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
 
-		    /* Compute the fisrt byte of the relaxed
+		    /* Compute the first byte of the relaxed
 		       instruction.  The original sequence 0x58 0xX0
 		       is relaxed to 0x4X, where X represents the
 		       condition code.  */
 		    code &= 0xf0;
 		    code >>= 4;
 		    code |= 0x40;
-		    bfd_put_8 (abfd, code, contents + irel->r_offset - 2);
+		    bfd_put_8 (abfd, code, contents + irel->r_offset - 2); /* bCC:8.  */
 		  }
-		else if (code == 0x5c)
+		else if (code == 0x5c)	/* bsr16.  */
 		  /* This is bsr.  */
-		  bfd_put_8 (abfd, 0x55, contents + irel->r_offset - 2);
+		  bfd_put_8 (abfd, 0x55, contents + irel->r_offset - 2);  /* bsr8.  */
 		else
 		  /* Might be MOVSD.  */
 		  break;
@@ -1012,15 +1036,15 @@
 	    break;
 	  }
 
-	/* This is a 16-bit absolute address in one of the following
-	   instructions:
+	  /* This is a 16-bit absolute address in one of the following
+	     instructions:
 
 	     "band", "bclr", "biand", "bild", "bior", "bist", "bixor",
 	     "bld", "bnot", "bor", "bset", "bst", "btst", "bxor", and
 	     "mov.b"
 
-	   We may relax this into an 8-bit absolute address if it's in
-	   the right range.  */
+	     We may relax this into an 8-bit absolute address if it's in
+	     the right range.  */
 	case R_H8_DIR16A8:
 	  {
 	    bfd_vma value;
@@ -1100,15 +1124,15 @@
 	    break;
 	  }
 
-	/* This is a 24-bit absolute address in one of the following
-	   instructions:
+	  /* This is a 24-bit absolute address in one of the following
+	     instructions:
 
 	     "band", "bclr", "biand", "bild", "bior", "bist", "bixor",
 	     "bld", "bnot", "bor", "bset", "bst", "btst", "bxor", and
 	     "mov.b"
 
-	   We may relax this into an 8-bit absolute address if it's in
-	   the right range.  */
+	     We may relax this into an 8-bit absolute address if it's in
+	     the right range.  */
 	case R_H8_DIR24A8:
 	  {
 	    bfd_vma value;
@@ -1175,7 +1199,7 @@
 					     R_H8_DIR8);
 		irel->r_offset--;
 
-		/* Delete two bytes of data.  */
+		/* Delete four bytes of data.  */
 		if (!elf32_h8_relax_delete_bytes (abfd, sec,
 						  irel->r_offset + 1, 4))
 		  goto error_return;
@@ -1192,9 +1216,9 @@
 	  /* This is a 24-/32-bit absolute address in one of the
 	     following instructions:
 
-	       "band", "bclr", "biand", "bild", "bior", "bist",
-	       "bixor", "bld", "bnot", "bor", "bset", "bst", "btst",
-	       "bxor", "ldc.w", "stc.w" and "mov.[bwl]"
+	     "band", "bclr", "biand", "bild", "bior", "bist",
+	     "bixor", "bld", "bnot", "bor", "bset", "bst", "btst",
+	     "bxor", "ldc.w", "stc.w" and "mov.[bwl]"
 
 	     We may relax this into an 16-bit absolute address if it's
 	     in the right range.  */
@@ -1217,7 +1241,7 @@
 
 		if (irel->r_offset >= 4)
 		  {
-		    /* Check for 4-byte MOVA relaxation.  */
+		    /* Check for 4-byte MOVA relaxation (SH-specific).  */
 		    int second_reloc = 0;
 
 		    op_ptr = contents + irel->r_offset - 4;
@@ -1238,7 +1262,8 @@
 			    second_reloc = 1;
 			  }
 		      }
-		    if (irel < irelend)
+
+		    if (irel + 1 < irelend)
 		      {
 			Elf_Internal_Rela *next_reloc = irel + 1;
 			arelent bfd_reloc;
@@ -1283,7 +1308,7 @@
 		      }
 		  }
 
-		/* Now check for short version of MOVA.  */
+		/* Now check for short version of MOVA.  (SH-specific) */
 		op_ptr = contents + irel->r_offset - 2;
 		op0 = bfd_get_8 (abfd, op_ptr + 0);
 		op1 = bfd_get_8 (abfd, op_ptr + 1);
@@ -1320,9 +1345,99 @@
 		   Note that this is not required, and it may be slow.  */
 		*again = TRUE;
 	      }
-	    break;
+	    break;	/* case R_H8_DIR32A16 */
 	  }
 
+	case R_H8_DISP32A16:
+	  /* mov.[bwl] @(displ:24/32+ERx) -> mov.[bwl] @(displ:16+ERx)  4 bytes
+	     It is assured that instruction uses at least 4 bytes opcode before
+	     reloc entry addressing mode "register indirect with displacement"
+	     relaxing options (all saving 4 bytes):
+	     0x78 0sss0000 0x6A 0010dddd disp:32  mov.b @(d:32,ERs),Rd  ->
+	     0x6E 0sssdddd disp:16  mov.b @(d:16,ERs),Rd
+	     0x78 0sss0000 0x6B 0010dddd disp:32  mov.w @(d:32,ERs),Rd  ->
+	     0x6F 0sssdddd disp:16  mov.w @(d:16,ERs),Rd
+	     0x01 0x00 0x78 0sss0000 0x6B 00100ddd disp:32  mov.l @(d:32,ERs),ERd ->
+	     0x01 0x00 0x6F 0sss0ddd disp:16  mov.l @(d:16,ERs),ERd
+
+	     0x78 0ddd0000 0x6A 1010ssss disp:32  mov.b Rs,@(d:32,ERd)  ->
+	     0x6E 1dddssss disp:16  mov.b Rs,@(d:16,ERd)
+	     0x78 0ddd0000 0x6B 1010ssss disp:32  mov.w Rs,@(d:32,ERd)  ->
+	     0x6F 1dddssss disp:16  mov.w Rs,@(d:16,ERd)
+	     0x01 0x00 0x78 xddd0000 0x6B 10100sss disp:32  mov.l ERs,@(d:32,ERd) ->
+	     0x01 0x00 0x6F 1ddd0sss disp:16  mov.l ERs,@(d:16,ERd)
+	     mov.l prefix 0x01 0x00 can be left as is and mov.l handled same
+	     as mov.w/  */
+	  {
+	    bfd_vma value;
+
+	    value = bfd_h8300_pad_address (abfd, symval + irel->r_addend);
+	    if (value <= 0x7fff || value >= 0xffff8000u)
+	      {
+		unsigned char op0, op1, op2, op3, op0n, op1n;
+		int relax = 0;
+
+		/* Note that we've changed the relocs, section contents,
+		   etc.  */
+		elf_section_data (sec)->relocs = internal_relocs;
+		elf_section_data (sec)->this_hdr.contents = contents;
+		symtab_hdr->contents = (unsigned char *) isymbuf;
+
+		if (irel->r_offset >= 4)
+		  {
+		    op0 = bfd_get_8 (abfd, contents + irel->r_offset - 4);
+		    op1 = bfd_get_8 (abfd, contents + irel->r_offset - 3);
+		    op2 = bfd_get_8 (abfd, contents + irel->r_offset - 2);
+		    op3 = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+
+		    if (op0 == 0x78)
+		      {
+			switch(op2)
+			  {
+			  case 0x6A:
+			    if ((op1 & 0x8F) == 0x00 && (op3 & 0x70) == 0x20)
+			      {
+				/* mov.b.  */
+				op0n = 0x6E;
+				relax = 1;
+			      }
+			    break;
+			  case 0x6B:
+			    if ((op1 & 0x0F) == 0x00 && (op3 & 0x70) == 0x20)
+			      {
+				/* mov.w/l.  */
+				op0n = 0x6F;
+				relax = 1;
+			      }
+			    break;
+			  default:
+			    break;
+			  }
+		      }
+		  }
+
+		if (relax)
+		  {
+		    op1n = (op3 & 0x8F) | (op1 & 0x70);
+		    bfd_put_8 (abfd, op0n, contents + irel->r_offset - 4);
+		    bfd_put_8 (abfd, op1n, contents + irel->r_offset - 3);
+
+		    /* Fix the relocation's type.  */
+		    irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_H8_DIR16);
+		    irel->r_offset -= 2;
+
+		    /* Delete four bytes of data.  */
+		    if (!elf32_h8_relax_delete_bytes (abfd, sec, irel->r_offset + 2, 4))
+		      goto error_return;
+
+		    /* That will change things, so, we should relax again.
+		       Note that this is not required, and it may be slow.  */
+		    *again = TRUE;
+		  }
+	      }
+	  }
+	  break;
+
 	default:
 	  break;
 	}
@@ -1403,7 +1518,7 @@
     {
       /* Get the new reloc address.  */
       if ((irel->r_offset > addr
-	   && irel->r_offset < toaddr))
+	   && irel->r_offset <= toaddr))
 	irel->r_offset -= count;
     }
 
@@ -1415,7 +1530,7 @@
     {
       if (isym->st_shndx == sec_shndx
 	  && isym->st_value > addr
-	  && isym->st_value < toaddr)
+	  && isym->st_value <= toaddr)
 	isym->st_value -= count;
     }
 
@@ -1427,14 +1542,13 @@
   for (; sym_hashes < end_hashes; sym_hashes++)
     {
       struct elf_link_hash_entry *sym_hash = *sym_hashes;
+
       if ((sym_hash->root.type == bfd_link_hash_defined
 	   || sym_hash->root.type == bfd_link_hash_defweak)
 	  && sym_hash->root.u.def.section == sec
 	  && sym_hash->root.u.def.value > addr
-	  && sym_hash->root.u.def.value < toaddr)
-	{
-	  sym_hash->root.u.def.value -= count;
-	}
+	  && sym_hash->root.u.def.value <= toaddr)
+	sym_hash->root.u.def.value -= count;
     }
 
   return TRUE;
@@ -1523,7 +1637,7 @@
       bfd_size_type amt;
 
       internal_relocs = (_bfd_elf_link_read_relocs
-			 (input_bfd, input_section, (PTR) NULL,
+			 (input_bfd, input_section, NULL,
 			  (Elf_Internal_Rela *) NULL, FALSE));
       if (internal_relocs == NULL)
 	goto error_return;
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 7f0f2cb..dfffbcb 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -1,7 +1,5 @@
 /* BFD back-end for HP PA-RISC ELF files.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright 1990-2013 Free Software Foundation, Inc.
 
    Original code by
 	Center for Software Science
@@ -10,7 +8,7 @@
    Largely rewritten by Alan Modra <[email protected]>
    Naming cleanup by Carlos O'Donell <[email protected]>
    TLS support written by Randolph Chung <[email protected]>
- 
+
    This file is part of BFD, the Binary File Descriptor library.
 
    This program is free software; you can redistribute it and/or modify
@@ -124,20 +122,20 @@
    Structure/Variable         		Prefix
    elf_link_hash_table			"etab"
    elf_link_hash_entry			"eh"
-   
+
    elf32_hppa_link_hash_table		"htab"
    elf32_hppa_link_hash_entry		"hh"
 
    bfd_hash_table			"btab"
    bfd_hash_entry			"bh"
-   
+
    bfd_hash_table containing stubs	"bstab"
    elf32_hppa_stub_hash_entry		"hsh"
 
    elf32_hppa_dyn_reloc_entry		"hdh"
-   
+
    Always remember to use GNU Coding Style. */
-					  
+
 #define PLT_ENTRY_SIZE 8
 #define GOT_ENTRY_SIZE 4
 #define ELF_DYNAMIC_INTERPRETER "/lib/ld.so.1"
@@ -419,7 +417,7 @@
   struct elf32_hppa_link_hash_table *htab;
   bfd_size_type amt = sizeof (*htab);
 
-  htab = bfd_malloc (amt);
+  htab = bfd_zmalloc (amt);
   if (htab == NULL)
     return NULL;
 
@@ -436,26 +434,8 @@
 			    sizeof (struct elf32_hppa_stub_hash_entry)))
     return NULL;
 
-  htab->stub_bfd = NULL;
-  htab->add_stub_section = NULL;
-  htab->layout_sections_again = NULL;
-  htab->stub_group = NULL;
-  htab->sgot = NULL;
-  htab->srelgot = NULL;
-  htab->splt = NULL;
-  htab->srelplt = NULL;
-  htab->sdynbss = NULL;
-  htab->srelbss = NULL;
   htab->text_segment_base = (bfd_vma) -1;
   htab->data_segment_base = (bfd_vma) -1;
-  htab->multi_subspace = 0;
-  htab->has_12bit_branch = 0;
-  htab->has_17bit_branch = 0;
-  htab->has_22bit_branch = 0;
-  htab->need_plt_stub = 0;
-  htab->sym_cache.abfd = NULL;
-  htab->tls_ldm_got.refcount = 0;
-
   return &htab->etab.root;
 }
 
@@ -468,7 +448,7 @@
     = (struct elf32_hppa_link_hash_table *) btab;
 
   bfd_hash_table_free (&htab->bstab);
-  _bfd_generic_link_hash_table_free (btab);
+  _bfd_elf_link_hash_table_free (btab);
 }
 
 /* Build a name for an entry in the stub hash table.  */
@@ -1005,14 +985,14 @@
   if (! _bfd_elf_create_dynamic_sections (abfd, info))
     return FALSE;
 
-  htab->splt = bfd_get_section_by_name (abfd, ".plt");
-  htab->srelplt = bfd_get_section_by_name (abfd, ".rela.plt");
+  htab->splt = bfd_get_linker_section (abfd, ".plt");
+  htab->srelplt = bfd_get_linker_section (abfd, ".rela.plt");
 
-  htab->sgot = bfd_get_section_by_name (abfd, ".got");
-  htab->srelgot = bfd_get_section_by_name (abfd, ".rela.got");
+  htab->sgot = bfd_get_linker_section (abfd, ".got");
+  htab->srelgot = bfd_get_linker_section (abfd, ".rela.got");
 
-  htab->sdynbss = bfd_get_section_by_name (abfd, ".dynbss");
-  htab->srelbss = bfd_get_section_by_name (abfd, ".rela.bss");
+  htab->sdynbss = bfd_get_linker_section (abfd, ".dynbss");
+  htab->srelbss = bfd_get_linker_section (abfd, ".rela.bss");
 
   /* hppa-linux needs _GLOBAL_OFFSET_TABLE_ to be visible from the main
      application, because __canonicalize_funcptr_for_compare needs it.  */
@@ -1110,7 +1090,7 @@
 {
   Elf_Internal_Shdr *symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   bfd_signed_vma *local_refcounts;
-                  
+
   local_refcounts = elf_local_got_refcounts (abfd);
   if (local_refcounts == NULL)
     {
@@ -1187,6 +1167,10 @@
 	  while (hh->eh.root.type == bfd_link_hash_indirect
 		 || hh->eh.root.type == bfd_link_hash_warning)
 	    hh = hppa_elf_hash_entry (hh->eh.root.u.i.link);
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  hh->eh.root.non_ir_ref = 1;
 	}
 
       r_type = ELF32_R_TYPE (rela->r_info);
@@ -1378,7 +1362,7 @@
 	      else
 	        {
 	          bfd_signed_vma *local_got_refcounts;
-		  
+
 	          /* This is a global offset table entry for a local symbol.  */
 	          local_got_refcounts = hppa32_elf_local_refcounts (abfd);
 	          if (local_got_refcounts == NULL)
@@ -1724,10 +1708,10 @@
 
       case 396:		/* Linux/hppa */
 	/* pr_cursig */
-	elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+	elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
 
 	/* pr_pid */
-	elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
+	elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
 
 	/* pr_reg */
 	offset = 72;
@@ -1750,9 +1734,9 @@
 	return FALSE;
 
       case 124:		/* Linux/hppa elf_prpsinfo.  */
-	elf_tdata (abfd)->core_program
+	elf_tdata (abfd)->core->program
 	  = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
-	elf_tdata (abfd)->core_command
+	elf_tdata (abfd)->core->command
 	  = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
     }
 
@@ -1760,7 +1744,7 @@
      onto the end of the args in some (at least one anyway)
      implementations, so strip it off if it exists.  */
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
@@ -1789,10 +1773,12 @@
 	}
     }
 
-  if (! hppa_elf_hash_entry (eh)->plabel)
+  /* STT_GNU_IFUNC symbol must go through PLT.  */
+  if (! hppa_elf_hash_entry (eh)->plabel
+      && eh->type != STT_GNU_IFUNC)
     {
       eh->needs_plt = 0;
-      eh->plt = elf_hash_table (info)->init_plt_refcount;
+      eh->plt = elf_hash_table (info)->init_plt_offset;
     }
 }
 
@@ -1814,6 +1800,13 @@
   if (eh->type == STT_FUNC
       || eh->needs_plt)
     {
+      /* If the symbol is used by a plabel, we must allocate a PLT slot.
+	 The refcounts are not reliable when it has been hidden since
+	 hide_symbol can be called before the plabel flag is set.  */
+      if (hppa_elf_hash_entry (eh)->plabel
+	  && eh->plt.refcount <= 0)
+	eh->plt.refcount = 1;
+
       if (eh->plt.refcount <= 0
 	  || (eh->def_regular
 	      && eh->root.type != bfd_link_hash_defweak
@@ -1889,13 +1882,6 @@
 	}
     }
 
-  if (eh->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-			     eh->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -1913,7 +1899,7 @@
   /* We must generate a COPY reloc to tell the dynamic linker to
      copy the initial value out of the dynamic object and into the
      runtime process image.  */
-  if ((eh->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((eh->root.u.def.section->flags & SEC_ALLOC) != 0 && eh->size != 0)
     {
       htab->srelbss->size += sizeof (Elf32_External_Rela);
       eh->needs_copy = 1;
@@ -1963,7 +1949,7 @@
 	     means that the plt entry is only used by a plabel.
 	     We'll be using a normal plt entry for this symbol, so
 	     clear the plabel indicator.  */
-	  
+
 	  hh->plabel = 0;
 	}
       else if (hh->plabel)
@@ -2011,7 +1997,7 @@
     return FALSE;
 
   hh = hppa_elf_hash_entry (eh);
-  
+
   if (htab->etab.dynamic_sections_created
       && eh->plt.offset != (bfd_vma) -1
       && !hh->plabel
@@ -2112,7 +2098,7 @@
       /* For the non-shared case, discard space for relocs against
 	 symbols which turn out to need copy relocs or are not
 	 dynamic.  */
-      
+
       if (!eh->non_got_ref
 	  && ((ELIMINATE_COPY_RELOCS
 	       && eh->def_dynamic
@@ -2223,7 +2209,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  sec = bfd_get_section_by_name (dynobj, ".interp");
+	  sec = bfd_get_linker_section (dynobj, ".interp");
 	  if (sec == NULL)
 	    abort ();
 	  sec->size = sizeof ELF_DYNAMIC_INTERPRETER;
@@ -2299,7 +2285,7 @@
 		sec->size += 2 * GOT_ENTRY_SIZE;
 	      else if ((*local_tls_type & GOT_TLS_GD) == GOT_TLS_GD)
 		sec->size += GOT_ENTRY_SIZE;
-	      if (info->shared) 
+	      if (info->shared)
 	        {
 		  srel->size += sizeof (Elf32_External_Rela);
 		  if ((*local_tls_type & (GOT_TLS_GD | GOT_TLS_IE)) == (GOT_TLS_GD | GOT_TLS_IE))
@@ -2340,10 +2326,10 @@
 	    }
 	}
     }
-  
+
   if (htab->tls_ldm_got.refcount > 0)
     {
-      /* Allocate 2 got entries and 1 dynamic reloc for 
+      /* Allocate 2 got entries and 1 dynamic reloc for
          R_PARISC_TLS_DTPMOD32 relocs.  */
       htab->tls_ldm_got.offset = htab->sgot->size;
       htab->sgot->size += (GOT_ENTRY_SIZE * 2);
@@ -2382,7 +2368,7 @@
 	      bfd_size_type mask;
 
 	      if (gotalign > pltalign)
-		bfd_set_section_alignment (dynobj, sec, gotalign);
+		(void) bfd_set_section_alignment (dynobj, sec, gotalign);
 	      mask = ((bfd_size_type) 1 << gotalign) - 1;
 	      sec->size = (sec->size + sizeof (plt_stub) + mask) & ~mask;
 	    }
@@ -3218,7 +3204,7 @@
 }
 
 /* Return the base vma address which should be subtracted from the real
-   address when resolving a dtpoff relocation.  
+   address when resolving a dtpoff relocation.
    This is PT_TLS segment p_vaddr.  */
 
 static bfd_vma
@@ -3240,9 +3226,9 @@
   /* If tls_sec is NULL, we should have signalled an error already.  */
   if (htab->tls_sec == NULL)
     return 0;
-  /* hppa TLS ABI is variant I and static TLS block start just after 
+  /* hppa TLS ABI is variant I and static TLS block start just after
      tcbhead structure which has 2 pointer fields.  */
-  return (address - htab->tls_sec->vma 
+  return (address - htab->tls_sec->vma
 	  + align_power ((bfd_vma) 8, htab->tls_sec->alignment_power));
 }
 
@@ -3321,7 +3307,7 @@
   bfd_signed_vma addend = rela->r_addend;
   bfd_vma location;
   struct elf32_hppa_stub_hash_entry *hsh = NULL;
-  int val;  
+  int val;
 
   if (r_type == R_PARISC_NONE)
     return bfd_reloc_ok;
@@ -3340,10 +3326,16 @@
       switch (r_type)
 	{
 	  case R_PARISC_DLTIND21L:
+	  case R_PARISC_TLS_GD21L:
+	  case R_PARISC_TLS_LDM21L:
+	  case R_PARISC_TLS_IE21L:
 	    r_type = R_PARISC_DPREL21L;
 	    break;
 
 	  case R_PARISC_DLTIND14R:
+	  case R_PARISC_TLS_GD14R:
+	  case R_PARISC_TLS_LDM14R:
+	  case R_PARISC_TLS_IE14R:
 	    r_type = R_PARISC_DPREL14R;
 	    break;
 
@@ -3409,53 +3401,48 @@
     case R_PARISC_DPREL21L:
     case R_PARISC_DPREL14R:
     case R_PARISC_DPREL14F:
-    case R_PARISC_TLS_GD21L:
-    case R_PARISC_TLS_LDM21L:
-    case R_PARISC_TLS_IE21L:
       /* Convert instructions that use the linkage table pointer (r19) to
 	 instructions that use the global data pointer (dp).  This is the
 	 most efficient way of using PIC code in an incomplete executable,
 	 but the user must follow the standard runtime conventions for
 	 accessing data for this to work.  */
-      if (orig_r_type == R_PARISC_DLTIND21L
-	  || (!info->shared
-	      && (r_type == R_PARISC_TLS_GD21L
-		  || r_type == R_PARISC_TLS_LDM21L
-		  || r_type == R_PARISC_TLS_IE21L)))
+      if (orig_r_type != r_type)
 	{
-	  /* Convert addil instructions if the original reloc was a
-	     DLTIND21L.  GCC sometimes uses a register other than r19 for
-	     the operation, so we must convert any addil instruction
-	     that uses this relocation.  */
-	  if ((insn & 0xfc000000) == ((int) OP_ADDIL << 26))
-	    insn = ADDIL_DP;
-	  else
-	    /* We must have a ldil instruction.  It's too hard to find
-	       and convert the associated add instruction, so issue an
-	       error.  */
-	    (*_bfd_error_handler)
-	      (_("%B(%A+0x%lx): %s fixup for insn 0x%x is not supported in a non-shared link"),
-	       input_bfd,
-	       input_section,
-	       (long) offset,
-	       howto->name,
-	       insn);
-	}
-      else if (orig_r_type == R_PARISC_DLTIND14F)
-	{
-	  /* This must be a format 1 load/store.  Change the base
-	     register to dp.  */
-	  insn = (insn & 0xfc1ffff) | (27 << 21);
+	  if (r_type == R_PARISC_DPREL21L)
+	    {
+	      /* GCC sometimes uses a register other than r19 for the
+		 operation, so we must convert any addil instruction
+		 that uses this relocation.  */
+	      if ((insn & 0xfc000000) == ((int) OP_ADDIL << 26))
+		insn = ADDIL_DP;
+	      else
+		/* We must have a ldil instruction.  It's too hard to find
+		   and convert the associated add instruction, so issue an
+		   error.  */
+		(*_bfd_error_handler)
+		  (_("%B(%A+0x%lx): %s fixup for insn 0x%x is not supported in a non-shared link"),
+		   input_bfd,
+		   input_section,
+		   (long) offset,
+		   howto->name,
+		   insn);
+	    }
+	  else if (r_type == R_PARISC_DPREL14F)
+	    {
+	      /* This must be a format 1 load/store.  Change the base
+		 register to dp.  */
+	      insn = (insn & 0xfc1ffff) | (27 << 21);
+	    }
 	}
 
-    /* For all the DP relative relocations, we need to examine the symbol's
-       section.  If it has no section or if it's a code section, then
-       "data pointer relative" makes no sense.  In that case we don't
-       adjust the "value", and for 21 bit addil instructions, we change the
-       source addend register from %dp to %r0.  This situation commonly
-       arises for undefined weak symbols and when a variable's "constness"
-       is declared differently from the way the variable is defined.  For
-       instance: "extern int foo" with foo defined as "const int foo".  */
+      /* For all the DP relative relocations, we need to examine the symbol's
+	 section.  If it has no section or if it's a code section, then
+	 "data pointer relative" makes no sense.  In that case we don't
+	 adjust the "value", and for 21 bit addil instructions, we change the
+	 source addend register from %dp to %r0.  This situation commonly
+	 arises for undefined weak symbols and when a variable's "constness"
+	 is declared differently from the way the variable is defined.  For
+	 instance: "extern int foo" with foo defined as "const int foo".  */
       if (sym_sec == NULL || (sym_sec->flags & SEC_CODE) != 0)
 	{
 	  if ((insn & ((0x3f << 26) | (0x1f << 21)))
@@ -3472,6 +3459,9 @@
     case R_PARISC_DLTIND21L:
     case R_PARISC_DLTIND14R:
     case R_PARISC_DLTIND14F:
+    case R_PARISC_TLS_GD21L:
+    case R_PARISC_TLS_LDM21L:
+    case R_PARISC_TLS_IE21L:
     case R_PARISC_TLS_GD14R:
     case R_PARISC_TLS_LDM14R:
     case R_PARISC_TLS_IE14R:
@@ -3728,10 +3718,10 @@
 	  hh = hppa_elf_hash_entry (eh);
 	}
 
-      if (sym_sec != NULL && elf_discarded_section (sym_sec))
+      if (sym_sec != NULL && discarded_section (sym_sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rela, relend,
-					 elf_hppa_howto_table + r_type,
+					 rela, 1, relend,
+					 elf_hppa_howto_table + r_type, 0,
 					 contents);
 
       if (info->relocatable)
@@ -3996,7 +3986,7 @@
 		      || outrel.r_offset == (bfd_vma) -2);
 	      outrel.r_offset += (input_section->output_offset
 				  + input_section->output_section->vma);
-	      	      
+
 	      if (skip)
 		{
 		  memset (&outrel, 0, sizeof (outrel));
@@ -4058,12 +4048,12 @@
 	      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 	    }
 	  break;
-	  
+
 	case R_PARISC_TLS_LDM21L:
 	case R_PARISC_TLS_LDM14R:
 	  {
 	    bfd_vma off;
-	
+
 	    off = htab->tls_ldm_got.offset;
 	    if (off & 1)
 	      off &= ~1;
@@ -4072,12 +4062,12 @@
 		Elf_Internal_Rela outrel;
 		bfd_byte *loc;
 
-		outrel.r_offset = (off 
+		outrel.r_offset = (off
 				   + htab->sgot->output_section->vma
 				   + htab->sgot->output_offset);
 		outrel.r_addend = 0;
 		outrel.r_info = ELF32_R_INFO (0, R_PARISC_TLS_DTPMOD32);
-		loc = htab->srelgot->contents; 
+		loc = htab->srelgot->contents;
 		loc += htab->srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
 
 		bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
@@ -4149,7 +4139,7 @@
 			|| hh->eh.root.type != bfd_link_hash_undefweak))
 		  {
 		    need_relocs = TRUE;
-		    loc = htab->srelgot->contents; 
+		    loc = htab->srelgot->contents;
 		    /* FIXME (CAO): Should this be reloc_count++ ? */
 		    loc += htab->srelgot->reloc_count * sizeof (Elf32_External_Rela);
 		  }
@@ -4436,9 +4426,7 @@
     }
 
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
-  if (eh_name (eh)[0] == '_'
-      && (strcmp (eh_name (eh), "_DYNAMIC") == 0
-	  || eh == htab->etab.hgot))
+  if (eh == htab->etab.hdynamic || eh == htab->etab.hgot)
     {
       sym->st_shndx = SHN_ABS;
     }
@@ -4450,7 +4438,9 @@
    dynamic linker, before writing them out.  */
 
 static enum elf_reloc_type_class
-elf32_hppa_reloc_type_class (const Elf_Internal_Rela *rela)
+elf32_hppa_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			     const asection *rel_sec ATTRIBUTE_UNUSED,
+			     const Elf_Internal_Rela *rela)
 {
   /* Handle TLS relocs first; we don't want them to be marked
      relative by the "if (ELF32_R_SYM (rela->r_info) == STN_UNDEF)"
@@ -4500,7 +4490,7 @@
   if (sgot != NULL && bfd_is_abs_section (sgot->output_section))
     return FALSE;
 
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (htab->etab.dynamic_sections_created)
     {
diff --git a/bfd/elf32-i370.c b/bfd/elf32-i370.c
index 8082927..48e25f2 100644
--- a/bfd/elf32-i370.c
+++ b/bfd/elf32-i370.c
@@ -1,6 +1,6 @@
 /* i370-specific support for 32-bit ELF
    Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007, 2008, 2010, 2011 Free Software Foundation, Inc.
+   2005, 2006, 2007, 2008, 2010, 2011, 2012 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support.
    Hacked by Linas Vepstas for i370 [email protected]
 
@@ -420,23 +420,23 @@
   flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
 	   | SEC_LINKER_CREATED);
 
-  s = bfd_make_section_with_flags (abfd, ".dynsbss",
-				   SEC_ALLOC | SEC_LINKER_CREATED);
+  s = bfd_make_section_anyway_with_flags (abfd, ".dynsbss",
+					  SEC_ALLOC | SEC_LINKER_CREATED);
   if (s == NULL)
     return FALSE;
 
   if (! info->shared)
     {
-      s = bfd_make_section_with_flags (abfd, ".rela.sbss",
-				       flags | SEC_READONLY);
+      s = bfd_make_section_anyway_with_flags (abfd, ".rela.sbss",
+					      flags | SEC_READONLY);
       if (s == NULL
 	  || ! bfd_set_section_alignment (abfd, s, 2))
 	return FALSE;
     }
 
    /* XXX beats me, seem to need a rela.text ...  */
-   s = bfd_make_section_with_flags (abfd, ".rela.text",
-				    flags | SEC_READONLY);
+   s = bfd_make_section_anyway_with_flags (abfd, ".rela.text",
+					   flags | SEC_READONLY);
    if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, 2))
     return FALSE;
@@ -472,7 +472,7 @@
 		      && h->ref_regular
 		      && !h->def_regular)));
 
-  s = bfd_get_section_by_name (dynobj, ".rela.text");
+  s = bfd_get_linker_section (dynobj, ".rela.text");
   BFD_ASSERT (s != NULL);
   s->size += sizeof (Elf32_External_Rela);
 
@@ -498,13 +498,6 @@
   if (info->shared)
     return TRUE;
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-			     h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -520,23 +513,23 @@
      only if there were actually SDAREL relocs for that symbol.  */
 
   if (h->size <= elf_gp_size (dynobj))
-    s = bfd_get_section_by_name (dynobj, ".dynsbss");
+    s = bfd_get_linker_section (dynobj, ".dynsbss");
   else
-    s = bfd_get_section_by_name (dynobj, ".dynbss");
+    s = bfd_get_linker_section (dynobj, ".dynbss");
   BFD_ASSERT (s != NULL);
 
   /* We must generate a R_I370_COPY reloc to tell the dynamic linker to
      copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rela.bss section we are going to use.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       asection *srel;
 
       if (h->size <= elf_gp_size (dynobj))
-	srel = bfd_get_section_by_name (dynobj, ".rela.sbss");
+	srel = bfd_get_linker_section (dynobj, ".rela.sbss");
       else
-	srel = bfd_get_section_by_name (dynobj, ".rela.bss");
+	srel = bfd_get_linker_section (dynobj, ".rela.bss");
       BFD_ASSERT (srel != NULL);
       srel->size += sizeof (Elf32_External_Rela);
       h->needs_copy = 1;
@@ -595,7 +588,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
@@ -615,7 +608,7 @@
 
       for (p = rela_sections; *p != NULL; p++)
 	{
-	  s = bfd_get_section_by_name (dynobj, *p);
+	  s = bfd_get_linker_section (dynobj, *p);
 	  if (s != NULL)
 	    s->size = 0;
 	}
@@ -832,6 +825,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       if (info->shared)
@@ -876,20 +873,20 @@
 {
   asection *sdyn;
   bfd *dynobj = elf_hash_table (info)->dynobj;
-  asection *sgot = bfd_get_section_by_name (dynobj, ".got");
+  asection *sgot = bfd_get_linker_section (dynobj, ".got");
 
 #ifdef DEBUG
   fprintf (stderr, "i370_elf_finish_dynamic_sections called\n");
 #endif
 
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       asection *splt;
       Elf32_External_Dyn *dyncon, *dynconend;
 
-      splt = bfd_get_section_by_name (dynobj, ".plt");
+      splt = bfd_get_linker_section (dynobj, ".plt");
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       dyncon = (Elf32_External_Dyn *) sdyn->contents;
@@ -952,7 +949,7 @@
 
       /* Set up the section symbols for the output sections.  */
 
-      sdynsym = bfd_get_section_by_name (dynobj, ".dynsym");
+      sdynsym = bfd_get_linker_section (dynobj, ".dynsym");
       BFD_ASSERT (sdynsym != NULL);
 
       sym.st_size = 0;
@@ -1138,9 +1135,9 @@
 	    }
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 923674b..cfb417a 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -1,6 +1,6 @@
 /* Intel 80386/80486-specific support for 32-bit ELF
    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -25,6 +25,7 @@
 #include "bfdlink.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
+#include "elf-nacl.h"
 #include "elf-vxworks.h"
 #include "bfd_stdint.h"
 #include "objalloc.h"
@@ -132,7 +133,9 @@
   HOWTO(R_386_TLS_TPOFF32, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
 	bfd_elf_generic_reloc, "R_386_TLS_TPOFF32",
 	TRUE, 0xffffffff, 0xffffffff, FALSE),
-  EMPTY_HOWTO (38),
+  HOWTO(R_386_SIZE32, 0, 2, 32, FALSE, 0, complain_overflow_unsigned,
+	bfd_elf_generic_reloc, "R_386_SIZE32",
+	TRUE, 0xffffffff, 0xffffffff, FALSE),
   HOWTO(R_386_TLS_GOTDESC, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
 	bfd_elf_generic_reloc, "R_386_TLS_GOTDESC",
 	TRUE, 0xffffffff, 0xffffffff, FALSE),
@@ -311,6 +314,10 @@
       TRACE ("BFD_RELOC_386_TLS_TPOFF32");
       return &elf_howto_table[R_386_TLS_TPOFF32 - R_386_tls_offset];
 
+    case BFD_RELOC_SIZE32:
+      TRACE ("BFD_RELOC_SIZE32");
+      return &elf_howto_table[R_386_SIZE32 - R_386_tls_offset];
+
     case BFD_RELOC_386_TLS_GOTDESC:
       TRACE ("BFD_RELOC_386_TLS_GOTDESC");
       return &elf_howto_table[R_386_TLS_GOTDESC - R_386_tls_offset];
@@ -418,10 +425,10 @@
  	return FALSE;
 
       /* pr_cursig */
-      elf_tdata (abfd)->core_signal = bfd_get_32 (abfd, note->descdata + 20);
+      elf_tdata (abfd)->core->signal = bfd_get_32 (abfd, note->descdata + 20);
 
       /* pr_pid */
-      elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
+      elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
 
       /* pr_reg */
       offset = 28;
@@ -436,10 +443,10 @@
 
 	case 144:		/* Linux/i386 */
 	  /* pr_cursig */
-	  elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+	  elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
 
 	  /* pr_pid */
-	  elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
+	  elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
 
 	  /* pr_reg */
 	  offset = 72;
@@ -464,9 +471,9 @@
       if (pr_version != 1)
 	return FALSE;
 
-      elf_tdata (abfd)->core_program
+      elf_tdata (abfd)->core->program
 	= _bfd_elfcore_strndup (abfd, note->descdata + 8, 17);
-      elf_tdata (abfd)->core_command
+      elf_tdata (abfd)->core->command
 	= _bfd_elfcore_strndup (abfd, note->descdata + 25, 81);
     }
   else
@@ -477,11 +484,11 @@
 	  return FALSE;
 
 	case 124:		/* Linux/i386 elf_prpsinfo.  */
-	  elf_tdata (abfd)->core_pid
+	  elf_tdata (abfd)->core->pid
 	    = bfd_get_32 (abfd, note->descdata + 12);
-	  elf_tdata (abfd)->core_program
+	  elf_tdata (abfd)->core->program
 	    = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
-	  elf_tdata (abfd)->core_command
+	  elf_tdata (abfd)->core->command
 	    = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
 	}
     }
@@ -490,7 +497,7 @@
      onto the end of the args in some (at least one anyway)
      implementations, so strip it off if it exists.  */
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
@@ -806,6 +813,12 @@
 
   /* The index of the next unused R_386_TLS_DESC slot in .rel.plt.  */
   bfd_vma next_tls_desc_index;
+
+  /* The index of the next unused R_386_JUMP_SLOT slot in .rel.plt.  */
+  bfd_vma next_jump_slot_index;
+
+  /* The index of the next unused R_386_IRELATIVE slot in .rel.plt.  */
+  bfd_vma next_irelative_index;
 };
 
 /* Get the i386 ELF linker hash table from a link_info structure.  */
@@ -924,7 +937,7 @@
   struct elf_i386_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_i386_link_hash_table);
 
-  ret = (struct elf_i386_link_hash_table *) bfd_malloc (amt);
+  ret = (struct elf_i386_link_hash_table *) bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
 
@@ -937,16 +950,6 @@
       return NULL;
     }
 
-  ret->sdynbss = NULL;
-  ret->srelbss = NULL;
-  ret->plt_eh_frame = NULL;
-  ret->tls_ldm_got.refcount = 0;
-  ret->next_tls_desc_index = 0;
-  ret->sgotplt_jump_table_size = 0;
-  ret->sym_cache.abfd = NULL;
-  ret->srelplt2 = NULL;
-  ret->tls_module_base = NULL;
-
   ret->loc_hash_table = htab_try_create (1024,
 					 elf_i386_local_htab_hash,
 					 elf_i386_local_htab_eq,
@@ -973,7 +976,7 @@
     htab_delete (htab->loc_hash_table);
   if (htab->loc_hash_memory)
     objalloc_free ((struct objalloc *) htab->loc_hash_memory);
-  _bfd_generic_link_hash_table_free (hash);
+  _bfd_elf_link_hash_table_free (hash);
 }
 
 /* Create .plt, .rel.plt, .got, .got.plt, .rel.got, .dynbss, and
@@ -992,9 +995,9 @@
   if (htab == NULL)
     return FALSE;
 
-  htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
+  htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
   if (!info->shared)
-    htab->srelbss = bfd_get_section_by_name (dynobj, ".rel.bss");
+    htab->srelbss = bfd_get_linker_section (dynobj, ".rel.bss");
 
   if (!htab->sdynbss
       || (!info->shared && !htab->srelbss))
@@ -1006,22 +1009,17 @@
     return FALSE;
 
   if (!info->no_ld_generated_unwind_info
-      && bfd_get_section_by_name (dynobj, ".eh_frame") == NULL
+      && htab->plt_eh_frame == NULL
       && htab->elf.splt != NULL)
     {
-      flagword flags = get_elf_backend_data (dynobj)->dynamic_sec_flags;
+      flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY
+			| SEC_HAS_CONTENTS | SEC_IN_MEMORY
+			| SEC_LINKER_CREATED);
       htab->plt_eh_frame
-	= bfd_make_section_with_flags (dynobj, ".eh_frame",
-				       flags | SEC_READONLY);
+	= bfd_make_section_anyway_with_flags (dynobj, ".eh_frame", flags);
       if (htab->plt_eh_frame == NULL
 	  || !bfd_set_section_alignment (dynobj, htab->plt_eh_frame, 2))
 	return FALSE;
-
-      htab->plt_eh_frame->size = sizeof (elf_i386_eh_frame_plt);
-      htab->plt_eh_frame->contents
-	= bfd_alloc (dynobj, htab->plt_eh_frame->size);
-      memcpy (htab->plt_eh_frame->contents, elf_i386_eh_frame_plt,
-	      sizeof (elf_i386_eh_frame_plt));
     }
 
   return TRUE;
@@ -1444,6 +1442,7 @@
       struct elf_link_hash_entry *h;
       Elf_Internal_Sym *isym;
       const char *name;
+      bfd_boolean size_reloc;
 
       r_symndx = ELF32_R_SYM (rel->r_info);
       r_type = ELF32_R_TYPE (rel->r_info);
@@ -1513,73 +1512,9 @@
 	      break;
 	    }
 
-	  /* Since STT_GNU_IFUNC symbol must go through PLT, we handle
-	     it here if it is defined in a non-shared object.  */
-	  if (h->type == STT_GNU_IFUNC
-	      && h->def_regular)
-	    {
-	      /* It is referenced by a non-shared object. */
-	      h->ref_regular = 1;
-	      h->needs_plt = 1;
-
-	      /* STT_GNU_IFUNC symbol must go through PLT.  */
-	      h->plt.refcount += 1;
-
-	      /* STT_GNU_IFUNC needs dynamic sections.  */
-	      if (htab->elf.dynobj == NULL)
-		htab->elf.dynobj = abfd;
-
-	      switch (r_type)
-		{
-		default:
-		  if (h->root.root.string)
-		    name = h->root.root.string;
-		  else
-		    name = bfd_elf_sym_name (abfd, symtab_hdr, isym,
-					     NULL);
-		  (*_bfd_error_handler)
-		    (_("%B: relocation %s against STT_GNU_IFUNC "
-		       "symbol `%s' isn't handled by %s"), abfd,
-		     elf_howto_table[r_type].name,
-		     name, __FUNCTION__);
-		  bfd_set_error (bfd_error_bad_value);
-		  return FALSE;
-
-		case R_386_32:
-		  h->non_got_ref = 1;
-		  h->pointer_equality_needed = 1;
-		  if (info->shared)
-		    {
-		      /* We must copy these reloc types into the
-			 output file.  Create a reloc section in
-			 dynobj and make room for this reloc.  */
-		      sreloc = _bfd_elf_create_ifunc_dyn_reloc
-			(abfd, info, sec, sreloc,
-			 &((struct elf_i386_link_hash_entry *) h)->dyn_relocs);
-		      if (sreloc == NULL)
-			return FALSE;
-		    }
-		  break;
-
-		case R_386_PC32:
-		  h->non_got_ref = 1;
-		  break;
-
-		case R_386_PLT32:
-		  break;
-
-		case R_386_GOT32:
-		case R_386_GOTOFF:
-		  h->got.refcount += 1;
-		  if (htab->elf.sgot == NULL
-		      && !_bfd_elf_create_got_section (htab->elf.dynobj,
-						       info))
-		    return FALSE;
-		  break;
-		}
-
-	      continue;
-	    }
+	  /* It is referenced by a non-shared object. */
+	  h->ref_regular = 1;
+	  h->root.non_ir_ref = 1;
 	}
 
       if (! elf_i386_tls_transition (info, abfd, sec, NULL,
@@ -1611,6 +1546,10 @@
 	  h->plt.refcount += 1;
 	  break;
 
+	case R_386_SIZE32:
+	  size_reloc = TRUE;
+	  goto do_size;
+
 	case R_386_TLS_IE_32:
 	case R_386_TLS_IE:
 	case R_386_TLS_GOTIE:
@@ -1703,6 +1642,7 @@
 		      (_("%B: `%s' accessed both as normal and "
 			 "thread local symbol"),
 		       abfd, name);
+		    bfd_set_error (bfd_error_bad_value);
 		    return FALSE;
 		  }
 	      }
@@ -1757,6 +1697,8 @@
 		h->pointer_equality_needed = 1;
 	    }
 
+	  size_reloc = FALSE;
+do_size:
 	  /* If we are creating a shared library, and this is a reloc
 	     against a global symbol, or a non PC relative reloc
 	     against a local symbol, then we need to copy the reloc
@@ -1853,7 +1795,8 @@
 		}
 
 	      p->count += 1;
-	      if (r_type == R_386_PC32)
+	      /* Count size relocation as PC-relative relocation.  */
+	      if (r_type == R_386_PC32 || size_reloc)
 		p->pc_count += 1;
 	    }
 	  break;
@@ -2019,6 +1962,7 @@
 
 	case R_386_32:
 	case R_386_PC32:
+	case R_386_SIZE32:
 	  if (info->shared
 	      && (h == NULL || h->type != STT_GNU_IFUNC))
 	    break;
@@ -2062,10 +2006,44 @@
 {
   struct elf_i386_link_hash_table *htab;
   asection *s;
+  struct elf_i386_link_hash_entry *eh;
+  struct elf_dyn_relocs *p;
 
   /* STT_GNU_IFUNC symbol must go through PLT. */
   if (h->type == STT_GNU_IFUNC)
     {
+      /* All local STT_GNU_IFUNC references must be treate as local
+	 calls via local PLT.  */
+      if (h->ref_regular
+	  && SYMBOL_CALLS_LOCAL (info, h))
+	{
+	  bfd_size_type pc_count = 0, count = 0;
+	  struct elf_dyn_relocs **pp;
+
+	  eh = (struct elf_i386_link_hash_entry *) h;
+	  for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
+	    {
+	      pc_count += p->pc_count;
+	      p->count -= p->pc_count;
+	      p->pc_count = 0;
+	      count += p->count;
+	      if (p->count == 0)
+		*pp = p->next;
+	      else
+		pp = &p->next;
+	    }
+
+	  if (pc_count || count)
+	    {
+	      h->needs_plt = 1;
+	      h->non_got_ref = 1;
+	      if (h->plt.refcount <= 0)
+		h->plt.refcount = 1;
+	      else
+		h->plt.refcount += 1;
+	    }
+	}
+
       if (h->plt.refcount <= 0)
 	{
 	  h->plt.offset = (bfd_vma) -1;
@@ -2151,9 +2129,6 @@
   if (ELIMINATE_COPY_RELOCS
       && !get_elf_i386_backend_data (info->output_bfd)->is_vxworks)
     {
-      struct elf_i386_link_hash_entry * eh;
-      struct elf_dyn_relocs *p;
-
       eh = (struct elf_i386_link_hash_entry *) h;
       for (p = eh->dyn_relocs; p != NULL; p = p->next)
 	{
@@ -2169,13 +2144,6 @@
 	}
     }
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-			     h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -2189,7 +2157,7 @@
   /* We must generate a R_386_COPY reloc to tell the dynamic linker to
      copy the initial value out of the dynamic object and into the
      runtime process image.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       htab->srelbss->size += sizeof (Elf32_External_Rel);
       h->needs_copy = 1;
@@ -2229,7 +2197,8 @@
   if (h->type == STT_GNU_IFUNC
       && h->def_regular)
     return _bfd_elf_allocate_ifunc_dyn_relocs (info, h, &eh->dyn_relocs,
-                                               plt_entry_size, 4);
+                                               plt_entry_size,
+					       plt_entry_size, 4);
   else if (htab->elf.dynamic_sections_created
 	   && h->plt.refcount > 0)
     {
@@ -2275,7 +2244,7 @@
 
 	  /* We also need to make an entry in the .rel.plt section.  */
 	  htab->elf.srelplt->size += sizeof (Elf32_External_Rel);
-	  htab->next_tls_desc_index++;
+	  htab->elf.srelplt->reloc_count++;
 
 	  if (get_elf_i386_backend_data (info->output_bfd)->is_vxworks
               && !info->shared)
@@ -2539,6 +2508,153 @@
   return TRUE;
 }
 
+/* Convert
+   mov foo@GOT(%reg), %reg
+   to
+   lea foo@GOTOFF(%reg), %reg
+   with the local symbol, foo.  */
+
+static bfd_boolean
+elf_i386_convert_mov_to_lea (bfd *abfd, asection *sec,
+			     struct bfd_link_info *link_info)
+{
+  Elf_Internal_Shdr *symtab_hdr;
+  Elf_Internal_Rela *internal_relocs;
+  Elf_Internal_Rela *irel, *irelend;
+  bfd_byte *contents;
+  struct elf_i386_link_hash_table *htab;
+  bfd_boolean changed_contents;
+  bfd_boolean changed_relocs;
+  bfd_signed_vma *local_got_refcounts;
+
+  /* Don't even try to convert non-ELF outputs.  */
+  if (!is_elf_hash_table (link_info->hash))
+    return FALSE;
+
+  /* Nothing to do if there are no codes, no relocations or no output.  */
+  if ((sec->flags & (SEC_CODE | SEC_RELOC)) != (SEC_CODE | SEC_RELOC)
+      || sec->reloc_count == 0
+      || discarded_section (sec))
+    return TRUE;
+
+  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+
+  /* Load the relocations for this section.  */
+  internal_relocs = (_bfd_elf_link_read_relocs
+		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
+		      link_info->keep_memory));
+  if (internal_relocs == NULL)
+    return FALSE;
+
+  htab = elf_i386_hash_table (link_info);
+  changed_contents = FALSE;
+  changed_relocs = FALSE;
+  local_got_refcounts = elf_local_got_refcounts (abfd);
+
+  /* Get the section contents.  */
+  if (elf_section_data (sec)->this_hdr.contents != NULL)
+    contents = elf_section_data (sec)->this_hdr.contents;
+  else
+    {
+      if (!bfd_malloc_and_get_section (abfd, sec, &contents))
+	goto error_return;
+    }
+
+  irelend = internal_relocs + sec->reloc_count;
+  for (irel = internal_relocs; irel < irelend; irel++)
+    {
+      unsigned int r_type = ELF32_R_TYPE (irel->r_info);
+      unsigned int r_symndx = ELF32_R_SYM (irel->r_info);
+      unsigned int indx;
+      struct elf_link_hash_entry *h;
+
+      if (r_type != R_386_GOT32)
+	continue;
+
+      /* Get the symbol referred to by the reloc.  */
+      if (r_symndx < symtab_hdr->sh_info)
+	{
+	  Elf_Internal_Sym *isym;
+
+	  isym = bfd_sym_from_r_symndx (&htab->sym_cache,
+					abfd, r_symndx);
+
+	  /* STT_GNU_IFUNC must keep R_386_GOT32 relocation.  */
+	  if (ELF_ST_TYPE (isym->st_info) != STT_GNU_IFUNC
+	      && bfd_get_8 (input_bfd,
+			    contents + irel->r_offset - 2) == 0x8b)
+	    {
+	      bfd_put_8 (output_bfd, 0x8d,
+			 contents + irel->r_offset - 2);
+	      irel->r_info = ELF32_R_INFO (r_symndx, R_386_GOTOFF);
+	      if (local_got_refcounts != NULL
+		  && local_got_refcounts[r_symndx] > 0)
+		local_got_refcounts[r_symndx] -= 1;
+	      changed_contents = TRUE;
+	      changed_relocs = TRUE;
+	    }
+	  continue;
+	}
+
+      indx = r_symndx - symtab_hdr->sh_info;
+      h = elf_sym_hashes (abfd)[indx];
+      BFD_ASSERT (h != NULL);
+
+      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;
+
+      /* STT_GNU_IFUNC must keep R_386_GOT32 relocation.  We also avoid
+	 optimizing _DYNAMIC since ld.so may use its link-time address.  */
+      if (h->def_regular
+	  && h->type != STT_GNU_IFUNC
+	  && h != htab->elf.hdynamic
+	  && SYMBOL_REFERENCES_LOCAL (link_info, h)
+	  && bfd_get_8 (input_bfd,
+			contents + irel->r_offset - 2) == 0x8b)
+	{
+	  bfd_put_8 (output_bfd, 0x8d,
+		     contents + irel->r_offset - 2);
+	  irel->r_info = ELF32_R_INFO (r_symndx, R_386_GOTOFF);
+	  if (h->got.refcount > 0)
+	    h->got.refcount -= 1;
+	  changed_contents = TRUE;
+	  changed_relocs = TRUE;
+	}
+    }
+
+  if (contents != NULL
+      && elf_section_data (sec)->this_hdr.contents != contents)
+    {
+      if (!changed_contents && !link_info->keep_memory)
+	free (contents);
+      else
+	{
+	  /* Cache the section contents for elf_link_input_bfd.  */
+	  elf_section_data (sec)->this_hdr.contents = contents;
+	}
+    }
+
+  if (elf_section_data (sec)->relocs != internal_relocs)
+    {
+      if (!changed_relocs)
+	free (internal_relocs);
+      else
+	elf_section_data (sec)->relocs = internal_relocs;
+    }
+
+  return TRUE;
+
+ error_return:
+  if (contents != NULL
+      && elf_section_data (sec)->this_hdr.contents != contents)
+    free (contents);
+  if (internal_relocs != NULL
+      && elf_section_data (sec)->relocs != internal_relocs)
+    free (internal_relocs);
+  return FALSE;
+}
+
 /* Set the sizes of the dynamic sections.  */
 
 static bfd_boolean
@@ -2562,7 +2678,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  if (s == NULL)
 	    abort ();
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
@@ -2589,6 +2705,9 @@
 	{
 	  struct elf_dyn_relocs *p;
 
+	  if (!elf_i386_convert_mov_to_lea (ibfd, s, info))
+	    return FALSE;
+
 	  for (p = ((struct elf_dyn_relocs *)
 		     elf_section_data (s)->local_dynrel);
 	       p != NULL;
@@ -2700,21 +2819,26 @@
      incremented.  However, when we reserve space for TLS descriptors,
      it's not incremented, so in order to compute the space reserved
      for them, it suffices to multiply the reloc count by the jump
-     slot size.  */
+     slot size.
+
+     PR ld/13302: We start next_irelative_index at the end of .rela.plt
+     so that R_386_IRELATIVE entries come last.  */
   if (htab->elf.srelplt)
-    htab->sgotplt_jump_table_size = htab->next_tls_desc_index * 4;
+    {
+      htab->next_tls_desc_index = htab->elf.srelplt->reloc_count;
+      htab->sgotplt_jump_table_size = htab->next_tls_desc_index * 4;
+      htab->next_irelative_index = htab->elf.srelplt->reloc_count - 1;
+    }
+  else if (htab->elf.irelplt)
+    htab->next_irelative_index = htab->elf.irelplt->reloc_count - 1;
+
 
   if (htab->elf.sgotplt)
     {
-      struct elf_link_hash_entry *got;
-      got = elf_link_hash_lookup (elf_hash_table (info),
-				  "_GLOBAL_OFFSET_TABLE_",
-				  FALSE, FALSE, FALSE);
-
       /* Don't allocate .got.plt section if there are no GOT nor PLT
-         entries and there is no refeence to _GLOBAL_OFFSET_TABLE_.  */
-      if ((got == NULL
-	   || !got->ref_regular_nonweak)
+         entries and there is no reference to _GLOBAL_OFFSET_TABLE_.  */
+      if ((htab->elf.hgot == NULL
+	   || !htab->elf.hgot->ref_regular_nonweak)
 	  && (htab->elf.sgotplt->size
 	      == get_elf_backend_data (output_bfd)->got_header_size)
 	  && (htab->elf.splt == NULL
@@ -2728,6 +2852,14 @@
 	htab->elf.sgotplt->size = 0;
     }
 
+
+  if (htab->plt_eh_frame != NULL
+      && htab->elf.splt != NULL
+      && htab->elf.splt->size != 0
+      && !bfd_is_abs_section (htab->elf.splt->output_section)
+      && _bfd_elf_eh_frame_present (info))
+    htab->plt_eh_frame->size = sizeof (elf_i386_eh_frame_plt);
+
   /* We now have determined the sizes of the various dynamic sections.
      Allocate memory for them.  */
   relocs = FALSE;
@@ -2739,11 +2871,7 @@
 	continue;
 
       if (s == htab->elf.splt
-	  || s == htab->elf.sgot
-	  || s == htab->elf.sgotplt
-	  || s == htab->elf.iplt
-	  || s == htab->elf.igotplt
-	  || s == htab->sdynbss)
+	  || s == htab->elf.sgot)
 	{
 	  /* Strip this section if we don't need it; see the
 	     comment below.  */
@@ -2754,6 +2882,14 @@
 	  if (htab->elf.hplt != NULL)
 	    strip_section = FALSE;
 	}
+      else if (s == htab->elf.sgotplt
+	       || s == htab->elf.iplt
+	       || s == htab->elf.igotplt
+	       || s == htab->plt_eh_frame
+	       || s == htab->sdynbss)
+	{
+	  /* Strip these too.  */
+	}
       else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rel"))
 	{
 	  if (s->size != 0
@@ -2801,11 +2937,13 @@
     }
 
   if (htab->plt_eh_frame != NULL
-      && htab->elf.splt != NULL
-      && htab->elf.splt->size != 0
-      && (htab->elf.splt->flags & SEC_EXCLUDE) == 0)
-    bfd_put_32 (dynobj, htab->elf.splt->size,
-		htab->plt_eh_frame->contents + PLT_FDE_LEN_OFFSET);
+      && htab->plt_eh_frame->contents != NULL)
+    {
+      memcpy (htab->plt_eh_frame->contents, elf_i386_eh_frame_plt,
+	      sizeof (elf_i386_eh_frame_plt));
+      bfd_put_32 (dynobj, htab->elf.splt->size,
+		  htab->plt_eh_frame->contents + PLT_FDE_LEN_OFFSET);
+    }
 
   if (htab->elf.dynamic_sections_created)
     {
@@ -3052,6 +3190,7 @@
       bfd_reloc_status_type r;
       unsigned int indx;
       int tls_type;
+      bfd_vma st_size;
 
       r_type = ELF32_R_TYPE (rel->r_info);
       if (r_type == R_386_GNU_VTINHERIT
@@ -3084,6 +3223,7 @@
 	  relocation = (sec->output_section->vma
 			+ sec->output_offset
 			+ sym->st_value);
+	  st_size = sym->st_size;
 
 	  if (ELF_ST_TYPE (sym->st_info) == STT_SECTION
 	      && ((sec->flags & SEC_MERGE) != 0
@@ -3176,11 +3316,12 @@
 				   r_symndx, symtab_hdr, sym_hashes,
 				   h, sec, relocation,
 				   unresolved_reloc, warned);
+	  st_size = h->size;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -3232,11 +3373,10 @@
 
 	    case R_386_32:
 	      /* Generate dynamic relcoation only when there is a
-		 non-GOF reference in a shared object.  */
+		 non-GOT reference in a shared object.  */
 	      if (info->shared && h->non_got_ref)
 		{
 		  Elf_Internal_Rela outrel;
-		  bfd_byte *loc;
 		  asection *sreloc;
 		  bfd_vma offset;
 
@@ -3270,10 +3410,7 @@
 		    outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
 
 		  sreloc = htab->elf.irelifunc;
-		  loc = sreloc->contents;
-		  loc += (sreloc->reloc_count++
-			  * sizeof (Elf32_External_Rel));
-		  bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
+		  elf_append_rel (output_bfd, sreloc, &outrel);
 
 		  /* If this reloc is against an external symbol, we
 		     do not want to fiddle with the addend.  Otherwise,
@@ -3427,7 +3564,6 @@
 		    {
 		      asection *s;
 		      Elf_Internal_Rela outrel;
-		      bfd_byte *loc;
 
 		      s = htab->elf.srelgot;
 		      if (s == NULL)
@@ -3437,9 +3573,7 @@
 					 + htab->elf.sgot->output_offset
 					 + off);
 		      outrel.r_info = ELF32_R_INFO (0, R_386_RELATIVE);
-		      loc = s->contents;
-		      loc += s->reloc_count++ * sizeof (Elf32_External_Rel);
-		      bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
+		      elf_append_rel (output_bfd, s, &outrel);
 		    }
 
 		  local_got_offsets[r_symndx] |= 1;
@@ -3492,6 +3626,7 @@
 		  return FALSE;
 		}
 	      else if (!info->executable
+		       && !SYMBOLIC_BIND (info, h)
 		       && h->type == STT_FUNC
 		       && ELF_ST_VISIBILITY (h->other) == STV_PROTECTED)
 		{
@@ -3543,6 +3678,11 @@
 	  unresolved_reloc = FALSE;
 	  break;
 
+	case R_386_SIZE32:
+	  /* Set to symbol size.  */
+	  relocation = st_size;
+	  /* Fall through.  */
+
 	case R_386_32:
 	case R_386_PC32:
 	  if ((input_section->flags & SEC_ALLOC) == 0
@@ -3553,7 +3693,7 @@
 	       && (h == NULL
 		   || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
 		   || h->root.type != bfd_link_hash_undefweak)
-	       && (r_type != R_386_PC32
+	       && ((r_type != R_386_PC32 && r_type != R_386_SIZE32)
 		   || !SYMBOL_CALLS_LOCAL (info, h)))
 	      || (ELIMINATE_COPY_RELOCS
 		  && !info->shared
@@ -3566,7 +3706,6 @@
 		      || h->root.type == bfd_link_hash_undefined)))
 	    {
 	      Elf_Internal_Rela outrel;
-	      bfd_byte *loc;
 	      bfd_boolean skip, relocate;
 	      asection *sreloc;
 
@@ -3611,10 +3750,7 @@
 		  goto check_relocation_error;
 		}
 
-	      loc = sreloc->contents;
-	      loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rel);
-
-	      bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
+	      elf_append_rel (output_bfd, sreloc, &outrel);
 
 	      /* If this reloc is against an external symbol, we do
 		 not want to fiddle with the addend.  Otherwise, we
@@ -3629,7 +3765,6 @@
 	  if (!info->executable)
 	    {
 	      Elf_Internal_Rela outrel;
-	      bfd_byte *loc;
 	      asection *sreloc;
 
 	      outrel.r_offset = rel->r_offset
@@ -3639,9 +3774,7 @@
 	      sreloc = elf_section_data (input_section)->sreloc;
 	      if (sreloc == NULL)
 		abort ();
-	      loc = sreloc->contents;
-	      loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rel);
-	      bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
+	      elf_append_rel (output_bfd, sreloc, &outrel);
 	    }
 	  /* Fall through */
 
@@ -3867,7 +4000,6 @@
 	  else
 	    {
 	      Elf_Internal_Rela outrel;
-	      bfd_byte *loc;
 	      int dr_type;
 	      asection *sreloc;
 
@@ -3878,6 +4010,7 @@
 
 	      if (GOT_TLS_GDESC_P (tls_type))
 		{
+		  bfd_byte *loc;
 		  outrel.r_info = ELF32_R_INFO (indx, R_386_TLS_DESC);
 		  BFD_ASSERT (htab->sgotplt_jump_table_size + offplt + 8
 			      <= htab->elf.sgotplt->size);
@@ -3935,11 +4068,7 @@
 			    htab->elf.sgot->contents + off);
 	      outrel.r_info = ELF32_R_INFO (indx, dr_type);
 
-	      loc = sreloc->contents;
-	      loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rel);
-	      BFD_ASSERT (loc + sizeof (Elf32_External_Rel)
-			  <= sreloc->contents + sreloc->size);
-	      bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
+	      elf_append_rel (output_bfd, sreloc, &outrel);
 
 	      if (GOT_TLS_GD_P (tls_type))
 		{
@@ -3957,11 +4086,7 @@
 		      outrel.r_info = ELF32_R_INFO (indx,
 						    R_386_TLS_DTPOFF32);
 		      outrel.r_offset += 4;
-		      sreloc->reloc_count++;
-		      loc += sizeof (Elf32_External_Rel);
-		      BFD_ASSERT (loc + sizeof (Elf32_External_Rel)
-				  <= sreloc->contents + sreloc->size);
-		      bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
+		      elf_append_rel (output_bfd, sreloc, &outrel);
 		    }
 		}
 	      else if (tls_type == GOT_TLS_IE_BOTH)
@@ -3973,9 +4098,7 @@
 			      htab->elf.sgot->contents + off + 4);
 		  outrel.r_info = ELF32_R_INFO (indx, R_386_TLS_TPOFF);
 		  outrel.r_offset += 4;
-		  sreloc->reloc_count++;
-		  loc += sizeof (Elf32_External_Rel);
-		  bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
+		  elf_append_rel (output_bfd, sreloc, &outrel);
 		}
 
 	    dr_done:
@@ -4157,7 +4280,6 @@
 	  else
 	    {
 	      Elf_Internal_Rela outrel;
-	      bfd_byte *loc;
 
 	      if (htab->elf.srelgot == NULL)
 		abort ();
@@ -4170,9 +4292,7 @@
 	      bfd_put_32 (output_bfd, 0,
 			  htab->elf.sgot->contents + off + 4);
 	      outrel.r_info = ELF32_R_INFO (0, R_386_TLS_DTPMOD32);
-	      loc = htab->elf.srelgot->contents;
-	      loc += htab->elf.srelgot->reloc_count++ * sizeof (Elf32_External_Rel);
-	      bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
+	      elf_append_rel (output_bfd, htab->elf.srelgot, &outrel);
 	      htab->tls_ldm_got.offset |= 1;
 	    }
 	  relocation = htab->elf.sgot->output_section->vma
@@ -4196,7 +4316,6 @@
 	    {
 	      Elf_Internal_Rela outrel;
 	      asection *sreloc;
-	      bfd_byte *loc;
 
 	      outrel.r_offset = rel->r_offset
 				+ input_section->output_section->vma
@@ -4212,9 +4331,7 @@
 	      sreloc = elf_section_data (input_section)->sreloc;
 	      if (sreloc == NULL)
 		abort ();
-	      loc = sreloc->contents;
-	      loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rel);
-	      bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc);
+	      elf_append_rel (output_bfd, sreloc, &outrel);
 	      if (indx)
 		continue;
 	      else if (r_type == R_386_TLS_LE_32)
@@ -4239,8 +4356,7 @@
 	  && !((input_section->flags & SEC_DEBUGGING) != 0
 	       && h->def_dynamic)
 	  && _bfd_elf_section_offset (output_bfd, info, input_section,
-                                      rel->r_offset) != (bfd_vma) -1)
-
+				      rel->r_offset) != (bfd_vma) -1)
 	{
 	  (*_bfd_error_handler)
 	    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
@@ -4350,7 +4466,7 @@
 	  || plt == NULL
 	  || gotplt == NULL
 	  || relplt == NULL)
-	return FALSE;
+	abort ();
 
       /* Get the index in the procedure linkage table which
 	 corresponds to this symbol.  This is the index of this symbol
@@ -4365,13 +4481,13 @@
 
       if (plt == htab->elf.splt)
 	{
-	  plt_index = h->plt.offset / plt_entry_size - 1;
-	  got_offset = (plt_index + 3) * 4;
+	  got_offset = h->plt.offset / plt_entry_size - 1;
+	  got_offset = (got_offset + 3) * 4;
 	}
       else
 	{
-	  plt_index = h->plt.offset / plt_entry_size;
-	  got_offset = plt_index * 4;
+	  got_offset = h->plt.offset / plt_entry_size;
+	  got_offset = got_offset * 4;
 	}
 
       /* Fill in the entry in the procedure linkage table.  */
@@ -4420,7 +4536,7 @@
 			      + got_offset);
 	      rel.r_info = ELF32_R_INFO (htab->elf.hplt->indx, R_386_32);
 	      bfd_elf32_swap_reloc_out (output_bfd, &rel,
-	      loc + sizeof (Elf32_External_Rel));
+					loc + sizeof (Elf32_External_Rel));
 	    }
 	}
       else
@@ -4432,18 +4548,6 @@
                       + abed->plt->plt_got_offset);
 	}
 
-      /* Don't fill PLT entry for static executables.  */
-      if (plt == htab->elf.splt)
-	{
-	  bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rel),
-		      plt->contents + h->plt.offset
-                      + abed->plt->plt_reloc_offset);
-	  bfd_put_32 (output_bfd, - (h->plt.offset
-                                     + abed->plt->plt_plt_offset + 4),
-		      plt->contents + h->plt.offset
-                      + abed->plt->plt_plt_offset);
-	}
-
       /* Fill in the entry in the global offset table.  */
       bfd_put_32 (output_bfd,
 		  (plt->output_section->vma
@@ -4471,12 +4575,29 @@
 		       + h->root.u.def.section->output_offset),
 		      gotplt->contents + got_offset);
 	  rel.r_info = ELF32_R_INFO (0, R_386_IRELATIVE);
+	  /* R_386_IRELATIVE comes last.  */
+	  plt_index = htab->next_irelative_index--;
 	}
       else
-	rel.r_info = ELF32_R_INFO (h->dynindx, R_386_JUMP_SLOT);
+	{
+	  rel.r_info = ELF32_R_INFO (h->dynindx, R_386_JUMP_SLOT);
+	  plt_index = htab->next_jump_slot_index++;
+	}
       loc = relplt->contents + plt_index * sizeof (Elf32_External_Rel);
       bfd_elf32_swap_reloc_out (output_bfd, &rel, loc);
 
+      /* Don't fill PLT entry for static executables.  */
+      if (plt == htab->elf.splt)
+	{
+	  bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rel),
+		      plt->contents + h->plt.offset
+                      + abed->plt->plt_reloc_offset);
+	  bfd_put_32 (output_bfd, - (h->plt.offset
+                                     + abed->plt->plt_plt_offset + 4),
+		      plt->contents + h->plt.offset
+                      + abed->plt->plt_plt_offset);
+	}
+
       if (!h->def_regular)
 	{
 	  /* Mark the symbol as undefined, rather than as defined in
@@ -4498,7 +4619,6 @@
       && (elf_i386_hash_entry(h)->tls_type & GOT_TLS_IE) == 0)
     {
       Elf_Internal_Rela rel;
-      bfd_byte *loc;
 
       /* This symbol has an entry in the global offset table.  Set it
 	 up.  */
@@ -4556,15 +4676,12 @@
 	  rel.r_info = ELF32_R_INFO (h->dynindx, R_386_GLOB_DAT);
 	}
 
-      loc = htab->elf.srelgot->contents;
-      loc += htab->elf.srelgot->reloc_count++ * sizeof (Elf32_External_Rel);
-      bfd_elf32_swap_reloc_out (output_bfd, &rel, loc);
+      elf_append_rel (output_bfd, htab->elf.srelgot, &rel);
     }
 
   if (h->needs_copy)
     {
       Elf_Internal_Rela rel;
-      bfd_byte *loc;
 
       /* This symbol needs a copy reloc.  Set it up.  */
 
@@ -4578,22 +4695,9 @@
 		      + h->root.u.def.section->output_section->vma
 		      + h->root.u.def.section->output_offset);
       rel.r_info = ELF32_R_INFO (h->dynindx, R_386_COPY);
-      loc = htab->srelbss->contents;
-      loc += htab->srelbss->reloc_count++ * sizeof (Elf32_External_Rel);
-      bfd_elf32_swap_reloc_out (output_bfd, &rel, loc);
+      elf_append_rel (output_bfd, htab->srelbss, &rel);
     }
 
-  /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  SYM may
-     be NULL for local symbols.
-
-     On VxWorks, the _GLOBAL_OFFSET_TABLE_ symbol is not absolute: it
-     is relative to the ".got" section.  */
-  if (sym != NULL
-      && (strcmp (h->root.root.string, "_DYNAMIC") == 0
-	  || (!abed->is_vxworks
-              && h == htab->elf.hgot)))
-    sym->st_shndx = SHN_ABS;
-
   return TRUE;
 }
 
@@ -4616,7 +4720,9 @@
    dynamic linker, before writing them out.  */
 
 static enum elf_reloc_type_class
-elf_i386_reloc_type_class (const Elf_Internal_Rela *rela)
+elf_i386_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			   const asection *rel_sec ATTRIBUTE_UNUSED,
+			   const Elf_Internal_Rela *rela)
 {
   switch (ELF32_R_TYPE (rela->r_info))
     {
@@ -4647,7 +4753,7 @@
     return FALSE;
 
   dynobj = htab->elf.dynobj;
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
   abed = get_elf_i386_backend_data (output_bfd);
 
   if (htab->elf.dynamic_sections_created)
@@ -4832,7 +4938,8 @@
     }
 
   /* Adjust .eh_frame for .plt section.  */
-  if (htab->plt_eh_frame != NULL)
+  if (htab->plt_eh_frame != NULL
+      && htab->plt_eh_frame->contents != NULL)
     {
       if (htab->elf.splt != NULL
 	  && htab->elf.splt->size != 0
@@ -4849,7 +4956,7 @@
 			     + PLT_FDE_START_OFFSET);
 	}
       if (htab->plt_eh_frame->sec_info_type
-	  == ELF_INFO_TYPE_EH_FRAME)
+	  == SEC_INFO_TYPE_EH_FRAME)
 	{
 	  if (! _bfd_elf_write_section_eh_frame (output_bfd, info,
 						 htab->plt_eh_frame,
@@ -5094,7 +5201,10 @@
     0x8b, 0x4b, 0x08,		/* mov 0x8(%ebx), %ecx */
     0x83, 0xe1, 0xe0,		/* and $NACLMASK, %ecx */
     0xff, 0xe1,			/* jmp *%ecx */
-    0x90                        /* nop */
+
+    /* This is expected to be the same size as elf_i386_nacl_plt0_entry,
+       so pad to that size with nop instructions.  */
+    0x90, 0x90, 0x90, 0x90, 0x90, 0x90
   };
 
 static const bfd_byte elf_i386_nacl_pic_plt_entry[NACL_PLT_ENTRY_SIZE] =
@@ -5185,11 +5295,34 @@
     0,                                  /* is_vxworks */
   };
 
+static bfd_boolean
+elf32_i386_nacl_elf_object_p (bfd *abfd)
+{
+  /* Set the right machine number for a NaCl i386 ELF32 file.  */
+  bfd_default_set_arch_mach (abfd, bfd_arch_i386, bfd_mach_i386_i386_nacl);
+  return TRUE;
+}
+
 #undef	elf_backend_arch_data
 #define elf_backend_arch_data	&elf_i386_nacl_arch_bed
 
+#undef	elf_backend_object_p
+#define elf_backend_object_p			elf32_i386_nacl_elf_object_p
+#undef	elf_backend_modify_segment_map
+#define	elf_backend_modify_segment_map		nacl_modify_segment_map
+#undef	elf_backend_modify_program_headers
+#define	elf_backend_modify_program_headers	nacl_modify_program_headers
+#undef	elf_backend_final_write_processing
+#define elf_backend_final_write_processing	nacl_final_write_processing
+
 #include "elf32-target.h"
 
+/* Restore defaults.  */
+#undef	elf_backend_object_p
+#undef	elf_backend_modify_segment_map
+#undef	elf_backend_modify_program_headers
+#undef	elf_backend_final_write_processing
+
 /* VxWorks support.  */
 
 #undef	TARGET_LITTLE_SYM
diff --git a/bfd/elf32-i860.c b/bfd/elf32-i860.c
index 00c8ca7..c7991bd 100644
--- a/bfd/elf32-i860.c
+++ b/bfd/elf32-i860.c
@@ -1,5 +1,6 @@
 /* Intel i860 specific support for 32-bit ELF.
-   Copyright 1993, 1995, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
+   Copyright 1993, 1995, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008,
+   2010, 2011, 2012
    Free Software Foundation, Inc.
 
    Full i860 support contributed by Jason Eckhardt <[email protected]>.
@@ -1014,7 +1015,7 @@
   insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
 
   value += rel->r_addend;
-  value += 0x8000; 
+  value += 0x8000;
   value = ((value >> 16) & 0xffff);
 
   insn = (insn & 0xffff0000) | value;
@@ -1128,9 +1129,9 @@
 				   unresolved_reloc, warned);
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
diff --git a/bfd/elf32-i960.c b/bfd/elf32-i960.c
index 6112e3f..bb03897 100644
--- a/bfd/elf32-i960.c
+++ b/bfd/elf32-i960.c
@@ -1,5 +1,5 @@
 /* Intel 960 specific support for 32-bit ELF
-   Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007
+   Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -47,7 +47,7 @@
 elf32_i960_relocate (bfd *abfd ATTRIBUTE_UNUSED,
 		     arelent *reloc_entry,
 		     asymbol *symbol,
-		     PTR data ATTRIBUTE_UNUSED,
+		     void * data ATTRIBUTE_UNUSED,
 		     asection *input_section,
 		     bfd *output_bfd,
 		     char **error_message ATTRIBUTE_UNUSED)
diff --git a/bfd/elf32-ip2k.c b/bfd/elf32-ip2k.c
index 0a251b8..3bbad14 100644
--- a/bfd/elf32-ip2k.c
+++ b/bfd/elf32-ip2k.c
@@ -1,5 +1,5 @@
 /* Ubicom IP2xxx specific support for 32-bit ELF
-   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
+   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -348,7 +348,7 @@
 {
   bfd_byte code[4];
   int table_index = 0;
-  
+
   /* Check current page-jmp.  */
   if (addr + 4 > sec->size)
     return -1;
@@ -358,7 +358,7 @@
   if ((! IS_PAGE_OPCODE (code + 0))
       || (! IS_JMP_OPCODE (code + 2)))
     return -1;
-  
+
   /* Search back.  */
   while (1)
     {
@@ -428,7 +428,7 @@
 {
   bfd_byte code[16];
   int table_index = 0;
-  
+
   /* Check current page-jmp.  */
   if (addr + 4 > sec->size)
     return -1;
@@ -437,7 +437,7 @@
   if ((! IS_PAGE_OPCODE (code + 0))
       || (! IS_JMP_OPCODE (code + 2)))
     return -1;
-  
+
   /* Search back.  */
   while (1)
     {
@@ -464,7 +464,7 @@
 	  && (IS_INC_1SP_OPCODE (code + 12))
 	  && (IS_JMP_OPCODE (code + 14)))
 	return table_index;
-      
+
       if ((! IS_PAGE_OPCODE (code + 0))
 	  || (! IS_JMP_OPCODE (code + 2)))
 	return -1;
@@ -658,11 +658,11 @@
 	      if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
 		{
 		  asection *sym_sec;
-		  
+
 		  /* A local symbol.  */
 		  isym = isymbuf + ELF32_R_SYM (irel->r_info);
 		  sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
-		  
+
 		  if (sym_sec == sec)
 		    {
 		      const char *name;
@@ -671,20 +671,20 @@
 		      bfd_vma baseaddr = BASEADDR (sec);
 		      bfd_vma symval = BASEADDR (sym_sec) + isym->st_value
 			+ irel->r_addend;
-		      
+
 		      if ((baseaddr + addr) <= symval
 			  && symval <= (baseaddr + endaddr))
 			irel->r_addend += count;
 
 		      /* Go hunt up a function and fix its line info if needed.  */
-		      stabp = stabcontents + irel->r_offset - 8; 
+		      stabp = stabcontents + irel->r_offset - 8;
 
 		      /* Go pullout the stab entry.  */
 		      type  = bfd_h_get_8 (abfd, stabp + TYPEOFF);
 		      value = bfd_h_get_32 (abfd, stabp + VALOFF);
-		      
+
 		      name = bfd_get_stab_name (type);
-		      
+
 		      if (strcmp (name, "FUN") == 0)
 			{
 			  int function_adjusted = 0;
@@ -710,7 +710,7 @@
 				    {
 				      /* Adjust the value.  */
 				      value += count;
-				  
+
 				      /* We need to put it back.  */
 				      bfd_h_put_32 (abfd, value,stabp + VALOFF);
 				    }
@@ -819,10 +819,10 @@
   /* Delete the PAGE insn.  */
   if (!ip2k_elf_relax_delete_bytes (abfd, sec, irel->r_offset, 2))
     return FALSE;
-	
+
   /* Modified => will need to iterate relaxation again.  */
   *again = TRUE;
-  
+
   return TRUE;
 }
 
@@ -837,7 +837,7 @@
   Elf_Internal_Rela *ireltest = irel;
   bfd_byte code[4];
   bfd_vma addr;
-  
+
   /* Test all page instructions.  */
   addr = irel->r_offset;
   while (1)
@@ -908,7 +908,7 @@
   Elf_Internal_Rela *ireltest = irel;
   bfd_byte code[12];
   bfd_vma addr;
-  
+
   /* Test all page instructions.  */
   addr = irel->r_offset;
 
@@ -995,7 +995,7 @@
   Elf_Internal_Rela *irel;
   int switch_table_128;
   int switch_table_256;
-  
+
   /* Walk thru the section looking for relaxation opportunities.  */
   for (irel = misc->irelbase; irel < irelend; irel++)
     {
@@ -1436,9 +1436,9 @@
 	  name = h->root.root.string;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
diff --git a/bfd/elf32-iq2000.c b/bfd/elf32-iq2000.c
index 63ef3dc..3a90a99 100644
--- a/bfd/elf32-iq2000.c
+++ b/bfd/elf32-iq2000.c
@@ -1,5 +1,5 @@
 /* IQ2000-specific support for 32-bit ELF.
-   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
+   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -290,7 +290,7 @@
   bfd_vma insn;
 
   insn = bfd_get_32 (input_bfd, contents + relhi->r_offset);
-  
+
   value += relhi->r_addend;
   value &= 0x7fffffff; /* Mask off top-bit which is Harvard mask bit.  */
 
@@ -299,7 +299,7 @@
   if (value & 0x8000)
     value += 0x10000;
 
-  value >>= 16; 
+  value >>= 16;
   insn = ((insn & ~0xFFFF) | value);
 
   bfd_put_32 (input_bfd, insn, contents + relhi->r_offset);
@@ -444,7 +444,7 @@
 /* Look through the relocs for a section during the first phase.
    Since we don't do .gots or .plts, we just need to consider the
    virtual table relocs for gc.	 */
- 
+
 static bfd_boolean
 iq2000_elf_check_relocs (bfd *abfd,
 			 struct bfd_link_info *info,
@@ -456,19 +456,19 @@
   const Elf_Internal_Rela *rel;
   const Elf_Internal_Rela *rel_end;
   bfd_boolean changed = FALSE;
-  
+
   if (info->relocatable)
     return TRUE;
-  
+
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
-  
+
   rel_end = relocs + sec->reloc_count;
   for (rel = relocs; rel < rel_end; rel++)
     {
       struct elf_link_hash_entry *h;
       unsigned long r_symndx;
-      
+
       r_symndx = ELF32_R_SYM (rel->r_info);
       if (r_symndx < symtab_hdr->sh_info)
 	h = NULL;
@@ -478,8 +478,12 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
-      
+
       switch (ELF32_R_TYPE (rel->r_info))
 	{
 	  /* This relocation describes the C++ object vtable
@@ -488,7 +492,7 @@
 	  if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
 	    return FALSE;
 	  break;
-	  
+
 	  /* This relocation describes which C++ vtable entries
 	     are actually used.  Record for later use during GC.  */
 	case R_IQ2000_GNU_VTENTRY:
@@ -584,20 +588,20 @@
       bfd_reloc_status_type	   r;
       const char *		   name = NULL;
       int			   r_type;
-      
+
       r_type = ELF32_R_TYPE (rel->r_info);
-      
+
       if (   r_type == R_IQ2000_GNU_VTINHERIT
 	  || r_type == R_IQ2000_GNU_VTENTRY)
 	continue;
-      
+
       r_symndx = ELF32_R_SYM (rel->r_info);
 
       howto  = iq2000_elf_howto_table + ELF32_R_TYPE (rel->r_info);
       h	     = NULL;
       sym    = NULL;
       sec    = NULL;
-      
+
       if (r_symndx < symtab_hdr->sh_info)
 	{
 	  asection *osec;
@@ -615,7 +619,7 @@
 	  relocation = (sec->output_section->vma
 			+ sec->output_offset
 			+ sym->st_value);
-	  
+
 	  name = bfd_elf_string_from_elf_section
 	    (input_bfd, symtab_hdr->sh_link, sym->st_name);
 	  name = (name == NULL) ? bfd_section_name (input_bfd, osec) : name;
@@ -633,9 +637,9 @@
 	  name = h->root.root.string;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -674,12 +678,12 @@
 		(info, (h ? &h->root : NULL), name, howto->name,
 		 (bfd_vma) 0, input_bfd, input_section, rel->r_offset);
 	      break;
-	      
+
 	    case bfd_reloc_undefined:
 	      r = info->callbacks->undefined_symbol
 		(info, name, input_bfd, input_section, rel->r_offset, TRUE);
 	      break;
-	      
+
 	    case bfd_reloc_outofrange:
 	      msg = _("internal error: out of range error");
 	      break;
@@ -836,7 +840,7 @@
 	      break;
 	    }
 	}
-      
+
       /* Print out any mismatches from above.  */
       if (new_opt[0])
 	{
diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c
index 07add20..df6f346 100644
--- a/bfd/elf32-lm32.c
+++ b/bfd/elf32-lm32.c
@@ -1,5 +1,5 @@
 /* Lattice Mico32-specific support for 32-bit ELF
-   Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
    Contributed by Jon Beniston <[email protected]>
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -19,8 +19,8 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
 #include "elf/lm32.h"
@@ -159,7 +159,7 @@
   struct elf_lm32_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_lm32_link_hash_table);
 
-  ret = bfd_malloc (amt);
+  ret = bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
 
@@ -172,16 +172,6 @@
       return NULL;
     }
 
-  ret->sgot = NULL;
-  ret->sgotplt = NULL;
-  ret->srelgot = NULL;
-  ret->sfixup32 = NULL;
-  ret->splt = NULL;
-  ret->srelplt = NULL;
-  ret->sdynbss = NULL;
-  ret->srelbss = NULL;
-  ret->relocs32 = 0;
-
   return &ret->root.root;
 }
 
@@ -217,8 +207,8 @@
   asection *s;
 
   /* This function may be called more than once.  */
-  s = bfd_get_section_by_name (dynobj, ".got");
-  if (s != NULL && (s->flags & SEC_LINKER_CREATED) != 0)
+  s = bfd_get_linker_section (dynobj, ".got");
+  if (s != NULL)
     return TRUE;
 
   htab = lm32_elf_hash_table (info);
@@ -228,9 +218,9 @@
   if (! _bfd_elf_create_got_section (dynobj, info))
     return FALSE;
 
-  htab->sgot = bfd_get_section_by_name (dynobj, ".got");
-  htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
-  htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+  htab->sgot = bfd_get_linker_section (dynobj, ".got");
+  htab->sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
+  htab->srelgot = bfd_get_linker_section (dynobj, ".rela.got");
   if (! htab->sgot || ! htab->sgotplt || ! htab->srelgot)
     abort ();
 
@@ -250,16 +240,18 @@
     return FALSE;
 
   /* Fixup section for R_LM32_32 relocs.  */
-  lm32fdpic_fixup32_section (info) = bfd_make_section_with_flags (dynobj,
-                                                                   ".rofixup",
-				                                   (SEC_ALLOC
-                                                                   | SEC_LOAD
-                                                                   | SEC_HAS_CONTENTS
-                                                                   | SEC_IN_MEMORY
-	                                                           | SEC_LINKER_CREATED
-                                                                   | SEC_READONLY));
+  lm32fdpic_fixup32_section (info)
+    = bfd_make_section_anyway_with_flags (dynobj,
+					  ".rofixup",
+					  (SEC_ALLOC
+					   | SEC_LOAD
+					   | SEC_HAS_CONTENTS
+					   | SEC_IN_MEMORY
+					   | SEC_LINKER_CREATED
+					   | SEC_READONLY));
   if (lm32fdpic_fixup32_section (info) == NULL
-      || ! bfd_set_section_alignment (dynobj, lm32fdpic_fixup32_section (info), 2))
+      || ! bfd_set_section_alignment (dynobj,
+				      lm32fdpic_fixup32_section (info), 2))
     return FALSE;
 
   return TRUE;
@@ -783,8 +775,7 @@
   Elf_Internal_Phdr *p;
 
   /* Find the segment that contains the output_section.  */
-  for (m = elf_tdata (output_bfd)->segment_map,
-	 p = elf_tdata (output_bfd)->phdr;
+  for (m = elf_seg_map (output_bfd), p = elf_tdata (output_bfd)->phdr;
        m != NULL;
        m = m->next, p++)
     {
@@ -893,9 +884,9 @@
 	  name = h->root.root.string;
         }
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
         {
@@ -1031,7 +1022,8 @@
 
                           /* We need to generate a R_LM32_RELATIVE reloc
                              for the dynamic linker.  */
-                          srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+                          srelgot = bfd_get_linker_section (dynobj,
+							    ".rela.got");
                           BFD_ASSERT (srelgot != NULL);
 
                           outrel.r_offset = (sgot->output_section->vma
@@ -1313,6 +1305,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       /* Some relocs require a global offset table.  */
@@ -1346,7 +1342,7 @@
               /* Create .rofixup section */
               if (htab->sfixup32 == NULL)
                 {
-                  if (! create_rofixup_section (abfd, info))
+                  if (! create_rofixup_section (dynobj, info))
                     return FALSE;
                 }
               break;
@@ -1356,7 +1352,9 @@
               /* Create .rofixup section.  */
               if (htab->sfixup32 == NULL)
                 {
-                  if (! create_rofixup_section (abfd, info))
+		  if (dynobj == NULL)
+		    htab->root.dynobj = dynobj = abfd;
+                  if (! create_rofixup_section (dynobj, info))
                     return FALSE;
                 }
               break;
@@ -1427,7 +1425,7 @@
   dynobj = htab->root.dynobj;
 
   sgot = htab->sgotplt;
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (htab->root.dynamic_sections_created)
     {
@@ -1725,8 +1723,7 @@
                   && (h->root.type == bfd_link_hash_defined
                       || h->root.type == bfd_link_hash_defweak));
 
-      s = bfd_get_section_by_name (h->root.u.def.section->owner,
-                                   ".rela.bss");
+      s = bfd_get_linker_section (htab->root.dynobj, ".rela.bss");
       BFD_ASSERT (s != NULL);
 
       rela.r_offset = (h->root.u.def.value
@@ -1741,15 +1738,16 @@
     }
 
   /* Mark some specially defined symbols as absolute.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
-      || h == htab->root.hgot)
+  if (h == htab->root.hdynamic || h == htab->root.hgot)
     sym->st_shndx = SHN_ABS;
 
   return TRUE;
 }
 
 static enum elf_reloc_type_class
-lm32_elf_reloc_type_class (const Elf_Internal_Rela *rela)
+lm32_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			   const asection *rel_sec ATTRIBUTE_UNUSED,
+			   const Elf_Internal_Rela *rela)
 {
   switch ((int) ELF32_R_TYPE (rela->r_info))
     {
@@ -1863,13 +1861,6 @@
       return TRUE;
     }
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-			     h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -1891,7 +1882,7 @@
      to copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rela.bss section we are going to use.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       asection *srel;
 
@@ -2146,7 +2137,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
@@ -2372,7 +2363,7 @@
                           /* Don't generate entries for weak symbols.  */
                           if (!h || (h && h->root.type != bfd_link_hash_undefweak))
                             {
-                              if (!elf_discarded_section (s) && !((bfd_get_section_flags (ibfd, s) & SEC_ALLOC) == 0))
+                              if (!discarded_section (s) && !((bfd_get_section_flags (ibfd, s) & SEC_ALLOC) == 0))
                                 {
                                   switch (ELF32_R_TYPE (internal_relocs->r_info))
                                     {
@@ -2394,7 +2385,7 @@
                                   if (!strcmp (current->name, h->root.root.string))
                                     break;
                                 }
-                              if (!current && !elf_discarded_section (s) && (bfd_get_section_flags (ibfd, s) & SEC_ALLOC))
+                              if (!current && !discarded_section (s) && (bfd_get_section_flags (ibfd, s) & SEC_ALLOC))
                                 {
                                   /* Will this have an entry in the GOT.  */
                                   if (ELF32_R_TYPE (internal_relocs->r_info) == R_LM32_16_GOT)
@@ -2490,7 +2481,7 @@
   if (bed->plt_readonly)
     pltflags |= SEC_READONLY;
 
-  s = bfd_make_section_with_flags (abfd, ".plt", pltflags);
+  s = bfd_make_section_anyway_with_flags (abfd, ".plt", pltflags);
   htab->splt = s;
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
@@ -2518,9 +2509,10 @@
         return FALSE;
     }
 
-  s = bfd_make_section_with_flags (abfd,
-				   bed->default_use_rela_p ? ".rela.plt" : ".rel.plt",
-				   flags | SEC_READONLY);
+  s = bfd_make_section_anyway_with_flags (abfd,
+					  bed->default_use_rela_p
+					  ? ".rela.plt" : ".rel.plt",
+					  flags | SEC_READONLY);
   htab->srelplt = s;
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, ptralign))
@@ -2530,32 +2522,6 @@
       && ! create_got_section (abfd, info))
     return FALSE;
 
-  {
-    const char *secname;
-    char *relname;
-    flagword secflags;
-    asection *sec;
-
-    for (sec = abfd->sections; sec; sec = sec->next)
-      {
-        secflags = bfd_get_section_flags (abfd, sec);
-        if ((secflags & (SEC_DATA | SEC_LINKER_CREATED))
-            || ((secflags & SEC_HAS_CONTENTS) != SEC_HAS_CONTENTS))
-          continue;
-        secname = bfd_get_section_name (abfd, sec);
-        relname = bfd_malloc ((bfd_size_type) strlen (secname) + 6);
-        strcpy (relname, ".rela");
-        strcat (relname, secname);
-        if (bfd_get_section_by_name (abfd, secname))
-          continue;
-        s = bfd_make_section_with_flags (abfd, relname,
-					 flags | SEC_READONLY);
-        if (s == NULL
-            || ! bfd_set_section_alignment (abfd, s, ptralign))
-          return FALSE;
-      }
-  }
-
   if (bed->want_dynbss)
     {
       /* The .dynbss section is a place to put symbols which are defined
@@ -2564,8 +2530,8 @@
          image and use a R_*_COPY reloc to tell the dynamic linker to
          initialize them at run time.  The linker script puts the .dynbss
          section into the .bss section of the final image.  */
-      s = bfd_make_section_with_flags (abfd, ".dynbss",
-				       SEC_ALLOC | SEC_LINKER_CREATED);
+      s = bfd_make_section_anyway_with_flags (abfd, ".dynbss",
+					      SEC_ALLOC | SEC_LINKER_CREATED);
       htab->sdynbss = s;
       if (s == NULL)
         return FALSE;
@@ -2582,10 +2548,10 @@
          copy relocs.  */
       if (! info->shared)
         {
-          s = bfd_make_section_with_flags (abfd,
-					   (bed->default_use_rela_p
-					    ? ".rela.bss" : ".rel.bss"),
-					   flags | SEC_READONLY);
+          s = bfd_make_section_anyway_with_flags (abfd,
+						  (bed->default_use_rela_p
+						   ? ".rela.bss" : ".rel.bss"),
+						  flags | SEC_READONLY);
           htab->srelbss = s;
           if (s == NULL
               || ! bfd_set_section_alignment (abfd, s, ptralign))
@@ -2644,136 +2610,23 @@
 }
 
 static bfd_boolean
-lm32_elf_always_size_sections (bfd *output_bfd,
-				 struct bfd_link_info *info)
+lm32_elf_always_size_sections (bfd *output_bfd, struct bfd_link_info *info)
 {
   if (!info->relocatable)
     {
-      struct elf_link_hash_entry *h;
+      if (!bfd_elf_stack_segment_size (output_bfd, info,
+				       "__stacksize", DEFAULT_STACK_SIZE))
+	return FALSE;
 
-      /* Force a PT_GNU_STACK segment to be created.  */
-      if (! elf_tdata (output_bfd)->stack_flags)
-	elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X;
-
-      /* Define __stacksize if it's not defined yet.  */
-      h = elf_link_hash_lookup (elf_hash_table (info), "__stacksize",
-				FALSE, FALSE, FALSE);
-      if (! h || h->root.type != bfd_link_hash_defined
-	  || h->type != STT_OBJECT
-	  || !h->def_regular)
-	{
-	  struct bfd_link_hash_entry *bh = NULL;
-
-	  if (!(_bfd_generic_link_add_one_symbol
-		(info, output_bfd, "__stacksize",
-		 BSF_GLOBAL, bfd_abs_section_ptr, DEFAULT_STACK_SIZE,
-		 (const char *) NULL, FALSE,
-		 get_elf_backend_data (output_bfd)->collect, &bh)))
-	    return FALSE;
-
-	  h = (struct elf_link_hash_entry *) bh;
-	  h->def_regular = 1;
-	  h->type = STT_OBJECT;
-	  /* This one must NOT be hidden.  */
-	}
-    }
-
-  return TRUE;
-}
-
-static bfd_boolean
-lm32_elf_modify_segment_map (bfd *output_bfd,
-			     struct bfd_link_info *info)
-{
-  struct elf_segment_map *m;
-
-  /* objcopy and strip preserve what's already there using elf32_lm32fdpic_copy_
-     private_bfd_data ().  */
-  if (! info)
-    return TRUE;
-
-  for (m = elf_tdata (output_bfd)->segment_map; m != NULL; m = m->next)
-    if (m->p_type == PT_GNU_STACK)
-      break;
-
-  if (m)
-    {
       asection *sec = bfd_get_section_by_name (output_bfd, ".stack");
-      struct elf_link_hash_entry *h;
-
       if (sec)
-	{
-	  /* Obtain the pointer to the __stacksize symbol.  */
-	  h = elf_link_hash_lookup (elf_hash_table (info), "__stacksize",
-				    FALSE, FALSE, FALSE);
-	  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;
-	  BFD_ASSERT (h->root.type == bfd_link_hash_defined);
-
-	  /* Set the section size from the symbol value.  We
-	     intentionally ignore the symbol section.  */
-	  if (h->root.type == bfd_link_hash_defined)
-	    sec->size = h->root.u.def.value;
-	  else
-	    sec->size = DEFAULT_STACK_SIZE;
-
-	  /* Add the stack section to the PT_GNU_STACK segment,
-	     such that its size and alignment requirements make it
-	     to the segment.  */
-	  m->sections[m->count] = sec;
-	  m->count++;
-	}
+	sec->size = info->stacksize >= 0 ? info->stacksize : 0;
     }
 
   return TRUE;
 }
 
 static bfd_boolean
-lm32_elf_modify_program_headers (bfd *output_bfd,
-				       struct bfd_link_info *info)
-{
-  struct elf_obj_tdata *tdata = elf_tdata (output_bfd);
-  struct elf_segment_map *m;
-  Elf_Internal_Phdr *p;
-
-  if (! info)
-    return TRUE;
-
-  for (p = tdata->phdr, m = tdata->segment_map; m != NULL; m = m->next, p++)
-    if (m->p_type == PT_GNU_STACK)
-      break;
-
-  if (m)
-    {
-      struct elf_link_hash_entry *h;
-
-      /* Obtain the pointer to the __stacksize symbol.  */
-      h = elf_link_hash_lookup (elf_hash_table (info), "__stacksize",
-				FALSE, FALSE, FALSE);
-      if (h)
-	{
-	  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;
-	  BFD_ASSERT (h->root.type == bfd_link_hash_defined);
-	}
-
-      /* Set the header p_memsz from the symbol value.  We
-	 intentionally ignore the symbol section.  */
-      if (h && h->root.type == bfd_link_hash_defined)
-	p->p_memsz = h->root.u.def.value;
-      else
-	p->p_memsz = DEFAULT_STACK_SIZE;
-
-      p->p_align = 8;
-    }
-
-  return TRUE;
-}
-
-
-static bfd_boolean
 lm32_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
 {
   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
@@ -2851,6 +2704,7 @@
 #define elf_backend_rela_normal                 1
 #define elf_backend_object_p                    lm32_elf_object_p
 #define elf_backend_final_write_processing      lm32_elf_final_write_processing
+#define elf_backend_stack_align			8
 #define elf_backend_can_gc_sections             1
 #define elf_backend_can_refcount                1
 #define elf_backend_gc_mark_hook                lm32_elf_gc_mark_hook
@@ -2886,10 +2740,6 @@
 
 #undef  elf_backend_always_size_sections
 #define elf_backend_always_size_sections        lm32_elf_always_size_sections
-#undef  elf_backend_modify_segment_map
-#define elf_backend_modify_segment_map          lm32_elf_modify_segment_map
-#undef  elf_backend_modify_program_headers
-#define elf_backend_modify_program_headers      lm32_elf_modify_program_headers
 #undef  bfd_elf32_bfd_copy_private_bfd_data
 #define bfd_elf32_bfd_copy_private_bfd_data     lm32_elf_fdpic_copy_private_bfd_data
 
diff --git a/bfd/elf32-m32c.c b/bfd/elf32-m32c.c
index cf7ad99..5205b7b 100644
--- a/bfd/elf32-m32c.c
+++ b/bfd/elf32-m32c.c
@@ -1,5 +1,5 @@
 /* M16C/M32C specific support for 32-bit ELF.
-   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -28,9 +28,9 @@
 /* Forward declarations.  */
 static reloc_howto_type * m32c_reloc_type_lookup
   (bfd *, bfd_reloc_code_real_type);
-static void m32c_info_to_howto_rela 
+static void m32c_info_to_howto_rela
   (bfd *, arelent *, Elf_Internal_Rela *);
-static bfd_boolean m32c_elf_relocate_section 
+static bfd_boolean m32c_elf_relocate_section
   (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **);
 static bfd_boolean m32c_elf_check_relocs
   (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *);
@@ -268,7 +268,7 @@
   for (i = ARRAY_SIZE (m32c_reloc_map); --i;)
     if (m32c_reloc_map [i].bfd_reloc_val == code)
       return & m32c_elf_howto_table [m32c_reloc_map[i].m32c_reloc_val];
-  
+
   return NULL;
 }
 
@@ -362,7 +362,7 @@
   dynobj = elf_hash_table (info)->dynobj;
   splt = NULL;
   if (dynobj != NULL)
-    splt = bfd_get_section_by_name (dynobj, ".plt");
+    splt = bfd_get_linker_section (dynobj, ".plt");
 
   for (rel = relocs; rel < relend; rel ++)
     {
@@ -375,7 +375,7 @@
       bfd_reloc_status_type        r;
       const char *                 name = NULL;
       int                          r_type;
-      
+
       r_type = ELF32_R_TYPE (rel->r_info);
 
       /* These are only used for relaxing; we don't actually relocate
@@ -384,7 +384,7 @@
 	  || r_type == R_M32C_RL_1ADDR
 	  || r_type == R_M32C_RL_2ADDR)
 	continue;
-      
+
       r_symndx = ELF32_R_SYM (rel->r_info);
 
       howto  = m32c_elf_howto_table + ELF32_R_TYPE (rel->r_info);
@@ -400,7 +400,7 @@
 	  relocation = (sec->output_section->vma
 			+ sec->output_offset
 			+ sym->st_value);
-	  
+
 	  name = bfd_elf_string_from_elf_section
 	    (input_bfd, symtab_hdr->sh_link, sym->st_name);
 	  name = (sym->st_name == 0) ? bfd_section_name (input_bfd, sec) : name;
@@ -408,13 +408,13 @@
       else
 	{
 	  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;
 
 	  name = h->root.root.string;
-	  
+
 	  if (h->root.type == bfd_link_hash_defined
 	      || h->root.type == bfd_link_hash_defweak)
 	    {
@@ -434,9 +434,9 @@
 	    }
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	{
@@ -542,13 +542,13 @@
 		(info, (h ? &h->root : NULL), name, howto->name, (bfd_vma) 0,
 		 input_bfd, input_section, rel->r_offset);
 	      break;
-	      
+
 	    case bfd_reloc_undefined:
 	      r = info->callbacks->undefined_symbol
 		(info, name, input_bfd, input_section, rel->r_offset,
 		 TRUE);
 	      break;
-	      
+
 	    case bfd_reloc_outofrange:
 	      msg = _("internal error: out of range error");
 	      break;
@@ -580,7 +580,7 @@
 
 /* We support 16-bit pointers to code above 64k by generating a thunk
    below 64k containing a JMP instruction to the final address.  */
- 
+
 static bfd_boolean
 m32c_elf_check_relocs
     (bfd *                     abfd,
@@ -595,10 +595,10 @@
   bfd_vma *local_plt_offsets;
   asection *splt;
   bfd *dynobj;
- 
+
   if (info->relocatable)
     return TRUE;
- 
+
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
   local_plt_offsets = elf_local_got_offsets (abfd);
@@ -611,7 +611,7 @@
       struct elf_link_hash_entry *h;
       unsigned long r_symndx;
       bfd_vma *offset;
- 
+
       r_symndx = ELF32_R_SYM (rel->r_info);
       if (r_symndx < symtab_hdr->sh_info)
         h = NULL;
@@ -621,8 +621,12 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
- 
+
       switch (ELF32_R_TYPE (rel->r_info))
         {
 	  /* This relocation describes a 16-bit pointer to a function.
@@ -633,13 +637,14 @@
 	    elf_hash_table (info)->dynobj = dynobj = abfd;
 	  if (splt == NULL)
 	    {
-	      splt = bfd_get_section_by_name (dynobj, ".plt");
+	      splt = bfd_get_linker_section (dynobj, ".plt");
 	      if (splt == NULL)
 		{
 		  flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
 				    | SEC_IN_MEMORY | SEC_LINKER_CREATED
 				    | SEC_READONLY | SEC_CODE);
-		  splt = bfd_make_section_with_flags (dynobj, ".plt", flags);
+		  splt = bfd_make_section_anyway_with_flags (dynobj, ".plt",
+							     flags);
 		  if (splt == NULL
 		      || ! bfd_set_section_alignment (dynobj, splt, 1))
 		    return FALSE;
@@ -675,7 +680,7 @@
 	  break;
         }
     }
- 
+
   return TRUE;
 }
 
@@ -692,7 +697,7 @@
      been filled in.  */
 
   if ((dynobj = elf_hash_table (info)->dynobj) != NULL
-      && (splt = bfd_get_section_by_name (dynobj, ".plt")) != NULL)
+      && (splt = bfd_get_linker_section (dynobj, ".plt")) != NULL)
     {
       bfd_byte *contents = splt->contents;
       unsigned int i, size = splt->size;
@@ -720,7 +725,7 @@
   if (dynobj == NULL)
     return TRUE;
 
-  splt = bfd_get_section_by_name (dynobj, ".plt");
+  splt = bfd_get_linker_section (dynobj, ".plt");
   BFD_ASSERT (splt != NULL);
 
   splt->contents = (bfd_byte *) bfd_zalloc (dynobj, splt->size);
@@ -798,7 +803,7 @@
 	    case EF_M32C_CPU_M32C:  strcat (old_opt, " -m32c");  break;
 	    }
 	}
-      
+
       /* Print out any mismatches from above.  */
       if (new_opt[0])
 	{
@@ -829,7 +834,7 @@
 
 
 static bfd_boolean
-m32c_elf_print_private_bfd_data (bfd *abfd, PTR ptr)
+m32c_elf_print_private_bfd_data (bfd *abfd, void *ptr)
 {
   FILE *file = (FILE *) ptr;
   flagword flags;
@@ -901,7 +906,7 @@
       external_syms = bfd_malloc (1000);
       free_external = 1;
     }
-  
+
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   locsymcount = symtab_hdr->sh_size / get_elf_backend_data(abfd)->s->sizeof_sym;
   if (free_internal)
@@ -943,10 +948,10 @@
 	case SHN_UNDEF: st_shndx_str = "SHN_UNDEF";
 	default: st_shndx_str = "";
 	}
-      
+
       printf ("isym = %p st_value = %lx st_size = %lx st_name = (%lu) %s "
 	      "st_info = (%d) %s %s st_other = (%d) %s st_shndx = (%d) %s\n",
-	      isym, 
+	      isym,
 	      (unsigned long) isym->st_value,
 	      (unsigned long) isym->st_size,
 	      isym->st_name,
@@ -984,8 +989,7 @@
 };
 
 static bfd_boolean
-m32c_relax_plt_check (struct elf_link_hash_entry *h,
-                      PTR xdata)
+m32c_relax_plt_check (struct elf_link_hash_entry *h, void * xdata)
 {
   struct relax_plt_data *data = (struct relax_plt_data *) xdata;
 
@@ -1016,8 +1020,7 @@
    previously had a plt entry, give it a new entry offset.  */
 
 static bfd_boolean
-m32c_relax_plt_realloc (struct elf_link_hash_entry *h,
-                        PTR xdata)
+m32c_relax_plt_realloc (struct elf_link_hash_entry *h, void * xdata)
 {
   bfd_vma *entry = (bfd_vma *) xdata;
 
@@ -1031,8 +1034,7 @@
 }
 
 static bfd_boolean
-m32c_elf_relax_plt_section (bfd *dynobj,
-                            asection *splt,
+m32c_elf_relax_plt_section (asection *splt,
                             struct bfd_link_info *info,
                             bfd_boolean *again)
 {
@@ -1045,11 +1047,6 @@
   if (info->relocatable)
     return TRUE;
 
-  /* We only relax the .plt section at the moment.  */
-  if (dynobj != elf_hash_table (info)->dynobj
-      || strcmp (splt->name, ".plt") != 0)
-    return TRUE;
-
   /* Quick check for an empty plt.  */
   if (splt->size == 0)
     return TRUE;
@@ -1337,8 +1334,9 @@
   int machine;
 
   if (abfd == elf_hash_table (link_info)->dynobj
+      && (sec->flags & SEC_LINKER_CREATED) != 0
       && strcmp (sec->name, ".plt") == 0)
-    return m32c_elf_relax_plt_section (abfd, sec, link_info, again);
+    return m32c_elf_relax_plt_section (sec, link_info, again);
 
   /* Assume nothing changes.  */
   *again = FALSE;
@@ -1386,14 +1384,14 @@
       if (shndx_buf == NULL)
 	goto error_return;
       if (bfd_seek (abfd, shndx_hdr->sh_offset, SEEK_SET) != 0
-	  || bfd_bread ((PTR) shndx_buf, amt, abfd) != amt)
+	  || bfd_bread (shndx_buf, amt, abfd) != amt)
 	goto error_return;
       shndx_hdr->contents = (bfd_byte *) shndx_buf;
     }
 
   /* Get a copy of the native relocations.  */
   internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
 		      link_info->keep_memory));
   if (internal_relocs == NULL)
     goto error_return;
@@ -1585,7 +1583,7 @@
 
 	      enctbl = m16c_addr_encodings;
 	      posn = 2;
-	      
+
 	      /* Check the opcode for jumps.  We know it's safe to
 		 do this because all 2ADDR insns are at least two
 		 bytes long.  */
@@ -1771,7 +1769,7 @@
       /* Note that we've changed the relocs, section contents, etc.  */
       elf_section_data (sec)->relocs = internal_relocs;
       free_relocs = NULL;
-      
+
       elf_section_data (sec)->this_hdr.contents = contents;
       free_contents = NULL;
 
diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c
index 51ef61e..71e8fc7 100644
--- a/bfd/elf32-m32r.c
+++ b/bfd/elf32-m32r.c
@@ -1,6 +1,5 @@
 /* M32R-specific support for 32-bit ELF.
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright 1996-2013 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -1390,7 +1389,8 @@
 						  flags);
 	  if (s == NULL)
 	    return FALSE;
-	  bfd_set_section_alignment (abfd, s, 2);
+	  if (! bfd_set_section_alignment (abfd, s, 2))
+	    return FALSE;
 	}
 
       bh = bfd_link_hash_lookup (info->hash, "_SDA_BASE_",
@@ -1585,7 +1585,7 @@
   struct elf_m32r_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_m32r_link_hash_table);
 
-  ret = bfd_malloc (amt);
+  ret = bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
 
@@ -1598,15 +1598,6 @@
       return NULL;
     }
 
-  ret->sgot = NULL;
-  ret->sgotplt = NULL;
-  ret->srelgot = NULL;
-  ret->splt = NULL;
-  ret->srelplt = NULL;
-  ret->sdynbss = NULL;
-  ret->srelbss = NULL;
-  ret->sym_cache.abfd = NULL;
-
   return &ret->root.root;
 }
 
@@ -1625,9 +1616,9 @@
   if (htab == NULL)
     return FALSE;
 
-  htab->sgot = bfd_get_section_by_name (dynobj, ".got");
-  htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
-  htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+  htab->sgot = bfd_get_linker_section (dynobj, ".got");
+  htab->sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
+  htab->srelgot = bfd_get_linker_section (dynobj, ".rela.got");
   if (! htab->sgot || ! htab->sgotplt || ! htab->srelgot)
     abort ();
 
@@ -1661,7 +1652,7 @@
   if (bed->plt_readonly)
     pltflags |= SEC_READONLY;
 
-  s = bfd_make_section_with_flags (abfd, ".plt", pltflags);
+  s = bfd_make_section_anyway_with_flags (abfd, ".plt", pltflags);
   htab->splt = s;
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
@@ -1689,9 +1680,10 @@
         return FALSE;
     }
 
-  s = bfd_make_section_with_flags (abfd,
-				   bed->default_use_rela_p ? ".rela.plt" : ".rel.plt",
-				   flags | SEC_READONLY);
+  s = bfd_make_section_anyway_with_flags (abfd,
+					  bed->default_use_rela_p
+					  ? ".rela.plt" : ".rel.plt",
+					  flags | SEC_READONLY);
   htab->srelplt = s;
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, ptralign))
@@ -1701,32 +1693,6 @@
       && ! create_got_section (abfd, info))
     return FALSE;
 
-  {
-    const char *secname;
-    char *relname;
-    flagword secflags;
-    asection *sec;
-
-    for (sec = abfd->sections; sec; sec = sec->next)
-      {
-        secflags = bfd_get_section_flags (abfd, sec);
-        if ((secflags & (SEC_DATA | SEC_LINKER_CREATED))
-            || ((secflags & SEC_HAS_CONTENTS) != SEC_HAS_CONTENTS))
-          continue;
-        secname = bfd_get_section_name (abfd, sec);
-        relname = bfd_malloc ((bfd_size_type) strlen (secname) + 6);
-        strcpy (relname, ".rela");
-        strcat (relname, secname);
-        if (bfd_get_section_by_name (abfd, secname))
-          continue;
-        s = bfd_make_section_with_flags (abfd, relname,
-					 flags | SEC_READONLY);
-        if (s == NULL
-            || ! bfd_set_section_alignment (abfd, s, ptralign))
-          return FALSE;
-      }
-  }
-
   if (bed->want_dynbss)
     {
       /* The .dynbss section is a place to put symbols which are defined
@@ -1735,8 +1701,8 @@
          image and use a R_*_COPY reloc to tell the dynamic linker to
          initialize them at run time.  The linker script puts the .dynbss
          section into the .bss section of the final image.  */
-      s = bfd_make_section_with_flags (abfd, ".dynbss",
-				       SEC_ALLOC | SEC_LINKER_CREATED);
+      s = bfd_make_section_anyway_with_flags (abfd, ".dynbss",
+					      SEC_ALLOC | SEC_LINKER_CREATED);
       htab->sdynbss = s;
       if (s == NULL)
         return FALSE;
@@ -1753,10 +1719,10 @@
          copy relocs.  */
       if (! info->shared)
         {
-          s = bfd_make_section_with_flags (abfd,
-					   (bed->default_use_rela_p
-					    ? ".rela.bss" : ".rel.bss"),
-					   flags | SEC_READONLY);
+          s = bfd_make_section_anyway_with_flags (abfd,
+						  (bed->default_use_rela_p
+						   ? ".rela.bss" : ".rel.bss"),
+						  flags | SEC_READONLY);
           htab->srelbss = s;
           if (s == NULL
               || ! bfd_set_section_alignment (abfd, s, ptralign))
@@ -1922,13 +1888,6 @@
       return TRUE;
     }
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-			     h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -1950,7 +1909,7 @@
      to copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rela.bss section we are going to use.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       asection *srel;
 
@@ -2209,7 +2168,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
@@ -2589,7 +2548,11 @@
 		relocation = (h->root.u.def.value
 			      + sec->output_section->vma
 			      + sec->output_offset);
-	      else if (!info->relocatable)
+	      else if (!info->relocatable
+		       && (_bfd_elf_section_offset (output_bfd, info,
+						    input_section,
+						    rel->r_offset)
+			   != (bfd_vma) -1))
 		{
 		  (*_bfd_error_handler)
 		    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
@@ -2616,9 +2579,9 @@
 	    }
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable && !use_rel)
 	{
@@ -2817,7 +2780,8 @@
 
                           /* We need to generate a R_M32R_RELATIVE reloc
                              for the dynamic linker.  */
-                          srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+                          srelgot = bfd_get_linker_section (dynobj,
+							    ".rela.got");
                           BFD_ASSERT (srelgot != NULL);
 
                           outrel.r_offset = (sgot->output_section->vma
@@ -3010,7 +2974,7 @@
 		const char *name;
 
 		BFD_ASSERT (sec != NULL);
-		name = bfd_get_section_name (abfd, sec);
+		name = bfd_get_section_name (sec->owner, sec);
 
 		if (   strcmp (name, ".sdata") == 0
 		    || strcmp (name, ".sbss") == 0
@@ -3307,8 +3271,7 @@
                   && (h->root.type == bfd_link_hash_defined
                       || h->root.type == bfd_link_hash_defweak));
 
-      s = bfd_get_section_by_name (h->root.u.def.section->owner,
-                                   ".rela.bss");
+      s = bfd_get_linker_section (htab->root.dynobj, ".rela.bss");
       BFD_ASSERT (s != NULL);
 
       rela.r_offset = (h->root.u.def.value
@@ -3323,8 +3286,7 @@
     }
 
   /* Mark some specially defined symbols as absolute.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
-      || h == htab->root.hgot)
+  if (h == htab->root.hdynamic || h == htab->root.hgot)
     sym->st_shndx = SHN_ABS;
 
   return TRUE;
@@ -3353,7 +3315,7 @@
   dynobj = htab->root.dynobj;
 
   sgot = htab->sgotplt;
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (htab->root.dynamic_sections_created)
     {
@@ -3784,6 +3746,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       /* Some relocs require a global offset table.  */
@@ -4019,7 +3985,9 @@
 };
 
 static enum elf_reloc_type_class
-m32r_elf_reloc_type_class (const Elf_Internal_Rela *rela)
+m32r_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			   const asection *rel_sec ATTRIBUTE_UNUSED,
+			   const Elf_Internal_Rela *rela)
 {
   switch ((int) ELF32_R_TYPE (rela->r_info))
     {
diff --git a/bfd/elf32-m68hc11.c b/bfd/elf32-m68hc11.c
index 63d0786..b28579e 100644
--- a/bfd/elf32-m68hc11.c
+++ b/bfd/elf32-m68hc11.c
@@ -1,5 +1,5 @@
 /* Motorola 68HC11-specific support for 32-bit ELF
-   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010
+   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2012
    Free Software Foundation, Inc.
    Contributed by Stephane Carrez ([email protected])
    (Heavily copied from the D10V port by Martin Hunt ([email protected]))
@@ -703,7 +703,7 @@
 
   /* Get a copy of the native relocations.  */
   internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
 		      link_info->keep_memory));
   if (internal_relocs == NULL)
     goto error_return;
@@ -1302,6 +1302,7 @@
 #define elf_backend_final_write_processing	0
 #define elf_backend_can_gc_sections		1
 #define elf_backend_special_sections  elf32_m68hc11_special_sections
+#define elf_backend_merge_symbol_attribute elf32_m68hc11_merge_symbol_attribute
 
 #define bfd_elf32_bfd_link_hash_table_create \
                                 m68hc11_elf_bfd_link_hash_table_create
diff --git a/bfd/elf32-m68hc12.c b/bfd/elf32-m68hc12.c
index 1788856..2b5a1b3 100644
--- a/bfd/elf32-m68hc12.c
+++ b/bfd/elf32-m68hc12.c
@@ -1,5 +1,5 @@
 /* Motorola 68HC12-specific support for 32-bit ELF
-   Copyright 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007
+   Copyright 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2012
    Free Software Foundation, Inc.
    Contributed by Stephane Carrez ([email protected])
    (Heavily copied from the D10V port by Martin Hunt ([email protected]))
@@ -37,14 +37,7 @@
   (bfd *, arelent *, Elf_Internal_Rela *);
 
 /* Trampoline generation.  */
-static bfd_boolean m68hc12_elf_size_one_stub
-  (struct bfd_hash_entry *gen_entry, void *in_arg);
-static bfd_boolean m68hc12_elf_build_one_stub
-  (struct bfd_hash_entry *gen_entry, void *in_arg);
-static struct bfd_link_hash_table* m68hc12_elf_bfd_link_hash_table_create
-  (bfd*);
 
-static bfd_boolean m68hc12_elf_set_mach_from_flags PARAMS ((bfd *));
 
 /* Use REL instead of RELA to save space */
 #define USE_REL	1
@@ -324,11 +317,81 @@
 	 FALSE),		/* pcrel_offset */
 
   EMPTY_HOWTO (14),
-  EMPTY_HOWTO (15),
-  EMPTY_HOWTO (16),
-  EMPTY_HOWTO (17),
-  EMPTY_HOWTO (18),
-  EMPTY_HOWTO (19),
+
+  /* A 16 bit absolute relocation.  */
+  HOWTO (R_M68HC12_16B,		/* type */
+	 0,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC12_16B",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,			/* src_mask */
+	 0xffff,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* A 9 bit PC-rel relocation.  */
+  HOWTO (R_M68HC12_PCREL_9,	/* type */
+	 1,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 10,			/* bitsize (result is >>1) */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC12_PCREL_9",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0xfe00,		/* src_mask */
+	 0x01ff,		/* dst_mask */
+	 TRUE),                 /* pcrel_offset */
+
+  /* A 10 bit PC-rel relocation.  */
+  HOWTO (R_M68HC12_PCREL_10,	/* type */
+	 1,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 11,			/* bitsize (result is >>1) */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC12_PCREL_10",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0xfc00,		/* src_mask */
+	 0x03ff,		/* dst_mask */
+	 TRUE),                 /* pcrel_offset */
+
+  /* A 8 bit absolute relocation (upper address).  */
+  HOWTO (R_M68HC12_HI8XG,		/* type */
+	 8,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 8,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC12_HI8XG",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x00ff,		/* src_mask */
+	 0x00ff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* A 8 bit absolute relocation (lower address).  */
+  HOWTO (R_M68HC12_LO8XG,		/* type */
+	 8,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 8,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_M68HC12_LO8XG",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x00ff,		/* src_mask */
+	 0x00ff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
 
   /* Mark beginning of a jump instruction (any form).  */
   HOWTO (R_M68HC11_RL_JUMP,	/* type */
@@ -369,7 +432,8 @@
   unsigned char elf_reloc_val;
 };
 
-static const struct m68hc11_reloc_map m68hc11_reloc_map[] = {
+static const struct m68hc11_reloc_map m68hc11_reloc_map[] =
+{
   {BFD_RELOC_NONE, R_M68HC11_NONE,},
   {BFD_RELOC_8, R_M68HC11_8},
   {BFD_RELOC_M68HC11_HI8, R_M68HC11_HI8},
@@ -389,6 +453,13 @@
 
   {BFD_RELOC_M68HC11_RL_JUMP, R_M68HC11_RL_JUMP},
   {BFD_RELOC_M68HC11_RL_GROUP, R_M68HC11_RL_GROUP},
+
+  {BFD_RELOC_M68HC12_16B, R_M68HC12_16B},
+
+  {BFD_RELOC_M68HC12_9_PCREL, R_M68HC12_PCREL_9},
+  {BFD_RELOC_M68HC12_10_PCREL, R_M68HC12_PCREL_10},
+  {BFD_RELOC_M68HC12_HI8XG, R_M68HC12_HI8XG},
+  {BFD_RELOC_M68HC12_LO8XG, R_M68HC12_LO8XG},
 };
 
 static reloc_howto_type *
@@ -581,6 +652,7 @@
 #define elf_backend_special_sections elf32_m68hc12_special_sections
 #define elf_backend_post_process_headers     elf32_m68hc11_post_process_headers
 #define elf_backend_add_symbol_hook  elf32_m68hc11_add_symbol_hook
+#define elf_backend_merge_symbol_attribute elf32_m68hc11_merge_symbol_attribute
 
 #define bfd_elf32_bfd_link_hash_table_create \
                                 m68hc12_elf_bfd_link_hash_table_create
diff --git a/bfd/elf32-m68hc1x.c b/bfd/elf32-m68hc1x.c
index 961dce4..427e3cd 100644
--- a/bfd/elf32-m68hc1x.c
+++ b/bfd/elf32-m68hc1x.c
@@ -1,6 +1,6 @@
 /* Motorola 68HC11/HC12-specific support for 32-bit ELF
    Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-   2009, 2010, 2011  Free Software Foundation, Inc.
+   2009, 2010, 2011, 2012 Free Software Foundation, Inc.
    Contributed by Stephane Carrez ([email protected])
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -20,8 +20,8 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "alloca-conf.h"
 #include "sysdep.h"
+#include "alloca-conf.h"
 #include "bfd.h"
 #include "bfdlink.h"
 #include "libbfd.h"
@@ -50,7 +50,7 @@
 static bfd_boolean m68hc11_elf_export_one_stub
   (struct bfd_hash_entry *gen_entry, void *in_arg);
 
-static void scan_sections_for_abi (bfd*, asection*, PTR);
+static void scan_sections_for_abi (bfd*, asection*, void *);
 
 struct m68hc11_scan_param
 {
@@ -67,11 +67,10 @@
   struct m68hc11_elf_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct m68hc11_elf_link_hash_table);
 
-  ret = (struct m68hc11_elf_link_hash_table *) bfd_malloc (amt);
+  ret = (struct m68hc11_elf_link_hash_table *) bfd_zmalloc (amt);
   if (ret == (struct m68hc11_elf_link_hash_table *) NULL)
     return NULL;
 
-  memset (ret, 0, amt);
   if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
 				      _bfd_elf_link_hash_newfunc,
 				      sizeof (struct elf_link_hash_entry),
@@ -93,11 +92,6 @@
 			    sizeof (struct elf32_m68hc11_stub_hash_entry)))
     return NULL;
 
-  ret->stub_bfd = NULL;
-  ret->stub_section = 0;
-  ret->add_stub_section = NULL;
-  ret->sym_cache.abfd = NULL;
-
   return ret;
 }
 
@@ -111,7 +105,7 @@
 
   bfd_hash_table_free (ret->stub_hash_table);
   free (ret->stub_hash_table);
-  _bfd_generic_link_hash_table_free (hash);
+  _bfd_elf_link_hash_table_free (hash);
 }
 
 /* Assorted hash table functions.  */
@@ -214,6 +208,20 @@
   return TRUE;
 }
 
+/* Merge non-visibility st_other attributes, STO_M68HC12_FAR and
+   STO_M68HC12_INTERRUPT.  */
+
+void
+elf32_m68hc11_merge_symbol_attribute (struct elf_link_hash_entry *h,
+				      const Elf_Internal_Sym *isym,
+				      bfd_boolean definition,
+				      bfd_boolean dynamic ATTRIBUTE_UNUSED)
+{
+  if (definition)
+    h->other = ((isym->st_other & ~ELF_ST_VISIBILITY (-1))
+		| ELF_ST_VISIBILITY (h->other));
+}
+
 /* External entry points for sizing and building linker stubs.  */
 
 /* Set up various things so that we can make a list of input sections
@@ -653,7 +661,7 @@
   /* Build the stubs as directed by the stub hash table.  */
   table = htab->stub_hash_table;
   bfd_hash_traverse (table, m68hc11_elf_export_one_stub, info);
-  
+
   /* Scan the output sections to see if we use the memory banks.
      If so, export the symbols that define how the memory banks
      are mapped.  This is used by gdb and the simulator to obtain
@@ -863,6 +871,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       switch (ELF32_R_TYPE (rel->r_info))
@@ -904,9 +916,11 @@
   struct m68hc11_page_info *pinfo;
   const struct elf_backend_data * const ebd = get_elf_backend_data (input_bfd);
   struct m68hc11_elf_link_hash_table *htab;
+  unsigned long e_flags;
 
   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
+  e_flags = elf_elfheader (input_bfd)->e_flags;
 
   htab = m68hc11_elf_hash_table (info);
   if (htab == NULL)
@@ -934,13 +948,16 @@
       bfd_vma insn_addr;
       bfd_vma insn_page;
       bfd_boolean is_far = FALSE;
+      bfd_boolean is_xgate_symbol = FALSE;
+      bfd_boolean is_section_symbol = FALSE;
       struct elf_link_hash_entry *h;
+      bfd_vma val;
 
       r_symndx = ELF32_R_SYM (rel->r_info);
       r_type = ELF32_R_TYPE (rel->r_info);
 
       if (r_type == R_M68HC11_GNU_VTENTRY
-          || r_type == R_M68HC11_GNU_VTINHERIT )
+          || r_type == R_M68HC11_GNU_VTINHERIT)
         continue;
 
       (*ebd->elf_info_to_howto_rel) (input_bfd, &arel, rel);
@@ -957,6 +974,8 @@
 			+ sec->output_offset
 			+ sym->st_value);
 	  is_far = (sym && (sym->st_other & STO_M68HC12_FAR));
+	  is_xgate_symbol = (sym && (sym->st_target_internal));
+	  is_section_symbol = ELF_ST_TYPE (sym->st_info) & STT_SECTION;
 	}
       else
 	{
@@ -968,11 +987,12 @@
 				   warned);
 
 	  is_far = (h && (h->other & STO_M68HC12_FAR));
+	  is_xgate_symbol = (h && (h->target_internal));
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	{
@@ -1015,6 +1035,50 @@
       phys_page = m68hc11_phys_page (pinfo, relocation + rel->r_addend);
       switch (r_type)
         {
+        case R_M68HC12_LO8XG:
+          /* This relocation is specific to XGATE IMM16 calls and will precede
+	     a HI8. tc-m68hc11 only generates them in pairs.
+	     Leave the relocation to the HI8XG step.  */
+          r = bfd_reloc_ok;
+          r_type = R_M68HC11_NONE;
+          break;
+
+        case R_M68HC12_HI8XG:
+          /* This relocation is specific to XGATE IMM16 calls and must follow
+             a LO8XG. Does not actually check that it was a LO8XG.
+	     Adjusts high and low bytes.  */
+          relocation = phys_addr;
+          if ((e_flags & E_M68HC11_XGATE_RAMOFFSET)
+	      && (relocation >= 0x2000))
+	    relocation += 0xc000; /* HARDCODED RAM offset for XGATE.  */
+
+          /* Fetch 16 bit value including low byte in previous insn.  */
+          val = (bfd_get_8 (input_bfd, (bfd_byte*) contents + rel->r_offset) << 8)
+	    | bfd_get_8 (input_bfd, (bfd_byte*) contents + rel->r_offset - 2);
+
+          /* Add on value to preserve carry, then write zero to high byte.  */
+          relocation += val;
+
+          /* Write out top byte.  */
+          bfd_put_8 (input_bfd, (relocation >> 8) & 0xff,
+		     (bfd_byte*) contents + rel->r_offset);
+
+          /* Write out low byte to previous instruction.  */
+          bfd_put_8 (input_bfd, relocation & 0xff,
+		     (bfd_byte*) contents + rel->r_offset - 2);
+
+          /* Mark as relocation completed.  */
+          r = bfd_reloc_ok;
+          r_type = R_M68HC11_NONE;
+          break;
+
+        /* The HI8 and LO8 relocs are generated by %hi(expr) %lo(expr)
+           assembler directives. %hi does not support carry.  */
+        case R_M68HC11_HI8:
+        case R_M68HC11_LO8:
+          relocation = phys_addr;
+          break;
+
         case R_M68HC11_24:
           /* Reloc used by 68HC12 call instruction.  */
           bfd_put_16 (input_bfd, phys_addr,
@@ -1051,7 +1115,7 @@
                       "relocation may result in incorrect execution");
               buf = alloca (strlen (msg) + strlen (name) + 10);
               sprintf (buf, msg, name);
-              
+
               (* info->callbacks->warning)
                 (info, buf, name, input_bfd, NULL, rel->r_offset);
             }
@@ -1063,12 +1127,45 @@
 
           insn_page = m68hc11_phys_page (pinfo, insn_addr);
 
+         /* If we are linking an S12 instruction against an XGATE symbol, we
+            need to change the offset of the symbol value so that it's correct
+	    from the S12's perspective.  */
+          if (is_xgate_symbol)
+	    {
+	      /* The ram in the global space is mapped to 0x2000 in the 16-bit
+		 address space for S12 and 0xE000 in the 16-bit address space
+		 for XGATE.  */
+	      if (relocation >= 0xE000)
+		{
+		  /* We offset the address by the difference
+		     between these two mappings.  */
+		  relocation -= 0xC000;
+		  break;
+		}
+	      else
+		{
+		  const char * msg;
+		  char * buf;
+
+		  msg = _("XGATE address (%lx) is not within shared RAM"
+			  "(0xE000-0xFFFF), therefore you must manually offset "
+			  "the address, and possibly manage the page, in your "
+			  "code.");
+		  buf = alloca (strlen (msg) + 128);
+		  sprintf (buf, msg, phys_addr);
+		  if (!((*info->callbacks->warning) (info, buf, name, input_bfd,
+						     input_section, insn_addr)))
+		    return FALSE;
+		  break;
+		}
+	    }
+
           if (m68hc11_addr_is_banked (pinfo, relocation + rel->r_addend)
               && m68hc11_addr_is_banked (pinfo, insn_addr)
-              && phys_page != insn_page)
+              && phys_page != insn_page && !(e_flags & E_M68HC11_NO_BANK_WARNING))
             {
-              const char* msg;
-              char* buf;
+              const char * msg;
+              char * buf;
 
               msg = _("banked address [%lx:%04lx] (%lx) is not in the same bank "
                       "as current banked address [%lx:%04lx] (%lx)");
@@ -1084,10 +1181,11 @@
                 return FALSE;
               break;
             }
+
           if (phys_page != 0 && insn_page == 0)
             {
-              const char* msg;
-              char* buf;
+              const char * msg;
+              char * buf;
 
               msg = _("reference to a banked address [%lx:%04lx] in the "
                       "normal address space at %04lx");
@@ -1109,10 +1207,57 @@
             relocation = phys_addr;
           break;
         }
+
+      /* If we are linking an XGATE instruction against an S12 symbol, we
+         need to change the offset of the symbol value so that it's correct
+	 from the XGATE's perspective.  */
+      if (!strcmp (howto->name, "R_XGATE_IMM8_LO")
+          || !strcmp (howto->name, "R_XGATE_IMM8_HI"))
+        {
+          /* We can only offset S12 addresses that lie within the non-paged
+             area of RAM.  */
+          if (!is_xgate_symbol && !is_section_symbol)
+            {
+              /* The ram in the global space is mapped to 0x2000 and stops at
+                 0x4000 in the 16-bit address space for S12 and 0xE000 in the
+                 16-bit address space for XGATE.  */
+              if (relocation >= 0x2000 && relocation < 0x4000)
+                 /* We offset the address by the difference
+                   between these two mappings.  */
+                relocation += 0xC000;
+              else
+                {
+                  const char * msg;
+                  char * buf;
+
+                  /* Get virtual address of instruction having the relocation.  */
+                  insn_addr = input_section->output_section->vma
+                      + input_section->output_offset + rel->r_offset;
+
+                  msg = _("S12 address (%lx) is not within shared RAM"
+                      "(0x2000-0x4000), therefore you must manually "
+                      "offset the address in your code");
+                  buf = alloca (strlen (msg) + 128);
+                  sprintf (buf, msg, phys_addr);
+                  if (!((*info->callbacks->warning) (info, buf, name, input_bfd,
+						     input_section, insn_addr)))
+                    return FALSE;
+                  break;
+                }
+            }
+        }
+
       if (r_type != R_M68HC11_NONE)
-        r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+        {
+          if ((r_type == R_M68HC12_PCREL_9) || (r_type == R_M68HC12_PCREL_10))
+            r = _bfd_final_link_relocate (howto, input_bfd, input_section,
                                       contents, rel->r_offset,
-                                      relocation, rel->r_addend);
+                                      relocation - 2, rel->r_addend);
+          else
+            r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+                                          contents, rel->r_offset,
+                                          relocation, rel->r_addend);
+        }
 
       if (r != bfd_reloc_ok)
 	{
@@ -1296,13 +1441,16 @@
   else if (elf_elfheader (abfd)->e_flags & EF_M68HCS12_MACH)
     fprintf (file, _("cpu=HCS12]"));
   else
-    fprintf (file, _("cpu=HC12]"));    
+    fprintf (file, _("cpu=HC12]"));
 
   if (elf_elfheader (abfd)->e_flags & E_M68HC12_BANKS)
     fprintf (file, _(" [memory=bank-model]"));
   else
     fprintf (file, _(" [memory=flat]"));
 
+  if (elf_elfheader (abfd)->e_flags & E_M68HC11_XGATE_RAMOFFSET)
+    fprintf (file, _(" [XGATE RAM offsetting]"));
+
   fputc ('\n', file);
 
   return TRUE;
@@ -1316,7 +1464,7 @@
   if (asect->vma >= p->pinfo->bank_virtual)
     p->use_memory_banks = TRUE;
 }
-  
+
 /* Tweak the OSABI field of the elf header.  */
 
 void
diff --git a/bfd/elf32-m68hc1x.h b/bfd/elf32-m68hc1x.h
index 317371f..34b788e 100644
--- a/bfd/elf32-m68hc1x.h
+++ b/bfd/elf32-m68hc1x.h
@@ -1,5 +1,5 @@
 /* Motorola 68HC11/68HC12-specific support for 32-bit ELF
-   Copyright 2003, 2004, 2005, 2006, 2007, 2009, 2010
+   Copyright 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2012
    Free Software Foundation, Inc.
    Contributed by Stephane Carrez ([email protected])
 
@@ -176,6 +176,10 @@
    flagword *flagsp, asection **secp,
    bfd_vma *valp);
 
+void elf32_m68hc11_merge_symbol_attribute
+  (struct elf_link_hash_entry *, const Elf_Internal_Sym *,
+   bfd_boolean, bfd_boolean);
+
 /* Tweak the OSABI field of the elf header.  */
 
 extern void elf32_m68hc11_post_process_headers (bfd*, struct bfd_link_info*);
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c
index 612525c..b72bc83 100644
--- a/bfd/elf32-m68k.c
+++ b/bfd/elf32-m68k.c
@@ -1,6 +1,6 @@
 /* Motorola 68k series support for 32-bit ELF
    Copyright 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -28,42 +28,11 @@
 #include "elf/m68k.h"
 #include "opcode/m68k.h"
 
-static reloc_howto_type *reloc_type_lookup
-  PARAMS ((bfd *, bfd_reloc_code_real_type));
-static void rtype_to_howto
-  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
-static struct bfd_hash_entry *elf_m68k_link_hash_newfunc
-  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static struct bfd_link_hash_table *elf_m68k_link_hash_table_create
-  PARAMS ((bfd *));
-static bfd_boolean elf_m68k_check_relocs
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-	   const Elf_Internal_Rela *));
-static bfd_boolean elf_m68k_adjust_dynamic_symbol
-  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
-static bfd_boolean elf_m68k_size_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-static bfd_boolean elf_m68k_discard_copies
-  PARAMS ((struct elf_link_hash_entry *, PTR));
-static bfd_boolean elf_m68k_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
-	   Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
-static bfd_boolean elf_m68k_finish_dynamic_symbol
-  PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
-	   Elf_Internal_Sym *));
-static bfd_boolean elf_m68k_finish_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
+static bfd_boolean
+elf_m68k_discard_copies (struct elf_link_hash_entry *, void *);
 
-static bfd_boolean elf32_m68k_set_private_flags
-  PARAMS ((bfd *, flagword));
-static bfd_boolean elf32_m68k_merge_private_bfd_data
-  PARAMS ((bfd *, bfd *));
-static bfd_boolean elf32_m68k_print_private_bfd_data
-  PARAMS ((bfd *, PTR));
-static enum elf_reloc_type_class elf32_m68k_reloc_type_class
-  PARAMS ((const Elf_Internal_Rela *));
-
-static reloc_howto_type howto_table[] = {
+static reloc_howto_type howto_table[] =
+{
   HOWTO(R_68K_NONE,       0, 0, 0, FALSE,0, complain_overflow_dont,     bfd_elf_generic_reloc, "R_68K_NONE",      FALSE, 0, 0x00000000,FALSE),
   HOWTO(R_68K_32,         0, 2,32, FALSE,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_32",        FALSE, 0, 0xffffffff,FALSE),
   HOWTO(R_68K_16,         0, 1,16, FALSE,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_16",        FALSE, 0, 0x0000ffff,FALSE),
@@ -441,9 +410,8 @@
 };
 
 static reloc_howto_type *
-reloc_type_lookup (abfd, code)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+		   bfd_reloc_code_real_type code)
 {
   unsigned int i;
   for (i = 0; i < sizeof (reloc_map) / sizeof (reloc_map[0]); i++)
@@ -982,7 +950,7 @@
   struct elf_m68k_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_m68k_link_hash_table);
 
-  ret = (struct elf_m68k_link_hash_table *) bfd_malloc (amt);
+  ret = (struct elf_m68k_link_hash_table *) bfd_zmalloc (amt);
   if (ret == (struct elf_m68k_link_hash_table *) NULL)
     return NULL;
 
@@ -995,12 +963,6 @@
       return NULL;
     }
 
-  ret->sym_cache.abfd = NULL;
-  ret->plt_info = NULL;
-  ret->local_gp_p = FALSE;
-  ret->use_neg_got_offsets_p = FALSE;
-  ret->allow_multigot_p = FALSE;
-  ret->multi_got_.bfd2got = NULL;
   ret->multi_got_.global_symndx = 1;
 
   return &ret->root.root;
@@ -1020,6 +982,7 @@
       htab_delete (htab->multi_got_.bfd2got);
       htab->multi_got_.bfd2got = NULL;
     }
+  _bfd_elf_link_hash_table_free (_htab);
 }
 
 /* Set the right machine number.  */
@@ -1145,9 +1108,7 @@
 /* Keep m68k-specific flags in the ELF header.  */
 
 static bfd_boolean
-elf32_m68k_set_private_flags (abfd, flags)
-     bfd *abfd;
-     flagword flags;
+elf32_m68k_set_private_flags (bfd *abfd, flagword flags)
 {
   elf_elfheader (abfd)->e_flags = flags;
   elf_flags_init (abfd) = TRUE;
@@ -1157,9 +1118,7 @@
 /* Merge backend specific data from an object file to the output
    object file when linking.  */
 static bfd_boolean
-elf32_m68k_merge_private_bfd_data (ibfd, obfd)
-     bfd *ibfd;
-     bfd *obfd;
+elf32_m68k_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
 {
   flagword out_flags;
   flagword in_flags;
@@ -2468,7 +2427,7 @@
     {
       asection *s;
 
-      s = bfd_get_section_by_name (elf_hash_table (info)->dynobj, ".got");
+      s = bfd_get_linker_section (elf_hash_table (info)->dynobj, ".got");
       if (s != NULL)
 	s->size = arg_.offset;
       else
@@ -2477,7 +2436,7 @@
       BFD_ASSERT (arg_.slots_relas_diff <= arg_.n_slots);
       arg_.n_slots -= arg_.slots_relas_diff;
 
-      s = bfd_get_section_by_name (elf_hash_table (info)->dynobj, ".rela.got");
+      s = bfd_get_linker_section (elf_hash_table (info)->dynobj, ".rela.got");
       if (s != NULL)
 	s->size = arg_.n_slots * sizeof (Elf32_External_Rela);
       else
@@ -2581,11 +2540,10 @@
    table.  */
 
 static bfd_boolean
-elf_m68k_check_relocs (abfd, info, sec, relocs)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     asection *sec;
-     const Elf_Internal_Rela *relocs;
+elf_m68k_check_relocs (bfd *abfd,
+		       struct bfd_link_info *info,
+		       asection *sec,
+		       const Elf_Internal_Rela *relocs)
 {
   bfd *dynobj;
   Elf_Internal_Shdr *symtab_hdr;
@@ -2626,6 +2584,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       switch (ELF32_R_TYPE (rel->r_info))
@@ -2675,24 +2637,22 @@
 
 	  if (sgot == NULL)
 	    {
-	      sgot = bfd_get_section_by_name (dynobj, ".got");
+	      sgot = bfd_get_linker_section (dynobj, ".got");
 	      BFD_ASSERT (sgot != NULL);
 	    }
 
 	  if (srelgot == NULL
 	      && (h != NULL || info->shared))
 	    {
-	      srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+	      srelgot = bfd_get_linker_section (dynobj, ".rela.got");
 	      if (srelgot == NULL)
 		{
-		  srelgot = bfd_make_section_with_flags (dynobj,
-							 ".rela.got",
-							 (SEC_ALLOC
-							  | SEC_LOAD
-							  | SEC_HAS_CONTENTS
-							  | SEC_IN_MEMORY
-							  | SEC_LINKER_CREATED
-							  | SEC_READONLY));
+		  flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+				    | SEC_IN_MEMORY | SEC_LINKER_CREATED
+				    | SEC_READONLY);
+		  srelgot = bfd_make_section_anyway_with_flags (dynobj,
+								".rela.got",
+								flags);
 		  if (srelgot == NULL
 		      || !bfd_set_section_alignment (dynobj, srelgot, 2))
 		    return FALSE;
@@ -2816,21 +2776,25 @@
 	case R_68K_8:
 	case R_68K_16:
 	case R_68K_32:
+	  /* We don't need to handle relocs into sections not going into
+	     the "real" output.  */
+	  if ((sec->flags & SEC_ALLOC) == 0)
+	      break;
+
 	  if (h != NULL)
 	    {
 	      /* Make sure a plt entry is created for this symbol if it
 		 turns out to be a function defined by a dynamic object.  */
 	      h->plt.refcount++;
 
-	      if (!info->shared)
+	      if (info->executable)
 		/* This symbol needs a non-GOT reference.  */
 		h->non_got_ref = 1;
 	    }
 
 	  /* If we are creating a shared library, we need to copy the
 	     reloc into the shared library.  */
-	  if (info->shared
-	      && (sec->flags & SEC_ALLOC) != 0)
+	  if (info->shared)
 	    {
 	      /* When creating a shared object, we must copy these
 		 reloc types into the output file.  We create a reloc
@@ -3126,9 +3090,8 @@
    understand.  */
 
 static bfd_boolean
-elf_m68k_adjust_dynamic_symbol (info, h)
-     struct bfd_link_info *info;
-     struct elf_link_hash_entry *h;
+elf_m68k_adjust_dynamic_symbol (struct bfd_link_info *info,
+				struct elf_link_hash_entry *h)
 {
   struct elf_m68k_link_hash_table *htab;
   bfd *dynobj;
@@ -3178,7 +3141,7 @@
 	    return FALSE;
 	}
 
-      s = bfd_get_section_by_name (dynobj, ".plt");
+      s = bfd_get_linker_section (dynobj, ".plt");
       BFD_ASSERT (s != NULL);
 
       /* If this is the first .plt entry, make room for the special
@@ -3205,12 +3168,12 @@
 
       /* We also need to make an entry in the .got.plt section, which
 	 will be placed in the .got section by the linker script.  */
-      s = bfd_get_section_by_name (dynobj, ".got.plt");
+      s = bfd_get_linker_section (dynobj, ".got.plt");
       BFD_ASSERT (s != NULL);
       s->size += 4;
 
       /* We also need to make an entry in the .rela.plt section.  */
-      s = bfd_get_section_by_name (dynobj, ".rela.plt");
+      s = bfd_get_linker_section (dynobj, ".rela.plt");
       BFD_ASSERT (s != NULL);
       s->size += sizeof (Elf32_External_Rela);
 
@@ -3248,13 +3211,6 @@
   if (!h->non_got_ref)
     return TRUE;
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-			     h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -3265,18 +3221,18 @@
      both the dynamic object and the regular object will refer to the
      same memory location for the variable.  */
 
-  s = bfd_get_section_by_name (dynobj, ".dynbss");
+  s = bfd_get_linker_section (dynobj, ".dynbss");
   BFD_ASSERT (s != NULL);
 
   /* We must generate a R_68K_COPY reloc to tell the dynamic linker to
      copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rela.bss section we are going to use.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       asection *srel;
 
-      srel = bfd_get_section_by_name (dynobj, ".rela.bss");
+      srel = bfd_get_linker_section (dynobj, ".rela.bss");
       BFD_ASSERT (srel != NULL);
       srel->size += sizeof (Elf32_External_Rela);
       h->needs_copy = 1;
@@ -3288,9 +3244,8 @@
 /* Set the sizes of the dynamic sections.  */
 
 static bfd_boolean
-elf_m68k_size_dynamic_sections (output_bfd, info)
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info;
+elf_m68k_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
+				struct bfd_link_info *info)
 {
   bfd *dynobj;
   asection *s;
@@ -3305,7 +3260,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
@@ -3318,7 +3273,7 @@
 	 not actually use these entries.  Reset the size of .rela.got,
 	 which will cause it to get stripped from the output file
 	 below.  */
-      s = bfd_get_section_by_name (dynobj, ".rela.got");
+      s = bfd_get_linker_section (dynobj, ".rela.got");
       if (s != NULL)
 	s->size = 0;
     }
@@ -3332,7 +3287,7 @@
   if (info->shared)
     elf_link_hash_traverse (elf_hash_table (info),
 			    elf_m68k_discard_copies,
-			    (PTR) info);
+			    info);
 
   /* The check_relocs and adjust_dynamic_symbol entry points have
      determined the sizes of the various dynamic sections.  Allocate
@@ -3460,9 +3415,8 @@
    case.  */
 
 static bfd_boolean
-elf_m68k_discard_copies (h, inf)
-     struct elf_link_hash_entry *h;
-     PTR inf;
+elf_m68k_discard_copies (struct elf_link_hash_entry *h,
+			 void * inf)
 {
   struct bfd_link_info *info = (struct bfd_link_info *) inf;
   struct elf_m68k_pcrel_relocs_copied *s;
@@ -3482,6 +3436,18 @@
 	      }
 	}
 
+      /* Make sure undefined weak symbols are output as a dynamic symbol
+	 in PIEs.  */
+      if (h->non_got_ref
+	  && h->root.type == bfd_link_hash_undefweak
+	  && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+	  && h->dynindx == -1
+	  && !h->forced_local)
+	{
+	  if (! bfd_elf_link_record_dynamic_symbol (info, h))
+	    return FALSE;
+	}
+
       return TRUE;
     }
 
@@ -3635,16 +3601,14 @@
 /* Relocate an M68K ELF section.  */
 
 static bfd_boolean
-elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
-			   contents, relocs, local_syms, local_sections)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     Elf_Internal_Rela *relocs;
-     Elf_Internal_Sym *local_syms;
-     asection **local_sections;
+elf_m68k_relocate_section (bfd *output_bfd,
+			   struct bfd_link_info *info,
+			   bfd *input_bfd,
+			   asection *input_section,
+			   bfd_byte *contents,
+			   Elf_Internal_Rela *relocs,
+			   Elf_Internal_Sym *local_syms,
+			   asection **local_sections)
 {
   bfd *dynobj;
   Elf_Internal_Shdr *symtab_hdr;
@@ -3713,9 +3677,9 @@
 				   unresolved_reloc, warned);
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -3737,7 +3701,7 @@
 
 		  if (sgot == NULL)
 		    {
-		      sgot = bfd_get_section_by_name (dynobj, ".got");
+		      sgot = bfd_get_linker_section (dynobj, ".got");
 
 		      if (sgot != NULL)
 			sgot_output_offset = sgot->output_offset;
@@ -3812,7 +3776,7 @@
 
 	    if (sgot == NULL)
 	      {
-		sgot = bfd_get_section_by_name (dynobj, ".got");
+		sgot = bfd_get_linker_section (dynobj, ".got");
 		BFD_ASSERT (sgot != NULL);
 	      }
 
@@ -3883,7 +3847,7 @@
 		  {
 		    if (srela == NULL)
 		      {
-			srela = bfd_get_section_by_name (dynobj, ".rela.got");
+			srela = bfd_get_linker_section (dynobj, ".rela.got");
 			BFD_ASSERT (srela != NULL);
 		      }
 
@@ -3951,7 +3915,7 @@
 	case R_68K_TLS_LE32:
 	case R_68K_TLS_LE16:
 	case R_68K_TLS_LE8:
-	  if (info->shared)
+	  if (info->shared && !info->pie)
 	    {
 	      (*_bfd_error_handler)
 		(_("%B(%A+0x%lx): R_68K_TLS_LE32 relocation not permitted "
@@ -3987,7 +3951,7 @@
 
 	  if (splt == NULL)
 	    {
-	      splt = bfd_get_section_by_name (dynobj, ".plt");
+	      splt = bfd_get_linker_section (dynobj, ".plt");
 	      BFD_ASSERT (splt != NULL);
 	    }
 
@@ -4006,7 +3970,7 @@
 
 	  if (splt == NULL)
 	    {
-	      splt = bfd_get_section_by_name (dynobj, ".plt");
+	      splt = bfd_get_linker_section (dynobj, ".plt");
 	      BFD_ASSERT (splt != NULL);
 	    }
 
@@ -4148,7 +4112,9 @@
 	 not process them.  */
       if (unresolved_reloc
 	  && !((input_section->flags & SEC_DEBUGGING) != 0
-	       && h->def_dynamic))
+	       && h->def_dynamic)
+	  && _bfd_elf_section_offset (output_bfd, info, input_section,
+				      rel->r_offset) != (bfd_vma) -1)
 	{
 	  (*_bfd_error_handler)
 	    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
@@ -4258,11 +4224,10 @@
    dynamic sections here.  */
 
 static bfd_boolean
-elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-     struct elf_link_hash_entry *h;
-     Elf_Internal_Sym *sym;
+elf_m68k_finish_dynamic_symbol (bfd *output_bfd,
+				struct bfd_link_info *info,
+				struct elf_link_hash_entry *h,
+				Elf_Internal_Sym *sym)
 {
   bfd *dynobj;
 
@@ -4285,9 +4250,9 @@
       BFD_ASSERT (h->dynindx != -1);
 
       plt_info = elf_m68k_hash_table (info)->plt_info;
-      splt = bfd_get_section_by_name (dynobj, ".plt");
-      sgot = bfd_get_section_by_name (dynobj, ".got.plt");
-      srela = bfd_get_section_by_name (dynobj, ".rela.plt");
+      splt = bfd_get_linker_section (dynobj, ".plt");
+      sgot = bfd_get_linker_section (dynobj, ".got.plt");
+      srela = bfd_get_linker_section (dynobj, ".rela.plt");
       BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL);
 
       /* Get the index in the procedure linkage table which
@@ -4352,8 +4317,8 @@
       /* This symbol has an entry in the global offset table.  Set it
 	 up.  */
 
-      sgot = bfd_get_section_by_name (dynobj, ".got");
-      srela = bfd_get_section_by_name (dynobj, ".rela.got");
+      sgot = bfd_get_linker_section (dynobj, ".got");
+      srela = bfd_get_linker_section (dynobj, ".rela.got");
       BFD_ASSERT (sgot != NULL && srela != NULL);
 
       got_entry = elf_m68k_hash_entry (h)->glist;
@@ -4476,8 +4441,7 @@
 		  && (h->root.type == bfd_link_hash_defined
 		      || h->root.type == bfd_link_hash_defweak));
 
-      s = bfd_get_section_by_name (h->root.u.def.section->owner,
-				   ".rela.bss");
+      s = bfd_get_linker_section (dynobj, ".rela.bss");
       BFD_ASSERT (s != NULL);
 
       rela.r_offset = (h->root.u.def.value
@@ -4489,20 +4453,13 @@
       bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
     }
 
-  /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
-      || h == elf_hash_table (info)->hgot)
-    sym->st_shndx = SHN_ABS;
-
   return TRUE;
 }
 
 /* Finish up the dynamic sections.  */
 
 static bfd_boolean
-elf_m68k_finish_dynamic_sections (output_bfd, info)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
+elf_m68k_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
 {
   bfd *dynobj;
   asection *sgot;
@@ -4510,16 +4467,16 @@
 
   dynobj = elf_hash_table (info)->dynobj;
 
-  sgot = bfd_get_section_by_name (dynobj, ".got.plt");
+  sgot = bfd_get_linker_section (dynobj, ".got.plt");
   BFD_ASSERT (sgot != NULL);
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       asection *splt;
       Elf32_External_Dyn *dyncon, *dynconend;
 
-      splt = bfd_get_section_by_name (dynobj, ".plt");
+      splt = bfd_get_linker_section (dynobj, ".plt");
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       dyncon = (Elf32_External_Dyn *) sdyn->contents;
@@ -4646,7 +4603,7 @@
 
   /* Get a copy of the native relocations.  */
   internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, datasec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+		     (abfd, datasec, NULL, (Elf_Internal_Rela *) NULL,
 		      info->keep_memory));
   if (internal_relocs == NULL)
     goto error_return;
@@ -4784,8 +4741,9 @@
 }
 
 static enum elf_reloc_type_class
-elf32_m68k_reloc_type_class (rela)
-     const Elf_Internal_Rela *rela;
+elf32_m68k_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			     const asection *rel_sec ATTRIBUTE_UNUSED,
+			     const Elf_Internal_Rela *rela)
 {
   switch ((int) ELF32_R_TYPE (rela->r_info))
     {
@@ -4810,6 +4768,69 @@
   return plt->vma + (i + 1) * elf_m68k_get_plt_info (plt->owner)->size;
 }
 
+/* Support for core dump NOTE sections.  */
+
+static bfd_boolean
+elf_m68k_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
+{
+  int offset;
+  size_t size;
+
+  switch (note->descsz)
+    {
+    default:
+      return FALSE;
+
+    case 154:		/* Linux/m68k */
+      /* pr_cursig */
+      elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
+
+      /* pr_pid */
+      elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 22);
+
+      /* pr_reg */
+      offset = 70;
+      size = 80;
+
+      break;
+    }
+
+  /* Make a ".reg/999" section.  */
+  return _bfd_elfcore_make_pseudosection (abfd, ".reg",
+					  size, note->descpos + offset);
+}
+
+static bfd_boolean
+elf_m68k_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
+{
+  switch (note->descsz)
+    {
+    default:
+      return FALSE;
+
+    case 124:		/* Linux/m68k elf_prpsinfo.  */
+      elf_tdata (abfd)->core->pid
+	= bfd_get_32 (abfd, note->descdata + 12);
+      elf_tdata (abfd)->core->program
+	= _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
+      elf_tdata (abfd)->core->command
+	= _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
+    }
+
+  /* Note that for some reason, a spurious space is tacked
+     onto the end of the args in some (at least one anyway)
+     implementations, so strip it off if it exists.  */
+  {
+    char *command = elf_tdata (abfd)->core->command;
+    int n = strlen (command);
+
+    if (n > 0 && command[n - 1] == ' ')
+      command[n - 1] = '\0';
+  }
+
+  return TRUE;
+}
+
 #define TARGET_BIG_SYM			bfd_elf32_m68k_vec
 #define TARGET_BIG_NAME			"elf32-m68k"
 #define ELF_MACHINE_CODE		EM_68K
@@ -4849,6 +4870,8 @@
 #define elf_backend_reloc_type_class	elf32_m68k_reloc_type_class
 #define elf_backend_plt_sym_val		elf_m68k_plt_sym_val
 #define elf_backend_object_p		elf32_m68k_object_p
+#define elf_backend_grok_prstatus	elf_m68k_grok_prstatus
+#define elf_backend_grok_psinfo		elf_m68k_grok_psinfo
 
 #define elf_backend_can_gc_sections 1
 #define elf_backend_can_refcount 1
diff --git a/bfd/elf32-mcore.c b/bfd/elf32-mcore.c
index 31cc095..28ee2c4 100644
--- a/bfd/elf32-mcore.c
+++ b/bfd/elf32-mcore.c
@@ -1,6 +1,6 @@
 /* Motorola MCore specific support for 32-bit ELF
    Copyright 1994, 1995, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007, 2011 Free Software Foundation, Inc.
+   2007, 2011, 2012 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -89,7 +89,7 @@
 mcore_elf_unsupported_reloc (bfd * abfd,
 			     arelent * reloc_entry,
 			     asymbol * symbol ATTRIBUTE_UNUSED,
-			     PTR data ATTRIBUTE_UNUSED,
+			     void * data ATTRIBUTE_UNUSED,
 			     asection * input_section ATTRIBUTE_UNUSED,
 			     bfd * output_bfd ATTRIBUTE_UNUSED,
 			     char ** error_message ATTRIBUTE_UNUSED)
@@ -466,9 +466,9 @@
 				   unresolved_reloc, warned);
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -613,6 +613,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       switch (ELF32_R_TYPE (rel->r_info))
diff --git a/bfd/elf32-mep.c b/bfd/elf32-mep.c
index 6fecb25..f356fd0 100644
--- a/bfd/elf32-mep.c
+++ b/bfd/elf32-mep.c
@@ -1,6 +1,6 @@
 /* MeP-specific support for 32-bit ELF.
    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-   2010, 2011  Free Software Foundation, Inc.
+   2010, 2011, 2012 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -500,9 +500,9 @@
 	  name = h->root.root.string;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
diff --git a/bfd/elf32-metag.c b/bfd/elf32-metag.c
new file mode 100644
index 0000000..8851845
--- /dev/null
+++ b/bfd/elf32-metag.c
@@ -0,0 +1,4325 @@
+/* Meta support for 32-bit ELF
+   Copyright (C) 2013 Free Software Foundation, Inc.
+   Contributed by Imagination Technologies Ltd.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf32-metag.h"
+#include "elf/metag.h"
+
+#define GOT_ENTRY_SIZE 4
+#define ELF_DYNAMIC_INTERPRETER "/lib/ld-uClibc.so.0"
+
+/* ABI version:
+    0 - original
+    1 - with GOT offset */
+#define METAG_ELF_ABI_VERSION 1
+
+static const unsigned int plt0_entry[] =
+  {
+    0x02000005, /* MOVT D0Re0, #HI(GOT+4) */
+    0x02000000, /* ADD  D0Re0, D0Re0, #LO(GOT+4) */
+    0xb70001e3, /* SETL [A0StP++], D0Re0, D1Re0 */
+    0xc600012a, /* GETD PC, [D0Re0+#4] */
+    0xa0fffffe  /* NOP */
+  };
+
+static const unsigned int plt0_pic_entry[] =
+  {
+    0x82900001, /* ADDT A0.2, CPC0, #0 */
+    0x82100000, /* ADD  A0.2, A0.2, #0 */
+    0xa3100c20, /* MOV  D0Re0, A0.2 */
+    0xb70001e3, /* SETL [A0StP++], D0Re0, D1Re0 */
+    0xc600012a, /* GETD PC, [D0Re0+#4] */
+  };
+
+static const unsigned int plt_entry[] =
+  {
+    0x82100005, /* MOVT A0.2, #HI(GOT+off) */
+    0x82100000, /* ADD  A0.2, A0.2, #LO(GOT+off) */
+    0xc600806a, /* GETD PC, [A0.2] */
+    0x03000004, /* MOV  D1Re0, #LO(offset) */
+    0xa0000000  /* B    PLT0 */
+  };
+
+static const unsigned int plt_pic_entry[] =
+  {
+    0x82900001, /* ADDT A0.2, CPC0, #HI(GOT+off) */
+    0x82100000, /* ADD  A0.2, A0.2, #LO(GOT+off) */
+    0xc600806a, /* GETD PC, [A0.2] */
+    0x03000004, /* MOV  D1Re0, #LO(offset) */
+    0xa0000000  /* B    PLT0 */
+  };
+
+/* Variable names follow a coding style.
+   Please follow this (Apps Hungarian) style:
+
+   Structure/Variable              Prefix
+   elf_link_hash_table             "etab"
+   elf_link_hash_entry             "eh"
+
+   elf_metag_link_hash_table       "htab"
+   elf_metag_link_hash_entry       "hh"
+
+   bfd_link_hash_table             "btab"
+   bfd_link_hash_entry             "bh"
+
+   bfd_hash_table containing stubs "bstab"
+   elf_metag_stub_hash_entry       "hsh"
+
+   elf_metag_dyn_reloc_entry       "hdh"
+
+   Always remember to use GNU Coding Style.  */
+
+#define PLT_ENTRY_SIZE sizeof(plt_entry)
+
+static reloc_howto_type elf_metag_howto_table[] =
+{
+  /* High order 16 bit absolute.  */
+  HOWTO (R_METAG_HIADDR16,	/* type */
+	 16,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 3,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_HIADDR16",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0007fff8,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Low order 16 bit absolute.  */
+  HOWTO (R_METAG_LOADDR16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 3,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_LOADDR16",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0007fff8,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* 32 bit absolute.  */
+  HOWTO (R_METAG_ADDR32,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_ADDR32",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x00000000,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* No relocation.  */
+  HOWTO (R_METAG_NONE,		/* type */
+	 0,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 0,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_NONE",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* 19 bit pc relative */
+  HOWTO (R_METAG_RELBRANCH,	/* type */
+	 2,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 19,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 5,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_RELBRANCH",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x00ffffe0,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* GET/SET offset */
+  HOWTO (R_METAG_GETSETOFF,	/* type */
+	 0,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 7,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_GETSETOFF",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  EMPTY_HOWTO (6),
+  EMPTY_HOWTO (7),
+  EMPTY_HOWTO (8),
+  EMPTY_HOWTO (9),
+  EMPTY_HOWTO (10),
+  EMPTY_HOWTO (11),
+  EMPTY_HOWTO (12),
+  EMPTY_HOWTO (13),
+  EMPTY_HOWTO (14),
+  EMPTY_HOWTO (15),
+  EMPTY_HOWTO (16),
+  EMPTY_HOWTO (17),
+  EMPTY_HOWTO (18),
+  EMPTY_HOWTO (19),
+  EMPTY_HOWTO (20),
+  EMPTY_HOWTO (21),
+  EMPTY_HOWTO (22),
+  EMPTY_HOWTO (23),
+  EMPTY_HOWTO (24),
+  EMPTY_HOWTO (25),
+  EMPTY_HOWTO (26),
+  EMPTY_HOWTO (27),
+  EMPTY_HOWTO (28),
+  EMPTY_HOWTO (29),
+
+  HOWTO (R_METAG_GNU_VTINHERIT, /* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 0,			/* bitsize */
+	 FALSE,		/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 NULL,			/* special_function */
+	 "R_METAG_GNU_VTINHERIT", /* name */
+	 FALSE,		/* partial_inplace */
+	 0,			/* src_mask */
+	 0,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_METAG_GNU_VTENTRY,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 0,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 _bfd_elf_rel_vtable_reloc_fn, /* special_function */
+	 "R_METAG_GNU_VTENTRY",  /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* High order 16 bit GOT offset */
+  HOWTO (R_METAG_HI16_GOTOFF,	/* type */
+	 16,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 3,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_HI16_GOTOFF", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0007fff8,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Low order 16 bit GOT offset */
+  HOWTO (R_METAG_LO16_GOTOFF,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 3,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_LO16_GOTOFF", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0007fff8,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* GET/SET GOT offset */
+  HOWTO (R_METAG_GETSET_GOTOFF, /* type */
+	 0,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 7,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_GETSET_GOTOFF", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* GET/SET GOT relative */
+  HOWTO (R_METAG_GETSET_GOT,	/* type */
+	 0,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 7,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_GETSET_GOT",  /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* High order 16 bit GOT reference */
+  HOWTO (R_METAG_HI16_GOTPC,	/* type */
+	 16,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 3,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_HI16_GOTPC",  /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0007fff8,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Low order 16 bit GOT reference */
+  HOWTO (R_METAG_LO16_GOTPC,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 3,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_LO16_GOTPC",  /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0007fff8,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* High order 16 bit PLT */
+  HOWTO (R_METAG_HI16_PLT,	/* type */
+	 16,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 3,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_HI16_PLT",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0007fff8,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Low order 16 bit PLT */
+  HOWTO (R_METAG_LO16_PLT,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 3,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_LO16_PLT",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_METAG_RELBRANCH_PLT, /* type */
+	 2,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 19,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 5,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_RELBRANCH_PLT", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x00ffffe0,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Dummy relocs used by the linker internally.  */
+  HOWTO (R_METAG_GOTOFF,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_GOTOFF",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_METAG_PLT,		/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_GOTOFF",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* This is used only by the dynamic linker.  The symbol should exist
+     both in the object being run and in some shared library.  The
+     dynamic linker copies the data addressed by the symbol from the
+     shared library into the object, because the object being
+     run has to have the data at some particular address.  */
+  HOWTO (R_METAG_COPY,		/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_COPY",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Marks a procedure linkage table entry for a symbol.  */
+  HOWTO (R_METAG_JMP_SLOT,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_JMP_SLOT",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Used only by the dynamic linker.  When the object is run, this
+     longword is set to the load address of the object, plus the
+     addend.  */
+  HOWTO (R_METAG_RELATIVE,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_RELATIVE",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_METAG_GLOB_DAT,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_GLOB_DAT",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_METAG_TLS_GD,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 3,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_TLS_GD",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0007fff8,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_METAG_TLS_LDM,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 3,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_TLS_LDM",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0007fff8,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_METAG_TLS_LDO_HI16,	/* type */
+	 16,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 3,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_TLS_LDO_HI16", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0007fff8,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_METAG_TLS_LDO_LO16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 3,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_TLS_LDO_LO16", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0007fff8,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Dummy reloc used by the linker internally.  */
+  HOWTO (R_METAG_TLS_LDO,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 3,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_TLS_LDO",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0007fff8,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_METAG_TLS_IE,	/* type */
+	 2,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 7,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_TLS_IE",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0007ff80,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Dummy reloc used by the linker internally.  */
+  HOWTO (R_METAG_TLS_IENONPIC,  /* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 3,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_TLS_IENONPIC", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0007fff8,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_METAG_TLS_IENONPIC_HI16,/* type */
+	 16,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 3,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_TLS_IENONPIC_HI16", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0007fff8,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_METAG_TLS_IENONPIC_LO16,/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 3,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_TLS_IENONPIC_LO16", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0007fff8,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_METAG_TLS_TPOFF,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_TLS_TPOFF",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_METAG_TLS_DTPMOD,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_TLS_DTPMOD",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_METAG_TLS_DTPOFF,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_TLS_DTPOFF",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Dummy reloc used by the linker internally.  */
+  HOWTO (R_METAG_TLS_LE,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_TLS_LE",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_METAG_TLS_LE_HI16,	/* type */
+	 16,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 3,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_TLS_LE_HI16", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0007fff8,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_METAG_TLS_LE_LO16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 3,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_METAG_TLS_LE_LO16", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0007fff8,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+};
+
+#define BRANCH_BITS 19
+
+/* The GOT is typically accessed using a [GS]ETD instruction. The size of the
+   immediate offset which can be used in such instructions therefore limits
+   the usable size of the GOT. If the base register for the [GS]ETD (A1LbP)
+   is pointing to the base of the GOT then the size is limited to the maximum
+   11 bits unsigned dword offset, or 2^13 = 0x2000 bytes. However the offset
+   in a [GS]ETD instruction is signed, so by setting the base address register
+   to an offset of that 0x2000 byte maximum unsigned offset from the base of
+   the GOT we can use negative offsets in addition to positive. This
+   effectively doubles the usable GOT size to 0x4000 bytes.  */
+#define GOT_REG_OFFSET 0x2000
+
+struct metag_reloc_map
+{
+  bfd_reloc_code_real_type bfd_reloc_val;
+  unsigned int metag_reloc_val;
+};
+
+static const struct metag_reloc_map metag_reloc_map [] =
+  {
+    { BFD_RELOC_NONE,                R_METAG_NONE },
+    { BFD_RELOC_32,                  R_METAG_ADDR32 },
+    { BFD_RELOC_METAG_HIADDR16,      R_METAG_HIADDR16 },
+    { BFD_RELOC_METAG_LOADDR16,      R_METAG_LOADDR16 },
+    { BFD_RELOC_METAG_RELBRANCH,     R_METAG_RELBRANCH },
+    { BFD_RELOC_METAG_GETSETOFF,     R_METAG_GETSETOFF },
+    { BFD_RELOC_VTABLE_INHERIT,      R_METAG_GNU_VTINHERIT },
+    { BFD_RELOC_VTABLE_ENTRY,        R_METAG_GNU_VTENTRY },
+    { BFD_RELOC_METAG_REL8,          R_METAG_REL8 },
+    { BFD_RELOC_METAG_REL16,         R_METAG_REL16 },
+    { BFD_RELOC_METAG_HI16_GOTOFF,   R_METAG_HI16_GOTOFF },
+    { BFD_RELOC_METAG_LO16_GOTOFF,   R_METAG_LO16_GOTOFF },
+    { BFD_RELOC_METAG_GETSET_GOTOFF, R_METAG_GETSET_GOTOFF },
+    { BFD_RELOC_METAG_GETSET_GOT,    R_METAG_GETSET_GOT },
+    { BFD_RELOC_METAG_HI16_GOTPC,    R_METAG_HI16_GOTPC },
+    { BFD_RELOC_METAG_LO16_GOTPC,    R_METAG_LO16_GOTPC },
+    { BFD_RELOC_METAG_HI16_PLT,      R_METAG_HI16_PLT },
+    { BFD_RELOC_METAG_LO16_PLT,      R_METAG_LO16_PLT },
+    { BFD_RELOC_METAG_RELBRANCH_PLT, R_METAG_RELBRANCH_PLT },
+    { BFD_RELOC_METAG_GOTOFF,        R_METAG_GOTOFF },
+    { BFD_RELOC_METAG_PLT,           R_METAG_PLT },
+    { BFD_RELOC_METAG_COPY,          R_METAG_COPY },
+    { BFD_RELOC_METAG_JMP_SLOT,      R_METAG_JMP_SLOT },
+    { BFD_RELOC_METAG_RELATIVE,      R_METAG_RELATIVE },
+    { BFD_RELOC_METAG_GLOB_DAT,      R_METAG_GLOB_DAT },
+    { BFD_RELOC_METAG_TLS_GD,        R_METAG_TLS_GD },
+    { BFD_RELOC_METAG_TLS_LDM,       R_METAG_TLS_LDM },
+    { BFD_RELOC_METAG_TLS_LDO_HI16,  R_METAG_TLS_LDO_HI16 },
+    { BFD_RELOC_METAG_TLS_LDO_LO16,  R_METAG_TLS_LDO_LO16 },
+    { BFD_RELOC_METAG_TLS_LDO,       R_METAG_TLS_LDO },
+    { BFD_RELOC_METAG_TLS_IE,        R_METAG_TLS_IE },
+    { BFD_RELOC_METAG_TLS_IENONPIC,  R_METAG_TLS_IENONPIC },
+    { BFD_RELOC_METAG_TLS_IENONPIC_HI16, R_METAG_TLS_IENONPIC_HI16 },
+    { BFD_RELOC_METAG_TLS_IENONPIC_LO16, R_METAG_TLS_IENONPIC_LO16 },
+    { BFD_RELOC_METAG_TLS_TPOFF,     R_METAG_TLS_TPOFF },
+    { BFD_RELOC_METAG_TLS_DTPMOD,    R_METAG_TLS_DTPMOD },
+    { BFD_RELOC_METAG_TLS_DTPOFF,    R_METAG_TLS_DTPOFF },
+    { BFD_RELOC_METAG_TLS_LE,        R_METAG_TLS_LE },
+    { BFD_RELOC_METAG_TLS_LE_HI16,   R_METAG_TLS_LE_HI16 },
+    { BFD_RELOC_METAG_TLS_LE_LO16,   R_METAG_TLS_LE_LO16 },
+  };
+
+enum elf_metag_stub_type
+{
+  metag_stub_long_branch,
+  metag_stub_long_branch_shared,
+  metag_stub_none
+};
+
+struct elf_metag_stub_hash_entry
+{
+  /* Base hash table entry structure.  */
+  struct bfd_hash_entry bh_root;
+
+  /* The stub section.  */
+  asection *stub_sec;
+
+  /* Offset within stub_sec of the beginning of this stub.  */
+  bfd_vma stub_offset;
+
+  /* Given the symbol's value and its section we can determine its final
+     value when building the stubs (so the stub knows where to jump.  */
+  bfd_vma target_value;
+  asection *target_section;
+
+  enum elf_metag_stub_type stub_type;
+
+  /* The symbol table entry, if any, that this was derived from.  */
+  struct elf_metag_link_hash_entry *hh;
+
+  /* And the reloc addend that this was derived from.  */
+  bfd_vma addend;
+
+  /* Where this stub is being called from, or, in the case of combined
+     stub sections, the first input section in the group.  */
+  asection *id_sec;
+};
+
+struct elf_metag_link_hash_entry
+{
+  struct elf_link_hash_entry eh;
+
+  /* A pointer to the most recently used stub hash entry against this
+     symbol.  */
+  struct elf_metag_stub_hash_entry *hsh_cache;
+
+  /* Used to count relocations for delayed sizing of relocation
+     sections.  */
+  struct elf_metag_dyn_reloc_entry {
+
+    /* Next relocation in the chain.  */
+    struct elf_metag_dyn_reloc_entry *hdh_next;
+
+    /* The input section of the reloc.  */
+    asection *sec;
+
+    /* Number of relocs copied in this section.  */
+    bfd_size_type count;
+
+    /* Number of relative relocs copied for the input section.  */
+    bfd_size_type relative_count;
+  } *dyn_relocs;
+
+  enum
+    {
+      GOT_UNKNOWN = 0, GOT_NORMAL = 1, GOT_TLS_IE = 2, GOT_TLS_LDM = 4, GOT_TLS_GD = 8
+    } tls_type;
+};
+
+struct elf_metag_link_hash_table
+{
+  /* The main hash table.  */
+  struct elf_link_hash_table etab;
+
+  /* The stub hash table.  */
+  struct bfd_hash_table bstab;
+
+  /* Linker stub bfd.  */
+  bfd *stub_bfd;
+
+  /* Linker call-backs.  */
+  asection * (*add_stub_section) (const char *, asection *);
+  void (*layout_sections_again) (void);
+
+  /* Array to keep track of which stub sections have been created, and
+     information on stub grouping.  */
+  struct map_stub
+  {
+    /* This is the section to which stubs in the group will be
+       attached.  */
+    asection *link_sec;
+    /* The stub section.  */
+    asection *stub_sec;
+  } *stub_group;
+
+  /* Assorted information used by elf_metag_size_stubs.  */
+  unsigned int bfd_count;
+  int top_index;
+  asection **input_list;
+  Elf_Internal_Sym **all_local_syms;
+
+  /* Short-cuts to get to dynamic linker sections.  */
+  asection *sgot;
+  asection *sgotplt;
+  asection *srelgot;
+  asection *splt;
+  asection *srelplt;
+  asection *sdynbss;
+  asection *srelbss;
+
+  /* Small local sym cache.  */
+  struct sym_cache sym_cache;
+
+  /* Data for LDM relocations.  */
+  union
+  {
+    bfd_signed_vma refcount;
+    bfd_vma offset;
+  } tls_ldm_got;
+};
+
+/* Return the base vma address which should be subtracted from the
+   real address when resolving a dtpoff relocation.  This is PT_TLS
+   segment p_vaddr.  */
+static bfd_vma
+dtpoff_base (struct bfd_link_info *info)
+{
+  /* If tls_sec is NULL, we should have signalled an error already.  */
+  if (elf_hash_table (info)->tls_sec == NULL)
+    return 0;
+  return elf_hash_table (info)->tls_sec->vma;
+}
+
+/* Return the relocation value for R_METAG_TLS_IE */
+static bfd_vma
+tpoff (struct bfd_link_info *info, bfd_vma address)
+{
+  /* If tls_sec is NULL, we should have signalled an error already.  */
+  if (elf_hash_table (info)->tls_sec == NULL)
+    return 0;
+  /* METAG TLS ABI is variant I and static TLS blocks start just after
+     tcbhead structure which has 2 pointer fields.  */
+  return (address - elf_hash_table (info)->tls_sec->vma
+	  + align_power ((bfd_vma) 8,
+			 elf_hash_table (info)->tls_sec->alignment_power));
+}
+
+static void
+metag_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
+			  arelent *cache_ptr,
+			  Elf_Internal_Rela *dst)
+{
+  unsigned int r_type;
+
+  r_type = ELF32_R_TYPE (dst->r_info);
+  BFD_ASSERT (r_type < (unsigned int) R_METAG_MAX);
+  cache_ptr->howto = & elf_metag_howto_table [r_type];
+}
+
+static reloc_howto_type *
+metag_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
+			 bfd_reloc_code_real_type code)
+{
+  unsigned int i;
+
+  for (i = 0; i < sizeof (metag_reloc_map) / sizeof (metag_reloc_map[0]); i++)
+    if (metag_reloc_map [i].bfd_reloc_val == code)
+      return & elf_metag_howto_table [metag_reloc_map[i].metag_reloc_val];
+
+  return NULL;
+}
+
+static reloc_howto_type *
+metag_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+			 const char *r_name)
+{
+  unsigned int i;
+
+  for (i = 0; i < sizeof (elf_metag_howto_table) / sizeof (elf_metag_howto_table[0]); i++)
+    if (elf_metag_howto_table[i].name != NULL
+	&& strcasecmp (elf_metag_howto_table[i].name, r_name) == 0)
+      return &elf_metag_howto_table[i];
+
+  return NULL;
+}
+
+/* Various hash macros and functions.  */
+#define metag_link_hash_table(p) \
+  (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
+  == METAG_ELF_DATA ? ((struct elf_metag_link_hash_table *) ((p)->hash)) : NULL)
+
+#define metag_elf_hash_entry(ent) \
+  ((struct elf_metag_link_hash_entry *)(ent))
+
+#define metag_stub_hash_entry(ent) \
+  ((struct elf_metag_stub_hash_entry *)(ent))
+
+#define metag_stub_hash_lookup(table, string, create, copy) \
+  ((struct elf_metag_stub_hash_entry *) \
+   bfd_hash_lookup ((table), (string), (create), (copy)))
+
+#define metag_elf_local_got_tls_type(abfd) \
+  ((char *)(elf_local_got_offsets (abfd) + (elf_tdata (abfd)->symtab_hdr.sh_info)))
+
+/* Assorted hash table functions.  */
+
+/* Initialize an entry in the stub hash table.  */
+
+static struct bfd_hash_entry *
+stub_hash_newfunc (struct bfd_hash_entry *entry,
+		   struct bfd_hash_table *table,
+		   const char *string)
+{
+  /* Allocate the structure if it has not already been allocated by a
+     subclass.  */
+  if (entry == NULL)
+    {
+      entry = bfd_hash_allocate (table,
+				 sizeof (struct elf_metag_stub_hash_entry));
+      if (entry == NULL)
+	return entry;
+    }
+
+  /* Call the allocation method of the superclass.  */
+  entry = bfd_hash_newfunc (entry, table, string);
+  if (entry != NULL)
+    {
+      struct elf_metag_stub_hash_entry *hsh;
+
+      /* Initialize the local fields.  */
+      hsh = (struct elf_metag_stub_hash_entry *) entry;
+      hsh->stub_sec = NULL;
+      hsh->stub_offset = 0;
+      hsh->target_value = 0;
+      hsh->target_section = NULL;
+      hsh->stub_type = metag_stub_long_branch;
+      hsh->hh = NULL;
+      hsh->id_sec = NULL;
+    }
+
+  return entry;
+}
+
+/* Initialize an entry in the link hash table.  */
+
+static struct bfd_hash_entry *
+metag_link_hash_newfunc (struct bfd_hash_entry *entry,
+			 struct bfd_hash_table *table,
+			 const char *string)
+{
+  /* Allocate the structure if it has not already been allocated by a
+     subclass.  */
+  if (entry == NULL)
+    {
+      entry = bfd_hash_allocate (table,
+				 sizeof (struct elf_metag_link_hash_entry));
+      if (entry == NULL)
+	return entry;
+    }
+
+  /* Call the allocation method of the superclass.  */
+  entry = _bfd_elf_link_hash_newfunc (entry, table, string);
+  if (entry != NULL)
+    {
+      struct elf_metag_link_hash_entry *hh;
+
+      /* Initialize the local fields.  */
+      hh = (struct elf_metag_link_hash_entry *) entry;
+      hh->hsh_cache = NULL;
+      hh->dyn_relocs = NULL;
+      hh->tls_type = GOT_UNKNOWN;
+    }
+
+  return entry;
+}
+
+/* Create the derived linker hash table.  The Meta ELF port uses the derived
+   hash table to keep information specific to the Meta ELF linker (without
+   using static variables).  */
+
+static struct bfd_link_hash_table *
+elf_metag_link_hash_table_create (bfd *abfd)
+{
+  struct elf_metag_link_hash_table *htab;
+  bfd_size_type amt = sizeof (*htab);
+
+  htab = bfd_zmalloc (amt);
+  if (htab == NULL)
+    return NULL;
+
+  if (!_bfd_elf_link_hash_table_init (&htab->etab, abfd,
+				      metag_link_hash_newfunc,
+				      sizeof (struct elf_metag_link_hash_entry),
+				      METAG_ELF_DATA))
+    {
+      free (htab);
+      return NULL;
+    }
+
+  /* Init the stub hash table too.  */
+  if (!bfd_hash_table_init (&htab->bstab, stub_hash_newfunc,
+			    sizeof (struct elf_metag_stub_hash_entry)))
+    return NULL;
+
+  return &htab->etab.root;
+}
+
+/* Free the derived linker hash table.  */
+
+static void
+elf_metag_link_hash_table_free (struct bfd_link_hash_table *btab)
+{
+  struct elf_metag_link_hash_table *htab
+    = (struct elf_metag_link_hash_table *) btab;
+
+  bfd_hash_table_free (&htab->bstab);
+  _bfd_elf_link_hash_table_free (btab);
+}
+
+/* Section name for stubs is the associated section name plus this
+   string.  */
+#define STUB_SUFFIX ".stub"
+
+/* Build a name for an entry in the stub hash table.  */
+
+static char *
+metag_stub_name (const asection *input_section,
+		 const asection *sym_sec,
+		 const struct elf_metag_link_hash_entry *hh,
+		 const Elf_Internal_Rela *rel)
+{
+  char *stub_name;
+  bfd_size_type len;
+
+  if (hh)
+    {
+      len = 8 + 1 + strlen (hh->eh.root.root.string) + 1 + 8 + 1;
+      stub_name = bfd_malloc (len);
+      if (stub_name != NULL)
+	{
+	  sprintf (stub_name, "%08x_%s+%x",
+		   input_section->id & 0xffffffff,
+		   hh->eh.root.root.string,
+		   (int) rel->r_addend & 0xffffffff);
+	}
+    }
+  else
+    {
+      len = 8 + 1 + 8 + 1 + 8 + 1 + 8 + 1;
+      stub_name = bfd_malloc (len);
+      if (stub_name != NULL)
+	{
+	  sprintf (stub_name, "%08x_%x:%x+%x",
+		   input_section->id & 0xffffffff,
+		   sym_sec->id & 0xffffffff,
+		   (int) ELF32_R_SYM (rel->r_info) & 0xffffffff,
+		   (int) rel->r_addend & 0xffffffff);
+	}
+    }
+  return stub_name;
+}
+
+/* Look up an entry in the stub hash.  Stub entries are cached because
+   creating the stub name takes a bit of time.  */
+
+static struct elf_metag_stub_hash_entry *
+metag_get_stub_entry (const asection *input_section,
+		      const asection *sym_sec,
+		      struct elf_metag_link_hash_entry *hh,
+		      const Elf_Internal_Rela *rel,
+		      struct elf_metag_link_hash_table *htab)
+{
+  struct elf_metag_stub_hash_entry *hsh;
+  const asection *id_sec;
+
+  /* If this input section is part of a group of sections sharing one
+     stub section, then use the id of the first section in the group.
+     Stub names need to include a section id, as there may well be
+     more than one stub used to reach say, printf, and we need to
+     distinguish between them.  */
+  id_sec = htab->stub_group[input_section->id].link_sec;
+
+  if (hh != NULL && hh->hsh_cache != NULL
+      && hh->hsh_cache->hh == hh
+      && hh->hsh_cache->id_sec == id_sec)
+    {
+      hsh = hh->hsh_cache;
+    }
+  else
+    {
+      char *stub_name;
+
+      stub_name = metag_stub_name (id_sec, sym_sec, hh, rel);
+      if (stub_name == NULL)
+	return NULL;
+
+      hsh = metag_stub_hash_lookup (&htab->bstab,
+				    stub_name, FALSE, FALSE);
+
+      if (hh != NULL)
+	hh->hsh_cache = hsh;
+
+      free (stub_name);
+    }
+
+  return hsh;
+}
+
+/* Add a new stub entry to the stub hash.  Not all fields of the new
+   stub entry are initialised.  */
+
+static struct elf_metag_stub_hash_entry *
+metag_add_stub (const char *stub_name,
+		asection *section,
+		struct elf_metag_link_hash_table *htab)
+{
+  asection *link_sec;
+  asection *stub_sec;
+  struct elf_metag_stub_hash_entry *hsh;
+
+  link_sec = htab->stub_group[section->id].link_sec;
+  stub_sec = htab->stub_group[section->id].stub_sec;
+  if (stub_sec == NULL)
+    {
+      stub_sec = htab->stub_group[link_sec->id].stub_sec;
+      if (stub_sec == NULL)
+	{
+	  size_t namelen;
+	  bfd_size_type len;
+	  char *s_name;
+
+	  namelen = strlen (link_sec->name);
+	  len = namelen + sizeof (STUB_SUFFIX);
+	  s_name = bfd_alloc (htab->stub_bfd, len);
+	  if (s_name == NULL)
+	    return NULL;
+
+	  memcpy (s_name, link_sec->name, namelen);
+	  memcpy (s_name + namelen, STUB_SUFFIX, sizeof (STUB_SUFFIX));
+
+	  stub_sec = (*htab->add_stub_section) (s_name, link_sec);
+	  if (stub_sec == NULL)
+	    return NULL;
+	  htab->stub_group[link_sec->id].stub_sec = stub_sec;
+	}
+      htab->stub_group[section->id].stub_sec = stub_sec;
+    }
+
+  /* Enter this entry into the linker stub hash table.  */
+  hsh = metag_stub_hash_lookup (&htab->bstab, stub_name,
+				TRUE, FALSE);
+  if (hsh == NULL)
+    {
+      (*_bfd_error_handler) (_("%B: cannot create stub entry %s"),
+			     section->owner,
+			     stub_name);
+      return NULL;
+    }
+
+  hsh->stub_sec = stub_sec;
+  hsh->stub_offset = 0;
+  hsh->id_sec = link_sec;
+  return hsh;
+}
+
+/* Check a signed integer value can be represented in the given number
+   of bits.  */
+
+static bfd_boolean
+within_signed_range (int value, unsigned int bits)
+{
+  int min_val = -(1 << (bits - 1));
+  int max_val = (1 << (bits - 1)) - 1;
+  return (value <= max_val) && (value >= min_val);
+}
+
+/* Perform a relocation as part of a final link.  */
+
+static bfd_reloc_status_type
+metag_final_link_relocate (reloc_howto_type *howto,
+			   bfd *input_bfd,
+			   asection *input_section,
+			   bfd_byte *contents,
+			   Elf_Internal_Rela *rel,
+			   bfd_vma relocation,
+			   struct elf_metag_link_hash_entry *hh,
+			   struct elf_metag_link_hash_table *htab,
+			   asection *sym_sec)
+{
+  bfd_reloc_status_type r = bfd_reloc_ok;
+  bfd_byte *hit_data = contents + rel->r_offset;
+  int opcode, op_shift, op_extended, l1, l2;
+  bfd_signed_vma srel, addend = rel->r_addend;
+  struct elf_metag_stub_hash_entry *hsh = NULL;
+  bfd_vma location;
+
+  /* Find out where we are and where we're going.  */
+  location = (rel->r_offset +
+	      input_section->output_offset +
+	      input_section->output_section->vma);
+
+  switch (howto->type)
+    {
+    case R_METAG_RELBRANCH:
+    case R_METAG_RELBRANCH_PLT:
+      /* Make it a pc relative offset.  */
+      relocation -= location;
+      break;
+    case R_METAG_TLS_GD:
+    case R_METAG_TLS_IE:
+      relocation -= elf_gp (input_section->output_section->owner);
+      break;
+    default:
+      break;
+    }
+
+  switch (howto->type)
+    {
+    case R_METAG_RELBRANCH_PLT:
+    case R_METAG_RELBRANCH:
+      opcode = bfd_get_32 (input_bfd, hit_data);
+
+      srel = (bfd_signed_vma) relocation;
+      srel += addend;
+
+      /* If the branch is out of reach, then redirect the
+	 call to the local stub for this function.  */
+      if (srel > ((1 << (BRANCH_BITS + 1)) - 1) ||
+	  (srel < - (1 << (BRANCH_BITS + 1))))
+	{
+	  if (sym_sec == NULL)
+	    break;
+
+	  hsh = metag_get_stub_entry (input_section, sym_sec,
+				      hh, rel, htab);
+	  if (hsh == NULL)
+	    return bfd_reloc_undefined;
+
+	  /* Munge up the value and addend so that we call the stub
+	     rather than the procedure directly.  */
+	  srel = (hsh->stub_offset
+		  + hsh->stub_sec->output_offset
+		  + hsh->stub_sec->output_section->vma);
+	  srel -= location;
+	}
+
+      srel = srel >> 2;
+
+      if (!within_signed_range (srel, BRANCH_BITS))
+	{
+	  if (hh && hh->eh.root.type == bfd_link_hash_undefweak)
+	    srel = 0;
+	  else
+	    return bfd_reloc_overflow;
+	}
+
+      opcode &= ~(0x7ffff << 5);
+      opcode |= ((srel & 0x7ffff) << 5);
+
+      bfd_put_32 (input_bfd, opcode, hit_data);
+      break;
+    case R_METAG_GETSETOFF:
+    case R_METAG_GETSET_GOT:
+    case R_METAG_GETSET_GOTOFF:
+      opcode = bfd_get_32 (input_bfd, hit_data);
+
+      srel = (bfd_signed_vma) relocation;
+      srel += addend;
+
+      /* Is this a standard or extended GET/SET?  */
+      if ((opcode & 0xf0000000) == 0xa0000000)
+	{
+	  /* Extended GET/SET.  */
+	  l1 = opcode & 0x2;
+	  l2 = opcode & 0x4;
+	  op_extended = 1;
+	}
+      else
+	{
+	  /* Standard GET/SET.  */
+	  l1 = opcode & 0x01000000;
+	  l2 = opcode & 0x04000000;
+	  op_extended = 0;
+	}
+
+      /* Calculate the width of the GET/SET and how much we need to
+	 shift the result by.  */
+      if (l2)
+	if (l1)
+	  op_shift = 3;
+	else
+	  op_shift = 2;
+      else
+	if (l1)
+	  op_shift = 1;
+	else
+	  op_shift = 0;
+
+      /* GET/SET offsets are scaled by the width of the transfer.  */
+      srel = srel >> op_shift;
+
+      /* Extended GET/SET has signed 12 bits of offset, standard has
+	 signed 6 bits.  */
+      if (op_extended)
+	{
+	  if (!within_signed_range (srel, 12))
+	    {
+	      if (hh && hh->eh.root.type == bfd_link_hash_undefweak)
+		srel = 0;
+	      else
+		return bfd_reloc_overflow;
+	    }
+	  opcode &= ~(0xfff << 7);
+	  opcode |= ((srel & 0xfff) << 7);
+	}
+      else
+	{
+	  if (!within_signed_range (srel, 5))
+	    {
+	      if (hh && hh->eh.root.type == bfd_link_hash_undefweak)
+		srel = 0;
+	      else
+		return bfd_reloc_overflow;
+	    }
+	  opcode &= ~(0x3f << 8);
+	  opcode |= ((srel & 0x3f) << 8);
+	}
+
+      bfd_put_32 (input_bfd, opcode, hit_data);
+      break;
+    case R_METAG_TLS_GD:
+    case R_METAG_TLS_LDM:
+      opcode = bfd_get_32 (input_bfd, hit_data);
+
+      if ((bfd_signed_vma)relocation < 0)
+       {
+	 /* sign extend immediate */
+	 if ((opcode & 0xf2000001) == 0x02000000)
+	  {
+	    /* ADD De.e,Dx.r,#I16 */
+	    /* set SE bit */
+	    opcode |= (1 << 1);
+	  } else
+	    return bfd_reloc_overflow;
+       }
+
+      bfd_put_32 (input_bfd, opcode, hit_data);
+
+      r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+				    contents, rel->r_offset,
+				    relocation, rel->r_addend);
+      break;
+    default:
+      r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+				    contents, rel->r_offset,
+				    relocation, rel->r_addend);
+    }
+
+  return r;
+}
+
+/* This is defined because R_METAG_NONE != 0...
+   See RELOC_AGAINST_DISCARDED_SECTION for details.  */
+#define METAG_RELOC_AGAINST_DISCARDED_SECTION(info, input_bfd, input_section, \
+					      rel, relend, howto, contents) \
+  {									\
+    _bfd_clear_contents (howto, input_bfd, input_section,		\
+			 contents + rel->r_offset);			\
+									\
+    if (info->relocatable						\
+	&& (input_section->flags & SEC_DEBUGGING))			\
+      {									\
+	/* Only remove relocations in debug sections since other	\
+	   sections may require relocations.  */			\
+	Elf_Internal_Shdr *rel_hdr;					\
+									\
+	rel_hdr = _bfd_elf_single_rel_hdr (input_section->output_section); \
+									\
+	/* Avoid empty output section.  */				\
+	if (rel_hdr->sh_size > rel_hdr->sh_entsize)			\
+	  {								\
+	    rel_hdr->sh_size -= rel_hdr->sh_entsize;			\
+	    rel_hdr = _bfd_elf_single_rel_hdr (input_section);		\
+	    rel_hdr->sh_size -= rel_hdr->sh_entsize;			\
+									\
+	    memmove (rel, rel + 1, (relend - rel) * sizeof (*rel));	\
+									\
+	    input_section->reloc_count--;				\
+	    relend--;							\
+	    rel--;							\
+	    continue;							\
+	  }								\
+      }									\
+									\
+    rel->r_info = R_METAG_NONE;						\
+    rel->r_addend = 0;							\
+    continue;								\
+  }
+
+/* Relocate a META ELF section.
+
+The RELOCATE_SECTION function is called by the new ELF backend linker
+to handle the relocations for a section.
+
+The relocs are always passed as Rela structures; if the section
+actually uses Rel structures, the r_addend field will always be
+zero.
+
+This function is responsible for adjusting the section contents as
+necessary, and (if using Rela relocs and generating a relocatable
+output file) adjusting the reloc addend as necessary.
+
+This function does not have to worry about setting the reloc
+address or the reloc symbol index.
+
+LOCAL_SYMS is a pointer to the swapped in local symbols.
+
+LOCAL_SECTIONS is an array giving the section in the input file
+corresponding to the st_shndx field of each local symbol.
+
+The global hash table entry for the global symbols can be found
+via elf_sym_hashes (input_bfd).
+
+When generating relocatable output, this function must handle
+STB_LOCAL/STT_SECTION symbols specially.  The output symbol is
+going to be the section symbol corresponding to the output
+section, which means that the addend must be adjusted
+accordingly.  */
+
+static bfd_boolean
+elf_metag_relocate_section (bfd *output_bfd,
+			    struct bfd_link_info *info,
+			    bfd *input_bfd,
+			    asection *input_section,
+			    bfd_byte *contents,
+			    Elf_Internal_Rela *relocs,
+			    Elf_Internal_Sym *local_syms,
+			    asection **local_sections)
+{
+  bfd_vma *local_got_offsets;
+  Elf_Internal_Shdr *symtab_hdr;
+  struct elf_link_hash_entry **eh_syms;
+  struct elf_metag_link_hash_table *htab;
+  Elf_Internal_Rela *rel;
+  Elf_Internal_Rela *relend;
+  asection *sreloc;
+
+  symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
+  eh_syms = elf_sym_hashes (input_bfd);
+  relend = relocs + input_section->reloc_count;
+
+  htab = metag_link_hash_table (info);
+  local_got_offsets = elf_local_got_offsets (input_bfd);
+
+  sreloc = NULL;
+
+  for (rel = relocs; rel < relend; rel ++)
+    {
+      reloc_howto_type *howto;
+      unsigned long r_symndx;
+      Elf_Internal_Sym *sym;
+      asection *sec;
+      struct elf_metag_link_hash_entry *hh;
+      bfd_vma relocation;
+      bfd_reloc_status_type r;
+      const char *name;
+      int r_type;
+
+      r_type = ELF32_R_TYPE (rel->r_info);
+
+      if (r_type == R_METAG_GNU_VTINHERIT
+	  || r_type == R_METAG_GNU_VTENTRY
+	  || r_type == R_METAG_NONE)
+	continue;
+
+      r_symndx = ELF32_R_SYM (rel->r_info);
+
+      howto  = elf_metag_howto_table + ELF32_R_TYPE (rel->r_info);
+      hh     = NULL;
+      sym    = NULL;
+      sec    = NULL;
+
+      if (r_symndx < symtab_hdr->sh_info)
+	{
+	  sym = local_syms + r_symndx;
+	  sec = local_sections [r_symndx];
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
+
+	  name = bfd_elf_string_from_elf_section
+	    (input_bfd, symtab_hdr->sh_link, sym->st_name);
+	  name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name;
+	}
+      else
+	{
+	  struct elf_link_hash_entry *eh;
+	  bfd_boolean unresolved_reloc, warned;
+
+	  RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
+				   r_symndx, symtab_hdr, eh_syms,
+				   eh, sec, relocation,
+				   unresolved_reloc, warned);
+
+	  name = eh->root.root.string;
+	  hh = (struct elf_metag_link_hash_entry *) eh;
+	}
+
+      if (sec != NULL && discarded_section (sec))
+	  METAG_RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+						 rel, relend, howto, contents);
+
+      if (info->relocatable)
+	continue;
+
+      switch (r_type)
+	{
+	case R_METAG_ADDR32:
+	case R_METAG_RELBRANCH:
+	  if ((input_section->flags & SEC_ALLOC) == 0)
+	    break;
+
+	  if ((info->shared
+	       && r_symndx != STN_UNDEF
+	       && (input_section->flags & SEC_ALLOC) != 0
+	       && (r_type != R_METAG_RELBRANCH
+		   || !SYMBOL_CALLS_LOCAL (info, &hh->eh)))
+	      || (!info->shared
+		  && hh != NULL
+		  && hh->eh.dynindx != -1
+		  && !hh->eh.non_got_ref
+		  && ((hh->eh.def_dynamic
+		       && !hh->eh.def_regular)
+		      || hh->eh.root.type == bfd_link_hash_undefweak
+		      || hh->eh.root.type == bfd_link_hash_undefined)))
+	    {
+	      Elf_Internal_Rela outrel;
+	      bfd_boolean skip, relocate;
+	      bfd_byte *loc;
+
+	      /* When generating a shared object, these relocations
+		 are copied into the output file to be resolved at run
+		 time.  */
+
+	      sreloc = elf_section_data (input_section)->sreloc;
+	      BFD_ASSERT (sreloc != NULL);
+
+	      skip = FALSE;
+	      relocate = FALSE;
+
+	      outrel.r_offset = _bfd_elf_section_offset (output_bfd,
+							 info,
+							 input_section,
+							 rel->r_offset);
+	      if (outrel.r_offset == (bfd_vma) -1)
+		skip = TRUE;
+	      else if (outrel.r_offset == (bfd_vma) -2)
+		skip = TRUE, relocate = TRUE;
+	      outrel.r_offset += (input_section->output_section->vma
+				  + input_section->output_offset);
+
+	      if (skip)
+		{
+		  memset (&outrel, 0, sizeof outrel);
+		  outrel.r_info = ELF32_R_INFO (0, R_METAG_NONE);
+		}
+	      else if (r_type == R_METAG_RELBRANCH)
+		{
+		  BFD_ASSERT (hh != NULL && hh->eh.dynindx != -1);
+		  outrel.r_info = ELF32_R_INFO (hh->eh.dynindx, r_type);
+		  outrel.r_addend = rel->r_addend;
+		}
+	      else
+		{
+		  /* h->dynindx may be -1 if this symbol was marked to
+		     become local.  */
+		  if (hh == NULL
+		      || ((info->symbolic || hh->eh.dynindx == -1)
+			  && hh->eh.def_regular))
+		    {
+		      relocate = TRUE;
+		      outrel.r_info = ELF32_R_INFO (0, R_METAG_RELATIVE);
+		      outrel.r_addend = relocation + rel->r_addend;
+		    }
+		  else
+		    {
+		      BFD_ASSERT (hh->eh.dynindx != -1);
+		      outrel.r_info = ELF32_R_INFO (hh->eh.dynindx, r_type);
+		      outrel.r_addend = rel->r_addend;
+		    }
+		}
+
+	      loc = sreloc->contents;
+	      loc += sreloc->reloc_count * sizeof(Elf32_External_Rela);
+	      bfd_elf32_swap_reloca_out (output_bfd, &outrel,loc);
+	      ++sreloc->reloc_count;
+
+	      /* If this reloc is against an external symbol, we do
+		 not want to fiddle with the addend.  Otherwise, we
+		 need to include the symbol value so that it becomes
+		 an addend for the dynamic reloc.  */
+	      if (! relocate)
+		continue;
+	    }
+	  break;
+
+	case R_METAG_RELBRANCH_PLT:
+	  /* Relocation is to the entry for this symbol in the
+	     procedure linkage table.  */
+
+	  if (hh == NULL)
+	    break;
+
+	  if (hh->eh.forced_local)
+	    break;
+
+	  if (hh->eh.plt.offset == (bfd_vma) -1 ||
+	      htab->splt == NULL)
+	    {
+	      /* We didn't make a PLT entry for this symbol.  This
+		 happens when statically linking PIC code, or when
+		 using -Bsymbolic.  */
+	      break;
+	    }
+
+	  relocation = (htab->splt->output_section->vma
+			+ htab->splt->output_offset
+			+ hh->eh.plt.offset);
+	  break;
+	case R_METAG_HI16_GOTPC:
+	case R_METAG_LO16_GOTPC:
+	  BFD_ASSERT (htab->sgot != NULL);
+
+	  relocation = (htab->sgot->output_section->vma +
+			htab->sgot->output_offset);
+	  relocation += GOT_REG_OFFSET;
+	  relocation -= (input_section->output_section->vma
+			 + input_section->output_offset
+			 + rel->r_offset);
+	  break;
+	case R_METAG_HI16_GOTOFF:
+	case R_METAG_LO16_GOTOFF:
+	case R_METAG_GETSET_GOTOFF:
+	  BFD_ASSERT (htab->sgot != NULL);
+
+	  relocation -= (htab->sgot->output_section->vma +
+			 htab->sgot->output_offset);
+	  relocation -= GOT_REG_OFFSET;
+	  break;
+	case R_METAG_GETSET_GOT:
+	  {
+	    bfd_vma off;
+	    bfd_boolean do_got = 0;
+
+	    /* Relocation is to the entry for this symbol in the
+	       global offset table.  */
+	    if (hh != NULL)
+	      {
+		bfd_boolean dyn;
+
+		off = hh->eh.got.offset;
+		dyn = htab->etab.dynamic_sections_created;
+		if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared,
+						       &hh->eh))
+		  {
+		    /* If we aren't going to call finish_dynamic_symbol,
+		       then we need to handle initialisation of the .got
+		       entry and create needed relocs here.  Since the
+		       offset must always be a multiple of 4, we use the
+		       least significant bit to record whether we have
+		       initialised it already.  */
+		    if ((off & 1) != 0)
+		      off &= ~1;
+		    else
+		      {
+			hh->eh.got.offset |= 1;
+			do_got = 1;
+		      }
+		  }
+	      }
+	    else
+	      {
+		/* Local symbol case.  */
+		if (local_got_offsets == NULL)
+		  abort ();
+
+		off = local_got_offsets[r_symndx];
+
+		/* The offset must always be a multiple of 4.  We use
+		   the least significant bit to record whether we have
+		   already generated the necessary reloc.  */
+		if ((off & 1) != 0)
+		  off &= ~1;
+		else
+		  {
+		    local_got_offsets[r_symndx] |= 1;
+		    do_got = 1;
+		  }
+	      }
+
+	    if (do_got)
+	      {
+		if (info->shared)
+		  {
+		    /* Output a dynamic relocation for this GOT entry.
+		       In this case it is relative to the base of the
+		       object because the symbol index is zero.  */
+		    Elf_Internal_Rela outrel;
+		    bfd_byte *loc;
+		    asection *s = htab->srelgot;
+
+		    outrel.r_offset = (off
+				       + htab->sgot->output_offset
+				       + htab->sgot->output_section->vma);
+		    outrel.r_info = ELF32_R_INFO (0, R_METAG_RELATIVE);
+		    outrel.r_addend = relocation;
+		    loc = s->contents;
+		    loc += s->reloc_count++ * sizeof (Elf32_External_Rela);
+		    bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
+		  }
+		else
+		  bfd_put_32 (output_bfd, relocation,
+			      htab->sgot->contents + off);
+	      }
+
+	    if (off >= (bfd_vma) -2)
+	      abort ();
+
+	    relocation = off - GOT_REG_OFFSET;
+	  }
+	  break;
+	case R_METAG_TLS_GD:
+	case R_METAG_TLS_IE:
+	  {
+	    /* XXXMJF There is room here for optimisations. For example
+	       converting from GD->IE, etc.  */
+	    bfd_vma off;
+	    int indx;
+	    char tls_type;
+
+	    if (htab->sgot == NULL)
+	      abort();
+
+	    indx = 0;
+	    if (hh != NULL)
+	      {
+		bfd_boolean dyn;
+		dyn = htab->etab.dynamic_sections_created;
+
+		if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, &hh->eh)
+		    && (!info->shared
+			|| !SYMBOL_REFERENCES_LOCAL (info, &hh->eh)))
+		  {
+		    indx = hh->eh.dynindx;
+		  }
+		off = hh->eh.got.offset;
+		tls_type = hh->tls_type;
+	      }
+	    else
+	      {
+		/* Local symbol case.  */
+		if (local_got_offsets == NULL)
+		  abort ();
+
+		off = local_got_offsets[r_symndx];
+		tls_type = metag_elf_local_got_tls_type (input_bfd) [r_symndx];
+	      }
+
+	    if (tls_type == GOT_UNKNOWN)
+	      abort();
+
+	    if ((off & 1) != 0)
+	      off &= ~1;
+	    else
+	      {
+		bfd_boolean need_relocs = FALSE;
+		Elf_Internal_Rela outrel;
+		bfd_byte *loc = NULL;
+		int cur_off = off;
+
+		/* The GOT entries have not been initialized yet.  Do it
+		   now, and emit any relocations.  If both an IE GOT and a
+		   GD GOT are necessary, we emit the GD first.  */
+
+		if ((info->shared || indx != 0)
+		    && (hh == NULL
+			|| ELF_ST_VISIBILITY (hh->eh.other) == STV_DEFAULT
+			|| hh->eh.root.type != bfd_link_hash_undefweak))
+		  {
+		    need_relocs = TRUE;
+		    loc = htab->srelgot->contents;
+		    /* FIXME (CAO): Should this be reloc_count++ ? */
+		    loc += htab->srelgot->reloc_count * sizeof (Elf32_External_Rela);
+		  }
+
+		if (tls_type & GOT_TLS_GD)
+		  {
+		    if (need_relocs)
+		      {
+			outrel.r_offset = (cur_off
+					   + htab->sgot->output_section->vma
+					   + htab->sgot->output_offset);
+			outrel.r_info = ELF32_R_INFO (indx, R_METAG_TLS_DTPMOD);
+			outrel.r_addend = 0;
+			bfd_put_32 (output_bfd, 0, htab->sgot->contents + cur_off);
+
+			bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
+			htab->srelgot->reloc_count++;
+			loc += sizeof (Elf32_External_Rela);
+
+			if (indx == 0)
+			  bfd_put_32 (output_bfd, 0,
+				      htab->sgot->contents + cur_off + 4);
+			else
+			  {
+			    bfd_put_32 (output_bfd, 0,
+					htab->sgot->contents + cur_off + 4);
+			    outrel.r_info = ELF32_R_INFO (indx,
+						      R_METAG_TLS_DTPOFF);
+			    outrel.r_offset += 4;
+			    bfd_elf32_swap_reloca_out (output_bfd,
+						       &outrel, loc);
+			    htab->srelgot->reloc_count++;
+			    loc += sizeof (Elf32_External_Rela);
+			  }
+		      }
+		    else
+		      {
+			/* We don't support changing the TLS model.  */
+			abort ();
+		      }
+
+		    cur_off += 8;
+		  }
+
+		if (tls_type & GOT_TLS_IE)
+		  {
+		    if (need_relocs)
+		      {
+			outrel.r_offset = (cur_off
+					   + htab->sgot->output_section->vma
+					   + htab->sgot->output_offset);
+			outrel.r_info = ELF32_R_INFO (indx, R_METAG_TLS_TPOFF);
+
+			if (indx == 0)
+			  outrel.r_addend = relocation - dtpoff_base (info);
+			else
+			  outrel.r_addend = 0;
+
+			bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
+			htab->srelgot->reloc_count++;
+			loc += sizeof (Elf32_External_Rela);
+		      }
+		    else
+		      bfd_put_32 (output_bfd, tpoff (info, relocation),
+				  htab->sgot->contents + cur_off);
+
+		    cur_off += 4;
+		  }
+
+		  if (hh != NULL)
+		    hh->eh.got.offset |= 1;
+		  else
+		    local_got_offsets[r_symndx] |= 1;
+	      }
+
+	    /* Add the base of the GOT to the relocation value.  */
+	    relocation = off - GOT_REG_OFFSET;
+
+	    break;
+	  }
+
+	case R_METAG_TLS_IENONPIC_HI16:
+	case R_METAG_TLS_IENONPIC_LO16:
+	case R_METAG_TLS_LE_HI16:
+	case R_METAG_TLS_LE_LO16:
+	  if (info->shared)
+	    {
+	      (*_bfd_error_handler)
+		(_("%B(%A+0x%lx): R_METAG_TLS_LE/IENONPIC relocation not permitted in shared object"),
+		 input_bfd, input_section,
+		 (long) rel->r_offset, howto->name);
+	      return FALSE;
+	    }
+	  else
+	    relocation = tpoff (info, relocation);
+	  break;
+	case R_METAG_TLS_LDO_HI16:
+	case R_METAG_TLS_LDO_LO16:
+	  if (! info->shared)
+	    relocation = tpoff (info, relocation);
+	  else
+	    relocation -= dtpoff_base (info);
+	  break;
+	case R_METAG_TLS_LDM:
+	  {
+	    bfd_vma off;
+
+	    if (htab->sgot == NULL)
+	      abort();
+	    off = htab->tls_ldm_got.offset;
+	    if (off & 1)
+	      off &= ~1;
+	    else
+	      {
+		Elf_Internal_Rela outrel;
+		bfd_byte *loc;
+
+		outrel.r_offset = (off
+				   + htab->sgot->output_section->vma
+				   + htab->sgot->output_offset);
+
+		outrel.r_addend = 0;
+		outrel.r_info = ELF32_R_INFO (0, R_METAG_TLS_DTPMOD);
+		loc = htab->srelgot->contents;
+		loc += htab->srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
+		bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
+		htab->tls_ldm_got.offset |= 1;
+	      }
+
+	    relocation = off - GOT_REG_OFFSET;
+	    break;
+	  }
+	default:
+	  break;
+	}
+
+      r = metag_final_link_relocate (howto, input_bfd, input_section,
+				     contents, rel, relocation, hh, htab,
+				     sec);
+
+      if (r != bfd_reloc_ok)
+	{
+	  const char * msg = (const char *) NULL;
+
+	  switch (r)
+	    {
+	    case bfd_reloc_overflow:
+	      r = info->callbacks->reloc_overflow
+		(info, (hh ? &hh->eh.root : NULL), name, howto->name,
+		 (bfd_vma) 0, input_bfd, input_section, rel->r_offset);
+	      break;
+
+	    case bfd_reloc_undefined:
+	      r = info->callbacks->undefined_symbol
+		(info, name, input_bfd, input_section, rel->r_offset,
+		 TRUE);
+	      break;
+
+	    case bfd_reloc_outofrange:
+	      msg = _("internal error: out of range error");
+	      break;
+
+	    case bfd_reloc_notsupported:
+	      msg = _("internal error: unsupported relocation error");
+	      break;
+
+	    case bfd_reloc_dangerous:
+	      msg = _("internal error: dangerous relocation");
+	      break;
+
+	    default:
+	      msg = _("internal error: unknown error");
+	      break;
+	    }
+
+	  if (msg)
+	    r = info->callbacks->warning
+	      (info, msg, name, input_bfd, input_section, rel->r_offset);
+
+	  if (! r)
+	    return FALSE;
+	}
+    }
+
+  return TRUE;
+}
+
+/* Create the .plt and .got sections, and set up our hash table
+   short-cuts to various dynamic sections.  */
+
+static bfd_boolean
+elf_metag_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
+{
+  struct elf_metag_link_hash_table *htab;
+  struct elf_link_hash_entry *eh;
+  struct bfd_link_hash_entry *bh;
+  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+
+  /* Don't try to create the .plt and .got twice.  */
+  htab = metag_link_hash_table (info);
+  if (htab->splt != NULL)
+    return TRUE;
+
+  /* Call the generic code to do most of the work.  */
+  if (! _bfd_elf_create_dynamic_sections (abfd, info))
+    return FALSE;
+
+  htab->sgot = bfd_get_linker_section (abfd, ".got");
+  if (! htab->sgot)
+    return FALSE;
+
+  htab->sgotplt = bfd_make_section_with_flags (abfd, ".got.plt",
+					       (SEC_ALLOC | SEC_LOAD |
+						SEC_HAS_CONTENTS |
+						SEC_IN_MEMORY |
+						SEC_LINKER_CREATED));
+  if (htab->sgotplt == NULL
+      || !bfd_set_section_alignment (abfd, htab->sgotplt, 2))
+    return FALSE;
+
+  /* Define the symbol __GLOBAL_OFFSET_TABLE__ at the start of the .got
+     section.  We don't do this in the linker script because we don't want
+     to define the symbol if we are not creating a global offset table.  */
+  bh = NULL;
+  if (!(_bfd_generic_link_add_one_symbol
+	(info, abfd, "__GLOBAL_OFFSET_TABLE__", BSF_GLOBAL, htab->sgot,
+	 (bfd_vma) 0, NULL, FALSE, bed->collect, &bh)))
+    return FALSE;
+  eh = (struct elf_link_hash_entry *) bh;
+  eh->def_regular = 1;
+  eh->type = STT_OBJECT;
+  eh->other = STV_HIDDEN;
+
+  if (! info->executable
+      && ! bfd_elf_link_record_dynamic_symbol (info, eh))
+    return FALSE;
+
+  elf_hash_table (info)->hgot = eh;
+
+  htab->splt = bfd_get_linker_section (abfd, ".plt");
+  htab->srelplt = bfd_get_linker_section (abfd, ".rela.plt");
+
+  htab->srelgot = bfd_get_linker_section (abfd, ".rela.got");
+
+  htab->sdynbss = bfd_get_linker_section (abfd, ".dynbss");
+  htab->srelbss = bfd_get_linker_section (abfd, ".rela.bss");
+
+  return TRUE;
+}
+
+/* Look through the relocs for a section during the first phase, and
+   calculate needed space in the global offset table, procedure linkage
+   table, and dynamic reloc sections.  At this point we haven't
+   necessarily read all the input files.  */
+
+static bfd_boolean
+elf_metag_check_relocs (bfd *abfd,
+			struct bfd_link_info *info,
+			asection *sec,
+			const Elf_Internal_Rela *relocs)
+{
+  Elf_Internal_Shdr *symtab_hdr;
+  struct elf_link_hash_entry **eh_syms;
+  const Elf_Internal_Rela *rel;
+  const Elf_Internal_Rela *rel_end;
+  struct elf_metag_link_hash_table *htab;
+  asection *sreloc;
+  bfd *dynobj;
+  int tls_type = GOT_UNKNOWN, old_tls_type = GOT_UNKNOWN;
+
+  if (info->relocatable)
+    return TRUE;
+
+  htab = metag_link_hash_table (info);
+  dynobj = htab->etab.dynobj;
+  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+  eh_syms = elf_sym_hashes (abfd);
+  sreloc = NULL;
+
+  if (htab == NULL)
+    return FALSE;
+
+  rel_end = relocs + sec->reloc_count;
+  for (rel = relocs; rel < rel_end; rel++)
+    {
+      int r_type;
+      struct elf_metag_link_hash_entry *hh;
+      Elf_Internal_Sym *isym;
+      unsigned long r_symndx;
+
+      r_symndx = ELF32_R_SYM (rel->r_info);
+      r_type = ELF32_R_TYPE (rel->r_info);
+      if (r_symndx < symtab_hdr->sh_info)
+	{
+	  /* A local symbol.  */
+	  isym = bfd_sym_from_r_symndx (&htab->sym_cache,
+					abfd, r_symndx);
+	  if (isym == NULL)
+	    return FALSE;
+
+	  hh = NULL;
+	}
+      else
+	{
+	  isym = NULL;
+
+	  hh = (struct elf_metag_link_hash_entry *)
+	    eh_syms[r_symndx - symtab_hdr->sh_info];
+	  while (hh->eh.root.type == bfd_link_hash_indirect
+		 || hh->eh.root.type == bfd_link_hash_warning)
+	    hh = (struct elf_metag_link_hash_entry *) hh->eh.root.u.i.link;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  hh->eh.root.non_ir_ref = 1;
+	}
+
+      /* Some relocs require a global offset table.  */
+      if (htab->sgot == NULL)
+	{
+	  switch (r_type)
+	    {
+	    case R_METAG_TLS_GD:
+	    case R_METAG_TLS_LDM:
+	    case R_METAG_TLS_IE:
+	      if (info->shared)
+		info->flags |= DF_STATIC_TLS;
+	      /* Fall through.  */
+
+	    case R_METAG_HI16_GOTOFF:
+	    case R_METAG_LO16_GOTOFF:
+	    case R_METAG_GETSET_GOTOFF:
+	    case R_METAG_GETSET_GOT:
+	    case R_METAG_HI16_GOTPC:
+	    case R_METAG_LO16_GOTPC:
+	      if (dynobj == NULL)
+		htab->etab.dynobj = dynobj = abfd;
+	      if (!elf_metag_create_dynamic_sections (dynobj, info))
+		return FALSE;
+	      break;
+
+	    default:
+	      break;
+	    }
+	}
+
+      switch (r_type)
+	{
+	case R_METAG_TLS_IE:
+	case R_METAG_TLS_GD:
+	case R_METAG_GETSET_GOT:
+	  switch (r_type)
+	    {
+	    default:
+	      tls_type = GOT_NORMAL;
+	      break;
+	    case R_METAG_TLS_IE:
+	      tls_type = GOT_TLS_IE;
+	      break;
+	    case R_METAG_TLS_GD:
+	      tls_type = GOT_TLS_GD;
+	      break;
+	    }
+
+	  if (hh != NULL)
+	    {
+	      hh->eh.got.refcount += 1;
+	      old_tls_type = hh->tls_type;
+	    }
+	  else
+	    {
+	      bfd_signed_vma *local_got_refcounts;
+
+	      /* This is a global offset table entry for a local
+		 symbol.  */
+	      local_got_refcounts = elf_local_got_refcounts (abfd);
+	      if (local_got_refcounts == NULL)
+		{
+		  bfd_size_type size;
+
+		  size = symtab_hdr->sh_info;
+		  size *= sizeof (bfd_signed_vma);
+		  /* Add in space to store the local GOT TLS types.  */
+		  size += symtab_hdr->sh_info;
+		  local_got_refcounts = ((bfd_signed_vma *)
+					 bfd_zalloc (abfd, size));
+		  if (local_got_refcounts == NULL)
+		    return FALSE;
+		  elf_local_got_refcounts (abfd) = local_got_refcounts;
+		  memset (metag_elf_local_got_tls_type (abfd),
+			  GOT_UNKNOWN, symtab_hdr->sh_info);
+		}
+	      local_got_refcounts[r_symndx] += 1;
+	      old_tls_type = metag_elf_local_got_tls_type (abfd) [r_symndx];
+	    }
+
+	  if (old_tls_type != tls_type)
+	    {
+	      if (hh != NULL)
+		{
+		  hh->tls_type = tls_type;
+		}
+	      else
+		{
+		  metag_elf_local_got_tls_type (abfd) [r_symndx] = tls_type;
+		}
+	    }
+
+	  break;
+
+	case R_METAG_TLS_LDM:
+	  metag_link_hash_table (info)->tls_ldm_got.refcount += 1;
+	  break;
+
+	case R_METAG_RELBRANCH_PLT:
+	  /* This symbol requires a procedure linkage table entry.  We
+	     actually build the entry in adjust_dynamic_symbol,
+	     because this might be a case of linking PIC code without
+	     linking in any dynamic objects, in which case we don't
+	     need to generate a procedure linkage table after all.  */
+
+	  /* If this is a local symbol, we resolve it directly without
+	     creating a procedure linkage table entry.  */
+	  if (hh == NULL)
+	    continue;
+
+	  if (hh->eh.forced_local)
+	    break;
+
+	  hh->eh.needs_plt = 1;
+	  hh->eh.plt.refcount += 1;
+	  break;
+
+	case R_METAG_HIADDR16:
+	case R_METAG_LOADDR16:
+	  /* Let's help debug shared library creation.  These relocs
+	     cannot be used in shared libs.  Don't error out for
+	     sections we don't care about, such as debug sections or
+	     non-constant sections.  */
+	  if (info->shared
+	      && (sec->flags & SEC_ALLOC) != 0
+	      && (sec->flags & SEC_READONLY) != 0)
+	    {
+	      const char *name;
+
+	      if (hh)
+		name = hh->eh.root.root.string;
+	      else
+		name = bfd_elf_sym_name (abfd, symtab_hdr, isym, NULL);
+	      (*_bfd_error_handler)
+		(_("%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"),
+		 abfd, elf_metag_howto_table[r_type].name, name);
+	      bfd_set_error (bfd_error_bad_value);
+	      return FALSE;
+	    }
+
+	  /* Fall through.  */
+	case R_METAG_ADDR32:
+	case R_METAG_RELBRANCH:
+	case R_METAG_GETSETOFF:
+	  if (hh != NULL && !info->shared)
+	    {
+	      hh->eh.non_got_ref = 1;
+	      hh->eh.plt.refcount += 1;
+	    }
+
+	  /* If we are creating a shared library, and this is a reloc
+	     against a global symbol, or a non PC relative reloc
+	     against a local symbol, then we need to copy the reloc
+	     into the shared library.  However, if we are linking with
+	     -Bsymbolic, we do not need to copy a reloc against a
+	     global symbol which is defined in an object we are
+	     including in the link (i.e., DEF_REGULAR is set).  At
+	     this point we have not seen all the input files, so it is
+	     possible that DEF_REGULAR is not set now but will be set
+	     later (it is never cleared).  We account for that
+	     possibility below by storing information in the
+	     dyn_relocs field of the hash table entry. A similar
+	     situation occurs when creating shared libraries and symbol
+	     visibility changes render the symbol local.
+
+	     If on the other hand, we are creating an executable, we
+	     may need to keep relocations for symbols satisfied by a
+	     dynamic library if we manage to avoid copy relocs for the
+	     symbol.  */
+	  if ((info->shared
+	       && (sec->flags & SEC_ALLOC) != 0
+	       && (r_type != R_METAG_RELBRANCH
+		   || (hh != NULL
+		       && (! info->symbolic
+			   || hh->eh.root.type == bfd_link_hash_defweak
+			   || !hh->eh.def_regular))))
+	      || (!info->shared
+		  && (sec->flags & SEC_ALLOC) != 0
+		  && hh != NULL
+		  && (hh->eh.root.type == bfd_link_hash_defweak
+		      || !hh->eh.def_regular)))
+	    {
+	      struct elf_metag_dyn_reloc_entry *hdh_p;
+	      struct elf_metag_dyn_reloc_entry **hdh_head;
+
+	      if (dynobj == NULL)
+		htab->etab.dynobj = dynobj = abfd;
+
+	      /* When creating a shared object, we must copy these
+		 relocs into the output file.  We create a reloc
+		 section in dynobj and make room for the reloc.  */
+	      if (sreloc == NULL)
+		{
+		  sreloc = _bfd_elf_make_dynamic_reloc_section
+		    (sec, htab->etab.dynobj, 2, abfd, /*rela?*/ TRUE);
+
+		  if (sreloc == NULL)
+		    {
+		      bfd_set_error (bfd_error_bad_value);
+		      return FALSE;
+		    }
+
+		  elf_section_data (sec)->sreloc = sreloc;
+		}
+
+	      /* If this is a global symbol, we count the number of
+		 relocations we need for this symbol.  */
+	      if (hh != NULL)
+		hdh_head = &((struct elf_metag_link_hash_entry *) hh)->dyn_relocs;
+	      else
+		{
+		  /* Track dynamic relocs needed for local syms too.  */
+		  asection *sr;
+		  void *vpp;
+
+		  sr = bfd_section_from_elf_index (abfd, isym->st_shndx);
+		  if (sr == NULL)
+		    sr = sec;
+
+		  vpp = &elf_section_data (sr)->local_dynrel;
+		  hdh_head = (struct elf_metag_dyn_reloc_entry **) vpp;
+		}
+
+	      hdh_p = *hdh_head;
+	      if (hdh_p == NULL || hdh_p->sec != sec)
+		{
+		  hdh_p = ((struct elf_metag_dyn_reloc_entry *)
+			   bfd_alloc (dynobj, sizeof *hdh_p));
+		  if (hdh_p == NULL)
+		    return FALSE;
+		  hdh_p->hdh_next = *hdh_head;
+		  *hdh_head = hdh_p;
+		  hdh_p->sec = sec;
+		  hdh_p->count = 0;
+		  hdh_p->relative_count = 0;
+		}
+
+	      hdh_p->count += 1;
+	      if (ELF32_R_TYPE (rel->r_info) == R_METAG_RELBRANCH)
+		hdh_p->relative_count += 1;
+	    }
+	  break;
+
+	  /* This relocation describes the C++ object vtable hierarchy.
+	     Reconstruct it for later use during GC.  */
+	case R_METAG_GNU_VTINHERIT:
+	  if (!bfd_elf_gc_record_vtinherit (abfd, sec, &hh->eh,
+					    rel->r_offset))
+	    return FALSE;
+	  break;
+
+	  /* This relocation describes which C++ vtable entries are actually
+	     used.  Record for later use during GC.  */
+	case R_METAG_GNU_VTENTRY:
+	  BFD_ASSERT (hh != NULL);
+	  if (hh != NULL
+	      && !bfd_elf_gc_record_vtentry (abfd, sec, &hh->eh, rel->r_addend))
+	    return FALSE;
+	  break;
+	}
+    }
+
+  return TRUE;
+}
+
+/* Copy the extra info we tack onto an elf_link_hash_entry.  */
+
+static void
+elf_metag_copy_indirect_symbol (struct bfd_link_info *info,
+				struct elf_link_hash_entry *eh_dir,
+				struct elf_link_hash_entry *eh_ind)
+{
+  struct elf_metag_link_hash_entry *hh_dir, *hh_ind;
+
+  hh_dir = metag_elf_hash_entry (eh_dir);
+  hh_ind = metag_elf_hash_entry (eh_ind);
+
+  if (hh_ind->dyn_relocs != NULL)
+    {
+      if (hh_dir->dyn_relocs != NULL)
+	{
+	  struct elf_metag_dyn_reloc_entry **hdh_pp;
+	  struct elf_metag_dyn_reloc_entry *hdh_p;
+
+	  if (eh_ind->root.type == bfd_link_hash_indirect)
+	    abort ();
+
+	  /* Add reloc counts against the weak sym to the strong sym
+	     list.  Merge any entries against the same section.  */
+	  for (hdh_pp = &hh_ind->dyn_relocs; (hdh_p = *hdh_pp) != NULL; )
+	    {
+	      struct elf_metag_dyn_reloc_entry *hdh_q;
+
+	      for (hdh_q = hh_dir->dyn_relocs; hdh_q != NULL;
+		   hdh_q = hdh_q->hdh_next)
+		if (hdh_q->sec == hdh_p->sec)
+		  {
+		    hdh_q->relative_count += hdh_p->relative_count;
+		    hdh_q->count += hdh_p->count;
+		    *hdh_pp = hdh_p->hdh_next;
+		    break;
+		  }
+	      if (hdh_q == NULL)
+		hdh_pp = &hdh_p->hdh_next;
+	    }
+	  *hdh_pp = hh_dir->dyn_relocs;
+	}
+
+      hh_dir->dyn_relocs = hh_ind->dyn_relocs;
+      hh_ind->dyn_relocs = NULL;
+    }
+
+  if (eh_ind->root.type == bfd_link_hash_indirect
+      && eh_dir->got.refcount <= 0)
+    {
+      hh_dir->tls_type = hh_ind->tls_type;
+      hh_ind->tls_type = GOT_UNKNOWN;
+    }
+
+  _bfd_elf_link_hash_copy_indirect (info, eh_dir, eh_ind);
+}
+
+/* Adjust a symbol defined by a dynamic object and referenced by a
+   regular object.  The current definition is in some section of the
+   dynamic object, but we're not including those sections.  We have to
+   change the definition to something the rest of the link can
+   understand.  */
+
+static bfd_boolean
+elf_metag_adjust_dynamic_symbol (struct bfd_link_info *info,
+				 struct elf_link_hash_entry *eh)
+{
+  struct elf_metag_link_hash_table *htab;
+  struct elf_metag_link_hash_entry *hh;
+  struct elf_metag_dyn_reloc_entry *hdh_p;
+  asection *s;
+
+  /* If this is a function, put it in the procedure linkage table.  We
+     will fill in the contents of the procedure linkage table later,
+     when we know the address of the .got section.  */
+  if (eh->type == STT_FUNC
+      || eh->needs_plt)
+    {
+      if (eh->plt.refcount <= 0
+	  || SYMBOL_CALLS_LOCAL (info, eh)
+	  || (ELF_ST_VISIBILITY (eh->other) != STV_DEFAULT
+	      && eh->root.type == bfd_link_hash_undefweak))
+	{
+	  /* This case can occur if we saw a PLT reloc in an input
+	     file, but the symbol was never referred to by a dynamic
+	     object.  In such a case, we don't actually need to build
+	     a procedure linkage table, and we can just do a PCREL
+	     reloc instead.  */
+	  eh->plt.offset = (bfd_vma) -1;
+	  eh->needs_plt = 0;
+	}
+
+      return TRUE;
+    }
+  else
+    eh->plt.offset = (bfd_vma) -1;
+
+  /* If this is a weak symbol, and there is a real definition, the
+     processor independent code will have arranged for us to see the
+     real definition first, and we can just use the same value.  */
+  if (eh->u.weakdef != NULL)
+    {
+      if (eh->u.weakdef->root.type != bfd_link_hash_defined
+	  && eh->u.weakdef->root.type != bfd_link_hash_defweak)
+	abort ();
+      eh->root.u.def.section = eh->u.weakdef->root.u.def.section;
+      eh->root.u.def.value = eh->u.weakdef->root.u.def.value;
+      eh->non_got_ref = eh->u.weakdef->non_got_ref;
+      return TRUE;
+    }
+
+  /* This is a reference to a symbol defined by a dynamic object which
+     is not a function.  */
+
+  /* If we are creating a shared library, we must presume that the
+     only references to the symbol are via the global offset table.
+     For such cases we need not do anything here; the relocations will
+     be handled correctly by relocate_section.  */
+  if (info->shared)
+    return TRUE;
+
+  /* If there are no references to this symbol that do not use the
+     GOT, we don't need to generate a copy reloc.  */
+  if (!eh->non_got_ref)
+    return TRUE;
+
+  /* If -z nocopyreloc was given, we won't generate them either.  */
+  if (info->nocopyreloc)
+    {
+      eh->non_got_ref = 0;
+      return TRUE;
+    }
+
+  hh = (struct elf_metag_link_hash_entry *) eh;
+  for (hdh_p = hh->dyn_relocs; hdh_p != NULL; hdh_p = hdh_p->hdh_next)
+    {
+      s = hdh_p->sec->output_section;
+      if (s != NULL && (s->flags & SEC_READONLY) != 0)
+	break;
+    }
+
+  /* If we didn't find any dynamic relocs in read-only sections, then
+     we'll be keeping the dynamic relocs and avoiding the copy reloc.  */
+  if (hdh_p == NULL)
+    {
+      eh->non_got_ref = 0;
+      return TRUE;
+    }
+
+  /* We must allocate the symbol in our .dynbss section, which will
+     become part of the .bss section of the executable.  There will be
+     an entry for this symbol in the .dynsym section.  The dynamic
+     object will contain position independent code, so all references
+     from the dynamic object to this symbol will go through the global
+     offset table.  The dynamic linker will use the .dynsym entry to
+     determine the address it must put in the global offset table, so
+     both the dynamic object and the regular object will refer to the
+     same memory location for the variable.  */
+
+  htab = metag_link_hash_table (info);
+
+  /* We must generate a COPY reloc to tell the dynamic linker to
+     copy the initial value out of the dynamic object and into the
+     runtime process image.  */
+  if ((eh->root.u.def.section->flags & SEC_ALLOC) != 0 && eh->size != 0)
+    {
+      htab->srelbss->size += sizeof (Elf32_External_Rela);
+      eh->needs_copy = 1;
+    }
+
+  s = htab->sdynbss;
+
+  return _bfd_elf_adjust_dynamic_copy (eh, s);
+}
+
+/* Allocate space in .plt, .got and associated reloc sections for
+   global syms.  */
+
+static bfd_boolean
+allocate_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
+{
+  struct bfd_link_info *info;
+  struct elf_metag_link_hash_table *htab;
+  struct elf_metag_link_hash_entry *hh;
+  struct elf_metag_dyn_reloc_entry *hdh_p;
+
+  if (eh->root.type == bfd_link_hash_indirect)
+    return TRUE;
+
+  if (eh->root.type == bfd_link_hash_warning)
+    eh = (struct elf_link_hash_entry *) eh->root.u.i.link;
+
+  info = inf;
+  htab = metag_link_hash_table (info);
+
+  if (htab->etab.dynamic_sections_created
+      && eh->plt.refcount > 0)
+    {
+      /* Make sure this symbol is output as a dynamic symbol.
+	 Undefined weak syms won't yet be marked as dynamic.  */
+      if (eh->dynindx == -1
+	  && !eh->forced_local)
+	{
+	  if (! bfd_elf_link_record_dynamic_symbol (info, eh))
+	    return FALSE;
+	}
+
+      if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info->shared, eh))
+	{
+	  asection *s = htab->splt;
+
+	  /* If this is the first .plt entry, make room for the special
+	     first entry.  */
+	  if (s->size == 0)
+	    s->size += PLT_ENTRY_SIZE;
+
+	  eh->plt.offset = s->size;
+
+	  /* If this symbol is not defined in a regular file, and we are
+	     not generating a shared library, then set the symbol to this
+	     location in the .plt.  This is required to make function
+	     pointers compare as equal between the normal executable and
+	     the shared library.  */
+	  if (! info->shared
+	      && !eh->def_regular)
+	    {
+	      eh->root.u.def.section = s;
+	      eh->root.u.def.value = eh->plt.offset;
+	    }
+
+	  /* Make room for this entry.  */
+	  s->size += PLT_ENTRY_SIZE;
+
+	  /* We also need to make an entry in the .got.plt section, which
+	     will be placed in the .got section by the linker script.  */
+	  htab->sgotplt->size += 4;
+
+	  /* We also need to make an entry in the .rel.plt section.  */
+	  htab->srelplt->size += sizeof (Elf32_External_Rela);
+	}
+      else
+	{
+	  eh->plt.offset = (bfd_vma) -1;
+	  eh->needs_plt = 0;
+	}
+    }
+  else
+    {
+      eh->plt.offset = (bfd_vma) -1;
+      eh->needs_plt = 0;
+    }
+
+  if (eh->got.refcount > 0)
+    {
+      asection *s;
+      bfd_boolean dyn;
+      int tls_type = metag_elf_hash_entry (eh)->tls_type;
+
+      /* Make sure this symbol is output as a dynamic symbol.
+	 Undefined weak syms won't yet be marked as dynamic.  */
+      if (eh->dynindx == -1
+	  && !eh->forced_local)
+	{
+	  if (! bfd_elf_link_record_dynamic_symbol (info, eh))
+	    return FALSE;
+	}
+
+      s = htab->sgot;
+
+      eh->got.offset = s->size;
+      s->size += 4;
+      /* R_METAG_TLS_GD needs 2 consecutive GOT slots.  */
+      if (tls_type == GOT_TLS_GD)
+	  s->size += 4;
+      dyn = htab->etab.dynamic_sections_created;
+      /* R_METAG_TLS_IE needs one dynamic relocation if dynamic,
+	 R_METAG_TLS_GD needs one if local symbol and two if global.  */
+      if ((tls_type == GOT_TLS_GD && eh->dynindx == -1)
+	  || (tls_type == GOT_TLS_IE && dyn))
+	htab->srelgot->size += sizeof (Elf32_External_Rela);
+      else if (tls_type == GOT_TLS_GD)
+	  htab->srelgot->size += 2 * sizeof (Elf32_External_Rela);
+      else if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, eh))
+	  htab->srelgot->size += sizeof (Elf32_External_Rela);
+    }
+  else
+    eh->got.offset = (bfd_vma) -1;
+
+  hh = (struct elf_metag_link_hash_entry *) eh;
+  if (hh->dyn_relocs == NULL)
+    return TRUE;
+
+  /* If this is a -Bsymbolic shared link, then we need to discard all
+     space allocated for dynamic pc-relative relocs against symbols
+     defined in a regular object.  For the normal shared case, discard
+     space for relocs that have become local due to symbol visibility
+     changes.  */
+  if (info->shared)
+    {
+      if (SYMBOL_CALLS_LOCAL (info, eh))
+	{
+	  struct elf_metag_dyn_reloc_entry **hdh_pp;
+
+	  for (hdh_pp = &hh->dyn_relocs; (hdh_p = *hdh_pp) != NULL; )
+	    {
+	      hdh_p->count -= hdh_p->relative_count;
+	      hdh_p->relative_count = 0;
+	      if (hdh_p->count == 0)
+		*hdh_pp = hdh_p->hdh_next;
+	      else
+		hdh_pp = &hdh_p->hdh_next;
+	    }
+	}
+
+      /* Also discard relocs on undefined weak syms with non-default
+	 visibility.  */
+      if (hh->dyn_relocs != NULL
+	  && eh->root.type == bfd_link_hash_undefweak)
+	{
+	  if (ELF_ST_VISIBILITY (eh->other) != STV_DEFAULT)
+	    hh->dyn_relocs = NULL;
+
+	  /* Make sure undefined weak symbols are output as a dynamic
+	     symbol in PIEs.  */
+	  else if (eh->dynindx == -1
+		   && !eh->forced_local)
+	    {
+	      if (! bfd_elf_link_record_dynamic_symbol (info, eh))
+		return FALSE;
+	    }
+	}
+    }
+  else
+    {
+      /* For the non-shared case, discard space for relocs against
+	 symbols which turn out to need copy relocs or are not
+	 dynamic.  */
+      if (!eh->non_got_ref
+	  && ((eh->def_dynamic
+	       && !eh->def_regular)
+	      || (htab->etab.dynamic_sections_created
+		  && (eh->root.type == bfd_link_hash_undefweak
+		      || eh->root.type == bfd_link_hash_undefined))))
+	{
+	  /* Make sure this symbol is output as a dynamic symbol.
+	     Undefined weak syms won't yet be marked as dynamic.  */
+	  if (eh->dynindx == -1
+	      && !eh->forced_local)
+	    {
+	      if (! bfd_elf_link_record_dynamic_symbol (info, eh))
+		return FALSE;
+	    }
+
+	  /* If that succeeded, we know we'll be keeping all the
+	     relocs.  */
+	  if (eh->dynindx != -1)
+	    goto keep;
+	}
+
+      hh->dyn_relocs = NULL;
+      return TRUE;
+
+    keep: ;
+    }
+
+  /* Finally, allocate space.  */
+  for (hdh_p = hh->dyn_relocs; hdh_p != NULL; hdh_p = hdh_p->hdh_next)
+    {
+      asection *sreloc = elf_section_data (hdh_p->sec)->sreloc;
+      sreloc->size += hdh_p->count * sizeof (Elf32_External_Rela);
+    }
+
+  return TRUE;
+}
+
+/* Find any dynamic relocs that apply to read-only sections.  */
+
+static bfd_boolean
+readonly_dynrelocs (struct elf_link_hash_entry *eh, void *inf)
+{
+  struct elf_metag_link_hash_entry *hh;
+  struct elf_metag_dyn_reloc_entry *hdh_p;
+
+  if (eh->root.type == bfd_link_hash_warning)
+    eh = (struct elf_link_hash_entry *) eh->root.u.i.link;
+
+  hh = (struct elf_metag_link_hash_entry *) eh;
+  for (hdh_p = hh->dyn_relocs; hdh_p != NULL; hdh_p = hdh_p->hdh_next)
+    {
+      asection *s = hdh_p->sec->output_section;
+
+      if (s != NULL && (s->flags & SEC_READONLY) != 0)
+	{
+	  struct bfd_link_info *info = inf;
+
+	  info->flags |= DF_TEXTREL;
+
+	  /* Not an error, just cut short the traversal.  */
+	  return FALSE;
+	}
+    }
+  return TRUE;
+}
+
+/* Set the sizes of the dynamic sections.  */
+
+static bfd_boolean
+elf_metag_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
+				 struct bfd_link_info *info)
+{
+  struct elf_metag_link_hash_table *htab;
+  bfd *dynobj;
+  bfd *ibfd;
+  asection *s;
+  bfd_boolean relocs;
+
+  htab = metag_link_hash_table (info);
+  dynobj = htab->etab.dynobj;
+  if (dynobj == NULL)
+    abort ();
+
+  if (htab->etab.dynamic_sections_created)
+    {
+      /* Set the contents of the .interp section to the interpreter.  */
+      if (info->executable)
+	{
+	  s = bfd_get_linker_section (dynobj, ".interp");
+	  if (s == NULL)
+	    abort ();
+	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
+	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
+	}
+    }
+
+  /* Set up .got offsets for local syms, and space for local dynamic
+     relocs.  */
+  for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+    {
+      bfd_signed_vma *local_got;
+      bfd_signed_vma *end_local_got;
+      bfd_size_type locsymcount;
+      Elf_Internal_Shdr *symtab_hdr;
+      asection *srel;
+      char *local_tls_type;
+
+      if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
+	continue;
+
+      for (s = ibfd->sections; s != NULL; s = s->next)
+	{
+	  struct elf_metag_dyn_reloc_entry *hdh_p;
+
+	  for (hdh_p = ((struct elf_metag_dyn_reloc_entry *)
+			elf_section_data (s)->local_dynrel);
+	       hdh_p != NULL;
+	       hdh_p = hdh_p->hdh_next)
+	    {
+	      if (!bfd_is_abs_section (hdh_p->sec)
+		  && bfd_is_abs_section (hdh_p->sec->output_section))
+		{
+		  /* Input section has been discarded, either because
+		     it is a copy of a linkonce section or due to
+		     linker script /DISCARD/, so we'll be discarding
+		     the relocs too.  */
+		}
+	      else if (hdh_p->count != 0)
+		{
+		  srel = elf_section_data (hdh_p->sec)->sreloc;
+		  srel->size += hdh_p->count * sizeof (Elf32_External_Rela);
+		  if ((hdh_p->sec->output_section->flags & SEC_READONLY) != 0)
+		    info->flags |= DF_TEXTREL;
+		}
+	    }
+	}
+
+      local_got = elf_local_got_refcounts (ibfd);
+      if (!local_got)
+	continue;
+
+      symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+      locsymcount = symtab_hdr->sh_info;
+      end_local_got = local_got + locsymcount;
+      local_tls_type = metag_elf_local_got_tls_type (ibfd);
+      s = htab->sgot;
+      srel = htab->srelgot;
+      for (; local_got < end_local_got; ++local_got)
+	{
+	  if (*local_got > 0)
+	    {
+	      *local_got = s->size;
+	      s->size += GOT_ENTRY_SIZE;
+	      /* R_METAG_TLS_GD relocs need 2 consecutive GOT entries.  */
+	      if (*local_tls_type == GOT_TLS_GD)
+		s->size += 4;
+	      if (info->shared)
+		srel->size += sizeof (Elf32_External_Rela);
+	    }
+	  else
+	    *local_got = (bfd_vma) -1;
+	  ++local_tls_type;
+	}
+    }
+
+  if (htab->tls_ldm_got.refcount > 0)
+    {
+      /* Allocate 2 got entries and 1 dynamic reloc for R_METAG_TLS_LDM
+	 reloc.  */
+      htab->tls_ldm_got.offset = htab->sgot->size;
+      htab->sgot->size += 8;
+      htab->srelgot->size += sizeof (Elf32_External_Rela);
+    }
+  else
+    htab->tls_ldm_got.offset = -1;
+
+  /* Allocate global sym .plt and .got entries, and space for global
+     sym dynamic relocs.  */
+  elf_link_hash_traverse (&htab->etab, allocate_dynrelocs, info);
+
+  /* We now have determined the sizes of the various dynamic sections.
+     Allocate memory for them.  */
+  relocs = FALSE;
+  for (s = dynobj->sections; s != NULL; s = s->next)
+    {
+      bfd_boolean reloc_section = FALSE;
+
+      if ((s->flags & SEC_LINKER_CREATED) == 0)
+	continue;
+
+      if (s == htab->splt
+	  || s == htab->sgot
+	  || s == htab->sgotplt
+	  || s == htab->sdynbss)
+	{
+	  /* Strip this section if we don't need it; see the
+	     comment below.  */
+	}
+      else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela"))
+	{
+	  if (s->size != 0 && s != htab->srelplt)
+	    relocs = TRUE;
+
+	  /* We use the reloc_count field as a counter if we need
+	     to copy relocs into the output file.  */
+	  s->reloc_count = 0;
+	  reloc_section = TRUE;
+	}
+      else
+	{
+	  /* It's not one of our sections, so don't allocate space.  */
+	  continue;
+	}
+
+      if (s->size == 0)
+	{
+	  /* If we don't need this section, strip it from the
+	     output file.  This is mostly to handle .rela.bss and
+	     .rela.plt.  We must create both sections in
+	     create_dynamic_sections, because they must be created
+	     before the linker maps input sections to output
+	     sections.  The linker does that before
+	     adjust_dynamic_symbol is called, and it is that
+	     function which decides whether anything needs to go
+	     into these sections.  */
+	  s->flags |= SEC_EXCLUDE;
+	  continue;
+	}
+
+      if ((s->flags & SEC_HAS_CONTENTS) == 0)
+	continue;
+
+      /* Allocate memory for the section contents.  */
+      s->contents = bfd_zalloc (dynobj, s->size);
+      if (s->contents == NULL)
+	return FALSE;
+      else if (reloc_section)
+	{
+	  unsigned char *contents = s->contents;
+	  Elf32_External_Rela reloc;
+
+	  /* Fill the reloc section with a R_METAG_NONE type reloc.  */
+	  memset(&reloc, 0, sizeof(Elf32_External_Rela));
+	  reloc.r_info[0] = R_METAG_NONE;
+	  for (; contents < (s->contents + s->size);
+	       contents += sizeof(Elf32_External_Rela))
+	    {
+	      memcpy(contents, &reloc, sizeof(Elf32_External_Rela));
+	    }
+	}
+    }
+
+  if (htab->etab.dynamic_sections_created)
+    {
+      /* Add some entries to the .dynamic section.  We fill in the
+	 values later, in elf_metag_finish_dynamic_sections, but we
+	 must add the entries now so that we get the correct size for
+	 the .dynamic section.  The DT_DEBUG entry is filled in by the
+	 dynamic linker and used by the debugger.  */
+#define add_dynamic_entry(TAG, VAL) \
+  _bfd_elf_add_dynamic_entry (info, TAG, VAL)
+
+      if (!add_dynamic_entry (DT_PLTGOT, 0))
+	return FALSE;
+
+      if (info->executable)
+	{
+	  if (!add_dynamic_entry (DT_DEBUG, 0))
+	    return FALSE;
+	}
+
+      if (htab->srelplt->size != 0)
+	{
+	  if (!add_dynamic_entry (DT_PLTRELSZ, 0)
+	      || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+	      || !add_dynamic_entry (DT_JMPREL, 0))
+	    return FALSE;
+	}
+
+      if (relocs)
+	{
+	  if (!add_dynamic_entry (DT_RELA, 0)
+	      || !add_dynamic_entry (DT_RELASZ, 0)
+	      || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
+	    return FALSE;
+
+	  /* If any dynamic relocs apply to a read-only section,
+	     then we need a DT_TEXTREL entry.  */
+	  if ((info->flags & DF_TEXTREL) == 0)
+	    elf_link_hash_traverse (&htab->etab, readonly_dynrelocs, info);
+
+	  if ((info->flags & DF_TEXTREL) != 0)
+	    {
+	      if (!add_dynamic_entry (DT_TEXTREL, 0))
+		return FALSE;
+	    }
+	}
+    }
+#undef add_dynamic_entry
+
+  return TRUE;
+}
+
+/* Finish up dynamic symbol handling.  We set the contents of various
+   dynamic sections here.  */
+
+static bfd_boolean
+elf_metag_finish_dynamic_symbol (bfd *output_bfd,
+				 struct bfd_link_info *info,
+				 struct elf_link_hash_entry *eh,
+				 Elf_Internal_Sym *sym)
+{
+  struct elf_metag_link_hash_table *htab;
+  Elf_Internal_Rela rel;
+  bfd_byte *loc;
+
+  htab = metag_link_hash_table (info);
+
+  if (eh->plt.offset != (bfd_vma) -1)
+    {
+      asection *splt;
+      asection *sgot;
+      asection *srela;
+
+      bfd_vma plt_index;
+      bfd_vma got_offset;
+      bfd_vma got_entry;
+
+      if (eh->plt.offset & 1)
+	abort ();
+
+      BFD_ASSERT (eh->dynindx != -1);
+
+      splt = htab->splt;
+      sgot = htab->sgotplt;
+      srela = htab->srelplt;
+      BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL);
+
+      /* Get the index in the procedure linkage table which
+	 corresponds to this symbol.  This is the index of this symbol
+	 in all the symbols for which we are making plt entries.  The
+	 first entry in the procedure linkage table is reserved.  */
+      plt_index = eh->plt.offset / PLT_ENTRY_SIZE - 1;
+
+      /* Get the offset into the .got.plt table of the entry that
+	 corresponds to this function.  */
+      got_offset = plt_index * GOT_ENTRY_SIZE;
+
+      BFD_ASSERT (got_offset < (1 << 16));
+
+      got_entry = sgot->output_section->vma
+	+ sgot->output_offset
+	+ got_offset;
+
+      BFD_ASSERT (plt_index < (1 << 16));
+
+      /* Fill in the entry in the procedure linkage table.  */
+      if (! info->shared)
+	{
+	  bfd_put_32 (output_bfd,
+		      (plt_entry[0]
+		       | (((got_entry >> 16) & 0xffff) << 3)),
+		      splt->contents + eh->plt.offset);
+	  bfd_put_32 (output_bfd,
+		      (plt_entry[1]
+		       | ((got_entry & 0xffff) << 3)),
+		      splt->contents + eh->plt.offset + 4);
+	  bfd_put_32 (output_bfd, plt_entry[2],
+		      splt->contents + eh->plt.offset + 8);
+	  bfd_put_32 (output_bfd,
+		      (plt_entry[3] | (plt_index << 3)),
+		      splt->contents + eh->plt.offset + 12);
+	  bfd_put_32 (output_bfd,
+		      (plt_entry[4]
+		       | ((((unsigned int) ((- (eh->plt.offset + 16)) >> 2)) & 0x7ffff) << 5)),
+		      splt->contents + eh->plt.offset + 16);
+	}
+      else
+	{
+	  bfd_vma addr = got_entry - (splt->output_section->vma +
+				      splt->output_offset + eh->plt.offset);
+
+	  bfd_put_32 (output_bfd,
+		      plt_pic_entry[0] | (((addr >> 16) & 0xffff) << 3),
+		      splt->contents + eh->plt.offset);
+	  bfd_put_32 (output_bfd,
+		      plt_pic_entry[1] | ((addr & 0xffff) << 3),
+		      splt->contents + eh->plt.offset + 4);
+	  bfd_put_32 (output_bfd, plt_pic_entry[2],
+		      splt->contents + eh->plt.offset + 8);
+	  bfd_put_32 (output_bfd,
+		      (plt_pic_entry[3] | (plt_index << 3)),
+		      splt->contents + eh->plt.offset + 12);
+	  bfd_put_32 (output_bfd,
+		      (plt_pic_entry[4]
+		       + ((((unsigned int) ((- (eh->plt.offset + 16)) >> 2)) & 0x7ffff) << 5)),
+		      splt->contents + eh->plt.offset + 16);
+	}
+
+      /* Fill in the entry in the global offset table.  */
+      bfd_put_32 (output_bfd,
+		  (splt->output_section->vma
+		   + splt->output_offset
+		   + eh->plt.offset
+		   + 12), /* offset within PLT entry */
+		  sgot->contents + got_offset);
+
+      /* Fill in the entry in the .rela.plt section.  */
+      rel.r_offset = (sgot->output_section->vma
+		      + sgot->output_offset
+		      + got_offset);
+      rel.r_info = ELF32_R_INFO (eh->dynindx, R_METAG_JMP_SLOT);
+      rel.r_addend = 0;
+      loc = htab->srelplt->contents;
+      loc += plt_index * sizeof(Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
+
+      if (!eh->def_regular)
+	{
+	  /* Mark the symbol as undefined, rather than as defined in
+	     the .plt section.  Leave the value alone.  */
+	  sym->st_shndx = SHN_UNDEF;
+	}
+    }
+
+  if (eh->got.offset != (bfd_vma) -1
+      && (metag_elf_hash_entry (eh)->tls_type & GOT_TLS_GD) == 0
+      && (metag_elf_hash_entry (eh)->tls_type & GOT_TLS_IE) == 0)
+    {
+      /* This symbol has an entry in the global offset table.  Set it
+	 up.  */
+
+      rel.r_offset = ((eh->got.offset &~ (bfd_vma) 1)
+		      + htab->sgot->output_offset
+		      + htab->sgot->output_section->vma);
+
+      /* If this is a -Bsymbolic link and the symbol is defined
+	 locally or was forced to be local because of a version file,
+	 we just want to emit a RELATIVE reloc.  The entry in the
+	 global offset table will already have been initialized in the
+	 relocate_section function.  */
+      if (info->shared
+	  && (info->symbolic || eh->dynindx == -1)
+	  && eh->def_regular)
+	{
+	  rel.r_info = ELF32_R_INFO (0, R_METAG_RELATIVE);
+	  rel.r_addend = (eh->root.u.def.value
+			  + eh->root.u.def.section->output_offset
+			  + eh->root.u.def.section->output_section->vma);
+	}
+      else
+	{
+	  if ((eh->got.offset & 1) != 0)
+	    abort ();
+	  bfd_put_32 (output_bfd, 0, htab->sgot->contents + eh->got.offset);
+	  rel.r_info = ELF32_R_INFO (eh->dynindx, R_METAG_GLOB_DAT);
+	  rel.r_addend = 0;
+	}
+
+      loc = htab->srelgot->contents;
+      loc += htab->srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
+    }
+
+  if (eh->needs_copy)
+    {
+      asection *s;
+
+      /* This symbol needs a copy reloc.  Set it up.  */
+
+      if (! (eh->dynindx != -1
+	     && (eh->root.type == bfd_link_hash_defined
+		 || eh->root.type == bfd_link_hash_defweak)))
+	abort ();
+
+      s = htab->srelbss;
+
+      rel.r_offset = (eh->root.u.def.value
+		      + eh->root.u.def.section->output_offset
+		      + eh->root.u.def.section->output_section->vma);
+      rel.r_addend = 0;
+      rel.r_info = ELF32_R_INFO (eh->dynindx, R_METAG_COPY);
+      loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
+    }
+
+  /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
+  if (eh->root.root.string[0] == '_'
+      && (strcmp (eh->root.root.string, "_DYNAMIC") == 0
+	  || eh == htab->etab.hgot))
+    {
+      sym->st_shndx = SHN_ABS;
+    }
+
+  return TRUE;
+}
+
+/* Set the Meta ELF ABI version.  */
+
+static void
+elf_metag_post_process_headers (bfd * abfd, struct bfd_link_info * link_info ATTRIBUTE_UNUSED)
+{
+  Elf_Internal_Ehdr * i_ehdrp;	/* ELF file header, internal form.  */
+
+  i_ehdrp = elf_elfheader (abfd);
+  i_ehdrp->e_ident[EI_ABIVERSION] = METAG_ELF_ABI_VERSION;
+}
+
+/* Used to decide how to sort relocs in an optimal manner for the
+   dynamic linker, before writing them out.  */
+
+static enum elf_reloc_type_class
+elf_metag_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			    const asection *rel_sec ATTRIBUTE_UNUSED,
+			    const Elf_Internal_Rela *rela)
+{
+  switch ((int) ELF32_R_TYPE (rela->r_info))
+    {
+    case R_METAG_RELATIVE:
+      return reloc_class_relative;
+    case R_METAG_JMP_SLOT:
+      return reloc_class_plt;
+    case R_METAG_COPY:
+      return reloc_class_copy;
+    default:
+      return reloc_class_normal;
+    }
+}
+
+/* Finish up the dynamic sections.  */
+
+static bfd_boolean
+elf_metag_finish_dynamic_sections (bfd *output_bfd,
+				   struct bfd_link_info *info)
+{
+  bfd *dynobj;
+  struct elf_metag_link_hash_table *htab;
+  asection *sdyn;
+
+  htab = metag_link_hash_table (info);
+  dynobj = htab->etab.dynobj;
+
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
+
+  if (htab->etab.dynamic_sections_created)
+    {
+      asection *splt;
+      Elf32_External_Dyn *dyncon, *dynconend;
+
+      if (sdyn == NULL)
+	abort ();
+
+      dyncon = (Elf32_External_Dyn *) sdyn->contents;
+      dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size);
+      for (; dyncon < dynconend; dyncon++)
+	{
+	  Elf_Internal_Dyn dyn;
+	  asection *s;
+
+	  bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
+
+	  switch (dyn.d_tag)
+	    {
+	    default:
+	      continue;
+
+	    case DT_PLTGOT:
+	      s = htab->sgot->output_section;
+	      BFD_ASSERT (s != NULL);
+	      dyn.d_un.d_ptr = s->vma + htab->sgot->output_offset;
+	      bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+	      break;
+
+	    case DT_JMPREL:
+	      s = htab->srelplt->output_section;
+	      BFD_ASSERT (s != NULL);
+	      dyn.d_un.d_ptr = s->vma;
+	      bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+	      break;
+
+	    case DT_PLTRELSZ:
+	      s = htab->srelplt;
+	      dyn.d_un.d_val = s->size;
+	      bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+	      break;
+
+	    case DT_RELASZ:
+	      /* Don't count procedure linkage table relocs in the
+		 overall reloc count.  */
+	      if (htab->srelplt) {
+		s = htab->srelplt;
+		dyn.d_un.d_val -= s->size;
+	      }
+	      bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+	      break;
+
+	    case DT_RELA:
+	      /* We may not be using the standard ELF linker script.
+		 If .rela.plt is the first .rela section, we adjust
+		 DT_RELA to not include it.  */
+	      if (htab->srelplt) {
+		s = htab->srelplt;
+		if (dyn.d_un.d_ptr == s->output_section->vma + s->output_offset)
+		  dyn.d_un.d_ptr += s->size;
+	      }
+	      bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+	      break;
+	    }
+
+	}
+
+      /* Fill in the first entry in the procedure linkage table.  */
+      splt = htab->splt;
+      if (splt && splt->size > 0)
+	{
+	  unsigned long addr;
+	  /* addr = .got + 4 */
+	  addr = htab->sgot->output_section->vma +
+	    htab->sgot->output_offset + 4;
+	  if (info->shared)
+	    {
+	      addr -= splt->output_section->vma + splt->output_offset;
+	      bfd_put_32 (output_bfd,
+			  plt0_pic_entry[0] | (((addr >> 16) & 0xffff) << 3),
+			  splt->contents);
+	      bfd_put_32 (output_bfd,
+			  plt0_pic_entry[1] | ((addr & 0xffff) << 3),
+			  splt->contents + 4);
+	      bfd_put_32 (output_bfd, plt0_pic_entry[2], splt->contents + 8);
+	      bfd_put_32 (output_bfd, plt0_pic_entry[3], splt->contents + 12);
+	      bfd_put_32 (output_bfd, plt0_pic_entry[4], splt->contents + 16);
+	    }
+	  else
+	    {
+	      bfd_put_32 (output_bfd,
+			  plt0_entry[0] | (((addr >> 16) & 0xffff) << 3),
+			  splt->contents);
+	      bfd_put_32 (output_bfd,
+			  plt0_entry[1] | ((addr & 0xffff) << 3),
+			  splt->contents + 4);
+	      bfd_put_32 (output_bfd, plt0_entry[2], splt->contents + 8);
+	      bfd_put_32 (output_bfd, plt0_entry[3], splt->contents + 12);
+	      bfd_put_32 (output_bfd, plt0_entry[4], splt->contents + 16);
+	    }
+
+	  elf_section_data (splt->output_section)->this_hdr.sh_entsize =
+	    PLT_ENTRY_SIZE;
+	}
+    }
+
+  if (htab->sgot != NULL && htab->sgot->size != 0)
+    {
+      /* Fill in the first entry in the global offset table.
+	 We use it to point to our dynamic section, if we have one.  */
+      bfd_put_32 (output_bfd,
+		  sdyn ? sdyn->output_section->vma + sdyn->output_offset : 0,
+		  htab->sgot->contents);
+
+      /* The second entry is reserved for use by the dynamic linker.  */
+      memset (htab->sgot->contents + GOT_ENTRY_SIZE, 0, GOT_ENTRY_SIZE);
+
+      /* Set .got entry size.  */
+      elf_section_data (htab->sgot->output_section)
+	->this_hdr.sh_entsize = GOT_ENTRY_SIZE;
+    }
+
+  return TRUE;
+}
+
+/* Return the section that should be marked against GC for a given
+   relocation.  */
+
+static asection *
+elf_metag_gc_mark_hook (asection *sec,
+			struct bfd_link_info *info,
+			Elf_Internal_Rela *rela,
+			struct elf_link_hash_entry *hh,
+			Elf_Internal_Sym *sym)
+{
+  if (hh != NULL)
+    switch ((unsigned int) ELF32_R_TYPE (rela->r_info))
+      {
+      case R_METAG_GNU_VTINHERIT:
+      case R_METAG_GNU_VTENTRY:
+	return NULL;
+      }
+
+  return _bfd_elf_gc_mark_hook (sec, info, rela, hh, sym);
+}
+
+/* Update the got and plt entry reference counts for the section being
+   removed.  */
+
+static bfd_boolean
+elf_metag_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
+			 struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			 asection *sec ATTRIBUTE_UNUSED,
+			 const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED)
+{
+  Elf_Internal_Shdr *symtab_hdr;
+  struct elf_link_hash_entry **eh_syms;
+  bfd_signed_vma *local_got_refcounts;
+  bfd_signed_vma *local_plt_refcounts;
+  const Elf_Internal_Rela *rel, *relend;
+
+  if (info->relocatable)
+    return TRUE;
+
+  elf_section_data (sec)->local_dynrel = NULL;
+
+  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+  eh_syms = elf_sym_hashes (abfd);
+  local_got_refcounts = elf_local_got_refcounts (abfd);
+  local_plt_refcounts = local_got_refcounts;
+  if (local_plt_refcounts != NULL)
+    local_plt_refcounts += symtab_hdr->sh_info;
+
+  relend = relocs + sec->reloc_count;
+  for (rel = relocs; rel < relend; rel++)
+    {
+      unsigned long r_symndx;
+      unsigned int r_type;
+      struct elf_link_hash_entry *eh = NULL;
+
+      r_symndx = ELF32_R_SYM (rel->r_info);
+      if (r_symndx >= symtab_hdr->sh_info)
+	{
+	  struct elf_metag_link_hash_entry *hh;
+	  struct elf_metag_dyn_reloc_entry **hdh_pp;
+	  struct elf_metag_dyn_reloc_entry *hdh_p;
+
+	  eh = eh_syms[r_symndx - symtab_hdr->sh_info];
+	  while (eh->root.type == bfd_link_hash_indirect
+		 || eh->root.type == bfd_link_hash_warning)
+	    eh = (struct elf_link_hash_entry *) eh->root.u.i.link;
+	  hh = (struct elf_metag_link_hash_entry *) eh;
+
+	  for (hdh_pp = &hh->dyn_relocs; (hdh_p = *hdh_pp) != NULL;
+	       hdh_pp = &hdh_p->hdh_next)
+	    if (hdh_p->sec == sec)
+	      {
+		/* Everything must go for SEC.  */
+		*hdh_pp = hdh_p->hdh_next;
+		break;
+	      }
+	}
+
+      r_type = ELF32_R_TYPE (rel->r_info);
+      switch (r_type)
+	{
+	case R_METAG_TLS_LDM:
+	  if (metag_link_hash_table (info)->tls_ldm_got.refcount > 0)
+	    metag_link_hash_table (info)->tls_ldm_got.refcount -= 1;
+	  break;
+	case R_METAG_TLS_IE:
+	case R_METAG_TLS_GD:
+	case R_METAG_GETSET_GOT:
+	  if (eh != NULL)
+	    {
+	      if (eh->got.refcount > 0)
+		eh->got.refcount -= 1;
+	    }
+	  else if (local_got_refcounts != NULL)
+	    {
+	      if (local_got_refcounts[r_symndx] > 0)
+		local_got_refcounts[r_symndx] -= 1;
+	    }
+	  break;
+
+	case R_METAG_RELBRANCH_PLT:
+	  if (eh != NULL)
+	    {
+	      if (eh->plt.refcount > 0)
+		eh->plt.refcount -= 1;
+	    }
+	  break;
+
+	case R_METAG_ADDR32:
+	case R_METAG_HIADDR16:
+	case R_METAG_LOADDR16:
+	case R_METAG_GETSETOFF:
+	case R_METAG_RELBRANCH:
+	  if (eh != NULL)
+	    {
+	      struct elf_metag_link_hash_entry *hh;
+	      struct elf_metag_dyn_reloc_entry **hdh_pp;
+	      struct elf_metag_dyn_reloc_entry *hdh_p;
+
+	      if (!info->shared && eh->plt.refcount > 0)
+		eh->plt.refcount -= 1;
+
+	      hh = (struct elf_metag_link_hash_entry *) eh;
+
+	      for (hdh_pp = &hh->dyn_relocs; (hdh_p = *hdh_pp) != NULL;
+		   hdh_pp = &hdh_p->hdh_next)
+		if (hdh_p->sec == sec)
+		  {
+		    if (ELF32_R_TYPE (rel->r_info) == R_METAG_RELBRANCH)
+		      hdh_p->relative_count -= 1;
+		    hdh_p->count -= 1;
+		    if (hdh_p->count == 0)
+		      *hdh_pp = hdh_p->hdh_next;
+		    break;
+		  }
+	    }
+	  break;
+
+	default:
+	  break;
+	}
+    }
+
+  return TRUE;
+}
+
+/* Determine the type of stub needed, if any, for a call.  */
+
+static enum elf_metag_stub_type
+metag_type_of_stub (asection *input_sec,
+		    const Elf_Internal_Rela *rel,
+		    struct elf_metag_link_hash_entry *hh,
+		    bfd_vma destination,
+		    struct bfd_link_info *info ATTRIBUTE_UNUSED)
+{
+  bfd_vma location;
+  bfd_vma branch_offset;
+  bfd_vma max_branch_offset;
+
+  if (hh != NULL &&
+      !(hh->eh.root.type == bfd_link_hash_defined
+	|| hh->eh.root.type == bfd_link_hash_defweak))
+    return metag_stub_none;
+
+  /* Determine where the call point is.  */
+  location = (input_sec->output_offset
+	      + input_sec->output_section->vma
+	      + rel->r_offset);
+
+  branch_offset = destination - location;
+
+  /* Determine if a long branch stub is needed.  Meta branch offsets
+     are signed 19 bits 4 byte aligned.  */
+  max_branch_offset = (1 << (BRANCH_BITS-1)) << 2;
+
+  if (branch_offset + max_branch_offset >= 2*max_branch_offset)
+    {
+      if (info->shared)
+	return metag_stub_long_branch_shared;
+      else
+	return metag_stub_long_branch;
+    }
+
+  return metag_stub_none;
+}
+
+#define MOVT_A0_3	0x82180005
+#define JUMP_A0_3	0xac180003
+
+#define MOVT_A1LBP	0x83080005
+#define ADD_A1LBP	0x83080000
+
+#define ADDT_A0_3_CPC	0x82980001
+#define ADD_A0_3_A0_3	0x82180000
+#define MOV_PC_A0_3	0xa3180ca0
+
+static bfd_boolean
+metag_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg ATTRIBUTE_UNUSED)
+{
+  struct elf_metag_stub_hash_entry *hsh;
+  asection *stub_sec;
+  bfd *stub_bfd;
+  bfd_byte *loc;
+  bfd_vma sym_value;
+  int size;
+
+  /* Massage our args to the form they really have.  */
+  hsh = (struct elf_metag_stub_hash_entry *) gen_entry;
+
+  stub_sec = hsh->stub_sec;
+
+  /* Make a note of the offset within the stubs for this entry.  */
+  hsh->stub_offset = stub_sec->size;
+  loc = stub_sec->contents + hsh->stub_offset;
+
+  stub_bfd = stub_sec->owner;
+
+  switch (hsh->stub_type)
+    {
+    case metag_stub_long_branch_shared:
+      /* A PIC long branch stub is an ADDT and an ADD instruction used to
+	 calculate the jump target using A0.3 as a temporary. Then a MOV
+	 to PC carries out the jump.  */
+      sym_value = (hsh->target_value
+		   + hsh->target_section->output_offset
+		   + hsh->target_section->output_section->vma
+		   + hsh->addend);
+
+      sym_value -= (hsh->stub_offset
+		    + stub_sec->output_offset
+		    + stub_sec->output_section->vma);
+
+      bfd_put_32 (stub_bfd, ADDT_A0_3_CPC | (((sym_value >> 16) & 0xffff) << 3),
+		  loc);
+
+      bfd_put_32 (stub_bfd, ADD_A0_3_A0_3 | ((sym_value & 0xffff) << 3),
+		  loc + 4);
+
+      bfd_put_32 (stub_bfd, MOV_PC_A0_3, loc + 8);
+
+      size = 12;
+      break;
+    case metag_stub_long_branch:
+      /* A standard long branch stub is a MOVT instruction followed by a
+	 JUMP instruction using the A0.3 register as a temporary. This is
+	 the same method used by the LDLK linker (patch.c).  */
+      sym_value = (hsh->target_value
+		   + hsh->target_section->output_offset
+		   + hsh->target_section->output_section->vma
+		   + hsh->addend);
+
+      bfd_put_32 (stub_bfd, MOVT_A0_3 | (((sym_value >> 16) & 0xffff) << 3),
+		  loc);
+
+      bfd_put_32 (stub_bfd, JUMP_A0_3 | ((sym_value & 0xffff) << 3), loc + 4);
+
+      size = 8;
+      break;
+    default:
+      BFD_FAIL ();
+      return FALSE;
+    }
+
+  stub_sec->size += size;
+  return TRUE;
+}
+
+/* As above, but don't actually build the stub.  Just bump offset so
+   we know stub section sizes.  */
+
+static bfd_boolean
+metag_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg ATTRIBUTE_UNUSED)
+{
+  struct elf_metag_stub_hash_entry *hsh;
+  int size = 0;
+
+  /* Massage our args to the form they really have.  */
+  hsh = (struct elf_metag_stub_hash_entry *) gen_entry;
+
+  if (hsh->stub_type == metag_stub_long_branch)
+    size = 8;
+  else if (hsh->stub_type == metag_stub_long_branch_shared)
+    size = 12;
+
+  hsh->stub_sec->size += size;
+  return TRUE;
+}
+
+/* Set up various things so that we can make a list of input sections
+   for each output section included in the link.  Returns -1 on error,
+   0 when no stubs will be needed, and 1 on success.  */
+
+int
+elf_metag_setup_section_lists (bfd *output_bfd, struct bfd_link_info *info)
+{
+  bfd *input_bfd;
+  unsigned int bfd_count;
+  int top_id, top_index;
+  asection *section;
+  asection **input_list, **list;
+  bfd_size_type amt;
+  struct elf_metag_link_hash_table *htab = metag_link_hash_table (info);
+
+  /* Count the number of input BFDs and find the top input section id.  */
+  for (input_bfd = info->input_bfds, bfd_count = 0, top_id = 0;
+       input_bfd != NULL;
+       input_bfd = input_bfd->link_next)
+    {
+      bfd_count += 1;
+      for (section = input_bfd->sections;
+	   section != NULL;
+	   section = section->next)
+	{
+	  if (top_id < section->id)
+	    top_id = section->id;
+	}
+    }
+
+  htab->bfd_count = bfd_count;
+
+  amt = sizeof (struct map_stub) * (top_id + 1);
+  htab->stub_group = bfd_zmalloc (amt);
+  if (htab->stub_group == NULL)
+    return -1;
+
+  /* We can't use output_bfd->section_count here to find the top output
+     section index as some sections may have been removed, and
+     strip_excluded_output_sections doesn't renumber the indices.  */
+  for (section = output_bfd->sections, top_index = 0;
+       section != NULL;
+       section = section->next)
+    {
+      if (top_index < section->index)
+	top_index = section->index;
+    }
+
+  htab->top_index = top_index;
+  amt = sizeof (asection *) * (top_index + 1);
+  input_list = bfd_malloc (amt);
+  htab->input_list = input_list;
+  if (input_list == NULL)
+    return -1;
+
+  /* For sections we aren't interested in, mark their entries with a
+     value we can check later.  */
+  list = input_list + top_index;
+  do
+    *list = bfd_abs_section_ptr;
+  while (list-- != input_list);
+
+  for (section = output_bfd->sections;
+       section != NULL;
+       section = section->next)
+    {
+      /* FIXME: This is a bit of hack. Currently our .ctors and .dtors
+       * have PC relative relocs in them but no code flag set.  */
+      if (((section->flags & SEC_CODE) != 0) ||
+	  strcmp(".ctors", section->name) ||
+	  strcmp(".dtors", section->name))
+	input_list[section->index] = NULL;
+    }
+
+  return 1;
+}
+
+/* The linker repeatedly calls this function for each input section,
+   in the order that input sections are linked into output sections.
+   Build lists of input sections to determine groupings between which
+   we may insert linker stubs.  */
+
+void
+elf_metag_next_input_section (struct bfd_link_info *info, asection *isec)
+{
+  struct elf_metag_link_hash_table *htab = metag_link_hash_table (info);
+
+  if (isec->output_section->index <= htab->top_index)
+    {
+      asection **list = htab->input_list + isec->output_section->index;
+      if (*list != bfd_abs_section_ptr)
+	{
+	  /* Steal the link_sec pointer for our list.  */
+#define PREV_SEC(sec) (htab->stub_group[(sec)->id].link_sec)
+	  /* This happens to make the list in reverse order,
+	     which is what we want.  */
+	  PREV_SEC (isec) = *list;
+	  *list = isec;
+	}
+    }
+}
+
+/* See whether we can group stub sections together.  Grouping stub
+   sections may result in fewer stubs.  More importantly, we need to
+   put all .init* and .fini* stubs at the beginning of the .init or
+   .fini output sections respectively, because glibc splits the
+   _init and _fini functions into multiple parts.  Putting a stub in
+   the middle of a function is not a good idea.  */
+
+static void
+group_sections (struct elf_metag_link_hash_table *htab,
+		bfd_size_type stub_group_size,
+		bfd_boolean stubs_always_before_branch)
+{
+  asection **list = htab->input_list + htab->top_index;
+  do
+    {
+      asection *tail = *list;
+      if (tail == bfd_abs_section_ptr)
+	continue;
+      while (tail != NULL)
+	{
+	  asection *curr;
+	  asection *prev;
+	  bfd_size_type total;
+	  bfd_boolean big_sec;
+
+	  curr = tail;
+	  total = tail->size;
+	  big_sec = total >= stub_group_size;
+
+	  while ((prev = PREV_SEC (curr)) != NULL
+		 && ((total += curr->output_offset - prev->output_offset)
+		     < stub_group_size))
+	    curr = prev;
+
+	  /* OK, the size from the start of CURR to the end is less
+	     than stub_group_size bytes and thus can be handled by one stub
+	     section.  (or the tail section is itself larger than
+	     stub_group_size bytes, in which case we may be toast.)
+	     We should really be keeping track of the total size of
+	     stubs added here, as stubs contribute to the final output
+	     section size.  */
+	  do
+	    {
+	      prev = PREV_SEC (tail);
+	      /* Set up this stub group.  */
+	      htab->stub_group[tail->id].link_sec = curr;
+	    }
+	  while (tail != curr && (tail = prev) != NULL);
+
+	  /* But wait, there's more!  Input sections up to stub_group_size
+	     bytes before the stub section can be handled by it too.
+	     Don't do this if we have a really large section after the
+	     stubs, as adding more stubs increases the chance that
+	     branches may not reach into the stub section.  */
+	  if (!stubs_always_before_branch && !big_sec)
+	    {
+	      total = 0;
+	      while (prev != NULL
+		     && ((total += tail->output_offset - prev->output_offset)
+			 < stub_group_size))
+		{
+		  tail = prev;
+		  prev = PREV_SEC (tail);
+		  htab->stub_group[tail->id].link_sec = curr;
+		}
+	    }
+	  tail = prev;
+	}
+    }
+  while (list-- != htab->input_list);
+  free (htab->input_list);
+#undef PREV_SEC
+}
+
+/* Read in all local syms for all input bfds.
+   Returns -1 on error, 0 otherwise.  */
+
+static int
+get_local_syms (bfd *output_bfd ATTRIBUTE_UNUSED, bfd *input_bfd,
+		struct bfd_link_info *info)
+{
+  unsigned int bfd_indx;
+  Elf_Internal_Sym *local_syms, **all_local_syms;
+  int stub_changed = 0;
+  struct elf_metag_link_hash_table *htab = metag_link_hash_table (info);
+
+  /* We want to read in symbol extension records only once.  To do this
+     we need to read in the local symbols in parallel and save them for
+     later use; so hold pointers to the local symbols in an array.  */
+  bfd_size_type amt = sizeof (Elf_Internal_Sym *) * htab->bfd_count;
+  all_local_syms = bfd_zmalloc (amt);
+  htab->all_local_syms = all_local_syms;
+  if (all_local_syms == NULL)
+    return -1;
+
+  /* Walk over all the input BFDs, swapping in local symbols.  */
+  for (bfd_indx = 0;
+       input_bfd != NULL;
+       input_bfd = input_bfd->link_next, bfd_indx++)
+    {
+      Elf_Internal_Shdr *symtab_hdr;
+
+      /* We'll need the symbol table in a second.  */
+      symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+      if (symtab_hdr->sh_info == 0)
+	continue;
+
+      /* We need an array of the local symbols attached to the input bfd.  */
+      local_syms = (Elf_Internal_Sym *) symtab_hdr->contents;
+      if (local_syms == NULL)
+	{
+	  local_syms = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
+					     symtab_hdr->sh_info, 0,
+					     NULL, NULL, NULL);
+	  /* Cache them for elf_link_input_bfd.  */
+	  symtab_hdr->contents = (unsigned char *) local_syms;
+	}
+      if (local_syms == NULL)
+	return -1;
+
+      all_local_syms[bfd_indx] = local_syms;
+    }
+
+  return stub_changed;
+}
+
+/* Determine and set the size of the stub section for a final link.
+
+The basic idea here is to examine all the relocations looking for
+PC-relative calls to a target that is unreachable with a "CALLR"
+instruction.  */
+
+/* See elf32-hppa.c and elf64-ppc.c.  */
+
+bfd_boolean
+elf_metag_size_stubs(bfd *output_bfd, bfd *stub_bfd,
+		     struct bfd_link_info *info,
+		     bfd_signed_vma group_size,
+		     asection * (*add_stub_section) (const char *, asection *),
+		     void (*layout_sections_again) (void))
+{
+  bfd_size_type stub_group_size;
+  bfd_boolean stubs_always_before_branch;
+  bfd_boolean stub_changed;
+  struct elf_metag_link_hash_table *htab = metag_link_hash_table (info);
+
+  /* Stash our params away.  */
+  htab->stub_bfd = stub_bfd;
+  htab->add_stub_section = add_stub_section;
+  htab->layout_sections_again = layout_sections_again;
+  stubs_always_before_branch = group_size < 0;
+  if (group_size < 0)
+    stub_group_size = -group_size;
+  else
+    stub_group_size = group_size;
+  if (stub_group_size == 1)
+    {
+      /* Default values.  */
+      /* FIXME: not sure what these values should be */
+      if (stubs_always_before_branch)
+	{
+	  stub_group_size = (1 << BRANCH_BITS);
+	}
+      else
+	{
+	  stub_group_size = (1 << BRANCH_BITS);
+	}
+    }
+
+  group_sections (htab, stub_group_size, stubs_always_before_branch);
+
+  switch (get_local_syms (output_bfd, info->input_bfds, info))
+    {
+    default:
+      if (htab->all_local_syms)
+	goto error_ret_free_local;
+      return FALSE;
+
+    case 0:
+      stub_changed = FALSE;
+      break;
+
+    case 1:
+      stub_changed = TRUE;
+      break;
+    }
+
+  while (1)
+    {
+      bfd *input_bfd;
+      unsigned int bfd_indx;
+      asection *stub_sec;
+
+      for (input_bfd = info->input_bfds, bfd_indx = 0;
+	   input_bfd != NULL;
+	   input_bfd = input_bfd->link_next, bfd_indx++)
+	{
+	  Elf_Internal_Shdr *symtab_hdr;
+	  asection *section;
+	  Elf_Internal_Sym *local_syms;
+
+	  /* We'll need the symbol table in a second.  */
+	  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+	  if (symtab_hdr->sh_info == 0)
+	    continue;
+
+	  local_syms = htab->all_local_syms[bfd_indx];
+
+	  /* Walk over each section attached to the input bfd.  */
+	  for (section = input_bfd->sections;
+	       section != NULL;
+	       section = section->next)
+	    {
+	      Elf_Internal_Rela *internal_relocs, *irelaend, *irela;
+
+	      /* If there aren't any relocs, then there's nothing more
+		 to do.  */
+	      if ((section->flags & SEC_RELOC) == 0
+		  || section->reloc_count == 0)
+		continue;
+
+	      /* If this section is a link-once section that will be
+		 discarded, then don't create any stubs.  */
+	      if (section->output_section == NULL
+		  || section->output_section->owner != output_bfd)
+		continue;
+
+	      /* Get the relocs.  */
+	      internal_relocs
+		= _bfd_elf_link_read_relocs (input_bfd, section, NULL, NULL,
+					     info->keep_memory);
+	      if (internal_relocs == NULL)
+		goto error_ret_free_local;
+
+	      /* Now examine each relocation.  */
+	      irela = internal_relocs;
+	      irelaend = irela + section->reloc_count;
+	      for (; irela < irelaend; irela++)
+		{
+		  unsigned int r_type, r_indx;
+		  enum elf_metag_stub_type stub_type;
+		  struct elf_metag_stub_hash_entry *hsh;
+		  asection *sym_sec;
+		  bfd_vma sym_value;
+		  bfd_vma destination;
+		  struct elf_metag_link_hash_entry *hh;
+		  char *stub_name;
+		  const asection *id_sec;
+
+		  r_type = ELF32_R_TYPE (irela->r_info);
+		  r_indx = ELF32_R_SYM (irela->r_info);
+
+		  if (r_type >= (unsigned int) R_METAG_MAX)
+		    {
+		      bfd_set_error (bfd_error_bad_value);
+		    error_ret_free_internal:
+		      if (elf_section_data (section)->relocs == NULL)
+			free (internal_relocs);
+		      goto error_ret_free_local;
+		    }
+
+		  /* Only look for stubs on CALLR and B instructions.  */
+		  if (!(r_type == (unsigned int) R_METAG_RELBRANCH ||
+			r_type == (unsigned int) R_METAG_RELBRANCH_PLT))
+		    continue;
+
+		  /* Now determine the call target, its name, value,
+		     section.  */
+		  sym_sec = NULL;
+		  sym_value = 0;
+		  destination = 0;
+		  hh = NULL;
+		  if (r_indx < symtab_hdr->sh_info)
+		    {
+		      /* It's a local symbol.  */
+		      Elf_Internal_Sym *sym;
+		      Elf_Internal_Shdr *hdr;
+		      unsigned int shndx;
+
+		      sym = local_syms + r_indx;
+		      if (ELF_ST_TYPE (sym->st_info) != STT_SECTION)
+			sym_value = sym->st_value;
+		      shndx = sym->st_shndx;
+		      if (shndx < elf_numsections (input_bfd))
+			{
+			  hdr = elf_elfsections (input_bfd)[shndx];
+			  sym_sec = hdr->bfd_section;
+			  destination = (sym_value + irela->r_addend
+					 + sym_sec->output_offset
+					 + sym_sec->output_section->vma);
+			}
+		    }
+		  else
+		    {
+		      /* It's an external symbol.  */
+		      int e_indx;
+
+		      e_indx = r_indx - symtab_hdr->sh_info;
+		      hh = ((struct elf_metag_link_hash_entry *)
+			    elf_sym_hashes (input_bfd)[e_indx]);
+
+		      while (hh->eh.root.type == bfd_link_hash_indirect
+			     || hh->eh.root.type == bfd_link_hash_warning)
+			hh = ((struct elf_metag_link_hash_entry *)
+			      hh->eh.root.u.i.link);
+
+		      if (hh->eh.root.type == bfd_link_hash_defined
+			  || hh->eh.root.type == bfd_link_hash_defweak)
+			{
+			  sym_sec = hh->eh.root.u.def.section;
+			  sym_value = hh->eh.root.u.def.value;
+			  if (hh->eh.plt.offset != (bfd_vma) -1
+			      && hh->eh.dynindx != -1
+			      && r_type == (unsigned int) R_METAG_RELBRANCH_PLT)
+			    {
+			      sym_sec = htab->splt;
+			      sym_value = hh->eh.plt.offset;
+			    }
+
+			  if (sym_sec->output_section != NULL)
+			    destination = (sym_value + irela->r_addend
+					   + sym_sec->output_offset
+					   + sym_sec->output_section->vma);
+			  else
+			    continue;
+			}
+		      else if (hh->eh.root.type == bfd_link_hash_undefweak)
+			{
+			  if (! info->shared)
+			    continue;
+			}
+		      else if (hh->eh.root.type == bfd_link_hash_undefined)
+			{
+			  if (! (info->unresolved_syms_in_objects == RM_IGNORE
+				 && (ELF_ST_VISIBILITY (hh->eh.other)
+				     == STV_DEFAULT)))
+			    continue;
+			}
+		      else
+			{
+			  bfd_set_error (bfd_error_bad_value);
+			  goto error_ret_free_internal;
+			}
+		    }
+
+		  /* Determine what (if any) linker stub is needed.  */
+		  stub_type = metag_type_of_stub (section, irela, hh,
+						  destination, info);
+		  if (stub_type == metag_stub_none)
+		    continue;
+
+		  /* Support for grouping stub sections.  */
+		  id_sec = htab->stub_group[section->id].link_sec;
+
+		  /* Get the name of this stub.  */
+		  stub_name = metag_stub_name (id_sec, sym_sec, hh, irela);
+		  if (!stub_name)
+		    goto error_ret_free_internal;
+
+		  hsh = metag_stub_hash_lookup (&htab->bstab,
+						stub_name,
+						FALSE, FALSE);
+		  if (hsh != NULL)
+		    {
+		      /* The proper stub has already been created.  */
+		      free (stub_name);
+		      continue;
+		    }
+
+		  hsh = metag_add_stub (stub_name, section, htab);
+		  if (hsh == NULL)
+		    {
+		      free (stub_name);
+		      goto error_ret_free_internal;
+		    }
+		  hsh->target_value = sym_value;
+		  hsh->target_section = sym_sec;
+		  hsh->stub_type = stub_type;
+		  hsh->hh = hh;
+		  hsh->addend = irela->r_addend;
+		  stub_changed = TRUE;
+		}
+
+	      /* We're done with the internal relocs, free them.  */
+	      if (elf_section_data (section)->relocs == NULL)
+		free (internal_relocs);
+	    }
+	}
+
+      if (!stub_changed)
+	break;
+
+      /* OK, we've added some stubs.  Find out the new size of the
+	 stub sections.  */
+      for (stub_sec = htab->stub_bfd->sections;
+	   stub_sec != NULL;
+	   stub_sec = stub_sec->next)
+	stub_sec->size = 0;
+
+      bfd_hash_traverse (&htab->bstab, metag_size_one_stub, htab);
+
+      /* Ask the linker to do its stuff.  */
+      (*htab->layout_sections_again) ();
+      stub_changed = FALSE;
+    }
+
+  free (htab->all_local_syms);
+  return TRUE;
+
+ error_ret_free_local:
+  free (htab->all_local_syms);
+  return FALSE;
+}
+
+/* Build all the stubs associated with the current output file.  The
+   stubs are kept in a hash table attached to the main linker hash
+   table.  This function is called via metagelf_finish in the linker.  */
+
+bfd_boolean
+elf_metag_build_stubs (struct bfd_link_info *info)
+{
+  asection *stub_sec;
+  struct bfd_hash_table *table;
+  struct elf_metag_link_hash_table *htab;
+
+  htab = metag_link_hash_table (info);
+
+  for (stub_sec = htab->stub_bfd->sections;
+       stub_sec != NULL;
+       stub_sec = stub_sec->next)
+    {
+      bfd_size_type size;
+
+      /* Allocate memory to hold the linker stubs.  */
+      size = stub_sec->size;
+      stub_sec->contents = bfd_zalloc (htab->stub_bfd, size);
+      if (stub_sec->contents == NULL && size != 0)
+	return FALSE;
+      stub_sec->size = 0;
+    }
+
+  /* Build the stubs as directed by the stub hash table.  */
+  table = &htab->bstab;
+  bfd_hash_traverse (table, metag_build_one_stub, info);
+
+  return TRUE;
+}
+
+/* Return TRUE if SYM represents a local label symbol.  */
+
+static bfd_boolean
+elf_metag_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED, const char *name)
+{
+  if (name[0] == '$' && name[1] == 'L')
+    return 1;
+  return _bfd_elf_is_local_label_name (abfd, name);
+}
+
+/* Return address for Ith PLT stub in section PLT, for relocation REL
+   or (bfd_vma) -1 if it should not be included.  */
+
+static bfd_vma
+elf_metag_plt_sym_val (bfd_vma i, const asection *plt,
+		       const arelent *rel ATTRIBUTE_UNUSED)
+{
+  return plt->vma + (i + 1) * PLT_ENTRY_SIZE;
+}
+
+#define ELF_ARCH		bfd_arch_metag
+#define ELF_TARGET_ID		METAG_ELF_DATA
+#define ELF_MACHINE_CODE	EM_METAG
+#define ELF_MINPAGESIZE	0x1000
+#define ELF_MAXPAGESIZE	0x4000
+#define ELF_COMMONPAGESIZE	0x1000
+
+#define TARGET_LITTLE_SYM	bfd_elf32_metag_vec
+#define TARGET_LITTLE_NAME	"elf32-metag"
+
+#define elf_symbol_leading_char '_'
+
+#define elf_info_to_howto_rel			NULL
+#define elf_info_to_howto			metag_info_to_howto_rela
+
+#define bfd_elf32_bfd_is_local_label_name	elf_metag_is_local_label_name
+#define bfd_elf32_bfd_link_hash_table_create \
+	elf_metag_link_hash_table_create
+#define bfd_elf32_bfd_link_hash_table_free	elf_metag_link_hash_table_free
+#define elf_backend_relocate_section		elf_metag_relocate_section
+#define elf_backend_gc_mark_hook		elf_metag_gc_mark_hook
+#define elf_backend_gc_sweep_hook		elf_metag_gc_sweep_hook
+#define elf_backend_check_relocs		elf_metag_check_relocs
+#define elf_backend_create_dynamic_sections	elf_metag_create_dynamic_sections
+#define elf_backend_adjust_dynamic_symbol	elf_metag_adjust_dynamic_symbol
+#define elf_backend_finish_dynamic_symbol	elf_metag_finish_dynamic_symbol
+#define elf_backend_finish_dynamic_sections	elf_metag_finish_dynamic_sections
+#define elf_backend_size_dynamic_sections	elf_metag_size_dynamic_sections
+#define elf_backend_omit_section_dynsym \
+  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
+#define elf_backend_post_process_headers	elf_metag_post_process_headers
+#define elf_backend_reloc_type_class		elf_metag_reloc_type_class
+#define elf_backend_copy_indirect_symbol	elf_metag_copy_indirect_symbol
+#define elf_backend_plt_sym_val		elf_metag_plt_sym_val
+
+#define elf_backend_can_gc_sections		1
+#define elf_backend_can_refcount		1
+#define elf_backend_got_header_size		12
+#define elf_backend_rela_normal		1
+#define elf_backend_want_got_sym		0
+#define elf_backend_want_plt_sym		0
+#define elf_backend_plt_readonly		1
+
+#define bfd_elf32_bfd_reloc_type_lookup	metag_reloc_type_lookup
+#define bfd_elf32_bfd_reloc_name_lookup	metag_reloc_name_lookup
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-metag.h b/bfd/elf32-metag.h
new file mode 100644
index 0000000..46772e0
--- /dev/null
+++ b/bfd/elf32-metag.h
@@ -0,0 +1,38 @@
+/* Meta support for 32-bit ELF
+   Copyright (C) 2013 Free Software Foundation, Inc.
+   Contributed by Imagination Technologies Ltd.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#ifndef _ELF32_METAG_H
+#define _ELF32_METAG_H
+
+extern int elf_metag_setup_section_lists
+  (bfd *, struct bfd_link_info *);
+
+extern void elf_metag_next_input_section
+  (struct bfd_link_info *, asection *);
+
+extern bfd_boolean elf_metag_size_stubs
+  (bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
+   asection * (*) (const char *, asection *), void (*) (void));
+
+extern bfd_boolean elf_metag_build_stubs
+  (struct bfd_link_info *);
+
+#endif  /* _ELF32_METAG_H */
diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
index b180dc4..4a5e80d 100644
--- a/bfd/elf32-microblaze.c
+++ b/bfd/elf32-microblaze.c
@@ -1,6 +1,6 @@
 /* Xilinx MicroBlaze-specific support for 32-bit ELF
 
-   Copyright 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -22,8 +22,8 @@
 
 int dbg = 0;
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "bfdlink.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
@@ -370,6 +370,132 @@
           0,			/* Source Mask.  */
           0x0000ffff,		/* Dest Mask.  */
           FALSE), 		/* PC relative offset?  */
+
+   /* Marker relocs for TLS.  */
+   HOWTO (R_MICROBLAZE_TLS,
+	 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_MICROBLAZE_TLS",		/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+   HOWTO (R_MICROBLAZE_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_MICROBLAZE_TLSGD",		/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+   HOWTO (R_MICROBLAZE_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_MICROBLAZE_TLSLD",		/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+   /* Computes the load module index of the load module that contains the
+      definition of its TLS sym.  */
+   HOWTO (R_MICROBLAZE_TLSDTPMOD32,
+	 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_MICROBLAZE_TLSDTPMOD32",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+   /* Computes a dtv-relative displacement, the difference between the value
+      of sym+add and the base address of the thread-local storage block that
+      contains the definition of sym, minus 0x8000.  Used for initializing GOT */
+   HOWTO (R_MICROBLAZE_TLSDTPREL32,
+	 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_MICROBLAZE_TLSDTPREL32",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+   /* Computes a dtv-relative displacement, the difference between the value
+      of sym+add and the base address of the thread-local storage block that
+      contains the definition of sym, minus 0x8000.  */
+   HOWTO (R_MICROBLAZE_TLSDTPREL64,
+	 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_MICROBLAZE_TLSDTPREL64",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+   /* Computes a tp-relative displacement, the difference between the value of
+      sym+add and the value of the thread pointer (r13).  */
+   HOWTO (R_MICROBLAZE_TLSGOTTPREL32,
+	 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_MICROBLAZE_TLSGOTTPREL32",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+   /* Computes a tp-relative displacement, the difference between the value of
+      sym+add and the value of the thread pointer (r13).  */
+   HOWTO (R_MICROBLAZE_TLSTPREL32,
+	 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_MICROBLAZE_TLSTPREL32",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
 };
 
 #ifndef NUM_ELEM
@@ -461,6 +587,27 @@
     case BFD_RELOC_MICROBLAZE_32_GOTOFF:
       microblaze_reloc = R_MICROBLAZE_GOTOFF_32;
       break;
+    case BFD_RELOC_MICROBLAZE_64_TLSGD:
+      microblaze_reloc = R_MICROBLAZE_TLSGD;
+      break;
+    case BFD_RELOC_MICROBLAZE_64_TLSLD:
+      microblaze_reloc = R_MICROBLAZE_TLSLD;
+      break;
+    case BFD_RELOC_MICROBLAZE_32_TLSDTPREL:
+      microblaze_reloc = R_MICROBLAZE_TLSDTPREL32;
+      break;
+    case BFD_RELOC_MICROBLAZE_64_TLSDTPREL:
+      microblaze_reloc = R_MICROBLAZE_TLSDTPREL64;
+      break;
+    case BFD_RELOC_MICROBLAZE_32_TLSDTPMOD:
+      microblaze_reloc = R_MICROBLAZE_TLSDTPMOD32;
+      break;
+    case BFD_RELOC_MICROBLAZE_64_TLSGOTTPREL:
+      microblaze_reloc = R_MICROBLAZE_TLSGOTTPREL32;
+      break;
+    case BFD_RELOC_MICROBLAZE_64_TLSTPREL:
+      microblaze_reloc = R_MICROBLAZE_TLSTPREL32;
+      break;
     case BFD_RELOC_MICROBLAZE_COPY:
       microblaze_reloc = R_MICROBLAZE_COPY;
       break;
@@ -550,8 +697,21 @@
   /* Track dynamic relocs copied for this symbol.  */
   struct elf32_mb_dyn_relocs *dyn_relocs;
 
+  /* TLS Reference Types for the symbol; Updated by check_relocs */
+#define TLS_GD     1  /* GD reloc. */
+#define TLS_LD     2  /* LD reloc. */
+#define TLS_TPREL  4  /* TPREL reloc, => IE. */
+#define TLS_DTPREL 8  /* DTPREL reloc, => LD. */
+#define TLS_TLS    16 /* Any TLS reloc.  */
+  unsigned char tls_mask;
+
 };
 
+#define IS_TLS_GD(x)     (x == (TLS_TLS | TLS_GD))
+#define IS_TLS_LD(x)     (x == (TLS_TLS | TLS_LD))
+#define IS_TLS_DTPREL(x) (x == (TLS_TLS | TLS_DTPREL))
+#define IS_TLS_NONE(x)   (x == 0)
+
 #define elf32_mb_hash_entry(ent) ((struct elf32_mb_link_hash_entry *)(ent))
 
 /* ELF linker hash table.  */
@@ -571,8 +731,17 @@
 
   /* Small local sym to section mapping cache.  */
   struct sym_cache sym_sec;
+
+  /* TLS Local Dynamic GOT Entry */
+  union {
+    bfd_signed_vma refcount;
+    bfd_vma offset;
+  } tlsld_got;
 };
 
+/* Nonzero if this section has TLS related relocations.  */
+#define has_tls_reloc sec_flg0
+
 /* Get the ELF linker hash table from a link_info structure.  */
 
 #define elf32_mb_hash_table(p)				\
@@ -604,6 +773,7 @@
 
       eh = (struct elf32_mb_link_hash_entry *) entry;
       eh->dyn_relocs = NULL;
+      eh->tls_mask = 0;
     }
 
   return entry;
@@ -654,6 +824,40 @@
                              + h->u.def.section->output_offset);
 }
 
+static bfd_vma
+dtprel_base (struct bfd_link_info *info)
+{
+  /* If tls_sec is NULL, we should have signalled an error already.  */
+  if (elf_hash_table (info)->tls_sec == NULL)
+    return 0;
+  return elf_hash_table (info)->tls_sec->vma;
+}
+
+/* The size of the thread control block.  */
+#define TCB_SIZE	8
+
+/* Output a simple dynamic relocation into SRELOC.  */
+
+static void
+microblaze_elf_output_dynamic_relocation (bfd *output_bfd,
+					  asection *sreloc,
+					  unsigned long reloc_index,
+					  unsigned long indx,
+					  int r_type,
+					  bfd_vma offset,
+					  bfd_vma addend)
+{
+
+  Elf_Internal_Rela rel;
+
+  rel.r_info = ELF32_R_INFO (indx, r_type);
+  rel.r_offset = offset;
+  rel.r_addend = addend;
+
+  bfd_elf32_swap_reloca_out (output_bfd, &rel,
+              (sreloc->contents + reloc_index * sizeof (Elf32_External_Rela)));
+}
+
 /* This code is taken from elf32-m32r.c
    There is some attempt to make this function usable for many architectures,
    both USE_REL and USE_RELA ['twould be nice if such a critter existed],
@@ -702,10 +906,12 @@
   Elf_Internal_Shdr *symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
   struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
   Elf_Internal_Rela *rel, *relend;
+  int endian = (bfd_little_endian (output_bfd)) ? 0 : 2;
   /* Assume success.  */
   bfd_boolean ret = TRUE;
   asection *sreloc;
   bfd_vma *local_got_offsets;
+  unsigned int tls_type;
 
   if (!microblaze_elf_howto_table[R_MICROBLAZE_max-1])
     microblaze_elf_howto_init ();
@@ -737,6 +943,8 @@
 
       h = NULL;
       r_type = ELF32_R_TYPE (rel->r_info);
+      tls_type = 0;
+
       if (r_type < 0 || r_type >= (int) R_MICROBLAZE_max)
 	{
 	  (*_bfd_error_handler) (_("%s: unknown relocation type %d"),
@@ -839,7 +1047,7 @@
 		/* Only relocate if the symbol is defined.  */
 		if (sec)
 		  {
-		    name = bfd_get_section_name (abfd, sec);
+		    name = bfd_get_section_name (sec->owner, sec);
 
 		    if (strcmp (name, ".sdata2") == 0
 			|| strcmp (name, ".sbss2") == 0)
@@ -868,7 +1076,7 @@
 					       bfd_get_filename (input_bfd),
 					       sym_name,
 					       microblaze_elf_howto_table[(int) r_type]->name,
-					       bfd_get_section_name (abfd, sec));
+					       bfd_get_section_name (sec->owner, sec));
 			/*bfd_set_error (bfd_error_bad_value); ??? why? */
 			ret = FALSE;
 			continue;
@@ -884,7 +1092,7 @@
 		/* Only relocate if the symbol is defined.  */
 		if (sec)
 		  {
-		    name = bfd_get_section_name (abfd, sec);
+		    name = bfd_get_section_name (sec->owner, sec);
 
 		    if (strcmp (name, ".sdata") == 0
 			|| strcmp (name, ".sbss") == 0)
@@ -913,7 +1121,7 @@
 					       bfd_get_filename (input_bfd),
 					       sym_name,
 					       microblaze_elf_howto_table[(int) r_type]->name,
-					       bfd_get_section_name (abfd, sec));
+					       bfd_get_section_name (sec->owner, sec));
 			/*bfd_set_error (bfd_error_bad_value); ??? why? */
 			ret = FALSE;
 			continue;
@@ -933,9 +1141,9 @@
 			     + offset + INST_WORD_SIZE);
 	      relocation += addend;
 	      bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
-			  contents + offset + 2);
+	                  contents + offset + endian);
 	      bfd_put_16 (input_bfd, relocation & 0xffff,
-			  contents + offset + 2 + INST_WORD_SIZE);
+	                  contents + offset + endian + INST_WORD_SIZE);
 	      break;
 
 	    case (int) R_MICROBLAZE_PLT_64:
@@ -952,9 +1160,9 @@
 					      + input_section->output_offset
 					      + offset + INST_WORD_SIZE);
 		    bfd_put_16 (input_bfd, (immediate >> 16) & 0xffff,
-				contents + offset + 2);
+		                contents + offset + endian);
 		    bfd_put_16 (input_bfd, immediate & 0xffff,
-				contents + offset + 2 + INST_WORD_SIZE);
+		                contents + offset + endian + INST_WORD_SIZE);
 		  }
 		else
 		  {
@@ -963,77 +1171,189 @@
 				   + offset + INST_WORD_SIZE);
 		    immediate = relocation;
 		    bfd_put_16 (input_bfd, (immediate >> 16) & 0xffff,
-				contents + offset + 2);
+		                contents + offset + endian);
 		    bfd_put_16 (input_bfd, immediate & 0xffff,
-				contents + offset + 2 + INST_WORD_SIZE);
+		                contents + offset + endian + INST_WORD_SIZE);
 		  }
 		break;
 	      }
 
+	    case (int) R_MICROBLAZE_TLSGD:
+	      tls_type = (TLS_TLS | TLS_GD);
+	      goto dogot;
+	    case (int) R_MICROBLAZE_TLSLD:
+	      tls_type = (TLS_TLS | TLS_LD);
+	    dogot:
 	    case (int) R_MICROBLAZE_GOT_64:
 	      {
+		bfd_vma *offp;
+		bfd_vma off, off2;
+		unsigned long indx;
+		bfd_vma static_value;
+
+		bfd_boolean need_relocs = FALSE;
 		if (htab->sgot == NULL)
 		  abort ();
-		if (h == NULL)
-		  {
-		    bfd_vma off;
-		    if (local_got_offsets == NULL)
-		      abort ();
-		    off = local_got_offsets[r_symndx];
-		    /* The LSB indicates whether we've already
-		       created relocation.  */
-		    if (off & 1)
-		      off &= ~1;
-		    else
-		      {
-			bfd_put_32 (output_bfd, relocation + addend,
-				    htab->sgot->contents + off);
 
-			if (info->shared)
-			  {
-			    Elf_Internal_Rela outrel;
-			    bfd_byte *loc;
-			    if (htab->srelgot == NULL)
-			      abort ();
-			    outrel.r_offset = (htab->sgot->output_section->vma
-					       + htab->sgot->output_offset
-					       + off);
-			    outrel.r_info = ELF32_R_INFO (0, R_MICROBLAZE_REL);
-			    outrel.r_addend = relocation + addend;
-			    loc = htab->srelgot->contents;
-			    loc += htab->srelgot->reloc_count++
-			      * sizeof (Elf32_External_Rela);
-			    bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
-			  }
-			local_got_offsets[r_symndx] |= 1;
-		      }
-		    relocation = htab->sgot->output_section->vma
-		      + htab->sgot->output_offset + off
-		      - htab->sgotplt->output_section->vma
-		      - htab->sgotplt->output_offset;
-		    unresolved_reloc = FALSE;
+		indx = 0;
+		offp = NULL;
+
+		/* 1. Identify GOT Offset;
+		   2. Compute Static Values
+		   3. Process Module Id, Process Offset
+		   4. Fixup Relocation with GOT offset value. */
+
+		/* 1. Determine GOT Offset to use : TLS_LD, global, local */
+		if (IS_TLS_LD (tls_type))
+		  offp = &htab->tlsld_got.offset;
+		else if (h != NULL)
+		  {
+		    if (htab->sgotplt != NULL && h->got.offset != (bfd_vma) -1)
+			offp = &h->got.offset;
+		    else
+			abort ();
 		  }
 		else
 		  {
-		    if (htab->sgotplt != NULL && h != NULL
-			&& h->got.offset != (bfd_vma) -1)
+		    if (local_got_offsets == NULL)
+		      abort ();
+		    offp = &local_got_offsets[r_symndx];
+		  }
+
+		if (!offp)
+		  abort ();
+
+		off = (*offp) & ~1;
+		off2 = off;
+
+		if (IS_TLS_LD(tls_type) || IS_TLS_GD(tls_type))
+		  off2 = off + 4;
+
+		/* Symbol index to use for relocs */
+		if (h != NULL)
+		  {
+		    bfd_boolean dyn =
+			elf_hash_table (info)->dynamic_sections_created;
+
+		    if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
+			&& (!info->shared || !SYMBOL_REFERENCES_LOCAL (info, h)))
+		      indx = h->dynindx;
+		  }
+
+		/* Need to generate relocs ? */
+		if ((info->shared || indx != 0)
+		    && (h == NULL
+		    || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+		    || h->root.type != bfd_link_hash_undefweak))
+		  need_relocs = TRUE;
+
+		/* 2. Compute/Emit Static value of r-expression */
+		static_value = relocation + addend;
+
+		/* 3. Process module-id and offset */
+		if (! ((*offp) & 1) )
+		  {
+		    bfd_vma got_offset;
+
+		    got_offset = (htab->sgot->output_section->vma
+				  + htab->sgot->output_offset
+				  + off);
+
+		    /* Process module-id */
+		    if (IS_TLS_LD(tls_type))
 		      {
-			bfd_put_32 (output_bfd, relocation + addend,
-				    htab->sgot->contents + h->got.offset);
-			relocation = htab->sgot->output_section->vma
-			  + htab->sgot->output_offset
-			  + h->got.offset
-			  - htab->sgotplt->output_section->vma
-			  - htab->sgotplt->output_offset;
-			unresolved_reloc = FALSE;
+			if (! info->shared)
+			  {
+			    bfd_put_32 (output_bfd, 1, htab->sgot->contents + off);
+			  }
+			else
+			  {
+			    microblaze_elf_output_dynamic_relocation (output_bfd,
+			      htab->srelgot, htab->srelgot->reloc_count++,
+			      /* symindex= */ 0, R_MICROBLAZE_TLSDTPMOD32,
+			      got_offset, 0);
+			  }
+		      }
+		    else if (IS_TLS_GD(tls_type))
+		      {
+		        if (! need_relocs)
+			  {
+			    bfd_put_32 (output_bfd, 1, htab->sgot->contents + off);
+			  }
+		        else
+			  {
+			    microblaze_elf_output_dynamic_relocation (output_bfd,
+			      htab->srelgot,
+			      htab->srelgot->reloc_count++,
+			      /* symindex= */ indx, R_MICROBLAZE_TLSDTPMOD32,
+			      got_offset, indx ? 0 : static_value);
+			  }
+		      }
+
+		    /* Process Offset */
+		    if (htab->srelgot == NULL)
+		      abort ();
+
+		    got_offset = (htab->sgot->output_section->vma
+				  + htab->sgot->output_offset
+				  + off2);
+		    if (IS_TLS_LD(tls_type))
+		      {
+		        /* For LD, offset should be 0 */
+		        *offp |= 1;
+		        bfd_put_32 (output_bfd, 0, htab->sgot->contents + off2);
+		      }
+		    else if (IS_TLS_GD(tls_type))
+		      {
+		        *offp |= 1;
+		        static_value -= dtprel_base(info);
+		        if (need_relocs)
+		          {
+			    microblaze_elf_output_dynamic_relocation (output_bfd,
+			      htab->srelgot, htab->srelgot->reloc_count++,
+			      /* symindex= */ indx, R_MICROBLAZE_TLSDTPREL32,
+			      got_offset, indx ? 0 : static_value);
+		          }
+		        else
+			  {
+			    bfd_put_32 (output_bfd, static_value,
+					htab->sgot->contents + off2);
+		          }
 		      }
 		    else
-		      abort (); /* ??? */
+		      {
+			  bfd_put_32 (output_bfd, static_value,
+				      htab->sgot->contents + off2);
+
+			  /* Relocs for dyn symbols generated by
+			     finish_dynamic_symbols */
+			  if (info->shared && h == NULL)
+			    {
+			      *offp |= 1;
+			      microblaze_elf_output_dynamic_relocation (output_bfd,
+				htab->srelgot, htab->srelgot->reloc_count++,
+				/* symindex= */ indx, R_MICROBLAZE_REL,
+				got_offset, static_value);
+			    }
+		      }
 		  }
+
+		/* 4. Fixup Relocation with GOT offset value
+		      Compute relative address of GOT entry for applying
+		      the current relocation */
+		relocation = htab->sgot->output_section->vma
+			     + htab->sgot->output_offset
+			     + off
+			     - htab->sgotplt->output_section->vma
+			     - htab->sgotplt->output_offset;
+
+		/* Apply Current Relocation */
 		bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
-			    contents + offset + 2);
+		            contents + offset + endian);
 		bfd_put_16 (input_bfd, relocation & 0xffff,
-			    contents + offset + 2 + INST_WORD_SIZE);
+		            contents + offset + endian + INST_WORD_SIZE);
+
+		unresolved_reloc = FALSE;
 		break;
 	      }
 
@@ -1048,8 +1368,8 @@
 		immediate = relocation;
 		lo = immediate & 0x0000ffff;
 		high = (immediate >> 16) & 0x0000ffff;
-		bfd_put_16 (input_bfd, high, contents + offset + 2);
-		bfd_put_16 (input_bfd, lo, contents + offset + INST_WORD_SIZE + 2);
+		bfd_put_16 (input_bfd, high, contents + offset + endian);
+		bfd_put_16 (input_bfd, lo, contents + offset + INST_WORD_SIZE + endian);
 		break;
 	      }
 
@@ -1063,6 +1383,14 @@
 		break;
 	      }
 
+	    case (int) R_MICROBLAZE_TLSDTPREL64:
+	      relocation += addend;
+	      relocation -= dtprel_base(info);
+	      bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
+			  contents + offset + 2);
+	      bfd_put_16 (input_bfd, relocation & 0xffff,
+			  contents + offset + 2 + INST_WORD_SIZE);
+	      break;
 	    case (int) R_MICROBLAZE_64_PCREL :
 	    case (int) R_MICROBLAZE_64:
 	    case (int) R_MICROBLAZE_32:
@@ -1082,9 +1410,9 @@
 					 + input_section->output_offset
 					 + offset + INST_WORD_SIZE);
 			bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
-				    contents + offset + 2);
+			            contents + offset + endian);
 			bfd_put_16 (input_bfd, relocation & 0xffff,
-				    contents + offset + 2 + INST_WORD_SIZE);
+			            contents + offset + endian + INST_WORD_SIZE);
 		      }
 		    break;
 		  }
@@ -1176,9 +1504,9 @@
 					 + input_section->output_offset
 					 + offset + INST_WORD_SIZE);
 			bfd_put_16 (input_bfd, (relocation >> 16) & 0xffff,
-				    contents + offset + 2);
+			            contents + offset + endian);
 			bfd_put_16 (input_bfd, relocation & 0xffff,
-				    contents + offset + 2 + INST_WORD_SIZE);
+			            contents + offset + endian + INST_WORD_SIZE);
 		      }
 		    break;
 		  }
@@ -1253,12 +1581,28 @@
 
   return ret;
 }
+
+/* Merge backend specific data from an object file to the output
+   object file when linking.
+
+   Note: We only use this hook to catch endian mismatches.  */
+static bfd_boolean
+microblaze_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
+{
+  /* Check if we have the same endianess.  */
+  if (! _bfd_generic_verify_endian_match (ibfd, obfd))
+    return FALSE;
+
+  return TRUE;
+}
+
 
 /* Calculate fixup value for reference.  */
 
 static int
-calc_fixup (bfd_vma addr, asection *sec)
+calc_fixup (bfd_vma start, bfd_vma size, asection *sec)
 {
+  bfd_vma end = start + size;
   int i, fixup = 0;
 
   if (sec == NULL || sec->relax == NULL)
@@ -1267,14 +1611,45 @@
   /* Look for addr in relax table, total fixup value.  */
   for (i = 0; i < sec->relax_count; i++)
     {
-      if (addr <= sec->relax[i].addr)
+      if (end <= sec->relax[i].addr)
         break;
+      if ((end != start) && (start > sec->relax[i].addr))
+        continue;
       fixup += sec->relax[i].size;
     }
-
   return fixup;
 }
 
+/* Read-modify-write into the bfd, an immediate value into appropriate fields of
+   a 32-bit instruction.  */
+static void
+microblaze_bfd_write_imm_value_32 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
+{
+    unsigned long instr = bfd_get_32 (abfd, bfd_addr);
+    instr &= ~0x0000ffff;
+    instr |= (val & 0x0000ffff);
+    bfd_put_32 (abfd, instr, bfd_addr);
+}
+
+/* Read-modify-write into the bfd, an immediate value into appropriate fields of
+   two consecutive 32-bit instructions.  */
+static void
+microblaze_bfd_write_imm_value_64 (bfd *abfd, bfd_byte *bfd_addr, bfd_vma val)
+{
+    unsigned long instr_hi;
+    unsigned long instr_lo;
+
+    instr_hi = bfd_get_32 (abfd, bfd_addr);
+    instr_hi &= ~0x0000ffff;
+    instr_hi |= ((val >> 16) & 0x0000ffff);
+    bfd_put_32 (abfd, instr_hi, bfd_addr);
+
+    instr_lo = bfd_get_32 (abfd, bfd_addr + INST_WORD_SIZE);
+    instr_lo &= ~0x0000ffff;
+    instr_lo |= (val & 0x0000ffff);
+    bfd_put_32 (abfd, instr_lo, bfd_addr + INST_WORD_SIZE);
+}
+
 static bfd_boolean
 microblaze_elf_relax_section (bfd *abfd,
 			      asection *sec,
@@ -1305,7 +1680,8 @@
   /* Only do this for a text section.  */
   if (link_info->relocatable
       || (sec->flags & SEC_RELOC) == 0
-      || (sec->reloc_count == 0))
+      || (sec->reloc_count == 0)
+      || (sec->flags & SEC_CODE) == 0)
     return TRUE;
 
   BFD_ASSERT ((sec->size > 0) || (sec->rawsize > 0));
@@ -1453,7 +1829,7 @@
 	  bfd_vma nraddr;
 
           /* Get the new reloc address.  */
-	  nraddr = irel->r_offset - calc_fixup (irel->r_offset, sec);
+	  nraddr = irel->r_offset - calc_fixup (irel->r_offset, 0, sec);
           switch ((enum elf_microblaze_reloc_type) ELF32_R_TYPE (irel->r_info))
 	    {
 	    default:
@@ -1471,7 +1847,7 @@
 		  /* Only handle relocs against .text.  */
 		  if (isym->st_shndx == shndx
 		      && ELF32_ST_TYPE (isym->st_info) == STT_SECTION)
-		    irel->r_addend -= calc_fixup (irel->r_addend, sec);
+		    irel->r_addend -= calc_fixup (irel->r_addend, 0, sec);
 	        }
 	      break;
 	    case R_MICROBLAZE_NONE:
@@ -1481,11 +1857,12 @@
 	        int sfix, efix;
 	        bfd_vma target_address;
 	        target_address = irel->r_addend + irel->r_offset;
-	        sfix = calc_fixup (irel->r_offset, sec);
-	        efix = calc_fixup (target_address, sec);
+	        sfix = calc_fixup (irel->r_offset, 0, sec);
+	        efix = calc_fixup (target_address, 0, sec);
 	        irel->r_addend -= (efix - sfix);
 	        /* Should use HOWTO.  */
-	        bfd_put_16 (abfd, irel->r_addend, contents + irel->r_offset + 2);
+	        microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset,
+	                                           irel->r_addend);
 	      }
 	      break;
 	    case R_MICROBLAZE_64_NONE:
@@ -1495,11 +1872,11 @@
 	        int sfix, efix;
 	        bfd_vma target_address;
 		target_address = irel->r_addend + irel->r_offset + INST_WORD_SIZE;
-		sfix = calc_fixup (irel->r_offset + INST_WORD_SIZE, sec);
-		efix = calc_fixup (target_address, sec);
+		sfix = calc_fixup (irel->r_offset + INST_WORD_SIZE, 0, sec);
+		efix = calc_fixup (target_address, 0, sec);
 		irel->r_addend -= (efix - sfix);
-		bfd_put_16 (abfd, irel->r_addend, contents + irel->r_offset
-			    + INST_WORD_SIZE + 2);
+    microblaze_bfd_write_imm_value_32 (abfd, contents + irel->r_offset
+                                       + INST_WORD_SIZE, irel->r_addend);
 	      }
 	      break;
 	    }
@@ -1559,7 +1936,7 @@
                             }
 
                         }
-		      irelscan->r_addend -= calc_fixup (irelscan->r_addend, sec);
+		      irelscan->r_addend -= calc_fixup (irelscan->r_addend, 0, sec);
                     }
 		  else if (ELF32_R_TYPE (irelscan->r_info) == (int) R_MICROBLAZE_32_SYM_OP_SYM)
 		    {
@@ -1590,6 +1967,7 @@
 			}
 		      irelscan->r_addend -= calc_fixup (irel->r_addend
 							+ isym->st_value,
+							0,
 							sec);
 		    }
 		}
@@ -1627,13 +2005,14 @@
 			    }
 			}
 
-		      immediate = (unsigned short) bfd_get_16 (abfd, ocontents +
-							       irelscan->r_offset + 2);
+		      unsigned long instr = bfd_get_32 (abfd, ocontents + irelscan->r_offset);
+		      immediate = instr & 0x0000ffff;
 		      target_address = immediate;
-		      offset = calc_fixup (target_address, sec);
+		      offset = calc_fixup (target_address, 0, sec);
 		      immediate -= offset;
 		      irelscan->r_addend -= offset;
-		      bfd_put_16 (abfd, immediate, ocontents + irelscan->r_offset + 2);
+          microblaze_bfd_write_imm_value_32 (abfd, ocontents + irelscan->r_offset,
+                                             irelscan->r_addend);
 		    }
 		}
 
@@ -1669,16 +2048,14 @@
 			      elf_section_data (o)->this_hdr.contents = ocontents;
 			    }
 			}
-		      immediate = (unsigned short) (bfd_get_16 (abfd, ocontents
-								+ irelscan->r_offset
-								+ 2) << 16)
-			& 0xffff0000;
-		      immediate += (unsigned short) (bfd_get_16 (abfd, ocontents
-								 + irelscan->r_offset
-								 + INST_WORD_SIZE + 2))
-			& 0x0000ffff;
-
-		      offset = calc_fixup (irelscan->r_addend, sec);
+          unsigned long instr_hi =  bfd_get_32 (abfd, ocontents
+                                                + irelscan->r_offset);
+          unsigned long instr_lo =  bfd_get_32 (abfd, ocontents
+                                                + irelscan->r_offset
+                                                + INST_WORD_SIZE);
+          immediate = (instr_hi & 0x0000ffff) << 16;
+          immediate |= (instr_lo & 0x0000ffff);
+		      offset = calc_fixup (irelscan->r_addend, 0, sec);
 		      immediate -= offset;
 		      irelscan->r_addend -= offset;
 		    }
@@ -1715,22 +2092,19 @@
 			      elf_section_data (o)->this_hdr.contents = ocontents;
 			    }
 			}
-
-		      immediate = (unsigned short)
-			(bfd_get_16 (abfd, ocontents + irelscan->r_offset + 2) << 16)
-			& 0xffff0000;
-		      immediate += (unsigned short)
-			(bfd_get_16 (abfd, ocontents + irelscan->r_offset
-				     + INST_WORD_SIZE + 2))
-			& 0x0000ffff;
+          unsigned long instr_hi =  bfd_get_32 (abfd, ocontents
+                                                + irelscan->r_offset);
+          unsigned long instr_lo =  bfd_get_32 (abfd, ocontents
+                                                + irelscan->r_offset
+                                                + INST_WORD_SIZE);
+          immediate = (instr_hi & 0x0000ffff) << 16;
+          immediate |= (instr_lo & 0x0000ffff);
 		      target_address = immediate;
-		      offset = calc_fixup (target_address, sec);
+		      offset = calc_fixup (target_address, 0, sec);
 		      immediate -= offset;
 		      irelscan->r_addend -= offset;
-		      bfd_put_16 (abfd, ((immediate >> 16) & 0x0000ffff),
-				  ocontents + irelscan->r_offset + 2);
-		      bfd_put_16 (abfd, (immediate & 0x0000ffff),
-				  ocontents + irelscan->r_offset + INST_WORD_SIZE + 2);
+          microblaze_bfd_write_imm_value_64 (abfd, ocontents
+                                             + irelscan->r_offset, immediate);
 		    }
 		}
             }
@@ -1741,24 +2115,30 @@
       for (isym = isymbuf; isym < isymend; isym++)
         {
           if (isym->st_shndx == shndx)
-	    isym->st_value =- calc_fixup (isym->st_value, sec);
+            {
+              isym->st_value -= calc_fixup (isym->st_value, 0, sec);
+              if (isym->st_size)
+                isym->st_size -= calc_fixup (isym->st_value, isym->st_size, sec);
+            }
         }
 
       /* Now adjust the global symbols defined in this section.  */
       isym = isymbuf + symtab_hdr->sh_info;
-      isymend = isymbuf + (symtab_hdr->sh_size / sizeof (Elf32_External_Sym));
-      for (sym_index = 0; isym < isymend; isym++, sym_index++)
+      symcount =  (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)) - symtab_hdr->sh_info;
+      for (sym_index = 0; sym_index < symcount; sym_index++)
         {
           sym_hash = elf_sym_hashes (abfd)[sym_index];
-          if (isym->st_shndx == shndx
-              && (sym_hash->root.type == bfd_link_hash_defined
+          if ((sym_hash->root.type == bfd_link_hash_defined
                   || sym_hash->root.type == bfd_link_hash_defweak)
               && sym_hash->root.u.def.section == sec)
-	    {
-	      sym_hash->root.u.def.value -= calc_fixup (sym_hash->root.u.def.value,
-						        sec);
-	    }
-	}
+            {
+              sym_hash->root.u.def.value -= calc_fixup (sym_hash->root.u.def.value,
+                                                        0, sec);
+              if (sym_hash->size)
+                sym_hash->size -= calc_fixup (sym_hash->root.u.def.value,
+                                              sym_hash->size, sec);
+            }
+        }
 
       /* Physically move the code and change the cooked size.  */
       dest = sec->relax[0].addr;
@@ -1800,9 +2180,12 @@
 
   if (sec->relax_count == 0)
     {
+      *again = FALSE;
       free (sec->relax);
       sec->relax = NULL;
     }
+  else
+    *again = TRUE;
   return TRUE;
 
  error_return:
@@ -1875,12 +2258,13 @@
   if (htab == NULL)
     return FALSE;
 
-  htab->sgot = bfd_get_section_by_name (dynobj, ".got");
-  htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
+  htab->sgot = bfd_get_linker_section (dynobj, ".got");
+  htab->sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
   if (!htab->sgot || !htab->sgotplt)
     return FALSE;
 
-  htab->srelgot = bfd_make_section (dynobj, ".rela.got");
+  if ((htab->srelgot = bfd_get_linker_section (dynobj, ".rela.got")) == NULL)
+    htab->srelgot = bfd_make_section_anyway (dynobj, ".rela.got");
   if (htab->srelgot == NULL
       || ! bfd_set_section_flags (dynobj, htab->srelgot, SEC_ALLOC
                                   | SEC_LOAD
@@ -1893,6 +2277,33 @@
   return TRUE;
 }
 
+static bfd_boolean
+update_local_sym_info (bfd *abfd,
+		       Elf_Internal_Shdr *symtab_hdr,
+		       unsigned long r_symndx,
+		       unsigned int tls_type)
+{
+  bfd_signed_vma *local_got_refcounts = elf_local_got_refcounts (abfd);
+  unsigned char *local_got_tls_masks;
+
+  if (local_got_refcounts == NULL)
+    {
+      bfd_size_type size = symtab_hdr->sh_info;
+
+      size *= (sizeof (*local_got_refcounts) + sizeof (*local_got_tls_masks));
+      local_got_refcounts = bfd_zalloc (abfd, size);
+      if (local_got_refcounts == NULL)
+        return FALSE;
+      elf_local_got_refcounts (abfd) = local_got_refcounts;
+    }
+
+  local_got_tls_masks =
+         (unsigned char *) (local_got_refcounts + symtab_hdr->sh_info);
+  local_got_tls_masks[r_symndx] |= tls_type;
+  local_got_refcounts[r_symndx] += 1;
+
+  return TRUE;
+}
 /* Look through the relocs for a section during the first phase.  */
 
 static bfd_boolean
@@ -1929,6 +2340,7 @@
       unsigned int r_type;
       struct elf_link_hash_entry * h;
       unsigned long r_symndx;
+      unsigned char tls_type = 0;
 
       r_symndx = ELF32_R_SYM (rel->r_info);
       r_type = ELF32_R_TYPE (rel->r_info);
@@ -1936,7 +2348,13 @@
       if (r_symndx < symtab_hdr->sh_info)
         h = NULL;
       else
-        h = sym_hashes [r_symndx - symtab_hdr->sh_info];
+	{
+	  h = sym_hashes [r_symndx - symtab_hdr->sh_info];
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
+	}
 
       switch (r_type)
         {
@@ -1964,6 +2382,13 @@
           break;
 
 	  /* This relocation requires .got entry.  */
+        case R_MICROBLAZE_TLSGD:
+          tls_type |= (TLS_TLS | TLS_GD);
+          goto dogottls;
+        case R_MICROBLAZE_TLSLD:
+          tls_type |= (TLS_TLS | TLS_LD);
+        dogottls:
+          sec->has_tls_reloc = 1;
         case R_MICROBLAZE_GOT_64:
           if (htab->sgot == NULL)
             {
@@ -1975,25 +2400,12 @@
           if (h != NULL)
 	    {
 	      h->got.refcount += 1;
+	      elf32_mb_hash_entry (h)->tls_mask |= tls_type;
 	    }
           else
 	    {
-	      bfd_signed_vma *local_got_refcounts;
-
-	      /* This is a global offset table entry for a local symbol.  */
-	      local_got_refcounts = elf_local_got_refcounts (abfd);
-	      if (local_got_refcounts == NULL)
-		{
-		  bfd_size_type size;
-
-		  size = symtab_hdr->sh_info;
-		  size *= sizeof (bfd_signed_vma);
-		  local_got_refcounts = bfd_zalloc (abfd, size);
-		  if (local_got_refcounts == NULL)
-		    return FALSE;
-		  elf_local_got_refcounts (abfd) = local_got_refcounts;
-		}
-	      local_got_refcounts[r_symndx] += 1;
+	      if (! update_local_sym_info(abfd, symtab_hdr, r_symndx, tls_type) )
+		return FALSE;
 	    }
           break;
 
@@ -2057,44 +2469,16 @@
 
 		if (sreloc == NULL)
 		  {
-		    const char *name;
 		    bfd *dynobj;
-		    unsigned int strndx = elf_elfheader (abfd)->e_shstrndx;
-		    unsigned int shnam = _bfd_elf_single_rel_hdr (sec)->sh_name;
-
-		    name = bfd_elf_string_from_elf_section (abfd, strndx, shnam);
-		    if (name == NULL)
-		      return FALSE;
-
-		    if (strncmp (name, ".rela", 5) != 0
-			|| strcmp (bfd_get_section_name (abfd, sec),
-				   name + 5) != 0)
-		      {
-			(*_bfd_error_handler)
-			  (_("%B: bad relocation section name `%s\'"),
-			   abfd, name);
-		      }
 
 		    if (htab->elf.dynobj == NULL)
 		      htab->elf.dynobj = abfd;
 		    dynobj = htab->elf.dynobj;
 
-		    sreloc = bfd_get_section_by_name (dynobj, name);
+		    sreloc = _bfd_elf_make_dynamic_reloc_section (sec, dynobj,
+								  2, abfd, 1);
 		    if (sreloc == NULL)
-		      {
-			flagword flags;
-
-			sreloc = bfd_make_section (dynobj, name);
-			flags = (SEC_HAS_CONTENTS | SEC_READONLY
-				 | SEC_IN_MEMORY | SEC_LINKER_CREATED);
-			if ((sec->flags & SEC_ALLOC) != 0)
-			  flags |= SEC_ALLOC | SEC_LOAD;
-			if (sreloc == NULL
-			    || ! bfd_set_section_flags (dynobj, sreloc, flags)
-			    || ! bfd_set_section_alignment (dynobj, sreloc, 2))
-			  return FALSE;
-		      }
-		    elf_section_data (sec)->sreloc = sreloc;
+		      return FALSE;
 		  }
 
 		/* If this is a global symbol, we count the number of
@@ -2166,11 +2550,11 @@
   if (!_bfd_elf_create_dynamic_sections (dynobj, info))
     return FALSE;
 
-  htab->splt = bfd_get_section_by_name (dynobj, ".plt");
-  htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt");
-  htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
+  htab->splt = bfd_get_linker_section (dynobj, ".plt");
+  htab->srelplt = bfd_get_linker_section (dynobj, ".rela.plt");
+  htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
   if (!info->shared)
-    htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
+    htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
 
   if (!htab->splt || !htab->srelplt || !htab->sdynbss
       || (!info->shared && !htab->srelbss))
@@ -2225,6 +2609,8 @@
       eind->dyn_relocs = NULL;
     }
 
+  edir->tls_mask |= eind->tls_mask;
+
   _bfd_elf_link_hash_copy_indirect (info, dir, ind);
 }
 
@@ -2443,8 +2829,10 @@
       h->needs_plt = 0;
     }
 
+  eh = (struct elf32_mb_link_hash_entry *) h;
   if (h->got.refcount > 0)
     {
+      unsigned int need;
       asection *s;
 
       /* Make sure this symbol is output as a dynamic symbol.
@@ -2456,15 +2844,43 @@
             return FALSE;
         }
 
-      s = htab->sgot;
-      h->got.offset = s->size;
-      s->size += 4;
-      htab->srelgot->size += sizeof (Elf32_External_Rela);
+      need = 0;
+      if ((eh->tls_mask & TLS_TLS) != 0)
+        {
+          /* Handle TLS Symbol */
+          if ((eh->tls_mask & TLS_LD) != 0)
+            {
+              if (!eh->elf.def_dynamic)
+                /* We'll just use htab->tlsld_got.offset.  This should
+                   always be the case.  It's a little odd if we have
+                   a local dynamic reloc against a non-local symbol.  */
+                htab->tlsld_got.refcount += 1;
+              else
+                need += 8;
+            }
+          if ((eh->tls_mask & TLS_GD) != 0)
+            need += 8;
+        }
+      else
+        {
+          /* Regular (non-TLS) symbol */
+          need += 4;
+        }
+      if (need == 0)
+        {
+          h->got.offset = (bfd_vma) -1;
+        }
+      else
+        {
+          s = htab->sgot;
+          h->got.offset = s->size;
+          s->size += need;
+          htab->srelgot->size += need * (sizeof (Elf32_External_Rela) / 4);
+        }
     }
   else
     h->got.offset = (bfd_vma) -1;
 
-  eh = (struct elf32_mb_link_hash_entry *) h;
   if (eh->dyn_relocs == NULL)
     return TRUE;
 
@@ -2562,6 +2978,7 @@
       bfd_signed_vma *end_local_got;
       bfd_size_type locsymcount;
       Elf_Internal_Shdr *symtab_hdr;
+      unsigned char *lgot_masks;
       asection *srel;
 
       if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
@@ -2601,17 +3018,36 @@
       symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
       locsymcount = symtab_hdr->sh_info;
       end_local_got = local_got + locsymcount;
+      lgot_masks = (unsigned char *) end_local_got;
       s = htab->sgot;
       srel = htab->srelgot;
 
-      for (; local_got < end_local_got; ++local_got)
-        {
-          if (*local_got > 0)
-            {
-              *local_got = s->size;
-              s->size += 4;
-              if (info->shared)
-                srel->size += sizeof (Elf32_External_Rela);
+      for (; local_got < end_local_got; ++local_got, ++lgot_masks)
+	{
+	  if (*local_got > 0)
+	    {
+	      unsigned int need = 0;
+	      if ((*lgot_masks & TLS_TLS) != 0)
+		{
+		  if ((*lgot_masks & TLS_GD) != 0)
+		    need += 8;
+		  if ((*lgot_masks & TLS_LD) != 0)
+		    htab->tlsld_got.refcount += 1;
+		}
+	      else
+		need += 4;
+
+	      if (need == 0)
+		{
+		  *local_got = (bfd_vma) -1;
+		}
+	      else
+		{
+		  *local_got = s->size;
+		  s->size += need;
+		  if (info->shared)
+		    srel->size += need * (sizeof (Elf32_External_Rela) / 4);
+		}
             }
           else
             *local_got = (bfd_vma) -1;
@@ -2622,6 +3058,16 @@
      sym dynamic relocs.  */
   elf_link_hash_traverse (elf_hash_table (info), allocate_dynrelocs, info);
 
+  if (htab->tlsld_got.refcount > 0)
+    {
+      htab->tlsld_got.offset = htab->sgot->size;
+      htab->sgot->size += 8;
+      if (info->shared)
+        htab->srelgot->size += sizeof (Elf32_External_Rela);
+    }
+  else
+    htab->tlsld_got.offset = (bfd_vma) -1;
+
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Make space for the trailing nop in .plt.  */
@@ -2740,6 +3186,7 @@
 				      Elf_Internal_Sym *sym)
 {
   struct elf32_mb_link_hash_table *htab;
+  struct elf32_mb_link_hash_entry *eh = elf32_mb_hash_entry(h);
 
   htab = elf32_mb_hash_table (info);
   if (htab == NULL)
@@ -2811,12 +3258,14 @@
         }
     }
 
-  if (h->got.offset != (bfd_vma) -1)
+  /* h->got.refcount to be checked ? */
+  if (h->got.offset != (bfd_vma) -1 &&
+      ! ((h->got.offset & 1) ||
+          IS_TLS_LD(eh->tls_mask) || IS_TLS_GD(eh->tls_mask)))
     {
       asection *sgot;
       asection *srela;
-      Elf_Internal_Rela rela;
-      bfd_byte *loc;
+      bfd_vma offset;
 
       /* This symbol has an entry in the global offset table.  Set it
          up.  */
@@ -2825,8 +3274,7 @@
       srela = htab->srelgot;
       BFD_ASSERT (sgot != NULL && srela != NULL);
 
-      rela.r_offset = (sgot->output_section->vma
-                       + sgot->output_offset
+      offset = (sgot->output_section->vma + sgot->output_offset
                        + (h->got.offset &~ (bfd_vma) 1));
 
       /* If this is a -Bsymbolic link, and the symbol is defined
@@ -2839,22 +3287,25 @@
           && h->def_regular)
         {
           asection *sec = h->root.u.def.section;
-          rela.r_info = ELF32_R_INFO (0, R_MICROBLAZE_REL);
-          rela.r_addend = (h->root.u.def.value
-                           + sec->output_section->vma
-                           + sec->output_offset);
+          microblaze_elf_output_dynamic_relocation (output_bfd,
+                                                    srela, srela->reloc_count++,
+                                                    /* symindex= */ 0,
+                                                    R_MICROBLAZE_REL, offset,
+                                                    h->root.u.def.value
+                                                    + sec->output_section->vma
+                                                    + sec->output_offset);
         }
       else
         {
-          rela.r_info = ELF32_R_INFO (h->dynindx, R_MICROBLAZE_GLOB_DAT);
-          rela.r_addend = 0;
+          microblaze_elf_output_dynamic_relocation (output_bfd,
+                                                    srela, srela->reloc_count++,
+                                                    h->dynindx,
+                                                    R_MICROBLAZE_GLOB_DAT,
+                                                    offset, 0);
         }
 
       bfd_put_32 (output_bfd, (bfd_vma) 0,
                   sgot->contents + (h->got.offset &~ (bfd_vma) 1));
-      loc = srela->contents;
-      loc += srela->reloc_count++ * sizeof (Elf32_External_Rela);
-      bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
     }
 
   if (h->needs_copy)
@@ -2867,8 +3318,7 @@
 
       BFD_ASSERT (h->dynindx != -1);
 
-      s = bfd_get_section_by_name (h->root.u.def.section->owner,
-                                   ".rela.bss");
+      s = bfd_get_linker_section (htab->elf.dynobj, ".rela.bss");
       BFD_ASSERT (s != NULL);
 
       rela.r_offset = (h->root.u.def.value
@@ -2881,9 +3331,9 @@
     }
 
   /* Mark some specially defined symbols as absolute.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
-      || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0
-      || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0)
+  if (h == htab->elf.hdynamic
+      || h == htab->elf.hgot
+      || h == htab->elf.hplt)
     sym->st_shndx = SHN_ABS;
 
   return TRUE;
@@ -2906,14 +3356,14 @@
 
   dynobj = htab->elf.dynobj;
 
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (htab->elf.dynamic_sections_created)
     {
       asection *splt;
       Elf32_External_Dyn *dyncon, *dynconend;
 
-      splt = bfd_get_section_by_name (dynobj, ".plt");
+      splt = bfd_get_linker_section (dynobj, ".plt");
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       dyncon = (Elf32_External_Dyn *) sdyn->contents;
@@ -2968,7 +3418,7 @@
 
   /* Set the first entry in the global offset table to the address of
      the dynamic section.  */
-  sgot = bfd_get_section_by_name (dynobj, ".got.plt");
+  sgot = bfd_get_linker_section (dynobj, ".got.plt");
   if (sgot && sgot->size > 0)
     {
       if (sdyn == NULL)
@@ -3004,7 +3454,7 @@
     {
       /* Common symbols less than or equal to -G nn bytes are automatically
 	 put into .sbss.  */
-      *secp = bfd_make_section_anyway (abfd, ".sbss");
+      *secp = bfd_make_section_old_way (abfd, ".sbss");
       if (*secp == NULL
           || ! bfd_set_section_flags (abfd, *secp, SEC_IS_COMMON))
         return FALSE;
@@ -3015,6 +3465,8 @@
   return TRUE;
 }
 
+#define TARGET_LITTLE_SYM      bfd_elf32_microblazeel_vec
+#define TARGET_LITTLE_NAME     "elf32-microblazeel"
 
 #define TARGET_BIG_SYM          bfd_elf32_microblaze_vec
 #define TARGET_BIG_NAME		"elf32-microblaze"
@@ -3023,7 +3475,7 @@
 #define ELF_TARGET_ID		MICROBLAZE_ELF_DATA
 #define ELF_MACHINE_CODE	EM_MICROBLAZE
 #define ELF_MACHINE_ALT1	EM_MICROBLAZE_OLD
-#define ELF_MAXPAGESIZE		0x4   		/* 4k, if we ever have 'em.  */
+#define ELF_MAXPAGESIZE		0x1000
 #define elf_info_to_howto	microblaze_elf_info_to_howto
 #define elf_info_to_howto_rel	NULL
 
@@ -3031,6 +3483,7 @@
 #define bfd_elf32_bfd_is_local_label_name       microblaze_elf_is_local_label_name
 #define elf_backend_relocate_section		microblaze_elf_relocate_section
 #define bfd_elf32_bfd_relax_section             microblaze_elf_relax_section
+#define bfd_elf32_bfd_merge_private_bfd_data    microblaze_elf_merge_private_bfd_data
 #define bfd_elf32_bfd_reloc_name_lookup		microblaze_elf_reloc_name_lookup
 
 #define elf_backend_gc_mark_hook		microblaze_elf_gc_mark_hook
diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
index fd3d4ba..eec2ef7 100644
--- a/bfd/elf32-mips.c
+++ b/bfd/elf32-mips.c
@@ -830,6 +830,111 @@
 	 0x0000ffff,		/* src_mask */
 	 0x0000ffff,	        /* dst_mask */
 	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS general dynamic variable reference.  */
+  HOWTO (R_MIPS16_TLS_GD,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_GD",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS local dynamic variable reference.  */
+  HOWTO (R_MIPS16_TLS_LDM,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_LDM",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS local dynamic offset.  */
+  HOWTO (R_MIPS16_TLS_DTPREL_HI16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_DTPREL_HI16",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS local dynamic offset.  */
+  HOWTO (R_MIPS16_TLS_DTPREL_LO16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_DTPREL_LO16",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS thread pointer offset.  */
+  HOWTO (R_MIPS16_TLS_GOTTPREL,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_GOTTPREL",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS thread pointer offset.  */
+  HOWTO (R_MIPS16_TLS_TPREL_HI16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_TPREL_HI16", /* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS thread pointer offset.  */
+  HOWTO (R_MIPS16_TLS_TPREL_LO16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_TPREL_LO16", /* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
 };
 
 static reloc_howto_type elf_micromips_howto_table_rel[] =
@@ -1410,7 +1515,7 @@
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_bitfield, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_COPY",		/* name */
 	 FALSE,			/* partial_inplace */
 	 0x0,         		/* src_mask */
@@ -1426,13 +1531,29 @@
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_bitfield, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_JUMP_SLOT",	/* name */
 	 FALSE,			/* partial_inplace */
 	 0x0,         		/* src_mask */
 	 0x0,		        /* dst_mask */
 	 FALSE);		/* pcrel_offset */
 
+/* Used in EH tables.  */
+static reloc_howto_type elf_mips_eh_howto =
+  HOWTO (R_MIPS_EH,		/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS_EH",		/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,	        /* dst_mask */
+	 FALSE);		/* pcrel_offset */
+
 /* Set the GP value for OUTPUT_BFD.  Returns FALSE if this is a
    dangerous relocation.  */
 
@@ -1796,6 +1917,15 @@
   { BFD_RELOC_MIPS16_CALL16, R_MIPS16_CALL16 - R_MIPS16_min },
   { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min },
   { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_GD, R_MIPS16_TLS_GD - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_LDM, R_MIPS16_TLS_LDM - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_DTPREL_HI16,
+    R_MIPS16_TLS_DTPREL_HI16 - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_DTPREL_LO16,
+    R_MIPS16_TLS_DTPREL_LO16 - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_GOTTPREL, R_MIPS16_TLS_GOTTPREL - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_HI16 - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_TPREL_LO16, R_MIPS16_TLS_TPREL_LO16 - R_MIPS16_min }
 };
 
 static const struct elf_reloc_map micromips_reloc_map[] =
@@ -1896,6 +2026,8 @@
       return &elf_mips_copy_howto;
     case BFD_RELOC_MIPS_JUMP_SLOT:
       return &elf_mips_jump_slot_howto;
+    case BFD_RELOC_MIPS_EH:
+      return &elf_mips_eh_howto;
     }
 }
 
@@ -1941,6 +2073,8 @@
     return &elf_mips_copy_howto;
   if (strcasecmp (elf_mips_jump_slot_howto.name, r_name) == 0)
     return &elf_mips_jump_slot_howto;
+  if (strcasecmp (elf_mips_eh_howto.name, r_name) == 0)
+    return &elf_mips_eh_howto;
 
   return NULL;
 }
@@ -1965,6 +2099,8 @@
       return &elf_mips_copy_howto;
     case R_MIPS_JUMP_SLOT:
       return &elf_mips_jump_slot_howto;
+    case R_MIPS_EH:
+      return &elf_mips_eh_howto;
     default:
       if (r_type >= R_MICROMIPS_min && r_type < R_MICROMIPS_max)
 	return &elf_micromips_howto_table_rel[r_type - R_MICROMIPS_min];
@@ -2031,18 +2167,17 @@
 {
   unsigned long mach;
 
+  if (ABI_N32_P (abfd))
+    return FALSE;
+
   /* Irix 5 and 6 are broken.  Object file symbol tables are not always
      sorted correctly such that local symbols precede global symbols,
      and the sh_info field in the symbol table is not always right.  */
   if (SGI_COMPAT (abfd))
     elf_bad_symtab (abfd) = TRUE;
 
-  if (ABI_N32_P (abfd))
-    return FALSE;
-
   mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
   bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
-
   return TRUE;
 }
 
@@ -2073,10 +2208,10 @@
 
       case 256:		/* Linux/MIPS */
 	/* pr_cursig */
-	elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+	elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
 
 	/* pr_pid */
-	elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
+	elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
 
 	/* pr_reg */
 	offset = 72;
@@ -2099,9 +2234,9 @@
 	return FALSE;
 
       case 128:		/* Linux/MIPS elf_prpsinfo */
-	elf_tdata (abfd)->core_program
+	elf_tdata (abfd)->core->program
 	 = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
-	elf_tdata (abfd)->core_command
+	elf_tdata (abfd)->core->command
 	 = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
     }
 
@@ -2110,7 +2245,7 @@
      implementations, so strip it off if it exists.  */
 
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
@@ -2231,7 +2366,6 @@
 #define elf_backend_default_use_rela_p	0
 #define elf_backend_sign_extend_vma	TRUE
 #define elf_backend_plt_readonly	1
-#define elf_backend_plt_sym_val		_bfd_mips_elf_plt_sym_val
 
 #define elf_backend_discard_info	_bfd_mips_elf_discard_info
 #define elf_backend_ignore_discarded_relocs \
@@ -2243,6 +2377,7 @@
 					mips_elf_is_local_label_name
 #define bfd_elf32_bfd_is_target_special_symbol \
 					_bfd_mips_elf_is_target_special_symbol
+#define bfd_elf32_get_synthetic_symtab	_bfd_mips_elf_get_synthetic_symtab
 #define bfd_elf32_find_nearest_line	_bfd_mips_elf_find_nearest_line
 #define bfd_elf32_find_inliner_info	_bfd_mips_elf_find_inliner_info
 #define bfd_elf32_new_section_hook	_bfd_mips_elf_new_section_hook
@@ -2258,6 +2393,7 @@
 #define bfd_elf32_bfd_print_private_bfd_data \
 					_bfd_mips_elf_print_private_bfd_data
 #define bfd_elf32_bfd_relax_section	_bfd_mips_elf_relax_section
+#define bfd_elf32_mkobject		_bfd_mips_elf_mkobject
 
 /* Support for SGI-ish mips targets.  */
 #define TARGET_LITTLE_SYM		bfd_elf32_littlemips_vec
@@ -2350,6 +2486,7 @@
 #define TARGET_LITTLE_NAME              "elf32-littlemips-vxworks"
 #define TARGET_BIG_SYM                  bfd_elf32_bigmips_vxworks_vec
 #define TARGET_BIG_NAME                 "elf32-bigmips-vxworks"
+#undef	ELF_OSABI
 
 #undef elf32_bed
 #define elf32_bed			elf32_mips_vxworks_bed
@@ -2369,7 +2506,6 @@
 #define elf_backend_default_use_rela_p		1
 #undef elf_backend_got_header_size
 #define elf_backend_got_header_size		(4 * 3)
-#undef elf_backend_plt_sym_val
 
 #undef elf_backend_finish_dynamic_symbol
 #define elf_backend_finish_dynamic_symbol \
@@ -2395,4 +2531,6 @@
 #undef elf_backend_symbol_processing
 /* NOTE: elf_backend_rela_normal is not defined for MIPS.  */
 
+#undef bfd_elf32_get_synthetic_symtab
+
 #include "elf32-target.h"
diff --git a/bfd/elf32-moxie.c b/bfd/elf32-moxie.c
index 8463599..d0cbb0f 100644
--- a/bfd/elf32-moxie.c
+++ b/bfd/elf32-moxie.c
@@ -1,5 +1,5 @@
 /* moxie-specific support for 32-bit ELF.
-   Copyright 2009, 2010 Free Software Foundation, Inc.
+   Copyright 2009, 2010, 2012 Free Software Foundation, Inc.
 
    Copied from elf32-fr30.c which is..
    Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
@@ -250,9 +250,9 @@
 	  name = h->root.root.string;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -356,6 +356,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
     }
 
@@ -366,8 +370,10 @@
 #define ELF_MACHINE_CODE	EM_MOXIE
 #define ELF_MAXPAGESIZE		0x1
 
-#define TARGET_BIG_SYM          bfd_elf32_moxie_vec
-#define TARGET_BIG_NAME		"elf32-moxie"
+#define TARGET_BIG_SYM          bfd_elf32_bigmoxie_vec
+#define TARGET_BIG_NAME		"elf32-bigmoxie"
+#define TARGET_LITTLE_SYM       bfd_elf32_littlemoxie_vec
+#define TARGET_LITTLE_NAME	"elf32-littlemoxie"
 
 #define elf_info_to_howto_rel			NULL
 #define elf_info_to_howto			moxie_info_to_howto_rela
diff --git a/bfd/elf32-msp430.c b/bfd/elf32-msp430.c
index 9a5fb2a..2f7a3da 100644
--- a/bfd/elf32-msp430.c
+++ b/bfd/elf32-msp430.c
@@ -1,6 +1,5 @@
 /*  MSP430-specific support for 32-bit ELF
-    Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2010
-    Free Software Foundation, Inc.
+    Copyright (C) 2002-2013 Free Software Foundation, Inc.
     Contributed by Dmitry Diky <[email protected]>
 
     This file is part of BFD, the Binary File Descriptor library.
@@ -27,9 +26,6 @@
 #include "elf-bfd.h"
 #include "elf/msp430.h"
 
-/* Use RELA instead of REL.  */
-#undef USE_REL
-
 static reloc_howto_type elf_msp430_howto_table[] =
 {
   HOWTO (R_MSP430_NONE,		/* type */
@@ -60,7 +56,7 @@
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* A 13 bit PC relative relocation.  */
+  /* A 10 bit PC relative relocation.  */
   HOWTO (R_MSP430_10_PCREL,	/* type */
 	 1,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -69,10 +65,10 @@
 	 0,			/* bitpos */
 	 complain_overflow_bitfield,/* complain_on_overflow */
 	 bfd_elf_generic_reloc,	/* special_function */
-	 "R_MSP430_13_PCREL",	/* name */
+	 "R_MSP430_10_PCREL",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0xfff,			/* src_mask */
-	 0xfff,			/* dst_mask */
+	 0x3ff,			/* src_mask */
+	 0x3ff,			/* dst_mask */
 	 TRUE),			/* pcrel_offset */
 
   /* A 16 bit absolute relocation.  */
@@ -90,7 +86,7 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
-  /* A 16 bit absolute relocation for command address.  */
+  /* A 16 bit PC relative relocation for command address.  */
   HOWTO (R_MSP430_16_PCREL,	/* type */
 	 1,			/* rightshift */
 	 1,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -135,7 +131,7 @@
 	 0xffff,		/* dst_mask */
 	 TRUE),			/* pcrel_offset */
 
-  /* A 13 bit PC relative relocation for complicated polymorphs.  */
+  /* A 10 bit PC relative relocation for complicated polymorphs.  */
   HOWTO (R_MSP430_2X_PCREL,	/* type */
 	 1,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -146,8 +142,8 @@
 	 bfd_elf_generic_reloc,	/* special_function */
 	 "R_MSP430_2X_PCREL",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0xfff,			/* src_mask */
-	 0xfff,			/* dst_mask */
+	 0x3ff,			/* src_mask */
+	 0x3ff,			/* dst_mask */
 	 TRUE),			/* pcrel_offset */
 
   /* A 16 bit relaxable relocation for command address.  */
@@ -164,6 +160,340 @@
 	 0,			/* src_mask */
 	 0xffff,		/* dst_mask */
 	 TRUE)			/* pcrel_offset */
+
+  /* A 8-bit absolute relocation.  */
+  , HOWTO (R_MSP430_8,		/* type */
+	 0,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 8,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430_8",		/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Together with a following reloc, allows for the difference
+     between two symbols to be the real addend of the second reloc.  */
+  HOWTO (R_MSP430_SYM_DIFF,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 NULL, 			/* special handler.  */
+	 "R_MSP430_SYM_DIFF",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE)			/* pcrel_offset */  
+};
+
+static reloc_howto_type elf_msp430x_howto_table[] =
+{
+  HOWTO (R_MSP430_NONE,		/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430_NONE",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_MSP430_ABS32,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430_ABS32",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_MSP430_ABS16,	/* type */
+	 0,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430_ABS16",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_MSP430_ABS8,		/* type */
+	 0,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 8,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430_ABS8",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xff,			/* src_mask */
+	 0xff,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_MSP430_PCR16,	/* type */
+	 1,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430_PCR16",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  HOWTO (R_MSP430X_PCR20_EXT_SRC,/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430X_PCR20_EXT_SRC",/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  HOWTO (R_MSP430X_PCR20_EXT_DST,/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430X_PCR20_EXT_DST",/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  HOWTO (R_MSP430X_PCR20_EXT_ODST,/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430X_PCR20_EXT_ODST",/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  HOWTO (R_MSP430X_ABS20_EXT_SRC,/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430X_ABS20_EXT_SRC",/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  HOWTO (R_MSP430X_ABS20_EXT_DST,/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430X_ABS20_EXT_DST",/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  HOWTO (R_MSP430X_ABS20_EXT_ODST,/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430X_ABS20_EXT_ODST",/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  HOWTO (R_MSP430X_ABS20_ADR_SRC,/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430X_ABS20_ADR_SRC",/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  HOWTO (R_MSP430X_ABS20_ADR_DST,/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430X_ABS20_ADR_DST",/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  HOWTO (R_MSP430X_PCR16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430X_PCR16",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  HOWTO (R_MSP430X_PCR20_CALL,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430X_PCR20_CALL",/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  HOWTO (R_MSP430X_ABS16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430X_ABS16",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  HOWTO (R_MSP430_ABS_HI16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430_ABS_HI16",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  HOWTO (R_MSP430_PREL31,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430_PREL31",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 TRUE),                 /* pcrel_offset */
+
+  EMPTY_HOWTO (R_MSP430_EHTYPE),
+  
+  /* A 10 bit PC relative relocation.  */
+  HOWTO (R_MSP430X_10_PCREL,	/* type */
+	 1,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 10,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430X_10_PCREL",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x3ff,			/* src_mask */
+	 0x3ff,			/* dst_mask */
+	 TRUE),  		/* pcrel_offset */
+
+  /* A 10 bit PC relative relocation for complicated polymorphs.  */
+  HOWTO (R_MSP430X_2X_PCREL,	/* type */
+	 1,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 10,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_MSP430X_2X_PCREL",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x3ff,			/* src_mask */
+	 0x3ff,			/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  /* Together with a following reloc, allows for the difference
+     between two symbols to be the real addend of the second reloc.  */
+  HOWTO (R_MSP430X_SYM_DIFF,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 NULL, 			/* special handler.  */
+	 "R_MSP430X_SYM_DIFF",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE)			/* pcrel_offset */  
 };
 
 /* Map BFD reloc types to MSP430 ELF reloc types.  */
@@ -175,18 +505,55 @@
 };
 
 static const struct msp430_reloc_map msp430_reloc_map[] =
-  {
-    {BFD_RELOC_NONE,                 R_MSP430_NONE},
-    {BFD_RELOC_32,                   R_MSP430_32},
-    {BFD_RELOC_MSP430_10_PCREL,      R_MSP430_10_PCREL},
-    {BFD_RELOC_16,                   R_MSP430_16_BYTE},
-    {BFD_RELOC_MSP430_16_PCREL,      R_MSP430_16_PCREL},
-    {BFD_RELOC_MSP430_16,            R_MSP430_16},
-    {BFD_RELOC_MSP430_16_PCREL_BYTE, R_MSP430_16_PCREL_BYTE},
-    {BFD_RELOC_MSP430_16_BYTE,       R_MSP430_16_BYTE},
-    {BFD_RELOC_MSP430_2X_PCREL,      R_MSP430_2X_PCREL},
-    {BFD_RELOC_MSP430_RL_PCREL,      R_MSP430_RL_PCREL}
-  };
+{
+  {BFD_RELOC_NONE,                 R_MSP430_NONE},
+  {BFD_RELOC_32,                   R_MSP430_32},
+  {BFD_RELOC_MSP430_10_PCREL,      R_MSP430_10_PCREL},
+  {BFD_RELOC_16,                   R_MSP430_16_BYTE},
+  {BFD_RELOC_MSP430_16_PCREL,      R_MSP430_16_PCREL},
+  {BFD_RELOC_MSP430_16,            R_MSP430_16},
+  {BFD_RELOC_MSP430_16_PCREL_BYTE, R_MSP430_16_PCREL_BYTE},
+  {BFD_RELOC_MSP430_16_BYTE,       R_MSP430_16_BYTE},
+  {BFD_RELOC_MSP430_2X_PCREL,      R_MSP430_2X_PCREL},
+  {BFD_RELOC_MSP430_RL_PCREL,      R_MSP430_RL_PCREL},
+  {BFD_RELOC_8,                    R_MSP430_8},
+  {BFD_RELOC_MSP430_SYM_DIFF,      R_MSP430_SYM_DIFF}
+};
+
+static const struct msp430_reloc_map msp430x_reloc_map[] =
+{
+  {BFD_RELOC_NONE,                    R_MSP430_NONE},
+  {BFD_RELOC_32,                      R_MSP430_ABS32},
+  {BFD_RELOC_16,                      R_MSP430_ABS16},
+  {BFD_RELOC_8,                       R_MSP430_ABS8},
+  {BFD_RELOC_MSP430_ABS8,             R_MSP430_ABS8},
+  {BFD_RELOC_MSP430X_PCR20_EXT_SRC,   R_MSP430X_PCR20_EXT_SRC},
+  {BFD_RELOC_MSP430X_PCR20_EXT_DST,   R_MSP430X_PCR20_EXT_DST},
+  {BFD_RELOC_MSP430X_PCR20_EXT_ODST,  R_MSP430X_PCR20_EXT_ODST},
+  {BFD_RELOC_MSP430X_ABS20_EXT_SRC,   R_MSP430X_ABS20_EXT_SRC},
+  {BFD_RELOC_MSP430X_ABS20_EXT_DST,   R_MSP430X_ABS20_EXT_DST},
+  {BFD_RELOC_MSP430X_ABS20_EXT_ODST,  R_MSP430X_ABS20_EXT_ODST},
+  {BFD_RELOC_MSP430X_ABS20_ADR_SRC,   R_MSP430X_ABS20_ADR_SRC},
+  {BFD_RELOC_MSP430X_ABS20_ADR_DST,   R_MSP430X_ABS20_ADR_DST},
+  {BFD_RELOC_MSP430X_PCR16,           R_MSP430X_PCR16},
+  {BFD_RELOC_MSP430X_PCR20_CALL,      R_MSP430X_PCR20_CALL},
+  {BFD_RELOC_MSP430X_ABS16,           R_MSP430X_ABS16},
+  {BFD_RELOC_MSP430_ABS_HI16,         R_MSP430_ABS_HI16},
+  {BFD_RELOC_MSP430_PREL31,           R_MSP430_PREL31},
+  {BFD_RELOC_MSP430_10_PCREL,         R_MSP430X_10_PCREL},
+  {BFD_RELOC_MSP430_2X_PCREL,         R_MSP430X_2X_PCREL},
+  {BFD_RELOC_MSP430_RL_PCREL,         R_MSP430X_PCR16},
+  {BFD_RELOC_MSP430_SYM_DIFF,         R_MSP430X_SYM_DIFF}
+};
+
+static inline bfd_boolean
+uses_msp430x_relocs (bfd * abfd)
+{
+  extern const bfd_target bfd_elf32_msp430_ti_vec;
+
+  return bfd_get_mach (abfd) == bfd_mach_msp430x
+    || abfd->xvec == & bfd_elf32_msp430_ti_vec;
+}
 
 static reloc_howto_type *
 bfd_elf32_bfd_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
@@ -194,9 +561,18 @@
 {
   unsigned int i;
 
-  for (i = 0; i < ARRAY_SIZE (msp430_reloc_map); i++)
-    if (msp430_reloc_map[i].bfd_reloc_val == code)
-      return &elf_msp430_howto_table[msp430_reloc_map[i].elf_reloc_val];
+  if (uses_msp430x_relocs (abfd))
+    {
+      for (i = ARRAY_SIZE (msp430x_reloc_map); i--;)
+	if (msp430x_reloc_map[i].bfd_reloc_val == code)
+	  return elf_msp430x_howto_table + msp430x_reloc_map[i].elf_reloc_val;
+    }
+  else
+    {
+      for (i = 0; i < ARRAY_SIZE (msp430_reloc_map); i++)
+	if (msp430_reloc_map[i].bfd_reloc_val == code)
+	  return &elf_msp430_howto_table[msp430_reloc_map[i].elf_reloc_val];
+    }
 
   return NULL;
 }
@@ -207,13 +583,23 @@
 {
   unsigned int i;
 
-  for (i = 0;
-       i < (sizeof (elf_msp430_howto_table)
-	    / sizeof (elf_msp430_howto_table[0]));
-       i++)
-    if (elf_msp430_howto_table[i].name != NULL
-	&& strcasecmp (elf_msp430_howto_table[i].name, r_name) == 0)
-      return &elf_msp430_howto_table[i];
+  if (uses_msp430x_relocs (abfd))
+    {
+      for (i = ARRAY_SIZE (elf_msp430x_howto_table); i--;)
+	if (elf_msp430x_howto_table[i].name != NULL
+	    && strcasecmp (elf_msp430x_howto_table[i].name, r_name) == 0)
+	  return elf_msp430x_howto_table + i;
+    }
+  else
+    {
+      for (i = 0;
+	   i < (sizeof (elf_msp430_howto_table)
+		/ sizeof (elf_msp430_howto_table[0]));
+	   i++)
+	if (elf_msp430_howto_table[i].name != NULL
+	    && strcasecmp (elf_msp430_howto_table[i].name, r_name) == 0)
+	  return &elf_msp430_howto_table[i];
+    }
 
   return NULL;
 }
@@ -228,6 +614,14 @@
   unsigned int r_type;
 
   r_type = ELF32_R_TYPE (dst->r_info);
+
+  if (uses_msp430x_relocs (abfd))
+    {
+      BFD_ASSERT (r_type < (unsigned int) R_MSP430x_max);
+      cache_ptr->howto = elf_msp430x_howto_table + r_type;
+      return;
+    }
+
   BFD_ASSERT (r_type < (unsigned int) R_MSP430_max);
   cache_ptr->howto = &elf_msp430_howto_table[r_type];
 }
@@ -266,6 +660,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
     }
 
@@ -276,16 +674,413 @@
    routines, but a few relocs, we have to do them ourselves.  */
 
 static bfd_reloc_status_type
-msp430_final_link_relocate (reloc_howto_type * howto, bfd * input_bfd,
-			    asection * input_section, bfd_byte * contents,
-			    Elf_Internal_Rela * rel, bfd_vma relocation)
+msp430_final_link_relocate (reloc_howto_type *     howto,
+			    bfd *                  input_bfd,
+			    asection *             input_section,
+			    bfd_byte *             contents,
+			    Elf_Internal_Rela *    rel,
+			    bfd_vma                relocation,
+			    struct bfd_link_info * info)
 {
+  static asection *  sym_diff_section;
+  static bfd_vma     sym_diff_value;
+
+  struct bfd_elf_section_data * esd = elf_section_data (input_section);
   bfd_reloc_status_type r = bfd_reloc_ok;
   bfd_vma x;
   bfd_signed_vma srel;
+  bfd_boolean is_rel_reloc = FALSE;
 
-  switch (howto->type)
+  if (uses_msp430x_relocs (input_bfd))
     {
+      /* See if we have a REL type relocation.  */
+      is_rel_reloc = (esd->rel.hdr != NULL);
+      /* Sanity check - only one type of relocation per section.
+	 FIXME: Theoretically it is possible to have both types,
+	 but if that happens how can we distinguish between the two ?  */
+      BFD_ASSERT (! is_rel_reloc || ! esd->rela.hdr);
+      /* If we are using a REL relocation then the addend should be empty.  */
+      BFD_ASSERT (! is_rel_reloc || rel->r_addend == 0);
+    }
+
+  if (sym_diff_section != NULL)
+    {
+      BFD_ASSERT (sym_diff_section == input_section);
+ 
+     if (uses_msp430x_relocs (input_bfd))
+       switch (howto->type)
+	 {
+	 case R_MSP430_ABS32:
+	  /* If we are computing a 32-bit value for the location lists
+	     and the result is 0 then we add one to the value.  A zero
+	     value can result because of linker relaxation deleteing
+	     prologue instructions and using a value of 1 (for the begin
+	     and end offsets in the location list entry) results in a
+	     nul entry which does not prevent the following entries from
+	     being parsed.  */
+	   if (relocation == sym_diff_value
+	       && strcmp (input_section->name, ".debug_loc") == 0)
+	     ++ relocation;
+	   /* Fall through.  */
+	 case R_MSP430_ABS16:
+	 case R_MSP430X_ABS16:
+	 case R_MSP430_ABS8:
+	   BFD_ASSERT (! is_rel_reloc);
+	   relocation -= sym_diff_value;
+	  break;
+
+	 default:
+	   return bfd_reloc_dangerous;
+	 }
+     else
+       switch (howto->type)
+	 {
+	 case R_MSP430_32:
+	 case R_MSP430_16:
+	 case R_MSP430_16_BYTE:
+	 case R_MSP430_8:
+	   relocation -= sym_diff_value;
+	  break;
+
+	 default:
+	   return bfd_reloc_dangerous;
+	 }
+       
+      sym_diff_section = NULL;
+    }
+
+  if (uses_msp430x_relocs (input_bfd))
+    switch (howto->type)
+      {
+      case R_MSP430X_SYM_DIFF:
+	/* Cache the input section and value.
+	   The offset is unreliable, since relaxation may
+	   have reduced the following reloc's offset.  */
+	BFD_ASSERT (! is_rel_reloc);
+	sym_diff_section = input_section;
+	sym_diff_value = relocation;
+	return bfd_reloc_ok;
+
+      case R_MSP430_ABS16:
+	contents += rel->r_offset;
+	srel = (bfd_signed_vma) relocation;
+	if (is_rel_reloc)
+	  srel += bfd_get_16 (input_bfd, contents);
+	else
+	  srel += rel->r_addend;
+	bfd_put_16 (input_bfd, srel & 0xffff, contents);
+	break;
+
+      case R_MSP430X_10_PCREL:
+	contents += rel->r_offset;
+	srel = (bfd_signed_vma) relocation;
+	if (is_rel_reloc)
+	  srel += bfd_get_16 (input_bfd, contents) & 0x3ff;
+	else
+	  srel += rel->r_addend;
+	srel -= rel->r_offset;
+	srel -= 2;		/* Branch instructions add 2 to the PC...  */
+	srel -= (input_section->output_section->vma +
+		 input_section->output_offset);
+	if (srel & 1)
+	  return bfd_reloc_outofrange;
+
+	/* MSP430 addresses commands as words.  */
+	srel >>= 1;
+
+	/* Check for an overflow.  */
+	if (srel < -512 || srel > 511)
+	  {
+	    if (info->disable_target_specific_optimizations < 0)
+	      {
+		static bfd_boolean warned = FALSE;
+		if (! warned)
+		  {
+		    info->callbacks->warning
+		      (info,
+		       _("Try enabling relaxation to avoid relocation truncations"),
+		       NULL, input_bfd, input_section, relocation);
+		    warned = TRUE;
+		  }
+	      }
+	    return bfd_reloc_overflow;
+	  }
+
+	x = bfd_get_16 (input_bfd, contents);
+	x = (x & 0xfc00) | (srel & 0x3ff);
+	bfd_put_16 (input_bfd, x, contents);
+	break;
+
+      case R_MSP430X_PCR20_EXT_ODST:
+	/* [0,4]+[48,16] = ---F ---- FFFF */
+	contents += rel->r_offset;
+	srel = (bfd_signed_vma) relocation;
+	if (is_rel_reloc)
+	  {
+	    bfd_vma addend;
+	    addend = (bfd_get_16 (input_bfd, contents) & 0xf) << 16;
+	    addend |= bfd_get_16 (input_bfd, contents+4);
+	    srel += addend;
+	    
+	  }
+	else
+	  srel += rel->r_addend;
+	srel -= rel->r_offset;
+	srel -= (input_section->output_section->vma +
+		 input_section->output_offset);
+	bfd_put_16 (input_bfd, (srel & 0xffff), contents + 6);
+	x = bfd_get_16 (input_bfd, contents);
+	x = (x & 0xfff0) | ((srel >> 16) & 0xf);
+	bfd_put_16 (input_bfd, x, contents);
+	break;
+
+      case R_MSP430X_ABS20_EXT_SRC:
+	/* [7,4]+[32,16] = -78- FFFF */
+	contents += rel->r_offset;
+	srel = (bfd_signed_vma) relocation;
+	if (is_rel_reloc)
+	  {
+	    bfd_vma addend;
+	    addend = (bfd_get_16 (input_bfd, contents) & 0x0780) << 9;
+	    addend |= bfd_get_16 (input_bfd, contents+2);
+	    srel += addend;
+	  }
+	else
+	  srel += rel->r_addend;
+	bfd_put_16 (input_bfd, (srel & 0xffff), contents + 4);
+	srel >>= 16;
+	x = bfd_get_16 (input_bfd, contents);
+	x = (x & 0xf87f) | ((srel << 7) & 0x0780);
+	bfd_put_16 (input_bfd, x, contents);
+	break;
+
+      case R_MSP430_16_PCREL:
+	contents += rel->r_offset;
+	srel = (bfd_signed_vma) relocation;
+	if (is_rel_reloc)
+	  srel += bfd_get_16 (input_bfd, contents);
+	else
+	  srel += rel->r_addend;
+	srel -= rel->r_offset;
+	/* Only branch instructions add 2 to the PC...  */
+	srel -= (input_section->output_section->vma +
+		 input_section->output_offset);
+	if (srel & 1)
+	  return bfd_reloc_outofrange;
+	bfd_put_16 (input_bfd, srel & 0xffff, contents);
+	break;
+
+      case R_MSP430X_PCR20_EXT_DST:
+	/* [0,4]+[32,16] = ---F FFFF */
+	contents += rel->r_offset;
+	srel = (bfd_signed_vma) relocation;
+	if (is_rel_reloc)
+	  {
+	    bfd_vma addend;
+	    addend = (bfd_get_16 (input_bfd, contents) & 0xf) << 16;
+	    addend |= bfd_get_16 (input_bfd, contents+2);
+	    srel += addend;
+	  }
+	else
+	  srel += rel->r_addend;
+	srel -= rel->r_offset;
+	srel -= (input_section->output_section->vma +
+		 input_section->output_offset);
+	bfd_put_16 (input_bfd, (srel & 0xffff), contents + 4);
+	srel >>= 16;
+	x = bfd_get_16 (input_bfd, contents);
+	x = (x & 0xfff0) | (srel & 0xf);
+	bfd_put_16 (input_bfd, x, contents);
+	break;
+
+      case R_MSP430X_PCR20_EXT_SRC:
+	/* [7,4]+32,16] = -78- FFFF */
+	contents += rel->r_offset;
+	srel = (bfd_signed_vma) relocation;
+	if (is_rel_reloc)
+	  {
+	    bfd_vma addend;
+	    addend = ((bfd_get_16 (input_bfd, contents) & 0x0780) << 9);
+	    addend |= bfd_get_16 (input_bfd, contents+2);
+	    srel += addend;;
+	  }
+	else
+	  srel += rel->r_addend;
+	srel -= rel->r_offset;
+	/* Only branch instructions add 2 to the PC...  */
+	srel -= (input_section->output_section->vma +
+		 input_section->output_offset);
+	bfd_put_16 (input_bfd, (srel & 0xffff), contents + 4);
+	srel >>= 16;
+	x = bfd_get_16 (input_bfd, contents);
+	x = (x & 0xf87f) | ((srel << 7) & 0x0780);
+	bfd_put_16 (input_bfd, x, contents);
+	break;
+
+      case R_MSP430_ABS8:
+	contents += rel->r_offset;
+	srel = (bfd_signed_vma) relocation;
+	if (is_rel_reloc)
+	  srel += bfd_get_8 (input_bfd, contents);
+	else
+	  srel += rel->r_addend;
+	bfd_put_8 (input_bfd, srel & 0xff, contents);
+	break;
+
+      case R_MSP430X_ABS20_EXT_DST:
+	contents += rel->r_offset;
+	srel = (bfd_signed_vma) relocation;
+	if (is_rel_reloc)
+	  srel += bfd_get_16 (input_bfd, contents) & 0xf;
+	else
+	  srel += rel->r_addend;
+	bfd_put_16 (input_bfd, (srel & 0xffff), contents + 4);
+	srel >>= 16;
+	x = bfd_get_16 (input_bfd, contents);
+	x = (x & 0xfff0) | (srel & 0xf);
+	bfd_put_16 (input_bfd, x, contents);
+	break;
+
+      case R_MSP430X_ABS20_EXT_ODST:
+	/* [0,4]+[48,16] = ---F ---- FFFF */
+	contents += rel->r_offset;
+	srel = (bfd_signed_vma) relocation;
+	if (is_rel_reloc)
+	  {
+	    bfd_vma addend;
+	    addend = (bfd_get_16 (input_bfd, contents) & 0xf) << 16;
+	    addend |= bfd_get_16 (input_bfd, contents+4);
+	    srel += addend;
+	  }
+	else
+	  srel += rel->r_addend;
+	bfd_put_16 (input_bfd, (srel & 0xffff), contents + 6);
+	srel >>= 16;
+	x = bfd_get_16 (input_bfd, contents);
+	x = (x & 0xfff0) | (srel & 0xf);
+	bfd_put_16 (input_bfd, x, contents);
+	break;
+
+      case R_MSP430X_ABS20_ADR_SRC:
+	/* [8,4]+[32,16] = -F-- FFFF */
+	contents += rel->r_offset;
+	srel = (bfd_signed_vma) relocation;
+	if (is_rel_reloc)
+	  {
+	    bfd_vma addend;
+
+	    addend = ((bfd_get_16 (input_bfd, contents) & 0xf00) << 8);
+	    addend |= bfd_get_16 (input_bfd, contents+2);
+	    srel += addend;
+	  }
+	else
+	  srel += rel->r_addend;
+	bfd_put_16 (input_bfd, (srel & 0xffff), contents + 2);
+	srel >>= 16;
+	x = bfd_get_16 (input_bfd, contents);
+	x = (x & 0xf0ff) | ((srel << 8) & 0x0f00);
+	bfd_put_16 (input_bfd, x, contents);
+	break;
+
+      case R_MSP430X_ABS20_ADR_DST:
+	/* [0,4]+[32,16] = ---F FFFF */
+	contents += rel->r_offset;
+	srel = (bfd_signed_vma) relocation;
+	if (is_rel_reloc)
+	  {
+	    bfd_vma addend;
+	    addend = ((bfd_get_16 (input_bfd, contents) & 0xf) << 16);
+	    addend |= bfd_get_16 (input_bfd, contents+2);
+	    srel += addend;
+	  }
+	else
+	  srel += rel->r_addend;
+	bfd_put_16 (input_bfd, (srel & 0xffff), contents + 2);
+	srel >>= 16;
+	x = bfd_get_16 (input_bfd, contents);
+	x = (x & 0xfff0) | (srel & 0xf);
+	bfd_put_16 (input_bfd, x, contents);
+	break;
+
+      case R_MSP430X_ABS16:
+	contents += rel->r_offset;
+	srel = (bfd_signed_vma) relocation;
+	if (is_rel_reloc)
+	  srel += bfd_get_16 (input_bfd, contents);
+	else
+	  srel += rel->r_addend;
+	x = srel;
+	if (x > 0xffff)
+	  return bfd_reloc_overflow;	
+	bfd_put_16 (input_bfd, srel & 0xffff, contents);
+	break;
+
+      case R_MSP430_ABS_HI16:
+	/* The EABI specifies that this must be a RELA reloc.  */
+	BFD_ASSERT (! is_rel_reloc);
+	contents += rel->r_offset;
+	srel = (bfd_signed_vma) relocation;
+	srel += rel->r_addend;
+	bfd_put_16 (input_bfd, (srel >> 16) & 0xffff, contents);
+	break;
+      
+      case R_MSP430X_PCR20_CALL:
+	/* [0,4]+[32,16] = ---F FFFF*/
+	contents += rel->r_offset;
+	srel = (bfd_signed_vma) relocation;
+	if (is_rel_reloc)
+	  {
+	    bfd_vma addend;
+	    addend = (bfd_get_16 (input_bfd, contents) & 0xf) << 16;
+	    addend |= bfd_get_16 (input_bfd, contents+2);
+	    srel += addend;
+	  }
+	else
+	  srel += rel->r_addend;
+	srel -= rel->r_offset;
+	srel -= (input_section->output_section->vma +
+		 input_section->output_offset);
+	bfd_put_16 (input_bfd, srel & 0xffff, contents + 2);
+	srel >>= 16;
+	x = bfd_get_16 (input_bfd, contents);
+	x = (x & 0xfff0) | (srel & 0xf);
+	bfd_put_16 (input_bfd, x, contents);
+	break;
+	
+      case R_MSP430X_PCR16:
+	contents += rel->r_offset;
+	srel = (bfd_signed_vma) relocation;
+	if (is_rel_reloc)
+	  srel += bfd_get_16 (input_bfd, contents);
+	else
+	  srel += rel->r_addend;
+	srel -= rel->r_offset;
+	srel -= (input_section->output_section->vma +
+		 input_section->output_offset);
+	bfd_put_16 (input_bfd, srel & 0xffff, contents);
+	break;
+      
+      case R_MSP430_PREL31:
+	contents += rel->r_offset;
+	srel = (bfd_signed_vma) relocation;
+	if (is_rel_reloc)
+	  srel += (bfd_get_32 (input_bfd, contents) & 0x7fffffff);
+	else
+	  srel += rel->r_addend;
+	srel += rel->r_addend;
+	x = bfd_get_32 (input_bfd, contents);
+	x = (x & 0x80000000) | ((srel >> 31) & 0x7fffffff);
+	bfd_put_32 (input_bfd, x, contents);
+	break;
+	
+      default:
+	r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+				      contents, rel->r_offset,
+				      relocation, rel->r_addend);
+      }
+  else
+    switch (howto->type)
+      {
     case R_MSP430_10_PCREL:
       contents += rel->r_offset;
       srel = (bfd_signed_vma) relocation;
@@ -303,8 +1098,22 @@
 
       /* Check for an overflow.  */
       if (srel < -512 || srel > 511)
-	return bfd_reloc_overflow;
-
+	{
+	  if (info->disable_target_specific_optimizations < 0)
+	    {
+	      static bfd_boolean warned = FALSE;
+	      if (! warned)
+		{
+		  info->callbacks->warning
+		    (info,
+		     _("Try enabling relaxation to avoid relocation truncations"),
+		     NULL, input_bfd, input_section, relocation);
+		  warned = TRUE;
+		}
+	    }
+	  return bfd_reloc_overflow;
+	}
+      
       x = bfd_get_16 (input_bfd, contents);
       x = (x & 0xfc00) | (srel & 0x3ff);
       bfd_put_16 (input_bfd, x, contents);
@@ -339,8 +1148,8 @@
       bfd_put_16 (input_bfd, x, contents - 2);
       break;
 
-    case R_MSP430_16_PCREL:
     case R_MSP430_RL_PCREL:
+    case R_MSP430_16_PCREL:
       contents += rel->r_offset;
       srel = (bfd_signed_vma) relocation;
       srel += rel->r_addend;
@@ -385,11 +1194,27 @@
       bfd_put_16 (input_bfd, srel & 0xffff, contents);
       break;
 
-    default:
-      r = _bfd_final_link_relocate (howto, input_bfd, input_section,
-				    contents, rel->r_offset,
-				    relocation, rel->r_addend);
-    }
+    case R_MSP430_8:
+      contents += rel->r_offset;
+      srel = (bfd_signed_vma) relocation;
+      srel += rel->r_addend;
+
+      bfd_put_8 (input_bfd, srel & 0xff, contents);
+      break;
+	 
+    case R_MSP430_SYM_DIFF:
+      /* Cache the input section and value.
+	 The offset is unreliable, since relaxation may
+	 have reduced the following reloc's offset.  */
+      sym_diff_section = input_section;
+      sym_diff_value = relocation;
+      return bfd_reloc_ok;
+
+      default:
+	r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+				      contents, rel->r_offset,
+				      relocation, rel->r_addend);
+      }
 
   return r;
 }
@@ -429,7 +1254,12 @@
 
       r_type = ELF32_R_TYPE (rel->r_info);
       r_symndx = ELF32_R_SYM (rel->r_info);
-      howto = elf_msp430_howto_table + r_type;
+
+      if (uses_msp430x_relocs (input_bfd))
+	howto = elf_msp430x_howto_table + r_type;
+      else
+	howto = elf_msp430_howto_table + r_type;
+
       h = NULL;
       sym = NULL;
       sec = NULL;
@@ -442,7 +1272,7 @@
 
 	  name = bfd_elf_string_from_elf_section
 	      (input_bfd, symtab_hdr->sh_link, sym->st_name);
-	  name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name;
+	  name = (name == NULL || * name == 0) ? bfd_section_name (input_bfd, sec) : name;
 	}
       else
 	{
@@ -452,17 +1282,18 @@
 				   r_symndx, symtab_hdr, sym_hashes,
 				   h, sec, relocation,
 				   unresolved_reloc, warned);
+	  name = h->root.root.string;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
 
       r = msp430_final_link_relocate (howto, input_bfd, input_section,
-				      contents, rel, relocation);
+				      contents, rel, relocation, info);
 
       if (r != bfd_reloc_ok)
 	{
@@ -472,7 +1303,7 @@
 	    {
 	    case bfd_reloc_overflow:
 	      r = info->callbacks->reloc_overflow
-		  (info, (h ? &h->root : NULL), name, howto->name,
+		(info, (h ? &h->root : NULL), name, howto->name,
 		   (bfd_vma) 0, input_bfd, input_section,
 		   rel->r_offset);
 	      break;
@@ -483,7 +1314,7 @@
 	      break;
 
 	    case bfd_reloc_outofrange:
-	      msg = _("internal error: out of range error");
+	      msg = _("internal error: branch/jump to an odd address detected");
 	      break;
 
 	    case bfd_reloc_notsupported:
@@ -525,61 +1356,29 @@
   switch (bfd_get_mach (abfd))
     {
     default:
-    case bfd_mach_msp110:
-      val = E_MSP430_MACH_MSP430x11x1;
-      break;
-
-    case bfd_mach_msp11:
-      val = E_MSP430_MACH_MSP430x11;
-      break;
-
-    case bfd_mach_msp12:
-      val = E_MSP430_MACH_MSP430x12;
-      break;
-
-    case bfd_mach_msp13:
-      val = E_MSP430_MACH_MSP430x13;
-      break;
-
-    case bfd_mach_msp14:
-      val = E_MSP430_MACH_MSP430x14;
-      break;
-
-    case bfd_mach_msp15:
-      val = E_MSP430_MACH_MSP430x15;
-      break;
-
-    case bfd_mach_msp16:
-      val = E_MSP430_MACH_MSP430x16;
-      break;
-
-    case bfd_mach_msp31:
-      val = E_MSP430_MACH_MSP430x31;
-      break;
-
-    case bfd_mach_msp32:
-      val = E_MSP430_MACH_MSP430x32;
-      break;
-
-    case bfd_mach_msp33:
-      val = E_MSP430_MACH_MSP430x33;
-      break;
-
-    case bfd_mach_msp41:
-      val = E_MSP430_MACH_MSP430x41;
-      break;
-
-    case bfd_mach_msp42:
-      val = E_MSP430_MACH_MSP430x42;
-      break;
-
-    case bfd_mach_msp43:
-      val = E_MSP430_MACH_MSP430x43;
-      break;
-
-    case bfd_mach_msp44:
-      val = E_MSP430_MACH_MSP430x44;
-      break;
+    case bfd_mach_msp110: val = E_MSP430_MACH_MSP430x11x1; break;
+    case bfd_mach_msp11: val = E_MSP430_MACH_MSP430x11; break;
+    case bfd_mach_msp12: val = E_MSP430_MACH_MSP430x12; break;
+    case bfd_mach_msp13: val = E_MSP430_MACH_MSP430x13; break;
+    case bfd_mach_msp14: val = E_MSP430_MACH_MSP430x14; break;
+    case bfd_mach_msp15: val = E_MSP430_MACH_MSP430x15; break;
+    case bfd_mach_msp16: val = E_MSP430_MACH_MSP430x16; break;
+    case bfd_mach_msp31: val = E_MSP430_MACH_MSP430x31; break;
+    case bfd_mach_msp32: val = E_MSP430_MACH_MSP430x32; break;
+    case bfd_mach_msp33: val = E_MSP430_MACH_MSP430x33; break;
+    case bfd_mach_msp41: val = E_MSP430_MACH_MSP430x41; break;
+    case bfd_mach_msp42: val = E_MSP430_MACH_MSP430x42; break;
+    case bfd_mach_msp43: val = E_MSP430_MACH_MSP430x43; break;
+    case bfd_mach_msp44: val = E_MSP430_MACH_MSP430x44; break;
+    case bfd_mach_msp20: val = E_MSP430_MACH_MSP430x20; break;
+    case bfd_mach_msp22: val = E_MSP430_MACH_MSP430x22; break;
+    case bfd_mach_msp23: val = E_MSP430_MACH_MSP430x23; break;
+    case bfd_mach_msp24: val = E_MSP430_MACH_MSP430x24; break;
+    case bfd_mach_msp26: val = E_MSP430_MACH_MSP430x26; break;
+    case bfd_mach_msp46: val = E_MSP430_MACH_MSP430x46; break;
+    case bfd_mach_msp47: val = E_MSP430_MACH_MSP430x47; break;
+    case bfd_mach_msp54: val = E_MSP430_MACH_MSP430x54; break;
+    case bfd_mach_msp430x: val = E_MSP430_MACH_MSP430X; break;
     }
 
   elf_elfheader (abfd)->e_machine = EM_MSP430;
@@ -602,64 +1401,32 @@
       switch (e_mach)
 	{
 	default:
-	case E_MSP430_MACH_MSP430x11:
-	  e_set = bfd_mach_msp11;
-	  break;
-
-	case E_MSP430_MACH_MSP430x11x1:
-	  e_set = bfd_mach_msp110;
-	  break;
-
-	case E_MSP430_MACH_MSP430x12:
-	  e_set = bfd_mach_msp12;
-	  break;
-
-	case E_MSP430_MACH_MSP430x13:
-	  e_set = bfd_mach_msp13;
-	  break;
-
-	case E_MSP430_MACH_MSP430x14:
-	  e_set = bfd_mach_msp14;
-	  break;
-
-	case E_MSP430_MACH_MSP430x15:
-	  e_set = bfd_mach_msp15;
-	  break;
-
-	case E_MSP430_MACH_MSP430x16:
-	  e_set = bfd_mach_msp16;
-	  break;
-
-	case E_MSP430_MACH_MSP430x31:
-	  e_set = bfd_mach_msp31;
-	  break;
-
-	case E_MSP430_MACH_MSP430x32:
-	  e_set = bfd_mach_msp32;
-	  break;
-
-	case E_MSP430_MACH_MSP430x33:
-	  e_set = bfd_mach_msp33;
-	  break;
-
-	case E_MSP430_MACH_MSP430x41:
-	  e_set = bfd_mach_msp41;
-	  break;
-
-	case E_MSP430_MACH_MSP430x42:
-	  e_set = bfd_mach_msp42;
-	  break;
-
-	case E_MSP430_MACH_MSP430x43:
-	  e_set = bfd_mach_msp43;
-	  break;
-
-	case E_MSP430_MACH_MSP430x44:
-	  e_set = bfd_mach_msp44;
-	  break;
+	case E_MSP430_MACH_MSP430x11: e_set = bfd_mach_msp11; break;
+	case E_MSP430_MACH_MSP430x11x1: e_set = bfd_mach_msp110; break;
+	case E_MSP430_MACH_MSP430x12: e_set = bfd_mach_msp12; break;
+	case E_MSP430_MACH_MSP430x13: e_set = bfd_mach_msp13; break;
+	case E_MSP430_MACH_MSP430x14: e_set = bfd_mach_msp14; break;
+	case E_MSP430_MACH_MSP430x15: e_set = bfd_mach_msp15; break;
+	case E_MSP430_MACH_MSP430x16: e_set = bfd_mach_msp16; break;
+	case E_MSP430_MACH_MSP430x31: e_set = bfd_mach_msp31; break;
+	case E_MSP430_MACH_MSP430x32: e_set = bfd_mach_msp32; break;
+	case E_MSP430_MACH_MSP430x33: e_set = bfd_mach_msp33; break;
+	case E_MSP430_MACH_MSP430x41: e_set = bfd_mach_msp41; break;
+	case E_MSP430_MACH_MSP430x42: e_set = bfd_mach_msp42; break;
+	case E_MSP430_MACH_MSP430x43: e_set = bfd_mach_msp43; break;
+	case E_MSP430_MACH_MSP430x44: e_set = bfd_mach_msp44; break;
+	case E_MSP430_MACH_MSP430x20: e_set = bfd_mach_msp20; break;
+	case E_MSP430_MACH_MSP430x22: e_set = bfd_mach_msp22; break;
+	case E_MSP430_MACH_MSP430x23: e_set = bfd_mach_msp23; break;
+	case E_MSP430_MACH_MSP430x24: e_set = bfd_mach_msp24; break;
+	case E_MSP430_MACH_MSP430x26: e_set = bfd_mach_msp26; break;
+	case E_MSP430_MACH_MSP430x46: e_set = bfd_mach_msp46; break;
+	case E_MSP430_MACH_MSP430x47: e_set = bfd_mach_msp47; break;
+	case E_MSP430_MACH_MSP430x54: e_set = bfd_mach_msp54; break;
+	case E_MSP430_MACH_MSP430X: e_set = bfd_mach_msp430x; break;
 	}
     }
-
+  
   return bfd_default_set_arch_mach (abfd, bfd_arch_msp430, e_set);
 }
 
@@ -667,9 +1434,11 @@
    Relaxation required only in two cases:
     - Bad hand coding like jumps from one section to another or
       from file to file.
-    - Sibling calls. This will affect onlu 'jump label' polymorph. Without
+    - Sibling calls. This will affect only 'jump label' polymorph. Without
       relaxing this enlarges code by 2 bytes. Sibcalls implemented but
       do not work in gcc's port by the reason I do not know.
+    - To convert out of range conditional jump instructions (found inside
+      a function) into inverted jumps over an unconditional branch instruction.
    Anyway, if a relaxation required, user should pass -relax option to the
    linker.
 
@@ -793,11 +1562,13 @@
   return FALSE;
 }
 
-/* Adjust all local symbols defined as '.section + 0xXXXX' (.section has sec_shndx)
-    referenced from current and other sections */
+/* Adjust all local symbols defined as '.section + 0xXXXX' (.section has
+   sec_shndx) referenced from current and other sections.  */
+
 static bfd_boolean
-msp430_elf_relax_adjust_locals(bfd * abfd, asection * sec, bfd_vma addr,
-    int count, unsigned int sec_shndx, bfd_vma toaddr)
+msp430_elf_relax_adjust_locals (bfd * abfd, asection * sec, bfd_vma addr,
+				int count, unsigned int sec_shndx,
+				bfd_vma toaddr)
 {
   Elf_Internal_Shdr *symtab_hdr;
   Elf_Internal_Rela *irel;
@@ -805,11 +1576,14 @@
   Elf_Internal_Sym *isym;
 
   irel = elf_section_data (sec)->relocs;
+  if (irel == NULL)
+    return TRUE;
+
   irelend = irel + sec->reloc_count;
   symtab_hdr = & elf_tdata (abfd)->symtab_hdr;
   isym = (Elf_Internal_Sym *) symtab_hdr->contents;
   
-  for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++)
+  for (;irel < irelend; irel++)
     {
       int sidx = ELF32_R_SYM(irel->r_info);
       Elf_Internal_Sym *lsym = isym + sidx;
@@ -859,7 +1633,7 @@
   /* Adjust all the relocs.  */
   symtab_hdr = & elf_tdata (abfd)->symtab_hdr;
   isym = (Elf_Internal_Sym *) symtab_hdr->contents;
-  for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++)
+  for (; irel < irelend; irel++)
     {
       /* Get the new reloc address.  */
       if ((irel->r_offset > addr && irel->r_offset < toaddr))
@@ -867,7 +1641,7 @@
     }
 
   for (p = abfd->sections; p != NULL; p = p->next)
-    msp430_elf_relax_adjust_locals(abfd,p,addr,count,sec_shndx,toaddr);
+    msp430_elf_relax_adjust_locals (abfd,p,addr,count,sec_shndx,toaddr);
   
   /* Adjust the local symbols defined in this section.  */
   symtab_hdr = & elf_tdata (abfd)->symtab_hdr;
@@ -897,7 +1671,82 @@
   return TRUE;
 }
 
+/* Insert two words into a section whilst relaxing.  */
 
+static bfd_byte *
+msp430_elf_relax_add_two_words (bfd * abfd, asection * sec, bfd_vma addr,
+				int word1, int word2)
+{
+  Elf_Internal_Shdr *symtab_hdr;
+  unsigned int sec_shndx;
+  bfd_byte *contents;
+  Elf_Internal_Rela *irel;
+  Elf_Internal_Rela *irelend;
+  Elf_Internal_Sym *isym;
+  Elf_Internal_Sym *isymend;
+  struct elf_link_hash_entry **sym_hashes;
+  struct elf_link_hash_entry **end_hashes;
+  unsigned int symcount;
+  bfd_vma sec_end;
+  asection *p;
+
+  contents = elf_section_data (sec)->this_hdr.contents;
+  sec_end = sec->size;
+
+  /* Make space for the new words.  */
+  contents = bfd_realloc (contents, sec_end + 4);
+  memmove (contents + addr + 4, contents + addr, sec_end - addr);
+
+  /* Insert the new words.  */
+  bfd_put_16 (abfd, word1, contents + addr);
+  bfd_put_16 (abfd, word2, contents + addr + 2);
+
+  /* Update the section information.  */
+  sec->size += 4;
+  elf_section_data (sec)->this_hdr.contents = contents;  
+
+  /* Adjust all the relocs.  */
+  irel = elf_section_data (sec)->relocs;
+  irelend = irel + sec->reloc_count;
+
+  for (; irel < irelend; irel++)
+    if ((irel->r_offset >= addr && irel->r_offset < sec_end))
+      irel->r_offset += 4;
+
+  /* Adjust the local symbols defined in this section.  */
+  sec_shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
+  for (p = abfd->sections; p != NULL; p = p->next)
+    msp430_elf_relax_adjust_locals (abfd, p, addr, -4,
+				    sec_shndx, sec_end);
+
+  /* Adjust the global symbols affected by the move.  */
+  symtab_hdr = & elf_tdata (abfd)->symtab_hdr;
+  isym = (Elf_Internal_Sym *) symtab_hdr->contents;
+  for (isymend = isym + symtab_hdr->sh_info; isym < isymend; isym++)
+    if (isym->st_shndx == sec_shndx
+	&& isym->st_value >= addr && isym->st_value < sec_end)
+      isym->st_value += 4;
+
+  /* Now adjust the global symbols defined in this section.  */
+  symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)
+	      - symtab_hdr->sh_info);
+  sym_hashes = elf_sym_hashes (abfd);
+  end_hashes = sym_hashes + symcount;
+  for (; sym_hashes < end_hashes; sym_hashes++)
+    {
+      struct elf_link_hash_entry *sym_hash = *sym_hashes;
+
+      if ((sym_hash->root.type == bfd_link_hash_defined
+	   || sym_hash->root.type == bfd_link_hash_defweak)
+	  && sym_hash->root.u.def.section == sec
+	  && sym_hash->root.u.def.value >= addr
+	  && sym_hash->root.u.def.value < sec_end)
+	sym_hash->root.u.def.value += 4;
+    }
+
+  return contents;
+}
+   
 static bfd_boolean
 msp430_elf_relax_section (bfd * abfd, asection * sec,
 			  struct bfd_link_info * link_info,
@@ -910,6 +1759,7 @@
   bfd_byte *          contents = NULL;
   Elf_Internal_Sym *  isymbuf = NULL;
 
+
   /* Assume nothing changes.  */
   *again = FALSE;
 
@@ -917,8 +1767,8 @@
      this section does not have relocs, or if this is not a
      code section.  */
   if (link_info->relocatable
-      || (sec->flags & SEC_RELOC) == 0
-      || sec->reloc_count == 0 || (sec->flags & SEC_CODE) == 0)
+    || (sec->flags & SEC_RELOC) == 0
+    || sec->reloc_count == 0 || (sec->flags & SEC_CODE) == 0)
     return TRUE;
 
   symtab_hdr = & elf_tdata (abfd)->symtab_hdr;
@@ -931,13 +1781,21 @@
 
   /* Walk through them looking for relaxing opportunities.  */
   irelend = internal_relocs + sec->reloc_count;
+
+  /* Do code size growing relocs first.  */
   for (irel = internal_relocs; irel < irelend; irel++)
     {
       bfd_vma symval;
 
       /* If this isn't something that can be relaxed, then ignore
          this reloc.  */
-      if (ELF32_R_TYPE (irel->r_info) != (int) R_MSP430_RL_PCREL)
+      if (uses_msp430x_relocs (abfd)
+          && ELF32_R_TYPE (irel->r_info) == (int) R_MSP430X_10_PCREL)
+	;
+      else if (! uses_msp430x_relocs (abfd)
+               && ELF32_R_TYPE (irel->r_info) == (int) R_MSP430_10_PCREL)
+	;
+      else
 	continue;
 
       /* Get the section contents if we haven't done so already.  */
@@ -1011,109 +1869,288 @@
          that would be more work, but would require less memory when
          the linker is run.  */
 
-      /* Try to turn a 16bit pc-relative branch into a 10bit pc-relative
-         branch.  */
-      /* Paranoia? paranoia...  */      
-      if (ELF32_R_TYPE (irel->r_info) == (int) R_MSP430_RL_PCREL)
+      bfd_signed_vma value = symval;
+      int opcode;
+
+      /* Compute the value that will be relocated.  */
+      value += irel->r_addend;
+      /* Convert to PC relative.  */
+      value -= (sec->output_section->vma + sec->output_offset);
+      value -= irel->r_offset;
+      value -= 2;
+      /* Scale.  */
+      value >>= 1;
+
+      /* If it is in range then no modifications are needed.  */
+      if (value >= -512 && value <= 511)
+	continue;
+
+      /* Get the opcode.  */
+      opcode = bfd_get_16 (abfd, contents + irel->r_offset);
+	  
+      /* Compute the new opcode.  We are going to convert:
+	 J<cond> label
+	 into:
+	 J<inv-cond> 1f
+	 BR[A] #label
+	 1:                     */
+      switch (opcode & 0xfc00)
 	{
-	  bfd_vma value = symval;
-
-	  /* Deal with pc-relative gunk.  */
-	  value -= (sec->output_section->vma + sec->output_offset);
-	  value -= irel->r_offset;
-	  value += irel->r_addend;
-
-	  /* See if the value will fit in 10 bits, note the high value is
-	     1016 as the target will be two bytes closer if we are
-	     able to relax. */
-	  if ((long) value < 1016 && (long) value > -1016)
-	    {
-	      int code0 = 0, code1 = 0, code2 = 0;
-	      int i;
-	      struct rcodes_s *rx;
-
-	      /* Get the opcode.  */
-	      if (irel->r_offset >= 6)
-		code0 = bfd_get_16 (abfd, contents + irel->r_offset - 6);
-
-	      if (irel->r_offset >= 4)
-		code1 = bfd_get_16 (abfd, contents + irel->r_offset - 4);
-
-	      code2 = bfd_get_16 (abfd, contents + irel->r_offset - 2);
-
-	      if (code2 != 0x4010)
-		continue;
-
-	      /* Check r4 and r3.  */
-	      for (i = NUMB_RELAX_CODES - 1; i >= 0; i--)
-		{
-		  rx = &rcode[i];
-		  if (rx->cdx == 2 && rx->f0 == code0 && rx->f1 == code1)
-		    break;
-		  else if (rx->cdx == 1 && rx->f1 == code1)
-		    break;
-		  else if (rx->cdx == 0)	/* This is an unconditional jump.  */
-		    break;
-		}
-
-	      /* Check labels:
-		   .Label0:       ; we do not care about this label
-		      jeq    +6
-		   .Label1:       ; make sure there is no label here
-		      jl     +4
-		   .Label2:       ; make sure there is no label here
-		      br .Label_dst
-
-	         So, if there is .Label1 or .Label2 we cannot relax this code.
-	         This actually should not happen, cause for relaxable
-		 instructions we use RL_PCREL reloc instead of 16_PCREL.
-		 Will change this in the future. */
-
-	      if (rx->cdx > 0
-		  && msp430_elf_symbol_address_p (abfd, sec, isymbuf,
-						  irel->r_offset - 2))
-		continue;
-	      if (rx->cdx > 1
-		  && msp430_elf_symbol_address_p (abfd, sec, isymbuf,
-						  irel->r_offset - 4))
-		continue;
-
-	      /* Note that we've changed the relocs, section contents, etc.  */
-	      elf_section_data (sec)->relocs = internal_relocs;
-	      elf_section_data (sec)->this_hdr.contents = contents;
-	      symtab_hdr->contents = (unsigned char *) isymbuf;
-
-	      /* Fix the relocation's type.  */
-	      if (rx->labels == 3)	/* Handle special cases.  */
-		irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
-					   R_MSP430_2X_PCREL);
-	      else
-		irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
-					   R_MSP430_10_PCREL);
-
-	      /* Fix the opcode right way.  */
-	      bfd_put_16 (abfd, rx->t0, contents + irel->r_offset - rx->off);
-	      if (rx->t1)
-		bfd_put_16 (abfd, rx->t1,
-			    contents + irel->r_offset - rx->off + 2);
-
-	      /* Delete bytes. */
-	      if (!msp430_elf_relax_delete_bytes (abfd, sec,
-						  irel->r_offset - rx->off +
-						  rx->ncl, rx->bs))
-		goto error_return;
-
-	      /* Handle unconditional jumps.  */
-	      if (rx->cdx == 0)
-		irel->r_offset -= 2;
-
-	      /* That will change things, so, we should relax again.
-	         Note that this is not required, and it may be slow.  */
-	      *again = TRUE;
-	    }
+	case 0x3800: opcode = 0x3402; break; /* Jl  -> Jge +2 */  
+	case 0x3400: opcode = 0x3802; break; /* Jge -> Jl  +2 */
+	case 0x2c00: opcode = 0x2802; break; /* Jhs -> Jlo +2 */
+	case 0x2800: opcode = 0x2c02; break; /* Jlo -> Jhs +2 */
+	case 0x2400: opcode = 0x2002; break; /* Jeq -> Jne +2 */
+	case 0x2000: opcode = 0x2402; break; /* jne -> Jeq +2 */
+	case 0x3000: /* jn    */
+	  /* There is no direct inverse of the Jn insn.
+	     FIXME: we could do this as:
+	        Jn 1f
+	        br 2f
+	     1: br label
+	     2:                */
+	  continue;
+	default:
+	  /* Not a conditional branch instruction.  */
+	  /* fprintf (stderr, "unrecog: %x\n", opcode); */
+	  goto error_return;
 	}
+
+      /* Note that we've changed the relocs, section contents, etc.  */
+      elf_section_data (sec)->relocs = internal_relocs;
+      elf_section_data (sec)->this_hdr.contents = contents;
+      symtab_hdr->contents = (unsigned char *) isymbuf;
+
+      /* Install the new opcode.  */
+      bfd_put_16 (abfd, opcode, contents + irel->r_offset);
+
+      /* Insert the new branch instruction.  */
+      if (uses_msp430x_relocs (abfd))
+	{
+	  /* Insert an absolute branch (aka MOVA) instruction.  */	  
+	  contents = msp430_elf_relax_add_two_words
+	    (abfd, sec, irel->r_offset + 2, 0x0080, 0x0000);
+
+	  /* Update the relocation to point to the inserted branch
+	     instruction.  Note - we are changing a PC-relative reloc
+	     into an absolute reloc, but this is OK because we have
+	     arranged with the assembler to have the reloc's value be
+	     a (local) symbol, not a section+offset value.  */
+	  irel->r_offset += 2;
+	  irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+				       R_MSP430X_ABS20_ADR_SRC);
+	}
+      else
+	{
+	  contents = msp430_elf_relax_add_two_words
+	    (abfd, sec, irel->r_offset + 2, 0x4030, 0x0000);
+
+	  /* See comment above about converting a 10-bit PC-rel
+	     relocation into a 16-bit absolute relocation.  */
+	  irel->r_offset += 4;
+	  irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+				       R_MSP430_16);
+	}
+
+      /* Growing the section may mean that other
+	 conditional branches need to be fixed.  */
+      *again = TRUE;
     }
 
+  if (! uses_msp430x_relocs (abfd))
+    /* Now perform the relocations that shrink the code size.
+       We only do this for non msp430x as gas only generates the RL
+       reloc for the msp430.  */
+    for (irel = internal_relocs; irel < irelend; irel++)
+      {
+	bfd_vma symval;
+
+	/* Get the section contents if we haven't done so already.  */
+	if (contents == NULL)
+	  {
+	    /* Get cached copy if it exists.  */
+	    if (elf_section_data (sec)->this_hdr.contents != NULL)
+	      contents = elf_section_data (sec)->this_hdr.contents;
+	    else if (! bfd_malloc_and_get_section (abfd, sec, &contents))
+	      goto error_return;
+	  }
+
+	/* Read this BFD's local symbols if we haven't done so already.  */
+	if (isymbuf == NULL && symtab_hdr->sh_info != 0)
+	  {
+	    isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
+	    if (isymbuf == NULL)
+	      isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
+					      symtab_hdr->sh_info, 0,
+					      NULL, NULL, NULL);
+	    if (isymbuf == NULL)
+	      goto error_return;
+	  }
+
+	/* Get the value of the symbol referred to by the reloc.  */
+	if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
+	  {
+	    /* A local symbol.  */
+	    Elf_Internal_Sym *isym;
+	    asection *sym_sec;
+
+	    isym = isymbuf + ELF32_R_SYM (irel->r_info);
+	    if (isym->st_shndx == SHN_UNDEF)
+	      sym_sec = bfd_und_section_ptr;
+	    else if (isym->st_shndx == SHN_ABS)
+	      sym_sec = bfd_abs_section_ptr;
+	    else if (isym->st_shndx == SHN_COMMON)
+	      sym_sec = bfd_com_section_ptr;
+	    else
+	      sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
+	    symval = (isym->st_value
+		      + sym_sec->output_section->vma + sym_sec->output_offset);
+	  }
+	else
+	  {
+	    unsigned long indx;
+	    struct elf_link_hash_entry *h;
+
+	    /* An external symbol.  */
+	    indx = ELF32_R_SYM (irel->r_info) - symtab_hdr->sh_info;
+	    h = elf_sym_hashes (abfd)[indx];
+	    BFD_ASSERT (h != NULL);
+
+	    if (h->root.type != bfd_link_hash_defined
+		&& h->root.type != bfd_link_hash_defweak)
+	      /* This appears to be a reference to an undefined
+		 symbol.  Just ignore it--it will be caught by the
+		 regular reloc processing.  */
+	      continue;
+
+	    symval = (h->root.u.def.value
+		      + h->root.u.def.section->output_section->vma
+		      + h->root.u.def.section->output_offset);
+	  }
+
+	/* For simplicity of coding, we are going to modify the section
+	   contents, the section relocs, and the BFD symbol table.  We
+	   must tell the rest of the code not to free up this
+	   information.  It would be possible to instead create a table
+	   of changes which have to be made, as is done in coff-mips.c;
+	   that would be more work, but would require less memory when
+	   the linker is run.  */
+
+	/* Try to turn a 16bit pc-relative branch into a 10bit pc-relative
+	   branch.  */
+	/* Paranoia? paranoia...  */      
+	if (ELF32_R_TYPE (irel->r_info) == (int) R_MSP430_RL_PCREL)
+	  {
+	    bfd_vma value = symval;
+
+	    /* Deal with pc-relative gunk.  */
+	    value -= (sec->output_section->vma + sec->output_offset);
+	    value -= irel->r_offset;
+	    value += irel->r_addend;
+
+	    /* See if the value will fit in 10 bits, note the high value is
+	       1016 as the target will be two bytes closer if we are
+	       able to relax.  */
+	    if ((long) value < 1016 && (long) value > -1016)
+	      {
+		int code0 = 0, code1 = 0, code2 = 0;
+		int i;
+		struct rcodes_s *rx;
+
+		/* Get the opcode.  */
+		if (irel->r_offset >= 6)
+		  code0 = bfd_get_16 (abfd, contents + irel->r_offset - 6);
+
+		if (irel->r_offset >= 4)
+		  code1 = bfd_get_16 (abfd, contents + irel->r_offset - 4);
+
+		code2 = bfd_get_16 (abfd, contents + irel->r_offset - 2);
+
+		if (code2 != 0x4010)
+		  continue;
+
+		/* Check r4 and r3.  */
+		for (i = NUMB_RELAX_CODES - 1; i >= 0; i--)
+		  {
+		    rx = &rcode[i];
+		    if (rx->cdx == 2 && rx->f0 == code0 && rx->f1 == code1)
+		      break;
+		    else if (rx->cdx == 1 && rx->f1 == code1)
+		      break;
+		    else if (rx->cdx == 0)	/* This is an unconditional jump.  */
+		      break;
+		  }
+
+		/* Check labels:
+		   .Label0:       ; we do not care about this label
+		   jeq    +6
+		   .Label1:       ; make sure there is no label here
+		   jl     +4
+		   .Label2:       ; make sure there is no label here
+		   br .Label_dst
+
+		   So, if there is .Label1 or .Label2 we cannot relax this code.
+		   This actually should not happen, cause for relaxable
+		   instructions we use RL_PCREL reloc instead of 16_PCREL.
+		   Will change this in the future. */
+
+		if (rx->cdx > 0
+		    && msp430_elf_symbol_address_p (abfd, sec, isymbuf,
+						    irel->r_offset - 2))
+		  continue;
+		if (rx->cdx > 1
+		    && msp430_elf_symbol_address_p (abfd, sec, isymbuf,
+						    irel->r_offset - 4))
+		  continue;
+
+		/* Note that we've changed the relocs, section contents, etc.  */
+		elf_section_data (sec)->relocs = internal_relocs;
+		elf_section_data (sec)->this_hdr.contents = contents;
+		symtab_hdr->contents = (unsigned char *) isymbuf;
+
+		/* Fix the relocation's type.  */
+		if (uses_msp430x_relocs (abfd))
+		  {
+		    if (rx->labels == 3)	/* Handle special cases.  */
+		      irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+						   R_MSP430X_2X_PCREL);
+		    else
+		      irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+						   R_MSP430X_10_PCREL);
+		  }
+		else
+		  {
+		    if (rx->labels == 3)	/* Handle special cases.  */
+		      irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+						   R_MSP430_2X_PCREL);
+		    else
+		      irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+						   R_MSP430_10_PCREL);
+		  }
+
+		/* Fix the opcode right way.  */
+		bfd_put_16 (abfd, rx->t0, contents + irel->r_offset - rx->off);
+		if (rx->t1)
+		  bfd_put_16 (abfd, rx->t1,
+			      contents + irel->r_offset - rx->off + 2);
+
+		/* Delete bytes. */
+		if (!msp430_elf_relax_delete_bytes (abfd, sec,
+						    irel->r_offset - rx->off +
+						    rx->ncl, rx->bs))
+		  goto error_return;
+
+		/* Handle unconditional jumps.  */
+		if (rx->cdx == 0)
+		  irel->r_offset -= 2;
+
+		/* That will change things, so, we should relax again.
+		   Note that this is not required, and it may be slow.  */
+		*again = TRUE;
+	      }
+	  }
+      }
+
   if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
     {
       if (!link_info->keep_memory)
@@ -1156,11 +2193,259 @@
   return FALSE;
 }
 
+/* Handle an MSP430 specific section when reading an object file.
+   This is called when bfd_section_from_shdr finds a section with
+   an unknown type.  */
+
+static bfd_boolean
+elf32_msp430_section_from_shdr (bfd *abfd,
+				Elf_Internal_Shdr * hdr,
+				const char *name,
+				int shindex)
+{
+  switch (hdr->sh_type)
+    {
+    case SHT_MSP430_SEC_FLAGS:
+    case SHT_MSP430_SYM_ALIASES:
+    case SHT_MSP430_ATTRIBUTES:
+      return _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex);
+    default:
+      return FALSE;
+    }
+}
+
+static bfd_boolean
+elf32_msp430_obj_attrs_handle_unknown (bfd *abfd, int tag)
+{
+  _bfd_error_handler
+    (_("Warning: %B: Unknown MSPABI object attribute %d"),
+     abfd, tag);
+  return TRUE;
+}
+
+/* Determine whether an object attribute tag takes an integer, a
+   string or both.  */
+
+static int
+elf32_msp430_obj_attrs_arg_type (int tag)
+{
+  if (tag == Tag_compatibility)
+    return ATTR_TYPE_FLAG_INT_VAL | ATTR_TYPE_FLAG_STR_VAL;
+
+  if (tag < 32)
+    return ATTR_TYPE_FLAG_INT_VAL;
+
+  return (tag & 1) != 0 ? ATTR_TYPE_FLAG_STR_VAL : ATTR_TYPE_FLAG_INT_VAL;
+}
+
+static inline const char *
+isa_type (int isa)
+{
+  switch (isa)
+    {
+    case 1: return "MSP430";
+    case 2: return "MSP430X";
+    default: return "unknown";
+    }
+}
+
+static inline const char *
+code_model (int model)
+{
+  switch (model)
+    {
+    case 1: return "small";
+    case 2: return "large";
+    default: return "unknown";
+    }
+}
+
+static inline const char *
+data_model (int model)
+{
+  switch (model)
+    {
+    case 1: return "small";
+    case 2: return "large";
+    case 3: return "restricted large";
+    default: return "unknown";
+    }
+}
+
+/* Merge MSPABI object attributes from IBFD into OBFD.
+   Raise an error if there are conflicting attributes.  */
+
+static bfd_boolean
+elf32_msp430_merge_mspabi_attributes (bfd *ibfd, bfd *obfd)
+{
+  obj_attribute *in_attr;
+  obj_attribute *out_attr;
+  bfd_boolean result = TRUE;
+  static bfd * first_input_bfd = NULL;
+
+  /* Skip linker created files.  */
+  if (ibfd->flags & BFD_LINKER_CREATED)
+    return TRUE;
+
+  /* If this is the first real object just copy the attributes.  */
+  if (!elf_known_obj_attributes_proc (obfd)[0].i)
+    {
+      _bfd_elf_copy_obj_attributes (ibfd, obfd);
+
+      out_attr = elf_known_obj_attributes_proc (obfd);
+
+      /* Use the Tag_null value to indicate that
+	 the attributes have been initialized.  */
+      out_attr[0].i = 1;
+
+      first_input_bfd = ibfd;
+      return TRUE;
+    }
+
+  in_attr = elf_known_obj_attributes_proc (ibfd);
+  out_attr = elf_known_obj_attributes_proc (obfd);
+
+  /* The ISAs must be the same.  */
+  if (in_attr[OFBA_MSPABI_Tag_ISA].i != out_attr[OFBA_MSPABI_Tag_ISA].i)
+    {
+      _bfd_error_handler
+	(_("error: %B uses %s instructions but %B uses %s"),
+	 ibfd, first_input_bfd,
+	 isa_type (in_attr[OFBA_MSPABI_Tag_ISA].i),
+	 isa_type (out_attr[OFBA_MSPABI_Tag_ISA].i));
+      result = FALSE;
+    }
+
+  /* The code models must be the same.  */
+  if (in_attr[OFBA_MSPABI_Tag_Code_Model].i !=
+      out_attr[OFBA_MSPABI_Tag_Code_Model].i)
+    {
+      _bfd_error_handler
+	(_("error: %B uses the %s code model whereas %B uses the %s code model"),
+	 ibfd, first_input_bfd,
+	 code_model (in_attr[OFBA_MSPABI_Tag_Code_Model].i),
+	 code_model (out_attr[OFBA_MSPABI_Tag_Code_Model].i));
+      result = FALSE;
+    }
+
+  /* The large code model is only supported by the MSP430X.  */
+  if (in_attr[OFBA_MSPABI_Tag_Code_Model].i == 2
+      && out_attr[OFBA_MSPABI_Tag_ISA].i != 2)
+    {
+      _bfd_error_handler
+	(_("error: %B uses the large code model but %B uses MSP430 instructions"),
+	 ibfd, first_input_bfd);
+      result = FALSE;
+    }
+
+  /* The data models must be the same.  */
+  if (in_attr[OFBA_MSPABI_Tag_Data_Model].i !=
+      out_attr[OFBA_MSPABI_Tag_Data_Model].i)
+    {
+      _bfd_error_handler
+	(_("error: %B uses the %s data model whereas %B uses the %s data model"),
+	 ibfd, first_input_bfd,
+	 data_model (in_attr[OFBA_MSPABI_Tag_Data_Model].i),
+	 data_model (out_attr[OFBA_MSPABI_Tag_Data_Model].i));
+      result = FALSE;
+    }
+
+  /* The small code model requires the use of the small data model.  */
+  if (in_attr[OFBA_MSPABI_Tag_Code_Model].i == 1
+      && out_attr[OFBA_MSPABI_Tag_Data_Model].i != 1)
+    {
+      _bfd_error_handler
+	(_("error: %B uses the small code model but %B uses the %s data model"),
+	 ibfd, first_input_bfd,
+	 data_model (out_attr[OFBA_MSPABI_Tag_Data_Model].i));
+      result = FALSE;
+    }
+
+  /* The large data models are only supported by the MSP430X.  */
+  if (in_attr[OFBA_MSPABI_Tag_Data_Model].i > 1
+      && out_attr[OFBA_MSPABI_Tag_ISA].i != 2)
+    {
+      _bfd_error_handler
+	(_("error: %B uses the %s data model but %B only uses MSP430 instructions"),
+	 ibfd, first_input_bfd,
+	 data_model (in_attr[OFBA_MSPABI_Tag_Data_Model].i));
+      result = FALSE;
+    }
+  
+  return result;
+}
+
+/* Merge backend specific data from an object file to the output
+   object file when linking.  */
+
+static bfd_boolean
+elf32_msp430_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
+{
+  /* Make sure that the machine number reflects the most
+     advanced version of the MSP architecture required.  */
+#define max(a,b) ((a) > (b) ? (a) : (b))
+  if (bfd_get_mach (ibfd) != bfd_get_mach (obfd))
+    bfd_default_set_arch_mach (obfd, bfd_get_arch (obfd),
+			       max (bfd_get_mach (ibfd), bfd_get_mach (obfd)));
+#undef max
+
+  return elf32_msp430_merge_mspabi_attributes (ibfd, obfd);
+}
+
+/* Copy backend specific data from one object module to another.  */
+
+static bfd_boolean
+elf32_msp430_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
+{
+  /* Copy object attributes.  */
+  _bfd_elf_copy_obj_attributes (ibfd, obfd);
+
+  return TRUE;
+}
+
+static bfd_boolean
+msp430_elf_is_target_special_symbol (bfd *abfd, asymbol *sym)
+{
+  return _bfd_elf_is_local_label_name (abfd, sym->name);
+}
+
+/* This is gross.  The MSP430 EABI says that (sec 11.5):
+
+     "An implementation may choose to use Rel or Rela
+      type relocations for other relocations."
+
+   But it also says that:
+   
+     "Certain relocations are identified as Rela only. [snip]
+      Where Rela is specified, an implementation must honor
+      this requirement."
+
+  There is one relocation marked as requiring RELA - R_MSP430_ABS_HI16 - but
+  to keep things simple we choose to use RELA relocations throughout.  The
+  problem is that the TI compiler generates REL relocations, so we have to
+  be able to accept those as well.  */
+
+#define elf_backend_may_use_rel_p  1
+#define elf_backend_may_use_rela_p 1
+#define elf_backend_default_use_rela_p 1
+
+#undef  elf_backend_obj_attrs_vendor
+#define elf_backend_obj_attrs_vendor		"mspabi"
+#undef  elf_backend_obj_attrs_section
+#define elf_backend_obj_attrs_section		".MSP430.attributes"
+#undef  elf_backend_obj_attrs_section_type
+#define elf_backend_obj_attrs_section_type	SHT_MSP430_ATTRIBUTES
+#define elf_backend_section_from_shdr  		elf32_msp430_section_from_shdr
+#define elf_backend_obj_attrs_handle_unknown 	elf32_msp430_obj_attrs_handle_unknown
+#undef  elf_backend_obj_attrs_arg_type
+#define elf_backend_obj_attrs_arg_type		elf32_msp430_obj_attrs_arg_type
+#define bfd_elf32_bfd_copy_private_bfd_data	elf32_msp430_copy_private_bfd_data
+#define bfd_elf32_bfd_merge_private_bfd_data	elf32_msp430_merge_private_bfd_data
 
 #define ELF_ARCH		bfd_arch_msp430
 #define ELF_MACHINE_CODE	EM_MSP430
 #define ELF_MACHINE_ALT1	EM_MSP430_OLD
-#define ELF_MAXPAGESIZE		1
+#define ELF_MAXPAGESIZE		4
 #define	ELF_OSABI		ELFOSABI_STANDALONE
 
 #define TARGET_LITTLE_SYM       bfd_elf32_msp430_vec
@@ -1175,5 +2460,30 @@
 #define elf_backend_object_p		     elf32_msp430_object_p
 #define elf_backend_post_process_headers     _bfd_elf_set_osabi
 #define bfd_elf32_bfd_relax_section	     msp430_elf_relax_section
+#define bfd_elf32_bfd_is_target_special_symbol	msp430_elf_is_target_special_symbol
+
+#undef  elf32_bed
+#define elf32_bed		elf32_msp430_bed
+
+#include "elf32-target.h"
+
+/* The TI compiler sets the OSABI field to ELFOSABI_NONE.  */
+#undef  TARGET_LITTLE_SYM
+#define TARGET_LITTLE_SYM       bfd_elf32_msp430_ti_vec
+
+#undef  elf32_bed
+#define elf32_bed		elf32_msp430_ti_bed
+
+#undef	ELF_OSABI		
+#define	ELF_OSABI		ELFOSABI_NONE
+
+static const struct bfd_elf_special_section msp430_ti_elf_special_sections[] =
+{
+  /* prefix, prefix_length,        suffix_len, type,               attributes.  */
+  { STRING_COMMA_LEN (".TI.symbol.alias"),  0, SHT_MSP430_SYM_ALIASES, 0 },
+  { STRING_COMMA_LEN (".TI.section.flags"), 0, SHT_MSP430_SEC_FLAGS,   0 },
+  { STRING_COMMA_LEN ("_TI_build_attrib"),  0, SHT_MSP430_ATTRIBUTES,  0 },
+  { NULL, 0,                                0, 0,                      0 }
+};
 
 #include "elf32-target.h"
diff --git a/bfd/elf32-mt.c b/bfd/elf32-mt.c
index 1be5d00..ea05c91 100644
--- a/bfd/elf32-mt.c
+++ b/bfd/elf32-mt.c
@@ -1,5 +1,5 @@
 /* Morpho Technologies MT specific support for 32-bit ELF
-   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011
+   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -26,7 +26,7 @@
 #include "elf/mt.h"
 
 /* Prototypes.  */
-static reloc_howto_type * mt_reloc_type_lookup 
+static reloc_howto_type * mt_reloc_type_lookup
   (bfd *, bfd_reloc_code_real_type);
 
 static void mt_info_to_howto_rela
@@ -36,11 +36,11 @@
   (bfd *, Elf_Internal_Rela *, bfd_byte *, bfd_vma);
 
 static bfd_reloc_status_type mt_final_link_relocate
-  (reloc_howto_type *, bfd *, asection *, bfd_byte *, 
+  (reloc_howto_type *, bfd *, asection *, bfd_byte *,
    Elf_Internal_Rela *, bfd_vma);
 
 static bfd_boolean mt_elf_relocate_section
-  (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, 
+  (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
    Elf_Internal_Rela *, Elf_Internal_Sym *, asection **);
 
 /* Relocation tables.  */
@@ -48,77 +48,77 @@
 {
   /* This reloc does nothing.  */
   HOWTO (R_MT_NONE,           /* type */
-          0,                      /* rightshift */ 
-          2,                      /* size (0 = byte, 1 = short, 2 = long) */ 
+          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_MT_NONE",          /* name */ 
-          FALSE,                  /* partial_inplace */ 
-          0 ,                     /* src_mask */ 
-          0,                      /* dst_mask */ 
+          FALSE,                  /* pc_relative */
+          0,                      /* bitpos */
+          complain_overflow_dont, /* complain_on_overflow */
+          bfd_elf_generic_reloc,  /* special_function */
+          "R_MT_NONE",          /* name */
+          FALSE,                  /* partial_inplace */
+          0 ,                     /* src_mask */
+          0,                      /* dst_mask */
           FALSE),                 /* pcrel_offset */
 
   /* A 16 bit absolute relocation.  */
   HOWTO (R_MT_16,             /* type */
-          0,                      /* rightshift */ 
-          2,                      /* size (0 = byte, 1 = short, 2 = long) */ 
+          0,                      /* rightshift */
+          2,                      /* size (0 = byte, 1 = short, 2 = long) */
           16,                     /* bitsize */
-          FALSE,                  /* pc_relative */ 
-          0,                      /* bitpos */ 
-          complain_overflow_dont, /* complain_on_overflow */ 
-          bfd_elf_generic_reloc,  /* special_function */ 
-          "R_MT_16",            /* name */ 
-          FALSE,                  /* partial_inplace */ 
-          0 ,                     /* src_mask */ 
-          0xffff,                 /* dst_mask */ 
+          FALSE,                  /* pc_relative */
+          0,                      /* bitpos */
+          complain_overflow_dont, /* complain_on_overflow */
+          bfd_elf_generic_reloc,  /* special_function */
+          "R_MT_16",            /* name */
+          FALSE,                  /* partial_inplace */
+          0 ,                     /* src_mask */
+          0xffff,                 /* dst_mask */
           FALSE),                 /* pcrel_offset */
 
   /* A 32 bit absolute relocation.  */
   HOWTO (R_MT_32,             /* type */
-          0,                      /* rightshift */ 
-          2,                      /* size (0 = byte, 1 = short, 2 = long) */ 
+          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_MT_32",            /* name */ 
-          FALSE,                  /* partial_inplace */ 
-          0 ,                     /* src_mask */ 
-          0xffffffff,             /* dst_mask */ 
+          FALSE,                  /* pc_relative */
+          0,                      /* bitpos */
+          complain_overflow_dont, /* complain_on_overflow */
+          bfd_elf_generic_reloc,  /* special_function */
+          "R_MT_32",            /* name */
+          FALSE,                  /* partial_inplace */
+          0 ,                     /* src_mask */
+          0xffffffff,             /* dst_mask */
           FALSE),                 /* pcrel_offset */
 
   /* A 32 bit pc-relative relocation.  */
   HOWTO (R_MT_32_PCREL,       /* type */
-          0,                      /* rightshift */ 
-          2,                      /* size (0 = byte, 1 = short, 2 = long) */ 
+          0,                      /* rightshift */
+          2,                      /* size (0 = byte, 1 = short, 2 = long) */
           32,                     /* bitsize */
-          TRUE,                   /* pc_relative */ 
-          0,                      /* bitpos */ 
-          complain_overflow_dont, /* complain_on_overflow */ 
-          bfd_elf_generic_reloc,  /* special_function */ 
-          "R_MT_32_PCREL",    /* name */ 
-          FALSE,                  /* partial_inplace */ 
-          0 ,                     /* src_mask */ 
-          0xffffffff,             /* dst_mask */ 
+          TRUE,                   /* pc_relative */
+          0,                      /* bitpos */
+          complain_overflow_dont, /* complain_on_overflow */
+          bfd_elf_generic_reloc,  /* special_function */
+          "R_MT_32_PCREL",    /* name */
+          FALSE,                  /* partial_inplace */
+          0 ,                     /* src_mask */
+          0xffffffff,             /* dst_mask */
           TRUE),                  /* pcrel_offset */
 
   /* A 16 bit pc-relative relocation.  */
   HOWTO (R_MT_PC16,           /* type */
-          0,                      /* rightshift */ 
-          2,                      /* size (0 = byte, 1 = short, 2 = long) */ 
+          0,                      /* rightshift */
+          2,                      /* size (0 = byte, 1 = short, 2 = long) */
           16,                     /* bitsize */
-          TRUE,                   /* pc_relative */ 
-          0,                      /* bitpos */ 
-          complain_overflow_signed, /* complain_on_overflow */ 
-          bfd_elf_generic_reloc,  /* special_function */ 
-          "R_MT_PC16",          /* name */ 
-          FALSE,                  /* partial_inplace */ 
-          0,                      /* src_mask */ 
-          0xffff,                 /* dst_mask */ 
+          TRUE,                   /* pc_relative */
+          0,                      /* bitpos */
+          complain_overflow_signed, /* complain_on_overflow */
+          bfd_elf_generic_reloc,  /* special_function */
+          "R_MT_PC16",          /* name */
+          FALSE,                  /* partial_inplace */
+          0,                      /* src_mask */
+          0xffff,                 /* dst_mask */
           TRUE),                  /* pcrel_offset */
 
   /* high 16 bits of symbol value.  */
@@ -321,7 +321,7 @@
       bfd_reloc_status_type        r;
       const char *                 name = NULL;
       int                          r_type;
-      
+
       r_type = ELF32_R_TYPE (rel->r_info);
 
       r_symndx = ELF32_R_SYM (rel->r_info);
@@ -330,13 +330,13 @@
       h      = NULL;
       sym    = NULL;
       sec    = NULL;
-      
+
       if (r_symndx < symtab_hdr->sh_info)
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections [r_symndx];
 	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
-	  
+
 	  name = bfd_elf_string_from_elf_section
 	    (input_bfd, symtab_hdr->sh_link, sym->st_name);
 	  name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name;
@@ -354,9 +354,9 @@
 	  name = h->root.root.string;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -385,12 +385,12 @@
 		(info, (h ? &h->root : NULL), name, howto->name, (bfd_vma) 0,
 		 input_bfd, input_section, rel->r_offset);
 	      break;
-	      
+
 	    case bfd_reloc_undefined:
 	      r = info->callbacks->undefined_symbol
 		(info, name, input_bfd, input_section, rel->r_offset, TRUE);
 	      break;
-	      
+
 	    case bfd_reloc_outofrange:
 	      msg = _("internal error: out of range error");
 	      break;
@@ -419,7 +419,7 @@
 /* Look through the relocs for a section during the first phase.
    Since we don't do .gots or .plts, we just need to consider the
    virtual table relocs for gc.  */
- 
+
 static bfd_boolean
 mt_elf_check_relocs
     (bfd *                     abfd,
@@ -431,19 +431,19 @@
   struct elf_link_hash_entry ** sym_hashes;
   const Elf_Internal_Rela *     rel;
   const Elf_Internal_Rela *     rel_end;
-  
+
   if (info->relocatable)
     return TRUE;
-  
+
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
-  
+
   rel_end = relocs + sec->reloc_count;
   for (rel = relocs; rel < rel_end; rel++)
     {
       struct elf_link_hash_entry *h;
       unsigned long r_symndx;
-      
+
       r_symndx = ELF32_R_SYM (rel->r_info);
       if (r_symndx < symtab_hdr->sh_info)
         h = NULL;
@@ -453,6 +453,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
     }
 
@@ -499,7 +503,7 @@
   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
     return TRUE;
-  
+
   BFD_ASSERT (!elf_flags_init (obfd)
 	      || elf_elfheader (obfd)->e_flags == elf_elfheader (ibfd)->e_flags);
 
@@ -551,7 +555,7 @@
 	 MS2 are not subsets of each other.   */
       ok = FALSE;
     }
-  
+
   if (ok)
     {
       obfd->arch_info = ibfd->arch_info;
@@ -568,7 +572,7 @@
   flagword flags;
 
   BFD_ASSERT (abfd != NULL && ptr != NULL);
-  
+
   /* Print normal ELF private data.  */
   _bfd_elf_print_private_bfd_data (abfd, ptr);
 
diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c
new file mode 100644
index 0000000..a6c6720
--- /dev/null
+++ b/bfd/elf32-nios2.c
@@ -0,0 +1,4136 @@
+/* 32-bit ELF support for Nios II.
+   Copyright (C) 2012, 2013 Free Software Foundation, Inc.
+   Contributed by Nigel Gray ([email protected]).
+   Contributed by Mentor Graphics, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+/* This file handles Altera Nios II ELF targets.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libbfd.h"
+#include "bfdlink.h"
+#include "genlink.h"
+#include "elf-bfd.h"
+#include "elf/nios2.h"
+#include "opcode/nios2.h"
+
+/* Use RELA relocations.  */
+#ifndef USE_RELA
+#define USE_RELA
+#endif
+
+#ifdef USE_REL
+#undef USE_REL
+#endif
+
+/* Forward declarations.  */
+static bfd_reloc_status_type nios2_elf32_ignore_reloc
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_reloc_status_type nios2_elf32_hi16_relocate
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_reloc_status_type nios2_elf32_lo16_relocate
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_reloc_status_type nios2_elf32_hiadj16_relocate
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_reloc_status_type nios2_elf32_pcrel_lo16_relocate
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_reloc_status_type nios2_elf32_pcrel_hiadj16_relocate
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_reloc_status_type nios2_elf32_pcrel16_relocate
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_reloc_status_type nios2_elf32_call26_relocate
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_reloc_status_type nios2_elf32_gprel_relocate
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_reloc_status_type nios2_elf32_ujmp_relocate
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_reloc_status_type nios2_elf32_cjmp_relocate
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static bfd_reloc_status_type nios2_elf32_callr_relocate
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+
+/* Target vector.  */
+extern const bfd_target bfd_elf32_littlenios2_vec;
+extern const bfd_target bfd_elf32_bignios2_vec;
+
+/* Offset of tp and dtp pointers from start of TLS block.  */
+#define TP_OFFSET	0x7000
+#define DTP_OFFSET	0x8000
+
+/* The relocation table used for SHT_REL sections.  */
+static reloc_howto_type elf_nios2_howto_table_rel[] = {
+  /* No relocation.  */
+  HOWTO (R_NIOS2_NONE,		/* type */
+	 0,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 0,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_NIOS2_NONE",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* 16-bit signed immediate relocation.  */
+  HOWTO (R_NIOS2_S16,		/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 6,			/* bitpos */
+	 complain_overflow_signed,	/* complain on overflow */
+	 bfd_elf_generic_reloc,	/* special function */
+	 "R_NIOS2_S16",		/* name */
+	 FALSE,			/* partial_inplace */
+	 0x003fffc0,		/* src_mask */
+	 0x003fffc0,		/* dest_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* 16-bit unsigned immediate relocation.  */
+  HOWTO (R_NIOS2_U16,		/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 6,			/* bitpos */
+	 complain_overflow_unsigned,	/* complain on overflow */
+	 bfd_elf_generic_reloc,	/* special function */
+	 "R_NIOS2_U16",		/* name */
+	 FALSE,			/* partial_inplace */
+	 0x003fffc0,		/* src_mask */
+	 0x003fffc0,		/* dest_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_NIOS2_PCREL16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 6,			/* bitpos */
+	 complain_overflow_signed,	/* complain on overflow */
+	 nios2_elf32_pcrel16_relocate,	/* special function */
+	 "R_NIOS2_PCREL16",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x003fffc0,		/* src_mask */
+	 0x003fffc0,		/* dest_mask */
+	 TRUE),			/* pcrel_offset */
+
+  HOWTO (R_NIOS2_CALL26,	/* type */
+	 2,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 26,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 6,			/* bitpos */
+	 complain_overflow_dont,	/* complain on overflow */
+	 nios2_elf32_call26_relocate,	/* special function */
+	 "R_NIOS2_CALL26",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffc0,		/* src_mask */
+	 0xffffffc0,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (R_NIOS2_IMM5,
+	 0,
+	 2,
+	 5,
+	 FALSE,
+	 6,
+	 complain_overflow_bitfield,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_IMM5",
+	 FALSE,
+	 0x000007c0,
+	 0x000007c0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_CACHE_OPX,
+	 0,
+	 2,
+	 5,
+	 FALSE,
+	 22,
+	 complain_overflow_bitfield,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_CACHE_OPX",
+	 FALSE,
+	 0x07c00000,
+	 0x07c00000,
+	 FALSE),
+
+  HOWTO (R_NIOS2_IMM6,
+	 0,
+	 2,
+	 6,
+	 FALSE,
+	 6,
+	 complain_overflow_bitfield,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_IMM6",
+	 FALSE,
+	 0x00000fc0,
+	 0x00000fc0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_IMM8,
+	 0,
+	 2,
+	 8,
+	 FALSE,
+	 6,
+	 complain_overflow_bitfield,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_IMM8",
+	 FALSE,
+	 0x00003fc0,
+	 0x00003fc0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_HI16,
+	 0,
+	 2,
+	 32,
+	 FALSE,
+	 6,
+	 complain_overflow_dont,
+	 nios2_elf32_hi16_relocate,
+	 "R_NIOS2_HI16",
+	 FALSE,
+	 0x003fffc0,
+	 0x003fffc0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_LO16,
+	 0,
+	 2,
+	 32,
+	 FALSE,
+	 6,
+	 complain_overflow_dont,
+	 nios2_elf32_lo16_relocate,
+	 "R_NIOS2_LO16",
+	 FALSE,
+	 0x003fffc0,
+	 0x003fffc0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_HIADJ16,
+	 0,
+	 2,
+	 32,
+	 FALSE,
+	 6,
+	 complain_overflow_dont,
+	 nios2_elf32_hiadj16_relocate,
+	 "R_NIOS2_HIADJ16",
+	 FALSE,
+	 0x003fffc0,
+	 0x003fffc0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_BFD_RELOC_32,
+	 0,
+	 2,			/* long */
+	 32,
+	 FALSE,
+	 0,
+	 complain_overflow_dont,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_BFD_RELOC32",
+	 FALSE,
+	 0xffffffff,
+	 0xffffffff,
+	 FALSE),
+
+  HOWTO (R_NIOS2_BFD_RELOC_16,
+	 0,
+	 1,			/* short */
+	 16,
+	 FALSE,
+	 0,
+	 complain_overflow_bitfield,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_BFD_RELOC16",
+	 FALSE,
+	 0x0000ffff,
+	 0x0000ffff,
+	 FALSE),
+
+  HOWTO (R_NIOS2_BFD_RELOC_8,
+	 0,
+	 0,			/* byte */
+	 8,
+	 FALSE,
+	 0,
+	 complain_overflow_bitfield,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_BFD_RELOC8",
+	 FALSE,
+	 0x000000ff,
+	 0x000000ff,
+	 FALSE),
+
+  HOWTO (R_NIOS2_GPREL,
+	 0,
+	 2,
+	 32,
+	 FALSE,
+	 6,
+	 complain_overflow_dont,
+	 nios2_elf32_gprel_relocate,
+	 "R_NIOS2_GPREL",
+	 FALSE,
+	 0x003fffc0,
+	 0x003fffc0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_GNU_VTINHERIT,
+	 0,
+	 2,			/* short */
+	 0,
+	 FALSE,
+	 0,
+	 complain_overflow_dont,
+	 NULL,
+	 "R_NIOS2_GNU_VTINHERIT",
+	 FALSE,
+	 0,
+	 0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_GNU_VTENTRY,
+	 0,
+	 2,			/* byte */
+	 0,
+	 FALSE,
+	 0,
+	 complain_overflow_dont,
+	 _bfd_elf_rel_vtable_reloc_fn,
+	 "R_NIOS2_GNU_VTENTRY",
+	 FALSE,
+	 0,
+	 0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_UJMP,
+	 0,
+	 2,
+	 32,
+	 FALSE,
+	 6,
+	 complain_overflow_dont,
+	 nios2_elf32_ujmp_relocate,
+	 "R_NIOS2_UJMP",
+	 FALSE,
+	 0x003fffc0,
+	 0x003fffc0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_CJMP,
+	 0,
+	 2,
+	 32,
+	 FALSE,
+	 6,
+	 complain_overflow_dont,
+	 nios2_elf32_cjmp_relocate,
+	 "R_NIOS2_CJMP",
+	 FALSE,
+	 0x003fffc0,
+	 0x003fffc0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_CALLR,
+	 0,
+	 2,
+	 32,
+	 FALSE,
+	 6,
+	 complain_overflow_dont,
+	 nios2_elf32_callr_relocate,
+	 "R_NIOS2_CALLR",
+	 FALSE,
+	 0x003fffc0,
+	 0x003fffc0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_ALIGN,
+	 0,
+	 2,
+	 0,
+	 FALSE,
+	 0,
+	 complain_overflow_dont,
+	 nios2_elf32_ignore_reloc,
+	 "R_NIOS2_ALIGN",
+	 FALSE,
+	 0,
+	 0,
+	 TRUE),
+
+
+  HOWTO (R_NIOS2_GOT16,
+	 0,
+	 2,
+	 16,
+	 FALSE,
+	 6,
+	 complain_overflow_bitfield,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_GOT16",
+	 FALSE,
+	 0x003fffc0,
+	 0x003fffc0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_CALL16,
+	 0,
+	 2,
+	 16,
+	 FALSE,
+	 6,
+	 complain_overflow_bitfield,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_CALL16",
+	 FALSE,
+	 0x003fffc0,
+	 0x003fffc0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_GOTOFF_LO,
+	 0,
+	 2,
+	 16,
+	 FALSE,
+	 6,
+	 complain_overflow_dont,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_GOTOFF_LO",
+	 FALSE,
+	 0x003fffc0,
+	 0x003fffc0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_GOTOFF_HA,
+	 0,
+	 2,
+	 16,
+	 FALSE,
+	 6,
+	 complain_overflow_dont,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_GOTOFF_HA",
+	 FALSE,
+	 0x003fffc0,
+	 0x003fffc0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_PCREL_LO,
+	 0,
+	 2,
+	 16,
+	 TRUE,
+	 6,
+	 complain_overflow_dont,
+	 nios2_elf32_pcrel_lo16_relocate,
+	 "R_NIOS2_PCREL_LO",
+	 FALSE,
+	 0x003fffc0,
+	 0x003fffc0,
+	 TRUE),
+
+  HOWTO (R_NIOS2_PCREL_HA,
+	 0,
+	 2,
+	 16,
+	 FALSE, /* This is a PC-relative relocation, but we need to subtract
+		   PC ourselves before the HIADJ.  */
+	 6,
+	 complain_overflow_dont,
+	 nios2_elf32_pcrel_hiadj16_relocate,
+	 "R_NIOS2_PCREL_HA",
+	 FALSE,
+	 0x003fffc0,
+	 0x003fffc0,
+	 TRUE),
+
+  HOWTO (R_NIOS2_TLS_GD16,
+	 0,
+	 2,
+	 16,
+	 FALSE,
+	 6,
+	 complain_overflow_bitfield,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_TLS_GD16",
+	 FALSE,
+	 0x003fffc0,
+	 0x003fffc0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_TLS_LDM16,
+	 0,
+	 2,
+	 16,
+	 FALSE,
+	 6,
+	 complain_overflow_bitfield,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_TLS_LDM16",
+	 FALSE,
+	 0x003fffc0,
+	 0x003fffc0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_TLS_LDO16,
+	 0,
+	 2,
+	 16,
+	 FALSE,
+	 6,
+	 complain_overflow_bitfield,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_TLS_LDO16",
+	 FALSE,
+	 0x003fffc0,
+	 0x003fffc0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_TLS_IE16,
+	 0,
+	 2,
+	 16,
+	 FALSE,
+	 6,
+	 complain_overflow_bitfield,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_TLS_IE16",
+	 FALSE,
+	 0x003fffc0,
+	 0x003fffc0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_TLS_LE16,
+	 0,
+	 2,
+	 16,
+	 FALSE,
+	 6,
+	 complain_overflow_bitfield,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_TLS_LE16",
+	 FALSE,
+	 0x003fffc0,
+	 0x003fffc0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_TLS_DTPMOD,
+	 0,
+	 2,
+	 32,
+	 FALSE,
+	 0,
+	 complain_overflow_dont,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_TLS_DTPMOD",
+	 FALSE,
+	 0xffffffff,
+	 0xffffffff,
+	 FALSE),
+
+  HOWTO (R_NIOS2_TLS_DTPREL,
+	 0,
+	 2,
+	 32,
+	 FALSE,
+	 0,
+	 complain_overflow_dont,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_TLS_DTPREL",
+	 FALSE,
+	 0xffffffff,
+	 0xffffffff,
+	 FALSE),
+
+  HOWTO (R_NIOS2_TLS_TPREL,
+	 0,
+	 2,
+	 32,
+	 FALSE,
+	 0,
+	 complain_overflow_dont,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_TLS_TPREL",
+	 FALSE,
+	 0xffffffff,
+	 0xffffffff,
+	 FALSE),
+
+  HOWTO (R_NIOS2_COPY,
+	 0,
+	 2,
+	 32,
+	 FALSE,
+	 0,
+	 complain_overflow_dont,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_COPY",
+	 FALSE,
+	 0,
+	 0,
+	 FALSE),
+
+  HOWTO (R_NIOS2_GLOB_DAT,
+	 0,
+	 2,
+	 32,
+	 FALSE,
+	 0,
+	 complain_overflow_dont,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_GLOB_DAT",
+	 FALSE,
+	 0xffffffff,
+	 0xffffffff,
+	 FALSE),
+
+  HOWTO (R_NIOS2_JUMP_SLOT,
+	 0,
+	 2,
+	 32,
+	 FALSE,
+	 0,
+	 complain_overflow_dont,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_JUMP_SLOT",
+	 FALSE,
+	 0xffffffff,
+	 0xffffffff,
+	 FALSE),
+
+  HOWTO (R_NIOS2_RELATIVE,
+	 0,
+	 2,
+	 32,
+	 FALSE,
+	 0,
+	 complain_overflow_dont,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_RELATIVE",
+	 FALSE,
+	 0xffffffff,
+	 0xffffffff,
+	 FALSE),
+
+  HOWTO (R_NIOS2_GOTOFF,
+	 0,
+	 2,
+	 32,
+	 FALSE,
+	 0,
+	 complain_overflow_dont,
+	 bfd_elf_generic_reloc,
+	 "R_NIOS2_GOTOFF",
+	 FALSE,
+	 0xffffffff,
+	 0xffffffff,
+	 FALSE),
+
+/* Add other relocations here.  */
+};
+
+static unsigned char elf_code_to_howto_index[R_NIOS2_ILLEGAL + 1];
+
+/* Return the howto for relocation RTYPE.  */
+static reloc_howto_type *
+lookup_howto (unsigned int rtype)
+{
+  static int initialized = 0;
+  int i;
+  int howto_tbl_size = (int) (sizeof (elf_nios2_howto_table_rel)
+			      / sizeof (elf_nios2_howto_table_rel[0]));
+
+  if (!initialized)
+    {
+      initialized = 1;
+      memset (elf_code_to_howto_index, 0xff,
+	      sizeof (elf_code_to_howto_index));
+      for (i = 0; i < howto_tbl_size; i++)
+	elf_code_to_howto_index[elf_nios2_howto_table_rel[i].type] = i;
+    }
+
+  BFD_ASSERT (rtype <= R_NIOS2_ILLEGAL);
+  i = elf_code_to_howto_index[rtype];
+  if (i >= howto_tbl_size)
+    return 0;
+  return elf_nios2_howto_table_rel + i;
+}
+
+/* Map for converting BFD reloc types to Nios II reloc types.  */
+struct elf_reloc_map
+{
+  bfd_reloc_code_real_type bfd_val;
+  enum elf_nios2_reloc_type elf_val;
+};
+
+static const struct elf_reloc_map nios2_reloc_map[] = {
+  {BFD_RELOC_NIOS2_S16, R_NIOS2_S16},
+  {BFD_RELOC_NIOS2_U16, R_NIOS2_U16},
+  {BFD_RELOC_16_PCREL, R_NIOS2_PCREL16},
+  {BFD_RELOC_NIOS2_CALL26, R_NIOS2_CALL26},
+  {BFD_RELOC_NIOS2_IMM5, R_NIOS2_IMM5},
+  {BFD_RELOC_NIOS2_CACHE_OPX, R_NIOS2_CACHE_OPX},
+  {BFD_RELOC_NIOS2_IMM6, R_NIOS2_IMM6},
+  {BFD_RELOC_NIOS2_IMM8, R_NIOS2_IMM8},
+  {BFD_RELOC_NIOS2_HI16, R_NIOS2_HI16},
+  {BFD_RELOC_NIOS2_LO16, R_NIOS2_LO16},
+  {BFD_RELOC_NIOS2_HIADJ16, R_NIOS2_HIADJ16},
+  {BFD_RELOC_32, R_NIOS2_BFD_RELOC_32},
+  {BFD_RELOC_16, R_NIOS2_BFD_RELOC_16},
+  {BFD_RELOC_8, R_NIOS2_BFD_RELOC_8},
+  {BFD_RELOC_NIOS2_GPREL, R_NIOS2_GPREL},
+  {BFD_RELOC_VTABLE_INHERIT, R_NIOS2_GNU_VTINHERIT},
+  {BFD_RELOC_VTABLE_ENTRY, R_NIOS2_GNU_VTENTRY},
+  {BFD_RELOC_NIOS2_UJMP, R_NIOS2_UJMP},
+  {BFD_RELOC_NIOS2_CJMP, R_NIOS2_CJMP},
+  {BFD_RELOC_NIOS2_CALLR, R_NIOS2_CALLR},
+  {BFD_RELOC_NIOS2_ALIGN, R_NIOS2_ALIGN},
+  {BFD_RELOC_NIOS2_GOT16, R_NIOS2_GOT16},
+  {BFD_RELOC_NIOS2_CALL16, R_NIOS2_CALL16},
+  {BFD_RELOC_NIOS2_GOTOFF_LO, R_NIOS2_GOTOFF_LO},
+  {BFD_RELOC_NIOS2_GOTOFF_HA, R_NIOS2_GOTOFF_HA},
+  {BFD_RELOC_NIOS2_PCREL_LO, R_NIOS2_PCREL_LO},
+  {BFD_RELOC_NIOS2_PCREL_HA, R_NIOS2_PCREL_HA},
+  {BFD_RELOC_NIOS2_TLS_GD16, R_NIOS2_TLS_GD16},
+  {BFD_RELOC_NIOS2_TLS_LDM16, R_NIOS2_TLS_LDM16},
+  {BFD_RELOC_NIOS2_TLS_LDO16, R_NIOS2_TLS_LDO16},
+  {BFD_RELOC_NIOS2_TLS_IE16, R_NIOS2_TLS_IE16},
+  {BFD_RELOC_NIOS2_TLS_LE16, R_NIOS2_TLS_LE16},
+  {BFD_RELOC_NIOS2_TLS_DTPMOD, R_NIOS2_TLS_DTPMOD},
+  {BFD_RELOC_NIOS2_TLS_DTPREL, R_NIOS2_TLS_DTPREL},
+  {BFD_RELOC_NIOS2_TLS_TPREL, R_NIOS2_TLS_TPREL},
+  {BFD_RELOC_NIOS2_COPY, R_NIOS2_COPY},
+  {BFD_RELOC_NIOS2_GLOB_DAT, R_NIOS2_GLOB_DAT},
+  {BFD_RELOC_NIOS2_JUMP_SLOT, R_NIOS2_JUMP_SLOT},
+  {BFD_RELOC_NIOS2_RELATIVE, R_NIOS2_RELATIVE},
+  {BFD_RELOC_NIOS2_GOTOFF, R_NIOS2_GOTOFF}
+};
+
+/* The Nios II linker needs to keep track of the number of relocs that it
+   decides to copy as dynamic relocs in check_relocs for each symbol.
+   This is so that it can later discard them if they are found to be
+   unnecessary.  We store the information in a field extending the
+   regular ELF linker hash table.  */
+
+struct elf32_nios2_dyn_relocs
+{
+  struct elf32_nios2_dyn_relocs *next;
+
+  /* The input section of the reloc.  */
+  asection *sec;
+
+  /* Total number of relocs copied for the input section.  */
+  bfd_size_type count;
+
+  /* Number of pc-relative relocs copied for the input section.  */
+  bfd_size_type pc_count;
+};
+
+/* Nios II ELF linker hash entry.  */
+
+struct elf32_nios2_link_hash_entry
+{
+  struct elf_link_hash_entry root;
+
+  /* Track dynamic relocs copied for this symbol.  */
+  struct elf32_nios2_dyn_relocs *dyn_relocs;
+
+#define GOT_UNKNOWN	0
+#define GOT_NORMAL	1
+#define GOT_TLS_GD	2
+#define GOT_TLS_IE	4
+  unsigned char tls_type;
+
+  /* We need to detect and take special action for symbols which are only
+     referenced with %call() and not with %got().  Such symbols do not need
+     a dynamic GOT reloc in shared objects, only a dynamic PLT reloc.  Lazy
+     linking will not work if the dynamic GOT reloc exists.
+     To check for this condition efficiently, we compare got_types_used against
+     CALL16_USED, meaning
+     (got_types_used & (GOT16_USED | CALL16_USED)) == CALL16_USED.  */
+#define GOT16_USED	1
+#define CALL16_USED	2
+  unsigned char got_types_used;
+};
+
+#define elf32_nios2_hash_entry(ent) \
+  ((struct elf32_nios2_link_hash_entry *) (ent))
+
+/* Get the Nios II elf linker hash table from a link_info structure.  */
+#define elf32_nios2_hash_table(info) \
+  ((struct elf32_nios2_link_hash_table *) ((info)->hash))
+
+/* Nios II ELF linker hash table.  */
+struct elf32_nios2_link_hash_table
+  {
+    /* The main hash table.  */
+    struct elf_link_hash_table root;
+
+    /* Short-cuts to get to dynamic linker sections.  */
+    asection *sdynbss;
+    asection *srelbss;
+    asection *sbss;
+
+    union {
+      bfd_signed_vma refcount;
+      bfd_vma offset;
+    } tls_ldm_got;
+
+    /* Small local sym cache.  */
+    struct sym_cache sym_cache;
+
+    bfd_vma res_n_size;
+  };
+
+struct nios2_elf32_obj_tdata
+{
+  struct elf_obj_tdata root;
+
+  /* tls_type for each local got entry.  */
+  char *local_got_tls_type;
+
+  /* TRUE if TLS GD relocs have been seen for this object.  */
+  bfd_boolean has_tlsgd;
+};
+
+#define elf32_nios2_tdata(abfd) \
+  ((struct nios2_elf32_obj_tdata *) (abfd)->tdata.any)
+
+#define elf32_nios2_local_got_tls_type(abfd) \
+  (elf32_nios2_tdata (abfd)->local_got_tls_type)
+
+/* The name of the dynamic interpreter.  This is put in the .interp
+   section.  */
+#define ELF_DYNAMIC_INTERPRETER "/lib/ld.so.1"
+
+/* PLT implementation for position-dependent code.  */
+static const bfd_vma nios2_plt_entry[] = { /* .PLTn: */
+  0x03c00034,	/* movhi r15, %hiadj(plt_got_slot_address) */
+  0x7bc00017,	/* ldw r15, %lo(plt_got_slot_address)(r15) */
+  0x7800683a	/* jmp r15 */
+};
+
+static const bfd_vma nios2_plt0_entry[] = { /* .PLTresolve */
+  0x03800034,	/* movhi r14, %hiadj(res_0) */
+  0x73800004,	/* addi r14, r14, %lo(res_0) */
+  0x7b9fc83a,	/* sub r15, r15, r14 */
+  0x03400034,	/* movhi r13, %hiadj(_GLOBAL_OFFSET_TABLE_) */
+  0x6b800017,	/* ldw r14, %lo(_GLOBAL_OFFSET_TABLE_+4)(r13) */
+  0x6b400017,	/* ldw r13, %lo(_GLOBAL_OFFSET_TABLE_+8)(r13) */
+  0x6800683a	/* jmp r13 */
+};
+
+/* PLT implementation for position-independent code.  */
+static const bfd_vma nios2_so_plt_entry[] = { /* .PLTn */
+  0x03c00034,	/* movhi r15, %hiadj(index * 4) */
+  0x7bc00004,	/* addi r15, r15, %lo(index * 4) */
+  0x00000006	/* br .PLTresolve */
+};
+
+static const bfd_vma nios2_so_plt0_entry[] = { /* .PLTresolve */
+  0x001ce03a,	/* nextpc r14 */
+  0x03400034,	/* movhi r13, %hiadj(_GLOBAL_OFFSET_TABLE_) */
+  0x6b9b883a,	/* add r13, r13, r14 */
+  0x6b800017,	/* ldw r14, %lo(_GLOBAL_OFFSET_TABLE_+4)(r13) */
+  0x6b400017,	/* ldw r13, %lo(_GLOBAL_OFFSET_TABLE_+8)(r13) */
+  0x6800683a	/* jmp r13 */
+};
+
+/* Implement elf_backend_grok_prstatus:
+   Support for core dump NOTE sections.  */
+static bfd_boolean
+nios2_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
+{
+  int offset;
+  size_t size;
+
+  switch (note->descsz)
+    {
+    default:
+      return FALSE;
+
+    case 212:	      /* Linux/Nios II */
+      /* pr_cursig */
+      elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
+
+      /* pr_pid */
+      elf_tdata (abfd)->core->pid = bfd_get_32 (abfd, note->descdata + 24);
+
+      /* pr_reg */
+      offset = 72;
+      size = 136;
+
+      break;
+    }
+
+  /* Make a ".reg/999" section.  */
+  return _bfd_elfcore_make_pseudosection (abfd, ".reg",
+					  size, note->descpos + offset);
+}
+
+/* Implement elf_backend_grok_psinfo.  */
+static bfd_boolean
+nios2_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
+{
+  switch (note->descsz)
+    {
+    default:
+      return FALSE;
+
+    case 124:	      /* Linux/Nios II elf_prpsinfo */
+      elf_tdata (abfd)->core->program
+	= _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
+      elf_tdata (abfd)->core->command
+	= _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
+    }
+
+  /* Note that for some reason, a spurious space is tacked
+     onto the end of the args in some (at least one anyway)
+     implementations, so strip it off if it exists.  */
+
+  {
+    char *command = elf_tdata (abfd)->core->command;
+    int n = strlen (command);
+
+    if (0 < n && command[n - 1] == ' ')
+      command[n - 1] = '\0';
+  }
+
+  return TRUE;
+}
+
+/* Create an entry in a Nios II ELF linker hash table.  */
+static struct bfd_hash_entry *
+link_hash_newfunc (struct bfd_hash_entry *entry,
+		   struct bfd_hash_table *table, const char *string)
+{
+  /* Allocate the structure if it has not already been allocated by a
+     subclass.  */
+  if (entry == NULL)
+    {
+      entry = bfd_hash_allocate (table,
+				 sizeof (struct elf32_nios2_link_hash_entry));
+      if (entry == NULL)
+	return entry;
+    }
+
+  /* Call the allocation method of the superclass.  */
+  entry = _bfd_elf_link_hash_newfunc (entry, table, string);
+  if (entry)
+    {
+      struct elf32_nios2_link_hash_entry *eh;
+
+      eh = (struct elf32_nios2_link_hash_entry *) entry;
+      eh->dyn_relocs = NULL;
+      eh->tls_type = GOT_UNKNOWN;
+      eh->got_types_used = 0;
+    }
+
+  return entry;
+}
+
+/* Implement bfd_elf32_bfd_reloc_type_lookup:
+   Given a BFD reloc type, return a howto structure.  */
+static reloc_howto_type *
+nios2_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+				   bfd_reloc_code_real_type code)
+{
+  int i;
+  for (i = 0;
+       i < (int) (sizeof (nios2_reloc_map) / sizeof (struct elf_reloc_map));
+       ++i)
+    if (nios2_reloc_map[i].bfd_val == code)
+      return &elf_nios2_howto_table_rel[(int) nios2_reloc_map[i].elf_val];
+  return NULL;
+}
+
+/* Implement bfd_elf32_bfd_reloc_name_lookup:
+   Given a reloc name, return a howto structure.  */
+static reloc_howto_type *
+nios2_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+				   const char *r_name)
+{
+  unsigned int i;
+  for (i = 0;
+       i < (sizeof (elf_nios2_howto_table_rel)
+	    / sizeof (elf_nios2_howto_table_rel[0]));
+       i++)
+    if (elf_nios2_howto_table_rel[i].name
+	&& strcasecmp (elf_nios2_howto_table_rel[i].name, r_name) == 0)
+      return &elf_nios2_howto_table_rel[i];
+
+  return NULL;	
+}
+
+/* Implement elf_info_to_howto:
+   Given a ELF32 relocation, fill in a arelent structure.  */
+static void
+nios2_elf32_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *cache_ptr,
+			   Elf_Internal_Rela *dst)
+{
+  unsigned int r_type;
+
+  r_type = ELF32_R_TYPE (dst->r_info);
+  BFD_ASSERT (r_type < R_NIOS2_ILLEGAL);
+  cache_ptr->howto = &elf_nios2_howto_table_rel[r_type];
+}
+
+/* Return the base VMA address which should be subtracted from real addresses
+   when resolving @dtpoff relocation.
+   This is PT_TLS segment p_vaddr.  */
+static bfd_vma
+dtpoff_base (struct bfd_link_info *info)
+{
+  /* If tls_sec is NULL, we should have signalled an error already.  */
+  if (elf_hash_table (info)->tls_sec == NULL)
+    return 0;
+  return elf_hash_table (info)->tls_sec->vma;
+}
+
+/* Return the relocation value for @tpoff relocation
+   if STT_TLS virtual address is ADDRESS.  */
+static bfd_vma
+tpoff (struct bfd_link_info *info, bfd_vma address)
+{
+  struct elf_link_hash_table *htab = elf_hash_table (info);
+
+  /* If tls_sec is NULL, we should have signalled an error already.  */
+  if (htab->tls_sec == NULL)
+    return 0;
+  return address - htab->tls_sec->vma;
+}
+
+/* Set the GP value for OUTPUT_BFD.  Returns FALSE if this is a
+   dangerous relocation.  */
+static bfd_boolean
+nios2_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp, struct bfd_link_info *info)
+{
+
+  bfd_boolean gp_found;
+  struct bfd_hash_entry *h;
+  struct bfd_link_hash_entry *lh;
+
+  /* If we've already figured out what GP will be, just return it. */
+  *pgp = _bfd_get_gp_value (output_bfd);
+  if (*pgp)
+    return TRUE;
+
+  h = bfd_hash_lookup (&info->hash->table, "_gp", FALSE, FALSE);
+  lh = (struct bfd_link_hash_entry *) h;
+lookup:
+  if (lh)
+    {
+      switch (lh->type)
+	{
+	case bfd_link_hash_undefined:
+	case bfd_link_hash_undefweak:
+	case bfd_link_hash_common:
+	  gp_found = FALSE;
+	  break;
+	case bfd_link_hash_defined:
+	case bfd_link_hash_defweak:
+	  gp_found = TRUE;
+	  *pgp = lh->u.def.value;
+	  break;
+	case bfd_link_hash_indirect:
+	case bfd_link_hash_warning:
+	  lh = lh->u.i.link;
+	  /* @@FIXME  ignoring warning for now */
+	  goto lookup;
+	case bfd_link_hash_new:
+	default:
+	  abort ();
+	}
+    }
+  else
+    gp_found = FALSE;
+
+  if (!gp_found)
+    {
+      /* Only get the error once. */
+      *pgp = 4;
+      _bfd_set_gp_value (output_bfd, *pgp);
+      return FALSE;
+    }
+
+  _bfd_set_gp_value (output_bfd, *pgp);
+
+  return TRUE;
+}
+
+/* Retrieve the previously cached _gp pointer, returning bfd_reloc_dangerous
+   if it's not available as we don't have a link_info pointer available here
+   to look it up in the output symbol table.  We don't need to adjust the
+   symbol value for an external symbol if we are producing relocatable
+   output.  */
+static bfd_reloc_status_type
+nios2_elf_final_gp (bfd *output_bfd, asymbol *symbol, bfd_boolean relocatable, 
+		    char **error_message, bfd_vma *pgp)
+{
+  if (bfd_is_und_section (symbol->section) && !relocatable)
+    {
+      *pgp = 0;
+      return bfd_reloc_undefined;
+    }
+
+  *pgp = _bfd_get_gp_value (output_bfd);
+  if (*pgp == 0 && (!relocatable || (symbol->flags & BSF_SECTION_SYM) != 0))
+    {
+      if (relocatable)
+	{
+	  /* Make up a value.  */
+	  *pgp = symbol->section->output_section->vma + 0x4000;
+	  _bfd_set_gp_value (output_bfd, *pgp);
+	}
+      else
+	{
+	  *error_message
+	    = (char *) _("global pointer relative relocation when _gp not defined");
+	  return bfd_reloc_dangerous;
+	}
+    }
+
+  return bfd_reloc_ok;
+}
+
+/* The usual way of loading a 32-bit constant into a Nios II register is to
+   load the high 16 bits in one instruction and then add the low 16 bits with
+   a signed add. This means that the high halfword needs to be adjusted to
+   compensate for the sign bit of the low halfword. This function returns the
+   adjusted high halfword for a given 32-bit constant.  */
+static
+bfd_vma hiadj (bfd_vma symbol_value)
+{
+  return ((symbol_value + 0x8000) >> 16) & 0xffff;
+}
+
+/* Do the relocations that require special handling.  */
+static bfd_reloc_status_type
+nios2_elf32_do_hi16_relocate (bfd *abfd, reloc_howto_type *howto, 
+			      asection *input_section ATTRIBUTE_UNUSED, 
+			      bfd_byte *data, bfd_vma offset, 
+			      bfd_vma symbol_value, bfd_vma addend)
+{
+  symbol_value = symbol_value + addend;
+  addend = 0;
+  symbol_value = (symbol_value >> 16) & 0xffff;
+  return _bfd_final_link_relocate (howto, abfd, input_section,
+				   data, offset, symbol_value, addend);
+}
+
+static bfd_reloc_status_type
+nios2_elf32_do_lo16_relocate (bfd *abfd, reloc_howto_type *howto,
+			      asection *input_section ATTRIBUTE_UNUSED, 
+			      bfd_byte *data, bfd_vma offset, 
+			      bfd_vma symbol_value, bfd_vma addend)
+{
+  symbol_value = symbol_value + addend;
+  addend = 0;
+  symbol_value = symbol_value & 0xffff;
+  return _bfd_final_link_relocate (howto, abfd, input_section,
+				   data, offset, symbol_value, addend);
+}
+
+static bfd_reloc_status_type
+nios2_elf32_do_hiadj16_relocate (bfd *abfd, reloc_howto_type *howto,
+				 asection *input_section ATTRIBUTE_UNUSED, 
+				 bfd_byte *data, bfd_vma offset,
+				 bfd_vma symbol_value, bfd_vma addend)
+{
+  symbol_value = symbol_value + addend;
+  addend = 0;
+  symbol_value = hiadj(symbol_value);
+  return _bfd_final_link_relocate (howto, abfd, input_section, data, offset,
+				   symbol_value, addend);
+}
+
+static bfd_reloc_status_type
+nios2_elf32_do_pcrel_lo16_relocate (bfd *abfd, reloc_howto_type *howto,
+				    asection *input_section ATTRIBUTE_UNUSED,
+				    bfd_byte *data, bfd_vma offset,
+				    bfd_vma symbol_value, bfd_vma addend)
+{
+  symbol_value = symbol_value + addend;
+  addend = 0;
+  symbol_value = symbol_value & 0xffff;
+  return _bfd_final_link_relocate (howto, abfd, input_section,
+				   data, offset, symbol_value, addend);
+}
+
+static bfd_reloc_status_type
+nios2_elf32_do_pcrel_hiadj16_relocate (bfd *abfd, reloc_howto_type *howto,
+				       asection *input_section
+				       ATTRIBUTE_UNUSED,
+				       bfd_byte *data, bfd_vma offset,
+				       bfd_vma symbol_value, bfd_vma addend)
+{
+  symbol_value = symbol_value + addend;
+  symbol_value -= (input_section->output_section->vma
+		   + input_section->output_offset);
+  symbol_value -= offset;
+  addend = 0;
+  symbol_value = hiadj(symbol_value);
+  return _bfd_final_link_relocate (howto, abfd, input_section, data, offset,
+				   symbol_value, addend);
+}
+
+static bfd_reloc_status_type
+nios2_elf32_do_pcrel16_relocate (bfd *abfd, reloc_howto_type *howto,
+				 asection *input_section ATTRIBUTE_UNUSED, 
+				 bfd_byte *data, bfd_vma offset, 
+				 bfd_vma symbol_value, bfd_vma addend)
+{
+  /* NIOS2 pc relative relocations are relative to the next 32-bit instruction 
+     so we need to subtract 4 before doing a final_link_relocate. */
+  symbol_value = symbol_value + addend - 4;
+  addend = 0;
+  return _bfd_final_link_relocate (howto, abfd, input_section,
+				   data, offset, symbol_value, addend);
+}
+
+static bfd_reloc_status_type
+nios2_elf32_do_call26_relocate (bfd *abfd, reloc_howto_type *howto,
+				asection *input_section ATTRIBUTE_UNUSED, 
+				bfd_byte *data, bfd_vma offset, 
+				bfd_vma symbol_value, bfd_vma addend)
+{
+  /* Check that the relocation is in the same page as the current address.  */
+  if (((symbol_value + addend) & 0xf0000000)
+      != ((input_section->output_section->vma + offset) & 0xf0000000))
+    return bfd_reloc_overflow;
+
+  return _bfd_final_link_relocate (howto, abfd, input_section,
+				   data, offset, symbol_value, addend);
+}
+
+static bfd_reloc_status_type
+nios2_elf32_do_gprel_relocate (bfd *abfd, reloc_howto_type *howto,
+			       asection *input_section ATTRIBUTE_UNUSED, 
+			       bfd_byte *data, bfd_vma offset, 
+			       bfd_vma symbol_value, bfd_vma addend)
+{
+  /* Because we need the output_bfd, the special handling is done
+     in nios2_elf32_relocate_section or in nios2_elf32_gprel_relocate.  */
+  return _bfd_final_link_relocate (howto, abfd, input_section,
+				   data, offset, symbol_value, addend);
+}
+
+static bfd_reloc_status_type
+nios2_elf32_do_ujmp_relocate (bfd *abfd, reloc_howto_type *howto,
+			      asection *input_section ATTRIBUTE_UNUSED, 
+			      bfd_byte *data, bfd_vma offset, 
+			      bfd_vma symbol_value, bfd_vma addend)
+{
+  bfd_vma symbol_lo16, symbol_hi16;
+  bfd_reloc_status_type r;
+  symbol_value = symbol_value + addend;
+  addend = 0;
+  symbol_hi16 = (symbol_value >> 16) & 0xffff;
+  symbol_lo16 = symbol_value & 0xffff;
+
+  r = _bfd_final_link_relocate (howto, abfd, input_section,
+				data, offset, symbol_hi16, addend);
+
+  if (r == bfd_reloc_ok)
+    return _bfd_final_link_relocate (howto, abfd, input_section,
+				     data, offset + 4, symbol_lo16, addend);
+
+  return r;
+}
+
+static bfd_reloc_status_type
+nios2_elf32_do_cjmp_relocate (bfd *abfd, reloc_howto_type *howto,
+			      asection *input_section ATTRIBUTE_UNUSED, 
+			      bfd_byte *data, bfd_vma offset, 
+			      bfd_vma symbol_value, bfd_vma addend)
+{
+  bfd_vma symbol_lo16, symbol_hi16;
+  bfd_reloc_status_type r;
+  symbol_value = symbol_value + addend;
+  addend = 0;
+  symbol_hi16 = (symbol_value >> 16) & 0xffff;
+  symbol_lo16 = symbol_value & 0xffff;
+
+  r = _bfd_final_link_relocate (howto, abfd, input_section,
+				data, offset, symbol_hi16, addend);
+
+  if (r == bfd_reloc_ok)
+    return _bfd_final_link_relocate (howto, abfd, input_section,
+				     data, offset + 4, symbol_lo16, addend);
+
+  return r;
+}
+
+static bfd_reloc_status_type
+nios2_elf32_do_callr_relocate (bfd *abfd, reloc_howto_type *howto,
+			       asection *input_section ATTRIBUTE_UNUSED, 
+			       bfd_byte *data, bfd_vma offset, 
+			       bfd_vma symbol_value, bfd_vma addend)
+{
+  bfd_vma symbol_lo16, symbol_hi16;
+  bfd_reloc_status_type r;
+  symbol_value = symbol_value + addend;
+  addend = 0;
+  symbol_hi16 = (symbol_value >> 16) & 0xffff;
+  symbol_lo16 = symbol_value & 0xffff;
+
+  r = _bfd_final_link_relocate (howto, abfd, input_section,
+				data, offset, symbol_hi16, addend);
+
+  if (r == bfd_reloc_ok)
+    return _bfd_final_link_relocate (howto, abfd, input_section,
+				     data, offset + 4, symbol_lo16, addend);
+
+  return r;
+}
+
+/* HOWTO handlers for relocations that require special handling.  */
+
+/* This is for relocations used only when relaxing to ensure
+   changes in size of section don't screw up .align.  */
+static bfd_reloc_status_type
+nios2_elf32_ignore_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry,
+			  asymbol *symbol ATTRIBUTE_UNUSED, 
+			  void *data ATTRIBUTE_UNUSED, asection *input_section, 
+			  bfd *output_bfd, 
+			  char **error_message ATTRIBUTE_UNUSED)
+{
+  if (output_bfd != NULL)
+    reloc_entry->address += input_section->output_offset;
+  return bfd_reloc_ok;
+}
+
+static bfd_reloc_status_type
+nios2_elf32_hi16_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol, 
+			   void *data, asection *input_section, 
+			   bfd *output_bfd, 
+			   char **error_message ATTRIBUTE_UNUSED)
+{
+  /* This part is from bfd_elf_generic_reloc.  */
+  if (output_bfd != NULL
+      && (symbol->flags & BSF_SECTION_SYM) == 0
+      && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
+    {
+      reloc_entry->address += input_section->output_offset;
+      return bfd_reloc_ok;
+    }
+
+  if (output_bfd != NULL)
+    /* FIXME: See bfd_perform_relocation.  Is this right?  */
+    return bfd_reloc_continue;
+
+  return nios2_elf32_do_hi16_relocate (abfd, reloc_entry->howto,
+				       input_section,
+				       data, reloc_entry->address,
+				       (symbol->value
+					+ symbol->section->output_section->vma
+					+ symbol->section->output_offset),
+				       reloc_entry->addend);
+}
+
+static bfd_reloc_status_type
+nios2_elf32_lo16_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
+			   void *data, asection *input_section, 
+			   bfd *output_bfd, 
+			   char **error_message ATTRIBUTE_UNUSED)
+{
+  /* This part is from bfd_elf_generic_reloc.  */
+  if (output_bfd != NULL
+      && (symbol->flags & BSF_SECTION_SYM) == 0
+      && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
+    {
+      reloc_entry->address += input_section->output_offset;
+      return bfd_reloc_ok;
+    }
+
+  if (output_bfd != NULL)
+    /* FIXME: See bfd_perform_relocation.  Is this right?  */
+    return bfd_reloc_continue;
+
+  return nios2_elf32_do_lo16_relocate (abfd, reloc_entry->howto,
+				       input_section,
+				       data, reloc_entry->address,
+				       (symbol->value
+					+ symbol->section->output_section->vma
+					+ symbol->section->output_offset),
+				       reloc_entry->addend);
+}
+
+static bfd_reloc_status_type
+nios2_elf32_hiadj16_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
+			      void *data, asection *input_section, 
+			      bfd *output_bfd, 
+			      char **error_message ATTRIBUTE_UNUSED)
+{
+  /* This part is from bfd_elf_generic_reloc.  */
+  if (output_bfd != NULL
+      && (symbol->flags & BSF_SECTION_SYM) == 0
+      && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
+    {
+      reloc_entry->address += input_section->output_offset;
+      return bfd_reloc_ok;
+    }
+
+  if (output_bfd != NULL)
+    /* FIXME: See bfd_perform_relocation.  Is this right?  */
+    return bfd_reloc_continue;
+
+  return nios2_elf32_do_hiadj16_relocate (abfd, reloc_entry->howto,
+					  input_section,
+					  data, reloc_entry->address,
+					  (symbol->value
+					   + symbol->section->output_section->vma
+					   + symbol->section->output_offset),
+					  reloc_entry->addend);
+}
+
+static bfd_reloc_status_type
+nios2_elf32_pcrel_lo16_relocate (bfd *abfd, arelent *reloc_entry,
+				 asymbol *symbol, void *data,
+				 asection *input_section, bfd *output_bfd,
+				 char **error_message ATTRIBUTE_UNUSED)
+{
+  /* This part is from bfd_elf_generic_reloc.  */
+  if (output_bfd != NULL
+      && (symbol->flags & BSF_SECTION_SYM) == 0
+      && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
+    {
+      reloc_entry->address += input_section->output_offset;
+      return bfd_reloc_ok;
+    }
+
+  if (output_bfd != NULL)
+    /* FIXME: See bfd_perform_relocation.  Is this right?  */
+    return bfd_reloc_continue;
+
+  return nios2_elf32_do_pcrel_lo16_relocate (
+    abfd, reloc_entry->howto, input_section, data, reloc_entry->address,
+    (symbol->value + symbol->section->output_section->vma
+     + symbol->section->output_offset),
+    reloc_entry->addend);
+}
+
+static bfd_reloc_status_type
+nios2_elf32_pcrel_hiadj16_relocate (bfd *abfd, arelent *reloc_entry,
+				    asymbol *symbol, void *data,
+				    asection *input_section, bfd *output_bfd,
+				    char **error_message ATTRIBUTE_UNUSED)
+{
+  /* This part is from bfd_elf_generic_reloc.  */
+  if (output_bfd != NULL
+      && (symbol->flags & BSF_SECTION_SYM) == 0
+      && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
+    {
+      reloc_entry->address += input_section->output_offset;
+      return bfd_reloc_ok;
+    }
+
+  if (output_bfd != NULL)
+    /* FIXME: See bfd_perform_relocation.  Is this right?  */
+    return bfd_reloc_continue;
+
+  return nios2_elf32_do_pcrel_hiadj16_relocate (
+    abfd, reloc_entry->howto, input_section, data, reloc_entry->address,
+    (symbol->value + symbol->section->output_section->vma
+     + symbol->section->output_offset),
+    reloc_entry->addend);
+}
+
+static bfd_reloc_status_type
+nios2_elf32_pcrel16_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
+			      void *data, asection *input_section, 
+			      bfd *output_bfd, 
+			      char **error_message ATTRIBUTE_UNUSED)
+{
+  /* This part is from bfd_elf_generic_reloc.  */
+  if (output_bfd != NULL
+      && (symbol->flags & BSF_SECTION_SYM) == 0
+      && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
+    {
+      reloc_entry->address += input_section->output_offset;
+      return bfd_reloc_ok;
+    }
+
+  if (output_bfd != NULL)
+    /* FIXME: See bfd_perform_relocation.  Is this right?  */
+    return bfd_reloc_continue;
+
+  return nios2_elf32_do_pcrel16_relocate (abfd, reloc_entry->howto,
+					  input_section,
+					  data, reloc_entry->address,
+					  (symbol->value
+					   + symbol->section->output_section->vma
+					   + symbol->section->output_offset),
+					  reloc_entry->addend);
+}
+
+static bfd_reloc_status_type
+nios2_elf32_call26_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
+			     void *data, asection *input_section, 
+			     bfd *output_bfd, 
+			     char **error_message ATTRIBUTE_UNUSED)
+{
+  /* This part is from bfd_elf_generic_reloc.  */
+  if (output_bfd != NULL
+      && (symbol->flags & BSF_SECTION_SYM) == 0
+      && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
+    {
+      reloc_entry->address += input_section->output_offset;
+      return bfd_reloc_ok;
+    }
+
+  if (output_bfd != NULL)
+    /* FIXME: See bfd_perform_relocation.  Is this right?  */
+    return bfd_reloc_continue;
+
+  return nios2_elf32_do_call26_relocate (abfd, reloc_entry->howto,
+					 input_section,
+					 data, reloc_entry->address,
+					 (symbol->value
+					  + symbol->section->output_section->vma
+					  + symbol->section->output_offset),
+					 reloc_entry->addend);
+}
+
+static bfd_reloc_status_type
+nios2_elf32_gprel_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
+			    void *data, asection *input_section, 
+			    bfd *output_bfd, char **msg)
+{
+  bfd_vma relocation;
+  bfd_vma gp;
+  bfd_reloc_status_type r;
+
+
+  /* This part is from bfd_elf_generic_reloc.  */
+  if (output_bfd != NULL
+      && (symbol->flags & BSF_SECTION_SYM) == 0
+      && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
+    {
+      reloc_entry->address += input_section->output_offset;
+      return bfd_reloc_ok;
+    }
+
+  if (output_bfd != NULL)
+    /* FIXME: See bfd_perform_relocation.  Is this right?  */
+    return bfd_reloc_continue;
+
+  relocation = (symbol->value
+		+ symbol->section->output_section->vma
+		+ symbol->section->output_offset);
+
+  /* This assumes we've already cached the _gp symbol.  */
+  r = nios2_elf_final_gp (abfd, symbol, FALSE, msg, &gp);
+  if (r == bfd_reloc_ok)
+    {
+      relocation = relocation + reloc_entry->addend - gp;
+      reloc_entry->addend = 0;
+      if ((signed) relocation < -32768 || (signed) relocation > 32767)
+	{
+	  *msg = _("global pointer relative address out of range");
+	  r = bfd_reloc_outofrange;
+	}
+      else
+	r = nios2_elf32_do_gprel_relocate (abfd, reloc_entry->howto,
+					   input_section,
+					   data, reloc_entry->address,
+					   relocation, reloc_entry->addend);
+    }
+
+  return r;
+}
+
+static bfd_reloc_status_type
+nios2_elf32_ujmp_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
+			   void *data, asection *input_section, 
+			   bfd *output_bfd, char **msg ATTRIBUTE_UNUSED)
+{
+  /* This part is from bfd_elf_generic_reloc.  */
+  if (output_bfd != NULL
+      && (symbol->flags & BSF_SECTION_SYM) == 0
+      && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
+    {
+      reloc_entry->address += input_section->output_offset;
+      return bfd_reloc_ok;
+    }
+
+  if (output_bfd != NULL)
+    /* FIXME: See bfd_perform_relocation.  Is this right?  */
+    return bfd_reloc_continue;
+
+  return nios2_elf32_do_ujmp_relocate (abfd, reloc_entry->howto,
+				       input_section,
+				       data, reloc_entry->address,
+				       (symbol->value
+					+ symbol->section->output_section->vma
+					+ symbol->section->output_offset),
+				       reloc_entry->addend);
+}
+
+static bfd_reloc_status_type
+nios2_elf32_cjmp_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
+			   void *data, asection *input_section, 
+			   bfd *output_bfd, char **msg ATTRIBUTE_UNUSED)
+{
+  /* This part is from bfd_elf_generic_reloc.  */
+  if (output_bfd != NULL
+      && (symbol->flags & BSF_SECTION_SYM) == 0
+      && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
+    {
+      reloc_entry->address += input_section->output_offset;
+      return bfd_reloc_ok;
+    }
+
+  if (output_bfd != NULL)
+    /* FIXME: See bfd_perform_relocation.  Is this right?  */
+    return bfd_reloc_continue;
+
+  return nios2_elf32_do_cjmp_relocate (abfd, reloc_entry->howto,
+				       input_section,
+				       data, reloc_entry->address,
+				       (symbol->value
+					+ symbol->section->output_section->vma
+					+ symbol->section->output_offset),
+				       reloc_entry->addend);
+}
+
+static bfd_reloc_status_type
+nios2_elf32_callr_relocate (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
+			    void *data, asection *input_section, 
+			    bfd *output_bfd, char **msg ATTRIBUTE_UNUSED)
+{
+  /* This part is from bfd_elf_generic_reloc.  */
+  if (output_bfd != NULL
+      && (symbol->flags & BSF_SECTION_SYM) == 0
+      && (!reloc_entry->howto->partial_inplace || reloc_entry->addend == 0))
+    {
+      reloc_entry->address += input_section->output_offset;
+      return bfd_reloc_ok;
+    }
+
+  if (output_bfd != NULL)
+    /* FIXME: See bfd_perform_relocation.  Is this right?  */
+    return bfd_reloc_continue;
+
+  return nios2_elf32_do_callr_relocate (abfd, reloc_entry->howto,
+					input_section,
+					data, reloc_entry->address,
+					(symbol->value
+					 + symbol->section->output_section->vma
+					 + symbol->section->output_offset),
+					reloc_entry->addend);
+}
+
+ 
+/* Implement elf_backend_relocate_section.  */
+static bfd_boolean
+nios2_elf32_relocate_section (bfd *output_bfd,
+			      struct bfd_link_info *info,
+			      bfd *input_bfd,
+			      asection *input_section,
+			      bfd_byte *contents,
+			      Elf_Internal_Rela *relocs,
+			      Elf_Internal_Sym *local_syms,
+			      asection **local_sections)
+{
+  Elf_Internal_Shdr *symtab_hdr;
+  struct elf_link_hash_entry **sym_hashes;
+  Elf_Internal_Rela *rel;
+  Elf_Internal_Rela *relend;
+  struct elf32_nios2_link_hash_table *htab;
+  asection *sgot;
+  asection *splt;
+  asection *sreloc = NULL;
+  bfd_vma *local_got_offsets;
+
+  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+  sym_hashes = elf_sym_hashes (input_bfd);
+  relend = relocs + input_section->reloc_count;
+
+  htab = elf32_nios2_hash_table (info);
+  sgot = htab->root.sgot;
+  splt = htab->root.splt;
+  local_got_offsets = elf_local_got_offsets (input_bfd);
+
+  for (rel = relocs; rel < relend; rel++)
+    {
+      reloc_howto_type *howto;
+      unsigned long r_symndx;
+      Elf_Internal_Sym *sym;
+      asection *sec;
+      struct elf_link_hash_entry *h;
+      struct elf32_nios2_link_hash_entry *eh;
+      bfd_vma relocation;
+      bfd_vma gp;
+      bfd_vma reloc_address;
+      bfd_reloc_status_type r = bfd_reloc_ok;
+      const char *name = NULL;
+      int r_type;
+      const char *format;
+      char msgbuf[256];
+      const char* msg = (const char*) NULL;
+      bfd_boolean unresolved_reloc;
+      bfd_vma off;
+      int use_plt;
+
+      r_type = ELF32_R_TYPE (rel->r_info);
+      r_symndx = ELF32_R_SYM (rel->r_info);
+
+      howto = lookup_howto ((unsigned) ELF32_R_TYPE (rel->r_info));
+      h = NULL;
+      sym = NULL;
+      sec = NULL;
+
+      if (r_symndx < symtab_hdr->sh_info)
+	{
+	  sym = local_syms + r_symndx;
+	  sec = local_sections[r_symndx];
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
+	}
+      else
+	{
+	  bfd_boolean warned;
+
+	  RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
+				   r_symndx, symtab_hdr, sym_hashes,
+				   h, sec, relocation,
+				   unresolved_reloc, warned);
+	}
+
+      if (sec && discarded_section (sec))
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, 1, relend, howto, 0, contents);
+
+      /* Nothing more to do unless this is a final link.  */
+      if (info->relocatable)
+	continue;
+
+      if (sec && sec->output_section)
+	reloc_address = (sec->output_section->vma + sec->output_offset
+			 + rel->r_offset);
+      else
+	reloc_address = 0;
+		
+      if (howto)
+	{
+	  switch (howto->type)
+	    {
+	    case R_NIOS2_HI16:
+	      r = nios2_elf32_do_hi16_relocate (input_bfd, howto,
+						input_section,
+						contents, rel->r_offset,
+						relocation, rel->r_addend);
+	      break;
+	    case R_NIOS2_LO16:
+	      r = nios2_elf32_do_lo16_relocate (input_bfd, howto,
+						input_section,
+						contents, rel->r_offset,
+						relocation, rel->r_addend);
+	      break;
+	    case R_NIOS2_PCREL_LO:
+	      r = nios2_elf32_do_pcrel_lo16_relocate (input_bfd, howto,
+						      input_section,
+						      contents,
+						      rel->r_offset,
+						      relocation,
+						      rel->r_addend);
+	      break;
+	    case R_NIOS2_HIADJ16:
+	      r = nios2_elf32_do_hiadj16_relocate (input_bfd, howto,
+						   input_section, contents,
+						   rel->r_offset, relocation,
+						   rel->r_addend);
+	      break;
+	    case R_NIOS2_PCREL_HA:
+	      r = nios2_elf32_do_pcrel_hiadj16_relocate (input_bfd, howto,
+							 input_section,
+							 contents,
+							 rel->r_offset,
+							 relocation,
+							 rel->r_addend);
+	      break;
+	    case R_NIOS2_PCREL16:
+	      r = nios2_elf32_do_pcrel16_relocate (input_bfd, howto,
+						   input_section, contents,
+						   rel->r_offset, relocation,
+						   rel->r_addend);
+	      break;
+	    case R_NIOS2_GPREL:
+	      /* Turns an absolute address into a gp-relative address.  */
+	      if (!nios2_elf_assign_gp (output_bfd, &gp, info))
+		{
+		  format = _("global pointer relative relocation at address "
+			     "0x%08x when _gp not defined\n");
+		  sprintf (msgbuf, format, reloc_address);
+		  msg = msgbuf;
+		  r = bfd_reloc_dangerous;
+		}
+	      else
+		{
+		  bfd_vma symbol_address = rel->r_addend + relocation;
+		  relocation = relocation + rel->r_addend - gp;
+		  rel->r_addend = 0;
+		  if (((signed) relocation < -32768
+		       || (signed) relocation > 32767)
+		      && (!h
+			  || h->root.type == bfd_link_hash_defined
+			  || h->root.type == bfd_link_hash_defweak))
+		    {
+		      format = _("Unable to reach %s (at 0x%08x) from the "
+				 "global pointer (at 0x%08x) because the "
+				 "offset (%d) is out of the allowed range, "
+				 "-32678 to 32767.\n" );
+		      sprintf (msgbuf, format, name, symbol_address, gp, 
+			       (signed)relocation);
+		      msg = msgbuf;
+		      r = bfd_reloc_outofrange;
+		    }
+		  else
+		    r =	_bfd_final_link_relocate (howto, input_bfd,
+						  input_section, contents,
+						  rel->r_offset, relocation,
+						  rel->r_addend);
+		}
+
+	      break;
+	    case R_NIOS2_UJMP:
+	      r = nios2_elf32_do_ujmp_relocate (input_bfd, howto,
+						input_section,
+						contents, rel->r_offset,
+						relocation, rel->r_addend);
+	      break;
+	    case R_NIOS2_CJMP:
+	      r = nios2_elf32_do_cjmp_relocate (input_bfd, howto,
+						input_section,
+						contents, rel->r_offset,
+						relocation, rel->r_addend);
+	      break;
+	    case R_NIOS2_CALLR:
+	      r = nios2_elf32_do_callr_relocate (input_bfd, howto,
+						 input_section, contents,
+						 rel->r_offset, relocation,
+						 rel->r_addend);
+	      break;
+	    case R_NIOS2_CALL26:
+	      /* If we have a call to an undefined weak symbol, we just want
+		 to stuff a zero in the bits of the call instruction and
+		 bypass the normal call26 relocation handling, because it'll
+		 diagnose an overflow error if address 0 isn't in the same
+		 256MB segment as the call site.  Presumably the call
+		 should be guarded by a null check anyway.  */
+	      if (h != NULL && h->root.type == bfd_link_hash_undefweak)
+		{
+		  BFD_ASSERT (relocation == 0 && rel->r_addend == 0);
+		  r = _bfd_final_link_relocate (howto, input_bfd,
+						input_section, contents,
+						rel->r_offset, relocation,
+						rel->r_addend);
+		  break;
+		}
+	      /* Handle relocations which should use the PLT entry.
+		 NIOS2_BFD_RELOC_32 relocations will use the symbol's value,
+		 which may point to a PLT entry, but we don't need to handle
+		 that here.  If we created a PLT entry, all branches in this
+		 object should go to it.  */
+	      if (h != NULL && splt != NULL && h->plt.offset != (bfd_vma) -1)
+		{
+		  /* If we've created a .plt section, and assigned a PLT entry
+		     to this function, it should not be known to bind locally.
+		     If it were, we would have cleared the PLT entry.  */
+		  BFD_ASSERT (!SYMBOL_CALLS_LOCAL (info, h));
+
+		  relocation = (splt->output_section->vma
+				+ splt->output_offset
+				+ h->plt.offset);
+
+		  unresolved_reloc = FALSE;
+		}
+	      r = nios2_elf32_do_call26_relocate (input_bfd, howto,
+						  input_section, contents,
+						  rel->r_offset, relocation,
+						  rel->r_addend);
+	      break;
+	    case R_NIOS2_ALIGN:
+	      r = bfd_reloc_ok;
+	      /* For symmetry this would be
+		 r = nios2_elf32_do_ignore_reloc (input_bfd, howto,
+						  input_section, contents,
+						  rel->r_offset, relocation,
+						  rel->r_addend);
+		but do_ignore_reloc would do no more than return
+		bfd_reloc_ok. */
+	      break;
+
+	    case R_NIOS2_GOT16:
+	    case R_NIOS2_CALL16:
+	      /* Relocation is to the entry for this symbol in the
+		 global offset table.  */
+	      if (sgot == NULL)
+		{
+		  r = bfd_reloc_notsupported;
+		  break;
+		}
+
+	      use_plt = 0;
+
+	      if (h != NULL)
+		{
+		  bfd_boolean dyn;
+
+		  eh = (struct elf32_nios2_link_hash_entry *)h;
+		  use_plt = (eh->got_types_used == CALL16_USED
+			     && h->plt.offset != (bfd_vma) -1);
+
+		  off = h->got.offset;
+		  BFD_ASSERT (off != (bfd_vma) -1);
+		  dyn = elf_hash_table (info)->dynamic_sections_created;
+		  if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
+		      || (info->shared
+			  && SYMBOL_REFERENCES_LOCAL (info, h))
+		      || (ELF_ST_VISIBILITY (h->other)
+			  && h->root.type == bfd_link_hash_undefweak))
+		    {
+		      /* This is actually a static link, or it is a -Bsymbolic
+			 link and the symbol is defined locally.  We must
+			 initialize this entry in the global offset table.
+			 Since the offset must always be a multiple of 4, we
+			 use the least significant bit to record whether we
+			 have initialized it already.
+
+			 When doing a dynamic link, we create a .rela.got
+			 relocation entry to initialize the value.  This is
+			 done in the finish_dynamic_symbol routine.  */
+		      if ((off & 1) != 0)
+			off &= ~1;
+		      else
+			{
+			  bfd_put_32 (output_bfd, relocation,
+				      sgot->contents + off);
+			  h->got.offset |= 1;
+			}
+		    }
+		  else
+		    unresolved_reloc = FALSE;
+		}
+	      else
+		{
+		  BFD_ASSERT (local_got_offsets != NULL
+			      && local_got_offsets[r_symndx] != (bfd_vma) -1);
+
+		  off = local_got_offsets[r_symndx];
+
+		  /* The offset must always be a multiple of 4.  We use the
+		     least significant bit to record whether we have already
+		     generated the necessary reloc.  */
+		  if ((off & 1) != 0)
+		    off &= ~1;
+		  else
+		    {
+		      bfd_put_32 (output_bfd, relocation,
+				  sgot->contents + off);
+
+		      if (info->shared)
+			{
+			  asection *srelgot;
+			  Elf_Internal_Rela outrel;
+			  bfd_byte *loc;
+
+			  srelgot = htab->root.srelgot;
+			  BFD_ASSERT (srelgot != NULL);
+
+			  outrel.r_addend = relocation;
+			  outrel.r_offset = (sgot->output_section->vma
+					     + sgot->output_offset
+					     + off);
+			  outrel.r_info = ELF32_R_INFO (0, R_NIOS2_RELATIVE);
+			  loc = srelgot->contents;
+			  loc += (srelgot->reloc_count++ *
+				  sizeof (Elf32_External_Rela));
+			  bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
+			}
+
+		      local_got_offsets[r_symndx] |= 1;
+		    }
+		}
+
+	      if (use_plt && info->shared)
+		{
+		  off = ((h->plt.offset - 24) / 12 + 3) * 4;
+		  relocation = htab->root.sgotplt->output_offset + off;
+		}
+	      else
+		relocation = sgot->output_offset + off;
+
+	      /* This relocation does not use the addend.  */
+	      rel->r_addend = 0;
+
+	      r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+					    contents, rel->r_offset,
+					    relocation, rel->r_addend);
+	      break;
+
+	    case R_NIOS2_GOTOFF_LO:
+	    case R_NIOS2_GOTOFF_HA:
+	    case R_NIOS2_GOTOFF:
+	      /* Relocation is relative to the start of the
+		 global offset table.  */
+
+	      BFD_ASSERT (sgot != NULL);
+	      if (sgot == NULL)
+		{
+		  r = bfd_reloc_notsupported;
+		  break;
+		}
+
+	      /* Note that sgot->output_offset is not involved in this
+		 calculation.  We always want the start of .got.  If we
+		 define _GLOBAL_OFFSET_TABLE in a different way, as is
+		 permitted by the ABI, we might have to change this
+		 calculation.  */
+	      relocation -= sgot->output_section->vma;
+	      switch (howto->type)
+		{
+		case R_NIOS2_GOTOFF_LO:
+		  r = nios2_elf32_do_lo16_relocate (input_bfd, howto,
+						    input_section, contents,
+						    rel->r_offset, relocation,
+						    rel->r_addend);
+		  break;
+		case R_NIOS2_GOTOFF_HA:
+		  r = nios2_elf32_do_hiadj16_relocate (input_bfd, howto,
+						       input_section, contents,
+						       rel->r_offset,
+						       relocation,
+						       rel->r_addend);
+		  break;
+		default:
+		  r = _bfd_final_link_relocate (howto, input_bfd,
+						input_section, contents,
+						rel->r_offset, relocation,
+						rel->r_addend);
+		  break;
+		}
+	      break;
+
+	    case R_NIOS2_TLS_LDO16:
+	      relocation -= dtpoff_base (info) + DTP_OFFSET;
+
+	      r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+					    contents, rel->r_offset,
+					    relocation, rel->r_addend);
+	      break;
+	    case R_NIOS2_TLS_LDM16:
+	      if (htab->root.sgot == NULL)
+		abort ();
+
+	      off = htab->tls_ldm_got.offset;
+
+	      if ((off & 1) != 0)
+		off &= ~1;
+	      else
+		{
+		  /* If we don't know the module number, create a relocation
+		     for it.  */
+		  if (info->shared)
+		    {
+		      Elf_Internal_Rela outrel;
+		      bfd_byte *loc;
+
+		      if (htab->root.srelgot == NULL)
+			abort ();
+
+		      outrel.r_addend = 0;
+		      outrel.r_offset = (htab->root.sgot->output_section->vma
+					 + htab->root.sgot->output_offset
+					 + off);
+		      outrel.r_info = ELF32_R_INFO (0, R_NIOS2_TLS_DTPMOD);
+
+		      loc = htab->root.srelgot->contents;
+		      loc += (htab->root.srelgot->reloc_count++
+			      * sizeof (Elf32_External_Rela));
+		      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
+		    }
+		  else
+		    bfd_put_32 (output_bfd, 1,
+				htab->root.sgot->contents + off);
+
+		  htab->tls_ldm_got.offset |= 1;
+		}
+
+	      relocation = (htab->root.sgot->output_offset + off);
+
+	      r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+					    contents, rel->r_offset,
+					    relocation, rel->r_addend);
+
+	      break;
+	    case R_NIOS2_TLS_GD16:
+	    case R_NIOS2_TLS_IE16:
+	      {
+		int indx;
+		char tls_type;
+
+		if (htab->root.sgot == NULL)
+		  abort ();
+
+		indx = 0;
+		if (h != NULL)
+		  {
+		    bfd_boolean dyn;
+		    dyn = htab->root.dynamic_sections_created;
+		    if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
+			&& (!info->shared
+			    || !SYMBOL_REFERENCES_LOCAL (info, h)))
+		      {
+			unresolved_reloc = FALSE;
+			indx = h->dynindx;
+		      }
+		    off = h->got.offset;
+		    tls_type = (((struct elf32_nios2_link_hash_entry *) h)
+				->tls_type);
+		  }
+		else
+		  {
+		    if (local_got_offsets == NULL)
+		      abort ();
+		    off = local_got_offsets[r_symndx];
+		    tls_type = (elf32_nios2_local_got_tls_type (input_bfd)
+				[r_symndx]);
+		  }
+
+		if (tls_type == GOT_UNKNOWN)
+		  abort ();
+
+		if ((off & 1) != 0)
+		  off &= ~1;
+		else
+		  {
+		    bfd_boolean need_relocs = FALSE;
+		    Elf_Internal_Rela outrel;
+		    bfd_byte *loc = NULL;
+		    int cur_off = off;
+
+		    /* The GOT entries have not been initialized yet.  Do it
+		       now, and emit any relocations.  If both an IE GOT and a
+		       GD GOT are necessary, we emit the GD first.  */
+
+		    if ((info->shared || indx != 0)
+			&& (h == NULL
+			    || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+			    || h->root.type != bfd_link_hash_undefweak))
+		      {
+			need_relocs = TRUE;
+			if (htab->root.srelgot == NULL)
+			  abort ();
+			loc = htab->root.srelgot->contents;
+			loc += (htab->root.srelgot->reloc_count *
+				sizeof (Elf32_External_Rela));
+		      }
+
+		    if (tls_type & GOT_TLS_GD)
+		      {
+			if (need_relocs)
+			  {
+			    outrel.r_addend = 0;
+			    outrel.r_offset = (htab->root.sgot->output_section->vma
+					       + htab->root.sgot->output_offset
+					       + cur_off);
+			    outrel.r_info = ELF32_R_INFO (indx,
+							  R_NIOS2_TLS_DTPMOD);
+
+			    bfd_elf32_swap_reloca_out (output_bfd, &outrel,
+						       loc);
+			    htab->root.srelgot->reloc_count++;
+			    loc += sizeof (Elf32_External_Rela);
+
+			    if (indx == 0)
+			      bfd_put_32 (output_bfd,
+					  (relocation - dtpoff_base (info) -
+					   DTP_OFFSET),
+					  htab->root.sgot->contents + cur_off + 4);
+			    else
+			      {
+				outrel.r_addend = 0;
+				outrel.r_info = ELF32_R_INFO (indx,
+				  R_NIOS2_TLS_DTPREL);
+				outrel.r_offset += 4;
+
+				bfd_elf32_swap_reloca_out (output_bfd, &outrel,
+							   loc);
+				htab->root.srelgot->reloc_count++;
+				loc += sizeof (Elf32_External_Rela);
+			      }
+			  }
+			else
+			  {
+			    /* If we are not emitting relocations for a
+			       general dynamic reference, then we must be in a
+			       static link or an executable link with the
+			       symbol binding locally.  Mark it as belonging
+			       to module 1, the executable.  */
+			    bfd_put_32 (output_bfd, 1,
+					htab->root.sgot->contents + cur_off);
+			    bfd_put_32 (output_bfd, (relocation -
+						     dtpoff_base (info) -
+						     DTP_OFFSET),
+					htab->root.sgot->contents + cur_off + 4);
+			  }
+
+			cur_off += 8;
+		      }
+
+		    if (tls_type & GOT_TLS_IE)
+		      {
+			if (need_relocs)
+			  {
+			    if (indx == 0)
+			      outrel.r_addend = (relocation -
+						 dtpoff_base (info));
+			    else
+			      outrel.r_addend = 0;
+			    outrel.r_offset = (htab->root.sgot->output_section->vma
+					       + htab->root.sgot->output_offset
+					       + cur_off);
+			    outrel.r_info = ELF32_R_INFO (indx,
+							  R_NIOS2_TLS_TPREL);
+
+			    bfd_elf32_swap_reloca_out (output_bfd, &outrel,
+						       loc);
+			    htab->root.srelgot->reloc_count++;
+			    loc += sizeof (Elf32_External_Rela);
+			  }
+			else
+			  bfd_put_32 (output_bfd, (tpoff (info, relocation)
+						   - TP_OFFSET),
+				      htab->root.sgot->contents + cur_off);
+			cur_off += 4;
+		      }
+
+		    if (h != NULL)
+		      h->got.offset |= 1;
+		    else
+		      local_got_offsets[r_symndx] |= 1;
+		  }
+
+		if ((tls_type & GOT_TLS_GD) && r_type != R_NIOS2_TLS_GD16)
+		  off += 8;
+		relocation = (htab->root.sgot->output_offset + off);
+
+		r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+					      contents, rel->r_offset,
+					      relocation, rel->r_addend);
+	      }
+
+	      break;
+	    case R_NIOS2_TLS_LE16:
+	      if (info->shared && !info->pie)
+		{
+		  (*_bfd_error_handler)
+		    (_("%B(%A+0x%lx): R_NIOS2_TLS_LE16 relocation not "
+		       "permitted in shared object"),
+		     input_bfd, input_section,
+		     (long) rel->r_offset, howto->name);
+		  return FALSE;
+		}
+	      else
+		relocation = tpoff (info, relocation) - TP_OFFSET;
+
+	      r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+					    contents, rel->r_offset,
+					    relocation, rel->r_addend);
+	      break;
+
+	    case R_NIOS2_BFD_RELOC_32:
+	      if (info->shared
+		  && (input_section->flags & SEC_ALLOC) != 0
+		  && (h == NULL
+		      || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+		      || h->root.type != bfd_link_hash_undefweak))
+		{
+		  Elf_Internal_Rela outrel;
+		  bfd_byte *loc;
+		  bfd_boolean skip, relocate;
+
+		  /* When generating a shared object, these relocations
+		     are copied into the output file to be resolved at run
+		     time.  */
+
+		  skip = FALSE;
+		  relocate = FALSE;
+
+		  outrel.r_offset
+		    = _bfd_elf_section_offset (output_bfd, info,
+					       input_section, rel->r_offset);
+		  if (outrel.r_offset == (bfd_vma) -1)
+		    skip = TRUE;
+		  else if (outrel.r_offset == (bfd_vma) -2)
+		    skip = TRUE, relocate = TRUE;
+		  outrel.r_offset += (input_section->output_section->vma
+				      + input_section->output_offset);
+
+		  if (skip)
+		    memset (&outrel, 0, sizeof outrel);
+		  else if (h != NULL
+			   && h->dynindx != -1
+			   && (!info->shared
+			       || !info->symbolic
+			       || !h->def_regular))
+		    {
+		      outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
+		      outrel.r_addend = rel->r_addend;
+		    }
+		  else
+		    {
+		      /* This symbol is local, or marked to become local.  */
+		      outrel.r_addend = relocation + rel->r_addend;
+		      relocate = TRUE;
+		      outrel.r_info = ELF32_R_INFO (0, R_NIOS2_RELATIVE);
+		    }
+
+		  sreloc = elf_section_data (input_section)->sreloc;
+		  if (sreloc == NULL)
+		    abort ();
+
+		  loc = sreloc->contents;
+		  loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela);
+		  bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
+
+		  /* This reloc will be computed at runtime, so there's no
+		     need to do anything now, except for R_NIOS2_BFD_RELOC_32
+		     relocations that have been turned into
+		     R_NIOS2_RELATIVE.  */
+		  if (!relocate)
+		    break;
+		}
+
+	      r = _bfd_final_link_relocate (howto, input_bfd,
+					    input_section, contents,
+					    rel->r_offset, relocation,
+					    rel->r_addend);
+	      break;
+
+	    case R_NIOS2_TLS_DTPREL:
+	      relocation -= dtpoff_base (info);
+	      /* Fall through.  */
+
+	    default:
+	      r = _bfd_final_link_relocate (howto, input_bfd,
+					    input_section, contents,
+					    rel->r_offset, relocation,
+					    rel->r_addend);
+	      break;
+	    }
+	}
+      else
+	r = bfd_reloc_notsupported;
+
+      if (r != bfd_reloc_ok)
+	{
+	  if (h != NULL)
+	    name = h->root.root.string;
+	  else
+	    {
+	      name = bfd_elf_string_from_elf_section (input_bfd,
+						      symtab_hdr->sh_link,
+						      sym->st_name);
+	      if (name == NULL || *name == '\0')
+		name = bfd_section_name (input_bfd, sec);
+	    }
+
+	  switch (r)
+	    {
+	    case bfd_reloc_overflow:
+	      r = info->callbacks->reloc_overflow (info, NULL, name,
+						   howto->name, (bfd_vma) 0,
+						   input_bfd, input_section,
+						   rel->r_offset);
+	      break;
+
+	    case bfd_reloc_undefined:
+	      r = info->callbacks->undefined_symbol (info, name, input_bfd,
+						     input_section,
+						     rel->r_offset, TRUE);
+	      break;
+
+	    case bfd_reloc_outofrange:
+	      if (msg == NULL)
+		msg = _("relocation out of range");
+	      break;
+
+	    case bfd_reloc_notsupported:
+	      if (msg == NULL)
+		msg = _("unsupported relocation");
+	      break;
+
+	    case bfd_reloc_dangerous:
+	      if (msg == NULL)
+		msg = _("dangerous relocation");
+	      break;
+
+	    default:
+	      if (msg == NULL)
+		msg = _("unknown error");
+	      break;
+	    }
+
+	  if (msg)
+	    {
+	      r = info->callbacks->warning
+		(info, msg, name, input_bfd, input_section, rel->r_offset);
+	      return FALSE;
+	    }
+	}
+    }
+  return TRUE;
+}
+
+/* Implement elf-backend_section_flags:
+   Convert NIOS2 specific section flags to bfd internal section flags.  */
+static bfd_boolean
+nios2_elf32_section_flags (flagword *flags, const Elf_Internal_Shdr *hdr)
+{
+  if (hdr->sh_flags & SHF_NIOS2_GPREL)
+    *flags |= SEC_SMALL_DATA;
+
+  return TRUE;
+}
+
+/* Implement elf_backend_fake_sections:
+   Set the correct type for an NIOS2 ELF section.  We do this by the
+   section name, which is a hack, but ought to work.  */
+static bfd_boolean
+nios2_elf32_fake_sections (bfd *abfd ATTRIBUTE_UNUSED,
+			   Elf_Internal_Shdr *hdr, asection *sec)
+{
+  register const char *name = bfd_get_section_name (abfd, sec);
+
+  if ((sec->flags & SEC_SMALL_DATA)
+      || strcmp (name, ".sdata") == 0
+      || strcmp (name, ".sbss") == 0
+      || strcmp (name, ".lit4") == 0 || strcmp (name, ".lit8") == 0)
+    hdr->sh_flags |= SHF_NIOS2_GPREL;
+
+  return TRUE;
+}
+
+/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
+   shortcuts to them in our hash table.  */
+static bfd_boolean
+create_got_section (bfd *dynobj, struct bfd_link_info *info)
+{
+  struct elf32_nios2_link_hash_table *htab;
+
+  htab = elf32_nios2_hash_table (info);
+
+  if (! _bfd_elf_create_got_section (dynobj, info))
+    return FALSE;
+
+  /* In order for the two loads in .PLTresolve to share the same %hiadj,
+     _GLOBAL_OFFSET_TABLE_ must be aligned to a 16-byte boundary.  */
+  if (!bfd_set_section_alignment (dynobj, htab->root.sgotplt, 4))
+    return FALSE;
+
+  return TRUE;
+}
+
+/* Implement elf_backend_create_dynamic_sections:
+   Create .plt, .rela.plt, .got, .got.plt, .rela.got, .dynbss, and
+   .rela.bss sections in DYNOBJ, and set up shortcuts to them in our
+   hash table.  */
+static bfd_boolean
+nios2_elf32_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
+{
+  struct elf32_nios2_link_hash_table *htab;
+
+  htab = elf32_nios2_hash_table (info);
+  if (!htab->root.sgot && !create_got_section (dynobj, info))
+    return FALSE;
+
+  _bfd_elf_create_dynamic_sections (dynobj, info);
+
+  /* In order for the two loads in a shared object .PLTresolve to share the
+     same %hiadj, the start of the PLT (as well as the GOT) must be aligned
+     to a 16-byte boundary.  This is because the addresses for these loads
+     include the -(.plt+4) PIC correction.  */
+  if (!bfd_set_section_alignment (dynobj, htab->root.splt, 4))
+    return FALSE;
+
+  htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
+  if (!htab->sdynbss)
+    return FALSE;
+  if (!info->shared)
+    {
+      htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
+      if (!htab->srelbss)
+	return FALSE;
+    }
+
+  return TRUE;
+}
+
+/* Implement elf_backend_copy_indirect_symbol:
+   Copy the extra info we tack onto an elf_link_hash_entry.  */
+static void
+nios2_elf32_copy_indirect_symbol (struct bfd_link_info *info,
+				  struct elf_link_hash_entry *dir,
+				  struct elf_link_hash_entry *ind)
+{
+  struct elf32_nios2_link_hash_entry *edir, *eind;
+
+  edir = (struct elf32_nios2_link_hash_entry *) dir;
+  eind = (struct elf32_nios2_link_hash_entry *) ind;
+
+  if (eind->dyn_relocs != NULL)
+    {
+      if (edir->dyn_relocs != NULL)
+	{
+	  struct elf32_nios2_dyn_relocs **pp;
+	  struct elf32_nios2_dyn_relocs *p;
+
+	  /* Add reloc counts against the indirect sym to the direct sym
+	     list.  Merge any entries against the same section.  */
+	  for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
+	    {
+	      struct elf32_nios2_dyn_relocs *q;
+
+	      for (q = edir->dyn_relocs; q != NULL; q = q->next)
+		if (q->sec == p->sec)
+		  {
+		    q->pc_count += p->pc_count;
+		    q->count += p->count;
+		    *pp = p->next;
+		    break;
+		  }
+	      if (q == NULL)
+		pp = &p->next;
+	    }
+	  *pp = edir->dyn_relocs;
+	}
+
+      edir->dyn_relocs = eind->dyn_relocs;
+      eind->dyn_relocs = NULL;
+    }
+
+  if (ind->root.type == bfd_link_hash_indirect
+      && dir->got.refcount <= 0)
+    {
+      edir->tls_type = eind->tls_type;
+      eind->tls_type = GOT_UNKNOWN;
+    }
+
+  edir->got_types_used |= eind->got_types_used;
+
+  _bfd_elf_link_hash_copy_indirect (info, dir, ind);
+}
+
+/* Implement elf_backend_check_relocs:
+   Look through the relocs for a section during the first phase.  */
+static bfd_boolean
+nios2_elf32_check_relocs (bfd *abfd, struct bfd_link_info *info,
+			  asection *sec, const Elf_Internal_Rela *relocs)
+{
+  bfd *dynobj;
+  Elf_Internal_Shdr *symtab_hdr;
+  struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
+  const Elf_Internal_Rela *rel;
+  const Elf_Internal_Rela *rel_end;
+  struct elf32_nios2_link_hash_table *htab;
+  asection *sgot;
+  asection *srelgot;
+  asection *sreloc = NULL;
+  bfd_signed_vma *local_got_refcounts;
+
+  if (info->relocatable)
+    return TRUE;
+
+  dynobj = elf_hash_table (info)->dynobj;
+  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+  sym_hashes = elf_sym_hashes (abfd);
+  sym_hashes_end = (sym_hashes
+		    + symtab_hdr->sh_size / sizeof (Elf32_External_Sym));
+  if (!elf_bad_symtab (abfd))
+    sym_hashes_end -= symtab_hdr->sh_info;
+  local_got_refcounts = elf_local_got_refcounts (abfd);
+
+  htab = elf32_nios2_hash_table (info);
+  sgot = htab->root.sgot;
+  srelgot = htab->root.srelgot;
+
+  rel_end = relocs + sec->reloc_count;
+  for (rel = relocs; rel < rel_end; rel++)
+    {
+      unsigned int r_type;
+      struct elf_link_hash_entry *h;
+      unsigned long r_symndx;
+
+      r_symndx = ELF32_R_SYM (rel->r_info);
+      if (r_symndx < symtab_hdr->sh_info)
+	h = NULL;
+      else
+	{
+	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
+	}
+
+      r_type = ELF32_R_TYPE (rel->r_info);
+
+      switch (r_type)
+	{
+	case R_NIOS2_GOT16:
+	case R_NIOS2_CALL16:
+	case R_NIOS2_TLS_GD16:
+	case R_NIOS2_TLS_IE16:
+	  /* This symbol requires a global offset table entry.  */
+	  {
+	    int tls_type, old_tls_type;
+
+	    switch (r_type)
+	      {
+	      default:
+	      case R_NIOS2_GOT16:
+	      case R_NIOS2_CALL16:
+		tls_type = GOT_NORMAL;
+		break;
+	      case R_NIOS2_TLS_GD16:
+		tls_type = GOT_TLS_GD;
+		break;
+	      case R_NIOS2_TLS_IE16:
+		tls_type = GOT_TLS_IE;
+		break;
+	      }
+
+	    if (dynobj == NULL)
+	      {
+		/* Create the .got section.  */
+		elf_hash_table (info)->dynobj = dynobj = abfd;
+		nios2_elf32_create_dynamic_sections (dynobj, info);
+	      }
+
+	    if (sgot == NULL)
+	      {
+		sgot = htab->root.sgot;
+		BFD_ASSERT (sgot != NULL);
+	      }
+
+	    if (srelgot == NULL
+		&& (h != NULL || info->shared))
+	      {
+		srelgot = htab->root.srelgot;
+		BFD_ASSERT (srelgot != NULL);
+	      }
+
+	    if (h != NULL)
+	      {
+		struct elf32_nios2_link_hash_entry *eh
+		  = (struct elf32_nios2_link_hash_entry *)h;
+		h->got.refcount++;
+		old_tls_type = elf32_nios2_hash_entry(h)->tls_type;
+		if (r_type == R_NIOS2_CALL16)
+		  {
+		    /* Make sure a plt entry is created for this symbol if
+		       it turns out to be a function defined by a dynamic
+		       object.  */
+		    h->plt.refcount++;
+		    h->needs_plt = 1;
+		    h->type = STT_FUNC;
+		    eh->got_types_used |= CALL16_USED;
+		  }
+		else
+		  eh->got_types_used |= GOT16_USED;
+	      }
+	    else
+	      {
+		/* This is a global offset table entry for a local symbol.  */
+		if (local_got_refcounts == NULL)
+		  {
+		    bfd_size_type size;
+
+		    size = symtab_hdr->sh_info;
+		    size *= (sizeof (bfd_signed_vma) + sizeof (char));
+		    local_got_refcounts
+		      = ((bfd_signed_vma *) bfd_zalloc (abfd, size));
+		    if (local_got_refcounts == NULL)
+		      return FALSE;
+		    elf_local_got_refcounts (abfd) = local_got_refcounts;
+		    elf32_nios2_local_got_tls_type (abfd)
+		      = (char *) (local_got_refcounts + symtab_hdr->sh_info);
+		  }
+		local_got_refcounts[r_symndx]++;
+		old_tls_type = elf32_nios2_local_got_tls_type (abfd) [r_symndx];
+	      }
+
+	    /* We will already have issued an error message if there is a
+	       TLS / non-TLS mismatch, based on the symbol type.  We don't
+	       support any linker relaxations.  So just combine any TLS
+	       types needed.  */
+	    if (old_tls_type != GOT_UNKNOWN && old_tls_type != GOT_NORMAL
+		&& tls_type != GOT_NORMAL)
+	      tls_type |= old_tls_type;
+
+	    if (old_tls_type != tls_type)
+	      {
+		if (h != NULL)
+		  elf32_nios2_hash_entry (h)->tls_type = tls_type;
+		else
+		  elf32_nios2_local_got_tls_type (abfd) [r_symndx] = tls_type;
+	      }
+	  }
+	  /* Fall through */
+	case R_NIOS2_TLS_LDM16:
+	  if (r_type == R_NIOS2_TLS_LDM16)
+	    htab->tls_ldm_got.refcount++;
+
+	  if (htab->root.sgot == NULL)
+	    {
+	      if (htab->root.dynobj == NULL)
+		htab->root.dynobj = abfd;
+	      if (!create_got_section (htab->root.dynobj, info))
+		return FALSE;
+	    }
+	  break;
+
+	  /* This relocation describes the C++ object vtable hierarchy.
+	     Reconstruct it for later use during GC.  */
+	case R_NIOS2_GNU_VTINHERIT:
+	  if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+	    return FALSE;
+	  break;
+
+	  /* This relocation describes which C++ vtable entries are actually
+	     used.  Record for later use during GC.  */
+	case R_NIOS2_GNU_VTENTRY:
+	  if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+	    return FALSE;
+	  break;
+
+	case R_NIOS2_BFD_RELOC_32:
+	case R_NIOS2_CALL26:
+	case R_NIOS2_HIADJ16:
+	case R_NIOS2_LO16:
+
+	  if (h != NULL)
+	    {
+	      /* If this reloc is in a read-only section, we might
+		   need a copy reloc.  We can't check reliably at this
+		   stage whether the section is read-only, as input
+		   sections have not yet been mapped to output sections.
+		   Tentatively set the flag for now, and correct in
+		   adjust_dynamic_symbol.  */
+	      if (!info->shared)
+		h->non_got_ref = 1;
+
+	      /* Make sure a plt entry is created for this symbol if it
+		 turns out to be a function defined by a dynamic object.  */
+	      h->plt.refcount++;
+
+	      if (r_type == R_NIOS2_CALL26)
+		h->needs_plt = 1;
+	    }
+
+	  /* If we are creating a shared library, we need to copy the
+	     reloc into the shared library.  */
+	  if (info->shared
+	      && (sec->flags & SEC_ALLOC) != 0
+	      && (r_type == R_NIOS2_BFD_RELOC_32
+		  || (h != NULL && ! h->needs_plt
+		      && (! info->symbolic || ! h->def_regular))))
+	    {
+	      struct elf32_nios2_dyn_relocs *p;
+	      struct elf32_nios2_dyn_relocs **head;
+
+	      /* When creating a shared object, we must copy these
+		 reloc types into the output file.  We create a reloc
+		 section in dynobj and make room for this reloc.  */
+	      if (sreloc == NULL)
+		{
+		  sreloc = _bfd_elf_make_dynamic_reloc_section
+		    (sec, dynobj, 2, abfd, TRUE);
+		  if (sreloc == NULL)
+		    return FALSE;
+		}
+
+	      /* If this is a global symbol, we count the number of
+		 relocations we need for this symbol.  */
+	      if (h != NULL)
+		head = &((struct elf32_nios2_link_hash_entry *) h)->dyn_relocs;
+	      else
+		{
+		  /* Track dynamic relocs needed for local syms too.
+		     We really need local syms available to do this
+		     easily.  Oh well.  */
+
+		  asection *s;
+		  void *vpp;
+		  Elf_Internal_Sym *isym;
+
+		  isym = bfd_sym_from_r_symndx (&htab->sym_cache,
+						abfd, r_symndx);
+		  if (isym == NULL)
+		    return FALSE;
+
+		  s = bfd_section_from_elf_index (abfd, isym->st_shndx);
+		  if (s == NULL)
+		    s = sec;
+
+		  vpp = &elf_section_data (s)->local_dynrel;
+		  head = (struct elf32_nios2_dyn_relocs **) vpp;
+		}
+
+	      p = *head;
+	      if (p == NULL || p->sec != sec)
+		{
+		  bfd_size_type amt = sizeof *p;
+		  p = ((struct elf32_nios2_dyn_relocs *)
+		       bfd_alloc (htab->root.dynobj, amt));
+		  if (p == NULL)
+		    return FALSE;
+		  p->next = *head;
+		  *head = p;
+		  p->sec = sec;
+		  p->count = 0;
+		  p->pc_count = 0;
+		}
+
+	      p->count += 1;
+
+	    }
+	  break;
+	}
+    }
+
+  return TRUE;
+}
+
+
+/* Implement elf_backend_gc_mark_hook:
+   Return the section that should be marked against GC for a given
+   relocation.  */
+static asection *
+nios2_elf32_gc_mark_hook (asection *sec,
+			  struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			  Elf_Internal_Rela *rel,
+			  struct elf_link_hash_entry *h,
+			  Elf_Internal_Sym *sym)
+{
+  if (h != NULL)
+    switch (ELF32_R_TYPE (rel->r_info))
+      {
+      case R_NIOS2_GNU_VTINHERIT:
+      case R_NIOS2_GNU_VTENTRY:
+	return NULL;
+      }
+  return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
+}
+
+/* Implement elf_backend_gc_sweep_hook:
+   Update the got entry reference counts for the section being removed.  */
+static bfd_boolean
+nios2_elf32_gc_sweep_hook (bfd *abfd,
+			   struct bfd_link_info *info,
+			   asection *sec,
+			   const Elf_Internal_Rela *relocs)
+{
+  Elf_Internal_Shdr *symtab_hdr;
+  struct elf_link_hash_entry **sym_hashes;
+  bfd_signed_vma *local_got_refcounts;
+  const Elf_Internal_Rela *rel, *relend;
+  bfd *dynobj;
+
+  if (info->relocatable)
+    return TRUE;
+
+  elf_section_data (sec)->local_dynrel = NULL;
+
+  dynobj = elf_hash_table (info)->dynobj;
+  if (dynobj == NULL)
+    return TRUE;
+
+  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+  sym_hashes = elf_sym_hashes (abfd);
+  local_got_refcounts = elf_local_got_refcounts (abfd);
+
+  relend = relocs + sec->reloc_count;
+  for (rel = relocs; rel < relend; rel++)
+    {
+      unsigned long r_symndx;
+      struct elf_link_hash_entry *h = NULL;
+      int r_type;
+
+      r_symndx = ELF32_R_SYM (rel->r_info);
+      if (r_symndx >= symtab_hdr->sh_info)
+	{
+	  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_NIOS2_GOT16:
+	case R_NIOS2_CALL16:
+	  if (h != NULL)
+	    {
+	      if (h->got.refcount > 0)
+		--h->got.refcount;
+	    }
+	  else if (local_got_refcounts != NULL)
+	    {
+	      if (local_got_refcounts[r_symndx] > 0)
+		--local_got_refcounts[r_symndx];
+	    }
+	  break;
+
+	case R_NIOS2_PCREL_LO:
+	case R_NIOS2_PCREL_HA:
+	case R_NIOS2_BFD_RELOC_32:
+	case R_NIOS2_CALL26:
+	  if (h != NULL)
+	    {
+	      struct elf32_nios2_link_hash_entry *eh;
+	      struct elf32_nios2_dyn_relocs **pp;
+	      struct elf32_nios2_dyn_relocs *p;
+
+	      eh = (struct elf32_nios2_link_hash_entry *) h;
+
+	      if (h->plt.refcount > 0)
+		--h->plt.refcount;
+
+	      if (r_type == R_NIOS2_PCREL_LO || r_type == R_NIOS2_PCREL_HA
+		  || r_type == R_NIOS2_BFD_RELOC_32)
+		{
+		  for (pp = &eh->dyn_relocs; (p = *pp) != NULL;
+		       pp = &p->next)
+		    if (p->sec == sec)
+		      {
+			p->count -= 1;
+			if (p->count == 0)
+			  *pp = p->next;
+			break;
+		      }
+		}
+	    }
+	  break;
+
+	default:
+	  break;
+	}
+    }
+
+  return TRUE;
+}
+
+/* Install 16-bit immediate value VALUE at offset OFFSET into section SEC.  */
+static void
+nios2_elf32_install_imm16 (asection *sec, bfd_vma offset, bfd_vma value)
+{
+  bfd_vma word = bfd_get_32 (sec->owner, sec->contents + offset);
+
+  BFD_ASSERT(value <= 0xffff);
+
+  bfd_put_32 (sec->owner, word | ((value & 0xffff) << 6),
+	      sec->contents + offset);
+}
+
+/* Install COUNT 32-bit values DATA starting at offset OFFSET into
+   section SEC. */
+static void
+nios2_elf32_install_data (asection *sec, const bfd_vma *data, bfd_vma offset,
+			  int count)
+{
+  while (count--)
+    {
+      bfd_put_32 (sec->owner, *data, sec->contents + offset);
+      offset += 4;
+      ++data;
+    }
+}
+
+/* Implement elf_backend_finish_dynamic_symbols:
+   Finish up dynamic symbol handling.  We set the contents of various
+   dynamic sections here.  */
+static bfd_boolean
+nios2_elf32_finish_dynamic_symbol (bfd *output_bfd,
+				   struct bfd_link_info *info,
+				   struct elf_link_hash_entry *h,
+				   Elf_Internal_Sym *sym)
+{
+  struct elf32_nios2_link_hash_table *htab;
+  struct elf32_nios2_link_hash_entry *eh
+    = (struct elf32_nios2_link_hash_entry *)h;
+  int use_plt;
+
+  htab = elf32_nios2_hash_table (info);
+
+  if (h->plt.offset != (bfd_vma) -1)
+    {
+      asection *splt;
+      asection *sgotplt;
+      asection *srela;
+      bfd_vma plt_index;
+      bfd_vma got_offset;
+      Elf_Internal_Rela rela;
+      bfd_byte *loc;
+      bfd_vma got_address;
+
+      /* This symbol has an entry in the procedure linkage table.  Set
+	 it up.  */
+      BFD_ASSERT (h->dynindx != -1);
+      splt = htab->root.splt;
+      sgotplt = htab->root.sgotplt;
+      srela = htab->root.srelplt;
+      BFD_ASSERT (splt != NULL && sgotplt != NULL && srela != NULL);
+
+      /* Emit the PLT entry.  */
+      if (info->shared)
+	{
+	  nios2_elf32_install_data (splt, nios2_so_plt_entry, h->plt.offset,
+				    3);
+	  plt_index = (h->plt.offset - 24) / 12;
+	  got_offset = (plt_index + 3) * 4;
+	  nios2_elf32_install_imm16 (splt, h->plt.offset,
+				     hiadj(plt_index * 4));
+	  nios2_elf32_install_imm16 (splt, h->plt.offset + 4,
+				     (plt_index * 4) & 0xffff);
+	  nios2_elf32_install_imm16 (splt, h->plt.offset + 8,
+				     0xfff4 - h->plt.offset);
+	  got_address = (sgotplt->output_section->vma + sgotplt->output_offset
+			 + got_offset);
+
+	  /* Fill in the entry in the global offset table.  There are no
+	     res_n slots for a shared object PLT, instead the .got.plt entries
+	     point to the PLT entries.  */
+	  bfd_put_32 (output_bfd,
+		      splt->output_section->vma + splt->output_offset
+		      + h->plt.offset, sgotplt->contents + got_offset);
+	}
+      else
+	{
+	  plt_index = (h->plt.offset - 28 - htab->res_n_size) / 12;
+	  got_offset = (plt_index + 3) * 4;
+
+	  nios2_elf32_install_data (splt, nios2_plt_entry, h->plt.offset, 3);
+	  got_address = (sgotplt->output_section->vma + sgotplt->output_offset
+			 + got_offset);
+	  nios2_elf32_install_imm16 (splt, h->plt.offset, hiadj(got_address));
+	  nios2_elf32_install_imm16 (splt, h->plt.offset + 4,
+				     got_address & 0xffff);
+
+	  /* Fill in the entry in the global offset table.  */
+	  bfd_put_32 (output_bfd,
+		      splt->output_section->vma + splt->output_offset
+		      + plt_index * 4, sgotplt->contents + got_offset);
+	}
+
+      /* Fill in the entry in the .rela.plt section.  */
+      rela.r_offset = got_address;
+      rela.r_info = ELF32_R_INFO (h->dynindx, R_NIOS2_JUMP_SLOT);
+      rela.r_addend = 0;
+      loc = srela->contents + plt_index * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
+
+      if (!h->def_regular)
+	{
+	  /* Mark the symbol as undefined, rather than as defined in
+	     the .plt section.  Leave the value alone.  */
+	  sym->st_shndx = SHN_UNDEF;
+	  /* If the symbol is weak, we do need to clear the value.
+	     Otherwise, the PLT entry would provide a definition for
+	     the symbol even if the symbol wasn't defined anywhere,
+	     and so the symbol would never be NULL.  */
+	  if (!h->ref_regular_nonweak)
+	    sym->st_value = 0;
+	}
+    }
+
+  use_plt = (eh->got_types_used == CALL16_USED
+	     && h->plt.offset != (bfd_vma) -1);
+
+  if (!use_plt && h->got.offset != (bfd_vma) -1
+      && (elf32_nios2_hash_entry (h)->tls_type & GOT_TLS_GD) == 0
+      && (elf32_nios2_hash_entry (h)->tls_type & GOT_TLS_IE) == 0)
+    {
+      asection *sgot;
+      asection *srela;
+      Elf_Internal_Rela rela;
+      bfd_byte *loc;
+      bfd_vma offset;
+
+      /* This symbol has an entry in the global offset table.  Set it
+	 up.  */
+      sgot = htab->root.sgot;
+      srela = htab->root.srelgot;
+      BFD_ASSERT (sgot != NULL && srela != NULL);
+
+      offset = (h->got.offset & ~(bfd_vma) 1);
+      rela.r_offset = (sgot->output_section->vma
+		       + sgot->output_offset + offset);
+
+      /* If this is a -Bsymbolic link, and the symbol is defined
+	 locally, we just want to emit a RELATIVE reloc.  Likewise if
+	 the symbol was forced to be local because of a version file.
+	 The entry in the global offset table will already have been
+	 initialized in the relocate_section function.  */
+
+      if (info->shared && SYMBOL_REFERENCES_LOCAL (info, h))
+	{
+	  rela.r_info = ELF32_R_INFO (0, R_NIOS2_RELATIVE);
+	  rela.r_addend = bfd_get_signed_32 (output_bfd,
+					     (sgot->contents + offset));
+	  bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + offset);
+	}
+      else
+	{
+	  bfd_put_32 (output_bfd, (bfd_vma) 0,
+		      sgot->contents + offset);
+	  rela.r_info = ELF32_R_INFO (h->dynindx, R_NIOS2_GLOB_DAT);
+	  rela.r_addend = 0;
+	}
+
+      loc = srela->contents;
+      loc += srela->reloc_count++ * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
+    }
+
+  if (use_plt && h->got.offset != (bfd_vma) -1)
+    {
+      bfd_vma offset = (h->got.offset & ~(bfd_vma) 1);
+      asection *sgot = htab->root.sgot;
+      asection *splt = htab->root.splt;
+      bfd_put_32 (output_bfd, (splt->output_section->vma + splt->output_offset
+			       + h->plt.offset),
+		  sgot->contents + offset);
+    }
+
+  if (h->needs_copy)
+    {
+      asection *s;
+      Elf_Internal_Rela rela;
+      bfd_byte *loc;
+
+      /* This symbol needs a copy reloc.  Set it up.  */
+      BFD_ASSERT (h->dynindx != -1
+		  && (h->root.type == bfd_link_hash_defined
+		      || h->root.type == bfd_link_hash_defweak));
+
+      s = htab->srelbss;
+      BFD_ASSERT (s != NULL);
+
+      rela.r_offset = (h->root.u.def.value
+		       + h->root.u.def.section->output_section->vma
+		       + h->root.u.def.section->output_offset);
+      rela.r_info = ELF32_R_INFO (h->dynindx, R_NIOS2_COPY);
+      rela.r_addend = 0;
+      loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
+    }
+
+  /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
+  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+      || h == elf_hash_table (info)->hgot)
+    sym->st_shndx = SHN_ABS;
+
+  return TRUE;
+}
+
+/* Implement elf_backend_finish_dynamic_sections.  */
+static bfd_boolean
+nios2_elf32_finish_dynamic_sections (bfd *output_bfd,
+				     struct bfd_link_info *info)
+{
+  bfd *dynobj;
+  asection *sgotplt;
+  asection *sdyn;
+  struct elf32_nios2_link_hash_table *htab;
+
+  htab = elf32_nios2_hash_table (info);
+  dynobj = elf_hash_table (info)->dynobj;
+  sgotplt = htab->root.sgotplt;
+  BFD_ASSERT (sgotplt != NULL);
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
+
+  if (elf_hash_table (info)->dynamic_sections_created)
+    {
+      asection *splt;
+      Elf32_External_Dyn *dyncon, *dynconend;
+
+      splt = htab->root.splt;
+      BFD_ASSERT (splt != NULL && sdyn != NULL);
+
+      dyncon = (Elf32_External_Dyn *) sdyn->contents;
+      dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size);
+      for (; dyncon < dynconend; dyncon++)
+	{
+	  Elf_Internal_Dyn dyn;
+	  asection *s;
+
+	  bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
+
+	  switch (dyn.d_tag)
+	    {
+	    default:
+	      break;
+
+	    case DT_PLTGOT:
+	      s = htab->root.sgot;
+	      BFD_ASSERT (s != NULL);
+	      dyn.d_un.d_ptr = s->output_section->vma;
+	      bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+	      break;
+
+	    case DT_JMPREL:
+	      s = htab->root.srelplt;
+	      BFD_ASSERT (s != NULL);
+	      dyn.d_un.d_ptr = s->output_section->vma;
+	      bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+	      break;
+
+	    case DT_PLTRELSZ:
+	      s = htab->root.srelplt;
+	      BFD_ASSERT (s != NULL);
+	      dyn.d_un.d_val = s->size;
+	      bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+	      break;
+
+	    case DT_RELASZ:
+	      /* The procedure linkage table relocs (DT_JMPREL) should
+		 not be included in the overall relocs (DT_RELA).
+		 Therefore, we override the DT_RELASZ entry here to
+		 make it not include the JMPREL relocs.  Since the
+		 linker script arranges for .rela.plt to follow all
+		 other relocation sections, we don't have to worry
+		 about changing the DT_RELA entry.  */
+	      s = htab->root.srelplt;
+	      if (s != NULL)
+		dyn.d_un.d_val -= s->size;
+	      bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+	      break;
+
+	    case DT_NIOS2_GP:
+	      s = htab->root.sgot;
+	      BFD_ASSERT (s != NULL);
+	      dyn.d_un.d_ptr = s->output_section->vma + 0x7ff0;
+	      bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
+	      break;
+	    }
+	}
+
+      /* Fill in the first entry in the procedure linkage table.  */
+      if (splt->size > 0)
+	{
+	  bfd_vma got_address = (sgotplt->output_section->vma
+				 + sgotplt->output_offset);
+	  if (info->shared)
+	    {
+	      bfd_vma corrected = got_address - (splt->output_section->vma
+						 + splt->output_offset + 4);
+	      nios2_elf32_install_data (splt, nios2_so_plt0_entry, 0, 6);
+	      nios2_elf32_install_imm16 (splt, 4, hiadj (corrected));
+	      nios2_elf32_install_imm16 (splt, 12, (corrected & 0xffff) + 4);
+	      nios2_elf32_install_imm16 (splt, 16, (corrected & 0xffff) + 8);
+	    }
+	  else
+	    {
+	      /* Divide by 4 here, not 3 because we already corrected for the
+		 res_N branches.  */
+	      bfd_vma res_size = (splt->size - 28) / 4;
+	      bfd_vma res_start = (splt->output_section->vma
+				   + splt->output_offset);
+	      bfd_vma res_offset;
+
+	      for (res_offset = 0; res_offset < res_size; res_offset += 4)
+		bfd_put_32 (output_bfd,
+			    6 | ((res_size - (res_offset + 4)) << 6),
+			    splt->contents + res_offset);
+
+	      nios2_elf32_install_data (splt, nios2_plt0_entry, res_size, 7);
+	      nios2_elf32_install_imm16 (splt, res_size, hiadj (res_start));
+	      nios2_elf32_install_imm16 (splt, res_size + 4,
+					 res_start & 0xffff);
+	      nios2_elf32_install_imm16 (splt, res_size + 12,
+					 hiadj (got_address));
+	      nios2_elf32_install_imm16 (splt, res_size + 16,
+					 (got_address & 0xffff) + 4);
+	      nios2_elf32_install_imm16 (splt, res_size + 20,
+					 (got_address & 0xffff) + 8);
+	    }
+	}
+    }
+  /* Fill in the first three entries in the global offset table.  */
+  if (sgotplt->size > 0)
+    {
+      if (sdyn == NULL)
+	bfd_put_32 (output_bfd, (bfd_vma) 0, sgotplt->contents);
+      else
+	bfd_put_32 (output_bfd,
+		    sdyn->output_section->vma + sdyn->output_offset,
+		    sgotplt->contents);
+      bfd_put_32 (output_bfd, (bfd_vma) 0, sgotplt->contents + 4);
+      bfd_put_32 (output_bfd, (bfd_vma) 0, sgotplt->contents + 8);
+    }
+
+  elf_section_data (sgotplt->output_section)->this_hdr.sh_entsize = 4;
+
+  return TRUE;
+}
+
+/* Implement elf_backend_adjust_dynamic_symbol:
+   Adjust a symbol defined by a dynamic object and referenced by a
+   regular object.  The current definition is in some section of the
+   dynamic object, but we're not including those sections.  We have to
+   change the definition to something the rest of the link can
+   understand.  */
+static bfd_boolean
+nios2_elf32_adjust_dynamic_symbol (struct bfd_link_info *info,
+				   struct elf_link_hash_entry *h)
+{
+  struct elf32_nios2_link_hash_table *htab;
+  bfd *dynobj;
+  asection *s;
+  unsigned align2;
+
+  htab = elf32_nios2_hash_table (info);
+  dynobj = elf_hash_table (info)->dynobj;
+
+  /* Make sure we know what is going on here.  */
+  BFD_ASSERT (dynobj != NULL
+	      && (h->needs_plt
+		  || h->u.weakdef != NULL
+		  || (h->def_dynamic
+		      && h->ref_regular
+		      && !h->def_regular)));
+
+  /* If this is a function, put it in the procedure linkage table.  We
+     will fill in the contents of the procedure linkage table later,
+     when we know the address of the .got section.  */
+  if (h->type == STT_FUNC || h->needs_plt)
+    {
+      if (h->plt.refcount <= 0
+	  || SYMBOL_CALLS_LOCAL (info, h)
+	  || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
+	      && h->root.type == bfd_link_hash_undefweak))
+	{
+	  /* This case can occur if we saw a PLT reloc in an input
+	     file, but the symbol was never referred to by a dynamic
+	     object, or if all references were garbage collected.  In
+	     such a case, we don't actually need to build a procedure
+	     linkage table, and we can just do a PCREL reloc instead.  */
+	  h->plt.offset = (bfd_vma) -1;
+	  h->needs_plt = 0;
+	}
+
+      return TRUE;
+    }
+
+  /* Reinitialize the plt offset now that it is not used as a reference
+     count any more.  */
+  h->plt.offset = (bfd_vma) -1;
+
+  /* If this is a weak symbol, and there is a real definition, the
+     processor independent code will have arranged for us to see the
+     real definition first, and we can just use the same value.  */
+  if (h->u.weakdef != NULL)
+    {
+      BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
+		  || h->u.weakdef->root.type == bfd_link_hash_defweak);
+      h->root.u.def.section = h->u.weakdef->root.u.def.section;
+      h->root.u.def.value = h->u.weakdef->root.u.def.value;
+      return TRUE;
+    }
+
+  /* If there are no non-GOT references, we do not need a copy
+     relocation.  */
+  if (!h->non_got_ref)
+    return TRUE;
+
+  /* This is a reference to a symbol defined by a dynamic object which
+     is not a function.
+     If we are creating a shared library, we must presume that the
+     only references to the symbol are via the global offset table.
+     For such cases we need not do anything here; the relocations will
+     be handled correctly by relocate_section.  */
+  if (info->shared)
+    return TRUE;
+
+  if (h->size == 0)
+    {
+      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
+			     h->root.root.string);
+      return TRUE;
+    }
+
+  /* We must allocate the symbol in our .dynbss section, which will
+     become part of the .bss section of the executable.  There will be
+     an entry for this symbol in the .dynsym section.  The dynamic
+     object will contain position independent code, so all references
+     from the dynamic object to this symbol will go through the global
+     offset table.  The dynamic linker will use the .dynsym entry to
+     determine the address it must put in the global offset table, so
+     both the dynamic object and the regular object will refer to the
+     same memory location for the variable.  */
+  s = htab->sdynbss;
+  BFD_ASSERT (s != NULL);
+
+  /* We must generate a R_NIOS2_COPY reloc to tell the dynamic linker to
+     copy the initial value out of the dynamic object and into the
+     runtime process image.  We need to remember the offset into the
+     .rela.bss section we are going to use.  */
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+    {
+      asection *srel;
+
+      srel = htab->srelbss;
+      BFD_ASSERT (srel != NULL);
+      srel->size += sizeof (Elf32_External_Rela);
+      h->needs_copy = 1;
+    }
+
+  align2 = bfd_log2 (h->size);
+  if (align2 > h->root.u.def.section->alignment_power)
+    align2 = h->root.u.def.section->alignment_power;
+
+  /* Align dynbss.  */
+  s->size = BFD_ALIGN (s->size, (bfd_size_type)1 << align2);
+  if (align2 > bfd_get_section_alignment (dynobj, s)
+      && !bfd_set_section_alignment (dynobj, s, align2))
+    return FALSE;
+
+  /* Define the symbol as being at this point in the section.  */
+  h->root.u.def.section = s;
+  h->root.u.def.value = s->size;
+
+  /* Increment the section size to make room for the symbol.  */
+  s->size += h->size;
+
+  return TRUE;
+}
+
+/* Worker function for nios2_elf32_size_dynamic_sections.  */
+static bfd_boolean
+adjust_dynrelocs (struct elf_link_hash_entry *h, PTR inf)
+{
+  struct bfd_link_info *info;
+  struct elf32_nios2_link_hash_table *htab;
+
+  if (h->root.type == bfd_link_hash_indirect)
+    return TRUE;
+
+  if (h->root.type == bfd_link_hash_warning)
+    /* When warning symbols are created, they **replace** the "real"
+       entry in the hash table, thus we never get to see the real
+       symbol in a hash traversal.  So look at it now.  */
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+  info = (struct bfd_link_info *) inf;
+  htab = elf32_nios2_hash_table (info);
+
+  if (h->plt.offset != (bfd_vma)-1)
+    h->plt.offset += htab->res_n_size;
+  if (htab->root.splt == h->root.u.def.section)
+    h->root.u.def.value += htab->res_n_size;
+
+  return TRUE;
+}
+
+/* Another worker function for nios2_elf32_size_dynamic_sections.
+   Allocate space in .plt, .got and associated reloc sections for
+   dynamic relocs.  */
+static bfd_boolean
+allocate_dynrelocs (struct elf_link_hash_entry *h, PTR inf)
+{
+  struct bfd_link_info *info;
+  struct elf32_nios2_link_hash_table *htab;
+  struct elf32_nios2_link_hash_entry *eh;
+  struct elf32_nios2_dyn_relocs *p;
+  int use_plt;
+
+  if (h->root.type == bfd_link_hash_indirect)
+    return TRUE;
+
+  if (h->root.type == bfd_link_hash_warning)
+    /* When warning symbols are created, they **replace** the "real"
+       entry in the hash table, thus we never get to see the real
+       symbol in a hash traversal.  So look at it now.  */
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+  info = (struct bfd_link_info *) inf;
+  htab = elf32_nios2_hash_table (info);
+
+  if (htab->root.dynamic_sections_created
+      && h->plt.refcount > 0)
+    {
+      /* Make sure this symbol is output as a dynamic symbol.
+	 Undefined weak syms won't yet be marked as dynamic.  */
+      if (h->dynindx == -1
+	  && !h->forced_local
+	  && !bfd_elf_link_record_dynamic_symbol (info, h))
+	return FALSE;
+
+      if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info->shared, h))
+	{
+	  asection *s = htab->root.splt;
+
+	  /* Allocate room for the header.  */
+	  if (s->size == 0)
+	    {
+	      if (info->shared)
+		s->size = 24;
+	      else
+		s->size = 28;
+	    }
+
+	  h->plt.offset = s->size;
+
+	  /* If this symbol is not defined in a regular file, and we are
+	     not generating a shared library, then set the symbol to this
+	     location in the .plt.  This is required to make function
+	     pointers compare as equal between the normal executable and
+	     the shared library.  */
+	  if (! info->shared
+	      && !h->def_regular)
+	    {
+	      h->root.u.def.section = s;
+	      h->root.u.def.value = h->plt.offset;
+	    }
+
+	  /* Make room for this entry.  */
+	  s->size += 12;
+
+	  /* We also need to make an entry in the .rela.plt section.  */
+	  htab->root.srelplt->size += sizeof (Elf32_External_Rela);
+
+	  /* And the .got.plt section.  */
+	  htab->root.sgotplt->size += 4;
+	}
+      else
+	{
+	  h->plt.offset = (bfd_vma) -1;
+	  h->needs_plt = 0;
+	}
+    }
+  else
+    {
+      h->plt.offset = (bfd_vma) -1;
+      h->needs_plt = 0;
+    }
+
+  eh = (struct elf32_nios2_link_hash_entry *) h;
+  use_plt = (eh->got_types_used == CALL16_USED
+	     && h->plt.offset != (bfd_vma) -1);
+
+  if (h->got.refcount > 0)
+    {
+      asection *s;
+      bfd_boolean dyn;
+      int tls_type = eh->tls_type;
+      int indx;
+
+      /* Make sure this symbol is output as a dynamic symbol.
+	 Undefined weak syms won't yet be marked as dynamic.  */
+      if (h->dynindx == -1
+	  && !h->forced_local
+	  && !bfd_elf_link_record_dynamic_symbol (info, h))
+	return FALSE;
+
+      s = htab->root.sgot;
+      h->got.offset = s->size;
+
+      if (tls_type == GOT_UNKNOWN)
+	abort ();
+
+      if (tls_type == GOT_NORMAL)
+	/* Non-TLS symbols need one GOT slot.  */
+	s->size += 4;
+      else
+	{
+	  if (tls_type & GOT_TLS_GD)
+	    /* R_NIOS2_TLS_GD16 needs 2 consecutive GOT slots.  */
+	    s->size += 8;
+	  if (tls_type & GOT_TLS_IE)
+	    /* R_NIOS2_TLS_IE16 needs one GOT slot.  */
+	    s->size += 4;
+	}
+
+      dyn = htab->root.dynamic_sections_created;
+
+      indx = 0;
+      if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
+	  && (!info->shared
+	      || !SYMBOL_REFERENCES_LOCAL (info, h)))
+	indx = h->dynindx;
+
+      if (tls_type != GOT_NORMAL
+	  && (info->shared || indx != 0)
+	  && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+	      || h->root.type != bfd_link_hash_undefweak))
+	{
+	  if (tls_type & GOT_TLS_IE)
+	    htab->root.srelgot->size += sizeof (Elf32_External_Rela);
+
+	  if (tls_type & GOT_TLS_GD)
+	    htab->root.srelgot->size += sizeof (Elf32_External_Rela);
+
+	  if ((tls_type & GOT_TLS_GD) && indx != 0)
+	    htab->root.srelgot->size += sizeof (Elf32_External_Rela);
+	}
+      else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+		|| h->root.type != bfd_link_hash_undefweak)
+	       && !use_plt
+	       && (info->shared
+		   || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
+	htab->root.srelgot->size += sizeof (Elf32_External_Rela);
+    }
+  else
+    h->got.offset = (bfd_vma) -1;
+
+  if (eh->dyn_relocs == NULL)
+    return TRUE;
+
+  /* In the shared -Bsymbolic case, discard space allocated for
+     dynamic pc-relative relocs against symbols which turn out to be
+     defined in regular objects.  For the normal shared case, discard
+     space for pc-relative relocs that have become local due to symbol
+     visibility changes.  */
+
+  if (info->shared)
+    {
+      if (h->def_regular
+	  && (h->forced_local || info->symbolic))
+	{
+	  struct elf32_nios2_dyn_relocs **pp;
+
+	  for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
+	    {
+	      p->count -= p->pc_count;
+	      p->pc_count = 0;
+	      if (p->count == 0)
+		*pp = p->next;
+	      else
+		pp = &p->next;
+	    }
+	}
+
+      /* Also discard relocs on undefined weak syms with non-default
+	 visibility.  */
+      if (eh->dyn_relocs != NULL
+	  && h->root.type == bfd_link_hash_undefweak)
+	{
+	  if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
+	    eh->dyn_relocs = NULL;
+
+	  /* Make sure undefined weak symbols are output as a dynamic
+	     symbol in PIEs.  */
+	  else if (h->dynindx == -1
+		   && !h->forced_local
+		   && !bfd_elf_link_record_dynamic_symbol (info, h))
+	    return FALSE;
+	}
+    }
+  else
+    {
+      /* For the non-shared case, discard space for relocs against
+	 symbols which turn out to need copy relocs or are not
+	 dynamic.  */
+
+      if (!h->non_got_ref
+	  && ((h->def_dynamic && !h->def_regular)
+	      || (htab->root.dynamic_sections_created
+		  && (h->root.type == bfd_link_hash_undefweak
+		      || h->root.type == bfd_link_hash_undefined))))
+	{
+	  /* Make sure this symbol is output as a dynamic symbol.
+	     Undefined weak syms won't yet be marked as dynamic.  */
+	  if (h->dynindx == -1
+	      && !h->forced_local
+	      && !bfd_elf_link_record_dynamic_symbol (info, h))
+	    return FALSE;
+
+	  /* If that succeeded, we know we'll be keeping all the
+	     relocs.  */
+	  if (h->dynindx != -1)
+	    goto keep;
+	}
+
+      eh->dyn_relocs = NULL;
+
+    keep: ;
+    }
+
+  /* Finally, allocate space.  */
+  for (p = eh->dyn_relocs; p != NULL; p = p->next)
+    {
+      asection *sreloc = elf_section_data (p->sec)->sreloc;
+      sreloc->size += p->count * sizeof (Elf32_External_Rela);
+    }
+
+  return TRUE;
+}
+
+/* Implement elf_backend_size_dynamic_sections:
+   Set the sizes of the dynamic sections.  */
+static bfd_boolean
+nios2_elf32_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
+				   struct bfd_link_info *info)
+{
+  bfd *dynobj;
+  asection *s;
+  bfd_boolean plt;
+  bfd_boolean got;
+  bfd_boolean relocs;
+  bfd *ibfd;
+  struct elf32_nios2_link_hash_table *htab;
+
+  htab = elf32_nios2_hash_table (info);
+  dynobj = elf_hash_table (info)->dynobj;
+  BFD_ASSERT (dynobj != NULL);
+
+  htab->res_n_size = 0;
+  if (elf_hash_table (info)->dynamic_sections_created)
+    {
+      /* Set the contents of the .interp section to the interpreter.  */
+      if (info->executable)
+	{
+	  s = bfd_get_linker_section (dynobj, ".interp");
+	  BFD_ASSERT (s != NULL);
+	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
+	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
+	}
+    }
+  else
+    {
+      /* We may have created entries in the .rela.got section.
+	 However, if we are not creating the dynamic sections, we will
+	 not actually use these entries.  Reset the size of .rela.got,
+	 which will cause it to get stripped from the output file
+	 below.  */
+      s = htab->root.srelgot;
+      if (s != NULL)
+	s->size = 0;
+    }
+
+  /* Set up .got offsets for local syms, and space for local dynamic
+     relocs.  */
+  for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+    {
+      bfd_signed_vma *local_got;
+      bfd_signed_vma *end_local_got;
+      char *local_tls_type;
+      bfd_size_type locsymcount;
+      Elf_Internal_Shdr *symtab_hdr;
+      asection *srel;
+
+      if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
+	continue;
+
+      for (s = ibfd->sections; s != NULL; s = s->next)
+	{
+	  struct elf32_nios2_dyn_relocs *p;
+
+	  for (p = elf_section_data (s)->local_dynrel; p != NULL; p = p->next)
+	    {
+	      if (!bfd_is_abs_section (p->sec)
+		  && bfd_is_abs_section (p->sec->output_section))
+		{
+		  /* Input section has been discarded, either because
+		     it is a copy of a linkonce section or due to
+		     linker script /DISCARD/, so we'll be discarding
+		     the relocs too.  */
+		}
+	      else if (p->count != 0)
+		{
+		  srel = elf_section_data (p->sec)->sreloc;
+		  srel->size += p->count * sizeof (Elf32_External_Rela);
+		  if ((p->sec->output_section->flags & SEC_READONLY) != 0)
+		    info->flags |= DF_TEXTREL;
+		}
+	    }
+	}
+
+      local_got = elf_local_got_refcounts (ibfd);
+      if (!local_got)
+	continue;
+
+      symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+      locsymcount = symtab_hdr->sh_info;
+      end_local_got = local_got + locsymcount;
+      local_tls_type = elf32_nios2_local_got_tls_type (ibfd);
+      s = htab->root.sgot;
+      srel = htab->root.srelgot;
+      for (; local_got < end_local_got; ++local_got, ++local_tls_type)
+	{
+	  if (*local_got > 0)
+	    {
+	      *local_got = s->size;
+	      if (*local_tls_type & GOT_TLS_GD)
+		/* TLS_GD relocs need an 8-byte structure in the GOT.  */
+		s->size += 8;
+	      if (*local_tls_type & GOT_TLS_IE)
+		s->size += 4;
+	      if (*local_tls_type == GOT_NORMAL)
+		s->size += 4;
+
+	      if (info->shared || *local_tls_type == GOT_TLS_GD)
+		srel->size += sizeof (Elf32_External_Rela);
+	    }
+	  else
+	    *local_got = (bfd_vma) -1;
+	}
+    }
+
+  if (htab->tls_ldm_got.refcount > 0)
+    {
+      /* Allocate two GOT entries and one dynamic relocation (if necessary)
+	 for R_NIOS2_TLS_LDM16 relocations.  */
+      htab->tls_ldm_got.offset = htab->root.sgot->size;
+      htab->root.sgot->size += 8;
+      if (info->shared)
+	htab->root.srelgot->size += sizeof (Elf32_External_Rela);
+    }
+  else
+    htab->tls_ldm_got.offset = -1;
+
+  /* Allocate global sym .plt and .got entries, and space for global
+     sym dynamic relocs.  */
+  elf_link_hash_traverse (& htab->root, allocate_dynrelocs, info);
+
+  /* The check_relocs and adjust_dynamic_symbol entry points have
+     determined the sizes of the various dynamic sections.  Allocate
+     memory for them.  */
+  plt = FALSE;
+  got = FALSE;
+  relocs = FALSE;
+  for (s = dynobj->sections; s != NULL; s = s->next)
+    {
+      const char *name;
+
+      if ((s->flags & SEC_LINKER_CREATED) == 0)
+	continue;
+
+      /* It's OK to base decisions on the section name, because none
+	 of the dynobj section names depend upon the input files.  */
+      name = bfd_get_section_name (dynobj, s);
+
+      if (strcmp (name, ".plt") == 0)
+	{
+	  /* Remember whether there is a PLT.  */
+	  plt = s->size != 0;
+
+	  /* Correct for the number of res_N branches.  */
+	  if (plt && !info->shared)
+	    {
+	      htab->res_n_size = (s->size-28) / 3;
+	      s->size += htab->res_n_size;
+	    }
+	}
+      else if (CONST_STRNEQ (name, ".rela"))
+	{
+	  if (s->size != 0)
+	    {
+	      relocs = TRUE;
+
+	      /* We use the reloc_count field as a counter if we need
+		 to copy relocs into the output file.  */
+	      s->reloc_count = 0;
+	    }
+	}
+      else if (CONST_STRNEQ (name, ".got"))
+	got = s->size != 0;
+      else if (strcmp (name, ".dynbss") != 0)
+	/* It's not one of our sections, so don't allocate space.  */
+	continue;
+
+      if (s->size == 0)
+	{
+	  /* If we don't need this section, strip it from the
+	     output file.  This is mostly to handle .rela.bss and
+	     .rela.plt.  We must create both sections in
+	     create_dynamic_sections, because they must be created
+	     before the linker maps input sections to output
+	     sections.  The linker does that before
+	     adjust_dynamic_symbol is called, and it is that
+	     function which decides whether anything needs to go
+	     into these sections.  */
+	  s->flags |= SEC_EXCLUDE;
+	  continue;
+	}
+
+      if ((s->flags & SEC_HAS_CONTENTS) == 0)
+	continue;
+
+      /* Allocate memory for the section contents.  */
+      /* FIXME: This should be a call to bfd_alloc not bfd_zalloc.
+	 Unused entries should be reclaimed before the section's contents
+	 are written out, but at the moment this does not happen.  Thus in
+	 order to prevent writing out garbage, we initialize the section's
+	 contents to zero.  */
+      s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
+      if (s->contents == NULL)
+	return FALSE;
+    }
+
+  /* Adjust dynamic symbols that point to the plt to account for the
+     now-known number of resN slots.  */
+  if (htab->res_n_size)
+    elf_link_hash_traverse (& htab->root, adjust_dynrelocs, info);
+
+  if (elf_hash_table (info)->dynamic_sections_created)
+    {
+      /* Add some entries to the .dynamic section.  We fill in the
+	 values later, in elf_nios2_finish_dynamic_sections, but we
+	 must add the entries now so that we get the correct size for
+	 the .dynamic section.  The DT_DEBUG entry is filled in by the
+	 dynamic linker and used by the debugger.  */
+#define add_dynamic_entry(TAG, VAL) \
+  _bfd_elf_add_dynamic_entry (info, TAG, VAL)
+
+      if (!info->shared && !add_dynamic_entry (DT_DEBUG, 0))
+	return FALSE;
+
+      if (got && !add_dynamic_entry (DT_PLTGOT, 0))
+	return FALSE;
+
+      if (plt
+	  && (!add_dynamic_entry (DT_PLTRELSZ, 0)
+	      || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+	      || !add_dynamic_entry (DT_JMPREL, 0)))
+	return FALSE;
+
+      if (relocs
+	  && (!add_dynamic_entry (DT_RELA, 0)
+	      || !add_dynamic_entry (DT_RELASZ, 0)
+	      || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela))))
+	return FALSE;
+
+      if (!info->shared && !add_dynamic_entry (DT_NIOS2_GP, 0))
+	return FALSE;
+
+      if ((info->flags & DF_TEXTREL) != 0
+	  && !add_dynamic_entry (DT_TEXTREL, 0))
+	return FALSE;
+    }
+#undef add_dynamic_entry
+
+  return TRUE;
+}
+
+/* Implement bfd_elf32_bfd_link_hash_table_create.  */
+static struct bfd_link_hash_table *
+nios2_elf32_link_hash_table_create (bfd *abfd)
+{
+  struct elf32_nios2_link_hash_table *ret;
+  bfd_size_type amt = sizeof (struct elf32_nios2_link_hash_table);
+
+  ret = bfd_zmalloc (amt);
+  if (ret == NULL)
+    return NULL;
+
+  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
+				      link_hash_newfunc,
+				      sizeof (struct
+					      elf32_nios2_link_hash_entry),
+				      NIOS2_ELF_DATA))
+    {
+      free (ret);
+      return NULL;
+    }
+
+  return &ret->root.root;
+}
+
+/* Implement elf_backend_reloc_type_class.  */
+static enum elf_reloc_type_class
+nios2_elf32_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			      const asection *rel_sec ATTRIBUTE_UNUSED,
+			      const Elf_Internal_Rela *rela)
+{
+  switch ((int) ELF32_R_TYPE (rela->r_info))
+    {
+    case R_NIOS2_RELATIVE:
+      return reloc_class_relative;
+    case R_NIOS2_JUMP_SLOT:
+      return reloc_class_plt;
+    case R_NIOS2_COPY:
+      return reloc_class_copy;
+    default:
+      return reloc_class_normal;
+    }
+}
+
+/* Return 1 if target is one of ours.  */
+static bfd_boolean
+is_nios2_elf_target (const struct bfd_target *targ)
+{
+  return (targ == &bfd_elf32_littlenios2_vec
+	  || targ == &bfd_elf32_bignios2_vec);
+}
+
+/* Implement elf_backend_add_symbol_hook.
+   This hook is called by the linker when adding symbols from an object
+   file.  We use it to put .comm items in .sbss, and not .bss.  */
+static bfd_boolean
+nios2_elf_add_symbol_hook (bfd *abfd,
+			   struct bfd_link_info *info,
+			   Elf_Internal_Sym *sym,
+			   const char **namep ATTRIBUTE_UNUSED,
+			   flagword *flagsp ATTRIBUTE_UNUSED,
+			   asection **secp,
+			   bfd_vma *valp)
+{
+  bfd *dynobj;
+
+  if (sym->st_shndx == SHN_COMMON
+      && !info->relocatable
+      && sym->st_size <= elf_gp_size (abfd)
+      && is_nios2_elf_target (info->output_bfd->xvec))
+    {
+      /* Common symbols less than or equal to -G nn bytes are automatically
+	 put into .sbss.  */
+      struct elf32_nios2_link_hash_table *htab;
+
+      htab = elf32_nios2_hash_table (info);
+      if (htab->sbss == NULL)
+	{
+	  flagword flags = SEC_IS_COMMON | SEC_LINKER_CREATED;
+
+	  dynobj = elf_hash_table (info)->dynobj;
+	  if (!dynobj)
+	    dynobj = abfd;
+
+	  htab->sbss = bfd_make_section_anyway_with_flags (dynobj, ".sbss",
+							   flags);
+	  if (htab->sbss == NULL)
+	    return FALSE;
+	}
+
+      *secp = htab->sbss;
+      *valp = sym->st_size;
+    }
+
+  return TRUE;
+}
+
+/* Implement elf_backend_can_make_relative_eh_frame:
+   Decide whether to attempt to turn absptr or lsda encodings in
+   shared libraries into pcrel within the given input section.  */
+static bfd_boolean
+nios2_elf32_can_make_relative_eh_frame (bfd *input_bfd ATTRIBUTE_UNUSED,
+					struct bfd_link_info *info
+					ATTRIBUTE_UNUSED,
+					asection *eh_frame_section
+					ATTRIBUTE_UNUSED)
+{
+  /* We can't use PC-relative encodings in the .eh_frame section.  */
+  return FALSE;
+}
+
+/* Implement elf_backend_special_sections.  */
+const struct bfd_elf_special_section elf32_nios2_special_sections[] =
+{
+  { STRING_COMMA_LEN (".sbss"),	 -2, SHT_NOBITS,
+    SHF_ALLOC + SHF_WRITE + SHF_NIOS2_GPREL },
+  { STRING_COMMA_LEN (".sdata"), -2, SHT_PROGBITS,
+    SHF_ALLOC + SHF_WRITE + SHF_NIOS2_GPREL },
+  { NULL,		      0,  0, 0,		     0 }
+};
+
+#define ELF_ARCH			bfd_arch_nios2
+#define ELF_TARGET_ID			NIOS2_ELF_DATA
+#define ELF_MACHINE_CODE		EM_ALTERA_NIOS2
+
+/* The Nios II MMU uses a 4K page size.  */
+
+#define ELF_MAXPAGESIZE			0x1000
+
+#define bfd_elf32_bfd_link_hash_table_create \
+					  nios2_elf32_link_hash_table_create
+
+/* Relocation table lookup macros.  */
+
+#define bfd_elf32_bfd_reloc_type_lookup	  nios2_elf32_bfd_reloc_type_lookup
+#define bfd_elf32_bfd_reloc_name_lookup	  nios2_elf32_bfd_reloc_name_lookup
+
+/* JUMP_TABLE_LINK macros.  */
+
+/* elf_info_to_howto (using RELA relocations).  */
+
+#define elf_info_to_howto		  nios2_elf32_info_to_howto
+
+/* elf backend functions.  */
+
+#define elf_backend_can_gc_sections	1
+#define elf_backend_can_refcount	1
+#define elf_backend_plt_readonly	1
+#define elf_backend_want_got_plt	1
+#define elf_backend_rela_normal		1
+
+#define elf_backend_relocate_section	  nios2_elf32_relocate_section
+#define elf_backend_section_flags	  nios2_elf32_section_flags
+#define elf_backend_fake_sections	  nios2_elf32_fake_sections
+#define elf_backend_check_relocs	  nios2_elf32_check_relocs
+
+#define elf_backend_gc_mark_hook	  nios2_elf32_gc_mark_hook
+#define elf_backend_gc_sweep_hook	  nios2_elf32_gc_sweep_hook
+#define elf_backend_create_dynamic_sections \
+					  nios2_elf32_create_dynamic_sections
+#define elf_backend_finish_dynamic_symbol nios2_elf32_finish_dynamic_symbol
+#define elf_backend_finish_dynamic_sections \
+					  nios2_elf32_finish_dynamic_sections
+#define elf_backend_adjust_dynamic_symbol nios2_elf32_adjust_dynamic_symbol
+#define elf_backend_reloc_type_class	  nios2_elf32_reloc_type_class
+#define elf_backend_size_dynamic_sections nios2_elf32_size_dynamic_sections
+#define elf_backend_add_symbol_hook	  nios2_elf_add_symbol_hook
+#define elf_backend_copy_indirect_symbol  nios2_elf32_copy_indirect_symbol
+
+#define elf_backend_grok_prstatus	  nios2_grok_prstatus
+#define elf_backend_grok_psinfo		  nios2_grok_psinfo
+
+#undef elf_backend_can_make_relative_eh_frame
+#define elf_backend_can_make_relative_eh_frame \
+					  nios2_elf32_can_make_relative_eh_frame
+
+#define elf_backend_special_sections	  elf32_nios2_special_sections
+
+#define TARGET_LITTLE_SYM		bfd_elf32_littlenios2_vec
+#define TARGET_LITTLE_NAME		"elf32-littlenios2"
+#define TARGET_BIG_SYM			bfd_elf32_bignios2_vec
+#define TARGET_BIG_NAME			"elf32-bignios2"
+
+#define elf_backend_got_header_size	12
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-openrisc.c b/bfd/elf32-openrisc.c
index ada738e..7abc938 100644
--- a/bfd/elf32-openrisc.c
+++ b/bfd/elf32-openrisc.c
@@ -1,5 +1,5 @@
 /* OpenRISC-specific support for 32-bit ELF.
-   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007
+   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2012
    Free Software Foundation, Inc.
    Contributed by Johan Rydberg, [email protected]
 
@@ -373,9 +373,9 @@
 				   unresolved_reloc, warned);
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -486,6 +486,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       switch (ELF32_R_TYPE (rel->r_info))
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 0c25c3e..63928dc 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -1,6 +1,6 @@
 /* PowerPC-specific support for 32-bit ELF
    Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support.
 
@@ -37,6 +37,14 @@
 #include "elf32-ppc.h"
 #include "elf-vxworks.h"
 #include "dwarf2.h"
+#include "elf-linux-psinfo.h"
+
+typedef enum split16_format_type
+{
+  split16a_type = 0,
+  split16d_type
+}
+split16_format_type;
 
 /* RELA relocations are used here.  */
 
@@ -44,6 +52,8 @@
   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 static bfd_reloc_status_type ppc_elf_unhandled_reloc
   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+static void ppc_elf_vle_split16
+  (bfd *, bfd_byte *, bfd_vma, bfd_vma, split16_format_type);
 
 /* Branch prediction bit for branch taken relocs.  */
 #define BRANCH_PREDICT_BIT 0x200000
@@ -1392,6 +1402,262 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
+  /* A relative 8 bit branch.  */
+  HOWTO (R_PPC_VLE_REL8,	/* type */
+	 1,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 8,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_PPC_VLE_REL8",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xff,			/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  /* A relative 15 bit branch.  */
+  HOWTO (R_PPC_VLE_REL15,	/* type */
+	 1,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 15,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 1,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_PPC_VLE_REL15",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xfe,			/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  /* A relative 24 bit branch.  */
+  HOWTO (R_PPC_VLE_REL24,	/* type */
+	 1,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 24,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 1,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_PPC_VLE_REL24",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x1fffffe,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  /* The 16 LSBS in split16a format.  */
+  HOWTO (R_PPC_VLE_LO16A,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc,	 /* special_function */
+	 "R_PPC_VLE_LO16A",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x1f007ff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* The 16 LSBS in split16d format.  */
+  HOWTO (R_PPC_VLE_LO16D,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc,	 /* special_function */
+	 "R_PPC_VLE_LO16D",		/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x1f07ff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Bits 16-31 split16a format.  */
+  HOWTO (R_PPC_VLE_HI16A,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc,	 /* special_function */
+	 "R_PPC_VLE_HI16A",		/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x1f007ff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Bits 16-31 split16d format.  */
+  HOWTO (R_PPC_VLE_HI16D,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc,	 /* special_function */
+	 "R_PPC_VLE_HI16D",		/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x1f07ff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Bits 16-31 (High Adjusted) in split16a format.  */
+  HOWTO (R_PPC_VLE_HA16A,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc,	 /* special_function */
+	 "R_PPC_VLE_HA16A",		/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x1f007ff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Bits 16-31 (High Adjusted) in split16d format.  */
+  HOWTO (R_PPC_VLE_HA16D,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc,	 /* special_function */
+	 "R_PPC_VLE_HA16D",		/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x1f07ff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* This reloc does nothing.  */
+  HOWTO (R_PPC_VLE_SDA21,		/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_PPC_VLE_SDA21",		/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* This reloc does nothing.  */
+  HOWTO (R_PPC_VLE_SDA21_LO,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_PPC_VLE_SDA21_LO",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* The 16 LSBS relative to _SDA_BASE_ in split16a format.  */
+  HOWTO (R_PPC_VLE_SDAREL_LO16A,/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	 /* special_function */
+	 "R_PPC_VLE_SDAREL_LO16A",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x1f007ff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* The 16 LSBS relative to _SDA_BASE_ in split16d format.  */
+  /* This reloc does nothing.  */
+  HOWTO (R_PPC_VLE_SDAREL_LO16D, /* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	 /* special_function */
+	 "R_PPC_VLE_SDAREL_LO16D",		/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x1f07ff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Bits 16-31 relative to _SDA_BASE_ in split16a format.  */
+  HOWTO (R_PPC_VLE_SDAREL_HI16A,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	 /* special_function */
+	 "R_PPC_VLE_SDAREL_HI16A",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x1f007ff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Bits 16-31 relative to _SDA_BASE_ in split16d format.  */
+  HOWTO (R_PPC_VLE_SDAREL_HI16D,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	 /* special_function */
+	 "R_PPC_VLE_SDAREL_HI16D",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x1f07ff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Bits 16-31 (HA) relative to _SDA_BASE split16a format.  */
+  HOWTO (R_PPC_VLE_SDAREL_HA16A,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	 /* special_function */
+	 "R_PPC_VLE_SDAREL_HA16A",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x1f007ff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Bits 16-31 (HA) relative to _SDA_BASE split16d format.  */
+  HOWTO (R_PPC_VLE_SDAREL_HA16D,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	 /* special_function */
+	 "R_PPC_VLE_SDAREL_HA16D",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x1f07ff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
   HOWTO (R_PPC_IRELATIVE,	/* type */
 	 0,			/* rightshift */
 	 2,			/* size (0 = byte, 1 = short, 2 = long) */
@@ -1512,6 +1778,58 @@
 	 0xffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 };
+
+/* External 32-bit PPC structure for PRPSINFO.  This structure is
+   ABI-defined, thus we choose to use char arrays here in order to
+   avoid dealing with different types in different architectures.
+
+   The PPC 32-bit structure uses int for `pr_uid' and `pr_gid' while
+   most non-PPC architectures use `short int'.
+
+   This structure will ultimately be written in the corefile's note
+   section, as the PRPSINFO.  */
+
+struct elf_external_ppc_linux_prpsinfo32
+  {
+    char pr_state;			/* Numeric process state.  */
+    char pr_sname;			/* Char for pr_state.  */
+    char pr_zomb;			/* Zombie.  */
+    char pr_nice;			/* Nice val.  */
+    char pr_flag[4];			/* Flags.  */
+    char pr_uid[4];
+    char pr_gid[4];
+    char pr_pid[4];
+    char pr_ppid[4];
+    char pr_pgrp[4];
+    char pr_sid[4];
+    char pr_fname[16];			/* Filename of executable.  */
+    char pr_psargs[80];			/* Initial part of arg list.  */
+  };
+
+/* Helper macro to swap (properly handling endianess) things from the
+   `elf_internal_prpsinfo' structure to the `elf_external_ppc_prpsinfo32'
+   structure.
+
+   Note that FROM should be a pointer, and TO should be the explicit type.  */
+
+#define PPC_LINUX_PRPSINFO32_SWAP_FIELDS(abfd, from, to)	      \
+  do								      \
+    {								      \
+      H_PUT_8 (abfd, from->pr_state, &to.pr_state);		      \
+      H_PUT_8 (abfd, from->pr_sname, &to.pr_sname);		      \
+      H_PUT_8 (abfd, from->pr_zomb, &to.pr_zomb);		      \
+      H_PUT_8 (abfd, from->pr_nice, &to.pr_nice);		      \
+      H_PUT_32 (abfd, from->pr_flag, to.pr_flag);		      \
+      H_PUT_32 (abfd, from->pr_uid, to.pr_uid);			      \
+      H_PUT_32 (abfd, from->pr_gid, to.pr_gid);			      \
+      H_PUT_32 (abfd, from->pr_pid, to.pr_pid);			      \
+      H_PUT_32 (abfd, from->pr_ppid, to.pr_ppid);		      \
+      H_PUT_32 (abfd, from->pr_pgrp, to.pr_pgrp);		      \
+      H_PUT_32 (abfd, from->pr_sid, to.pr_sid);			      \
+      strncpy (to.pr_fname, from->pr_fname, sizeof (to.pr_fname));    \
+      strncpy (to.pr_psargs, from->pr_psargs, sizeof (to.pr_psargs)); \
+    } while (0)
+
 
 /* Initialize the ppc_elf_howto_table, so that linear accesses can be done.  */
 
@@ -1550,7 +1868,9 @@
     case BFD_RELOC_NONE:		r = R_PPC_NONE;			break;
     case BFD_RELOC_32:			r = R_PPC_ADDR32;		break;
     case BFD_RELOC_PPC_BA26:		r = R_PPC_ADDR24;		break;
+    case BFD_RELOC_PPC64_ADDR16_DS:
     case BFD_RELOC_16:			r = R_PPC_ADDR16;		break;
+    case BFD_RELOC_PPC64_ADDR16_LO_DS:
     case BFD_RELOC_LO16:		r = R_PPC_ADDR16_LO;		break;
     case BFD_RELOC_HI16:		r = R_PPC_ADDR16_HI;		break;
     case BFD_RELOC_HI16_S:		r = R_PPC_ADDR16_HA;		break;
@@ -1561,7 +1881,9 @@
     case BFD_RELOC_PPC_B16:		r = R_PPC_REL14;		break;
     case BFD_RELOC_PPC_B16_BRTAKEN:	r = R_PPC_REL14_BRTAKEN;	break;
     case BFD_RELOC_PPC_B16_BRNTAKEN:	r = R_PPC_REL14_BRNTAKEN;	break;
+    case BFD_RELOC_PPC64_GOT16_DS:
     case BFD_RELOC_16_GOTOFF:		r = R_PPC_GOT16;		break;
+    case BFD_RELOC_PPC64_GOT16_LO_DS:
     case BFD_RELOC_LO16_GOTOFF:		r = R_PPC_GOT16_LO;		break;
     case BFD_RELOC_HI16_GOTOFF:		r = R_PPC_GOT16_HI;		break;
     case BFD_RELOC_HI16_S_GOTOFF:	r = R_PPC_GOT16_HA;		break;
@@ -1572,26 +1894,34 @@
     case BFD_RELOC_32_PCREL:		r = R_PPC_REL32;		break;
     case BFD_RELOC_32_PLTOFF:		r = R_PPC_PLT32;		break;
     case BFD_RELOC_32_PLT_PCREL:	r = R_PPC_PLTREL32;		break;
+    case BFD_RELOC_PPC64_PLT16_LO_DS:
     case BFD_RELOC_LO16_PLTOFF:		r = R_PPC_PLT16_LO;		break;
     case BFD_RELOC_HI16_PLTOFF:		r = R_PPC_PLT16_HI;		break;
     case BFD_RELOC_HI16_S_PLTOFF:	r = R_PPC_PLT16_HA;		break;
     case BFD_RELOC_GPREL16:		r = R_PPC_SDAREL16;		break;
+    case BFD_RELOC_PPC64_SECTOFF_DS:
     case BFD_RELOC_16_BASEREL:		r = R_PPC_SECTOFF;		break;
+    case BFD_RELOC_PPC64_SECTOFF_LO_DS:
     case BFD_RELOC_LO16_BASEREL:	r = R_PPC_SECTOFF_LO;		break;
     case BFD_RELOC_HI16_BASEREL:	r = R_PPC_SECTOFF_HI;		break;
     case BFD_RELOC_HI16_S_BASEREL:	r = R_PPC_SECTOFF_HA;		break;
     case BFD_RELOC_CTOR:		r = R_PPC_ADDR32;		break;
+    case BFD_RELOC_PPC64_TOC16_DS:
     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_PPC64_TPREL16_DS:
     case BFD_RELOC_PPC_TPREL16:		r = R_PPC_TPREL16;		break;
+    case BFD_RELOC_PPC64_TPREL16_LO_DS:
     case BFD_RELOC_PPC_TPREL16_LO:	r = R_PPC_TPREL16_LO;		break;
     case BFD_RELOC_PPC_TPREL16_HI:	r = R_PPC_TPREL16_HI;		break;
     case BFD_RELOC_PPC_TPREL16_HA:	r = R_PPC_TPREL16_HA;		break;
     case BFD_RELOC_PPC_TPREL:		r = R_PPC_TPREL32;		break;
+    case BFD_RELOC_PPC64_DTPREL16_DS:
     case BFD_RELOC_PPC_DTPREL16:	r = R_PPC_DTPREL16;		break;
+    case BFD_RELOC_PPC64_DTPREL16_LO_DS:
     case BFD_RELOC_PPC_DTPREL16_LO:	r = R_PPC_DTPREL16_LO;		break;
     case BFD_RELOC_PPC_DTPREL16_HI:	r = R_PPC_DTPREL16_HI;		break;
     case BFD_RELOC_PPC_DTPREL16_HA:	r = R_PPC_DTPREL16_HA;		break;
@@ -1628,6 +1958,35 @@
     case BFD_RELOC_PPC_EMB_RELST_HA:	r = R_PPC_EMB_RELST_HA;		break;
     case BFD_RELOC_PPC_EMB_BIT_FLD:	r = R_PPC_EMB_BIT_FLD;		break;
     case BFD_RELOC_PPC_EMB_RELSDA:	r = R_PPC_EMB_RELSDA;		break;
+    case BFD_RELOC_PPC_VLE_REL8:	r = R_PPC_VLE_REL8;		break;
+    case BFD_RELOC_PPC_VLE_REL15:	r = R_PPC_VLE_REL15;		break;
+    case BFD_RELOC_PPC_VLE_REL24:	r = R_PPC_VLE_REL24;		break;
+    case BFD_RELOC_PPC_VLE_LO16A:	r = R_PPC_VLE_LO16A;		break;
+    case BFD_RELOC_PPC_VLE_LO16D:	r = R_PPC_VLE_LO16D;		break;
+    case BFD_RELOC_PPC_VLE_HI16A:	r = R_PPC_VLE_HI16A;		break;
+    case BFD_RELOC_PPC_VLE_HI16D:	r = R_PPC_VLE_HI16D;		break;
+    case BFD_RELOC_PPC_VLE_HA16A:	r = R_PPC_VLE_HA16A;		break;
+    case BFD_RELOC_PPC_VLE_HA16D:	r = R_PPC_VLE_HA16D;		break;
+    case BFD_RELOC_PPC_VLE_SDA21:	r = R_PPC_VLE_SDA21;		break;
+    case BFD_RELOC_PPC_VLE_SDA21_LO:	r = R_PPC_VLE_SDA21_LO;		break;
+    case BFD_RELOC_PPC_VLE_SDAREL_LO16A:
+      r = R_PPC_VLE_SDAREL_LO16A;
+      break;
+    case BFD_RELOC_PPC_VLE_SDAREL_LO16D:
+      r = R_PPC_VLE_SDAREL_LO16D;
+      break;
+    case BFD_RELOC_PPC_VLE_SDAREL_HI16A:
+      r = R_PPC_VLE_SDAREL_HI16A;
+      break;
+    case BFD_RELOC_PPC_VLE_SDAREL_HI16D:
+      r = R_PPC_VLE_SDAREL_HI16D;
+      break;
+    case BFD_RELOC_PPC_VLE_SDAREL_HA16A:
+      r = R_PPC_VLE_SDAREL_HA16A;
+      break;
+    case BFD_RELOC_PPC_VLE_SDAREL_HA16D:
+      r = R_PPC_VLE_SDAREL_HA16D;
+      break;
     case BFD_RELOC_16_PCREL:		r = R_PPC_REL16;		break;
     case BFD_RELOC_LO16_PCREL:		r = R_PPC_REL16_LO;		break;
     case BFD_RELOC_HI16_PCREL:		r = R_PPC_REL16_HI;		break;
@@ -1857,10 +2216,10 @@
 
     case 268:		/* Linux/PPC.  */
       /* pr_cursig */
-      elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+      elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
 
       /* pr_pid */
-      elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
+      elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
 
       /* pr_reg */
       offset = 72;
@@ -1883,11 +2242,11 @@
       return FALSE;
 
     case 128:		/* Linux/PPC elf_prpsinfo.  */
-      elf_tdata (abfd)->core_pid
+      elf_tdata (abfd)->core->pid
 	= bfd_get_32 (abfd, note->descdata + 16);
-      elf_tdata (abfd)->core_program
+      elf_tdata (abfd)->core->program
 	= _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
-      elf_tdata (abfd)->core_command
+      elf_tdata (abfd)->core->command
 	= _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
     }
 
@@ -1896,7 +2255,7 @@
      implementations, so strip it off if it exists.  */
 
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
@@ -1906,6 +2265,19 @@
   return TRUE;
 }
 
+char *
+elfcore_write_ppc_linux_prpsinfo32 (bfd *abfd, char *buf, int *bufsiz,
+				      const struct elf_internal_linux_prpsinfo *prpsinfo)
+{
+  struct elf_external_ppc_linux_prpsinfo32 data;
+
+  memset (&data, 0, sizeof (data));
+  PPC_LINUX_PRPSINFO32_SWAP_FIELDS (abfd, prpsinfo, data);
+
+  return elfcore_write_note (abfd, buf, bufsiz,
+			     "CORE", NT_PRPSINFO, &data, sizeof (data));
+}
+
 static char *
 ppc_elf_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type, ...)
 {
@@ -1920,7 +2292,7 @@
 	va_list ap;
 
 	va_start (ap, note_type);
-	memset (data, 0, 32);
+	memset (data, 0, sizeof (data));
 	strncpy (data + 32, va_arg (ap, const char *), 16);
 	strncpy (data + 48, va_arg (ap, const char *), 80);
 	va_end (ap);
@@ -1952,6 +2324,28 @@
     }
 }
 
+static flagword
+ppc_elf_lookup_section_flags (char *flag_name)
+{
+
+  if (!strcmp (flag_name, "SHF_PPC_VLE"))
+    return SHF_PPC_VLE;
+
+  return 0;
+}
+
+/* Add the VLE flag if required.  */
+
+bfd_boolean
+ppc_elf_section_processing (bfd *abfd, Elf_Internal_Shdr *shdr)
+{
+  if (bfd_get_mach (abfd) == bfd_mach_ppc_vle
+      && (shdr->sh_flags & SHF_EXECINSTR) != 0)
+    shdr->sh_flags |= SHF_PPC_VLE;
+
+  return TRUE;
+}
+
 /* Return address for Ith PLT stub in section PLT, for relocation REL
    or (bfd_vma) -1 if it should not be included.  */
 
@@ -2025,6 +2419,70 @@
   return ret;
 }
 
+/* Modify the segment map for VLE executables.  */
+
+bfd_boolean
+ppc_elf_modify_segment_map (bfd *abfd,
+			    struct bfd_link_info *info ATTRIBUTE_UNUSED)
+{
+  struct elf_segment_map *m, *n;
+  bfd_size_type amt;
+  unsigned int j, k;
+  bfd_boolean sect0_vle, sectj_vle;
+
+  /* At this point in the link, output sections have already been sorted by
+     LMA and assigned to segments.  All that is left to do is to ensure
+     there is no mixing of VLE & non-VLE sections in a text segment.
+     If we find that case, we split the segment.
+     We maintain the original output section order.  */
+
+  for (m = elf_seg_map (abfd); m != NULL; m = m->next)
+    {
+      if (m->count == 0)
+	continue;
+
+      sect0_vle = (elf_section_flags (m->sections[0]) & SHF_PPC_VLE) != 0;
+      for (j = 1; j < m->count; ++j)
+	{
+	  sectj_vle = (elf_section_flags (m->sections[j]) & SHF_PPC_VLE) != 0;
+
+	  if (sectj_vle != sect0_vle)
+	    break;
+        }
+      if (j >= m->count)
+	continue;
+
+      /* sections 0..j-1 stay in this (current) segment,
+	 the remainder are put in a new segment.
+	 The scan resumes with the new segment.  */
+
+      /* Fix the new segment.  */
+      amt = sizeof (struct elf_segment_map);
+      amt += (m->count - j - 1) * sizeof (asection *);
+      n = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
+      if (n == NULL)
+        return FALSE;
+
+      n->p_type = PT_LOAD;
+      n->p_flags = PF_X | PF_R;
+      if (sectj_vle)
+        n->p_flags |= PF_PPC_VLE;
+      n->count = m->count - j;
+      for (k = 0; k < n->count; ++k)
+        {
+          n->sections[k] = m->sections[j+k];
+          m->sections[j+k] = NULL;
+	}
+      n->next = m->next;
+      m->next = n;
+
+      /* Fix the current segment  */
+      m->count = j;
+    }
+
+  return TRUE;
+}
+
 /* Add extra PPC sections -- Note, for now, make .sbss2 and
    .PPC.EMB.sbss0 a normal section, and not a bss section so
    that the linker doesn't crater when trying to make more than
@@ -2625,6 +3083,21 @@
    shared lib.  */
 #define ELIMINATE_COPY_RELOCS 1
 
+/* Used to track dynamic relocations for local symbols.  */
+struct ppc_dyn_relocs
+{
+  struct ppc_dyn_relocs *next;
+
+  /* The input section of the reloc.  */
+  asection *sec;
+
+  /* Total number of relocs copied for the input section.  */
+  unsigned int count : 31;
+
+  /* Whether this entry is for STT_GNU_IFUNC symbols.  */
+  unsigned int ifunc : 1;
+};
+
 /* PPC ELF linker hash entry.  */
 
 struct ppc_elf_link_hash_entry
@@ -2732,7 +3205,7 @@
 };
 
 /* Rename some of the generic section flags to better document how they
-   are used here.  */
+   are used for ppc32.  The flags are only valid for ppc32 elf objects.  */
 
 /* Nonzero if this section has TLS related relocations.  */
 #define has_tls_reloc sec_flg0
@@ -2829,13 +3302,13 @@
     return FALSE;
 
   htab = ppc_elf_hash_table (info);
-  htab->got = s = bfd_get_section_by_name (abfd, ".got");
+  htab->got = s = bfd_get_linker_section (abfd, ".got");
   if (s == NULL)
     abort ();
 
   if (htab->is_vxworks)
     {
-      htab->sgotplt = bfd_get_section_by_name (abfd, ".got.plt");
+      htab->sgotplt = bfd_get_linker_section (abfd, ".got.plt");
       if (!htab->sgotplt)
 	abort ();
     }
@@ -2849,7 +3322,7 @@
 	return FALSE;
     }
 
-  htab->relgot = bfd_get_section_by_name (abfd, ".rela.got");
+  htab->relgot = bfd_get_linker_section (abfd, ".rela.got");
   if (!htab->relgot)
     abort ();
 
@@ -2923,7 +3396,7 @@
       && !ppc_elf_create_glink (abfd, info))
     return FALSE;
 
-  htab->dynbss = bfd_get_section_by_name (abfd, ".dynbss");
+  htab->dynbss = bfd_get_linker_section (abfd, ".dynbss");
   s = bfd_make_section_anyway_with_flags (abfd, ".dynsbss",
 					  SEC_ALLOC | SEC_LINKER_CREATED);
   htab->dynsbss = s;
@@ -2932,7 +3405,7 @@
 
   if (! info->shared)
     {
-      htab->relbss = bfd_get_section_by_name (abfd, ".rela.bss");
+      htab->relbss = bfd_get_linker_section (abfd, ".rela.bss");
       flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_HAS_CONTENTS
 	       | SEC_IN_MEMORY | SEC_LINKER_CREATED);
       s = bfd_make_section_anyway_with_flags (abfd, ".rela.sbss", flags);
@@ -2946,8 +3419,8 @@
       && !elf_vxworks_create_dynamic_sections (abfd, info, &htab->srelplt2))
     return FALSE;
 
-  htab->relplt = bfd_get_section_by_name (abfd, ".rela.plt");
-  htab->plt = s = bfd_get_section_by_name (abfd, ".plt");
+  htab->relplt = bfd_get_linker_section (abfd, ".rela.plt");
+  htab->plt = s = bfd_get_linker_section (abfd, ".plt");
   if (s == NULL)
     abort ();
 
@@ -2987,10 +3460,6 @@
   edir->elf.needs_plt |= eind->elf.needs_plt;
   edir->elf.pointer_equality_needed |= eind->elf.pointer_equality_needed;
 
-  /* If we were called to copy over info for a weak sym, that's all.  */
-  if (eind->elf.root.type != bfd_link_hash_indirect)
-    return;
-
   if (eind->dyn_relocs != NULL)
     {
       if (edir->dyn_relocs != NULL)
@@ -3022,6 +3491,16 @@
       eind->dyn_relocs = NULL;
     }
 
+  /* If we were called to copy over info for a weak sym, that's all.
+     You might think dyn_relocs need not be copied over;  After all,
+     both syms will be dynamic or both non-dynamic so we're just
+     moving reloc accounting around.  However, ELIMINATE_COPY_RELOCS
+     code in ppc_elf_adjust_dynamic_symbol needs to check for
+     dyn_relocs in read-only sections, and it does so on what is the
+     DIR sym here.  */
+  if (eind->elf.root.type != bfd_link_hash_indirect)
+    return;
+
   /* Copy over the GOT refcount entries that we may have already seen to
      the symbol which just became indirect.  */
   edir->elf.got.refcount += eind->elf.got.refcount;
@@ -3432,6 +3911,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       /* If a relocation refers to _GLOBAL_OFFSET_TABLE_, create the .got.
@@ -3457,13 +3940,11 @@
 	  if (isym == NULL)
 	    return FALSE;
 
-	  if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC
-	      && (!info->shared
-		  || is_branch_reloc (r_type)))
+	  if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC)
 	    {
 	      struct plt_entry **ifunc;
-	      bfd_vma addend;
 
+	      /* Set PLT_IFUNC flag for this sym, no GOT entry yet.  */
 	      ifunc = update_local_sym_info (abfd, symtab_hdr, r_symndx,
 					     PLT_IFUNC);
 	      if (ifunc == NULL)
@@ -3472,15 +3953,19 @@
 	      /* STT_GNU_IFUNC symbols must have a PLT entry;
 		 In a non-pie executable even when there are
 		 no plt calls.  */
-	      addend = 0;
-	      if (r_type == R_PPC_PLTREL24)
+	      if (!info->shared
+		  || is_branch_reloc (r_type))
 		{
-		  ppc_elf_tdata (abfd)->makes_plt_call = 1;
-		  if (info->shared)
-		    addend = rel->r_addend;
+		  bfd_vma addend = 0;
+		  if (r_type == R_PPC_PLTREL24)
+		    {
+		      ppc_elf_tdata (abfd)->makes_plt_call = 1;
+		      if (info->shared)
+			addend = rel->r_addend;
+		    }
+		  if (!update_plt_info (abfd, ifunc, got2, addend))
+		    return FALSE;
 		}
-	      if (!update_plt_info (abfd, ifunc, got2, addend))
-		return FALSE;
 	    }
 	}
 
@@ -3614,10 +4099,21 @@
 	    }
 	  break;
 
+	case R_PPC_VLE_SDAREL_LO16A:
+	case R_PPC_VLE_SDAREL_LO16D:
+	case R_PPC_VLE_SDAREL_HI16A:
+	case R_PPC_VLE_SDAREL_HI16D:
+	case R_PPC_VLE_SDAREL_HA16A:
+	case R_PPC_VLE_SDAREL_HA16D:
 	case R_PPC_SDAREL16:
 	  if (htab->sdata[0].sym == NULL
 	      && !create_sdata_sym (info, &htab->sdata[0]))
 	    return FALSE;
+
+	  if (htab->sdata[1].sym == NULL
+	      && !create_sdata_sym (info, &htab->sdata[1]))
+	    return FALSE;
+
 	  if (h != NULL)
 	    {
 	      ppc_elf_hash_entry (h)->has_sda_refs = TRUE;
@@ -3625,6 +4121,17 @@
 	    }
 	  break;
 
+	case R_PPC_VLE_REL8:
+	case R_PPC_VLE_REL15:
+	case R_PPC_VLE_REL24:
+	case R_PPC_VLE_LO16A:
+	case R_PPC_VLE_LO16D:
+	case R_PPC_VLE_HI16A:
+	case R_PPC_VLE_HI16D:
+	case R_PPC_VLE_HA16A:
+	case R_PPC_VLE_HA16D:
+	  break;
+
 	case R_PPC_EMB_SDA2REL:
 	  if (info->shared)
 	    {
@@ -3641,6 +4148,8 @@
 	    }
 	  break;
 
+	case R_PPC_VLE_SDA21_LO:
+	case R_PPC_VLE_SDA21:
 	case R_PPC_EMB_SDA21:
 	case R_PPC_EMB_RELSDA:
 	  if (info->shared)
@@ -3915,7 +4424,7 @@
 	  if ((info->shared
 	       && (must_be_dyn_reloc (info, r_type)
 		   || (h != NULL
-		       && (! info->symbolic
+		       && (!SYMBOLIC_BIND (info, h)
 			   || h->root.type == bfd_link_hash_defweak
 			   || !h->def_regular))))
 	      || (ELIMINATE_COPY_RELOCS
@@ -3924,9 +4433,6 @@
 		  && (h->root.type == bfd_link_hash_defweak
 		      || !h->def_regular)))
 	    {
-	      struct elf_dyn_relocs *p;
-	      struct elf_dyn_relocs **rel_head;
-
 #ifdef DEBUG
 	      fprintf (stderr,
 		       "ppc_elf_check_relocs needs to "
@@ -3950,13 +4456,34 @@
 		 relocations we need for this symbol.  */
 	      if (h != NULL)
 		{
+		  struct elf_dyn_relocs *p;
+		  struct elf_dyn_relocs **rel_head;
+
 		  rel_head = &ppc_elf_hash_entry (h)->dyn_relocs;
+		  p = *rel_head;
+		  if (p == NULL || p->sec != sec)
+		    {
+		      p = bfd_alloc (htab->elf.dynobj, sizeof *p);
+		      if (p == NULL)
+			return FALSE;
+		      p->next = *rel_head;
+		      *rel_head = p;
+		      p->sec = sec;
+		      p->count = 0;
+		      p->pc_count = 0;
+		    }
+		  p->count += 1;
+		  if (!must_be_dyn_reloc (info, r_type))
+		    p->pc_count += 1;
 		}
 	      else
 		{
 		  /* Track dynamic relocs needed for local syms too.
 		     We really need local syms available to do this
 		     easily.  Oh well.  */
+		  struct ppc_dyn_relocs *p;
+		  struct ppc_dyn_relocs **rel_head;
+		  bfd_boolean is_ifunc;
 		  asection *s;
 		  void *vpp;
 		  Elf_Internal_Sym *isym;
@@ -3971,25 +4498,24 @@
 		    s = sec;
 
 		  vpp = &elf_section_data (s)->local_dynrel;
-		  rel_head = (struct elf_dyn_relocs **) vpp;
+		  rel_head = (struct ppc_dyn_relocs **) vpp;
+		  is_ifunc = ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC;
+		  p = *rel_head;
+		  if (p != NULL && p->sec == sec && p->ifunc != is_ifunc)
+		    p = p->next;
+		  if (p == NULL || p->sec != sec || p->ifunc != is_ifunc)
+		    {
+		      p = bfd_alloc (htab->elf.dynobj, sizeof *p);
+		      if (p == NULL)
+			return FALSE;
+		      p->next = *rel_head;
+		      *rel_head = p;
+		      p->sec = sec;
+		      p->ifunc = is_ifunc;
+		      p->count = 0;
+		    }
+		  p->count += 1;
 		}
-
-	      p = *rel_head;
-	      if (p == NULL || p->sec != sec)
-		{
-		  p = bfd_alloc (htab->elf.dynobj, sizeof *p);
-		  if (p == NULL)
-		    return FALSE;
-		  p->next = *rel_head;
-		  *rel_head = p;
-		  p->sec = sec;
-		  p->count = 0;
-		  p->pc_count = 0;
-		}
-
-	      p->count += 1;
-	      if (!must_be_dyn_reloc (info, r_type))
-		p->pc_count += 1;
 	    }
 
 	  break;
@@ -4238,6 +4764,24 @@
 
   return TRUE;
 }
+
+static void
+ppc_elf_vle_split16 (bfd *output_bfd, bfd_byte *contents,
+                 bfd_vma offset, bfd_vma relocation,
+		 split16_format_type split16_format)
+
+{
+  bfd_vma insn, top5, bottom11;
+
+  insn = bfd_get_32 (output_bfd, contents + offset);
+  top5 = relocation >> 11;
+  top5 = top5 << (split16_format == split16a_type ? 20 : 16);
+  bottom11 = relocation & 0x7ff;
+  insn |= top5;
+  insn |= bottom11;
+  bfd_put_32 (output_bfd, insn, contents + offset);
+}
+
 
 /* Choose which PLT scheme to use, and set .plt flags appropriately.
    Returns -1 on error, 0 for old PLT, 1 for new PLT.  */
@@ -5039,13 +5583,6 @@
       return TRUE;
     }
 
-  if (h->size == 0)
-    {
-      info->callbacks->einfo (_("%P: dynamic variable `%s' is zero size\n"),
-			      h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -5069,7 +5606,7 @@
      copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rela.bss section we are going to use.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       asection *srel;
 
@@ -5402,6 +5939,9 @@
 		  || eh->elf.root.type != bfd_link_hash_undefweak))
 	    {
 	      asection *rsec = htab->relgot;
+
+	      if (eh->elf.type == STT_GNU_IFUNC)
+		rsec = htab->reliplt;
 	      /* All the entries we allocated need relocs.
 		 Except LD only needs one.  */
 	      if ((eh->tls_mask & TLS_LD) != 0
@@ -5519,7 +6059,7 @@
   for (p = eh->dyn_relocs; p != NULL; p = p->next)
     {
       asection *sreloc = elf_section_data (p->sec)->sreloc;
-      if (!htab->elf.dynamic_sections_created)
+      if (eh->elf.type == STT_GNU_IFUNC)
 	sreloc = htab->reliplt;
       sreloc->size += p->count * sizeof (Elf32_External_Rela);
     }
@@ -5583,7 +6123,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (htab->elf.dynobj, ".interp");
+	  s = bfd_get_linker_section (htab->elf.dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
@@ -5612,9 +6152,9 @@
 
       for (s = ibfd->sections; s != NULL; s = s->next)
 	{
-	  struct elf_dyn_relocs *p;
+	  struct ppc_dyn_relocs *p;
 
-	  for (p = ((struct elf_dyn_relocs *)
+	  for (p = ((struct ppc_dyn_relocs *)
 		    elf_section_data (s)->local_dynrel);
 	       p != NULL;
 	       p = p->next)
@@ -5637,7 +6177,7 @@
 	      else if (p->count != 0)
 		{
 		  asection *sreloc = elf_section_data (p->sec)->sreloc;
-		  if (!htab->elf.dynamic_sections_created)
+		  if (p->ifunc)
 		    sreloc = htab->reliplt;
 		  sreloc->size += p->count * sizeof (Elf32_External_Rela);
 		  if ((p->sec->output_section->flags
@@ -5682,8 +6222,12 @@
 	      {
 		*local_got = allocate_got (htab, need);
 		if (info->shared)
-		  htab->relgot->size += (need
-					 * (sizeof (Elf32_External_Rela) / 4));
+		  {
+		    asection *srel = htab->relgot;
+		    if ((*lgot_masks & PLT_IFUNC) != 0)
+		      srel = htab->reliplt;
+		    srel->size += need * (sizeof (Elf32_External_Rela) / 4);
+		  }
 	      }
 	  }
 	else
@@ -5823,7 +6367,8 @@
   if (htab->glink != NULL
       && htab->glink->size != 0
       && htab->glink_eh_frame != NULL
-      && !bfd_is_abs_section (htab->glink_eh_frame->output_section))
+      && !bfd_is_abs_section (htab->glink_eh_frame->output_section)
+      && _bfd_elf_eh_frame_present (info))
     {
       s = htab->glink_eh_frame;
       s->size = sizeof (glink_eh_frame_cie) + 20;
@@ -5868,7 +6413,8 @@
 	{
 	  /* Strip these too.  */
 	}
-      else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela"))
+      else if (CONST_STRNEQ (bfd_get_section_name (htab->elf.dynobj, s),
+			     ".rela"))
 	{
 	  if (s->size != 0)
 	    {
@@ -5942,7 +6488,7 @@
 	  if (!htab->no_tls_get_addr_opt
 	      && htab->tls_get_addr != NULL
 	      && htab->tls_get_addr->plt.plist != NULL
-	      && !add_dynamic_entry (DT_PPC_TLSOPT, 0))
+	      && !add_dynamic_entry (DT_PPC_OPT, PPC_OPT_TLS))
 	    return FALSE;
 	}
 
@@ -5971,6 +6517,66 @@
    }
 #undef add_dynamic_entry
 
+  if (htab->glink_eh_frame != NULL
+      && htab->glink_eh_frame->contents != NULL)
+    {
+      unsigned char *p = htab->glink_eh_frame->contents;
+      bfd_vma val;
+
+      memcpy (p, glink_eh_frame_cie, sizeof (glink_eh_frame_cie));
+      /* CIE length (rewrite in case little-endian).  */
+      bfd_put_32 (htab->elf.dynobj, sizeof (glink_eh_frame_cie) - 4, p);
+      p += sizeof (glink_eh_frame_cie);
+      /* FDE length.  */
+      val = htab->glink_eh_frame->size - 4 - sizeof (glink_eh_frame_cie);
+      bfd_put_32 (htab->elf.dynobj, val, p);
+      p += 4;
+      /* CIE pointer.  */
+      val = p - htab->glink_eh_frame->contents;
+      bfd_put_32 (htab->elf.dynobj, val, p);
+      p += 4;
+      /* Offset to .glink.  Set later.  */
+      p += 4;
+      /* .glink size.  */
+      bfd_put_32 (htab->elf.dynobj, htab->glink->size, p);
+      p += 4;
+      /* Augmentation.  */
+      p += 1;
+
+      if (info->shared
+	  && htab->elf.dynamic_sections_created)
+	{
+	  bfd_vma adv = (htab->glink->size - GLINK_PLTRESOLVE + 8) >> 2;
+	  if (adv < 64)
+	    *p++ = DW_CFA_advance_loc + adv;
+	  else if (adv < 256)
+	    {
+	      *p++ = DW_CFA_advance_loc1;
+	      *p++ = adv;
+	    }
+	  else if (adv < 65536)
+	    {
+	      *p++ = DW_CFA_advance_loc2;
+	      bfd_put_16 (htab->elf.dynobj, adv, p);
+	      p += 2;
+	    }
+	  else
+	    {
+	      *p++ = DW_CFA_advance_loc4;
+	      bfd_put_32 (htab->elf.dynobj, adv, p);
+	      p += 4;
+	    }
+	  *p++ = DW_CFA_register;
+	  *p++ = 65;
+	  p++;
+	  *p++ = DW_CFA_advance_loc + 4;
+	  *p++ = DW_CFA_restore_extended;
+	  *p++ = 65;
+	}
+      BFD_ASSERT ((bfd_vma) ((p + 3 - htab->glink_eh_frame->contents) & -4)
+		  == htab->glink_eh_frame->size);
+    }
+
   return TRUE;
 }
 
@@ -6225,7 +6831,7 @@
 	 attribute for a code section, and we are only looking at
 	 branches.  However, implement it correctly here as a
 	 reference for other target relax_section functions.  */
-      if (0 && tsec->sec_info_type == ELF_INFO_TYPE_MERGE)
+      if (0 && tsec->sec_info_type == SEC_INFO_TYPE_MERGE)
 	{
 	  /* At this stage in linking, no SEC_MERGE symbol has been
 	     adjusted, so all references to such symbols need to be
@@ -6760,6 +7366,21 @@
   return insn;
 }
 
+static bfd_boolean
+is_insn_ds_form (unsigned int insn)
+{
+  return ((insn & (0x3f << 26)) == 58u << 26 /* ld,ldu,lwa */
+	  || (insn & (0x3f << 26)) == 62u << 26 /* std,stdu,stq */
+	  || (insn & (0x3f << 26)) == 57u << 26 /* lfdp */
+	  || (insn & (0x3f << 26)) == 61u << 26 /* stfdp */);
+}
+
+static bfd_boolean
+is_insn_dq_form (unsigned int insn)
+{
+  return (insn & (0x3f << 26)) == 56u << 26; /* lq */
+}
+
 /* The RELOCATE_SECTION function is called by the ELF backend linker
    to handle the relocations for a section.
 
@@ -6805,7 +7426,7 @@
   Elf_Internal_Rela *rel;
   Elf_Internal_Rela *relend;
   Elf_Internal_Rela outrel;
-  asection *got2, *sreloc = NULL;
+  asection *got2;
   bfd_vma *local_got_offsets;
   bfd_boolean ret = TRUE;
   bfd_vma d_offset = (bfd_big_endian (output_bfd) ? 2 : 0);
@@ -6880,7 +7501,7 @@
 	  sym_name = h->root.root.string;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	{
 	  /* For relocs against symbols from removed linkonce sections,
 	     or sections discarded by a linker script, we just want the
@@ -6889,14 +7510,14 @@
 	  if (r_type < R_PPC_max)
 	    howto = ppc_elf_howto_table[r_type];
 	  RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					   rel, relend, howto, contents);
+					   rel, 1, relend, howto, 0, contents);
 	}
 
       if (info->relocatable)
 	{
 	  if (got2 != NULL
 	      && r_type == R_PPC_PLTREL24
-	      && rel->r_addend >= 32768)
+	      && rel->r_addend != 0)
 	    {
 	      /* R_PPC_PLTREL24 is rather special.  If non-zero, the
 		 addend specifies the GOT pointer offset within .got2.  */
@@ -7343,6 +7964,7 @@
 		  ;
 		else
 		  {
+		    BFD_ASSERT (h->dynindx != -1);
 		    indx = h->dynindx;
 		    unresolved_reloc = FALSE;
 		  }
@@ -7410,6 +8032,8 @@
 			asection *rsec = htab->relgot;
 			bfd_byte * loc;
 
+			if (ifunc != NULL)
+			  rsec = htab->reliplt;
 			outrel.r_offset = (htab->got->output_section->vma
 					   + htab->got->output_offset
 					   + off);
@@ -7612,6 +8236,9 @@
 	case R_PPC_UADDR16:
 	  goto dodyn;
 
+	case R_PPC_VLE_REL8:
+	case R_PPC_VLE_REL15:
+	case R_PPC_VLE_REL24:
 	case R_PPC_REL24:
 	case R_PPC_REL14:
 	case R_PPC_REL14_BRTAKEN:
@@ -7653,7 +8280,8 @@
 		  && !h->def_regular))
 	    {
 	      int skip;
-	      bfd_byte * loc;
+	      bfd_byte *loc;
+	      asection *sreloc;
 #ifdef DEBUG
 	      fprintf (stderr, "ppc_elf_relocate_section needs to "
 		       "create relocation for %s\n",
@@ -7664,14 +8292,11 @@
 	      /* When generating a shared object, these relocations
 		 are copied into the output file to be resolved at run
 		 time.  */
+	      sreloc = elf_section_data (input_section)->sreloc;
+	      if (ifunc)
+		sreloc = htab->reliplt;
 	      if (sreloc == NULL)
-		{
-		  sreloc = elf_section_data (input_section)->sreloc;
-		  if (!htab->elf.dynamic_sections_created)
-		    sreloc = htab->reliplt;
-		  if (sreloc == NULL)
-		    return FALSE;
-		}
+		return FALSE;
 
 	      skip = 0;
 	      outrel.r_offset = _bfd_elf_section_offset (output_bfd, info,
@@ -7690,6 +8315,7 @@
 			    || h->root.type == bfd_link_hash_undefweak))
 		       || !SYMBOL_REFERENCES_LOCAL (info, h))
 		{
+		  BFD_ASSERT (h->dynindx != -1);
 		  unresolved_reloc = FALSE;
 		  outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
 		  outrel.r_addend = rel->r_addend;
@@ -7887,40 +8513,46 @@
 	      unresolved_reloc = TRUE;
 	      break;
 	    }
-	  BFD_ASSERT (strcmp (bfd_get_section_name (abfd, sec), ".got") == 0
-		      || strcmp (bfd_get_section_name (abfd, sec), ".cgot") == 0);
+	  BFD_ASSERT (strcmp (bfd_get_section_name (sec->owner, sec),
+			      ".got") == 0
+		      || strcmp (bfd_get_section_name (sec->owner, sec),
+				 ".cgot") == 0);
 
 	  addend -= sec->output_section->vma + sec->output_offset + 0x8000;
 	  break;
 
 	case R_PPC_PLTREL24:
-	  if (h == NULL || ifunc != NULL)
-	    break;
-	  /* Relocation is to the entry for this symbol in the
-	     procedure linkage table.  */
-	  {
-	    struct plt_entry *ent = find_plt_ent (&h->plt.plist, got2,
-						  info->shared ? addend : 0);
-	    addend = 0;
-	    if (ent == NULL
-		|| htab->plt == NULL)
-	      {
-		/* We didn't make a PLT entry for this symbol.  This
-		   happens when statically linking PIC code, or when
-		   using -Bsymbolic.  */
-		break;
-	      }
+	  if (h != NULL && ifunc == NULL)
+	    {
+	      struct plt_entry *ent = find_plt_ent (&h->plt.plist, got2,
+						    info->shared ? addend : 0);
+	      if (ent == NULL
+		  || htab->plt == NULL)
+		{
+		  /* We didn't make a PLT entry for this symbol.  This
+		     happens when statically linking PIC code, or when
+		     using -Bsymbolic.  */
+		}
+	      else
+		{
+		  /* Relocation is to the entry for this symbol in the
+		     procedure linkage table.  */
+		  unresolved_reloc = FALSE;
+		  if (htab->plt_type == PLT_NEW)
+		    relocation = (htab->glink->output_section->vma
+				  + htab->glink->output_offset
+				  + ent->glink_offset);
+		  else
+		    relocation = (htab->plt->output_section->vma
+				  + htab->plt->output_offset
+				  + ent->plt.offset);
+		}
+	    }
 
-	    unresolved_reloc = FALSE;
-	    if (htab->plt_type == PLT_NEW)
-	      relocation = (htab->glink->output_section->vma
-			    + htab->glink->output_offset
-			    + ent->glink_offset);
-	    else
-	      relocation = (htab->plt->output_section->vma
-			    + htab->plt->output_offset
-			    + ent->plt.offset);
-	  }
+	  /* R_PPC_PLTREL24 is rather special.  If non-zero, the
+	     addend specifies the GOT pointer offset within .got2.
+	     Don't apply it to the relocation field.  */
+	  addend = 0;
 	  break;
 
 	  /* Relocate against _SDA_BASE_.  */
@@ -7938,7 +8570,7 @@
 	      }
 	    addend -= SYM_VAL (sda);
 
-	    name = bfd_get_section_name (abfd, sec->output_section);
+	    name = bfd_get_section_name (output_bfd, sec->output_section);
 	    if (! ((CONST_STRNEQ (name, ".sdata")
 		    && (name[6] == 0 || name[6] == '.'))
 		   || (CONST_STRNEQ (name, ".sbss")
@@ -7970,7 +8602,7 @@
 	      }
 	    addend -= SYM_VAL (sda);
 
-	    name = bfd_get_section_name (abfd, sec->output_section);
+	    name = bfd_get_section_name (output_bfd, sec->output_section);
 	    if (! (CONST_STRNEQ (name, ".sdata2")
 		   || CONST_STRNEQ (name, ".sbss2")))
 	      {
@@ -7985,9 +8617,53 @@
 	  }
 	  break;
 
+	case R_PPC_VLE_LO16A:
+	  relocation = (relocation + addend) & 0xffff;
+	  ppc_elf_vle_split16 (output_bfd, contents, rel->r_offset,
+                               relocation, split16a_type);
+	  continue;
+
+	case R_PPC_VLE_LO16D:
+	  relocation = (relocation + addend) & 0xffff;
+	  ppc_elf_vle_split16 (output_bfd, contents, rel->r_offset,
+                               relocation, split16d_type);
+	  continue;
+
+	case R_PPC_VLE_HI16A:
+	  relocation = ((relocation + addend) >> 16) & 0xffff;
+	  ppc_elf_vle_split16 (output_bfd, contents, rel->r_offset,
+                               relocation, split16a_type);
+	  continue;
+
+	case R_PPC_VLE_HI16D:
+	  relocation = ((relocation + addend) >> 16) & 0xffff;
+	  ppc_elf_vle_split16 (output_bfd, contents, rel->r_offset,
+                               relocation, split16d_type);
+	  continue;
+
+	case R_PPC_VLE_HA16A:
+	  {
+	    bfd_vma value = relocation + addend;
+	    value = (((value >> 16) + ((value & 0x8000) ? 1 : 0)) & 0xffff);
+	    ppc_elf_vle_split16 (output_bfd, contents, rel->r_offset,
+                                 value, split16a_type);
+	  }
+	  continue;
+
+	case R_PPC_VLE_HA16D:
+	  {
+	    bfd_vma value = relocation + addend;
+	    value = (((value >> 16) + ((value & 0x8000) ? 1 : 0)) & 0xffff);
+	    ppc_elf_vle_split16 (output_bfd, contents, rel->r_offset,
+                                 value, split16d_type);
+	  }
+	  continue;
+
 	  /* Relocate against either _SDA_BASE_, _SDA2_BASE_, or 0.  */
 	case R_PPC_EMB_SDA21:
+	case R_PPC_VLE_SDA21:
 	case R_PPC_EMB_RELSDA:
+	case R_PPC_VLE_SDA21_LO:
 	  {
 	    const char *name;
 	    int reg;
@@ -7999,7 +8675,7 @@
 		break;
 	      }
 
-	    name = bfd_get_section_name (abfd, sec->output_section);
+	    name = bfd_get_section_name (output_bfd, sec->output_section);
 	    if (((CONST_STRNEQ (name, ".sdata")
 		  && (name[6] == 0 || name[6] == '.'))
 		 || (CONST_STRNEQ (name, ".sbss")
@@ -8044,7 +8720,25 @@
 		addend -= SYM_VAL (sda);
 	      }
 
-	    if (r_type == R_PPC_EMB_SDA21)
+	    if (reg == 0
+		&& (r_type == R_PPC_VLE_SDA21
+		    || r_type == R_PPC_VLE_SDA21_LO))
+	      {
+		/* Use the split20 format.  */
+		bfd_vma insn, bits12to15, bits21to31;
+		bfd_vma value  = (relocation + rel->r_offset) & 0xffff;
+		/* Propagate sign bit, if necessary.  */
+		insn = (value & 0x8000) ? 0x70107800 : 0x70000000;
+		bits12to15 = value & 0x700;
+		bits21to31 = value & 0x7ff;
+		insn |= bits12to15;
+		insn |= bits21to31;
+  		bfd_put_32 (output_bfd, insn, contents + rel->r_offset);
+		continue;
+	      }
+	    else if (r_type == R_PPC_EMB_SDA21
+		     || r_type == R_PPC_VLE_SDA21
+		     || r_type == R_PPC_VLE_SDA21_LO)
 	      {
 		bfd_vma insn;  /* Fill in register field.  */
 
@@ -8055,6 +8749,107 @@
 	  }
 	  break;
 
+	case R_PPC_VLE_SDAREL_LO16A:
+	case R_PPC_VLE_SDAREL_LO16D:
+	case R_PPC_VLE_SDAREL_HI16A:
+	case R_PPC_VLE_SDAREL_HI16D:
+	case R_PPC_VLE_SDAREL_HA16A:
+	case R_PPC_VLE_SDAREL_HA16D:
+	  {
+	    bfd_vma value;
+	    const char *name;
+	    //int reg;
+	    struct elf_link_hash_entry *sda = NULL;
+
+	    if (sec == NULL || sec->output_section == NULL)
+	      {
+		unresolved_reloc = TRUE;
+		break;
+	      }
+
+	    name = bfd_get_section_name (output_bfd, sec->output_section);
+	    if (((CONST_STRNEQ (name, ".sdata")
+		  && (name[6] == 0 || name[6] == '.'))
+		 || (CONST_STRNEQ (name, ".sbss")
+		     && (name[5] == 0 || name[5] == '.'))))
+	      {
+		//reg = 13;
+		sda = htab->sdata[0].sym;
+	      }
+	    else if (CONST_STRNEQ (name, ".sdata2")
+		     || CONST_STRNEQ (name, ".sbss2"))
+	      {
+		//reg = 2;
+		sda = htab->sdata[1].sym;
+	      }
+	    else
+	      {
+		(*_bfd_error_handler)
+		  (_("%B: the target (%s) of a %s relocation is "
+		     "in the wrong output section (%s)"),
+		   input_bfd,
+		   sym_name,
+		   howto->name,
+		   name);
+
+		bfd_set_error (bfd_error_bad_value);
+		ret = FALSE;
+		continue;
+	      }
+
+	    if (sda != NULL)
+	      {
+		if (!is_static_defined (sda))
+		  {
+		    unresolved_reloc = TRUE;
+		    break;
+		  }
+	      }
+
+	   value = sda->root.u.def.section->output_section->vma
+   		   + sda->root.u.def.section->output_offset;
+
+	   if (r_type == R_PPC_VLE_SDAREL_LO16A)
+	      {
+		value = (value + addend) & 0xffff;
+	        ppc_elf_vle_split16 (output_bfd, contents, rel->r_offset,
+                                     value, split16a_type);
+	      }
+	   else if (r_type == R_PPC_VLE_SDAREL_LO16D)
+	      {
+		value = (value + addend) & 0xffff;
+	        ppc_elf_vle_split16 (output_bfd, contents, rel->r_offset,
+                                     value, split16d_type);
+	      }
+	   else if (r_type == R_PPC_VLE_SDAREL_HI16A)
+	      {
+		value = ((value + addend) >> 16) & 0xffff;
+	        ppc_elf_vle_split16 (output_bfd, contents, rel->r_offset,
+                                     value, split16a_type);
+	      }
+	   else if (r_type == R_PPC_VLE_SDAREL_HI16D)
+	      {
+		value = ((value + addend) >> 16) & 0xffff;
+	        ppc_elf_vle_split16 (output_bfd, contents, rel->r_offset,
+                                     value, split16d_type);
+	      }
+	   else if (r_type == R_PPC_VLE_SDAREL_HA16A)
+	      {
+		value += addend;
+		value = (((value >> 16) + ((value & 0x8000) ? 1 : 0)) & 0xffff);
+	        ppc_elf_vle_split16 (output_bfd, contents, rel->r_offset,
+                                     value, split16a_type);
+	      }
+	   else if (r_type == R_PPC_VLE_SDAREL_HA16D)
+	      {
+		value += addend;
+		value = (((value >> 16) + ((value & 0x8000) ? 1 : 0)) & 0xffff);
+	        ppc_elf_vle_split16 (output_bfd, contents, rel->r_offset,
+                                     value, split16d_type);
+	      }
+	  }
+	  continue;
+
 	  /* Relocate against the beginning of the section.  */
 	case R_PPC_SECTOFF:
 	case R_PPC_SECTOFF_LO:
@@ -8135,6 +8930,54 @@
 	     Bits 0:15 are not used.  */
 	  addend += 0x8000;
 	  break;
+
+	case R_PPC_ADDR16:
+	case R_PPC_ADDR16_LO:
+	case R_PPC_GOT16:
+	case R_PPC_GOT16_LO:
+	case R_PPC_SDAREL16:
+	case R_PPC_SECTOFF:
+	case R_PPC_SECTOFF_LO:
+	case R_PPC_DTPREL16:
+	case R_PPC_DTPREL16_LO:
+	case R_PPC_TPREL16:
+	case R_PPC_TPREL16_LO:
+	case R_PPC_GOT_TLSGD16:
+	case R_PPC_GOT_TLSGD16_LO:
+	case R_PPC_GOT_TLSLD16:
+	case R_PPC_GOT_TLSLD16_LO:
+	case R_PPC_GOT_DTPREL16:
+	case R_PPC_GOT_DTPREL16_LO:
+	case R_PPC_GOT_TPREL16:
+	case R_PPC_GOT_TPREL16_LO:
+	  {
+	    /* The 32-bit ABI lacks proper relocations to deal with
+	       certain 64-bit instructions.  Prevent damage to bits
+	       that make up part of the insn opcode.  */
+	    unsigned int insn, mask, lobit;
+
+	    insn = bfd_get_32 (output_bfd, contents + rel->r_offset - d_offset);
+	    mask = 0;
+	    if (is_insn_ds_form (insn))
+	      mask = 3;
+	    else if (is_insn_dq_form (insn))
+	      mask = 15;
+	    else
+	      break;
+	    lobit = mask & (relocation + addend);
+	    if (lobit != 0)
+	      {
+		addend -= lobit;
+		info->callbacks->einfo
+		  (_("%P: %H: error: %s against `%s' not a multiple of %u\n"),
+		   input_bfd, input_section, rel->r_offset,
+		   howto->name, sym_name, mask + 1);
+		bfd_set_error (bfd_error_bad_value);
+		ret = FALSE;
+	      }
+	    addend += insn & mask;
+	  }
+	  break;
 	}
 
 #ifdef DEBUG
@@ -8150,7 +8993,9 @@
 
       if (unresolved_reloc
 	  && !((input_section->flags & SEC_DEBUGGING) != 0
-	       && h->def_dynamic))
+	       && h->def_dynamic)
+	  && _bfd_elf_section_offset (output_bfd, info, input_section,
+				      rel->r_offset) != (bfd_vma) -1)
 	{
 	  info->callbacks->einfo
 	    (_("%P: %H: unresolvable %s relocation against symbol `%s'\n"),
@@ -8327,7 +9172,7 @@
 			    htab->plt->contents + ent->plt.offset + 28);
 
 		/* Fill in the GOT entry corresponding to this PLT slot with
-		   the address immediately after the the "bctr" instruction
+		   the address immediately after the "bctr" instruction
 		   in this PLT entry.  */
 		bfd_put_32 (output_bfd, (htab->plt->output_section->vma
 					 + htab->plt->output_offset
@@ -8547,26 +9392,23 @@
   fprintf (stderr, "\n");
 #endif
 
-  /* Mark some specially defined symbols as absolute.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
-      || (!htab->is_vxworks
-	  && (h == htab->elf.hgot
-	      || strcmp (h->root.root.string,
-			 "_PROCEDURE_LINKAGE_TABLE_") == 0)))
-    sym->st_shndx = SHN_ABS;
-
   return TRUE;
 }
 
 static enum elf_reloc_type_class
-ppc_elf_reloc_type_class (const Elf_Internal_Rela *rela)
+ppc_elf_reloc_type_class (const struct bfd_link_info *info,
+			  const asection *rel_sec,
+			  const Elf_Internal_Rela *rela)
 {
+  struct ppc_elf_link_hash_table *htab = ppc_elf_hash_table (info);
+
+  if (rel_sec == htab->reliplt)
+    return reloc_class_ifunc;
+
   switch (ELF32_R_TYPE (rela->r_info))
     {
     case R_PPC_RELATIVE:
       return reloc_class_relative;
-    case R_PPC_REL24:
-    case R_PPC_ADDR24:
     case R_PPC_JMP_SLOT:
       return reloc_class_plt;
     case R_PPC_COPY:
@@ -8595,9 +9437,9 @@
 
   htab = ppc_elf_hash_table (info);
   dynobj = elf_hash_table (info)->dynobj;
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
   if (htab->is_vxworks)
-    splt = bfd_get_section_by_name (dynobj, ".plt");
+    splt = bfd_get_linker_section (dynobj, ".plt");
   else
     splt = NULL;
 
@@ -8989,17 +9831,10 @@
       unsigned char *p = htab->glink_eh_frame->contents;
       bfd_vma val;
 
-      memcpy (p, glink_eh_frame_cie, sizeof (glink_eh_frame_cie));
-      /* CIE length (rewrite in case little-endian).  */
-      bfd_put_32 (htab->elf.dynobj, sizeof (glink_eh_frame_cie) - 4, p);
       p += sizeof (glink_eh_frame_cie);
       /* FDE length.  */
-      val = htab->glink_eh_frame->size - 4 - sizeof (glink_eh_frame_cie);
-      bfd_put_32 (htab->elf.dynobj, val, p);
       p += 4;
       /* CIE pointer.  */
-      val = p - htab->glink_eh_frame->contents;
-      bfd_put_32 (htab->elf.dynobj, val, p);
       p += 4;
       /* Offset to .glink.  */
       val = (htab->glink->output_section->vma
@@ -9008,47 +9843,8 @@
 	      + htab->glink_eh_frame->output_offset);
       val -= p - htab->glink_eh_frame->contents;
       bfd_put_32 (htab->elf.dynobj, val, p);
-      p += 4;
-      /* .glink size.  */
-      bfd_put_32 (htab->elf.dynobj, htab->glink->size, p);
-      p += 4;
-      /* Augmentation.  */
-      p += 1;
 
-      if (info->shared
-	  && htab->elf.dynamic_sections_created)
-	{
-	  bfd_vma adv = (htab->glink->size - GLINK_PLTRESOLVE + 8) >> 2;
-	  if (adv < 64)
-	    *p++ = DW_CFA_advance_loc + adv;
-	  else if (adv < 256)
-	    {
-	      *p++ = DW_CFA_advance_loc1;
-	      *p++ = adv;
-	    }
-	  else if (adv < 65536)
-	    {
-	      *p++ = DW_CFA_advance_loc2;
-	      bfd_put_16 (htab->elf.dynobj, adv, p);
-	      p += 2;
-	    }
-	  else
-	    {
-	      *p++ = DW_CFA_advance_loc4;
-	      bfd_put_32 (htab->elf.dynobj, adv, p);
-	      p += 4;
-	    }
-	  *p++ = DW_CFA_register;
-	  *p++ = 65;
-	  p++;
-	  *p++ = DW_CFA_advance_loc + 4;
-	  *p++ = DW_CFA_restore_extended;
-	  *p++ = 65;
-	}
-      BFD_ASSERT ((bfd_vma) ((p + 3 - htab->glink_eh_frame->contents) & -4)
-		  == htab->glink_eh_frame->size);
-
-      if (htab->glink_eh_frame->sec_info_type == ELF_INFO_TYPE_EH_FRAME
+      if (htab->glink_eh_frame->sec_info_type == SEC_INFO_TYPE_EH_FRAME
 	  && !_bfd_elf_write_section_eh_frame (output_bfd, info,
 					       htab->glink_eh_frame,
 					       htab->glink_eh_frame->contents))
@@ -9091,7 +9887,7 @@
 #define bfd_elf32_bfd_merge_private_bfd_data	ppc_elf_merge_private_bfd_data
 #define bfd_elf32_bfd_relax_section		ppc_elf_relax_section
 #define bfd_elf32_bfd_reloc_type_lookup		ppc_elf_reloc_type_lookup
-#define bfd_elf32_bfd_reloc_name_lookup	ppc_elf_reloc_name_lookup
+#define bfd_elf32_bfd_reloc_name_lookup		ppc_elf_reloc_name_lookup
 #define bfd_elf32_bfd_set_private_flags		ppc_elf_set_private_flags
 #define bfd_elf32_bfd_link_hash_table_create	ppc_elf_link_hash_table_create
 #define bfd_elf32_get_synthetic_symtab		ppc_elf_get_synthetic_symtab
@@ -9112,6 +9908,7 @@
 #define elf_backend_finish_dynamic_sections	ppc_elf_finish_dynamic_sections
 #define elf_backend_fake_sections		ppc_elf_fake_sections
 #define elf_backend_additional_program_headers	ppc_elf_additional_program_headers
+#define elf_backend_modify_segment_map     	ppc_elf_modify_segment_map
 #define elf_backend_grok_prstatus		ppc_elf_grok_prstatus
 #define elf_backend_grok_psinfo			ppc_elf_grok_psinfo
 #define elf_backend_write_core_note		ppc_elf_write_core_note
@@ -9124,6 +9921,26 @@
 #define elf_backend_action_discarded		ppc_elf_action_discarded
 #define elf_backend_init_index_section		_bfd_elf_init_1_index_section
 #define elf_backend_post_process_headers	_bfd_elf_set_osabi
+#define elf_backend_lookup_section_flags_hook	ppc_elf_lookup_section_flags
+#define elf_backend_section_processing		ppc_elf_section_processing
+
+#include "elf32-target.h"
+
+/* FreeBSD Target */
+
+#undef  TARGET_LITTLE_SYM
+#undef  TARGET_LITTLE_NAME
+
+#undef  TARGET_BIG_SYM
+#define TARGET_BIG_SYM  bfd_elf32_powerpc_freebsd_vec
+#undef  TARGET_BIG_NAME
+#define TARGET_BIG_NAME "elf32-powerpc-freebsd"
+
+#undef  ELF_OSABI
+#define ELF_OSABI	ELFOSABI_FREEBSD
+
+#undef  elf32_bed
+#define elf32_bed	elf32_powerpc_fbsd_bed
 
 #include "elf32-target.h"
 
@@ -9137,6 +9954,8 @@
 #undef TARGET_BIG_NAME
 #define TARGET_BIG_NAME		"elf32-powerpc-vxworks"
 
+#undef  ELF_OSABI
+
 /* VxWorks uses the elf default section flags for .plt.  */
 static const struct bfd_elf_special_section *
 ppc_elf_vxworks_get_sec_type_attr (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
diff --git a/bfd/elf32-ppc.h b/bfd/elf32-ppc.h
index 4becb30..0bf973c 100644
--- a/bfd/elf32-ppc.h
+++ b/bfd/elf32-ppc.h
@@ -1,5 +1,5 @@
 /* PowerPC-specific support for 64-bit ELF.
-   Copyright 2003, 2005, 2007 Free Software Foundation, Inc.
+   Copyright 2003, 2005, 2007, 2009, 2012 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -31,3 +31,6 @@
 asection *ppc_elf_tls_setup (bfd *, struct bfd_link_info *, int);
 bfd_boolean ppc_elf_tls_optimize (bfd *, struct bfd_link_info *);
 void ppc_elf_set_sdata_syms (bfd *, struct bfd_link_info *);
+extern bfd_boolean ppc_elf_modify_segment_map (bfd *,
+		           struct bfd_link_info * ATTRIBUTE_UNUSED);
+extern bfd_boolean ppc_elf_section_processing (bfd *, Elf_Internal_Shdr *);
diff --git a/bfd/elf32-rl78.c b/bfd/elf32-rl78.c
new file mode 100644
index 0000000..d18cc18
--- /dev/null
+++ b/bfd/elf32-rl78.c
@@ -0,0 +1,2520 @@
+/* Renesas RL78 specific support for 32-bit ELF.
+   Copyright (C) 2011-2013 Free Software Foundation, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "bfd_stdint.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf/rl78.h"
+#include "libiberty.h"
+
+#define valid_16bit_address(v) ((v) <= 0x0ffff || (v) >= 0xf0000)
+
+#define RL78REL(n,sz,bit,shift,complain,pcrel)				     \
+  HOWTO (R_RL78_##n, shift, sz, bit, pcrel, 0, complain_overflow_ ## complain, \
+	 bfd_elf_generic_reloc, "R_RL78_" #n, FALSE, 0, ~0, FALSE)
+
+/* Note that the relocations around 0x7f are internal to this file;
+   feel free to move them as needed to avoid conflicts with published
+   relocation numbers.  */
+
+static reloc_howto_type rl78_elf_howto_table [] =
+{
+  RL78REL (NONE,         0,  0, 0, dont,     FALSE),
+  RL78REL (DIR32,        2, 32, 0, signed,   FALSE),
+  RL78REL (DIR24S,       2, 24, 0, signed,   FALSE),
+  RL78REL (DIR16,        1, 16, 0, dont,     FALSE),
+  RL78REL (DIR16U,       1, 16, 0, unsigned, FALSE),
+  RL78REL (DIR16S,       1, 16, 0, signed,   FALSE),
+  RL78REL (DIR8,         0,  8, 0, dont,     FALSE),
+  RL78REL (DIR8U,        0,  8, 0, unsigned, FALSE),
+  RL78REL (DIR8S,        0,  8, 0, signed,   FALSE),
+  RL78REL (DIR24S_PCREL, 2, 24, 0, signed,   TRUE),
+  RL78REL (DIR16S_PCREL, 1, 16, 0, signed,   TRUE),
+  RL78REL (DIR8S_PCREL,  0,  8, 0, signed,   TRUE),
+  RL78REL (DIR16UL,      1, 16, 2, unsigned, FALSE),
+  RL78REL (DIR16UW,      1, 16, 1, unsigned, FALSE),
+  RL78REL (DIR8UL,       0,  8, 2, unsigned, FALSE),
+  RL78REL (DIR8UW,       0,  8, 1, unsigned, FALSE),
+  RL78REL (DIR32_REV,    1, 16, 0, dont,     FALSE),
+  RL78REL (DIR16_REV,    1, 16, 0, dont,     FALSE),
+  RL78REL (DIR3U_PCREL,  0,  3, 0, dont,     TRUE),
+
+  EMPTY_HOWTO (0x13),
+  EMPTY_HOWTO (0x14),
+  EMPTY_HOWTO (0x15),
+  EMPTY_HOWTO (0x16),
+  EMPTY_HOWTO (0x17),
+  EMPTY_HOWTO (0x18),
+  EMPTY_HOWTO (0x19),
+  EMPTY_HOWTO (0x1a),
+  EMPTY_HOWTO (0x1b),
+  EMPTY_HOWTO (0x1c),
+  EMPTY_HOWTO (0x1d),
+  EMPTY_HOWTO (0x1e),
+  EMPTY_HOWTO (0x1f),
+
+  EMPTY_HOWTO (0x20),
+  EMPTY_HOWTO (0x21),
+  EMPTY_HOWTO (0x22),
+  EMPTY_HOWTO (0x23),
+  EMPTY_HOWTO (0x24),
+  EMPTY_HOWTO (0x25),
+  EMPTY_HOWTO (0x26),
+  EMPTY_HOWTO (0x27),
+  EMPTY_HOWTO (0x28),
+  EMPTY_HOWTO (0x29),
+  EMPTY_HOWTO (0x2a),
+  EMPTY_HOWTO (0x2b),
+  EMPTY_HOWTO (0x2c),
+  RL78REL (RH_RELAX, 0,  0, 0, dont,     FALSE),
+
+  EMPTY_HOWTO (0x2e),
+  EMPTY_HOWTO (0x2f),
+  EMPTY_HOWTO (0x30),
+  EMPTY_HOWTO (0x31),
+  EMPTY_HOWTO (0x32),
+  EMPTY_HOWTO (0x33),
+  EMPTY_HOWTO (0x34),
+  EMPTY_HOWTO (0x35),
+  EMPTY_HOWTO (0x36),
+  EMPTY_HOWTO (0x37),
+  EMPTY_HOWTO (0x38),
+  EMPTY_HOWTO (0x39),
+  EMPTY_HOWTO (0x3a),
+  EMPTY_HOWTO (0x3b),
+  EMPTY_HOWTO (0x3c),
+  EMPTY_HOWTO (0x3d),
+  EMPTY_HOWTO (0x3e),
+  EMPTY_HOWTO (0x3f),
+  EMPTY_HOWTO (0x40),
+
+  RL78REL (ABS32,        2, 32, 0, dont,     FALSE),
+  RL78REL (ABS24S,       2, 24, 0, signed,   FALSE),
+  RL78REL (ABS16,        1, 16, 0, dont,     FALSE),
+  RL78REL (ABS16U,       1, 16, 0, unsigned, FALSE),
+  RL78REL (ABS16S,       1, 16, 0, signed,   FALSE),
+  RL78REL (ABS8,         0,  8, 0, dont,     FALSE),
+  RL78REL (ABS8U,        0,  8, 0, unsigned, FALSE),
+  RL78REL (ABS8S,        0,  8, 0, signed,   FALSE),
+  RL78REL (ABS24S_PCREL, 2, 24, 0, signed,   TRUE),
+  RL78REL (ABS16S_PCREL, 1, 16, 0, signed,   TRUE),
+  RL78REL (ABS8S_PCREL,  0,  8, 0, signed,   TRUE),
+  RL78REL (ABS16UL,      1, 16, 0, unsigned, FALSE),
+  RL78REL (ABS16UW,      1, 16, 0, unsigned, FALSE),
+  RL78REL (ABS8UL,       0,  8, 0, unsigned, FALSE),
+  RL78REL (ABS8UW,       0,  8, 0, unsigned, FALSE),
+  RL78REL (ABS32_REV,    2, 32, 0, dont,     FALSE),
+  RL78REL (ABS16_REV,    1, 16, 0, dont,     FALSE),
+
+#define STACK_REL_P(x) ((x) <= R_RL78_ABS16_REV && (x) >= R_RL78_ABS32)
+
+  EMPTY_HOWTO (0x52),
+  EMPTY_HOWTO (0x53),
+  EMPTY_HOWTO (0x54),
+  EMPTY_HOWTO (0x55),
+  EMPTY_HOWTO (0x56),
+  EMPTY_HOWTO (0x57),
+  EMPTY_HOWTO (0x58),
+  EMPTY_HOWTO (0x59),
+  EMPTY_HOWTO (0x5a),
+  EMPTY_HOWTO (0x5b),
+  EMPTY_HOWTO (0x5c),
+  EMPTY_HOWTO (0x5d),
+  EMPTY_HOWTO (0x5e),
+  EMPTY_HOWTO (0x5f),
+  EMPTY_HOWTO (0x60),
+  EMPTY_HOWTO (0x61),
+  EMPTY_HOWTO (0x62),
+  EMPTY_HOWTO (0x63),
+  EMPTY_HOWTO (0x64),
+  EMPTY_HOWTO (0x65),
+  EMPTY_HOWTO (0x66),
+  EMPTY_HOWTO (0x67),
+  EMPTY_HOWTO (0x68),
+  EMPTY_HOWTO (0x69),
+  EMPTY_HOWTO (0x6a),
+  EMPTY_HOWTO (0x6b),
+  EMPTY_HOWTO (0x6c),
+  EMPTY_HOWTO (0x6d),
+  EMPTY_HOWTO (0x6e),
+  EMPTY_HOWTO (0x6f),
+  EMPTY_HOWTO (0x70),
+  EMPTY_HOWTO (0x71),
+  EMPTY_HOWTO (0x72),
+  EMPTY_HOWTO (0x73),
+  EMPTY_HOWTO (0x74),
+  EMPTY_HOWTO (0x75),
+  EMPTY_HOWTO (0x76),
+  EMPTY_HOWTO (0x77),
+
+  EMPTY_HOWTO (0x78),
+  EMPTY_HOWTO (0x79),
+  EMPTY_HOWTO (0x7a),
+  EMPTY_HOWTO (0x7b),
+  EMPTY_HOWTO (0x7c),
+  EMPTY_HOWTO (0x7d),
+  EMPTY_HOWTO (0x7e),
+  EMPTY_HOWTO (0x7f),
+
+  RL78REL (SYM,       2, 32, 0, dont, FALSE),
+  RL78REL (OPneg,     2, 32, 0, dont, FALSE),
+  RL78REL (OPadd,     2, 32, 0, dont, FALSE),
+  RL78REL (OPsub,     2, 32, 0, dont, FALSE),
+  RL78REL (OPmul,     2, 32, 0, dont, FALSE),
+  RL78REL (OPdiv,     2, 32, 0, dont, FALSE),
+  RL78REL (OPshla,    2, 32, 0, dont, FALSE),
+  RL78REL (OPshra,    2, 32, 0, dont, FALSE),
+  RL78REL (OPsctsize, 2, 32, 0, dont, FALSE),
+  EMPTY_HOWTO (0x89),
+  EMPTY_HOWTO (0x8a),
+  EMPTY_HOWTO (0x8b),
+  EMPTY_HOWTO (0x8c),
+  RL78REL (OPscttop,  2, 32, 0, dont, FALSE),
+  EMPTY_HOWTO (0x8e),
+  EMPTY_HOWTO (0x8f),
+  RL78REL (OPand,     2, 32, 0, dont, FALSE),
+  RL78REL (OPor,      2, 32, 0, dont, FALSE),
+  RL78REL (OPxor,     2, 32, 0, dont, FALSE),
+  RL78REL (OPnot,     2, 32, 0, dont, FALSE),
+  RL78REL (OPmod,     2, 32, 0, dont, FALSE),
+  RL78REL (OPromtop,  2, 32, 0, dont, FALSE),
+  RL78REL (OPramtop,  2, 32, 0, dont, FALSE)
+};
+
+/* Map BFD reloc types to RL78 ELF reloc types.  */
+
+struct rl78_reloc_map
+{
+  bfd_reloc_code_real_type  bfd_reloc_val;
+  unsigned int              rl78_reloc_val;
+};
+
+static const struct rl78_reloc_map rl78_reloc_map [] =
+{
+  { BFD_RELOC_NONE,		R_RL78_NONE },
+  { BFD_RELOC_8,		R_RL78_DIR8S },
+  { BFD_RELOC_16,		R_RL78_DIR16S },
+  { BFD_RELOC_24,		R_RL78_DIR24S },
+  { BFD_RELOC_32,		R_RL78_DIR32 },
+  { BFD_RELOC_RL78_16_OP,	R_RL78_DIR16 },
+  { BFD_RELOC_RL78_DIR3U_PCREL,	R_RL78_DIR3U_PCREL },
+  { BFD_RELOC_8_PCREL,		R_RL78_DIR8S_PCREL },
+  { BFD_RELOC_16_PCREL,		R_RL78_DIR16S_PCREL },
+  { BFD_RELOC_24_PCREL,		R_RL78_DIR24S_PCREL },
+  { BFD_RELOC_RL78_8U,		R_RL78_DIR8U },
+  { BFD_RELOC_RL78_16U,		R_RL78_DIR16U },
+  { BFD_RELOC_RL78_SYM,		R_RL78_SYM },
+  { BFD_RELOC_RL78_OP_SUBTRACT,	R_RL78_OPsub },
+  { BFD_RELOC_RL78_OP_NEG,	R_RL78_OPneg },
+  { BFD_RELOC_RL78_OP_AND,	R_RL78_OPand },
+  { BFD_RELOC_RL78_OP_SHRA,	R_RL78_OPshra },
+  { BFD_RELOC_RL78_ABS8,	R_RL78_ABS8 },
+  { BFD_RELOC_RL78_ABS16,	R_RL78_ABS16 },
+  { BFD_RELOC_RL78_ABS16_REV,	R_RL78_ABS16_REV },
+  { BFD_RELOC_RL78_ABS32,	R_RL78_ABS32 },
+  { BFD_RELOC_RL78_ABS32_REV,	R_RL78_ABS32_REV },
+  { BFD_RELOC_RL78_ABS16UL,	R_RL78_ABS16UL },
+  { BFD_RELOC_RL78_ABS16UW,	R_RL78_ABS16UW },
+  { BFD_RELOC_RL78_ABS16U,	R_RL78_ABS16U },
+  { BFD_RELOC_RL78_RELAX,	R_RL78_RH_RELAX }
+};
+
+static reloc_howto_type *
+rl78_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
+			bfd_reloc_code_real_type code)
+{
+  unsigned int i;
+
+  if (code == BFD_RELOC_RL78_32_OP)
+    return rl78_elf_howto_table + R_RL78_DIR32;
+
+  for (i = ARRAY_SIZE (rl78_reloc_map); --i;)
+    if (rl78_reloc_map [i].bfd_reloc_val == code)
+      return rl78_elf_howto_table + rl78_reloc_map[i].rl78_reloc_val;
+
+  return NULL;
+}
+
+static reloc_howto_type *
+rl78_reloc_name_lookup (bfd * abfd ATTRIBUTE_UNUSED, const char * r_name)
+{
+  unsigned int i;
+
+  for (i = 0; i < ARRAY_SIZE (rl78_elf_howto_table); i++)
+    if (rl78_elf_howto_table[i].name != NULL
+	&& strcasecmp (rl78_elf_howto_table[i].name, r_name) == 0)
+      return rl78_elf_howto_table + i;
+
+  return NULL;
+}
+
+/* Set the howto pointer for an RL78 ELF reloc.  */
+
+static void
+rl78_info_to_howto_rela (bfd *               abfd ATTRIBUTE_UNUSED,
+			 arelent *           cache_ptr,
+			 Elf_Internal_Rela * dst)
+{
+  unsigned int r_type;
+
+  r_type = ELF32_R_TYPE (dst->r_info);
+  BFD_ASSERT (r_type < (unsigned int) R_RL78_max);
+  cache_ptr->howto = rl78_elf_howto_table + r_type;
+}
+
+static bfd_vma
+get_symbol_value (const char *            name,
+		  bfd_reloc_status_type * status,
+		  struct bfd_link_info *  info,
+		  bfd *                   input_bfd,
+		  asection *              input_section,
+		  int			  offset)
+{
+  bfd_vma value = 0;
+  struct bfd_link_hash_entry * h;
+
+  h = bfd_link_hash_lookup (info->hash, name, FALSE, FALSE, TRUE);
+
+  if (h == NULL
+      || (h->type != bfd_link_hash_defined
+	  && h->type != bfd_link_hash_defweak))
+    * status = info->callbacks->undefined_symbol
+      (info, name, input_bfd, input_section, offset, TRUE);
+  else
+    value = (h->u.def.value
+	     + h->u.def.section->output_section->vma
+	     + h->u.def.section->output_offset);
+
+  return value;
+}
+
+static bfd_vma
+get_romstart (bfd_reloc_status_type * status,
+	      struct bfd_link_info *  info,
+	      bfd *                   abfd,
+	      asection *              sec,
+	      int		      offset)
+{
+  static bfd_boolean cached = FALSE;
+  static bfd_vma     cached_value = 0;
+
+  if (!cached)
+    {
+      cached_value = get_symbol_value ("_start", status, info, abfd, sec, offset);
+      cached = TRUE;
+    }
+  return cached_value;
+}
+
+static bfd_vma
+get_ramstart (bfd_reloc_status_type * status,
+	      struct bfd_link_info *  info,
+	      bfd *                   abfd,
+	      asection *              sec,
+	      int		      offset)
+{
+  static bfd_boolean cached = FALSE;
+  static bfd_vma     cached_value = 0;
+
+  if (!cached)
+    {
+      cached_value = get_symbol_value ("__datastart", status, info, abfd, sec, offset);
+      cached = TRUE;
+    }
+  return cached_value;
+}
+
+#define NUM_STACK_ENTRIES 16
+static int32_t rl78_stack [ NUM_STACK_ENTRIES ];
+static unsigned int rl78_stack_top;
+
+#define RL78_STACK_PUSH(val)			\
+  do						\
+    {						\
+      if (rl78_stack_top < NUM_STACK_ENTRIES)	\
+        rl78_stack [rl78_stack_top ++] = (val);	\
+      else					\
+        r = bfd_reloc_dangerous;		\
+    }						\
+  while (0)
+
+#define RL78_STACK_POP(dest)			\
+  do						\
+    {						\
+      if (rl78_stack_top > 0)			\
+        (dest) = rl78_stack [-- rl78_stack_top];	\
+      else					\
+        (dest) = 0, r = bfd_reloc_dangerous;	\
+    }						\
+  while (0)
+
+/* Relocate an RL78 ELF section.
+   There is some attempt to make this function usable for many architectures,
+   both USE_REL and USE_RELA ['twould be nice if such a critter existed],
+   if only to serve as a learning tool.
+
+   The RELOCATE_SECTION function is called by the new ELF backend linker
+   to handle the relocations for a section.
+
+   The relocs are always passed as Rela structures; if the section
+   actually uses Rel structures, the r_addend field will always be
+   zero.
+
+   This function is responsible for adjusting the section contents as
+   necessary, and (if using Rela relocs and generating a relocatable
+   output file) adjusting the reloc addend as necessary.
+
+   This function does not have to worry about setting the reloc
+   address or the reloc symbol index.
+
+   LOCAL_SYMS is a pointer to the swapped in local symbols.
+
+   LOCAL_SECTIONS is an array giving the section in the input file
+   corresponding to the st_shndx field of each local symbol.
+
+   The global hash table entry for the global symbols can be found
+   via elf_sym_hashes (input_bfd).
+
+   When generating relocatable output, this function must handle
+   STB_LOCAL/STT_SECTION symbols specially.  The output symbol is
+   going to be the section symbol corresponding to the output
+   section, which means that the addend must be adjusted
+   accordingly.  */
+
+static bfd_boolean
+rl78_elf_relocate_section
+    (bfd *                   output_bfd,
+     struct bfd_link_info *  info,
+     bfd *                   input_bfd,
+     asection *              input_section,
+     bfd_byte *              contents,
+     Elf_Internal_Rela *     relocs,
+     Elf_Internal_Sym *      local_syms,
+     asection **             local_sections)
+{
+  Elf_Internal_Shdr *           symtab_hdr;
+  struct elf_link_hash_entry ** sym_hashes;
+  Elf_Internal_Rela *           rel;
+  Elf_Internal_Rela *           relend;
+  bfd *dynobj;
+  asection *splt;
+
+  symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
+  sym_hashes = elf_sym_hashes (input_bfd);
+  relend     = relocs + input_section->reloc_count;
+
+  dynobj = elf_hash_table (info)->dynobj;
+  splt = NULL;
+  if (dynobj != NULL)
+    splt = bfd_get_linker_section (dynobj, ".plt");
+
+  for (rel = relocs; rel < relend; rel ++)
+    {
+      reloc_howto_type *           howto;
+      unsigned long                r_symndx;
+      Elf_Internal_Sym *           sym;
+      asection *                   sec;
+      struct elf_link_hash_entry * h;
+      bfd_vma                      relocation;
+      bfd_reloc_status_type        r;
+      const char *                 name = NULL;
+      bfd_boolean                  unresolved_reloc = TRUE;
+      int                          r_type;
+
+      r_type = ELF32_R_TYPE (rel->r_info);
+      r_symndx = ELF32_R_SYM (rel->r_info);
+
+      howto  = rl78_elf_howto_table + ELF32_R_TYPE (rel->r_info);
+      h      = NULL;
+      sym    = NULL;
+      sec    = NULL;
+      relocation = 0;
+
+      if (r_symndx < symtab_hdr->sh_info)
+	{
+	  sym = local_syms + r_symndx;
+	  sec = local_sections [r_symndx];
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, & sec, rel);
+
+	  name = bfd_elf_string_from_elf_section
+	    (input_bfd, symtab_hdr->sh_link, sym->st_name);
+	  name = (sym->st_name == 0) ? bfd_section_name (input_bfd, sec) : name;
+	}
+      else
+	{
+	  bfd_boolean warned;
+
+	  RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
+				   r_symndx, symtab_hdr, sym_hashes, h,
+				   sec, relocation, unresolved_reloc,
+				   warned);
+
+	  name = h->root.root.string;
+	}
+
+      if (sec != NULL && discarded_section (sec))
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, 1, relend, howto, 0, contents);
+
+      if (info->relocatable)
+	{
+	  /* This is a relocatable link.  We don't have to change
+             anything, unless the reloc is against a section symbol,
+             in which case we have to adjust according to where the
+             section symbol winds up in the output section.  */
+	  if (sym != NULL && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+	    rel->r_addend += sec->output_offset;
+	  continue;
+	}
+
+      switch (ELF32_R_TYPE (rel->r_info))
+	{
+	case R_RL78_DIR16S:
+	  {
+	    bfd_vma *plt_offset;
+
+	    if (h != NULL)
+	      plt_offset = &h->plt.offset;
+	    else
+	      plt_offset = elf_local_got_offsets (input_bfd) + r_symndx;
+
+	    if (! valid_16bit_address (relocation))
+	      {
+		/* If this is the first time we've processed this symbol,
+		   fill in the plt entry with the correct symbol address.  */
+		if ((*plt_offset & 1) == 0)
+		  {
+		    unsigned int x;
+
+		    x = 0x000000ec;  /* br !!abs24 */
+		    x |= (relocation << 8) & 0xffffff00;
+		    bfd_put_32 (input_bfd, x, splt->contents + *plt_offset);
+		    *plt_offset |= 1;
+		  }
+
+		relocation = (splt->output_section->vma
+			      + splt->output_offset
+			      + (*plt_offset & -2));
+		if (name)
+		{
+		  char *newname = bfd_malloc (strlen(name)+5);
+		  strcpy (newname, name);
+		  strcat(newname, ".plt");
+		  _bfd_generic_link_add_one_symbol (info,
+						    input_bfd,
+						    newname,
+						    BSF_FUNCTION | BSF_WEAK,
+						    splt,
+						    (*plt_offset & -2),
+						    0,
+						    1,
+						    0,
+						    0);
+		}
+	      }
+	  }
+	  break;
+	}
+
+      if (h != NULL && h->root.type == bfd_link_hash_undefweak)
+	/* If the symbol is undefined and weak
+	   then the relocation resolves to zero.  */
+	relocation = 0;
+      else
+	{
+	  if (howto->pc_relative)
+	    {
+	      relocation -= (input_section->output_section->vma
+			     + input_section->output_offset
+			     + rel->r_offset);
+	      relocation -= bfd_get_reloc_size (howto);
+	    }
+
+	  relocation += rel->r_addend;
+	}
+
+      r = bfd_reloc_ok;
+
+#define RANGE(a,b) if (a > (long) relocation || (long) relocation > b) r = bfd_reloc_overflow
+#define ALIGN(m)   if (relocation & m) r = bfd_reloc_other;
+#define OP(i)      (contents[rel->r_offset + (i)])
+
+      /* Opcode relocs are always big endian.  Data relocs are bi-endian.  */
+      switch (r_type)
+	{
+	case R_RL78_NONE:
+	  break;
+
+	case R_RL78_RH_RELAX:
+	  break;
+
+	case R_RL78_DIR8S_PCREL:
+	  RANGE (-128, 127);
+	  OP (0) = relocation;
+	  break;
+
+	case R_RL78_DIR8S:
+	  RANGE (-128, 255);
+	  OP (0) = relocation;
+	  break;
+
+	case R_RL78_DIR8U:
+	  RANGE (0, 255);
+	  OP (0) = relocation;
+	  break;
+
+	case R_RL78_DIR16S_PCREL:
+	  RANGE (-32768, 32767);
+	  OP (0) = relocation;
+	  OP (1) = relocation >> 8;
+	  break;
+
+	case R_RL78_DIR16S:
+	  if ((relocation & 0xf0000) == 0xf0000)
+	    relocation &= 0xffff;
+	  RANGE (-32768, 65535);
+	  OP (0) = relocation;
+	  OP (1) = relocation >> 8;
+	  break;
+
+	case R_RL78_DIR16U:
+	  RANGE (0, 65536);
+	  OP (0) = relocation;
+	  OP (1) = relocation >> 8;
+	  break;
+
+	case R_RL78_DIR16:
+	  RANGE (-32768, 65536);
+	  OP (0) = relocation;
+	  OP (1) = relocation >> 8;
+	  break;
+
+	case R_RL78_DIR16_REV:
+	  RANGE (-32768, 65536);
+	  OP (1) = relocation;
+	  OP (0) = relocation >> 8;
+	  break;
+
+	case R_RL78_DIR3U_PCREL:
+	  RANGE (3, 10);
+	  OP (0) &= 0xf8;
+	  OP (0) |= relocation & 0x07;
+	  break;
+
+	case R_RL78_DIR24S_PCREL:
+	  RANGE (-0x800000, 0x7fffff);
+	  OP (0) = relocation;
+	  OP (1) = relocation >> 8;
+	  OP (2) = relocation >> 16;
+	  break;
+
+	case R_RL78_DIR24S:
+	  RANGE (-0x800000, 0x7fffff);
+	  OP (0) = relocation;
+	  OP (1) = relocation >> 8;
+	  OP (2) = relocation >> 16;
+	  break;
+
+	case R_RL78_DIR32:
+	  OP (0) = relocation;
+	  OP (1) = relocation >> 8;
+	  OP (2) = relocation >> 16;
+	  OP (3) = relocation >> 24;
+	  break;
+
+	case R_RL78_DIR32_REV:
+	  OP (3) = relocation;
+	  OP (2) = relocation >> 8;
+	  OP (1) = relocation >> 16;
+	  OP (0) = relocation >> 24;
+	  break;
+
+	case R_RL78_RH_SFR:
+	  RANGE (0xfff00, 0xfffff);
+	  OP (0) = relocation & 0xff;
+	  break;
+
+	case R_RL78_RH_SADDR:
+	  RANGE (0xffe20, 0xfff1f);
+	  OP (0) = relocation & 0xff;
+	  break;
+
+	  /* Complex reloc handling:  */
+
+	case R_RL78_ABS32:
+	  RL78_STACK_POP (relocation);
+	  OP (0) = relocation;
+	  OP (1) = relocation >> 8;
+	  OP (2) = relocation >> 16;
+	  OP (3) = relocation >> 24;
+	  break;
+
+	case R_RL78_ABS32_REV:
+	  RL78_STACK_POP (relocation);
+	  OP (3) = relocation;
+	  OP (2) = relocation >> 8;
+	  OP (1) = relocation >> 16;
+	  OP (0) = relocation >> 24;
+	  break;
+
+	case R_RL78_ABS24S_PCREL:
+	case R_RL78_ABS24S:
+	  RL78_STACK_POP (relocation);
+	  RANGE (-0x800000, 0x7fffff);
+	  OP (0) = relocation;
+	  OP (1) = relocation >> 8;
+	  OP (2) = relocation >> 16;
+	  break;
+
+	case R_RL78_ABS16:
+	  RL78_STACK_POP (relocation);
+	  RANGE (-32768, 65535);
+	  OP (0) = relocation;
+	  OP (1) = relocation >> 8;
+	  break;
+
+	case R_RL78_ABS16_REV:
+	  RL78_STACK_POP (relocation);
+	  RANGE (-32768, 65535);
+	  OP (1) = relocation;
+	  OP (0) = relocation >> 8;
+	  break;
+
+	case R_RL78_ABS16S_PCREL:
+	case R_RL78_ABS16S:
+	  RL78_STACK_POP (relocation);
+	  RANGE (-32768, 32767);
+	  OP (0) = relocation;
+	  OP (1) = relocation >> 8;
+	  break;
+
+	case R_RL78_ABS16U:
+	  RL78_STACK_POP (relocation);
+	  RANGE (0, 65536);
+	  OP (0) = relocation;
+	  OP (1) = relocation >> 8;
+	  break;
+
+	case R_RL78_ABS16UL:
+	  RL78_STACK_POP (relocation);
+	  relocation >>= 2;
+	  RANGE (0, 65536);
+	  OP (0) = relocation;
+	  OP (1) = relocation >> 8;
+	  break;
+
+	case R_RL78_ABS16UW:
+	  RL78_STACK_POP (relocation);
+	  relocation >>= 1;
+	  RANGE (0, 65536);
+	  OP (0) = relocation;
+	  OP (1) = relocation >> 8;
+	  break;
+
+	case R_RL78_ABS8:
+	  RL78_STACK_POP (relocation);
+	  RANGE (-128, 255);
+	  OP (0) = relocation;
+	  break;
+
+	case R_RL78_ABS8U:
+	  RL78_STACK_POP (relocation);
+	  RANGE (0, 255);
+	  OP (0) = relocation;
+	  break;
+
+	case R_RL78_ABS8UL:
+	  RL78_STACK_POP (relocation);
+	  relocation >>= 2;
+	  RANGE (0, 255);
+	  OP (0) = relocation;
+	  break;
+
+	case R_RL78_ABS8UW:
+	  RL78_STACK_POP (relocation);
+	  relocation >>= 1;
+	  RANGE (0, 255);
+	  OP (0) = relocation;
+	  break;
+
+	case R_RL78_ABS8S_PCREL:
+	case R_RL78_ABS8S:
+	  RL78_STACK_POP (relocation);
+	  RANGE (-128, 127);
+	  OP (0) = relocation;
+	  break;
+
+	case R_RL78_SYM:
+	  if (r_symndx < symtab_hdr->sh_info)
+	    RL78_STACK_PUSH (sec->output_section->vma
+			   + sec->output_offset
+			   + sym->st_value
+			   + rel->r_addend);
+	  else
+	    {
+	      if (h != NULL
+		  && (h->root.type == bfd_link_hash_defined
+		      || h->root.type == bfd_link_hash_defweak))
+		RL78_STACK_PUSH (h->root.u.def.value
+			       + sec->output_section->vma
+			       + sec->output_offset
+			       + rel->r_addend);
+	      else if (h->root.type == bfd_link_hash_undefweak)
+		RL78_STACK_PUSH (0);
+	      else
+		_bfd_error_handler (_("Warning: RL78_SYM reloc with an unknown symbol"));
+	    }
+	  break;
+
+	case R_RL78_OPneg:
+	  {
+	    int32_t tmp;
+
+	    RL78_STACK_POP (tmp);
+	    tmp = - tmp;
+	    RL78_STACK_PUSH (tmp);
+	  }
+	  break;
+
+	case R_RL78_OPadd:
+	  {
+	    int32_t tmp1, tmp2;
+
+	    RL78_STACK_POP (tmp2);
+	    RL78_STACK_POP (tmp1);
+	    tmp1 += tmp2;
+	    RL78_STACK_PUSH (tmp1);
+	  }
+	  break;
+
+	case R_RL78_OPsub:
+	  {
+	    int32_t tmp1, tmp2;
+
+	    /* For the expression "A - B", the assembler pushes A,
+	       then B, then OPSUB.  So the first op we pop is B, not
+	       A.  */
+	    RL78_STACK_POP (tmp2);	/* B */
+	    RL78_STACK_POP (tmp1);	/* A */
+	    tmp1 -= tmp2;		/* A - B */
+	    RL78_STACK_PUSH (tmp1);
+	  }
+	  break;
+
+	case R_RL78_OPmul:
+	  {
+	    int32_t tmp1, tmp2;
+
+	    RL78_STACK_POP (tmp2);
+	    RL78_STACK_POP (tmp1);
+	    tmp1 *= tmp2;
+	    RL78_STACK_PUSH (tmp1);
+	  }
+	  break;
+
+	case R_RL78_OPdiv:
+	  {
+	    int32_t tmp1, tmp2;
+
+	    RL78_STACK_POP (tmp2);
+	    RL78_STACK_POP (tmp1);
+	    tmp1 /= tmp2;
+	    RL78_STACK_PUSH (tmp1);
+	  }
+	  break;
+
+	case R_RL78_OPshla:
+	  {
+	    int32_t tmp1, tmp2;
+
+	    RL78_STACK_POP (tmp2);
+	    RL78_STACK_POP (tmp1);
+	    tmp1 <<= tmp2;
+	    RL78_STACK_PUSH (tmp1);
+	  }
+	  break;
+
+	case R_RL78_OPshra:
+	  {
+	    int32_t tmp1, tmp2;
+
+	    RL78_STACK_POP (tmp2);
+	    RL78_STACK_POP (tmp1);
+	    tmp1 >>= tmp2;
+	    RL78_STACK_PUSH (tmp1);
+	  }
+	  break;
+
+	case R_RL78_OPsctsize:
+	  RL78_STACK_PUSH (input_section->size);
+	  break;
+
+	case R_RL78_OPscttop:
+	  RL78_STACK_PUSH (input_section->output_section->vma);
+	  break;
+
+	case R_RL78_OPand:
+	  {
+	    int32_t tmp1, tmp2;
+
+	    RL78_STACK_POP (tmp2);
+	    RL78_STACK_POP (tmp1);
+	    tmp1 &= tmp2;
+	    RL78_STACK_PUSH (tmp1);
+	  }
+	  break;
+
+	case R_RL78_OPor:
+	  {
+	    int32_t tmp1, tmp2;
+
+	    RL78_STACK_POP (tmp2);
+	    RL78_STACK_POP (tmp1);
+	    tmp1 |= tmp2;
+	    RL78_STACK_PUSH (tmp1);
+	  }
+	  break;
+
+	case R_RL78_OPxor:
+	  {
+	    int32_t tmp1, tmp2;
+
+	    RL78_STACK_POP (tmp2);
+	    RL78_STACK_POP (tmp1);
+	    tmp1 ^= tmp2;
+	    RL78_STACK_PUSH (tmp1);
+	  }
+	  break;
+
+	case R_RL78_OPnot:
+	  {
+	    int32_t tmp;
+
+	    RL78_STACK_POP (tmp);
+	    tmp = ~ tmp;
+	    RL78_STACK_PUSH (tmp);
+	  }
+	  break;
+
+	case R_RL78_OPmod:
+	  {
+	    int32_t tmp1, tmp2;
+
+	    RL78_STACK_POP (tmp2);
+	    RL78_STACK_POP (tmp1);
+	    tmp1 %= tmp2;
+	    RL78_STACK_PUSH (tmp1);
+	  }
+	  break;
+
+	case R_RL78_OPromtop:
+	  RL78_STACK_PUSH (get_romstart (&r, info, input_bfd, input_section, rel->r_offset));
+	  break;
+
+	case R_RL78_OPramtop:
+	  RL78_STACK_PUSH (get_ramstart (&r, info, input_bfd, input_section, rel->r_offset));
+	  break;
+
+	default:
+	  r = bfd_reloc_notsupported;
+	  break;
+	}
+
+      if (r != bfd_reloc_ok)
+	{
+	  const char * msg = NULL;
+
+	  switch (r)
+	    {
+	    case bfd_reloc_overflow:
+	      /* Catch the case of a missing function declaration
+		 and emit a more helpful error message.  */
+	      if (r_type == R_RL78_DIR24S_PCREL)
+		msg = _("%B(%A): error: call to undefined function '%s'");
+	      else
+		r = info->callbacks->reloc_overflow
+		  (info, (h ? &h->root : NULL), name, howto->name, (bfd_vma) 0,
+		   input_bfd, input_section, rel->r_offset);
+	      break;
+
+	    case bfd_reloc_undefined:
+	      r = info->callbacks->undefined_symbol
+		(info, name, input_bfd, input_section, rel->r_offset,
+		 TRUE);
+	      break;
+
+	    case bfd_reloc_other:
+	      msg = _("%B(%A): warning: unaligned access to symbol '%s' in the small data area");
+	      break;
+
+	    case bfd_reloc_outofrange:
+	      msg = _("%B(%A): internal error: out of range error");
+	      break;
+
+	    case bfd_reloc_notsupported:
+	      msg = _("%B(%A): internal error: unsupported relocation error");
+	      break;
+
+	    case bfd_reloc_dangerous:
+	      msg = _("%B(%A): internal error: dangerous relocation");
+	      break;
+
+	    default:
+	      msg = _("%B(%A): internal error: unknown error");
+	      break;
+	    }
+
+	  if (msg)
+	    _bfd_error_handler (msg, input_bfd, input_section, name);
+
+	  if (! r)
+	    return FALSE;
+	}
+    }
+
+  return TRUE;
+}
+
+/* Function to set the ELF flag bits.  */
+
+static bfd_boolean
+rl78_elf_set_private_flags (bfd * abfd, flagword flags)
+{
+  elf_elfheader (abfd)->e_flags = flags;
+  elf_flags_init (abfd) = TRUE;
+  return TRUE;
+}
+
+static bfd_boolean no_warn_mismatch = FALSE;
+
+void bfd_elf32_rl78_set_target_flags (bfd_boolean);
+
+void
+bfd_elf32_rl78_set_target_flags (bfd_boolean user_no_warn_mismatch)
+{
+  no_warn_mismatch = user_no_warn_mismatch;
+}
+
+/* Merge backend specific data from an object file to the output
+   object file when linking.  */
+
+static bfd_boolean
+rl78_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
+{
+  flagword new_flags;
+  flagword old_flags;
+  bfd_boolean error = FALSE;
+
+  new_flags = elf_elfheader (ibfd)->e_flags;
+  old_flags = elf_elfheader (obfd)->e_flags;
+
+  if (!elf_flags_init (obfd))
+    {
+      /* First call, no flags set.  */
+      elf_flags_init (obfd) = TRUE;
+      elf_elfheader (obfd)->e_flags = new_flags;
+    }
+  else if (old_flags != new_flags)
+    {
+      flagword changed_flags = old_flags ^ new_flags;
+
+      if (changed_flags & E_FLAG_RL78_G10)
+	{
+	  (*_bfd_error_handler)
+	    (_("RL78/G10 ABI conflict: cannot link G10 and non-G10 objects together"));
+
+	  if (old_flags & E_FLAG_RL78_G10)
+	    (*_bfd_error_handler) (_("- %s is G10, %s is not"),
+				   bfd_get_filename (obfd), bfd_get_filename (ibfd));
+	  else
+	    (*_bfd_error_handler) (_("- %s is G10, %s is not"),
+				   bfd_get_filename (ibfd), bfd_get_filename (obfd));
+	}
+    }
+
+  return !error;
+}
+
+static bfd_boolean
+rl78_elf_print_private_bfd_data (bfd * abfd, void * ptr)
+{
+  FILE * file = (FILE *) ptr;
+  flagword flags;
+
+  BFD_ASSERT (abfd != NULL && ptr != NULL);
+
+  /* Print normal ELF private data.  */
+  _bfd_elf_print_private_bfd_data (abfd, ptr);
+
+  flags = elf_elfheader (abfd)->e_flags;
+  fprintf (file, _("private flags = 0x%lx:"), (long) flags);
+
+  if (flags & E_FLAG_RL78_G10)
+    fprintf (file, _(" [G10]"));
+
+  fputc ('\n', file);
+  return TRUE;
+}
+
+/* Return the MACH for an e_flags value.  */
+
+static int
+elf32_rl78_machine (bfd * abfd)
+{
+  if ((elf_elfheader (abfd)->e_flags & EF_RL78_CPU_MASK) == EF_RL78_CPU_RL78)
+    return bfd_mach_rl78;
+
+  return 0;
+}
+
+static bfd_boolean
+rl78_elf_object_p (bfd * abfd)
+{
+  bfd_default_set_arch_mach (abfd, bfd_arch_rl78,
+			     elf32_rl78_machine (abfd));
+  return TRUE;
+}
+ 
+#ifdef DEBUG
+void
+rl78_dump_symtab (bfd * abfd, void * internal_syms, void * external_syms)
+{
+  size_t locsymcount;
+  Elf_Internal_Sym * isymbuf;
+  Elf_Internal_Sym * isymend;
+  Elf_Internal_Sym * isym;
+  Elf_Internal_Shdr * symtab_hdr;
+  bfd_boolean free_internal = FALSE, free_external = FALSE;
+  char * st_info_str;
+  char * st_info_stb_str;
+  char * st_other_str;
+  char * st_shndx_str;
+
+  if (! internal_syms)
+    {
+      internal_syms = bfd_malloc (1000);
+      free_internal = 1;
+    }
+  if (! external_syms)
+    {
+      external_syms = bfd_malloc (1000);
+      free_external = 1;
+    }
+
+  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+  locsymcount = symtab_hdr->sh_size / get_elf_backend_data (abfd)->s->sizeof_sym;
+  if (free_internal)
+    isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
+				    symtab_hdr->sh_info, 0,
+				    internal_syms, external_syms, NULL);
+  else
+    isymbuf = internal_syms;
+  isymend = isymbuf + locsymcount;
+
+  for (isym = isymbuf ; isym < isymend ; isym++)
+    {
+      switch (ELF_ST_TYPE (isym->st_info))
+	{
+	case STT_FUNC: st_info_str = "STT_FUNC";
+	case STT_SECTION: st_info_str = "STT_SECTION";
+	case STT_FILE: st_info_str = "STT_FILE";
+	case STT_OBJECT: st_info_str = "STT_OBJECT";
+	case STT_TLS: st_info_str = "STT_TLS";
+	default: st_info_str = "";
+	}
+      switch (ELF_ST_BIND (isym->st_info))
+	{
+	case STB_LOCAL: st_info_stb_str = "STB_LOCAL";
+	case STB_GLOBAL: st_info_stb_str = "STB_GLOBAL";
+	default: st_info_stb_str = "";
+	}
+      switch (ELF_ST_VISIBILITY (isym->st_other))
+	{
+	case STV_DEFAULT: st_other_str = "STV_DEFAULT";
+	case STV_INTERNAL: st_other_str = "STV_INTERNAL";
+	case STV_PROTECTED: st_other_str = "STV_PROTECTED";
+	default: st_other_str = "";
+	}
+      switch (isym->st_shndx)
+	{
+	case SHN_ABS: st_shndx_str = "SHN_ABS";
+	case SHN_COMMON: st_shndx_str = "SHN_COMMON";
+	case SHN_UNDEF: st_shndx_str = "SHN_UNDEF";
+	default: st_shndx_str = "";
+	}
+    }
+  if (free_internal)
+    free (internal_syms);
+  if (free_external)
+    free (external_syms);
+}
+
+char *
+rl78_get_reloc (long reloc)
+{
+  if (0 <= reloc && reloc < R_RL78_max)
+    return rl78_elf_howto_table[reloc].name;
+  return "";
+}
+#endif /* DEBUG */
+
+
+/* support PLT for 16-bit references to 24-bit functions.  */
+
+/* We support 16-bit pointers to code above 64k by generating a thunk
+   below 64k containing a JMP instruction to the final address.  */
+
+static bfd_boolean
+rl78_elf_check_relocs
+    (bfd *                     abfd,
+     struct bfd_link_info *    info,
+     asection *                sec,
+     const Elf_Internal_Rela * relocs)
+{
+  Elf_Internal_Shdr *           symtab_hdr;
+  struct elf_link_hash_entry ** sym_hashes;
+  const Elf_Internal_Rela *     rel;
+  const Elf_Internal_Rela *     rel_end;
+  bfd_vma *local_plt_offsets;
+  asection *splt;
+  bfd *dynobj;
+
+  if (info->relocatable)
+    return TRUE;
+
+  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+  sym_hashes = elf_sym_hashes (abfd);
+  local_plt_offsets = elf_local_got_offsets (abfd);
+  splt = NULL;
+  dynobj = elf_hash_table(info)->dynobj;
+
+  rel_end = relocs + sec->reloc_count;
+  for (rel = relocs; rel < rel_end; rel++)
+    {
+      struct elf_link_hash_entry *h;
+      unsigned long r_symndx;
+      bfd_vma *offset;
+
+      r_symndx = ELF32_R_SYM (rel->r_info);
+      if (r_symndx < symtab_hdr->sh_info)
+        h = NULL;
+      else
+	{
+	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
+	}
+
+      switch (ELF32_R_TYPE (rel->r_info))
+        {
+	  /* This relocation describes a 16-bit pointer to a function.
+	     We may need to allocate a thunk in low memory; reserve memory
+	     for it now.  */
+	case R_RL78_DIR16S:
+	  if (dynobj == NULL)
+	    elf_hash_table (info)->dynobj = dynobj = abfd;
+	  if (splt == NULL)
+	    {
+	      splt = bfd_get_linker_section (dynobj, ".plt");
+	      if (splt == NULL)
+		{
+		  flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+				    | SEC_IN_MEMORY | SEC_LINKER_CREATED
+				    | SEC_READONLY | SEC_CODE);
+		  splt = bfd_make_section_anyway_with_flags (dynobj, ".plt",
+							     flags);
+		  if (splt == NULL
+		      || ! bfd_set_section_alignment (dynobj, splt, 1))
+		    return FALSE;
+		}
+	    }
+
+	  if (h != NULL)
+	    offset = &h->plt.offset;
+	  else
+	    {
+	      if (local_plt_offsets == NULL)
+		{
+		  size_t size;
+		  unsigned int i;
+
+		  size = symtab_hdr->sh_info * sizeof (bfd_vma);
+		  local_plt_offsets = (bfd_vma *) bfd_alloc (abfd, size);
+		  if (local_plt_offsets == NULL)
+		    return FALSE;
+		  elf_local_got_offsets (abfd) = local_plt_offsets;
+
+		  for (i = 0; i < symtab_hdr->sh_info; i++)
+		    local_plt_offsets[i] = (bfd_vma) -1;
+		}
+	      offset = &local_plt_offsets[r_symndx];
+	    }
+
+	  if (*offset == (bfd_vma) -1)
+	    {
+	      *offset = splt->size;
+	      splt->size += 4;
+	    }
+	  break;
+        }
+    }
+
+  return TRUE;
+}
+
+/* This must exist if dynobj is ever set.  */
+
+static bfd_boolean
+rl78_elf_finish_dynamic_sections (bfd *abfd ATTRIBUTE_UNUSED,
+                                  struct bfd_link_info *info)
+{
+  bfd *dynobj;
+  asection *splt;
+
+  if (!elf_hash_table (info)->dynamic_sections_created)
+    return TRUE;
+
+  /* As an extra sanity check, verify that all plt entries have been
+     filled in.  However, relaxing might have changed the relocs so
+     that some plt entries don't get filled in, so we have to skip
+     this check if we're relaxing.  Unfortunately, check_relocs is
+     called before relaxation.  */
+
+  if (info->relax_trip > 0) 
+    return TRUE;
+
+  if ((dynobj = elf_hash_table (info)->dynobj) != NULL
+      && (splt = bfd_get_linker_section (dynobj, ".plt")) != NULL)
+    {
+      bfd_byte *contents = splt->contents;
+      unsigned int i, size = splt->size;
+
+      for (i = 0; i < size; i += 4)
+	{
+	  unsigned int x = bfd_get_32 (dynobj, contents + i);
+	  BFD_ASSERT (x != 0);
+	}
+    }
+
+  return TRUE;
+}
+
+static bfd_boolean
+rl78_elf_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
+                               struct bfd_link_info *info)
+{
+  bfd *dynobj;
+  asection *splt;
+
+  if (info->relocatable)
+    return TRUE;
+
+  dynobj = elf_hash_table (info)->dynobj;
+  if (dynobj == NULL)
+    return TRUE;
+
+  splt = bfd_get_linker_section (dynobj, ".plt");
+  BFD_ASSERT (splt != NULL);
+
+  splt->contents = (bfd_byte *) bfd_zalloc (dynobj, splt->size);
+  if (splt->contents == NULL)
+    return FALSE;
+
+  return TRUE;
+}
+
+
+
+/* Handle relaxing.  */
+
+/* A subroutine of rl78_elf_relax_section.  If the global symbol H
+   is within the low 64k, remove any entry for it in the plt.  */
+
+struct relax_plt_data
+{
+  asection *splt;
+  bfd_boolean *again;
+};
+
+static bfd_boolean
+rl78_relax_plt_check (struct elf_link_hash_entry *h, void * xdata)
+{
+  struct relax_plt_data *data = (struct relax_plt_data *) xdata;
+
+  if (h->plt.offset != (bfd_vma) -1)
+    {
+      bfd_vma address;
+
+      if (h->root.type == bfd_link_hash_undefined
+	  || h->root.type == bfd_link_hash_undefweak)
+	address = 0;
+      else
+	address = (h->root.u.def.section->output_section->vma
+		   + h->root.u.def.section->output_offset
+		   + h->root.u.def.value);
+
+      if (valid_16bit_address (address))
+	{
+	  h->plt.offset = -1;
+	  data->splt->size -= 4;
+	  *data->again = TRUE;
+	}
+    }
+
+  return TRUE;
+}
+
+/* A subroutine of rl78_elf_relax_section.  If the global symbol H
+   previously had a plt entry, give it a new entry offset.  */
+
+static bfd_boolean
+rl78_relax_plt_realloc (struct elf_link_hash_entry *h, void * xdata)
+{
+  bfd_vma *entry = (bfd_vma *) xdata;
+
+  if (h->plt.offset != (bfd_vma) -1)
+    {
+      h->plt.offset = *entry;
+      *entry += 4;
+    }
+
+  return TRUE;
+}
+
+static bfd_boolean
+rl78_elf_relax_plt_section (bfd *dynobj,
+                            asection *splt,
+                            struct bfd_link_info *info,
+                            bfd_boolean *again)
+{
+  struct relax_plt_data relax_plt_data;
+  bfd *ibfd;
+
+  /* Assume nothing changes.  */
+  *again = FALSE;
+
+  if (info->relocatable)
+    return TRUE;
+
+  /* We only relax the .plt section at the moment.  */
+  if (dynobj != elf_hash_table (info)->dynobj
+      || strcmp (splt->name, ".plt") != 0)
+    return TRUE;
+
+  /* Quick check for an empty plt.  */
+  if (splt->size == 0)
+    return TRUE;
+
+  /* Map across all global symbols; see which ones happen to
+     fall in the low 64k.  */
+  relax_plt_data.splt = splt;
+  relax_plt_data.again = again;
+  elf_link_hash_traverse (elf_hash_table (info), rl78_relax_plt_check,
+			  &relax_plt_data);
+
+  /* Likewise for local symbols, though that's somewhat less convenient
+     as we have to walk the list of input bfds and swap in symbol data.  */
+  for (ibfd = info->input_bfds; ibfd ; ibfd = ibfd->link_next)
+    {
+      bfd_vma *local_plt_offsets = elf_local_got_offsets (ibfd);
+      Elf_Internal_Shdr *symtab_hdr;
+      Elf_Internal_Sym *isymbuf = NULL;
+      unsigned int idx;
+
+      if (! local_plt_offsets)
+	continue;
+
+      symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+      if (symtab_hdr->sh_info != 0)
+	{
+	  isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
+	  if (isymbuf == NULL)
+	    isymbuf = bfd_elf_get_elf_syms (ibfd, symtab_hdr,
+					    symtab_hdr->sh_info, 0,
+					    NULL, NULL, NULL);
+	  if (isymbuf == NULL)
+	    return FALSE;
+	}
+
+      for (idx = 0; idx < symtab_hdr->sh_info; ++idx)
+	{
+	  Elf_Internal_Sym *isym;
+	  asection *tsec;
+	  bfd_vma address;
+
+	  if (local_plt_offsets[idx] == (bfd_vma) -1)
+	    continue;
+
+	  isym = &isymbuf[idx];
+	  if (isym->st_shndx == SHN_UNDEF)
+	    continue;
+	  else if (isym->st_shndx == SHN_ABS)
+	    tsec = bfd_abs_section_ptr;
+	  else if (isym->st_shndx == SHN_COMMON)
+	    tsec = bfd_com_section_ptr;
+	  else
+	    tsec = bfd_section_from_elf_index (ibfd, isym->st_shndx);
+
+	  address = (tsec->output_section->vma
+		     + tsec->output_offset
+		     + isym->st_value);
+	  if (valid_16bit_address (address))
+	    {
+	      local_plt_offsets[idx] = -1;
+	      splt->size -= 4;
+	      *again = TRUE;
+	    }
+	}
+
+      if (isymbuf != NULL
+	  && symtab_hdr->contents != (unsigned char *) isymbuf)
+	{
+	  if (! info->keep_memory)
+	    free (isymbuf);
+	  else
+	    {
+	      /* Cache the symbols for elf_link_input_bfd.  */
+	      symtab_hdr->contents = (unsigned char *) isymbuf;
+	    }
+	}
+    }
+
+  /* If we changed anything, walk the symbols again to reallocate
+     .plt entry addresses.  */
+  if (*again && splt->size > 0)
+    {
+      bfd_vma entry = 0;
+
+      elf_link_hash_traverse (elf_hash_table (info),
+			      rl78_relax_plt_realloc, &entry);
+
+      for (ibfd = info->input_bfds; ibfd ; ibfd = ibfd->link_next)
+	{
+	  bfd_vma *local_plt_offsets = elf_local_got_offsets (ibfd);
+	  unsigned int nlocals = elf_tdata (ibfd)->symtab_hdr.sh_info;
+	  unsigned int idx;
+
+	  if (! local_plt_offsets)
+	    continue;
+
+	  for (idx = 0; idx < nlocals; ++idx)
+	    if (local_plt_offsets[idx] != (bfd_vma) -1)
+	      {
+	        local_plt_offsets[idx] = entry;
+		entry += 4;
+	      }
+	}
+    }
+
+  return TRUE;
+}
+
+/* Delete some bytes from a section while relaxing.  */
+
+static bfd_boolean
+elf32_rl78_relax_delete_bytes (bfd *abfd, asection *sec, bfd_vma addr, int count,
+			     Elf_Internal_Rela *alignment_rel, int force_snip)
+{
+  Elf_Internal_Shdr * symtab_hdr;
+  unsigned int        sec_shndx;
+  bfd_byte *          contents;
+  Elf_Internal_Rela * irel;
+  Elf_Internal_Rela * irelend;
+  Elf_Internal_Sym *  isym;
+  Elf_Internal_Sym *  isymend;
+  bfd_vma             toaddr;
+  unsigned int        symcount;
+  struct elf_link_hash_entry ** sym_hashes;
+  struct elf_link_hash_entry ** end_hashes;
+
+  if (!alignment_rel)
+    force_snip = 1;
+
+  sec_shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
+
+  contents = elf_section_data (sec)->this_hdr.contents;
+
+  /* The deletion must stop at the next alignment boundary, if
+     ALIGNMENT_REL is non-NULL.  */
+  toaddr = sec->size;
+  if (alignment_rel)
+    toaddr = alignment_rel->r_offset;
+
+  irel = elf_section_data (sec)->relocs;
+  irelend = irel + sec->reloc_count;
+
+  /* Actually delete the bytes.  */
+  memmove (contents + addr, contents + addr + count,
+	   (size_t) (toaddr - addr - count));
+
+  /* If we don't have an alignment marker to worry about, we can just
+     shrink the section.  Otherwise, we have to fill in the newly
+     created gap with NOP insns (0x03).  */
+  if (force_snip)
+    sec->size -= count;
+  else
+    memset (contents + toaddr - count, 0x03, count);
+
+  /* Adjust all the relocs.  */
+  for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++)
+    {
+      /* Get the new reloc address.  */
+      if (irel->r_offset > addr
+	  && (irel->r_offset < toaddr
+	      || (force_snip && irel->r_offset == toaddr)))
+	irel->r_offset -= count;
+
+      /* If we see an ALIGN marker at the end of the gap, we move it
+	 to the beginning of the gap, since marking these gaps is what
+	 they're for.  */
+      if (irel->r_offset == toaddr
+	  && ELF32_R_TYPE (irel->r_info) == R_RL78_RH_RELAX
+	  && irel->r_addend & RL78_RELAXA_ALIGN)
+	irel->r_offset -= count;
+    }
+
+  /* Adjust the local symbols defined in this section.  */
+  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+  isym = (Elf_Internal_Sym *) symtab_hdr->contents;
+  isymend = isym + symtab_hdr->sh_info;
+
+  for (; isym < isymend; isym++)
+    {
+      /* If the symbol is in the range of memory we just moved, we
+	 have to adjust its value.  */
+      if (isym->st_shndx == sec_shndx
+	  && isym->st_value > addr
+	  && isym->st_value < toaddr)
+	isym->st_value -= count;
+
+      /* If the symbol *spans* the bytes we just deleted (i.e. it's
+	 *end* is in the moved bytes but it's *start* isn't), then we
+	 must adjust its size.  */
+      if (isym->st_shndx == sec_shndx
+	  && isym->st_value < addr
+	  && isym->st_value + isym->st_size > addr
+	  && isym->st_value + isym->st_size < toaddr)
+	isym->st_size -= count;
+    }
+
+  /* Now adjust the global symbols defined in this section.  */
+  symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)
+	      - symtab_hdr->sh_info);
+  sym_hashes = elf_sym_hashes (abfd);
+  end_hashes = sym_hashes + symcount;
+
+  for (; sym_hashes < end_hashes; sym_hashes++)
+    {
+      struct elf_link_hash_entry *sym_hash = *sym_hashes;
+
+      if ((sym_hash->root.type == bfd_link_hash_defined
+	   || sym_hash->root.type == bfd_link_hash_defweak)
+	  && sym_hash->root.u.def.section == sec)
+	{
+	  /* As above, adjust the value if needed.  */
+	  if (sym_hash->root.u.def.value > addr
+	      && sym_hash->root.u.def.value < toaddr)
+	    sym_hash->root.u.def.value -= count;
+
+	  /* As above, adjust the size if needed.  */
+	  if (sym_hash->root.u.def.value < addr
+	      && sym_hash->root.u.def.value + sym_hash->size > addr
+	      && sym_hash->root.u.def.value + sym_hash->size < toaddr)
+	    sym_hash->size -= count;
+	}
+    }
+
+  return TRUE;
+}
+
+/* Used to sort relocs by address.  If relocs have the same address,
+   we maintain their relative order, except that R_RL78_RH_RELAX
+   alignment relocs must be the first reloc for any given address.  */
+
+static void
+reloc_bubblesort (Elf_Internal_Rela * r, int count)
+{
+  int i;
+  bfd_boolean again;
+  bfd_boolean swappit;
+
+  /* This is almost a classic bubblesort.  It's the slowest sort, but
+     we're taking advantage of the fact that the relocations are
+     mostly in order already (the assembler emits them that way) and
+     we need relocs with the same address to remain in the same
+     relative order.  */
+  again = TRUE;
+  while (again)
+    {
+      again = FALSE;
+      for (i = 0; i < count - 1; i ++)
+	{
+	  if (r[i].r_offset > r[i + 1].r_offset)
+	    swappit = TRUE;
+	  else if (r[i].r_offset < r[i + 1].r_offset)
+	    swappit = FALSE;
+	  else if (ELF32_R_TYPE (r[i + 1].r_info) == R_RL78_RH_RELAX
+		   && (r[i + 1].r_addend & RL78_RELAXA_ALIGN))
+	    swappit = TRUE;
+	  else if (ELF32_R_TYPE (r[i + 1].r_info) == R_RL78_RH_RELAX
+		   && (r[i + 1].r_addend & RL78_RELAXA_ELIGN)
+		   && !(ELF32_R_TYPE (r[i].r_info) == R_RL78_RH_RELAX
+			&& (r[i].r_addend & RL78_RELAXA_ALIGN)))
+	    swappit = TRUE;
+	  else
+	    swappit = FALSE;
+
+	  if (swappit)
+	    {
+	      Elf_Internal_Rela tmp;
+
+	      tmp = r[i];
+	      r[i] = r[i + 1];
+	      r[i + 1] = tmp;
+	      /* If we do move a reloc back, re-scan to see if it
+		 needs to be moved even further back.  This avoids
+		 most of the O(n^2) behavior for our cases.  */
+	      if (i > 0)
+		i -= 2;
+	      again = TRUE;
+	    }
+	}
+    }
+}
+
+
+#define OFFSET_FOR_RELOC(rel, lrel, scale) \
+  rl78_offset_for_reloc (abfd, rel + 1, symtab_hdr, shndx_buf, intsyms, \
+		       lrel, abfd, sec, link_info, scale)
+
+static bfd_vma
+rl78_offset_for_reloc (bfd *                    abfd,
+		     Elf_Internal_Rela *      rel,
+		     Elf_Internal_Shdr *      symtab_hdr,
+		     Elf_External_Sym_Shndx * shndx_buf ATTRIBUTE_UNUSED,
+		     Elf_Internal_Sym *       intsyms,
+		     Elf_Internal_Rela **     lrel,
+		     bfd *                    input_bfd,
+		     asection *               input_section,
+		     struct bfd_link_info *   info,
+		     int *                    scale)
+{
+  bfd_vma symval;
+  bfd_reloc_status_type r;
+
+  *scale = 1;
+
+  /* REL is the first of 1..N relocations.  We compute the symbol
+     value for each relocation, then combine them if needed.  LREL
+     gets a pointer to the last relocation used.  */
+  while (1)
+    {
+      int32_t tmp1, tmp2;
+
+      /* Get the value of the symbol referred to by the reloc.  */
+      if (ELF32_R_SYM (rel->r_info) < symtab_hdr->sh_info)
+	{
+	  /* A local symbol.  */
+	  Elf_Internal_Sym *isym;
+	  asection *ssec;
+
+	  isym = intsyms + ELF32_R_SYM (rel->r_info);
+
+	  if (isym->st_shndx == SHN_UNDEF)
+	    ssec = bfd_und_section_ptr;
+	  else if (isym->st_shndx == SHN_ABS)
+	    ssec = bfd_abs_section_ptr;
+	  else if (isym->st_shndx == SHN_COMMON)
+	    ssec = bfd_com_section_ptr;
+	  else
+	    ssec = bfd_section_from_elf_index (abfd,
+					       isym->st_shndx);
+
+	  /* Initial symbol value.  */
+	  symval = isym->st_value;
+
+	  /* GAS may have made this symbol relative to a section, in
+	     which case, we have to add the addend to find the
+	     symbol.  */
+	  if (ELF_ST_TYPE (isym->st_info) == STT_SECTION)
+	    symval += rel->r_addend;
+
+	  if (ssec)
+	    {
+	      if ((ssec->flags & SEC_MERGE)
+		  && ssec->sec_info_type == SEC_INFO_TYPE_MERGE)
+		symval = _bfd_merged_section_offset (abfd, & ssec,
+						     elf_section_data (ssec)->sec_info,
+						     symval);
+	    }
+
+	  /* Now make the offset relative to where the linker is putting it.  */
+	  if (ssec)
+	    symval +=
+	      ssec->output_section->vma + ssec->output_offset;
+
+	  symval += rel->r_addend;
+	}
+      else
+	{
+	  unsigned long indx;
+	  struct elf_link_hash_entry * h;
+
+	  /* An external symbol.  */
+	  indx = ELF32_R_SYM (rel->r_info) - symtab_hdr->sh_info;
+	  h = elf_sym_hashes (abfd)[indx];
+	  BFD_ASSERT (h != NULL);
+
+	  if (h->root.type != bfd_link_hash_defined
+	      && h->root.type != bfd_link_hash_defweak)
+	    {
+	      /* This appears to be a reference to an undefined
+		 symbol.  Just ignore it--it will be caught by the
+		 regular reloc processing.  */
+	      if (lrel)
+		*lrel = rel;
+	      return 0;
+	    }
+
+	  symval = (h->root.u.def.value
+		    + h->root.u.def.section->output_section->vma
+		    + h->root.u.def.section->output_offset);
+
+	  symval += rel->r_addend;
+	}
+
+      switch (ELF32_R_TYPE (rel->r_info))
+	{
+	case R_RL78_SYM:
+	  RL78_STACK_PUSH (symval);
+	  break;
+
+	case R_RL78_OPneg:
+	  RL78_STACK_POP (tmp1);
+	  tmp1 = - tmp1;
+	  RL78_STACK_PUSH (tmp1);
+	  break;
+
+	case R_RL78_OPadd:
+	  RL78_STACK_POP (tmp1);
+	  RL78_STACK_POP (tmp2);
+	  tmp1 += tmp2;
+	  RL78_STACK_PUSH (tmp1);
+	  break;
+
+	case R_RL78_OPsub:
+	  RL78_STACK_POP (tmp1);
+	  RL78_STACK_POP (tmp2);
+	  tmp2 -= tmp1;
+	  RL78_STACK_PUSH (tmp2);
+	  break;
+
+	case R_RL78_OPmul:
+	  RL78_STACK_POP (tmp1);
+	  RL78_STACK_POP (tmp2);
+	  tmp1 *= tmp2;
+	  RL78_STACK_PUSH (tmp1);
+	  break;
+
+	case R_RL78_OPdiv:
+	  RL78_STACK_POP (tmp1);
+	  RL78_STACK_POP (tmp2);
+	  tmp1 /= tmp2;
+	  RL78_STACK_PUSH (tmp1);
+	  break;
+
+	case R_RL78_OPshla:
+	  RL78_STACK_POP (tmp1);
+	  RL78_STACK_POP (tmp2);
+	  tmp1 <<= tmp2;
+	  RL78_STACK_PUSH (tmp1);
+	  break;
+
+	case R_RL78_OPshra:
+	  RL78_STACK_POP (tmp1);
+	  RL78_STACK_POP (tmp2);
+	  tmp1 >>= tmp2;
+	  RL78_STACK_PUSH (tmp1);
+	  break;
+
+	case R_RL78_OPsctsize:
+	  RL78_STACK_PUSH (input_section->size);
+	  break;
+
+	case R_RL78_OPscttop:
+	  RL78_STACK_PUSH (input_section->output_section->vma);
+	  break;
+
+	case R_RL78_OPand:
+	  RL78_STACK_POP (tmp1);
+	  RL78_STACK_POP (tmp2);
+	  tmp1 &= tmp2;
+	  RL78_STACK_PUSH (tmp1);
+	  break;
+
+	case R_RL78_OPor:
+	  RL78_STACK_POP (tmp1);
+	  RL78_STACK_POP (tmp2);
+	  tmp1 |= tmp2;
+	  RL78_STACK_PUSH (tmp1);
+	  break;
+
+	case R_RL78_OPxor:
+	  RL78_STACK_POP (tmp1);
+	  RL78_STACK_POP (tmp2);
+	  tmp1 ^= tmp2;
+	  RL78_STACK_PUSH (tmp1);
+	  break;
+
+	case R_RL78_OPnot:
+	  RL78_STACK_POP (tmp1);
+	  tmp1 = ~ tmp1;
+	  RL78_STACK_PUSH (tmp1);
+	  break;
+
+	case R_RL78_OPmod:
+	  RL78_STACK_POP (tmp1);
+	  RL78_STACK_POP (tmp2);
+	  tmp1 %= tmp2;
+	  RL78_STACK_PUSH (tmp1);
+	  break;
+
+	case R_RL78_OPromtop:
+	  RL78_STACK_PUSH (get_romstart (&r, info, input_bfd, input_section, rel->r_offset));
+	  break;
+
+	case R_RL78_OPramtop:
+	  RL78_STACK_PUSH (get_ramstart (&r, info, input_bfd, input_section, rel->r_offset));
+	  break;
+
+	case R_RL78_DIR16UL:
+	case R_RL78_DIR8UL:
+	case R_RL78_ABS16UL:
+	case R_RL78_ABS8UL:
+	  if (rl78_stack_top)
+	    RL78_STACK_POP (symval);
+	  if (lrel)
+	    *lrel = rel;
+	  *scale = 4;
+	  return symval;
+
+	case R_RL78_DIR16UW:
+	case R_RL78_DIR8UW:
+	case R_RL78_ABS16UW:
+	case R_RL78_ABS8UW:
+	  if (rl78_stack_top)
+	    RL78_STACK_POP (symval);
+	  if (lrel)
+	    *lrel = rel;
+	  *scale = 2;
+	  return symval;
+
+	default:
+	  if (rl78_stack_top)
+	    RL78_STACK_POP (symval);
+	  if (lrel)
+	    *lrel = rel;
+	  return symval;
+	}
+
+      rel ++;
+    }
+}
+
+struct {
+  int prefix;		/* or -1 for "no prefix" */
+  int insn;		/* or -1 for "end of list" */
+  int insn_for_saddr;	/* or -1 for "no alternative" */
+  int insn_for_sfr;	/* or -1 for "no alternative" */
+} relax_addr16[] = {
+  { -1, 0x02, 0x06, -1 },	/* ADDW	AX, !addr16 */
+  { -1, 0x22, 0x26, -1 },	/* SUBW	AX, !addr16 */
+  { -1, 0x42, 0x46, -1 },	/* CMPW	AX, !addr16 */
+  { -1, 0x40, 0x4a, -1 },	/* CMP	!addr16, #byte */
+
+  { -1, 0x0f, 0x0b, -1 },	/* ADD	A, !addr16 */
+  { -1, 0x1f, 0x1b, -1 },	/* ADDC	A, !addr16 */
+  { -1, 0x2f, 0x2b, -1 },	/* SUB	A, !addr16 */
+  { -1, 0x3f, 0x3b, -1 },	/* SUBC	A, !addr16 */
+  { -1, 0x4f, 0x4b, -1 },	/* CMP	A, !addr16 */
+  { -1, 0x5f, 0x5b, -1 },	/* AND	A, !addr16 */
+  { -1, 0x6f, 0x6b, -1 },	/* OR	A, !addr16 */
+  { -1, 0x7f, 0x7b, -1 },	/* XOR	A, !addr16 */
+
+  { -1, 0x8f, 0x8d, 0x8e },	/* MOV	A, !addr16 */
+  { -1, 0x9f, 0x9d, 0x9e },	/* MOV	!addr16, A */
+  { -1, 0xaf, 0xad, 0xae },	/* MOVW	AX, !addr16 */
+  { -1, 0xbf, 0xbd, 0xbe },	/* MOVW	!addr16, AX */
+  { -1, 0xcf, 0xcd, 0xce },	/* MOVW	!addr16, #word */
+
+  { -1, 0xa0, 0xa4, -1 },	/* INC	!addr16 */
+  { -1, 0xa2, 0xa6, -1 },	/* INCW	!addr16 */
+  { -1, 0xb0, 0xb4, -1 },	/* DEC	!addr16 */
+  { -1, 0xb2, 0xb6, -1 },	/* DECW	!addr16 */
+
+  { -1, 0xd5, 0xd4, -1 },	/* CMP0	!addr16 */
+  { -1, 0xe5, 0xe4, -1 },	/* ONEB	!addr16 */
+  { -1, 0xf5, 0xf4, -1 },	/* CLRB	!addr16 */
+
+  { -1, 0xd9, 0xd8, -1 },	/* MOV	X, !addr16 */
+  { -1, 0xe9, 0xe8, -1 },	/* MOV	B, !addr16 */
+  { -1, 0xf9, 0xf8, -1 },	/* MOV	C, !addr16 */
+  { -1, 0xdb, 0xda, -1 },	/* MOVW	BC, !addr16 */
+  { -1, 0xeb, 0xea, -1 },	/* MOVW	DE, !addr16 */
+  { -1, 0xfb, 0xfa, -1 },	/* MOVW	HL, !addr16 */
+
+  { 0x61, 0xaa, 0xa8, -1 },	/* XCH	A, !addr16 */
+
+  { 0x71, 0x00, 0x02, 0x0a },	/* SET1	!addr16.0 */
+  { 0x71, 0x10, 0x12, 0x1a },	/* SET1	!addr16.0 */
+  { 0x71, 0x20, 0x22, 0x2a },	/* SET1	!addr16.0 */
+  { 0x71, 0x30, 0x32, 0x3a },	/* SET1	!addr16.0 */
+  { 0x71, 0x40, 0x42, 0x4a },	/* SET1	!addr16.0 */
+  { 0x71, 0x50, 0x52, 0x5a },	/* SET1	!addr16.0 */
+  { 0x71, 0x60, 0x62, 0x6a },	/* SET1	!addr16.0 */
+  { 0x71, 0x70, 0x72, 0x7a },	/* SET1	!addr16.0 */
+
+  { 0x71, 0x08, 0x03, 0x0b },	/* CLR1	!addr16.0 */
+  { 0x71, 0x18, 0x13, 0x1b },	/* CLR1	!addr16.0 */
+  { 0x71, 0x28, 0x23, 0x2b },	/* CLR1	!addr16.0 */
+  { 0x71, 0x38, 0x33, 0x3b },	/* CLR1	!addr16.0 */
+  { 0x71, 0x48, 0x43, 0x4b },	/* CLR1	!addr16.0 */
+  { 0x71, 0x58, 0x53, 0x5b },	/* CLR1	!addr16.0 */
+  { 0x71, 0x68, 0x63, 0x6b },	/* CLR1	!addr16.0 */
+  { 0x71, 0x78, 0x73, 0x7b },	/* CLR1	!addr16.0 */
+
+  { -1, -1, -1, -1 }
+};
+
+/* Relax one section.  */
+
+static bfd_boolean
+rl78_elf_relax_section
+    (bfd *                  abfd,
+     asection *             sec,
+     struct bfd_link_info * link_info,
+     bfd_boolean *          again)
+{
+  Elf_Internal_Shdr * symtab_hdr;
+  Elf_Internal_Shdr * shndx_hdr;
+  Elf_Internal_Rela * internal_relocs;
+  Elf_Internal_Rela * free_relocs = NULL;
+  Elf_Internal_Rela * irel;
+  Elf_Internal_Rela * srel;
+  Elf_Internal_Rela * irelend;
+  Elf_Internal_Rela * next_alignment;
+  bfd_byte *          contents = NULL;
+  bfd_byte *          free_contents = NULL;
+  Elf_Internal_Sym *  intsyms = NULL;
+  Elf_Internal_Sym *  free_intsyms = NULL;
+  Elf_External_Sym_Shndx * shndx_buf = NULL;
+  bfd_vma pc;
+  bfd_vma symval ATTRIBUTE_UNUSED = 0;
+  int pcrel ATTRIBUTE_UNUSED = 0;
+  int code ATTRIBUTE_UNUSED = 0;
+  int section_alignment_glue;
+  int scale;
+
+  if (abfd == elf_hash_table (link_info)->dynobj
+      && strcmp (sec->name, ".plt") == 0)
+    return rl78_elf_relax_plt_section (abfd, sec, link_info, again);
+
+  /* Assume nothing changes.  */
+  *again = FALSE;
+
+  /* We don't have to do anything for a relocatable link, if
+     this section does not have relocs, or if this is not a
+     code section.  */
+  if (link_info->relocatable
+      || (sec->flags & SEC_RELOC) == 0
+      || sec->reloc_count == 0
+      || (sec->flags & SEC_CODE) == 0)
+    return TRUE;
+
+  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+  shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr;
+
+  /* Get the section contents.  */
+  if (elf_section_data (sec)->this_hdr.contents != NULL)
+    contents = elf_section_data (sec)->this_hdr.contents;
+  /* Go get them off disk.  */
+  else
+    {
+      if (! bfd_malloc_and_get_section (abfd, sec, &contents))
+	goto error_return;
+      elf_section_data (sec)->this_hdr.contents = contents;
+    }
+
+  /* Read this BFD's symbols.  */
+  /* Get cached copy if it exists.  */
+  if (symtab_hdr->contents != NULL)
+    intsyms = (Elf_Internal_Sym *) symtab_hdr->contents;
+  else
+    {
+      intsyms = bfd_elf_get_elf_syms (abfd, symtab_hdr, symtab_hdr->sh_info, 0, NULL, NULL, NULL);
+      symtab_hdr->contents = (bfd_byte *) intsyms;
+    }
+
+  if (shndx_hdr->sh_size != 0)
+    {
+      bfd_size_type amt;
+
+      amt = symtab_hdr->sh_info;
+      amt *= sizeof (Elf_External_Sym_Shndx);
+      shndx_buf = (Elf_External_Sym_Shndx *) bfd_malloc (amt);
+      if (shndx_buf == NULL)
+	goto error_return;
+      if (bfd_seek (abfd, shndx_hdr->sh_offset, SEEK_SET) != 0
+	  || bfd_bread (shndx_buf, amt, abfd) != amt)
+	goto error_return;
+      shndx_hdr->contents = (bfd_byte *) shndx_buf;
+    }
+
+  /* Get a copy of the native relocations.  */
+  internal_relocs = (_bfd_elf_link_read_relocs
+		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
+		      link_info->keep_memory));
+  if (internal_relocs == NULL)
+    goto error_return;
+  if (! link_info->keep_memory)
+    free_relocs = internal_relocs;
+
+  /* The RL_ relocs must be just before the operand relocs they go
+     with, so we must sort them to guarantee this.  We use bubblesort
+     instead of qsort so we can guarantee that relocs with the same
+     address remain in the same relative order.  */
+  reloc_bubblesort (internal_relocs, sec->reloc_count);
+
+  /* Walk through them looking for relaxing opportunities.  */
+  irelend = internal_relocs + sec->reloc_count;
+
+
+  /* This will either be NULL or a pointer to the next alignment
+     relocation.  */
+  next_alignment = internal_relocs;
+
+  /* We calculate worst case shrinkage caused by alignment directives.
+     No fool-proof, but better than either ignoring the problem or
+     doing heavy duty analysis of all the alignment markers in all
+     input sections.  */
+  section_alignment_glue = 0;
+  for (irel = internal_relocs; irel < irelend; irel++)
+      if (ELF32_R_TYPE (irel->r_info) == R_RL78_RH_RELAX
+	  && irel->r_addend & RL78_RELAXA_ALIGN)
+	{
+	  int this_glue = 1 << (irel->r_addend & RL78_RELAXA_ANUM);
+
+	  if (section_alignment_glue < this_glue)
+	    section_alignment_glue = this_glue;
+	}
+  /* Worst case is all 0..N alignments, in order, causing 2*N-1 byte
+     shrinkage.  */
+  section_alignment_glue *= 2;
+
+  for (irel = internal_relocs; irel < irelend; irel++)
+    {
+      unsigned char *insn;
+      int nrelocs;
+
+      /* The insns we care about are all marked with one of these.  */
+      if (ELF32_R_TYPE (irel->r_info) != R_RL78_RH_RELAX)
+	continue;
+
+      if (irel->r_addend & RL78_RELAXA_ALIGN
+	  || next_alignment == internal_relocs)
+	{
+	  /* When we delete bytes, we need to maintain all the alignments
+	     indicated.  In addition, we need to be careful about relaxing
+	     jumps across alignment boundaries - these displacements
+	     *grow* when we delete bytes.  For now, don't shrink
+	     displacements across an alignment boundary, just in case.
+	     Note that this only affects relocations to the same
+	     section.  */
+	  next_alignment += 2;
+	  while (next_alignment < irelend
+		 && (ELF32_R_TYPE (next_alignment->r_info) != R_RL78_RH_RELAX
+		     || !(next_alignment->r_addend & RL78_RELAXA_ELIGN)))
+	    next_alignment ++;
+	  if (next_alignment >= irelend || next_alignment->r_offset == 0)
+	    next_alignment = NULL;
+	}
+
+      /* When we hit alignment markers, see if we've shrunk enough
+	 before them to reduce the gap without violating the alignment
+	 requirements.  */
+      if (irel->r_addend & RL78_RELAXA_ALIGN)
+	{
+	  /* At this point, the next relocation *should* be the ELIGN
+	     end marker.  */
+	  Elf_Internal_Rela *erel = irel + 1;
+	  unsigned int alignment, nbytes;
+
+	  if (ELF32_R_TYPE (erel->r_info) != R_RL78_RH_RELAX)
+	    continue;
+	  if (!(erel->r_addend & RL78_RELAXA_ELIGN))
+	    continue;
+
+	  alignment = 1 << (irel->r_addend & RL78_RELAXA_ANUM);
+
+	  if (erel->r_offset - irel->r_offset < alignment)
+	    continue;
+
+	  nbytes = erel->r_offset - irel->r_offset;
+	  nbytes /= alignment;
+	  nbytes *= alignment;
+
+	  elf32_rl78_relax_delete_bytes (abfd, sec, erel->r_offset-nbytes, nbytes, next_alignment,
+				       erel->r_offset == sec->size);
+	  *again = TRUE;
+
+	  continue;
+	}
+
+      if (irel->r_addend & RL78_RELAXA_ELIGN)
+	  continue;
+
+      insn = contents + irel->r_offset;
+
+      nrelocs = irel->r_addend & RL78_RELAXA_RNUM;
+
+      /* At this point, we have an insn that is a candidate for linker
+	 relaxation.  There are NRELOCS relocs following that may be
+	 relaxed, although each reloc may be made of more than one
+	 reloc entry (such as gp-rel symbols).  */
+
+      /* Get the value of the symbol referred to by the reloc.  Just
+         in case this is the last reloc in the list, use the RL's
+         addend to choose between this reloc (no addend) or the next
+         (yes addend, which means at least one following reloc).  */
+
+      /* srel points to the "current" reloction for this insn -
+	 actually the last reloc for a given operand, which is the one
+	 we need to update.  We check the relaxations in the same
+	 order that the relocations happen, so we'll just push it
+	 along as we go.  */
+      srel = irel;
+
+      pc = sec->output_section->vma + sec->output_offset
+	+ srel->r_offset;
+
+#define GET_RELOC \
+      BFD_ASSERT (nrelocs > 0);			       \
+      symval = OFFSET_FOR_RELOC (srel, &srel, &scale); \
+      pcrel = symval - pc + srel->r_addend; \
+      nrelocs --;
+
+#define SNIPNR(offset, nbytes) \
+	elf32_rl78_relax_delete_bytes (abfd, sec, (insn - contents) + offset, nbytes, next_alignment, 0);
+#define SNIP(offset, nbytes, newtype) \
+        SNIPNR (offset, nbytes);						\
+	srel->r_info = ELF32_R_INFO (ELF32_R_SYM (srel->r_info), newtype)
+
+      /* The order of these bit tests must match the order that the
+	 relocs appear in.  Since we sorted those by offset, we can
+	 predict them.  */
+
+      /*----------------------------------------------------------------------*/
+      /* EF ad		BR $rel8	pcrel
+	 ED al ah	BR !abs16	abs
+	 EE al ah	BR $!rel16	pcrel
+	 EC al ah as	BR !!abs20	abs
+
+	 FD al ah	CALL !abs16	abs
+	 FE al ah	CALL $!rel16	pcrel
+	 FC al ah as	CALL !!abs20	abs
+
+	 DC ad		BC  $rel8
+	 DE ad		BNC $rel8
+	 DD ad		BZ  $rel8
+	 DF ad		BNZ $rel8
+	 61 C3 ad	BH  $rel8
+	 61 D3 ad	BNH $rel8
+	 61 C8 EF ad	SKC  ; BR $rel8
+	 61 D8 EF ad	SKNC ; BR $rel8
+	 61 E8 EF ad	SKZ  ; BR $rel8
+	 61 F8 EF ad	SKNZ ; BR $rel8
+	 61 E3 EF ad	SKH  ; BR $rel8
+	 61 F3 EF ad	SKNH ; BR $rel8
+       */
+
+      if (irel->r_addend & RL78_RELAXA_BRA)
+	{
+	  /* SKIP opcodes that skip non-branches will have a relax tag
+	     but no corresponding symbol to relax against; we just
+	     skip those.  */
+	  if (irel->r_addend & RL78_RELAXA_RNUM)
+	    {
+	      GET_RELOC;
+	    }
+
+	  switch (insn[0])
+	    {
+	    case 0xec: /* BR !!abs20 */
+
+	      if (pcrel < 127
+		  && pcrel > -127)
+		{
+		  insn[0] = 0xef;
+		  insn[1] = pcrel;
+		  SNIP (2, 2, R_RL78_DIR8S_PCREL);
+		  *again = TRUE;
+		}
+	      else if (symval < 65536)
+		{
+		  insn[0] = 0xed;
+		  insn[1] = symval & 0xff;
+		  insn[2] = symval >> 8;
+		  SNIP (2, 1, R_RL78_DIR16S);
+		  *again = TRUE;
+		}
+	      else if (pcrel < 32767
+		       && pcrel > -32767)
+		{
+		  insn[0] = 0xee;
+		  insn[1] = pcrel & 0xff;
+		  insn[2] = pcrel >> 8;
+		  SNIP (2, 1, R_RL78_DIR16S_PCREL);
+		  *again = TRUE;
+		}
+	      break;
+
+	    case 0xee: /* BR $!pcrel16 */
+	    case 0xed: /* BR $!abs16 */
+	      if (pcrel < 127
+		  && pcrel > -127)
+		{
+		  insn[0] = 0xef;
+		  insn[1] = pcrel;
+		  SNIP (2, 1, R_RL78_DIR8S_PCREL);
+		  *again = TRUE;
+		}
+	      break;
+
+	    case 0xfc: /* CALL !!abs20 */
+	      if (symval < 65536)
+		{
+		  insn[0] = 0xfd;
+		  insn[1] = symval & 0xff;
+		  insn[2] = symval >> 8;
+		  SNIP (2, 1, R_RL78_DIR16S);
+		  *again = TRUE;
+		}
+	      else if (pcrel < 32767
+		       && pcrel > -32767)
+		{
+		  insn[0] = 0xfe;
+		  insn[1] = pcrel & 0xff;
+		  insn[2] = pcrel >> 8;
+		  SNIP (2, 1, R_RL78_DIR16S_PCREL);
+		  *again = TRUE;
+		}
+	      break;
+
+	    case 0x61: /* PREFIX */
+	      /* For SKIP/BR, we change the BR opcode and delete the
+		 SKIP.  That way, we don't have to find and change the
+		 relocation for the BR.  */
+	      /* Note that, for the case where we're skipping some
+		 other insn, we have no "other" reloc but that's safe
+		 here anyway. */
+	      switch (insn[1])
+		{
+		case 0xc8: /* SKC */
+		  if (insn[2] == 0xef)
+		    {
+		      insn[2] = 0xde; /* BNC */
+		      SNIPNR (0, 2);
+		    }
+		  break;
+
+		case 0xd8: /* SKNC */
+		  if (insn[2] == 0xef)
+		    {
+		      insn[2] = 0xdc; /* BC */
+		      SNIPNR (0, 2);
+		    }
+		  break;
+
+		case 0xe8: /* SKZ */
+		  if (insn[2] == 0xef)
+		    {
+		      insn[2] = 0xdf; /* BNZ */
+		      SNIPNR (0, 2);
+		    }
+		  break;
+
+		case 0xf8: /* SKNZ */
+		  if (insn[2] == 0xef)
+		    {
+		      insn[2] = 0xdd; /* BZ */
+		      SNIPNR (0, 2);
+		    }
+		  break;
+
+		case 0xe3: /* SKH */
+		  if (insn[2] == 0xef)
+		    {
+		      insn[2] = 0xd3; /* BNH */
+		      SNIPNR (1, 1); /* we reuse the 0x61 prefix from the SKH */
+		    }
+		  break;
+
+		case 0xf3: /* SKNH */
+		  if (insn[2] == 0xef)
+		    {
+		      insn[2] = 0xc3; /* BH */
+		      SNIPNR (1, 1); /* we reuse the 0x61 prefix from the SKH */
+		    }
+		  break;
+		}
+	      break;
+	    }
+
+	}
+
+      if (irel->r_addend & RL78_RELAXA_ADDR16)
+	{
+	  /*----------------------------------------------------------------------*/
+	  /* Some insns have both a 16-bit address operand and an 8-bit
+	     variant if the address is within a special range:
+
+	     Address		16-bit operand	SADDR range	SFR range
+	     FFF00-FFFFF	0xff00-0xffff	0x00-0xff
+	     FFE20-FFF1F	0xfe20-0xff1f	 		0x00-0xff
+
+	     The RELAX_ADDR16[] array has the insn encodings for the
+	     16-bit operand version, as well as the SFR and SADDR
+	     variants.  We only need to replace the encodings and
+	     adjust the operand.
+
+	     Note: we intentionally do not attempt to decode and skip
+	     any ES: prefix, as adding ES: means the addr16 (likely)
+	     no longer points to saddr/sfr space.
+	  */
+
+	  int is_sfr;
+	  int is_saddr;
+	  int idx;
+	  int poff;
+
+	  GET_RELOC;
+
+	  if (0xffe20 <= symval && symval <= 0xfffff)
+	    {
+
+	      is_saddr = (0xffe20 <= symval && symval <= 0xfff1f);
+	      is_sfr   = (0xfff00 <= symval && symval <= 0xfffff);
+
+	      for (idx = 0; relax_addr16[idx].insn != -1; idx ++)
+		{
+		  if (relax_addr16[idx].prefix != -1
+		      && insn[0] == relax_addr16[idx].prefix
+		      && insn[1] == relax_addr16[idx].insn)
+		    {
+		      poff = 1;
+		    }
+		  else if (relax_addr16[idx].prefix == -1
+			   && insn[0] == relax_addr16[idx].insn)
+		    {
+		      poff = 0;
+		    }
+		  else
+		    continue;
+
+		  /* We have a matched insn, and poff is 0 or 1 depending
+		     on the base pattern size.  */
+
+		  if (is_sfr && relax_addr16[idx].insn_for_sfr != -1)
+		    {
+		      insn[poff] = relax_addr16[idx].insn_for_sfr;
+		      SNIP (poff+2, 1, R_RL78_RH_SFR);
+		    }
+
+		  else if  (is_saddr && relax_addr16[idx].insn_for_saddr != -1)
+		    {
+		      insn[poff] = relax_addr16[idx].insn_for_saddr;
+		      SNIP (poff+2, 1, R_RL78_RH_SADDR);
+		    }
+
+		}
+	    }
+	}
+
+      /*----------------------------------------------------------------------*/
+
+    }
+
+  return TRUE;
+
+ error_return:
+  if (free_relocs != NULL)
+    free (free_relocs);
+
+  if (free_contents != NULL)
+    free (free_contents);
+
+  if (shndx_buf != NULL)
+    {
+      shndx_hdr->contents = NULL;
+      free (shndx_buf);
+    }
+
+  if (free_intsyms != NULL)
+    free (free_intsyms);
+
+  return TRUE;
+}
+
+
+
+#define ELF_ARCH		bfd_arch_rl78
+#define ELF_MACHINE_CODE	EM_RL78
+#define ELF_MAXPAGESIZE		0x1000
+
+#define TARGET_LITTLE_SYM	bfd_elf32_rl78_vec
+#define TARGET_LITTLE_NAME	"elf32-rl78"
+
+#define elf_info_to_howto_rel			NULL
+#define elf_info_to_howto			rl78_info_to_howto_rela
+#define elf_backend_object_p			rl78_elf_object_p
+#define elf_backend_relocate_section		rl78_elf_relocate_section
+#define elf_symbol_leading_char                 ('_')
+#define elf_backend_can_gc_sections		1
+
+#define bfd_elf32_bfd_reloc_type_lookup		rl78_reloc_type_lookup
+#define bfd_elf32_bfd_reloc_name_lookup		rl78_reloc_name_lookup
+#define bfd_elf32_bfd_set_private_flags		rl78_elf_set_private_flags
+#define bfd_elf32_bfd_merge_private_bfd_data	rl78_elf_merge_private_bfd_data
+#define bfd_elf32_bfd_print_private_bfd_data	rl78_elf_print_private_bfd_data
+
+#define bfd_elf32_bfd_relax_section		rl78_elf_relax_section
+#define elf_backend_check_relocs                rl78_elf_check_relocs
+#define elf_backend_always_size_sections \
+  rl78_elf_always_size_sections
+#define elf_backend_finish_dynamic_sections \
+  rl78_elf_finish_dynamic_sections
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c
index f049f6e..39174bc 100644
--- a/bfd/elf32-rx.c
+++ b/bfd/elf32-rx.c
@@ -1,5 +1,5 @@
 /* Renesas RX specific support for 32-bit ELF.
-   Copyright (C) 2008, 2009, 2010, 2011
+   Copyright (C) 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -32,6 +32,7 @@
    endian-swap we would otherwise get.  We check for this in
    rx_elf_object_p().  */
 const bfd_target bfd_elf32_rx_be_ns_vec;
+const bfd_target bfd_elf32_rx_be_vec;
 
 #ifdef DEBUG
 char * rx_get_reloc (long);
@@ -462,6 +463,13 @@
   struct elf_link_hash_entry ** sym_hashes;
   Elf_Internal_Rela *           rel;
   Elf_Internal_Rela *           relend;
+  bfd_boolean			pid_mode;
+  bfd_boolean			saw_subtract = FALSE;
+
+  if (elf_elfheader (output_bfd)->e_flags & E_FLAG_RX_PID)
+    pid_mode = TRUE;
+  else
+    pid_mode = FALSE;
 
   symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
@@ -488,6 +496,9 @@
       sec    = NULL;
       relocation = 0;
 
+      if (rx_stack_top == 0)
+	saw_subtract = FALSE;
+
       if (r_symndx < symtab_hdr->sh_info)
 	{
 	  sym = local_syms + r_symndx;
@@ -510,9 +521,9 @@
 	  name = h->root.root.string;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	{
@@ -553,6 +564,28 @@
       _bfd_error_handler (_("%B:%A: Warning: deprecated Red Hat reloc " type " detected against: %s."), \
       input_bfd, input_section, name)
 
+      /* Check for unsafe relocs in PID mode.  These are any relocs where
+	 an absolute address is being computed.  There are special cases
+	 for relocs against symbols that are known to be referenced in
+	 crt0.o before the PID base address register has been initialised.  */
+#define UNSAFE_FOR_PID							\
+  do									\
+    {									\
+      if (pid_mode							\
+          && sec != NULL						\
+	  && sec->flags & SEC_READONLY					\
+	  && !(input_section->flags & SEC_DEBUGGING)			\
+	  && strcmp (name, "__pid_base") != 0				\
+	  && strcmp (name, "__gp") != 0					\
+	  && strcmp (name, "__romdatastart") != 0			\
+	  && !saw_subtract)						\
+	_bfd_error_handler (_("%B(%A): unsafe PID relocation %s at 0x%08lx (against %s in %s)"), \
+			    input_bfd, input_section, howto->name,	\
+			    input_section->output_section->vma + input_section->output_offset + rel->r_offset, \
+			    name, sec->name);				\
+    }									\
+  while (0)
+
       /* Opcode relocs are always big endian.  Data relocs are bi-endian.  */
       switch (r_type)
 	{
@@ -573,16 +606,19 @@
 	  WARN_REDHAT ("RX_RH_8_NEG");
 	  relocation = - relocation;
 	case R_RX_DIR8S_PCREL:
+	  UNSAFE_FOR_PID;
 	  RANGE (-128, 127);
 	  OP (0) = relocation;
 	  break;
 
 	case R_RX_DIR8S:
+	  UNSAFE_FOR_PID;
 	  RANGE (-128, 255);
 	  OP (0) = relocation;
 	  break;
 
 	case R_RX_DIR8U:
+	  UNSAFE_FOR_PID;
 	  RANGE (0, 255);
 	  OP (0) = relocation;
 	  break;
@@ -591,6 +627,7 @@
 	  WARN_REDHAT ("RX_RH_16_NEG");
 	  relocation = - relocation;
 	case R_RX_DIR16S_PCREL:
+	  UNSAFE_FOR_PID;
 	  RANGE (-32768, 32767);
 #if RX_OPCODE_BIG_ENDIAN
 #else
@@ -601,6 +638,7 @@
 
 	case R_RX_RH_16_OP:
 	  WARN_REDHAT ("RX_RH_16_OP");
+	  UNSAFE_FOR_PID;
 	  RANGE (-32768, 32767);
 #if RX_OPCODE_BIG_ENDIAN
 	  OP (1) = relocation;
@@ -612,6 +650,7 @@
 	  break;
 
 	case R_RX_DIR16S:
+	  UNSAFE_FOR_PID;
 	  RANGE (-32768, 65535);
 	  if (BIGE (output_bfd) && !(input_section->flags & SEC_CODE))
 	    {
@@ -626,6 +665,7 @@
 	  break;
 
 	case R_RX_DIR16U:
+	  UNSAFE_FOR_PID;
 	  RANGE (0, 65536);
 #if RX_OPCODE_BIG_ENDIAN
 	  OP (1) = relocation;
@@ -637,6 +677,7 @@
 	  break;
 
 	case R_RX_DIR16:
+	  UNSAFE_FOR_PID;
 	  RANGE (-32768, 65536);
 #if RX_OPCODE_BIG_ENDIAN
 	  OP (1) = relocation;
@@ -648,6 +689,7 @@
 	  break;
 
 	case R_RX_DIR16_REV:
+	  UNSAFE_FOR_PID;
 	  RANGE (-32768, 65536);
 #if RX_OPCODE_BIG_ENDIAN
 	  OP (0) = relocation;
@@ -665,6 +707,7 @@
 	  break;
 
 	case R_RX_RH_24_NEG:
+	  UNSAFE_FOR_PID;
 	  WARN_REDHAT ("RX_RH_24_NEG");
 	  relocation = - relocation;
 	case R_RX_DIR24S_PCREL:
@@ -681,6 +724,7 @@
 	  break;
 
 	case R_RX_RH_24_OP:
+	  UNSAFE_FOR_PID;
 	  WARN_REDHAT ("RX_RH_24_OP");
 	  RANGE (-0x800000, 0x7fffff);
 #if RX_OPCODE_BIG_ENDIAN
@@ -695,6 +739,7 @@
 	  break;
 
 	case R_RX_DIR24S:
+	  UNSAFE_FOR_PID;
 	  RANGE (-0x800000, 0x7fffff);
 	  if (BIGE (output_bfd) && !(input_section->flags & SEC_CODE))
 	    {
@@ -711,6 +756,7 @@
 	  break;
 
 	case R_RX_RH_24_UNS:
+	  UNSAFE_FOR_PID;
 	  WARN_REDHAT ("RX_RH_24_UNS");
 	  RANGE (0, 0xffffff);
 #if RX_OPCODE_BIG_ENDIAN
@@ -725,6 +771,7 @@
 	  break;
 
 	case R_RX_RH_32_NEG:
+	  UNSAFE_FOR_PID;
 	  WARN_REDHAT ("RX_RH_32_NEG");
 	  relocation = - relocation;
 #if RX_OPCODE_BIG_ENDIAN
@@ -741,6 +788,7 @@
 	  break;
 
 	case R_RX_RH_32_OP:
+	  UNSAFE_FOR_PID;
 	  WARN_REDHAT ("RX_RH_32_OP");
 #if RX_OPCODE_BIG_ENDIAN
 	  OP (3) = relocation;
@@ -920,6 +968,7 @@
 	  /* Complex reloc handling:  */
 
 	case R_RX_ABS32:
+	  UNSAFE_FOR_PID;
 	  RX_STACK_POP (relocation);
 #if RX_OPCODE_BIG_ENDIAN
 	  OP (3) = relocation;
@@ -935,6 +984,7 @@
 	  break;
 
 	case R_RX_ABS32_REV:
+	  UNSAFE_FOR_PID;
 	  RX_STACK_POP (relocation);
 #if RX_OPCODE_BIG_ENDIAN
 	  OP (0) = relocation;
@@ -951,6 +1001,7 @@
 
 	case R_RX_ABS24S_PCREL:
 	case R_RX_ABS24S:
+	  UNSAFE_FOR_PID;
 	  RX_STACK_POP (relocation);
 	  RANGE (-0x800000, 0x7fffff);
 	  if (BIGE (output_bfd) && !(input_section->flags & SEC_CODE))
@@ -968,6 +1019,7 @@
 	  break;
 
 	case R_RX_ABS16:
+	  UNSAFE_FOR_PID;
 	  RX_STACK_POP (relocation);
 	  RANGE (-32768, 65535);
 #if RX_OPCODE_BIG_ENDIAN
@@ -980,6 +1032,7 @@
 	  break;
 
 	case R_RX_ABS16_REV:
+	  UNSAFE_FOR_PID;
 	  RX_STACK_POP (relocation);
 	  RANGE (-32768, 65535);
 #if RX_OPCODE_BIG_ENDIAN
@@ -1008,6 +1061,7 @@
 	  break;
 
 	case R_RX_ABS16U:
+	  UNSAFE_FOR_PID;
 	  RX_STACK_POP (relocation);
 	  RANGE (0, 65536);
 #if RX_OPCODE_BIG_ENDIAN
@@ -1020,6 +1074,7 @@
 	  break;
 
 	case R_RX_ABS16UL:
+	  UNSAFE_FOR_PID;
 	  RX_STACK_POP (relocation);
 	  relocation >>= 2;
 	  RANGE (0, 65536);
@@ -1033,6 +1088,7 @@
 	  break;
 
 	case R_RX_ABS16UW:
+	  UNSAFE_FOR_PID;
 	  RX_STACK_POP (relocation);
 	  relocation >>= 1;
 	  RANGE (0, 65536);
@@ -1046,18 +1102,21 @@
 	  break;
 
 	case R_RX_ABS8:
+	  UNSAFE_FOR_PID;
 	  RX_STACK_POP (relocation);
 	  RANGE (-128, 255);
 	  OP (0) = relocation;
 	  break;
 
 	case R_RX_ABS8U:
+	  UNSAFE_FOR_PID;
 	  RX_STACK_POP (relocation);
 	  RANGE (0, 255);
 	  OP (0) = relocation;
 	  break;
 
 	case R_RX_ABS8UL:
+	  UNSAFE_FOR_PID;
 	  RX_STACK_POP (relocation);
 	  relocation >>= 2;
 	  RANGE (0, 255);
@@ -1065,14 +1124,16 @@
 	  break;
 
 	case R_RX_ABS8UW:
+	  UNSAFE_FOR_PID;
 	  RX_STACK_POP (relocation);
 	  relocation >>= 1;
 	  RANGE (0, 255);
 	  OP (0) = relocation;
 	  break;
 
-	case R_RX_ABS8S_PCREL:
 	case R_RX_ABS8S:
+	  UNSAFE_FOR_PID;
+	case R_RX_ABS8S_PCREL:
 	  RX_STACK_POP (relocation);
 	  RANGE (-128, 127);
 	  OP (0) = relocation;
@@ -1082,7 +1143,8 @@
 	  if (r_symndx < symtab_hdr->sh_info)
 	    RX_STACK_PUSH (sec->output_section->vma
 			   + sec->output_offset
-			   + sym->st_value);
+			   + sym->st_value
+			   + rel->r_addend);
 	  else
 	    {
 	      if (h != NULL
@@ -1090,7 +1152,8 @@
 		      || h->root.type == bfd_link_hash_defweak))
 		RX_STACK_PUSH (h->root.u.def.value
 			       + sec->output_section->vma
-			       + sec->output_offset);
+			       + sec->output_offset
+			       + rel->r_addend);
 	      else
 		_bfd_error_handler (_("Warning: RX_SYM reloc with an unknown symbol"));
 	    }
@@ -1100,6 +1163,7 @@
 	  {
 	    int32_t tmp;
 
+	    saw_subtract = TRUE;
 	    RX_STACK_POP (tmp);
 	    tmp = - tmp;
 	    RX_STACK_PUSH (tmp);
@@ -1121,6 +1185,7 @@
 	  {
 	    int32_t tmp1, tmp2;
 
+	    saw_subtract = TRUE;
 	    RX_STACK_POP (tmp1);
 	    RX_STACK_POP (tmp2);
 	    tmp2 -= tmp1;
@@ -1588,7 +1653,7 @@
 	  if (ssec)
 	    {
 	      if ((ssec->flags & SEC_MERGE)
-		  && ssec->sec_info_type == ELF_INFO_TYPE_MERGE)
+		  && ssec->sec_info_type == SEC_INFO_TYPE_MERGE)
 		symval = _bfd_merged_section_offset (abfd, & ssec,
 						     elf_section_data (ssec)->sec_info,
 						     symval);
@@ -1861,14 +1926,14 @@
       if (shndx_buf == NULL)
 	goto error_return;
       if (bfd_seek (abfd, shndx_hdr->sh_offset, SEEK_SET) != 0
-	  || bfd_bread ((PTR) shndx_buf, amt, abfd) != amt)
+	  || bfd_bread (shndx_buf, amt, abfd) != amt)
 	goto error_return;
       shndx_hdr->contents = (bfd_byte *) shndx_buf;
     }
 
   /* Get a copy of the native relocations.  */
   internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
 		      link_info->keep_memory));
   if (internal_relocs == NULL)
     goto error_return;
@@ -2050,7 +2115,7 @@
 		   /* Decodable bits.  */
 		   && (insn[0] & 0xcc) == 0xcc
 		   /* Width.  */
-		   && (insn[0] & 0x30) != 3
+		   && (insn[0] & 0x30) != 0x30
 		   /* Register MSBs.  */
 		   && (insn[1] & 0x88)  == 0x00)
 	    {
@@ -2154,7 +2219,7 @@
 		   /* Decodable bits.  */
 		   && (insn[0] & 0xc3) == 0xc3
 		   /* Width.  */
-		   && (insn[0] & 0x30) != 3
+		   && (insn[0] & 0x30) != 0x30
 		   /* Register MSBs.  */
 		   && (insn[1] & 0x88)  == 0x00)
 	    {
@@ -2872,6 +2937,39 @@
   ignore_lma = user_ignore_lma;
 }
 
+/* Converts FLAGS into a descriptive string.
+   Returns a static pointer.  */
+
+static const char *
+describe_flags (flagword flags)
+{
+  static char buf [128];
+
+  buf[0] = 0;
+
+  if (flags & E_FLAG_RX_64BIT_DOUBLES)
+    strcat (buf, "64-bit doubles");
+  else
+    strcat (buf, "32-bit doubles");
+
+  if (flags & E_FLAG_RX_DSP)
+    strcat (buf, ", dsp");
+  else
+    strcat (buf, ", no dsp");
+
+  if (flags & E_FLAG_RX_PID)
+    strcat (buf, ", pid");
+  else
+    strcat (buf, ", no pid");
+
+  if (flags & E_FLAG_RX_ABI)
+    strcat (buf, ", RX ABI");
+  else
+    strcat (buf, ", GCC ABI");
+
+  return buf;
+}
+
 /* Merge backend specific data from an object file to the output
    object file when linking.  */
 
@@ -2893,7 +2991,10 @@
     }
   else if (old_flags != new_flags)
     {
-      flagword known_flags = E_FLAG_RX_64BIT_DOUBLES | E_FLAG_RX_DSP;
+      flagword known_flags;
+
+      known_flags = E_FLAG_RX_ABI | E_FLAG_RX_64BIT_DOUBLES
+	| E_FLAG_RX_DSP | E_FLAG_RX_PID;
 
       if ((old_flags ^ new_flags) & known_flags)
 	{
@@ -2906,9 +3007,12 @@
 	    }
 	  else
 	    {
-	      (*_bfd_error_handler)
-		("ELF header flags mismatch: old_flags = 0x%.8lx, new_flags = 0x%.8lx, filename = %s",
-		 old_flags, new_flags, bfd_get_filename (ibfd));
+	      _bfd_error_handler ("There is a conflict merging the ELF header flags from %s",
+				  bfd_get_filename (ibfd));
+	      _bfd_error_handler ("  the input  file's flags: %s",
+				  describe_flags (new_flags));
+	      _bfd_error_handler ("  the output file's flags: %s",
+				  describe_flags (old_flags));
 	      error = TRUE;
 	    }
 	}
@@ -2936,21 +3040,20 @@
   flags = elf_elfheader (abfd)->e_flags;
   fprintf (file, _("private flags = 0x%lx:"), (long) flags);
 
-  if (flags & E_FLAG_RX_64BIT_DOUBLES)
-    fprintf (file, _(" [64-bit doubles]"));
-  if (flags & E_FLAG_RX_DSP)
-    fprintf (file, _(" [dsp]"));
-
-  fputc ('\n', file);
+  fprintf (file, "%s", describe_flags (flags));
   return TRUE;
 }
 
 /* Return the MACH for an e_flags value.  */
 
 static int
-elf32_rx_machine (bfd * abfd)
+elf32_rx_machine (bfd * abfd ATTRIBUTE_UNUSED)
 {
+#if 0 /* FIXME: EF_RX_CPU_MASK collides with E_FLAG_RX_...
+	 Need to sort out how these flag bits are used.
+         For now we assume that the flags are OK.  */
   if ((elf_elfheader (abfd)->e_flags & EF_RX_CPU_MASK) == EF_RX_CPU_RX)
+#endif
     return bfd_mach_rx;
 
   return 0;
@@ -2964,6 +3067,7 @@
   Elf_Internal_Phdr *phdr = elf_tdata (abfd)->phdr;
   int nphdrs = elf_elfheader (abfd)->e_phnum;
   sec_ptr bsec;
+  static int saw_be = FALSE;
 
   /* We never want to automatically choose the non-swapping big-endian
      target.  The user can only get that explicitly, such as with -I
@@ -2972,6 +3076,15 @@
       && abfd->target_defaulted)
     return FALSE;
 
+  /* BFD->target_defaulted is not set to TRUE when a target is chosen
+     as a fallback, so we check for "scanning" to know when to stop
+     using the non-swapping target.  */
+  if (abfd->xvec == &bfd_elf32_rx_be_ns_vec
+      && saw_be)
+    return FALSE;
+  if (abfd->xvec == &bfd_elf32_rx_be_vec)
+    saw_be = TRUE;
+
   bfd_default_set_arch_mach (abfd, bfd_arch_rx,
 			     elf32_rx_machine (abfd));
 
@@ -2985,7 +3098,8 @@
 	{
 	  Elf_Internal_Shdr *sec = elf_tdata(abfd)->elf_sect_ptr[u];
 
-	  if (phdr[i].p_offset <= (bfd_vma) sec->sh_offset
+	  if (phdr[i].p_filesz
+	      && phdr[i].p_offset <= (bfd_vma) sec->sh_offset
 	      && (bfd_vma)sec->sh_offset <= phdr[i].p_offset + (phdr[i].p_filesz - 1))
 	    {
 	      /* Found one!  The difference between the two addresses,
@@ -3009,7 +3123,8 @@
       bsec = abfd->sections;
       while (bsec)
 	{
-	  if (phdr[i].p_vaddr <= bsec->lma
+	  if (phdr[i].p_filesz
+	      && phdr[i].p_vaddr <= bsec->vma
 	      && bsec->vma <= phdr[i].p_vaddr + (phdr[i].p_filesz - 1))
 	    {
 	      bsec->lma = phdr[i].p_paddr + (bsec->vma - phdr[i].p_vaddr);
@@ -3395,7 +3510,7 @@
   bed = get_elf_backend_data (abfd);
   tdata = elf_tdata (abfd);
   phdr = tdata->phdr;
-  count = tdata->program_header_size / bed->s->sizeof_phdr;
+  count = elf_program_header_size (abfd) / bed->s->sizeof_phdr;
 
   if (ignore_lma)
     for (i = count; i-- != 0;)
@@ -3418,6 +3533,17 @@
 
   return TRUE;
 }
+
+/* The default literal sections should always be marked as "code" (i.e.,
+   SHF_EXECINSTR).  This is particularly important for big-endian mode
+   when we do not want their contents byte reversed.  */
+static const struct bfd_elf_special_section elf32_rx_special_sections[] =
+{
+  { STRING_COMMA_LEN (".init_array"),    0, SHT_INIT_ARRAY, SHF_ALLOC + SHF_EXECINSTR },
+  { STRING_COMMA_LEN (".fini_array"),    0, SHT_FINI_ARRAY, SHF_ALLOC + SHF_EXECINSTR },
+  { STRING_COMMA_LEN (".preinit_array"), 0, SHT_PREINIT_ARRAY, SHF_ALLOC + SHF_EXECINSTR },
+  { NULL,                        0,      0, 0,            0 }
+};
 
 #define ELF_ARCH		bfd_arch_rx
 #define ELF_MACHINE_CODE	EM_RX
@@ -3446,6 +3572,7 @@
 #define bfd_elf32_set_section_contents		rx_set_section_contents
 #define bfd_elf32_bfd_final_link		rx_final_link
 #define bfd_elf32_bfd_relax_section		elf32_rx_relax_section_wrapper
+#define elf_backend_special_sections	        elf32_rx_special_sections
 
 #include "elf32-target.h"
 
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index 98437d0..6467b03 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -1,6 +1,6 @@
 /* IBM S/390-specific support for 32-bit ELF
    Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-   2011 Free Software Foundation, Inc.
+   2011, 2012 Free Software Foundation, Inc.
    Contributed by Carl B. Pedersen and Martin Schwidefsky.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -25,74 +25,22 @@
 #include "bfdlink.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
-
-static reloc_howto_type *elf_s390_reloc_type_lookup
-  PARAMS ((bfd *, bfd_reloc_code_real_type));
-static void elf_s390_info_to_howto
-  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
-static bfd_boolean elf_s390_is_local_label_name
-  PARAMS ((bfd *, const char *));
-static struct bfd_hash_entry *link_hash_newfunc
-  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static struct bfd_link_hash_table *elf_s390_link_hash_table_create
-  PARAMS ((bfd *));
-static bfd_boolean create_got_section
-  PARAMS((bfd *, struct bfd_link_info *));
-static bfd_boolean elf_s390_create_dynamic_sections
-  PARAMS((bfd *, struct bfd_link_info *));
-static void elf_s390_copy_indirect_symbol
-  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *,
-	   struct elf_link_hash_entry *));
-static bfd_boolean elf_s390_check_relocs
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-	   const Elf_Internal_Rela *));
-struct elf_s390_link_hash_entry;
-static void elf_s390_adjust_gotplt
-  PARAMS ((struct elf_s390_link_hash_entry *));
-static bfd_boolean elf_s390_adjust_dynamic_symbol
-  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
-static bfd_boolean allocate_dynrelocs
-  PARAMS ((struct elf_link_hash_entry *, PTR));
-static bfd_boolean readonly_dynrelocs
-  PARAMS ((struct elf_link_hash_entry *, PTR));
-static bfd_boolean elf_s390_size_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-static bfd_boolean elf_s390_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
-	   Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
-static bfd_boolean elf_s390_finish_dynamic_symbol
-  PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
-	   Elf_Internal_Sym *));
-static enum elf_reloc_type_class elf_s390_reloc_type_class
-  PARAMS ((const Elf_Internal_Rela *));
-static bfd_boolean elf_s390_finish_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-static bfd_boolean elf_s390_object_p
-  PARAMS ((bfd *));
-static bfd_boolean elf_s390_grok_prstatus
-  PARAMS ((bfd *, Elf_Internal_Note *));
-static int elf_s390_tls_transition
-  PARAMS ((struct bfd_link_info *, int, int));
-static bfd_reloc_status_type s390_tls_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static bfd_vma dtpoff_base
-  PARAMS ((struct bfd_link_info *));
-static bfd_vma tpoff
-  PARAMS ((struct bfd_link_info *, bfd_vma));
-static void invalid_tls_insn
-  PARAMS ((bfd *, asection *, Elf_Internal_Rela *));
-static bfd_reloc_status_type s390_elf_ldisp_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-
 #include "elf/s390.h"
 
+static bfd_reloc_status_type
+s390_tls_reloc (bfd *, arelent *, asymbol *, void *,
+		asection *, bfd *, char **);
+static bfd_reloc_status_type
+s390_elf_ldisp_reloc (bfd *, arelent *, asymbol *, void *,
+		      asection *, bfd *, char **);
+
 /* The relocation "howto" table.  */
 
 static reloc_howto_type elf_howto_table[] =
 {
   HOWTO (R_390_NONE,		/* type */
 	 0,			/* rightshift */
-	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 0,			/* size (0 = byte, 1 = 2 byte, 2 = 4 byte) */
 	 0,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
@@ -211,6 +159,16 @@
 	s390_elf_ldisp_reloc, "R_390_GOTPLT20", FALSE, 0,0x0fffff00, FALSE),
   HOWTO(R_390_TLS_GOTIE20, 0, 2, 20, FALSE, 8, complain_overflow_dont,
 	s390_elf_ldisp_reloc, "R_390_TLS_GOTIE20", FALSE, 0,0x0fffff00, FALSE),
+  HOWTO(R_390_IRELATIVE, 0, 2, 32, TRUE, 0, complain_overflow_bitfield,
+	bfd_elf_generic_reloc, "R_390_IRELATIVE", FALSE, 0, 0xffffffff, FALSE),
+  HOWTO(R_390_PC12DBL,   1, 1, 12,  TRUE, 0, complain_overflow_bitfield,
+	bfd_elf_generic_reloc, "R_390_PC12DBL",  FALSE, 0,0x00000fff, TRUE),
+  HOWTO(R_390_PLT12DBL,	 1, 1, 12,  TRUE, 0, complain_overflow_bitfield,
+	bfd_elf_generic_reloc, "R_390_PLT12DBL", FALSE, 0,0x00000fff, TRUE),
+  HOWTO(R_390_PC24DBL,   1, 2, 24,  TRUE, 0, complain_overflow_bitfield,
+	bfd_elf_generic_reloc, "R_390_PC24DBL",  FALSE, 0,0x00ffffff, TRUE),
+  HOWTO(R_390_PLT24DBL,	 1, 2, 24,  TRUE, 0, complain_overflow_bitfield,
+	bfd_elf_generic_reloc, "R_390_PLT24DBL", FALSE, 0,0x00ffffff, TRUE),
 };
 
 /* GNU extension to record C++ vtable hierarchy.  */
@@ -220,9 +178,8 @@
   HOWTO (R_390_GNU_VTENTRY, 0,2,0,FALSE,0,complain_overflow_dont, _bfd_elf_rel_vtable_reloc_fn,"R_390_GNU_VTENTRY", FALSE,0,0, FALSE);
 
 static reloc_howto_type *
-elf_s390_reloc_type_lookup (abfd, code)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+elf_s390_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+			    bfd_reloc_code_real_type code)
 {
   switch (code)
     {
@@ -262,10 +219,18 @@
       return &elf_howto_table[(int) R_390_GOT16];
     case BFD_RELOC_16_PCREL:
       return &elf_howto_table[(int) R_390_PC16];
+    case BFD_RELOC_390_PC12DBL:
+      return &elf_howto_table[(int) R_390_PC12DBL];
+    case BFD_RELOC_390_PLT12DBL:
+      return &elf_howto_table[(int) R_390_PLT12DBL];
     case BFD_RELOC_390_PC16DBL:
       return &elf_howto_table[(int) R_390_PC16DBL];
     case BFD_RELOC_390_PLT16DBL:
       return &elf_howto_table[(int) R_390_PLT16DBL];
+    case BFD_RELOC_390_PC24DBL:
+      return &elf_howto_table[(int) R_390_PC24DBL];
+    case BFD_RELOC_390_PLT24DBL:
+      return &elf_howto_table[(int) R_390_PLT24DBL];
     case BFD_RELOC_390_PC32DBL:
       return &elf_howto_table[(int) R_390_PC32DBL];
     case BFD_RELOC_390_PLT32DBL:
@@ -324,6 +289,8 @@
       return &elf_howto_table[(int) R_390_GOTPLT20];
     case BFD_RELOC_390_TLS_GOTIE20:
       return &elf_howto_table[(int) R_390_TLS_GOTIE20];
+    case BFD_RELOC_390_IRELATIVE:
+      return &elf_howto_table[(int) R_390_IRELATIVE];
     case BFD_RELOC_VTABLE_INHERIT:
       return &elf32_s390_vtinherit_howto;
     case BFD_RELOC_VTABLE_ENTRY:
@@ -357,10 +324,9 @@
    and elf32-s390.c has its own copy.  */
 
 static void
-elf_s390_info_to_howto (abfd, cache_ptr, dst)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *cache_ptr;
-     Elf_Internal_Rela *dst;
+elf_s390_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+			arelent *cache_ptr,
+			Elf_Internal_Rela *dst)
 {
   unsigned int r_type = ELF32_R_TYPE(dst->r_info);
   switch (r_type)
@@ -386,15 +352,13 @@
 
 /* A relocation function which doesn't do anything.  */
 static bfd_reloc_status_type
-s390_tls_reloc (abfd, reloc_entry, symbol, data, input_section,
-		output_bfd, error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc_entry;
-     asymbol *symbol ATTRIBUTE_UNUSED;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+s390_tls_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+		arelent *reloc_entry,
+		asymbol *symbol ATTRIBUTE_UNUSED,
+		void * data ATTRIBUTE_UNUSED,
+		asection *input_section,
+		bfd *output_bfd,
+		char **error_message ATTRIBUTE_UNUSED)
 {
   if (output_bfd)
     reloc_entry->address += input_section->output_offset;
@@ -403,20 +367,18 @@
 
 /* Handle the large displacement relocs.  */
 static bfd_reloc_status_type
-s390_elf_ldisp_reloc (abfd, reloc_entry, symbol, data, input_section,
-                      output_bfd, error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc_entry;
-     asymbol *symbol;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+s390_elf_ldisp_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+		      arelent *reloc_entry,
+		      asymbol *symbol,
+		      void * data ATTRIBUTE_UNUSED,
+		      asection *input_section,
+		      bfd *output_bfd,
+		      char **error_message ATTRIBUTE_UNUSED)
 {
   reloc_howto_type *howto = reloc_entry->howto;
   bfd_vma relocation;
   bfd_vma insn;
-  
+
   if (output_bfd != (bfd *) NULL
       && (symbol->flags & BSF_SECTION_SYM) == 0
       && (! howto->partial_inplace
@@ -425,13 +387,13 @@
       reloc_entry->address += input_section->output_offset;
       return bfd_reloc_ok;
     }
-  
+
   if (output_bfd != NULL)
     return bfd_reloc_continue;
-  
+
   if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
     return bfd_reloc_outofrange;
-  
+
   relocation = (symbol->value
 		+ symbol->section->output_section->vma
 		+ symbol->section->output_offset);
@@ -442,11 +404,11 @@
 		     + input_section->output_offset);
       relocation -= reloc_entry->address;
     }
-  
+
   insn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
   insn |= (relocation & 0xfff) << 16 | (relocation & 0xff000) >> 4;
   bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
-  
+
   if ((bfd_signed_vma) relocation < - 0x80000
       || (bfd_signed_vma) relocation > 0x7ffff)
     return bfd_reloc_overflow;
@@ -455,9 +417,7 @@
 }
 
 static bfd_boolean
-elf_s390_is_local_label_name (abfd, name)
-     bfd *abfd;
-     const char *name;
+elf_s390_is_local_label_name (bfd *abfd, const char *name)
 {
   if (name[0] == '.' && (name[1] == 'X' || name[1] == 'L'))
     return TRUE;
@@ -470,7 +430,7 @@
 /* The name of the dynamic interpreter.  This is put in the .interp
    section.  */
 
-#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
+#define ELF_DYNAMIC_INTERPRETER "/lib/ld.so.1"
 
 /* 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
@@ -485,6 +445,8 @@
 
 #define GOT_ENTRY_SIZE 4
 
+#define RELA_ENTRY_SIZE sizeof (Elf32_External_Rela)
+
 /* The first three entries in a procedure linkage table are reserved,
    and the initial contents are unimportant (we zero them out).
    Subsequent entries look like this.  See the SVR4 ABI 386
@@ -509,7 +471,7 @@
    The GOT holds the address in the PLT to be executed.
    The loader then gets:
    24(15) =  Pointer to the structure describing the object.
-   28(15) =  Offset in symbol table
+   28(15) =  Offset into rela.plt
 
    The loader  must  then find the module where the function is
    and insert the address in the GOT.
@@ -527,7 +489,7 @@
       BRC  15,-x       # 4 bytes  Jump to start of PLT
       .word 0          # 2 bytes filler
       .long ?          # 4 bytes  offset in GOT
-      .long ?          # 4 bytes  offset into symbol table
+      .long ?          # 4 bytes  offset into rela.plt
 
   This was the general case. There are two additional, optimizes PLT
   definitions. One for GOT offsets < 4096 and one for GOT offsets < 32768.
@@ -537,10 +499,10 @@
       BCR  15,1           # 2 bytes  Jump to address
       .word 0,0,0         # 6 bytes  filler
 RET1: BASR 1,0            # 2 bytes  Return from GOT 1st time
-      L    1,14(1)        # 4 bytes  Load offset in symbol table in r1
+      L    1,14(1)        # 4 bytes  Load offset in rela.plt in r1
       BRC  15,-x          # 4 bytes  Jump to start of PLT
       .word 0,0,0         # 6 bytes  filler
-      .long ?             # 4 bytes  offset into symbol table
+      .long ?             # 4 bytes  offset into rela.plt
 
   Second the one for GOT offsets < 32768:
 
@@ -549,10 +511,10 @@
       BCR  15,1           # 2 bytes  Jump to address
       .word 0             # 2 bytes  filler
 RET1: BASR 1,0            # 2 bytes  Return from GOT 1st time
-      L    1,14(1)        # 4 bytes  Load offset in symbol table in r1
+      L    1,14(1)        # 4 bytes  Load offset in rela.plt in r1
       BRC  15,-x          # 4 bytes  Jump to start of PLT
       .word 0,0,0         # 6 bytes  filler
-      .long ?             # 4 bytes  offset into symbol table
+      .long ?             # 4 bytes  offset into rela.plt
 
 Total = 32 bytes per PLT entry
 
@@ -567,40 +529,76 @@
       BRC  15,-x       # 4 bytes  Jump to start of PLT
       .word 0          # 2 bytes  filler
       .long ?          # 4 bytes  address of GOT entry
-      .long ?          # 4 bytes  offset into symbol table  */
+      .long ?          # 4 bytes  offset into rela.plt  */
 
-#define PLT_PIC_ENTRY_WORD0 0x0d105810
-#define PLT_PIC_ENTRY_WORD1 0x10165811
-#define PLT_PIC_ENTRY_WORD2 0xc00007f1
-#define PLT_PIC_ENTRY_WORD3 0x0d105810
-#define PLT_PIC_ENTRY_WORD4 0x100ea7f4
+static const bfd_byte elf_s390_plt_entry[PLT_ENTRY_SIZE] =
+  {
+    0x0d, 0x10,                             /* basr    %r1,%r0     */
+    0x58, 0x10, 0x10, 0x16,                 /* l       %r1,22(%r1) */
+    0x58, 0x10, 0x10, 0x00,                 /* l       %r1,0(%r1)  */
+    0x07, 0xf1,                             /* br      %r1         */
+    0x0d, 0x10,                             /* basr    %r1,%r0     */
+    0x58, 0x10, 0x10, 0x0e,                 /* l       %r1,14(%r1) */
+    0xa7, 0xf4, 0x00, 0x00,                 /* j       first plt   */
+    0x00, 0x00,                             /* padding             */
+    0x00, 0x00, 0x00, 0x00,                 /* GOT offset          */
+    0x00, 0x00, 0x00, 0x00                  /* rela.plt offset     */
+  };
 
-#define PLT_PIC12_ENTRY_WORD0 0x5810c000
-#define PLT_PIC12_ENTRY_WORD1 0x07f10000
-#define PLT_PIC12_ENTRY_WORD2 0x00000000
-#define PLT_PIC12_ENTRY_WORD3 0x0d105810
-#define PLT_PIC12_ENTRY_WORD4 0x100ea7f4
+/* Generic PLT pic entry.  */
+static const bfd_byte elf_s390_plt_pic_entry[PLT_ENTRY_SIZE] =
+  {
+    0x0d, 0x10,                             /* basr    %r1,%r0         */
+    0x58, 0x10, 0x10, 0x16,                 /* l       %r1,22(%r1)     */
+    0x58, 0x11, 0xc0, 0x00,                 /* l       %r1,0(%r1,%r12) */
+    0x07, 0xf1,                             /* br      %r1             */
+    0x0d, 0x10,                             /* basr    %r1,%r0         */
+    0x58, 0x10, 0x10, 0x0e,                 /* l       %r1,14(%r1)     */
+    0xa7, 0xf4, 0x00, 0x00,                 /* j       first plt       */
+    0x00, 0x00,                             /* padding                 */
+    0x00, 0x00, 0x00, 0x00,                 /* GOT offset              */
+    0x00, 0x00, 0x00, 0x00                  /* rela.plt offset         */
+  };
 
-#define PLT_PIC16_ENTRY_WORD0 0xa7180000
-#define PLT_PIC16_ENTRY_WORD1 0x5811c000
-#define PLT_PIC16_ENTRY_WORD2 0x07f10000
-#define PLT_PIC16_ENTRY_WORD3 0x0d105810
-#define PLT_PIC16_ENTRY_WORD4 0x100ea7f4
+/* Optimized PLT pic entry for GOT offset < 4k.  xx will be replaced
+   when generating the PLT slot with the GOT offset.  */
+static const bfd_byte elf_s390_plt_pic12_entry[PLT_ENTRY_SIZE] =
+  {
+    0x58, 0x10, 0xc0, 0x00,                 /* l       %r1,xx(%r12) */
+    0x07, 0xf1,                             /* br      %r1          */
+    0x00, 0x00, 0x00, 0x00,                 /* padding              */
+    0x00, 0x00,
+    0x0d, 0x10,                             /* basr    %r1,%r0      */
+    0x58, 0x10, 0x10, 0x0e,                 /* l       %r1,14(%r1)  */
+    0xa7, 0xf4, 0x00, 0x00,                 /* j       first plt    */
+    0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00
+  };
 
-#define PLT_ENTRY_WORD0     0x0d105810
-#define PLT_ENTRY_WORD1     0x10165810
-#define PLT_ENTRY_WORD2     0x100007f1
-#define PLT_ENTRY_WORD3     0x0d105810
-#define PLT_ENTRY_WORD4     0x100ea7f4
+/* Optimized PLT pic entry for GOT offset < 32k.  xx will be replaced
+   when generating the PLT slot with the GOT offset.  */
+static const bfd_byte elf_s390_plt_pic16_entry[PLT_ENTRY_SIZE] =
+  {
+    0xa7, 0x18, 0x00, 0x00,                 /* lhi     %r1,xx          */
+    0x58, 0x11, 0xc0, 0x00,                 /* l       %r1,0(%r1,%r12) */
+    0x07, 0xf1,                             /* br      %r1             */
+    0x00, 0x00,
+    0x0d, 0x10,                             /* basr    %r1,%r0         */
+    0x58, 0x10, 0x10, 0x0e,                 /* l       %r1,14(%r1)     */
+    0xa7, 0xf4, 0x00, 0x00,                 /* j       first plt       */
+    0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00
+  };
 
-/* The first PLT entry pushes the offset into the symbol table
+/* The first PLT entry pushes the offset into the rela.plt
    from R1 onto the stack at 8(15) and the loader object info
    at 12(15), loads the loader address in R1 and jumps to it.  */
 
 /* The first entry in the PLT for PIC code:
 
 PLT0:
-   ST   1,28(15)  # R1 has offset into symbol table
+   ST   1,28(15)  # R1 has offset into rela.plt
    L    1,4(12)   # Get loader ino(object struct address)
    ST   1,24(15)  # Store address
    L    1,8(12)   # Entry address of loader in R1
@@ -609,7 +607,7 @@
    The first entry in the PLT for static code:
 
 PLT0:
-   ST   1,28(15)      # R1 has offset into symbol table
+   ST   1,28(15)      # R1 has offset into rela.plt
    BASR 1,0
    L    1,18(0,1)     # Get address of GOT
    MVC  24(4,15),4(1) # Move loader ino to stack
@@ -618,38 +616,32 @@
    .word 0            # filler
    .long got          # address of GOT  */
 
-#define PLT_PIC_FIRST_ENTRY_WORD0 0x5010f01c
-#define PLT_PIC_FIRST_ENTRY_WORD1 0x5810c004
-#define PLT_PIC_FIRST_ENTRY_WORD2 0x5010f018
-#define PLT_PIC_FIRST_ENTRY_WORD3 0x5810c008
-#define PLT_PIC_FIRST_ENTRY_WORD4 0x07f10000
+static const bfd_byte elf_s390_plt_first_entry[PLT_FIRST_ENTRY_SIZE] =
+  {
+    0x50, 0x10, 0xf0, 0x1c,                   /* st      %r1,28(%r15)      */
+    0x0d, 0x10,                               /* basr    %r1,%r0           */
+    0x58, 0x10, 0x10, 0x12,                   /* l       %r1,18(%r1)       */
+    0xd2, 0x03, 0xf0, 0x18, 0x10, 0x04,       /* mvc     24(4,%r15),4(%r1) */
+    0x58, 0x10, 0x10, 0x08,                   /* l       %r1,8(%r1)        */
+    0x07, 0xf1,                               /* br      %r1               */
+    0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00
+  };
 
-#define PLT_FIRST_ENTRY_WORD0     0x5010f01c
-#define PLT_FIRST_ENTRY_WORD1     0x0d105810
-#define PLT_FIRST_ENTRY_WORD2     0x1012D203
-#define PLT_FIRST_ENTRY_WORD3     0xf0181004
-#define PLT_FIRST_ENTRY_WORD4     0x58101008
-#define PLT_FIRST_ENTRY_WORD5     0x07f10000
+static const bfd_byte elf_s390_plt_pic_first_entry[PLT_FIRST_ENTRY_SIZE] =
+  {
+    0x50, 0x10, 0xf0, 0x1c,                     /* st      %r1,28(%r15)  */
+    0x58, 0x10, 0xc0, 0x04,                     /* l       %r1,4(%r12)   */
+    0x50, 0x10, 0xf0, 0x18,                     /* st      %r1,24(%r15)  */
+    0x58, 0x10, 0xc0, 0x08,                     /* l       %r1,8(%r12)   */
+    0x07, 0xf1,                                 /* br      %r1           */
+    0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00
+  };
 
-/* The s390 linker needs to keep track of the number of relocs that it
-   decides to copy as dynamic relocs in check_relocs for each symbol.
-   This is so that it can later discard them if they are found to be
-   unnecessary.  We store the information in a field extending the
-   regular ELF linker hash table.  */
-
-struct elf_s390_dyn_relocs
-{
-  struct elf_s390_dyn_relocs *next;
-
-  /* The input section of the reloc.  */
-  asection *sec;
-
-  /* Total number of relocs copied for the input section.  */
-  bfd_size_type count;
-
-  /* Number of pc-relative relocs copied for the input section.  */
-  bfd_size_type pc_count;
-};
 
 /* s390 ELF linker hash entry.  */
 
@@ -658,7 +650,7 @@
   struct elf_link_hash_entry elf;
 
   /* Track dynamic relocs copied for this symbol.  */
-  struct elf_s390_dyn_relocs *dyn_relocs;
+  struct elf_dyn_relocs *dyn_relocs;
 
   /* Number of GOTPLT references for a function.  */
   bfd_signed_vma gotplt_refcount;
@@ -669,17 +661,43 @@
 #define GOT_TLS_IE	3
 #define GOT_TLS_IE_NLT	4
   unsigned char tls_type;
+
+  /* For pointer equality reasons we might need to change the symbol
+     type from STT_GNU_IFUNC to STT_FUNC together with its value and
+     section entry.  So after alloc_dynrelocs only these values should
+     be used.  In order to check whether a symbol is IFUNC use
+     s390_is_ifunc_symbol_p.  */
+  bfd_vma ifunc_resolver_address;
+  asection *ifunc_resolver_section;
 };
 
 #define elf_s390_hash_entry(ent) \
   ((struct elf_s390_link_hash_entry *)(ent))
 
+/* This structure represents an entry in the local PLT list needed for
+   local IFUNC symbols.  */
+struct plt_entry
+{
+  /* The section of the local symbol.
+     Set in relocate_section and used in finish_dynamic_sections.  */
+  asection *sec;
+
+  union
+  {
+    bfd_signed_vma refcount;
+    bfd_vma offset;
+  } plt;
+};
+
 /* NOTE: Keep this structure in sync with
    the one declared in elf64-s390.c.  */
 struct elf_s390_obj_tdata
 {
   struct elf_obj_tdata root;
 
+  /* A local PLT is needed for ifunc symbols.  */
+  struct plt_entry *local_plt;
+
   /* TLS type for each local got entry.  */
   char *local_got_tls_type;
 };
@@ -687,6 +705,9 @@
 #define elf_s390_tdata(abfd) \
   ((struct elf_s390_obj_tdata *) (abfd)->tdata.any)
 
+#define elf_s390_local_plt(abfd)		\
+  (elf_s390_tdata (abfd)->local_plt)
+
 #define elf_s390_local_got_tls_type(abfd) \
   (elf_s390_tdata (abfd)->local_got_tls_type)
 
@@ -703,8 +724,7 @@
 }
 
 static bfd_boolean
-elf_s390_object_p (abfd)
-     bfd *abfd;
+elf_s390_object_p (bfd *abfd)
 {
   /* Set the right machine number for an s390 elf32 file.  */
   return bfd_default_set_arch_mach (abfd, bfd_arch_s390, bfd_mach_s390_31);
@@ -717,15 +737,12 @@
   struct elf_link_hash_table elf;
 
   /* Short-cuts to get to dynamic linker sections.  */
-  asection *sgot;
-  asection *sgotplt;
-  asection *srelgot;
-  asection *splt;
-  asection *srelplt;
   asection *sdynbss;
   asection *srelbss;
+  asection *irelifunc;
 
-  union {
+  union
+  {
     bfd_signed_vma refcount;
     bfd_vma offset;
   } tls_ldm_got;
@@ -740,13 +757,15 @@
   (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
   == S390_ELF_DATA ? ((struct elf_s390_link_hash_table *) ((p)->hash)) : NULL)
 
+#undef ELF64
+#include "elf-s390-common.c"
+
 /* Create an entry in an s390 ELF linker hash table.  */
 
 static struct bfd_hash_entry *
-link_hash_newfunc (entry, table, string)
-     struct bfd_hash_entry *entry;
-     struct bfd_hash_table *table;
-     const char *string;
+link_hash_newfunc (struct bfd_hash_entry *entry,
+		   struct bfd_hash_table *table,
+		   const char *string)
 {
   /* Allocate the structure if it has not already been allocated by a
      subclass.  */
@@ -768,6 +787,8 @@
       eh->dyn_relocs = NULL;
       eh->gotplt_refcount = 0;
       eh->tls_type = GOT_UNKNOWN;
+      eh->ifunc_resolver_address = 0;
+      eh->ifunc_resolver_section = NULL;
     }
 
   return entry;
@@ -776,13 +797,12 @@
 /* Create an s390 ELF linker hash table.  */
 
 static struct bfd_link_hash_table *
-elf_s390_link_hash_table_create (abfd)
-     bfd *abfd;
+elf_s390_link_hash_table_create (bfd *abfd)
 {
   struct elf_s390_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_s390_link_hash_table);
 
-  ret = (struct elf_s390_link_hash_table *) bfd_malloc (amt);
+  ret = (struct elf_s390_link_hash_table *) bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
 
@@ -794,16 +814,6 @@
       return NULL;
     }
 
-  ret->sgot = NULL;
-  ret->sgotplt = NULL;
-  ret->srelgot = NULL;
-  ret->splt = NULL;
-  ret->srelplt = NULL;
-  ret->sdynbss = NULL;
-  ret->srelbss = NULL;
-  ret->tls_ldm_got.refcount = 0;
-  ret->sym_cache.abfd = NULL;
-
   return &ret->elf.root;
 }
 
@@ -811,9 +821,7 @@
    shortcuts to them in our hash table.  */
 
 static bfd_boolean
-create_got_section (dynobj, info)
-     bfd *dynobj;
-     struct bfd_link_info *info;
+create_got_section (bfd *dynobj, struct bfd_link_info *info)
 {
   struct elf_s390_link_hash_table *htab;
 
@@ -821,10 +829,10 @@
     return FALSE;
 
   htab = elf_s390_hash_table (info);
-  htab->sgot = bfd_get_section_by_name (dynobj, ".got");
-  htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
-  htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
-  if (!htab->sgot || !htab->sgotplt || !htab->srelgot)
+  htab->elf.sgot = bfd_get_linker_section (dynobj, ".got");
+  htab->elf.sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
+  htab->elf.srelgot = bfd_get_linker_section (dynobj, ".rela.got");
+  if (!htab->elf.sgot || !htab->elf.sgotplt || !htab->elf.srelgot)
     abort ();
 
   return TRUE;
@@ -835,26 +843,24 @@
    hash table.  */
 
 static bfd_boolean
-elf_s390_create_dynamic_sections (dynobj, info)
-     bfd *dynobj;
-     struct bfd_link_info *info;
+elf_s390_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info)
 {
   struct elf_s390_link_hash_table *htab;
 
   htab = elf_s390_hash_table (info);
-  if (!htab->sgot && !create_got_section (dynobj, info))
+  if (!htab->elf.sgot && !create_got_section (dynobj, info))
     return FALSE;
 
   if (!_bfd_elf_create_dynamic_sections (dynobj, info))
     return FALSE;
 
-  htab->splt = bfd_get_section_by_name (dynobj, ".plt");
-  htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt");
-  htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
+  htab->elf.splt = bfd_get_linker_section (dynobj, ".plt");
+  htab->elf.srelplt = bfd_get_linker_section (dynobj, ".rela.plt");
+  htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
   if (!info->shared)
-    htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
+    htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
 
-  if (!htab->splt || !htab->srelplt || !htab->sdynbss
+  if (!htab->elf.splt || !htab->elf.srelplt || !htab->sdynbss
       || (!info->shared && !htab->srelbss))
     abort ();
 
@@ -864,9 +870,9 @@
 /* Copy the extra info we tack onto an elf_link_hash_entry.  */
 
 static void
-elf_s390_copy_indirect_symbol (info, dir, ind)
-     struct bfd_link_info *info;
-     struct elf_link_hash_entry *dir, *ind;
+elf_s390_copy_indirect_symbol (struct bfd_link_info *info,
+			       struct elf_link_hash_entry *dir,
+			       struct elf_link_hash_entry *ind)
 {
   struct elf_s390_link_hash_entry *edir, *eind;
 
@@ -877,14 +883,14 @@
     {
       if (edir->dyn_relocs != NULL)
 	{
-	  struct elf_s390_dyn_relocs **pp;
-	  struct elf_s390_dyn_relocs *p;
+	  struct elf_dyn_relocs **pp;
+	  struct elf_dyn_relocs *p;
 
 	  /* Add reloc counts against the indirect sym to the direct sym
 	     list.  Merge any entries against the same section.  */
 	  for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
 	    {
-	      struct elf_s390_dyn_relocs *q;
+	      struct elf_dyn_relocs *q;
 
 	      for (q = edir->dyn_relocs; q != NULL; q = q->next)
 		if (q->sec == p->sec)
@@ -928,10 +934,9 @@
 }
 
 static int
-elf_s390_tls_transition (info, r_type, is_local)
-     struct bfd_link_info *info;
-     int r_type;
-     int is_local;
+elf_s390_tls_transition (struct bfd_link_info *info,
+			 int r_type,
+			 int is_local)
 {
   if (info->shared)
     return r_type;
@@ -959,11 +964,10 @@
    table.  */
 
 static bfd_boolean
-elf_s390_check_relocs (abfd, info, sec, relocs)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     asection *sec;
-     const Elf_Internal_Rela *relocs;
+elf_s390_check_relocs (bfd *abfd,
+		       struct bfd_link_info *info,
+		       asection *sec,
+		       const Elf_Internal_Rela *relocs)
 {
   struct elf_s390_link_hash_table *htab;
   Elf_Internal_Shdr *symtab_hdr;
@@ -973,6 +977,7 @@
   asection *sreloc;
   bfd_signed_vma *local_got_refcounts;
   int tls_type, old_tls_type;
+  Elf_Internal_Sym *isym;
 
   if (info->relocatable)
     return TRUE;
@@ -1003,13 +1008,44 @@
 	}
 
       if (r_symndx < symtab_hdr->sh_info)
-	h = NULL;
+	{
+	  /* A local symbol.  */
+	  isym = bfd_sym_from_r_symndx (&htab->sym_cache,
+					abfd, r_symndx);
+	  if (isym == NULL)
+	    return FALSE;
+
+	  if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC)
+	    {
+	      struct plt_entry *plt;
+
+	      if (htab->elf.dynobj == NULL)
+		htab->elf.dynobj = abfd;
+
+	      if (!s390_elf_create_ifunc_sections (htab->elf.dynobj, info))
+		return FALSE;
+
+	      if (local_got_refcounts == NULL)
+		{
+		  if (!elf_s390_allocate_local_syminfo (abfd, symtab_hdr))
+		    return FALSE;
+		  local_got_refcounts = elf_local_got_refcounts (abfd);
+		}
+	      plt = elf_s390_local_plt (abfd);
+	      plt[r_symndx].plt.refcount++;
+	    }
+	  h = NULL;
+	}
       else
 	{
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       /* Create got section and local_got_refcounts array if they
@@ -1039,24 +1075,16 @@
 	  if (h == NULL
 	      && local_got_refcounts == NULL)
 	    {
-	      bfd_size_type size;
-
-	      size = symtab_hdr->sh_info;
-	      size *= (sizeof (bfd_signed_vma) + sizeof(char));
-	      local_got_refcounts = ((bfd_signed_vma *)
-				     bfd_zalloc (abfd, size));
-	      if (local_got_refcounts == NULL)
+	      if (!elf_s390_allocate_local_syminfo (abfd, symtab_hdr))
 		return FALSE;
-	      elf_local_got_refcounts (abfd) = local_got_refcounts;
-	      elf_s390_local_got_tls_type (abfd)
-		= (char *) (local_got_refcounts + symtab_hdr->sh_info);
+	      local_got_refcounts = elf_local_got_refcounts (abfd);
 	    }
 	  /* Fall through.  */
 	case R_390_GOTOFF16:
 	case R_390_GOTOFF32:
 	case R_390_GOTPC:
 	case R_390_GOTPCDBL:
-	  if (htab->sgot == NULL)
+	  if (htab->elf.sgot == NULL)
 	    {
 	      if (htab->elf.dynobj == NULL)
 		htab->elf.dynobj = abfd;
@@ -1065,16 +1093,39 @@
 	    }
 	}
 
+      if (h != NULL)
+	{
+	  if (htab->elf.dynobj == NULL)
+	    htab->elf.dynobj = abfd;
+	  if (!s390_elf_create_ifunc_sections (htab->elf.dynobj, info))
+	    return FALSE;
+
+	  /* Make sure an IFUNC symbol defined in a non-shared object
+	     always gets a PLT slot.  */
+	  if (s390_is_ifunc_symbol_p (h) && h->def_regular)
+	    {
+	      /* The symbol is called by the dynamic loader in order
+		 to resolve the relocation.  So it is in fact also
+		 referenced.  */
+	      h->ref_regular = 1;
+	      h->needs_plt = 1;
+	    }
+	}
       switch (r_type)
 	{
 	case R_390_GOTOFF16:
 	case R_390_GOTOFF32:
 	case R_390_GOTPC:
 	case R_390_GOTPCDBL:
-	  /* Got is created, nothing to be done.  */
+	  /* These relocs do not need a GOT slot.  They just load the
+	     GOT pointer itself or address something else relative to
+	     the GOT.  Since the GOT pointer has been set up above we
+	     are done.  */
 	  break;
 
+	case R_390_PLT12DBL:
 	case R_390_PLT16DBL:
+	case R_390_PLT24DBL:
 	case R_390_PLT32DBL:
 	case R_390_PLT32:
 	case R_390_PLTOFF16:
@@ -1209,10 +1260,12 @@
 	case R_390_16:
 	case R_390_32:
 	case R_390_PC16:
+	case R_390_PC12DBL:
 	case R_390_PC16DBL:
+	case R_390_PC24DBL:
 	case R_390_PC32DBL:
 	case R_390_PC32:
-	  if (h != NULL && !info->shared)
+	  if (h != NULL)
 	    {
 	      /* If this reloc is in a read-only section, we might
 		 need a copy reloc.  We can't check reliably at this
@@ -1222,9 +1275,12 @@
 		 adjust_dynamic_symbol.  */
 	      h->non_got_ref = 1;
 
-	      /* We may need a .plt entry if the function this reloc
-		 refers to is in a shared lib.  */
-	      h->plt.refcount += 1;
+	      if (!info->shared)
+		{
+		  /* We may need a .plt entry if the function this reloc
+		     refers to is in a shared lib.  */
+		  h->plt.refcount += 1;
+		}
 	    }
 
 	  /* If we are creating a shared library, and this is a reloc
@@ -1251,7 +1307,9 @@
 	  if ((info->shared
 	       && (sec->flags & SEC_ALLOC) != 0
 	       && ((ELF32_R_TYPE (rel->r_info) != R_390_PC16
+		    && ELF32_R_TYPE (rel->r_info) != R_390_PC12DBL
 		    && ELF32_R_TYPE (rel->r_info) != R_390_PC16DBL
+		    && ELF32_R_TYPE (rel->r_info) != R_390_PC24DBL
 		    && ELF32_R_TYPE (rel->r_info) != R_390_PC32DBL
 		    && ELF32_R_TYPE (rel->r_info) != R_390_PC32)
 		   || (h != NULL
@@ -1265,8 +1323,8 @@
 		  && (h->root.type == bfd_link_hash_defweak
 		      || !h->def_regular)))
 	    {
-	      struct elf_s390_dyn_relocs *p;
-	      struct elf_s390_dyn_relocs **head;
+	      struct elf_dyn_relocs *p;
+	      struct elf_dyn_relocs **head;
 
 	      /* We must copy these reloc types into the output file.
 		 Create a reloc section in dynobj and make room for
@@ -1296,7 +1354,6 @@
 		     easily.  Oh well.  */
 		  asection *s;
 		  void *vpp;
-		  Elf_Internal_Sym *isym;
 
 		  isym = bfd_sym_from_r_symndx (&htab->sym_cache,
 						abfd, r_symndx);
@@ -1308,7 +1365,7 @@
 		    s = sec;
 
 		  vpp = &elf_section_data (s)->local_dynrel;
-		  head = (struct elf_s390_dyn_relocs **) vpp;
+		  head = (struct elf_dyn_relocs **) vpp;
 		}
 
 	      p = *head;
@@ -1316,7 +1373,7 @@
 		{
 		  bfd_size_type amt = sizeof *p;
 
-		  p = ((struct elf_s390_dyn_relocs *)
+		  p = ((struct elf_dyn_relocs *)
 		       bfd_alloc (htab->elf.dynobj, amt));
 		  if (p == NULL)
 		    return FALSE;
@@ -1329,7 +1386,9 @@
 
 	      p->count += 1;
 	      if (ELF32_R_TYPE (rel->r_info) == R_390_PC16
+		  || ELF32_R_TYPE (rel->r_info) == R_390_PC12DBL
 		  || ELF32_R_TYPE (rel->r_info) == R_390_PC16DBL
+		  || ELF32_R_TYPE (rel->r_info) == R_390_PC24DBL
 		  || ELF32_R_TYPE (rel->r_info) == R_390_PC32DBL
 		  || ELF32_R_TYPE (rel->r_info) == R_390_PC32)
 		p->pc_count += 1;
@@ -1389,6 +1448,7 @@
 			asection *sec,
 			const Elf_Internal_Rela *relocs)
 {
+  struct elf_s390_link_hash_table *htab;
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
   bfd_signed_vma *local_got_refcounts;
@@ -1397,6 +1457,10 @@
   if (info->relocatable)
     return TRUE;
 
+  htab = elf_s390_hash_table (info);
+  if (htab == NULL)
+    return FALSE;
+
   elf_section_data (sec)->local_dynrel = NULL;
 
   symtab_hdr = &elf_symtab_hdr (abfd);
@@ -1414,8 +1478,8 @@
       if (r_symndx >= symtab_hdr->sh_info)
 	{
 	  struct elf_s390_link_hash_entry *eh;
-	  struct elf_s390_dyn_relocs **pp;
-	  struct elf_s390_dyn_relocs *p;
+	  struct elf_dyn_relocs **pp;
+	  struct elf_dyn_relocs *p;
 
 	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
 	  while (h->root.type == bfd_link_hash_indirect
@@ -1431,6 +1495,23 @@
 		break;
 	      }
 	}
+      else
+	{
+	  Elf_Internal_Sym *isym;
+
+	  /* A local symbol.  */
+	  isym = bfd_sym_from_r_symndx (&htab->sym_cache,
+					abfd, r_symndx);
+	  if (isym == NULL)
+	    return FALSE;
+
+	  if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC)
+	    {
+	      struct plt_entry *plt = elf_s390_local_plt (abfd);
+	      if (plt[r_symndx].plt.refcount > 0)
+		plt[r_symndx].plt.refcount--;
+	    }
+	}
 
       r_type = ELF32_R_TYPE (rel->r_info);
       r_type = elf_s390_tls_transition (info, r_type, h != NULL);
@@ -1474,14 +1555,18 @@
 	case R_390_20:
 	case R_390_32:
 	case R_390_PC16:
+	case R_390_PC12DBL:
 	case R_390_PC16DBL:
+	case R_390_PC24DBL:
 	case R_390_PC32DBL:
 	case R_390_PC32:
 	  if (info->shared)
 	    break;
 	  /* Fall through.  */
 
+	case R_390_PLT12DBL:
 	case R_390_PLT16DBL:
+	case R_390_PLT24DBL:
 	case R_390_PLT32DBL:
 	case R_390_PLT32:
 	case R_390_PLTOFF16:
@@ -1529,8 +1614,7 @@
    created (we're only linking static objects).  */
 
 static void
-elf_s390_adjust_gotplt (h)
-     struct elf_s390_link_hash_entry *h;
+elf_s390_adjust_gotplt (struct elf_s390_link_hash_entry *h)
 {
   if (h->elf.root.type == bfd_link_hash_warning)
     h = (struct elf_s390_link_hash_entry *) h->elf.root.u.i.link;
@@ -1551,13 +1635,16 @@
    understand.  */
 
 static bfd_boolean
-elf_s390_adjust_dynamic_symbol (info, h)
-     struct bfd_link_info *info;
-     struct elf_link_hash_entry *h;
+elf_s390_adjust_dynamic_symbol (struct bfd_link_info *info,
+				struct elf_link_hash_entry *h)
 {
   struct elf_s390_link_hash_table *htab;
   asection *s;
 
+  /* STT_GNU_IFUNC symbol must go through PLT. */
+  if (s390_is_ifunc_symbol_p (h))
+    return TRUE;
+
   /* If this is a function, put it in the procedure linkage table.  We
      will fill in the contents of the procedure linkage table later
      (although we could actually do it here).  */
@@ -1628,7 +1715,7 @@
   if (ELIMINATE_COPY_RELOCS)
     {
       struct elf_s390_link_hash_entry * eh;
-      struct elf_s390_dyn_relocs *p;
+      struct elf_dyn_relocs *p;
 
       eh = (struct elf_s390_link_hash_entry *) h;
       for (p = eh->dyn_relocs; p != NULL; p = p->next)
@@ -1647,13 +1734,6 @@
 	}
     }
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-			     h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -1669,7 +1749,7 @@
   /* We must generate a R_390_COPY reloc to tell the dynamic linker to
      copy the initial value out of the dynamic object and into the
      runtime process image.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       htab->srelbss->size += sizeof (Elf32_External_Rela);
       h->needs_copy = 1;
@@ -1684,14 +1764,12 @@
    dynamic relocs.  */
 
 static bfd_boolean
-allocate_dynrelocs (h, inf)
-     struct elf_link_hash_entry *h;
-     PTR inf;
+allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
 {
   struct bfd_link_info *info;
   struct elf_s390_link_hash_table *htab;
-  struct elf_s390_link_hash_entry *eh;
-  struct elf_s390_dyn_relocs *p;
+  struct elf_s390_link_hash_entry *eh = (struct elf_s390_link_hash_entry *)h;
+  struct elf_dyn_relocs *p;
 
   if (h->root.type == bfd_link_hash_indirect)
     return TRUE;
@@ -1699,8 +1777,13 @@
   info = (struct bfd_link_info *) inf;
   htab = elf_s390_hash_table (info);
 
-  if (htab->elf.dynamic_sections_created
-      && h->plt.refcount > 0)
+  /* Since STT_GNU_IFUNC symbol must go through PLT, we handle it
+     here if it is defined and referenced in a non-shared object.  */
+  if (s390_is_ifunc_symbol_p (h) && h->def_regular)
+    return s390_elf_allocate_ifunc_dyn_relocs (info, h,
+					       &eh->dyn_relocs);
+  else if (htab->elf.dynamic_sections_created
+	   && h->plt.refcount > 0)
     {
       /* Make sure this symbol is output as a dynamic symbol.
 	 Undefined weak syms won't yet be marked as dynamic.  */
@@ -1714,7 +1797,7 @@
       if (info->shared
 	  || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h))
 	{
-	  asection *s = htab->splt;
+	  asection *s = htab->elf.splt;
 
 	  /* If this is the first .plt entry, make room for the special
 	     first entry.  */
@@ -1740,10 +1823,10 @@
 
 	  /* We also need to make an entry in the .got.plt section, which
 	     will be placed in the .got section by the linker script.  */
-	  htab->sgotplt->size += GOT_ENTRY_SIZE;
+	  htab->elf.sgotplt->size += GOT_ENTRY_SIZE;
 
 	  /* We also need to make an entry in the .rela.plt section.  */
-	  htab->srelplt->size += sizeof (Elf32_External_Rela);
+	  htab->elf.srelplt->size += sizeof (Elf32_External_Rela);
 	}
       else
 	{
@@ -1773,8 +1856,8 @@
 	   to be stored somewhere. The immediate value in the instruction
 	   is not bit enough so the value is stored in the got.  */
 	{
-	  h->got.offset = htab->sgot->size;
-	  htab->sgot->size += GOT_ENTRY_SIZE;
+	  h->got.offset = htab->elf.sgot->size;
+	  htab->elf.sgot->size += GOT_ENTRY_SIZE;
 	}
       else
 	h->got.offset = (bfd_vma) -1;
@@ -1794,7 +1877,7 @@
 	    return FALSE;
 	}
 
-      s = htab->sgot;
+      s = htab->elf.sgot;
       h->got.offset = s->size;
       s->size += GOT_ENTRY_SIZE;
       /* R_390_TLS_GD32 needs 2 consecutive GOT slots.  */
@@ -1805,19 +1888,18 @@
 	 R_390_TLS_GD32 needs one if local symbol and two if global.  */
       if ((tls_type == GOT_TLS_GD && h->dynindx == -1)
 	  || tls_type >= GOT_TLS_IE)
-	htab->srelgot->size += sizeof (Elf32_External_Rela);
+	htab->elf.srelgot->size += sizeof (Elf32_External_Rela);
       else if (tls_type == GOT_TLS_GD)
-	htab->srelgot->size += 2 * sizeof (Elf32_External_Rela);
+	htab->elf.srelgot->size += 2 * sizeof (Elf32_External_Rela);
       else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
 		|| h->root.type != bfd_link_hash_undefweak)
 	       && (info->shared
 		   || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
-	htab->srelgot->size += sizeof (Elf32_External_Rela);
+	htab->elf.srelgot->size += sizeof (Elf32_External_Rela);
     }
   else
     h->got.offset = (bfd_vma) -1;
 
-  eh = (struct elf_s390_link_hash_entry *) h;
   if (eh->dyn_relocs == NULL)
     return TRUE;
 
@@ -1831,7 +1913,7 @@
     {
       if (SYMBOL_CALLS_LOCAL (info, h))
 	{
-	  struct elf_s390_dyn_relocs **pp;
+	  struct elf_dyn_relocs **pp;
 
 	  for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
 	    {
@@ -1909,12 +1991,10 @@
 /* Find any dynamic relocs that apply to read-only sections.  */
 
 static bfd_boolean
-readonly_dynrelocs (h, inf)
-     struct elf_link_hash_entry *h;
-     PTR inf;
+readonly_dynrelocs (struct elf_link_hash_entry *h, void * inf)
 {
   struct elf_s390_link_hash_entry *eh;
-  struct elf_s390_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
 
   eh = (struct elf_s390_link_hash_entry *) h;
   for (p = eh->dyn_relocs; p != NULL; p = p->next)
@@ -1937,9 +2017,8 @@
 /* Set the sizes of the dynamic sections.  */
 
 static bfd_boolean
-elf_s390_size_dynamic_sections (output_bfd, info)
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info;
+elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
+				struct bfd_link_info *info)
 {
   struct elf_s390_link_hash_table *htab;
   bfd *dynobj;
@@ -1957,7 +2036,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  if (s == NULL)
 	    abort ();
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
@@ -1975,13 +2054,15 @@
       bfd_size_type locsymcount;
       Elf_Internal_Shdr *symtab_hdr;
       asection *srela;
+      struct plt_entry *local_plt;
+      unsigned int i;
 
       if (! is_s390_elf (ibfd))
 	continue;
 
       for (s = ibfd->sections; s != NULL; s = s->next)
 	{
-	  struct elf_s390_dyn_relocs *p;
+	  struct elf_dyn_relocs *p;
 
 	  for (p = elf_section_data (s)->local_dynrel; p != NULL; p = p->next)
 	    {
@@ -2011,8 +2092,8 @@
       locsymcount = symtab_hdr->sh_info;
       end_local_got = local_got + locsymcount;
       local_tls_type = elf_s390_local_got_tls_type (ibfd);
-      s = htab->sgot;
-      srela = htab->srelgot;
+      s = htab->elf.sgot;
+      srela = htab->elf.srelgot;
       for (; local_got < end_local_got; ++local_got, ++local_tls_type)
 	{
 	  if (*local_got > 0)
@@ -2027,22 +2108,35 @@
 	  else
 	    *local_got = (bfd_vma) -1;
 	}
+      local_plt = elf_s390_local_plt (ibfd);
+      for (i = 0; i < symtab_hdr->sh_info; i++)
+	{
+	  if (local_plt[i].plt.refcount > 0)
+	    {
+	      local_plt[i].plt.offset = htab->elf.iplt->size;
+	      htab->elf.iplt->size += PLT_ENTRY_SIZE;
+	      htab->elf.igotplt->size += GOT_ENTRY_SIZE;
+	      htab->elf.irelplt->size += RELA_ENTRY_SIZE;
+	    }
+	  else
+            local_plt[i].plt.offset = (bfd_vma) -1;
+	}
     }
 
   if (htab->tls_ldm_got.refcount > 0)
     {
       /* Allocate 2 got entries and 1 dynamic reloc for R_390_TLS_LDM32
 	 relocs.  */
-      htab->tls_ldm_got.offset = htab->sgot->size;
-      htab->sgot->size += 2 * GOT_ENTRY_SIZE;
-      htab->srelgot->size += sizeof (Elf32_External_Rela);
+      htab->tls_ldm_got.offset = htab->elf.sgot->size;
+      htab->elf.sgot->size += 2 * GOT_ENTRY_SIZE;
+      htab->elf.srelgot->size += sizeof (Elf32_External_Rela);
     }
   else
     htab->tls_ldm_got.offset = -1;
 
   /* Allocate global sym .plt and .got entries, and space for global
      sym dynamic relocs.  */
-  elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, (PTR) info);
+  elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, info);
 
   /* We now have determined the sizes of the various dynamic sections.
      Allocate memory for them.  */
@@ -2052,10 +2146,13 @@
       if ((s->flags & SEC_LINKER_CREATED) == 0)
 	continue;
 
-      if (s == htab->splt
-	  || s == htab->sgot
-	  || s == htab->sgotplt
-	  || s == htab->sdynbss)
+      if (s == htab->elf.splt
+	  || s == htab->elf.sgot
+	  || s == htab->elf.sgotplt
+	  || s == htab->sdynbss
+	  || s == htab->elf.iplt
+	  || s == htab->elf.igotplt
+	  || s == htab->irelifunc)
 	{
 	  /* Strip this section if we don't need it; see the
 	     comment below.  */
@@ -2120,7 +2217,7 @@
 	    return FALSE;
 	}
 
-      if (htab->splt->size != 0)
+      if (htab->elf.splt->size != 0)
 	{
 	  if (!add_dynamic_entry (DT_PLTGOT, 0)
 	      || !add_dynamic_entry (DT_PLTRELSZ, 0)
@@ -2139,8 +2236,7 @@
 	  /* If any dynamic relocs apply to a read-only section,
 	     then we need a DT_TEXTREL entry.  */
 	  if ((info->flags & DF_TEXTREL) == 0)
-	    elf_link_hash_traverse (&htab->elf, readonly_dynrelocs,
-				    (PTR) info);
+	    elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, info);
 
 	  if ((info->flags & DF_TEXTREL) != 0)
 	    {
@@ -2159,8 +2255,7 @@
    This is PT_TLS segment p_vaddr.  */
 
 static bfd_vma
-dtpoff_base (info)
-     struct bfd_link_info *info;
+dtpoff_base (struct bfd_link_info *info)
 {
   /* If tls_sec is NULL, we should have signalled an error already.  */
   if (elf_hash_table (info)->tls_sec == NULL)
@@ -2172,9 +2267,7 @@
    if STT_TLS virtual address is ADDRESS.  */
 
 static bfd_vma
-tpoff (info, address)
-     struct bfd_link_info *info;
-     bfd_vma address;
+tpoff (struct bfd_link_info *info, bfd_vma address)
 {
   struct elf_link_hash_table *htab = elf_hash_table (info);
 
@@ -2188,10 +2281,9 @@
    instruction.  */
 
 static void
-invalid_tls_insn (input_bfd, input_section, rel)
-     bfd *input_bfd;
-     asection *input_section;
-     Elf_Internal_Rela *rel;
+invalid_tls_insn (bfd *input_bfd,
+		  asection *input_section,
+		  Elf_Internal_Rela *rel)
 {
   reloc_howto_type *howto;
 
@@ -2208,16 +2300,14 @@
 /* Relocate a 390 ELF section.  */
 
 static bfd_boolean
-elf_s390_relocate_section (output_bfd, info, input_bfd, input_section,
-			      contents, relocs, local_syms, local_sections)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     Elf_Internal_Rela *relocs;
-     Elf_Internal_Sym *local_syms;
-     asection **local_sections;
+elf_s390_relocate_section (bfd *output_bfd,
+			   struct bfd_link_info *info,
+			   bfd *input_bfd,
+			   asection *input_section,
+			   bfd_byte *contents,
+			   Elf_Internal_Rela *relocs,
+			   Elf_Internal_Sym *local_syms,
+			   asection **local_sections)
 {
   struct elf_s390_link_hash_table *htab;
   Elf_Internal_Shdr *symtab_hdr;
@@ -2248,6 +2338,7 @@
       bfd_boolean unresolved_reloc;
       bfd_reloc_status_type r;
       int tls_type;
+      asection *base_got = htab->elf.sgot;
 
       r_type = ELF32_R_TYPE (rel->r_info);
       if (r_type == (int) R_390_GNU_VTINHERIT
@@ -2270,7 +2361,56 @@
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections[r_symndx];
-	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
+	  if (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC)
+	    {
+	      struct plt_entry *local_plt = elf_s390_local_plt (input_bfd);
+	      if (local_plt == NULL)
+		return FALSE;
+
+	      /* Address of the PLT slot.  */
+	      relocation = (htab->elf.iplt->output_section->vma
+			    + htab->elf.iplt->output_offset
+			    + local_plt[r_symndx].plt.offset);
+
+	      switch (r_type)
+		{
+		case R_390_PLTOFF16:
+		case R_390_PLTOFF32:
+		  relocation -= htab->elf.sgot->output_section->vma;
+		  break;
+		case R_390_GOTPLT12:
+		case R_390_GOTPLT16:
+		case R_390_GOTPLT20:
+		case R_390_GOTPLT32:
+		case R_390_GOTPLTENT:
+		case R_390_GOT12:
+		case R_390_GOT16:
+		case R_390_GOT20:
+		case R_390_GOT32:
+		case R_390_GOTENT:
+		  {
+		    /* Write the PLT slot address into the GOT slot.  */
+		    bfd_put_32 (output_bfd, relocation,
+				htab->elf.sgot->contents +
+				local_got_offsets[r_symndx]);
+		    relocation = (local_got_offsets[r_symndx] +
+				  htab->elf.sgot->output_offset);
+
+		    if (r_type == R_390_GOTENT || r_type == R_390_GOTPLTENT)
+		      relocation += htab->elf.sgot->output_section->vma;
+		    break;
+		  }
+		default:
+		  break;
+		}
+	      /* The output section is needed later in
+		 finish_dynamic_section when creating the dynamic
+		 relocation.  */
+	      local_plt[r_symndx].sec = sec;
+	      goto do_relocation;
+	    }
+	  else
+	    relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
 	}
       else
 	{
@@ -2282,9 +2422,9 @@
 				   unresolved_reloc, warned);
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -2309,19 +2449,29 @@
 	    {
 	      bfd_vma plt_index;
 
-	      /* Calc. index no.
-		 Current offset - size first entry / entry size.  */
-	      plt_index = (h->plt.offset - PLT_FIRST_ENTRY_SIZE) /
-		PLT_ENTRY_SIZE;
+	      if (s390_is_ifunc_symbol_p (h))
+		{
+		  plt_index = h->plt.offset / PLT_ENTRY_SIZE;
+		  relocation = (plt_index * GOT_ENTRY_SIZE +
+				htab->elf.igotplt->output_offset);
+		  if (r_type == R_390_GOTPLTENT)
+		    relocation += htab->elf.igotplt->output_section->vma;
+		}
+	      else
+		{
+		  /* Calc. index no.
+		     Current offset - size first entry / entry size.  */
+		  plt_index = (h->plt.offset - PLT_FIRST_ENTRY_SIZE) /
+		    PLT_ENTRY_SIZE;
 
-	      /* Offset in GOT is PLT index plus GOT headers(3) times 4,
-		 addr & GOT addr.  */
-	      relocation = (plt_index + 3) * GOT_ENTRY_SIZE;
+		  /* Offset in GOT is PLT index plus GOT headers(3)
+		     times 4, addr & GOT addr.  */
+		  relocation = (plt_index + 3) * GOT_ENTRY_SIZE;
+		  if (r_type == R_390_GOTPLTENT)
+		    relocation += htab->elf.sgot->output_section->vma;
+		}
 	      unresolved_reloc = FALSE;
 
-	      if (r_type == R_390_GOTPLTENT)
-		relocation += htab->sgot->output_section->vma;
-	      break;
 	    }
 	  /* Fall through.  */
 
@@ -2332,7 +2482,7 @@
 	case R_390_GOTENT:
 	  /* Relocation is to the entry for this symbol in the global
 	     offset table.  */
-	  if (htab->sgot == NULL)
+	  if (base_got == NULL)
 	    abort ();
 
 	  if (h != NULL)
@@ -2341,11 +2491,30 @@
 
 	      off = h->got.offset;
 	      dyn = htab->elf.dynamic_sections_created;
-	      if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
-		  || (info->shared
-		      && SYMBOL_REFERENCES_LOCAL (info, h))
-		  || (ELF_ST_VISIBILITY (h->other)
-		      && h->root.type == bfd_link_hash_undefweak))
+
+	      if (s390_is_ifunc_symbol_p (h))
+		{
+		  BFD_ASSERT (h->plt.offset != (bfd_vma) -1);
+		  if (off == (bfd_vma)-1)
+		    {
+		      /* No explicit GOT usage so redirect to the
+			 got.iplt slot.  */
+		      base_got = htab->elf.igotplt;
+		      off = h->plt.offset / PLT_ENTRY_SIZE * GOT_ENTRY_SIZE;
+		    }
+		  else
+		    {
+		      /* Explicit GOT slots must contain the address
+			 of the PLT slot. This will be handled in
+			 finish_dynamic_symbol.  */
+		    }
+		}
+	      else if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
+		       || (info->shared
+			   && SYMBOL_REFERENCES_LOCAL (info, h))
+		       || (ELF_ST_VISIBILITY (h->other)
+			   && h->root.type == bfd_link_hash_undefweak))
+
 		{
 		  /* This is actually a static link, or it is a
 		     -Bsymbolic link and the symbol is defined
@@ -2364,9 +2533,39 @@
 		  else
 		    {
 		      bfd_put_32 (output_bfd, relocation,
-				  htab->sgot->contents + off);
+				  base_got->contents + off);
 		      h->got.offset |= 1;
 		    }
+
+		  if ((h->def_regular
+		       && info->shared
+		       && SYMBOL_REFERENCES_LOCAL (info, h))
+		      /* lrl rx,sym@GOTENT -> larl rx, sym */
+		      && ((r_type == R_390_GOTENT
+			   && (bfd_get_16 (input_bfd,
+					   contents + rel->r_offset - 2)
+			       & 0xff0f) == 0xc40d)
+			  /* ly rx, sym@GOT(r12) -> larl rx, sym */
+			  || (r_type == R_390_GOT20
+			      && (bfd_get_32 (input_bfd,
+					      contents + rel->r_offset - 2)
+				  & 0xff00f000) == 0xe300c000
+			      && bfd_get_8 (input_bfd,
+					    contents + rel->r_offset + 3) == 0x58)))
+		    {
+		      unsigned short new_insn =
+			(0xc000 | (bfd_get_8 (input_bfd,
+					      contents + rel->r_offset - 1) & 0xf0));
+		      bfd_put_16 (output_bfd, new_insn,
+				  contents + rel->r_offset - 2);
+		      r_type = R_390_PC32DBL;
+		      rel->r_addend = 2;
+		      howto = elf_howto_table + r_type;
+		      relocation = h->root.u.def.value
+			+ h->root.u.def.section->output_section->vma
+			+ h->root.u.def.section->output_offset;
+		      goto do_relocation;
+		    }
 		}
 	      else
 		unresolved_reloc = FALSE;
@@ -2386,7 +2585,7 @@
 	      else
 		{
 		  bfd_put_32 (output_bfd, relocation,
-			      htab->sgot->contents + off);
+			      htab->elf.sgot->contents + off);
 
 		  if (info->shared)
 		    {
@@ -2394,12 +2593,12 @@
 		      Elf_Internal_Rela outrel;
 		      bfd_byte *loc;
 
-		      srelgot = htab->srelgot;
+		      srelgot = htab->elf.srelgot;
 		      if (srelgot == NULL)
 			abort ();
 
-		      outrel.r_offset = (htab->sgot->output_section->vma
-					 + htab->sgot->output_offset
+		      outrel.r_offset = (htab->elf.sgot->output_section->vma
+					 + htab->elf.sgot->output_offset
 					 + off);
 		      outrel.r_info = ELF32_R_INFO (0, R_390_RELATIVE);
 		      outrel.r_addend = relocation;
@@ -2415,7 +2614,7 @@
 	  if (off >= (bfd_vma) -2)
 	    abort ();
 
-	  relocation = htab->sgot->output_offset + off;
+	  relocation = base_got->output_offset + off;
 
 	  /* For @GOTENT the relocation is against the offset between
 	     the instruction and the symbols entry in the GOT and not
@@ -2423,7 +2622,7 @@
 	     add the vma of the GOT to get the correct value.  */
 	  if (   r_type == R_390_GOTENT
 	      || r_type == R_390_GOTPLTENT)
-	    relocation += htab->sgot->output_section->vma;
+	    relocation += base_got->output_section->vma;
 
 	  break;
 
@@ -2437,17 +2636,19 @@
 	     defined _GLOBAL_OFFSET_TABLE in a different way, as is
 	     permitted by the ABI, we might have to change this
 	     calculation.  */
-	  relocation -= htab->sgot->output_section->vma;
+	  relocation -= htab->elf.sgot->output_section->vma;
 	  break;
 
 	case R_390_GOTPC:
 	case R_390_GOTPCDBL:
 	  /* Use global offset table as symbol value.  */
-	  relocation = htab->sgot->output_section->vma;
+	  relocation = htab->elf.sgot->output_section->vma;
 	  unresolved_reloc = FALSE;
 	  break;
 
+	case R_390_PLT12DBL:
 	case R_390_PLT16DBL:
+	case R_390_PLT24DBL:
 	case R_390_PLT32DBL:
 	case R_390_PLT32:
 	  /* Relocation is to the entry for this symbol in the
@@ -2459,7 +2660,7 @@
 	    break;
 
 	  if (h->plt.offset == (bfd_vma) -1
-	      || htab->splt == NULL)
+	      || (htab->elf.splt == NULL && htab->elf.iplt == NULL))
 	    {
 	      /* We didn't make a PLT entry for this symbol.  This
 		 happens when statically linking PIC code, or when
@@ -2467,9 +2668,14 @@
 	      break;
 	    }
 
-	  relocation = (htab->splt->output_section->vma
-			+ htab->splt->output_offset
-			+ h->plt.offset);
+	  if (s390_is_ifunc_symbol_p (h))
+	    relocation = (htab->elf.iplt->output_section->vma
+                          + htab->elf.iplt->output_offset
+			  + h->plt.offset);
+	  else
+	    relocation = (htab->elf.splt->output_section->vma
+			  + htab->elf.splt->output_offset
+			  + h->plt.offset);
 	  unresolved_reloc = FALSE;
 	  break;
 
@@ -2480,18 +2686,24 @@
 
 	  /* For local symbols or if we didn't make a PLT entry for
 	     this symbol resolve the symbol directly.  */
-	  if (   h == NULL
+	  if (h == NULL
 	      || h->plt.offset == (bfd_vma) -1
-	      || htab->splt == NULL)
+	      || (htab->elf.splt == NULL && !s390_is_ifunc_symbol_p (h)))
 	    {
-	      relocation -= htab->sgot->output_section->vma;
+	      relocation -= htab->elf.sgot->output_section->vma;
 	      break;
 	    }
 
-	  relocation = (htab->splt->output_section->vma
-			+ htab->splt->output_offset
-			+ h->plt.offset
-			- htab->sgot->output_section->vma);
+	  if (s390_is_ifunc_symbol_p (h))
+	    relocation = (htab->elf.iplt->output_section->vma
+			  + htab->elf.iplt->output_offset
+			  + h->plt.offset
+			  - htab->elf.sgot->output_section->vma);
+	  else
+	    relocation = (htab->elf.splt->output_section->vma
+			  + htab->elf.splt->output_offset
+			  + h->plt.offset
+			  - htab->elf.sgot->output_section->vma);
 	  unresolved_reloc = FALSE;
 	  break;
 
@@ -2499,9 +2711,72 @@
 	case R_390_16:
 	case R_390_32:
 	case R_390_PC16:
+	case R_390_PC12DBL:
 	case R_390_PC16DBL:
+	case R_390_PC24DBL:
 	case R_390_PC32DBL:
 	case R_390_PC32:
+	  if (h != NULL
+	      && s390_is_ifunc_symbol_p (h)
+	      && h->def_regular)
+	    {
+	      if (!info->shared || !h->non_got_ref)
+		{
+		  /* For a non-shared object STT_GNU_IFUNC symbol must
+		     go through PLT.  */
+		  relocation = (htab->elf.iplt->output_section->vma
+				+ htab->elf.iplt->output_offset
+				+ h ->plt.offset);
+		  goto do_relocation;
+		}
+	      else
+		{
+		  /* For shared objects a runtime relocation is needed.  */
+
+		  Elf_Internal_Rela outrel;
+		  asection *sreloc;
+
+		  /* Need a dynamic relocation to get the real function
+		     address.  */
+		  outrel.r_offset = _bfd_elf_section_offset (output_bfd,
+							     info,
+							     input_section,
+							     rel->r_offset);
+		  if (outrel.r_offset == (bfd_vma) -1
+		      || outrel.r_offset == (bfd_vma) -2)
+		    abort ();
+
+		  outrel.r_offset += (input_section->output_section->vma
+				      + input_section->output_offset);
+
+		  if (h->dynindx == -1
+		      || h->forced_local
+		      || info->executable)
+		    {
+		      /* This symbol is resolved locally.  */
+		      outrel.r_info = ELF32_R_INFO (0, R_390_IRELATIVE);
+		      outrel.r_addend = (h->root.u.def.value
+					 + h->root.u.def.section->output_section->vma
+					 + h->root.u.def.section->output_offset);
+		    }
+		  else
+		    {
+		      outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
+		      outrel.r_addend = 0;
+		    }
+
+		  sreloc = htab->elf.irelifunc;
+		  elf_append_rela (output_bfd, sreloc, &outrel);
+
+		  /* If this reloc is against an external symbol, we
+		     do not want to fiddle with the addend.  Otherwise,
+		     we need to include the symbol value so that it
+		     becomes an addend for the dynamic reloc.  For an
+		     internal symbol, we have updated addend.  */
+		  continue;
+		}
+	    }
+
 	  if ((input_section->flags & SEC_ALLOC) == 0)
 	    break;
 
@@ -2510,7 +2785,9 @@
 		   || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
 		   || h->root.type != bfd_link_hash_undefweak)
 	       && ((r_type != R_390_PC16
+		    && r_type != R_390_PC12DBL
 		    && r_type != R_390_PC16DBL
+		    && r_type != R_390_PC24DBL
 		    && r_type != R_390_PC32DBL
 		    && r_type != R_390_PC32)
 		   || !SYMBOL_CALLS_LOCAL (info, h)))
@@ -2551,7 +2828,9 @@
 	      else if (h != NULL
 		       && h->dynindx != -1
 		       && (r_type == R_390_PC16
+			   || r_type == R_390_PC12DBL
 			   || r_type == R_390_PC16DBL
+			   || r_type == R_390_PC24DBL
 			   || r_type == R_390_PC32DBL
 			   || r_type == R_390_PC32
 			   || !info->shared
@@ -2668,7 +2947,7 @@
 	      continue;
 	    }
 
-	  if (htab->sgot == NULL)
+	  if (htab->elf.sgot == NULL)
 	    abort ();
 
 	  if (h != NULL)
@@ -2691,11 +2970,11 @@
 	      bfd_byte *loc;
 	      int dr_type, indx;
 
-	      if (htab->srelgot == NULL)
+	      if (htab->elf.srelgot == NULL)
 		abort ();
 
-	      outrel.r_offset = (htab->sgot->output_section->vma
-				 + htab->sgot->output_offset + off);
+	      outrel.r_offset = (htab->elf.sgot->output_section->vma
+				 + htab->elf.sgot->output_offset + off);
 
 	      indx = h && h->dynindx != -1 ? h->dynindx : 0;
 	      if (r_type == R_390_TLS_GD32)
@@ -2707,8 +2986,8 @@
 	      else
 		outrel.r_addend = 0;
 	      outrel.r_info = ELF32_R_INFO (indx, dr_type);
-	      loc = htab->srelgot->contents;
-	      loc += htab->srelgot->reloc_count++
+	      loc = htab->elf.srelgot->contents;
+	      loc += htab->elf.srelgot->reloc_count++
 		* sizeof (Elf32_External_Rela);
 	      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 
@@ -2719,14 +2998,14 @@
 		      BFD_ASSERT (! unresolved_reloc);
 		      bfd_put_32 (output_bfd,
 				  relocation - dtpoff_base (info),
-				  htab->sgot->contents + off + GOT_ENTRY_SIZE);
+				  htab->elf.sgot->contents + off + GOT_ENTRY_SIZE);
 		    }
 		  else
 		    {
 		      outrel.r_info = ELF32_R_INFO (indx, R_390_TLS_DTPOFF);
 		      outrel.r_offset += GOT_ENTRY_SIZE;
 		      outrel.r_addend = 0;
-		      htab->srelgot->reloc_count++;
+		      htab->elf.srelgot->reloc_count++;
 		      loc += sizeof (Elf32_External_Rela);
 		      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 		    }
@@ -2742,14 +3021,14 @@
 	    abort ();
 	  if (r_type == ELF32_R_TYPE (rel->r_info))
 	    {
-	      relocation = htab->sgot->output_offset + off;
+	      relocation = htab->elf.sgot->output_offset + off;
 	      if (r_type == R_390_TLS_IE32 || r_type == R_390_TLS_IEENT)
-		relocation += htab->sgot->output_section->vma;
+		relocation += htab->elf.sgot->output_section->vma;
 	      unresolved_reloc = FALSE;
 	    }
 	  else
 	    {
-	      bfd_put_32 (output_bfd, htab->sgot->output_offset + off,
+	      bfd_put_32 (output_bfd, htab->elf.sgot->output_offset + off,
 			  contents + rel->r_offset);
 	      continue;
 	    }
@@ -2774,15 +3053,15 @@
 		goto emit_tls_relocs;
 	    }
 
-	  if (htab->sgot == NULL)
+	  if (htab->elf.sgot == NULL)
 	    abort ();
 
 	  BFD_ASSERT (! unresolved_reloc);
 	  bfd_put_32 (output_bfd, -tpoff (info, relocation),
-		      htab->sgot->contents + off);
-	  relocation = htab->sgot->output_offset + off;
+		      htab->elf.sgot->contents + off);
+	  relocation = htab->elf.sgot->output_offset + off;
 	  if (r_type == R_390_TLS_IEENT)
-	    relocation += htab->sgot->output_section->vma;
+	    relocation += htab->elf.sgot->output_section->vma;
 	  unresolved_reloc = FALSE;
 	  break;
 
@@ -2793,7 +3072,7 @@
 	       and the value will turn out zero.  */
 	    continue;
 
-	  if (htab->sgot == NULL)
+	  if (htab->elf.sgot == NULL)
 	    abort ();
 
 	  off = htab->tls_ldm_got.offset;
@@ -2804,23 +3083,23 @@
 	      Elf_Internal_Rela outrel;
 	      bfd_byte *loc;
 
-	      if (htab->srelgot == NULL)
+	      if (htab->elf.srelgot == NULL)
 		abort ();
 
-	      outrel.r_offset = (htab->sgot->output_section->vma
-				 + htab->sgot->output_offset + off);
+	      outrel.r_offset = (htab->elf.sgot->output_section->vma
+				 + htab->elf.sgot->output_offset + off);
 
 	      bfd_put_32 (output_bfd, 0,
-			  htab->sgot->contents + off + GOT_ENTRY_SIZE);
+			  htab->elf.sgot->contents + off + GOT_ENTRY_SIZE);
 	      outrel.r_info = ELF32_R_INFO (0, R_390_TLS_DTPMOD);
 	      outrel.r_addend = 0;
-	      loc = htab->srelgot->contents;
-	      loc += htab->srelgot->reloc_count++
+	      loc = htab->elf.srelgot->contents;
+	      loc += htab->elf.srelgot->reloc_count++
 		* sizeof (Elf32_External_Rela);
 	      bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 	      htab->tls_ldm_got.offset |= 1;
 	    }
-	  relocation = htab->sgot->output_offset + off;
+	  relocation = htab->elf.sgot->output_offset + off;
 	  unresolved_reloc = FALSE;
 	  break;
 
@@ -2862,7 +3141,7 @@
 	  continue;
 
 	case R_390_TLS_LDO32:
-	  if (info->shared)
+	  if (info->shared || (input_section->flags & SEC_DEBUGGING))
 	    relocation -= dtpoff_base (info);
 	  else
 	    /* When converting LDO to LE, we must negate.  */
@@ -2919,11 +3198,18 @@
 
 	      insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
 	      if ((insn & 0xff000fff) != 0x4d000000 &&
-		  (insn & 0xffff0000) != 0xc0e50000)
+		  (insn & 0xffff0000) != 0xc0e50000 &&
+		  (insn & 0xff000000) != 0x0d000000)
 		invalid_tls_insn (input_bfd, input_section, rel);
 	      if (!info->shared && (h == NULL || h->dynindx == -1))
 		{
-		  if ((insn & 0xff000000) == 0x4d000000)
+		  if ((insn & 0xff000000) == 0x0d000000)
+		    {
+		      /* GD->LE transition.
+			 basr rx, ry -> nopr r7 */
+		      insn = 0x07070000 | (insn & 0xffff);
+		    }
+		  else if ((insn & 0xff000000) == 0x4d000000)
 		    {
 		      /* GD->LE transition.
 			 bas %r14,0(%rx,%r13) -> bc 0,0  */
@@ -2932,7 +3218,7 @@
 		  else
 		    {
 		      /* GD->LE transition.
-			 brasl %r14,_tls_get_addr@plt -> brcl 0,.  */
+			 brasl %r14,_tls_get_offset@plt -> brcl 0,.  */
 		      insn = 0xc0040000;
 		      bfd_put_16 (output_bfd, 0x0000,
 				  contents + rel->r_offset + 4);
@@ -2940,6 +3226,11 @@
 		}
 	      else
 		{
+		  /* If basr is used in the pic case to invoke
+		     _tls_get_offset, something went wrong before.  */
+		  if ((insn & 0xff000000) == 0x0d000000)
+		    invalid_tls_insn (input_bfd, input_section, rel);
+
 		  if ((insn & 0xff000000) == 0x4d000000)
 		    {
 		      /* GD->IE transition.
@@ -2966,9 +3257,17 @@
 
 		  insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
 		  if ((insn & 0xff000fff) != 0x4d000000 &&
-		      (insn & 0xffff0000) != 0xc0e50000)
+		      (insn & 0xffff0000) != 0xc0e50000 &&
+		      (insn & 0xff000000) != 0x0d000000)
 		    invalid_tls_insn (input_bfd, input_section, rel);
-		  if ((insn & 0xff000000) == 0x4d000000)
+
+		  if ((insn & 0xff000000) == 0x0d000000)
+		    {
+		      /* LD->LE transition.
+			 basr rx, ry -> nopr r7 */
+		      insn = 0x07070000 | (insn & 0xffff);
+		    }
+		  else if ((insn & 0xff000000) == 0x4d000000)
 		    {
 		      /* LD->LE transition.
 			 bas %r14,0(%rx,%r13) -> bc 0,0  */
@@ -2977,7 +3276,7 @@
 		  else
 		    {
 		      /* LD->LE transition.
-			 brasl %r14,__tls_get_addr@plt -> brcl 0,. */
+			 brasl %r14,__tls_get_offset@plt -> brcl 0,. */
 		      insn = 0xc0040000;
 		      bfd_put_16 (output_bfd, 0x0000,
 				  contents + rel->r_offset + 4);
@@ -2996,7 +3295,9 @@
 	 not process them.  */
       if (unresolved_reloc
 	  && !((input_section->flags & SEC_DEBUGGING) != 0
-	       && h->def_dynamic))
+	       && h->def_dynamic)
+	  && _bfd_elf_section_offset (output_bfd, info, input_section,
+				      rel->r_offset) != (bfd_vma) -1)
 	(*_bfd_error_handler)
 	  (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
 	   input_bfd,
@@ -3005,6 +3306,15 @@
 	   howto->name,
 	   h->root.root.string);
 
+    do_relocation:
+
+      /* When applying a 24 bit reloc we need to start one byte
+	 earlier.  Otherwise the 32 bit get/put bfd operations might
+	 access a byte after the actual section.  */
+      if (r_type == R_390_PC24DBL
+	  || r_type == R_390_PLT24DBL)
+	rel->r_offset--;
+
       if (r_type == R_390_20
 	  || r_type == R_390_GOT20
 	  || r_type == R_390_GOTPLT20
@@ -3061,17 +3371,163 @@
   return TRUE;
 }
 
+/* Generate the PLT slots together with the dynamic relocations needed
+   for IFUNC symbols.  */
+
+static void
+elf_s390_finish_ifunc_symbol (bfd *output_bfd,
+			      struct bfd_link_info *info,
+			      struct elf_link_hash_entry *h,
+			      struct elf_s390_link_hash_table *htab,
+			      bfd_vma iplt_offset,
+			      bfd_vma resolver_address)
+{
+  bfd_vma iplt_index;
+  bfd_vma got_offset;
+  bfd_vma igotiplt_offset;
+  Elf_Internal_Rela rela;
+  bfd_byte *loc;
+  asection *plt, *gotplt, *relplt;
+  bfd_vma relative_offset;
+
+  if (htab->elf.iplt == NULL
+      || htab->elf.igotplt == NULL
+      || htab->elf.irelplt == NULL)
+    abort ();
+
+  gotplt = htab->elf.igotplt;
+  relplt = htab->elf.irelplt;
+
+  /* Index of the PLT slot within iplt section.  */
+  iplt_index = iplt_offset / PLT_ENTRY_SIZE;
+  plt = htab->elf.iplt;
+  /* Offset into the igot.plt section.  */
+  igotiplt_offset = iplt_index * GOT_ENTRY_SIZE;
+  /* Offset into the got section.  */
+  got_offset = igotiplt_offset + gotplt->output_offset;
+
+  /* S390 uses halfwords for relative branch calc!  */
+  relative_offset = - (plt->output_offset +
+		       (PLT_ENTRY_SIZE * iplt_index) + 18) / 2;
+/* If offset is > 32768, branch to a previous branch
+   390 can only handle +-64 K jumps.  */
+  if ( -32768 > (int) relative_offset )
+    relative_offset
+      = -(unsigned) (((65536 / PLT_ENTRY_SIZE - 1) * PLT_ENTRY_SIZE) / 2);
+
+  /* Fill in the entry in the procedure linkage table.  */
+  if (!info->shared)
+    {
+      memcpy (plt->contents + iplt_offset, elf_s390_plt_entry,
+	      PLT_ENTRY_SIZE);
+
+      /* Adjust jump to the first plt entry.  */
+      bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
+		  plt->contents + iplt_offset + 20);
+
+      /* Push the GOT offset field.  */
+      bfd_put_32 (output_bfd,
+		  (gotplt->output_section->vma
+		   + got_offset),
+		  plt->contents + iplt_offset + 24);
+    }
+  else if (got_offset < 4096)
+    {
+      /* The GOT offset is small enough to be used directly as
+	 displacement.  */
+      memcpy (plt->contents + iplt_offset,
+	      elf_s390_plt_pic12_entry,
+	      PLT_ENTRY_SIZE);
+
+      /* Put in the GOT offset as displacement value.  The 0xc000
+	 value comes from the first word of the plt entry.  Look
+	 at the elf_s390_plt_pic16_entry content.  */
+      bfd_put_16 (output_bfd, (bfd_vma)0xc000 | got_offset,
+		  plt->contents + iplt_offset + 2);
+
+      /* Adjust the jump to the first plt entry.  */
+      bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
+		  plt->contents + iplt_offset + 20);
+    }
+  else if (got_offset < 32768)
+    {
+      /* The GOT offset is too big for a displacement but small
+	 enough to be a signed 16 bit immediate value as it can be
+	 used in an lhi instruction.  */
+      memcpy (plt->contents + iplt_offset,
+	      elf_s390_plt_pic16_entry,
+	      PLT_ENTRY_SIZE);
+
+      /* Put in the GOT offset for the lhi instruction.  */
+      bfd_put_16 (output_bfd, (bfd_vma)got_offset,
+		  plt->contents + iplt_offset + 2);
+
+      /* Adjust the jump to the first plt entry.  */
+      bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
+		  plt->contents + iplt_offset + 20);
+    }
+  else
+    {
+      memcpy (plt->contents + iplt_offset,
+	      elf_s390_plt_pic_entry,
+	      PLT_ENTRY_SIZE);
+
+      /* Adjust the jump to the first plt entry.  */
+      bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
+		  plt->contents + iplt_offset + 20);
+
+      /* Push the GOT offset field.  */
+      bfd_put_32 (output_bfd, got_offset,
+		  plt->contents + iplt_offset + 24);
+    }
+  /* Insert offset into  reloc. table here.  */
+  bfd_put_32 (output_bfd, relplt->output_offset +
+	      iplt_index * RELA_ENTRY_SIZE,
+	      plt->contents + iplt_offset + 28);
+
+  /* Fill in the entry in the global offset table.
+     Points to instruction after GOT offset.  */
+  bfd_put_32 (output_bfd,
+	      (plt->output_section->vma
+	       + plt->output_offset
+	       + iplt_offset
+	       + 12),
+	      gotplt->contents + igotiplt_offset);
+
+  /* Fill in the entry in the .rela.plt section.  */
+  rela.r_offset = gotplt->output_section->vma + got_offset;
+
+  if (!h
+      || h->dynindx == -1
+      || ((info->executable
+	   || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
+	  && h->def_regular))
+    {
+      /* The symbol can be locally resolved.  */
+      rela.r_info = ELF32_R_INFO (0, R_390_IRELATIVE);
+      rela.r_addend = resolver_address;
+    }
+  else
+    {
+      rela.r_info = ELF32_R_INFO (h->dynindx, R_390_JMP_SLOT);
+      rela.r_addend = 0;
+    }
+
+  loc = relplt->contents + iplt_index * RELA_ENTRY_SIZE;
+  bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
+}
+
 /* Finish up dynamic symbol handling.  We set the contents of various
    dynamic sections here.  */
 
 static bfd_boolean
-elf_s390_finish_dynamic_symbol (output_bfd, info, h, sym)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-     struct elf_link_hash_entry *h;
-     Elf_Internal_Sym *sym;
+elf_s390_finish_dynamic_symbol (bfd *output_bfd,
+				struct bfd_link_info *info,
+				struct elf_link_hash_entry *h,
+				Elf_Internal_Sym *sym)
 {
   struct elf_s390_link_hash_table *htab;
+  struct elf_s390_link_hash_entry *eh = (struct elf_s390_link_hash_entry*)h;
 
   htab = elf_s390_hash_table (info);
 
@@ -3085,131 +3541,139 @@
 
       /* This symbol has an entry in the procedure linkage table.  Set
 	 it up.  */
-      if (h->dynindx == -1
-	  || htab->splt == NULL
-	  || htab->sgotplt == NULL
-	  || htab->srelplt == NULL)
-	abort ();
-
-      /* Calc. index no.
-	 Current offset - size first entry / entry size.  */
-      plt_index = (h->plt.offset - PLT_FIRST_ENTRY_SIZE) / PLT_ENTRY_SIZE;
-
-      /* Offset in GOT is PLT index plus GOT headers(3) times 4,
-	 addr & GOT addr.  */
-      got_offset = (plt_index + 3) * GOT_ENTRY_SIZE;
-
-      /* S390 uses halfwords for relative branch calc!  */
-      relative_offset = - ((PLT_FIRST_ENTRY_SIZE +
-			    (PLT_ENTRY_SIZE * plt_index) + 18) / 2);
-      /* If offset is > 32768, branch to a previous branch
-	 390 can only handle +-64 K jumps.  */
-      if ( -32768 > (int) relative_offset )
-	relative_offset
-	  = -(unsigned) (((65536 / PLT_ENTRY_SIZE - 1) * PLT_ENTRY_SIZE) / 2);
-
-      /* Fill in the entry in the procedure linkage table.  */
-      if (!info->shared)
+      if (s390_is_ifunc_symbol_p (h))
 	{
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD0,
-		      htab->splt->contents + h->plt.offset);
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD1,
-		      htab->splt->contents + h->plt.offset + 4);
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD2,
-		      htab->splt->contents + h->plt.offset + 8);
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD3,
-		      htab->splt->contents + h->plt.offset + 12);
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD4,
-		      htab->splt->contents + h->plt.offset + 16);
-	  bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
-		      htab->splt->contents + h->plt.offset + 20);
-	  bfd_put_32 (output_bfd,
-		      (htab->sgotplt->output_section->vma
-		       + htab->sgotplt->output_offset
-		       + got_offset),
-		      htab->splt->contents + h->plt.offset + 24);
-	}
-      else if (got_offset < 4096)
-	{
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD0 + got_offset,
-		      htab->splt->contents + h->plt.offset);
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD1,
-		      htab->splt->contents + h->plt.offset + 4);
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD2,
-		      htab->splt->contents + h->plt.offset + 8);
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD3,
-		      htab->splt->contents + h->plt.offset + 12);
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD4,
-		      htab->splt->contents + h->plt.offset + 16);
-	  bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
-		      htab->splt->contents + h->plt.offset + 20);
-	  bfd_put_32 (output_bfd, (bfd_vma) 0,
-		      htab->splt->contents + h->plt.offset + 24);
-	}
-      else if (got_offset < 32768)
-	{
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD0 + got_offset,
-		      htab->splt->contents + h->plt.offset);
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD1,
-		      htab->splt->contents + h->plt.offset + 4);
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD2,
-		      htab->splt->contents + h->plt.offset + 8);
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD3,
-		      htab->splt->contents + h->plt.offset + 12);
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD4,
-		      htab->splt->contents + h->plt.offset + 16);
-	  bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
-		      htab->splt->contents + h->plt.offset + 20);
-	  bfd_put_32 (output_bfd, (bfd_vma) 0,
-		      htab->splt->contents + h->plt.offset + 24);
+	  /* If we can resolve the IFUNC symbol locally we generate an
+	     IRELATIVE reloc.  */
+	  elf_s390_finish_ifunc_symbol (output_bfd, info, h, htab, h->plt.offset,
+					eh->ifunc_resolver_address +
+					eh->ifunc_resolver_section->output_offset +
+					eh->ifunc_resolver_section->output_section->vma);
+	  /* Fallthrough.  Handling of explicit GOT slots of IFUNC
+	     symbols is below.  */
 	}
       else
 	{
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD0,
-		      htab->splt->contents + h->plt.offset);
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD1,
-		      htab->splt->contents + h->plt.offset + 4);
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD2,
-		      htab->splt->contents + h->plt.offset + 8);
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD3,
-		      htab->splt->contents + h->plt.offset + 12);
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD4,
-		      htab->splt->contents + h->plt.offset + 16);
-	  bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
-		      htab->splt->contents + h->plt.offset + 20);
-	  bfd_put_32 (output_bfd, got_offset,
-		      htab->splt->contents + h->plt.offset + 24);
-	}
-      /* Insert offset into  reloc. table here.  */
-      bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rela),
-		  htab->splt->contents + h->plt.offset + 28);
+	  if (h->dynindx == -1
+	      || htab->elf.splt == NULL
+	      || htab->elf.sgotplt == NULL
+	      || htab->elf.srelplt == NULL)
+	    abort ();
 
-      /* Fill in the entry in the global offset table.
-	 Points to instruction after GOT offset.  */
-      bfd_put_32 (output_bfd,
-		  (htab->splt->output_section->vma
-		   + htab->splt->output_offset
-		   + h->plt.offset
-		   + 12),
-		  htab->sgotplt->contents + got_offset);
+	  /* Calc. index no.
+	     Current offset - size first entry / entry size.  */
+	  plt_index = (h->plt.offset - PLT_FIRST_ENTRY_SIZE) / PLT_ENTRY_SIZE;
 
-      /* Fill in the entry in the .rela.plt section.  */
-      rela.r_offset = (htab->sgotplt->output_section->vma
-		       + htab->sgotplt->output_offset
-		       + got_offset);
-      rela.r_info = ELF32_R_INFO (h->dynindx, R_390_JMP_SLOT);
-      rela.r_addend = 0;
-      loc = htab->srelplt->contents + plt_index * sizeof (Elf32_External_Rela);
-      bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
+	  /* Offset in GOT is PLT index plus GOT headers(3) times 4,
+	     addr & GOT addr.  */
+	  got_offset = (plt_index + 3) * GOT_ENTRY_SIZE;
 
-      if (!h->def_regular)
-	{
-	  /* Mark the symbol as undefined, rather than as defined in
-	     the .plt section.  Leave the value alone.  This is a clue
-	     for the dynamic linker, to make function pointer
-	     comparisons work between an application and shared
-	     library.  */
-	  sym->st_shndx = SHN_UNDEF;
+	  /* S390 uses halfwords for relative branch calc!  */
+	  relative_offset = - ((PLT_FIRST_ENTRY_SIZE +
+				(PLT_ENTRY_SIZE * plt_index) + 18) / 2);
+	  /* If offset is > 32768, branch to a previous branch
+	     390 can only handle +-64 K jumps.  */
+	  if ( -32768 > (int) relative_offset )
+	    relative_offset
+	      = -(unsigned) (((65536 / PLT_ENTRY_SIZE - 1) * PLT_ENTRY_SIZE) / 2);
+
+	  /* Fill in the entry in the procedure linkage table.  */
+	  if (!info->shared)
+	    {
+	      memcpy (htab->elf.splt->contents + h->plt.offset, elf_s390_plt_entry,
+		      PLT_ENTRY_SIZE);
+
+	      /* Adjust jump to the first plt entry.  */
+	      bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
+			  htab->elf.splt->contents + h->plt.offset + 20);
+
+	      /* Push the GOT offset field.  */
+	      bfd_put_32 (output_bfd,
+			  (htab->elf.sgotplt->output_section->vma
+			   + htab->elf.sgotplt->output_offset
+			   + got_offset),
+			  htab->elf.splt->contents + h->plt.offset + 24);
+	    }
+	  else if (got_offset < 4096)
+	    {
+	      /* The GOT offset is small enough to be used directly as
+		 displacement.  */
+	      memcpy (htab->elf.splt->contents + h->plt.offset,
+		      elf_s390_plt_pic12_entry,
+		      PLT_ENTRY_SIZE);
+
+	      /* Put in the GOT offset as displacement value.  The 0xc000
+		 value comes from the first word of the plt entry.  Look
+		 at the elf_s390_plt_pic16_entry content.  */
+	      bfd_put_16 (output_bfd, (bfd_vma)0xc000 | got_offset,
+			  htab->elf.splt->contents + h->plt.offset + 2);
+
+	      /* Adjust the jump to the first plt entry.  */
+	      bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
+			  htab->elf.splt->contents + h->plt.offset + 20);
+	    }
+	  else if (got_offset < 32768)
+	    {
+	      /* The GOT offset is too big for a displacement but small
+		 enough to be a signed 16 bit immediate value as it can be
+		 used in an lhi instruction.  */
+	      memcpy (htab->elf.splt->contents + h->plt.offset,
+		      elf_s390_plt_pic16_entry,
+		      PLT_ENTRY_SIZE);
+
+	      /* Put in the GOT offset for the lhi instruction.  */
+	      bfd_put_16 (output_bfd, (bfd_vma)got_offset,
+			  htab->elf.splt->contents + h->plt.offset + 2);
+
+	      /* Adjust the jump to the first plt entry.  */
+	      bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
+			  htab->elf.splt->contents + h->plt.offset + 20);
+	    }
+	  else
+	    {
+	      memcpy (htab->elf.splt->contents + h->plt.offset,
+		      elf_s390_plt_pic_entry,
+		      PLT_ENTRY_SIZE);
+
+	      /* Adjust the jump to the first plt entry.  */
+	      bfd_put_32 (output_bfd, (bfd_vma) 0+(relative_offset << 16),
+			  htab->elf.splt->contents + h->plt.offset + 20);
+
+	      /* Push the GOT offset field.  */
+	      bfd_put_32 (output_bfd, got_offset,
+			  htab->elf.splt->contents + h->plt.offset + 24);
+	    }
+	  /* Insert offset into  reloc. table here.  */
+	  bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rela),
+		      htab->elf.splt->contents + h->plt.offset + 28);
+
+	  /* Fill in the entry in the global offset table.
+	     Points to instruction after GOT offset.  */
+	  bfd_put_32 (output_bfd,
+		      (htab->elf.splt->output_section->vma
+		       + htab->elf.splt->output_offset
+		       + h->plt.offset
+		       + 12),
+		      htab->elf.sgotplt->contents + got_offset);
+
+	  /* Fill in the entry in the .rela.plt section.  */
+	  rela.r_offset = (htab->elf.sgotplt->output_section->vma
+			   + htab->elf.sgotplt->output_offset
+			   + got_offset);
+	  rela.r_info = ELF32_R_INFO (h->dynindx, R_390_JMP_SLOT);
+	  rela.r_addend = 0;
+	  loc = htab->elf.srelplt->contents + plt_index * sizeof (Elf32_External_Rela);
+	  bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
+
+	  if (!h->def_regular)
+	    {
+	      /* Mark the symbol as undefined, rather than as defined in
+		 the .plt section.  Leave the value alone.  This is a clue
+		 for the dynamic linker, to make function pointer
+		 comparisons work between an application and shared
+		 library.  */
+	      sym->st_shndx = SHN_UNDEF;
+	    }
 	}
     }
 
@@ -3224,11 +3688,11 @@
       /* This symbol has an entry in the global offset table.  Set it
 	 up.  */
 
-      if (htab->sgot == NULL || htab->srelgot == NULL)
+      if (htab->elf.sgot == NULL || htab->elf.srelgot == NULL)
 	abort ();
 
-      rela.r_offset = (htab->sgot->output_section->vma
-		       + htab->sgot->output_offset
+      rela.r_offset = (htab->elf.sgot->output_section->vma
+		       + htab->elf.sgot->output_offset
 		       + (h->got.offset &~ (bfd_vma) 1));
 
       /* If this is a static link, or it is a -Bsymbolic link and the
@@ -3236,9 +3700,37 @@
 	 of a version file, we just want to emit a RELATIVE reloc.
 	 The entry in the global offset table will already have been
 	 initialized in the relocate_section function.  */
-      if (info->shared
+      if (h->def_regular && s390_is_ifunc_symbol_p (h))
+	{
+	  if (info->shared)
+	    {
+	      /* An explicit GOT slot usage needs GLOB_DAT.  If the
+		 symbol references local the implicit got.iplt slot
+		 will be used and the IRELATIVE reloc has been created
+		 above.  */
+	      goto do_glob_dat;
+	    }
+	  else
+	    {
+	      /* For non-shared objects explicit GOT slots must be
+		 filled with the PLT slot address for pointer
+		 equality reasons.  */
+	      bfd_put_32 (output_bfd, (htab->elf.iplt->output_section->vma
+				       + htab->elf.iplt->output_offset
+				       + h->plt.offset),
+			  htab->elf.sgot->contents + h->got.offset);
+	      return TRUE;
+	    }
+	}
+      else if (info->shared
 	  && SYMBOL_REFERENCES_LOCAL (info, h))
 	{
+	  /* If this is a static link, or it is a -Bsymbolic link and
+	     the symbol is defined locally or was forced to be local
+	     because of a version file, we just want to emit a
+	     RELATIVE reloc.  The entry in the global offset table
+	     will already have been initialized in the
+	     relocate_section function.  */
 	  if (!h->def_regular)
 	    return FALSE;
 	  BFD_ASSERT((h->got.offset & 1) != 0);
@@ -3250,13 +3742,14 @@
       else
 	{
 	  BFD_ASSERT((h->got.offset & 1) == 0);
-	  bfd_put_32 (output_bfd, (bfd_vma) 0, htab->sgot->contents + h->got.offset);
+	do_glob_dat:
+	  bfd_put_32 (output_bfd, (bfd_vma) 0, htab->elf.sgot->contents + h->got.offset);
 	  rela.r_info = ELF32_R_INFO (h->dynindx, R_390_GLOB_DAT);
 	  rela.r_addend = 0;
 	}
 
-      loc = htab->srelgot->contents;
-      loc += htab->srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
+      loc = htab->elf.srelgot->contents;
+      loc += htab->elf.srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
       bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
     }
 
@@ -3284,7 +3777,7 @@
     }
 
   /* Mark some specially defined symbols as absolute.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+  if (h == htab->elf.hdynamic
       || h == htab->elf.hgot
       || h == htab->elf.hplt)
     sym->st_shndx = SHN_ABS;
@@ -3296,8 +3789,9 @@
    dynamic linker, before writing them out.  */
 
 static enum elf_reloc_type_class
-elf_s390_reloc_type_class (rela)
-     const Elf_Internal_Rela *rela;
+elf_s390_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			   const asection *rel_sec ATTRIBUTE_UNUSED,
+			   const Elf_Internal_Rela *rela)
 {
   switch ((int) ELF32_R_TYPE (rela->r_info))
     {
@@ -3315,23 +3809,24 @@
 /* Finish up the dynamic sections.  */
 
 static bfd_boolean
-elf_s390_finish_dynamic_sections (output_bfd, info)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
+elf_s390_finish_dynamic_sections (bfd *output_bfd,
+				  struct bfd_link_info *info)
 {
   struct elf_s390_link_hash_table *htab;
   bfd *dynobj;
   asection *sdyn;
+  bfd *ibfd;
+  unsigned int i;
 
   htab = elf_s390_hash_table (info);
   dynobj = htab->elf.dynobj;
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (htab->elf.dynamic_sections_created)
     {
       Elf32_External_Dyn *dyncon, *dynconend;
 
-      if (sdyn == NULL || htab->sgot == NULL)
+      if (sdyn == NULL || htab->elf.sgot == NULL)
 	abort ();
 
       dyncon = (Elf32_External_Dyn *) sdyn->contents;
@@ -3349,15 +3844,15 @@
 	      continue;
 
 	    case DT_PLTGOT:
-	      dyn.d_un.d_ptr = htab->sgot->output_section->vma;
+	      dyn.d_un.d_ptr = htab->elf.sgot->output_section->vma;
 	      break;
 
 	    case DT_JMPREL:
-	      dyn.d_un.d_ptr = htab->srelplt->output_section->vma;
+	      dyn.d_un.d_ptr = htab->elf.srelplt->output_section->vma;
 	      break;
 
 	    case DT_PLTRELSZ:
-	      s = htab->srelplt->output_section;
+	      s = htab->elf.srelplt->output_section;
 	      dyn.d_un.d_val = s->size;
 	      break;
 	    }
@@ -3366,72 +3861,82 @@
 	}
 
       /* Fill in the special first entry in the procedure linkage table.  */
-      if (htab->splt && htab->splt->size > 0)
+      if (htab->elf.splt && htab->elf.splt->size > 0)
 	{
-	  memset (htab->splt->contents, 0, PLT_FIRST_ENTRY_SIZE);
+	  memset (htab->elf.splt->contents, 0, PLT_FIRST_ENTRY_SIZE);
 	  if (info->shared)
 	    {
-	      bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD0,
-			  htab->splt->contents );
-	      bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD1,
-			  htab->splt->contents +4 );
-	      bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD2,
-			  htab->splt->contents +8 );
-	      bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD3,
-			  htab->splt->contents +12 );
-	      bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD4,
-			  htab->splt->contents +16 );
-	   }
+	      memcpy (htab->elf.splt->contents, elf_s390_plt_pic_first_entry,
+		      PLT_FIRST_ENTRY_SIZE);
+	    }
 	  else
-	   {
-	      bfd_put_32 (output_bfd, (bfd_vma)PLT_FIRST_ENTRY_WORD0,
-			  htab->splt->contents );
-	      bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD1,
-			  htab->splt->contents +4 );
-	      bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD2,
-			  htab->splt->contents +8 );
-	      bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD3,
-			  htab->splt->contents +12 );
-	      bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD4,
-			  htab->splt->contents +16 );
-	      bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD5,
-			  htab->splt->contents +20 );
+	    {
+	      memcpy (htab->elf.splt->contents, elf_s390_plt_first_entry,
+		      PLT_FIRST_ENTRY_SIZE);
 	      bfd_put_32 (output_bfd,
-			  htab->sgotplt->output_section->vma
-			  + htab->sgotplt->output_offset,
-			  htab->splt->contents + 24);
+			  htab->elf.sgotplt->output_section->vma
+			  + htab->elf.sgotplt->output_offset,
+			  htab->elf.splt->contents + 24);
 	   }
-	  elf_section_data (htab->splt->output_section)
+	  elf_section_data (htab->elf.splt->output_section)
 	    ->this_hdr.sh_entsize = 4;
 	}
 
     }
 
-  if (htab->sgotplt)
+  if (htab->elf.sgotplt)
     {
       /* Fill in the first three entries in the global offset table.  */
-      if (htab->sgotplt->size > 0)
+      if (htab->elf.sgotplt->size > 0)
 	{
 	  bfd_put_32 (output_bfd,
 		      (sdyn == NULL ? (bfd_vma) 0
 		       : sdyn->output_section->vma + sdyn->output_offset),
-		      htab->sgotplt->contents);
+		      htab->elf.sgotplt->contents);
 	  /* One entry for shared object struct ptr.  */
-	  bfd_put_32 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + 4);
+	  bfd_put_32 (output_bfd, (bfd_vma) 0, htab->elf.sgotplt->contents + 4);
 	  /* One entry for _dl_runtime_resolve.  */
-	  bfd_put_32 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + 8);
+	  bfd_put_32 (output_bfd, (bfd_vma) 0, htab->elf.sgotplt->contents + 8);
 	}
 
-      elf_section_data (htab->sgotplt->output_section)
+      elf_section_data (htab->elf.sgotplt->output_section)
 	->this_hdr.sh_entsize = 4;
     }
+  /* Finish dynamic symbol for local IFUNC symbols.  */
+  for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+    {
+      struct plt_entry *local_plt;
+      Elf_Internal_Sym *isym;
+      Elf_Internal_Shdr *symtab_hdr;
+
+      symtab_hdr = &elf_symtab_hdr (ibfd);
+
+      local_plt = elf_s390_local_plt (ibfd);
+      if (local_plt != NULL)
+	for (i = 0; i < symtab_hdr->sh_info; i++)
+	  {
+	    if (local_plt[i].plt.offset != (bfd_vma) -1)
+	      {
+		asection *sec = local_plt[i].sec;
+		isym = bfd_sym_from_r_symndx (&htab->sym_cache, ibfd, i);
+		if (isym == NULL)
+		  return FALSE;
+
+		if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC)
+		  elf_s390_finish_ifunc_symbol (output_bfd, info, NULL, htab,
+						local_plt[i].plt.offset,
+						isym->st_value
+						+ sec->output_section->vma
+						+ sec->output_offset);
+
+	      }
+	  }
+    }
   return TRUE;
 }
 
 static bfd_boolean
-elf_s390_grok_prstatus (abfd, note)
-     bfd * abfd;
-     Elf_Internal_Note * note;
+elf_s390_grok_prstatus (bfd * abfd, Elf_Internal_Note * note)
 {
   int offset;
   unsigned int size;
@@ -3443,10 +3948,10 @@
 
       case 224:		/* S/390 Linux.  */
 	/* pr_cursig */
-	elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+	elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
 
 	/* pr_pid */
-	elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
+	elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
 
 	/* pr_reg */
 	offset = 72;
@@ -3514,9 +4019,9 @@
 #define elf_backend_relocate_section	      elf_s390_relocate_section
 #define elf_backend_size_dynamic_sections     elf_s390_size_dynamic_sections
 #define elf_backend_init_index_section	      _bfd_elf_init_1_index_section
-#define elf_backend_reloc_type_class	      elf_s390_reloc_type_class
 #define elf_backend_grok_prstatus	      elf_s390_grok_prstatus
 #define elf_backend_plt_sym_val		      elf_s390_plt_sym_val
+#define elf_backend_add_symbol_hook           elf_s390_add_symbol_hook
 
 #define bfd_elf32_mkobject		elf_s390_mkobject
 #define elf_backend_object_p		elf_s390_object_p
diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c
index b437624..47cc987 100644
--- a/bfd/elf32-score.c
+++ b/bfd/elf32-score.c
@@ -1,5 +1,5 @@
 /* 32-bit ELF support for S+core.
-   Copyright 2006, 2007, 2008, 2009, 2010, 2011
+   Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
    Contributed by
    Brain.lin ([email protected])
@@ -1066,7 +1066,7 @@
 static asection *
 score_elf_got_section (bfd *abfd, bfd_boolean maybe_excluded)
 {
-  asection *sgot = bfd_get_section_by_name (abfd, ".got");
+  asection *sgot = bfd_get_linker_section (abfd, ".got");
 
   if (sgot == NULL || (! maybe_excluded && (sgot->flags & SEC_EXCLUDE) != 0))
     return NULL;
@@ -1247,16 +1247,16 @@
   static const char dname[] = ".rel.dyn";
   asection *sreloc;
 
-  sreloc = bfd_get_section_by_name (dynobj, dname);
+  sreloc = bfd_get_linker_section (dynobj, dname);
   if (sreloc == NULL && create_p)
     {
-      sreloc = bfd_make_section_with_flags (dynobj, dname,
-                                            (SEC_ALLOC
-                                             | SEC_LOAD
-                                             | SEC_HAS_CONTENTS
-                                             | SEC_IN_MEMORY
-                                             | SEC_LINKER_CREATED
-                                             | SEC_READONLY));
+      sreloc = bfd_make_section_anyway_with_flags (dynobj, dname,
+						   (SEC_ALLOC
+						    | SEC_LOAD
+						    | SEC_HAS_CONTENTS
+						    | SEC_IN_MEMORY
+						    | SEC_LINKER_CREATED
+						    | SEC_READONLY));
       if (sreloc == NULL
           || ! bfd_set_section_alignment (dynobj, sreloc,
                                           SCORE_ELF_LOG_FILE_ALIGN (dynobj)))
@@ -1429,7 +1429,7 @@
 
   /* We have to use an alignment of 2**4 here because this is hardcoded
      in the function stub generation and in the linker script.  */
-  s = bfd_make_section_with_flags (abfd, ".got", flags);
+  s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
    if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, 4))
     return FALSE;
@@ -2672,9 +2672,9 @@
             }
         }
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
         {
@@ -2837,6 +2837,10 @@
             {
               while (h->root.type == bfd_link_hash_indirect)
                 h = (struct elf_link_hash_entry *)h->root.u.i.link;
+
+	      /* PR15323, ref flags aren't set for references in the
+		 same object.  */
+	      h->root.non_ir_ref = 1;
             }
         }
 
@@ -3123,7 +3127,7 @@
       if (!h->def_regular)
         {
           /* We need .stub section.  */
-          s = bfd_get_section_by_name (dynobj, SCORE_ELF_STUB_SECTION_NAME);
+          s = bfd_get_linker_section (dynobj, SCORE_ELF_STUB_SECTION_NAME);
           BFD_ASSERT (s != NULL);
 
           h->root.u.def.section = s;
@@ -3259,7 +3263,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (!info->shared)
         {
-          s = bfd_get_section_by_name (dynobj, ".interp");
+          s = bfd_get_linker_section (dynobj, ".interp");
           BFD_ASSERT (s != NULL);
           s->size = strlen (ELF_DYNAMIC_INTERPRETER) + 1;
           s->contents = (bfd_byte *) ELF_DYNAMIC_INTERPRETER;
@@ -3417,7 +3421,7 @@
            | SEC_LINKER_CREATED | SEC_READONLY);
 
   /* ABI requests the .dynamic section to be read only.  */
-  s = bfd_get_section_by_name (abfd, ".dynamic");
+  s = bfd_get_linker_section (abfd, ".dynamic");
   if (s != NULL)
     {
       if (!bfd_set_section_flags (abfd, s, flags))
@@ -3432,10 +3436,10 @@
     return FALSE;
 
   /* Create .stub section.  */
-  if (bfd_get_section_by_name (abfd, SCORE_ELF_STUB_SECTION_NAME) == NULL)
+  if (bfd_get_linker_section (abfd, SCORE_ELF_STUB_SECTION_NAME) == NULL)
     {
-      s = bfd_make_section_with_flags (abfd, SCORE_ELF_STUB_SECTION_NAME,
-                                       flags | SEC_CODE);
+      s = bfd_make_section_anyway_with_flags (abfd, SCORE_ELF_STUB_SECTION_NAME,
+					      flags | SEC_CODE);
       if (s == NULL
           || !bfd_set_section_alignment (abfd, s, 2))
 
@@ -3489,7 +3493,7 @@
       /* This symbol has a stub.  Set it up.  */
       BFD_ASSERT (h->dynindx != -1);
 
-      s = bfd_get_section_by_name (dynobj, SCORE_ELF_STUB_SECTION_NAME);
+      s = bfd_get_linker_section (dynobj, SCORE_ELF_STUB_SECTION_NAME);
       BFD_ASSERT (s != NULL);
 
       /* FIXME: Can h->dynindex be more than 64K?  */
@@ -3537,7 +3541,8 @@
 
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
   name = h->root.root.string;
-  if (strcmp (name, "_DYNAMIC") == 0 || strcmp (name, "_GLOBAL_OFFSET_TABLE_") == 0)
+  if (h == elf_hash_table (info)->hdynamic
+      || h == elf_hash_table (info)->hgot)
     sym->st_shndx = SHN_ABS;
   else if (strcmp (name, "_DYNAMIC_LINK") == 0)
     {
@@ -3568,7 +3573,7 @@
 
   dynobj = elf_hash_table (info)->dynobj;
 
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   sgot = score_elf_got_section (dynobj, FALSE);
   if (sgot == NULL)
@@ -3905,10 +3910,12 @@
 
     case 148:                  /* Linux/Score 32-bit.  */
       /* pr_cursig */
-      elf_tdata (abfd)->core_signal = score_bfd_get_16 (abfd, note->descdata + 12);
+      elf_tdata (abfd)->core->signal
+	= score_bfd_get_16 (abfd, note->descdata + 12);
 
       /* pr_pid */
-      elf_tdata (abfd)->core_lwpid = score_bfd_get_32 (abfd, note->descdata + 24);
+      elf_tdata (abfd)->core->lwpid
+	= score_bfd_get_32 (abfd, note->descdata + 24);
 
       /* pr_reg */
       offset = 72;
@@ -3918,7 +3925,8 @@
     }
 
   /* Make a ".reg/999" section.  */
-  return _bfd_elfcore_make_pseudosection (abfd, ".reg", raw_size, note->descpos + offset);
+  return _bfd_elfcore_make_pseudosection (abfd, ".reg", raw_size,
+					  note->descpos + offset);
 }
 
 static bfd_boolean
@@ -3930,8 +3938,10 @@
       return FALSE;
 
     case 124:                  /* Linux/Score elf_prpsinfo.  */
-      elf_tdata (abfd)->core_program = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
-      elf_tdata (abfd)->core_command = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
+      elf_tdata (abfd)->core->program
+	= _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
+      elf_tdata (abfd)->core->command
+	= _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
     }
 
   /* Note that for some reason, a spurious space is tacked
@@ -3939,7 +3949,7 @@
      implementations, so strip it off if it exists.  */
 
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
@@ -4356,7 +4366,7 @@
   struct elf_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_link_hash_table);
 
-  ret = (struct elf_link_hash_table *) bfd_malloc (amt);
+  ret = (struct elf_link_hash_table *) bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
 
diff --git a/bfd/elf32-score.h b/bfd/elf32-score.h
index 54bd092..f315603 100644
--- a/bfd/elf32-score.h
+++ b/bfd/elf32-score.h
@@ -30,10 +30,10 @@
                               struct elf_link_hash_entry *,
                               bfd_boolean);
 
-extern void 
+extern void
 s7_bfd_score_info_to_howto (bfd *, arelent *, Elf_Internal_Rela *);
 
-extern bfd_boolean 
+extern bfd_boolean
 s7_bfd_score_elf_relocate_section (bfd *,
                                    struct bfd_link_info *,
                                    bfd *,
diff --git a/bfd/elf32-score7.c b/bfd/elf32-score7.c
index 3e98bfc..c75c703 100644
--- a/bfd/elf32-score7.c
+++ b/bfd/elf32-score7.c
@@ -1,5 +1,5 @@
 /* 32-bit ELF support for S+core.
-   Copyright 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
    Contributed by
    Brain.lin ([email protected])
    Mei Ligang ([email protected])
@@ -22,8 +22,8 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 #include "libiberty.h"
 #include "elf-bfd.h"
@@ -948,7 +948,7 @@
 static asection *
 score_elf_got_section (bfd *abfd, bfd_boolean maybe_excluded)
 {
-  asection *sgot = bfd_get_section_by_name (abfd, ".got");
+  asection *sgot = bfd_get_linker_section (abfd, ".got");
 
   if (sgot == NULL || (! maybe_excluded && (sgot->flags & SEC_EXCLUDE) != 0))
     return NULL;
@@ -1103,16 +1103,16 @@
   static const char dname[] = ".rel.dyn";
   asection *sreloc;
 
-  sreloc = bfd_get_section_by_name (dynobj, dname);
+  sreloc = bfd_get_linker_section (dynobj, dname);
   if (sreloc == NULL && create_p)
     {
-      sreloc = bfd_make_section_with_flags (dynobj, dname,
-                                            (SEC_ALLOC
-                                             | SEC_LOAD
-                                             | SEC_HAS_CONTENTS
-                                             | SEC_IN_MEMORY
-                                             | SEC_LINKER_CREATED
-                                             | SEC_READONLY));
+      sreloc = bfd_make_section_anyway_with_flags (dynobj, dname,
+						   (SEC_ALLOC
+						    | SEC_LOAD
+						    | SEC_HAS_CONTENTS
+						    | SEC_IN_MEMORY
+						    | SEC_LINKER_CREATED
+						    | SEC_READONLY));
       if (sreloc == NULL
           || ! bfd_set_section_alignment (dynobj, sreloc,
                                           SCORE_ELF_LOG_FILE_ALIGN (dynobj)))
@@ -1286,7 +1286,7 @@
 
   /* We have to use an alignment of 2**4 here because this is hardcoded
      in the function stub generation and in the linker script.  */
-  s = bfd_make_section_with_flags (abfd, ".got", flags);
+  s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
    if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, 4))
     return FALSE;
@@ -2443,9 +2443,9 @@
             }
         }
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
         {
@@ -2641,6 +2641,10 @@
             {
               while (h->root.type == bfd_link_hash_indirect)
                 h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+	      /* PR15323, ref flags aren't set for references in the
+		 same object.  */
+	      h->root.non_ir_ref = 1;
             }
         }
 
@@ -2928,7 +2932,7 @@
       if (!h->def_regular)
         {
           /* We need .stub section.  */
-          s = bfd_get_section_by_name (dynobj, SCORE_ELF_STUB_SECTION_NAME);
+          s = bfd_get_linker_section (dynobj, SCORE_ELF_STUB_SECTION_NAME);
           BFD_ASSERT (s != NULL);
 
           h->root.u.def.section = s;
@@ -3066,7 +3070,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (!info->shared)
         {
-          s = bfd_get_section_by_name (dynobj, ".interp");
+          s = bfd_get_linker_section (dynobj, ".interp");
           BFD_ASSERT (s != NULL);
           s->size = strlen (ELF_DYNAMIC_INTERPRETER) + 1;
           s->contents = (bfd_byte *) ELF_DYNAMIC_INTERPRETER;
@@ -3224,7 +3228,7 @@
            | SEC_LINKER_CREATED | SEC_READONLY);
 
   /* ABI requests the .dynamic section to be read only.  */
-  s = bfd_get_section_by_name (abfd, ".dynamic");
+  s = bfd_get_linker_section (abfd, ".dynamic");
   if (s != NULL)
     {
       if (!bfd_set_section_flags (abfd, s, flags))
@@ -3239,10 +3243,10 @@
     return FALSE;
 
   /* Create .stub section.  */
-  if (bfd_get_section_by_name (abfd, SCORE_ELF_STUB_SECTION_NAME) == NULL)
+  if (bfd_get_linker_section (abfd, SCORE_ELF_STUB_SECTION_NAME) == NULL)
     {
-      s = bfd_make_section_with_flags (abfd, SCORE_ELF_STUB_SECTION_NAME,
-                                       flags | SEC_CODE);
+      s = bfd_make_section_anyway_with_flags (abfd, SCORE_ELF_STUB_SECTION_NAME,
+					      flags | SEC_CODE);
       if (s == NULL
           || !bfd_set_section_alignment (abfd, s, 2))
 
@@ -3297,7 +3301,7 @@
       /* This symbol has a stub.  Set it up.  */
       BFD_ASSERT (h->dynindx != -1);
 
-      s = bfd_get_section_by_name (dynobj, SCORE_ELF_STUB_SECTION_NAME);
+      s = bfd_get_linker_section (dynobj, SCORE_ELF_STUB_SECTION_NAME);
       BFD_ASSERT (s != NULL);
 
       /* FIXME: Can h->dynindex be more than 64K?  */
@@ -3345,7 +3349,8 @@
 
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
   name = h->root.root.string;
-  if (strcmp (name, "_DYNAMIC") == 0 || strcmp (name, "_GLOBAL_OFFSET_TABLE_") == 0)
+  if (h == elf_hash_table (info)->hdynamic
+      || h == elf_hash_table (info)->hgot)
     sym->st_shndx = SHN_ABS;
   else if (strcmp (name, "_DYNAMIC_LINK") == 0)
     {
@@ -3377,7 +3382,7 @@
 
   dynobj = elf_hash_table (info)->dynobj;
 
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   sgot = score_elf_got_section (dynobj, FALSE);
   if (sgot == NULL)
@@ -3721,10 +3726,10 @@
     case 272:                  /* Linux/Score elf_prstatus */
 
       /* pr_cursig */
-      elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+      elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
 
       /* pr_pid */
-      elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
+      elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
 
       /* pr_reg */
       offset = 72;
@@ -3736,7 +3741,8 @@
     }
 
   /* Make a ".reg/999" section.  */
-  return _bfd_elfcore_make_pseudosection (abfd, ".reg", raw_size, note->descpos + offset);
+  return _bfd_elfcore_make_pseudosection (abfd, ".reg", raw_size,
+					  note->descpos + offset);
 }
 
 bfd_boolean
@@ -3749,10 +3755,12 @@
 
     case 128:                  /* Linux/Score elf_prpsinfo.  */
       /* pr_fname */
-      elf_tdata (abfd)->core_program = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
+      elf_tdata (abfd)->core->program
+	= _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
 
       /* pr_psargs */
-      elf_tdata (abfd)->core_command = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
+      elf_tdata (abfd)->core->command
+	= _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
       break;
     }
 
@@ -3761,7 +3769,7 @@
      implementations, so strip it off if it exists.  */
 
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
diff --git a/bfd/elf32-sh-symbian.c b/bfd/elf32-sh-symbian.c
index 0882d52..85c26f3 100644
--- a/bfd/elf32-sh-symbian.c
+++ b/bfd/elf32-sh-symbian.c
@@ -24,7 +24,7 @@
 /* Stop elf32-sh.c from defining any target vectors.  */
 #define SH_TARGET_ALREADY_DEFINED
 #define sh_find_elf_flags           sh_symbian_find_elf_flags
-#define sh_elf_get_flags_from_mach  sh_symbian_elf_get_flags_from_mach 
+#define sh_elf_get_flags_from_mach  sh_symbian_elf_get_flags_from_mach
 #include "elf32-sh.c"
 
 
@@ -129,7 +129,7 @@
 	bfd_set_error (bfd_error_invalid_operation);
 	_bfd_error_handler (_("%B: IMPORT AS directive for %s conceals previous IMPORT AS"),
 			    abfd, current_name);
-	return FALSE;	    
+	return FALSE;
       }
 
   if ((node = bfd_malloc (sizeof * node)) == NULL)
@@ -148,7 +148,7 @@
     }
   else
     strcpy (node->current_name, current_name);
-  
+
   if ((node->new_name = bfd_malloc (strlen (new_name) + 1)) == NULL)
     {
       if (SYMBIAN_DEBUG)
@@ -378,7 +378,7 @@
 	  if (SYMBIAN_DEBUG)
 	    fprintf (stderr, "offset into .directive section: %ld\n",
 		     (long) (directive - (char *) contents));
-	  
+
 	  bfd_set_error (bfd_error_invalid_operation);
 	  _bfd_error_handler (_("%B: Unrecognised .directive command: %s"),
 			      abfd, directive);
@@ -409,7 +409,7 @@
 
   if (!contents)
     bfd_set_error (bfd_error_no_memory);
-  else 
+  else
     {
       if (bfd_get_section_contents (abfd, sec, contents, 0, sz))
 	result = sh_symbian_process_embedded_commands (info, abfd, sec, contents);
@@ -444,9 +444,9 @@
       symbol_rename *                ptr;
       bfd_size_type                  num_global_syms;
       unsigned long		     num_local_syms;
-      
+
       BFD_ASSERT (! elf_bad_symtab (input_bfd));
- 
+
       symtab_hdr       = & elf_tdata (input_bfd)->symtab_hdr;
       hash_table       = elf_hash_table (info);
       num_local_syms   = symtab_hdr->sh_info;
@@ -469,52 +469,37 @@
 		fprintf (stderr, "IMPORT AS: current symbol '%s' does not exist\n", ptr->current_name);
 	      continue;
 	    }
-	  
-	  new_hash = elf_link_hash_lookup (hash_table, ptr->new_name, FALSE, FALSE, TRUE);
 
+	  new_hash = elf_link_hash_lookup (hash_table, ptr->new_name,
+					   FALSE, FALSE, TRUE);
 	  /* If we could not find the symbol then it is a new, undefined symbol.
 	     Symbian want this behaviour - ie they want to be able to rename the
 	     reference in a reloc from one undefined symbol to another, new and
 	     undefined symbol.  So we create that symbol here.  */
 	  if (new_hash == NULL)
 	    {
-	      asection *                     psec = bfd_und_section_ptr;
-	      Elf_Internal_Sym               new_sym;
-	      bfd_vma                        new_value = 0;
-	      bfd_boolean                    skip;
-	      bfd_boolean                    override;
-	      bfd_boolean                    type_change_ok;
-	      bfd_boolean                    size_change_ok;
-
-	      new_sym.st_value = 0;
-	      new_sym.st_size  = 0;
-	      new_sym.st_name  = -1;
-	      new_sym.st_info  = ELF_ST_INFO (STB_GLOBAL, STT_FUNC);
-	      new_sym.st_other = ELF_ST_VISIBILITY (STV_DEFAULT);
-	      new_sym.st_shndx = SHN_UNDEF;
-	      new_sym.st_target_internal = 0;
-
-	      if (! _bfd_elf_merge_symbol (input_bfd, info,
-					   ptr->new_name, & new_sym,
-					   & psec, & new_value, NULL,
-					   & new_hash, & skip,
-					   & override, & type_change_ok,
-					   & size_change_ok))
+	      struct bfd_link_hash_entry *bh = NULL;
+	      bfd_boolean collect = get_elf_backend_data (input_bfd)->collect;
+	      if (_bfd_generic_link_add_one_symbol (info, input_bfd,
+						    ptr->new_name, BSF_GLOBAL,
+						    bfd_und_section_ptr, 0,
+						    NULL, FALSE, collect,
+						    &bh))
 		{
-		  _bfd_error_handler (_("%B: Failed to add renamed symbol %s"),
-				      input_bfd, ptr->new_name);
-		  continue;
+		  new_hash = (struct elf_link_hash_entry *) bh;
+		  new_hash->type = STT_FUNC;
+		  new_hash->non_elf = 0;
+
+		  if (SYMBIAN_DEBUG)
+		    fprintf (stderr, "Created new symbol %s\n", ptr->new_name);
 		}
-	      /* XXX - should we check psec, skip, override etc ?  */
+	    }
 
-	      new_hash->root.type = bfd_link_hash_undefined;
-
-	      /* Allow the symbol to become local if necessary.  */
-	      if (new_hash->dynindx == -1)
-		new_hash->def_regular = 1;
-
-	      if (SYMBIAN_DEBUG)
-		fprintf (stderr, "Created new symbol %s\n", ptr->new_name);
+	  if (new_hash == NULL)
+	    {
+	      _bfd_error_handler (_("%B: Failed to add renamed symbol %s"),
+				  input_bfd, ptr->new_name);
+	      continue;
 	    }
 
 	  /* Convert the new_hash value into a index into the table of symbol hashes.  */
@@ -568,7 +553,7 @@
 	  int                          r_type;
 	  unsigned long                r_symndx;
 	  struct elf_link_hash_entry * h;
-      
+
 	  r_symndx = ELF32_R_SYM (rel->r_info);
 	  r_type = ELF32_R_TYPE (rel->r_info);
 
@@ -612,7 +597,7 @@
 	      }
 	}
     }
-  
+
   return sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 				  contents, relocs, local_syms, local_sections);
 }
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index ca2c4af..86fe1b3 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -1,6 +1,7 @@
 /* Renesas / SuperH SH specific support for 32-bit ELF
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+   2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
+   Free Software Foundation, Inc.
    Contributed by Ian Lance Taylor, Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -2405,7 +2406,7 @@
      and thus require fixups or relocations.  */
   bfd_signed_vma abs_funcdesc_refcount;
 
-  enum {
+  enum got_type {
     GOT_UNKNOWN = 0, GOT_NORMAL, GOT_TLS_GD, GOT_TLS_IE, GOT_FUNCDESC
   } got_type;
 };
@@ -2548,7 +2549,7 @@
   struct elf_sh_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_sh_link_hash_table);
 
-  ret = (struct elf_sh_link_hash_table *) bfd_malloc (amt);
+  ret = (struct elf_sh_link_hash_table *) bfd_zmalloc (amt);
   if (ret == (struct elf_sh_link_hash_table *) NULL)
     return NULL;
 
@@ -2561,17 +2562,6 @@
       return NULL;
     }
 
-  ret->sgot = NULL;
-  ret->sgotplt = NULL;
-  ret->srelgot = NULL;
-  ret->splt = NULL;
-  ret->srelplt = NULL;
-  ret->sdynbss = NULL;
-  ret->srelbss = NULL;
-  ret->srelplt2 = NULL;
-  ret->sym_cache.abfd = NULL;
-  ret->tls_ldm_got.refcount = 0;
-  ret->plt_info = NULL;
   ret->vxworks_p = vxworks_object_p (abfd);
   ret->fdpic_p = fdpic_object_p (abfd);
 
@@ -2621,39 +2611,39 @@
   if (htab == NULL)
     return FALSE;
 
-  htab->sgot = bfd_get_section_by_name (dynobj, ".got");
-  htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
-  htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+  htab->sgot = bfd_get_linker_section (dynobj, ".got");
+  htab->sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
+  htab->srelgot = bfd_get_linker_section (dynobj, ".rela.got");
   if (! htab->sgot || ! htab->sgotplt || ! htab->srelgot)
     abort ();
 
-  htab->sfuncdesc = bfd_make_section_with_flags (dynobj, ".got.funcdesc",
-						 (SEC_ALLOC | SEC_LOAD
-						  | SEC_HAS_CONTENTS
-						  | SEC_IN_MEMORY
-						  | SEC_LINKER_CREATED));
+  htab->sfuncdesc = bfd_make_section_anyway_with_flags (dynobj, ".got.funcdesc",
+							(SEC_ALLOC | SEC_LOAD
+							 | SEC_HAS_CONTENTS
+							 | SEC_IN_MEMORY
+							 | SEC_LINKER_CREATED));
   if (htab->sfuncdesc == NULL
       || ! bfd_set_section_alignment (dynobj, htab->sfuncdesc, 2))
     return FALSE;
 
-  htab->srelfuncdesc = bfd_make_section_with_flags (dynobj,
-						    ".rela.got.funcdesc",
-						    (SEC_ALLOC | SEC_LOAD
-						     | SEC_HAS_CONTENTS
-						     | SEC_IN_MEMORY
-						     | SEC_LINKER_CREATED
-						     | SEC_READONLY));
+  htab->srelfuncdesc = bfd_make_section_anyway_with_flags (dynobj,
+							   ".rela.got.funcdesc",
+							   (SEC_ALLOC | SEC_LOAD
+							    | SEC_HAS_CONTENTS
+							    | SEC_IN_MEMORY
+							    | SEC_LINKER_CREATED
+							    | SEC_READONLY));
   if (htab->srelfuncdesc == NULL
       || ! bfd_set_section_alignment (dynobj, htab->srelfuncdesc, 2))
     return FALSE;
 
   /* Also create .rofixup.  */
-  htab->srofixup = bfd_make_section_with_flags (dynobj, ".rofixup",
-						(SEC_ALLOC | SEC_LOAD
-						 | SEC_HAS_CONTENTS
-						 | SEC_IN_MEMORY
-						 | SEC_LINKER_CREATED
-						 | SEC_READONLY));
+  htab->srofixup = bfd_make_section_anyway_with_flags (dynobj, ".rofixup",
+						       (SEC_ALLOC | SEC_LOAD
+							| SEC_HAS_CONTENTS
+							| SEC_IN_MEMORY
+							| SEC_LINKER_CREATED
+							| SEC_READONLY));
   if (htab->srofixup == NULL
       || ! bfd_set_section_alignment (dynobj, htab->srofixup, 2))
     return FALSE;
@@ -2707,7 +2697,7 @@
   if (bed->plt_readonly)
     pltflags |= SEC_READONLY;
 
-  s = bfd_make_section_with_flags (abfd, ".plt", pltflags);
+  s = bfd_make_section_anyway_with_flags (abfd, ".plt", pltflags);
   htab->splt = s;
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
@@ -2736,9 +2726,10 @@
 	return FALSE;
     }
 
-  s = bfd_make_section_with_flags (abfd,
-				   bed->default_use_rela_p ? ".rela.plt" : ".rel.plt",
-				   flags | SEC_READONLY);
+  s = bfd_make_section_anyway_with_flags (abfd,
+					  bed->default_use_rela_p
+					  ? ".rela.plt" : ".rel.plt",
+					  flags | SEC_READONLY);
   htab->srelplt = s;
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, ptralign))
@@ -2748,32 +2739,6 @@
       && !create_got_section (abfd, info))
     return FALSE;
 
-  {
-    const char *secname;
-    char *relname;
-    flagword secflags;
-    asection *sec;
-
-    for (sec = abfd->sections; sec; sec = sec->next)
-      {
-	secflags = bfd_get_section_flags (abfd, sec);
-	if ((secflags & (SEC_DATA | SEC_LINKER_CREATED))
-	    || ((secflags & SEC_HAS_CONTENTS) != SEC_HAS_CONTENTS))
-	  continue;
-	secname = bfd_get_section_name (abfd, sec);
-	relname = (char *) bfd_malloc ((bfd_size_type) strlen (secname) + 6);
-	strcpy (relname, ".rela");
-	strcat (relname, secname);
-	if (bfd_get_section_by_name (abfd, secname))
-	  continue;
-	s = bfd_make_section_with_flags (abfd, relname,
-					 flags | SEC_READONLY);
-	if (s == NULL
-	    || ! bfd_set_section_alignment (abfd, s, ptralign))
-	  return FALSE;
-      }
-  }
-
   if (bed->want_dynbss)
     {
       /* The .dynbss section is a place to put symbols which are defined
@@ -2782,8 +2747,8 @@
 	 image and use a R_*_COPY reloc to tell the dynamic linker to
 	 initialize them at run time.  The linker script puts the .dynbss
 	 section into the .bss section of the final image.  */
-      s = bfd_make_section_with_flags (abfd, ".dynbss",
-				       SEC_ALLOC | SEC_LINKER_CREATED);
+      s = bfd_make_section_anyway_with_flags (abfd, ".dynbss",
+					      SEC_ALLOC | SEC_LINKER_CREATED);
       htab->sdynbss = s;
       if (s == NULL)
 	return FALSE;
@@ -2801,10 +2766,10 @@
 	 copy relocs.  */
       if (! info->shared)
 	{
-	  s = bfd_make_section_with_flags (abfd,
-					   (bed->default_use_rela_p
-					    ? ".rela.bss" : ".rel.bss"),
-					   flags | SEC_READONLY);
+	  s = bfd_make_section_anyway_with_flags (abfd,
+						  (bed->default_use_rela_p
+						   ? ".rela.bss" : ".rel.bss"),
+						  flags | SEC_READONLY);
 	  htab->srelbss = s;
 	  if (s == NULL
 	      || ! bfd_set_section_alignment (abfd, s, ptralign))
@@ -2926,13 +2891,6 @@
       return TRUE;
     }
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-			     h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -2950,7 +2908,7 @@
      copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rela.bss section we are going to use.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       asection *srel;
 
@@ -3084,7 +3042,7 @@
     {
       asection *s;
       bfd_boolean dyn;
-      int got_type = sh_elf_hash_entry (h)->got_type;
+      enum got_type got_type = sh_elf_hash_entry (h)->got_type;
 
       /* Make sure this symbol is output as a dynamic symbol.
 	 Undefined weak syms won't yet be marked as dynamic.  */
@@ -3110,6 +3068,9 @@
 	      && (got_type == GOT_NORMAL || got_type == GOT_FUNCDESC))
 	    htab->srofixup->size += 4;
 	}
+      /* No dynamic relocations required when IE->LE conversion happens.  */
+      else if (got_type == GOT_TLS_IE && !h->def_dynamic && !info->shared)
+	;
       /* R_SH_TLS_IE_32 needs one dynamic relocation if dynamic,
 	 R_SH_TLS_GD needs one if local symbol and two if global.  */
       else if ((got_type == GOT_TLS_GD && h->dynindx == -1)
@@ -3342,86 +3303,13 @@
 {
   sh_elf_hash_table (info)->plt_info = get_plt_info (output_bfd, info->shared);
 
-  if (sh_elf_hash_table (info)->fdpic_p && !info->relocatable)
-    {
-      struct elf_link_hash_entry *h;
-
-      /* Force a PT_GNU_STACK segment to be created.  */
-      if (! elf_tdata (output_bfd)->stack_flags)
-	elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X;
-
-      /* Define __stacksize if it's not defined yet.  */
-      h = elf_link_hash_lookup (elf_hash_table (info), "__stacksize",
-				FALSE, FALSE, FALSE);
-      if (! h || h->root.type != bfd_link_hash_defined
-	  || h->type != STT_OBJECT
-	  || !h->def_regular)
-	{
-	  struct bfd_link_hash_entry *bh = NULL;
-
-	  if (!(_bfd_generic_link_add_one_symbol
-		(info, output_bfd, "__stacksize",
-		 BSF_GLOBAL, bfd_abs_section_ptr, DEFAULT_STACK_SIZE,
-		 (const char *) NULL, FALSE,
-		 get_elf_backend_data (output_bfd)->collect, &bh)))
-	    return FALSE;
-
-	  h = (struct elf_link_hash_entry *) bh;
-	  h->def_regular = 1;
-	  h->type = STT_OBJECT;
-	}
-    }
+  if (sh_elf_hash_table (info)->fdpic_p && !info->relocatable
+      && !bfd_elf_stack_segment_size (output_bfd, info,
+				      "__stacksize", DEFAULT_STACK_SIZE))
+    return FALSE;
   return TRUE;
 }
 
-#if !defined INCLUDE_SHMEDIA && !defined SH_TARGET_ALREADY_DEFINED
-
-static bfd_boolean
-sh_elf_modify_program_headers (bfd *output_bfd, struct bfd_link_info *info)
-{
-  struct elf_obj_tdata *tdata = elf_tdata (output_bfd);
-  struct elf_segment_map *m;
-  Elf_Internal_Phdr *p;
-
-  /* objcopy and strip preserve what's already there using
-     sh_elf_copy_private_bfd_data ().  */
-  if (! info)
-    return TRUE;
-
-  for (p = tdata->phdr, m = tdata->segment_map; m != NULL; m = m->next, p++)
-    if (m->p_type == PT_GNU_STACK)
-      break;
-
-  if (m)
-    {
-      struct elf_link_hash_entry *h;
-
-      /* Obtain the pointer to the __stacksize symbol.  */
-      h = elf_link_hash_lookup (elf_hash_table (info), "__stacksize",
-				FALSE, FALSE, FALSE);
-      if (h)
-	{
-	  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;
-	  BFD_ASSERT (h->root.type == bfd_link_hash_defined);
-	}
-
-      /* Set the header p_memsz from the symbol value.  We
-	 intentionally ignore the symbol section.  */
-      if (h && h->root.type == bfd_link_hash_defined)
-	p->p_memsz = h->root.u.def.value;
-      else
-	p->p_memsz = DEFAULT_STACK_SIZE;
-
-      p->p_align = 8;
-    }
-
-  return TRUE;
-}
-
-#endif
-
 /* Set the sizes of the dynamic sections.  */
 
 static bfd_boolean
@@ -3446,7 +3334,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
@@ -3788,8 +3676,10 @@
 static unsigned
 sh_elf_osec_to_segment (bfd *output_bfd, asection *osec)
 {
-  Elf_Internal_Phdr *p = _bfd_elf_find_segment_containing_section (output_bfd,
-								   osec);
+  Elf_Internal_Phdr *p = NULL;
+
+  if (output_bfd->xvec->flavour == bfd_target_elf_flavour)
+    p = _bfd_elf_find_segment_containing_section (output_bfd, osec);
 
   /* FIXME: Nothing ever says what this index is relative to.  The kernel
      supplies data in terms of the number of load segments but this is
@@ -3802,7 +3692,8 @@
 {
   unsigned seg = sh_elf_osec_to_segment (output_bfd, osec);
 
-  return ! (elf_tdata (output_bfd)->phdr[seg].p_flags & PF_W);
+  return (seg != (unsigned) -1
+	  && ! (elf_tdata (output_bfd)->phdr[seg].p_flags & PF_W));
 }
 
 /* Generate the initial contents of a local function descriptor, along
@@ -3980,7 +3871,7 @@
       bfd_reloc_status_type r;
       int seen_stt_datalabel = 0;
       bfd_vma off;
-      int got_type;
+      enum got_type got_type;
       const char *symname = NULL;
 
       r_symndx = ELF32_R_SYM (rel->r_info);
@@ -4048,7 +3939,7 @@
 	      _("Unexpected STO_SH5_ISA32 on local symbol is not handled"),
 	      input_bfd, input_section, rel->r_offset));
 
-	  if (sec != NULL && elf_discarded_section (sec))
+	  if (sec != NULL && discarded_section (sec))
 	    /* Handled below.  */
 	    ;
 	  else if (info->relocatable)
@@ -4208,7 +4099,11 @@
 				 STT_DATALABEL on the way to it.  */
 			      | ((h->other & STO_SH5_ISA32) != 0
 				 && ! seen_stt_datalabel));
-	      else if (!info->relocatable)
+	      else if (!info->relocatable
+		       && (_bfd_elf_section_offset (output_bfd, info,
+						    input_section,
+						    rel->r_offset)
+			   != (bfd_vma) -1))
 		{
 		  (*_bfd_error_handler)
 		    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
@@ -4236,9 +4131,9 @@
 	    }
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -4327,7 +4222,7 @@
 	      ((*_bfd_error_handler)
 	       (_("%B: 0x%lx: fatal: unaligned %s relocation 0x%lx"),
 		input_section->owner,
-		(unsigned long) rel->r_offset, howto->name, 
+		(unsigned long) rel->r_offset, howto->name,
 		(unsigned long) relocation));
 	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
@@ -4342,7 +4237,7 @@
 	      ((*_bfd_error_handler)
 	       (_("%B: 0x%lx: fatal: unaligned %s relocation 0x%lx"),
 		input_section->owner,
-		(unsigned long) rel->r_offset, howto->name, 
+		(unsigned long) rel->r_offset, howto->name,
 		(unsigned long) relocation));
 	      bfd_set_error (bfd_error_bad_value);
 	      return FALSE;
@@ -4530,6 +4425,12 @@
 
 	      check_segment[0] = check_segment[1] = -1;
 	    }
+	    /* We don't want warnings for non-NULL tests on undefined weak
+	       symbols.  */
+	    else if (r_type == R_SH_REL32
+		     && h
+		     && h->root.type == bfd_link_hash_undefweak) 
+	      check_segment[0] = check_segment[1] = -1;
 	  goto final_link_relocate;
 
 	case R_SH_GOTPLT32:
@@ -4694,8 +4595,8 @@
 
 		      if (srelgot == NULL)
 			{
-			  srelgot = bfd_get_section_by_name (dynobj,
-							     ".rela.got");
+			  srelgot = bfd_get_linker_section (dynobj,
+							    ".rela.got");
 			  BFD_ASSERT (srelgot != NULL);
 			}
 
@@ -5016,7 +4917,7 @@
 
 		if (srelgot == NULL)
 		  {
-		    srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+		    srelgot = bfd_get_linker_section (dynobj, ".rela.got");
 		    BFD_ASSERT (srelgot != NULL);
 		  }
 
@@ -5306,7 +5207,7 @@
 
 	      if (srelgot == NULL)
 		{
-		  srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+		  srelgot = bfd_get_linker_section (dynobj, ".rela.got");
 		  BFD_ASSERT (srelgot != NULL);
 		}
 
@@ -6027,9 +5928,9 @@
   eind->datalabel_got.refcount = 0;
 #endif
   edir->funcdesc.refcount += eind->funcdesc.refcount;
-  eind->funcdesc.refcount = 0;  
+  eind->funcdesc.refcount = 0;
   edir->abs_funcdesc_refcount += eind->abs_funcdesc_refcount;
-  eind->abs_funcdesc_refcount = 0;  
+  eind->abs_funcdesc_refcount = 0;
 
   if (ind->root.type == bfd_link_hash_indirect
       && dir->got.refcount <= 0)
@@ -6089,7 +5990,7 @@
   const Elf_Internal_Rela *rel_end;
   asection *sreloc;
   unsigned int r_type;
-  int got_type, old_got_type;
+  enum got_type got_type, old_got_type;
 
   sreloc = NULL;
 
@@ -6130,6 +6031,10 @@
 #endif
 	      h = (struct elf_link_hash_entry *) h->root.u.i.link;
 	    }
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       r_type = sh_elf_optimized_tls_reloc (info, r_type, h == NULL);
@@ -6649,7 +6554,7 @@
 
   if (sh_ef_bfd_table[flags] == 0)
     return FALSE;
-  
+
   bfd_default_set_arch_mach (abfd, bfd_arch_sh, sh_ef_bfd_table[flags]);
 
   return TRUE;
@@ -6665,11 +6570,11 @@
 sh_elf_get_flags_from_mach (unsigned long mach)
 {
   int i = ARRAY_SIZE (sh_ef_bfd_table) - 1;
-  
+
   for (; i>0; i--)
     if (sh_ef_bfd_table[i] == mach)
       return i;
-  
+
   /* shouldn't get here */
   BFD_FAIL();
 
@@ -6704,38 +6609,6 @@
   if (! is_sh_elf (ibfd) || ! is_sh_elf (obfd))
     return TRUE;
 
-  /* Copy the stack size.  */
-  if (elf_tdata (ibfd)->phdr && elf_tdata (obfd)->phdr
-      && fdpic_object_p (ibfd) && fdpic_object_p (obfd))
-    {
-      unsigned i;
-
-      for (i = 0; i < elf_elfheader (ibfd)->e_phnum; i++)
-	if (elf_tdata (ibfd)->phdr[i].p_type == PT_GNU_STACK)
-	  {
-	    Elf_Internal_Phdr *iphdr = &elf_tdata (ibfd)->phdr[i];
-
-	    for (i = 0; i < elf_elfheader (obfd)->e_phnum; i++)
-	      if (elf_tdata (obfd)->phdr[i].p_type == PT_GNU_STACK)
-		{
-		  memcpy (&elf_tdata (obfd)->phdr[i], iphdr, sizeof (*iphdr));
-
-		  /* Rewrite the phdrs, since we're only called after they
-		     were first written.  */
-		  if (bfd_seek (obfd,
-				(bfd_signed_vma) get_elf_backend_data (obfd)
-				->s->sizeof_ehdr, SEEK_SET) != 0
-		      || get_elf_backend_data (obfd)->s
-		      ->write_out_phdrs (obfd, elf_tdata (obfd)->phdr,
-					 elf_elfheader (obfd)->e_phnum) != 0)
-		    return FALSE;
-		  break;
-		}
-
-	    break;
-	  }
-    }
-
   return sh_elf_set_private_flags (obfd, elf_elfheader (ibfd)->e_flags);
 }
 #endif /* not sh_elf_copy_private_data */
@@ -7163,8 +7036,7 @@
 		  && (h->root.type == bfd_link_hash_defined
 		      || h->root.type == bfd_link_hash_defweak));
 
-      s = bfd_get_section_by_name (h->root.u.def.section->owner,
-				   ".rela.bss");
+      s = bfd_get_linker_section (htab->root.dynobj, ".rela.bss");
       BFD_ASSERT (s != NULL);
 
       rel.r_offset = (h->root.u.def.value
@@ -7179,7 +7051,7 @@
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  On VxWorks,
      _GLOBAL_OFFSET_TABLE_ is not absolute: it is relative to the
      ".got" section.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+  if (h == htab->root.hdynamic
       || (!htab->vxworks_p && h == htab->root.hgot))
     sym->st_shndx = SHN_ABS;
 
@@ -7200,7 +7072,7 @@
     return FALSE;
 
   sgotplt = htab->sgotplt;
-  sdyn = bfd_get_section_by_name (htab->root.dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (htab->root.dynobj, ".dynamic");
 
   if (htab->root.dynamic_sections_created)
     {
@@ -7372,7 +7244,7 @@
 
   if (sgotplt && sgotplt->size > 0)
     elf_section_data (sgotplt->output_section)->this_hdr.sh_entsize = 4;
-    
+
   /* At the very end of the .rofixup section is a pointer to the GOT.  */
   if (htab->fdpic_p && htab->srofixup != NULL)
     {
@@ -7399,7 +7271,9 @@
 }
 
 static enum elf_reloc_type_class
-sh_elf_reloc_type_class (const Elf_Internal_Rela *rela)
+sh_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			 const asection *rel_sec ATTRIBUTE_UNUSED,
+			 const Elf_Internal_Rela *rela)
 {
   switch ((int) ELF32_R_TYPE (rela->r_info))
     {
@@ -7430,10 +7304,10 @@
 
       case 168:		/* Linux/SH */
 	/* pr_cursig */
-	elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+	elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
 
 	/* pr_pid */
-	elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
+	elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
 
 	/* pr_reg */
 	offset = 72;
@@ -7456,9 +7330,9 @@
 	return FALSE;
 
       case 124:		/* Linux/SH elf_prpsinfo */
-	elf_tdata (abfd)->core_program
+	elf_tdata (abfd)->core->program
 	 = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
-	elf_tdata (abfd)->core_command
+	elf_tdata (abfd)->core->command
 	 = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
     }
 
@@ -7467,7 +7341,7 @@
      implementations, so strip it off if it exists.  */
 
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
@@ -7478,7 +7352,7 @@
 }
 #endif /* not SH_TARGET_ALREADY_DEFINED */
 
- 
+
 /* Return address for Ith PLT stub in section PLT, for relocation REL
    or (bfd_vma) -1 if it should not be included.  */
 
@@ -7609,6 +7483,7 @@
 #define elf_backend_encode_eh_address \
 					sh_elf_encode_eh_address
 
+#define elf_backend_stack_align		8
 #define elf_backend_can_gc_sections	1
 #define elf_backend_can_refcount	1
 #define elf_backend_want_got_plt	1
@@ -7671,9 +7546,6 @@
 #define	TARGET_LITTLE_SYM		bfd_elf32_shfd_vec
 #undef	TARGET_LITTLE_NAME
 #define	TARGET_LITTLE_NAME		"elf32-sh-fdpic"
-#undef elf_backend_modify_program_headers
-#define elf_backend_modify_program_headers \
-					sh_elf_modify_program_headers
 
 #undef	elf32_bed
 #define	elf32_bed			elf32_sh_fd_bed
diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
index f722fcc..52abfd4 100644
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -41,16 +41,16 @@
       return FALSE;
 
     case 260:			/* Solaris prpsinfo_t.  */
-      elf_tdata (abfd)->core_program
+      elf_tdata (abfd)->core->program
 	= _bfd_elfcore_strndup (abfd, note->descdata + 84, 16);
-      elf_tdata (abfd)->core_command
+      elf_tdata (abfd)->core->command
 	= _bfd_elfcore_strndup (abfd, note->descdata + 100, 80);
       break;
 
     case 336:			/* Solaris psinfo_t.  */
-      elf_tdata (abfd)->core_program
+      elf_tdata (abfd)->core->program
 	= _bfd_elfcore_strndup (abfd, note->descdata + 88, 16);
-      elf_tdata (abfd)->core_command
+      elf_tdata (abfd)->core->command
 	= _bfd_elfcore_strndup (abfd, note->descdata + 104, 80);
       break;
     }
@@ -153,7 +153,9 @@
 }
 
 static enum elf_reloc_type_class
-elf32_sparc_reloc_type_class (const Elf_Internal_Rela *rela)
+elf32_sparc_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			      const asection *rel_sec ATTRIBUTE_UNUSED,
+			      const Elf_Internal_Rela *rela)
 {
   switch ((int) ELF32_R_TYPE (rela->r_info))
     {
diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c
index ae3ed10..86fb33c 100644
--- a/bfd/elf32-spu.c
+++ b/bfd/elf32-spu.c
@@ -1,6 +1,6 @@
 /* SPU specific support for 32-bit ELF
 
-   Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+   Copyright 2006-2013 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -439,7 +439,7 @@
 {
   struct spu_link_hash_table *htab;
 
-  htab = bfd_malloc (sizeof (*htab));
+  htab = bfd_zmalloc (sizeof (*htab));
   if (htab == NULL)
     return NULL;
 
@@ -452,9 +452,6 @@
       return NULL;
     }
 
-  memset (&htab->ovtab, 0,
-	  sizeof (*htab) - offsetof (struct spu_link_hash_table, ovtab));
-
   htab->elf.init_got_refcount.refcount = 0;
   htab->elf.init_got_refcount.glist = NULL;
   htab->elf.init_got_offset.offset = 0;
@@ -1145,7 +1142,7 @@
 }
 
 /* Support two sizes of overlay stubs, a slower more compact stub of two
-   intructions, and a faster stub of four instructions.
+   instructions, and a faster stub of four instructions.
    Soft-icache stubs are four or eight words.  */
 
 static unsigned int
@@ -1425,7 +1422,7 @@
 	add = (int) irela->r_addend & 0xffffffff;
       if (add != 0)
 	len += 1 + 8;
-      name = bfd_malloc (len);
+      name = bfd_malloc (len + 1);
       if (name == NULL)
 	return FALSE;
 
@@ -1485,7 +1482,7 @@
     {
       return count_stub (htab, NULL, NULL, nonovl_stub, h, NULL);
     }
-  
+
   return TRUE;
 }
 
@@ -1511,7 +1508,7 @@
       return build_stub (info, NULL, NULL, nonovl_stub, h, NULL,
 			 h->root.u.def.value, sym_sec);
     }
-  
+
   return TRUE;
 }
 
@@ -2154,7 +2151,7 @@
 
   htab->local_store = hi + 1 - lo;
 
-  for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+  for (m = elf_seg_map (abfd); m != NULL; m = m->next)
     if (m->p_type == PT_LOAD)
       for (i = 0; i < m->count; i++)
 	if (m->sections[i]->size != 0
@@ -2948,7 +2945,7 @@
   sec_arr = bfd_zmalloc (bfd_idx * sizeof (*sec_arr));
   if (sec_arr == NULL)
     return FALSE;
-  
+
   for (ibfd = info->input_bfds, bfd_idx = 0;
        ibfd != NULL;
        ibfd = ibfd->link_next, bfd_idx++)
@@ -2981,7 +2978,7 @@
       if (symtab_hdr->contents != NULL)
 	{
 	  /* Don't use cached symbols since the generic ELF linker
-	     code only reads local symbols, and we need globals too.  */ 
+	     code only reads local symbols, and we need globals too.  */
 	  free (symtab_hdr->contents);
 	  symtab_hdr->contents = NULL;
 	}
@@ -4080,7 +4077,7 @@
 			   struct bfd_link_info *info)
 {
   unsigned int j;
-	  
+
   for (j = base; j < count && ovly_map[j] == ovlynum; j++)
     {
       asection *sec = ovly_sections[2 * j];
@@ -4177,7 +4174,7 @@
   /* Find the extents of our loadable image.  */
   lo = (unsigned int) -1;
   hi = 0;
-  for (m = elf_tdata (info->output_bfd)->segment_map; m != NULL; m = m->next)
+  for (m = elf_seg_map (info->output_bfd); m != NULL; m = m->next)
     if (m->p_type == PT_LOAD)
       for (i = 0; i < m->count; i++)
 	if (m->sections[i]->size != 0)
@@ -4895,9 +4892,9 @@
 	  sym_name = h->root.root.string;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -4908,8 +4905,8 @@
 	  && !(h->def_regular || ELF_COMMON_DEF_P (h)))
 	{
 	  bfd_byte *loc = contents + rel->r_offset;
-	  loc[0] = 0x1c; 
-	  loc[1] = 0x00; 
+	  loc[0] = 0x1c;
+	  loc[1] = 0x00;
 	  loc[2] &= 0x3f;
 	}
 
@@ -5000,7 +4997,9 @@
       else if (is_ea_sym)
 	unresolved_reloc = TRUE;
 
-      if (unresolved_reloc)
+      if (unresolved_reloc
+	  && _bfd_elf_section_offset (output_bfd, info, input_section,
+				      rel->r_offset) != (bfd_vma) -1)
 	{
 	  (*_bfd_error_handler)
 	    (_("%B(%s+0x%lx): unresolvable %s relocation against symbol `%s'"),
@@ -5198,7 +5197,7 @@
     return TRUE;
 
   toe = bfd_get_section_by_name (abfd, ".toe");
-  for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+  for (m = elf_seg_map (abfd); m != NULL; m = m->next)
     if (m->p_type == PT_LOAD && m->count > 1)
       for (i = 0; i < m->count; i++)
 	if ((s = m->sections[i]) == toe
@@ -5248,7 +5247,7 @@
      as PF_OVERLAY) will be placed into SPU local store on startup.  */
 
   /* Move all overlay segments onto a separate list.  */
-  p = &elf_tdata (abfd)->segment_map;
+  p = &elf_seg_map (abfd);
   p_overlay = &m_overlay;
   while (*p != NULL)
     {
@@ -5266,8 +5265,8 @@
     }
 
   /* Re-insert overlay segments at the head of the segment map.  */
-  *p_overlay = elf_tdata (abfd)->segment_map;
-  elf_tdata (abfd)->segment_map = m_overlay;
+  *p_overlay = elf_seg_map (abfd);
+  elf_seg_map (abfd) = m_overlay;
 
   return TRUE;
 }
@@ -5302,14 +5301,14 @@
   bed = get_elf_backend_data (abfd);
   tdata = elf_tdata (abfd);
   phdr = tdata->phdr;
-  count = tdata->program_header_size / bed->s->sizeof_phdr;
+  count = elf_program_header_size (abfd) / bed->s->sizeof_phdr;
   htab = spu_hash_table (info);
   if (htab->num_overlays != 0)
     {
       struct elf_segment_map *m;
       unsigned int o;
 
-      for (i = 0, m = elf_tdata (abfd)->segment_map; m; ++i, m = m->next)
+      for (i = 0, m = elf_seg_map (abfd); m; ++i, m = m->next)
 	if (m->count != 0
 	    && (o = spu_elf_section_data (m->sections[0])->u.o.ovl_index) != 0)
 	  {
diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c
index 19287fe..7ac6325 100644
--- a/bfd/elf32-tic6x.c
+++ b/bfd/elf32-tic6x.c
@@ -1,6 +1,5 @@
 /* 32-bit ELF support for TI C6X
-   Copyright 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright 2010-2013 Free Software Foundation, Inc.
    Contributed by Joseph Myers <[email protected]>
    		  Bernd Schmidt  <[email protected]>
 
@@ -1570,7 +1569,7 @@
   struct elf32_tic6x_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf32_tic6x_link_hash_table);
 
-  ret = bfd_malloc (amt);
+  ret = bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
 
@@ -1583,7 +1582,6 @@
       return NULL;
     }
 
-  ret->sym_cache.abfd = NULL;
   ret->obfd = abfd;
   ret->elf.is_relocatable_executable = 1;
 
@@ -1615,14 +1613,6 @@
   return TRUE;
 }
 
-/* Destroy a C6X ELF linker hash table.  */
-
-static void
-elf32_tic6x_link_hash_table_free (struct bfd_link_hash_table *hash)
-{
-  _bfd_generic_link_hash_table_free (hash);
-}
-
 /* Called to pass PARAMS to the backend.  We store them in the hash table
    associated with INFO.  */
 
@@ -1670,9 +1660,9 @@
       || ! bfd_set_section_alignment (dynobj, htab->elf.splt, 5))
     return FALSE;
 
-  htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
+  htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
   if (!info->shared)
-    htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
+    htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
 
   if (!htab->sdynbss
       || (!info->shared && !htab->srelbss))
@@ -1787,7 +1777,7 @@
 	 Get the offset into the .got table of the entry that
 	 corresponds to this function.  Each .got entry is 4 bytes.
 	 The first three are reserved.
-	 
+
 	 For static executables, we don't reserve anything.  */
 
       plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
@@ -1849,8 +1839,8 @@
       /* This symbol has an entry in the global offset table.
          Set it up.  */
 
-      sgot = bfd_get_section_by_name (dynobj, ".got");
-      srela = bfd_get_section_by_name (dynobj, ".rela.got");
+      sgot = bfd_get_linker_section (dynobj, ".got");
+      srela = bfd_get_linker_section (dynobj, ".rela.got");
       BFD_ASSERT (sgot != NULL && srela != NULL);
 
       /* If this is a -Bsymbolic link, and the symbol is defined
@@ -1903,7 +1893,7 @@
     }
 
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+  if (h == elf_hash_table (info)->hdynamic
       || h == elf_hash_table (info)->hgot)
     sym->st_shndx = SHN_ABS;
 
@@ -2157,13 +2147,6 @@
   if (htab == NULL)
     return FALSE;
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-			     h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -2177,7 +2160,7 @@
   /* We must generate a R_C6000_COPY reloc to tell the dynamic linker to
      copy the initial value out of the dynamic object and into the
      runtime process image.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       htab->srelbss->size += sizeof (Elf32_External_Rela);
       h->needs_copy = 1;
@@ -2334,9 +2317,9 @@
 				   unresolved_reloc, warned);
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	{
@@ -2848,6 +2831,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       switch (r_type)
@@ -3050,7 +3037,7 @@
       *secp = bfd_make_section_old_way (abfd, ".scommon");
       (*secp)->flags |= SEC_IS_COMMON;
       *valp = sym->st_size;
-      bfd_set_section_alignment (abfd, *secp, bfd_log2 (sym->st_value));
+      (void) bfd_set_section_alignment (abfd, *secp, bfd_log2 (sym->st_value));
       break;
     }
 
@@ -3312,7 +3299,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  if (s == NULL)
 	    abort ();
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
@@ -3326,8 +3313,6 @@
     {
       bfd_signed_vma *local_got;
       bfd_signed_vma *end_local_got;
-      char *local_tls_type;
-      bfd_vma *local_tlsdesc_gotent;
       bfd_size_type locsymcount;
       Elf_Internal_Shdr *symtab_hdr;
       asection *srel;
@@ -3368,8 +3353,7 @@
       end_local_got = local_got + locsymcount;
       s = htab->elf.sgot;
       srel = htab->elf.srelgot;
-      for (; local_got < end_local_got;
-	   ++local_got, ++local_tls_type, ++local_tlsdesc_gotent)
+      for (; local_got < end_local_got; ++local_got)
 	{
 	  if (*local_got > 0)
 	    {
@@ -3527,79 +3511,10 @@
 static bfd_boolean
 elf32_tic6x_always_size_sections (bfd *output_bfd, struct bfd_link_info *info)
 {
-  if (elf32_tic6x_using_dsbt (output_bfd) && !info->relocatable)
-    {
-      struct elf_link_hash_entry *h;
-
-      /* Force a PT_GNU_STACK segment to be created.  */
-      if (! elf_tdata (output_bfd)->stack_flags)
-	elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X;
-
-      /* Define __stacksize if it's not defined yet.  */
-      h = elf_link_hash_lookup (elf_hash_table (info), "__stacksize",
-				FALSE, FALSE, FALSE);
-      if (! h || h->root.type != bfd_link_hash_defined
-	  || h->type != STT_OBJECT
-	  || !h->def_regular)
-	{
-	  struct bfd_link_hash_entry *bh = NULL;
-
-	  if (!(_bfd_generic_link_add_one_symbol
-		(info, output_bfd, "__stacksize",
-		 BSF_GLOBAL, bfd_abs_section_ptr, DEFAULT_STACK_SIZE,
-		 (const char *) NULL, FALSE,
-		 get_elf_backend_data (output_bfd)->collect, &bh)))
-	    return FALSE;
-
-	  h = (struct elf_link_hash_entry *) bh;
-	  h->def_regular = 1;
-	  h->type = STT_OBJECT;
-	}
-    }
-  return TRUE;
-}
-
-static bfd_boolean
-elf32_tic6x_modify_program_headers (bfd *output_bfd,
-				    struct bfd_link_info *info)
-{
-  struct elf_obj_tdata *tdata = elf_tdata (output_bfd);
-  struct elf_segment_map *m;
-  Elf_Internal_Phdr *p;
-
-  /* objcopy and strip preserve what's already there using
-     elf32_tic6x_copy_private_bfd_data ().  */
-  if (! info)
-    return TRUE;
-
-  for (p = tdata->phdr, m = tdata->segment_map; m != NULL; m = m->next, p++)
-    if (m->p_type == PT_GNU_STACK)
-      break;
-
-  if (m)
-    {
-      struct elf_link_hash_entry *h;
-
-      /* Obtain the pointer to the __stacksize symbol.  */
-      h = elf_link_hash_lookup (elf_hash_table (info), "__stacksize",
-				FALSE, FALSE, FALSE);
-      if (h)
-	{
-	  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;
-	  BFD_ASSERT (h->root.type == bfd_link_hash_defined);
-	}
-
-      /* Set the header p_memsz from the symbol value.  We
-	 intentionally ignore the symbol section.  */
-      if (h && h->root.type == bfd_link_hash_defined)
-	p->p_memsz = h->root.u.def.value;
-      else
-	p->p_memsz = DEFAULT_STACK_SIZE;
-
-      p->p_align = 8;
-    }
+  if (elf32_tic6x_using_dsbt (output_bfd) && !info->relocatable
+      && !bfd_elf_stack_segment_size (output_bfd, info,
+				      "__stacksize", DEFAULT_STACK_SIZE))
+    return FALSE;
 
   return TRUE;
 }
@@ -3614,7 +3529,7 @@
 
   htab = elf32_tic6x_hash_table (info);
   dynobj = htab->elf.dynobj;
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (elf_hash_table (info)->dynamic_sections_created)
     {
@@ -4018,51 +3933,11 @@
   if (!_bfd_generic_verify_endian_match (ibfd, obfd))
     return FALSE;
 
-  if (!elf32_tic6x_merge_attributes (ibfd, obfd))
-    return FALSE;
-
-  return TRUE;
-}
-
-static bfd_boolean
-elf32_tic6x_copy_private_data (bfd * ibfd, bfd * obfd)
-{
-  _bfd_elf_copy_private_bfd_data (ibfd, obfd);
-
   if (! is_tic6x_elf (ibfd) || ! is_tic6x_elf (obfd))
     return TRUE;
 
-  /* Copy the stack size.  */
-  if (elf_tdata (ibfd)->phdr && elf_tdata (obfd)->phdr
-      && elf32_tic6x_using_dsbt (ibfd) && elf32_tic6x_using_dsbt (obfd))
-    {
-      unsigned i;
-
-      for (i = 0; i < elf_elfheader (ibfd)->e_phnum; i++)
-	if (elf_tdata (ibfd)->phdr[i].p_type == PT_GNU_STACK)
-	  {
-	    Elf_Internal_Phdr *iphdr = &elf_tdata (ibfd)->phdr[i];
-
-	    for (i = 0; i < elf_elfheader (obfd)->e_phnum; i++)
-	      if (elf_tdata (obfd)->phdr[i].p_type == PT_GNU_STACK)
-		{
-		  memcpy (&elf_tdata (obfd)->phdr[i], iphdr, sizeof (*iphdr));
-
-		  /* Rewrite the phdrs, since we're only called after they
-		     were first written.  */
-		  if (bfd_seek (obfd,
-				(bfd_signed_vma) get_elf_backend_data (obfd)
-				->s->sizeof_ehdr, SEEK_SET) != 0
-		      || get_elf_backend_data (obfd)->s
-		      ->write_out_phdrs (obfd, elf_tdata (obfd)->phdr,
-					 elf_elfheader (obfd)->e_phnum) != 0)
-		    return FALSE;
-		  break;
-		}
-
-	    break;
-	  }
-    }
+  if (!elf32_tic6x_merge_attributes (ibfd, obfd))
+    return FALSE;
 
   return TRUE;
 }
@@ -4081,11 +3956,11 @@
 {
   tic6x_unwind_table_edit *new_edit = (tic6x_unwind_table_edit *)
       xmalloc (sizeof (tic6x_unwind_table_edit));
-  
+
   new_edit->type = type;
   new_edit->linked_section = linked_section;
   new_edit->index = tindex;
-  
+
   if (tindex > 0)
     {
       new_edit->next = NULL;
@@ -4151,7 +4026,7 @@
 
 /* Scan .cx6abi.exidx tables, and create a list describing edits which
    should be made to those tables, such that:
-   
+
      1. Regions without unwind data are marked with EXIDX_CANTUNWIND entries.
      2. Duplicate entries are merged together (EXIDX_CANTUNWIND, or unwind
         codes which have been inlined into the index).
@@ -4179,15 +4054,15 @@
   for (inp = info->input_bfds; inp != NULL; inp = inp->link_next)
     {
       asection *sec;
-      
+
       for (sec = inp->sections; sec != NULL; sec = sec->next)
         {
 	  struct bfd_elf_section_data *elf_sec = elf_section_data (sec);
 	  Elf_Internal_Shdr *hdr = &elf_sec->this_hdr;
-	  
+
 	  if (!hdr || hdr->sh_type != SHT_C6000_UNWIND)
 	    continue;
-	  
+
 	  if (elf_sec->linked_to)
 	    {
 	      Elf_Internal_Shdr *linked_hdr
@@ -4250,13 +4125,13 @@
       hdr = &elf_section_data (exidx_sec)->this_hdr;
       if (hdr->sh_type != SHT_C6000_UNWIND)
         continue;
-      
+
       exidx_data = get_tic6x_elf_section_data (exidx_sec);
       if (exidx_data == NULL)
         continue;
-      
+
       ibfd = exidx_sec->owner;
-	  
+
       if (hdr->contents != NULL)
 	contents = hdr->contents;
       else if (! bfd_malloc_and_get_section (ibfd, exidx_sec, &contents))
@@ -4309,7 +4184,7 @@
       /* Record edits to be applied later (in elf32_tic6x_write_section).  */
       exidx_data->u.exidx.unwind_edit_list = unwind_edit_head;
       exidx_data->u.exidx.unwind_edit_tail = unwind_edit_tail;
-	  
+
       if (deleted_exidx_bytes > 0)
 	elf32_tic6x_adjust_exidx_size (exidx_sec, -deleted_exidx_bytes);
 
@@ -4347,12 +4222,12 @@
   /* High bit of first word is supposed to be zero.  */
   if ((first_word & 0x80000000ul) == 0)
     first_word = elf32_tic6x_add_low31 (first_word, offset);
-  
+
   /* If the high bit of the first word is clear, and the bit pattern is not 0x1
      (EXIDX_CANTUNWIND), this is an offset to an .c6xabi.extab entry.  */
   if ((second_word != 0x1) && ((second_word & 0x80000000ul) == 0))
     second_word = elf32_tic6x_add_low31 (second_word, offset);
-  
+
   bfd_put_32 (output_bfd, first_word, to);
   bfd_put_32 (output_bfd, second_word, to + 4);
 }
@@ -4398,7 +4273,7 @@
       if (edit_node)
 	{
 	  unsigned int edit_index = edit_node->index;
-	  
+
 	  if (in_index < edit_index && in_index * 8 < input_size)
 	    {
 	      elf32_tic6x_copy_exidx_entry (output_bfd,
@@ -4417,7 +4292,7 @@
 		  in_index++;
 		  add_to_offsets += 8;
 		  break;
-		
+
 		case INSERT_EXIDX_CANTUNWIND_AT_END:
 		  {
 		    asection *text_sec = edit_node->linked_section;
@@ -4447,7 +4322,7 @@
 		  }
 		  break;
 		}
-	      
+
 	      edit_node = edit_node->next;
 	    }
 	}
@@ -4488,12 +4363,11 @@
 #define ELF_MAXPAGESIZE		0x1000
 #define bfd_elf32_bfd_reloc_type_lookup elf32_tic6x_reloc_type_lookup
 #define bfd_elf32_bfd_reloc_name_lookup elf32_tic6x_reloc_name_lookup
-#define bfd_elf32_bfd_copy_private_bfd_data	elf32_tic6x_copy_private_data
 #define bfd_elf32_bfd_merge_private_bfd_data	elf32_tic6x_merge_private_bfd_data
 #define bfd_elf32_mkobject		elf32_tic6x_mkobject
 #define bfd_elf32_bfd_link_hash_table_create  elf32_tic6x_link_hash_table_create
-#define bfd_elf32_bfd_link_hash_table_free    elf32_tic6x_link_hash_table_free
 #define bfd_elf32_new_section_hook	elf32_tic6x_new_section_hook
+#define elf_backend_stack_align		8
 #define elf_backend_can_gc_sections	1
 #define elf_backend_default_use_rela_p	1
 #define elf_backend_may_use_rel_p	1
@@ -4513,8 +4387,6 @@
 #define elf_backend_fake_sections       elf32_tic6x_fake_sections
 #define elf_backend_gc_sweep_hook	elf32_tic6x_gc_sweep_hook
 #define elf_backend_gc_mark_extra_sections elf32_tic6x_gc_mark_extra_sections
-#define elf_backend_modify_program_headers \
-  elf32_tic6x_modify_program_headers
 #define elf_backend_create_dynamic_sections \
   elf32_tic6x_create_dynamic_sections
 #define elf_backend_adjust_dynamic_symbol \
diff --git a/bfd/elf32-tilegx.c b/bfd/elf32-tilegx.c
index 902e9ba..648fbf1 100644
--- a/bfd/elf32-tilegx.c
+++ b/bfd/elf32-tilegx.c
@@ -38,11 +38,11 @@
     return FALSE;
 
   /* pr_cursig */
-  elf_tdata (abfd)->core_signal =
+  elf_tdata (abfd)->core->signal =
     bfd_get_16 (abfd, note->descdata + TILEGX_PRSTATUS_OFFSET_PR_CURSIG);
 
   /* pr_pid */
-  elf_tdata (abfd)->core_pid =
+  elf_tdata (abfd)->core->pid =
     bfd_get_32 (abfd, note->descdata + TILEGX_PRSTATUS_OFFSET_PR_PID);
 
   /* pr_reg */
@@ -60,9 +60,9 @@
   if (note->descsz != TILEGX_PRPSINFO_SIZEOF)
     return FALSE;
 
-  elf_tdata (abfd)->core_program
+  elf_tdata (abfd)->core->program
     = _bfd_elfcore_strndup (abfd, note->descdata + TILEGX_PRPSINFO_OFFSET_PR_FNAME, 16);
-  elf_tdata (abfd)->core_command
+  elf_tdata (abfd)->core->command
     = _bfd_elfcore_strndup (abfd, note->descdata + TILEGX_PRPSINFO_OFFSET_PR_PSARGS, ELF_PR_PSARGS_SIZE);
 
 
@@ -70,7 +70,7 @@
      onto the end of the args in some (at least one anyway)
      implementations, so strip it off if it exists.  */
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
@@ -87,8 +87,10 @@
 #define ELF_MAXPAGESIZE		0x10000
 #define ELF_COMMONPAGESIZE	0x10000
 
-#define TARGET_LITTLE_SYM       bfd_elf32_tilegx_vec
-#define TARGET_LITTLE_NAME	"elf32-tilegx"
+#define TARGET_BIG_SYM          bfd_elf32_tilegx_be_vec
+#define TARGET_BIG_NAME         "elf32-tilegx-be"
+#define TARGET_LITTLE_SYM       bfd_elf32_tilegx_le_vec
+#define TARGET_LITTLE_NAME      "elf32-tilegx-le"
 
 #define elf_backend_reloc_type_class	     tilegx_reloc_type_class
 
diff --git a/bfd/elf32-tilepro.c b/bfd/elf32-tilepro.c
index f2aed9c..c36da2b 100644
--- a/bfd/elf32-tilepro.c
+++ b/bfd/elf32-tilepro.c
@@ -1,5 +1,5 @@
 /* TILEPro-specific support for 32-bit ELF.
-   Copyright 2011 Free Software Foundation, Inc.
+   Copyright 2011, 2012 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -18,8 +18,8 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
 #include "elf/tilepro.h"
@@ -380,12 +380,26 @@
   EMPTY_HOWTO (57),
   EMPTY_HOWTO (58),
   EMPTY_HOWTO (59),
-  EMPTY_HOWTO (60),
-  EMPTY_HOWTO (61),
-  EMPTY_HOWTO (62),
-  EMPTY_HOWTO (63),
-  EMPTY_HOWTO (64),
-  EMPTY_HOWTO (65),
+
+  HOWTO (R_TILEPRO_TLS_GD_CALL, /* type */
+	 TILEPRO_LOG2_BUNDLE_ALIGNMENT_IN_BYTES, /* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 29,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed,/* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_TILEPRO_TLS_GD_CALL", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 -1,			/* dst_mask */
+	 TRUE), 		/* pcrel_offset */
+
+  TILEPRO_IMM_HOWTO(R_TILEPRO_IMM8_X0_TLS_GD_ADD,  0,  8),
+  TILEPRO_IMM_HOWTO(R_TILEPRO_IMM8_X1_TLS_GD_ADD,  0,  8),
+  TILEPRO_IMM_HOWTO(R_TILEPRO_IMM8_Y0_TLS_GD_ADD,  0,  8),
+  TILEPRO_IMM_HOWTO(R_TILEPRO_IMM8_Y1_TLS_GD_ADD,  0,  8),
+  TILEPRO_IMM_HOWTO(R_TILEPRO_TLS_IE_LOAD,  0,  8),
 
   /* Offsets into the GOT of TLS Descriptors. */
 
@@ -454,17 +468,12 @@
 	 -1,			/* dst_mask */
 	 TRUE),			/* pcrel_offset */
 
-#define TILEPRO_IMM16_HOWTO_TLS_IE(name, rshift) \
-  HOWTO (name, rshift, 1, 16, FALSE, 0, \
-         complain_overflow_dont, bfd_elf_generic_reloc, \
-         #name, FALSE, 0, 0xffff, TRUE)
-
-  TILEPRO_IMM16_HOWTO_TLS_IE (R_TILEPRO_IMM16_X0_TLS_IE_LO,  0),
-  TILEPRO_IMM16_HOWTO_TLS_IE (R_TILEPRO_IMM16_X1_TLS_IE_LO,  0),
-  TILEPRO_IMM16_HOWTO_TLS_IE (R_TILEPRO_IMM16_X0_TLS_IE_HI, 16),
-  TILEPRO_IMM16_HOWTO_TLS_IE (R_TILEPRO_IMM16_X1_TLS_IE_HI, 16),
-  TILEPRO_IMM16_HOWTO_TLS_IE (R_TILEPRO_IMM16_X0_TLS_IE_HA, 16),
-  TILEPRO_IMM16_HOWTO_TLS_IE (R_TILEPRO_IMM16_X1_TLS_IE_HA, 16),
+  TILEPRO_IMM16_HOWTO (R_TILEPRO_IMM16_X0_TLS_IE_LO,  0),
+  TILEPRO_IMM16_HOWTO (R_TILEPRO_IMM16_X1_TLS_IE_LO,  0),
+  TILEPRO_IMM16_HOWTO (R_TILEPRO_IMM16_X0_TLS_IE_HI, 16),
+  TILEPRO_IMM16_HOWTO (R_TILEPRO_IMM16_X1_TLS_IE_HI, 16),
+  TILEPRO_IMM16_HOWTO (R_TILEPRO_IMM16_X0_TLS_IE_HA, 16),
+  TILEPRO_IMM16_HOWTO (R_TILEPRO_IMM16_X1_TLS_IE_HA, 16),
 
   /* These are common with the Solaris TLS implementation. */
   HOWTO(R_TILEPRO_TLS_DTPMOD32, 0, 0, 0, FALSE, 0, complain_overflow_dont,
@@ -475,8 +484,42 @@
         FALSE, 0, 0xFFFFFFFF, TRUE),
   HOWTO(R_TILEPRO_TLS_TPOFF32, 0, 0, 0, FALSE, 0, complain_overflow_dont,
         bfd_elf_generic_reloc, "R_TILEPRO_TLS_TPOFF32",
-        FALSE, 0, 0, TRUE)
+        FALSE, 0, 0, TRUE),
 
+  HOWTO (R_TILEPRO_IMM16_X0_TLS_LE,/* type */
+	 0,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_TILEPRO_IMM16_X0_TLS_LE",/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 -1,			/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  HOWTO (R_TILEPRO_IMM16_X1_TLS_LE,/* type */
+	 0,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_TILEPRO_IMM16_X1_TLS_LE",/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 -1,			/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  TILEPRO_IMM16_HOWTO (R_TILEPRO_IMM16_X0_TLS_LE_LO,  0),
+  TILEPRO_IMM16_HOWTO (R_TILEPRO_IMM16_X1_TLS_LE_LO,  0),
+  TILEPRO_IMM16_HOWTO (R_TILEPRO_IMM16_X0_TLS_LE_HI, 16),
+  TILEPRO_IMM16_HOWTO (R_TILEPRO_IMM16_X1_TLS_LE_HI, 16),
+  TILEPRO_IMM16_HOWTO (R_TILEPRO_IMM16_X0_TLS_LE_HA, 16),
+  TILEPRO_IMM16_HOWTO (R_TILEPRO_IMM16_X1_TLS_LE_HA, 16),
 };
 
 static reloc_howto_type tilepro_elf_howto_table2 [] =
@@ -590,6 +633,13 @@
   TH_REMAP (BFD_RELOC_TILEPRO_SHAMT_Y0,    R_TILEPRO_SHAMT_Y0)
   TH_REMAP (BFD_RELOC_TILEPRO_SHAMT_Y1,    R_TILEPRO_SHAMT_Y1)
 
+  TH_REMAP (BFD_RELOC_TILEPRO_TLS_GD_CALL,        R_TILEPRO_TLS_GD_CALL)
+  TH_REMAP (BFD_RELOC_TILEPRO_IMM8_X0_TLS_GD_ADD, R_TILEPRO_IMM8_X0_TLS_GD_ADD)
+  TH_REMAP (BFD_RELOC_TILEPRO_IMM8_X1_TLS_GD_ADD, R_TILEPRO_IMM8_X1_TLS_GD_ADD)
+  TH_REMAP (BFD_RELOC_TILEPRO_IMM8_Y0_TLS_GD_ADD, R_TILEPRO_IMM8_Y0_TLS_GD_ADD)
+  TH_REMAP (BFD_RELOC_TILEPRO_IMM8_Y1_TLS_GD_ADD, R_TILEPRO_IMM8_Y1_TLS_GD_ADD)
+  TH_REMAP (BFD_RELOC_TILEPRO_TLS_IE_LOAD,        R_TILEPRO_TLS_IE_LOAD)
+
   TH_REMAP (BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD,    R_TILEPRO_IMM16_X0_TLS_GD)
   TH_REMAP (BFD_RELOC_TILEPRO_IMM16_X1_TLS_GD,    R_TILEPRO_IMM16_X1_TLS_GD)
   TH_REMAP (BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD_LO, R_TILEPRO_IMM16_X0_TLS_GD_LO)
@@ -612,6 +662,15 @@
   TH_REMAP (BFD_RELOC_TILEPRO_TLS_DTPOFF32, R_TILEPRO_TLS_DTPOFF32)
   TH_REMAP (BFD_RELOC_TILEPRO_TLS_TPOFF32,  R_TILEPRO_TLS_TPOFF32)
 
+  TH_REMAP (BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE,    R_TILEPRO_IMM16_X0_TLS_LE)
+  TH_REMAP (BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE,    R_TILEPRO_IMM16_X1_TLS_LE)
+  TH_REMAP (BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_LO, R_TILEPRO_IMM16_X0_TLS_LE_LO)
+  TH_REMAP (BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_LO, R_TILEPRO_IMM16_X1_TLS_LE_LO)
+  TH_REMAP (BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_HI, R_TILEPRO_IMM16_X0_TLS_LE_HI)
+  TH_REMAP (BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_HI, R_TILEPRO_IMM16_X1_TLS_LE_HI)
+  TH_REMAP (BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_HA, R_TILEPRO_IMM16_X0_TLS_LE_HA)
+  TH_REMAP (BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_HA, R_TILEPRO_IMM16_X1_TLS_LE_HA)
+
 #undef TH_REMAP
 
   { BFD_RELOC_VTABLE_INHERIT, R_TILEPRO_GNU_VTINHERIT, tilepro_elf_howto_table2 },
@@ -678,6 +737,16 @@
    && elf_tdata (bfd) != NULL				\
    && elf_object_id (bfd) == TILEPRO_ELF_DATA)
 
+/* Allocate TILEPro ELF private object data.  */
+
+static bfd_boolean
+tilepro_elf_mkobject (bfd *abfd)
+{
+  return bfd_elf_allocate_object (abfd,
+				  sizeof (struct _bfd_tilepro_elf_obj_tdata),
+				  TILEPRO_ELF_DATA);
+}
+
 #include "elf/common.h"
 #include "elf/internal.h"
 
@@ -745,7 +814,7 @@
 {
   unsigned int r_type = ELF32_R_TYPE (dst->r_info);
 
-  if (r_type <= (unsigned int) R_TILEPRO_TLS_TPOFF32)
+  if (r_type <= (unsigned int) R_TILEPRO_IMM16_X1_TLS_LE_HA)
     cache_ptr->howto = &tilepro_elf_howto_table [r_type];
   else if (r_type - R_TILEPRO_GNU_VTINHERIT
 	   <= (unsigned int) R_TILEPRO_GNU_VTENTRY)
@@ -845,7 +914,20 @@
   create_Imm16_X0,
   create_Imm16_X1,
   create_Imm16_X0,
-  create_Imm16_X1
+  create_Imm16_X1,
+
+  NULL,
+  NULL,
+  NULL,
+
+  create_Imm16_X0,
+  create_Imm16_X1,
+  create_Imm16_X0,
+  create_Imm16_X1,
+  create_Imm16_X0,
+  create_Imm16_X1,
+  create_Imm16_X0,
+  create_Imm16_X1,
 };
 
 #define NELEMS(a)	((int) (sizeof (a) / sizeof ((a)[0])))
@@ -862,11 +944,11 @@
     return FALSE;
 
   /* pr_cursig */
-  elf_tdata (abfd)->core_signal =
+  elf_tdata (abfd)->core->signal =
     bfd_get_16 (abfd, note->descdata + TILEPRO_PRSTATUS_OFFSET_PR_CURSIG);
 
   /* pr_pid */
-  elf_tdata (abfd)->core_pid =
+  elf_tdata (abfd)->core->pid =
     bfd_get_32 (abfd, note->descdata + TILEPRO_PRSTATUS_OFFSET_PR_PID);
 
   /* pr_reg */
@@ -884,11 +966,11 @@
   if (note->descsz != TILEPRO_PRPSINFO_SIZEOF)
     return FALSE;
 
-  elf_tdata (abfd)->core_program
+  elf_tdata (abfd)->core->program
     = _bfd_elfcore_strndup (abfd,
 			    note->descdata + TILEPRO_PRPSINFO_OFFSET_PR_FNAME,
 			    16);
-  elf_tdata (abfd)->core_command
+  elf_tdata (abfd)->core->command
     = _bfd_elfcore_strndup (abfd,
 			    note->descdata + TILEPRO_PRPSINFO_OFFSET_PR_PSARGS,
 			    ELF_PR_PSARGS_SIZE);
@@ -898,7 +980,7 @@
      onto the end of the args in some (at least one anyway)
      implementations, so strip it off if it exists.  */
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
@@ -1033,7 +1115,7 @@
 tilepro_plt_entry_build (asection *splt, asection *sgotplt, bfd_vma offset,
 		      bfd_vma *r_offset)
 {
-  int plt_index = (offset - PLT_HEADER_SIZE) / PLT_ENTRY_SIZE;
+  int plt_index = (offset - PLT_ENTRY_SIZE) / PLT_ENTRY_SIZE;
   int got_offset = plt_index * GOT_ENTRY_SIZE + GOTPLT_HEADER_SIZE;
   tilepro_bundle_bits *pc;
 
@@ -1152,8 +1234,8 @@
   struct elf_link_hash_table *htab = elf_hash_table (info);
 
   /* This function may be called more than once.  */
-  s = bfd_get_section_by_name (abfd, ".got");
-  if (s != NULL && (s->flags & SEC_LINKER_CREATED) != 0)
+  s = bfd_get_linker_section (abfd, ".got");
+  if (s != NULL)
     return TRUE;
 
   flags = bed->dynamic_sec_flags;
@@ -1225,9 +1307,9 @@
   if (!_bfd_elf_create_dynamic_sections (dynobj, info))
     return FALSE;
 
-  htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
+  htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
   if (!info->shared)
-    htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
+    htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
 
   if (!htab->elf.splt || !htab->elf.srelplt || !htab->sdynbss
       || (!info->shared && !htab->srelbss))
@@ -1288,6 +1370,99 @@
   _bfd_elf_link_hash_copy_indirect (info, dir, ind);
 }
 
+static int
+tilepro_tls_translate_to_le (int r_type)
+{
+  switch (r_type)
+    {
+    case R_TILEPRO_IMM16_X0_TLS_GD:
+    case R_TILEPRO_IMM16_X0_TLS_IE:
+      return R_TILEPRO_IMM16_X0_TLS_LE;
+
+    case R_TILEPRO_IMM16_X1_TLS_GD:
+    case R_TILEPRO_IMM16_X1_TLS_IE:
+      return R_TILEPRO_IMM16_X1_TLS_LE;
+
+    case R_TILEPRO_IMM16_X0_TLS_GD_LO:
+    case R_TILEPRO_IMM16_X0_TLS_IE_LO:
+      return R_TILEPRO_IMM16_X0_TLS_LE_LO;
+
+    case R_TILEPRO_IMM16_X1_TLS_GD_LO:
+    case R_TILEPRO_IMM16_X1_TLS_IE_LO:
+      return R_TILEPRO_IMM16_X1_TLS_LE_LO;
+
+    case R_TILEPRO_IMM16_X0_TLS_GD_HI:
+    case R_TILEPRO_IMM16_X0_TLS_IE_HI:
+      return R_TILEPRO_IMM16_X0_TLS_LE_HI;
+
+    case R_TILEPRO_IMM16_X1_TLS_GD_HI:
+    case R_TILEPRO_IMM16_X1_TLS_IE_HI:
+      return R_TILEPRO_IMM16_X1_TLS_LE_HI;
+
+    case R_TILEPRO_IMM16_X0_TLS_GD_HA:
+    case R_TILEPRO_IMM16_X0_TLS_IE_HA:
+      return R_TILEPRO_IMM16_X0_TLS_LE_HA;
+
+    case R_TILEPRO_IMM16_X1_TLS_GD_HA:
+    case R_TILEPRO_IMM16_X1_TLS_IE_HA:
+      return R_TILEPRO_IMM16_X1_TLS_LE_HA;
+    }
+  return r_type;
+}
+
+static int
+tilepro_tls_translate_to_ie (int r_type)
+{
+  switch (r_type)
+    {
+    case R_TILEPRO_IMM16_X0_TLS_GD:
+    case R_TILEPRO_IMM16_X0_TLS_IE:
+      return R_TILEPRO_IMM16_X0_TLS_IE;
+
+    case R_TILEPRO_IMM16_X1_TLS_GD:
+    case R_TILEPRO_IMM16_X1_TLS_IE:
+      return R_TILEPRO_IMM16_X1_TLS_IE;
+
+    case R_TILEPRO_IMM16_X0_TLS_GD_LO:
+    case R_TILEPRO_IMM16_X0_TLS_IE_LO:
+      return R_TILEPRO_IMM16_X0_TLS_IE_LO;
+
+    case R_TILEPRO_IMM16_X1_TLS_GD_LO:
+    case R_TILEPRO_IMM16_X1_TLS_IE_LO:
+      return R_TILEPRO_IMM16_X1_TLS_IE_LO;
+
+    case R_TILEPRO_IMM16_X0_TLS_GD_HI:
+    case R_TILEPRO_IMM16_X0_TLS_IE_HI:
+      return R_TILEPRO_IMM16_X0_TLS_IE_HI;
+
+    case R_TILEPRO_IMM16_X1_TLS_GD_HI:
+    case R_TILEPRO_IMM16_X1_TLS_IE_HI:
+      return R_TILEPRO_IMM16_X1_TLS_IE_HI;
+
+    case R_TILEPRO_IMM16_X0_TLS_GD_HA:
+    case R_TILEPRO_IMM16_X0_TLS_IE_HA:
+      return R_TILEPRO_IMM16_X0_TLS_IE_HA;
+
+    case R_TILEPRO_IMM16_X1_TLS_GD_HA:
+    case R_TILEPRO_IMM16_X1_TLS_IE_HA:
+      return R_TILEPRO_IMM16_X1_TLS_IE_HA;
+    }
+  return r_type;
+}
+
+static int
+tilepro_elf_tls_transition (struct bfd_link_info *info, int r_type,
+			    int is_local)
+{
+  if (info->shared)
+    return r_type;
+
+  if (is_local)
+    return tilepro_tls_translate_to_le (r_type);
+  else
+    return tilepro_tls_translate_to_ie (r_type);
+}
+
 /* Look through the relocs for a section during the first phase, and
    allocate space in the global offset table or procedure linkage
    table.  */
@@ -1346,10 +1521,27 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
+      r_type = tilepro_elf_tls_transition (info, r_type, h == NULL);
       switch (r_type)
 	{
+        case R_TILEPRO_IMM16_X0_TLS_LE:
+        case R_TILEPRO_IMM16_X1_TLS_LE:
+        case R_TILEPRO_IMM16_X0_TLS_LE_LO:
+        case R_TILEPRO_IMM16_X1_TLS_LE_LO:
+        case R_TILEPRO_IMM16_X0_TLS_LE_HI:
+        case R_TILEPRO_IMM16_X1_TLS_LE_HI:
+        case R_TILEPRO_IMM16_X0_TLS_LE_HA:
+        case R_TILEPRO_IMM16_X1_TLS_LE_HA:
+	  if (info->shared)
+	    goto r_tilepro_plt32;
+	  break;
+
         case R_TILEPRO_IMM16_X0_TLS_GD:
         case R_TILEPRO_IMM16_X1_TLS_GD:
         case R_TILEPRO_IMM16_X0_TLS_GD_LO:
@@ -1358,7 +1550,8 @@
         case R_TILEPRO_IMM16_X1_TLS_GD_HI:
         case R_TILEPRO_IMM16_X0_TLS_GD_HA:
         case R_TILEPRO_IMM16_X1_TLS_GD_HA:
-          tls_type = GOT_TLS_GD;
+	  BFD_ASSERT (info->shared);
+	  tls_type = GOT_TLS_GD;
           goto have_got_reference;
 
         case R_TILEPRO_IMM16_X0_TLS_IE:
@@ -1454,6 +1647,24 @@
 	    }
 	  break;
 
+	case R_TILEPRO_TLS_GD_CALL:
+	  if (info->shared)
+	    {
+	      /* These are basically R_TILEPRO_JOFFLONG_X1_PLT relocs
+		 against __tls_get_addr.  */
+	      struct bfd_link_hash_entry *bh = NULL;
+	      if (! _bfd_generic_link_add_one_symbol (info, abfd,
+						      "__tls_get_addr", 0,
+						      bfd_und_section_ptr, 0,
+						      NULL, FALSE, FALSE,
+						      &bh))
+		return FALSE;
+	      h = (struct elf_link_hash_entry *) bh;
+	    }
+	  else
+	    break;
+	  /* Fall through */
+
         case R_TILEPRO_JOFFLONG_X1_PLT:
 	  /* This symbol requires a procedure linkage table entry.  We
 	     actually build the entry in adjust_dynamic_symbol,
@@ -1523,15 +1734,14 @@
         case R_TILEPRO_SHAMT_Y0:
         case R_TILEPRO_SHAMT_Y1:
 	  if (h != NULL)
-            {
               h->non_got_ref = 1;
 
-              if (!info->shared)
-                {
-                  /* We may need a .plt entry if the function this reloc
-                     refers to is in a shared lib.  */
-                  h->plt.refcount += 1;
-                }
+	r_tilepro_plt32:
+	  if (h != NULL && !info->shared)
+	    {
+	      /* We may need a .plt entry if the function this reloc
+		 refers to is in a shared lib.  */
+	      h->plt.refcount += 1;
             }
 
 	  /* If we are creating a shared library, and this is a reloc
@@ -1662,11 +1872,33 @@
   if (h != NULL)
     {
       switch (ELF32_R_TYPE (rel->r_info))
-      {
-      case R_TILEPRO_GNU_VTINHERIT:
-      case R_TILEPRO_GNU_VTENTRY:
-	break;
-      }
+	{
+	case R_TILEPRO_GNU_VTINHERIT:
+	case R_TILEPRO_GNU_VTENTRY:
+	  return NULL;
+	}
+    }
+
+  /* FIXME: The test here, in check_relocs and in relocate_section
+     dealing with TLS optimization, ought to be !info->executable.  */
+  if (info->shared)
+    {
+      switch (ELF32_R_TYPE (rel->r_info))
+	{
+	case R_TILEPRO_TLS_GD_CALL:
+	  /* This reloc implicitly references __tls_get_addr.  We know
+	     another reloc will reference the same symbol as the one
+	     on this reloc, so the real symbol and section will be
+	     gc marked when processing the other reloc.  That lets
+	     us handle __tls_get_addr here.  */
+	  h = elf_link_hash_lookup (elf_hash_table (info), "__tls_get_addr",
+				    FALSE, FALSE, TRUE);
+	  BFD_ASSERT (h != NULL);
+	  h->mark = 1;
+	  if (h->u.weakdef != NULL)
+	    h->u.weakdef->mark = 1;
+	  sym = NULL;
+	}
     }
 
   return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
@@ -1725,6 +1957,7 @@
 	}
 
       r_type = ELF32_R_TYPE (rel->r_info);
+      r_type = tilepro_elf_tls_transition (info, r_type, h != NULL);
       switch (r_type)
 	{
         case R_TILEPRO_IMM16_X0_GOT:
@@ -1758,7 +1991,8 @@
 	    }
 	  else
 	    {
-	      if (local_got_refcounts[r_symndx] > 0)
+	      if (local_got_refcounts &&
+		  local_got_refcounts[r_symndx] > 0)
 		local_got_refcounts[r_symndx]--;
 	    }
 	  break;
@@ -1935,13 +2169,6 @@
       return TRUE;
     }
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-			     h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -1956,7 +2183,7 @@
      to copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rel.bss section we are going to use.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       htab->srelbss->size += TILEPRO_ELF_RELA_BYTES;
       h->needs_copy = 1;
@@ -2002,7 +2229,7 @@
 	  /* Allocate room for the header.  */
 	  if (s->size == 0)
 	    {
-	      s->size = PLT_HEADER_SIZE;
+	      s->size = PLT_ENTRY_SIZE;
 	    }
 
           h->plt.offset = s->size;
@@ -2040,7 +2267,14 @@
       h->needs_plt = 0;
     }
 
-  if (h->got.refcount > 0)
+  /* If a TLS_IE symbol is now local to the binary, make it a TLS_LE
+     requiring no TLS entry.  */
+  if (h->got.refcount > 0
+      && !info->shared
+      && h->dynindx == -1
+      && tilepro_elf_hash_entry(h)->tls_type == GOT_TLS_IE)
+    h->got.offset = (bfd_vma) -1;
+  else if (h->got.refcount > 0)
     {
       asection *s;
       bfd_boolean dyn;
@@ -2229,7 +2463,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF32_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF32_DYNAMIC_INTERPRETER;
@@ -2467,6 +2701,87 @@
   return (address - htab->tls_sec->vma);
 }
 
+/* Replace the MASK bits in ADDR with those in INSN, for the next
+   TILEPRO_BUNDLE_SIZE_IN_BYTES bytes.  */
+
+static void
+tilepro_replace_insn (bfd_byte *addr, const bfd_byte *mask,
+		      const bfd_byte *insn)
+{
+  int i;
+  for (i = 0; i < TILEPRO_BUNDLE_SIZE_IN_BYTES; i++)
+    {
+      addr[i] = (addr[i] & ~mask[i]) | (insn[i] & mask[i]);
+    }
+}
+
+/* Mask to extract the bits corresponding to an instruction in a
+   specific pipe of a bundle.  */
+static const bfd_byte insn_mask_X1[] = {
+  0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x7f
+};
+
+/* Mask to extract the bits corresponding to an instruction in a
+   specific pipe of a bundle, minus the destination operand and the
+   first source operand.  */
+static const bfd_byte insn_mask_X0_no_dest_no_srca[] = {
+  0x00, 0xf0, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00
+};
+
+static const bfd_byte insn_mask_X1_no_dest_no_srca[] = {
+  0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x7f
+};
+
+static const bfd_byte insn_mask_Y0_no_dest_no_srca[] = {
+  0x00, 0xf0, 0x0f, 0x78, 0x00, 0x00, 0x00, 0x00
+};
+
+static const bfd_byte insn_mask_Y1_no_dest_no_srca[] = {
+  0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x07, 0x78
+};
+
+/* Mask to extract the first source operand of an instruction.  */
+static const bfd_byte srca_mask_X0[] = {
+  0xc0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+static const bfd_byte srca_mask_X1[] = {
+  0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00
+};
+
+/* Various instructions synthesized to support tls references.  */
+
+/* move r0, r0 in the X1 pipe, used for tls le.  */
+static const bfd_byte insn_tls_le_move_X1[] = {
+  0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x33, 0x08
+};
+
+/* move r0, zero in the X0 and X1 pipe, used for tls le.  */
+static const bfd_byte insn_tls_le_move_zero_X0X1[] = {
+  0xc0, 0xff, 0xcf, 0x00, 0xe0, 0xff, 0x33, 0x08
+};
+
+/* lw r0, r0 in the X1 pipe, used for tls ie.  */
+static const bfd_byte insn_tls_ie_lw_X1[] = {
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x0b, 0x40
+};
+
+/* add r0, r0, tp in various pipes, used for tls ie.  */
+static const bfd_byte insn_tls_ie_add_X0X1[] = {
+  0x00, 0x50, 0x0f, 0x00, 0x00, 0xa8, 0x07, 0x08
+};
+static const bfd_byte insn_tls_ie_add_Y0Y1[] = {
+  0x00, 0x50, 0x03, 0x08, 0x00, 0xa8, 0x01, 0x8c
+};
+
+/* move r0, r0 in various pipes, used for tls gd.  */
+static const bfd_byte insn_tls_gd_add_X0X1[] = {
+  0x00, 0xf0, 0xcf, 0x00, 0x00, 0xf8, 0x33, 0x08
+};
+static const bfd_byte insn_tls_gd_add_Y0Y1[] = {
+  0x00, 0xf0, 0x0b, 0x18, 0x00, 0xf8, 0x05, 0x9c
+};
+
 /* Relocate an TILEPRO ELF section.
 
    The RELOCATE_SECTION function is called by the new ELF backend linker
@@ -2531,6 +2846,7 @@
   for (; rel < relend; rel++)
     {
       int r_type, tls_type;
+      bfd_boolean is_tls_iele, is_tls_le;
       reloc_howto_type *howto;
       unsigned long r_symndx;
       struct elf_link_hash_entry *h;
@@ -2594,9 +2910,9 @@
 	    }
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -2613,6 +2929,118 @@
 
       switch (r_type)
 	{
+	case R_TILEPRO_TLS_GD_CALL:
+	case R_TILEPRO_IMM8_X0_TLS_GD_ADD:
+	case R_TILEPRO_IMM8_Y0_TLS_GD_ADD:
+	case R_TILEPRO_IMM8_X1_TLS_GD_ADD:
+	case R_TILEPRO_IMM8_Y1_TLS_GD_ADD:
+	case R_TILEPRO_IMM16_X0_TLS_GD_HA:
+	case R_TILEPRO_IMM16_X1_TLS_GD_HA:
+	case R_TILEPRO_IMM16_X0_TLS_IE_HA:
+	case R_TILEPRO_IMM16_X1_TLS_IE_HA:
+	  tls_type = GOT_UNKNOWN;
+	  if (h == NULL && local_got_offsets)
+	    tls_type =
+	      _bfd_tilepro_elf_local_got_tls_type (input_bfd) [r_symndx];
+	  else if (h != NULL)
+	    tls_type = tilepro_elf_hash_entry(h)->tls_type;
+
+	  is_tls_iele = (! info->shared || tls_type == GOT_TLS_IE);
+	  is_tls_le = is_tls_iele && (!info->shared
+				      && (h == NULL || h->dynindx == -1));
+
+	  if (r_type == R_TILEPRO_TLS_GD_CALL)
+	    {
+	      if (is_tls_le)
+		{
+		  /* GD -> LE */
+		  tilepro_replace_insn (contents + rel->r_offset,
+					insn_mask_X1, insn_tls_le_move_X1);
+		  continue;
+		}
+	      else if (is_tls_iele)
+		{
+		  /* GD -> IE */
+		  tilepro_replace_insn (contents + rel->r_offset,
+					insn_mask_X1, insn_tls_ie_lw_X1);
+		  continue;
+		}
+
+	      /* GD -> GD */
+	      h = (struct elf_link_hash_entry *)
+		bfd_link_hash_lookup (info->hash, "__tls_get_addr", FALSE,
+				      FALSE, TRUE);
+	      BFD_ASSERT (h != NULL);
+	      r_type = R_TILEPRO_JOFFLONG_X1_PLT;
+	      howto = tilepro_elf_howto_table + r_type;
+	    }
+	  else if (r_type == R_TILEPRO_IMM16_X0_TLS_GD_HA
+		   || r_type == R_TILEPRO_IMM16_X0_TLS_IE_HA)
+	    {
+	      if (is_tls_le)
+		tilepro_replace_insn (contents + rel->r_offset, srca_mask_X0,
+				      insn_tls_le_move_zero_X0X1);
+	    }
+	  else if (r_type == R_TILEPRO_IMM16_X1_TLS_GD_HA
+		   || r_type == R_TILEPRO_IMM16_X1_TLS_IE_HA)
+	    {
+	      if (is_tls_le)
+		tilepro_replace_insn (contents + rel->r_offset, srca_mask_X1,
+				      insn_tls_le_move_zero_X0X1);
+	    }
+	  else
+	    {
+	      const bfd_byte *mask = NULL;
+	      const bfd_byte *add_insn = NULL;
+
+	      switch (r_type)
+		{
+		case R_TILEPRO_IMM8_X0_TLS_GD_ADD:
+		  add_insn = is_tls_iele ? insn_tls_ie_add_X0X1
+		    : insn_tls_gd_add_X0X1;
+		  mask = insn_mask_X0_no_dest_no_srca;
+		  break;
+		case R_TILEPRO_IMM8_X1_TLS_GD_ADD:
+		  add_insn = is_tls_iele ? insn_tls_ie_add_X0X1
+		    : insn_tls_gd_add_X0X1;
+		  mask = insn_mask_X1_no_dest_no_srca;
+		  break;
+		case R_TILEPRO_IMM8_Y0_TLS_GD_ADD:
+		  add_insn = is_tls_iele ? insn_tls_ie_add_Y0Y1
+		    : insn_tls_gd_add_Y0Y1;
+		  mask = insn_mask_Y0_no_dest_no_srca;
+		  break;
+		case R_TILEPRO_IMM8_Y1_TLS_GD_ADD:
+		  add_insn = is_tls_iele ? insn_tls_ie_add_Y0Y1
+		    : insn_tls_gd_add_Y0Y1;
+		  mask = insn_mask_Y1_no_dest_no_srca;
+		  break;
+		}
+
+	      tilepro_replace_insn (contents + rel->r_offset, mask, add_insn);
+
+	      continue;
+	    }
+	  break;
+	case R_TILEPRO_TLS_IE_LOAD:
+	  if (!info->shared && (h == NULL || h->dynindx == -1))
+	    /* IE -> LE */
+	    tilepro_replace_insn (contents + rel->r_offset,
+				  insn_mask_X1_no_dest_no_srca,
+				  insn_tls_le_move_X1);
+	  else
+	    /* IE -> IE */
+	    tilepro_replace_insn (contents + rel->r_offset,
+				  insn_mask_X1_no_dest_no_srca,
+				  insn_tls_ie_lw_X1);
+	  continue;
+	  break;
+	default:
+	  break;
+	}
+
+      switch (r_type)
+	{
         case R_TILEPRO_IMM16_X0_GOT:
         case R_TILEPRO_IMM16_X1_GOT:
         case R_TILEPRO_IMM16_X0_GOT_LO:
@@ -2700,7 +3128,7 @@
 		  local_got_offsets[r_symndx] |= 1;
 		}
 	    }
-	  relocation = htab->elf.sgot->output_offset + off - got_base;
+	  relocation = off - got_base;
 	  break;
 
         case R_TILEPRO_JOFFLONG_X1_PLT:
@@ -2908,6 +3336,45 @@
 	    }
 	  break;
 
+        case R_TILEPRO_IMM16_X0_TLS_LE:
+        case R_TILEPRO_IMM16_X1_TLS_LE:
+        case R_TILEPRO_IMM16_X0_TLS_LE_LO:
+        case R_TILEPRO_IMM16_X1_TLS_LE_LO:
+        case R_TILEPRO_IMM16_X0_TLS_LE_HI:
+        case R_TILEPRO_IMM16_X1_TLS_LE_HI:
+        case R_TILEPRO_IMM16_X0_TLS_LE_HA:
+        case R_TILEPRO_IMM16_X1_TLS_LE_HA:
+	  if (info->shared)
+	    {
+	      Elf_Internal_Rela outrel;
+	      bfd_boolean skip;
+
+	      BFD_ASSERT (sreloc != NULL);
+	      skip = FALSE;
+	      outrel.r_offset =
+		_bfd_elf_section_offset (output_bfd, info, input_section,
+					 rel->r_offset);
+	      if (outrel.r_offset == (bfd_vma) -1)
+		skip = TRUE;
+	      else if (outrel.r_offset == (bfd_vma) -2)
+		skip = TRUE;
+	      outrel.r_offset += (input_section->output_section->vma
+				  + input_section->output_offset);
+	      if (skip)
+		memset (&outrel, 0, sizeof outrel);
+	      else
+		{
+		  outrel.r_info = ELF32_R_INFO (0, r_type);
+		  outrel.r_addend = relocation - dtpoff_base (info)
+				    + rel->r_addend;
+		}
+
+	      tilepro_elf_append_rela_32 (output_bfd, sreloc, &outrel);
+	      continue;
+	    }
+	  relocation = tpoff (info, relocation);
+	  break;
+
         case R_TILEPRO_IMM16_X0_TLS_GD:
         case R_TILEPRO_IMM16_X1_TLS_GD:
         case R_TILEPRO_IMM16_X0_TLS_GD_LO:
@@ -2916,9 +3383,6 @@
         case R_TILEPRO_IMM16_X1_TLS_GD_HI:
         case R_TILEPRO_IMM16_X0_TLS_GD_HA:
         case R_TILEPRO_IMM16_X1_TLS_GD_HA:
-          tls_type = GOT_TLS_GD;
-          goto have_tls_reference;
-
         case R_TILEPRO_IMM16_X0_TLS_IE:
         case R_TILEPRO_IMM16_X1_TLS_IE:
         case R_TILEPRO_IMM16_X0_TLS_IE_LO:
@@ -2927,45 +3391,32 @@
         case R_TILEPRO_IMM16_X1_TLS_IE_HI:
         case R_TILEPRO_IMM16_X0_TLS_IE_HA:
         case R_TILEPRO_IMM16_X1_TLS_IE_HA:
-          tls_type = GOT_TLS_IE;
-          /* Fall through. */
-
-        have_tls_reference:
+	  r_type = tilepro_elf_tls_transition (info, r_type, h == NULL);
+          tls_type = GOT_UNKNOWN;
 	  if (h == NULL && local_got_offsets)
 	    tls_type
 	      = _bfd_tilepro_elf_local_got_tls_type (input_bfd) [r_symndx];
 	  else if (h != NULL)
 	    {
 	      tls_type = tilepro_elf_hash_entry(h)->tls_type;
+	      if (!info->shared && h->dynindx == -1 && tls_type == GOT_TLS_IE)
+		r_type = tilepro_tls_translate_to_le (r_type);
 	    }
 	  if (tls_type == GOT_TLS_IE)
-	    switch (r_type)
-	      {
-              case R_TILEPRO_IMM16_X0_TLS_GD:
-                r_type = R_TILEPRO_IMM16_X0_TLS_IE;
-                break;
-              case R_TILEPRO_IMM16_X1_TLS_GD:
-                r_type = R_TILEPRO_IMM16_X1_TLS_IE;
-                break;
-              case R_TILEPRO_IMM16_X0_TLS_GD_LO:
-                r_type = R_TILEPRO_IMM16_X0_TLS_IE_LO;
-                break;
-              case R_TILEPRO_IMM16_X1_TLS_GD_LO:
-                r_type = R_TILEPRO_IMM16_X1_TLS_IE_LO;
-                break;
-              case R_TILEPRO_IMM16_X0_TLS_GD_HI:
-                r_type = R_TILEPRO_IMM16_X0_TLS_IE_HI;
-                break;
-              case R_TILEPRO_IMM16_X1_TLS_GD_HI:
-                r_type = R_TILEPRO_IMM16_X1_TLS_IE_HI;
-                break;
-              case R_TILEPRO_IMM16_X0_TLS_GD_HA:
-                r_type = R_TILEPRO_IMM16_X0_TLS_IE_HA;
-                break;
-              case R_TILEPRO_IMM16_X1_TLS_GD_HA:
-                r_type = R_TILEPRO_IMM16_X1_TLS_IE_HA;
-                break;
-	      }
+	    r_type = tilepro_tls_translate_to_ie (r_type);
+
+	  if (r_type == R_TILEPRO_IMM16_X0_TLS_LE
+	      || r_type == R_TILEPRO_IMM16_X1_TLS_LE
+	      || r_type == R_TILEPRO_IMM16_X0_TLS_LE_LO
+	      || r_type == R_TILEPRO_IMM16_X1_TLS_LE_LO
+	      || r_type == R_TILEPRO_IMM16_X0_TLS_LE_HI
+	      || r_type == R_TILEPRO_IMM16_X1_TLS_LE_HI
+	      || r_type == R_TILEPRO_IMM16_X0_TLS_LE_HA
+	      || r_type == R_TILEPRO_IMM16_X1_TLS_LE_HA)
+	    {
+	      relocation = tpoff (info, relocation);
+	      break;
+	    }
 
 	  if (h != NULL)
 	    {
@@ -3096,7 +3547,7 @@
 	  if (off >= (bfd_vma) -2)
 	    abort ();
 
-	  relocation = htab->elf.sgot->output_offset + off - got_base;
+	  relocation = off - got_base;
 	  unresolved_reloc = FALSE;
 	  howto = tilepro_elf_howto_table + r_type;
 	  break;
@@ -3110,7 +3561,9 @@
 	 not process them.  */
       if (unresolved_reloc
 	  && !((input_section->flags & SEC_DEBUGGING) != 0
-	       && h->def_dynamic))
+	       && h->def_dynamic)
+	  && _bfd_elf_section_offset (output_bfd, info, input_section,
+				      rel->r_offset) != (bfd_vma) -1)
 	(*_bfd_error_handler)
 	  (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
 	   input_bfd,
@@ -3358,8 +3811,7 @@
       /* This symbols needs a copy reloc.  Set it up.  */
       BFD_ASSERT (h->dynindx != -1);
 
-      s = bfd_get_section_by_name (h->root.u.def.section->owner,
-				   ".rela.bss");
+      s = htab->srelbss;
       BFD_ASSERT (s != NULL);
 
       rela.r_offset = (h->root.u.def.value
@@ -3371,7 +3823,7 @@
     }
 
   /* Mark some specially defined symbols as absolute. */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+  if (h == htab->elf.hdynamic
       || (h == htab->elf.hgot || h == htab->elf.hplt))
     sym->st_shndx = SHN_ABS;
 
@@ -3434,14 +3886,14 @@
   BFD_ASSERT (htab != NULL);
   dynobj = htab->elf.dynobj;
 
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       asection *splt;
       bfd_boolean ret;
 
-      splt = bfd_get_section_by_name (dynobj, ".plt");
+      splt = htab->elf.splt;
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       ret = tilepro_finish_dyn (output_bfd, info, dynobj, sdyn, splt);
@@ -3451,10 +3903,15 @@
 
       /* Fill in the first entry in the procedure linkage table.  */
       if (splt->size > 0)
-        memcpy (splt->contents, tilepro_plt0_entry, PLT_HEADER_SIZE);
+	{
+	  memcpy (splt->contents, tilepro_plt0_entry, PLT_HEADER_SIZE);
+	  memset (splt->contents + PLT_HEADER_SIZE, 0,
+		  PLT_ENTRY_SIZE - PLT_HEADER_SIZE);
+	}
 
-      elf_section_data (splt->output_section)->this_hdr.sh_entsize
-	= PLT_ENTRY_SIZE;
+      if (elf_section_data (splt->output_section) != NULL)
+	elf_section_data (splt->output_section)->this_hdr.sh_entsize
+	  = PLT_ENTRY_SIZE;
     }
 
   if (htab->elf.sgotplt)
@@ -3508,11 +3965,13 @@
 tilepro_elf_plt_sym_val (bfd_vma i, const asection *plt,
                       const arelent *rel ATTRIBUTE_UNUSED)
 {
-  return plt->vma + PLT_HEADER_SIZE + i * PLT_ENTRY_SIZE;
+  return plt->vma + (i + 1) * PLT_ENTRY_SIZE;
 }
 
 static enum elf_reloc_type_class
-tilepro_reloc_type_class (const Elf_Internal_Rela *rela)
+tilepro_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			  const asection *rel_sec ATTRIBUTE_UNUSED,
+			  const Elf_Internal_Rela *rela)
 {
   switch ((int) ELF32_R_TYPE (rela->r_info))
     {
@@ -3588,6 +4047,8 @@
 #define elf_backend_grok_psinfo              tilepro_elf_grok_psinfo
 #define elf_backend_additional_program_headers tilepro_additional_program_headers
 
+#define bfd_elf32_mkobject		     tilepro_elf_mkobject
+
 #define elf_backend_init_index_section	_bfd_elf_init_1_index_section
 
 #define elf_backend_can_gc_sections 1
diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c
index 9e6f77d..89724ad 100644
--- a/bfd/elf32-v850.c
+++ b/bfd/elf32-v850.c
@@ -1,6 +1,5 @@
 /* V850-specific support for 32-bit ELF
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2006, 2007, 2008, 2009, 2010, 2011  Free Software Foundation, Inc.
+   Copyright 1996-2013 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -54,7 +53,7 @@
   struct elf_link_hash_entry **sym_hashes;
   const Elf_Internal_Rela *rel;
   const Elf_Internal_Rela *rel_end;
-  enum v850_reloc_type r_type;
+  unsigned int r_type;
   int other = 0;
   const char *common = NULL;
 
@@ -84,34 +83,16 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
-      r_type = (enum v850_reloc_type) ELF32_R_TYPE (rel->r_info);
+      r_type = ELF32_R_TYPE (rel->r_info);
       switch (r_type)
 	{
 	default:
-	case R_V850_NONE:
-	case R_V850_9_PCREL:
-	case R_V850_16_PCREL:
-	case R_V850_17_PCREL:
-	case R_V850_22_PCREL:
-	case R_V850_32_PCREL:
-	case R_V850_32_ABS:
-	case R_V850_HI16:
-	case R_V850_HI16_S:
-	case R_V850_LO16:
-	case R_V850_LO16_S1:
-	case R_V850_LO16_SPLIT_OFFSET:
-	case R_V850_23:
-	case R_V850_ABS32:
-	case R_V850_REL32:
-	case R_V850_16:
-	case R_V850_16_S1:
-	case R_V850_16_SPLIT_OFFSET:
-	case R_V850_8:
-	case R_V850_CALLT_6_7_OFFSET:
-	case R_V850_CALLT_15_16_OFFSET:
-	case R_V850_CALLT_16_16_OFFSET:
 	  break;
 
         /* This relocation describes the C++ object vtable hierarchy.
@@ -133,6 +114,9 @@
 	case R_V850_SDA_16_16_SPLIT_OFFSET:
 	case R_V850_SDA_16_16_OFFSET:
 	case R_V850_SDA_15_16_OFFSET:
+	case R_V810_GPWLO_1:
+	case R_V850_HWLO:
+	case R_V850_HWLO_1:
 	  other = V850_OTHER_SDA;
 	  common = ".scommon";
 	  goto small_data_common;
@@ -509,13 +493,19 @@
   switch (r_type)
     {
     default:
+#ifdef DEBUG
+      fprintf (stderr, "reloc number %d not recognised\n", r_type);
+#endif
       return bfd_reloc_notsupported;
 
     case R_V850_REL32:
     case R_V850_ABS32:
+    case R_V810_WORD:
+    case R_V850_PC32:
       bfd_put_32 (abfd, addend, address);
       return bfd_reloc_ok;
 
+    case R_V850_WLO23:
     case R_V850_23:
       insn  = bfd_get_32 (abfd, address);
       insn &= ~((0x7f << 4) | (0x7fff80 << (16-7)));
@@ -523,6 +513,7 @@
       bfd_put_32 (abfd, (bfd_vma) insn, address);
       return bfd_reloc_ok;
 
+    case R_V850_PCR22:
     case R_V850_22_PCREL:
       if (saddend > 0x1fffff || saddend < -0x200000)
 	return bfd_reloc_overflow;
@@ -536,6 +527,7 @@
       bfd_put_32 (abfd, (bfd_vma) insn, address);
       return bfd_reloc_ok;
 
+    case R_V850_PC17:
     case R_V850_17_PCREL:
       if (saddend > 0xffff || saddend < -0x10000)
 	return bfd_reloc_overflow;
@@ -548,6 +540,7 @@
       insn |= ((addend & 0xfffe) << 16) | ((addend & 0x10000) >> (16-4));
       break;
 
+    case R_V850_PC16U:
     case R_V850_16_PCREL:
       if ((saddend < -0xffff) || (saddend > 0))
 	return bfd_reloc_overflow;
@@ -560,6 +553,7 @@
       insn |= (-addend & 0xfffe);
       break;
 
+    case R_V850_PC9:
     case R_V850_9_PCREL:
       if (saddend > 0xff || saddend < -0x100)
 	return bfd_reloc_overflow;
@@ -572,12 +566,14 @@
       insn |= ((addend & 0x1f0) << 7) | ((addend & 0x0e) << 3);
       break;
 
+    case R_V810_WHI:
     case R_V850_HI16:
       addend += (bfd_get_16 (abfd, address) << 16);
       addend = (addend >> 16);
       insn = addend;
       break;
 
+    case R_V810_WHI1:
     case R_V850_HI16_S:
       /* Remember where this relocation took place.  */
       remember_hi16s_reloc (abfd, addend, address);
@@ -592,12 +588,14 @@
       insn = addend;
       break;
 
+    case R_V810_WLO:
     case R_V850_LO16:
       insn = bfd_get_16 (abfd, address);
       if (! v850_elf_perform_lo16_relocation (abfd, &insn, addend))
 	return bfd_reloc_overflow;
       break;
 
+    case R_V810_BYTE:
     case R_V850_8:
       addend += (char) bfd_get_8 (abfd, address);
 
@@ -623,7 +621,7 @@
     case R_V850_CALLT_15_16_OFFSET:
       insn = bfd_get_16 (abfd, address);
 
-      addend += insn & 0xfffe;;
+      addend += insn & 0xfffe;
 
       saddend = (bfd_signed_vma) addend;
 
@@ -651,6 +649,7 @@
       break;
 
     case R_V850_16:
+    case R_V810_HWORD:
     case R_V850_SDA_16_16_OFFSET:
     case R_V850_ZDA_16_16_OFFSET:
     case R_V850_TDA_16_16_OFFSET:
@@ -667,6 +666,7 @@
     case R_V850_16_S1:
     case R_V850_SDA_15_16_OFFSET:
     case R_V850_ZDA_15_16_OFFSET:
+    case R_V810_GPWLO_1:
       insn = bfd_get_16 (abfd, address);
       addend += (insn & 0xfffe);
 
@@ -755,6 +755,9 @@
       insn |= addend;
       break;
 
+    case R_V810_WLO_1:
+    case R_V850_HWLO:
+    case R_V850_HWLO_1:
     case R_V850_LO16_S1:
       insn = bfd_get_16 (abfd, address);
       result = insn & 0xfffe;
@@ -767,6 +770,7 @@
 	bfd_put_16 (abfd, insn, address);
       return bfd_reloc_ok;
 
+    case R_V850_BLO:
     case R_V850_LO16_SPLIT_OFFSET:
       insn = bfd_get_32 (abfd, address);
       result = ((insn & 0xfffe0000) >> 16) | ((insn & 0x20) >> 5);
@@ -885,7 +889,7 @@
 }
 /* Note: It is REQUIRED that the 'type' value of each entry
    in this array match the index of the entry in the array.
-   SeeAlso: RELOC_NUBMER in include/elf/v850.h  */
+   SeeAlso: RELOC_NUBMER in include/elf/v850.h.  */
 static reloc_howto_type v850_elf_howto_table[] =
 {
   /* This reloc does nothing.  */
@@ -1741,6 +1745,109 @@
   { BFD_RELOC_V850_CODE,                   R_V850_CODE                   },
   { BFD_RELOC_V850_DATA,                   R_V850_DATA                   },
 };
+
+#define V800_RELOC(name,sz,bit,shift,complain,pcrel,resolver)		 \
+  HOWTO (name, shift, sz, bit, pcrel, 0, complain_overflow_ ## complain, \
+	 bfd_elf_ ## resolver ## _reloc, #name, FALSE, 0, ~0, FALSE)
+
+#define V800_EMPTY(name) EMPTY_HOWTO (name - R_V810_NONE)
+
+#define bfd_elf_v850_reloc v850_elf_reloc
+
+/* Note: It is REQUIRED that the 'type' value (R_V810_...) of each entry
+   in this array match the index of the entry in the array minus 0x30.
+   See: bfd_elf_v850_relocate_section(), v800_elf_reloc_type_lookup()
+   and v800_elf_info_to_howto().  */
+
+static reloc_howto_type v800_elf_howto_table[] =
+{
+  V800_RELOC (R_V810_NONE,      0,  0, 0, dont,     FALSE, generic),	/* Type = 0x30 */
+  V800_RELOC (R_V810_BYTE,      0,  8, 0, dont,     FALSE, generic),
+  V800_RELOC (R_V810_HWORD,     1, 16, 0, dont,     FALSE, generic),
+  V800_RELOC (R_V810_WORD,      2, 32, 0, dont,     FALSE, generic),
+  V800_RELOC (R_V810_WLO,       1, 16, 0, dont,     FALSE, generic),
+  V800_RELOC (R_V810_WHI,       1, 16, 0, dont,     FALSE, generic),
+  V800_RELOC (R_V810_WHI1,      1, 16, 0, dont,     FALSE, generic),
+  V800_RELOC (R_V810_GPBYTE,    0,  8, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_GPHWORD,   1, 16, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_GPWORD,    2, 32, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_GPWLO,     1, 16, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_GPWHI,     1, 16, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_GPWHI1,    1, 16, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V850_HWLO,      1, 16, 0, dont,     FALSE, generic),
+  V800_EMPTY (R_V810_reserved1),
+  V800_RELOC (R_V850_EP7BIT,    0,  7, 0, unsigned, FALSE, v850),
+  V800_RELOC (R_V850_EPHBYTE,   0,  8, 1, unsigned, FALSE, v850),
+  V800_RELOC (R_V850_EPWBYTE,   0,  8, 2, unsigned, FALSE, v850),
+  V800_RELOC (R_V850_REGHWLO,   1, 16, 0, dont,     FALSE, v850),
+  V800_EMPTY (R_V810_reserved2),
+  V800_RELOC (R_V850_GPHWLO,    1, 16, 0, dont,     FALSE, v850),
+  V800_EMPTY (R_V810_reserved3),
+  V800_RELOC (R_V850_PCR22,     2, 22, 0, signed,   TRUE,  generic),
+  V800_RELOC (R_V850_BLO,       2, 24, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V850_EP4BIT,    0,  4, 0, unsigned, FALSE, v850),
+  V800_RELOC (R_V850_EP5BIT,    0,  5, 0, unsigned, FALSE, v850),
+  V800_RELOC (R_V850_REGBLO,    2, 24, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V850_GPBLO,     2, 24, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_WLO_1,     1, 16, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_GPWLO_1,   1, 16, 0, signed,   FALSE, v850),
+  V800_RELOC (R_V850_BLO_1,     2, 16, 0, signed,   FALSE, v850),
+  V800_RELOC (R_V850_HWLO_1,    1, 16, 0, signed,   FALSE, v850),
+  V800_EMPTY  (R_V810_reserved4),
+  V800_RELOC (R_V850_GPBLO_1,   2, 16, 1, signed,   FALSE, v850),
+  V800_RELOC (R_V850_GPHWLO_1,  1, 16, 1, signed,   FALSE, v850),
+  V800_EMPTY (R_V810_reserved5),
+  V800_RELOC (R_V850_EPBLO,     2, 16, 1, signed,   FALSE, v850),
+  V800_RELOC (R_V850_EPHWLO,    1, 16, 1, signed,   FALSE, v850),
+  V800_EMPTY (R_V810_reserved6),
+  V800_RELOC (R_V850_EPWLO_N,   1, 16, 1, signed,   FALSE, v850),
+  V800_RELOC (R_V850_PC32,      2, 32, 1, signed,   TRUE,  v850),
+  V800_RELOC (R_V850_W23BIT,    2, 23, 1, signed,   FALSE, v850),
+  V800_RELOC (R_V850_GPW23BIT,  2, 23, 1, signed,   FALSE, v850),
+  V800_RELOC (R_V850_EPW23BIT,  2, 23, 1, signed,   FALSE, v850),
+  V800_RELOC (R_V850_B23BIT,    2, 23, 1, signed,   FALSE, v850),
+  V800_RELOC (R_V850_GPB23BIT,  2, 23, 1, signed,   FALSE, v850),
+  V800_RELOC (R_V850_EPB23BIT,  2, 23, 1, signed,   FALSE, v850),
+  V800_RELOC (R_V850_PC16U,     1, 16, 1, unsigned, TRUE,  generic),
+  V800_RELOC (R_V850_PC17,      2, 17, 1, signed,   TRUE,  generic),
+  V800_RELOC (R_V850_DW8,       2,  8, 2, signed,   FALSE, v850),
+  V800_RELOC (R_V850_GPDW8,     2,  8, 2, signed,   FALSE, v850),
+  V800_RELOC (R_V850_EPDW8,     2,  8, 2, signed,   FALSE, v850),
+  V800_RELOC (R_V850_PC9,       1,  9, 3, signed,   TRUE,  v850),
+  V800_RELOC (R_V810_REGBYTE,   0,  8, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_REGHWORD,  1, 16, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_REGWORD,   2, 32, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_REGWLO,    1, 16, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_REGWHI,    1, 16, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_REGWHI1,   1, 16, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V850_REGW23BIT, 2, 23, 1, signed,   FALSE, v850),
+  V800_RELOC (R_V850_REGB23BIT, 2, 23, 1, signed,   FALSE, v850),
+  V800_RELOC (R_V850_REGDW8,    2,  8, 2, signed,   FALSE, v850),
+  V800_RELOC (R_V810_EPBYTE,    0,  8, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_EPHWORD,   1, 16, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_EPWORD,    2, 32, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V850_WLO23,     2, 32, 1, dont,     FALSE, v850),
+  V800_RELOC (R_V850_WORD_E,    2, 32, 1, dont,     FALSE, v850),
+  V800_RELOC (R_V850_REGWORD_E, 2, 32, 1, dont,     FALSE, v850),
+  V800_RELOC (R_V850_WORD,      2, 32, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V850_GPWORD,    2, 32, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V850_REGWORD,   2, 32, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V850_EPWORD,    2, 32, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_TPBYTE,    0,  8, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_TPHWORD,   1, 16, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_TPWORD,    2, 32, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_TPWLO,     1, 16, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_TPWHI,     1, 16, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_TPWHI1,    1, 16, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V850_TPHWLO,    1, 16, 1, dont,     FALSE, v850),
+  V800_RELOC (R_V850_TPBLO,     2, 24, 0, dont,     FALSE, v850),
+  V800_RELOC (R_V810_TPWLO_1,   1, 16, 0, signed,   FALSE, v850),
+  V800_RELOC (R_V850_TPBLO_1,   2, 16, 0, signed,   FALSE, v850),
+  V800_RELOC (R_V850_TPHWLO_1,  1, 16, 0, signed,   FALSE, v850),
+  V800_RELOC (R_V850_TP23BIT,   2, 23, 0, signed,   FALSE, v850),
+  V800_RELOC (R_V850_TPW23BIT,  2, 23, 0, signed,   FALSE, v850),
+  V800_RELOC (R_V850_TPDW8,     2,  8, 0, signed,   FALSE, v850)
+};
 
 /* Map a bfd relocation into the appropriate howto structure.  */
 
@@ -1813,6 +1920,12 @@
   return (   (name[0] == '.' && (name[1] == 'L' || name[1] == '.'))
 	  || (name[0] == '_' &&  name[1] == '.' && name[2] == 'L' && name[3] == '_'));
 }
+
+static bfd_boolean
+v850_elf_is_target_special_symbol (bfd *abfd, asymbol *sym)
+{
+  return v850_elf_is_local_label_name (abfd, sym->name);
+}
 
 /* We overload some of the bfd_reloc error codes for own purposes.  */
 #define bfd_reloc_gp_not_found		bfd_reloc_other
@@ -1840,12 +1953,14 @@
   /* Adjust the value according to the relocation.  */
   switch (r_type)
     {
+    case R_V850_PC9:
     case R_V850_9_PCREL:
       value -= (input_section->output_section->vma
 		+ input_section->output_offset);
       value -= offset;
       break;
 
+    case R_V850_PC16U:
     case R_V850_16_PCREL:
       value -= (input_section->output_section->vma
 		+ input_section->output_offset
@@ -1857,6 +1972,7 @@
 
       break;
 
+    case R_V850_PC17:
     case R_V850_17_PCREL:
       value -= (input_section->output_section->vma
 		+ input_section->output_offset
@@ -1869,6 +1985,7 @@
       value = SEXT17 (value);
       break;
 
+    case R_V850_PCR22:
     case R_V850_22_PCREL:
       value -= (input_section->output_section->vma
 		+ input_section->output_offset
@@ -1882,6 +1999,7 @@
       value = SEXT22 (value);
       break;
 
+    case R_V850_PC32:
     case R_V850_32_PCREL:
       value -= (input_section->output_section->vma
 		+ input_section->output_offset
@@ -1898,6 +2016,15 @@
     case R_V850_16:
     case R_V850_ABS32:
     case R_V850_8:
+    case R_V810_BYTE:
+    case R_V810_HWORD:
+    case R_V810_WORD:
+    case R_V810_WLO:
+    case R_V810_WHI:
+    case R_V810_WHI1:
+    case R_V810_WLO_1:
+    case R_V850_WLO23:
+    case R_V850_BLO:
       break;
 
     case R_V850_ZDA_15_16_OFFSET:
@@ -1912,6 +2039,7 @@
     case R_V850_SDA_15_16_OFFSET:
     case R_V850_SDA_16_16_OFFSET:
     case R_V850_SDA_16_16_SPLIT_OFFSET:
+    case R_V810_GPWLO_1:
       {
 	unsigned long                gp;
 	struct bfd_link_hash_entry * h;
@@ -2001,6 +2129,7 @@
     break;
 
     case R_V850_NONE:
+    case R_V810_NONE:
     case R_V850_GNU_VTINHERIT:
     case R_V850_GNU_VTENTRY:
     case R_V850_LONGCALL:
@@ -2009,6 +2138,9 @@
       return bfd_reloc_ok;
 
     default:
+#ifdef DEBUG
+      fprintf (stderr, "reloc number %d not recognised\n", r_type);
+#endif
       return bfd_reloc_notsupported;
     }
 
@@ -2045,7 +2177,7 @@
   relend = relocs + input_section->reloc_count;
   for (; rel < relend; rel++)
     {
-      int r_type;
+      unsigned int r_type;
       reloc_howto_type *howto;
       unsigned long r_symndx;
       Elf_Internal_Sym *sym;
@@ -2061,7 +2193,13 @@
           || r_type == R_V850_GNU_VTINHERIT)
         continue;
 
-      howto = v850_elf_howto_table + r_type;
+      if (bfd_get_arch (input_bfd) == bfd_arch_v850_rh850)
+	howto = v800_elf_howto_table + (r_type - R_V810_NONE);
+      else
+	howto = v850_elf_howto_table + r_type;
+
+      BFD_ASSERT (r_type == howto->type);
+
       h = NULL;
       sym = NULL;
       sec = NULL;
@@ -2093,9 +2231,9 @@
 				   unresolved_reloc, warned);
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -2198,31 +2336,42 @@
   return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
-/* Set the right machine number.  */
+/* Set the right machine number and architecture.  */
 
 static bfd_boolean
 v850_elf_object_p (bfd *abfd)
 {
-  switch (elf_elfheader (abfd)->e_flags & EF_V850_ARCH)
+  enum bfd_architecture arch;
+  unsigned long mach;
+
+  switch (elf_elfheader (abfd)->e_machine)
     {
+    case EM_V800:
+      arch = bfd_arch_v850_rh850;
+      mach = (elf_elfheader (abfd)->e_flags & EF_V800_850E3)
+	? bfd_mach_v850e3v5 : bfd_mach_v850e2v3;
+      break;
+
+    case EM_CYGNUS_V850:
+    case EM_V850:
+      arch = bfd_arch_v850;
+      switch (elf_elfheader (abfd)->e_flags & EF_V850_ARCH)
+	{
+	default:
+	case E_V850_ARCH:     mach = bfd_mach_v850; break;
+	case E_V850E_ARCH:    mach = bfd_mach_v850e; break;
+	case E_V850E1_ARCH:   mach = bfd_mach_v850e1; break;
+	case E_V850E2_ARCH:   mach = bfd_mach_v850e2; break;
+	case E_V850E2V3_ARCH: mach = bfd_mach_v850e2v3; break;
+	case E_V850E3V5_ARCH: mach = bfd_mach_v850e3v5; break;
+	}
+      break;
+
     default:
-    case E_V850_ARCH:
-      bfd_default_set_arch_mach (abfd, bfd_arch_v850, bfd_mach_v850);
-      break;
-    case E_V850E_ARCH:
-      bfd_default_set_arch_mach (abfd, bfd_arch_v850, bfd_mach_v850e);
-      break;
-    case E_V850E1_ARCH:
-      bfd_default_set_arch_mach (abfd, bfd_arch_v850, bfd_mach_v850e1);
-      break;
-    case E_V850E2_ARCH:
-      bfd_default_set_arch_mach (abfd, bfd_arch_v850, bfd_mach_v850e2);
-      break;
-    case E_V850E2V3_ARCH:
-      bfd_default_set_arch_mach (abfd, bfd_arch_v850, bfd_mach_v850e2v3);
-      break;
+      return FALSE;
     }
-  return TRUE;
+
+  return bfd_default_set_arch_mach (abfd, arch, mach);
 }
 
 /* Store the machine number in the flags field.  */
@@ -2233,18 +2382,32 @@
 {
   unsigned long val;
 
-  switch (bfd_get_mach (abfd))
+  switch (bfd_get_arch (abfd))
     {
-    default:
-    case bfd_mach_v850:   val = E_V850_ARCH; break;
-    case bfd_mach_v850e:  val = E_V850E_ARCH; break;
-    case bfd_mach_v850e1: val = E_V850E1_ARCH; break;
-    case bfd_mach_v850e2: val = E_V850E2_ARCH;  break;
-    case bfd_mach_v850e2v3: val = E_V850E2V3_ARCH;  break;
-    }
+    case bfd_arch_v850_rh850:
+      val = EF_RH850_ABI;
+      if (bfd_get_mach (abfd) == bfd_mach_v850e3v5)
+	val |= EF_V800_850E3;
+      elf_elfheader (abfd)->e_flags |= val;
+      break;
 
-  elf_elfheader (abfd)->e_flags &=~ EF_V850_ARCH;
-  elf_elfheader (abfd)->e_flags |= val;
+    case bfd_arch_v850:
+      switch (bfd_get_mach (abfd))
+	{
+	default:
+	case bfd_mach_v850:     val = E_V850_ARCH; break;
+	case bfd_mach_v850e:    val = E_V850E_ARCH; break;
+	case bfd_mach_v850e1:   val = E_V850E1_ARCH; break;
+	case bfd_mach_v850e2:   val = E_V850E2_ARCH; break;
+	case bfd_mach_v850e2v3: val = E_V850E2V3_ARCH; break;
+	case bfd_mach_v850e3v5: val = E_V850E3V5_ARCH; break;
+	}
+      elf_elfheader (abfd)->e_flags &=~ EF_V850_ARCH;
+      elf_elfheader (abfd)->e_flags |= val;
+      break;
+    default:
+      break;
+    }
 }
 
 /* Function to keep V850 specific file flags.  */
@@ -2301,17 +2464,36 @@
   if (in_flags == out_flags)
     return TRUE;
 
+  if (bfd_get_arch (obfd) == bfd_arch_v850_rh850)
+    {
+      if ((in_flags & EF_V800_850E3) != (out_flags & EF_V800_850E3))
+	{
+	  _bfd_error_handler (_("%B: Architecture mismatch with previous modules"),
+			      ibfd);
+	  elf_elfheader (obfd)->e_flags |= EF_V800_850E3;
+	}
+
+      if ((in_flags & EF_RH850_DATA_ALIGN8) != (out_flags & EF_RH850_DATA_ALIGN8))
+	{
+	  _bfd_error_handler (_("%B: Alignment mismatch with previous modules"),
+			      ibfd);
+	  elf_elfheader (obfd)->e_flags |= EF_RH850_DATA_ALIGN8;
+	}
+
+      return TRUE;
+    }
+
   if ((in_flags & EF_V850_ARCH) != (out_flags & EF_V850_ARCH)
       && (in_flags & EF_V850_ARCH) != E_V850_ARCH)
     {
-
-      /* Allow v850e1 binaries to be linked with v850e binaries.
-         Set the output binary to v850e.  */
-      if ((in_flags & EF_V850_ARCH) == E_V850E1_ARCH
+      /* Allow earlier architecture binaries to be linked with later binaries.
+         Set the output binary to the later architecture, except for v850e1,
+         which we set to v850e.  */
+      if (   (in_flags  & EF_V850_ARCH) == E_V850E1_ARCH
           && (out_flags & EF_V850_ARCH) == E_V850E_ARCH)
         return TRUE;
 
-      if ((in_flags & EF_V850_ARCH) == E_V850_ARCH
+      if (   (in_flags  & EF_V850_ARCH) == E_V850_ARCH
 	  && (out_flags & EF_V850_ARCH) == E_V850E_ARCH)
 	{
 	  elf_elfheader (obfd)->e_flags =
@@ -2319,7 +2501,7 @@
 	  return TRUE;
 	}
 
-      if (((in_flags & EF_V850_ARCH) == E_V850_ARCH
+      if ((   (in_flags & EF_V850_ARCH) == E_V850_ARCH
 	   || (in_flags & EF_V850_ARCH) == E_V850E_ARCH)
 	  && (out_flags & EF_V850_ARCH) == E_V850E2_ARCH)
 	{
@@ -2328,7 +2510,7 @@
 	  return TRUE;
 	}
 
-      if (((in_flags & EF_V850_ARCH) == E_V850_ARCH
+      if ((   (in_flags & EF_V850_ARCH) == E_V850_ARCH
 	   || (in_flags & EF_V850_ARCH) == E_V850E_ARCH
 	   || (in_flags & EF_V850_ARCH) == E_V850E2_ARCH)
 	  && (out_flags & EF_V850_ARCH) == E_V850E2V3_ARCH)
@@ -2338,6 +2520,17 @@
 	  return TRUE;
 	}
 
+      if ((   (in_flags & EF_V850_ARCH) == E_V850_ARCH
+	   || (in_flags & EF_V850_ARCH) == E_V850E_ARCH
+	   || (in_flags & EF_V850_ARCH) == E_V850E2_ARCH
+           || (in_flags & EF_V850_ARCH) == E_V850E2V3_ARCH)
+	  && (out_flags & EF_V850_ARCH) == E_V850E3V5_ARCH)
+	{
+	  elf_elfheader (obfd)->e_flags =
+	    ((out_flags & ~ EF_V850_ARCH) | E_V850E3V5_ARCH);
+	  return TRUE;
+	}
+
       _bfd_error_handler (_("%B: Architecture mismatch with previous modules"),
 			  ibfd);
     }
@@ -2359,14 +2552,30 @@
   /* xgettext:c-format.  */
   fprintf (file, _("private flags = %lx: "), elf_elfheader (abfd)->e_flags);
 
-  switch (elf_elfheader (abfd)->e_flags & EF_V850_ARCH)
+  if (bfd_get_arch (abfd) == bfd_arch_v850_rh850)
     {
-    default:
-    case E_V850_ARCH: fprintf (file, _("v850 architecture")); break;
-    case E_V850E_ARCH: fprintf (file, _("v850e architecture")); break;
-    case E_V850E1_ARCH: fprintf (file, _("v850e1 architecture")); break;
-    case E_V850E2_ARCH: fprintf (file, _("v850e2 architecture")); break;
-    case E_V850E2V3_ARCH: fprintf (file, _("v850e2v3 architecture")); break;
+      if ((elf_elfheader (abfd)->e_flags & EF_RH850_ABI) != EF_RH850_ABI)
+	fprintf (file, _("unknown v850 architecture"));
+      else if (elf_elfheader (abfd)->e_flags & EF_V800_850E3)
+	fprintf (file, _("v850 E3 architecture"));
+      else
+	fprintf (file, _("v850 architecture"));
+
+      if (elf_elfheader (abfd)->e_flags & EF_RH850_DATA_ALIGN8)
+	fprintf (file, _(", 8-byte data alignment"));
+    }
+  else
+    {
+      switch (elf_elfheader (abfd)->e_flags & EF_V850_ARCH)
+	{
+	default:
+	case E_V850_ARCH: fprintf (file, _("v850 architecture")); break;
+	case E_V850E_ARCH: fprintf (file, _("v850e architecture")); break;
+	case E_V850E1_ARCH: fprintf (file, _("v850e1 architecture")); break;
+	case E_V850E2_ARCH: fprintf (file, _("v850e2 architecture")); break;
+	case E_V850E2V3_ARCH: fprintf (file, _("v850e2v3 architecture")); break;
+	case E_V850E3V5_ARCH: fprintf (file, _("v850e3v5 architecture")); break;
+	}
     }
 
   fputc ('\n', file);
@@ -2932,7 +3141,7 @@
 
 	  if (alignmoveto < alignto)
 	    {
-	      unsigned int i;
+	      bfd_vma i;
 
 	      align_pad_size = alignto - alignmoveto;
 #ifdef DEBUG_RELAX
@@ -2964,6 +3173,7 @@
 	  Elf_Internal_Rela *lo_irelfn;
 	  Elf_Internal_Rela *irelcall;
 	  bfd_signed_vma foff;
+	  unsigned int r_type;
 
 	  if (! (irel->r_offset >= addr && irel->r_offset < toaddr
 		 && (ELF32_R_TYPE (irel->r_info) == (int) R_V850_LONGCALL
@@ -3059,23 +3269,33 @@
 	      /* Get the reloc for the address from which the register is
 	         being loaded.  This reloc will tell us which function is
 	         actually being called.  */
+
 	      for (hi_irelfn = internal_relocs; hi_irelfn < irelend; hi_irelfn ++)
-		if (hi_irelfn->r_offset == laddr + 2
-		    && ELF32_R_TYPE (hi_irelfn->r_info)
-		        == (int) R_V850_HI16_S)
-		  break;
+		{
+		  r_type = ELF32_R_TYPE (hi_irelfn->r_info);
+
+		  if (hi_irelfn->r_offset == laddr + 2
+		      && (r_type == (int) R_V850_HI16_S || r_type == (int) R_V810_WHI1))
+		    break;
+		}
 
 	      for (lo_irelfn = internal_relocs; lo_irelfn < irelend; lo_irelfn ++)
-		if (lo_irelfn->r_offset == laddr + 6
-		    && ELF32_R_TYPE (lo_irelfn->r_info)
-		        == (int) R_V850_LO16)
-		  break;
+		{
+		  r_type = ELF32_R_TYPE (lo_irelfn->r_info);
+
+		  if (lo_irelfn->r_offset == laddr + 6
+		      && (r_type == (int) R_V850_LO16 || r_type == (int) R_V810_WLO))
+		    break;
+		}
 
 	      for (irelcall = internal_relocs; irelcall < irelend; irelcall ++)
-		if (irelcall->r_offset == laddr + 8
-		    && ELF32_R_TYPE (irelcall->r_info)
-                        == (int) R_V850_22_PCREL)
-		  break;
+		{
+		  r_type = ELF32_R_TYPE (irelcall->r_info);
+
+		  if (irelcall->r_offset == laddr + 8
+		      && (r_type == (int) R_V850_22_PCREL || r_type == (int) R_V850_PCR22))
+		    break;
+		}
 
 	      if (   hi_irelfn == irelend
 		  || lo_irelfn == irelend
@@ -3201,7 +3421,10 @@
 	      symtab_hdr->contents = (bfd_byte *) isymbuf;
 
 	      /* Replace the long call with a jarl.  */
-	      irel->r_info = ELF32_R_INFO (ELF32_R_SYM (hi_irelfn->r_info), R_V850_22_PCREL);
+	      if (bfd_get_arch (abfd) == bfd_arch_v850_rh850)
+		irel->r_info = ELF32_R_INFO (ELF32_R_SYM (hi_irelfn->r_info), R_V850_PCR22);
+	      else
+		irel->r_info = ELF32_R_INFO (ELF32_R_SYM (hi_irelfn->r_info), R_V850_22_PCREL);
 
 	      addend = 0;
 
@@ -3277,14 +3500,22 @@
 	         being loaded.  This reloc will tell us which function is
 	         actually being called.  */
 	      for (hi_irelfn = internal_relocs; hi_irelfn < irelend; hi_irelfn ++)
-		if (hi_irelfn->r_offset == laddr + 2
-		    && ELF32_R_TYPE (hi_irelfn->r_info) == (int) R_V850_HI16_S)
-		  break;
+		{
+		  r_type = ELF32_R_TYPE (hi_irelfn->r_info);
+
+		  if (hi_irelfn->r_offset == laddr + 2
+		      && ((r_type == (int) R_V850_HI16_S) || r_type == (int) R_V810_WHI1))
+		    break;
+		}
 
 	      for (lo_irelfn = internal_relocs; lo_irelfn < irelend; lo_irelfn ++)
-		if (lo_irelfn->r_offset == laddr + 6
-		    && ELF32_R_TYPE (lo_irelfn->r_info) == (int) R_V850_LO16)
-		  break;
+		{
+		  r_type = ELF32_R_TYPE (lo_irelfn->r_info);
+
+		  if (lo_irelfn->r_offset == laddr + 6
+		      && (r_type == (int) R_V850_LO16 || r_type == (int) R_V810_WLO))
+		    break;
+		}
 
 	      if (   hi_irelfn == irelend
 		  || lo_irelfn == irelend)
@@ -3391,8 +3622,11 @@
 		{
 		  /* Replace the long jump with a jr.  */
 
-		  irel->r_info =
-		    ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_V850_22_PCREL);
+		  if (bfd_get_arch (abfd) == bfd_arch_v850_rh850)
+		    irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_V850_PCR22);
+		  else
+		    irel->r_info =
+		      ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_V850_22_PCREL);
 
 		  irel->r_addend = addend;
 		  addend = 0;
@@ -3424,8 +3658,11 @@
 		{
 		  /* Replace the long jump with a br.  */
 
-		  irel->r_info =
-			ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_V850_9_PCREL);
+		  if (bfd_get_arch (abfd) == bfd_arch_v850_rh850)
+		    irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_V850_PC9);
+		  else
+		    irel->r_info =
+		      ELF32_R_INFO (ELF32_R_SYM (irel->r_info), R_V850_9_PCREL);
 
 		  irel->r_addend = addend;
 		  addend = 0;
@@ -3538,7 +3775,6 @@
 #define ELF_ARCH				bfd_arch_v850
 #define ELF_MACHINE_CODE			EM_V850
 #define ELF_MACHINE_ALT1			EM_CYGNUS_V850
-#define ELF_MACHINE_ALT2			EM_V800 /* This is the value used by the GreenHills toolchain.  */
 #define ELF_MAXPAGESIZE				0x1000
 
 #define elf_info_to_howto			v850_elf_info_to_howto_rela
@@ -3561,8 +3797,10 @@
 #define elf_backend_rela_normal 1
 
 #define bfd_elf32_bfd_is_local_label_name	v850_elf_is_local_label_name
+#define bfd_elf32_bfd_is_target_special_symbol	v850_elf_is_target_special_symbol
+
 #define bfd_elf32_bfd_reloc_type_lookup		v850_elf_reloc_type_lookup
-#define bfd_elf32_bfd_reloc_name_lookup	v850_elf_reloc_name_lookup
+#define bfd_elf32_bfd_reloc_name_lookup	        v850_elf_reloc_name_lookup
 #define bfd_elf32_bfd_merge_private_bfd_data 	v850_elf_merge_private_bfd_data
 #define bfd_elf32_bfd_set_private_flags		v850_elf_set_private_flags
 #define bfd_elf32_bfd_print_private_bfd_data	v850_elf_print_private_bfd_data
@@ -3570,4 +3808,122 @@
 
 #define elf_symbol_leading_char			'_'
 
+#undef  elf32_bed
+#define elf32_bed elf32_v850_bed
+
+#include "elf32-target.h"
+
+/* Map BFD reloc types to V800 ELF reloc types.  */
+
+static const struct v850_elf_reloc_map v800_elf_reloc_map[] =
+{
+  { BFD_RELOC_NONE,                   R_V810_NONE    },
+  { BFD_RELOC_8,                      R_V810_BYTE    },
+  { BFD_RELOC_16,                     R_V810_HWORD   },
+  { BFD_RELOC_32,                     R_V810_WORD    },
+  { BFD_RELOC_LO16,                   R_V810_WLO     },
+  { BFD_RELOC_HI16,                   R_V810_WHI     },
+  { BFD_RELOC_HI16_S,                 R_V810_WHI1    },
+  { BFD_RELOC_V850_32_PCREL,          R_V850_PC32    },
+  { BFD_RELOC_V850_22_PCREL,          R_V850_PCR22   },
+  { BFD_RELOC_V850_17_PCREL,          R_V850_PC17    },
+  { BFD_RELOC_V850_16_PCREL,          R_V850_PC16U   },
+  { BFD_RELOC_V850_9_PCREL,	      R_V850_PC9     },
+  { BFD_RELOC_V850_LO16_S1,           R_V810_WLO_1   }, /* Or R_V850_HWLO or R_V850_HWLO_1.  */
+  { BFD_RELOC_V850_23,                R_V850_WLO23   },
+  { BFD_RELOC_V850_LO16_SPLIT_OFFSET, R_V850_BLO     },
+  { BFD_RELOC_V850_ZDA_16_16_OFFSET,  R_V810_HWORD   },
+  { BFD_RELOC_V850_TDA_16_16_OFFSET,  R_V810_HWORD   },
+  { BFD_RELOC_V850_SDA_16_16_OFFSET,  R_V810_HWORD   },
+  { BFD_RELOC_V850_SDA_15_16_OFFSET,  R_V810_GPWLO_1 }
+};
+
+/* Map a bfd relocation into the appropriate howto structure.  */
+
+static reloc_howto_type *
+v800_elf_reloc_type_lookup (bfd * abfd, bfd_reloc_code_real_type code)
+{
+  unsigned int i;
+
+  BFD_ASSERT (bfd_get_arch (abfd) == bfd_arch_v850_rh850);
+
+  for (i = ARRAY_SIZE (v800_elf_reloc_map); i --;)
+    if (v800_elf_reloc_map[i].bfd_reloc_val == code)
+      {
+	unsigned int elf_reloc_val = v800_elf_reloc_map[i].elf_reloc_val;
+	unsigned int idx = elf_reloc_val - R_V810_NONE;
+
+	BFD_ASSERT (v800_elf_howto_table[idx].type == elf_reloc_val);
+
+	return v800_elf_howto_table + idx;
+      }
+
+#ifdef DEBUG
+  fprintf (stderr, "failed to find v800 equiv of bfd reloc code %d\n", code);
+#endif
+  return NULL;
+}
+
+static reloc_howto_type *
+v800_elf_reloc_name_lookup (bfd * abfd, const char * r_name)
+{
+  unsigned int i;
+
+  BFD_ASSERT (bfd_get_arch (abfd) == bfd_arch_v850_rh850);
+
+  for (i = ARRAY_SIZE (v800_elf_howto_table); i--;)
+    if (v800_elf_howto_table[i].name != NULL
+	&& strcasecmp (v800_elf_howto_table[i].name, r_name) == 0)
+      return v800_elf_howto_table + i;
+
+  return NULL;
+}
+
+
+/* Set the howto pointer in CACHE_PTR for a V800 ELF reloc.  */
+
+static void
+v800_elf_info_to_howto (bfd *               abfd,
+			arelent *           cache_ptr,
+			Elf_Internal_Rela * dst)
+{
+  unsigned int r_type = ELF32_R_TYPE (dst->r_info);
+
+  BFD_ASSERT (bfd_get_arch (abfd) == bfd_arch_v850_rh850);
+
+  BFD_ASSERT (r_type < (unsigned int) R_V800_max);
+
+  if (r_type == R_V800_NONE)
+    r_type = R_V810_NONE;
+
+  BFD_ASSERT (r_type >= (unsigned int) R_V810_NONE);
+  r_type -= R_V810_NONE;
+  BFD_ASSERT (r_type < ARRAY_SIZE (v800_elf_howto_table));
+
+  cache_ptr->howto = v800_elf_howto_table + r_type;
+}
+
+
+#undef  TARGET_LITTLE_SYM
+#define TARGET_LITTLE_SYM			bfd_elf32_v850_rh850_vec
+#undef  TARGET_LITTLE_NAME
+#define TARGET_LITTLE_NAME			"elf32-v850-rh850"
+#undef  ELF_ARCH
+#define ELF_ARCH				bfd_arch_v850_rh850
+#undef  ELF_MACHINE_CODE
+#define ELF_MACHINE_CODE			EM_V800
+#undef  ELF_MACHINE_ALT1
+
+#undef  elf32_bed
+#define elf32_bed elf32_v850_rh850_bed
+
+#undef  elf_info_to_howto
+#define elf_info_to_howto			v800_elf_info_to_howto
+#undef  elf_info_to_howto_rel
+#define elf_info_to_howto_rel			NULL
+#undef  bfd_elf32_bfd_reloc_type_lookup
+#define bfd_elf32_bfd_reloc_type_lookup		v800_elf_reloc_type_lookup
+#undef  bfd_elf32_bfd_reloc_name_lookup
+#define bfd_elf32_bfd_reloc_name_lookup		v800_elf_reloc_name_lookup
+
 #include "elf32-target.h"
diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c
index 643381c..c6a8f81 100644
--- a/bfd/elf32-vax.c
+++ b/bfd/elf32-vax.c
@@ -1,6 +1,6 @@
 /* VAX series support for 32-bit ELF
    Copyright 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
    Contributed by Matt Thomas <[email protected]>.
 
@@ -53,7 +53,7 @@
 
 static bfd_boolean elf32_vax_set_private_flags (bfd *, flagword);
 static bfd_boolean elf32_vax_merge_private_bfd_data (bfd *, bfd *);
-static bfd_boolean elf32_vax_print_private_bfd_data (bfd *, PTR);
+static bfd_boolean elf32_vax_print_private_bfd_data (bfd *, void *);
 
 static reloc_howto_type howto_table[] = {
   HOWTO (R_VAX_NONE,		/* type */
@@ -423,7 +423,7 @@
 #define elf_vax_link_hash_traverse(table, func, info)			\
   (elf_link_hash_traverse						\
    ((table),								\
-    (bfd_boolean (*) (struct elf_link_hash_entry *, PTR)) (func),	\
+    (bfd_boolean (*) (struct elf_link_hash_entry *, void *)) (func),	\
     (info)))
 
 /* Create an entry in an VAX ELF linker hash table.  */
@@ -465,7 +465,7 @@
   struct elf_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_link_hash_table);
 
-  ret = bfd_malloc (amt);
+  ret = bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
 
@@ -514,7 +514,7 @@
 
 /* Display the flags field */
 static bfd_boolean
-elf32_vax_print_private_bfd_data (bfd *abfd, PTR ptr)
+elf32_vax_print_private_bfd_data (bfd *abfd, void * ptr)
 {
   FILE *file = (FILE *) ptr;
 
@@ -585,20 +585,22 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       switch (ELF32_R_TYPE (rel->r_info))
 	{
 	case R_VAX_GOT32:
 	  BFD_ASSERT (h != NULL);
-	  if (h->forced_local
-	      || h == elf_hash_table (info)->hgot
-	      || h == elf_hash_table (info)->hplt)
-	    break;
 
 	  /* If this is a local symbol, we resolve it directly without
 	     creating a global offset table entry.  */
-	  if (h == NULL || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
+	  if (h->forced_local
+	      || h == elf_hash_table (info)->hgot
+	      || h == elf_hash_table (info)->hplt)
 	    break;
 
 	  /* This symbol requires a global offset table entry.  */
@@ -613,24 +615,23 @@
 
 	  if (sgot == NULL)
 	    {
-	      sgot = bfd_get_section_by_name (dynobj, ".got");
+	      sgot = bfd_get_linker_section (dynobj, ".got");
 	      BFD_ASSERT (sgot != NULL);
 	    }
 
 	  if (srelgot == NULL
 	      && (h != NULL || info->shared))
 	    {
-	      srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+	      srelgot = bfd_get_linker_section (dynobj, ".rela.got");
 	      if (srelgot == NULL)
 		{
-		  srelgot = bfd_make_section_with_flags (dynobj,
-							 ".rela.got",
-							 (SEC_ALLOC
-							  | SEC_LOAD
-							  | SEC_HAS_CONTENTS
-							  | SEC_IN_MEMORY
-							  | SEC_LINKER_CREATED
-							  | SEC_READONLY));
+		  flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+				    | SEC_IN_MEMORY | SEC_LINKER_CREATED
+				    | SEC_READONLY);
+
+		  srelgot = bfd_make_section_anyway_with_flags (dynobj,
+								".rela.got",
+								flags);
 		  if (srelgot == NULL
 		      || !bfd_set_section_alignment (dynobj, srelgot, 2))
 		    return FALSE;
@@ -669,11 +670,11 @@
              never referenced by a dynamic object, in which case we
              don't need to generate a procedure linkage table entry
              after all.  */
+	  BFD_ASSERT (h != NULL);
 
 	  /* If this is a local symbol, we resolve it directly without
 	     creating a procedure linkage table entry.  */
-	  BFD_ASSERT (h != NULL);
-	  if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT || h->forced_local)
+	  if (h->forced_local)
 	    break;
 
 	  h->needs_plt = 1;
@@ -911,9 +912,8 @@
    understand.  */
 
 static bfd_boolean
-elf_vax_adjust_dynamic_symbol (info, h)
-     struct bfd_link_info *info;
-     struct elf_link_hash_entry *h;
+elf_vax_adjust_dynamic_symbol (struct bfd_link_info *info,
+			       struct elf_link_hash_entry *h)
 {
   bfd *dynobj;
   asection *s;
@@ -934,40 +934,22 @@
   if (h->type == STT_FUNC
       || h->needs_plt)
     {
-      if (! info->shared
-	  && !h->def_dynamic
-	  && !h->ref_dynamic
-	  /* We must always create the plt entry if it was referenced
-	     by a PLTxxO relocation.  In this case we already recorded
-	     it as a dynamic symbol.  */
-	  && h->dynindx == -1)
+      if (h->plt.refcount <= 0
+	  || SYMBOL_CALLS_LOCAL (info, h)
+	  || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
+	      && h->root.type == bfd_link_hash_undefweak))
 	{
 	  /* This case can occur if we saw a PLTxx reloc in an input
 	     file, but the symbol was never referred to by a dynamic
-	     object.  In such a case, we don't actually need to build
-	     a procedure linkage table, and we can just do a PCxx
-	     reloc instead.  */
-	  BFD_ASSERT (h->needs_plt);
+	     object, or if all references were garbage collected.  In
+	     such a case, we don't actually need to build a procedure
+	     linkage table, and we can just do a PCxx reloc instead.  */
 	  h->plt.offset = (bfd_vma) -1;
-	  return TRUE;
-	}
-
-      /* GC may have rendered this entry unused.  */
-      if (h->plt.refcount <= 0)
-	{
 	  h->needs_plt = 0;
-	  h->plt.offset = (bfd_vma) -1;
 	  return TRUE;
 	}
 
-      /* Make sure this symbol is output as a dynamic symbol.  */
-      if (h->dynindx == -1)
-	{
-	  if (! bfd_elf_link_record_dynamic_symbol (info, h))
-	    return FALSE;
-	}
-
-      s = bfd_get_section_by_name (dynobj, ".plt");
+      s = bfd_get_linker_section (dynobj, ".plt");
       BFD_ASSERT (s != NULL);
 
       /* If this is the first .plt entry, make room for the special
@@ -997,13 +979,13 @@
       /* We also need to make an entry in the .got.plt section, which
 	 will be placed in the .got section by the linker script.  */
 
-      s = bfd_get_section_by_name (dynobj, ".got.plt");
+      s = bfd_get_linker_section (dynobj, ".got.plt");
       BFD_ASSERT (s != NULL);
       s->size += 4;
 
       /* We also need to make an entry in the .rela.plt section.  */
 
-      s = bfd_get_section_by_name (dynobj, ".rela.plt");
+      s = bfd_get_linker_section (dynobj, ".rela.plt");
       BFD_ASSERT (s != NULL);
       s->size += sizeof (Elf32_External_Rela);
 
@@ -1036,13 +1018,6 @@
   if (info->shared)
     return TRUE;
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-			     h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -1053,18 +1028,18 @@
      both the dynamic object and the regular object will refer to the
      same memory location for the variable.  */
 
-  s = bfd_get_section_by_name (dynobj, ".dynbss");
+  s = bfd_get_linker_section (dynobj, ".dynbss");
   BFD_ASSERT (s != NULL);
 
   /* We must generate a R_VAX_COPY reloc to tell the dynamic linker to
      copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rela.bss section we are going to use.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       asection *srel;
 
-      srel = bfd_get_section_by_name (dynobj, ".rela.bss");
+      srel = bfd_get_linker_section (dynobj, ".rela.bss");
       BFD_ASSERT (srel != NULL);
       srel->size += sizeof (Elf32_External_Rela);
       h->needs_copy = 1;
@@ -1073,6 +1048,59 @@
   return _bfd_elf_adjust_dynamic_copy (h, s);
 }
 
+/* This function is called via elf_link_hash_traverse.  It resets GOT
+   and PLT (.GOT) reference counts back to -1 so normal PC32 relocation
+   will be done.  */
+
+static bfd_boolean
+elf_vax_discard_got_entries (struct elf_link_hash_entry *h,
+			     void *infoptr ATTRIBUTE_UNUSED)
+{
+  h->got.refcount = -1;
+  h->plt.refcount = -1;
+
+  return TRUE;
+}
+
+/* Discard unused dynamic data if this is a static link.  */
+
+static bfd_boolean
+elf_vax_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
+			      struct bfd_link_info *info)
+{
+  bfd *dynobj;
+  asection *s;
+
+  dynobj = elf_hash_table (info)->dynobj;
+
+  if (dynobj && !elf_hash_table (info)->dynamic_sections_created)
+    {
+      /* We may have created entries in the .rela.got and .got sections.
+	 However, if we are not creating the dynamic sections, we will
+	 not actually use these entries.  Reset the size of .rela.got
+	 and .got, which will cause them to get stripped from the output
+	 file below.  */
+      s = bfd_get_linker_section (dynobj, ".rela.got");
+      if (s != NULL)
+	s->size = 0;
+      s = bfd_get_linker_section (dynobj, ".got.plt");
+      if (s != NULL)
+	s->size = 0;
+      s = bfd_get_linker_section (dynobj, ".got");
+      if (s != NULL)
+	s->size = 0;
+    }
+
+  /* If this is a static link, we need to discard all the got entries we've
+     recorded.  */
+  if (!dynobj || !elf_hash_table (info)->dynamic_sections_created)
+    elf_link_hash_traverse (elf_hash_table (info),
+			    elf_vax_discard_got_entries,
+			    info);
+
+  return TRUE;
+}
+
 /* Set the sizes of the dynamic sections.  */
 
 static bfd_boolean
@@ -1092,29 +1120,12 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
 	}
     }
-  else
-    {
-      /* We may have created entries in the .rela.got and .got sections.
-	 However, if we are not creating the dynamic sections, we will
-	 not actually use these entries.  Reset the size of .rela.got
-	 and .got, which will cause it to get stripped from the output
-	 file below.  */
-      s = bfd_get_section_by_name (dynobj, ".rela.got");
-      if (s != NULL)
-	s->size = 0;
-      s = bfd_get_section_by_name (dynobj, ".got.plt");
-      if (s != NULL)
-	s->size = 0;
-      s = bfd_get_section_by_name (dynobj, ".got");
-      if (s != NULL)
-	s->size = 0;
-    }
 
   /* If this is a -Bsymbolic shared link, then we need to discard all PC
      relative relocs against symbols defined in a regular object.  We
@@ -1125,12 +1136,12 @@
 				elf_vax_discard_copies,
 				NULL);
 
-  /* If this is a -Bsymbolic shared link or a static link, we need to
-     discard all the got entries we've recorded.  Otherwise, we need to
-     instantiate (allocate space for them).  */
+  /* If this is a -Bsymbolic shared link, we need to discard all the got
+     entries we've recorded.  Otherwise, we need to instantiate (allocate
+     space for them).  */
   elf_link_hash_traverse (elf_hash_table (info),
 			  elf_vax_instantiate_got_entries,
-			  (PTR) info);
+			  info);
 
   /* The check_relocs and adjust_dynamic_symbol entry points have
      determined the sizes of the various dynamic sections.  Allocate
@@ -1269,7 +1280,7 @@
 
 static bfd_boolean
 elf_vax_discard_copies (struct elf_vax_link_hash_entry *h,
-			PTR ignore ATTRIBUTE_UNUSED)
+			void * ignore ATTRIBUTE_UNUSED)
 {
   struct elf_vax_pcrel_relocs_copied *s;
 
@@ -1283,15 +1294,15 @@
   return TRUE;
 }
 
-/* This function is called via elf_link_hash_traverse.  It looks for entries
-   that have GOT or PLT (.GOT) references.  If creating a static object or a
-   shared object with -Bsymbolic, it resets the reference count back to 0
-   and sets the offset to -1 so normal PC32 relocation will be done.  If
-   creating a shared object or executable, space in the .got and .rela.got
-   will be reserved for the symbol.  */
+/* This function is called via elf_link_hash_traverse.  It looks for
+   entries that have GOT or PLT (.GOT) references.  If creating a shared
+   object with -Bsymbolic, or the symbol has been forced local, then it
+   resets the reference count back to -1 so normal PC32 relocation will
+   be done.  Otherwise space in the .got and .rela.got will be reserved
+   for the symbol.  */
 
 static bfd_boolean
-elf_vax_instantiate_got_entries (struct elf_link_hash_entry *h, PTR infoptr)
+elf_vax_instantiate_got_entries (struct elf_link_hash_entry *h, void * infoptr)
 {
   struct bfd_link_info *info = (struct bfd_link_info *) infoptr;
   bfd *dynobj;
@@ -1303,25 +1314,18 @@
     return TRUE;
 
   dynobj = elf_hash_table (info)->dynobj;
-  if (dynobj == NULL)
-    return TRUE;
+  BFD_ASSERT (dynobj != NULL);
 
-  sgot = bfd_get_section_by_name (dynobj, ".got");
-  srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+  sgot = bfd_get_linker_section (dynobj, ".got");
+  srelgot = bfd_get_linker_section (dynobj, ".rela.got");
 
-  if (!elf_hash_table (info)->dynamic_sections_created
-      || (info->shared && info->symbolic)
-      || h->forced_local)
+  if (SYMBOL_REFERENCES_LOCAL (info, h))
     {
-      h->got.refcount = 0;
-      h->got.offset = (bfd_vma) -1;
-      h->plt.refcount = 0;
-      h->plt.offset = (bfd_vma) -1;
+      h->got.refcount = -1;
+      h->plt.refcount = -1;
     }
   else if (h->got.refcount > 0)
     {
-      bfd_boolean dyn;
-
       /* Make sure this symbol is output as a dynamic symbol.  */
       if (h->dynindx == -1)
 	{
@@ -1329,15 +1333,9 @@
 	    return FALSE;
 	}
 
-      dyn = elf_hash_table (info)->dynamic_sections_created;
       /* Allocate space in the .got and .rela.got sections.  */
-      if (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
-	  && (info->shared
-	      || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
-	{
-	  sgot->size += 4;
-	  srelgot->size += sizeof (Elf32_External_Rela);
-	}
+      sgot->size += 4;
+      srelgot->size += sizeof (Elf32_External_Rela);
     }
 
   return TRUE;
@@ -1450,9 +1448,9 @@
 	    relocation = 0;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -1462,56 +1460,26 @@
 	case R_VAX_GOT32:
 	  /* Relocation is to the address of the entry for this symbol
 	     in the global offset table.  */
+
+	  /* Resolve a GOTxx reloc against a local symbol directly,
+	     without using the global offset table.  */
 	  if (h == NULL
-	      || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
-	      || h->got.offset == (bfd_vma) -1
-	      || h->forced_local)
+	      || h->got.offset == (bfd_vma) -1)
 	    break;
 
-	  /* Relocation is the offset of the entry for this symbol in
-	     the global offset table.  */
-
 	  {
-	    bfd_boolean dyn;
 	    bfd_vma off;
 
 	    if (sgot == NULL)
 	      {
-		sgot = bfd_get_section_by_name (dynobj, ".got");
+		sgot = bfd_get_linker_section (dynobj, ".got");
 		BFD_ASSERT (sgot != NULL);
 	      }
 
-	    BFD_ASSERT (h != NULL);
 	    off = h->got.offset;
-	    BFD_ASSERT (off != (bfd_vma) -1);
 	    BFD_ASSERT (off < sgot->size);
 
-	    dyn = elf_hash_table (info)->dynamic_sections_created;
-	    if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
-		|| (info->shared
-		    && SYMBOL_REFERENCES_LOCAL (info, h)))
-	      {
-		/* The symbol was forced to be local
-		   because of a version file..  We must initialize
-		   this entry in the global offset table.  Since
-		   the offset must always be a multiple of 4, we
-		   use the least significant bit to record whether
-		   we have initialized it already.
-
-		   When doing a dynamic link, we create a .rela.got
-		   relocation entry to initialize the value.  This
-		   is done in the finish_dynamic_symbol routine.  */
-		if ((off & 1) != 0)
-		  off &= ~1;
-		else
-		  {
-		    bfd_put_32 (output_bfd, relocation + rel->r_addend,
-				sgot->contents + off);
-		    h->got.offset |= 1;
-		  }
-	      } else {
-		bfd_put_32 (output_bfd, rel->r_addend, sgot->contents + off);
-	      }
+	    bfd_put_32 (output_bfd, rel->r_addend, sgot->contents + off);
 
 	    relocation = sgot->output_offset + off;
 	    /* The GOT relocation uses the addend.  */
@@ -1538,28 +1506,18 @@
 	  /* Resolve a PLTxx reloc against a local symbol directly,
 	     without using the procedure linkage table.  */
 	  if (h == NULL
-	      || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
-	      || h->forced_local)
+	      || h->plt.offset == (bfd_vma) -1)
 	    break;
 
-	  if (h->plt.offset == (bfd_vma) -1
-	      || !elf_hash_table (info)->dynamic_sections_created)
-	    {
-	      /* We didn't make a PLT entry for this symbol.  This
-		 happens when statically linking PIC code, or when
-		 using -Bsymbolic.  */
-	      break;
-	    }
-
 	  if (splt == NULL)
 	    {
-	      splt = bfd_get_section_by_name (dynobj, ".plt");
+	      splt = bfd_get_linker_section (dynobj, ".plt");
 	      BFD_ASSERT (splt != NULL);
 	    }
 
 	  if (sgotplt == NULL)
 	    {
-	      sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
+	      sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
 	      BFD_ASSERT (sgotplt != NULL);
 	    }
 
@@ -1698,14 +1656,12 @@
 		    }
 		}
 
-	      if (!strcmp (bfd_get_section_name (input_bfd, input_section),
-			   ".text") != 0 ||
-		  (info->shared
-		   && ELF32_R_TYPE(outrel.r_info) != R_VAX_32
-		   && ELF32_R_TYPE(outrel.r_info) != R_VAX_RELATIVE
-		   && ELF32_R_TYPE(outrel.r_info) != R_VAX_COPY
-		   && ELF32_R_TYPE(outrel.r_info) != R_VAX_JMP_SLOT
-		   && ELF32_R_TYPE(outrel.r_info) != R_VAX_GLOB_DAT))
+	      if ((input_section->flags & SEC_CODE) != 0
+		  || (ELF32_R_TYPE (outrel.r_info) != R_VAX_32
+		      && ELF32_R_TYPE (outrel.r_info) != R_VAX_RELATIVE
+		      && ELF32_R_TYPE (outrel.r_info) != R_VAX_COPY
+		      && ELF32_R_TYPE (outrel.r_info) != R_VAX_JMP_SLOT
+		      && ELF32_R_TYPE (outrel.r_info) != R_VAX_GLOB_DAT))
 		{
 		  if (h != NULL)
 		    (*_bfd_error_handler)
@@ -1817,9 +1773,9 @@
 	 it up.  */
       BFD_ASSERT (h->dynindx != -1);
 
-      splt = bfd_get_section_by_name (dynobj, ".plt");
-      sgot = bfd_get_section_by_name (dynobj, ".got.plt");
-      srela = bfd_get_section_by_name (dynobj, ".rela.plt");
+      splt = bfd_get_linker_section (dynobj, ".plt");
+      sgot = bfd_get_linker_section (dynobj, ".got.plt");
+      srela = bfd_get_linker_section (dynobj, ".rela.plt");
       BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL);
 
       addend = 2 * (h->plt.offset & 1);
@@ -1881,31 +1837,16 @@
 
       /* This symbol has an entry in the global offset table.  Set it
 	 up.  */
-      sgot = bfd_get_section_by_name (dynobj, ".got");
-      srela = bfd_get_section_by_name (dynobj, ".rela.got");
+      sgot = bfd_get_linker_section (dynobj, ".got");
+      srela = bfd_get_linker_section (dynobj, ".rela.got");
       BFD_ASSERT (sgot != NULL && srela != NULL);
 
       rela.r_offset = (sgot->output_section->vma
 		       + sgot->output_offset
-		       + (h->got.offset &~ 1));
-
-      /* If the symbol was forced to be local because of a version file
-	 locally we just want to emit a RELATIVE reloc.  The entry in
-	 the global offset table will already have been initialized in
-	 the relocate_section function.  */
-      if (info->shared
-	  && h->dynindx == -1
-	  && h->def_regular)
-	{
-	  rela.r_info = ELF32_R_INFO (0, R_VAX_RELATIVE);
-	}
-      else
-	{
-	  rela.r_info = ELF32_R_INFO (h->dynindx, R_VAX_GLOB_DAT);
-	}
+		       + h->got.offset);
+      rela.r_info = ELF32_R_INFO (h->dynindx, R_VAX_GLOB_DAT);
       rela.r_addend = bfd_get_signed_32 (output_bfd,
-					 (sgot->contents
-					  + (h->got.offset & ~1)));
+					 sgot->contents + h->got.offset);
 
       loc = srela->contents;
       loc += srela->reloc_count++ * sizeof (Elf32_External_Rela);
@@ -1923,8 +1864,7 @@
 		  && (h->root.type == bfd_link_hash_defined
 		      || h->root.type == bfd_link_hash_defweak));
 
-      s = bfd_get_section_by_name (h->root.u.def.section->owner,
-				   ".rela.bss");
+      s = bfd_get_linker_section (dynobj, ".rela.bss");
       BFD_ASSERT (s != NULL);
 
       rela.r_offset = (h->root.u.def.value
@@ -1937,7 +1877,7 @@
     }
 
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+  if (h == elf_hash_table (info)->hdynamic
       || h == elf_hash_table (info)->hgot)
     sym->st_shndx = SHN_ABS;
 
@@ -1955,16 +1895,16 @@
 
   dynobj = elf_hash_table (info)->dynobj;
 
-  sgot = bfd_get_section_by_name (dynobj, ".got.plt");
+  sgot = bfd_get_linker_section (dynobj, ".got.plt");
   BFD_ASSERT (sgot != NULL);
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       asection *splt;
       Elf32_External_Dyn *dyncon, *dynconend;
 
-      splt = bfd_get_section_by_name (dynobj, ".plt");
+      splt = bfd_get_linker_section (dynobj, ".plt");
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       dyncon = (Elf32_External_Dyn *) sdyn->contents;
@@ -2049,13 +1989,16 @@
       bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 8);
     }
 
-  elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
+  if (elf_section_data (sgot->output_section) != NULL)
+    elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
 
   return TRUE;
 }
 
 static enum elf_reloc_type_class
-elf_vax_reloc_type_class (const Elf_Internal_Rela *rela)
+elf_vax_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			  const asection *rel_sec ATTRIBUTE_UNUSED,
+			  const Elf_Internal_Rela *rela)
 {
   switch ((int) ELF32_R_TYPE (rela->r_info))
     {
@@ -2091,6 +2034,8 @@
 #define elf_backend_check_relocs	elf_vax_check_relocs
 #define elf_backend_adjust_dynamic_symbol \
 					elf_vax_adjust_dynamic_symbol
+#define elf_backend_always_size_sections \
+					elf_vax_always_size_sections
 #define elf_backend_size_dynamic_sections \
 					elf_vax_size_dynamic_sections
 #define elf_backend_init_index_section	_bfd_elf_init_1_index_section
diff --git a/bfd/elf32-xc16x.c b/bfd/elf32-xc16x.c
index 11d9840..9f285c7 100644
--- a/bfd/elf32-xc16x.c
+++ b/bfd/elf32-xc16x.c
@@ -1,6 +1,6 @@
 /* Infineon XC16X-specific support for 16-bit ELF.
-   Copyright 2006, 2007, 2009, 2010  Free Software Foundation, Inc.
-   Contributed by KPIT Cummins Infosystems 
+   Copyright 2006, 2007, 2009, 2010, 2012 Free Software Foundation, Inc.
+   Contributed by KPIT Cummins Infosystems
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -381,7 +381,7 @@
 				   unresolved_reloc, warned);
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	{
 	  /* For relocs against symbols from removed linkonce sections,
 	     or sections discarded by a linker script, we just want the
@@ -389,7 +389,7 @@
 	  reloc_howto_type *howto;
 	  howto = xc16x_reloc_type_lookup (input_bfd, r_type);
 	  RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					   rel, relend, howto, contents);
+					   rel, 1, relend, howto, 0, contents);
 	}
 
       if (info->relocatable)
@@ -433,11 +433,11 @@
 
 static unsigned long
 elf32_xc16x_mach (flagword flags)
-{  
+{
   switch (flags)
     {
     case 0x1000:
-    default: 
+    default:
       return bfd_mach_xc16x;
 
     case 0x1001:
diff --git a/bfd/elf32-xgate.c b/bfd/elf32-xgate.c
new file mode 100644
index 0000000..b822260
--- /dev/null
+++ b/bfd/elf32-xgate.c
@@ -0,0 +1,730 @@
+/* Freescale XGATE-specific support for 32-bit ELF
+   Copyright 2010, 2011, 2012
+   Free Software Foundation, Inc.
+   Contributed by Sean Keys([email protected])
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "bfdlink.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "elf32-xgate.h"
+#include "elf/xgate.h"
+#include "opcode/xgate.h"
+#include "libiberty.h"
+
+/* Relocation functions.  */
+static reloc_howto_type *
+bfd_elf32_bfd_reloc_type_lookup (bfd *, bfd_reloc_code_real_type);
+static reloc_howto_type *
+bfd_elf32_bfd_reloc_name_lookup (bfd *, const char *);
+static void
+xgate_info_to_howto_rel (bfd *, arelent *, Elf_Internal_Rela *);
+static bfd_boolean
+xgate_elf_set_mach_from_flags (bfd *);
+static struct bfd_hash_entry *
+stub_hash_newfunc (struct bfd_hash_entry *, struct bfd_hash_table *,
+    const char *);
+static struct bfd_link_hash_table*
+xgate_elf_bfd_link_hash_table_create (bfd *);
+
+/* Use REL instead of RELA to save space */
+#define USE_REL	1
+
+static reloc_howto_type elf_xgate_howto_table[] =
+{
+  /* This reloc does nothing.  */
+  HOWTO (R_XGATE_NONE, /* type */
+	 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_XGATE_NONE", /* name */
+	 FALSE, /* partial_inplace */
+	 0, /* src_mask */
+	 0, /* dst_mask */
+	 FALSE), /* pcrel_offset */
+
+  /* A 8 bit absolute relocation.  */
+  HOWTO (R_XGATE_8, /* type */
+	 0, /* rightshift */
+	 0, /* size (0 = byte, 1 = short, 2 = long) */
+	 8, /* bitsize */
+	 FALSE, /* pc_relative */
+	 0, /* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_XGATE_8", /* name */
+	 FALSE, /* partial_inplace */
+	 0x00ff, /* src_mask */
+	 0x00ff, /* dst_mask */
+	 FALSE), /* pcrel_offset */
+
+  /* A 8 bit PC-rel relocation.  */
+  HOWTO (R_XGATE_PCREL_8, /* type */
+	 0, /* rightshift */
+	 0, /* size (0 = byte, 1 = short, 2 = long) */
+	 8, /* bitsize */
+	 TRUE, /* pc_relative */
+	 0, /* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_XGATE_PCREL_8", /* name */
+	 FALSE, /* partial_inplace */
+	 0x00ff, /* src_mask */
+	 0x00ff, /* dst_mask */
+	 TRUE), /* pcrel_offset */
+
+  /* A 16 bit absolute relocation.  */
+  HOWTO (R_XGATE_16, /* type */
+	 0, /* rightshift */
+	 1, /* size (0 = byte, 1 = short, 2 = long) */
+	 16, /* bitsize */
+	 FALSE, /* pc_relative */
+	 0, /* bitpos */
+	 complain_overflow_dont /*bitfield */, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_XGATE_16", /* name */
+	 FALSE, /* partial_inplace */
+	 0xffff, /* src_mask */
+	 0xffff, /* dst_mask */
+	 FALSE), /* pcrel_offset */
+
+  /* A 32 bit absolute relocation.  This one is never used for the
+     code relocation.  It's used by gas for -gstabs generation.  */
+  HOWTO (R_XGATE_32, /* type */
+	 0, /* rightshift */
+	 2, /* size (0 = byte, 1 = short, 2 = long) */
+	 32, /* bitsize */
+	 FALSE, /* pc_relative */
+	 0, /* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_XGATE_32", /* name */
+	 FALSE, /* partial_inplace */
+	 0xffffffff, /* src_mask */
+	 0xffffffff, /* dst_mask */
+	 FALSE), /* pcrel_offset */
+
+  /* A 16 bit PC-rel relocation.  */
+  HOWTO (R_XGATE_PCREL_16, /* type */
+	 0, /* rightshift */
+	 1, /* size (0 = byte, 1 = short, 2 = long) */
+	 16, /* bitsize */
+	 TRUE, /* pc_relative */
+	 0, /* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_XGATE_PCREL_16", /* name */
+	 FALSE, /* partial_inplace */
+	 0xffff, /* src_mask */
+	 0xffff, /* dst_mask */
+	 TRUE), /* pcrel_offset */
+
+  /* GNU extension to record C++ vtable hierarchy.  */
+  HOWTO (R_XGATE_GNU_VTINHERIT, /* type */
+	 0, /* rightshift */
+	 1, /* size (0 = byte, 1 = short, 2 = long) */
+	 0, /* bitsize */
+	 FALSE, /* pc_relative */
+	 0, /* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 NULL, /* special_function */
+	 "R_XGATE_GNU_VTINHERIT", /* name */
+	 FALSE, /* partial_inplace */
+	 0, /* src_mask */
+	 0, /* dst_mask */
+	 FALSE), /* pcrel_offset */
+
+  /* GNU extension to record C++ vtable member usage.  */
+  HOWTO (R_XGATE_GNU_VTENTRY, /* type */
+	 0, /* rightshift */
+	 1, /* size (0 = byte, 1 = short, 2 = long) */
+	 0, /* bitsize */
+	 FALSE, /* pc_relative */
+	 0, /* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 _bfd_elf_rel_vtable_reloc_fn, /* special_function */
+	 "R_XGATE_GNU_VTENTRY", /* name */
+	 FALSE, /* partial_inplace */
+	 0, /* src_mask */
+	 0, /* dst_mask */
+	 FALSE), /* pcrel_offset */
+
+  /* A 24 bit relocation.  */
+  HOWTO (R_XGATE_24, /* type */
+	 0, /* rightshift */
+	 1, /* size (0 = byte, 1 = short, 2 = long) */
+	 16, /* bitsize */
+	 FALSE, /* pc_relative */
+	 0, /* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_XGATE_IMM8_LO", /* name */
+	 FALSE, /* partial_inplace */
+	 0x00ff, /* src_mask */
+	 0x00ff, /* dst_mask */
+	 FALSE), /* pcrel_offset */
+
+  /* A 16-bit low relocation.  */
+  HOWTO (R_XGATE_LO16, /* type */
+	 8, /* rightshift */
+	 1, /* size (0 = byte, 1 = short, 2 = long) */
+	 16, /* bitsize */
+	 FALSE, /* pc_relative */
+	 0, /* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_XGATE_IMM8_HI", /* name */
+	 FALSE, /* partial_inplace */
+	 0x00ff, /* src_mask */
+	 0x00ff, /* dst_mask */
+	 FALSE), /* pcrel_offset */
+
+  /* A page relocation.  */
+  HOWTO (R_XGATE_GPAGE, /* type */
+	 0, /* rightshift */
+	 0, /* size (0 = byte, 1 = short, 2 = long) */
+	 8, /* bitsize */
+	 FALSE, /* pc_relative */
+	 0, /* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 xgate_elf_special_reloc,/* special_function */
+	 "R_XGATE_GPAGE", /* name */
+	 FALSE, /* partial_inplace */
+	 0x00ff, /* src_mask */
+	 0x00ff, /* dst_mask */
+	 FALSE), /* pcrel_offset */
+
+  /* A 9 bit absolute relocation.   */
+  HOWTO (R_XGATE_PCREL_9, /* type */
+	 0, /* rightshift */
+	 1, /* size (0 = byte, 1 = short, 2 = long) */
+	 9, /* bitsize */
+	 TRUE, /* pc_relative */
+	 0, /* bitpos */
+	 complain_overflow_bitfield, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_XGATE_PCREL_9", /* name */
+	 FALSE, /* partial_inplace */
+	 0xffff, /* src_mask */
+	 0xffff, /* dst_mask */
+	 TRUE), /* pcrel_offset */
+
+  /* A 8 bit absolute relocation (upper address).  */
+  HOWTO (R_XGATE_PCREL_10, /* type */
+	 8, /* rightshift */
+	 0, /* size (0 = byte, 1 = short, 2 = long) */
+	 10, /* bitsize */
+	 TRUE, /* pc_relative */
+	 0, /* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_XGATE_PCREL_10", /* name */
+	 FALSE, /* partial_inplace */
+	 0x00ff, /* src_mask */
+	 0x00ff, /* dst_mask */
+	 TRUE), /* pcrel_offset */
+
+  /* A 8 bit absolute relocation.  */
+  HOWTO (R_XGATE_IMM8_LO, /* type */
+	 0, /* rightshift */
+	 1, /* size (0 = byte, 1 = short, 2 = long) */
+	 16, /* bitsize */
+	 FALSE, /* pc_relative */
+	 0, /* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_XGATE_IMM8_LO", /* name */
+	 FALSE, /* partial_inplace */
+	 0xffff, /* src_mask */
+	 0xffff, /* dst_mask */
+	 FALSE), /* pcrel_offset */
+
+  /* A 16 bit absolute relocation (upper address).  */
+  HOWTO (R_XGATE_IMM8_HI, /* type */
+	 8, /* rightshift */
+	 1, /* size (0 = byte, 1 = short, 2 = long) */
+	 16, /* bitsize */
+	 FALSE, /* pc_relative */
+	 0, /* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_XGATE_IMM8_HI", /* name */
+	 FALSE, /* partial_inplace */
+	 0x00ff, /* src_mask */
+	 0x00ff, /* dst_mask */
+	 FALSE), /* pcrel_offset */
+
+  /* A 3 bit absolute relocation.  */
+  HOWTO (R_XGATE_IMM3, /* type */
+	 8, /* rightshift */
+	 1, /* size (0 = byte, 1 = short, 2 = long) */
+	 16, /* bitsize */
+	 FALSE, /* pc_relative */
+	 0, /* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_XGATE_IMM3", /* name */
+	 FALSE, /* partial_inplace */
+	 0x00ff, /* src_mask */
+	 0x00ff, /* dst_mask */
+	 FALSE), /* pcrel_offset */
+
+  /* A 4 bit absolute relocation.  */
+  HOWTO (R_XGATE_IMM4, /* type */
+	 8, /* rightshift */
+	 1, /* size (0 = byte, 1 = short, 2 = long) */
+	 16, /* bitsize */
+	 FALSE, /* pc_relative */
+	 0, /* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_XGATE_IMM4", /* name */
+	 FALSE, /* partial_inplace */
+	 0x00ff, /* src_mask */
+	 0x00ff, /* dst_mask */
+	 FALSE), /* pcrel_offset */
+
+  /* A 5 bit absolute relocation.  */
+  HOWTO (R_XGATE_IMM5, /* type */
+	 8, /* rightshift */
+	 1, /* size (0 = byte, 1 = short, 2 = long) */
+	 16, /* bitsize */
+	 FALSE, /* pc_relative */
+	 0, /* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_XGATE_IMM5", /* name */
+	 FALSE, /* partial_inplace */
+	 0x00ff, /* src_mask */
+	 0x00ff, /* dst_mask */
+	 FALSE), /* pcrel_offset */
+
+  /* Mark beginning of a jump instruction (any form).  */
+  HOWTO (R_XGATE_RL_JUMP, /* type */
+	 0, /* rightshift */
+	 1, /* size (0 = byte, 1 = short, 2 = long) */
+	 0, /* bitsize */
+	 FALSE, /* pc_relative */
+	 0, /* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 xgate_elf_ignore_reloc, /* special_function */
+	 "R_XGATE_RL_JUMP", /* name */
+	 TRUE, /* partial_inplace */
+	 0, /* src_mask */
+	 0, /* dst_mask */
+	 TRUE), /* pcrel_offset */
+
+  /* Mark beginning of Gcc relaxation group instruction.  */
+  HOWTO (R_XGATE_RL_GROUP, /* type */
+	 0, /* rightshift */
+	 1, /* size (0 = byte, 1 = short, 2 = long) */
+	 0, /* bitsize */
+	 FALSE, /* pc_relative */
+	 0, /* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 xgate_elf_ignore_reloc, /* special_function */
+	 "R_XGATE_RL_GROUP", /* name */
+	 TRUE, /* partial_inplace */
+	 0, /* src_mask */
+	 0, /* dst_mask */
+	 TRUE), /* pcrel_offset */
+};
+
+/* Map BFD reloc types to XGATE ELF reloc types.  */
+
+struct xgate_reloc_map
+{
+  bfd_reloc_code_real_type bfd_reloc_val;
+  unsigned char elf_reloc_val;
+};
+
+static const struct xgate_reloc_map xgate_reloc_map[] =
+{
+  {BFD_RELOC_NONE, R_XGATE_NONE},
+  {BFD_RELOC_8, R_XGATE_8},
+  {BFD_RELOC_8_PCREL, R_XGATE_PCREL_8},
+  {BFD_RELOC_16_PCREL, R_XGATE_PCREL_16},
+  {BFD_RELOC_16, R_XGATE_16},
+  {BFD_RELOC_32, R_XGATE_32},
+
+  {BFD_RELOC_VTABLE_INHERIT, R_XGATE_GNU_VTINHERIT},
+  {BFD_RELOC_VTABLE_ENTRY, R_XGATE_GNU_VTENTRY},
+
+  {BFD_RELOC_XGATE_LO16, R_XGATE_LO16},
+  {BFD_RELOC_XGATE_GPAGE, R_XGATE_GPAGE},
+  {BFD_RELOC_XGATE_24, R_XGATE_24},
+  {BFD_RELOC_XGATE_PCREL_9, R_XGATE_PCREL_9},
+  {BFD_RELOC_XGATE_PCREL_10,  R_XGATE_PCREL_10},
+  {BFD_RELOC_XGATE_IMM8_LO, R_XGATE_IMM8_LO},
+  {BFD_RELOC_XGATE_IMM8_HI, R_XGATE_IMM8_HI},
+  {BFD_RELOC_XGATE_IMM3, R_XGATE_IMM3},
+  {BFD_RELOC_XGATE_IMM4, R_XGATE_IMM4},
+  {BFD_RELOC_XGATE_IMM5, R_XGATE_IMM5},
+
+  {BFD_RELOC_XGATE_RL_JUMP, R_XGATE_RL_JUMP},
+  {BFD_RELOC_XGATE_RL_GROUP, R_XGATE_RL_GROUP},
+};
+
+static reloc_howto_type *
+bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+				 bfd_reloc_code_real_type code)
+{
+  unsigned int i;
+
+  for (i = 0; i < ARRAY_SIZE (xgate_reloc_map); i++)
+    if (xgate_reloc_map[i].bfd_reloc_val == code)
+      return &elf_xgate_howto_table[xgate_reloc_map[i].elf_reloc_val];
+
+  return NULL;
+}
+
+static reloc_howto_type *
+bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
+{
+  unsigned int i;
+
+  for (i = 0; i < ARRAY_SIZE (elf_xgate_howto_table); i++)
+    if (elf_xgate_howto_table[i].name != NULL
+        && strcasecmp (elf_xgate_howto_table[i].name, r_name) == 0)
+      return &elf_xgate_howto_table[i];
+
+  return NULL;
+}
+
+/* Set the howto pointer for an XGATE ELF reloc.  */
+
+static void
+xgate_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
+			 arelent *cache_ptr,
+			 Elf_Internal_Rela *dst)
+{
+  unsigned int r_type;
+
+  r_type = ELF32_R_TYPE (dst->r_info);
+  BFD_ASSERT(r_type < (unsigned int) R_XGATE_max);
+  cache_ptr->howto = &elf_xgate_howto_table[r_type];
+}
+
+/* Free the derived linker hash table.  */
+
+void
+xgate_elf_bfd_link_hash_table_free (struct bfd_link_hash_table *hash)
+{
+  struct xgate_elf_link_hash_table *ret =
+      (struct xgate_elf_link_hash_table *) hash;
+
+  bfd_hash_table_free (ret->stub_hash_table);
+  free (ret->stub_hash_table);
+  _bfd_elf_link_hash_table_free (hash);
+}
+
+/* Create a XGATE ELF linker hash table.  */
+
+static struct bfd_link_hash_table*
+xgate_elf_bfd_link_hash_table_create (bfd *abfd)
+{
+  struct xgate_elf_link_hash_table *ret;
+  bfd_size_type amt = sizeof(struct xgate_elf_link_hash_table);
+
+  ret = (struct xgate_elf_link_hash_table *) bfd_zmalloc (amt);
+  if (ret == (struct xgate_elf_link_hash_table *) NULL)
+    return NULL;
+
+  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
+      _bfd_elf_link_hash_newfunc, sizeof(struct elf_link_hash_entry),
+      XGATE_ELF_DATA))
+    {
+      free (ret);
+      return NULL;
+    }
+
+  /* Init the stub hash table too.  */
+  amt = sizeof(struct bfd_hash_table);
+  ret->stub_hash_table = (struct bfd_hash_table*) bfd_zmalloc (amt);
+  if (ret->stub_hash_table == NULL)
+    {
+      free (ret);
+      return NULL;
+    }
+
+  if (!bfd_hash_table_init (ret->stub_hash_table, stub_hash_newfunc,
+      sizeof(struct elf32_xgate_stub_hash_entry)))
+    {
+      free (ret->stub_hash_table);
+      free (ret);
+      return NULL;
+    }
+
+  return &ret->root.root;
+}
+
+static bfd_boolean
+xgate_elf_set_mach_from_flags (bfd *abfd ATTRIBUTE_UNUSED)
+{
+  return TRUE;
+}
+
+/* Specific sections:
+ - The .page0 is a data section that is mapped in [0x0000..0x00FF].
+   Page0 accesses are faster on the M68HC12.
+ - The .vectors is the section that represents the interrupt
+   vectors.
+ - The .xgate section is starts in 0xE08800 or as xgate sees it 0x0800. */
+static const struct bfd_elf_special_section elf32_xgate_special_sections[] =
+{
+  { STRING_COMMA_LEN (".eeprom"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
+  { STRING_COMMA_LEN (".page0"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
+  { STRING_COMMA_LEN (".softregs"), 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE },
+  { STRING_COMMA_LEN (".vectors"), 0, SHT_PROGBITS, SHF_ALLOC },
+/*{ STRING_COMMA_LEN (".xgate"),    0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
+  TODO finish this implementation */
+  { NULL, 0, 0, 0, 0 }
+};
+
+struct xgate_scan_param
+{
+  struct xgate_page_info* pinfo;
+  bfd_boolean use_memory_banks;
+};
+
+/* Assorted hash table functions.  */
+
+/* Initialize an entry in the stub hash table.  */
+
+static struct bfd_hash_entry *
+stub_hash_newfunc (struct bfd_hash_entry *entry,
+		   struct bfd_hash_table *table ATTRIBUTE_UNUSED,
+		   const char *string ATTRIBUTE_UNUSED)
+{
+  return entry;
+}
+
+/* Hook called by the linker routine which adds symbols from an object
+   file. */
+
+bfd_boolean
+elf32_xgate_add_symbol_hook (bfd *abfd ATTRIBUTE_UNUSED,
+			     struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			     Elf_Internal_Sym *sym,
+			     const char **namep ATTRIBUTE_UNUSED,
+			     flagword *flagsp ATTRIBUTE_UNUSED,
+			     asection **secp ATTRIBUTE_UNUSED,
+			     bfd_vma *valp ATTRIBUTE_UNUSED)
+{
+  /* For some reason the st_target_internal value is not retained
+     after xgate_frob_symbol is called, hence this temp hack.  */
+  sym->st_target_internal = 1;
+  return TRUE;
+}
+
+/* External entry points for sizing and building linker stubs.  */
+
+/* Set up various things so that we can make a list of input sections
+   for each output section included in the link.  Returns -1 on error,
+   0 when no stubs will be needed, and 1 on success.  */
+
+int
+elf32_xgate_setup_section_lists (bfd *output_bfd ATTRIBUTE_UNUSED,
+				 struct bfd_link_info *info ATTRIBUTE_UNUSED)
+{
+  return 1;
+}
+
+/* Determine and set the size of the stub section for a final link.
+   The basic idea here is to examine all the relocations looking for
+   PC-relative calls to a target that is unreachable with any "9-bit PC-REL"
+   instruction.  */
+
+bfd_boolean
+elf32_xgate_size_stubs (bfd *output_bfd ATTRIBUTE_UNUSED,
+			bfd *stub_bfd ATTRIBUTE_UNUSED,
+			struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			asection * (*add_stub_section) (const char*, asection*) ATTRIBUTE_UNUSED)
+{
+  return FALSE;
+}
+
+/* Build all the stubs associated with the current output file.  The
+   stubs are kept in a hash table attached to the main linker hash
+   table.  This function is called via xgateelf_finish in the
+   linker.  */
+
+bfd_boolean
+elf32_xgate_build_stubs (bfd *abfd ATTRIBUTE_UNUSED,
+			 struct bfd_link_info *info ATTRIBUTE_UNUSED)
+{
+  return TRUE;
+}
+
+void
+xgate_elf_get_bank_parameters (struct bfd_link_info *info ATTRIBUTE_UNUSED)
+{
+  return;
+}
+
+/* This function is used for relocs which are only used for relaxing,
+   which the linker should otherwise ignore.  */
+
+bfd_reloc_status_type
+xgate_elf_ignore_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+			arelent *reloc_entry,
+			asymbol *symbol ATTRIBUTE_UNUSED,
+			void *data ATTRIBUTE_UNUSED,
+			asection *input_section,
+			bfd *output_bfd,
+			char **error_message ATTRIBUTE_UNUSED)
+{
+  if (output_bfd != NULL)
+    reloc_entry->address += input_section->output_offset;
+  return bfd_reloc_ok;
+}
+
+bfd_reloc_status_type
+xgate_elf_special_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+			 arelent *reloc_entry ATTRIBUTE_UNUSED,
+			 asymbol *symbol ATTRIBUTE_UNUSED,
+			 void *data ATTRIBUTE_UNUSED,
+			 asection *input_section ATTRIBUTE_UNUSED,
+			 bfd *output_bfd ATTRIBUTE_UNUSED,
+			 char **error_message ATTRIBUTE_UNUSED)
+{
+  abort ();
+}
+
+/* Look through the relocs for a section during the first phase.
+   Since we don't do .gots or .plts, we just need to consider the
+   virtual table relocs for gc.  */
+
+bfd_boolean
+elf32_xgate_check_relocs (bfd *abfd ATTRIBUTE_UNUSED,
+			  struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			  asection *sec ATTRIBUTE_UNUSED,
+			  const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED)
+{
+  return TRUE;
+}
+
+/* Relocate a XGATE/S12x ELF section.  */
+
+bfd_boolean
+elf32_xgate_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
+			      struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			      bfd *input_bfd ATTRIBUTE_UNUSED,
+			      asection *input_section ATTRIBUTE_UNUSED,
+			      bfd_byte *contents ATTRIBUTE_UNUSED,
+			      Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED,
+			      Elf_Internal_Sym *local_syms ATTRIBUTE_UNUSED,
+			      asection **local_sections ATTRIBUTE_UNUSED)
+{
+  return TRUE;
+}
+
+/* Set and control ELF flags in ELF header.  */
+
+bfd_boolean
+_bfd_xgate_elf_set_private_flags (bfd *abfd ATTRIBUTE_UNUSED,
+				  flagword flags ATTRIBUTE_UNUSED)
+{
+  return TRUE;
+}
+
+/* Merge backend specific data from an object file to the output
+   object file when linking.  */
+
+bfd_boolean
+_bfd_xgate_elf_merge_private_bfd_data (bfd *ibfd ATTRIBUTE_UNUSED,
+				       bfd *obfd ATTRIBUTE_UNUSED)
+{
+  return TRUE;
+}
+
+bfd_boolean
+_bfd_xgate_elf_print_private_bfd_data (bfd *abfd, void *ptr)
+{
+  FILE *file = (FILE *) ptr;
+
+  BFD_ASSERT (abfd != NULL && ptr != NULL);
+
+  /* Print normal ELF private data.  */
+  _bfd_elf_print_private_bfd_data (abfd, ptr);
+
+  /* xgettext:c-format */
+  fprintf (file, _("private flags = %lx:"), elf_elfheader (abfd)->e_flags);
+
+  if (elf_elfheader (abfd)->e_flags & E_XGATE_I32)
+    fprintf (file, _("[abi=32-bit int, "));
+  else
+    fprintf (file, _("[abi=16-bit int, "));
+
+  if (elf_elfheader (abfd)->e_flags & E_XGATE_F64)
+    fprintf (file, _("64-bit double, "));
+  else
+    fprintf (file, _("32-bit double, "));
+  if (elf_elfheader (abfd)->e_flags & EF_XGATE_MACH)
+    fprintf (file, _("cpu=XGATE]"));
+  else
+    fprintf (file, _("error reading cpu type from elf private data"));
+  fputc ('\n', file);
+
+  return TRUE;
+}
+
+void
+elf32_xgate_post_process_headers (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_info *link_info ATTRIBUTE_UNUSED)
+{
+
+}
+
+#define ELF_ARCH                             bfd_arch_xgate
+#define ELF_MACHINE_CODE                     EM_XGATE
+#define ELF_TARGET_ID                        XGATE_ELF_DATA
+
+#define ELF_MAXPAGESIZE                      0x1000
+
+#define TARGET_BIG_SYM                       bfd_elf32_xgate_vec
+#define TARGET_BIG_NAME                      "elf32-xgate"
+
+#define elf_info_to_howto                    0
+#define elf_info_to_howto_rel                xgate_info_to_howto_rel
+#define elf_backend_check_relocs             elf32_xgate_check_relocs
+#define elf_backend_relocate_section         elf32_xgate_relocate_section
+#define elf_backend_object_p                 xgate_elf_set_mach_from_flags
+#define elf_backend_final_write_processing   0
+#define elf_backend_can_gc_sections          1
+#define elf_backend_special_sections         elf32_xgate_special_sections
+#define elf_backend_post_process_headers     elf32_xgate_post_process_headers
+#define elf_backend_add_symbol_hook          elf32_xgate_add_symbol_hook
+
+#define bfd_elf32_bfd_link_hash_table_create xgate_elf_bfd_link_hash_table_create
+#define bfd_elf32_bfd_link_hash_table_free   xgate_elf_bfd_link_hash_table_free
+#define bfd_elf32_bfd_merge_private_bfd_data _bfd_xgate_elf_merge_private_bfd_data
+#define bfd_elf32_bfd_set_private_flags      _bfd_xgate_elf_set_private_flags
+#define bfd_elf32_bfd_print_private_bfd_data _bfd_xgate_elf_print_private_bfd_data
+
+#define xgate_stub_hash_lookup(table, string, create, copy)	\
+    ((struct elf32_xgate_stub_hash_entry *) \
+        bfd_hash_lookup ((table), (string), (create), (copy)))
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-xgate.h b/bfd/elf32-xgate.h
new file mode 100644
index 0000000..7ecdf12
--- /dev/null
+++ b/bfd/elf32-xgate.h
@@ -0,0 +1,144 @@
+/* Freescale XGATE-specific support for 32-bit ELF
+   Copyright 2012 Free Software Foundation, Inc.
+
+   Contributed by Sean Keys ([email protected])
+   (Heavily copied from the HC11 port by Stephane Carrez ([email protected]))
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#ifndef _ELF32_XGATE_H
+#define _ELF32_XGATE_H
+
+#include "elf-bfd.h"
+#include "bfdlink.h"
+#include "elf/xgate.h"
+
+/* Set and control ELF flags in ELF header.  */
+extern bfd_boolean _bfd_xgate_elf_merge_private_bfd_data (bfd*,bfd*);
+extern bfd_boolean _bfd_xgate_elf_set_private_flags (bfd*,flagword);
+extern bfd_boolean _bfd_xgate_elf_print_private_bfd_data (bfd*, void*);
+
+struct elf32_xgate_stub_hash_entry
+{
+  /* Base hash table entry structure.  */
+  struct bfd_hash_entry root;
+
+  /* The stub section.  */
+  asection *stub_sec;
+
+  /* Offset within stub_sec of the beginning of this stub.  */
+  bfd_vma stub_offset;
+
+  /* Given the symbol's value and its section we can determine its final
+     value when building the stubs (so the stub knows where to jump.  */
+  bfd_vma target_value;
+  asection *target_section;
+};
+
+struct xgate_page_info
+{
+  bfd_vma bank_virtual;
+  bfd_vma bank_physical;
+  bfd_vma bank_physical_end;
+  bfd_vma bank_mask;
+  bfd_vma bank_size;
+  int bank_shift;
+  int bank_param_initialized;
+  bfd_vma trampoline_addr;
+};
+
+struct xgate_elf_link_hash_table
+{
+  struct elf_link_hash_table root;
+  struct xgate_page_info pinfo;
+
+  /* The stub hash table.  */
+  struct bfd_hash_table* stub_hash_table;
+
+  /* Linker stub bfd.  */
+  bfd *stub_bfd;
+
+  asection* stub_section;
+  asection* tramp_section;
+
+  /* Linker call-backs.  */
+  asection * (*add_stub_section) (const char *, asection *);
+
+  /* Assorted information used by elf32_hppa_size_stubs.  */
+  unsigned int bfd_count;
+  int          top_index;
+  asection **  input_list;
+
+  /* Small local sym cache.  */
+  struct sym_cache sym_cache;
+
+  bfd_boolean (*size_one_stub) (struct bfd_hash_entry*, void*);
+  bfd_boolean (*build_one_stub) (struct bfd_hash_entry*, void*);
+};
+
+/* Get the XGate ELF linker hash table from a link_info structure.  */
+
+#define xgate_elf_hash_table(p) \
+  ((struct xgate_elf_link_hash_table *) ((p)->hash))
+
+/* Create a XGATE ELF linker hash table.  */
+
+extern struct xgate_elf_link_hash_table* xgate_elf_hash_table_create
+  (bfd *);
+extern void xgate_elf_bfd_link_hash_table_free (struct bfd_link_hash_table *);
+
+extern void xgate_elf_get_bank_parameters (struct bfd_link_info *);
+
+/* Return 1 if the address is in banked memory.
+   This can be applied to a virtual address and to a physical address.  */
+extern int xgate_addr_is_banked (struct xgate_page_info *, bfd_vma);
+
+/* Return the physical address seen by the processor, taking
+   into account banked memory.  */
+extern bfd_vma xgate_phys_addr (struct xgate_page_info *, bfd_vma);
+
+/* Return the page number corresponding to an address in banked memory.  */
+extern bfd_vma xgate_phys_page (struct xgate_page_info *, bfd_vma);
+
+bfd_reloc_status_type xgate_elf_ignore_reloc
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+bfd_reloc_status_type xgate_elf_special_reloc
+  (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
+
+bfd_boolean elf32_xgate_check_relocs
+  (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *);
+bfd_boolean elf32_xgate_relocate_section
+  (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+   Elf_Internal_Rela *, Elf_Internal_Sym *, asection **);
+
+bfd_boolean elf32_xgate_add_symbol_hook
+  (bfd *, struct bfd_link_info *, Elf_Internal_Sym *, const char **,
+   flagword *, asection **, bfd_vma *);
+
+/* Tweak the OSABI field of the elf header.  */
+extern void elf32_xgate_post_process_headers (bfd *, struct bfd_link_info *);
+
+int elf32_xgate_setup_section_lists (bfd *, struct bfd_link_info *);
+
+bfd_boolean elf32_xgate_size_stubs
+  (bfd *, bfd *, struct bfd_link_info *,
+   asection * (*) (const char *, asection *));
+
+bfd_boolean elf32_xgate_build_stubs (bfd * abfd, struct bfd_link_info *);
+
+#endif /* _ELF32_XGATE_H */
diff --git a/bfd/elf32-xstormy16.c b/bfd/elf32-xstormy16.c
index 6141783..851ebbc 100644
--- a/bfd/elf32-xstormy16.c
+++ b/bfd/elf32-xstormy16.c
@@ -1,5 +1,5 @@
 /* Xstormy16-specific support for 32-bit ELF.
-   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2011
+   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -437,6 +437,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       switch (ELF32_R_TYPE (rel->r_info))
@@ -456,18 +460,15 @@
 	    elf_hash_table (info)->dynobj = dynobj = abfd;
 	  if (splt == NULL)
 	    {
-	      splt = bfd_get_section_by_name (dynobj, ".plt");
+	      splt = bfd_get_linker_section (dynobj, ".plt");
 	      if (splt == NULL)
 		{
-		  splt = bfd_make_section_with_flags (dynobj, ".plt",
-						      (SEC_ALLOC
-						       | SEC_LOAD
-						       | SEC_HAS_CONTENTS
-						       | SEC_IN_MEMORY
-						       | SEC_LINKER_CREATED
-						       | SEC_READONLY
-						       | SEC_CODE));
+		  flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+				    | SEC_IN_MEMORY | SEC_LINKER_CREATED
+				    | SEC_READONLY | SEC_CODE);
 
+		  splt = bfd_make_section_anyway_with_flags (dynobj, ".plt",
+							     flags);
 		  if (splt == NULL
 		      || ! bfd_set_section_alignment (dynobj, splt, 1))
 		    return FALSE;
@@ -719,7 +720,7 @@
   if (dynobj == NULL)
     return TRUE;
 
-  splt = bfd_get_section_by_name (dynobj, ".plt");
+  splt = bfd_get_linker_section (dynobj, ".plt");
   BFD_ASSERT (splt != NULL);
 
   splt->contents = bfd_zalloc (dynobj, splt->size);
@@ -783,7 +784,7 @@
   dynobj = elf_hash_table (info)->dynobj;
   splt = NULL;
   if (dynobj != NULL)
-    splt = bfd_get_section_by_name (dynobj, ".plt");
+    splt = bfd_get_linker_section (dynobj, ".plt");
 
   for (rel = relocs; rel < relend; rel ++)
     {
@@ -825,9 +826,9 @@
 				   unresolved_reloc, warned);
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -973,7 +974,7 @@
      been filled in.  */
 
   if ((dynobj = elf_hash_table (info)->dynobj) != NULL
-      && (splt = bfd_get_section_by_name (dynobj, ".plt")) != NULL)
+      && (splt = bfd_get_linker_section (dynobj, ".plt")) != NULL)
     {
       bfd_byte *contents = splt->contents;
       unsigned int i, size = splt->size;
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index c6e4fb4..28ed9aa 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -1,5 +1,5 @@
 /* Xtensa-specific support for 32-bit ELF.
-   Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -655,7 +655,7 @@
   struct elf_xtensa_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_xtensa_link_hash_table);
 
-  ret = bfd_malloc (amt);
+  ret = bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
 
@@ -668,16 +668,6 @@
       return NULL;
     }
 
-  ret->sgot = NULL;
-  ret->sgotplt = NULL;
-  ret->srelgot = NULL;
-  ret->splt = NULL;
-  ret->srelplt = NULL;
-  ret->sgotloc = NULL;
-  ret->spltlittbl = NULL;
-
-  ret->plt_reloc_count = 0;
-
   /* Create a hash entry for "_TLS_MODULE_BASE_" to speed up checking
      for it later.  */
   tlsbase = elf_link_hash_lookup (&ret->elf, "_TLS_MODULE_BASE_",
@@ -752,7 +742,7 @@
 	      != GET_XTENSA_PROP_ALIGNMENT (b->flags)))
 	return (GET_XTENSA_PROP_ALIGNMENT (a->flags)
 		- GET_XTENSA_PROP_ALIGNMENT (b->flags));
-      
+
       if ((a->flags & XTENSA_PROP_UNREACHABLE)
 	  != (b->flags & XTENSA_PROP_UNREACHABLE))
 	return ((b->flags & XTENSA_PROP_UNREACHABLE)
@@ -814,7 +804,7 @@
   if (table_section)
     table_size = table_section->size;
 
-  if (table_size == 0) 
+  if (table_size == 0)
     {
       *table_p = NULL;
       return 0;
@@ -849,7 +839,7 @@
   section_limit = bfd_get_section_limit (abfd, section);
   rel_end = internal_relocs + table_section->reloc_count;
 
-  for (off = 0; off < table_size; off += table_entry_size) 
+  for (off = 0; off < table_size; off += table_entry_size)
     {
       bfd_vma address = bfd_get_32 (abfd, table_data + off);
 
@@ -1017,6 +1007,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
       eh = elf_xtensa_hash_entry (h);
 
@@ -1414,11 +1408,11 @@
   /* First do all the standard stuff.  */
   if (! _bfd_elf_create_dynamic_sections (dynobj, info))
     return FALSE;
-  htab->splt = bfd_get_section_by_name (dynobj, ".plt");
-  htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt");
-  htab->sgot = bfd_get_section_by_name (dynobj, ".got");
-  htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
-  htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+  htab->splt = bfd_get_linker_section (dynobj, ".plt");
+  htab->srelplt = bfd_get_linker_section (dynobj, ".rela.plt");
+  htab->sgot = bfd_get_linker_section (dynobj, ".got");
+  htab->sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
+  htab->srelgot = bfd_get_linker_section (dynobj, ".rela.got");
 
   /* Create any extra PLT sections in case check_relocs has already
      been called on all the non-dynamic input files.  */
@@ -1435,14 +1429,15 @@
     return FALSE;
 
   /* Create ".got.loc" (literal tables for use by dynamic linker).  */
-  htab->sgotloc = bfd_make_section_with_flags (dynobj, ".got.loc", flags);
+  htab->sgotloc = bfd_make_section_anyway_with_flags (dynobj, ".got.loc",
+						      flags);
   if (htab->sgotloc == NULL
       || ! bfd_set_section_alignment (dynobj, htab->sgotloc, 2))
     return FALSE;
 
   /* Create ".xt.lit.plt" (literal table for ".got.plt*").  */
-  htab->spltlittbl = bfd_make_section_with_flags (dynobj, ".xt.lit.plt",
-						  noalloc_flags);
+  htab->spltlittbl = bfd_make_section_anyway_with_flags (dynobj, ".xt.lit.plt",
+							 noalloc_flags);
   if (htab->spltlittbl == NULL
       || ! bfd_set_section_alignment (dynobj, htab->spltlittbl, 2))
     return FALSE;
@@ -1474,14 +1469,14 @@
 
       sname = (char *) bfd_malloc (10);
       sprintf (sname, ".plt.%u", chunk);
-      s = bfd_make_section_with_flags (dynobj, sname, flags | SEC_CODE);
+      s = bfd_make_section_anyway_with_flags (dynobj, sname, flags | SEC_CODE);
       if (s == NULL
 	  || ! bfd_set_section_alignment (dynobj, s, 2))
 	return FALSE;
 
       sname = (char *) bfd_malloc (14);
       sprintf (sname, ".got.plt.%u", chunk);
-      s = bfd_make_section_with_flags (dynobj, sname, flags);
+      s = bfd_make_section_anyway_with_flags (dynobj, sname, flags);
       if (s == NULL
 	  || ! bfd_set_section_alignment (dynobj, s, 2))
 	return FALSE;
@@ -1636,7 +1631,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  if (s == NULL)
 	    abort ();
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
@@ -1712,7 +1707,7 @@
 	    continue;
 	  for (s = abfd->sections; s != NULL; s = s->next)
 	    {
-	      if (! elf_discarded_section (s)
+	      if (! discarded_section (s)
 		  && xtensa_is_littable_section (s)
 		  && s != spltlittbl)
 		sgotloc->size += s->size;
@@ -1968,7 +1963,7 @@
 	  if (is_windowed_call_opcode (opcode))
 	    {
 	      if ((self_address >> CALL_SEGMENT_BITS)
-		  != (relocation >> CALL_SEGMENT_BITS)) 
+		  != (relocation >> CALL_SEGMENT_BITS))
 		{
 		  *error_message = "windowed longcall crosses 1GB boundary; "
 		    "return may fail";
@@ -2141,7 +2136,7 @@
       && is_windowed_call_opcode (opcode))
     {
       if ((self_address >> CALL_SEGMENT_BITS)
-	  != (relocation >> CALL_SEGMENT_BITS)) 
+	  != (relocation >> CALL_SEGMENT_BITS))
 	{
 	  *error_message =
 	    "windowed call crosses 1GB boundary; return may fail";
@@ -2169,8 +2164,8 @@
 
   VA_OPEN (ap, arglen);
   VA_FIXEDARG (ap, const char *, origmsg);
-  
-  is_append = (origmsg == message);  
+
+  is_append = (origmsg == message);
 
   orig_len = strlen (origmsg);
   len = orig_len + strlen (fmt) + arglen + 20;
@@ -2656,9 +2651,9 @@
 	  sym_type = h->type;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	{
@@ -3058,7 +3053,9 @@
 	 not process them.  */
       if (unresolved_reloc
 	  && !((input_section->flags & SEC_DEBUGGING) != 0
-	       && h->def_dynamic))
+	       && h->def_dynamic)
+	  && _bfd_elf_section_offset (output_bfd, info, input_section,
+				      rel->r_offset) != (bfd_vma) -1)
 	{
 	  (*_bfd_error_handler)
 	    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
@@ -3132,7 +3129,7 @@
     }
 
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+  if (h == elf_hash_table (info)->hdynamic
       || h == elf_hash_table (info)->hgot)
     sym->st_shndx = SHN_ABS;
 
@@ -3273,7 +3270,7 @@
     return FALSE;
 
   dynobj = elf_hash_table (info)->dynobj;
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
   BFD_ASSERT (sdyn != NULL);
 
   /* Set the first entry in the global offset table to the address of
@@ -3499,10 +3496,10 @@
       return TRUE;
     }
 
-  if ((out_flag & EF_XTENSA_XT_INSN) != (in_flag & EF_XTENSA_XT_INSN)) 
+  if ((out_flag & EF_XTENSA_XT_INSN) != (in_flag & EF_XTENSA_XT_INSN))
     elf_elfheader (obfd)->e_flags &= (~ EF_XTENSA_XT_INSN);
 
-  if ((out_flag & EF_XTENSA_XT_LIT) != (in_flag & EF_XTENSA_XT_LIT)) 
+  if ((out_flag & EF_XTENSA_XT_LIT) != (in_flag & EF_XTENSA_XT_LIT))
     elf_elfheader (obfd)->e_flags &= (~ EF_XTENSA_XT_LIT);
 
   return TRUE;
@@ -3592,7 +3589,9 @@
 
 
 static enum elf_reloc_type_class
-elf_xtensa_reloc_type_class (const Elf_Internal_Rela *rela)
+elf_xtensa_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			     const asection *rel_sec ATTRIBUTE_UNUSED,
+			     const Elf_Internal_Rela *rela)
 {
   switch ((int) ELF32_R_TYPE (rela->r_info))
     {
@@ -3789,10 +3788,10 @@
      based on the size.  Just assume this is GNU/Linux.  */
 
   /* pr_cursig */
-  elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+  elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
 
   /* pr_pid */
-  elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
+  elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
 
   /* pr_reg */
   offset = 72;
@@ -3813,9 +3812,9 @@
 	return FALSE;
 
       case 128:		/* GNU/Linux elf_prpsinfo */
-	elf_tdata (abfd)->core_program
+	elf_tdata (abfd)->core->program
 	 = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
-	elf_tdata (abfd)->core_command
+	elf_tdata (abfd)->core->command
 	 = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
     }
 
@@ -3824,7 +3823,7 @@
      implementations, so strip it off if it exists.  */
 
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
@@ -4093,7 +4092,7 @@
     return 0;
 
   size += insnlen;
-  
+
   insnlen = insn_decode_len (contents, content_len, offset + size);
   if (insnlen == 0)
     return 0;
@@ -4132,7 +4131,7 @@
   return FALSE;
 }
 
-      
+
 #define MIN_INSN_LENGTH 2
 
 /* Return 0 if it fails to decode.  */
@@ -4233,7 +4232,7 @@
       BFD_ASSERT (FALSE);
       return FALSE;
     }
-  
+
   loop_len = insn_decode_len (contents, content_length, offset);
   insn_len = insn_decode_len (contents, content_length, offset + loop_len);
   if (loop_len == 0 || insn_len == 0)
@@ -4625,7 +4624,7 @@
   return 0;
 }
 
-		       
+
 /* Attempt to widen an instruction.  If the widening is valid, perform
    the action in-place directly into the contents and return TRUE.  Otherwise,
    the return value is FALSE and the contents are not modified.  */
@@ -4720,12 +4719,12 @@
       *error_message = _("Attempt to convert L32R/CALLX to CALL failed");
       return bfd_reloc_other;
     }
-  
+
   /* Assemble a NOP ("or a1, a1, a1") into the 0 byte offset.  */
   core_format = xtensa_format_lookup (isa, "x24");
   opcode = xtensa_opcode_lookup (isa, "or");
   xtensa_opcode_encode (isa, core_format, 0, slotbuf, opcode);
-  for (opn = 0; opn < 3; opn++) 
+  for (opn = 0; opn < 3; opn++)
     {
       uint32 regno = 1;
       xtensa_operand_encode (isa, opcode, opn, &regno);
@@ -4793,7 +4792,7 @@
 #define CONST16_TARGET_REG_OPERAND 0
 #define CALLN_SOURCE_OPERAND 0
 
-static xtensa_opcode 
+static xtensa_opcode
 get_expanded_call_opcode (bfd_byte *buf, int bufsize, bfd_boolean *p_uses_l32r)
 {
   static xtensa_insnbuf insnbuf = NULL;
@@ -4869,7 +4868,7 @@
       || xtensa_format_get_slot (isa, fmt, 0, insnbuf, slotbuf))
     return XTENSA_UNDEFINED;
   opcode = xtensa_opcode_decode (isa, fmt, 0, slotbuf);
-  if (opcode == XTENSA_UNDEFINED 
+  if (opcode == XTENSA_UNDEFINED
       || !is_indirect_call_opcode (opcode))
     return XTENSA_UNDEFINED;
 
@@ -4900,7 +4899,7 @@
    For efficiency, an r_reloc also contains a "target_offset" field to
    cache the target-section-relative offset value that is represented by
    the relocation.
-   
+
    The r_reloc also contains a virtual offset that allows multiple
    inserted literals to be placed at the same "address" with
    different offsets.  */
@@ -5027,7 +5026,7 @@
       fprintf (fp, " + ");
       fprintf_vma (fp, r_rel->virtual_offset);
     }
-    
+
   fprintf (fp, ")");
 }
 
@@ -5147,7 +5146,7 @@
 
 struct literal_value_struct
 {
-  r_reloc r_rel; 
+  r_reloc r_rel;
   unsigned long value;
   bfd_boolean is_abs_literal;
 };
@@ -5188,7 +5187,7 @@
 {
   struct elf_link_hash_entry *h1, *h2;
 
-  if (r_reloc_is_const (&src1->r_rel) != r_reloc_is_const (&src2->r_rel)) 
+  if (r_reloc_is_const (&src1->r_rel) != r_reloc_is_const (&src2->r_rel))
     return FALSE;
 
   if (r_reloc_is_const (&src1->r_rel))
@@ -5200,13 +5199,13 @@
 
   if (src1->r_rel.target_offset != src2->r_rel.target_offset)
     return FALSE;
-   
+
   if (src1->r_rel.virtual_offset != src2->r_rel.virtual_offset)
     return FALSE;
 
   if (src1->value != src2->value)
     return FALSE;
-  
+
   /* Now check for the same section (if defined) or the same elf_hash
      (if undefined or weak).  */
   h1 = r_reloc_get_hash_entry (&src1->r_rel);
@@ -5248,7 +5247,7 @@
   values->count = 0;
   values->buckets = (value_map **)
     bfd_zmalloc (sizeof (value_map *) * values->bucket_count);
-  if (values->buckets == NULL) 
+  if (values->buckets == NULL)
     {
       free (values);
       return NULL;
@@ -5287,7 +5286,7 @@
       hash_val += hash_bfd_vma (src->is_abs_literal * 1000);
       hash_val += hash_bfd_vma (src->r_rel.target_offset);
       hash_val += hash_bfd_vma (src->r_rel.virtual_offset);
-  
+
       /* Now check for the same section and the same elf_hash.  */
       if (r_reloc_is_defined (&src->r_rel))
 	sec_or_hash = r_reloc_get_section (&src->r_rel);
@@ -5353,7 +5352,7 @@
   *bucket_p = val_e;
   map->count++;
   /* FIXME: Consider resizing the hash table if we get too many entries.  */
-  
+
   return val_e;
 }
 
@@ -5493,7 +5492,7 @@
    "unreachable_space" bytes can be freely contracted.  Note that a
    negative removed value is a fill.  */
 
-static void 
+static void
 text_action_add (text_action_list *l,
 		 text_action_t action,
 		 asection *sec,
@@ -5514,8 +5513,8 @@
   for (m_p = &l->head; *m_p && (*m_p)->offset <= offset; m_p = &(*m_p)->next)
     {
       text_action *t = *m_p;
-      
-      if (action == ta_fill) 
+
+      if (action == ta_fill)
 	{
 	  /* When the action is another fill at the same address,
 	     just increase the size.  */
@@ -5612,7 +5611,7 @@
 }
 
 
-static bfd_vma 
+static bfd_vma
 offset_with_removed_text (text_action_list *action_list, bfd_vma offset)
 {
   text_action *r = action_list->head;
@@ -5750,9 +5749,9 @@
   else
     new_r->to.abfd = NULL;
   new_r->next = NULL;
-  
+
   r = removed_list->head;
-  if (r == NULL) 
+  if (r == NULL)
     {
       removed_list->head = new_r;
       removed_list->tail = new_r;
@@ -5765,7 +5764,7 @@
     }
   else
     {
-      while (r->from.target_offset < from->target_offset && r->next) 
+      while (r->from.target_offset < from->target_offset && r->next)
 	{
 	  r = r->next;
 	}
@@ -5843,7 +5842,7 @@
      reallocated, the newly allocated relocations will be referenced
      here along with the actual size allocated.  The relocation
      count will always be found in the section structure.  */
-  Elf_Internal_Rela *allocated_relocs; 
+  Elf_Internal_Rela *allocated_relocs;
   unsigned relocs_count;
   unsigned allocated_relocs_count;
 };
@@ -5909,7 +5908,7 @@
   relax_info->fix_array = NULL;
   relax_info->fix_array_count = 0;
 
-  relax_info->allocated_relocs = NULL; 
+  relax_info->allocated_relocs = NULL;
   relax_info->relocs_count = 0;
   relax_info->allocated_relocs_count = 0;
 }
@@ -5929,11 +5928,11 @@
   asection *src_sec;
   bfd_vma src_offset;
   unsigned src_type;			/* Relocation type.  */
-  
+
   asection *target_sec;
   bfd_vma target_offset;
   bfd_boolean translated;
-  
+
   reloc_bfd_fix *next;
 };
 
@@ -6064,7 +6063,7 @@
 
 
 static void
-clear_section_cache (section_cache_t *sec_cache)
+free_section_cache (section_cache_t *sec_cache)
 {
   if (sec_cache->sec)
     {
@@ -6072,7 +6071,6 @@
       release_internal_relocs (sec_cache->sec, sec_cache->relocs);
       if (sec_cache->ptbl)
 	free (sec_cache->ptbl);
-      memset (sec_cache, 0, sizeof (sec_cache));
     }
 }
 
@@ -6113,8 +6111,8 @@
     goto err;
 
   /* Fill in the new section cache.  */
-  clear_section_cache (sec_cache);
-  memset (sec_cache, 0, sizeof (sec_cache));
+  free_section_cache (sec_cache);
+  init_section_cache (sec_cache);
 
   sec_cache->sec = sec;
   sec_cache->contents = contents;
@@ -6545,7 +6543,7 @@
 
   sec_size = bfd_get_section_limit (abfd, sec);
   contents = elf_section_data (sec)->this_hdr.contents;
-  
+
   if (contents == NULL && sec_size != 0)
     {
       if (!bfd_malloc_and_get_section (abfd, sec, &contents))
@@ -6554,7 +6552,7 @@
 	    free (contents);
 	  return NULL;
 	}
-      if (keep_memory) 
+      if (keep_memory)
 	elf_section_data (sec)->this_hdr.contents = contents;
     }
   return contents;
@@ -6629,12 +6627,12 @@
   (bfd *, asection *, struct bfd_link_info *, value_map_hash_table *);
 static Elf_Internal_Rela *get_irel_at_offset
   (asection *, Elf_Internal_Rela *, bfd_vma);
-static bfd_boolean is_removable_literal 
+static bfd_boolean is_removable_literal
   (const source_reloc *, int, const source_reloc *, int, asection *,
    property_table_entry *, int);
 static bfd_boolean remove_dead_literal
   (bfd *, asection *, struct bfd_link_info *, Elf_Internal_Rela *,
-   Elf_Internal_Rela *, source_reloc *, property_table_entry *, int); 
+   Elf_Internal_Rela *, source_reloc *, property_table_entry *, int);
 static bfd_boolean identify_literal_placement
   (bfd *, asection *, bfd_byte *, struct bfd_link_info *,
    value_map_hash_table *, bfd_boolean *, Elf_Internal_Rela *, int,
@@ -6664,7 +6662,7 @@
 static bfd_boolean relax_section_symbols (bfd *, asection *);
 
 
-static bfd_boolean 
+static bfd_boolean
 elf_xtensa_relax_section (bfd *abfd,
 			  asection *sec,
 			  struct bfd_link_info *link_info,
@@ -6827,7 +6825,7 @@
 
   internal_relocs = retrieve_internal_relocs (abfd, sec,
 					      link_info->keep_memory);
-  if (internal_relocs == NULL) 
+  if (internal_relocs == NULL)
     return ok;
 
   contents = retrieve_contents (abfd, sec, link_info->keep_memory);
@@ -6838,7 +6836,7 @@
     }
 
   source_relax_info = get_xtensa_relax_info (sec);
-  for (i = 0; i < sec->reloc_count; i++) 
+  for (i = 0; i < sec->reloc_count; i++)
     {
       Elf_Internal_Rela *irel = &internal_relocs[i];
       r_reloc r_rel;
@@ -6918,9 +6916,9 @@
   unsigned i;
   bfd_size_type sec_size;
 
-  internal_relocs = retrieve_internal_relocs (abfd, sec, 
+  internal_relocs = retrieve_internal_relocs (abfd, sec,
 					      link_info->keep_memory);
-  if (internal_relocs == NULL) 
+  if (internal_relocs == NULL)
     return ok;
 
   sec_size = bfd_get_section_limit (abfd, sec);
@@ -6932,7 +6930,7 @@
     }
 
   /* Record relocations against relaxable literal sections.  */
-  for (i = 0; i < sec->reloc_count; i++) 
+  for (i = 0; i < sec->reloc_count; i++)
     {
       Elf_Internal_Rela *irel = &internal_relocs[i];
       r_reloc r_rel;
@@ -6990,7 +6988,7 @@
      relocations associated with ASM_EXPANDs because they were just
      added in the preceding loop over the relocations.  */
 
-  for (i = 0; i < sec->reloc_count; i++) 
+  for (i = 0; i < sec->reloc_count; i++)
     {
       Elf_Internal_Rela *irel = &internal_relocs[i];
       bfd_boolean is_reachable;
@@ -7029,7 +7027,7 @@
 		 the l32r_irel.  Note: The src_relocs array is not yet
 		 sorted, but it wouldn't matter anyway because we're
 		 searching by source offset instead of target offset.  */
-	      s_reloc = find_source_reloc (target_relax_info->src_relocs, 
+	      s_reloc = find_source_reloc (target_relax_info->src_relocs,
 					   target_relax_info->src_next,
 					   sec, l32r_irel);
 	      BFD_ASSERT (s_reloc);
@@ -7088,7 +7086,7 @@
   if (contents == NULL)
     return FALSE;
 
-  if (ELF32_R_TYPE (irel->r_info) != R_XTENSA_ASM_EXPAND) 
+  if (ELF32_R_TYPE (irel->r_info) != R_XTENSA_ASM_EXPAND)
     return FALSE;
 
   sec_size = bfd_get_section_limit (abfd, sec);
@@ -7097,7 +7095,7 @@
   /* Optimization of longcalls that use CONST16 is not yet implemented.  */
   if (!uses_l32r)
     return FALSE;
-  
+
   direct_call_opcode = swap_callx_for_call_opcode (opcode);
   if (direct_call_opcode == XTENSA_UNDEFINED)
     return FALSE;
@@ -7116,7 +7114,7 @@
      shouldn't crash regardless.  */
   if (!target_sec->output_section)
     return FALSE;
-      
+
   /* For relocatable sections, we can only simplify when the output
      section of the target is the same as the output section of the
      source.  */
@@ -7129,7 +7127,7 @@
 		  + sec->output_offset + irel->r_offset + 3);
   dest_address = (target_sec->output_section->vma
 		  + target_sec->output_offset + target_offset);
-      
+
   *is_reachable_p = pcrel_reloc_fits (direct_call_opcode, 0,
 				      self_address, dest_address);
 
@@ -7150,7 +7148,7 @@
 {
   unsigned i;
 
-  for (i = 0; i < sec->reloc_count; i++) 
+  for (i = 0; i < sec->reloc_count; i++)
     {
       Elf_Internal_Rela *irel = &internal_relocs[i];
 
@@ -7367,7 +7365,7 @@
     return FALSE;
   prev_opcode = insn_decode_opcode (contents, content_length, offset-3, 0);
   return (xtensa_opcode_is_loop (xtensa_default_isa, prev_opcode) == 1);
-} 
+}
 
 
 /* Find all of the possible actions for an extended basic block.  */
@@ -7417,7 +7415,7 @@
 
 	  insn_len = insn_decode_len (ebb->contents, ebb->content_length,
 				      offset);
-	  if (insn_len == 0) 
+	  if (insn_len == 0)
 	    goto decode_error;
 
 	  if (check_branch_target_aligned_address (offset, insn_len))
@@ -7446,7 +7444,7 @@
 	    {
 	      bfd_size_type simplify_size;
 
-	      simplify_size = get_asm_simplify_size (ebb->contents, 
+	      simplify_size = get_asm_simplify_size (ebb->contents,
 						     ebb->content_length,
 						     irel->r_offset);
 	      if (simplify_size == 0)
@@ -7454,7 +7452,7 @@
 
 	      ebb_propose_action (ebb_table, EBB_NO_ALIGN, 0,
 				  ta_convert_longcall, offset, 0, TRUE);
-	      
+
 	      offset += simplify_size;
 	      continue;
 	    }
@@ -7801,7 +7799,7 @@
 };
 
 
-static int 
+static int
 xlate_compare (const void *a_v, const void *b_v)
 {
   const xlate_map_entry_t *a = (const xlate_map_entry_t *) a_v;
@@ -7831,7 +7829,7 @@
   r = bsearch (&offset, map->entry, map->entry_count,
 	       sizeof (xlate_map_entry_t), &xlate_compare);
   e = (xlate_map_entry_t *) r;
-  
+
   BFD_ASSERT (e != NULL);
   if (e == NULL)
     return offset;
@@ -7856,7 +7854,7 @@
     return NULL;
 
   num_actions = action_list_count (action_list);
-  map->entry = (xlate_map_entry_t *) 
+  map->entry = (xlate_map_entry_t *)
     bfd_malloc (sizeof (xlate_map_entry_t) * (num_actions + 1));
   if (map->entry == NULL)
     {
@@ -7864,7 +7862,7 @@
       return NULL;
     }
   map->entry_count = 0;
-  
+
   removed = 0;
   current_entry = &map->entry[0];
 
@@ -7919,7 +7917,7 @@
 
 /* Free an offset translation map.  */
 
-static void 
+static void
 free_xlate_map (xlate_map_t *map)
 {
   if (map && map->entry)
@@ -8151,7 +8149,7 @@
    add an entry to the per-section list of removed literals.  The
    actual changes are deferred until the next pass.  */
 
-static bfd_boolean 
+static bfd_boolean
 compute_removed_literals (bfd *abfd,
 			  asection *sec,
 			  struct bfd_link_info *link_info,
@@ -8178,7 +8176,7 @@
   if (!relax_info->is_relaxable_literal_section)
     return ok;
 
-  internal_relocs = retrieve_internal_relocs (abfd, sec, 
+  internal_relocs = retrieve_internal_relocs (abfd, sec,
 					      link_info->keep_memory);
 
   sec_size = bfd_get_section_limit (abfd, sec);
@@ -8230,14 +8228,14 @@
 	continue;
       prev_i = i;
 
-      if (last_loc_is_prev && 
+      if (last_loc_is_prev &&
 	  last_target_offset + 4 != rel->r_rel.target_offset)
 	last_loc_is_prev = FALSE;
 
       /* Check if the relocation was from an L32R that is being removed
 	 because a CALLX was converted to a direct CALL, and check if
 	 there are no other relocations to the literal.  */
-      if (is_removable_literal (rel, i, src_relocs, relax_info->src_count, 
+      if (is_removable_literal (rel, i, src_relocs, relax_info->src_count,
 				sec, prop_table, ptblsize))
 	{
 	  if (!remove_dead_literal (abfd, sec, link_info, internal_relocs,
@@ -8251,8 +8249,8 @@
 	}
 
       if (!identify_literal_placement (abfd, sec, contents, link_info,
-				       values, 
-				       &last_loc_is_prev, irel, 
+				       values,
+				       &last_loc_is_prev, irel,
 				       relax_info->src_count - i, rel,
 				       prop_table, ptblsize,
 				       &target_sec_cache, rel->is_abs_literal))
@@ -8269,8 +8267,9 @@
 #endif /* DEBUG */
 
 error_return:
-  if (prop_table) free (prop_table);
-  clear_section_cache (&target_sec_cache);
+  if (prop_table)
+    free (prop_table);
+  free_section_cache (&target_sec_cache);
 
   release_contents (sec, contents);
   release_internal_relocs (sec, internal_relocs);
@@ -8288,7 +8287,7 @@
   unsigned r_type;
   Elf_Internal_Rela key;
 
-  if (!internal_relocs) 
+  if (!internal_relocs)
     return NULL;
 
   key.r_offset = offset;
@@ -8332,8 +8331,8 @@
 
   if (!rel->is_null)
     return FALSE;
-  
-  entry = elf_xtensa_find_property_entry (prop_table, ptblsize, 
+
+  entry = elf_xtensa_find_property_entry (prop_table, ptblsize,
 					  sec->vma + rel->r_rel.target_offset);
   if (entry && (entry->flags & XTENSA_PROP_NO_TRANSFORM))
     return FALSE;
@@ -8354,7 +8353,7 @@
 }
 
 
-bfd_boolean 
+bfd_boolean
 remove_dead_literal (bfd *abfd,
 		     asection *sec,
 		     struct bfd_link_info *link_info,
@@ -8381,7 +8380,7 @@
 		   ta_remove_literal, sec, rel->r_rel.target_offset, 4);
 
   /* If the section is 4-byte aligned, do not add fill.  */
-  if (sec->alignment_power > 2) 
+  if (sec->alignment_power > 2)
     {
       int fill_extra_space;
       bfd_vma entry_sec_offset;
@@ -8425,7 +8424,7 @@
 }
 
 
-bfd_boolean 
+bfd_boolean
 identify_literal_placement (bfd *abfd,
 			    asection *sec,
 			    bfd_byte *contents,
@@ -8495,7 +8494,7 @@
   /* For relocatable links, do not try to move literals.  To do it
      correctly might increase the number of relocations in an input
      section making the default relocatable linking fail.  */
-  if (!link_info->relocatable && !literal_placed 
+  if (!link_info->relocatable && !literal_placed
       && values->has_last_loc && !(*last_loc_is_prev_p))
     {
       asection *target_sec = r_reloc_get_section (&values->last_loc);
@@ -8508,7 +8507,7 @@
 	  /* There is a last loc that was in the same output section.  */
 	  if (relocations_reach (rel, remaining_src_rels, &try_loc)
 	      && move_shared_literal (sec, link_info, rel,
-				      prop_table, ptblsize, 
+				      prop_table, ptblsize,
 				      &try_loc, &val, target_sec_cache))
 	    {
 	      values->last_loc.virtual_offset += 4;
@@ -8608,7 +8607,7 @@
 /* Move a literal to another literal location because it is
    the same as the other literal value.  */
 
-static bfd_boolean 
+static bfd_boolean
 coalesce_shared_literal (asection *sec,
 			 source_reloc *rel,
 			 property_table_entry *prop_table,
@@ -8637,7 +8636,7 @@
 		   ta_remove_literal, sec, rel->r_rel.target_offset, 4);
 
   /* If the section is 4-byte aligned, do not add fill.  */
-  if (sec->alignment_power > 2) 
+  if (sec->alignment_power > 2)
     {
       int fill_extra_space;
       bfd_vma entry_sec_offset;
@@ -8673,7 +8672,7 @@
    total amount of space used because of alignments so we need to do
    this carefully.  Also, it may make a branch go out of range.  */
 
-static bfd_boolean 
+static bfd_boolean
 move_shared_literal (asection *sec,
 		     struct bfd_link_info *link_info,
 		     source_reloc *rel,
@@ -8716,7 +8715,7 @@
     return FALSE;
 
   target_entry = elf_xtensa_find_property_entry
-    (target_sec_cache->ptbl, target_sec_cache->pte_count, 
+    (target_sec_cache->ptbl, target_sec_cache->pte_count,
      target_sec->vma + target_loc->target_offset);
 
   if (!target_entry)
@@ -8727,7 +8726,7 @@
 
   init_ebb_constraint (&ebb_table);
   ebb = &ebb_table.ebb;
-  init_ebb (ebb, target_sec_cache->sec, target_sec_cache->contents, 
+  init_ebb (ebb, target_sec_cache->sec, target_sec_cache->contents,
 	    target_sec_cache->content_length,
 	    target_sec_cache->ptbl, target_sec_cache->pte_count,
 	    target_sec_cache->relocs, target_sec_cache->reloc_count);
@@ -8739,24 +8738,24 @@
 		      -4 - (1 << target_sec->alignment_power), TRUE);
 
   /* Check all of the PC-relative relocations to make sure they still fit.  */
-  relocs_fit = check_section_ebb_pcrels_fit (target_sec->owner, target_sec, 
+  relocs_fit = check_section_ebb_pcrels_fit (target_sec->owner, target_sec,
 					     target_sec_cache->contents,
 					     target_sec_cache->relocs,
 					     &ebb_table, NULL);
 
-  if (!relocs_fit) 
+  if (!relocs_fit)
     return FALSE;
 
   text_action_add_literal (&target_relax_info->action_list,
 			   ta_add_literal, target_loc, lit_value, -4);
 
-  if (target_sec->alignment_power > 2 && target_entry != src_entry) 
+  if (target_sec->alignment_power > 2 && target_entry != src_entry)
     {
       /* May need to add or remove some fill to maintain alignment.  */
       int fill_extra_space;
       bfd_vma entry_sec_offset;
 
-      entry_sec_offset = 
+      entry_sec_offset =
 	target_entry->address - target_sec->vma + target_entry->size;
 
       /* If the literal range is at the end of the section,
@@ -8789,7 +8788,7 @@
 		   ta_remove_literal, sec, rel->r_rel.target_offset, 4);
 
   /* If the section is 4-byte aligned, do not add fill.  */
-  if (sec->alignment_power > 2 && target_entry != src_entry) 
+  if (sec->alignment_power > 2 && target_entry != src_entry)
     {
       int fill_extra_space;
       bfd_vma entry_sec_offset;
@@ -8853,7 +8852,7 @@
       return relax_property_section (abfd, sec, link_info);
     }
 
-  internal_relocs = retrieve_internal_relocs (abfd, sec, 
+  internal_relocs = retrieve_internal_relocs (abfd, sec,
 					      link_info->keep_memory);
   if (!internal_relocs && !relax_info->action_list.head)
     return TRUE;
@@ -8960,9 +8959,9 @@
 	     that here and adjust things accordingly.  */
 	  if (! elf_xtensa_ignore_discarded_relocs (sec)
 	      && elf_xtensa_action_discarded (sec) == PRETEND
-	      && sec->sec_info_type != ELF_INFO_TYPE_STABS
+	      && sec->sec_info_type != SEC_INFO_TYPE_STABS
 	      && target_sec != NULL
-	      && elf_discarded_section (target_sec))
+	      && discarded_section (target_sec))
 	    {
 	      /* It would be natural to call _bfd_elf_check_kept_section
 		 here, but it's not exported from elflink.c.  It's also a
@@ -9183,7 +9182,7 @@
 		      dup_dot += copy_size;
 		    }
 		  virtual_action = TRUE;
-		} 
+		}
 	      else
 		BFD_ASSERT (action->virtual_offset <= orig_dot_vo);
 	    }
@@ -9254,7 +9253,7 @@
 				 relax_info, &internal_relocs, &action->value))
 		goto error_return;
 
-	      if (virtual_action) 
+	      if (virtual_action)
 		orig_dot_vo += copy_size;
 
 	      orig_dot += orig_insn_size;
@@ -9319,7 +9318,7 @@
 }
 
 
-static bfd_boolean 
+static bfd_boolean
 translate_section_fixes (asection *sec)
 {
   xtensa_relax_info *relax_info;
@@ -9340,7 +9339,7 @@
 /* Translate a fix given the mapping in the relax info for the target
    section.  If it has already been translated, no work is required.  */
 
-static bfd_boolean 
+static bfd_boolean
 translate_reloc_bfd_fix (reloc_bfd_fix *fix)
 {
   reloc_bfd_fix new_fix;
@@ -9386,7 +9385,7 @@
 				      target_offset);
     }
 
-  if (removed) 
+  if (removed)
     {
       asection *new_sec;
 
@@ -9396,11 +9395,11 @@
 
       /* This was moved to some other address (possibly another section).  */
       new_sec = r_reloc_get_section (&removed->to);
-      if (new_sec != sec) 
+      if (new_sec != sec)
 	{
 	  sec = new_sec;
 	  relax_info = get_xtensa_relax_info (sec);
-	  if (!relax_info || 
+	  if (!relax_info ||
 	      (!relax_info->is_relaxable_literal_section
 	       && !relax_info->is_relaxable_asm_section))
 	    {
@@ -9689,7 +9688,7 @@
 	  BFD_ASSERT (relax_info->allocated_relocs == NULL
 		      || sec->reloc_count == relax_info->relocs_count);
 
-	  if (relax_info->allocated_relocs_count == 0) 
+	  if (relax_info->allocated_relocs_count == 0)
 	    new_relocs_count = (sec->reloc_count + 2) * 2;
 	  else
 	    new_relocs_count = (relax_info->allocated_relocs_count + 2) * 2;
@@ -9709,7 +9708,7 @@
 	  if (insert_at != sec->reloc_count)
 	    memcpy (new_relocs + insert_at + 1,
 		    (*internal_relocs_p) + insert_at,
-		    (sec->reloc_count - insert_at) 
+		    (sec->reloc_count - insert_at)
 		    * sizeof (Elf_Internal_Rela));
 
 	  if (*internal_relocs_p != relax_info->allocated_relocs)
@@ -9768,7 +9767,7 @@
   bfd_size_type entry_size;
 
   sec_size = bfd_get_section_limit (abfd, sec);
-  internal_relocs = retrieve_internal_relocs (abfd, sec, 
+  internal_relocs = retrieve_internal_relocs (abfd, sec,
 					      link_info->keep_memory);
   contents = retrieve_contents (abfd, sec, link_info->keep_memory);
   if (contents == NULL && sec_size != 0)
@@ -9993,7 +9992,7 @@
 	  actual_offset = offset - removed_bytes;
 	  size = bfd_get_32 (abfd, &contents[actual_offset + 4]);
 
-	  if (is_full_prop_section) 
+	  if (is_full_prop_section)
 	    flags = bfd_get_32 (abfd, &contents[actual_offset + 8]);
 	  else
 	    flags = predef_flags;
@@ -10021,7 +10020,7 @@
 		  bfd_vma new_address =
 		    (offset_rel->r_addend
 		     + bfd_get_32 (abfd, &contents[actual_offset]));
-		  if (is_full_prop_section) 
+		  if (is_full_prop_section)
 		    old_flags = bfd_get_32
 		      (abfd, &contents[last_irel->r_offset + 8]);
 		  else
@@ -10273,7 +10272,7 @@
 
   dynobj = elf_hash_table (info)->dynobj;
   sprintf (plt_name, ".plt.%u", chunk);
-  return bfd_get_section_by_name (dynobj, plt_name);
+  return bfd_get_linker_section (dynobj, plt_name);
 }
 
 
@@ -10294,7 +10293,7 @@
 
   dynobj = elf_hash_table (info)->dynobj;
   sprintf (got_name, ".got.plt.%u", chunk);
-  return bfd_get_section_by_name (dynobj, got_name);
+  return bfd_get_linker_section (dynobj, got_name);
 }
 
 
@@ -10437,7 +10436,7 @@
 }
 
 
-static bfd_boolean 
+static bfd_boolean
 xtensa_is_property_section (asection *sec)
 {
   if (xtensa_is_insntable_section (sec)
@@ -10449,7 +10448,7 @@
 }
 
 
-static bfd_boolean 
+static bfd_boolean
 xtensa_is_insntable_section (asection *sec)
 {
   if (CONST_STRNEQ (sec->name, XTENSA_INSN_SEC_NAME)
@@ -10460,7 +10459,7 @@
 }
 
 
-static bfd_boolean 
+static bfd_boolean
 xtensa_is_littable_section (asection *sec)
 {
   if (CONST_STRNEQ (sec->name, XTENSA_LIT_SEC_NAME)
@@ -10471,7 +10470,7 @@
 }
 
 
-static bfd_boolean 
+static bfd_boolean
 xtensa_is_proptable_section (asection *sec)
 {
   if (CONST_STRNEQ (sec->name, XTENSA_PROP_SEC_NAME)
@@ -10524,7 +10523,7 @@
 {
   const char *gname = inf;
   const char *group_name = elf_group_name (sec);
-  
+
   return (group_name == gname
 	  || (group_name != NULL
 	      && gname != NULL
@@ -10556,9 +10555,9 @@
     {
       char *linkonce_kind = 0;
 
-      if (strcmp (base_name, XTENSA_INSN_SEC_NAME) == 0) 
+      if (strcmp (base_name, XTENSA_INSN_SEC_NAME) == 0)
 	linkonce_kind = "x.";
-      else if (strcmp (base_name, XTENSA_LIT_SEC_NAME) == 0) 
+      else if (strcmp (base_name, XTENSA_LIT_SEC_NAME) == 0)
 	linkonce_kind = "p.";
       else if (strcmp (base_name, XTENSA_PROP_SEC_NAME) == 0)
 	linkonce_kind = "prop.";
@@ -10673,7 +10672,7 @@
 
       /* Find the corresponding ".got.plt*" section.  */
       if (sec->name[4] == '\0')
-	sgotplt = bfd_get_section_by_name (sec->owner, ".got.plt");
+	sgotplt = bfd_get_linker_section (sec->owner, ".got.plt");
       else
 	{
 	  char got_name[14];
@@ -10683,7 +10682,7 @@
 	  chunk = strtol (&sec->name[5], NULL, 10);
 
 	  sprintf (got_name, ".got.plt.%u", chunk);
-	  sgotplt = bfd_get_section_by_name (sec->owner, got_name);
+	  sgotplt = bfd_get_linker_section (sec->owner, got_name);
 	}
       BFD_ASSERT (sgotplt);
 
@@ -10698,7 +10697,7 @@
   if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
     return ok;
 
-  internal_relocs = retrieve_internal_relocs (abfd, sec, 
+  internal_relocs = retrieve_internal_relocs (abfd, sec,
 					      link_info->keep_memory);
   if (internal_relocs == NULL
       || sec->reloc_count == 0)
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index f5a34c2..289164f 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -1,6 +1,7 @@
 /* Alpha specific support for 64-bit ELF
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2006, 2007, 2008, 2009, 2010, 2011  Free Software Foundation, Inc.
+   2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
+   Free Software Foundation, Inc.
    Contributed by Richard Henderson <[email protected]>.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -210,7 +211,7 @@
 #define alpha_elf_link_hash_traverse(table, func, info)			\
   (elf_link_hash_traverse						\
    (&(table)->root,							\
-    (bfd_boolean (*) (struct elf_link_hash_entry *, PTR)) (func),	\
+    (bfd_boolean (*) (struct elf_link_hash_entry *, void *)) (func),	\
     (info)))
 
 /* Get the Alpha ELF linker hash table from a link_info structure.  */
@@ -224,7 +225,7 @@
 #define alpha_elf_sym_hashes(abfd) \
   ((struct alpha_elf_link_hash_entry **)elf_sym_hashes(abfd))
 
-/* Should we do dynamic things to this symbol?  This differs from the 
+/* Should we do dynamic things to this symbol?  This differs from the
    generic version in that we never need to consider function pointer
    equality wrt PLT entries -- we don't create a PLT entry if a symbol's
    address is ever taken.  */
@@ -298,6 +299,15 @@
   return &ret->root.root;
 }
 
+/* Alpha ELF follows MIPS ELF in using a special find_nearest_line
+   routine in order to handle the ECOFF debugging information.  */
+
+struct alpha_elf_find_line
+{
+  struct ecoff_debug_info d;
+  struct ecoff_find_line i;
+};
+
 /* We have some private fields hanging off of the elf_tdata structure.  */
 
 struct alpha_elf_obj_tdata
@@ -327,6 +337,10 @@
   /* For every got, this is the sum of the number of words required
      to hold all of the member object's local got.  */
   int local_got_size;
+
+  /* Used by elf64_alpha_find_nearest_line entry point.  */
+  struct alpha_elf_find_line *find_line_info;
+
 };
 
 #define alpha_elf_tdata(abfd) \
@@ -356,7 +370,7 @@
 static bfd_reloc_status_type
 elf64_alpha_reloc_nil (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc,
 		       asymbol *sym ATTRIBUTE_UNUSED,
-		       PTR data ATTRIBUTE_UNUSED, asection *sec,
+		       void * data ATTRIBUTE_UNUSED, asection *sec,
 		       bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED)
 {
   if (output_bfd)
@@ -369,7 +383,7 @@
 static bfd_reloc_status_type
 elf64_alpha_reloc_bad (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc,
 		       asymbol *sym ATTRIBUTE_UNUSED,
-		       PTR data ATTRIBUTE_UNUSED, asection *sec,
+		       void * data ATTRIBUTE_UNUSED, asection *sec,
 		       bfd *output_bfd, char **error_message ATTRIBUTE_UNUSED)
 {
   if (output_bfd)
@@ -421,7 +435,7 @@
 
 static bfd_reloc_status_type
 elf64_alpha_reloc_gpdisp (bfd *abfd, arelent *reloc_entry,
-			  asymbol *sym ATTRIBUTE_UNUSED, PTR data,
+			  asymbol *sym ATTRIBUTE_UNUSED, void * data,
 			  asection *input_section, bfd *output_bfd,
 			  char **err_msg)
 {
@@ -1376,17 +1390,17 @@
     }
 
   READ (line, cbLineOffset, cbLine, sizeof (unsigned char), unsigned char *);
-  READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size, PTR);
-  READ (external_pdr, cbPdOffset, ipdMax, swap->external_pdr_size, PTR);
-  READ (external_sym, cbSymOffset, isymMax, swap->external_sym_size, PTR);
-  READ (external_opt, cbOptOffset, ioptMax, swap->external_opt_size, PTR);
+  READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size, void *);
+  READ (external_pdr, cbPdOffset, ipdMax, swap->external_pdr_size, void *);
+  READ (external_sym, cbSymOffset, isymMax, swap->external_sym_size, void *);
+  READ (external_opt, cbOptOffset, ioptMax, swap->external_opt_size, void *);
   READ (external_aux, cbAuxOffset, iauxMax, sizeof (union aux_ext),
 	union aux_ext *);
   READ (ss, cbSsOffset, issMax, sizeof (char), char *);
   READ (ssext, cbSsExtOffset, issExtMax, sizeof (char), char *);
-  READ (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size, PTR);
-  READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size, PTR);
-  READ (external_ext, cbExtOffset, iextMax, swap->external_ext_size, PTR);
+  READ (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size, void *);
+  READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size, void *);
+  READ (external_ext, cbExtOffset, iextMax, swap->external_ext_size, void *);
 #undef READ
 
   debug->fdr = NULL;
@@ -1429,17 +1443,6 @@
   return name[0] == '$';
 }
 
-/* Alpha ELF follows MIPS ELF in using a special find_nearest_line
-   routine in order to handle the ECOFF debugging information.  We
-   still call this mips_elf_find_line because of the slot
-   find_line_info in elf_obj_tdata is declared that way.  */
-
-struct mips_elf_find_line
-{
-  struct ecoff_debug_info d;
-  struct ecoff_find_line i;
-};
-
 static bfd_boolean
 elf64_alpha_find_nearest_line (bfd *abfd, asection *section, asymbol **symbols,
 			       bfd_vma offset, const char **filename_ptr,
@@ -1448,7 +1451,8 @@
 {
   asection *msec;
 
-  if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
+  if (_bfd_dwarf2_find_nearest_line (abfd, dwarf_debug_sections,
+                                     section, symbols, offset,
 				     filename_ptr, functionname_ptr,
 				     line_ptr, NULL, 0,
 				     &elf_tdata (abfd)->dwarf2_find_line_info))
@@ -1458,7 +1462,7 @@
   if (msec != NULL)
     {
       flagword origflags;
-      struct mips_elf_find_line *fi;
+      struct alpha_elf_find_line *fi;
       const struct ecoff_debug_swap * const swap =
 	get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
 
@@ -1469,16 +1473,16 @@
       if (elf_section_data (msec)->this_hdr.sh_type != SHT_NOBITS)
 	msec->flags |= SEC_HAS_CONTENTS;
 
-      fi = elf_tdata (abfd)->find_line_info;
+      fi = alpha_elf_tdata (abfd)->find_line_info;
       if (fi == NULL)
 	{
 	  bfd_size_type external_fdr_size;
 	  char *fraw_src;
 	  char *fraw_end;
 	  struct fdr *fdr_ptr;
-	  bfd_size_type amt = sizeof (struct mips_elf_find_line);
+	  bfd_size_type amt = sizeof (struct alpha_elf_find_line);
 
-	  fi = (struct mips_elf_find_line *) bfd_zalloc (abfd, amt);
+	  fi = (struct alpha_elf_find_line *) bfd_zalloc (abfd, amt);
 	  if (fi == NULL)
 	    {
 	      msec->flags = origflags;
@@ -1505,9 +1509,9 @@
 	  fraw_end = (fraw_src
 		      + fi->d.symbolic_header.ifdMax * external_fdr_size);
 	  for (; fraw_src < fraw_end; fraw_src += external_fdr_size, fdr_ptr++)
-	    (*swap->swap_fdr_in) (abfd, (PTR) fraw_src, fdr_ptr);
+	    (*swap->swap_fdr_in) (abfd, fraw_src, fdr_ptr);
 
-	  elf_tdata (abfd)->find_line_info = fi;
+	  alpha_elf_tdata (abfd)->find_line_info = fi;
 
 	  /* Note that we don't bother to ever free this information.
              find_nearest_line is either called all the time, as in
@@ -1547,7 +1551,7 @@
 };
 
 static bfd_boolean
-elf64_alpha_output_extsym (struct alpha_elf_link_hash_entry *h, PTR data)
+elf64_alpha_output_extsym (struct alpha_elf_link_hash_entry *h, void * data)
 {
   struct extsym_info *einfo = (struct extsym_info *) data;
   bfd_boolean strip;
@@ -1808,6 +1812,9 @@
 		 || h->root.root.type == bfd_link_hash_warning)
 	    h = (struct alpha_elf_link_hash_entry *)h->root.root.u.i.link;
 
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.root.non_ir_ref = 1;
 	  h->root.ref_regular = 1;
 	}
 
@@ -2101,7 +2108,7 @@
     {
       h->needs_plt = TRUE;
 
-      s = bfd_get_section_by_name(dynobj, ".plt");
+      s = bfd_get_linker_section (dynobj, ".plt");
       if (!s && !elf64_alpha_create_dynamic_sections (dynobj, info))
 	return FALSE;
 
@@ -2390,7 +2397,7 @@
 
 static bfd_boolean
 elf64_alpha_calc_got_offsets_for_symbol (struct alpha_elf_link_hash_entry *h,
-					 PTR arg ATTRIBUTE_UNUSED)
+					 void * arg ATTRIBUTE_UNUSED)
 {
   struct alpha_elf_got_entry *gotent;
 
@@ -2542,7 +2549,8 @@
 }
 
 static bfd_boolean
-elf64_alpha_size_plt_section_1 (struct alpha_elf_link_hash_entry *h, PTR data)
+elf64_alpha_size_plt_section_1 (struct alpha_elf_link_hash_entry *h,
+				void * data)
 {
   asection *splt = (asection *) data;
   struct alpha_elf_got_entry *gotent;
@@ -2587,7 +2595,7 @@
     return;
 
   dynobj = elf_hash_table(info)->dynobj;
-  splt = bfd_get_section_by_name (dynobj, ".plt");
+  splt = bfd_get_linker_section (dynobj, ".plt");
   if (splt == NULL)
     return;
 
@@ -2597,7 +2605,7 @@
 				elf64_alpha_size_plt_section_1, splt);
 
   /* Every plt entry requires a JMP_SLOT relocation.  */
-  spltrel = bfd_get_section_by_name (dynobj, ".rela.plt");
+  spltrel = bfd_get_linker_section (dynobj, ".rela.plt");
   entries = 0;
   if (splt->size)
     {
@@ -2613,7 +2621,7 @@
      entire contents of the .got.plt section.  */
   if (elf64_alpha_use_secureplt)
     {
-      sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
+      sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
       sgotplt->size = entries ? 16 : 0;
     }
 }
@@ -2772,7 +2780,7 @@
   if (entries > 0)
     {
       bfd *dynobj = elf_hash_table(info)->dynobj;
-      asection *srel = bfd_get_section_by_name (dynobj, ".rela.got");
+      asection *srel = bfd_get_linker_section (dynobj, ".rela.got");
       BFD_ASSERT (srel != NULL);
       srel->size += sizeof (Elf64_External_Rela) * entries;
     }
@@ -2822,7 +2830,7 @@
     }
 
   dynobj = elf_hash_table(info)->dynobj;
-  srel = bfd_get_section_by_name (dynobj, ".rela.got");
+  srel = bfd_get_linker_section (dynobj, ".rela.got");
   if (!srel)
     {
       BFD_ASSERT (entries == 0);
@@ -2858,7 +2866,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
@@ -3168,7 +3176,7 @@
       else
 	{
 	  tsec_relocs = (_bfd_elf_link_read_relocs
-		         (info->abfd, info->tsec, (PTR) NULL,
+		         (info->abfd, info->tsec, NULL,
 			 (Elf_Internal_Rela *) NULL,
 			 info->link_info->keep_memory));
 	  if (tsec_relocs == NULL)
@@ -3582,7 +3590,9 @@
   use_gottprel = FALSE;
   new_symndx = is_gd ? ELF64_R_SYM (irel->r_info) : STN_UNDEF;
 
-  switch (!dynamic && !info->link_info->shared)
+  /* Some compilers warn about a Boolean-looking expression being
+     used in a switch.  The explicit cast silences them.  */
+  switch ((int) (!dynamic && !info->link_info->shared))
     {
     case 1:
       {
@@ -3753,7 +3763,7 @@
 
   /* Load the relocations for this section.  */
   internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
 		      link_info->keep_memory));
   if (internal_relocs == NULL)
     return FALSE;
@@ -4106,10 +4116,10 @@
 	  sec = h->root.u.def.section;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend,
-					 elf64_alpha_howto_table + r_type,
+					 rel, 1, relend,
+					 elf64_alpha_howto_table + r_type, 0,
 					 contents);
 
       if (sym != NULL && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
@@ -4138,7 +4148,7 @@
   bfd_boolean ret_val;
 
   BFD_ASSERT (is_alpha_elf (input_bfd));
-  
+
   /* Handle relocatable links with a smaller loop.  */
   if (info->relocatable)
     return elf64_alpha_relocate_section_r (output_bfd, info, input_bfd,
@@ -4153,7 +4163,7 @@
 
   dynobj = elf_hash_table (info)->dynobj;
   if (dynobj)
-    srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+    srelgot = bfd_get_linker_section (dynobj, ".rela.got");
   else
     srelgot = NULL;
 
@@ -4164,7 +4174,7 @@
 		      (input_bfd, elf_elfheader(input_bfd)->e_shstrndx,
 		       _bfd_elf_single_rel_hdr (input_section)->sh_name));
       BFD_ASSERT(section_name != NULL);
-      srel = bfd_get_section_by_name (dynobj, section_name);
+      srel = bfd_get_linker_section (dynobj, section_name);
     }
   else
     srel = NULL;
@@ -4212,6 +4222,7 @@
       bfd_vma value;
       bfd_vma addend;
       bfd_boolean dynamic_symbol_p;
+      bfd_boolean unresolved_reloc = FALSE;
       bfd_boolean undef_weak_ref = FALSE;
       unsigned long r_type;
 
@@ -4263,7 +4274,7 @@
 	     unless it has been done already.  */
 	  if ((sec->flags & SEC_MERGE)
 	      && ELF_ST_TYPE (sym->st_info) == STT_SECTION
-	      && sec->sec_info_type == ELF_INFO_TYPE_MERGE
+	      && sec->sec_info_type == SEC_INFO_TYPE_MERGE
 	      && gotent
 	      && !gotent->reloc_xlated)
 	    {
@@ -4293,7 +4304,6 @@
       else
 	{
 	  bfd_boolean warned;
-	  bfd_boolean unresolved_reloc;
 	  struct elf_link_hash_entry *hh;
 	  struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
 
@@ -4315,9 +4325,9 @@
 	  gotent = h->got_entries;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       addend = rel->r_addend;
       value += addend;
@@ -4526,7 +4536,12 @@
 	    else if (info->shared
 		     && r_symndx != STN_UNDEF
 		     && (input_section->flags & SEC_ALLOC)
-		     && !undef_weak_ref)
+		     && !undef_weak_ref
+		     && !(unresolved_reloc
+			  && (_bfd_elf_section_offset (output_bfd, info,
+						       input_section,
+						       rel->r_offset)
+			      == (bfd_vma) -1)))
 	      {
 		if (r_type == R_ALPHA_REFLONG)
 		  {
@@ -4572,7 +4587,11 @@
 	  /* ??? .eh_frame references to discarded sections will be smashed
 	     to relocations against SHN_UNDEF.  The .eh_frame format allows
 	     NULL to be encoded as 0 in any format, so this works here.  */
-	  if (r_symndx == STN_UNDEF)
+	  if (r_symndx == STN_UNDEF
+	      || (unresolved_reloc
+		  && _bfd_elf_section_offset (output_bfd, info,
+					      input_section,
+					      rel->r_offset) == (bfd_vma) -1))
 	    howto = (elf64_alpha_howto_table
 		     + (r_type - R_ALPHA_SREL32 + R_ALPHA_REFLONG));
 	  goto default_reloc;
@@ -4717,7 +4736,7 @@
 
 	    if (r_symndx < symtab_hdr->sh_info
 		&& sec != NULL && howto->pc_relative
-		&& elf_discarded_section (sec))
+		&& discarded_section (sec))
 	      break;
 
 	    if (h != NULL)
@@ -4771,9 +4790,9 @@
 
       BFD_ASSERT (h->dynindx != -1);
 
-      splt = bfd_get_section_by_name (dynobj, ".plt");
+      splt = bfd_get_linker_section (dynobj, ".plt");
       BFD_ASSERT (splt != NULL);
-      srel = bfd_get_section_by_name (dynobj, ".rela.plt");
+      srel = bfd_get_linker_section (dynobj, ".rela.plt");
       BFD_ASSERT (srel != NULL);
 
       for (gotent = ah->got_entries; gotent ; gotent = gotent->next)
@@ -4843,7 +4862,7 @@
       asection *srel;
       struct alpha_elf_got_entry *gotent;
 
-      srel = bfd_get_section_by_name (dynobj, ".rela.got");
+      srel = bfd_get_linker_section (dynobj, ".rela.got");
       BFD_ASSERT (srel != NULL);
 
       for (gotent = ((struct alpha_elf_link_hash_entry *) h)->got_entries;
@@ -4878,19 +4897,19 @@
 	      abort ();
 	    }
 
-	  elf64_alpha_emit_dynrel (output_bfd, info, sgot, srel, 
+	  elf64_alpha_emit_dynrel (output_bfd, info, sgot, srel,
 				   gotent->got_offset, h->dynindx,
 				   r_type, gotent->addend);
 
 	  if (gotent->reloc_type == R_ALPHA_TLSGD)
-	    elf64_alpha_emit_dynrel (output_bfd, info, sgot, srel, 
+	    elf64_alpha_emit_dynrel (output_bfd, info, sgot, srel,
 				     gotent->got_offset + 8, h->dynindx,
 				     R_ALPHA_DTPREL64, gotent->addend);
 	}
     }
 
   /* Mark some specially defined symbols as absolute.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+  if (h == elf_hash_table (info)->hdynamic
       || h == elf_hash_table (info)->hgot
       || h == elf_hash_table (info)->hplt)
     sym->st_shndx = SHN_ABS;
@@ -4908,7 +4927,7 @@
   asection *sdyn;
 
   dynobj = elf_hash_table (info)->dynobj;
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (elf_hash_table (info)->dynamic_sections_created)
     {
@@ -4916,8 +4935,8 @@
       Elf64_External_Dyn *dyncon, *dynconend;
       bfd_vma plt_vma, gotplt_vma;
 
-      splt = bfd_get_section_by_name (dynobj, ".plt");
-      srelaplt = bfd_get_section_by_name (output_bfd, ".rela.plt");
+      splt = bfd_get_linker_section (dynobj, ".plt");
+      srelaplt = bfd_get_linker_section (output_bfd, ".rela.plt");
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       plt_vma = splt->output_section->vma + splt->output_offset;
@@ -4925,7 +4944,7 @@
       gotplt_vma = 0;
       if (elf64_alpha_use_secureplt)
 	{
-	  sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
+	  sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
 	  BFD_ASSERT (sgotplt != NULL);
 	  if (sgotplt->size > 0)
 	    gotplt_vma = sgotplt->output_section->vma + sgotplt->output_offset;
@@ -5092,7 +5111,7 @@
 	  debug.external_ext = debug.external_ext_end = NULL;
 
 	  mdebug_handle = bfd_ecoff_debug_init (abfd, &debug, swap, info);
-	  if (mdebug_handle == (PTR) NULL)
+	  if (mdebug_handle == NULL)
 	    return FALSE;
 
 	  if (1)
@@ -5196,7 +5215,7 @@
 		  const char *name;
 		  struct alpha_elf_link_hash_entry *h;
 
-		  (*input_swap->swap_ext_in) (input_bfd, (PTR) eraw_src, &ext);
+		  (*input_swap->swap_ext_in) (input_bfd, eraw_src, &ext);
 		  if (ext.asym.sc == scNil
 		      || ext.asym.sc == scUndefined
 		      || ext.asym.sc == scSUndefined)
@@ -5243,7 +5262,7 @@
 	  einfo.failed = FALSE;
 	  elf_link_hash_traverse (elf_hash_table (info),
 				  elf64_alpha_output_extsym,
-				  (PTR) &einfo);
+				  &einfo);
 	  if (einfo.failed)
 	    return FALSE;
 
@@ -5301,7 +5320,9 @@
 }
 
 static enum elf_reloc_type_class
-elf64_alpha_reloc_type_class (const Elf_Internal_Rela *rela)
+elf64_alpha_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			      const asection *rel_sec ATTRIBUTE_UNUSED,
+			      const Elf_Internal_Rela *rela)
 {
   switch ((int) ELF64_R_TYPE (rela->r_info))
     {
diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index 057a92d..c992563 100644
--- a/bfd/elf64-hppa.c
+++ b/bfd/elf64-hppa.c
@@ -1,6 +1,7 @@
 /* Support for HPPA 64-bit ELF
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-   2010, 2011 Free Software Foundation, Inc.
+   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+   2009, 2010, 2011, 2012
+   Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -19,8 +20,8 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "alloca-conf.h"
 #include "sysdep.h"
+#include "alloca-conf.h"
 #include "bfd.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
@@ -193,9 +194,6 @@
   (bfd *, struct bfd_link_info *,
    struct elf_link_hash_entry *, Elf_Internal_Sym *);
 
-static enum elf_reloc_type_class elf64_hppa_reloc_type_class
-  (const Elf_Internal_Rela *);
-
 static bfd_boolean elf64_hppa_finish_dynamic_sections
   (bfd *, struct bfd_link_info *);
 
@@ -298,7 +296,7 @@
   struct elf64_hppa_link_hash_table *htab;
   bfd_size_type amt = sizeof (*htab);
 
-  htab = bfd_zalloc (abfd, amt);
+  htab = bfd_zmalloc (amt);
   if (htab == NULL)
     return NULL;
 
@@ -307,7 +305,7 @@
 				      sizeof (struct elf64_hppa_link_hash_entry),
 				      HPPA64_ELF_DATA))
     {
-      bfd_release (abfd, htab);
+      free (htab);
       return NULL;
     }
 
@@ -415,16 +413,16 @@
   if (!dynobj)
     hppa_info->root.dynobj = dynobj = abfd;
 
-  srel = bfd_get_section_by_name (dynobj, srel_name);
+  srel = bfd_get_linker_section (dynobj, srel_name);
   if (srel == NULL)
     {
-      srel = bfd_make_section_with_flags (dynobj, srel_name,
-					  (SEC_ALLOC
-					   | SEC_LOAD
-					   | SEC_HAS_CONTENTS
-					   | SEC_IN_MEMORY
-					   | SEC_LINKER_CREATED
-					   | SEC_READONLY));
+      srel = bfd_make_section_anyway_with_flags (dynobj, srel_name,
+						 (SEC_ALLOC
+						  | SEC_LOAD
+						  | SEC_HAS_CONTENTS
+						  | SEC_IN_MEMORY
+						  | SEC_LINKER_CREATED
+						  | SEC_READONLY));
       if (srel == NULL
 	  || !bfd_set_section_alignment (dynobj, srel, 3))
 	return FALSE;
@@ -475,7 +473,7 @@
 {
   Elf_Internal_Shdr *symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   bfd_signed_vma *local_refcounts;
-                  
+
   local_refcounts = elf_local_got_refcounts (abfd);
   if (local_refcounts == NULL)
     {
@@ -646,6 +644,9 @@
 		 || hh->eh.root.type == bfd_link_hash_warning)
 	    hh = hppa_elf_hash_entry (hh->eh.root.u.i.link);
 
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  hh->eh.root.non_ir_ref = 1;
 	  hh->eh.ref_regular = 1;
 	}
       else
@@ -795,7 +796,7 @@
 	  else
 	    {
 	      bfd_signed_vma *local_dlt_refcounts;
-                  
+
 	      /* This is a DLT entry for a local symbol.  */
 	      local_dlt_refcounts = hppa64_elf_local_refcounts (abfd);
 	      if (local_dlt_refcounts == NULL)
@@ -820,7 +821,7 @@
 	    {
 	      bfd_signed_vma *local_dlt_refcounts;
 	      bfd_signed_vma *local_plt_refcounts;
-                  
+
 	      /* This is a PLT entry for a local symbol.  */
 	      local_dlt_refcounts = hppa64_elf_local_refcounts (abfd);
 	      if (local_dlt_refcounts == NULL)
@@ -854,7 +855,7 @@
 	    {
 	      bfd_signed_vma *local_dlt_refcounts;
 	      bfd_signed_vma *local_opd_refcounts;
-                  
+
 	      /* This is a OPD for a local symbol.  */
 	      local_dlt_refcounts = hppa64_elf_local_refcounts (abfd);
 	      if (local_dlt_refcounts == NULL)
@@ -1131,7 +1132,7 @@
   Elf_Internal_Ehdr * i_ehdrp;
 
   i_ehdrp = elf_elfheader (abfd);
-  
+
   i_ehdrp->e_ident[EI_OSABI] = get_elf_backend_data (abfd)->elf_osabi;
   i_ehdrp->e_ident[EI_ABIVERSION] = 1;
 }
@@ -1156,12 +1157,12 @@
       if (!dynobj)
 	hppa_info->root.dynobj = dynobj = abfd;
 
-      opd = bfd_make_section_with_flags (dynobj, ".opd",
-					 (SEC_ALLOC
-					  | SEC_LOAD
-					  | SEC_HAS_CONTENTS
-					  | SEC_IN_MEMORY
-					  | SEC_LINKER_CREATED));
+      opd = bfd_make_section_anyway_with_flags (dynobj, ".opd",
+						(SEC_ALLOC
+						 | SEC_LOAD
+						 | SEC_HAS_CONTENTS
+						 | SEC_IN_MEMORY
+						 | SEC_LINKER_CREATED));
       if (!opd
 	  || !bfd_set_section_alignment (abfd, opd, 3))
 	{
@@ -1192,12 +1193,12 @@
       if (!dynobj)
 	hppa_info->root.dynobj = dynobj = abfd;
 
-      plt = bfd_make_section_with_flags (dynobj, ".plt",
-					 (SEC_ALLOC
-					  | SEC_LOAD
-					  | SEC_HAS_CONTENTS
-					  | SEC_IN_MEMORY
-					  | SEC_LINKER_CREATED));
+      plt = bfd_make_section_anyway_with_flags (dynobj, ".plt",
+						(SEC_ALLOC
+						 | SEC_LOAD
+						 | SEC_HAS_CONTENTS
+						 | SEC_IN_MEMORY
+						 | SEC_LINKER_CREATED));
       if (!plt
 	  || !bfd_set_section_alignment (abfd, plt, 3))
 	{
@@ -1228,12 +1229,12 @@
       if (!dynobj)
 	hppa_info->root.dynobj = dynobj = abfd;
 
-      dlt = bfd_make_section_with_flags (dynobj, ".dlt",
-					 (SEC_ALLOC
-					  | SEC_LOAD
-					  | SEC_HAS_CONTENTS
-					  | SEC_IN_MEMORY
-					  | SEC_LINKER_CREATED));
+      dlt = bfd_make_section_anyway_with_flags (dynobj, ".dlt",
+						(SEC_ALLOC
+						 | SEC_LOAD
+						 | SEC_HAS_CONTENTS
+						 | SEC_IN_MEMORY
+						 | SEC_LINKER_CREATED));
       if (!dlt
 	  || !bfd_set_section_alignment (abfd, dlt, 3))
 	{
@@ -1264,12 +1265,12 @@
       if (!dynobj)
 	hppa_info->root.dynobj = dynobj = abfd;
 
-      stub = bfd_make_section_with_flags (dynobj, ".stub",
-					  (SEC_ALLOC | SEC_LOAD
-					   | SEC_HAS_CONTENTS
-					   | SEC_IN_MEMORY
-					   | SEC_READONLY
-					   | SEC_LINKER_CREATED));
+      stub = bfd_make_section_anyway_with_flags (dynobj, ".stub",
+						 (SEC_ALLOC | SEC_LOAD
+						  | SEC_HAS_CONTENTS
+						  | SEC_IN_MEMORY
+						  | SEC_READONLY
+						  | SEC_LINKER_CREATED));
       if (!stub
 	  || !bfd_set_section_alignment (abfd, stub, 3))
 	{
@@ -1344,45 +1345,45 @@
   if (! get_opd (abfd, info, hppa_info))
     return FALSE;
 
-  s = bfd_make_section_with_flags (abfd, ".rela.dlt",
-				   (SEC_ALLOC | SEC_LOAD
-				    | SEC_HAS_CONTENTS
-				    | SEC_IN_MEMORY
-				    | SEC_READONLY
-				    | SEC_LINKER_CREATED));
+  s = bfd_make_section_anyway_with_flags (abfd, ".rela.dlt",
+					  (SEC_ALLOC | SEC_LOAD
+					   | SEC_HAS_CONTENTS
+					   | SEC_IN_MEMORY
+					   | SEC_READONLY
+					   | SEC_LINKER_CREATED));
   if (s == NULL
       || !bfd_set_section_alignment (abfd, s, 3))
     return FALSE;
   hppa_info->dlt_rel_sec = s;
 
-  s = bfd_make_section_with_flags (abfd, ".rela.plt",
-				   (SEC_ALLOC | SEC_LOAD
-				    | SEC_HAS_CONTENTS
-				    | SEC_IN_MEMORY
-				    | SEC_READONLY
-				    | SEC_LINKER_CREATED));
+  s = bfd_make_section_anyway_with_flags (abfd, ".rela.plt",
+					  (SEC_ALLOC | SEC_LOAD
+					   | SEC_HAS_CONTENTS
+					   | SEC_IN_MEMORY
+					   | SEC_READONLY
+					   | SEC_LINKER_CREATED));
   if (s == NULL
       || !bfd_set_section_alignment (abfd, s, 3))
     return FALSE;
   hppa_info->plt_rel_sec = s;
 
-  s = bfd_make_section_with_flags (abfd, ".rela.data",
-				   (SEC_ALLOC | SEC_LOAD
-				    | SEC_HAS_CONTENTS
-				    | SEC_IN_MEMORY
-				    | SEC_READONLY
-				    | SEC_LINKER_CREATED));
+  s = bfd_make_section_anyway_with_flags (abfd, ".rela.data",
+					  (SEC_ALLOC | SEC_LOAD
+					   | SEC_HAS_CONTENTS
+					   | SEC_IN_MEMORY
+					   | SEC_READONLY
+					   | SEC_LINKER_CREATED));
   if (s == NULL
       || !bfd_set_section_alignment (abfd, s, 3))
     return FALSE;
   hppa_info->other_rel_sec = s;
 
-  s = bfd_make_section_with_flags (abfd, ".rela.opd",
-				   (SEC_ALLOC | SEC_LOAD
-				    | SEC_HAS_CONTENTS
-				    | SEC_IN_MEMORY
-				    | SEC_READONLY
-				    | SEC_LINKER_CREATED));
+  s = bfd_make_section_anyway_with_flags (abfd, ".rela.opd",
+					  (SEC_ALLOC | SEC_LOAD
+					   | SEC_HAS_CONTENTS
+					   | SEC_IN_MEMORY
+					   | SEC_READONLY
+					   | SEC_LINKER_CREATED));
   if (s == NULL
       || !bfd_set_section_alignment (abfd, s, 3))
     return FALSE;
@@ -1561,7 +1562,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  sec = bfd_get_section_by_name (dynobj, ".interp");
+	  sec = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (sec != NULL);
 	  sec->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  sec->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
@@ -1574,7 +1575,7 @@
 	 not actually use these entries.  Reset the size of .rela.dlt,
 	 which will cause it to get stripped from the output file
 	 below.  */
-      sec = bfd_get_section_by_name (dynobj, ".rela.dlt");
+      sec = bfd_get_linker_section (dynobj, ".rela.dlt");
       if (sec != NULL)
 	sec->size = 0;
     }
@@ -1638,7 +1639,7 @@
 	    {
 	      *local_dlt = sec->size;
 	      sec->size += DLT_ENTRY_SIZE;
-	      if (info->shared) 
+	      if (info->shared)
 	        {
 		  srel->size += sizeof (Elf64_External_Rela);
 	        }
@@ -2212,7 +2213,7 @@
 
 	  nh = elf_link_hash_lookup (elf_hash_table (info),
 				     new_name, TRUE, TRUE, FALSE);
- 
+
 	  /* All we really want from the new symbol is its dynamic
 	     symbol index.  */
 	  if (nh)
@@ -2445,7 +2446,9 @@
    dynamic linker, before writing them out.  */
 
 static enum elf_reloc_type_class
-elf64_hppa_reloc_type_class (const Elf_Internal_Rela *rela)
+elf64_hppa_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			     const asection *rel_sec ATTRIBUTE_UNUSED,
+			     const Elf_Internal_Rela *rela)
 {
   if (ELF64_R_SYM (rela->r_info) == STN_UNDEF)
     return reloc_class_relative;
@@ -2491,7 +2494,7 @@
 			  elf64_hppa_finalize_dlt,
 			  info);
 
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (elf_hash_table (info)->dynamic_sections_created)
     {
@@ -2521,6 +2524,8 @@
 		 area at the start of the .data section.  So all we have to
 		 to is find the start of the .data section.  */
 	      s = bfd_get_section_by_name (output_bfd, ".data");
+	      if (!s)
+		return FALSE;
 	      dyn.d_un.d_ptr = s->vma;
 	      bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
 	      break;
@@ -2590,10 +2595,10 @@
 
       case 760:		/* Linux/hppa */
 	/* pr_cursig */
-	elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+	elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
 
 	/* pr_pid */
-	elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 32);
+	elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 32);
 
 	/* pr_reg */
 	offset = 112;
@@ -2619,16 +2624,16 @@
       return FALSE;
 
     case 136:		/* Linux/hppa elf_prpsinfo.  */
-      elf_tdata (abfd)->core_program
+      elf_tdata (abfd)->core->program
 	= _bfd_elfcore_strndup (abfd, note->descdata + 40, 16);
-      elf_tdata (abfd)->core_command
+      elf_tdata (abfd)->core->command
 	= _bfd_elfcore_strndup (abfd, note->descdata + 56, 80);
     }
 
   /* Note that for some reason, a spurious space is tacked
      onto the end of the args in some (at least one anyway)
      implementations, so strip it off if it exists.  */
-  command = elf_tdata (abfd)->core_command;
+  command = elf_tdata (abfd)->core->command;
   n = strlen (command);
 
   if (0 < n && command[n - 1] == ' ')
@@ -2686,7 +2691,7 @@
   s = bfd_get_section_by_name (abfd, ".interp");
   if (! s)
     {
-      for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+      for (m = elf_seg_map (abfd); m != NULL; m = m->next)
 	if (m->p_type == PT_PHDR)
 	  break;
       if (m == NULL)
@@ -2702,12 +2707,12 @@
 	  m->p_paddr_valid = 1;
 	  m->includes_phdrs = 1;
 
-	  m->next = elf_tdata (abfd)->segment_map;
-	  elf_tdata (abfd)->segment_map = m;
+	  m->next = elf_seg_map (abfd);
+	  elf_seg_map (abfd) = m;
 	}
     }
 
-  for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+  for (m = elf_seg_map (abfd); m != NULL; m = m->next)
     if (m->p_type == PT_LOAD)
       {
 	unsigned int i;
@@ -2771,7 +2776,7 @@
       if (bfd_bread (&sig, 4, abfd) != 4)
 	return FALSE;
 
-      elf_tdata (abfd)->core_signal = sig;
+      elf_tdata (abfd)->core->signal = sig;
 
       if (!_bfd_elf_make_section_from_phdr (abfd, hdr, sec_index, typename))
 	return FALSE;
@@ -3189,7 +3194,7 @@
 
   if (hppa_info == NULL)
     return bfd_reloc_notsupported;
-  
+
   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
   local_offsets = elf_local_got_offsets (input_bfd);
   insn = bfd_get_32 (input_bfd, hit_data);
@@ -3272,7 +3277,7 @@
 	    && value + addend + max_branch_offset >= 2*max_branch_offset)
 	  {
 	    (*_bfd_error_handler)
-	      (_("%B(%A+0x" BFD_VMA_FMT "x): cannot reach %s"),
+	      (_("%B(%A+0x%" BFD_VMA_FMT "x): cannot reach %s"),
 	      input_bfd,
 	      input_section,
 	      offset,
@@ -3858,14 +3863,14 @@
 	  /* This is not a local symbol.  */
 	  struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
 
-	  /* It seems this can happen with erroneous or unsupported 
+	  /* It seems this can happen with erroneous or unsupported
 	     input (mixing a.out and elf in an archive, for example.)  */
 	  if (sym_hashes == NULL)
 	    return FALSE;
 
 	  eh = sym_hashes[r_symndx - symtab_hdr->sh_info];
 
-	  while (eh->root.type == bfd_link_hash_indirect 
+	  while (eh->root.type == bfd_link_hash_indirect
 		 || eh->root.type == bfd_link_hash_warning)
 	    eh = (struct elf_link_hash_entry *) eh->root.u.i.link;
 
@@ -3919,9 +3924,9 @@
             }
 	}
 
-      if (sym_sec != NULL && elf_discarded_section (sym_sec))
+      if (sym_sec != NULL && discarded_section (sym_sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -4056,7 +4061,7 @@
 					elf64_hppa_finish_dynamic_sections
 #define elf_backend_grok_prstatus	elf64_hppa_grok_prstatus
 #define elf_backend_grok_psinfo		elf64_hppa_grok_psinfo
- 
+
 /* Stuff for the BFD linker: */
 #define bfd_elf64_bfd_link_hash_table_create \
 	elf64_hppa_hash_table_create
diff --git a/bfd/elf64-ia64-vms.c b/bfd/elf64-ia64-vms.c
new file mode 100644
index 0000000..102cdff
--- /dev/null
+++ b/bfd/elf64-ia64-vms.c
@@ -0,0 +1,5610 @@
+/* IA-64 support for OpenVMS
+   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+   2008, 2009, 2010, 2012  Free Software Foundation, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libbfd.h"
+#include "elf-bfd.h"
+#include "opcode/ia64.h"
+#include "elf/ia64.h"
+#include "objalloc.h"
+#include "hashtab.h"
+#include "elfxx-ia64.h"
+#include "vms.h"
+#include "bfdver.h"
+
+/* THE RULES for all the stuff the linker creates --
+
+  GOT		Entries created in response to LTOFF or LTOFF_FPTR
+		relocations.  Dynamic relocs created for dynamic
+		symbols in an application; REL relocs for locals
+		in a shared library.
+
+  FPTR		The canonical function descriptor.  Created for local
+		symbols in applications.  Descriptors for dynamic symbols
+		and local symbols in shared libraries are created by
+		ld.so.  Thus there are no dynamic relocs against these
+		objects.  The FPTR relocs for such _are_ passed through
+		to the dynamic relocation tables.
+
+  FULL_PLT	Created for a PCREL21B relocation against a dynamic symbol.
+		Requires the creation of a PLTOFF entry.  This does not
+		require any dynamic relocations.
+
+  PLTOFF	Created by PLTOFF relocations.  For local symbols, this
+		is an alternate function descriptor, and in shared libraries
+		requires two REL relocations.  Note that this cannot be
+		transformed into an FPTR relocation, since it must be in
+		range of the GP.  For dynamic symbols, this is a function
+		descriptor.  */
+
+typedef struct bfd_hash_entry *(*new_hash_entry_func)
+  (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
+
+/* In dynamically (linker-) created sections, we generally need to keep track
+   of the place a symbol or expression got allocated to. This is done via hash
+   tables that store entries of the following type.  */
+
+struct elf64_ia64_dyn_sym_info
+{
+  /* The addend for which this entry is relevant.  */
+  bfd_vma addend;
+
+  bfd_vma got_offset;
+  bfd_vma fptr_offset;
+  bfd_vma pltoff_offset;
+  bfd_vma plt_offset;
+  bfd_vma plt2_offset;
+
+  /* The symbol table entry, if any, that this was derived from.  */
+  struct elf_link_hash_entry *h;
+
+  /* Used to count non-got, non-plt relocations for delayed sizing
+     of relocation sections.  */
+  struct elf64_ia64_dyn_reloc_entry
+  {
+    struct elf64_ia64_dyn_reloc_entry *next;
+    asection *srel;
+    int type;
+    int count;
+  } *reloc_entries;
+
+  /* TRUE when the section contents have been updated.  */
+  unsigned got_done : 1;
+  unsigned fptr_done : 1;
+  unsigned pltoff_done : 1;
+
+  /* TRUE for the different kinds of linker data we want created.  */
+  unsigned want_got : 1;
+  unsigned want_gotx : 1;
+  unsigned want_fptr : 1;
+  unsigned want_ltoff_fptr : 1;
+  unsigned want_plt : 1;	/* A MIN_PLT entry.  */
+  unsigned want_plt2 : 1;	/* A FULL_PLT.  */
+  unsigned want_pltoff : 1;
+};
+
+struct elf64_ia64_local_hash_entry
+{
+  int id;
+  unsigned int r_sym;
+  /* The number of elements in elf64_ia64_dyn_sym_info array.  */
+  unsigned int count;
+  /* The number of sorted elements in elf64_ia64_dyn_sym_info array.  */
+  unsigned int sorted_count;
+  /* The size of elf64_ia64_dyn_sym_info array.  */
+  unsigned int size;
+  /* The array of elf64_ia64_dyn_sym_info.  */
+  struct elf64_ia64_dyn_sym_info *info;
+
+  /* TRUE if this hash entry's addends was translated for
+     SHF_MERGE optimization.  */
+  unsigned sec_merge_done : 1;
+};
+
+struct elf64_ia64_link_hash_entry
+{
+  struct elf_link_hash_entry root;
+
+  /* Set if this symbol is defined in a shared library.
+     We can't use root.u.def.section->owner as the symbol is an absolute
+     symbol.  */
+  bfd *shl;
+
+  /* The number of elements in elf64_ia64_dyn_sym_info array.  */
+  unsigned int count;
+  /* The number of sorted elements in elf64_ia64_dyn_sym_info array.  */
+  unsigned int sorted_count;
+  /* The size of elf64_ia64_dyn_sym_info array.  */
+  unsigned int size;
+  /* The array of elf64_ia64_dyn_sym_info.  */
+  struct elf64_ia64_dyn_sym_info *info;
+};
+
+struct elf64_ia64_link_hash_table
+{
+  /* The main hash table.  */
+  struct elf_link_hash_table root;
+
+  asection *fptr_sec;		/* Function descriptor table (or NULL).  */
+  asection *rel_fptr_sec;	/* Dynamic relocation section for same.  */
+  asection *pltoff_sec;		/* Private descriptors for plt (or NULL).  */
+  asection *fixups_sec;		/* Fixups section.  */
+  asection *transfer_sec;	/* Transfer vector section.  */
+  asection *note_sec;		/* .note section.  */
+
+  /* There are maybe R_IA64_GPREL22 relocations, including those
+     optimized from R_IA64_LTOFF22X, against non-SHF_IA_64_SHORT
+     sections.  We need to record those sections so that we can choose
+     a proper GP to cover all R_IA64_GPREL22 relocations.  */
+  asection *max_short_sec;	/* Maximum short output section.  */
+  bfd_vma max_short_offset;	/* Maximum short offset.  */
+  asection *min_short_sec;	/* Minimum short output section.  */
+  bfd_vma min_short_offset;	/* Minimum short offset.  */
+
+  htab_t loc_hash_table;
+  void *loc_hash_memory;
+};
+
+struct elf64_ia64_allocate_data
+{
+  struct bfd_link_info *info;
+  bfd_size_type ofs;
+};
+
+#define elf64_ia64_hash_table(p) \
+  (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
+  == IA64_ELF_DATA ? ((struct elf64_ia64_link_hash_table *) ((p)->hash)) : NULL)
+
+struct elf64_ia64_vms_obj_tdata
+{
+  struct elf_obj_tdata root;
+
+  /* Ident for shared library.  */
+  bfd_uint64_t ident;
+
+  /* Used only during link: offset in the .fixups section for this bfd.  */
+  bfd_vma fixups_off;
+
+  /* Max number of shared libraries.  */
+  unsigned int needed_count;
+};
+
+#define elf_ia64_vms_tdata(abfd) \
+  ((struct elf64_ia64_vms_obj_tdata *)((abfd)->tdata.any))
+#define elf_ia64_vms_ident(abfd) (elf_ia64_vms_tdata(abfd)->ident)
+
+struct elf64_vms_transfer
+{
+  unsigned char size[4];
+  unsigned char spare[4];
+  unsigned char tfradr1[8];
+  unsigned char tfradr2[8];
+  unsigned char tfradr3[8];
+  unsigned char tfradr4[8];
+  unsigned char tfradr5[8];
+
+  /* Local function descriptor for tfr3.  */
+  unsigned char tfr3_func[8];
+  unsigned char tfr3_gp[8];
+};
+
+typedef struct
+{
+  Elf64_External_Ehdr ehdr;
+  unsigned char vms_needed_count[8];
+} Elf64_External_VMS_Ehdr;
+
+static struct elf64_ia64_dyn_sym_info * get_dyn_sym_info
+  (struct elf64_ia64_link_hash_table *,
+   struct elf_link_hash_entry *,
+   bfd *, const Elf_Internal_Rela *, bfd_boolean);
+static bfd_boolean elf64_ia64_dynamic_symbol_p
+  (struct elf_link_hash_entry *);
+static bfd_boolean elf64_ia64_choose_gp
+  (bfd *, struct bfd_link_info *, bfd_boolean);
+static void elf64_ia64_dyn_sym_traverse
+  (struct elf64_ia64_link_hash_table *,
+   bfd_boolean (*) (struct elf64_ia64_dyn_sym_info *, void *),
+   void *);
+static bfd_boolean allocate_global_data_got
+  (struct elf64_ia64_dyn_sym_info *, void *);
+static bfd_boolean allocate_global_fptr_got
+  (struct elf64_ia64_dyn_sym_info *, void *);
+static bfd_boolean allocate_local_got
+  (struct elf64_ia64_dyn_sym_info *, void *);
+static bfd_boolean allocate_dynrel_entries
+  (struct elf64_ia64_dyn_sym_info *, void *);
+static asection *get_pltoff
+  (bfd *, struct elf64_ia64_link_hash_table *);
+static asection *get_got
+  (bfd *, struct elf64_ia64_link_hash_table *);
+
+
+/* Given a ELF reloc, return the matching HOWTO structure.  */
+
+static void
+elf64_ia64_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+			  arelent *bfd_reloc,
+			  Elf_Internal_Rela *elf_reloc)
+{
+  bfd_reloc->howto
+    = ia64_elf_lookup_howto ((unsigned int) ELF64_R_TYPE (elf_reloc->r_info));
+}
+
+
+#define PLT_FULL_ENTRY_SIZE	(2 * 16)
+
+static const bfd_byte plt_full_entry[PLT_FULL_ENTRY_SIZE] =
+{
+  0x0b, 0x78, 0x00, 0x02, 0x00, 0x24,  /*   [MMI]       addl r15=0,r1;;   */
+  0x00, 0x41, 0x3c, 0x70, 0x29, 0xc0,  /*               ld8.acq r16=[r15],8*/
+  0x01, 0x08, 0x00, 0x84,              /*               mov r14=r1;;      */
+  0x11, 0x08, 0x00, 0x1e, 0x18, 0x10,  /*   [MIB]       ld8 r1=[r15]      */
+  0x60, 0x80, 0x04, 0x80, 0x03, 0x00,  /*               mov b6=r16        */
+  0x60, 0x00, 0x80, 0x00               /*               br.few b6;;       */
+};
+
+static const bfd_byte oor_brl[16] =
+{
+  0x05, 0x00, 0x00, 0x00, 0x01, 0x00,  /*  [MLX]        nop.m 0           */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /*               brl.sptk.few tgt;;*/
+  0x00, 0x00, 0x00, 0xc0
+};
+
+
+/* These functions do relaxation for IA-64 ELF.  */
+
+/* Rename some of the generic section flags to better document how they
+   are used here.  */
+#define skip_relax_pass_0 sec_flg0
+#define skip_relax_pass_1 sec_flg1
+
+static void
+elf64_ia64_update_short_info (asection *sec, bfd_vma offset,
+			      struct elf64_ia64_link_hash_table *ia64_info)
+{
+  /* Skip ABS and SHF_IA_64_SHORT sections.  */
+  if (sec == bfd_abs_section_ptr
+      || (sec->flags & SEC_SMALL_DATA) != 0)
+    return;
+
+  if (!ia64_info->min_short_sec)
+    {
+      ia64_info->max_short_sec = sec;
+      ia64_info->max_short_offset = offset;
+      ia64_info->min_short_sec = sec;
+      ia64_info->min_short_offset = offset;
+    }
+  else if (sec == ia64_info->max_short_sec
+	   && offset > ia64_info->max_short_offset)
+    ia64_info->max_short_offset = offset;
+  else if (sec == ia64_info->min_short_sec
+	   && offset < ia64_info->min_short_offset)
+    ia64_info->min_short_offset = offset;
+  else if (sec->output_section->vma
+	   > ia64_info->max_short_sec->vma)
+    {
+      ia64_info->max_short_sec = sec;
+      ia64_info->max_short_offset = offset;
+    }
+  else if (sec->output_section->vma
+	   < ia64_info->min_short_sec->vma)
+    {
+      ia64_info->min_short_sec = sec;
+      ia64_info->min_short_offset = offset;
+    }
+}
+
+/* Use a two passes algorithm.  In the first pass, branches are relaxed
+   (which may increase the size of the section).  In the second pass,
+   the other relaxations are done.
+*/
+
+static bfd_boolean
+elf64_ia64_relax_section (bfd *abfd, asection *sec,
+			  struct bfd_link_info *link_info,
+			  bfd_boolean *again)
+{
+  struct one_fixup
+    {
+      struct one_fixup *next;
+      asection *tsec;
+      bfd_vma toff;
+      bfd_vma trampoff;
+    };
+
+  Elf_Internal_Shdr *symtab_hdr;
+  Elf_Internal_Rela *internal_relocs;
+  Elf_Internal_Rela *irel, *irelend;
+  bfd_byte *contents;
+  Elf_Internal_Sym *isymbuf = NULL;
+  struct elf64_ia64_link_hash_table *ia64_info;
+  struct one_fixup *fixups = NULL;
+  bfd_boolean changed_contents = FALSE;
+  bfd_boolean changed_relocs = FALSE;
+  bfd_boolean skip_relax_pass_0 = TRUE;
+  bfd_boolean skip_relax_pass_1 = TRUE;
+  bfd_vma gp = 0;
+
+  /* Assume we're not going to change any sizes, and we'll only need
+     one pass.  */
+  *again = FALSE;
+
+  if (link_info->relocatable)
+    (*link_info->callbacks->einfo)
+      (_("%P%F: --relax and -r may not be used together\n"));
+
+  /* Don't even try to relax for non-ELF outputs.  */
+  if (!is_elf_hash_table (link_info->hash))
+    return FALSE;
+
+  /* Nothing to do if there are no relocations or there is no need for
+     the current pass.  */
+  if ((sec->flags & SEC_RELOC) == 0
+      || sec->reloc_count == 0
+      || (link_info->relax_pass == 0 && sec->skip_relax_pass_0)
+      || (link_info->relax_pass == 1 && sec->skip_relax_pass_1))
+    return TRUE;
+
+  ia64_info = elf64_ia64_hash_table (link_info);
+  if (ia64_info == NULL)
+    return FALSE;
+
+  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+
+  /* Load the relocations for this section.  */
+  internal_relocs = (_bfd_elf_link_read_relocs
+		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
+		      link_info->keep_memory));
+  if (internal_relocs == NULL)
+    return FALSE;
+
+  irelend = internal_relocs + sec->reloc_count;
+
+  /* Get the section contents.  */
+  if (elf_section_data (sec)->this_hdr.contents != NULL)
+    contents = elf_section_data (sec)->this_hdr.contents;
+  else
+    {
+      if (!bfd_malloc_and_get_section (abfd, sec, &contents))
+	goto error_return;
+    }
+
+  for (irel = internal_relocs; irel < irelend; irel++)
+    {
+      unsigned long r_type = ELF64_R_TYPE (irel->r_info);
+      bfd_vma symaddr, reladdr, trampoff, toff, roff;
+      asection *tsec;
+      struct one_fixup *f;
+      bfd_size_type amt;
+      bfd_boolean is_branch;
+      struct elf64_ia64_dyn_sym_info *dyn_i;
+
+      switch (r_type)
+	{
+	case R_IA64_PCREL21B:
+	case R_IA64_PCREL21BI:
+	case R_IA64_PCREL21M:
+	case R_IA64_PCREL21F:
+	  /* In pass 1, all br relaxations are done. We can skip it. */
+	  if (link_info->relax_pass == 1)
+	    continue;
+	  skip_relax_pass_0 = FALSE;
+	  is_branch = TRUE;
+	  break;
+
+	case R_IA64_PCREL60B:
+	  /* We can't optimize brl to br in pass 0 since br relaxations
+	     will increase the code size. Defer it to pass 1.  */
+	  if (link_info->relax_pass == 0)
+	    {
+	      skip_relax_pass_1 = FALSE;
+	      continue;
+	    }
+	  is_branch = TRUE;
+	  break;
+
+	case R_IA64_GPREL22:
+	  /* Update max_short_sec/min_short_sec.  */
+
+	case R_IA64_LTOFF22X:
+	case R_IA64_LDXMOV:
+	  /* We can't relax ldx/mov in pass 0 since br relaxations will
+	     increase the code size. Defer it to pass 1.  */
+	  if (link_info->relax_pass == 0)
+	    {
+	      skip_relax_pass_1 = FALSE;
+	      continue;
+	    }
+	  is_branch = FALSE;
+	  break;
+
+	default:
+	  continue;
+	}
+
+      /* Get the value of the symbol referred to by the reloc.  */
+      if (ELF64_R_SYM (irel->r_info) < symtab_hdr->sh_info)
+	{
+	  /* A local symbol.  */
+	  Elf_Internal_Sym *isym;
+
+	  /* Read this BFD's local symbols.  */
+	  if (isymbuf == NULL)
+	    {
+	      isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
+	      if (isymbuf == NULL)
+		isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
+						symtab_hdr->sh_info, 0,
+						NULL, NULL, NULL);
+	      if (isymbuf == 0)
+		goto error_return;
+	    }
+
+	  isym = isymbuf + ELF64_R_SYM (irel->r_info);
+	  if (isym->st_shndx == SHN_UNDEF)
+	    continue;	/* We can't do anything with undefined symbols.  */
+	  else if (isym->st_shndx == SHN_ABS)
+	    tsec = bfd_abs_section_ptr;
+	  else if (isym->st_shndx == SHN_COMMON)
+	    tsec = bfd_com_section_ptr;
+	  else if (isym->st_shndx == SHN_IA_64_ANSI_COMMON)
+	    tsec = bfd_com_section_ptr;
+	  else
+	    tsec = bfd_section_from_elf_index (abfd, isym->st_shndx);
+
+	  toff = isym->st_value;
+	  dyn_i = get_dyn_sym_info (ia64_info, NULL, abfd, irel, FALSE);
+	}
+      else
+	{
+	  unsigned long indx;
+	  struct elf_link_hash_entry *h;
+
+	  indx = ELF64_R_SYM (irel->r_info) - symtab_hdr->sh_info;
+	  h = elf_sym_hashes (abfd)[indx];
+	  BFD_ASSERT (h != NULL);
+
+	  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;
+
+	  dyn_i = get_dyn_sym_info (ia64_info, h, abfd, irel, FALSE);
+
+	  /* For branches to dynamic symbols, we're interested instead
+	     in a branch to the PLT entry.  */
+	  if (is_branch && dyn_i && dyn_i->want_plt2)
+	    {
+	      /* Internal branches shouldn't be sent to the PLT.
+		 Leave this for now and we'll give an error later.  */
+	      if (r_type != R_IA64_PCREL21B)
+		continue;
+
+	      tsec = ia64_info->root.splt;
+	      toff = dyn_i->plt2_offset;
+	      BFD_ASSERT (irel->r_addend == 0);
+	    }
+
+	  /* Can't do anything else with dynamic symbols.  */
+	  else if (elf64_ia64_dynamic_symbol_p (h))
+	    continue;
+
+	  else
+	    {
+	      /* We can't do anything with undefined symbols.  */
+	      if (h->root.type == bfd_link_hash_undefined
+		  || h->root.type == bfd_link_hash_undefweak)
+		continue;
+
+	      tsec = h->root.u.def.section;
+	      toff = h->root.u.def.value;
+	    }
+	}
+
+      toff += irel->r_addend;
+
+      symaddr = tsec->output_section->vma + tsec->output_offset + toff;
+
+      roff = irel->r_offset;
+
+      if (is_branch)
+	{
+	  bfd_signed_vma offset;
+
+	  reladdr = (sec->output_section->vma
+		     + sec->output_offset
+		     + roff) & (bfd_vma) -4;
+
+	  /* The .plt section is aligned at 32byte and the .text section
+	     is aligned at 64byte. The .text section is right after the
+	     .plt section.  After the first relaxation pass, linker may
+	     increase the gap between the .plt and .text sections up
+	     to 32byte.  We assume linker will always insert 32byte
+	     between the .plt and .text sections after the first
+	     relaxation pass.  */
+	  if (tsec == ia64_info->root.splt)
+	    offset = -0x1000000 + 32;
+	  else
+	    offset = -0x1000000;
+
+	  /* If the branch is in range, no need to do anything.  */
+	  if ((bfd_signed_vma) (symaddr - reladdr) >= offset
+	      && (bfd_signed_vma) (symaddr - reladdr) <= 0x0FFFFF0)
+	    {
+	      /* If the 60-bit branch is in 21-bit range, optimize it. */
+	      if (r_type == R_IA64_PCREL60B)
+		{
+		  ia64_elf_relax_brl (contents, roff);
+
+		  irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
+                                               R_IA64_PCREL21B);
+
+		  /* If the original relocation offset points to slot
+		     1, change it to slot 2.  */
+		  if ((irel->r_offset & 3) == 1)
+		    irel->r_offset += 1;
+		}
+
+	      continue;
+	    }
+	  else if (r_type == R_IA64_PCREL60B)
+	    continue;
+	  else if (ia64_elf_relax_br (contents, roff))
+	    {
+	      irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
+                                           R_IA64_PCREL60B);
+
+	      /* Make the relocation offset point to slot 1.  */
+	      irel->r_offset = (irel->r_offset & ~((bfd_vma) 0x3)) + 1;
+	      continue;
+	    }
+
+	  /* We can't put a trampoline in a .init/.fini section. Issue
+	     an error.  */
+	  if (strcmp (sec->output_section->name, ".init") == 0
+	      || strcmp (sec->output_section->name, ".fini") == 0)
+	    {
+	      (*_bfd_error_handler)
+		(_("%B: Can't relax br at 0x%lx in section `%A'. Please use brl or indirect branch."),
+		 sec->owner, sec, (unsigned long) roff);
+	      bfd_set_error (bfd_error_bad_value);
+	      goto error_return;
+	    }
+
+	  /* If the branch and target are in the same section, you've
+	     got one honking big section and we can't help you unless
+	     you are branching backwards.  You'll get an error message
+	     later.  */
+	  if (tsec == sec && toff > roff)
+	    continue;
+
+	  /* Look for an existing fixup to this address.  */
+	  for (f = fixups; f ; f = f->next)
+	    if (f->tsec == tsec && f->toff == toff)
+	      break;
+
+	  if (f == NULL)
+	    {
+	      /* Two alternatives: If it's a branch to a PLT entry, we can
+		 make a copy of the FULL_PLT entry.  Otherwise, we'll have
+		 to use a `brl' insn to get where we're going.  */
+
+	      size_t size;
+
+	      if (tsec == ia64_info->root.splt)
+		size = sizeof (plt_full_entry);
+	      else
+		size = sizeof (oor_brl);
+
+	      /* Resize the current section to make room for the new branch. */
+	      trampoff = (sec->size + 15) & (bfd_vma) -16;
+
+	      /* If trampoline is out of range, there is nothing we
+		 can do.  */
+	      offset = trampoff - (roff & (bfd_vma) -4);
+	      if (offset < -0x1000000 || offset > 0x0FFFFF0)
+		continue;
+
+	      amt = trampoff + size;
+	      contents = (bfd_byte *) bfd_realloc (contents, amt);
+	      if (contents == NULL)
+		goto error_return;
+	      sec->size = amt;
+
+	      if (tsec == ia64_info->root.splt)
+		{
+		  memcpy (contents + trampoff, plt_full_entry, size);
+
+		  /* Hijack the old relocation for use as the PLTOFF reloc.  */
+		  irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
+					       R_IA64_PLTOFF22);
+		  irel->r_offset = trampoff;
+		}
+	      else
+		{
+                  memcpy (contents + trampoff, oor_brl, size);
+                  irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
+                                               R_IA64_PCREL60B);
+                  irel->r_offset = trampoff + 2;
+		}
+
+	      /* Record the fixup so we don't do it again this section.  */
+	      f = (struct one_fixup *)
+		bfd_malloc ((bfd_size_type) sizeof (*f));
+	      f->next = fixups;
+	      f->tsec = tsec;
+	      f->toff = toff;
+	      f->trampoff = trampoff;
+	      fixups = f;
+	    }
+	  else
+	    {
+	      /* If trampoline is out of range, there is nothing we
+		 can do.  */
+	      offset = f->trampoff - (roff & (bfd_vma) -4);
+	      if (offset < -0x1000000 || offset > 0x0FFFFF0)
+		continue;
+
+	      /* Nop out the reloc, since we're finalizing things here.  */
+	      irel->r_info = ELF64_R_INFO (0, R_IA64_NONE);
+	    }
+
+	  /* Fix up the existing branch to hit the trampoline.  */
+	  if (ia64_elf_install_value (contents + roff, offset, r_type)
+	      != bfd_reloc_ok)
+	    goto error_return;
+
+	  changed_contents = TRUE;
+	  changed_relocs = TRUE;
+	}
+      else
+	{
+	  /* Fetch the gp.  */
+	  if (gp == 0)
+	    {
+	      bfd *obfd = sec->output_section->owner;
+	      gp = _bfd_get_gp_value (obfd);
+	      if (gp == 0)
+		{
+		  if (!elf64_ia64_choose_gp (obfd, link_info, FALSE))
+		    goto error_return;
+		  gp = _bfd_get_gp_value (obfd);
+		}
+	    }
+
+	  /* If the data is out of range, do nothing.  */
+	  if ((bfd_signed_vma) (symaddr - gp) >= 0x200000
+	      ||(bfd_signed_vma) (symaddr - gp) < -0x200000)
+	    continue;
+
+	  if (r_type == R_IA64_GPREL22)
+	    elf64_ia64_update_short_info (tsec->output_section,
+					  tsec->output_offset + toff,
+					  ia64_info);
+	  else if (r_type == R_IA64_LTOFF22X)
+	    {
+              /* Can't deal yet correctly with ABS symbols.  */
+              if (bfd_is_abs_section (tsec))
+                continue;
+
+	      irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
+					   R_IA64_GPREL22);
+	      changed_relocs = TRUE;
+
+	      elf64_ia64_update_short_info (tsec->output_section,
+					    tsec->output_offset + toff,
+					    ia64_info);
+	    }
+	  else
+	    {
+	      ia64_elf_relax_ldxmov (contents, roff);
+	      irel->r_info = ELF64_R_INFO (0, R_IA64_NONE);
+	      changed_contents = TRUE;
+	      changed_relocs = TRUE;
+	    }
+	}
+    }
+
+  /* ??? If we created fixups, this may push the code segment large
+     enough that the data segment moves, which will change the GP.
+     Reset the GP so that we re-calculate next round.  We need to
+     do this at the _beginning_ of the next round; now will not do.  */
+
+  /* Clean up and go home.  */
+  while (fixups)
+    {
+      struct one_fixup *f = fixups;
+      fixups = fixups->next;
+      free (f);
+    }
+
+  if (isymbuf != NULL
+      && symtab_hdr->contents != (unsigned char *) isymbuf)
+    {
+      if (! link_info->keep_memory)
+	free (isymbuf);
+      else
+	{
+	  /* Cache the symbols for elf_link_input_bfd.  */
+	  symtab_hdr->contents = (unsigned char *) isymbuf;
+	}
+    }
+
+  if (contents != NULL
+      && elf_section_data (sec)->this_hdr.contents != contents)
+    {
+      if (!changed_contents && !link_info->keep_memory)
+	free (contents);
+      else
+	{
+	  /* Cache the section contents for elf_link_input_bfd.  */
+	  elf_section_data (sec)->this_hdr.contents = contents;
+	}
+    }
+
+  if (elf_section_data (sec)->relocs != internal_relocs)
+    {
+      if (!changed_relocs)
+	free (internal_relocs);
+      else
+	elf_section_data (sec)->relocs = internal_relocs;
+    }
+
+  if (link_info->relax_pass == 0)
+    {
+      /* Pass 0 is only needed to relax br.  */
+      sec->skip_relax_pass_0 = skip_relax_pass_0;
+      sec->skip_relax_pass_1 = skip_relax_pass_1;
+    }
+
+  *again = changed_contents || changed_relocs;
+  return TRUE;
+
+ error_return:
+  if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents)
+    free (isymbuf);
+  if (contents != NULL
+      && elf_section_data (sec)->this_hdr.contents != contents)
+    free (contents);
+  if (internal_relocs != NULL
+      && elf_section_data (sec)->relocs != internal_relocs)
+    free (internal_relocs);
+  return FALSE;
+}
+#undef skip_relax_pass_0
+#undef skip_relax_pass_1
+
+/* Return TRUE if NAME is an unwind table section name.  */
+
+static inline bfd_boolean
+is_unwind_section_name (bfd *abfd ATTRIBUTE_UNUSED, const char *name)
+{
+  return ((CONST_STRNEQ (name, ELF_STRING_ia64_unwind)
+	   && ! CONST_STRNEQ (name, ELF_STRING_ia64_unwind_info))
+	  || CONST_STRNEQ (name, ELF_STRING_ia64_unwind_once));
+}
+
+
+/* Convert IA-64 specific section flags to bfd internal section flags.  */
+
+/* ??? There is no bfd internal flag equivalent to the SHF_IA_64_NORECOV
+   flag.  */
+
+static bfd_boolean
+elf64_ia64_section_flags (flagword *flags,
+			  const Elf_Internal_Shdr *hdr)
+{
+  if (hdr->sh_flags & SHF_IA_64_SHORT)
+    *flags |= SEC_SMALL_DATA;
+
+  return TRUE;
+}
+
+/* Set the correct type for an IA-64 ELF section.  We do this by the
+   section name, which is a hack, but ought to work.  */
+
+static bfd_boolean
+elf64_ia64_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr,
+			  asection *sec)
+{
+  const char *name;
+
+  name = bfd_get_section_name (abfd, sec);
+
+  if (is_unwind_section_name (abfd, name))
+    {
+      /* We don't have the sections numbered at this point, so sh_info
+	 is set later, in elf64_ia64_final_write_processing.  */
+      hdr->sh_type = SHT_IA_64_UNWIND;
+      hdr->sh_flags |= SHF_LINK_ORDER;
+    }
+  else if (strcmp (name, ELF_STRING_ia64_archext) == 0)
+    hdr->sh_type = SHT_IA_64_EXT;
+
+  if (sec->flags & SEC_SMALL_DATA)
+    hdr->sh_flags |= SHF_IA_64_SHORT;
+
+  return TRUE;
+}
+
+/* Hook called by the linker routine which adds symbols from an object
+   file.  We use it to put .comm items in .sbss, and not .bss.  */
+
+static bfd_boolean
+elf64_ia64_add_symbol_hook (bfd *abfd,
+			    struct bfd_link_info *info,
+			    Elf_Internal_Sym *sym,
+			    const char **namep ATTRIBUTE_UNUSED,
+			    flagword *flagsp ATTRIBUTE_UNUSED,
+			    asection **secp,
+			    bfd_vma *valp)
+{
+  if (sym->st_shndx == SHN_COMMON
+      && !info->relocatable
+      && sym->st_size <= elf_gp_size (abfd))
+    {
+      /* Common symbols less than or equal to -G nn bytes are
+	 automatically put into .sbss.  */
+
+      asection *scomm = bfd_get_section_by_name (abfd, ".scommon");
+
+      if (scomm == NULL)
+	{
+	  scomm = bfd_make_section_with_flags (abfd, ".scommon",
+					       (SEC_ALLOC
+						| SEC_IS_COMMON
+						| SEC_LINKER_CREATED));
+	  if (scomm == NULL)
+	    return FALSE;
+	}
+
+      *secp = scomm;
+      *valp = sym->st_size;
+    }
+
+  return TRUE;
+}
+
+/* According to the Tahoe assembler spec, all labels starting with a
+   '.' are local.  */
+
+static bfd_boolean
+elf64_ia64_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED,
+				const char *name)
+{
+  return name[0] == '.';
+}
+
+/* Should we do dynamic things to this symbol?  */
+
+static bfd_boolean
+elf64_ia64_dynamic_symbol_p (struct elf_link_hash_entry *h)
+{
+  return h != NULL && h->def_dynamic;
+}
+
+static struct bfd_hash_entry*
+elf64_ia64_new_elf_hash_entry (struct bfd_hash_entry *entry,
+			       struct bfd_hash_table *table,
+			       const char *string)
+{
+  struct elf64_ia64_link_hash_entry *ret;
+  ret = (struct elf64_ia64_link_hash_entry *) entry;
+
+  /* Allocate the structure if it has not already been allocated by a
+     subclass.  */
+  if (!ret)
+    ret = bfd_hash_allocate (table, sizeof (*ret));
+
+  if (!ret)
+    return 0;
+
+  /* Call the allocation method of the superclass.  */
+  ret = ((struct elf64_ia64_link_hash_entry *)
+	 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
+				     table, string));
+
+  ret->info = NULL;
+  ret->count = 0;
+  ret->sorted_count = 0;
+  ret->size = 0;
+  return (struct bfd_hash_entry *) ret;
+}
+
+static void
+elf64_ia64_hash_hide_symbol (struct bfd_link_info *info,
+			     struct elf_link_hash_entry *xh,
+			     bfd_boolean force_local)
+{
+  struct elf64_ia64_link_hash_entry *h;
+  struct elf64_ia64_dyn_sym_info *dyn_i;
+  unsigned int count;
+
+  h = (struct elf64_ia64_link_hash_entry *)xh;
+
+  _bfd_elf_link_hash_hide_symbol (info, &h->root, force_local);
+
+  for (count = h->count, dyn_i = h->info;
+       count != 0;
+       count--, dyn_i++)
+    {
+      dyn_i->want_plt2 = 0;
+      dyn_i->want_plt = 0;
+    }
+}
+
+/* Compute a hash of a local hash entry.  */
+
+static hashval_t
+elf64_ia64_local_htab_hash (const void *ptr)
+{
+  struct elf64_ia64_local_hash_entry *entry
+    = (struct elf64_ia64_local_hash_entry *) ptr;
+
+  return ELF_LOCAL_SYMBOL_HASH (entry->id, entry->r_sym);
+}
+
+/* Compare local hash entries.  */
+
+static int
+elf64_ia64_local_htab_eq (const void *ptr1, const void *ptr2)
+{
+  struct elf64_ia64_local_hash_entry *entry1
+    = (struct elf64_ia64_local_hash_entry *) ptr1;
+  struct elf64_ia64_local_hash_entry *entry2
+    = (struct elf64_ia64_local_hash_entry *) ptr2;
+
+  return entry1->id == entry2->id && entry1->r_sym == entry2->r_sym;
+}
+
+/* Create the derived linker hash table.  The IA-64 ELF port uses this
+   derived hash table to keep information specific to the IA-64 ElF
+   linker (without using static variables).  */
+
+static struct bfd_link_hash_table *
+elf64_ia64_hash_table_create (bfd *abfd)
+{
+  struct elf64_ia64_link_hash_table *ret;
+
+  ret = bfd_zmalloc ((bfd_size_type) sizeof (*ret));
+  if (!ret)
+    return NULL;
+
+  if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
+				      elf64_ia64_new_elf_hash_entry,
+				      sizeof (struct elf64_ia64_link_hash_entry),
+				      IA64_ELF_DATA))
+    {
+      free (ret);
+      return NULL;
+    }
+
+  ret->loc_hash_table = htab_try_create (1024, elf64_ia64_local_htab_hash,
+					 elf64_ia64_local_htab_eq, NULL);
+  ret->loc_hash_memory = objalloc_create ();
+  if (!ret->loc_hash_table || !ret->loc_hash_memory)
+    {
+      free (ret);
+      return NULL;
+    }
+
+  return &ret->root.root;
+}
+
+/* Free the global elf64_ia64_dyn_sym_info array.  */
+
+static bfd_boolean
+elf64_ia64_global_dyn_info_free (void **xentry,
+				 void * unused ATTRIBUTE_UNUSED)
+{
+  struct elf64_ia64_link_hash_entry *entry
+    = (struct elf64_ia64_link_hash_entry *) xentry;
+
+  if (entry->root.root.type == bfd_link_hash_warning)
+    entry = (struct elf64_ia64_link_hash_entry *) entry->root.root.u.i.link;
+
+  if (entry->info)
+    {
+      free (entry->info);
+      entry->info = NULL;
+      entry->count = 0;
+      entry->sorted_count = 0;
+      entry->size = 0;
+    }
+
+  return TRUE;
+}
+
+/* Free the local elf64_ia64_dyn_sym_info array.  */
+
+static bfd_boolean
+elf64_ia64_local_dyn_info_free (void **slot,
+				void * unused ATTRIBUTE_UNUSED)
+{
+  struct elf64_ia64_local_hash_entry *entry
+    = (struct elf64_ia64_local_hash_entry *) *slot;
+
+  if (entry->info)
+    {
+      free (entry->info);
+      entry->info = NULL;
+      entry->count = 0;
+      entry->sorted_count = 0;
+      entry->size = 0;
+    }
+
+  return TRUE;
+}
+
+/* Destroy IA-64 linker hash table.  */
+
+static void
+elf64_ia64_hash_table_free (struct bfd_link_hash_table *hash)
+{
+  struct elf64_ia64_link_hash_table *ia64_info
+    = (struct elf64_ia64_link_hash_table *) hash;
+  if (ia64_info->loc_hash_table)
+    {
+      htab_traverse (ia64_info->loc_hash_table,
+		     elf64_ia64_local_dyn_info_free, NULL);
+      htab_delete (ia64_info->loc_hash_table);
+    }
+  if (ia64_info->loc_hash_memory)
+    objalloc_free ((struct objalloc *) ia64_info->loc_hash_memory);
+  elf_link_hash_traverse (&ia64_info->root,
+			  elf64_ia64_global_dyn_info_free, NULL);
+  _bfd_elf_link_hash_table_free (hash);
+}
+
+/* Traverse both local and global hash tables.  */
+
+struct elf64_ia64_dyn_sym_traverse_data
+{
+  bfd_boolean (*func) (struct elf64_ia64_dyn_sym_info *, void *);
+  void * data;
+};
+
+static bfd_boolean
+elf64_ia64_global_dyn_sym_thunk (struct bfd_hash_entry *xentry,
+				 void * xdata)
+{
+  struct elf64_ia64_link_hash_entry *entry
+    = (struct elf64_ia64_link_hash_entry *) xentry;
+  struct elf64_ia64_dyn_sym_traverse_data *data
+    = (struct elf64_ia64_dyn_sym_traverse_data *) xdata;
+  struct elf64_ia64_dyn_sym_info *dyn_i;
+  unsigned int count;
+
+  if (entry->root.root.type == bfd_link_hash_warning)
+    entry = (struct elf64_ia64_link_hash_entry *) entry->root.root.u.i.link;
+
+  for (count = entry->count, dyn_i = entry->info;
+       count != 0;
+       count--, dyn_i++)
+    if (! (*data->func) (dyn_i, data->data))
+      return FALSE;
+  return TRUE;
+}
+
+static bfd_boolean
+elf64_ia64_local_dyn_sym_thunk (void **slot, void * xdata)
+{
+  struct elf64_ia64_local_hash_entry *entry
+    = (struct elf64_ia64_local_hash_entry *) *slot;
+  struct elf64_ia64_dyn_sym_traverse_data *data
+    = (struct elf64_ia64_dyn_sym_traverse_data *) xdata;
+  struct elf64_ia64_dyn_sym_info *dyn_i;
+  unsigned int count;
+
+  for (count = entry->count, dyn_i = entry->info;
+       count != 0;
+       count--, dyn_i++)
+    if (! (*data->func) (dyn_i, data->data))
+      return FALSE;
+  return TRUE;
+}
+
+static void
+elf64_ia64_dyn_sym_traverse (struct elf64_ia64_link_hash_table *ia64_info,
+			     bfd_boolean (*func) (struct elf64_ia64_dyn_sym_info *, void *),
+			     void * data)
+{
+  struct elf64_ia64_dyn_sym_traverse_data xdata;
+
+  xdata.func = func;
+  xdata.data = data;
+
+  elf_link_hash_traverse (&ia64_info->root,
+			  elf64_ia64_global_dyn_sym_thunk, &xdata);
+  htab_traverse (ia64_info->loc_hash_table,
+		 elf64_ia64_local_dyn_sym_thunk, &xdata);
+}
+
+#define NOTE_NAME "IPF/VMS"
+
+static bfd_boolean
+create_ia64_vms_notes (bfd *abfd, struct bfd_link_info *info,
+                       unsigned int time_hi, unsigned int time_lo)
+{
+#define NBR_NOTES 7
+  Elf_Internal_Note notes[NBR_NOTES];
+  char *module_name;
+  int module_name_len;
+  unsigned char cur_time[8];
+  Elf64_External_VMS_ORIG_DYN_Note *orig_dyn;
+  unsigned int orig_dyn_size;
+  unsigned int note_size;
+  int i;
+  unsigned char *noteptr;
+  unsigned char *note_contents;
+  struct elf64_ia64_link_hash_table *ia64_info;
+
+  ia64_info = elf64_ia64_hash_table (info);
+
+  module_name = vms_get_module_name (bfd_get_filename (abfd), TRUE);
+  module_name_len = strlen (module_name) + 1;
+
+  bfd_putl32 (time_lo, cur_time + 0);
+  bfd_putl32 (time_hi, cur_time + 4);
+
+  /* Note 0: IMGNAM.  */
+  notes[0].type = NT_VMS_IMGNAM;
+  notes[0].descdata = module_name;
+  notes[0].descsz = module_name_len;
+
+  /* Note 1: GSTNAM.  */
+  notes[1].type = NT_VMS_GSTNAM;
+  notes[1].descdata = module_name;
+  notes[1].descsz = module_name_len;
+
+  /* Note 2: IMGID.  */
+#define IMG_ID "V1.0"
+  notes[2].type = NT_VMS_IMGID;
+  notes[2].descdata = IMG_ID;
+  notes[2].descsz = sizeof (IMG_ID);
+
+  /* Note 3: Linktime.  */
+  notes[3].type = NT_VMS_LINKTIME;
+  notes[3].descdata = (char *)cur_time;
+  notes[3].descsz = sizeof (cur_time);
+
+  /* Note 4: Linker id.  */
+  notes[4].type = NT_VMS_LINKID;
+  notes[4].descdata = "GNU ld " BFD_VERSION_STRING;
+  notes[4].descsz = strlen (notes[4].descdata) + 1;
+
+  /* Note 5: Original dyn.  */
+  orig_dyn_size = (sizeof (*orig_dyn) + sizeof (IMG_ID) - 1 + 7) & ~7;
+  orig_dyn = bfd_zalloc (abfd, orig_dyn_size);
+  if (orig_dyn == NULL)
+    return FALSE;
+  bfd_putl32 (1, orig_dyn->major_id);
+  bfd_putl32 (3, orig_dyn->minor_id);
+  memcpy (orig_dyn->manipulation_date, cur_time, sizeof (cur_time));
+  bfd_putl64 (VMS_LF_IMGSTA | VMS_LF_MAIN, orig_dyn->link_flags);
+  bfd_putl32 (EF_IA_64_ABI64, orig_dyn->elf_flags);
+  memcpy (orig_dyn->imgid, IMG_ID, sizeof (IMG_ID));
+  notes[5].type = NT_VMS_ORIG_DYN;
+  notes[5].descdata = (char *)orig_dyn;
+  notes[5].descsz = orig_dyn_size;
+
+  /* Note 3: Patchtime.  */
+  notes[6].type = NT_VMS_PATCHTIME;
+  notes[6].descdata = (char *)cur_time;
+  notes[6].descsz = sizeof (cur_time);
+
+  /* Compute notes size.  */
+  note_size = 0;
+  for (i = 0; i < NBR_NOTES; i++)
+    note_size += sizeof (Elf64_External_VMS_Note) - 1
+      + ((sizeof (NOTE_NAME) - 1 + 7) & ~7)
+      + ((notes[i].descsz + 7) & ~7);
+
+  /* Malloc a temporary buffer large enough for most notes */
+  note_contents = (unsigned char *) bfd_zalloc (abfd, note_size);
+  if (note_contents == NULL)
+    return FALSE;
+  noteptr = note_contents;
+
+  /* Fill notes.  */
+  for (i = 0; i < NBR_NOTES; i++)
+    {
+      Elf64_External_VMS_Note *enote = (Elf64_External_VMS_Note *) noteptr;
+
+      bfd_putl64 (sizeof (NOTE_NAME) - 1, enote->namesz);
+      bfd_putl64 (notes[i].descsz, enote->descsz);
+      bfd_putl64 (notes[i].type, enote->type);
+
+      noteptr = (unsigned char *)enote->name;
+      memcpy (noteptr, NOTE_NAME, sizeof (NOTE_NAME) - 1);
+      noteptr += (sizeof (NOTE_NAME) - 1 + 7) & ~7;
+      memcpy (noteptr, notes[i].descdata, notes[i].descsz);
+      noteptr += (notes[i].descsz + 7) & ~7;
+    }
+
+  ia64_info->note_sec->contents = note_contents;
+  ia64_info->note_sec->size = note_size;
+
+  free (module_name);
+
+  return TRUE;
+}
+
+static bfd_boolean
+elf64_ia64_create_dynamic_sections (bfd *abfd,
+				    struct bfd_link_info *info)
+{
+  struct elf64_ia64_link_hash_table *ia64_info;
+  asection *s;
+  flagword flags;
+  const struct elf_backend_data *bed;
+
+  ia64_info = elf64_ia64_hash_table (info);
+  if (ia64_info == NULL)
+    return FALSE;
+
+  if (elf_hash_table (info)->dynamic_sections_created)
+    return TRUE;
+
+  abfd = elf_hash_table (info)->dynobj;
+  bed = get_elf_backend_data (abfd);
+
+  flags = bed->dynamic_sec_flags;
+
+  s = bfd_make_section_anyway_with_flags (abfd, ".dynamic",
+					  flags | SEC_READONLY);
+  if (s == NULL
+      || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
+    return FALSE;
+
+  s = bfd_make_section_anyway_with_flags (abfd, ".plt", flags | SEC_READONLY);
+  if (s == NULL
+      || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
+    return FALSE;
+  ia64_info->root.splt = s;
+
+  if (!get_got (abfd, ia64_info))
+    return FALSE;
+
+  if (!get_pltoff (abfd, ia64_info))
+    return FALSE;
+
+  s = bfd_make_section_anyway_with_flags (abfd, ".vmsdynstr",
+					  (SEC_ALLOC
+					   | SEC_HAS_CONTENTS
+					   | SEC_IN_MEMORY
+					   | SEC_LINKER_CREATED));
+  if (s == NULL
+      || !bfd_set_section_alignment (abfd, s, 0))
+    return FALSE;
+
+  /* Create a fixup section.  */
+  s = bfd_make_section_anyway_with_flags (abfd, ".fixups",
+					  (SEC_ALLOC
+					   | SEC_HAS_CONTENTS
+					   | SEC_IN_MEMORY
+					   | SEC_LINKER_CREATED));
+  if (s == NULL
+      || !bfd_set_section_alignment (abfd, s, 3))
+    return FALSE;
+  ia64_info->fixups_sec = s;
+
+  /* Create the transfer fixup section.  */
+  s = bfd_make_section_anyway_with_flags (abfd, ".transfer",
+					  (SEC_ALLOC
+					   | SEC_HAS_CONTENTS
+					   | SEC_IN_MEMORY
+					   | SEC_LINKER_CREATED));
+  if (s == NULL
+      || !bfd_set_section_alignment (abfd, s, 3))
+    return FALSE;
+  s->size = sizeof (struct elf64_vms_transfer);
+  ia64_info->transfer_sec = s;
+
+  /* Create note section.  */
+  s = bfd_make_section_anyway_with_flags (abfd, ".vms.note",
+                                          (SEC_LINKER_CREATED
+                                           | SEC_HAS_CONTENTS
+                                           | SEC_IN_MEMORY
+                                           | SEC_READONLY));
+  if (s == NULL
+      || !bfd_set_section_alignment (abfd, s, 3))
+    return FALSE;
+  ia64_info->note_sec = s;
+
+  elf_hash_table (info)->dynamic_sections_created = TRUE;
+  return TRUE;
+}
+
+/* Find and/or create a hash entry for local symbol.  */
+static struct elf64_ia64_local_hash_entry *
+get_local_sym_hash (struct elf64_ia64_link_hash_table *ia64_info,
+		    bfd *abfd, const Elf_Internal_Rela *rel,
+		    bfd_boolean create)
+{
+  struct elf64_ia64_local_hash_entry e, *ret;
+  asection *sec = abfd->sections;
+  hashval_t h = ELF_LOCAL_SYMBOL_HASH (sec->id,
+				       ELF64_R_SYM (rel->r_info));
+  void **slot;
+
+  e.id = sec->id;
+  e.r_sym = ELF64_R_SYM (rel->r_info);
+  slot = htab_find_slot_with_hash (ia64_info->loc_hash_table, &e, h,
+				   create ? INSERT : NO_INSERT);
+
+  if (!slot)
+    return NULL;
+
+  if (*slot)
+    return (struct elf64_ia64_local_hash_entry *) *slot;
+
+  ret = (struct elf64_ia64_local_hash_entry *)
+	objalloc_alloc ((struct objalloc *) ia64_info->loc_hash_memory,
+			sizeof (struct elf64_ia64_local_hash_entry));
+  if (ret)
+    {
+      memset (ret, 0, sizeof (*ret));
+      ret->id = sec->id;
+      ret->r_sym = ELF64_R_SYM (rel->r_info);
+      *slot = ret;
+    }
+  return ret;
+}
+
+/* Used to sort elf64_ia64_dyn_sym_info array.  */
+
+static int
+addend_compare (const void *xp, const void *yp)
+{
+  const struct elf64_ia64_dyn_sym_info *x
+    = (const struct elf64_ia64_dyn_sym_info *) xp;
+  const struct elf64_ia64_dyn_sym_info *y
+    = (const struct elf64_ia64_dyn_sym_info *) yp;
+
+  return x->addend < y->addend ? -1 : x->addend > y->addend ? 1 : 0;
+}
+
+/* Sort elf64_ia64_dyn_sym_info array and remove duplicates.  */
+
+static unsigned int
+sort_dyn_sym_info (struct elf64_ia64_dyn_sym_info *info,
+		   unsigned int count)
+{
+  bfd_vma curr, prev, got_offset;
+  unsigned int i, kept, dupes, diff, dest, src, len;
+
+  qsort (info, count, sizeof (*info), addend_compare);
+
+  /* Find the first duplicate.  */
+  prev = info [0].addend;
+  got_offset = info [0].got_offset;
+  for (i = 1; i < count; i++)
+    {
+      curr = info [i].addend;
+      if (curr == prev)
+	{
+	  /* For duplicates, make sure that GOT_OFFSET is valid.  */
+	  if (got_offset == (bfd_vma) -1)
+	    got_offset = info [i].got_offset;
+	  break;
+	}
+      got_offset = info [i].got_offset;
+      prev = curr;
+    }
+
+  /* We may move a block of elements to here.  */
+  dest = i++;
+
+  /* Remove duplicates.  */
+  if (i < count)
+    {
+      while (i < count)
+	{
+	  /* For duplicates, make sure that the kept one has a valid
+	     got_offset.  */
+	  kept = dest - 1;
+	  if (got_offset != (bfd_vma) -1)
+	    info [kept].got_offset = got_offset;
+
+	  curr = info [i].addend;
+	  got_offset = info [i].got_offset;
+
+	  /* Move a block of elements whose first one is different from
+	     the previous.  */
+	  if (curr == prev)
+	    {
+	      for (src = i + 1; src < count; src++)
+		{
+		  if (info [src].addend != curr)
+		    break;
+		  /* For duplicates, make sure that GOT_OFFSET is
+		     valid.  */
+		  if (got_offset == (bfd_vma) -1)
+		    got_offset = info [src].got_offset;
+		}
+
+	      /* Make sure that the kept one has a valid got_offset.  */
+	      if (got_offset != (bfd_vma) -1)
+		info [kept].got_offset = got_offset;
+	    }
+	  else
+	    src = i;
+
+	  if (src >= count)
+	    break;
+
+	  /* Find the next duplicate.  SRC will be kept.  */
+	  prev = info [src].addend;
+	  got_offset = info [src].got_offset;
+	  for (dupes = src + 1; dupes < count; dupes ++)
+	    {
+	      curr = info [dupes].addend;
+	      if (curr == prev)
+		{
+		  /* Make sure that got_offset is valid.  */
+		  if (got_offset == (bfd_vma) -1)
+		    got_offset = info [dupes].got_offset;
+
+		  /* For duplicates, make sure that the kept one has
+		     a valid got_offset.  */
+		  if (got_offset != (bfd_vma) -1)
+		    info [dupes - 1].got_offset = got_offset;
+		  break;
+		}
+	      got_offset = info [dupes].got_offset;
+	      prev = curr;
+	    }
+
+	  /* How much to move.  */
+	  len = dupes - src;
+	  i = dupes + 1;
+
+	  if (len == 1 && dupes < count)
+	    {
+	      /* If we only move 1 element, we combine it with the next
+		 one.  There must be at least a duplicate.  Find the
+		 next different one.  */
+	      for (diff = dupes + 1, src++; diff < count; diff++, src++)
+		{
+		  if (info [diff].addend != curr)
+		    break;
+		  /* Make sure that got_offset is valid.  */
+		  if (got_offset == (bfd_vma) -1)
+		    got_offset = info [diff].got_offset;
+		}
+
+	      /* Makre sure that the last duplicated one has an valid
+		 offset.  */
+	      BFD_ASSERT (curr == prev);
+	      if (got_offset != (bfd_vma) -1)
+		info [diff - 1].got_offset = got_offset;
+
+	      if (diff < count)
+		{
+		  /* Find the next duplicate.  Track the current valid
+		     offset.  */
+		  prev = info [diff].addend;
+		  got_offset = info [diff].got_offset;
+		  for (dupes = diff + 1; dupes < count; dupes ++)
+		    {
+		      curr = info [dupes].addend;
+		      if (curr == prev)
+			{
+			  /* For duplicates, make sure that GOT_OFFSET
+			     is valid.  */
+			  if (got_offset == (bfd_vma) -1)
+			    got_offset = info [dupes].got_offset;
+			  break;
+			}
+		      got_offset = info [dupes].got_offset;
+		      prev = curr;
+		      diff++;
+		    }
+
+		  len = diff - src + 1;
+		  i = diff + 1;
+		}
+	    }
+
+	  memmove (&info [dest], &info [src], len * sizeof (*info));
+
+	  dest += len;
+	}
+
+      count = dest;
+    }
+  else
+    {
+      /* When we get here, either there is no duplicate at all or
+	 the only duplicate is the last element.  */
+      if (dest < count)
+	{
+	  /* If the last element is a duplicate, make sure that the
+	     kept one has a valid got_offset.  We also update count.  */
+	  if (got_offset != (bfd_vma) -1)
+	    info [dest - 1].got_offset = got_offset;
+	  count = dest;
+	}
+    }
+
+  return count;
+}
+
+/* Find and/or create a descriptor for dynamic symbol info.  This will
+   vary based on global or local symbol, and the addend to the reloc.
+
+   We don't sort when inserting.  Also, we sort and eliminate
+   duplicates if there is an unsorted section.  Typically, this will
+   only happen once, because we do all insertions before lookups.  We
+   then use bsearch to do a lookup.  This also allows lookups to be
+   fast.  So we have fast insertion (O(log N) due to duplicate check),
+   fast lookup (O(log N)) and one sort (O(N log N) expected time).
+   Previously, all lookups were O(N) because of the use of the linked
+   list and also all insertions were O(N) because of the check for
+   duplicates.  There are some complications here because the array
+   size grows occasionally, which may add an O(N) factor, but this
+   should be rare.  Also,  we free the excess array allocation, which
+   requires a copy which is O(N), but this only happens once.  */
+
+static struct elf64_ia64_dyn_sym_info *
+get_dyn_sym_info (struct elf64_ia64_link_hash_table *ia64_info,
+		  struct elf_link_hash_entry *h, bfd *abfd,
+		  const Elf_Internal_Rela *rel, bfd_boolean create)
+{
+  struct elf64_ia64_dyn_sym_info **info_p, *info, *dyn_i, key;
+  unsigned int *count_p, *sorted_count_p, *size_p;
+  unsigned int count, sorted_count, size;
+  bfd_vma addend = rel ? rel->r_addend : 0;
+  bfd_size_type amt;
+
+  if (h)
+    {
+      struct elf64_ia64_link_hash_entry *global_h;
+
+      global_h = (struct elf64_ia64_link_hash_entry *) h;
+      info_p = &global_h->info;
+      count_p = &global_h->count;
+      sorted_count_p = &global_h->sorted_count;
+      size_p = &global_h->size;
+    }
+  else
+    {
+      struct elf64_ia64_local_hash_entry *loc_h;
+
+      loc_h = get_local_sym_hash (ia64_info, abfd, rel, create);
+      if (!loc_h)
+	{
+	  BFD_ASSERT (!create);
+	  return NULL;
+	}
+
+      info_p = &loc_h->info;
+      count_p = &loc_h->count;
+      sorted_count_p = &loc_h->sorted_count;
+      size_p = &loc_h->size;
+    }
+
+  count = *count_p;
+  sorted_count = *sorted_count_p;
+  size = *size_p;
+  info = *info_p;
+  if (create)
+    {
+      /* When we create the array, we don't check for duplicates,
+         except in the previously sorted section if one exists, and
+	 against the last inserted entry.  This allows insertions to
+	 be fast.  */
+      if (info)
+	{
+	  if (sorted_count)
+	    {
+	      /* Try bsearch first on the sorted section.  */
+	      key.addend = addend;
+	      dyn_i = bsearch (&key, info, sorted_count,
+			       sizeof (*info), addend_compare);
+
+	      if (dyn_i)
+		{
+		  return dyn_i;
+		}
+	    }
+
+	  /* Do a quick check for the last inserted entry.  */
+	  dyn_i = info + count - 1;
+	  if (dyn_i->addend == addend)
+	    {
+	      return dyn_i;
+	    }
+	}
+
+      if (size == 0)
+	{
+	  /* It is the very first element. We create the array of size
+	     1.  */
+	  size = 1;
+	  amt = size * sizeof (*info);
+	  info = bfd_malloc (amt);
+	}
+      else if (size <= count)
+	{
+	  /* We double the array size every time when we reach the
+	     size limit.  */
+	  size += size;
+	  amt = size * sizeof (*info);
+	  info = bfd_realloc (info, amt);
+	}
+      else
+	goto has_space;
+
+      if (info == NULL)
+	return NULL;
+      *size_p = size;
+      *info_p = info;
+
+has_space:
+      /* Append the new one to the array.  */
+      dyn_i = info + count;
+      memset (dyn_i, 0, sizeof (*dyn_i));
+      dyn_i->got_offset = (bfd_vma) -1;
+      dyn_i->addend = addend;
+
+      /* We increment count only since the new ones are unsorted and
+	 may have duplicate.  */
+      (*count_p)++;
+    }
+  else
+    {
+      /* It is a lookup without insertion.  Sort array if part of the
+	 array isn't sorted.  */
+      if (count != sorted_count)
+	{
+	  count = sort_dyn_sym_info (info, count);
+	  *count_p = count;
+	  *sorted_count_p = count;
+	}
+
+      /* Free unused memory.  */
+      if (size != count)
+	{
+	  amt = count * sizeof (*info);
+	  info = bfd_malloc (amt);
+	  if (info != NULL)
+	    {
+	      memcpy (info, *info_p, amt);
+	      free (*info_p);
+	      *size_p = count;
+	      *info_p = info;
+	    }
+	}
+
+      key.addend = addend;
+      dyn_i = bsearch (&key, info, count,
+		       sizeof (*info), addend_compare);
+    }
+
+  return dyn_i;
+}
+
+static asection *
+get_got (bfd *abfd, struct elf64_ia64_link_hash_table *ia64_info)
+{
+  asection *got;
+  bfd *dynobj;
+
+  got = ia64_info->root.sgot;
+  if (!got)
+    {
+      flagword flags;
+
+      dynobj = ia64_info->root.dynobj;
+      if (!dynobj)
+	ia64_info->root.dynobj = dynobj = abfd;
+
+      /* The .got section is always aligned at 8 bytes.  */
+      flags = get_elf_backend_data (dynobj)->dynamic_sec_flags;
+      got = bfd_make_section_anyway_with_flags (dynobj, ".got",
+						flags | SEC_SMALL_DATA);
+      if (got == NULL
+          || !bfd_set_section_alignment (dynobj, got, 3))
+        return NULL;
+      ia64_info->root.sgot = got;
+    }
+
+  return got;
+}
+
+/* Create function descriptor section (.opd).  This section is called .opd
+   because it contains "official procedure descriptors".  The "official"
+   refers to the fact that these descriptors are used when taking the address
+   of a procedure, thus ensuring a unique address for each procedure.  */
+
+static asection *
+get_fptr (bfd *abfd, struct bfd_link_info *info,
+	  struct elf64_ia64_link_hash_table *ia64_info)
+{
+  asection *fptr;
+  bfd *dynobj;
+
+  fptr = ia64_info->fptr_sec;
+  if (!fptr)
+    {
+      dynobj = ia64_info->root.dynobj;
+      if (!dynobj)
+	ia64_info->root.dynobj = dynobj = abfd;
+
+      fptr = bfd_make_section_anyway_with_flags (dynobj, ".opd",
+						 (SEC_ALLOC
+						  | SEC_LOAD
+						  | SEC_HAS_CONTENTS
+						  | SEC_IN_MEMORY
+						  | (info->pie ? 0
+						     : SEC_READONLY)
+						  | SEC_LINKER_CREATED));
+      if (!fptr
+	  || !bfd_set_section_alignment (dynobj, fptr, 4))
+	{
+	  BFD_ASSERT (0);
+	  return NULL;
+	}
+
+      ia64_info->fptr_sec = fptr;
+
+      if (info->pie)
+	{
+	  asection *fptr_rel;
+	  fptr_rel = bfd_make_section_anyway_with_flags (dynobj, ".rela.opd",
+							 (SEC_ALLOC | SEC_LOAD
+							  | SEC_HAS_CONTENTS
+							  | SEC_IN_MEMORY
+							  | SEC_LINKER_CREATED
+							  | SEC_READONLY));
+	  if (fptr_rel == NULL
+	      || !bfd_set_section_alignment (dynobj, fptr_rel, 3))
+	    {
+	      BFD_ASSERT (0);
+	      return NULL;
+	    }
+
+	  ia64_info->rel_fptr_sec = fptr_rel;
+	}
+    }
+
+  return fptr;
+}
+
+static asection *
+get_pltoff (bfd *abfd, struct elf64_ia64_link_hash_table *ia64_info)
+{
+  asection *pltoff;
+  bfd *dynobj;
+
+  pltoff = ia64_info->pltoff_sec;
+  if (!pltoff)
+    {
+      dynobj = ia64_info->root.dynobj;
+      if (!dynobj)
+	ia64_info->root.dynobj = dynobj = abfd;
+
+      pltoff = bfd_make_section_anyway_with_flags (dynobj,
+						   ELF_STRING_ia64_pltoff,
+						   (SEC_ALLOC
+						    | SEC_LOAD
+						    | SEC_HAS_CONTENTS
+						    | SEC_IN_MEMORY
+						    | SEC_SMALL_DATA
+						    | SEC_LINKER_CREATED));
+      if (!pltoff
+	  || !bfd_set_section_alignment (dynobj, pltoff, 4))
+	{
+	  BFD_ASSERT (0);
+	  return NULL;
+	}
+
+      ia64_info->pltoff_sec = pltoff;
+    }
+
+  return pltoff;
+}
+
+static asection *
+get_reloc_section (bfd *abfd,
+		   struct elf64_ia64_link_hash_table *ia64_info,
+		   asection *sec, bfd_boolean create)
+{
+  const char *srel_name;
+  asection *srel;
+  bfd *dynobj;
+
+  srel_name = (bfd_elf_string_from_elf_section
+	       (abfd, elf_elfheader(abfd)->e_shstrndx,
+		_bfd_elf_single_rel_hdr (sec)->sh_name));
+  if (srel_name == NULL)
+    return NULL;
+
+  BFD_ASSERT ((CONST_STRNEQ (srel_name, ".rela")
+	       && strcmp (bfd_get_section_name (abfd, sec),
+			  srel_name+5) == 0)
+	      || (CONST_STRNEQ (srel_name, ".rel")
+		  && strcmp (bfd_get_section_name (abfd, sec),
+			     srel_name+4) == 0));
+
+  dynobj = ia64_info->root.dynobj;
+  if (!dynobj)
+    ia64_info->root.dynobj = dynobj = abfd;
+
+  srel = bfd_get_linker_section (dynobj, srel_name);
+  if (srel == NULL && create)
+    {
+      srel = bfd_make_section_anyway_with_flags (dynobj, srel_name,
+						 (SEC_ALLOC | SEC_LOAD
+						  | SEC_HAS_CONTENTS
+						  | SEC_IN_MEMORY
+						  | SEC_LINKER_CREATED
+						  | SEC_READONLY));
+      if (srel == NULL
+	  || !bfd_set_section_alignment (dynobj, srel, 3))
+	return NULL;
+    }
+
+  return srel;
+}
+
+static bfd_boolean
+count_dyn_reloc (bfd *abfd, struct elf64_ia64_dyn_sym_info *dyn_i,
+		 asection *srel, int type)
+{
+  struct elf64_ia64_dyn_reloc_entry *rent;
+
+  for (rent = dyn_i->reloc_entries; rent; rent = rent->next)
+    if (rent->srel == srel && rent->type == type)
+      break;
+
+  if (!rent)
+    {
+      rent = ((struct elf64_ia64_dyn_reloc_entry *)
+	      bfd_alloc (abfd, (bfd_size_type) sizeof (*rent)));
+      if (!rent)
+	return FALSE;
+
+      rent->next = dyn_i->reloc_entries;
+      rent->srel = srel;
+      rent->type = type;
+      rent->count = 0;
+      dyn_i->reloc_entries = rent;
+    }
+  rent->count++;
+
+  return TRUE;
+}
+
+static bfd_boolean
+elf64_ia64_check_relocs (bfd *abfd, struct bfd_link_info *info,
+			 asection *sec,
+			 const Elf_Internal_Rela *relocs)
+{
+  struct elf64_ia64_link_hash_table *ia64_info;
+  const Elf_Internal_Rela *relend;
+  Elf_Internal_Shdr *symtab_hdr;
+  const Elf_Internal_Rela *rel;
+  asection *got, *fptr, *srel, *pltoff;
+  enum {
+    NEED_GOT = 1,
+    NEED_GOTX = 2,
+    NEED_FPTR = 4,
+    NEED_PLTOFF = 8,
+    NEED_MIN_PLT = 16,
+    NEED_FULL_PLT = 32,
+    NEED_DYNREL = 64,
+    NEED_LTOFF_FPTR = 128
+  };
+  int need_entry;
+  struct elf_link_hash_entry *h;
+  unsigned long r_symndx;
+  bfd_boolean maybe_dynamic;
+
+  if (info->relocatable)
+    return TRUE;
+
+  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+  ia64_info = elf64_ia64_hash_table (info);
+  if (ia64_info == NULL)
+    return FALSE;
+
+  got = fptr = srel = pltoff = NULL;
+
+  relend = relocs + sec->reloc_count;
+
+  /* We scan relocations first to create dynamic relocation arrays.  We
+     modified get_dyn_sym_info to allow fast insertion and support fast
+     lookup in the next loop.  */
+  for (rel = relocs; rel < relend; ++rel)
+    {
+      r_symndx = ELF64_R_SYM (rel->r_info);
+      if (r_symndx >= symtab_hdr->sh_info)
+	{
+	  long indx = r_symndx - symtab_hdr->sh_info;
+	  h = elf_sym_hashes (abfd)[indx];
+	  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;
+	}
+      else
+	h = NULL;
+
+      /* We can only get preliminary data on whether a symbol is
+	 locally or externally defined, as not all of the input files
+	 have yet been processed.  Do something with what we know, as
+	 this may help reduce memory usage and processing time later.  */
+      maybe_dynamic = (h && ((!info->executable
+			      && (!SYMBOLIC_BIND (info, h)
+				  || info->unresolved_syms_in_shared_libs == RM_IGNORE))
+			     || !h->def_regular
+			     || h->root.type == bfd_link_hash_defweak));
+
+      need_entry = 0;
+      switch (ELF64_R_TYPE (rel->r_info))
+	{
+	case R_IA64_TPREL64MSB:
+	case R_IA64_TPREL64LSB:
+	case R_IA64_LTOFF_TPREL22:
+	case R_IA64_DTPREL32MSB:
+	case R_IA64_DTPREL32LSB:
+	case R_IA64_DTPREL64MSB:
+	case R_IA64_DTPREL64LSB:
+	case R_IA64_LTOFF_DTPREL22:
+	case R_IA64_DTPMOD64MSB:
+	case R_IA64_DTPMOD64LSB:
+	case R_IA64_LTOFF_DTPMOD22:
+          abort ();
+	  break;
+
+	case R_IA64_IPLTMSB:
+	case R_IA64_IPLTLSB:
+          break;
+
+	case R_IA64_LTOFF_FPTR22:
+	case R_IA64_LTOFF_FPTR64I:
+	case R_IA64_LTOFF_FPTR32MSB:
+	case R_IA64_LTOFF_FPTR32LSB:
+	case R_IA64_LTOFF_FPTR64MSB:
+	case R_IA64_LTOFF_FPTR64LSB:
+	  need_entry = NEED_FPTR | NEED_GOT | NEED_LTOFF_FPTR;
+	  break;
+
+	case R_IA64_FPTR64I:
+	case R_IA64_FPTR32MSB:
+	case R_IA64_FPTR32LSB:
+	case R_IA64_FPTR64MSB:
+	case R_IA64_FPTR64LSB:
+	  if (info->shared || h)
+	    need_entry = NEED_FPTR | NEED_DYNREL;
+	  else
+	    need_entry = NEED_FPTR;
+	  break;
+
+	case R_IA64_LTOFF22:
+	case R_IA64_LTOFF64I:
+	  need_entry = NEED_GOT;
+	  break;
+
+	case R_IA64_LTOFF22X:
+	  need_entry = NEED_GOTX;
+	  break;
+
+	case R_IA64_PLTOFF22:
+	case R_IA64_PLTOFF64I:
+	case R_IA64_PLTOFF64MSB:
+	case R_IA64_PLTOFF64LSB:
+	  need_entry = NEED_PLTOFF;
+	  if (h)
+	    {
+	      if (maybe_dynamic)
+		need_entry |= NEED_MIN_PLT;
+	    }
+	  else
+	    {
+	      (*info->callbacks->warning)
+		(info, _("@pltoff reloc against local symbol"), 0,
+		 abfd, 0, (bfd_vma) 0);
+	    }
+	  break;
+
+	case R_IA64_PCREL21B:
+        case R_IA64_PCREL60B:
+	  /* Depending on where this symbol is defined, we may or may not
+	     need a full plt entry.  Only skip if we know we'll not need
+	     the entry -- static or symbolic, and the symbol definition
+	     has already been seen.  */
+	  if (maybe_dynamic && rel->r_addend == 0)
+	    need_entry = NEED_FULL_PLT;
+	  break;
+
+	case R_IA64_IMM14:
+	case R_IA64_IMM22:
+	case R_IA64_IMM64:
+	case R_IA64_DIR32MSB:
+	case R_IA64_DIR32LSB:
+	case R_IA64_DIR64MSB:
+	case R_IA64_DIR64LSB:
+	  /* Shared objects will always need at least a REL relocation.  */
+	  if (info->shared || maybe_dynamic)
+	    need_entry = NEED_DYNREL;
+	  break;
+
+	case R_IA64_PCREL22:
+	case R_IA64_PCREL64I:
+	case R_IA64_PCREL32MSB:
+	case R_IA64_PCREL32LSB:
+	case R_IA64_PCREL64MSB:
+	case R_IA64_PCREL64LSB:
+	  if (maybe_dynamic)
+	    need_entry = NEED_DYNREL;
+	  break;
+	}
+
+      if (!need_entry)
+	continue;
+
+      if ((need_entry & NEED_FPTR) != 0
+	  && rel->r_addend)
+	{
+	  (*info->callbacks->warning)
+	    (info, _("non-zero addend in @fptr reloc"), 0,
+	     abfd, 0, (bfd_vma) 0);
+	}
+
+      if (get_dyn_sym_info (ia64_info, h, abfd, rel, TRUE) == NULL)
+	return FALSE;
+    }
+
+  /* Now, we only do lookup without insertion, which is very fast
+     with the modified get_dyn_sym_info.  */
+  for (rel = relocs; rel < relend; ++rel)
+    {
+      struct elf64_ia64_dyn_sym_info *dyn_i;
+      int dynrel_type = R_IA64_NONE;
+
+      r_symndx = ELF64_R_SYM (rel->r_info);
+      if (r_symndx >= symtab_hdr->sh_info)
+	{
+	  /* We're dealing with a global symbol -- find its hash entry
+	     and mark it as being referenced.  */
+	  long indx = r_symndx - symtab_hdr->sh_info;
+	  h = elf_sym_hashes (abfd)[indx];
+	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
+	  h->ref_regular = 1;
+	}
+      else
+	h = NULL;
+
+      /* We can only get preliminary data on whether a symbol is
+	 locally or externally defined, as not all of the input files
+	 have yet been processed.  Do something with what we know, as
+	 this may help reduce memory usage and processing time later.  */
+      maybe_dynamic = (h && ((!info->executable
+			      && (!SYMBOLIC_BIND (info, h)
+				  || info->unresolved_syms_in_shared_libs == RM_IGNORE))
+			     || !h->def_regular
+			     || h->root.type == bfd_link_hash_defweak));
+
+      need_entry = 0;
+      switch (ELF64_R_TYPE (rel->r_info))
+	{
+	case R_IA64_TPREL64MSB:
+	case R_IA64_TPREL64LSB:
+	case R_IA64_LTOFF_TPREL22:
+	case R_IA64_DTPREL32MSB:
+	case R_IA64_DTPREL32LSB:
+	case R_IA64_DTPREL64MSB:
+	case R_IA64_DTPREL64LSB:
+	case R_IA64_LTOFF_DTPREL22:
+	case R_IA64_DTPMOD64MSB:
+	case R_IA64_DTPMOD64LSB:
+	case R_IA64_LTOFF_DTPMOD22:
+          abort ();
+	  break;
+
+	case R_IA64_LTOFF_FPTR22:
+	case R_IA64_LTOFF_FPTR64I:
+	case R_IA64_LTOFF_FPTR32MSB:
+	case R_IA64_LTOFF_FPTR32LSB:
+	case R_IA64_LTOFF_FPTR64MSB:
+	case R_IA64_LTOFF_FPTR64LSB:
+	  need_entry = NEED_FPTR | NEED_GOT | NEED_LTOFF_FPTR;
+	  break;
+
+	case R_IA64_FPTR64I:
+	case R_IA64_FPTR32MSB:
+	case R_IA64_FPTR32LSB:
+	case R_IA64_FPTR64MSB:
+	case R_IA64_FPTR64LSB:
+	  if (info->shared || h)
+	    need_entry = NEED_FPTR | NEED_DYNREL;
+	  else
+	    need_entry = NEED_FPTR;
+	  dynrel_type = R_IA64_FPTR64LSB;
+	  break;
+
+	case R_IA64_LTOFF22:
+	case R_IA64_LTOFF64I:
+	  need_entry = NEED_GOT;
+	  break;
+
+	case R_IA64_LTOFF22X:
+	  need_entry = NEED_GOTX;
+	  break;
+
+	case R_IA64_PLTOFF22:
+	case R_IA64_PLTOFF64I:
+	case R_IA64_PLTOFF64MSB:
+	case R_IA64_PLTOFF64LSB:
+	  need_entry = NEED_PLTOFF;
+	  if (h)
+	    {
+	      if (maybe_dynamic)
+		need_entry |= NEED_MIN_PLT;
+	    }
+	  break;
+
+	case R_IA64_PCREL21B:
+        case R_IA64_PCREL60B:
+	  /* Depending on where this symbol is defined, we may or may not
+	     need a full plt entry.  Only skip if we know we'll not need
+	     the entry -- static or symbolic, and the symbol definition
+	     has already been seen.  */
+	  if (maybe_dynamic && rel->r_addend == 0)
+	    need_entry = NEED_FULL_PLT;
+	  break;
+
+	case R_IA64_IMM14:
+	case R_IA64_IMM22:
+	case R_IA64_IMM64:
+	case R_IA64_DIR32MSB:
+	case R_IA64_DIR32LSB:
+	case R_IA64_DIR64MSB:
+	case R_IA64_DIR64LSB:
+	  /* Shared objects will always need at least a REL relocation.  */
+	  if (info->shared || maybe_dynamic)
+	    need_entry = NEED_DYNREL;
+	  dynrel_type = R_IA64_DIR64LSB;
+	  break;
+
+	case R_IA64_IPLTMSB:
+	case R_IA64_IPLTLSB:
+	  break;
+
+	case R_IA64_PCREL22:
+	case R_IA64_PCREL64I:
+	case R_IA64_PCREL32MSB:
+	case R_IA64_PCREL32LSB:
+	case R_IA64_PCREL64MSB:
+	case R_IA64_PCREL64LSB:
+	  if (maybe_dynamic)
+	    need_entry = NEED_DYNREL;
+	  dynrel_type = R_IA64_PCREL64LSB;
+	  break;
+	}
+
+      if (!need_entry)
+	continue;
+
+      dyn_i = get_dyn_sym_info (ia64_info, h, abfd, rel, FALSE);
+
+      /* Record whether or not this is a local symbol.  */
+      dyn_i->h = h;
+
+      /* Create what's needed.  */
+      if (need_entry & (NEED_GOT | NEED_GOTX))
+	{
+	  if (!got)
+	    {
+	      got = get_got (abfd, ia64_info);
+	      if (!got)
+		return FALSE;
+	    }
+	  if (need_entry & NEED_GOT)
+	    dyn_i->want_got = 1;
+	  if (need_entry & NEED_GOTX)
+	    dyn_i->want_gotx = 1;
+	}
+      if (need_entry & NEED_FPTR)
+	{
+          /* Create the .opd section.  */
+	  if (!fptr)
+	    {
+	      fptr = get_fptr (abfd, info, ia64_info);
+	      if (!fptr)
+		return FALSE;
+	    }
+	  dyn_i->want_fptr = 1;
+	}
+      if (need_entry & NEED_LTOFF_FPTR)
+	dyn_i->want_ltoff_fptr = 1;
+      if (need_entry & (NEED_MIN_PLT | NEED_FULL_PLT))
+	{
+          if (!ia64_info->root.dynobj)
+	    ia64_info->root.dynobj = abfd;
+	  h->needs_plt = 1;
+	  dyn_i->want_plt = 1;
+	}
+      if (need_entry & NEED_FULL_PLT)
+	dyn_i->want_plt2 = 1;
+      if (need_entry & NEED_PLTOFF)
+	{
+	  /* This is needed here, in case @pltoff is used in a non-shared
+	     link.  */
+	  if (!pltoff)
+	    {
+	      pltoff = get_pltoff (abfd, ia64_info);
+	      if (!pltoff)
+		return FALSE;
+	    }
+
+	  dyn_i->want_pltoff = 1;
+	}
+      if ((need_entry & NEED_DYNREL) && (sec->flags & SEC_ALLOC))
+	{
+	  if (!srel)
+	    {
+	      srel = get_reloc_section (abfd, ia64_info, sec, TRUE);
+	      if (!srel)
+		return FALSE;
+	    }
+	  if (!count_dyn_reloc (abfd, dyn_i, srel, dynrel_type))
+	    return FALSE;
+	}
+    }
+
+  return TRUE;
+}
+
+/* For cleanliness, and potentially faster dynamic loading, allocate
+   external GOT entries first.  */
+
+static bfd_boolean
+allocate_global_data_got (struct elf64_ia64_dyn_sym_info *dyn_i,
+			  void * data)
+{
+  struct elf64_ia64_allocate_data *x = (struct elf64_ia64_allocate_data *)data;
+
+  if ((dyn_i->want_got || dyn_i->want_gotx)
+      && ! dyn_i->want_fptr
+      && elf64_ia64_dynamic_symbol_p (dyn_i->h))
+     {
+       /* GOT entry with FPTR is done by allocate_global_fptr_got.  */
+       dyn_i->got_offset = x->ofs;
+       x->ofs += 8;
+     }
+  return TRUE;
+}
+
+/* Next, allocate all the GOT entries used by LTOFF_FPTR relocs.  */
+
+static bfd_boolean
+allocate_global_fptr_got (struct elf64_ia64_dyn_sym_info *dyn_i,
+			  void * data)
+{
+  struct elf64_ia64_allocate_data *x = (struct elf64_ia64_allocate_data *)data;
+
+  if (dyn_i->want_got
+      && dyn_i->want_fptr
+      && elf64_ia64_dynamic_symbol_p (dyn_i->h))
+    {
+      dyn_i->got_offset = x->ofs;
+      x->ofs += 8;
+    }
+  return TRUE;
+}
+
+/* Lastly, allocate all the GOT entries for local data.  */
+
+static bfd_boolean
+allocate_local_got (struct elf64_ia64_dyn_sym_info *dyn_i,
+		    void * data)
+{
+  struct elf64_ia64_allocate_data *x = (struct elf64_ia64_allocate_data *) data;
+
+  if ((dyn_i->want_got || dyn_i->want_gotx)
+      && !elf64_ia64_dynamic_symbol_p (dyn_i->h))
+    {
+      dyn_i->got_offset = x->ofs;
+      x->ofs += 8;
+    }
+  return TRUE;
+}
+
+/* Allocate function descriptors.  We can do these for every function
+   in a main executable that is not exported.  */
+
+static bfd_boolean
+allocate_fptr (struct elf64_ia64_dyn_sym_info *dyn_i, void * data)
+{
+  struct elf64_ia64_allocate_data *x = (struct elf64_ia64_allocate_data *) data;
+
+  if (dyn_i->want_fptr)
+    {
+      struct elf_link_hash_entry *h = dyn_i->h;
+
+      if (h)
+	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 == NULL || !h->def_dynamic)
+	{
+          /*  A non dynamic symbol.  */
+	  dyn_i->fptr_offset = x->ofs;
+	  x->ofs += 16;
+	}
+      else
+	dyn_i->want_fptr = 0;
+    }
+  return TRUE;
+}
+
+/* Allocate all the minimal PLT entries.  */
+
+static bfd_boolean
+allocate_plt_entries (struct elf64_ia64_dyn_sym_info *dyn_i,
+		      void * data ATTRIBUTE_UNUSED)
+{
+  if (dyn_i->want_plt)
+    {
+      struct elf_link_hash_entry *h = dyn_i->h;
+
+      if (h)
+	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;
+
+      /* ??? Versioned symbols seem to lose NEEDS_PLT.  */
+      if (elf64_ia64_dynamic_symbol_p (h))
+	{
+	  dyn_i->want_pltoff = 1;
+	}
+      else
+	{
+	  dyn_i->want_plt = 0;
+	  dyn_i->want_plt2 = 0;
+	}
+    }
+  return TRUE;
+}
+
+/* Allocate all the full PLT entries.  */
+
+static bfd_boolean
+allocate_plt2_entries (struct elf64_ia64_dyn_sym_info *dyn_i,
+		       void * data)
+{
+  struct elf64_ia64_allocate_data *x = (struct elf64_ia64_allocate_data *)data;
+
+  if (dyn_i->want_plt2)
+    {
+      struct elf_link_hash_entry *h = dyn_i->h;
+      bfd_size_type ofs = x->ofs;
+
+      dyn_i->plt2_offset = ofs;
+      x->ofs = ofs + PLT_FULL_ENTRY_SIZE;
+
+      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;
+      dyn_i->h->plt.offset = ofs;
+    }
+  return TRUE;
+}
+
+/* Allocate all the PLTOFF entries requested by relocations and
+   plt entries.  We can't share space with allocated FPTR entries,
+   because the latter are not necessarily addressable by the GP.
+   ??? Relaxation might be able to determine that they are.  */
+
+static bfd_boolean
+allocate_pltoff_entries (struct elf64_ia64_dyn_sym_info *dyn_i,
+			 void * data)
+{
+  struct elf64_ia64_allocate_data *x = (struct elf64_ia64_allocate_data *)data;
+
+  if (dyn_i->want_pltoff)
+    {
+      dyn_i->pltoff_offset = x->ofs;
+      x->ofs += 16;
+    }
+  return TRUE;
+}
+
+/* Allocate dynamic relocations for those symbols that turned out
+   to be dynamic.  */
+
+static bfd_boolean
+allocate_dynrel_entries (struct elf64_ia64_dyn_sym_info *dyn_i,
+			 void * data)
+{
+  struct elf64_ia64_allocate_data *x = (struct elf64_ia64_allocate_data *)data;
+  struct elf64_ia64_link_hash_table *ia64_info;
+  struct elf64_ia64_dyn_reloc_entry *rent;
+  bfd_boolean dynamic_symbol, shared, resolved_zero;
+  struct elf64_ia64_link_hash_entry *h_ia64;
+
+  ia64_info = elf64_ia64_hash_table (x->info);
+  if (ia64_info == NULL)
+    return FALSE;
+
+  /* Note that this can't be used in relation to FPTR relocs below.  */
+  dynamic_symbol = elf64_ia64_dynamic_symbol_p (dyn_i->h);
+
+  shared = x->info->shared;
+  resolved_zero = (dyn_i->h
+		   && ELF_ST_VISIBILITY (dyn_i->h->other)
+		   && dyn_i->h->root.type == bfd_link_hash_undefweak);
+
+  /* Take care of the GOT and PLT relocations.  */
+
+  if ((!resolved_zero
+       && (dynamic_symbol || shared)
+       && (dyn_i->want_got || dyn_i->want_gotx))
+      || (dyn_i->want_ltoff_fptr
+	  && dyn_i->h
+	  && dyn_i->h->def_dynamic))
+    {
+      /* VMS: FIX64.  */
+      if (dyn_i->h != NULL && dyn_i->h->def_dynamic)
+        {
+          h_ia64 = (struct elf64_ia64_link_hash_entry *) dyn_i->h;
+          elf_ia64_vms_tdata (h_ia64->shl)->fixups_off +=
+            sizeof (Elf64_External_VMS_IMAGE_FIXUP);
+          ia64_info->fixups_sec->size +=
+            sizeof (Elf64_External_VMS_IMAGE_FIXUP);
+        }
+    }
+
+  if (ia64_info->rel_fptr_sec && dyn_i->want_fptr)
+    {
+      /* VMS: only image reloc.  */
+      if (dyn_i->h == NULL || dyn_i->h->root.type != bfd_link_hash_undefweak)
+	ia64_info->rel_fptr_sec->size += sizeof (Elf64_External_Rela);
+    }
+
+  if (!resolved_zero && dyn_i->want_pltoff)
+    {
+      /* VMS: FIXFD.  */
+      if (dyn_i->h != NULL && dyn_i->h->def_dynamic)
+        {
+          h_ia64 = (struct elf64_ia64_link_hash_entry *) dyn_i->h;
+          elf_ia64_vms_tdata (h_ia64->shl)->fixups_off +=
+            sizeof (Elf64_External_VMS_IMAGE_FIXUP);
+          ia64_info->fixups_sec->size +=
+            sizeof (Elf64_External_VMS_IMAGE_FIXUP);
+        }
+    }
+
+  /* Take care of the normal data relocations.  */
+
+  for (rent = dyn_i->reloc_entries; rent; rent = rent->next)
+    {
+      int count = rent->count;
+
+      switch (rent->type)
+	{
+	case R_IA64_FPTR32LSB:
+	case R_IA64_FPTR64LSB:
+	  /* Allocate one iff !want_fptr and not PIE, which by this point
+	     will be true only if we're actually allocating one statically
+	     in the main executable.  Position independent executables
+	     need a relative reloc.  */
+	  if (dyn_i->want_fptr && !x->info->pie)
+	    continue;
+	  break;
+	case R_IA64_PCREL32LSB:
+	case R_IA64_PCREL64LSB:
+	  if (!dynamic_symbol)
+	    continue;
+	  break;
+	case R_IA64_DIR32LSB:
+	case R_IA64_DIR64LSB:
+	  if (!dynamic_symbol && !shared)
+	    continue;
+	  break;
+	case R_IA64_IPLTLSB:
+	  if (!dynamic_symbol && !shared)
+	    continue;
+	  /* Use two REL relocations for IPLT relocations
+	     against local symbols.  */
+	  if (!dynamic_symbol)
+	    count *= 2;
+	  break;
+	case R_IA64_DTPREL32LSB:
+	case R_IA64_TPREL64LSB:
+	case R_IA64_DTPREL64LSB:
+	case R_IA64_DTPMOD64LSB:
+	  break;
+	default:
+	  abort ();
+	}
+
+      /* Add a fixup.  */
+      if (!dynamic_symbol)
+        abort ();
+
+      h_ia64 = (struct elf64_ia64_link_hash_entry *) dyn_i->h;
+      elf_ia64_vms_tdata (h_ia64->shl)->fixups_off +=
+        sizeof (Elf64_External_VMS_IMAGE_FIXUP);
+      ia64_info->fixups_sec->size +=
+        sizeof (Elf64_External_VMS_IMAGE_FIXUP);
+    }
+
+  return TRUE;
+}
+
+static bfd_boolean
+elf64_ia64_adjust_dynamic_symbol (struct bfd_link_info *info ATTRIBUTE_UNUSED,
+				  struct elf_link_hash_entry *h)
+{
+  /* ??? Undefined symbols with PLT entries should be re-defined
+     to be the PLT entry.  */
+
+  /* If this is a weak symbol, and there is a real definition, the
+     processor independent code will have arranged for us to see the
+     real definition first, and we can just use the same value.  */
+  if (h->u.weakdef != NULL)
+    {
+      BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
+                  || h->u.weakdef->root.type == bfd_link_hash_defweak);
+      h->root.u.def.section = h->u.weakdef->root.u.def.section;
+      h->root.u.def.value = h->u.weakdef->root.u.def.value;
+      return TRUE;
+    }
+
+  /* If this is a reference to a symbol defined by a dynamic object which
+     is not a function, we might allocate the symbol in our .dynbss section
+     and allocate a COPY dynamic relocation.
+
+     But IA-64 code is canonically PIC, so as a rule we can avoid this sort
+     of hackery.  */
+
+  return TRUE;
+}
+
+static bfd_boolean
+elf64_ia64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
+				  struct bfd_link_info *info)
+{
+  struct elf64_ia64_allocate_data data;
+  struct elf64_ia64_link_hash_table *ia64_info;
+  asection *sec;
+  bfd *dynobj;
+  struct elf_link_hash_table *hash_table;
+
+  hash_table = elf_hash_table (info);
+  dynobj = hash_table->dynobj;
+  ia64_info = elf64_ia64_hash_table (info);
+  if (ia64_info == NULL)
+    return FALSE;
+  BFD_ASSERT(dynobj != NULL);
+  data.info = info;
+
+  /* Allocate the GOT entries.  */
+
+  if (ia64_info->root.sgot)
+    {
+      data.ofs = 0;
+      elf64_ia64_dyn_sym_traverse (ia64_info, allocate_global_data_got, &data);
+      elf64_ia64_dyn_sym_traverse (ia64_info, allocate_global_fptr_got, &data);
+      elf64_ia64_dyn_sym_traverse (ia64_info, allocate_local_got, &data);
+      ia64_info->root.sgot->size = data.ofs;
+    }
+
+  /* Allocate the FPTR entries.  */
+
+  if (ia64_info->fptr_sec)
+    {
+      data.ofs = 0;
+      elf64_ia64_dyn_sym_traverse (ia64_info, allocate_fptr, &data);
+      ia64_info->fptr_sec->size = data.ofs;
+    }
+
+  /* Now that we've seen all of the input files, we can decide which
+     symbols need plt entries.  Allocate the minimal PLT entries first.
+     We do this even though dynamic_sections_created may be FALSE, because
+     this has the side-effect of clearing want_plt and want_plt2.  */
+
+  data.ofs = 0;
+  elf64_ia64_dyn_sym_traverse (ia64_info, allocate_plt_entries, &data);
+
+  /* Align the pointer for the plt2 entries.  */
+  data.ofs = (data.ofs + 31) & (bfd_vma) -32;
+
+  elf64_ia64_dyn_sym_traverse (ia64_info, allocate_plt2_entries, &data);
+  if (data.ofs != 0 || ia64_info->root.dynamic_sections_created)
+    {
+      /* FIXME: we always reserve the memory for dynamic linker even if
+	 there are no PLT entries since dynamic linker may assume the
+	 reserved memory always exists.  */
+
+      BFD_ASSERT (ia64_info->root.dynamic_sections_created);
+
+      ia64_info->root.splt->size = data.ofs;
+    }
+
+  /* Allocate the PLTOFF entries.  */
+
+  if (ia64_info->pltoff_sec)
+    {
+      data.ofs = 0;
+      elf64_ia64_dyn_sym_traverse (ia64_info, allocate_pltoff_entries, &data);
+      ia64_info->pltoff_sec->size = data.ofs;
+    }
+
+  if (ia64_info->root.dynamic_sections_created)
+    {
+      /* Allocate space for the dynamic relocations that turned out to be
+	 required.  */
+      elf64_ia64_dyn_sym_traverse (ia64_info, allocate_dynrel_entries, &data);
+    }
+
+  /* We have now determined the sizes of the various dynamic sections.
+     Allocate memory for them.  */
+  for (sec = dynobj->sections; sec != NULL; sec = sec->next)
+    {
+      bfd_boolean strip;
+
+      if (!(sec->flags & SEC_LINKER_CREATED))
+	continue;
+
+      /* If we don't need this section, strip it from the output file.
+	 There were several sections primarily related to dynamic
+	 linking that must be create before the linker maps input
+	 sections to output sections.  The linker does that before
+	 bfd_elf_size_dynamic_sections is called, and it is that
+	 function which decides whether anything needs to go into
+	 these sections.  */
+
+      strip = (sec->size == 0);
+
+      if (sec == ia64_info->root.sgot)
+	strip = FALSE;
+      else if (sec == ia64_info->root.srelgot)
+	{
+	  if (strip)
+	    ia64_info->root.srelgot = NULL;
+	  else
+	    /* We use the reloc_count field as a counter if we need to
+	       copy relocs into the output file.  */
+	    sec->reloc_count = 0;
+	}
+      else if (sec == ia64_info->fptr_sec)
+	{
+	  if (strip)
+	    ia64_info->fptr_sec = NULL;
+	}
+      else if (sec == ia64_info->rel_fptr_sec)
+	{
+	  if (strip)
+	    ia64_info->rel_fptr_sec = NULL;
+	  else
+	    /* We use the reloc_count field as a counter if we need to
+	       copy relocs into the output file.  */
+	    sec->reloc_count = 0;
+	}
+      else if (sec == ia64_info->root.splt)
+	{
+	  if (strip)
+	    ia64_info->root.splt = NULL;
+	}
+      else if (sec == ia64_info->pltoff_sec)
+	{
+	  if (strip)
+	    ia64_info->pltoff_sec = NULL;
+	}
+      else if (sec == ia64_info->fixups_sec)
+	{
+          if (strip)
+            ia64_info->fixups_sec = NULL;
+	}
+      else if (sec == ia64_info->transfer_sec)
+        {
+          ;
+        }
+      else
+	{
+	  const char *name;
+
+	  /* It's OK to base decisions on the section name, because none
+	     of the dynobj section names depend upon the input files.  */
+	  name = bfd_get_section_name (dynobj, sec);
+
+	  if (strcmp (name, ".got.plt") == 0)
+	    strip = FALSE;
+	  else if (CONST_STRNEQ (name, ".rel"))
+	    {
+	      if (!strip)
+		{
+		  /* We use the reloc_count field as a counter if we need to
+		     copy relocs into the output file.  */
+		  sec->reloc_count = 0;
+		}
+	    }
+	  else
+	    continue;
+	}
+
+      if (strip)
+	sec->flags |= SEC_EXCLUDE;
+      else
+	{
+	  /* Allocate memory for the section contents.  */
+	  sec->contents = (bfd_byte *) bfd_zalloc (dynobj, sec->size);
+	  if (sec->contents == NULL && sec->size != 0)
+	    return FALSE;
+	}
+    }
+
+  if (elf_hash_table (info)->dynamic_sections_created)
+    {
+      bfd *abfd;
+      asection *dynsec;
+      asection *dynstrsec;
+      Elf_Internal_Dyn dyn;
+      const struct elf_backend_data *bed;
+      unsigned int shl_num = 0;
+      bfd_vma fixups_off = 0;
+      bfd_vma strdyn_off;
+      unsigned int time_hi, time_lo;
+
+      /* The .dynamic section must exist and be empty.  */
+      dynsec = bfd_get_linker_section (hash_table->dynobj, ".dynamic");
+      BFD_ASSERT (dynsec != NULL);
+      BFD_ASSERT (dynsec->size == 0);
+
+      dynstrsec = bfd_get_linker_section (hash_table->dynobj, ".vmsdynstr");
+      BFD_ASSERT (dynstrsec != NULL);
+      BFD_ASSERT (dynstrsec->size == 0);
+      dynstrsec->size = 1;	/* Initial blank.  */
+
+      /* Ident + link time.  */
+      vms_get_time (&time_hi, &time_lo);
+
+      if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_IDENT, 0))
+        return FALSE;
+      if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_LINKTIME,
+                                       (((bfd_uint64_t)time_hi) << 32)
+                                       + time_lo))
+        return FALSE;
+
+      /* Strtab.  */
+      strdyn_off = dynsec->size;
+      if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_STRTAB_OFFSET, 0))
+        return FALSE;
+      if (!_bfd_elf_add_dynamic_entry (info, DT_STRSZ, 0))
+        return FALSE;
+
+      /* PLTGOT  */
+      if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_PLTGOT_SEG, 0))
+        return FALSE;
+      if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_PLTGOT_OFFSET, 0))
+        return FALSE;
+
+      /* Misc.  */
+      if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_FPMODE, 0x9800000))
+        return FALSE;
+      if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_LNKFLAGS,
+                                       VMS_LF_IMGSTA | VMS_LF_MAIN))
+        return FALSE;
+
+      /* Add entries for shared libraries.  */
+      for (abfd = info->input_bfds; abfd; abfd = abfd->link_next)
+        {
+          char *soname;
+          size_t soname_len;
+          bfd_size_type strindex;
+          bfd_byte *newcontents;
+          bfd_vma fixups_shl_off;
+
+          if (!(abfd->flags & DYNAMIC))
+            continue;
+          BFD_ASSERT (abfd->xvec == output_bfd->xvec);
+
+          if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_NEEDED_IDENT,
+                                           elf_ia64_vms_ident (abfd)))
+            return FALSE;
+
+          soname = vms_get_module_name (abfd->filename, TRUE);
+          if (soname == NULL)
+            return FALSE;
+          strindex = dynstrsec->size;
+          soname_len = strlen (soname) + 1;
+          newcontents = (bfd_byte *) bfd_realloc (dynstrsec->contents,
+                                                  strindex + soname_len);
+          if (newcontents == NULL)
+            return FALSE;
+          memcpy (newcontents + strindex, soname, soname_len);
+          dynstrsec->size += soname_len;
+          dynstrsec->contents = newcontents;
+
+          if (!_bfd_elf_add_dynamic_entry (info, DT_NEEDED, strindex))
+            return FALSE;
+
+          if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_FIXUP_NEEDED,
+                                           shl_num))
+            return FALSE;
+          shl_num++;
+
+          /* The fixups_off was in fact containing the size of the fixup
+             section.  Remap into the offset.  */
+          fixups_shl_off = elf_ia64_vms_tdata (abfd)->fixups_off;
+          elf_ia64_vms_tdata (abfd)->fixups_off = fixups_off;
+
+          if (!_bfd_elf_add_dynamic_entry
+              (info, DT_IA_64_VMS_FIXUP_RELA_CNT,
+               fixups_shl_off / sizeof (Elf64_External_VMS_IMAGE_FIXUP)))
+            return FALSE;
+          if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_FIXUP_RELA_OFF,
+                                           fixups_off))
+            return FALSE;
+          fixups_off += fixups_shl_off;
+        }
+
+      /* Unwind.  */
+      if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_UNWINDSZ, 0))
+        return FALSE;
+      if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_UNWIND_CODSEG, 0))
+        return FALSE;
+      if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_UNWIND_INFOSEG, 0))
+        return FALSE;
+      if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_UNWIND_OFFSET, 0))
+        return FALSE;
+      if (!_bfd_elf_add_dynamic_entry (info, DT_IA_64_VMS_UNWIND_SEG, 0))
+        return FALSE;
+
+      if (!_bfd_elf_add_dynamic_entry (info, DT_NULL, 0xdead))
+            return FALSE;
+
+      /* Fix the strtab entries.  */
+      bed = get_elf_backend_data (hash_table->dynobj);
+
+      if (dynstrsec->size > 1)
+        dynstrsec->contents[0] = 0;
+      else
+        dynstrsec->size = 0;
+
+      /* Note: one 'spare' (ie DT_NULL) entry is added by
+         bfd_elf_size_dynsym_hash_dynstr.  */
+      dyn.d_tag = DT_IA_64_VMS_STRTAB_OFFSET;
+      dyn.d_un.d_val = dynsec->size /* + sizeof (Elf64_External_Dyn) */;
+      bed->s->swap_dyn_out (hash_table->dynobj, &dyn,
+                            dynsec->contents + strdyn_off);
+
+      dyn.d_tag = DT_STRSZ;
+      dyn.d_un.d_val = dynstrsec->size;
+      bed->s->swap_dyn_out (hash_table->dynobj, &dyn,
+                            dynsec->contents + strdyn_off + bed->s->sizeof_dyn);
+
+      elf_ia64_vms_tdata (output_bfd)->needed_count = shl_num;
+
+      /* Note section.  */
+      if (!create_ia64_vms_notes (output_bfd, info, time_hi, time_lo))
+        return FALSE;
+    }
+
+  /* ??? Perhaps force __gp local.  */
+
+  return TRUE;
+}
+
+static void
+elf64_ia64_install_fixup (bfd *output_bfd,
+                          struct elf64_ia64_link_hash_table *ia64_info,
+                          struct elf_link_hash_entry *h,
+                          unsigned int type, asection *sec, bfd_vma offset,
+                          bfd_vma addend)
+{
+  asection *relsec;
+  Elf64_External_VMS_IMAGE_FIXUP *fixup;
+  struct elf64_ia64_link_hash_entry *h_ia64;
+  bfd_vma fixoff;
+  Elf_Internal_Phdr *phdr;
+
+  if (h == NULL || !h->def_dynamic)
+    abort ();
+
+  h_ia64 = (struct elf64_ia64_link_hash_entry *) h;
+  fixoff = elf_ia64_vms_tdata (h_ia64->shl)->fixups_off;
+  elf_ia64_vms_tdata (h_ia64->shl)->fixups_off +=
+    sizeof (Elf64_External_VMS_IMAGE_FIXUP);
+  relsec = ia64_info->fixups_sec;
+
+  fixup = (Elf64_External_VMS_IMAGE_FIXUP *)(relsec->contents + fixoff);
+  offset += sec->output_section->vma + sec->output_offset;
+
+  /* FIXME: this is slow.  We should cache the last one used, or create a
+     map.  */
+  phdr = _bfd_elf_find_segment_containing_section
+    (output_bfd, sec->output_section);
+  BFD_ASSERT (phdr != NULL);
+
+  bfd_putl64 (offset - phdr->p_vaddr, fixup->fixup_offset);
+  bfd_putl32 (type, fixup->type);
+  bfd_putl32 (phdr - elf_tdata (output_bfd)->phdr, fixup->fixup_seg);
+  bfd_putl64 (addend, fixup->addend);
+  bfd_putl32 (h->root.u.def.value, fixup->symvec_index);
+  bfd_putl32 (2, fixup->data_type);
+}
+
+/* Store an entry for target address TARGET_ADDR in the linkage table
+   and return the gp-relative address of the linkage table entry.  */
+
+static bfd_vma
+set_got_entry (bfd *abfd, struct bfd_link_info *info,
+	       struct elf64_ia64_dyn_sym_info *dyn_i,
+	       bfd_vma addend, bfd_vma value, unsigned int dyn_r_type)
+{
+  struct elf64_ia64_link_hash_table *ia64_info;
+  asection *got_sec;
+  bfd_boolean done;
+  bfd_vma got_offset;
+
+  ia64_info = elf64_ia64_hash_table (info);
+  if (ia64_info == NULL)
+    return 0;
+
+  got_sec = ia64_info->root.sgot;
+
+  switch (dyn_r_type)
+    {
+    case R_IA64_TPREL64LSB:
+    case R_IA64_DTPMOD64LSB:
+    case R_IA64_DTPREL32LSB:
+    case R_IA64_DTPREL64LSB:
+      abort ();
+      break;
+    default:
+      done = dyn_i->got_done;
+      dyn_i->got_done = TRUE;
+      got_offset = dyn_i->got_offset;
+      break;
+    }
+
+  BFD_ASSERT ((got_offset & 7) == 0);
+
+  if (! done)
+    {
+      /* Store the target address in the linkage table entry.  */
+      bfd_put_64 (abfd, value, got_sec->contents + got_offset);
+
+      /* Install a dynamic relocation if needed.  */
+      if (((info->shared
+	    && (!dyn_i->h
+		|| ELF_ST_VISIBILITY (dyn_i->h->other) == STV_DEFAULT
+		|| dyn_i->h->root.type != bfd_link_hash_undefweak))
+           || elf64_ia64_dynamic_symbol_p (dyn_i->h))
+	  && (!dyn_i->want_ltoff_fptr
+	      || !info->pie
+	      || !dyn_i->h
+	      || dyn_i->h->root.type != bfd_link_hash_undefweak))
+	{
+	  if (!dyn_i->h || !dyn_i->h->def_dynamic)
+	    {
+	      dyn_r_type = R_IA64_REL64LSB;
+	      addend = value;
+	    }
+
+          /* VMS: install a FIX32 or FIX64.  */
+          switch (dyn_r_type)
+            {
+            case R_IA64_DIR32LSB:
+            case R_IA64_FPTR32LSB:
+              dyn_r_type = R_IA64_VMS_FIX32;
+              break;
+            case R_IA64_DIR64LSB:
+            case R_IA64_FPTR64LSB:
+              dyn_r_type = R_IA64_VMS_FIX64;
+              break;
+            default:
+              BFD_ASSERT (FALSE);
+              break;
+            }
+          elf64_ia64_install_fixup
+            (info->output_bfd, ia64_info, dyn_i->h,
+             dyn_r_type, got_sec, got_offset, addend);
+        }
+    }
+
+  /* Return the address of the linkage table entry.  */
+  value = (got_sec->output_section->vma
+	   + got_sec->output_offset
+	   + got_offset);
+
+  return value;
+}
+
+/* Fill in a function descriptor consisting of the function's code
+   address and its global pointer.  Return the descriptor's address.  */
+
+static bfd_vma
+set_fptr_entry (bfd *abfd, struct bfd_link_info *info,
+		struct elf64_ia64_dyn_sym_info *dyn_i,
+		bfd_vma value)
+{
+  struct elf64_ia64_link_hash_table *ia64_info;
+  asection *fptr_sec;
+
+  ia64_info = elf64_ia64_hash_table (info);
+  if (ia64_info == NULL)
+    return 0;
+
+  fptr_sec = ia64_info->fptr_sec;
+
+  if (!dyn_i->fptr_done)
+    {
+      dyn_i->fptr_done = 1;
+
+      /* Fill in the function descriptor.  */
+      bfd_put_64 (abfd, value, fptr_sec->contents + dyn_i->fptr_offset);
+      bfd_put_64 (abfd, _bfd_get_gp_value (abfd),
+		  fptr_sec->contents + dyn_i->fptr_offset + 8);
+    }
+
+  /* Return the descriptor's address.  */
+  value = (fptr_sec->output_section->vma
+	   + fptr_sec->output_offset
+	   + dyn_i->fptr_offset);
+
+  return value;
+}
+
+/* Fill in a PLTOFF entry consisting of the function's code address
+   and its global pointer.  Return the descriptor's address.  */
+
+static bfd_vma
+set_pltoff_entry (bfd *abfd, struct bfd_link_info *info,
+		  struct elf64_ia64_dyn_sym_info *dyn_i,
+		  bfd_vma value, bfd_boolean is_plt)
+{
+  struct elf64_ia64_link_hash_table *ia64_info;
+  asection *pltoff_sec;
+
+  ia64_info = elf64_ia64_hash_table (info);
+  if (ia64_info == NULL)
+    return 0;
+
+  pltoff_sec = ia64_info->pltoff_sec;
+
+  /* Don't do anything if this symbol uses a real PLT entry.  In
+     that case, we'll fill this in during finish_dynamic_symbol.  */
+  if ((! dyn_i->want_plt || is_plt)
+      && !dyn_i->pltoff_done)
+    {
+      bfd_vma gp = _bfd_get_gp_value (abfd);
+
+      /* Fill in the function descriptor.  */
+      bfd_put_64 (abfd, value, pltoff_sec->contents + dyn_i->pltoff_offset);
+      bfd_put_64 (abfd, gp, pltoff_sec->contents + dyn_i->pltoff_offset + 8);
+
+      /* Install dynamic relocations if needed.  */
+      if (!is_plt
+	  && info->shared
+	  && (!dyn_i->h
+	      || ELF_ST_VISIBILITY (dyn_i->h->other) == STV_DEFAULT
+	      || dyn_i->h->root.type != bfd_link_hash_undefweak))
+	{
+          /* VMS:  */
+          abort ();
+	}
+
+      dyn_i->pltoff_done = 1;
+    }
+
+  /* Return the descriptor's address.  */
+  value = (pltoff_sec->output_section->vma
+	   + pltoff_sec->output_offset
+	   + dyn_i->pltoff_offset);
+
+  return value;
+}
+
+/* Called through qsort to sort the .IA_64.unwind section during a
+   non-relocatable link.  Set elf64_ia64_unwind_entry_compare_bfd
+   to the output bfd so we can do proper endianness frobbing.  */
+
+static bfd *elf64_ia64_unwind_entry_compare_bfd;
+
+static int
+elf64_ia64_unwind_entry_compare (const void * a, const void * b)
+{
+  bfd_vma av, bv;
+
+  av = bfd_get_64 (elf64_ia64_unwind_entry_compare_bfd, a);
+  bv = bfd_get_64 (elf64_ia64_unwind_entry_compare_bfd, b);
+
+  return (av < bv ? -1 : av > bv ? 1 : 0);
+}
+
+/* Make sure we've got ourselves a nice fat __gp value.  */
+static bfd_boolean
+elf64_ia64_choose_gp (bfd *abfd, struct bfd_link_info *info, bfd_boolean final)
+{
+  bfd_vma min_vma = (bfd_vma) -1, max_vma = 0;
+  bfd_vma min_short_vma = min_vma, max_short_vma = 0;
+  struct elf_link_hash_entry *gp;
+  bfd_vma gp_val;
+  asection *os;
+  struct elf64_ia64_link_hash_table *ia64_info;
+
+  ia64_info = elf64_ia64_hash_table (info);
+  if (ia64_info == NULL)
+    return FALSE;
+
+  /* Find the min and max vma of all sections marked short.  Also collect
+     min and max vma of any type, for use in selecting a nice gp.  */
+  for (os = abfd->sections; os ; os = os->next)
+    {
+      bfd_vma lo, hi;
+
+      if ((os->flags & SEC_ALLOC) == 0)
+	continue;
+
+      lo = os->vma;
+      /* When this function is called from elfNN_ia64_final_link
+	 the correct value to use is os->size.  When called from
+	 elfNN_ia64_relax_section we are in the middle of section
+	 sizing; some sections will already have os->size set, others
+	 will have os->size zero and os->rawsize the previous size.  */
+      hi = os->vma + (!final && os->rawsize ? os->rawsize : os->size);
+      if (hi < lo)
+	hi = (bfd_vma) -1;
+
+      if (min_vma > lo)
+	min_vma = lo;
+      if (max_vma < hi)
+	max_vma = hi;
+      if (os->flags & SEC_SMALL_DATA)
+	{
+	  if (min_short_vma > lo)
+	    min_short_vma = lo;
+	  if (max_short_vma < hi)
+	    max_short_vma = hi;
+	}
+    }
+
+  if (ia64_info->min_short_sec)
+    {
+      if (min_short_vma
+	  > (ia64_info->min_short_sec->vma
+	     + ia64_info->min_short_offset))
+	min_short_vma = (ia64_info->min_short_sec->vma
+			 + ia64_info->min_short_offset);
+      if (max_short_vma
+	  < (ia64_info->max_short_sec->vma
+	     + ia64_info->max_short_offset))
+	max_short_vma = (ia64_info->max_short_sec->vma
+			 + ia64_info->max_short_offset);
+    }
+
+  /* See if the user wants to force a value.  */
+  gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", FALSE,
+			     FALSE, FALSE);
+
+  if (gp
+      && (gp->root.type == bfd_link_hash_defined
+	  || gp->root.type == bfd_link_hash_defweak))
+    {
+      asection *gp_sec = gp->root.u.def.section;
+      gp_val = (gp->root.u.def.value
+		+ gp_sec->output_section->vma
+		+ gp_sec->output_offset);
+    }
+  else
+    {
+      /* Pick a sensible value.  */
+
+      if (ia64_info->min_short_sec)
+	{
+	  bfd_vma short_range = max_short_vma - min_short_vma;
+
+	  /* If min_short_sec is set, pick one in the middle bewteen
+	     min_short_vma and max_short_vma.  */
+	  if (short_range >= 0x400000)
+	    goto overflow;
+	  gp_val = min_short_vma + short_range / 2;
+	}
+      else
+	{
+	  asection *got_sec = ia64_info->root.sgot;
+
+	  /* Start with just the address of the .got.  */
+	  if (got_sec)
+	    gp_val = got_sec->output_section->vma;
+	  else if (max_short_vma != 0)
+	    gp_val = min_short_vma;
+	  else if (max_vma - min_vma < 0x200000)
+	    gp_val = min_vma;
+	  else
+	    gp_val = max_vma - 0x200000 + 8;
+	}
+
+      /* If it is possible to address the entire image, but we
+	 don't with the choice above, adjust.  */
+      if (max_vma - min_vma < 0x400000
+	  && (max_vma - gp_val >= 0x200000
+	      || gp_val - min_vma > 0x200000))
+	gp_val = min_vma + 0x200000;
+      else if (max_short_vma != 0)
+	{
+	  /* If we don't cover all the short data, adjust.  */
+	  if (max_short_vma - gp_val >= 0x200000)
+	    gp_val = min_short_vma + 0x200000;
+
+	  /* If we're addressing stuff past the end, adjust back.  */
+	  if (gp_val > max_vma)
+	    gp_val = max_vma - 0x200000 + 8;
+	}
+    }
+
+  /* Validate whether all SHF_IA_64_SHORT sections are within
+     range of the chosen GP.  */
+
+  if (max_short_vma != 0)
+    {
+      if (max_short_vma - min_short_vma >= 0x400000)
+	{
+overflow:
+	  (*_bfd_error_handler)
+	    (_("%s: short data segment overflowed (0x%lx >= 0x400000)"),
+	     bfd_get_filename (abfd),
+	     (unsigned long) (max_short_vma - min_short_vma));
+	  return FALSE;
+	}
+      else if ((gp_val > min_short_vma
+		&& gp_val - min_short_vma > 0x200000)
+	       || (gp_val < max_short_vma
+		   && max_short_vma - gp_val >= 0x200000))
+	{
+	  (*_bfd_error_handler)
+	    (_("%s: __gp does not cover short data segment"),
+	     bfd_get_filename (abfd));
+	  return FALSE;
+	}
+    }
+
+  _bfd_set_gp_value (abfd, gp_val);
+
+  return TRUE;
+}
+
+static bfd_boolean
+elf64_ia64_final_link (bfd *abfd, struct bfd_link_info *info)
+{
+  struct elf64_ia64_link_hash_table *ia64_info;
+  asection *unwind_output_sec;
+
+  ia64_info = elf64_ia64_hash_table (info);
+  if (ia64_info == NULL)
+    return FALSE;
+
+  /* Make sure we've got ourselves a nice fat __gp value.  */
+  if (!info->relocatable)
+    {
+      bfd_vma gp_val;
+      struct elf_link_hash_entry *gp;
+
+      /* We assume after gp is set, section size will only decrease. We
+	 need to adjust gp for it.  */
+      _bfd_set_gp_value (abfd, 0);
+      if (! elf64_ia64_choose_gp (abfd, info, TRUE))
+	return FALSE;
+      gp_val = _bfd_get_gp_value (abfd);
+
+      gp = elf_link_hash_lookup (elf_hash_table (info), "__gp", FALSE,
+			         FALSE, FALSE);
+      if (gp)
+	{
+	  gp->root.type = bfd_link_hash_defined;
+	  gp->root.u.def.value = gp_val;
+	  gp->root.u.def.section = bfd_abs_section_ptr;
+	}
+    }
+
+  /* If we're producing a final executable, we need to sort the contents
+     of the .IA_64.unwind section.  Force this section to be relocated
+     into memory rather than written immediately to the output file.  */
+  unwind_output_sec = NULL;
+  if (!info->relocatable)
+    {
+      asection *s = bfd_get_section_by_name (abfd, ELF_STRING_ia64_unwind);
+      if (s)
+	{
+	  unwind_output_sec = s->output_section;
+	  unwind_output_sec->contents
+	    = bfd_malloc (unwind_output_sec->size);
+	  if (unwind_output_sec->contents == NULL)
+	    return FALSE;
+	}
+    }
+
+  /* Invoke the regular ELF backend linker to do all the work.  */
+  if (!bfd_elf_final_link (abfd, info))
+    return FALSE;
+
+  if (unwind_output_sec)
+    {
+      elf64_ia64_unwind_entry_compare_bfd = abfd;
+      qsort (unwind_output_sec->contents,
+	     (size_t) (unwind_output_sec->size / 24),
+	     24,
+	     elf64_ia64_unwind_entry_compare);
+
+      if (! bfd_set_section_contents (abfd, unwind_output_sec,
+				      unwind_output_sec->contents, (bfd_vma) 0,
+				      unwind_output_sec->size))
+	return FALSE;
+    }
+
+  return TRUE;
+}
+
+static bfd_boolean
+elf64_ia64_relocate_section (bfd *output_bfd,
+			     struct bfd_link_info *info,
+			     bfd *input_bfd,
+			     asection *input_section,
+			     bfd_byte *contents,
+			     Elf_Internal_Rela *relocs,
+			     Elf_Internal_Sym *local_syms,
+			     asection **local_sections)
+{
+  struct elf64_ia64_link_hash_table *ia64_info;
+  Elf_Internal_Shdr *symtab_hdr;
+  Elf_Internal_Rela *rel;
+  Elf_Internal_Rela *relend;
+  bfd_boolean ret_val = TRUE;	/* for non-fatal errors */
+  bfd_vma gp_val;
+
+  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+  ia64_info = elf64_ia64_hash_table (info);
+  if (ia64_info == NULL)
+    return FALSE;
+
+  /* Infect various flags from the input section to the output section.  */
+  if (info->relocatable)
+    {
+      bfd_vma flags;
+
+      flags = elf_section_data(input_section)->this_hdr.sh_flags;
+      flags &= SHF_IA_64_NORECOV;
+
+      elf_section_data(input_section->output_section)
+	->this_hdr.sh_flags |= flags;
+    }
+
+  gp_val = _bfd_get_gp_value (output_bfd);
+
+  rel = relocs;
+  relend = relocs + input_section->reloc_count;
+  for (; rel < relend; ++rel)
+    {
+      struct elf_link_hash_entry *h;
+      struct elf64_ia64_dyn_sym_info *dyn_i;
+      bfd_reloc_status_type r;
+      reloc_howto_type *howto;
+      unsigned long r_symndx;
+      Elf_Internal_Sym *sym;
+      unsigned int r_type;
+      bfd_vma value;
+      asection *sym_sec;
+      bfd_byte *hit_addr;
+      bfd_boolean dynamic_symbol_p;
+      bfd_boolean undef_weak_ref;
+
+      r_type = ELF64_R_TYPE (rel->r_info);
+      if (r_type > R_IA64_MAX_RELOC_CODE)
+	{
+	  (*_bfd_error_handler)
+	    (_("%B: unknown relocation type %d"),
+	     input_bfd, (int) r_type);
+	  bfd_set_error (bfd_error_bad_value);
+	  ret_val = FALSE;
+	  continue;
+	}
+
+      howto = ia64_elf_lookup_howto (r_type);
+      r_symndx = ELF64_R_SYM (rel->r_info);
+      h = NULL;
+      sym = NULL;
+      sym_sec = NULL;
+      undef_weak_ref = FALSE;
+
+      if (r_symndx < symtab_hdr->sh_info)
+	{
+	  /* Reloc against local symbol.  */
+	  asection *msec;
+	  sym = local_syms + r_symndx;
+	  sym_sec = local_sections[r_symndx];
+	  msec = sym_sec;
+	  value = _bfd_elf_rela_local_sym (output_bfd, sym, &msec, rel);
+	  if (!info->relocatable
+	      && (sym_sec->flags & SEC_MERGE) != 0
+	      && ELF_ST_TYPE (sym->st_info) == STT_SECTION
+	      && sym_sec->sec_info_type == SEC_INFO_TYPE_MERGE)
+	    {
+	      struct elf64_ia64_local_hash_entry *loc_h;
+
+	      loc_h = get_local_sym_hash (ia64_info, input_bfd, rel, FALSE);
+	      if (loc_h && ! loc_h->sec_merge_done)
+		{
+		  struct elf64_ia64_dyn_sym_info *dynent;
+		  unsigned int count;
+
+		  for (count = loc_h->count, dynent = loc_h->info;
+		       count != 0;
+		       count--, dynent++)
+		    {
+		      msec = sym_sec;
+		      dynent->addend =
+			_bfd_merged_section_offset (output_bfd, &msec,
+						    elf_section_data (msec)->
+						    sec_info,
+						    sym->st_value
+						    + dynent->addend);
+		      dynent->addend -= sym->st_value;
+		      dynent->addend += msec->output_section->vma
+					+ msec->output_offset
+					- sym_sec->output_section->vma
+					- sym_sec->output_offset;
+		    }
+
+		  /* We may have introduced duplicated entries. We need
+		     to remove them properly.  */
+		  count = sort_dyn_sym_info (loc_h->info, loc_h->count);
+		  if (count != loc_h->count)
+		    {
+		      loc_h->count = count;
+		      loc_h->sorted_count = count;
+		    }
+
+		  loc_h->sec_merge_done = 1;
+		}
+	    }
+	}
+      else
+	{
+	  bfd_boolean unresolved_reloc;
+	  bfd_boolean warned;
+	  struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
+
+	  RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
+				   r_symndx, symtab_hdr, sym_hashes,
+				   h, sym_sec, value,
+				   unresolved_reloc, warned);
+
+	  if (h->root.type == bfd_link_hash_undefweak)
+	    undef_weak_ref = TRUE;
+	  else if (warned)
+	    continue;
+	}
+
+      /* For relocs against symbols from removed linkonce sections,
+	 or sections discarded by a linker script, we just want the
+	 section contents zeroed.  Avoid any special processing.  */
+      if (sym_sec != NULL && discarded_section (sym_sec))
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, 1, relend, howto, 0, contents);
+
+      if (info->relocatable)
+	continue;
+
+      hit_addr = contents + rel->r_offset;
+      value += rel->r_addend;
+      dynamic_symbol_p = elf64_ia64_dynamic_symbol_p (h);
+
+      switch (r_type)
+	{
+	case R_IA64_NONE:
+	case R_IA64_LDXMOV:
+	  continue;
+
+	case R_IA64_IMM14:
+	case R_IA64_IMM22:
+	case R_IA64_IMM64:
+	case R_IA64_DIR32MSB:
+	case R_IA64_DIR32LSB:
+	case R_IA64_DIR64MSB:
+	case R_IA64_DIR64LSB:
+	  /* Install a dynamic relocation for this reloc.  */
+	  if ((dynamic_symbol_p || info->shared)
+	      && r_symndx != 0
+	      && (input_section->flags & SEC_ALLOC) != 0)
+	    {
+	      unsigned int dyn_r_type;
+	      bfd_vma addend;
+
+	      switch (r_type)
+		{
+		case R_IA64_IMM14:
+		case R_IA64_IMM22:
+		case R_IA64_IMM64:
+		  /* ??? People shouldn't be doing non-pic code in
+		     shared libraries nor dynamic executables.  */
+		  (*_bfd_error_handler)
+		    (_("%B: non-pic code with imm relocation against dynamic symbol `%s'"),
+		     input_bfd,
+		     h ? h->root.root.string
+		       : bfd_elf_sym_name (input_bfd, symtab_hdr, sym,
+					   sym_sec));
+		  ret_val = FALSE;
+		  continue;
+
+		default:
+		  break;
+		}
+
+	      /* If we don't need dynamic symbol lookup, find a
+		 matching RELATIVE relocation.  */
+	      dyn_r_type = r_type;
+	      if (dynamic_symbol_p)
+		{
+		  addend = rel->r_addend;
+		  value = 0;
+		}
+	      else
+		{
+		  addend = value;
+		}
+
+              /* VMS: install a FIX64.  */
+              switch (dyn_r_type)
+                {
+                case R_IA64_DIR32LSB:
+                  dyn_r_type = R_IA64_VMS_FIX32;
+                  break;
+                case R_IA64_DIR64LSB:
+                  dyn_r_type = R_IA64_VMS_FIX64;
+                  break;
+                default:
+                  BFD_ASSERT (FALSE);
+                  break;
+                }
+              elf64_ia64_install_fixup
+                (output_bfd, ia64_info, h,
+                 dyn_r_type, input_section, rel->r_offset, addend);
+              r = bfd_reloc_ok;
+              break;
+	    }
+	  /* Fall through.  */
+
+	case R_IA64_LTV32MSB:
+	case R_IA64_LTV32LSB:
+	case R_IA64_LTV64MSB:
+	case R_IA64_LTV64LSB:
+	  r = ia64_elf_install_value (hit_addr, value, r_type);
+	  break;
+
+	case R_IA64_GPREL22:
+	case R_IA64_GPREL64I:
+	case R_IA64_GPREL32MSB:
+	case R_IA64_GPREL32LSB:
+	case R_IA64_GPREL64MSB:
+	case R_IA64_GPREL64LSB:
+	  if (dynamic_symbol_p)
+	    {
+	      (*_bfd_error_handler)
+		(_("%B: @gprel relocation against dynamic symbol %s"),
+		 input_bfd,
+		 h ? h->root.root.string
+		   : bfd_elf_sym_name (input_bfd, symtab_hdr, sym,
+				       sym_sec));
+	      ret_val = FALSE;
+	      continue;
+	    }
+	  value -= gp_val;
+	  r = ia64_elf_install_value (hit_addr, value, r_type);
+	  break;
+
+	case R_IA64_LTOFF22:
+	case R_IA64_LTOFF22X:
+	case R_IA64_LTOFF64I:
+          dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
+	  value = set_got_entry (input_bfd, info, dyn_i,
+				 rel->r_addend, value, R_IA64_DIR64LSB);
+	  value -= gp_val;
+	  r = ia64_elf_install_value (hit_addr, value, r_type);
+	  break;
+
+	case R_IA64_PLTOFF22:
+	case R_IA64_PLTOFF64I:
+	case R_IA64_PLTOFF64MSB:
+	case R_IA64_PLTOFF64LSB:
+          dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
+	  value = set_pltoff_entry (output_bfd, info, dyn_i, value, FALSE);
+	  value -= gp_val;
+	  r = ia64_elf_install_value (hit_addr, value, r_type);
+	  break;
+
+	case R_IA64_FPTR64I:
+	case R_IA64_FPTR32MSB:
+	case R_IA64_FPTR32LSB:
+	case R_IA64_FPTR64MSB:
+	case R_IA64_FPTR64LSB:
+          dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
+	  if (dyn_i->want_fptr)
+	    {
+	      if (!undef_weak_ref)
+		value = set_fptr_entry (output_bfd, info, dyn_i, value);
+	    }
+	  if (!dyn_i->want_fptr || info->pie)
+	    {
+	      /* Otherwise, we expect the dynamic linker to create
+		 the entry.  */
+
+	      if (dyn_i->want_fptr)
+		{
+		  if (r_type == R_IA64_FPTR64I)
+		    {
+		      /* We can't represent this without a dynamic symbol.
+			 Adjust the relocation to be against an output
+			 section symbol, which are always present in the
+			 dynamic symbol table.  */
+		      /* ??? People shouldn't be doing non-pic code in
+			 shared libraries.  Hork.  */
+		      (*_bfd_error_handler)
+			(_("%B: linking non-pic code in a position independent executable"),
+			 input_bfd);
+		      ret_val = FALSE;
+		      continue;
+		    }
+		}
+	      else
+		{
+		  value = 0;
+		}
+
+              /* VMS: FIXFD.  */
+              elf64_ia64_install_fixup
+                (output_bfd, ia64_info, h, R_IA64_VMS_FIXFD,
+                 input_section, rel->r_offset, 0);
+              r = bfd_reloc_ok;
+              break;
+	    }
+
+	  r = ia64_elf_install_value (hit_addr, value, r_type);
+	  break;
+
+	case R_IA64_LTOFF_FPTR22:
+	case R_IA64_LTOFF_FPTR64I:
+	case R_IA64_LTOFF_FPTR32MSB:
+	case R_IA64_LTOFF_FPTR32LSB:
+	case R_IA64_LTOFF_FPTR64MSB:
+	case R_IA64_LTOFF_FPTR64LSB:
+          dyn_i = get_dyn_sym_info (ia64_info, h, input_bfd, rel, FALSE);
+          if (dyn_i->want_fptr)
+            {
+              BFD_ASSERT (h == NULL || !h->def_dynamic);
+              if (!undef_weak_ref)
+                value = set_fptr_entry (output_bfd, info, dyn_i, value);
+            }
+          else
+            value = 0;
+
+          value = set_got_entry (output_bfd, info, dyn_i,
+                                 rel->r_addend, value, R_IA64_FPTR64LSB);
+          value -= gp_val;
+          r = ia64_elf_install_value (hit_addr, value, r_type);
+	  break;
+
+	case R_IA64_PCREL32MSB:
+	case R_IA64_PCREL32LSB:
+	case R_IA64_PCREL64MSB:
+	case R_IA64_PCREL64LSB:
+	  /* Install a dynamic relocation for this reloc.  */
+	  if (dynamic_symbol_p && r_symndx != 0)
+	    {
+              /* VMS: doesn't exist ???  */
+              abort ();
+	    }
+	  goto finish_pcrel;
+
+	case R_IA64_PCREL21B:
+	case R_IA64_PCREL60B:
+	  /* We should have created a PLT entry for any dynamic symbol.  */
+	  dyn_i = NULL;
+	  if (h)
+	    dyn_i = get_dyn_sym_info (ia64_info, h, NULL, NULL, FALSE);
+
+	  if (dyn_i && dyn_i->want_plt2)
+	    {
+	      /* Should have caught this earlier.  */
+	      BFD_ASSERT (rel->r_addend == 0);
+
+	      value = (ia64_info->root.splt->output_section->vma
+		       + ia64_info->root.splt->output_offset
+		       + dyn_i->plt2_offset);
+	    }
+	  else
+	    {
+	      /* Since there's no PLT entry, Validate that this is
+		 locally defined.  */
+	      BFD_ASSERT (undef_weak_ref || sym_sec->output_section != NULL);
+
+	      /* If the symbol is undef_weak, we shouldn't be trying
+		 to call it.  There's every chance that we'd wind up
+		 with an out-of-range fixup here.  Don't bother setting
+		 any value at all.  */
+	      if (undef_weak_ref)
+		continue;
+	    }
+	  goto finish_pcrel;
+
+	case R_IA64_PCREL21BI:
+	case R_IA64_PCREL21F:
+	case R_IA64_PCREL21M:
+	case R_IA64_PCREL22:
+	case R_IA64_PCREL64I:
+	  /* The PCREL21BI reloc is specifically not intended for use with
+	     dynamic relocs.  PCREL21F and PCREL21M are used for speculation
+	     fixup code, and thus probably ought not be dynamic.  The
+	     PCREL22 and PCREL64I relocs aren't emitted as dynamic relocs.  */
+	  if (dynamic_symbol_p)
+	    {
+	      const char *msg;
+
+	      if (r_type == R_IA64_PCREL21BI)
+		msg = _("%B: @internal branch to dynamic symbol %s");
+	      else if (r_type == R_IA64_PCREL21F || r_type == R_IA64_PCREL21M)
+		msg = _("%B: speculation fixup to dynamic symbol %s");
+	      else
+		msg = _("%B: @pcrel relocation against dynamic symbol %s");
+	      (*_bfd_error_handler) (msg, input_bfd,
+				     h ? h->root.root.string
+				       : bfd_elf_sym_name (input_bfd,
+							   symtab_hdr,
+							   sym,
+							   sym_sec));
+	      ret_val = FALSE;
+	      continue;
+	    }
+	  goto finish_pcrel;
+
+	finish_pcrel:
+	  /* Make pc-relative.  */
+	  value -= (input_section->output_section->vma
+		    + input_section->output_offset
+		    + rel->r_offset) & ~ (bfd_vma) 0x3;
+	  r = ia64_elf_install_value (hit_addr, value, r_type);
+	  break;
+
+	case R_IA64_SEGREL32MSB:
+	case R_IA64_SEGREL32LSB:
+	case R_IA64_SEGREL64MSB:
+	case R_IA64_SEGREL64LSB:
+	    {
+	      /* Find the segment that contains the output_section.  */
+	      Elf_Internal_Phdr *p = _bfd_elf_find_segment_containing_section
+		(output_bfd, sym_sec->output_section);
+
+	      if (p == NULL)
+		{
+		  r = bfd_reloc_notsupported;
+		}
+	      else
+		{
+		  /* The VMA of the segment is the vaddr of the associated
+		     program header.  */
+		  if (value > p->p_vaddr)
+		    value -= p->p_vaddr;
+		  else
+		    value = 0;
+		  r = ia64_elf_install_value (hit_addr, value, r_type);
+		}
+	      break;
+	    }
+
+	case R_IA64_SECREL32MSB:
+	case R_IA64_SECREL32LSB:
+	case R_IA64_SECREL64MSB:
+	case R_IA64_SECREL64LSB:
+	  /* Make output-section relative to section where the symbol
+	     is defined. PR 475  */
+	  if (sym_sec)
+	    value -= sym_sec->output_section->vma;
+	  r = ia64_elf_install_value (hit_addr, value, r_type);
+	  break;
+
+	case R_IA64_IPLTMSB:
+	case R_IA64_IPLTLSB:
+	  /* Install a dynamic relocation for this reloc.  */
+	  if ((dynamic_symbol_p || info->shared)
+	      && (input_section->flags & SEC_ALLOC) != 0)
+	    {
+              /* VMS: FIXFD ??  */
+              abort ();
+	    }
+
+	  if (r_type == R_IA64_IPLTMSB)
+	    r_type = R_IA64_DIR64MSB;
+	  else
+	    r_type = R_IA64_DIR64LSB;
+	  ia64_elf_install_value (hit_addr, value, r_type);
+	  r = ia64_elf_install_value (hit_addr + 8, gp_val, r_type);
+	  break;
+
+	case R_IA64_TPREL14:
+	case R_IA64_TPREL22:
+	case R_IA64_TPREL64I:
+	  r = bfd_reloc_notsupported;
+	  break;
+
+	case R_IA64_DTPREL14:
+	case R_IA64_DTPREL22:
+	case R_IA64_DTPREL64I:
+	case R_IA64_DTPREL32LSB:
+	case R_IA64_DTPREL32MSB:
+	case R_IA64_DTPREL64LSB:
+	case R_IA64_DTPREL64MSB:
+	  r = bfd_reloc_notsupported;
+	  break;
+
+	case R_IA64_LTOFF_TPREL22:
+	case R_IA64_LTOFF_DTPMOD22:
+	case R_IA64_LTOFF_DTPREL22:
+	  r = bfd_reloc_notsupported;
+	  break;
+
+	default:
+	  r = bfd_reloc_notsupported;
+	  break;
+	}
+
+      switch (r)
+	{
+	case bfd_reloc_ok:
+	  break;
+
+	case bfd_reloc_undefined:
+	  /* This can happen for global table relative relocs if
+	     __gp is undefined.  This is a panic situation so we
+	     don't try to continue.  */
+	  (*info->callbacks->undefined_symbol)
+	    (info, "__gp", input_bfd, input_section, rel->r_offset, 1);
+	  return FALSE;
+
+	case bfd_reloc_notsupported:
+	  {
+	    const char *name;
+
+	    if (h)
+	      name = h->root.root.string;
+	    else
+	      name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym,
+				       sym_sec);
+	    if (!(*info->callbacks->warning) (info, _("unsupported reloc"),
+					      name, input_bfd,
+					      input_section, rel->r_offset))
+	      return FALSE;
+	    ret_val = FALSE;
+	  }
+	  break;
+
+	case bfd_reloc_dangerous:
+	case bfd_reloc_outofrange:
+	case bfd_reloc_overflow:
+	default:
+	  {
+	    const char *name;
+
+	    if (h)
+	      name = h->root.root.string;
+	    else
+	      name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym,
+				       sym_sec);
+
+	    switch (r_type)
+	      {
+	      case R_IA64_TPREL14:
+	      case R_IA64_TPREL22:
+	      case R_IA64_TPREL64I:
+	      case R_IA64_DTPREL14:
+	      case R_IA64_DTPREL22:
+	      case R_IA64_DTPREL64I:
+	      case R_IA64_DTPREL32LSB:
+	      case R_IA64_DTPREL32MSB:
+	      case R_IA64_DTPREL64LSB:
+	      case R_IA64_DTPREL64MSB:
+	      case R_IA64_LTOFF_TPREL22:
+	      case R_IA64_LTOFF_DTPMOD22:
+	      case R_IA64_LTOFF_DTPREL22:
+		(*_bfd_error_handler)
+		  (_("%B: missing TLS section for relocation %s against `%s' at 0x%lx in section `%A'."),
+		   input_bfd, input_section, howto->name, name,
+		   rel->r_offset);
+		break;
+
+	      case R_IA64_PCREL21B:
+	      case R_IA64_PCREL21BI:
+	      case R_IA64_PCREL21M:
+	      case R_IA64_PCREL21F:
+		if (is_elf_hash_table (info->hash))
+		  {
+		    /* Relaxtion is always performed for ELF output.
+		       Overflow failures for those relocations mean
+		       that the section is too big to relax.  */
+		    (*_bfd_error_handler)
+		      (_("%B: Can't relax br (%s) to `%s' at 0x%lx in section `%A' with size 0x%lx (> 0x1000000)."),
+		       input_bfd, input_section, howto->name, name,
+		       rel->r_offset, input_section->size);
+		    break;
+		  }
+	      default:
+		if (!(*info->callbacks->reloc_overflow) (info,
+							 &h->root,
+							 name,
+							 howto->name,
+							 (bfd_vma) 0,
+							 input_bfd,
+							 input_section,
+							 rel->r_offset))
+		  return FALSE;
+		break;
+	      }
+
+	    ret_val = FALSE;
+	  }
+	  break;
+	}
+    }
+
+  return ret_val;
+}
+
+static bfd_boolean
+elf64_ia64_finish_dynamic_symbol (bfd *output_bfd,
+				  struct bfd_link_info *info,
+				  struct elf_link_hash_entry *h,
+				  Elf_Internal_Sym *sym)
+{
+  struct elf64_ia64_link_hash_table *ia64_info;
+  struct elf64_ia64_dyn_sym_info *dyn_i;
+
+  ia64_info = elf64_ia64_hash_table (info);
+  if (ia64_info == NULL)
+    return FALSE;
+
+  dyn_i = get_dyn_sym_info (ia64_info, h, NULL, NULL, FALSE);
+
+  /* Fill in the PLT data, if required.  */
+  if (dyn_i && dyn_i->want_plt)
+    {
+      bfd_byte *loc;
+      asection *plt_sec;
+      bfd_vma plt_addr, pltoff_addr, gp_val;
+
+      gp_val = _bfd_get_gp_value (output_bfd);
+
+      plt_sec = ia64_info->root.splt;
+      plt_addr = 0;  /* Not used as overriden by FIXUPs.  */
+      pltoff_addr = set_pltoff_entry (output_bfd, info, dyn_i, plt_addr, TRUE);
+
+      /* Initialize the FULL PLT entry, if needed.  */
+      if (dyn_i->want_plt2)
+	{
+	  loc = plt_sec->contents + dyn_i->plt2_offset;
+
+	  memcpy (loc, plt_full_entry, PLT_FULL_ENTRY_SIZE);
+	  ia64_elf_install_value (loc, pltoff_addr - gp_val, R_IA64_IMM22);
+
+	  /* Mark the symbol as undefined, rather than as defined in the
+	     plt section.  Leave the value alone.  */
+	  /* ??? We didn't redefine it in adjust_dynamic_symbol in the
+	     first place.  But perhaps elflink.c did some for us.  */
+	  if (!h->def_regular)
+	    sym->st_shndx = SHN_UNDEF;
+	}
+
+      /* VMS: FIXFD.  */
+      elf64_ia64_install_fixup
+        (output_bfd, ia64_info, h, R_IA64_VMS_FIXFD, ia64_info->pltoff_sec,
+         pltoff_addr - (ia64_info->pltoff_sec->output_section->vma
+                        + ia64_info->pltoff_sec->output_offset), 0);
+    }
+
+  /* Mark some specially defined symbols as absolute.  */
+  if (h == ia64_info->root.hdynamic
+      || h == ia64_info->root.hgot
+      || h == ia64_info->root.hplt)
+    sym->st_shndx = SHN_ABS;
+
+  return TRUE;
+}
+
+static bfd_boolean
+elf64_ia64_finish_dynamic_sections (bfd *abfd,
+				    struct bfd_link_info *info)
+{
+  struct elf64_ia64_link_hash_table *ia64_info;
+  bfd *dynobj;
+
+  ia64_info = elf64_ia64_hash_table (info);
+  if (ia64_info == NULL)
+    return FALSE;
+
+  dynobj = ia64_info->root.dynobj;
+
+  if (elf_hash_table (info)->dynamic_sections_created)
+    {
+      Elf64_External_Dyn *dyncon, *dynconend;
+      asection *sdyn;
+      asection *unwind_sec;
+      bfd_vma gp_val;
+      unsigned int gp_seg;
+      bfd_vma gp_off;
+      Elf_Internal_Phdr *phdr;
+      Elf_Internal_Phdr *base_phdr;
+      unsigned int unwind_seg = 0;
+      unsigned int code_seg = 0;
+
+      sdyn = bfd_get_linker_section (dynobj, ".dynamic");
+      BFD_ASSERT (sdyn != NULL);
+      dyncon = (Elf64_External_Dyn *) sdyn->contents;
+      dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->size);
+
+      gp_val = _bfd_get_gp_value (abfd);
+      phdr = _bfd_elf_find_segment_containing_section
+        (info->output_bfd, ia64_info->pltoff_sec->output_section);
+      BFD_ASSERT (phdr != NULL);
+      base_phdr = elf_tdata (info->output_bfd)->phdr;
+      gp_seg = phdr - base_phdr;
+      gp_off = gp_val - phdr->p_vaddr;
+
+      unwind_sec = bfd_get_section_by_name (abfd, ELF_STRING_ia64_unwind);
+      if (unwind_sec != NULL)
+        {
+          asection *code_sec;
+
+          phdr = _bfd_elf_find_segment_containing_section (abfd, unwind_sec);
+          BFD_ASSERT (phdr != NULL);
+          unwind_seg = phdr - base_phdr;
+
+          code_sec = bfd_get_section_by_name (abfd, "$CODE$");
+          phdr = _bfd_elf_find_segment_containing_section (abfd, code_sec);
+          BFD_ASSERT (phdr != NULL);
+          code_seg = phdr - base_phdr;
+        }
+
+      for (; dyncon < dynconend; dyncon++)
+	{
+	  Elf_Internal_Dyn dyn;
+
+	  bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn);
+
+	  switch (dyn.d_tag)
+	    {
+            case DT_IA_64_VMS_FIXUP_RELA_OFF:
+              dyn.d_un.d_val +=
+                (ia64_info->fixups_sec->output_section->vma
+                 + ia64_info->fixups_sec->output_offset)
+                - (sdyn->output_section->vma + sdyn->output_offset);
+              break;
+
+            case DT_IA_64_VMS_PLTGOT_OFFSET:
+              dyn.d_un.d_val = gp_off;
+              break;
+
+            case DT_IA_64_VMS_PLTGOT_SEG:
+              dyn.d_un.d_val = gp_seg;
+              break;
+
+            case DT_IA_64_VMS_UNWINDSZ:
+              if (unwind_sec == NULL)
+                {
+                  dyn.d_tag = DT_NULL;
+                  dyn.d_un.d_val = 0xdead;
+                }
+              else
+                dyn.d_un.d_val = unwind_sec->size;
+              break;
+
+            case DT_IA_64_VMS_UNWIND_CODSEG:
+              dyn.d_un.d_val = code_seg;
+              break;
+
+            case DT_IA_64_VMS_UNWIND_INFOSEG:
+            case DT_IA_64_VMS_UNWIND_SEG:
+              dyn.d_un.d_val = unwind_seg;
+              break;
+
+            case DT_IA_64_VMS_UNWIND_OFFSET:
+              break;
+
+            default:
+              /* No need to rewrite the entry.  */
+              continue;
+	    }
+
+	  bfd_elf64_swap_dyn_out (abfd, &dyn, dyncon);
+	}
+    }
+
+  /* Handle transfer addresses.  */
+  {
+    asection *tfr_sec = ia64_info->transfer_sec;
+    struct elf64_vms_transfer *tfr;
+    struct elf_link_hash_entry *tfr3;
+
+    tfr = (struct elf64_vms_transfer *)tfr_sec->contents;
+    bfd_putl32 (6 * 8, tfr->size);
+    bfd_putl64 (tfr_sec->output_section->vma
+                + tfr_sec->output_offset
+                + 6 * 8, tfr->tfradr3);
+
+    tfr3 = elf_link_hash_lookup (elf_hash_table (info), "ELF$TFRADR", FALSE,
+                                 FALSE, FALSE);
+
+    if (tfr3
+        && (tfr3->root.type == bfd_link_hash_defined
+            || tfr3->root.type == bfd_link_hash_defweak))
+      {
+        asection *tfr3_sec = tfr3->root.u.def.section;
+        bfd_vma tfr3_val;
+
+        tfr3_val = (tfr3->root.u.def.value
+                    + tfr3_sec->output_section->vma
+                    + tfr3_sec->output_offset);
+
+        bfd_putl64 (tfr3_val, tfr->tfr3_func);
+        bfd_putl64 (_bfd_get_gp_value (info->output_bfd), tfr->tfr3_gp);
+      }
+
+    /* FIXME: set linker flags,
+       handle lib$initialize.  */
+  }
+
+  return TRUE;
+}
+
+/* ELF file flag handling:  */
+
+/* Function to keep IA-64 specific file flags.  */
+static bfd_boolean
+elf64_ia64_set_private_flags (bfd *abfd, flagword flags)
+{
+  BFD_ASSERT (!elf_flags_init (abfd)
+	      || elf_elfheader (abfd)->e_flags == flags);
+
+  elf_elfheader (abfd)->e_flags = flags;
+  elf_flags_init (abfd) = TRUE;
+  return TRUE;
+}
+
+/* Merge backend specific data from an object file to the output
+   object file when linking.  */
+static bfd_boolean
+elf64_ia64_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
+{
+  flagword out_flags;
+  flagword in_flags;
+  bfd_boolean ok = TRUE;
+
+  /* Don't even pretend to support mixed-format linking.  */
+  if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+    return FALSE;
+
+  in_flags  = elf_elfheader (ibfd)->e_flags;
+  out_flags = elf_elfheader (obfd)->e_flags;
+
+  if (! elf_flags_init (obfd))
+    {
+      elf_flags_init (obfd) = TRUE;
+      elf_elfheader (obfd)->e_flags = in_flags;
+
+      if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
+	  && bfd_get_arch_info (obfd)->the_default)
+	{
+	  return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd),
+				    bfd_get_mach (ibfd));
+	}
+
+      return TRUE;
+    }
+
+  /* Check flag compatibility.  */
+  if (in_flags == out_flags)
+    return TRUE;
+
+  /* Output has EF_IA_64_REDUCEDFP set only if all inputs have it set.  */
+  if (!(in_flags & EF_IA_64_REDUCEDFP) && (out_flags & EF_IA_64_REDUCEDFP))
+    elf_elfheader (obfd)->e_flags &= ~EF_IA_64_REDUCEDFP;
+
+  if ((in_flags & EF_IA_64_TRAPNIL) != (out_flags & EF_IA_64_TRAPNIL))
+    {
+      (*_bfd_error_handler)
+	(_("%B: linking trap-on-NULL-dereference with non-trapping files"),
+	 ibfd);
+
+      bfd_set_error (bfd_error_bad_value);
+      ok = FALSE;
+    }
+  if ((in_flags & EF_IA_64_BE) != (out_flags & EF_IA_64_BE))
+    {
+      (*_bfd_error_handler)
+	(_("%B: linking big-endian files with little-endian files"),
+	 ibfd);
+
+      bfd_set_error (bfd_error_bad_value);
+      ok = FALSE;
+    }
+  if ((in_flags & EF_IA_64_ABI64) != (out_flags & EF_IA_64_ABI64))
+    {
+      (*_bfd_error_handler)
+	(_("%B: linking 64-bit files with 32-bit files"),
+	 ibfd);
+
+      bfd_set_error (bfd_error_bad_value);
+      ok = FALSE;
+    }
+  if ((in_flags & EF_IA_64_CONS_GP) != (out_flags & EF_IA_64_CONS_GP))
+    {
+      (*_bfd_error_handler)
+	(_("%B: linking constant-gp files with non-constant-gp files"),
+	 ibfd);
+
+      bfd_set_error (bfd_error_bad_value);
+      ok = FALSE;
+    }
+  if ((in_flags & EF_IA_64_NOFUNCDESC_CONS_GP)
+      != (out_flags & EF_IA_64_NOFUNCDESC_CONS_GP))
+    {
+      (*_bfd_error_handler)
+	(_("%B: linking auto-pic files with non-auto-pic files"),
+	 ibfd);
+
+      bfd_set_error (bfd_error_bad_value);
+      ok = FALSE;
+    }
+
+  return ok;
+}
+
+static bfd_boolean
+elf64_ia64_print_private_bfd_data (bfd *abfd, void * ptr)
+{
+  FILE *file = (FILE *) ptr;
+  flagword flags = elf_elfheader (abfd)->e_flags;
+
+  BFD_ASSERT (abfd != NULL && ptr != NULL);
+
+  fprintf (file, "private flags = %s%s%s%s%s%s%s%s\n",
+	   (flags & EF_IA_64_TRAPNIL) ? "TRAPNIL, " : "",
+	   (flags & EF_IA_64_EXT) ? "EXT, " : "",
+	   (flags & EF_IA_64_BE) ? "BE, " : "LE, ",
+	   (flags & EF_IA_64_REDUCEDFP) ? "REDUCEDFP, " : "",
+	   (flags & EF_IA_64_CONS_GP) ? "CONS_GP, " : "",
+	   (flags & EF_IA_64_NOFUNCDESC_CONS_GP) ? "NOFUNCDESC_CONS_GP, " : "",
+	   (flags & EF_IA_64_ABSOLUTE) ? "ABSOLUTE, " : "",
+	   (flags & EF_IA_64_ABI64) ? "ABI64" : "ABI32");
+
+  _bfd_elf_print_private_bfd_data (abfd, ptr);
+  return TRUE;
+}
+
+static enum elf_reloc_type_class
+elf64_ia64_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			     const asection *rel_sec ATTRIBUTE_UNUSED,
+			     const Elf_Internal_Rela *rela)
+{
+  switch ((int) ELF64_R_TYPE (rela->r_info))
+    {
+    case R_IA64_REL32MSB:
+    case R_IA64_REL32LSB:
+    case R_IA64_REL64MSB:
+    case R_IA64_REL64LSB:
+      return reloc_class_relative;
+    case R_IA64_IPLTMSB:
+    case R_IA64_IPLTLSB:
+      return reloc_class_plt;
+    case R_IA64_COPY:
+      return reloc_class_copy;
+    default:
+      return reloc_class_normal;
+    }
+}
+
+static const struct bfd_elf_special_section elf64_ia64_special_sections[] =
+{
+  { STRING_COMMA_LEN (".sbss"),  -1, SHT_NOBITS,   SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT },
+  { STRING_COMMA_LEN (".sdata"), -1, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT },
+  { NULL,                    0,   0, 0,            0 }
+};
+
+static bfd_boolean
+elf64_ia64_object_p (bfd *abfd)
+{
+  asection *sec;
+  asection *group, *unwi, *unw;
+  flagword flags;
+  const char *name;
+  char *unwi_name, *unw_name;
+  bfd_size_type amt;
+
+  if (abfd->flags & DYNAMIC)
+    return TRUE;
+
+  /* Flags for fake group section.  */
+  flags = (SEC_LINKER_CREATED | SEC_GROUP | SEC_LINK_ONCE
+	   | SEC_EXCLUDE);
+
+  /* We add a fake section group for each .gnu.linkonce.t.* section,
+     which isn't in a section group, and its unwind sections.  */
+  for (sec = abfd->sections; sec != NULL; sec = sec->next)
+    {
+      if (elf_sec_group (sec) == NULL
+	  && ((sec->flags & (SEC_LINK_ONCE | SEC_CODE | SEC_GROUP))
+	      == (SEC_LINK_ONCE | SEC_CODE))
+	  && CONST_STRNEQ (sec->name, ".gnu.linkonce.t."))
+	{
+	  name = sec->name + 16;
+
+	  amt = strlen (name) + sizeof (".gnu.linkonce.ia64unwi.");
+	  unwi_name = bfd_alloc (abfd, amt);
+	  if (!unwi_name)
+	    return FALSE;
+
+	  strcpy (stpcpy (unwi_name, ".gnu.linkonce.ia64unwi."), name);
+	  unwi = bfd_get_section_by_name (abfd, unwi_name);
+
+	  amt = strlen (name) + sizeof (".gnu.linkonce.ia64unw.");
+	  unw_name = bfd_alloc (abfd, amt);
+	  if (!unw_name)
+	    return FALSE;
+
+	  strcpy (stpcpy (unw_name, ".gnu.linkonce.ia64unw."), name);
+	  unw = bfd_get_section_by_name (abfd, unw_name);
+
+	  /* We need to create a fake group section for it and its
+	     unwind sections.  */
+	  group = bfd_make_section_anyway_with_flags (abfd, name,
+						      flags);
+	  if (group == NULL)
+	    return FALSE;
+
+	  /* Move the fake group section to the beginning.  */
+	  bfd_section_list_remove (abfd, group);
+	  bfd_section_list_prepend (abfd, group);
+
+	  elf_next_in_group (group) = sec;
+
+	  elf_group_name (sec) = name;
+	  elf_next_in_group (sec) = sec;
+	  elf_sec_group (sec) = group;
+
+	  if (unwi)
+	    {
+	      elf_group_name (unwi) = name;
+	      elf_next_in_group (unwi) = sec;
+	      elf_next_in_group (sec) = unwi;
+	      elf_sec_group (unwi) = group;
+	    }
+
+	   if (unw)
+	     {
+	       elf_group_name (unw) = name;
+	       if (unwi)
+		 {
+		   elf_next_in_group (unw) = elf_next_in_group (unwi);
+		   elf_next_in_group (unwi) = unw;
+		 }
+	       else
+		 {
+		   elf_next_in_group (unw) = sec;
+		   elf_next_in_group (sec) = unw;
+		 }
+	       elf_sec_group (unw) = group;
+	     }
+
+	   /* Fake SHT_GROUP section header.  */
+	  elf_section_data (group)->this_hdr.bfd_section = group;
+	  elf_section_data (group)->this_hdr.sh_type = SHT_GROUP;
+	}
+    }
+  return TRUE;
+}
+
+/* Handle an IA-64 specific section when reading an object file.  This
+   is called when bfd_section_from_shdr finds a section with an unknown
+   type.  */
+
+static bfd_boolean
+elf64_vms_section_from_shdr (bfd *abfd,
+			     Elf_Internal_Shdr *hdr,
+			     const char *name,
+			     int shindex)
+{
+  flagword secflags = 0;
+
+  switch (hdr->sh_type)
+    {
+    case SHT_IA_64_VMS_TRACE:
+    case SHT_IA_64_VMS_DEBUG:
+    case SHT_IA_64_VMS_DEBUG_STR:
+      secflags = SEC_DEBUGGING;
+      break;
+
+    case SHT_IA_64_UNWIND:
+    case SHT_IA_64_HP_OPT_ANOT:
+      break;
+
+    case SHT_IA_64_EXT:
+      if (strcmp (name, ELF_STRING_ia64_archext) != 0)
+	return FALSE;
+      break;
+
+    default:
+      return FALSE;
+    }
+
+  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
+    return FALSE;
+
+  if (secflags != 0)
+    {
+      asection *newsect = hdr->bfd_section;
+
+      if (! bfd_set_section_flags
+          (abfd, newsect, bfd_get_section_flags (abfd, newsect) | secflags))
+	return FALSE;
+    }
+
+  return TRUE;
+}
+
+static bfd_boolean
+elf64_vms_object_p (bfd *abfd)
+{
+  Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
+  Elf_Internal_Phdr *i_phdr = elf_tdata (abfd)->phdr;
+  unsigned int i;
+  unsigned int num_text = 0;
+  unsigned int num_data = 0;
+  unsigned int num_rodata = 0;
+  char name[16];
+
+  if (!elf64_ia64_object_p (abfd))
+    return FALSE;
+
+  /* Many VMS compilers do not generate sections for the corresponding
+     segment.  This is boring as binutils tools won't be able to disassemble
+     the code.  So we simply create all the missing sections.  */
+  for (i = 0; i < i_ehdrp->e_phnum; i++, i_phdr++)
+    {
+      /* Is there a section for this segment?  */
+      bfd_vma base_vma = i_phdr->p_vaddr;
+      bfd_vma limit_vma = base_vma + i_phdr->p_filesz;
+
+      if (i_phdr->p_type != PT_LOAD)
+	continue;
+
+      /* We need to cover from base_vms to limit_vma.  */
+    again:
+      while (base_vma < limit_vma)
+	{
+	  bfd_vma next_vma = limit_vma;
+	  asection *nsec;
+	  asection *sec;
+	  flagword flags;
+	  char *nname = NULL;
+
+	  /* Find a section covering [base_vma;limit_vma)  */
+	  for (sec = abfd->sections; sec != NULL; sec = sec->next)
+	    {
+	      /* Skip uninteresting sections (either not in memory or
+		 below base_vma.  */
+	      if ((sec->flags & (SEC_ALLOC | SEC_LOAD)) == 0
+		  || sec->vma + sec->size <= base_vma)
+		continue;
+	      if (sec->vma <= base_vma)
+		{
+		  /* This section covers (maybe partially) the beginning
+		     of the range.  */
+		  base_vma = sec->vma + sec->size;
+		  goto again;
+		}
+	      if (sec->vma < next_vma)
+		{
+		  /* This section partially covers the end of the range.
+		     Used to compute the size of the hole.  */
+		  next_vma = sec->vma;
+		}
+	    }
+
+	  /* No section covering [base_vma; next_vma).  Create a fake one.  */
+	  flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
+	  if (i_phdr->p_flags & PF_X)
+	    {
+	      flags |= SEC_CODE;
+	      if (num_text++ == 0)
+		nname = ".text";
+	      else
+		sprintf (name, ".text$%u", num_text);
+	    }
+	  else if ((i_phdr->p_flags & (PF_R | PF_W)) == PF_R)
+	    {
+	      flags |= SEC_READONLY;
+	      sprintf (name, ".rodata$%u", num_rodata++);
+	    }
+	  else
+	    {
+	      flags |= SEC_DATA;
+	      sprintf (name, ".data$%u", num_data++);
+	    }
+
+	  /* Allocate name.  */
+	  if (nname == NULL)
+	    {
+	      size_t name_len = strlen (name) + 1;
+	      nname = bfd_alloc (abfd, name_len);
+	      if (nname == NULL)
+		return FALSE;
+	      memcpy (nname, name, name_len);
+	    }
+
+	  /* Create and fill new section.  */
+	  nsec = bfd_make_section_anyway_with_flags (abfd, nname, flags);
+	  if (nsec == NULL)
+	    return FALSE;
+	  nsec->vma = base_vma;
+	  nsec->size = next_vma - base_vma;
+	  nsec->filepos = i_phdr->p_offset + (base_vma - i_phdr->p_vaddr);
+
+	  base_vma = next_vma;
+	}
+    }
+  return TRUE;
+}
+
+static void
+elf64_vms_post_process_headers (bfd *abfd,
+				struct bfd_link_info *info ATTRIBUTE_UNUSED)
+{
+  Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
+
+  i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_OPENVMS;
+  i_ehdrp->e_ident[EI_ABIVERSION] = 2;
+}
+
+static bfd_boolean
+elf64_vms_section_processing (bfd *abfd ATTRIBUTE_UNUSED,
+			      Elf_Internal_Shdr *hdr)
+{
+  if (hdr->bfd_section != NULL)
+    {
+      const char *name = bfd_get_section_name (abfd, hdr->bfd_section);
+
+      if (strcmp (name, ".text") == 0)
+	hdr->sh_flags |= SHF_IA_64_VMS_SHARED;
+      else if ((strcmp (name, ".debug") == 0)
+	    || (strcmp (name, ".debug_abbrev") == 0)
+	    || (strcmp (name, ".debug_aranges") == 0)
+	    || (strcmp (name, ".debug_frame") == 0)
+	    || (strcmp (name, ".debug_info") == 0)
+	    || (strcmp (name, ".debug_loc") == 0)
+	    || (strcmp (name, ".debug_macinfo") == 0)
+	    || (strcmp (name, ".debug_pubnames") == 0)
+	    || (strcmp (name, ".debug_pubtypes") == 0))
+	hdr->sh_type = SHT_IA_64_VMS_DEBUG;
+      else if ((strcmp (name, ".debug_line") == 0)
+	    || (strcmp (name, ".debug_ranges") == 0)
+	    || (strcmp (name, ".trace_info") == 0)
+	    || (strcmp (name, ".trace_abbrev") == 0)
+	    || (strcmp (name, ".trace_aranges") == 0))
+	hdr->sh_type = SHT_IA_64_VMS_TRACE;
+      else if (strcmp (name, ".debug_str") == 0)
+	hdr->sh_type = SHT_IA_64_VMS_DEBUG_STR;
+    }
+
+  return TRUE;
+}
+
+/* The final processing done just before writing out a VMS IA-64 ELF
+   object file.  */
+
+static void
+elf64_vms_final_write_processing (bfd *abfd,
+				  bfd_boolean linker ATTRIBUTE_UNUSED)
+{
+  Elf_Internal_Shdr *hdr;
+  asection *s;
+  int unwind_info_sect_idx = 0;
+
+  for (s = abfd->sections; s; s = s->next)
+    {
+      hdr = &elf_section_data (s)->this_hdr;
+
+      if (strcmp (bfd_get_section_name (abfd, hdr->bfd_section),
+		  ".IA_64.unwind_info") == 0)
+	unwind_info_sect_idx = elf_section_data (s)->this_idx;
+
+      switch (hdr->sh_type)
+	{
+	case SHT_IA_64_UNWIND:
+	  /* VMS requires sh_info to point to the unwind info section.  */
+          hdr->sh_info = unwind_info_sect_idx;
+	  break;
+	}
+    }
+
+  if (! elf_flags_init (abfd))
+    {
+      unsigned long flags = 0;
+
+      if (abfd->xvec->byteorder == BFD_ENDIAN_BIG)
+	flags |= EF_IA_64_BE;
+      if (bfd_get_mach (abfd) == bfd_mach_ia64_elf64)
+	flags |= EF_IA_64_ABI64;
+
+      elf_elfheader (abfd)->e_flags = flags;
+      elf_flags_init (abfd) = TRUE;
+    }
+}
+
+static bfd_boolean
+elf64_vms_write_shdrs_and_ehdr (bfd *abfd)
+{
+  unsigned char needed_count[8];
+
+  if (!bfd_elf64_write_shdrs_and_ehdr (abfd))
+    return FALSE;
+
+  bfd_putl64 (elf_ia64_vms_tdata (abfd)->needed_count, needed_count);
+
+  if (bfd_seek (abfd, sizeof (Elf64_External_Ehdr), SEEK_SET) != 0
+      || bfd_bwrite (needed_count, 8, abfd) != 8)
+    return FALSE;
+
+  return TRUE;
+}
+
+static bfd_boolean
+elf64_vms_close_and_cleanup (bfd *abfd)
+{
+  if (bfd_get_format (abfd) == bfd_object)
+    {
+      long isize;
+
+      /* Pad to 8 byte boundary for IPF/VMS.  */
+      isize = bfd_get_size (abfd);
+      if ((isize & 7) != 0)
+	{
+	  int ishort = 8 - (isize & 7);
+          bfd_uint64_t pad = 0;
+
+	  bfd_seek (abfd, isize, SEEK_SET);
+	  bfd_bwrite (&pad, ishort, abfd);
+	}
+    }
+
+  return _bfd_elf_close_and_cleanup (abfd);
+}
+
+/* Add symbols from an ELF object file to the linker hash table.  */
+
+static bfd_boolean
+elf64_vms_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
+{
+  Elf_Internal_Shdr *hdr;
+  bfd_size_type symcount;
+  bfd_size_type extsymcount;
+  bfd_size_type extsymoff;
+  struct elf_link_hash_entry **sym_hash;
+  bfd_boolean dynamic;
+  Elf_Internal_Sym *isymbuf = NULL;
+  Elf_Internal_Sym *isym;
+  Elf_Internal_Sym *isymend;
+  const struct elf_backend_data *bed;
+  struct elf_link_hash_table *htab;
+  bfd_size_type amt;
+
+  htab = elf_hash_table (info);
+  bed = get_elf_backend_data (abfd);
+
+  if ((abfd->flags & DYNAMIC) == 0)
+    dynamic = FALSE;
+  else
+    {
+      dynamic = TRUE;
+
+      /* You can't use -r against a dynamic object.  Also, there's no
+	 hope of using a dynamic object which does not exactly match
+	 the format of the output file.  */
+      if (info->relocatable
+	  || !is_elf_hash_table (htab)
+	  || info->output_bfd->xvec != abfd->xvec)
+	{
+	  if (info->relocatable)
+	    bfd_set_error (bfd_error_invalid_operation);
+	  else
+	    bfd_set_error (bfd_error_wrong_format);
+	  goto error_return;
+	}
+    }
+
+  if (! dynamic)
+    {
+      /* If we are creating a shared library, create all the dynamic
+	 sections immediately.  We need to attach them to something,
+	 so we attach them to this BFD, provided it is the right
+	 format.  FIXME: If there are no input BFD's of the same
+	 format as the output, we can't make a shared library.  */
+      if (info->shared
+	  && is_elf_hash_table (htab)
+	  && info->output_bfd->xvec == abfd->xvec
+	  && !htab->dynamic_sections_created)
+	{
+	  if (! elf64_ia64_create_dynamic_sections (abfd, info))
+	    goto error_return;
+	}
+    }
+  else if (!is_elf_hash_table (htab))
+    goto error_return;
+  else
+    {
+      asection *s;
+      bfd_byte *dynbuf;
+      bfd_byte *extdyn;
+
+      /* ld --just-symbols and dynamic objects don't mix very well.
+	 ld shouldn't allow it.  */
+      if ((s = abfd->sections) != NULL
+	  && s->sec_info_type == SEC_INFO_TYPE_JUST_SYMS)
+	abort ();
+
+      /* Be sure there are dynamic sections.  */
+      if (! elf64_ia64_create_dynamic_sections (htab->dynobj, info))
+        goto error_return;
+
+      s = bfd_get_section_by_name (abfd, ".dynamic");
+      if (s == NULL)
+        {
+          /* VMS libraries do not have dynamic sections.  Create one from
+             the segment.  */
+          Elf_Internal_Phdr *phdr;
+          unsigned int i, phnum;
+
+          phdr = elf_tdata (abfd)->phdr;
+          if (phdr == NULL)
+            goto error_return;
+          phnum = elf_elfheader (abfd)->e_phnum;
+          for (i = 0; i < phnum; phdr++)
+            if (phdr->p_type == PT_DYNAMIC)
+              {
+                s = bfd_make_section (abfd, ".dynamic");
+                if (s == NULL)
+                  goto error_return;
+                s->vma = phdr->p_vaddr;
+                s->lma = phdr->p_paddr;
+                s->size = phdr->p_filesz;
+                s->filepos = phdr->p_offset;
+                s->flags |= SEC_HAS_CONTENTS;
+                s->alignment_power = bfd_log2 (phdr->p_align);
+                break;
+              }
+          if (s == NULL)
+            goto error_return;
+        }
+
+      /* Extract IDENT.  */
+      if (!bfd_malloc_and_get_section (abfd, s, &dynbuf))
+        {
+error_free_dyn:
+          free (dynbuf);
+          goto error_return;
+        }
+
+      for (extdyn = dynbuf;
+           extdyn < dynbuf + s->size;
+           extdyn += bed->s->sizeof_dyn)
+        {
+          Elf_Internal_Dyn dyn;
+
+          bed->s->swap_dyn_in (abfd, extdyn, &dyn);
+          if (dyn.d_tag == DT_IA_64_VMS_IDENT)
+            {
+              bfd_uint64_t tagv = dyn.d_un.d_val;
+              elf_ia64_vms_ident (abfd) = tagv;
+              break;
+            }
+        }
+      if (extdyn >= dynbuf + s->size)
+        {
+          /* Ident not found.  */
+          goto error_free_dyn;
+        }
+      free (dynbuf);
+
+      /* We do not want to include any of the sections in a dynamic
+	 object in the output file.  We hack by simply clobbering the
+	 list of sections in the BFD.  This could be handled more
+	 cleanly by, say, a new section flag; the existing
+	 SEC_NEVER_LOAD flag is not the one we want, because that one
+	 still implies that the section takes up space in the output
+	 file.  */
+      bfd_section_list_clear (abfd);
+
+      /* FIXME: should we detect if this library is already included ?
+         This should be harmless and shouldn't happen in practice.  */
+    }
+
+  hdr = &elf_tdata (abfd)->symtab_hdr;
+  symcount = hdr->sh_size / bed->s->sizeof_sym;
+
+  /* The sh_info field of the symtab header tells us where the
+     external symbols start.  We don't care about the local symbols at
+     this point.  */
+  extsymcount = symcount - hdr->sh_info;
+  extsymoff = hdr->sh_info;
+
+  sym_hash = NULL;
+  if (extsymcount != 0)
+    {
+      isymbuf = bfd_elf_get_elf_syms (abfd, hdr, extsymcount, extsymoff,
+				      NULL, NULL, NULL);
+      if (isymbuf == NULL)
+	goto error_return;
+
+      /* We store a pointer to the hash table entry for each external
+	 symbol.  */
+      amt = extsymcount * sizeof (struct elf_link_hash_entry *);
+      sym_hash = (struct elf_link_hash_entry **) bfd_alloc (abfd, amt);
+      if (sym_hash == NULL)
+	goto error_free_sym;
+      elf_sym_hashes (abfd) = sym_hash;
+    }
+
+  for (isym = isymbuf, isymend = isymbuf + extsymcount;
+       isym < isymend;
+       isym++, sym_hash++)
+    {
+      int bind;
+      bfd_vma value;
+      asection *sec, *new_sec;
+      flagword flags;
+      const char *name;
+      struct elf_link_hash_entry *h;
+      bfd_boolean definition;
+      bfd_boolean size_change_ok;
+      bfd_boolean type_change_ok;
+      bfd_boolean common;
+      unsigned int old_alignment;
+      bfd *old_bfd;
+
+      flags = BSF_NO_FLAGS;
+      sec = NULL;
+      value = isym->st_value;
+      *sym_hash = NULL;
+      common = bed->common_definition (isym);
+
+      bind = ELF_ST_BIND (isym->st_info);
+      switch (bind)
+	{
+	case STB_LOCAL:
+	  /* This should be impossible, since ELF requires that all
+	     global symbols follow all local symbols, and that sh_info
+	     point to the first global symbol.  Unfortunately, Irix 5
+	     screws this up.  */
+	  continue;
+
+	case STB_GLOBAL:
+	  if (isym->st_shndx != SHN_UNDEF && !common)
+	    flags = BSF_GLOBAL;
+	  break;
+
+	case STB_WEAK:
+	  flags = BSF_WEAK;
+	  break;
+
+	case STB_GNU_UNIQUE:
+	  flags = BSF_GNU_UNIQUE;
+	  break;
+
+	default:
+	  /* Leave it up to the processor backend.  */
+	  break;
+	}
+
+      if (isym->st_shndx == SHN_UNDEF)
+	sec = bfd_und_section_ptr;
+      else if (isym->st_shndx == SHN_ABS)
+	sec = bfd_abs_section_ptr;
+      else if (isym->st_shndx == SHN_COMMON)
+	{
+	  sec = bfd_com_section_ptr;
+	  /* What ELF calls the size we call the value.  What ELF
+	     calls the value we call the alignment.  */
+	  value = isym->st_size;
+	}
+      else
+	{
+	  sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
+	  if (sec == NULL)
+	    sec = bfd_abs_section_ptr;
+	  else if (sec->kept_section)
+	    {
+	      /* Symbols from discarded section are undefined.  We keep
+		 its visibility.  */
+	      sec = bfd_und_section_ptr;
+	      isym->st_shndx = SHN_UNDEF;
+	    }
+	  else if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0)
+	    value -= sec->vma;
+	}
+
+      name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link,
+					      isym->st_name);
+      if (name == NULL)
+	goto error_free_vers;
+
+      if (bed->elf_add_symbol_hook)
+	{
+	  if (! (*bed->elf_add_symbol_hook) (abfd, info, isym, &name, &flags,
+					     &sec, &value))
+	    goto error_free_vers;
+
+	  /* The hook function sets the name to NULL if this symbol
+	     should be skipped for some reason.  */
+	  if (name == NULL)
+	    continue;
+	}
+
+      /* Sanity check that all possibilities were handled.  */
+      if (sec == NULL)
+	{
+	  bfd_set_error (bfd_error_bad_value);
+	  goto error_free_vers;
+	}
+
+      if (bfd_is_und_section (sec)
+	  || bfd_is_com_section (sec))
+	definition = FALSE;
+      else
+	definition = TRUE;
+
+      size_change_ok = FALSE;
+      type_change_ok = bed->type_change_ok;
+      old_alignment = 0;
+      old_bfd = NULL;
+      new_sec = sec;
+
+      if (! bfd_is_und_section (sec))
+        h = elf_link_hash_lookup (htab, name, TRUE, FALSE, FALSE);
+      else
+        h = ((struct elf_link_hash_entry *) bfd_wrapped_link_hash_lookup
+             (abfd, info, name, TRUE, FALSE, FALSE));
+      if (h == NULL)
+        goto error_free_sym;
+
+      *sym_hash = h;
+
+      if (is_elf_hash_table (htab))
+	{
+	  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;
+
+	  /* Remember the old alignment if this is a common symbol, so
+	     that we don't reduce the alignment later on.  We can't
+	     check later, because _bfd_generic_link_add_one_symbol
+	     will set a default for the alignment which we want to
+	     override. We also remember the old bfd where the existing
+	     definition comes from.  */
+	  switch (h->root.type)
+	    {
+	    default:
+	      break;
+
+	    case bfd_link_hash_defined:
+              if (abfd->selective_search)
+                continue;
+              /* Fall-through.  */
+	    case bfd_link_hash_defweak:
+	      old_bfd = h->root.u.def.section->owner;
+	      break;
+
+	    case bfd_link_hash_common:
+	      old_bfd = h->root.u.c.p->section->owner;
+	      old_alignment = h->root.u.c.p->alignment_power;
+	      break;
+	    }
+	}
+
+      if (! (_bfd_generic_link_add_one_symbol
+	     (info, abfd, name, flags, sec, value, NULL, FALSE, bed->collect,
+	      (struct bfd_link_hash_entry **) sym_hash)))
+	goto error_free_vers;
+
+      h = *sym_hash;
+      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_hash = h;
+      if (definition)
+	h->unique_global = (flags & BSF_GNU_UNIQUE) != 0;
+
+      /* Set the alignment of a common symbol.  */
+      if ((common || bfd_is_com_section (sec))
+	  && h->root.type == bfd_link_hash_common)
+	{
+	  unsigned int align;
+
+	  if (common)
+	    align = bfd_log2 (isym->st_value);
+	  else
+	    {
+	      /* The new symbol is a common symbol in a shared object.
+		 We need to get the alignment from the section.  */
+	      align = new_sec->alignment_power;
+	    }
+	  if (align > old_alignment
+	      /* Permit an alignment power of zero if an alignment of one
+		 is specified and no other alignments have been specified.  */
+	      || (isym->st_value == 1 && old_alignment == 0))
+	    h->root.u.c.p->alignment_power = align;
+	  else
+	    h->root.u.c.p->alignment_power = old_alignment;
+	}
+
+      if (is_elf_hash_table (htab))
+	{
+	  /* Check the alignment when a common symbol is involved. This
+	     can change when a common symbol is overridden by a normal
+	     definition or a common symbol is ignored due to the old
+	     normal definition. We need to make sure the maximum
+	     alignment is maintained.  */
+	  if ((old_alignment || common)
+	      && h->root.type != bfd_link_hash_common)
+	    {
+	      unsigned int common_align;
+	      unsigned int normal_align;
+	      unsigned int symbol_align;
+	      bfd *normal_bfd;
+	      bfd *common_bfd;
+
+	      symbol_align = ffs (h->root.u.def.value) - 1;
+	      if (h->root.u.def.section->owner != NULL
+		  && (h->root.u.def.section->owner->flags & DYNAMIC) == 0)
+		{
+		  normal_align = h->root.u.def.section->alignment_power;
+		  if (normal_align > symbol_align)
+		    normal_align = symbol_align;
+		}
+	      else
+		normal_align = symbol_align;
+
+	      if (old_alignment)
+		{
+		  common_align = old_alignment;
+		  common_bfd = old_bfd;
+		  normal_bfd = abfd;
+		}
+	      else
+		{
+		  common_align = bfd_log2 (isym->st_value);
+		  common_bfd = abfd;
+		  normal_bfd = old_bfd;
+		}
+
+	      if (normal_align < common_align)
+		{
+		  /* PR binutils/2735 */
+		  if (normal_bfd == NULL)
+		    (*_bfd_error_handler)
+		      (_("Warning: alignment %u of common symbol `%s' in %B"
+			 " is greater than the alignment (%u) of its section %A"),
+		       common_bfd, h->root.u.def.section,
+		       1 << common_align, name, 1 << normal_align);
+		  else
+		    (*_bfd_error_handler)
+		      (_("Warning: alignment %u of symbol `%s' in %B"
+			 " is smaller than %u in %B"),
+		       normal_bfd, common_bfd,
+		       1 << normal_align, name, 1 << common_align);
+		}
+	    }
+
+	  /* Remember the symbol size if it isn't undefined.  */
+	  if ((isym->st_size != 0 && isym->st_shndx != SHN_UNDEF)
+	      && (definition || h->size == 0))
+	    {
+	      if (h->size != 0
+		  && h->size != isym->st_size
+		  && ! size_change_ok)
+		(*_bfd_error_handler)
+		  (_("Warning: size of symbol `%s' changed"
+		     " from %lu in %B to %lu in %B"),
+		   old_bfd, abfd,
+		   name, (unsigned long) h->size,
+		   (unsigned long) isym->st_size);
+
+	      h->size = isym->st_size;
+	    }
+
+	  /* If this is a common symbol, then we always want H->SIZE
+	     to be the size of the common symbol.  The code just above
+	     won't fix the size if a common symbol becomes larger.  We
+	     don't warn about a size change here, because that is
+	     covered by --warn-common.  Allow changed between different
+	     function types.  */
+	  if (h->root.type == bfd_link_hash_common)
+	    h->size = h->root.u.c.size;
+
+	  if (ELF_ST_TYPE (isym->st_info) != STT_NOTYPE
+	      && (definition || h->type == STT_NOTYPE))
+	    {
+	      unsigned int type = ELF_ST_TYPE (isym->st_info);
+
+	      if (h->type != type)
+		{
+		  if (h->type != STT_NOTYPE && ! type_change_ok)
+		    (*_bfd_error_handler)
+		      (_("Warning: type of symbol `%s' changed"
+			 " from %d to %d in %B"),
+		       abfd, name, h->type, type);
+
+		  h->type = type;
+		}
+	    }
+
+	  /* Set a flag in the hash table entry indicating the type of
+	     reference or definition we just found.  Keep a count of
+	     the number of dynamic symbols we find.  A dynamic symbol
+	     is one which is referenced or defined by both a regular
+	     object and a shared object.  */
+	  if (! dynamic)
+	    {
+	      if (! definition)
+		{
+		  h->ref_regular = 1;
+		  if (bind != STB_WEAK)
+		    h->ref_regular_nonweak = 1;
+		}
+	      else
+		{
+                  BFD_ASSERT (!h->def_dynamic);
+		  h->def_regular = 1;
+		}
+	    }
+	  else
+	    {
+	      BFD_ASSERT (definition);
+              h->def_dynamic = 1;
+              h->dynindx = -2;
+              ((struct elf64_ia64_link_hash_entry *)h)->shl = abfd;
+	    }
+	}
+    }
+
+  if (isymbuf != NULL)
+    {
+      free (isymbuf);
+      isymbuf = NULL;
+    }
+
+  /* If this object is the same format as the output object, and it is
+     not a shared library, then let the backend look through the
+     relocs.
+
+     This is required to build global offset table entries and to
+     arrange for dynamic relocs.  It is not required for the
+     particular common case of linking non PIC code, even when linking
+     against shared libraries, but unfortunately there is no way of
+     knowing whether an object file has been compiled PIC or not.
+     Looking through the relocs is not particularly time consuming.
+     The problem is that we must either (1) keep the relocs in memory,
+     which causes the linker to require additional runtime memory or
+     (2) read the relocs twice from the input file, which wastes time.
+     This would be a good case for using mmap.
+
+     I have no idea how to handle linking PIC code into a file of a
+     different format.  It probably can't be done.  */
+  if (! dynamic
+      && is_elf_hash_table (htab)
+      && bed->check_relocs != NULL
+      && (*bed->relocs_compatible) (abfd->xvec, info->output_bfd->xvec))
+    {
+      asection *o;
+
+      for (o = abfd->sections; o != NULL; o = o->next)
+	{
+	  Elf_Internal_Rela *internal_relocs;
+	  bfd_boolean ok;
+
+	  if ((o->flags & SEC_RELOC) == 0
+	      || o->reloc_count == 0
+	      || ((info->strip == strip_all || info->strip == strip_debugger)
+		  && (o->flags & SEC_DEBUGGING) != 0)
+	      || bfd_is_abs_section (o->output_section))
+	    continue;
+
+	  internal_relocs = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL,
+						       info->keep_memory);
+	  if (internal_relocs == NULL)
+	    goto error_return;
+
+	  ok = (*bed->check_relocs) (abfd, info, o, internal_relocs);
+
+	  if (elf_section_data (o)->relocs != internal_relocs)
+	    free (internal_relocs);
+
+	  if (! ok)
+	    goto error_return;
+	}
+    }
+
+  return TRUE;
+
+ error_free_vers:
+ error_free_sym:
+  if (isymbuf != NULL)
+    free (isymbuf);
+ error_return:
+  return FALSE;
+}
+
+static bfd_boolean
+elf64_vms_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info)
+{
+  int pass;
+  struct bfd_link_hash_entry **pundef;
+  struct bfd_link_hash_entry **next_pundef;
+
+  /* We only accept VMS libraries.  */
+  if (info->output_bfd->xvec != abfd->xvec)
+    {
+      bfd_set_error (bfd_error_wrong_format);
+      return FALSE;
+    }
+
+  /* The archive_pass field in the archive itself is used to
+     initialize PASS, since we may search the same archive multiple
+     times.  */
+  pass = ++abfd->archive_pass;
+
+  /* Look through the list of undefined symbols.  */
+  for (pundef = &info->hash->undefs; *pundef != NULL; pundef = next_pundef)
+    {
+      struct bfd_link_hash_entry *h;
+      symindex symidx;
+      bfd *element;
+      bfd *orig_element;
+
+      h = *pundef;
+      next_pundef = &(*pundef)->u.undef.next;
+
+      /* When a symbol is defined, it is not necessarily removed from
+	 the list.  */
+      if (h->type != bfd_link_hash_undefined
+	  && h->type != bfd_link_hash_common)
+	{
+	  /* Remove this entry from the list, for general cleanliness
+	     and because we are going to look through the list again
+	     if we search any more libraries.  We can't remove the
+	     entry if it is the tail, because that would lose any
+	     entries we add to the list later on.  */
+	  if (*pundef != info->hash->undefs_tail)
+            {
+              *pundef = *next_pundef;
+              next_pundef = pundef;
+            }
+	  continue;
+	}
+
+      /* Look for this symbol in the archive hash table.  */
+      symidx = _bfd_vms_lib_find_symbol (abfd, h->root.string);
+      if (symidx == BFD_NO_MORE_SYMBOLS)
+	{
+	  /* Nothing in this slot.  */
+	  continue;
+	}
+
+      element = bfd_get_elt_at_index (abfd, symidx);
+      if (element == NULL)
+	return FALSE;
+
+      if (element->archive_pass == -1 || element->archive_pass == pass)
+        {
+          /* Next symbol if this archive is wrong or already handled.  */
+          continue;
+        }
+
+      orig_element = element;
+      if (bfd_is_thin_archive (abfd))
+        {
+          element = _bfd_vms_lib_get_imagelib_file (element);
+          if (element == NULL || !bfd_check_format (element, bfd_object))
+            {
+              orig_element->archive_pass = -1;
+              return FALSE;
+            }
+        }
+      else if (! bfd_check_format (element, bfd_object))
+        {
+          element->archive_pass = -1;
+          return FALSE;
+        }
+
+      /* Unlike the generic linker, we know that this element provides
+	 a definition for an undefined symbol and we know that we want
+	 to include it.  We don't need to check anything.  */
+      if (! (*info->callbacks->add_archive_element) (info, element,
+                                                     h->root.string, &element))
+	return FALSE;
+      if (! elf64_vms_link_add_object_symbols (element, info))
+	return FALSE;
+
+      orig_element->archive_pass = pass;
+    }
+
+  return TRUE;
+}
+
+static bfd_boolean
+elf64_vms_bfd_link_add_symbols (bfd *abfd, struct bfd_link_info *info)
+{
+  switch (bfd_get_format (abfd))
+    {
+    case bfd_object:
+      return elf64_vms_link_add_object_symbols (abfd, info);
+      break;
+    case bfd_archive:
+      return elf64_vms_link_add_archive_symbols (abfd, info);
+      break;
+    default:
+      bfd_set_error (bfd_error_wrong_format);
+      return FALSE;
+    }
+}
+
+static bfd_boolean
+elf64_ia64_vms_mkobject (bfd *abfd)
+{
+  return bfd_elf_allocate_object
+    (abfd, sizeof (struct elf64_ia64_vms_obj_tdata), IA64_ELF_DATA);
+}
+
+
+/* Size-dependent data and functions.  */
+static const struct elf_size_info elf64_ia64_vms_size_info = {
+  sizeof (Elf64_External_VMS_Ehdr),
+  sizeof (Elf64_External_Phdr),
+  sizeof (Elf64_External_Shdr),
+  sizeof (Elf64_External_Rel),
+  sizeof (Elf64_External_Rela),
+  sizeof (Elf64_External_Sym),
+  sizeof (Elf64_External_Dyn),
+  sizeof (Elf_External_Note),
+  4,
+  1,
+  64, 3, /* ARCH_SIZE, LOG_FILE_ALIGN */
+  ELFCLASS64, EV_CURRENT,
+  bfd_elf64_write_out_phdrs,
+  elf64_vms_write_shdrs_and_ehdr,
+  bfd_elf64_checksum_contents,
+  bfd_elf64_write_relocs,
+  bfd_elf64_swap_symbol_in,
+  bfd_elf64_swap_symbol_out,
+  bfd_elf64_slurp_reloc_table,
+  bfd_elf64_slurp_symbol_table,
+  bfd_elf64_swap_dyn_in,
+  bfd_elf64_swap_dyn_out,
+  bfd_elf64_swap_reloc_in,
+  bfd_elf64_swap_reloc_out,
+  bfd_elf64_swap_reloca_in,
+  bfd_elf64_swap_reloca_out
+};
+
+#define ELF_ARCH			bfd_arch_ia64
+#define ELF_MACHINE_CODE		EM_IA_64
+#define ELF_MAXPAGESIZE			0x10000	/* 64KB */
+#define ELF_COMMONPAGESIZE		0x200	/* 16KB */
+
+#define elf_backend_section_from_shdr \
+	elf64_ia64_section_from_shdr
+#define elf_backend_section_flags \
+	elf64_ia64_section_flags
+#define elf_backend_fake_sections \
+	elf64_ia64_fake_sections
+#define elf_backend_final_write_processing \
+	elf64_ia64_final_write_processing
+#define elf_backend_add_symbol_hook \
+	elf64_ia64_add_symbol_hook
+#define elf_info_to_howto \
+	elf64_ia64_info_to_howto
+
+#define bfd_elf64_bfd_reloc_type_lookup \
+	ia64_elf_reloc_type_lookup
+#define bfd_elf64_bfd_reloc_name_lookup \
+	ia64_elf_reloc_name_lookup
+#define bfd_elf64_bfd_is_local_label_name \
+	elf64_ia64_is_local_label_name
+#define bfd_elf64_bfd_relax_section \
+	elf64_ia64_relax_section
+
+#define elf_backend_object_p \
+	elf64_ia64_object_p
+
+/* Stuff for the BFD linker: */
+#define bfd_elf64_bfd_link_hash_table_create \
+	elf64_ia64_hash_table_create
+#define bfd_elf64_bfd_link_hash_table_free \
+	elf64_ia64_hash_table_free
+#define elf_backend_create_dynamic_sections \
+	elf64_ia64_create_dynamic_sections
+#define elf_backend_check_relocs \
+	elf64_ia64_check_relocs
+#define elf_backend_adjust_dynamic_symbol \
+	elf64_ia64_adjust_dynamic_symbol
+#define elf_backend_size_dynamic_sections \
+	elf64_ia64_size_dynamic_sections
+#define elf_backend_omit_section_dynsym \
+  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
+#define elf_backend_relocate_section \
+	elf64_ia64_relocate_section
+#define elf_backend_finish_dynamic_symbol \
+	elf64_ia64_finish_dynamic_symbol
+#define elf_backend_finish_dynamic_sections \
+	elf64_ia64_finish_dynamic_sections
+#define bfd_elf64_bfd_final_link \
+	elf64_ia64_final_link
+
+#define bfd_elf64_bfd_merge_private_bfd_data \
+	elf64_ia64_merge_private_bfd_data
+#define bfd_elf64_bfd_set_private_flags \
+	elf64_ia64_set_private_flags
+#define bfd_elf64_bfd_print_private_bfd_data \
+	elf64_ia64_print_private_bfd_data
+
+#define elf_backend_plt_readonly	1
+#define elf_backend_want_plt_sym	0
+#define elf_backend_plt_alignment	5
+#define elf_backend_got_header_size	0
+#define elf_backend_want_got_plt	1
+#define elf_backend_may_use_rel_p	1
+#define elf_backend_may_use_rela_p	1
+#define elf_backend_default_use_rela_p	1
+#define elf_backend_want_dynbss		0
+#define elf_backend_hide_symbol		elf64_ia64_hash_hide_symbol
+#define elf_backend_fixup_symbol	_bfd_elf_link_hash_fixup_symbol
+#define elf_backend_reloc_type_class	elf64_ia64_reloc_type_class
+#define elf_backend_rela_normal		1
+#define elf_backend_special_sections	elf64_ia64_special_sections
+#define elf_backend_default_execstack	0
+
+/* FIXME: PR 290: The Intel C compiler generates SHT_IA_64_UNWIND with
+   SHF_LINK_ORDER. But it doesn't set the sh_link or sh_info fields.
+   We don't want to flood users with so many error messages. We turn
+   off the warning for now. It will be turned on later when the Intel
+   compiler is fixed.   */
+#define elf_backend_link_order_error_handler NULL
+
+/* VMS-specific vectors.  */
+
+#undef  TARGET_LITTLE_SYM
+#define TARGET_LITTLE_SYM		bfd_elf64_ia64_vms_vec
+#undef  TARGET_LITTLE_NAME
+#define TARGET_LITTLE_NAME		"elf64-ia64-vms"
+#undef  TARGET_BIG_SYM
+#undef  TARGET_BIG_NAME
+
+/* These are VMS specific functions.  */
+
+#undef  elf_backend_object_p
+#define elf_backend_object_p elf64_vms_object_p
+
+#undef  elf_backend_section_from_shdr
+#define elf_backend_section_from_shdr elf64_vms_section_from_shdr
+
+#undef  elf_backend_post_process_headers
+#define elf_backend_post_process_headers elf64_vms_post_process_headers
+
+#undef  elf_backend_section_processing
+#define elf_backend_section_processing elf64_vms_section_processing
+
+#undef  elf_backend_final_write_processing
+#define elf_backend_final_write_processing elf64_vms_final_write_processing
+
+#undef  bfd_elf64_close_and_cleanup
+#define bfd_elf64_close_and_cleanup elf64_vms_close_and_cleanup
+
+#undef  elf_backend_section_from_bfd_section
+
+#undef  elf_backend_symbol_processing
+
+#undef  elf_backend_want_p_paddr_set_to_zero
+
+#undef  ELF_OSABI
+#define ELF_OSABI			ELFOSABI_OPENVMS
+
+#undef  ELF_MAXPAGESIZE
+#define ELF_MAXPAGESIZE			0x10000	/* 64KB */
+
+#undef  elf64_bed
+#define elf64_bed elf64_ia64_vms_bed
+
+#define elf_backend_size_info elf64_ia64_vms_size_info
+
+/* Use VMS-style archives (in particular, don't use the standard coff
+   archive format).  */
+#define bfd_elf64_archive_functions
+
+#undef bfd_elf64_archive_p
+#define bfd_elf64_archive_p _bfd_vms_lib_ia64_archive_p
+#undef bfd_elf64_write_archive_contents
+#define bfd_elf64_write_archive_contents _bfd_vms_lib_write_archive_contents
+#undef bfd_elf64_mkarchive
+#define bfd_elf64_mkarchive _bfd_vms_lib_ia64_mkarchive
+
+#define bfd_elf64_archive_slurp_armap \
+  _bfd_vms_lib_slurp_armap
+#define bfd_elf64_archive_slurp_extended_name_table \
+  _bfd_vms_lib_slurp_extended_name_table
+#define bfd_elf64_archive_construct_extended_name_table \
+  _bfd_vms_lib_construct_extended_name_table
+#define bfd_elf64_archive_truncate_arname \
+  _bfd_vms_lib_truncate_arname
+#define bfd_elf64_archive_write_armap \
+  _bfd_vms_lib_write_armap
+#define bfd_elf64_archive_read_ar_hdr \
+  _bfd_vms_lib_read_ar_hdr
+#define bfd_elf64_archive_write_ar_hdr \
+  _bfd_vms_lib_write_ar_hdr
+#define bfd_elf64_archive_openr_next_archived_file \
+  _bfd_vms_lib_openr_next_archived_file
+#define bfd_elf64_archive_get_elt_at_index \
+  _bfd_vms_lib_get_elt_at_index
+#define bfd_elf64_archive_generic_stat_arch_elt \
+  _bfd_vms_lib_generic_stat_arch_elt
+#define bfd_elf64_archive_update_armap_timestamp \
+  _bfd_vms_lib_update_armap_timestamp
+
+/* VMS link methods.  */
+#undef  bfd_elf64_bfd_link_add_symbols
+#define bfd_elf64_bfd_link_add_symbols 	elf64_vms_bfd_link_add_symbols
+
+#undef  elf_backend_want_got_sym
+#define elf_backend_want_got_sym 	0
+
+#undef  bfd_elf64_mkobject
+#define bfd_elf64_mkobject		elf64_ia64_vms_mkobject
+
+/* Redefine to align segments on block size.  */
+#undef  ELF_MAXPAGESIZE
+#define ELF_MAXPAGESIZE			0x200 /* 512B  */
+
+#undef  elf_backend_want_got_plt
+#define elf_backend_want_got_plt	0
+
+#include "elf64-target.h"
diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c
index 3feb1bb..a0c5cc5 100644
--- a/bfd/elf64-mips.c
+++ b/bfd/elf64-mips.c
@@ -1340,7 +1340,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_DTPMOD64", /* name */
 	 FALSE,			/* partial_inplace */
-	 MINUS_ONE,		/* src_mask */
+	 0,			/* src_mask */
 	 MINUS_ONE,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1354,7 +1354,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_DTPREL64",	/* name */
 	 FALSE,			/* partial_inplace */
-	 MINUS_ONE,		/* src_mask */
+	 0,			/* src_mask */
 	 MINUS_ONE,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1369,7 +1369,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_GD",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1384,7 +1384,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_LDM",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1399,7 +1399,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_DTPREL_HI16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1414,7 +1414,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_DTPREL_LO16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1429,7 +1429,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_GOTTPREL",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1446,7 +1446,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_TPREL64",	/* name */
 	 FALSE,			/* partial_inplace */
-	 MINUS_ONE,		/* src_mask */
+	 0,			/* src_mask */
 	 MINUS_ONE,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1461,7 +1461,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_TPREL_HI16", /* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1476,7 +1476,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_TPREL_LO16", /* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1590,6 +1590,111 @@
 	 0x0000ffff,		/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS general dynamic variable reference.  */
+  HOWTO (R_MIPS16_TLS_GD,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_GD",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS local dynamic variable reference.  */
+  HOWTO (R_MIPS16_TLS_LDM,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_LDM",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS local dynamic offset.  */
+  HOWTO (R_MIPS16_TLS_DTPREL_HI16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_DTPREL_HI16",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS local dynamic offset.  */
+  HOWTO (R_MIPS16_TLS_DTPREL_LO16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_DTPREL_LO16",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS thread pointer offset.  */
+  HOWTO (R_MIPS16_TLS_GOTTPREL,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_GOTTPREL",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS thread pointer offset.  */
+  HOWTO (R_MIPS16_TLS_TPREL_HI16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_TPREL_HI16", /* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS thread pointer offset.  */
+  HOWTO (R_MIPS16_TLS_TPREL_LO16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_TPREL_LO16", /* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
 };
 
 static reloc_howto_type mips16_elf64_howto_table_rela[] =
@@ -1608,7 +1713,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS16_26",		/* name */
 	 FALSE,			/* partial_inplace */
-	 0x3ffffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x3ffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1623,7 +1728,7 @@
 	 mips16_gprel_reloc,	/* special_function */
 	 "R_MIPS16_GPREL",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,	        /* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1638,7 +1743,7 @@
 	 _bfd_mips_elf_got16_reloc, /* special_function */
 	 "R_MIPS16_GOT16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,	        /* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1653,7 +1758,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS16_CALL16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,	        /* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1668,7 +1773,7 @@
 	 _bfd_mips_elf_hi16_reloc, /* special_function */
 	 "R_MIPS16_HI16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1683,7 +1788,112 @@
 	 _bfd_mips_elf_lo16_reloc, /* special_function */
 	 "R_MIPS16_LO16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS general dynamic variable reference.  */
+  HOWTO (R_MIPS16_TLS_GD,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_GD",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS local dynamic variable reference.  */
+  HOWTO (R_MIPS16_TLS_LDM,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_LDM",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS local dynamic offset.  */
+  HOWTO (R_MIPS16_TLS_DTPREL_HI16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_DTPREL_HI16",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS local dynamic offset.  */
+  HOWTO (R_MIPS16_TLS_DTPREL_LO16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_DTPREL_LO16",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS thread pointer offset.  */
+  HOWTO (R_MIPS16_TLS_GOTTPREL,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_GOTTPREL",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS thread pointer offset.  */
+  HOWTO (R_MIPS16_TLS_TPREL_HI16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_TPREL_HI16", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS thread pointer offset.  */
+  HOWTO (R_MIPS16_TLS_TPREL_LO16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_TPREL_LO16", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 };
@@ -1974,6 +2184,37 @@
 	 0x0000ffff,		/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
+
+  /* Section displacement.  */
+  HOWTO (R_MICROMIPS_SCN_DISP,  /* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MICROMIPS_SCN_DISP", /* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Protected jump conversion.  This is an optimization hint.  No
+     relocation is required for correctness.  */
+  HOWTO (R_MICROMIPS_JALR,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MICROMIPS_JALR",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x00000000,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
 };
 
 static reloc_howto_type micromips_elf64_howto_table_rela[] =
@@ -1996,7 +2237,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_26_S1",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x3ffffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x3ffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2011,7 +2252,7 @@
 	 _bfd_mips_elf_hi16_reloc, /* special_function */
 	 "R_MICROMIPS_HI16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2026,7 +2267,7 @@
 	 _bfd_mips_elf_lo16_reloc, /* special_function */
 	 "R_MICROMIPS_LO16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2041,7 +2282,7 @@
 	 _bfd_mips_elf32_gprel16_reloc, /* special_function */
 	 "R_MICROMIPS_GPREL16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2056,7 +2297,7 @@
 	 _bfd_mips_elf32_gprel16_reloc, /* special_function */
 	 "R_MICROMIPS_LITERAL",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2071,7 +2312,7 @@
 	 _bfd_mips_elf_got16_reloc, /* special_function */
 	 "R_MICROMIPS_GOT16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2086,7 +2327,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_PC7_S1",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000007f,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000007f,		/* dst_mask */
 	 TRUE),			/* pcrel_offset */
 
@@ -2100,7 +2341,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_PC10_S1",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x000003ff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x000003ff,		/* dst_mask */
 	 TRUE),			/* pcrel_offset */
 
@@ -2114,7 +2355,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_PC16_S1",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 TRUE),			/* pcrel_offset */
 
@@ -2129,7 +2370,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_CALL16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2147,7 +2388,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_GOT_DISP",/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2162,7 +2403,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_GOT_PAGE",/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2177,7 +2418,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_GOT_OFST",/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2192,7 +2433,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_GOT_HI16",/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2207,7 +2448,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_GOT_LO16",/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2222,7 +2463,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_SUB",	/* name */
 	 FALSE,			/* partial_inplace */
-	 MINUS_ONE,		/* src_mask */
+	 0,			/* src_mask */
 	 MINUS_ONE,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2237,7 +2478,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_HIGHER",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2252,7 +2493,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_HIGHEST",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2267,7 +2508,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_CALL_HI16",/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2282,9 +2523,40 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_CALL_LO16",/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
+
+  /* Section displacement.  */
+  HOWTO (R_MICROMIPS_SCN_DISP,  /* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MICROMIPS_SCN_DISP", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Protected jump conversion.  This is an optimization hint.  No
+     relocation is required for correctness.  */
+  HOWTO (R_MICROMIPS_JALR,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MICROMIPS_JALR",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x00000000,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
 };
 
 /* GNU extension to record C++ vtable hierarchy */
@@ -2350,6 +2622,23 @@
 	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 TRUE);			/* pcrel_offset */
+
+/* 32 bit pc-relative.  Used for compact EH tables.  */
+static reloc_howto_type elf_mips_gnu_pcrel32 =
+  HOWTO (R_MIPS_PC32,		/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS_PC32",		/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 TRUE);			/* pcrel_offset */
+
 
 /* Originally a VxWorks extension, but now used for other systems too.  */
 static reloc_howto_type elf_mips_copy_howto =
@@ -2360,7 +2649,7 @@
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_bitfield, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_COPY",		/* name */
 	 FALSE,			/* partial_inplace */
 	 0x0,         		/* src_mask */
@@ -2376,12 +2665,29 @@
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_bitfield, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_JUMP_SLOT",	/* name */
 	 FALSE,			/* partial_inplace */
 	 0x0,         		/* src_mask */
 	 0x0,		        /* dst_mask */
 	 FALSE);		/* pcrel_offset */
+
+/* Used in EH tables.  */
+static reloc_howto_type elf_mips_eh_howto =
+  HOWTO (R_MIPS_EH,		/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS_EH",		/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,	        /* dst_mask */
+	 FALSE);		/* pcrel_offset */
+
 
 /* Swap in a MIPS 64-bit Rel reloc.  */
 
@@ -2498,6 +2804,7 @@
 
   mirel.r_offset = src[0].r_offset;
   BFD_ASSERT(src[0].r_offset == src[1].r_offset);
+  BFD_ASSERT(src[0].r_offset == src[2].r_offset);
 
   mirel.r_type = ELF64_MIPS_R_TYPE (src[0].r_info);
   mirel.r_sym = ELF64_R_SYM (src[0].r_info);
@@ -2908,6 +3215,15 @@
   { BFD_RELOC_MIPS16_CALL16, R_MIPS16_CALL16 - R_MIPS16_min },
   { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min },
   { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_GD, R_MIPS16_TLS_GD - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_LDM, R_MIPS16_TLS_LDM - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_DTPREL_HI16,
+    R_MIPS16_TLS_DTPREL_HI16 - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_DTPREL_LO16,
+    R_MIPS16_TLS_DTPREL_LO16 - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_GOTTPREL, R_MIPS16_TLS_GOTTPREL - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_HI16 - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_TPREL_LO16, R_MIPS16_TLS_TPREL_LO16 - R_MIPS16_min }
 };
 
 static const struct elf_reloc_map micromips_reloc_map[] =
@@ -2932,6 +3248,8 @@
   { BFD_RELOC_MICROMIPS_HIGHEST, R_MICROMIPS_HIGHEST - R_MICROMIPS_min },
   { BFD_RELOC_MICROMIPS_CALL_HI16, R_MICROMIPS_CALL_HI16 - R_MICROMIPS_min },
   { BFD_RELOC_MICROMIPS_CALL_LO16, R_MICROMIPS_CALL_LO16 - R_MICROMIPS_min },
+  { BFD_RELOC_MICROMIPS_SCN_DISP, R_MICROMIPS_SCN_DISP - R_MICROMIPS_min },
+  { BFD_RELOC_MICROMIPS_JALR, R_MICROMIPS_JALR - R_MICROMIPS_min },
 };
 /* Given a BFD reloc type, return a howto structure.  */
 
@@ -2973,6 +3291,10 @@
       return &elf_mips_gnu_vtinherit_howto;
     case BFD_RELOC_VTABLE_ENTRY:
       return &elf_mips_gnu_vtentry_howto;
+    case BFD_RELOC_32_PCREL:
+      return &elf_mips_gnu_pcrel32;
+    case BFD_RELOC_MIPS_EH:
+      return &elf_mips_eh_howto;
     case BFD_RELOC_MIPS_COPY:
       return &elf_mips_copy_howto;
     case BFD_RELOC_MIPS_JUMP_SLOT:
@@ -3020,6 +3342,10 @@
     return &elf_mips_gnu_rel16_s2;
   if (strcasecmp (elf_mips_gnu_rela16_s2.name, r_name) == 0)
     return &elf_mips_gnu_rela16_s2;
+  if (strcasecmp (elf_mips_gnu_pcrel32.name, r_name) == 0)
+    return &elf_mips_gnu_pcrel32;
+  if (strcasecmp (elf_mips_eh_howto.name, r_name) == 0)
+    return &elf_mips_eh_howto;
   if (strcasecmp (elf_mips_copy_howto.name, r_name) == 0)
     return &elf_mips_copy_howto;
   if (strcasecmp (elf_mips_jump_slot_howto.name, r_name) == 0)
@@ -3044,6 +3370,10 @@
 	return &elf_mips_gnu_rela16_s2;
       else
 	return &elf_mips_gnu_rel16_s2;
+    case R_MIPS_PC32:
+      return &elf_mips_gnu_pcrel32;
+    case R_MIPS_EH:
+      return &elf_mips_eh_howto;
     case R_MIPS_COPY:
       return &elf_mips_copy_howto;
     case R_MIPS_JUMP_SLOT:
@@ -3724,10 +4054,10 @@
 
       case 480:		/* Linux/MIPS - N64 kernel */
 	/* pr_cursig */
-	elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+	elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
 
 	/* pr_pid */
-	elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 32);
+	elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 32);
 
 	/* pr_reg */
 	offset = 112;
@@ -3750,9 +4080,9 @@
 	return FALSE;
 
       case 136:		/* Linux/MIPS - N64 kernel elf_prpsinfo */
-	elf_tdata (abfd)->core_program
+	elf_tdata (abfd)->core->program
 	 = _bfd_elfcore_strndup (abfd, note->descdata + 40, 16);
-	elf_tdata (abfd)->core_command
+	elf_tdata (abfd)->core->command
 	 = _bfd_elfcore_strndup (abfd, note->descdata + 56, 80);
     }
 
@@ -3761,7 +4091,7 @@
      implementations, so strip it off if it exists.  */
 
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
@@ -3906,7 +4236,7 @@
 #define elf_backend_grok_prstatus	elf64_mips_grok_prstatus
 #define elf_backend_grok_psinfo		elf64_mips_grok_psinfo
 
-#define elf_backend_got_header_size	(4 * MIPS_RESERVED_GOTNO)
+#define elf_backend_got_header_size	(8 * MIPS_RESERVED_GOTNO)
 
 /* MIPS ELF64 can use a mixture of REL and RELA, but some Relocations
    work better/work only in RELA, so we default to this.  */
@@ -3946,6 +4276,7 @@
 #define bfd_elf64_get_dynamic_reloc_upper_bound mips_elf64_get_dynamic_reloc_upper_bound
 #define bfd_elf64_canonicalize_dynamic_reloc mips_elf64_canonicalize_dynamic_reloc
 #define bfd_elf64_bfd_relax_section     _bfd_mips_relax_section
+#define bfd_elf64_mkobject		_bfd_mips_elf_mkobject
 
 /* MIPS ELF64 archive functions.  */
 #define bfd_elf64_archive_functions
diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c
index ecc9ad0..499bcd6 100644
--- a/bfd/elf64-mmix.c
+++ b/bfd/elf64-mmix.c
@@ -1,5 +1,6 @@
 /* MMIX-specific support for 64-bit ELF.
-   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
+   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011,
+   2012
    Free Software Foundation, Inc.
    Contributed by Hans-Peter Nilsson <[email protected]>
 
@@ -166,70 +167,24 @@
     struct bpo_reloc_request *reloc_request;
   };
 
-static int mmix_elf_link_output_symbol_hook
-  PARAMS ((struct bfd_link_info *, const char *, Elf_Internal_Sym *,
-	   asection *, struct elf_link_hash_entry *));
 
-static bfd_reloc_status_type mmix_elf_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+extern bfd_boolean mmix_elf_final_link (bfd *, struct bfd_link_info *);
 
-static reloc_howto_type *bfd_elf64_bfd_reloc_type_lookup
-  PARAMS ((bfd *, bfd_reloc_code_real_type));
-
-static void mmix_info_to_howto_rela
-  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
-
-static int mmix_elf_sort_relocs PARAMS ((const PTR, const PTR));
-
-static bfd_boolean mmix_elf_new_section_hook
-  PARAMS ((bfd *, asection *));
-
-static bfd_boolean mmix_elf_check_relocs
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-	   const Elf_Internal_Rela *));
-
-static bfd_boolean mmix_elf_check_common_relocs
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-	   const Elf_Internal_Rela *));
-
-static bfd_boolean mmix_elf_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
-	   Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
-
-static bfd_reloc_status_type mmix_final_link_relocate
-  (reloc_howto_type *, asection *, bfd_byte *, bfd_vma, bfd_signed_vma,
-   bfd_vma, const char *, asection *, char **);
-
-static bfd_reloc_status_type mmix_elf_perform_relocation
-  (asection *, reloc_howto_type *, void *, bfd_vma, bfd_vma, char **);
-
-static bfd_boolean mmix_elf_section_from_bfd_section
-  PARAMS ((bfd *, asection *, int *));
-
-static bfd_boolean mmix_elf_add_symbol_hook
-  PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Sym *,
-	   const char **, flagword *, asection **, bfd_vma *));
-
-static bfd_boolean mmix_elf_is_local_label_name
-  PARAMS ((bfd *, const char *));
-
-static int bpo_reloc_request_sort_fn PARAMS ((const PTR, const PTR));
-
-static bfd_boolean mmix_elf_relax_section
-  PARAMS ((bfd *abfd, asection *sec, struct bfd_link_info *link_info,
-	   bfd_boolean *again));
-
-extern bfd_boolean mmix_elf_final_link PARAMS ((bfd *, struct bfd_link_info *));
-
-extern void mmix_elf_symbol_processing PARAMS ((bfd *, asymbol *));
+extern void mmix_elf_symbol_processing (bfd *, asymbol *);
 
 /* Only intended to be called from a debugger.  */
 extern void mmix_dump_bpo_gregs
-  PARAMS ((struct bfd_link_info *, bfd_error_handler_type));
+  (struct bfd_link_info *, bfd_error_handler_type);
 
 static void
-mmix_set_relaxable_size
-  PARAMS ((bfd *, asection *, void *));
+mmix_set_relaxable_size (bfd *, asection *, void *);
+static bfd_reloc_status_type
+mmix_elf_reloc (bfd *, arelent *, asymbol *, void *,
+		asection *, bfd *, char **);
+static bfd_reloc_status_type
+mmix_final_link_relocate (reloc_howto_type *, asection *, bfd_byte *, bfd_vma,
+			  bfd_signed_vma, bfd_vma, const char *, asection *,
+			  char **);
 
 
 /* Watch out: this currently needs to have elements with the same index as
@@ -840,9 +795,8 @@
   };
 
 static reloc_howto_type *
-bfd_elf64_bfd_reloc_type_lookup (abfd, code)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+bfd_elf64_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+				 bfd_reloc_code_real_type code)
 {
   unsigned int i;
 
@@ -874,9 +828,7 @@
 }
 
 static bfd_boolean
-mmix_elf_new_section_hook (abfd, sec)
-     bfd *abfd;
-     asection *sec;
+mmix_elf_new_section_hook (bfd *abfd, asection *sec)
 {
   if (!sec->used_by_bfd)
     {
@@ -1302,10 +1254,9 @@
 /* Set the howto pointer for an MMIX ELF reloc (type RELA).  */
 
 static void
-mmix_info_to_howto_rela (abfd, cache_ptr, dst)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *cache_ptr;
-     Elf_Internal_Rela *dst;
+mmix_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
+			 arelent *cache_ptr,
+			 Elf_Internal_Rela *dst)
 {
   unsigned int r_type;
 
@@ -1319,15 +1270,13 @@
    the reloc_table.  We don't get here for final pure ELF linking.  */
 
 static bfd_reloc_status_type
-mmix_elf_reloc (abfd, reloc_entry, symbol, data, input_section,
-		output_bfd, error_message)
-     bfd *abfd;
-     arelent *reloc_entry;
-     asymbol *symbol;
-     PTR data;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message;
+mmix_elf_reloc (bfd *abfd,
+		arelent *reloc_entry,
+		asymbol *symbol,
+		void * data,
+		asection *input_section,
+		bfd *output_bfd,
+		char **error_message)
 {
   bfd_vma relocation;
   bfd_reloc_status_type r;
@@ -1397,16 +1346,14 @@
    for guidance if you're thinking of copying this.  */
 
 static bfd_boolean
-mmix_elf_relocate_section (output_bfd, info, input_bfd, input_section,
-			   contents, relocs, local_syms, local_sections)
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     Elf_Internal_Rela *relocs;
-     Elf_Internal_Sym *local_syms;
-     asection **local_sections;
+mmix_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
+			   struct bfd_link_info *info,
+			   bfd *input_bfd,
+			   asection *input_section,
+			   bfd_byte *contents,
+			   Elf_Internal_Rela *relocs,
+			   Elf_Internal_Sym *local_syms,
+			   asection **local_sections)
 {
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
@@ -1475,9 +1422,9 @@
 	  name = h->root.root.string;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	{
@@ -1770,7 +1717,9 @@
 	first_global = 255;
       else
 	{
-	  first_global = bfd_get_section_vma (abfd, regsec) / 8;
+	  first_global
+	    = bfd_get_section_vma (input_section->output_section->owner,
+				   regsec) / 8;
 	  if (strcmp (bfd_get_section_name (symsec->owner, symsec),
 		      MMIX_REG_CONTENTS_SECTION_NAME) == 0)
 	    {
@@ -1855,9 +1804,7 @@
 /* Sort register relocs to come before expanding relocs.  */
 
 static int
-mmix_elf_sort_relocs (p1, p2)
-     const PTR p1;
-     const PTR p2;
+mmix_elf_sort_relocs (const void * p1, const void * p2)
 {
   const Elf_Internal_Rela *r1 = (const Elf_Internal_Rela *) p1;
   const Elf_Internal_Rela *r2 = (const Elf_Internal_Rela *) p2;
@@ -1890,11 +1837,10 @@
 /* Subset of mmix_elf_check_relocs, common to ELF and mmo linking.  */
 
 static bfd_boolean
-mmix_elf_check_common_relocs  (abfd, info, sec, relocs)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     asection *sec;
-     const Elf_Internal_Rela *relocs;
+mmix_elf_check_common_relocs  (bfd *abfd,
+			       struct bfd_link_info *info,
+			       asection *sec,
+			       const Elf_Internal_Rela *relocs)
 {
   bfd *bpo_greg_owner = NULL;
   asection *allocated_gregs_section = NULL;
@@ -1927,7 +1873,7 @@
 	  if (bpo_greg_owner == NULL)
 	    {
 	      bpo_greg_owner = abfd;
-	      info->base_file = (PTR) bpo_greg_owner;
+	      info->base_file = bpo_greg_owner;
 	    }
 
 	  if (allocated_gregs_section == NULL)
@@ -2023,11 +1969,10 @@
 /* Look through the relocs for a section during the first phase.  */
 
 static bfd_boolean
-mmix_elf_check_relocs (abfd, info, sec, relocs)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     asection *sec;
-     const Elf_Internal_Rela *relocs;
+mmix_elf_check_relocs (bfd *abfd,
+		       struct bfd_link_info *info,
+		       asection *sec,
+		       const Elf_Internal_Rela *relocs)
 {
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
@@ -2039,7 +1984,7 @@
 
   /* First we sort the relocs so that any register relocs come before
      expansion-relocs to the same insn.  FIXME: Not done for mmo.  */
-  qsort ((PTR) relocs, sec->reloc_count, sizeof (Elf_Internal_Rela),
+  qsort ((void *) relocs, sec->reloc_count, sizeof (Elf_Internal_Rela),
 	 mmix_elf_sort_relocs);
 
   /* Do the common part.  */
@@ -2064,6 +2009,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       switch (ELF64_R_TYPE (rel->r_info))
@@ -2093,9 +2042,7 @@
    Copied from elf_link_add_object_symbols.  */
 
 bfd_boolean
-_bfd_mmix_check_all_relocs (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info;
+_bfd_mmix_check_all_relocs (bfd *abfd, struct bfd_link_info *info)
 {
   asection *o;
 
@@ -2112,7 +2059,7 @@
 	continue;
 
       internal_relocs
-	= _bfd_elf_link_read_relocs (abfd, o, (PTR) NULL,
+	= _bfd_elf_link_read_relocs (abfd, o, NULL,
 				     (Elf_Internal_Rela *) NULL,
 				     info->keep_memory);
       if (internal_relocs == NULL)
@@ -2135,12 +2082,11 @@
    number.  */
 
 static int
-mmix_elf_link_output_symbol_hook (info, name, sym, input_sec, h)
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     const char *name ATTRIBUTE_UNUSED;
-     Elf_Internal_Sym *sym;
-     asection *input_sec;
-     struct elf_link_hash_entry *h ATTRIBUTE_UNUSED;
+mmix_elf_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED,
+				  const char *name ATTRIBUTE_UNUSED,
+				  Elf_Internal_Sym *sym,
+				  asection *input_sec,
+				  struct elf_link_hash_entry *h ATTRIBUTE_UNUSED)
 {
   if (input_sec != NULL
       && input_sec->name != NULL
@@ -2200,10 +2146,9 @@
    index.  */
 
 static bfd_boolean
-mmix_elf_section_from_bfd_section (abfd, sec, retval)
-     bfd *                 abfd ATTRIBUTE_UNUSED;
-     asection *            sec;
-     int *                 retval;
+mmix_elf_section_from_bfd_section (bfd *       abfd ATTRIBUTE_UNUSED,
+				   asection *  sec,
+				   int *       retval)
 {
   if (strcmp (bfd_get_section_name (abfd, sec), MMIX_REG_SECTION_NAME) == 0)
     *retval = SHN_REGISTER;
@@ -2220,15 +2165,14 @@
    symbols, since otherwise having two with the same value would cause
    them to be "merged", but with the contents serialized.  */
 
-bfd_boolean
-mmix_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
-     bfd *abfd;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     Elf_Internal_Sym *sym;
-     const char **namep ATTRIBUTE_UNUSED;
-     flagword *flagsp ATTRIBUTE_UNUSED;
-     asection **secp;
-     bfd_vma *valp ATTRIBUTE_UNUSED;
+static bfd_boolean
+mmix_elf_add_symbol_hook (bfd *abfd,
+			  struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			  Elf_Internal_Sym *sym,
+			  const char **namep ATTRIBUTE_UNUSED,
+			  flagword *flagsp ATTRIBUTE_UNUSED,
+			  asection **secp,
+			  bfd_vma *valp ATTRIBUTE_UNUSED)
 {
   if (sym->st_shndx == SHN_REGISTER)
     {
@@ -2263,10 +2207,8 @@
 
 /* We consider symbols matching "L.*:[0-9]+" to be local symbols.  */
 
-bfd_boolean
-mmix_elf_is_local_label_name (abfd, name)
-     bfd *abfd;
-     const char *name;
+static bfd_boolean
+mmix_elf_is_local_label_name (bfd *abfd, const char *name)
 {
   const char *colpos;
   int digits;
@@ -2294,9 +2236,7 @@
 /* We get rid of the register section here.  */
 
 bfd_boolean
-mmix_elf_final_link (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info;
+mmix_elf_final_link (bfd *abfd, struct bfd_link_info *info)
 {
   /* We never output a register section, though we create one for
      temporary measures.  Check that nobody entered contents into it.  */
@@ -2343,10 +2283,9 @@
    section size.  This is expected to shrink during linker relaxation.  */
 
 static void
-mmix_set_relaxable_size (abfd, sec, ptr)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     asection *sec;
-     void *ptr;
+mmix_set_relaxable_size (bfd *abfd ATTRIBUTE_UNUSED,
+			 asection *sec,
+			 void *ptr)
 {
   struct bfd_link_info *info = ptr;
 
@@ -2371,9 +2310,8 @@
    R_MMIX_BASE_PLUS_OFFSET relocs seen by the linker.  */
 
 bfd_boolean
-_bfd_mmix_before_linker_allocation (abfd, info)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info;
+_bfd_mmix_before_linker_allocation (bfd *abfd ATTRIBUTE_UNUSED,
+				    struct bfd_link_info *info)
 {
   asection *bpo_gregs_section;
   bfd *bpo_greg_owner;
@@ -2450,9 +2388,8 @@
    calculated at this point; we just move the contents into place here.  */
 
 bfd_boolean
-_bfd_mmix_after_linker_allocation (abfd, link_info)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *link_info;
+_bfd_mmix_after_linker_allocation (bfd *abfd ATTRIBUTE_UNUSED,
+				   struct bfd_link_info *link_info)
 {
   asection *bpo_gregs_section;
   bfd *bpo_greg_owner;
@@ -2523,9 +2460,7 @@
    value.  */
 
 static int
-bpo_reloc_request_sort_fn (p1, p2)
-     const PTR p1;
-     const PTR p2;
+bpo_reloc_request_sort_fn (const void * p1, const void * p2)
 {
   const struct bpo_reloc_request *r1 = (const struct bpo_reloc_request *) p1;
   const struct bpo_reloc_request *r2 = (const struct bpo_reloc_request *) p2;
@@ -2616,11 +2551,10 @@
    Symbol- and reloc-reading infrastructure copied from elf-m10200.c.  */
 
 static bfd_boolean
-mmix_elf_relax_section (abfd, sec, link_info, again)
-     bfd *abfd;
-     asection *sec;
-     struct bfd_link_info *link_info;
-     bfd_boolean *again;
+mmix_elf_relax_section (bfd *abfd,
+			asection *sec,
+			struct bfd_link_info *link_info,
+			bfd_boolean *again)
 {
   Elf_Internal_Shdr *symtab_hdr;
   Elf_Internal_Rela *internal_relocs;
@@ -2666,7 +2600,7 @@
 
   /* Get a copy of the native relocations.  */
   internal_relocs
-    = _bfd_elf_link_read_relocs (abfd, sec, (PTR) NULL,
+    = _bfd_elf_link_read_relocs (abfd, sec, NULL,
 				 (Elf_Internal_Rela *) NULL,
 				 link_info->keep_memory);
   if (internal_relocs == NULL)
@@ -2870,7 +2804,7 @@
       gregdata->n_remaining_bpo_relocs_this_relaxation_round
 	= gregdata->n_bpo_relocs;
 
-      qsort ((PTR) gregdata->reloc_request,
+      qsort (gregdata->reloc_request,
 	     gregdata->n_max_bpo_relocs,
 	     sizeof (struct bpo_reloc_request),
 	     bpo_reloc_request_sort_fn);
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 7c7abea..bf13a5d 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -1,6 +1,6 @@
 /* PowerPC64-specific support for 64-bit ELF.
    Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-   2009, 2010, 2011 Free Software Foundation, Inc.
+   2009, 2010, 2011, 2012 Free Software Foundation, Inc.
    Written by Linus Nordberg, Swox AB <[email protected]>,
    based on elf32-ppc.c by Ian Lance Taylor.
    Largely rewritten by Alan Modra.
@@ -81,7 +81,8 @@
 #define bfd_elf64_mkobject		      ppc64_elf_mkobject
 #define bfd_elf64_bfd_reloc_type_lookup	      ppc64_elf_reloc_type_lookup
 #define bfd_elf64_bfd_reloc_name_lookup	      ppc64_elf_reloc_name_lookup
-#define bfd_elf64_bfd_merge_private_bfd_data  _bfd_generic_verify_endian_match
+#define bfd_elf64_bfd_merge_private_bfd_data  ppc64_elf_merge_private_bfd_data
+#define bfd_elf64_bfd_print_private_bfd_data  ppc64_elf_print_private_bfd_data
 #define bfd_elf64_new_section_hook	      ppc64_elf_new_section_hook
 #define bfd_elf64_bfd_link_hash_table_create  ppc64_elf_link_hash_table_create
 #define bfd_elf64_bfd_link_hash_table_free    ppc64_elf_link_hash_table_free
@@ -96,7 +97,7 @@
 #define elf_backend_copy_indirect_symbol      ppc64_elf_copy_indirect_symbol
 #define elf_backend_add_symbol_hook	      ppc64_elf_add_symbol_hook
 #define elf_backend_check_directives	      ppc64_elf_process_dot_syms
-#define elf_backend_as_needed_cleanup	      ppc64_elf_as_needed_cleanup
+#define elf_backend_notice_as_needed	      ppc64_elf_notice_as_needed
 #define elf_backend_archive_symbol_lookup     ppc64_elf_archive_symbol_lookup
 #define elf_backend_check_relocs	      ppc64_elf_check_relocs
 #define elf_backend_gc_keep		      ppc64_elf_gc_keep
@@ -108,6 +109,7 @@
 #define elf_backend_maybe_function_sym	      ppc64_elf_maybe_function_sym
 #define elf_backend_always_size_sections      ppc64_elf_func_desc_adjust
 #define elf_backend_size_dynamic_sections     ppc64_elf_size_dynamic_sections
+#define elf_backend_hash_symbol		      ppc64_elf_hash_symbol
 #define elf_backend_init_index_section	      _bfd_elf_init_2_index_sections
 #define elf_backend_action_discarded	      ppc64_elf_action_discarded
 #define elf_backend_relocate_section	      ppc64_elf_relocate_section
@@ -117,16 +119,25 @@
 #define elf_backend_link_output_symbol_hook   ppc64_elf_output_symbol_hook
 #define elf_backend_special_sections	      ppc64_elf_special_sections
 #define elf_backend_post_process_headers      _bfd_elf_set_osabi
+#define elf_backend_merge_symbol_attribute    ppc64_elf_merge_symbol_attribute
 
 /* The name of the dynamic interpreter.  This is put in the .interp
    section.  */
 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
 
 /* The size in bytes of an entry in the procedure linkage table.  */
-#define PLT_ENTRY_SIZE 24
+#define PLT_ENTRY_SIZE(htab) (htab->opd_abi ? 24 : 8)
 
 /* The initial size of the plt reserved for the dynamic linker.  */
-#define PLT_INITIAL_ENTRY_SIZE PLT_ENTRY_SIZE
+#define PLT_INITIAL_ENTRY_SIZE(htab) (htab->opd_abi ? 24 : 16)
+
+/* Offsets to some stack save slots.  */
+#define STK_LR 16
+#define STK_TOC(htab) (htab->opd_abi ? 40 : 24)
+/* This one is dodgy.  ABIv2 does not have a linker word, so use the
+   CR save slot.  Used only by optimised __tls_get_addr call stub,
+   relying on __tls_get_addr_opt not saving CR..  */
+#define STK_LINKER(htab) (htab->opd_abi ? 32 : 8)
 
 /* TOC base pointers offset from start of TOC.  */
 #define TOC_BASE_OFF	0x8000
@@ -137,26 +148,35 @@
 
 /* .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.  */
-#define PLT_CALL_STUB_SIZE (7*4)
-#define ADDIS_R12_R2	0x3d820000	/* addis %r12,%r2,xxx@ha     */
-#define STD_R2_40R1	0xf8410028	/* std	 %r2,40(%r1)	     */
-#define LD_R11_0R12	0xe96c0000	/* ld	 %r11,xxx+0@l(%r12)  */
-#define MTCTR_R11	0x7d6903a6	/* mtctr %r11		     */
-#define LD_R2_0R12	0xe84c0000	/* ld	 %r2,xxx+8@l(%r12)   */
-					/* ld	 %r11,xxx+16@l(%r12) */
+   insert an addi to adjust r11.  */
+#define STD_R2_0R1	0xf8410000	/* std	 %r2,0+40(%r1)	     */
+#define ADDIS_R11_R2	0x3d620000	/* addis %r11,%r2,xxx@ha     */
+#define LD_R12_0R11	0xe98b0000	/* ld	 %r12,xxx+0@l(%r11)  */
+#define MTCTR_R12	0x7d8903a6	/* mtctr %r12		     */
+#define LD_R2_0R11	0xe84b0000	/* ld	 %r2,xxx+8@l(%r11)   */
+#define LD_R11_0R11	0xe96b0000	/* ld	 %r11,xxx+16@l(%r11) */
 #define BCTR		0x4e800420	/* bctr			     */
 
-
-#define ADDIS_R12_R12	0x3d8c0000	/* addis %r12,%r12,off@ha  */
-#define ADDI_R12_R12	0x398c0000	/* addi %r12,%r12,off@l  */
+#define ADDI_R11_R11	0x396b0000	/* addi %r11,%r11,off@l  */
 #define ADDIS_R2_R2	0x3c420000	/* addis %r2,%r2,off@ha  */
 #define ADDI_R2_R2	0x38420000	/* addi  %r2,%r2,off@l   */
 
+#define XOR_R2_R12_R12	0x7d826278	/* xor   %r2,%r12,%r12   */
+#define ADD_R11_R11_R2	0x7d6b1214	/* add   %r11,%r11,%r2   */
+#define XOR_R11_R12_R12	0x7d8b6278	/* xor   %r11,%r12,%r12  */
+#define ADD_R2_R2_R11	0x7c425a14	/* add   %r2,%r2,%r11    */
+#define CMPLDI_R2_0	0x28220000	/* cmpldi %r2,0          */
+#define BNECTR		0x4ca20420	/* bnectr+               */
+#define BNECTR_P4	0x4ce20420	/* bnectr+               */
+
+#define LD_R12_0R2	0xe9820000	/* ld	 %r12,xxx+0(%r2) */
 #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)     */
+#define LD_R2_0R1	0xe8410000	/* ld    %r2,0(%r1)      */
+
+#define ADDIS_R12_R12	0x3d8c0000	/* addis %r12,%r12,xxx@ha */
+#define LD_R12_0R12	0xe98c0000	/* ld    %r12,xxx@l(%r12) */
 
 /* glink call stub instructions.  We enter with the index in R0.  */
 #define GLINK_CALL_STUB_SIZE (16*4)
@@ -167,14 +187,19 @@
 #define BCL_20_31	0x429f0005	/*  bcl 20,31,1f		*/
 					/* 1:				*/
 #define MFLR_R11	0x7d6802a6	/*  mflr %11			*/
-#define LD_R2_M16R11	0xe84bfff0	/*  ld %2,(0b-1b)(%11)		*/
+					/*  ld %2,(0b-1b)(%11)		*/
 #define MTLR_R12	0x7d8803a6	/*  mtlr %12			*/
-#define ADD_R12_R2_R11	0x7d825a14	/*  add %12,%2,%11		*/
-					/*  ld %11,0(%12)		*/
-					/*  ld %2,8(%12)		*/
-					/*  mtctr %11			*/
-					/*  ld %11,16(%12)		*/
+#define ADD_R11_R2_R11	0x7d625a14	/*  add %11,%2,%11		*/
+					/*  ld %12,0(%11)		*/
+					/*  ld %2,8(%11)		*/
+					/*  mtctr %12			*/
+					/*  ld %11,16(%11)		*/
 					/*  bctr			*/
+#define MFLR_R0		0x7c0802a6	/*  mflr %r0			*/
+#define MTLR_R0		0x7c0803a6	/*  mtlr %r0			*/
+#define SUB_R12_R12_R11	0x7d8b6050	/*  subf %r12,%r11,%r12		*/
+#define ADDI_R0_R12	0x380c0000	/*  addi %r0,%r12,0		*/
+#define SRDI_R0_R0_2	0x7800f082	/*  rldicl %r0,%r0,62,2		*/
 
 /* Pad with this.  */
 #define NOP		0x60000000
@@ -302,7 +327,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 bfd_elf_generic_reloc,	/* special_function */
 	 "R_PPC64_ADDR16_HI",	/* name */
 	 FALSE,			/* partial_inplace */
@@ -318,7 +343,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_ha_reloc,	/* special_function */
 	 "R_PPC64_ADDR16_HA",	/* name */
 	 FALSE,			/* partial_inplace */
@@ -480,7 +505,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont,/* complain_on_overflow */
+	 complain_overflow_signed,/* complain_on_overflow */
 	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_GOT16_HI",	/* name */
 	 FALSE,			/* partial_inplace */
@@ -496,7 +521,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont,/* complain_on_overflow */
+	 complain_overflow_signed,/* complain_on_overflow */
 	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_GOT16_HA",	/* name */
 	 FALSE,			/* partial_inplace */
@@ -673,7 +698,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_PLT16_HI",	/* name */
 	 FALSE,			/* partial_inplace */
@@ -689,7 +714,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_PLT16_HA",	/* name */
 	 FALSE,			/* partial_inplace */
@@ -734,7 +759,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_sectoff_reloc, /* special_function */
 	 "R_PPC64_SECTOFF_HI",	/* name */
 	 FALSE,			/* partial_inplace */
@@ -749,7 +774,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_sectoff_ha_reloc, /* special_function */
 	 "R_PPC64_SECTOFF_HA",	/* name */
 	 FALSE,			/* partial_inplace */
@@ -956,7 +981,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_toc_reloc,	/* special_function */
 	 "R_PPC64_TOC16_HI",	/* name */
 	 FALSE,			/* partial_inplace */
@@ -975,7 +1000,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_toc_ha_reloc, /* special_function */
 	 "R_PPC64_TOC16_HA",	/* name */
 	 FALSE,			/* partial_inplace */
@@ -1047,7 +1072,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_PLTGOT16_HI",	/* name */
 	 FALSE,			/* partial_inplace */
@@ -1065,7 +1090,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont,/* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_PLTGOT16_HA",	/* name */
 	 FALSE,			/* partial_inplace */
@@ -1367,7 +1392,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_DTPREL16_HI",	/* name */
 	 FALSE,			/* partial_inplace */
@@ -1382,7 +1407,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_DTPREL16_HA",	/* name */
 	 FALSE,			/* partial_inplace */
@@ -1533,7 +1558,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_TPREL16_HI",	/* name */
 	 FALSE,			/* partial_inplace */
@@ -1548,7 +1573,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_TPREL16_HA",	/* name */
 	 FALSE,			/* partial_inplace */
@@ -1685,7 +1710,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_GOT_TLSGD16_HI", /* name */
 	 FALSE,			/* partial_inplace */
@@ -1700,7 +1725,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_GOT_TLSGD16_HA", /* name */
 	 FALSE,			/* partial_inplace */
@@ -1747,7 +1772,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_GOT_TLSLD16_HI", /* name */
 	 FALSE,			/* partial_inplace */
@@ -1762,7 +1787,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_GOT_TLSLD16_HA", /* name */
 	 FALSE,			/* partial_inplace */
@@ -1808,7 +1833,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_GOT_DTPREL16_HI", /* name */
 	 FALSE,			/* partial_inplace */
@@ -1823,7 +1848,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_GOT_DTPREL16_HA", /* name */
 	 FALSE,			/* partial_inplace */
@@ -1869,7 +1894,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_GOT_TPREL16_HI", /* name */
 	 FALSE,			/* partial_inplace */
@@ -1884,7 +1909,7 @@
 	 16,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_unhandled_reloc, /* special_function */
 	 "R_PPC64_GOT_TPREL16_HA", /* name */
 	 FALSE,			/* partial_inplace */
@@ -1957,7 +1982,7 @@
 	 16,			/* bitsize */
 	 TRUE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 bfd_elf_generic_reloc,	/* special_function */
 	 "R_PPC64_REL16_HI",	/* name */
 	 FALSE,			/* partial_inplace */
@@ -1973,7 +1998,7 @@
 	 16,			/* bitsize */
 	 TRUE,			/* pc_relative */
 	 0,			/* bitpos */
-	 complain_overflow_dont, /* complain_on_overflow */
+	 complain_overflow_signed, /* complain_on_overflow */
 	 ppc64_elf_ha_reloc,	/* special_function */
 	 "R_PPC64_REL16_HA",	/* name */
 	 FALSE,			/* partial_inplace */
@@ -1981,6 +2006,96 @@
 	 0xffff,		/* dst_mask */
 	 TRUE),			/* pcrel_offset */
 
+  /* Like R_PPC64_ADDR16_HI, but no overflow.  */
+  HOWTO (R_PPC64_ADDR16_HIGH,	/* type */
+	 16,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_PPC64_ADDR16_HIGH",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Like R_PPC64_ADDR16_HA, but no overflow.  */
+  HOWTO (R_PPC64_ADDR16_HIGHA,	/* type */
+	 16,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 ppc64_elf_ha_reloc,	/* special_function */
+	 "R_PPC64_ADDR16_HIGHA",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Like R_PPC64_DTPREL16_HI, but no overflow.  */
+  HOWTO (R_PPC64_DTPREL16_HIGH,
+	 16,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 ppc64_elf_unhandled_reloc, /* special_function */
+	 "R_PPC64_DTPREL16_HIGH", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Like R_PPC64_DTPREL16_HA, but no overflow.  */
+  HOWTO (R_PPC64_DTPREL16_HIGHA,
+	 16,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 ppc64_elf_unhandled_reloc, /* special_function */
+	 "R_PPC64_DTPREL16_HIGHA", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Like R_PPC64_TPREL16_HI, but no overflow.  */
+  HOWTO (R_PPC64_TPREL16_HIGH,
+	 16,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 ppc64_elf_unhandled_reloc, /* special_function */
+	 "R_PPC64_TPREL16_HIGH",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Like R_PPC64_TPREL16_HA, but no overflow.  */
+  HOWTO (R_PPC64_TPREL16_HIGHA,
+	 16,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 ppc64_elf_unhandled_reloc, /* special_function */
+	 "R_PPC64_TPREL16_HIGHA",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
   /* GNU extension to record C++ vtable hierarchy.  */
   HOWTO (R_PPC64_GNU_VTINHERIT,	/* type */
 	 0,			/* rightshift */
@@ -2059,8 +2174,12 @@
       break;
     case BFD_RELOC_HI16:			r = R_PPC64_ADDR16_HI;
       break;
+    case BFD_RELOC_PPC64_ADDR16_HIGH:		r = R_PPC64_ADDR16_HIGH;
+      break;
     case BFD_RELOC_HI16_S:			r = R_PPC64_ADDR16_HA;
       break;
+    case BFD_RELOC_PPC64_ADDR16_HIGHA:		r = R_PPC64_ADDR16_HIGHA;
+      break;
     case BFD_RELOC_PPC_BA16:			r = R_PPC64_ADDR14;
       break;
     case BFD_RELOC_PPC_BA16_BRTAKEN:		r = R_PPC64_ADDR14_BRTAKEN;
@@ -2179,8 +2298,12 @@
       break;
     case BFD_RELOC_PPC_TPREL16_HI:		r = R_PPC64_TPREL16_HI;
       break;
+    case BFD_RELOC_PPC64_TPREL16_HIGH:		r = R_PPC64_TPREL16_HIGH;
+      break;
     case BFD_RELOC_PPC_TPREL16_HA:		r = R_PPC64_TPREL16_HA;
       break;
+    case BFD_RELOC_PPC64_TPREL16_HIGHA:		r = R_PPC64_TPREL16_HIGHA;
+      break;
     case BFD_RELOC_PPC_TPREL:			r = R_PPC64_TPREL64;
       break;
     case BFD_RELOC_PPC_DTPREL16:		r = R_PPC64_DTPREL16;
@@ -2189,8 +2312,12 @@
       break;
     case BFD_RELOC_PPC_DTPREL16_HI:		r = R_PPC64_DTPREL16_HI;
       break;
+    case BFD_RELOC_PPC64_DTPREL16_HIGH:		r = R_PPC64_DTPREL16_HIGH;
+      break;
     case BFD_RELOC_PPC_DTPREL16_HA:		r = R_PPC64_DTPREL16_HA;
       break;
+    case BFD_RELOC_PPC64_DTPREL16_HIGHA:	r = R_PPC64_DTPREL16_HIGHA;
+      break;
     case BFD_RELOC_PPC_DTPREL:			r = R_PPC64_DTPREL64;
       break;
     case BFD_RELOC_PPC_GOT_TLSGD16:		r = R_PPC64_GOT_TLSGD16;
@@ -2357,8 +2484,8 @@
   long insn;
   enum elf_ppc64_reloc_type r_type;
   bfd_size_type octets;
-  /* Disabled until we sort out how ld should choose 'y' vs 'at'.  */
-  bfd_boolean is_power4 = FALSE;
+  /* Assume 'at' branch hints.  */
+  bfd_boolean is_isa_v2 = TRUE;
 
   /* If this is a relocatable link (output_bfd test tells us), just
      call the generic function.  Any adjustment will be done at final
@@ -2375,7 +2502,7 @@
       || r_type == R_PPC64_REL14_BRTAKEN)
     insn |= 0x01 << 21; /* 'y' or 't' bit, lowest bit of BO field.  */
 
-  if (is_power4)
+  if (is_isa_v2)
     {
       /* Set 'a' bit.  This is 0b00010 in BO field for branch
 	 on CR(BI) insns (BO == 001at or 011at), and 0b01000
@@ -2465,7 +2592,7 @@
 
   TOCstart = _bfd_get_gp_value (input_section->output_section->owner);
   if (TOCstart == 0)
-    TOCstart = ppc64_elf_toc (input_section->output_section->owner);
+    TOCstart = ppc64_elf_set_toc (NULL, input_section->output_section->owner);
 
   /* Subtract the TOC base address.  */
   reloc_entry->addend -= TOCstart + TOC_BASE_OFF;
@@ -2488,7 +2615,7 @@
 
   TOCstart = _bfd_get_gp_value (input_section->output_section->owner);
   if (TOCstart == 0)
-    TOCstart = ppc64_elf_toc (input_section->output_section->owner);
+    TOCstart = ppc64_elf_set_toc (NULL, input_section->output_section->owner);
 
   /* Subtract the TOC base address.  */
   reloc_entry->addend -= TOCstart + TOC_BASE_OFF;
@@ -2515,7 +2642,7 @@
 
   TOCstart = _bfd_get_gp_value (input_section->output_section->owner);
   if (TOCstart == 0)
-    TOCstart = ppc64_elf_toc (input_section->output_section->owner);
+    TOCstart = ppc64_elf_set_toc (NULL, input_section->output_section->owner);
 
   octets = reloc_entry->address * bfd_octets_per_byte (abfd);
   bfd_put_64 (abfd, TOCstart + TOC_BASE_OFF, (bfd_byte *) data + octets);
@@ -2608,8 +2735,13 @@
      sections means we potentially need one of these for each input bfd.  */
   struct got_entry tlsld_got;
 
-  /* A copy of relocs before they are modified for --emit-relocs.  */
-  Elf_Internal_Rela *opd_relocs;
+  union {
+    /* A copy of relocs before they are modified for --emit-relocs.  */
+    Elf_Internal_Rela *relocs;
+
+    /* Section contents.  */
+    bfd_byte *contents;
+  } opd;
 
   /* Nonzero if this bfd has small toc/got relocs, ie. that expect
      the reloc to be in the range -32768 to 32767.  */
@@ -2670,10 +2802,10 @@
     return FALSE;
 
   /* pr_cursig */
-  elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+  elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
 
   /* pr_pid */
-  elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 32);
+  elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 32);
 
   /* pr_reg */
   offset = 112;
@@ -2690,11 +2822,11 @@
   if (note->descsz != 136)
     return FALSE;
 
-  elf_tdata (abfd)->core_pid
+  elf_tdata (abfd)->core->pid
     = bfd_get_32 (abfd, note->descdata + 24);
-  elf_tdata (abfd)->core_program
+  elf_tdata (abfd)->core->program
     = _bfd_elfcore_strndup (abfd, note->descdata + 40, 16);
-  elf_tdata (abfd)->core_command
+  elf_tdata (abfd)->core->command
     = _bfd_elfcore_strndup (abfd, note->descdata + 56, 80);
 
   return TRUE;
@@ -2715,7 +2847,7 @@
 	va_list ap;
 
 	va_start (ap, note_type);
-	memset (data, 0, 40);
+	memset (data, 0, sizeof (data));
 	strncpy (data + 40, va_arg (ap, const char *), 16);
 	strncpy (data + 56, va_arg (ap, const char *), 80);
 	va_end (ap);
@@ -2829,6 +2961,19 @@
     return &ppc64_elf_section_data (sec)->u.opd;
   return NULL;
 }
+
+static inline int
+abiversion (bfd *abfd)
+{
+  return elf_elfheader (abfd)->e_flags & EF_PPC64_ABI;
+}
+
+static inline void
+set_abiversion (bfd *abfd, int ver)
+{
+  elf_elfheader (abfd)->e_flags &= ~EF_PPC64_ABI;
+  elf_elfheader (abfd)->e_flags |= ver & EF_PPC64_ABI;
+}
 
 /* Parameters for the qsort hook.  */
 static bfd_boolean synthetic_relocatable;
@@ -2975,15 +3120,19 @@
   long count;
   char *names;
   long symcount, codesecsym, codesecsymend, secsymend, opdsymend;
-  asection *opd;
+  asection *opd = NULL;
   bfd_boolean relocatable = (abfd->flags & (EXEC_P | DYNAMIC)) == 0;
   asymbol **syms;
+  int abi = abiversion (abfd);
 
   *ret = NULL;
 
-  opd = bfd_get_section_by_name (abfd, ".opd");
-  if (opd == NULL)
-    return 0;
+  if (abi < 2)
+    {
+      opd = bfd_get_section_by_name (abfd, ".opd");
+      if (opd == NULL && abi == 1)
+	return 0;
+    }
 
   symcount = static_count;
   if (!relocatable)
@@ -3152,20 +3301,18 @@
   else
     {
       bfd_boolean (*slurp_relocs) (bfd *, asection *, asymbol **, bfd_boolean);
-      bfd_byte *contents;
+      bfd_byte *contents = NULL;
       size_t size;
       long plt_count = 0;
       bfd_vma glink_vma = 0, resolv_vma = 0;
       asection *dynamic, *glink = NULL, *relplt = NULL;
       arelent *p;
 
-      if (!bfd_malloc_and_get_section (abfd, opd, &contents))
+      if (opd != NULL && !bfd_malloc_and_get_section (abfd, opd, &contents))
 	{
+	free_contents_and_exit:
 	  if (contents)
-	    {
-	    free_contents_and_exit:
-	      free (contents);
-	    }
+	    free (contents);
 	  count = -1;
 	  goto done;
 	}
@@ -3214,9 +3361,9 @@
 
 	      if (dyn.d_tag == DT_PPC64_GLINK)
 		{
-		  /* The first glink stub starts at offset 32; see comment in
-		     ppc64_elf_finish_dynamic_sections. */
-		  glink_vma = dyn.d_un.d_val + 32;
+		  /* The first glink stub starts at offset 32; see
+		     comment in ppc64_elf_finish_dynamic_sections. */
+		  glink_vma = dyn.d_un.d_val + GLINK_CALL_STUB_SIZE - 8 * 4;
 		  /* The .glink section usually does not survive the final
 		     link; search for the section (usually .text) where the
 		     glink stubs now reside.  */
@@ -3234,13 +3381,21 @@
 	  /* Determine __glink trampoline by reading the relative branch
 	     from the first glink stub.  */
 	  bfd_byte buf[4];
-	  if (bfd_get_section_contents (abfd, glink, buf,
-					glink_vma + 4 - glink->vma, 4))
+	  unsigned int off = 0;
+
+	  while (bfd_get_section_contents (abfd, glink, buf,
+					   glink_vma + off - glink->vma, 4))
 	    {
 	      unsigned int insn = bfd_get_32 (abfd, buf);
 	      insn ^= B_DOT;
 	      if ((insn & ~0x3fffffc) == 0)
-		resolv_vma = glink_vma + 4 + (insn ^ 0x2000000) - 0x2000000;
+		{
+		  resolv_vma = glink_vma + off + (insn ^ 0x2000000) - 0x2000000;
+		  break;
+		}
+	      off += 4;
+	      if (off > 4)
+		break;
 	    }
 
 	  if (resolv_vma)
@@ -3252,7 +3407,7 @@
 	      slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table;
 	      if (! (*slurp_relocs) (abfd, relplt, dyn_syms, TRUE))
 		goto free_contents_and_exit;
-	
+
 	      plt_count = relplt->size / sizeof (Elf64_External_Rela);
 	      size += plt_count * sizeof (asymbol);
 
@@ -3393,8 +3548,13 @@
 	      memcpy (names, "@plt", sizeof ("@plt"));
 	      names += sizeof ("@plt");
 	      s++;
-	      glink_vma += 8;
-	      if (i >= 0x8000)
+	      if (abi < 2)
+		{
+		  glink_vma += 8;
+		  if (i >= 0x8000)
+		    glink_vma += 4;
+		}
+	      else
 		glink_vma += 4;
 	    }
 	  count += plt_count;
@@ -3445,13 +3605,13 @@
    .
    .
    .	.foo_stub:
-   .		addis	12,2,Lfoo@toc@ha	# in practice, the call stub
-   .		addi	12,12,Lfoo@toc@l	# is slightly optimized, but
-   .		std	2,40(1)			# this is the general idea
-   .		ld	11,0(12)
-   .		ld	2,8(12)
-   .		mtctr	11
-   .		ld	11,16(12)
+   .		std	2,40(1)			# in practice, the call stub
+   .		addis	11,2,Lfoo@toc@ha	# is slightly optimized, but
+   .		addi	11,11,Lfoo@toc@l	# this is the general idea
+   .		ld	12,0(11)
+   .		ld	2,8(11)
+   .		mtctr	12
+   .		ld	11,16(11)
    .		bctr
    .
    .		.section .plt
@@ -3502,6 +3662,8 @@
     case R_PPC64_TPREL16_HA:
     case R_PPC64_TPREL16_DS:
     case R_PPC64_TPREL16_LO_DS:
+    case R_PPC64_TPREL16_HIGH:
+    case R_PPC64_TPREL16_HIGHA:
     case R_PPC64_TPREL16_HIGHER:
     case R_PPC64_TPREL16_HIGHERA:
     case R_PPC64_TPREL16_HIGHEST:
@@ -3541,21 +3703,21 @@
    ppc_stub_plt_branch:
    Similar to the above, but a 24 bit branch in the stub section won't
    reach its destination.
-   .	addis	%r12,%r2,xxx@toc@ha
-   .	ld	%r11,xxx@toc@l(%r12)
-   .	mtctr	%r11
+   .	addis	%r11,%r2,xxx@toc@ha
+   .	ld	%r12,xxx@toc@l(%r11)
+   .	mtctr	%r12
    .	bctr
 
    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@toc@l" will be inserted before the "mtctr".
-   .	addis	%r12,%r2,xxx@toc@ha
+   "addi %r11,%r11,xxx@toc@l" will be inserted before the "mtctr".
    .	std	%r2,40(%r1)
-   .	ld	%r11,xxx+0@toc@l(%r12)
-   .	mtctr	%r11
-   .	ld	%r2,xxx+8@toc@l(%r12)
-   .	ld	%r11,xxx+16@toc@l(%r12)
+   .	addis	%r11,%r2,xxx@toc@ha
+   .	ld	%r12,xxx+0@toc@l(%r11)
+   .	mtctr	%r12
+   .	ld	%r2,xxx+8@toc@l(%r11)
+   .	ld	%r11,xxx+16@toc@l(%r11)
    .	bctr
 
    ppc_stub_long_branch and ppc_stub_plt_branch may also have additional
@@ -3568,11 +3730,11 @@
 
    A ppc_stub_plt_branch with an r2 offset looks like:
    .	std	%r2,40(%r1)
-   .	addis	%r12,%r2,xxx@toc@ha
-   .	ld	%r11,xxx@toc@l(%r12)
+   .	addis	%r11,%r2,xxx@toc@ha
+   .	ld	%r12,xxx@toc@l(%r11)
    .	addis	%r2,%r2,off@ha
    .	addi	%r2,%r2,off@l
-   .	mtctr	%r11
+   .	mtctr	%r12
    .	bctr
 
    In cases where the "addis" instruction would add zero, the "addis" is
@@ -3585,7 +3747,8 @@
   ppc_stub_long_branch_r2off,
   ppc_stub_plt_branch,
   ppc_stub_plt_branch_r2off,
-  ppc_stub_plt_call
+  ppc_stub_plt_call,
+  ppc_stub_plt_call_r2save
 };
 
 struct ppc_stub_hash_entry {
@@ -3610,12 +3773,12 @@
   struct ppc_link_hash_entry *h;
   struct plt_entry *plt_ent;
 
-  /* And the reloc addend that this was derived from.  */
-  bfd_vma addend;
-
   /* Where this stub is being called from, or, in the case of combined
      stub sections, the first input section in the group.  */
   asection *id_sec;
+
+  /* Symbol st_other.  */
+  unsigned char other;
 };
 
 struct ppc_branch_hash_entry {
@@ -3630,6 +3793,21 @@
   unsigned int iter;
 };
 
+/* Used to track dynamic relocations for local symbols.  */
+struct ppc_dyn_relocs
+{
+  struct ppc_dyn_relocs *next;
+
+  /* The input section of the reloc.  */
+  asection *sec;
+
+  /* Total number of relocs copied for the input section.  */
+  unsigned int count : 31;
+
+  /* Whether this entry is for STT_GNU_IFUNC symbols.  */
+  unsigned int ifunc : 1;
+};
+
 struct ppc_link_hash_entry
 {
   struct elf_link_hash_entry elf;
@@ -3731,12 +3909,7 @@
   /* List of input sections for each output section.  */
   asection **input_list;
 
-  /* Short-cuts to get to dynamic linker sections.  */
-  asection *got;
-  asection *plt;
-  asection *relplt;
-  asection *iplt;
-  asection *reliplt;
+  /* Shortcuts to get to dynamic linker sections.  */
   asection *dynbss;
   asection *relbss;
   asection *glink;
@@ -3753,14 +3926,23 @@
   bfd_size_type got_reli_size;
 
   /* Statistics.  */
-  unsigned long stub_count[ppc_stub_plt_call];
+  unsigned long stub_count[ppc_stub_plt_call_r2save];
 
   /* Number of stubs against global syms.  */
   unsigned long stub_globals;
 
+  /* Alignment of PLT call stubs.  */
+  unsigned int plt_stub_align:4;
+
+  /* Set if we're linking code with function descriptors.  */
+  unsigned int opd_abi:1;
+
   /* Set if PLT call stubs should load r11.  */
   unsigned int plt_static_chain:1;
 
+  /* Set if PLT call stubs need a read-read barrier.  */
+  unsigned int plt_thread_safe:1;
+
   /* Set if we should emit symbols for stubs.  */
   unsigned int emit_stub_syms:1;
 
@@ -3850,7 +4032,9 @@
       eh->target_value = 0;
       eh->target_section = NULL;
       eh->h = NULL;
+      eh->plt_ent = NULL;
       eh->id_sec = NULL;
+      eh->other = 0;
     }
 
   return entry;
@@ -4026,12 +4210,88 @@
   bfd_hash_table_free (&htab->branch_hash_table);
   if (htab->tocsave_htab)
     htab_delete (htab->tocsave_htab);
-  _bfd_generic_link_hash_table_free (hash);
+  _bfd_elf_link_hash_table_free (hash);
+}
+
+/* Create sections for linker generated code.  */
+
+static bfd_boolean
+create_linkage_sections (bfd *dynobj, struct bfd_link_info *info)
+{
+  struct ppc_link_hash_table *htab;
+  flagword flags;
+
+  htab = ppc_hash_table (info);
+
+  /* Create .sfpr for code to save and restore fp regs.  */
+  flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY
+	   | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+  htab->sfpr = bfd_make_section_anyway_with_flags (dynobj, ".sfpr",
+						   flags);
+  if (htab->sfpr == NULL
+      || ! bfd_set_section_alignment (dynobj, htab->sfpr, 2))
+    return FALSE;
+
+  /* Create .glink for lazy dynamic linking support.  */
+  htab->glink = bfd_make_section_anyway_with_flags (dynobj, ".glink",
+						    flags);
+  if (htab->glink == NULL
+      || ! bfd_set_section_alignment (dynobj, htab->glink, 3))
+    return FALSE;
+
+  if (!info->no_ld_generated_unwind_info)
+    {
+      flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_HAS_CONTENTS
+	       | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+      htab->glink_eh_frame = bfd_make_section_anyway_with_flags (dynobj,
+								 ".eh_frame",
+								 flags);
+      if (htab->glink_eh_frame == NULL
+	  || !bfd_set_section_alignment (dynobj, htab->glink_eh_frame, 2))
+	return FALSE;
+    }
+
+  flags = SEC_ALLOC | SEC_LINKER_CREATED;
+  htab->elf.iplt = bfd_make_section_anyway_with_flags (dynobj, ".iplt", flags);
+  if (htab->elf.iplt == NULL
+      || ! bfd_set_section_alignment (dynobj, htab->elf.iplt, 3))
+    return FALSE;
+
+  flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY
+	   | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+  htab->elf.irelplt
+    = bfd_make_section_anyway_with_flags (dynobj, ".rela.iplt", flags);
+  if (htab->elf.irelplt == NULL
+      || ! bfd_set_section_alignment (dynobj, htab->elf.irelplt, 3))
+    return FALSE;
+
+  /* Create branch lookup table for plt_branch stubs.  */
+  flags = (SEC_ALLOC | SEC_LOAD
+	   | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+  htab->brlt = bfd_make_section_anyway_with_flags (dynobj, ".branch_lt",
+						   flags);
+  if (htab->brlt == NULL
+      || ! bfd_set_section_alignment (dynobj, htab->brlt, 3))
+    return FALSE;
+
+  if (!info->shared)
+    return TRUE;
+
+  flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY
+	   | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+  htab->relbrlt = bfd_make_section_anyway_with_flags (dynobj,
+						      ".rela.branch_lt",
+						      flags);
+  if (htab->relbrlt == NULL
+      || ! bfd_set_section_alignment (dynobj, htab->relbrlt, 3))
+    return FALSE;
+
+  return TRUE;
 }
 
 /* Satisfy the ELF linker by filling in some fields in our fake bfd.  */
 
-void
+bfd_boolean
 ppc64_elf_init_stub_bfd (bfd *abfd, struct bfd_link_info *info)
 {
   struct ppc_link_hash_table *htab;
@@ -4043,9 +4303,14 @@
    the start of the output TOC section.  */
   htab = ppc_hash_table (info);
   if (htab == NULL)
-    return;
+    return FALSE;
   htab->stub_bfd = abfd;
   htab->elf.dynobj = abfd;
+
+  if (info->relocatable)
+    return TRUE;
+
+  return create_linkage_sections (htab->elf.dynobj, info);
 }
 
 /* Build a name for an entry in the stub hash table.  */
@@ -4057,7 +4322,7 @@
 	       const Elf_Internal_Rela *rel)
 {
   char *stub_name;
-  bfd_size_type len;
+  ssize_t len;
 
   /* rel->r_addend is actually 64 bit, but who uses more than +/- 2^31
      offsets from a sym as a branch target?  In fact, we could
@@ -4071,10 +4336,10 @@
       if (stub_name == NULL)
 	return stub_name;
 
-      sprintf (stub_name, "%08x.%s+%x",
-	       input_section->id & 0xffffffff,
-	       h->elf.root.root.string,
-	       (int) rel->r_addend & 0xffffffff);
+      len = sprintf (stub_name, "%08x.%s+%x",
+		     input_section->id & 0xffffffff,
+		     h->elf.root.root.string,
+		     (int) rel->r_addend & 0xffffffff);
     }
   else
     {
@@ -4083,13 +4348,13 @@
       if (stub_name == NULL)
 	return stub_name;
 
-      sprintf (stub_name, "%08x.%x:%x+%x",
-	       input_section->id & 0xffffffff,
-	       sym_sec->id & 0xffffffff,
-	       (int) ELF64_R_SYM (rel->r_info) & 0xffffffff,
-	       (int) rel->r_addend & 0xffffffff);
+      len = sprintf (stub_name, "%08x.%x:%x+%x",
+		     input_section->id & 0xffffffff,
+		     sym_sec->id & 0xffffffff,
+		     (int) ELF64_R_SYM (rel->r_info) & 0xffffffff,
+		     (int) rel->r_addend & 0xffffffff);
     }
-  if (stub_name[len - 2] == '+' && stub_name[len - 1] == '0')
+  if (len > 2 && stub_name[len - 2] == '+' && stub_name[len - 1] == '0')
     stub_name[len - 2] = 0;
   return stub_name;
 }
@@ -4195,85 +4460,6 @@
   return stub_entry;
 }
 
-/* Create sections for linker generated code.  */
-
-static bfd_boolean
-create_linkage_sections (bfd *dynobj, struct bfd_link_info *info)
-{
-  struct ppc_link_hash_table *htab;
-  flagword flags;
-
-  htab = ppc_hash_table (info);
-  if (htab == NULL)
-    return FALSE;
-
-  /* Create .sfpr for code to save and restore fp regs.  */
-  flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_READONLY
-	   | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED);
-  htab->sfpr = bfd_make_section_anyway_with_flags (dynobj, ".sfpr",
-						   flags);
-  if (htab->sfpr == NULL
-      || ! bfd_set_section_alignment (dynobj, htab->sfpr, 2))
-    return FALSE;
-
-  /* Create .glink for lazy dynamic linking support.  */
-  htab->glink = bfd_make_section_anyway_with_flags (dynobj, ".glink",
-						    flags);
-  if (htab->glink == NULL
-      || ! bfd_set_section_alignment (dynobj, htab->glink, 3))
-    return FALSE;
-
-  if (!info->no_ld_generated_unwind_info)
-    {
-      flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_HAS_CONTENTS
-	       | SEC_IN_MEMORY | SEC_LINKER_CREATED);
-      htab->glink_eh_frame = bfd_make_section_anyway_with_flags (dynobj,
-								 ".eh_frame",
-								 flags);
-      if (htab->glink_eh_frame == NULL
-	  || !bfd_set_section_alignment (abfd, htab->glink_eh_frame, 2))
-	return FALSE;
-    }
-
-  flags = SEC_ALLOC | SEC_LINKER_CREATED;
-  htab->iplt = bfd_make_section_anyway_with_flags (dynobj, ".iplt", flags);
-  if (htab->iplt == NULL
-      || ! bfd_set_section_alignment (dynobj, htab->iplt, 3))
-    return FALSE;
-
-  flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY
-	   | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED);
-  htab->reliplt = bfd_make_section_anyway_with_flags (dynobj,
-						      ".rela.iplt",
-						      flags);
-  if (htab->reliplt == NULL
-      || ! bfd_set_section_alignment (dynobj, htab->reliplt, 3))
-    return FALSE;
-
-  /* Create branch lookup table for plt_branch stubs.  */
-  flags = (SEC_ALLOC | SEC_LOAD
-	   | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED);
-  htab->brlt = bfd_make_section_anyway_with_flags (dynobj, ".branch_lt",
-						   flags);
-  if (htab->brlt == NULL
-      || ! bfd_set_section_alignment (dynobj, htab->brlt, 3))
-    return FALSE;
-
-  if (!info->shared)
-    return TRUE;
-
-  flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY
-	   | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED);
-  htab->relbrlt = bfd_make_section_anyway_with_flags (dynobj,
-						      ".rela.branch_lt",
-						      flags);
-  if (htab->relbrlt == NULL
-      || ! bfd_set_section_alignment (dynobj, htab->relbrlt, 3))
-    return FALSE;
-
-  return TRUE;
-}
-
 /* Create .got and .rela.got sections in ABFD, and .got in dynobj if
    not already done.  */
 
@@ -4289,15 +4475,9 @@
   if (htab == NULL)
     return FALSE;
 
-  if (!htab->got)
-    {
-      if (! _bfd_elf_create_got_section (htab->elf.dynobj, info))
-	return FALSE;
-
-      htab->got = bfd_get_section_by_name (htab->elf.dynobj, ".got");
-      if (!htab->got)
-	abort ();
-    }
+  if (!htab->elf.sgot
+      && !_bfd_elf_create_got_section (htab->elf.dynobj, info))
+    return FALSE;
 
   flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
 	   | SEC_LINKER_CREATED);
@@ -4332,15 +4512,11 @@
   if (htab == NULL)
     return FALSE;
 
-  if (!htab->got)
-    htab->got = bfd_get_section_by_name (dynobj, ".got");
-  htab->plt = bfd_get_section_by_name (dynobj, ".plt");
-  htab->relplt = bfd_get_section_by_name (dynobj, ".rela.plt");
-  htab->dynbss = bfd_get_section_by_name (dynobj, ".dynbss");
+  htab->dynbss = bfd_get_linker_section (dynobj, ".dynbss");
   if (!info->shared)
-    htab->relbss = bfd_get_section_by_name (dynobj, ".rela.bss");
+    htab->relbss = bfd_get_linker_section (dynobj, ".rela.bss");
 
-  if (!htab->got || !htab->plt || !htab->relplt || !htab->dynbss
+  if (!htab->elf.sgot || !htab->elf.splt || !htab->elf.srelplt || !htab->dynbss
       || (!info->shared && !htab->relbss))
     abort ();
 
@@ -4435,10 +4611,7 @@
   edir->elf.ref_regular |= eind->elf.ref_regular;
   edir->elf.ref_regular_nonweak |= eind->elf.ref_regular_nonweak;
   edir->elf.needs_plt |= eind->elf.needs_plt;
-
-  /* If we were called to copy over info for a weak sym, that's all.  */
-  if (eind->elf.root.type != bfd_link_hash_indirect)
-    return;
+  edir->elf.pointer_equality_needed |= eind->elf.pointer_equality_needed;
 
   /* Copy over any dynamic relocs we may have on the indirect sym.  */
   if (eind->dyn_relocs != NULL)
@@ -4472,6 +4645,16 @@
       eind->dyn_relocs = NULL;
     }
 
+  /* If we were called to copy over info for a weak sym, that's all.
+     You might think dyn_relocs need not be copied over;  After all,
+     both syms will be dynamic or both non-dynamic so we're just
+     moving reloc accounting around.  However, ELIMINATE_COPY_RELOCS
+     code in ppc64_elf_adjust_dynamic_symbol needs to check for
+     dyn_relocs in read-only sections, and it does so on what is the
+     DIR sym here.  */
+  if (eind->elf.root.type != bfd_link_hash_indirect)
+    return;
+
   /* Copy over got entries that we may have already seen to the
      symbol which just became indirect.  */
   if (eind->elf.got.glist != NULL)
@@ -4587,7 +4770,7 @@
 ppc64_elf_add_symbol_hook (bfd *ibfd,
 			   struct bfd_link_info *info,
 			   Elf_Internal_Sym *isym,
-			   const char **name ATTRIBUTE_UNUSED,
+			   const char **name,
 			   flagword *flags ATTRIBUTE_UNUSED,
 			   asection **sec,
 			   bfd_vma *value ATTRIBUTE_UNUSED)
@@ -4607,9 +4790,35 @@
 	   && strcmp ((*sec)->name, ".opd") == 0)
     isym->st_info = ELF_ST_INFO (ELF_ST_BIND (isym->st_info), STT_FUNC);
 
+  if ((STO_PPC64_LOCAL_MASK & isym->st_other) != 0)
+    {
+      if (abiversion (ibfd) == 0)
+	set_abiversion (ibfd, 2);
+      else if (abiversion (ibfd) == 1)
+	{
+	  info->callbacks->einfo (_("%P: symbol '%s' has invalid st_other"
+				    " for ABI version 1\n"), name);
+	  bfd_set_error (bfd_error_bad_value);
+	  return FALSE;
+	}
+    }
+
   return TRUE;
 }
 
+/* Merge non-visibility st_other attributes: local entry point.  */
+
+static void
+ppc64_elf_merge_symbol_attribute (struct elf_link_hash_entry *h,
+				  const Elf_Internal_Sym *isym,
+				  bfd_boolean definition,
+				  bfd_boolean dynamic)
+{
+  if (definition && !dynamic)
+    h->other = ((isym->st_other & ~ELF_ST_VISIBILITY (-1))
+		| ELF_ST_VISIBILITY (h->other));
+}
+
 /* This function makes an old ABI object reference to ".bar" cause the
    inclusion of a new ABI object archive that defines "bar".
    NAME is a symbol defined in an archive.  Return a symbol in the hash
@@ -4733,7 +4942,12 @@
       while ((eh = *p) != NULL)
 	{
 	  *p = NULL;
-	  if (!add_symbol_adjust (eh, info))
+	  if (&eh->elf == htab->elf.hgot)
+	    ;
+	  else if (htab->elf.hgot == NULL
+		   && strcmp (eh->elf.root.root.string, ".TOC.") == 0)
+	    htab->elf.hgot = &eh->elf;
+	  else if (!add_symbol_adjust (eh, info))
 	    return FALSE;
 	  p = &eh->u.next_dot_sym;
 	}
@@ -4761,16 +4975,20 @@
    not to be needed.  */
 
 static bfd_boolean
-ppc64_elf_as_needed_cleanup (bfd *ibfd ATTRIBUTE_UNUSED,
-			     struct bfd_link_info *info)
+ppc64_elf_notice_as_needed (bfd *ibfd,
+			    struct bfd_link_info *info,
+			    enum notice_asneeded_action act)
 {
-  struct ppc_link_hash_table *htab = ppc_hash_table (info);
+  if (act == notice_not_needed)
+    {
+      struct ppc_link_hash_table *htab = ppc_hash_table (info);
 
-  if (htab == NULL)
-    return FALSE;
+      if (htab == NULL)
+	return FALSE;
 
-  htab->dot_syms = NULL;
-  return TRUE;
+      htab->dot_syms = NULL;
+    }
+  return _bfd_elf_notice_as_needed (ibfd, info, act);
 }
 
 /* If --just-symbols against a final linked binary, then assume we need
@@ -4936,6 +5154,15 @@
 	 information about the associated function section.  */
       bfd_size_type amt;
 
+      if (abiversion (abfd) == 0)
+	set_abiversion (abfd, 1);
+      else if (abiversion (abfd) == 2)
+	{
+	  info->callbacks->einfo (_("%P: .opd not allowed in ABI version %d\n"),
+				  abiversion (abfd));
+	  bfd_set_error (bfd_error_bad_value);
+	  return FALSE;
+	}
       amt = sec->size * sizeof (*opd_sym_map) / 8;
       opd_sym_map = bfd_zalloc (abfd, amt);
       if (opd_sym_map == NULL)
@@ -4945,10 +5172,6 @@
       ppc64_elf_section_data (sec)->sec_type = sec_opd;
     }
 
-  if (htab->sfpr == NULL
-      && !create_linkage_sections (htab->elf.dynobj, info))
-    return FALSE;
-
   rel_end = relocs + sec->reloc_count;
   for (rel = relocs; rel < rel_end; rel++)
     {
@@ -4966,6 +5189,13 @@
 	{
 	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
 	  h = elf_follow_link (h);
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
+
+	  if (h == htab->elf.hgot)
+	    sec->has_toc_reloc = 1;
 	}
 
       tls_type = 0;
@@ -5111,6 +5341,14 @@
 	    if (!update_local_sym_info (abfd, symtab_hdr, r_symndx,
 					rel->r_addend, tls_type))
 	      return FALSE;
+
+	  /* We may also need a plt entry if the symbol turns out to be
+	     an ifunc.  */
+	  if (h != NULL && !info->shared && abiversion (abfd) == 2)
+	    {
+	      if (!update_plt_info (abfd, &h->plt.plist, rel->r_addend))
+		return FALSE;
+	    }
 	  break;
 
 	case R_PPC64_PLT16_HA:
@@ -5156,6 +5394,8 @@
 	case R_PPC64_DTPREL16_HA:
 	case R_PPC64_DTPREL16_DS:
 	case R_PPC64_DTPREL16_LO_DS:
+	case R_PPC64_DTPREL16_HIGH:
+	case R_PPC64_DTPREL16_HIGHA:
 	case R_PPC64_DTPREL16_HIGHER:
 	case R_PPC64_DTPREL16_HIGHERA:
 	case R_PPC64_DTPREL16_HIGHEST:
@@ -5316,6 +5556,8 @@
 	case R_PPC64_TPREL16_HA:
 	case R_PPC64_TPREL16_DS:
 	case R_PPC64_TPREL16_LO_DS:
+	case R_PPC64_TPREL16_HIGH:
+	case R_PPC64_TPREL16_HIGHA:
 	case R_PPC64_TPREL16_HIGHER:
 	case R_PPC64_TPREL16_HIGHERA:
 	case R_PPC64_TPREL16_HIGHEST:
@@ -5359,22 +5601,35 @@
 	    }
 	  /* Fall through.  */
 
-	case R_PPC64_REL30:
-	case R_PPC64_REL32:
-	case R_PPC64_REL64:
-	case R_PPC64_ADDR14:
-	case R_PPC64_ADDR14_BRNTAKEN:
-	case R_PPC64_ADDR14_BRTAKEN:
 	case R_PPC64_ADDR16:
 	case R_PPC64_ADDR16_DS:
 	case R_PPC64_ADDR16_HA:
 	case R_PPC64_ADDR16_HI:
+	case R_PPC64_ADDR16_HIGH:
+	case R_PPC64_ADDR16_HIGHA:
 	case R_PPC64_ADDR16_HIGHER:
 	case R_PPC64_ADDR16_HIGHERA:
 	case R_PPC64_ADDR16_HIGHEST:
 	case R_PPC64_ADDR16_HIGHESTA:
 	case R_PPC64_ADDR16_LO:
 	case R_PPC64_ADDR16_LO_DS:
+	  if (h != NULL && !info->shared && abiversion (abfd) == 2
+	      && rel->r_addend == 0)
+	    {
+	      /* We may need a .plt entry if this reloc refers to a
+		 function in a shared lib.  */
+	      if (!update_plt_info (abfd, &h->plt.plist, rel->r_addend))
+		return FALSE;
+	      h->pointer_equality_needed = 1;
+	    }
+	  /* Fall through.  */
+
+	case R_PPC64_REL30:
+	case R_PPC64_REL32:
+	case R_PPC64_REL64:
+	case R_PPC64_ADDR14:
+	case R_PPC64_ADDR14_BRNTAKEN:
+	case R_PPC64_ADDR14_BRTAKEN:
 	case R_PPC64_ADDR24:
 	case R_PPC64_ADDR32:
 	case R_PPC64_UADDR16:
@@ -5414,7 +5669,7 @@
 	  if ((info->shared
 	       && (must_be_dyn_reloc (info, r_type)
 		   || (h != NULL
-		       && (! info->symbolic
+		       && (!SYMBOLIC_BIND (info, h)
 			   || h->root.type == bfd_link_hash_defweak
 			   || !h->def_regular))))
 	      || (ELIMINATE_COPY_RELOCS
@@ -5425,9 +5680,6 @@
 	      || (!info->shared
 		  && ifunc != NULL))
 	    {
-	      struct elf_dyn_relocs *p;
-	      struct elf_dyn_relocs **head;
-
 	      /* We must copy these reloc types into the output file.
 		 Create a reloc section in dynobj and make room for
 		 this reloc.  */
@@ -5444,13 +5696,34 @@
 		 relocations we need for this symbol.  */
 	      if (h != NULL)
 		{
+		  struct elf_dyn_relocs *p;
+		  struct elf_dyn_relocs **head;
+
 		  head = &((struct ppc_link_hash_entry *) h)->dyn_relocs;
+		  p = *head;
+		  if (p == NULL || p->sec != sec)
+		    {
+		      p = bfd_alloc (htab->elf.dynobj, sizeof *p);
+		      if (p == NULL)
+			return FALSE;
+		      p->next = *head;
+		      *head = p;
+		      p->sec = sec;
+		      p->count = 0;
+		      p->pc_count = 0;
+		    }
+		  p->count += 1;
+		  if (!must_be_dyn_reloc (info, r_type))
+		    p->pc_count += 1;
 		}
 	      else
 		{
 		  /* Track dynamic relocs needed for local syms too.
 		     We really need local syms available to do this
 		     easily.  Oh well.  */
+		  struct ppc_dyn_relocs *p;
+		  struct ppc_dyn_relocs **head;
+		  bfd_boolean is_ifunc;
 		  asection *s;
 		  void *vpp;
 		  Elf_Internal_Sym *isym;
@@ -5465,25 +5738,24 @@
 		    s = sec;
 
 		  vpp = &elf_section_data (s)->local_dynrel;
-		  head = (struct elf_dyn_relocs **) vpp;
+		  head = (struct ppc_dyn_relocs **) vpp;
+		  is_ifunc = ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC;
+		  p = *head;
+		  if (p != NULL && p->sec == sec && p->ifunc != is_ifunc)
+		    p = p->next;
+		  if (p == NULL || p->sec != sec || p->ifunc != is_ifunc)
+		    {
+		      p = bfd_alloc (htab->elf.dynobj, sizeof *p);
+		      if (p == NULL)
+			return FALSE;
+		      p->next = *head;
+		      *head = p;
+		      p->sec = sec;
+		      p->ifunc = is_ifunc;
+		      p->count = 0;
+		    }
+		  p->count += 1;
 		}
-
-	      p = *head;
-	      if (p == NULL || p->sec != sec)
-		{
-		  p = bfd_alloc (htab->elf.dynobj, sizeof *p);
-		  if (p == NULL)
-		    return FALSE;
-		  p->next = *head;
-		  *head = p;
-		  p->sec = sec;
-		  p->count = 0;
-		  p->pc_count = 0;
-		}
-
-	      p->count += 1;
-	      if (!must_be_dyn_reloc (info, r_type))
-		p->pc_count += 1;
 	    }
 	  break;
 
@@ -5495,6 +5767,78 @@
   return TRUE;
 }
 
+/* Merge backend specific data from an object file to the output
+   object file when linking.  */
+
+static bfd_boolean
+ppc64_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
+{
+  unsigned long iflags, oflags;
+
+  if ((ibfd->flags & BFD_LINKER_CREATED) != 0)
+    return TRUE;
+
+  if (!is_ppc64_elf (ibfd) || !is_ppc64_elf (obfd))
+    return TRUE;
+
+  if (!_bfd_generic_verify_endian_match (ibfd, obfd))
+    return FALSE;
+
+  iflags = elf_elfheader (ibfd)->e_flags;
+  oflags = elf_elfheader (obfd)->e_flags;
+
+  if (!elf_flags_init (obfd) || oflags == 0)
+    {
+      elf_flags_init (obfd) = TRUE;
+      elf_elfheader (obfd)->e_flags = iflags;
+    }
+  else if (iflags == oflags || iflags == 0)
+    ;
+  else if (iflags & ~EF_PPC64_ABI)
+    {
+      (*_bfd_error_handler)
+	(_("%B uses unknown e_flags 0x%lx"), ibfd, iflags);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+  else
+    {
+      (*_bfd_error_handler)
+	(_("%B: ABI version %ld is not compatible with ABI version %ld output"),
+	 ibfd, iflags, oflags);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+
+  /* Merge Tag_compatibility attributes and any common GNU ones.  */
+  _bfd_elf_merge_object_attributes (ibfd, obfd);
+
+  return TRUE;
+}
+
+static bfd_boolean
+ppc64_elf_print_private_bfd_data (bfd *abfd, void *ptr)
+{
+  /* Print normal ELF private data.  */
+  _bfd_elf_print_private_bfd_data (abfd, ptr);
+
+  if (elf_elfheader (abfd)->e_flags != 0)
+    {
+      FILE *file = ptr;
+
+      /* xgettext:c-format */
+      fprintf (file, _("private flags = 0x%lx:"),
+	       elf_elfheader (abfd)->e_flags);
+
+      if ((elf_elfheader (abfd)->e_flags & EF_PPC64_ABI) != 0)
+	fprintf (file, _(" [abiv%ld]"),
+		 elf_elfheader (abfd)->e_flags & EF_PPC64_ABI);
+      fputc ('\n', file);
+    }
+
+  return TRUE;
+}
+
 /* OFFSET in OPD_SEC specifies a function descriptor.  Return the address
    of the code entry point, and its section.  */
 
@@ -5514,12 +5858,16 @@
      at a final linked executable with addr2line or somesuch.  */
   if (opd_sec->reloc_count == 0)
     {
-      char buf[8];
+      bfd_byte *contents = ppc64_elf_tdata (opd_bfd)->opd.contents;
 
-      if (!bfd_get_section_contents (opd_bfd, opd_sec, buf, offset, 8))
-	return (bfd_vma) -1;
+      if (contents == NULL)
+	{
+	  if (!bfd_malloc_and_get_section (opd_bfd, opd_sec, &contents))
+	    return (bfd_vma) -1;
+	  ppc64_elf_tdata (opd_bfd)->opd.contents = contents;
+	}
 
-      val = bfd_get_64 (opd_bfd, buf);
+      val = bfd_get_64 (opd_bfd, contents + offset);
       if (code_sec != NULL)
 	{
 	  asection *sec, *likely = NULL;
@@ -5551,7 +5899,7 @@
 
   BFD_ASSERT (is_ppc64_elf (opd_bfd));
 
-  relocs = ppc64_elf_tdata (opd_bfd)->opd_relocs;
+  relocs = ppc64_elf_tdata (opd_bfd)->opd.relocs;
   if (relocs == NULL)
     relocs = _bfd_elf_link_read_relocs (opd_bfd, opd_sec, NULL, NULL, TRUE);
 
@@ -5577,15 +5925,18 @@
 	      unsigned long symndx = ELF64_R_SYM (look->r_info);
 	      asection *sec;
 
-	      if (symndx < symtab_hdr->sh_info)
+	      if (symndx < symtab_hdr->sh_info
+		  || elf_sym_hashes (opd_bfd) == NULL)
 		{
 		  Elf_Internal_Sym *sym;
 
 		  sym = (Elf_Internal_Sym *) symtab_hdr->contents;
 		  if (sym == NULL)
 		    {
-		      sym = bfd_elf_get_elf_syms (opd_bfd, symtab_hdr,
-						  symtab_hdr->sh_info,
+		      size_t symcnt = symtab_hdr->sh_info;
+		      if (elf_sym_hashes (opd_bfd) == NULL)
+			symcnt = symtab_hdr->sh_size / symtab_hdr->sh_entsize;
+		      sym = bfd_elf_get_elf_syms (opd_bfd, symtab_hdr, symcnt,
 						  0, NULL, NULL, NULL);
 		      if (sym == NULL)
 			break;
@@ -5604,11 +5955,30 @@
 
 		  sym_hashes = elf_sym_hashes (opd_bfd);
 		  rh = sym_hashes[symndx - symtab_hdr->sh_info];
-		  rh = elf_follow_link (rh);
-		  BFD_ASSERT (rh->root.type == bfd_link_hash_defined
-			      || rh->root.type == bfd_link_hash_defweak);
-		  val = rh->root.u.def.value;
-		  sec = rh->root.u.def.section;
+		  if (rh != NULL)
+		    {
+		      rh = elf_follow_link (rh);
+		      BFD_ASSERT (rh->root.type == bfd_link_hash_defined
+				  || rh->root.type == bfd_link_hash_defweak);
+		      val = rh->root.u.def.value;
+		      sec = rh->root.u.def.section;
+		    }
+		  else
+		    {
+		      /* Handle the odd case where we can be called
+			 during bfd_elf_link_add_symbols before the
+			 symbol hashes have been fully populated.  */
+		      Elf_Internal_Sym *sym;
+
+		      sym = bfd_elf_get_elf_syms (opd_bfd, symtab_hdr, 1,
+						  symndx, NULL, NULL, NULL);
+		      if (sym == NULL)
+			break;
+
+		      val = sym->st_value;
+		      sec = bfd_section_from_elf_index (opd_bfd, sym->st_shndx);
+		      free (sym);
+		    }
 		}
 	      val += look->r_addend;
 	      if (code_off != NULL)
@@ -6151,7 +6521,7 @@
 savegpr0_tail (bfd *abfd, bfd_byte *p, int r)
 {
   p = savegpr0 (abfd, p, r);
-  bfd_put_32 (abfd, STD_R0_0R1 + 16, p);
+  bfd_put_32 (abfd, STD_R0_0R1 + STK_LR, p);
   p = p + 4;
   bfd_put_32 (abfd, BLR, p);
   return p + 4;
@@ -6167,7 +6537,7 @@
 static bfd_byte *
 restgpr0_tail (bfd *abfd, bfd_byte *p, int r)
 {
-  bfd_put_32 (abfd, LD_R0_0R1 + 16, p);
+  bfd_put_32 (abfd, LD_R0_0R1 + STK_LR, p);
   p = p + 4;
   p = restgpr0 (abfd, p, r);
   bfd_put_32 (abfd, MTLR_R0, p);
@@ -6222,7 +6592,7 @@
 savefpr0_tail (bfd *abfd, bfd_byte *p, int r)
 {
   p = savefpr (abfd, p, r);
-  bfd_put_32 (abfd, STD_R0_0R1 + 16, p);
+  bfd_put_32 (abfd, STD_R0_0R1 + STK_LR, p);
   p = p + 4;
   bfd_put_32 (abfd, BLR, p);
   return p + 4;
@@ -6238,7 +6608,7 @@
 static bfd_byte *
 restfpr0_tail (bfd *abfd, bfd_byte *p, int r)
 {
-  bfd_put_32 (abfd, LD_R0_0R1 + 16, p);
+  bfd_put_32 (abfd, LD_R0_0R1 + STK_LR, p);
   p = p + 4;
   p = restfpr (abfd, p, r);
   bfd_put_32 (abfd, MTLR_R0, p);
@@ -6445,7 +6815,7 @@
 {
   struct ppc_link_hash_table *htab;
   unsigned int i;
-  const struct sfpr_def_parms funcs[] =
+  static const struct sfpr_def_parms funcs[] =
     {
       { "_savegpr0_", 14, 31, savegpr0, savegpr0_tail },
       { "_restgpr0_", 14, 29, restgpr0, restgpr0_tail },
@@ -6465,15 +6835,31 @@
   if (htab == NULL)
     return FALSE;
 
+  if (!info->relocatable
+      && htab->elf.hgot != NULL)
+    {
+      _bfd_elf_link_hash_hide_symbol (info, htab->elf.hgot, TRUE);
+      /* Make .TOC. defined so as to prevent it being made dynamic.
+	 The wrong value here is fixed later in ppc64_elf_set_toc.  */
+      htab->elf.hgot->type = STT_OBJECT;
+      htab->elf.hgot->root.type = bfd_link_hash_defined;
+      htab->elf.hgot->root.u.def.value = 0;
+      htab->elf.hgot->root.u.def.section = bfd_abs_section_ptr;
+      htab->elf.hgot->def_regular = 1;
+      htab->elf.hgot->other = ((htab->elf.hgot->other & ~ELF_ST_VISIBILITY (-1))
+			       | STV_HIDDEN);
+    }
+
   if (htab->sfpr == NULL)
     /* We don't have any relocs.  */
     return TRUE;
 
   /* Provide any missing _save* and _rest* functions.  */
   htab->sfpr->size = 0;
-  for (i = 0; i < sizeof (funcs) / sizeof (funcs[0]); i++)
-    if (!sfpr_define (info, &funcs[i]))
-      return FALSE;
+  if (!info->relocatable)
+    for (i = 0; i < sizeof (funcs) / sizeof (funcs[0]); i++)
+      if (!sfpr_define (info, &funcs[i]))
+	return FALSE;
 
   elf_link_hash_traverse (&htab->elf, func_desc_adjust, info);
 
@@ -6483,6 +6869,25 @@
   return TRUE;
 }
 
+/* Return true if we have dynamic relocs that apply to read-only sections.  */
+
+static bfd_boolean
+readonly_dynrelocs (struct elf_link_hash_entry *h)
+{
+  struct ppc_link_hash_entry *eh;
+  struct elf_dyn_relocs *p;
+
+  eh = (struct ppc_link_hash_entry *) h;
+  for (p = eh->dyn_relocs; p != NULL; p = p->next)
+    {
+      asection *s = p->sec->output_section;
+
+      if (s != NULL && (s->flags & SEC_READONLY) != 0)
+	return TRUE;
+    }
+  return FALSE;
+}
+
 /* Adjust a symbol defined by a dynamic object and referenced by a
    regular object.  The current definition is in some section of the
    dynamic object, but we're not including those sections.  We have to
@@ -6520,6 +6925,26 @@
 	  h->plt.plist = NULL;
 	  h->needs_plt = 0;
 	}
+      else if (abiversion (info->output_bfd) == 2)
+	{
+	  /* After adjust_dynamic_symbol, non_got_ref set in the
+	     non-shared case means that we have allocated space in
+	     .dynbss for the symbol and thus dyn_relocs for this
+	     symbol should be discarded.
+	     If we get here we know we are making a PLT entry for this
+	     symbol, and in an executable we'd normally resolve
+	     relocations against this symbol to the PLT entry.  Allow
+	     dynamic relocs if the reference is weak, and the dynamic
+	     relocs will not cause text relocation.  */
+	  if (!h->ref_regular_nonweak
+	      && h->non_got_ref
+	      && h->type != STT_GNU_IFUNC
+	      && !readonly_dynrelocs (h))
+	    h->non_got_ref = 0;
+
+	  /* If making a plt entry, then we don't need copy relocs.  */
+	  return TRUE;
+	}
     }
   else
     h->plt.plist = NULL;
@@ -6554,26 +6979,12 @@
   if (!h->def_dynamic || !h->ref_regular || h->def_regular)
     return TRUE;
 
-  if (ELIMINATE_COPY_RELOCS)
+  /* If we didn't find any dynamic relocs in read-only sections, then
+     we'll be keeping the dynamic relocs and avoiding the copy reloc.  */
+  if (ELIMINATE_COPY_RELOCS && !readonly_dynrelocs (h))
     {
-      struct ppc_link_hash_entry * eh;
-      struct elf_dyn_relocs *p;
-
-      eh = (struct ppc_link_hash_entry *) h;
-      for (p = eh->dyn_relocs; p != NULL; p = p->next)
-	{
-	  s = p->sec->output_section;
-	  if (s != NULL && (s->flags & SEC_READONLY) != 0)
-	    break;
-	}
-
-      /* If we didn't find any dynamic relocs in read-only sections, then
-	 we'll be keeping the dynamic relocs and avoiding the copy reloc.  */
-      if (p == NULL)
-	{
-	  h->non_got_ref = 0;
-	  return TRUE;
-	}
+      h->non_got_ref = 0;
+      return TRUE;
     }
 
   if (h->plt.plist != NULL)
@@ -6584,7 +6995,7 @@
 	 sections.  Allow them to proceed, but warn that this might
 	 break at runtime.  */
       info->callbacks->einfo
-	(_("%P: copy reloc against `%s' requires lazy plt linking; "
+	(_("%P: copy reloc against `%T' requires lazy plt linking; "
 	   "avoid setting LD_BIND_NOW=1 or upgrade gcc\n"),
 	 h->root.root.string);
     }
@@ -6592,13 +7003,6 @@
   /* This is a reference to a symbol defined by a dynamic object which
      is not a function.  */
 
-  if (h->size == 0)
-    {
-      info->callbacks->einfo (_("%P: dynamic variable `%s' is zero size\n"),
-			      h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -6613,7 +7017,7 @@
      to copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rela.bss section we are going to use.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       htab->relbss->size += sizeof (Elf64_External_Rela);
       h->needs_copy = 1;
@@ -6914,7 +7318,7 @@
 	  if (dsec == NULL)
 	    {
 	      for (dsec = sym_sec->owner->sections; dsec; dsec = dsec->next)
-		if (elf_discarded_section (dsec))
+		if (discarded_section (dsec))
 		  {
 		    ppc64_elf_tdata (sym_sec->owner)->deleted_section = dsec;
 		    break;
@@ -6931,7 +7335,7 @@
 }
 
 /* Handles decrementing dynamic reloc counts for the reloc specified by
-   R_INFO in section SEC.  If LOCAL_SYMS is NULL, then H and SYM_SEC
+   R_INFO in section SEC.  If LOCAL_SYMS is NULL, then H and SYM
    have already been determined.  */
 
 static bfd_boolean
@@ -6940,11 +7344,10 @@
 		  struct bfd_link_info *info,
 		  Elf_Internal_Sym **local_syms,
 		  struct elf_link_hash_entry *h,
-		  asection *sym_sec)
+		  Elf_Internal_Sym *sym)
 {
   enum elf_ppc64_reloc_type r_type;
-  struct elf_dyn_relocs *p;
-  struct elf_dyn_relocs **pp;
+  asection *sym_sec = NULL;
 
   /* Can this reloc be dynamic?  This switch, and later tests here
      should be kept in sync with the code in check_relocs.  */
@@ -6960,6 +7363,8 @@
     case R_PPC64_TPREL16_HA:
     case R_PPC64_TPREL16_DS:
     case R_PPC64_TPREL16_LO_DS:
+    case R_PPC64_TPREL16_HIGH:
+    case R_PPC64_TPREL16_HIGHA:
     case R_PPC64_TPREL16_HIGHER:
     case R_PPC64_TPREL16_HIGHERA:
     case R_PPC64_TPREL16_HIGHEST:
@@ -6981,6 +7386,8 @@
     case R_PPC64_ADDR16_DS:
     case R_PPC64_ADDR16_HA:
     case R_PPC64_ADDR16_HI:
+    case R_PPC64_ADDR16_HIGH:
+    case R_PPC64_ADDR16_HIGHA:
     case R_PPC64_ADDR16_HIGHER:
     case R_PPC64_ADDR16_HIGHERA:
     case R_PPC64_ADDR16_HIGHEST:
@@ -6999,7 +7406,6 @@
   if (local_syms != NULL)
     {
       unsigned long r_symndx;
-      Elf_Internal_Sym *sym;
       bfd *ibfd = sec->owner;
 
       r_symndx = ELF64_R_SYM (r_info);
@@ -7010,7 +7416,7 @@
   if ((info->shared
        && (must_be_dyn_reloc (info, r_type)
 	   || (h != NULL
-	       && (!info->symbolic
+	       && (!SYMBOLIC_BIND (info, h)
 		   || h->root.type == bfd_link_hash_defweak
 		   || !h->def_regular))))
       || (ELIMINATE_COPY_RELOCS
@@ -7023,39 +7429,62 @@
     return TRUE;
 
   if (h != NULL)
-    pp = &((struct ppc_link_hash_entry *) h)->dyn_relocs;
-  else
     {
-      if (sym_sec != NULL)
-	{
-	  void *vpp = &elf_section_data (sym_sec)->local_dynrel;
-	  pp = (struct elf_dyn_relocs **) vpp;
-	}
-      else
-	{
-	  void *vpp = &elf_section_data (sec)->local_dynrel;
-	  pp = (struct elf_dyn_relocs **) vpp;
-	}
+      struct elf_dyn_relocs *p;
+      struct elf_dyn_relocs **pp;
+      pp = &((struct ppc_link_hash_entry *) h)->dyn_relocs;
 
       /* elf_gc_sweep may have already removed all dyn relocs associated
-	 with local syms for a given section.  Don't report a dynreloc
-	 miscount.  */
-      if (*pp == NULL)
+	 with local syms for a given section.  Also, symbol flags are
+	 changed by elf_gc_sweep_symbol, confusing the test above.  Don't
+	 report a dynreloc miscount.  */
+      if (*pp == NULL && info->gc_sections)
 	return TRUE;
-    }
 
-  while ((p = *pp) != NULL)
-    {
-      if (p->sec == sec)
+      while ((p = *pp) != NULL)
 	{
-	  if (!must_be_dyn_reloc (info, r_type))
-	    p->pc_count -= 1;
-	  p->count -= 1;
-	  if (p->count == 0)
-	    *pp = p->next;
-	  return TRUE;
+	  if (p->sec == sec)
+	    {
+	      if (!must_be_dyn_reloc (info, r_type))
+		p->pc_count -= 1;
+	      p->count -= 1;
+	      if (p->count == 0)
+		*pp = p->next;
+	      return TRUE;
+	    }
+	  pp = &p->next;
 	}
-      pp = &p->next;
+    }
+  else
+    {
+      struct ppc_dyn_relocs *p;
+      struct ppc_dyn_relocs **pp;
+      void *vpp;
+      bfd_boolean is_ifunc;
+
+      if (local_syms == NULL)
+	sym_sec = bfd_section_from_elf_index (sec->owner, sym->st_shndx);
+      if (sym_sec == NULL)
+	sym_sec = sec;
+
+      vpp = &elf_section_data (sym_sec)->local_dynrel;
+      pp = (struct ppc_dyn_relocs **) vpp;
+
+      if (*pp == NULL && info->gc_sections)
+	return TRUE;
+
+      is_ifunc = ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC;
+      while ((p = *pp) != NULL)
+	{
+	  if (p->sec == sec && p->ifunc == is_ifunc)
+	    {
+	      p->count -= 1;
+	      if (p->count == 0)
+		*pp = p->next;
+	      return TRUE;
+	    }
+	  pp = &p->next;
+	}
     }
 
   info->callbacks->einfo (_("%P: dynreloc miscount for %B, section %A\n"),
@@ -7095,7 +7524,7 @@
       if (sec == NULL || sec->size == 0)
 	continue;
 
-      if (sec->sec_info_type == ELF_INFO_TYPE_JUST_SYMS)
+      if (sec->sec_info_type == SEC_INFO_TYPE_JUST_SYMS)
 	continue;
 
       if (sec->output_section == bfd_abs_section_ptr)
@@ -7388,7 +7817,7 @@
 		  if (!NO_OPD_RELOCS
 		      && !info->relocatable
 		      && !dec_dynrel_count (rel->r_info, sec, info,
-					    NULL, h, sym_sec))
+					    NULL, h, sym))
 		    goto error_ret;
 		}
 	      else
@@ -7483,6 +7912,9 @@
   if (htab == NULL)
     return NULL;
 
+  if (abiversion (info->output_bfd) == 1)
+    htab->opd_abi = 1;
+
   if (*no_multi_toc)
     htab->do_multi_toc = 0;
   else if (!htab->do_multi_toc)
@@ -7995,13 +8427,13 @@
 		      /* 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))
+					     NULL, h, sym))
 			return FALSE;
 
 		      if (tls_set == (TLS_EXPLICIT | TLS_GD))
 			{
 			  if (!dec_dynrel_count ((rel + 1)->r_info, sec, info,
-						 NULL, h, sym_sec))
+						 NULL, h, sym))
 			    return FALSE;
 			}
 		    }
@@ -8139,8 +8571,8 @@
       toc = bfd_get_section_by_name (ibfd, ".toc");
       if (toc == NULL
 	  || toc->size == 0
-	  || toc->sec_info_type == ELF_INFO_TYPE_JUST_SYMS
-	  || elf_discarded_section (toc))
+	  || toc->sec_info_type == SEC_INFO_TYPE_JUST_SYMS
+	  || discarded_section (toc))
 	continue;
 
       toc_relocs = NULL;
@@ -8153,7 +8585,7 @@
       for (sec = ibfd->sections; sec != NULL; sec = sec->next)
 	{
 	  if (sec->reloc_count == 0
-	      || !elf_discarded_section (sec)
+	      || !discarded_section (sec)
 	      || get_opd_info (sec)
 	      || (sec->flags & SEC_ALLOC) == 0
 	      || (sec->flags & SEC_DEBUGGING) != 0)
@@ -8233,7 +8665,7 @@
 	 .  addi ry,rx,addr@toc@l
 	 when addr is within 2G of the toc pointer.  This then means
 	 that the word storing "addr" in the toc is no longer needed.  */
-	 
+
       if (!ppc64_elf_tdata (ibfd)->has_small_toc_reloc
 	  && toc->output_section->rawsize < (bfd_vma) 1 << 31
 	  && toc->reloc_count != 0)
@@ -8263,10 +8695,10 @@
 		goto error_ret;
 
 	      if (sym_sec == NULL
-		  || elf_discarded_section (sym_sec))
+		  || discarded_section (sym_sec))
 		continue;
 
-	      if (!SYMBOL_CALLS_LOCAL (info, h))
+	      if (!SYMBOL_REFERENCES_LOCAL (info, h))
 		continue;
 
 	      if (h != NULL)
@@ -8343,7 +8775,7 @@
 	  int repeat;
 
 	  if (sec->reloc_count == 0
-	      || elf_discarded_section (sec)
+	      || discarded_section (sec)
 	      || get_opd_info (sec)
 	      || (sec->flags & SEC_ALLOC) == 0
 	      || (sec->flags & SEC_DEBUGGING) != 0)
@@ -8355,150 +8787,156 @@
 	    goto error_ret;
 
 	  /* Mark toc entries referenced as used.  */
-	  repeat = 0;
 	  do
-	    for (rel = relstart; rel < relstart + sec->reloc_count; ++rel)
-	      {
-		enum elf_ppc64_reloc_type r_type;
-		unsigned long r_symndx;
-		asection *sym_sec;
-		struct elf_link_hash_entry *h;
-		Elf_Internal_Sym *sym;
-		bfd_vma val;
-		enum {no_check, check_lo, check_ha} insn_check;
+	    {
+	      repeat = 0;
+	      for (rel = relstart; rel < relstart + sec->reloc_count; ++rel)
+		{
+		  enum elf_ppc64_reloc_type r_type;
+		  unsigned long r_symndx;
+		  asection *sym_sec;
+		  struct elf_link_hash_entry *h;
+		  Elf_Internal_Sym *sym;
+		  bfd_vma val;
+		  enum {no_check, check_lo, check_ha} insn_check;
 
-		r_type = ELF64_R_TYPE (rel->r_info);
-		switch (r_type)
-		  {
-		  default:
-		    insn_check = no_check;
-		    break;
+		  r_type = ELF64_R_TYPE (rel->r_info);
+		  switch (r_type)
+		    {
+		    default:
+		      insn_check = no_check;
+		      break;
 
-		  case R_PPC64_GOT_TLSLD16_HA:
-		  case R_PPC64_GOT_TLSGD16_HA:
-		  case R_PPC64_GOT_TPREL16_HA:
-		  case R_PPC64_GOT_DTPREL16_HA:
-		  case R_PPC64_GOT16_HA:
-		  case R_PPC64_TOC16_HA:
-		    insn_check = check_ha;
-		    break;
+		    case R_PPC64_GOT_TLSLD16_HA:
+		    case R_PPC64_GOT_TLSGD16_HA:
+		    case R_PPC64_GOT_TPREL16_HA:
+		    case R_PPC64_GOT_DTPREL16_HA:
+		    case R_PPC64_GOT16_HA:
+		    case R_PPC64_TOC16_HA:
+		      insn_check = check_ha;
+		      break;
 
-		  case R_PPC64_GOT_TLSLD16_LO:
-		  case R_PPC64_GOT_TLSGD16_LO:
-		  case R_PPC64_GOT_TPREL16_LO_DS:
-		  case R_PPC64_GOT_DTPREL16_LO_DS:
-		  case R_PPC64_GOT16_LO:
-		  case R_PPC64_GOT16_LO_DS:
-		  case R_PPC64_TOC16_LO:
-		  case R_PPC64_TOC16_LO_DS:
-		    insn_check = check_lo;
-		    break;
-		  }
+		    case R_PPC64_GOT_TLSLD16_LO:
+		    case R_PPC64_GOT_TLSGD16_LO:
+		    case R_PPC64_GOT_TPREL16_LO_DS:
+		    case R_PPC64_GOT_DTPREL16_LO_DS:
+		    case R_PPC64_GOT16_LO:
+		    case R_PPC64_GOT16_LO_DS:
+		    case R_PPC64_TOC16_LO:
+		    case R_PPC64_TOC16_LO_DS:
+		      insn_check = check_lo;
+		      break;
+		    }
 
-		if (insn_check != no_check)
-		  {
-		    bfd_vma off = rel->r_offset & ~3;
-		    unsigned char buf[4];
-		    unsigned int insn;
+		  if (insn_check != no_check)
+		    {
+		      bfd_vma off = rel->r_offset & ~3;
+		      unsigned char buf[4];
+		      unsigned int insn;
 
-		    if (!bfd_get_section_contents (ibfd, sec, buf, off, 4))
-		      {
-			free (used);
-			goto error_ret;
-		      }
-		    insn = bfd_get_32 (ibfd, buf);
-		    if (insn_check == check_lo
-			? !ok_lo_toc_insn (insn)
-			: ((insn & ((0x3f << 26) | 0x1f << 16))
-			   != ((15u << 26) | (2 << 16)) /* addis rt,2,imm */))
-		      {
-			char str[12];
+		      if (!bfd_get_section_contents (ibfd, sec, buf, off, 4))
+			{
+			  free (used);
+			  goto error_ret;
+			}
+		      insn = bfd_get_32 (ibfd, buf);
+		      if (insn_check == check_lo
+			  ? !ok_lo_toc_insn (insn)
+			  : ((insn & ((0x3f << 26) | 0x1f << 16))
+			     != ((15u << 26) | (2 << 16)) /* addis rt,2,imm */))
+			{
+			  char str[12];
 
-			ppc64_elf_tdata (ibfd)->unexpected_toc_insn = 1;
-			sprintf (str, "%#08x", insn);
-			info->callbacks->einfo
-			  (_("%P: %H: toc optimization is not supported for"
-			     " %s instruction.\n"),
-			   ibfd, sec, rel->r_offset & ~3, str);
-		      }
-		  }
+			  ppc64_elf_tdata (ibfd)->unexpected_toc_insn = 1;
+			  sprintf (str, "%#08x", insn);
+			  info->callbacks->einfo
+			    (_("%P: %H: toc optimization is not supported for"
+			       " %s instruction.\n"),
+			     ibfd, sec, rel->r_offset & ~3, str);
+			}
+		    }
 
-		switch (r_type)
-		  {
-		  case R_PPC64_TOC16:
-		  case R_PPC64_TOC16_LO:
-		  case R_PPC64_TOC16_HI:
-		  case R_PPC64_TOC16_HA:
-		  case R_PPC64_TOC16_DS:
-		  case R_PPC64_TOC16_LO_DS:
-		    /* In case we're taking addresses of toc entries.  */
-		  case R_PPC64_ADDR64:
-		    break;
+		  switch (r_type)
+		    {
+		    case R_PPC64_TOC16:
+		    case R_PPC64_TOC16_LO:
+		    case R_PPC64_TOC16_HI:
+		    case R_PPC64_TOC16_HA:
+		    case R_PPC64_TOC16_DS:
+		    case R_PPC64_TOC16_LO_DS:
+		      /* In case we're taking addresses of toc entries.  */
+		    case R_PPC64_ADDR64:
+		      break;
 
-		  default:
+		    default:
+		      continue;
+		    }
+
+		  r_symndx = ELF64_R_SYM (rel->r_info);
+		  if (!get_sym_h (&h, &sym, &sym_sec, NULL, &local_syms,
+				  r_symndx, ibfd))
+		    {
+		      free (used);
+		      goto error_ret;
+		    }
+
+		  if (sym_sec != toc)
 		    continue;
-		  }
 
-		r_symndx = ELF64_R_SYM (rel->r_info);
-		if (!get_sym_h (&h, &sym, &sym_sec, NULL, &local_syms,
-				r_symndx, ibfd))
-		  {
-		    free (used);
-		    goto error_ret;
-		  }
+		  if (h != NULL)
+		    val = h->root.u.def.value;
+		  else
+		    val = sym->st_value;
+		  val += rel->r_addend;
 
-		if (sym_sec != toc)
-		  continue;
+		  if (val >= toc->size)
+		    continue;
 
-		if (h != NULL)
-		  val = h->root.u.def.value;
-		else
-		  val = sym->st_value;
-		val += rel->r_addend;
+		  if ((skip[val >> 3] & can_optimize) != 0)
+		    {
+		      bfd_vma off;
+		      unsigned char opc;
 
-		if (val >= toc->size)
-		  continue;
-
-		if ((skip[val >> 3] & can_optimize) != 0)
-		  {
-		    bfd_vma off;
-		    unsigned char opc;
-
-		    switch (r_type)
-		      {
-		      case R_PPC64_TOC16_HA:
-			break;
-
-		      case R_PPC64_TOC16_LO_DS:
-			off = rel->r_offset + (bfd_big_endian (ibfd) ? -2 : 3);
-			if (!bfd_get_section_contents (ibfd, sec, &opc, off, 1))
-			  {
-			    free (used);
-			    goto error_ret;
-			  }
-			if ((opc & (0x3f << 2)) == (58u << 2))
+		      switch (r_type)
+			{
+			case R_PPC64_TOC16_HA:
 			  break;
-			/* Fall thru */
 
-		      default:
-			/* Wrong sort of reloc, or not a ld.  We may
-			   as well clear ref_from_discarded too.  */
-			skip[val >> 3] = 0;
-		      }
-		  }
+			case R_PPC64_TOC16_LO_DS:
+			  off = rel->r_offset;
+			  off += (bfd_big_endian (ibfd) ? -2 : 3);
+			  if (!bfd_get_section_contents (ibfd, sec, &opc,
+							 off, 1))
+			    {
+			      free (used);
+			      goto error_ret;
+			    }
+			  if ((opc & (0x3f << 2)) == (58u << 2))
+			    break;
+			  /* Fall thru */
 
-		/* For the toc section, we only mark as used if
-		   this entry itself isn't unused.  */
-		if (sec == toc
-		    && !used[val >> 3]
-		    && (used[rel->r_offset >> 3]
-			|| !(skip[rel->r_offset >> 3] & ref_from_discarded)))
-		  /* Do all the relocs again, to catch reference
-		     chains.  */
-		  repeat = 1;
+			default:
+			  /* Wrong sort of reloc, or not a ld.  We may
+			     as well clear ref_from_discarded too.  */
+			  skip[val >> 3] = 0;
+			}
+		    }
 
-		used[val >> 3] = 1;
-	      }
+		  if (sec != toc)
+		    used[val >> 3] = 1;
+		  /* For the toc section, we only mark as used if this
+		     entry itself isn't unused.  */
+		  else if ((used[rel->r_offset >> 3]
+			    || !(skip[rel->r_offset >> 3] & ref_from_discarded))
+			   && !used[val >> 3])
+		    {
+		      /* Do all the relocs again, to catch reference
+			 chains.  */
+		      repeat = 1;
+		      used[val >> 3] = 1;
+		    }
+		}
+	    }
 	  while (repeat);
 
 	  if (elf_section_data (sec)->relocs != relstart)
@@ -8565,7 +9003,7 @@
 	  for (sec = ibfd->sections; sec != NULL; sec = sec->next)
 	    {
 	      if (sec->reloc_count == 0
-		  || elf_discarded_section (sec))
+		  || discarded_section (sec))
 		continue;
 
 	      relstart = _bfd_elf_link_read_relocs (ibfd, sec, NULL, NULL,
@@ -8640,7 +9078,7 @@
 			  if (!ppc64_elf_howto_table[R_PPC64_ADDR32])
 			    ppc_howto_init ();
 			  info->callbacks->einfo
-			    (_("%P: %H: %s relocation references "
+			    (_("%P: %H: %s references "
 			       "optimized away TOC entry\n"),
 			     ibfd, sec, rel->r_offset,
 			     ppc64_elf_howto_table[r_type]->name);
@@ -8787,20 +9225,19 @@
   got->size += entsize;
 
   dyn = htab->elf.dynamic_sections_created;
-  if ((info->shared
-       || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))
-	    && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
-		|| h->root.type != bfd_link_hash_undefweak))
+  if (h->type == STT_GNU_IFUNC)
+    {
+      htab->elf.irelplt->size += rentsize;
+      htab->got_reli_size += rentsize;
+    }
+  else if ((info->shared
+	    || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))
+	   && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+	       || h->root.type != bfd_link_hash_undefweak))
     {
       asection *relgot = ppc64_elf_tdata (gent->owner)->relgot;
       relgot->size += rentsize;
     }
-  else if (h->type == STT_GNU_IFUNC)
-    {
-      asection *relgot = htab->reliplt;
-      relgot->size += rentsize;
-      htab->got_reli_size += rentsize;
-    }
 }
 
 /* This function merges got entries in the same toc group.  */
@@ -8857,35 +9294,40 @@
 	    if (!htab->elf.dynamic_sections_created
 		|| h->dynindx == -1)
 	      {
-		s = htab->iplt;
+		s = htab->elf.iplt;
 		pent->plt.offset = s->size;
-		s->size += PLT_ENTRY_SIZE;
-		s = htab->reliplt;
+		s->size += PLT_ENTRY_SIZE (htab);
+		s = htab->elf.irelplt;
 	      }
 	    else
 	      {
 		/* If this is the first .plt entry, make room for the special
 		   first entry.  */
-		s = htab->plt;
+		s = htab->elf.splt;
 		if (s->size == 0)
-		  s->size += PLT_INITIAL_ENTRY_SIZE;
+		  s->size += PLT_INITIAL_ENTRY_SIZE (htab);
 
 		pent->plt.offset = s->size;
 
 		/* Make room for this entry.  */
-		s->size += PLT_ENTRY_SIZE;
+		s->size += PLT_ENTRY_SIZE (htab);
 
 		/* Make room for the .glink code.  */
 		s = htab->glink;
 		if (s->size == 0)
 		  s->size += GLINK_CALL_STUB_SIZE;
-		/* We need bigger stubs past index 32767.  */
-		if (s->size >= GLINK_CALL_STUB_SIZE + 32768*2*4)
+		if (htab->opd_abi)
+		  {
+		    /* We need bigger stubs past index 32767.  */
+		    if (s->size >= GLINK_CALL_STUB_SIZE + 32768*2*4)
+		      s->size += 4;
+		    s->size += 2*4;
+		  }
+		else
 		  s->size += 4;
-		s->size += 2*4;
 
 		/* We also need to make an entry in the .rela.plt section.  */
-		s = htab->relplt;
+		s = htab->elf.srelplt;
 	      }
 	    s->size += sizeof (Elf64_External_Rela);
 	    doneone = TRUE;
@@ -9063,36 +9505,73 @@
   for (p = eh->dyn_relocs; p != NULL; p = p->next)
     {
       asection *sreloc = elf_section_data (p->sec)->sreloc;
-      if (!htab->elf.dynamic_sections_created)
-	sreloc = htab->reliplt;
+      if (eh->elf.type == STT_GNU_IFUNC)
+	sreloc = htab->elf.irelplt;
       sreloc->size += p->count * sizeof (Elf64_External_Rela);
     }
 
   return TRUE;
 }
 
-/* Find any dynamic relocs that apply to read-only sections.  */
+/* Called via elf_link_hash_traverse from ppc64_elf_size_dynamic_sections
+   to set up space for global entry stubs.  These are put in glink,
+   after the branch table.  */
 
 static bfd_boolean
-readonly_dynrelocs (struct elf_link_hash_entry *h, void *inf)
+size_global_entry_stubs (struct elf_link_hash_entry *h, void *inf)
 {
-  struct ppc_link_hash_entry *eh;
-  struct elf_dyn_relocs *p;
+  struct bfd_link_info *info;
+  struct ppc_link_hash_table *htab;
+  struct plt_entry *pent;
+  asection *s;
 
-  eh = (struct ppc_link_hash_entry *) h;
-  for (p = eh->dyn_relocs; p != NULL; p = p->next)
+  if (h->root.type == bfd_link_hash_indirect)
+    return TRUE;
+
+  if (!h->pointer_equality_needed)
+    return TRUE;
+
+  if (h->def_regular)
+    return TRUE;
+
+  info = inf;
+  htab = ppc_hash_table (info);
+  if (htab == NULL)
+    return FALSE;
+
+  s = htab->glink;
+  for (pent = h->plt.plist; pent != NULL; pent = pent->next)
+    if (pent->plt.offset != (bfd_vma) -1
+	&& pent->addend == 0)
+      {
+	/* For ELFv2, if this symbol is not defined in a regular file
+	   and we are not generating a shared library or pie, then we
+	   need to define the symbol in the executable on a call stub.
+	   This is to avoid text relocations.  */
+	s->size = (s->size + 15) & -16;
+	h->root.u.def.section = s;
+	h->root.u.def.value = s->size;
+	s->size += 16;
+	break;
+      }
+  return TRUE;
+}
+
+/* Set DF_TEXTREL if we find any dynamic relocs that apply to
+   read-only sections.  */
+
+static bfd_boolean
+maybe_set_textrel (struct elf_link_hash_entry *h, void *info)
+{
+  if (h->root.type == bfd_link_hash_indirect)
+    return TRUE;
+
+  if (readonly_dynrelocs (h))
     {
-      asection *s = p->sec->output_section;
+      ((struct bfd_link_info *) info)->flags |= DF_TEXTREL;
 
-      if (s != NULL && (s->flags & SEC_READONLY) != 0)
-	{
-	  struct bfd_link_info *info = inf;
-
-	  info->flags |= DF_TEXTREL;
-
-	  /* Not an error, just cut short the traversal.  */
-	  return FALSE;
-	}
+      /* Not an error, just cut short the traversal.  */
+      return FALSE;
     }
   return TRUE;
 }
@@ -9100,7 +9579,7 @@
 /* Set the sizes of the dynamic sections.  */
 
 static bfd_boolean
-ppc64_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
+ppc64_elf_size_dynamic_sections (bfd *output_bfd,
 				 struct bfd_link_info *info)
 {
   struct ppc_link_hash_table *htab;
@@ -9123,7 +9602,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  if (s == NULL)
 	    abort ();
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
@@ -9142,14 +9621,13 @@
       unsigned char *lgot_masks;
       bfd_size_type locsymcount;
       Elf_Internal_Shdr *symtab_hdr;
-      asection *srel;
 
       if (!is_ppc64_elf (ibfd))
 	continue;
 
       for (s = ibfd->sections; s != NULL; s = s->next)
 	{
-	  struct elf_dyn_relocs *p;
+	  struct ppc_dyn_relocs *p;
 
 	  for (p = elf_section_data (s)->local_dynrel; p != NULL; p = p->next)
 	    {
@@ -9163,9 +9641,9 @@
 		}
 	      else if (p->count != 0)
 		{
-		  srel = elf_section_data (p->sec)->sreloc;
-		  if (!htab->elf.dynamic_sections_created)
-		    srel = htab->reliplt;
+		  asection *srel = elf_section_data (p->sec)->sreloc;
+		  if (p->ifunc)
+		    srel = htab->elf.irelplt;
 		  srel->size += p->count * sizeof (Elf64_External_Rela);
 		  if ((p->sec->output_section->flags & SEC_READONLY) != 0)
 		    info->flags |= DF_TEXTREL;
@@ -9184,7 +9662,6 @@
       end_local_plt = local_plt + locsymcount;
       lgot_masks = (unsigned char *) end_local_plt;
       s = ppc64_elf_tdata (ibfd)->got;
-      srel = ppc64_elf_tdata (ibfd)->relgot;
       for (; lgot_ents < end_lgot_ents; ++lgot_ents, ++lgot_masks)
 	{
 	  struct got_entry **pent, *ent;
@@ -9200,19 +9677,25 @@
 		  }
 		else
 		  {
-		    unsigned int num = 1;
+		    unsigned int ent_size = 8;
+		    unsigned int rel_size = sizeof (Elf64_External_Rela);
+
 		    ent->got.offset = s->size;
 		    if ((ent->tls_type & *lgot_masks & TLS_GD) != 0)
-		      num = 2;
-		    s->size += num * 8;
-		    if (info->shared)
-		      srel->size += num * sizeof (Elf64_External_Rela);
-		    else if ((*lgot_masks & PLT_IFUNC) != 0)
 		      {
-			htab->reliplt->size
-			  += num * sizeof (Elf64_External_Rela);
-			htab->got_reli_size
-			  += num * sizeof (Elf64_External_Rela);
+			ent_size *= 2;
+			rel_size *= 2;
+		      }
+		    s->size += ent_size;
+		    if ((*lgot_masks & PLT_IFUNC) != 0)
+		      {
+			htab->elf.irelplt->size += rel_size;
+			htab->got_reli_size += rel_size;
+		      }
+		    else if (info->shared)
+		      {
+			asection *srel = ppc64_elf_tdata (ibfd)->relgot;
+			srel->size += rel_size;
 		      }
 		    pent = &ent->next;
 		  }
@@ -9229,11 +9712,11 @@
 	  for (ent = *local_plt; ent != NULL; ent = ent->next)
 	    if (ent->plt.refcount > 0)
 	      {
-		s = htab->iplt;
+		s = htab->elf.iplt;
 		ent->plt.offset = s->size;
-		s->size += PLT_ENTRY_SIZE;
+		s->size += PLT_ENTRY_SIZE (htab);
 
-		htab->reliplt->size += sizeof (Elf64_External_Rela);
+		htab->elf.irelplt->size += sizeof (Elf64_External_Rela);
 	      }
 	    else
 	      ent->plt.offset = (bfd_vma) -1;
@@ -9243,6 +9726,12 @@
   /* Allocate global sym .plt and .got entries, and space for global
      sym dynamic relocs.  */
   elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, info);
+  /* Stash the end of glink branch table.  */
+  if (htab->glink != NULL)
+    htab->glink->rawsize = htab->glink->size;
+
+  if (!htab->opd_abi && !info->shared)
+    elf_link_hash_traverse (&htab->elf, size_global_entry_stubs, info);
 
   first_tlsld = NULL;
   for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
@@ -9290,9 +9779,9 @@
       if (s == htab->brlt || s == htab->relbrlt)
 	/* These haven't been allocated yet;  don't strip.  */
 	continue;
-      else if (s == htab->got
-	       || s == htab->plt
-	       || s == htab->iplt
+      else if (s == htab->elf.sgot
+	       || s == htab->elf.splt
+	       || s == htab->elf.iplt
 	       || s == htab->glink
 	       || s == htab->dynbss)
 	{
@@ -9309,7 +9798,7 @@
 	{
 	  if (s->size != 0)
 	    {
-	      if (s != htab->relplt)
+	      if (s != htab->elf.srelplt)
 		relocs = TRUE;
 
 	      /* We use the reloc_count field as a counter if we need
@@ -9359,7 +9848,7 @@
 	continue;
 
       s = ppc64_elf_tdata (ibfd)->got;
-      if (s != NULL && s != htab->got)
+      if (s != NULL && s != htab->elf.sgot)
 	{
 	  if (s->size == 0)
 	    s->flags |= SEC_EXCLUDE;
@@ -9388,6 +9877,8 @@
 
   if (htab->elf.dynamic_sections_created)
     {
+      bfd_boolean tls_opt;
+
       /* Add some entries to the .dynamic section.  We fill in the
 	 values later, in ppc64_elf_finish_dynamic_sections, but we
 	 must add the entries now so that we get the correct size for
@@ -9402,7 +9893,7 @@
 	    return FALSE;
 	}
 
-      if (htab->plt != NULL && htab->plt->size != 0)
+      if (htab->elf.splt != NULL && htab->elf.splt->size != 0)
 	{
 	  if (!add_dynamic_entry (DT_PLTGOT, 0)
 	      || !add_dynamic_entry (DT_PLTRELSZ, 0)
@@ -9412,18 +9903,21 @@
 	    return FALSE;
 	}
 
-      if (NO_OPD_RELOCS)
+      if (NO_OPD_RELOCS && abiversion (output_bfd) <= 1)
 	{
 	  if (!add_dynamic_entry (DT_PPC64_OPD, 0)
 	      || !add_dynamic_entry (DT_PPC64_OPDSZ, 0))
 	    return FALSE;
 	}
 
-      if (!htab->no_tls_get_addr_opt
-	  && htab->tls_get_addr_fd != NULL
-	  && htab->tls_get_addr_fd->elf.plt.plist != NULL
-	  && !add_dynamic_entry (DT_PPC64_TLSOPT, 0))
-	return FALSE;
+      tls_opt = (!htab->no_tls_get_addr_opt
+		 && htab->tls_get_addr_fd != NULL
+		 && htab->tls_get_addr_fd->elf.plt.plist != NULL);
+      if (tls_opt || !htab->opd_abi)
+	{
+	  if (!add_dynamic_entry (DT_PPC64_OPT, tls_opt ? PPC64_OPT_TLS : 0))
+	    return FALSE;
+	}
 
       if (relocs)
 	{
@@ -9435,7 +9929,7 @@
 	  /* If any dynamic relocs apply to a read-only section,
 	     then we need a DT_TEXTREL entry.  */
 	  if ((info->flags & DF_TEXTREL) == 0)
-	    elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, info);
+	    elf_link_hash_traverse (&htab->elf, maybe_set_textrel, info);
 
 	  if ((info->flags & DF_TEXTREL) != 0)
 	    {
@@ -9449,6 +9943,19 @@
   return TRUE;
 }
 
+/* Return TRUE if symbol should be hashed in the `.gnu.hash' section.  */
+
+static bfd_boolean
+ppc64_elf_hash_symbol (struct elf_link_hash_entry *h)
+{
+  if (h->plt.plist != NULL
+      && !h->def_regular
+      && !h->pointer_equality_needed)
+    return FALSE;
+
+  return _bfd_elf_hash_symbol (h);
+}
+
 /* Determine the type of stub needed, if any, for a call.  */
 
 static inline enum ppc_stub_type
@@ -9456,7 +9963,8 @@
 		  const Elf_Internal_Rela *rel,
 		  struct ppc_link_hash_entry **hash,
 		  struct plt_entry **plt_ent,
-		  bfd_vma destination)
+		  bfd_vma destination,
+		  unsigned long local_off)
 {
   struct ppc_link_hash_entry *h = *hash;
   bfd_vma location;
@@ -9525,7 +10033,7 @@
   if (r_type != R_PPC64_REL24)
     max_branch_offset = 1 << 15;
 
-  if (branch_offset + max_branch_offset >= 2 * max_branch_offset)
+  if (branch_offset + max_branch_offset >= 2 * max_branch_offset - local_off)
     /* We need a stub.  Figure out whether a long_branch or plt_branch
        is needed later.  */
     return ppc_stub_long_branch;
@@ -9533,96 +10041,244 @@
   return ppc_stub_none;
 }
 
-/* Build a .plt call stub.  */
+/* With power7 weakly ordered memory model, it is possible for ld.so
+   to update a plt entry in one thread and have another thread see a
+   stale zero toc entry.  To avoid this we need some sort of acquire
+   barrier in the call stub.  One solution is to make the load of the
+   toc word seem to appear to depend on the load of the function entry
+   word.  Another solution is to test for r2 being zero, and branch to
+   the appropriate glink entry if so.
 
-static inline bfd_byte *
-build_plt_stub (bfd *obfd, bfd_byte *p, int offset, Elf_Internal_Rela *r,
-		bfd_boolean plt_static_chain)
-{
+   .	fake dep barrier	compare
+   .	ld 12,xxx(2)		ld 12,xxx(2)
+   .	mtctr 12		mtctr 12
+   .	xor 11,12,12		ld 2,xxx+8(2)
+   .	add 2,2,11		cmpldi 2,0
+   .	ld 2,xxx+8(2)		bnectr+
+   .	bctr			b <glink_entry>
+
+   The solution involving the compare turns out to be faster, so
+   that's what we use unless the branch won't reach.  */
+
+#define ALWAYS_USE_FAKE_DEP 0
+#define ALWAYS_EMIT_R2SAVE 0
+
 #define PPC_LO(v) ((v) & 0xffff)
 #define PPC_HI(v) (((v) >> 16) & 0xffff)
 #define PPC_HA(v) PPC_HI ((v) + 0x8000)
 
+static inline unsigned int
+plt_stub_size (struct ppc_link_hash_table *htab,
+	       struct ppc_stub_hash_entry *stub_entry,
+	       bfd_vma off)
+{
+  unsigned size = 12;
+
+  if (ALWAYS_EMIT_R2SAVE
+      || stub_entry->stub_type == ppc_stub_plt_call_r2save)
+    size += 4;
+  if (PPC_HA (off) != 0)
+    size += 4;
+  if (htab->opd_abi)
+    {
+      size += 4;
+      if (htab->plt_static_chain)
+	size += 4;
+      if (htab->plt_thread_safe)
+	size += 8;
+      if (PPC_HA (off + 8 + 8 * htab->plt_static_chain) != PPC_HA (off))
+	size += 4;
+    }
+  if (stub_entry->h != NULL
+      && (stub_entry->h == htab->tls_get_addr_fd
+	  || stub_entry->h == htab->tls_get_addr)
+      && !htab->no_tls_get_addr_opt)
+    size += 13 * 4;
+  return size;
+}
+
+/* If this stub would cross fewer 2**plt_stub_align boundaries if we align,
+   then return the padding needed to do so.  */
+static inline unsigned int
+plt_stub_pad (struct ppc_link_hash_table *htab,
+	      struct ppc_stub_hash_entry *stub_entry,
+	      bfd_vma plt_off)
+{
+  int stub_align = 1 << htab->plt_stub_align;
+  unsigned stub_size = plt_stub_size (htab, stub_entry, plt_off);
+  bfd_vma stub_off = stub_entry->stub_sec->size;
+
+  if (((stub_off + stub_size - 1) & -stub_align) - (stub_off & -stub_align)
+      > (stub_size & -stub_align))
+    return stub_align - (stub_off & (stub_align - 1));
+  return 0;
+}
+
+/* Build a .plt call stub.  */
+
+static inline bfd_byte *
+build_plt_stub (struct ppc_link_hash_table *htab,
+		struct ppc_stub_hash_entry *stub_entry,
+		bfd_byte *p, bfd_vma offset, Elf_Internal_Rela *r)
+{
+  bfd *obfd = htab->stub_bfd;
+  bfd_boolean plt_load_toc = htab->opd_abi;
+  bfd_boolean plt_static_chain = htab->plt_static_chain;
+  bfd_boolean plt_thread_safe = htab->plt_thread_safe;
+  bfd_boolean use_fake_dep = plt_thread_safe;
+  bfd_vma cmp_branch_off = 0;
+
+  if (!ALWAYS_USE_FAKE_DEP
+      && plt_load_toc
+      && plt_thread_safe
+      && !(stub_entry->h != NULL
+	   && (stub_entry->h == htab->tls_get_addr_fd
+	       || stub_entry->h == htab->tls_get_addr)
+	   && !htab->no_tls_get_addr_opt))
+    {
+      bfd_vma pltoff = stub_entry->plt_ent->plt.offset & ~1;
+      bfd_vma pltindex = ((pltoff - PLT_INITIAL_ENTRY_SIZE (htab))
+			  / PLT_ENTRY_SIZE (htab));
+      bfd_vma glinkoff = GLINK_CALL_STUB_SIZE + pltindex * 8;
+      bfd_vma to, from;
+
+      if (pltindex > 32768)
+	glinkoff += (pltindex - 32768) * 4;
+      to = (glinkoff
+	    + htab->glink->output_offset
+	    + htab->glink->output_section->vma);
+      from = (p - stub_entry->stub_sec->contents
+	      + 4 * (ALWAYS_EMIT_R2SAVE
+		     || stub_entry->stub_type == ppc_stub_plt_call_r2save)
+	      + 4 * (PPC_HA (offset) != 0)
+	      + 4 * (PPC_HA (offset + 8 + 8 * plt_static_chain)
+		     != PPC_HA (offset))
+	      + 4 * (plt_static_chain != 0)
+	      + 20
+	      + stub_entry->stub_sec->output_offset
+	      + stub_entry->stub_sec->output_section->vma);
+      cmp_branch_off = to - from;
+      use_fake_dep = cmp_branch_off + (1 << 25) >= (1 << 26);
+    }
+
   if (PPC_HA (offset) != 0)
     {
       if (r != NULL)
 	{
-	  r[0].r_offset += 4;
+	  if (ALWAYS_EMIT_R2SAVE
+	      || stub_entry->stub_type == ppc_stub_plt_call_r2save)
+	    r[0].r_offset += 4;
 	  r[0].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_HA);
 	  r[1].r_offset = r[0].r_offset + 4;
 	  r[1].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_LO_DS);
 	  r[1].r_addend = r[0].r_addend;
-	  if (PPC_HA (offset + 8 + 8 * plt_static_chain) != PPC_HA (offset))
+	  if (plt_load_toc)
 	    {
-	      r[2].r_offset = r[1].r_offset + 4;
-	      r[2].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_LO);
-	      r[2].r_addend = r[0].r_addend;
-	    }
-	  else
-	    {
-	      r[2].r_offset = r[1].r_offset + 8;
-	      r[2].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_LO_DS);
-	      r[2].r_addend = r[0].r_addend + 8;
-	      if (plt_static_chain)
+	      if (PPC_HA (offset + 8 + 8 * plt_static_chain) != PPC_HA (offset))
 		{
-		  r[3].r_offset = r[2].r_offset + 4;
-		  r[3].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_LO_DS);
-		  r[3].r_addend = r[0].r_addend + 16;
+		  r[2].r_offset = r[1].r_offset + 4;
+		  r[2].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_LO);
+		  r[2].r_addend = r[0].r_addend;
+		}
+	      else
+		{
+		  r[2].r_offset = r[1].r_offset + 8 + 8 * use_fake_dep;
+		  r[2].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_LO_DS);
+		  r[2].r_addend = r[0].r_addend + 8;
+		  if (plt_static_chain)
+		    {
+		      r[3].r_offset = r[2].r_offset + 4;
+		      r[3].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_LO_DS);
+		      r[3].r_addend = r[0].r_addend + 16;
+		    }
 		}
 	    }
 	}
-      bfd_put_32 (obfd, STD_R2_40R1, p),			p += 4;
-      bfd_put_32 (obfd, ADDIS_R12_R2 | PPC_HA (offset), p),	p += 4;
-      bfd_put_32 (obfd, LD_R11_0R12 | PPC_LO (offset), p),	p += 4;
-      if (PPC_HA (offset + 8 + 8 * plt_static_chain) != PPC_HA (offset))
+      if (ALWAYS_EMIT_R2SAVE
+	  || stub_entry->stub_type == ppc_stub_plt_call_r2save)
+	bfd_put_32 (obfd, STD_R2_0R1 + STK_TOC (htab), p),	p += 4;
+      bfd_put_32 (obfd, ADDIS_R11_R2 | PPC_HA (offset), p),	p += 4;
+      bfd_put_32 (obfd, LD_R12_0R11 | PPC_LO (offset), p),	p += 4;
+      if (plt_load_toc
+	  && PPC_HA (offset + 8 + 8 * plt_static_chain) != PPC_HA (offset))
 	{
-	  bfd_put_32 (obfd, ADDI_R12_R12 | PPC_LO (offset), p),	p += 4;
+	  bfd_put_32 (obfd, ADDI_R11_R11 | 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;
-      if (plt_static_chain)
-	bfd_put_32 (obfd, LD_R11_0R12 | PPC_LO (offset + 16), p), p += 4;
-      bfd_put_32 (obfd, BCTR, p),				p += 4;
+      bfd_put_32 (obfd, MTCTR_R12, p),				p += 4;
+      if (plt_load_toc)
+	{
+	  if (use_fake_dep)
+	    {
+	      bfd_put_32 (obfd, XOR_R2_R12_R12, p),		p += 4;
+	      bfd_put_32 (obfd, ADD_R11_R11_R2, p),		p += 4;
+	    }
+	  bfd_put_32 (obfd, LD_R2_0R11 | PPC_LO (offset + 8), p), p += 4;
+	  if (plt_static_chain)
+	    bfd_put_32 (obfd, LD_R11_0R11 | PPC_LO (offset + 16), p), p += 4;
+	}
     }
   else
     {
       if (r != NULL)
 	{
-	  r[0].r_offset += 4;
+	  if (ALWAYS_EMIT_R2SAVE
+	      || stub_entry->stub_type == ppc_stub_plt_call_r2save)
+	    r[0].r_offset += 4;
 	  r[0].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_DS);
-	  if (PPC_HA (offset + 8 + 8 * plt_static_chain) != PPC_HA (offset))
+	  if (plt_load_toc)
 	    {
-	      r[1].r_offset = r[0].r_offset + 4;
-	      r[1].r_info = ELF64_R_INFO (0, R_PPC64_TOC16);
-	      r[1].r_addend = r[0].r_addend;
-	    }
-	  else
-	    {
-	      r[1].r_offset = r[0].r_offset + 8;
-	      r[1].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_DS);
-	      r[1].r_addend = r[0].r_addend + 8 + 8 * plt_static_chain;
-	      if (plt_static_chain)
+	      if (PPC_HA (offset + 8 + 8 * plt_static_chain) != PPC_HA (offset))
 		{
-		  r[2].r_offset = r[1].r_offset + 4;
-		  r[2].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_DS);
-		  r[2].r_addend = r[0].r_addend + 8;
+		  r[1].r_offset = r[0].r_offset + 4;
+		  r[1].r_info = ELF64_R_INFO (0, R_PPC64_TOC16);
+		  r[1].r_addend = r[0].r_addend;
+		}
+	      else
+		{
+		  r[1].r_offset = r[0].r_offset + 8 + 8 * use_fake_dep;
+		  r[1].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_DS);
+		  r[1].r_addend = r[0].r_addend + 8 + 8 * plt_static_chain;
+		  if (plt_static_chain)
+		    {
+		      r[2].r_offset = r[1].r_offset + 4;
+		      r[2].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_DS);
+		      r[2].r_addend = r[0].r_addend + 8;
+		    }
 		}
 	    }
 	}
-      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 + 8 + 8 * plt_static_chain) != PPC_HA (offset))
+      if (ALWAYS_EMIT_R2SAVE
+	  || stub_entry->stub_type == ppc_stub_plt_call_r2save)
+	bfd_put_32 (obfd, STD_R2_0R1 + STK_TOC (htab), p),	p += 4;
+      bfd_put_32 (obfd, LD_R12_0R2 | PPC_LO (offset), p),	p += 4;
+      if (plt_load_toc
+	  && PPC_HA (offset + 8 + 8 * plt_static_chain) != 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;
-      if (plt_static_chain)
-	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, MTCTR_R12, p),				p += 4;
+      if (plt_load_toc)
+	{
+	  if (use_fake_dep)
+	    {
+	      bfd_put_32 (obfd, XOR_R11_R12_R12, p),		p += 4;
+	      bfd_put_32 (obfd, ADD_R2_R2_R11, p),		p += 4;
+	    }
+	  if (plt_static_chain)
+	    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;
+	}
     }
+  if (plt_load_toc && plt_thread_safe && !use_fake_dep)
+    {
+      bfd_put_32 (obfd, CMPLDI_R2_0, p),			p += 4;
+      bfd_put_32 (obfd, BNECTR_P4, p),				p += 4;
+      bfd_put_32 (obfd, B_DOT | (cmp_branch_off & 0x3fffffc), p), p += 4;
+    }
+  else
+    bfd_put_32 (obfd, BCTR, p),					p += 4;
   return p;
 }
 
@@ -9635,17 +10291,18 @@
 #define ADD_R3_R12_R13	0x7c6c6a14
 #define BEQLR		0x4d820020
 #define MR_R3_R0	0x7c030378
-#define MFLR_R11	0x7d6802a6
 #define STD_R11_0R1	0xf9610000
 #define BCTRL		0x4e800421
 #define LD_R11_0R1	0xe9610000
-#define LD_R2_0R1	0xe8410000
 #define MTLR_R11	0x7d6803a6
 
 static inline bfd_byte *
-build_tls_get_addr_stub (bfd *obfd, bfd_byte *p, int offset,
-			 Elf_Internal_Rela *r, bfd_boolean plt_static_chain)
+build_tls_get_addr_stub (struct ppc_link_hash_table *htab,
+			 struct ppc_stub_hash_entry *stub_entry,
+			 bfd_byte *p, bfd_vma offset, Elf_Internal_Rela *r)
 {
+  bfd *obfd = htab->stub_bfd;
+
   bfd_put_32 (obfd, LD_R11_0R3 + 0, p),		p += 4;
   bfd_put_32 (obfd, LD_R12_0R3 + 8, p),		p += 4;
   bfd_put_32 (obfd, MR_R0_R3, p),		p += 4;
@@ -9654,15 +10311,15 @@
   bfd_put_32 (obfd, BEQLR, p),			p += 4;
   bfd_put_32 (obfd, MR_R3_R0, p),		p += 4;
   bfd_put_32 (obfd, MFLR_R11, p),		p += 4;
-  bfd_put_32 (obfd, STD_R11_0R1 + 32, p),	p += 4;
+  bfd_put_32 (obfd, STD_R11_0R1 + STK_LINKER (htab), p), p += 4;
 
   if (r != NULL)
     r[0].r_offset += 9 * 4;
-  p = build_plt_stub (obfd, p, offset, r, plt_static_chain);
+  p = build_plt_stub (htab, stub_entry, p, offset, r);
   bfd_put_32 (obfd, BCTRL, p - 4);
 
-  bfd_put_32 (obfd, LD_R11_0R1 + 32, p),	p += 4;
-  bfd_put_32 (obfd, LD_R2_0R1 + 40, p),		p += 4;
+  bfd_put_32 (obfd, LD_R11_0R1 + STK_LINKER (htab), p),	p += 4;
+  bfd_put_32 (obfd, LD_R2_0R1 + STK_TOC (htab), p),	p += 4;
   bfd_put_32 (obfd, MTLR_R11, p),		p += 4;
   bfd_put_32 (obfd, BLR, p),			p += 4;
 
@@ -9711,13 +10368,15 @@
       /* Support linking -R objects.  Get the toc pointer from the
 	 opd entry.  */
       char buf[8];
+      if (!htab->opd_abi)
+	return r2off;
       asection *opd = stub_entry->h->elf.root.u.def.section;
       bfd_vma opd_off = stub_entry->h->elf.root.u.def.value;
 
       if (strcmp (opd->name, ".opd") != 0
 	  || opd->reloc_count != 0)
 	{
-	  info->callbacks->einfo (_("%P: cannot find opd entry toc for %s\n"),
+	  info->callbacks->einfo (_("%P: cannot find opd entry toc for `%T'\n"),
 				  stub_entry->h->elf.root.root.string);
 	  bfd_set_error (bfd_error_bad_value);
 	  return 0;
@@ -9763,9 +10422,11 @@
     case ppc_stub_long_branch:
     case ppc_stub_long_branch_r2off:
       /* Branches are relative.  This is where we are going to.  */
-      off = dest = (stub_entry->target_value
-		    + stub_entry->target_section->output_offset
-		    + stub_entry->target_section->output_section->vma);
+      dest = (stub_entry->target_value
+	      + stub_entry->target_section->output_offset
+	      + stub_entry->target_section->output_section->vma);
+      dest += PPC64_LOCAL_ENTRY_OFFSET (stub_entry->other);
+      off = dest;
 
       /* And this is where we are coming from.  */
       off -= (stub_entry->stub_offset
@@ -9782,7 +10443,7 @@
 	      htab->stub_error = TRUE;
 	      return FALSE;
 	    }
-	  bfd_put_32 (htab->stub_bfd, STD_R2_40R1, loc);
+	  bfd_put_32 (htab->stub_bfd, STD_R2_0R1 + STK_TOC (htab), loc);
 	  loc += 4;
 	  size = 12;
 	  if (PPC_HA (r2off) != 0)
@@ -9799,8 +10460,9 @@
 
       if (off + (1 << 25) >= (bfd_vma) (1 << 26))
 	{
-	  info->callbacks->einfo (_("%P: long branch stub `%s' offset overflow\n"),
-				  stub_entry->root.string);
+	  info->callbacks->einfo
+	    (_("%P: long branch stub `%s' offset overflow\n"),
+	     stub_entry->root.string);
 	  htab->stub_error = TRUE;
 	  return FALSE;
 	}
@@ -9867,6 +10529,8 @@
       dest = (stub_entry->target_value
 	      + stub_entry->target_section->output_offset
 	      + stub_entry->target_section->output_section->vma);
+      if (stub_entry->stub_type != ppc_stub_plt_branch_r2off)
+	dest += PPC64_LOCAL_ENTRY_OFFSET (stub_entry->other);
 
       bfd_put_64 (htab->brlt->owner, dest,
 		  htab->brlt->contents + br_entry->offset);
@@ -9920,7 +10584,7 @@
       if (off + 0x80008000 > 0xffffffff || (off & 7) != 0)
 	{
 	  info->callbacks->einfo
-	    (_("%P: linkage table error against `%s'\n"),
+	    (_("%P: linkage table error against `%T'\n"),
 	     stub_entry->root.string);
 	  bfd_set_error (bfd_error_bad_value);
 	  htab->stub_error = TRUE;
@@ -9935,7 +10599,8 @@
 	  r[0].r_offset = loc - stub_entry->stub_sec->contents;
 	  if (bfd_big_endian (info->output_bfd))
 	    r[0].r_offset += 2;
-	  if (stub_entry->stub_type == ppc_stub_plt_branch_r2off)
+	  if (stub_entry->stub_type == ppc_stub_plt_branch_r2off
+	      && htab->opd_abi)
 	    r[0].r_offset += 4;
 	  r[0].r_info = ELF64_R_INFO (0, R_PPC64_TOC16_DS);
 	  r[0].r_addend = dest;
@@ -9948,19 +10613,20 @@
 	    }
 	}
 
-      if (stub_entry->stub_type != ppc_stub_plt_branch_r2off)
+      if (stub_entry->stub_type != ppc_stub_plt_branch_r2off
+	  || !htab->opd_abi)
 	{
 	  if (PPC_HA (off) != 0)
 	    {
 	      size = 16;
-	      bfd_put_32 (htab->stub_bfd, ADDIS_R12_R2 | PPC_HA (off), loc);
+	      bfd_put_32 (htab->stub_bfd, ADDIS_R11_R2 | PPC_HA (off), loc);
 	      loc += 4;
-	      bfd_put_32 (htab->stub_bfd, LD_R11_0R12 | PPC_LO (off), loc);
+	      bfd_put_32 (htab->stub_bfd, LD_R12_0R11 | PPC_LO (off), loc);
 	    }
 	  else
 	    {
 	      size = 12;
-	      bfd_put_32 (htab->stub_bfd, LD_R11_0R2 | PPC_LO (off), loc);
+	      bfd_put_32 (htab->stub_bfd, LD_R12_0R2 | PPC_LO (off), loc);
 	    }
 	}
       else
@@ -9973,20 +10639,20 @@
 	      return FALSE;
 	    }
 
-	  bfd_put_32 (htab->stub_bfd, STD_R2_40R1, loc);
+	  bfd_put_32 (htab->stub_bfd, STD_R2_0R1 + STK_TOC (htab), loc);
 	  loc += 4;
 	  size = 20;
 	  if (PPC_HA (off) != 0)
 	    {
 	      size += 4;
-	      bfd_put_32 (htab->stub_bfd, ADDIS_R12_R2 | PPC_HA (off), loc);
+	      bfd_put_32 (htab->stub_bfd, ADDIS_R11_R2 | PPC_HA (off), loc);
 	      loc += 4;
-	      bfd_put_32 (htab->stub_bfd, LD_R11_0R12 | PPC_LO (off), loc);
+	      bfd_put_32 (htab->stub_bfd, LD_R12_0R11 | PPC_LO (off), loc);
 	      loc += 4;
 	    }
 	  else
 	    {
-	      bfd_put_32 (htab->stub_bfd, LD_R11_0R2 | PPC_LO (off), loc);
+	      bfd_put_32 (htab->stub_bfd, LD_R12_0R2 | PPC_LO (off), loc);
 	      loc += 4;
 	    }
 
@@ -9999,12 +10665,13 @@
 	  bfd_put_32 (htab->stub_bfd, ADDI_R2_R2 | PPC_LO (r2off), loc);
 	}
       loc += 4;
-      bfd_put_32 (htab->stub_bfd, MTCTR_R11, loc);
+      bfd_put_32 (htab->stub_bfd, MTCTR_R12, loc);
       loc += 4;
       bfd_put_32 (htab->stub_bfd, BCTR, loc);
       break;
 
     case ppc_stub_plt_call:
+    case ppc_stub_plt_call_r2save:
       if (stub_entry->h != NULL
 	  && stub_entry->h->is_func_descriptor
 	  && stub_entry->h->oh != NULL)
@@ -10028,11 +10695,11 @@
       if (dest >= (bfd_vma) -2)
 	abort ();
 
-      plt = htab->plt;
+      plt = htab->elf.splt;
       if (!htab->elf.dynamic_sections_created
 	  || stub_entry->h == NULL
 	  || stub_entry->h->elf.dynindx == -1)
-	plt = htab->iplt;
+	plt = htab->elf.iplt;
 
       dest += plt->output_offset + plt->output_section->vma;
 
@@ -10043,13 +10710,16 @@
 	  bfd_byte *rl;
 
 	  rela.r_offset = dest;
-	  rela.r_info = ELF64_R_INFO (0, R_PPC64_JMP_IREL);
+	  if (htab->opd_abi)
+	    rela.r_info = ELF64_R_INFO (0, R_PPC64_JMP_IREL);
+	  else
+	    rela.r_info = ELF64_R_INFO (0, R_PPC64_IRELATIVE);
 	  rela.r_addend = (stub_entry->target_value
 			   + stub_entry->target_section->output_offset
 			   + stub_entry->target_section->output_section->vma);
 
-	  rl = (htab->reliplt->contents
-		+ (htab->reliplt->reloc_count++
+	  rl = (htab->elf.irelplt->contents
+		+ (htab->elf.irelplt->reloc_count++
 		   * sizeof (Elf64_External_Rela)));
 	  bfd_elf64_swap_reloca_out (info->output_bfd, &rela, rl);
 	  stub_entry->plt_ent->plt.offset |= 1;
@@ -10062,7 +10732,7 @@
       if (off + 0x80008000 > 0xffffffff || (off & 7) != 0)
 	{
 	  info->callbacks->einfo
-	    (_("%P: linkage table error against `%s'\n"),
+	    (_("%P: linkage table error against `%T'\n"),
 	     stub_entry->h != NULL
 	     ? stub_entry->h->elf.root.root.string
 	     : "<local sym>");
@@ -10071,6 +10741,15 @@
 	  return FALSE;
 	}
 
+      if (htab->plt_stub_align != 0)
+	{
+	  unsigned pad = plt_stub_pad (htab, stub_entry, off);
+
+	  stub_entry->stub_sec->size += pad;
+	  stub_entry->stub_offset = stub_entry->stub_sec->size;
+	  loc += pad;
+	}
+
       r = NULL;
       if (info->emitrelocations)
 	{
@@ -10090,11 +10769,9 @@
 	  && (stub_entry->h == htab->tls_get_addr_fd
 	      || stub_entry->h == htab->tls_get_addr)
 	  && !htab->no_tls_get_addr_opt)
-	p = build_tls_get_addr_stub (htab->stub_bfd, loc, off, r,
-				     htab->plt_static_chain);
+	p = build_tls_get_addr_stub (htab, stub_entry, loc, off, r);
       else
-	p = build_plt_stub (htab->stub_bfd, loc, off, r,
-			    htab->plt_static_chain);
+	p = build_plt_stub (htab, stub_entry, loc, off, r);
       size = p - loc;
       break;
 
@@ -10114,6 +10791,7 @@
 				       "long_branch_r2off",
 				       "plt_branch",
 				       "plt_branch_r2off",
+				       "plt_call",
 				       "plt_call" };
 
       len1 = strlen (stub_str[stub_entry->stub_type - 1]);
@@ -10164,41 +10842,34 @@
   if (htab == NULL)
     return FALSE;
 
-  if (stub_entry->stub_type == ppc_stub_plt_call)
+  if (stub_entry->stub_type == ppc_stub_plt_call
+      || stub_entry->stub_type == ppc_stub_plt_call_r2save)
     {
       asection *plt;
       off = stub_entry->plt_ent->plt.offset & ~(bfd_vma) 1;
       if (off >= (bfd_vma) -2)
 	abort ();
-      plt = htab->plt;
+      plt = htab->elf.splt;
       if (!htab->elf.dynamic_sections_created
 	  || stub_entry->h == NULL
 	  || stub_entry->h->elf.dynindx == -1)
-	plt = htab->iplt;
+	plt = htab->elf.iplt;
       off += (plt->output_offset
 	      + plt->output_section->vma
 	      - elf_gp (plt->output_section->owner)
 	      - htab->stub_group[stub_entry->id_sec->id].toc_off);
 
-      size = PLT_CALL_STUB_SIZE;
-      if (!htab->plt_static_chain)
-	size -= 4;
-      if (PPC_HA (off) == 0)
-	size -= 4;
-      if (PPC_HA (off + 8 + 8 * htab->plt_static_chain) != PPC_HA (off))
-	size += 4;
-      if (stub_entry->h != NULL
-	  && (stub_entry->h == htab->tls_get_addr_fd
-	      || stub_entry->h == htab->tls_get_addr)
-	  && !htab->no_tls_get_addr_opt)
-	size += 13 * 4;
+      size = plt_stub_size (htab, stub_entry, off);
+      if (htab->plt_stub_align)
+	size += plt_stub_pad (htab, stub_entry, off);
       if (info->emitrelocations)
 	{
 	  stub_entry->stub_sec->reloc_count
-	    += (2
-		+ (PPC_HA (off) != 0)
-		+ (htab->plt_static_chain
-		   && PPC_HA (off + 16) == PPC_HA (off)));
+	    += ((PPC_HA (off) != 0)
+		+ (htab->opd_abi
+		   ? 2 + (htab->plt_static_chain
+			  && PPC_HA (off + 16) == PPC_HA (off))
+		   : 1));
 	  stub_entry->stub_sec->flags |= SEC_RELOC;
 	}
     }
@@ -10207,6 +10878,7 @@
       /* ppc_stub_long_branch or ppc_stub_plt_branch, or their r2off
 	 variants.  */
       bfd_vma r2off = 0;
+      bfd_vma local_off = 0;
 
       off = (stub_entry->target_value
 	     + stub_entry->target_section->output_offset
@@ -10224,7 +10896,7 @@
       if (stub_entry->stub_type == ppc_stub_long_branch_r2off)
 	{
 	  r2off = get_r2off (info, stub_entry);
-	  if (r2off == 0)
+	  if (r2off == 0 && htab->opd_abi)
 	    {
 	      htab->stub_error = TRUE;
 	      return FALSE;
@@ -10235,8 +10907,13 @@
 	  off -= size - 4;
 	}
 
-      /* If the branch offset if too big, use a ppc_stub_plt_branch.  */
-      if (off + (1 << 25) >= (bfd_vma) (1 << 26))
+      local_off = PPC64_LOCAL_ENTRY_OFFSET (stub_entry->other);
+
+      /* If the branch offset if too big, use a ppc_stub_plt_branch.
+	 Do the same for -R objects without function descriptors.  */
+      if (off + (1 << 25) >= (bfd_vma) (1 << 26) - local_off
+	  || (stub_entry->stub_type == ppc_stub_long_branch_r2off
+	      && r2off == 0))
 	{
 	  struct ppc_branch_hash_entry *br_entry;
 
@@ -10279,7 +10956,8 @@
 	      stub_entry->stub_sec->flags |= SEC_RELOC;
 	    }
 
-	  if (stub_entry->stub_type != ppc_stub_plt_branch_r2off)
+	  if (stub_entry->stub_type != ppc_stub_plt_branch_r2off
+	      || !htab->opd_abi)
 	    {
 	      size = 12;
 	      if (PPC_HA (off) != 0)
@@ -10329,9 +11007,6 @@
   htab->add_stub_section = add_stub_section;
   htab->layout_sections_again = layout_sections_again;
 
-  if (htab->brlt == NULL)
-    return 0;
-
   /* Find the top input section id.  */
   for (input_bfd = info->input_bfds, top_id = 3;
        input_bfd != NULL;
@@ -10384,8 +11059,7 @@
 {
   struct ppc_link_hash_table *htab = ppc_hash_table (info);
 
-  elf_gp (info->output_bfd) = ppc64_elf_toc (info->output_bfd);
-  htab->toc_curr = elf_gp (info->output_bfd);
+  htab->toc_curr = ppc64_elf_set_toc (info, info->output_bfd);
   htab->toc_bfd = NULL;
   htab->toc_first_sec = NULL;
 }
@@ -10406,7 +11080,9 @@
   if (!htab->second_toc_pass)
     {
       /* Keep track of the first .toc or .got section for this input bfd.  */
-      if (htab->toc_bfd != isec->owner)
+      bfd_boolean new_bfd = htab->toc_bfd != isec->owner;
+
+      if (new_bfd)
 	{
 	  htab->toc_bfd = isec->owner;
 	  htab->toc_first_sec = isec;
@@ -10434,7 +11110,8 @@
 
       /* Die if someone uses a linker script that doesn't keep input
 	 file .toc and .got together.  */
-      if (elf_gp (isec->owner) != 0
+      if (new_bfd
+	  && elf_gp (isec->owner) != 0
 	  && elf_gp (isec->owner) != off)
 	return FALSE;
 
@@ -10543,8 +11220,8 @@
     }
 
   /* Zap sizes of got sections.  */
-  htab->reliplt->rawsize = htab->reliplt->size;
-  htab->reliplt->size -= htab->got_reli_size;
+  htab->elf.irelplt->rawsize = htab->elf.irelplt->size;
+  htab->elf.irelplt->size -= htab->got_reli_size;
   htab->got_reli_size = 0;
 
   for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
@@ -10576,7 +11253,7 @@
       unsigned char *lgot_masks;
       bfd_size_type locsymcount;
       Elf_Internal_Shdr *symtab_hdr;
-      asection *s, *srel;
+      asection *s;
 
       if (!is_ppc64_elf (ibfd))
 	continue;
@@ -10592,26 +11269,31 @@
       end_local_plt = local_plt + locsymcount;
       lgot_masks = (unsigned char *) end_local_plt;
       s = ppc64_elf_tdata (ibfd)->got;
-      srel = ppc64_elf_tdata (ibfd)->relgot;
       for (; lgot_ents < end_lgot_ents; ++lgot_ents, ++lgot_masks)
 	{
 	  struct got_entry *ent;
 
 	  for (ent = *lgot_ents; ent != NULL; ent = ent->next)
 	    {
-	      unsigned int num = 1;
+	      unsigned int ent_size = 8;
+	      unsigned int rel_size = sizeof (Elf64_External_Rela);
+
 	      ent->got.offset = s->size;
 	      if ((ent->tls_type & *lgot_masks & TLS_GD) != 0)
-		num = 2;
-	      s->size += num * 8;
-	      if (info->shared)
-		srel->size += num * sizeof (Elf64_External_Rela);
-	      else if ((*lgot_masks & PLT_IFUNC) != 0)
 		{
-		  htab->reliplt->size
-		    += num * sizeof (Elf64_External_Rela);
-		  htab->got_reli_size
-		    += num * sizeof (Elf64_External_Rela);
+		  ent_size *= 2;
+		  rel_size *= 2;
+		}
+	      s->size += ent_size;
+	      if ((*lgot_masks & PLT_IFUNC) != 0)
+		{
+		  htab->elf.irelplt->size += rel_size;
+		  htab->got_reli_size += rel_size;
+		}
+	      else if (info->shared)
+		{
+		  asection *srel = ppc64_elf_tdata (ibfd)->relgot;
+		  srel->size += rel_size;
 		}
 	    }
 	}
@@ -10641,7 +11323,7 @@
 	}
     }
 
-  done_something = htab->reliplt->rawsize != htab->reliplt->size;
+  done_something = htab->elf.irelplt->rawsize != htab->elf.irelplt->size;
   if (!done_something)
     for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
       {
@@ -10829,7 +11511,10 @@
 	     need a plt_branch stub.  A plt_branch stub uses r2.  */
 	  else if (dest - (isec->output_offset
 			   + isec->output_section->vma
-			   + rel->r_offset) + (1 << 25) >= (2 << 25))
+			   + rel->r_offset) + (1 << 25)
+		   >= (2u << 25) - PPC64_LOCAL_ENTRY_OFFSET (h
+							     ? h->other
+							     : sym->st_other))
 	    {
 	      ret = 1;
 	      break;
@@ -10923,42 +11608,25 @@
 
   if (htab->multi_toc_needed)
     {
-      /* If a code section has a function that uses the TOC then we need
-	 to use the right TOC (obviously).  Also, make sure that .opd gets
-	 the correct TOC value for R_PPC64_TOC relocs that don't have or
-	 can't find their function symbol (shouldn't ever happen now).
-	 Also specially treat .fixup for the linux kernel.  .fixup
-	 contains branches, but only back to the function that hit an
-	 exception.  */
-      if (isec->has_toc_reloc
-	  || (isec->flags & SEC_CODE) == 0
-	  || strcmp (isec->name, ".fixup") == 0)
+      /* Analyse sections that aren't already flagged as needing a
+	 valid toc pointer.  Exclude .fixup for the linux kernel.
+	 .fixup contains branches, but only back to the function that
+	 hit an exception.  */
+      if (!(isec->has_toc_reloc
+	    || (isec->flags & SEC_CODE) == 0
+	    || strcmp (isec->name, ".fixup") == 0
+	    || isec->call_check_done))
 	{
-	  if (elf_gp (isec->owner) != 0)
-	    htab->toc_curr = elf_gp (isec->owner);
-	}
-      else
-	{
-	  if (!isec->call_check_done
-	      && toc_adjusting_stub_needed (info, isec) < 0)
+	  if (toc_adjusting_stub_needed (info, isec) < 0)
 	    return FALSE;
-	  /* If we make a local call from this section, ie. a branch
-	     without a following nop, then we have no place to put a
-	     toc restoring insn.  We must use the same toc group as
-	     the callee.
-	     Testing makes_toc_func_call actually tests for *any*
-	     calls to functions that need a good toc pointer.  A more
-	     precise test would be better, as this one will set
-	     incorrect values for pasted .init/.fini fragments.
-	     (Fixed later in check_pasted_section.)  */
-	  if (isec->makes_toc_func_call
-	      && elf_gp (isec->owner) != 0)
-	    htab->toc_curr = elf_gp (isec->owner);
 	}
+      /* Make all sections use the TOC assigned for this object file.
+	 This will be wrong for pasted sections;  We fix that in
+	 check_pasted_section().  */
+      if (elf_gp (isec->owner) != 0)
+	htab->toc_curr = elf_gp (isec->owner);
     }
 
-  /* Functions that don't use the TOC can belong in any TOC group.
-     Use the last TOC base.  */
   htab->stub_group[isec->id].toc_off = htab->toc_curr;
   return TRUE;
 }
@@ -11143,6 +11811,7 @@
 {
   if (isec->size == 0
       && isec->output_section->size == 0
+      && !(isec->output_section->flags & SEC_KEEP)
       && !bfd_section_removed_from_list (info->output_bfd,
 					 isec->output_section)
       && elf_section_data (isec->output_section)->dynindx == 0)
@@ -11161,7 +11830,8 @@
 
 bfd_boolean
 ppc64_elf_size_stubs (struct bfd_link_info *info, bfd_signed_vma group_size,
-		      bfd_boolean plt_static_chain)
+		      bfd_boolean plt_static_chain, int plt_thread_safe,
+		      int plt_stub_align)
 {
   bfd_size_type stub_group_size;
   bfd_boolean stubs_always_before_branch;
@@ -11171,6 +11841,44 @@
     return FALSE;
 
   htab->plt_static_chain = plt_static_chain;
+  htab->plt_stub_align = plt_stub_align;
+  if (plt_thread_safe == -1 && !info->executable)
+    plt_thread_safe = 1;
+  if (!htab->opd_abi)
+    plt_thread_safe = 0;
+  else if (plt_thread_safe == -1)
+    {
+      static const char *const thread_starter[] =
+	{
+	  "pthread_create",
+	  /* libstdc++ */
+	  "_ZNSt6thread15_M_start_threadESt10shared_ptrINS_10_Impl_baseEE",
+	  /* librt */
+	  "aio_init", "aio_read", "aio_write", "aio_fsync", "lio_listio",
+	  "mq_notify", "create_timer",
+	  /* libanl */
+	  "getaddrinfo_a",
+	  /* libgomp */
+	  "GOMP_parallel_start",
+	  "GOMP_parallel_loop_static_start",
+	  "GOMP_parallel_loop_dynamic_start",
+	  "GOMP_parallel_loop_guided_start",
+	  "GOMP_parallel_loop_runtime_start",
+	  "GOMP_parallel_sections_start",
+	};
+      unsigned i;
+
+      for (i = 0; i < sizeof (thread_starter)/ sizeof (thread_starter[0]); i++)
+	{
+	  struct elf_link_hash_entry *h;
+	  h = elf_link_hash_lookup (&htab->elf, thread_starter[i],
+				    FALSE, FALSE, TRUE);
+	  plt_thread_safe = h != NULL && h->ref_regular;
+	  if (plt_thread_safe)
+	    break;
+	}
+    }
+  htab->plt_thread_safe = plt_thread_safe;
   stubs_always_before_branch = group_size < 0;
   if (group_size < 0)
     stub_group_size = -group_size;
@@ -11244,6 +11952,7 @@
 		  asection *sym_sec, *code_sec;
 		  bfd_vma sym_value, code_value;
 		  bfd_vma destination;
+		  unsigned long local_off;
 		  bfd_boolean ok_dest;
 		  struct ppc_link_hash_entry *hash;
 		  struct ppc_link_hash_entry *fdh;
@@ -11320,12 +12029,16 @@
 		    }
 
 		  destination = 0;
+		  local_off = 0;
 		  if (ok_dest)
 		    {
 		      sym_value += irela->r_addend;
 		      destination = (sym_value
 				     + sym_sec->output_offset
 				     + sym_sec->output_section->vma);
+		      local_off = PPC64_LOCAL_ENTRY_OFFSET (hash
+							    ? hash->elf.other
+							    : sym->st_other);
 		    }
 
 		  code_sec = sym_sec;
@@ -11362,7 +12075,8 @@
 		  /* Determine what (if any) linker stub is needed.  */
 		  plt_ent = NULL;
 		  stub_type = ppc_type_of_stub (section, irela, &hash,
-						&plt_ent, destination);
+						&plt_ent, destination,
+						local_off);
 
 		  if (stub_type != ppc_stub_plt_call)
 		    {
@@ -11405,10 +12119,14 @@
 		  if (stub_type == ppc_stub_plt_call
 		      && irela + 1 < irelaend
 		      && irela[1].r_offset == irela->r_offset + 4
-		      && ELF64_R_TYPE (irela[1].r_info) == R_PPC64_TOCSAVE
-		      && !tocsave_find (htab, INSERT,
-					&local_syms, irela + 1, input_bfd))
-		    goto error_ret_free_internal;
+		      && ELF64_R_TYPE (irela[1].r_info) == R_PPC64_TOCSAVE)
+		    {
+		      if (!tocsave_find (htab, INSERT,
+					 &local_syms, irela + 1, input_bfd))
+			goto error_ret_free_internal;
+		    }
+		  else if (stub_type == ppc_stub_plt_call)
+		    stub_type = ppc_stub_plt_call_r2save;
 
 		  /* Support for grouping stub sections.  */
 		  id_sec = htab->stub_group[section->id].link_sec;
@@ -11424,6 +12142,8 @@
 		    {
 		      /* The proper stub has already been created.  */
 		      free (stub_name);
+		      if (stub_type == ppc_stub_plt_call_r2save)
+			stub_entry->stub_type = stub_type;
 		      continue;
 		    }
 
@@ -11443,7 +12163,8 @@
 		    }
 
 		  stub_entry->stub_type = stub_type;
-		  if (stub_type != ppc_stub_plt_call)
+		  if (stub_type != ppc_stub_plt_call
+		      && stub_type != ppc_stub_plt_call_r2save)
 		    {
 		      stub_entry->target_value = code_value;
 		      stub_entry->target_section = code_sec;
@@ -11455,7 +12176,7 @@
 		    }
 		  stub_entry->h = hash;
 		  stub_entry->plt_ent = plt_ent;
-		  stub_entry->addend = irela->r_addend;
+		  stub_entry->other = hash ? hash->elf.other : sym->st_other;
 
 		  if (stub_entry->h != NULL)
 		    htab->stub_globals += 1;
@@ -11506,9 +12227,9 @@
 
       if (htab->glink_eh_frame != NULL
 	  && !bfd_is_abs_section (htab->glink_eh_frame->output_section)
-	  && (htab->glink_eh_frame->flags & SEC_EXCLUDE) == 0)
+	  && htab->glink_eh_frame->output_section->size != 0)
 	{
-	  bfd_size_type size = 0;
+	  size_t size = 0, align;
 
 	  for (stub_sec = htab->stub_bfd->sections;
 	       stub_sec != NULL;
@@ -11519,10 +12240,22 @@
 	    size += 24;
 	  if (size != 0)
 	    size += sizeof (glink_eh_frame_cie);
+	  align = 1;
+	  align <<= htab->glink_eh_frame->output_section->alignment_power;
+	  align -= 1;
+	  size = (size + align) & ~align;
 	  htab->glink_eh_frame->rawsize = htab->glink_eh_frame->size;
 	  htab->glink_eh_frame->size = size;
 	}
 
+      if (htab->plt_stub_align != 0)
+	for (stub_sec = htab->stub_bfd->sections;
+	     stub_sec != NULL;
+	     stub_sec = stub_sec->next)
+	  if ((stub_sec->flags & SEC_LINKER_CREATED) == 0)
+	    stub_sec->size = ((stub_sec->size + (1 << htab->plt_stub_align) - 1)
+			      & (-1 << htab->plt_stub_align));
+
       for (stub_sec = htab->stub_bfd->sections;
 	   stub_sec != NULL;
 	   stub_sec = stub_sec->next)
@@ -11552,7 +12285,7 @@
    move, we'll be called again.  Provide a value for TOCstart.  */
 
 bfd_vma
-ppc64_elf_toc (bfd *obfd)
+ppc64_elf_set_toc (struct bfd_link_info *info, bfd *obfd)
 {
   asection *s;
   bfd_vma TOCstart;
@@ -11603,9 +12336,88 @@
   if (s != NULL)
     TOCstart = s->output_section->vma + s->output_offset;
 
+  _bfd_set_gp_value (obfd, TOCstart);
+
+  if (info != NULL && s != NULL && is_ppc64_elf (obfd))
+    {
+      struct ppc_link_hash_table *htab = ppc_hash_table (info);
+
+      if (htab != NULL
+	  && htab->elf.hgot != NULL)
+	{
+	  htab->elf.hgot->root.u.def.value = TOC_BASE_OFF;
+	  htab->elf.hgot->root.u.def.section = s;
+	}
+    }
   return TOCstart;
 }
 
+/* Called via elf_link_hash_traverse from ppc64_elf_build_stubs to
+   write out any global entry stubs.  */
+
+static bfd_boolean
+build_global_entry_stubs (struct elf_link_hash_entry *h, void *inf)
+{
+  struct bfd_link_info *info;
+  struct ppc_link_hash_table *htab;
+  struct plt_entry *pent;
+  asection *s;
+
+  if (h->root.type == bfd_link_hash_indirect)
+    return TRUE;
+
+  if (!h->pointer_equality_needed)
+    return TRUE;
+
+  if (h->def_regular)
+    return TRUE;
+
+  info = inf;
+  htab = ppc_hash_table (info);
+  if (htab == NULL)
+    return FALSE;
+
+  s = htab->glink;
+  for (pent = h->plt.plist; pent != NULL; pent = pent->next)
+    if (pent->plt.offset != (bfd_vma) -1
+	&& pent->addend == 0)
+      {
+	bfd_byte *p;
+	asection *plt;
+	bfd_vma off;
+
+	p = s->contents + h->root.u.def.value;
+	plt = htab->elf.splt;
+	if (!htab->elf.dynamic_sections_created
+	    || h->dynindx == -1)
+	  plt = htab->elf.iplt;
+	off = pent->plt.offset + plt->output_offset + plt->output_section->vma;
+	off -= h->root.u.def.value + s->output_offset + s->output_section->vma;
+
+	if (off + 0x80008000 > 0xffffffff || (off & 3) != 0)
+	  {
+	    info->callbacks->einfo
+	      (_("%P: linkage table error against `%T'\n"),
+	       h->root.root.string);
+	    bfd_set_error (bfd_error_bad_value);
+	    htab->stub_error = TRUE;
+	  }
+
+	if (PPC_HA (off) != 0)
+	  {
+	    bfd_put_32 (s->owner, ADDIS_R12_R12 | PPC_HA (off), p);
+	    p += 4;
+	  }
+	bfd_put_32 (s->owner, LD_R12_0R12 | PPC_LO (off), p);
+	p += 4;
+	bfd_put_32 (s->owner, MTCTR_R12, p);
+	p += 4;
+	bfd_put_32 (s->owner, BCTR, p);
+	break;
+      }
+  return TRUE;
+}
+
 /* Build all the stubs associated with the current output file.
    The stubs are kept in a hash table attached to the main linker
    hash table.  This function is called via gldelf64ppc_finish.  */
@@ -11666,7 +12478,9 @@
 	      h->non_elf = 0;
 	    }
 	}
-      plt0 = htab->plt->output_section->vma + htab->plt->output_offset - 16;
+      plt0 = (htab->elf.splt->output_section->vma
+	      + htab->elf.splt->output_offset
+	      - 16);
       if (info->emitrelocations)
 	{
 	  Elf_Internal_Rela *r = get_relocs (htab->glink, 1);
@@ -11681,26 +12495,56 @@
       plt0 -= htab->glink->output_section->vma + htab->glink->output_offset;
       bfd_put_64 (htab->glink->owner, plt0, p);
       p += 8;
-      bfd_put_32 (htab->glink->owner, MFLR_R12, p);
-      p += 4;
-      bfd_put_32 (htab->glink->owner, BCL_20_31, p);
-      p += 4;
-      bfd_put_32 (htab->glink->owner, MFLR_R11, p);
-      p += 4;
-      bfd_put_32 (htab->glink->owner, LD_R2_M16R11, p);
-      p += 4;
-      bfd_put_32 (htab->glink->owner, MTLR_R12, p);
-      p += 4;
-      bfd_put_32 (htab->glink->owner, ADD_R12_R2_R11, p);
-      p += 4;
-      bfd_put_32 (htab->glink->owner, LD_R11_0R12, p);
-      p += 4;
-      bfd_put_32 (htab->glink->owner, LD_R2_0R12 | 8, p);
-      p += 4;
-      bfd_put_32 (htab->glink->owner, MTCTR_R11, p);
-      p += 4;
-      bfd_put_32 (htab->glink->owner, LD_R11_0R12 | 16, p);
-      p += 4;
+      if (htab->opd_abi)
+	{
+	  bfd_put_32 (htab->glink->owner, MFLR_R12, p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, BCL_20_31, p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, MFLR_R11, p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, LD_R2_0R11 | (-16 & 0xfffc), p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, MTLR_R12, p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, ADD_R11_R2_R11, p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, LD_R12_0R11, p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, LD_R2_0R11 | 8, p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, MTCTR_R12, p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, LD_R11_0R11 | 16, p);
+	  p += 4;
+	}
+      else
+	{
+	  bfd_put_32 (htab->glink->owner, MFLR_R0, p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, BCL_20_31, p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, MFLR_R11, p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, LD_R2_0R11 | (-16 & 0xfffc), p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, MTLR_R0, p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, SUB_R12_R12_R11, p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, ADD_R11_R2_R11, p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, ADDI_R0_R12 | (-48 & 0xffff), p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, LD_R12_0R11, p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, SRDI_R0_R0_2, p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, MTCTR_R12, p);
+	  p += 4;
+	  bfd_put_32 (htab->glink->owner, LD_R11_0R11 | 8, p);
+	  p += 4;
+	}
       bfd_put_32 (htab->glink->owner, BCTR, p);
       p += 4;
       while (p - htab->glink->contents < GLINK_CALL_STUB_SIZE)
@@ -11711,26 +12555,33 @@
 
       /* Build the .glink lazy link call stubs.  */
       indx = 0;
-      while (p < htab->glink->contents + htab->glink->size)
+      while (p < htab->glink->contents + htab->glink->rawsize)
 	{
-	  if (indx < 0x8000)
+	  if (htab->opd_abi)
 	    {
-	      bfd_put_32 (htab->glink->owner, LI_R0_0 | indx, p);
-	      p += 4;
-	    }
-	  else
-	    {
-	      bfd_put_32 (htab->glink->owner, LIS_R0_0 | PPC_HI (indx), p);
-	      p += 4;
-	      bfd_put_32 (htab->glink->owner, ORI_R0_R0_0 | PPC_LO (indx), p);
-	      p += 4;
+	      if (indx < 0x8000)
+		{
+		  bfd_put_32 (htab->glink->owner, LI_R0_0 | indx, p);
+		  p += 4;
+		}
+	      else
+		{
+		  bfd_put_32 (htab->glink->owner, LIS_R0_0 | PPC_HI (indx), p);
+		  p += 4;
+		  bfd_put_32 (htab->glink->owner, ORI_R0_R0_0 | PPC_LO (indx),
+			      p);
+		  p += 4;
+		}
 	    }
 	  bfd_put_32 (htab->glink->owner,
 		      B_DOT | ((htab->glink->contents - p + 8) & 0x3fffffc), p);
 	  indx++;
 	  p += 4;
 	}
-      htab->glink->rawsize = p - htab->glink->contents;
+
+      /* Build .glink global entry stubs.  */
+      if (htab->glink->size > htab->glink->rawsize)
+	elf_link_hash_traverse (&htab->elf, build_global_entry_stubs, info);
     }
 
   if (htab->brlt->size != 0)
@@ -11752,17 +12603,21 @@
       && htab->glink_eh_frame->size != 0)
     {
       bfd_vma val;
+      bfd_byte *last_fde;
+      size_t last_fde_len, size, align, pad;
 
       p = bfd_zalloc (htab->glink_eh_frame->owner, htab->glink_eh_frame->size);
       if (p == NULL)
 	return FALSE;
       htab->glink_eh_frame->contents = p;
+      last_fde = p;
 
       htab->glink_eh_frame->rawsize = htab->glink_eh_frame->size;
 
       memcpy (p, glink_eh_frame_cie, sizeof (glink_eh_frame_cie));
       /* CIE length (rewrite in case little-endian).  */
-      bfd_put_32 (htab->elf.dynobj, sizeof (glink_eh_frame_cie) - 4, p);
+      last_fde_len = sizeof (glink_eh_frame_cie) - 4;
+      bfd_put_32 (htab->elf.dynobj, last_fde_len, p);
       p += sizeof (glink_eh_frame_cie);
 
       for (stub_sec = htab->stub_bfd->sections;
@@ -11770,6 +12625,8 @@
 	   stub_sec = stub_sec->next)
 	if ((stub_sec->flags & SEC_LINKER_CREATED) == 0)
 	  {
+	    last_fde = p;
+	    last_fde_len = 16;
 	    /* FDE length.  */
 	    bfd_put_32 (htab->elf.dynobj, 16, p);
 	    p += 4;
@@ -11802,6 +12659,8 @@
 	  }
       if (htab->glink != NULL && htab->glink->size != 0)
 	{
+	  last_fde = p;
+	  last_fde_len = 20;
 	  /* FDE length.  */
 	  bfd_put_32 (htab->elf.dynobj, 20, p);
 	  p += 4;
@@ -11826,7 +12685,7 @@
 	  bfd_put_32 (htab->elf.dynobj, val, p);
 	  p += 4;
 	  /* .glink size.  */
-	  bfd_put_32 (htab->elf.dynobj, htab->glink->rawsize - 8, p);
+	  bfd_put_32 (htab->elf.dynobj, htab->glink->size - 8, p);
 	  p += 4;
 	  /* Augmentation.  */
 	  p += 1;
@@ -11839,7 +12698,16 @@
 	  *p++ = DW_CFA_restore_extended;
 	  *p++ = 65;
 	}
-      htab->glink_eh_frame->size = p - htab->glink_eh_frame->contents;
+      /* Subsume any padding into the last FDE if user .eh_frame
+	 sections are aligned more than glink_eh_frame.  Otherwise any
+	 zero padding will be seen as a terminator.  */
+      size = p - htab->glink_eh_frame->contents;
+      align = 1;
+      align <<= htab->glink_eh_frame->output_section->alignment_power;
+      align -= 1;
+      pad = ((size + align) & ~align) - size;
+      htab->glink_eh_frame->size = size + pad;
+      bfd_put_32 (htab->elf.dynobj, last_fde_len + pad, last_fde);
     }
 
   /* Build the stubs as directed by the stub hash table.  */
@@ -11848,6 +12716,14 @@
   if (htab->relbrlt != NULL)
     htab->relbrlt->reloc_count = 0;
 
+  if (htab->plt_stub_align != 0)
+    for (stub_sec = htab->stub_bfd->sections;
+	 stub_sec != NULL;
+	 stub_sec = stub_sec->next)
+      if ((stub_sec->flags & SEC_LINKER_CREATED) == 0)
+	stub_sec->size = ((stub_sec->size + (1 << htab->plt_stub_align) - 1)
+			  & (-1 << htab->plt_stub_align));
+
   for (stub_sec = htab->stub_bfd->sections;
        stub_sec != NULL;
        stub_sec = stub_sec->next)
@@ -11859,7 +12735,6 @@
       }
 
   if (stub_sec != NULL
-      || htab->glink->rawsize != htab->glink->size
       || (htab->glink_eh_frame != NULL
 	  && htab->glink_eh_frame->rawsize != htab->glink_eh_frame->size))
     {
@@ -11881,14 +12756,16 @@
 			 "  toc adjust   %lu\n"
 			 "  long branch  %lu\n"
 			 "  long toc adj %lu\n"
-			 "  plt call     %lu"),
+			 "  plt call     %lu\n"
+			 "  plt call toc %lu"),
 	       stub_sec_count,
 	       stub_sec_count == 1 ? "" : "s",
 	       htab->stub_count[ppc_stub_long_branch - 1],
 	       htab->stub_count[ppc_stub_long_branch_r2off - 1],
 	       htab->stub_count[ppc_stub_plt_branch - 1],
 	       htab->stub_count[ppc_stub_plt_branch_r2off - 1],
-	       htab->stub_count[ppc_stub_plt_call - 1]);
+	       htab->stub_count[ppc_stub_plt_call - 1],
+	       htab->stub_count[ppc_stub_plt_call_r2save - 1]);
     }
   return TRUE;
 }
@@ -11988,8 +12865,8 @@
   bfd_vma TOCstart;
   bfd_boolean ret = TRUE;
   bfd_boolean is_opd;
-  /* Disabled until we sort out how ld should choose 'y' vs 'at'.  */
-  bfd_boolean is_power4 = FALSE;
+  /* Assume 'at' branch hints.  */
+  bfd_boolean is_isa_v2 = TRUE;
   bfd_vma d_offset = (bfd_big_endian (output_bfd) ? 2 : 0);
 
   /* Initialize howto table if needed.  */
@@ -12032,6 +12909,7 @@
       bfd_vma relocation;
       bfd_boolean unresolved_reloc;
       bfd_boolean warned;
+      enum { DEST_NORMAL, DEST_OPD, DEST_STUB } reloc_dest;
       unsigned int insn;
       unsigned int mask;
       struct ppc_stub_hash_entry *stub_entry;
@@ -12096,18 +12974,53 @@
 				   unresolved_reloc, warned);
 	  sym_name = h_elf->root.root.string;
 	  sym_type = h_elf->type;
+	  if (sec != NULL
+	      && sec->owner == output_bfd
+	      && strcmp (sec->name, ".opd") == 0)
+	    {
+	      /* This is a symbol defined in a linker script.  All
+		 such are defined in output sections, even those
+		 defined by simple assignment from a symbol defined in
+		 an input section.  Transfer the symbol to an
+		 appropriate input .opd section, so that a branch to
+		 this symbol will be mapped to the location specified
+		 by the opd entry.  */
+	      struct bfd_link_order *lo;
+	      for (lo = sec->map_head.link_order; lo != NULL; lo = lo->next)
+		if (lo->type == bfd_indirect_link_order)
+		  {
+		    asection *isec = lo->u.indirect.section;
+		    if (h_elf->root.u.def.value >= isec->output_offset
+			&& h_elf->root.u.def.value < (isec->output_offset
+						      + isec->size))
+		      {
+			h_elf->root.u.def.value -= isec->output_offset;
+			h_elf->root.u.def.section = isec;
+			sec = isec;
+			break;
+		      }
+		  }
+	    }
 	}
       h = (struct ppc_link_hash_entry *) h_elf;
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend,
-					 ppc64_elf_howto_table[r_type],
+					 rel, 1, relend,
+					 ppc64_elf_howto_table[r_type], 0,
 					 contents);
 
       if (info->relocatable)
 	continue;
 
+      if (h != NULL && &h->elf == htab->elf.hgot)
+	{
+	  relocation = (TOCstart
+			+ htab->stub_group[input_section->id].toc_off);
+	  sec = bfd_abs_section_ptr;
+	  unresolved_reloc = FALSE;
+	}
+
       /* TLS optimizations.  Replace instruction sequences and relocs
 	 based on information we collected in tls_optimize.  We edit
 	 RELOCS so that --emit-relocs will output something sensible
@@ -12162,8 +13075,8 @@
 	  else
 	    info->callbacks->einfo
 	      (!IS_PPC64_TLS_RELOC (r_type)
-	       ? _("%P: %H: %s used with TLS symbol %s\n")
-	       : _("%P: %H: %s used with non-TLS symbol %s\n"),
+	       ? _("%P: %H: %s used with TLS symbol `%T'\n")
+	       : _("%P: %H: %s used with non-TLS symbol `%T'\n"),
 	       input_bfd, input_section, rel->r_offset,
 	       ppc64_elf_howto_table[r_type]->name,
 	       sym_name);
@@ -12563,12 +13476,46 @@
 	      rel->r_info = ELF64_R_INFO (r_symndx, r_type);
 	    }
 	  break;
+
+	case R_PPC64_REL16_HA:
+	  /* If we are generating a non-PIC executable, edit
+	     .	0:	addis 2,12,.TOC.-0b@ha
+	     .		addi 2,2,.TOC.-0b@l
+	     used by ELFv2 global entry points to set up r2, to
+	     .		lis 2,.TOC.@ha
+	     .		addi 2,2,.TOC.@l
+	     if .TOC. is in range.  */
+	  if (!info->shared
+	      && h != NULL && &h->elf == htab->elf.hgot
+	      && rel + 1 < relend
+	      && rel[1].r_info == ELF64_R_INFO (r_symndx, R_PPC64_REL16_LO)
+	      && rel[1].r_offset == rel->r_offset + 4
+	      && rel[1].r_addend == rel->r_addend + 4
+	      && relocation + 0x80008000 <= 0xffffffff)
+	    {
+	      unsigned int insn1, insn2;
+	      bfd_vma offset = rel->r_offset - d_offset;
+	      insn1 = bfd_get_32 (output_bfd, contents + offset);
+	      insn2 = bfd_get_32 (output_bfd, contents + offset + 4);
+	      if ((insn1 & 0xffff0000) == 0x3c4c0000 /* addis 2,12 */
+		  && (insn2 & 0xffff0000) == 0x38420000 /* addi 2,2 */)
+		{
+		  r_type = R_PPC64_ADDR16_HA;
+		  rel->r_info = ELF64_R_INFO (r_symndx, r_type);
+		  rel->r_addend -= d_offset;
+		  rel[1].r_info = ELF64_R_INFO (r_symndx, R_PPC64_ADDR16_LO);
+		  rel[1].r_addend -= d_offset + 4;
+		  bfd_put_32 (output_bfd, 0x3c400000, contents + offset);
+		}
+	    }
+	  break;
 	}
 
       /* Handle other relocations that tweak non-addend part of insn.  */
       insn = 0;
       max_br_offset = 1 << 25;
       addend = rel->r_addend;
+      reloc_dest = DEST_NORMAL;
       switch (r_type)
 	{
 	default:
@@ -12584,7 +13531,8 @@
 	      insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
 	      if (insn == NOP
 		  || insn == CROR_151515 || insn == CROR_313131)
-		bfd_put_32 (input_bfd, STD_R2_40R1,
+		bfd_put_32 (input_bfd,
+			    STD_R2_0R1 + STK_TOC (htab),
 			    contents + rel->r_offset);
 	    }
 	  break;
@@ -12622,82 +13570,101 @@
 					   htab);
 	  if (stub_entry != NULL
 	      && (stub_entry->stub_type == ppc_stub_plt_call
+		  || stub_entry->stub_type == ppc_stub_plt_call_r2save
 		  || stub_entry->stub_type == ppc_stub_plt_branch_r2off
 		  || stub_entry->stub_type == ppc_stub_long_branch_r2off))
 	    {
 	      bfd_boolean can_plt_call = FALSE;
 
+	      /* All of these stubs will modify r2, so there must be a
+		 branch and link followed by a nop.  The nop is
+		 replaced by an insn to restore r2.  */
 	      if (rel->r_offset + 8 <= input_section->size)
 		{
-		  unsigned long nop;
-		  nop = bfd_get_32 (input_bfd, contents + rel->r_offset + 4);
-		  if (nop == NOP
-		      || nop == CROR_151515 || nop == CROR_313131)
+		  unsigned long br;
+
+		  br = bfd_get_32 (input_bfd,
+				   contents + rel->r_offset);
+		  if ((br & 1) != 0)
 		    {
-		      if (h != NULL
-			  && (h == htab->tls_get_addr_fd
-			      || h == htab->tls_get_addr)
-			  && !htab->no_tls_get_addr_opt)
+		      unsigned long nop;
+
+		      nop = bfd_get_32 (input_bfd,
+					contents + rel->r_offset + 4);
+		      if (nop == NOP
+			  || nop == CROR_151515 || nop == CROR_313131)
 			{
-			  /* Special stub used, leave nop alone.  */
+			  if (h != NULL
+			      && (h == htab->tls_get_addr_fd
+				  || h == htab->tls_get_addr)
+			      && !htab->no_tls_get_addr_opt)
+			    {
+			      /* Special stub used, leave nop alone.  */
+			    }
+			  else
+			    bfd_put_32 (input_bfd,
+					LD_R2_0R1 + STK_TOC (htab),
+					contents + rel->r_offset + 4);
+			  can_plt_call = TRUE;
 			}
-		      else
-			bfd_put_32 (input_bfd, LD_R2_40R1,
-				    contents + rel->r_offset + 4);
+		    }
+		}
+
+	      if (!can_plt_call && h != NULL)
+		{
+		  const char *name = h->elf.root.root.string;
+
+		  if (*name == '.')
+		    ++name;
+
+		  if (strncmp (name, "__libc_start_main", 17) == 0
+		      && (name[17] == 0 || name[17] == '@'))
+		    {
+		      /* Allow crt1 branch to go via a toc adjusting
+			 stub.  Other calls that never return could do
+			 the same, if we could detect such.  */
 		      can_plt_call = TRUE;
 		    }
 		}
 
 	      if (!can_plt_call)
 		{
-		  if (stub_entry->stub_type == ppc_stub_plt_call)
+		  /* g++ as of 20130507 emits self-calls without a
+		     following nop.  This is arguably wrong since we
+		     have conflicting information.  On the one hand a
+		     global symbol and on the other a local call
+		     sequence, but don't error for this special case.
+		     It isn't possible to cheaply verify we have
+		     exactly such a call.  Allow all calls to the same
+		     section.  */
+		  asection *code_sec = sec;
+
+		  if (get_opd_info (sec) != NULL)
 		    {
-		      /* If this is a plain branch rather than a branch
-			 and link, don't require a nop.  However, don't
-			 allow tail calls in a shared library as they
-			 will result in r2 being corrupted.  */
-		      unsigned long br;
-		      br = bfd_get_32 (input_bfd, contents + rel->r_offset);
-		      if (info->executable && (br & 1) == 0)
-			can_plt_call = TRUE;
-		      else
-			stub_entry = NULL;
+		      bfd_vma off = (relocation + addend
+				     - sec->output_section->vma
+				     - sec->output_offset);
+
+		      opd_entry_value (sec, off, &code_sec, NULL, FALSE);
 		    }
-		  else if (h != NULL
-			   && strcmp (h->elf.root.root.string,
-				      ".__libc_start_main") == 0)
-		    {
-		      /* Allow crt1 branch to go via a toc adjusting stub.  */
-		      can_plt_call = TRUE;
-		    }
-		  else
-		    {
-		      if (strcmp (input_section->output_section->name,
-				  ".init") == 0
-			  || strcmp (input_section->output_section->name,
-				     ".fini") == 0)
-			info->callbacks->einfo
-			  (_("%P: %H: automatic multiple TOCs "
-			     "not supported using your crt files; "
-			     "recompile with -mminimal-toc or upgrade gcc\n"),
-			   input_bfd, input_section, rel->r_offset);
-		      else
-			info->callbacks->einfo
-			  (_("%P: %H: sibling call optimization to `%s' "
-			     "does not allow automatic multiple TOCs; "
-			     "recompile with -mminimal-toc or "
-			     "-fno-optimize-sibling-calls, "
-			     "or make `%s' extern\n"),
-			   input_bfd, input_section, rel->r_offset,
-			   sym_name,
-			   sym_name);
-		      bfd_set_error (bfd_error_bad_value);
-		      ret = FALSE;
-		    }
+		  if (code_sec == input_section)
+		    can_plt_call = TRUE;
+		}
+
+	      if (!can_plt_call)
+		{
+		  info->callbacks->einfo
+		    (_("%P: %H: call to `%T' lacks nop, can't restore toc; "
+		       "recompile with -fPIC"),
+		     input_bfd, input_section, rel->r_offset, sym_name);
+
+		  bfd_set_error (bfd_error_bad_value);
+		  ret = FALSE;
 		}
 
 	      if (can_plt_call
-		  && stub_entry->stub_type == ppc_stub_plt_call)
+		  && (stub_entry->stub_type == ppc_stub_plt_call
+		      || stub_entry->stub_type == ppc_stub_plt_call_r2save))
 		unresolved_reloc = FALSE;
 	    }
 
@@ -12715,6 +13682,7 @@
 		{
 		  relocation = dest;
 		  addend = 0;
+		  reloc_dest = DEST_OPD;
 		}
 	    }
 
@@ -12724,6 +13692,10 @@
 		  + input_section->output_offset
 		  + input_section->output_section->vma);
 
+	  relocation += PPC64_LOCAL_ENTRY_OFFSET (fdh
+						  ? fdh->elf.other
+						  : sym->st_other);
+
 	  if (stub_entry != NULL
 	      && (stub_entry->stub_type == ppc_stub_long_branch
 		  || stub_entry->stub_type == ppc_stub_plt_branch)
@@ -12742,8 +13714,12 @@
 			    + stub_entry->stub_sec->output_offset
 			    + stub_entry->stub_sec->output_section->vma);
 	      addend = 0;
+	      reloc_dest = DEST_STUB;
 
- 	      if (stub_entry->stub_type == ppc_stub_plt_call
+ 	      if ((stub_entry->stub_type == ppc_stub_plt_call
+		   || stub_entry->stub_type == ppc_stub_plt_call_r2save)
+		  && (ALWAYS_EMIT_R2SAVE
+		      || stub_entry->stub_type == ppc_stub_plt_call_r2save)
 		  && rel + 1 < relend
 		  && rel[1].r_offset == rel->r_offset + 4
 		  && ELF64_R_TYPE (rel[1].r_info) == R_PPC64_TOCSAVE)
@@ -12752,7 +13728,7 @@
 
 	  if (insn != 0)
 	    {
-	      if (is_power4)
+	      if (is_isa_v2)
 		{
 		  /* Set 'a' bit.  This is 0b00010 in BO field for branch
 		     on CR(BI) insns (BO == 001at or 011at), and 0b01000
@@ -12796,7 +13772,7 @@
 	{
 	default:
 	  info->callbacks->einfo
-	    (_("%P: %B: unknown relocation type %d for symbol %s\n"),
+	    (_("%P: %B: unknown relocation type %d for `%T'\n"),
 	     input_bfd, (int) r_type, sym_name);
 
 	  bfd_set_error (bfd_error_bad_value);
@@ -12873,7 +13849,7 @@
 		    if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared,
 							  &h->elf)
 			|| (info->shared
-			    && SYMBOL_CALLS_LOCAL (info, &h->elf)))
+			    && SYMBOL_REFERENCES_LOCAL (info, &h->elf)))
 		      /* This is actually a static link, or it is a
 			 -Bsymbolic link and the symbol is defined
 			 locally, or the symbol was forced to be local
@@ -12881,6 +13857,7 @@
 		      ;
 		    else
 		      {
+			BFD_ASSERT (h->elf.dynindx != -1);
 			indx = h->elf.dynindx;
 			unresolved_reloc = FALSE;
 		      }
@@ -12928,15 +13905,15 @@
 		ifunc = (h != NULL
 			 ? h->elf.type == STT_GNU_IFUNC
 			 : ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC);
-		if ((info->shared || indx != 0)
-		    && (h == NULL
-			|| (tls_type == (TLS_TLS | TLS_LD)
-			    && !h->elf.def_dynamic)
-			|| ELF_ST_VISIBILITY (h->elf.other) == STV_DEFAULT
-			|| h->elf.root.type != bfd_link_hash_undefweak))
+		if (ifunc)
+		  relgot = htab->elf.irelplt;
+		else if ((info->shared || indx != 0)
+			 && (h == NULL
+			     || (tls_type == (TLS_TLS | TLS_LD)
+				 && !h->elf.def_dynamic)
+			     || ELF_ST_VISIBILITY (h->elf.other) == STV_DEFAULT
+			     || h->elf.root.type != bfd_link_hash_undefweak))
 		  relgot = ppc64_elf_tdata (ent->owner)->relgot;
-		else if (ifunc)
-		  relgot = htab->reliplt;
 		if (relgot != NULL)
 		  {
 		    outrel.r_offset = (got->output_section->vma
@@ -13043,17 +14020,18 @@
 	     symbol.  This happens when statically linking PIC code,
 	     or when using -Bsymbolic.  Go find a match if there is a
 	     PLT entry.  */
-	  if (htab->plt != NULL)
+	  if (htab->elf.splt != NULL)
 	    {
 	      struct plt_entry *ent;
 	      for (ent = h->elf.plt.plist; ent != NULL; ent = ent->next)
-		if (ent->addend == orig_rel.r_addend
-		    && ent->plt.offset != (bfd_vma) -1)
+		if (ent->plt.offset != (bfd_vma) -1
+		    && ent->addend == orig_rel.r_addend)
 		  {
-		    relocation = (htab->plt->output_section->vma
-				  + htab->plt->output_offset
+		    relocation = (htab->elf.splt->output_section->vma
+				  + htab->elf.splt->output_offset
 				  + ent->plt.offset);
 		    unresolved_reloc = FALSE;
+		    break;
 		  }
 	    }
 	  break;
@@ -13113,6 +14091,8 @@
 	case R_PPC64_TPREL16_HA:
 	case R_PPC64_TPREL16_DS:
 	case R_PPC64_TPREL16_LO_DS:
+	case R_PPC64_TPREL16_HIGH:
+	case R_PPC64_TPREL16_HIGHA:
 	case R_PPC64_TPREL16_HIGHER:
 	case R_PPC64_TPREL16_HIGHERA:
 	case R_PPC64_TPREL16_HIGHEST:
@@ -13147,6 +14127,8 @@
 	case R_PPC64_DTPREL16_HA:
 	case R_PPC64_DTPREL16_DS:
 	case R_PPC64_DTPREL16_LO_DS:
+	case R_PPC64_DTPREL16_HIGH:
+	case R_PPC64_DTPREL16_HIGHA:
 	case R_PPC64_DTPREL16_HIGHER:
 	case R_PPC64_DTPREL16_HIGHERA:
 	case R_PPC64_DTPREL16_HIGHEST:
@@ -13179,6 +14161,8 @@
 	case R_PPC64_ADDR16_DS:
 	case R_PPC64_ADDR16_HA:
 	case R_PPC64_ADDR16_HI:
+	case R_PPC64_ADDR16_HIGH:
+	case R_PPC64_ADDR16_HIGHA:
 	case R_PPC64_ADDR16_HIGHER:
 	case R_PPC64_ADDR16_HIGHERA:
 	case R_PPC64_ADDR16_HIGHEST:
@@ -13250,10 +14234,13 @@
 
 	      if (skip)
 		memset (&outrel, 0, sizeof outrel);
-	      else if (!SYMBOL_CALLS_LOCAL (info, &h->elf)
+	      else if (!SYMBOL_REFERENCES_LOCAL (info, &h->elf)
 		       && !is_opd
 		       && r_type != R_PPC64_TOC)
-		outrel.r_info = ELF64_R_INFO (h->elf.dynindx, r_type);
+		{
+		  BFD_ASSERT (h->elf.dynindx != -1);
+		  outrel.r_info = ELF64_R_INFO (h->elf.dynindx, r_type);
+		}
 	      else
 		{
 		  /* This symbol is local, or marked to become local,
@@ -13302,8 +14289,8 @@
 			  : ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC)
 			{
 			  info->callbacks->einfo
-			    (_("%P: %H: relocation %s for indirect "
-			       "function %s unsupported\n"),
+			    (_("%P: %H: %s for indirect "
+			       "function `%T' unsupported\n"),
 			     input_bfd, input_section, rel->r_offset,
 			     ppc64_elf_howto_table[r_type]->name,
 			     sym_name);
@@ -13347,8 +14334,10 @@
 		}
 
 	      sreloc = elf_section_data (input_section)->sreloc;
-	      if (!htab->elf.dynamic_sections_created)
-		sreloc = htab->reliplt;
+	      if (h != NULL
+		  ? h->elf.type == STT_GNU_IFUNC
+		  : ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC)
+		sreloc = htab->elf.irelplt;
 	      if (sreloc == NULL)
 		abort ();
 
@@ -13407,7 +14396,7 @@
 	  /* These ones haven't been implemented yet.  */
 
 	  info->callbacks->einfo
-	    (_("%P: %B: relocation %s is not supported for symbol %s\n"),
+	    (_("%P: %B: %s is not supported for `%T'\n"),
 	     input_bfd,
 	     ppc64_elf_howto_table[r_type]->name, sym_name);
 
@@ -13488,21 +14477,20 @@
 	default:
 	  break;
 
-	case R_PPC64_ADDR16_HA:
 	case R_PPC64_REL16_HA:
+	case R_PPC64_ADDR16_HA:
+	case R_PPC64_ADDR16_HIGHA:
 	case R_PPC64_ADDR16_HIGHERA:
 	case R_PPC64_ADDR16_HIGHESTA:
 	case R_PPC64_TOC16_HA:
 	case R_PPC64_SECTOFF_HA:
 	case R_PPC64_TPREL16_HA:
-	case R_PPC64_DTPREL16_HA:
-	case R_PPC64_TPREL16_HIGHER:
+	case R_PPC64_TPREL16_HIGHA:
 	case R_PPC64_TPREL16_HIGHERA:
-	case R_PPC64_TPREL16_HIGHEST:
 	case R_PPC64_TPREL16_HIGHESTA:
-	case R_PPC64_DTPREL16_HIGHER:
+	case R_PPC64_DTPREL16_HA:
+	case R_PPC64_DTPREL16_HIGHA:
 	case R_PPC64_DTPREL16_HIGHERA:
-	case R_PPC64_DTPREL16_HIGHEST:
 	case R_PPC64_DTPREL16_HIGHESTA:
 	  /* It's just possible that this symbol is a weak symbol
 	     that's not actually defined anywhere. In that case,
@@ -13574,10 +14562,10 @@
 	  && !((input_section->flags & SEC_DEBUGGING) != 0
 	       && h->elf.def_dynamic)
 	  && _bfd_elf_section_offset (output_bfd, info, input_section,
-                                      rel->r_offset) != (bfd_vma) -1)
+				      rel->r_offset) != (bfd_vma) -1)
 	{
 	  info->callbacks->einfo
-	    (_("%P: %H: unresolvable %s relocation against symbol `%s'\n"),
+	    (_("%P: %H: unresolvable %s against `%T'\n"),
 	     input_bfd, input_section, rel->r_offset,
 	     ppc64_elf_howto_table[(int) r_type]->name,
 	     h->elf.root.root.string);
@@ -13594,8 +14582,21 @@
 
       if (r != bfd_reloc_ok)
 	{
-	  if (sym_name == NULL)
-	    sym_name = "(null)";
+	  char *more_info = NULL;
+	  const char *reloc_name = ppc64_elf_howto_table[r_type]->name;
+
+	  if (reloc_dest != DEST_NORMAL)
+	    {
+	      more_info = bfd_malloc (strlen (reloc_name) + 8);
+	      if (more_info != NULL)
+		{
+		  strcpy (more_info, reloc_name);
+		  strcat (more_info, (reloc_dest == DEST_OPD
+				      ? " (OPD)" : " (stub)"));
+		  reloc_name = more_info;
+		}
+	    }
+
 	  if (r == bfd_reloc_overflow)
 	    {
 	      if (warned)
@@ -13614,22 +14615,21 @@
 		}
 
 	      if (!((*info->callbacks->reloc_overflow)
-		    (info, (h ? &h->elf.root : NULL), sym_name,
-		     ppc64_elf_howto_table[r_type]->name,
-		     orig_rel.r_addend, input_bfd, input_section,
-		     rel->r_offset)))
+		    (info, &h->elf.root, sym_name,
+		     reloc_name, orig_rel.r_addend,
+		     input_bfd, input_section, rel->r_offset)))
 		return FALSE;
 	    }
 	  else
 	    {
 	      info->callbacks->einfo
-		(_("%P: %H: %s reloc against `%s': error %d\n"),
+		(_("%P: %H: %s against `%T': error %d\n"),
 		 input_bfd, input_section, rel->r_offset,
-		 ppc64_elf_howto_table[r_type]->name,
-		 sym_name,
-		 (int) r);
+		 reloc_name, sym_name, (int) r);
 	      ret = FALSE;
 	    }
+	  if (more_info != NULL)
+	    free (more_info);
 	}
     }
 
@@ -13643,8 +14643,8 @@
       bfd_size_type amt;
       amt = input_section->reloc_count * sizeof (Elf_Internal_Rela);
       rel = bfd_alloc (input_bfd, amt);
-      BFD_ASSERT (ppc64_elf_tdata (input_bfd)->opd_relocs == NULL);
-      ppc64_elf_tdata (input_bfd)->opd_relocs = rel;
+      BFD_ASSERT (ppc64_elf_tdata (input_bfd)->opd.relocs == NULL);
+      ppc64_elf_tdata (input_bfd)->opd.relocs = rel;
       if (rel == NULL)
 	return FALSE;
       memcpy (rel, relocs, amt);
@@ -13691,7 +14691,7 @@
 ppc64_elf_finish_dynamic_symbol (bfd *output_bfd,
 				 struct bfd_link_info *info,
 				 struct elf_link_hash_entry *h,
-				 Elf_Internal_Sym *sym)
+				 Elf_Internal_Sym *sym ATTRIBUTE_UNUSED)
 {
   struct ppc_link_hash_table *htab;
   struct plt_entry *ent;
@@ -13714,30 +14714,57 @@
 			&& h->def_regular
 			&& (h->root.type == bfd_link_hash_defined
 			    || h->root.type == bfd_link_hash_defweak));
-	    rela.r_offset = (htab->iplt->output_section->vma
-			     + htab->iplt->output_offset
+	    rela.r_offset = (htab->elf.iplt->output_section->vma
+			     + htab->elf.iplt->output_offset
 			     + ent->plt.offset);
-	    rela.r_info = ELF64_R_INFO (0, R_PPC64_JMP_IREL);
+	    if (htab->opd_abi)
+	      rela.r_info = ELF64_R_INFO (0, R_PPC64_JMP_IREL);
+	    else
+	      rela.r_info = ELF64_R_INFO (0, R_PPC64_IRELATIVE);
 	    rela.r_addend = (h->root.u.def.value
 			     + h->root.u.def.section->output_offset
 			     + h->root.u.def.section->output_section->vma
 			     + ent->addend);
-	    loc = (htab->reliplt->contents
-		   + (htab->reliplt->reloc_count++
+	    loc = (htab->elf.irelplt->contents
+		   + (htab->elf.irelplt->reloc_count++
 		      * sizeof (Elf64_External_Rela)));
 	  }
 	else
 	  {
-	    rela.r_offset = (htab->plt->output_section->vma
-			     + htab->plt->output_offset
+	    rela.r_offset = (htab->elf.splt->output_section->vma
+			     + htab->elf.splt->output_offset
 			     + ent->plt.offset);
 	    rela.r_info = ELF64_R_INFO (h->dynindx, R_PPC64_JMP_SLOT);
 	    rela.r_addend = ent->addend;
-	    loc = (htab->relplt->contents
-		   + ((ent->plt.offset - PLT_INITIAL_ENTRY_SIZE)
-		      / (PLT_ENTRY_SIZE / sizeof (Elf64_External_Rela))));
+	    loc = (htab->elf.srelplt->contents
+		   + ((ent->plt.offset - PLT_INITIAL_ENTRY_SIZE (htab))
+		      / PLT_ENTRY_SIZE (htab) * sizeof (Elf64_External_Rela)));
 	  }
 	bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
+
+	if (!htab->opd_abi)
+	  {
+	    if (!h->def_regular)
+	      {
+		/* Mark the symbol as undefined, rather than as
+		   defined in glink.  Leave the value if there were
+		   any relocations where pointer equality matters
+		   (this is a clue for the dynamic linker, to make
+		   function pointer comparisons work between an
+		   application and shared library), otherwise set it
+		   to zero.  */
+		sym->st_shndx = SHN_UNDEF;
+		if (!h->pointer_equality_needed)
+		  sym->st_value = 0;
+		else if (!h->ref_regular_nonweak)
+		  {
+		    /* This breaks function pointer comparisons, but
+		       that is better than breaking tests for a NULL
+		       function pointer.  */
+		    sym->st_value = 0;
+		  }
+	      }
+	  }
       }
 
   if (h->needs_copy)
@@ -13760,10 +14787,6 @@
       bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
     }
 
-  /* Mark some specially defined symbols as absolute.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0)
-    sym->st_shndx = SHN_ABS;
-
   return TRUE;
 }
 
@@ -13771,9 +14794,15 @@
    dynamic linker, before writing them out.  */
 
 static enum elf_reloc_type_class
-ppc64_elf_reloc_type_class (const Elf_Internal_Rela *rela)
+ppc64_elf_reloc_type_class (const struct bfd_link_info *info,
+			    const asection *rel_sec,
+			    const Elf_Internal_Rela *rela)
 {
   enum elf_ppc64_reloc_type r_type;
+  struct ppc_link_hash_table *htab = ppc_hash_table (info);
+
+  if (rel_sec == htab->elf.irelplt)
+    return reloc_class_ifunc;
 
   r_type = ELF64_R_TYPE (rela->r_info);
   switch (r_type)
@@ -13804,13 +14833,13 @@
     return FALSE;
 
   dynobj = htab->elf.dynobj;
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (htab->elf.dynamic_sections_created)
     {
       Elf64_External_Dyn *dyncon, *dynconend;
 
-      if (sdyn == NULL || htab->got == NULL)
+      if (sdyn == NULL || htab->elf.sgot == NULL)
 	abort ();
 
       dyncon = (Elf64_External_Dyn *) sdyn->contents;
@@ -13834,7 +14863,7 @@
 		 of glink rather than the first entry point, which is
 		 what ld.so needs, and now have a bigger stub to
 		 support automatic multiple TOCs.  */
-	      dyn.d_un.d_ptr += GLINK_CALL_STUB_SIZE - 32;
+	      dyn.d_un.d_ptr += GLINK_CALL_STUB_SIZE - 8 * 4;
 	      break;
 
 	    case DT_PPC64_OPD:
@@ -13844,6 +14873,11 @@
 	      dyn.d_un.d_ptr = s->vma;
 	      break;
 
+	    case DT_PPC64_OPT:
+	      if (htab->do_multi_toc && htab->multi_toc_needed)
+		dyn.d_un.d_val |= PPC64_OPT_MULTI_TOC;
+	      break;
+
 	    case DT_PPC64_OPDSZ:
 	      s = bfd_get_section_by_name (output_bfd, ".opd");
 	      if (s == NULL)
@@ -13852,23 +14886,23 @@
 	      break;
 
 	    case DT_PLTGOT:
-	      s = htab->plt;
+	      s = htab->elf.splt;
 	      dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
 	      break;
 
 	    case DT_JMPREL:
-	      s = htab->relplt;
+	      s = htab->elf.srelplt;
 	      dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
 	      break;
 
 	    case DT_PLTRELSZ:
-	      dyn.d_un.d_val = htab->relplt->size;
+	      dyn.d_un.d_val = htab->elf.srelplt->size;
 	      break;
 
 	    case DT_RELASZ:
 	      /* Don't count procedure linkage table relocs in the
 		 overall reloc count.  */
-	      s = htab->relplt;
+	      s = htab->elf.srelplt;
 	      if (s == NULL)
 		continue;
 	      dyn.d_un.d_val -= s->size;
@@ -13878,7 +14912,7 @@
 	      /* We may not be using the standard ELF linker script.
 		 If .rela.plt is the first .rela section, we adjust
 		 DT_RELA to not include it.  */
-	      s = htab->relplt;
+	      s = htab->elf.srelplt;
 	      if (s == NULL)
 		continue;
 	      if (dyn.d_un.d_ptr != s->output_section->vma + s->output_offset)
@@ -13891,23 +14925,23 @@
 	}
     }
 
-  if (htab->got != NULL && htab->got->size != 0)
+  if (htab->elf.sgot != NULL && htab->elf.sgot->size != 0)
     {
       /* Fill in the first entry in the global offset table.
 	 We use it to hold the link-time TOCbase.  */
       bfd_put_64 (output_bfd,
 		  elf_gp (output_bfd) + TOC_BASE_OFF,
-		  htab->got->contents);
+		  htab->elf.sgot->contents);
 
       /* Set .got entry size.  */
-      elf_section_data (htab->got->output_section)->this_hdr.sh_entsize = 8;
+      elf_section_data (htab->elf.sgot->output_section)->this_hdr.sh_entsize = 8;
     }
 
-  if (htab->plt != NULL && htab->plt->size != 0)
+  if (htab->elf.splt != NULL && htab->elf.splt->size != 0)
     {
       /* Set .plt entry size.  */
-      elf_section_data (htab->plt->output_section)->this_hdr.sh_entsize
-	= PLT_ENTRY_SIZE;
+      elf_section_data (htab->elf.splt->output_section)->this_hdr.sh_entsize
+	= PLT_ENTRY_SIZE (htab);
     }
 
   /* brlt is SEC_LINKER_CREATED, so we need to write out relocs for
@@ -13932,7 +14966,7 @@
 
 
   if (htab->glink_eh_frame != NULL
-      && htab->glink_eh_frame->sec_info_type == ELF_INFO_TYPE_EH_FRAME
+      && htab->glink_eh_frame->sec_info_type == SEC_INFO_TYPE_EH_FRAME
       && !_bfd_elf_write_section_eh_frame (output_bfd, info,
 					   htab->glink_eh_frame,
 					   htab->glink_eh_frame->contents))
@@ -13970,3 +15004,22 @@
 }
 
 #include "elf64-target.h"
+
+/* FreeBSD support */
+
+#undef  TARGET_LITTLE_SYM
+#undef  TARGET_LITTLE_NAME
+
+#undef  TARGET_BIG_SYM
+#define TARGET_BIG_SYM	bfd_elf64_powerpc_freebsd_vec
+#undef  TARGET_BIG_NAME
+#define TARGET_BIG_NAME "elf64-powerpc-freebsd"
+
+#undef  ELF_OSABI
+#define	ELF_OSABI       ELFOSABI_FREEBSD
+
+#undef  elf64_bed
+#define elf64_bed	elf64_powerpc_fbsd_bed
+
+#include "elf64-target.h"
+
diff --git a/bfd/elf64-ppc.h b/bfd/elf64-ppc.h
index 9026c56..06c655f 100644
--- a/bfd/elf64-ppc.h
+++ b/bfd/elf64-ppc.h
@@ -1,5 +1,5 @@
 /* PowerPC64-specific support for 64-bit ELF.
-   Copyright 2002, 2003, 2004, 2005, 2007, 2008, 2010, 2011
+   Copyright 2002, 2003, 2004, 2005, 2007, 2008, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -19,7 +19,7 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-void ppc64_elf_init_stub_bfd
+bfd_boolean ppc64_elf_init_stub_bfd
   (bfd *, struct bfd_link_info *);
 bfd_boolean ppc64_elf_edit_opd
   (struct bfd_link_info *, bfd_boolean);
@@ -31,8 +31,8 @@
   (struct bfd_link_info *);
 bfd_boolean ppc64_elf_has_small_toc_reloc
   (asection *);
-bfd_vma ppc64_elf_toc
-  (bfd *);
+bfd_vma ppc64_elf_set_toc
+  (struct bfd_link_info *, bfd *);
 int ppc64_elf_setup_section_lists
   (struct bfd_link_info *, asection *(*) (const char *, asection *),
    void (*) (void));
@@ -49,7 +49,7 @@
 bfd_boolean ppc64_elf_next_input_section
   (struct bfd_link_info *, asection *);
 bfd_boolean ppc64_elf_size_stubs
-  (struct bfd_link_info *, bfd_signed_vma, bfd_boolean);
+(struct bfd_link_info *, bfd_signed_vma, bfd_boolean, int, int);
 bfd_boolean ppc64_elf_build_stubs
   (bfd_boolean, struct bfd_link_info *, char **);
 void ppc64_elf_restore_symbols
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index 9884da0..3aea98c 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -1,6 +1,6 @@
 /* IBM S/390-specific support for 64-bit ELF
    Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-   2010, 2011 Free Software Foundation, Inc.
+   2010, 2011, 2012 Free Software Foundation, Inc.
    Contributed Martin Schwidefsky ([email protected]).
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -25,75 +25,25 @@
 #include "bfdlink.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
-
-static reloc_howto_type *elf_s390_reloc_type_lookup
-  PARAMS ((bfd *, bfd_reloc_code_real_type));
-static void elf_s390_info_to_howto
-  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
-static bfd_boolean elf_s390_is_local_label_name
-  PARAMS ((bfd *, const char *));
-static struct bfd_hash_entry *link_hash_newfunc
-  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static struct bfd_link_hash_table *elf_s390_link_hash_table_create
-  PARAMS ((bfd *));
-static bfd_boolean create_got_section
-  PARAMS((bfd *, struct bfd_link_info *));
-static bfd_boolean elf_s390_create_dynamic_sections
-  PARAMS((bfd *, struct bfd_link_info *));
-static void elf_s390_copy_indirect_symbol
-  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *,
-	   struct elf_link_hash_entry *));
-static bfd_boolean elf_s390_check_relocs
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-	   const Elf_Internal_Rela *));
-struct elf_s390_link_hash_entry;
-static void elf_s390_adjust_gotplt
-  PARAMS ((struct elf_s390_link_hash_entry *));
-static bfd_boolean elf_s390_adjust_dynamic_symbol
-  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
-static bfd_boolean allocate_dynrelocs
-  PARAMS ((struct elf_link_hash_entry *, PTR));
-static bfd_boolean readonly_dynrelocs
-  PARAMS ((struct elf_link_hash_entry *, PTR));
-static bfd_boolean elf_s390_size_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-static bfd_boolean elf_s390_relocate_section
-  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
-	   Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
-static bfd_boolean elf_s390_finish_dynamic_symbol
-  PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
-	   Elf_Internal_Sym *));
-static enum elf_reloc_type_class elf_s390_reloc_type_class
-  PARAMS ((const Elf_Internal_Rela *));
-static bfd_boolean elf_s390_finish_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-static bfd_boolean elf_s390_object_p
-  PARAMS ((bfd *));
-static int elf_s390_tls_transition
-  PARAMS ((struct bfd_link_info *, int, int));
-static bfd_reloc_status_type s390_tls_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static bfd_vma dtpoff_base
-  PARAMS ((struct bfd_link_info *));
-static bfd_vma tpoff
-  PARAMS ((struct bfd_link_info *, bfd_vma));
-static void invalid_tls_insn
-  PARAMS ((bfd *, asection *, Elf_Internal_Rela *));
-static bfd_reloc_status_type s390_elf_ldisp_reloc
-  PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-
 #include "elf/s390.h"
 
 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value
    from smaller values.  Start with zero, widen, *then* decrement.  */
 #define MINUS_ONE      (((bfd_vma)0) - 1)
 
+static bfd_reloc_status_type
+s390_tls_reloc (bfd *, arelent *, asymbol *, void *,
+		asection *, bfd *, char **);
+static bfd_reloc_status_type
+s390_elf_ldisp_reloc (bfd *, arelent *, asymbol *, void *,
+		      asection *, bfd *, char **);
+
 /* The relocation "howto" table.  */
 static reloc_howto_type elf_howto_table[] =
 {
   HOWTO (R_390_NONE,		/* type */
 	 0,			/* rightshift */
-	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 0,			/* size (0 = byte, 1 = 2 byte, 2 = 4 byte) */
 	 0,			/* bitsize */
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
@@ -219,6 +169,16 @@
 	s390_elf_ldisp_reloc, "R_390_GOTPLT20", FALSE, 0,0x0fffff00, FALSE),
   HOWTO(R_390_TLS_GOTIE20, 0, 2, 20, FALSE, 8, complain_overflow_dont,
 	s390_elf_ldisp_reloc, "R_390_TLS_GOTIE20", FALSE, 0,0x0fffff00, FALSE),
+  HOWTO(R_390_IRELATIVE, 0, 4, 64, FALSE, 0, complain_overflow_bitfield,
+	bfd_elf_generic_reloc, "R_390_IRELATIVE", FALSE, 0, MINUS_ONE, FALSE),
+  HOWTO(R_390_PC12DBL,   1, 1, 12,  TRUE, 0, complain_overflow_bitfield,
+	bfd_elf_generic_reloc, "R_390_PC12DBL",  FALSE, 0,0x00000fff, TRUE),
+  HOWTO(R_390_PLT12DBL,  1, 1, 12,  TRUE, 0, complain_overflow_bitfield,
+	bfd_elf_generic_reloc, "R_390_PLT12DBL", FALSE, 0,0x00000fff, TRUE),
+  HOWTO(R_390_PC24DBL,   1, 2, 24,  TRUE, 0, complain_overflow_bitfield,
+	bfd_elf_generic_reloc, "R_390_PC24DBL",  FALSE, 0,0x00ffffff, TRUE),
+  HOWTO(R_390_PLT24DBL,  1, 2, 24,  TRUE, 0, complain_overflow_bitfield,
+	bfd_elf_generic_reloc, "R_390_PLT24DBL", FALSE, 0,0x00ffffff, TRUE),
 };
 
 /* GNU extension to record C++ vtable hierarchy.  */
@@ -228,9 +188,8 @@
   HOWTO (R_390_GNU_VTENTRY, 0,4,0,FALSE,0,complain_overflow_dont, _bfd_elf_rel_vtable_reloc_fn,"R_390_GNU_VTENTRY", FALSE,0,0, FALSE);
 
 static reloc_howto_type *
-elf_s390_reloc_type_lookup (abfd, code)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+elf_s390_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+			    bfd_reloc_code_real_type code)
 {
   switch (code)
     {
@@ -270,10 +229,18 @@
       return &elf_howto_table[(int) R_390_GOT16];
     case BFD_RELOC_16_PCREL:
       return &elf_howto_table[(int) R_390_PC16];
+    case BFD_RELOC_390_PC12DBL:
+      return &elf_howto_table[(int) R_390_PC12DBL];
+    case BFD_RELOC_390_PLT12DBL:
+      return &elf_howto_table[(int) R_390_PLT12DBL];
     case BFD_RELOC_390_PC16DBL:
       return &elf_howto_table[(int) R_390_PC16DBL];
     case BFD_RELOC_390_PLT16DBL:
       return &elf_howto_table[(int) R_390_PLT16DBL];
+    case BFD_RELOC_390_PC24DBL:
+      return &elf_howto_table[(int) R_390_PC24DBL];
+    case BFD_RELOC_390_PLT24DBL:
+      return &elf_howto_table[(int) R_390_PLT24DBL];
     case BFD_RELOC_390_PC32DBL:
       return &elf_howto_table[(int) R_390_PC32DBL];
     case BFD_RELOC_390_PLT32DBL:
@@ -346,6 +313,8 @@
       return &elf_howto_table[(int) R_390_GOTPLT20];
     case BFD_RELOC_390_TLS_GOTIE20:
       return &elf_howto_table[(int) R_390_TLS_GOTIE20];
+    case BFD_RELOC_390_IRELATIVE:
+      return &elf_howto_table[(int) R_390_IRELATIVE];
     case BFD_RELOC_VTABLE_INHERIT:
       return &elf64_s390_vtinherit_howto;
     case BFD_RELOC_VTABLE_ENTRY:
@@ -381,10 +350,9 @@
    and elf64-s390.c has its own copy.  */
 
 static void
-elf_s390_info_to_howto (abfd, cache_ptr, dst)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *cache_ptr;
-     Elf_Internal_Rela *dst;
+elf_s390_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+			arelent *cache_ptr,
+			Elf_Internal_Rela *dst)
 {
   unsigned int r_type = ELF64_R_TYPE(dst->r_info);
   switch (r_type)
@@ -410,15 +378,13 @@
 
 /* A relocation function which doesn't do anything.  */
 static bfd_reloc_status_type
-s390_tls_reloc (abfd, reloc_entry, symbol, data, input_section,
-		output_bfd, error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc_entry;
-     asymbol *symbol ATTRIBUTE_UNUSED;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+s390_tls_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+		arelent *reloc_entry,
+		asymbol *symbol ATTRIBUTE_UNUSED,
+		void * data ATTRIBUTE_UNUSED,
+		asection *input_section,
+		bfd *output_bfd,
+		char **error_message ATTRIBUTE_UNUSED)
 {
   if (output_bfd)
     reloc_entry->address += input_section->output_offset;
@@ -427,15 +393,13 @@
 
 /* Handle the large displacement relocs.  */
 static bfd_reloc_status_type
-s390_elf_ldisp_reloc (abfd, reloc_entry, symbol, data, input_section,
-                      output_bfd, error_message)
-     bfd *abfd;
-     arelent *reloc_entry;
-     asymbol *symbol;
-     PTR data;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+s390_elf_ldisp_reloc (bfd *abfd,
+		      arelent *reloc_entry,
+		      asymbol *symbol,
+		      void * data,
+		      asection *input_section,
+		      bfd *output_bfd,
+		      char **error_message ATTRIBUTE_UNUSED)
 {
   reloc_howto_type *howto = reloc_entry->howto;
   bfd_vma relocation;
@@ -466,7 +430,7 @@
       relocation -= reloc_entry->address;
     }
 
-  insn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address); 
+  insn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
   insn |= (relocation & 0xfff) << 16 | (relocation & 0xff000) >> 4;
   bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
 
@@ -478,9 +442,7 @@
 }
 
 static bfd_boolean
-elf_s390_is_local_label_name (abfd, name)
-     bfd *abfd;
-     const char *name;
+elf_s390_is_local_label_name (bfd *abfd, const char *name)
 {
   if (name[0] == '.' && (name[1] == 'X' || name[1] == 'L'))
     return TRUE;
@@ -493,7 +455,7 @@
 /* The name of the dynamic interpreter.  This is put in the .interp
    section.  */
 
-#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
+#define ELF_DYNAMIC_INTERPRETER "/lib/ld64.so.1"
 
 /* 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
@@ -508,6 +470,8 @@
 
 #define GOT_ENTRY_SIZE 8
 
+#define RELA_ENTRY_SIZE sizeof (Elf64_External_Rela)
+
 /* The first three entries in a procedure linkage table are reserved,
    and the initial contents are unimportant (we zero them out).
    Subsequent entries look like this.  See the SVR4 ABI 386
@@ -540,31 +504,33 @@
    RET1: BASR 1,0         # 2 bytes  Return from GOT 1st time
          LGF  1,12(1)     # 6 bytes  Load offset in symbl table in r1
          BRCL 15,-x       # 6 bytes  Jump to start of PLT
-         .long ?          # 4 bytes  offset into symbol table
+         .long ?          # 4 bytes  offset into .rela.plt
 
    Total = 32 bytes per PLT entry
    Fixup at offset 2: relative address to GOT entry
    Fixup at offset 22: relative branch to PLT0
-   Fixup at offset 28: 32 bit offset into symbol table
+   Fixup at offset 28: 32 bit offset into .rela.plt
 
-   A 32 bit offset into the symbol table is enough. It allows for symbol
-   tables up to a size of 2 gigabyte. A single dynamic object (the main
-   program, any shared library) is limited to 4GB in size and I want to see
-   the program that manages to have a symbol table of more than 2 GB with a
-   total size of at max 4 GB.  */
+   A 32 bit offset into the symbol table is enough. It allows for
+   .rela.plt sections up to a size of 2 gigabyte.  A single dynamic
+   object (the main program, any shared library) is limited to 4GB in
+   size.  Having a .rela.plt of 2GB would already make the .plt
+   section bigger than 8GB.  */
 
-#define PLT_ENTRY_WORD0     (bfd_vma) 0xc0100000
-#define PLT_ENTRY_WORD1     (bfd_vma) 0x0000e310
-#define PLT_ENTRY_WORD2     (bfd_vma) 0x10000004
-#define PLT_ENTRY_WORD3     (bfd_vma) 0x07f10d10
-#define PLT_ENTRY_WORD4     (bfd_vma) 0xe310100c
-#define PLT_ENTRY_WORD5     (bfd_vma) 0x0014c0f4
-#define PLT_ENTRY_WORD6     (bfd_vma) 0x00000000
-#define PLT_ENTRY_WORD7     (bfd_vma) 0x00000000
+static const bfd_byte elf_s390x_plt_entry[PLT_ENTRY_SIZE] =
+  {
+    0xc0, 0x10, 0x00, 0x00, 0x00, 0x00,     /* larl    %r1,.       */
+    0xe3, 0x10, 0x10, 0x00, 0x00, 0x04,     /* lg      %r1,0(%r1)  */
+    0x07, 0xf1,                             /* br      %r1         */
+    0x0d, 0x10,                             /* basr    %r1,%r0     */
+    0xe3, 0x10, 0x10, 0x0c, 0x00, 0x14,     /* lgf     %r1,12(%r1) */
+    0xc0, 0xf4, 0x00, 0x00, 0x00, 0x00,     /* jg      first plt   */
+    0x00, 0x00, 0x00, 0x00                  /* .long   0x00000000  */
+  };
 
 /* The first PLT entry pushes the offset into the symbol table
-   from R1 onto the stack at 8(15) and the loader object info
-   at 12(15), loads the loader address in R1 and jumps to it.  */
+   from R1 onto the stack at 56(15) and the loader object info
+   at 48(15), loads the loader address in R1 and jumps to it.  */
 
 /* The first entry in the PLT:
 
@@ -577,34 +543,18 @@
 
      Fixup at offset 8: relative address to start of GOT.  */
 
-#define PLT_FIRST_ENTRY_WORD0     (bfd_vma) 0xe310f038
-#define PLT_FIRST_ENTRY_WORD1     (bfd_vma) 0x0024c010
-#define PLT_FIRST_ENTRY_WORD2     (bfd_vma) 0x00000000
-#define PLT_FIRST_ENTRY_WORD3     (bfd_vma) 0xd207f030
-#define PLT_FIRST_ENTRY_WORD4     (bfd_vma) 0x1008e310
-#define PLT_FIRST_ENTRY_WORD5     (bfd_vma) 0x10100004
-#define PLT_FIRST_ENTRY_WORD6     (bfd_vma) 0x07f10700
-#define PLT_FIRST_ENTRY_WORD7     (bfd_vma) 0x07000700
+static const bfd_byte elf_s390x_first_plt_entry[PLT_FIRST_ENTRY_SIZE] =
+  {
+    0xe3, 0x10, 0xf0, 0x38, 0x00, 0x24,     /* stg     %r1,56(%r15)      */
+    0xc0, 0x10, 0x00, 0x00, 0x00, 0x00,     /* larl    %r1,.             */
+    0xd2, 0x07, 0xf0, 0x30, 0x10, 0x08,     /* mvc     48(8,%r15),8(%r1) */
+    0xe3, 0x10, 0x10, 0x10, 0x00, 0x04,     /* lg      %r1,16(%r1)       */
+    0x07, 0xf1,                             /* br      %r1               */
+    0x07, 0x00,                             /* nopr    %r0               */
+    0x07, 0x00,                             /* nopr    %r0               */
+    0x07, 0x00                              /* nopr    %r0               */
+  };
 
-/* The s390 linker needs to keep track of the number of relocs that it
-   decides to copy as dynamic relocs in check_relocs for each symbol.
-   This is so that it can later discard them if they are found to be
-   unnecessary.  We store the information in a field extending the
-   regular ELF linker hash table.  */
-
-struct elf_s390_dyn_relocs
-{
-  struct elf_s390_dyn_relocs *next;
-
-  /* The input section of the reloc.  */
-  asection *sec;
-
-  /* Total number of relocs copied for the input section.  */
-  bfd_size_type count;
-
-  /* Number of pc-relative relocs copied for the input section.  */
-  bfd_size_type pc_count;
-};
 
 /* s390 ELF linker hash entry.  */
 
@@ -613,7 +563,7 @@
   struct elf_link_hash_entry elf;
 
   /* Track dynamic relocs copied for this symbol.  */
-  struct elf_s390_dyn_relocs *dyn_relocs;
+  struct elf_dyn_relocs *dyn_relocs;
 
   /* Number of GOTPLT references for a function.  */
   bfd_signed_vma gotplt_refcount;
@@ -624,17 +574,43 @@
 #define GOT_TLS_IE	3
 #define GOT_TLS_IE_NLT	3
   unsigned char tls_type;
+
+  /* For pointer equality reasons we might need to change the symbol
+     type from STT_GNU_IFUNC to STT_FUNC together with its value and
+     section entry.  So after alloc_dynrelocs only these values should
+     be used.  In order to check whether a symbol is IFUNC use
+     s390_is_ifunc_symbol_p.  */
+  bfd_vma ifunc_resolver_address;
+  asection *ifunc_resolver_section;
 };
 
 #define elf_s390_hash_entry(ent) \
   ((struct elf_s390_link_hash_entry *)(ent))
 
+/* This structure represents an entry in the local PLT list needed for
+   local IFUNC symbols.  */
+struct plt_entry
+{
+  /* The section of the local symbol.
+     Set in relocate_section and used in finish_dynamic_sections.  */
+  asection *sec;
+
+  union
+    {
+      bfd_signed_vma refcount;
+      bfd_vma offset;
+    } plt;
+};
+
 /* NOTE: Keep this structure in sync with
    the one declared in elf32-s390.c.  */
 struct elf_s390_obj_tdata
 {
   struct elf_obj_tdata root;
 
+  /* A local PLT is needed for ifunc symbols.  */
+  struct plt_entry *local_plt;
+
   /* TLS type for each local got entry.  */
   char *local_got_tls_type;
 };
@@ -642,6 +618,9 @@
 #define elf_s390_tdata(abfd) \
   ((struct elf_s390_obj_tdata *) (abfd)->tdata.any)
 
+#define elf_s390_local_plt(abfd) \
+  (elf_s390_tdata (abfd)->local_plt)
+
 #define elf_s390_local_got_tls_type(abfd) \
   (elf_s390_tdata (abfd)->local_got_tls_type)
 
@@ -658,8 +637,7 @@
 }
 
 static bfd_boolean
-elf_s390_object_p (abfd)
-     bfd *abfd;
+elf_s390_object_p (bfd *abfd)
 {
   /* Set the right machine number for an s390 elf32 file.  */
   return bfd_default_set_arch_mach (abfd, bfd_arch_s390, bfd_mach_s390_64);
@@ -672,13 +650,9 @@
   struct elf_link_hash_table elf;
 
   /* Short-cuts to get to dynamic linker sections.  */
-  asection *sgot;
-  asection *sgotplt;
-  asection *srelgot;
-  asection *splt;
-  asection *srelplt;
   asection *sdynbss;
   asection *srelbss;
+  asection *irelifunc;
 
   union {
     bfd_signed_vma refcount;
@@ -695,13 +669,15 @@
   (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
   == S390_ELF_DATA ? ((struct elf_s390_link_hash_table *) ((p)->hash)) : NULL)
 
+#define ELF64 1
+#include "elf-s390-common.c"
+
 /* Create an entry in an s390 ELF linker hash table.  */
 
 static struct bfd_hash_entry *
-link_hash_newfunc (entry, table, string)
-     struct bfd_hash_entry *entry;
-     struct bfd_hash_table *table;
-     const char *string;
+link_hash_newfunc (struct bfd_hash_entry *entry,
+		   struct bfd_hash_table *table,
+		   const char *string)
 {
   /* Allocate the structure if it has not already been allocated by a
      subclass.  */
@@ -723,6 +699,8 @@
       eh->dyn_relocs = NULL;
       eh->gotplt_refcount = 0;
       eh->tls_type = GOT_UNKNOWN;
+      eh->ifunc_resolver_address = 0;
+      eh->ifunc_resolver_section = NULL;
     }
 
   return entry;
@@ -731,13 +709,12 @@
 /* Create an s390 ELF linker hash table.  */
 
 static struct bfd_link_hash_table *
-elf_s390_link_hash_table_create (abfd)
-     bfd *abfd;
+elf_s390_link_hash_table_create (bfd *abfd)
 {
   struct elf_s390_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_s390_link_hash_table);
 
-  ret = (struct elf_s390_link_hash_table *) bfd_malloc (amt);
+  ret = (struct elf_s390_link_hash_table *) bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
 
@@ -749,16 +726,6 @@
       return NULL;
     }
 
-  ret->sgot = NULL;
-  ret->sgotplt = NULL;
-  ret->srelgot = NULL;
-  ret->splt = NULL;
-  ret->srelplt = NULL;
-  ret->sdynbss = NULL;
-  ret->srelbss = NULL;
-  ret->tls_ldm_got.refcount = 0;
-  ret->sym_cache.abfd = NULL;
-
   return &ret->elf.root;
 }
 
@@ -778,10 +745,10 @@
   if (htab == NULL)
     return FALSE;
 
-  htab->sgot = bfd_get_section_by_name (dynobj, ".got");
-  htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
-  htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
-  if (!htab->sgot || !htab->sgotplt || !htab->srelgot)
+  htab->elf.sgot = bfd_get_linker_section (dynobj, ".got");
+  htab->elf.sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
+  htab->elf.srelgot = bfd_get_linker_section (dynobj, ".rela.got");
+  if (!htab->elf.sgot || !htab->elf.sgotplt || !htab->elf.srelgot)
     abort ();
   return TRUE;
 }
@@ -800,19 +767,19 @@
   if (htab == NULL)
     return FALSE;
 
-  if (!htab->sgot && !create_got_section (dynobj, info))
+  if (!htab->elf.sgot && !create_got_section (dynobj, info))
     return FALSE;
 
   if (!_bfd_elf_create_dynamic_sections (dynobj, info))
     return FALSE;
 
-  htab->splt = bfd_get_section_by_name (dynobj, ".plt");
-  htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt");
-  htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
+  htab->elf.splt = bfd_get_linker_section (dynobj, ".plt");
+  htab->elf.srelplt = bfd_get_linker_section (dynobj, ".rela.plt");
+  htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
   if (!info->shared)
-    htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
+    htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
 
-  if (!htab->splt || !htab->srelplt || !htab->sdynbss
+  if (!htab->elf.splt || !htab->elf.srelplt || !htab->sdynbss
       || (!info->shared && !htab->srelbss))
     abort ();
 
@@ -822,9 +789,9 @@
 /* Copy the extra info we tack onto an elf_link_hash_entry.  */
 
 static void
-elf_s390_copy_indirect_symbol (info, dir, ind)
-     struct bfd_link_info *info;
-     struct elf_link_hash_entry *dir, *ind;
+elf_s390_copy_indirect_symbol (struct bfd_link_info *info,
+			       struct elf_link_hash_entry *dir,
+			       struct elf_link_hash_entry *ind)
 {
   struct elf_s390_link_hash_entry *edir, *eind;
 
@@ -835,14 +802,14 @@
     {
       if (edir->dyn_relocs != NULL)
 	{
-	  struct elf_s390_dyn_relocs **pp;
-	  struct elf_s390_dyn_relocs *p;
+	  struct elf_dyn_relocs **pp;
+	  struct elf_dyn_relocs *p;
 
 	  /* Add reloc counts against the indirect sym to the direct sym
 	     list.  Merge any entries against the same section.  */
 	  for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
 	    {
-	      struct elf_s390_dyn_relocs *q;
+	      struct elf_dyn_relocs *q;
 
 	      for (q = edir->dyn_relocs; q != NULL; q = q->next)
 		if (q->sec == p->sec)
@@ -886,10 +853,9 @@
 }
 
 static int
-elf_s390_tls_transition (info, r_type, is_local)
-     struct bfd_link_info *info;
-     int r_type;
-     int is_local;
+elf_s390_tls_transition (struct bfd_link_info *info,
+			 int r_type,
+			 int is_local)
 {
   if (info->shared)
     return r_type;
@@ -952,6 +918,7 @@
       unsigned int r_type;
       unsigned long r_symndx;
       struct elf_link_hash_entry *h;
+      Elf_Internal_Sym *isym;
 
       r_symndx = ELF64_R_SYM (rel->r_info);
 
@@ -964,13 +931,44 @@
 	}
 
       if (r_symndx < symtab_hdr->sh_info)
-	h = NULL;
+	{
+	  /* A local symbol.  */
+	  isym = bfd_sym_from_r_symndx (&htab->sym_cache,
+					abfd, r_symndx);
+	  if (isym == NULL)
+	    return FALSE;
+
+	  if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC)
+	    {
+	      struct plt_entry *plt;
+
+	      if (htab->elf.dynobj == NULL)
+		htab->elf.dynobj = abfd;
+
+	      if (!s390_elf_create_ifunc_sections (htab->elf.dynobj, info))
+		return FALSE;
+
+	      if (local_got_refcounts == NULL)
+		{
+		  if (!elf_s390_allocate_local_syminfo (abfd, symtab_hdr))
+		    return FALSE;
+		  local_got_refcounts = elf_local_got_refcounts (abfd);
+		}
+	      plt = elf_s390_local_plt (abfd);
+	      plt[r_symndx].plt.refcount++;
+	    }
+	  h = NULL;
+	}
       else
 	{
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       /* Create got section and local_got_refcounts array if they
@@ -1002,25 +1000,18 @@
 	  if (h == NULL
 	      && local_got_refcounts == NULL)
 	    {
-	      bfd_size_type size;
-
-	      size = symtab_hdr->sh_info;
-	      size *= (sizeof (bfd_signed_vma) + sizeof(char));
-	      local_got_refcounts = ((bfd_signed_vma *)
-				     bfd_zalloc (abfd, size));
-	      if (local_got_refcounts == NULL)
+	      if (!elf_s390_allocate_local_syminfo (abfd, symtab_hdr))
 		return FALSE;
-	      elf_local_got_refcounts (abfd) = local_got_refcounts;
-	      elf_s390_local_got_tls_type (abfd)
-		= (char *) (local_got_refcounts + symtab_hdr->sh_info);
+	      local_got_refcounts = elf_local_got_refcounts (abfd);
 	    }
+
 	  /* Fall through.  */
 	case R_390_GOTOFF16:
 	case R_390_GOTOFF32:
 	case R_390_GOTOFF64:
 	case R_390_GOTPC:
 	case R_390_GOTPCDBL:
-	  if (htab->sgot == NULL)
+	  if (htab->elf.sgot == NULL)
 	    {
 	      if (htab->elf.dynobj == NULL)
 		htab->elf.dynobj = abfd;
@@ -1029,6 +1020,25 @@
 	    }
 	}
 
+      if (h != NULL)
+	{
+	  if (htab->elf.dynobj == NULL)
+	    htab->elf.dynobj = abfd;
+	  if (!s390_elf_create_ifunc_sections (htab->elf.dynobj, info))
+	    return FALSE;
+
+	  /* Make sure an IFUNC symbol defined in a non-shared object
+	     always gets a PLT slot.  */
+	  if (s390_is_ifunc_symbol_p (h) && h->def_regular)
+	    {
+	      /* The symbol is called by the dynamic loader in order
+		 to resolve the relocation.  So it is in fact also
+		 referenced.  */
+	      h->ref_regular = 1;
+	      h->needs_plt = 1;
+	    }
+	}
+
       switch (r_type)
 	{
 	case R_390_GOTOFF16:
@@ -1036,10 +1046,15 @@
 	case R_390_GOTOFF64:
 	case R_390_GOTPC:
 	case R_390_GOTPCDBL:
-	  /* Got is created, nothing to be done.  */
+	  /* These relocs do not need a GOT slot.  They just load the
+	     GOT pointer itself or address something else relative to
+	     the GOT.  Since the GOT pointer has been set up above we
+	     are done.  */
 	  break;
 
+	case R_390_PLT12DBL:
 	case R_390_PLT16DBL:
+	case R_390_PLT24DBL:
 	case R_390_PLT32:
 	case R_390_PLT32DBL:
 	case R_390_PLT64:
@@ -1178,12 +1193,14 @@
 	case R_390_16:
 	case R_390_32:
 	case R_390_64:
+	case R_390_PC12DBL:
 	case R_390_PC16:
 	case R_390_PC16DBL:
+	case R_390_PC24DBL:
 	case R_390_PC32:
 	case R_390_PC32DBL:
 	case R_390_PC64:
-	  if (h != NULL && !info->shared)
+	  if (h != NULL)
 	    {
 	      /* If this reloc is in a read-only section, we might
 		 need a copy reloc.  We can't check reliably at this
@@ -1193,9 +1210,12 @@
 		 adjust_dynamic_symbol.  */
 	      h->non_got_ref = 1;
 
-	      /* We may need a .plt entry if the function this reloc
-		 refers to is in a shared lib.  */
-	      h->plt.refcount += 1;
+	      if (!info->shared)
+		{
+		  /* We may need a .plt entry if the function this reloc
+		     refers to is in a shared lib.  */
+		  h->plt.refcount += 1;
+		}
 	    }
 
 	  /* If we are creating a shared library, and this is a reloc
@@ -1222,7 +1242,9 @@
 	  if ((info->shared
 	       && (sec->flags & SEC_ALLOC) != 0
 	       && ((ELF64_R_TYPE (rel->r_info) != R_390_PC16
+		    && ELF64_R_TYPE (rel->r_info) != R_390_PC12DBL
 		    && ELF64_R_TYPE (rel->r_info) != R_390_PC16DBL
+		    && ELF64_R_TYPE (rel->r_info) != R_390_PC24DBL
 		    && ELF64_R_TYPE (rel->r_info) != R_390_PC32
 		    && ELF64_R_TYPE (rel->r_info) != R_390_PC32DBL
 		    && ELF64_R_TYPE (rel->r_info) != R_390_PC64)
@@ -1237,8 +1259,8 @@
 		  && (h->root.type == bfd_link_hash_defweak
 		      || !h->def_regular)))
 	    {
-	      struct elf_s390_dyn_relocs *p;
-	      struct elf_s390_dyn_relocs **head;
+	      struct elf_dyn_relocs *p;
+	      struct elf_dyn_relocs **head;
 
 	      /* We must copy these reloc types into the output file.
 		 Create a reloc section in dynobj and make room for
@@ -1268,7 +1290,6 @@
 		     easily.  Oh well.  */
 		  asection *s;
 		  void *vpp;
-		  Elf_Internal_Sym *isym;
 
 		  isym = bfd_sym_from_r_symndx (&htab->sym_cache,
 						abfd, r_symndx);
@@ -1280,14 +1301,14 @@
 		    s = sec;
 
 		  vpp = &elf_section_data (s)->local_dynrel;
-		  head = (struct elf_s390_dyn_relocs **) vpp;
+		  head = (struct elf_dyn_relocs **) vpp;
 		}
 
 	      p = *head;
 	      if (p == NULL || p->sec != sec)
 		{
 		  bfd_size_type amt = sizeof *p;
-		  p = ((struct elf_s390_dyn_relocs *)
+		  p = ((struct elf_dyn_relocs *)
 		       bfd_alloc (htab->elf.dynobj, amt));
 		  if (p == NULL)
 		    return FALSE;
@@ -1300,6 +1321,8 @@
 
 	      p->count += 1;
 	      if (ELF64_R_TYPE (rel->r_info) == R_390_PC16
+		  || ELF64_R_TYPE (rel->r_info) == R_390_PC12DBL
+		  || ELF64_R_TYPE (rel->r_info) == R_390_PC16DBL
 		  || ELF64_R_TYPE (rel->r_info) == R_390_PC16DBL
 		  || ELF64_R_TYPE (rel->r_info) == R_390_PC32
 		  || ELF64_R_TYPE (rel->r_info) == R_390_PC32DBL
@@ -1391,8 +1414,8 @@
       if (r_symndx >= symtab_hdr->sh_info)
 	{
 	  struct elf_s390_link_hash_entry *eh;
-	  struct elf_s390_dyn_relocs **pp;
-	  struct elf_s390_dyn_relocs *p;
+	  struct elf_dyn_relocs **pp;
+	  struct elf_dyn_relocs *p;
 
 	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
 	  while (h->root.type == bfd_link_hash_indirect
@@ -1408,6 +1431,23 @@
 		break;
 	      }
 	}
+      else
+	{
+	  Elf_Internal_Sym *isym;
+
+	  /* A local symbol.  */
+	  isym = bfd_sym_from_r_symndx (&htab->sym_cache,
+					abfd, r_symndx);
+	  if (isym == NULL)
+	    return FALSE;
+
+	  if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC)
+	    {
+	      struct plt_entry *plt = elf_s390_local_plt (abfd);
+	      if (plt[r_symndx].plt.refcount > 0)
+		plt[r_symndx].plt.refcount--;
+	    }
+	}
 
       r_type = ELF64_R_TYPE (rel->r_info);
       r_type = elf_s390_tls_transition (info, r_type, h != NULL);
@@ -1454,7 +1494,9 @@
 	case R_390_32:
 	case R_390_64:
 	case R_390_PC16:
+	case R_390_PC12DBL:
 	case R_390_PC16DBL:
+	case R_390_PC24DBL:
 	case R_390_PC32:
 	case R_390_PC32DBL:
 	case R_390_PC64:
@@ -1462,7 +1504,9 @@
 	    break;
 	  /* Fall through */
 
+	case R_390_PLT12DBL:
 	case R_390_PLT16DBL:
+	case R_390_PLT24DBL:
 	case R_390_PLT32:
 	case R_390_PLT32DBL:
 	case R_390_PLT64:
@@ -1513,8 +1557,7 @@
    created (we're only linking static objects).  */
 
 static void
-elf_s390_adjust_gotplt (h)
-     struct elf_s390_link_hash_entry *h;
+elf_s390_adjust_gotplt (struct elf_s390_link_hash_entry *h)
 {
   if (h->elf.root.type == bfd_link_hash_warning)
     h = (struct elf_s390_link_hash_entry *) h->elf.root.u.i.link;
@@ -1541,6 +1584,10 @@
   struct elf_s390_link_hash_table *htab;
   asection *s;
 
+  /* STT_GNU_IFUNC symbol must go through PLT. */
+  if (s390_is_ifunc_symbol_p (h))
+    return TRUE;
+
   /* If this is a function, put it in the procedure linkage table.  We
      will fill in the contents of the procedure linkage table later
      (although we could actually do it here).  */
@@ -1611,7 +1658,7 @@
   if (ELIMINATE_COPY_RELOCS)
     {
       struct elf_s390_link_hash_entry * eh;
-      struct elf_s390_dyn_relocs *p;
+      struct elf_dyn_relocs *p;
 
       eh = (struct elf_s390_link_hash_entry *) h;
       for (p = eh->dyn_relocs; p != NULL; p = p->next)
@@ -1630,13 +1677,6 @@
 	}
     }
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-			     h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -1654,7 +1694,7 @@
   /* We must generate a R_390_COPY reloc to tell the dynamic linker to
      copy the initial value out of the dynamic object and into the
      runtime process image.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       htab->srelbss->size += sizeof (Elf64_External_Rela);
       h->needs_copy = 1;
@@ -1674,8 +1714,8 @@
 {
   struct bfd_link_info *info;
   struct elf_s390_link_hash_table *htab;
-  struct elf_s390_link_hash_entry *eh;
-  struct elf_s390_dyn_relocs *p;
+  struct elf_s390_link_hash_entry *eh = (struct elf_s390_link_hash_entry *)h;
+  struct elf_dyn_relocs *p;
 
   if (h->root.type == bfd_link_hash_indirect)
     return TRUE;
@@ -1685,8 +1725,13 @@
   if (htab == NULL)
     return FALSE;
 
-  if (htab->elf.dynamic_sections_created
-      && h->plt.refcount > 0)
+  /* Since STT_GNU_IFUNC symbol must go through PLT, we handle it
+     here if it is defined and referenced in a non-shared object.  */
+  if (s390_is_ifunc_symbol_p (h) && h->def_regular)
+    return s390_elf_allocate_ifunc_dyn_relocs (info, h,
+					       &eh->dyn_relocs);
+  else if (htab->elf.dynamic_sections_created
+	   && h->plt.refcount > 0)
     {
       /* Make sure this symbol is output as a dynamic symbol.
 	 Undefined weak syms won't yet be marked as dynamic.  */
@@ -1700,7 +1745,7 @@
       if (info->shared
 	  || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h))
 	{
-	  asection *s = htab->splt;
+	  asection *s = htab->elf.splt;
 
 	  /* If this is the first .plt entry, make room for the special
 	     first entry.  */
@@ -1726,10 +1771,10 @@
 
 	  /* We also need to make an entry in the .got.plt section, which
 	     will be placed in the .got section by the linker script.  */
-	  htab->sgotplt->size += GOT_ENTRY_SIZE;
+	  htab->elf.sgotplt->size += GOT_ENTRY_SIZE;
 
 	  /* We also need to make an entry in the .rela.plt section.  */
-	  htab->srelplt->size += sizeof (Elf64_External_Rela);
+	  htab->elf.srelplt->size += sizeof (Elf64_External_Rela);
 	}
       else
 	{
@@ -1759,8 +1804,8 @@
 	   to be stored somewhere. The immediate value in the instruction
 	   is not bit enough so the value is stored in the got.  */
 	{
-	  h->got.offset = htab->sgot->size;
-	  htab->sgot->size += GOT_ENTRY_SIZE;
+	  h->got.offset = htab->elf.sgot->size;
+	  htab->elf.sgot->size += GOT_ENTRY_SIZE;
 	}
       else
 	h->got.offset = (bfd_vma) -1;
@@ -1780,7 +1825,7 @@
 	    return FALSE;
 	}
 
-      s = htab->sgot;
+      s = htab->elf.sgot;
       h->got.offset = s->size;
       s->size += GOT_ENTRY_SIZE;
       /* R_390_TLS_GD64 needs 2 consecutive GOT slots.  */
@@ -1791,19 +1836,18 @@
 	 R_390_TLS_GD64 needs one if local symbol and two if global.  */
       if ((tls_type == GOT_TLS_GD && h->dynindx == -1)
 	  || tls_type >= GOT_TLS_IE)
-	htab->srelgot->size += sizeof (Elf64_External_Rela);
+	htab->elf.srelgot->size += sizeof (Elf64_External_Rela);
       else if (tls_type == GOT_TLS_GD)
-	htab->srelgot->size += 2 * sizeof (Elf64_External_Rela);
+	htab->elf.srelgot->size += 2 * sizeof (Elf64_External_Rela);
       else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
 		|| h->root.type != bfd_link_hash_undefweak)
 	       && (info->shared
 		   || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
-	htab->srelgot->size += sizeof (Elf64_External_Rela);
+	htab->elf.srelgot->size += sizeof (Elf64_External_Rela);
     }
   else
     h->got.offset = (bfd_vma) -1;
 
-  eh = (struct elf_s390_link_hash_entry *) h;
   if (eh->dyn_relocs == NULL)
     return TRUE;
 
@@ -1817,7 +1861,7 @@
     {
       if (SYMBOL_CALLS_LOCAL (info, h))
 	{
-	  struct elf_s390_dyn_relocs **pp;
+	  struct elf_dyn_relocs **pp;
 
 	  for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
 	    {
@@ -1894,12 +1938,10 @@
 /* Find any dynamic relocs that apply to read-only sections.  */
 
 static bfd_boolean
-readonly_dynrelocs (h, inf)
-     struct elf_link_hash_entry *h;
-     PTR inf;
+readonly_dynrelocs (struct elf_link_hash_entry *h, void * inf)
 {
   struct elf_s390_link_hash_entry *eh;
-  struct elf_s390_dyn_relocs *p;
+  struct elf_dyn_relocs *p;
 
   eh = (struct elf_s390_link_hash_entry *) h;
   for (p = eh->dyn_relocs; p != NULL; p = p->next)
@@ -1944,7 +1986,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  if (s == NULL)
 	    abort ();
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
@@ -1962,13 +2004,15 @@
       bfd_size_type locsymcount;
       Elf_Internal_Shdr *symtab_hdr;
       asection *srela;
+      struct plt_entry *local_plt;
+      unsigned int i;
 
       if (! is_s390_elf (ibfd))
 	continue;
 
       for (s = ibfd->sections; s != NULL; s = s->next)
 	{
-	  struct elf_s390_dyn_relocs *p;
+	  struct elf_dyn_relocs *p;
 
 	  for (p = elf_section_data (s)->local_dynrel; p != NULL; p = p->next)
 	    {
@@ -1998,8 +2042,8 @@
       locsymcount = symtab_hdr->sh_info;
       end_local_got = local_got + locsymcount;
       local_tls_type = elf_s390_local_got_tls_type (ibfd);
-      s = htab->sgot;
-      srela = htab->srelgot;
+      s = htab->elf.sgot;
+      srela = htab->elf.srelgot;
       for (; local_got < end_local_got; ++local_got, ++local_tls_type)
 	{
 	  if (*local_got > 0)
@@ -2014,22 +2058,36 @@
 	  else
 	    *local_got = (bfd_vma) -1;
 	}
+
+      local_plt = elf_s390_local_plt (ibfd);
+      for (i = 0; i < symtab_hdr->sh_info; i++)
+	{
+	  if (local_plt[i].plt.refcount > 0)
+	    {
+	      local_plt[i].plt.offset = htab->elf.iplt->size;
+	      htab->elf.iplt->size += PLT_ENTRY_SIZE;
+	      htab->elf.igotplt->size += GOT_ENTRY_SIZE;
+	      htab->elf.irelplt->size += sizeof (Elf64_External_Rela);
+	    }
+	  else
+	    local_plt[i].plt.offset = (bfd_vma) -1;
+	}
     }
 
   if (htab->tls_ldm_got.refcount > 0)
     {
       /* Allocate 2 got entries and 1 dynamic reloc for R_390_TLS_LDM64
 	 relocs.  */
-      htab->tls_ldm_got.offset = htab->sgot->size;
-      htab->sgot->size += 2 * GOT_ENTRY_SIZE;
-      htab->srelgot->size += sizeof (Elf64_External_Rela);
+      htab->tls_ldm_got.offset = htab->elf.sgot->size;
+      htab->elf.sgot->size += 2 * GOT_ENTRY_SIZE;
+      htab->elf.srelgot->size += sizeof (Elf64_External_Rela);
     }
   else
     htab->tls_ldm_got.offset = -1;
 
   /* Allocate global sym .plt and .got entries, and space for global
      sym dynamic relocs.  */
-  elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, (PTR) info);
+  elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, info);
 
   /* We now have determined the sizes of the various dynamic sections.
      Allocate memory for them.  */
@@ -2039,17 +2097,20 @@
       if ((s->flags & SEC_LINKER_CREATED) == 0)
 	continue;
 
-      if (s == htab->splt
-	  || s == htab->sgot
-	  || s == htab->sgotplt
-	  || s == htab->sdynbss)
+      if (s == htab->elf.splt
+	  || s == htab->elf.sgot
+	  || s == htab->elf.sgotplt
+	  || s == htab->sdynbss
+	  || s == htab->elf.iplt
+	  || s == htab->elf.igotplt
+	  || s == htab->irelifunc)
 	{
 	  /* Strip this section if we don't need it; see the
 	     comment below.  */
 	}
       else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela"))
 	{
-	  if (s->size != 0 && s != htab->srelplt)
+	  if (s->size != 0 && s != htab->elf.srelplt)
 	    relocs = TRUE;
 
 	  /* We use the reloc_count field as a counter if we need
@@ -2107,7 +2168,7 @@
 	    return FALSE;
 	}
 
-      if (htab->splt->size != 0)
+      if (htab->elf.splt->size != 0)
 	{
 	  if (!add_dynamic_entry (DT_PLTGOT, 0)
 	      || !add_dynamic_entry (DT_PLTRELSZ, 0)
@@ -2127,7 +2188,7 @@
 	     then we need a DT_TEXTREL entry.  */
 	  if ((info->flags & DF_TEXTREL) == 0)
 	    elf_link_hash_traverse (&htab->elf, readonly_dynrelocs,
-				    (PTR) info);
+				    info);
 
 	  if ((info->flags & DF_TEXTREL) != 0)
 	    {
@@ -2146,8 +2207,7 @@
    This is PT_TLS segment p_vaddr.  */
 
 static bfd_vma
-dtpoff_base (info)
-     struct bfd_link_info *info;
+dtpoff_base (struct bfd_link_info *info)
 {
   /* If tls_sec is NULL, we should have signalled an error already.  */
   if (elf_hash_table (info)->tls_sec == NULL)
@@ -2159,9 +2219,7 @@
    if STT_TLS virtual address is ADDRESS.  */
 
 static bfd_vma
-tpoff (info, address)
-     struct bfd_link_info *info;
-     bfd_vma address;
+tpoff (struct bfd_link_info *info, bfd_vma address)
 {
   struct elf_link_hash_table *htab = elf_hash_table (info);
 
@@ -2175,10 +2233,9 @@
    instruction.  */
 
 static void
-invalid_tls_insn (input_bfd, input_section, rel)
-     bfd *input_bfd;
-     asection *input_section;
-     Elf_Internal_Rela *rel;
+invalid_tls_insn (bfd *input_bfd,
+		  asection *input_section,
+		  Elf_Internal_Rela *rel)
 {
   reloc_howto_type *howto;
 
@@ -2236,6 +2293,7 @@
       bfd_boolean unresolved_reloc;
       bfd_reloc_status_type r;
       int tls_type;
+      asection *base_got = htab->elf.sgot;
 
       r_type = ELF64_R_TYPE (rel->r_info);
       if (r_type == (int) R_390_GNU_VTINHERIT
@@ -2258,7 +2316,60 @@
 	{
 	  sym = local_syms + r_symndx;
 	  sec = local_sections[r_symndx];
-	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
+
+	  if (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC)
+	    {
+	      struct plt_entry *local_plt = elf_s390_local_plt (input_bfd);
+	      if (local_plt == NULL)
+		return FALSE;
+
+	      /* Address of the PLT slot.  */
+	      relocation = (htab->elf.iplt->output_section->vma
+			    + htab->elf.iplt->output_offset
+			    + local_plt[r_symndx].plt.offset);
+
+	      switch (r_type)
+		{
+		case R_390_PLTOFF16:
+		case R_390_PLTOFF32:
+		case R_390_PLTOFF64:
+		  relocation -= htab->elf.sgot->output_section->vma;
+		  break;
+		case R_390_GOTPLT12:
+		case R_390_GOTPLT16:
+		case R_390_GOTPLT20:
+		case R_390_GOTPLT32:
+		case R_390_GOTPLT64:
+		case R_390_GOTPLTENT:
+		case R_390_GOT12:
+		case R_390_GOT16:
+		case R_390_GOT20:
+		case R_390_GOT32:
+		case R_390_GOT64:
+		case R_390_GOTENT:
+		  {
+		    /* Write the PLT slot address into the GOT slot.  */
+		    bfd_put_64 (output_bfd, relocation,
+				htab->elf.sgot->contents +
+				local_got_offsets[r_symndx]);
+		    relocation = (local_got_offsets[r_symndx] +
+				  htab->elf.sgot->output_offset);
+
+		    if (r_type == R_390_GOTENT || r_type == R_390_GOTPLTENT)
+		      relocation += htab->elf.sgot->output_section->vma;
+		    break;
+		  }
+		default:
+		  break;
+		}
+	      /* The output section is needed later in
+		 finish_dynamic_section when creating the dynamic
+		 relocation.  */
+	      local_plt[r_symndx].sec = sec;
+	      goto do_relocation;
+	    }
+	  else
+	    relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
 	}
       else
 	{
@@ -2270,9 +2381,9 @@
 				   unresolved_reloc, warned);
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -2298,18 +2409,28 @@
 	    {
 	      bfd_vma plt_index;
 
-	      /* Calc. index no.
-		 Current offset - size first entry / entry size.  */
-	      plt_index = (h->plt.offset - PLT_FIRST_ENTRY_SIZE) /
-		PLT_ENTRY_SIZE;
+	      if (s390_is_ifunc_symbol_p (h))
+		{
+		  plt_index = h->plt.offset / PLT_ENTRY_SIZE;
+		  relocation = (plt_index * GOT_ENTRY_SIZE +
+				htab->elf.igotplt->output_offset);
+		  if (r_type == R_390_GOTPLTENT)
+		    relocation += htab->elf.igotplt->output_section->vma;
+		}
+	      else
+		{
+		  /* Calc. index no.
+		     Current offset - size first entry / entry size.  */
+		  plt_index = (h->plt.offset - PLT_FIRST_ENTRY_SIZE) /
+		    PLT_ENTRY_SIZE;
 
-	      /* Offset in GOT is PLT index plus GOT headers(3) times 4,
-		 addr & GOT addr.  */
-	      relocation = (plt_index + 3) * GOT_ENTRY_SIZE;
+		  /* Offset in GOT is PLT index plus GOT headers(3)
+		     times 4, addr & GOT addr.  */
+		  relocation = (plt_index + 3) * GOT_ENTRY_SIZE;
+		  if (r_type == R_390_GOTPLTENT)
+		    relocation += htab->elf.sgot->output_section->vma;
+		}
 	      unresolved_reloc = FALSE;
-
-	      if (r_type == R_390_GOTPLTENT)
-		relocation += htab->sgot->output_section->vma;
 	      break;
 	    }
 	  /* Fall through.  */
@@ -2322,7 +2443,7 @@
 	case R_390_GOTENT:
 	  /* Relocation is to the entry for this symbol in the global
 	     offset table.  */
-	  if (htab->sgot == NULL)
+	  if (base_got == NULL)
 	    abort ();
 
 	  if (h != NULL)
@@ -2331,11 +2452,29 @@
 
 	      off = h->got.offset;
 	      dyn = htab->elf.dynamic_sections_created;
-	      if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
-		  || (info->shared
-		      && SYMBOL_REFERENCES_LOCAL (info, h))
-		  || (ELF_ST_VISIBILITY (h->other)
-		      && h->root.type == bfd_link_hash_undefweak))
+
+	      if (s390_is_ifunc_symbol_p (h))
+		{
+		  BFD_ASSERT (h->plt.offset != (bfd_vma) -1);
+		  if (off == (bfd_vma)-1)
+		    {
+		      /* No explicit GOT usage so redirect to the
+			 got.iplt slot.  */
+		      base_got = htab->elf.igotplt;
+		      off = h->plt.offset / PLT_ENTRY_SIZE * GOT_ENTRY_SIZE;
+		    }
+		  else
+		    {
+		      /* Explicit GOT slots must contain the address
+			 of the PLT slot. This will be handled in
+			 finish_dynamic_symbol.  */
+		    }
+		}
+	      else if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
+		       || (info->shared
+			   && SYMBOL_REFERENCES_LOCAL (info, h))
+		       || (ELF_ST_VISIBILITY (h->other)
+			   && h->root.type == bfd_link_hash_undefweak))
 		{
 		  /* This is actually a static link, or it is a
 		     -Bsymbolic link and the symbol is defined
@@ -2354,9 +2493,40 @@
 		  else
 		    {
 		      bfd_put_64 (output_bfd, relocation,
-				  htab->sgot->contents + off);
+				  base_got->contents + off);
 		      h->got.offset |= 1;
 		    }
+
+		  if ((h->def_regular
+		       && info->shared
+		       && SYMBOL_REFERENCES_LOCAL (info, h))
+		      /* lgrl rx,sym@GOTENT -> larl rx, sym */
+		      && ((r_type == R_390_GOTENT
+			   && (bfd_get_16 (input_bfd,
+					   contents + rel->r_offset - 2)
+			       & 0xff0f) == 0xc408)
+			  /* lg rx, sym@GOT(r12) -> larl rx, sym */
+			  || (r_type == R_390_GOT20
+			      && (bfd_get_32 (input_bfd,
+					      contents + rel->r_offset - 2)
+				  & 0xff00f000) == 0xe300c000
+			      && bfd_get_8 (input_bfd,
+					    contents + rel->r_offset + 3) == 0x04)))
+
+		    {
+		      unsigned short new_insn =
+			(0xc000 | (bfd_get_8 (input_bfd,
+					      contents + rel->r_offset - 1) & 0xf0));
+		      bfd_put_16 (output_bfd, new_insn,
+				  contents + rel->r_offset - 2);
+		      r_type = R_390_PC32DBL;
+		      rel->r_addend = 2;
+		      howto = elf_howto_table + r_type;
+		      relocation = h->root.u.def.value
+			+ h->root.u.def.section->output_section->vma
+			+ h->root.u.def.section->output_offset;
+		      goto do_relocation;
+		    }
 		}
 	      else
 		unresolved_reloc = FALSE;
@@ -2376,7 +2546,7 @@
 	      else
 		{
 		  bfd_put_64 (output_bfd, relocation,
-			      htab->sgot->contents + off);
+			      htab->elf.sgot->contents + off);
 
 		  if (info->shared)
 		    {
@@ -2384,12 +2554,12 @@
 		      Elf_Internal_Rela outrel;
 		      bfd_byte *loc;
 
-		      s = htab->srelgot;
+		      s = htab->elf.srelgot;
 		      if (s == NULL)
 			abort ();
 
-		      outrel.r_offset = (htab->sgot->output_section->vma
-					 + htab->sgot->output_offset
+		      outrel.r_offset = (htab->elf.sgot->output_section->vma
+					 + htab->elf.sgot->output_offset
 					 + off);
 		      outrel.r_info = ELF64_R_INFO (0, R_390_RELATIVE);
 		      outrel.r_addend = relocation;
@@ -2405,7 +2575,7 @@
 	  if (off >= (bfd_vma) -2)
 	    abort ();
 
-	  relocation = htab->sgot->output_offset + off;
+	  relocation = base_got->output_offset + off;
 
 	  /* For @GOTENT the relocation is against the offset between
 	     the instruction and the symbols entry in the GOT and not
@@ -2413,7 +2583,7 @@
 	     add the vma of the GOT to get the correct value.  */
 	  if (   r_type == R_390_GOTENT
 	      || r_type == R_390_GOTPLTENT)
-	    relocation += htab->sgot->output_section->vma;
+	    relocation += base_got->output_section->vma;
 
 	  break;
 
@@ -2428,17 +2598,19 @@
 	     defined _GLOBAL_OFFSET_TABLE in a different way, as is
 	     permitted by the ABI, we might have to change this
 	     calculation.  */
-	  relocation -= htab->sgot->output_section->vma;
+	  relocation -= htab->elf.sgot->output_section->vma;
 	  break;
 
 	case R_390_GOTPC:
 	case R_390_GOTPCDBL:
 	  /* Use global offset table as symbol value.  */
-	  relocation = htab->sgot->output_section->vma;
+	  relocation = htab->elf.sgot->output_section->vma;
 	  unresolved_reloc = FALSE;
 	  break;
 
+	case R_390_PLT12DBL:
 	case R_390_PLT16DBL:
+	case R_390_PLT24DBL:
 	case R_390_PLT32:
 	case R_390_PLT32DBL:
 	case R_390_PLT64:
@@ -2451,17 +2623,21 @@
 	    break;
 
 	  if (h->plt.offset == (bfd_vma) -1
-	      || htab->splt == NULL)
+	      || (htab->elf.splt == NULL && !s390_is_ifunc_symbol_p (h)))
 	    {
 	      /* We didn't make a PLT entry for this symbol.  This
 		 happens when statically linking PIC code, or when
 		 using -Bsymbolic.  */
 	      break;
 	    }
-
-	  relocation = (htab->splt->output_section->vma
-			+ htab->splt->output_offset
-			+ h->plt.offset);
+	  if (s390_is_ifunc_symbol_p (h))
+	    relocation = (htab->elf.iplt->output_section->vma
+			  + htab->elf.iplt->output_offset
+			  + h->plt.offset);
+	  else
+	    relocation = (htab->elf.splt->output_section->vma
+			  + htab->elf.splt->output_offset
+			  + h->plt.offset);
 	  unresolved_reloc = FALSE;
 	  break;
 
@@ -2473,18 +2649,24 @@
 
 	  /* For local symbols or if we didn't make a PLT entry for
 	     this symbol resolve the symbol directly.  */
-	  if (   h == NULL
+	  if (h == NULL
 	      || h->plt.offset == (bfd_vma) -1
-	      || htab->splt == NULL)
+	      || (htab->elf.splt == NULL && !s390_is_ifunc_symbol_p (h)))
 	    {
-	      relocation -= htab->sgot->output_section->vma;
+	      relocation -= htab->elf.sgot->output_section->vma;
 	      break;
 	    }
 
-	  relocation = (htab->splt->output_section->vma
-			+ htab->splt->output_offset
-			+ h->plt.offset
-			- htab->sgot->output_section->vma);
+	  if (s390_is_ifunc_symbol_p (h))
+	    relocation = (htab->elf.iplt->output_section->vma
+			  + htab->elf.iplt->output_offset
+			  + h->plt.offset
+			  - htab->elf.sgot->output_section->vma);
+	  else
+	    relocation = (htab->elf.splt->output_section->vma
+			  + htab->elf.splt->output_offset
+			  + h->plt.offset
+			  - htab->elf.sgot->output_section->vma);
 	  unresolved_reloc = FALSE;
 	  break;
 
@@ -2493,10 +2675,74 @@
 	case R_390_32:
 	case R_390_64:
 	case R_390_PC16:
+	case R_390_PC12DBL:
 	case R_390_PC16DBL:
+	case R_390_PC24DBL:
 	case R_390_PC32:
 	case R_390_PC32DBL:
 	case R_390_PC64:
+
+	  if (h != NULL
+	      && s390_is_ifunc_symbol_p (h)
+	      && h->def_regular)
+	    {
+	      if (!info->shared || !h->non_got_ref)
+		{
+		  /* For a non-shared object STT_GNU_IFUNC symbol must
+		     go through PLT.  */
+		  relocation = (htab->elf.iplt->output_section->vma
+				+ htab->elf.iplt->output_offset
+				+ h ->plt.offset);
+		  goto do_relocation;
+		}
+	      else
+		{
+		  /* For shared objects a runtime relocation is needed.  */
+
+		  Elf_Internal_Rela outrel;
+		  asection *sreloc;
+
+		  /* Need a dynamic relocation to get the real function
+		     address.  */
+		  outrel.r_offset = _bfd_elf_section_offset (output_bfd,
+							     info,
+							     input_section,
+							     rel->r_offset);
+		  if (outrel.r_offset == (bfd_vma) -1
+		      || outrel.r_offset == (bfd_vma) -2)
+		    abort ();
+
+		  outrel.r_offset += (input_section->output_section->vma
+				      + input_section->output_offset);
+
+		  if (h->dynindx == -1
+		      || h->forced_local
+		      || info->executable)
+		    {
+		      /* This symbol is resolved locally.  */
+		      outrel.r_info = ELF64_R_INFO (0, R_390_IRELATIVE);
+		      outrel.r_addend = (h->root.u.def.value
+					 + h->root.u.def.section->output_section->vma
+					 + h->root.u.def.section->output_offset);
+		    }
+		  else
+		    {
+		      outrel.r_info = ELF64_R_INFO (h->dynindx, r_type);
+		      outrel.r_addend = 0;
+		    }
+
+		  sreloc = htab->elf.irelifunc;
+		  elf_append_rela (output_bfd, sreloc, &outrel);
+
+		  /* If this reloc is against an external symbol, we
+		     do not want to fiddle with the addend.  Otherwise,
+		     we need to include the symbol value so that it
+		     becomes an addend for the dynamic reloc.  For an
+		     internal symbol, we have updated addend.  */
+		  continue;
+		}
+	    }
+
 	  if ((input_section->flags & SEC_ALLOC) == 0)
 	    break;
 
@@ -2505,7 +2751,9 @@
 		   || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
 		   || h->root.type != bfd_link_hash_undefweak)
 	       && ((r_type != R_390_PC16
+		    && r_type != R_390_PC12DBL
 		    && r_type != R_390_PC16DBL
+		    && r_type != R_390_PC24DBL
 		    && r_type != R_390_PC32
 		    && r_type != R_390_PC32DBL
 		    && r_type != R_390_PC64)
@@ -2547,7 +2795,9 @@
 	      else if (h != NULL
 		       && h->dynindx != -1
 		       && (r_type == R_390_PC16
+			   || r_type == R_390_PC12DBL
 			   || r_type == R_390_PC16DBL
+			   || r_type == R_390_PC24DBL
 			   || r_type == R_390_PC32
 			   || r_type == R_390_PC32DBL
 			   || r_type == R_390_PC64
@@ -2667,7 +2917,7 @@
 	      continue;
 	    }
 
-	  if (htab->sgot == NULL)
+	  if (htab->elf.sgot == NULL)
 	    abort ();
 
 	  if (h != NULL)
@@ -2690,11 +2940,11 @@
 	      bfd_byte *loc;
 	      int dr_type, indx;
 
-	      if (htab->srelgot == NULL)
+	      if (htab->elf.srelgot == NULL)
 		abort ();
 
-	      outrel.r_offset = (htab->sgot->output_section->vma
-				 + htab->sgot->output_offset + off);
+	      outrel.r_offset = (htab->elf.sgot->output_section->vma
+				 + htab->elf.sgot->output_offset + off);
 
 	      indx = h && h->dynindx != -1 ? h->dynindx : 0;
 	      if (r_type == R_390_TLS_GD64)
@@ -2706,8 +2956,8 @@
 	      else
 		outrel.r_addend = 0;
 	      outrel.r_info = ELF64_R_INFO (indx, dr_type);
-	      loc = htab->srelgot->contents;
-	      loc += htab->srelgot->reloc_count++
+	      loc = htab->elf.srelgot->contents;
+	      loc += htab->elf.srelgot->reloc_count++
 		* sizeof (Elf64_External_Rela);
 	      bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 
@@ -2718,14 +2968,14 @@
 	    	      BFD_ASSERT (! unresolved_reloc);
 		      bfd_put_64 (output_bfd,
 				  relocation - dtpoff_base (info),
-				  htab->sgot->contents + off + GOT_ENTRY_SIZE);
+				  htab->elf.sgot->contents + off + GOT_ENTRY_SIZE);
 		    }
 		  else
 		    {
 		      outrel.r_info = ELF64_R_INFO (indx, R_390_TLS_DTPOFF);
 		      outrel.r_offset += GOT_ENTRY_SIZE;
 		      outrel.r_addend = 0;
-		      htab->srelgot->reloc_count++;
+		      htab->elf.srelgot->reloc_count++;
 		      loc += sizeof (Elf64_External_Rela);
 		      bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 		    }
@@ -2741,14 +2991,14 @@
 	    abort ();
 	  if (r_type == ELF64_R_TYPE (rel->r_info))
 	    {
-	      relocation = htab->sgot->output_offset + off;
+	      relocation = htab->elf.sgot->output_offset + off;
 	      if (r_type == R_390_TLS_IE64 || r_type == R_390_TLS_IEENT)
-		relocation += htab->sgot->output_section->vma;
+		relocation += htab->elf.sgot->output_section->vma;
 	      unresolved_reloc = FALSE;
 	    }
 	  else
 	    {
-	      bfd_put_64 (output_bfd, htab->sgot->output_offset + off,
+	      bfd_put_64 (output_bfd, htab->elf.sgot->output_offset + off,
 			  contents + rel->r_offset);
 	      continue;
 	    }
@@ -2773,15 +3023,15 @@
 		goto emit_tls_relocs;
 	    }
 
-	  if (htab->sgot == NULL)
+	  if (htab->elf.sgot == NULL)
 	    abort ();
 
 	  BFD_ASSERT (! unresolved_reloc);
 	  bfd_put_64 (output_bfd, -tpoff (info, relocation),
-		      htab->sgot->contents + off);
-	  relocation = htab->sgot->output_offset + off;
+		      htab->elf.sgot->contents + off);
+	  relocation = htab->elf.sgot->output_offset + off;
 	  if (r_type == R_390_TLS_IEENT)
-	    relocation += htab->sgot->output_section->vma;
+	    relocation += htab->elf.sgot->output_section->vma;
 	  unresolved_reloc = FALSE;
 	  break;
 
@@ -2792,7 +3042,7 @@
 	       and the value will turn out zero.  */
 	    continue;
 
-	  if (htab->sgot == NULL)
+	  if (htab->elf.sgot == NULL)
 	    abort ();
 
 	  off = htab->tls_ldm_got.offset;
@@ -2803,23 +3053,23 @@
 	      Elf_Internal_Rela outrel;
 	      bfd_byte *loc;
 
-	      if (htab->srelgot == NULL)
+	      if (htab->elf.srelgot == NULL)
 		abort ();
 
-	      outrel.r_offset = (htab->sgot->output_section->vma
-				 + htab->sgot->output_offset + off);
+	      outrel.r_offset = (htab->elf.sgot->output_section->vma
+				 + htab->elf.sgot->output_offset + off);
 
 	      bfd_put_64 (output_bfd, 0,
-			  htab->sgot->contents + off + GOT_ENTRY_SIZE);
+			  htab->elf.sgot->contents + off + GOT_ENTRY_SIZE);
 	      outrel.r_info = ELF64_R_INFO (0, R_390_TLS_DTPMOD);
 	      outrel.r_addend = 0;
-	      loc = htab->srelgot->contents;
-	      loc += htab->srelgot->reloc_count++
+	      loc = htab->elf.srelgot->contents;
+	      loc += htab->elf.srelgot->reloc_count++
 		* sizeof (Elf64_External_Rela);
 	      bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
 	      htab->tls_ldm_got.offset |= 1;
 	    }
-	  relocation = htab->sgot->output_offset + off;
+	  relocation = htab->elf.sgot->output_offset + off;
 	  unresolved_reloc = FALSE;
 	  break;
 
@@ -2861,7 +3111,7 @@
 	  continue;
 
 	case R_390_TLS_LDO64:
-	  if (info->shared)
+	  if (info->shared || (input_section->flags & SEC_DEBUGGING))
 	    relocation -= dtpoff_base (info);
 	  else
 	    /* When converting LDO to LE, we must negate.  */
@@ -2971,7 +3221,9 @@
 	 not process them.  */
       if (unresolved_reloc
 	  && !((input_section->flags & SEC_DEBUGGING) != 0
-	       && h->def_dynamic))
+	       && h->def_dynamic)
+	  && _bfd_elf_section_offset (output_bfd, info, input_section,
+				      rel->r_offset) != (bfd_vma) -1)
 	(*_bfd_error_handler)
 	  (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
 	   input_bfd,
@@ -2980,6 +3232,15 @@
 	   howto->name,
 	   h->root.root.string);
 
+    do_relocation:
+
+      /* When applying a 24 bit reloc we need to start one byte
+	 earlier.  Otherwise the 32 bit get/put bfd operations might
+	 access a byte after the actual section.  */
+      if (r_type == R_390_PC24DBL
+	  || r_type == R_390_PLT24DBL)
+	rel->r_offset--;
+
       if (r_type == R_390_20
 	  || r_type == R_390_GOT20
 	  || r_type == R_390_GOTPLT20
@@ -3036,6 +3297,92 @@
   return TRUE;
 }
 
+/* Generate the PLT slots together with the dynamic relocations needed
+   for IFUNC symbols.  */
+
+static void
+elf_s390_finish_ifunc_symbol (bfd *output_bfd,
+			      struct bfd_link_info *info,
+			      struct elf_link_hash_entry *h,
+			      struct elf_s390_link_hash_table *htab,
+			      bfd_vma plt_offset,
+			      bfd_vma resolver_address)
+{
+  bfd_vma plt_index;
+  bfd_vma got_offset;
+  Elf_Internal_Rela rela;
+  bfd_byte *loc;
+  asection *plt, *gotplt, *relplt;
+
+  if (htab->elf.iplt == NULL
+      || htab->elf.igotplt == NULL
+      || htab->elf.irelplt == NULL)
+    abort ();
+
+  /* Index of the PLT slot within iplt section.  */
+  plt_index = plt_offset / PLT_ENTRY_SIZE;
+  plt = htab->elf.iplt;
+  /* Offset into the igot.plt section.  */
+  got_offset = plt_index * GOT_ENTRY_SIZE;
+  gotplt = htab->elf.igotplt;
+  relplt = htab->elf.irelplt;
+
+  /* Fill in the blueprint of a PLT.  */
+  memcpy (plt->contents + plt_offset, elf_s390x_plt_entry,
+	  PLT_ENTRY_SIZE);
+
+  /* Fixup the relative address to the GOT entry */
+  bfd_put_32 (output_bfd,
+	      (gotplt->output_section->vma +
+	       gotplt->output_offset + got_offset
+	       - (plt->output_section->vma +
+		  plt->output_offset +
+		  plt_offset))/2,
+	      plt->contents + plt_offset + 2);
+  /* Fixup the relative branch to PLT 0 */
+  bfd_put_32 (output_bfd, - (plt->output_offset +
+			     (PLT_ENTRY_SIZE * plt_index) + 22)/2,
+	      plt->contents + plt_offset + 24);
+  /* Fixup offset into .rela.plt section.  */
+  bfd_put_32 (output_bfd, relplt->output_offset +
+	      plt_index * sizeof (Elf64_External_Rela),
+	      plt->contents + plt_offset + 28);
+
+  /* Fill in the entry in the global offset table.
+     Points to instruction after GOT offset.  */
+  bfd_put_64 (output_bfd,
+	      (plt->output_section->vma
+	       + plt->output_offset
+	       + plt_offset
+	       + 14),
+	      gotplt->contents + got_offset);
+
+  /* Fill in the entry in the .rela.plt section.  */
+  rela.r_offset = (gotplt->output_section->vma
+		   + gotplt->output_offset
+		   + got_offset);
+
+  if (!h
+      || h->dynindx == -1
+      || ((info->executable
+	   || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
+	  && h->def_regular))
+    {
+      /* The symbol can be locally resolved.  */
+      rela.r_info = ELF64_R_INFO (0, R_390_IRELATIVE);
+      rela.r_addend = resolver_address;
+    }
+  else
+    {
+      rela.r_info = ELF64_R_INFO (h->dynindx, R_390_JMP_SLOT);
+      rela.r_addend = 0;
+    }
+
+  loc = relplt->contents + plt_index * sizeof (Elf64_External_Rela);
+  bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
+}
+
+
 /* Finish up dynamic symbol handling.  We set the contents of various
    dynamic sections here.  */
 
@@ -3046,6 +3393,7 @@
 				Elf_Internal_Sym *sym)
 {
   struct elf_s390_link_hash_table *htab;
+  struct elf_s390_link_hash_entry *eh = (struct elf_s390_link_hash_entry*)h;
 
   htab = elf_s390_hash_table (info);
   if (htab == NULL)
@@ -3060,78 +3408,82 @@
 
       /* This symbol has an entry in the procedure linkage table.  Set
 	 it up.  */
-
-      if (h->dynindx == -1
-	  || htab->splt == NULL
-	  || htab->sgotplt == NULL
-	  || htab->srelplt == NULL)
-	abort ();
-
-      /* Calc. index no.
-	 Current offset - size first entry / entry size.  */
-      plt_index = (h->plt.offset - PLT_FIRST_ENTRY_SIZE) / PLT_ENTRY_SIZE;
-
-      /* Offset in GOT is PLT index plus GOT headers(3) times 8,
-	 addr & GOT addr.  */
-      got_offset = (plt_index + 3) * GOT_ENTRY_SIZE;
-
-      /* Fill in the blueprint of a PLT.  */
-      bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD0,
-		  htab->splt->contents + h->plt.offset);
-      bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD1,
-		  htab->splt->contents + h->plt.offset + 4);
-      bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD2,
-		  htab->splt->contents + h->plt.offset + 8);
-      bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD3,
-		  htab->splt->contents + h->plt.offset + 12);
-      bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD4,
-		  htab->splt->contents + h->plt.offset + 16);
-      bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD5,
-		  htab->splt->contents + h->plt.offset + 20);
-      bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD6,
-		  htab->splt->contents + h->plt.offset + 24);
-      bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD7,
-		  htab->splt->contents + h->plt.offset + 28);
-      /* Fixup the relative address to the GOT entry */
-      bfd_put_32 (output_bfd,
-		  (htab->sgotplt->output_section->vma +
-		   htab->sgotplt->output_offset + got_offset
-		   - (htab->splt->output_section->vma + h->plt.offset))/2,
-		  htab->splt->contents + h->plt.offset + 2);
-      /* Fixup the relative branch to PLT 0 */
-      bfd_put_32 (output_bfd, - (PLT_FIRST_ENTRY_SIZE +
-				 (PLT_ENTRY_SIZE * plt_index) + 22)/2,
-		  htab->splt->contents + h->plt.offset + 24);
-      /* Fixup offset into symbol table */
-      bfd_put_32 (output_bfd, plt_index * sizeof (Elf64_External_Rela),
-		  htab->splt->contents + h->plt.offset + 28);
-
-      /* Fill in the entry in the global offset table.
-	 Points to instruction after GOT offset.  */
-      bfd_put_64 (output_bfd,
-		  (htab->splt->output_section->vma
-		   + htab->splt->output_offset
-		   + h->plt.offset
-		   + 14),
-		  htab->sgotplt->contents + got_offset);
-
-      /* Fill in the entry in the .rela.plt section.  */
-      rela.r_offset = (htab->sgotplt->output_section->vma
-		       + htab->sgotplt->output_offset
-		       + got_offset);
-      rela.r_info = ELF64_R_INFO (h->dynindx, R_390_JMP_SLOT);
-      rela.r_addend = 0;
-      loc = htab->srelplt->contents + plt_index * sizeof (Elf64_External_Rela);
-      bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
-
-      if (!h->def_regular)
+      if (s390_is_ifunc_symbol_p (h))
 	{
-	  /* Mark the symbol as undefined, rather than as defined in
-	     the .plt section.  Leave the value alone.  This is a clue
-	     for the dynamic linker, to make function pointer
-	     comparisons work between an application and shared
-	     library.  */
-	  sym->st_shndx = SHN_UNDEF;
+	  /* If we can resolve the IFUNC symbol locally we generate an
+	     IRELATIVE reloc.  */
+	  elf_s390_finish_ifunc_symbol (output_bfd, info, h, htab, h->plt.offset,
+					eh->ifunc_resolver_address +
+					eh->ifunc_resolver_section->output_offset +
+					eh->ifunc_resolver_section->output_section->vma);
+				 ;
+	  /* Fallthrough.  Handling of explicit GOT slots of IFUNC
+	     symbols is below.  */
+	}
+      else
+	{
+	  if (h->dynindx == -1
+	      || htab->elf.splt == NULL
+	      || htab->elf.sgotplt == NULL
+	      || htab->elf.srelplt == NULL)
+	    abort ();
+
+	  /* Calc. index no.
+	     Current offset - size first entry / entry size.  */
+	  plt_index = (h->plt.offset - PLT_FIRST_ENTRY_SIZE) / PLT_ENTRY_SIZE;
+
+	  /* Offset in GOT is PLT index plus GOT headers(3) times 8,
+	     addr & GOT addr.  */
+	  got_offset = (plt_index + 3) * GOT_ENTRY_SIZE;
+
+	  /* Fill in the blueprint of a PLT.  */
+	  memcpy (htab->elf.splt->contents + h->plt.offset, elf_s390x_plt_entry,
+		  PLT_ENTRY_SIZE);
+
+	  /* Fixup the relative address to the GOT entry */
+	  bfd_put_32 (output_bfd,
+		      (htab->elf.sgotplt->output_section->vma +
+		       htab->elf.sgotplt->output_offset + got_offset
+		       - (htab->elf.splt->output_section->vma +
+			  htab->elf.splt->output_offset +
+			  h->plt.offset))/2,
+		      htab->elf.splt->contents + h->plt.offset + 2);
+	  /* Fixup the relative branch to PLT 0 */
+	  bfd_put_32 (output_bfd, - (PLT_FIRST_ENTRY_SIZE +
+				     (PLT_ENTRY_SIZE * plt_index) + 22)/2,
+		      htab->elf.splt->contents + h->plt.offset + 24);
+	  /* Fixup offset into .rela.plt section.  */
+	  bfd_put_32 (output_bfd, plt_index * sizeof (Elf64_External_Rela),
+		      htab->elf.splt->contents + h->plt.offset + 28);
+
+	  /* Fill in the entry in the global offset table.
+	     Points to instruction after GOT offset.  */
+	  bfd_put_64 (output_bfd,
+		      (htab->elf.splt->output_section->vma
+		       + htab->elf.splt->output_offset
+		       + h->plt.offset
+		       + 14),
+		      htab->elf.sgotplt->contents + got_offset);
+
+	  /* Fill in the entry in the .rela.plt section.  */
+	  rela.r_offset = (htab->elf.sgotplt->output_section->vma
+			   + htab->elf.sgotplt->output_offset
+			   + got_offset);
+	  rela.r_info = ELF64_R_INFO (h->dynindx, R_390_JMP_SLOT);
+	  rela.r_addend = 0;
+	  loc = htab->elf.srelplt->contents + plt_index *
+	    sizeof (Elf64_External_Rela);
+	  bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
+
+	  if (!h->def_regular)
+	    {
+	      /* Mark the symbol as undefined, rather than as defined in
+		 the .plt section.  Leave the value alone.  This is a clue
+		 for the dynamic linker, to make function pointer
+		 comparisons work between an application and shared
+		 library.  */
+	      sym->st_shndx = SHN_UNDEF;
+	    }
 	}
     }
 
@@ -3145,21 +3497,44 @@
 
       /* This symbol has an entry in the global offset table.  Set it
 	 up.  */
-      if (htab->sgot == NULL || htab->srelgot == NULL)
+      if (htab->elf.sgot == NULL || htab->elf.srelgot == NULL)
 	abort ();
 
-      rela.r_offset = (htab->sgot->output_section->vma
-		       + htab->sgot->output_offset
+      rela.r_offset = (htab->elf.sgot->output_section->vma
+		       + htab->elf.sgot->output_offset
 		       + (h->got.offset &~ (bfd_vma) 1));
 
-      /* If this is a static link, or it is a -Bsymbolic link and the
-	 symbol is defined locally or was forced to be local because
-	 of a version file, we just want to emit a RELATIVE reloc.
-	 The entry in the global offset table will already have been
-	 initialized in the relocate_section function.  */
-      if (info->shared
+      if (h->def_regular && s390_is_ifunc_symbol_p (h))
+	{
+	  if (info->shared)
+	    {
+	      /* An explicit GOT slot usage needs GLOB_DAT.  If the
+		 symbol references local the implicit got.iplt slot
+		 will be used and the IRELATIVE reloc has been created
+		 above.  */
+	      goto do_glob_dat;
+	    }
+	  else
+	    {
+	      /* For non-shared objects explicit GOT slots must be
+		 filled with the PLT slot address for pointer
+		 equality reasons.  */
+	      bfd_put_64 (output_bfd, (htab->elf.iplt->output_section->vma
+				       + htab->elf.iplt->output_offset
+				       + h->plt.offset),
+			  htab->elf.sgot->contents + h->got.offset);
+	      return TRUE;
+	    }
+	}
+      else if (info->shared
 	  && SYMBOL_REFERENCES_LOCAL (info, h))
 	{
+	  /* If this is a static link, or it is a -Bsymbolic link and
+	     the symbol is defined locally or was forced to be local
+	     because of a version file, we just want to emit a
+	     RELATIVE reloc.  The entry in the global offset table
+	     will already have been initialized in the
+	     relocate_section function.  */
 	  if (!h->def_regular)
 	    return FALSE;
 	  BFD_ASSERT((h->got.offset & 1) != 0);
@@ -3171,13 +3546,14 @@
       else
 	{
 	  BFD_ASSERT((h->got.offset & 1) == 0);
-	  bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgot->contents + h->got.offset);
+do_glob_dat:
+	  bfd_put_64 (output_bfd, (bfd_vma) 0, htab->elf.sgot->contents + h->got.offset);
 	  rela.r_info = ELF64_R_INFO (h->dynindx, R_390_GLOB_DAT);
 	  rela.r_addend = 0;
 	}
 
-      loc = htab->srelgot->contents;
-      loc += htab->srelgot->reloc_count++ * sizeof (Elf64_External_Rela);
+      loc = htab->elf.srelgot->contents;
+      loc += htab->elf.srelgot->reloc_count++ * sizeof (Elf64_External_Rela);
       bfd_elf64_swap_reloca_out (output_bfd, &rela, loc);
     }
 
@@ -3205,7 +3581,7 @@
     }
 
   /* Mark some specially defined symbols as absolute.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+  if (h == htab->elf.hdynamic
       || h == htab->elf.hgot
       || h == htab->elf.hplt)
     sym->st_shndx = SHN_ABS;
@@ -3217,8 +3593,9 @@
    dynamic linker, before writing them out.  */
 
 static enum elf_reloc_type_class
-elf_s390_reloc_type_class (rela)
-     const Elf_Internal_Rela *rela;
+elf_s390_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			   const asection *rel_sec ATTRIBUTE_UNUSED,
+			   const Elf_Internal_Rela *rela)
 {
   switch ((int) ELF64_R_TYPE (rela->r_info))
     {
@@ -3242,19 +3619,21 @@
   struct elf_s390_link_hash_table *htab;
   bfd *dynobj;
   asection *sdyn;
+  bfd *ibfd;
+  unsigned int i;
 
   htab = elf_s390_hash_table (info);
   if (htab == NULL)
     return FALSE;
 
   dynobj = htab->elf.dynobj;
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (htab->elf.dynamic_sections_created)
     {
       Elf64_External_Dyn *dyncon, *dynconend;
 
-      if (sdyn == NULL || htab->sgot == NULL)
+      if (sdyn == NULL || htab->elf.sgot == NULL)
 	abort ();
 
       dyncon = (Elf64_External_Dyn *) sdyn->contents;
@@ -3272,15 +3651,15 @@
 	      continue;
 
 	    case DT_PLTGOT:
-	      dyn.d_un.d_ptr = htab->sgot->output_section->vma;
+	      dyn.d_un.d_ptr = htab->elf.sgot->output_section->vma;
 	      break;
 
 	    case DT_JMPREL:
-	      dyn.d_un.d_ptr = htab->srelplt->output_section->vma;
+	      dyn.d_un.d_ptr = htab->elf.srelplt->output_section->vma;
 	      break;
 
 	    case DT_PLTRELSZ:
-	      s = htab->srelplt->output_section;
+	      s = htab->elf.srelplt->output_section;
 	      dyn.d_un.d_val = s->size;
 	      break;
 
@@ -3292,7 +3671,7 @@
 		 linker script arranges for .rela.plt to follow all
 		 other relocation sections, we don't have to worry
 		 about changing the DT_RELA entry.  */
-	      s = htab->srelplt->output_section;
+	      s = htab->elf.srelplt->output_section;
 	      dyn.d_un.d_val -= s->size;
 	      break;
 	    }
@@ -3301,52 +3680,73 @@
 	}
 
       /* Fill in the special first entry in the procedure linkage table.  */
-      if (htab->splt && htab->splt->size > 0)
+      if (htab->elf.splt && htab->elf.splt->size > 0)
 	{
 	  /* fill in blueprint for plt 0 entry */
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD0,
-		      htab->splt->contents );
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD1,
-		      htab->splt->contents +4 );
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD3,
-		      htab->splt->contents +12 );
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD4,
-		      htab->splt->contents +16 );
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD5,
-		      htab->splt->contents +20 );
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD6,
-		      htab->splt->contents + 24);
-	  bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD7,
-		      htab->splt->contents + 28 );
+	  memcpy (htab->elf.splt->contents, elf_s390x_first_plt_entry,
+		  PLT_FIRST_ENTRY_SIZE);
 	  /* Fixup relative address to start of GOT */
 	  bfd_put_32 (output_bfd,
-		      (htab->sgotplt->output_section->vma +
-		       htab->sgotplt->output_offset
-		       - htab->splt->output_section->vma - 6)/2,
-		      htab->splt->contents + 8);
+		      (htab->elf.sgotplt->output_section->vma +
+		       htab->elf.sgotplt->output_offset
+		       - htab->elf.splt->output_section->vma - 6)/2,
+		      htab->elf.splt->contents + 8);
 	}
-      elf_section_data (htab->splt->output_section)
-	->this_hdr.sh_entsize = PLT_ENTRY_SIZE;
+      if (elf_section_data (htab->elf.splt->output_section) != NULL)
+	elf_section_data (htab->elf.splt->output_section)->this_hdr.sh_entsize
+	  = PLT_ENTRY_SIZE;
     }
 
-  if (htab->sgotplt)
+  if (htab->elf.sgotplt)
     {
       /* Fill in the first three entries in the global offset table.  */
-      if (htab->sgotplt->size > 0)
+      if (htab->elf.sgotplt->size > 0)
 	{
 	  bfd_put_64 (output_bfd,
 		      (sdyn == NULL ? (bfd_vma) 0
 		       : sdyn->output_section->vma + sdyn->output_offset),
-		      htab->sgotplt->contents);
+		      htab->elf.sgotplt->contents);
 	  /* One entry for shared object struct ptr.  */
-	  bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + 8);
+	  bfd_put_64 (output_bfd, (bfd_vma) 0, htab->elf.sgotplt->contents + 8);
 	  /* One entry for _dl_runtime_resolve.  */
-	  bfd_put_64 (output_bfd, (bfd_vma) 0, htab->sgotplt->contents + 12);
+	  bfd_put_64 (output_bfd, (bfd_vma) 0, htab->elf.sgotplt->contents + 12);
 	}
 
-      elf_section_data (htab->sgot->output_section)
+      elf_section_data (htab->elf.sgot->output_section)
 	->this_hdr.sh_entsize = 8;
     }
+
+  /* Finish dynamic symbol for local IFUNC symbols.  */
+  for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+    {
+      struct plt_entry *local_plt;
+      Elf_Internal_Sym *isym;
+      Elf_Internal_Shdr *symtab_hdr;
+
+      symtab_hdr = &elf_symtab_hdr (ibfd);
+
+      local_plt = elf_s390_local_plt (ibfd);
+      if (local_plt != NULL)
+	for (i = 0; i < symtab_hdr->sh_info; i++)
+	  {
+	    if (local_plt[i].plt.offset != (bfd_vma) -1)
+	      {
+		asection *sec = local_plt[i].sec;
+		isym = bfd_sym_from_r_symndx (&htab->sym_cache, ibfd, i);
+		if (isym == NULL)
+		  return FALSE;
+
+		if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC)
+		  elf_s390_finish_ifunc_symbol (output_bfd, info, NULL, htab,
+						local_plt[i].plt.offset,
+						isym->st_value
+						+ sec->output_section->vma
+						+ sec->output_offset);
+
+	      }
+	  }
+    }
+
   return TRUE;
 }
 
@@ -3360,7 +3760,6 @@
   return plt->vma + PLT_FIRST_ENTRY_SIZE + i * PLT_ENTRY_SIZE;
 }
 
-
 /* Why was the hash table entry size definition changed from
    ARCH_SIZE/8 to 4? This breaks the 64 bit dynamic linker and
    this is the only reason for the s390_elf64_size_info structure.  */
@@ -3433,10 +3832,25 @@
 #define elf_backend_relocate_section	      elf_s390_relocate_section
 #define elf_backend_size_dynamic_sections     elf_s390_size_dynamic_sections
 #define elf_backend_init_index_section	      _bfd_elf_init_1_index_section
-#define elf_backend_reloc_type_class	      elf_s390_reloc_type_class
 #define elf_backend_plt_sym_val		      elf_s390_plt_sym_val
+#define elf_backend_add_symbol_hook           elf_s390_add_symbol_hook
 
 #define bfd_elf64_mkobject		elf_s390_mkobject
 #define elf_backend_object_p		elf_s390_object_p
 
+/* Enable ELF64 archive functions.  */
+#define bfd_elf64_archive_functions
+extern bfd_boolean bfd_elf64_archive_slurp_armap (bfd *);
+extern bfd_boolean bfd_elf64_archive_write_armap (bfd *, unsigned int, struct orl *, unsigned int, int);
+
+#define bfd_elf64_archive_slurp_extended_name_table 	_bfd_archive_coff_slurp_extended_name_table
+#define bfd_elf64_archive_construct_extended_name_table _bfd_archive_coff_construct_extended_name_table
+#define bfd_elf64_archive_truncate_arname 		_bfd_archive_coff_truncate_arname
+#define bfd_elf64_archive_read_ar_hdr			_bfd_archive_coff_read_ar_hdr
+#define bfd_elf64_archive_write_ar_hdr			_bfd_archive_coff_write_ar_hdr
+#define bfd_elf64_archive_openr_next_archived_file 	_bfd_archive_coff_openr_next_archived_file
+#define bfd_elf64_archive_get_elt_at_index 		_bfd_archive_coff_get_elt_at_index
+#define bfd_elf64_archive_generic_stat_arch_elt 	_bfd_archive_coff_generic_stat_arch_elt
+#define bfd_elf64_archive_update_armap_timestamp 	_bfd_archive_coff_update_armap_timestamp
+
 #include "elf64-target.h"
diff --git a/bfd/elf64-sh64.c b/bfd/elf64-sh64.c
index bbef2a2..e70887b 100644
--- a/bfd/elf64-sh64.c
+++ b/bfd/elf64-sh64.c
@@ -1,6 +1,6 @@
 /* SuperH SH64-specific support for 64-bit ELF
    Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-   2010, 2011 Free Software Foundation, Inc.
+   2010, 2011, 2012 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -1514,7 +1514,7 @@
 	      _("Unexpected STO_SH5_ISA32 on local symbol is not handled"),
 	      input_bfd, input_section, rel->r_offset));
 
-	  if (sec != NULL && elf_discarded_section (sec))
+	  if (sec != NULL && discarded_section (sec))
 	    /* Handled below.  */
 	    ;
 	  else if (info->relocatable)
@@ -1630,7 +1630,11 @@
 				 STT_DATALABEL on the way to it.  */
 			      | ((h->other & STO_SH5_ISA32) != 0
 				 && ! seen_stt_datalabel));
-	      else if (!info->relocatable)
+	      else if (!info->relocatable
+		       && (_bfd_elf_section_offset (output_bfd, info,
+						    input_section,
+						    rel->r_offset)
+			   != (bfd_vma) -1))
 		{
 		  (*_bfd_error_handler)
 		    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
@@ -1657,9 +1661,9 @@
 	    }
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -1793,7 +1797,7 @@
 	     offset table extension for the procedure linkage table.  */
 	  if (sgotplt == NULL)
 	    {
-	      sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
+	      sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
 	      BFD_ASSERT (sgotplt != NULL);
 	    }
 
@@ -1816,7 +1820,7 @@
 	     offset table.  */
 	  if (sgot == NULL)
 	    {
-	      sgot = bfd_get_section_by_name (dynobj, ".got");
+	      sgot = bfd_get_linker_section (dynobj, ".got");
 	      BFD_ASSERT (sgot != NULL);
 	    }
 
@@ -1910,7 +1914,7 @@
 		      Elf_Internal_Rela outrel;
 		      bfd_byte *loc;
 
-		      s = bfd_get_section_by_name (dynobj, ".rela.got");
+		      s = bfd_get_linker_section (dynobj, ".rela.got");
 		      BFD_ASSERT (s != NULL);
 
 		      outrel.r_offset = (sgot->output_section->vma
@@ -1945,7 +1949,7 @@
 
 	  if (sgot == NULL)
 	    {
-	      sgot = bfd_get_section_by_name (dynobj, ".got");
+	      sgot = bfd_get_linker_section (dynobj, ".got");
 	      BFD_ASSERT (sgot != NULL);
 	    }
 
@@ -1970,7 +1974,7 @@
 
 	  if (sgot == NULL)
 	    {
-	      sgot = bfd_get_section_by_name (dynobj, ".got");
+	      sgot = bfd_get_linker_section (dynobj, ".got");
 	      BFD_ASSERT (sgot != NULL);
 	    }
 
@@ -2008,7 +2012,7 @@
 
 	  if (splt == NULL)
 	    {
-	      splt = bfd_get_section_by_name (dynobj, ".plt");
+	      splt = bfd_get_linker_section (dynobj, ".plt");
 	      BFD_ASSERT (splt != NULL);
 	    }
 
@@ -2420,6 +2424,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       /* Some relocs require a global offset table.  */
@@ -2486,24 +2494,22 @@
 
 	  if (sgot == NULL)
 	    {
-	      sgot = bfd_get_section_by_name (dynobj, ".got");
+	      sgot = bfd_get_linker_section (dynobj, ".got");
 	      BFD_ASSERT (sgot != NULL);
 	    }
 
 	  if (srelgot == NULL
 	      && (h != NULL || info->shared))
 	    {
-	      srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+	      srelgot = bfd_get_linker_section (dynobj, ".rela.got");
 	      if (srelgot == NULL)
 		{
-		  srelgot = bfd_make_section_with_flags (dynobj,
-							 ".rela.got",
-							 (SEC_ALLOC
-							  | SEC_LOAD
-							  | SEC_HAS_CONTENTS
-							  | SEC_IN_MEMORY
-							  | SEC_LINKER_CREATED
-							  | SEC_READONLY));
+		  flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+				    | SEC_IN_MEMORY | SEC_LINKER_CREATED
+				    | SEC_READONLY);
+		  srelgot = bfd_make_section_anyway_with_flags (dynobj,
+								".rela.got",
+								flags);
 		  if (srelgot == NULL
 		      || ! bfd_set_section_alignment (dynobj, srelgot, 2))
 		    return FALSE;
@@ -3067,7 +3073,7 @@
 {
   struct elf_link_hash_table *ret;
 
-  ret = (struct elf_link_hash_table *) bfd_malloc (sizeof (* ret));
+  ret = (struct elf_link_hash_table *) bfd_zmalloc (sizeof (* ret));
   if (ret == (struct elf_link_hash_table *) NULL)
     return NULL;
 
@@ -3155,7 +3161,7 @@
   if (bed->plt_readonly)
     pltflags |= SEC_READONLY;
 
-  s = bfd_make_section_with_flags (abfd, ".plt", pltflags);
+  s = bfd_make_section_anyway_with_flags (abfd, ".plt", pltflags);
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
     return FALSE;
@@ -3182,9 +3188,10 @@
 	return FALSE;
     }
 
-  s = bfd_make_section_with_flags (abfd,
-				   bed->default_use_rela_p ? ".rela.plt" : ".rel.plt",
-				   flags | SEC_READONLY);
+  s = bfd_make_section_anyway_with_flags (abfd,
+					  bed->default_use_rela_p
+					  ? ".rela.plt" : ".rel.plt",
+					  flags | SEC_READONLY);
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, ptralign))
     return FALSE;
@@ -3192,30 +3199,6 @@
   if (! _bfd_elf_create_got_section (abfd, info))
     return FALSE;
 
-  {
-    const char *secname;
-    char *relname;
-    flagword secflags;
-    asection *sec;
-
-    for (sec = abfd->sections; sec; sec = sec->next)
-      {
-	secflags = bfd_get_section_flags (abfd, sec);
-	if ((secflags & (SEC_DATA | SEC_LINKER_CREATED))
-	    || ((secflags & SEC_HAS_CONTENTS) != SEC_HAS_CONTENTS))
-	  continue;
-	secname = bfd_get_section_name (abfd, sec);
-	relname = (char *) bfd_malloc (strlen (secname) + 6);
-	strcpy (relname, ".rela");
-	strcat (relname, secname);
-	s = bfd_make_section_with_flags (abfd, relname,
-					 flags | SEC_READONLY);
-	if (s == NULL
-	    || ! bfd_set_section_alignment (abfd, s, ptralign))
-	  return FALSE;
-      }
-  }
-
   if (bed->want_dynbss)
     {
       /* The .dynbss section is a place to put symbols which are defined
@@ -3224,8 +3207,8 @@
 	 image and use a R_*_COPY reloc to tell the dynamic linker to
 	 initialize them at run time.  The linker script puts the .dynbss
 	 section into the .bss section of the final image.  */
-      s = bfd_make_section_with_flags (abfd, ".dynbss",
-				       SEC_ALLOC | SEC_LINKER_CREATED);
+      s = bfd_make_section_anyway_with_flags (abfd, ".dynbss",
+					      SEC_ALLOC | SEC_LINKER_CREATED);
       if (s == NULL)
 	return FALSE;
 
@@ -3242,10 +3225,10 @@
 	 copy relocs.  */
       if (! info->shared)
 	{
-	  s = bfd_make_section_with_flags (abfd,
-					   (bed->default_use_rela_p
-					    ? ".rela.bss" : ".rel.bss"),
-					   flags | SEC_READONLY);
+	  s = bfd_make_section_anyway_with_flags (abfd,
+						  (bed->default_use_rela_p
+						   ? ".rela.bss" : ".rel.bss"),
+						  flags | SEC_READONLY);
 	  if (s == NULL
 	      || ! bfd_set_section_alignment (abfd, s, ptralign))
 	    return FALSE;
@@ -3304,7 +3287,7 @@
 	    return FALSE;
 	}
 
-      s = bfd_get_section_by_name (dynobj, ".plt");
+      s = bfd_get_linker_section (dynobj, ".plt");
       BFD_ASSERT (s != NULL);
 
       /* If this is the first .plt entry, make room for the special
@@ -3332,13 +3315,13 @@
       /* We also need to make an entry in the .got.plt section, which
 	 will be placed in the .got section by the linker script.  */
 
-      s = bfd_get_section_by_name (dynobj, ".got.plt");
+      s = bfd_get_linker_section (dynobj, ".got.plt");
       BFD_ASSERT (s != NULL);
       s->size += 8;
 
       /* We also need to make an entry in the .rela.plt section.  */
 
-      s = bfd_get_section_by_name (dynobj, ".rela.plt");
+      s = bfd_get_linker_section (dynobj, ".rela.plt");
       BFD_ASSERT (s != NULL);
       s->size += sizeof (Elf64_External_Rela);
 
@@ -3372,13 +3355,6 @@
   if (!h->non_got_ref)
     return TRUE;
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-			     h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -3389,18 +3365,18 @@
      both the dynamic object and the regular object will refer to the
      same memory location for the variable.  */
 
-  s = bfd_get_section_by_name (dynobj, ".dynbss");
+  s = bfd_get_linker_section (dynobj, ".dynbss");
   BFD_ASSERT (s != NULL);
 
   /* We must generate a R_SH_COPY reloc to tell the dynamic linker to
      copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rela.bss section we are going to use.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       asection *srel;
 
-      srel = bfd_get_section_by_name (dynobj, ".rela.bss");
+      srel = bfd_get_linker_section (dynobj, ".rela.bss");
       BFD_ASSERT (srel != NULL);
       srel->size += sizeof (Elf64_External_Rela);
       h->needs_copy = 1;
@@ -3452,7 +3428,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
@@ -3465,7 +3441,7 @@
 	 not actually use these entries.  Reset the size of .rela.got,
 	 which will cause it to get stripped from the output file
 	 below.  */
-      s = bfd_get_section_by_name (dynobj, ".rela.got");
+      s = bfd_get_linker_section (dynobj, ".rela.got");
       if (s != NULL)
 	s->size = 0;
     }
@@ -3634,9 +3610,9 @@
 
       BFD_ASSERT (h->dynindx != -1);
 
-      splt = bfd_get_section_by_name (dynobj, ".plt");
-      sgot = bfd_get_section_by_name (dynobj, ".got.plt");
-      srel = bfd_get_section_by_name (dynobj, ".rela.plt");
+      splt = bfd_get_linker_section (dynobj, ".plt");
+      sgot = bfd_get_linker_section (dynobj, ".got.plt");
+      srel = bfd_get_linker_section (dynobj, ".rela.plt");
       BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
 
       /* Get the index in the procedure linkage table which
@@ -3737,8 +3713,8 @@
       /* This symbol has an entry in the global offset table.  Set it
 	 up.  */
 
-      sgot = bfd_get_section_by_name (dynobj, ".got");
-      srel = bfd_get_section_by_name (dynobj, ".rela.got");
+      sgot = bfd_get_linker_section (dynobj, ".got");
+      srel = bfd_get_linker_section (dynobj, ".rela.got");
       BFD_ASSERT (sgot != NULL && srel != NULL);
 
       rel.r_offset = (sgot->output_section->vma
@@ -3783,8 +3759,7 @@
 		  && (h->root.type == bfd_link_hash_defined
 		      || h->root.type == bfd_link_hash_defweak));
 
-      s = bfd_get_section_by_name (h->root.u.def.section->owner,
-				   ".rela.bss");
+      s = bfd_get_linker_section (dynobj, ".rela.bss");
       BFD_ASSERT (s != NULL);
 
       rel.r_offset = (h->root.u.def.value
@@ -3798,7 +3773,7 @@
     }
 
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+  if (h == elf_hash_table (info)->hdynamic
       || h == elf_hash_table (info)->hgot)
     sym->st_shndx = SHN_ABS;
 
@@ -3817,9 +3792,9 @@
 
   dynobj = elf_hash_table (info)->dynobj;
 
-  sgot = bfd_get_section_by_name (dynobj, ".got.plt");
+  sgot = bfd_get_linker_section (dynobj, ".got.plt");
   BFD_ASSERT (sgot != NULL);
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (elf_hash_table (info)->dynamic_sections_created)
     {
@@ -3902,7 +3877,7 @@
 	}
 
       /* Fill in the first entry in the procedure linkage table.  */
-      splt = bfd_get_section_by_name (dynobj, ".plt");
+      splt = bfd_get_linker_section (dynobj, ".plt");
       if (splt && splt->size > 0)
 	{
 	  if (info->shared)
diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c
index f5bfe75..65e3907 100644
--- a/bfd/elf64-sparc.c
+++ b/bfd/elf64-sparc.c
@@ -1,6 +1,6 @@
 /* SPARC-specific support for 64-bit ELF
    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -57,7 +57,7 @@
 				   Elf_Internal_Shdr *rel_hdr,
 				   asymbol **symbols, bfd_boolean dynamic)
 {
-  PTR allocated = NULL;
+  void * allocated = NULL;
   bfd_byte *native_relocs;
   arelent *relent;
   unsigned int i;
@@ -65,7 +65,7 @@
   bfd_size_type count;
   arelent *relents;
 
-  allocated = (PTR) bfd_malloc (rel_hdr->sh_size);
+  allocated = bfd_malloc (rel_hdr->sh_size);
   if (allocated == NULL)
     goto error_return;
 
@@ -279,7 +279,7 @@
 /* Write out the relocs.  */
 
 static void
-elf64_sparc_write_relocs (bfd *abfd, asection *sec, PTR data)
+elf64_sparc_write_relocs (bfd *abfd, asection *sec, void * data)
 {
   bfd_boolean *failedp = (bfd_boolean *) data;
   Elf_Internal_Shdr *rela_hdr;
@@ -330,7 +330,7 @@
   rela_hdr = elf_section_data (sec)->rela.hdr;
 
   rela_hdr->sh_size = rela_hdr->sh_entsize * count;
-  rela_hdr->contents = (PTR) bfd_alloc (abfd, rela_hdr->sh_size);
+  rela_hdr->contents = bfd_alloc (abfd, rela_hdr->sh_size);
   if (rela_hdr->contents == NULL)
     {
       *failedp = TRUE;
@@ -545,8 +545,8 @@
 static bfd_boolean
 elf64_sparc_output_arch_syms (bfd *output_bfd ATTRIBUTE_UNUSED,
 			      struct bfd_link_info *info,
-			      PTR finfo,
-			      int (*func) (PTR, const char *,
+			      void * flaginfo,
+			      int (*func) (void *, const char *,
 					   Elf_Internal_Sym *,
 					   asection *,
 					   struct elf_link_hash_entry *))
@@ -563,7 +563,7 @@
   if (elf_hash_table (info)->dynlocal)
     {
       bfd * dynobj = elf_hash_table (info)->dynobj;
-      asection *dynsymsec = bfd_get_section_by_name (dynobj, ".dynsym");
+      asection *dynsymsec = bfd_get_linker_section (dynobj, ".dynsym");
       struct elf_link_local_dynamic_entry *e;
 
       for (e = elf_hash_table (info)->dynlocal; e ; e = e->next)
@@ -594,7 +594,7 @@
 	sym.st_info = ELF_ST_INFO (app_regs [reg].bind, STT_REGISTER);
 	sym.st_shndx = app_regs [reg].shndx;
 	sym.st_target_internal = 0;
-	if ((*func) (finfo, app_regs [reg].name, &sym,
+	if ((*func) (flaginfo, app_regs [reg].name, &sym,
 		     sym.st_shndx == SHN_ABS
 		     ? bfd_abs_section_ptr : bfd_und_section_ptr,
 		     NULL) != 1)
@@ -741,7 +741,7 @@
 /* Print a STT_REGISTER symbol to file FILE.  */
 
 static const char *
-elf64_sparc_print_symbol_all (bfd *abfd ATTRIBUTE_UNUSED, PTR filep,
+elf64_sparc_print_symbol_all (bfd *abfd ATTRIBUTE_UNUSED, void * filep,
 			      asymbol *symbol)
 {
   FILE *file = (FILE *) filep;
@@ -765,7 +765,9 @@
 }
 
 static enum elf_reloc_type_class
-elf64_sparc_reloc_type_class (const Elf_Internal_Rela *rela)
+elf64_sparc_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			      const asection *rel_sec ATTRIBUTE_UNUSED,
+			      const Elf_Internal_Rela *rela)
 {
   switch ((int) ELF64_R_TYPE (rela->r_info))
     {
diff --git a/bfd/elf64-tilegx.c b/bfd/elf64-tilegx.c
index e30ca80..1043346 100644
--- a/bfd/elf64-tilegx.c
+++ b/bfd/elf64-tilegx.c
@@ -38,11 +38,11 @@
     return FALSE;
 
   /* pr_cursig */
-  elf_tdata (abfd)->core_signal =
+  elf_tdata (abfd)->core->signal =
     bfd_get_16 (abfd, note->descdata + TILEGX_PRSTATUS_OFFSET_PR_CURSIG);
 
   /* pr_pid */
-  elf_tdata (abfd)->core_pid =
+  elf_tdata (abfd)->core->pid =
     bfd_get_32 (abfd, note->descdata + TILEGX_PRSTATUS_OFFSET_PR_PID);
 
   /* pr_reg */
@@ -60,9 +60,9 @@
   if (note->descsz != TILEGX_PRPSINFO_SIZEOF)
     return FALSE;
 
-  elf_tdata (abfd)->core_program
+  elf_tdata (abfd)->core->program
     = _bfd_elfcore_strndup (abfd, note->descdata + TILEGX_PRPSINFO_OFFSET_PR_FNAME, 16);
-  elf_tdata (abfd)->core_command
+  elf_tdata (abfd)->core->command
     = _bfd_elfcore_strndup (abfd, note->descdata + TILEGX_PRPSINFO_OFFSET_PR_PSARGS, ELF_PR_PSARGS_SIZE);
 
 
@@ -70,7 +70,7 @@
      onto the end of the args in some (at least one anyway)
      implementations, so strip it off if it exists.  */
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
@@ -87,8 +87,11 @@
 #define ELF_MAXPAGESIZE		0x10000
 #define ELF_COMMONPAGESIZE	0x10000
 
-#define TARGET_LITTLE_SYM       bfd_elf64_tilegx_vec
-#define TARGET_LITTLE_NAME	"elf64-tilegx"
+
+#define TARGET_BIG_SYM          bfd_elf64_tilegx_be_vec
+#define TARGET_BIG_NAME         "elf64-tilegx-be"
+#define TARGET_LITTLE_SYM       bfd_elf64_tilegx_le_vec
+#define TARGET_LITTLE_NAME      "elf64-tilegx-le"
 
 #define elf_backend_reloc_type_class	     tilegx_reloc_type_class
 
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index ca7df35..d621689 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -1,6 +1,6 @@
 /* X86-64 specific support for ELF
    Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-   2010, 2011
+   2010, 2011, 2012, 2013
    Free Software Foundation, Inc.
    Contributed by Jan Hubicka <[email protected]>.
 
@@ -26,6 +26,7 @@
 #include "bfdlink.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
+#include "elf-nacl.h"
 #include "bfd_stdint.h"
 #include "objalloc.h"
 #include "hashtab.h"
@@ -147,8 +148,12 @@
   HOWTO(R_X86_64_PLTOFF64, 0, 4, 64, FALSE, 0, complain_overflow_signed,
 	bfd_elf_generic_reloc, "R_X86_64_PLTOFF64", FALSE, MINUS_ONE,
 	MINUS_ONE, FALSE),
-  EMPTY_HOWTO (32),
-  EMPTY_HOWTO (33),
+  HOWTO(R_X86_64_SIZE32, 0, 2, 32, FALSE, 0, complain_overflow_unsigned,
+	bfd_elf_generic_reloc, "R_X86_64_SIZE32", FALSE, 0xffffffff, 0xffffffff,
+	FALSE),
+  HOWTO(R_X86_64_SIZE64, 0, 4, 64, FALSE, 0, complain_overflow_unsigned,
+	bfd_elf_generic_reloc, "R_X86_64_SIZE64", FALSE, MINUS_ONE, MINUS_ONE,
+	FALSE),
   HOWTO(R_X86_64_GOTPC32_TLSDESC, 0, 2, 32, TRUE, 0,
 	complain_overflow_bitfield, bfd_elf_generic_reloc,
 	"R_X86_64_GOTPC32_TLSDESC",
@@ -167,12 +172,18 @@
   HOWTO(R_X86_64_RELATIVE64, 0, 4, 64, FALSE, 0, complain_overflow_bitfield,
 	bfd_elf_generic_reloc, "R_X86_64_RELATIVE64", FALSE, MINUS_ONE,
 	MINUS_ONE, FALSE),
+  HOWTO(R_X86_64_PC32_BND, 0, 2, 32, TRUE, 0, complain_overflow_signed,
+	bfd_elf_generic_reloc, "R_X86_64_PC32_BND", FALSE, 0xffffffff, 0xffffffff,
+	TRUE),
+  HOWTO(R_X86_64_PLT32_BND, 0, 2, 32, TRUE, 0, complain_overflow_signed,
+	bfd_elf_generic_reloc, "R_X86_64_PLT32_BND", FALSE, 0xffffffff, 0xffffffff,
+	TRUE),
 
   /* We have a gap in the reloc numbers here.
      R_X86_64_standard counts the number up to this point, and
      R_X86_64_vt_offset is the value to subtract from a reloc type of
      R_X86_64_GNU_VT* to form an index into this table.  */
-#define R_X86_64_standard (R_X86_64_IRELATIVE + 1)
+#define R_X86_64_standard (R_X86_64_PLT32_BND + 1)
 #define R_X86_64_vt_offset (R_X86_64_GNU_VTINHERIT - R_X86_64_standard)
 
 /* GNU extension to record C++ vtable hierarchy.  */
@@ -194,6 +205,7 @@
   (   ((TYPE) == R_X86_64_PC8)		\
    || ((TYPE) == R_X86_64_PC16)		\
    || ((TYPE) == R_X86_64_PC32)		\
+   || ((TYPE) == R_X86_64_PC32_BND)	\
    || ((TYPE) == R_X86_64_PC64))
 
 /* Map BFD relocs to the x86_64 elf relocs.  */
@@ -237,10 +249,14 @@
   { BFD_RELOC_X86_64_GOTPC64,	R_X86_64_GOTPC64, },
   { BFD_RELOC_X86_64_GOTPLT64,	R_X86_64_GOTPLT64, },
   { BFD_RELOC_X86_64_PLTOFF64,	R_X86_64_PLTOFF64, },
+  { BFD_RELOC_SIZE32,		R_X86_64_SIZE32, },
+  { BFD_RELOC_SIZE64,		R_X86_64_SIZE64, },
   { BFD_RELOC_X86_64_GOTPC32_TLSDESC, R_X86_64_GOTPC32_TLSDESC, },
   { BFD_RELOC_X86_64_TLSDESC_CALL, R_X86_64_TLSDESC_CALL, },
   { BFD_RELOC_X86_64_TLSDESC,	R_X86_64_TLSDESC, },
   { BFD_RELOC_X86_64_IRELATIVE,	R_X86_64_IRELATIVE, },
+  { BFD_RELOC_X86_64_PC32_BND,	R_X86_64_PC32_BND,},
+  { BFD_RELOC_X86_64_PLT32_BND,	R_X86_64_PLT32_BND,},
   { BFD_RELOC_VTABLE_INHERIT,	R_X86_64_GNU_VTINHERIT, },
   { BFD_RELOC_VTABLE_ENTRY,	R_X86_64_GNU_VTENTRY, },
 };
@@ -341,10 +357,10 @@
 
       case 296:		/* sizeof(istruct elf_prstatus) on Linux/x32 */
 	/* pr_cursig */
-	elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+	elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
 
 	/* pr_pid */
-	elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
+	elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
 
 	/* pr_reg */
 	offset = 72;
@@ -354,11 +370,11 @@
 
       case 336:		/* sizeof(istruct elf_prstatus) on Linux/x86_64 */
 	/* pr_cursig */
-	elf_tdata (abfd)->core_signal
+	elf_tdata (abfd)->core->signal
 	  = bfd_get_16 (abfd, note->descdata + 12);
 
 	/* pr_pid */
-	elf_tdata (abfd)->core_lwpid
+	elf_tdata (abfd)->core->lwpid
 	  = bfd_get_32 (abfd, note->descdata + 32);
 
 	/* pr_reg */
@@ -382,20 +398,20 @@
 	return FALSE;
 
       case 124:		/* sizeof(struct elf_prpsinfo) on Linux/x32 */
-	elf_tdata (abfd)->core_pid
+	elf_tdata (abfd)->core->pid
 	  = bfd_get_32 (abfd, note->descdata + 12);
-	elf_tdata (abfd)->core_program
+	elf_tdata (abfd)->core->program
 	  = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
-	elf_tdata (abfd)->core_command
+	elf_tdata (abfd)->core->command
 	  = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
 	break;
 
       case 136:		/* sizeof(struct elf_prpsinfo) on Linux/x86_64 */
-	elf_tdata (abfd)->core_pid
+	elf_tdata (abfd)->core->pid
 	  = bfd_get_32 (abfd, note->descdata + 24);
-	elf_tdata (abfd)->core_program
+	elf_tdata (abfd)->core->program
 	 = _bfd_elfcore_strndup (abfd, note->descdata + 40, 16);
-	elf_tdata (abfd)->core_command
+	elf_tdata (abfd)->core->command
 	 = _bfd_elfcore_strndup (abfd, note->descdata + 56, 80);
     }
 
@@ -404,7 +420,7 @@
      implementations, so strip it off if it exists.  */
 
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
@@ -420,8 +436,6 @@
 			    int note_type, ...)
 {
   const struct elf_backend_data *bed = get_elf_backend_data (abfd);
-  const void *p;
-  int size;
   va_list ap;
   const char *fname, *psargs;
   long pid;
@@ -445,19 +459,19 @@
 	  memset (&data, 0, sizeof (data));
 	  strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
 	  strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
-	  p = (const void *) &data;
-	  size = sizeof (data);
+	  return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type,
+				     &data, sizeof (data));
 	}
       else
 	{
-	  prpsinfo_t data;
+	  prpsinfo64_t data;
 	  memset (&data, 0, sizeof (data));
 	  strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
 	  strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
-	  p = (const void *) &data;
-	  size = sizeof (data);
+	  return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type,
+				     &data, sizeof (data));
 	}
-      break;
+      /* NOTREACHED */
 
     case NT_PRSTATUS:
       va_start (ap, note_type);
@@ -475,8 +489,8 @@
 	      prstat.pr_pid = pid;
 	      prstat.pr_cursig = cursig;
 	      memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
-	      p = (const void *) &prstat;
-	      size = sizeof (prstat);
+	      return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type,
+					 &prstat, sizeof (prstat));
 	    }
 	  else
 	    {
@@ -485,25 +499,22 @@
 	      prstat.pr_pid = pid;
 	      prstat.pr_cursig = cursig;
 	      memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
-	      p = (const void *) &prstat;
-	      size = sizeof (prstat);
+	      return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type,
+					 &prstat, sizeof (prstat));
 	    }
 	}
       else
 	{
-	  prstatus_t prstat;
+	  prstatus64_t prstat;
 	  memset (&prstat, 0, sizeof (prstat));
 	  prstat.pr_pid = pid;
 	  prstat.pr_cursig = cursig;
 	  memcpy (&prstat.pr_reg, gregs, sizeof (prstat.pr_reg));
-	  p = (const void *) &prstat;
-	  size = sizeof (prstat);
+	  return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type,
+				     &prstat, sizeof (prstat));
 	}
-      break;
     }
-
-  return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type, p,
-			     size);
+  /* NOTREACHED */
 }
 #endif
 
@@ -513,7 +524,7 @@
    section.  */
 
 #define ELF64_DYNAMIC_INTERPRETER "/lib/ld64.so.1"
-#define ELF32_DYNAMIC_INTERPRETER "/lib/ld32.so.1"
+#define ELF32_DYNAMIC_INTERPRETER "/lib/ldx32.so.1"
 
 /* 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
@@ -590,6 +601,72 @@
   DW_CFA_nop, DW_CFA_nop, DW_CFA_nop, DW_CFA_nop
 };
 
+/* Architecture-specific backend data for x86-64.  */
+
+struct elf_x86_64_backend_data
+{
+  /* Templates for the initial PLT entry and for subsequent entries.  */
+  const bfd_byte *plt0_entry;
+  const bfd_byte *plt_entry;
+  unsigned int plt_entry_size;          /* Size of each PLT entry.  */
+
+  /* Offsets into plt0_entry that are to be replaced with GOT[1] and GOT[2].  */
+  unsigned int plt0_got1_offset;
+  unsigned int plt0_got2_offset;
+
+  /* Offset of the end of the PC-relative instruction containing
+     plt0_got2_offset.  */
+  unsigned int plt0_got2_insn_end;
+
+  /* Offsets into plt_entry that are to be replaced with...  */
+  unsigned int plt_got_offset;    /* ... address of this symbol in .got. */
+  unsigned int plt_reloc_offset;  /* ... offset into relocation table. */
+  unsigned int plt_plt_offset;    /* ... offset to start of .plt. */
+
+  /* Length of the PC-relative instruction containing plt_got_offset.  */
+  unsigned int plt_got_insn_size;
+
+  /* Offset of the end of the PC-relative jump to plt0_entry.  */
+  unsigned int plt_plt_insn_end;
+
+  /* Offset into plt_entry where the initial value of the GOT entry points.  */
+  unsigned int plt_lazy_offset;
+
+  /* .eh_frame covering the .plt section.  */
+  const bfd_byte *eh_frame_plt;
+  unsigned int eh_frame_plt_size;
+};
+
+#define get_elf_x86_64_arch_data(bed) \
+  ((const struct elf_x86_64_backend_data *) (bed)->arch_data)
+
+#define get_elf_x86_64_backend_data(abfd) \
+  get_elf_x86_64_arch_data (get_elf_backend_data (abfd))
+
+#define GET_PLT_ENTRY_SIZE(abfd) \
+  get_elf_x86_64_backend_data (abfd)->plt_entry_size
+
+/* These are the standard parameters.  */
+static const struct elf_x86_64_backend_data elf_x86_64_arch_bed =
+  {
+    elf_x86_64_plt0_entry,              /* plt0_entry */
+    elf_x86_64_plt_entry,               /* plt_entry */
+    sizeof (elf_x86_64_plt_entry),      /* plt_entry_size */
+    2,                                  /* plt0_got1_offset */
+    8,                                  /* plt0_got2_offset */
+    12,                                 /* plt0_got2_insn_end */
+    2,                                  /* plt_got_offset */
+    7,                                  /* plt_reloc_offset */
+    12,                                 /* plt_plt_offset */
+    6,                                  /* plt_got_insn_size */
+    PLT_ENTRY_SIZE,                     /* plt_plt_insn_end */
+    6,                                  /* plt_lazy_offset */
+    elf_x86_64_eh_frame_plt,            /* eh_frame_plt */
+    sizeof (elf_x86_64_eh_frame_plt),   /* eh_frame_plt_size */
+  };
+
+#define	elf_backend_arch_data	&elf_x86_64_arch_bed
+
 /* x86-64 ELF linker hash entry.  */
 
 struct elf_x86_64_link_hash_entry
@@ -698,6 +775,11 @@
   /* The offset into sgot of the GOT entry used by the PLT entry
      above.  */
   bfd_vma tlsdesc_got;
+
+  /* The index of the next R_X86_64_JUMP_SLOT entry in .rela.plt.  */
+  bfd_vma next_jump_slot_index;
+  /* The index of the next R_X86_64_IRELATIVE entry in .rela.plt.  */
+  bfd_vma next_irelative_index;
 };
 
 /* Get the x86-64 ELF linker hash table from a link_info structure.  */
@@ -721,8 +803,8 @@
   if (entry == NULL)
     {
       entry = (struct bfd_hash_entry *)
-          bfd_hash_allocate (table,
-                             sizeof (struct elf_x86_64_link_hash_entry));
+	  bfd_hash_allocate (table,
+			     sizeof (struct elf_x86_64_link_hash_entry));
       if (entry == NULL)
 	return entry;
     }
@@ -817,7 +899,7 @@
   struct elf_x86_64_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_x86_64_link_hash_table);
 
-  ret = (struct elf_x86_64_link_hash_table *) bfd_malloc (amt);
+  ret = (struct elf_x86_64_link_hash_table *) bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
 
@@ -830,16 +912,6 @@
       return NULL;
     }
 
-  ret->sdynbss = NULL;
-  ret->srelbss = NULL;
-  ret->plt_eh_frame = NULL;
-  ret->sym_cache.abfd = NULL;
-  ret->tlsdesc_plt = 0;
-  ret->tlsdesc_got = 0;
-  ret->tls_ld_got.refcount = 0;
-  ret->sgotplt_jump_table_size = 0;
-  ret->tls_module_base = NULL;
-
   if (ABI_64_P (abfd))
     {
       ret->r_info = elf64_r_info;
@@ -883,7 +955,7 @@
     htab_delete (htab->loc_hash_table);
   if (htab->loc_hash_memory)
     objalloc_free ((struct objalloc *) htab->loc_hash_memory);
-  _bfd_generic_link_hash_table_free (hash);
+  _bfd_elf_link_hash_table_free (hash);
 }
 
 /* Create .plt, .rela.plt, .got, .got.plt, .rela.got, .dynbss, and
@@ -903,31 +975,26 @@
   if (htab == NULL)
     return FALSE;
 
-  htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
+  htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
   if (!info->shared)
-    htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
+    htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
 
   if (!htab->sdynbss
       || (!info->shared && !htab->srelbss))
     abort ();
 
   if (!info->no_ld_generated_unwind_info
-      && bfd_get_section_by_name (dynobj, ".eh_frame") == NULL
+      && htab->plt_eh_frame == NULL
       && htab->elf.splt != NULL)
     {
-      flagword flags = get_elf_backend_data (dynobj)->dynamic_sec_flags;
+      flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_READONLY
+			| SEC_HAS_CONTENTS | SEC_IN_MEMORY
+			| SEC_LINKER_CREATED);
       htab->plt_eh_frame
-	= bfd_make_section_with_flags (dynobj, ".eh_frame",
-				       flags | SEC_READONLY);
+	= bfd_make_section_anyway_with_flags (dynobj, ".eh_frame", flags);
       if (htab->plt_eh_frame == NULL
 	  || !bfd_set_section_alignment (dynobj, htab->plt_eh_frame, 3))
 	return FALSE;
-
-      htab->plt_eh_frame->size = sizeof (elf_x86_64_eh_frame_plt);
-      htab->plt_eh_frame->contents
-	= bfd_alloc (dynobj, htab->plt_eh_frame->size);
-      memcpy (htab->plt_eh_frame->contents, elf_x86_64_eh_frame_plt,
-	      sizeof (elf_x86_64_eh_frame_plt));
     }
   return TRUE;
 }
@@ -1007,6 +1074,14 @@
   return TRUE;
 }
 
+static bfd_boolean
+elf32_x86_64_elf_object_p (bfd *abfd)
+{
+  /* Set the right machine number for an x86-64 elf32 file.  */
+  bfd_default_set_arch_mach (abfd, bfd_arch_i386, bfd_mach_x64_32);
+  return TRUE;
+}
+
 /* Return TRUE if the TLS access code sequence support transition
    from R_TYPE.  */
 
@@ -1023,6 +1098,7 @@
 {
   unsigned int val;
   unsigned long r_symndx;
+  bfd_boolean largepic = FALSE;
   struct elf_link_hash_entry *h;
   bfd_vma offset;
   struct elf_x86_64_link_hash_table *htab;
@@ -1060,16 +1136,32 @@
 	     can transit to different access model.  For 32bit, only
 		leaq foo@tlsgd(%rip), %rdi
 		.word 0x6666; rex64; call __tls_get_addr
-	     can transit to different access model.  */
+	     can transit to different access model.  For largepic
+	     we also support:
+	        leaq foo@tlsgd(%rip), %rdi
+	        movabsq $__tls_get_addr@pltoff, %rax
+	        addq $rbx, %rax
+	        call *%rax.  */
 
 	  static const unsigned char call[] = { 0x66, 0x66, 0x48, 0xe8 };
 	  static const unsigned char leaq[] = { 0x66, 0x48, 0x8d, 0x3d };
 
-	  if ((offset + 12) > sec->size
-	      || memcmp (contents + offset + 4, call, 4) != 0)
+	  if ((offset + 12) > sec->size)
 	    return FALSE;
 
-	  if (ABI_64_P (abfd))
+	  if (memcmp (contents + offset + 4, call, 4) != 0)
+	    {
+	      if (!ABI_64_P (abfd)
+		  || (offset + 19) > sec->size
+		  || offset < 3
+		  || memcmp (contents + offset - 3, leaq + 1, 3) != 0
+		  || memcmp (contents + offset + 4, "\x48\xb8", 2) != 0
+		  || memcmp (contents + offset + 14, "\x48\x01\xd8\xff\xd0", 5)
+		     != 0)
+		return FALSE;
+	      largepic = TRUE;
+	    }
+	  else if (ABI_64_P (abfd))
 	    {
 	      if (offset < 4
 		  || memcmp (contents + offset - 4, leaq, 4) != 0)
@@ -1087,16 +1179,31 @@
 	  /* Check transition from LD access model.  Only
 		leaq foo@tlsld(%rip), %rdi;
 		call __tls_get_addr
-	     can transit to different access model.  */
+	     can transit to different access model.  For largepic
+	     we also support:
+	        leaq foo@tlsld(%rip), %rdi
+	        movabsq $__tls_get_addr@pltoff, %rax
+	        addq $rbx, %rax
+	        call *%rax.  */
 
 	  static const unsigned char lea[] = { 0x48, 0x8d, 0x3d };
 
 	  if (offset < 3 || (offset + 9) > sec->size)
 	    return FALSE;
 
-	  if (memcmp (contents + offset - 3, lea, 3) != 0
-	      || 0xe8 != *(contents + offset + 4))
+	  if (memcmp (contents + offset - 3, lea, 3) != 0)
 	    return FALSE;
+
+	  if (0xe8 != *(contents + offset + 4))
+	    {
+	      if (!ABI_64_P (abfd)
+		  || (offset + 19) > sec->size
+		  || memcmp (contents + offset + 4, "\x48\xb8", 2) != 0
+		  || memcmp (contents + offset + 14, "\x48\x01\xd8\xff\xd0", 5)
+		     != 0)
+		return FALSE;
+	      largepic = TRUE;
+	    }
 	}
 
       r_symndx = htab->r_sym (rel[1].r_info);
@@ -1105,11 +1212,13 @@
 
       h = sym_hashes[r_symndx - symtab_hdr->sh_info];
       /* Use strncmp to check __tls_get_addr since __tls_get_addr
-	 may be versioned.  */ 
+	 may be versioned.  */
       return (h != NULL
 	      && h->root.root.string != NULL
-	      && (ELF32_R_TYPE (rel[1].r_info) == R_X86_64_PC32
-		  || ELF32_R_TYPE (rel[1].r_info) == R_X86_64_PLT32)
+	      && (largepic
+		  ? ELF32_R_TYPE (rel[1].r_info) == R_X86_64_PLTOFF64
+		  : (ELF32_R_TYPE (rel[1].r_info) == R_X86_64_PC32
+		     || ELF32_R_TYPE (rel[1].r_info) == R_X86_64_PLT32))
 	      && (strncmp (h->root.root.string,
 			   "__tls_get_addr", 14) == 0));
 
@@ -1348,6 +1457,7 @@
       struct elf_link_hash_entry *h;
       Elf_Internal_Sym *isym;
       const char *name;
+      bfd_boolean size_reloc;
 
       r_symndx = htab->r_sym (rel->r_info);
       r_type = ELF32_R_TYPE (rel->r_info);
@@ -1441,8 +1551,10 @@
 	    case R_X86_64_32:
 	    case R_X86_64_64:
 	    case R_X86_64_PC32:
+	    case R_X86_64_PC32_BND:
 	    case R_X86_64_PC64:
 	    case R_X86_64_PLT32:
+	    case R_X86_64_PLT32_BND:
 	    case R_X86_64_GOTPCREL:
 	    case R_X86_64_GOTPCREL64:
 	      if (htab->elf.dynobj == NULL)
@@ -1452,82 +1564,9 @@
 	      break;
 	    }
 
-	  /* Since STT_GNU_IFUNC symbol must go through PLT, we handle
-	     it here if it is defined in a non-shared object.  */
-	  if (h->type == STT_GNU_IFUNC
-	      && h->def_regular)
-	    {
-	      /* It is referenced by a non-shared object. */
-	      h->ref_regular = 1;
-	      h->needs_plt = 1;
-
-	      /* STT_GNU_IFUNC symbol must go through PLT.  */
-	      h->plt.refcount += 1;
-
-	      /* STT_GNU_IFUNC needs dynamic sections.  */
-	      if (htab->elf.dynobj == NULL)
-		htab->elf.dynobj = abfd;
-
-	      switch (r_type)
-		{
-		default:
-		  if (h->root.root.string)
-		    name = h->root.root.string;
-		  else
-		    name = bfd_elf_sym_name (abfd, symtab_hdr, isym,
-					     NULL);
-		  (*_bfd_error_handler)
-		    (_("%B: relocation %s against STT_GNU_IFUNC "
-		       "symbol `%s' isn't handled by %s"), abfd,
-		     x86_64_elf_howto_table[r_type].name,
-		     name, __FUNCTION__);
-		  bfd_set_error (bfd_error_bad_value);
-		  return FALSE;
-
-		case R_X86_64_32:
-		  if (ABI_64_P (abfd))
-		    goto not_pointer;
-		case R_X86_64_64:
-		  h->non_got_ref = 1;
-		  h->pointer_equality_needed = 1;
-		  if (info->shared)
-		    {
-		      /* We must copy these reloc types into the output
-			 file.  Create a reloc section in dynobj and
-			 make room for this reloc.  */
-		      sreloc = _bfd_elf_create_ifunc_dyn_reloc
-			(abfd, info, sec, sreloc,
-			 &((struct elf_x86_64_link_hash_entry *) h)->dyn_relocs);
-		      if (sreloc == NULL)
-			return FALSE;
-		    }
-		  break;
-
-		case R_X86_64_32S:
-		case R_X86_64_PC32:
-		case R_X86_64_PC64:
-not_pointer:
-		  h->non_got_ref = 1;
-		  if (r_type != R_X86_64_PC32
-		      && r_type != R_X86_64_PC64)
-		    h->pointer_equality_needed = 1;
-		  break;
-
-		case R_X86_64_PLT32:
-		  break;
-
-		case R_X86_64_GOTPCREL:
-		case R_X86_64_GOTPCREL64:
-		  h->got.refcount += 1;
-		  if (htab->elf.sgot == NULL
-		      && !_bfd_elf_create_got_section (htab->elf.dynobj,
-						       info))
-		    return FALSE;
-		  break;
-		}
-
-	      continue;
-	    }
+	  /* It is referenced by a non-shared object. */
+	  h->ref_regular = 1;
+	  h->root.non_ir_ref = 1;
 	}
 
       if (! elf_x86_64_tls_transition (info, abfd, sec, NULL,
@@ -1648,6 +1687,7 @@
 		    (*_bfd_error_handler)
 		      (_("%B: '%s' accessed both as normal and thread local symbol"),
 		       abfd, name);
+		    bfd_set_error (bfd_error_bad_value);
 		    return FALSE;
 		  }
 	      }
@@ -1677,6 +1717,7 @@
 	  break;
 
 	case R_X86_64_PLT32:
+	case R_X86_64_PLT32_BND:
 	  /* This symbol requires a procedure linkage table entry.  We
 	     actually build the entry in adjust_dynamic_symbol,
 	     because this might be a case of linking PIC code which is
@@ -1703,6 +1744,11 @@
 	    }
 	  goto create_got;
 
+	case R_X86_64_SIZE32:
+	case R_X86_64_SIZE64:
+	  size_reloc = TRUE;
+	  goto do_size;
+
 	case R_X86_64_32:
 	  if (!ABI_64_P (abfd))
 	    goto pointer;
@@ -1732,6 +1778,7 @@
 	case R_X86_64_PC8:
 	case R_X86_64_PC16:
 	case R_X86_64_PC32:
+	case R_X86_64_PC32_BND:
 	case R_X86_64_PC64:
 	case R_X86_64_64:
 pointer:
@@ -1748,10 +1795,14 @@
 	      /* We may need a .plt entry if the function this reloc
 		 refers to is in a shared lib.  */
 	      h->plt.refcount += 1;
-	      if (r_type != R_X86_64_PC32 && r_type != R_X86_64_PC64)
+	      if (r_type != R_X86_64_PC32
+		  && r_type != R_X86_64_PC32_BND
+		  && r_type != R_X86_64_PC64)
 		h->pointer_equality_needed = 1;
 	    }
 
+	  size_reloc = FALSE;
+do_size:
 	  /* If we are creating a shared library, and this is a reloc
 	     against a global symbol, or a non PC relative reloc
 	     against a local symbol, then we need to copy the reloc
@@ -1852,7 +1903,8 @@
 		}
 
 	      p->count += 1;
-	      if (IS_X86_64_PCREL_TYPE (r_type))
+	      /* Count size relocation as PC-relative relocation.  */
+	      if (IS_X86_64_PCREL_TYPE (r_type) || size_reloc)
 		p->pc_count += 1;
 	    }
 	  break;
@@ -2005,7 +2057,7 @@
 	  if (h != NULL)
 	    {
 	      if (r_type == R_X86_64_GOTPLT64 && h->plt.refcount > 0)
-	        h->plt.refcount -= 1;
+		h->plt.refcount -= 1;
 	      if (h->got.refcount > 0)
 		h->got.refcount -= 1;
 	      if (h->type == STT_GNU_IFUNC)
@@ -2029,13 +2081,17 @@
 	case R_X86_64_PC8:
 	case R_X86_64_PC16:
 	case R_X86_64_PC32:
+	case R_X86_64_PC32_BND:
 	case R_X86_64_PC64:
+	case R_X86_64_SIZE32:
+	case R_X86_64_SIZE64:
 	  if (info->shared
 	      && (h == NULL || h->type != STT_GNU_IFUNC))
 	    break;
 	  /* Fall thru */
 
 	case R_X86_64_PLT32:
+	case R_X86_64_PLT32_BND:
 	case R_X86_64_PLTOFF64:
 	  if (h != NULL)
 	    {
@@ -2064,10 +2120,44 @@
 {
   struct elf_x86_64_link_hash_table *htab;
   asection *s;
+  struct elf_x86_64_link_hash_entry *eh;
+  struct elf_dyn_relocs *p;
 
   /* STT_GNU_IFUNC symbol must go through PLT. */
   if (h->type == STT_GNU_IFUNC)
     {
+      /* All local STT_GNU_IFUNC references must be treate as local
+	 calls via local PLT.  */
+      if (h->ref_regular
+	  && SYMBOL_CALLS_LOCAL (info, h))
+	{
+	  bfd_size_type pc_count = 0, count = 0;
+	  struct elf_dyn_relocs **pp;
+
+	  eh = (struct elf_x86_64_link_hash_entry *) h;
+	  for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
+	    {
+	      pc_count += p->pc_count;
+	      p->count -= p->pc_count;
+	      p->pc_count = 0;
+	      count += p->count;
+	      if (p->count == 0)
+		*pp = p->next;
+	      else
+		pp = &p->next;
+	    }
+
+	  if (pc_count || count)
+	    {
+	      h->needs_plt = 1;
+	      h->non_got_ref = 1;
+	      if (h->plt.refcount <= 0)
+		h->plt.refcount = 1;
+	      else
+		h->plt.refcount += 1;
+	    }
+	}
+
       if (h->plt.refcount <= 0)
 	{
 	  h->plt.offset = (bfd_vma) -1;
@@ -2144,9 +2234,6 @@
 
   if (ELIMINATE_COPY_RELOCS)
     {
-      struct elf_x86_64_link_hash_entry * eh;
-      struct elf_dyn_relocs *p;
-
       eh = (struct elf_x86_64_link_hash_entry *) h;
       for (p = eh->dyn_relocs; p != NULL; p = p->next)
 	{
@@ -2164,13 +2251,6 @@
 	}
     }
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-			     h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.	 There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -2188,7 +2268,7 @@
   /* We must generate a R_X86_64_COPY reloc to tell the dynamic linker
      to copy the initial value out of the dynamic object and into the
      runtime process image.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       const struct elf_backend_data *bed;
       bed = get_elf_backend_data (info->output_bfd);
@@ -2212,6 +2292,7 @@
   struct elf_x86_64_link_hash_entry *eh;
   struct elf_dyn_relocs *p;
   const struct elf_backend_data *bed;
+  unsigned int plt_entry_size;
 
   if (h->root.type == bfd_link_hash_indirect)
     return TRUE;
@@ -2223,6 +2304,7 @@
   if (htab == NULL)
     return FALSE;
   bed = get_elf_backend_data (info->output_bfd);
+  plt_entry_size = GET_PLT_ENTRY_SIZE (info->output_bfd);
 
   /* Since STT_GNU_IFUNC symbol must go through PLT, we handle it
      here if it is defined and referenced in a non-shared object.  */
@@ -2230,7 +2312,8 @@
       && h->def_regular)
     return _bfd_elf_allocate_ifunc_dyn_relocs (info, h,
 					       &eh->dyn_relocs,
-					       PLT_ENTRY_SIZE,
+					       plt_entry_size,
+					       plt_entry_size,
 					       GOT_ENTRY_SIZE);
   else if (htab->elf.dynamic_sections_created
 	   && h->plt.refcount > 0)
@@ -2252,7 +2335,7 @@
 	  /* If this is the first .plt entry, make room for the special
 	     first entry.  */
 	  if (s->size == 0)
-	    s->size += PLT_ENTRY_SIZE;
+	    s->size += plt_entry_size;
 
 	  h->plt.offset = s->size;
 
@@ -2269,7 +2352,7 @@
 	    }
 
 	  /* Make room for this entry.  */
-	  s->size += PLT_ENTRY_SIZE;
+	  s->size += plt_entry_size;
 
 	  /* We also need to make an entry in the .got.plt section, which
 	     will be placed in the .got section by the linker script.  */
@@ -2507,6 +2590,154 @@
   return TRUE;
 }
 
+/* Convert
+   mov foo@GOTPCREL(%rip), %reg
+   to
+   lea foo(%rip), %reg
+   with the local symbol, foo.  */
+
+static bfd_boolean
+elf_x86_64_convert_mov_to_lea (bfd *abfd, asection *sec,
+			       struct bfd_link_info *link_info)
+{
+  Elf_Internal_Shdr *symtab_hdr;
+  Elf_Internal_Rela *internal_relocs;
+  Elf_Internal_Rela *irel, *irelend;
+  bfd_byte *contents;
+  struct elf_x86_64_link_hash_table *htab;
+  bfd_boolean changed_contents;
+  bfd_boolean changed_relocs;
+  bfd_signed_vma *local_got_refcounts;
+
+  /* Don't even try to convert non-ELF outputs.  */
+  if (!is_elf_hash_table (link_info->hash))
+    return FALSE;
+
+  /* Nothing to do if there are no codes, no relocations or no output.  */
+  if ((sec->flags & (SEC_CODE | SEC_RELOC)) != (SEC_CODE | SEC_RELOC)
+      || sec->reloc_count == 0
+      || discarded_section (sec))
+    return TRUE;
+
+  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+
+  /* Load the relocations for this section.  */
+  internal_relocs = (_bfd_elf_link_read_relocs
+		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
+		      link_info->keep_memory));
+  if (internal_relocs == NULL)
+    return FALSE;
+
+  htab = elf_x86_64_hash_table (link_info);
+  changed_contents = FALSE;
+  changed_relocs = FALSE;
+  local_got_refcounts = elf_local_got_refcounts (abfd);
+
+  /* Get the section contents.  */
+  if (elf_section_data (sec)->this_hdr.contents != NULL)
+    contents = elf_section_data (sec)->this_hdr.contents;
+  else
+    {
+      if (!bfd_malloc_and_get_section (abfd, sec, &contents))
+	goto error_return;
+    }
+
+  irelend = internal_relocs + sec->reloc_count;
+  for (irel = internal_relocs; irel < irelend; irel++)
+    {
+      unsigned int r_type = ELF32_R_TYPE (irel->r_info);
+      unsigned int r_symndx = htab->r_sym (irel->r_info);
+      unsigned int indx;
+      struct elf_link_hash_entry *h;
+
+      if (r_type != R_X86_64_GOTPCREL)
+	continue;
+
+      /* Get the symbol referred to by the reloc.  */
+      if (r_symndx < symtab_hdr->sh_info)
+	{
+	  Elf_Internal_Sym *isym;
+
+	  isym = bfd_sym_from_r_symndx (&htab->sym_cache,
+					abfd, r_symndx);
+
+	  /* STT_GNU_IFUNC must keep R_X86_64_GOTPCREL relocation.  */
+	  if (ELF_ST_TYPE (isym->st_info) != STT_GNU_IFUNC
+	      && bfd_get_8 (input_bfd,
+			    contents + irel->r_offset - 2) == 0x8b)
+	    {
+	      bfd_put_8 (output_bfd, 0x8d,
+			 contents + irel->r_offset - 2);
+	      irel->r_info = htab->r_info (r_symndx, R_X86_64_PC32);
+	      if (local_got_refcounts != NULL
+		  && local_got_refcounts[r_symndx] > 0)
+		local_got_refcounts[r_symndx] -= 1;
+	      changed_contents = TRUE;
+	      changed_relocs = TRUE;
+	    }
+	  continue;
+	}
+
+      indx = r_symndx - symtab_hdr->sh_info;
+      h = elf_sym_hashes (abfd)[indx];
+      BFD_ASSERT (h != NULL);
+
+      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;
+
+      /* STT_GNU_IFUNC must keep R_X86_64_GOTPCREL relocation.  We also
+	 avoid optimizing _DYNAMIC since ld.so may use its link-time
+	 address.  */
+      if (h->def_regular
+	  && h->type != STT_GNU_IFUNC
+	  && h != htab->elf.hdynamic
+	  && SYMBOL_REFERENCES_LOCAL (link_info, h)
+	  && bfd_get_8 (input_bfd,
+			contents + irel->r_offset - 2) == 0x8b)
+	{
+	  bfd_put_8 (output_bfd, 0x8d,
+		     contents + irel->r_offset - 2);
+	  irel->r_info = htab->r_info (r_symndx, R_X86_64_PC32);
+	  if (h->got.refcount > 0)
+	    h->got.refcount -= 1;
+	  changed_contents = TRUE;
+	  changed_relocs = TRUE;
+	}
+    }
+
+  if (contents != NULL
+      && elf_section_data (sec)->this_hdr.contents != contents)
+    {
+      if (!changed_contents && !link_info->keep_memory)
+	free (contents);
+      else
+	{
+	  /* Cache the section contents for elf_link_input_bfd.  */
+	  elf_section_data (sec)->this_hdr.contents = contents;
+	}
+    }
+
+  if (elf_section_data (sec)->relocs != internal_relocs)
+    {
+      if (!changed_relocs)
+	free (internal_relocs);
+      else
+	elf_section_data (sec)->relocs = internal_relocs;
+    }
+
+  return TRUE;
+
+ error_return:
+  if (contents != NULL
+      && elf_section_data (sec)->this_hdr.contents != contents)
+    free (contents);
+  if (internal_relocs != NULL
+      && elf_section_data (sec)->relocs != internal_relocs)
+    free (internal_relocs);
+  return FALSE;
+}
+
 /* Set the sizes of the dynamic sections.  */
 
 static bfd_boolean
@@ -2534,7 +2765,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  if (s == NULL)
 	    abort ();
 	  s->size = htab->dynamic_interpreter_size;
@@ -2561,6 +2792,9 @@
 	{
 	  struct elf_dyn_relocs *p;
 
+	  if (!elf_x86_64_convert_mov_to_lea (ibfd, s, info))
+	    return FALSE;
+
 	  for (p = (struct elf_dyn_relocs *)
 		    (elf_section_data (s)->local_dynrel);
 	       p != NULL;
@@ -2667,10 +2901,18 @@
      incremented.  However, when we reserve space for TLS descriptors,
      it's not incremented, so in order to compute the space reserved
      for them, it suffices to multiply the reloc count by the jump
-     slot size.  */
+     slot size.
+
+     PR ld/13302: We start next_irelative_index at the end of .rela.plt
+     so that R_X86_64_IRELATIVE entries come last.  */
   if (htab->elf.srelplt)
-    htab->sgotplt_jump_table_size
-      = elf_x86_64_compute_jump_table_size (htab);
+    {
+      htab->sgotplt_jump_table_size
+	= elf_x86_64_compute_jump_table_size (htab);
+      htab->next_irelative_index = htab->elf.srelplt->reloc_count - 1;
+    }
+  else if (htab->elf.irelplt)
+    htab->next_irelative_index = htab->elf.irelplt->reloc_count - 1;
 
   if (htab->tlsdesc_plt)
     {
@@ -2685,23 +2927,18 @@
 	  /* Reserve room for the initial entry.
 	     FIXME: we could probably do away with it in this case.  */
 	  if (htab->elf.splt->size == 0)
-	    htab->elf.splt->size += PLT_ENTRY_SIZE;
+	    htab->elf.splt->size += GET_PLT_ENTRY_SIZE (output_bfd);
 	  htab->tlsdesc_plt = htab->elf.splt->size;
-	  htab->elf.splt->size += PLT_ENTRY_SIZE;
+	  htab->elf.splt->size += GET_PLT_ENTRY_SIZE (output_bfd);
 	}
     }
 
   if (htab->elf.sgotplt)
     {
-      struct elf_link_hash_entry *got;
-      got = elf_link_hash_lookup (elf_hash_table (info),
-				  "_GLOBAL_OFFSET_TABLE_",
-				  FALSE, FALSE, FALSE);
-
       /* Don't allocate .got.plt section if there are no GOT nor PLT
-         entries and there is no refeence to _GLOBAL_OFFSET_TABLE_.  */
-      if ((got == NULL
-	   || !got->ref_regular_nonweak)
+	 entries and there is no refeence to _GLOBAL_OFFSET_TABLE_.  */
+      if ((htab->elf.hgot == NULL
+	   || !htab->elf.hgot->ref_regular_nonweak)
 	  && (htab->elf.sgotplt->size
 	      == get_elf_backend_data (output_bfd)->got_header_size)
 	  && (htab->elf.splt == NULL
@@ -2715,6 +2952,17 @@
 	htab->elf.sgotplt->size = 0;
     }
 
+  if (htab->plt_eh_frame != NULL
+      && htab->elf.splt != NULL
+      && htab->elf.splt->size != 0
+      && !bfd_is_abs_section (htab->elf.splt->output_section)
+      && _bfd_elf_eh_frame_present (info))
+    {
+      const struct elf_x86_64_backend_data *arch_data
+	= get_elf_x86_64_arch_data (bed);
+      htab->plt_eh_frame->size = arch_data->eh_frame_plt_size;
+    }
+
   /* We now have determined the sizes of the various dynamic sections.
      Allocate memory for them.  */
   relocs = FALSE;
@@ -2728,6 +2976,7 @@
 	  || s == htab->elf.sgotplt
 	  || s == htab->elf.iplt
 	  || s == htab->elf.igotplt
+	  || s == htab->plt_eh_frame
 	  || s == htab->sdynbss)
 	{
 	  /* Strip this section if we don't need it; see the
@@ -2779,11 +3028,16 @@
     }
 
   if (htab->plt_eh_frame != NULL
-      && htab->elf.splt != NULL
-      && htab->elf.splt->size != 0
-      && (htab->elf.splt->flags & SEC_EXCLUDE) == 0)
-    bfd_put_32 (dynobj, htab->elf.splt->size,
-		htab->plt_eh_frame->contents + PLT_FDE_LEN_OFFSET);
+      && htab->plt_eh_frame->contents != NULL)
+    {
+      const struct elf_x86_64_backend_data *arch_data
+	= get_elf_x86_64_arch_data (bed);
+
+      memcpy (htab->plt_eh_frame->contents,
+	      arch_data->eh_frame_plt, htab->plt_eh_frame->size);
+      bfd_put_32 (dynobj, htab->elf.splt->size,
+		  htab->plt_eh_frame->contents + PLT_FDE_LEN_OFFSET);
+    }
 
   if (htab->elf.dynamic_sections_created)
     {
@@ -2825,7 +3079,7 @@
 	  /* If any dynamic relocs apply to a read-only section,
 	     then we need a DT_TEXTREL entry.  */
 	  if ((info->flags & DF_TEXTREL) == 0)
-	    elf_link_hash_traverse (&htab->elf, 
+	    elf_link_hash_traverse (&htab->elf,
 				    elf_x86_64_readonly_dynrelocs,
 				    info);
 
@@ -2978,6 +3232,7 @@
   bfd_vma *local_tlsdesc_gotents;
   Elf_Internal_Rela *rel;
   Elf_Internal_Rela *relend;
+  const unsigned int plt_entry_size = GET_PLT_ENTRY_SIZE (info->output_bfd);
 
   BFD_ASSERT (is_x86_64_elf (input_bfd));
 
@@ -3007,20 +3262,24 @@
       bfd_reloc_status_type r;
       int tls_type;
       asection *base_got;
+      bfd_vma st_size;
 
       r_type = ELF32_R_TYPE (rel->r_info);
       if (r_type == (int) R_X86_64_GNU_VTINHERIT
 	  || r_type == (int) R_X86_64_GNU_VTENTRY)
 	continue;
 
-      if (r_type >= R_X86_64_max)
+      if (r_type >= (int) R_X86_64_standard)
 	{
+	  (*_bfd_error_handler)
+	    (_("%B: unrecognized relocation (0x%x) in section `%A'"),
+	     input_bfd, input_section, r_type);
 	  bfd_set_error (bfd_error_bad_value);
 	  return FALSE;
 	}
 
       if (r_type != (int) R_X86_64_32
-	  || ABI_64_P (output_bfd)) 
+	  || ABI_64_P (output_bfd))
 	howto = x86_64_elf_howto_table + r_type;
       else
 	howto = (x86_64_elf_howto_table
@@ -3037,6 +3296,7 @@
 
 	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym,
 						&sec, rel);
+	  st_size = sym->st_size;
 
 	  /* Relocate against local STT_GNU_IFUNC symbol.  */
 	  if (!info->relocatable
@@ -3047,7 +3307,7 @@
 	      if (h == NULL)
 		abort ();
 
-	      /* Set STT_GNU_IFUNC symbol value.  */ 
+	      /* Set STT_GNU_IFUNC symbol value.  */
 	      h->root.u.def.value = sym->st_value;
 	      h->root.u.def.section = sec;
 	    }
@@ -3060,23 +3320,32 @@
 				   r_symndx, symtab_hdr, sym_hashes,
 				   h, sec, relocation,
 				   unresolved_reloc, warned);
+	  st_size = h->size;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
 
-      if (rel->r_addend == 0
-	  && r_type == R_X86_64_64
-	  && !ABI_64_P (output_bfd))
+      if (rel->r_addend == 0 && !ABI_64_P (output_bfd))
 	{
-	  /* For x32, treat R_X86_64_64 like R_X86_64_32 and zero-extend
-	     it to 64bit if addend is zero.  */
-	  r_type = R_X86_64_32;
-	  memset (contents + rel->r_offset + 4, 0, 4);
+	  if (r_type == R_X86_64_64)
+	    {
+	      /* For x32, treat R_X86_64_64 like R_X86_64_32 and
+		 zero-extend it to 64bit if addend is zero.  */
+	      r_type = R_X86_64_32;
+	      memset (contents + rel->r_offset + 4, 0, 4);
+	    }
+	  else if (r_type == R_X86_64_SIZE64)
+	    {
+	      /* For x32, treat R_X86_64_SIZE64 like R_X86_64_SIZE32 and
+		 zero-extend it to 64bit if addend is zero.  */
+	      r_type = R_X86_64_SIZE32;
+	      memset (contents + rel->r_offset + 4, 0, 4);
+	    }
 	}
 
       /* Since STT_GNU_IFUNC symbol must go through PLT, we handle
@@ -3123,7 +3392,7 @@
 	      if (ABI_64_P (output_bfd))
 		goto do_relocation;
 	      /* FALLTHROUGH */
-	    case R_X86_64_64: 
+	    case R_X86_64_64:
 	      if (rel->r_addend != 0)
 		{
 		  if (h->root.root.string)
@@ -3141,7 +3410,7 @@
 		}
 
 	      /* Generate dynamic relcoation only when there is a
-		 non-GOF reference in a shared object.  */
+		 non-GOT reference in a shared object.  */
 	      if (info->shared && h->non_got_ref)
 		{
 		  Elf_Internal_Rela outrel;
@@ -3188,8 +3457,10 @@
 		}
 	      /* FALLTHROUGH */
 	    case R_X86_64_PC32:
+	    case R_X86_64_PC32_BND:
 	    case R_X86_64_PC64:
 	    case R_X86_64_PLT32:
+	    case R_X86_64_PLT32_BND:
 	      goto do_relocation;
 
 	    case R_X86_64_GOTPCREL:
@@ -3208,13 +3479,13 @@
 
 		  if (htab->elf.splt != NULL)
 		    {
-		      plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
+		      plt_index = h->plt.offset / plt_entry_size - 1;
 		      off = (plt_index + 3) * GOT_ENTRY_SIZE;
 		      base_got = htab->elf.sgotplt;
 		    }
 		  else
 		    {
-		      plt_index = h->plt.offset / PLT_ENTRY_SIZE;
+		      plt_index = h->plt.offset / plt_entry_size;
 		      off = plt_index * GOT_ENTRY_SIZE;
 		      base_got = htab->elf.igotplt;
 		    }
@@ -3223,9 +3494,9 @@
 		      || h->forced_local
 		      || info->symbolic)
 		    {
-		      /* This references the local defitionion.  We must 
+		      /* This references the local defitionion.  We must
 			 initialize this entry in the global offset table.
-			 Since the offset must always be a multiple of 8, 
+			 Since the offset must always be a multiple of 8,
 			 we use the least significant bit to record
 			 whether we have initialized it already.
 
@@ -3281,14 +3552,14 @@
 
 	      off = h->got.offset;
 	      if (h->needs_plt
-	          && h->plt.offset != (bfd_vma)-1
+		  && h->plt.offset != (bfd_vma)-1
 		  && off == (bfd_vma)-1)
 		{
 		  /* We can't use h->got.offset here to save
 		     state, or even just remember the offset, as
 		     finish_dynamic_symbol would use that as offset into
 		     .got.  */
-		  bfd_vma plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
+		  bfd_vma plt_index = h->plt.offset / plt_entry_size - 1;
 		  off = (plt_index + 3) * GOT_ENTRY_SIZE;
 		  base_got = htab->elf.sgotplt;
 		}
@@ -3319,7 +3590,7 @@
 		      bfd_put_64 (output_bfd, relocation,
 				  base_got->contents + off);
 		      /* Note that this is harmless for the GOTPLT64 case,
-		         as -1 | 1 still is -1.  */
+			 as -1 | 1 still is -1.  */
 		      h->got.offset |= 1;
 		    }
 		}
@@ -3384,8 +3655,9 @@
 	  /* Check to make sure it isn't a protected function symbol
 	     for shared library since it may not be local when used
 	     as function address.  */
-	  if (info->shared
+	  if (!info->executable
 	      && h
+	      && !SYMBOLIC_BIND (info, h)
 	      && h->def_regular
 	      && h->type == STT_FUNC
 	      && ELF_ST_VISIBILITY (h->other) == STV_PROTECTED)
@@ -3417,7 +3689,7 @@
 	case R_X86_64_PLTOFF64:
 	  /* Relocation is PLT entry relative to GOT.  For local
 	     symbols it's the symbol itself relative to GOT.  */
-          if (h != NULL
+	  if (h != NULL
 	      /* See PLT32 handling.  */
 	      && h->plt.offset != (bfd_vma) -1
 	      && htab->elf.splt != NULL)
@@ -3433,6 +3705,7 @@
 	  break;
 
 	case R_X86_64_PLT32:
+	case R_X86_64_PLT32_BND:
 	  /* Relocation is to the entry for this symbol in the
 	     procedure linkage table.  */
 
@@ -3456,18 +3729,25 @@
 	  unresolved_reloc = FALSE;
 	  break;
 
+	case R_X86_64_SIZE32:
+	case R_X86_64_SIZE64:
+	  /* Set to symbol size.  */
+	  relocation = st_size;
+	  goto direct;
+
 	case R_X86_64_PC8:
 	case R_X86_64_PC16:
 	case R_X86_64_PC32:
+	case R_X86_64_PC32_BND:
 	  if (info->shared
-	      && ABI_64_P (output_bfd)
 	      && (input_section->flags & SEC_ALLOC) != 0
 	      && (input_section->flags & SEC_READONLY) != 0
 	      && h != NULL)
 	    {
 	      bfd_boolean fail = FALSE;
 	      bfd_boolean branch
-		= (r_type == R_X86_64_PC32
+		= ((r_type == R_X86_64_PC32
+		    || r_type == R_X86_64_PC32_BND)
 		   && is_32bit_relative_branch (contents, rel->r_offset));
 
 	      if (SYMBOL_REFERENCES_LOCAL (info, h))
@@ -3529,6 +3809,7 @@
 	  /* FIXME: The ABI says the linker should make sure the value is
 	     the same when it's zeroextended to 64 bit.	 */
 
+direct:
 	  if ((input_section->flags & SEC_ALLOC) == 0)
 	    break;
 
@@ -3536,7 +3817,9 @@
 	       && (h == NULL
 		   || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
 		   || h->root.type != bfd_link_hash_undefweak)
-	       && (! IS_X86_64_PCREL_TYPE (r_type)
+	       && ((! IS_X86_64_PCREL_TYPE (r_type)
+		      && r_type != R_X86_64_SIZE32
+		      && r_type != R_X86_64_SIZE64)
 		   || ! SYMBOL_CALLS_LOCAL (info, h)))
 	      || (ELIMINATE_COPY_RELOCS
 		  && !info->shared
@@ -3600,6 +3883,36 @@
 		      outrel.r_info = htab->r_info (0,
 						    R_X86_64_RELATIVE64);
 		      outrel.r_addend = relocation + rel->r_addend;
+		      /* Check addend overflow.  */
+		      if ((outrel.r_addend & 0x80000000)
+			  != (rel->r_addend & 0x80000000))
+			{
+			  const char *name;
+			  int addend = rel->r_addend;
+			  if (h && h->root.root.string)
+			    name = h->root.root.string;
+			  else
+			    name = bfd_elf_sym_name (input_bfd, symtab_hdr,
+						     sym, NULL);
+			  if (addend < 0)
+			    (*_bfd_error_handler)
+			      (_("%B: addend -0x%x in relocation %s against "
+				 "symbol `%s' at 0x%lx in section `%A' is "
+				 "out of range"),
+			       input_bfd, input_section, addend,
+			       x86_64_elf_howto_table[r_type].name,
+			       name, (unsigned long) rel->r_offset);
+			  else
+			    (*_bfd_error_handler)
+			      (_("%B: addend 0x%x in relocation %s against "
+				 "symbol `%s' at 0x%lx in section `%A' is "
+				 "out of range"),
+			       input_bfd, input_section, addend,
+			       x86_64_elf_howto_table[r_type].name,
+			       name, (unsigned long) rel->r_offset);
+			  bfd_set_error (bfd_error_bad_value);
+			  return FALSE;
+			}
 		    }
 		  else
 		    {
@@ -3692,8 +4005,26 @@
 		     .word 0x6666; rex64; call __tls_get_addr
 		     into:
 		     movl %fs:0, %eax
-		     leaq foo@tpoff(%rax), %rax */
-		  if (ABI_64_P (output_bfd))
+		     leaq foo@tpoff(%rax), %rax
+		     For largepic, change:
+		     leaq foo@tlsgd(%rip), %rdi
+		     movabsq $__tls_get_addr@pltoff, %rax
+		     addq %rbx, %rax
+		     call *%rax
+		     into:
+		     movq %fs:0, %rax
+		     leaq foo@tpoff(%rax), %rax
+		     nopw 0x0(%rax,%rax,1) */
+		  int largepic = 0;
+		  if (ABI_64_P (output_bfd)
+		      && contents[roff + 5] == (bfd_byte) '\xb8')
+		    {
+		      memcpy (contents + roff - 3,
+			      "\x64\x48\x8b\x04\x25\0\0\0\0\x48\x8d\x80"
+			      "\0\0\0\0\x66\x0f\x1f\x44\0", 22);
+		      largepic = 1;
+		    }
+		  else if (ABI_64_P (output_bfd))
 		    memcpy (contents + roff - 4,
 			    "\x64\x48\x8b\x04\x25\0\0\0\0\x48\x8d\x80\0\0\0",
 			    16);
@@ -3703,8 +4034,8 @@
 			    15);
 		  bfd_put_32 (output_bfd,
 			      elf_x86_64_tpoff (info, relocation),
-			      contents + roff + 8);
-		  /* Skip R_X86_64_PC32/R_X86_64_PLT32.  */
+			      contents + roff + 8 + largepic);
+		  /* Skip R_X86_64_PC32/R_X86_64_PLT32/R_X86_64_PLTOFF64.  */
 		  rel++;
 		  continue;
 		}
@@ -3939,8 +4270,26 @@
 		     .word 0x6666; rex64; call __tls_get_addr@plt
 		     into:
 		     movl %fs:0, %eax
-		     addq foo@gottpoff(%rip), %rax */
-		  if (ABI_64_P (output_bfd))
+		     addq foo@gottpoff(%rip), %rax
+		     For largepic, change:
+		     leaq foo@tlsgd(%rip), %rdi
+		     movabsq $__tls_get_addr@pltoff, %rax
+		     addq %rbx, %rax
+		     call *%rax
+		     into:
+		     movq %fs:0, %rax
+		     addq foo@gottpoff(%rax), %rax
+		     nopw 0x0(%rax,%rax,1) */
+		  int largepic = 0;
+		  if (ABI_64_P (output_bfd)
+		      && contents[roff + 5] == (bfd_byte) '\xb8')
+		    {
+		      memcpy (contents + roff - 3,
+			      "\x64\x48\x8b\x04\x25\0\0\0\0\x48\x03\x05"
+			      "\0\0\0\0\x66\x0f\x1f\x44\0", 22);
+		      largepic = 1;
+		    }
+		  else if (ABI_64_P (output_bfd))
 		    memcpy (contents + roff - 4,
 			    "\x64\x48\x8b\x04\x25\0\0\0\0\x48\x03\x05\0\0\0",
 			    16);
@@ -3952,12 +4301,13 @@
 		  relocation = (htab->elf.sgot->output_section->vma
 				+ htab->elf.sgot->output_offset + off
 				- roff
+				- largepic
 				- input_section->output_section->vma
 				- input_section->output_offset
 				- 12);
 		  bfd_put_32 (output_bfd, relocation,
-			      contents + roff + 8);
-		  /* Skip R_X86_64_PLT32.  */
+			      contents + roff + 8 + largepic);
+		  /* Skip R_X86_64_PLT32/R_X86_64_PLTOFF64.  */
 		  rel++;
 		  continue;
 		}
@@ -4019,16 +4369,29 @@
 		 For 64bit, we change it into:
 		 .word 0x6666; .byte 0x66; movq %fs:0, %rax.
 		 For 32bit, we change it into:
-		 nopl 0x0(%rax); movl %fs:0, %eax.  */
+		 nopl 0x0(%rax); movl %fs:0, %eax.
+		 For largepic, change:
+		 leaq foo@tlsgd(%rip), %rdi
+		 movabsq $__tls_get_addr@pltoff, %rax
+		 addq %rbx, %rax
+		 call *%rax
+		 into:
+		 data32 data32 data32 nopw %cs:0x0(%rax,%rax,1)
+		 movq %fs:0, %eax */
 
 	      BFD_ASSERT (r_type == R_X86_64_TPOFF32);
-	      if (ABI_64_P (output_bfd))
+	      if (ABI_64_P (output_bfd)
+		  && contents[rel->r_offset + 5] == (bfd_byte) '\xb8')
+		memcpy (contents + rel->r_offset - 3,
+			"\x66\x66\x66\x66\x2e\x0f\x1f\x84\0\0\0\0\0"
+			"\x64\x48\x8b\x04\x25\0\0\0", 22);
+	      else if (ABI_64_P (output_bfd))
 		memcpy (contents + rel->r_offset - 3,
 			"\x66\x66\x66\x64\x48\x8b\x04\x25\0\0\0", 12);
 	      else
 		memcpy (contents + rel->r_offset - 3,
 			"\x0f\x1f\x40\x00\x64\x8b\x04\x25\0\0\0", 12);
-	      /* Skip R_X86_64_PC32/R_X86_64_PLT32.  */
+	      /* Skip R_X86_64_PC32/R_X86_64_PLT32/R_X86_64_PLTOFF64.  */
 	      rel++;
 	      continue;
 	    }
@@ -4077,6 +4440,11 @@
 	  relocation = elf_x86_64_tpoff (info, relocation);
 	  break;
 
+	case R_X86_64_DTPOFF64:
+	  BFD_ASSERT ((input_section->flags & SEC_CODE) == 0);
+	  relocation -= elf_x86_64_dtpoff_base (info);
+	  break;
+
 	default:
 	  break;
 	}
@@ -4088,14 +4456,17 @@
 	  && !((input_section->flags & SEC_DEBUGGING) != 0
 	       && h->def_dynamic)
 	  && _bfd_elf_section_offset (output_bfd, info, input_section,
-                                      rel->r_offset) != (bfd_vma) -1)
-	(*_bfd_error_handler)
-	  (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
-	   input_bfd,
-	   input_section,
-	   (long) rel->r_offset,
-	   howto->name,
-	   h->root.root.string);
+				      rel->r_offset) != (bfd_vma) -1)
+	{
+	  (*_bfd_error_handler)
+	    (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
+	     input_bfd,
+	     input_section,
+	     (long) rel->r_offset,
+	     howto->name,
+	     h->root.root.string);
+	  return FALSE;
+	}
 
 do_relocation:
       r = _bfd_final_link_relocate (howto, input_bfd, input_section,
@@ -4149,9 +4520,11 @@
 elf_x86_64_finish_dynamic_symbol (bfd *output_bfd,
 				  struct bfd_link_info *info,
 				  struct elf_link_hash_entry *h,
-				  Elf_Internal_Sym *sym)
+				  Elf_Internal_Sym *sym ATTRIBUTE_UNUSED)
 {
   struct elf_x86_64_link_hash_table *htab;
+  const struct elf_x86_64_backend_data *const abed
+    = get_elf_x86_64_backend_data (output_bfd);
 
   htab = elf_x86_64_hash_table (info);
   if (htab == NULL)
@@ -4190,7 +4563,7 @@
 	  || plt == NULL
 	  || gotplt == NULL
 	  || relplt == NULL)
-	return FALSE;
+	abort ();
 
       /* Get the index in the procedure linkage table which
 	 corresponds to this symbol.  This is the index of this symbol
@@ -4205,50 +4578,38 @@
 
       if (plt == htab->elf.splt)
 	{
-	  plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
-	  got_offset = (plt_index + 3) * GOT_ENTRY_SIZE;
+	  got_offset = h->plt.offset / abed->plt_entry_size - 1;
+	  got_offset = (got_offset + 3) * GOT_ENTRY_SIZE;
 	}
       else
 	{
-	  plt_index = h->plt.offset / PLT_ENTRY_SIZE;
-	  got_offset = plt_index * GOT_ENTRY_SIZE;
+	  got_offset = h->plt.offset / abed->plt_entry_size;
+	  got_offset = got_offset * GOT_ENTRY_SIZE;
 	}
 
       /* Fill in the entry in the procedure linkage table.  */
-      memcpy (plt->contents + h->plt.offset, elf_x86_64_plt_entry,
-	      PLT_ENTRY_SIZE);
+      memcpy (plt->contents + h->plt.offset, abed->plt_entry,
+	      abed->plt_entry_size);
 
-      /* Insert the relocation positions of the plt section.  The magic
-	 numbers at the end of the statements are the positions of the
-	 relocations in the plt section.  */
-      /* Put offset for jmp *name@GOTPCREL(%rip), since the
-	 instruction uses 6 bytes, subtract this value.  */
+      /* Insert the relocation positions of the plt section.  */
+
+      /* Put offset the PC-relative instruction referring to the GOT entry,
+	 subtracting the size of that instruction.  */
       bfd_put_32 (output_bfd,
-		      (gotplt->output_section->vma
-		       + gotplt->output_offset
-		       + got_offset
-		       - plt->output_section->vma
-		       - plt->output_offset
-		       - h->plt.offset
-		       - 6),
-		  plt->contents + h->plt.offset + 2);
-
-      /* Don't fill PLT entry for static executables.  */
-      if (plt == htab->elf.splt)
-	{
-	  /* Put relocation index.  */
-	  bfd_put_32 (output_bfd, plt_index,
-		      plt->contents + h->plt.offset + 7);
-	  /* Put offset for jmp .PLT0.  */
-	  bfd_put_32 (output_bfd, - (h->plt.offset + PLT_ENTRY_SIZE),
-		      plt->contents + h->plt.offset + 12);
-	}
+		  (gotplt->output_section->vma
+		   + gotplt->output_offset
+		   + got_offset
+		   - plt->output_section->vma
+		   - plt->output_offset
+		   - h->plt.offset
+		   - abed->plt_got_insn_size),
+		  plt->contents + h->plt.offset + abed->plt_got_offset);
 
       /* Fill in the entry in the global offset table, initially this
-	 points to the pushq instruction in the PLT which is at offset 6.  */
+	 points to the second part of the PLT entry.  */
       bfd_put_64 (output_bfd, (plt->output_section->vma
 			       + plt->output_offset
-			       + h->plt.offset + 6),
+			       + h->plt.offset + abed->plt_lazy_offset),
 		  gotplt->contents + got_offset);
 
       /* Fill in the entry in the .rela.plt section.  */
@@ -4267,11 +4628,25 @@
 	  rela.r_addend = (h->root.u.def.value
 			   + h->root.u.def.section->output_section->vma
 			   + h->root.u.def.section->output_offset);
+	  /* R_X86_64_IRELATIVE comes last.  */
+	  plt_index = htab->next_irelative_index--;
 	}
       else
 	{
 	  rela.r_info = htab->r_info (h->dynindx, R_X86_64_JUMP_SLOT);
 	  rela.r_addend = 0;
+	  plt_index = htab->next_jump_slot_index++;
+	}
+
+      /* Don't fill PLT entry for static executables.  */
+      if (plt == htab->elf.splt)
+	{
+	  /* Put relocation index.  */
+	  bfd_put_32 (output_bfd, plt_index,
+		      plt->contents + h->plt.offset + abed->plt_reloc_offset);
+	  /* Put offset for jmp .PLT0.  */
+	  bfd_put_32 (output_bfd, - (h->plt.offset + abed->plt_plt_insn_end),
+		      plt->contents + h->plt.offset + abed->plt_plt_offset);
 	}
 
       bed = get_elf_backend_data (output_bfd);
@@ -4384,13 +4759,6 @@
       elf_append_rela (output_bfd, htab->srelbss, &rela);
     }
 
-  /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  SYM may
-     be NULL for local symbols.  */
-  if (sym != NULL
-      && (strcmp (h->root.root.string, "_DYNAMIC") == 0
-	  || h == htab->elf.hgot))
-    sym->st_shndx = SHN_ABS;
-
   return TRUE;
 }
 
@@ -4403,7 +4771,7 @@
   struct elf_link_hash_entry *h
     = (struct elf_link_hash_entry *) *slot;
   struct bfd_link_info *info
-    = (struct bfd_link_info *) inf; 
+    = (struct bfd_link_info *) inf;
 
   return elf_x86_64_finish_dynamic_symbol (info->output_bfd,
 					     info, h, NULL);
@@ -4413,11 +4781,14 @@
    dynamic linker, before writing them out.  */
 
 static enum elf_reloc_type_class
-elf_x86_64_reloc_type_class (const Elf_Internal_Rela *rela)
+elf_x86_64_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			     const asection *rel_sec ATTRIBUTE_UNUSED,
+			     const Elf_Internal_Rela *rela)
 {
   switch ((int) ELF32_R_TYPE (rela->r_info))
     {
     case R_X86_64_RELATIVE:
+    case R_X86_64_RELATIVE64:
       return reloc_class_relative;
     case R_X86_64_JUMP_SLOT:
       return reloc_class_plt;
@@ -4437,13 +4808,15 @@
   struct elf_x86_64_link_hash_table *htab;
   bfd *dynobj;
   asection *sdyn;
+  const struct elf_x86_64_backend_data *const abed
+    = get_elf_x86_64_backend_data (output_bfd);
 
   htab = elf_x86_64_hash_table (info);
   if (htab == NULL)
     return FALSE;
 
   dynobj = htab->elf.dynobj;
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (htab->elf.dynamic_sections_created)
     {
@@ -4519,8 +4892,8 @@
       if (htab->elf.splt && htab->elf.splt->size > 0)
 	{
 	  /* Fill in the first entry in the procedure linkage table.  */
-	  memcpy (htab->elf.splt->contents, elf_x86_64_plt0_entry,
-		  PLT_ENTRY_SIZE);
+	  memcpy (htab->elf.splt->contents,
+		  abed->plt0_entry, abed->plt_entry_size);
 	  /* Add offset for pushq GOT+8(%rip), since the instruction
 	     uses 6 bytes subtract this value.  */
 	  bfd_put_32 (output_bfd,
@@ -4530,20 +4903,20 @@
 		       - htab->elf.splt->output_section->vma
 		       - htab->elf.splt->output_offset
 		       - 6),
-		      htab->elf.splt->contents + 2);
-	  /* Add offset for jmp *GOT+16(%rip). The 12 is the offset to
-	     the end of the instruction.  */
+		      htab->elf.splt->contents + abed->plt0_got1_offset);
+	  /* Add offset for the PC-relative instruction accessing GOT+16,
+	     subtracting the offset to the end of that instruction.  */
 	  bfd_put_32 (output_bfd,
 		      (htab->elf.sgotplt->output_section->vma
 		       + htab->elf.sgotplt->output_offset
 		       + 16
 		       - htab->elf.splt->output_section->vma
 		       - htab->elf.splt->output_offset
-		       - 12),
-		      htab->elf.splt->contents + 8);
+		       - abed->plt0_got2_insn_end),
+		      htab->elf.splt->contents + abed->plt0_got2_offset);
 
-	  elf_section_data (htab->elf.splt->output_section)->this_hdr.sh_entsize =
-	    PLT_ENTRY_SIZE;
+	  elf_section_data (htab->elf.splt->output_section)
+	    ->this_hdr.sh_entsize = abed->plt_entry_size;
 
 	  if (htab->tlsdesc_plt)
 	    {
@@ -4551,8 +4924,7 @@
 			  htab->elf.sgot->contents + htab->tlsdesc_got);
 
 	      memcpy (htab->elf.splt->contents + htab->tlsdesc_plt,
-		      elf_x86_64_plt0_entry,
-		      PLT_ENTRY_SIZE);
+		      abed->plt0_entry, abed->plt_entry_size);
 
 	      /* Add offset for pushq GOT+8(%rip), since the
 		 instruction uses 6 bytes subtract this value.  */
@@ -4564,10 +4936,11 @@
 			   - htab->elf.splt->output_offset
 			   - htab->tlsdesc_plt
 			   - 6),
-			  htab->elf.splt->contents + htab->tlsdesc_plt + 2);
-	      /* Add offset for jmp *GOT+TDG(%rip), where TGD stands for
-		 htab->tlsdesc_got. The 12 is the offset to the end of
-		 the instruction.  */
+			  htab->elf.splt->contents
+			  + htab->tlsdesc_plt + abed->plt0_got1_offset);
+	  /* Add offset for the PC-relative instruction accessing GOT+TDG,
+	     where TGD stands for htab->tlsdesc_got, subtracting the offset
+	     to the end of that instruction.  */
 	      bfd_put_32 (output_bfd,
 			  (htab->elf.sgot->output_section->vma
 			   + htab->elf.sgot->output_offset
@@ -4575,8 +4948,9 @@
 			   - htab->elf.splt->output_section->vma
 			   - htab->elf.splt->output_offset
 			   - htab->tlsdesc_plt
-			   - 12),
-			  htab->elf.splt->contents + htab->tlsdesc_plt + 8);
+			   - abed->plt0_got2_insn_end),
+			  htab->elf.splt->contents
+			  + htab->tlsdesc_plt + abed->plt0_got2_offset);
 	    }
 	}
     }
@@ -4611,7 +4985,8 @@
     }
 
   /* Adjust .eh_frame for .plt section.  */
-  if (htab->plt_eh_frame != NULL)
+  if (htab->plt_eh_frame != NULL
+      && htab->plt_eh_frame->contents != NULL)
     {
       if (htab->elf.splt != NULL
 	  && htab->elf.splt->size != 0
@@ -4627,8 +5002,7 @@
 			     htab->plt_eh_frame->contents
 			     + PLT_FDE_START_OFFSET);
 	}
-      if (htab->plt_eh_frame->sec_info_type
-	  == ELF_INFO_TYPE_EH_FRAME)
+      if (htab->plt_eh_frame->sec_info_type == SEC_INFO_TYPE_EH_FRAME)
 	{
 	  if (! _bfd_elf_write_section_eh_frame (output_bfd, info,
 						 htab->plt_eh_frame,
@@ -4656,7 +5030,7 @@
 elf_x86_64_plt_sym_val (bfd_vma i, const asection *plt,
 			const arelent *rel ATTRIBUTE_UNUSED)
 {
-  return plt->vma + (i + 1) * PLT_ENTRY_SIZE;
+  return plt->vma + (i + 1) * GET_PLT_ENTRY_SIZE (plt->owner);
 }
 
 /* Handle an x86-64 specific section when reading an object file.  This
@@ -4781,49 +5155,33 @@
 }
 
 static bfd_boolean
-elf_x86_64_merge_symbol (struct bfd_link_info *info ATTRIBUTE_UNUSED,
-			 struct elf_link_hash_entry **sym_hash ATTRIBUTE_UNUSED,
-			 struct elf_link_hash_entry *h,
-			 Elf_Internal_Sym *sym,
+elf_x86_64_merge_symbol (struct elf_link_hash_entry *h,
+			 const Elf_Internal_Sym *sym,
 			 asection **psec,
-			 bfd_vma *pvalue ATTRIBUTE_UNUSED,
-			 unsigned int *pold_alignment ATTRIBUTE_UNUSED,
-			 bfd_boolean *skip ATTRIBUTE_UNUSED,
-			 bfd_boolean *override ATTRIBUTE_UNUSED,
-			 bfd_boolean *type_change_ok ATTRIBUTE_UNUSED,
-			 bfd_boolean *size_change_ok ATTRIBUTE_UNUSED,
-			 bfd_boolean *newdyn ATTRIBUTE_UNUSED,
-			 bfd_boolean *newdef,
-			 bfd_boolean *newdyncommon ATTRIBUTE_UNUSED,
-			 bfd_boolean *newweak ATTRIBUTE_UNUSED,
-			 bfd *abfd ATTRIBUTE_UNUSED,
-			 asection **sec,
-			 bfd_boolean *olddyn ATTRIBUTE_UNUSED,
-			 bfd_boolean *olddef,
-			 bfd_boolean *olddyncommon ATTRIBUTE_UNUSED,
-			 bfd_boolean *oldweak ATTRIBUTE_UNUSED,
+			 bfd_boolean newdef,
+			 bfd_boolean olddef,
 			 bfd *oldbfd,
-			 asection **oldsec)
+			 const asection *oldsec)
 {
   /* A normal common symbol and a large common symbol result in a
      normal common symbol.  We turn the large common symbol into a
      normal one.  */
-  if (!*olddef
+  if (!olddef
       && h->root.type == bfd_link_hash_common
-      && !*newdef
-      && bfd_is_com_section (*sec)
-      && *oldsec != *sec)
+      && !newdef
+      && bfd_is_com_section (*psec)
+      && oldsec != *psec)
     {
       if (sym->st_shndx == SHN_COMMON
-	  && (elf_section_flags (*oldsec) & SHF_X86_64_LARGE) != 0)
+	  && (elf_section_flags (oldsec) & SHF_X86_64_LARGE) != 0)
 	{
 	  h->root.u.c.p->section
 	    = bfd_make_section_old_way (oldbfd, "COMMON");
 	  h->root.u.c.p->section->flags = SEC_ALLOC;
 	}
       else if (sym->st_shndx == SHN_X86_64_LCOMMON
-	       && (elf_section_flags (*oldsec) & SHF_X86_64_LARGE) == 0)
-	*psec = *sec = bfd_com_section_ptr;
+	       && (elf_section_flags (oldsec) & SHF_X86_64_LARGE) == 0)
+	*psec = bfd_com_section_ptr;
     }
 
   return TRUE;
@@ -5009,6 +5367,210 @@
 
 #include "elf64-target.h"
 
+/* Native Client support.  */
+
+static bfd_boolean
+elf64_x86_64_nacl_elf_object_p (bfd *abfd)
+{
+  /* Set the right machine number for a NaCl x86-64 ELF64 file.  */
+  bfd_default_set_arch_mach (abfd, bfd_arch_i386, bfd_mach_x86_64_nacl);
+  return TRUE;
+}
+
+#undef	TARGET_LITTLE_SYM
+#define	TARGET_LITTLE_SYM		bfd_elf64_x86_64_nacl_vec
+#undef	TARGET_LITTLE_NAME
+#define	TARGET_LITTLE_NAME		"elf64-x86-64-nacl"
+#undef	elf64_bed
+#define	elf64_bed			elf64_x86_64_nacl_bed
+
+#undef	ELF_MAXPAGESIZE
+#undef	ELF_MINPAGESIZE
+#undef	ELF_COMMONPAGESIZE
+#define ELF_MAXPAGESIZE			0x10000
+#define ELF_MINPAGESIZE			0x10000
+#define ELF_COMMONPAGESIZE		0x10000
+
+/* Restore defaults.  */
+#undef	ELF_OSABI
+#undef	elf_backend_static_tls_alignment
+#undef	elf_backend_want_plt_sym
+#define elf_backend_want_plt_sym	0
+
+/* NaCl uses substantially different PLT entries for the same effects.  */
+
+#undef	elf_backend_plt_alignment
+#define elf_backend_plt_alignment	5
+#define NACL_PLT_ENTRY_SIZE		64
+#define	NACLMASK			0xe0 /* 32-byte alignment mask.  */
+
+static const bfd_byte elf_x86_64_nacl_plt0_entry[NACL_PLT_ENTRY_SIZE] =
+  {
+    0xff, 0x35, 8, 0, 0, 0,             /* pushq GOT+8(%rip) 		*/
+    0x4c, 0x8b, 0x1d, 16, 0, 0, 0,	/* mov GOT+16(%rip), %r11	*/
+    0x41, 0x83, 0xe3, NACLMASK,         /* and $-32, %r11d		*/
+    0x4d, 0x01, 0xfb,             	/* add %r15, %r11		*/
+    0x41, 0xff, 0xe3,             	/* jmpq *%r11			*/
+
+    /* 9-byte nop sequence to pad out to the next 32-byte boundary.  */
+    0x66, 0x0f, 0x1f, 0x84, 0, 0, 0, 0, 0, /* nopw 0x0(%rax,%rax,1)	*/
+
+    /* 32 bytes of nop to pad out to the standard size.  */
+    0x66, 0x66, 0x66, 0x66, 0x66, 0x66,    /* excess data32 prefixes	*/
+    0x2e, 0x0f, 0x1f, 0x84, 0, 0, 0, 0, 0, /* nopw %cs:0x0(%rax,%rax,1)	*/
+    0x66, 0x66, 0x66, 0x66, 0x66, 0x66,    /* excess data32 prefixes	*/
+    0x2e, 0x0f, 0x1f, 0x84, 0, 0, 0, 0, 0, /* nopw %cs:0x0(%rax,%rax,1)	*/
+    0x66,                                  /* excess data32 prefix	*/
+    0x90                                   /* nop */
+  };
+
+static const bfd_byte elf_x86_64_nacl_plt_entry[NACL_PLT_ENTRY_SIZE] =
+  {
+    0x4c, 0x8b, 0x1d, 0, 0, 0, 0,	/* mov name@GOTPCREL(%rip),%r11	*/
+    0x41, 0x83, 0xe3, NACLMASK,         /* and $-32, %r11d		*/
+    0x4d, 0x01, 0xfb,             	/* add %r15, %r11		*/
+    0x41, 0xff, 0xe3,             	/* jmpq *%r11			*/
+
+    /* 15-byte nop sequence to pad out to the next 32-byte boundary.  */
+    0x66, 0x66, 0x66, 0x66, 0x66, 0x66,    /* excess data32 prefixes	*/
+    0x2e, 0x0f, 0x1f, 0x84, 0, 0, 0, 0, 0, /* nopw %cs:0x0(%rax,%rax,1)	*/
+
+    /* Lazy GOT entries point here (32-byte aligned).  */
+    0x68,                 /* pushq immediate */
+    0, 0, 0, 0,           /* replaced with index into relocation table.  */
+    0xe9,                 /* jmp relative */
+    0, 0, 0, 0,           /* replaced with offset to start of .plt0.  */
+
+    /* 22 bytes of nop to pad out to the standard size.  */
+    0x66, 0x66, 0x66, 0x66, 0x66, 0x66,    /* excess data32 prefixes	*/
+    0x2e, 0x0f, 0x1f, 0x84, 0, 0, 0, 0, 0, /* nopw %cs:0x0(%rax,%rax,1)	*/
+    0x0f, 0x1f, 0x80, 0, 0, 0, 0,          /* nopl 0x0(%rax)		*/
+  };
+
+/* .eh_frame covering the .plt section.  */
+
+static const bfd_byte elf_x86_64_nacl_eh_frame_plt[] =
+  {
+#if (PLT_CIE_LENGTH != 20                               \
+     || PLT_FDE_LENGTH != 36                            \
+     || PLT_FDE_START_OFFSET != 4 + PLT_CIE_LENGTH + 8  \
+     || PLT_FDE_LEN_OFFSET != 4 + PLT_CIE_LENGTH + 12)
+# error "Need elf_x86_64_backend_data parameters for eh_frame_plt offsets!"
+#endif
+    PLT_CIE_LENGTH, 0, 0, 0,	/* CIE length */
+    0, 0, 0, 0,			/* CIE ID */
+    1,				/* CIE version */
+    'z', 'R', 0,                /* Augmentation string */
+    1,				/* Code alignment factor */
+    0x78,                       /* Data alignment factor */
+    16,				/* Return address column */
+    1,				/* Augmentation size */
+    DW_EH_PE_pcrel | DW_EH_PE_sdata4, /* FDE encoding */
+    DW_CFA_def_cfa, 7, 8,	/* DW_CFA_def_cfa: r7 (rsp) ofs 8 */
+    DW_CFA_offset + 16, 1,	/* DW_CFA_offset: r16 (rip) at cfa-8 */
+    DW_CFA_nop, DW_CFA_nop,
+
+    PLT_FDE_LENGTH, 0, 0, 0,	/* FDE length */
+    PLT_CIE_LENGTH + 8, 0, 0, 0,/* CIE pointer */
+    0, 0, 0, 0,			/* R_X86_64_PC32 .plt goes here */
+    0, 0, 0, 0,			/* .plt size goes here */
+    0,				/* Augmentation size */
+    DW_CFA_def_cfa_offset, 16,	/* DW_CFA_def_cfa_offset: 16 */
+    DW_CFA_advance_loc + 6,	/* DW_CFA_advance_loc: 6 to __PLT__+6 */
+    DW_CFA_def_cfa_offset, 24,	/* DW_CFA_def_cfa_offset: 24 */
+    DW_CFA_advance_loc + 58,	/* DW_CFA_advance_loc: 58 to __PLT__+64 */
+    DW_CFA_def_cfa_expression,	/* DW_CFA_def_cfa_expression */
+    13,				/* Block length */
+    DW_OP_breg7, 8,		/* DW_OP_breg7 (rsp): 8 */
+    DW_OP_breg16, 0,		/* DW_OP_breg16 (rip): 0 */
+    DW_OP_const1u, 63, DW_OP_and, DW_OP_const1u, 37, DW_OP_ge,
+    DW_OP_lit3, DW_OP_shl, DW_OP_plus,
+    DW_CFA_nop, DW_CFA_nop
+  };
+
+static const struct elf_x86_64_backend_data elf_x86_64_nacl_arch_bed =
+  {
+    elf_x86_64_nacl_plt0_entry,              /* plt0_entry */
+    elf_x86_64_nacl_plt_entry,               /* plt_entry */
+    NACL_PLT_ENTRY_SIZE,                     /* plt_entry_size */
+    2,                                       /* plt0_got1_offset */
+    9,                                       /* plt0_got2_offset */
+    13,                                      /* plt0_got2_insn_end */
+    3,                                       /* plt_got_offset */
+    33,                                      /* plt_reloc_offset */
+    38,                                      /* plt_plt_offset */
+    7,                                       /* plt_got_insn_size */
+    42,                                      /* plt_plt_insn_end */
+    32,                                      /* plt_lazy_offset */
+    elf_x86_64_nacl_eh_frame_plt,            /* eh_frame_plt */
+    sizeof (elf_x86_64_nacl_eh_frame_plt),   /* eh_frame_plt_size */
+  };
+
+#undef	elf_backend_arch_data
+#define	elf_backend_arch_data	&elf_x86_64_nacl_arch_bed
+
+#undef	elf_backend_object_p
+#define elf_backend_object_p			elf64_x86_64_nacl_elf_object_p
+#undef	elf_backend_modify_segment_map
+#define	elf_backend_modify_segment_map		nacl_modify_segment_map
+#undef	elf_backend_modify_program_headers
+#define	elf_backend_modify_program_headers	nacl_modify_program_headers
+#undef	elf_backend_final_write_processing
+#define elf_backend_final_write_processing	nacl_final_write_processing
+
+#include "elf64-target.h"
+
+/* Native Client x32 support.  */
+
+static bfd_boolean
+elf32_x86_64_nacl_elf_object_p (bfd *abfd)
+{
+  /* Set the right machine number for a NaCl x86-64 ELF32 file.  */
+  bfd_default_set_arch_mach (abfd, bfd_arch_i386, bfd_mach_x64_32_nacl);
+  return TRUE;
+}
+
+#undef  TARGET_LITTLE_SYM
+#define TARGET_LITTLE_SYM		bfd_elf32_x86_64_nacl_vec
+#undef  TARGET_LITTLE_NAME
+#define TARGET_LITTLE_NAME		"elf32-x86-64-nacl"
+#undef	elf32_bed
+#define	elf32_bed			elf32_x86_64_nacl_bed
+
+#define bfd_elf32_bfd_link_hash_table_create \
+  elf_x86_64_link_hash_table_create
+#define bfd_elf32_bfd_link_hash_table_free \
+  elf_x86_64_link_hash_table_free
+#define bfd_elf32_bfd_reloc_type_lookup	\
+  elf_x86_64_reloc_type_lookup
+#define bfd_elf32_bfd_reloc_name_lookup \
+  elf_x86_64_reloc_name_lookup
+#define bfd_elf32_mkobject \
+  elf_x86_64_mkobject
+
+#undef elf_backend_object_p
+#define elf_backend_object_p \
+  elf32_x86_64_nacl_elf_object_p
+
+#undef elf_backend_bfd_from_remote_memory
+#define elf_backend_bfd_from_remote_memory \
+  _bfd_elf32_bfd_from_remote_memory
+
+#undef elf_backend_size_info
+#define elf_backend_size_info \
+  _bfd_elf32_size_info
+
+#include "elf32-target.h"
+
+/* Restore defaults.  */
+#undef	elf_backend_object_p
+#define elf_backend_object_p		    elf64_x86_64_elf_object_p
+#undef	elf_backend_bfd_from_remote_memory
+#undef	elf_backend_size_info
+#undef	elf_backend_modify_segment_map
+#undef	elf_backend_modify_program_headers
+#undef	elf_backend_final_write_processing
+
 /* Intel L1OM support.  */
 
 static bfd_boolean
@@ -5037,10 +5599,17 @@
 #undef elf_backend_object_p
 #define elf_backend_object_p		    elf64_l1om_elf_object_p
 
-#undef  elf_backend_static_tls_alignment
-
-#undef elf_backend_want_plt_sym
-#define elf_backend_want_plt_sym	    0
+/* Restore defaults.  */
+#undef	ELF_MAXPAGESIZE
+#undef	ELF_MINPAGESIZE
+#undef	ELF_COMMONPAGESIZE
+#define ELF_MAXPAGESIZE			0x200000
+#define ELF_MINPAGESIZE			0x1000
+#define ELF_COMMONPAGESIZE		0x1000
+#undef	elf_backend_plt_alignment
+#define elf_backend_plt_alignment	4
+#undef	elf_backend_arch_data
+#define	elf_backend_arch_data	&elf_x86_64_arch_bed
 
 #include "elf64-target.h"
 
@@ -5111,18 +5680,11 @@
 
 /* 32bit x86-64 support.  */
 
-static bfd_boolean
-elf32_x86_64_elf_object_p (bfd *abfd)
-{
-  /* Set the right machine number for an x86-64 elf32 file.  */
-  bfd_default_set_arch_mach (abfd, bfd_arch_i386, bfd_mach_x64_32);
-  return TRUE;
-}
-
 #undef  TARGET_LITTLE_SYM
 #define TARGET_LITTLE_SYM		    bfd_elf32_x86_64_vec
 #undef  TARGET_LITTLE_NAME
 #define TARGET_LITTLE_NAME		    "elf32-x86-64"
+#undef	elf32_bed
 
 #undef ELF_ARCH
 #define ELF_ARCH			    bfd_arch_i386
@@ -5130,17 +5692,6 @@
 #undef	ELF_MACHINE_CODE
 #define ELF_MACHINE_CODE		    EM_X86_64
 
-#define bfd_elf32_bfd_link_hash_table_create \
-  elf_x86_64_link_hash_table_create
-#define bfd_elf32_bfd_link_hash_table_free \
-  elf_x86_64_link_hash_table_free
-#define bfd_elf32_bfd_reloc_type_lookup	\
-  elf_x86_64_reloc_type_lookup
-#define bfd_elf32_bfd_reloc_name_lookup \
-  elf_x86_64_reloc_name_lookup
-#define bfd_elf32_mkobject \
-  elf_x86_64_mkobject
-
 #undef	ELF_OSABI
 
 #undef elf_backend_object_p
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index 2244874..e296c5c 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -1,6 +1,6 @@
 /* ELF executable support for BFD.
    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    Written by Fred Fish @ Cygnus Support, from information published
@@ -495,13 +495,10 @@
   Elf_Internal_Shdr *i_shdrp;	/* Section header table, internal form */
   unsigned int shindex;
   const struct elf_backend_data *ebd;
-  struct bfd_preserve preserve;
   asection *s;
   bfd_size_type amt;
   const bfd_target *target;
 
-  preserve.marker = NULL;
-
   /* Read in the ELF header in external format.  */
 
   if (bfd_bread (&x_ehdr, sizeof (x_ehdr), abfd) != sizeof (x_ehdr))
@@ -539,9 +536,6 @@
       goto got_wrong_format_error;
     }
 
-  if (!bfd_preserve_save (abfd, &preserve))
-    goto got_no_match;
-
   target = abfd->xvec;
 
   /* Allocate an instance of the elf_obj_tdata structure and hook it up to
@@ -549,7 +543,6 @@
 
   if (! (*target->_bfd_set_format[bfd_object]) (abfd))
     goto got_no_match;
-  preserve.marker = elf_tdata (abfd);
 
   /* Now that we know the byte order, swap in the rest of the header */
   i_ehdrp = elf_elfheader (abfd);
@@ -633,8 +626,9 @@
       if (i_ehdrp->e_shnum == SHN_UNDEF)
 	{
 	  i_ehdrp->e_shnum = i_shdr.sh_size;
-	  if (i_ehdrp->e_shnum != i_shdr.sh_size
-	      || i_ehdrp->e_shnum == 0)
+	  if (i_ehdrp->e_shnum >= SHN_LORESERVE
+	      || i_ehdrp->e_shnum != i_shdr.sh_size
+	      || i_ehdrp->e_shnum  == 0)
 	    goto got_wrong_format_error;
 	}
 
@@ -841,25 +835,12 @@
 	    s->flags |= SEC_DEBUGGING;
 	}
     }
-
-  bfd_preserve_finish (abfd, &preserve);
   return target;
 
  got_wrong_format_error:
-  /* There is way too much undoing of half-known state here.  The caller,
-     bfd_check_format_matches, really shouldn't iterate on live bfd's to
-     check match/no-match like it does.  We have to rely on that a call to
-     bfd_default_set_arch_mach with the previously known mach, undoes what
-     was done by the first bfd_default_set_arch_mach (with mach 0) here.
-     For this to work, only elf-data and the mach may be changed by the
-     target-specific elf_backend_object_p function.  Note that saving the
-     whole bfd here and restoring it would be even worse; the first thing
-     you notice is that the cached bfd file position gets out of sync.  */
   bfd_set_error (bfd_error_wrong_format);
 
  got_no_match:
-  if (preserve.marker != NULL)
-    bfd_preserve_restore (abfd, &preserve);
   return NULL;
 }
 
@@ -1090,6 +1071,7 @@
     {
       Elf_Internal_Shdr i_shdr;
       Elf_External_Shdr x_shdr;
+      bfd_byte *contents, *free_contents;
 
       i_shdr = *i_shdrp[count];
       i_shdr.sh_offset = 0;
@@ -1097,28 +1079,36 @@
       elf_swap_shdr_out (abfd, &i_shdr, &x_shdr);
       (*process) (&x_shdr, sizeof x_shdr, arg);
 
-      /* PR ld/12451:
-	 Process the section's contents, if it has some.  Read them in if necessary.  */
-      if (i_shdr.contents)
-	(*process) (i_shdr.contents, i_shdr.sh_size, arg);
-      else if (i_shdr.sh_type != SHT_NOBITS)
+      /* Process the section's contents, if it has some.
+	 PR ld/12451: Read them in if necessary.  */
+      if (i_shdr.sh_type == SHT_NOBITS)
+	continue;
+      free_contents = NULL;
+      contents = i_shdr.contents;
+      if (contents == NULL)
 	{
 	  asection *sec;
 
 	  sec = bfd_section_from_elf_index (abfd, count);
 	  if (sec != NULL)
 	    {
-	      if (sec->contents == NULL)
+	      contents = sec->contents;
+	      if (contents == NULL)
 		{
 		  /* Force rereading from file.  */
 		  sec->flags &= ~SEC_IN_MEMORY;
-		  if (! bfd_malloc_and_get_section (abfd, sec, & sec->contents))
+		  if (!bfd_malloc_and_get_section (abfd, sec, &free_contents))
 		    continue;
+		  contents = free_contents;
 		}
-	      if (sec->contents != NULL)
-		(*process) (sec->contents, i_shdr.sh_size, arg);
 	    }
 	}
+      if (contents != NULL)
+	{
+	  (*process) (contents, i_shdr.sh_size, arg);
+	  if (free_contents != NULL)
+	    free (free_contents);
+	}
     }
 
   return TRUE;
@@ -1162,9 +1152,9 @@
 	verhdr = NULL;
       else
 	verhdr = &elf_tdata (abfd)->dynversym_hdr;
-      if ((elf_tdata (abfd)->dynverdef_section != 0
+      if ((elf_dynverdef (abfd) != 0
 	   && elf_tdata (abfd)->verdef == NULL)
-	  || (elf_tdata (abfd)->dynverref_section != 0
+	  || (elf_dynverref (abfd) != 0
 	      && elf_tdata (abfd)->verref == NULL))
 	{
 	  if (!_bfd_elf_slurp_version_tables (abfd, FALSE))
@@ -1450,7 +1440,7 @@
 	  (*_bfd_error_handler)
 	    (_("%s(%s): relocation %d has invalid symbol index %ld"),
 	     abfd->filename, asect->name, i, ELF_R_SYM (rela.r_info));
-	  relent->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+	  relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
 	}
       else
 	{
@@ -1615,7 +1605,7 @@
   (bfd *templ,
    bfd_vma ehdr_vma,
    bfd_vma *loadbasep,
-   int (*target_read_memory) (bfd_vma, bfd_byte *, int))
+   int (*target_read_memory) (bfd_vma, bfd_byte *, bfd_size_type))
 {
   Elf_External_Ehdr x_ehdr;	/* Elf file header, external form */
   Elf_Internal_Ehdr i_ehdr;	/* Elf file header, internal form */
diff --git a/bfd/elfcore.h b/bfd/elfcore.h
index 81980c0..429c09c 100644
--- a/bfd/elfcore.h
+++ b/bfd/elfcore.h
@@ -22,19 +22,19 @@
 char*
 elf_core_file_failing_command (bfd *abfd)
 {
-  return elf_tdata (abfd)->core_command;
+  return elf_tdata (abfd)->core->command;
 }
 
 int
 elf_core_file_failing_signal (bfd *abfd)
 {
-  return elf_tdata (abfd)->core_signal;
+  return elf_tdata (abfd)->core->signal;
 }
 
 int
 elf_core_file_pid (bfd *abfd)
 {
-  return elf_tdata (abfd)->core_pid;
+  return elf_tdata (abfd)->core->pid;
 }
 
 bfd_boolean
@@ -51,7 +51,7 @@
     }
 
   /* See if the name in the corefile matches the executable name.  */
-  corename = elf_tdata (core_bfd)->core_program;
+  corename = elf_tdata (core_bfd)->core->program;
   if (corename != NULL)
     {
       const char* execname = strrchr (exec_bfd->filename, '/');
@@ -84,11 +84,8 @@
   Elf_Internal_Phdr *i_phdrp;	/* Elf program header, internal form.  */
   unsigned int phindex;
   const struct elf_backend_data *ebd;
-  struct bfd_preserve preserve;
   bfd_size_type amt;
 
-  preserve.marker = NULL;
-
   /* Read in the ELF header in external format.  */
   if (bfd_bread (&x_ehdr, sizeof (x_ehdr), abfd) != sizeof (x_ehdr))
     {
@@ -123,13 +120,9 @@
       goto wrong;
     }
 
-  if (!bfd_preserve_save (abfd, &preserve))
-    goto fail;
-
   /* Give abfd an elf_obj_tdata.  */
   if (! (*abfd->xvec->_bfd_set_format[bfd_core]) (abfd))
     goto fail;
-  preserve.marker = elf_tdata (abfd);
 
   /* Swap in the rest of the header, now that we have the byte order.  */
   i_ehdrp = elf_elfheader (abfd);
@@ -294,7 +287,7 @@
   {
     bfd_size_type high = 0;
     struct stat statbuf;
-    for (phindex = 0; phindex < i_ehdrp->e_phnum; ++phindex) 
+    for (phindex = 0; phindex < i_ehdrp->e_phnum; ++phindex)
       {
 	Elf_Internal_Phdr *p = i_phdrp + phindex;
 	if (p->p_filesz)
@@ -315,27 +308,13 @@
 	  }
       }
   }
-  
+
   /* Save the entry point from the ELF header.  */
   bfd_get_start_address (abfd) = i_ehdrp->e_entry;
-
-  bfd_preserve_finish (abfd, &preserve);
   return abfd->xvec;
 
 wrong:
-  /* There is way too much undoing of half-known state here.  The caller,
-     bfd_check_format_matches, really shouldn't iterate on live bfd's to
-     check match/no-match like it does.  We have to rely on that a call to
-     bfd_default_set_arch_mach with the previously known mach, undoes what
-     was done by the first bfd_default_set_arch_mach (with mach 0) here.
-     For this to work, only elf-data and the mach may be changed by the
-     target-specific elf_backend_object_p function.  Note that saving the
-     whole bfd here and restoring it would be even worse; the first thing
-     you notice is that the cached bfd file position gets out of sync.  */
   bfd_set_error (bfd_error_wrong_format);
-
 fail:
-  if (preserve.marker != NULL)
-    bfd_preserve_restore (abfd, &preserve);
   return NULL;
 }
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 4086ef8..99b7ca1 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -1,7 +1,5 @@
 /* ELF linking support for BFD.
-   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright 1995-2013 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -87,7 +85,8 @@
   h->def_regular = 1;
   h->non_elf = 0;
   h->type = STT_OBJECT;
-  h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN;
+  if (ELF_ST_VISIBILITY (h->other) != STV_INTERNAL)
+    h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN;
 
   bed = get_elf_backend_data (abfd);
   (*bed->elf_backend_hide_symbol) (info, h, TRUE);
@@ -104,8 +103,8 @@
   struct elf_link_hash_table *htab = elf_hash_table (info);
 
   /* This function may be called more than once.  */
-  s = bfd_get_section_by_name (abfd, ".got");
-  if (s != NULL && (s->flags & SEC_LINKER_CREATED) != 0)
+  s = bfd_get_linker_section (abfd, ".got");
+  if (s != NULL)
     return TRUE;
 
   flags = bed->dynamic_sec_flags;
@@ -187,6 +186,7 @@
   flagword flags;
   asection *s;
   const struct elf_backend_data *bed;
+  struct elf_link_hash_entry *h;
 
   if (! is_elf_hash_table (info->hash))
     return FALSE;
@@ -254,7 +254,9 @@
      section.  We don't want to define it if there is no .dynamic
      section, since on some ELF platforms the start up code examines it
      to decide how to initialize the process.  */
-  if (!_bfd_elf_define_linkage_sym (abfd, info, s, "_DYNAMIC"))
+  h = _bfd_elf_define_linkage_sym (abfd, info, s, "_DYNAMIC");
+  elf_hash_table (info)->hdynamic = h;
+  if (h == NULL)
     return FALSE;
 
   if (info->emit_hash)
@@ -569,10 +571,11 @@
 
   h->def_regular = 1;
 
-  if (provide && hidden)
+  if (hidden)
     {
       bed = get_elf_backend_data (output_bfd);
-      h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN;
+      if (ELF_ST_VISIBILITY (h->other) != STV_INTERNAL)
+	h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN;
       (*bed->elf_backend_hide_symbol) (info, h, TRUE);
     }
 
@@ -779,8 +782,7 @@
 	  asection *ip;
 
 	  if (htab->dynobj != NULL
-	      && (ip = bfd_get_section_by_name (htab->dynobj, p->name)) != NULL
-	      && (ip->flags & SEC_LINKER_CREATED)
+	      && (ip = bfd_get_linker_section (htab->dynobj, p->name)) != NULL
 	      && ip->output_section == p)
 	    return TRUE;
 	}
@@ -893,27 +895,30 @@
     }
 }
 
-/* This function is called when we want to define a new symbol.  It
-   handles the various cases which arise when we find a definition in
-   a dynamic object, or when there is already a definition in a
-   dynamic object.  The new symbol is described by NAME, SYM, PSEC,
-   and PVALUE.  We set SYM_HASH to the hash table entry.  We set
-   OVERRIDE if the old symbol is overriding a new definition.  We set
-   TYPE_CHANGE_OK if it is OK for the type to change.  We set
-   SIZE_CHANGE_OK if it is OK for the size to change.  By OK to
-   change, we mean that we shouldn't warn if the type or size does
-   change.  We set POLD_ALIGNMENT if an old common symbol in a dynamic
-   object is overridden by a regular object.  */
+/* This function is called when we want to merge a new symbol with an
+   existing symbol.  It handles the various cases which arise when we
+   find a definition in a dynamic object, or when there is already a
+   definition in a dynamic object.  The new symbol is described by
+   NAME, SYM, PSEC, and PVALUE.  We set SYM_HASH to the hash table
+   entry.  We set POLDBFD to the old symbol's BFD.  We set POLD_WEAK
+   if the old symbol was weak.  We set POLD_ALIGNMENT to the alignment
+   of an old common symbol.  We set OVERRIDE if the old symbol is
+   overriding a new definition.  We set TYPE_CHANGE_OK if it is OK for
+   the type to change.  We set SIZE_CHANGE_OK if it is OK for the size
+   to change.  By OK to change, we mean that we shouldn't warn if the
+   type or size does change.  */
 
-bfd_boolean
+static bfd_boolean
 _bfd_elf_merge_symbol (bfd *abfd,
 		       struct bfd_link_info *info,
 		       const char *name,
 		       Elf_Internal_Sym *sym,
 		       asection **psec,
 		       bfd_vma *pvalue,
-		       unsigned int *pold_alignment,
 		       struct elf_link_hash_entry **sym_hash,
+		       bfd **poldbfd,
+		       bfd_boolean *pold_weak,
+		       unsigned int *pold_alignment,
 		       bfd_boolean *skip,
 		       bfd_boolean *override,
 		       bfd_boolean *type_change_ok,
@@ -921,6 +926,7 @@
 {
   asection *sec, *oldsec;
   struct elf_link_hash_entry *h;
+  struct elf_link_hash_entry *hi;
   struct elf_link_hash_entry *flip;
   int bind;
   bfd *oldbfd;
@@ -934,15 +940,6 @@
   sec = *psec;
   bind = ELF_ST_BIND (sym->st_info);
 
-  /* Silently discard TLS symbols from --just-syms.  There's no way to
-     combine a static TLS block with a new TLS block for this executable.  */
-  if (ELF_ST_TYPE (sym->st_info) == STT_TLS
-      && sec->sec_info_type == ELF_INFO_TYPE_JUST_SYMS)
-    {
-      *skip = TRUE;
-      return TRUE;
-    }
-
   if (! bfd_is_und_section (sec))
     h = elf_link_hash_lookup (elf_hash_table (info), name, TRUE, FALSE, FALSE);
   else
@@ -954,46 +951,26 @@
 
   bed = get_elf_backend_data (abfd);
 
-  /* This code is for coping with dynamic objects, and is only useful
-     if we are doing an ELF link.  */
-  if (!(*bed->relocs_compatible) (abfd->xvec, info->output_bfd->xvec))
-    return TRUE;
-
-  /* For merging, we only care about real symbols.  */
-
+  /* For merging, we only care about real symbols.  But we need to make
+     sure that indirect symbol dynamic flags are updated.  */
+  hi = h;
   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;
 
-  /* We have to check it for every instance since the first few may be
-     refereences and not all compilers emit symbol type for undefined
-     symbols.  */
-  bfd_elf_link_mark_dynamic_symbol (info, h, sym);
-
-  /* If we just created the symbol, mark it as being an ELF symbol.
-     Other than that, there is nothing to do--there is no merge issue
-     with a newly defined symbol--so we just return.  */
-
-  if (h->root.type == bfd_link_hash_new)
-    {
-      h->non_elf = 0;
-      return TRUE;
-    }
-
   /* OLDBFD and OLDSEC are a BFD and an ASECTION associated with the
      existing symbol.  */
 
+  oldbfd = NULL;
+  oldsec = NULL;
   switch (h->root.type)
     {
     default:
-      oldbfd = NULL;
-      oldsec = NULL;
       break;
 
     case bfd_link_hash_undefined:
     case bfd_link_hash_undefweak:
       oldbfd = h->root.u.undef.abfd;
-      oldsec = NULL;
       break;
 
     case bfd_link_hash_defined:
@@ -1005,13 +982,68 @@
     case bfd_link_hash_common:
       oldbfd = h->root.u.c.p->section->owner;
       oldsec = h->root.u.c.p->section;
+      if (pold_alignment)
+	*pold_alignment = h->root.u.c.p->alignment_power;
       break;
     }
+  if (poldbfd && *poldbfd == NULL)
+    *poldbfd = oldbfd;
 
   /* Differentiate strong and weak symbols.  */
   newweak = bind == STB_WEAK;
   oldweak = (h->root.type == bfd_link_hash_defweak
 	     || h->root.type == bfd_link_hash_undefweak);
+  if (pold_weak)
+    *pold_weak = oldweak;
+
+  /* This code is for coping with dynamic objects, and is only useful
+     if we are doing an ELF link.  */
+  if (!(*bed->relocs_compatible) (abfd->xvec, info->output_bfd->xvec))
+    return TRUE;
+
+  /* We have to check it for every instance since the first few may be
+     references and not all compilers emit symbol type for undefined
+     symbols.  */
+  bfd_elf_link_mark_dynamic_symbol (info, h, sym);
+
+  /* NEWDYN and OLDDYN indicate whether the new or old symbol,
+     respectively, is from a dynamic object.  */
+
+  newdyn = (abfd->flags & DYNAMIC) != 0;
+
+  /* ref_dynamic_nonweak and dynamic_def flags track actual undefined
+     syms and defined syms in dynamic libraries respectively.
+     ref_dynamic on the other hand can be set for a symbol defined in
+     a dynamic library, and def_dynamic may not be set;  When the
+     definition in a dynamic lib is overridden by a definition in the
+     executable use of the symbol in the dynamic lib becomes a
+     reference to the executable symbol.  */
+  if (newdyn)
+    {
+      if (bfd_is_und_section (sec))
+	{
+	  if (bind != STB_WEAK)
+	    {
+	      h->ref_dynamic_nonweak = 1;
+	      hi->ref_dynamic_nonweak = 1;
+	    }
+	}
+      else
+	{
+	  h->dynamic_def = 1;
+	  hi->dynamic_def = 1;
+	}
+    }
+
+  /* If we just created the symbol, mark it as being an ELF symbol.
+     Other than that, there is nothing to do--there is no merge issue
+     with a newly defined symbol--so we just return.  */
+
+  if (h->root.type == bfd_link_hash_new)
+    {
+      h->non_elf = 0;
+      return TRUE;
+    }
 
   /* In cases involving weak versioned symbols, we may wind up trying
      to merge a symbol with itself.  Catch that here, to avoid the
@@ -1025,11 +1057,6 @@
 	  || !h->def_regular))
     return TRUE;
 
-  /* NEWDYN and OLDDYN indicate whether the new or old symbol,
-     respectively, is from a dynamic object.  */
-
-  newdyn = (abfd->flags & DYNAMIC) != 0;
-
   olddyn = FALSE;
   if (oldbfd != NULL)
     olddyn = (oldbfd->flags & DYNAMIC) != 0;
@@ -1114,47 +1141,29 @@
 
       if (tdef && ntdef)
 	(*_bfd_error_handler)
-	  (_("%s: TLS definition in %B section %A mismatches non-TLS definition in %B section %A"),
+	  (_("%s: TLS definition in %B section %A "
+	     "mismatches non-TLS definition in %B section %A"),
 	   tbfd, tsec, ntbfd, ntsec, h->root.root.string);
       else if (!tdef && !ntdef)
 	(*_bfd_error_handler)
-	  (_("%s: TLS reference in %B mismatches non-TLS reference in %B"),
+	  (_("%s: TLS reference in %B "
+	     "mismatches non-TLS reference in %B"),
 	   tbfd, ntbfd, h->root.root.string);
       else if (tdef)
 	(*_bfd_error_handler)
-	  (_("%s: TLS definition in %B section %A mismatches non-TLS reference in %B"),
+	  (_("%s: TLS definition in %B section %A "
+	     "mismatches non-TLS reference in %B"),
 	   tbfd, tsec, ntbfd, h->root.root.string);
       else
 	(*_bfd_error_handler)
-	  (_("%s: TLS reference in %B mismatches non-TLS definition in %B section %A"),
+	  (_("%s: TLS reference in %B "
+	     "mismatches non-TLS definition in %B section %A"),
 	   tbfd, ntbfd, ntsec, h->root.root.string);
 
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
     }
 
-  /* We need to remember if a symbol has a definition in a dynamic
-     object or is weak in all dynamic objects. Internal and hidden
-     visibility will make it unavailable to dynamic objects.  */
-  if (newdyn && !h->dynamic_def)
-    {
-      if (!bfd_is_und_section (sec))
-	h->dynamic_def = 1;
-      else
-	{
-	  /* Check if this symbol is weak in all dynamic objects. If it
-	     is the first time we see it in a dynamic object, we mark
-	     if it is weak. Otherwise, we clear it.  */
-	  if (!h->ref_dynamic)
-	    {
-	      if (bind == STB_WEAK)
-		h->dynamic_weak = 1;
-	    }
-	  else if (bind != STB_WEAK)
-	    h->dynamic_weak = 0;
-	}
-    }
-
   /* If the old symbol has non-default visibility, we ignore the new
      definition from a dynamic object.  */
   if (newdyn
@@ -1164,6 +1173,7 @@
       *skip = TRUE;
       /* Make sure this symbol is dynamic.  */
       h->ref_dynamic = 1;
+      hi->ref_dynamic = 1;
       /* A protected symbol has external availability. Make sure it is
 	 recorded as dynamic.
 
@@ -1180,7 +1190,7 @@
       /* If the new symbol with non-default visibility comes from a
 	 relocatable file and the old definition comes from a dynamic
 	 object, we remove the old definition.  */
-      if ((*sym_hash)->root.type == bfd_link_hash_indirect)
+      if (hi->root.type == bfd_link_hash_indirect)
 	{
 	  /* Handle the case where the old dynamic definition is
 	     default versioned.  We need to copy the symbol info from
@@ -1188,43 +1198,42 @@
 	     was referenced before.  */
 	  if (h->ref_regular)
 	    {
-	      struct elf_link_hash_entry *vh = *sym_hash;
-
-	      vh->root.type = h->root.type;
+	      hi->root.type = h->root.type;
 	      h->root.type = bfd_link_hash_indirect;
-	      (*bed->elf_backend_copy_indirect_symbol) (info, vh, h);
-	      /* Protected symbols will override the dynamic definition
-		 with default version.  */
-	      if (ELF_ST_VISIBILITY (sym->st_other) == STV_PROTECTED)
+	      (*bed->elf_backend_copy_indirect_symbol) (info, hi, h);
+
+	      h->root.u.i.link = (struct bfd_link_hash_entry *) hi;
+	      if (ELF_ST_VISIBILITY (sym->st_other) != STV_PROTECTED)
 		{
-		  h->root.u.i.link = (struct bfd_link_hash_entry *) vh;
-		  vh->dynamic_def = 1;
-		  vh->ref_dynamic = 1;
+		  /* If the new symbol is hidden or internal, completely undo
+		     any dynamic link state.  */
+		  (*bed->elf_backend_hide_symbol) (info, h, TRUE);
+		  h->forced_local = 0;
+		  h->ref_dynamic = 0;
 		}
 	      else
-		{
-		  h->root.type = vh->root.type;
-		  vh->ref_dynamic = 0;
-		  /* We have to hide it here since it was made dynamic
-		     global with extra bits when the symbol info was
-		     copied from the old dynamic definition.  */
-		  (*bed->elf_backend_hide_symbol) (info, vh, TRUE);
-		}
-	      h = vh;
+		h->ref_dynamic = 1;
+
+	      h->def_dynamic = 0;
+	      /* FIXME: Should we check type and size for protected symbol?  */
+	      h->size = 0;
+	      h->type = 0;
+
+	      h = hi;
 	    }
 	  else
-	    h = *sym_hash;
+	    h = hi;
 	}
 
-      if ((h->root.u.undef.next || info->hash->undefs_tail == &h->root)
-	  && bfd_is_und_section (sec))
+      /* If the old symbol was undefined before, then it will still be
+	 on the undefs list.  If the new symbol is undefined or
+	 common, we can't make it bfd_link_hash_new here, because new
+	 undefined or common symbols will be added to the undefs list
+	 by _bfd_generic_link_add_one_symbol.  Symbols may not be
+	 added twice to the undefs list.  Also, if the new symbol is
+	 undefweak then we don't want to lose the strong undef.  */
+      if (h->root.u.undef.next || info->hash->undefs_tail == &h->root)
 	{
-	  /* If the new symbol is undefined and the old symbol was
-	     also undefined before, we need to make sure
-	     _bfd_generic_link_add_one_symbol doesn't mess
-	     up the linker hash table undefs list.  Since the old
-	     definition came from a dynamic object, it is still on the
-	     undefs list.  */
 	  h->root.type = bfd_link_hash_undefined;
 	  h->root.u.undef.abfd = abfd;
 	}
@@ -1234,20 +1243,23 @@
 	  h->root.u.undef.abfd = NULL;
 	}
 
-      if (h->def_dynamic)
+      if (ELF_ST_VISIBILITY (sym->st_other) != STV_PROTECTED)
 	{
-	  h->def_dynamic = 0;
-	  h->ref_dynamic = 1;
+	  /* If the new symbol is hidden or internal, completely undo
+	     any dynamic link state.  */
+	  (*bed->elf_backend_hide_symbol) (info, h, TRUE);
+	  h->forced_local = 0;
+	  h->ref_dynamic = 0;
 	}
+      else
+	h->ref_dynamic = 1;
+      h->def_dynamic = 0;
       /* FIXME: Should we check type and size for protected symbol?  */
       h->size = 0;
       h->type = 0;
       return TRUE;
     }
 
-  if (bind == STB_GNU_UNIQUE)
-    h->unique_global = 1;
-
   /* If a new weak symbol definition comes from a regular file and the
      old symbol comes from a dynamic library, we treat the new one as
      strong.  Similarly, an old weak symbol definition from a regular
@@ -1333,15 +1345,12 @@
 
   /* We now know everything about the old and new symbols.  We ask the
      backend to check if we can merge them.  */
-  if (bed->merge_symbol
-      && !bed->merge_symbol (info, sym_hash, h, sym, psec, pvalue,
-			     pold_alignment, skip, override,
-			     type_change_ok, size_change_ok,
-			     &newdyn, &newdef, &newdyncommon, &newweak,
-			     abfd, &sec,
-			     &olddyn, &olddef, &olddyncommon, &oldweak,
-			     oldbfd, &oldsec))
-    return FALSE;
+  if (bed->merge_symbol != NULL)
+    {
+      if (!bed->merge_symbol (h, sym, psec, newdef, olddef, oldbfd, oldsec))
+	return FALSE;
+      sec = *psec;
+    }
 
   /* If both the old and the new symbols look like common symbols in a
      dynamic object, set the size of the symbol to the larger of the
@@ -1490,8 +1499,8 @@
 	  *type_change_ok = TRUE;
 	}
 
-      if ((*sym_hash)->root.type == bfd_link_hash_indirect)
-	flip = *sym_hash;
+      if (hi->root.type == bfd_link_hash_indirect)
+	flip = hi;
       else
 	/* This union may have been set to be non-NULL when this symbol
 	   was seen in a dynamic object.  We must force the union to be
@@ -1536,8 +1545,8 @@
       *size_change_ok = TRUE;
       *type_change_ok = TRUE;
 
-      if ((*sym_hash)->root.type == bfd_link_hash_indirect)
-	flip = *sym_hash;
+      if (hi->root.type == bfd_link_hash_indirect)
+	flip = hi;
       else
 	h->verinfo.vertree = NULL;
     }
@@ -1564,7 +1573,7 @@
 
 /* This function is called to create an indirect symbol from the
    default for the symbol with the default version if needed. The
-   symbol is described by H, NAME, SYM, PSEC, VALUE, and OVERRIDE.  We
+   symbol is described by H, NAME, SYM, SEC, and VALUE.  We
    set DYNSYM if the new indirect symbol is dynamic.  */
 
 static bfd_boolean
@@ -1573,10 +1582,10 @@
 			     struct elf_link_hash_entry *h,
 			     const char *name,
 			     Elf_Internal_Sym *sym,
-			     asection **psec,
-			     bfd_vma *value,
-			     bfd_boolean *dynsym,
-			     bfd_boolean override)
+			     asection *sec,
+			     bfd_vma value,
+			     bfd **poldbfd,
+			     bfd_boolean *dynsym)
 {
   bfd_boolean type_change_ok;
   bfd_boolean size_change_ok;
@@ -1587,9 +1596,10 @@
   const struct elf_backend_data *bed;
   bfd_boolean collect;
   bfd_boolean dynamic;
+  bfd_boolean override;
   char *p;
   size_t len, shortlen;
-  asection *sec;
+  asection *tmp_sec;
 
   /* If this symbol has a version, and it is the default version, we
      create an indirect symbol from the default name to the fully
@@ -1599,24 +1609,6 @@
   if (p == NULL || p[1] != ELF_VER_CHR)
     return TRUE;
 
-  if (override)
-    {
-      /* We are overridden by an old definition. We need to check if we
-	 need to create the indirect symbol from the default name.  */
-      hi = elf_link_hash_lookup (elf_hash_table (info), name, TRUE,
-				 FALSE, FALSE);
-      BFD_ASSERT (hi != NULL);
-      if (hi == h)
-	return TRUE;
-      while (hi->root.type == bfd_link_hash_indirect
-	     || hi->root.type == bfd_link_hash_warning)
-	{
-	  hi = (struct elf_link_hash_entry *) hi->root.u.i.link;
-	  if (hi == h)
-	    return TRUE;
-	}
-    }
-
   bed = get_elf_backend_data (abfd);
   collect = bed->collect;
   dynamic = (abfd->flags & DYNAMIC) != 0;
@@ -1634,9 +1626,9 @@
      actually going to define an indirect symbol.  */
   type_change_ok = FALSE;
   size_change_ok = FALSE;
-  sec = *psec;
-  if (!_bfd_elf_merge_symbol (abfd, info, shortname, sym, &sec, value,
-			      NULL, &hi, &skip, &override,
+  tmp_sec = sec;
+  if (!_bfd_elf_merge_symbol (abfd, info, shortname, sym, &tmp_sec, &value,
+			      &hi, poldbfd, NULL, NULL, &skip, &override,
 			      &type_change_ok, &size_change_ok))
     return FALSE;
 
@@ -1717,6 +1709,7 @@
 	  if (! dynamic)
 	    {
 	      if (! info->executable
+		  || hi->def_dynamic
 		  || hi->ref_dynamic)
 		*dynsym = TRUE;
 	    }
@@ -1742,9 +1735,9 @@
   /* Once again, merge with any existing symbol.  */
   type_change_ok = FALSE;
   size_change_ok = FALSE;
-  sec = *psec;
-  if (!_bfd_elf_merge_symbol (abfd, info, shortname, sym, &sec, value,
-			      NULL, &hi, &skip, &override,
+  tmp_sec = sec;
+  if (!_bfd_elf_merge_symbol (abfd, info, shortname, sym, &tmp_sec, &value,
+			      &hi, NULL, NULL, NULL, &skip, &override,
 			      &type_change_ok, &size_change_ok))
     return FALSE;
 
@@ -2476,7 +2469,7 @@
       && !h->def_regular
       && h->ref_regular
       && !h->def_dynamic
-      && (h->root.u.def.section->owner->flags & DYNAMIC) == 0)
+      && (h->root.u.def.section->owner->flags & (DYNAMIC | BFD_PLUGIN)) == 0)
     h->def_regular = 1;
 
   /* If -Bsymbolic was used (which means to bind references to global
@@ -2510,23 +2503,21 @@
      over to the real definition.  */
   if (h->u.weakdef != NULL)
     {
-      struct elf_link_hash_entry *weakdef;
-
-      weakdef = h->u.weakdef;
-      while (h->root.type == bfd_link_hash_indirect)
-	h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
-      BFD_ASSERT (h->root.type == bfd_link_hash_defined
-		  || h->root.type == bfd_link_hash_defweak);
-      BFD_ASSERT (weakdef->def_dynamic);
-
       /* If the real definition is defined by a regular object file,
 	 don't do anything special.  See the longer description in
 	 _bfd_elf_adjust_dynamic_symbol, below.  */
-      if (weakdef->def_regular)
+      if (h->u.weakdef->def_regular)
 	h->u.weakdef = NULL;
       else
 	{
+	  struct elf_link_hash_entry *weakdef = h->u.weakdef;
+
+	  while (h->root.type == bfd_link_hash_indirect)
+	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+	  BFD_ASSERT (h->root.type == bfd_link_hash_defined
+		      || h->root.type == bfd_link_hash_defweak);
+	  BFD_ASSERT (weakdef->def_dynamic);
 	  BFD_ASSERT (weakdef->root.type == bfd_link_hash_defined
 		      || weakdef->root.type == bfd_link_hash_defweak);
 	  (*bed->elf_backend_copy_indirect_symbol) (eif->info, weakdef, h);
@@ -2708,7 +2699,7 @@
   if ((h->root.type == bfd_link_hash_defined
        || h->root.type == bfd_link_hash_defweak)
       && ((sec = h->root.u.def.section)->flags & SEC_MERGE)
-      && sec->sec_info_type == ELF_INFO_TYPE_MERGE)
+      && sec->sec_info_type == SEC_INFO_TYPE_MERGE)
     {
       bfd *output_bfd = (bfd *) data;
 
@@ -3031,7 +3022,7 @@
     return FALSE;
 
   bed = get_elf_backend_data (hash_table->dynobj);
-  s = bfd_get_section_by_name (hash_table->dynobj, ".dynamic");
+  s = bfd_get_linker_section (hash_table->dynobj, ".dynamic");
   BFD_ASSERT (s != NULL);
 
   newsize = s->size + bed->s->sizeof_dyn;
@@ -3060,26 +3051,24 @@
 		       bfd_boolean do_it)
 {
   struct elf_link_hash_table *hash_table;
-  bfd_size_type oldsize;
   bfd_size_type strindex;
 
   if (!_bfd_elf_link_create_dynstrtab (abfd, info))
     return -1;
 
   hash_table = elf_hash_table (info);
-  oldsize = _bfd_elf_strtab_size (hash_table->dynstr);
   strindex = _bfd_elf_strtab_add (hash_table->dynstr, soname, FALSE);
   if (strindex == (bfd_size_type) -1)
     return -1;
 
-  if (oldsize == _bfd_elf_strtab_size (hash_table->dynstr))
+  if (_bfd_elf_strtab_refcount (hash_table->dynstr, strindex) != 1)
     {
       asection *sdyn;
       const struct elf_backend_data *bed;
       bfd_byte *extdyn;
 
       bed = get_elf_backend_data (hash_table->dynobj);
-      sdyn = bfd_get_section_by_name (hash_table->dynobj, ".dynamic");
+      sdyn = bfd_get_linker_section (hash_table->dynobj, ".dynamic");
       if (sdyn != NULL)
 	for (extdyn = sdyn->contents;
 	     extdyn < sdyn->contents + sdyn->size;
@@ -3122,7 +3111,7 @@
   return FALSE;
 }
 
-/* Sort symbol by value and section.  */
+/* Sort symbol by value, section, and size.  */
 static int
 elf_sort_symbol (const void *arg1, const void *arg2)
 {
@@ -3141,7 +3130,8 @@
       if (sdiff != 0)
 	return sdiff > 0 ? 1 : -1;
     }
-  return 0;
+  vdiff = h1->size - h2->size;
+  return vdiff == 0 ? 0 : vdiff > 0 ? 1 : -1;
 }
 
 /* This function is used to adjust offsets into .dynstr for
@@ -3176,7 +3166,7 @@
   size = _bfd_elf_strtab_size (dynstr);
 
   bed = get_elf_backend_data (dynobj);
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
   BFD_ASSERT (sdyn != NULL);
 
   /* Update all .dynamic entries referencing .dynstr strings.  */
@@ -3225,7 +3215,7 @@
       Elf_Internal_Verdef def;
       Elf_Internal_Verdaux defaux;
 
-      s = bfd_get_section_by_name (dynobj, ".gnu.version_d");
+      s = bfd_get_linker_section (dynobj, ".gnu.version_d");
       p = s->contents;
       do
 	{
@@ -3257,7 +3247,7 @@
       Elf_Internal_Verneed need;
       Elf_Internal_Vernaux needaux;
 
-      s = bfd_get_section_by_name (dynobj, ".gnu.version_r");
+      s = bfd_get_linker_section (dynobj, ".gnu.version_r");
       p = s->contents;
       do
 	{
@@ -3319,6 +3309,18 @@
   return ibed->relocs_compatible == obed->relocs_compatible;
 }
 
+/* Make a special call to the linker "notice" function to tell it that
+   we are about to handle an as-needed lib, or have finished
+   processing the lib.  */ 
+
+bfd_boolean
+_bfd_elf_notice_as_needed (bfd *ibfd,
+			   struct bfd_link_info *info,
+			   enum notice_asneeded_action act)
+{
+  return (*info->callbacks->notice) (info, NULL, ibfd, NULL, act, 0, NULL);
+}
+
 /* Add symbols from an ELF object file to the linker hash table.  */
 
 static bfd_boolean
@@ -3348,13 +3350,13 @@
   unsigned int old_size = 0;
   unsigned int old_count = 0;
   void *old_tab = NULL;
-  void *old_hash;
   void *old_ent;
   struct bfd_link_hash_entry *old_undefs = NULL;
   struct bfd_link_hash_entry *old_undefs_tail = NULL;
   long old_dynsymcount = 0;
+  bfd_size_type old_dynstr_size = 0;
   size_t tabsize = 0;
-  size_t hashsize = 0;
+  asection *s;
 
   htab = elf_hash_table (info);
   bed = get_elf_backend_data (abfd);
@@ -3396,75 +3398,64 @@
      symbol.  This differs from .gnu.warning sections, which generate
      warnings when they are included in an output file.  */
   /* PR 12761: Also generate this warning when building shared libraries.  */
-  if (info->executable || info->shared)
+  for (s = abfd->sections; s != NULL; s = s->next)
     {
-      asection *s;
+      const char *name;
 
-      for (s = abfd->sections; s != NULL; s = s->next)
+      name = bfd_get_section_name (abfd, s);
+      if (CONST_STRNEQ (name, ".gnu.warning."))
 	{
-	  const char *name;
+	  char *msg;
+	  bfd_size_type sz;
 
-	  name = bfd_get_section_name (abfd, s);
-	  if (CONST_STRNEQ (name, ".gnu.warning."))
+	  name += sizeof ".gnu.warning." - 1;
+
+	  /* If this is a shared object, then look up the symbol
+	     in the hash table.  If it is there, and it is already
+	     been defined, then we will not be using the entry
+	     from this shared object, so we don't need to warn.
+	     FIXME: If we see the definition in a regular object
+	     later on, we will warn, but we shouldn't.  The only
+	     fix is to keep track of what warnings we are supposed
+	     to emit, and then handle them all at the end of the
+	     link.  */
+	  if (dynamic)
 	    {
-	      char *msg;
-	      bfd_size_type sz;
+	      struct elf_link_hash_entry *h;
 
-	      name += sizeof ".gnu.warning." - 1;
+	      h = elf_link_hash_lookup (htab, name, FALSE, FALSE, TRUE);
 
-	      /* If this is a shared object, then look up the symbol
-		 in the hash table.  If it is there, and it is already
-		 been defined, then we will not be using the entry
-		 from this shared object, so we don't need to warn.
-		 FIXME: If we see the definition in a regular object
-		 later on, we will warn, but we shouldn't.  The only
-		 fix is to keep track of what warnings we are supposed
-		 to emit, and then handle them all at the end of the
-		 link.  */
-	      if (dynamic)
-		{
-		  struct elf_link_hash_entry *h;
+	      /* FIXME: What about bfd_link_hash_common?  */
+	      if (h != NULL
+		  && (h->root.type == bfd_link_hash_defined
+		      || h->root.type == bfd_link_hash_defweak))
+		continue;
+	    }
 
-		  h = elf_link_hash_lookup (htab, name, FALSE, FALSE, TRUE);
+	  sz = s->size;
+	  msg = (char *) bfd_alloc (abfd, sz + 1);
+	  if (msg == NULL)
+	    goto error_return;
 
-		  /* FIXME: What about bfd_link_hash_common?  */
-		  if (h != NULL
-		      && (h->root.type == bfd_link_hash_defined
-			  || h->root.type == bfd_link_hash_defweak))
-		    {
-		      /* We don't want to issue this warning.  Clobber
-			 the section size so that the warning does not
-			 get copied into the output file.  */
-		      s->size = 0;
-		      continue;
-		    }
-		}
+	  if (! bfd_get_section_contents (abfd, s, msg, 0, sz))
+	    goto error_return;
 
-	      sz = s->size;
-	      msg = (char *) bfd_alloc (abfd, sz + 1);
-	      if (msg == NULL)
-		goto error_return;
+	  msg[sz] = '\0';
 
-	      if (! bfd_get_section_contents (abfd, s, msg, 0, sz))
-		goto error_return;
+	  if (! (_bfd_generic_link_add_one_symbol
+		 (info, abfd, name, BSF_WARNING, s, 0, msg,
+		  FALSE, bed->collect, NULL)))
+	    goto error_return;
 
-	      msg[sz] = '\0';
+	  if (!info->relocatable && info->executable)
+	    {
+	      /* Clobber the section size so that the warning does
+		 not get copied into the output file.  */
+	      s->size = 0;
 
-	      if (! (_bfd_generic_link_add_one_symbol
-		     (info, abfd, name, BSF_WARNING, s, 0, msg,
-		      FALSE, bed->collect, NULL)))
-		goto error_return;
-
-	      if (! info->relocatable)
-		{
-		  /* Clobber the section size so that the warning does
-		     not get copied into the output file.  */
-		  s->size = 0;
-
-		  /* Also set SEC_EXCLUDE, so that symbols defined in
-		     the warning section don't get copied to the output.  */
-		  s->flags |= SEC_EXCLUDE;
-		}
+	      /* Also set SEC_EXCLUDE, so that symbols defined in
+		 the warning section don't get copied to the output.  */
+	      s->flags |= SEC_EXCLUDE;
 	    }
 	}
     }
@@ -3490,7 +3481,6 @@
     goto error_return;
   else
     {
-      asection *s;
       const char *soname = NULL;
       char *audit = NULL;
       struct bfd_link_needed_list *rpath = NULL, *runpath = NULL;
@@ -3499,7 +3489,7 @@
       /* ld --just-symbols and dynamic objects don't mix very well.
 	 ld shouldn't allow it.  */
       if ((s = abfd->sections) != NULL
-	  && s->sec_info_type == ELF_INFO_TYPE_JUST_SYMS)
+	  && s->sec_info_type == SEC_INFO_TYPE_JUST_SYMS)
 	abort ();
 
       /* If this dynamic lib was specified on the command line with
@@ -3680,7 +3670,7 @@
 	return TRUE;
 
       /* Save the DT_AUDIT entry for the linker emulation code. */
-      elf_dt_audit (abfd) = audit; 
+      elf_dt_audit (abfd) = audit;
     }
 
   /* If this is a dynamic object, we always link against the .dynsym
@@ -3709,7 +3699,7 @@
       extsymoff = hdr->sh_info;
     }
 
-  sym_hash = NULL;
+  sym_hash = elf_sym_hashes (abfd);
   if (extsymcount != 0)
     {
       isymbuf = bfd_elf_get_elf_syms (abfd, hdr, extsymcount, extsymoff,
@@ -3717,13 +3707,16 @@
       if (isymbuf == NULL)
 	goto error_return;
 
-      /* We store a pointer to the hash table entry for each external
-	 symbol.  */
-      amt = extsymcount * sizeof (struct elf_link_hash_entry *);
-      sym_hash = (struct elf_link_hash_entry **) bfd_alloc (abfd, amt);
       if (sym_hash == NULL)
-	goto error_free_sym;
-      elf_sym_hashes (abfd) = sym_hash;
+	{
+	  /* We store a pointer to the hash table entry for each
+	     external symbol.  */
+	  amt = extsymcount * sizeof (struct elf_link_hash_entry *);
+	  sym_hash = (struct elf_link_hash_entry **) bfd_zalloc (abfd, amt);
+	  if (sym_hash == NULL)
+	    goto error_free_sym;
+	  elf_sym_hashes (abfd) = sym_hash;
+	}
     }
 
   if (dynamic)
@@ -3773,8 +3766,7 @@
 	}
 
       tabsize = htab->root.table.size * sizeof (struct bfd_hash_entry *);
-      hashsize = extsymcount * sizeof (struct elf_link_hash_entry *);
-      old_tab = bfd_malloc (tabsize + entsize + hashsize);
+      old_tab = bfd_malloc (tabsize + entsize);
       if (old_tab == NULL)
 	goto error_free_vers;
 
@@ -3786,22 +3778,20 @@
 
       /* Make a special call to the linker "notice" function to
 	 tell it that we are about to handle an as-needed lib.  */
-      if (!(*info->callbacks->notice) (info, NULL, abfd, NULL,
-				       notice_as_needed, 0, NULL))
+      if (!(*bed->notice_as_needed) (abfd, info, notice_as_needed))
 	goto error_free_vers;
 
-      /* Clone the symbol table and sym hashes.  Remember some
-	 pointers into the symbol table, and dynamic symbol count.  */
-      old_hash = (char *) old_tab + tabsize;
-      old_ent = (char *) old_hash + hashsize;
+      /* Clone the symbol table.  Remember some pointers into the
+	 symbol table, and dynamic symbol count.  */
+      old_ent = (char *) old_tab + tabsize;
       memcpy (old_tab, htab->root.table.table, tabsize);
-      memcpy (old_hash, sym_hash, hashsize);
       old_undefs = htab->root.undefs;
       old_undefs_tail = htab->root.undefs_tail;
       old_table = htab->root.table.table;
       old_size = htab->root.table.size;
       old_count = htab->root.table.count;
       old_dynsymcount = htab->dynsymcount;
+      old_dynstr_size = _bfd_elf_strtab_size (htab->dynstr);
 
       for (i = 0; i < htab->root.table.size; i++)
 	{
@@ -3834,22 +3824,23 @@
       flagword flags;
       const char *name;
       struct elf_link_hash_entry *h;
+      struct elf_link_hash_entry *hi;
       bfd_boolean definition;
       bfd_boolean size_change_ok;
       bfd_boolean type_change_ok;
       bfd_boolean new_weakdef;
+      bfd_boolean new_weak;
+      bfd_boolean old_weak;
       bfd_boolean override;
       bfd_boolean common;
       unsigned int old_alignment;
       bfd *old_bfd;
-      bfd * undef_bfd = NULL;
 
       override = FALSE;
 
       flags = BSF_NO_FLAGS;
       sec = NULL;
       value = isym->st_value;
-      *sym_hash = NULL;
       common = bed->common_definition (isym);
 
       bind = ELF_ST_BIND (isym->st_info);
@@ -3896,7 +3887,7 @@
 	  sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
 	  if (sec == NULL)
 	    sec = bfd_abs_section_ptr;
-	  else if (elf_discarded_section (sec))
+	  else if (discarded_section (sec))
 	    {
 	      /* Symbols from discarded section are undefined.  We keep
 		 its visibility.  */
@@ -3962,6 +3953,13 @@
 	  goto error_free_vers;
 	}
 
+      /* Silently discard TLS symbols from --just-syms.  There's
+	 no way to combine a static TLS block with a new TLS block
+	 for this executable.  */
+      if (ELF_ST_TYPE (isym->st_info) == STT_TLS
+	  && sec->sec_info_type == SEC_INFO_TYPE_JUST_SYMS)
+	continue;
+
       if (bfd_is_und_section (sec)
 	  || bfd_is_com_section (sec))
 	definition = FALSE;
@@ -3970,6 +3968,7 @@
 
       size_change_ok = FALSE;
       type_change_ok = bed->type_change_ok;
+      old_weak = FALSE;
       old_alignment = 0;
       old_bfd = NULL;
       new_sec = sec;
@@ -3980,20 +3979,6 @@
 	  unsigned int vernum = 0;
 	  bfd_boolean skip;
 
-	  /* If this is a definition of a symbol which was previously
-	     referenced in a non-weak manner then make a note of the bfd
-	     that contained the reference.  This is used if we need to
-	     refer to the source of the reference later on.  */
-	  if (! bfd_is_und_section (sec))
-	    {
-	      h = elf_link_hash_lookup (elf_hash_table (info), name, FALSE, FALSE, FALSE);
-
-	      if (h != NULL
-		  && h->root.type == bfd_link_hash_undefined
-		  && h->root.u.undef.abfd)
-		undef_bfd = h->root.u.undef.abfd;
-	    }
-	  
 	  if (ever == NULL)
 	    {
 	      if (info->default_imported_symver)
@@ -4101,22 +4086,9 @@
 	      name = newname;
 	    }
 
-	  /* If necessary, make a second attempt to locate the bfd
-	     containing an unresolved, non-weak reference to the
-	     current symbol.  */
-	  if (! bfd_is_und_section (sec) && undef_bfd == NULL)
-	    {
-	      h = elf_link_hash_lookup (elf_hash_table (info), name, FALSE, FALSE, FALSE);
-
-	      if (h != NULL
-		  && h->root.type == bfd_link_hash_undefined
-		  && h->root.u.undef.abfd)
-		undef_bfd = h->root.u.undef.abfd;
-	    }
-
-	  if (!_bfd_elf_merge_symbol (abfd, info, name, isym, &sec,
-				      &value, &old_alignment,
-				      sym_hash, &skip, &override,
+	  if (!_bfd_elf_merge_symbol (abfd, info, name, isym, &sec, &value,
+				      sym_hash, &old_bfd, &old_weak,
+				      &old_alignment, &skip, &override,
 				      &type_change_ok, &size_change_ok))
 	    goto error_free_vers;
 
@@ -4131,30 +4103,7 @@
 		 || h->root.type == bfd_link_hash_warning)
 	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
 
-	  /* Remember the old alignment if this is a common symbol, so
-	     that we don't reduce the alignment later on.  We can't
-	     check later, because _bfd_generic_link_add_one_symbol
-	     will set a default for the alignment which we want to
-	     override. We also remember the old bfd where the existing
-	     definition comes from.  */
-	  switch (h->root.type)
-	    {
-	    default:
-	      break;
-
-	    case bfd_link_hash_defined:
-	    case bfd_link_hash_defweak:
-	      old_bfd = h->root.u.def.section->owner;
-	      break;
-
-	    case bfd_link_hash_common:
-	      old_bfd = h->root.u.c.p->section->owner;
-	      old_alignment = h->root.u.c.p->alignment_power;
-	      break;
-	    }
-
 	  if (elf_tdata (abfd)->verdef != NULL
-	      && ! override
 	      && vernum > 1
 	      && definition)
 	    h->verinfo.verdef = &elf_tdata (abfd)->verdef[vernum - 1];
@@ -4166,18 +4115,20 @@
 	goto error_free_vers;
 
       h = *sym_hash;
+      /* We need to make sure that indirect symbol dynamic flags are
+	 updated.  */
+      hi = h;
       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_hash = h;
-      if (is_elf_hash_table (htab))
-	h->unique_global = (flags & BSF_GNU_UNIQUE) != 0;
 
+      new_weak = (flags & BSF_WEAK) != 0;
       new_weakdef = FALSE;
       if (dynamic
 	  && definition
-	  && (flags & BSF_WEAK) != 0
+	  && new_weak
 	  && !bed->is_function_type (ELF_ST_TYPE (isym->st_info))
 	  && is_elf_hash_table (htab)
 	  && h->u.weakdef == NULL)
@@ -4221,7 +4172,73 @@
 
       if (is_elf_hash_table (htab))
 	{
-	  bfd_boolean dynsym;
+	  /* Set a flag in the hash table entry indicating the type of
+	     reference or definition we just found.  A dynamic symbol
+	     is one which is referenced or defined by both a regular
+	     object and a shared object.  */
+	  bfd_boolean dynsym = FALSE;
+
+	  /* Plugin symbols aren't normal.  Don't set def_regular or
+	     ref_regular for them, or make them dynamic.  */
+	  if ((abfd->flags & BFD_PLUGIN) != 0)
+	    ;
+	  else if (! dynamic)
+	    {
+	      if (! definition)
+		{
+		  h->ref_regular = 1;
+		  if (bind != STB_WEAK)
+		    h->ref_regular_nonweak = 1;
+		}
+	      else
+		{
+		  h->def_regular = 1;
+		  if (h->def_dynamic)
+		    {
+		      h->def_dynamic = 0;
+		      h->ref_dynamic = 1;
+		    }
+		}
+
+	      /* If the indirect symbol has been forced local, don't
+		 make the real symbol dynamic.  */
+	      if ((h == hi || !hi->forced_local)
+		  && (! info->executable
+		      || h->def_dynamic
+		      || h->ref_dynamic))
+		dynsym = TRUE;
+	    }
+	  else
+	    {
+	      if (! definition)
+		{
+		  h->ref_dynamic = 1;
+		  hi->ref_dynamic = 1;
+		}
+	      else
+		{
+		  h->def_dynamic = 1;
+		  hi->def_dynamic = 1;
+		}
+
+	      /* If the indirect symbol has been forced local, don't
+		 make the real symbol dynamic.  */
+	      if ((h == hi || !hi->forced_local)
+		  && (h->def_regular
+		      || h->ref_regular
+		      || (h->u.weakdef != NULL
+			  && ! new_weakdef
+			  && h->u.weakdef->dynindx != -1)))
+		dynsym = TRUE;
+	    }
+
+	  /* Check to see if we need to add an indirect symbol for
+	     the default name.  */
+	  if (definition
+	      || (!override && h->root.type == bfd_link_hash_common))
+	    if (!_bfd_elf_add_default_symbol (abfd, info, h, name, isym,
+					      sec, value, &old_bfd, &dynsym))
+	      goto error_free_vers;
 
 	  /* Check the alignment when a common symbol is involved. This
 	     can change when a common symbol is overridden by a normal
@@ -4237,6 +4254,9 @@
 	      bfd *normal_bfd;
 	      bfd *common_bfd;
 
+	      BFD_ASSERT (h->root.type == bfd_link_hash_defined
+			  || h->root.type == bfd_link_hash_defweak);
+
 	      symbol_align = ffs (h->root.u.def.value) - 1;
 	      if (h->root.u.def.section->owner != NULL
 		  && (h->root.u.def.section->owner->flags & DYNAMIC) == 0)
@@ -4266,8 +4286,8 @@
 		  /* PR binutils/2735 */
 		  if (normal_bfd == NULL)
 		    (*_bfd_error_handler)
-		      (_("Warning: alignment %u of common symbol `%s' in %B"
-			 " is greater than the alignment (%u) of its section %A"),
+		      (_("Warning: alignment %u of common symbol `%s' in %B is"
+			 " greater than the alignment (%u) of its section %A"),
 		       common_bfd, h->root.u.def.section,
 		       1 << common_align, name, 1 << normal_align);
 		  else
@@ -4280,7 +4300,8 @@
 	    }
 
 	  /* Remember the symbol size if it isn't undefined.  */
-	  if ((isym->st_size != 0 && isym->st_shndx != SHN_UNDEF)
+	  if (isym->st_size != 0
+	      && isym->st_shndx != SHN_UNDEF
 	      && (definition || h->size == 0))
 	    {
 	      if (h->size != 0
@@ -4300,13 +4321,15 @@
 	     to be the size of the common symbol.  The code just above
 	     won't fix the size if a common symbol becomes larger.  We
 	     don't warn about a size change here, because that is
-	     covered by --warn-common.  Allow changed between different
+	     covered by --warn-common.  Allow changes between different
 	     function types.  */
 	  if (h->root.type == bfd_link_hash_common)
 	    h->size = h->root.u.c.size;
 
 	  if (ELF_ST_TYPE (isym->st_info) != STT_NOTYPE
-	      && (definition || h->type == STT_NOTYPE))
+	      && ((definition && !new_weak)
+		  || (old_weak && h->root.type == bfd_link_hash_common)
+		  || h->type == STT_NOTYPE))
 	    {
 	      unsigned int type = ELF_ST_TYPE (isym->st_info);
 
@@ -4331,51 +4354,6 @@
 	  /* Merge st_other field.  */
 	  elf_merge_st_other (abfd, h, isym, definition, dynamic);
 
-	  /* Set a flag in the hash table entry indicating the type of
-	     reference or definition we just found.  Keep a count of
-	     the number of dynamic symbols we find.  A dynamic symbol
-	     is one which is referenced or defined by both a regular
-	     object and a shared object.  */
-	  dynsym = FALSE;
-	  if (! dynamic)
-	    {
-	      if (! definition)
-		{
-		  h->ref_regular = 1;
-		  if (bind != STB_WEAK)
-		    h->ref_regular_nonweak = 1;
-		}
-	      else
-		{
-		  h->def_regular = 1;
-		  if (h->def_dynamic)
-		    {
-		      h->def_dynamic = 0;
-		      h->ref_dynamic = 1;
-		    }
-		}
-	      if (! info->executable
-		  || h->def_dynamic
-		  || h->ref_dynamic)
-		dynsym = TRUE;
-	    }
-	  else
-	    {
-	      if (! definition)
-		h->ref_dynamic = 1;
-	      else
-		{
-		  h->def_dynamic = 1;
-		  h->dynamic_def = 1;
-		}
-	      if (h->def_regular
-		  || h->ref_regular
-		  || (h->u.weakdef != NULL
-		      && ! new_weakdef
-		      && h->u.weakdef->dynindx != -1))
-		dynsym = TRUE;
-	    }
-
 	  /* We don't want to make debug symbol dynamic.  */
 	  if (definition && (sec->flags & SEC_DEBUGGING) && !info->relocatable)
 	    dynsym = FALSE;
@@ -4385,15 +4363,10 @@
 	    dynsym = FALSE;
 
 	  if (definition)
-	    h->target_internal = isym->st_target_internal;
-
-	  /* Check to see if we need to add an indirect symbol for
-	     the default name.  */
-	  if (definition || h->root.type == bfd_link_hash_common)
-	    if (!_bfd_elf_add_default_symbol (abfd, info, h, name, isym,
-					      &sec, &value, &dynsym,
-					      override))
-	      goto error_free_vers;
+	    {
+	      h->target_internal = isym->st_target_internal;
+	      h->unique_global = (flags & BSF_GNU_UNIQUE) != 0;
+	    }
 
 	  if (definition && !dynamic)
 	    {
@@ -4440,11 +4413,14 @@
 		break;
 	      }
 
+	  /* Don't add DT_NEEDED for references from the dummy bfd.  */
 	  if (!add_needed
 	      && definition
 	      && ((dynsym
-		   && h->ref_regular)
-		  || (h->ref_dynamic
+		   && h->ref_regular_nonweak
+		   && (old_bfd == NULL
+		       || (old_bfd->flags & BFD_PLUGIN) == 0))
+		  || (h->ref_dynamic_nonweak
 		      && (elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0
 		      && !on_needed_list (elf_dt_name (abfd), htab->needed))))
 	    {
@@ -4456,16 +4432,13 @@
 		 Add a DT_NEEDED entry for it.  Issue an error if
 		 --no-add-needed is used and the reference was not
 		 a weak one.  */
-	      if (undef_bfd != NULL
+	      if (old_bfd != NULL
 		  && (elf_dyn_lib_class (abfd) & DYN_NO_NEEDED) != 0)
 		{
 		  (*_bfd_error_handler)
 		    (_("%B: undefined reference to symbol '%s'"),
-		     undef_bfd, name);
-		  (*_bfd_error_handler)
-		    (_("note: '%s' is defined in DSO %B so try adding it to the linker command line"),
-		     abfd, name);
-		  bfd_set_error (bfd_error_invalid_operation);
+		     old_bfd, name);
+		  bfd_set_error (bfd_error_missing_dso);
 		  goto error_free_vers;
 		}
 
@@ -4499,18 +4472,16 @@
       unsigned int i;
 
       /* Restore the symbol table.  */
-      if (bed->as_needed_cleanup)
-	(*bed->as_needed_cleanup) (abfd, info);
-      old_hash = (char *) old_tab + tabsize;
-      old_ent = (char *) old_hash + hashsize;
-      sym_hash = elf_sym_hashes (abfd);
+      old_ent = (char *) old_tab + tabsize;
+      memset (elf_sym_hashes (abfd), 0,
+	      extsymcount * sizeof (struct elf_link_hash_entry *));
       htab->root.table.table = old_table;
       htab->root.table.size = old_size;
       htab->root.table.count = old_count;
       memcpy (htab->root.table.table, old_tab, tabsize);
-      memcpy (sym_hash, old_hash, hashsize);
       htab->root.undefs = old_undefs;
       htab->root.undefs_tail = old_undefs_tail;
+      _bfd_elf_strtab_restore_size (htab->dynstr, old_dynstr_size);
       for (i = 0; i < htab->root.table.size; i++)
 	{
 	  struct bfd_hash_entry *p;
@@ -4523,12 +4494,13 @@
 	      h = (struct elf_link_hash_entry *) p;
 	      if (h->root.type == bfd_link_hash_warning)
 		h = (struct elf_link_hash_entry *) h->root.u.i.link;
-	      if (h->dynindx >= old_dynsymcount)
+	      if (h->dynindx >= old_dynsymcount
+		  && h->dynstr_index < old_dynstr_size)
 		_bfd_elf_strtab_delref (htab->dynstr, h->dynstr_index);
 
 	      /* Preserve the maximum alignment and size for common
 		 symbols even if this dynamic lib isn't on DT_NEEDED
-		 since it can still be loaded at the run-time by another
+		 since it can still be loaded at run time by another
 		 dynamic lib.  */
 	      if (h->root.type == bfd_link_hash_common)
 		{
@@ -4547,8 +4519,9 @@
 		{
 		  memcpy (h->root.u.i.link, old_ent, htab->root.table.entsize);
 		  old_ent = (char *) old_ent + htab->root.table.entsize;
+		  h = (struct elf_link_hash_entry *) h->root.u.i.link;
 		}
-	      else if (h->root.type == bfd_link_hash_common)
+	      if (h->root.type == bfd_link_hash_common)
 		{
 		  if (size > h->root.u.c.size)
 		    h->root.u.c.size = size;
@@ -4560,8 +4533,7 @@
 
       /* Make a special call to the linker "notice" function to
 	 tell it that symbols added for crefs may need to be removed.  */
-      if (!(*info->callbacks->notice) (info, NULL, abfd, NULL,
-				       notice_not_needed, 0, NULL))
+      if (!(*bed->notice_as_needed) (abfd, info, notice_not_needed))
 	goto error_free_vers;
 
       free (old_tab);
@@ -4574,8 +4546,7 @@
 
   if (old_tab != NULL)
     {
-      if (!(*info->callbacks->notice) (info, NULL, abfd, NULL,
-				       notice_needed, 0, NULL))
+      if (!(*bed->notice_as_needed) (abfd, info, notice_needed))
 	goto error_free_vers;
       free (old_tab);
       old_tab = NULL;
@@ -4686,8 +4657,7 @@
 	  struct elf_link_hash_entry *hlook;
 	  asection *slook;
 	  bfd_vma vlook;
-	  long ilook;
-	  size_t i, j, idx;
+	  size_t i, j, idx = 0;
 
 	  hlook = weaks;
 	  weaks = hlook->u.weakdef;
@@ -4700,14 +4670,13 @@
 	  slook = hlook->root.u.def.section;
 	  vlook = hlook->root.u.def.value;
 
-	  ilook = -1;
 	  i = 0;
 	  j = sym_count;
-	  while (i < j)
+	  while (i != j)
 	    {
 	      bfd_signed_vma vdiff;
 	      idx = (i + j) / 2;
-	      h = sorted_sym_hash [idx];
+	      h = sorted_sym_hash[idx];
 	      vdiff = vlook - h->root.u.def.value;
 	      if (vdiff < 0)
 		j = idx;
@@ -4721,24 +4690,36 @@
 		  else if (sdiff > 0)
 		    i = idx + 1;
 		  else
-		    {
-		      ilook = idx;
-		      break;
-		    }
+		    break;
 		}
 	    }
 
 	  /* We didn't find a value/section match.  */
-	  if (ilook == -1)
+	  if (i == j)
 	    continue;
 
-	  for (i = ilook; i < sym_count; i++)
+	  /* With multiple aliases, or when the weak symbol is already
+	     strongly defined, we have multiple matching symbols and
+	     the binary search above may land on any of them.  Step
+	     one past the matching symbol(s).  */
+	  while (++idx != j)
 	    {
-	      h = sorted_sym_hash [i];
+	      h = sorted_sym_hash[idx];
+	      if (h->root.u.def.section != slook
+		  || h->root.u.def.value != vlook)
+		break;
+	    }
+
+	  /* Now look back over the aliases.  Since we sorted by size
+	     as well as value and section, we'll choose the one with
+	     the largest size.  */
+	  while (idx-- != i)
+	    {
+	      h = sorted_sym_hash[idx];
 
 	      /* Stop if value or section doesn't match.  */
-	      if (h->root.u.def.value != vlook
-		  || h->root.u.def.section != slook)
+	      if (h->root.u.def.section != slook
+		  || h->root.u.def.value != vlook)
 		break;
 	      else if (h != hlook)
 		{
@@ -4861,7 +4842,7 @@
 					       &string_offset))
 		  goto error_return;
 		if (secdata->sec_info)
-		  stab->sec_info_type = ELF_INFO_TYPE_STABS;
+		  stab->sec_info_type = SEC_INFO_TYPE_STABS;
 	    }
 	}
     }
@@ -5502,6 +5483,65 @@
   return TRUE;
 }
 
+/* Set a default stack segment size.  The value in INFO wins.  If it
+   is unset, LEGACY_SYMBOL's value is used, and if that symbol is
+   undefined it is initialized.  */
+
+bfd_boolean
+bfd_elf_stack_segment_size (bfd *output_bfd,
+			    struct bfd_link_info *info,
+			    const char *legacy_symbol,
+			    bfd_vma default_size)
+{
+  struct elf_link_hash_entry *h = NULL;
+
+  /* Look for legacy symbol.  */
+  if (legacy_symbol)
+    h = elf_link_hash_lookup (elf_hash_table (info), legacy_symbol,
+			      FALSE, FALSE, FALSE);
+  if (h && (h->root.type == bfd_link_hash_defined
+	    || h->root.type == bfd_link_hash_defweak)
+      && h->def_regular
+      && (h->type == STT_NOTYPE || h->type == STT_OBJECT))
+    {
+      /* The symbol has no type if specified on the command line.  */
+      h->type = STT_OBJECT;
+      if (info->stacksize)
+	(*_bfd_error_handler) (_("%B: stack size specified and %s set"),
+			       output_bfd, legacy_symbol);
+      else if (h->root.u.def.section != bfd_abs_section_ptr)
+	(*_bfd_error_handler) (_("%B: %s not absolute"),
+			       output_bfd, legacy_symbol);
+      else
+	info->stacksize = h->root.u.def.value;
+    }
+
+  if (!info->stacksize)
+    /* If the user didn't set a size, or explicitly inhibit the
+       size, set it now.  */
+    info->stacksize = default_size;
+
+  /* Provide the legacy symbol, if it is referenced.  */
+  if (h && (h->root.type == bfd_link_hash_undefined
+	    || h->root.type == bfd_link_hash_undefweak))
+    {
+      struct bfd_link_hash_entry *bh = NULL;
+
+      if (!(_bfd_generic_link_add_one_symbol
+	    (info, output_bfd, legacy_symbol,
+	     BSF_GLOBAL, bfd_abs_section_ptr,
+	     info->stacksize >= 0 ? info->stacksize : 0,
+	     NULL, FALSE, get_elf_backend_data (output_bfd)->collect, &bh)))
+	return FALSE;
+
+      h = (struct elf_link_hash_entry *) bh;
+      h->def_regular = 1;
+      h->type = STT_OBJECT;
+    }
+
+  return TRUE;
+}
+
 /* Set up the sizes and contents of the ELF dynamic sections.  This is
    called by the ELF linker emulation before_allocation routine.  We
    must set the sizes of the sections before the linker sets the
@@ -5531,10 +5571,30 @@
     return TRUE;
 
   bed = get_elf_backend_data (output_bfd);
+
+  /* Any syms created from now on start with -1 in
+     got.refcount/offset and plt.refcount/offset.  */
+  elf_hash_table (info)->init_got_refcount
+    = elf_hash_table (info)->init_got_offset;
+  elf_hash_table (info)->init_plt_refcount
+    = elf_hash_table (info)->init_plt_offset;
+
+  if (info->relocatable
+      && !_bfd_elf_size_group_sections (info))
+    return FALSE;
+
+  /* The backend may have to create some sections regardless of whether
+     we're dynamic or not.  */
+  if (bed->elf_backend_always_size_sections
+      && ! (*bed->elf_backend_always_size_sections) (output_bfd, info))
+    return FALSE;
+
+  /* Determine any GNU_STACK segment requirements, after the backend
+     has had a chance to set a default segment size.  */
   if (info->execstack)
-    elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X;
+    elf_stack_flags (output_bfd) = PF_R | PF_W | PF_X;
   else if (info->noexecstack)
-    elf_tdata (output_bfd)->stack_flags = PF_R | PF_W;
+    elf_stack_flags (output_bfd) = PF_R | PF_W;
   else
     {
       bfd *inputobj;
@@ -5560,43 +5620,16 @@
 	  else if (bed->default_execstack)
 	    exec = PF_X;
 	}
-      if (notesec)
-	{
-	  elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | exec;
-	  if (exec && info->relocatable
-	      && notesec->output_section != bfd_abs_section_ptr)
-	    notesec->output_section->flags |= SEC_CODE;
-	}
+      if (notesec || info->stacksize > 0)
+	elf_stack_flags (output_bfd) = PF_R | PF_W | exec;
+      if (notesec && exec && info->relocatable
+	  && notesec->output_section != bfd_abs_section_ptr)
+	notesec->output_section->flags |= SEC_CODE;
     }
 
-  /* Any syms created from now on start with -1 in
-     got.refcount/offset and plt.refcount/offset.  */
-  elf_hash_table (info)->init_got_refcount
-    = elf_hash_table (info)->init_got_offset;
-  elf_hash_table (info)->init_plt_refcount
-    = elf_hash_table (info)->init_plt_offset;
-
-  if (info->relocatable
-      && !_bfd_elf_size_group_sections (info))
-    return FALSE;
-
-  /* The backend may have to create some sections regardless of whether
-     we're dynamic or not.  */
-  if (bed->elf_backend_always_size_sections
-      && ! (*bed->elf_backend_always_size_sections) (output_bfd, info))
-    return FALSE;
-
-  if (! _bfd_elf_maybe_strip_eh_frame_hdr (info))
-    return FALSE;
-
   dynobj = elf_hash_table (info)->dynobj;
 
-  /* If there were no dynamic objects in the link, there is nothing to
-     do here.  */
-  if (dynobj == NULL)
-    return TRUE;
-
-  if (elf_hash_table (info)->dynamic_sections_created)
+  if (dynobj != NULL && elf_hash_table (info)->dynamic_sections_created)
     {
       struct elf_info_failed eif;
       struct elf_link_hash_entry *h;
@@ -5606,7 +5639,7 @@
       asection *s;
       bfd_boolean all_defined;
 
-      *sinterpptr = bfd_get_section_by_name (dynobj, ".interp");
+      *sinterpptr = bfd_get_linker_section (dynobj, ".interp");
       BFD_ASSERT (*sinterpptr != NULL || !info->executable);
 
       if (soname != NULL)
@@ -5628,19 +5661,16 @@
       if (rpath != NULL)
 	{
 	  bfd_size_type indx;
+	  bfd_vma tag;
 
 	  indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, rpath,
 				      TRUE);
-	  if (indx == (bfd_size_type) -1
-	      || !_bfd_elf_add_dynamic_entry (info, DT_RPATH, indx))
+	  if (indx == (bfd_size_type) -1)
 	    return FALSE;
 
-	  if  (info->new_dtags)
-	    {
-	      _bfd_elf_strtab_addref (elf_hash_table (info)->dynstr, indx);
-	      if (!_bfd_elf_add_dynamic_entry (info, DT_RUNPATH, indx))
-		return FALSE;
-	    }
+	  tag = info->new_dtags ? DT_RUNPATH : DT_RPATH;
+	  if (!_bfd_elf_add_dynamic_entry (info, tag, indx))
+	    return FALSE;
 	}
 
       if (filter_shlib != NULL)
@@ -5874,7 +5904,7 @@
 	    return FALSE;
 	}
 
-      dynstr = bfd_get_section_by_name (dynobj, ".dynstr");
+      dynstr = bfd_get_linker_section (dynobj, ".dynstr");
       /* If .dynstr is excluded from the link, we don't want any of
 	 these tags.  Strictly, we should be checking each section
 	 individually;  This quick check covers for the case where
@@ -5899,18 +5929,22 @@
 
   /* The backend must work out the sizes of all the other dynamic
      sections.  */
-  if (bed->elf_backend_size_dynamic_sections
+  if (dynobj != NULL
+      && bed->elf_backend_size_dynamic_sections != NULL
       && ! (*bed->elf_backend_size_dynamic_sections) (output_bfd, info))
     return FALSE;
 
-  if (elf_hash_table (info)->dynamic_sections_created)
+  if (! _bfd_elf_maybe_strip_eh_frame_hdr (info))
+    return FALSE;
+
+  if (dynobj != NULL && elf_hash_table (info)->dynamic_sections_created)
     {
       unsigned long section_sym_count;
       struct bfd_elf_version_tree *verdefs;
       asection *s;
 
       /* Set up the version definition section.  */
-      s = bfd_get_section_by_name (dynobj, ".gnu.version_d");
+      s = bfd_get_linker_section (dynobj, ".gnu.version_d");
       BFD_ASSERT (s != NULL);
 
       /* We may have created additional version definitions if we are
@@ -6173,7 +6207,7 @@
 
       /* Work out the size of the version reference section.  */
 
-      s = bfd_get_section_by_name (dynobj, ".gnu.version_r");
+      s = bfd_get_linker_section (dynobj, ".gnu.version_r");
       BFD_ASSERT (s != NULL);
       {
 	struct elf_find_verdep_info sinfo;
@@ -6285,7 +6319,7 @@
 	  || _bfd_elf_link_renumber_dynsyms (output_bfd, info,
 					     &section_sym_count) == 0)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".gnu.version");
+	  s = bfd_get_linker_section (dynobj, ".gnu.version");
 	  s->flags |= SEC_EXCLUDE;
 	}
     }
@@ -6369,7 +6403,7 @@
 						    &section_sym_count);
 
       /* Work out the size of the symbol version section.  */
-      s = bfd_get_section_by_name (dynobj, ".gnu.version");
+      s = bfd_get_linker_section (dynobj, ".gnu.version");
       BFD_ASSERT (s != NULL);
       if (dynsymcount != 0
 	  && (s->flags & SEC_EXCLUDE) == 0)
@@ -6389,7 +6423,7 @@
 	 the final symbol table, because until then we do not know the
 	 correct value to give the symbols.  We built the .dynstr
 	 section as we went along in elf_link_add_object_symbols.  */
-      s = bfd_get_section_by_name (dynobj, ".dynsym");
+      s = bfd_get_linker_section (dynobj, ".dynsym");
       BFD_ASSERT (s != NULL);
       s->size = dynsymcount * bed->s->sizeof_sym;
 
@@ -6447,7 +6481,7 @@
 
 	  elf_hash_table (info)->bucketcount = bucketcount;
 
-	  s = bfd_get_section_by_name (dynobj, ".hash");
+	  s = bfd_get_linker_section (dynobj, ".hash");
 	  BFD_ASSERT (s != NULL);
 	  hash_entry_size = elf_section_data (s)->this_hdr.sh_entsize;
 	  s->size = ((2 + bucketcount + dynsymcount) * hash_entry_size);
@@ -6501,7 +6535,7 @@
 	      return FALSE;
 	    }
 
-	  s = bfd_get_section_by_name (dynobj, ".gnu.hash");
+	  s = bfd_get_linker_section (dynobj, ".gnu.hash");
 	  BFD_ASSERT (s != NULL);
 
 	  if (cinfo.nsyms == 0)
@@ -6629,7 +6663,7 @@
 	    }
 	}
 
-      s = bfd_get_section_by_name (dynobj, ".dynstr");
+      s = bfd_get_linker_section (dynobj, ".dynstr");
       BFD_ASSERT (s != NULL);
 
       elf_finalize_dynstr (output_bfd, info);
@@ -6644,25 +6678,14 @@
   return TRUE;
 }
 
-/* Indicate that we are only retrieving symbol values from this
-   section.  */
-
-void
-_bfd_elf_link_just_syms (asection *sec, struct bfd_link_info *info)
-{
-  if (is_elf_hash_table (info->hash))
-    sec->sec_info_type = ELF_INFO_TYPE_JUST_SYMS;
-  _bfd_generic_link_just_syms (sec, info);
-}
-
 /* Make sure sec_info_type is cleared if sec_info is cleared too.  */
 
 static void
 merge_sections_remove_hook (bfd *abfd ATTRIBUTE_UNUSED,
 			    asection *sec)
 {
-  BFD_ASSERT (sec->sec_info_type == ELF_INFO_TYPE_MERGE);
-  sec->sec_info_type = ELF_INFO_TYPE_NONE;
+  BFD_ASSERT (sec->sec_info_type == SEC_INFO_TYPE_MERGE);
+  sec->sec_info_type = SEC_INFO_TYPE_NONE;
 }
 
 /* Finish SHF_MERGE section merging.  */
@@ -6690,7 +6713,7 @@
 					  sec, &secdata->sec_info))
 	      return FALSE;
 	    else if (secdata->sec_info)
-	      sec->sec_info_type = ELF_INFO_TYPE_MERGE;
+	      sec->sec_info_type = SEC_INFO_TYPE_MERGE;
 	  }
 
   if (elf_hash_table (info)->merge_info != NULL)
@@ -6816,7 +6839,8 @@
     }
 }
 
-/* Initialize an ELF linker hash table.  */
+/* Initialize an ELF linker hash table.  *TABLE has been zeroed by our
+   caller.  */
 
 bfd_boolean
 _bfd_elf_link_hash_table_init
@@ -6831,7 +6855,6 @@
   bfd_boolean ret;
   int can_refcount = get_elf_backend_data (abfd)->can_refcount;
 
-  memset (table, 0, sizeof * table);
   table->init_got_refcount.refcount = can_refcount - 1;
   table->init_plt_refcount.refcount = can_refcount - 1;
   table->init_got_offset.offset = -(bfd_vma) 1;
@@ -6855,7 +6878,7 @@
   struct elf_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct elf_link_hash_table);
 
-  ret = (struct elf_link_hash_table *) bfd_malloc (amt);
+  ret = (struct elf_link_hash_table *) bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
 
@@ -6870,6 +6893,18 @@
   return &ret->root;
 }
 
+/* Destroy an ELF linker hash table.  */
+
+void
+_bfd_elf_link_hash_table_free (struct bfd_link_hash_table *hash)
+{
+  struct elf_link_hash_table *htab = (struct elf_link_hash_table *) hash;
+  if (htab->dynstr != NULL)
+    _bfd_elf_strtab_free (htab->dynstr);
+  _bfd_merge_sections_free (htab->merge_info);
+  _bfd_generic_link_hash_table_free (hash);
+}
+
 /* This is a hook for the ELF emulation code in the generic linker to
    tell the backend linker what file name to use for the DT_NEEDED
    entry for a dynamic object.  */
@@ -7413,6 +7448,8 @@
   size_t symbuf_size;
   /* And same for symshndxbuf.  */
   size_t shndxbuf_size;
+  /* Number of STT_FILE syms seen.  */
+  size_t filesym_count;
 };
 
 /* This struct is used to pass information to elf_link_output_extsym.  */
@@ -7421,7 +7458,9 @@
 {
   bfd_boolean failed;
   bfd_boolean localsyms;
-  struct elf_final_link_info *finfo;
+  bfd_boolean need_second_pass;
+  bfd_boolean second_pass;
+  struct elf_final_link_info *flinfo;
 };
 
 
@@ -7498,7 +7537,7 @@
 static bfd_boolean
 resolve_symbol (const char *name,
 		bfd *input_bfd,
-		struct elf_final_link_info *finfo,
+		struct elf_final_link_info *flinfo,
 		bfd_vma *result,
 		Elf_Internal_Sym *isymbuf,
 		size_t locsymcount)
@@ -7527,7 +7566,7 @@
 #endif
       if (candidate && strcmp (candidate, name) == 0)
 	{
-	  asection *sec = finfo->sections [i];
+	  asection *sec = flinfo->sections [i];
 
 	  *result = _bfd_elf_rel_local_sym (input_bfd, sym, &sec, 0);
 	  *result += sec->output_offset + sec->output_section->vma;
@@ -7540,7 +7579,7 @@
     }
 
   /* Hmm, haven't found it yet. perhaps it is a global.  */
-  global_entry = bfd_link_hash_lookup (finfo->info->hash, name,
+  global_entry = bfd_link_hash_lookup (flinfo->info->hash, name,
 				       FALSE, FALSE, TRUE);
   if (!global_entry)
     return FALSE;
@@ -7609,7 +7648,7 @@
 eval_symbol (bfd_vma *result,
 	     const char **symp,
 	     bfd *input_bfd,
-	     struct elf_final_link_info *finfo,
+	     struct elf_final_link_info *flinfo,
 	     bfd_vma dot,
 	     Elf_Internal_Sym *isymbuf,
 	     size_t locsymcount,
@@ -7669,8 +7708,8 @@
 
       if (symbol_is_section)
 	{
-	  if (!resolve_section (symbuf, finfo->output_bfd->sections, result)
-	      && !resolve_symbol (symbuf, input_bfd, finfo, result,
+	  if (!resolve_section (symbuf, flinfo->output_bfd->sections, result)
+	      && !resolve_symbol (symbuf, input_bfd, flinfo, result,
 				  isymbuf, locsymcount))
 	    {
 	      undefined_reference ("section", symbuf);
@@ -7679,9 +7718,9 @@
 	}
       else
 	{
-	  if (!resolve_symbol (symbuf, input_bfd, finfo, result,
+	  if (!resolve_symbol (symbuf, input_bfd, flinfo, result,
 			       isymbuf, locsymcount)
-	      && !resolve_section (symbuf, finfo->output_bfd->sections,
+	      && !resolve_section (symbuf, flinfo->output_bfd->sections,
 				   result))
 	    {
 	      undefined_reference ("symbol", symbuf);
@@ -7700,7 +7739,7 @@
       if (*sym == ':')						\
 	++sym;							\
       *symp = sym;						\
-      if (!eval_symbol (&a, symp, input_bfd, finfo, dot,	\
+      if (!eval_symbol (&a, symp, input_bfd, flinfo, dot,	\
 			isymbuf, locsymcount, signed_p))	\
 	return FALSE;						\
       if (signed_p)						\
@@ -7717,11 +7756,11 @@
       if (*sym == ':')						\
 	++sym;							\
       *symp = sym;						\
-      if (!eval_symbol (&a, symp, input_bfd, finfo, dot,	\
+      if (!eval_symbol (&a, symp, input_bfd, flinfo, dot,	\
 			isymbuf, locsymcount, signed_p))	\
 	return FALSE;						\
       ++*symp;							\
-      if (!eval_symbol (&b, symp, input_bfd, finfo, dot,	\
+      if (!eval_symbol (&b, symp, input_bfd, flinfo, dot,	\
 			isymbuf, locsymcount, signed_p))	\
 	return FALSE;						\
       if (signed_p)						\
@@ -7803,31 +7842,49 @@
 	   bfd *input_bfd,
 	   bfd_byte *location)
 {
+  int shift;
   bfd_vma x = 0;
 
+  /* Sanity checks.  */
+  BFD_ASSERT (chunksz <= sizeof (x)
+	      && size >= chunksz
+	      && chunksz != 0
+	      && (size % chunksz) == 0
+	      && input_bfd != NULL
+	      && location != NULL);
+
+  if (chunksz == sizeof (x))
+    {
+      BFD_ASSERT (size == chunksz);
+
+      /* Make sure that we do not perform an undefined shift operation.
+	 We know that size == chunksz so there will only be one iteration
+	 of the loop below.  */
+      shift = 0;
+    }
+  else
+    shift = 8 * chunksz;
+
   for (; size; size -= chunksz, location += chunksz)
     {
       switch (chunksz)
 	{
-	default:
-	case 0:
-	  abort ();
 	case 1:
-	  x = (x << (8 * chunksz)) | bfd_get_8 (input_bfd, location);
+	  x = (x << shift) | bfd_get_8 (input_bfd, location);
 	  break;
 	case 2:
-	  x = (x << (8 * chunksz)) | bfd_get_16 (input_bfd, location);
+	  x = (x << shift) | bfd_get_16 (input_bfd, location);
 	  break;
 	case 4:
-	  x = (x << (8 * chunksz)) | bfd_get_32 (input_bfd, location);
+	  x = (x << shift) | bfd_get_32 (input_bfd, location);
 	  break;
-	case 8:
 #ifdef BFD64
-	  x = (x << (8 * chunksz)) | bfd_get_64 (input_bfd, location);
-#else
-	  abort ();
-#endif
+	case 8:
+	  x = (x << shift) | bfd_get_64 (input_bfd, location);
 	  break;
+#endif
+	default:
+	  abort ();
 	}
     }
   return x;
@@ -8026,18 +8083,15 @@
 {
   const struct elf_link_sort_rela *a = (const struct elf_link_sort_rela *) A;
   const struct elf_link_sort_rela *b = (const struct elf_link_sort_rela *) B;
-  int copya, copyb;
 
+  if (a->type < b->type)
+    return -1;
+  if (a->type > b->type)
+    return 1;
   if (a->u.offset < b->u.offset)
     return -1;
   if (a->u.offset > b->u.offset)
     return 1;
-  copya = (a->type == reloc_class_copy) * 2 + (a->type == reloc_class_plt);
-  copyb = (b->type == reloc_class_copy) * 2 + (b->type == reloc_class_plt);
-  if (copya < copyb)
-    return -1;
-  if (copya > copyb)
-    return 1;
   if (a->rela->r_offset < b->rela->r_offset)
     return -1;
   if (a->rela->r_offset > b->rela->r_offset)
@@ -8263,7 +8317,7 @@
 	    struct elf_link_sort_rela *s = (struct elf_link_sort_rela *) p;
 
 	    (*swap_in) (abfd, erel, s->rela);
-	    s->type = (*bed->elf_backend_reloc_type_class) (s->rela);
+	    s->type = (*bed->elf_backend_reloc_type_class) (info, o, s->rela);
 	    s->u.sym_mask = r_sym_mask;
 	    p += sort_elt;
 	    erel += ext_size;
@@ -8319,24 +8373,24 @@
 /* Flush the output symbols to the file.  */
 
 static bfd_boolean
-elf_link_flush_output_syms (struct elf_final_link_info *finfo,
+elf_link_flush_output_syms (struct elf_final_link_info *flinfo,
 			    const struct elf_backend_data *bed)
 {
-  if (finfo->symbuf_count > 0)
+  if (flinfo->symbuf_count > 0)
     {
       Elf_Internal_Shdr *hdr;
       file_ptr pos;
       bfd_size_type amt;
 
-      hdr = &elf_tdata (finfo->output_bfd)->symtab_hdr;
+      hdr = &elf_tdata (flinfo->output_bfd)->symtab_hdr;
       pos = hdr->sh_offset + hdr->sh_size;
-      amt = finfo->symbuf_count * bed->s->sizeof_sym;
-      if (bfd_seek (finfo->output_bfd, pos, SEEK_SET) != 0
-	  || bfd_bwrite (finfo->symbuf, amt, finfo->output_bfd) != amt)
+      amt = flinfo->symbuf_count * bed->s->sizeof_sym;
+      if (bfd_seek (flinfo->output_bfd, pos, SEEK_SET) != 0
+	  || bfd_bwrite (flinfo->symbuf, amt, flinfo->output_bfd) != amt)
 	return FALSE;
 
       hdr->sh_size += amt;
-      finfo->symbuf_count = 0;
+      flinfo->symbuf_count = 0;
     }
 
   return TRUE;
@@ -8345,7 +8399,7 @@
 /* Add a symbol to the output symbol table.  */
 
 static int
-elf_link_output_sym (struct elf_final_link_info *finfo,
+elf_link_output_sym (struct elf_final_link_info *flinfo,
 		     const char *name,
 		     Elf_Internal_Sym *elfsym,
 		     asection *input_sec,
@@ -8358,11 +8412,11 @@
      struct elf_link_hash_entry *);
   const struct elf_backend_data *bed;
 
-  bed = get_elf_backend_data (finfo->output_bfd);
+  bed = get_elf_backend_data (flinfo->output_bfd);
   output_symbol_hook = bed->elf_backend_link_output_symbol_hook;
   if (output_symbol_hook != NULL)
     {
-      int ret = (*output_symbol_hook) (finfo->info, name, elfsym, input_sec, h);
+      int ret = (*output_symbol_hook) (flinfo->info, name, elfsym, input_sec, h);
       if (ret != 1)
 	return ret;
     }
@@ -8373,41 +8427,41 @@
     elfsym->st_name = 0;
   else
     {
-      elfsym->st_name = (unsigned long) _bfd_stringtab_add (finfo->symstrtab,
+      elfsym->st_name = (unsigned long) _bfd_stringtab_add (flinfo->symstrtab,
 							    name, TRUE, FALSE);
       if (elfsym->st_name == (unsigned long) -1)
 	return 0;
     }
 
-  if (finfo->symbuf_count >= finfo->symbuf_size)
+  if (flinfo->symbuf_count >= flinfo->symbuf_size)
     {
-      if (! elf_link_flush_output_syms (finfo, bed))
+      if (! elf_link_flush_output_syms (flinfo, bed))
 	return 0;
     }
 
-  dest = finfo->symbuf + finfo->symbuf_count * bed->s->sizeof_sym;
-  destshndx = finfo->symshndxbuf;
+  dest = flinfo->symbuf + flinfo->symbuf_count * bed->s->sizeof_sym;
+  destshndx = flinfo->symshndxbuf;
   if (destshndx != NULL)
     {
-      if (bfd_get_symcount (finfo->output_bfd) >= finfo->shndxbuf_size)
+      if (bfd_get_symcount (flinfo->output_bfd) >= flinfo->shndxbuf_size)
 	{
 	  bfd_size_type amt;
 
-	  amt = finfo->shndxbuf_size * sizeof (Elf_External_Sym_Shndx);
+	  amt = flinfo->shndxbuf_size * sizeof (Elf_External_Sym_Shndx);
 	  destshndx = (Elf_External_Sym_Shndx *) bfd_realloc (destshndx,
                                                               amt * 2);
 	  if (destshndx == NULL)
 	    return 0;
-	  finfo->symshndxbuf = destshndx;
+	  flinfo->symshndxbuf = destshndx;
 	  memset ((char *) destshndx + amt, 0, amt);
-	  finfo->shndxbuf_size *= 2;
+	  flinfo->shndxbuf_size *= 2;
 	}
-      destshndx += bfd_get_symcount (finfo->output_bfd);
+      destshndx += bfd_get_symcount (flinfo->output_bfd);
     }
 
-  bed->s->swap_symbol_out (finfo->output_bfd, elfsym, dest, destshndx);
-  finfo->symbuf_count += 1;
-  bfd_get_symcount (finfo->output_bfd) += 1;
+  bed->s->swap_symbol_out (flinfo->output_bfd, elfsym, dest, destshndx);
+  flinfo->symbuf_count += 1;
+  bfd_get_symcount (flinfo->output_bfd) += 1;
 
   return 1;
 }
@@ -8448,6 +8502,10 @@
   if (!is_elf_hash_table (info->hash))
     return FALSE;
 
+  /* Check indirect symbol.  */
+  while (h->root.type == bfd_link_hash_indirect)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
   switch (h->root.type)
     {
     default:
@@ -8595,7 +8653,7 @@
 {
   struct elf_link_hash_entry *h = (struct elf_link_hash_entry *) bh;
   struct elf_outext_info *eoinfo = (struct elf_outext_info *) data;
-  struct elf_final_link_info *finfo = eoinfo->finfo;
+  struct elf_final_link_info *flinfo = eoinfo->flinfo;
   bfd_boolean strip;
   Elf_Internal_Sym sym;
   asection *input_sec;
@@ -8615,6 +8673,11 @@
     {
       if (!h->forced_local)
 	return TRUE;
+      if (eoinfo->second_pass
+	  && !((h->root.type == bfd_link_hash_defined
+		|| h->root.type == bfd_link_hash_defweak)
+	       && h->root.u.def.section->output_section != NULL))
+	return TRUE;
     }
   else
     {
@@ -8622,7 +8685,7 @@
 	return TRUE;
     }
 
-  bed = get_elf_backend_data (finfo->output_bfd);
+  bed = get_elf_backend_data (flinfo->output_bfd);
 
   if (h->root.type == bfd_link_hash_undefined)
     {
@@ -8641,14 +8704,16 @@
       /* If we are reporting errors for this situation then do so now.  */
       if (!ignore_undef
 	  && h->ref_dynamic
-	  && (!h->ref_regular || finfo->info->gc_sections)
-	  && ! elf_link_check_versioned_symbol (finfo->info, bed, h)
-	  && finfo->info->unresolved_syms_in_shared_libs != RM_IGNORE)
+	  && (!h->ref_regular || flinfo->info->gc_sections)
+	  && !elf_link_check_versioned_symbol (flinfo->info, bed, h)
+	  && flinfo->info->unresolved_syms_in_shared_libs != RM_IGNORE)
 	{
-	  if (! (finfo->info->callbacks->undefined_symbol
-		 (finfo->info, h->root.root.string,
-		  h->ref_regular ? NULL : h->root.u.undef.abfd,
-		  NULL, 0, finfo->info->unresolved_syms_in_shared_libs == RM_GENERATE_ERROR)))
+	  if (!(flinfo->info->callbacks->undefined_symbol
+		(flinfo->info, h->root.root.string,
+		 h->ref_regular ? NULL : h->root.u.undef.abfd,
+		 NULL, 0,
+		 (flinfo->info->unresolved_syms_in_shared_libs
+		  == RM_GENERATE_ERROR))))
 	    {
 	      bfd_set_error (bfd_error_bad_value);
 	      eoinfo->failed = TRUE;
@@ -8659,17 +8724,22 @@
 
   /* We should also warn if a forced local symbol is referenced from
      shared libraries.  */
-  if (!finfo->info->relocatable
-      && finfo->info->executable
+  if (!flinfo->info->relocatable
+      && flinfo->info->executable
       && h->forced_local
       && h->ref_dynamic
       && h->def_regular
       && !h->dynamic_def
-      && !h->dynamic_weak
-      && ! elf_link_check_versioned_symbol (finfo->info, bed, h))
+      && h->ref_dynamic_nonweak
+      && !elf_link_check_versioned_symbol (flinfo->info, bed, h))
     {
       bfd *def_bfd;
       const char *msg;
+      struct elf_link_hash_entry *hi = h;
+
+      /* Check indirect symbol.  */
+      while (hi->root.type == bfd_link_hash_indirect)
+	hi = (struct elf_link_hash_entry *) hi->root.u.i.link;
 
       if (ELF_ST_VISIBILITY (h->other) == STV_INTERNAL)
 	msg = _("%B: internal symbol `%s' in %B is referenced by DSO");
@@ -8677,10 +8747,10 @@
 	msg = _("%B: hidden symbol `%s' in %B is referenced by DSO");
       else
 	msg = _("%B: local symbol `%s' in %B is referenced by DSO");
-      def_bfd = finfo->output_bfd;
-      if (h->root.u.def.section != bfd_abs_section_ptr)
-	def_bfd = h->root.u.def.section->owner;
-      (*_bfd_error_handler) (msg, finfo->output_bfd, def_bfd,
+      def_bfd = flinfo->output_bfd;
+      if (hi->root.u.def.section != bfd_abs_section_ptr)
+	def_bfd = hi->root.u.def.section->owner;
+      (*_bfd_error_handler) (msg, flinfo->output_bfd, def_bfd,
 			     h->root.root.string);
       bfd_set_error (bfd_error_bad_value);
       eoinfo->failed = TRUE;
@@ -8699,16 +8769,16 @@
 	   && !h->def_regular
 	   && !h->ref_regular)
     strip = TRUE;
-  else if (finfo->info->strip == strip_all)
+  else if (flinfo->info->strip == strip_all)
     strip = TRUE;
-  else if (finfo->info->strip == strip_some
-	   && bfd_hash_lookup (finfo->info->keep_hash,
+  else if (flinfo->info->strip == strip_some
+	   && bfd_hash_lookup (flinfo->info->keep_hash,
 			       h->root.root.string, FALSE, FALSE) == NULL)
     strip = TRUE;
   else if ((h->root.type == bfd_link_hash_defined
 	    || h->root.type == bfd_link_hash_defweak)
-	   && ((finfo->info->strip_discarded
-		&& elf_discarded_section (h->root.u.def.section))
+	   && ((flinfo->info->strip_discarded
+		&& discarded_section (h->root.u.def.section))
 	       || (h->root.u.def.section->owner != NULL
 		   && (h->root.u.def.section->owner->flags & BFD_PLUGIN) != 0)))
     strip = TRUE;
@@ -8738,7 +8808,8 @@
       /* Turn off visibility on local symbol.  */
       sym.st_other &= ~ELF_ST_VISIBILITY (-1);
     }
-  else if (h->unique_global)
+  /* Set STB_GNU_UNIQUE only if symbol is defined in regular object.  */
+  else if (h->unique_global && h->def_regular)
     sym.st_info = ELF_ST_INFO (STB_GNU_UNIQUE, h->type);
   else if (h->root.type == bfd_link_hash_undefweak
 	   || h->root.type == bfd_link_hash_defweak)
@@ -8767,14 +8838,27 @@
 	input_sec = h->root.u.def.section;
 	if (input_sec->output_section != NULL)
 	  {
+	    if (eoinfo->localsyms && flinfo->filesym_count == 1)
+	      {
+		bfd_boolean second_pass_sym
+		  = (input_sec->owner == flinfo->output_bfd
+		     || input_sec->owner == NULL
+		     || (input_sec->flags & SEC_LINKER_CREATED) != 0
+		     || (input_sec->owner->flags & BFD_LINKER_CREATED) != 0);
+
+		eoinfo->need_second_pass |= second_pass_sym;
+		if (eoinfo->second_pass != second_pass_sym)
+		  return TRUE;
+	      }
+
 	    sym.st_shndx =
-	      _bfd_elf_section_from_bfd_section (finfo->output_bfd,
+	      _bfd_elf_section_from_bfd_section (flinfo->output_bfd,
 						 input_sec->output_section);
 	    if (sym.st_shndx == SHN_BAD)
 	      {
 		(*_bfd_error_handler)
 		  (_("%B: could not find output section %A for input section %A"),
-		   finfo->output_bfd, input_sec->output_section, input_sec);
+		   flinfo->output_bfd, input_sec->output_section, input_sec);
 		bfd_set_error (bfd_error_nonrepresentable_section);
 		eoinfo->failed = TRUE;
 		return FALSE;
@@ -8784,18 +8868,18 @@
 	       but in nonrelocatable files they are virtual
 	       addresses.  */
 	    sym.st_value = h->root.u.def.value + input_sec->output_offset;
-	    if (! finfo->info->relocatable)
+	    if (!flinfo->info->relocatable)
 	      {
 		sym.st_value += input_sec->output_section->vma;
 		if (h->type == STT_TLS)
 		  {
-		    asection *tls_sec = elf_hash_table (finfo->info)->tls_sec;
+		    asection *tls_sec = elf_hash_table (flinfo->info)->tls_sec;
 		    if (tls_sec != NULL)
 		      sym.st_value -= tls_sec->vma;
 		    else
 		      {
 			/* The TLS section may have been garbage collected.  */
-			BFD_ASSERT (finfo->info->gc_sections
+			BFD_ASSERT (flinfo->info->gc_sections
 				    && !input_sec->gc_mark);
 		      }
 		  }
@@ -8834,17 +8918,17 @@
      STT_GNU_IFUNC symbol must go through PLT.  */
   if ((h->type == STT_GNU_IFUNC
        && h->def_regular
-       && !finfo->info->relocatable)
+       && !flinfo->info->relocatable)
       || ((h->dynindx != -1
 	   || h->forced_local)
-	  && ((finfo->info->shared
+	  && ((flinfo->info->shared
 	       && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
 		   || h->root.type != bfd_link_hash_undefweak))
 	      || !h->forced_local)
-	  && elf_hash_table (finfo->info)->dynamic_sections_created))
+	  && elf_hash_table (flinfo->info)->dynamic_sections_created))
     {
       if (! ((*bed->elf_backend_finish_dynamic_symbol)
-	     (finfo->output_bfd, finfo->info, h, &sym)))
+	     (flinfo->output_bfd, flinfo->info, h, &sym)))
 	{
 	  eoinfo->failed = TRUE;
 	  return FALSE;
@@ -8887,7 +8971,7 @@
 
   /* If a non-weak symbol with non-default visibility is not defined
      locally, it is a fatal error.  */
-  if (! finfo->info->relocatable
+  if (!flinfo->info->relocatable
       && ELF_ST_VISIBILITY (sym.st_other) != STV_DEFAULT
       && ELF_ST_BIND (sym.st_info) != STB_WEAK
       && h->root.type == bfd_link_hash_undefined
@@ -8901,7 +8985,7 @@
 	msg = _("%B: internal symbol `%s' isn't defined");
       else
 	msg = _("%B: hidden symbol `%s' isn't defined");
-      (*_bfd_error_handler) (msg, finfo->output_bfd, h->root.root.string);
+      (*_bfd_error_handler) (msg, flinfo->output_bfd, h->root.root.string);
       bfd_set_error (bfd_error_bad_value);
       eoinfo->failed = TRUE;
       return FALSE;
@@ -8910,21 +8994,39 @@
   /* If this symbol should be put in the .dynsym section, then put it
      there now.  We already know the symbol index.  We also fill in
      the entry in the .hash section.  */
-  if (h->dynindx != -1
-      && elf_hash_table (finfo->info)->dynamic_sections_created)
+  if (flinfo->dynsym_sec != NULL
+      && h->dynindx != -1
+      && elf_hash_table (flinfo->info)->dynamic_sections_created)
     {
       bfd_byte *esym;
 
+      /* Since there is no version information in the dynamic string,
+	 if there is no version info in symbol version section, we will
+	 have a run-time problem.  */
+      if (h->verinfo.verdef == NULL)
+	{
+	  char *p = strrchr (h->root.root.string, ELF_VER_CHR);
+
+	  if (p && p [1] != '\0')
+	    {
+	      (*_bfd_error_handler)
+		(_("%B: No symbol version section for versioned symbol `%s'"),
+		 flinfo->output_bfd, h->root.root.string);
+	      eoinfo->failed = TRUE;
+	      return FALSE;
+	    }
+	}
+
       sym.st_name = h->dynstr_index;
-      esym = finfo->dynsym_sec->contents + h->dynindx * bed->s->sizeof_sym;
-      if (! check_dynsym (finfo->output_bfd, &sym))
+      esym = flinfo->dynsym_sec->contents + h->dynindx * bed->s->sizeof_sym;
+      if (!check_dynsym (flinfo->output_bfd, &sym))
 	{
 	  eoinfo->failed = TRUE;
 	  return FALSE;
 	}
-      bed->s->swap_symbol_out (finfo->output_bfd, &sym, esym, 0);
+      bed->s->swap_symbol_out (flinfo->output_bfd, &sym, esym, 0);
 
-      if (finfo->hash_sec != NULL)
+      if (flinfo->hash_sec != NULL)
 	{
 	  size_t hash_entry_size;
 	  bfd_byte *bucketpos;
@@ -8932,21 +9034,22 @@
 	  size_t bucketcount;
 	  size_t bucket;
 
-	  bucketcount = elf_hash_table (finfo->info)->bucketcount;
+	  bucketcount = elf_hash_table (flinfo->info)->bucketcount;
 	  bucket = h->u.elf_hash_value % bucketcount;
 
 	  hash_entry_size
-	    = elf_section_data (finfo->hash_sec)->this_hdr.sh_entsize;
-	  bucketpos = ((bfd_byte *) finfo->hash_sec->contents
+	    = elf_section_data (flinfo->hash_sec)->this_hdr.sh_entsize;
+	  bucketpos = ((bfd_byte *) flinfo->hash_sec->contents
 		       + (bucket + 2) * hash_entry_size);
-	  chain = bfd_get (8 * hash_entry_size, finfo->output_bfd, bucketpos);
-	  bfd_put (8 * hash_entry_size, finfo->output_bfd, h->dynindx, bucketpos);
-	  bfd_put (8 * hash_entry_size, finfo->output_bfd, chain,
-		   ((bfd_byte *) finfo->hash_sec->contents
+	  chain = bfd_get (8 * hash_entry_size, flinfo->output_bfd, bucketpos);
+	  bfd_put (8 * hash_entry_size, flinfo->output_bfd, h->dynindx,
+		   bucketpos);
+	  bfd_put (8 * hash_entry_size, flinfo->output_bfd, chain,
+		   ((bfd_byte *) flinfo->hash_sec->contents
 		    + (bucketcount + 2 + h->dynindx) * hash_entry_size));
 	}
 
-      if (finfo->symver_sec != NULL && finfo->symver_sec->contents != NULL)
+      if (flinfo->symver_sec != NULL && flinfo->symver_sec->contents != NULL)
 	{
 	  Elf_Internal_Versym iversym;
 	  Elf_External_Versym *eversym;
@@ -8964,16 +9067,16 @@
 		iversym.vs_vers = 1;
 	      else
 		iversym.vs_vers = h->verinfo.vertree->vernum + 1;
-	      if (finfo->info->create_default_symver)
+	      if (flinfo->info->create_default_symver)
 		iversym.vs_vers++;
 	    }
 
 	  if (h->hidden)
 	    iversym.vs_vers |= VERSYM_HIDDEN;
 
-	  eversym = (Elf_External_Versym *) finfo->symver_sec->contents;
+	  eversym = (Elf_External_Versym *) flinfo->symver_sec->contents;
 	  eversym += h->dynindx;
-	  _bfd_elf_swap_versym_out (finfo->output_bfd, &iversym, eversym);
+	  _bfd_elf_swap_versym_out (flinfo->output_bfd, &iversym, eversym);
 	}
     }
 
@@ -8982,8 +9085,8 @@
   if (strip || (input_sec->flags & SEC_EXCLUDE) != 0)
     return TRUE;
 
-  indx = bfd_get_symcount (finfo->output_bfd);
-  ret = elf_link_output_sym (finfo, h->root.root.string, &sym, input_sec, h);
+  indx = bfd_get_symcount (flinfo->output_bfd);
+  ret = elf_link_output_sym (flinfo, h->root.root.string, &sym, input_sec, h);
   if (ret == 0)
     {
       eoinfo->failed = TRUE;
@@ -9007,8 +9110,8 @@
 
   switch (sec->sec_info_type)
     {
-    case ELF_INFO_TYPE_STABS:
-    case ELF_INFO_TYPE_EH_FRAME:
+    case SEC_INFO_TYPE_STABS:
+    case SEC_INFO_TYPE_EH_FRAME:
       return TRUE;
     default:
       break;
@@ -9097,7 +9200,7 @@
    don't have to keep them in memory.  */
 
 static bfd_boolean
-elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd)
+elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
 {
   int (*relocate_section)
     (bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
@@ -9117,8 +9220,9 @@
   bfd_size_type address_size;
   bfd_vma r_type_mask;
   int r_sym_shift;
+  bfd_boolean have_file_sym = FALSE;
 
-  output_bfd = finfo->output_bfd;
+  output_bfd = flinfo->output_bfd;
   bed = get_elf_backend_data (output_bfd);
   relocate_section = bed->elf_backend_relocate_section;
 
@@ -9145,9 +9249,9 @@
   if (isymbuf == NULL && locsymcount != 0)
     {
       isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr, locsymcount, 0,
-				      finfo->internal_syms,
-				      finfo->external_syms,
-				      finfo->locsym_shndx);
+				      flinfo->internal_syms,
+				      flinfo->external_syms,
+				      flinfo->locsym_shndx);
       if (isymbuf == NULL)
 	return FALSE;
     }
@@ -9156,7 +9260,7 @@
      SEC_MERGE sections.  Write out those local symbols we know are
      going into the output file.  */
   isymend = isymbuf + locsymcount;
-  for (isym = isymbuf, pindex = finfo->indices, ppsection = finfo->sections;
+  for (isym = isymbuf, pindex = flinfo->indices, ppsection = flinfo->sections;
        isym < isymend;
        isym++, pindex++, ppsection++)
     {
@@ -9193,7 +9297,7 @@
 	      *ppsection = NULL;
 	      continue;
 	    }
-	  else if (isec->sec_info_type == ELF_INFO_TYPE_MERGE
+	  else if (isec->sec_info_type == SEC_INFO_TYPE_MERGE
 		   && ELF_ST_TYPE (isym->st_info) != STT_SECTION)
 	    isym->st_value =
 	      _bfd_merged_section_offset (output_bfd, &isec,
@@ -9204,7 +9308,7 @@
       *ppsection = isec;
 
       /* Don't output the first, undefined, symbol.  */
-      if (ppsection == finfo->sections)
+      if (ppsection == flinfo->sections)
 	continue;
 
       if (ELF_ST_TYPE (isym->st_info) == STT_SECTION)
@@ -9217,7 +9321,7 @@
 
       /* If we are stripping all symbols, we don't want to output this
 	 one.  */
-      if (finfo->info->strip == strip_all)
+      if (flinfo->info->strip == strip_all)
 	continue;
 
       /* If we are discarding all local symbols, we don't want to
@@ -9225,7 +9329,7 @@
 	 file, then some of the local symbols may be required by
 	 relocs; we output them below as we discover that they are
 	 needed.  */
-      if (finfo->info->discard == discard_all)
+      if (flinfo->info->discard == discard_all)
 	continue;
 
       /* If this symbol is defined in a section which we are
@@ -9243,15 +9347,38 @@
 	return FALSE;
 
       /* See if we are discarding symbols with this name.  */
-      if ((finfo->info->strip == strip_some
-	   && (bfd_hash_lookup (finfo->info->keep_hash, name, FALSE, FALSE)
+      if ((flinfo->info->strip == strip_some
+	   && (bfd_hash_lookup (flinfo->info->keep_hash, name, FALSE, FALSE)
 	       == NULL))
-	  || (((finfo->info->discard == discard_sec_merge
-		&& (isec->flags & SEC_MERGE) && ! finfo->info->relocatable)
-	       || finfo->info->discard == discard_l)
+	  || (((flinfo->info->discard == discard_sec_merge
+		&& (isec->flags & SEC_MERGE) && !flinfo->info->relocatable)
+	       || flinfo->info->discard == discard_l)
 	      && bfd_is_local_label_name (input_bfd, name)))
 	continue;
 
+      if (ELF_ST_TYPE (isym->st_info) == STT_FILE)
+	{
+	  have_file_sym = TRUE;
+	  flinfo->filesym_count += 1;
+	}
+      if (!have_file_sym)
+	{
+	  /* In the absence of debug info, bfd_find_nearest_line uses
+	     FILE symbols to determine the source file for local
+	     function symbols.  Provide a FILE symbol here if input
+	     files lack such, so that their symbols won't be
+	     associated with a previous input file.  It's not the
+	     source file, but the best we can do.  */
+	  have_file_sym = TRUE;
+	  flinfo->filesym_count += 1;
+	  memset (&osym, 0, sizeof (osym));
+	  osym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FILE);
+	  osym.st_shndx = SHN_ABS;
+	  if (!elf_link_output_sym (flinfo, input_bfd->filename, &osym,
+				    bfd_abs_section_ptr, NULL))
+	    return FALSE;
+	}
+
       osym = *isym;
 
       /* Adjust the section index for the output file.  */
@@ -9268,19 +9395,19 @@
 	 output_section.  Any special sections must be set up to meet
 	 these requirements.  */
       osym.st_value += isec->output_offset;
-      if (! finfo->info->relocatable)
+      if (!flinfo->info->relocatable)
 	{
 	  osym.st_value += isec->output_section->vma;
 	  if (ELF_ST_TYPE (osym.st_info) == STT_TLS)
 	    {
 	      /* STT_TLS symbols are relative to PT_TLS segment base.  */
-	      BFD_ASSERT (elf_hash_table (finfo->info)->tls_sec != NULL);
-	      osym.st_value -= elf_hash_table (finfo->info)->tls_sec->vma;
+	      BFD_ASSERT (elf_hash_table (flinfo->info)->tls_sec != NULL);
+	      osym.st_value -= elf_hash_table (flinfo->info)->tls_sec->vma;
 	    }
 	}
 
       indx = bfd_get_symcount (output_bfd);
-      ret = elf_link_output_sym (finfo, name, &osym, isec, NULL);
+      ret = elf_link_output_sym (flinfo, name, &osym, isec, NULL);
       if (ret == 0)
 	return FALSE;
       else if (ret == 1)
@@ -9312,7 +9439,7 @@
 	  continue;
 	}
 
-      if (finfo->info->relocatable
+      if (flinfo->info->relocatable
 	  && (o->flags & (SEC_LINKER_CREATED | SEC_GROUP)) == SEC_GROUP)
 	{
 	  /* Deal with the group signature symbol.  */
@@ -9322,7 +9449,7 @@
 
 	  if (symndx >= locsymcount
 	      || (elf_bad_symtab (input_bfd)
-		  && finfo->sections[symndx] == NULL))
+		  && flinfo->sections[symndx] == NULL))
 	    {
 	      struct elf_link_hash_entry *h = sym_hashes[symndx - extsymoff];
 	      while (h->root.type == bfd_link_hash_indirect
@@ -9335,16 +9462,16 @@
 	  else if (ELF_ST_TYPE (isymbuf[symndx].st_info) == STT_SECTION)
 	    {
 	      /* We'll use the output section target_index.  */
-	      asection *sec = finfo->sections[symndx]->output_section;
+	      asection *sec = flinfo->sections[symndx]->output_section;
 	      elf_section_data (osec)->this_hdr.sh_info = sec->target_index;
 	    }
 	  else
 	    {
-	      if (finfo->indices[symndx] == -1)
+	      if (flinfo->indices[symndx] == -1)
 		{
 		  /* Otherwise output the local symbol now.  */
 		  Elf_Internal_Sym sym = isymbuf[symndx];
-		  asection *sec = finfo->sections[symndx]->output_section;
+		  asection *sec = flinfo->sections[symndx]->output_section;
 		  const char *name;
 		  long indx;
 		  int ret;
@@ -9363,16 +9490,16 @@
 		  sym.st_value += o->output_offset;
 
 		  indx = bfd_get_symcount (output_bfd);
-		  ret = elf_link_output_sym (finfo, name, &sym, o, NULL);
+		  ret = elf_link_output_sym (flinfo, name, &sym, o, NULL);
 		  if (ret == 0)
 		    return FALSE;
 		  else if (ret == 1)
-		    finfo->indices[symndx] = indx;
+		    flinfo->indices[symndx] = indx;
 		  else
 		    abort ();
 		}
 	      elf_section_data (osec)->this_hdr.sh_info
-		= finfo->indices[symndx];
+		= flinfo->indices[symndx];
 	    }
 	}
 
@@ -9395,7 +9522,7 @@
 	contents = elf_section_data (o)->this_hdr.contents;
       else
 	{
-	  contents = finfo->contents;
+	  contents = flinfo->contents;
 	  if (! bfd_get_full_section_contents (input_bfd, o, &contents))
 	    return FALSE;
 	}
@@ -9409,8 +9536,8 @@
 
 	  /* Get the swapped relocs.  */
 	  internal_relocs
-	    = _bfd_elf_link_read_relocs (input_bfd, o, finfo->external_relocs,
-					 finfo->internal_relocs, FALSE);
+	    = _bfd_elf_link_read_relocs (input_bfd, o, flinfo->external_relocs,
+					 flinfo->internal_relocs, FALSE);
 	  if (internal_relocs == NULL
 	      && o->reloc_count > 0)
 	    return FALSE;
@@ -9463,7 +9590,7 @@
 
 	      if (r_symndx >= locsymcount
 		  || (elf_bad_symtab (input_bfd)
-		      && finfo->sections[r_symndx] == NULL))
+		      && flinfo->sections[r_symndx] == NULL))
 		{
 		  h = sym_hashes[r_symndx - extsymoff];
 
@@ -9501,13 +9628,13 @@
 		  Elf_Internal_Sym *sym = isymbuf + r_symndx;
 
 		  s_type = ELF_ST_TYPE (sym->st_info);
-		  ps = &finfo->sections[r_symndx];
+		  ps = &flinfo->sections[r_symndx];
 		  sym_name = bfd_elf_sym_name (input_bfd, symtab_hdr,
 					       sym, *ps);
 		}
 
 	      if ((s_type == STT_RELC || s_type == STT_SRELC)
-		  && !finfo->info->relocatable)
+		  && !flinfo->info->relocatable)
 		{
 		  bfd_vma val;
 		  bfd_vma dot = (rel->r_offset
@@ -9523,7 +9650,7 @@
 			  (unsigned long) rel->r_info,
 			  (unsigned long) rel->r_offset);
 #endif
-		  if (!eval_symbol (&val, &sym_name, input_bfd, finfo, dot,
+		  if (!eval_symbol (&val, &sym_name, input_bfd, flinfo, dot,
 				    isymbuf, locsymcount, s_type == STT_SRELC))
 		    return FALSE;
 
@@ -9537,11 +9664,11 @@
 		{
 		  /* Complain if the definition comes from a
 		     discarded section.  */
-		  if ((sec = *ps) != NULL && elf_discarded_section (sec))
+		  if ((sec = *ps) != NULL && discarded_section (sec))
 		    {
 		      BFD_ASSERT (r_symndx != STN_UNDEF);
 		      if (action_discarded & COMPLAIN)
-			(*finfo->info->callbacks->einfo)
+			(*flinfo->info->callbacks->einfo)
 			  (_("%X`%s' referenced in section `%A' of %B: "
 			     "defined in discarded section `%A' of %B\n"),
 			   sym_name, o, input_bfd, sec, sec->owner);
@@ -9557,7 +9684,7 @@
 			  asection *kept;
 
 			  kept = _bfd_elf_check_kept_section (sec,
-							      finfo->info);
+							      flinfo->info);
 			  if (kept != NULL)
 			    {
 			      *ps = kept;
@@ -9588,17 +9715,17 @@
 	     corresponding to the output section, which will require
 	     the addend to be adjusted.  */
 
-	  ret = (*relocate_section) (output_bfd, finfo->info,
+	  ret = (*relocate_section) (output_bfd, flinfo->info,
 				     input_bfd, o, contents,
 				     internal_relocs,
 				     isymbuf,
-				     finfo->sections);
+				     flinfo->sections);
 	  if (!ret)
 	    return FALSE;
 
 	  if (ret == 2
-	      || finfo->info->relocatable
-	      || finfo->info->emitrelocations)
+	      || flinfo->info->relocatable
+	      || flinfo->info->emitrelocations)
 	    {
 	      Elf_Internal_Rela *irela;
 	      Elf_Internal_Rela *irelaend, *irelamid;
@@ -9628,7 +9755,7 @@
 	      rel_hash_list = rel_hash;
 	      rela_hash_list = NULL;
 	      last_offset = o->output_offset;
-	      if (!finfo->info->relocatable)
+	      if (!flinfo->info->relocatable)
 		last_offset += o->output_section->vma;
 	      for (next_erel = 0; irela < irelaend; irela++, next_erel++)
 		{
@@ -9650,7 +9777,7 @@
 		    }
 
 		  irela->r_offset = _bfd_elf_section_offset (output_bfd,
-							     finfo->info, o,
+							     flinfo->info, o,
 							     irela->r_offset);
 		  if (irela->r_offset >= (bfd_vma) -2)
 		    {
@@ -9668,7 +9795,7 @@
 		  irela->r_offset += o->output_offset;
 
 		  /* Relocs in an executable have to be virtual addresses.  */
-		  if (!finfo->info->relocatable)
+		  if (!flinfo->info->relocatable)
 		    irela->r_offset += o->output_section->vma;
 
 		  last_offset = irela->r_offset;
@@ -9679,7 +9806,7 @@
 
 		  if (r_symndx >= locsymcount
 		      || (elf_bad_symtab (input_bfd)
-			  && finfo->sections[r_symndx] == NULL))
+			  && flinfo->sections[r_symndx] == NULL))
 		    {
 		      struct elf_link_hash_entry *rh;
 		      unsigned long indx;
@@ -9712,7 +9839,7 @@
 
 		  *rel_hash = NULL;
 		  sym = isymbuf[r_symndx];
-		  sec = finfo->sections[r_symndx];
+		  sec = flinfo->sections[r_symndx];
 		  if (ELF_ST_TYPE (sym.st_info) == STT_SECTION)
 		    {
 		      /* I suppose the backend ought to fill in the
@@ -9749,23 +9876,12 @@
 			      r_symndx = osec->target_index;
 			      if (r_symndx == STN_UNDEF)
 				{
-				  struct elf_link_hash_table *htab;
-				  asection *oi;
-
-				  htab = elf_hash_table (finfo->info);
-				  oi = htab->text_index_section;
-				  if ((osec->flags & SEC_READONLY) == 0
-				      && htab->data_index_section != NULL)
-				    oi = htab->data_index_section;
-
-				  if (oi != NULL)
-				    {
-				      irela->r_addend += osec->vma - oi->vma;
-				      r_symndx = oi->target_index;
-				    }
+				  irela->r_addend += osec->vma;
+				  osec = _bfd_nearby_section (output_bfd, osec,
+							      osec->vma);
+				  irela->r_addend -= osec->vma;
+				  r_symndx = osec->target_index;
 				}
-
-			      BFD_ASSERT (r_symndx != STN_UNDEF);
 			    }
 			}
 
@@ -9776,14 +9892,14 @@
 		    }
 		  else
 		    {
-		      if (finfo->indices[r_symndx] == -1)
+		      if (flinfo->indices[r_symndx] == -1)
 			{
 			  unsigned long shlink;
 			  const char *name;
 			  asection *osec;
 			  long indx;
 
-			  if (finfo->info->strip == strip_all)
+			  if (flinfo->info->strip == strip_all)
 			    {
 			      /* You can't do ld -r -s.  */
 			      bfd_set_error (bfd_error_invalid_operation);
@@ -9807,32 +9923,32 @@
 			    return FALSE;
 
 			  sym.st_value += sec->output_offset;
-			  if (! finfo->info->relocatable)
+			  if (!flinfo->info->relocatable)
 			    {
 			      sym.st_value += osec->vma;
 			      if (ELF_ST_TYPE (sym.st_info) == STT_TLS)
 				{
 				  /* STT_TLS symbols are relative to PT_TLS
 				     segment base.  */
-				  BFD_ASSERT (elf_hash_table (finfo->info)
+				  BFD_ASSERT (elf_hash_table (flinfo->info)
 					      ->tls_sec != NULL);
-				  sym.st_value -= (elf_hash_table (finfo->info)
+				  sym.st_value -= (elf_hash_table (flinfo->info)
 						   ->tls_sec->vma);
 				}
 			    }
 
 			  indx = bfd_get_symcount (output_bfd);
-			  ret = elf_link_output_sym (finfo, name, &sym, sec,
+			  ret = elf_link_output_sym (flinfo, name, &sym, sec,
 						     NULL);
 			  if (ret == 0)
 			    return FALSE;
 			  else if (ret == 1)
-			    finfo->indices[r_symndx] = indx;
+			    flinfo->indices[r_symndx] = indx;
 			  else
 			    abort ();
 			}
 
-		      r_symndx = finfo->indices[r_symndx];
+		      r_symndx = flinfo->indices[r_symndx];
 		    }
 
 		  irela->r_info = ((bfd_vma) r_symndx << r_sym_shift
@@ -9867,28 +9983,28 @@
 
       /* Write out the modified section contents.  */
       if (bed->elf_backend_write_section
-	  && (*bed->elf_backend_write_section) (output_bfd, finfo->info, o,
+	  && (*bed->elf_backend_write_section) (output_bfd, flinfo->info, o,
 						contents))
 	{
 	  /* Section written out.  */
 	}
       else switch (o->sec_info_type)
 	{
-	case ELF_INFO_TYPE_STABS:
+	case SEC_INFO_TYPE_STABS:
 	  if (! (_bfd_write_section_stabs
 		 (output_bfd,
-		  &elf_hash_table (finfo->info)->stab_info,
+		  &elf_hash_table (flinfo->info)->stab_info,
 		  o, &elf_section_data (o)->sec_info, contents)))
 	    return FALSE;
 	  break;
-	case ELF_INFO_TYPE_MERGE:
+	case SEC_INFO_TYPE_MERGE:
 	  if (! _bfd_write_merged_section (output_bfd, o,
 					   elf_section_data (o)->sec_info))
 	    return FALSE;
 	  break;
-	case ELF_INFO_TYPE_EH_FRAME:
+	case SEC_INFO_TYPE_EH_FRAME:
 	  {
-	    if (! _bfd_elf_write_section_eh_frame (output_bfd, finfo->info,
+	    if (! _bfd_elf_write_section_eh_frame (output_bfd, flinfo->info,
 						   o, contents))
 	      return FALSE;
 	  }
@@ -10256,6 +10372,42 @@
   return TRUE;
 }
 
+static void
+elf_final_link_free (bfd *obfd, struct elf_final_link_info *flinfo)
+{
+  asection *o;
+
+  if (flinfo->symstrtab != NULL)
+    _bfd_stringtab_free (flinfo->symstrtab);
+  if (flinfo->contents != NULL)
+    free (flinfo->contents);
+  if (flinfo->external_relocs != NULL)
+    free (flinfo->external_relocs);
+  if (flinfo->internal_relocs != NULL)
+    free (flinfo->internal_relocs);
+  if (flinfo->external_syms != NULL)
+    free (flinfo->external_syms);
+  if (flinfo->locsym_shndx != NULL)
+    free (flinfo->locsym_shndx);
+  if (flinfo->internal_syms != NULL)
+    free (flinfo->internal_syms);
+  if (flinfo->indices != NULL)
+    free (flinfo->indices);
+  if (flinfo->sections != NULL)
+    free (flinfo->sections);
+  if (flinfo->symbuf != NULL)
+    free (flinfo->symbuf);
+  if (flinfo->symshndxbuf != NULL)
+    free (flinfo->symshndxbuf);
+  for (o = obfd->sections; o != NULL; o = o->next)
+    {
+      struct bfd_elf_section_data *esdo = elf_section_data (o);
+      if ((o->flags & SEC_RELOC) != 0 && esdo->rel.hashes != NULL)
+	free (esdo->rel.hashes);
+      if ((o->flags & SEC_RELOC) != 0 && esdo->rela.hashes != NULL)
+	free (esdo->rela.hashes);
+    }
+}
 
 /* Do the final step of an ELF link.  */
 
@@ -10265,7 +10417,7 @@
   bfd_boolean dynamic;
   bfd_boolean emit_relocs;
   bfd *dynobj;
-  struct elf_final_link_info finfo;
+  struct elf_final_link_info flinfo;
   asection *o;
   struct bfd_link_order *p;
   bfd *sub;
@@ -10302,39 +10454,40 @@
   emit_relocs = (info->relocatable
 		 || info->emitrelocations);
 
-  finfo.info = info;
-  finfo.output_bfd = abfd;
-  finfo.symstrtab = _bfd_elf_stringtab_init ();
-  if (finfo.symstrtab == NULL)
+  flinfo.info = info;
+  flinfo.output_bfd = abfd;
+  flinfo.symstrtab = _bfd_elf_stringtab_init ();
+  if (flinfo.symstrtab == NULL)
     return FALSE;
 
   if (! dynamic)
     {
-      finfo.dynsym_sec = NULL;
-      finfo.hash_sec = NULL;
-      finfo.symver_sec = NULL;
+      flinfo.dynsym_sec = NULL;
+      flinfo.hash_sec = NULL;
+      flinfo.symver_sec = NULL;
     }
   else
     {
-      finfo.dynsym_sec = bfd_get_section_by_name (dynobj, ".dynsym");
-      finfo.hash_sec = bfd_get_section_by_name (dynobj, ".hash");
-      BFD_ASSERT (finfo.dynsym_sec != NULL);
-      finfo.symver_sec = bfd_get_section_by_name (dynobj, ".gnu.version");
+      flinfo.dynsym_sec = bfd_get_linker_section (dynobj, ".dynsym");
+      flinfo.hash_sec = bfd_get_linker_section (dynobj, ".hash");
+      /* Note that dynsym_sec can be NULL (on VMS).  */
+      flinfo.symver_sec = bfd_get_linker_section (dynobj, ".gnu.version");
       /* Note that it is OK if symver_sec is NULL.  */
     }
 
-  finfo.contents = NULL;
-  finfo.external_relocs = NULL;
-  finfo.internal_relocs = NULL;
-  finfo.external_syms = NULL;
-  finfo.locsym_shndx = NULL;
-  finfo.internal_syms = NULL;
-  finfo.indices = NULL;
-  finfo.sections = NULL;
-  finfo.symbuf = NULL;
-  finfo.symshndxbuf = NULL;
-  finfo.symbuf_count = 0;
-  finfo.shndxbuf_size = 0;
+  flinfo.contents = NULL;
+  flinfo.external_relocs = NULL;
+  flinfo.internal_relocs = NULL;
+  flinfo.external_syms = NULL;
+  flinfo.locsym_shndx = NULL;
+  flinfo.internal_syms = NULL;
+  flinfo.indices = NULL;
+  flinfo.sections = NULL;
+  flinfo.symbuf = NULL;
+  flinfo.symshndxbuf = NULL;
+  flinfo.symbuf_count = 0;
+  flinfo.shndxbuf_size = 0;
+  flinfo.filesym_count = 0;
 
   /* The object attributes have been merged.  Remove the input
      sections from the link, and set the contents of the output
@@ -10408,7 +10561,13 @@
 	      if (sec->flags & SEC_MERGE)
 		merged = TRUE;
 
-	      if (info->relocatable || info->emitrelocations)
+	      if (esdo->this_hdr.sh_type == SHT_REL
+		  || esdo->this_hdr.sh_type == SHT_RELA)
+		/* Some backends use reloc_count in relocation sections
+		   to count particular types of relocs.  Of course,
+		   reloc sections themselves can't have relocations.  */
+		reloc_count = 0;
+	      else if (info->relocatable || info->emitrelocations)
 		reloc_count = sec->reloc_count;
 	      else if (bed->elf_backend_count_relocs)
 		reloc_count = (*bed->elf_backend_count_relocs) (info, sec);
@@ -10546,32 +10705,32 @@
   /* sh_offset is set just below.  */
   symtab_hdr->sh_addralign = (bfd_vma) 1 << bed->s->log_file_align;
 
-  off = elf_tdata (abfd)->next_file_pos;
+  off = elf_next_file_pos (abfd);
   off = _bfd_elf_assign_file_position_for_section (symtab_hdr, off, TRUE);
 
-  /* Note that at this point elf_tdata (abfd)->next_file_pos is
+  /* Note that at this point elf_next_file_pos (abfd) is
      incorrect.  We do not yet know the size of the .symtab section.
      We correct next_file_pos below, after we do know the size.  */
 
   /* Allocate a buffer to hold swapped out symbols.  This is to avoid
      continuously seeking to the right position in the file.  */
   if (! info->keep_memory || max_sym_count < 20)
-    finfo.symbuf_size = 20;
+    flinfo.symbuf_size = 20;
   else
-    finfo.symbuf_size = max_sym_count;
-  amt = finfo.symbuf_size;
+    flinfo.symbuf_size = max_sym_count;
+  amt = flinfo.symbuf_size;
   amt *= bed->s->sizeof_sym;
-  finfo.symbuf = (bfd_byte *) bfd_malloc (amt);
-  if (finfo.symbuf == NULL)
+  flinfo.symbuf = (bfd_byte *) bfd_malloc (amt);
+  if (flinfo.symbuf == NULL)
     goto error_return;
   if (elf_numsections (abfd) > (SHN_LORESERVE & 0xFFFF))
     {
       /* Wild guess at number of output symbols.  realloc'd as needed.  */
       amt = 2 * max_sym_count + elf_numsections (abfd) + 1000;
-      finfo.shndxbuf_size = amt;
+      flinfo.shndxbuf_size = amt;
       amt *= sizeof (Elf_External_Sym_Shndx);
-      finfo.symshndxbuf = (Elf_External_Sym_Shndx *) bfd_zmalloc (amt);
-      if (finfo.symshndxbuf == NULL)
+      flinfo.symshndxbuf = (Elf_External_Sym_Shndx *) bfd_zmalloc (amt);
+      if (flinfo.symshndxbuf == NULL)
 	goto error_return;
     }
 
@@ -10586,7 +10745,7 @@
       elfsym.st_other = 0;
       elfsym.st_shndx = SHN_UNDEF;
       elfsym.st_target_internal = 0;
-      if (elf_link_output_sym (&finfo, NULL, &elfsym, bfd_und_section_ptr,
+      if (elf_link_output_sym (&flinfo, NULL, &elfsym, bfd_und_section_ptr,
 			       NULL) != 1)
 	goto error_return;
     }
@@ -10613,7 +10772,7 @@
 	      elfsym.st_shndx = i;
 	      if (!info->relocatable)
 		elfsym.st_value = o->vma;
-	      if (elf_link_output_sym (&finfo, NULL, &elfsym, o, NULL) != 1)
+	      if (elf_link_output_sym (&flinfo, NULL, &elfsym, o, NULL) != 1)
 		goto error_return;
 	    }
 	}
@@ -10623,15 +10782,15 @@
      files.  */
   if (max_contents_size != 0)
     {
-      finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
-      if (finfo.contents == NULL)
+      flinfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
+      if (flinfo.contents == NULL)
 	goto error_return;
     }
 
   if (max_external_reloc_size != 0)
     {
-      finfo.external_relocs = bfd_malloc (max_external_reloc_size);
-      if (finfo.external_relocs == NULL)
+      flinfo.external_relocs = bfd_malloc (max_external_reloc_size);
+      if (flinfo.external_relocs == NULL)
 	goto error_return;
     }
 
@@ -10639,39 +10798,39 @@
     {
       amt = max_internal_reloc_count * bed->s->int_rels_per_ext_rel;
       amt *= sizeof (Elf_Internal_Rela);
-      finfo.internal_relocs = (Elf_Internal_Rela *) bfd_malloc (amt);
-      if (finfo.internal_relocs == NULL)
+      flinfo.internal_relocs = (Elf_Internal_Rela *) bfd_malloc (amt);
+      if (flinfo.internal_relocs == NULL)
 	goto error_return;
     }
 
   if (max_sym_count != 0)
     {
       amt = max_sym_count * bed->s->sizeof_sym;
-      finfo.external_syms = (bfd_byte *) bfd_malloc (amt);
-      if (finfo.external_syms == NULL)
+      flinfo.external_syms = (bfd_byte *) bfd_malloc (amt);
+      if (flinfo.external_syms == NULL)
 	goto error_return;
 
       amt = max_sym_count * sizeof (Elf_Internal_Sym);
-      finfo.internal_syms = (Elf_Internal_Sym *) bfd_malloc (amt);
-      if (finfo.internal_syms == NULL)
+      flinfo.internal_syms = (Elf_Internal_Sym *) bfd_malloc (amt);
+      if (flinfo.internal_syms == NULL)
 	goto error_return;
 
       amt = max_sym_count * sizeof (long);
-      finfo.indices = (long int *) bfd_malloc (amt);
-      if (finfo.indices == NULL)
+      flinfo.indices = (long int *) bfd_malloc (amt);
+      if (flinfo.indices == NULL)
 	goto error_return;
 
       amt = max_sym_count * sizeof (asection *);
-      finfo.sections = (asection **) bfd_malloc (amt);
-      if (finfo.sections == NULL)
+      flinfo.sections = (asection **) bfd_malloc (amt);
+      if (flinfo.sections == NULL)
 	goto error_return;
     }
 
   if (max_sym_shndx_count != 0)
     {
       amt = max_sym_shndx_count * sizeof (Elf_External_Sym_Shndx);
-      finfo.locsym_shndx = (Elf_External_Sym_Shndx *) bfd_malloc (amt);
-      if (finfo.locsym_shndx == NULL)
+      flinfo.locsym_shndx = (Elf_External_Sym_Shndx *) bfd_malloc (amt);
+      if (flinfo.locsym_shndx == NULL)
 	goto error_return;
     }
 
@@ -10745,7 +10904,7 @@
 	    {
 	      if (! sub->output_has_begun)
 		{
-		  if (! elf_link_input_bfd (&finfo, sub))
+		  if (! elf_link_input_bfd (&flinfo, sub))
 		    goto error_return;
 		  sub->output_has_begun = TRUE;
 		}
@@ -10803,6 +10962,17 @@
 	  }
     }
 
+  /* Output a FILE symbol so that following locals are not associated
+     with the wrong input file.  */
+  memset (&elfsym, 0, sizeof (elfsym));
+  elfsym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FILE);
+  elfsym.st_shndx = SHN_ABS;
+
+  if (flinfo.filesym_count > 1
+      && !elf_link_output_sym (&flinfo, NULL, &elfsym,
+			       bfd_und_section_ptr, NULL))
+    return FALSE;
+
   /* Output any global symbols that got converted to local in a
      version script or due to symbol visibility.  We do this in a
      separate step since ELF requires all local symbols to appear
@@ -10810,12 +10980,27 @@
      some global symbols were, in fact, converted to become local.
      FIXME: Will this work correctly with the Irix 5 linker?  */
   eoinfo.failed = FALSE;
-  eoinfo.finfo = &finfo;
+  eoinfo.flinfo = &flinfo;
   eoinfo.localsyms = TRUE;
+  eoinfo.need_second_pass = FALSE;
+  eoinfo.second_pass = FALSE;
   bfd_hash_traverse (&info->hash->table, elf_link_output_extsym, &eoinfo);
   if (eoinfo.failed)
     return FALSE;
 
+  if (flinfo.filesym_count == 1
+      && !elf_link_output_sym (&flinfo, NULL, &elfsym,
+			       bfd_und_section_ptr, NULL))
+    return FALSE;
+
+  if (eoinfo.need_second_pass)
+    {
+      eoinfo.second_pass = TRUE;
+      bfd_hash_traverse (&info->hash->table, elf_link_output_extsym, &eoinfo);
+      if (eoinfo.failed)
+	return FALSE;
+    }
+
   /* If backend needs to output some local symbols not present in the hash
      table, do it now.  */
   if (bed->elf_backend_output_arch_local_syms)
@@ -10825,7 +11010,7 @@
 	 struct elf_link_hash_entry *);
 
       if (! ((*bed->elf_backend_output_arch_local_syms)
-	     (abfd, info, &finfo, (out_sym_func) elf_link_output_sym)))
+	     (abfd, info, &flinfo, (out_sym_func) elf_link_output_sym)))
 	return FALSE;
     }
 
@@ -10838,10 +11023,11 @@
   symtab_hdr->sh_info = bfd_get_symcount (abfd);
 
   if (dynamic
-      && finfo.dynsym_sec->output_section != bfd_abs_section_ptr)
+      && flinfo.dynsym_sec != NULL
+      && flinfo.dynsym_sec->output_section != bfd_abs_section_ptr)
     {
       Elf_Internal_Sym sym;
-      bfd_byte *dynsym = finfo.dynsym_sec->contents;
+      bfd_byte *dynsym = flinfo.dynsym_sec->contents;
       long last_local = 0;
 
       /* Write out the section symbols for the output sections.  */
@@ -10913,14 +11099,14 @@
 	    }
 	}
 
-      elf_section_data (finfo.dynsym_sec->output_section)->this_hdr.sh_info =
+      elf_section_data (flinfo.dynsym_sec->output_section)->this_hdr.sh_info =
 	last_local + 1;
     }
 
   /* We get the global symbols from the hash table.  */
   eoinfo.failed = FALSE;
   eoinfo.localsyms = FALSE;
-  eoinfo.finfo = &finfo;
+  eoinfo.flinfo = &flinfo;
   bfd_hash_traverse (&info->hash->table, elf_link_output_extsym, &eoinfo);
   if (eoinfo.failed)
     return FALSE;
@@ -10934,12 +11120,12 @@
 	 struct elf_link_hash_entry *);
 
       if (! ((*bed->elf_backend_output_arch_syms)
-	     (abfd, info, &finfo, (out_sym_func) elf_link_output_sym)))
+	     (abfd, info, &flinfo, (out_sym_func) elf_link_output_sym)))
 	return FALSE;
     }
 
   /* Flush all symbols to the file.  */
-  if (! elf_link_flush_output_syms (&finfo, bed))
+  if (! elf_link_flush_output_syms (&flinfo, bed))
     return FALSE;
 
   /* Now we know the size of the symtab section.  */
@@ -10958,7 +11144,7 @@
 						       off, TRUE);
 
       if (bfd_seek (abfd, symtab_shndx_hdr->sh_offset, SEEK_SET) != 0
-	  || (bfd_bwrite (finfo.symshndxbuf, amt, abfd) != amt))
+	  || (bfd_bwrite (flinfo.symshndxbuf, amt, abfd) != amt))
 	return FALSE;
     }
 
@@ -10970,7 +11156,7 @@
   symstrtab_hdr->sh_type = SHT_STRTAB;
   symstrtab_hdr->sh_flags = 0;
   symstrtab_hdr->sh_addr = 0;
-  symstrtab_hdr->sh_size = _bfd_stringtab_size (finfo.symstrtab);
+  symstrtab_hdr->sh_size = _bfd_stringtab_size (flinfo.symstrtab);
   symstrtab_hdr->sh_entsize = 0;
   symstrtab_hdr->sh_link = 0;
   symstrtab_hdr->sh_info = 0;
@@ -10978,12 +11164,12 @@
   symstrtab_hdr->sh_addralign = 1;
 
   off = _bfd_elf_assign_file_position_for_section (symstrtab_hdr, off, TRUE);
-  elf_tdata (abfd)->next_file_pos = off;
+  elf_next_file_pos (abfd) = off;
 
   if (bfd_get_symcount (abfd) > 0)
     {
       if (bfd_seek (abfd, symstrtab_hdr->sh_offset, SEEK_SET) != 0
-	  || ! _bfd_stringtab_emit (abfd, finfo.symstrtab))
+	  || ! _bfd_stringtab_emit (abfd, flinfo.symstrtab))
 	return FALSE;
     }
 
@@ -11014,7 +11200,7 @@
       bfd_byte *dyncon, *dynconend;
 
       /* Fix up .dynamic entries.  */
-      o = bfd_get_section_by_name (dynobj, ".dynamic");
+      o = bfd_get_linker_section (dynobj, ".dynamic");
       BFD_ASSERT (o != NULL);
 
       dyncon = o->contents;
@@ -11188,15 +11374,12 @@
 	goto error_return;
 
       /* Check for DT_TEXTREL (late, in case the backend removes it).  */
-      if ((info->warn_shared_textrel && info->shared)
-	  || info->error_textrel)
+      if (((info->warn_shared_textrel && info->shared)
+	   || info->error_textrel)
+	  && (o = bfd_get_linker_section (dynobj, ".dynamic")) != NULL)
 	{
 	  bfd_byte *dyncon, *dynconend;
 
-	  /* Fix up .dynamic entries.  */
-	  o = bfd_get_section_by_name (dynobj, ".dynamic");
-	  BFD_ASSERT (o != NULL);
-
 	  dyncon = o->contents;
 	  dynconend = o->contents + o->size;
 	  for (; dyncon < dynconend; dyncon += bed->s->sizeof_dyn)
@@ -11234,9 +11417,7 @@
 	    continue;
 	  if (elf_hash_table (info)->eh_info.hdr_sec == o)
 	    continue;
-	  if ((elf_section_data (o->output_section)->this_hdr.sh_type
-	       != SHT_STRTAB)
-	      && (strcmp (bfd_get_section_name (abfd, o), ".dynstr") != 0))
+	  if (strcmp (o->name, ".dynstr") != 0)
 	    {
 	      /* FIXME: octets_per_byte.  */
 	      if (! bfd_set_section_contents (abfd, o->output_section,
@@ -11274,44 +11455,12 @@
 	goto error_return;
     }
 
-  if (info->eh_frame_hdr)
-    {
-      if (! _bfd_elf_write_section_eh_frame_hdr (abfd, info))
-	goto error_return;
-    }
+  if (! _bfd_elf_write_section_eh_frame_hdr (abfd, info))
+    goto error_return;
 
-  if (finfo.symstrtab != NULL)
-    _bfd_stringtab_free (finfo.symstrtab);
-  if (finfo.contents != NULL)
-    free (finfo.contents);
-  if (finfo.external_relocs != NULL)
-    free (finfo.external_relocs);
-  if (finfo.internal_relocs != NULL)
-    free (finfo.internal_relocs);
-  if (finfo.external_syms != NULL)
-    free (finfo.external_syms);
-  if (finfo.locsym_shndx != NULL)
-    free (finfo.locsym_shndx);
-  if (finfo.internal_syms != NULL)
-    free (finfo.internal_syms);
-  if (finfo.indices != NULL)
-    free (finfo.indices);
-  if (finfo.sections != NULL)
-    free (finfo.sections);
-  if (finfo.symbuf != NULL)
-    free (finfo.symbuf);
-  if (finfo.symshndxbuf != NULL)
-    free (finfo.symshndxbuf);
-  for (o = abfd->sections; o != NULL; o = o->next)
-    {
-      struct bfd_elf_section_data *esdo = elf_section_data (o);
-      if ((o->flags & SEC_RELOC) != 0 && esdo->rel.hashes != NULL)
-	free (esdo->rel.hashes);
-      if ((o->flags & SEC_RELOC) != 0 && esdo->rela.hashes != NULL)
-	free (esdo->rela.hashes);
-    }
+  elf_final_link_free (abfd, &flinfo);
 
-  elf_tdata (abfd)->linker = TRUE;
+  elf_linker (abfd) = TRUE;
 
   if (attr_section)
     {
@@ -11326,37 +11475,7 @@
   return TRUE;
 
  error_return:
-  if (finfo.symstrtab != NULL)
-    _bfd_stringtab_free (finfo.symstrtab);
-  if (finfo.contents != NULL)
-    free (finfo.contents);
-  if (finfo.external_relocs != NULL)
-    free (finfo.external_relocs);
-  if (finfo.internal_relocs != NULL)
-    free (finfo.internal_relocs);
-  if (finfo.external_syms != NULL)
-    free (finfo.external_syms);
-  if (finfo.locsym_shndx != NULL)
-    free (finfo.locsym_shndx);
-  if (finfo.internal_syms != NULL)
-    free (finfo.internal_syms);
-  if (finfo.indices != NULL)
-    free (finfo.indices);
-  if (finfo.sections != NULL)
-    free (finfo.sections);
-  if (finfo.symbuf != NULL)
-    free (finfo.symbuf);
-  if (finfo.symshndxbuf != NULL)
-    free (finfo.symshndxbuf);
-  for (o = abfd->sections; o != NULL; o = o->next)
-    {
-      struct bfd_elf_section_data *esdo = elf_section_data (o);
-      if ((o->flags & SEC_RELOC) != 0 && esdo->rel.hashes != NULL)
-	free (esdo->rel.hashes);
-      if ((o->flags & SEC_RELOC) != 0 && esdo->rela.hashes != NULL)
-	free (esdo->rela.hashes);
-    }
-
+  elf_final_link_free (abfd, &flinfo);
   return FALSE;
 }
 
@@ -11534,7 +11653,7 @@
 	  if (sec_name && *sec_name != '\0')
 	    {
 	      bfd *i;
-	      
+
 	      for (i = info->input_bfds; i; i = i->link_next)
 		{
 		  sec = bfd_get_section_by_name (i, sec_name);
@@ -11579,11 +11698,11 @@
 	h = (struct elf_link_hash_entry *) h->root.u.i.link;
       h->mark = 1;
       /* If this symbol is weak and there is a non-weak definition, we
-         keep the non-weak definition because many backends put
-         dynamic reloc info on the non-weak definition for code
-         handling copy relocs.  */
+	 keep the non-weak definition because many backends put
+	 dynamic reloc info on the non-weak definition for code
+	 handling copy relocs.  */
       if (h->u.weakdef != NULL)
-        h->u.weakdef->mark = 1;
+	h->u.weakdef->mark = 1;
       return (*gc_mark_hook) (sec, info, cookie->rel, h, NULL);
     }
 
@@ -11606,7 +11725,8 @@
   rsec = _bfd_elf_gc_mark_rsec (info, sec, gc_mark_hook, cookie);
   if (rsec && !rsec->gc_mark)
     {
-      if (bfd_get_flavour (rsec->owner) != bfd_target_elf_flavour)
+      if (bfd_get_flavour (rsec->owner) != bfd_target_elf_flavour
+	  || (rsec->owner->flags & DYNAMIC) != 0)
 	rsec->gc_mark = 1;
       else if (!_bfd_elf_gc_mark (info, rsec, gc_mark_hook))
 	return FALSE;
@@ -11687,23 +11807,30 @@
     {
       asection *isec;
       bfd_boolean some_kept;
+      bfd_boolean debug_frag_seen;
 
       if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
 	continue;
 
-      /* Ensure all linker created sections are kept, and see whether
-	 any other section is already marked.  */
-      some_kept = FALSE;
+      /* Ensure all linker created sections are kept,
+	 see if any other section is already marked,
+	 and note if we have any fragmented debug sections.  */
+      debug_frag_seen = some_kept = FALSE;
       for (isec = ibfd->sections; isec != NULL; isec = isec->next)
 	{
 	  if ((isec->flags & SEC_LINKER_CREATED) != 0)
 	    isec->gc_mark = 1;
 	  else if (isec->gc_mark)
 	    some_kept = TRUE;
+
+	  if (debug_frag_seen == FALSE
+	      && (isec->flags & SEC_DEBUGGING)
+	      && CONST_STRNEQ (isec->name, ".debug_line."))
+	    debug_frag_seen = TRUE;
 	}
 
       /* If no section in this file will be kept, then we can
-	 toss out debug sections.  */
+	 toss out the debug and special sections.  */
       if (!some_kept)
 	continue;
 
@@ -11715,6 +11842,45 @@
 	    && ((isec->flags & SEC_DEBUGGING) != 0
 		|| (isec->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0))
 	  isec->gc_mark = 1;
+
+      if (! debug_frag_seen)
+	continue;
+
+      /* Look for CODE sections which are going to be discarded,
+	 and find and discard any fragmented debug sections which
+	 are associated with that code section.  */
+      for (isec = ibfd->sections; isec != NULL; isec = isec->next)
+	if ((isec->flags & SEC_CODE) != 0
+	    && isec->gc_mark == 0)
+	  {
+	    unsigned int ilen;
+	    asection *dsec;
+
+	    ilen = strlen (isec->name);
+
+	    /* Association is determined by the name of the debug section
+	       containing the name of the code section as a suffix.  For
+	       example .debug_line.text.foo is a debug section associated
+	       with .text.foo.  */
+	    for (dsec = ibfd->sections; dsec != NULL; dsec = dsec->next)
+	      {
+		unsigned int dlen;
+
+		if (dsec->gc_mark == 0
+		    || (dsec->flags & SEC_DEBUGGING) == 0)
+		  continue;
+
+		dlen = strlen (dsec->name);
+
+		if (dlen > ilen
+		    && strncmp (dsec->name + (dlen - ilen),
+				isec->name, ilen) == 0)
+		  {
+		    dsec->gc_mark = 0;
+		    break;
+		  }
+	      }
+	  }
     }
   return TRUE;
 }
@@ -11733,13 +11899,14 @@
 {
   if (!h->mark
       && (((h->root.type == bfd_link_hash_defined
-            || h->root.type == bfd_link_hash_defweak)
-           && !(h->def_regular
-                && h->root.u.def.section->gc_mark))
-          || h->root.type == bfd_link_hash_undefined
-          || h->root.type == bfd_link_hash_undefweak))
+	    || h->root.type == bfd_link_hash_defweak)
+	   && !(h->def_regular
+		&& h->root.u.def.section->gc_mark))
+	  || h->root.type == bfd_link_hash_undefined
+	  || h->root.type == bfd_link_hash_undefweak))
     {
       struct elf_gc_sweep_symbol_info *inf;
+
       inf = (struct elf_gc_sweep_symbol_info *) data;
       (*inf->hide_symbol) (inf->info, h, TRUE);
       h->def_regular = 0;
@@ -12016,12 +12183,14 @@
       struct elf_reloc_cookie cookie;
 
       sec = bfd_get_section_by_name (sub, ".eh_frame");
-      if (sec && init_reloc_cookie_for_section (&cookie, info, sec))
+      while (sec && init_reloc_cookie_for_section (&cookie, info, sec))
 	{
 	  _bfd_elf_parse_eh_frame (sub, info, sec, &cookie);
-	  if (elf_section_data (sec)->sec_info)
+	  if (elf_section_data (sec)->sec_info
+	      && (sec->flags & SEC_LINKER_CREATED) == 0)
 	    elf_eh_frame_section (sub) = sec;
 	  fini_reloc_cookie_for_section (&cookie, sec);
+	  sec = bfd_get_next_section_by_name (sec);
 	}
     }
   _bfd_elf_end_eh_frame_parsing (info);
@@ -12237,58 +12406,73 @@
   { "SHF_EXCLUDE", SHF_EXCLUDE },
 };
 
-void
+/* Returns TRUE if the section is to be included, otherwise FALSE.  */
+bfd_boolean
 bfd_elf_lookup_section_flags (struct bfd_link_info *info,
-			      struct flag_info *finfo)
+			      struct flag_info *flaginfo,
+			      asection *section)
 {
-  bfd *output_bfd = info->output_bfd;
-  const struct elf_backend_data *bed = get_elf_backend_data (output_bfd);
-  struct flag_info_list *tf = finfo->flag_list;
-  int with_hex = 0;
-  int without_hex = 0;
+  const bfd_vma sh_flags = elf_section_flags (section);
 
-  for (tf = finfo->flag_list; tf != NULL; tf = tf->next)
+  if (!flaginfo->flags_initialized)
     {
-      int i;
-      if (bed->elf_backend_lookup_section_flags_hook)
-	{
-	  flagword hexval =
-	     (*bed->elf_backend_lookup_section_flags_hook) ((char *) tf->name);
+      bfd *obfd = info->output_bfd;
+      const struct elf_backend_data *bed = get_elf_backend_data (obfd);
+      struct flag_info_list *tf = flaginfo->flag_list;
+      int with_hex = 0;
+      int without_hex = 0;
 
-	  if (hexval != 0)
-	    {
-	      if (tf->with == with_flags)
-		with_hex |= hexval;
-	      else if (tf->with == without_flags)
-		without_hex |= hexval;
-	      tf->valid = TRUE;
-	      continue;
-	    }
-	}
-      for (i = 0; i < 12; i++)
+      for (tf = flaginfo->flag_list; tf != NULL; tf = tf->next)
 	{
-	  if (!strcmp (tf->name, elf_flags_to_names[i].flag_name))
+	  unsigned i;
+	  flagword (*lookup) (char *);
+
+	  lookup = bed->elf_backend_lookup_section_flags_hook;
+	  if (lookup != NULL)
 	    {
-	      if (tf->with == with_flags)
-		with_hex |= elf_flags_to_names[i].flag_value;
-	      else if (tf->with == without_flags)
-		without_hex |= elf_flags_to_names[i].flag_value;
-	      tf->valid = TRUE;
-	      continue;
+	      flagword hexval = (*lookup) ((char *) tf->name);
+
+	      if (hexval != 0)
+		{
+		  if (tf->with == with_flags)
+		    with_hex |= hexval;
+		  else if (tf->with == without_flags)
+		    without_hex |= hexval;
+		  tf->valid = TRUE;
+		  continue;
+		}
 	    }
-	}
-      if (tf->valid == FALSE)
-	{
-	  info->callbacks->einfo 
+	  for (i = 0; i < ARRAY_SIZE (elf_flags_to_names); ++i)
+	    {
+	      if (strcmp (tf->name, elf_flags_to_names[i].flag_name) == 0)
+		{
+		  if (tf->with == with_flags)
+		    with_hex |= elf_flags_to_names[i].flag_value;
+		  else if (tf->with == without_flags)
+		    without_hex |= elf_flags_to_names[i].flag_value;
+		  tf->valid = TRUE;
+		  break;
+		}
+	    }
+	  if (!tf->valid)
+	    {
+	      info->callbacks->einfo
 		(_("Unrecognized INPUT_SECTION_FLAG %s\n"), tf->name);
-	  return;
+	      return FALSE;
+	    }
 	}
+      flaginfo->flags_initialized = TRUE;
+      flaginfo->only_with_flags |= with_hex;
+      flaginfo->not_with_flags |= without_hex;
     }
- finfo->flags_initialized = TRUE;
- finfo->only_with_flags |= with_hex;
- finfo->not_with_flags |= without_hex;
 
- return;
+  if ((flaginfo->only_with_flags & sh_flags) != flaginfo->only_with_flags)
+    return FALSE;
+
+  if ((flaginfo->not_with_flags & sh_flags) != 0)
+    return FALSE;
+
+  return TRUE;
 }
 
 struct alloc_got_off_arg {
@@ -12431,7 +12615,7 @@
 
 	  if ((h->root.type == bfd_link_hash_defined
 	       || h->root.type == bfd_link_hash_defweak)
-	      && elf_discarded_section (h->root.u.def.section))
+	      && discarded_section (h->root.u.def.section))
 	    return TRUE;
 	  else
 	    return FALSE;
@@ -12447,7 +12631,7 @@
 	  /* Need to: get the symbol; get the section.  */
 	  isym = &rcookie->locsyms[r_symndx];
 	  isec = bfd_section_from_elf_index (rcookie->abfd, isym->st_shndx);
-	  if (isec != NULL && elf_discarded_section (isec))
+	  if (isec != NULL && discarded_section (isec))
 	    return TRUE;
 	}
       return FALSE;
@@ -12481,24 +12665,21 @@
 
       bed = get_elf_backend_data (abfd);
 
-      if ((abfd->flags & DYNAMIC) != 0)
-	continue;
-
       eh = NULL;
       if (!info->relocatable)
 	{
 	  eh = bfd_get_section_by_name (abfd, ".eh_frame");
-	  if (eh != NULL
-	      && (eh->size == 0
-		  || bfd_is_abs_section (eh->output_section)))
-	    eh = NULL;
+	  while (eh != NULL
+		 && (eh->size == 0
+		     || bfd_is_abs_section (eh->output_section)))
+	    eh = bfd_get_next_section_by_name (eh);
 	}
 
       stab = bfd_get_section_by_name (abfd, ".stab");
       if (stab != NULL
 	  && (stab->size == 0
 	      || bfd_is_abs_section (stab->output_section)
-	      || stab->sec_info_type != ELF_INFO_TYPE_STABS))
+	      || stab->sec_info_type != SEC_INFO_TYPE_STABS))
 	stab = NULL;
 
       if (stab == NULL
@@ -12521,8 +12702,8 @@
 	  fini_reloc_cookie_rels (&cookie, stab);
 	}
 
-      if (eh != NULL
-	  && init_reloc_cookie_rels (&cookie, info, abfd, eh))
+      while (eh != NULL
+	     && init_reloc_cookie_rels (&cookie, info, abfd, eh))
 	{
 	  _bfd_elf_parse_eh_frame (abfd, info, eh, &cookie);
 	  if (_bfd_elf_discard_section_eh_frame (abfd, info, eh,
@@ -12530,6 +12711,7 @@
 						 &cookie))
 	    ret = TRUE;
 	  fini_reloc_cookie_rels (&cookie, eh);
+	  eh = bfd_get_next_section_by_name (eh);
 	}
 
       if (bed->elf_backend_discard_info != NULL
@@ -12742,7 +12924,7 @@
     return NULL;
 
   name = bfd_alloc (abfd, strlen (prefix) + strlen (old_name) + 1);
-  sprintf (name, "%s%s", prefix, old_name); 
+  sprintf (name, "%s%s", prefix, old_name);
 
   return name;
 }
@@ -12765,7 +12947,7 @@
 
       if (name != NULL)
 	{
-	  reloc_sec = bfd_get_section_by_name (abfd, name);
+	  reloc_sec = bfd_get_linker_section (abfd, name);
 
 	  if (reloc_sec != NULL)
 	    elf_section_data (sec)->sreloc = reloc_sec;
@@ -12801,19 +12983,23 @@
       if (name == NULL)
 	return NULL;
 
-      reloc_sec = bfd_get_section_by_name (dynobj, name);
+      reloc_sec = bfd_get_linker_section (dynobj, name);
 
       if (reloc_sec == NULL)
 	{
-	  flagword flags;
-
-	  flags = (SEC_HAS_CONTENTS | SEC_READONLY | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+	  flagword flags = (SEC_HAS_CONTENTS | SEC_READONLY
+			    | SEC_IN_MEMORY | SEC_LINKER_CREATED);
 	  if ((sec->flags & SEC_ALLOC) != 0)
 	    flags |= SEC_ALLOC | SEC_LOAD;
 
-	  reloc_sec = bfd_make_section_with_flags (dynobj, name, flags);
+	  reloc_sec = bfd_make_section_anyway_with_flags (dynobj, name, flags);
 	  if (reloc_sec != NULL)
 	    {
+	      /* _bfd_elf_get_sec_type_attr chooses a section type by
+		 name.  Override as it may be wrong, eg. for a user
+		 section named "auto" we'll get ".relauto" which is
+		 seen to be a .rela section.  */
+	      elf_section_type (reloc_sec) = is_rela ? SHT_RELA : SHT_REL;
 	      if (! bfd_set_section_alignment (dynobj, reloc_sec, alignment))
 		reloc_sec = NULL;
 	    }
@@ -12857,5 +13043,5 @@
   const struct elf_backend_data *bed = get_elf_backend_data (abfd);
   bfd_byte *loc = s->contents + (s->reloc_count++ * bed->s->sizeof_rel);
   BFD_ASSERT (loc + bed->s->sizeof_rel <= s->contents + s->size);
-  bed->s->swap_reloca_out (abfd, rel, loc);
+  bed->s->swap_reloc_out (abfd, rel, loc);
 }
diff --git a/bfd/elfn32-mips.c b/bfd/elfn32-mips.c
index 00ec8b0..2daf79e 100644
--- a/bfd/elfn32-mips.c
+++ b/bfd/elfn32-mips.c
@@ -1302,7 +1302,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_DTPMOD32",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0xffffffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1316,7 +1316,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_DTPREL32",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0xffffffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1334,7 +1334,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_GD",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1349,7 +1349,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_LDM",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1364,7 +1364,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_DTPREL_HI16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1379,7 +1379,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_DTPREL_LO16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1394,7 +1394,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_GOTTPREL",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1409,7 +1409,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_TPREL32",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0xffffffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0xffffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1426,7 +1426,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_TPREL_HI16", /* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1441,7 +1441,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_TLS_TPREL_LO16", /* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1555,6 +1555,111 @@
 	 0x0000ffff,		/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS general dynamic variable reference.  */
+  HOWTO (R_MIPS16_TLS_GD,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_GD",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS local dynamic variable reference.  */
+  HOWTO (R_MIPS16_TLS_LDM,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_LDM",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS local dynamic offset.  */
+  HOWTO (R_MIPS16_TLS_DTPREL_HI16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_DTPREL_HI16",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS local dynamic offset.  */
+  HOWTO (R_MIPS16_TLS_DTPREL_LO16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_DTPREL_LO16",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS thread pointer offset.  */
+  HOWTO (R_MIPS16_TLS_GOTTPREL,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_GOTTPREL",	/* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS thread pointer offset.  */
+  HOWTO (R_MIPS16_TLS_TPREL_HI16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_TPREL_HI16", /* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS thread pointer offset.  */
+  HOWTO (R_MIPS16_TLS_TPREL_LO16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_TPREL_LO16", /* name */
+	 TRUE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
 };
 
 static reloc_howto_type elf_mips16_howto_table_rela[] =
@@ -1573,7 +1678,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS16_26",		/* name */
 	 FALSE,			/* partial_inplace */
-	 0x3ffffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x3ffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1588,7 +1693,7 @@
 	 mips16_gprel_reloc,	/* special_function */
 	 "R_MIPS16_GPREL",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,	        /* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1603,7 +1708,7 @@
 	 _bfd_mips_elf_got16_reloc, /* special_function */
 	 "R_MIPS16_GOT16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,	        /* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1618,7 +1723,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS16_CALL16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,	        /* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1633,7 +1738,7 @@
 	 _bfd_mips_elf_hi16_reloc, /* special_function */
 	 "R_MIPS16_HI16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1648,7 +1753,112 @@
 	 _bfd_mips_elf_lo16_reloc, /* special_function */
 	 "R_MIPS16_LO16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS general dynamic variable reference.  */
+  HOWTO (R_MIPS16_TLS_GD,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_GD",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS local dynamic variable reference.  */
+  HOWTO (R_MIPS16_TLS_LDM,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_LDM",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS local dynamic offset.  */
+  HOWTO (R_MIPS16_TLS_DTPREL_HI16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_DTPREL_HI16",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS local dynamic offset.  */
+  HOWTO (R_MIPS16_TLS_DTPREL_LO16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_DTPREL_LO16",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS thread pointer offset.  */
+  HOWTO (R_MIPS16_TLS_GOTTPREL,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_GOTTPREL",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS thread pointer offset.  */
+  HOWTO (R_MIPS16_TLS_TPREL_HI16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_TPREL_HI16", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MIPS16 TLS thread pointer offset.  */
+  HOWTO (R_MIPS16_TLS_TPREL_LO16,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS16_TLS_TPREL_LO16", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 };
@@ -1939,6 +2149,37 @@
 	 0x0000ffff,		/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
+
+  /* Section displacement.  */
+  HOWTO (R_MICROMIPS_SCN_DISP,  /* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MICROMIPS_SCN_DISP", /* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Protected jump conversion.  This is an optimization hint.  No
+     relocation is required for correctness.  */
+  HOWTO (R_MICROMIPS_JALR,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MICROMIPS_JALR",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x00000000,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
 };
 
 static reloc_howto_type elf_micromips_howto_table_rela[] =
@@ -1961,7 +2202,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_26_S1",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x3ffffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x3ffffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1976,7 +2217,7 @@
 	 _bfd_mips_elf_hi16_reloc, /* special_function */
 	 "R_MICROMIPS_HI16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -1991,7 +2232,7 @@
 	 _bfd_mips_elf_lo16_reloc, /* special_function */
 	 "R_MICROMIPS_LO16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2006,7 +2247,7 @@
 	 _bfd_mips_elf32_gprel16_reloc, /* special_function */
 	 "R_MICROMIPS_GPREL16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2021,7 +2262,7 @@
 	 _bfd_mips_elf32_gprel16_reloc, /* special_function */
 	 "R_MICROMIPS_LITERAL",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2036,7 +2277,7 @@
 	 _bfd_mips_elf_got16_reloc, /* special_function */
 	 "R_MICROMIPS_GOT16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2051,7 +2292,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_PC7_S1",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000007f,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000007f,		/* dst_mask */
 	 TRUE),			/* pcrel_offset */
 
@@ -2065,7 +2306,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_PC10_S1",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x000003ff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x000003ff,		/* dst_mask */
 	 TRUE),			/* pcrel_offset */
 
@@ -2079,7 +2320,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_PC16_S1",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 TRUE),			/* pcrel_offset */
 
@@ -2094,7 +2335,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_CALL16",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2112,7 +2353,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_GOT_DISP",/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2127,7 +2368,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_GOT_PAGE",/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2142,7 +2383,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_GOT_OFST",/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2157,7 +2398,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_GOT_HI16",/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2172,7 +2413,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_GOT_LO16",/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2187,7 +2428,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_SUB",	/* name */
 	 FALSE,			/* partial_inplace */
-	 MINUS_ONE,		/* src_mask */
+	 0,			/* src_mask */
 	 MINUS_ONE,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2202,7 +2443,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_HIGHER",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2217,7 +2458,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_HIGHEST",	/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2232,7 +2473,7 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_CALL_HI16",/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
@@ -2247,9 +2488,40 @@
 	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MICROMIPS_CALL_LO16",/* name */
 	 FALSE,			/* partial_inplace */
-	 0x0000ffff,		/* src_mask */
+	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 FALSE),		/* pcrel_offset */
+
+  /* Section displacement.  */
+  HOWTO (R_MICROMIPS_SCN_DISP,  /* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MICROMIPS_SCN_DISP", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Protected jump conversion.  This is an optimization hint.  No
+     relocation is required for correctness.  */
+  HOWTO (R_MICROMIPS_JALR,	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MICROMIPS_JALR",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0x00000000,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
 };
 
 /* GNU extension to record C++ vtable hierarchy */
@@ -2315,6 +2587,23 @@
 	 0,			/* src_mask */
 	 0x0000ffff,		/* dst_mask */
 	 TRUE);			/* pcrel_offset */
+
+/* 32 bit pc-relative.  Used for compact EH tables.  */
+static reloc_howto_type elf_mips_gnu_pcrel32 =
+  HOWTO (R_MIPS_PC32,		/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS_PC32",		/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 TRUE);			/* pcrel_offset */
+
 
 /* Originally a VxWorks extension, but now used for other systems too.  */
 static reloc_howto_type elf_mips_copy_howto =
@@ -2325,7 +2614,7 @@
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_bitfield, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_COPY",		/* name */
 	 FALSE,			/* partial_inplace */
 	 0x0,         		/* src_mask */
@@ -2341,12 +2630,29 @@
 	 FALSE,			/* pc_relative */
 	 0,			/* bitpos */
 	 complain_overflow_bitfield, /* complain_on_overflow */
-	 bfd_elf_generic_reloc,	/* special_function */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
 	 "R_MIPS_JUMP_SLOT",	/* name */
 	 FALSE,			/* partial_inplace */
 	 0x0,         		/* src_mask */
 	 0x0,		        /* dst_mask */
 	 FALSE);		/* pcrel_offset */
+
+/* Used in EH tables.  */
+static reloc_howto_type elf_mips_eh_howto =
+  HOWTO (R_MIPS_EH,		/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed, /* complain_on_overflow */
+	 _bfd_mips_elf_generic_reloc, /* special_function */
+	 "R_MIPS_EH",		/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,	        /* dst_mask */
+	 FALSE);		/* pcrel_offset */
+
 
 /* Set the GP value for OUTPUT_BFD.  Returns FALSE if this is a
    dangerous relocation.  */
@@ -2724,6 +3030,15 @@
   { BFD_RELOC_MIPS16_CALL16, R_MIPS16_CALL16 - R_MIPS16_min },
   { BFD_RELOC_MIPS16_HI16_S, R_MIPS16_HI16 - R_MIPS16_min },
   { BFD_RELOC_MIPS16_LO16, R_MIPS16_LO16 - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_GD, R_MIPS16_TLS_GD - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_LDM, R_MIPS16_TLS_LDM - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_DTPREL_HI16,
+    R_MIPS16_TLS_DTPREL_HI16 - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_DTPREL_LO16,
+    R_MIPS16_TLS_DTPREL_LO16 - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_GOTTPREL, R_MIPS16_TLS_GOTTPREL - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_TPREL_HI16, R_MIPS16_TLS_TPREL_HI16 - R_MIPS16_min },
+  { BFD_RELOC_MIPS16_TLS_TPREL_LO16, R_MIPS16_TLS_TPREL_LO16 - R_MIPS16_min }
 };
 
 static const struct elf_reloc_map micromips_reloc_map[] =
@@ -2748,6 +3063,8 @@
   { BFD_RELOC_MICROMIPS_HIGHEST, R_MICROMIPS_HIGHEST - R_MICROMIPS_min },
   { BFD_RELOC_MICROMIPS_CALL_HI16, R_MICROMIPS_CALL_HI16 - R_MICROMIPS_min },
   { BFD_RELOC_MICROMIPS_CALL_LO16, R_MICROMIPS_CALL_LO16 - R_MICROMIPS_min },
+  { BFD_RELOC_MICROMIPS_SCN_DISP, R_MICROMIPS_SCN_DISP - R_MICROMIPS_min },
+  { BFD_RELOC_MICROMIPS_JALR, R_MICROMIPS_JALR - R_MICROMIPS_min },
 };
 
 /* Given a BFD reloc type, return a howto structure.  */
@@ -2790,6 +3107,10 @@
       return &elf_mips_gnu_vtinherit_howto;
     case BFD_RELOC_VTABLE_ENTRY:
       return &elf_mips_gnu_vtentry_howto;
+    case BFD_RELOC_32_PCREL:
+      return &elf_mips_gnu_pcrel32;
+    case BFD_RELOC_MIPS_EH:
+      return &elf_mips_eh_howto;
     case BFD_RELOC_MIPS_COPY:
       return &elf_mips_copy_howto;
     case BFD_RELOC_MIPS_JUMP_SLOT:
@@ -2838,6 +3159,10 @@
     return &elf_mips_gnu_rel16_s2;
   if (strcasecmp (elf_mips_gnu_rela16_s2.name, r_name) == 0)
     return &elf_mips_gnu_rela16_s2;
+  if (strcasecmp (elf_mips_gnu_pcrel32.name, r_name) == 0)
+    return &elf_mips_gnu_pcrel32;
+  if (strcasecmp (elf_mips_eh_howto.name, r_name) == 0)
+    return &elf_mips_eh_howto;
   if (strcasecmp (elf_mips_copy_howto.name, r_name) == 0)
     return &elf_mips_copy_howto;
   if (strcasecmp (elf_mips_jump_slot_howto.name, r_name) == 0)
@@ -2862,6 +3187,10 @@
 	return &elf_mips_gnu_rela16_s2;
       else
 	return &elf_mips_gnu_rel16_s2;
+    case R_MIPS_PC32:
+      return &elf_mips_gnu_pcrel32;
+    case R_MIPS_EH:
+      return &elf_mips_eh_howto;
     case R_MIPS_COPY:
       return &elf_mips_copy_howto;
     case R_MIPS_JUMP_SLOT:
@@ -2946,6 +3275,9 @@
 {
   unsigned long mach;
 
+  if (!ABI_N32_P (abfd))
+    return FALSE;
+
   /* Irix 5 and 6 are broken.  Object file symbol tables are not always
      sorted correctly such that local symbols precede global symbols,
      and the sh_info field in the symbol table is not always right.  */
@@ -2954,10 +3286,6 @@
 
   mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags);
   bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach);
-
-  if (! ABI_N32_P(abfd))
-    return FALSE;
-
   return TRUE;
 }
 
@@ -2975,10 +3303,10 @@
 
       case 440:		/* Linux/MIPS N32 */
 	/* pr_cursig */
-	elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+	elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
 
 	/* pr_pid */
-	elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
+	elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 24);
 
 	/* pr_reg */
 	offset = 72;
@@ -3001,9 +3329,9 @@
 	return FALSE;
 
       case 128:		/* Linux/MIPS elf_prpsinfo */
-	elf_tdata (abfd)->core_program
+	elf_tdata (abfd)->core->program
 	 = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
-	elf_tdata (abfd)->core_command
+	elf_tdata (abfd)->core->command
 	 = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
     }
 
@@ -3012,7 +3340,7 @@
      implementations, so strip it off if it exists.  */
 
   {
-    char *command = elf_tdata (abfd)->core_command;
+    char *command = elf_tdata (abfd)->core->command;
     int n = strlen (command);
 
     if (0 < n && command[n - 1] == ' ')
@@ -3162,6 +3490,7 @@
 #define bfd_elf32_bfd_print_private_bfd_data \
 					_bfd_mips_elf_print_private_bfd_data
 #define bfd_elf32_bfd_relax_section     _bfd_mips_relax_section
+#define bfd_elf32_mkobject		_bfd_mips_elf_mkobject
 
 /* Support for SGI-ish mips targets using n32 ABI.  */
 
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
new file mode 100644
index 0000000..6096d5f
--- /dev/null
+++ b/bfd/elfnn-aarch64.c
@@ -0,0 +1,7330 @@
+/* AArch64-specific support for NN-bit ELF.
+   Copyright 2009-2013  Free Software Foundation, Inc.
+   Contributed by ARM Ltd.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; see the file COPYING3. If not,
+   see <http://www.gnu.org/licenses/>.  */
+
+/* Notes on implementation:
+
+  Thread Local Store (TLS)
+
+  Overview:
+
+  The implementation currently supports both traditional TLS and TLS
+  descriptors, but only general dynamic (GD).
+
+  For traditional TLS the assembler will present us with code
+  fragments of the form:
+
+  adrp x0, :tlsgd:foo
+                           R_AARCH64_TLSGD_ADR_PAGE21(foo)
+  add  x0, :tlsgd_lo12:foo
+                           R_AARCH64_TLSGD_ADD_LO12_NC(foo)
+  bl   __tls_get_addr
+  nop
+
+  For TLS descriptors the assembler will present us with code
+  fragments of the form:
+
+  adrp  x0, :tlsdesc:foo                      R_AARCH64_TLSDESC_ADR_PAGE21(foo)
+  ldr   x1, [x0, #:tlsdesc_lo12:foo]          R_AARCH64_TLSDESC_LD64_LO12(foo)
+  add   x0, x0, #:tlsdesc_lo12:foo            R_AARCH64_TLSDESC_ADD_LO12(foo)
+  .tlsdesccall foo
+  blr   x1                                    R_AARCH64_TLSDESC_CALL(foo)
+
+  The relocations R_AARCH64_TLSGD_{ADR_PREL21,ADD_LO12_NC} against foo
+  indicate that foo is thread local and should be accessed via the
+  traditional TLS mechanims.
+
+  The relocations R_AARCH64_TLSDESC_{ADR_PAGE21,LD64_LO12_NC,ADD_LO12_NC}
+  against foo indicate that 'foo' is thread local and should be accessed
+  via a TLS descriptor mechanism.
+
+  The precise instruction sequence is only relevant from the
+  perspective of linker relaxation which is currently not implemented.
+
+  The static linker must detect that 'foo' is a TLS object and
+  allocate a double GOT entry. The GOT entry must be created for both
+  global and local TLS symbols. Note that this is different to none
+  TLS local objects which do not need a GOT entry.
+
+  In the traditional TLS mechanism, the double GOT entry is used to
+  provide the tls_index structure, containing module and offset
+  entries. The static linker places the relocation R_AARCH64_TLS_DTPMOD
+  on the module entry. The loader will subsequently fixup this
+  relocation with the module identity.
+
+  For global traditional TLS symbols the static linker places an
+  R_AARCH64_TLS_DTPREL relocation on the offset entry. The loader
+  will subsequently fixup the offset. For local TLS symbols the static
+  linker fixes up offset.
+
+  In the TLS descriptor mechanism the double GOT entry is used to
+  provide the descriptor. The static linker places the relocation
+  R_AARCH64_TLSDESC on the first GOT slot. The loader will
+  subsequently fix this up.
+
+  Implementation:
+
+  The handling of TLS symbols is implemented across a number of
+  different backend functions. The following is a top level view of
+  what processing is performed where.
+
+  The TLS implementation maintains state information for each TLS
+  symbol. The state information for local and global symbols is kept
+  in different places. Global symbols use generic BFD structures while
+  local symbols use backend specific structures that are allocated and
+  maintained entirely by the backend.
+
+  The flow:
+
+  elfNN_aarch64_check_relocs()
+
+  This function is invoked for each relocation.
+
+  The TLS relocations R_AARCH64_TLSGD_{ADR_PREL21,ADD_LO12_NC} and
+  R_AARCH64_TLSDESC_{ADR_PAGE21,LD64_LO12_NC,ADD_LO12_NC} are
+  spotted. One time creation of local symbol data structures are
+  created when the first local symbol is seen.
+
+  The reference count for a symbol is incremented.  The GOT type for
+  each symbol is marked as general dynamic.
+
+  elfNN_aarch64_allocate_dynrelocs ()
+
+  For each global with positive reference count we allocate a double
+  GOT slot. For a traditional TLS symbol we allocate space for two
+  relocation entries on the GOT, for a TLS descriptor symbol we
+  allocate space for one relocation on the slot. Record the GOT offset
+  for this symbol.
+
+  elfNN_aarch64_size_dynamic_sections ()
+
+  Iterate all input BFDS, look for in the local symbol data structure
+  constructed earlier for local TLS symbols and allocate them double
+  GOT slots along with space for a single GOT relocation. Update the
+  local symbol structure to record the GOT offset allocated.
+
+  elfNN_aarch64_relocate_section ()
+
+  Calls elfNN_aarch64_final_link_relocate ()
+
+  Emit the relevant TLS relocations against the GOT for each TLS
+  symbol. For local TLS symbols emit the GOT offset directly. The GOT
+  relocations are emitted once the first time a TLS symbol is
+  encountered. The implementation uses the LSB of the GOT offset to
+  flag that the relevant GOT relocations for a symbol have been
+  emitted. All of the TLS code that uses the GOT offset needs to take
+  care to mask out this flag bit before using the offset.
+
+  elfNN_aarch64_final_link_relocate ()
+
+  Fixup the R_AARCH64_TLSGD_{ADR_PREL21, ADD_LO12_NC} relocations.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libiberty.h"
+#include "libbfd.h"
+#include "bfd_stdint.h"
+#include "elf-bfd.h"
+#include "bfdlink.h"
+#include "objalloc.h"
+#include "elf/aarch64.h"
+#include "elfxx-aarch64.h"
+
+#define ARCH_SIZE	NN
+
+#if ARCH_SIZE == 64
+#define AARCH64_R(NAME)		R_AARCH64_ ## NAME
+#define AARCH64_R_STR(NAME)	"R_AARCH64_" #NAME
+#define HOWTO64(...)		HOWTO (__VA_ARGS__)
+#define HOWTO32(...)		EMPTY_HOWTO (0)
+#define LOG_FILE_ALIGN	3
+#endif
+
+#if ARCH_SIZE == 32
+#define AARCH64_R(NAME)		R_AARCH64_P32_ ## NAME
+#define AARCH64_R_STR(NAME)	"R_AARCH64_P32_" #NAME
+#define HOWTO64(...)		EMPTY_HOWTO (0)
+#define HOWTO32(...)		HOWTO (__VA_ARGS__)
+#define LOG_FILE_ALIGN	2
+#endif
+
+#define IS_AARCH64_TLS_RELOC(R_TYPE)				\
+  ((R_TYPE) == BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21		\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC		\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2		\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1		\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0		\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLS_DTPMOD			\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLS_DTPREL			\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLS_TPREL			\
+   || IS_AARCH64_TLSDESC_RELOC ((R_TYPE)))
+
+#define IS_AARCH64_TLSDESC_RELOC(R_TYPE)			\
+  ((R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_LD_PREL19		\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21		\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21		\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC		\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC	\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_OFF_G1		\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC		\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_LDR			\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_ADD			\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_CALL		\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC)
+
+#define ELIMINATE_COPY_RELOCS 0
+
+/* Return size of a relocation entry.  HTAB is the bfd's
+   elf_aarch64_link_hash_entry.  */
+#define RELOC_SIZE(HTAB) (sizeof (ElfNN_External_Rela))
+
+/* GOT Entry size - 8 bytes in ELF64 and 4 bytes in ELF32.  */
+#define GOT_ENTRY_SIZE                  (ARCH_SIZE / 8)
+#define PLT_ENTRY_SIZE                  (32)
+#define PLT_SMALL_ENTRY_SIZE            (16)
+#define PLT_TLSDESC_ENTRY_SIZE          (32)
+
+/* Encoding of the nop instruction */
+#define INSN_NOP 0xd503201f
+
+#define aarch64_compute_jump_table_size(htab)		\
+  (((htab)->root.srelplt == NULL) ? 0			\
+   : (htab)->root.srelplt->reloc_count * GOT_ENTRY_SIZE)
+
+/* The first entry in a procedure linkage table looks like this
+   if the distance between the PLTGOT and the PLT is < 4GB use
+   these PLT entries. Note that the dynamic linker gets &PLTGOT[2]
+   in x16 and needs to work out PLTGOT[1] by using an address of
+   [x16,#-GOT_ENTRY_SIZE].  */
+static const bfd_byte elfNN_aarch64_small_plt0_entry[PLT_ENTRY_SIZE] =
+{
+  0xf0, 0x7b, 0xbf, 0xa9,	/* stp x16, x30, [sp, #-16]!  */
+  0x10, 0x00, 0x00, 0x90,	/* adrp x16, (GOT+16)  */
+#if ARCH_SIZE == 64
+  0x11, 0x0A, 0x40, 0xf9,	/* ldr x17, [x16, #PLT_GOT+0x10]  */
+  0x10, 0x42, 0x00, 0x91,	/* add x16, x16,#PLT_GOT+0x10   */
+#else
+  0x11, 0x0A, 0x40, 0xb9,	/* ldr w17, [x16, #PLT_GOT+0x8]  */
+  0x10, 0x22, 0x00, 0x11,	/* add w16, w16,#PLT_GOT+0x8   */
+#endif
+  0x20, 0x02, 0x1f, 0xd6,	/* br x17  */
+  0x1f, 0x20, 0x03, 0xd5,	/* nop */
+  0x1f, 0x20, 0x03, 0xd5,	/* nop */
+  0x1f, 0x20, 0x03, 0xd5,	/* nop */
+};
+
+/* Per function entry in a procedure linkage table looks like this
+   if the distance between the PLTGOT and the PLT is < 4GB use
+   these PLT entries.  */
+static const bfd_byte elfNN_aarch64_small_plt_entry[PLT_SMALL_ENTRY_SIZE] =
+{
+  0x10, 0x00, 0x00, 0x90,	/* adrp x16, PLTGOT + n * 8  */
+#if ARCH_SIZE == 64
+  0x11, 0x02, 0x40, 0xf9,	/* ldr x17, [x16, PLTGOT + n * 8] */
+  0x10, 0x02, 0x00, 0x91,	/* add x16, x16, :lo12:PLTGOT + n * 8  */
+#else
+  0x11, 0x02, 0x40, 0xb9,	/* ldr w17, [x16, PLTGOT + n * 4] */
+  0x10, 0x02, 0x00, 0x11,	/* add w16, w16, :lo12:PLTGOT + n * 4  */
+#endif
+  0x20, 0x02, 0x1f, 0xd6,	/* br x17.  */
+};
+
+static const bfd_byte
+elfNN_aarch64_tlsdesc_small_plt_entry[PLT_TLSDESC_ENTRY_SIZE] =
+{
+  0xe2, 0x0f, 0xbf, 0xa9,	/* stp x2, x3, [sp, #-16]! */
+  0x02, 0x00, 0x00, 0x90,	/* adrp x2, 0 */
+  0x03, 0x00, 0x00, 0x90,	/* adrp x3, 0 */
+#if ARCH_SIZE == 64
+  0x42, 0x00, 0x40, 0xf9,	/* ldr x2, [x2, #0] */
+  0x63, 0x00, 0x00, 0x91,	/* add x3, x3, 0 */
+#else
+  0x42, 0x00, 0x40, 0xb9,	/* ldr w2, [x2, #0] */
+  0x63, 0x00, 0x00, 0x11,	/* add w3, w3, 0 */
+#endif
+  0x40, 0x00, 0x1f, 0xd6,	/* br x2 */
+  0x1f, 0x20, 0x03, 0xd5,	/* nop */
+  0x1f, 0x20, 0x03, 0xd5,	/* nop */
+};
+
+#define elf_info_to_howto               elfNN_aarch64_info_to_howto
+#define elf_info_to_howto_rel           elfNN_aarch64_info_to_howto
+
+#define AARCH64_ELF_ABI_VERSION		0
+
+/* In case we're on a 32-bit machine, construct a 64-bit "-1" value.  */
+#define ALL_ONES (~ (bfd_vma) 0)
+
+/* Indexed by the bfd interal reloc enumerators.
+   Therefore, the table needs to be synced with BFD_RELOC_AARCH64_*
+   in reloc.c.   */
+
+static reloc_howto_type elfNN_aarch64_howto_table[] =
+{
+  EMPTY_HOWTO (0),
+
+  /* Basic data relocations.  */
+
+#if ARCH_SIZE == 64
+  HOWTO (R_AARCH64_NULL,	/* type */
+	 0,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 0,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_AARCH64_NULL",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+#else
+  HOWTO (R_AARCH64_NONE,	/* type */
+	 0,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 0,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_AARCH64_NONE",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+#endif
+
+  /* .xword: (S+A) */
+  HOWTO64 (AARCH64_R (ABS64),	/* type */
+	 0,			/* rightshift */
+	 4,			/* size (4 = long long) */
+	 64,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_unsigned,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (ABS64),	/* name */
+	 FALSE,			/* partial_inplace */
+	 ALL_ONES,		/* src_mask */
+	 ALL_ONES,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* .word: (S+A) */
+  HOWTO (AARCH64_R (ABS32),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_unsigned,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (ABS32),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* .half:  (S+A) */
+  HOWTO (AARCH64_R (ABS16),	/* type */
+	 0,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_unsigned,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (ABS16),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* .xword: (S+A-P) */
+  HOWTO64 (AARCH64_R (PREL64),	/* type */
+	 0,			/* rightshift */
+	 4,			/* size (4 = long long) */
+	 64,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (PREL64),	/* name */
+	 FALSE,			/* partial_inplace */
+	 ALL_ONES,		/* src_mask */
+	 ALL_ONES,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  /* .word: (S+A-P) */
+  HOWTO (AARCH64_R (PREL32),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 32,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (PREL32),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  /* .half: (S+A-P) */
+  HOWTO (AARCH64_R (PREL16),	/* type */
+	 0,			/* rightshift */
+	 1,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (PREL16),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  /* Group relocations to create a 16, 32, 48 or 64 bit
+     unsigned data or abs address inline.  */
+
+  /* MOVZ:   ((S+A) >>  0) & 0xffff */
+  HOWTO (AARCH64_R (MOVW_UABS_G0),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_unsigned,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (MOVW_UABS_G0),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MOVK:   ((S+A) >>  0) & 0xffff [no overflow check] */
+  HOWTO (AARCH64_R (MOVW_UABS_G0_NC),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (MOVW_UABS_G0_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MOVZ:   ((S+A) >> 16) & 0xffff */
+  HOWTO (AARCH64_R (MOVW_UABS_G1),	/* type */
+	 16,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_unsigned,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (MOVW_UABS_G1),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MOVK:   ((S+A) >> 16) & 0xffff [no overflow check] */
+  HOWTO64 (AARCH64_R (MOVW_UABS_G1_NC),	/* type */
+	 16,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (MOVW_UABS_G1_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MOVZ:   ((S+A) >> 32) & 0xffff */
+  HOWTO64 (AARCH64_R (MOVW_UABS_G2),	/* type */
+	 32,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_unsigned,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (MOVW_UABS_G2),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MOVK:   ((S+A) >> 32) & 0xffff [no overflow check] */
+  HOWTO64 (AARCH64_R (MOVW_UABS_G2_NC),	/* type */
+	 32,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (MOVW_UABS_G2_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MOVZ:   ((S+A) >> 48) & 0xffff */
+  HOWTO64 (AARCH64_R (MOVW_UABS_G3),	/* type */
+	 48,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_unsigned,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (MOVW_UABS_G3),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Group relocations to create high part of a 16, 32, 48 or 64 bit
+     signed data or abs address inline. Will change instruction
+     to MOVN or MOVZ depending on sign of calculated value.  */
+
+  /* MOV[ZN]:   ((S+A) >>  0) & 0xffff */
+  HOWTO (AARCH64_R (MOVW_SABS_G0),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (MOVW_SABS_G0),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MOV[ZN]:   ((S+A) >> 16) & 0xffff */
+  HOWTO64 (AARCH64_R (MOVW_SABS_G1),	/* type */
+	 16,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (MOVW_SABS_G1),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* MOV[ZN]:   ((S+A) >> 32) & 0xffff */
+  HOWTO64 (AARCH64_R (MOVW_SABS_G2),	/* type */
+	 32,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (MOVW_SABS_G2),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+/* Relocations to generate 19, 21 and 33 bit PC-relative load/store
+   addresses: PG(x) is (x & ~0xfff).  */
+
+  /* LD-lit: ((S+A-P) >> 2) & 0x7ffff */
+  HOWTO (AARCH64_R (LD_PREL_LO19),	/* type */
+	 2,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 19,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (LD_PREL_LO19),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x7ffff,		/* src_mask */
+	 0x7ffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  /* ADR:    (S+A-P) & 0x1fffff */
+  HOWTO (AARCH64_R (ADR_PREL_LO21),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 21,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (ADR_PREL_LO21),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x1fffff,		/* src_mask */
+	 0x1fffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  /* ADRP:   ((PG(S+A)-PG(P)) >> 12) & 0x1fffff */
+  HOWTO (AARCH64_R (ADR_PREL_PG_HI21),	/* type */
+	 12,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 21,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (ADR_PREL_PG_HI21),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x1fffff,		/* src_mask */
+	 0x1fffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  /* ADRP:   ((PG(S+A)-PG(P)) >> 12) & 0x1fffff [no overflow check] */
+  HOWTO64 (AARCH64_R (ADR_PREL_PG_HI21_NC),	/* type */
+	 12,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 21,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (ADR_PREL_PG_HI21_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x1fffff,		/* src_mask */
+	 0x1fffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  /* ADD:    (S+A) & 0xfff [no overflow check] */
+  HOWTO (AARCH64_R (ADD_ABS_LO12_NC),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 10,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (ADD_ABS_LO12_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x3ffc00,		/* src_mask */
+	 0x3ffc00,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* LD/ST8:  (S+A) & 0xfff */
+  HOWTO (AARCH64_R (LDST8_ABS_LO12_NC),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (LDST8_ABS_LO12_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xfff,			/* src_mask */
+	 0xfff,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Relocations for control-flow instructions.  */
+
+  /* TBZ/NZ: ((S+A-P) >> 2) & 0x3fff */
+  HOWTO (AARCH64_R (TSTBR14),	/* type */
+	 2,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 14,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TSTBR14),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x3fff,		/* src_mask */
+	 0x3fff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  /* B.cond: ((S+A-P) >> 2) & 0x7ffff */
+  HOWTO (AARCH64_R (CONDBR19),	/* type */
+	 2,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 19,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (CONDBR19),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x7ffff,		/* src_mask */
+	 0x7ffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  /* B:      ((S+A-P) >> 2) & 0x3ffffff */
+  HOWTO (AARCH64_R (JUMP26),	/* type */
+	 2,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 26,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (JUMP26),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x3ffffff,		/* src_mask */
+	 0x3ffffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  /* BL:     ((S+A-P) >> 2) & 0x3ffffff */
+  HOWTO (AARCH64_R (CALL26),	/* type */
+	 2,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 26,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (CALL26),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x3ffffff,		/* src_mask */
+	 0x3ffffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  /* LD/ST16:  (S+A) & 0xffe */
+  HOWTO (AARCH64_R (LDST16_ABS_LO12_NC),	/* type */
+	 1,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (LDST16_ABS_LO12_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffe,			/* src_mask */
+	 0xffe,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* LD/ST32:  (S+A) & 0xffc */
+  HOWTO (AARCH64_R (LDST32_ABS_LO12_NC),	/* type */
+	 2,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (LDST32_ABS_LO12_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffc,			/* src_mask */
+	 0xffc,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* LD/ST64:  (S+A) & 0xff8 */
+  HOWTO (AARCH64_R (LDST64_ABS_LO12_NC),	/* type */
+	 3,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (LDST64_ABS_LO12_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xff8,			/* src_mask */
+	 0xff8,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* LD/ST128:  (S+A) & 0xff0 */
+  HOWTO (AARCH64_R (LDST128_ABS_LO12_NC),	/* type */
+	 4,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (LDST128_ABS_LO12_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xff0,			/* src_mask */
+	 0xff0,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Set a load-literal immediate field to bits
+     0x1FFFFC of G(S)-P */
+  HOWTO (AARCH64_R (GOT_LD_PREL19),	/* type */
+	 2,				/* rightshift */
+	 2,				/* size (0 = byte,1 = short,2 = long) */
+	 19,				/* bitsize */
+	 TRUE,				/* pc_relative */
+	 0,				/* bitpos */
+	 complain_overflow_signed,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,		/* special_function */
+	 AARCH64_R_STR (GOT_LD_PREL19),	/* name */
+	 FALSE,				/* partial_inplace */
+	 0xffffe0,			/* src_mask */
+	 0xffffe0,			/* dst_mask */
+	 TRUE),				/* pcrel_offset */
+
+  /* Get to the page for the GOT entry for the symbol
+     (G(S) - P) using an ADRP instruction.  */
+  HOWTO (AARCH64_R (ADR_GOT_PAGE),	/* type */
+	 12,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 21,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (ADR_GOT_PAGE),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x1fffff,		/* src_mask */
+	 0x1fffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  /* LD64: GOT offset G(S) & 0xff8  */
+  HOWTO64 (AARCH64_R (LD64_GOT_LO12_NC),	/* type */
+	 3,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (LD64_GOT_LO12_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xff8,			/* src_mask */
+	 0xff8,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* LD32: GOT offset G(S) & 0xffc  */
+  HOWTO32 (AARCH64_R (LD32_GOT_LO12_NC),	/* type */
+	 2,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (LD32_GOT_LO12_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffc,			/* src_mask */
+	 0xffc,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* Get to the page for the GOT entry for the symbol
+     (G(S) - P) using an ADRP instruction.  */
+  HOWTO (AARCH64_R (TLSGD_ADR_PAGE21),	/* type */
+	 12,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 21,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSGD_ADR_PAGE21),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x1fffff,		/* src_mask */
+	 0x1fffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  /* ADD: GOT offset G(S) & 0xff8 [no overflow check] */
+  HOWTO (AARCH64_R (TLSGD_ADD_LO12_NC),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSGD_ADD_LO12_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xfff,			/* src_mask */
+	 0xfff,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO64 (AARCH64_R (TLSIE_MOVW_GOTTPREL_G1),	/* type */
+	 16,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSIE_MOVW_GOTTPREL_G1),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO64 (AARCH64_R (TLSIE_MOVW_GOTTPREL_G0_NC),	/* type */
+	 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 */
+	 AARCH64_R_STR (TLSIE_MOVW_GOTTPREL_G0_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (AARCH64_R (TLSIE_ADR_GOTTPREL_PAGE21),	/* type */
+	 12,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 21,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSIE_ADR_GOTTPREL_PAGE21),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x1fffff,		/* src_mask */
+	 0x1fffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO64 (AARCH64_R (TLSIE_LD64_GOTTPREL_LO12_NC),	/* type */
+	 3,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSIE_LD64_GOTTPREL_LO12_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xff8,			/* src_mask */
+	 0xff8,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO32 (AARCH64_R (TLSIE_LD32_GOTTPREL_LO12_NC),	/* type */
+	 2,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSIE_LD32_GOTTPREL_LO12_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffc,			/* src_mask */
+	 0xffc,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (AARCH64_R (TLSIE_LD_GOTTPREL_PREL19),	/* type */
+	 2,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 21,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSIE_LD_GOTTPREL_PREL19),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x1ffffc,		/* src_mask */
+	 0x1ffffc,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO64 (AARCH64_R (TLSLE_MOVW_TPREL_G2),	/* type */
+	 32,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSLE_MOVW_TPREL_G2),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (AARCH64_R (TLSLE_MOVW_TPREL_G1),	/* type */
+	 16,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSLE_MOVW_TPREL_G1),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO64 (AARCH64_R (TLSLE_MOVW_TPREL_G1_NC),	/* type */
+	 16,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSLE_MOVW_TPREL_G1_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (AARCH64_R (TLSLE_MOVW_TPREL_G0),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSLE_MOVW_TPREL_G0),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (AARCH64_R (TLSLE_MOVW_TPREL_G0_NC),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSLE_MOVW_TPREL_G0_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (AARCH64_R (TLSLE_ADD_TPREL_HI12),	/* type */
+	 12,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSLE_ADD_TPREL_HI12),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xfff,			/* src_mask */
+	 0xfff,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (AARCH64_R (TLSLE_ADD_TPREL_LO12),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSLE_ADD_TPREL_LO12),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xfff,			/* src_mask */
+	 0xfff,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (AARCH64_R (TLSLE_ADD_TPREL_LO12_NC),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSLE_ADD_TPREL_LO12_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xfff,			/* src_mask */
+	 0xfff,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (AARCH64_R (TLSDESC_LD_PREL19),	/* type */
+	 2,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 21,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSDESC_LD_PREL19),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x1ffffc,		/* src_mask */
+	 0x1ffffc,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  HOWTO (AARCH64_R (TLSDESC_ADR_PREL21),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 21,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSDESC_ADR_PREL21),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x1fffff,		/* src_mask */
+	 0x1fffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  /* Get to the page for the GOT entry for the symbol
+     (G(S) - P) using an ADRP instruction.  */
+  HOWTO (AARCH64_R (TLSDESC_ADR_PAGE21),	/* type */
+	 12,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 21,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSDESC_ADR_PAGE21),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x1fffff,		/* src_mask */
+	 0x1fffff,		/* dst_mask */
+	 TRUE),			/* pcrel_offset */
+
+  /* LD64: GOT offset G(S) & 0xff8.  */
+  HOWTO64 (AARCH64_R (TLSDESC_LD64_LO12_NC),	/* type */
+	 3,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSDESC_LD64_LO12_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xff8,			/* src_mask */
+	 0xff8,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* LD32: GOT offset G(S) & 0xffc.  */
+  HOWTO32 (AARCH64_R (TLSDESC_LD32_LO12_NC),	/* type */
+	 2,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSDESC_LD32_LO12_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffc,			/* src_mask */
+	 0xffc,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  /* ADD: GOT offset G(S) & 0xfff.  */
+  HOWTO (AARCH64_R (TLSDESC_ADD_LO12_NC),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSDESC_ADD_LO12_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xfff,			/* src_mask */
+	 0xfff,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO64 (AARCH64_R (TLSDESC_OFF_G1),	/* type */
+	 16,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSDESC_OFF_G1),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO64 (AARCH64_R (TLSDESC_OFF_G0_NC),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSDESC_OFF_G0_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO64 (AARCH64_R (TLSDESC_LDR),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSDESC_LDR),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x0,			/* src_mask */
+	 0x0,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO64 (AARCH64_R (TLSDESC_ADD),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSDESC_ADD),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x0,			/* src_mask */
+	 0x0,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (AARCH64_R (TLSDESC_CALL),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 12,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSDESC_CALL),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0x0,			/* src_mask */
+	 0x0,			/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (AARCH64_R (COPY),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 64,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (COPY),	/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (AARCH64_R (GLOB_DAT),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 64,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (GLOB_DAT),	/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (AARCH64_R (JUMP_SLOT),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 64,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (JUMP_SLOT),	/* name */
+	 TRUE,			/* partial_inplace */
+	 0xffffffff,		/* src_mask */
+	 0xffffffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (AARCH64_R (RELATIVE),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 64,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (RELATIVE),	/* name */
+	 TRUE,			/* partial_inplace */
+	 ALL_ONES,		/* src_mask */
+	 ALL_ONES,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (AARCH64_R (TLS_DTPMOD),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 64,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+#if ARCH_SIZE == 64
+	 AARCH64_R_STR (TLS_DTPMOD64),	/* name */
+#else
+	 AARCH64_R_STR (TLS_DTPMOD),	/* name */
+#endif
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 ALL_ONES,		/* dst_mask */
+	 FALSE),		/* pc_reloffset */
+
+  HOWTO (AARCH64_R (TLS_DTPREL),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 64,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+#if ARCH_SIZE == 64
+	 AARCH64_R_STR (TLS_DTPREL64),	/* name */
+#else
+	 AARCH64_R_STR (TLS_DTPREL),	/* name */
+#endif
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 ALL_ONES,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (AARCH64_R (TLS_TPREL),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 64,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+#if ARCH_SIZE == 64
+	 AARCH64_R_STR (TLS_TPREL64),	/* name */
+#else
+	 AARCH64_R_STR (TLS_TPREL),	/* name */
+#endif
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 ALL_ONES,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (AARCH64_R (TLSDESC),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 64,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (TLSDESC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 ALL_ONES,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  HOWTO (AARCH64_R (IRELATIVE),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 64,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_bitfield,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (IRELATIVE),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 ALL_ONES,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
+  EMPTY_HOWTO (0),
+};
+
+static reloc_howto_type elfNN_aarch64_howto_none =
+  HOWTO (R_AARCH64_NONE,	/* type */
+	 0,			/* rightshift */
+	 0,			/* size (0 = byte, 1 = short, 2 = long) */
+	 0,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 "R_AARCH64_NONE",	/* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 0,			/* dst_mask */
+	 FALSE);		/* pcrel_offset */
+
+/* Given HOWTO, return the bfd internal relocation enumerator.  */
+
+static bfd_reloc_code_real_type
+elfNN_aarch64_bfd_reloc_from_howto (reloc_howto_type *howto)
+{
+  const int size
+    = (int) ARRAY_SIZE (elfNN_aarch64_howto_table);
+  const ptrdiff_t offset
+    = howto - elfNN_aarch64_howto_table;
+
+  if (offset > 0 && offset < size - 1)
+    return BFD_RELOC_AARCH64_RELOC_START + offset;
+
+  if (howto == &elfNN_aarch64_howto_none)
+    return BFD_RELOC_AARCH64_NONE;
+
+  return BFD_RELOC_AARCH64_RELOC_START;
+}
+
+/* Given R_TYPE, return the bfd internal relocation enumerator.  */
+
+static bfd_reloc_code_real_type
+elfNN_aarch64_bfd_reloc_from_type (unsigned int r_type)
+{
+  static bfd_boolean initialized_p = FALSE;
+  /* Indexed by R_TYPE, values are offsets in the howto_table.  */
+  static unsigned int offsets[R_AARCH64_end];
+
+  if (initialized_p == FALSE)
+    {
+      unsigned int i;
+
+      for (i = 1; i < ARRAY_SIZE (elfNN_aarch64_howto_table) - 1; ++i)
+	if (elfNN_aarch64_howto_table[i].type != 0)
+	  offsets[elfNN_aarch64_howto_table[i].type] = i;
+
+      initialized_p = TRUE;
+    }
+
+  if (r_type == R_AARCH64_NONE || r_type == R_AARCH64_NULL)
+    return BFD_RELOC_AARCH64_NONE;
+
+  return BFD_RELOC_AARCH64_RELOC_START + offsets[r_type];
+}
+
+struct elf_aarch64_reloc_map
+{
+  bfd_reloc_code_real_type from;
+  bfd_reloc_code_real_type to;
+};
+
+/* Map bfd generic reloc to AArch64-specific reloc.  */
+static const struct elf_aarch64_reloc_map elf_aarch64_reloc_map[] =
+{
+  {BFD_RELOC_NONE, BFD_RELOC_AARCH64_NONE},
+
+  /* Basic data relocations.  */
+  {BFD_RELOC_CTOR, BFD_RELOC_AARCH64_NN},
+  {BFD_RELOC_64, BFD_RELOC_AARCH64_64},
+  {BFD_RELOC_32, BFD_RELOC_AARCH64_32},
+  {BFD_RELOC_16, BFD_RELOC_AARCH64_16},
+  {BFD_RELOC_64_PCREL, BFD_RELOC_AARCH64_64_PCREL},
+  {BFD_RELOC_32_PCREL, BFD_RELOC_AARCH64_32_PCREL},
+  {BFD_RELOC_16_PCREL, BFD_RELOC_AARCH64_16_PCREL},
+};
+
+/* Given the bfd internal relocation enumerator in CODE, return the
+   corresponding howto entry.  */
+
+static reloc_howto_type *
+elfNN_aarch64_howto_from_bfd_reloc (bfd_reloc_code_real_type code)
+{
+  unsigned int i;
+
+  /* Convert bfd generic reloc to AArch64-specific reloc.  */
+  if (code < BFD_RELOC_AARCH64_RELOC_START
+      || code > BFD_RELOC_AARCH64_RELOC_END)
+    for (i = 0; i < ARRAY_SIZE (elf_aarch64_reloc_map); i++)
+      if (elf_aarch64_reloc_map[i].from == code)
+	{
+	  code = elf_aarch64_reloc_map[i].to;
+	  break;
+	}
+
+  if (code > BFD_RELOC_AARCH64_RELOC_START
+      && code < BFD_RELOC_AARCH64_RELOC_END)
+    if (elfNN_aarch64_howto_table[code - BFD_RELOC_AARCH64_RELOC_START].type)
+      return &elfNN_aarch64_howto_table[code - BFD_RELOC_AARCH64_RELOC_START];
+
+  if (code == BFD_RELOC_AARCH64_NONE)
+    return &elfNN_aarch64_howto_none;
+
+  return NULL;
+}
+
+static reloc_howto_type *
+elfNN_aarch64_howto_from_type (unsigned int r_type)
+{
+  bfd_reloc_code_real_type val;
+  reloc_howto_type *howto;
+
+#if ARCH_SIZE == 32
+  if (r_type > 256)
+    {
+      bfd_set_error (bfd_error_bad_value);
+      return NULL;
+    }
+#endif
+
+  if (r_type == R_AARCH64_NONE)
+    return &elfNN_aarch64_howto_none;
+
+  val = elfNN_aarch64_bfd_reloc_from_type (r_type);
+  howto = elfNN_aarch64_howto_from_bfd_reloc (val);
+
+  if (howto != NULL)
+    return howto;
+
+  bfd_set_error (bfd_error_bad_value);
+  return NULL;
+}
+
+static void
+elfNN_aarch64_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, arelent *bfd_reloc,
+			     Elf_Internal_Rela *elf_reloc)
+{
+  unsigned int r_type;
+
+  r_type = ELFNN_R_TYPE (elf_reloc->r_info);
+  bfd_reloc->howto = elfNN_aarch64_howto_from_type (r_type);
+}
+
+static reloc_howto_type *
+elfNN_aarch64_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+				 bfd_reloc_code_real_type code)
+{
+  reloc_howto_type *howto = elfNN_aarch64_howto_from_bfd_reloc (code);
+
+  if (howto != NULL)
+    return howto;
+
+  bfd_set_error (bfd_error_bad_value);
+  return NULL;
+}
+
+static reloc_howto_type *
+elfNN_aarch64_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+				 const char *r_name)
+{
+  unsigned int i;
+
+  for (i = 1; i < ARRAY_SIZE (elfNN_aarch64_howto_table) - 1; ++i)
+    if (elfNN_aarch64_howto_table[i].name != NULL
+	&& strcasecmp (elfNN_aarch64_howto_table[i].name, r_name) == 0)
+      return &elfNN_aarch64_howto_table[i];
+
+  return NULL;
+}
+
+#define TARGET_LITTLE_SYM               bfd_elfNN_littleaarch64_vec
+#define TARGET_LITTLE_NAME              "elfNN-littleaarch64"
+#define TARGET_BIG_SYM                  bfd_elfNN_bigaarch64_vec
+#define TARGET_BIG_NAME                 "elfNN-bigaarch64"
+
+/* The linker script knows the section names for placement.
+   The entry_names are used to do simple name mangling on the stubs.
+   Given a function name, and its type, the stub can be found. The
+   name can be changed. The only requirement is the %s be present.  */
+#define STUB_ENTRY_NAME   "__%s_veneer"
+
+/* The name of the dynamic interpreter.  This is put in the .interp
+   section.  */
+#define ELF_DYNAMIC_INTERPRETER     "/lib/ld.so.1"
+
+#define AARCH64_MAX_FWD_BRANCH_OFFSET \
+  (((1 << 25) - 1) << 2)
+#define AARCH64_MAX_BWD_BRANCH_OFFSET \
+  (-((1 << 25) << 2))
+
+#define AARCH64_MAX_ADRP_IMM ((1 << 20) - 1)
+#define AARCH64_MIN_ADRP_IMM (-(1 << 20))
+
+static int
+aarch64_valid_for_adrp_p (bfd_vma value, bfd_vma place)
+{
+  bfd_signed_vma offset = (bfd_signed_vma) (PG (value) - PG (place)) >> 12;
+  return offset <= AARCH64_MAX_ADRP_IMM && offset >= AARCH64_MIN_ADRP_IMM;
+}
+
+static int
+aarch64_valid_branch_p (bfd_vma value, bfd_vma place)
+{
+  bfd_signed_vma offset = (bfd_signed_vma) (value - place);
+  return (offset <= AARCH64_MAX_FWD_BRANCH_OFFSET
+	  && offset >= AARCH64_MAX_BWD_BRANCH_OFFSET);
+}
+
+static const uint32_t aarch64_adrp_branch_stub [] =
+{
+  0x90000010,			/*	adrp	ip0, X */
+				/*		R_AARCH64_ADR_HI21_PCREL(X) */
+  0x91000210,			/*	add	ip0, ip0, :lo12:X */
+				/*		R_AARCH64_ADD_ABS_LO12_NC(X) */
+  0xd61f0200,			/*	br	ip0 */
+};
+
+static const uint32_t aarch64_long_branch_stub[] =
+{
+#if ARCH_SIZE == 64
+  0x58000090,			/*	ldr   ip0, 1f */
+#else
+  0x18000090,			/*	ldr   wip0, 1f */
+#endif
+  0x10000011,			/*	adr   ip1, #0 */
+  0x8b110210,			/*	add   ip0, ip0, ip1 */
+  0xd61f0200,			/*	br	ip0 */
+  0x00000000,			/* 1:	.xword or .word
+				   R_AARCH64_PRELNN(X) + 12
+				 */
+  0x00000000,
+};
+
+/* Section name for stubs is the associated section name plus this
+   string.  */
+#define STUB_SUFFIX ".stub"
+
+enum elf_aarch64_stub_type
+{
+  aarch64_stub_none,
+  aarch64_stub_adrp_branch,
+  aarch64_stub_long_branch,
+};
+
+struct elf_aarch64_stub_hash_entry
+{
+  /* Base hash table entry structure.  */
+  struct bfd_hash_entry root;
+
+  /* The stub section.  */
+  asection *stub_sec;
+
+  /* Offset within stub_sec of the beginning of this stub.  */
+  bfd_vma stub_offset;
+
+  /* Given the symbol's value and its section we can determine its final
+     value when building the stubs (so the stub knows where to jump).  */
+  bfd_vma target_value;
+  asection *target_section;
+
+  enum elf_aarch64_stub_type stub_type;
+
+  /* The symbol table entry, if any, that this was derived from.  */
+  struct elf_aarch64_link_hash_entry *h;
+
+  /* Destination symbol type */
+  unsigned char st_type;
+
+  /* Where this stub is being called from, or, in the case of combined
+     stub sections, the first input section in the group.  */
+  asection *id_sec;
+
+  /* The name for the local symbol at the start of this stub.  The
+     stub name in the hash table has to be unique; this does not, so
+     it can be friendlier.  */
+  char *output_name;
+};
+
+/* Used to build a map of a section.  This is required for mixed-endian
+   code/data.  */
+
+typedef struct elf_elf_section_map
+{
+  bfd_vma vma;
+  char type;
+}
+elf_aarch64_section_map;
+
+
+typedef struct _aarch64_elf_section_data
+{
+  struct bfd_elf_section_data elf;
+  unsigned int mapcount;
+  unsigned int mapsize;
+  elf_aarch64_section_map *map;
+}
+_aarch64_elf_section_data;
+
+#define elf_aarch64_section_data(sec) \
+  ((_aarch64_elf_section_data *) elf_section_data (sec))
+
+/* The size of the thread control block.  */
+#define TCB_SIZE	16
+
+struct elf_aarch64_local_symbol
+{
+  unsigned int got_type;
+  bfd_signed_vma got_refcount;
+  bfd_vma got_offset;
+
+  /* Offset of the GOTPLT entry reserved for the TLS descriptor. The
+     offset is from the end of the jump table and reserved entries
+     within the PLTGOT.
+
+     The magic value (bfd_vma) -1 indicates that an offset has not be
+     allocated.  */
+  bfd_vma tlsdesc_got_jump_table_offset;
+};
+
+struct elf_aarch64_obj_tdata
+{
+  struct elf_obj_tdata root;
+
+  /* local symbol descriptors */
+  struct elf_aarch64_local_symbol *locals;
+
+  /* Zero to warn when linking objects with incompatible enum sizes.  */
+  int no_enum_size_warning;
+
+  /* Zero to warn when linking objects with incompatible wchar_t sizes.  */
+  int no_wchar_size_warning;
+};
+
+#define elf_aarch64_tdata(bfd)				\
+  ((struct elf_aarch64_obj_tdata *) (bfd)->tdata.any)
+
+#define elf_aarch64_locals(bfd) (elf_aarch64_tdata (bfd)->locals)
+
+#define is_aarch64_elf(bfd)				\
+  (bfd_get_flavour (bfd) == bfd_target_elf_flavour	\
+   && elf_tdata (bfd) != NULL				\
+   && elf_object_id (bfd) == AARCH64_ELF_DATA)
+
+static bfd_boolean
+elfNN_aarch64_mkobject (bfd *abfd)
+{
+  return bfd_elf_allocate_object (abfd, sizeof (struct elf_aarch64_obj_tdata),
+				  AARCH64_ELF_DATA);
+}
+
+#define elf_aarch64_hash_entry(ent) \
+  ((struct elf_aarch64_link_hash_entry *)(ent))
+
+#define GOT_UNKNOWN    0
+#define GOT_NORMAL     1
+#define GOT_TLS_GD     2
+#define GOT_TLS_IE     4
+#define GOT_TLSDESC_GD 8
+
+#define GOT_TLS_GD_ANY_P(type)	((type & GOT_TLS_GD) || (type & GOT_TLSDESC_GD))
+
+/* AArch64 ELF linker hash entry.  */
+struct elf_aarch64_link_hash_entry
+{
+  struct elf_link_hash_entry root;
+
+  /* Track dynamic relocs copied for this symbol.  */
+  struct elf_dyn_relocs *dyn_relocs;
+
+  /* Since PLT entries have variable size, we need to record the
+     index into .got.plt instead of recomputing it from the PLT
+     offset.  */
+  bfd_signed_vma plt_got_offset;
+
+  /* Bit mask representing the type of GOT entry(s) if any required by
+     this symbol.  */
+  unsigned int got_type;
+
+  /* A pointer to the most recently used stub hash entry against this
+     symbol.  */
+  struct elf_aarch64_stub_hash_entry *stub_cache;
+
+  /* Offset of the GOTPLT entry reserved for the TLS descriptor.  The offset
+     is from the end of the jump table and reserved entries within the PLTGOT.
+
+     The magic value (bfd_vma) -1 indicates that an offset has not
+     be allocated.  */
+  bfd_vma tlsdesc_got_jump_table_offset;
+};
+
+static unsigned int
+elfNN_aarch64_symbol_got_type (struct elf_link_hash_entry *h,
+			       bfd *abfd,
+			       unsigned long r_symndx)
+{
+  if (h)
+    return elf_aarch64_hash_entry (h)->got_type;
+
+  if (! elf_aarch64_locals (abfd))
+    return GOT_UNKNOWN;
+
+  return elf_aarch64_locals (abfd)[r_symndx].got_type;
+}
+
+/* Get the AArch64 elf linker hash table from a link_info structure.  */
+#define elf_aarch64_hash_table(info)					\
+  ((struct elf_aarch64_link_hash_table *) ((info)->hash))
+
+#define aarch64_stub_hash_lookup(table, string, create, copy)		\
+  ((struct elf_aarch64_stub_hash_entry *)				\
+   bfd_hash_lookup ((table), (string), (create), (copy)))
+
+/* AArch64 ELF linker hash table.  */
+struct elf_aarch64_link_hash_table
+{
+  /* The main hash table.  */
+  struct elf_link_hash_table root;
+
+  /* Nonzero to force PIC branch veneers.  */
+  int pic_veneer;
+
+  /* The number of bytes in the initial entry in the PLT.  */
+  bfd_size_type plt_header_size;
+
+  /* The number of bytes in the subsequent PLT etries.  */
+  bfd_size_type plt_entry_size;
+
+  /* Short-cuts to get to dynamic linker sections.  */
+  asection *sdynbss;
+  asection *srelbss;
+
+  /* Small local sym cache.  */
+  struct sym_cache sym_cache;
+
+  /* For convenience in allocate_dynrelocs.  */
+  bfd *obfd;
+
+  /* The amount of space used by the reserved portion of the sgotplt
+     section, plus whatever space is used by the jump slots.  */
+  bfd_vma sgotplt_jump_table_size;
+
+  /* The stub hash table.  */
+  struct bfd_hash_table stub_hash_table;
+
+  /* Linker stub bfd.  */
+  bfd *stub_bfd;
+
+  /* Linker call-backs.  */
+  asection *(*add_stub_section) (const char *, asection *);
+  void (*layout_sections_again) (void);
+
+  /* Array to keep track of which stub sections have been created, and
+     information on stub grouping.  */
+  struct map_stub
+  {
+    /* This is the section to which stubs in the group will be
+       attached.  */
+    asection *link_sec;
+    /* The stub section.  */
+    asection *stub_sec;
+  } *stub_group;
+
+  /* Assorted information used by elfNN_aarch64_size_stubs.  */
+  unsigned int bfd_count;
+  int top_index;
+  asection **input_list;
+
+  /* The offset into splt of the PLT entry for the TLS descriptor
+     resolver.  Special values are 0, if not necessary (or not found
+     to be necessary yet), and -1 if needed but not determined
+     yet.  */
+  bfd_vma tlsdesc_plt;
+
+  /* The GOT offset for the lazy trampoline.  Communicated to the
+     loader via DT_TLSDESC_GOT.  The magic value (bfd_vma) -1
+     indicates an offset is not allocated.  */
+  bfd_vma dt_tlsdesc_got;
+
+  /* Used by local STT_GNU_IFUNC symbols.  */
+  htab_t loc_hash_table;
+  void * loc_hash_memory;
+};
+
+/* Create an entry in an AArch64 ELF linker hash table.  */
+
+static struct bfd_hash_entry *
+elfNN_aarch64_link_hash_newfunc (struct bfd_hash_entry *entry,
+				 struct bfd_hash_table *table,
+				 const char *string)
+{
+  struct elf_aarch64_link_hash_entry *ret =
+    (struct elf_aarch64_link_hash_entry *) entry;
+
+  /* Allocate the structure if it has not already been allocated by a
+     subclass.  */
+  if (ret == NULL)
+    ret = bfd_hash_allocate (table,
+			     sizeof (struct elf_aarch64_link_hash_entry));
+  if (ret == NULL)
+    return (struct bfd_hash_entry *) ret;
+
+  /* Call the allocation method of the superclass.  */
+  ret = ((struct elf_aarch64_link_hash_entry *)
+	 _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
+				     table, string));
+  if (ret != NULL)
+    {
+      ret->dyn_relocs = NULL;
+      ret->got_type = GOT_UNKNOWN;
+      ret->plt_got_offset = (bfd_vma) - 1;
+      ret->stub_cache = NULL;
+      ret->tlsdesc_got_jump_table_offset = (bfd_vma) - 1;
+    }
+
+  return (struct bfd_hash_entry *) ret;
+}
+
+/* Initialize an entry in the stub hash table.  */
+
+static struct bfd_hash_entry *
+stub_hash_newfunc (struct bfd_hash_entry *entry,
+		   struct bfd_hash_table *table, const char *string)
+{
+  /* Allocate the structure if it has not already been allocated by a
+     subclass.  */
+  if (entry == NULL)
+    {
+      entry = bfd_hash_allocate (table,
+				 sizeof (struct
+					 elf_aarch64_stub_hash_entry));
+      if (entry == NULL)
+	return entry;
+    }
+
+  /* Call the allocation method of the superclass.  */
+  entry = bfd_hash_newfunc (entry, table, string);
+  if (entry != NULL)
+    {
+      struct elf_aarch64_stub_hash_entry *eh;
+
+      /* Initialize the local fields.  */
+      eh = (struct elf_aarch64_stub_hash_entry *) entry;
+      eh->stub_sec = NULL;
+      eh->stub_offset = 0;
+      eh->target_value = 0;
+      eh->target_section = NULL;
+      eh->stub_type = aarch64_stub_none;
+      eh->h = NULL;
+      eh->id_sec = NULL;
+    }
+
+  return entry;
+}
+
+/* Compute a hash of a local hash entry.  We use elf_link_hash_entry
+  for local symbol so that we can handle local STT_GNU_IFUNC symbols
+  as global symbol.  We reuse indx and dynstr_index for local symbol
+  hash since they aren't used by global symbols in this backend.  */
+
+static hashval_t
+elfNN_aarch64_local_htab_hash (const void *ptr)
+{
+  struct elf_link_hash_entry *h
+    = (struct elf_link_hash_entry *) ptr;
+  return ELF_LOCAL_SYMBOL_HASH (h->indx, h->dynstr_index);
+}
+
+/* Compare local hash entries.  */
+
+static int
+elfNN_aarch64_local_htab_eq (const void *ptr1, const void *ptr2)
+{
+  struct elf_link_hash_entry *h1
+     = (struct elf_link_hash_entry *) ptr1;
+  struct elf_link_hash_entry *h2
+    = (struct elf_link_hash_entry *) ptr2;
+
+  return h1->indx == h2->indx && h1->dynstr_index == h2->dynstr_index;
+}
+
+/* Find and/or create a hash entry for local symbol.  */
+
+static struct elf_link_hash_entry *
+elfNN_aarch64_get_local_sym_hash (struct elf_aarch64_link_hash_table *htab,
+				  bfd *abfd, const Elf_Internal_Rela *rel,
+				  bfd_boolean create)
+{
+  struct elf_aarch64_link_hash_entry e, *ret;
+  asection *sec = abfd->sections;
+  hashval_t h = ELF_LOCAL_SYMBOL_HASH (sec->id,
+				       ELFNN_R_SYM (rel->r_info));
+  void **slot;
+
+  e.root.indx = sec->id;
+  e.root.dynstr_index = ELFNN_R_SYM (rel->r_info);
+  slot = htab_find_slot_with_hash (htab->loc_hash_table, &e, h,
+				   create ? INSERT : NO_INSERT);
+
+  if (!slot)
+    return NULL;
+
+  if (*slot)
+    {
+      ret = (struct elf_aarch64_link_hash_entry *) *slot;
+      return &ret->root;
+    }
+
+  ret = (struct elf_aarch64_link_hash_entry *)
+	objalloc_alloc ((struct objalloc *) htab->loc_hash_memory,
+			sizeof (struct elf_aarch64_link_hash_entry));
+  if (ret)
+    {
+      memset (ret, 0, sizeof (*ret));
+      ret->root.indx = sec->id;
+      ret->root.dynstr_index = ELFNN_R_SYM (rel->r_info);
+      ret->root.dynindx = -1;
+      *slot = ret;
+    }
+  return &ret->root;
+}
+
+/* Copy the extra info we tack onto an elf_link_hash_entry.  */
+
+static void
+elfNN_aarch64_copy_indirect_symbol (struct bfd_link_info *info,
+				    struct elf_link_hash_entry *dir,
+				    struct elf_link_hash_entry *ind)
+{
+  struct elf_aarch64_link_hash_entry *edir, *eind;
+
+  edir = (struct elf_aarch64_link_hash_entry *) dir;
+  eind = (struct elf_aarch64_link_hash_entry *) ind;
+
+  if (eind->dyn_relocs != NULL)
+    {
+      if (edir->dyn_relocs != NULL)
+	{
+	  struct elf_dyn_relocs **pp;
+	  struct elf_dyn_relocs *p;
+
+	  /* Add reloc counts against the indirect sym to the direct sym
+	     list.  Merge any entries against the same section.  */
+	  for (pp = &eind->dyn_relocs; (p = *pp) != NULL;)
+	    {
+	      struct elf_dyn_relocs *q;
+
+	      for (q = edir->dyn_relocs; q != NULL; q = q->next)
+		if (q->sec == p->sec)
+		  {
+		    q->pc_count += p->pc_count;
+		    q->count += p->count;
+		    *pp = p->next;
+		    break;
+		  }
+	      if (q == NULL)
+		pp = &p->next;
+	    }
+	  *pp = edir->dyn_relocs;
+	}
+
+      edir->dyn_relocs = eind->dyn_relocs;
+      eind->dyn_relocs = NULL;
+    }
+
+  if (ind->root.type == bfd_link_hash_indirect)
+    {
+      /* Copy over PLT info.  */
+      if (dir->got.refcount <= 0)
+	{
+	  edir->got_type = eind->got_type;
+	  eind->got_type = GOT_UNKNOWN;
+	}
+    }
+
+  _bfd_elf_link_hash_copy_indirect (info, dir, ind);
+}
+
+/* Create an AArch64 elf linker hash table.  */
+
+static struct bfd_link_hash_table *
+elfNN_aarch64_link_hash_table_create (bfd *abfd)
+{
+  struct elf_aarch64_link_hash_table *ret;
+  bfd_size_type amt = sizeof (struct elf_aarch64_link_hash_table);
+
+  ret = bfd_zmalloc (amt);
+  if (ret == NULL)
+    return NULL;
+
+  if (!_bfd_elf_link_hash_table_init
+      (&ret->root, abfd, elfNN_aarch64_link_hash_newfunc,
+       sizeof (struct elf_aarch64_link_hash_entry), AARCH64_ELF_DATA))
+    {
+      free (ret);
+      return NULL;
+    }
+
+  ret->plt_header_size = PLT_ENTRY_SIZE;
+  ret->plt_entry_size = PLT_SMALL_ENTRY_SIZE;
+  ret->obfd = abfd;
+  ret->dt_tlsdesc_got = (bfd_vma) - 1;
+
+  if (!bfd_hash_table_init (&ret->stub_hash_table, stub_hash_newfunc,
+			    sizeof (struct elf_aarch64_stub_hash_entry)))
+    {
+      free (ret);
+      return NULL;
+    }
+
+  ret->loc_hash_table = htab_try_create (1024,
+					 elfNN_aarch64_local_htab_hash,
+					 elfNN_aarch64_local_htab_eq,
+					 NULL);
+  ret->loc_hash_memory = objalloc_create ();
+  if (!ret->loc_hash_table || !ret->loc_hash_memory)
+    {
+      free (ret);
+      return NULL;
+    }
+
+  return &ret->root.root;
+}
+
+/* Free the derived linker hash table.  */
+
+static void
+elfNN_aarch64_hash_table_free (struct bfd_link_hash_table *hash)
+{
+  struct elf_aarch64_link_hash_table *ret
+    = (struct elf_aarch64_link_hash_table *) hash;
+
+  if (ret->loc_hash_table)
+    htab_delete (ret->loc_hash_table);
+  if (ret->loc_hash_memory)
+    objalloc_free ((struct objalloc *) ret->loc_hash_memory);
+
+  bfd_hash_table_free (&ret->stub_hash_table);
+  _bfd_elf_link_hash_table_free (hash);
+}
+
+static bfd_boolean
+aarch64_relocate (unsigned int r_type, bfd *input_bfd, asection *input_section,
+		  bfd_vma offset, bfd_vma value)
+{
+  reloc_howto_type *howto;
+  bfd_vma place;
+
+  howto = elfNN_aarch64_howto_from_type (r_type);
+  place = (input_section->output_section->vma + input_section->output_offset
+	   + offset);
+
+  r_type = elfNN_aarch64_bfd_reloc_from_type (r_type);
+  value = _bfd_aarch64_elf_resolve_relocation (r_type, place, value, 0, FALSE);
+  return _bfd_aarch64_elf_put_addend (input_bfd,
+				      input_section->contents + offset, r_type,
+				      howto, value);
+}
+
+static enum elf_aarch64_stub_type
+aarch64_select_branch_stub (bfd_vma value, bfd_vma place)
+{
+  if (aarch64_valid_for_adrp_p (value, place))
+    return aarch64_stub_adrp_branch;
+  return aarch64_stub_long_branch;
+}
+
+/* Determine the type of stub needed, if any, for a call.  */
+
+static enum elf_aarch64_stub_type
+aarch64_type_of_stub (struct bfd_link_info *info,
+		      asection *input_sec,
+		      const Elf_Internal_Rela *rel,
+		      unsigned char st_type,
+		      struct elf_aarch64_link_hash_entry *hash,
+		      bfd_vma destination)
+{
+  bfd_vma location;
+  bfd_signed_vma branch_offset;
+  unsigned int r_type;
+  struct elf_aarch64_link_hash_table *globals;
+  enum elf_aarch64_stub_type stub_type = aarch64_stub_none;
+  bfd_boolean via_plt_p;
+
+  if (st_type != STT_FUNC)
+    return stub_type;
+
+  globals = elf_aarch64_hash_table (info);
+  via_plt_p = (globals->root.splt != NULL && hash != NULL
+	       && hash->root.plt.offset != (bfd_vma) - 1);
+
+  if (via_plt_p)
+    return stub_type;
+
+  /* Determine where the call point is.  */
+  location = (input_sec->output_offset
+	      + input_sec->output_section->vma + rel->r_offset);
+
+  branch_offset = (bfd_signed_vma) (destination - location);
+
+  r_type = ELFNN_R_TYPE (rel->r_info);
+
+  /* We don't want to redirect any old unconditional jump in this way,
+     only one which is being used for a sibcall, where it is
+     acceptable for the IP0 and IP1 registers to be clobbered.  */
+  if ((r_type == AARCH64_R (CALL26) || r_type == AARCH64_R (JUMP26))
+      && (branch_offset > AARCH64_MAX_FWD_BRANCH_OFFSET
+	  || branch_offset < AARCH64_MAX_BWD_BRANCH_OFFSET))
+    {
+      stub_type = aarch64_stub_long_branch;
+    }
+
+  return stub_type;
+}
+
+/* Build a name for an entry in the stub hash table.  */
+
+static char *
+elfNN_aarch64_stub_name (const asection *input_section,
+			 const asection *sym_sec,
+			 const struct elf_aarch64_link_hash_entry *hash,
+			 const Elf_Internal_Rela *rel)
+{
+  char *stub_name;
+  bfd_size_type len;
+
+  if (hash)
+    {
+      len = 8 + 1 + strlen (hash->root.root.root.string) + 1 + 16 + 1;
+      stub_name = bfd_malloc (len);
+      if (stub_name != NULL)
+	snprintf (stub_name, len, "%08x_%s+%" BFD_VMA_FMT "x",
+		  (unsigned int) input_section->id,
+		  hash->root.root.root.string,
+		  rel->r_addend);
+    }
+  else
+    {
+      len = 8 + 1 + 8 + 1 + 8 + 1 + 16 + 1;
+      stub_name = bfd_malloc (len);
+      if (stub_name != NULL)
+	snprintf (stub_name, len, "%08x_%x:%x+%" BFD_VMA_FMT "x",
+		  (unsigned int) input_section->id,
+		  (unsigned int) sym_sec->id,
+		  (unsigned int) ELFNN_R_SYM (rel->r_info),
+		  rel->r_addend);
+    }
+
+  return stub_name;
+}
+
+/* Look up an entry in the stub hash.  Stub entries are cached because
+   creating the stub name takes a bit of time.  */
+
+static struct elf_aarch64_stub_hash_entry *
+elfNN_aarch64_get_stub_entry (const asection *input_section,
+			      const asection *sym_sec,
+			      struct elf_link_hash_entry *hash,
+			      const Elf_Internal_Rela *rel,
+			      struct elf_aarch64_link_hash_table *htab)
+{
+  struct elf_aarch64_stub_hash_entry *stub_entry;
+  struct elf_aarch64_link_hash_entry *h =
+    (struct elf_aarch64_link_hash_entry *) hash;
+  const asection *id_sec;
+
+  if ((input_section->flags & SEC_CODE) == 0)
+    return NULL;
+
+  /* If this input section is part of a group of sections sharing one
+     stub section, then use the id of the first section in the group.
+     Stub names need to include a section id, as there may well be
+     more than one stub used to reach say, printf, and we need to
+     distinguish between them.  */
+  id_sec = htab->stub_group[input_section->id].link_sec;
+
+  if (h != NULL && h->stub_cache != NULL
+      && h->stub_cache->h == h && h->stub_cache->id_sec == id_sec)
+    {
+      stub_entry = h->stub_cache;
+    }
+  else
+    {
+      char *stub_name;
+
+      stub_name = elfNN_aarch64_stub_name (id_sec, sym_sec, h, rel);
+      if (stub_name == NULL)
+	return NULL;
+
+      stub_entry = aarch64_stub_hash_lookup (&htab->stub_hash_table,
+					     stub_name, FALSE, FALSE);
+      if (h != NULL)
+	h->stub_cache = stub_entry;
+
+      free (stub_name);
+    }
+
+  return stub_entry;
+}
+
+/* Add a new stub entry to the stub hash.  Not all fields of the new
+   stub entry are initialised.  */
+
+static struct elf_aarch64_stub_hash_entry *
+elfNN_aarch64_add_stub (const char *stub_name,
+			asection *section,
+			struct elf_aarch64_link_hash_table *htab)
+{
+  asection *link_sec;
+  asection *stub_sec;
+  struct elf_aarch64_stub_hash_entry *stub_entry;
+
+  link_sec = htab->stub_group[section->id].link_sec;
+  stub_sec = htab->stub_group[section->id].stub_sec;
+  if (stub_sec == NULL)
+    {
+      stub_sec = htab->stub_group[link_sec->id].stub_sec;
+      if (stub_sec == NULL)
+	{
+	  size_t namelen;
+	  bfd_size_type len;
+	  char *s_name;
+
+	  namelen = strlen (link_sec->name);
+	  len = namelen + sizeof (STUB_SUFFIX);
+	  s_name = bfd_alloc (htab->stub_bfd, len);
+	  if (s_name == NULL)
+	    return NULL;
+
+	  memcpy (s_name, link_sec->name, namelen);
+	  memcpy (s_name + namelen, STUB_SUFFIX, sizeof (STUB_SUFFIX));
+	  stub_sec = (*htab->add_stub_section) (s_name, link_sec);
+	  if (stub_sec == NULL)
+	    return NULL;
+	  htab->stub_group[link_sec->id].stub_sec = stub_sec;
+	}
+      htab->stub_group[section->id].stub_sec = stub_sec;
+    }
+
+  /* Enter this entry into the linker stub hash table.  */
+  stub_entry = aarch64_stub_hash_lookup (&htab->stub_hash_table, stub_name,
+					 TRUE, FALSE);
+  if (stub_entry == NULL)
+    {
+      (*_bfd_error_handler) (_("%s: cannot create stub entry %s"),
+			     section->owner, stub_name);
+      return NULL;
+    }
+
+  stub_entry->stub_sec = stub_sec;
+  stub_entry->stub_offset = 0;
+  stub_entry->id_sec = link_sec;
+
+  return stub_entry;
+}
+
+static bfd_boolean
+aarch64_build_one_stub (struct bfd_hash_entry *gen_entry,
+			void *in_arg ATTRIBUTE_UNUSED)
+{
+  struct elf_aarch64_stub_hash_entry *stub_entry;
+  asection *stub_sec;
+  bfd *stub_bfd;
+  bfd_byte *loc;
+  bfd_vma sym_value;
+  unsigned int template_size;
+  const uint32_t *template;
+  unsigned int i;
+
+  /* Massage our args to the form they really have.  */
+  stub_entry = (struct elf_aarch64_stub_hash_entry *) gen_entry;
+
+  stub_sec = stub_entry->stub_sec;
+
+  /* Make a note of the offset within the stubs for this entry.  */
+  stub_entry->stub_offset = stub_sec->size;
+  loc = stub_sec->contents + stub_entry->stub_offset;
+
+  stub_bfd = stub_sec->owner;
+
+  /* This is the address of the stub destination.  */
+  sym_value = (stub_entry->target_value
+	       + stub_entry->target_section->output_offset
+	       + stub_entry->target_section->output_section->vma);
+
+  if (stub_entry->stub_type == aarch64_stub_long_branch)
+    {
+      bfd_vma place = (stub_entry->stub_offset + stub_sec->output_section->vma
+		       + stub_sec->output_offset);
+
+      /* See if we can relax the stub.  */
+      if (aarch64_valid_for_adrp_p (sym_value, place))
+	stub_entry->stub_type = aarch64_select_branch_stub (sym_value, place);
+    }
+
+  switch (stub_entry->stub_type)
+    {
+    case aarch64_stub_adrp_branch:
+      template = aarch64_adrp_branch_stub;
+      template_size = sizeof (aarch64_adrp_branch_stub);
+      break;
+    case aarch64_stub_long_branch:
+      template = aarch64_long_branch_stub;
+      template_size = sizeof (aarch64_long_branch_stub);
+      break;
+    default:
+      BFD_FAIL ();
+      return FALSE;
+    }
+
+  for (i = 0; i < (template_size / sizeof template[0]); i++)
+    {
+      bfd_putl32 (template[i], loc);
+      loc += 4;
+    }
+
+  template_size = (template_size + 7) & ~7;
+  stub_sec->size += template_size;
+
+  switch (stub_entry->stub_type)
+    {
+    case aarch64_stub_adrp_branch:
+      if (aarch64_relocate (AARCH64_R (ADR_PREL_PG_HI21), stub_bfd, stub_sec,
+			    stub_entry->stub_offset, sym_value))
+	/* The stub would not have been relaxed if the offset was out
+	   of range.  */
+	BFD_FAIL ();
+
+      _bfd_final_link_relocate
+	(elfNN_aarch64_howto_from_type (AARCH64_R (ADD_ABS_LO12_NC)),
+	 stub_bfd,
+	 stub_sec,
+	 stub_sec->contents,
+	 stub_entry->stub_offset + 4,
+	 sym_value,
+	 0);
+      break;
+
+    case aarch64_stub_long_branch:
+      /* We want the value relative to the address 12 bytes back from the
+         value itself.  */
+      _bfd_final_link_relocate (elfNN_aarch64_howto_from_type
+				(AARCH64_R (PRELNN)), stub_bfd, stub_sec,
+				stub_sec->contents,
+				stub_entry->stub_offset + 16,
+				sym_value + 12, 0);
+      break;
+    default:
+      break;
+    }
+
+  return TRUE;
+}
+
+/* As above, but don't actually build the stub.  Just bump offset so
+   we know stub section sizes.  */
+
+static bfd_boolean
+aarch64_size_one_stub (struct bfd_hash_entry *gen_entry,
+		       void *in_arg ATTRIBUTE_UNUSED)
+{
+  struct elf_aarch64_stub_hash_entry *stub_entry;
+  int size;
+
+  /* Massage our args to the form they really have.  */
+  stub_entry = (struct elf_aarch64_stub_hash_entry *) gen_entry;
+
+  switch (stub_entry->stub_type)
+    {
+    case aarch64_stub_adrp_branch:
+      size = sizeof (aarch64_adrp_branch_stub);
+      break;
+    case aarch64_stub_long_branch:
+      size = sizeof (aarch64_long_branch_stub);
+      break;
+    default:
+      BFD_FAIL ();
+      return FALSE;
+      break;
+    }
+
+  size = (size + 7) & ~7;
+  stub_entry->stub_sec->size += size;
+  return TRUE;
+}
+
+/* External entry points for sizing and building linker stubs.  */
+
+/* Set up various things so that we can make a list of input sections
+   for each output section included in the link.  Returns -1 on error,
+   0 when no stubs will be needed, and 1 on success.  */
+
+int
+elfNN_aarch64_setup_section_lists (bfd *output_bfd,
+				   struct bfd_link_info *info)
+{
+  bfd *input_bfd;
+  unsigned int bfd_count;
+  int top_id, top_index;
+  asection *section;
+  asection **input_list, **list;
+  bfd_size_type amt;
+  struct elf_aarch64_link_hash_table *htab =
+    elf_aarch64_hash_table (info);
+
+  if (!is_elf_hash_table (htab))
+    return 0;
+
+  /* Count the number of input BFDs and find the top input section id.  */
+  for (input_bfd = info->input_bfds, bfd_count = 0, top_id = 0;
+       input_bfd != NULL; input_bfd = input_bfd->link_next)
+    {
+      bfd_count += 1;
+      for (section = input_bfd->sections;
+	   section != NULL; section = section->next)
+	{
+	  if (top_id < section->id)
+	    top_id = section->id;
+	}
+    }
+  htab->bfd_count = bfd_count;
+
+  amt = sizeof (struct map_stub) * (top_id + 1);
+  htab->stub_group = bfd_zmalloc (amt);
+  if (htab->stub_group == NULL)
+    return -1;
+
+  /* We can't use output_bfd->section_count here to find the top output
+     section index as some sections may have been removed, and
+     _bfd_strip_section_from_output doesn't renumber the indices.  */
+  for (section = output_bfd->sections, top_index = 0;
+       section != NULL; section = section->next)
+    {
+      if (top_index < section->index)
+	top_index = section->index;
+    }
+
+  htab->top_index = top_index;
+  amt = sizeof (asection *) * (top_index + 1);
+  input_list = bfd_malloc (amt);
+  htab->input_list = input_list;
+  if (input_list == NULL)
+    return -1;
+
+  /* For sections we aren't interested in, mark their entries with a
+     value we can check later.  */
+  list = input_list + top_index;
+  do
+    *list = bfd_abs_section_ptr;
+  while (list-- != input_list);
+
+  for (section = output_bfd->sections;
+       section != NULL; section = section->next)
+    {
+      if ((section->flags & SEC_CODE) != 0)
+	input_list[section->index] = NULL;
+    }
+
+  return 1;
+}
+
+/* Used by elfNN_aarch64_next_input_section and group_sections.  */
+#define PREV_SEC(sec) (htab->stub_group[(sec)->id].link_sec)
+
+/* The linker repeatedly calls this function for each input section,
+   in the order that input sections are linked into output sections.
+   Build lists of input sections to determine groupings between which
+   we may insert linker stubs.  */
+
+void
+elfNN_aarch64_next_input_section (struct bfd_link_info *info, asection *isec)
+{
+  struct elf_aarch64_link_hash_table *htab =
+    elf_aarch64_hash_table (info);
+
+  if (isec->output_section->index <= htab->top_index)
+    {
+      asection **list = htab->input_list + isec->output_section->index;
+
+      if (*list != bfd_abs_section_ptr)
+	{
+	  /* Steal the link_sec pointer for our list.  */
+	  /* This happens to make the list in reverse order,
+	     which is what we want.  */
+	  PREV_SEC (isec) = *list;
+	  *list = isec;
+	}
+    }
+}
+
+/* See whether we can group stub sections together.  Grouping stub
+   sections may result in fewer stubs.  More importantly, we need to
+   put all .init* and .fini* stubs at the beginning of the .init or
+   .fini output sections respectively, because glibc splits the
+   _init and _fini functions into multiple parts.  Putting a stub in
+   the middle of a function is not a good idea.  */
+
+static void
+group_sections (struct elf_aarch64_link_hash_table *htab,
+		bfd_size_type stub_group_size,
+		bfd_boolean stubs_always_before_branch)
+{
+  asection **list = htab->input_list + htab->top_index;
+
+  do
+    {
+      asection *tail = *list;
+
+      if (tail == bfd_abs_section_ptr)
+	continue;
+
+      while (tail != NULL)
+	{
+	  asection *curr;
+	  asection *prev;
+	  bfd_size_type total;
+
+	  curr = tail;
+	  total = tail->size;
+	  while ((prev = PREV_SEC (curr)) != NULL
+		 && ((total += curr->output_offset - prev->output_offset)
+		     < stub_group_size))
+	    curr = prev;
+
+	  /* OK, the size from the start of CURR to the end is less
+	     than stub_group_size and thus can be handled by one stub
+	     section.  (Or the tail section is itself larger than
+	     stub_group_size, in which case we may be toast.)
+	     We should really be keeping track of the total size of
+	     stubs added here, as stubs contribute to the final output
+	     section size.  */
+	  do
+	    {
+	      prev = PREV_SEC (tail);
+	      /* Set up this stub group.  */
+	      htab->stub_group[tail->id].link_sec = curr;
+	    }
+	  while (tail != curr && (tail = prev) != NULL);
+
+	  /* But wait, there's more!  Input sections up to stub_group_size
+	     bytes before the stub section can be handled by it too.  */
+	  if (!stubs_always_before_branch)
+	    {
+	      total = 0;
+	      while (prev != NULL
+		     && ((total += tail->output_offset - prev->output_offset)
+			 < stub_group_size))
+		{
+		  tail = prev;
+		  prev = PREV_SEC (tail);
+		  htab->stub_group[tail->id].link_sec = curr;
+		}
+	    }
+	  tail = prev;
+	}
+    }
+  while (list-- != htab->input_list);
+
+  free (htab->input_list);
+}
+
+#undef PREV_SEC
+
+/* Determine and set the size of the stub section for a final link.
+
+   The basic idea here is to examine all the relocations looking for
+   PC-relative calls to a target that is unreachable with a "bl"
+   instruction.  */
+
+bfd_boolean
+elfNN_aarch64_size_stubs (bfd *output_bfd,
+			  bfd *stub_bfd,
+			  struct bfd_link_info *info,
+			  bfd_signed_vma group_size,
+			  asection * (*add_stub_section) (const char *,
+							  asection *),
+			  void (*layout_sections_again) (void))
+{
+  bfd_size_type stub_group_size;
+  bfd_boolean stubs_always_before_branch;
+  bfd_boolean stub_changed = 0;
+  struct elf_aarch64_link_hash_table *htab = elf_aarch64_hash_table (info);
+
+  /* Propagate mach to stub bfd, because it may not have been
+     finalized when we created stub_bfd.  */
+  bfd_set_arch_mach (stub_bfd, bfd_get_arch (output_bfd),
+		     bfd_get_mach (output_bfd));
+
+  /* Stash our params away.  */
+  htab->stub_bfd = stub_bfd;
+  htab->add_stub_section = add_stub_section;
+  htab->layout_sections_again = layout_sections_again;
+  stubs_always_before_branch = group_size < 0;
+  if (group_size < 0)
+    stub_group_size = -group_size;
+  else
+    stub_group_size = group_size;
+
+  if (stub_group_size == 1)
+    {
+      /* Default values.  */
+      /* AArch64 branch range is +-128MB. The value used is 1MB less.  */
+      stub_group_size = 127 * 1024 * 1024;
+    }
+
+  group_sections (htab, stub_group_size, stubs_always_before_branch);
+
+  while (1)
+    {
+      bfd *input_bfd;
+      unsigned int bfd_indx;
+      asection *stub_sec;
+
+      for (input_bfd = info->input_bfds, bfd_indx = 0;
+	   input_bfd != NULL; input_bfd = input_bfd->link_next, bfd_indx++)
+	{
+	  Elf_Internal_Shdr *symtab_hdr;
+	  asection *section;
+	  Elf_Internal_Sym *local_syms = NULL;
+
+	  /* We'll need the symbol table in a second.  */
+	  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+	  if (symtab_hdr->sh_info == 0)
+	    continue;
+
+	  /* Walk over each section attached to the input bfd.  */
+	  for (section = input_bfd->sections;
+	       section != NULL; section = section->next)
+	    {
+	      Elf_Internal_Rela *internal_relocs, *irelaend, *irela;
+
+	      /* If there aren't any relocs, then there's nothing more
+		 to do.  */
+	      if ((section->flags & SEC_RELOC) == 0
+		  || section->reloc_count == 0
+		  || (section->flags & SEC_CODE) == 0)
+		continue;
+
+	      /* If this section is a link-once section that will be
+		 discarded, then don't create any stubs.  */
+	      if (section->output_section == NULL
+		  || section->output_section->owner != output_bfd)
+		continue;
+
+	      /* Get the relocs.  */
+	      internal_relocs
+		= _bfd_elf_link_read_relocs (input_bfd, section, NULL,
+					     NULL, info->keep_memory);
+	      if (internal_relocs == NULL)
+		goto error_ret_free_local;
+
+	      /* Now examine each relocation.  */
+	      irela = internal_relocs;
+	      irelaend = irela + section->reloc_count;
+	      for (; irela < irelaend; irela++)
+		{
+		  unsigned int r_type, r_indx;
+		  enum elf_aarch64_stub_type stub_type;
+		  struct elf_aarch64_stub_hash_entry *stub_entry;
+		  asection *sym_sec;
+		  bfd_vma sym_value;
+		  bfd_vma destination;
+		  struct elf_aarch64_link_hash_entry *hash;
+		  const char *sym_name;
+		  char *stub_name;
+		  const asection *id_sec;
+		  unsigned char st_type;
+		  bfd_size_type len;
+
+		  r_type = ELFNN_R_TYPE (irela->r_info);
+		  r_indx = ELFNN_R_SYM (irela->r_info);
+
+		  if (r_type >= (unsigned int) R_AARCH64_end)
+		    {
+		      bfd_set_error (bfd_error_bad_value);
+		    error_ret_free_internal:
+		      if (elf_section_data (section)->relocs == NULL)
+			free (internal_relocs);
+		      goto error_ret_free_local;
+		    }
+
+		  /* Only look for stubs on unconditional branch and
+		     branch and link instructions.  */
+		  if (r_type != (unsigned int) AARCH64_R (CALL26)
+		      && r_type != (unsigned int) AARCH64_R (JUMP26))
+		    continue;
+
+		  /* Now determine the call target, its name, value,
+		     section.  */
+		  sym_sec = NULL;
+		  sym_value = 0;
+		  destination = 0;
+		  hash = NULL;
+		  sym_name = NULL;
+		  if (r_indx < symtab_hdr->sh_info)
+		    {
+		      /* It's a local symbol.  */
+		      Elf_Internal_Sym *sym;
+		      Elf_Internal_Shdr *hdr;
+
+		      if (local_syms == NULL)
+			{
+			  local_syms
+			    = (Elf_Internal_Sym *) symtab_hdr->contents;
+			  if (local_syms == NULL)
+			    local_syms
+			      = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
+						      symtab_hdr->sh_info, 0,
+						      NULL, NULL, NULL);
+			  if (local_syms == NULL)
+			    goto error_ret_free_internal;
+			}
+
+		      sym = local_syms + r_indx;
+		      hdr = elf_elfsections (input_bfd)[sym->st_shndx];
+		      sym_sec = hdr->bfd_section;
+		      if (!sym_sec)
+			/* This is an undefined symbol.  It can never
+			   be resolved.  */
+			continue;
+
+		      if (ELF_ST_TYPE (sym->st_info) != STT_SECTION)
+			sym_value = sym->st_value;
+		      destination = (sym_value + irela->r_addend
+				     + sym_sec->output_offset
+				     + sym_sec->output_section->vma);
+		      st_type = ELF_ST_TYPE (sym->st_info);
+		      sym_name
+			= bfd_elf_string_from_elf_section (input_bfd,
+							   symtab_hdr->sh_link,
+							   sym->st_name);
+		    }
+		  else
+		    {
+		      int e_indx;
+
+		      e_indx = r_indx - symtab_hdr->sh_info;
+		      hash = ((struct elf_aarch64_link_hash_entry *)
+			      elf_sym_hashes (input_bfd)[e_indx]);
+
+		      while (hash->root.root.type == bfd_link_hash_indirect
+			     || hash->root.root.type == bfd_link_hash_warning)
+			hash = ((struct elf_aarch64_link_hash_entry *)
+				hash->root.root.u.i.link);
+
+		      if (hash->root.root.type == bfd_link_hash_defined
+			  || hash->root.root.type == bfd_link_hash_defweak)
+			{
+			  struct elf_aarch64_link_hash_table *globals =
+			    elf_aarch64_hash_table (info);
+			  sym_sec = hash->root.root.u.def.section;
+			  sym_value = hash->root.root.u.def.value;
+			  /* For a destination in a shared library,
+			     use the PLT stub as target address to
+			     decide whether a branch stub is
+			     needed.  */
+			  if (globals->root.splt != NULL && hash != NULL
+			      && hash->root.plt.offset != (bfd_vma) - 1)
+			    {
+			      sym_sec = globals->root.splt;
+			      sym_value = hash->root.plt.offset;
+			      if (sym_sec->output_section != NULL)
+				destination = (sym_value
+					       + sym_sec->output_offset
+					       +
+					       sym_sec->output_section->vma);
+			    }
+			  else if (sym_sec->output_section != NULL)
+			    destination = (sym_value + irela->r_addend
+					   + sym_sec->output_offset
+					   + sym_sec->output_section->vma);
+			}
+		      else if (hash->root.root.type == bfd_link_hash_undefined
+			       || (hash->root.root.type
+				   == bfd_link_hash_undefweak))
+			{
+			  /* For a shared library, use the PLT stub as
+			     target address to decide whether a long
+			     branch stub is needed.
+			     For absolute code, they cannot be handled.  */
+			  struct elf_aarch64_link_hash_table *globals =
+			    elf_aarch64_hash_table (info);
+
+			  if (globals->root.splt != NULL && hash != NULL
+			      && hash->root.plt.offset != (bfd_vma) - 1)
+			    {
+			      sym_sec = globals->root.splt;
+			      sym_value = hash->root.plt.offset;
+			      if (sym_sec->output_section != NULL)
+				destination = (sym_value
+					       + sym_sec->output_offset
+					       +
+					       sym_sec->output_section->vma);
+			    }
+			  else
+			    continue;
+			}
+		      else
+			{
+			  bfd_set_error (bfd_error_bad_value);
+			  goto error_ret_free_internal;
+			}
+		      st_type = ELF_ST_TYPE (hash->root.type);
+		      sym_name = hash->root.root.root.string;
+		    }
+
+		  /* Determine what (if any) linker stub is needed.  */
+		  stub_type = aarch64_type_of_stub
+		    (info, section, irela, st_type, hash, destination);
+		  if (stub_type == aarch64_stub_none)
+		    continue;
+
+		  /* Support for grouping stub sections.  */
+		  id_sec = htab->stub_group[section->id].link_sec;
+
+		  /* Get the name of this stub.  */
+		  stub_name = elfNN_aarch64_stub_name (id_sec, sym_sec, hash,
+						       irela);
+		  if (!stub_name)
+		    goto error_ret_free_internal;
+
+		  stub_entry =
+		    aarch64_stub_hash_lookup (&htab->stub_hash_table,
+					      stub_name, FALSE, FALSE);
+		  if (stub_entry != NULL)
+		    {
+		      /* The proper stub has already been created.  */
+		      free (stub_name);
+		      continue;
+		    }
+
+		  stub_entry = elfNN_aarch64_add_stub (stub_name, section,
+						       htab);
+		  if (stub_entry == NULL)
+		    {
+		      free (stub_name);
+		      goto error_ret_free_internal;
+		    }
+
+		  stub_entry->target_value = sym_value;
+		  stub_entry->target_section = sym_sec;
+		  stub_entry->stub_type = stub_type;
+		  stub_entry->h = hash;
+		  stub_entry->st_type = st_type;
+
+		  if (sym_name == NULL)
+		    sym_name = "unnamed";
+		  len = sizeof (STUB_ENTRY_NAME) + strlen (sym_name);
+		  stub_entry->output_name = bfd_alloc (htab->stub_bfd, len);
+		  if (stub_entry->output_name == NULL)
+		    {
+		      free (stub_name);
+		      goto error_ret_free_internal;
+		    }
+
+		  snprintf (stub_entry->output_name, len, STUB_ENTRY_NAME,
+			    sym_name);
+
+		  stub_changed = TRUE;
+		}
+
+	      /* We're done with the internal relocs, free them.  */
+	      if (elf_section_data (section)->relocs == NULL)
+		free (internal_relocs);
+	    }
+	}
+
+      if (!stub_changed)
+	break;
+
+      /* OK, we've added some stubs.  Find out the new size of the
+         stub sections.  */
+      for (stub_sec = htab->stub_bfd->sections;
+	   stub_sec != NULL; stub_sec = stub_sec->next)
+	stub_sec->size = 0;
+
+      bfd_hash_traverse (&htab->stub_hash_table, aarch64_size_one_stub, htab);
+
+      /* Ask the linker to do its stuff.  */
+      (*htab->layout_sections_again) ();
+      stub_changed = FALSE;
+    }
+
+  return TRUE;
+
+error_ret_free_local:
+  return FALSE;
+}
+
+/* Build all the stubs associated with the current output file.  The
+   stubs are kept in a hash table attached to the main linker hash
+   table.  We also set up the .plt entries for statically linked PIC
+   functions here.  This function is called via aarch64_elf_finish in the
+   linker.  */
+
+bfd_boolean
+elfNN_aarch64_build_stubs (struct bfd_link_info *info)
+{
+  asection *stub_sec;
+  struct bfd_hash_table *table;
+  struct elf_aarch64_link_hash_table *htab;
+
+  htab = elf_aarch64_hash_table (info);
+
+  for (stub_sec = htab->stub_bfd->sections;
+       stub_sec != NULL; stub_sec = stub_sec->next)
+    {
+      bfd_size_type size;
+
+      /* Ignore non-stub sections.  */
+      if (!strstr (stub_sec->name, STUB_SUFFIX))
+	continue;
+
+      /* Allocate memory to hold the linker stubs.  */
+      size = stub_sec->size;
+      stub_sec->contents = bfd_zalloc (htab->stub_bfd, size);
+      if (stub_sec->contents == NULL && size != 0)
+	return FALSE;
+      stub_sec->size = 0;
+    }
+
+  /* Build the stubs as directed by the stub hash table.  */
+  table = &htab->stub_hash_table;
+  bfd_hash_traverse (table, aarch64_build_one_stub, info);
+
+  return TRUE;
+}
+
+
+/* Add an entry to the code/data map for section SEC.  */
+
+static void
+elfNN_aarch64_section_map_add (asection *sec, char type, bfd_vma vma)
+{
+  struct _aarch64_elf_section_data *sec_data =
+    elf_aarch64_section_data (sec);
+  unsigned int newidx;
+
+  if (sec_data->map == NULL)
+    {
+      sec_data->map = bfd_malloc (sizeof (elf_aarch64_section_map));
+      sec_data->mapcount = 0;
+      sec_data->mapsize = 1;
+    }
+
+  newidx = sec_data->mapcount++;
+
+  if (sec_data->mapcount > sec_data->mapsize)
+    {
+      sec_data->mapsize *= 2;
+      sec_data->map = bfd_realloc_or_free
+	(sec_data->map, sec_data->mapsize * sizeof (elf_aarch64_section_map));
+    }
+
+  if (sec_data->map)
+    {
+      sec_data->map[newidx].vma = vma;
+      sec_data->map[newidx].type = type;
+    }
+}
+
+
+/* Initialise maps of insn/data for input BFDs.  */
+void
+bfd_elfNN_aarch64_init_maps (bfd *abfd)
+{
+  Elf_Internal_Sym *isymbuf;
+  Elf_Internal_Shdr *hdr;
+  unsigned int i, localsyms;
+
+  /* Make sure that we are dealing with an AArch64 elf binary.  */
+  if (!is_aarch64_elf (abfd))
+    return;
+
+  if ((abfd->flags & DYNAMIC) != 0)
+    return;
+
+  hdr = &elf_symtab_hdr (abfd);
+  localsyms = hdr->sh_info;
+
+  /* Obtain a buffer full of symbols for this BFD. The hdr->sh_info field
+     should contain the number of local symbols, which should come before any
+     global symbols.  Mapping symbols are always local.  */
+  isymbuf = bfd_elf_get_elf_syms (abfd, hdr, localsyms, 0, NULL, NULL, NULL);
+
+  /* No internal symbols read?  Skip this BFD.  */
+  if (isymbuf == NULL)
+    return;
+
+  for (i = 0; i < localsyms; i++)
+    {
+      Elf_Internal_Sym *isym = &isymbuf[i];
+      asection *sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
+      const char *name;
+
+      if (sec != NULL && ELF_ST_BIND (isym->st_info) == STB_LOCAL)
+	{
+	  name = bfd_elf_string_from_elf_section (abfd,
+						  hdr->sh_link,
+						  isym->st_name);
+
+	  if (bfd_is_aarch64_special_symbol_name
+	      (name, BFD_AARCH64_SPECIAL_SYM_TYPE_MAP))
+	    elfNN_aarch64_section_map_add (sec, name[1], isym->st_value);
+	}
+    }
+}
+
+/* Set option values needed during linking.  */
+void
+bfd_elfNN_aarch64_set_options (struct bfd *output_bfd,
+			       struct bfd_link_info *link_info,
+			       int no_enum_warn,
+			       int no_wchar_warn, int pic_veneer)
+{
+  struct elf_aarch64_link_hash_table *globals;
+
+  globals = elf_aarch64_hash_table (link_info);
+  globals->pic_veneer = pic_veneer;
+
+  BFD_ASSERT (is_aarch64_elf (output_bfd));
+  elf_aarch64_tdata (output_bfd)->no_enum_size_warning = no_enum_warn;
+  elf_aarch64_tdata (output_bfd)->no_wchar_size_warning = no_wchar_warn;
+}
+
+static bfd_vma
+aarch64_calculate_got_entry_vma (struct elf_link_hash_entry *h,
+				 struct elf_aarch64_link_hash_table
+				 *globals, struct bfd_link_info *info,
+				 bfd_vma value, bfd *output_bfd,
+				 bfd_boolean *unresolved_reloc_p)
+{
+  bfd_vma off = (bfd_vma) - 1;
+  asection *basegot = globals->root.sgot;
+  bfd_boolean dyn = globals->root.dynamic_sections_created;
+
+  if (h != NULL)
+    {
+      BFD_ASSERT (basegot != NULL);
+      off = h->got.offset;
+      BFD_ASSERT (off != (bfd_vma) - 1);
+      if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
+	  || (info->shared
+	      && SYMBOL_REFERENCES_LOCAL (info, h))
+	  || (ELF_ST_VISIBILITY (h->other)
+	      && h->root.type == bfd_link_hash_undefweak))
+	{
+	  /* This is actually a static link, or it is a -Bsymbolic link
+	     and the symbol is defined locally.  We must initialize this
+	     entry in the global offset table.  Since the offset must
+	     always be a multiple of 8 (4 in the case of ILP32), we use
+	     the least significant bit to record whether we have
+	     initialized it already.
+	     When doing a dynamic link, we create a .rel(a).got relocation
+	     entry to initialize the value.  This is done in the
+	     finish_dynamic_symbol routine.  */
+	  if ((off & 1) != 0)
+	    off &= ~1;
+	  else
+	    {
+	      bfd_put_NN (output_bfd, value, basegot->contents + off);
+	      h->got.offset |= 1;
+	    }
+	}
+      else
+	*unresolved_reloc_p = FALSE;
+
+      off = off + basegot->output_section->vma + basegot->output_offset;
+    }
+
+  return off;
+}
+
+/* Change R_TYPE to a more efficient access model where possible,
+   return the new reloc type.  */
+
+static bfd_reloc_code_real_type
+aarch64_tls_transition_without_check (bfd_reloc_code_real_type r_type,
+				      struct elf_link_hash_entry *h)
+{
+  bfd_boolean is_local = h == NULL;
+
+  switch (r_type)
+    {
+    case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
+      return (is_local
+	      ? BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1
+	      : BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21);
+
+    case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_LDNN_LO12_NC:
+      return (is_local
+	      ? BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC
+	      : BFD_RELOC_AARCH64_TLSIE_LDNN_GOTTPREL_LO12_NC);
+
+    case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+      return is_local ? BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1 : r_type;
+
+    case BFD_RELOC_AARCH64_TLSIE_LDNN_GOTTPREL_LO12_NC:
+      return is_local ? BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC : r_type;
+
+    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_CALL:
+      /* Instructions with these relocations will become NOPs.  */
+      return BFD_RELOC_AARCH64_NONE;
+
+    default:
+      break;
+    }
+
+  return r_type;
+}
+
+static unsigned int
+aarch64_reloc_got_type (bfd_reloc_code_real_type r_type)
+{
+  switch (r_type)
+    {
+    case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
+    case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC:
+    case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
+    case BFD_RELOC_AARCH64_GOT_LD_PREL19:
+      return GOT_NORMAL;
+
+    case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
+      return GOT_TLS_GD;
+
+    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_TLSDESC_CALL:
+    case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC:
+      return GOT_TLSDESC_GD;
+
+    case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+    case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC:
+      return GOT_TLS_IE;
+
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2:
+      return GOT_UNKNOWN;
+
+    default:
+      break;
+    }
+  return GOT_UNKNOWN;
+}
+
+static bfd_boolean
+aarch64_can_relax_tls (bfd *input_bfd,
+		       struct bfd_link_info *info,
+		       bfd_reloc_code_real_type r_type,
+		       struct elf_link_hash_entry *h,
+		       unsigned long r_symndx)
+{
+  unsigned int symbol_got_type;
+  unsigned int reloc_got_type;
+
+  if (! IS_AARCH64_TLS_RELOC (r_type))
+    return FALSE;
+
+  symbol_got_type = elfNN_aarch64_symbol_got_type (h, input_bfd, r_symndx);
+  reloc_got_type = aarch64_reloc_got_type (r_type);
+
+  if (symbol_got_type == GOT_TLS_IE && GOT_TLS_GD_ANY_P (reloc_got_type))
+    return TRUE;
+
+  if (info->shared)
+    return FALSE;
+
+  if  (h && h->root.type == bfd_link_hash_undefweak)
+    return FALSE;
+
+  return TRUE;
+}
+
+/* Given the relocation code R_TYPE, return the relaxed bfd reloc
+   enumerator.  */
+
+static bfd_reloc_code_real_type
+aarch64_tls_transition (bfd *input_bfd,
+			struct bfd_link_info *info,
+			unsigned int r_type,
+			struct elf_link_hash_entry *h,
+			unsigned long r_symndx)
+{
+  bfd_reloc_code_real_type bfd_r_type
+    = elfNN_aarch64_bfd_reloc_from_type (r_type);
+
+  if (! aarch64_can_relax_tls (input_bfd, info, bfd_r_type, h, r_symndx))
+    return bfd_r_type;
+
+  return aarch64_tls_transition_without_check (bfd_r_type, h);
+}
+
+/* Return the base VMA address which should be subtracted from real addresses
+   when resolving R_AARCH64_TLS_DTPREL relocation.  */
+
+static bfd_vma
+dtpoff_base (struct bfd_link_info *info)
+{
+  /* If tls_sec is NULL, we should have signalled an error already.  */
+  BFD_ASSERT (elf_hash_table (info)->tls_sec != NULL);
+  return elf_hash_table (info)->tls_sec->vma;
+}
+
+/* Return the base VMA address which should be subtracted from real addresses
+   when resolving R_AARCH64_TLS_GOTTPREL64 relocations.  */
+
+static bfd_vma
+tpoff_base (struct bfd_link_info *info)
+{
+  struct elf_link_hash_table *htab = elf_hash_table (info);
+
+  /* If tls_sec is NULL, we should have signalled an error already.  */
+  if (htab->tls_sec == NULL)
+    return 0;
+
+  bfd_vma base = align_power ((bfd_vma) TCB_SIZE,
+			      htab->tls_sec->alignment_power);
+  return htab->tls_sec->vma - base;
+}
+
+static bfd_vma *
+symbol_got_offset_ref (bfd *input_bfd, struct elf_link_hash_entry *h,
+		       unsigned long r_symndx)
+{
+  /* Calculate the address of the GOT entry for symbol
+     referred to in h.  */
+  if (h != NULL)
+    return &h->got.offset;
+  else
+    {
+      /* local symbol */
+      struct elf_aarch64_local_symbol *l;
+
+      l = elf_aarch64_locals (input_bfd);
+      return &l[r_symndx].got_offset;
+    }
+}
+
+static void
+symbol_got_offset_mark (bfd *input_bfd, struct elf_link_hash_entry *h,
+			unsigned long r_symndx)
+{
+  bfd_vma *p;
+  p = symbol_got_offset_ref (input_bfd, h, r_symndx);
+  *p |= 1;
+}
+
+static int
+symbol_got_offset_mark_p (bfd *input_bfd, struct elf_link_hash_entry *h,
+			  unsigned long r_symndx)
+{
+  bfd_vma value;
+  value = * symbol_got_offset_ref (input_bfd, h, r_symndx);
+  return value & 1;
+}
+
+static bfd_vma
+symbol_got_offset (bfd *input_bfd, struct elf_link_hash_entry *h,
+		   unsigned long r_symndx)
+{
+  bfd_vma value;
+  value = * symbol_got_offset_ref (input_bfd, h, r_symndx);
+  value &= ~1;
+  return value;
+}
+
+static bfd_vma *
+symbol_tlsdesc_got_offset_ref (bfd *input_bfd, struct elf_link_hash_entry *h,
+			       unsigned long r_symndx)
+{
+  /* Calculate the address of the GOT entry for symbol
+     referred to in h.  */
+  if (h != NULL)
+    {
+      struct elf_aarch64_link_hash_entry *eh;
+      eh = (struct elf_aarch64_link_hash_entry *) h;
+      return &eh->tlsdesc_got_jump_table_offset;
+    }
+  else
+    {
+      /* local symbol */
+      struct elf_aarch64_local_symbol *l;
+
+      l = elf_aarch64_locals (input_bfd);
+      return &l[r_symndx].tlsdesc_got_jump_table_offset;
+    }
+}
+
+static void
+symbol_tlsdesc_got_offset_mark (bfd *input_bfd, struct elf_link_hash_entry *h,
+				unsigned long r_symndx)
+{
+  bfd_vma *p;
+  p = symbol_tlsdesc_got_offset_ref (input_bfd, h, r_symndx);
+  *p |= 1;
+}
+
+static int
+symbol_tlsdesc_got_offset_mark_p (bfd *input_bfd,
+				  struct elf_link_hash_entry *h,
+				  unsigned long r_symndx)
+{
+  bfd_vma value;
+  value = * symbol_tlsdesc_got_offset_ref (input_bfd, h, r_symndx);
+  return value & 1;
+}
+
+static bfd_vma
+symbol_tlsdesc_got_offset (bfd *input_bfd, struct elf_link_hash_entry *h,
+			  unsigned long r_symndx)
+{
+  bfd_vma value;
+  value = * symbol_tlsdesc_got_offset_ref (input_bfd, h, r_symndx);
+  value &= ~1;
+  return value;
+}
+
+/* Perform a relocation as part of a final link.  */
+static bfd_reloc_status_type
+elfNN_aarch64_final_link_relocate (reloc_howto_type *howto,
+				   bfd *input_bfd,
+				   bfd *output_bfd,
+				   asection *input_section,
+				   bfd_byte *contents,
+				   Elf_Internal_Rela *rel,
+				   bfd_vma value,
+				   struct bfd_link_info *info,
+				   asection *sym_sec,
+				   struct elf_link_hash_entry *h,
+				   bfd_boolean *unresolved_reloc_p,
+				   bfd_boolean save_addend,
+				   bfd_vma *saved_addend,
+				   Elf_Internal_Sym *sym)
+{
+  Elf_Internal_Shdr *symtab_hdr;
+  unsigned int r_type = howto->type;
+  bfd_reloc_code_real_type bfd_r_type
+    = elfNN_aarch64_bfd_reloc_from_howto (howto);
+  bfd_reloc_code_real_type new_bfd_r_type;
+  unsigned long r_symndx;
+  bfd_byte *hit_data = contents + rel->r_offset;
+  bfd_vma place;
+  bfd_signed_vma signed_addend;
+  struct elf_aarch64_link_hash_table *globals;
+  bfd_boolean weak_undef_p;
+
+  globals = elf_aarch64_hash_table (info);
+
+  symtab_hdr = &elf_symtab_hdr (input_bfd);
+
+  BFD_ASSERT (is_aarch64_elf (input_bfd));
+
+  r_symndx = ELFNN_R_SYM (rel->r_info);
+
+  /* It is possible to have linker relaxations on some TLS access
+     models.  Update our information here.  */
+  new_bfd_r_type = aarch64_tls_transition (input_bfd, info, r_type, h, r_symndx);
+  if (new_bfd_r_type != bfd_r_type)
+    {
+      bfd_r_type = new_bfd_r_type;
+      howto = elfNN_aarch64_howto_from_bfd_reloc (bfd_r_type);
+      BFD_ASSERT (howto != NULL);
+      r_type = howto->type;
+    }
+
+  place = input_section->output_section->vma
+    + input_section->output_offset + rel->r_offset;
+
+  /* Get addend, accumulating the addend for consecutive relocs
+     which refer to the same offset.  */
+  signed_addend = saved_addend ? *saved_addend : 0;
+  signed_addend += rel->r_addend;
+
+  weak_undef_p = (h ? h->root.type == bfd_link_hash_undefweak
+		  : bfd_is_und_section (sym_sec));
+
+  /* Since STT_GNU_IFUNC symbol must go through PLT, we handle
+     it here if it is defined in a non-shared object.  */
+  if (h != NULL
+      && h->type == STT_GNU_IFUNC
+      && h->def_regular)
+    {
+      asection *plt;
+      const char *name;
+      asection *base_got;
+      bfd_vma off;
+
+      if ((input_section->flags & SEC_ALLOC) == 0
+	  || h->plt.offset == (bfd_vma) -1)
+	abort ();
+
+      /* STT_GNU_IFUNC symbol must go through PLT.  */
+      plt = globals->root.splt ? globals->root.splt : globals->root.iplt;
+      value = (plt->output_section->vma + plt->output_offset + h->plt.offset);
+
+      switch (bfd_r_type)
+	{
+	default:
+	  if (h->root.root.string)
+	    name = h->root.root.string;
+	  else
+	    name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym,
+				     NULL);
+	  (*_bfd_error_handler)
+	    (_("%B: relocation %s against STT_GNU_IFUNC "
+	       "symbol `%s' isn't handled by %s"), input_bfd,
+	     howto->name, name, __FUNCTION__);
+	  bfd_set_error (bfd_error_bad_value);
+	  return FALSE;
+
+	case BFD_RELOC_AARCH64_NN:
+	  if (rel->r_addend != 0)
+	    {
+	      if (h->root.root.string)
+		name = h->root.root.string;
+	      else
+		name = bfd_elf_sym_name (input_bfd, symtab_hdr,
+					 sym, NULL);
+	      (*_bfd_error_handler)
+		(_("%B: relocation %s against STT_GNU_IFUNC "
+		   "symbol `%s' has non-zero addend: %d"),
+		 input_bfd, howto->name, name, rel->r_addend);
+	      bfd_set_error (bfd_error_bad_value);
+	      return FALSE;
+	    }
+
+	  /* Generate dynamic relocation only when there is a
+	     non-GOT reference in a shared object.  */
+	  if (info->shared && h->non_got_ref)
+	    {
+	      Elf_Internal_Rela outrel;
+	      asection *sreloc;
+
+	      /* Need a dynamic relocation to get the real function
+		 address.  */
+	      outrel.r_offset = _bfd_elf_section_offset (output_bfd,
+							 info,
+							 input_section,
+							 rel->r_offset);
+	      if (outrel.r_offset == (bfd_vma) -1
+		  || outrel.r_offset == (bfd_vma) -2)
+		abort ();
+
+	      outrel.r_offset += (input_section->output_section->vma
+				  + input_section->output_offset);
+
+	      if (h->dynindx == -1
+		  || h->forced_local
+		  || info->executable)
+		{
+		  /* This symbol is resolved locally.  */
+		  outrel.r_info = ELFNN_R_INFO (0, AARCH64_R (IRELATIVE));
+		  outrel.r_addend = (h->root.u.def.value
+				     + h->root.u.def.section->output_section->vma
+				     + h->root.u.def.section->output_offset);
+		}
+	      else
+		{
+		  outrel.r_info = ELFNN_R_INFO (h->dynindx, r_type);
+		  outrel.r_addend = 0;
+		}
+
+	      sreloc = globals->root.irelifunc;
+	      elf_append_rela (output_bfd, sreloc, &outrel);
+
+	      /* If this reloc is against an external symbol, we
+		 do not want to fiddle with the addend.  Otherwise,
+		 we need to include the symbol value so that it
+		 becomes an addend for the dynamic reloc.  For an
+		 internal symbol, we have updated addend.  */
+	      return bfd_reloc_ok;
+	    }
+	  /* FALLTHROUGH */
+	case BFD_RELOC_AARCH64_JUMP26:
+	case BFD_RELOC_AARCH64_CALL26:
+	  value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value,
+						       signed_addend,
+						       weak_undef_p);
+	  return _bfd_aarch64_elf_put_addend (input_bfd, hit_data, bfd_r_type,
+					      howto, value);
+	case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
+	case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC:
+	case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
+	case BFD_RELOC_AARCH64_GOT_LD_PREL19:
+	  base_got = globals->root.sgot;
+	  off = h->got.offset;
+
+	  if (base_got == NULL)
+	    abort ();
+
+	  if (off == (bfd_vma) -1)
+	    {
+	      bfd_vma plt_index;
+
+	      /* We can't use h->got.offset here to save state, or
+		 even just remember the offset, as finish_dynamic_symbol
+		 would use that as offset into .got.  */
+
+	      if (globals->root.splt != NULL)
+		{
+		  plt_index = ((h->plt.offset - globals->plt_header_size) /
+		               globals->plt_entry_size);
+		  off = (plt_index + 3) * GOT_ENTRY_SIZE;
+		  base_got = globals->root.sgotplt;
+		}
+	      else
+		{
+		  plt_index = h->plt.offset / globals->plt_entry_size;
+		  off = plt_index * GOT_ENTRY_SIZE;
+		  base_got = globals->root.igotplt;
+		}
+
+	      if (h->dynindx == -1
+		  || h->forced_local
+		  || info->symbolic)
+		{
+		  /* This references the local definition.  We must
+		     initialize this entry in the global offset table.
+		     Since the offset must always be a multiple of 8,
+		     we use the least significant bit to record
+		     whether we have initialized it already.
+
+		     When doing a dynamic link, we create a .rela.got
+		     relocation entry to initialize the value.  This
+		     is done in the finish_dynamic_symbol routine.	 */
+		  if ((off & 1) != 0)
+		    off &= ~1;
+		  else
+		    {
+		      bfd_put_NN (output_bfd, value,
+				  base_got->contents + off);
+		      /* Note that this is harmless as -1 | 1 still is -1.  */
+		      h->got.offset |= 1;
+		    }
+		}
+	      value = (base_got->output_section->vma
+		       + base_got->output_offset + off);
+	    }
+	  else
+	    value = aarch64_calculate_got_entry_vma (h, globals, info,
+						     value, output_bfd,
+						     unresolved_reloc_p);
+	  value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value,
+						       0, weak_undef_p);
+	  return _bfd_aarch64_elf_put_addend (input_bfd, hit_data, bfd_r_type, howto, value);
+	case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
+	case BFD_RELOC_AARCH64_ADD_LO12:
+	  break;
+	}
+    }
+
+  switch (bfd_r_type)
+    {
+    case BFD_RELOC_AARCH64_NONE:
+    case BFD_RELOC_AARCH64_TLSDESC_CALL:
+      *unresolved_reloc_p = FALSE;
+      return bfd_reloc_ok;
+
+    case BFD_RELOC_AARCH64_NN:
+
+      /* When generating a shared object or relocatable executable, these
+         relocations are copied into the output file to be resolved at
+         run time.  */
+      if (((info->shared == TRUE) || globals->root.is_relocatable_executable)
+	  && (input_section->flags & SEC_ALLOC)
+	  && (h == NULL
+	      || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+	      || h->root.type != bfd_link_hash_undefweak))
+	{
+	  Elf_Internal_Rela outrel;
+	  bfd_byte *loc;
+	  bfd_boolean skip, relocate;
+	  asection *sreloc;
+
+	  *unresolved_reloc_p = FALSE;
+
+	  skip = FALSE;
+	  relocate = FALSE;
+
+	  outrel.r_addend = signed_addend;
+	  outrel.r_offset =
+	    _bfd_elf_section_offset (output_bfd, info, input_section,
+				     rel->r_offset);
+	  if (outrel.r_offset == (bfd_vma) - 1)
+	    skip = TRUE;
+	  else if (outrel.r_offset == (bfd_vma) - 2)
+	    {
+	      skip = TRUE;
+	      relocate = TRUE;
+	    }
+
+	  outrel.r_offset += (input_section->output_section->vma
+			      + input_section->output_offset);
+
+	  if (skip)
+	    memset (&outrel, 0, sizeof outrel);
+	  else if (h != NULL
+		   && h->dynindx != -1
+		   && (!info->shared || !info->symbolic || !h->def_regular))
+	    outrel.r_info = ELFNN_R_INFO (h->dynindx, r_type);
+	  else
+	    {
+	      int symbol;
+
+	      /* On SVR4-ish systems, the dynamic loader cannot
+		 relocate the text and data segments independently,
+		 so the symbol does not matter.  */
+	      symbol = 0;
+	      outrel.r_info = ELFNN_R_INFO (symbol, AARCH64_R (RELATIVE));
+	      outrel.r_addend += value;
+	    }
+
+	  sreloc = elf_section_data (input_section)->sreloc;
+	  if (sreloc == NULL || sreloc->contents == NULL)
+	    return bfd_reloc_notsupported;
+
+	  loc = sreloc->contents + sreloc->reloc_count++ * RELOC_SIZE (globals);
+	  bfd_elfNN_swap_reloca_out (output_bfd, &outrel, loc);
+
+	  if (sreloc->reloc_count * RELOC_SIZE (globals) > sreloc->size)
+	    {
+	      /* Sanity to check that we have previously allocated
+		 sufficient space in the relocation section for the
+		 number of relocations we actually want to emit.  */
+	      abort ();
+	    }
+
+	  /* If this reloc is against an external symbol, we do not want to
+	     fiddle with the addend.  Otherwise, we need to include the symbol
+	     value so that it becomes an addend for the dynamic reloc.  */
+	  if (!relocate)
+	    return bfd_reloc_ok;
+
+	  return _bfd_final_link_relocate (howto, input_bfd, input_section,
+					   contents, rel->r_offset, value,
+					   signed_addend);
+	}
+      else
+	value += signed_addend;
+      break;
+
+    case BFD_RELOC_AARCH64_JUMP26:
+    case BFD_RELOC_AARCH64_CALL26:
+      {
+	asection *splt = globals->root.splt;
+	bfd_boolean via_plt_p =
+	  splt != NULL && h != NULL && h->plt.offset != (bfd_vma) - 1;
+
+	/* A call to an undefined weak symbol is converted to a jump to
+	   the next instruction unless a PLT entry will be created.
+	   The jump to the next instruction is optimized as a NOP.
+	   Do the same for local undefined symbols.  */
+	if (weak_undef_p && ! via_plt_p)
+	  {
+	    bfd_putl32 (INSN_NOP, hit_data);
+	    return bfd_reloc_ok;
+	  }
+
+	/* If the call goes through a PLT entry, make sure to
+	   check distance to the right destination address.  */
+	if (via_plt_p)
+	  {
+	    value = (splt->output_section->vma
+		     + splt->output_offset + h->plt.offset);
+	    *unresolved_reloc_p = FALSE;
+	  }
+
+	/* If the target symbol is global and marked as a function the
+	   relocation applies a function call or a tail call.  In this
+	   situation we can veneer out of range branches.  The veneers
+	   use IP0 and IP1 hence cannot be used arbitrary out of range
+	   branches that occur within the body of a function.  */
+	if (h && h->type == STT_FUNC)
+	  {
+	    /* Check if a stub has to be inserted because the destination
+	       is too far away.  */
+	    if (! aarch64_valid_branch_p (value, place))
+	      {
+		/* The target is out of reach, so redirect the branch to
+		   the local stub for this function.  */
+		struct elf_aarch64_stub_hash_entry *stub_entry;
+		stub_entry = elfNN_aarch64_get_stub_entry (input_section,
+							   sym_sec, h,
+							   rel, globals);
+		if (stub_entry != NULL)
+		  value = (stub_entry->stub_offset
+			   + stub_entry->stub_sec->output_offset
+			   + stub_entry->stub_sec->output_section->vma);
+	      }
+	  }
+      }
+      value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value,
+						   signed_addend, weak_undef_p);
+      break;
+
+    case BFD_RELOC_AARCH64_16:
+#if ARCH_SIZE == 64
+    case BFD_RELOC_AARCH64_32:
+#endif
+    case BFD_RELOC_AARCH64_ADD_LO12:
+    case BFD_RELOC_AARCH64_ADR_LO21_PCREL:
+    case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
+    case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
+    case BFD_RELOC_AARCH64_BRANCH19:
+    case BFD_RELOC_AARCH64_LD_LO19_PCREL:
+    case BFD_RELOC_AARCH64_LDST8_LO12:
+    case BFD_RELOC_AARCH64_LDST16_LO12:
+    case BFD_RELOC_AARCH64_LDST32_LO12:
+    case BFD_RELOC_AARCH64_LDST64_LO12:
+    case BFD_RELOC_AARCH64_LDST128_LO12:
+    case BFD_RELOC_AARCH64_MOVW_G0_S:
+    case BFD_RELOC_AARCH64_MOVW_G1_S:
+    case BFD_RELOC_AARCH64_MOVW_G2_S:
+    case BFD_RELOC_AARCH64_MOVW_G0:
+    case BFD_RELOC_AARCH64_MOVW_G0_NC:
+    case BFD_RELOC_AARCH64_MOVW_G1:
+    case BFD_RELOC_AARCH64_MOVW_G1_NC:
+    case BFD_RELOC_AARCH64_MOVW_G2:
+    case BFD_RELOC_AARCH64_MOVW_G2_NC:
+    case BFD_RELOC_AARCH64_MOVW_G3:
+    case BFD_RELOC_AARCH64_16_PCREL:
+    case BFD_RELOC_AARCH64_32_PCREL:
+    case BFD_RELOC_AARCH64_64_PCREL:
+    case BFD_RELOC_AARCH64_TSTBR14:
+      value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value,
+						   signed_addend, weak_undef_p);
+      break;
+
+    case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
+    case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC:
+    case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
+    case BFD_RELOC_AARCH64_GOT_LD_PREL19:
+      if (globals->root.sgot == NULL)
+	BFD_ASSERT (h != NULL);
+
+      if (h != NULL)
+	{
+	  value = aarch64_calculate_got_entry_vma (h, globals, info, value,
+						   output_bfd,
+						   unresolved_reloc_p);
+	  value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value,
+						       0, weak_undef_p);
+	}
+      break;
+
+    case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+    case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC:
+      if (globals->root.sgot == NULL)
+	return bfd_reloc_notsupported;
+
+      value = (symbol_got_offset (input_bfd, h, r_symndx)
+	       + globals->root.sgot->output_section->vma
+	       + globals->root.sgot->output_offset);
+
+      value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value,
+						   0, weak_undef_p);
+      *unresolved_reloc_p = FALSE;
+      break;
+
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2:
+      value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value,
+						   signed_addend - tpoff_base (info),
+						   weak_undef_p);
+      *unresolved_reloc_p = FALSE;
+      break;
+
+    case BFD_RELOC_AARCH64_TLSDESC_ADD:
+    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_LDR:
+      if (globals->root.sgot == NULL)
+	return bfd_reloc_notsupported;
+
+      value = (symbol_tlsdesc_got_offset (input_bfd, h, r_symndx)
+	       + globals->root.sgotplt->output_section->vma
+	       + globals->root.sgotplt->output_offset
+	       + globals->sgotplt_jump_table_size);
+
+      value = _bfd_aarch64_elf_resolve_relocation (bfd_r_type, place, value,
+						   0, weak_undef_p);
+      *unresolved_reloc_p = FALSE;
+      break;
+
+    default:
+      return bfd_reloc_notsupported;
+    }
+
+  if (saved_addend)
+    *saved_addend = value;
+
+  /* Only apply the final relocation in a sequence.  */
+  if (save_addend)
+    return bfd_reloc_continue;
+
+  return _bfd_aarch64_elf_put_addend (input_bfd, hit_data, bfd_r_type,
+				      howto, value);
+}
+
+/* Handle TLS relaxations.  Relaxing is possible for symbols that use
+   R_AARCH64_TLSDESC_ADR_{PAGE, LD64_LO12_NC, ADD_LO12_NC} during a static
+   link.
+
+   Return bfd_reloc_ok if we're done, bfd_reloc_continue if the caller
+   is to then call final_link_relocate.  Return other values in the
+   case of error.  */
+
+static bfd_reloc_status_type
+elfNN_aarch64_tls_relax (struct elf_aarch64_link_hash_table *globals,
+			 bfd *input_bfd, bfd_byte *contents,
+			 Elf_Internal_Rela *rel, struct elf_link_hash_entry *h)
+{
+  bfd_boolean is_local = h == NULL;
+  unsigned int r_type = ELFNN_R_TYPE (rel->r_info);
+  unsigned long insn;
+
+  BFD_ASSERT (globals && input_bfd && contents && rel);
+
+  switch (elfNN_aarch64_bfd_reloc_from_type (r_type))
+    {
+    case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
+      if (is_local)
+	{
+	  /* GD->LE relaxation:
+	     adrp x0, :tlsgd:var     =>   movz x0, :tprel_g1:var
+	     or
+	     adrp x0, :tlsdesc:var   =>   movz x0, :tprel_g1:var
+	   */
+	  bfd_putl32 (0xd2a00000, contents + rel->r_offset);
+	  return bfd_reloc_continue;
+	}
+      else
+	{
+	  /* GD->IE relaxation:
+	     adrp x0, :tlsgd:var     =>   adrp x0, :gottprel:var
+	     or
+	     adrp x0, :tlsdesc:var   =>   adrp x0, :gottprel:var
+	   */
+	  insn = bfd_getl32 (contents + rel->r_offset);
+	  return bfd_reloc_continue;
+	}
+
+    case BFD_RELOC_AARCH64_TLSDESC_LDNN_LO12_NC:
+      if (is_local)
+	{
+	  /* GD->LE relaxation:
+	     ldr xd, [x0, #:tlsdesc_lo12:var]   =>   movk x0, :tprel_g0_nc:var
+	   */
+	  bfd_putl32 (0xf2800000, contents + rel->r_offset);
+	  return bfd_reloc_continue;
+	}
+      else
+	{
+	  /* GD->IE relaxation:
+	     ldr xd, [x0, #:tlsdesc_lo12:var] => ldr x0, [x0, #:gottprel_lo12:var]
+	   */
+	  insn = bfd_getl32 (contents + rel->r_offset);
+	  insn &= 0xffffffe0;
+	  bfd_putl32 (insn, contents + rel->r_offset);
+	  return bfd_reloc_continue;
+	}
+
+    case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
+      if (is_local)
+	{
+	  /* GD->LE relaxation
+	     add  x0, #:tlsgd_lo12:var  => movk x0, :tprel_g0_nc:var
+	     bl   __tls_get_addr        => mrs  x1, tpidr_el0
+	     nop                        => add  x0, x1, x0
+	   */
+
+	  /* First kill the tls_get_addr reloc on the bl instruction.  */
+	  BFD_ASSERT (rel->r_offset + 4 == rel[1].r_offset);
+	  rel[1].r_info = ELFNN_R_INFO (STN_UNDEF, R_AARCH64_NONE);
+
+	  bfd_putl32 (0xf2800000, contents + rel->r_offset);
+	  bfd_putl32 (0xd53bd041, contents + rel->r_offset + 4);
+	  bfd_putl32 (0x8b000020, contents + rel->r_offset + 8);
+	  return bfd_reloc_continue;
+	}
+      else
+	{
+	  /* GD->IE relaxation
+	     ADD  x0, #:tlsgd_lo12:var  => ldr  x0, [x0, #:gottprel_lo12:var]
+	     BL   __tls_get_addr        => mrs  x1, tpidr_el0
+	       R_AARCH64_CALL26
+	     NOP                        => add  x0, x1, x0
+	   */
+
+	  BFD_ASSERT (ELFNN_R_TYPE (rel[1].r_info) == AARCH64_R (CALL26));
+
+	  /* Remove the relocation on the BL instruction.  */
+	  rel[1].r_info = ELFNN_R_INFO (STN_UNDEF, R_AARCH64_NONE);
+
+	  bfd_putl32 (0xf9400000, contents + rel->r_offset);
+
+	  /* We choose to fixup the BL and NOP instructions using the
+	     offset from the second relocation to allow flexibility in
+	     scheduling instructions between the ADD and BL.  */
+	  bfd_putl32 (0xd53bd041, contents + rel[1].r_offset);
+	  bfd_putl32 (0x8b000020, contents + rel[1].r_offset + 4);
+	  return bfd_reloc_continue;
+	}
+
+    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_CALL:
+      /* GD->IE/LE relaxation:
+         add x0, x0, #:tlsdesc_lo12:var   =>   nop
+         blr xd                           =>   nop
+       */
+      bfd_putl32 (INSN_NOP, contents + rel->r_offset);
+      return bfd_reloc_ok;
+
+    case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+      /* IE->LE relaxation:
+         adrp xd, :gottprel:var   =>   movz xd, :tprel_g1:var
+       */
+      if (is_local)
+	{
+	  insn = bfd_getl32 (contents + rel->r_offset);
+	  bfd_putl32 (0xd2a00000 | (insn & 0x1f), contents + rel->r_offset);
+	}
+      return bfd_reloc_continue;
+
+    case BFD_RELOC_AARCH64_TLSIE_LDNN_GOTTPREL_LO12_NC:
+      /* IE->LE relaxation:
+         ldr  xd, [xm, #:gottprel_lo12:var]   =>   movk xd, :tprel_g0_nc:var
+       */
+      if (is_local)
+	{
+	  insn = bfd_getl32 (contents + rel->r_offset);
+	  bfd_putl32 (0xf2800000 | (insn & 0x1f), contents + rel->r_offset);
+	}
+      return bfd_reloc_continue;
+
+    default:
+      return bfd_reloc_continue;
+    }
+
+  return bfd_reloc_ok;
+}
+
+/* Relocate an AArch64 ELF section.  */
+
+static bfd_boolean
+elfNN_aarch64_relocate_section (bfd *output_bfd,
+				struct bfd_link_info *info,
+				bfd *input_bfd,
+				asection *input_section,
+				bfd_byte *contents,
+				Elf_Internal_Rela *relocs,
+				Elf_Internal_Sym *local_syms,
+				asection **local_sections)
+{
+  Elf_Internal_Shdr *symtab_hdr;
+  struct elf_link_hash_entry **sym_hashes;
+  Elf_Internal_Rela *rel;
+  Elf_Internal_Rela *relend;
+  const char *name;
+  struct elf_aarch64_link_hash_table *globals;
+  bfd_boolean save_addend = FALSE;
+  bfd_vma addend = 0;
+
+  globals = elf_aarch64_hash_table (info);
+
+  symtab_hdr = &elf_symtab_hdr (input_bfd);
+  sym_hashes = elf_sym_hashes (input_bfd);
+
+  rel = relocs;
+  relend = relocs + input_section->reloc_count;
+  for (; rel < relend; rel++)
+    {
+      unsigned int r_type;
+      bfd_reloc_code_real_type bfd_r_type;
+      bfd_reloc_code_real_type relaxed_bfd_r_type;
+      reloc_howto_type *howto;
+      unsigned long r_symndx;
+      Elf_Internal_Sym *sym;
+      asection *sec;
+      struct elf_link_hash_entry *h;
+      bfd_vma relocation;
+      bfd_reloc_status_type r;
+      arelent bfd_reloc;
+      char sym_type;
+      bfd_boolean unresolved_reloc = FALSE;
+      char *error_message = NULL;
+
+      r_symndx = ELFNN_R_SYM (rel->r_info);
+      r_type = ELFNN_R_TYPE (rel->r_info);
+
+      bfd_reloc.howto = elfNN_aarch64_howto_from_type (r_type);
+      howto = bfd_reloc.howto;
+
+      if (howto == NULL)
+	{
+	  (*_bfd_error_handler)
+	    (_("%B: unrecognized relocation (0x%x) in section `%A'"),
+	     input_bfd, input_section, r_type);
+	  return FALSE;
+	}
+      bfd_r_type = elfNN_aarch64_bfd_reloc_from_howto (howto);
+
+      h = NULL;
+      sym = NULL;
+      sec = NULL;
+
+      if (r_symndx < symtab_hdr->sh_info)
+	{
+	  sym = local_syms + r_symndx;
+	  sym_type = ELFNN_ST_TYPE (sym->st_info);
+	  sec = local_sections[r_symndx];
+
+	  /* An object file might have a reference to a local
+	     undefined symbol.  This is a daft object file, but we
+	     should at least do something about it.  */
+	  if (r_type != R_AARCH64_NONE && r_type != R_AARCH64_NULL
+	      && bfd_is_und_section (sec)
+	      && ELF_ST_BIND (sym->st_info) != STB_WEAK)
+	    {
+	      if (!info->callbacks->undefined_symbol
+		  (info, bfd_elf_string_from_elf_section
+		   (input_bfd, symtab_hdr->sh_link, sym->st_name),
+		   input_bfd, input_section, rel->r_offset, TRUE))
+		return FALSE;
+	    }
+
+	  relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
+
+	  /* Relocate against local STT_GNU_IFUNC symbol.  */
+	  if (!info->relocatable
+	      && ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC)
+	    {
+	      h = elfNN_aarch64_get_local_sym_hash (globals, input_bfd,
+						    rel, FALSE);
+	      if (h == NULL)
+		abort ();
+
+	      /* Set STT_GNU_IFUNC symbol value.  */
+	      h->root.u.def.value = sym->st_value;
+	      h->root.u.def.section = sec;
+	    }
+	}
+      else
+	{
+	  bfd_boolean warned;
+
+	  RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
+				   r_symndx, symtab_hdr, sym_hashes,
+				   h, sec, relocation,
+				   unresolved_reloc, warned);
+
+	  sym_type = h->type;
+	}
+
+      if (sec != NULL && discarded_section (sec))
+	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					 rel, 1, relend, howto, 0, contents);
+
+      if (info->relocatable)
+	{
+	  /* This is a relocatable link.  We don't have to change
+	     anything, unless the reloc is against a section symbol,
+	     in which case we have to adjust according to where the
+	     section symbol winds up in the output section.  */
+	  if (sym != NULL && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+	    rel->r_addend += sec->output_offset;
+	  continue;
+	}
+
+      if (h != NULL)
+	name = h->root.root.string;
+      else
+	{
+	  name = (bfd_elf_string_from_elf_section
+		  (input_bfd, symtab_hdr->sh_link, sym->st_name));
+	  if (name == NULL || *name == '\0')
+	    name = bfd_section_name (input_bfd, sec);
+	}
+
+      if (r_symndx != 0
+	  && r_type != R_AARCH64_NONE
+	  && r_type != R_AARCH64_NULL
+	  && (h == NULL
+	      || h->root.type == bfd_link_hash_defined
+	      || h->root.type == bfd_link_hash_defweak)
+	  && IS_AARCH64_TLS_RELOC (bfd_r_type) != (sym_type == STT_TLS))
+	{
+	  (*_bfd_error_handler)
+	    ((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,
+	     input_section, (long) rel->r_offset, howto->name, name);
+	}
+
+      /* We relax only if we can see that there can be a valid transition
+         from a reloc type to another.
+         We call elfNN_aarch64_final_link_relocate unless we're completely
+         done, i.e., the relaxation produced the final output we want.  */
+
+      relaxed_bfd_r_type = aarch64_tls_transition (input_bfd, info, r_type,
+						   h, r_symndx);
+      if (relaxed_bfd_r_type != bfd_r_type)
+	{
+	  bfd_r_type = relaxed_bfd_r_type;
+	  howto = elfNN_aarch64_howto_from_bfd_reloc (bfd_r_type);
+	  BFD_ASSERT (howto != NULL);
+	  r_type = howto->type;
+	  r = elfNN_aarch64_tls_relax (globals, input_bfd, contents, rel, h);
+	  unresolved_reloc = 0;
+	}
+      else
+	r = bfd_reloc_continue;
+
+      /* There may be multiple consecutive relocations for the
+         same offset.  In that case we are supposed to treat the
+         output of each relocation as the addend for the next.  */
+      if (rel + 1 < relend
+	  && rel->r_offset == rel[1].r_offset
+	  && ELFNN_R_TYPE (rel[1].r_info) != R_AARCH64_NONE
+	  && ELFNN_R_TYPE (rel[1].r_info) != R_AARCH64_NULL)
+	save_addend = TRUE;
+      else
+	save_addend = FALSE;
+
+      if (r == bfd_reloc_continue)
+	r = elfNN_aarch64_final_link_relocate (howto, input_bfd, output_bfd,
+					       input_section, contents, rel,
+					       relocation, info, sec,
+					       h, &unresolved_reloc,
+					       save_addend, &addend, sym);
+
+      switch (elfNN_aarch64_bfd_reloc_from_type (r_type))
+	{
+	case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
+	case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
+	  if (! symbol_got_offset_mark_p (input_bfd, h, r_symndx))
+	    {
+	      bfd_boolean need_relocs = FALSE;
+	      bfd_byte *loc;
+	      int indx;
+	      bfd_vma off;
+
+	      off = symbol_got_offset (input_bfd, h, r_symndx);
+	      indx = h && h->dynindx != -1 ? h->dynindx : 0;
+
+	      need_relocs =
+		(info->shared || indx != 0) &&
+		(h == NULL
+		 || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+		 || h->root.type != bfd_link_hash_undefweak);
+
+	      BFD_ASSERT (globals->root.srelgot != NULL);
+
+	      if (need_relocs)
+		{
+		  Elf_Internal_Rela rela;
+		  rela.r_info = ELFNN_R_INFO (indx, AARCH64_R (TLS_DTPMOD));
+		  rela.r_addend = 0;
+		  rela.r_offset = globals->root.sgot->output_section->vma +
+		    globals->root.sgot->output_offset + off;
+
+
+		  loc = globals->root.srelgot->contents;
+		  loc += globals->root.srelgot->reloc_count++
+		    * RELOC_SIZE (htab);
+		  bfd_elfNN_swap_reloca_out (output_bfd, &rela, loc);
+
+		  if (indx == 0)
+		    {
+		      bfd_put_NN (output_bfd,
+				  relocation - dtpoff_base (info),
+				  globals->root.sgot->contents + off
+				  + GOT_ENTRY_SIZE);
+		    }
+		  else
+		    {
+		      /* This TLS symbol is global. We emit a
+			 relocation to fixup the tls offset at load
+			 time.  */
+		      rela.r_info =
+			ELFNN_R_INFO (indx, AARCH64_R (TLS_DTPREL));
+		      rela.r_addend = 0;
+		      rela.r_offset =
+			(globals->root.sgot->output_section->vma
+			 + globals->root.sgot->output_offset + off
+			 + GOT_ENTRY_SIZE);
+
+		      loc = globals->root.srelgot->contents;
+		      loc += globals->root.srelgot->reloc_count++
+			* RELOC_SIZE (globals);
+		      bfd_elfNN_swap_reloca_out (output_bfd, &rela, loc);
+		      bfd_put_NN (output_bfd, (bfd_vma) 0,
+				  globals->root.sgot->contents + off
+				  + GOT_ENTRY_SIZE);
+		    }
+		}
+	      else
+		{
+		  bfd_put_NN (output_bfd, (bfd_vma) 1,
+			      globals->root.sgot->contents + off);
+		  bfd_put_NN (output_bfd,
+			      relocation - dtpoff_base (info),
+			      globals->root.sgot->contents + off
+			      + GOT_ENTRY_SIZE);
+		}
+
+	      symbol_got_offset_mark (input_bfd, h, r_symndx);
+	    }
+	  break;
+
+	case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+	case BFD_RELOC_AARCH64_TLSIE_LDNN_GOTTPREL_LO12_NC:
+	  if (! symbol_got_offset_mark_p (input_bfd, h, r_symndx))
+	    {
+	      bfd_boolean need_relocs = FALSE;
+	      bfd_byte *loc;
+	      int indx;
+	      bfd_vma off;
+
+	      off = symbol_got_offset (input_bfd, h, r_symndx);
+
+	      indx = h && h->dynindx != -1 ? h->dynindx : 0;
+
+	      need_relocs =
+		(info->shared || indx != 0) &&
+		(h == NULL
+		 || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+		 || h->root.type != bfd_link_hash_undefweak);
+
+	      BFD_ASSERT (globals->root.srelgot != NULL);
+
+	      if (need_relocs)
+		{
+		  Elf_Internal_Rela rela;
+
+		  if (indx == 0)
+		    rela.r_addend = relocation - dtpoff_base (info);
+		  else
+		    rela.r_addend = 0;
+
+		  rela.r_info = ELFNN_R_INFO (indx, AARCH64_R (TLS_TPREL));
+		  rela.r_offset = globals->root.sgot->output_section->vma +
+		    globals->root.sgot->output_offset + off;
+
+		  loc = globals->root.srelgot->contents;
+		  loc += globals->root.srelgot->reloc_count++
+		    * RELOC_SIZE (htab);
+
+		  bfd_elfNN_swap_reloca_out (output_bfd, &rela, loc);
+
+		  bfd_put_NN (output_bfd, rela.r_addend,
+			      globals->root.sgot->contents + off);
+		}
+	      else
+		bfd_put_NN (output_bfd, relocation - tpoff_base (info),
+			    globals->root.sgot->contents + off);
+
+	      symbol_got_offset_mark (input_bfd, h, r_symndx);
+	    }
+	  break;
+
+	case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
+	case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
+	case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
+	case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2:
+	case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1:
+	case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
+	case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0:
+	case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
+	  break;
+
+	case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+	case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
+	case BFD_RELOC_AARCH64_TLSDESC_LDNN_LO12_NC:
+	  if (! symbol_tlsdesc_got_offset_mark_p (input_bfd, h, r_symndx))
+	    {
+	      bfd_boolean need_relocs = FALSE;
+	      int indx = h && h->dynindx != -1 ? h->dynindx : 0;
+	      bfd_vma off = symbol_tlsdesc_got_offset (input_bfd, h, r_symndx);
+
+	      need_relocs = (h == NULL
+			     || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+			     || h->root.type != bfd_link_hash_undefweak);
+
+	      BFD_ASSERT (globals->root.srelgot != NULL);
+	      BFD_ASSERT (globals->root.sgot != NULL);
+
+	      if (need_relocs)
+		{
+		  bfd_byte *loc;
+		  Elf_Internal_Rela rela;
+		  rela.r_info = ELFNN_R_INFO (indx, AARCH64_R (TLSDESC));
+
+		  rela.r_addend = 0;
+		  rela.r_offset = (globals->root.sgotplt->output_section->vma
+				   + globals->root.sgotplt->output_offset
+				   + off + globals->sgotplt_jump_table_size);
+
+		  if (indx == 0)
+		    rela.r_addend = relocation - dtpoff_base (info);
+
+		  /* Allocate the next available slot in the PLT reloc
+		     section to hold our R_AARCH64_TLSDESC, the next
+		     available slot is determined from reloc_count,
+		     which we step. But note, reloc_count was
+		     artifically moved down while allocating slots for
+		     real PLT relocs such that all of the PLT relocs
+		     will fit above the initial reloc_count and the
+		     extra stuff will fit below.  */
+		  loc = globals->root.srelplt->contents;
+		  loc += globals->root.srelplt->reloc_count++
+		    * RELOC_SIZE (globals);
+
+		  bfd_elfNN_swap_reloca_out (output_bfd, &rela, loc);
+
+		  bfd_put_NN (output_bfd, (bfd_vma) 0,
+			      globals->root.sgotplt->contents + off +
+			      globals->sgotplt_jump_table_size);
+		  bfd_put_NN (output_bfd, (bfd_vma) 0,
+			      globals->root.sgotplt->contents + off +
+			      globals->sgotplt_jump_table_size +
+			      GOT_ENTRY_SIZE);
+		}
+
+	      symbol_tlsdesc_got_offset_mark (input_bfd, h, r_symndx);
+	    }
+	  break;
+	default:
+	  break;
+	}
+
+      if (!save_addend)
+	addend = 0;
+
+
+      /* Dynamic relocs are not propagated for SEC_DEBUGGING sections
+         because such sections are not SEC_ALLOC and thus ld.so will
+         not process them.  */
+      if (unresolved_reloc
+	  && !((input_section->flags & SEC_DEBUGGING) != 0
+	       && h->def_dynamic)
+	  && _bfd_elf_section_offset (output_bfd, info, input_section,
+				      +rel->r_offset) != (bfd_vma) - 1)
+	{
+	  (*_bfd_error_handler)
+	    (_
+	     ("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
+	     input_bfd, input_section, (long) rel->r_offset, howto->name,
+	     h->root.root.string);
+	  return FALSE;
+	}
+
+      if (r != bfd_reloc_ok && r != bfd_reloc_continue)
+	{
+	  switch (r)
+	    {
+	    case bfd_reloc_overflow:
+	      /* If the overflowing reloc was to an undefined symbol,
+		 we have already printed one error message and there
+		 is no point complaining again.  */
+	      if ((!h ||
+		   h->root.type != bfd_link_hash_undefined)
+		  && (!((*info->callbacks->reloc_overflow)
+			(info, (h ? &h->root : NULL), name, howto->name,
+			 (bfd_vma) 0, input_bfd, input_section,
+			 rel->r_offset))))
+		return FALSE;
+	      break;
+
+	    case bfd_reloc_undefined:
+	      if (!((*info->callbacks->undefined_symbol)
+		    (info, name, input_bfd, input_section,
+		     rel->r_offset, TRUE)))
+		return FALSE;
+	      break;
+
+	    case bfd_reloc_outofrange:
+	      error_message = _("out of range");
+	      goto common_error;
+
+	    case bfd_reloc_notsupported:
+	      error_message = _("unsupported relocation");
+	      goto common_error;
+
+	    case bfd_reloc_dangerous:
+	      /* error_message should already be set.  */
+	      goto common_error;
+
+	    default:
+	      error_message = _("unknown error");
+	      /* Fall through.  */
+
+	    common_error:
+	      BFD_ASSERT (error_message != NULL);
+	      if (!((*info->callbacks->reloc_dangerous)
+		    (info, error_message, input_bfd, input_section,
+		     rel->r_offset)))
+		return FALSE;
+	      break;
+	    }
+	}
+    }
+
+  return TRUE;
+}
+
+/* Set the right machine number.  */
+
+static bfd_boolean
+elfNN_aarch64_object_p (bfd *abfd)
+{
+#if ARCH_SIZE == 32
+  bfd_default_set_arch_mach (abfd, bfd_arch_aarch64, bfd_mach_aarch64_ilp32);
+#else
+  bfd_default_set_arch_mach (abfd, bfd_arch_aarch64, bfd_mach_aarch64);
+#endif
+  return TRUE;
+}
+
+/* Function to keep AArch64 specific flags in the ELF header.  */
+
+static bfd_boolean
+elfNN_aarch64_set_private_flags (bfd *abfd, flagword flags)
+{
+  if (elf_flags_init (abfd) && elf_elfheader (abfd)->e_flags != flags)
+    {
+    }
+  else
+    {
+      elf_elfheader (abfd)->e_flags = flags;
+      elf_flags_init (abfd) = TRUE;
+    }
+
+  return TRUE;
+}
+
+/* Copy backend specific data from one object module to another.  */
+
+static bfd_boolean
+elfNN_aarch64_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
+{
+  flagword in_flags;
+
+  if (!is_aarch64_elf (ibfd) || !is_aarch64_elf (obfd))
+    return TRUE;
+
+  in_flags = elf_elfheader (ibfd)->e_flags;
+
+  elf_elfheader (obfd)->e_flags = in_flags;
+  elf_flags_init (obfd) = TRUE;
+
+  /* Also copy the EI_OSABI field.  */
+  elf_elfheader (obfd)->e_ident[EI_OSABI] =
+    elf_elfheader (ibfd)->e_ident[EI_OSABI];
+
+  /* Copy object attributes.  */
+  _bfd_elf_copy_obj_attributes (ibfd, obfd);
+
+  return TRUE;
+}
+
+/* Merge backend specific data from an object file to the output
+   object file when linking.  */
+
+static bfd_boolean
+elfNN_aarch64_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
+{
+  flagword out_flags;
+  flagword in_flags;
+  bfd_boolean flags_compatible = TRUE;
+  asection *sec;
+
+  /* Check if we have the same endianess.  */
+  if (!_bfd_generic_verify_endian_match (ibfd, obfd))
+    return FALSE;
+
+  if (!is_aarch64_elf (ibfd) || !is_aarch64_elf (obfd))
+    return TRUE;
+
+  /* The input BFD must have had its flags initialised.  */
+  /* The following seems bogus to me -- The flags are initialized in
+     the assembler but I don't think an elf_flags_init field is
+     written into the object.  */
+  /* BFD_ASSERT (elf_flags_init (ibfd)); */
+
+  in_flags = elf_elfheader (ibfd)->e_flags;
+  out_flags = elf_elfheader (obfd)->e_flags;
+
+  if (!elf_flags_init (obfd))
+    {
+      /* If the input is the default architecture and had the default
+         flags then do not bother setting the flags for the output
+         architecture, instead allow future merges to do this.  If no
+         future merges ever set these flags then they will retain their
+         uninitialised values, which surprise surprise, correspond
+         to the default values.  */
+      if (bfd_get_arch_info (ibfd)->the_default
+	  && elf_elfheader (ibfd)->e_flags == 0)
+	return TRUE;
+
+      elf_flags_init (obfd) = TRUE;
+      elf_elfheader (obfd)->e_flags = in_flags;
+
+      if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
+	  && bfd_get_arch_info (obfd)->the_default)
+	return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd),
+				  bfd_get_mach (ibfd));
+
+      return TRUE;
+    }
+
+  /* Identical flags must be compatible.  */
+  if (in_flags == out_flags)
+    return TRUE;
+
+  /* Check to see if the input BFD actually contains any sections.  If
+     not, its flags may not have been initialised either, but it
+     cannot actually cause any incompatiblity.  Do not short-circuit
+     dynamic objects; their section list may be emptied by
+     elf_link_add_object_symbols.
+
+     Also check to see if there are no code sections in the input.
+     In this case there is no need to check for code specific flags.
+     XXX - do we need to worry about floating-point format compatability
+     in data sections ?  */
+  if (!(ibfd->flags & DYNAMIC))
+    {
+      bfd_boolean null_input_bfd = TRUE;
+      bfd_boolean only_data_sections = TRUE;
+
+      for (sec = ibfd->sections; sec != NULL; sec = sec->next)
+	{
+	  if ((bfd_get_section_flags (ibfd, sec)
+	       & (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS))
+	      == (SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS))
+	    only_data_sections = FALSE;
+
+	  null_input_bfd = FALSE;
+	  break;
+	}
+
+      if (null_input_bfd || only_data_sections)
+	return TRUE;
+    }
+
+  return flags_compatible;
+}
+
+/* Display the flags field.  */
+
+static bfd_boolean
+elfNN_aarch64_print_private_bfd_data (bfd *abfd, void *ptr)
+{
+  FILE *file = (FILE *) ptr;
+  unsigned long flags;
+
+  BFD_ASSERT (abfd != NULL && ptr != NULL);
+
+  /* Print normal ELF private data.  */
+  _bfd_elf_print_private_bfd_data (abfd, ptr);
+
+  flags = elf_elfheader (abfd)->e_flags;
+  /* Ignore init flag - it may not be set, despite the flags field
+     containing valid data.  */
+
+  /* xgettext:c-format */
+  fprintf (file, _("private flags = %lx:"), elf_elfheader (abfd)->e_flags);
+
+  if (flags)
+    fprintf (file, _("<Unrecognised flag bits set>"));
+
+  fputc ('\n', file);
+
+  return TRUE;
+}
+
+/* Update the got entry reference counts for the section being removed.  */
+
+static bfd_boolean
+elfNN_aarch64_gc_sweep_hook (bfd *abfd,
+			     struct bfd_link_info *info,
+			     asection *sec,
+			     const Elf_Internal_Rela * relocs)
+{
+  struct elf_aarch64_link_hash_table *htab;
+  Elf_Internal_Shdr *symtab_hdr;
+  struct elf_link_hash_entry **sym_hashes;
+  struct elf_aarch64_local_symbol *locals;
+  const Elf_Internal_Rela *rel, *relend;
+
+  if (info->relocatable)
+    return TRUE;
+
+  htab = elf_aarch64_hash_table (info);
+
+  if (htab == NULL)
+    return FALSE;
+
+  elf_section_data (sec)->local_dynrel = NULL;
+
+  symtab_hdr = &elf_symtab_hdr (abfd);
+  sym_hashes = elf_sym_hashes (abfd);
+
+  locals = elf_aarch64_locals (abfd);
+
+  relend = relocs + sec->reloc_count;
+  for (rel = relocs; rel < relend; rel++)
+    {
+      unsigned long r_symndx;
+      unsigned int r_type;
+      struct elf_link_hash_entry *h = NULL;
+
+      r_symndx = ELFNN_R_SYM (rel->r_info);
+
+      if (r_symndx >= symtab_hdr->sh_info)
+	{
+
+	  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;
+        }
+      else
+	{
+	  Elf_Internal_Sym *isym;
+
+	  /* A local symbol.  */
+	  isym = bfd_sym_from_r_symndx (&htab->sym_cache,
+					abfd, r_symndx);
+
+	  /* Check relocation against local STT_GNU_IFUNC symbol.  */
+	  if (isym != NULL
+	      && ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC)
+	    {
+	      h = elfNN_aarch64_get_local_sym_hash (htab, abfd, rel, FALSE);
+	      if (h == NULL)
+		abort ();
+	    }
+	}
+
+      if (h)
+	{
+	  struct elf_aarch64_link_hash_entry *eh;
+	  struct elf_dyn_relocs **pp;
+	  struct elf_dyn_relocs *p;
+
+	  eh = (struct elf_aarch64_link_hash_entry *) h;
+
+	  for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
+	    if (p->sec == sec)
+	      {
+		/* Everything must go for SEC.  */
+		*pp = p->next;
+		break;
+	      }
+	}
+
+      r_type = ELFNN_R_TYPE (rel->r_info);
+      switch (aarch64_tls_transition (abfd,info, r_type, h ,r_symndx))
+	{
+	case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
+	case BFD_RELOC_AARCH64_GOT_LD_PREL19:
+	case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC:
+	case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
+	case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+	case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
+	case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC:
+	case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
+	case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
+	case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
+	case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+	case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC:
+	case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
+	case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
+	case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
+	case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
+	case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0:
+	case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
+	case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1:
+	case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
+	case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2:
+	  if (h != NULL)
+	    {
+	      if (h->got.refcount > 0)
+		h->got.refcount -= 1;
+
+	      if (h->type == STT_GNU_IFUNC)
+		{
+		  if (h->plt.refcount > 0)
+		    h->plt.refcount -= 1;
+		}
+	    }
+	  else if (locals != NULL)
+	    {
+	      if (locals[r_symndx].got_refcount > 0)
+		locals[r_symndx].got_refcount -= 1;
+	    }
+	  break;
+
+	case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
+	case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
+	case BFD_RELOC_AARCH64_ADR_LO21_PCREL:
+	  if (h != NULL && info->executable)
+	    {
+	      if (h->plt.refcount > 0)
+		h->plt.refcount -= 1;
+	    }
+	  break;
+
+	case BFD_RELOC_AARCH64_CALL26:
+	case BFD_RELOC_AARCH64_JUMP26:
+	  /* If this is a local symbol then we resolve it
+	     directly without creating a PLT entry.  */
+	  if (h == NULL)
+	    continue;
+
+	  if (h->plt.refcount > 0)
+	    h->plt.refcount -= 1;
+	  break;
+
+	case BFD_RELOC_AARCH64_NN:
+	  if (h != NULL && info->executable)
+	    {
+	      if (h->plt.refcount > 0)
+		h->plt.refcount -= 1;
+	    }
+	  break;
+
+	default:
+	  break;
+	}
+    }
+
+  return TRUE;
+}
+
+/* Adjust a symbol defined by a dynamic object and referenced by a
+   regular object.  The current definition is in some section of the
+   dynamic object, but we're not including those sections.  We have to
+   change the definition to something the rest of the link can
+   understand.	*/
+
+static bfd_boolean
+elfNN_aarch64_adjust_dynamic_symbol (struct bfd_link_info *info,
+				     struct elf_link_hash_entry *h)
+{
+  struct elf_aarch64_link_hash_table *htab;
+  asection *s;
+
+  /* If this is a function, put it in the procedure linkage table.  We
+     will fill in the contents of the procedure linkage table later,
+     when we know the address of the .got section.  */
+  if (h->type == STT_FUNC || h->type == STT_GNU_IFUNC || h->needs_plt)
+    {
+      if (h->plt.refcount <= 0
+	  || (h->type != STT_GNU_IFUNC
+	      && (SYMBOL_CALLS_LOCAL (info, h)
+		  || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
+		      && h->root.type == bfd_link_hash_undefweak))))
+	{
+	  /* This case can occur if we saw a CALL26 reloc in
+	     an input file, but the symbol wasn't referred to
+	     by a dynamic object or all references were
+	     garbage collected. In which case we can end up
+	     resolving.  */
+	  h->plt.offset = (bfd_vma) - 1;
+	  h->needs_plt = 0;
+	}
+
+      return TRUE;
+    }
+  else
+    /* It's possible that we incorrectly decided a .plt reloc was
+       needed for an R_X86_64_PC32 reloc to a non-function sym in
+       check_relocs.  We can't decide accurately between function and
+       non-function syms in check-relocs;  Objects loaded later in
+       the link may change h->type.  So fix it now.  */
+    h->plt.offset = (bfd_vma) - 1;
+
+
+  /* If this is a weak symbol, and there is a real definition, the
+     processor independent code will have arranged for us to see the
+     real definition first, and we can just use the same value.  */
+  if (h->u.weakdef != NULL)
+    {
+      BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
+		  || h->u.weakdef->root.type == bfd_link_hash_defweak);
+      h->root.u.def.section = h->u.weakdef->root.u.def.section;
+      h->root.u.def.value = h->u.weakdef->root.u.def.value;
+      if (ELIMINATE_COPY_RELOCS || info->nocopyreloc)
+	h->non_got_ref = h->u.weakdef->non_got_ref;
+      return TRUE;
+    }
+
+  /* If we are creating a shared library, we must presume that the
+     only references to the symbol are via the global offset table.
+     For such cases we need not do anything here; the relocations will
+     be handled correctly by relocate_section.  */
+  if (info->shared)
+    return TRUE;
+
+  /* If there are no references to this symbol that do not use the
+     GOT, we don't need to generate a copy reloc.  */
+  if (!h->non_got_ref)
+    return TRUE;
+
+  /* If -z nocopyreloc was given, we won't generate them either.  */
+  if (info->nocopyreloc)
+    {
+      h->non_got_ref = 0;
+      return TRUE;
+    }
+
+  /* We must allocate the symbol in our .dynbss section, which will
+     become part of the .bss section of the executable.  There will be
+     an entry for this symbol in the .dynsym section.  The dynamic
+     object will contain position independent code, so all references
+     from the dynamic object to this symbol will go through the global
+     offset table.  The dynamic linker will use the .dynsym entry to
+     determine the address it must put in the global offset table, so
+     both the dynamic object and the regular object will refer to the
+     same memory location for the variable.  */
+
+  htab = elf_aarch64_hash_table (info);
+
+  /* We must generate a R_AARCH64_COPY reloc to tell the dynamic linker
+     to copy the initial value out of the dynamic object and into the
+     runtime process image.  */
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
+    {
+      htab->srelbss->size += RELOC_SIZE (htab);
+      h->needs_copy = 1;
+    }
+
+  s = htab->sdynbss;
+
+  return _bfd_elf_adjust_dynamic_copy (h, s);
+
+}
+
+static bfd_boolean
+elfNN_aarch64_allocate_local_symbols (bfd *abfd, unsigned number)
+{
+  struct elf_aarch64_local_symbol *locals;
+  locals = elf_aarch64_locals (abfd);
+  if (locals == NULL)
+    {
+      locals = (struct elf_aarch64_local_symbol *)
+	bfd_zalloc (abfd, number * sizeof (struct elf_aarch64_local_symbol));
+      if (locals == NULL)
+	return FALSE;
+      elf_aarch64_locals (abfd) = locals;
+    }
+  return TRUE;
+}
+
+/* Create the .got section to hold the global offset table.  */
+
+static bfd_boolean
+aarch64_elf_create_got_section (bfd *abfd, struct bfd_link_info *info)
+{
+  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+  flagword flags;
+  asection *s;
+  struct elf_link_hash_entry *h;
+  struct elf_link_hash_table *htab = elf_hash_table (info);
+
+  /* This function may be called more than once.  */
+  s = bfd_get_linker_section (abfd, ".got");
+  if (s != NULL)
+    return TRUE;
+
+  flags = bed->dynamic_sec_flags;
+
+  s = bfd_make_section_anyway_with_flags (abfd,
+					  (bed->rela_plts_and_copies_p
+					   ? ".rela.got" : ".rel.got"),
+					  (bed->dynamic_sec_flags
+					   | SEC_READONLY));
+  if (s == NULL
+      || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
+    return FALSE;
+  htab->srelgot = s;
+
+  s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
+  if (s == NULL
+      || !bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
+    return FALSE;
+  htab->sgot = s;
+  htab->sgot->size += GOT_ENTRY_SIZE;
+
+  if (bed->want_got_sym)
+    {
+      /* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the .got
+	 (or .got.plt) section.  We don't do this in the linker script
+	 because we don't want to define the symbol if we are not creating
+	 a global offset table.  */
+      h = _bfd_elf_define_linkage_sym (abfd, info, s,
+				       "_GLOBAL_OFFSET_TABLE_");
+      elf_hash_table (info)->hgot = h;
+      if (h == NULL)
+	return FALSE;
+    }
+
+  if (bed->want_got_plt)
+    {
+      s = bfd_make_section_anyway_with_flags (abfd, ".got.plt", flags);
+      if (s == NULL
+	  || !bfd_set_section_alignment (abfd, s,
+					 bed->s->log_file_align))
+	return FALSE;
+      htab->sgotplt = s;
+    }
+
+  /* The first bit of the global offset table is the header.  */
+  s->size += bed->got_header_size;
+
+  return TRUE;
+}
+
+/* Look through the relocs for a section during the first phase.  */
+
+static bfd_boolean
+elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
+			    asection *sec, const Elf_Internal_Rela *relocs)
+{
+  Elf_Internal_Shdr *symtab_hdr;
+  struct elf_link_hash_entry **sym_hashes;
+  const Elf_Internal_Rela *rel;
+  const Elf_Internal_Rela *rel_end;
+  asection *sreloc;
+
+  struct elf_aarch64_link_hash_table *htab;
+
+  if (info->relocatable)
+    return TRUE;
+
+  BFD_ASSERT (is_aarch64_elf (abfd));
+
+  htab = elf_aarch64_hash_table (info);
+  sreloc = NULL;
+
+  symtab_hdr = &elf_symtab_hdr (abfd);
+  sym_hashes = elf_sym_hashes (abfd);
+
+  rel_end = relocs + sec->reloc_count;
+  for (rel = relocs; rel < rel_end; rel++)
+    {
+      struct elf_link_hash_entry *h;
+      unsigned long r_symndx;
+      unsigned int r_type;
+      bfd_reloc_code_real_type bfd_r_type;
+      Elf_Internal_Sym *isym;
+
+      r_symndx = ELFNN_R_SYM (rel->r_info);
+      r_type = ELFNN_R_TYPE (rel->r_info);
+
+      if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr))
+	{
+	  (*_bfd_error_handler) (_("%B: bad symbol index: %d"), abfd,
+				 r_symndx);
+	  return FALSE;
+	}
+
+      if (r_symndx < symtab_hdr->sh_info)
+	{
+	  /* A local symbol.  */
+	  isym = bfd_sym_from_r_symndx (&htab->sym_cache,
+					abfd, r_symndx);
+	  if (isym == NULL)
+	    return FALSE;
+
+	  /* Check relocation against local STT_GNU_IFUNC symbol.  */
+	  if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC)
+	    {
+	      h = elfNN_aarch64_get_local_sym_hash (htab, abfd, rel,
+						    TRUE);
+	      if (h == NULL)
+		return FALSE;
+
+	      /* Fake a STT_GNU_IFUNC symbol.  */
+	      h->type = STT_GNU_IFUNC;
+	      h->def_regular = 1;
+	      h->ref_regular = 1;
+	      h->forced_local = 1;
+	      h->root.type = bfd_link_hash_defined;
+	    }
+	  else
+	    h = NULL;
+	}
+      else
+	{
+	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
+	}
+
+      /* Could be done earlier, if h were already available.  */
+      bfd_r_type = aarch64_tls_transition (abfd, info, r_type, h, r_symndx);
+
+      if (h != NULL)
+	{
+	  /* Create the ifunc sections for static executables.  If we
+	     never see an indirect function symbol nor we are building
+	     a static executable, those sections will be empty and
+	     won't appear in output.  */
+	  switch (bfd_r_type)
+	    {
+	    default:
+	      break;
+
+	    case BFD_RELOC_AARCH64_NN:
+	    case BFD_RELOC_AARCH64_CALL26:
+	    case BFD_RELOC_AARCH64_JUMP26:
+	    case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC:
+	    case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
+	    case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
+	    case BFD_RELOC_AARCH64_GOT_LD_PREL19:
+	    case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
+	    case BFD_RELOC_AARCH64_ADD_LO12:
+	      if (htab->root.dynobj == NULL)
+		htab->root.dynobj = abfd;
+	      if (!_bfd_elf_create_ifunc_sections (htab->root.dynobj, info))
+		return FALSE;
+	      break;
+	    }
+
+	  /* It is referenced by a non-shared object. */
+	  h->ref_regular = 1;
+	  h->root.non_ir_ref = 1;
+	}
+
+      switch (bfd_r_type)
+	{
+	case BFD_RELOC_AARCH64_NN:
+
+	  /* We don't need to handle relocs into sections not going into
+	     the "real" output.  */
+	  if ((sec->flags & SEC_ALLOC) == 0)
+	    break;
+
+	  if (h != NULL)
+	    {
+	      if (!info->shared)
+		h->non_got_ref = 1;
+
+	      h->plt.refcount += 1;
+	      h->pointer_equality_needed = 1;
+	    }
+
+	  /* No need to do anything if we're not creating a shared
+	     object.  */
+	  if (! info->shared)
+	    break;
+
+	  {
+	    struct elf_dyn_relocs *p;
+	    struct elf_dyn_relocs **head;
+
+	    /* We must copy these reloc types into the output file.
+	       Create a reloc section in dynobj and make room for
+	       this reloc.  */
+	    if (sreloc == NULL)
+	      {
+		if (htab->root.dynobj == NULL)
+		  htab->root.dynobj = abfd;
+
+		sreloc = _bfd_elf_make_dynamic_reloc_section
+		  (sec, htab->root.dynobj, LOG_FILE_ALIGN, abfd, /*rela? */ TRUE);
+
+		if (sreloc == NULL)
+		  return FALSE;
+	      }
+
+	    /* If this is a global symbol, we count the number of
+	       relocations we need for this symbol.  */
+	    if (h != NULL)
+	      {
+		struct elf_aarch64_link_hash_entry *eh;
+		eh = (struct elf_aarch64_link_hash_entry *) h;
+		head = &eh->dyn_relocs;
+	      }
+	    else
+	      {
+		/* Track dynamic relocs needed for local syms too.
+		   We really need local syms available to do this
+		   easily.  Oh well.  */
+
+		asection *s;
+		void **vpp;
+
+		isym = bfd_sym_from_r_symndx (&htab->sym_cache,
+					      abfd, r_symndx);
+		if (isym == NULL)
+		  return FALSE;
+
+		s = bfd_section_from_elf_index (abfd, isym->st_shndx);
+		if (s == NULL)
+		  s = sec;
+
+		/* Beware of type punned pointers vs strict aliasing
+		   rules.  */
+		vpp = &(elf_section_data (s)->local_dynrel);
+		head = (struct elf_dyn_relocs **) vpp;
+	      }
+
+	    p = *head;
+	    if (p == NULL || p->sec != sec)
+	      {
+		bfd_size_type amt = sizeof *p;
+		p = ((struct elf_dyn_relocs *)
+		     bfd_zalloc (htab->root.dynobj, amt));
+		if (p == NULL)
+		  return FALSE;
+		p->next = *head;
+		*head = p;
+		p->sec = sec;
+	      }
+
+	    p->count += 1;
+
+	  }
+	  break;
+
+	  /* RR: We probably want to keep a consistency check that
+	     there are no dangling GOT_PAGE relocs.  */
+	case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
+	case BFD_RELOC_AARCH64_GOT_LD_PREL19:
+	case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC:
+	case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
+	case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+	case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
+	case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC:
+	case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
+	case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
+	case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
+	case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+	case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC:
+	case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
+	case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
+	case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
+	case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
+	case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0:
+	case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
+	case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1:
+	case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
+	case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2:
+	  {
+	    unsigned got_type;
+	    unsigned old_got_type;
+
+	    got_type = aarch64_reloc_got_type (bfd_r_type);
+
+	    if (h)
+	      {
+		h->got.refcount += 1;
+		old_got_type = elf_aarch64_hash_entry (h)->got_type;
+	      }
+	    else
+	      {
+		struct elf_aarch64_local_symbol *locals;
+
+		if (!elfNN_aarch64_allocate_local_symbols
+		    (abfd, symtab_hdr->sh_info))
+		  return FALSE;
+
+		locals = elf_aarch64_locals (abfd);
+		BFD_ASSERT (r_symndx < symtab_hdr->sh_info);
+		locals[r_symndx].got_refcount += 1;
+		old_got_type = locals[r_symndx].got_type;
+	      }
+
+	    /* If a variable is accessed with both general dynamic TLS
+	       methods, two slots may be created.  */
+	    if (GOT_TLS_GD_ANY_P (old_got_type) && GOT_TLS_GD_ANY_P (got_type))
+	      got_type |= old_got_type;
+
+	    /* We will already have issued an error message if there
+	       is a TLS/non-TLS mismatch, based on the symbol type.
+	       So just combine any TLS types needed.  */
+	    if (old_got_type != GOT_UNKNOWN && old_got_type != GOT_NORMAL
+		&& got_type != GOT_NORMAL)
+	      got_type |= old_got_type;
+
+	    /* If the symbol is accessed by both IE and GD methods, we
+	       are able to relax.  Turn off the GD flag, without
+	       messing up with any other kind of TLS types that may be
+	       involved.  */
+	    if ((got_type & GOT_TLS_IE) && GOT_TLS_GD_ANY_P (got_type))
+	      got_type &= ~ (GOT_TLSDESC_GD | GOT_TLS_GD);
+
+	    if (old_got_type != got_type)
+	      {
+		if (h != NULL)
+		  elf_aarch64_hash_entry (h)->got_type = got_type;
+		else
+		  {
+		    struct elf_aarch64_local_symbol *locals;
+		    locals = elf_aarch64_locals (abfd);
+		    BFD_ASSERT (r_symndx < symtab_hdr->sh_info);
+		    locals[r_symndx].got_type = got_type;
+		  }
+	      }
+
+	    if (htab->root.dynobj == NULL)
+	      htab->root.dynobj = abfd;
+	    if (! aarch64_elf_create_got_section (htab->root.dynobj, info))
+	      return FALSE;
+	    break;
+	  }
+
+	case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
+	case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
+	case BFD_RELOC_AARCH64_ADR_LO21_PCREL:
+	  if (h != NULL && info->executable)
+	    {
+	      /* If this reloc is in a read-only section, we might
+		 need a copy reloc.  We can't check reliably at this
+		 stage whether the section is read-only, as input
+		 sections have not yet been mapped to output sections.
+		 Tentatively set the flag for now, and correct in
+		 adjust_dynamic_symbol.  */
+	      h->non_got_ref = 1;
+	      h->plt.refcount += 1;
+	      h->pointer_equality_needed = 1;
+	    }
+	  /* FIXME:: RR need to handle these in shared libraries
+	     and essentially bomb out as these being non-PIC
+	     relocations in shared libraries.  */
+	  break;
+
+	case BFD_RELOC_AARCH64_CALL26:
+	case BFD_RELOC_AARCH64_JUMP26:
+	  /* If this is a local symbol then we resolve it
+	     directly without creating a PLT entry.  */
+	  if (h == NULL)
+	    continue;
+
+	  h->needs_plt = 1;
+	  if (h->plt.refcount <= 0)
+	    h->plt.refcount = 1;
+	  else
+	    h->plt.refcount += 1;
+	  break;
+
+	default:
+	  break;
+	}
+    }
+
+  return TRUE;
+}
+
+/* Treat mapping symbols as special target symbols.  */
+
+static bfd_boolean
+elfNN_aarch64_is_target_special_symbol (bfd *abfd ATTRIBUTE_UNUSED,
+					asymbol *sym)
+{
+  return bfd_is_aarch64_special_symbol_name (sym->name,
+					     BFD_AARCH64_SPECIAL_SYM_TYPE_ANY);
+}
+
+/* This is a copy of elf_find_function () from elf.c except that
+   AArch64 mapping symbols are ignored when looking for function names.  */
+
+static bfd_boolean
+aarch64_elf_find_function (bfd *abfd ATTRIBUTE_UNUSED,
+			   asection *section,
+			   asymbol **symbols,
+			   bfd_vma offset,
+			   const char **filename_ptr,
+			   const char **functionname_ptr)
+{
+  const char *filename = NULL;
+  asymbol *func = NULL;
+  bfd_vma low_func = 0;
+  asymbol **p;
+
+  for (p = symbols; *p != NULL; p++)
+    {
+      elf_symbol_type *q;
+
+      q = (elf_symbol_type *) * p;
+
+      switch (ELF_ST_TYPE (q->internal_elf_sym.st_info))
+	{
+	default:
+	  break;
+	case STT_FILE:
+	  filename = bfd_asymbol_name (&q->symbol);
+	  break;
+	case STT_FUNC:
+	case STT_NOTYPE:
+	  /* Skip mapping symbols.  */
+	  if ((q->symbol.flags & BSF_LOCAL)
+	      && (bfd_is_aarch64_special_symbol_name
+		  (q->symbol.name, BFD_AARCH64_SPECIAL_SYM_TYPE_ANY)))
+	    continue;
+	  /* Fall through.  */
+	  if (bfd_get_section (&q->symbol) == section
+	      && q->symbol.value >= low_func && q->symbol.value <= offset)
+	    {
+	      func = (asymbol *) q;
+	      low_func = q->symbol.value;
+	    }
+	  break;
+	}
+    }
+
+  if (func == NULL)
+    return FALSE;
+
+  if (filename_ptr)
+    *filename_ptr = filename;
+  if (functionname_ptr)
+    *functionname_ptr = bfd_asymbol_name (func);
+
+  return TRUE;
+}
+
+
+/* Find the nearest line to a particular section and offset, for error
+   reporting.   This code is a duplicate of the code in elf.c, except
+   that it uses aarch64_elf_find_function.  */
+
+static bfd_boolean
+elfNN_aarch64_find_nearest_line (bfd *abfd,
+				 asection *section,
+				 asymbol **symbols,
+				 bfd_vma offset,
+				 const char **filename_ptr,
+				 const char **functionname_ptr,
+				 unsigned int *line_ptr)
+{
+  bfd_boolean found = FALSE;
+
+  /* We skip _bfd_dwarf1_find_nearest_line since no known AArch64
+     toolchain uses it.  */
+
+  if (_bfd_dwarf2_find_nearest_line (abfd, dwarf_debug_sections,
+				     section, symbols, offset,
+				     filename_ptr, functionname_ptr,
+				     line_ptr, NULL, 0,
+				     &elf_tdata (abfd)->dwarf2_find_line_info))
+    {
+      if (!*functionname_ptr)
+	aarch64_elf_find_function (abfd, section, symbols, offset,
+				   *filename_ptr ? NULL : filename_ptr,
+				   functionname_ptr);
+
+      return TRUE;
+    }
+
+  if (!_bfd_stab_section_find_nearest_line (abfd, symbols, section, offset,
+					    &found, filename_ptr,
+					    functionname_ptr, line_ptr,
+					    &elf_tdata (abfd)->line_info))
+    return FALSE;
+
+  if (found && (*functionname_ptr || *line_ptr))
+    return TRUE;
+
+  if (symbols == NULL)
+    return FALSE;
+
+  if (!aarch64_elf_find_function (abfd, section, symbols, offset,
+				  filename_ptr, functionname_ptr))
+    return FALSE;
+
+  *line_ptr = 0;
+  return TRUE;
+}
+
+static bfd_boolean
+elfNN_aarch64_find_inliner_info (bfd *abfd,
+				 const char **filename_ptr,
+				 const char **functionname_ptr,
+				 unsigned int *line_ptr)
+{
+  bfd_boolean found;
+  found = _bfd_dwarf2_find_inliner_info
+    (abfd, filename_ptr,
+     functionname_ptr, line_ptr, &elf_tdata (abfd)->dwarf2_find_line_info);
+  return found;
+}
+
+
+static void
+elfNN_aarch64_post_process_headers (bfd *abfd,
+				    struct bfd_link_info *link_info)
+{
+  Elf_Internal_Ehdr *i_ehdrp;	/* ELF file header, internal form.  */
+
+  i_ehdrp = elf_elfheader (abfd);
+  i_ehdrp->e_ident[EI_ABIVERSION] = AARCH64_ELF_ABI_VERSION;
+
+  _bfd_elf_set_osabi (abfd, link_info);
+}
+
+static enum elf_reloc_type_class
+elfNN_aarch64_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+				const asection *rel_sec ATTRIBUTE_UNUSED,
+				const Elf_Internal_Rela *rela)
+{
+  switch ((int) ELFNN_R_TYPE (rela->r_info))
+    {
+    case AARCH64_R (RELATIVE):
+      return reloc_class_relative;
+    case AARCH64_R (JUMP_SLOT):
+      return reloc_class_plt;
+    case AARCH64_R (COPY):
+      return reloc_class_copy;
+    default:
+      return reloc_class_normal;
+    }
+}
+
+/* Handle an AArch64 specific section when reading an object file.  This is
+   called when bfd_section_from_shdr finds a section with an unknown
+   type.  */
+
+static bfd_boolean
+elfNN_aarch64_section_from_shdr (bfd *abfd,
+				 Elf_Internal_Shdr *hdr,
+				 const char *name, int shindex)
+{
+  /* There ought to be a place to keep ELF backend specific flags, but
+     at the moment there isn't one.  We just keep track of the
+     sections by their name, instead.  Fortunately, the ABI gives
+     names for all the AArch64 specific sections, so we will probably get
+     away with this.  */
+  switch (hdr->sh_type)
+    {
+    case SHT_AARCH64_ATTRIBUTES:
+      break;
+
+    default:
+      return FALSE;
+    }
+
+  if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
+    return FALSE;
+
+  return TRUE;
+}
+
+/* A structure used to record a list of sections, independently
+   of the next and prev fields in the asection structure.  */
+typedef struct section_list
+{
+  asection *sec;
+  struct section_list *next;
+  struct section_list *prev;
+}
+section_list;
+
+/* Unfortunately we need to keep a list of sections for which
+   an _aarch64_elf_section_data structure has been allocated.  This
+   is because it is possible for functions like elfNN_aarch64_write_section
+   to be called on a section which has had an elf_data_structure
+   allocated for it (and so the used_by_bfd field is valid) but
+   for which the AArch64 extended version of this structure - the
+   _aarch64_elf_section_data structure - has not been allocated.  */
+static section_list *sections_with_aarch64_elf_section_data = NULL;
+
+static void
+record_section_with_aarch64_elf_section_data (asection *sec)
+{
+  struct section_list *entry;
+
+  entry = bfd_malloc (sizeof (*entry));
+  if (entry == NULL)
+    return;
+  entry->sec = sec;
+  entry->next = sections_with_aarch64_elf_section_data;
+  entry->prev = NULL;
+  if (entry->next != NULL)
+    entry->next->prev = entry;
+  sections_with_aarch64_elf_section_data = entry;
+}
+
+static struct section_list *
+find_aarch64_elf_section_entry (asection *sec)
+{
+  struct section_list *entry;
+  static struct section_list *last_entry = NULL;
+
+  /* This is a short cut for the typical case where the sections are added
+     to the sections_with_aarch64_elf_section_data list in forward order and
+     then looked up here in backwards order.  This makes a real difference
+     to the ld-srec/sec64k.exp linker test.  */
+  entry = sections_with_aarch64_elf_section_data;
+  if (last_entry != NULL)
+    {
+      if (last_entry->sec == sec)
+	entry = last_entry;
+      else if (last_entry->next != NULL && last_entry->next->sec == sec)
+	entry = last_entry->next;
+    }
+
+  for (; entry; entry = entry->next)
+    if (entry->sec == sec)
+      break;
+
+  if (entry)
+    /* Record the entry prior to this one - it is the entry we are
+       most likely to want to locate next time.  Also this way if we
+       have been called from
+       unrecord_section_with_aarch64_elf_section_data () we will not
+       be caching a pointer that is about to be freed.  */
+    last_entry = entry->prev;
+
+  return entry;
+}
+
+static void
+unrecord_section_with_aarch64_elf_section_data (asection *sec)
+{
+  struct section_list *entry;
+
+  entry = find_aarch64_elf_section_entry (sec);
+
+  if (entry)
+    {
+      if (entry->prev != NULL)
+	entry->prev->next = entry->next;
+      if (entry->next != NULL)
+	entry->next->prev = entry->prev;
+      if (entry == sections_with_aarch64_elf_section_data)
+	sections_with_aarch64_elf_section_data = entry->next;
+      free (entry);
+    }
+}
+
+
+typedef struct
+{
+  void *finfo;
+  struct bfd_link_info *info;
+  asection *sec;
+  int sec_shndx;
+  int (*func) (void *, const char *, Elf_Internal_Sym *,
+	       asection *, struct elf_link_hash_entry *);
+} output_arch_syminfo;
+
+enum map_symbol_type
+{
+  AARCH64_MAP_INSN,
+  AARCH64_MAP_DATA
+};
+
+
+/* Output a single mapping symbol.  */
+
+static bfd_boolean
+elfNN_aarch64_output_map_sym (output_arch_syminfo *osi,
+			      enum map_symbol_type type, bfd_vma offset)
+{
+  static const char *names[2] = { "$x", "$d" };
+  Elf_Internal_Sym sym;
+
+  sym.st_value = (osi->sec->output_section->vma
+		  + osi->sec->output_offset + offset);
+  sym.st_size = 0;
+  sym.st_other = 0;
+  sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_NOTYPE);
+  sym.st_shndx = osi->sec_shndx;
+  return osi->func (osi->finfo, names[type], &sym, osi->sec, NULL) == 1;
+}
+
+
+
+/* Output mapping symbols for PLT entries associated with H.  */
+
+static bfd_boolean
+elfNN_aarch64_output_plt_map (struct elf_link_hash_entry *h, void *inf)
+{
+  output_arch_syminfo *osi = (output_arch_syminfo *) inf;
+  bfd_vma addr;
+
+  if (h->root.type == bfd_link_hash_indirect)
+    return TRUE;
+
+  if (h->root.type == bfd_link_hash_warning)
+    /* When warning symbols are created, they **replace** the "real"
+       entry in the hash table, thus we never get to see the real
+       symbol in a hash traversal.  So look at it now.  */
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+  if (h->plt.offset == (bfd_vma) - 1)
+    return TRUE;
+
+  addr = h->plt.offset;
+  if (addr == 32)
+    {
+      if (!elfNN_aarch64_output_map_sym (osi, AARCH64_MAP_INSN, addr))
+	return FALSE;
+    }
+  return TRUE;
+}
+
+
+/* Output a single local symbol for a generated stub.  */
+
+static bfd_boolean
+elfNN_aarch64_output_stub_sym (output_arch_syminfo *osi, const char *name,
+			       bfd_vma offset, bfd_vma size)
+{
+  Elf_Internal_Sym sym;
+
+  sym.st_value = (osi->sec->output_section->vma
+		  + osi->sec->output_offset + offset);
+  sym.st_size = size;
+  sym.st_other = 0;
+  sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FUNC);
+  sym.st_shndx = osi->sec_shndx;
+  return osi->func (osi->finfo, name, &sym, osi->sec, NULL) == 1;
+}
+
+static bfd_boolean
+aarch64_map_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
+{
+  struct elf_aarch64_stub_hash_entry *stub_entry;
+  asection *stub_sec;
+  bfd_vma addr;
+  char *stub_name;
+  output_arch_syminfo *osi;
+
+  /* Massage our args to the form they really have.  */
+  stub_entry = (struct elf_aarch64_stub_hash_entry *) gen_entry;
+  osi = (output_arch_syminfo *) in_arg;
+
+  stub_sec = stub_entry->stub_sec;
+
+  /* Ensure this stub is attached to the current section being
+     processed.  */
+  if (stub_sec != osi->sec)
+    return TRUE;
+
+  addr = (bfd_vma) stub_entry->stub_offset;
+
+  stub_name = stub_entry->output_name;
+
+  switch (stub_entry->stub_type)
+    {
+    case aarch64_stub_adrp_branch:
+      if (!elfNN_aarch64_output_stub_sym (osi, stub_name, addr,
+					  sizeof (aarch64_adrp_branch_stub)))
+	return FALSE;
+      if (!elfNN_aarch64_output_map_sym (osi, AARCH64_MAP_INSN, addr))
+	return FALSE;
+      break;
+    case aarch64_stub_long_branch:
+      if (!elfNN_aarch64_output_stub_sym
+	  (osi, stub_name, addr, sizeof (aarch64_long_branch_stub)))
+	return FALSE;
+      if (!elfNN_aarch64_output_map_sym (osi, AARCH64_MAP_INSN, addr))
+	return FALSE;
+      if (!elfNN_aarch64_output_map_sym (osi, AARCH64_MAP_DATA, addr + 16))
+	return FALSE;
+      break;
+    default:
+      BFD_FAIL ();
+    }
+
+  return TRUE;
+}
+
+/* Output mapping symbols for linker generated sections.  */
+
+static bfd_boolean
+elfNN_aarch64_output_arch_local_syms (bfd *output_bfd,
+				      struct bfd_link_info *info,
+				      void *finfo,
+				      int (*func) (void *, const char *,
+						   Elf_Internal_Sym *,
+						   asection *,
+						   struct elf_link_hash_entry
+						   *))
+{
+  output_arch_syminfo osi;
+  struct elf_aarch64_link_hash_table *htab;
+
+  htab = elf_aarch64_hash_table (info);
+
+  osi.finfo = finfo;
+  osi.info = info;
+  osi.func = func;
+
+  /* Long calls stubs.  */
+  if (htab->stub_bfd && htab->stub_bfd->sections)
+    {
+      asection *stub_sec;
+
+      for (stub_sec = htab->stub_bfd->sections;
+	   stub_sec != NULL; stub_sec = stub_sec->next)
+	{
+	  /* Ignore non-stub sections.  */
+	  if (!strstr (stub_sec->name, STUB_SUFFIX))
+	    continue;
+
+	  osi.sec = stub_sec;
+
+	  osi.sec_shndx = _bfd_elf_section_from_bfd_section
+	    (output_bfd, osi.sec->output_section);
+
+	  bfd_hash_traverse (&htab->stub_hash_table, aarch64_map_one_stub,
+			     &osi);
+	}
+    }
+
+  /* Finally, output mapping symbols for the PLT.  */
+  if (!htab->root.splt || htab->root.splt->size == 0)
+    return TRUE;
+
+  /* For now live without mapping symbols for the plt.  */
+  osi.sec_shndx = _bfd_elf_section_from_bfd_section
+    (output_bfd, htab->root.splt->output_section);
+  osi.sec = htab->root.splt;
+
+  elf_link_hash_traverse (&htab->root, elfNN_aarch64_output_plt_map,
+			  (void *) &osi);
+
+  return TRUE;
+
+}
+
+/* Allocate target specific section data.  */
+
+static bfd_boolean
+elfNN_aarch64_new_section_hook (bfd *abfd, asection *sec)
+{
+  if (!sec->used_by_bfd)
+    {
+      _aarch64_elf_section_data *sdata;
+      bfd_size_type amt = sizeof (*sdata);
+
+      sdata = bfd_zalloc (abfd, amt);
+      if (sdata == NULL)
+	return FALSE;
+      sec->used_by_bfd = sdata;
+    }
+
+  record_section_with_aarch64_elf_section_data (sec);
+
+  return _bfd_elf_new_section_hook (abfd, sec);
+}
+
+
+static void
+unrecord_section_via_map_over_sections (bfd *abfd ATTRIBUTE_UNUSED,
+					asection *sec,
+					void *ignore ATTRIBUTE_UNUSED)
+{
+  unrecord_section_with_aarch64_elf_section_data (sec);
+}
+
+static bfd_boolean
+elfNN_aarch64_close_and_cleanup (bfd *abfd)
+{
+  if (abfd->sections)
+    bfd_map_over_sections (abfd,
+			   unrecord_section_via_map_over_sections, NULL);
+
+  return _bfd_elf_close_and_cleanup (abfd);
+}
+
+static bfd_boolean
+elfNN_aarch64_bfd_free_cached_info (bfd *abfd)
+{
+  if (abfd->sections)
+    bfd_map_over_sections (abfd,
+			   unrecord_section_via_map_over_sections, NULL);
+
+  return _bfd_free_cached_info (abfd);
+}
+
+/* Create dynamic sections. This is different from the ARM backend in that
+   the got, plt, gotplt and their relocation sections are all created in the
+   standard part of the bfd elf backend.  */
+
+static bfd_boolean
+elfNN_aarch64_create_dynamic_sections (bfd *dynobj,
+				       struct bfd_link_info *info)
+{
+  struct elf_aarch64_link_hash_table *htab;
+
+  /* We need to create .got section.  */
+  if (!aarch64_elf_create_got_section (dynobj, info))
+    return FALSE;
+
+  if (!_bfd_elf_create_dynamic_sections (dynobj, info))
+    return FALSE;
+
+  htab = elf_aarch64_hash_table (info);
+  htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
+  if (!info->shared)
+    htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
+
+  if (!htab->sdynbss || (!info->shared && !htab->srelbss))
+    abort ();
+
+  return TRUE;
+}
+
+
+/* Allocate space in .plt, .got and associated reloc sections for
+   dynamic relocs.  */
+
+static bfd_boolean
+elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
+{
+  struct bfd_link_info *info;
+  struct elf_aarch64_link_hash_table *htab;
+  struct elf_aarch64_link_hash_entry *eh;
+  struct elf_dyn_relocs *p;
+
+  /* An example of a bfd_link_hash_indirect symbol is versioned
+     symbol. For example: __gxx_personality_v0(bfd_link_hash_indirect)
+     -> __gxx_personality_v0(bfd_link_hash_defined)
+
+     There is no need to process bfd_link_hash_indirect symbols here
+     because we will also be presented with the concrete instance of
+     the symbol and elfNN_aarch64_copy_indirect_symbol () will have been
+     called to copy all relevant data from the generic to the concrete
+     symbol instance.
+   */
+  if (h->root.type == bfd_link_hash_indirect)
+    return TRUE;
+
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+  info = (struct bfd_link_info *) inf;
+  htab = elf_aarch64_hash_table (info);
+
+  /* Since STT_GNU_IFUNC symbol must go through PLT, we handle it
+     here if it is defined and referenced in a non-shared object.  */
+  if (h->type == STT_GNU_IFUNC
+      && h->def_regular)
+    return TRUE;
+  else if (htab->root.dynamic_sections_created && h->plt.refcount > 0)
+    {
+      /* Make sure this symbol is output as a dynamic symbol.
+         Undefined weak syms won't yet be marked as dynamic.  */
+      if (h->dynindx == -1 && !h->forced_local)
+	{
+	  if (!bfd_elf_link_record_dynamic_symbol (info, h))
+	    return FALSE;
+	}
+
+      if (info->shared || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h))
+	{
+	  asection *s = htab->root.splt;
+
+	  /* If this is the first .plt entry, make room for the special
+	     first entry.  */
+	  if (s->size == 0)
+	    s->size += htab->plt_header_size;
+
+	  h->plt.offset = s->size;
+
+	  /* If this symbol is not defined in a regular file, and we are
+	     not generating a shared library, then set the symbol to this
+	     location in the .plt.  This is required to make function
+	     pointers compare as equal between the normal executable and
+	     the shared library.  */
+	  if (!info->shared && !h->def_regular)
+	    {
+	      h->root.u.def.section = s;
+	      h->root.u.def.value = h->plt.offset;
+	    }
+
+	  /* Make room for this entry. For now we only create the
+	     small model PLT entries. We later need to find a way
+	     of relaxing into these from the large model PLT entries.  */
+	  s->size += PLT_SMALL_ENTRY_SIZE;
+
+	  /* We also need to make an entry in the .got.plt section, which
+	     will be placed in the .got section by the linker script.  */
+	  htab->root.sgotplt->size += GOT_ENTRY_SIZE;
+
+	  /* We also need to make an entry in the .rela.plt section.  */
+	  htab->root.srelplt->size += RELOC_SIZE (htab);
+
+	  /* We need to ensure that all GOT entries that serve the PLT
+	     are consecutive with the special GOT slots [0] [1] and
+	     [2]. Any addtional relocations, such as
+	     R_AARCH64_TLSDESC, must be placed after the PLT related
+	     entries.  We abuse the reloc_count such that during
+	     sizing we adjust reloc_count to indicate the number of
+	     PLT related reserved entries.  In subsequent phases when
+	     filling in the contents of the reloc entries, PLT related
+	     entries are placed by computing their PLT index (0
+	     .. reloc_count). While other none PLT relocs are placed
+	     at the slot indicated by reloc_count and reloc_count is
+	     updated.  */
+
+	  htab->root.srelplt->reloc_count++;
+	}
+      else
+	{
+	  h->plt.offset = (bfd_vma) - 1;
+	  h->needs_plt = 0;
+	}
+    }
+  else
+    {
+      h->plt.offset = (bfd_vma) - 1;
+      h->needs_plt = 0;
+    }
+
+  eh = (struct elf_aarch64_link_hash_entry *) h;
+  eh->tlsdesc_got_jump_table_offset = (bfd_vma) - 1;
+
+  if (h->got.refcount > 0)
+    {
+      bfd_boolean dyn;
+      unsigned got_type = elf_aarch64_hash_entry (h)->got_type;
+
+      h->got.offset = (bfd_vma) - 1;
+
+      dyn = htab->root.dynamic_sections_created;
+
+      /* Make sure this symbol is output as a dynamic symbol.
+         Undefined weak syms won't yet be marked as dynamic.  */
+      if (dyn && h->dynindx == -1 && !h->forced_local)
+	{
+	  if (!bfd_elf_link_record_dynamic_symbol (info, h))
+	    return FALSE;
+	}
+
+      if (got_type == GOT_UNKNOWN)
+	{
+	}
+      else if (got_type == GOT_NORMAL)
+	{
+	  h->got.offset = htab->root.sgot->size;
+	  htab->root.sgot->size += GOT_ENTRY_SIZE;
+	  if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+	       || h->root.type != bfd_link_hash_undefweak)
+	      && (info->shared
+		  || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
+	    {
+	      htab->root.srelgot->size += RELOC_SIZE (htab);
+	    }
+	}
+      else
+	{
+	  int indx;
+	  if (got_type & GOT_TLSDESC_GD)
+	    {
+	      eh->tlsdesc_got_jump_table_offset =
+		(htab->root.sgotplt->size
+		 - aarch64_compute_jump_table_size (htab));
+	      htab->root.sgotplt->size += GOT_ENTRY_SIZE * 2;
+	      h->got.offset = (bfd_vma) - 2;
+	    }
+
+	  if (got_type & GOT_TLS_GD)
+	    {
+	      h->got.offset = htab->root.sgot->size;
+	      htab->root.sgot->size += GOT_ENTRY_SIZE * 2;
+	    }
+
+	  if (got_type & GOT_TLS_IE)
+	    {
+	      h->got.offset = htab->root.sgot->size;
+	      htab->root.sgot->size += GOT_ENTRY_SIZE;
+	    }
+
+	  indx = h && h->dynindx != -1 ? h->dynindx : 0;
+	  if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+	       || h->root.type != bfd_link_hash_undefweak)
+	      && (info->shared
+		  || indx != 0
+		  || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
+	    {
+	      if (got_type & GOT_TLSDESC_GD)
+		{
+		  htab->root.srelplt->size += RELOC_SIZE (htab);
+		  /* Note reloc_count not incremented here!  We have
+		     already adjusted reloc_count for this relocation
+		     type.  */
+
+		  /* TLSDESC PLT is now needed, but not yet determined.  */
+		  htab->tlsdesc_plt = (bfd_vma) - 1;
+		}
+
+	      if (got_type & GOT_TLS_GD)
+		htab->root.srelgot->size += RELOC_SIZE (htab) * 2;
+
+	      if (got_type & GOT_TLS_IE)
+		htab->root.srelgot->size += RELOC_SIZE (htab);
+	    }
+	}
+    }
+  else
+    {
+      h->got.offset = (bfd_vma) - 1;
+    }
+
+  if (eh->dyn_relocs == NULL)
+    return TRUE;
+
+  /* In the shared -Bsymbolic case, discard space allocated for
+     dynamic pc-relative relocs against symbols which turn out to be
+     defined in regular objects.  For the normal shared case, discard
+     space for pc-relative relocs that have become local due to symbol
+     visibility changes.  */
+
+  if (info->shared)
+    {
+      /* Relocs that use pc_count are those that appear on a call
+         insn, or certain REL relocs that can 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 then they
+         should avoid writing weird assembly.  */
+      if (SYMBOL_CALLS_LOCAL (info, h))
+	{
+	  struct elf_dyn_relocs **pp;
+
+	  for (pp = &eh->dyn_relocs; (p = *pp) != NULL;)
+	    {
+	      p->count -= p->pc_count;
+	      p->pc_count = 0;
+	      if (p->count == 0)
+		*pp = p->next;
+	      else
+		pp = &p->next;
+	    }
+	}
+
+      /* Also discard relocs on undefined weak syms with non-default
+         visibility.  */
+      if (eh->dyn_relocs != NULL && h->root.type == bfd_link_hash_undefweak)
+	{
+	  if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
+	    eh->dyn_relocs = NULL;
+
+	  /* Make sure undefined weak symbols are output as a dynamic
+	     symbol in PIEs.  */
+	  else if (h->dynindx == -1
+		   && !h->forced_local
+		   && !bfd_elf_link_record_dynamic_symbol (info, h))
+	    return FALSE;
+	}
+
+    }
+  else if (ELIMINATE_COPY_RELOCS)
+    {
+      /* For the non-shared case, discard space for relocs against
+         symbols which turn out to need copy relocs or are not
+         dynamic.  */
+
+      if (!h->non_got_ref
+	  && ((h->def_dynamic
+	       && !h->def_regular)
+	      || (htab->root.dynamic_sections_created
+		  && (h->root.type == bfd_link_hash_undefweak
+		      || h->root.type == bfd_link_hash_undefined))))
+	{
+	  /* Make sure this symbol is output as a dynamic symbol.
+	     Undefined weak syms won't yet be marked as dynamic.  */
+	  if (h->dynindx == -1
+	      && !h->forced_local
+	      && !bfd_elf_link_record_dynamic_symbol (info, h))
+	    return FALSE;
+
+	  /* If that succeeded, we know we'll be keeping all the
+	     relocs.  */
+	  if (h->dynindx != -1)
+	    goto keep;
+	}
+
+      eh->dyn_relocs = NULL;
+
+    keep:;
+    }
+
+  /* Finally, allocate space.  */
+  for (p = eh->dyn_relocs; p != NULL; p = p->next)
+    {
+      asection *sreloc;
+
+      sreloc = elf_section_data (p->sec)->sreloc;
+
+      BFD_ASSERT (sreloc != NULL);
+
+      sreloc->size += p->count * RELOC_SIZE (htab);
+    }
+
+  return TRUE;
+}
+
+/* Allocate space in .plt, .got and associated reloc sections for
+   ifunc dynamic relocs.  */
+
+static bfd_boolean
+elfNN_aarch64_allocate_ifunc_dynrelocs (struct elf_link_hash_entry *h,
+					void *inf)
+{
+  struct bfd_link_info *info;
+  struct elf_aarch64_link_hash_table *htab;
+  struct elf_aarch64_link_hash_entry *eh;
+
+  /* An example of a bfd_link_hash_indirect symbol is versioned
+     symbol. For example: __gxx_personality_v0(bfd_link_hash_indirect)
+     -> __gxx_personality_v0(bfd_link_hash_defined)
+
+     There is no need to process bfd_link_hash_indirect symbols here
+     because we will also be presented with the concrete instance of
+     the symbol and elfNN_aarch64_copy_indirect_symbol () will have been
+     called to copy all relevant data from the generic to the concrete
+     symbol instance.
+   */
+  if (h->root.type == bfd_link_hash_indirect)
+    return TRUE;
+
+  if (h->root.type == bfd_link_hash_warning)
+    h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+  info = (struct bfd_link_info *) inf;
+  htab = elf_aarch64_hash_table (info);
+
+  eh = (struct elf_aarch64_link_hash_entry *) h;
+
+  /* Since STT_GNU_IFUNC symbol must go through PLT, we handle it
+     here if it is defined and referenced in a non-shared object.  */
+  if (h->type == STT_GNU_IFUNC
+      && h->def_regular)
+    return _bfd_elf_allocate_ifunc_dyn_relocs (info, h,
+					       &eh->dyn_relocs,
+					       htab->plt_entry_size,
+					       htab->plt_header_size,
+					       GOT_ENTRY_SIZE);
+  return TRUE;
+}
+
+/* Allocate space in .plt, .got and associated reloc sections for
+   local dynamic relocs.  */
+
+static bfd_boolean
+elfNN_aarch64_allocate_local_dynrelocs (void **slot, void *inf)
+{
+  struct elf_link_hash_entry *h
+    = (struct elf_link_hash_entry *) *slot;
+
+  if (h->type != STT_GNU_IFUNC
+      || !h->def_regular
+      || !h->ref_regular
+      || !h->forced_local
+      || h->root.type != bfd_link_hash_defined)
+    abort ();
+
+  return elfNN_aarch64_allocate_dynrelocs (h, inf);
+}
+
+/* Allocate space in .plt, .got and associated reloc sections for
+   local ifunc dynamic relocs.  */
+
+static bfd_boolean
+elfNN_aarch64_allocate_local_ifunc_dynrelocs (void **slot, void *inf)
+{
+  struct elf_link_hash_entry *h
+    = (struct elf_link_hash_entry *) *slot;
+
+  if (h->type != STT_GNU_IFUNC
+      || !h->def_regular
+      || !h->ref_regular
+      || !h->forced_local
+      || h->root.type != bfd_link_hash_defined)
+    abort ();
+
+  return elfNN_aarch64_allocate_ifunc_dynrelocs (h, inf);
+}
+
+/* This is the most important function of all . Innocuosly named
+   though !  */
+static bfd_boolean
+elfNN_aarch64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
+				     struct bfd_link_info *info)
+{
+  struct elf_aarch64_link_hash_table *htab;
+  bfd *dynobj;
+  asection *s;
+  bfd_boolean relocs;
+  bfd *ibfd;
+
+  htab = elf_aarch64_hash_table ((info));
+  dynobj = htab->root.dynobj;
+
+  BFD_ASSERT (dynobj != NULL);
+
+  if (htab->root.dynamic_sections_created)
+    {
+      if (info->executable)
+	{
+	  s = bfd_get_linker_section (dynobj, ".interp");
+	  if (s == NULL)
+	    abort ();
+	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
+	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
+	}
+    }
+
+  /* Set up .got offsets for local syms, and space for local dynamic
+     relocs.  */
+  for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next)
+    {
+      struct elf_aarch64_local_symbol *locals = NULL;
+      Elf_Internal_Shdr *symtab_hdr;
+      asection *srel;
+      unsigned int i;
+
+      if (!is_aarch64_elf (ibfd))
+	continue;
+
+      for (s = ibfd->sections; s != NULL; s = s->next)
+	{
+	  struct elf_dyn_relocs *p;
+
+	  for (p = (struct elf_dyn_relocs *)
+	       (elf_section_data (s)->local_dynrel); p != NULL; p = p->next)
+	    {
+	      if (!bfd_is_abs_section (p->sec)
+		  && bfd_is_abs_section (p->sec->output_section))
+		{
+		  /* Input section has been discarded, either because
+		     it is a copy of a linkonce section or due to
+		     linker script /DISCARD/, so we'll be discarding
+		     the relocs too.  */
+		}
+	      else if (p->count != 0)
+		{
+		  srel = elf_section_data (p->sec)->sreloc;
+		  srel->size += p->count * RELOC_SIZE (htab);
+		  if ((p->sec->output_section->flags & SEC_READONLY) != 0)
+		    info->flags |= DF_TEXTREL;
+		}
+	    }
+	}
+
+      locals = elf_aarch64_locals (ibfd);
+      if (!locals)
+	continue;
+
+      symtab_hdr = &elf_symtab_hdr (ibfd);
+      srel = htab->root.srelgot;
+      for (i = 0; i < symtab_hdr->sh_info; i++)
+	{
+	  locals[i].got_offset = (bfd_vma) - 1;
+	  locals[i].tlsdesc_got_jump_table_offset = (bfd_vma) - 1;
+	  if (locals[i].got_refcount > 0)
+	    {
+	      unsigned got_type = locals[i].got_type;
+	      if (got_type & GOT_TLSDESC_GD)
+		{
+		  locals[i].tlsdesc_got_jump_table_offset =
+		    (htab->root.sgotplt->size
+		     - aarch64_compute_jump_table_size (htab));
+		  htab->root.sgotplt->size += GOT_ENTRY_SIZE * 2;
+		  locals[i].got_offset = (bfd_vma) - 2;
+		}
+
+	      if (got_type & GOT_TLS_GD)
+		{
+		  locals[i].got_offset = htab->root.sgot->size;
+		  htab->root.sgot->size += GOT_ENTRY_SIZE * 2;
+		}
+
+	      if (got_type & GOT_TLS_IE)
+		{
+		  locals[i].got_offset = htab->root.sgot->size;
+		  htab->root.sgot->size += GOT_ENTRY_SIZE;
+		}
+
+	      if (got_type == GOT_UNKNOWN)
+		{
+		}
+
+	      if (got_type == GOT_NORMAL)
+		{
+		}
+
+	      if (info->shared)
+		{
+		  if (got_type & GOT_TLSDESC_GD)
+		    {
+		      htab->root.srelplt->size += RELOC_SIZE (htab);
+		      /* Note RELOC_COUNT not incremented here! */
+		      htab->tlsdesc_plt = (bfd_vma) - 1;
+		    }
+
+		  if (got_type & GOT_TLS_GD)
+		    htab->root.srelgot->size += RELOC_SIZE (htab) * 2;
+
+		  if (got_type & GOT_TLS_IE)
+		    htab->root.srelgot->size += RELOC_SIZE (htab);
+		}
+	    }
+	  else
+	    {
+	      locals[i].got_refcount = (bfd_vma) - 1;
+	    }
+	}
+    }
+
+
+  /* Allocate global sym .plt and .got entries, and space for global
+     sym dynamic relocs.  */
+  elf_link_hash_traverse (&htab->root, elfNN_aarch64_allocate_dynrelocs,
+			  info);
+
+  /* Allocate global ifunc sym .plt and .got entries, and space for global
+     ifunc sym dynamic relocs.  */
+  elf_link_hash_traverse (&htab->root, elfNN_aarch64_allocate_ifunc_dynrelocs,
+			  info);
+
+  /* Allocate .plt and .got entries, and space for local symbols.  */
+  htab_traverse (htab->loc_hash_table,
+		 elfNN_aarch64_allocate_local_dynrelocs,
+		 info);
+
+  /* Allocate .plt and .got entries, and space for local ifunc symbols.  */
+  htab_traverse (htab->loc_hash_table,
+		 elfNN_aarch64_allocate_local_ifunc_dynrelocs,
+		 info);
+
+  /* For every jump slot reserved in the sgotplt, reloc_count is
+     incremented.  However, when we reserve space for TLS descriptors,
+     it's not incremented, so in order to compute the space reserved
+     for them, it suffices to multiply the reloc count by the jump
+     slot size.  */
+
+  if (htab->root.srelplt)
+    htab->sgotplt_jump_table_size = aarch64_compute_jump_table_size (htab);
+
+  if (htab->tlsdesc_plt)
+    {
+      if (htab->root.splt->size == 0)
+	htab->root.splt->size += PLT_ENTRY_SIZE;
+
+      htab->tlsdesc_plt = htab->root.splt->size;
+      htab->root.splt->size += PLT_TLSDESC_ENTRY_SIZE;
+
+      /* If we're not using lazy TLS relocations, don't generate the
+         GOT entry required.  */
+      if (!(info->flags & DF_BIND_NOW))
+	{
+	  htab->dt_tlsdesc_got = htab->root.sgot->size;
+	  htab->root.sgot->size += GOT_ENTRY_SIZE;
+	}
+    }
+
+  /* We now have determined the sizes of the various dynamic sections.
+     Allocate memory for them.  */
+  relocs = FALSE;
+  for (s = dynobj->sections; s != NULL; s = s->next)
+    {
+      if ((s->flags & SEC_LINKER_CREATED) == 0)
+	continue;
+
+      if (s == htab->root.splt
+	  || s == htab->root.sgot
+	  || s == htab->root.sgotplt
+	  || s == htab->root.iplt
+	  || s == htab->root.igotplt || s == htab->sdynbss)
+	{
+	  /* Strip this section if we don't need it; see the
+	     comment below.  */
+	}
+      else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela"))
+	{
+	  if (s->size != 0 && s != htab->root.srelplt)
+	    relocs = TRUE;
+
+	  /* We use the reloc_count field as a counter if we need
+	     to copy relocs into the output file.  */
+	  if (s != htab->root.srelplt)
+	    s->reloc_count = 0;
+	}
+      else
+	{
+	  /* It's not one of our sections, so don't allocate space.  */
+	  continue;
+	}
+
+      if (s->size == 0)
+	{
+	  /* If we don't need this section, strip it from the
+	     output file.  This is mostly to handle .rela.bss and
+	     .rela.plt.  We must create both sections in
+	     create_dynamic_sections, because they must be created
+	     before the linker maps input sections to output
+	     sections.  The linker does that before
+	     adjust_dynamic_symbol is called, and it is that
+	     function which decides whether anything needs to go
+	     into these sections.  */
+
+	  s->flags |= SEC_EXCLUDE;
+	  continue;
+	}
+
+      if ((s->flags & SEC_HAS_CONTENTS) == 0)
+	continue;
+
+      /* Allocate memory for the section contents.  We use bfd_zalloc
+         here in case unused entries are not reclaimed before the
+         section's contents are written out.  This should not happen,
+         but this way if it does, we get a R_AARCH64_NONE reloc instead
+         of garbage.  */
+      s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
+      if (s->contents == NULL)
+	return FALSE;
+    }
+
+  if (htab->root.dynamic_sections_created)
+    {
+      /* Add some entries to the .dynamic section.  We fill in the
+         values later, in elfNN_aarch64_finish_dynamic_sections, but we
+         must add the entries now so that we get the correct size for
+         the .dynamic section.  The DT_DEBUG entry is filled in by the
+         dynamic linker and used by the debugger.  */
+#define add_dynamic_entry(TAG, VAL)			\
+      _bfd_elf_add_dynamic_entry (info, TAG, VAL)
+
+      if (info->executable)
+	{
+	  if (!add_dynamic_entry (DT_DEBUG, 0))
+	    return FALSE;
+	}
+
+      if (htab->root.splt->size != 0)
+	{
+	  if (!add_dynamic_entry (DT_PLTGOT, 0)
+	      || !add_dynamic_entry (DT_PLTRELSZ, 0)
+	      || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+	      || !add_dynamic_entry (DT_JMPREL, 0))
+	    return FALSE;
+
+	  if (htab->tlsdesc_plt
+	      && (!add_dynamic_entry (DT_TLSDESC_PLT, 0)
+		  || !add_dynamic_entry (DT_TLSDESC_GOT, 0)))
+	    return FALSE;
+	}
+
+      if (relocs)
+	{
+	  if (!add_dynamic_entry (DT_RELA, 0)
+	      || !add_dynamic_entry (DT_RELASZ, 0)
+	      || !add_dynamic_entry (DT_RELAENT, RELOC_SIZE (htab)))
+	    return FALSE;
+
+	  /* If any dynamic relocs apply to a read-only section,
+	     then we need a DT_TEXTREL entry.  */
+	  if ((info->flags & DF_TEXTREL) != 0)
+	    {
+	      if (!add_dynamic_entry (DT_TEXTREL, 0))
+		return FALSE;
+	    }
+	}
+    }
+#undef add_dynamic_entry
+
+  return TRUE;
+}
+
+static inline void
+elf_aarch64_update_plt_entry (bfd *output_bfd,
+			      bfd_reloc_code_real_type r_type,
+			      bfd_byte *plt_entry, bfd_vma value)
+{
+  reloc_howto_type *howto = elfNN_aarch64_howto_from_bfd_reloc (r_type);
+
+  _bfd_aarch64_elf_put_addend (output_bfd, plt_entry, r_type, howto, value);
+}
+
+static void
+elfNN_aarch64_create_small_pltn_entry (struct elf_link_hash_entry *h,
+				       struct elf_aarch64_link_hash_table
+				       *htab, bfd *output_bfd,
+				       struct bfd_link_info *info)
+{
+  bfd_byte *plt_entry;
+  bfd_vma plt_index;
+  bfd_vma got_offset;
+  bfd_vma gotplt_entry_address;
+  bfd_vma plt_entry_address;
+  Elf_Internal_Rela rela;
+  bfd_byte *loc;
+  asection *plt, *gotplt, *relplt;
+
+  /* When building a static executable, use .iplt, .igot.plt and
+     .rela.iplt sections for STT_GNU_IFUNC symbols.  */
+  if (htab->root.splt != NULL)
+    {
+      plt = htab->root.splt;
+      gotplt = htab->root.sgotplt;
+      relplt = htab->root.srelplt;
+    }
+  else
+    {
+      plt = htab->root.iplt;
+      gotplt = htab->root.igotplt;
+      relplt = htab->root.irelplt;
+    }
+
+  /* Get the index in the procedure linkage table which
+     corresponds to this symbol.  This is the index of this symbol
+     in all the symbols for which we are making plt entries.  The
+     first entry in the procedure linkage table is reserved.
+
+     Get the offset into the .got table of the entry that
+     corresponds to this function.	Each .got entry is GOT_ENTRY_SIZE
+     bytes. The first three are reserved for the dynamic linker.
+
+     For static executables, we don't reserve anything.  */
+
+  if (plt == htab->root.splt)
+    {
+      plt_index = (h->plt.offset - htab->plt_header_size) / htab->plt_entry_size;
+      got_offset = (plt_index + 3) * GOT_ENTRY_SIZE;
+    }
+  else
+    {
+      plt_index = h->plt.offset / htab->plt_entry_size;
+      got_offset = plt_index * GOT_ENTRY_SIZE;
+    }
+
+  plt_entry = plt->contents + h->plt.offset;
+  plt_entry_address = plt->output_section->vma
+    + plt->output_offset + h->plt.offset;
+  gotplt_entry_address = gotplt->output_section->vma +
+    gotplt->output_offset + got_offset;
+
+  /* Copy in the boiler-plate for the PLTn entry.  */
+  memcpy (plt_entry, elfNN_aarch64_small_plt_entry, PLT_SMALL_ENTRY_SIZE);
+
+  /* Fill in the top 21 bits for this: ADRP x16, PLT_GOT + n * 8.
+     ADRP:   ((PG(S+A)-PG(P)) >> 12) & 0x1fffff */
+  elf_aarch64_update_plt_entry (output_bfd, BFD_RELOC_AARCH64_ADR_HI21_PCREL,
+				plt_entry,
+				PG (gotplt_entry_address) -
+				PG (plt_entry_address));
+
+  /* Fill in the lo12 bits for the load from the pltgot.  */
+  elf_aarch64_update_plt_entry (output_bfd, BFD_RELOC_AARCH64_LDSTNN_LO12,
+				plt_entry + 4,
+				PG_OFFSET (gotplt_entry_address));
+
+  /* Fill in the lo12 bits for the add from the pltgot entry.  */
+  elf_aarch64_update_plt_entry (output_bfd, BFD_RELOC_AARCH64_ADD_LO12,
+				plt_entry + 8,
+				PG_OFFSET (gotplt_entry_address));
+
+  /* All the GOTPLT Entries are essentially initialized to PLT0.  */
+  bfd_put_NN (output_bfd,
+	      plt->output_section->vma + plt->output_offset,
+	      gotplt->contents + got_offset);
+
+  rela.r_offset = gotplt_entry_address;
+
+  if (h->dynindx == -1
+      || ((info->executable
+	   || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
+	  && h->def_regular
+	  && h->type == STT_GNU_IFUNC))
+    {
+      /* If an STT_GNU_IFUNC symbol is locally defined, generate
+	 R_AARCH64_IRELATIVE instead of R_AARCH64_JUMP_SLOT.  */
+      rela.r_info = ELFNN_R_INFO (0, AARCH64_R (IRELATIVE));
+      rela.r_addend = (h->root.u.def.value
+		       + h->root.u.def.section->output_section->vma
+		       + h->root.u.def.section->output_offset);
+    }
+  else
+    {
+      /* Fill in the entry in the .rela.plt section.  */
+      rela.r_info = ELFNN_R_INFO (h->dynindx, AARCH64_R (JUMP_SLOT));
+      rela.r_addend = 0;
+    }
+
+  /* Compute the relocation entry to used based on PLT index and do
+     not adjust reloc_count. The reloc_count has already been adjusted
+     to account for this entry.  */
+  loc = relplt->contents + plt_index * RELOC_SIZE (htab);
+  bfd_elfNN_swap_reloca_out (output_bfd, &rela, loc);
+}
+
+/* Size sections even though they're not dynamic.  We use it to setup
+   _TLS_MODULE_BASE_, if needed.  */
+
+static bfd_boolean
+elfNN_aarch64_always_size_sections (bfd *output_bfd,
+				    struct bfd_link_info *info)
+{
+  asection *tls_sec;
+
+  if (info->relocatable)
+    return TRUE;
+
+  tls_sec = elf_hash_table (info)->tls_sec;
+
+  if (tls_sec)
+    {
+      struct elf_link_hash_entry *tlsbase;
+
+      tlsbase = elf_link_hash_lookup (elf_hash_table (info),
+				      "_TLS_MODULE_BASE_", TRUE, TRUE, FALSE);
+
+      if (tlsbase)
+	{
+	  struct bfd_link_hash_entry *h = NULL;
+	  const struct elf_backend_data *bed =
+	    get_elf_backend_data (output_bfd);
+
+	  if (!(_bfd_generic_link_add_one_symbol
+		(info, output_bfd, "_TLS_MODULE_BASE_", BSF_LOCAL,
+		 tls_sec, 0, NULL, FALSE, bed->collect, &h)))
+	    return FALSE;
+
+	  tlsbase->type = STT_TLS;
+	  tlsbase = (struct elf_link_hash_entry *) h;
+	  tlsbase->def_regular = 1;
+	  tlsbase->other = STV_HIDDEN;
+	  (*bed->elf_backend_hide_symbol) (info, tlsbase, TRUE);
+	}
+    }
+
+  return TRUE;
+}
+
+/* Finish up dynamic symbol handling.  We set the contents of various
+   dynamic sections here.  */
+static bfd_boolean
+elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd,
+				     struct bfd_link_info *info,
+				     struct elf_link_hash_entry *h,
+				     Elf_Internal_Sym *sym)
+{
+  struct elf_aarch64_link_hash_table *htab;
+  htab = elf_aarch64_hash_table (info);
+
+  if (h->plt.offset != (bfd_vma) - 1)
+    {
+      asection *plt, *gotplt, *relplt;
+
+      /* This symbol has an entry in the procedure linkage table.  Set
+         it up.  */
+
+      /* When building a static executable, use .iplt, .igot.plt and
+	 .rela.iplt sections for STT_GNU_IFUNC symbols.  */
+      if (htab->root.splt != NULL)
+	{
+	  plt = htab->root.splt;
+	  gotplt = htab->root.sgotplt;
+	  relplt = htab->root.srelplt;
+	}
+      else
+	{
+	  plt = htab->root.iplt;
+	  gotplt = htab->root.igotplt;
+	  relplt = htab->root.irelplt;
+	}
+
+      /* This symbol has an entry in the procedure linkage table.  Set
+	 it up.	 */
+      if ((h->dynindx == -1
+	   && !((h->forced_local || info->executable)
+		&& h->def_regular
+		&& h->type == STT_GNU_IFUNC))
+	  || plt == NULL
+	  || gotplt == NULL
+	  || relplt == NULL)
+	abort ();
+
+      elfNN_aarch64_create_small_pltn_entry (h, htab, output_bfd, info);
+      if (!h->def_regular)
+	{
+	  /* Mark the symbol as undefined, rather than as defined in
+	     the .plt section.  Leave the value alone.  This is a clue
+	     for the dynamic linker, to make function pointer
+	     comparisons work between an application and shared
+	     library.  */
+	  sym->st_shndx = SHN_UNDEF;
+	}
+    }
+
+  if (h->got.offset != (bfd_vma) - 1
+      && elf_aarch64_hash_entry (h)->got_type == GOT_NORMAL)
+    {
+      Elf_Internal_Rela rela;
+      bfd_byte *loc;
+
+      /* This symbol has an entry in the global offset table.  Set it
+         up.  */
+      if (htab->root.sgot == NULL || htab->root.srelgot == NULL)
+	abort ();
+
+      rela.r_offset = (htab->root.sgot->output_section->vma
+		       + htab->root.sgot->output_offset
+		       + (h->got.offset & ~(bfd_vma) 1));
+
+      if (h->def_regular
+          && h->type == STT_GNU_IFUNC)
+        {
+          if (info->shared)
+            {
+              /* Generate R_AARCH64_GLOB_DAT.  */
+              goto do_glob_dat;
+            }
+          else
+            {
+              asection *plt;
+
+              if (!h->pointer_equality_needed)
+                abort ();
+
+              /* For non-shared object, we can't use .got.plt, which
+                 contains the real function address if we need pointer
+                 equality.  We load the GOT entry with the PLT entry.  */
+              plt = htab->root.splt ? htab->root.splt : htab->root.iplt;
+              bfd_put_NN (output_bfd, (plt->output_section->vma
+                                       + plt->output_offset
+                                       + h->plt.offset),
+                          htab->root.sgot->contents
+                          + (h->got.offset & ~(bfd_vma) 1));
+              return TRUE;
+            }
+        }
+      else if (info->shared && SYMBOL_REFERENCES_LOCAL (info, h))
+	{
+	  if (!h->def_regular)
+	    return FALSE;
+
+	  BFD_ASSERT ((h->got.offset & 1) != 0);
+	  rela.r_info = ELFNN_R_INFO (0, AARCH64_R (RELATIVE));
+	  rela.r_addend = (h->root.u.def.value
+			   + h->root.u.def.section->output_section->vma
+			   + h->root.u.def.section->output_offset);
+	}
+      else
+	{
+do_glob_dat:
+	  BFD_ASSERT ((h->got.offset & 1) == 0);
+	  bfd_put_NN (output_bfd, (bfd_vma) 0,
+		      htab->root.sgot->contents + h->got.offset);
+	  rela.r_info = ELFNN_R_INFO (h->dynindx, AARCH64_R (GLOB_DAT));
+	  rela.r_addend = 0;
+	}
+
+      loc = htab->root.srelgot->contents;
+      loc += htab->root.srelgot->reloc_count++ * RELOC_SIZE (htab);
+      bfd_elfNN_swap_reloca_out (output_bfd, &rela, loc);
+    }
+
+  if (h->needs_copy)
+    {
+      Elf_Internal_Rela rela;
+      bfd_byte *loc;
+
+      /* This symbol needs a copy reloc.  Set it up.  */
+
+      if (h->dynindx == -1
+	  || (h->root.type != bfd_link_hash_defined
+	      && h->root.type != bfd_link_hash_defweak)
+	  || htab->srelbss == NULL)
+	abort ();
+
+      rela.r_offset = (h->root.u.def.value
+		       + h->root.u.def.section->output_section->vma
+		       + h->root.u.def.section->output_offset);
+      rela.r_info = ELFNN_R_INFO (h->dynindx, AARCH64_R (COPY));
+      rela.r_addend = 0;
+      loc = htab->srelbss->contents;
+      loc += htab->srelbss->reloc_count++ * RELOC_SIZE (htab);
+      bfd_elfNN_swap_reloca_out (output_bfd, &rela, loc);
+    }
+
+  /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  SYM may
+     be NULL for local symbols.  */
+  if (sym != NULL
+      && (h == elf_hash_table (info)->hdynamic
+	  || h == elf_hash_table (info)->hgot))
+    sym->st_shndx = SHN_ABS;
+
+  return TRUE;
+}
+
+/* Finish up local dynamic symbol handling.  We set the contents of
+   various dynamic sections here.  */
+
+static bfd_boolean
+elfNN_aarch64_finish_local_dynamic_symbol (void **slot, void *inf)
+{
+  struct elf_link_hash_entry *h
+    = (struct elf_link_hash_entry *) *slot;
+  struct bfd_link_info *info
+    = (struct bfd_link_info *) inf;
+
+  return elfNN_aarch64_finish_dynamic_symbol (info->output_bfd,
+					      info, h, NULL);
+}
+
+static void
+elfNN_aarch64_init_small_plt0_entry (bfd *output_bfd ATTRIBUTE_UNUSED,
+				     struct elf_aarch64_link_hash_table
+				     *htab)
+{
+  /* Fill in PLT0. Fixme:RR Note this doesn't distinguish between
+     small and large plts and at the minute just generates
+     the small PLT.  */
+
+  /* PLT0 of the small PLT looks like this in ELF64 -
+     stp x16, x30, [sp, #-16]!		// Save the reloc and lr on stack.
+     adrp x16, PLT_GOT + 16		// Get the page base of the GOTPLT
+     ldr  x17, [x16, #:lo12:PLT_GOT+16] // Load the address of the
+					// symbol resolver
+     add  x16, x16, #:lo12:PLT_GOT+16   // Load the lo12 bits of the
+					// GOTPLT entry for this.
+     br   x17
+     PLT0 will be slightly different in ELF32 due to different got entry
+     size.
+   */
+  bfd_vma plt_got_2nd_ent;	/* Address of GOT[2].  */
+  bfd_vma plt_base;
+
+
+  memcpy (htab->root.splt->contents, elfNN_aarch64_small_plt0_entry,
+	  PLT_ENTRY_SIZE);
+  elf_section_data (htab->root.splt->output_section)->this_hdr.sh_entsize =
+    PLT_ENTRY_SIZE;
+
+  plt_got_2nd_ent = (htab->root.sgotplt->output_section->vma
+		  + htab->root.sgotplt->output_offset
+		  + GOT_ENTRY_SIZE * 2);
+
+  plt_base = htab->root.splt->output_section->vma +
+    htab->root.splt->output_offset;
+
+  /* Fill in the top 21 bits for this: ADRP x16, PLT_GOT + n * 8.
+     ADRP:   ((PG(S+A)-PG(P)) >> 12) & 0x1fffff */
+  elf_aarch64_update_plt_entry (output_bfd, BFD_RELOC_AARCH64_ADR_HI21_PCREL,
+				htab->root.splt->contents + 4,
+				PG (plt_got_2nd_ent) - PG (plt_base + 4));
+
+  elf_aarch64_update_plt_entry (output_bfd, BFD_RELOC_AARCH64_LDSTNN_LO12,
+				htab->root.splt->contents + 8,
+				PG_OFFSET (plt_got_2nd_ent));
+
+  elf_aarch64_update_plt_entry (output_bfd, BFD_RELOC_AARCH64_ADD_LO12,
+				htab->root.splt->contents + 12,
+				PG_OFFSET (plt_got_2nd_ent));
+}
+
+static bfd_boolean
+elfNN_aarch64_finish_dynamic_sections (bfd *output_bfd,
+				       struct bfd_link_info *info)
+{
+  struct elf_aarch64_link_hash_table *htab;
+  bfd *dynobj;
+  asection *sdyn;
+
+  htab = elf_aarch64_hash_table (info);
+  dynobj = htab->root.dynobj;
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
+
+  if (htab->root.dynamic_sections_created)
+    {
+      ElfNN_External_Dyn *dyncon, *dynconend;
+
+      if (sdyn == NULL || htab->root.sgot == NULL)
+	abort ();
+
+      dyncon = (ElfNN_External_Dyn *) sdyn->contents;
+      dynconend = (ElfNN_External_Dyn *) (sdyn->contents + sdyn->size);
+      for (; dyncon < dynconend; dyncon++)
+	{
+	  Elf_Internal_Dyn dyn;
+	  asection *s;
+
+	  bfd_elfNN_swap_dyn_in (dynobj, dyncon, &dyn);
+
+	  switch (dyn.d_tag)
+	    {
+	    default:
+	      continue;
+
+	    case DT_PLTGOT:
+	      s = htab->root.sgotplt;
+	      dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
+	      break;
+
+	    case DT_JMPREL:
+	      dyn.d_un.d_ptr = htab->root.srelplt->output_section->vma;
+	      break;
+
+	    case DT_PLTRELSZ:
+	      s = htab->root.srelplt;
+	      dyn.d_un.d_val = s->size;
+	      break;
+
+	    case DT_RELASZ:
+	      /* The procedure linkage table relocs (DT_JMPREL) should
+		 not be included in the overall relocs (DT_RELA).
+		 Therefore, we override the DT_RELASZ entry here to
+		 make it not include the JMPREL relocs.  Since the
+		 linker script arranges for .rela.plt to follow all
+		 other relocation sections, we don't have to worry
+		 about changing the DT_RELA entry.  */
+	      if (htab->root.srelplt != NULL)
+		{
+		  s = htab->root.srelplt;
+		  dyn.d_un.d_val -= s->size;
+		}
+	      break;
+
+	    case DT_TLSDESC_PLT:
+	      s = htab->root.splt;
+	      dyn.d_un.d_ptr = s->output_section->vma + s->output_offset
+		+ htab->tlsdesc_plt;
+	      break;
+
+	    case DT_TLSDESC_GOT:
+	      s = htab->root.sgot;
+	      dyn.d_un.d_ptr = s->output_section->vma + s->output_offset
+		+ htab->dt_tlsdesc_got;
+	      break;
+	    }
+
+	  bfd_elfNN_swap_dyn_out (output_bfd, &dyn, dyncon);
+	}
+
+    }
+
+  /* Fill in the special first entry in the procedure linkage table.  */
+  if (htab->root.splt && htab->root.splt->size > 0)
+    {
+      elfNN_aarch64_init_small_plt0_entry (output_bfd, htab);
+
+      elf_section_data (htab->root.splt->output_section)->
+	this_hdr.sh_entsize = htab->plt_entry_size;
+
+
+      if (htab->tlsdesc_plt)
+	{
+	  bfd_put_NN (output_bfd, (bfd_vma) 0,
+		      htab->root.sgot->contents + htab->dt_tlsdesc_got);
+
+	  memcpy (htab->root.splt->contents + htab->tlsdesc_plt,
+		  elfNN_aarch64_tlsdesc_small_plt_entry,
+		  sizeof (elfNN_aarch64_tlsdesc_small_plt_entry));
+
+	  {
+	    bfd_vma adrp1_addr =
+	      htab->root.splt->output_section->vma
+	      + htab->root.splt->output_offset + htab->tlsdesc_plt + 4;
+
+	    bfd_vma adrp2_addr = adrp1_addr + 4;
+
+	    bfd_vma got_addr =
+	      htab->root.sgot->output_section->vma
+	      + htab->root.sgot->output_offset;
+
+	    bfd_vma pltgot_addr =
+	      htab->root.sgotplt->output_section->vma
+	      + htab->root.sgotplt->output_offset;
+
+	    bfd_vma dt_tlsdesc_got = got_addr + htab->dt_tlsdesc_got;
+
+	    bfd_byte *plt_entry =
+	      htab->root.splt->contents + htab->tlsdesc_plt;
+
+	    /* adrp x2, DT_TLSDESC_GOT */
+	    elf_aarch64_update_plt_entry (output_bfd,
+					  BFD_RELOC_AARCH64_ADR_HI21_PCREL,
+					  plt_entry + 4,
+					  (PG (dt_tlsdesc_got)
+					   - PG (adrp1_addr)));
+
+	    /* adrp x3, 0 */
+	    elf_aarch64_update_plt_entry (output_bfd,
+					  BFD_RELOC_AARCH64_ADR_HI21_PCREL,
+					  plt_entry + 8,
+					  (PG (pltgot_addr)
+					   - PG (adrp2_addr)));
+
+	    /* ldr x2, [x2, #0] */
+	    elf_aarch64_update_plt_entry (output_bfd,
+					  BFD_RELOC_AARCH64_LDSTNN_LO12,
+					  plt_entry + 12,
+					  PG_OFFSET (dt_tlsdesc_got));
+
+	    /* add x3, x3, 0 */
+	    elf_aarch64_update_plt_entry (output_bfd,
+					  BFD_RELOC_AARCH64_ADD_LO12,
+					  plt_entry + 16,
+					  PG_OFFSET (pltgot_addr));
+	  }
+	}
+    }
+
+  if (htab->root.sgotplt)
+    {
+      if (bfd_is_abs_section (htab->root.sgotplt->output_section))
+	{
+	  (*_bfd_error_handler)
+	    (_("discarded output section: `%A'"), htab->root.sgotplt);
+	  return FALSE;
+	}
+
+      /* Fill in the first three entries in the global offset table.  */
+      if (htab->root.sgotplt->size > 0)
+	{
+	  bfd_put_NN (output_bfd, (bfd_vma) 0, htab->root.sgotplt->contents);
+
+	  /* Write GOT[1] and GOT[2], needed for the dynamic linker.  */
+	  bfd_put_NN (output_bfd,
+		      (bfd_vma) 0,
+		      htab->root.sgotplt->contents + GOT_ENTRY_SIZE);
+	  bfd_put_NN (output_bfd,
+		      (bfd_vma) 0,
+		      htab->root.sgotplt->contents + GOT_ENTRY_SIZE * 2);
+	}
+
+      if (htab->root.sgot)
+	{
+	  if (htab->root.sgot->size > 0)
+	    {
+	      bfd_vma addr =
+		sdyn ? sdyn->output_section->vma + sdyn->output_offset : 0;
+	      bfd_put_NN (output_bfd, addr, htab->root.sgot->contents);
+	    }
+	}
+
+      elf_section_data (htab->root.sgotplt->output_section)->
+	this_hdr.sh_entsize = GOT_ENTRY_SIZE;
+    }
+
+  if (htab->root.sgot && htab->root.sgot->size > 0)
+    elf_section_data (htab->root.sgot->output_section)->this_hdr.sh_entsize
+      = GOT_ENTRY_SIZE;
+
+  /* Fill PLT and GOT entries for local STT_GNU_IFUNC symbols.  */
+  htab_traverse (htab->loc_hash_table,
+		 elfNN_aarch64_finish_local_dynamic_symbol,
+		 info);
+
+  return TRUE;
+}
+
+/* Return address for Ith PLT stub in section PLT, for relocation REL
+   or (bfd_vma) -1 if it should not be included.  */
+
+static bfd_vma
+elfNN_aarch64_plt_sym_val (bfd_vma i, const asection *plt,
+			   const arelent *rel ATTRIBUTE_UNUSED)
+{
+  return plt->vma + PLT_ENTRY_SIZE + i * PLT_SMALL_ENTRY_SIZE;
+}
+
+
+/* We use this so we can override certain functions
+   (though currently we don't).  */
+
+const struct elf_size_info elfNN_aarch64_size_info =
+{
+  sizeof (ElfNN_External_Ehdr),
+  sizeof (ElfNN_External_Phdr),
+  sizeof (ElfNN_External_Shdr),
+  sizeof (ElfNN_External_Rel),
+  sizeof (ElfNN_External_Rela),
+  sizeof (ElfNN_External_Sym),
+  sizeof (ElfNN_External_Dyn),
+  sizeof (Elf_External_Note),
+  4,				/* Hash table entry size.  */
+  1,				/* Internal relocs per external relocs.  */
+  ARCH_SIZE,			/* Arch size.  */
+  LOG_FILE_ALIGN,		/* Log_file_align.  */
+  ELFCLASSNN, EV_CURRENT,
+  bfd_elfNN_write_out_phdrs,
+  bfd_elfNN_write_shdrs_and_ehdr,
+  bfd_elfNN_checksum_contents,
+  bfd_elfNN_write_relocs,
+  bfd_elfNN_swap_symbol_in,
+  bfd_elfNN_swap_symbol_out,
+  bfd_elfNN_slurp_reloc_table,
+  bfd_elfNN_slurp_symbol_table,
+  bfd_elfNN_swap_dyn_in,
+  bfd_elfNN_swap_dyn_out,
+  bfd_elfNN_swap_reloc_in,
+  bfd_elfNN_swap_reloc_out,
+  bfd_elfNN_swap_reloca_in,
+  bfd_elfNN_swap_reloca_out
+};
+
+#define ELF_ARCH			bfd_arch_aarch64
+#define ELF_MACHINE_CODE		EM_AARCH64
+#define ELF_MAXPAGESIZE			0x10000
+#define ELF_MINPAGESIZE			0x1000
+#define ELF_COMMONPAGESIZE		0x1000
+
+#define bfd_elfNN_close_and_cleanup             \
+  elfNN_aarch64_close_and_cleanup
+
+#define bfd_elfNN_bfd_copy_private_bfd_data	\
+  elfNN_aarch64_copy_private_bfd_data
+
+#define bfd_elfNN_bfd_free_cached_info          \
+  elfNN_aarch64_bfd_free_cached_info
+
+#define bfd_elfNN_bfd_is_target_special_symbol	\
+  elfNN_aarch64_is_target_special_symbol
+
+#define bfd_elfNN_bfd_link_hash_table_create    \
+  elfNN_aarch64_link_hash_table_create
+
+#define bfd_elfNN_bfd_link_hash_table_free      \
+  elfNN_aarch64_hash_table_free
+
+#define bfd_elfNN_bfd_merge_private_bfd_data	\
+  elfNN_aarch64_merge_private_bfd_data
+
+#define bfd_elfNN_bfd_print_private_bfd_data	\
+  elfNN_aarch64_print_private_bfd_data
+
+#define bfd_elfNN_bfd_reloc_type_lookup		\
+  elfNN_aarch64_reloc_type_lookup
+
+#define bfd_elfNN_bfd_reloc_name_lookup		\
+  elfNN_aarch64_reloc_name_lookup
+
+#define bfd_elfNN_bfd_set_private_flags		\
+  elfNN_aarch64_set_private_flags
+
+#define bfd_elfNN_find_inliner_info		\
+  elfNN_aarch64_find_inliner_info
+
+#define bfd_elfNN_find_nearest_line		\
+  elfNN_aarch64_find_nearest_line
+
+#define bfd_elfNN_mkobject			\
+  elfNN_aarch64_mkobject
+
+#define bfd_elfNN_new_section_hook		\
+  elfNN_aarch64_new_section_hook
+
+#define elf_backend_adjust_dynamic_symbol	\
+  elfNN_aarch64_adjust_dynamic_symbol
+
+#define elf_backend_always_size_sections	\
+  elfNN_aarch64_always_size_sections
+
+#define elf_backend_check_relocs		\
+  elfNN_aarch64_check_relocs
+
+#define elf_backend_copy_indirect_symbol	\
+  elfNN_aarch64_copy_indirect_symbol
+
+/* Create .dynbss, and .rela.bss sections in DYNOBJ, and set up shortcuts
+   to them in our hash.  */
+#define elf_backend_create_dynamic_sections	\
+  elfNN_aarch64_create_dynamic_sections
+
+#define elf_backend_init_index_section		\
+  _bfd_elf_init_2_index_sections
+
+#define elf_backend_finish_dynamic_sections	\
+  elfNN_aarch64_finish_dynamic_sections
+
+#define elf_backend_finish_dynamic_symbol	\
+  elfNN_aarch64_finish_dynamic_symbol
+
+#define elf_backend_gc_sweep_hook		\
+  elfNN_aarch64_gc_sweep_hook
+
+#define elf_backend_object_p			\
+  elfNN_aarch64_object_p
+
+#define elf_backend_output_arch_local_syms      \
+  elfNN_aarch64_output_arch_local_syms
+
+#define elf_backend_plt_sym_val			\
+  elfNN_aarch64_plt_sym_val
+
+#define elf_backend_post_process_headers	\
+  elfNN_aarch64_post_process_headers
+
+#define elf_backend_relocate_section		\
+  elfNN_aarch64_relocate_section
+
+#define elf_backend_reloc_type_class		\
+  elfNN_aarch64_reloc_type_class
+
+#define elf_backend_section_from_shdr		\
+  elfNN_aarch64_section_from_shdr
+
+#define elf_backend_size_dynamic_sections	\
+  elfNN_aarch64_size_dynamic_sections
+
+#define elf_backend_size_info			\
+  elfNN_aarch64_size_info
+
+#define elf_backend_can_refcount       1
+#define elf_backend_can_gc_sections    1
+#define elf_backend_plt_readonly       1
+#define elf_backend_want_got_plt       1
+#define elf_backend_want_plt_sym       0
+#define elf_backend_may_use_rel_p      0
+#define elf_backend_may_use_rela_p     1
+#define elf_backend_default_use_rela_p 1
+#define elf_backend_got_header_size (GOT_ENTRY_SIZE * 3)
+#define elf_backend_default_execstack  0
+
+#undef  elf_backend_obj_attrs_section
+#define elf_backend_obj_attrs_section		".ARM.attributes"
+
+#include "elfNN-target.h"
diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c
index 3e2ee0b..117b4c8 100644
--- a/bfd/elfnn-ia64.c
+++ b/bfd/elfnn-ia64.c
@@ -1,6 +1,5 @@
 /* IA-64 support for 64-bit ELF
-   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-   2008, 2009, 2010, 2011  Free Software Foundation, Inc.
+   Copyright 1998-2013 Free Software Foundation, Inc.
    Contributed by David Mosberger-Tang <[email protected]>
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -41,14 +40,6 @@
 #define	LOG_SECTION_ALIGN	2
 #endif
 
-/* Only add code for vms when the vms target is enabled.  This is required
-   because it depends on vms-lib.c for its archive format and we don't want
-   to compile that code if it is not used.  */
-#if ARCH_SIZE == 64 && \
-  (defined (HAVE_bfd_elf64_ia64_vms_vec) || defined (HAVE_all_vecs))
-#define INCLUDE_IA64_VMS
-#endif
-
 typedef struct bfd_hash_entry *(*new_hash_entry_func)
   (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
 
@@ -186,18 +177,18 @@
   (bfd *abfd, struct bfd_link_info *info, bfd_boolean final);
 static void elfNN_ia64_dyn_sym_traverse
   (struct elfNN_ia64_link_hash_table *ia64_info,
-   bfd_boolean (*func) (struct elfNN_ia64_dyn_sym_info *, PTR),
-   PTR info);
+   bfd_boolean (*func) (struct elfNN_ia64_dyn_sym_info *, void *),
+   void * info);
 static bfd_boolean allocate_global_data_got
-  (struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data);
+  (struct elfNN_ia64_dyn_sym_info *dyn_i, void * data);
 static bfd_boolean allocate_global_fptr_got
-  (struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data);
+  (struct elfNN_ia64_dyn_sym_info *dyn_i, void * data);
 static bfd_boolean allocate_local_got
-  (struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data);
+  (struct elfNN_ia64_dyn_sym_info *dyn_i, void * data);
 static bfd_boolean elfNN_ia64_hpux_vec
   (const bfd_target *vec);
 static bfd_boolean allocate_dynrel_entries
-  (struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data);
+  (struct elfNN_ia64_dyn_sym_info *dyn_i, void * data);
 static asection *get_pltoff
   (bfd *abfd, struct bfd_link_info *info,
    struct elfNN_ia64_link_hash_table *ia64_info);
@@ -530,7 +521,7 @@
 	  symtype = h->type;
 	}
 
-      if (tsec->sec_info_type == ELF_INFO_TYPE_MERGE)
+      if (tsec->sec_info_type == SEC_INFO_TYPE_MERGE)
 	{
 	  /* At this stage in linking, no SEC_MERGE symbol has been
 	     adjusted, so all references to such symbols need to be
@@ -578,7 +569,7 @@
 	     .plt section.  After the first relaxation pass, linker may
 	     increase the gap between the .plt and .text sections up
 	     to 32byte.  We assume linker will always insert 32byte
-	     between the .plt and .text sections after the the first
+	     between the .plt and .text sections after the first
 	     relaxation pass.  */
 	  if (tsec == ia64_info->root.splt)
 	    offset = -0x1000000 + 32;
@@ -1102,7 +1093,7 @@
   s = bfd_get_section_by_name (abfd, ELF_STRING_ia64_archext);
   if (s && (s->flags & SEC_LOAD))
     {
-      for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+      for (m = elf_seg_map (abfd); m != NULL; m = m->next)
 	if (m->p_type == PT_IA_64_ARCHEXT)
 	  break;
       if (m == NULL)
@@ -1117,7 +1108,7 @@
 	  m->sections[0] = s;
 
 	  /* We want to put it after the PHDR and INTERP segments.  */
-	  pm = &elf_tdata (abfd)->segment_map;
+	  pm = &elf_seg_map (abfd);
 	  while (*pm != NULL
 		 && ((*pm)->p_type == PT_PHDR
 		     || (*pm)->p_type == PT_INTERP))
@@ -1137,7 +1128,7 @@
 
       if (s && (s->flags & SEC_LOAD))
 	{
-	  for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+	  for (m = elf_seg_map (abfd); m != NULL; m = m->next)
 	    if (m->p_type == PT_IA_64_UNWIND)
 	      {
 		int i;
@@ -1166,7 +1157,7 @@
 	      m->next = NULL;
 
 	      /* We want to put it last.  */
-	      pm = &elf_tdata (abfd)->segment_map;
+	      pm = &elf_seg_map (abfd);
 	      while (*pm != NULL)
 		pm = &(*pm)->next;
 	      *pm = m;
@@ -1189,7 +1180,7 @@
   struct elf_segment_map *m;
   Elf_Internal_Phdr *p;
 
-  for (p = tdata->phdr, m = tdata->segment_map; m != NULL; m = m->next, p++)
+  for (p = tdata->phdr, m = elf_seg_map (abfd); m != NULL; m = m->next, p++)
     if (m->p_type == PT_LOAD)
       {
 	int i;
@@ -1416,7 +1407,7 @@
 
 static bfd_boolean
 elfNN_ia64_global_dyn_info_free (void **xentry,
-				PTR unused ATTRIBUTE_UNUSED)
+				 void * unused ATTRIBUTE_UNUSED)
 {
   struct elfNN_ia64_link_hash_entry *entry
     = (struct elfNN_ia64_link_hash_entry *) xentry;
@@ -1437,7 +1428,7 @@
 
 static bfd_boolean
 elfNN_ia64_local_dyn_info_free (void **slot,
-				PTR unused ATTRIBUTE_UNUSED)
+				void * unused ATTRIBUTE_UNUSED)
 {
   struct elfNN_ia64_local_hash_entry *entry
     = (struct elfNN_ia64_local_hash_entry *) *slot;
@@ -1471,20 +1462,20 @@
     objalloc_free ((struct objalloc *) ia64_info->loc_hash_memory);
   elf_link_hash_traverse (&ia64_info->root,
 			  elfNN_ia64_global_dyn_info_free, NULL);
-  _bfd_generic_link_hash_table_free (hash);
+  _bfd_elf_link_hash_table_free (hash);
 }
 
 /* Traverse both local and global hash tables.  */
 
 struct elfNN_ia64_dyn_sym_traverse_data
 {
-  bfd_boolean (*func) (struct elfNN_ia64_dyn_sym_info *, PTR);
-  PTR data;
+  bfd_boolean (*func) (struct elfNN_ia64_dyn_sym_info *, void *);
+  void * data;
 };
 
 static bfd_boolean
 elfNN_ia64_global_dyn_sym_thunk (struct bfd_hash_entry *xentry,
-				 PTR xdata)
+				 void * xdata)
 {
   struct elfNN_ia64_link_hash_entry *entry
     = (struct elfNN_ia64_link_hash_entry *) xentry;
@@ -1502,7 +1493,7 @@
 }
 
 static bfd_boolean
-elfNN_ia64_local_dyn_sym_thunk (void **slot, PTR xdata)
+elfNN_ia64_local_dyn_sym_thunk (void **slot, void * xdata)
 {
   struct elfNN_ia64_local_hash_entry *entry
     = (struct elfNN_ia64_local_hash_entry *) *slot;
@@ -1521,8 +1512,8 @@
 
 static void
 elfNN_ia64_dyn_sym_traverse (struct elfNN_ia64_link_hash_table *ia64_info,
-			     bfd_boolean (*func) (struct elfNN_ia64_dyn_sym_info *, PTR),
-			     PTR data)
+			     bfd_boolean (*func) (struct elfNN_ia64_dyn_sym_info *, void *),
+			     void * data)
 {
   struct elfNN_ia64_dyn_sym_traverse_data xdata;
 
@@ -1554,18 +1545,19 @@
     bfd_set_section_flags (abfd, ia64_info->root.sgot,
 			   SEC_SMALL_DATA | flags);
     /* The .got section is always aligned at 8 bytes.  */
-    bfd_set_section_alignment (abfd, ia64_info->root.sgot, 3);
+    if (! bfd_set_section_alignment (abfd, ia64_info->root.sgot, 3))
+      return FALSE;
   }
 
   if (!get_pltoff (abfd, info, ia64_info))
     return FALSE;
 
-  s = bfd_make_section_with_flags (abfd, ".rela.IA_64.pltoff",
-				   (SEC_ALLOC | SEC_LOAD
-				    | SEC_HAS_CONTENTS
-				    | SEC_IN_MEMORY
-				    | SEC_LINKER_CREATED
-				    | SEC_READONLY));
+  s = bfd_make_section_anyway_with_flags (abfd, ".rela.IA_64.pltoff",
+					  (SEC_ALLOC | SEC_LOAD
+					   | SEC_HAS_CONTENTS
+					   | SEC_IN_MEMORY
+					   | SEC_LINKER_CREATED
+					   | SEC_READONLY));
   if (s == NULL
       || !bfd_set_section_alignment (abfd, s, LOG_SECTION_ALIGN))
     return FALSE;
@@ -1960,16 +1952,17 @@
       if (!dynobj)
 	ia64_info->root.dynobj = dynobj = abfd;
       if (!_bfd_elf_create_got_section (dynobj, info))
-	return 0;
+	return NULL;
 
       got = ia64_info->root.sgot;
 
       /* The .got section is always aligned at 8 bytes.  */
       if (!bfd_set_section_alignment (abfd, got, 3))
-	return 0;
+	return NULL;
 
       flags = bfd_get_section_flags (abfd, got);
-      bfd_set_section_flags (abfd, got, SEC_SMALL_DATA | flags);
+      if (! bfd_set_section_flags (abfd, got, SEC_SMALL_DATA | flags))
+	return NULL;
     }
 
   return got;
@@ -1994,13 +1987,14 @@
       if (!dynobj)
 	ia64_info->root.dynobj = dynobj = abfd;
 
-      fptr = bfd_make_section_with_flags (dynobj, ".opd",
-					  (SEC_ALLOC
-					   | SEC_LOAD
-					   | SEC_HAS_CONTENTS
-					   | SEC_IN_MEMORY
-					   | (info->pie ? 0 : SEC_READONLY)
-					   | SEC_LINKER_CREATED));
+      fptr = bfd_make_section_anyway_with_flags (dynobj, ".opd",
+						 (SEC_ALLOC
+						  | SEC_LOAD
+						  | SEC_HAS_CONTENTS
+						  | SEC_IN_MEMORY
+						  | (info->pie ? 0
+						     : SEC_READONLY)
+						  | SEC_LINKER_CREATED));
       if (!fptr
 	  || !bfd_set_section_alignment (abfd, fptr, 4))
 	{
@@ -2013,12 +2007,12 @@
       if (info->pie)
 	{
 	  asection *fptr_rel;
-	  fptr_rel = bfd_make_section_with_flags (dynobj, ".rela.opd",
-						  (SEC_ALLOC | SEC_LOAD
-						   | SEC_HAS_CONTENTS
-						   | SEC_IN_MEMORY
-						   | SEC_LINKER_CREATED
-						   | SEC_READONLY));
+	  fptr_rel = bfd_make_section_anyway_with_flags (dynobj, ".rela.opd",
+							 (SEC_ALLOC | SEC_LOAD
+							  | SEC_HAS_CONTENTS
+							  | SEC_IN_MEMORY
+							  | SEC_LINKER_CREATED
+							  | SEC_READONLY));
 	  if (fptr_rel == NULL
 	      || !bfd_set_section_alignment (abfd, fptr_rel,
 					     LOG_SECTION_ALIGN))
@@ -2048,14 +2042,14 @@
       if (!dynobj)
 	ia64_info->root.dynobj = dynobj = abfd;
 
-      pltoff = bfd_make_section_with_flags (dynobj,
-					    ELF_STRING_ia64_pltoff,
-					    (SEC_ALLOC
-					     | SEC_LOAD
-					     | SEC_HAS_CONTENTS
-					     | SEC_IN_MEMORY
-					     | SEC_SMALL_DATA
-					     | SEC_LINKER_CREATED));
+      pltoff = bfd_make_section_anyway_with_flags (dynobj,
+						   ELF_STRING_ia64_pltoff,
+						   (SEC_ALLOC
+						    | SEC_LOAD
+						    | SEC_HAS_CONTENTS
+						    | SEC_IN_MEMORY
+						    | SEC_SMALL_DATA
+						    | SEC_LINKER_CREATED));
       if (!pltoff
 	  || !bfd_set_section_alignment (abfd, pltoff, 4))
 	{
@@ -2088,15 +2082,15 @@
   if (!dynobj)
     ia64_info->root.dynobj = dynobj = abfd;
 
-  srel = bfd_get_section_by_name (dynobj, srel_name);
+  srel = bfd_get_linker_section (dynobj, srel_name);
   if (srel == NULL && create)
     {
-      srel = bfd_make_section_with_flags (dynobj, srel_name,
-					  (SEC_ALLOC | SEC_LOAD
-					   | SEC_HAS_CONTENTS
-					   | SEC_IN_MEMORY
-					   | SEC_LINKER_CREATED
-					   | SEC_READONLY));
+      srel = bfd_make_section_anyway_with_flags (dynobj, srel_name,
+						 (SEC_ALLOC | SEC_LOAD
+						  | SEC_HAS_CONTENTS
+						  | SEC_IN_MEMORY
+						  | SEC_LINKER_CREATED
+						  | SEC_READONLY));
       if (srel == NULL
 	  || !bfd_set_section_alignment (dynobj, srel,
 					 LOG_SECTION_ALIGN))
@@ -2359,6 +2353,9 @@
 		 || h->root.type == bfd_link_hash_warning)
 	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
 
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	  h->ref_regular = 1;
 	}
       else
@@ -2666,7 +2663,7 @@
 
 static bfd_boolean
 allocate_local_got (struct elfNN_ia64_dyn_sym_info *dyn_i,
-		    PTR data)
+		    void * data)
 {
   struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data;
 
@@ -2701,7 +2698,7 @@
    in a main executable that is not exported.  */
 
 static bfd_boolean
-allocate_fptr (struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data)
+allocate_fptr (struct elfNN_ia64_dyn_sym_info *dyn_i, void * data)
 {
   struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data;
 
@@ -2748,7 +2745,7 @@
 
 static bfd_boolean
 allocate_plt_entries (struct elfNN_ia64_dyn_sym_info *dyn_i,
-		      PTR data)
+		      void * data)
 {
   struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data;
 
@@ -2785,7 +2782,7 @@
 
 static bfd_boolean
 allocate_plt2_entries (struct elfNN_ia64_dyn_sym_info *dyn_i,
-		       PTR data)
+		       void * data)
 {
   struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data;
 
@@ -2812,7 +2809,7 @@
 
 static bfd_boolean
 allocate_pltoff_entries (struct elfNN_ia64_dyn_sym_info *dyn_i,
-			 PTR data)
+			 void * data)
 {
   struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data;
 
@@ -2829,7 +2826,7 @@
 
 static bfd_boolean
 allocate_dynrel_entries (struct elfNN_ia64_dyn_sym_info *dyn_i,
-			 PTR data)
+			 void * data)
 {
   struct elfNN_ia64_allocate_data *x = (struct elfNN_ia64_allocate_data *)data;
   struct elfNN_ia64_link_hash_table *ia64_info;
@@ -2996,7 +2993,7 @@
   if (ia64_info->root.dynamic_sections_created
       && info->executable)
     {
-      sec = bfd_get_section_by_name (dynobj, ".interp");
+      sec = bfd_get_linker_section (dynobj, ".interp");
       BFD_ASSERT (sec != NULL);
       sec->contents = (bfd_byte *) ELF_DYNAMIC_INTERPRETER;
       sec->size = strlen (ELF_DYNAMIC_INTERPRETER) + 1;
@@ -3053,7 +3050,7 @@
 
       /* If we've got a .plt, we need some extra memory for the dynamic
 	 linker.  We stuff these in .got.plt.  */
-      sec = bfd_get_section_by_name (dynobj, ".got.plt");
+      sec = bfd_get_linker_section (dynobj, ".got.plt");
       sec->size = 8 * PLT_RESERVED_WORDS;
     }
 
@@ -3544,7 +3541,7 @@
 static bfd *elfNN_ia64_unwind_entry_compare_bfd;
 
 static int
-elfNN_ia64_unwind_entry_compare (const PTR a, const PTR b)
+elfNN_ia64_unwind_entry_compare (const void * a, const void * b)
 {
   bfd_vma av, bv;
 
@@ -3861,7 +3858,7 @@
 	  if (!info->relocatable
 	      && (sym_sec->flags & SEC_MERGE) != 0
 	      && ELF_ST_TYPE (sym->st_info) == STT_SECTION
-	      && sym_sec->sec_info_type == ELF_INFO_TYPE_MERGE)
+	      && sym_sec->sec_info_type == SEC_INFO_TYPE_MERGE)
 	    {
 	      struct elfNN_ia64_local_hash_entry *loc_h;
 
@@ -3919,9 +3916,9 @@
 	    continue;
 	}
 
-      if (sym_sec != NULL && elf_discarded_section (sym_sec))
+      if (sym_sec != NULL && discarded_section (sym_sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -4593,7 +4590,7 @@
     }
 
   /* Mark some specially defined symbols as absolute.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+  if (h == ia64_info->root.hdynamic
       || h == ia64_info->root.hgot
       || h == ia64_info->root.hplt)
     sym->st_shndx = SHN_ABS;
@@ -4620,8 +4617,8 @@
       asection *sdyn, *sgotplt;
       bfd_vma gp_val;
 
-      sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
-      sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
+      sdyn = bfd_get_linker_section (dynobj, ".dynamic");
+      sgotplt = bfd_get_linker_section (dynobj, ".got.plt");
       BFD_ASSERT (sdyn != NULL);
       dyncon = (ElfNN_External_Dyn *) sdyn->contents;
       dynconend = (ElfNN_External_Dyn *) (sdyn->contents + sdyn->size);
@@ -4793,7 +4790,7 @@
 }
 
 static bfd_boolean
-elfNN_ia64_print_private_bfd_data (bfd *abfd, PTR ptr)
+elfNN_ia64_print_private_bfd_data (bfd *abfd, void * ptr)
 {
   FILE *file = (FILE *) ptr;
   flagword flags = elf_elfheader (abfd)->e_flags;
@@ -4815,7 +4812,9 @@
 }
 
 static enum elf_reloc_type_class
-elfNN_ia64_reloc_type_class (const Elf_Internal_Rela *rela)
+elfNN_ia64_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			     const asection *rel_sec ATTRIBUTE_UNUSED,
+			     const Elf_Internal_Rela *rela)
 {
   switch ((int) ELFNN_R_TYPE (rela->r_info))
     {
@@ -4978,268 +4977,6 @@
       break;
     }
 }
-
-#ifdef INCLUDE_IA64_VMS
-
-static bfd_boolean
-elfNN_vms_section_from_shdr (bfd *abfd,
-			     Elf_Internal_Shdr *hdr,
-			     const char *name,
-			     int shindex)
-{
-  switch (hdr->sh_type)
-    {
-    case SHT_IA_64_VMS_TRACE:
-    case SHT_IA_64_VMS_DEBUG:
-    case SHT_IA_64_VMS_DEBUG_STR:
-      break;
-
-    default:
-      return elfNN_ia64_section_from_shdr (abfd, hdr, name, shindex);
-    }
-
-  if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
-    return FALSE;
-
-  return TRUE;
-}
-
-static bfd_boolean
-elfNN_vms_object_p (bfd *abfd)
-{
-  Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
-  Elf_Internal_Phdr *i_phdr = elf_tdata (abfd)->phdr;
-  unsigned int i;
-  unsigned int num_text = 0;
-  unsigned int num_data = 0;
-  unsigned int num_rodata = 0;
-  char name[16];
-
-  if (!elfNN_ia64_object_p (abfd))
-    return FALSE;
-
-  for (i = 0; i < i_ehdrp->e_phnum; i++, i_phdr++)
-    {
-      /* Is there a section for this segment?  */
-      bfd_vma base_vma = i_phdr->p_vaddr;
-      bfd_vma limit_vma = base_vma + i_phdr->p_filesz;
-
-      if (i_phdr->p_type != PT_LOAD)
-	continue;
-
-    again:
-      while (base_vma < limit_vma)
-	{
-	  bfd_vma next_vma = limit_vma;
-	  asection *nsec;
-	  asection *sec;
-	  flagword flags;
-	  char *nname = NULL;
-
-	  /* Find a section covering base_vma.  */
-	  for (sec = abfd->sections; sec != NULL; sec = sec->next)
-	    {
-	      if ((sec->flags & (SEC_ALLOC | SEC_LOAD)) == 0)
-		continue;
-	      if (sec->vma <= base_vma && sec->vma + sec->size > base_vma)
-		{
-		  base_vma = sec->vma + sec->size;
-		  goto again;
-		}
-	      if (sec->vma < next_vma && sec->vma + sec->size >= base_vma)
-		next_vma = sec->vma;
-	    }
-
-	  /* No section covering [base_vma; next_vma).  Create a fake one.  */
-	  flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
-	  if (i_phdr->p_flags & PF_X)
-	    {
-	      flags |= SEC_CODE;
-	      if (num_text++ == 0)
-		nname = ".text";
-	      else
-		sprintf (name, ".text$%u", num_text);
-	    }
-	  else if ((i_phdr->p_flags & (PF_R | PF_W)) == PF_R)
-	    {
-	      flags |= SEC_READONLY;
-	      sprintf (name, ".rodata$%u", num_rodata++);
-	    }
-	  else
-	    {
-	      flags |= SEC_DATA;
-	      sprintf (name, ".data$%u", num_data++);
-	    }
-
-	  /* Allocate name.  */
-	  if (nname == NULL)
-	    {
-	      size_t name_len = strlen (name) + 1;
-	      nname = bfd_alloc (abfd, name_len);
-	      if (nname == NULL)
-		return FALSE;
-	      memcpy (nname, name, name_len);
-	    }
-
-	  /* Create and fill new section.  */
-	  nsec = bfd_make_section_anyway_with_flags (abfd, nname, flags);
-	  if (nsec == NULL)
-	    return FALSE;
-	  nsec->vma = base_vma;
-	  nsec->size = next_vma - base_vma;
-	  nsec->filepos = i_phdr->p_offset + (base_vma - i_phdr->p_vaddr);
-
-	  base_vma = next_vma;
-	}
-    }
-  return TRUE;
-}
-
-static void
-elfNN_vms_post_process_headers (bfd *abfd,
-				struct bfd_link_info *info ATTRIBUTE_UNUSED)
-{
-  Elf_Internal_Ehdr *i_ehdrp = elf_elfheader (abfd);
-
-  i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_OPENVMS;
-  i_ehdrp->e_ident[EI_ABIVERSION] = 2;
-}
-
-static bfd_boolean
-elfNN_vms_section_processing (bfd *abfd ATTRIBUTE_UNUSED,
-			      Elf_Internal_Shdr *hdr)
-{
-  if (hdr->bfd_section != NULL)
-    {
-      const char *name = bfd_get_section_name (abfd, hdr->bfd_section);
-
-      if (strcmp (name, ".text") == 0)
-	hdr->sh_flags |= SHF_IA_64_VMS_SHARED;
-      else if ((strcmp (name, ".debug") == 0)
-	    || (strcmp (name, ".debug_abbrev") == 0)
-	    || (strcmp (name, ".debug_aranges") == 0)
-	    || (strcmp (name, ".debug_frame") == 0)
-	    || (strcmp (name, ".debug_info") == 0)
-	    || (strcmp (name, ".debug_loc") == 0)
-	    || (strcmp (name, ".debug_macinfo") == 0)
-	    || (strcmp (name, ".debug_pubnames") == 0)
-	    || (strcmp (name, ".debug_pubtypes") == 0))
-	hdr->sh_type = SHT_IA_64_VMS_DEBUG;
-      else if ((strcmp (name, ".debug_line") == 0)
-	    || (strcmp (name, ".debug_ranges") == 0))
-	hdr->sh_type = SHT_IA_64_VMS_TRACE;
-      else if (strcmp (name, ".debug_str") == 0)
-	hdr->sh_type = SHT_IA_64_VMS_DEBUG_STR;
-      else if (strcmp (name, ".vms_display_name_info") == 0)
-	{
-	  int idx, symcount;
-	  asymbol **syms;
-	  struct elf_obj_tdata *t = elf_tdata (abfd);
-	  int buf[2];
-	  int demangler_sym_idx = -1;
-
-	  symcount = bfd_get_symcount (abfd);
-	  syms = bfd_get_outsymbols (abfd);
-	  for (idx = 0; idx < symcount; idx++)
-	    {
-	      asymbol *sym;
-	      sym = syms[idx];
-	      if ((sym->flags & (BSF_DEBUGGING | BSF_DYNAMIC))
-	          && strchr (sym->name, '@')
-		  && (strcmp (sym->section->name, BFD_ABS_SECTION_NAME) == 0))
-		{
-		  demangler_sym_idx = sym->udata.i;
-		  break;
-		}
-	    }
-
-	  hdr->sh_type = SHT_IA_64_VMS_DISPLAY_NAME_INFO;
-	  hdr->sh_entsize = 4;
-	  hdr->sh_addralign = 0;
-	  hdr->sh_link = t->symtab_section;
-
-	  /* Find symtab index of demangler routine and stuff it in
-	     the second long word of section data.  */
-
-	  if (demangler_sym_idx > -1)
-	    {
-	      bfd_seek (abfd, hdr->sh_offset, SEEK_SET);
-	      bfd_bread (buf, hdr->sh_size, abfd);
-	      buf [1] = demangler_sym_idx;
-	      bfd_seek (abfd, hdr->sh_offset, SEEK_SET);
-	      bfd_bwrite (buf, hdr->sh_size, abfd);
-	    }
-	}
-    }
-
-  return TRUE;
-}
-
-/* The final processing done just before writing out a VMS IA-64 ELF
-   object file.  */
-
-static void
-elfNN_vms_final_write_processing (bfd *abfd,
-				  bfd_boolean linker ATTRIBUTE_UNUSED)
-{
-  Elf_Internal_Shdr *hdr;
-  asection *s;
-  int unwind_info_sect_idx = 0;
-
-  for (s = abfd->sections; s; s = s->next)
-    {
-      hdr = &elf_section_data (s)->this_hdr;
-
-      if (strcmp (bfd_get_section_name (abfd, hdr->bfd_section),
-		  ".IA_64.unwind_info") == 0)
-	unwind_info_sect_idx = elf_section_data (s)->this_idx;
-
-      switch (hdr->sh_type)
-	{
-	case SHT_IA_64_UNWIND:
-	  /* VMS requires sh_info to point to the unwind info section.  */
-          hdr->sh_info = unwind_info_sect_idx;
-	  break;
-	}
-    }
-
-  if (! elf_flags_init (abfd))
-    {
-      unsigned long flags = 0;
-
-      if (abfd->xvec->byteorder == BFD_ENDIAN_BIG)
-	flags |= EF_IA_64_BE;
-      if (bfd_get_mach (abfd) == bfd_mach_ia64_elf64)
-	flags |= EF_IA_64_ABI64;
-
-      elf_elfheader(abfd)->e_flags = flags;
-      elf_flags_init (abfd) = TRUE;
-    }
-}
-
-static bfd_boolean
-elfNN_vms_close_and_cleanup (bfd *abfd)
-{
-  if (bfd_get_format (abfd) == bfd_object)
-    {
-      long isize, irsize;
-
-      if (elf_shstrtab (abfd) != NULL)
-	_bfd_elf_strtab_free (elf_shstrtab (abfd));
-
-      /* Pad to 8 byte boundary for IPF/VMS.  */
-      isize = bfd_get_size (abfd);
-      if ((irsize = isize/8*8) < isize)
-	{
-	  int ishort = (irsize + 8) - isize;
-	  bfd_seek (abfd, isize, SEEK_SET);
-	  bfd_bwrite (bfd_zmalloc (ishort), ishort, abfd);
-	}
-    }
-
-  return _bfd_generic_close_and_cleanup (abfd);
-}
-#endif /* INCLUDE_IA64_VMS */
 
 #define TARGET_LITTLE_SYM		bfd_elfNN_ia64_little_vec
 #define TARGET_LITTLE_NAME		"elfNN-ia64-little"
@@ -5372,86 +5109,3 @@
 #define elfNN_bed elfNN_ia64_hpux_bed
 
 #include "elfNN-target.h"
-
-/* VMS-specific vectors.  */
-#ifdef INCLUDE_IA64_VMS
-
-#undef  TARGET_LITTLE_SYM
-#define TARGET_LITTLE_SYM		bfd_elfNN_ia64_vms_vec
-#undef  TARGET_LITTLE_NAME
-#define TARGET_LITTLE_NAME		"elfNN-ia64-vms"
-#undef  TARGET_BIG_SYM
-#undef  TARGET_BIG_NAME
-
-/* These are VMS specific functions.  */
-
-#undef  elf_backend_object_p
-#define elf_backend_object_p elfNN_vms_object_p
-
-#undef  elf_backend_section_from_shdr
-#define elf_backend_section_from_shdr elfNN_vms_section_from_shdr
-
-#undef  elf_backend_post_process_headers
-#define elf_backend_post_process_headers elfNN_vms_post_process_headers
-
-#undef  elf_backend_section_processing
-#define elf_backend_section_processing elfNN_vms_section_processing
-
-#undef  elf_backend_final_write_processing
-#define elf_backend_final_write_processing elfNN_vms_final_write_processing
-
-#undef  bfd_elfNN_close_and_cleanup
-#define bfd_elfNN_close_and_cleanup elfNN_vms_close_and_cleanup
-
-#undef  elf_backend_section_from_bfd_section
-
-#undef  elf_backend_symbol_processing
-
-#undef  elf_backend_want_p_paddr_set_to_zero
-
-#undef ELF_OSABI
-#define ELF_OSABI			ELFOSABI_OPENVMS
-
-#undef  ELF_MAXPAGESIZE
-#define ELF_MAXPAGESIZE			0x10000	/* 64KB */
-
-#undef  elfNN_bed
-#define elfNN_bed elfNN_ia64_vms_bed
-
-/* Use VMS-style archives (in particular, don't use the standard coff
-   archive format).  */
-#define bfd_elfNN_archive_functions
-
-#undef bfd_elfNN_archive_p
-#define bfd_elfNN_archive_p _bfd_vms_lib_ia64_archive_p
-#undef bfd_elfNN_write_archive_contents
-#define bfd_elfNN_write_archive_contents _bfd_vms_lib_write_archive_contents
-#undef bfd_elfNN_mkarchive
-#define bfd_elfNN_mkarchive _bfd_vms_lib_ia64_mkarchive
-
-#define bfd_elfNN_archive_slurp_armap \
-  _bfd_vms_lib_slurp_armap
-#define bfd_elfNN_archive_slurp_extended_name_table \
-  _bfd_vms_lib_slurp_extended_name_table
-#define bfd_elfNN_archive_construct_extended_name_table \
-  _bfd_vms_lib_construct_extended_name_table
-#define bfd_elfNN_archive_truncate_arname \
-  _bfd_vms_lib_truncate_arname
-#define bfd_elfNN_archive_write_armap \
-  _bfd_vms_lib_write_armap
-#define bfd_elfNN_archive_read_ar_hdr \
-  _bfd_vms_lib_read_ar_hdr
-#define bfd_elfNN_archive_write_ar_hdr \
-  _bfd_vms_lib_write_ar_hdr
-#define bfd_elfNN_archive_openr_next_archived_file \
-  _bfd_vms_lib_openr_next_archived_file
-#define bfd_elfNN_archive_get_elt_at_index \
-  _bfd_vms_lib_get_elt_at_index
-#define bfd_elfNN_archive_generic_stat_arch_elt \
-  _bfd_vms_lib_generic_stat_arch_elt
-#define bfd_elfNN_archive_update_armap_timestamp \
-  _bfd_vms_lib_update_armap_timestamp
-
-#include "elfNN-target.h"
-
-#endif /* INCLUDE_IA64_VMS */
diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c
new file mode 100644
index 0000000..129319d
--- /dev/null
+++ b/bfd/elfxx-aarch64.c
@@ -0,0 +1,522 @@
+/* AArch64-specific support for ELF.
+   Copyright 2009-2013  Free Software Foundation, Inc.
+   Contributed by ARM Ltd.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; see the file COPYING3. If not,
+   see <http://www.gnu.org/licenses/>.  */
+
+#include "sysdep.h"
+#include "elfxx-aarch64.h"
+
+#define MASK(n) ((1u << (n)) - 1)
+
+/* Decode the 26-bit offset of unconditional branch.  */
+static inline uint32_t
+decode_branch_ofs_26 (uint32_t insn)
+{
+  return insn & MASK (26);
+}
+
+/* Decode the 19-bit offset of conditional branch and compare & branch.  */
+static inline uint32_t
+decode_cond_branch_ofs_19 (uint32_t insn)
+{
+  return (insn >> 5) & MASK (19);
+}
+
+/* Decode the 19-bit offset of load literal.  */
+static inline uint32_t
+decode_ld_lit_ofs_19 (uint32_t insn)
+{
+  return (insn >> 5) & MASK (19);
+}
+
+/* Decode the 14-bit offset of test & branch.  */
+static inline uint32_t
+decode_tst_branch_ofs_14 (uint32_t insn)
+{
+  return (insn >> 5) & MASK (14);
+}
+
+/* Decode the 16-bit imm of move wide.  */
+static inline uint32_t
+decode_movw_imm (uint32_t insn)
+{
+  return (insn >> 5) & MASK (16);
+}
+
+/* Decode the 12-bit imm of add immediate.  */
+static inline uint32_t
+decode_add_imm (uint32_t insn)
+{
+  return (insn >> 10) & MASK (12);
+}
+
+/* Reencode the imm field of add immediate.  */
+static inline uint32_t
+reencode_add_imm (uint32_t insn, uint32_t imm)
+{
+  return (insn & ~(MASK (12) << 10)) | ((imm & MASK (12)) << 10);
+}
+
+/* Reencode the imm field of adr.  */
+static inline uint32_t
+reencode_adr_imm (uint32_t insn, uint32_t imm)
+{
+  return (insn & ~((MASK (2) << 29) | (MASK (19) << 5)))
+    | ((imm & MASK (2)) << 29) | ((imm & (MASK (19) << 2)) << 3);
+}
+
+/* Reencode the imm field of ld/st pos immediate.  */
+static inline uint32_t
+reencode_ldst_pos_imm (uint32_t insn, uint32_t imm)
+{
+  return (insn & ~(MASK (12) << 10)) | ((imm & MASK (12)) << 10);
+}
+
+/* Encode the 26-bit offset of unconditional branch.  */
+static inline uint32_t
+reencode_branch_ofs_26 (uint32_t insn, uint32_t ofs)
+{
+  return (insn & ~MASK (26)) | (ofs & MASK (26));
+}
+
+/* Encode the 19-bit offset of conditional branch and compare & branch.  */
+static inline uint32_t
+reencode_cond_branch_ofs_19 (uint32_t insn, uint32_t ofs)
+{
+  return (insn & ~(MASK (19) << 5)) | ((ofs & MASK (19)) << 5);
+}
+
+/* Decode the 19-bit offset of load literal.  */
+static inline uint32_t
+reencode_ld_lit_ofs_19 (uint32_t insn, uint32_t ofs)
+{
+  return (insn & ~(MASK (19) << 5)) | ((ofs & MASK (19)) << 5);
+}
+
+/* Encode the 14-bit offset of test & branch.  */
+static inline uint32_t
+reencode_tst_branch_ofs_14 (uint32_t insn, uint32_t ofs)
+{
+  return (insn & ~(MASK (14) << 5)) | ((ofs & MASK (14)) << 5);
+}
+
+/* Reencode the imm field of move wide.  */
+static inline uint32_t
+reencode_movw_imm (uint32_t insn, uint32_t imm)
+{
+  return (insn & ~(MASK (16) << 5)) | ((imm & MASK (16)) << 5);
+}
+
+/* Reencode mov[zn] to movz.  */
+static inline uint32_t
+reencode_movzn_to_movz (uint32_t opcode)
+{
+  return opcode | (1 << 30);
+}
+
+/* Reencode mov[zn] to movn.  */
+static inline uint32_t
+reencode_movzn_to_movn (uint32_t opcode)
+{
+  return opcode & ~(1 << 30);
+}
+
+/* Return non-zero if the indicated VALUE has overflowed the maximum
+   range expressible by a unsigned number with the indicated number of
+   BITS.  */
+
+static bfd_reloc_status_type
+aarch64_unsigned_overflow (bfd_vma value, unsigned int bits)
+{
+  bfd_vma lim;
+  if (bits >= sizeof (bfd_vma) * 8)
+    return bfd_reloc_ok;
+  lim = (bfd_vma) 1 << bits;
+  if (value >= lim)
+    return bfd_reloc_overflow;
+  return bfd_reloc_ok;
+}
+
+/* Return non-zero if the indicated VALUE has overflowed the maximum
+   range expressible by an signed number with the indicated number of
+   BITS.  */
+
+static bfd_reloc_status_type
+aarch64_signed_overflow (bfd_vma value, unsigned int bits)
+{
+  bfd_signed_vma svalue = (bfd_signed_vma) value;
+  bfd_signed_vma lim;
+
+  if (bits >= sizeof (bfd_vma) * 8)
+    return bfd_reloc_ok;
+  lim = (bfd_signed_vma) 1 << (bits - 1);
+  if (svalue < -lim || svalue >= lim)
+    return bfd_reloc_overflow;
+  return bfd_reloc_ok;
+}
+
+/* Insert the addend/value into the instruction or data object being
+   relocated.  */
+bfd_reloc_status_type
+_bfd_aarch64_elf_put_addend (bfd *abfd,
+			     bfd_byte *address, bfd_reloc_code_real_type r_type,
+			     reloc_howto_type *howto, bfd_signed_vma addend)
+{
+  bfd_reloc_status_type status = bfd_reloc_ok;
+  bfd_signed_vma old_addend = addend;
+  bfd_vma contents;
+  int size;
+
+  size = bfd_get_reloc_size (howto);
+  switch (size)
+    {
+    case 2:
+      contents = bfd_get_16 (abfd, address);
+      break;
+    case 4:
+      if (howto->src_mask != 0xffffffff)
+	/* Must be 32-bit instruction, always little-endian.  */
+	contents = bfd_getl32 (address);
+      else
+	/* Must be 32-bit data (endianness dependent).  */
+	contents = bfd_get_32 (abfd, address);
+      break;
+    case 8:
+      contents = bfd_get_64 (abfd, address);
+      break;
+    default:
+      abort ();
+    }
+
+  switch (howto->complain_on_overflow)
+    {
+    case complain_overflow_dont:
+      break;
+    case complain_overflow_signed:
+      status = aarch64_signed_overflow (addend,
+					howto->bitsize + howto->rightshift);
+      break;
+    case complain_overflow_unsigned:
+      status = aarch64_unsigned_overflow (addend,
+					  howto->bitsize + howto->rightshift);
+      break;
+    case complain_overflow_bitfield:
+    default:
+      abort ();
+    }
+
+  addend >>= howto->rightshift;
+
+  switch (r_type)
+    {
+    case BFD_RELOC_AARCH64_JUMP26:
+    case BFD_RELOC_AARCH64_CALL26:
+      contents = reencode_branch_ofs_26 (contents, addend);
+      break;
+
+    case BFD_RELOC_AARCH64_BRANCH19:
+      contents = reencode_cond_branch_ofs_19 (contents, addend);
+      break;
+
+    case BFD_RELOC_AARCH64_TSTBR14:
+      contents = reencode_tst_branch_ofs_14 (contents, addend);
+      break;
+
+    case BFD_RELOC_AARCH64_LD_LO19_PCREL:
+    case BFD_RELOC_AARCH64_GOT_LD_PREL19:
+      if (old_addend & ((1 << howto->rightshift) - 1))
+	return bfd_reloc_overflow;
+      contents = reencode_ld_lit_ofs_19 (contents, addend);
+      break;
+
+    case BFD_RELOC_AARCH64_TLSDESC_CALL:
+      break;
+
+    case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+    case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
+    case BFD_RELOC_AARCH64_ADR_LO21_PCREL:
+    case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
+    case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
+      contents = reencode_adr_imm (contents, addend);
+      break;
+
+    case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_ADD_LO12:
+      /* Corresponds to: add rd, rn, #uimm12 to provide the low order
+         12 bits of the page offset following
+         BFD_RELOC_AARCH64_ADR_HI21_PCREL which computes the
+         (pc-relative) page base.  */
+      contents = reencode_add_imm (contents, addend);
+      break;
+
+    case BFD_RELOC_AARCH64_LDST8_LO12:
+    case BFD_RELOC_AARCH64_LDST16_LO12:
+    case BFD_RELOC_AARCH64_LDST32_LO12:
+    case BFD_RELOC_AARCH64_LDST64_LO12:
+    case BFD_RELOC_AARCH64_LDST128_LO12:
+    case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
+    case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC:
+      if (old_addend & ((1 << howto->rightshift) - 1))
+	return bfd_reloc_overflow;
+      /* Used for ldr*|str* rt, [rn, #uimm12] to provide the low order
+         12 bits of the page offset following BFD_RELOC_AARCH64_ADR_HI21_PCREL
+         which computes the (pc-relative) page base.  */
+      contents = reencode_ldst_pos_imm (contents, addend);
+      break;
+
+      /* Group relocations to create high bits of a 16, 32, 48 or 64
+         bit signed data or abs address inline. Will change
+         instruction to MOVN or MOVZ depending on sign of calculated
+         value.  */
+
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
+    case BFD_RELOC_AARCH64_MOVW_G0_S:
+    case BFD_RELOC_AARCH64_MOVW_G1_S:
+    case BFD_RELOC_AARCH64_MOVW_G2_S:
+      /* NOTE: We can only come here with movz or movn.  */
+      if (addend < 0)
+	{
+	  /* Force use of MOVN.  */
+	  addend = ~addend;
+	  contents = reencode_movzn_to_movn (contents);
+	}
+      else
+	{
+	  /* Force use of MOVZ.  */
+	  contents = reencode_movzn_to_movz (contents);
+	}
+      /* fall through */
+
+      /* Group relocations to create a 16, 32, 48 or 64 bit unsigned
+         data or abs address inline.  */
+
+    case BFD_RELOC_AARCH64_MOVW_G0:
+    case BFD_RELOC_AARCH64_MOVW_G0_NC:
+    case BFD_RELOC_AARCH64_MOVW_G1:
+    case BFD_RELOC_AARCH64_MOVW_G1_NC:
+    case BFD_RELOC_AARCH64_MOVW_G2:
+    case BFD_RELOC_AARCH64_MOVW_G2_NC:
+    case BFD_RELOC_AARCH64_MOVW_G3:
+      contents = reencode_movw_imm (contents, addend);
+      break;
+
+    default:
+      /* Repack simple data */
+      if (howto->dst_mask & (howto->dst_mask + 1))
+	return bfd_reloc_notsupported;
+
+      contents = ((contents & ~howto->dst_mask) | (addend & howto->dst_mask));
+      break;
+    }
+
+  switch (size)
+    {
+    case 2:
+      bfd_put_16 (abfd, contents, address);
+      break;
+    case 4:
+      if (howto->dst_mask != 0xffffffff)
+	/* must be 32-bit instruction, always little-endian */
+	bfd_putl32 (contents, address);
+      else
+	/* must be 32-bit data (endianness dependent) */
+	bfd_put_32 (abfd, contents, address);
+      break;
+    case 8:
+      bfd_put_64 (abfd, contents, address);
+      break;
+    default:
+      abort ();
+    }
+
+  return status;
+}
+
+bfd_vma
+_bfd_aarch64_elf_resolve_relocation (bfd_reloc_code_real_type r_type,
+				     bfd_vma place, bfd_vma value,
+				     bfd_vma addend, bfd_boolean weak_undef_p)
+{
+  switch (r_type)
+    {
+    case BFD_RELOC_AARCH64_TLSDESC_CALL:
+    case BFD_RELOC_AARCH64_NONE:
+      break;
+
+    case BFD_RELOC_AARCH64_ADR_LO21_PCREL:
+    case BFD_RELOC_AARCH64_BRANCH19:
+    case BFD_RELOC_AARCH64_LD_LO19_PCREL:
+    case BFD_RELOC_AARCH64_16_PCREL:
+    case BFD_RELOC_AARCH64_32_PCREL:
+    case BFD_RELOC_AARCH64_64_PCREL:
+    case BFD_RELOC_AARCH64_TSTBR14:
+      if (weak_undef_p)
+	value = place;
+      value = value + addend - place;
+      break;
+
+    case BFD_RELOC_AARCH64_CALL26:
+    case BFD_RELOC_AARCH64_JUMP26:
+      value = value + addend - place;
+      break;
+
+    case BFD_RELOC_AARCH64_16:
+    case BFD_RELOC_AARCH64_32:
+    case BFD_RELOC_AARCH64_MOVW_G0_S:
+    case BFD_RELOC_AARCH64_MOVW_G1_S:
+    case BFD_RELOC_AARCH64_MOVW_G2_S:
+    case BFD_RELOC_AARCH64_MOVW_G0:
+    case BFD_RELOC_AARCH64_MOVW_G0_NC:
+    case BFD_RELOC_AARCH64_MOVW_G1:
+    case BFD_RELOC_AARCH64_MOVW_G1_NC:
+    case BFD_RELOC_AARCH64_MOVW_G2:
+    case BFD_RELOC_AARCH64_MOVW_G2_NC:
+    case BFD_RELOC_AARCH64_MOVW_G3:
+      value = value + addend;
+      break;
+
+    case BFD_RELOC_AARCH64_ADR_HI21_PCREL:
+    case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL:
+      if (weak_undef_p)
+	value = PG (place);
+      value = PG (value + addend) - PG (place);
+      break;
+
+    case BFD_RELOC_AARCH64_GOT_LD_PREL19:
+      value = value + addend - place;
+      break;
+
+    case BFD_RELOC_AARCH64_ADR_GOT_PAGE:
+    case BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
+    case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
+      value = PG (value + addend) - PG (place);
+      break;
+
+    case BFD_RELOC_AARCH64_ADD_LO12:
+    case BFD_RELOC_AARCH64_LD64_GOT_LO12_NC:
+    case BFD_RELOC_AARCH64_LD32_GOT_LO12_NC:
+    case BFD_RELOC_AARCH64_LDST8_LO12:
+    case BFD_RELOC_AARCH64_LDST16_LO12:
+    case BFD_RELOC_AARCH64_LDST32_LO12:
+    case BFD_RELOC_AARCH64_LDST64_LO12:
+    case BFD_RELOC_AARCH64_LDST128_LO12:
+    case BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_ADD:
+    case BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSDESC_LDR:
+    case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12:
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
+      value = PG_OFFSET (value + addend);
+      break;
+
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC:
+      value = (value + addend) & (bfd_vma) 0xffff0000;
+      break;
+    case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12:
+      value = (value + addend) & (bfd_vma) 0xfff000;
+      break;
+
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0:
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
+      value = (value + addend) & (bfd_vma) 0xffff;
+      break;
+
+    case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2:
+      value = (value + addend) & ~(bfd_vma) 0xffffffff;
+      value -= place & ~(bfd_vma) 0xffffffff;
+      break;
+
+    default:
+      break;
+    }
+
+  return value;
+}
+
+/* Hook called by the linker routine which adds symbols from an object
+   file.  */
+
+bfd_boolean
+_bfd_aarch64_elf_add_symbol_hook (bfd *abfd, struct bfd_link_info *info,
+				  Elf_Internal_Sym *sym,
+				  const char **namep ATTRIBUTE_UNUSED,
+				  flagword *flagsp ATTRIBUTE_UNUSED,
+				  asection **secp ATTRIBUTE_UNUSED,
+				  bfd_vma *valp ATTRIBUTE_UNUSED)
+{
+  if ((abfd->flags & DYNAMIC) == 0
+      && (ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC
+	  || ELF_ST_BIND (sym->st_info) == STB_GNU_UNIQUE))
+    elf_tdata (info->output_bfd)->has_gnu_symbols = TRUE;
+
+  return TRUE;
+}
+
+/* Support for core dump NOTE sections.  */
+
+bfd_boolean
+_bfd_aarch64_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
+{
+  int offset;
+  size_t size;
+
+  switch (note->descsz)
+    {
+      default:
+	return FALSE;
+
+      case 392:		/* sizeof(struct elf_prstatus) on Linux/arm64.  */
+	/* pr_cursig */
+	elf_tdata (abfd)->core->signal
+	  = bfd_get_16 (abfd, note->descdata + 12);
+
+	/* pr_pid */
+	elf_tdata (abfd)->core->lwpid
+	  = bfd_get_32 (abfd, note->descdata + 32);
+
+	/* pr_reg */
+	offset = 112;
+	size = 272;
+
+	break;
+    }
+
+  /* Make a ".reg/999" section.  */
+  return _bfd_elfcore_make_pseudosection (abfd, ".reg",
+					  size, note->descpos + offset);
+}
diff --git a/bfd/elfxx-aarch64.h b/bfd/elfxx-aarch64.h
new file mode 100644
index 0000000..dece641
--- /dev/null
+++ b/bfd/elfxx-aarch64.h
@@ -0,0 +1,47 @@
+/* AArch64-specific backend routines.
+   Copyright 2009-2013  Free Software Foundation, Inc.
+   Contributed by ARM Ltd.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; see the file COPYING3. If not,
+   see <http://www.gnu.org/licenses/>.  */
+
+#include "bfd.h"
+#include "elf-bfd.h"
+#include "stdint.h"
+
+/* Take the PAGE component of an address or offset.  */
+#define PG(x) ((x) & ~ (bfd_vma) 0xfff)
+#define PG_OFFSET(x) ((x) & (bfd_vma) 0xfff)
+
+extern bfd_reloc_status_type
+_bfd_aarch64_elf_put_addend (bfd *, bfd_byte *, bfd_reloc_code_real_type,
+			     reloc_howto_type *, bfd_signed_vma);
+
+extern bfd_vma
+_bfd_aarch64_elf_resolve_relocation (bfd_reloc_code_real_type, bfd_vma, bfd_vma,
+				     bfd_vma, bfd_boolean);
+
+extern bfd_boolean
+_bfd_aarch64_elf_add_symbol_hook (bfd *, struct bfd_link_info *,
+				  Elf_Internal_Sym *, const char **,
+				  flagword *, asection **, bfd_vma *);
+
+extern bfd_boolean
+_bfd_aarch64_elf_grok_prstatus (bfd *, Elf_Internal_Note *);
+
+
+#define elf_backend_add_symbol_hook	_bfd_aarch64_elf_add_symbol_hook
+#define elf_backend_grok_prstatus	_bfd_aarch64_elf_grok_prstatus
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 5a9d158..d7498e1 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -1,7 +1,5 @@
 /* MIPS-specific support for ELF
-   Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright 1993-2013 Free Software Foundation, Inc.
 
    Most of the information added by Ian Lance Taylor, Cygnus Support,
    <[email protected]>.
@@ -47,42 +45,35 @@
 
 #include "hashtab.h"
 
+/* Types of TLS GOT entry.  */
+enum mips_got_tls_type {
+  GOT_TLS_NONE,
+  GOT_TLS_GD,
+  GOT_TLS_LDM,
+  GOT_TLS_IE
+};
+
 /* This structure is used to hold information about one GOT entry.
-   There are three types of entry:
+   There are four types of entry:
 
-      (1) absolute addresses
-	    (abfd == NULL)
-      (2) SYMBOL + OFFSET addresses, where SYMBOL is local to an input bfd
-	    (abfd != NULL, symndx >= 0)
-      (3) SYMBOL addresses, where SYMBOL is not local to an input bfd
-	    (abfd != NULL, symndx == -1)
+      (1) an absolute address
+	    requires: abfd == NULL
+	    fields: d.address
 
-   Type (3) entries are treated differently for different types of GOT.
-   In the "master" GOT -- i.e.  the one that describes every GOT
-   reference needed in the link -- the mips_got_entry is keyed on both
-   the symbol and the input bfd that references it.  If it turns out
-   that we need multiple GOTs, we can then use this information to
-   create separate GOTs for each input bfd.
+      (2) a SYMBOL + OFFSET address, where SYMBOL is local to an input bfd
+	    requires: abfd != NULL, symndx >= 0, tls_type != GOT_TLS_LDM
+	    fields: abfd, symndx, d.addend, tls_type
 
-   However, we want each of these separate GOTs to have at most one
-   entry for a given symbol, so their type (3) entries are keyed only
-   on the symbol.  The input bfd given by the "abfd" field is somewhat
-   arbitrary in this case.
+      (3) a SYMBOL address, where SYMBOL is not local to an input bfd
+	    requires: abfd != NULL, symndx == -1
+	    fields: d.h, tls_type
 
-   This means that when there are multiple GOTs, each GOT has a unique
-   mips_got_entry for every symbol within it.  We can therefore use the
-   mips_got_entry fields (tls_type and gotidx) to track the symbol's
-   GOT index.
-
-   However, if it turns out that we need only a single GOT, we continue
-   to use the master GOT to describe it.  There may therefore be several
-   mips_got_entries for the same symbol, each with a different input bfd.
-   We want to make sure that each symbol gets a unique GOT entry, so when
-   there's a single GOT, we use the symbol's hash entry, not the
-   mips_got_entry fields, to track a symbol's GOT index.  */
+      (4) a TLS LDM slot
+	    requires: abfd != NULL, symndx == 0, tls_type == GOT_TLS_LDM
+	    fields: none; there's only one of these per GOT.  */
 struct mips_got_entry
 {
-  /* The input bfd in which the symbol is defined.  */
+  /* One input bfd that needs the GOT entry.  */
   bfd *abfd;
   /* The index of the symbol, as stored in the relocation r_info, if
      we have a local symbol; -1 otherwise.  */
@@ -95,25 +86,47 @@
        that should be added to the symbol value.  */
     bfd_vma addend;
     /* If abfd != NULL && symndx == -1, the hash table entry
-       corresponding to symbol in the GOT.  The symbol's entry
+       corresponding to a symbol in the GOT.  The symbol's entry
        is in the local area if h->global_got_area is GGA_NONE,
        otherwise it is in the global area.  */
     struct mips_elf_link_hash_entry *h;
   } d;
 
-  /* The TLS types included in this GOT entry (specifically, GD and
-     IE).  The GD and IE flags can be added as we encounter new
-     relocations.  LDM can also be set; it will always be alone, not
-     combined with any GD or IE flags.  An LDM GOT entry will be
-     a local symbol entry with r_symndx == 0.  */
+  /* The TLS type of this GOT entry.  An LDM GOT entry will be a local
+     symbol entry with r_symndx == 0.  */
   unsigned char tls_type;
 
+  /* True if we have filled in the GOT contents for a TLS entry,
+     and created the associated relocations.  */
+  unsigned char tls_initialized;
+
   /* The offset from the beginning of the .got section to the entry
      corresponding to this symbol+addend.  If it's a global symbol
      whose offset is yet to be decided, it's going to be -1.  */
   long gotidx;
 };
 
+/* This structure represents a GOT page reference from an input bfd.
+   Each instance represents a symbol + ADDEND, where the representation
+   of the symbol depends on whether it is local to the input bfd.
+   If it is, then SYMNDX >= 0, and the symbol has index SYMNDX in U.ABFD.
+   Otherwise, SYMNDX < 0 and U.H points to the symbol's hash table entry.
+
+   Page references with SYMNDX >= 0 always become page references
+   in the output.  Page references with SYMNDX < 0 only become page
+   references if the symbol binds locally; in other cases, the page
+   reference decays to a global GOT reference.  */
+struct mips_got_page_ref
+{
+  long symndx;
+  union
+  {
+    struct mips_elf_link_hash_entry *h;
+    bfd *abfd;
+  } u;
+  bfd_vma addend;
+};
+
 /* This structure describes a range of addends: [MIN_ADDEND, MAX_ADDEND].
    The structures form a non-overlapping list that is sorted by increasing
    MIN_ADDEND.  */
@@ -125,13 +138,11 @@
 };
 
 /* This structure describes the range of addends that are applied to page
-   relocations against a given symbol.  */
+   relocations against a given section.  */
 struct mips_got_page_entry
 {
-  /* The input bfd in which the symbol is defined.  */
-  bfd *abfd;
-  /* The index of the symbol, as stored in the relocation r_info.  */
-  long symndx;
+  /* The section that these entries are based on.  */
+  asection *sec;
   /* The ranges for this page entry.  */
   struct mips_got_page_range *ranges;
   /* The maximum number of page entries needed for RANGES.  */
@@ -142,9 +153,6 @@
 
 struct mips_got_info
 {
-  /* The global symbol in the GOT with the lowest index in the dynamic
-     symbol table.  */
-  struct elf_link_hash_entry *global_gotsym;
   /* The number of global .got entries.  */
   unsigned int global_gotno;
   /* The number of global .got entries that are in the GGA_RELOC_ONLY area.  */
@@ -158,40 +166,25 @@
   unsigned int local_gotno;
   /* The maximum number of page entries needed.  */
   unsigned int page_gotno;
+  /* The number of relocations needed for the GOT entries.  */
+  unsigned int relocs;
   /* The number of local .got entries we have used.  */
   unsigned int assigned_gotno;
   /* A hash table holding members of the got.  */
   struct htab *got_entries;
+  /* A hash table holding mips_got_page_ref structures.  */
+  struct htab *got_page_refs;
   /* A hash table of mips_got_page_entry structures.  */
   struct htab *got_page_entries;
-  /* A hash table mapping input bfds to other mips_got_info.  NULL
-     unless multi-got was necessary.  */
-  struct htab *bfd2got;
   /* In multi-got links, a pointer to the next got (err, rather, most
      of the time, it points to the previous got).  */
   struct mips_got_info *next;
-  /* This is the GOT index of the TLS LDM entry for the GOT, MINUS_ONE
-     for none, or MINUS_TWO for not yet assigned.  This is needed
-     because a single-GOT link may have multiple hash table entries
-     for the LDM.  It does not get initialized in multi-GOT mode.  */
-  bfd_vma tls_ldm_offset;
 };
 
-/* Map an input bfd to a got in a multi-got link.  */
-
-struct mips_elf_bfd2got_hash
-{
-  bfd *bfd;
-  struct mips_got_info *g;
-};
-
-/* Structure passed when traversing the bfd2got hash table, used to
-   create and merge bfd's gots.  */
+/* Structure passed when merging bfds' gots.  */
 
 struct mips_elf_got_per_bfd_arg
 {
-  /* A hashtable that maps bfds to gots.  */
-  htab_t bfd2got;
   /* The output bfd.  */
   bfd *obfd;
   /* The link information.  */
@@ -215,23 +208,14 @@
   unsigned int global_count;
 };
 
-/* Another structure used to pass arguments for got entries traversal.  */
+/* A structure used to pass information to htab_traverse callbacks
+   when laying out the GOT.  */
 
-struct mips_elf_set_global_got_offset_arg
+struct mips_elf_traverse_got_arg
 {
+  struct bfd_link_info *info;
   struct mips_got_info *g;
   int value;
-  unsigned int needed_relocs;
-  struct bfd_link_info *info;
-};
-
-/* A structure used to count TLS relocations or GOT entries, for GOT
-   entry or ELF symbol table traversal.  */
-
-struct mips_elf_count_tls_arg
-{
-  struct bfd_link_info *info;
-  unsigned int needed;
 };
 
 struct _mips_elf_section_data
@@ -306,12 +290,12 @@
 #define LA25_LUI(VAL) (0x3c190000 | (VAL))	/* lui t9,VAL */
 #define LA25_J(VAL) (0x08000000 | (((VAL) >> 2) & 0x3ffffff)) /* j VAL */
 #define LA25_ADDIU(VAL) (0x27390000 | (VAL))	/* addiu t9,t9,VAL */
-#define LA25_LUI_MICROMIPS_1(VAL) (0x41b9)	/* lui t9,VAL */
-#define LA25_LUI_MICROMIPS_2(VAL) (VAL)
-#define LA25_J_MICROMIPS_1(VAL) (0xd400 | (((VAL) >> 17) & 0x3ff)) /* j VAL */
-#define LA25_J_MICROMIPS_2(VAL) ((VAL) >> 1)
-#define LA25_ADDIU_MICROMIPS_1(VAL) (0x3339)	/* addiu t9,t9,VAL */
-#define LA25_ADDIU_MICROMIPS_2(VAL) (VAL)
+#define LA25_LUI_MICROMIPS(VAL)						\
+  (0x41b90000 | (VAL))				/* lui t9,VAL */
+#define LA25_J_MICROMIPS(VAL)						\
+  (0xd4000000 | (((VAL) >> 1) & 0x3ffffff))	/* j VAL */
+#define LA25_ADDIU_MICROMIPS(VAL)					\
+  (0x33390000 | (VAL))				/* addiu t9,t9,VAL */
 
 /* This structure is passed to mips_elf_sort_hash_table_f when sorting
    the dynamic symbols.  */
@@ -333,6 +317,32 @@
   long max_non_got_dynindx;
 };
 
+/* We make up to two PLT entries if needed, one for standard MIPS code
+   and one for compressed code, either a MIPS16 or microMIPS one.  We
+   keep a separate record of traditional lazy-binding stubs, for easier
+   processing.  */
+
+struct plt_entry
+{
+  /* Traditional SVR4 stub offset, or -1 if none.  */
+  bfd_vma stub_offset;
+
+  /* Standard PLT entry offset, or -1 if none.  */
+  bfd_vma mips_offset;
+
+  /* Compressed PLT entry offset, or -1 if none.  */
+  bfd_vma comp_offset;
+
+  /* The corresponding .got.plt index, or -1 if none.  */
+  bfd_vma gotplt_index;
+
+  /* Whether we need a standard PLT entry.  */
+  unsigned int need_mips : 1;
+
+  /* Whether we need a compressed PLT entry.  */
+  unsigned int need_comp : 1;
+};
+
 /* The MIPS ELF linker needs additional information for each symbol in
    the global hash table.  */
 
@@ -362,22 +372,6 @@
      being called returns a floating point value.  */
   asection *call_fp_stub;
 
-#define GOT_NORMAL	0
-#define GOT_TLS_GD	1
-#define GOT_TLS_LDM	2
-#define GOT_TLS_IE	4
-#define GOT_TLS_OFFSET_DONE    0x40
-#define GOT_TLS_DONE    0x80
-  unsigned char tls_type;
-
-  /* This is only used in single-GOT mode; in multi-GOT mode there
-     is one mips_got_entry per GOT entry, so the offset is stored
-     there.  In single-GOT mode there may be many mips_got_entry
-     structures all referring to the same GOT slot.  It might be
-     possible to use root.got.offset instead, but that field is
-     overloaded already.  */
-  bfd_vma tls_got_offset;
-
   /* The highest GGA_* value that satisfies all references to this symbol.  */
   unsigned int global_got_area : 2;
 
@@ -413,6 +407,9 @@
   /* Does this symbol need a traditional MIPS lazy-binding stub
      (as opposed to a PLT entry)?  */
   unsigned int needs_lazy_stub : 1;
+
+  /* Does this symbol resolve to a PLT entry?  */
+  unsigned int use_plt_entry : 1;
 };
 
 /* MIPS ELF linker hash table.  */
@@ -420,11 +417,6 @@
 struct mips_elf_link_hash_table
 {
   struct elf_link_hash_table root;
-#if 0
-  /* We no longer use this.  */
-  /* String section indices for the dynamic section symbols.  */
-  bfd_size_type dynsym_sec_strindex[SIZEOF_MIPS_DYNSYM_SECNAMES];
-#endif
 
   /* The number of .rtproc entries.  */
   bfd_size_type procedure_count;
@@ -432,12 +424,12 @@
   /* The size of the .compact_rel section (if SGI_COMPAT).  */
   bfd_size_type compact_rel_size;
 
-  /* This flag indicates that the value of DT_MIPS_RLD_MAP dynamic
-     entry is set to the address of __rld_obj_head as in IRIX5.  */
+  /* This flag indicates that the value of DT_MIPS_RLD_MAP dynamic entry
+     is set to the address of __rld_obj_head as in IRIX5 and IRIX6.  */
   bfd_boolean use_rld_obj_head;
 
-  /* This is the value of the __rld_map or __rld_obj_head symbol.  */
-  bfd_vma rld_value;
+  /* The  __rld_map or __rld_obj_head symbol. */
+  struct elf_link_hash_entry *rld_symbol;
 
   /* This is set if we see any mips16 stub sections.  */
   bfd_boolean mips16_stubs_seen;
@@ -445,6 +437,9 @@
   /* True if we can generate copy relocs and PLTs.  */
   bfd_boolean use_plts_and_copy_relocs;
 
+  /* True if we can only use 32-bit microMIPS instructions.  */
+  bfd_boolean insn32;
+
   /* True if we're generating code for VxWorks.  */
   bfd_boolean is_vxworks;
 
@@ -465,11 +460,27 @@
   /* The master GOT information.  */
   struct mips_got_info *got_info;
 
+  /* The global symbol in the GOT with the lowest index in the dynamic
+     symbol table.  */
+  struct elf_link_hash_entry *global_gotsym;
+
   /* The size of the PLT header in bytes.  */
   bfd_vma plt_header_size;
 
-  /* The size of a PLT entry in bytes.  */
-  bfd_vma plt_entry_size;
+  /* The size of a standard PLT entry in bytes.  */
+  bfd_vma plt_mips_entry_size;
+
+  /* The size of a compressed PLT entry in bytes.  */
+  bfd_vma plt_comp_entry_size;
+
+  /* The offset of the next standard PLT entry to create.  */
+  bfd_vma plt_mips_offset;
+
+  /* The offset of the next compressed PLT entry to create.  */
+  bfd_vma plt_comp_offset;
+
+  /* The index of the next .got.plt entry to create.  */
+  bfd_vma plt_got_index;
 
   /* The number of functions that need a lazy-binding stub.  */
   bfd_vma lazy_stub_count;
@@ -496,6 +507,12 @@
      The function returns the new section on success, otherwise it
      returns null.  */
   asection *(*add_stub_section) (const char *, asection *, asection *);
+
+  /* Small local sym cache.  */
+  struct sym_cache sym_cache;
+
+  /* Is the PLT header compressed?  */
+  unsigned int plt_header_is_comp : 1;
 };
 
 /* Get the MIPS ELF linker hash table from a link_info structure.  */
@@ -515,6 +532,41 @@
   bfd_boolean error;
 };
 
+/* MIPS ELF private object data.  */
+
+struct mips_elf_obj_tdata
+{
+  /* Generic ELF private object data.  */
+  struct elf_obj_tdata root;
+
+  /* Input BFD providing Tag_GNU_MIPS_ABI_FP attribute for output.  */
+  bfd *abi_fp_bfd;
+
+  /* The GOT requirements of input bfds.  */
+  struct mips_got_info *got;
+
+  /* Used by _bfd_mips_elf_find_nearest_line.  The structure could be
+     included directly in this one, but there's no point to wasting
+     the memory just for the infrequently called find_nearest_line.  */
+  struct mips_elf_find_line *find_line_info;
+
+  /* An array of stub sections indexed by symbol number.  */
+  asection **local_stubs;
+  asection **local_call_stubs;
+
+  /* The Irix 5 support uses two virtual sections, which represent
+     text/data symbols defined in dynamic objects.  */
+  asymbol *elf_data_symbol;
+  asymbol *elf_text_symbol;
+  asection *elf_data_section;
+  asection *elf_text_section;
+};
+
+/* Get MIPS ELF private object data from BFD's tdata.  */
+
+#define mips_elf_tdata(bfd) \
+  ((struct mips_elf_obj_tdata *) (bfd)->tdata.any)
+
 #define TLS_RELOC_P(r_type) \
   (r_type == R_MIPS_TLS_DTPMOD32		\
    || r_type == R_MIPS_TLS_DTPMOD64		\
@@ -529,6 +581,13 @@
    || r_type == R_MIPS_TLS_TPREL64		\
    || r_type == R_MIPS_TLS_TPREL_HI16		\
    || r_type == R_MIPS_TLS_TPREL_LO16		\
+   || r_type == R_MIPS16_TLS_GD			\
+   || r_type == R_MIPS16_TLS_LDM		\
+   || r_type == R_MIPS16_TLS_DTPREL_HI16	\
+   || r_type == R_MIPS16_TLS_DTPREL_LO16	\
+   || r_type == R_MIPS16_TLS_GOTTPREL		\
+   || r_type == R_MIPS16_TLS_TPREL_HI16		\
+   || r_type == R_MIPS16_TLS_TPREL_LO16		\
    || r_type == R_MICROMIPS_TLS_GD		\
    || r_type == R_MICROMIPS_TLS_LDM		\
    || r_type == R_MICROMIPS_TLS_DTPREL_HI16	\
@@ -680,12 +739,8 @@
   (bfd *, struct bfd_link_info *, const Elf_Internal_Rela *,
    struct mips_elf_link_hash_entry *, asection *, bfd_vma,
    bfd_vma *, asection *);
-static hashval_t mips_elf_got_entry_hash
-  (const void *);
 static bfd_vma mips_elf_adjust_gp
   (bfd *, struct mips_got_info *, bfd *);
-static struct mips_got_info *mips_elf_got_for_ibfd
-  (struct mips_got_info *, bfd *);
 
 /* This will be used when we sort the dynamic relocation records.  */
 static bfd *reldyn_sorting_bfd;
@@ -727,6 +782,10 @@
 /* Nonzero if ABFD is using NewABI conventions.  */
 #define NEWABI_P(abfd) (ABI_N32_P (abfd) || ABI_64_P (abfd))
 
+/* Nonzero if ABFD has microMIPS code.  */
+#define MICROMIPS_P(abfd) \
+  ((elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH_ASE_MICROMIPS) != 0)
+
 /* The IRIX compatibility level we are striving for.  */
 #define IRIX_COMPAT(abfd) \
   (get_elf_backend_data (abfd)->elf_backend_mips_irix_compat (abfd))
@@ -768,6 +827,10 @@
 #define MIPS_ELF_GOT_SIZE(abfd) \
   (get_elf_backend_data (abfd)->s->arch_size / 8)
 
+/* The size of the .rld_map section. */
+#define MIPS_ELF_RLD_MAP_SIZE(abfd) \
+  (get_elf_backend_data (abfd)->s->arch_size / 8)
+
 /* The size of a symbol-table entry.  */
 #define MIPS_ELF_SYM_SIZE(abfd) \
   (get_elf_backend_data (abfd)->s->sizeof_sym)
@@ -838,8 +901,35 @@
     ? (0x64180000 + (VAL))	/* daddiu t8,zero,VAL sign extended */	\
     : (0x24180000 + (VAL))))	/* addiu t8,zero,VAL sign extended */
 
+/* Likewise for the microMIPS ASE.  */
+#define STUB_LW_MICROMIPS(abfd)						\
+  (ABI_64_P (abfd)							\
+   ? 0xdf3c8010					/* ld t9,0x8010(gp) */	\
+   : 0xff3c8010)				/* lw t9,0x8010(gp) */
+#define STUB_MOVE_MICROMIPS 0x0dff		/* move t7,ra */
+#define STUB_MOVE32_MICROMIPS(abfd)					\
+   (ABI_64_P (abfd)							\
+    ? 0x581f7950				/* daddu t7,ra,zero */	\
+    : 0x001f7950)				/* addu t7,ra,zero */
+#define STUB_LUI_MICROMIPS(VAL)						\
+   (0x41b80000 + (VAL))				/* lui t8,VAL */
+#define STUB_JALR_MICROMIPS 0x45d9		/* jalr t9 */
+#define STUB_JALR32_MICROMIPS 0x03f90f3c	/* jalr ra,t9 */
+#define STUB_ORI_MICROMIPS(VAL)						\
+  (0x53180000 + (VAL))				/* ori t8,t8,VAL */
+#define STUB_LI16U_MICROMIPS(VAL)					\
+  (0x53000000 + (VAL))				/* ori t8,zero,VAL unsigned */
+#define STUB_LI16S_MICROMIPS(abfd, VAL)					\
+   (ABI_64_P (abfd)							\
+    ? 0x5f000000 + (VAL)	/* daddiu t8,zero,VAL sign extended */	\
+    : 0x33000000 + (VAL))	/* addiu t8,zero,VAL sign extended */
+
 #define MIPS_FUNCTION_STUB_NORMAL_SIZE 16
 #define MIPS_FUNCTION_STUB_BIG_SIZE 20
+#define MICROMIPS_FUNCTION_STUB_NORMAL_SIZE 12
+#define MICROMIPS_FUNCTION_STUB_BIG_SIZE 16
+#define MICROMIPS_INSN32_FUNCTION_STUB_NORMAL_SIZE 16
+#define MICROMIPS_INSN32_FUNCTION_STUB_BIG_SIZE 20
 
 /* The name of the dynamic interpreter.  This is put in the .interp
    section.  */
@@ -951,7 +1041,40 @@
   0x2718fffe	/* subu $24, $24, 2					*/
 };
 
-/* The format of subsequent PLT entries.  */
+/* The format of the microMIPS first PLT entry in an O32 executable.
+   We rely on v0 ($2) rather than t8 ($24) to contain the address
+   of the GOTPLT entry handled, so this stub may only be used when
+   all the subsequent PLT entries are microMIPS code too.
+
+   The trailing NOP is for alignment and correct disassembly only.  */
+static const bfd_vma micromips_o32_exec_plt0_entry[] =
+{
+  0x7980, 0x0000,	/* addiupc $3, (&GOTPLT[0]) - .			*/
+  0xff23, 0x0000,	/* lw $25, 0($3)				*/
+  0x0535,		/* subu $2, $2, $3				*/
+  0x2525,		/* srl $2, $2, 2				*/
+  0x3302, 0xfffe,	/* subu $24, $2, 2				*/
+  0x0dff,		/* move $15, $31				*/
+  0x45f9,		/* jalrs $25					*/
+  0x0f83,		/* move $28, $3					*/
+  0x0c00		/* nop						*/
+};
+
+/* The format of the microMIPS first PLT entry in an O32 executable
+   in the insn32 mode.  */
+static const bfd_vma micromips_insn32_o32_exec_plt0_entry[] =
+{
+  0x41bc, 0x0000,	/* lui $28, %hi(&GOTPLT[0])			*/
+  0xff3c, 0x0000,	/* lw $25, %lo(&GOTPLT[0])($28)			*/
+  0x339c, 0x0000,	/* addiu $28, $28, %lo(&GOTPLT[0])		*/
+  0x0398, 0xc1d0,	/* subu $24, $24, $28				*/
+  0x001f, 0x7950,	/* move $15, $31				*/
+  0x0318, 0x1040,	/* srl $24, $24, 2				*/
+  0x03f9, 0x0f3c,	/* jalr $25					*/
+  0x3318, 0xfffe	/* subu $24, $24, 2				*/
+};
+
+/* The format of subsequent standard PLT entries.  */
 static const bfd_vma mips_exec_plt_entry[] =
 {
   0x3c0f0000,	/* lui $15, %hi(.got.plt entry)			*/
@@ -960,6 +1083,39 @@
   0x03200008	/* jr $25					*/
 };
 
+/* The format of subsequent MIPS16 o32 PLT entries.  We use v0 ($2)
+   and v1 ($3) as temporaries because t8 ($24) and t9 ($25) are not
+   directly addressable.  */
+static const bfd_vma mips16_o32_exec_plt_entry[] =
+{
+  0xb203,		/* lw $2, 12($pc)			*/
+  0x9a60,		/* lw $3, 0($2)				*/
+  0x651a,		/* move $24, $2				*/
+  0xeb00,		/* jr $3				*/
+  0x653b,		/* move $25, $3				*/
+  0x6500,		/* nop					*/
+  0x0000, 0x0000	/* .word (.got.plt entry)		*/
+};
+
+/* The format of subsequent microMIPS o32 PLT entries.  We use v0 ($2)
+   as a temporary because t8 ($24) is not addressable with ADDIUPC.  */
+static const bfd_vma micromips_o32_exec_plt_entry[] =
+{
+  0x7900, 0x0000,	/* addiupc $2, (.got.plt entry) - .	*/
+  0xff22, 0x0000,	/* lw $25, 0($2)			*/
+  0x4599,		/* jr $25				*/
+  0x0f02		/* move $24, $2				*/
+};
+
+/* The format of subsequent microMIPS o32 PLT entries in the insn32 mode.  */
+static const bfd_vma micromips_insn32_o32_exec_plt_entry[] =
+{
+  0x41af, 0x0000,	/* lui $15, %hi(.got.plt entry)		*/
+  0xff2f, 0x0000,	/* lw $25, %lo(.got.plt entry)($15)	*/
+  0x0019, 0x0f3c,	/* jr $25				*/
+  0x330f, 0x0000	/* addiu $24, $15, %lo(.got.plt entry)	*/
+};
+
 /* The format of the first PLT entry in a VxWorks executable.  */
 static const bfd_vma mips_vxworks_exec_plt0_entry[] =
 {
@@ -1002,6 +1158,23 @@
   0x24180000	/* li t8, <pltindex>	*/
 };
 
+/* microMIPS 32-bit opcode helper installer.  */
+
+static void
+bfd_put_micromips_32 (const bfd *abfd, bfd_vma opcode, bfd_byte *ptr)
+{
+  bfd_put_16 (abfd, (opcode >> 16) & 0xffff, ptr);
+  bfd_put_16 (abfd,  opcode        & 0xffff, ptr + 2);
+}
+
+/* microMIPS 32-bit opcode helper retriever.  */
+
+static bfd_vma
+bfd_get_micromips_32 (const bfd *abfd, const bfd_byte *ptr)
+{
+  return (bfd_get_16 (abfd, ptr) << 16) | bfd_get_16 (abfd, ptr + 2);
+}
+
 /* Look up an entry in a MIPS ELF linker hash table.  */
 
 #define mips_elf_link_hash_lookup(table, string, create, copy, follow)	\
@@ -1073,7 +1246,6 @@
       ret->fn_stub = NULL;
       ret->call_stub = NULL;
       ret->call_fp_stub = NULL;
-      ret->tls_type = GOT_NORMAL;
       ret->global_got_area = GGA_NONE;
       ret->got_only_for_calls = TRUE;
       ret->readonly_reloc = FALSE;
@@ -1082,11 +1254,21 @@
       ret->need_fn_stub = FALSE;
       ret->has_nonpic_branches = FALSE;
       ret->needs_lazy_stub = FALSE;
+      ret->use_plt_entry = FALSE;
     }
 
   return (struct bfd_hash_entry *) ret;
 }
 
+/* Allocate MIPS ELF private object data.  */
+
+bfd_boolean
+_bfd_mips_elf_mkobject (bfd *abfd)
+{
+  return bfd_elf_allocate_object (abfd, sizeof (struct mips_elf_obj_tdata),
+				  MIPS_ELF_DATA);
+}
+
 bfd_boolean
 _bfd_mips_elf_new_section_hook (bfd *abfd, asection *sec)
 {
@@ -1449,14 +1631,17 @@
    function, or 0 if we can't decide which function that is.  */
 
 static unsigned long
-mips16_stub_symndx (asection *sec ATTRIBUTE_UNUSED,
+mips16_stub_symndx (const struct elf_backend_data *bed,
+		    asection *sec ATTRIBUTE_UNUSED,
 		    const Elf_Internal_Rela *relocs,
 		    const Elf_Internal_Rela *relend)
 {
+  int int_rels_per_ext_rel = bed->s->int_rels_per_ext_rel;
   const Elf_Internal_Rela *rel;
 
-  /* Trust the first R_MIPS_NONE relocation, if any.  */
-  for (rel = relocs; rel < relend; rel++)
+  /* Trust the first R_MIPS_NONE relocation, if any, but not a subsequent
+     one in a compound relocation.  */
+  for (rel = relocs; rel < relend; rel += int_rels_per_ext_rel)
     if (ELF_R_TYPE (sec->owner, rel->r_info) == R_MIPS_NONE)
       return ELF_R_SYM (sec->owner, rel->r_info);
 
@@ -1571,9 +1756,10 @@
 }
 
 /* Return true if H is a locally-defined PIC function, in the sense
-   that it might need $25 to be valid on entry.  Note that MIPS16
-   functions never need $25 to be valid on entry; they set up $gp
-   using PC-relative instructions instead.  */
+   that it or its fn_stub might need $25 to be valid on entry.
+   Note that MIPS16 functions set up $gp using PC-relative instructions,
+   so they themselves never need $25 to be valid.  Only non-MIPS16
+   entry points are of interest here.  */
 
 static bfd_boolean
 mips_elf_local_pic_function_p (struct mips_elf_link_hash_entry *h)
@@ -1582,11 +1768,32 @@
 	   || h->root.root.type == bfd_link_hash_defweak)
 	  && h->root.def_regular
 	  && !bfd_is_abs_section (h->root.root.u.def.section)
-	  && !ELF_ST_IS_MIPS16 (h->root.other)
+	  && (!ELF_ST_IS_MIPS16 (h->root.other)
+	      || (h->fn_stub && h->need_fn_stub))
 	  && (PIC_OBJECT_P (h->root.root.u.def.section->owner)
 	      || ELF_ST_IS_MIPS_PIC (h->root.other)));
 }
 
+/* Set *SEC to the input section that contains the target of STUB.
+   Return the offset of the target from the start of that section.  */
+
+static bfd_vma
+mips_elf_get_la25_target (struct mips_elf_la25_stub *stub,
+			  asection **sec)
+{
+  if (ELF_ST_IS_MIPS16 (stub->h->root.other))
+    {
+      BFD_ASSERT (stub->h->need_fn_stub);
+      *sec = stub->h->fn_stub;
+      return 0;
+    }
+  else
+    {
+      *sec = stub->h->root.root.u.def.section;
+      return stub->h->root.root.u.def.value;
+    }
+}
+
 /* STUB describes an la25 stub that we have decided to implement
    by inserting an LUI/ADDIU pair before the target function.
    Create the section and redirect the function symbol to it.  */
@@ -1611,7 +1818,7 @@
   sprintf (name, ".text.stub.%d", (int) htab_elements (htab->la25_stubs));
 
   /* Create the section.  */
-  input_section = stub->h->root.root.u.def.section;
+  mips_elf_get_la25_target (stub, &input_section);
   s = htab->add_stub_section (name, input_section,
 			      input_section->output_section);
   if (s == NULL)
@@ -1685,12 +1892,6 @@
   bfd_vma value;
   void **slot;
 
-  /* Prefer to use LUI/ADDIU stubs if the function is at the beginning
-     of the section and if we would need no more than 2 nops.  */
-  s = h->root.root.u.def.section;
-  value = h->root.root.u.def.value;
-  use_trampoline_p = (value != 0 || s->alignment_power > 4);
-
   /* Describe the stub we want.  */
   search.stub_section = NULL;
   search.offset = 0;
@@ -1720,6 +1921,11 @@
   *stub = search;
   *slot = stub;
 
+  /* Prefer to use LUI/ADDIU stubs if the function is at the beginning
+     of the section and if we would need no more than 2 nops.  */
+  value = mips_elf_get_la25_target (stub, &s);
+  use_trampoline_p = (value != 0 || s->alignment_power > 4);
+
   h->la25_stub = stub;
   return (use_trampoline_p
 	  ? mips_elf_add_la25_trampoline (stub, info)
@@ -1860,6 +2066,13 @@
     case R_MIPS16_CALL16:
     case R_MIPS16_HI16:
     case R_MIPS16_LO16:
+    case R_MIPS16_TLS_GD:
+    case R_MIPS16_TLS_LDM:
+    case R_MIPS16_TLS_DTPREL_HI16:
+    case R_MIPS16_TLS_DTPREL_LO16:
+    case R_MIPS16_TLS_GOTTPREL:
+    case R_MIPS16_TLS_TPREL_HI16:
+    case R_MIPS16_TLS_TPREL_LO16:
       return TRUE;
 
     default:
@@ -1987,19 +2200,25 @@
 static inline bfd_boolean
 tls_gd_reloc_p (unsigned int r_type)
 {
-  return r_type == R_MIPS_TLS_GD || r_type == R_MICROMIPS_TLS_GD;
+  return (r_type == R_MIPS_TLS_GD
+	  || r_type == R_MIPS16_TLS_GD
+	  || r_type == R_MICROMIPS_TLS_GD);
 }
 
 static inline bfd_boolean
 tls_ldm_reloc_p (unsigned int r_type)
 {
-  return r_type == R_MIPS_TLS_LDM || r_type == R_MICROMIPS_TLS_LDM;
+  return (r_type == R_MIPS_TLS_LDM
+	  || r_type == R_MIPS16_TLS_LDM
+	  || r_type == R_MICROMIPS_TLS_LDM);
 }
 
 static inline bfd_boolean
 tls_gottprel_reloc_p (unsigned int r_type)
 {
-  return r_type == R_MIPS_TLS_GOTTPREL || r_type == R_MICROMIPS_TLS_GOTTPREL;
+  return (r_type == R_MIPS_TLS_GOTTPREL
+	  || r_type == R_MIPS16_TLS_GOTTPREL
+	  || r_type == R_MICROMIPS_TLS_GOTTPREL);
 }
 
 void
@@ -2650,6 +2869,8 @@
 
       if (hd->needs_lazy_stub)
 	{
+	  BFD_ASSERT (hd->root.plt.plist != NULL);
+	  BFD_ASSERT (hd->root.plt.plist->stub_offset != MINUS_ONE);
 	  /* Set type and value for a symbol with a function stub.  */
 	  h->esym.asym.st = stProc;
 	  sec = hd->root.root.u.def.section;
@@ -2659,7 +2880,7 @@
 	    {
 	      output_section = sec->output_section;
 	      if (output_section != NULL)
-		h->esym.asym.value = (hd->root.plt.offset
+		h->esym.asym.value = (hd->root.plt.plist->stub_offset
 				      + sec->output_offset
 				      + output_section->vma);
 	      else
@@ -2705,21 +2926,18 @@
 #endif
 }
 
-/* got_entries only match if they're identical, except for gotidx, so
-   use all fields to compute the hash, and compare the appropriate
-   union members.  */
-
 static hashval_t
 mips_elf_got_entry_hash (const void *entry_)
 {
   const struct mips_got_entry *entry = (struct mips_got_entry *)entry_;
 
-  return entry->symndx
-    + ((entry->tls_type & GOT_TLS_LDM) << 17)
-    + (! entry->abfd ? mips_elf_hash_bfd_vma (entry->d.address)
-       : entry->abfd->id
-         + (entry->symndx >= 0 ? mips_elf_hash_bfd_vma (entry->d.addend)
-	    : entry->d.h->root.root.root.hash));
+  return (entry->symndx
+	  + ((entry->tls_type == GOT_TLS_LDM) << 18)
+	  + (entry->tls_type == GOT_TLS_LDM ? 0
+	     : !entry->abfd ? mips_elf_hash_bfd_vma (entry->d.address)
+	     : entry->symndx >= 0 ? (entry->abfd->id
+				     + mips_elf_hash_bfd_vma (entry->d.addend))
+	     : entry->d.h->root.root.root.hash));
 }
 
 static int
@@ -2728,56 +2946,39 @@
   const struct mips_got_entry *e1 = (struct mips_got_entry *)entry1;
   const struct mips_got_entry *e2 = (struct mips_got_entry *)entry2;
 
-  /* An LDM entry can only match another LDM entry.  */
-  if ((e1->tls_type ^ e2->tls_type) & GOT_TLS_LDM)
-    return 0;
-
-  return e1->abfd == e2->abfd && e1->symndx == e2->symndx
-    && (! e1->abfd ? e1->d.address == e2->d.address
-	: e1->symndx >= 0 ? e1->d.addend == e2->d.addend
-	: e1->d.h == e2->d.h);
+  return (e1->symndx == e2->symndx
+	  && e1->tls_type == e2->tls_type
+	  && (e1->tls_type == GOT_TLS_LDM ? TRUE
+	      : !e1->abfd ? !e2->abfd && e1->d.address == e2->d.address
+	      : e1->symndx >= 0 ? (e1->abfd == e2->abfd
+				   && e1->d.addend == e2->d.addend)
+	      : e2->abfd && e1->d.h == e2->d.h));
 }
 
-/* multi_got_entries are still a match in the case of global objects,
-   even if the input bfd in which they're referenced differs, so the
-   hash computation and compare functions are adjusted
-   accordingly.  */
-
 static hashval_t
-mips_elf_multi_got_entry_hash (const void *entry_)
+mips_got_page_ref_hash (const void *ref_)
 {
-  const struct mips_got_entry *entry = (struct mips_got_entry *)entry_;
+  const struct mips_got_page_ref *ref;
 
-  return entry->symndx
-    + (! entry->abfd
-       ? mips_elf_hash_bfd_vma (entry->d.address)
-       : entry->symndx >= 0
-       ? ((entry->tls_type & GOT_TLS_LDM)
-	  ? (GOT_TLS_LDM << 17)
-	  : (entry->abfd->id
-	     + mips_elf_hash_bfd_vma (entry->d.addend)))
-       : entry->d.h->root.root.root.hash);
+  ref = (const struct mips_got_page_ref *) ref_;
+  return ((ref->symndx >= 0
+	   ? (hashval_t) (ref->u.abfd->id + ref->symndx)
+	   : ref->u.h->root.root.root.hash)
+	  + mips_elf_hash_bfd_vma (ref->addend));
 }
 
 static int
-mips_elf_multi_got_entry_eq (const void *entry1, const void *entry2)
+mips_got_page_ref_eq (const void *ref1_, const void *ref2_)
 {
-  const struct mips_got_entry *e1 = (struct mips_got_entry *)entry1;
-  const struct mips_got_entry *e2 = (struct mips_got_entry *)entry2;
+  const struct mips_got_page_ref *ref1, *ref2;
 
-  /* Any two LDM entries match.  */
-  if (e1->tls_type & e2->tls_type & GOT_TLS_LDM)
-    return 1;
-
-  /* Nothing else matches an LDM entry.  */
-  if ((e1->tls_type ^ e2->tls_type) & GOT_TLS_LDM)
-    return 0;
-
-  return e1->symndx == e2->symndx
-    && (e1->symndx >= 0 ? e1->abfd == e2->abfd && e1->d.addend == e2->d.addend
-	: e1->abfd == NULL || e2->abfd == NULL
-	? e1->abfd == e2->abfd && e1->d.address == e2->d.address
-	: e1->d.h == e2->d.h);
+  ref1 = (const struct mips_got_page_ref *) ref1_;
+  ref2 = (const struct mips_got_page_ref *) ref2_;
+  return (ref1->symndx == ref2->symndx
+	  && (ref1->symndx < 0
+	      ? ref1->u.h == ref2->u.h
+	      : ref1->u.abfd == ref2->u.abfd)
+	  && ref1->addend == ref2->addend);
 }
 
 static hashval_t
@@ -2786,7 +2987,7 @@
   const struct mips_got_page_entry *entry;
 
   entry = (const struct mips_got_page_entry *) entry_;
-  return entry->abfd->id + entry->symndx;
+  return entry->sec->id;
 }
 
 static int
@@ -2796,9 +2997,71 @@
 
   entry1 = (const struct mips_got_page_entry *) entry1_;
   entry2 = (const struct mips_got_page_entry *) entry2_;
-  return entry1->abfd == entry2->abfd && entry1->symndx == entry2->symndx;
+  return entry1->sec == entry2->sec;
 }
 
+/* Create and return a new mips_got_info structure.  */
+
+static struct mips_got_info *
+mips_elf_create_got_info (bfd *abfd)
+{
+  struct mips_got_info *g;
+
+  g = bfd_zalloc (abfd, sizeof (struct mips_got_info));
+  if (g == NULL)
+    return NULL;
+
+  g->got_entries = htab_try_create (1, mips_elf_got_entry_hash,
+				    mips_elf_got_entry_eq, NULL);
+  if (g->got_entries == NULL)
+    return NULL;
+
+  g->got_page_refs = htab_try_create (1, mips_got_page_ref_hash,
+				      mips_got_page_ref_eq, NULL);
+  if (g->got_page_refs == NULL)
+    return NULL;
+
+  return g;
+}
+
+/* Return the GOT info for input bfd ABFD, trying to create a new one if
+   CREATE_P and if ABFD doesn't already have a GOT.  */
+
+static struct mips_got_info *
+mips_elf_bfd_got (bfd *abfd, bfd_boolean create_p)
+{
+  struct mips_elf_obj_tdata *tdata;
+
+  if (!is_mips_elf (abfd))
+    return NULL;
+
+  tdata = mips_elf_tdata (abfd);
+  if (!tdata->got && create_p)
+    tdata->got = mips_elf_create_got_info (abfd);
+  return tdata->got;
+}
+
+/* Record that ABFD should use output GOT G.  */
+
+static void
+mips_elf_replace_bfd_got (bfd *abfd, struct mips_got_info *g)
+{
+  struct mips_elf_obj_tdata *tdata;
+
+  BFD_ASSERT (is_mips_elf (abfd));
+  tdata = mips_elf_tdata (abfd);
+  if (tdata->got)
+    {
+      /* The GOT structure itself and the hash table entries are
+	 allocated to a bfd, but the hash tables aren't.  */
+      htab_delete (tdata->got->got_entries);
+      htab_delete (tdata->got->got_page_refs);
+      if (tdata->got->got_page_entries)
+	htab_delete (tdata->got->got_page_entries);
+    }
+  tdata->got = g;
+}
+
 /* Return the dynamic relocation section.  If it doesn't exist, try to
    create a new it if CREATE_P, otherwise return NULL.  Also return NULL
    if creation fails.  */
@@ -2812,16 +3075,16 @@
 
   dname = MIPS_ELF_REL_DYN_NAME (info);
   dynobj = elf_hash_table (info)->dynobj;
-  sreloc = bfd_get_section_by_name (dynobj, dname);
+  sreloc = bfd_get_linker_section (dynobj, dname);
   if (sreloc == NULL && create_p)
     {
-      sreloc = bfd_make_section_with_flags (dynobj, dname,
-					    (SEC_ALLOC
-					     | SEC_LOAD
-					     | SEC_HAS_CONTENTS
-					     | SEC_IN_MEMORY
-					     | SEC_LINKER_CREATED
-					     | SEC_READONLY));
+      sreloc = bfd_make_section_anyway_with_flags (dynobj, dname,
+						   (SEC_ALLOC
+						    | SEC_LOAD
+						    | SEC_HAS_CONTENTS
+						    | SEC_IN_MEMORY
+						    | SEC_LINKER_CREATED
+						    | SEC_READONLY));
       if (sreloc == NULL
 	  || ! bfd_set_section_alignment (dynobj, sreloc,
 					  MIPS_ELF_LOG_FILE_ALIGN (dynobj)))
@@ -2830,6 +3093,43 @@
   return sreloc;
 }
 
+/* Return the GOT_TLS_* type required by relocation type R_TYPE.  */
+
+static int
+mips_elf_reloc_tls_type (unsigned int r_type)
+{
+  if (tls_gd_reloc_p (r_type))
+    return GOT_TLS_GD;
+
+  if (tls_ldm_reloc_p (r_type))
+    return GOT_TLS_LDM;
+
+  if (tls_gottprel_reloc_p (r_type))
+    return GOT_TLS_IE;
+
+  return GOT_TLS_NONE;
+}
+
+/* Return the number of GOT slots needed for GOT TLS type TYPE.  */
+
+static int
+mips_tls_got_entries (unsigned int type)
+{
+  switch (type)
+    {
+    case GOT_TLS_GD:
+    case GOT_TLS_LDM:
+      return 2;
+
+    case GOT_TLS_IE:
+      return 1;
+
+    case GOT_TLS_NONE:
+      return 0;
+    }
+  abort ();
+}
+
 /* Count the number of relocations needed for a TLS GOT entry, with
    access types from TLS_TYPE, and symbol H (or a local symbol if H
    is NULL).  */
@@ -2839,7 +3139,6 @@
 		     struct elf_link_hash_entry *h)
 {
   int indx = 0;
-  int ret = 0;
   bfd_boolean need_relocs = FALSE;
   bfd_boolean dyn = elf_hash_table (info)->dynamic_sections_created;
 
@@ -2854,70 +3153,43 @@
     need_relocs = TRUE;
 
   if (!need_relocs)
-    return FALSE;
+    return 0;
 
-  if (tls_type & GOT_TLS_GD)
+  switch (tls_type)
     {
-      ret++;
-      if (indx != 0)
-	ret++;
+    case GOT_TLS_GD:
+      return indx != 0 ? 2 : 1;
+
+    case GOT_TLS_IE:
+      return 1;
+
+    case GOT_TLS_LDM:
+      return info->shared ? 1 : 0;
+
+    default:
+      return 0;
     }
-
-  if (tls_type & GOT_TLS_IE)
-    ret++;
-
-  if ((tls_type & GOT_TLS_LDM) && info->shared)
-    ret++;
-
-  return ret;
 }
 
-/* Count the number of TLS relocations required for the GOT entry in
-   ARG1, if it describes a local symbol.  */
+/* Add the number of GOT entries and TLS relocations required by ENTRY
+   to G.  */
 
-static int
-mips_elf_count_local_tls_relocs (void **arg1, void *arg2)
+static void
+mips_elf_count_got_entry (struct bfd_link_info *info,
+			  struct mips_got_info *g,
+			  struct mips_got_entry *entry)
 {
-  struct mips_got_entry *entry = * (struct mips_got_entry **) arg1;
-  struct mips_elf_count_tls_arg *arg = arg2;
-
-  if (entry->abfd != NULL && entry->symndx != -1)
-    arg->needed += mips_tls_got_relocs (arg->info, entry->tls_type, NULL);
-
-  return 1;
-}
-
-/* Count the number of TLS GOT entries required for the global (or
-   forced-local) symbol in ARG1.  */
-
-static int
-mips_elf_count_global_tls_entries (void *arg1, void *arg2)
-{
-  struct mips_elf_link_hash_entry *hm
-    = (struct mips_elf_link_hash_entry *) arg1;
-  struct mips_elf_count_tls_arg *arg = arg2;
-
-  if (hm->tls_type & GOT_TLS_GD)
-    arg->needed += 2;
-  if (hm->tls_type & GOT_TLS_IE)
-    arg->needed += 1;
-
-  return 1;
-}
-
-/* Count the number of TLS relocations required for the global (or
-   forced-local) symbol in ARG1.  */
-
-static int
-mips_elf_count_global_tls_relocs (void *arg1, void *arg2)
-{
-  struct mips_elf_link_hash_entry *hm
-    = (struct mips_elf_link_hash_entry *) arg1;
-  struct mips_elf_count_tls_arg *arg = arg2;
-
-  arg->needed += mips_tls_got_relocs (arg->info, hm->tls_type, &hm->root);
-
-  return 1;
+  if (entry->tls_type)
+    {
+      g->tls_gotno += mips_tls_got_entries (entry->tls_type);
+      g->relocs += mips_tls_got_relocs (info, entry->tls_type,
+					entry->symndx < 0
+					? &entry->d.h->root : NULL);
+    }
+  else if (entry->symndx >= 0 || entry->d.h->global_got_area == GGA_NONE)
+    g->local_gotno += 1;
+  else
+    g->global_gotno += 1;
 }
 
 /* Output a simple dynamic relocation into SRELOC.  */
@@ -2954,16 +3226,15 @@
 /* Initialize a set of TLS GOT entries for one symbol.  */
 
 static void
-mips_elf_initialize_tls_slots (bfd *abfd, bfd_vma got_offset,
-			       unsigned char *tls_type_p,
-			       struct bfd_link_info *info,
+mips_elf_initialize_tls_slots (bfd *abfd, struct bfd_link_info *info,
+			       struct mips_got_entry *entry,
 			       struct mips_elf_link_hash_entry *h,
 			       bfd_vma value)
 {
   struct mips_elf_link_hash_table *htab;
   int indx;
   asection *sreloc, *sgot;
-  bfd_vma offset, offset2;
+  bfd_vma got_offset, got_offset2;
   bfd_boolean need_relocs = FALSE;
 
   htab = mips_elf_hash_table (info);
@@ -2982,7 +3253,7 @@
 	indx = h->root.dynindx;
     }
 
-  if (*tls_type_p & GOT_TLS_DONE)
+  if (entry->tls_initialized)
     return;
 
   if ((info->shared || indx != 0)
@@ -2999,66 +3270,61 @@
 
   /* Emit necessary relocations.  */
   sreloc = mips_elf_rel_dyn_section (info, FALSE);
+  got_offset = entry->gotidx;
 
-  /* General Dynamic.  */
-  if (*tls_type_p & GOT_TLS_GD)
+  switch (entry->tls_type)
     {
-      offset = got_offset;
-      offset2 = offset + MIPS_ELF_GOT_SIZE (abfd);
+    case GOT_TLS_GD:
+      /* General Dynamic.  */
+      got_offset2 = got_offset + MIPS_ELF_GOT_SIZE (abfd);
 
       if (need_relocs)
 	{
 	  mips_elf_output_dynamic_relocation
 	    (abfd, sreloc, sreloc->reloc_count++, indx,
 	     ABI_64_P (abfd) ? R_MIPS_TLS_DTPMOD64 : R_MIPS_TLS_DTPMOD32,
-	     sgot->output_offset + sgot->output_section->vma + offset);
+	     sgot->output_offset + sgot->output_section->vma + got_offset);
 
 	  if (indx)
 	    mips_elf_output_dynamic_relocation
 	      (abfd, sreloc, sreloc->reloc_count++, indx,
 	       ABI_64_P (abfd) ? R_MIPS_TLS_DTPREL64 : R_MIPS_TLS_DTPREL32,
-	       sgot->output_offset + sgot->output_section->vma + offset2);
+	       sgot->output_offset + sgot->output_section->vma + got_offset2);
 	  else
 	    MIPS_ELF_PUT_WORD (abfd, value - dtprel_base (info),
-			       sgot->contents + offset2);
+			       sgot->contents + got_offset2);
 	}
       else
 	{
 	  MIPS_ELF_PUT_WORD (abfd, 1,
-			     sgot->contents + offset);
+			     sgot->contents + got_offset);
 	  MIPS_ELF_PUT_WORD (abfd, value - dtprel_base (info),
-			     sgot->contents + offset2);
+			     sgot->contents + got_offset2);
 	}
+      break;
 
-      got_offset += 2 * MIPS_ELF_GOT_SIZE (abfd);
-    }
-
-  /* Initial Exec model.  */
-  if (*tls_type_p & GOT_TLS_IE)
-    {
-      offset = got_offset;
-
+    case GOT_TLS_IE:
+      /* Initial Exec model.  */
       if (need_relocs)
 	{
 	  if (indx == 0)
 	    MIPS_ELF_PUT_WORD (abfd, value - elf_hash_table (info)->tls_sec->vma,
-			       sgot->contents + offset);
+			       sgot->contents + got_offset);
 	  else
 	    MIPS_ELF_PUT_WORD (abfd, 0,
-			       sgot->contents + offset);
+			       sgot->contents + got_offset);
 
 	  mips_elf_output_dynamic_relocation
 	    (abfd, sreloc, sreloc->reloc_count++, indx,
 	     ABI_64_P (abfd) ? R_MIPS_TLS_TPREL64 : R_MIPS_TLS_TPREL32,
-	     sgot->output_offset + sgot->output_section->vma + offset);
+	     sgot->output_offset + sgot->output_section->vma + got_offset);
 	}
       else
 	MIPS_ELF_PUT_WORD (abfd, value - tprel_base (info),
-			   sgot->contents + offset);
-    }
+			   sgot->contents + got_offset);
+      break;
 
-  if (*tls_type_p & GOT_TLS_LDM)
-    {
+    case GOT_TLS_LDM:
       /* The initial offset is zero, and the LD offsets will include the
 	 bias by DTP_OFFSET.  */
       MIPS_ELF_PUT_WORD (abfd, 0,
@@ -3073,49 +3339,13 @@
 	  (abfd, sreloc, sreloc->reloc_count++, indx,
 	   ABI_64_P (abfd) ? R_MIPS_TLS_DTPMOD64 : R_MIPS_TLS_DTPMOD32,
 	   sgot->output_offset + sgot->output_section->vma + got_offset);
+      break;
+
+    default:
+      abort ();
     }
 
-  *tls_type_p |= GOT_TLS_DONE;
-}
-
-/* Return the GOT index to use for a relocation of type R_TYPE against
-   a symbol accessed using TLS_TYPE models.  The GOT entries for this
-   symbol in this GOT start at GOT_INDEX.  This function initializes the
-   GOT entries and corresponding relocations.  */
-
-static bfd_vma
-mips_tls_got_index (bfd *abfd, bfd_vma got_index, unsigned char *tls_type,
-		    int r_type, struct bfd_link_info *info,
-		    struct mips_elf_link_hash_entry *h, bfd_vma symbol)
-{
-  BFD_ASSERT (tls_gottprel_reloc_p (r_type)
-	      || tls_gd_reloc_p (r_type)
-	      || tls_ldm_reloc_p (r_type));
-
-  mips_elf_initialize_tls_slots (abfd, got_index, tls_type, info, h, symbol);
-
-  if (tls_gottprel_reloc_p (r_type))
-    {
-      BFD_ASSERT (*tls_type & GOT_TLS_IE);
-      if (*tls_type & GOT_TLS_GD)
-	return got_index + 2 * MIPS_ELF_GOT_SIZE (abfd);
-      else
-	return got_index;
-    }
-
-  if (tls_gd_reloc_p (r_type))
-    {
-      BFD_ASSERT (*tls_type & GOT_TLS_GD);
-      return got_index;
-    }
-
-  if (tls_ldm_reloc_p (r_type))
-    {
-      BFD_ASSERT (*tls_type & GOT_TLS_LDM);
-      return got_index;
-    }
-
-  return got_index;
+  entry->tls_initialized = TRUE;
 }
 
 /* Return the offset from _GLOBAL_OFFSET_TABLE_ of the .got.plt entry
@@ -3126,25 +3356,20 @@
 mips_elf_gotplt_index (struct bfd_link_info *info,
 		       struct elf_link_hash_entry *h)
 {
-  bfd_vma plt_index, got_address, got_value;
+  bfd_vma got_address, got_value;
   struct mips_elf_link_hash_table *htab;
 
   htab = mips_elf_hash_table (info);
   BFD_ASSERT (htab != NULL);
 
-  BFD_ASSERT (h->plt.offset != (bfd_vma) -1);
-
-  /* This function only works for VxWorks, because a non-VxWorks .got.plt
-     section starts with reserved entries.  */
-  BFD_ASSERT (htab->is_vxworks);
-
-  /* Calculate the index of the symbol's PLT entry.  */
-  plt_index = (h->plt.offset - htab->plt_header_size) / htab->plt_entry_size;
+  BFD_ASSERT (h->plt.plist != NULL);
+  BFD_ASSERT (h->plt.plist->gotplt_index != MINUS_ONE);
 
   /* Calculate the address of the associated .got.plt entry.  */
   got_address = (htab->sgotplt->output_section->vma
 		 + htab->sgotplt->output_offset
-		 + plt_index * 4);
+		 + (h->plt.plist->gotplt_index
+		    * MIPS_ELF_GOT_SIZE (info->output_bfd)));
 
   /* Calculate the value of _GLOBAL_OFFSET_TABLE_.  */
   got_value = (htab->root.hgot->root.u.def.section->output_section->vma
@@ -3175,79 +3400,75 @@
   if (!entry)
     return MINUS_ONE;
 
-  if (TLS_RELOC_P (r_type))
-    {
-      if (entry->symndx == -1 && htab->got_info->next == NULL)
-	/* A type (3) entry in the single-GOT case.  We use the symbol's
-	   hash table entry to track the index.  */
-	return mips_tls_got_index (abfd, h->tls_got_offset, &h->tls_type,
-				   r_type, info, h, value);
-      else
-	return mips_tls_got_index (abfd, entry->gotidx, &entry->tls_type,
-				   r_type, info, h, value);
-    }
-  else
-    return entry->gotidx;
+  if (entry->tls_type)
+    mips_elf_initialize_tls_slots (abfd, info, entry, h, value);
+  return entry->gotidx;
 }
 
-/* Returns the GOT index for the global symbol indicated by H.  */
+/* Return the GOT index of global symbol H in the primary GOT.  */
 
 static bfd_vma
-mips_elf_global_got_index (bfd *abfd, bfd *ibfd, struct elf_link_hash_entry *h,
-			   int r_type, struct bfd_link_info *info)
+mips_elf_primary_global_got_index (bfd *obfd, struct bfd_link_info *info,
+				   struct elf_link_hash_entry *h)
 {
   struct mips_elf_link_hash_table *htab;
+  long global_got_dynindx;
+  struct mips_got_info *g;
   bfd_vma got_index;
-  struct mips_got_info *g, *gg;
-  long global_got_dynindx = 0;
 
   htab = mips_elf_hash_table (info);
   BFD_ASSERT (htab != NULL);
 
-  gg = g = htab->got_info;
-  if (g->bfd2got && ibfd)
+  global_got_dynindx = 0;
+  if (htab->global_gotsym != NULL)
+    global_got_dynindx = htab->global_gotsym->dynindx;
+
+  /* Once we determine the global GOT entry with the lowest dynamic
+     symbol table index, we must put all dynamic symbols with greater
+     indices into the primary GOT.  That makes it easy to calculate the
+     GOT offset.  */
+  BFD_ASSERT (h->dynindx >= global_got_dynindx);
+  g = mips_elf_bfd_got (obfd, FALSE);
+  got_index = ((h->dynindx - global_got_dynindx + g->local_gotno)
+	       * MIPS_ELF_GOT_SIZE (obfd));
+  BFD_ASSERT (got_index < htab->sgot->size);
+
+  return got_index;
+}
+
+/* Return the GOT index for the global symbol indicated by H, which is
+   referenced by a relocation of type R_TYPE in IBFD.  */
+
+static bfd_vma
+mips_elf_global_got_index (bfd *obfd, struct bfd_link_info *info, bfd *ibfd,
+			   struct elf_link_hash_entry *h, int r_type)
+{
+  struct mips_elf_link_hash_table *htab;
+  struct mips_got_info *g;
+  struct mips_got_entry lookup, *entry;
+  bfd_vma gotidx;
+
+  htab = mips_elf_hash_table (info);
+  BFD_ASSERT (htab != NULL);
+
+  g = mips_elf_bfd_got (ibfd, FALSE);
+  BFD_ASSERT (g);
+
+  lookup.tls_type = mips_elf_reloc_tls_type (r_type);
+  if (!lookup.tls_type && g == mips_elf_bfd_got (obfd, FALSE))
+    return mips_elf_primary_global_got_index (obfd, info, h);
+
+  lookup.abfd = ibfd;
+  lookup.symndx = -1;
+  lookup.d.h = (struct mips_elf_link_hash_entry *) h;
+  entry = htab_find (g->got_entries, &lookup);
+  BFD_ASSERT (entry);
+
+  gotidx = entry->gotidx;
+  BFD_ASSERT (gotidx > 0 && gotidx < htab->sgot->size);
+
+  if (lookup.tls_type)
     {
-      struct mips_got_entry e, *p;
-
-      BFD_ASSERT (h->dynindx >= 0);
-
-      g = mips_elf_got_for_ibfd (g, ibfd);
-      if (g->next != gg || TLS_RELOC_P (r_type))
-	{
-	  e.abfd = ibfd;
-	  e.symndx = -1;
-	  e.d.h = (struct mips_elf_link_hash_entry *)h;
-	  e.tls_type = 0;
-
-	  p = htab_find (g->got_entries, &e);
-
-	  BFD_ASSERT (p->gotidx > 0);
-
-	  if (TLS_RELOC_P (r_type))
-	    {
-	      bfd_vma value = MINUS_ONE;
-	      if ((h->root.type == bfd_link_hash_defined
-		   || h->root.type == bfd_link_hash_defweak)
-		  && h->root.u.def.section->output_section)
-		value = (h->root.u.def.value
-			 + h->root.u.def.section->output_offset
-			 + h->root.u.def.section->output_section->vma);
-
-	      return mips_tls_got_index (abfd, p->gotidx, &p->tls_type, r_type,
-					 info, e.d.h, value);
-	    }
-	  else
-	    return p->gotidx;
-	}
-    }
-
-  if (gg->global_gotsym != NULL)
-    global_got_dynindx = gg->global_gotsym->dynindx;
-
-  if (TLS_RELOC_P (r_type))
-    {
-      struct mips_elf_link_hash_entry *hm
-	= (struct mips_elf_link_hash_entry *) h;
       bfd_vma value = MINUS_ONE;
 
       if ((h->root.type == bfd_link_hash_defined
@@ -3257,22 +3478,9 @@
 		 + h->root.u.def.section->output_offset
 		 + h->root.u.def.section->output_section->vma);
 
-      got_index = mips_tls_got_index (abfd, hm->tls_got_offset, &hm->tls_type,
-				      r_type, info, hm, value);
+      mips_elf_initialize_tls_slots (obfd, info, entry, lookup.d.h, value);
     }
-  else
-    {
-      /* Once we determine the global GOT entry with the lowest dynamic
-	 symbol table index, we must put all dynamic symbols with greater
-	 indices into the GOT.  That makes it easy to calculate the GOT
-	 offset.  */
-      BFD_ASSERT (h->dynindx >= global_got_dynindx);
-      got_index = ((h->dynindx - global_got_dynindx + g->local_gotno)
-		   * MIPS_ELF_GOT_SIZE (abfd));
-    }
-  BFD_ASSERT (got_index < htab->sgot->size);
-
-  return got_index;
+  return gotidx;
 }
 
 /* Find a GOT page entry that points to within 32KB of VALUE.  These
@@ -3364,72 +3572,68 @@
 				 struct mips_elf_link_hash_entry *h,
 				 int r_type)
 {
-  struct mips_got_entry entry, **loc;
+  struct mips_got_entry lookup, *entry;
+  void **loc;
   struct mips_got_info *g;
   struct mips_elf_link_hash_table *htab;
+  bfd_vma gotidx;
 
   htab = mips_elf_hash_table (info);
   BFD_ASSERT (htab != NULL);
 
-  entry.abfd = NULL;
-  entry.symndx = -1;
-  entry.d.address = value;
-  entry.tls_type = 0;
-
-  g = mips_elf_got_for_ibfd (htab->got_info, ibfd);
+  g = mips_elf_bfd_got (ibfd, FALSE);
   if (g == NULL)
     {
-      g = mips_elf_got_for_ibfd (htab->got_info, abfd);
+      g = mips_elf_bfd_got (abfd, FALSE);
       BFD_ASSERT (g != NULL);
     }
 
   /* This function shouldn't be called for symbols that live in the global
      area of the GOT.  */
   BFD_ASSERT (h == NULL || h->global_got_area == GGA_NONE);
-  if (TLS_RELOC_P (r_type))
-    {
-      struct mips_got_entry *p;
 
-      entry.abfd = ibfd;
+  lookup.tls_type = mips_elf_reloc_tls_type (r_type);
+  if (lookup.tls_type)
+    {
+      lookup.abfd = ibfd;
       if (tls_ldm_reloc_p (r_type))
 	{
-	  entry.tls_type = GOT_TLS_LDM;
-	  entry.symndx = 0;
-	  entry.d.addend = 0;
+	  lookup.symndx = 0;
+	  lookup.d.addend = 0;
 	}
       else if (h == NULL)
 	{
-	  entry.symndx = r_symndx;
-	  entry.d.addend = 0;
+	  lookup.symndx = r_symndx;
+	  lookup.d.addend = 0;
 	}
       else
-	entry.d.h = h;
+	{
+	  lookup.symndx = -1;
+	  lookup.d.h = h;
+	}
 
-      p = (struct mips_got_entry *)
-	htab_find (g->got_entries, &entry);
+      entry = (struct mips_got_entry *) htab_find (g->got_entries, &lookup);
+      BFD_ASSERT (entry);
 
-      BFD_ASSERT (p);
-      return p;
+      gotidx = entry->gotidx;
+      BFD_ASSERT (gotidx > 0 && gotidx < htab->sgot->size);
+
+      return entry;
     }
 
-  loc = (struct mips_got_entry **) htab_find_slot (g->got_entries, &entry,
-						   INSERT);
-  if (*loc)
-    return *loc;
-
-  entry.gotidx = MIPS_ELF_GOT_SIZE (abfd) * g->assigned_gotno++;
-  entry.tls_type = 0;
-
-  *loc = (struct mips_got_entry *)bfd_alloc (abfd, sizeof entry);
-
-  if (! *loc)
+  lookup.abfd = NULL;
+  lookup.symndx = -1;
+  lookup.d.address = value;
+  loc = htab_find_slot (g->got_entries, &lookup, INSERT);
+  if (!loc)
     return NULL;
 
-  memcpy (*loc, &entry, sizeof entry);
+  entry = (struct mips_got_entry *) *loc;
+  if (entry)
+    return entry;
 
-  if (g->assigned_gotno > g->local_gotno)
+  if (g->assigned_gotno >= g->local_gotno)
     {
-      (*loc)->gotidx = -1;
       /* We didn't allocate enough space in the GOT.  */
       (*_bfd_error_handler)
 	(_("not enough GOT space for local GOT entries"));
@@ -3437,8 +3641,15 @@
       return NULL;
     }
 
-  MIPS_ELF_PUT_WORD (abfd, value,
-		     (htab->sgot->contents + entry.gotidx));
+  entry = (struct mips_got_entry *) bfd_alloc (abfd, sizeof (*entry));
+  if (!entry)
+    return NULL;
+
+  lookup.gotidx = MIPS_ELF_GOT_SIZE (abfd) * g->assigned_gotno++;
+  *entry = lookup;
+  *loc = entry;
+
+  MIPS_ELF_PUT_WORD (abfd, value, htab->sgot->contents + entry->gotidx);
 
   /* These GOT entries need a dynamic relocation on VxWorks.  */
   if (htab->is_vxworks)
@@ -3451,7 +3662,7 @@
       s = mips_elf_rel_dyn_section (info, FALSE);
       got_address = (htab->sgot->output_section->vma
 		     + htab->sgot->output_offset
-		     + entry.gotidx);
+		     + entry->gotidx);
 
       rloc = s->contents + (s->reloc_count++ * sizeof (Elf32_External_Rela));
       outrel.r_offset = got_address;
@@ -3460,7 +3671,7 @@
       bfd_elf32_swap_reloca_out (abfd, &outrel, rloc);
     }
 
-  return *loc;
+  return entry;
 }
 
 /* Return the number of dynamic section symbols required by OUTPUT_BFD.
@@ -3529,7 +3740,7 @@
 
   /* Now we know which dynamic symbol has the lowest dynamic symbol
      table index in the GOT.  */
-  g->global_gotsym = hsd.low;
+  htab->global_gotsym = hsd.low;
 
   return TRUE;
 }
@@ -3555,15 +3766,11 @@
       break;
 
     case GGA_NORMAL:
-      BFD_ASSERT (h->tls_type == GOT_NORMAL);
-
       h->root.dynindx = --hsd->min_got_dynindx;
       hsd->low = (struct elf_link_hash_entry *) h;
       break;
 
     case GGA_RELOC_ONLY:
-      BFD_ASSERT (h->tls_type == GOT_NORMAL);
-
       if (hsd->max_unref_got_dynindx == hsd->min_got_dynindx)
 	hsd->low = (struct elf_link_hash_entry *) h;
       h->root.dynindx = hsd->max_unref_got_dynindx++;
@@ -3573,21 +3780,67 @@
   return TRUE;
 }
 
-/* If H is a symbol that needs a global GOT entry, but has a dynamic
-   symbol table index lower than any we've seen to date, record it for
-   posterity.  FOR_CALL is true if the caller is only interested in
+/* Record that input bfd ABFD requires a GOT entry like *LOOKUP
+   (which is owned by the caller and shouldn't be added to the
+   hash table directly).  */
+
+static bfd_boolean
+mips_elf_record_got_entry (struct bfd_link_info *info, bfd *abfd,
+			   struct mips_got_entry *lookup)
+{
+  struct mips_elf_link_hash_table *htab;
+  struct mips_got_entry *entry;
+  struct mips_got_info *g;
+  void **loc, **bfd_loc;
+
+  /* Make sure there's a slot for this entry in the master GOT.  */
+  htab = mips_elf_hash_table (info);
+  g = htab->got_info;
+  loc = htab_find_slot (g->got_entries, lookup, INSERT);
+  if (!loc)
+    return FALSE;
+
+  /* Populate the entry if it isn't already.  */
+  entry = (struct mips_got_entry *) *loc;
+  if (!entry)
+    {
+      entry = (struct mips_got_entry *) bfd_alloc (abfd, sizeof (*entry));
+      if (!entry)
+	return FALSE;
+
+      lookup->tls_initialized = FALSE;
+      lookup->gotidx = -1;
+      *entry = *lookup;
+      *loc = entry;
+    }
+
+  /* Reuse the same GOT entry for the BFD's GOT.  */
+  g = mips_elf_bfd_got (abfd, TRUE);
+  if (!g)
+    return FALSE;
+
+  bfd_loc = htab_find_slot (g->got_entries, lookup, INSERT);
+  if (!bfd_loc)
+    return FALSE;
+
+  if (!*bfd_loc)
+    *bfd_loc = entry;
+  return TRUE;
+}
+
+/* ABFD has a GOT relocation of type R_TYPE against H.  Reserve a GOT
+   entry for it.  FOR_CALL is true if the caller is only interested in
    using the GOT entry for calls.  */
 
 static bfd_boolean
 mips_elf_record_global_got_symbol (struct elf_link_hash_entry *h,
 				   bfd *abfd, struct bfd_link_info *info,
-				   bfd_boolean for_call,
-				   unsigned char tls_flag)
+				   bfd_boolean for_call, int r_type)
 {
   struct mips_elf_link_hash_table *htab;
   struct mips_elf_link_hash_entry *hmips;
-  struct mips_got_entry entry, **loc;
-  struct mips_got_info *g;
+  struct mips_got_entry entry;
+  unsigned char tls_type;
 
   htab = mips_elf_hash_table (info);
   BFD_ASSERT (htab != NULL);
@@ -3611,53 +3864,27 @@
 	return FALSE;
     }
 
-  /* Make sure we have a GOT to put this entry into.  */
-  g = htab->got_info;
-  BFD_ASSERT (g != NULL);
+  tls_type = mips_elf_reloc_tls_type (r_type);
+  if (tls_type == GOT_TLS_NONE && hmips->global_got_area > GGA_NORMAL)
+    hmips->global_got_area = GGA_NORMAL;
 
   entry.abfd = abfd;
   entry.symndx = -1;
   entry.d.h = (struct mips_elf_link_hash_entry *) h;
-  entry.tls_type = 0;
-
-  loc = (struct mips_got_entry **) htab_find_slot (g->got_entries, &entry,
-						   INSERT);
-
-  /* If we've already marked this entry as needing GOT space, we don't
-     need to do it again.  */
-  if (*loc)
-    {
-      (*loc)->tls_type |= tls_flag;
-      return TRUE;
-    }
-
-  *loc = (struct mips_got_entry *)bfd_alloc (abfd, sizeof entry);
-
-  if (! *loc)
-    return FALSE;
-
-  entry.gotidx = -1;
-  entry.tls_type = tls_flag;
-
-  memcpy (*loc, &entry, sizeof entry);
-
-  if (tls_flag == 0)
-    hmips->global_got_area = GGA_NORMAL;
-
-  return TRUE;
+  entry.tls_type = tls_type;
+  return mips_elf_record_got_entry (info, abfd, &entry);
 }
 
-/* Reserve space in G for a GOT entry containing the value of symbol
-   SYMNDX in input bfd ABDF, plus ADDEND.  */
+/* ABFD has a GOT relocation of type R_TYPE against symbol SYMNDX + ADDEND,
+   where SYMNDX is a local symbol.  Reserve a GOT entry for it.  */
 
 static bfd_boolean
 mips_elf_record_local_got_symbol (bfd *abfd, long symndx, bfd_vma addend,
-				  struct bfd_link_info *info,
-				  unsigned char tls_flag)
+				  struct bfd_link_info *info, int r_type)
 {
   struct mips_elf_link_hash_table *htab;
   struct mips_got_info *g;
-  struct mips_got_entry entry, **loc;
+  struct mips_got_entry entry;
 
   htab = mips_elf_hash_table (info);
   BFD_ASSERT (htab != NULL);
@@ -3668,55 +3895,186 @@
   entry.abfd = abfd;
   entry.symndx = symndx;
   entry.d.addend = addend;
-  entry.tls_type = tls_flag;
-  loc = (struct mips_got_entry **)
-    htab_find_slot (g->got_entries, &entry, INSERT);
+  entry.tls_type = mips_elf_reloc_tls_type (r_type);
+  return mips_elf_record_got_entry (info, abfd, &entry);
+}
 
-  if (*loc)
-    {
-      if (tls_flag == GOT_TLS_GD && !((*loc)->tls_type & GOT_TLS_GD))
-	{
-	  g->tls_gotno += 2;
-	  (*loc)->tls_type |= tls_flag;
-	}
-      else if (tls_flag == GOT_TLS_IE && !((*loc)->tls_type & GOT_TLS_IE))
-	{
-	  g->tls_gotno += 1;
-	  (*loc)->tls_type |= tls_flag;
-	}
-      return TRUE;
-    }
+/* Record that ABFD has a page relocation against SYMNDX + ADDEND.
+   H is the symbol's hash table entry, or null if SYMNDX is local
+   to ABFD.  */
 
-  if (tls_flag != 0)
+static bfd_boolean
+mips_elf_record_got_page_ref (struct bfd_link_info *info, bfd *abfd,
+			      long symndx, struct elf_link_hash_entry *h,
+			      bfd_signed_vma addend)
+{
+  struct mips_elf_link_hash_table *htab;
+  struct mips_got_info *g1, *g2;
+  struct mips_got_page_ref lookup, *entry;
+  void **loc, **bfd_loc;
+
+  htab = mips_elf_hash_table (info);
+  BFD_ASSERT (htab != NULL);
+
+  g1 = htab->got_info;
+  BFD_ASSERT (g1 != NULL);
+
+  if (h)
     {
-      entry.gotidx = -1;
-      entry.tls_type = tls_flag;
-      if (tls_flag == GOT_TLS_IE)
-	g->tls_gotno += 1;
-      else if (tls_flag == GOT_TLS_GD)
-	g->tls_gotno += 2;
-      else if (g->tls_ldm_offset == MINUS_ONE)
-	{
-	  g->tls_ldm_offset = MINUS_TWO;
-	  g->tls_gotno += 2;
-	}
+      lookup.symndx = -1;
+      lookup.u.h = (struct mips_elf_link_hash_entry *) h;
     }
   else
     {
-      entry.gotidx = g->local_gotno++;
-      entry.tls_type = 0;
+      lookup.symndx = symndx;
+      lookup.u.abfd = abfd;
     }
-
-  *loc = (struct mips_got_entry *)bfd_alloc (abfd, sizeof entry);
-
-  if (! *loc)
+  lookup.addend = addend;
+  loc = htab_find_slot (g1->got_page_refs, &lookup, INSERT);
+  if (loc == NULL)
     return FALSE;
 
-  memcpy (*loc, &entry, sizeof entry);
+  entry = (struct mips_got_page_ref *) *loc;
+  if (!entry)
+    {
+      entry = bfd_alloc (abfd, sizeof (*entry));
+      if (!entry)
+	return FALSE;
+
+      *entry = lookup;
+      *loc = entry;
+    }
+
+  /* Add the same entry to the BFD's GOT.  */
+  g2 = mips_elf_bfd_got (abfd, TRUE);
+  if (!g2)
+    return FALSE;
+
+  bfd_loc = htab_find_slot (g2->got_page_refs, &lookup, INSERT);
+  if (!bfd_loc)
+    return FALSE;
+
+  if (!*bfd_loc)
+    *bfd_loc = entry;
 
   return TRUE;
 }
 
+/* Add room for N relocations to the .rel(a).dyn section in ABFD.  */
+
+static void
+mips_elf_allocate_dynamic_relocations (bfd *abfd, struct bfd_link_info *info,
+				       unsigned int n)
+{
+  asection *s;
+  struct mips_elf_link_hash_table *htab;
+
+  htab = mips_elf_hash_table (info);
+  BFD_ASSERT (htab != NULL);
+
+  s = mips_elf_rel_dyn_section (info, FALSE);
+  BFD_ASSERT (s != NULL);
+
+  if (htab->is_vxworks)
+    s->size += n * MIPS_ELF_RELA_SIZE (abfd);
+  else
+    {
+      if (s->size == 0)
+	{
+	  /* Make room for a null element.  */
+	  s->size += MIPS_ELF_REL_SIZE (abfd);
+	  ++s->reloc_count;
+	}
+      s->size += n * MIPS_ELF_REL_SIZE (abfd);
+    }
+}
+
+/* A htab_traverse callback for GOT entries, with DATA pointing to a
+   mips_elf_traverse_got_arg structure.  Count the number of GOT
+   entries and TLS relocs.  Set DATA->value to true if we need
+   to resolve indirect or warning symbols and then recreate the GOT.  */
+
+static int
+mips_elf_check_recreate_got (void **entryp, void *data)
+{
+  struct mips_got_entry *entry;
+  struct mips_elf_traverse_got_arg *arg;
+
+  entry = (struct mips_got_entry *) *entryp;
+  arg = (struct mips_elf_traverse_got_arg *) data;
+  if (entry->abfd != NULL && entry->symndx == -1)
+    {
+      struct mips_elf_link_hash_entry *h;
+
+      h = entry->d.h;
+      if (h->root.root.type == bfd_link_hash_indirect
+	  || h->root.root.type == bfd_link_hash_warning)
+	{
+	  arg->value = TRUE;
+	  return 0;
+	}
+    }
+  mips_elf_count_got_entry (arg->info, arg->g, entry);
+  return 1;
+}
+
+/* A htab_traverse callback for GOT entries, with DATA pointing to a
+   mips_elf_traverse_got_arg structure.  Add all entries to DATA->g,
+   converting entries for indirect and warning symbols into entries
+   for the target symbol.  Set DATA->g to null on error.  */
+
+static int
+mips_elf_recreate_got (void **entryp, void *data)
+{
+  struct mips_got_entry new_entry, *entry;
+  struct mips_elf_traverse_got_arg *arg;
+  void **slot;
+
+  entry = (struct mips_got_entry *) *entryp;
+  arg = (struct mips_elf_traverse_got_arg *) data;
+  if (entry->abfd != NULL
+      && entry->symndx == -1
+      && (entry->d.h->root.root.type == bfd_link_hash_indirect
+	  || entry->d.h->root.root.type == bfd_link_hash_warning))
+    {
+      struct mips_elf_link_hash_entry *h;
+
+      new_entry = *entry;
+      entry = &new_entry;
+      h = entry->d.h;
+      do
+	{
+	  BFD_ASSERT (h->global_got_area == GGA_NONE);
+	  h = (struct mips_elf_link_hash_entry *) h->root.root.u.i.link;
+	}
+      while (h->root.root.type == bfd_link_hash_indirect
+	     || h->root.root.type == bfd_link_hash_warning);
+      entry->d.h = h;
+    }
+  slot = htab_find_slot (arg->g->got_entries, entry, INSERT);
+  if (slot == NULL)
+    {
+      arg->g = NULL;
+      return 0;
+    }
+  if (*slot == NULL)
+    {
+      if (entry == &new_entry)
+	{
+	  entry = bfd_alloc (entry->abfd, sizeof (*entry));
+	  if (!entry)
+	    {
+	      arg->g = NULL;
+	      return 0;
+	    }
+	  *entry = new_entry;
+	}
+      *slot = entry;
+      mips_elf_count_got_entry (arg->info, arg->g, entry);
+    }
+  return 1;
+}
+
 /* Return the maximum number of GOT page entries required for RANGE.  */
 
 static bfd_vma
@@ -3725,50 +4083,33 @@
   return (range->max_addend - range->min_addend + 0x1ffff) >> 16;
 }
 
-/* Record that ABFD has a page relocation against symbol SYMNDX and
-   that ADDEND is the addend for that relocation.
-
-   This function creates an upper bound on the number of GOT slots
-   required; no attempt is made to combine references to non-overridable
-   global symbols across multiple input files.  */
+/* Record that G requires a page entry that can reach SEC + ADDEND.  */
 
 static bfd_boolean
-mips_elf_record_got_page_entry (struct bfd_link_info *info, bfd *abfd,
-				long symndx, bfd_signed_vma addend)
+mips_elf_record_got_page_entry (struct mips_got_info *g,
+				asection *sec, bfd_signed_vma addend)
 {
-  struct mips_elf_link_hash_table *htab;
-  struct mips_got_info *g;
   struct mips_got_page_entry lookup, *entry;
   struct mips_got_page_range **range_ptr, *range;
   bfd_vma old_pages, new_pages;
   void **loc;
 
-  htab = mips_elf_hash_table (info);
-  BFD_ASSERT (htab != NULL);
-
-  g = htab->got_info;
-  BFD_ASSERT (g != NULL);
-
-  /* Find the mips_got_page_entry hash table entry for this symbol.  */
-  lookup.abfd = abfd;
-  lookup.symndx = symndx;
+  /* Find the mips_got_page_entry hash table entry for this section.  */
+  lookup.sec = sec;
   loc = htab_find_slot (g->got_page_entries, &lookup, INSERT);
   if (loc == NULL)
     return FALSE;
 
   /* Create a mips_got_page_entry if this is the first time we've
-     seen the symbol.  */
+     seen the section.  */
   entry = (struct mips_got_page_entry *) *loc;
   if (!entry)
     {
-      entry = bfd_alloc (abfd, sizeof (*entry));
+      entry = bfd_zalloc (sec->owner, sizeof (*entry));
       if (!entry)
 	return FALSE;
 
-      entry->abfd = abfd;
-      entry->symndx = symndx;
-      entry->ranges = NULL;
-      entry->num_pages = 0;
+      entry->sec = sec;
       *loc = entry;
     }
 
@@ -3784,7 +4125,7 @@
   range = *range_ptr;
   if (!range || addend < range->min_addend - 0xffff)
     {
-      range = bfd_alloc (abfd, sizeof (*range));
+      range = bfd_zalloc (sec->owner, sizeof (*range));
       if (!range)
 	return FALSE;
 
@@ -3827,132 +4168,142 @@
   return TRUE;
 }
 
-/* Add room for N relocations to the .rel(a).dyn section in ABFD.  */
+/* A htab_traverse callback for which *REFP points to a mips_got_page_ref
+   and for which DATA points to a mips_elf_traverse_got_arg.  Work out
+   whether the page reference described by *REFP needs a GOT page entry,
+   and record that entry in DATA->g if so.  Set DATA->g to null on failure.  */
 
-static void
-mips_elf_allocate_dynamic_relocations (bfd *abfd, struct bfd_link_info *info,
-				       unsigned int n)
+static bfd_boolean
+mips_elf_resolve_got_page_ref (void **refp, void *data)
 {
-  asection *s;
+  struct mips_got_page_ref *ref;
+  struct mips_elf_traverse_got_arg *arg;
   struct mips_elf_link_hash_table *htab;
+  asection *sec;
+  bfd_vma addend;
 
-  htab = mips_elf_hash_table (info);
-  BFD_ASSERT (htab != NULL);
+  ref = (struct mips_got_page_ref *) *refp;
+  arg = (struct mips_elf_traverse_got_arg *) data;
+  htab = mips_elf_hash_table (arg->info);
 
-  s = mips_elf_rel_dyn_section (info, FALSE);
-  BFD_ASSERT (s != NULL);
-
-  if (htab->is_vxworks)
-    s->size += n * MIPS_ELF_RELA_SIZE (abfd);
-  else
-    {
-      if (s->size == 0)
-	{
-	  /* Make room for a null element.  */
-	  s->size += MIPS_ELF_REL_SIZE (abfd);
-	  ++s->reloc_count;
-	}
-      s->size += n * MIPS_ELF_REL_SIZE (abfd);
-    }
-}
-
-/* A htab_traverse callback for GOT entries.  Set boolean *DATA to true
-   if the GOT entry is for an indirect or warning symbol.  */
-
-static int
-mips_elf_check_recreate_got (void **entryp, void *data)
-{
-  struct mips_got_entry *entry;
-  bfd_boolean *must_recreate;
-
-  entry = (struct mips_got_entry *) *entryp;
-  must_recreate = (bfd_boolean *) data;
-  if (entry->abfd != NULL && entry->symndx == -1)
+  if (ref->symndx < 0)
     {
       struct mips_elf_link_hash_entry *h;
 
-      h = entry->d.h;
-      if (h->root.root.type == bfd_link_hash_indirect
-	  || h->root.root.type == bfd_link_hash_warning)
+      /* Global GOT_PAGEs decay to GOT_DISP and so don't need page entries.  */
+      h = ref->u.h;
+      if (!SYMBOL_REFERENCES_LOCAL (arg->info, &h->root))
+	return 1;
+
+      /* Ignore undefined symbols; we'll issue an error later if
+	 appropriate.  */
+      if (!((h->root.root.type == bfd_link_hash_defined
+	     || h->root.root.type == bfd_link_hash_defweak)
+	    && h->root.root.u.def.section))
+	return 1;
+
+      sec = h->root.root.u.def.section;
+      addend = h->root.root.u.def.value + ref->addend;
+    }
+  else
+    {
+      Elf_Internal_Sym *isym;
+
+      /* Read in the symbol.  */
+      isym = bfd_sym_from_r_symndx (&htab->sym_cache, ref->u.abfd,
+				    ref->symndx);
+      if (isym == NULL)
 	{
-	  *must_recreate = TRUE;
+	  arg->g = NULL;
 	  return 0;
 	}
-    }
-  return 1;
-}
 
-/* A htab_traverse callback for GOT entries.  Add all entries to
-   hash table *DATA, converting entries for indirect and warning
-   symbols into entries for the target symbol.  Set *DATA to null
-   on error.  */
-
-static int
-mips_elf_recreate_got (void **entryp, void *data)
-{
-  htab_t *new_got;
-  struct mips_got_entry *entry;
-  void **slot;
-
-  new_got = (htab_t *) data;
-  entry = (struct mips_got_entry *) *entryp;
-  if (entry->abfd != NULL && entry->symndx == -1)
-    {
-      struct mips_elf_link_hash_entry *h;
-
-      h = entry->d.h;
-      while (h->root.root.type == bfd_link_hash_indirect
-	     || h->root.root.type == bfd_link_hash_warning)
+      /* Get the associated input section.  */
+      sec = bfd_section_from_elf_index (ref->u.abfd, isym->st_shndx);
+      if (sec == NULL)
 	{
-	  BFD_ASSERT (h->global_got_area == GGA_NONE);
-	  h = (struct mips_elf_link_hash_entry *) h->root.root.u.i.link;
+	  arg->g = NULL;
+	  return 0;
 	}
-      entry->d.h = h;
+
+      /* If this is a mergable section, work out the section and offset
+	 of the merged data.  For section symbols, the addend specifies
+	 of the offset _of_ the first byte in the data, otherwise it
+	 specifies the offset _from_ the first byte.  */
+      if (sec->flags & SEC_MERGE)
+	{
+	  void *secinfo;
+
+	  secinfo = elf_section_data (sec)->sec_info;
+	  if (ELF_ST_TYPE (isym->st_info) == STT_SECTION)
+	    addend = _bfd_merged_section_offset (ref->u.abfd, &sec, secinfo,
+						 isym->st_value + ref->addend);
+	  else
+	    addend = _bfd_merged_section_offset (ref->u.abfd, &sec, secinfo,
+						 isym->st_value) + ref->addend;
+	}
+      else
+	addend = isym->st_value + ref->addend;
     }
-  slot = htab_find_slot (*new_got, entry, INSERT);
-  if (slot == NULL)
+  if (!mips_elf_record_got_page_entry (arg->g, sec, addend))
     {
-      *new_got = NULL;
+      arg->g = NULL;
       return 0;
     }
-  if (*slot == NULL)
-    *slot = entry;
-  else
-    free (entry);
   return 1;
 }
 
 /* If any entries in G->got_entries are for indirect or warning symbols,
-   replace them with entries for the target symbol.  */
+   replace them with entries for the target symbol.  Convert g->got_page_refs
+   into got_page_entry structures and estimate the number of page entries
+   that they require.  */
 
 static bfd_boolean
-mips_elf_resolve_final_got_entries (struct mips_got_info *g)
+mips_elf_resolve_final_got_entries (struct bfd_link_info *info,
+				    struct mips_got_info *g)
 {
-  bfd_boolean must_recreate;
-  htab_t new_got;
+  struct mips_elf_traverse_got_arg tga;
+  struct mips_got_info oldg;
 
-  must_recreate = FALSE;
-  htab_traverse (g->got_entries, mips_elf_check_recreate_got, &must_recreate);
-  if (must_recreate)
+  oldg = *g;
+
+  tga.info = info;
+  tga.g = g;
+  tga.value = FALSE;
+  htab_traverse (g->got_entries, mips_elf_check_recreate_got, &tga);
+  if (tga.value)
     {
-      new_got = htab_create (htab_size (g->got_entries),
-			     mips_elf_got_entry_hash,
-			     mips_elf_got_entry_eq, NULL);
-      htab_traverse (g->got_entries, mips_elf_recreate_got, &new_got);
-      if (new_got == NULL)
+      *g = oldg;
+      g->got_entries = htab_create (htab_size (oldg.got_entries),
+				    mips_elf_got_entry_hash,
+				    mips_elf_got_entry_eq, NULL);
+      if (!g->got_entries)
 	return FALSE;
 
-      /* Each entry in g->got_entries has either been copied to new_got
-	 or freed.  Now delete the hash table itself.  */
-      htab_delete (g->got_entries);
-      g->got_entries = new_got;
+      htab_traverse (oldg.got_entries, mips_elf_recreate_got, &tga);
+      if (!tga.g)
+	return FALSE;
+
+      htab_delete (oldg.got_entries);
     }
+
+  g->got_page_entries = htab_try_create (1, mips_got_page_entry_hash,
+					 mips_got_page_entry_eq, NULL);
+  if (g->got_page_entries == NULL)
+    return FALSE;
+
+  tga.info = info;
+  tga.g = g;
+  htab_traverse (g->got_page_refs, mips_elf_resolve_got_page_ref, &tga);
+
   return TRUE;
 }
 
-/* A mips_elf_link_hash_traverse callback for which DATA points
-   to the link_info structure.  Count the number of type (3) entries
-   in the master GOT.  */
+/* A mips_elf_link_hash_traverse callback for which DATA points to the
+   link_info structure.  Decide whether the hash entry needs an entry in
+   the global part of the primary GOT, setting global_got_area accordingly.
+   Count the number of global symbols that are in the primary GOT only
+   because they have relocations against them (reloc_only_gotno).  */
 
 static int
 mips_elf_count_got_symbols (struct mips_elf_link_hash_entry *h, void *data)
@@ -3979,209 +4330,90 @@
 	  || (h->got_only_for_calls
 	      ? SYMBOL_CALLS_LOCAL (info, &h->root)
 	      : SYMBOL_REFERENCES_LOCAL (info, &h->root)))
-	{
-	  /* The symbol belongs in the local GOT.  We no longer need this
-	     entry if it was only used for relocations; those relocations
-	     will be against the null or section symbol instead of H.  */
-	  if (h->global_got_area != GGA_RELOC_ONLY)
-	    g->local_gotno++;
-	  h->global_got_area = GGA_NONE;
-	}
+	/* The symbol belongs in the local GOT.  We no longer need this
+	   entry if it was only used for relocations; those relocations
+	   will be against the null or section symbol instead of H.  */
+	h->global_got_area = GGA_NONE;
       else if (htab->is_vxworks
 	       && h->got_only_for_calls
-	       && h->root.plt.offset != MINUS_ONE)
+	       && h->root.plt.plist->mips_offset != MINUS_ONE)
 	/* On VxWorks, calls can refer directly to the .got.plt entry;
 	   they don't need entries in the regular GOT.  .got.plt entries
 	   will be allocated by _bfd_mips_elf_adjust_dynamic_symbol.  */
 	h->global_got_area = GGA_NONE;
-      else
+      else if (h->global_got_area == GGA_RELOC_ONLY)
 	{
+	  g->reloc_only_gotno++;
 	  g->global_gotno++;
-	  if (h->global_got_area == GGA_RELOC_ONLY)
-	    g->reloc_only_gotno++;
 	}
     }
   return 1;
 }
 
-/* Compute the hash value of the bfd in a bfd2got hash entry.  */
-
-static hashval_t
-mips_elf_bfd2got_entry_hash (const void *entry_)
-{
-  const struct mips_elf_bfd2got_hash *entry
-    = (struct mips_elf_bfd2got_hash *)entry_;
-
-  return entry->bfd->id;
-}
-
-/* Check whether two hash entries have the same bfd.  */
+/* A htab_traverse callback for GOT entries.  Add each one to the GOT
+   given in mips_elf_traverse_got_arg DATA.  Clear DATA->G on error.  */
 
 static int
-mips_elf_bfd2got_entry_eq (const void *entry1, const void *entry2)
+mips_elf_add_got_entry (void **entryp, void *data)
 {
-  const struct mips_elf_bfd2got_hash *e1
-    = (const struct mips_elf_bfd2got_hash *)entry1;
-  const struct mips_elf_bfd2got_hash *e2
-    = (const struct mips_elf_bfd2got_hash *)entry2;
+  struct mips_got_entry *entry;
+  struct mips_elf_traverse_got_arg *arg;
+  void **slot;
 
-  return e1->bfd == e2->bfd;
-}
-
-/* In a multi-got link, determine the GOT to be used for IBFD.  G must
-   be the master GOT data.  */
-
-static struct mips_got_info *
-mips_elf_got_for_ibfd (struct mips_got_info *g, bfd *ibfd)
-{
-  struct mips_elf_bfd2got_hash e, *p;
-
-  if (! g->bfd2got)
-    return g;
-
-  e.bfd = ibfd;
-  p = htab_find (g->bfd2got, &e);
-  return p ? p->g : NULL;
-}
-
-/* Use BFD2GOT to find ABFD's got entry, creating one if none exists.
-   Return NULL if an error occured.  */
-
-static struct mips_got_info *
-mips_elf_get_got_for_bfd (struct htab *bfd2got, bfd *output_bfd,
-			  bfd *input_bfd)
-{
-  struct mips_elf_bfd2got_hash bfdgot_entry, *bfdgot;
-  struct mips_got_info *g;
-  void **bfdgotp;
-
-  bfdgot_entry.bfd = input_bfd;
-  bfdgotp = htab_find_slot (bfd2got, &bfdgot_entry, INSERT);
-  bfdgot = (struct mips_elf_bfd2got_hash *) *bfdgotp;
-
-  if (bfdgot == NULL)
+  entry = (struct mips_got_entry *) *entryp;
+  arg = (struct mips_elf_traverse_got_arg *) data;
+  slot = htab_find_slot (arg->g->got_entries, entry, INSERT);
+  if (!slot)
     {
-      bfdgot = ((struct mips_elf_bfd2got_hash *)
-		bfd_alloc (output_bfd, sizeof (struct mips_elf_bfd2got_hash)));
-      if (bfdgot == NULL)
-	return NULL;
-
-      *bfdgotp = bfdgot;
-
-      g = ((struct mips_got_info *)
-	   bfd_alloc (output_bfd, sizeof (struct mips_got_info)));
-      if (g == NULL)
-	return NULL;
-
-      bfdgot->bfd = input_bfd;
-      bfdgot->g = g;
-
-      g->global_gotsym = NULL;
-      g->global_gotno = 0;
-      g->reloc_only_gotno = 0;
-      g->local_gotno = 0;
-      g->page_gotno = 0;
-      g->assigned_gotno = -1;
-      g->tls_gotno = 0;
-      g->tls_assigned_gotno = 0;
-      g->tls_ldm_offset = MINUS_ONE;
-      g->got_entries = htab_try_create (1, mips_elf_multi_got_entry_hash,
-					mips_elf_multi_got_entry_eq, NULL);
-      if (g->got_entries == NULL)
-	return NULL;
-
-      g->got_page_entries = htab_try_create (1, mips_got_page_entry_hash,
-					     mips_got_page_entry_eq, NULL);
-      if (g->got_page_entries == NULL)
-	return NULL;
-
-      g->bfd2got = NULL;
-      g->next = NULL;
-    }
-
-  return bfdgot->g;
-}
-
-/* A htab_traverse callback for the entries in the master got.
-   Create one separate got for each bfd that has entries in the global
-   got, such that we can tell how many local and global entries each
-   bfd requires.  */
-
-static int
-mips_elf_make_got_per_bfd (void **entryp, void *p)
-{
-  struct mips_got_entry *entry = (struct mips_got_entry *)*entryp;
-  struct mips_elf_got_per_bfd_arg *arg = (struct mips_elf_got_per_bfd_arg *)p;
-  struct mips_got_info *g;
-
-  g = mips_elf_get_got_for_bfd (arg->bfd2got, arg->obfd, entry->abfd);
-  if (g == NULL)
-    {
-      arg->obfd = NULL;
+      arg->g = NULL;
       return 0;
     }
-
-  /* Insert the GOT entry in the bfd's got entry hash table.  */
-  entryp = htab_find_slot (g->got_entries, entry, INSERT);
-  if (*entryp != NULL)
-    return 1;
-
-  *entryp = entry;
-
-  if (entry->tls_type)
+  if (!*slot)
     {
-      if (entry->tls_type & (GOT_TLS_GD | GOT_TLS_LDM))
-	g->tls_gotno += 2;
-      if (entry->tls_type & GOT_TLS_IE)
-	g->tls_gotno += 1;
+      *slot = entry;
+      mips_elf_count_got_entry (arg->info, arg->g, entry);
     }
-  else if (entry->symndx >= 0 || entry->d.h->global_got_area == GGA_NONE)
-    ++g->local_gotno;
-  else
-    ++g->global_gotno;
-
   return 1;
 }
 
-/* A htab_traverse callback for the page entries in the master got.
-   Associate each page entry with the bfd's got.  */
+/* A htab_traverse callback for GOT page entries.  Add each one to the GOT
+   given in mips_elf_traverse_got_arg DATA.  Clear DATA->G on error.  */
 
 static int
-mips_elf_make_got_pages_per_bfd (void **entryp, void *p)
+mips_elf_add_got_page_entry (void **entryp, void *data)
 {
-  struct mips_got_page_entry *entry = (struct mips_got_page_entry *) *entryp;
-  struct mips_elf_got_per_bfd_arg *arg = (struct mips_elf_got_per_bfd_arg *) p;
-  struct mips_got_info *g;
+  struct mips_got_page_entry *entry;
+  struct mips_elf_traverse_got_arg *arg;
+  void **slot;
 
-  g = mips_elf_get_got_for_bfd (arg->bfd2got, arg->obfd, entry->abfd);
-  if (g == NULL)
+  entry = (struct mips_got_page_entry *) *entryp;
+  arg = (struct mips_elf_traverse_got_arg *) data;
+  slot = htab_find_slot (arg->g->got_page_entries, entry, INSERT);
+  if (!slot)
     {
-      arg->obfd = NULL;
+      arg->g = NULL;
       return 0;
     }
-
-  /* Insert the GOT entry in the bfd's got entry hash table.  */
-  entryp = htab_find_slot (g->got_page_entries, entry, INSERT);
-  if (*entryp != NULL)
-    return 1;
-
-  *entryp = entry;
-  g->page_gotno += entry->num_pages;
+  if (!*slot)
+    {
+      *slot = entry;
+      arg->g->page_gotno += entry->num_pages;
+    }
   return 1;
 }
 
-/* Consider merging the got described by BFD2GOT with TO, using the
-   information given by ARG.  Return -1 if this would lead to overflow,
-   1 if they were merged successfully, and 0 if a merge failed due to
-   lack of memory.  (These values are chosen so that nonnegative return
-   values can be returned by a htab_traverse callback.)  */
+/* Consider merging FROM, which is ABFD's GOT, into TO.  Return -1 if
+   this would lead to overflow, 1 if they were merged successfully,
+   and 0 if a merge failed due to lack of memory.  (These values are chosen
+   so that nonnegative return values can be returned by a htab_traverse
+   callback.)  */
 
 static int
-mips_elf_merge_got_with (struct mips_elf_bfd2got_hash *bfd2got,
+mips_elf_merge_got_with (bfd *abfd, struct mips_got_info *from,
 			 struct mips_got_info *to,
 			 struct mips_elf_got_per_bfd_arg *arg)
 {
-  struct mips_got_info *from = bfd2got->g;
+  struct mips_elf_traverse_got_arg tga;
   unsigned int estimate;
 
   /* Work out how many page entries we would need for the combined GOT.  */
@@ -4194,10 +4426,10 @@
   estimate += from->local_gotno + to->local_gotno;
   estimate += from->tls_gotno + to->tls_gotno;
 
-  /* If we're merging with the primary got, we will always have
-     the full set of global entries.  Otherwise estimate those
+  /* If we're merging with the primary got, any TLS relocations will
+     come after the full set of global entries.  Otherwise estimate those
      conservatively as well.  */
-  if (to == arg->primary)
+  if (to == arg->primary && from->tls_gotno + to->tls_gotno)
     estimate += arg->global_count;
   else
     estimate += from->global_gotno + to->global_gotno;
@@ -4206,44 +4438,37 @@
   if (estimate > arg->max_count)
     return -1;
 
-  /* Commit to the merge.  Record that TO is now the bfd for this got.  */
-  bfd2got->g = to;
-
   /* Transfer the bfd's got information from FROM to TO.  */
-  htab_traverse (from->got_entries, mips_elf_make_got_per_bfd, arg);
-  if (arg->obfd == NULL)
+  tga.info = arg->info;
+  tga.g = to;
+  htab_traverse (from->got_entries, mips_elf_add_got_entry, &tga);
+  if (!tga.g)
     return 0;
 
-  htab_traverse (from->got_page_entries, mips_elf_make_got_pages_per_bfd, arg);
-  if (arg->obfd == NULL)
+  htab_traverse (from->got_page_entries, mips_elf_add_got_page_entry, &tga);
+  if (!tga.g)
     return 0;
 
-  /* We don't have to worry about releasing memory of the actual
-     got entries, since they're all in the master got_entries hash
-     table anyway.  */
-  htab_delete (from->got_entries);
-  htab_delete (from->got_page_entries);
+  mips_elf_replace_bfd_got (abfd, to);
   return 1;
 }
 
-/* Attempt to merge gots of different input bfds.  Try to use as much
+/* Attempt to merge GOT G, which belongs to ABFD.  Try to use as much
    as possible of the primary got, since it doesn't require explicit
    dynamic relocations, but don't use bfds that would reference global
    symbols out of the addressable range.  Failing the primary got,
    attempt to merge with the current got, or finish the current got
    and then make make the new got current.  */
 
-static int
-mips_elf_merge_gots (void **bfd2got_, void *p)
+static bfd_boolean
+mips_elf_merge_got (bfd *abfd, struct mips_got_info *g,
+		    struct mips_elf_got_per_bfd_arg *arg)
 {
-  struct mips_elf_bfd2got_hash *bfd2got
-    = (struct mips_elf_bfd2got_hash *)*bfd2got_;
-  struct mips_elf_got_per_bfd_arg *arg = (struct mips_elf_got_per_bfd_arg *)p;
-  struct mips_got_info *g;
   unsigned int estimate;
   int result;
 
-  g = bfd2got->g;
+  if (!mips_elf_resolve_final_got_entries (arg->info, g))
+    return FALSE;
 
   /* Work out the number of page, local and TLS entries.  */
   estimate = arg->max_pages;
@@ -4263,12 +4488,12 @@
 	 a starting point for the primary GOT.  */
       if (!arg->primary)
 	{
-	  arg->primary = bfd2got->g;
-	  return 1;
+	  arg->primary = g;
+	  return TRUE;
 	}
 
       /* Try merging with the primary GOT.  */
-      result = mips_elf_merge_got_with (bfd2got, arg->primary, arg);
+      result = mips_elf_merge_got_with (abfd, g, arg->primary, arg);
       if (result >= 0)
 	return result;
     }
@@ -4276,7 +4501,7 @@
   /* If we can merge with the last-created got, do it.  */
   if (arg->current)
     {
-      result = mips_elf_merge_got_with (bfd2got, arg->current, arg);
+      result = mips_elf_merge_got_with (abfd, g, arg->current, arg);
       if (result >= 0)
 	return result;
     }
@@ -4287,106 +4512,110 @@
   g->next = arg->current;
   arg->current = g;
 
-  return 1;
+  return TRUE;
 }
 
-/* Set the TLS GOT index for the GOT entry in ENTRYP.  ENTRYP's NEXT field
-   is null iff there is just a single GOT.  */
+/* ENTRYP is a hash table entry for a mips_got_entry.  Set its gotidx
+   to GOTIDX, duplicating the entry if it has already been assigned
+   an index in a different GOT.  */
+
+static bfd_boolean
+mips_elf_set_gotidx (void **entryp, long gotidx)
+{
+  struct mips_got_entry *entry;
+
+  entry = (struct mips_got_entry *) *entryp;
+  if (entry->gotidx > 0)
+    {
+      struct mips_got_entry *new_entry;
+
+      new_entry = bfd_alloc (entry->abfd, sizeof (*entry));
+      if (!new_entry)
+	return FALSE;
+
+      *new_entry = *entry;
+      *entryp = new_entry;
+      entry = new_entry;
+    }
+  entry->gotidx = gotidx;
+  return TRUE;
+}
+
+/* Set the TLS GOT index for the GOT entry in ENTRYP.  DATA points to a
+   mips_elf_traverse_got_arg in which DATA->value is the size of one
+   GOT entry.  Set DATA->g to null on failure.  */
 
 static int
-mips_elf_initialize_tls_index (void **entryp, void *p)
+mips_elf_initialize_tls_index (void **entryp, void *data)
 {
-  struct mips_got_entry *entry = (struct mips_got_entry *)*entryp;
-  struct mips_got_info *g = p;
-  bfd_vma next_index;
-  unsigned char tls_type;
+  struct mips_got_entry *entry;
+  struct mips_elf_traverse_got_arg *arg;
 
   /* We're only interested in TLS symbols.  */
-  if (entry->tls_type == 0)
+  entry = (struct mips_got_entry *) *entryp;
+  if (entry->tls_type == GOT_TLS_NONE)
     return 1;
 
-  next_index = MIPS_ELF_GOT_SIZE (entry->abfd) * (long) g->tls_assigned_gotno;
-
-  if (entry->symndx == -1 && g->next == NULL)
+  arg = (struct mips_elf_traverse_got_arg *) data;
+  if (!mips_elf_set_gotidx (entryp, arg->value * arg->g->tls_assigned_gotno))
     {
-      /* A type (3) got entry in the single-GOT case.  We use the symbol's
-	 hash table entry to track its index.  */
-      if (entry->d.h->tls_type & GOT_TLS_OFFSET_DONE)
-	return 1;
-      entry->d.h->tls_type |= GOT_TLS_OFFSET_DONE;
-      entry->d.h->tls_got_offset = next_index;
-      tls_type = entry->d.h->tls_type;
-    }
-  else
-    {
-      if (entry->tls_type & GOT_TLS_LDM)
-	{
-	  /* There are separate mips_got_entry objects for each input bfd
-	     that requires an LDM entry.  Make sure that all LDM entries in
-	     a GOT resolve to the same index.  */
-	  if (g->tls_ldm_offset != MINUS_TWO && g->tls_ldm_offset != MINUS_ONE)
-	    {
-	      entry->gotidx = g->tls_ldm_offset;
-	      return 1;
-	    }
-	  g->tls_ldm_offset = next_index;
-	}
-      entry->gotidx = next_index;
-      tls_type = entry->tls_type;
+      arg->g = NULL;
+      return 0;
     }
 
   /* Account for the entries we've just allocated.  */
-  if (tls_type & (GOT_TLS_GD | GOT_TLS_LDM))
-    g->tls_assigned_gotno += 2;
-  if (tls_type & GOT_TLS_IE)
-    g->tls_assigned_gotno += 1;
-
+  arg->g->tls_assigned_gotno += mips_tls_got_entries (entry->tls_type);
   return 1;
 }
 
-/* If passed a NULL mips_got_info in the argument, set the marker used
-   to tell whether a global symbol needs a got entry (in the primary
-   got) to the given VALUE.
+/* A htab_traverse callback for GOT entries, where DATA points to a
+   mips_elf_traverse_got_arg.  Set the global_got_area of each global
+   symbol to DATA->value.  */
 
-   If passed a pointer G to a mips_got_info in the argument (it must
-   not be the primary GOT), compute the offset from the beginning of
-   the (primary) GOT section to the entry in G corresponding to the
-   global symbol.  G's assigned_gotno must contain the index of the
-   first available global GOT entry in G.  VALUE must contain the size
-   of a GOT entry in bytes.  For each global GOT entry that requires a
-   dynamic relocation, NEEDED_RELOCS is incremented, and the symbol is
-   marked as not eligible for lazy resolution through a function
-   stub.  */
 static int
-mips_elf_set_global_got_offset (void **entryp, void *p)
+mips_elf_set_global_got_area (void **entryp, void *data)
 {
-  struct mips_got_entry *entry = (struct mips_got_entry *)*entryp;
-  struct mips_elf_set_global_got_offset_arg *arg
-    = (struct mips_elf_set_global_got_offset_arg *)p;
-  struct mips_got_info *g = arg->g;
+  struct mips_got_entry *entry;
+  struct mips_elf_traverse_got_arg *arg;
 
-  if (g && entry->tls_type != GOT_NORMAL)
-    arg->needed_relocs +=
-      mips_tls_got_relocs (arg->info, entry->tls_type,
-			   entry->symndx == -1 ? &entry->d.h->root : NULL);
+  entry = (struct mips_got_entry *) *entryp;
+  arg = (struct mips_elf_traverse_got_arg *) data;
+  if (entry->abfd != NULL
+      && entry->symndx == -1
+      && entry->d.h->global_got_area != GGA_NONE)
+    entry->d.h->global_got_area = arg->value;
+  return 1;
+}
 
+/* A htab_traverse callback for secondary GOT entries, where DATA points
+   to a mips_elf_traverse_got_arg.  Assign GOT indices to global entries
+   and record the number of relocations they require.  DATA->value is
+   the size of one GOT entry.  Set DATA->g to null on failure.  */
+
+static int
+mips_elf_set_global_gotidx (void **entryp, void *data)
+{
+  struct mips_got_entry *entry;
+  struct mips_elf_traverse_got_arg *arg;
+
+  entry = (struct mips_got_entry *) *entryp;
+  arg = (struct mips_elf_traverse_got_arg *) data;
   if (entry->abfd != NULL
       && entry->symndx == -1
       && entry->d.h->global_got_area != GGA_NONE)
     {
-      if (g)
+      if (!mips_elf_set_gotidx (entryp, arg->value * arg->g->assigned_gotno))
 	{
-	  BFD_ASSERT (g->global_gotsym == NULL);
-
-	  entry->gotidx = arg->value * (long) g->assigned_gotno++;
-	  if (arg->info->shared
-	      || (elf_hash_table (arg->info)->dynamic_sections_created
-		  && entry->d.h->root.def_dynamic
-		  && !entry->d.h->root.def_regular))
-	    ++arg->needed_relocs;
+	  arg->g = NULL;
+	  return 0;
 	}
-      else
-	entry->d.h->global_got_area = arg->value;
+      arg->g->assigned_gotno += 1;
+
+      if (arg->info->shared
+	  || (elf_hash_table (arg->info)->dynamic_sections_created
+	      && entry->d.h->root.def_dynamic
+	      && !entry->d.h->root.def_regular))
+	arg->g->relocs += 1;
     }
 
   return 1;
@@ -4424,10 +4653,10 @@
 static bfd_vma
 mips_elf_adjust_gp (bfd *abfd, struct mips_got_info *g, bfd *ibfd)
 {
-  if (g->bfd2got == NULL)
+  if (!g->next)
     return 0;
 
-  g = mips_elf_got_for_ibfd (g, ibfd);
+  g = mips_elf_bfd_got (ibfd, FALSE);
   if (! g)
     return 0;
 
@@ -4448,37 +4677,19 @@
 {
   struct mips_elf_link_hash_table *htab;
   struct mips_elf_got_per_bfd_arg got_per_bfd_arg;
-  struct mips_elf_set_global_got_offset_arg set_got_offset_arg;
+  struct mips_elf_traverse_got_arg tga;
   struct mips_got_info *g, *gg;
   unsigned int assign, needed_relocs;
-  bfd *dynobj;
+  bfd *dynobj, *ibfd;
 
   dynobj = elf_hash_table (info)->dynobj;
   htab = mips_elf_hash_table (info);
   BFD_ASSERT (htab != NULL);
 
   g = htab->got_info;
-  g->bfd2got = htab_try_create (1, mips_elf_bfd2got_entry_hash,
-				mips_elf_bfd2got_entry_eq, NULL);
-  if (g->bfd2got == NULL)
-    return FALSE;
 
-  got_per_bfd_arg.bfd2got = g->bfd2got;
   got_per_bfd_arg.obfd = abfd;
   got_per_bfd_arg.info = info;
-
-  /* Count how many GOT entries each input bfd requires, creating a
-     map from bfd to got info while at that.  */
-  htab_traverse (g->got_entries, mips_elf_make_got_per_bfd, &got_per_bfd_arg);
-  if (got_per_bfd_arg.obfd == NULL)
-    return FALSE;
-
-  /* Also count how many page entries each input bfd requires.  */
-  htab_traverse (g->got_page_entries, mips_elf_make_got_pages_per_bfd,
-		 &got_per_bfd_arg);
-  if (got_per_bfd_arg.obfd == NULL)
-    return FALSE;
-
   got_per_bfd_arg.current = NULL;
   got_per_bfd_arg.primary = NULL;
   got_per_bfd_arg.max_count = ((MIPS_ELF_GOT_MAX_SIZE (info)
@@ -4486,46 +4697,23 @@
 			       - htab->reserved_gotno);
   got_per_bfd_arg.max_pages = pages;
   /* The number of globals that will be included in the primary GOT.
-     See the calls to mips_elf_set_global_got_offset below for more
+     See the calls to mips_elf_set_global_got_area below for more
      information.  */
   got_per_bfd_arg.global_count = g->global_gotno;
 
   /* Try to merge the GOTs of input bfds together, as long as they
      don't seem to exceed the maximum GOT size, choosing one of them
      to be the primary GOT.  */
-  htab_traverse (g->bfd2got, mips_elf_merge_gots, &got_per_bfd_arg);
-  if (got_per_bfd_arg.obfd == NULL)
-    return FALSE;
+  for (ibfd = info->input_bfds; ibfd; ibfd = ibfd->link_next)
+    {
+      gg = mips_elf_bfd_got (ibfd, FALSE);
+      if (gg && !mips_elf_merge_got (ibfd, gg, &got_per_bfd_arg))
+	return FALSE;
+    }
 
   /* If we do not find any suitable primary GOT, create an empty one.  */
   if (got_per_bfd_arg.primary == NULL)
-    {
-      g->next = (struct mips_got_info *)
-	bfd_alloc (abfd, sizeof (struct mips_got_info));
-      if (g->next == NULL)
-	return FALSE;
-
-      g->next->global_gotsym = NULL;
-      g->next->global_gotno = 0;
-      g->next->reloc_only_gotno = 0;
-      g->next->local_gotno = 0;
-      g->next->page_gotno = 0;
-      g->next->tls_gotno = 0;
-      g->next->assigned_gotno = 0;
-      g->next->tls_assigned_gotno = 0;
-      g->next->tls_ldm_offset = MINUS_ONE;
-      g->next->got_entries = htab_try_create (1, mips_elf_multi_got_entry_hash,
-					      mips_elf_multi_got_entry_eq,
-					      NULL);
-      if (g->next->got_entries == NULL)
-	return FALSE;
-      g->next->got_page_entries = htab_try_create (1, mips_got_page_entry_hash,
-						   mips_got_page_entry_eq,
-						   NULL);
-      if (g->next->got_page_entries == NULL)
-	return FALSE;
-      g->next->bfd2got = NULL;
-    }
+    g->next = mips_elf_create_got_info (abfd);
   else
     g->next = got_per_bfd_arg.primary;
   g->next->next = got_per_bfd_arg.current;
@@ -4539,23 +4727,7 @@
      didn't mark in check_relocs, and we want a quick way to find it.
      We can't just use gg->next because we're going to reverse the
      list.  */
-  {
-    struct mips_elf_bfd2got_hash *bfdgot;
-    void **bfdgotp;
-
-    bfdgot = (struct mips_elf_bfd2got_hash *)bfd_alloc
-      (abfd, sizeof (struct mips_elf_bfd2got_hash));
-
-    if (bfdgot == NULL)
-      return FALSE;
-
-    bfdgot->bfd = abfd;
-    bfdgot->g = g;
-    bfdgotp = htab_find_slot (gg->bfd2got, bfdgot, INSERT);
-
-    BFD_ASSERT (*bfdgotp == NULL);
-    *bfdgotp = bfdgot;
-  }
+  mips_elf_replace_bfd_got (abfd, g);
 
   /* Every symbol that is referenced in a dynamic relocation must be
      present in the primary GOT, so arrange for them to appear after
@@ -4563,13 +4735,11 @@
   gg->reloc_only_gotno = gg->global_gotno - g->global_gotno;
   g->global_gotno = gg->global_gotno;
 
-  set_got_offset_arg.g = NULL;
-  set_got_offset_arg.value = GGA_RELOC_ONLY;
-  htab_traverse (gg->got_entries, mips_elf_set_global_got_offset,
-		 &set_got_offset_arg);
-  set_got_offset_arg.value = GGA_NORMAL;
-  htab_traverse (g->got_entries, mips_elf_set_global_got_offset,
-		 &set_got_offset_arg);
+  tga.info = info;
+  tga.value = GGA_RELOC_ONLY;
+  htab_traverse (gg->got_entries, mips_elf_set_global_got_area, &tga);
+  tga.value = GGA_NORMAL;
+  htab_traverse (g->got_entries, mips_elf_set_global_got_area, &tga);
 
   /* Now go through the GOTs assigning them offset ranges.
      [assigned_gotno, local_gotno[ will be set to the range of local
@@ -4610,7 +4780,12 @@
       /* Set up any TLS entries.  We always place the TLS entries after
 	 all non-TLS entries.  */
       g->tls_assigned_gotno = g->local_gotno + g->global_gotno;
-      htab_traverse (g->got_entries, mips_elf_initialize_tls_index, g);
+      tga.g = g;
+      tga.value = MIPS_ELF_GOT_SIZE (abfd);
+      htab_traverse (g->got_entries, mips_elf_initialize_tls_index, &tga);
+      if (!tga.g)
+	return FALSE;
+      BFD_ASSERT (g->tls_assigned_gotno == assign);
 
       /* Move onto the next GOT.  It will be a secondary GOT if nonull.  */
       g = gn;
@@ -4622,38 +4797,37 @@
     }
   while (g);
 
-  got->size = (gg->next->local_gotno
-	       + gg->next->global_gotno
-	       + gg->next->tls_gotno) * MIPS_ELF_GOT_SIZE (abfd);
+  got->size = assign * MIPS_ELF_GOT_SIZE (abfd);
 
   needed_relocs = 0;
-  set_got_offset_arg.value = MIPS_ELF_GOT_SIZE (abfd);
-  set_got_offset_arg.info = info;
   for (g = gg->next; g && g->next != gg; g = g->next)
     {
       unsigned int save_assign;
 
-      /* Assign offsets to global GOT entries.  */
+      /* Assign offsets to global GOT entries and count how many
+	 relocations they need.  */
       save_assign = g->assigned_gotno;
       g->assigned_gotno = g->local_gotno;
-      set_got_offset_arg.g = g;
-      set_got_offset_arg.needed_relocs = 0;
-      htab_traverse (g->got_entries,
-		     mips_elf_set_global_got_offset,
-		     &set_got_offset_arg);
-      needed_relocs += set_got_offset_arg.needed_relocs;
-      BFD_ASSERT (g->assigned_gotno - g->local_gotno <= g->global_gotno);
-
+      tga.info = info;
+      tga.value = MIPS_ELF_GOT_SIZE (abfd);
+      tga.g = g;
+      htab_traverse (g->got_entries, mips_elf_set_global_gotidx, &tga);
+      if (!tga.g)
+	return FALSE;
+      BFD_ASSERT (g->assigned_gotno == g->local_gotno + g->global_gotno);
       g->assigned_gotno = save_assign;
+
       if (info->shared)
 	{
-	  needed_relocs += g->local_gotno - g->assigned_gotno;
+	  g->relocs += g->local_gotno - g->assigned_gotno;
 	  BFD_ASSERT (g->assigned_gotno == g->next->local_gotno
 		      + g->next->global_gotno
 		      + g->next->tls_gotno
 		      + htab->reserved_gotno);
 	}
+      needed_relocs += g->relocs;
     }
+  needed_relocs += g->relocs;
 
   if (needed_relocs)
     mips_elf_allocate_dynamic_relocations (dynobj, info,
@@ -4784,12 +4958,12 @@
   flagword flags;
   register asection *s;
 
-  if (bfd_get_section_by_name (abfd, ".compact_rel") == NULL)
+  if (bfd_get_linker_section (abfd, ".compact_rel") == NULL)
     {
       flags = (SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED
 	       | SEC_READONLY);
 
-      s = bfd_make_section_with_flags (abfd, ".compact_rel", flags);
+      s = bfd_make_section_anyway_with_flags (abfd, ".compact_rel", flags);
       if (s == NULL
 	  || ! bfd_set_section_alignment (abfd, s,
 					  MIPS_ELF_LOG_FILE_ALIGN (abfd)))
@@ -4810,8 +4984,6 @@
   register asection *s;
   struct elf_link_hash_entry *h;
   struct bfd_link_hash_entry *bh;
-  struct mips_got_info *g;
-  bfd_size_type amt;
   struct mips_elf_link_hash_table *htab;
 
   htab = mips_elf_hash_table (info);
@@ -4826,7 +4998,7 @@
 
   /* We have to use an alignment of 2**4 here because this is hardcoded
      in the function stub generation and in the linker script.  */
-  s = bfd_make_section_with_flags (abfd, ".got", flags);
+  s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, 4))
     return FALSE;
@@ -4845,42 +5017,23 @@
   h->non_elf = 0;
   h->def_regular = 1;
   h->type = STT_OBJECT;
+  h->other = (h->other & ~ELF_ST_VISIBILITY (-1)) | STV_HIDDEN;
   elf_hash_table (info)->hgot = h;
 
   if (info->shared
       && ! bfd_elf_link_record_dynamic_symbol (info, h))
     return FALSE;
 
-  amt = sizeof (struct mips_got_info);
-  g = bfd_alloc (abfd, amt);
-  if (g == NULL)
-    return FALSE;
-  g->global_gotsym = NULL;
-  g->global_gotno = 0;
-  g->reloc_only_gotno = 0;
-  g->tls_gotno = 0;
-  g->local_gotno = 0;
-  g->page_gotno = 0;
-  g->assigned_gotno = 0;
-  g->bfd2got = NULL;
-  g->next = NULL;
-  g->tls_ldm_offset = MINUS_ONE;
-  g->got_entries = htab_try_create (1, mips_elf_got_entry_hash,
-				    mips_elf_got_entry_eq, NULL);
-  if (g->got_entries == NULL)
-    return FALSE;
-  g->got_page_entries = htab_try_create (1, mips_got_page_entry_hash,
-					 mips_got_page_entry_eq, NULL);
-  if (g->got_page_entries == NULL)
-    return FALSE;
-  htab->got_info = g;
+  htab->got_info = mips_elf_create_got_info (abfd);
   mips_elf_section_data (s)->elf.this_hdr.sh_flags
     |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL;
 
   /* We also need a .got.plt section when generating PLTs.  */
-  s = bfd_make_section_with_flags (abfd, ".got.plt",
-				   SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
-				   | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+  s = bfd_make_section_anyway_with_flags (abfd, ".got.plt",
+					  SEC_ALLOC | SEC_LOAD
+					  | SEC_HAS_CONTENTS
+					  | SEC_IN_MEMORY
+					  | SEC_LINKER_CREATED);
   if (s == NULL)
     return FALSE;
   htab->sgotplt = s;
@@ -4907,7 +5060,8 @@
    stub.  */
 
 static bfd_boolean
-mips_elf_relocation_needs_la25_stub (bfd *input_bfd, int r_type)
+mips_elf_relocation_needs_la25_stub (bfd *input_bfd, int r_type,
+				     bfd_boolean target_is_16_bit_code_p)
 {
   /* We specifically ignore branches and jumps from EF_PIC objects,
      where the onus is on the compiler or programmer to perform any
@@ -4921,7 +5075,6 @@
     {
     case R_MIPS_26:
     case R_MIPS_PC16:
-    case R_MIPS16_26:
     case R_MICROMIPS_26_S1:
     case R_MICROMIPS_PC7_S1:
     case R_MICROMIPS_PC10_S1:
@@ -4929,6 +5082,9 @@
     case R_MICROMIPS_PC23_S2:
       return TRUE;
 
+    case R_MIPS16_26:
+      return !target_is_16_bit_code_p;
+
     default:
       return FALSE;
     }
@@ -5160,10 +5316,7 @@
 	}
 
       target_is_16_bit_code_p = ELF_ST_IS_MIPS16 (h->root.other);
-      /* If the output section is the PLT section,
-         then the target is not microMIPS.  */
-      target_is_micromips_code_p = (htab->splt != sec
-				    && ELF_ST_IS_MICROMIPS (h->root.other));
+      target_is_micromips_code_p = ELF_ST_IS_MICROMIPS (h->root.other);
     }
 
   /* If this is a reference to a 16-bit function with a stub, we need
@@ -5181,38 +5334,52 @@
 	   && h->fn_stub != NULL
 	   && (r_type != R_MIPS16_CALL16 || h->need_fn_stub))
 	  || (local_p
-	      && elf_tdata (input_bfd)->local_stubs != NULL
-	      && elf_tdata (input_bfd)->local_stubs[r_symndx] != NULL))
+	      && mips_elf_tdata (input_bfd)->local_stubs != NULL
+	      && mips_elf_tdata (input_bfd)->local_stubs[r_symndx] != NULL))
       && !section_allows_mips16_refs_p (input_section))
     {
       /* This is a 32- or 64-bit call to a 16-bit function.  We should
 	 have already noticed that we were going to need the
 	 stub.  */
       if (local_p)
-	sec = elf_tdata (input_bfd)->local_stubs[r_symndx];
+	{
+	  sec = mips_elf_tdata (input_bfd)->local_stubs[r_symndx];
+	  value = 0;
+	}
       else
 	{
 	  BFD_ASSERT (h->need_fn_stub);
-	  sec = h->fn_stub;
+	  if (h->la25_stub)
+	    {
+	      /* If a LA25 header for the stub itself exists, point to the
+		 prepended LUI/ADDIU sequence.  */
+	      sec = h->la25_stub->stub_section;
+	      value = h->la25_stub->offset;
+	    }
+	  else
+	    {
+	      sec = h->fn_stub;
+	      value = 0;
+	    }
 	}
 
-      symbol = sec->output_section->vma + sec->output_offset;
+      symbol = sec->output_section->vma + sec->output_offset + value;
       /* The target is 16-bit, but the stub isn't.  */
       target_is_16_bit_code_p = FALSE;
     }
-  /* If this is a 16-bit call to a 32- or 64-bit function with a stub, we
-     need to redirect the call to the stub.  Note that we specifically
-     exclude R_MIPS16_CALL16 from this behavior; indirect calls should
-     use an indirect stub instead.  */
+  /* If this is a MIPS16 call with a stub, that is made through the PLT or
+     to a standard MIPS function, we need to redirect the call to the stub.
+     Note that we specifically exclude R_MIPS16_CALL16 from this behavior;
+     indirect calls should use an indirect stub instead.  */
   else if (r_type == R_MIPS16_26 && !info->relocatable
 	   && ((h != NULL && (h->call_stub != NULL || h->call_fp_stub != NULL))
 	       || (local_p
-		   && elf_tdata (input_bfd)->local_call_stubs != NULL
-		   && elf_tdata (input_bfd)->local_call_stubs[r_symndx] != NULL))
-	   && !target_is_16_bit_code_p)
+		   && mips_elf_tdata (input_bfd)->local_call_stubs != NULL
+		   && mips_elf_tdata (input_bfd)->local_call_stubs[r_symndx] != NULL))
+	   && ((h != NULL && h->use_plt_entry) || !target_is_16_bit_code_p))
     {
       if (local_p)
-	sec = elf_tdata (input_bfd)->local_call_stubs[r_symndx];
+	sec = mips_elf_tdata (input_bfd)->local_call_stubs[r_symndx];
       else
 	{
 	  /* If both call_stub and call_fp_stub are defined, we can figure
@@ -5221,7 +5388,7 @@
 	  if (h->call_stub != NULL && h->call_fp_stub != NULL)
 	    {
 	      asection *o;
-	      
+
 	      sec = NULL;
 	      for (o = input_bfd->sections; o != NULL; o = o->next)
 		{
@@ -5246,10 +5413,36 @@
   /* If this is a direct call to a PIC function, redirect to the
      non-PIC stub.  */
   else if (h != NULL && h->la25_stub
-	   && mips_elf_relocation_needs_la25_stub (input_bfd, r_type))
+	   && mips_elf_relocation_needs_la25_stub (input_bfd, r_type,
+						   target_is_16_bit_code_p))
     symbol = (h->la25_stub->stub_section->output_section->vma
 	      + h->la25_stub->stub_section->output_offset
 	      + h->la25_stub->offset);
+  /* For direct MIPS16 and microMIPS calls make sure the compressed PLT
+     entry is used if a standard PLT entry has also been made.  In this
+     case the symbol will have been set by mips_elf_set_plt_sym_value
+     to point to the standard PLT entry, so redirect to the compressed
+     one.  */
+  else if ((r_type == R_MIPS16_26 || r_type == R_MICROMIPS_26_S1)
+	   && !info->relocatable
+	   && h != NULL
+	   && h->use_plt_entry
+	   && h->root.plt.plist->comp_offset != MINUS_ONE
+	   && h->root.plt.plist->mips_offset != MINUS_ONE)
+    {
+      bfd_boolean micromips_p = MICROMIPS_P (abfd);
+
+      sec = htab->splt;
+      symbol = (sec->output_section->vma
+		+ sec->output_offset
+		+ htab->plt_header_size
+		+ htab->plt_mips_offset
+		+ h->root.plt.plist->comp_offset
+		+ 1);
+
+      target_is_16_bit_code_p = !micromips_p;
+      target_is_micromips_code_p = micromips_p;
+    }
 
   /* Make sure MIPS16 and microMIPS are not used together.  */
   if ((r_type == R_MIPS16_26 && target_is_micromips_code_p)
@@ -5275,7 +5468,10 @@
 				&& (target_is_16_bit_code_p
 				    || target_is_micromips_code_p))));
 
-  local_p = h == NULL || SYMBOL_REFERENCES_LOCAL (info, &h->root);
+  local_p = (h == NULL
+	     || (h->got_only_for_calls
+		 ? SYMBOL_CALLS_LOCAL (info, &h->root)
+		 : SYMBOL_REFERENCES_LOCAL (info, &h->root)));
 
   gp0 = _bfd_get_gp_value (input_bfd);
   gp = _bfd_get_gp_value (abfd);
@@ -5318,6 +5514,9 @@
     case R_MIPS_TLS_GD:
     case R_MIPS_TLS_GOTTPREL:
     case R_MIPS_TLS_LDM:
+    case R_MIPS16_TLS_GD:
+    case R_MIPS16_TLS_GOTTPREL:
+    case R_MIPS16_TLS_LDM:
     case R_MICROMIPS_TLS_GD:
     case R_MICROMIPS_TLS_GOTTPREL:
     case R_MICROMIPS_TLS_LDM:
@@ -5345,9 +5544,9 @@
 	  else
 	    {
 	      BFD_ASSERT (addend == 0);
-	      g = mips_elf_global_got_index (dynobj, input_bfd,
-					     &h->root, r_type, info);
-	      if (h->tls_type == GOT_NORMAL
+	      g = mips_elf_global_got_index (abfd, info, input_bfd,
+					     &h->root, r_type);
+	      if (!TLS_RELOC_P (r_type)
 		  && !elf_hash_table (info)->dynamic_sections_created)
 		/* This is a static link.  We must initialize the GOT entry.  */
 		MIPS_ELF_PUT_WORD (dynobj, symbol, htab->sgot->contents + g);
@@ -5487,6 +5686,7 @@
       break;
 
     case R_MIPS_TLS_DTPREL_HI16:
+    case R_MIPS16_TLS_DTPREL_HI16:
     case R_MICROMIPS_TLS_DTPREL_HI16:
       value = (mips_elf_high (addend + symbol - dtprel_base (info))
 	       & howto->dst_mask);
@@ -5495,17 +5695,22 @@
     case R_MIPS_TLS_DTPREL_LO16:
     case R_MIPS_TLS_DTPREL32:
     case R_MIPS_TLS_DTPREL64:
+    case R_MIPS16_TLS_DTPREL_LO16:
     case R_MICROMIPS_TLS_DTPREL_LO16:
       value = (symbol + addend - dtprel_base (info)) & howto->dst_mask;
       break;
 
     case R_MIPS_TLS_TPREL_HI16:
+    case R_MIPS16_TLS_TPREL_HI16:
     case R_MICROMIPS_TLS_TPREL_HI16:
       value = (mips_elf_high (addend + symbol - tprel_base (info))
 	       & howto->dst_mask);
       break;
 
     case R_MIPS_TLS_TPREL_LO16:
+    case R_MIPS_TLS_TPREL32:
+    case R_MIPS_TLS_TPREL64:
+    case R_MIPS16_TLS_TPREL_LO16:
     case R_MICROMIPS_TLS_TPREL_LO16:
       value = (symbol + addend - tprel_base (info)) & howto->dst_mask;
       break;
@@ -5527,10 +5732,11 @@
 	       12: addu    $v0,$v1
 	       14: move    $gp,$v0
 	     So the offsets of hi and lo relocs are the same, but the
-	     $pc is four higher than $t9 would be, so reduce
-	     both reloc addends by 4. */
+	     base $pc is that used by the ADDIUPC instruction at $t9 + 4.
+	     ADDIUPC clears the low two bits of the instruction address,
+	     so the base is ($t9 + 4) & ~3.  */
 	  if (r_type == R_MIPS16_HI16)
-	    value = mips_elf_high (addend + gp - p - 4);
+	    value = mips_elf_high (addend + gp - ((p + 4) & ~(bfd_vma) 0x3));
 	  /* The microMIPS .cpload sequence uses the same assembly
 	     instructions as the traditional psABI version, but the
 	     incoming $t9 has the low bit set.  */
@@ -5553,7 +5759,7 @@
 	  /* See the comment for R_MIPS16_HI16 above for the reason
 	     for this conditional.  */
 	  if (r_type == R_MIPS16_LO16)
-	    value = addend + gp - p;
+	    value = addend + gp - (p & ~(bfd_vma) 0x3);
 	  else if (r_type == R_MICROMIPS_LO16
 		   || r_type == R_MICROMIPS_HI0_LO16)
 	    value = addend + gp - p + 3;
@@ -5637,6 +5843,9 @@
     case R_MIPS_TLS_GOTTPREL:
     case R_MIPS_TLS_LDM:
     case R_MIPS_GOT_DISP:
+    case R_MIPS16_TLS_GD:
+    case R_MIPS16_TLS_GOTTPREL:
+    case R_MIPS16_TLS_LDM:
     case R_MICROMIPS_TLS_GD:
     case R_MICROMIPS_TLS_GOTTPREL:
     case R_MICROMIPS_TLS_LDM:
@@ -5793,7 +6002,7 @@
 /* It has been determined that the result of the RELOCATION is the
    VALUE.  Use HOWTO to place VALUE into the output file at the
    appropriate position.  The SECTION is the section to which the
-   relocation applies.  
+   relocation applies.
    CROSS_MODE_JUMP_P is true if the relocation field
    is a MIPS16 or microMIPS jump to standard MIPS code, or vice versa.
 
@@ -5849,11 +6058,12 @@
 	  jalx_opcode = 0x1d;
 	}
 
-      /* If the opcode is not JAL or JALX, there's a problem.  */
+      /* If the opcode is not JAL or JALX, there's a problem.  We cannot
+         convert J or JALS to JALX.  */
       if (!ok)
 	{
 	  (*_bfd_error_handler)
-	    (_("%B: %A+0x%lx: Direct jumps between ISA modes are not allowed; consider recompiling with interlinking enabled."),
+	    (_("%B: %A+0x%lx: Unsupported jump between ISA modes; consider recompiling with interlinking enabled."),
 	     input_bfd,
 	     input_section,
 	     (unsigned long) relocation->r_offset);
@@ -6099,7 +6309,7 @@
   /* On IRIX5, make an entry of compact relocation info.  */
   if (IRIX_COMPAT (output_bfd) == ict_irix5)
     {
-      asection *scpt = bfd_get_section_by_name (dynobj, ".compact_rel");
+      asection *scpt = bfd_get_linker_section (dynobj, ".compact_rel");
       bfd_byte *cr;
 
       if (scpt)
@@ -6167,6 +6377,9 @@
     case E_MIPS_MACH_5500:
       return bfd_mach_mips5500;
 
+    case E_MIPS_MACH_5900:
+      return bfd_mach_mips5900;
+
     case E_MIPS_MACH_9000:
       return bfd_mach_mips9000;
 
@@ -6182,6 +6395,9 @@
     case E_MIPS_MACH_LS3A:
       return bfd_mach_mips_loongson_3a;
 
+    case E_MIPS_MACH_OCTEON2:
+      return bfd_mach_mips_octeon2;
+
     case E_MIPS_MACH_OCTEON:
       return bfd_mach_mips_octeon;
 
@@ -6337,7 +6553,6 @@
       {
 	asection *section = bfd_get_section_by_name (abfd, ".text");
 
-	BFD_ASSERT (SGI_COMPAT (abfd));
 	if (section != NULL)
 	  {
 	    asym->section = section;
@@ -6353,7 +6568,6 @@
       {
 	asection *section = bfd_get_section_by_name (abfd, ".data");
 
-	BFD_ASSERT (SGI_COMPAT (abfd));
 	if (section != NULL)
 	  {
 	    asym->section = section;
@@ -6372,7 +6586,7 @@
       && (asym->value & 1) != 0)
     {
       asym->value--;
-      if (elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH_ASE_MICROMIPS)
+      if (MICROMIPS_P (abfd))
 	elfsym->internal_elf_sym.st_other
 	  = ELF_ST_SET_MICROMIPS (elfsym->internal_elf_sym.st_other);
       else
@@ -6974,7 +7188,7 @@
 
     case SHN_MIPS_TEXT:
       /* This section is used in a shared object.  */
-      if (elf_tdata (abfd)->elf_text_section == NULL)
+      if (mips_elf_tdata (abfd)->elf_text_section == NULL)
 	{
 	  asymbol *elf_text_symbol;
 	  asection *elf_text_section;
@@ -6991,11 +7205,11 @@
 
 	  /* Initialize the section.  */
 
-	  elf_tdata (abfd)->elf_text_section = elf_text_section;
-	  elf_tdata (abfd)->elf_text_symbol = elf_text_symbol;
+	  mips_elf_tdata (abfd)->elf_text_section = elf_text_section;
+	  mips_elf_tdata (abfd)->elf_text_symbol = elf_text_symbol;
 
 	  elf_text_section->symbol = elf_text_symbol;
-	  elf_text_section->symbol_ptr_ptr = &elf_tdata (abfd)->elf_text_symbol;
+	  elf_text_section->symbol_ptr_ptr = &mips_elf_tdata (abfd)->elf_text_symbol;
 
 	  elf_text_section->name = ".text";
 	  elf_text_section->flags = SEC_NO_FLAGS;
@@ -7008,14 +7222,14 @@
       /* This code used to do *secp = bfd_und_section_ptr if
          info->shared.  I don't know why, and that doesn't make sense,
          so I took it out.  */
-      *secp = elf_tdata (abfd)->elf_text_section;
+      *secp = mips_elf_tdata (abfd)->elf_text_section;
       break;
 
     case SHN_MIPS_ACOMMON:
       /* Fall through. XXX Can we treat this as allocated data?  */
     case SHN_MIPS_DATA:
       /* This section is used in a shared object.  */
-      if (elf_tdata (abfd)->elf_data_section == NULL)
+      if (mips_elf_tdata (abfd)->elf_data_section == NULL)
 	{
 	  asymbol *elf_data_symbol;
 	  asection *elf_data_section;
@@ -7032,11 +7246,11 @@
 
 	  /* Initialize the section.  */
 
-	  elf_tdata (abfd)->elf_data_section = elf_data_section;
-	  elf_tdata (abfd)->elf_data_symbol = elf_data_symbol;
+	  mips_elf_tdata (abfd)->elf_data_section = elf_data_section;
+	  mips_elf_tdata (abfd)->elf_data_symbol = elf_data_symbol;
 
 	  elf_data_section->symbol = elf_data_symbol;
-	  elf_data_section->symbol_ptr_ptr = &elf_tdata (abfd)->elf_data_symbol;
+	  elf_data_section->symbol_ptr_ptr = &mips_elf_tdata (abfd)->elf_data_symbol;
 
 	  elf_data_section->name = ".data";
 	  elf_data_section->flags = SEC_NO_FLAGS;
@@ -7049,7 +7263,7 @@
       /* This code used to do *secp = bfd_und_section_ptr if
          info->shared.  I don't know why, and that doesn't make sense,
          so I took it out.  */
-      *secp = elf_tdata (abfd)->elf_data_section;
+      *secp = mips_elf_tdata (abfd)->elf_data_section;
       break;
 
     case SHN_MIPS_SUNDEFINED:
@@ -7081,6 +7295,7 @@
 	return FALSE;
 
       mips_elf_hash_table (info)->use_rld_obj_head = TRUE;
+      mips_elf_hash_table (info)->rld_symbol = h;
     }
 
   /* If this is a mips16 text symbol, add 1 to the value to make it
@@ -7139,7 +7354,7 @@
      EABI doesn't.  */
   if (!htab->is_vxworks)
     {
-      s = bfd_get_section_by_name (abfd, ".dynamic");
+      s = bfd_get_linker_section (abfd, ".dynamic");
       if (s != NULL)
 	{
 	  if (! bfd_set_section_flags (abfd, s, flags))
@@ -7155,21 +7370,21 @@
     return FALSE;
 
   /* Create .stub section.  */
-  s = bfd_make_section_with_flags (abfd,
-				   MIPS_ELF_STUB_SECTION_NAME (abfd),
-				   flags | SEC_CODE);
+  s = bfd_make_section_anyway_with_flags (abfd,
+					  MIPS_ELF_STUB_SECTION_NAME (abfd),
+					  flags | SEC_CODE);
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s,
 				      MIPS_ELF_LOG_FILE_ALIGN (abfd)))
     return FALSE;
   htab->sstubs = s;
 
-  if ((IRIX_COMPAT (abfd) == ict_irix5 || IRIX_COMPAT (abfd) == ict_none)
+  if (!mips_elf_hash_table (info)->use_rld_obj_head
       && !info->shared
-      && bfd_get_section_by_name (abfd, ".rld_map") == NULL)
+      && bfd_get_linker_section (abfd, ".rld_map") == NULL)
     {
-      s = bfd_make_section_with_flags (abfd, ".rld_map",
-				       flags &~ (flagword) SEC_READONLY);
+      s = bfd_make_section_anyway_with_flags (abfd, ".rld_map",
+					      flags &~ (flagword) SEC_READONLY);
       if (s == NULL
 	  || ! bfd_set_section_alignment (abfd, s,
 					  MIPS_ELF_LOG_FILE_ALIGN (abfd)))
@@ -7207,21 +7422,26 @@
 	}
 
       /* Change alignments of some sections.  */
-      s = bfd_get_section_by_name (abfd, ".hash");
+      s = bfd_get_linker_section (abfd, ".hash");
       if (s != NULL)
-	bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd));
-      s = bfd_get_section_by_name (abfd, ".dynsym");
+	(void) bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd));
+
+      s = bfd_get_linker_section (abfd, ".dynsym");
       if (s != NULL)
-	bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd));
-      s = bfd_get_section_by_name (abfd, ".dynstr");
+	(void) bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd));
+
+      s = bfd_get_linker_section (abfd, ".dynstr");
       if (s != NULL)
-	bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd));
+	(void) bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd));
+
+      /* ??? */
       s = bfd_get_section_by_name (abfd, ".reginfo");
       if (s != NULL)
-	bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd));
-      s = bfd_get_section_by_name (abfd, ".dynamic");
+	(void) bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd));
+
+      s = bfd_get_linker_section (abfd, ".dynamic");
       if (s != NULL)
-	bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd));
+	(void) bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd));
     }
 
   if (!info->shared)
@@ -7249,7 +7469,7 @@
 	     and is filled in by the rtld to contain a pointer to
 	     the _r_debug structure. Its symbol value will be set in
 	     _bfd_mips_elf_finish_dynamic_symbol.  */
-	  s = bfd_get_section_by_name (abfd, ".rld_map");
+	  s = bfd_get_linker_section (abfd, ".rld_map");
 	  BFD_ASSERT (s != NULL);
 
 	  name = SGI_COMPAT (abfd) ? "__rld_map" : "__RLD_MAP";
@@ -7266,58 +7486,35 @@
 
 	  if (! bfd_elf_link_record_dynamic_symbol (info, h))
 	    return FALSE;
+	  mips_elf_hash_table (info)->rld_symbol = h;
 	}
     }
 
   /* Create the .plt, .rel(a).plt, .dynbss and .rel(a).bss sections.
-     Also create the _PROCEDURE_LINKAGE_TABLE symbol.  */
+     Also, on VxWorks, create the _PROCEDURE_LINKAGE_TABLE_ symbol.  */
   if (!_bfd_elf_create_dynamic_sections (abfd, info))
     return FALSE;
 
   /* Cache the sections created above.  */
-  htab->splt = bfd_get_section_by_name (abfd, ".plt");
-  htab->sdynbss = bfd_get_section_by_name (abfd, ".dynbss");
+  htab->splt = bfd_get_linker_section (abfd, ".plt");
+  htab->sdynbss = bfd_get_linker_section (abfd, ".dynbss");
   if (htab->is_vxworks)
     {
-      htab->srelbss = bfd_get_section_by_name (abfd, ".rela.bss");
-      htab->srelplt = bfd_get_section_by_name (abfd, ".rela.plt");
+      htab->srelbss = bfd_get_linker_section (abfd, ".rela.bss");
+      htab->srelplt = bfd_get_linker_section (abfd, ".rela.plt");
     }
   else
-    htab->srelplt = bfd_get_section_by_name (abfd, ".rel.plt");
+    htab->srelplt = bfd_get_linker_section (abfd, ".rel.plt");
   if (!htab->sdynbss
       || (htab->is_vxworks && !htab->srelbss && !info->shared)
       || !htab->srelplt
       || !htab->splt)
     abort ();
 
-  if (htab->is_vxworks)
-    {
-      /* Do the usual VxWorks handling.  */
-      if (!elf_vxworks_create_dynamic_sections (abfd, info, &htab->srelplt2))
-	return FALSE;
-
-      /* Work out the PLT sizes.  */
-      if (info->shared)
-	{
-	  htab->plt_header_size
-	    = 4 * ARRAY_SIZE (mips_vxworks_shared_plt0_entry);
-	  htab->plt_entry_size
-	    = 4 * ARRAY_SIZE (mips_vxworks_shared_plt_entry);
-	}
-      else
-	{
-	  htab->plt_header_size
-	    = 4 * ARRAY_SIZE (mips_vxworks_exec_plt0_entry);
-	  htab->plt_entry_size
-	    = 4 * ARRAY_SIZE (mips_vxworks_exec_plt_entry);
-	}
-    }
-  else if (!info->shared)
-    {
-      /* All variants of the plt0 entry are the same size.  */
-      htab->plt_header_size = 4 * ARRAY_SIZE (mips_o32_exec_plt0_entry);
-      htab->plt_entry_size = 4 * ARRAY_SIZE (mips_exec_plt_entry);
-    }
+  /* Do the usual VxWorks handling.  */
+  if (htab->is_vxworks
+      && !elf_vxworks_create_dynamic_sections (abfd, info, &htab->srelplt2))
+    return FALSE;
 
   return TRUE;
 }
@@ -7445,8 +7642,27 @@
   return bfd_malloc_and_get_section (abfd, sec, contents);
 }
 
+/* Make a new PLT record to keep internal data.  */
+
+static struct plt_entry *
+mips_elf_make_plt_record (bfd *abfd)
+{
+  struct plt_entry *entry;
+
+  entry = bfd_zalloc (abfd, sizeof (*entry));
+  if (entry == NULL)
+    return NULL;
+
+  entry->stub_offset = MINUS_ONE;
+  entry->mips_offset = MINUS_ONE;
+  entry->comp_offset = MINUS_ONE;
+  entry->gotplt_index = MINUS_ONE;
+  return entry;
+}
+
 /* Look through the relocs for a section during the first phase, and
-   allocate space in the global offset table.  */
+   allocate space in the global offset table and record the need for
+   standard MIPS and compressed procedure linkage table entries.  */
 
 bfd_boolean
 _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
@@ -7490,7 +7706,7 @@
       /* Look at the relocation information to figure out which symbol
          this is for.  */
 
-      r_symndx = mips16_stub_symndx (sec, relocs, rel_end);
+      r_symndx = mips16_stub_symndx (bed, sec, relocs, rel_end);
       if (r_symndx == 0)
 	{
 	  (*_bfd_error_handler)
@@ -7552,7 +7768,7 @@
 
 	  /* Record this stub in an array of local symbol stubs for
              this BFD.  */
-	  if (elf_tdata (abfd)->local_stubs == NULL)
+	  if (mips_elf_tdata (abfd)->local_stubs == NULL)
 	    {
 	      unsigned long symcount;
 	      asection **n;
@@ -7566,11 +7782,11 @@
 	      n = bfd_zalloc (abfd, amt);
 	      if (n == NULL)
 		return FALSE;
-	      elf_tdata (abfd)->local_stubs = n;
+	      mips_elf_tdata (abfd)->local_stubs = n;
 	    }
 
 	  sec->flags |= SEC_KEEP;
-	  elf_tdata (abfd)->local_stubs[r_symndx] = sec;
+	  mips_elf_tdata (abfd)->local_stubs[r_symndx] = sec;
 
 	  /* We don't need to set mips16_stubs_seen in this case.
              That flag is used to see whether we need to look through
@@ -7615,7 +7831,7 @@
       /* Look at the relocation information to figure out which symbol
          this is for.  */
 
-      r_symndx = mips16_stub_symndx (sec, relocs, rel_end);
+      r_symndx = mips16_stub_symndx (bed, sec, relocs, rel_end);
       if (r_symndx == 0)
 	{
 	  (*_bfd_error_handler)
@@ -7677,7 +7893,7 @@
 
 	  /* Record this stub in an array of local symbol call_stubs for
              this BFD.  */
-	  if (elf_tdata (abfd)->local_call_stubs == NULL)
+	  if (mips_elf_tdata (abfd)->local_call_stubs == NULL)
 	    {
 	      unsigned long symcount;
 	      asection **n;
@@ -7691,11 +7907,11 @@
 	      n = bfd_zalloc (abfd, amt);
 	      if (n == NULL)
 		return FALSE;
-	      elf_tdata (abfd)->local_call_stubs = n;
+	      mips_elf_tdata (abfd)->local_call_stubs = n;
 	    }
 
 	  sec->flags |= SEC_KEEP;
-	  elf_tdata (abfd)->local_call_stubs[r_symndx] = sec;
+	  mips_elf_tdata (abfd)->local_call_stubs[r_symndx] = sec;
 
 	  /* We don't need to set mips16_stubs_seen in this case.
              That flag is used to see whether we need to look through
@@ -7706,14 +7922,14 @@
 	{
 	  h = ((struct mips_elf_link_hash_entry *)
 	       sym_hashes[r_symndx - extsymoff]);
-	  
+
 	  /* H is the symbol this stub is for.  */
-	  
+
 	  if (CALL_FP_STUB_P (name))
 	    loc = &h->call_fp_stub;
 	  else
 	    loc = &h->call_stub;
-	  
+
 	  /* If we already have an appropriate stub for this function, we
 	     don't need another one, so we can discard this one.  Since
 	     this function is called before the linker maps input sections
@@ -7756,10 +7972,16 @@
       else
 	{
 	  h = sym_hashes[r_symndx - extsymoff];
-	  while (h != NULL
-		 && (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 != NULL)
+	    {
+	      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;
+
+	      /* PR15323, ref flags aren't set for references in the
+		 same object.  */
+	      h->root.non_ir_ref = 1;
+	    }
 	}
 
       /* Set CAN_MAKE_DYNAMIC_P to true if we can convert this
@@ -7767,8 +7989,6 @@
       can_make_dynamic_p = FALSE;
       switch (r_type)
 	{
-	case R_MIPS16_GOT16:
-	case R_MIPS16_CALL16:
 	case R_MIPS_GOT16:
 	case R_MIPS_CALL16:
 	case R_MIPS_CALL_HI16:
@@ -7781,6 +8001,11 @@
 	case R_MIPS_TLS_GOTTPREL:
 	case R_MIPS_TLS_GD:
 	case R_MIPS_TLS_LDM:
+	case R_MIPS16_GOT16:
+	case R_MIPS16_CALL16:
+	case R_MIPS16_TLS_GOTTPREL:
+	case R_MIPS16_TLS_GD:
+	case R_MIPS16_TLS_LDM:
 	case R_MICROMIPS_GOT16:
 	case R_MICROMIPS_CALL16:
 	case R_MICROMIPS_CALL_HI16:
@@ -7914,11 +8139,13 @@
 	     R_MIPS_CALL_HI16 because these are always followed by an
 	     R_MIPS_GOT_LO16 or R_MIPS_CALL_LO16.  */
 	  if (!mips_elf_record_local_got_symbol (abfd, r_symndx,
-						 rel->r_addend, info, 0))
+						 rel->r_addend, info, r_type))
 	    return FALSE;
 	}
 
-      if (h != NULL && mips_elf_relocation_needs_la25_stub (abfd, r_type))
+      if (h != NULL
+	  && mips_elf_relocation_needs_la25_stub (abfd, r_type,
+						  ELF_ST_IS_MIPS16 (h->other)))
 	((struct mips_elf_link_hash_entry *) h)->has_nonpic_branches = TRUE;
 
       switch (r_type)
@@ -7945,7 +8172,8 @@
 	      /* Make sure there is room in the regular GOT to hold the
 		 function's address.  We may eliminate it in favour of
 		 a .got.plt entry later; see mips_elf_count_got_symbols.  */
-	      if (!mips_elf_record_global_got_symbol (h, abfd, info, TRUE, 0))
+	      if (!mips_elf_record_global_got_symbol (h, abfd, info, TRUE,
+						      r_type))
 		return FALSE;
 
 	      /* We need a stub, not a plt entry for the undefined
@@ -7958,21 +8186,6 @@
 
 	case R_MIPS_GOT_PAGE:
 	case R_MICROMIPS_GOT_PAGE:
-	  /* If this is a global, overridable symbol, GOT_PAGE will
-	     decay to GOT_DISP, so we'll need a GOT entry for it.  */
-	  if (h)
-	    {
-	      struct mips_elf_link_hash_entry *hmips =
-		(struct mips_elf_link_hash_entry *) h;
-
-	      /* This symbol is definitely not overridable.  */
-	      if (hmips->root.def_regular
-		  && ! (info->shared && ! info->symbolic
-			&& ! hmips->root.forced_local))
-		h = NULL;
-	    }
-	  /* Fall through.  */
-
 	case R_MIPS16_GOT16:
 	case R_MIPS_GOT16:
 	case R_MIPS_GOT_HI16:
@@ -8001,26 +8214,42 @@
 		}
 	      else
 		addend = rel->r_addend;
-	      if (!mips_elf_record_got_page_entry (info, abfd, r_symndx,
-						   addend))
+	      if (!mips_elf_record_got_page_ref (info, abfd, r_symndx,
+						 h, addend))
 		return FALSE;
+
+	      if (h)
+		{
+		  struct mips_elf_link_hash_entry *hmips =
+		    (struct mips_elf_link_hash_entry *) h;
+
+		  /* This symbol is definitely not overridable.  */
+		  if (hmips->root.def_regular
+		      && ! (info->shared && ! info->symbolic
+			    && ! hmips->root.forced_local))
+		    h = NULL;
+		}
 	    }
+	  /* If this is a global, overridable symbol, GOT_PAGE will
+	     decay to GOT_DISP, so we'll need a GOT entry for it.  */
 	  /* Fall through.  */
 
 	case R_MIPS_GOT_DISP:
 	case R_MICROMIPS_GOT_DISP:
 	  if (h && !mips_elf_record_global_got_symbol (h, abfd, info,
-						       FALSE, 0))
+						       FALSE, r_type))
 	    return FALSE;
 	  break;
 
 	case R_MIPS_TLS_GOTTPREL:
+	case R_MIPS16_TLS_GOTTPREL:
 	case R_MICROMIPS_TLS_GOTTPREL:
 	  if (info->shared)
 	    info->flags |= DF_STATIC_TLS;
 	  /* Fall through */
 
 	case R_MIPS_TLS_LDM:
+	case R_MIPS16_TLS_LDM:
 	case R_MICROMIPS_TLS_LDM:
 	  if (tls_ldm_reloc_p (r_type))
 	    {
@@ -8030,35 +8259,23 @@
 	  /* Fall through */
 
 	case R_MIPS_TLS_GD:
+	case R_MIPS16_TLS_GD:
 	case R_MICROMIPS_TLS_GD:
 	  /* This symbol requires a global offset table entry, or two
 	     for TLS GD relocations.  */
-	  {
-	    unsigned char flag;
-
-	    flag = (tls_gd_reloc_p (r_type)
-		    ? GOT_TLS_GD
-		    : tls_ldm_reloc_p (r_type) ? GOT_TLS_LDM : GOT_TLS_IE);
-	    if (h != NULL)
-	      {
-		struct mips_elf_link_hash_entry *hmips =
-		  (struct mips_elf_link_hash_entry *) h;
-		hmips->tls_type |= flag;
-
-		if (h && !mips_elf_record_global_got_symbol (h, abfd, info,
-							     FALSE, flag))
-		  return FALSE;
-	      }
-	    else
-	      {
-		BFD_ASSERT (flag == GOT_TLS_LDM || r_symndx != STN_UNDEF);
-
-		if (!mips_elf_record_local_got_symbol (abfd, r_symndx,
-						       rel->r_addend,
-						       info, flag))
-		  return FALSE;
-	      }
-	  }
+	  if (h != NULL)
+	    {
+	      if (!mips_elf_record_global_got_symbol (h, abfd, info,
+						      FALSE, r_type))
+		return FALSE;
+	    }
+	  else
+	    {
+	      if (!mips_elf_record_local_got_symbol (abfd, r_symndx,
+						     rel->r_addend,
+						     info, r_type))
+		return FALSE;
+	    }
 	  break;
 
 	case R_MIPS_32:
@@ -8148,6 +8365,28 @@
 	  break;
 	}
 
+      /* Record the need for a PLT entry.  At this point we don't know
+         yet if we are going to create a PLT in the first place, but
+         we only record whether the relocation requires a standard MIPS
+         or a compressed code entry anyway.  If we don't make a PLT after
+         all, then we'll just ignore these arrangements.  Likewise if
+         a PLT entry is not created because the symbol is satisfied
+         locally.  */
+      if (h != NULL
+	  && jal_reloc_p (r_type)
+	  && !SYMBOL_CALLS_LOCAL (info, h))
+	{
+	  if (h->plt.plist == NULL)
+	    h->plt.plist = mips_elf_make_plt_record (abfd);
+	  if (h->plt.plist == NULL)
+	    return FALSE;
+
+	  if (r_type == R_MIPS_26)
+	    h->plt.plist->need_mips = TRUE;
+	  else
+	    h->plt.plist->need_comp = TRUE;
+	}
+
       /* We must not create a stub for a symbol that has relocations
 	 related to taking the function's address.  This doesn't apply to
 	 VxWorks, where CALL relocs refer to a .got.plt entry instead of
@@ -8429,7 +8668,7 @@
   if (! info->relocatable
       && hmips->possibly_dynamic_relocs != 0
       && (h->root.type == bfd_link_hash_defweak
-	  || !h->def_regular
+	  || (!h->def_regular && !ELF_COMMON_DEF_P (h))
 	  || info->shared))
     {
       bfd_boolean do_copy = TRUE;
@@ -8550,11 +8789,16 @@
 	   && !(ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
 		&& h->root.type == bfd_link_hash_undefweak))
     {
-      /* If this is the first symbol to need a PLT entry, allocate room
-	 for the header.  */
-      if (htab->splt->size == 0)
+      bfd_boolean micromips_p = MICROMIPS_P (info->output_bfd);
+      bfd_boolean newabi_p = NEWABI_P (info->output_bfd);
+
+      /* If this is the first symbol to need a PLT entry, then make some
+         basic setup.  Also work out PLT entry sizes.  We'll need them
+         for PLT offset calculations.  */
+      if (htab->plt_mips_offset + htab->plt_comp_offset == 0)
 	{
 	  BFD_ASSERT (htab->sgotplt->size == 0);
+	  BFD_ASSERT (htab->plt_got_index == 0);
 
 	  /* If we're using the PLT additions to the psABI, each PLT
 	     entry is 16 bytes and the PLT0 entry is 32 bytes.
@@ -8570,39 +8814,107 @@
 					  MIPS_ELF_LOG_FILE_ALIGN (dynobj)))
 	    return FALSE;
 
-	  htab->splt->size += htab->plt_header_size;
-
 	  /* On non-VxWorks targets, the first two entries in .got.plt
 	     are reserved.  */
 	  if (!htab->is_vxworks)
-	    htab->sgotplt->size += 2 * MIPS_ELF_GOT_SIZE (dynobj);
+	    htab->plt_got_index
+	      += (get_elf_backend_data (dynobj)->got_header_size
+		  / MIPS_ELF_GOT_SIZE (dynobj));
 
 	  /* On VxWorks, also allocate room for the header's
 	     .rela.plt.unloaded entries.  */
 	  if (htab->is_vxworks && !info->shared)
 	    htab->srelplt2->size += 2 * sizeof (Elf32_External_Rela);
+
+	  /* Now work out the sizes of individual PLT entries.  */
+	  if (htab->is_vxworks && info->shared)
+	    htab->plt_mips_entry_size
+	      = 4 * ARRAY_SIZE (mips_vxworks_shared_plt_entry);
+	  else if (htab->is_vxworks)
+	    htab->plt_mips_entry_size
+	      = 4 * ARRAY_SIZE (mips_vxworks_exec_plt_entry);
+	  else if (newabi_p)
+	    htab->plt_mips_entry_size
+	      = 4 * ARRAY_SIZE (mips_exec_plt_entry);
+	  else if (!micromips_p)
+	    {
+	      htab->plt_mips_entry_size
+		= 4 * ARRAY_SIZE (mips_exec_plt_entry);
+	      htab->plt_comp_entry_size
+		= 2 * ARRAY_SIZE (mips16_o32_exec_plt_entry);
+	    }
+	  else if (htab->insn32)
+	    {
+	      htab->plt_mips_entry_size
+		= 4 * ARRAY_SIZE (mips_exec_plt_entry);
+	      htab->plt_comp_entry_size
+		= 2 * ARRAY_SIZE (micromips_insn32_o32_exec_plt_entry);
+	    }
+	  else
+	    {
+	      htab->plt_mips_entry_size
+		= 4 * ARRAY_SIZE (mips_exec_plt_entry);
+	      htab->plt_comp_entry_size
+		= 2 * ARRAY_SIZE (micromips_o32_exec_plt_entry);
+	    }
 	}
 
-      /* Assign the next .plt entry to this symbol.  */
-      h->plt.offset = htab->splt->size;
-      htab->splt->size += htab->plt_entry_size;
+      if (h->plt.plist == NULL)
+	h->plt.plist = mips_elf_make_plt_record (dynobj);
+      if (h->plt.plist == NULL)
+	return FALSE;
+
+      /* There are no defined MIPS16 or microMIPS PLT entries for VxWorks,
+         n32 or n64, so always use a standard entry there.
+
+         If the symbol has a MIPS16 call stub and gets a PLT entry, then
+         all MIPS16 calls will go via that stub, and there is no benefit
+         to having a MIPS16 entry.  And in the case of call_stub a
+         standard entry actually has to be used as the stub ends with a J
+         instruction.  */
+      if (newabi_p
+	  || htab->is_vxworks
+	  || hmips->call_stub
+	  || hmips->call_fp_stub)
+	{
+	  h->plt.plist->need_mips = TRUE;
+	  h->plt.plist->need_comp = FALSE;
+	}
+
+      /* Otherwise, if there are no direct calls to the function, we
+         have a free choice of whether to use standard or compressed
+         entries.  Prefer microMIPS entries if the object is known to
+         contain microMIPS code, so that it becomes possible to create
+         pure microMIPS binaries.  Prefer standard entries otherwise,
+         because MIPS16 ones are no smaller and are usually slower.  */
+      if (!h->plt.plist->need_mips && !h->plt.plist->need_comp)
+	{
+	  if (micromips_p)
+	    h->plt.plist->need_comp = TRUE;
+	  else
+	    h->plt.plist->need_mips = TRUE;
+	}
+
+      if (h->plt.plist->need_mips)
+	{
+	  h->plt.plist->mips_offset = htab->plt_mips_offset;
+	  htab->plt_mips_offset += htab->plt_mips_entry_size;
+	}
+      if (h->plt.plist->need_comp)
+	{
+	  h->plt.plist->comp_offset = htab->plt_comp_offset;
+	  htab->plt_comp_offset += htab->plt_comp_entry_size;
+	}
+
+      /* Reserve the corresponding .got.plt entry now too.  */
+      h->plt.plist->gotplt_index = htab->plt_got_index++;
 
       /* If the output file has no definition of the symbol, set the
 	 symbol's value to the address of the stub.  */
       if (!info->shared && !h->def_regular)
-	{
-	  h->root.u.def.section = htab->splt;
-	  h->root.u.def.value = h->plt.offset;
-	  /* For VxWorks, point at the PLT load stub rather than the
-	     lazy resolution stub; this stub will become the canonical
-	     function address.  */
-	  if (htab->is_vxworks)
-	    h->root.u.def.value += 8;
-	}
+	hmips->use_plt_entry = TRUE;
 
-      /* Make room for the .got.plt entry and the R_MIPS_JUMP_SLOT
-	 relocation.  */
-      htab->sgotplt->size += MIPS_ELF_GOT_SIZE (dynobj);
+      /* Make room for the R_MIPS_JUMP_SLOT relocation.  */
       htab->srelplt->size += (htab->is_vxworks
 			      ? MIPS_ELF_RELA_SIZE (dynobj)
 			      : MIPS_ELF_REL_SIZE (dynobj));
@@ -8718,8 +9030,8 @@
   struct mips_got_info *g;
   bfd_size_type loadable_size = 0;
   bfd_size_type page_gotno;
-  bfd *sub;
-  struct mips_elf_count_tls_arg count_tls_arg;
+  bfd *ibfd;
+  struct mips_elf_traverse_got_arg tga;
   struct mips_elf_link_hash_table *htab;
 
   htab = mips_elf_hash_table (info);
@@ -8742,22 +9054,21 @@
   g->local_gotno += htab->reserved_gotno;
   g->assigned_gotno = htab->reserved_gotno;
 
-  /* Replace entries for indirect and warning symbols with entries for
-     the target symbol.  */
-  if (!mips_elf_resolve_final_got_entries (g))
-    return FALSE;
-
-  /* Count the number of GOT symbols.  */
+  /* Decide which symbols need to go in the global part of the GOT and
+     count the number of reloc-only GOT symbols.  */
   mips_elf_link_hash_traverse (htab, mips_elf_count_got_symbols, info);
 
+  if (!mips_elf_resolve_final_got_entries (info, g))
+    return FALSE;
+
   /* Calculate the total loadable size of the output.  That
      will give us the maximum number of GOT_PAGE entries
      required.  */
-  for (sub = info->input_bfds; sub; sub = sub->link_next)
+  for (ibfd = info->input_bfds; ibfd; ibfd = ibfd->link_next)
     {
       asection *subsection;
 
-      for (subsection = sub->sections;
+      for (subsection = ibfd->sections;
 	   subsection;
 	   subsection = subsection->next)
 	{
@@ -8778,64 +9089,52 @@
        sections.  Is 5 enough?  */
     page_gotno = (loadable_size >> 16) + 5;
 
-  /* Choose the smaller of the two estimates; both are intended to be
+  /* Choose the smaller of the two page estimates; both are intended to be
      conservative.  */
   if (page_gotno > g->page_gotno)
     page_gotno = g->page_gotno;
 
   g->local_gotno += page_gotno;
+
   s->size += g->local_gotno * MIPS_ELF_GOT_SIZE (output_bfd);
   s->size += g->global_gotno * MIPS_ELF_GOT_SIZE (output_bfd);
-
-  /* We need to calculate tls_gotno for global symbols at this point
-     instead of building it up earlier, to avoid doublecounting
-     entries for one global symbol from multiple input files.  */
-  count_tls_arg.info = info;
-  count_tls_arg.needed = 0;
-  elf_link_hash_traverse (elf_hash_table (info),
-			  mips_elf_count_global_tls_entries,
-			  &count_tls_arg);
-  g->tls_gotno += count_tls_arg.needed;
   s->size += g->tls_gotno * MIPS_ELF_GOT_SIZE (output_bfd);
 
   /* VxWorks does not support multiple GOTs.  It initializes $gp to
      __GOTT_BASE__[__GOTT_INDEX__], the value of which is set by the
      dynamic loader.  */
-  if (htab->is_vxworks)
-    {
-      /* VxWorks executables do not need a GOT.  */
-      if (info->shared)
-	{
-	  /* Each VxWorks GOT entry needs an explicit relocation.  */
-	  unsigned int count;
-
-	  count = g->global_gotno + g->local_gotno - htab->reserved_gotno;
-	  if (count)
-	    mips_elf_allocate_dynamic_relocations (dynobj, info, count);
-	}
-    }
-  else if (s->size > MIPS_ELF_GOT_MAX_SIZE (info))
+  if (!htab->is_vxworks && s->size > MIPS_ELF_GOT_MAX_SIZE (info))
     {
       if (!mips_elf_multi_got (output_bfd, info, s, page_gotno))
 	return FALSE;
     }
   else
     {
-      struct mips_elf_count_tls_arg arg;
+      /* Record that all bfds use G.  This also has the effect of freeing
+	 the per-bfd GOTs, which we no longer need.  */
+      for (ibfd = info->input_bfds; ibfd; ibfd = ibfd->link_next)
+	if (mips_elf_bfd_got (ibfd, FALSE))
+	  mips_elf_replace_bfd_got (ibfd, g);
+      mips_elf_replace_bfd_got (output_bfd, g);
 
       /* Set up TLS entries.  */
       g->tls_assigned_gotno = g->global_gotno + g->local_gotno;
-      htab_traverse (g->got_entries, mips_elf_initialize_tls_index, g);
+      tga.info = info;
+      tga.g = g;
+      tga.value = MIPS_ELF_GOT_SIZE (output_bfd);
+      htab_traverse (g->got_entries, mips_elf_initialize_tls_index, &tga);
+      if (!tga.g)
+	return FALSE;
+      BFD_ASSERT (g->tls_assigned_gotno
+		  == g->global_gotno + g->local_gotno + g->tls_gotno);
+
+      /* Each VxWorks GOT entry needs an explicit relocation.  */
+      if (htab->is_vxworks && info->shared)
+	g->relocs += g->global_gotno + g->local_gotno - htab->reserved_gotno;
 
       /* Allocate room for the TLS relocations.  */
-      arg.info = info;
-      arg.needed = 0;
-      htab_traverse (g->got_entries, mips_elf_count_local_tls_relocs, &arg);
-      elf_link_hash_traverse (elf_hash_table (info),
-			      mips_elf_count_global_tls_relocs,
-			      &arg);
-      if (arg.needed)
-	mips_elf_allocate_dynamic_relocations (dynobj, info, arg.needed);
+      if (g->relocs)
+	mips_elf_allocate_dynamic_relocations (dynobj, info, g->relocs);
     }
 
   return TRUE;
@@ -8866,29 +9165,62 @@
   dynsymcount = (elf_hash_table (info)->dynsymcount
 		 + count_section_dynsyms (output_bfd, info));
 
-  /* Determine the size of one stub entry.  */
-  htab->function_stub_size = (dynsymcount > 0x10000
-			      ? MIPS_FUNCTION_STUB_BIG_SIZE
-			      : MIPS_FUNCTION_STUB_NORMAL_SIZE);
+  /* Determine the size of one stub entry.  There's no disadvantage
+     from using microMIPS code here, so for the sake of pure-microMIPS
+     binaries we prefer it whenever there's any microMIPS code in
+     output produced at all.  This has a benefit of stubs being
+     shorter by 4 bytes each too, unless in the insn32 mode.  */
+  if (!MICROMIPS_P (output_bfd))
+    htab->function_stub_size = (dynsymcount > 0x10000
+				? MIPS_FUNCTION_STUB_BIG_SIZE
+				: MIPS_FUNCTION_STUB_NORMAL_SIZE);
+  else if (htab->insn32)
+    htab->function_stub_size = (dynsymcount > 0x10000
+				? MICROMIPS_INSN32_FUNCTION_STUB_BIG_SIZE
+				: MICROMIPS_INSN32_FUNCTION_STUB_NORMAL_SIZE);
+  else
+    htab->function_stub_size = (dynsymcount > 0x10000
+				? MICROMIPS_FUNCTION_STUB_BIG_SIZE
+				: MICROMIPS_FUNCTION_STUB_NORMAL_SIZE);
 
   htab->sstubs->size = htab->lazy_stub_count * htab->function_stub_size;
 }
 
-/* A mips_elf_link_hash_traverse callback for which DATA points to the
-   MIPS hash table.  If H needs a traditional MIPS lazy-binding stub,
-   allocate an entry in the stubs section.  */
+/* A mips_elf_link_hash_traverse callback for which DATA points to a
+   mips_htab_traverse_info.  If H needs a traditional MIPS lazy-binding
+   stub, allocate an entry in the stubs section.  */
 
 static bfd_boolean
-mips_elf_allocate_lazy_stub (struct mips_elf_link_hash_entry *h, void **data)
+mips_elf_allocate_lazy_stub (struct mips_elf_link_hash_entry *h, void *data)
 {
+  struct mips_htab_traverse_info *hti = data;
   struct mips_elf_link_hash_table *htab;
+  struct bfd_link_info *info;
+  bfd *output_bfd;
 
-  htab = (struct mips_elf_link_hash_table *) data;
+  info = hti->info;
+  output_bfd = hti->output_bfd;
+  htab = mips_elf_hash_table (info);
+  BFD_ASSERT (htab != NULL);
+
   if (h->needs_lazy_stub)
     {
+      bfd_boolean micromips_p = MICROMIPS_P (output_bfd);
+      unsigned int other = micromips_p ? STO_MICROMIPS : 0;
+      bfd_vma isa_bit = micromips_p;
+
+      BFD_ASSERT (htab->root.dynobj != NULL);
+      if (h->root.plt.plist == NULL)
+	h->root.plt.plist = mips_elf_make_plt_record (htab->sstubs->owner);
+      if (h->root.plt.plist == NULL)
+	{
+	  hti->error = TRUE;
+	  return FALSE;
+	}
       h->root.root.u.def.section = htab->sstubs;
-      h->root.root.u.def.value = htab->sstubs->size;
-      h->root.plt.offset = htab->sstubs->size;
+      h->root.root.u.def.value = htab->sstubs->size + isa_bit;
+      h->root.plt.plist->stub_offset = htab->sstubs->size;
+      h->root.other = other;
       htab->sstubs->size += htab->function_stub_size;
     }
   return TRUE;
@@ -8897,22 +9229,97 @@
 /* Allocate offsets in the stubs section to each symbol that needs one.
    Set the final size of the .MIPS.stub section.  */
 
-static void
+static bfd_boolean
 mips_elf_lay_out_lazy_stubs (struct bfd_link_info *info)
 {
+  bfd *output_bfd = info->output_bfd;
+  bfd_boolean micromips_p = MICROMIPS_P (output_bfd);
+  unsigned int other = micromips_p ? STO_MICROMIPS : 0;
+  bfd_vma isa_bit = micromips_p;
   struct mips_elf_link_hash_table *htab;
+  struct mips_htab_traverse_info hti;
+  struct elf_link_hash_entry *h;
+  bfd *dynobj;
 
   htab = mips_elf_hash_table (info);
   BFD_ASSERT (htab != NULL);
 
   if (htab->lazy_stub_count == 0)
-    return;
+    return TRUE;
 
   htab->sstubs->size = 0;
-  mips_elf_link_hash_traverse (htab, mips_elf_allocate_lazy_stub, htab);
+  hti.info = info;
+  hti.output_bfd = output_bfd;
+  hti.error = FALSE;
+  mips_elf_link_hash_traverse (htab, mips_elf_allocate_lazy_stub, &hti);
+  if (hti.error)
+    return FALSE;
   htab->sstubs->size += htab->function_stub_size;
   BFD_ASSERT (htab->sstubs->size
 	      == htab->lazy_stub_count * htab->function_stub_size);
+
+  dynobj = elf_hash_table (info)->dynobj;
+  BFD_ASSERT (dynobj != NULL);
+  h = _bfd_elf_define_linkage_sym (dynobj, info, htab->sstubs, "_MIPS_STUBS_");
+  if (h == NULL)
+    return FALSE;
+  h->root.u.def.value = isa_bit;
+  h->other = other;
+  h->type = STT_FUNC;
+
+  return TRUE;
+}
+
+/* A mips_elf_link_hash_traverse callback for which DATA points to a
+   bfd_link_info.  If H uses the address of a PLT entry as the value
+   of the symbol, then set the entry in the symbol table now.  Prefer
+   a standard MIPS PLT entry.  */
+
+static bfd_boolean
+mips_elf_set_plt_sym_value (struct mips_elf_link_hash_entry *h, void *data)
+{
+  struct bfd_link_info *info = data;
+  bfd_boolean micromips_p = MICROMIPS_P (info->output_bfd);
+  struct mips_elf_link_hash_table *htab;
+  unsigned int other;
+  bfd_vma isa_bit;
+  bfd_vma val;
+
+  htab = mips_elf_hash_table (info);
+  BFD_ASSERT (htab != NULL);
+
+  if (h->use_plt_entry)
+    {
+      BFD_ASSERT (h->root.plt.plist != NULL);
+      BFD_ASSERT (h->root.plt.plist->mips_offset != MINUS_ONE
+		  || h->root.plt.plist->comp_offset != MINUS_ONE);
+
+      val = htab->plt_header_size;
+      if (h->root.plt.plist->mips_offset != MINUS_ONE)
+	{
+	  isa_bit = 0;
+	  val += h->root.plt.plist->mips_offset;
+	  other = 0;
+	}
+      else
+	{
+	  isa_bit = 1;
+	  val += htab->plt_mips_offset + h->root.plt.plist->comp_offset;
+	  other = micromips_p ? STO_MICROMIPS : STO_MIPS16;
+	}
+      val += isa_bit;
+      /* For VxWorks, point at the PLT load stub rather than the lazy
+         resolution stub; this stub will become the canonical function
+         address.  */
+      if (htab->is_vxworks)
+	val += 8;
+
+      h->root.root.u.def.section = htab->splt;
+      h->root.root.u.def.value = val;
+      h->root.other = other;
+    }
+
+  return TRUE;
 }
 
 /* Set the sizes of the dynamic sections.  */
@@ -8936,7 +9343,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
 	  s->size
 	    = strlen (ELF_DYNAMIC_INTERPRETER (output_bfd)) + 1;
@@ -8944,24 +9351,74 @@
 	    = (bfd_byte *) ELF_DYNAMIC_INTERPRETER (output_bfd);
 	}
 
-      /* Create a symbol for the PLT, if we know that we are using it.  */
-      if (htab->splt && htab->splt->size > 0 && htab->root.hplt == NULL)
+      /* Figure out the size of the PLT header if we know that we
+         are using it.  For the sake of cache alignment always use
+         a standard header whenever any standard entries are present
+         even if microMIPS entries are present as well.  This also
+         lets the microMIPS header rely on the value of $v0 only set
+         by microMIPS entries, for a small size reduction.
+
+         Set symbol table entry values for symbols that use the
+         address of their PLT entry now that we can calculate it.
+
+         Also create the _PROCEDURE_LINKAGE_TABLE_ symbol if we
+         haven't already in _bfd_elf_create_dynamic_sections.  */
+      if (htab->splt && htab->plt_mips_offset + htab->plt_comp_offset != 0)
 	{
+	  bfd_boolean micromips_p = (MICROMIPS_P (output_bfd)
+				     && !htab->plt_mips_offset);
+	  unsigned int other = micromips_p ? STO_MICROMIPS : 0;
+	  bfd_vma isa_bit = micromips_p;
 	  struct elf_link_hash_entry *h;
+	  bfd_vma size;
 
 	  BFD_ASSERT (htab->use_plts_and_copy_relocs);
+	  BFD_ASSERT (htab->sgotplt->size == 0);
+	  BFD_ASSERT (htab->splt->size == 0);
 
-	  h = _bfd_elf_define_linkage_sym (dynobj, info, htab->splt,
-					   "_PROCEDURE_LINKAGE_TABLE_");
-	  htab->root.hplt = h;
-	  if (h == NULL)
-	    return FALSE;
+	  if (htab->is_vxworks && info->shared)
+	    size = 4 * ARRAY_SIZE (mips_vxworks_shared_plt0_entry);
+	  else if (htab->is_vxworks)
+	    size = 4 * ARRAY_SIZE (mips_vxworks_exec_plt0_entry);
+	  else if (ABI_64_P (output_bfd))
+	    size = 4 * ARRAY_SIZE (mips_n64_exec_plt0_entry);
+	  else if (ABI_N32_P (output_bfd))
+	    size = 4 * ARRAY_SIZE (mips_n32_exec_plt0_entry);
+	  else if (!micromips_p)
+	    size = 4 * ARRAY_SIZE (mips_o32_exec_plt0_entry);
+	  else if (htab->insn32)
+	    size = 2 * ARRAY_SIZE (micromips_insn32_o32_exec_plt0_entry);
+	  else
+	    size = 2 * ARRAY_SIZE (micromips_o32_exec_plt0_entry);
+
+	  htab->plt_header_is_comp = micromips_p;
+	  htab->plt_header_size = size;
+	  htab->splt->size = (size
+			      + htab->plt_mips_offset
+			      + htab->plt_comp_offset);
+	  htab->sgotplt->size = (htab->plt_got_index
+				 * MIPS_ELF_GOT_SIZE (dynobj));
+
+	  mips_elf_link_hash_traverse (htab, mips_elf_set_plt_sym_value, info);
+
+	  if (htab->root.hplt == NULL)
+	    {
+	      h = _bfd_elf_define_linkage_sym (dynobj, info, htab->splt,
+					       "_PROCEDURE_LINKAGE_TABLE_");
+	      htab->root.hplt = h;
+	      if (h == NULL)
+		return FALSE;
+	    }
+
+	  h = htab->root.hplt;
+	  h->root.u.def.value = isa_bit;
+	  h->other = other;
 	  h->type = STT_FUNC;
 	}
     }
 
   /* Allocate space for global sym dynamic relocs.  */
-  elf_link_hash_traverse (&htab->root, allocate_dynrelocs, (PTR) info);
+  elf_link_hash_traverse (&htab->root, allocate_dynrelocs, info);
 
   mips_elf_estimate_stub_size (output_bfd, info);
 
@@ -9027,7 +9484,7 @@
 	{
 	  /* We add a room for __rld_map.  It will be filled in by the
 	     rtld to contain a pointer to the _r_debug structure.  */
-	  s->size += 4;
+	  s->size += MIPS_ELF_RLD_MAP_SIZE (output_bfd);
 	}
       else if (SGI_COMPAT (output_bfd)
 	       && CONST_STRNEQ (name, ".compact_rel"))
@@ -9078,8 +9535,8 @@
 
       /* SGI object has the equivalence of DT_DEBUG in the
 	 DT_MIPS_RLD_MAP entry.  This must come first because glibc
-	 only fills in DT_MIPS_RLD_MAP (not DT_DEBUG) and GDB only
-	 looks at the first one it sees.  */
+	 only fills in DT_MIPS_RLD_MAP (not DT_DEBUG) and some tools
+	 may only look at the first one they see.  */
       if (!info->shared
 	  && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_MAP, 0))
 	return FALSE;
@@ -9167,7 +9624,7 @@
 
 	  if (IRIX_COMPAT (dynobj) == ict_irix6
 	      && (bfd_get_section_by_name
-		  (dynobj, MIPS_ELF_OPTIONS_SECTION_NAME (dynobj)))
+		  (output_bfd, MIPS_ELF_OPTIONS_SECTION_NAME (dynobj)))
 	      && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_OPTIONS, 0))
 	    return FALSE;
 	}
@@ -9234,6 +9691,55 @@
     }
 }
 
+/* Handle relocations against symbols from removed linkonce sections,
+   or sections discarded by a linker script.  We use this wrapper around
+   RELOC_AGAINST_DISCARDED_SECTION to handle triplets of compound relocs
+   on 64-bit ELF targets.  In this case for any relocation handled, which
+   always be the first in a triplet, the remaining two have to be processed
+   together with the first, even if they are R_MIPS_NONE.  It is the symbol
+   index referred by the first reloc that applies to all the three and the
+   remaining two never refer to an object symbol.  And it is the final
+   relocation (the last non-null one) that determines the output field of
+   the whole relocation so retrieve the corresponding howto structure for
+   the relocatable field to be cleared by RELOC_AGAINST_DISCARDED_SECTION.
+
+   Note that RELOC_AGAINST_DISCARDED_SECTION is a macro that uses "continue"
+   and therefore requires to be pasted in a loop.  It also defines a block
+   and does not protect any of its arguments, hence the extra brackets.  */
+
+static void
+mips_reloc_against_discarded_section (bfd *output_bfd,
+				      struct bfd_link_info *info,
+				      bfd *input_bfd, asection *input_section,
+				      Elf_Internal_Rela **rel,
+				      const Elf_Internal_Rela **relend,
+				      bfd_boolean rel_reloc,
+				      reloc_howto_type *howto,
+				      bfd_byte *contents)
+{
+  const struct elf_backend_data *bed = get_elf_backend_data (output_bfd);
+  int count = bed->s->int_rels_per_ext_rel;
+  unsigned int r_type;
+  int i;
+
+  for (i = count - 1; i > 0; i--)
+    {
+      r_type = ELF_R_TYPE (output_bfd, (*rel)[i].r_info);
+      if (r_type != R_MIPS_NONE)
+	{
+	  howto = MIPS_ELF_RTYPE_TO_HOWTO (input_bfd, r_type, !rel_reloc);
+	  break;
+	}
+    }
+  do
+    {
+       RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+					(*rel), count, (*relend),
+					howto, i, contents);
+    }
+  while (0);
+}
+
 /* Relocate a MIPS ELF section.  */
 
 bfd_boolean
@@ -9256,7 +9762,7 @@
       const char *name;
       bfd_vma value = 0;
       reloc_howto_type *howto;
-      bfd_boolean cross_mode_jump_p;
+      bfd_boolean cross_mode_jump_p = FALSE;
       /* TRUE if the relocation is a RELA relocation, rather than a
          REL relocation.  */
       bfd_boolean rela_relocation_p = TRUE;
@@ -9299,9 +9805,13 @@
 	    sec = h->root.u.def.section;
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
-	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+      if (sec != NULL && discarded_section (sec))
+	{
+	  mips_reloc_against_discarded_section (output_bfd, info, input_bfd,
+						input_section, &rel, &relend,
+						rel_reloc, howto, contents);
+	  continue;
+	}
 
       if (r_type == R_MIPS_64 && ! NEWABI_P (input_bfd))
 	{
@@ -9615,9 +10125,9 @@
   offset = stub->offset;
 
   /* Work out the target address.  */
-  target = (stub->h->root.root.u.def.section->output_section->vma
-	    + stub->h->root.root.u.def.section->output_offset
-	    + stub->h->root.root.u.def.value);
+  target = mips_elf_get_la25_target (stub, &s);
+  target += s->output_section->vma + s->output_offset;
+
   target_high = ((target + 0x8000) >> 16) & 0xffff;
   target_low = (target & 0xffff);
 
@@ -9629,14 +10139,12 @@
       loc += offset;
       if (ELF_ST_IS_MICROMIPS (stub->h->root.other))
 	{
-	  bfd_put_16 (hti->output_bfd, LA25_LUI_MICROMIPS_1 (target_high),
-		      loc);
-	  bfd_put_16 (hti->output_bfd, LA25_LUI_MICROMIPS_2 (target_high),
-		      loc + 2);
-	  bfd_put_16 (hti->output_bfd, LA25_ADDIU_MICROMIPS_1 (target_low),
-		      loc + 4);
-	  bfd_put_16 (hti->output_bfd, LA25_ADDIU_MICROMIPS_2 (target_low),
-		      loc + 6);
+	  bfd_put_micromips_32 (hti->output_bfd,
+				LA25_LUI_MICROMIPS (target_high),
+				loc);
+	  bfd_put_micromips_32 (hti->output_bfd,
+				LA25_ADDIU_MICROMIPS (target_low),
+				loc + 4);
 	}
       else
 	{
@@ -9650,16 +10158,12 @@
       loc += offset;
       if (ELF_ST_IS_MICROMIPS (stub->h->root.other))
 	{
-	  bfd_put_16 (hti->output_bfd, LA25_LUI_MICROMIPS_1 (target_high),
-		      loc);
-	  bfd_put_16 (hti->output_bfd, LA25_LUI_MICROMIPS_2 (target_high),
-		      loc + 2);
-	  bfd_put_16 (hti->output_bfd, LA25_J_MICROMIPS_1 (target), loc + 4);
-	  bfd_put_16 (hti->output_bfd, LA25_J_MICROMIPS_2 (target), loc + 6);
-	  bfd_put_16 (hti->output_bfd, LA25_ADDIU_MICROMIPS_1 (target_low),
-		      loc + 8);
-	  bfd_put_16 (hti->output_bfd, LA25_ADDIU_MICROMIPS_2 (target_low),
-		      loc + 10);
+	  bfd_put_micromips_32 (hti->output_bfd,
+				LA25_LUI_MICROMIPS (target_high), loc);
+	  bfd_put_micromips_32 (hti->output_bfd,
+				LA25_J_MICROMIPS (target), loc + 4);
+	  bfd_put_micromips_32 (hti->output_bfd,
+				LA25_ADDIU_MICROMIPS (target_low), loc + 8);
 	  bfd_put_32 (hti->output_bfd, 0, loc + 12);
 	}
       else
@@ -9747,68 +10251,158 @@
 
   BFD_ASSERT (!htab->is_vxworks);
 
-  if (h->plt.offset != MINUS_ONE && hmips->no_fn_stub)
+  if (h->plt.plist != NULL
+      && (h->plt.plist->mips_offset != MINUS_ONE
+	  || h->plt.plist->comp_offset != MINUS_ONE))
     {
       /* We've decided to create a PLT entry for this symbol.  */
       bfd_byte *loc;
-      bfd_vma header_address, plt_index, got_address;
+      bfd_vma header_address, got_address;
       bfd_vma got_address_high, got_address_low, load;
-      const bfd_vma *plt_entry;
+      bfd_vma got_index;
+      bfd_vma isa_bit;
+
+      got_index = h->plt.plist->gotplt_index;
 
       BFD_ASSERT (htab->use_plts_and_copy_relocs);
       BFD_ASSERT (h->dynindx != -1);
       BFD_ASSERT (htab->splt != NULL);
-      BFD_ASSERT (h->plt.offset <= htab->splt->size);
+      BFD_ASSERT (got_index != MINUS_ONE);
       BFD_ASSERT (!h->def_regular);
 
       /* Calculate the address of the PLT header.  */
+      isa_bit = htab->plt_header_is_comp;
       header_address = (htab->splt->output_section->vma
-			+ htab->splt->output_offset);
-
-      /* Calculate the index of the entry.  */
-      plt_index = ((h->plt.offset - htab->plt_header_size)
-		   / htab->plt_entry_size);
+			+ htab->splt->output_offset + isa_bit);
 
       /* Calculate the address of the .got.plt entry.  */
       got_address = (htab->sgotplt->output_section->vma
 		     + htab->sgotplt->output_offset
-		     + (2 + plt_index) * MIPS_ELF_GOT_SIZE (dynobj));
+		     + got_index * MIPS_ELF_GOT_SIZE (dynobj));
+
       got_address_high = ((got_address + 0x8000) >> 16) & 0xffff;
       got_address_low = got_address & 0xffff;
 
       /* Initially point the .got.plt entry at the PLT header.  */
-      loc = (htab->sgotplt->contents
-	     + (2 + plt_index) * MIPS_ELF_GOT_SIZE (dynobj));
+      loc = (htab->sgotplt->contents + got_index * MIPS_ELF_GOT_SIZE (dynobj));
       if (ABI_64_P (output_bfd))
 	bfd_put_64 (output_bfd, header_address, loc);
       else
 	bfd_put_32 (output_bfd, header_address, loc);
 
-      /* Find out where the .plt entry should go.  */
-      loc = htab->splt->contents + h->plt.offset;
-
-      /* Pick the load opcode.  */
-      load = MIPS_ELF_LOAD_WORD (output_bfd);
-
-      /* Fill in the PLT entry itself.  */
-      plt_entry = mips_exec_plt_entry;
-      bfd_put_32 (output_bfd, plt_entry[0] | got_address_high, loc);
-      bfd_put_32 (output_bfd, plt_entry[1] | got_address_low | load, loc + 4);
-
-      if (! LOAD_INTERLOCKS_P (output_bfd))
+      /* Now handle the PLT itself.  First the standard entry (the order
+         does not matter, we just have to pick one).  */
+      if (h->plt.plist->mips_offset != MINUS_ONE)
 	{
-	  bfd_put_32 (output_bfd, plt_entry[2] | got_address_low, loc + 8);
-	  bfd_put_32 (output_bfd, plt_entry[3], loc + 12);
+	  const bfd_vma *plt_entry;
+	  bfd_vma plt_offset;
+
+	  plt_offset = htab->plt_header_size + h->plt.plist->mips_offset;
+
+	  BFD_ASSERT (plt_offset <= htab->splt->size);
+
+	  /* Find out where the .plt entry should go.  */
+	  loc = htab->splt->contents + plt_offset;
+
+	  /* Pick the load opcode.  */
+	  load = MIPS_ELF_LOAD_WORD (output_bfd);
+
+	  /* Fill in the PLT entry itself.  */
+	  plt_entry = mips_exec_plt_entry;
+	  bfd_put_32 (output_bfd, plt_entry[0] | got_address_high, loc);
+	  bfd_put_32 (output_bfd, plt_entry[1] | got_address_low | load,
+		      loc + 4);
+
+	  if (! LOAD_INTERLOCKS_P (output_bfd))
+	    {
+	      bfd_put_32 (output_bfd, plt_entry[2] | got_address_low, loc + 8);
+	      bfd_put_32 (output_bfd, plt_entry[3], loc + 12);
+	    }
+	  else
+	    {
+	      bfd_put_32 (output_bfd, plt_entry[3], loc + 8);
+	      bfd_put_32 (output_bfd, plt_entry[2] | got_address_low,
+			  loc + 12);
+	    }
 	}
-      else
+
+      /* Now the compressed entry.  They come after any standard ones.  */
+      if (h->plt.plist->comp_offset != MINUS_ONE)
 	{
-	  bfd_put_32 (output_bfd, plt_entry[3], loc + 8);
-	  bfd_put_32 (output_bfd, plt_entry[2] | got_address_low, loc + 12);
+	  bfd_vma plt_offset;
+
+	  plt_offset = (htab->plt_header_size + htab->plt_mips_offset
+			+ h->plt.plist->comp_offset);
+
+	  BFD_ASSERT (plt_offset <= htab->splt->size);
+
+	  /* Find out where the .plt entry should go.  */
+	  loc = htab->splt->contents + plt_offset;
+
+	  /* Fill in the PLT entry itself.  */
+	  if (!MICROMIPS_P (output_bfd))
+	    {
+	      const bfd_vma *plt_entry = mips16_o32_exec_plt_entry;
+
+	      bfd_put_16 (output_bfd, plt_entry[0], loc);
+	      bfd_put_16 (output_bfd, plt_entry[1], loc + 2);
+	      bfd_put_16 (output_bfd, plt_entry[2], loc + 4);
+	      bfd_put_16 (output_bfd, plt_entry[3], loc + 6);
+	      bfd_put_16 (output_bfd, plt_entry[4], loc + 8);
+	      bfd_put_16 (output_bfd, plt_entry[5], loc + 10);
+	      bfd_put_32 (output_bfd, got_address, loc + 12);
+	    }
+	  else if (htab->insn32)
+	    {
+	      const bfd_vma *plt_entry = micromips_insn32_o32_exec_plt_entry;
+
+	      bfd_put_16 (output_bfd, plt_entry[0], loc);
+	      bfd_put_16 (output_bfd, got_address_high, loc + 2);
+	      bfd_put_16 (output_bfd, plt_entry[2], loc + 4);
+	      bfd_put_16 (output_bfd, got_address_low, loc + 6);
+	      bfd_put_16 (output_bfd, plt_entry[4], loc + 8);
+	      bfd_put_16 (output_bfd, plt_entry[5], loc + 10);
+	      bfd_put_16 (output_bfd, plt_entry[6], loc + 12);
+	      bfd_put_16 (output_bfd, got_address_low, loc + 14);
+	    }
+	  else
+	    {
+	      const bfd_vma *plt_entry = micromips_o32_exec_plt_entry;
+	      bfd_signed_vma gotpc_offset;
+	      bfd_vma loc_address;
+
+	      BFD_ASSERT (got_address % 4 == 0);
+
+	      loc_address = (htab->splt->output_section->vma
+			     + htab->splt->output_offset + plt_offset);
+	      gotpc_offset = got_address - ((loc_address | 3) ^ 3);
+
+	      /* ADDIUPC has a span of +/-16MB, check we're in range.  */
+	      if (gotpc_offset + 0x1000000 >= 0x2000000)
+		{
+		  (*_bfd_error_handler)
+		    (_("%B: `%A' offset of %ld from `%A' "
+		       "beyond the range of ADDIUPC"),
+		     output_bfd,
+		     htab->sgotplt->output_section,
+		     htab->splt->output_section,
+		     (long) gotpc_offset);
+		  bfd_set_error (bfd_error_no_error);
+		  return FALSE;
+		}
+	      bfd_put_16 (output_bfd,
+			  plt_entry[0] | ((gotpc_offset >> 18) & 0x7f), loc);
+	      bfd_put_16 (output_bfd, (gotpc_offset >> 2) & 0xffff, loc + 2);
+	      bfd_put_16 (output_bfd, plt_entry[2], loc + 4);
+	      bfd_put_16 (output_bfd, plt_entry[3], loc + 6);
+	      bfd_put_16 (output_bfd, plt_entry[4], loc + 8);
+	      bfd_put_16 (output_bfd, plt_entry[5], loc + 10);
+	    }
 	}
 
       /* Emit an R_MIPS_JUMP_SLOT relocation against the .got.plt entry.  */
       mips_elf_output_dynamic_relocation (output_bfd, htab->srelplt,
-					  plt_index, h->dynindx,
+					  got_index - 2, h->dynindx,
 					  R_MIPS_JUMP_SLOT, got_address);
 
       /* We distinguish between PLT entries and lazy-binding stubs by
@@ -9817,21 +10411,36 @@
 	 binary where pointer equality matters.  */
       sym->st_shndx = SHN_UNDEF;
       if (h->pointer_equality_needed)
-	sym->st_other = STO_MIPS_PLT;
+	sym->st_other = ELF_ST_SET_MIPS_PLT (sym->st_other);
       else
-	sym->st_value = 0;
+	{
+	  sym->st_value = 0;
+	  sym->st_other = 0;
+	}
     }
-  else if (h->plt.offset != MINUS_ONE)
+
+  if (h->plt.plist != NULL && h->plt.plist->stub_offset != MINUS_ONE)
     {
       /* We've decided to create a lazy-binding stub.  */
+      bfd_boolean micromips_p = MICROMIPS_P (output_bfd);
+      unsigned int other = micromips_p ? STO_MICROMIPS : 0;
+      bfd_vma stub_size = htab->function_stub_size;
       bfd_byte stub[MIPS_FUNCTION_STUB_BIG_SIZE];
+      bfd_vma isa_bit = micromips_p;
+      bfd_vma stub_big_size;
+
+      if (!micromips_p)
+	stub_big_size = MIPS_FUNCTION_STUB_BIG_SIZE;
+      else if (htab->insn32)
+	stub_big_size = MICROMIPS_INSN32_FUNCTION_STUB_BIG_SIZE;
+      else
+	stub_big_size = MICROMIPS_FUNCTION_STUB_BIG_SIZE;
 
       /* This symbol has a stub.  Set it up.  */
 
       BFD_ASSERT (h->dynindx != -1);
 
-      BFD_ASSERT ((htab->function_stub_size == MIPS_FUNCTION_STUB_BIG_SIZE)
-                  || (h->dynindx <= 0xffff));
+      BFD_ASSERT (stub_size == stub_big_size || h->dynindx <= 0xffff);
 
       /* Values up to 2^31 - 1 are allowed.  Larger values would cause
 	 sign extension at runtime in the stub, resulting in a negative
@@ -9840,35 +10449,95 @@
 	return FALSE;
 
       /* Fill the stub.  */
-      idx = 0;
-      bfd_put_32 (output_bfd, STUB_LW (output_bfd), stub + idx);
-      idx += 4;
-      bfd_put_32 (output_bfd, STUB_MOVE (output_bfd), stub + idx);
-      idx += 4;
-      if (htab->function_stub_size == MIPS_FUNCTION_STUB_BIG_SIZE)
-        {
-          bfd_put_32 (output_bfd, STUB_LUI ((h->dynindx >> 16) & 0x7fff),
-                      stub + idx);
-          idx += 4;
-        }
-      bfd_put_32 (output_bfd, STUB_JALR, stub + idx);
-      idx += 4;
+      if (micromips_p)
+	{
+	  idx = 0;
+	  bfd_put_micromips_32 (output_bfd, STUB_LW_MICROMIPS (output_bfd),
+				stub + idx);
+	  idx += 4;
+	  if (htab->insn32)
+	    {
+	      bfd_put_micromips_32 (output_bfd,
+				    STUB_MOVE32_MICROMIPS (output_bfd),
+				    stub + idx);
+	      idx += 4;
+	    }
+	  else
+	    {
+	      bfd_put_16 (output_bfd, STUB_MOVE_MICROMIPS, stub + idx);
+	      idx += 2;
+	    }
+	  if (stub_size == stub_big_size)
+	    {
+	      long dynindx_hi = (h->dynindx >> 16) & 0x7fff;
 
-      /* If a large stub is not required and sign extension is not a
-         problem, then use legacy code in the stub.  */
-      if (htab->function_stub_size == MIPS_FUNCTION_STUB_BIG_SIZE)
-	bfd_put_32 (output_bfd, STUB_ORI (h->dynindx & 0xffff), stub + idx);
-      else if (h->dynindx & ~0x7fff)
-        bfd_put_32 (output_bfd, STUB_LI16U (h->dynindx & 0xffff), stub + idx);
+	      bfd_put_micromips_32 (output_bfd,
+				    STUB_LUI_MICROMIPS (dynindx_hi),
+				    stub + idx);
+	      idx += 4;
+	    }
+	  if (htab->insn32)
+	    {
+	      bfd_put_micromips_32 (output_bfd, STUB_JALR32_MICROMIPS,
+				    stub + idx);
+	      idx += 4;
+	    }
+	  else
+	    {
+	      bfd_put_16 (output_bfd, STUB_JALR_MICROMIPS, stub + idx);
+	      idx += 2;
+	    }
+
+	  /* If a large stub is not required and sign extension is not a
+	     problem, then use legacy code in the stub.  */
+	  if (stub_size == stub_big_size)
+	    bfd_put_micromips_32 (output_bfd,
+				  STUB_ORI_MICROMIPS (h->dynindx & 0xffff),
+				  stub + idx);
+	  else if (h->dynindx & ~0x7fff)
+	    bfd_put_micromips_32 (output_bfd,
+				  STUB_LI16U_MICROMIPS (h->dynindx & 0xffff),
+				  stub + idx);
+	  else
+	    bfd_put_micromips_32 (output_bfd,
+				  STUB_LI16S_MICROMIPS (output_bfd,
+							h->dynindx),
+				  stub + idx);
+	}
       else
-        bfd_put_32 (output_bfd, STUB_LI16S (output_bfd, h->dynindx),
-		    stub + idx);
+	{
+	  idx = 0;
+	  bfd_put_32 (output_bfd, STUB_LW (output_bfd), stub + idx);
+	  idx += 4;
+	  bfd_put_32 (output_bfd, STUB_MOVE (output_bfd), stub + idx);
+	  idx += 4;
+	  if (stub_size == stub_big_size)
+	    {
+	      bfd_put_32 (output_bfd, STUB_LUI ((h->dynindx >> 16) & 0x7fff),
+			  stub + idx);
+	      idx += 4;
+	    }
+	  bfd_put_32 (output_bfd, STUB_JALR, stub + idx);
+	  idx += 4;
 
-      BFD_ASSERT (h->plt.offset <= htab->sstubs->size);
-      memcpy (htab->sstubs->contents + h->plt.offset,
-	      stub, htab->function_stub_size);
+	  /* If a large stub is not required and sign extension is not a
+	     problem, then use legacy code in the stub.  */
+	  if (stub_size == stub_big_size)
+	    bfd_put_32 (output_bfd, STUB_ORI (h->dynindx & 0xffff),
+			stub + idx);
+	  else if (h->dynindx & ~0x7fff)
+	    bfd_put_32 (output_bfd, STUB_LI16U (h->dynindx & 0xffff),
+			stub + idx);
+	  else
+	    bfd_put_32 (output_bfd, STUB_LI16S (output_bfd, h->dynindx),
+			stub + idx);
+	}
 
-      /* Mark the symbol as undefined.  plt.offset != -1 occurs
+      BFD_ASSERT (h->plt.plist->stub_offset <= htab->sstubs->size);
+      memcpy (htab->sstubs->contents + h->plt.plist->stub_offset,
+	      stub, stub_size);
+
+      /* Mark the symbol as undefined.  stub_offset != -1 occurs
 	 only for the referenced symbol.  */
       sym->st_shndx = SHN_UNDEF;
 
@@ -9877,7 +10546,9 @@
 	 to its stub address when unlinking a shared object.  */
       sym->st_value = (htab->sstubs->output_section->vma
 		       + htab->sstubs->output_offset
-		       + h->plt.offset);
+		       + h->plt.plist->stub_offset
+		       + isa_bit);
+      sym->st_other = other;
     }
 
   /* If we have a MIPS16 function with a stub, the dynamic symbol must
@@ -9907,12 +10578,11 @@
       bfd_vma value;
 
       value = sym->st_value;
-      offset = mips_elf_global_got_index (dynobj, output_bfd, h,
-					  R_MIPS_GOT16, info);
+      offset = mips_elf_primary_global_got_index (output_bfd, info, h);
       MIPS_ELF_PUT_WORD (output_bfd, value, sgot->contents + offset);
     }
 
-  if (hmips->global_got_area != GGA_NONE && g->next && h->type != STT_TLS)
+  if (hmips->global_got_area != GGA_NONE && g->next)
     {
       struct mips_got_entry e, *p;
       bfd_vma entry;
@@ -9923,7 +10593,7 @@
       e.abfd = output_bfd;
       e.symndx = -1;
       e.d.h = hmips;
-      e.tls_type = 0;
+      e.tls_type = GOT_TLS_NONE;
 
       for (g = g->next; g->next != gg; g = g->next)
 	{
@@ -9932,6 +10602,7 @@
 							   &e)))
 	    {
 	      offset = p->gotidx;
+	      BFD_ASSERT (offset > 0 && offset < htab->sgot->size);
 	      if (info->shared
 		  || (elf_hash_table (info)->dynamic_sections_created
 		      && p->d.h != NULL
@@ -9967,7 +10638,7 @@
 
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
   name = h->root.root.string;
-  if (strcmp (name, "_DYNAMIC") == 0
+  if (h == elf_hash_table (info)->hdynamic
       || h == elf_hash_table (info)->hgot)
     sym->st_shndx = SHN_ABS;
   else if (strcmp (name, "_DYNAMIC_LINK") == 0
@@ -10030,38 +10701,18 @@
   if (IRIX_COMPAT (output_bfd) == ict_irix6)
     mips_elf_irix6_finish_dynamic_symbol (output_bfd, name, sym);
 
-  if (! info->shared)
-    {
-      if (! mips_elf_hash_table (info)->use_rld_obj_head
-	  && (strcmp (name, "__rld_map") == 0
-	      || strcmp (name, "__RLD_MAP") == 0))
-	{
-	  asection *s = bfd_get_section_by_name (dynobj, ".rld_map");
-	  BFD_ASSERT (s != NULL);
-	  sym->st_value = s->output_section->vma + s->output_offset;
-	  bfd_put_32 (output_bfd, 0, s->contents);
-	  if (mips_elf_hash_table (info)->rld_value == 0)
-	    mips_elf_hash_table (info)->rld_value = sym->st_value;
-	}
-      else if (mips_elf_hash_table (info)->use_rld_obj_head
-	       && strcmp (name, "__rld_obj_head") == 0)
-	{
-	  /* IRIX6 does not use a .rld_map section.  */
-	  if (IRIX_COMPAT (output_bfd) == ict_irix5
-              || IRIX_COMPAT (output_bfd) == ict_none)
-	    BFD_ASSERT (bfd_get_section_by_name (dynobj, ".rld_map")
-			!= NULL);
-	  mips_elf_hash_table (info)->rld_value = sym->st_value;
-	}
-    }
-
-  /* Keep dynamic MIPS16 symbols odd.  This allows the dynamic linker to
-     treat MIPS16 symbols like any other.  */
+  /* Keep dynamic compressed symbols odd.  This allows the dynamic linker
+     to treat compressed symbols like any other.  */
   if (ELF_ST_IS_MIPS16 (sym->st_other))
     {
       BFD_ASSERT (sym->st_value & 1);
       sym->st_other -= STO_MIPS16;
     }
+  else if (ELF_ST_IS_MICROMIPS (sym->st_other))
+    {
+      BFD_ASSERT (sym->st_value & 1);
+      sym->st_other -= STO_MICROMIPS;
+    }
 
   return TRUE;
 }
@@ -10085,30 +10736,32 @@
   dynobj = elf_hash_table (info)->dynobj;
   hmips = (struct mips_elf_link_hash_entry *) h;
 
-  if (h->plt.offset != (bfd_vma) -1)
+  if (h->plt.plist != NULL && h->plt.plist->mips_offset != MINUS_ONE)
     {
       bfd_byte *loc;
-      bfd_vma plt_address, plt_index, got_address, got_offset, branch_offset;
+      bfd_vma plt_address, got_address, got_offset, branch_offset;
       Elf_Internal_Rela rel;
       static const bfd_vma *plt_entry;
+      bfd_vma gotplt_index;
+      bfd_vma plt_offset;
+
+      plt_offset = htab->plt_header_size + h->plt.plist->mips_offset;
+      gotplt_index = h->plt.plist->gotplt_index;
 
       BFD_ASSERT (h->dynindx != -1);
       BFD_ASSERT (htab->splt != NULL);
-      BFD_ASSERT (h->plt.offset <= htab->splt->size);
+      BFD_ASSERT (gotplt_index != MINUS_ONE);
+      BFD_ASSERT (plt_offset <= htab->splt->size);
 
       /* Calculate the address of the .plt entry.  */
       plt_address = (htab->splt->output_section->vma
 		     + htab->splt->output_offset
-		     + h->plt.offset);
-
-      /* Calculate the index of the entry.  */
-      plt_index = ((h->plt.offset - htab->plt_header_size)
-		   / htab->plt_entry_size);
+		     + plt_offset);
 
       /* Calculate the address of the .got.plt entry.  */
       got_address = (htab->sgotplt->output_section->vma
 		     + htab->sgotplt->output_offset
-		     + plt_index * 4);
+		     + gotplt_index * MIPS_ELF_GOT_SIZE (output_bfd));
 
       /* Calculate the offset of the .got.plt entry from
 	 _GLOBAL_OFFSET_TABLE_.  */
@@ -10116,20 +10769,21 @@
 
       /* Calculate the offset for the branch at the start of the PLT
 	 entry.  The branch jumps to the beginning of .plt.  */
-      branch_offset = -(h->plt.offset / 4 + 1) & 0xffff;
+      branch_offset = -(plt_offset / 4 + 1) & 0xffff;
 
       /* Fill in the initial value of the .got.plt entry.  */
       bfd_put_32 (output_bfd, plt_address,
-		  htab->sgotplt->contents + plt_index * 4);
+		  (htab->sgotplt->contents
+		   + gotplt_index * MIPS_ELF_GOT_SIZE (output_bfd)));
 
       /* Find out where the .plt entry should go.  */
-      loc = htab->splt->contents + h->plt.offset;
+      loc = htab->splt->contents + plt_offset;
 
       if (info->shared)
 	{
 	  plt_entry = mips_vxworks_shared_plt_entry;
 	  bfd_put_32 (output_bfd, plt_entry[0] | branch_offset, loc);
-	  bfd_put_32 (output_bfd, plt_entry[1] | plt_index, loc + 4);
+	  bfd_put_32 (output_bfd, plt_entry[1] | gotplt_index, loc + 4);
 	}
       else
 	{
@@ -10140,7 +10794,7 @@
 	  got_address_low = got_address & 0xffff;
 
 	  bfd_put_32 (output_bfd, plt_entry[0] | branch_offset, loc);
-	  bfd_put_32 (output_bfd, plt_entry[1] | plt_index, loc + 4);
+	  bfd_put_32 (output_bfd, plt_entry[1] | gotplt_index, loc + 4);
 	  bfd_put_32 (output_bfd, plt_entry[2] | got_address_high, loc + 8);
 	  bfd_put_32 (output_bfd, plt_entry[3] | got_address_low, loc + 12);
 	  bfd_put_32 (output_bfd, plt_entry[4], loc + 16);
@@ -10149,12 +10803,12 @@
 	  bfd_put_32 (output_bfd, plt_entry[7], loc + 28);
 
 	  loc = (htab->srelplt2->contents
-		 + (plt_index * 3 + 2) * sizeof (Elf32_External_Rela));
+		 + (gotplt_index * 3 + 2) * sizeof (Elf32_External_Rela));
 
 	  /* Emit a relocation for the .got.plt entry.  */
 	  rel.r_offset = got_address;
 	  rel.r_info = ELF32_R_INFO (htab->root.hplt->indx, R_MIPS_32);
-	  rel.r_addend = h->plt.offset;
+	  rel.r_addend = plt_offset;
 	  bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
 
 	  /* Emit a relocation for the lui of %hi(<.got.plt slot>).  */
@@ -10172,7 +10826,8 @@
 	}
 
       /* Emit an R_MIPS_JUMP_SLOT relocation against the .got.plt entry.  */
-      loc = htab->srelplt->contents + plt_index * sizeof (Elf32_External_Rela);
+      loc = (htab->srelplt->contents
+	     + gotplt_index * sizeof (Elf32_External_Rela));
       rel.r_offset = got_address;
       rel.r_info = ELF32_R_INFO (h->dynindx, R_MIPS_JUMP_SLOT);
       rel.r_addend = 0;
@@ -10197,8 +10852,7 @@
       asection *s;
 
       /* Install the symbol value in the GOT.   */
-      offset = mips_elf_global_got_index (dynobj, output_bfd, h,
-					  R_MIPS_GOT16, info);
+      offset = mips_elf_primary_global_got_index (output_bfd, info, h);
       MIPS_ELF_PUT_WORD (output_bfd, sym->st_value, sgot->contents + offset);
 
       /* Add a dynamic relocation for it.  */
@@ -10240,7 +10894,7 @@
 
 /* Write out a plt0 entry to the beginning of .plt.  */
 
-static void
+static bfd_boolean
 mips_finish_exec_plt (bfd *output_bfd, struct bfd_link_info *info)
 {
   bfd_byte *loc;
@@ -10255,8 +10909,12 @@
     plt_entry = mips_n64_exec_plt0_entry;
   else if (ABI_N32_P (output_bfd))
     plt_entry = mips_n32_exec_plt0_entry;
-  else
+  else if (!htab->plt_header_is_comp)
     plt_entry = mips_o32_exec_plt0_entry;
+  else if (htab->insn32)
+    plt_entry = micromips_insn32_o32_exec_plt0_entry;
+  else
+    plt_entry = micromips_o32_exec_plt0_entry;
 
   /* Calculate the value of .got.plt.  */
   gotplt_value = (htab->sgotplt->output_section->vma
@@ -10271,14 +10929,62 @@
 
   /* Install the PLT header.  */
   loc = htab->splt->contents;
-  bfd_put_32 (output_bfd, plt_entry[0] | gotplt_value_high, loc);
-  bfd_put_32 (output_bfd, plt_entry[1] | gotplt_value_low, loc + 4);
-  bfd_put_32 (output_bfd, plt_entry[2] | gotplt_value_low, loc + 8);
-  bfd_put_32 (output_bfd, plt_entry[3], loc + 12);
-  bfd_put_32 (output_bfd, plt_entry[4], loc + 16);
-  bfd_put_32 (output_bfd, plt_entry[5], loc + 20);
-  bfd_put_32 (output_bfd, plt_entry[6], loc + 24);
-  bfd_put_32 (output_bfd, plt_entry[7], loc + 28);
+  if (plt_entry == micromips_o32_exec_plt0_entry)
+    {
+      bfd_vma gotpc_offset;
+      bfd_vma loc_address;
+      size_t i;
+
+      BFD_ASSERT (gotplt_value % 4 == 0);
+
+      loc_address = (htab->splt->output_section->vma
+		     + htab->splt->output_offset);
+      gotpc_offset = gotplt_value - ((loc_address | 3) ^ 3);
+
+      /* ADDIUPC has a span of +/-16MB, check we're in range.  */
+      if (gotpc_offset + 0x1000000 >= 0x2000000)
+	{
+	  (*_bfd_error_handler)
+	    (_("%B: `%A' offset of %ld from `%A' beyond the range of ADDIUPC"),
+	     output_bfd,
+	     htab->sgotplt->output_section,
+	     htab->splt->output_section,
+	     (long) gotpc_offset);
+	  bfd_set_error (bfd_error_no_error);
+	  return FALSE;
+	}
+      bfd_put_16 (output_bfd,
+		  plt_entry[0] | ((gotpc_offset >> 18) & 0x7f), loc);
+      bfd_put_16 (output_bfd, (gotpc_offset >> 2) & 0xffff, loc + 2);
+      for (i = 2; i < ARRAY_SIZE (micromips_o32_exec_plt0_entry); i++)
+	bfd_put_16 (output_bfd, plt_entry[i], loc + (i * 2));
+    }
+  else if (plt_entry == micromips_insn32_o32_exec_plt0_entry)
+    {
+      size_t i;
+
+      bfd_put_16 (output_bfd, plt_entry[0], loc);
+      bfd_put_16 (output_bfd, gotplt_value_high, loc + 2);
+      bfd_put_16 (output_bfd, plt_entry[2], loc + 4);
+      bfd_put_16 (output_bfd, gotplt_value_low, loc + 6);
+      bfd_put_16 (output_bfd, plt_entry[4], loc + 8);
+      bfd_put_16 (output_bfd, gotplt_value_low, loc + 10);
+      for (i = 6; i < ARRAY_SIZE (micromips_insn32_o32_exec_plt0_entry); i++)
+	bfd_put_16 (output_bfd, plt_entry[i], loc + (i * 2));
+    }
+  else
+    {
+      bfd_put_32 (output_bfd, plt_entry[0] | gotplt_value_high, loc);
+      bfd_put_32 (output_bfd, plt_entry[1] | gotplt_value_low, loc + 4);
+      bfd_put_32 (output_bfd, plt_entry[2] | gotplt_value_low, loc + 8);
+      bfd_put_32 (output_bfd, plt_entry[3], loc + 12);
+      bfd_put_32 (output_bfd, plt_entry[4], loc + 16);
+      bfd_put_32 (output_bfd, plt_entry[5], loc + 20);
+      bfd_put_32 (output_bfd, plt_entry[6], loc + 24);
+      bfd_put_32 (output_bfd, plt_entry[7], loc + 28);
+    }
+
+  return TRUE;
 }
 
 /* Install the PLT header for a VxWorks executable and finalize the
@@ -10391,7 +11097,7 @@
 
   dynobj = elf_hash_table (info)->dynobj;
 
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   sgot = htab->sgot;
   gg = htab->got_info;
@@ -10404,7 +11110,7 @@
       BFD_ASSERT (sdyn != NULL);
       BFD_ASSERT (gg != NULL);
 
-      g = mips_elf_got_for_ibfd (gg, output_bfd);
+      g = mips_elf_bfd_got (output_bfd, FALSE);
       BFD_ASSERT (g != NULL);
 
       for (b = sdyn->contents;
@@ -10494,9 +11200,9 @@
 	      break;
 
 	    case DT_MIPS_GOTSYM:
-	      if (gg->global_gotsym)
+	      if (htab->global_gotsym)
 		{
-		  dyn.d_un.d_val = gg->global_gotsym->dynindx;
+		  dyn.d_un.d_val = htab->global_gotsym->dynindx;
 		  break;
 		}
 	      /* In case if we don't have global got symbols we default
@@ -10517,7 +11223,19 @@
 	      break;
 
 	    case DT_MIPS_RLD_MAP:
-	      dyn.d_un.d_ptr = mips_elf_hash_table (info)->rld_value;
+	      {
+		struct elf_link_hash_entry *h;
+		h = mips_elf_hash_table (info)->rld_symbol;
+		if (!h)
+		  {
+		    dyn_to_skip = MIPS_ELF_DYN_SIZE (dynobj);
+		    swap_out_p = FALSE;
+		    break;
+		  }
+		s = h->root.u.def.section;
+		dyn.d_un.d_ptr = (s->output_section->vma + s->output_offset
+				  + h->root.u.def.value);
+	      }
 	      break;
 
 	    case DT_MIPS_OPTIONS:
@@ -10725,7 +11443,7 @@
     if (SGI_COMPAT (output_bfd))
       {
 	/* Write .compact_rel section out.  */
-	s = bfd_get_section_by_name (dynobj, ".compact_rel");
+	s = bfd_get_linker_section (dynobj, ".compact_rel");
 	if (s != NULL)
 	  {
 	    cpt.id1 = 1;
@@ -10788,7 +11506,8 @@
       else
 	{
 	  BFD_ASSERT (!info->shared);
-	  mips_finish_exec_plt (output_bfd, info);
+	  if (!mips_finish_exec_plt (output_bfd, info))
+	    return FALSE;
 	}
     }
   return TRUE;
@@ -10852,6 +11571,10 @@
       val = E_MIPS_ARCH_4 | E_MIPS_MACH_5500;
       break;
 
+    case bfd_mach_mips5900:
+      val = E_MIPS_ARCH_3 | E_MIPS_MACH_5900;
+      break;
+
     case bfd_mach_mips9000:
       val = E_MIPS_ARCH_4 | E_MIPS_MACH_9000;
       break;
@@ -10887,6 +11610,7 @@
       break;
 
     case bfd_mach_mips_octeon:
+    case bfd_mach_mips_octeonp:
       val = E_MIPS_ARCH_64R2 | E_MIPS_MACH_OCTEON;
       break;
 
@@ -10894,6 +11618,10 @@
       val = E_MIPS_ARCH_64 | E_MIPS_MACH_XLR;
       break;
 
+    case bfd_mach_mips_octeon2:
+      val = E_MIPS_ARCH_64R2 | E_MIPS_MACH_OCTEON2;
+      break;
+
     case bfd_mach_mipsisa32:
       val = E_MIPS_ARCH_32;
       break;
@@ -11053,7 +11781,7 @@
   s = bfd_get_section_by_name (abfd, ".reginfo");
   if (s != NULL && (s->flags & SEC_LOAD) != 0)
     {
-      for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+      for (m = elf_seg_map (abfd); m != NULL; m = m->next)
 	if (m->p_type == PT_MIPS_REGINFO)
 	  break;
       if (m == NULL)
@@ -11068,7 +11796,7 @@
 	  m->sections[0] = s;
 
 	  /* We want to put it after the PHDR and INTERP segments.  */
-	  pm = &elf_tdata (abfd)->segment_map;
+	  pm = &elf_seg_map (abfd);
 	  while (*pm != NULL
 		 && ((*pm)->p_type == PT_PHDR
 		     || (*pm)->p_type == PT_INTERP))
@@ -11098,7 +11826,7 @@
 	{
 	  struct elf_segment_map *options_segment;
 
-	  pm = &elf_tdata (abfd)->segment_map;
+	  pm = &elf_seg_map (abfd);
 	  while (*pm != NULL
 		 && ((*pm)->p_type == PT_PHDR
 		     || (*pm)->p_type == PT_INTERP))
@@ -11128,7 +11856,7 @@
 	      && bfd_get_section_by_name (abfd, ".dynamic") != NULL
 	      && bfd_get_section_by_name (abfd, ".mdebug") != NULL)
 	    {
-	      for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
+	      for (m = elf_seg_map (abfd); m != NULL; m = m->next)
 		if (m->p_type == PT_MIPS_RTPROC)
 		  break;
 	      if (m == NULL)
@@ -11154,7 +11882,7 @@
 		    }
 
 		  /* We want to put it after the DYNAMIC segment.  */
-		  pm = &elf_tdata (abfd)->segment_map;
+		  pm = &elf_seg_map (abfd);
 		  while (*pm != NULL && (*pm)->p_type != PT_DYNAMIC)
 		    pm = &(*pm)->next;
 		  if (*pm != NULL)
@@ -11168,7 +11896,7 @@
       /* On IRIX5, the PT_DYNAMIC segment includes the .dynamic,
 	 .dynstr, .dynsym, and .hash sections, and everything in
 	 between.  */
-      for (pm = &elf_tdata (abfd)->segment_map; *pm != NULL;
+      for (pm = &elf_seg_map (abfd); *pm != NULL;
 	   pm = &(*pm)->next)
 	if ((*pm)->p_type == PT_DYNAMIC)
 	  break;
@@ -11275,7 +12003,7 @@
       && !SGI_COMPAT (abfd)
       && bfd_get_section_by_name (abfd, ".dynamic"))
     {
-      for (pm = &elf_tdata (abfd)->segment_map; *pm != NULL; pm = &(*pm)->next)
+      for (pm = &elf_seg_map (abfd); *pm != NULL; pm = &(*pm)->next)
 	if ((*pm)->p_type == PT_NULL)
 	  break;
       if (*pm == NULL)
@@ -11430,9 +12158,6 @@
     indmips->global_got_area = GGA_NONE;
   if (indmips->has_nonpic_branches)
     dirmips->has_nonpic_branches = TRUE;
-
-  if (dirmips->tls_type == 0)
-    dirmips->tls_type = indmips->tls_type;
 }
 
 #define PDR_SIZE 32
@@ -11567,7 +12292,8 @@
 				     line_ptr))
     return TRUE;
 
-  if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
+  if (_bfd_dwarf2_find_nearest_line (abfd, dwarf_debug_sections,
+                                     section, symbols, offset,
 				     filename_ptr, functionname_ptr,
 				     line_ptr, NULL, ABI_64_P (abfd) ? 8 : 0,
 				     &elf_tdata (abfd)->dwarf2_find_line_info))
@@ -11588,7 +12314,7 @@
       if (elf_section_data (msec)->this_hdr.sh_type != SHT_NOBITS)
 	msec->flags |= SEC_HAS_CONTENTS;
 
-      fi = elf_tdata (abfd)->find_line_info;
+      fi = mips_elf_tdata (abfd)->find_line_info;
       if (fi == NULL)
 	{
 	  bfd_size_type external_fdr_size;
@@ -11626,7 +12352,7 @@
 	  for (; fraw_src < fraw_end; fraw_src += external_fdr_size, fdr_ptr++)
 	    (*swap->swap_fdr_in) (abfd, fraw_src, fdr_ptr);
 
-	  elf_tdata (abfd)->find_line_info = fi;
+	  mips_elf_tdata (abfd)->find_line_info = fi;
 
 	  /* Note that we don't bother to ever free this information.
              find_nearest_line is either called all the time, as in
@@ -12199,7 +12925,7 @@
   unsigned long opcode;
   int bdsize;
 
-  opcode = (bfd_get_16 (abfd, ptr) << 16) | bfd_get_16 (abfd, ptr + 2);
+  opcode = bfd_get_micromips_32 (abfd, ptr);
   if (find_match (opcode, ds_insns_32_bd32) >= 0)
     /* 32-bit branch/jump with a 32-bit delay slot.  */
     bdsize = 4;
@@ -12244,7 +12970,7 @@
 {
   unsigned long opcode;
 
-  opcode = (bfd_get_16 (abfd, ptr) << 16) | bfd_get_16 (abfd, ptr + 2);
+  opcode = bfd_get_micromips_32 (abfd, ptr);
   if (MATCH (opcode, j_insn_32)
 						/* J  */
       || MATCH (opcode, bc_insn_32)
@@ -12276,9 +13002,7 @@
   const Elf_Internal_Rela *irel;
   unsigned long opcode;
 
-  opcode   = bfd_get_16 (abfd, ptr);
-  opcode <<= 16;
-  opcode  |= bfd_get_16 (abfd, ptr + 2);
+  opcode = bfd_get_micromips_32 (abfd, ptr);
   if (find_match (opcode, bzc_insns_32) < 0)
     return FALSE;
 
@@ -12301,6 +13025,7 @@
 			     struct bfd_link_info *link_info,
 			     bfd_boolean *again)
 {
+  bfd_boolean insn32 = mips_elf_hash_table (link_info)->insn32;
   Elf_Internal_Shdr *symtab_hdr;
   Elf_Internal_Rela *internal_relocs;
   Elf_Internal_Rela *irel, *irelend;
@@ -12324,7 +13049,7 @@
 
   /* Get a copy of the native relocations.  */
   internal_relocs = (_bfd_elf_link_read_relocs
-		     (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+		     (abfd, sec, NULL, (Elf_Internal_Rela *) NULL,
 		      link_info->keep_memory));
   if (internal_relocs == NULL)
     goto error_return;
@@ -12436,8 +13161,7 @@
       if (irel->r_offset + 4 > sec->size)
 	continue;
 
-      opcode  = bfd_get_16 (abfd, ptr    ) << 16;
-      opcode |= bfd_get_16 (abfd, ptr + 2);
+      opcode = bfd_get_micromips_32 (abfd, ptr);
 
       /* This is the pc-relative distance from the instruction the
          relocation is applied to, to the symbol referred.  */
@@ -12519,8 +13243,7 @@
 	      continue;
 	    }
 
-	  nextopc  = bfd_get_16 (abfd, contents + irel[1].r_offset    ) << 16;
-	  nextopc |= bfd_get_16 (abfd, contents + irel[1].r_offset + 2);
+	  nextopc = bfd_get_micromips_32 (abfd, contents + irel[1].r_offset);
 
 	  /* Give up unless the same register is used with both
 	     relocations.  */
@@ -12561,10 +13284,8 @@
 	      nextopc = (addiupc_insn.match
 			 | ADDIUPC_REG_FIELD (OP32_TREG (nextopc)));
 
-	      bfd_put_16 (abfd, (nextopc >> 16) & 0xffff,
-			  contents + irel[1].r_offset);
-	      bfd_put_16 (abfd,  nextopc        & 0xffff,
-			  contents + irel[1].r_offset + 2);
+	      bfd_put_micromips_32 (abfd, nextopc,
+				    contents + irel[1].r_offset);
 	    }
 
 	  /* Can't do anything, give up, sigh...  */
@@ -12587,7 +13308,13 @@
 	       && irel->r_offset + 5 < sec->size
 	       && ((fndopc = find_match (opcode, bz_rs_insns_32)) >= 0
 		   || (fndopc = find_match (opcode, bz_rt_insns_32)) >= 0)
-	       && MATCH (bfd_get_16 (abfd, ptr + 4), nop_insn_16))
+	       && ((!insn32
+		    && (delcnt = MATCH (bfd_get_16 (abfd, ptr + 4),
+					nop_insn_16) ? 2 : 0))
+		   || (irel->r_offset + 7 < sec->size
+		       && (delcnt = MATCH (bfd_get_micromips_32 (abfd,
+								 ptr + 4),
+					   nop_insn_32) ? 4 : 0))))
 	{
 	  unsigned long reg;
 
@@ -12598,25 +13325,24 @@
 		    | BZC32_REG_FIELD (reg)
 		    | (opcode & 0xffff));		/* Addend value.  */
 
-	  bfd_put_16 (abfd, (opcode >> 16) & 0xffff, ptr);
-	  bfd_put_16 (abfd,  opcode        & 0xffff, ptr + 2);
+	  bfd_put_micromips_32 (abfd, opcode, ptr);
 
-	  /* Delete the 16-bit delay slot NOP: two bytes from
-	     irel->offset + 4.  */
-	  delcnt = 2;
+	  /* Delete the delay slot NOP: two or four bytes from
+	     irel->offset + 4; delcnt has already been set above.  */
 	  deloff = 4;
 	}
 
       /* R_MICROMIPS_PC16_S1 relaxation to R_MICROMIPS_PC10_S1.  We need
          to check the distance from the next instruction, so subtract 2.  */
-      else if (r_type == R_MICROMIPS_PC16_S1
+      else if (!insn32
+	       && r_type == R_MICROMIPS_PC16_S1
 	       && IS_BITSIZE (pcrval - 2, 11)
 	       && find_match (opcode, b_insns_32) >= 0)
 	{
 	  /* Fix the relocation's type.  */
 	  irel->r_info = ELF32_R_INFO (r_symndx, R_MICROMIPS_PC10_S1);
 
-	  /* Replace the the 32-bit opcode with a 16-bit opcode.  */
+	  /* Replace the 32-bit opcode with a 16-bit opcode.  */
 	  bfd_put_16 (abfd,
 		      (b_insn_16.match
 		       | (opcode & 0x3ff)),		/* Addend value.  */
@@ -12629,7 +13355,8 @@
 
       /* R_MICROMIPS_PC16_S1 relaxation to R_MICROMIPS_PC7_S1.  We need
          to check the distance from the next instruction, so subtract 2.  */
-      else if (r_type == R_MICROMIPS_PC16_S1
+      else if (!insn32
+	       && r_type == R_MICROMIPS_PC16_S1
 	       && IS_BITSIZE (pcrval - 2, 8)
 	       && (((fndopc = find_match (opcode, bz_rs_insns_32)) >= 0
 		    && OP16_VALID_REG (OP32_SREG (opcode)))
@@ -12643,7 +13370,7 @@
 	  /* Fix the relocation's type.  */
 	  irel->r_info = ELF32_R_INFO (r_symndx, R_MICROMIPS_PC7_S1);
 
-	  /* Replace the the 32-bit opcode with a 16-bit opcode.  */
+	  /* Replace the 32-bit opcode with a 16-bit opcode.  */
 	  bfd_put_16 (abfd,
 		      (bz_insns_16[fndopc].match
 		       | BZ16_REG_FIELD (reg)
@@ -12656,7 +13383,8 @@
 	}
 
       /* R_MICROMIPS_26_S1 -- JAL to JALS relaxation for microMIPS targets.  */
-      else if (r_type == R_MICROMIPS_26_S1
+      else if (!insn32
+	       && r_type == R_MICROMIPS_26_S1
 	       && target_is_micromips_code_p
 	       && irel->r_offset + 7 < sec->size
 	       && MATCH (opcode, jal_insn_32_bd32))
@@ -12664,8 +13392,7 @@
 	  unsigned long n32opc;
 	  bfd_boolean relaxed = FALSE;
 
-	  n32opc  = bfd_get_16 (abfd, ptr + 4) << 16;
-	  n32opc |= bfd_get_16 (abfd, ptr + 6);
+	  n32opc = bfd_get_micromips_32 (abfd, ptr + 4);
 
 	  if (MATCH (n32opc, nop_insn_32))
 	    {
@@ -12692,10 +13419,7 @@
 	    {
 	      /* JAL with 32-bit delay slot that is changed to a JALS
 	         with 16-bit delay slot.  */
-	      bfd_put_16 (abfd, (jal_insn_32_bd16.match >> 16) & 0xffff,
-			  ptr);
-	      bfd_put_16 (abfd,  jal_insn_32_bd16.match        & 0xffff,
-			  ptr + 2);
+	      bfd_put_micromips_32 (abfd, jal_insn_32_bd16.match, ptr);
 
 	      /* Delete 2 bytes from irel->r_offset + 6.  */
 	      delcnt = 2;
@@ -12773,7 +13497,7 @@
   struct mips_elf_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct mips_elf_link_hash_table);
 
-  ret = bfd_malloc (amt);
+  ret = bfd_zmalloc (amt);
   if (ret == NULL)
     return NULL;
 
@@ -12785,36 +13509,8 @@
       free (ret);
       return NULL;
     }
-
-#if 0
-  /* We no longer use this.  */
-  for (i = 0; i < SIZEOF_MIPS_DYNSYM_SECNAMES; i++)
-    ret->dynsym_sec_strindex[i] = (bfd_size_type) -1;
-#endif
-  ret->procedure_count = 0;
-  ret->compact_rel_size = 0;
-  ret->use_rld_obj_head = FALSE;
-  ret->rld_value = 0;
-  ret->mips16_stubs_seen = FALSE;
-  ret->use_plts_and_copy_relocs = FALSE;
-  ret->is_vxworks = FALSE;
-  ret->small_data_overflow_reported = FALSE;
-  ret->srelbss = NULL;
-  ret->sdynbss = NULL;
-  ret->srelplt = NULL;
-  ret->srelplt2 = NULL;
-  ret->sgotplt = NULL;
-  ret->splt = NULL;
-  ret->sstubs = NULL;
-  ret->sgot = NULL;
-  ret->got_info = NULL;
-  ret->plt_header_size = 0;
-  ret->plt_entry_size = 0;
-  ret->lazy_stub_count = 0;
-  ret->function_stub_size = 0;
-  ret->strampoline = NULL;
-  ret->la25_stubs = NULL;
-  ret->add_stub_section = NULL;
+  ret->root.init_plt_refcount.plist = NULL;
+  ret->root.init_plt_offset.plist = NULL;
 
   return &ret->root.root;
 }
@@ -12846,6 +13542,15 @@
 {
   mips_elf_hash_table (info)->use_plts_and_copy_relocs = TRUE;
 }
+
+/* A function that the linker calls to select between all or only
+   32-bit microMIPS instructions.  */
+
+void
+_bfd_mips_elf_insn32 (struct bfd_link_info *info, bfd_boolean on)
+{
+  mips_elf_hash_table (info)->insn32 = on;
+}
 
 /* We need to use a special link routine to handle the .reginfo and
    the .mdebug sections.  We need to merge all instances of these
@@ -13171,15 +13876,15 @@
 	  if (SGI_COMPAT (abfd) && info->shared)
 	    {
 	      /* Create .rtproc section.  */
-	      rtproc_sec = bfd_get_section_by_name (abfd, ".rtproc");
+	      rtproc_sec = bfd_get_linker_section (abfd, ".rtproc");
 	      if (rtproc_sec == NULL)
 		{
 		  flagword flags = (SEC_HAS_CONTENTS | SEC_IN_MEMORY
 				    | SEC_LINKER_CREATED | SEC_READONLY);
 
-		  rtproc_sec = bfd_make_section_with_flags (abfd,
-							    ".rtproc",
-							    flags);
+		  rtproc_sec = bfd_make_section_anyway_with_flags (abfd,
+								   ".rtproc",
+								   flags);
 		  if (rtproc_sec == NULL
 		      || ! bfd_set_section_alignment (abfd, rtproc_sec, 4))
 		    return FALSE;
@@ -13482,7 +14187,8 @@
 
 /* Structure for saying that BFD machine EXTENSION extends BASE.  */
 
-struct mips_mach_extension {
+struct mips_mach_extension
+{
   unsigned long extension, base;
 };
 
@@ -13490,8 +14196,11 @@
 /* An array describing how BFD machines relate to one another.  The entries
    are ordered topologically with MIPS I extensions listed last.  */
 
-static const struct mips_mach_extension mips_mach_extensions[] = {
+static const struct mips_mach_extension mips_mach_extensions[] =
+{
   /* MIPS64r2 extensions.  */
+  { bfd_mach_mips_octeon2, bfd_mach_mips_octeonp },
+  { bfd_mach_mips_octeonp, bfd_mach_mips_octeon },
   { bfd_mach_mips_octeon, bfd_mach_mipsisa64r2 },
 
   /* MIPS64 extensions.  */
@@ -13537,6 +14246,7 @@
   { bfd_mach_mips4300, bfd_mach_mips4000 },
   { bfd_mach_mips4100, bfd_mach_mips4000 },
   { bfd_mach_mips4010, bfd_mach_mips4000 },
+  { bfd_mach_mips5900, bfd_mach_mips4000 },
 
   /* MIPS32 extensions.  */
   { bfd_mach_mipsisa32r2, bfd_mach_mipsisa32 },
@@ -13603,6 +14313,12 @@
 {
   obj_attribute *in_attr;
   obj_attribute *out_attr;
+  bfd *abi_fp_bfd;
+
+  abi_fp_bfd = mips_elf_tdata (obfd)->abi_fp_bfd;
+  in_attr = elf_known_obj_attributes (ibfd)[OBJ_ATTR_GNU];
+  if (!abi_fp_bfd && in_attr[Tag_GNU_MIPS_ABI_FP].i != Val_GNU_MIPS_ABI_FP_ANY)
+    mips_elf_tdata (obfd)->abi_fp_bfd = ibfd;
 
   if (!elf_known_obj_attributes_proc (obfd)[0].i)
     {
@@ -13618,122 +14334,178 @@
 
   /* Check for conflicting Tag_GNU_MIPS_ABI_FP attributes and merge
      non-conflicting ones.  */
-  in_attr = elf_known_obj_attributes (ibfd)[OBJ_ATTR_GNU];
   out_attr = elf_known_obj_attributes (obfd)[OBJ_ATTR_GNU];
   if (in_attr[Tag_GNU_MIPS_ABI_FP].i != out_attr[Tag_GNU_MIPS_ABI_FP].i)
     {
       out_attr[Tag_GNU_MIPS_ABI_FP].type = 1;
-      if (out_attr[Tag_GNU_MIPS_ABI_FP].i == 0)
+      if (out_attr[Tag_GNU_MIPS_ABI_FP].i == Val_GNU_MIPS_ABI_FP_ANY)
 	out_attr[Tag_GNU_MIPS_ABI_FP].i = in_attr[Tag_GNU_MIPS_ABI_FP].i;
-      else if (in_attr[Tag_GNU_MIPS_ABI_FP].i == 0)
-	;
-      else if (in_attr[Tag_GNU_MIPS_ABI_FP].i > 4)
-	_bfd_error_handler
-	  (_("Warning: %B uses unknown floating point ABI %d"), ibfd,
-	   in_attr[Tag_GNU_MIPS_ABI_FP].i);
-      else if (out_attr[Tag_GNU_MIPS_ABI_FP].i > 4)
-	_bfd_error_handler
-	  (_("Warning: %B uses unknown floating point ABI %d"), obfd,
-	   out_attr[Tag_GNU_MIPS_ABI_FP].i);
-      else
+      else if (in_attr[Tag_GNU_MIPS_ABI_FP].i != Val_GNU_MIPS_ABI_FP_ANY)
 	switch (out_attr[Tag_GNU_MIPS_ABI_FP].i)
 	  {
-	  case 1:
+	  case Val_GNU_MIPS_ABI_FP_DOUBLE:
 	    switch (in_attr[Tag_GNU_MIPS_ABI_FP].i)
 	      {
-	      case 2:
+	      case Val_GNU_MIPS_ABI_FP_SINGLE:
 		_bfd_error_handler
-		  (_("Warning: %B uses -msingle-float, %B uses -mdouble-float"),
-		   obfd, ibfd);
+		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
+		   obfd, abi_fp_bfd, ibfd, "-mdouble-float", "-msingle-float");
 		break;
 
-	      case 3:
+	      case Val_GNU_MIPS_ABI_FP_SOFT:
 		_bfd_error_handler
-		  (_("Warning: %B uses hard float, %B uses soft float"),
-		   obfd, ibfd);
+		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
+		   obfd, abi_fp_bfd, ibfd, "-mhard-float", "-msoft-float");
 		break;
 
-	      case 4:
+	      case Val_GNU_MIPS_ABI_FP_64:
 		_bfd_error_handler
-		  (_("Warning: %B uses -msingle-float, %B uses -mips32r2 -mfp64"),
-		   obfd, ibfd);
+		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
+		   obfd, abi_fp_bfd, ibfd,
+		   "-mdouble-float", "-mips32r2 -mfp64");
 		break;
 
 	      default:
-		abort ();
+		_bfd_error_handler
+		  (_("Warning: %B uses %s (set by %B), "
+		     "%B uses unknown floating point ABI %d"),
+		   obfd, abi_fp_bfd, ibfd,
+		   "-mdouble-float", in_attr[Tag_GNU_MIPS_ABI_FP].i);
+		break;
 	      }
 	    break;
 
-	  case 2:
+	  case Val_GNU_MIPS_ABI_FP_SINGLE:
 	    switch (in_attr[Tag_GNU_MIPS_ABI_FP].i)
 	      {
-	      case 1:
+	      case Val_GNU_MIPS_ABI_FP_DOUBLE:
 		_bfd_error_handler
-		  (_("Warning: %B uses -msingle-float, %B uses -mdouble-float"),
-		   ibfd, obfd);
+		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
+		   obfd, abi_fp_bfd, ibfd, "-msingle-float", "-mdouble-float");
 		break;
 
-	      case 3:
+	      case Val_GNU_MIPS_ABI_FP_SOFT:
 		_bfd_error_handler
-		  (_("Warning: %B uses hard float, %B uses soft float"),
-		   obfd, ibfd);
+		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
+		   obfd, abi_fp_bfd, ibfd, "-mhard-float", "-msoft-float");
 		break;
 
-	      case 4:
+	      case Val_GNU_MIPS_ABI_FP_64:
 		_bfd_error_handler
-		  (_("Warning: %B uses -mdouble-float, %B uses -mips32r2 -mfp64"),
-		   obfd, ibfd);
+		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
+		   obfd, abi_fp_bfd, ibfd,
+		   "-msingle-float", "-mips32r2 -mfp64");
 		break;
 
 	      default:
-		abort ();
+		_bfd_error_handler
+		  (_("Warning: %B uses %s (set by %B), "
+		     "%B uses unknown floating point ABI %d"),
+		   obfd, abi_fp_bfd, ibfd,
+		   "-msingle-float", in_attr[Tag_GNU_MIPS_ABI_FP].i);
+		break;
 	      }
 	    break;
 
-	  case 3:
+	  case Val_GNU_MIPS_ABI_FP_SOFT:
 	    switch (in_attr[Tag_GNU_MIPS_ABI_FP].i)
 	      {
-	      case 1:
-	      case 2:
-	      case 4:
+	      case Val_GNU_MIPS_ABI_FP_DOUBLE:
+	      case Val_GNU_MIPS_ABI_FP_SINGLE:
+	      case Val_GNU_MIPS_ABI_FP_64:
 		_bfd_error_handler
-		  (_("Warning: %B uses hard float, %B uses soft float"),
-		   ibfd, obfd);
+		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
+		   obfd, abi_fp_bfd, ibfd, "-msoft-float", "-mhard-float");
 		break;
 
 	      default:
-		abort ();
+		_bfd_error_handler
+		  (_("Warning: %B uses %s (set by %B), "
+		     "%B uses unknown floating point ABI %d"),
+		   obfd, abi_fp_bfd, ibfd,
+		   "-msoft-float", in_attr[Tag_GNU_MIPS_ABI_FP].i);
+		break;
 	      }
 	    break;
 
-	  case 4:
+	  case Val_GNU_MIPS_ABI_FP_64:
 	    switch (in_attr[Tag_GNU_MIPS_ABI_FP].i)
 	      {
-	      case 1:
+	      case Val_GNU_MIPS_ABI_FP_DOUBLE:
 		_bfd_error_handler
-		  (_("Warning: %B uses -msingle-float, %B uses -mips32r2 -mfp64"),
-		   ibfd, obfd);
+		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
+		   obfd, abi_fp_bfd, ibfd,
+		   "-mips32r2 -mfp64", "-mdouble-float");
 		break;
 
-	      case 2:
+	      case Val_GNU_MIPS_ABI_FP_SINGLE:
 		_bfd_error_handler
-		  (_("Warning: %B uses -mdouble-float, %B uses -mips32r2 -mfp64"),
-		   ibfd, obfd);
+		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
+		   obfd, abi_fp_bfd, ibfd,
+		   "-mips32r2 -mfp64", "-msingle-float");
 		break;
 
-	      case 3:
+	      case Val_GNU_MIPS_ABI_FP_SOFT:
 		_bfd_error_handler
-		  (_("Warning: %B uses hard float, %B uses soft float"),
-		   obfd, ibfd);
+		  (_("Warning: %B uses %s (set by %B), %B uses %s"),
+		   obfd, abi_fp_bfd, ibfd, "-mhard-float", "-msoft-float");
 		break;
 
 	      default:
-		abort ();
+		_bfd_error_handler
+		  (_("Warning: %B uses %s (set by %B), "
+		     "%B uses unknown floating point ABI %d"),
+		   obfd, abi_fp_bfd, ibfd,
+		   "-mips32r2 -mfp64", in_attr[Tag_GNU_MIPS_ABI_FP].i);
+		break;
 	      }
 	    break;
 
 	  default:
-	    abort ();
+	    switch (in_attr[Tag_GNU_MIPS_ABI_FP].i)
+	      {
+	      case Val_GNU_MIPS_ABI_FP_DOUBLE:
+		_bfd_error_handler
+		  (_("Warning: %B uses unknown floating point ABI %d "
+		     "(set by %B), %B uses %s"),
+		   obfd, abi_fp_bfd, ibfd,
+		   out_attr[Tag_GNU_MIPS_ABI_FP].i, "-mdouble-float");
+		break;
+
+	      case Val_GNU_MIPS_ABI_FP_SINGLE:
+		_bfd_error_handler
+		  (_("Warning: %B uses unknown floating point ABI %d "
+		     "(set by %B), %B uses %s"),
+		   obfd, abi_fp_bfd, ibfd,
+		   out_attr[Tag_GNU_MIPS_ABI_FP].i, "-msingle-float");
+		break;
+
+	      case Val_GNU_MIPS_ABI_FP_SOFT:
+		_bfd_error_handler
+		  (_("Warning: %B uses unknown floating point ABI %d "
+		     "(set by %B), %B uses %s"),
+		   obfd, abi_fp_bfd, ibfd,
+		   out_attr[Tag_GNU_MIPS_ABI_FP].i, "-msoft-float");
+		break;
+
+	      case Val_GNU_MIPS_ABI_FP_64:
+		_bfd_error_handler
+		  (_("Warning: %B uses unknown floating point ABI %d "
+		     "(set by %B), %B uses %s"),
+		   obfd, abi_fp_bfd, ibfd,
+		   out_attr[Tag_GNU_MIPS_ABI_FP].i, "-mips32r2 -mfp64");
+		break;
+
+	      default:
+		_bfd_error_handler
+		  (_("Warning: %B uses unknown floating point ABI %d "
+		     "(set by %B), %B uses unknown floating point ABI %d"),
+		   obfd, abi_fp_bfd, ibfd,
+		   out_attr[Tag_GNU_MIPS_ABI_FP].i,
+		   in_attr[Tag_GNU_MIPS_ABI_FP].i);
+		break;
+	      }
+	    break;
 	  }
     }
 
@@ -13791,7 +14563,7 @@
 
       if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
 	  && (bfd_get_arch_info (obfd)->the_default
-	      || mips_mach_extends_p (bfd_get_mach (obfd), 
+	      || mips_mach_extends_p (bfd_get_mach (obfd),
 				      bfd_get_mach (ibfd))))
 	{
 	  if (! bfd_set_arch_mach (obfd, bfd_get_arch (ibfd),
@@ -13959,6 +14731,20 @@
       old_flags &= ~ EF_MIPS_ARCH_ASE;
     }
 
+  /* Compare NaN encodings.  */
+  if ((new_flags & EF_MIPS_NAN2008) != (old_flags & EF_MIPS_NAN2008))
+    {
+      _bfd_error_handler (_("%B: linking %s module with previous %s modules"),
+			  ibfd,
+			  (new_flags & EF_MIPS_NAN2008
+			   ? "-mnan=2008" : "-mnan=legacy"),
+			  (old_flags & EF_MIPS_NAN2008
+			   ? "-mnan=2008" : "-mnan=legacy"));
+      ok = FALSE;
+      new_flags &= ~EF_MIPS_NAN2008;
+      old_flags &= ~EF_MIPS_NAN2008;
+    }
+
   /* Warn about any other mismatches */
   if (new_flags != old_flags)
     {
@@ -14150,6 +14936,12 @@
   if (elf_elfheader (abfd)->e_flags & EF_MIPS_ARCH_ASE_MICROMIPS)
     fprintf (file, " [micromips]");
 
+  if (elf_elfheader (abfd)->e_flags & EF_MIPS_NAN2008)
+    fprintf (file, " [nan2008]");
+
+  if (elf_elfheader (abfd)->e_flags & EF_MIPS_FP64)
+    fprintf (file, " [fp64]");
+
   if (elf_elfheader (abfd)->e_flags & EF_MIPS_32BITMODE)
     fprintf (file, " [32bitmode]");
   else
@@ -14237,6 +15029,246 @@
 	  + i * 4 * ARRAY_SIZE (mips_exec_plt_entry));
 }
 
+/* Build a table of synthetic symbols to represent the PLT.  As with MIPS16
+   and microMIPS PLT slots we may have a many-to-one mapping between .plt
+   and .got.plt and also the slots may be of a different size each we walk
+   the PLT manually fetching instructions and matching them against known
+   patterns.  To make things easier standard MIPS slots, if any, always come
+   first.  As we don't create proper ELF symbols we use the UDATA.I member
+   of ASYMBOL to carry ISA annotation.  The encoding used is the same as
+   with the ST_OTHER member of the ELF symbol.  */
+
+long
+_bfd_mips_elf_get_synthetic_symtab (bfd *abfd,
+				    long symcount ATTRIBUTE_UNUSED,
+				    asymbol **syms ATTRIBUTE_UNUSED,
+				    long dynsymcount, asymbol **dynsyms,
+				    asymbol **ret)
+{
+  static const char pltname[] = "_PROCEDURE_LINKAGE_TABLE_";
+  static const char microsuffix[] = "@micromipsplt";
+  static const char m16suffix[] = "@mips16plt";
+  static const char mipssuffix[] = "@plt";
+
+  bfd_boolean (*slurp_relocs) (bfd *, asection *, asymbol **, bfd_boolean);
+  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+  bfd_boolean micromips_p = MICROMIPS_P (abfd);
+  Elf_Internal_Shdr *hdr;
+  bfd_byte *plt_data;
+  bfd_vma plt_offset;
+  unsigned int other;
+  bfd_vma entry_size;
+  bfd_vma plt0_size;
+  asection *relplt;
+  bfd_vma opcode;
+  asection *plt;
+  asymbol *send;
+  size_t size;
+  char *names;
+  long counti;
+  arelent *p;
+  asymbol *s;
+  char *nend;
+  long count;
+  long pi;
+  long i;
+  long n;
+
+  *ret = NULL;
+
+  if ((abfd->flags & (DYNAMIC | EXEC_P)) == 0 || dynsymcount <= 0)
+    return 0;
+
+  relplt = bfd_get_section_by_name (abfd, ".rel.plt");
+  if (relplt == NULL)
+    return 0;
+
+  hdr = &elf_section_data (relplt)->this_hdr;
+  if (hdr->sh_link != elf_dynsymtab (abfd) || hdr->sh_type != SHT_REL)
+    return 0;
+
+  plt = bfd_get_section_by_name (abfd, ".plt");
+  if (plt == NULL)
+    return 0;
+
+  slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table;
+  if (!(*slurp_relocs) (abfd, relplt, dynsyms, TRUE))
+    return -1;
+  p = relplt->relocation;
+
+  /* Calculating the exact amount of space required for symbols would
+     require two passes over the PLT, so just pessimise assuming two
+     PLT slots per relocation.  */
+  count = relplt->size / hdr->sh_entsize;
+  counti = count * bed->s->int_rels_per_ext_rel;
+  size = 2 * count * sizeof (asymbol);
+  size += count * (sizeof (mipssuffix) +
+		   (micromips_p ? sizeof (microsuffix) : sizeof (m16suffix)));
+  for (pi = 0; pi < counti; pi += bed->s->int_rels_per_ext_rel)
+    size += 2 * strlen ((*p[pi].sym_ptr_ptr)->name);
+
+  /* Add the size of "_PROCEDURE_LINKAGE_TABLE_" too.  */
+  size += sizeof (asymbol) + sizeof (pltname);
+
+  if (!bfd_malloc_and_get_section (abfd, plt, &plt_data))
+    return -1;
+
+  if (plt->size < 16)
+    return -1;
+
+  s = *ret = bfd_malloc (size);
+  if (s == NULL)
+    return -1;
+  send = s + 2 * count + 1;
+
+  names = (char *) send;
+  nend = (char *) s + size;
+  n = 0;
+
+  opcode = bfd_get_micromips_32 (abfd, plt_data + 12);
+  if (opcode == 0x3302fffe)
+    {
+      if (!micromips_p)
+	return -1;
+      plt0_size = 2 * ARRAY_SIZE (micromips_o32_exec_plt0_entry);
+      other = STO_MICROMIPS;
+    }
+  else if (opcode == 0x0398c1d0)
+    {
+      if (!micromips_p)
+	return -1;
+      plt0_size = 2 * ARRAY_SIZE (micromips_insn32_o32_exec_plt0_entry);
+      other = STO_MICROMIPS;
+    }
+  else
+    {
+      plt0_size = 4 * ARRAY_SIZE (mips_o32_exec_plt0_entry);
+      other = 0;
+    }
+
+  s->the_bfd = abfd;
+  s->flags = BSF_SYNTHETIC | BSF_FUNCTION | BSF_LOCAL;
+  s->section = plt;
+  s->value = 0;
+  s->name = names;
+  s->udata.i = other;
+  memcpy (names, pltname, sizeof (pltname));
+  names += sizeof (pltname);
+  ++s, ++n;
+
+  pi = 0;
+  for (plt_offset = plt0_size;
+       plt_offset + 8 <= plt->size && s < send;
+       plt_offset += entry_size)
+    {
+      bfd_vma gotplt_addr;
+      const char *suffix;
+      bfd_vma gotplt_hi;
+      bfd_vma gotplt_lo;
+      size_t suffixlen;
+
+      opcode = bfd_get_micromips_32 (abfd, plt_data + plt_offset + 4);
+
+      /* Check if the second word matches the expected MIPS16 instruction.  */
+      if (opcode == 0x651aeb00)
+	{
+	  if (micromips_p)
+	    return -1;
+	  /* Truncated table???  */
+	  if (plt_offset + 16 > plt->size)
+	    break;
+	  gotplt_addr = bfd_get_32 (abfd, plt_data + plt_offset + 12);
+	  entry_size = 2 * ARRAY_SIZE (mips16_o32_exec_plt_entry);
+	  suffixlen = sizeof (m16suffix);
+	  suffix = m16suffix;
+	  other = STO_MIPS16;
+	}
+      /* Likewise the expected microMIPS instruction (no insn32 mode).  */
+      else if (opcode == 0xff220000)
+	{
+	  if (!micromips_p)
+	    return -1;
+	  gotplt_hi = bfd_get_16 (abfd, plt_data + plt_offset) & 0x7f;
+	  gotplt_lo = bfd_get_16 (abfd, plt_data + plt_offset + 2) & 0xffff;
+	  gotplt_hi = ((gotplt_hi ^ 0x40) - 0x40) << 18;
+	  gotplt_lo <<= 2;
+	  gotplt_addr = gotplt_hi + gotplt_lo;
+	  gotplt_addr += ((plt->vma + plt_offset) | 3) ^ 3;
+	  entry_size = 2 * ARRAY_SIZE (micromips_o32_exec_plt_entry);
+	  suffixlen = sizeof (microsuffix);
+	  suffix = microsuffix;
+	  other = STO_MICROMIPS;
+	}
+      /* Likewise the expected microMIPS instruction (insn32 mode).  */
+      else if ((opcode & 0xffff0000) == 0xff2f0000)
+	{
+	  gotplt_hi = bfd_get_16 (abfd, plt_data + plt_offset + 2) & 0xffff;
+	  gotplt_lo = bfd_get_16 (abfd, plt_data + plt_offset + 6) & 0xffff;
+	  gotplt_hi = ((gotplt_hi ^ 0x8000) - 0x8000) << 16;
+	  gotplt_lo = (gotplt_lo ^ 0x8000) - 0x8000;
+	  gotplt_addr = gotplt_hi + gotplt_lo;
+	  entry_size = 2 * ARRAY_SIZE (micromips_insn32_o32_exec_plt_entry);
+	  suffixlen = sizeof (microsuffix);
+	  suffix = microsuffix;
+	  other = STO_MICROMIPS;
+	}
+      /* Otherwise assume standard MIPS code.  */
+      else
+	{
+	  gotplt_hi = bfd_get_32 (abfd, plt_data + plt_offset) & 0xffff;
+	  gotplt_lo = bfd_get_32 (abfd, plt_data + plt_offset + 4) & 0xffff;
+	  gotplt_hi = ((gotplt_hi ^ 0x8000) - 0x8000) << 16;
+	  gotplt_lo = (gotplt_lo ^ 0x8000) - 0x8000;
+	  gotplt_addr = gotplt_hi + gotplt_lo;
+	  entry_size = 4 * ARRAY_SIZE (mips_exec_plt_entry);
+	  suffixlen = sizeof (mipssuffix);
+	  suffix = mipssuffix;
+	  other = 0;
+	}
+      /* Truncated table???  */
+      if (plt_offset + entry_size > plt->size)
+	break;
+
+      for (i = 0;
+	   i < count && p[pi].address != gotplt_addr;
+	   i++, pi = (pi + bed->s->int_rels_per_ext_rel) % counti);
+
+      if (i < count)
+	{
+	  size_t namelen;
+	  size_t len;
+
+	  *s = **p[pi].sym_ptr_ptr;
+	  /* Undefined syms won't have BSF_LOCAL or BSF_GLOBAL set.  Since
+	     we are defining a symbol, ensure one of them is set.  */
+	  if ((s->flags & BSF_LOCAL) == 0)
+	    s->flags |= BSF_GLOBAL;
+	  s->flags |= BSF_SYNTHETIC;
+	  s->section = plt;
+	  s->value = plt_offset;
+	  s->name = names;
+	  s->udata.i = other;
+
+	  len = strlen ((*p[pi].sym_ptr_ptr)->name);
+	  namelen = len + suffixlen;
+	  if (names + namelen > nend)
+	    break;
+
+	  memcpy (names, (*p[pi].sym_ptr_ptr)->name, len);
+	  names += len;
+	  memcpy (names, suffix, suffixlen);
+	  names += suffixlen;
+
+	  ++s, ++n;
+	  pi = (pi + bed->s->int_rels_per_ext_rel) % counti;
+	}
+    }
+
+  free (plt_data);
+
+  return n;
+}
+
 void
 _bfd_mips_post_process_headers (bfd *abfd, struct bfd_link_info *link_info)
 {
diff --git a/bfd/elfxx-mips.h b/bfd/elfxx-mips.h
index 8cb7e3b..f27dc15 100644
--- a/bfd/elfxx-mips.h
+++ b/bfd/elfxx-mips.h
@@ -23,6 +23,8 @@
 #include "elf/internal.h"
 #include "elf/mips.h"
 
+extern bfd_boolean _bfd_mips_elf_mkobject
+  (bfd *);
 extern bfd_boolean _bfd_mips_elf_new_section_hook
   (bfd *, asection *);
 extern void _bfd_mips_elf_symbol_processing
@@ -145,11 +147,15 @@
   (struct elf_link_hash_entry *);
 extern void _bfd_mips_elf_use_plts_and_copy_relocs
   (struct bfd_link_info *);
+extern void _bfd_mips_elf_insn32
+  (struct bfd_link_info *, bfd_boolean);
 extern bfd_boolean _bfd_mips_elf_init_stubs
   (struct bfd_link_info *,
    asection *(*) (const char *, asection *, asection *));
 extern bfd_vma _bfd_mips_elf_plt_sym_val
   (bfd_vma, const asection *, const arelent *rel);
+extern long _bfd_mips_elf_get_synthetic_symtab
+  (bfd *, long, asymbol **, long, asymbol **, asymbol **);
 extern void _bfd_mips_post_process_headers
   (bfd *abfd, struct bfd_link_info *link_info);
 
diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c
index 9a15124..94da360 100644
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -1,5 +1,5 @@
 /* SPARC-specific support for ELF
-   Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -53,7 +53,7 @@
 
 static bfd_reloc_status_type
 init_insn_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
-		 PTR data, asection *input_section, bfd *output_bfd,
+		 void * data, asection *input_section, bfd *output_bfd,
 		 bfd_vma *prelocation, bfd_vma *pinsn)
 {
   bfd_vma relocation;
@@ -97,7 +97,7 @@
 sparc_elf_notsup_reloc (bfd *abfd ATTRIBUTE_UNUSED,
 			arelent *reloc_entry ATTRIBUTE_UNUSED,
 			asymbol *symbol ATTRIBUTE_UNUSED,
-			PTR data ATTRIBUTE_UNUSED,
+			void * data ATTRIBUTE_UNUSED,
 			asection *input_section ATTRIBUTE_UNUSED,
 			bfd *output_bfd ATTRIBUTE_UNUSED,
 			char **error_message ATTRIBUTE_UNUSED)
@@ -109,7 +109,7 @@
 
 static bfd_reloc_status_type
 sparc_elf_wdisp16_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
-			 PTR data, asection *input_section, bfd *output_bfd,
+			 void * data, asection *input_section, bfd *output_bfd,
 			 char **error_message ATTRIBUTE_UNUSED)
 {
   bfd_vma relocation;
@@ -132,11 +132,39 @@
     return bfd_reloc_ok;
 }
 
+/* Handle the WDISP10 reloc.  */
+
+static bfd_reloc_status_type
+sparc_elf_wdisp10_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
+			 void * data, asection *input_section, bfd *output_bfd,
+			 char **error_message ATTRIBUTE_UNUSED)
+{
+  bfd_vma relocation;
+  bfd_vma insn;
+  bfd_reloc_status_type status;
+
+  status = init_insn_reloc (abfd, reloc_entry, symbol, data,
+			    input_section, output_bfd, &relocation, &insn);
+  if (status != bfd_reloc_other)
+    return status;
+
+  insn &= ~ (bfd_vma) 0x181fe0;
+  insn |= (((relocation >> 2) & 0x300) << 11)
+	  | (((relocation >> 2) & 0xff) << 5);
+  bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
+
+  if ((bfd_signed_vma) relocation < - 0x1000
+      || (bfd_signed_vma) relocation > 0xfff)
+    return bfd_reloc_overflow;
+  else
+    return bfd_reloc_ok;
+}
+
 /* Handle the HIX22 reloc.  */
 
 static bfd_reloc_status_type
 sparc_elf_hix22_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
-		       PTR data, asection *input_section, bfd *output_bfd,
+		       void * data, asection *input_section, bfd *output_bfd,
 		       char **error_message ATTRIBUTE_UNUSED)
 {
   bfd_vma relocation;
@@ -162,7 +190,7 @@
 
 static bfd_reloc_status_type
 sparc_elf_lox10_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
-		       PTR data, asection *input_section, bfd *output_bfd,
+		       void * data, asection *input_section, bfd *output_bfd,
 		       char **error_message ATTRIBUTE_UNUSED)
 {
   bfd_vma relocation;
@@ -267,6 +295,10 @@
   HOWTO(R_SPARC_GOTDATA_OP_HIX22,0,2,0,FALSE,0,complain_overflow_bitfield,sparc_elf_hix22_reloc,"R_SPARC_GOTDATA_OP_HIX22",FALSE,0,0x003fffff, FALSE),
   HOWTO(R_SPARC_GOTDATA_OP_LOX10,0,2,0,FALSE,0,complain_overflow_dont,  sparc_elf_lox10_reloc,  "R_SPARC_GOTDATA_OP_LOX10",FALSE,0,0x000003ff, FALSE),
   HOWTO(R_SPARC_GOTDATA_OP,0,0, 0,FALSE,0,complain_overflow_dont,   bfd_elf_generic_reloc,  "R_SPARC_GOTDATA_OP",FALSE,0,0x00000000,TRUE),
+  HOWTO(R_SPARC_H34,12,2,22,FALSE,0,complain_overflow_unsigned,bfd_elf_generic_reloc,"R_SPARC_H34",FALSE,0,0x003fffff,FALSE),
+  HOWTO(R_SPARC_SIZE32,0,2,32,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,"R_SPARC_SIZE32",FALSE,0,0xffffffff,TRUE),
+  HOWTO(R_SPARC_SIZE64,0,4,64,FALSE,0,complain_overflow_bitfield,bfd_elf_generic_reloc,"R_SPARC_SIZE64",FALSE,0,MINUS_ONE, TRUE),
+  HOWTO(R_SPARC_WDISP10,2,2,10,TRUE, 0,complain_overflow_signed,sparc_elf_wdisp10_reloc,"R_SPARC_WDISP10",FALSE,0,0x00000000,TRUE),
 };
 static reloc_howto_type sparc_jmp_irel_howto =
   HOWTO(R_SPARC_JMP_IREL,  0,0,00,FALSE,0,complain_overflow_dont,    bfd_elf_generic_reloc,  "R_SPARC_JMP_IREL",FALSE,0,0x00000000,TRUE);
@@ -524,6 +556,18 @@
     case BFD_RELOC_SPARC_GOTDATA_OP:
       return &_bfd_sparc_elf_howto_table[R_SPARC_GOTDATA_OP];
 
+    case BFD_RELOC_SPARC_H34:
+      return &_bfd_sparc_elf_howto_table[R_SPARC_H34];
+
+    case BFD_RELOC_SPARC_SIZE32:
+      return &_bfd_sparc_elf_howto_table[R_SPARC_SIZE32];
+
+    case BFD_RELOC_SPARC_SIZE64:
+      return &_bfd_sparc_elf_howto_table[R_SPARC_SIZE64];
+
+    case BFD_RELOC_SPARC_WDISP10:
+      return &_bfd_sparc_elf_howto_table[R_SPARC_WDISP10];
+
     case BFD_RELOC_SPARC_JMP_IREL:
       return &sparc_jmp_irel_howto;
 
@@ -1163,9 +1207,9 @@
   if (!_bfd_elf_create_dynamic_sections (dynobj, info))
     return FALSE;
 
-  htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
+  htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
   if (!info->shared)
-    htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
+    htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
 
   if (htab->is_vxworks)
     {
@@ -1389,7 +1433,7 @@
 						TRUE);
 	      if (h == NULL)
 		return FALSE;
-	      
+
 	      /* Fake a STT_GNU_IFUNC symbol.  */
 	      h->type = STT_GNU_IFUNC;
 	      h->def_regular = 1;
@@ -1406,6 +1450,10 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
       if (h && h->type == STT_GNU_IFUNC)
@@ -1656,6 +1704,7 @@
 	case R_SPARC_WDISP22:
 	case R_SPARC_WDISP19:
 	case R_SPARC_WDISP16:
+	case R_SPARC_WDISP10:
 	case R_SPARC_8:
 	case R_SPARC_16:
 	case R_SPARC_32:
@@ -1680,6 +1729,7 @@
 	case R_SPARC_H44:
 	case R_SPARC_M44:
 	case R_SPARC_L44:
+	case R_SPARC_H34:
 	case R_SPARC_UA64:
 	  if (h != NULL)
 	    h->non_got_ref = 1;
@@ -1827,6 +1877,29 @@
 	return NULL;
       }
 
+  /* FIXME: The test here, in check_relocs and in relocate_section
+     dealing with TLS optimization, ought to be !info->executable.  */
+  if (info->shared)
+    {
+      switch (SPARC_ELF_R_TYPE (rel->r_info))
+	{
+	case R_SPARC_TLS_GD_CALL:
+	case R_SPARC_TLS_LDM_CALL:
+	  /* This reloc implicitly references __tls_get_addr.  We know
+	     another reloc will reference the same symbol as the one
+	     on this reloc, so the real symbol and section will be
+	     gc marked when processing the other reloc.  That lets
+	     us handle __tls_get_addr here.  */
+	  h = elf_link_hash_lookup (elf_hash_table (info), "__tls_get_addr",
+				    FALSE, FALSE, TRUE);
+	  BFD_ASSERT (h != NULL);
+	  h->mark = 1;
+	  if (h->u.weakdef != NULL)
+	    h->u.weakdef->mark = 1;
+	  sym = NULL;
+	}
+    }
+
   return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
 
@@ -1956,6 +2029,7 @@
 	case R_SPARC_WDISP22:
 	case R_SPARC_WDISP19:
 	case R_SPARC_WDISP16:
+	case R_SPARC_WDISP10:
 	case R_SPARC_8:
 	case R_SPARC_16:
 	case R_SPARC_32:
@@ -1981,6 +2055,7 @@
 	case R_SPARC_H44:
 	case R_SPARC_M44:
 	case R_SPARC_L44:
+	case R_SPARC_H34:
 	case R_SPARC_UA64:
 	  if (info->shared)
 	    break;
@@ -2114,13 +2189,6 @@
       return TRUE;
     }
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-			     h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -2135,7 +2203,7 @@
      to copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rel.bss section we are going to use.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       htab->srelbss->size += SPARC_ELF_RELA_BYTES (htab);
       h->needs_copy = 1;
@@ -2150,7 +2218,7 @@
    dynamic relocs.  */
 
 static bfd_boolean
-allocate_dynrelocs (struct elf_link_hash_entry *h, PTR inf)
+allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
 {
   struct bfd_link_info *info;
   struct _bfd_sparc_elf_link_hash_table *htab;
@@ -2430,7 +2498,7 @@
 /* Find any dynamic relocs that apply to read-only sections.  */
 
 static bfd_boolean
-readonly_dynrelocs (struct elf_link_hash_entry *h, PTR inf)
+readonly_dynrelocs (struct elf_link_hash_entry *h, void * inf)
 {
   struct _bfd_sparc_elf_link_hash_entry *eh;
   struct _bfd_sparc_elf_dyn_relocs *p;
@@ -2491,7 +2559,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
 	  s->size = htab->dynamic_interpreter_size;
 	  s->contents = (unsigned char *) htab->dynamic_interpreter;
@@ -2586,7 +2654,7 @@
 
   /* Allocate global sym .plt and .got entries, and space for global
      sym dynamic relocs.  */
-  elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, (PTR) info);
+  elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, info);
 
   /* Allocate .plt and .got entries, and space for local symbols.  */
   htab_traverse (htab->loc_hash_table, allocate_local_dynrelocs, info);
@@ -2701,8 +2769,7 @@
       /* If any dynamic relocs apply to a read-only section,
 	 then we need a DT_TEXTREL entry.  */
       if ((info->flags & DF_TEXTREL) == 0)
-	elf_link_hash_traverse (&htab->elf, readonly_dynrelocs,
-				(PTR) info);
+	elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, info);
 
       if (info->flags & DF_TEXTREL)
 	{
@@ -2945,7 +3012,7 @@
 	      if (h == NULL)
 		abort ();
 
-	      /* Set STT_GNU_IFUNC symbol value.  */ 
+	      /* Set STT_GNU_IFUNC symbol value.  */
 	      h->root.u.def.value = sym->st_value;
 	      h->root.u.def.section = sec;
 	    }
@@ -2970,9 +3037,9 @@
 	    }
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -3238,7 +3305,7 @@
 	      if (h == NULL)
 		break;
 	    }
-	  /* PR 7027: We need similar behaviour for 64-bit binaries.  */ 
+	  /* PR 7027: We need similar behaviour for 64-bit binaries.  */
 	  else if (r_type == R_SPARC_WPLT30 && h == NULL)
 	    break;
 	  else
@@ -3283,6 +3350,7 @@
 	case R_SPARC_WDISP22:
 	case R_SPARC_WDISP19:
 	case R_SPARC_WDISP16:
+	case R_SPARC_WDISP10:
 	case R_SPARC_8:
 	case R_SPARC_16:
 	case R_SPARC_32:
@@ -3307,6 +3375,7 @@
 	case R_SPARC_H44:
 	case R_SPARC_M44:
 	case R_SPARC_L44:
+	case R_SPARC_H34:
 	case R_SPARC_UA64:
 	r_sparc_plt32:
 	  if ((input_section->flags & SEC_ALLOC) == 0
@@ -3828,7 +3897,9 @@
 	 not process them.  */
       if (unresolved_reloc
 	  && !((input_section->flags & SEC_DEBUGGING) != 0
-	       && h->def_dynamic))
+	       && h->def_dynamic)
+	  && _bfd_elf_section_offset (output_bfd, info, input_section,
+				      rel->r_offset) != (bfd_vma) -1)
 	(*_bfd_error_handler)
 	  (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
 	   input_bfd,
@@ -3876,6 +3947,25 @@
 				  bfd_arch_bits_per_address (input_bfd),
 				  relocation);
 	}
+      else if (r_type == R_SPARC_WDISP10)
+	{
+	  bfd_vma x;
+
+	  relocation += rel->r_addend;
+	  relocation -= (input_section->output_section->vma
+			 + input_section->output_offset);
+	  relocation -= rel->r_offset;
+
+	  x = bfd_get_32 (input_bfd, contents + rel->r_offset);
+	  x |= ((((relocation >> 2) & 0x300) << 11)
+		| (((relocation >> 2) & 0xff) << 5));
+	  bfd_put_32 (input_bfd, x, contents + rel->r_offset);
+
+	  r = bfd_check_overflow (howto->complain_on_overflow,
+				  howto->bitsize, howto->rightshift,
+				  bfd_arch_bits_per_address (input_bfd),
+				  relocation);
+	}
       else if (r_type == R_SPARC_REV32)
 	{
 	  bfd_vma x;
@@ -4063,11 +4153,13 @@
 	      {
 		const char *name;
 
-		/* The Solaris native linker silently disregards overflows. 
+		/* The Solaris native linker silently disregards overflows.
 		   We don't, but this breaks stabs debugging info, whose
 		   relocations are only 32-bits wide.  Ignore overflows in
 		   this case and also for discarded entries.  */
-		if ((r_type == R_SPARC_32 || r_type == R_SPARC_DISP32)
+		if ((r_type == R_SPARC_32
+		     || r_type == R_SPARC_UA32
+		     || r_type == R_SPARC_DISP32)
 		    && (((input_section->flags & SEC_DEBUGGING) != 0
 			 && strcmp (bfd_section_name (input_bfd,
 						      input_section),
@@ -4430,8 +4522,8 @@
       /* This symbols needs a copy reloc.  Set it up.  */
       BFD_ASSERT (h->dynindx != -1);
 
-      s = bfd_get_section_by_name (h->root.u.def.section->owner,
-				   ".rela.bss");
+      s = bfd_get_linker_section (h->root.u.def.section->owner,
+				  ".rela.bss");
       BFD_ASSERT (s != NULL);
 
       rela.r_offset = (h->root.u.def.value
@@ -4446,7 +4538,7 @@
      _GLOBAL_OFFSET_TABLE_ is not absolute: it is relative to the
      ".got" section.  Likewise _PROCEDURE_LINKAGE_TABLE_ and ".plt".  */
   if (sym != NULL
-      && (strcmp (h->root.root.string, "_DYNAMIC") == 0
+      && (h == htab->elf.hdynamic
 	  || (!htab->is_vxworks
 	      && (h == htab->elf.hgot || h == htab->elf.hplt))))
     sym->st_shndx = SHN_ABS;
@@ -4653,7 +4745,7 @@
   struct elf_link_hash_entry *h
     = (struct elf_link_hash_entry *) *slot;
   struct bfd_link_info *info
-    = (struct bfd_link_info *) inf; 
+    = (struct bfd_link_info *) inf;
 
   return _bfd_sparc_elf_finish_dynamic_symbol (info->output_bfd, info,
 					       h, NULL);
@@ -4670,13 +4762,13 @@
   BFD_ASSERT (htab != NULL);
   dynobj = htab->elf.dynobj;
 
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       asection *splt;
 
-      splt = bfd_get_section_by_name (dynobj, ".plt");
+      splt = htab->elf.splt;
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       if (!sparc_finish_dyn (output_bfd, info, dynobj, sdyn, splt))
@@ -4701,9 +4793,10 @@
 	    }
 	}
 
-      elf_section_data (splt->output_section)->this_hdr.sh_entsize
-	= (htab->is_vxworks || !ABI_64_P (output_bfd))
-	  ? 0 : htab->plt_entry_size;
+      if (elf_section_data (splt->output_section) != NULL)
+        elf_section_data (splt->output_section)->this_hdr.sh_entsize
+          = ((htab->is_vxworks || !ABI_64_P (output_bfd))
+             ? 0 : htab->plt_entry_size);
     }
 
   /* Set the first entry in the global offset table to the address of
@@ -4817,6 +4910,7 @@
   out_attr = &out_attrs[Tag_GNU_Sparc_HWCAPS];
 
   out_attr->i |= in_attr->i;
+  out_attr->type = 1;
 
   /* Merge Tag_compatibility attributes and any common GNU ones.  */
   _bfd_elf_merge_object_attributes (ibfd, obfd);
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index 5a6cae0..d42ce26 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -109,6 +109,9 @@
 #ifndef elf_backend_default_execstack
 #define elf_backend_default_execstack 1
 #endif
+#ifndef elf_backend_stack_align
+#define elf_backend_stack_align 16
+#endif
 
 #define bfd_elfNN_bfd_debug_info_start	bfd_void
 #define bfd_elfNN_bfd_debug_info_end	bfd_void
@@ -229,14 +232,13 @@
   _bfd_elf_canonicalize_dynamic_reloc
 #endif
 
-#ifndef bfd_elfNN_bfd_link_hash_table_free
-#define bfd_elfNN_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
-#endif
-
 #ifdef elf_backend_relocate_section
 #ifndef bfd_elfNN_bfd_link_hash_table_create
 #define bfd_elfNN_bfd_link_hash_table_create _bfd_elf_link_hash_table_create
 #endif
+#ifndef bfd_elfNN_bfd_link_hash_table_free
+#define bfd_elfNN_bfd_link_hash_table_free _bfd_elf_link_hash_table_free
+#endif
 #ifndef bfd_elfNN_bfd_link_add_symbols
 #define bfd_elfNN_bfd_link_add_symbols	bfd_elf_link_add_symbols
 #endif
@@ -253,6 +255,9 @@
 #define bfd_elfNN_bfd_link_hash_table_create \
   _bfd_generic_link_hash_table_create
 #endif
+#ifndef bfd_elfNN_bfd_link_hash_table_free
+#define bfd_elfNN_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
+#endif
 #ifndef bfd_elfNN_bfd_link_add_symbols
 #define bfd_elfNN_bfd_link_add_symbols	_bfd_generic_link_add_symbols
 #endif
@@ -419,8 +424,8 @@
 #ifndef elf_backend_check_directives
 #define elf_backend_check_directives	0
 #endif
-#ifndef elf_backend_as_needed_cleanup
-#define elf_backend_as_needed_cleanup	0
+#ifndef elf_backend_notice_as_needed
+#define elf_backend_notice_as_needed	_bfd_elf_notice_as_needed
 #endif
 #ifndef elf_backend_adjust_dynamic_symbol
 #define elf_backend_adjust_dynamic_symbol 0
@@ -700,7 +705,7 @@
   elf_backend_relocs_compatible,
   elf_backend_check_relocs,
   elf_backend_check_directives,
-  elf_backend_as_needed_cleanup,
+  elf_backend_notice_as_needed,
   elf_backend_adjust_dynamic_symbol,
   elf_backend_always_size_sections,
   elf_backend_size_dynamic_sections,
@@ -770,6 +775,7 @@
   elf_backend_obj_attrs_order,
   elf_backend_obj_attrs_handle_unknown,
   elf_backend_static_tls_alignment,
+  elf_backend_stack_align,
   elf_backend_collect,
   elf_backend_type_change_ok,
   elf_backend_may_use_rel_p,
diff --git a/bfd/elfxx-tilegx.c b/bfd/elfxx-tilegx.c
index c484562..c57e38f 100644
--- a/bfd/elfxx-tilegx.c
+++ b/bfd/elfxx-tilegx.c
@@ -1,5 +1,5 @@
 /* TILE-Gx-specific support for ELF.
-   Copyright 2011 Free Software Foundation, Inc.
+   Copyright 2011, 2012, 2013 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -18,8 +18,8 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
 #include "elf/tilegx.h"
@@ -490,35 +490,38 @@
 
   TILEGX_IMM16_HOWTO (R_TILEGX_IMM16_X0_HW0_GOT, 0),
   TILEGX_IMM16_HOWTO (R_TILEGX_IMM16_X1_HW0_GOT, 0),
-  TILEGX_IMM16_HOWTO (R_TILEGX_IMM16_X0_HW1_GOT, 16),
-  TILEGX_IMM16_HOWTO (R_TILEGX_IMM16_X1_HW1_GOT, 16),
-  TILEGX_IMM16_HOWTO (R_TILEGX_IMM16_X0_HW2_GOT, 32),
-  TILEGX_IMM16_HOWTO (R_TILEGX_IMM16_X1_HW2_GOT, 32),
-  TILEGX_IMM16_HOWTO (R_TILEGX_IMM16_X0_HW3_GOT, 48),
-  TILEGX_IMM16_HOWTO (R_TILEGX_IMM16_X1_HW3_GOT, 48),
+
+  TILEGX_IMM16_HOWTO_PCREL (R_TILEGX_IMM16_X0_HW0_PLT_PCREL, 0),
+  TILEGX_IMM16_HOWTO_PCREL (R_TILEGX_IMM16_X1_HW0_PLT_PCREL, 0),
+  TILEGX_IMM16_HOWTO_PCREL (R_TILEGX_IMM16_X0_HW1_PLT_PCREL, 16),
+  TILEGX_IMM16_HOWTO_PCREL (R_TILEGX_IMM16_X1_HW1_PLT_PCREL, 16),
+  TILEGX_IMM16_HOWTO_PCREL (R_TILEGX_IMM16_X0_HW2_PLT_PCREL, 32),
+  TILEGX_IMM16_HOWTO_PCREL (R_TILEGX_IMM16_X1_HW2_PLT_PCREL, 32),
 
   TILEGX_IMM16_HOWTO_LAST (R_TILEGX_IMM16_X0_HW0_LAST_GOT, 0),
   TILEGX_IMM16_HOWTO_LAST (R_TILEGX_IMM16_X1_HW0_LAST_GOT, 0),
   TILEGX_IMM16_HOWTO_LAST (R_TILEGX_IMM16_X0_HW1_LAST_GOT, 16),
   TILEGX_IMM16_HOWTO_LAST (R_TILEGX_IMM16_X1_HW1_LAST_GOT, 16),
-  TILEGX_IMM16_HOWTO_LAST (R_TILEGX_IMM16_X0_HW2_LAST_GOT, 32),
-  TILEGX_IMM16_HOWTO_LAST (R_TILEGX_IMM16_X1_HW2_LAST_GOT, 32),
+
+  TILEGX_IMM16_HOWTO_PCREL (R_TILEGX_IMM16_X0_HW3_PLT_PCREL, 48),
+  TILEGX_IMM16_HOWTO_PCREL (R_TILEGX_IMM16_X1_HW3_PLT_PCREL, 48),
 
   TILEGX_IMM16_HOWTO (R_TILEGX_IMM16_X0_HW0_TLS_GD, 0),
   TILEGX_IMM16_HOWTO (R_TILEGX_IMM16_X1_HW0_TLS_GD, 0),
-  TILEGX_IMM16_HOWTO (R_TILEGX_IMM16_X0_HW1_TLS_GD, 16),
-  TILEGX_IMM16_HOWTO (R_TILEGX_IMM16_X1_HW1_TLS_GD, 16),
-  TILEGX_IMM16_HOWTO (R_TILEGX_IMM16_X0_HW2_TLS_GD, 32),
-  TILEGX_IMM16_HOWTO (R_TILEGX_IMM16_X1_HW2_TLS_GD, 32),
-  TILEGX_IMM16_HOWTO (R_TILEGX_IMM16_X0_HW3_TLS_GD, 48),
-  TILEGX_IMM16_HOWTO (R_TILEGX_IMM16_X1_HW3_TLS_GD, 48),
+
+  TILEGX_IMM16_HOWTO (R_TILEGX_IMM16_X0_HW0_TLS_LE, 0),
+  TILEGX_IMM16_HOWTO (R_TILEGX_IMM16_X1_HW0_TLS_LE, 0),
+  TILEGX_IMM16_HOWTO_LAST (R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE, 0),
+  TILEGX_IMM16_HOWTO_LAST (R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE, 0),
+  TILEGX_IMM16_HOWTO_LAST (R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE, 16),
+  TILEGX_IMM16_HOWTO_LAST (R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE, 16),
 
   TILEGX_IMM16_HOWTO_LAST (R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD, 0),
   TILEGX_IMM16_HOWTO_LAST (R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD, 0),
   TILEGX_IMM16_HOWTO_LAST (R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD, 16),
   TILEGX_IMM16_HOWTO_LAST (R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD, 16),
-  TILEGX_IMM16_HOWTO_LAST (R_TILEGX_IMM16_X0_HW2_LAST_TLS_GD, 32),
-  TILEGX_IMM16_HOWTO_LAST (R_TILEGX_IMM16_X1_HW2_LAST_TLS_GD, 32),
+  EMPTY_HOWTO (90),
+  EMPTY_HOWTO (91),
 
 #define TILEGX_IMM16_HOWTO_TLS_IE(name, rshift) \
   HOWTO (name, rshift, 1, 16, FALSE, 0, \
@@ -527,12 +530,13 @@
 
   TILEGX_IMM16_HOWTO_TLS_IE (R_TILEGX_IMM16_X0_HW0_TLS_IE, 0),
   TILEGX_IMM16_HOWTO_TLS_IE (R_TILEGX_IMM16_X1_HW0_TLS_IE, 0),
-  TILEGX_IMM16_HOWTO_TLS_IE (R_TILEGX_IMM16_X0_HW1_TLS_IE, 16),
-  TILEGX_IMM16_HOWTO_TLS_IE (R_TILEGX_IMM16_X1_HW1_TLS_IE, 16),
-  TILEGX_IMM16_HOWTO_TLS_IE (R_TILEGX_IMM16_X0_HW2_TLS_IE, 32),
-  TILEGX_IMM16_HOWTO_TLS_IE (R_TILEGX_IMM16_X1_HW2_TLS_IE, 32),
-  TILEGX_IMM16_HOWTO_TLS_IE (R_TILEGX_IMM16_X0_HW3_TLS_IE, 48),
-  TILEGX_IMM16_HOWTO_TLS_IE (R_TILEGX_IMM16_X1_HW3_TLS_IE, 48),
+
+  TILEGX_IMM16_HOWTO_LAST_PCREL (R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL,  0),
+  TILEGX_IMM16_HOWTO_LAST_PCREL (R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL,  0),
+  TILEGX_IMM16_HOWTO_LAST_PCREL (R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL, 16),
+  TILEGX_IMM16_HOWTO_LAST_PCREL (R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL, 16),
+  TILEGX_IMM16_HOWTO_LAST_PCREL (R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL, 32),
+  TILEGX_IMM16_HOWTO_LAST_PCREL (R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL, 32),
 
 #define TILEGX_IMM16_HOWTO_LAST_TLS_IE(name, rshift) \
   HOWTO (name, rshift, 1, 16, FALSE, 0, \
@@ -543,8 +547,8 @@
   TILEGX_IMM16_HOWTO_LAST_TLS_IE (R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE, 0),
   TILEGX_IMM16_HOWTO_LAST_TLS_IE (R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE, 16),
   TILEGX_IMM16_HOWTO_LAST_TLS_IE (R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE, 16),
-  TILEGX_IMM16_HOWTO_LAST_TLS_IE (R_TILEGX_IMM16_X0_HW2_LAST_TLS_IE, 32),
-  TILEGX_IMM16_HOWTO_LAST_TLS_IE (R_TILEGX_IMM16_X1_HW2_LAST_TLS_IE, 32),
+  EMPTY_HOWTO (104),
+  EMPTY_HOWTO (105),
 
   HOWTO(R_TILEGX_TLS_DTPMOD64, 0, 0, 0, FALSE, 0, complain_overflow_dont,
         bfd_elf_generic_reloc, "R_TILEGX_TLS_DTPMOD64",
@@ -564,7 +568,31 @@
         FALSE, 0, -1, TRUE),
   HOWTO(R_TILEGX_TLS_TPOFF32, 0, 0, 0, FALSE, 0, complain_overflow_dont,
         bfd_elf_generic_reloc, "R_TILEGX_TLS_TPOFF32",
-        FALSE, 0, 0, TRUE)
+        FALSE, 0, 0, TRUE),
+
+  HOWTO (R_TILEGX_TLS_GD_CALL, /* type */
+	 TILEGX_LOG2_BUNDLE_ALIGNMENT_IN_BYTES, /* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 27,			/* bitsize */
+	 TRUE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_signed,/* complain_on_overflow */
+	 bfd_elf_generic_reloc, /* special_function */
+	 "R_TILEGX_TLS_GD_CALL", /* name */
+	 FALSE,			/* partial_inplace */
+	 0,			/* src_mask */
+	 -1,			/* dst_mask */
+	 TRUE), 		/* pcrel_offset */
+
+  TILEGX_IMM_HOWTO(R_TILEGX_IMM8_X0_TLS_GD_ADD,  0,  8),
+  TILEGX_IMM_HOWTO(R_TILEGX_IMM8_X1_TLS_GD_ADD,  0,  8),
+  TILEGX_IMM_HOWTO(R_TILEGX_IMM8_Y0_TLS_GD_ADD,  0,  8),
+  TILEGX_IMM_HOWTO(R_TILEGX_IMM8_Y1_TLS_GD_ADD,  0,  8),
+  TILEGX_IMM_HOWTO(R_TILEGX_TLS_IE_LOAD, 0,  8),
+  TILEGX_IMM_HOWTO(R_TILEGX_IMM8_X0_TLS_ADD,  0,  8),
+  TILEGX_IMM_HOWTO(R_TILEGX_IMM8_X1_TLS_ADD,  0,  8),
+  TILEGX_IMM_HOWTO(R_TILEGX_IMM8_Y0_TLS_ADD,  0,  8),
+  TILEGX_IMM_HOWTO(R_TILEGX_IMM8_Y1_TLS_ADD,  0,  8),
 };
 
 static reloc_howto_type tilegx_elf_howto_table2 [] =
@@ -686,46 +714,42 @@
   SIMPLE_REMAP (TILEGX_IMM16_X1_HW2_LAST_PCREL)
   SIMPLE_REMAP (TILEGX_IMM16_X0_HW0_GOT)
   SIMPLE_REMAP (TILEGX_IMM16_X1_HW0_GOT)
-  SIMPLE_REMAP (TILEGX_IMM16_X0_HW1_GOT)
-  SIMPLE_REMAP (TILEGX_IMM16_X1_HW1_GOT)
-  SIMPLE_REMAP (TILEGX_IMM16_X0_HW2_GOT)
-  SIMPLE_REMAP (TILEGX_IMM16_X1_HW2_GOT)
-  SIMPLE_REMAP (TILEGX_IMM16_X0_HW3_GOT)
-  SIMPLE_REMAP (TILEGX_IMM16_X1_HW3_GOT)
+  SIMPLE_REMAP (TILEGX_IMM16_X0_HW0_PLT_PCREL)
+  SIMPLE_REMAP (TILEGX_IMM16_X1_HW0_PLT_PCREL)
+  SIMPLE_REMAP (TILEGX_IMM16_X0_HW1_PLT_PCREL)
+  SIMPLE_REMAP (TILEGX_IMM16_X1_HW1_PLT_PCREL)
+  SIMPLE_REMAP (TILEGX_IMM16_X0_HW2_PLT_PCREL)
+  SIMPLE_REMAP (TILEGX_IMM16_X1_HW2_PLT_PCREL)
   SIMPLE_REMAP (TILEGX_IMM16_X0_HW0_LAST_GOT)
   SIMPLE_REMAP (TILEGX_IMM16_X1_HW0_LAST_GOT)
   SIMPLE_REMAP (TILEGX_IMM16_X0_HW1_LAST_GOT)
   SIMPLE_REMAP (TILEGX_IMM16_X1_HW1_LAST_GOT)
-  SIMPLE_REMAP (TILEGX_IMM16_X0_HW2_LAST_GOT)
-  SIMPLE_REMAP (TILEGX_IMM16_X1_HW2_LAST_GOT)
+  SIMPLE_REMAP (TILEGX_IMM16_X0_HW3_PLT_PCREL)
+  SIMPLE_REMAP (TILEGX_IMM16_X1_HW3_PLT_PCREL)
   SIMPLE_REMAP (TILEGX_IMM16_X0_HW0_TLS_GD)
   SIMPLE_REMAP (TILEGX_IMM16_X1_HW0_TLS_GD)
-  SIMPLE_REMAP (TILEGX_IMM16_X0_HW1_TLS_GD)
-  SIMPLE_REMAP (TILEGX_IMM16_X1_HW1_TLS_GD)
-  SIMPLE_REMAP (TILEGX_IMM16_X0_HW2_TLS_GD)
-  SIMPLE_REMAP (TILEGX_IMM16_X1_HW2_TLS_GD)
-  SIMPLE_REMAP (TILEGX_IMM16_X0_HW3_TLS_GD)
-  SIMPLE_REMAP (TILEGX_IMM16_X1_HW3_TLS_GD)
+  SIMPLE_REMAP (TILEGX_IMM16_X0_HW0_TLS_LE)
+  SIMPLE_REMAP (TILEGX_IMM16_X1_HW0_TLS_LE)
+  SIMPLE_REMAP (TILEGX_IMM16_X0_HW0_LAST_TLS_LE)
+  SIMPLE_REMAP (TILEGX_IMM16_X1_HW0_LAST_TLS_LE)
+  SIMPLE_REMAP (TILEGX_IMM16_X0_HW1_LAST_TLS_LE)
+  SIMPLE_REMAP (TILEGX_IMM16_X1_HW1_LAST_TLS_LE)
   SIMPLE_REMAP (TILEGX_IMM16_X0_HW0_LAST_TLS_GD)
   SIMPLE_REMAP (TILEGX_IMM16_X1_HW0_LAST_TLS_GD)
   SIMPLE_REMAP (TILEGX_IMM16_X0_HW1_LAST_TLS_GD)
   SIMPLE_REMAP (TILEGX_IMM16_X1_HW1_LAST_TLS_GD)
-  SIMPLE_REMAP (TILEGX_IMM16_X0_HW2_LAST_TLS_GD)
-  SIMPLE_REMAP (TILEGX_IMM16_X1_HW2_LAST_TLS_GD)
   SIMPLE_REMAP (TILEGX_IMM16_X0_HW0_TLS_IE)
   SIMPLE_REMAP (TILEGX_IMM16_X1_HW0_TLS_IE)
-  SIMPLE_REMAP (TILEGX_IMM16_X0_HW1_TLS_IE)
-  SIMPLE_REMAP (TILEGX_IMM16_X1_HW1_TLS_IE)
-  SIMPLE_REMAP (TILEGX_IMM16_X0_HW2_TLS_IE)
-  SIMPLE_REMAP (TILEGX_IMM16_X1_HW2_TLS_IE)
-  SIMPLE_REMAP (TILEGX_IMM16_X0_HW3_TLS_IE)
-  SIMPLE_REMAP (TILEGX_IMM16_X1_HW3_TLS_IE)
+  SIMPLE_REMAP (TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL)
+  SIMPLE_REMAP (TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL)
+  SIMPLE_REMAP (TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL)
+  SIMPLE_REMAP (TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL)
+  SIMPLE_REMAP (TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL)
+  SIMPLE_REMAP (TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL)
   SIMPLE_REMAP (TILEGX_IMM16_X0_HW0_LAST_TLS_IE)
   SIMPLE_REMAP (TILEGX_IMM16_X1_HW0_LAST_TLS_IE)
   SIMPLE_REMAP (TILEGX_IMM16_X0_HW1_LAST_TLS_IE)
   SIMPLE_REMAP (TILEGX_IMM16_X1_HW1_LAST_TLS_IE)
-  SIMPLE_REMAP (TILEGX_IMM16_X0_HW2_LAST_TLS_IE)
-  SIMPLE_REMAP (TILEGX_IMM16_X1_HW2_LAST_TLS_IE)
 
   SIMPLE_REMAP (TILEGX_TLS_DTPMOD64)
   SIMPLE_REMAP (TILEGX_TLS_DTPOFF64)
@@ -735,6 +759,17 @@
   SIMPLE_REMAP (TILEGX_TLS_DTPOFF32)
   SIMPLE_REMAP (TILEGX_TLS_TPOFF32)
 
+  SIMPLE_REMAP (TILEGX_TLS_GD_CALL)
+  SIMPLE_REMAP (TILEGX_IMM8_X0_TLS_GD_ADD)
+  SIMPLE_REMAP (TILEGX_IMM8_X1_TLS_GD_ADD)
+  SIMPLE_REMAP (TILEGX_IMM8_Y0_TLS_GD_ADD)
+  SIMPLE_REMAP (TILEGX_IMM8_Y1_TLS_GD_ADD)
+  SIMPLE_REMAP (TILEGX_TLS_IE_LOAD)
+  SIMPLE_REMAP (TILEGX_IMM8_X0_TLS_ADD)
+  SIMPLE_REMAP (TILEGX_IMM8_X1_TLS_ADD)
+  SIMPLE_REMAP (TILEGX_IMM8_Y0_TLS_ADD)
+  SIMPLE_REMAP (TILEGX_IMM8_Y1_TLS_ADD)
+
 #undef SIMPLE_REMAP
 #undef TH_REMAP
 
@@ -824,6 +859,10 @@
   asection *sdynbss;
   asection *srelbss;
 
+  /* Whether LE transition has been disabled for some of the
+     sections.  */
+  bfd_boolean disable_le_transition;
+
   /* Small local sym to section mapping cache.  */
   struct sym_cache sym_cache;
 };
@@ -920,7 +959,7 @@
 {
   unsigned int r_type = TILEGX_ELF_R_TYPE (dst->r_info);
 
-  if (r_type <= (unsigned int) R_TILEGX_TLS_TPOFF32)
+  if (r_type <= (unsigned int) R_TILEGX_IMM8_Y1_TLS_ADD)
     cache_ptr->howto = &tilegx_elf_howto_table [r_type];
   else if (r_type - R_TILEGX_GNU_VTINHERIT
 	   <= (unsigned int) R_TILEGX_GNU_VTENTRY)
@@ -1027,6 +1066,8 @@
   create_Imm16_X1,
   create_Imm16_X0,
   create_Imm16_X1,
+  NULL,
+  NULL,
   create_Imm16_X0,
   create_Imm16_X1,
   create_Imm16_X0,
@@ -1039,10 +1080,6 @@
   create_Imm16_X1,
   create_Imm16_X0,
   create_Imm16_X1,
-  create_Imm16_X0,
-  create_Imm16_X1,
-  create_Imm16_X0,
-  create_Imm16_X1
 };
 
 static void
@@ -1183,7 +1220,7 @@
 };
 
 /* Reuse an existing info 10 bundle.  */
-static const bfd_byte const *tilegx64_plt_tail_entry =
+static const bfd_byte *const tilegx64_plt_tail_entry =
   &tilegx64_short_plt_entry[4 * TILEGX_BUNDLE_SIZE_IN_BYTES];
 
 static const bfd_byte
@@ -1228,7 +1265,7 @@
 };
 
 /* Reuse an existing info 10 bundle.  */
-static const bfd_byte const *tilegx32_plt_tail_entry =
+static const bfd_byte *const tilegx32_plt_tail_entry =
   &tilegx64_short_plt_entry[4 * TILEGX_BUNDLE_SIZE_IN_BYTES];
 
 static int
@@ -1402,23 +1439,23 @@
   struct elf_link_hash_table *htab = elf_hash_table (info);
 
   /* This function may be called more than once.  */
-  s = bfd_get_section_by_name (abfd, ".got");
-  if (s != NULL && (s->flags & SEC_LINKER_CREATED) != 0)
+  s = bfd_get_linker_section (abfd, ".got");
+  if (s != NULL)
     return TRUE;
 
   flags = bed->dynamic_sec_flags;
 
-  s = bfd_make_section_with_flags (abfd,
-				   (bed->rela_plts_and_copies_p
-				    ? ".rela.got" : ".rel.got"),
-				   (bed->dynamic_sec_flags
-				    | SEC_READONLY));
+  s = bfd_make_section_anyway_with_flags (abfd,
+					  (bed->rela_plts_and_copies_p
+					   ? ".rela.got" : ".rel.got"),
+					  (bed->dynamic_sec_flags
+					   | SEC_READONLY));
   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
     return FALSE;
   htab->srelgot = s;
 
-  s = s_got = bfd_make_section_with_flags (abfd, ".got", flags);
+  s = s_got = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
   if (s == NULL
       || !bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
     return FALSE;
@@ -1429,7 +1466,7 @@
 
   if (bed->want_got_plt)
     {
-      s = bfd_make_section_with_flags (abfd, ".got.plt", flags);
+      s = bfd_make_section_anyway_with_flags (abfd, ".got.plt", flags);
       if (s == NULL
 	  || !bfd_set_section_alignment (abfd, s,
 					 bed->s->log_file_align))
@@ -1475,9 +1512,9 @@
   if (!_bfd_elf_create_dynamic_sections (dynobj, info))
     return FALSE;
 
-  htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss");
+  htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss");
   if (!info->shared)
-    htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss");
+    htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss");
 
   if (!htab->elf.splt || !htab->elf.srelplt || !htab->sdynbss
       || (!info->shared && !htab->srelbss))
@@ -1538,6 +1575,83 @@
   _bfd_elf_link_hash_copy_indirect (info, dir, ind);
 }
 
+static int
+tilegx_tls_translate_to_le (int r_type)
+{
+  switch (r_type)
+    {
+    case R_TILEGX_IMM16_X0_HW0_TLS_GD:
+    case R_TILEGX_IMM16_X0_HW0_TLS_IE:
+      return R_TILEGX_IMM16_X0_HW0_TLS_LE;
+
+    case R_TILEGX_IMM16_X1_HW0_TLS_GD:
+    case R_TILEGX_IMM16_X1_HW0_TLS_IE:
+      return R_TILEGX_IMM16_X1_HW0_TLS_LE;
+
+    case R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD:
+    case R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE:
+      return R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE;
+
+    case R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD:
+    case R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE:
+      return R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE;
+
+    case R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD:
+    case R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE:
+      return R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE;
+
+    case R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD:
+    case R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE:
+      return R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE;
+    }
+  return r_type;
+}
+
+static int
+tilegx_tls_translate_to_ie (int r_type)
+{
+  switch (r_type)
+    {
+    case R_TILEGX_IMM16_X0_HW0_TLS_GD:
+    case R_TILEGX_IMM16_X0_HW0_TLS_IE:
+      return R_TILEGX_IMM16_X0_HW0_TLS_IE;
+
+    case R_TILEGX_IMM16_X1_HW0_TLS_GD:
+    case R_TILEGX_IMM16_X1_HW0_TLS_IE:
+      return R_TILEGX_IMM16_X1_HW0_TLS_IE;
+
+    case R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD:
+    case R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE:
+      return R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE;
+
+    case R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD:
+    case R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE:
+      return R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE;
+
+    case R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD:
+    case R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE:
+      return R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE;
+
+    case R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD:
+    case R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE:
+      return R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE;
+    }
+  return r_type;
+}
+
+static int
+tilegx_elf_tls_transition (struct bfd_link_info *info, int r_type,
+			   int is_local, bfd_boolean disable_le_transition)
+{
+  if (info->shared)
+    return r_type;
+
+  if (is_local && !disable_le_transition)
+    return tilegx_tls_translate_to_le (r_type);
+  else
+    return tilegx_tls_translate_to_ie (r_type);
+}
+
 /* Look through the relocs for a section during the first phase, and
    allocate space in the global offset table or procedure linkage
    table.  */
@@ -1553,6 +1667,7 @@
   const Elf_Internal_Rela *rel_end;
   asection *sreloc;
   int num_relocs;
+  bfd_boolean has_tls_gd_or_ie = FALSE, has_tls_add = FALSE;
 
   if (info->relocatable)
     return TRUE;
@@ -1571,6 +1686,33 @@
     htab->elf.dynobj = abfd;
 
   rel_end = relocs + num_relocs;
+
+  /* Check whether to do optimization to transform TLS GD/IE
+     referehces to TLS LE.  We disable it if we're linking with old
+     TLS code sequences that do not support such optimization.  Old
+     TLS code sequences have tls_gd_call/tls_ie_load relocations but
+     no tls_add relocations.  */
+  for (rel = relocs; rel < rel_end && !has_tls_add; rel++)
+    {
+      int r_type = TILEGX_ELF_R_TYPE (rel->r_info);
+      switch (r_type)
+	{
+	case R_TILEGX_TLS_GD_CALL:
+	case R_TILEGX_TLS_IE_LOAD:
+	  has_tls_gd_or_ie = TRUE;
+	  break;
+	case R_TILEGX_IMM8_X0_TLS_ADD:
+	case R_TILEGX_IMM8_Y0_TLS_ADD:
+	case R_TILEGX_IMM8_X1_TLS_ADD:
+	case R_TILEGX_IMM8_Y1_TLS_ADD:
+	  has_tls_add = TRUE;
+	  break;
+	}
+    }
+
+  sec->sec_flg0 = (has_tls_gd_or_ie && !has_tls_add);
+  htab->disable_le_transition |= sec->sec_flg0;
+
   for (rel = relocs; rel < rel_end; rel++)
     {
       unsigned int r_type;
@@ -1596,41 +1738,42 @@
 	  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;
+
+	  /* PR15323, ref flags aren't set for references in the same
+	     object.  */
+	  h->root.non_ir_ref = 1;
 	}
 
+      r_type = tilegx_elf_tls_transition (info, r_type, h == NULL,
+					  sec->sec_flg0);
       switch (r_type)
 	{
+	case R_TILEGX_IMM16_X0_HW0_TLS_LE:
+	case R_TILEGX_IMM16_X1_HW0_TLS_LE:
+	case R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE:
+	case R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE:
+	case R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE:
+	case R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE:
+	  if (info->shared)
+	    goto r_tilegx_plt32;
+	  break;
+
 	case R_TILEGX_IMM16_X0_HW0_TLS_GD:
 	case R_TILEGX_IMM16_X1_HW0_TLS_GD:
-	case R_TILEGX_IMM16_X0_HW1_TLS_GD:
-	case R_TILEGX_IMM16_X1_HW1_TLS_GD:
-	case R_TILEGX_IMM16_X0_HW2_TLS_GD:
-	case R_TILEGX_IMM16_X1_HW2_TLS_GD:
-	case R_TILEGX_IMM16_X0_HW3_TLS_GD:
-	case R_TILEGX_IMM16_X1_HW3_TLS_GD:
 	case R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD:
 	case R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD:
 	case R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD:
 	case R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD:
-	case R_TILEGX_IMM16_X0_HW2_LAST_TLS_GD:
-	case R_TILEGX_IMM16_X1_HW2_LAST_TLS_GD:
-          tls_type = GOT_TLS_GD;
+	  BFD_ASSERT (info->shared);
+	  tls_type = GOT_TLS_GD;
           goto have_got_reference;
 
 	case R_TILEGX_IMM16_X0_HW0_TLS_IE:
 	case R_TILEGX_IMM16_X1_HW0_TLS_IE:
-	case R_TILEGX_IMM16_X0_HW1_TLS_IE:
-	case R_TILEGX_IMM16_X1_HW1_TLS_IE:
-	case R_TILEGX_IMM16_X0_HW2_TLS_IE:
-	case R_TILEGX_IMM16_X1_HW2_TLS_IE:
-	case R_TILEGX_IMM16_X0_HW3_TLS_IE:
-	case R_TILEGX_IMM16_X1_HW3_TLS_IE:
 	case R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE:
 	case R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE:
 	case R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE:
 	case R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE:
-	case R_TILEGX_IMM16_X0_HW2_LAST_TLS_IE:
-	case R_TILEGX_IMM16_X1_HW2_LAST_TLS_IE:
           tls_type = GOT_TLS_IE;
           if (info->shared)
             info->flags |= DF_STATIC_TLS;
@@ -1638,18 +1781,10 @@
 
 	case R_TILEGX_IMM16_X0_HW0_GOT:
 	case R_TILEGX_IMM16_X1_HW0_GOT:
-	case R_TILEGX_IMM16_X0_HW1_GOT:
-	case R_TILEGX_IMM16_X1_HW1_GOT:
-	case R_TILEGX_IMM16_X0_HW2_GOT:
-	case R_TILEGX_IMM16_X1_HW2_GOT:
-	case R_TILEGX_IMM16_X0_HW3_GOT:
-	case R_TILEGX_IMM16_X1_HW3_GOT:
 	case R_TILEGX_IMM16_X0_HW0_LAST_GOT:
 	case R_TILEGX_IMM16_X1_HW0_LAST_GOT:
 	case R_TILEGX_IMM16_X0_HW1_LAST_GOT:
 	case R_TILEGX_IMM16_X1_HW1_LAST_GOT:
-	case R_TILEGX_IMM16_X0_HW2_LAST_GOT:
-	case R_TILEGX_IMM16_X1_HW2_LAST_GOT:
           tls_type = GOT_NORMAL;
           /* Fall Through */
 
@@ -1720,7 +1855,39 @@
 	    }
 	  break;
 
+	case R_TILEGX_TLS_GD_CALL:
+	  if (info->shared)
+	    {
+	      /* These are basically R_TILEGX_JUMPOFF_X1_PLT relocs
+		 against __tls_get_addr.  */
+	      struct bfd_link_hash_entry *bh = NULL;
+	      if (! _bfd_generic_link_add_one_symbol (info, abfd,
+						      "__tls_get_addr", 0,
+						      bfd_und_section_ptr, 0,
+						      NULL, FALSE, FALSE,
+						      &bh))
+		return FALSE;
+	      h = (struct elf_link_hash_entry *) bh;
+	    }
+	  else
+	    break;
+	  /* Fall through */
+
         case R_TILEGX_JUMPOFF_X1_PLT:
+	case R_TILEGX_IMM16_X0_HW0_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW0_PLT_PCREL:
+	case R_TILEGX_IMM16_X0_HW1_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW1_PLT_PCREL:
+	case R_TILEGX_IMM16_X0_HW2_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW2_PLT_PCREL:
+	case R_TILEGX_IMM16_X0_HW3_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW3_PLT_PCREL:
+	case R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL:
+	case R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL:
+	case R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL:
 	  /* This symbol requires a procedure linkage table entry.  We
 	     actually build the entry in adjust_dynamic_symbol,
 	     because this might be a case of linking PIC code without
@@ -1805,16 +1972,15 @@
 	case R_TILEGX_IMM16_X0_HW2_LAST:
 	case R_TILEGX_IMM16_X1_HW2_LAST:
 	  if (h != NULL)
-            {
-              h->non_got_ref = 1;
+	    h->non_got_ref = 1;
 
-              if (!info->shared)
-                {
-                  /* We may need a .plt entry if the function this reloc
-                     refers to is in a shared lib.  */
-                  h->plt.refcount += 1;
-                }
-            }
+	r_tilegx_plt32:
+	  if (h != NULL && !info->shared)
+	    {
+	      /* We may need a .plt entry if the function this reloc
+		 refers to is in a shared lib.  */
+	      h->plt.refcount += 1;
+	    }
 
 	  /* If we are creating a shared library, and this is a reloc
 	     against a global symbol, or a non PC relative reloc
@@ -1945,11 +2111,33 @@
   if (h != NULL)
     {
       switch (TILEGX_ELF_R_TYPE (rel->r_info))
-      {
-      case R_TILEGX_GNU_VTINHERIT:
-      case R_TILEGX_GNU_VTENTRY:
-	break;
-      }
+	{
+	case R_TILEGX_GNU_VTINHERIT:
+	case R_TILEGX_GNU_VTENTRY:
+	  return NULL;
+	}
+    }
+
+  /* FIXME: The test here, in check_relocs and in relocate_section
+     dealing with TLS optimization, ought to be !info->executable.  */
+  if (info->shared)
+    {
+      switch (TILEGX_ELF_R_TYPE (rel->r_info))
+	{
+	case R_TILEGX_TLS_GD_CALL:
+	  /* This reloc implicitly references __tls_get_addr.  We know
+	     another reloc will reference the same symbol as the one
+	     on this reloc, so the real symbol and section will be
+	     gc marked when processing the other reloc.  That lets
+	     us handle __tls_get_addr here.  */
+	  h = elf_link_hash_lookup (elf_hash_table (info), "__tls_get_addr",
+				    FALSE, FALSE, TRUE);
+	  BFD_ASSERT (h != NULL);
+	  h->mark = 1;
+	  if (h->u.weakdef != NULL)
+	    h->u.weakdef->mark = 1;
+	  sym = NULL;
+	}
     }
 
   return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
@@ -2008,51 +2196,28 @@
 	}
 
       r_type = TILEGX_ELF_R_TYPE (rel->r_info);
-
+      r_type = tilegx_elf_tls_transition (info, r_type, h != NULL,
+					  sec->sec_flg0);
       switch (r_type)
 	{
 	case R_TILEGX_IMM16_X0_HW0_GOT:
 	case R_TILEGX_IMM16_X1_HW0_GOT:
-	case R_TILEGX_IMM16_X0_HW1_GOT:
-	case R_TILEGX_IMM16_X1_HW1_GOT:
-	case R_TILEGX_IMM16_X0_HW2_GOT:
-	case R_TILEGX_IMM16_X1_HW2_GOT:
-	case R_TILEGX_IMM16_X0_HW3_GOT:
-	case R_TILEGX_IMM16_X1_HW3_GOT:
 	case R_TILEGX_IMM16_X0_HW0_LAST_GOT:
 	case R_TILEGX_IMM16_X1_HW0_LAST_GOT:
 	case R_TILEGX_IMM16_X0_HW1_LAST_GOT:
 	case R_TILEGX_IMM16_X1_HW1_LAST_GOT:
-	case R_TILEGX_IMM16_X0_HW2_LAST_GOT:
-	case R_TILEGX_IMM16_X1_HW2_LAST_GOT:
 	case R_TILEGX_IMM16_X0_HW0_TLS_GD:
 	case R_TILEGX_IMM16_X1_HW0_TLS_GD:
-	case R_TILEGX_IMM16_X0_HW1_TLS_GD:
-	case R_TILEGX_IMM16_X1_HW1_TLS_GD:
-	case R_TILEGX_IMM16_X0_HW2_TLS_GD:
-	case R_TILEGX_IMM16_X1_HW2_TLS_GD:
-	case R_TILEGX_IMM16_X0_HW3_TLS_GD:
-	case R_TILEGX_IMM16_X1_HW3_TLS_GD:
 	case R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD:
 	case R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD:
 	case R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD:
 	case R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD:
-	case R_TILEGX_IMM16_X0_HW2_LAST_TLS_GD:
-	case R_TILEGX_IMM16_X1_HW2_LAST_TLS_GD:
 	case R_TILEGX_IMM16_X0_HW0_TLS_IE:
 	case R_TILEGX_IMM16_X1_HW0_TLS_IE:
-	case R_TILEGX_IMM16_X0_HW1_TLS_IE:
-	case R_TILEGX_IMM16_X1_HW1_TLS_IE:
-	case R_TILEGX_IMM16_X0_HW2_TLS_IE:
-	case R_TILEGX_IMM16_X1_HW2_TLS_IE:
-	case R_TILEGX_IMM16_X0_HW3_TLS_IE:
-	case R_TILEGX_IMM16_X1_HW3_TLS_IE:
 	case R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE:
 	case R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE:
 	case R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE:
 	case R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE:
-	case R_TILEGX_IMM16_X0_HW2_LAST_TLS_IE:
-	case R_TILEGX_IMM16_X1_HW2_LAST_TLS_IE:
 	  if (h != NULL)
 	    {
 	      if (h->got.refcount > 0)
@@ -2060,7 +2225,8 @@
 	    }
 	  else
 	    {
-	      if (local_got_refcounts[r_symndx] > 0)
+	      if (local_got_refcounts &&
+		  local_got_refcounts[r_symndx] > 0)
 		local_got_refcounts[r_symndx]--;
 	    }
 	  break;
@@ -2137,6 +2303,20 @@
 	  /* Fall through.  */
 
         case R_TILEGX_JUMPOFF_X1_PLT:
+	case R_TILEGX_IMM16_X0_HW0_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW0_PLT_PCREL:
+	case R_TILEGX_IMM16_X0_HW1_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW1_PLT_PCREL:
+	case R_TILEGX_IMM16_X0_HW2_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW2_PLT_PCREL:
+	case R_TILEGX_IMM16_X0_HW3_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW3_PLT_PCREL:
+	case R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL:
+	case R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL:
+	case R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL:
 	  if (h != NULL)
 	    {
 	      if (h->plt.refcount > 0)
@@ -2256,13 +2436,6 @@
       return TRUE;
     }
 
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-			     h->root.root.string);
-      return TRUE;
-    }
-
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -2277,7 +2450,7 @@
      to copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rel.bss section we are going to use.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       htab->srelbss->size += TILEGX_ELF_RELA_BYTES (htab);
       h->needs_copy = 1;
@@ -2323,10 +2496,10 @@
 	  /* Allocate room for the header and tail.  */
 	  if (s->size == 0)
 	    {
-	      s->size = PLT_HEADER_SIZE + PLT_TAIL_SIZE;
+	      s->size = PLT_ENTRY_SIZE;
 	    }
 
-          h->plt.offset = s->size - PLT_TAIL_SIZE;
+          h->plt.offset = s->size - PLT_ENTRY_SIZE + PLT_HEADER_SIZE;
 
 	  /* If this symbol is not defined in a regular file, and we are
 	     not generating a shared library, then set the symbol to this
@@ -2361,7 +2534,15 @@
       h->needs_plt = 0;
     }
 
-  if (h->got.refcount > 0)
+  /* If a TLS_IE symbol is now local to the binary, make it a TLS_LE
+     requiring no TLS entry.  */
+  if (h->got.refcount > 0
+      && !htab->disable_le_transition
+      && !info->shared
+      && h->dynindx == -1
+      && tilegx_elf_hash_entry(h)->tls_type == GOT_TLS_IE)
+    h->got.offset = (bfd_vma) -1;
+  else if (h->got.refcount > 0)
     {
       asection *s;
       bfd_boolean dyn;
@@ -2543,7 +2724,7 @@
       /* Set the contents of the .interp section to the interpreter.  */
       if (info->executable)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = bfd_get_linker_section (dynobj, ".interp");
 	  BFD_ASSERT (s != NULL);
 	  s->size = strlen (htab->dynamic_interpreter) + 1;
 	  s->contents = (unsigned char *) htab->dynamic_interpreter;
@@ -2781,6 +2962,125 @@
   return (address - htab->tls_sec->vma);
 }
 
+/* Copy SIZE bits from FROM to TO at address ADDR.  */
+
+static void
+tilegx_copy_bits (bfd_byte *addr, int from, int to, int size)
+{
+  int i;
+  for (i = 0; i < size; i++)
+    {
+      int from_byte = (from + i) / 8;
+      int from_bit = (from + i) % 8;
+      int to_byte = (to + i) / 8;
+      int to_bit = (to + i) % 8;
+      bfd_byte to_mask = 1 << to_bit;
+      addr[to_byte] = (addr[to_byte] & ~to_mask)
+	| ((addr[from_byte] >> from_bit << to_bit) & to_mask);
+    }
+}
+
+/* Replace the MASK bits in ADDR with those in INSN, for the next
+   TILEGX_BUNDLE_SIZE_IN_BYTES bytes.  */
+
+static void
+tilegx_replace_insn (bfd_byte *addr, const bfd_byte *mask,
+		     const bfd_byte *insn)
+{
+  int i;
+  for (i = 0; i < TILEGX_BUNDLE_SIZE_IN_BYTES; i++)
+    {
+      addr[i] = (addr[i] & ~mask[i]) | (insn[i] & mask[i]);
+    }
+}
+
+/* Mask to extract the bits corresponding to an instruction in a
+   specific pipe of a bundle.  */
+static const bfd_byte insn_mask_X1[] = {
+  0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0x3f
+};
+
+/* Mask to extract the bits corresponding to an instruction in a
+   specific pipe of a bundle, minus the destination operand and the
+   first source operand.  */
+static const bfd_byte insn_mask_X0_no_dest_no_srca[] = {
+  0x00, 0xf0, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00
+};
+
+static const bfd_byte insn_mask_X1_no_dest_no_srca[] = {
+  0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x3f
+};
+
+static const bfd_byte insn_mask_Y0_no_dest_no_srca[] = {
+  0x00, 0xf0, 0x0f, 0x78, 0x00, 0x00, 0x00, 0x00
+};
+static const bfd_byte insn_mask_Y1_no_dest_no_srca[] = {
+  0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x07, 0x3c
+};
+
+/* Mask to extract the bits corresponding to an instruction in a
+   specific pipe of a bundle, minus the register operands.  */
+static const bfd_byte insn_mask_X0_no_operand[] = {
+  0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00
+};
+
+static const bfd_byte insn_mask_X1_no_operand[] = {
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x3f
+};
+
+static const bfd_byte insn_mask_Y0_no_operand[] = {
+  0x00, 0x00, 0x0c, 0x78, 0x00, 0x00, 0x00, 0x00
+};
+
+static const bfd_byte insn_mask_Y1_no_operand[] = {
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x3c
+};
+
+/* Various instructions synthesized to support tls references.  */
+
+/* ld r0, r0 in the X1 pipe, used for tls ie.  */
+static const bfd_byte insn_tls_ie_ld_X1[] = {
+  0x00, 0x00, 0x00, 0x00, 0x00, 0xe8, 0x6a, 0x28
+};
+
+/* ld4s r0, r0 in the X1 pipe, used for tls ie.  */
+static const bfd_byte insn_tls_ie_ld4s_X1[] = {
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x6a, 0x28
+};
+
+/* add r0, r0, tp in various pipes, used for tls ie.  */
+static const bfd_byte insn_tls_ie_add_X0X1[] = {
+  0x00, 0x50, 0x0f, 0x50, 0x00, 0xa8, 0x07, 0x28
+};
+static const bfd_byte insn_tls_ie_add_Y0Y1[] = {
+  0x00, 0x50, 0x27, 0x2c, 0x00, 0xa8, 0x13, 0x9a
+};
+
+/* addx r0, r0, tp in various pipes, used for tls ie.  */
+static const bfd_byte insn_tls_ie_addx_X0X1[] = {
+  0x00, 0x50, 0x0b, 0x50, 0x00, 0xa8, 0x05, 0x28
+};
+static const bfd_byte insn_tls_ie_addx_Y0Y1[] = {
+  0x00, 0x50, 0x03, 0x2c, 0x00, 0xa8, 0x01, 0x9a
+};
+
+/* move r0, r0 in various pipes, used for tls gd.  */
+static const bfd_byte insn_tls_gd_add_X0X1[] = {
+  0x00, 0xf0, 0x07, 0x51, 0x00, 0xf8, 0x3b, 0x28
+};
+static const bfd_byte insn_tls_gd_add_Y0Y1[] = {
+  0x00, 0xf0, 0x0b, 0x54, 0x00, 0xf8, 0x05, 0xae
+};
+
+static const bfd_byte *insn_move_X0X1 = insn_tls_gd_add_X0X1;
+static const bfd_byte *insn_move_Y0Y1 = insn_tls_gd_add_Y0Y1;
+
+static const bfd_byte *insn_add_X0X1 = insn_tls_ie_add_X0X1;
+static const bfd_byte *insn_add_Y0Y1 = insn_tls_ie_add_Y0Y1;
+
+static const bfd_byte *insn_addx_X0X1 = insn_tls_ie_addx_X0X1;
+static const bfd_byte *insn_addx_Y0Y1 = insn_tls_ie_addx_Y0Y1;
+
 /* Relocate an TILEGX ELF section.
 
    The RELOCATE_SECTION function is called by the new ELF backend linker
@@ -2845,6 +3145,7 @@
   for (; rel < relend; rel++)
     {
       int r_type, tls_type;
+      bfd_boolean is_tls_iele, is_tls_le;
       reloc_howto_type *howto;
       unsigned long r_symndx;
       struct elf_link_hash_entry *h;
@@ -2908,9 +3209,9 @@
 	    }
 	}
 
-      if (sec != NULL && elf_discarded_section (sec))
+      if (sec != NULL && discarded_section (sec))
 	RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
-					 rel, relend, howto, contents);
+					 rel, 1, relend, howto, 0, contents);
 
       if (info->relocatable)
 	continue;
@@ -2927,20 +3228,203 @@
 
       switch (r_type)
 	{
+	case R_TILEGX_TLS_GD_CALL:
+	case R_TILEGX_IMM8_X0_TLS_GD_ADD:
+	case R_TILEGX_IMM8_Y0_TLS_GD_ADD:
+	case R_TILEGX_IMM8_X1_TLS_GD_ADD:
+	case R_TILEGX_IMM8_Y1_TLS_GD_ADD:
+	case R_TILEGX_IMM8_X0_TLS_ADD:
+	case R_TILEGX_IMM8_Y0_TLS_ADD:
+	case R_TILEGX_IMM8_X1_TLS_ADD:
+	case R_TILEGX_IMM8_Y1_TLS_ADD:
+	  tls_type = GOT_UNKNOWN;
+	  if (h == NULL && local_got_offsets)
+	    tls_type =
+	      _bfd_tilegx_elf_local_got_tls_type (input_bfd) [r_symndx];
+	  else if (h != NULL)
+	    tls_type = tilegx_elf_hash_entry(h)->tls_type;
+
+	  is_tls_iele = (! info->shared || tls_type == GOT_TLS_IE);
+	  is_tls_le = is_tls_iele && (!input_section->sec_flg0
+				      && !info->shared
+				      && (h == NULL || h->dynindx == -1));
+
+	  if (r_type == R_TILEGX_TLS_GD_CALL)
+	    {
+	      if (is_tls_le)
+		{
+		  /* GD -> LE */
+		  tilegx_replace_insn (contents + rel->r_offset,
+				       insn_mask_X1, insn_move_X0X1);
+		  continue;
+		}
+	      else if (is_tls_iele)
+		{
+		  /* GD -> IE */
+		  if (ABI_64_P (output_bfd))
+		    tilegx_replace_insn (contents + rel->r_offset,
+					 insn_mask_X1, insn_tls_ie_ld_X1);
+		  else
+		    tilegx_replace_insn (contents + rel->r_offset,
+					 insn_mask_X1, insn_tls_ie_ld4s_X1);
+		  continue;
+		}
+
+	      /* GD -> GD */
+	      h = (struct elf_link_hash_entry *)
+		bfd_link_hash_lookup (info->hash, "__tls_get_addr", FALSE,
+				      FALSE, TRUE);
+	      BFD_ASSERT (h != NULL);
+	      r_type = R_TILEGX_JUMPOFF_X1_PLT;
+	      howto = tilegx_elf_howto_table + r_type;
+	    }
+	  else if (r_type == R_TILEGX_IMM8_X0_TLS_ADD
+		   || r_type ==  R_TILEGX_IMM8_X1_TLS_ADD
+		   || r_type ==  R_TILEGX_IMM8_Y0_TLS_ADD
+		   || r_type ==  R_TILEGX_IMM8_Y1_TLS_ADD)
+	    {
+	      bfd_boolean is_pipe0 =
+		(r_type == R_TILEGX_IMM8_X0_TLS_ADD
+		 || r_type ==  R_TILEGX_IMM8_Y0_TLS_ADD);
+	      bfd_boolean is_X0X1 =
+		(r_type == R_TILEGX_IMM8_X0_TLS_ADD
+		 || r_type ==  R_TILEGX_IMM8_X1_TLS_ADD);
+	      int dest_begin = is_pipe0 ? 0 : 31;
+	      int src_begin;
+	      const bfd_byte *insn;
+	      const bfd_byte *mask = NULL;
+
+	      if (is_tls_le)
+		{
+		  /* 1. copy dest operand into the first source operand.
+		     2. change the opcode to "move".  */
+		  src_begin = is_pipe0 ? 6 : 37;
+		  insn = is_X0X1 ? insn_move_X0X1 : insn_move_Y0Y1;
+
+		  switch (r_type)
+		    {
+		    case R_TILEGX_IMM8_X0_TLS_ADD:
+		      mask = insn_mask_X0_no_dest_no_srca;
+		      break;
+		    case R_TILEGX_IMM8_X1_TLS_ADD:
+		      mask = insn_mask_X1_no_dest_no_srca;
+		      break;
+		    case R_TILEGX_IMM8_Y0_TLS_ADD:
+		      mask = insn_mask_Y0_no_dest_no_srca;
+		      break;
+		    case R_TILEGX_IMM8_Y1_TLS_ADD:
+		      mask = insn_mask_Y1_no_dest_no_srca;
+		      break;
+		    }
+		}
+	      else
+		{
+		  /* 1. copy dest operand into the second source operand.
+		     2. change the opcode to "add".  */
+		  src_begin = is_pipe0 ? 12 : 43;
+		  if (ABI_64_P (output_bfd))
+		    insn = is_X0X1 ? insn_add_X0X1 : insn_add_Y0Y1;
+		  else
+		    insn = is_X0X1 ? insn_addx_X0X1 : insn_addx_Y0Y1;
+
+		  switch (r_type)
+		    {
+		    case R_TILEGX_IMM8_X0_TLS_ADD:
+		      mask = insn_mask_X0_no_operand;
+		      break;
+		    case R_TILEGX_IMM8_X1_TLS_ADD:
+		      mask = insn_mask_X1_no_operand;
+		      break;
+		    case R_TILEGX_IMM8_Y0_TLS_ADD:
+		      mask = insn_mask_Y0_no_operand;
+		      break;
+		    case R_TILEGX_IMM8_Y1_TLS_ADD:
+		      mask = insn_mask_Y1_no_operand;
+		      break;
+		    }
+		}
+
+	      tilegx_copy_bits (contents + rel->r_offset, dest_begin,
+				src_begin, 6);
+	      tilegx_replace_insn (contents  + rel->r_offset, mask, insn);
+
+	      continue;
+	    }
+	  else
+	    {
+	      const bfd_byte *mask = NULL;
+	      const bfd_byte *add_insn = NULL;
+	      bfd_boolean is_64bit = ABI_64_P (output_bfd);
+
+	      switch (r_type)
+		{
+		case R_TILEGX_IMM8_X0_TLS_GD_ADD:
+		  add_insn = is_tls_iele
+		    ? (is_64bit ? insn_tls_ie_add_X0X1 : insn_tls_ie_addx_X0X1)
+		    : insn_tls_gd_add_X0X1;
+		  mask = insn_mask_X0_no_dest_no_srca;
+		  break;
+		case R_TILEGX_IMM8_X1_TLS_GD_ADD:
+		  add_insn = is_tls_iele
+		    ? (is_64bit ? insn_tls_ie_add_X0X1 : insn_tls_ie_addx_X0X1)
+		    : insn_tls_gd_add_X0X1;
+		  mask = insn_mask_X1_no_dest_no_srca;
+		  break;
+		case R_TILEGX_IMM8_Y0_TLS_GD_ADD:
+		  add_insn = is_tls_iele
+		    ? (is_64bit ? insn_tls_ie_add_Y0Y1 : insn_tls_ie_addx_Y0Y1)
+		    : insn_tls_gd_add_Y0Y1;
+		  mask = insn_mask_Y0_no_dest_no_srca;
+		  break;
+		case R_TILEGX_IMM8_Y1_TLS_GD_ADD:
+		  add_insn = is_tls_iele
+		    ? (is_64bit ? insn_tls_ie_add_Y0Y1 : insn_tls_ie_addx_Y0Y1)
+		    : insn_tls_gd_add_Y0Y1;
+		  mask = insn_mask_Y1_no_dest_no_srca;
+		  break;
+		}
+
+	      tilegx_replace_insn (contents + rel->r_offset, mask, add_insn);
+
+	      continue;
+	    }
+	  break;
+	case R_TILEGX_TLS_IE_LOAD:
+	  if (!input_section->sec_flg0
+	      && !info->shared
+	      && (h == NULL || h->dynindx == -1))
+	    {
+	      /* IE -> LE */
+	      tilegx_replace_insn (contents + rel->r_offset,
+				   insn_mask_X1_no_dest_no_srca,
+				   insn_move_X0X1);
+	    }
+	  else
+	    {
+	      /* IE -> IE */
+	      if (ABI_64_P (output_bfd))
+		tilegx_replace_insn (contents + rel->r_offset,
+				     insn_mask_X1_no_dest_no_srca,
+				     insn_tls_ie_ld_X1);
+	      else
+		tilegx_replace_insn (contents + rel->r_offset,
+				     insn_mask_X1_no_dest_no_srca,
+				     insn_tls_ie_ld4s_X1);
+	    }
+	  continue;
+	  break;
+	default:
+	  break;
+	}
+
+      switch (r_type)
+	{
 	case R_TILEGX_IMM16_X0_HW0_GOT:
 	case R_TILEGX_IMM16_X1_HW0_GOT:
-	case R_TILEGX_IMM16_X0_HW1_GOT:
-	case R_TILEGX_IMM16_X1_HW1_GOT:
-	case R_TILEGX_IMM16_X0_HW2_GOT:
-	case R_TILEGX_IMM16_X1_HW2_GOT:
-	case R_TILEGX_IMM16_X0_HW3_GOT:
-	case R_TILEGX_IMM16_X1_HW3_GOT:
 	case R_TILEGX_IMM16_X0_HW0_LAST_GOT:
 	case R_TILEGX_IMM16_X1_HW0_LAST_GOT:
 	case R_TILEGX_IMM16_X0_HW1_LAST_GOT:
 	case R_TILEGX_IMM16_X1_HW1_LAST_GOT:
-	case R_TILEGX_IMM16_X0_HW2_LAST_GOT:
-	case R_TILEGX_IMM16_X1_HW2_LAST_GOT:
 	  /* Relocation is to the entry for this symbol in the global
 	     offset table.  */
 	  if (htab->elf.sgot == NULL)
@@ -3021,10 +3505,24 @@
 		  local_got_offsets[r_symndx] |= 1;
 		}
 	    }
-	  relocation = htab->elf.sgot->output_offset + off - got_base;
+	  relocation = off - got_base;
 	  break;
 
         case R_TILEGX_JUMPOFF_X1_PLT:
+	case R_TILEGX_IMM16_X0_HW0_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW0_PLT_PCREL:
+	case R_TILEGX_IMM16_X0_HW1_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW1_PLT_PCREL:
+	case R_TILEGX_IMM16_X0_HW2_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW2_PLT_PCREL:
+	case R_TILEGX_IMM16_X0_HW3_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW3_PLT_PCREL:
+	case R_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL:
+	case R_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL:
+	case R_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL:
+	case R_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL:
 	  /* Relocation is to the entry for this symbol in the
 	     procedure linkage table.  */
           BFD_ASSERT (h != NULL);
@@ -3248,92 +3746,83 @@
 	    }
 	  break;
 
+        case R_TILEGX_IMM16_X0_HW0_TLS_LE:
+        case R_TILEGX_IMM16_X1_HW0_TLS_LE:
+        case R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE:
+        case R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE:
+        case R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE:
+        case R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE:
+	  if (info->shared)
+	    {
+	      Elf_Internal_Rela outrel;
+	      bfd_boolean skip;
+
+	      BFD_ASSERT (sreloc != NULL);
+	      skip = FALSE;
+	      outrel.r_offset =
+		_bfd_elf_section_offset (output_bfd, info, input_section,
+					 rel->r_offset);
+	      if (outrel.r_offset == (bfd_vma) -1)
+		skip = TRUE;
+	      else if (outrel.r_offset == (bfd_vma) -2)
+		skip = TRUE;
+	      outrel.r_offset += (input_section->output_section->vma
+				  + input_section->output_offset);
+	      if (skip)
+		memset (&outrel, 0, sizeof outrel);
+	      else
+		{
+		  outrel.r_info = TILEGX_ELF_R_INFO (htab, NULL, 0, r_type);
+		  outrel.r_addend = relocation - dtpoff_base (info)
+				    + rel->r_addend;
+		}
+
+	      tilegx_elf_append_rela (output_bfd, sreloc, &outrel);
+	      continue;
+	    }
+	  relocation = tpoff (info, relocation);
+	  break;
+
         case R_TILEGX_IMM16_X0_HW0_TLS_GD:
         case R_TILEGX_IMM16_X1_HW0_TLS_GD:
-        case R_TILEGX_IMM16_X0_HW1_TLS_GD:
-        case R_TILEGX_IMM16_X1_HW1_TLS_GD:
-        case R_TILEGX_IMM16_X0_HW2_TLS_GD:
-        case R_TILEGX_IMM16_X1_HW2_TLS_GD:
-        case R_TILEGX_IMM16_X0_HW3_TLS_GD:
-        case R_TILEGX_IMM16_X1_HW3_TLS_GD:
         case R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD:
         case R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD:
         case R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD:
         case R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD:
-        case R_TILEGX_IMM16_X0_HW2_LAST_TLS_GD:
-        case R_TILEGX_IMM16_X1_HW2_LAST_TLS_GD:
-          tls_type = GOT_TLS_GD;
-          goto have_tls_reference;
-
         case R_TILEGX_IMM16_X0_HW0_TLS_IE:
         case R_TILEGX_IMM16_X1_HW0_TLS_IE:
-        case R_TILEGX_IMM16_X0_HW1_TLS_IE:
-        case R_TILEGX_IMM16_X1_HW1_TLS_IE:
-        case R_TILEGX_IMM16_X0_HW2_TLS_IE:
-        case R_TILEGX_IMM16_X1_HW2_TLS_IE:
-        case R_TILEGX_IMM16_X0_HW3_TLS_IE:
-        case R_TILEGX_IMM16_X1_HW3_TLS_IE:
         case R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE:
         case R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE:
         case R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE:
         case R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE:
-        case R_TILEGX_IMM16_X0_HW2_LAST_TLS_IE:
-        case R_TILEGX_IMM16_X1_HW2_LAST_TLS_IE:
-          tls_type = GOT_TLS_IE;
-          /* Fall through. */
-
-        have_tls_reference:
+	  r_type = tilegx_elf_tls_transition (info, r_type, h == NULL,
+					      input_section->sec_flg0);
+          tls_type = GOT_UNKNOWN;
 	  if (h == NULL && local_got_offsets)
-	    tls_type = _bfd_tilegx_elf_local_got_tls_type (input_bfd) [r_symndx];
+	    tls_type =
+	      _bfd_tilegx_elf_local_got_tls_type (input_bfd) [r_symndx];
 	  else if (h != NULL)
-	    tls_type = tilegx_elf_hash_entry(h)->tls_type;
+	    {
+	      tls_type = tilegx_elf_hash_entry(h)->tls_type;
+	      if (!info->shared && h->dynindx == -1 && tls_type == GOT_TLS_IE)
+		r_type = (!input_section->sec_flg0
+			  ? tilegx_tls_translate_to_le (r_type)
+			  : tilegx_tls_translate_to_ie (r_type));
+	    }
 
 	  if (tls_type == GOT_TLS_IE)
-	    switch (r_type)
-	      {
-              case R_TILEGX_IMM16_X0_HW0_TLS_GD:
-                r_type = R_TILEGX_IMM16_X0_HW0_TLS_IE;
-                break;
-              case R_TILEGX_IMM16_X1_HW0_TLS_GD:
-                r_type = R_TILEGX_IMM16_X1_HW0_TLS_IE;
-                break;
-              case R_TILEGX_IMM16_X0_HW1_TLS_GD:
-                r_type = R_TILEGX_IMM16_X0_HW1_TLS_IE;
-                break;
-              case R_TILEGX_IMM16_X1_HW1_TLS_GD:
-                r_type = R_TILEGX_IMM16_X1_HW1_TLS_IE;
-                break;
-              case R_TILEGX_IMM16_X0_HW2_TLS_GD:
-                r_type = R_TILEGX_IMM16_X0_HW2_TLS_IE;
-                break;
-              case R_TILEGX_IMM16_X1_HW2_TLS_GD:
-                r_type = R_TILEGX_IMM16_X1_HW2_TLS_IE;
-                break;
-              case R_TILEGX_IMM16_X0_HW3_TLS_GD:
-                r_type = R_TILEGX_IMM16_X0_HW3_TLS_IE;
-                break;
-              case R_TILEGX_IMM16_X1_HW3_TLS_GD:
-                r_type = R_TILEGX_IMM16_X1_HW3_TLS_IE;
-                break;
-              case R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD:
-                r_type = R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE;
-                break;
-              case R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD:
-                r_type = R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE;
-                break;
-              case R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD:
-                r_type = R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE;
-                break;
-              case R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD:
-                r_type = R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE;
-                break;
-              case R_TILEGX_IMM16_X0_HW2_LAST_TLS_GD:
-                r_type = R_TILEGX_IMM16_X0_HW2_LAST_TLS_IE;
-                break;
-              case R_TILEGX_IMM16_X1_HW2_LAST_TLS_GD:
-                r_type = R_TILEGX_IMM16_X1_HW2_LAST_TLS_IE;
-                break;
-	      }
+	    r_type = tilegx_tls_translate_to_ie (r_type);
+
+	  if (r_type == R_TILEGX_IMM16_X0_HW0_TLS_LE
+	      || r_type == R_TILEGX_IMM16_X1_HW0_TLS_LE
+	      || r_type == R_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
+	      || r_type == R_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
+	      || r_type == R_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
+	      || r_type == R_TILEGX_IMM16_X1_HW1_LAST_TLS_LE)
+	    {
+	      relocation = tpoff (info, relocation);
+	      break;
+	    }
 
 	  if (h != NULL)
 	    {
@@ -3386,18 +3875,10 @@
                 {
 		  case R_TILEGX_IMM16_X0_HW0_TLS_IE:
 		  case R_TILEGX_IMM16_X1_HW0_TLS_IE:
-		  case R_TILEGX_IMM16_X0_HW1_TLS_IE:
-		  case R_TILEGX_IMM16_X1_HW1_TLS_IE:
-		  case R_TILEGX_IMM16_X0_HW2_TLS_IE:
-		  case R_TILEGX_IMM16_X1_HW2_TLS_IE:
-		  case R_TILEGX_IMM16_X0_HW3_TLS_IE:
-		  case R_TILEGX_IMM16_X1_HW3_TLS_IE:
 		  case R_TILEGX_IMM16_X0_HW0_LAST_TLS_IE:
 		  case R_TILEGX_IMM16_X1_HW0_LAST_TLS_IE:
 		  case R_TILEGX_IMM16_X0_HW1_LAST_TLS_IE:
 		  case R_TILEGX_IMM16_X1_HW1_LAST_TLS_IE:
-		  case R_TILEGX_IMM16_X0_HW2_LAST_TLS_IE:
-		  case R_TILEGX_IMM16_X1_HW2_LAST_TLS_IE:
 		    if (need_relocs) {
 		      TILEGX_ELF_PUT_WORD (htab, output_bfd, 0,
 					   htab->elf.sgot->contents + off);
@@ -3418,18 +3899,10 @@
 
 		  case R_TILEGX_IMM16_X0_HW0_TLS_GD:
 		  case R_TILEGX_IMM16_X1_HW0_TLS_GD:
-		  case R_TILEGX_IMM16_X0_HW1_TLS_GD:
-		  case R_TILEGX_IMM16_X1_HW1_TLS_GD:
-		  case R_TILEGX_IMM16_X0_HW2_TLS_GD:
-		  case R_TILEGX_IMM16_X1_HW2_TLS_GD:
-		  case R_TILEGX_IMM16_X0_HW3_TLS_GD:
-		  case R_TILEGX_IMM16_X1_HW3_TLS_GD:
 		  case R_TILEGX_IMM16_X0_HW0_LAST_TLS_GD:
 		  case R_TILEGX_IMM16_X1_HW0_LAST_TLS_GD:
 		  case R_TILEGX_IMM16_X0_HW1_LAST_TLS_GD:
 		  case R_TILEGX_IMM16_X1_HW1_LAST_TLS_GD:
-		  case R_TILEGX_IMM16_X0_HW2_LAST_TLS_GD:
-		  case R_TILEGX_IMM16_X1_HW2_LAST_TLS_GD:
 		    if (need_relocs) {
  	              outrel.r_offset = (htab->elf.sgot->output_section->vma
 				       + htab->elf.sgot->output_offset + off);
@@ -3479,7 +3952,7 @@
 	  if (off >= (bfd_vma) -2)
 	    abort ();
 
-	  relocation = htab->elf.sgot->output_offset + off - got_base;
+	  relocation = off - got_base;
 	  unresolved_reloc = FALSE;
 	  howto = tilegx_elf_howto_table + r_type;
 	  break;
@@ -3493,7 +3966,9 @@
 	 not process them.  */
       if (unresolved_reloc
 	  && !((input_section->flags & SEC_DEBUGGING) != 0
-	       && h->def_dynamic))
+	       && h->def_dynamic)
+	  && _bfd_elf_section_offset (output_bfd, info, input_section,
+				      rel->r_offset) != (bfd_vma) -1)
 	(*_bfd_error_handler)
 	  (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
 	   input_bfd,
@@ -3724,8 +4199,7 @@
       /* This symbols needs a copy reloc.  Set it up.  */
       BFD_ASSERT (h->dynindx != -1);
 
-      s = bfd_get_section_by_name (h->root.u.def.section->owner,
-				   ".rela.bss");
+      s = htab->srelbss;
       BFD_ASSERT (s != NULL);
 
       rela.r_offset = (h->root.u.def.value
@@ -3737,7 +4211,7 @@
     }
 
   /* Mark some specially defined symbols as absolute. */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+  if (h == htab->elf.hdynamic
       || (h == htab->elf.hgot || h == htab->elf.hplt))
     sym->st_shndx = SHN_ABS;
 
@@ -3799,19 +4273,20 @@
   bfd *dynobj;
   asection *sdyn;
   struct tilegx_elf_link_hash_table *htab;
+  size_t pad_size;
 
   htab = tilegx_elf_hash_table (info);
   BFD_ASSERT (htab != NULL);
   dynobj = htab->elf.dynobj;
 
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       asection *splt;
       bfd_boolean ret;
 
-      splt = bfd_get_section_by_name (dynobj, ".plt");
+      splt = htab->elf.splt;
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       ret = tilegx_finish_dyn (output_bfd, info, dynobj, sdyn, splt);
@@ -3827,10 +4302,15 @@
 		    tilegx64_plt0_entry : tilegx32_plt0_entry,
 		  PLT_HEADER_SIZE);
 
-	  memcpy (splt->contents + splt->size - PLT_TAIL_SIZE,
+	  memcpy (splt->contents + splt->size
+		  - PLT_ENTRY_SIZE + PLT_HEADER_SIZE,
 		  ABI_64_P (output_bfd) ?
 		    tilegx64_plt_tail_entry : tilegx32_plt_tail_entry,
 		  PLT_TAIL_SIZE);
+	  /* Add padding so that the plt section is a multiple of its
+	     entry size.  */
+	  pad_size = PLT_ENTRY_SIZE - PLT_HEADER_SIZE - PLT_TAIL_SIZE;
+	  memset (splt->contents + splt->size - pad_size, 0, pad_size);
 	}
 
       elf_section_data (splt->output_section)->this_hdr.sh_entsize
@@ -3894,7 +4374,9 @@
 }
 
 enum elf_reloc_type_class
-tilegx_reloc_type_class (const Elf_Internal_Rela *rela)
+tilegx_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+			 const asection *rel_sec ATTRIBUTE_UNUSED,
+			 const Elf_Internal_Rela *rela)
 {
   switch ((int) TILEGX_ELF_R_TYPE (rela->r_info))
     {
diff --git a/bfd/elfxx-tilegx.h b/bfd/elfxx-tilegx.h
index 90ea5c8..78900ad 100644
--- a/bfd/elfxx-tilegx.h
+++ b/bfd/elfxx-tilegx.h
@@ -22,7 +22,9 @@
 #include "elf/internal.h"
 
 extern enum elf_reloc_type_class
-tilegx_reloc_type_class (const Elf_Internal_Rela *);
+tilegx_reloc_type_class (const struct bfd_link_info *,
+			 const asection *,
+			 const Elf_Internal_Rela *);
 
 extern reloc_howto_type *
 tilegx_reloc_name_lookup (bfd *, const char *);
diff --git a/bfd/format.c b/bfd/format.c
index 66b9051..b8f39ca 100644
--- a/bfd/format.c
+++ b/bfd/format.c
@@ -95,6 +95,91 @@
   return bfd_check_format_matches (abfd, format, NULL);
 }
 
+struct bfd_preserve
+{
+  void *marker;
+  void *tdata;
+  flagword flags;
+  const struct bfd_arch_info *arch_info;
+  struct bfd_section *sections;
+  struct bfd_section *section_last;
+  unsigned int section_count;
+  struct bfd_hash_table section_htab;
+};
+
+/* When testing an object for compatibility with a particular target
+   back-end, the back-end object_p function needs to set up certain
+   fields in the bfd on successfully recognizing the object.  This
+   typically happens in a piecemeal fashion, with failures possible at
+   many points.  On failure, the bfd is supposed to be restored to its
+   initial state, which is virtually impossible.  However, restoring a
+   subset of the bfd state works in practice.  This function stores
+   the subset.  */
+
+static bfd_boolean
+bfd_preserve_save (bfd *abfd, struct bfd_preserve *preserve)
+{
+  preserve->tdata = abfd->tdata.any;
+  preserve->arch_info = abfd->arch_info;
+  preserve->flags = abfd->flags;
+  preserve->sections = abfd->sections;
+  preserve->section_last = abfd->section_last;
+  preserve->section_count = abfd->section_count;
+  preserve->section_htab = abfd->section_htab;
+  preserve->marker = bfd_alloc (abfd, 1);
+  if (preserve->marker == NULL)
+    return FALSE;
+
+  return bfd_hash_table_init (&abfd->section_htab, bfd_section_hash_newfunc,
+			      sizeof (struct section_hash_entry));
+}
+
+/* Clear out a subset of BFD state.  */
+
+static void
+bfd_reinit (bfd *abfd)
+{
+  abfd->tdata.any = NULL;
+  abfd->arch_info = &bfd_default_arch_struct;
+  abfd->flags &= BFD_FLAGS_SAVED;
+  bfd_section_list_clear (abfd);
+}
+
+/* Restores bfd state saved by bfd_preserve_save.  */
+
+static void
+bfd_preserve_restore (bfd *abfd, struct bfd_preserve *preserve)
+{
+  bfd_hash_table_free (&abfd->section_htab);
+
+  abfd->tdata.any = preserve->tdata;
+  abfd->arch_info = preserve->arch_info;
+  abfd->flags = preserve->flags;
+  abfd->section_htab = preserve->section_htab;
+  abfd->sections = preserve->sections;
+  abfd->section_last = preserve->section_last;
+  abfd->section_count = preserve->section_count;
+
+  /* bfd_release frees all memory more recently bfd_alloc'd than
+     its arg, as well as its arg.  */
+  bfd_release (abfd, preserve->marker);
+  preserve->marker = NULL;
+}
+
+/* Called when the bfd state saved by bfd_preserve_save is no longer
+   needed.  */
+
+static void
+bfd_preserve_finish (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_preserve *preserve)
+{
+  /* It would be nice to be able to free more memory here, eg. old
+     tdata, but that's not possible since these blocks are sitting
+     inside bfd_alloc'd memory.  The section hash is on a separate
+     objalloc.  */
+  bfd_hash_table_free (&preserve->section_htab);
+  preserve->marker = NULL;
+}
+
 /*
 FUNCTION
 	bfd_check_format_matches
@@ -124,6 +209,7 @@
   const bfd_target *save_targ, *right_targ, *ar_right_targ, *match_targ;
   int match_count, best_count, best_match;
   int ar_match_index;
+  struct bfd_preserve preserve;
 
   if (matching != NULL)
     *matching = NULL;
@@ -138,12 +224,6 @@
   if (abfd->format != bfd_unknown)
     return abfd->format == format;
 
-  /* Since the target type was defaulted, check them
-     all in the hope that one will be uniquely recognized.  */
-  save_targ = abfd->xvec;
-  match_count = 0;
-  ar_match_index = _bfd_target_vector_entries;
-
   if (matching != NULL || *bfd_associated_vector != NULL)
     {
       bfd_size_type amt;
@@ -154,14 +234,10 @@
 	return FALSE;
     }
 
-  right_targ = 0;
-  ar_right_targ = 0;
-  match_targ = 0;
-  best_match = 256;
-  best_count = 0;
-
   /* Presume the answer is yes.  */
   abfd->format = format;
+  save_targ = abfd->xvec;
+  preserve.marker = NULL;
 
   /* If the target type was explicitly specified, just check that target.  */
   if (!abfd->target_defaulted)
@@ -190,10 +266,19 @@
 	goto err_unrecog;
     }
 
+  /* Since the target type was defaulted, check them all in the hope
+     that one will be uniquely recognized.  */
+  right_targ = NULL;
+  ar_right_targ = NULL;
+  match_targ = NULL;
+  best_match = 256;
+  best_count = 0;
+  match_count = 0;
+  ar_match_index = _bfd_target_vector_entries;
+
   for (target = bfd_target_vector; *target != NULL; target++)
     {
       const bfd_target *temp;
-      bfd_error_type err;
 
       /* Don't check the default target twice.  */
       if (*target == &binary_vec
@@ -201,7 +286,13 @@
 	  || (*target)->match_priority > best_match)
 	continue;
 
-      abfd->xvec = *target;	/* Change BFD's target temporarily.  */
+      /* If we already tried a match, the bfd is modified and may
+	 have sections attached, which will confuse the next
+	 _bfd_check_format call.  */
+      bfd_reinit (abfd);
+
+      /* Change BFD's target temporarily.  */
+      abfd->xvec = *target;
 
       if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
 	goto err_ret;
@@ -214,44 +305,51 @@
 
       temp = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
       if (temp)
-	match_targ = temp;
-
-      if (temp && (abfd->format != bfd_archive || bfd_has_map (abfd)))
 	{
-	  /* This format checks out as ok!  */
-	  right_targ = temp;
+	  match_targ = temp;
+	  if (preserve.marker != NULL)
+	    bfd_preserve_finish (abfd, &preserve);
 
-	  /* If this is the default target, accept it, even if other
-	     targets might match.  People who want those other targets
-	     have to set the GNUTARGET variable.  */
-	  if (temp == bfd_default_vector[0])
-	    goto ok_ret;
-
-	  if (matching_vector)
-	    matching_vector[match_count] = temp;
-	  match_count++;
-
-	  if (temp->match_priority < best_match)
+	  if (abfd->format != bfd_archive
+	      || (bfd_has_map (abfd)
+		  && bfd_get_error () != bfd_error_wrong_object_format))
 	    {
-	      best_match = temp->match_priority;
-	      best_count = 0;
+	      /* This format checks out as ok!  */
+	      right_targ = temp;
+
+	      /* If this is the default target, accept it, even if
+		 other targets might match.  People who want those
+		 other targets have to set the GNUTARGET variable.  */
+	      if (temp == bfd_default_vector[0])
+		goto ok_ret;
+
+	      if (matching_vector)
+		matching_vector[match_count] = temp;
+	      match_count++;
+
+	      if (temp->match_priority < best_match)
+		{
+		  best_match = temp->match_priority;
+		  best_count = 0;
+		}
+	      best_count++;
 	    }
-	  best_count++;
+	  else
+	    {
+	      /* An archive with no armap or objects of the wrong
+		 type.  We want this target to match if we get no
+		 better matches.  */
+	      if (ar_right_targ != bfd_default_vector[0])
+		ar_right_targ = *target;
+	      if (matching_vector)
+		matching_vector[ar_match_index] = *target;
+	      ar_match_index++;
+	    }
+
+	  if (!bfd_preserve_save (abfd, &preserve))
+	    goto err_ret;
 	}
-      else if (temp
-	       || (err = bfd_get_error ()) == bfd_error_wrong_object_format
-	       || err == bfd_error_file_ambiguously_recognized)
-	{
-	  /* An archive with no armap or objects of the wrong type,
-	     or an ambiguous match.  We want this target to match
-	     if we get no better matches.  */
-	  if (ar_right_targ != bfd_default_vector[0])
-	    ar_right_targ = *target;
-	  if (matching_vector)
-	    matching_vector[ar_match_index] = *target;
-	  ar_match_index++;
-	}
-      else if (err != bfd_error_wrong_format)
+      else if (bfd_get_error () != bfd_error_wrong_format)
 	goto err_ret;
     }
 
@@ -278,6 +376,9 @@
 	}
     }
 
+  /* We have more than one equally good match.  If any of the best
+     matches is a target in config.bfd targ_defvec or targ_selvecs,
+     choose it.  */
   if (match_count > 1)
     {
       const bfd_target * const *assoc = bfd_associated_vector;
@@ -287,7 +388,8 @@
 	  int i = match_count;
 
 	  while (--i >= 0)
-	    if (matching_vector[i] == right_targ)
+	    if (matching_vector[i] == right_targ
+		&& right_targ->match_priority <= best_match)
 	      break;
 
 	  if (i >= 0)
@@ -298,6 +400,29 @@
 	}
     }
 
+  /* We still have more than one equally good match, and at least some
+     of the targets support match priority.  Choose the first of the
+     best matches.  */
+  if (match_count > 1 && best_count != match_count)
+    {
+      int i;
+
+      for (i = 0; i < match_count; i++)
+	{
+	  right_targ = matching_vector[i];
+	  if (right_targ->match_priority <= best_match)
+	    break;
+	}
+      match_count = 1;
+    }
+
+  /* There is way too much undoing of half-known state here.  We
+     really shouldn't iterate on live bfd's.  Note that saving the
+     whole bfd and restoring it would be even worse; the first thing
+     you notice is that the cached bfd file position gets out of sync.  */
+  if (preserve.marker != NULL)
+    bfd_preserve_restore (abfd, &preserve);
+
   if (match_count == 1)
     {
       abfd->xvec = right_targ;
@@ -306,9 +431,11 @@
 	 state (except possibly for XVEC).  */
       if (match_targ != right_targ)
 	{
+	  bfd_reinit (abfd);
 	  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
 	    goto err_ret;
 	  match_targ = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
+	  BFD_ASSERT (match_targ != NULL);
 	}
 
     ok_ret:
@@ -322,7 +449,9 @@
 
       if (matching_vector)
 	free (matching_vector);
-      return TRUE;			/* File position has moved, BTW.  */
+
+      /* File position has moved, BTW.  */
+      return TRUE;
     }
 
   if (match_count == 0)
@@ -334,11 +463,14 @@
       abfd->format = bfd_unknown;
       if (matching_vector)
 	free (matching_vector);
+      if (preserve.marker != NULL)
+	bfd_preserve_restore (abfd, &preserve);
       return FALSE;
     }
 
-  abfd->xvec = save_targ;		/* Restore original target type.  */
-  abfd->format = bfd_unknown;		/* Restore original format.  */
+  /* Restore original target type and format.  */
+  abfd->xvec = save_targ;
+  abfd->format = bfd_unknown;
   bfd_set_error (bfd_error_file_ambiguously_recognized);
 
   if (matching)
diff --git a/bfd/hash.c b/bfd/hash.c
index 1de2c2a..82e711a 100644
--- a/bfd/hash.c
+++ b/bfd/hash.c
@@ -1,6 +1,6 @@
 /* hash.c -- hash table routines for BFD
    Copyright 1993, 1994, 1995, 1997, 1999, 2001, 2002, 2003, 2004, 2005,
-   2006, 2007, 2009, 2010, 2011  Free Software Foundation, Inc.
+   2006, 2007, 2009, 2010, 2011, 2012   Free Software Foundation, Inc.
    Written by Steve Chamberlain <[email protected]>
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -538,7 +538,7 @@
 	  table->frozen = 1;
 	  return hashp;
 	}
-      memset ((PTR) newtable, 0, alloc);
+      memset (newtable, 0, alloc);
 
       for (hi = 0; hi < table->size; hi ++)
 	while (table->table[hi])
@@ -808,7 +808,8 @@
 
 /* Get the index of a string in a strtab, adding it if it is not
    already present.  If HASH is FALSE, we don't really use the hash
-   table, and we don't eliminate duplicate strings.  */
+   table, and we don't eliminate duplicate strings.  If COPY is true
+   then store a copy of STR if creating a new entry.  */
 
 bfd_size_type
 _bfd_stringtab_add (struct bfd_strtab_hash *tab,
@@ -834,11 +835,13 @@
 	entry->root.string = str;
       else
 	{
+	  size_t len = strlen (str) + 1;
 	  char *n;
 
-	  n = (char *) bfd_hash_allocate (&tab->table, strlen (str) + 1);
+	  n = (char *) bfd_hash_allocate (&tab->table, len);
 	  if (n == NULL)
 	    return (bfd_size_type) -1;
+          memcpy (n, str, len);
 	  entry->root.string = n;
 	}
       entry->index = (bfd_size_type) -1;
diff --git a/bfd/hosts/alphavms.h b/bfd/hosts/alphavms.h
index 2a34212..8d21826 100644
--- a/bfd/hosts/alphavms.h
+++ b/bfd/hosts/alphavms.h
@@ -21,6 +21,13 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
+#ifdef PACKAGE
+#error sysdep.h must be included in lieu of config.h
+#endif
+
+#include "config.h"
+#include "ansidecl.h"
+
 #include <stddef.h>
 #include <fcntl.h>
 #include <errno.h>
@@ -34,32 +41,7 @@
 #include <unixio.h>
 #include <time.h>
 
-#include "bfd.h"
 #include "filenames.h"
-
-#ifndef BFD_HOST_64_BIT
-/* Make the basic types 64-bit quantities on the host.
-   Also provide the support macros BFD needs.  */
-# ifdef __GNUC__
-#  define	BFD_HOST_64_BIT	long long
-# else
-#  define	BFD_HOST_64_BIT	long
-# endif
-typedef unsigned BFD_HOST_64_BIT uint64_type;
-typedef BFD_HOST_64_BIT int64_type;
-
-# define sprintf_vma(s,x) sprintf (s, "%016lx", x) /* BFD_HOST_64_BIT */
-# define fprintf_vma(f,x) fprintf (f, "%016lx", x) /* BFD_HOST_64_BIT */
-
-# define BYTES_IN_PRINTF_INT 4
-
-/* These must have type unsigned long because they are used as
-   arguments in printf functions.  */
-# define uint64_typeLOW(x) ((unsigned long) (((x) & 0xffffffff))) /* BFD_HOST_64_BIT */
-# define uint64_typeHIGH(x) ((unsigned long) (((x) >> 32) & 0xffffffff)) /* BFD_HOST_64_BIT */
-
-#endif /* BFD_HOST_64_BIT */
-
 #include "fopen-vms.h"
 
 #define NO_FCNTL 1
diff --git a/bfd/hosts/x86-64linux.h b/bfd/hosts/x86-64linux.h
index 4ffc3f2..78be09a 100644
--- a/bfd/hosts/x86-64linux.h
+++ b/bfd/hosts/x86-64linux.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2006, 2011
+/* Copyright (C) 2006, 2011, 2012
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -40,6 +40,9 @@
 typedef unsigned long long int uint64_t;
 #endif
 
+/* Unsigned 64-bit integer aligned to 8 bytes.  */
+typedef uint64_t __attribute__ ((__aligned__ (8))) a8_uint64_t;
+
 #undef HAVE_PRPSINFO32_T
 #define HAVE_PRPSINFO32_T
 #undef HAVE_PRPSINFO32_T_PR_PID
@@ -71,40 +74,40 @@
   int32_t xss;
 };
 
-struct user_regsx32_struct
+struct user_regs64_struct
 {
-  uint64_t r15;
-  uint64_t r14;
-  uint64_t r13;
-  uint64_t r12;
-  uint64_t rbp;
-  uint64_t rbx;
-  uint64_t r11;
-  uint64_t r10;
-  uint64_t r9;
-  uint64_t r8;
-  uint64_t rax;
-  uint64_t rcx;
-  uint64_t rdx;
-  uint64_t rsi;
-  uint64_t rdi;
-  uint64_t orig_rax;
-  uint64_t rip;
-  uint64_t cs;
-  uint64_t eflags;
-  uint64_t rsp;
-  uint64_t ss;
-  uint64_t fs_base;
-  uint64_t gs_base;
-  uint64_t ds;
-  uint64_t es;
-  uint64_t fs;
-  uint64_t gs;
+  a8_uint64_t r15;
+  a8_uint64_t r14;
+  a8_uint64_t r13;
+  a8_uint64_t r12;
+  a8_uint64_t rbp;
+  a8_uint64_t rbx;
+  a8_uint64_t r11;
+  a8_uint64_t r10;
+  a8_uint64_t r9;
+  a8_uint64_t r8;
+  a8_uint64_t rax;
+  a8_uint64_t rcx;
+  a8_uint64_t rdx;
+  a8_uint64_t rsi;
+  a8_uint64_t rdi;
+  a8_uint64_t orig_rax;
+  a8_uint64_t rip;
+  a8_uint64_t cs;
+  a8_uint64_t eflags;
+  a8_uint64_t rsp;
+  a8_uint64_t ss;
+  a8_uint64_t fs_base;
+  a8_uint64_t gs_base;
+  a8_uint64_t ds;
+  a8_uint64_t es;
+  a8_uint64_t fs;
+  a8_uint64_t gs;
 };
 
 /* Type for a general-purpose register.  */
 typedef uint32_t elf_greg32_t;
-typedef uint64_t elf_gregx32_t;
+typedef a8_uint64_t elf_greg64_t;
 
 /* And the whole bunch of them.  We could have used `struct
    user_regs_struct' directly in the typedef, but tradition says that
@@ -112,8 +115,8 @@
    semantics, so leave it that way.  */
 #define ELF_NGREG32 (sizeof (struct user_regs32_struct) / sizeof(elf_greg32_t))
 typedef elf_greg32_t elf_gregset32_t[ELF_NGREG32];
-#define ELF_NGREGX32 (sizeof (struct user_regsx32_struct) / sizeof(elf_gregx32_t))
-typedef elf_gregx32_t elf_gregsetx32_t[ELF_NGREGX32];
+#define ELF_NGREG64 (sizeof (struct user_regs64_struct) / sizeof(elf_greg64_t))
+typedef elf_greg64_t elf_gregset64_t[ELF_NGREG64];
 
 /* Definitions to generate Intel SVR4-like core files.  These mostly
    have the same names as the SVR4 types with "elf_" tacked on the
@@ -128,6 +131,12 @@
     int tv_usec;
   };
 
+struct prstatus64_timeval
+  {
+    a8_uint64_t tv_sec;
+    a8_uint64_t tv_usec;
+  };
+
 struct elf_prstatus32
   {
     struct elf_siginfo pr_info;		/* Info associated with signal.  */
@@ -160,7 +169,25 @@
     struct prstatus32_timeval pr_stime;		/* System time.  */
     struct prstatus32_timeval pr_cutime;	/* Cumulative user time.  */
     struct prstatus32_timeval pr_cstime;	/* Cumulative system time.  */
-    elf_gregsetx32_t pr_reg;		/* GP registers.  */
+    elf_gregset64_t pr_reg;		/* GP registers.  */
+    int pr_fpvalid;			/* True if math copro being used.  */
+  };
+
+struct elf_prstatus64
+  {
+    struct elf_siginfo pr_info;	/* Info associated with signal.  */
+    short int pr_cursig;		/* Current signal.  */
+    a8_uint64_t pr_sigpend;		/* Set of pending signals.  */
+    a8_uint64_t pr_sighold;		/* Set of held signals.  */
+    pid_t pr_pid;
+    pid_t pr_ppid;
+    pid_t pr_pgrp;
+    pid_t pr_sid;
+    struct prstatus64_timeval pr_utime;		/* User time.  */
+    struct prstatus64_timeval pr_stime;		/* System time.  */
+    struct prstatus64_timeval pr_cutime;	/* Cumulative user time.  */
+    struct prstatus64_timeval pr_cstime;	/* Cumulative system time.  */
+    elf_gregset64_t pr_reg;		/* GP registers.  */
     int pr_fpvalid;			/* True if math copro being used.  */
   };
 
@@ -179,6 +206,20 @@
     char pr_psargs[ELF_PRARGSZ];	/* Initial part of arg list.  */
   };
 
+struct elf_prpsinfo64
+  {
+    char pr_state;			/* Numeric process state.  */
+    char pr_sname;			/* Char for pr_state.  */
+    char pr_zomb;			/* Zombie.  */
+    char pr_nice;			/* Nice val.  */
+    a8_uint64_t pr_flag;		/* Flags.  */
+    unsigned int pr_uid;
+    unsigned int pr_gid;
+    int pr_pid, pr_ppid, pr_pgrp, pr_sid;
+    /* Lots missing */
+    char pr_fname[16];			/* Filename of executable.  */
+    char pr_psargs[ELF_PRARGSZ];	/* Initial part of arg list.  */
+  };
 
 /* The rest of this file provides the types for emulation of the
    Solaris <proc_service.h> interfaces that should be implemented by
@@ -187,4 +228,6 @@
 /* Process status and info.  In the end we do provide typedefs for them.  */
 typedef struct elf_prstatus32 prstatus32_t;
 typedef struct elf_prstatusx32 prstatusx32_t;
+typedef struct elf_prstatus64 prstatus64_t;
 typedef struct elf_prpsinfo32 prpsinfo32_t;
+typedef struct elf_prpsinfo64 prpsinfo64_t;
diff --git a/bfd/hp300hpux.c b/bfd/hp300hpux.c
index 7779fef..6803d74 100644
--- a/bfd/hp300hpux.c
+++ b/bfd/hp300hpux.c
@@ -1,6 +1,6 @@
 /* BFD backend for hp-ux 9000/300
    Copyright 1990, 1991, 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005, 2007, 2010 Free Software Foundation, Inc.
+   2003, 2004, 2005, 2007, 2010, 2012 Free Software Foundation, Inc.
    Written by Glenn Engel.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -195,26 +195,19 @@
 
 #include "aoutx.h"
 
-static const bfd_target * MY (callback)
-  PARAMS ((bfd *));
-static bfd_boolean MY (write_object_contents)
-  PARAMS ((bfd *));
+static const bfd_target * MY (callback) (bfd *);
+static bfd_boolean MY (write_object_contents) (bfd *);
 static void convert_sym_type
-  PARAMS ((struct external_nlist *, aout_symbol_type *, bfd *));
+  (struct external_nlist *, aout_symbol_type *, bfd *);
 
-bfd_boolean MY (slurp_symbol_table)
-  PARAMS ((bfd *));
+bfd_boolean MY (slurp_symbol_table) (bfd *);
 void MY (swap_std_reloc_in)
-  PARAMS ((bfd *, struct hp300hpux_reloc *, arelent *, asymbol **,
-	   bfd_size_type));
+  (bfd *, struct hp300hpux_reloc *, arelent *, asymbol **, bfd_size_type);
 bfd_boolean MY (slurp_reloc_table)
-  PARAMS ((bfd *, sec_ptr, asymbol **));
-long MY (canonicalize_symtab)
-  PARAMS ((bfd *, asymbol **));
-long MY (get_symtab_upper_bound)
-  PARAMS ((bfd *));
-long MY (canonicalize_reloc)
-  PARAMS ((bfd *, sec_ptr, arelent **, asymbol **));
+  (bfd *, sec_ptr, asymbol **);
+long MY (canonicalize_symtab)  (bfd *, asymbol **);
+long MY (get_symtab_upper_bound)  (bfd *);
+long MY (canonicalize_reloc)  (bfd *, sec_ptr, arelent **, asymbol **);
 
 /* Since the hpux symbol table has nlist elements interspersed with
    strings and we need to insert som strings for secondary symbols, we
@@ -227,8 +220,7 @@
 /* Set parameters about this a.out file that are machine-dependent.
    This routine is called from some_aout_object_p just before it returns.  */
 static const bfd_target *
-MY (callback) (abfd)
-     bfd *abfd;
+MY (callback) (bfd *abfd)
 {
   struct internal_exec *execp = exec_hdr (abfd);
 
@@ -282,12 +274,10 @@
   return abfd->xvec;
 }
 
-extern bfd_boolean aout_32_write_syms
-  PARAMS ((bfd * abfd));
+extern bfd_boolean aout_32_write_syms (bfd *);
 
 static bfd_boolean
-MY (write_object_contents) (abfd)
-     bfd *abfd;
+MY (write_object_contents) (bfd * abfd)
 {
   struct external_exec exec_bytes;
   struct internal_exec *execp = exec_hdr (abfd);
@@ -320,7 +310,7 @@
   H_PUT_32 (abfd, (bfd_get_symcount (abfd) * 12), exec_bytes.e_drelocs);
 
   if (bfd_seek (abfd, (file_ptr) 0, FALSE) != 0
-      || (bfd_bwrite ((PTR) &exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, abfd)
+      || (bfd_bwrite (&exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, abfd)
 	  != EXEC_BYTES_SIZE))
     return FALSE;
 
@@ -353,14 +343,13 @@
   return TRUE;
 }
 
-/* convert the hp symbol type to be the same as aout64.h usage so we */
-/* can piggyback routines in aoutx.h.                                */
+/* Convert the hp symbol type to be the same as aout64.h usage so we
+   can piggyback routines in aoutx.h.  */
 
 static void
-convert_sym_type (sym_pointer, cache_ptr, abfd)
-     struct external_nlist *sym_pointer ATTRIBUTE_UNUSED;
-     aout_symbol_type *cache_ptr;
-     bfd *abfd ATTRIBUTE_UNUSED;
+convert_sym_type (struct external_nlist *sym_pointer ATTRIBUTE_UNUSED,
+		  aout_symbol_type *cache_ptr,
+		  bfd *abfd ATTRIBUTE_UNUSED)
 {
   int name_type;
   int new_type;
@@ -452,10 +441,9 @@
 */
 
 void
-NAME (aout,swap_exec_header_in) (abfd, raw_bytes, execp)
-     bfd *abfd;
-     struct external_exec *raw_bytes;
-     struct internal_exec *execp;
+NAME (aout,swap_exec_header_in) (bfd *abfd,
+				 struct external_exec *raw_bytes,
+				 struct internal_exec *execp)
 {
   struct external_exec *bytes = (struct external_exec *) raw_bytes;
 
@@ -536,8 +524,7 @@
 */
 
 bfd_boolean
-MY (slurp_symbol_table) (abfd)
-     bfd *abfd;
+MY (slurp_symbol_table) (bfd *abfd)
 {
   bfd_size_type symbol_bytes;
   struct external_nlist *syms;
@@ -559,7 +546,7 @@
     return FALSE;
   syms = (struct external_nlist *) (strings + SYM_EXTRA_BYTES);
   if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
-      || bfd_bread ((PTR) syms, symbol_bytes, abfd) != symbol_bytes)
+      || bfd_bread (syms, symbol_bytes, abfd) != symbol_bytes)
     {
       bfd_release (abfd, syms);
       return FALSE;
@@ -640,12 +627,11 @@
 }
 
 void
-MY (swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
-     bfd *abfd;
-     struct hp300hpux_reloc *bytes;
-     arelent *cache_ptr;
-     asymbol **symbols;
-     bfd_size_type symcount ATTRIBUTE_UNUSED;
+MY (swap_std_reloc_in) (bfd *abfd,
+			struct hp300hpux_reloc *bytes,
+			arelent *cache_ptr,
+			asymbol **symbols,
+			bfd_size_type symcount ATTRIBUTE_UNUSED)
 {
   int r_index;
   int r_extern = 0;
@@ -719,14 +705,11 @@
 }
 
 bfd_boolean
-MY (slurp_reloc_table) (abfd, asect, symbols)
-     bfd *abfd;
-     sec_ptr asect;
-     asymbol **symbols;
+MY (slurp_reloc_table) (bfd *abfd, sec_ptr asect, asymbol **symbols)
 {
   bfd_size_type count;
   bfd_size_type reloc_size;
-  PTR relocs;
+  void * relocs;
   arelent *reloc_cache;
   size_t each_size;
   struct hp300hpux_reloc *rptr;
@@ -765,7 +748,7 @@
   if (!reloc_cache && count != 0)
     return FALSE;
 
-  relocs = (PTR) bfd_alloc (abfd, reloc_size);
+  relocs = bfd_alloc (abfd, reloc_size);
   if (!relocs && reloc_size != 0)
     {
       bfd_release (abfd, reloc_cache);
@@ -801,18 +784,12 @@
 /* call aout_32 versions if the input file was generated by gcc         */
 /************************************************************************/
 
-long aout_32_canonicalize_symtab
-  PARAMS ((bfd * abfd, asymbol ** location));
-long aout_32_get_symtab_upper_bound
-  PARAMS ((bfd * abfd));
-long aout_32_canonicalize_reloc
-  PARAMS ((bfd * abfd, sec_ptr section, arelent ** relptr,
-	   asymbol ** symbols));
+long aout_32_canonicalize_symtab  (bfd *, asymbol **);
+long aout_32_get_symtab_upper_bound  (bfd *);
+long aout_32_canonicalize_reloc  (bfd *, sec_ptr, arelent **, asymbol **);
 
 long
-MY (canonicalize_symtab) (abfd, location)
-     bfd *abfd;
-     asymbol **location;
+MY (canonicalize_symtab) (bfd *abfd, asymbol **location)
 {
   unsigned int counter = 0;
   aout_symbol_type *symbase;
@@ -830,8 +807,7 @@
 }
 
 long
-MY (get_symtab_upper_bound) (abfd)
-     bfd *abfd;
+MY (get_symtab_upper_bound) (bfd *abfd)
 {
   if (obj_aout_subformat (abfd) == gnu_encap_format)
     return aout_32_get_symtab_upper_bound (abfd);
@@ -842,14 +818,14 @@
 }
 
 long
-MY (canonicalize_reloc) (abfd, section, relptr, symbols)
-     bfd *abfd;
-     sec_ptr section;
-     arelent **relptr;
-     asymbol **symbols;
+MY (canonicalize_reloc) (bfd *abfd,
+			 sec_ptr section,
+			 arelent **relptr,
+			 asymbol **symbols)
 {
   arelent *tblptr = section->relocation;
   unsigned int count;
+
   if (obj_aout_subformat (abfd) == gnu_encap_format)
     return aout_32_canonicalize_reloc (abfd, section, relptr, symbols);
 
diff --git a/bfd/hppabsd-core.c b/bfd/hppabsd-core.c
index 152d464..c9e0985 100644
--- a/bfd/hppabsd-core.c
+++ b/bfd/hppabsd-core.c
@@ -1,6 +1,6 @@
 /* BFD back-end for HPPA BSD core files.
    Copyright 1993, 1994, 1995, 1998, 1999, 2001, 2002, 2003, 2004, 2005,
-   2006, 2007 Free Software Foundation, Inc.
+   2006, 2007, 2012 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -49,46 +49,34 @@
 #include <sys/user.h>		/* After a.out.h  */
 #include <sys/file.h>
 
-static asection *make_bfd_asection
-  PARAMS ((bfd *, const char *, flagword, bfd_size_type, file_ptr,
-	   unsigned int));
-static const bfd_target *hppabsd_core_core_file_p
-  PARAMS ((bfd *));
-static char *hppabsd_core_core_file_failing_command
-  PARAMS ((bfd *));
-static int hppabsd_core_core_file_failing_signal
-  PARAMS ((bfd *));
 #define hppabsd_core_core_file_matches_executable_p generic_core_file_matches_executable_p
 #define hppabsd_core_core_file_pid _bfd_nocore_core_file_pid
-static void swap_abort
-  PARAMS ((void));
 
 /* These are stored in the bfd's tdata.  */
 
 struct hppabsd_core_struct
-  {
-    int sig;
-    char cmd[MAXCOMLEN + 1];
-    asection *data_section;
-    asection *stack_section;
-    asection *reg_section;
-  };
+{
+  int sig;
+  char cmd[MAXCOMLEN + 1];
+  asection *data_section;
+  asection *stack_section;
+  asection *reg_section;
+};
 
 #define core_hdr(bfd) ((bfd)->tdata.hppabsd_core_data)
-#define core_signal(bfd) (core_hdr(bfd)->sig)
-#define core_command(bfd) (core_hdr(bfd)->cmd)
-#define core_datasec(bfd) (core_hdr(bfd)->data_section)
+#define core_signal(bfd)   (core_hdr(bfd)->sig)
+#define core_command(bfd)  (core_hdr(bfd)->cmd)
+#define core_datasec(bfd)  (core_hdr(bfd)->data_section)
 #define core_stacksec(bfd) (core_hdr(bfd)->stack_section)
-#define core_regsec(bfd) (core_hdr(bfd)->reg_section)
+#define core_regsec(bfd)   (core_hdr(bfd)->reg_section)
 
 static asection *
-make_bfd_asection (abfd, name, flags, size, offset, alignment_power)
-     bfd *abfd;
-     const char *name;
-     flagword flags;
-     bfd_size_type size;
-     file_ptr offset;
-     unsigned int alignment_power;
+make_bfd_asection (bfd *abfd,
+		   const char *name,
+		   flagword flags,
+		   bfd_size_type size,
+		   file_ptr offset,
+		   unsigned int alignment_power)
 {
   asection *asect;
 
@@ -104,8 +92,7 @@
 }
 
 static const bfd_target *
-hppabsd_core_core_file_p (abfd)
-     bfd *abfd;
+hppabsd_core_core_file_p (bfd *abfd)
 {
   int val;
   struct user u;
@@ -205,22 +192,20 @@
 }
 
 static char *
-hppabsd_core_core_file_failing_command (abfd)
-     bfd *abfd;
+hppabsd_core_core_file_failing_command (bfd *abfd)
 {
   return core_command (abfd);
 }
 
 static int
-hppabsd_core_core_file_failing_signal (abfd)
-     bfd *abfd;
+hppabsd_core_core_file_failing_signal (bfd *abfd)
 {
   return core_signal (abfd);
 }
 
 /* If somebody calls any byte-swapping routines, shoot them.  */
 static void
-swap_abort ()
+swap_abort (void)
 {
   /* This way doesn't require any declaration for ANSI to fuck up.  */
   abort ();
@@ -280,6 +265,6 @@
 
     NULL,
 
-    (PTR) 0			/* backend_data */
+    NULL			/* backend_data */
   };
 #endif
diff --git a/bfd/hpux-core.c b/bfd/hpux-core.c
index 3e8fd83..3731210 100644
--- a/bfd/hpux-core.c
+++ b/bfd/hpux-core.c
@@ -1,6 +1,6 @@
 /* BFD back-end for HP/UX core files.
    Copyright 1993, 1994, 1996, 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007, 2008, 2010, 2011 Free Software Foundation, Inc.
+   2007, 2008, 2010, 2011, 2012  Free Software Foundation, Inc.
    Written by Stu Grossman, Cygnus Support.
    Converted to back-end form by Ian Lance Taylor, Cygnus SUpport
 
@@ -425,5 +425,5 @@
 
     NULL,
 
-    (PTR) 0			/* backend_data */
+    NULL			/* backend_data */
   };
diff --git a/bfd/i386dynix.c b/bfd/i386dynix.c
index 30d2450..a33571e 100644
--- a/bfd/i386dynix.c
+++ b/bfd/i386dynix.c
@@ -1,5 +1,6 @@
 /* BFD back-end for i386 a.out binaries under dynix.
-   Copyright 1994, 1995, 2001, 2003, 2005, 2007 Free Software Foundation, Inc.
+   Copyright 1994, 1995, 2001, 2003, 2005, 2007, 2012
+   Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -55,10 +56,9 @@
 #define a_shdrsize a_dload
 
 void
-i386dynix_32_swap_exec_header_in (abfd, raw_bytes, execp)
-     bfd *abfd;
-     struct external_exec *raw_bytes;
-     struct internal_exec *execp;
+i386dynix_32_swap_exec_header_in (bfd *abfd,
+				  struct external_exec *raw_bytes,
+				  struct internal_exec *execp)
 {
   struct external_exec *bytes = (struct external_exec *)raw_bytes;
 
@@ -66,7 +66,7 @@
      configuration (IE for i960), so ensure that all such uninitialized
      fields are zero'd out.  There are places where two of these structs
      are memcmp'd, and thus the contents do matter. */
-  memset ((PTR) execp, 0, sizeof (struct internal_exec));
+  memset (execp, 0, sizeof (struct internal_exec));
   /* Now fill in fields in the execp, from the bytes in the raw data.  */
   execp->a_info   = H_GET_32 (abfd, bytes->e_info);
   execp->a_text   = GET_WORD (abfd, bytes->e_text);
diff --git a/bfd/i386linux.c b/bfd/i386linux.c
index 03a2dbe..65ae5c9 100644
--- a/bfd/i386linux.c
+++ b/bfd/i386linux.c
@@ -1,6 +1,7 @@
 /* BFD back-end for linux flavored i386 a.out binaries.
    Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2001, 2002, 2003,
-   2004, 2005, 2006, 2007, 2008, 2009, 2011 Free Software Foundation, Inc.
+   2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012
+   Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -49,15 +50,13 @@
    becomes important.  */
 
 static void MY_final_link_callback
-  PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
+  (bfd *, file_ptr *, file_ptr *, file_ptr *);
 static bfd_boolean i386linux_bfd_final_link
-  PARAMS ((bfd *, struct bfd_link_info *));
-static bfd_boolean i386linux_write_object_contents PARAMS ((bfd *));
+  (bfd *, struct bfd_link_info *);
+static bfd_boolean i386linux_write_object_contents (bfd *);
 
 static bfd_boolean
-i386linux_bfd_final_link (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info;
+i386linux_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
 {
   obj_aout_subformat (abfd) = q_magic_format;
   return NAME(aout,final_link) (abfd, info, MY_final_link_callback);
@@ -68,8 +67,7 @@
 /* Set the machine type correctly.  */
 
 static bfd_boolean
-i386linux_write_object_contents (abfd)
-     bfd *abfd;
+i386linux_write_object_contents (bfd *abfd)
 {
   struct external_exec exec_bytes;
   struct internal_exec *execp = exec_hdr (abfd);
@@ -169,31 +167,12 @@
   struct fixup *fixup_list;
 };
 
-static struct bfd_hash_entry *linux_link_hash_newfunc
-  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static struct bfd_link_hash_table *linux_link_hash_table_create
-  PARAMS ((bfd *));
-static struct fixup *new_fixup
-  PARAMS ((struct bfd_link_info *, struct linux_link_hash_entry *,
-	   bfd_vma, int));
-static bfd_boolean linux_link_create_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-static bfd_boolean linux_add_one_symbol
-  PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword, asection *,
-	   bfd_vma, const char *, bfd_boolean, bfd_boolean,
-	   struct bfd_link_hash_entry **));
-static bfd_boolean linux_tally_symbols
-  PARAMS ((struct linux_link_hash_entry *, PTR));
-static bfd_boolean linux_finish_dynamic_link
-  PARAMS ((bfd *, struct bfd_link_info *));
-
 /* Routine to create an entry in an Linux link hash table.  */
 
 static struct bfd_hash_entry *
-linux_link_hash_newfunc (entry, table, string)
-     struct bfd_hash_entry *entry;
-     struct bfd_hash_table *table;
-     const char *string;
+linux_link_hash_newfunc (struct bfd_hash_entry *entry,
+			 struct bfd_hash_table *table,
+			 const char *string)
 {
   struct linux_link_hash_entry *ret = (struct linux_link_hash_entry *) entry;
 
@@ -220,13 +199,12 @@
 /* Create a Linux link hash table.  */
 
 static struct bfd_link_hash_table *
-linux_link_hash_table_create (abfd)
-     bfd *abfd;
+linux_link_hash_table_create (bfd *abfd)
 {
   struct linux_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct linux_link_hash_table);
 
-  ret = (struct linux_link_hash_table *) bfd_alloc (abfd, amt);
+  ret = (struct linux_link_hash_table *) bfd_zmalloc (amt);
   if (ret == (struct linux_link_hash_table *) NULL)
     return (struct bfd_link_hash_table *) NULL;
   if (!NAME(aout,link_hash_table_init) (&ret->root, abfd,
@@ -237,11 +215,6 @@
       return (struct bfd_link_hash_table *) NULL;
     }
 
-  ret->dynobj = NULL;
-  ret->fixup_count = 0;
-  ret->local_builtins = 0;
-  ret->fixup_list = NULL;
-
   return &ret->root.root;
 }
 
@@ -257,7 +230,7 @@
 #define linux_link_hash_traverse(table, func, info)			\
   (aout_link_hash_traverse						\
    (&(table)->root,							\
-    (bfd_boolean (*) PARAMS ((struct aout_link_hash_entry *, PTR))) (func), \
+    (bfd_boolean (*) (struct aout_link_hash_entry *, void *)) (func),   \
     (info)))
 
 /* Get the Linux link hash table from the info structure.  This is
@@ -268,11 +241,10 @@
 /* Store the information for a new fixup.  */
 
 static struct fixup *
-new_fixup (info, h, value, builtin)
-     struct bfd_link_info *info;
-     struct linux_link_hash_entry *h;
-     bfd_vma value;
-     int builtin;
+new_fixup (struct bfd_link_info *info,
+	   struct linux_link_hash_entry *h,
+	   bfd_vma value,
+	   int builtin)
 {
   struct fixup *f;
 
@@ -298,12 +270,11 @@
    create it for now.  */
 
 static bfd_boolean
-linux_link_create_dynamic_sections (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
+linux_link_create_dynamic_sections (bfd *abfd,
+				    struct bfd_link_info *info ATTRIBUTE_UNUSED)
 {
   flagword flags;
-  register asection *s;
+  asection *s;
 
   /* Note that we set the SEC_IN_MEMORY flag.  */
   flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
@@ -325,18 +296,16 @@
    tweaking needed for dynamic linking support.  */
 
 static bfd_boolean
-linux_add_one_symbol (info, abfd, name, flags, section, value, string,
-		      copy, collect, hashp)
-     struct bfd_link_info *info;
-     bfd *abfd;
-     const char *name;
-     flagword flags;
-     asection *section;
-     bfd_vma value;
-     const char *string;
-     bfd_boolean copy;
-     bfd_boolean collect;
-     struct bfd_link_hash_entry **hashp;
+linux_add_one_symbol (struct bfd_link_info *info,
+		      bfd *abfd,
+		      const char *name,
+		      flagword flags,
+		      asection *section,
+		      bfd_vma value,
+		      const char *string,
+		      bfd_boolean copy,
+		      bfd_boolean collect,
+		      struct bfd_link_hash_entry **hashp)
 {
   struct linux_link_hash_entry *h;
   bfd_boolean insert;
@@ -425,9 +394,7 @@
    This function is called via linux_link_hash_traverse.  */
 
 static bfd_boolean
-linux_tally_symbols (h, data)
-     struct linux_link_hash_entry *h;
-     PTR data;
+linux_tally_symbols (struct linux_link_hash_entry *h, void * data)
 {
   struct bfd_link_info *info = (struct bfd_link_info *) data;
   struct fixup *f, *f1;
@@ -548,9 +515,8 @@
    are required.  */
 
 bfd_boolean
-bfd_i386linux_size_dynamic_sections (output_bfd, info)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
+bfd_i386linux_size_dynamic_sections (bfd *output_bfd,
+				     struct bfd_link_info *info)
 {
   struct fixup *f;
   asection *s;
@@ -561,7 +527,7 @@
   /* First find the fixups... */
   linux_link_hash_traverse (linux_hash_table (info),
 			    linux_tally_symbols,
-			    (PTR) info);
+			    info);
 
   /* If there are builtin fixups, leave room for a marker.  This is
      used by the dynamic linker so that it knows that all that follow
@@ -603,9 +569,8 @@
    the stuff we need.  */
 
 static bfd_boolean
-linux_finish_dynamic_link (output_bfd, info)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
+linux_finish_dynamic_link (bfd *output_bfd,
+			   struct bfd_link_info *info)
 {
   asection *s, *os, *is;
   bfd_byte *fixup_table;
@@ -755,7 +720,7 @@
 		SEEK_SET) != 0)
     return FALSE;
 
-  if (bfd_bwrite ((PTR) s->contents, s->size, output_bfd) != s->size)
+  if (bfd_bwrite (s->contents, s->size, output_bfd) != s->size)
     return FALSE;
 
   return TRUE;
diff --git a/bfd/i386lynx.c b/bfd/i386lynx.c
index 0a1b854..d373e2a 100644
--- a/bfd/i386lynx.c
+++ b/bfd/i386lynx.c
@@ -1,6 +1,6 @@
 /* BFD back-end for i386 a.out binaries under LynxOS.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2001, 2002,
-   2003, 2005, 2007, 2009, 2010 Free Software Foundation, Inc.
+   2003, 2005, 2007, 2009, 2010, 2012  Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -52,7 +52,7 @@
 	NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes);	      \
 									      \
 	if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0		      \
-	    || bfd_bwrite ((PTR) &exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, \
+	    || bfd_bwrite (&exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, \
 			  abfd) != EXEC_BYTES_SIZE)			      \
 	  return FALSE;							      \
 	/* Now write out reloc info, followed by syms and strings */	      \
@@ -84,22 +84,6 @@
 #include "libaout.h"
 #include "aout/aout64.h"
 
-void NAME (lynx,swap_std_reloc_out)
-  PARAMS ((bfd *, arelent *, struct reloc_std_external *));
-void NAME (lynx,swap_ext_reloc_out)
-  PARAMS ((bfd *, arelent *, struct reloc_ext_external *));
-void NAME (lynx,swap_ext_reloc_in)
-  PARAMS ((bfd *, struct reloc_ext_external *, arelent *, asymbol **,
-	   bfd_size_type));
-void NAME (lynx,swap_std_reloc_in)
-  PARAMS ((bfd *, struct reloc_std_external *, arelent *, asymbol **,
-	   bfd_size_type));
-bfd_boolean NAME (lynx,slurp_reloc_table)
-  PARAMS ((bfd *, sec_ptr, asymbol **));
-bfd_boolean NAME (lynx,squirt_out_relocs)
-  PARAMS ((bfd *, asection *));
-long NAME (lynx,canonicalize_reloc)
-  PARAMS ((bfd *, sec_ptr, arelent **, asymbol **));
 
 #ifdef LYNX_CORE
 
@@ -124,11 +108,10 @@
 /* Standard reloc stuff */
 /* Output standard relocation information to a file in target byte order. */
 
-void
-NAME(lynx,swap_std_reloc_out) (abfd, g, natptr)
-     bfd *abfd;
-     arelent *g;
-     struct reloc_std_external *natptr;
+static void
+NAME(lynx,swap_std_reloc_out) (bfd *abfd,
+			       arelent *g,
+			       struct reloc_std_external *natptr)
 {
   int r_index;
   asymbol *sym = *(g->sym_ptr_ptr);
@@ -157,7 +140,6 @@
      check for that here
   */
 
-
   if (bfd_is_com_section (output_section)
       || bfd_is_abs_section (output_section)
       || bfd_is_und_section (output_section))
@@ -216,11 +198,10 @@
 /* Extended stuff */
 /* Output extended relocation information to a file in target byte order. */
 
-void
-NAME(lynx,swap_ext_reloc_out) (abfd, g, natptr)
-     bfd *abfd;
-     arelent *g;
-     register struct reloc_ext_external *natptr;
+static void
+NAME(lynx,swap_ext_reloc_out) (bfd *abfd,
+			       arelent *g,
+			       struct reloc_ext_external *natptr)
 {
   int r_index;
   int r_extern;
@@ -302,11 +283,14 @@
 
 
 #define MOVE_ADDRESS(ad)       						\
-  if (r_extern) {							\
+  if (r_extern)								\
+    {									\
    /* undefined symbol */						\
      cache_ptr->sym_ptr_ptr = symbols + r_index;			\
      cache_ptr->addend = ad;						\
-     } else {								\
+    }									\
+  else									\
+    {									\
     /* defined, section relative. replace symbol with pointer to    	\
        symbol which points to section  */				\
     switch (r_index) {							\
@@ -334,13 +318,12 @@
     }									\
   }     								\
 
-void
-NAME(lynx,swap_ext_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
-     bfd *abfd;
-     struct reloc_ext_external *bytes;
-     arelent *cache_ptr;
-     asymbol **symbols;
-     bfd_size_type symcount ATTRIBUTE_UNUSED;
+static void
+NAME(lynx,swap_ext_reloc_in) (bfd *abfd,
+			      struct reloc_ext_external *bytes,
+			      arelent *cache_ptr,
+			      asymbol **symbols,
+			      bfd_size_type symcount ATTRIBUTE_UNUSED)
 {
   int r_index;
   int r_extern;
@@ -358,13 +341,12 @@
   MOVE_ADDRESS (GET_SWORD (abfd, bytes->r_addend));
 }
 
-void
-NAME(lynx,swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount)
-     bfd *abfd;
-     struct reloc_std_external *bytes;
-     arelent *cache_ptr;
-     asymbol **symbols;
-     bfd_size_type symcount ATTRIBUTE_UNUSED;
+static void
+NAME(lynx,swap_std_reloc_in) (bfd *abfd,
+			      struct reloc_std_external *bytes,
+			      arelent *cache_ptr,
+			      asymbol **symbols,
+			      bfd_size_type symcount ATTRIBUTE_UNUSED)
 {
   int r_index;
   int r_extern;
@@ -388,15 +370,14 @@
 
 /* Reloc hackery */
 
-bfd_boolean
-NAME(lynx,slurp_reloc_table) (abfd, asect, symbols)
-     bfd *abfd;
-     sec_ptr asect;
-     asymbol **symbols;
+static bfd_boolean
+NAME(lynx,slurp_reloc_table) (bfd *abfd,
+			      sec_ptr asect,
+			      asymbol **symbols)
 {
   bfd_size_type count;
   bfd_size_type reloc_size;
-  PTR relocs;
+  void * relocs;
   arelent *reloc_cache;
   size_t each_size;
 
@@ -433,7 +414,7 @@
   if (!reloc_cache && count != 0)
     return FALSE;
 
-  relocs = (PTR) bfd_alloc (abfd, reloc_size);
+  relocs = bfd_alloc (abfd, reloc_size);
   if (!relocs && reloc_size != 0)
     {
       free (reloc_cache);
@@ -449,7 +430,7 @@
 
   if (each_size == RELOC_EXT_SIZE)
     {
-      register struct reloc_ext_external *rptr = (struct reloc_ext_external *) relocs;
+      struct reloc_ext_external *rptr = (struct reloc_ext_external *) relocs;
       unsigned int counter = 0;
       arelent *cache_ptr = reloc_cache;
 
@@ -461,7 +442,7 @@
     }
   else
     {
-      register struct reloc_std_external *rptr = (struct reloc_std_external *) relocs;
+      struct reloc_std_external *rptr = (struct reloc_std_external *) relocs;
       unsigned int counter = 0;
       arelent *cache_ptr = reloc_cache;
 
@@ -483,15 +464,12 @@
 
 /* Write out a relocation section into an object file.  */
 
-bfd_boolean
-NAME(lynx,squirt_out_relocs) (abfd, section)
-     bfd *abfd;
-     asection *section;
+static bfd_boolean
+NAME(lynx,squirt_out_relocs) (bfd *abfd, asection *section)
 {
   arelent **generic;
   unsigned char *native, *natptr;
   size_t each_size;
-
   unsigned int count = section->reloc_count;
   bfd_size_type natsize;
 
@@ -522,7 +500,7 @@
 	NAME(lynx,swap_std_reloc_out) (abfd, *generic, (struct reloc_std_external *) natptr);
     }
 
-  if (bfd_bwrite ((PTR) native, natsize, abfd) != natsize)
+  if (bfd_bwrite (native, natsize, abfd) != natsize)
     {
       bfd_release (abfd, native);
       return FALSE;
@@ -533,12 +511,11 @@
 }
 
 /* This is stupid.  This function should be a boolean predicate */
-long
-NAME(lynx,canonicalize_reloc) (abfd, section, relptr, symbols)
-     bfd *abfd;
-     sec_ptr section;
-     arelent **relptr;
-     asymbol **symbols;
+static long
+NAME(lynx,canonicalize_reloc) (bfd *abfd,
+			       sec_ptr section,
+			       arelent **relptr,
+			       asymbol **symbols)
 {
   arelent *tblptr = section->relocation;
   unsigned int count;
diff --git a/bfd/i386mach3.c b/bfd/i386mach3.c
index 8402bdf..74b5e5e 100644
--- a/bfd/i386mach3.c
+++ b/bfd/i386mach3.c
@@ -1,6 +1,6 @@
 /* BFD back-end for i386 a.out binaries.
-   Copyright 1990, 1991, 1993, 1994, 1995, 1997, 2001, 2002, 2003, 2005, 2007
-   Free Software Foundation, Inc.
+   Copyright 1990, 1991, 1993, 1994, 1995, 1997, 2001, 2002, 2003, 2005, 2007,
+   2012  Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -51,9 +51,11 @@
 #define MY(OP) CONCAT2 (i386mach3_,OP)
 #define TARGETNAME "a.out-mach3"
 
-static bfd_boolean MY (set_sizes) PARAMS ((bfd *));
+static bfd_boolean MY (set_sizes) (bfd *);
 #define MY_backend_data &MY(backend_data)
-static const struct aout_backend_data MY(backend_data) = {
+
+static const struct aout_backend_data MY(backend_data) =
+{
   0,				/* zmagic contiguous */
   1,				/* text incl header */
   0,				/* entry is text address */
diff --git a/bfd/i386msdos.c b/bfd/i386msdos.c
index b67b13e..ed7d896 100644
--- a/bfd/i386msdos.c
+++ b/bfd/i386msdos.c
@@ -1,6 +1,7 @@
 /* BFD back-end for MS-DOS executables.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2001, 2002,
-   2003, 2004, 2005, 2006, 2007, 2009, 2011 Free Software Foundation, Inc.
+   2003, 2004, 2005, 2006, 2007, 2009, 2011, 2012
+   Free Software Foundation, Inc.
    Written by Bryan Ford of the University of Utah.
 
    Contributed by the Center for Software Science at the
@@ -228,7 +229,7 @@
 
     NULL,
 
-    (PTR) 0
+    NULL
   };
 
 
diff --git a/bfd/i386os9k.c b/bfd/i386os9k.c
index 3beb8a3..cea63bd 100644
--- a/bfd/i386os9k.c
+++ b/bfd/i386os9k.c
@@ -1,6 +1,6 @@
 /* BFD back-end for os9000 i386 binaries.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2001, 2002,
-   2004, 2005, 2006, 2007, 2009, 2011 Free Software Foundation, Inc.
+   2004, 2005, 2006, 2007, 2009, 2011, 2012  Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -120,7 +120,7 @@
   struct internal_exec anexec;
   mh_com exec_bytes;
 
-  if (bfd_bread ((PTR) &exec_bytes, (bfd_size_type) MHCOM_BYTES_SIZE, abfd)
+  if (bfd_bread (&exec_bytes, (bfd_size_type) MHCOM_BYTES_SIZE, abfd)
       != MHCOM_BYTES_SIZE)
     {
       if (bfd_get_error () != bfd_error_system_call)
@@ -221,5 +221,5 @@
 
     NULL,
 
-    (PTR) 0,
+    NULL,
   };
diff --git a/bfd/ieee.c b/bfd/ieee.c
index de1e926..b93fdeb 100644
--- a/bfd/ieee.c
+++ b/bfd/ieee.c
@@ -1662,7 +1662,7 @@
   unsigned int section_number;
   ieee_per_section_type *current_map = NULL;
   asection *s;
-  
+
   /* Seek to the start of the data area.  */
   if (ieee->read_data)
     return TRUE;
diff --git a/bfd/irix-core.c b/bfd/irix-core.c
index 7fd5109..9a39929 100644
--- a/bfd/irix-core.c
+++ b/bfd/irix-core.c
@@ -1,6 +1,6 @@
 /* BFD back-end for Irix core files.
    Copyright 1993, 1994, 1996, 1999, 2001, 2002, 2004, 2005, 2006, 2007,
-   2010, 2011 Free Software Foundation, Inc.
+   2010, 2011, 2012  Free Software Foundation, Inc.
    Written by Stu Grossman, Cygnus Support.
    Converted to back-end form by Ian Lance Taylor, Cygnus Support
 
@@ -62,7 +62,7 @@
 
   for (i = 0; i < coreout->c_nvmap; i++)
     {
-      val = bfd_bread ((PTR) &vmap, (bfd_size_type) sizeof vmap, abfd);
+      val = bfd_bread (&vmap, (bfd_size_type) sizeof vmap, abfd);
       if (val != sizeof vmap)
 	break;
 
@@ -110,7 +110,7 @@
 
   for (i = 0; i < coreout->c_nvmap; i++)
     {
-      val = bfd_bread ((PTR) &vmap, (bfd_size_type) sizeof vmap, abfd);
+      val = bfd_bread (&vmap, (bfd_size_type) sizeof vmap, abfd);
       if (val != sizeof vmap)
 	break;
 
@@ -175,7 +175,7 @@
   struct idesc *idg, *idf, *ids;
   bfd_size_type amt;
 
-  val = bfd_bread ((PTR) &coreout, (bfd_size_type) sizeof coreout, abfd);
+  val = bfd_bread (&coreout, (bfd_size_type) sizeof coreout, abfd);
   if (val != sizeof coreout)
     {
       if (bfd_get_error () != bfd_error_system_call)
@@ -328,7 +328,7 @@
 
     NULL,
 
-    (PTR) 0			/* backend_data */
+    NULL			/* backend_data */
   };
 
 #endif /* IRIX_CORE */
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index 99654b5..52c1f5f 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -3,7 +3,7 @@
 
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
    1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-   2010, 2011
+   2010, 2011, 2012
    Free Software Foundation, Inc.
 
    Written by Cygnus Support.
@@ -64,16 +64,17 @@
 /* tdata for an archive.  For an input archive, cache
    needs to be free()'d.  For an output archive, symdefs do.  */
 
-struct artdata {
+struct artdata
+{
   file_ptr first_file_filepos;
   /* Speed up searching the armap */
   htab_t cache;
-  bfd *archive_head;		/* Only interesting in output routines */
-  carsym *symdefs;		/* the symdef entries */
-  symindex symdef_count;	/* how many there are */
-  char *extended_names;		/* clever intel extension */
-  bfd_size_type extended_names_size; /* Size of extended names */
-  /* when more compilers are standard C, this can be a time_t */
+  bfd *archive_head;		/* Only interesting in output routines.  */
+  carsym *symdefs;		/* The symdef entries.  */
+  symindex symdef_count;	/* How many there are.  */
+  char *extended_names;		/* Clever intel extension.  */
+  bfd_size_type extended_names_size; /* Size of extended names.  */
+  /* When more compilers are standard C, this can be a time_t.  */
   long  armap_timestamp;	/* Timestamp value written into armap.
 				   This is used for BSD archives to check
 				   that the timestamp is recent enough
@@ -88,12 +89,15 @@
 #define bfd_ardata(bfd) ((bfd)->tdata.aout_ar_data)
 
 /* Goes in bfd's arelt_data slot */
-struct areltdata {
-  char * arch_header;		/* it's actually a string */
-  unsigned int parsed_size;	/* octets of filesize not including ar_hdr */
-  unsigned int extra_size;	/* BSD4.4: extra bytes after the header.  */
-  char *filename;		/* null-terminated */
-  file_ptr origin;		/* for element of a thin archive */
+struct areltdata
+{
+  char * arch_header;		/* It's actually a string.  */
+  bfd_size_type parsed_size;	/* Octets of filesize not including ar_hdr.  */
+  bfd_size_type extra_size;	/* BSD4.4: extra bytes after the header.  */
+  char *filename;		/* Null-terminated.  */
+  file_ptr origin;		/* For element of a thin archive.  */
+  void *parent_cache;		/* Where and how to find this member.  */
+  file_ptr key;
 };
 
 #define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size)
@@ -115,6 +119,7 @@
 
 extern void _bfd_default_error_handler (const char *s, ...);
 extern bfd_error_handler_type _bfd_error_handler;
+extern bfd_assert_handler_type _bfd_assert_handler;
 
 /* These routines allocate and free things on the BFD's objalloc.  */
 
@@ -157,8 +162,6 @@
   (bfd *, symindex);
 bfd * _bfd_new_bfd
   (void);
-void _bfd_delete_bfd
-  (bfd *);
 bfd_boolean _bfd_free_cached_info
   (bfd *);
 
@@ -203,6 +206,8 @@
   (bfd *);
 extern void _bfd_ar_spacepad
   (char *, size_t, const char *, long);
+extern bfd_boolean _bfd_ar_sizepad
+  (char *, size_t, bfd_size_type);
 
 extern void *_bfd_generic_read_ar_hdr_mag
   (bfd *, const char *);
@@ -227,7 +232,9 @@
 /* Generic routines to use for BFD_JUMP_TABLE_GENERIC.  Use
    BFD_JUMP_TABLE_GENERIC (_bfd_generic).  */
 
-#define _bfd_generic_close_and_cleanup bfd_true
+#define _bfd_generic_close_and_cleanup _bfd_archive_close_and_cleanup
+extern bfd_boolean _bfd_archive_close_and_cleanup
+  (bfd *);
 #define _bfd_generic_bfd_free_cached_info bfd_true
 extern bfd_boolean _bfd_generic_new_section_hook
   (bfd *, asection *);
@@ -454,7 +461,7 @@
   ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) \
    bfd_false)
 #define _bfd_nolink_bfd_lookup_section_flags \
-  ((void (*) (struct bfd_link_info *, struct flag_info *)) \
+  ((bfd_boolean (*) (struct bfd_link_info *, struct flag_info *, asection *)) \
    bfd_0)
 #define _bfd_nolink_bfd_merge_sections \
   ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) \
@@ -521,10 +528,22 @@
   (bfd *, asection *, asymbol **, bfd_vma, const char **,
    const char **, unsigned int *);
 
+struct dwarf_debug_section
+{
+  const char *uncompressed_name;
+  const char *compressed_name;
+};
+
+/* Map of uncompressed DWARF debug section name to compressed one.  It
+   is terminated by NULL uncompressed_name.  */
+
+extern const struct dwarf_debug_section dwarf_debug_sections[];
+
 /* Find the nearest line using DWARF 2 debugging information.  */
 extern bfd_boolean _bfd_dwarf2_find_nearest_line
-  (bfd *, asection *, asymbol **, bfd_vma, const char **, const char **,
-   unsigned int *, unsigned int *, unsigned int, void **);
+  (bfd *, const struct dwarf_debug_section *, asection *, asymbol **, bfd_vma,
+   const char **, const char **, unsigned int *, unsigned int *, unsigned int,
+   void **);
 
 /* Find the line using DWARF 2 debugging information.  */
 extern bfd_boolean _bfd_dwarf2_find_line
@@ -541,7 +560,15 @@
 /* Find inliner info after calling bfd_find_nearest_line. */
 extern bfd_boolean _bfd_dwarf2_find_inliner_info
   (bfd *, const char **, const char **, unsigned int *, void **);
-  
+
+/* Read DWARF 2 debugging information. */
+extern bfd_boolean _bfd_dwarf2_slurp_debug_info
+  (bfd *, bfd *, const struct dwarf_debug_section *, asymbol **, void **);
+
+/* Clean up the data used to handle DWARF 2 debugging information. */
+extern void _bfd_dwarf2_cleanup_debug_info
+  (bfd *, void **);
+
 /* Create a new section entry.  */
 extern struct bfd_hash_entry *bfd_section_hash_newfunc
   (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
@@ -680,6 +707,10 @@
 extern bfd_vma _bfd_merged_section_offset
   (bfd *, asection **, void *, bfd_vma);
 
+/* Tidy up when done.  */
+
+extern void _bfd_merge_sections_free (void *);
+
 /* Create a string table.  */
 extern struct bfd_strtab_hash *_bfd_stringtab_init
   (void);
@@ -815,14 +846,3 @@
 
 extern bfd_vma read_unsigned_leb128 (bfd *, bfd_byte *, unsigned int *);
 extern bfd_signed_vma read_signed_leb128 (bfd *, bfd_byte *, unsigned int *);
-
-struct dwarf_debug_section
-{
-  const char *uncompressed_name;
-  const char *compressed_name;
-};
-
-/* Map of uncompressed DWARF debug section name to compressed one.  It
-   is terminated by NULL uncompressed_name.  */
-
-extern const struct dwarf_debug_section dwarf_debug_sections[];
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 548006a..4aaecbf 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -8,7 +8,7 @@
 
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
    1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-   2010, 2011
+   2010, 2011, 2012
    Free Software Foundation, Inc.
 
    Written by Cygnus Support.
@@ -69,16 +69,17 @@
 /* tdata for an archive.  For an input archive, cache
    needs to be free()'d.  For an output archive, symdefs do.  */
 
-struct artdata {
+struct artdata
+{
   file_ptr first_file_filepos;
   /* Speed up searching the armap */
   htab_t cache;
-  bfd *archive_head;		/* Only interesting in output routines */
-  carsym *symdefs;		/* the symdef entries */
-  symindex symdef_count;	/* how many there are */
-  char *extended_names;		/* clever intel extension */
-  bfd_size_type extended_names_size; /* Size of extended names */
-  /* when more compilers are standard C, this can be a time_t */
+  bfd *archive_head;		/* Only interesting in output routines.  */
+  carsym *symdefs;		/* The symdef entries.  */
+  symindex symdef_count;	/* How many there are.  */
+  char *extended_names;		/* Clever intel extension.  */
+  bfd_size_type extended_names_size; /* Size of extended names.  */
+  /* When more compilers are standard C, this can be a time_t.  */
   long  armap_timestamp;	/* Timestamp value written into armap.
 				   This is used for BSD archives to check
 				   that the timestamp is recent enough
@@ -93,12 +94,15 @@
 #define bfd_ardata(bfd) ((bfd)->tdata.aout_ar_data)
 
 /* Goes in bfd's arelt_data slot */
-struct areltdata {
-  char * arch_header;		/* it's actually a string */
-  unsigned int parsed_size;	/* octets of filesize not including ar_hdr */
-  unsigned int extra_size;	/* BSD4.4: extra bytes after the header.  */
-  char *filename;		/* null-terminated */
-  file_ptr origin;		/* for element of a thin archive */
+struct areltdata
+{
+  char * arch_header;		/* It's actually a string.  */
+  bfd_size_type parsed_size;	/* Octets of filesize not including ar_hdr.  */
+  bfd_size_type extra_size;	/* BSD4.4: extra bytes after the header.  */
+  char *filename;		/* Null-terminated.  */
+  file_ptr origin;		/* For element of a thin archive.  */
+  void *parent_cache;		/* Where and how to find this member.  */
+  file_ptr key;
 };
 
 #define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size)
@@ -120,6 +124,7 @@
 
 extern void _bfd_default_error_handler (const char *s, ...);
 extern bfd_error_handler_type _bfd_error_handler;
+extern bfd_assert_handler_type _bfd_assert_handler;
 
 /* These routines allocate and free things on the BFD's objalloc.  */
 
@@ -162,8 +167,6 @@
   (bfd *, symindex);
 bfd * _bfd_new_bfd
   (void);
-void _bfd_delete_bfd
-  (bfd *);
 bfd_boolean _bfd_free_cached_info
   (bfd *);
 
@@ -208,6 +211,8 @@
   (bfd *);
 extern void _bfd_ar_spacepad
   (char *, size_t, const char *, long);
+extern bfd_boolean _bfd_ar_sizepad
+  (char *, size_t, bfd_size_type);
 
 extern void *_bfd_generic_read_ar_hdr_mag
   (bfd *, const char *);
@@ -232,7 +237,9 @@
 /* Generic routines to use for BFD_JUMP_TABLE_GENERIC.  Use
    BFD_JUMP_TABLE_GENERIC (_bfd_generic).  */
 
-#define _bfd_generic_close_and_cleanup bfd_true
+#define _bfd_generic_close_and_cleanup _bfd_archive_close_and_cleanup
+extern bfd_boolean _bfd_archive_close_and_cleanup
+  (bfd *);
 #define _bfd_generic_bfd_free_cached_info bfd_true
 extern bfd_boolean _bfd_generic_new_section_hook
   (bfd *, asection *);
@@ -459,7 +466,7 @@
   ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) \
    bfd_false)
 #define _bfd_nolink_bfd_lookup_section_flags \
-  ((void (*) (struct bfd_link_info *, struct flag_info *)) \
+  ((bfd_boolean (*) (struct bfd_link_info *, struct flag_info *, asection *)) \
    bfd_0)
 #define _bfd_nolink_bfd_merge_sections \
   ((bfd_boolean (*) (bfd *, struct bfd_link_info *)) \
@@ -526,10 +533,22 @@
   (bfd *, asection *, asymbol **, bfd_vma, const char **,
    const char **, unsigned int *);
 
+struct dwarf_debug_section
+{
+  const char *uncompressed_name;
+  const char *compressed_name;
+};
+
+/* Map of uncompressed DWARF debug section name to compressed one.  It
+   is terminated by NULL uncompressed_name.  */
+
+extern const struct dwarf_debug_section dwarf_debug_sections[];
+
 /* Find the nearest line using DWARF 2 debugging information.  */
 extern bfd_boolean _bfd_dwarf2_find_nearest_line
-  (bfd *, asection *, asymbol **, bfd_vma, const char **, const char **,
-   unsigned int *, unsigned int *, unsigned int, void **);
+  (bfd *, const struct dwarf_debug_section *, asection *, asymbol **, bfd_vma,
+   const char **, const char **, unsigned int *, unsigned int *, unsigned int,
+   void **);
 
 /* Find the line using DWARF 2 debugging information.  */
 extern bfd_boolean _bfd_dwarf2_find_line
@@ -546,7 +565,15 @@
 /* Find inliner info after calling bfd_find_nearest_line. */
 extern bfd_boolean _bfd_dwarf2_find_inliner_info
   (bfd *, const char **, const char **, unsigned int *, void **);
-  
+
+/* Read DWARF 2 debugging information. */
+extern bfd_boolean _bfd_dwarf2_slurp_debug_info
+  (bfd *, bfd *, const struct dwarf_debug_section *, asymbol **, void **);
+
+/* Clean up the data used to handle DWARF 2 debugging information. */
+extern void _bfd_dwarf2_cleanup_debug_info
+  (bfd *, void **);
+
 /* Create a new section entry.  */
 extern struct bfd_hash_entry *bfd_section_hash_newfunc
   (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
@@ -685,6 +712,10 @@
 extern bfd_vma _bfd_merged_section_offset
   (bfd *, asection **, void *, bfd_vma);
 
+/* Tidy up when done.  */
+
+extern void _bfd_merge_sections_free (void *);
+
 /* Create a string table.  */
 extern struct bfd_strtab_hash *_bfd_stringtab_init
   (void);
@@ -820,17 +851,6 @@
 
 extern bfd_vma read_unsigned_leb128 (bfd *, bfd_byte *, unsigned int *);
 extern bfd_signed_vma read_signed_leb128 (bfd *, bfd_byte *, unsigned int *);
-
-struct dwarf_debug_section
-{
-  const char *uncompressed_name;
-  const char *compressed_name;
-};
-
-/* Map of uncompressed DWARF debug section name to compressed one.  It
-   is terminated by NULL uncompressed_name.  */
-
-extern const struct dwarf_debug_section dwarf_debug_sections[];
 /* Extracted from init.c.  */
 /* Extracted from libbfd.c.  */
 bfd_boolean bfd_write_bigendian_4byte_int (bfd *, unsigned int);
@@ -924,6 +944,8 @@
   "BFD_RELOC_HI16_PLTOFF",
   "BFD_RELOC_HI16_S_PLTOFF",
   "BFD_RELOC_8_PLTOFF",
+  "BFD_RELOC_SIZE32",
+  "BFD_RELOC_SIZE64",
   "BFD_RELOC_68K_GLOB_DAT",
   "BFD_RELOC_68K_JMP_SLOT",
   "BFD_RELOC_68K_RELATIVE",
@@ -1006,6 +1028,10 @@
   "BFD_RELOC_SPARC_M44",
   "BFD_RELOC_SPARC_L44",
   "BFD_RELOC_SPARC_REGISTER",
+  "BFD_RELOC_SPARC_H34",
+  "BFD_RELOC_SPARC_SIZE32",
+  "BFD_RELOC_SPARC_SIZE64",
+  "BFD_RELOC_SPARC_WDISP10",
   "BFD_RELOC_SPARC_REV32",
   "BFD_RELOC_SPARC_TLS_GD_HI22",
   "BFD_RELOC_SPARC_TLS_GD_LO10",
@@ -1090,6 +1116,13 @@
   "BFD_RELOC_MIPS16_HI16",
   "BFD_RELOC_MIPS16_HI16_S",
   "BFD_RELOC_MIPS16_LO16",
+  "BFD_RELOC_MIPS16_TLS_GD",
+  "BFD_RELOC_MIPS16_TLS_LDM",
+  "BFD_RELOC_MIPS16_TLS_DTPREL_HI16",
+  "BFD_RELOC_MIPS16_TLS_DTPREL_LO16",
+  "BFD_RELOC_MIPS16_TLS_GOTTPREL",
+  "BFD_RELOC_MIPS16_TLS_TPREL_HI16",
+  "BFD_RELOC_MIPS16_TLS_TPREL_LO16",
   "BFD_RELOC_MIPS_LITERAL",
   "BFD_RELOC_MICROMIPS_LITERAL",
   "BFD_RELOC_MICROMIPS_7_PCREL_S1",
@@ -1154,6 +1187,7 @@
   "BFD_RELOC_MICROMIPS_TLS_TPREL_HI16",
   "BFD_RELOC_MIPS_TLS_TPREL_LO16",
   "BFD_RELOC_MICROMIPS_TLS_TPREL_LO16",
+  "BFD_RELOC_MIPS_EH",
 
   "BFD_RELOC_MIPS_COPY",
   "BFD_RELOC_MIPS_JUMP_SLOT",
@@ -1210,6 +1244,17 @@
   "BFD_RELOC_MN10300_RELATIVE",
   "BFD_RELOC_MN10300_SYM_DIFF",
   "BFD_RELOC_MN10300_ALIGN",
+  "BFD_RELOC_MN10300_TLS_GD",
+  "BFD_RELOC_MN10300_TLS_LD",
+  "BFD_RELOC_MN10300_TLS_LDO",
+  "BFD_RELOC_MN10300_TLS_GOTIE",
+  "BFD_RELOC_MN10300_TLS_IE",
+  "BFD_RELOC_MN10300_TLS_LE",
+  "BFD_RELOC_MN10300_TLS_DTPMOD",
+  "BFD_RELOC_MN10300_TLS_DTPOFF",
+  "BFD_RELOC_MN10300_TLS_TPOFF",
+  "BFD_RELOC_MN10300_32_PCREL",
+  "BFD_RELOC_MN10300_16_PCREL",
 
   "BFD_RELOC_386_GOT32",
   "BFD_RELOC_386_PLT32",
@@ -1262,6 +1307,8 @@
   "BFD_RELOC_X86_64_TLSDESC_CALL",
   "BFD_RELOC_X86_64_TLSDESC",
   "BFD_RELOC_X86_64_IRELATIVE",
+  "BFD_RELOC_X86_64_PC32_BND",
+  "BFD_RELOC_X86_64_PLT32_BND",
   "BFD_RELOC_NS32K_IMM_8",
   "BFD_RELOC_NS32K_IMM_16",
   "BFD_RELOC_NS32K_IMM_32",
@@ -1312,6 +1359,23 @@
   "BFD_RELOC_PPC_EMB_RELST_HA",
   "BFD_RELOC_PPC_EMB_BIT_FLD",
   "BFD_RELOC_PPC_EMB_RELSDA",
+  "BFD_RELOC_PPC_VLE_REL8",
+  "BFD_RELOC_PPC_VLE_REL15",
+  "BFD_RELOC_PPC_VLE_REL24",
+  "BFD_RELOC_PPC_VLE_LO16A",
+  "BFD_RELOC_PPC_VLE_LO16D",
+  "BFD_RELOC_PPC_VLE_HI16A",
+  "BFD_RELOC_PPC_VLE_HI16D",
+  "BFD_RELOC_PPC_VLE_HA16A",
+  "BFD_RELOC_PPC_VLE_HA16D",
+  "BFD_RELOC_PPC_VLE_SDA21",
+  "BFD_RELOC_PPC_VLE_SDA21_LO",
+  "BFD_RELOC_PPC_VLE_SDAREL_LO16A",
+  "BFD_RELOC_PPC_VLE_SDAREL_LO16D",
+  "BFD_RELOC_PPC_VLE_SDAREL_HI16A",
+  "BFD_RELOC_PPC_VLE_SDAREL_HI16D",
+  "BFD_RELOC_PPC_VLE_SDAREL_HA16A",
+  "BFD_RELOC_PPC_VLE_SDAREL_HA16D",
   "BFD_RELOC_PPC64_HIGHER",
   "BFD_RELOC_PPC64_HIGHER_S",
   "BFD_RELOC_PPC64_HIGHEST",
@@ -1335,6 +1399,8 @@
   "BFD_RELOC_PPC64_TOC16_LO_DS",
   "BFD_RELOC_PPC64_PLTGOT16_DS",
   "BFD_RELOC_PPC64_PLTGOT16_LO_DS",
+  "BFD_RELOC_PPC64_ADDR16_HIGH",
+  "BFD_RELOC_PPC64_ADDR16_HIGHA",
   "BFD_RELOC_PPC_TLS",
   "BFD_RELOC_PPC_TLSGD",
   "BFD_RELOC_PPC_TLSLD",
@@ -1377,6 +1443,10 @@
   "BFD_RELOC_PPC64_DTPREL16_HIGHERA",
   "BFD_RELOC_PPC64_DTPREL16_HIGHEST",
   "BFD_RELOC_PPC64_DTPREL16_HIGHESTA",
+  "BFD_RELOC_PPC64_TPREL16_HIGH",
+  "BFD_RELOC_PPC64_TPREL16_HIGHA",
+  "BFD_RELOC_PPC64_DTPREL16_HIGH",
+  "BFD_RELOC_PPC64_DTPREL16_HIGHA",
   "BFD_RELOC_I370_D12",
   "BFD_RELOC_CTOR",
   "BFD_RELOC_ARM_PCREL_BRANCH",
@@ -1718,8 +1788,6 @@
   "BFD_RELOC_V850_32_GOTOFF",
   "BFD_RELOC_V850_CODE",
   "BFD_RELOC_V850_DATA",
-  "BFD_RELOC_MN10300_32_PCREL",
-  "BFD_RELOC_MN10300_16_PCREL",
   "BFD_RELOC_TIC30_LDP",
   "BFD_RELOC_TIC54X_PARTLS7",
   "BFD_RELOC_TIC54X_PARTMS9",
@@ -1791,6 +1859,44 @@
   "BFD_RELOC_MEP_GNU_VTINHERIT",
   "BFD_RELOC_MEP_GNU_VTENTRY",
 
+  "BFD_RELOC_METAG_HIADDR16",
+  "BFD_RELOC_METAG_LOADDR16",
+  "BFD_RELOC_METAG_RELBRANCH",
+  "BFD_RELOC_METAG_GETSETOFF",
+  "BFD_RELOC_METAG_HIOG",
+  "BFD_RELOC_METAG_LOOG",
+  "BFD_RELOC_METAG_REL8",
+  "BFD_RELOC_METAG_REL16",
+  "BFD_RELOC_METAG_HI16_GOTOFF",
+  "BFD_RELOC_METAG_LO16_GOTOFF",
+  "BFD_RELOC_METAG_GETSET_GOTOFF",
+  "BFD_RELOC_METAG_GETSET_GOT",
+  "BFD_RELOC_METAG_HI16_GOTPC",
+  "BFD_RELOC_METAG_LO16_GOTPC",
+  "BFD_RELOC_METAG_HI16_PLT",
+  "BFD_RELOC_METAG_LO16_PLT",
+  "BFD_RELOC_METAG_RELBRANCH_PLT",
+  "BFD_RELOC_METAG_GOTOFF",
+  "BFD_RELOC_METAG_PLT",
+  "BFD_RELOC_METAG_COPY",
+  "BFD_RELOC_METAG_JMP_SLOT",
+  "BFD_RELOC_METAG_RELATIVE",
+  "BFD_RELOC_METAG_GLOB_DAT",
+  "BFD_RELOC_METAG_TLS_GD",
+  "BFD_RELOC_METAG_TLS_LDM",
+  "BFD_RELOC_METAG_TLS_LDO_HI16",
+  "BFD_RELOC_METAG_TLS_LDO_LO16",
+  "BFD_RELOC_METAG_TLS_LDO",
+  "BFD_RELOC_METAG_TLS_IE",
+  "BFD_RELOC_METAG_TLS_IENONPIC",
+  "BFD_RELOC_METAG_TLS_IENONPIC_HI16",
+  "BFD_RELOC_METAG_TLS_IENONPIC_LO16",
+  "BFD_RELOC_METAG_TLS_TPOFF",
+  "BFD_RELOC_METAG_TLS_DTPMOD",
+  "BFD_RELOC_METAG_TLS_DTPOFF",
+  "BFD_RELOC_METAG_TLS_LE",
+  "BFD_RELOC_METAG_TLS_LE_HI16",
+  "BFD_RELOC_METAG_TLS_LE_LO16",
   "BFD_RELOC_MMIX_GETA",
   "BFD_RELOC_MMIX_GETA_1",
   "BFD_RELOC_MMIX_GETA_2",
@@ -1838,6 +1944,42 @@
   "BFD_RELOC_AVR_LDI",
   "BFD_RELOC_AVR_6",
   "BFD_RELOC_AVR_6_ADIW",
+  "BFD_RELOC_AVR_8_LO",
+  "BFD_RELOC_AVR_8_HI",
+  "BFD_RELOC_AVR_8_HLO",
+  "BFD_RELOC_RL78_NEG8",
+  "BFD_RELOC_RL78_NEG16",
+  "BFD_RELOC_RL78_NEG24",
+  "BFD_RELOC_RL78_NEG32",
+  "BFD_RELOC_RL78_16_OP",
+  "BFD_RELOC_RL78_24_OP",
+  "BFD_RELOC_RL78_32_OP",
+  "BFD_RELOC_RL78_8U",
+  "BFD_RELOC_RL78_16U",
+  "BFD_RELOC_RL78_24U",
+  "BFD_RELOC_RL78_DIR3U_PCREL",
+  "BFD_RELOC_RL78_DIFF",
+  "BFD_RELOC_RL78_GPRELB",
+  "BFD_RELOC_RL78_GPRELW",
+  "BFD_RELOC_RL78_GPRELL",
+  "BFD_RELOC_RL78_SYM",
+  "BFD_RELOC_RL78_OP_SUBTRACT",
+  "BFD_RELOC_RL78_OP_NEG",
+  "BFD_RELOC_RL78_OP_AND",
+  "BFD_RELOC_RL78_OP_SHRA",
+  "BFD_RELOC_RL78_ABS8",
+  "BFD_RELOC_RL78_ABS16",
+  "BFD_RELOC_RL78_ABS16_REV",
+  "BFD_RELOC_RL78_ABS32",
+  "BFD_RELOC_RL78_ABS32_REV",
+  "BFD_RELOC_RL78_ABS16U",
+  "BFD_RELOC_RL78_ABS16UW",
+  "BFD_RELOC_RL78_ABS16UL",
+  "BFD_RELOC_RL78_RELAX",
+  "BFD_RELOC_RL78_HI16",
+  "BFD_RELOC_RL78_HI8",
+  "BFD_RELOC_RL78_LO16",
+  "BFD_RELOC_RL78_CODE",
   "BFD_RELOC_RX_NEG8",
   "BFD_RELOC_RX_NEG16",
   "BFD_RELOC_RX_NEG24",
@@ -1874,8 +2016,12 @@
   "BFD_RELOC_390_RELATIVE",
   "BFD_RELOC_390_GOTPC",
   "BFD_RELOC_390_GOT16",
+  "BFD_RELOC_390_PC12DBL",
+  "BFD_RELOC_390_PLT12DBL",
   "BFD_RELOC_390_PC16DBL",
   "BFD_RELOC_390_PLT16DBL",
+  "BFD_RELOC_390_PC24DBL",
+  "BFD_RELOC_390_PLT24DBL",
   "BFD_RELOC_390_PC32DBL",
   "BFD_RELOC_390_PLT32DBL",
   "BFD_RELOC_390_GOTPCDBL",
@@ -1915,6 +2061,7 @@
   "BFD_RELOC_390_GOT20",
   "BFD_RELOC_390_GOTPLT20",
   "BFD_RELOC_390_TLS_GOTIE20",
+  "BFD_RELOC_390_IRELATIVE",
   "BFD_RELOC_SCORE_GPREL15",
   "BFD_RELOC_SCORE_DUMMY2",
   "BFD_RELOC_SCORE_JMP",
@@ -2032,6 +2179,24 @@
   "BFD_RELOC_M68HC11_PAGE",
   "BFD_RELOC_M68HC11_24",
   "BFD_RELOC_M68HC12_5B",
+  "BFD_RELOC_XGATE_RL_JUMP",
+  "BFD_RELOC_XGATE_RL_GROUP",
+  "BFD_RELOC_XGATE_LO16",
+  "BFD_RELOC_XGATE_GPAGE",
+  "BFD_RELOC_XGATE_24",
+  "BFD_RELOC_XGATE_PCREL_9",
+  "BFD_RELOC_XGATE_PCREL_10",
+  "BFD_RELOC_XGATE_IMM8_LO",
+  "BFD_RELOC_XGATE_IMM8_HI",
+  "BFD_RELOC_XGATE_IMM3",
+  "BFD_RELOC_XGATE_IMM4",
+  "BFD_RELOC_XGATE_IMM5",
+  "BFD_RELOC_M68HC12_9B",
+  "BFD_RELOC_M68HC12_16B",
+  "BFD_RELOC_M68HC12_9_PCREL",
+  "BFD_RELOC_M68HC12_10_PCREL",
+  "BFD_RELOC_M68HC12_LO8XG",
+  "BFD_RELOC_M68HC12_HI8XG",
   "BFD_RELOC_16C_NUM08",
   "BFD_RELOC_16C_NUM08_C",
   "BFD_RELOC_16C_NUM16",
@@ -2197,6 +2362,7 @@
   "BFD_RELOC_H8_DIR24A8",
   "BFD_RELOC_H8_DIR24R8",
   "BFD_RELOC_H8_DIR32A16",
+  "BFD_RELOC_H8_DISP32A16",
   "BFD_RELOC_XSTORMY16_REL_12",
   "BFD_RELOC_XSTORMY16_12",
   "BFD_RELOC_XSTORMY16_24",
@@ -2223,6 +2389,55 @@
   "BFD_RELOC_MSP430_16_BYTE",
   "BFD_RELOC_MSP430_2X_PCREL",
   "BFD_RELOC_MSP430_RL_PCREL",
+  "BFD_RELOC_MSP430_ABS8",
+  "BFD_RELOC_MSP430X_PCR20_EXT_SRC",
+  "BFD_RELOC_MSP430X_PCR20_EXT_DST",
+  "BFD_RELOC_MSP430X_PCR20_EXT_ODST",
+  "BFD_RELOC_MSP430X_ABS20_EXT_SRC",
+  "BFD_RELOC_MSP430X_ABS20_EXT_DST",
+  "BFD_RELOC_MSP430X_ABS20_EXT_ODST",
+  "BFD_RELOC_MSP430X_ABS20_ADR_SRC",
+  "BFD_RELOC_MSP430X_ABS20_ADR_DST",
+  "BFD_RELOC_MSP430X_PCR16",
+  "BFD_RELOC_MSP430X_PCR20_CALL",
+  "BFD_RELOC_MSP430X_ABS16",
+  "BFD_RELOC_MSP430_ABS_HI16",
+  "BFD_RELOC_MSP430_PREL31",
+  "BFD_RELOC_MSP430_SYM_DIFF",
+  "BFD_RELOC_NIOS2_S16",
+  "BFD_RELOC_NIOS2_U16",
+  "BFD_RELOC_NIOS2_CALL26",
+  "BFD_RELOC_NIOS2_IMM5",
+  "BFD_RELOC_NIOS2_CACHE_OPX",
+  "BFD_RELOC_NIOS2_IMM6",
+  "BFD_RELOC_NIOS2_IMM8",
+  "BFD_RELOC_NIOS2_HI16",
+  "BFD_RELOC_NIOS2_LO16",
+  "BFD_RELOC_NIOS2_HIADJ16",
+  "BFD_RELOC_NIOS2_GPREL",
+  "BFD_RELOC_NIOS2_UJMP",
+  "BFD_RELOC_NIOS2_CJMP",
+  "BFD_RELOC_NIOS2_CALLR",
+  "BFD_RELOC_NIOS2_ALIGN",
+  "BFD_RELOC_NIOS2_GOT16",
+  "BFD_RELOC_NIOS2_CALL16",
+  "BFD_RELOC_NIOS2_GOTOFF_LO",
+  "BFD_RELOC_NIOS2_GOTOFF_HA",
+  "BFD_RELOC_NIOS2_PCREL_LO",
+  "BFD_RELOC_NIOS2_PCREL_HA",
+  "BFD_RELOC_NIOS2_TLS_GD16",
+  "BFD_RELOC_NIOS2_TLS_LDM16",
+  "BFD_RELOC_NIOS2_TLS_LDO16",
+  "BFD_RELOC_NIOS2_TLS_IE16",
+  "BFD_RELOC_NIOS2_TLS_LE16",
+  "BFD_RELOC_NIOS2_TLS_DTPMOD",
+  "BFD_RELOC_NIOS2_TLS_DTPREL",
+  "BFD_RELOC_NIOS2_TLS_TPREL",
+  "BFD_RELOC_NIOS2_COPY",
+  "BFD_RELOC_NIOS2_GLOB_DAT",
+  "BFD_RELOC_NIOS2_JUMP_SLOT",
+  "BFD_RELOC_NIOS2_RELATIVE",
+  "BFD_RELOC_NIOS2_GOTOFF",
   "BFD_RELOC_IQ2000_OFFSET_16",
   "BFD_RELOC_IQ2000_OFFSET_21",
   "BFD_RELOC_IQ2000_UHI16",
@@ -2290,6 +2505,7 @@
   "BFD_RELOC_LM32_JMP_SLOT",
   "BFD_RELOC_LM32_RELATIVE",
   "BFD_RELOC_MACH_O_SECTDIFF",
+  "BFD_RELOC_MACH_O_LOCAL_SECTDIFF",
   "BFD_RELOC_MACH_O_PAIR",
   "BFD_RELOC_MACH_O_X86_64_BRANCH32",
   "BFD_RELOC_MACH_O_X86_64_BRANCH8",
@@ -2312,6 +2528,92 @@
   "BFD_RELOC_MICROBLAZE_64_GOTOFF",
   "BFD_RELOC_MICROBLAZE_32_GOTOFF",
   "BFD_RELOC_MICROBLAZE_COPY",
+  "BFD_RELOC_MICROBLAZE_64_TLS",
+  "BFD_RELOC_MICROBLAZE_64_TLSGD",
+  "BFD_RELOC_MICROBLAZE_64_TLSLD",
+  "BFD_RELOC_MICROBLAZE_32_TLSDTPMOD",
+  "BFD_RELOC_MICROBLAZE_32_TLSDTPREL",
+  "BFD_RELOC_MICROBLAZE_64_TLSDTPREL",
+  "BFD_RELOC_MICROBLAZE_64_TLSGOTTPREL",
+  "BFD_RELOC_MICROBLAZE_64_TLSTPREL",
+  "BFD_RELOC_AARCH64_RELOC_START",
+  "BFD_RELOC_AARCH64_NONE",
+  "BFD_RELOC_AARCH64_64",
+  "BFD_RELOC_AARCH64_32",
+  "BFD_RELOC_AARCH64_16",
+  "BFD_RELOC_AARCH64_64_PCREL",
+  "BFD_RELOC_AARCH64_32_PCREL",
+  "BFD_RELOC_AARCH64_16_PCREL",
+  "BFD_RELOC_AARCH64_MOVW_G0",
+  "BFD_RELOC_AARCH64_MOVW_G0_NC",
+  "BFD_RELOC_AARCH64_MOVW_G1",
+  "BFD_RELOC_AARCH64_MOVW_G1_NC",
+  "BFD_RELOC_AARCH64_MOVW_G2",
+  "BFD_RELOC_AARCH64_MOVW_G2_NC",
+  "BFD_RELOC_AARCH64_MOVW_G3",
+  "BFD_RELOC_AARCH64_MOVW_G0_S",
+  "BFD_RELOC_AARCH64_MOVW_G1_S",
+  "BFD_RELOC_AARCH64_MOVW_G2_S",
+  "BFD_RELOC_AARCH64_LD_LO19_PCREL",
+  "BFD_RELOC_AARCH64_ADR_LO21_PCREL",
+  "BFD_RELOC_AARCH64_ADR_HI21_PCREL",
+  "BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL",
+  "BFD_RELOC_AARCH64_ADD_LO12",
+  "BFD_RELOC_AARCH64_LDST8_LO12",
+  "BFD_RELOC_AARCH64_TSTBR14",
+  "BFD_RELOC_AARCH64_BRANCH19",
+  "BFD_RELOC_AARCH64_JUMP26",
+  "BFD_RELOC_AARCH64_CALL26",
+  "BFD_RELOC_AARCH64_LDST16_LO12",
+  "BFD_RELOC_AARCH64_LDST32_LO12",
+  "BFD_RELOC_AARCH64_LDST64_LO12",
+  "BFD_RELOC_AARCH64_LDST128_LO12",
+  "BFD_RELOC_AARCH64_GOT_LD_PREL19",
+  "BFD_RELOC_AARCH64_ADR_GOT_PAGE",
+  "BFD_RELOC_AARCH64_LD64_GOT_LO12_NC",
+  "BFD_RELOC_AARCH64_LD32_GOT_LO12_NC",
+  "BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21",
+  "BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC",
+  "BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1",
+  "BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC",
+  "BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21",
+  "BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC",
+  "BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC",
+  "BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19",
+  "BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2",
+  "BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1",
+  "BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1_NC",
+  "BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0",
+  "BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC",
+  "BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12",
+  "BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12",
+  "BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC",
+  "BFD_RELOC_AARCH64_TLSDESC_LD_PREL19",
+  "BFD_RELOC_AARCH64_TLSDESC_ADR_PREL21",
+  "BFD_RELOC_AARCH64_TLSDESC_ADR_PAGE21",
+  "BFD_RELOC_AARCH64_TLSDESC_LD64_LO12_NC",
+  "BFD_RELOC_AARCH64_TLSDESC_LD32_LO12_NC",
+  "BFD_RELOC_AARCH64_TLSDESC_ADD_LO12_NC",
+  "BFD_RELOC_AARCH64_TLSDESC_OFF_G1",
+  "BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC",
+  "BFD_RELOC_AARCH64_TLSDESC_LDR",
+  "BFD_RELOC_AARCH64_TLSDESC_ADD",
+  "BFD_RELOC_AARCH64_TLSDESC_CALL",
+  "BFD_RELOC_AARCH64_COPY",
+  "BFD_RELOC_AARCH64_GLOB_DAT",
+  "BFD_RELOC_AARCH64_JUMP_SLOT",
+  "BFD_RELOC_AARCH64_RELATIVE",
+  "BFD_RELOC_AARCH64_TLS_DTPMOD",
+  "BFD_RELOC_AARCH64_TLS_DTPREL",
+  "BFD_RELOC_AARCH64_TLS_TPREL",
+  "BFD_RELOC_AARCH64_TLSDESC",
+  "BFD_RELOC_AARCH64_IRELATIVE",
+  "BFD_RELOC_AARCH64_RELOC_END",
+  "BFD_RELOC_AARCH64_GAS_INTERNAL_FIXUP",
+  "BFD_RELOC_AARCH64_LDST_LO12",
+  "BFD_RELOC_AARCH64_LD_GOT_LO12_NC",
+  "BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_LO12_NC",
+  "BFD_RELOC_AARCH64_TLSDESC_LD_LO12_NC",
   "BFD_RELOC_TILEPRO_COPY",
   "BFD_RELOC_TILEPRO_GLOB_DAT",
   "BFD_RELOC_TILEPRO_JMP_SLOT",
@@ -2358,6 +2660,12 @@
   "BFD_RELOC_TILEPRO_SHAMT_X1",
   "BFD_RELOC_TILEPRO_SHAMT_Y0",
   "BFD_RELOC_TILEPRO_SHAMT_Y1",
+  "BFD_RELOC_TILEPRO_TLS_GD_CALL",
+  "BFD_RELOC_TILEPRO_IMM8_X0_TLS_GD_ADD",
+  "BFD_RELOC_TILEPRO_IMM8_X1_TLS_GD_ADD",
+  "BFD_RELOC_TILEPRO_IMM8_Y0_TLS_GD_ADD",
+  "BFD_RELOC_TILEPRO_IMM8_Y1_TLS_GD_ADD",
+  "BFD_RELOC_TILEPRO_TLS_IE_LOAD",
   "BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD",
   "BFD_RELOC_TILEPRO_IMM16_X1_TLS_GD",
   "BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD_LO",
@@ -2377,6 +2685,14 @@
   "BFD_RELOC_TILEPRO_TLS_DTPMOD32",
   "BFD_RELOC_TILEPRO_TLS_DTPOFF32",
   "BFD_RELOC_TILEPRO_TLS_TPOFF32",
+  "BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE",
+  "BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE",
+  "BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_LO",
+  "BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_LO",
+  "BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_HI",
+  "BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_HI",
+  "BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_HA",
+  "BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_HA",
   "BFD_RELOC_TILEGX_HW0",
   "BFD_RELOC_TILEGX_HW1",
   "BFD_RELOC_TILEGX_HW2",
@@ -2434,52 +2750,65 @@
   "BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_PCREL",
   "BFD_RELOC_TILEGX_IMM16_X0_HW0_GOT",
   "BFD_RELOC_TILEGX_IMM16_X1_HW0_GOT",
-  "BFD_RELOC_TILEGX_IMM16_X0_HW1_GOT",
-  "BFD_RELOC_TILEGX_IMM16_X1_HW1_GOT",
-  "BFD_RELOC_TILEGX_IMM16_X0_HW2_GOT",
-  "BFD_RELOC_TILEGX_IMM16_X1_HW2_GOT",
-  "BFD_RELOC_TILEGX_IMM16_X0_HW3_GOT",
-  "BFD_RELOC_TILEGX_IMM16_X1_HW3_GOT",
+  "BFD_RELOC_TILEGX_IMM16_X0_HW0_PLT_PCREL",
+  "BFD_RELOC_TILEGX_IMM16_X1_HW0_PLT_PCREL",
+  "BFD_RELOC_TILEGX_IMM16_X0_HW1_PLT_PCREL",
+  "BFD_RELOC_TILEGX_IMM16_X1_HW1_PLT_PCREL",
+  "BFD_RELOC_TILEGX_IMM16_X0_HW2_PLT_PCREL",
+  "BFD_RELOC_TILEGX_IMM16_X1_HW2_PLT_PCREL",
   "BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_GOT",
   "BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_GOT",
   "BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_GOT",
   "BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_GOT",
-  "BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_GOT",
-  "BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_GOT",
+  "BFD_RELOC_TILEGX_IMM16_X0_HW3_PLT_PCREL",
+  "BFD_RELOC_TILEGX_IMM16_X1_HW3_PLT_PCREL",
   "BFD_RELOC_TILEGX_IMM16_X0_HW0_TLS_GD",
   "BFD_RELOC_TILEGX_IMM16_X1_HW0_TLS_GD",
-  "BFD_RELOC_TILEGX_IMM16_X0_HW1_TLS_GD",
-  "BFD_RELOC_TILEGX_IMM16_X1_HW1_TLS_GD",
-  "BFD_RELOC_TILEGX_IMM16_X0_HW2_TLS_GD",
-  "BFD_RELOC_TILEGX_IMM16_X1_HW2_TLS_GD",
-  "BFD_RELOC_TILEGX_IMM16_X0_HW3_TLS_GD",
-  "BFD_RELOC_TILEGX_IMM16_X1_HW3_TLS_GD",
+  "BFD_RELOC_TILEGX_IMM16_X0_HW0_TLS_LE",
+  "BFD_RELOC_TILEGX_IMM16_X1_HW0_TLS_LE",
+  "BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_TLS_LE",
+  "BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_TLS_LE",
+  "BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_TLS_LE",
+  "BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_TLS_LE",
   "BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_TLS_GD",
   "BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_TLS_GD",
   "BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_TLS_GD",
   "BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_TLS_GD",
-  "BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_TLS_GD",
-  "BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_TLS_GD",
   "BFD_RELOC_TILEGX_IMM16_X0_HW0_TLS_IE",
   "BFD_RELOC_TILEGX_IMM16_X1_HW0_TLS_IE",
-  "BFD_RELOC_TILEGX_IMM16_X0_HW1_TLS_IE",
-  "BFD_RELOC_TILEGX_IMM16_X1_HW1_TLS_IE",
-  "BFD_RELOC_TILEGX_IMM16_X0_HW2_TLS_IE",
-  "BFD_RELOC_TILEGX_IMM16_X1_HW2_TLS_IE",
-  "BFD_RELOC_TILEGX_IMM16_X0_HW3_TLS_IE",
-  "BFD_RELOC_TILEGX_IMM16_X1_HW3_TLS_IE",
+  "BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_PLT_PCREL",
+  "BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_PLT_PCREL",
+  "BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_PLT_PCREL",
+  "BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_PLT_PCREL",
+  "BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_PLT_PCREL",
+  "BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_PLT_PCREL",
   "BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_TLS_IE",
   "BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_TLS_IE",
   "BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_TLS_IE",
   "BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_TLS_IE",
-  "BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_TLS_IE",
-  "BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_TLS_IE",
   "BFD_RELOC_TILEGX_TLS_DTPMOD64",
   "BFD_RELOC_TILEGX_TLS_DTPOFF64",
   "BFD_RELOC_TILEGX_TLS_TPOFF64",
   "BFD_RELOC_TILEGX_TLS_DTPMOD32",
   "BFD_RELOC_TILEGX_TLS_DTPOFF32",
   "BFD_RELOC_TILEGX_TLS_TPOFF32",
+  "BFD_RELOC_TILEGX_TLS_GD_CALL",
+  "BFD_RELOC_TILEGX_IMM8_X0_TLS_GD_ADD",
+  "BFD_RELOC_TILEGX_IMM8_X1_TLS_GD_ADD",
+  "BFD_RELOC_TILEGX_IMM8_Y0_TLS_GD_ADD",
+  "BFD_RELOC_TILEGX_IMM8_Y1_TLS_GD_ADD",
+  "BFD_RELOC_TILEGX_TLS_IE_LOAD",
+  "BFD_RELOC_TILEGX_IMM8_X0_TLS_ADD",
+  "BFD_RELOC_TILEGX_IMM8_X1_TLS_ADD",
+  "BFD_RELOC_TILEGX_IMM8_Y0_TLS_ADD",
+  "BFD_RELOC_TILEGX_IMM8_Y1_TLS_ADD",
+  "BFD_RELOC_EPIPHANY_SIMM8",
+  "BFD_RELOC_EPIPHANY_SIMM24",
+  "BFD_RELOC_EPIPHANY_HIGH",
+  "BFD_RELOC_EPIPHANY_LOW",
+  "BFD_RELOC_EPIPHANY_SIMM11",
+  "BFD_RELOC_EPIPHANY_IMM11",
+  "BFD_RELOC_EPIPHANY_IMM8",
  "@@overflow: BFD_RELOC_UNUSED@@",
 };
 #endif
@@ -2496,8 +2825,8 @@
 bfd_boolean bfd_generic_gc_sections
    (bfd *, struct bfd_link_info *);
 
-void bfd_generic_lookup_section_flags
-   (struct bfd_link_info *, struct flag_info *);
+bfd_boolean bfd_generic_lookup_section_flags
+   (struct bfd_link_info *, struct flag_info *, asection *);
 
 bfd_boolean bfd_generic_merge_sections
    (bfd *, struct bfd_link_info *);
@@ -2521,4 +2850,8 @@
 bfd_boolean bfd_default_scan
    (const struct bfd_arch_info *info, const char *string);
 
+void *bfd_arch_default_fill (bfd_size_type count,
+    bfd_boolean is_bigendian,
+    bfd_boolean code);
+
 /* Extracted from elf.c.  */
diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h
index 00d9ab2..49b5f10 100644
--- a/bfd/libcoff-in.h
+++ b/bfd/libcoff-in.h
@@ -1,7 +1,5 @@
 /* BFD COFF object file private structure.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright 1990-2013 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -118,6 +116,7 @@
   int dll;
   int has_reloc_section;
   int dont_strip_reloc;
+  bfd_boolean insert_timestamp;
   bfd_boolean (*in_reloc_p) (bfd *, reloc_howto_type *);
   flagword real_flags;
 } pe_data_type;
@@ -318,6 +317,9 @@
   (bfd *);
 extern bfd_boolean coff_write_symbols
   (bfd *);
+extern bfd_boolean coff_write_alien_symbol
+  (bfd *, asymbol *, struct internal_syment *, bfd_vma *,
+   bfd_size_type *, asection **, bfd_size_type *);
 extern bfd_boolean coff_write_linenumbers
   (bfd *);
 extern alent *coff_get_lineno
@@ -347,6 +349,13 @@
 extern bfd_boolean coff_find_nearest_line
   (bfd *, asection *, asymbol **, bfd_vma, const char **,
    const char **, unsigned int *);
+extern bfd_boolean coff_find_nearest_line_discriminator
+  (bfd *, asection *, asymbol **, bfd_vma, const char **,
+   const char **, unsigned int *, unsigned int *);
+struct dwarf_debug_section;
+extern bfd_boolean coff_find_nearest_line_with_names
+  (bfd *, const struct dwarf_debug_section *, asection *, asymbol **,
+   bfd_vma, const char **, const char **, unsigned int *);
 extern bfd_boolean coff_find_inliner_info
   (bfd *, const char **, const char **, unsigned int *);
 extern int coff_sizeof_headers
diff --git a/bfd/libcoff.h b/bfd/libcoff.h
index bd58c82..19b6d9c 100644
--- a/bfd/libcoff.h
+++ b/bfd/libcoff.h
@@ -3,9 +3,7 @@
    Run "make headers" in your build bfd/ to regenerate.  */
 
 /* BFD COFF object file private structure.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright 1990-2013 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -122,6 +120,7 @@
   int dll;
   int has_reloc_section;
   int dont_strip_reloc;
+  bfd_boolean insert_timestamp;
   bfd_boolean (*in_reloc_p) (bfd *, reloc_howto_type *);
   flagword real_flags;
 } pe_data_type;
@@ -322,6 +321,9 @@
   (bfd *);
 extern bfd_boolean coff_write_symbols
   (bfd *);
+extern bfd_boolean coff_write_alien_symbol
+  (bfd *, asymbol *, struct internal_syment *, bfd_vma *,
+   bfd_size_type *, asection **, bfd_size_type *);
 extern bfd_boolean coff_write_linenumbers
   (bfd *);
 extern alent *coff_get_lineno
@@ -351,6 +353,13 @@
 extern bfd_boolean coff_find_nearest_line
   (bfd *, asection *, asymbol **, bfd_vma, const char **,
    const char **, unsigned int *);
+extern bfd_boolean coff_find_nearest_line_discriminator
+  (bfd *, asection *, asymbol **, bfd_vma, const char **,
+   const char **, unsigned int *, unsigned int *);
+struct dwarf_debug_section;
+extern bfd_boolean coff_find_nearest_line_with_names
+  (bfd *, const struct dwarf_debug_section *, asection *, asymbol **,
+   bfd_vma, const char **, const char **, unsigned int *);
 extern bfd_boolean coff_find_inliner_info
   (bfd *, const char **, const char **, unsigned int *);
 extern int coff_sizeof_headers
@@ -723,7 +732,7 @@
   bfd_boolean _bfd_coff_long_section_names;
   bfd_boolean (*_bfd_coff_set_long_section_names)
     (bfd *, int);
-  
+
   unsigned int _bfd_coff_default_section_alignment_power;
   bfd_boolean _bfd_coff_force_symnames_in_strings;
   unsigned int _bfd_coff_debug_string_prefix_length;
diff --git a/bfd/libpei.h b/bfd/libpei.h
index f8a02b9..40026ef 100644
--- a/bfd/libpei.h
+++ b/bfd/libpei.h
@@ -14,7 +14,7 @@
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
diff --git a/bfd/libxcoff.h b/bfd/libxcoff.h
index 53a5e72..3f66524 100644
--- a/bfd/libxcoff.h
+++ b/bfd/libxcoff.h
@@ -77,7 +77,7 @@
     (bfd *, union internal_auxent *, const char *);
 
   /* Line number and relocation overflow.
-     XCOFF32 overflows to another section when the line number or the 
+     XCOFF32 overflows to another section when the line number or the
      relocation count exceeds 0xffff.  XCOFF64 does not overflow.  */
   bfd_boolean (*_xcoff_is_lineno_count_overflow) (bfd *, bfd_vma);
   bfd_boolean (*_xcoff_is_reloc_count_overflow)  (bfd *, bfd_vma);
@@ -87,11 +87,11 @@
      XCOFF64 is offset in .loader header.  */
   bfd_vma (*_xcoff_loader_symbol_offset) (bfd *, struct internal_ldhdr *);
   bfd_vma (*_xcoff_loader_reloc_offset)  (bfd *, struct internal_ldhdr *);
-  
-  /* Global linkage.  The first word of global linkage code must be be 
+
+  /* Global linkage.  The first word of global linkage code must be be
      modified by filling in the correct TOC offset.  */
   unsigned long *_xcoff_glink_code;
-  
+
   /* Size of the global link code in bytes of the xcoff_glink_code table.  */
   unsigned long _xcoff_glink_size;
 
@@ -185,7 +185,7 @@
 #define bfd_xcoff_glink_code(a, b)   ((xcoff_backend (a)->_xcoff_glink_code[(b)]))
 #define bfd_xcoff_glink_code_size(a) ((xcoff_backend (a)->_xcoff_glink_size))
 
-/* Check for the magic number U803XTOCMAGIC or U64_TOCMAGIC for 64 bit 
+/* Check for the magic number U803XTOCMAGIC or U64_TOCMAGIC for 64 bit
    targets.  */
 #define bfd_xcoff_is_xcoff64(a) \
   (   (0x01EF == (bfd_xcoff_magic_number (a))) \
diff --git a/bfd/linker.c b/bfd/linker.c
index 7a01e11..190520a 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -1,6 +1,6 @@
 /* linker.c -- BFD linker routines
    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
    Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support
 
@@ -810,6 +810,7 @@
 _bfd_generic_link_just_syms (asection *sec,
 			     struct bfd_link_info *info ATTRIBUTE_UNUSED)
 {
+  sec->sec_info_type = SEC_INFO_TYPE_JUST_SYMS;
   sec->output_section = bfd_abs_section_ptr;
   sec->output_offset = sec->vma;
 }
@@ -2358,6 +2359,12 @@
 	  else
 	    output = FALSE;
 	}
+      else if (sym->flags == 0
+	       && (sym->section->owner->flags & BFD_PLUGIN) != 0)
+	/* LTO doesn't set symbol information.  We get here with the
+	   generic linker for a symbol that was "common" but no longer
+	   needs to be global.  */
+	output = FALSE;
       else
 	abort ();
 
@@ -2664,7 +2671,14 @@
 
   fill = link_order->u.data.contents;
   fill_size = link_order->u.data.size;
-  if (fill_size != 0 && fill_size < size)
+  if (fill_size == 0)
+    {
+      fill = abfd->arch_info->fill (size, bfd_big_endian (abfd),
+				    (sec->flags & SEC_CODE) != 0);
+      if (fill == NULL)
+	return FALSE;
+    }
+  else if (fill_size < size)
     {
       bfd_byte *p;
       fill = (bfd_byte *) bfd_malloc (size);
@@ -2905,7 +2919,7 @@
 /* Sections marked with the SEC_LINK_ONCE flag should only be linked
    once into the output.  This routine checks each section, and
    arrange to discard it if a section of the same name has already
-   been linked.  This code assumes that all relevant sections have the 
+   been linked.  This code assumes that all relevant sections have the
    SEC_LINK_ONCE flag set; that is, it does not depend solely upon the
    section name.  bfd_section_already_linked is called via
    bfd_map_over_sections.  */
@@ -3123,6 +3137,76 @@
   return FALSE;
 }
 
+/* Choose a neighbouring section to S in OBFD that will be output, or
+   the absolute section if ADDR is out of bounds of the neighbours.  */
+
+asection *
+_bfd_nearby_section (bfd *obfd, asection *s, bfd_vma addr)
+{
+  asection *next, *prev, *best;
+
+  /* Find preceding kept section.  */
+  for (prev = s->prev; prev != NULL; prev = prev->prev)
+    if ((prev->flags & SEC_EXCLUDE) == 0
+	&& !bfd_section_removed_from_list (obfd, prev))
+      break;
+
+  /* Find following kept section.  Start at prev->next because
+     other sections may have been added after S was removed.  */
+  if (s->prev != NULL)
+    next = s->prev->next;
+  else
+    next = s->owner->sections;
+  for (; next != NULL; next = next->next)
+    if ((next->flags & SEC_EXCLUDE) == 0
+	&& !bfd_section_removed_from_list (obfd, next))
+      break;
+
+  /* Choose better of two sections, based on flags.  The idea
+     is to choose a section that will be in the same segment
+     as S would have been if it was kept.  */
+  best = next;
+  if (prev == NULL)
+    {
+      if (next == NULL)
+	best = bfd_abs_section_ptr;
+    }
+  else if (next == NULL)
+    best = prev;
+  else if (((prev->flags ^ next->flags)
+	    & (SEC_ALLOC | SEC_THREAD_LOCAL | SEC_LOAD)) != 0)
+    {
+      if (((next->flags ^ s->flags)
+	   & (SEC_ALLOC | SEC_THREAD_LOCAL)) != 0
+	  /* We prefer to choose a loaded section.  Section S
+	     doesn't have SEC_LOAD set (it being excluded, that
+	     part of the flag processing didn't happen) so we
+	     can't compare that flag to those of NEXT and PREV.  */
+	  || ((prev->flags & SEC_LOAD) != 0
+	      && (next->flags & SEC_LOAD) == 0))
+	best = prev;
+    }
+  else if (((prev->flags ^ next->flags) & SEC_READONLY) != 0)
+    {
+      if (((next->flags ^ s->flags) & SEC_READONLY) != 0)
+	best = prev;
+    }
+  else if (((prev->flags ^ next->flags) & SEC_CODE) != 0)
+    {
+      if (((next->flags ^ s->flags) & SEC_CODE) != 0)
+	best = prev;
+    }
+  else
+    {
+      /* Flags we care about are the same.  Prefer the following
+	 section if that will result in a positive valued sym.  */
+      if (addr < next->vma)
+	best = prev;
+    }
+
+  return best;
+}
+
 /* Convert symbols in excluded output sections to use a kept section.  */
 
 static bfd_boolean
@@ -3139,68 +3223,10 @@
 	  && (s->output_section->flags & SEC_EXCLUDE) != 0
 	  && bfd_section_removed_from_list (obfd, s->output_section))
 	{
-	  asection *op, *op1;
+	  asection *op;
 
 	  h->u.def.value += s->output_offset + s->output_section->vma;
-
-	  /* Find preceding kept section.  */
-	  for (op1 = s->output_section->prev; op1 != NULL; op1 = op1->prev)
-	    if ((op1->flags & SEC_EXCLUDE) == 0
-		&& !bfd_section_removed_from_list (obfd, op1))
-	      break;
-
-	  /* Find following kept section.  Start at prev->next because
-	     other sections may have been added after S was removed.  */
-	  if (s->output_section->prev != NULL)
-	    op = s->output_section->prev->next;
-	  else
-	    op = s->output_section->owner->sections;
-	  for (; op != NULL; op = op->next)
-	    if ((op->flags & SEC_EXCLUDE) == 0
-		&& !bfd_section_removed_from_list (obfd, op))
-	      break;
-
-	  /* Choose better of two sections, based on flags.  The idea
-	     is to choose a section that will be in the same segment
-	     as S would have been if it was kept.  */
-	  if (op1 == NULL)
-	    {
-	      if (op == NULL)
-		op = bfd_abs_section_ptr;
-	    }
-	  else if (op == NULL)
-	    op = op1;
-	  else if (((op1->flags ^ op->flags)
-		    & (SEC_ALLOC | SEC_THREAD_LOCAL | SEC_LOAD)) != 0)
-	    {
-	      if (((op->flags ^ s->flags)
-		   & (SEC_ALLOC | SEC_THREAD_LOCAL)) != 0
-		  /* We prefer to choose a loaded section.  Section S
-		     doesn't have SEC_LOAD set (it being excluded, that
-		     part of the flag processing didn't happen) so we
-		     can't compare that flag to those of OP and OP1.  */
-		  || ((op1->flags & SEC_LOAD) != 0
-		      && (op->flags & SEC_LOAD) == 0))
-		op = op1;
-	    }
-	  else if (((op1->flags ^ op->flags) & SEC_READONLY) != 0)
-	    {
-	      if (((op->flags ^ s->flags) & SEC_READONLY) != 0)
-		op = op1;
-	    }
-	  else if (((op1->flags ^ op->flags) & SEC_CODE) != 0)
-	    {
-	      if (((op->flags ^ s->flags) & SEC_CODE) != 0)
-		op = op1;
-	    }
-	  else
-	    {
-	      /* Flags we care about are the same.  Prefer the following
-		 section if that will result in a positive valued sym.  */
-	      if (h->u.def.value < op->vma)
-		op = op1;
-	    }
-
+	  op = _bfd_nearby_section (obfd, s->output_section, h->u.def.value);
 	  h->u.def.value -= op->vma;
 	  h->u.def.section = op;
 	}
@@ -3276,7 +3302,7 @@
 
 /*
 FUNCTION
-	bfd_find_version_for_sym 
+	bfd_find_version_for_sym
 
 SYNOPSIS
 	struct bfd_elf_version_tree * bfd_find_version_for_sym
diff --git a/bfd/lynx-core.c b/bfd/lynx-core.c
index ab6a834..0b4af04 100644
--- a/bfd/lynx-core.c
+++ b/bfd/lynx-core.c
@@ -58,13 +58,12 @@
 /* Handle Lynx core dump file.  */
 
 static asection *
-make_bfd_asection (abfd, name, flags, size, vma, filepos)
-     bfd *abfd;
-     const char *name;
-     flagword flags;
-     bfd_size_type size;
-     bfd_vma vma;
-     file_ptr filepos;
+make_bfd_asection (bfd *abfd,
+		   const char *name,
+		   flagword flags,
+		   bfd_size_type size,
+		   bfd_vma vma,
+		   file_ptr filepos)
 {
   asection *asect;
   char *newname;
@@ -88,8 +87,7 @@
 }
 
 const bfd_target *
-lynx_core_file_p (abfd)
-     bfd *abfd;
+lynx_core_file_p (bfd *abfd)
 {
   int secnum;
   struct pssentry pss;
@@ -215,15 +213,13 @@
 }
 
 char *
-lynx_core_file_failing_command (abfd)
-     bfd *abfd;
+lynx_core_file_failing_command (bfd *abfd)
 {
   return core_command (abfd);
 }
 
 int
-lynx_core_file_failing_signal (abfd)
-     bfd *abfd;
+lynx_core_file_failing_signal (bfd *abfd)
 {
   return core_signal (abfd);
 }
diff --git a/bfd/m68klinux.c b/bfd/m68klinux.c
index ab5a456..f612782 100644
--- a/bfd/m68klinux.c
+++ b/bfd/m68klinux.c
@@ -1,6 +1,6 @@
 /* BFD back-end for linux flavored m68k a.out binaries.
    Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011
+   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -51,15 +51,11 @@
    becomes important.  */
 
 static void MY_final_link_callback
-  PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
-static bfd_boolean m68klinux_bfd_final_link
-  PARAMS ((bfd *, struct bfd_link_info *));
-static bfd_boolean m68klinux_write_object_contents PARAMS ((bfd *));
+  (bfd *, file_ptr *, file_ptr *, file_ptr *);
 
 static bfd_boolean
-m68klinux_bfd_final_link (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info;
+m68klinux_bfd_final_link (bfd *abfd,
+			  struct bfd_link_info *info)
 {
   obj_aout_subformat (abfd) = q_magic_format;
   return NAME(aout,final_link) (abfd, info, MY_final_link_callback);
@@ -70,8 +66,7 @@
 /* Set the machine type correctly.  */
 
 static bfd_boolean
-m68klinux_write_object_contents (abfd)
-     bfd *abfd;
+m68klinux_write_object_contents (bfd *abfd)
 {
   struct external_exec exec_bytes;
   struct internal_exec *execp = exec_hdr (abfd);
@@ -171,31 +166,12 @@
   struct fixup *fixup_list;
 };
 
-static struct bfd_hash_entry *linux_link_hash_newfunc
-  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static struct bfd_link_hash_table *linux_link_hash_table_create
-  PARAMS ((bfd *));
-static struct fixup *new_fixup
-  PARAMS ((struct bfd_link_info *, struct linux_link_hash_entry *,
-	   bfd_vma, int));
-static bfd_boolean linux_link_create_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-static bfd_boolean linux_add_one_symbol
-  PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword, asection *,
-	   bfd_vma, const char *, bfd_boolean, bfd_boolean,
-	   struct bfd_link_hash_entry **));
-static bfd_boolean linux_tally_symbols
-  PARAMS ((struct linux_link_hash_entry *, PTR));
-static bfd_boolean linux_finish_dynamic_link
-  PARAMS ((bfd *, struct bfd_link_info *));
-
 /* Routine to create an entry in an Linux link hash table.  */
 
 static struct bfd_hash_entry *
-linux_link_hash_newfunc (entry, table, string)
-     struct bfd_hash_entry *entry;
-     struct bfd_hash_table *table;
-     const char *string;
+linux_link_hash_newfunc (struct bfd_hash_entry *entry,
+			 struct bfd_hash_table *table,
+			 const char *string)
 {
   struct linux_link_hash_entry *ret = (struct linux_link_hash_entry *) entry;
 
@@ -222,13 +198,12 @@
 /* Create a Linux link hash table.  */
 
 static struct bfd_link_hash_table *
-linux_link_hash_table_create (abfd)
-     bfd *abfd;
+linux_link_hash_table_create (bfd *abfd)
 {
   struct linux_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct linux_link_hash_table);
 
-  ret = (struct linux_link_hash_table *) bfd_malloc (amt);
+  ret = (struct linux_link_hash_table *) bfd_zmalloc (amt);
   if (ret == (struct linux_link_hash_table *) NULL)
     {
       bfd_set_error (bfd_error_no_memory);
@@ -242,11 +217,6 @@
       return (struct bfd_link_hash_table *) NULL;
     }
 
-  ret->dynobj = NULL;
-  ret->fixup_count = 0;
-  ret->local_builtins = 0;
-  ret->fixup_list = NULL;
-
   return &ret->root.root;
 }
 
@@ -262,7 +232,7 @@
 #define linux_link_hash_traverse(table, func, info)			\
   (aout_link_hash_traverse						\
    (&(table)->root,							\
-    (bfd_boolean (*) PARAMS ((struct aout_link_hash_entry *, PTR))) (func),	\
+    (bfd_boolean (*) (struct aout_link_hash_entry *, void *)) (func),	\
     (info)))
 
 /* Get the Linux link hash table from the info structure.  This is
@@ -273,11 +243,10 @@
 /* Store the information for a new fixup.  */
 
 static struct fixup *
-new_fixup (info, h, value, builtin)
-     struct bfd_link_info *info;
-     struct linux_link_hash_entry *h;
-     bfd_vma value;
-     int builtin;
+new_fixup (struct bfd_link_info *info,
+	   struct linux_link_hash_entry *h,
+	   bfd_vma value,
+	   int builtin)
 {
   struct fixup *f;
 
@@ -303,12 +272,11 @@
    create it for now.  */
 
 static bfd_boolean
-linux_link_create_dynamic_sections (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
+linux_link_create_dynamic_sections (bfd *abfd,
+				    struct bfd_link_info *info ATTRIBUTE_UNUSED)
 {
   flagword flags;
-  register asection *s;
+  asection *s;
 
   /* Note that we set the SEC_IN_MEMORY flag.  */
   flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
@@ -330,18 +298,16 @@
    tweaking needed for dynamic linking support.  */
 
 static bfd_boolean
-linux_add_one_symbol (info, abfd, name, flags, section, value, string,
-		      copy, collect, hashp)
-     struct bfd_link_info *info;
-     bfd *abfd;
-     const char *name;
-     flagword flags;
-     asection *section;
-     bfd_vma value;
-     const char *string;
-     bfd_boolean copy;
-     bfd_boolean collect;
-     struct bfd_link_hash_entry **hashp;
+linux_add_one_symbol (struct bfd_link_info *info,
+		      bfd *abfd,
+		      const char *name,
+		      flagword flags,
+		      asection *section,
+		      bfd_vma value,
+		      const char *string,
+		      bfd_boolean copy,
+		      bfd_boolean collect,
+		      struct bfd_link_hash_entry **hashp)
 {
   struct linux_link_hash_entry *h;
   bfd_boolean insert;
@@ -430,9 +396,8 @@
    This function is called via linux_link_hash_traverse.  */
 
 static bfd_boolean
-linux_tally_symbols (h, data)
-     struct linux_link_hash_entry *h;
-     PTR data;
+linux_tally_symbols (struct linux_link_hash_entry *h,
+		     void * data)
 {
   struct bfd_link_info *info = (struct bfd_link_info *) data;
   struct fixup *f, *f1;
@@ -553,9 +518,8 @@
    are required.  */
 
 bfd_boolean
-bfd_m68klinux_size_dynamic_sections (output_bfd, info)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
+bfd_m68klinux_size_dynamic_sections (bfd *output_bfd,
+				     struct bfd_link_info *info)
 {
   struct fixup *f;
   asection *s;
@@ -566,7 +530,7 @@
   /* First find the fixups...  */
   linux_link_hash_traverse (linux_hash_table (info),
 			    linux_tally_symbols,
-			    (PTR) info);
+			    info);
 
   /* If there are builtin fixups, leave room for a marker.  This is
      used by the dynamic linker so that it knows that all that follow
@@ -611,9 +575,7 @@
    the stuff we need.  */
 
 static bfd_boolean
-linux_finish_dynamic_link (output_bfd, info)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
+linux_finish_dynamic_link (bfd *output_bfd, struct bfd_link_info *info)
 {
   asection *s, *os, *is;
   bfd_byte *fixup_table;
@@ -761,7 +723,7 @@
 		SEEK_SET) != 0)
     return FALSE;
 
-  if (bfd_bwrite ((PTR) s->contents, s->size, output_bfd) != s->size)
+  if (bfd_bwrite (s->contents, s->size, output_bfd) != s->size)
     return FALSE;
 
   return TRUE;
diff --git a/bfd/mach-o-i386.c b/bfd/mach-o-i386.c
index 1191560..97e0d58 100644
--- a/bfd/mach-o-i386.c
+++ b/bfd/mach-o-i386.c
@@ -63,6 +63,7 @@
 
 static reloc_howto_type i386_howto_table[]=
 {
+  /* 0 */
   HOWTO(BFD_RELOC_32, 0, 2, 32, FALSE, 0,
 	complain_overflow_bitfield,
 	NULL, "32",
@@ -79,6 +80,7 @@
 	complain_overflow_bitfield,
 	NULL, "DISP32",
 	FALSE, 0xffffffff, 0xffffffff, TRUE),
+  /* 4 */
   HOWTO(BFD_RELOC_16_PCREL, 0, 1, 16, TRUE, 0,
 	complain_overflow_bitfield,
 	NULL, "DISP16",
@@ -87,10 +89,27 @@
 	complain_overflow_bitfield,
 	NULL, "SECTDIFF_32",
 	FALSE, 0xffffffff, 0xffffffff, FALSE),
+  HOWTO(BFD_RELOC_MACH_O_LOCAL_SECTDIFF, 0, 2, 32, FALSE, 0,
+	complain_overflow_bitfield,
+	NULL, "LSECTDIFF_32",
+	FALSE, 0xffffffff, 0xffffffff, FALSE),
   HOWTO(BFD_RELOC_MACH_O_PAIR, 0, 2, 32, FALSE, 0,
 	complain_overflow_bitfield,
 	NULL, "PAIR_32",
 	FALSE, 0xffffffff, 0xffffffff, FALSE),
+  /* 8 */
+  HOWTO(BFD_RELOC_MACH_O_SECTDIFF, 0, 1, 16, FALSE, 0,
+	complain_overflow_bitfield,
+	NULL, "SECTDIFF_16",
+	FALSE, 0xffff, 0xffff, FALSE),
+  HOWTO(BFD_RELOC_MACH_O_LOCAL_SECTDIFF, 0, 1, 16, FALSE, 0,
+	complain_overflow_bitfield,
+	NULL, "LSECTDIFF_16",
+	FALSE, 0xffff, 0xffff, FALSE),
+  HOWTO(BFD_RELOC_MACH_O_PAIR, 0, 1, 16, FALSE, 0,
+	complain_overflow_bitfield,
+	NULL, "PAIR_16",
+	FALSE, 0xffff, 0xffff, FALSE),
 };
 
 static bfd_boolean
@@ -101,17 +120,43 @@
       switch (reloc->r_type)
         {
         case BFD_MACH_O_GENERIC_RELOC_PAIR:
-          if (reloc->r_length != 2)
-            return FALSE;
-          res->howto = &i386_howto_table[6];
-          res->address = res[-1].address;
-          return TRUE;
+          if (reloc->r_length == 2)
+            {
+	      res->howto = &i386_howto_table[7];
+	      res->address = res[-1].address;
+	      return TRUE;
+            }
+          else if (reloc->r_length == 1)
+	    {
+	      res->howto = &i386_howto_table[10];
+	      res->address = res[-1].address;
+	      return TRUE;
+	    }
+          return FALSE;
         case BFD_MACH_O_GENERIC_RELOC_SECTDIFF:
+          if (reloc->r_length == 2)
+            {
+	      res->howto = &i386_howto_table[5];
+	      return TRUE;
+            }
+          else if (reloc->r_length == 1)
+            {
+	      res->howto = &i386_howto_table[8];
+	      return TRUE;
+            }
+          return FALSE;
         case BFD_MACH_O_GENERIC_RELOC_LOCAL_SECTDIFF:
-          if (reloc->r_length != 2)
-            return FALSE;
-          res->howto = &i386_howto_table[5];
-          return TRUE;
+          if (reloc->r_length == 2)
+            {
+	      res->howto = &i386_howto_table[6];
+	      return TRUE;
+            }
+          else if (reloc->r_length == 1)
+            {
+	      res->howto = &i386_howto_table[9];
+	      return TRUE;
+            }
+          return FALSE;
         default:
           return FALSE;
         }
@@ -178,20 +223,26 @@
       rinfo->r_scattered = 1;
       rinfo->r_type = BFD_MACH_O_GENERIC_RELOC_SECTDIFF;
       rinfo->r_pcrel = 0;
-      rinfo->r_length = 2;
+      rinfo->r_length = rel->howto->size;
       rinfo->r_extern = 0;
-      rinfo->r_value = (*rel->sym_ptr_ptr)->value 
-        + (*rel->sym_ptr_ptr)->section->vma;
+      rinfo->r_value = rel->addend;
+      break;
+    case BFD_RELOC_MACH_O_LOCAL_SECTDIFF:
+      rinfo->r_scattered = 1;
+      rinfo->r_type = BFD_MACH_O_GENERIC_RELOC_LOCAL_SECTDIFF;
+      rinfo->r_pcrel = 0;
+      rinfo->r_length = rel->howto->size;
+      rinfo->r_extern = 0;
+      rinfo->r_value = rel->addend;
       break;
     case BFD_RELOC_MACH_O_PAIR:
       rinfo->r_address = 0;
       rinfo->r_scattered = 1;
       rinfo->r_type = BFD_MACH_O_GENERIC_RELOC_PAIR;
       rinfo->r_pcrel = 0;
-      rinfo->r_length = 2;
+      rinfo->r_length = rel->howto->size;
       rinfo->r_extern = 0;
-      rinfo->r_value = (*rel->sym_ptr_ptr)->value 
-        + (*rel->sym_ptr_ptr)->section->vma;
+      rinfo->r_value = rel->addend;
       break;
     default:
       return FALSE;
@@ -280,11 +331,67 @@
   return FALSE;
 }
 
+static const mach_o_section_name_xlat text_section_names_xlat[] =
+  {
+    {	".symbol_stub",			"__symbol_stub",
+	SEC_CODE | SEC_LOAD,		BFD_MACH_O_S_SYMBOL_STUBS,
+	BFD_MACH_O_S_ATTR_PURE_INSTRUCTIONS,
+					0},
+    {	".picsymbol_stub",		"__picsymbol_stub",
+	SEC_CODE | SEC_LOAD,		BFD_MACH_O_S_SYMBOL_STUBS,
+	BFD_MACH_O_S_ATTR_PURE_INSTRUCTIONS,
+					0},
+    { NULL, NULL, 0, 0, 0, 0}
+  };
+
+static const mach_o_section_name_xlat data_section_names_xlat[] =
+  {
+    /* The first two are recognized by i386, but not emitted for x86 by
+       modern GCC.  */
+    {	".non_lazy_symbol_pointer",	"__nl_symbol_ptr",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS,
+	BFD_MACH_O_S_ATTR_NONE,		2},
+    {	".lazy_symbol_pointer",		"__la_symbol_ptr",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_LAZY_SYMBOL_POINTERS,
+	BFD_MACH_O_S_ATTR_NONE,		2},
+    {	".lazy_symbol_pointer2",	"__la_sym_ptr2",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_LAZY_SYMBOL_POINTERS,
+	BFD_MACH_O_S_ATTR_NONE,		2},
+    {	".lazy_symbol_pointer3",	"__la_sym_ptr3",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_LAZY_SYMBOL_POINTERS,
+	BFD_MACH_O_S_ATTR_NONE,		2},
+    { NULL, NULL, 0, 0, 0, 0}
+  };
+
+static const mach_o_section_name_xlat import_section_names_xlat[] =
+  {
+    {	".picsymbol_stub3",		"__jump_table",
+	SEC_CODE | SEC_LOAD,		BFD_MACH_O_S_SYMBOL_STUBS,
+	BFD_MACH_O_S_ATTR_PURE_INSTRUCTIONS
+	| BFD_MACH_O_S_SELF_MODIFYING_CODE,
+					6},
+    {	".non_lazy_symbol_pointer_x86",	"__pointers",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS,
+	BFD_MACH_O_S_ATTR_NONE,		2},
+    { NULL, NULL, 0, 0, 0, 0}
+  };
+
+const mach_o_segment_name_xlat mach_o_i386_segsec_names_xlat[] =
+  {
+    { "__TEXT", text_section_names_xlat },
+    { "__DATA", data_section_names_xlat },
+    { "__IMPORT", import_section_names_xlat },
+    { NULL, NULL }
+  };
+
 #define bfd_mach_o_swap_reloc_in bfd_mach_o_i386_swap_reloc_in
 #define bfd_mach_o_swap_reloc_out bfd_mach_o_i386_swap_reloc_out
 #define bfd_mach_o_print_thread bfd_mach_o_i386_print_thread
 
-#define bfd_mach_o_bfd_reloc_type_lookup bfd_mach_o_i386_bfd_reloc_type_lookup 
+#define bfd_mach_o_tgt_seg_table mach_o_i386_segsec_names_xlat
+#define bfd_mach_o_section_type_valid_for_tgt NULL
+
+#define bfd_mach_o_bfd_reloc_type_lookup bfd_mach_o_i386_bfd_reloc_type_lookup
 #define bfd_mach_o_bfd_reloc_name_lookup bfd_mach_o_i386_bfd_reloc_name_lookup
 
 #define TARGET_NAME 		mach_o_i386_vec
@@ -292,4 +399,5 @@
 #define TARGET_ARCHITECTURE	bfd_arch_i386
 #define TARGET_BIG_ENDIAN 	0
 #define TARGET_ARCHIVE 		0
+#define TARGET_PRIORITY		0
 #include "mach-o-target.c"
diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c
index 29682c9..497d1fa 100644
--- a/bfd/mach-o-target.c
+++ b/bfd/mach-o-target.c
@@ -15,7 +15,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software 
+   along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
@@ -25,13 +25,12 @@
 #ifndef MACH_O_TARGET_COMMON_DEFINED
 #define MACH_O_TARGET_COMMON_DEFINED
 
-#define bfd_mach_o_close_and_cleanup                  _bfd_generic_close_and_cleanup
 #define bfd_mach_o_bfd_free_cached_info               _bfd_generic_bfd_free_cached_info
 #define bfd_mach_o_get_section_contents_in_window     _bfd_generic_get_section_contents_in_window
+#define bfd_mach_o_bfd_print_private_bfd_data	      _bfd_generic_bfd_print_private_bfd_data
 #define bfd_mach_o_bfd_is_target_special_symbol       ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
 #define bfd_mach_o_bfd_is_local_label_name            bfd_generic_is_local_label_name
 #define bfd_mach_o_get_lineno                         _bfd_nosymbols_get_lineno
-#define bfd_mach_o_find_nearest_line                  _bfd_nosymbols_find_nearest_line
 #define bfd_mach_o_find_inliner_info                  _bfd_nosymbols_find_inliner_info
 #define bfd_mach_o_bfd_make_debug_symbol              _bfd_nosymbols_bfd_make_debug_symbol
 #define bfd_mach_o_read_minisymbols                   _bfd_generic_read_minisymbols
@@ -47,7 +46,7 @@
 #define bfd_mach_o_bfd_final_link                     _bfd_generic_final_link
 #define bfd_mach_o_bfd_link_split_section             _bfd_generic_link_split_section
 #define bfd_mach_o_bfd_merge_private_bfd_data         _bfd_generic_bfd_merge_private_bfd_data
-#define bfd_mach_o_bfd_set_private_flags              _bfd_generic_bfd_set_private_flags
+#define bfd_mach_o_bfd_set_private_flags              bfd_mach_o_bfd_set_private_flags
 #define bfd_mach_o_get_section_contents               _bfd_generic_get_section_contents
 #define bfd_mach_o_bfd_gc_sections                    bfd_generic_gc_sections
 #define bfd_mach_o_bfd_lookup_section_flags           bfd_generic_lookup_section_flags
@@ -96,7 +95,9 @@
   TARGET_ARCHITECTURE,
   bfd_mach_o_swap_reloc_in,
   bfd_mach_o_swap_reloc_out,
-  bfd_mach_o_print_thread
+  bfd_mach_o_print_thread,
+  bfd_mach_o_tgt_seg_table,
+  bfd_mach_o_section_type_valid_for_tgt
 };
 
 const bfd_target TARGET_NAME =
@@ -118,7 +119,7 @@
   '_',				/* symbol_leading_char.  */
   ' ',				/* ar_pad_char.  */
   16,				/* ar_max_namelen.  */
-  0,				/* match priority.  */
+  TARGET_PRIORITY,	/* match priority.  */
 
 #if TARGET_BIG_ENDIAN
   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
diff --git a/bfd/mach-o-x86-64.c b/bfd/mach-o-x86-64.c
index 2248d97..232701e 100644
--- a/bfd/mach-o-x86-64.c
+++ b/bfd/mach-o-x86-64.c
@@ -224,21 +224,56 @@
   rinfo->r_scattered = 0;
   switch (rel->howto->type)
     {
+    case BFD_RELOC_32:
+      rinfo->r_type = BFD_MACH_O_X86_64_RELOC_UNSIGNED;
+      rinfo->r_pcrel = 0;
+      rinfo->r_length = 2;
+      break;
     case BFD_RELOC_64:
       rinfo->r_type = BFD_MACH_O_X86_64_RELOC_UNSIGNED;
       rinfo->r_pcrel = 0;
       rinfo->r_length = 3;
       break;
     case BFD_RELOC_32_PCREL:
+      rinfo->r_type = BFD_MACH_O_X86_64_RELOC_SIGNED;
+      rinfo->r_pcrel = 1;
+      rinfo->r_length = 2;
+      break;
+    case BFD_RELOC_MACH_O_X86_64_PCREL32_1:
+      rinfo->r_type = BFD_MACH_O_X86_64_RELOC_SIGNED_1;
+      rinfo->r_pcrel = 1;
+      rinfo->r_length = 2;
+      break;
+    case BFD_RELOC_MACH_O_X86_64_PCREL32_2:
+      rinfo->r_type = BFD_MACH_O_X86_64_RELOC_SIGNED_2;
+      rinfo->r_pcrel = 1;
+      rinfo->r_length = 2;
+      break;
+    case BFD_RELOC_MACH_O_X86_64_PCREL32_4:
+      rinfo->r_type = BFD_MACH_O_X86_64_RELOC_SIGNED_4;
+      rinfo->r_pcrel = 1;
+      rinfo->r_length = 2;
+      break;
+    case BFD_RELOC_MACH_O_X86_64_BRANCH32:
       rinfo->r_type = BFD_MACH_O_X86_64_RELOC_BRANCH;
       rinfo->r_pcrel = 1;
       rinfo->r_length = 2;
       break;
+    case BFD_RELOC_MACH_O_X86_64_SUBTRACTOR32:
+      rinfo->r_type = BFD_MACH_O_X86_64_RELOC_SUBTRACTOR;
+      rinfo->r_pcrel = 0;
+      rinfo->r_length = 2;
+      break;
     case BFD_RELOC_MACH_O_X86_64_SUBTRACTOR64:
       rinfo->r_type = BFD_MACH_O_X86_64_RELOC_SUBTRACTOR;
       rinfo->r_pcrel = 0;
       rinfo->r_length = 3;
       break;
+    case BFD_RELOC_MACH_O_X86_64_GOT:
+      rinfo->r_type = BFD_MACH_O_X86_64_RELOC_GOT;
+      rinfo->r_pcrel = 1;
+      rinfo->r_length = 2;
+      break;
     case BFD_RELOC_MACH_O_X86_64_GOT_LOAD:
       rinfo->r_type = BFD_MACH_O_X86_64_RELOC_GOT_LOAD;
       rinfo->r_pcrel = 1;
@@ -281,16 +316,46 @@
   return NULL;
 }
 
+static bfd_boolean
+bfd_mach_o_section_type_valid_for_x86_64 (unsigned long val)
+{
+  if (val == BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS
+      || val == BFD_MACH_O_S_LAZY_SYMBOL_POINTERS
+      || val == BFD_MACH_O_S_SYMBOL_STUBS)
+    return FALSE;
+  return TRUE;
+}
+
+/* We want to bump the alignment of some sections.  */
+static const mach_o_section_name_xlat text_section_names_xlat[] =
+  {
+    {	".eh_frame",				"__eh_frame",
+	SEC_READONLY | SEC_DATA | SEC_LOAD,	BFD_MACH_O_S_COALESCED,
+	BFD_MACH_O_S_ATTR_LIVE_SUPPORT
+	| BFD_MACH_O_S_ATTR_STRIP_STATIC_SYMS
+	| BFD_MACH_O_S_ATTR_NO_TOC,		3},
+    { NULL, NULL, 0, 0, 0, 0}
+  };
+
+const mach_o_segment_name_xlat mach_o_x86_64_segsec_names_xlat[] =
+  {
+    { "__TEXT", text_section_names_xlat },
+    { NULL, NULL }
+  };
+
 #define bfd_mach_o_swap_reloc_in bfd_mach_o_x86_64_swap_reloc_in
 #define bfd_mach_o_swap_reloc_out bfd_mach_o_x86_64_swap_reloc_out
 
 #define bfd_mach_o_bfd_reloc_type_lookup bfd_mach_o_x86_64_bfd_reloc_type_lookup
 #define bfd_mach_o_bfd_reloc_name_lookup bfd_mach_o_x86_64_bfd_reloc_name_lookup
 #define bfd_mach_o_print_thread NULL
+#define bfd_mach_o_tgt_seg_table mach_o_x86_64_segsec_names_xlat
+#define bfd_mach_o_section_type_valid_for_tgt bfd_mach_o_section_type_valid_for_x86_64
 
 #define TARGET_NAME 		mach_o_x86_64_vec
 #define TARGET_STRING 		"mach-o-x86-64"
 #define TARGET_ARCHITECTURE	bfd_arch_i386
 #define TARGET_BIG_ENDIAN 	0
 #define TARGET_ARCHIVE 		0
+#define TARGET_PRIORITY		0
 #include "mach-o-target.c"
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index 91f0306..32e48ac 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -1,7 +1,5 @@
 /* Mach-O support for BFD.
-   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-   2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright 1999-2013 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -29,6 +27,8 @@
 #include "mach-o/reloc.h"
 #include "mach-o/external.h"
 #include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
 
 #define bfd_mach_o_object_p bfd_mach_o_gen_object_p
 #define bfd_mach_o_core_p bfd_mach_o_gen_core_p
@@ -37,8 +37,6 @@
 #define FILE_ALIGN(off, algn) \
   (((off) + ((file_ptr) 1 << (algn)) - 1) & ((file_ptr) -1 << (algn)))
 
-static int bfd_mach_o_read_symtab_symbols (bfd *);
-
 unsigned int
 bfd_mach_o_version (bfd *abfd)
 {
@@ -84,123 +82,322 @@
 {
   return mach_o_wide_p (&bfd_mach_o_get_data (abfd)->header);
 }
-      
+
 /* Tables to translate well known Mach-O segment/section names to bfd
    names.  Use of canonical names (such as .text or .debug_frame) is required
    by gdb.  */
 
-struct mach_o_section_name_xlat
-{
-  const char *bfd_name;
-  const char *mach_o_name;
-  flagword flags;
-};
-
-static const struct mach_o_section_name_xlat dwarf_section_names_xlat[] =
+/* __TEXT Segment.  */
+static const mach_o_section_name_xlat text_section_names_xlat[] =
   {
-    { ".debug_frame",    "__debug_frame",    SEC_DEBUGGING },
-    { ".debug_info",     "__debug_info",     SEC_DEBUGGING },
-    { ".debug_abbrev",   "__debug_abbrev",   SEC_DEBUGGING },
-    { ".debug_aranges",  "__debug_aranges",  SEC_DEBUGGING },
-    { ".debug_macinfo",  "__debug_macinfo",  SEC_DEBUGGING },
-    { ".debug_line",     "__debug_line",     SEC_DEBUGGING },
-    { ".debug_loc",      "__debug_loc",      SEC_DEBUGGING },
-    { ".debug_pubnames", "__debug_pubnames", SEC_DEBUGGING },
-    { ".debug_pubtypes", "__debug_pubtypes", SEC_DEBUGGING },
-    { ".debug_str",      "__debug_str",      SEC_DEBUGGING },
-    { ".debug_ranges",   "__debug_ranges",   SEC_DEBUGGING },
-    { NULL, NULL, 0}
+    {	".text",				"__text",
+	SEC_CODE | SEC_LOAD,			BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_PURE_INSTRUCTIONS,	0},
+    {	".const",				"__const",
+	SEC_READONLY | SEC_DATA | SEC_LOAD,	BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NONE,			0},
+    {	".static_const",			"__static_const",
+	SEC_READONLY | SEC_DATA | SEC_LOAD,	BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NONE,			0},
+    {	".cstring",				"__cstring",
+	SEC_READONLY | SEC_DATA | SEC_LOAD | SEC_MERGE | SEC_STRINGS,
+						BFD_MACH_O_S_CSTRING_LITERALS,
+	BFD_MACH_O_S_ATTR_NONE,			0},
+    {	".literal4",				"__literal4",
+	SEC_READONLY | SEC_DATA | SEC_LOAD,	BFD_MACH_O_S_4BYTE_LITERALS,
+	BFD_MACH_O_S_ATTR_NONE,			2},
+    {	".literal8",				"__literal8",
+	SEC_READONLY | SEC_DATA | SEC_LOAD,	BFD_MACH_O_S_8BYTE_LITERALS,
+	BFD_MACH_O_S_ATTR_NONE,			3},
+    {	".literal16",				"__literal16",
+	SEC_READONLY | SEC_DATA | SEC_LOAD,	BFD_MACH_O_S_16BYTE_LITERALS,
+	BFD_MACH_O_S_ATTR_NONE,			4},
+    {	".constructor",				"__constructor",
+	SEC_CODE | SEC_LOAD,			BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NONE,			0},
+    {	".destructor",				"__destructor",
+	SEC_CODE | SEC_LOAD,			BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NONE,			0},
+    {	".eh_frame",				"__eh_frame",
+	SEC_READONLY | SEC_DATA | SEC_LOAD,	BFD_MACH_O_S_COALESCED,
+	BFD_MACH_O_S_ATTR_LIVE_SUPPORT
+	| BFD_MACH_O_S_ATTR_STRIP_STATIC_SYMS
+	| BFD_MACH_O_S_ATTR_NO_TOC,		2},
+    { NULL, NULL, 0, 0, 0, 0}
   };
 
-static const struct mach_o_section_name_xlat text_section_names_xlat[] =
+/* __DATA Segment.  */
+static const mach_o_section_name_xlat data_section_names_xlat[] =
   {
-    { ".text",     "__text",      SEC_CODE | SEC_LOAD },
-    { ".const",    "__const",     SEC_READONLY | SEC_DATA | SEC_LOAD },
-    { ".cstring",  "__cstring",   SEC_READONLY | SEC_DATA | SEC_LOAD },
-    { ".eh_frame", "__eh_frame",  SEC_READONLY | SEC_LOAD },
-    { NULL, NULL, 0}
+    {	".data",			"__data",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NONE,		0},
+    {	".bss",				"__bss",
+	SEC_NO_FLAGS,			BFD_MACH_O_S_ZEROFILL,
+	BFD_MACH_O_S_ATTR_NONE,		0},
+    {	".const_data",			"__const",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NONE,		0},
+    {	".static_data",			"__static_data",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NONE,		0},
+    {	".mod_init_func",		"__mod_init_func",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_MOD_INIT_FUNC_POINTERS,
+	BFD_MACH_O_S_ATTR_NONE,		2},
+    {	".mod_term_func",		"__mod_term_func",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_MOD_FINI_FUNC_POINTERS,
+	BFD_MACH_O_S_ATTR_NONE,		2},
+    {	".dyld",			"__dyld",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NONE,		0},
+    {	".cfstring",			"__cfstring",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NONE,		2},
+    { NULL, NULL, 0, 0, 0, 0}
   };
 
-static const struct mach_o_section_name_xlat data_section_names_xlat[] =
+/* __DWARF Segment.  */
+static const mach_o_section_name_xlat dwarf_section_names_xlat[] =
   {
-    { ".data",                "__data",          SEC_DATA | SEC_LOAD },
-    { ".const_data",          "__const",         SEC_DATA | SEC_LOAD },
-    { ".dyld",                "__dyld",          SEC_DATA | SEC_LOAD },
-    { ".lazy_symbol_ptr",     "__la_symbol_ptr", SEC_DATA | SEC_LOAD },
-    { ".non_lazy_symbol_ptr", "__nl_symbol_ptr", SEC_DATA | SEC_LOAD },
-    { ".bss",                 "__bss",           SEC_NO_FLAGS },
-    { NULL, NULL, 0}
+    {	".debug_frame",			"__debug_frame",
+	SEC_DEBUGGING,			BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_DEBUG,	0},
+    {	".debug_info",			"__debug_info",
+	SEC_DEBUGGING,			BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_DEBUG,	0},
+    {	".debug_abbrev",		"__debug_abbrev",
+	SEC_DEBUGGING,			BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_DEBUG,	0},
+    {	".debug_aranges",		"__debug_aranges",
+	SEC_DEBUGGING,			BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_DEBUG,	0},
+    {	".debug_macinfo",		"__debug_macinfo",
+	SEC_DEBUGGING,			BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_DEBUG,	0},
+    {	".debug_line",			"__debug_line",
+	SEC_DEBUGGING,			BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_DEBUG,	0},
+    {	".debug_loc",			"__debug_loc",
+	SEC_DEBUGGING,			BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_DEBUG,	0},
+    {	".debug_pubnames",		"__debug_pubnames",
+	SEC_DEBUGGING,			BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_DEBUG,	0},
+    {	".debug_pubtypes",		"__debug_pubtypes",
+	SEC_DEBUGGING,			BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_DEBUG,	0},
+    {	".debug_str",			"__debug_str",
+	SEC_DEBUGGING,			BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_DEBUG,	0},
+    {	".debug_ranges",		"__debug_ranges",
+	SEC_DEBUGGING,			BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_DEBUG,	0},
+    {	".debug_macro",			"__debug_macro",
+	SEC_DEBUGGING,			BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_DEBUG,	0},
+    {	".debug_gdb_scripts",		"__debug_gdb_scri",
+	SEC_DEBUGGING,			BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_DEBUG,	0},
+    { NULL, NULL, 0, 0, 0, 0}
   };
 
-struct mach_o_segment_name_xlat
-{
-  /* Segment name.  */
-  const char *segname;
+/* __OBJC Segment.  */
+static const mach_o_section_name_xlat objc_section_names_xlat[] =
+  {
+    {	".objc_class",			"__class",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    {	".objc_meta_class",		"__meta_class",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    {	".objc_cat_cls_meth",		"__cat_cls_meth",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    {	".objc_cat_inst_meth",		"__cat_inst_meth",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    {	".objc_protocol",		"__protocol",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    {	".objc_string_object",		"__string_object",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    {	".objc_cls_meth",		"__cls_meth",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    {	".objc_inst_meth",		"__inst_meth",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    {	".objc_cls_refs",		"__cls_refs",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_LITERAL_POINTERS,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    {	".objc_message_refs",		"__message_refs",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_LITERAL_POINTERS,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    {	".objc_symbols",		"__symbols",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    {	".objc_category",		"__category",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    {	".objc_class_vars",		"__class_vars",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    {	".objc_instance_vars",		"__instance_vars",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    {	".objc_module_info",		"__module_info",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    {	".objc_selector_strs",		"__selector_strs",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_CSTRING_LITERALS,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    {	".objc_image_info",		"__image_info",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    {	".objc_selector_fixup",		"__sel_fixup",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    /* Objc V1 */
+    {	".objc1_class_ext",		"__class_ext",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    {	".objc1_property_list",		"__property",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    {	".objc1_protocol_ext",		"__protocol_ext",
+	SEC_DATA | SEC_LOAD,		BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
+    { NULL, NULL, 0, 0, 0, 0}
+  };
 
-  /* List of known sections for the segment.  */
-  const struct mach_o_section_name_xlat *sections;
-};
-
-/* List of known segment names.  */
-
-static const struct mach_o_segment_name_xlat segsec_names_xlat[] =
+static const mach_o_segment_name_xlat segsec_names_xlat[] =
   {
     { "__TEXT", text_section_names_xlat },
     { "__DATA", data_section_names_xlat },
     { "__DWARF", dwarf_section_names_xlat },
+    { "__OBJC", objc_section_names_xlat },
     { NULL, NULL }
   };
 
-/* Mach-O to bfd names.  */
+static const char dsym_subdir[] = ".dSYM/Contents/Resources/DWARF";
 
-void
-bfd_mach_o_normalize_section_name (const char *segname, const char *sectname,
-                                   const char **name, flagword *flags)
+/* For both cases bfd-name => mach-o name and vice versa, the specific target
+   is checked before the generic.  This allows a target (e.g. ppc for cstring)
+   to override the generic definition with a more specific one.  */
+
+/* Fetch the translation from a Mach-O section designation (segment, section)
+   as a bfd short name, if one exists.  Otherwise return NULL.
+
+   Allow the segment and section names to be unterminated 16 byte arrays.  */
+
+const mach_o_section_name_xlat *
+bfd_mach_o_section_data_for_mach_sect (bfd *abfd, const char *segname,
+				       const char *sectname)
 {
   const struct mach_o_segment_name_xlat *seg;
+  const mach_o_section_name_xlat *sec;
+  bfd_mach_o_backend_data *bed = bfd_mach_o_get_backend_data (abfd);
 
-  *name = NULL;
-  *flags = SEC_NO_FLAGS;
-
-  for (seg = segsec_names_xlat; seg->segname; seg++)
-    {
+  /* First try any target-specific translations defined...  */
+  if (bed->segsec_names_xlat)
+    for (seg = bed->segsec_names_xlat; seg->segname; seg++)
       if (strncmp (seg->segname, segname, BFD_MACH_O_SEGNAME_SIZE) == 0)
-        {
-          const struct mach_o_section_name_xlat *sec;
+	for (sec = seg->sections; sec->mach_o_name; sec++)
+	  if (strncmp (sec->mach_o_name, sectname,
+		       BFD_MACH_O_SECTNAME_SIZE) == 0)
+	    return sec;
 
-          for (sec = seg->sections; sec->mach_o_name; sec++)
-            {
-              if (strncmp (sec->mach_o_name, sectname,
-                           BFD_MACH_O_SECTNAME_SIZE) == 0)
-                {
-                  *name = sec->bfd_name;
-                  *flags = sec->flags;
-                  return;
-                }
-            }
-          return;
-        }
-    }
+  /* ... and then the Mach-O generic ones.  */
+  for (seg = segsec_names_xlat; seg->segname; seg++)
+    if (strncmp (seg->segname, segname, BFD_MACH_O_SEGNAME_SIZE) == 0)
+      for (sec = seg->sections; sec->mach_o_name; sec++)
+        if (strncmp (sec->mach_o_name, sectname,
+		     BFD_MACH_O_SECTNAME_SIZE) == 0)
+          return sec;
+
+  return NULL;
 }
 
-/* Convert Mach-O section name to BFD.  Try to use standard names, otherwise
-   forge a new name.  SEGNAME and SECTNAME are 16 bytes strings.  */
+/* If the bfd_name for this section is a 'canonical' form for which we
+   know the Mach-O data, return the segment name and the data for the
+   Mach-O equivalent.  Otherwise return NULL.  */
 
-static void
-bfd_mach_o_convert_section_name_to_bfd
-  (bfd *abfd, const char *segname, const char *sectname,
-   const char **name, flagword *flags)
+const mach_o_section_name_xlat *
+bfd_mach_o_section_data_for_bfd_name (bfd *abfd, const char *bfd_name,
+				      const char **segname)
 {
+  const struct mach_o_segment_name_xlat *seg;
+  const mach_o_section_name_xlat *sec;
+  bfd_mach_o_backend_data *bed = bfd_mach_o_get_backend_data (abfd);
+  *segname = NULL;
+
+  if (bfd_name[0] != '.')
+    return NULL;
+
+  /* First try any target-specific translations defined...  */
+  if (bed->segsec_names_xlat)
+    for (seg = bed->segsec_names_xlat; seg->segname; seg++)
+      for (sec = seg->sections; sec->bfd_name; sec++)
+	if (strcmp (bfd_name, sec->bfd_name) == 0)
+	  {
+	    *segname = seg->segname;
+	    return sec;
+	  }
+
+  /* ... and then the Mach-O generic ones.  */
+  for (seg = segsec_names_xlat; seg->segname; seg++)
+    for (sec = seg->sections; sec->bfd_name; sec++)
+      if (strcmp (bfd_name, sec->bfd_name) == 0)
+	{
+	  *segname = seg->segname;
+	  return sec;
+	}
+
+  return NULL;
+}
+
+/* Convert Mach-O section name to BFD.
+
+   Try to use standard/canonical names, for which we have tables including
+   default flag settings - which are returned.  Otherwise forge a new name
+   in the form "<segmentname>.<sectionname>" this will be prefixed with
+   LC_SEGMENT. if the segment name does not begin with an underscore.
+
+   SEGNAME and SECTNAME are 16 byte arrays (they do not need to be NUL-
+   terminated if the name length is exactly 16 bytes - but must be if the name
+   length is less than 16 characters).  */
+
+void
+bfd_mach_o_convert_section_name_to_bfd (bfd *abfd, const char *segname,
+					const char *secname, const char **name,
+					flagword *flags)
+{
+  const mach_o_section_name_xlat *xlat;
   char *res;
   unsigned int len;
   const char *pfx = "";
 
-  /* First search for a canonical name.  */
-  bfd_mach_o_normalize_section_name (segname, sectname, name, flags);
+  *name = NULL;
+  *flags = SEC_NO_FLAGS;
 
-  /* Return now if found.  */
-  if (*name)
-    return;
+  /* First search for a canonical name...
+     xlat will be non-null if there is an entry for segname, secname.  */
+  xlat = bfd_mach_o_section_data_for_mach_sect (abfd, segname, secname);
+  if (xlat)
+    {
+      len = strlen (xlat->bfd_name);
+      res = bfd_alloc (abfd, len+1);
+      if (res == NULL)
+	return;
+      memcpy (res, xlat->bfd_name, len+1);
+      *name = res;
+      *flags = xlat->bfd_flags;
+      return;
+    }
+
+  /* ... else we make up a bfd name from the segment concatenated with the
+     section.  */
 
   len = 16 + 1 + 16 + 1;
 
@@ -217,43 +414,46 @@
   res = bfd_alloc (abfd, len);
   if (res == NULL)
     return;
-  snprintf (res, len, "%s%.16s.%.16s", pfx, segname, sectname);
+  snprintf (res, len, "%s%.16s.%.16s", pfx, segname, secname);
   *name = res;
-  *flags = SEC_NO_FLAGS;
 }
 
-/* Convert a bfd section name to a Mach-O segment + section name.  */
+/* Convert a bfd section name to a Mach-O segment + section name.
 
-static void
+   If the name is a canonical one for which we have a Darwin match
+   return the translation table - which contains defaults for flags,
+   type, attribute and default alignment data.
+
+   Otherwise, expand the bfd_name (assumed to be in the form
+   "[LC_SEGMENT.]<segmentname>.<sectionname>") and return NULL.  */
+
+static const mach_o_section_name_xlat *
 bfd_mach_o_convert_section_name_to_mach_o (bfd *abfd ATTRIBUTE_UNUSED,
                                            asection *sect,
                                            bfd_mach_o_section *section)
 {
-  const struct mach_o_segment_name_xlat *seg;
+  const mach_o_section_name_xlat *xlat;
   const char *name = bfd_get_section_name (abfd, sect);
+  const char *segname;
   const char *dot;
   unsigned int len;
   unsigned int seglen;
   unsigned int seclen;
 
-  /* List of well known names.  They all start with a dot.  */
-  if (name[0] == '.')
-    for (seg = segsec_names_xlat; seg->segname; seg++)
-      {
-        const struct mach_o_section_name_xlat *sec;
+  memset (section->segname, 0, BFD_MACH_O_SEGNAME_SIZE + 1);
+  memset (section->sectname, 0, BFD_MACH_O_SECTNAME_SIZE + 1);
 
-        for (sec = seg->sections; sec->mach_o_name; sec++)
-          {
-            if (strcmp (sec->bfd_name, name) == 0)
-              {
-                strcpy (section->segname, seg->segname);
-                strcpy (section->sectname, sec->mach_o_name);
-                return;
-              }
-          }
-      }
+  /* See if is a canonical name ... */
+  xlat = bfd_mach_o_section_data_for_bfd_name (abfd, name, &segname);
+  if (xlat)
+    {
+      strcpy (section->segname, segname);
+      strcpy (section->sectname, xlat->mach_o_name);
+      return xlat;
+    }
 
-  /* Strip LC_SEGMENT. prefix.  */
+  /* .. else we convert our constructed one back to Mach-O.
+     Strip LC_SEGMENT. prefix, if present.  */
   if (strncmp (name, "LC_SEGMENT.", 11) == 0)
     name += 11;
 
@@ -273,23 +473,30 @@
           section->segname[seglen] = 0;
           memcpy (section->sectname, dot + 1, seclen);
           section->sectname[seclen] = 0;
-          return;
+          return NULL;
         }
     }
 
+  /* The segment and section names are both missing - don't make them
+     into dots.  */
+  if (dot && dot == name)
+    return NULL;
+
+  /* Just duplicate the name into both segment and section.  */
   if (len > 16)
     len = 16;
   memcpy (section->segname, name, len);
   section->segname[len] = 0;
   memcpy (section->sectname, name, len);
   section->sectname[len] = 0;
+  return NULL;
 }
 
 /* Return the size of an entry for section SEC.
    Must be called only for symbol pointer section and symbol stubs
    sections.  */
 
-static unsigned int
+unsigned int
 bfd_mach_o_section_get_entry_size (bfd *abfd, bfd_mach_o_section *sec)
 {
   switch (sec->flags & BFD_MACH_O_SECTION_TYPE_MASK)
@@ -309,7 +516,7 @@
    Must be called only for symbol pointer section and symbol stubs
    sections.  */
 
-static unsigned int
+unsigned int
 bfd_mach_o_section_get_nbr_indirect (bfd *abfd, bfd_mach_o_section *sec)
 {
   unsigned int elsz;
@@ -327,10 +534,17 @@
 
 bfd_boolean
 bfd_mach_o_bfd_copy_private_symbol_data (bfd *ibfd ATTRIBUTE_UNUSED,
-					 asymbol *isymbol ATTRIBUTE_UNUSED,
+					 asymbol *isymbol,
 					 bfd *obfd ATTRIBUTE_UNUSED,
-					 asymbol *osymbol ATTRIBUTE_UNUSED)
+					 asymbol *osymbol)
 {
+  bfd_mach_o_asymbol *os, *is;
+  os = (bfd_mach_o_asymbol *)osymbol;
+  is = (bfd_mach_o_asymbol *)isymbol;
+  os->n_type = is->n_type;
+  os->n_sect = is->n_sect;
+  os->n_desc = is->n_desc;
+  os->symbol.udata.i = is->symbol.udata.i;
   return TRUE;
 }
 
@@ -339,10 +553,20 @@
 
 bfd_boolean
 bfd_mach_o_bfd_copy_private_section_data (bfd *ibfd ATTRIBUTE_UNUSED,
-					  asection *isection ATTRIBUTE_UNUSED,
+					  asection *isection,
 					  bfd *obfd ATTRIBUTE_UNUSED,
-					  asection *osection ATTRIBUTE_UNUSED)
+					  asection *osection)
 {
+  if (osection->used_by_bfd == NULL)
+    osection->used_by_bfd = isection->used_by_bfd;
+  else
+    if (isection->used_by_bfd != NULL)
+      memcpy (osection->used_by_bfd, isection->used_by_bfd,
+	      sizeof (bfd_mach_o_section));
+
+  if (osection->used_by_bfd != NULL)
+    ((bfd_mach_o_section *)osection->used_by_bfd)->bfdsection = osection;
+
   return TRUE;
 }
 
@@ -364,6 +588,22 @@
   return TRUE;
 }
 
+/* This allows us to set up to 32 bits of flags (unless we invent some
+   fiendish scheme to subdivide).  For now, we'll just set the file flags
+   without error checking - just overwrite.  */
+
+bfd_boolean
+bfd_mach_o_bfd_set_private_flags (bfd *abfd, flagword flags)
+{
+  bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
+
+  if (!mdata)
+    return FALSE;
+
+  mdata->header.flags = flags;
+  return TRUE;
+}
+
 /* Count the total number of symbols.  */
 
 static long
@@ -402,9 +642,10 @@
       return 0;
     }
 
-  if (bfd_mach_o_read_symtab_symbols (abfd) != 0)
+  if (!bfd_mach_o_read_symtab_symbols (abfd))
     {
-      (*_bfd_error_handler) (_("bfd_mach_o_canonicalize_symtab: unable to load symbols"));
+      (*_bfd_error_handler)
+        (_("bfd_mach_o_canonicalize_symtab: unable to load symbols"));
       return 0;
     }
 
@@ -418,6 +659,8 @@
   return nsyms;
 }
 
+/* Create synthetic symbols for indirect symbols.  */
+
 long
 bfd_mach_o_get_synthetic_symtab (bfd *abfd,
                                  long symcount ATTRIBUTE_UNUSED,
@@ -437,19 +680,23 @@
 
   *ret = NULL;
 
+  /* Stop now if no symbols or no indirect symbols.  */
   if (dysymtab == NULL || symtab == NULL || symtab->symbols == NULL)
     return 0;
 
   if (dysymtab->nindirectsyms == 0)
     return 0;
 
+  /* We need to allocate a bfd symbol for every indirect symbol and to
+     allocate the memory for its name.  */
   count = dysymtab->nindirectsyms;
   size = count * sizeof (asymbol) + 1;
 
   for (j = 0; j < count; j++)
     {
       unsigned int isym = dysymtab->indirect_syms[j];
-              
+
+      /* Some indirect symbols are anonymous.  */
       if (isym < symtab->nsyms && symtab->symbols[isym].symbol.name)
         size += strlen (symtab->symbols[isym].symbol.name) + sizeof ("$stub");
     }
@@ -460,7 +707,7 @@
   names = (char *) (s + count);
   nul_name = names;
   *names++ = 0;
-  
+
   n = 0;
   for (i = 0; i < mdata->nsects; i++)
     {
@@ -468,12 +715,13 @@
       unsigned int first, last;
       bfd_vma addr;
       bfd_vma entry_size;
-      
+
       switch (sec->flags & BFD_MACH_O_SECTION_TYPE_MASK)
         {
         case BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS:
         case BFD_MACH_O_S_LAZY_SYMBOL_POINTERS:
         case BFD_MACH_O_S_SYMBOL_STUBS:
+          /* Only these sections have indirect symbols.  */
           first = sec->reserved1;
           last = first + bfd_mach_o_section_get_nbr_indirect (abfd, sec);
           addr = sec->addr;
@@ -486,7 +734,7 @@
               s->section = sec->bfdsection;
               s->value = addr - sec->addr;
               s->udata.p = NULL;
-              
+
               if (isym < symtab->nsyms
                   && symtab->symbols[isym].symbol.name)
                 {
@@ -547,7 +795,10 @@
 	switch (asym->n_type & BFD_MACH_O_N_TYPE)
 	  {
 	  case BFD_MACH_O_N_UNDF:
-	    name = "UND";
+            if (symbol->value == 0)
+              name = "UND";
+            else
+              name = "COM";
 	    break;
 	  case BFD_MACH_O_N_ABS:
 	    name = "ABS";
@@ -571,14 +822,14 @@
                asym->n_type, name, asym->n_sect, asym->n_desc);
       if ((asym->n_type & BFD_MACH_O_N_STAB) == 0
 	  && (asym->n_type & BFD_MACH_O_N_TYPE) == BFD_MACH_O_N_SECT)
-	fprintf (file, " %-5s", symbol->section->name);
+	fprintf (file, " [%s]", symbol->section->name);
       fprintf (file, " %s", symbol->name);
     }
 }
 
 static void
 bfd_mach_o_convert_architecture (bfd_mach_o_cpu_type mtype,
-				 bfd_mach_o_cpu_subtype msubtype ATTRIBUTE_UNUSED,
+				 bfd_mach_o_cpu_subtype msubtype,
 				 enum bfd_architecture *type,
 				 unsigned long *subtype)
 {
@@ -586,8 +837,12 @@
 
   switch (mtype)
     {
-    case BFD_MACH_O_CPU_TYPE_VAX: *type = bfd_arch_vax; break;
-    case BFD_MACH_O_CPU_TYPE_MC680x0: *type = bfd_arch_m68k; break;
+    case BFD_MACH_O_CPU_TYPE_VAX:
+      *type = bfd_arch_vax;
+      break;
+    case BFD_MACH_O_CPU_TYPE_MC680x0:
+      *type = bfd_arch_m68k;
+      break;
     case BFD_MACH_O_CPU_TYPE_I386:
       *type = bfd_arch_i386;
       *subtype = bfd_mach_i386_i386;
@@ -596,17 +851,52 @@
       *type = bfd_arch_i386;
       *subtype = bfd_mach_x86_64;
       break;
-    case BFD_MACH_O_CPU_TYPE_MIPS: *type = bfd_arch_mips; break;
-    case BFD_MACH_O_CPU_TYPE_MC98000: *type = bfd_arch_m98k; break;
-    case BFD_MACH_O_CPU_TYPE_HPPA: *type = bfd_arch_hppa; break;
-    case BFD_MACH_O_CPU_TYPE_ARM: *type = bfd_arch_arm; break;
-    case BFD_MACH_O_CPU_TYPE_MC88000: *type = bfd_arch_m88k; break;
+    case BFD_MACH_O_CPU_TYPE_MIPS:
+      *type = bfd_arch_mips;
+      break;
+    case BFD_MACH_O_CPU_TYPE_MC98000:
+      *type = bfd_arch_m98k;
+      break;
+    case BFD_MACH_O_CPU_TYPE_HPPA:
+      *type = bfd_arch_hppa;
+      break;
+    case BFD_MACH_O_CPU_TYPE_ARM:
+      *type = bfd_arch_arm;
+      switch (msubtype)
+        {
+        case BFD_MACH_O_CPU_SUBTYPE_ARM_V4T:
+          *subtype = bfd_mach_arm_4T;
+          break;
+        case BFD_MACH_O_CPU_SUBTYPE_ARM_V6:
+          *subtype = bfd_mach_arm_4T;	/* Best fit ?  */
+          break;
+        case BFD_MACH_O_CPU_SUBTYPE_ARM_V5TEJ:
+          *subtype = bfd_mach_arm_5TE;
+          break;
+        case BFD_MACH_O_CPU_SUBTYPE_ARM_XSCALE:
+          *subtype = bfd_mach_arm_XScale;
+          break;
+        case BFD_MACH_O_CPU_SUBTYPE_ARM_V7:
+          *subtype = bfd_mach_arm_5TE;	/* Best fit ?  */
+          break;
+        case BFD_MACH_O_CPU_SUBTYPE_ARM_ALL:
+        default:
+          break;
+        }
+      break;
+    case BFD_MACH_O_CPU_TYPE_MC88000:
+      *type = bfd_arch_m88k;
+      break;
     case BFD_MACH_O_CPU_TYPE_SPARC:
       *type = bfd_arch_sparc;
       *subtype = bfd_mach_sparc;
       break;
-    case BFD_MACH_O_CPU_TYPE_I860: *type = bfd_arch_i860; break;
-    case BFD_MACH_O_CPU_TYPE_ALPHA: *type = bfd_arch_alpha; break;
+    case BFD_MACH_O_CPU_TYPE_I860:
+      *type = bfd_arch_i860;
+      break;
+    case BFD_MACH_O_CPU_TYPE_ALPHA:
+      *type = bfd_arch_alpha;
+      break;
     case BFD_MACH_O_CPU_TYPE_POWERPC:
       *type = bfd_arch_powerpc;
       *subtype = bfd_mach_ppc;
@@ -686,6 +976,35 @@
   return (asect->reloc_count + 1) * sizeof (arelent *);
 }
 
+/* In addition to the need to byte-swap the symbol number, the bit positions
+   of the fields in the relocation information vary per target endian-ness.  */
+
+static void
+bfd_mach_o_swap_in_non_scattered_reloc (bfd *abfd, bfd_mach_o_reloc_info *rel,
+				       unsigned char *fields)
+{
+  unsigned char info = fields[3];
+
+  if (bfd_big_endian (abfd))
+    {
+      rel->r_value = (fields[0] << 16) | (fields[1] << 8) | fields[2];
+      rel->r_type = (info >> BFD_MACH_O_BE_TYPE_SHIFT) & BFD_MACH_O_TYPE_MASK;
+      rel->r_pcrel = (info & BFD_MACH_O_BE_PCREL) ? 1 : 0;
+      rel->r_length = (info >> BFD_MACH_O_BE_LENGTH_SHIFT)
+		      & BFD_MACH_O_LENGTH_MASK;
+      rel->r_extern = (info & BFD_MACH_O_BE_EXTERN) ? 1 : 0;
+    }
+  else
+    {
+      rel->r_value = (fields[2] << 16) | (fields[1] << 8) | fields[0];
+      rel->r_type = (info >> BFD_MACH_O_LE_TYPE_SHIFT) & BFD_MACH_O_TYPE_MASK;
+      rel->r_pcrel = (info & BFD_MACH_O_LE_PCREL) ? 1 : 0;
+      rel->r_length = (info >> BFD_MACH_O_LE_LENGTH_SHIFT)
+		      & BFD_MACH_O_LENGTH_MASK;
+      rel->r_extern = (info & BFD_MACH_O_LE_EXTERN) ? 1 : 0;
+    }
+}
+
 static int
 bfd_mach_o_canonicalize_one_reloc (bfd *abfd,
                                    struct mach_o_reloc_info_external *raw,
@@ -695,20 +1014,28 @@
   bfd_mach_o_backend_data *bed = bfd_mach_o_get_backend_data (abfd);
   bfd_mach_o_reloc_info reloc;
   bfd_vma addr;
-  bfd_vma symnum;
   asymbol **sym;
 
   addr = bfd_get_32 (abfd, raw->r_address);
-  symnum = bfd_get_32 (abfd, raw->r_symbolnum);
-  
+  res->sym_ptr_ptr = NULL;
+  res->addend = 0;
+
   if (addr & BFD_MACH_O_SR_SCATTERED)
     {
       unsigned int j;
+      bfd_vma symnum = bfd_get_32 (abfd, raw->r_symbolnum);
 
-      /* Scattered relocation.
-         Extract section and offset from r_value.  */
-      res->sym_ptr_ptr = NULL;
-      res->addend = 0;
+      /* Scattered relocation, can't be extern. */
+      reloc.r_scattered = 1;
+      reloc.r_extern = 0;
+
+      /*   Extract section and offset from r_value (symnum).  */
+      reloc.r_value = symnum;
+      /* FIXME: This breaks when a symbol in a reloc exactly follows the
+	 end of the data for the section (e.g. in a calculation of section
+	 data length).  At present, the symbol will end up associated with
+	 the following section or, if it falls within alignment padding, as
+	 null - which will assert later.  */
       for (j = 0; j < mdata->nsects; j++)
         {
           bfd_mach_o_section *sect = mdata->sections[j];
@@ -719,42 +1046,72 @@
               break;
             }
         }
-      res->address = BFD_MACH_O_GET_SR_ADDRESS (addr);
+
+      /* Extract the info and address fields from r_address.  */
       reloc.r_type = BFD_MACH_O_GET_SR_TYPE (addr);
       reloc.r_length = BFD_MACH_O_GET_SR_LENGTH (addr);
       reloc.r_pcrel = addr & BFD_MACH_O_SR_PCREL;
-      reloc.r_scattered = 1;
+      reloc.r_address = BFD_MACH_O_GET_SR_TYPE (addr);
+      res->address = BFD_MACH_O_GET_SR_ADDRESS (addr);
     }
   else
     {
-      unsigned int num = BFD_MACH_O_GET_R_SYMBOLNUM (symnum);
-      res->addend = 0;
-      res->address = addr;
-      if (symnum & BFD_MACH_O_R_EXTERN)
-        {
-          sym = syms + num;
-          reloc.r_extern = 1;
-        }
+      unsigned int num;
+
+      /* Non-scattered relocation.  */
+      reloc.r_scattered = 0;
+
+      /* The value and info fields have to be extracted dependent on target
+         endian-ness.  */
+      bfd_mach_o_swap_in_non_scattered_reloc (abfd, &reloc, raw->r_symbolnum);
+      num = reloc.r_value;
+
+      if (reloc.r_extern)
+	{
+	  /* An external symbol number.  */
+	  sym = syms + num;
+	}
+      else if (num == 0x00ffffff)
+	{
+	  /* The 'symnum' in a non-scattered PAIR is 0x00ffffff.  But as this
+	     is generic code, we don't know wether this is really a PAIR.
+	     This value is almost certainly not a valid section number, hence
+	     this specific case to avoid an assertion failure.
+	     Target specific swap_reloc_in routine should adjust that.  */
+	  sym = bfd_abs_section_ptr->symbol_ptr_ptr;
+	}
       else
         {
+	  /* A section number.  */
           BFD_ASSERT (num != 0);
           BFD_ASSERT (num <= mdata->nsects);
+
           sym = mdata->sections[num - 1]->bfdsection->symbol_ptr_ptr;
           /* For a symbol defined in section S, the addend (stored in the
              binary) contains the address of the section.  To comply with
-             bfd conventio, substract the section address.
+             bfd convention, subtract the section address.
              Use the address from the header, so that the user can modify
              the vma of the section.  */
           res->addend = -mdata->sections[num - 1]->addr;
-          reloc.r_extern = 0;
         }
+      /* Note: Pairs for PPC LO/HI/HA are not scattered, but contain the offset
+	 in the lower 16bits of the address value.  So we have to find the
+	 'symbol' from the preceding reloc.  We do this even though the
+	 section symbol is probably not needed here, because NULL symbol
+	 values cause an assert in generic BFD code.  This must be done in
+	 the PPC swap_reloc_in routine.  */
       res->sym_ptr_ptr = sym;
-      reloc.r_type = BFD_MACH_O_GET_R_TYPE (symnum);
-      reloc.r_length = BFD_MACH_O_GET_R_LENGTH (symnum);
-      reloc.r_pcrel = (symnum & BFD_MACH_O_R_PCREL) ? 1 : 0;
-      reloc.r_scattered = 0;
+
+      /* The 'address' is just r_address.
+         ??? maybe this should be masked with  0xffffff for safety.  */
+      res->address = addr;
+      reloc.r_address = addr;
     }
-  
+
+  /* We have set up a reloc with all the information present, so the swapper
+     can modify address, value and addend fields, if necessary, to convey
+     information in the generic BFD reloc that is mach-o specific.  */
+
   if (!(*bed->_bfd_mach_o_swap_reloc_in)(res, &reloc))
     return -1;
   return 0;
@@ -808,21 +1165,25 @@
   if (bed->_bfd_mach_o_swap_reloc_in == NULL)
     return 0;
 
-  res = bfd_malloc (asect->reloc_count * sizeof (arelent));
-  if (res == NULL)
-    return -1;
-
-  if (bfd_mach_o_canonicalize_relocs (abfd, asect->rel_filepos,
-                                      asect->reloc_count, res, syms) < 0)
+  if (asect->relocation == NULL)
     {
-      free (res);
-      return -1;
+      res = bfd_malloc (asect->reloc_count * sizeof (arelent));
+      if (res == NULL)
+        return -1;
+
+      if (bfd_mach_o_canonicalize_relocs (abfd, asect->rel_filepos,
+                                          asect->reloc_count, res, syms) < 0)
+        {
+          free (res);
+          return -1;
+        }
+      asect->relocation = res;
     }
 
+  res = asect->relocation;
   for (i = 0; i < asect->reloc_count; i++)
     rels[i] = &res[i];
   rels[i] = NULL;
-  asect->relocation = res;
 
   return i;
 }
@@ -834,7 +1195,7 @@
 
   if (mdata->dysymtab == NULL)
     return 1;
-  return (mdata->dysymtab->nextrel + mdata->dysymtab->nlocrel)
+  return (mdata->dysymtab->nextrel + mdata->dysymtab->nlocrel + 1)
     * sizeof (arelent *);
 }
 
@@ -857,35 +1218,76 @@
   if (bed->_bfd_mach_o_swap_reloc_in == NULL)
     return 0;
 
-  res = bfd_malloc ((dysymtab->nextrel + dysymtab->nlocrel) * sizeof (arelent));
-  if (res == NULL)
-    return -1;
-
-  if (bfd_mach_o_canonicalize_relocs (abfd, dysymtab->extreloff,
-                                      dysymtab->nextrel, res, syms) < 0)
+  if (mdata->dyn_reloc_cache == NULL)
     {
-      free (res);
-      return -1;
+      res = bfd_malloc ((dysymtab->nextrel + dysymtab->nlocrel)
+                        * sizeof (arelent));
+      if (res == NULL)
+        return -1;
+
+      if (bfd_mach_o_canonicalize_relocs (abfd, dysymtab->extreloff,
+                                          dysymtab->nextrel, res, syms) < 0)
+        {
+          free (res);
+          return -1;
+        }
+
+      if (bfd_mach_o_canonicalize_relocs (abfd, dysymtab->locreloff,
+                                          dysymtab->nlocrel,
+                                          res + dysymtab->nextrel, syms) < 0)
+        {
+          free (res);
+          return -1;
+        }
+
+      mdata->dyn_reloc_cache = res;
     }
 
-  if (bfd_mach_o_canonicalize_relocs (abfd, dysymtab->locreloff,
-                                      dysymtab->nlocrel,
-                                      res + dysymtab->nextrel, syms) < 0)
-    {
-      free (res);
-      return -1;
-    }
-
+  res = mdata->dyn_reloc_cache;
   for (i = 0; i < dysymtab->nextrel + dysymtab->nlocrel; i++)
     rels[i] = &res[i];
   rels[i] = NULL;
   return i;
 }
 
+/* In addition to the need to byte-swap the symbol number, the bit positions
+   of the fields in the relocation information vary per target endian-ness.  */
+
+static void
+bfd_mach_o_swap_out_non_scattered_reloc (bfd *abfd, unsigned char *fields,
+				       bfd_mach_o_reloc_info *rel)
+{
+  unsigned char info = 0;
+
+  BFD_ASSERT (rel->r_type <= 15);
+  BFD_ASSERT (rel->r_length <= 3);
+
+  if (bfd_big_endian (abfd))
+    {
+      fields[0] = (rel->r_value >> 16) & 0xff;
+      fields[1] = (rel->r_value >> 8) & 0xff;
+      fields[2] = rel->r_value & 0xff;
+      info |= rel->r_type << BFD_MACH_O_BE_TYPE_SHIFT;
+      info |= rel->r_pcrel ? BFD_MACH_O_BE_PCREL : 0;
+      info |= rel->r_length << BFD_MACH_O_BE_LENGTH_SHIFT;
+      info |= rel->r_extern ? BFD_MACH_O_BE_EXTERN : 0;
+    }
+  else
+    {
+      fields[2] = (rel->r_value >> 16) & 0xff;
+      fields[1] = (rel->r_value >> 8) & 0xff;
+      fields[0] = rel->r_value & 0xff;
+      info |= rel->r_type << BFD_MACH_O_LE_TYPE_SHIFT;
+      info |= rel->r_pcrel ? BFD_MACH_O_LE_PCREL : 0;
+      info |= rel->r_length << BFD_MACH_O_LE_LENGTH_SHIFT;
+      info |= rel->r_extern ? BFD_MACH_O_LE_EXTERN : 0;
+    }
+  fields[3] = info;
+}
+
 static bfd_boolean
 bfd_mach_o_write_relocs (bfd *abfd, bfd_mach_o_section *section)
 {
-  bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
   unsigned int i;
   arelent **entries;
   asection *sec;
@@ -898,13 +1300,6 @@
   if (bed->_bfd_mach_o_swap_reloc_out == NULL)
     return TRUE;
 
-  /* Allocate relocation room.  */
-  mdata->filelen = FILE_ALIGN(mdata->filelen, 2);
-  section->nreloc = sec->reloc_count;
-  sec->rel_filepos = mdata->filelen;
-  section->reloff = sec->rel_filepos;
-  mdata->filelen += sec->reloc_count * BFD_MACH_O_RELENT_SIZE;
-
   if (bfd_seek (abfd, section->reloff, SEEK_SET) != 0)
     return FALSE;
 
@@ -936,15 +1331,9 @@
         }
       else
         {
-          unsigned long v;
-
           bfd_put_32 (abfd, pinfo->r_address, raw.r_address);
-          v = BFD_MACH_O_SET_R_SYMBOLNUM (pinfo->r_value)
-            | (pinfo->r_pcrel ? BFD_MACH_O_R_PCREL : 0)
-            | BFD_MACH_O_SET_R_LENGTH (pinfo->r_length)
-            | (pinfo->r_extern ? BFD_MACH_O_R_EXTERN : 0)
-            | BFD_MACH_O_SET_R_TYPE (pinfo->r_type);
-          bfd_put_32 (abfd, v, raw.r_symbolnum);
+          bfd_mach_o_swap_out_non_scattered_reloc (abfd, raw.r_symbolnum,
+						   pinfo);
         }
 
       if (bfd_bwrite (&raw, BFD_MACH_O_RELENT_SIZE, abfd)
@@ -1025,7 +1414,7 @@
   bfd_h_put_32 (abfd, seg->initprot, raw.initprot);
   bfd_h_put_32 (abfd, seg->nsects, raw.nsects);
   bfd_h_put_32 (abfd, seg->flags, raw.flags);
-  
+
   if (bfd_seek (abfd, command->offset + BFD_MACH_O_LC_SIZE, SEEK_SET) != 0
       || bfd_bwrite (&raw, sizeof (raw), abfd) != sizeof (raw))
     return -1;
@@ -1097,18 +1486,24 @@
   if (strtab == NULL)
     return FALSE;
 
+  if (sym->nsyms > 0)
+    /* Although we don't strictly need to do this, for compatibility with
+       Darwin system tools, actually output an empty string for the index
+       0 entry.  */
+    _bfd_stringtab_add (strtab, "", TRUE, FALSE);
+
   for (i = 0; i < sym->nsyms; i++)
     {
       bfd_size_type str_index;
       bfd_mach_o_asymbol *s = (bfd_mach_o_asymbol *)symbols[i];
 
-      /* Compute name index.  */
-      /* An index of 0 always means the empty string.  */
       if (s->symbol.name == 0 || s->symbol.name[0] == '\0')
+	/* An index of 0 always means the empty string.  */
         str_index = 0;
       else
         {
           str_index = _bfd_stringtab_add (strtab, s->symbol.name, TRUE, FALSE);
+
           if (str_index == (bfd_size_type) -1)
             goto err;
         }
@@ -1171,8 +1566,258 @@
   return FALSE;
 }
 
-/* Process the symbols and generate Mach-O specific fields.
-   Number them.  */
+/* Write a dysymtab command.
+   TODO: Possibly coalesce writes of smaller objects.  */
+
+static bfd_boolean
+bfd_mach_o_write_dysymtab (bfd *abfd, bfd_mach_o_load_command *command)
+{
+  bfd_mach_o_dysymtab_command *cmd = &command->command.dysymtab;
+
+  BFD_ASSERT (command->type == BFD_MACH_O_LC_DYSYMTAB);
+
+  if (cmd->nmodtab != 0)
+    {
+      unsigned int i;
+
+      if (bfd_seek (abfd, cmd->modtaboff, SEEK_SET) != 0)
+	return FALSE;
+
+      for (i = 0; i < cmd->nmodtab; i++)
+	{
+	  bfd_mach_o_dylib_module *module = &cmd->dylib_module[i];
+	  unsigned int iinit;
+	  unsigned int ninit;
+
+	  iinit = module->iinit & 0xffff;
+	  iinit |= ((module->iterm & 0xffff) << 16);
+
+	  ninit = module->ninit & 0xffff;
+	  ninit |= ((module->nterm & 0xffff) << 16);
+
+	  if (bfd_mach_o_wide_p (abfd))
+	    {
+	      struct mach_o_dylib_module_64_external w;
+
+	      bfd_h_put_32 (abfd, module->module_name_idx, &w.module_name);
+	      bfd_h_put_32 (abfd, module->iextdefsym, &w.iextdefsym);
+	      bfd_h_put_32 (abfd, module->nextdefsym, &w.nextdefsym);
+	      bfd_h_put_32 (abfd, module->irefsym, &w.irefsym);
+	      bfd_h_put_32 (abfd, module->nrefsym, &w.nrefsym);
+	      bfd_h_put_32 (abfd, module->ilocalsym, &w.ilocalsym);
+	      bfd_h_put_32 (abfd, module->nlocalsym, &w.nlocalsym);
+	      bfd_h_put_32 (abfd, module->iextrel, &w.iextrel);
+	      bfd_h_put_32 (abfd, module->nextrel, &w.nextrel);
+	      bfd_h_put_32 (abfd, iinit, &w.iinit_iterm);
+	      bfd_h_put_32 (abfd, ninit, &w.ninit_nterm);
+	      bfd_h_put_64 (abfd, module->objc_module_info_addr,
+			    &w.objc_module_info_addr);
+	      bfd_h_put_32 (abfd, module->objc_module_info_size,
+			    &w.objc_module_info_size);
+
+	      if (bfd_bwrite ((void *) &w, sizeof (w), abfd) != sizeof (w))
+		return FALSE;
+	    }
+	  else
+	    {
+	      struct mach_o_dylib_module_external n;
+
+	      bfd_h_put_32 (abfd, module->module_name_idx, &n.module_name);
+	      bfd_h_put_32 (abfd, module->iextdefsym, &n.iextdefsym);
+	      bfd_h_put_32 (abfd, module->nextdefsym, &n.nextdefsym);
+	      bfd_h_put_32 (abfd, module->irefsym, &n.irefsym);
+	      bfd_h_put_32 (abfd, module->nrefsym, &n.nrefsym);
+	      bfd_h_put_32 (abfd, module->ilocalsym, &n.ilocalsym);
+	      bfd_h_put_32 (abfd, module->nlocalsym, &n.nlocalsym);
+	      bfd_h_put_32 (abfd, module->iextrel, &n.iextrel);
+	      bfd_h_put_32 (abfd, module->nextrel, &n.nextrel);
+	      bfd_h_put_32 (abfd, iinit, &n.iinit_iterm);
+	      bfd_h_put_32 (abfd, ninit, &n.ninit_nterm);
+	      bfd_h_put_32 (abfd, module->objc_module_info_addr,
+			    &n.objc_module_info_addr);
+	      bfd_h_put_32 (abfd, module->objc_module_info_size,
+			    &n.objc_module_info_size);
+
+	      if (bfd_bwrite ((void *) &n, sizeof (n), abfd) != sizeof (n))
+		return FALSE;
+	    }
+	}
+    }
+
+  if (cmd->ntoc != 0)
+    {
+      unsigned int i;
+
+      if (bfd_seek (abfd, cmd->tocoff, SEEK_SET) != 0)
+	return FALSE;
+
+      for (i = 0; i < cmd->ntoc; i++)
+	{
+	  struct mach_o_dylib_table_of_contents_external raw;
+	  bfd_mach_o_dylib_table_of_content *toc = &cmd->dylib_toc[i];
+
+	  bfd_h_put_32 (abfd, toc->symbol_index, &raw.symbol_index);
+	  bfd_h_put_32 (abfd, toc->module_index, &raw.module_index);
+
+	  if (bfd_bwrite (&raw, sizeof (raw), abfd) != sizeof (raw))
+	    return FALSE;
+	}
+    }
+
+  if (cmd->nindirectsyms > 0)
+    {
+      unsigned int i;
+
+      if (bfd_seek (abfd, cmd->indirectsymoff, SEEK_SET) != 0)
+	return FALSE;
+
+      for (i = 0; i < cmd->nindirectsyms; ++i)
+	{
+	  unsigned char raw[4];
+
+	  bfd_h_put_32 (abfd, cmd->indirect_syms[i], &raw);
+	  if (bfd_bwrite (raw, sizeof (raw), abfd) != sizeof (raw))
+	    return FALSE;
+	}
+    }
+
+  if (cmd->nextrefsyms != 0)
+    {
+      unsigned int i;
+
+      if (bfd_seek (abfd, cmd->extrefsymoff, SEEK_SET) != 0)
+	return FALSE;
+
+      for (i = 0; i < cmd->nextrefsyms; i++)
+	{
+	  unsigned long v;
+	  unsigned char raw[4];
+	  bfd_mach_o_dylib_reference *ref = &cmd->ext_refs[i];
+
+	  /* Fields isym and flags are written as bit-fields, thus we need
+	     a specific processing for endianness.  */
+
+	  if (bfd_big_endian (abfd))
+	    {
+	      v = ((ref->isym & 0xffffff) << 8);
+	      v |= ref->flags & 0xff;
+	    }
+	  else
+	    {
+	      v = ref->isym  & 0xffffff;
+	      v |= ((ref->flags & 0xff) << 24);
+	    }
+
+	  bfd_h_put_32 (abfd, v, raw);
+	  if (bfd_bwrite (raw, sizeof (raw), abfd) != sizeof (raw))
+	    return FALSE;
+	}
+    }
+
+  /* The command.  */
+  if (bfd_seek (abfd, command->offset + BFD_MACH_O_LC_SIZE, SEEK_SET) != 0)
+    return FALSE;
+  else
+    {
+      struct mach_o_dysymtab_command_external raw;
+
+      bfd_h_put_32 (abfd, cmd->ilocalsym, &raw.ilocalsym);
+      bfd_h_put_32 (abfd, cmd->nlocalsym, &raw.nlocalsym);
+      bfd_h_put_32 (abfd, cmd->iextdefsym, &raw.iextdefsym);
+      bfd_h_put_32 (abfd, cmd->nextdefsym, &raw.nextdefsym);
+      bfd_h_put_32 (abfd, cmd->iundefsym, &raw.iundefsym);
+      bfd_h_put_32 (abfd, cmd->nundefsym, &raw.nundefsym);
+      bfd_h_put_32 (abfd, cmd->tocoff, &raw.tocoff);
+      bfd_h_put_32 (abfd, cmd->ntoc, &raw.ntoc);
+      bfd_h_put_32 (abfd, cmd->modtaboff, &raw.modtaboff);
+      bfd_h_put_32 (abfd, cmd->nmodtab, &raw.nmodtab);
+      bfd_h_put_32 (abfd, cmd->extrefsymoff, &raw.extrefsymoff);
+      bfd_h_put_32 (abfd, cmd->nextrefsyms, &raw.nextrefsyms);
+      bfd_h_put_32 (abfd, cmd->indirectsymoff, &raw.indirectsymoff);
+      bfd_h_put_32 (abfd, cmd->nindirectsyms, &raw.nindirectsyms);
+      bfd_h_put_32 (abfd, cmd->extreloff, &raw.extreloff);
+      bfd_h_put_32 (abfd, cmd->nextrel, &raw.nextrel);
+      bfd_h_put_32 (abfd, cmd->locreloff, &raw.locreloff);
+      bfd_h_put_32 (abfd, cmd->nlocrel, &raw.nlocrel);
+
+      if (bfd_bwrite (&raw, sizeof (raw), abfd) != sizeof (raw))
+	return FALSE;
+    }
+
+  return TRUE;
+}
+
+static unsigned
+bfd_mach_o_primary_symbol_sort_key (bfd_mach_o_asymbol *s)
+{
+  unsigned mtyp = s->n_type & BFD_MACH_O_N_TYPE;
+
+  /* Just leave debug symbols where they are (pretend they are local, and
+     then they will just be sorted on position).  */
+  if (s->n_type & BFD_MACH_O_N_STAB)
+    return 0;
+
+  /* Local (we should never see an undefined local AFAICT).  */
+  if (! (s->n_type & (BFD_MACH_O_N_EXT | BFD_MACH_O_N_PEXT)))
+    return 0;
+
+  /* Common symbols look like undefined externs.  */
+  if (mtyp == BFD_MACH_O_N_UNDF)
+    return 2;
+
+  /* A defined non-local, non-debug symbol.  */
+  return 1;
+}
+
+static int
+bfd_mach_o_cf_symbols (const void *a, const void *b)
+{
+  bfd_mach_o_asymbol *sa = *(bfd_mach_o_asymbol **) a;
+  bfd_mach_o_asymbol *sb = *(bfd_mach_o_asymbol **) b;
+  unsigned int soa, sob;
+
+  soa = bfd_mach_o_primary_symbol_sort_key (sa);
+  sob = bfd_mach_o_primary_symbol_sort_key (sb);
+  if (soa < sob)
+    return -1;
+
+  if (soa > sob)
+    return 1;
+
+  /* If it's local or stab, just preserve the input order.  */
+  if (soa == 0)
+    {
+      if (sa->symbol.udata.i < sb->symbol.udata.i)
+        return -1;
+      if (sa->symbol.udata.i > sb->symbol.udata.i)
+        return  1;
+
+      /* This is probably an error.  */
+      return 0;
+    }
+
+  /* The second sort key is name.  */
+  return strcmp (sa->symbol.name, sb->symbol.name);
+}
+
+/* Process the symbols.
+
+   This should be OK for single-module files - but it is not likely to work
+   for multi-module shared libraries.
+
+   (a) If the application has not filled in the relevant mach-o fields, make
+       an estimate.
+
+   (b) Order them, like this:
+	(  i) local.
+		(unsorted)
+	( ii) external defined
+		(by name)
+	(iii) external undefined/common
+		(by name)
+	( iv) common
+		(by name)
+*/
 
 static bfd_boolean
 bfd_mach_o_mangle_symbols (bfd *abfd)
@@ -1180,15 +1825,22 @@
   unsigned long i;
   asymbol **symbols = bfd_get_outsymbols (abfd);
 
+  if (symbols == NULL || bfd_get_symcount (abfd) == 0)
+    return TRUE;
+
   for (i = 0; i < bfd_get_symcount (abfd); i++)
     {
       bfd_mach_o_asymbol *s = (bfd_mach_o_asymbol *)symbols[i];
 
-      if (s->n_type == BFD_MACH_O_N_UNDF && !(s->symbol.flags & BSF_DEBUGGING))
+      /* We use this value, which is out-of-range as a symbol index, to signal
+	 that the mach-o-specific data are not filled in and need to be created
+	 from the bfd values.  It is much preferable for the application to do
+	 this, since more meaningful diagnostics can be made that way.  */
+
+      if (s->symbol.udata.i == SYM_MACHO_FIELDS_UNSET)
         {
-          /* As genuine Mach-O symbols type shouldn't be N_UNDF (undefined
-             symbols should be N_UNDEF | N_EXT), we suppose the back-end
-             values haven't been set.  */
+          /* No symbol information has been set - therefore determine
+             it from the bfd symbol flags/info.  */
           if (s->symbol.section == bfd_abs_section_ptr)
             s->n_type = BFD_MACH_O_N_ABS;
           else if (s->symbol.section == bfd_und_section_ptr)
@@ -1196,25 +1848,98 @@
               s->n_type = BFD_MACH_O_N_UNDF;
               if (s->symbol.flags & BSF_WEAK)
                 s->n_desc |= BFD_MACH_O_N_WEAK_REF;
+              /* mach-o automatically makes undefined symbols extern.  */
+	      s->n_type |= BFD_MACH_O_N_EXT;
+	      s->symbol.flags |= BSF_GLOBAL;
             }
           else if (s->symbol.section == bfd_com_section_ptr)
-            s->n_type = BFD_MACH_O_N_UNDF | BFD_MACH_O_N_EXT;
+	    {
+              s->n_type = BFD_MACH_O_N_UNDF | BFD_MACH_O_N_EXT;
+              s->symbol.flags |= BSF_GLOBAL;
+            }
           else
             s->n_type = BFD_MACH_O_N_SECT;
-          
+
           if (s->symbol.flags & BSF_GLOBAL)
             s->n_type |= BFD_MACH_O_N_EXT;
         }
 
-      /* Compute section index.  */
-      if (s->symbol.section != bfd_abs_section_ptr
+      /* Put the section index in, where required.  */
+      if ((s->symbol.section != bfd_abs_section_ptr
           && s->symbol.section != bfd_und_section_ptr
           && s->symbol.section != bfd_com_section_ptr)
-        s->n_sect = s->symbol.section->target_index;
+          || ((s->n_type & BFD_MACH_O_N_STAB) != 0
+               && s->symbol.name == NULL))
+	s->n_sect = s->symbol.section->target_index;
 
-      /* Number symbols.  */
+      /* Number to preserve order for local and debug syms.  */
       s->symbol.udata.i = i;
     }
+
+  /* Sort the symbols.  */
+  qsort ((void *) symbols, (size_t) bfd_get_symcount (abfd),
+	 sizeof (asymbol *), bfd_mach_o_cf_symbols);
+
+  for (i = 0; i < bfd_get_symcount (abfd); ++i)
+    {
+      bfd_mach_o_asymbol *s = (bfd_mach_o_asymbol *)symbols[i];
+      s->symbol.udata.i = i;  /* renumber.  */
+    }
+
+  return TRUE;
+}
+
+/* We build a flat table of sections, which can be re-ordered if necessary.
+   Fill in the section number and other mach-o-specific data.  */
+
+static bfd_boolean
+bfd_mach_o_mangle_sections (bfd *abfd, bfd_mach_o_data_struct *mdata)
+{
+  asection *sec;
+  unsigned target_index;
+  unsigned nsect;
+
+  nsect = bfd_count_sections (abfd);
+
+  /* Don't do it if it's already set - assume the application knows what it's
+     doing.  */
+  if (mdata->nsects == nsect
+      && (mdata->nsects == 0 || mdata->sections != NULL))
+    return TRUE;
+
+  mdata->nsects = nsect;
+  mdata->sections = bfd_alloc (abfd,
+			       mdata->nsects * sizeof (bfd_mach_o_section *));
+  if (mdata->sections == NULL)
+    return FALSE;
+
+  /* We need to check that this can be done...  */
+  if (nsect > 255)
+    (*_bfd_error_handler) (_("mach-o: there are too many sections (%d)"
+			     " maximum is 255,\n"), nsect);
+
+  /* Create Mach-O sections.
+     Section type, attribute and align should have been set when the
+     section was created - either read in or specified.  */
+  target_index = 0;
+  for (sec = abfd->sections; sec; sec = sec->next)
+    {
+      unsigned bfd_align = bfd_get_section_alignment (abfd, sec);
+      bfd_mach_o_section *msect = bfd_mach_o_get_mach_o_section (sec);
+
+      mdata->sections[target_index] = msect;
+
+      msect->addr = bfd_get_section_vma (abfd, sec);
+      msect->size = bfd_get_section_size (sec);
+
+      /* Use the largest alignment set, in case it was bumped after the
+	 section was created.  */
+      msect->align = msect->align > bfd_align ? msect->align : bfd_align;
+
+      msect->offset = 0;
+      sec->target_index = ++target_index;
+    }
+
   return TRUE;
 }
 
@@ -1224,27 +1949,14 @@
   unsigned int i;
   bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
 
+  /* Make the commands, if not already present.  */
   if (mdata->header.ncmds == 0)
     if (!bfd_mach_o_build_commands (abfd))
       return FALSE;
 
-  /* Now write header information.  */
-  if (mdata->header.filetype == 0)
-    {
-      if (abfd->flags & EXEC_P)
-        mdata->header.filetype = BFD_MACH_O_MH_EXECUTE;
-      else if (abfd->flags & DYNAMIC)
-        mdata->header.filetype = BFD_MACH_O_MH_DYLIB;
-      else
-        mdata->header.filetype = BFD_MACH_O_MH_OBJECT;
-    }
   if (!bfd_mach_o_write_header (abfd, &mdata->header))
     return FALSE;
 
-  /* Assign a number to each symbols.  */
-  if (!bfd_mach_o_mangle_symbols (abfd))
-    return FALSE;
-
   for (i = 0; i < mdata->header.ncmds; i++)
     {
       struct mach_o_load_command_external raw;
@@ -1274,6 +1986,10 @@
 	  if (!bfd_mach_o_write_symtab (abfd, cur))
 	    return FALSE;
 	  break;
+	case BFD_MACH_O_LC_DYSYMTAB:
+	  if (!bfd_mach_o_write_dysymtab (abfd, cur))
+	    return FALSE;
+	  break;
 	case BFD_MACH_O_LC_SYMSEG:
 	  break;
 	case BFD_MACH_O_LC_THREAD:
@@ -1286,11 +2002,11 @@
 	case BFD_MACH_O_LC_IDENT:
 	case BFD_MACH_O_LC_FVMFILE:
 	case BFD_MACH_O_LC_PREPAGE:
-	case BFD_MACH_O_LC_DYSYMTAB:
 	case BFD_MACH_O_LC_LOAD_DYLIB:
 	case BFD_MACH_O_LC_LOAD_WEAK_DYLIB:
 	case BFD_MACH_O_LC_ID_DYLIB:
 	case BFD_MACH_O_LC_REEXPORT_DYLIB:
+        case BFD_MACH_O_LC_LOAD_UPWARD_DYLIB:
 	case BFD_MACH_O_LC_LOAD_DYLINKER:
 	case BFD_MACH_O_LC_ID_DYLINKER:
 	case BFD_MACH_O_LC_PREBOUND_DYLIB:
@@ -1341,110 +2057,493 @@
     s->flags = BFD_MACH_O_S_REGULAR;
 }
 
-/* Build Mach-O load commands from the sections.  */
+/* Count the number of sections in the list for the segment named.
 
-bfd_boolean
-bfd_mach_o_build_commands (bfd *abfd)
+   The special case of NULL or "" for the segment name is valid for
+   an MH_OBJECT file and means 'all sections available'.
+
+   Requires that the sections table in mdata be filled in.
+
+   Returns the number of sections (0 is valid).
+   Any number > 255 signals an invalid section count, although we will,
+   perhaps, allow the file to be written (in line with Darwin tools up
+   to XCode 4).
+
+   A section count of (unsigned long) -1 signals a definite error.  */
+
+static unsigned long
+bfd_mach_o_count_sections_for_seg (const char *segment,
+				   bfd_mach_o_data_struct *mdata)
 {
-  bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
-  unsigned int wide = mach_o_wide_p (&mdata->header);
-  bfd_mach_o_segment_command *seg;
-  asection *sec;
-  bfd_mach_o_load_command *cmd;
-  bfd_mach_o_load_command *symtab_cmd;
-  int target_index;
+  unsigned i,j;
+  if (mdata == NULL || mdata->sections == NULL)
+    return (unsigned long) -1;
 
-  /* Return now if commands are already built.  */
-  if (mdata->header.ncmds)
-    return FALSE;
+  /* The MH_OBJECT case, all sections are considered; Although nsects is
+     is an unsigned long, the maximum valid section count is 255 and this
+     will have been checked already by mangle_sections.  */
+  if (segment == NULL || segment[0] == '\0')
+    return mdata->nsects;
 
-  /* Very simple version: a command (segment) to contain all the sections and
-     a command for the symbol table.  */
-  mdata->header.ncmds = 2;
-  mdata->commands = bfd_alloc (abfd, mdata->header.ncmds
-                               * sizeof (bfd_mach_o_load_command));
-  if (mdata->commands == NULL)
-    return FALSE;
-  cmd = &mdata->commands[0];
-  seg = &cmd->command.segment;
-
-  seg->nsects = bfd_count_sections (abfd);
-
-  /* Set segment command.  */
-  if (wide)
+  /* Count the number of sections we see in this segment.  */
+  j = 0;
+  for (i = 0; i < mdata->nsects; ++i)
     {
-      cmd->type = BFD_MACH_O_LC_SEGMENT_64;
-      cmd->offset = BFD_MACH_O_HEADER_64_SIZE;
-      cmd->len = BFD_MACH_O_LC_SEGMENT_64_SIZE
-        + BFD_MACH_O_SECTION_64_SIZE * seg->nsects;
+      bfd_mach_o_section *s = mdata->sections[i];
+      if (strncmp (segment, s->segname, BFD_MACH_O_SEGNAME_SIZE) == 0)
+        j++;
     }
-  else
-    {
-      cmd->type = BFD_MACH_O_LC_SEGMENT;
-      cmd->offset = BFD_MACH_O_HEADER_SIZE;
-      cmd->len = BFD_MACH_O_LC_SEGMENT_SIZE
-        + BFD_MACH_O_SECTION_SIZE * seg->nsects;
-    }
-  cmd->type_required = FALSE;
-  mdata->header.sizeofcmds = cmd->len;
-  mdata->filelen = cmd->offset + cmd->len;
+  return j;
+}
 
-  /* Set symtab command.  */
-  symtab_cmd = &mdata->commands[1];
-  
-  symtab_cmd->type = BFD_MACH_O_LC_SYMTAB;
-  symtab_cmd->offset = cmd->offset + cmd->len;
-  symtab_cmd->len = 6 * 4;
-  symtab_cmd->type_required = FALSE;
-  
-  mdata->header.sizeofcmds += symtab_cmd->len;
-  mdata->filelen += symtab_cmd->len;
+static bfd_boolean
+bfd_mach_o_build_seg_command (const char *segment,
+			      bfd_mach_o_data_struct *mdata,
+			      bfd_mach_o_segment_command *seg)
+{
+  unsigned i;
+  int is_mho = (segment == NULL || segment[0] == '\0');
 
   /* Fill segment command.  */
-  memset (seg->segname, 0, sizeof (seg->segname));
+  if (is_mho)
+    memset (seg->segname, 0, sizeof (seg->segname));
+  else
+    strncpy (seg->segname, segment, sizeof (seg->segname));
+
+  /* TODO: fix this up for non-MH_OBJECT cases.  */
   seg->vmaddr = 0;
+  seg->vmsize = 0;
+
   seg->fileoff = mdata->filelen;
   seg->filesize = 0;
   seg->maxprot = BFD_MACH_O_PROT_READ | BFD_MACH_O_PROT_WRITE
-    | BFD_MACH_O_PROT_EXECUTE;
+		 | BFD_MACH_O_PROT_EXECUTE;
   seg->initprot = seg->maxprot;
   seg->flags = 0;
   seg->sect_head = NULL;
   seg->sect_tail = NULL;
 
-  /* Create Mach-O sections.  */
-  target_index = 0;
-  for (sec = abfd->sections; sec; sec = sec->next)
+  /*  Append sections to the segment.
+
+      This is a little tedious, we have to honor the need to account zerofill
+      sections after all the rest.  This forces us to do the calculation of
+      total vmsize in three passes so that any alignment increments are
+      properly accounted.  */
+
+  for (i = 0; i < mdata->nsects; ++i)
     {
-      bfd_mach_o_section *msect = bfd_mach_o_get_mach_o_section (sec);
+      bfd_mach_o_section *s = mdata->sections[i];
+      asection *sec = s->bfdsection;
 
+      /* If we're not making an MH_OBJECT, check whether this section is from
+	 our segment, and skip if not.  Otherwise, just add all sections.  */
+      if (! is_mho
+	  && strncmp (segment, s->segname, BFD_MACH_O_SEGNAME_SIZE) != 0)
+	continue;
+
+      /* Although we account for zerofill section sizes in vm order, they are
+	 placed in the file in source sequence.  */
       bfd_mach_o_append_section_to_segment (seg, sec);
+      s->offset = 0;
 
-      if (msect->flags == 0)
-        {
-          /* We suppose it hasn't been set.  Convert from BFD flags.  */
-          bfd_mach_o_set_section_flags_from_bfd (abfd, sec);
+      /* Zerofill sections have zero file size & offset,
+	 and are not written.  */
+      if ((s->flags & BFD_MACH_O_SECTION_TYPE_MASK) == BFD_MACH_O_S_ZEROFILL
+          || (s->flags & BFD_MACH_O_SECTION_TYPE_MASK)
+	      == BFD_MACH_O_S_GB_ZEROFILL)
+        continue;
+
+      if (s->size > 0)
+       {
+	  seg->vmsize = FILE_ALIGN (seg->vmsize, s->align);
+	  seg->vmsize += s->size;
+
+	  seg->filesize = FILE_ALIGN (seg->filesize, s->align);
+	  seg->filesize += s->size;
+
+          mdata->filelen = FILE_ALIGN (mdata->filelen, s->align);
+          s->offset = mdata->filelen;
         }
-      msect->addr = bfd_get_section_vma (abfd, sec);
-      msect->size = bfd_get_section_size (sec);
-      msect->align = bfd_get_section_alignment (abfd, sec);
 
-      if (msect->size != 0)
-        {
-          mdata->filelen = FILE_ALIGN (mdata->filelen, msect->align);
-          msect->offset = mdata->filelen;
-        }
-      else
-        msect->offset = 0;
-
-      sec->filepos = msect->offset;
-      sec->target_index = ++target_index;
-
-      mdata->filelen += msect->size;
+      sec->filepos = s->offset;
+      mdata->filelen += s->size;
     }
-  seg->filesize = mdata->filelen - seg->fileoff;
-  seg->vmsize = seg->filesize;
 
+  /* Now pass through again, for zerofill, only now we just update the vmsize.  */
+  for (i = 0; i < mdata->nsects; ++i)
+    {
+      bfd_mach_o_section *s = mdata->sections[i];
+
+      if ((s->flags & BFD_MACH_O_SECTION_TYPE_MASK) != BFD_MACH_O_S_ZEROFILL)
+        continue;
+
+      if (! is_mho
+	  && strncmp (segment, s->segname, BFD_MACH_O_SEGNAME_SIZE) != 0)
+	continue;
+
+      if (s->size > 0)
+	{
+	  seg->vmsize = FILE_ALIGN (seg->vmsize, s->align);
+	  seg->vmsize += s->size;
+	}
+    }
+
+  /* Now pass through again, for zerofill_GB.  */
+  for (i = 0; i < mdata->nsects; ++i)
+    {
+      bfd_mach_o_section *s = mdata->sections[i];
+
+      if ((s->flags & BFD_MACH_O_SECTION_TYPE_MASK) != BFD_MACH_O_S_GB_ZEROFILL)
+        continue;
+
+      if (! is_mho
+	  && strncmp (segment, s->segname, BFD_MACH_O_SEGNAME_SIZE) != 0)
+	continue;
+
+      if (s->size > 0)
+	{
+	  seg->vmsize = FILE_ALIGN (seg->vmsize, s->align);
+	  seg->vmsize += s->size;
+	}
+    }
+
+  /* Allocate space for the relocations.  */
+  mdata->filelen = FILE_ALIGN(mdata->filelen, 2);
+
+  for (i = 0; i < mdata->nsects; ++i)
+    {
+      bfd_mach_o_section *ms = mdata->sections[i];
+      asection *sec = ms->bfdsection;
+
+      if ((ms->nreloc = sec->reloc_count) == 0)
+        {
+	  ms->reloff = 0;
+	  continue;
+        }
+      sec->rel_filepos = mdata->filelen;
+      ms->reloff = sec->rel_filepos;
+      mdata->filelen += sec->reloc_count * BFD_MACH_O_RELENT_SIZE;
+    }
+
+  return TRUE;
+}
+
+/* Count the number of indirect symbols in the image.
+   Requires that the sections are in their final order.  */
+
+static unsigned int
+bfd_mach_o_count_indirect_symbols (bfd *abfd, bfd_mach_o_data_struct *mdata)
+{
+  unsigned int i;
+  unsigned int nisyms = 0;
+
+  for (i = 0; i < mdata->nsects; ++i)
+    {
+      bfd_mach_o_section *sec = mdata->sections[i];
+
+      switch (sec->flags & BFD_MACH_O_SECTION_TYPE_MASK)
+	{
+	  case BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS:
+	  case BFD_MACH_O_S_LAZY_SYMBOL_POINTERS:
+	  case BFD_MACH_O_S_SYMBOL_STUBS:
+	    nisyms += bfd_mach_o_section_get_nbr_indirect (abfd, sec);
+	    break;
+	  default:
+	    break;
+	}
+    }
+  return nisyms;
+}
+
+static bfd_boolean
+bfd_mach_o_build_dysymtab_command (bfd *abfd,
+				   bfd_mach_o_data_struct *mdata,
+				   bfd_mach_o_load_command *cmd)
+{
+  bfd_mach_o_dysymtab_command *dsym = &cmd->command.dysymtab;
+
+  /* TODO:
+     We are not going to try and fill these in yet and, moreover, we are
+     going to bail if they are already set.  */
+  if (dsym->nmodtab != 0
+      || dsym->ntoc != 0
+      || dsym->nextrefsyms != 0)
+    {
+      (*_bfd_error_handler) (_("sorry: modtab, toc and extrefsyms are not yet"
+				" implemented for dysymtab commands."));
+      return FALSE;
+    }
+
+  dsym->ilocalsym = 0;
+
+  if (bfd_get_symcount (abfd) > 0)
+    {
+      asymbol **symbols = bfd_get_outsymbols (abfd);
+      unsigned long i;
+
+       /* Count the number of each kind of symbol.  */
+      for (i = 0; i < bfd_get_symcount (abfd); ++i)
+	{
+	  bfd_mach_o_asymbol *s = (bfd_mach_o_asymbol *)symbols[i];
+	  if (s->n_type & (BFD_MACH_O_N_EXT | BFD_MACH_O_N_PEXT))
+	    break;
+	}
+      dsym->nlocalsym = i;
+      dsym->iextdefsym = i;
+      for (; i < bfd_get_symcount (abfd); ++i)
+	{
+	  bfd_mach_o_asymbol *s = (bfd_mach_o_asymbol *)symbols[i];
+	  if ((s->n_type & BFD_MACH_O_N_TYPE) == BFD_MACH_O_N_UNDF)
+	    break;
+	}
+      dsym->nextdefsym = i - dsym->nlocalsym;
+      dsym->iundefsym = dsym->nextdefsym + dsym->iextdefsym;
+      dsym->nundefsym = bfd_get_symcount (abfd)
+			- dsym->nlocalsym
+			- dsym->nextdefsym;
+    }
+  else
+    {
+      dsym->nlocalsym = 0;
+      dsym->iextdefsym = 0;
+      dsym->nextdefsym = 0;
+      dsym->iundefsym = 0;
+      dsym->nundefsym = 0;
+    }
+
+  dsym->nindirectsyms = bfd_mach_o_count_indirect_symbols (abfd, mdata);
+  if (dsym->nindirectsyms > 0)
+    {
+      unsigned i;
+      unsigned n;
+
+      mdata->filelen = FILE_ALIGN (mdata->filelen, 2);
+      dsym->indirectsymoff = mdata->filelen;
+      mdata->filelen += dsym->nindirectsyms * 4;
+
+      dsym->indirect_syms = bfd_zalloc (abfd, dsym->nindirectsyms * 4);
+      if (dsym->indirect_syms == NULL)
+        return FALSE;
+
+      n = 0;
+      for (i = 0; i < mdata->nsects; ++i)
+	{
+	  bfd_mach_o_section *sec = mdata->sections[i];
+
+	  switch (sec->flags & BFD_MACH_O_SECTION_TYPE_MASK)
+	    {
+	      case BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS:
+	      case BFD_MACH_O_S_LAZY_SYMBOL_POINTERS:
+	      case BFD_MACH_O_S_SYMBOL_STUBS:
+		{
+		  unsigned j, num;
+		  bfd_mach_o_asymbol **isyms = sec->indirect_syms;
+
+		  num = bfd_mach_o_section_get_nbr_indirect (abfd, sec);
+		  if (isyms == NULL || num == 0)
+		    break;
+		  /* Record the starting index in the reserved1 field.  */
+		  sec->reserved1 = n;
+		  for (j = 0; j < num; j++, n++)
+		    {
+		      if (isyms[j] == NULL)
+		        dsym->indirect_syms[n] = BFD_MACH_O_INDIRECT_SYM_LOCAL;
+		      else if (isyms[j]->symbol.section == bfd_abs_section_ptr
+			       && ! (isyms[j]->n_type & BFD_MACH_O_N_EXT))
+		        dsym->indirect_syms[n] = BFD_MACH_O_INDIRECT_SYM_LOCAL
+						 | BFD_MACH_O_INDIRECT_SYM_ABS;
+		      else
+		        dsym->indirect_syms[n] = isyms[j]->symbol.udata.i;
+		    }
+		}
+		break;
+	      default:
+		break;
+	    }
+	}
+    }
+
+  return TRUE;
+}
+
+/* Build Mach-O load commands (currently assuming an MH_OBJECT file).
+   TODO: Other file formats, rebuilding symtab/dysymtab commands for strip
+   and copy functionality.  */
+
+bfd_boolean
+bfd_mach_o_build_commands (bfd *abfd)
+{
+  bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
+  unsigned wide = mach_o_wide_p (&mdata->header);
+  int segcmd_idx = -1;
+  int symtab_idx = -1;
+  int dysymtab_idx = -1;
+  unsigned long base_offset = 0;
+
+  /* Return now if commands are already present.  */
+  if (mdata->header.ncmds)
+    return FALSE;
+
+  /* Fill in the file type, if not already set.  */
+
+  if (mdata->header.filetype == 0)
+    {
+      if (abfd->flags & EXEC_P)
+        mdata->header.filetype = BFD_MACH_O_MH_EXECUTE;
+      else if (abfd->flags & DYNAMIC)
+        mdata->header.filetype = BFD_MACH_O_MH_DYLIB;
+      else
+        mdata->header.filetype = BFD_MACH_O_MH_OBJECT;
+    }
+
+  /* If hasn't already been done, flatten sections list, and sort
+     if/when required.  Must be done before the symbol table is adjusted,
+     since that depends on properly numbered sections.  */
+  if (mdata->nsects == 0 || mdata->sections == NULL)
+    if (! bfd_mach_o_mangle_sections (abfd, mdata))
+      return FALSE;
+
+  /* Order the symbol table, fill-in/check mach-o specific fields and
+     partition out any indirect symbols.  */
+  if (!bfd_mach_o_mangle_symbols (abfd))
+    return FALSE;
+
+  /* Very simple command set (only really applicable to MH_OBJECTs):
+     All the commands are optional - present only when there is suitable data.
+     (i.e. it is valid to have an empty file)
+
+	a command (segment) to contain all the sections,
+	command for the symbol table,
+	a command for the dysymtab.
+
+     ??? maybe we should assert that this is an MH_OBJECT?  */
+
+  if (mdata->nsects > 0)
+    {
+      segcmd_idx = 0;
+      mdata->header.ncmds = 1;
+    }
+
+  if (bfd_get_symcount (abfd) > 0)
+    {
+      mdata->header.ncmds++;
+      symtab_idx = segcmd_idx + 1; /* 0 if the seg command is absent.  */
+    }
+
+  /* FIXME:
+     This is a rather crude test for whether we should build a dysymtab.  */
+  if (bfd_mach_o_should_emit_dysymtab ()
+      && bfd_get_symcount (abfd))
+    {
+      mdata->header.ncmds++;
+      /* If there should be a case where a dysymtab could be emitted without
+	 a symtab (seems improbable), this would need amending.  */
+      dysymtab_idx = symtab_idx + 1;
+    }
+
+  if (wide)
+    base_offset = BFD_MACH_O_HEADER_64_SIZE;
+  else
+    base_offset = BFD_MACH_O_HEADER_SIZE;
+
+  /* Well, we must have a header, at least.  */
+  mdata->filelen = base_offset;
+
+  /* A bit unusual, but no content is valid;
+     as -n empty.s -o empty.o  */
+  if (mdata->header.ncmds == 0)
+    return TRUE;
+
+  mdata->commands = bfd_zalloc (abfd, mdata->header.ncmds
+                                * sizeof (bfd_mach_o_load_command));
+  if (mdata->commands == NULL)
+    return FALSE;
+
+  if (segcmd_idx >= 0)
+    {
+      bfd_mach_o_load_command *cmd = &mdata->commands[segcmd_idx];
+      bfd_mach_o_segment_command *seg = &cmd->command.segment;
+
+      /* Count the segctions in the special blank segment used for MH_OBJECT.  */
+      seg->nsects = bfd_mach_o_count_sections_for_seg (NULL, mdata);
+      if (seg->nsects == (unsigned long) -1)
+	return FALSE;
+
+      /* Init segment command.  */
+      cmd->offset = base_offset;
+      if (wide)
+	{
+	  cmd->type = BFD_MACH_O_LC_SEGMENT_64;
+	  cmd->len = BFD_MACH_O_LC_SEGMENT_64_SIZE
+			+ BFD_MACH_O_SECTION_64_SIZE * seg->nsects;
+	}
+      else
+	{
+	  cmd->type = BFD_MACH_O_LC_SEGMENT;
+	  cmd->len = BFD_MACH_O_LC_SEGMENT_SIZE
+			+ BFD_MACH_O_SECTION_SIZE * seg->nsects;
+	}
+
+      cmd->type_required = FALSE;
+      mdata->header.sizeofcmds = cmd->len;
+      mdata->filelen += cmd->len;
+    }
+
+  if (symtab_idx >= 0)
+    {
+      /* Init symtab command.  */
+      bfd_mach_o_load_command *cmd = &mdata->commands[symtab_idx];
+
+      cmd->type = BFD_MACH_O_LC_SYMTAB;
+      cmd->offset = base_offset;
+      if (segcmd_idx >= 0)
+        cmd->offset += mdata->commands[segcmd_idx].len;
+
+      cmd->len = sizeof (struct mach_o_symtab_command_external)
+		 + BFD_MACH_O_LC_SIZE;
+      cmd->type_required = FALSE;
+      mdata->header.sizeofcmds += cmd->len;
+      mdata->filelen += cmd->len;
+    }
+
+  /* If required, setup symtab command, see comment above about the quality
+     of this test.  */
+  if (dysymtab_idx >= 0)
+    {
+      bfd_mach_o_load_command *cmd = &mdata->commands[dysymtab_idx];
+
+      cmd->type = BFD_MACH_O_LC_DYSYMTAB;
+      if (symtab_idx >= 0)
+        cmd->offset = mdata->commands[symtab_idx].offset
+		    + mdata->commands[symtab_idx].len;
+      else if (segcmd_idx >= 0)
+        cmd->offset = mdata->commands[segcmd_idx].offset
+		    + mdata->commands[segcmd_idx].len;
+      else
+	cmd->offset = base_offset;
+
+      cmd->type_required = FALSE;
+      cmd->len = sizeof (struct mach_o_dysymtab_command_external)
+		 + BFD_MACH_O_LC_SIZE;
+
+      mdata->header.sizeofcmds += cmd->len;
+      mdata->filelen += cmd->len;
+    }
+
+  /* So, now we have sized the commands and the filelen set to that.
+     Now we can build the segment command and set the section file offsets.  */
+  if (segcmd_idx >= 0
+      && ! bfd_mach_o_build_seg_command
+		(NULL, mdata, &mdata->commands[segcmd_idx].command.segment))
+    return FALSE;
+
+  /* If we're doing a dysymtab, cmd points to its load command.  */
+  if (dysymtab_idx >= 0
+      && ! bfd_mach_o_build_dysymtab_command (abfd, mdata,
+					      &mdata->commands[dysymtab_idx]))
+    return FALSE;
+
+  /* The symtab command is filled in when the symtab is written.  */
   return TRUE;
 }
 
@@ -1459,8 +2558,8 @@
 {
   file_ptr pos;
 
-  /* This must be done first, because bfd_set_section_contents is
-     going to set output_has_begun to TRUE.  */
+  /* Trying to write the first section contents will trigger the creation of
+     the load commands if they are not already present.  */
   if (! abfd->output_has_begun && ! bfd_mach_o_build_commands (abfd))
     return FALSE;
 
@@ -1494,7 +2593,7 @@
   if (new_symbol == NULL)
     return new_symbol;
   new_symbol->the_bfd = abfd;
-  new_symbol->udata.i = 0;
+  new_symbol->udata.i = SYM_MACHO_FIELDS_UNSET;
   return new_symbol;
 }
 
@@ -1561,6 +2660,8 @@
 
   if (mach_o_wide_p (header))
     header->reserved = (*get32) (raw.reserved);
+  else
+    header->reserved = 0;
 
   return TRUE;
 }
@@ -1569,11 +2670,13 @@
 bfd_mach_o_new_section_hook (bfd *abfd, asection *sec)
 {
   bfd_mach_o_section *s;
+  unsigned bfdalign = bfd_get_section_alignment (abfd, sec);
 
   s = bfd_mach_o_get_mach_o_section (sec);
   if (s == NULL)
     {
       flagword bfd_flags;
+      static const mach_o_section_name_xlat * xlat;
 
       s = (bfd_mach_o_section *) bfd_zalloc (abfd, sizeof (*s));
       if (s == NULL)
@@ -1581,21 +2684,24 @@
       sec->used_by_bfd = s;
       s->bfdsection = sec;
 
-      /* Create default name.  */
-      bfd_mach_o_convert_section_name_to_mach_o (abfd, sec, s);
-
-      /* Create default flags.  */
-      bfd_flags = bfd_get_section_flags (abfd, sec);
-      if ((bfd_flags & SEC_CODE) == SEC_CODE)
-        s->flags = BFD_MACH_O_S_ATTR_PURE_INSTRUCTIONS
-          | BFD_MACH_O_S_ATTR_SOME_INSTRUCTIONS
-          | BFD_MACH_O_S_REGULAR;
-      else if ((bfd_flags & (SEC_ALLOC | SEC_LOAD)) == SEC_ALLOC)
-        s->flags = BFD_MACH_O_S_ZEROFILL;
-      else if (bfd_flags & SEC_DEBUGGING)
-        s->flags = BFD_MACH_O_S_REGULAR |  BFD_MACH_O_S_ATTR_DEBUG;
+      /* Create the Darwin seg/sect name pair from the bfd name.
+	 If this is a canonical name for which a specific paiting exists
+	 there will also be defined flags, type, attribute and alignment
+	 values.  */
+      xlat = bfd_mach_o_convert_section_name_to_mach_o (abfd, sec, s);
+      if (xlat != NULL)
+	{
+	  s->flags = xlat->macho_sectype | xlat->macho_secattr;
+	  s->align = xlat->sectalign > bfdalign ? xlat->sectalign
+						: bfdalign;
+	  (void) bfd_set_section_alignment (abfd, sec, s->align);
+	  bfd_flags = bfd_get_section_flags (abfd, sec);
+	  if (bfd_flags == SEC_NO_FLAGS)
+	    bfd_set_section_flags (abfd, sec, xlat->bfd_flags);
+	}
       else
-        s->flags = BFD_MACH_O_S_REGULAR;
+	/* Create default flags.  */
+	bfd_mach_o_set_section_flags_from_bfd (abfd, sec);
     }
 
   return _bfd_generic_new_section_hook (abfd, sec);
@@ -1611,6 +2717,9 @@
   flags = bfd_get_section_flags (abfd, sec);
   section = bfd_mach_o_get_mach_o_section (sec);
 
+  /* TODO: see if we should use the xlat system for doing this by
+     preference and fall back to this for unknown sections.  */
+
   if (flags == SEC_NO_FLAGS)
     {
       /* Try to guess flags.  */
@@ -1693,7 +2802,7 @@
   memcpy (section->segname, raw.segname, sizeof (raw.segname));
   section->segname[BFD_MACH_O_SEGNAME_SIZE] = 0;
   memcpy (section->sectname, raw.sectname, sizeof (raw.sectname));
-  section->segname[BFD_MACH_O_SECTNAME_SIZE] = 0;
+  section->sectname[BFD_MACH_O_SECTNAME_SIZE] = 0;
   section->addr = bfd_h_get_32 (abfd, raw.addr);
   section->size = bfd_h_get_32 (abfd, raw.size);
   section->offset = bfd_h_get_32 (abfd, raw.offset);
@@ -1732,7 +2841,7 @@
   memcpy (section->segname, raw.segname, sizeof (raw.segname));
   section->segname[BFD_MACH_O_SEGNAME_SIZE] = 0;
   memcpy (section->sectname, raw.sectname, sizeof (raw.sectname));
-  section->segname[BFD_MACH_O_SECTNAME_SIZE] = 0;
+  section->sectname[BFD_MACH_O_SECTNAME_SIZE] = 0;
   section->addr = bfd_h_get_64 (abfd, raw.addr);
   section->size = bfd_h_get_64 (abfd, raw.size);
   section->offset = bfd_h_get_32 (abfd, raw.offset);
@@ -1761,7 +2870,7 @@
     return bfd_mach_o_read_section_32 (abfd, offset, prot);
 }
 
-static int
+static bfd_boolean
 bfd_mach_o_read_symtab_symbol (bfd *abfd,
                                bfd_mach_o_symtab_command *sym,
                                bfd_mach_o_asymbol *s,
@@ -1788,7 +2897,7 @@
       (*_bfd_error_handler)
         (_("bfd_mach_o_read_symtab_symbol: unable to read %d bytes at %lu"),
          symwidth, (unsigned long) symoff);
-      return -1;
+      return FALSE;
     }
 
   stroff = bfd_h_get_32 (abfd, raw.n_strx);
@@ -1807,14 +2916,14 @@
         (_("bfd_mach_o_read_symtab_symbol: name out of range (%lu >= %lu)"),
          (unsigned long) stroff,
          (unsigned long) sym->strsize);
-      return -1;
+      return FALSE;
     }
 
   s->symbol.the_bfd = abfd;
   s->symbol.name = sym->strtab + stroff;
   s->symbol.value = value;
   s->symbol.flags = 0x0;
-  s->symbol.udata.i = 0;
+  s->symbol.udata.i = i;
   s->n_type = type;
   s->n_sect = section;
   s->n_desc = desc;
@@ -1845,13 +2954,9 @@
     }
   else
     {
-      if (type & BFD_MACH_O_N_PEXT)
+      if (type & (BFD_MACH_O_N_PEXT | BFD_MACH_O_N_EXT))
 	s->symbol.flags |= BSF_GLOBAL;
-
-      if (type & BFD_MACH_O_N_EXT)
-	s->symbol.flags |= BSF_GLOBAL;
-
-      if (!(type & (BFD_MACH_O_N_PEXT | BFD_MACH_O_N_EXT)))
+      else
 	s->symbol.flags |= BSF_LOCAL;
 
       switch (symtype)
@@ -1897,10 +3002,12 @@
 	    }
 	  break;
 	case BFD_MACH_O_N_INDR:
-	  (*_bfd_error_handler) (_("bfd_mach_o_read_symtab_symbol: "
-				   "symbol \"%s\" is unsupported 'indirect' reference: setting to undefined"),
-				 s->symbol.name);
-	  s->symbol.section = bfd_und_section_ptr;
+	  /* FIXME: we don't follow the BFD convention as this indirect symbol
+	     won't be followed by the referenced one.  This looks harmless
+	     unless we start using the linker.	*/
+	  s->symbol.flags |= BSF_INDIRECT;
+	  s->symbol.section = bfd_ind_section_ptr;
+	  s->symbol.value = 0;
 	  break;
 	default:
 	  (*_bfd_error_handler) (_("bfd_mach_o_read_symtab_symbol: "
@@ -1911,10 +3018,10 @@
 	}
     }
 
-  return 0;
+  return TRUE;
 }
 
-static int
+bfd_boolean
 bfd_mach_o_read_symtab_strtab (bfd *abfd)
 {
   bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
@@ -1922,11 +3029,11 @@
 
   /* Fail if there is no symtab.  */
   if (sym == NULL)
-    return -1;
+    return FALSE;
 
   /* Success if already loaded.  */
   if (sym->strtab)
-    return 0;
+    return TRUE;
 
   if (abfd->flags & BFD_IN_MEMORY)
     {
@@ -1937,7 +3044,7 @@
       if ((sym->stroff + sym->strsize) > b->size)
 	{
 	  bfd_set_error (bfd_error_file_truncated);
-	  return -1;
+	  return FALSE;
 	}
       sym->strtab = (char *) b->buffer + sym->stroff;
     }
@@ -1945,31 +3052,30 @@
     {
       sym->strtab = bfd_alloc (abfd, sym->strsize);
       if (sym->strtab == NULL)
-        return -1;
+        return FALSE;
 
       if (bfd_seek (abfd, sym->stroff, SEEK_SET) != 0
-          || bfd_bread ((void *) sym->strtab, sym->strsize, abfd) != sym->strsize)
+          || bfd_bread (sym->strtab, sym->strsize, abfd) != sym->strsize)
         {
           bfd_set_error (bfd_error_file_truncated);
-          return -1;
+          return FALSE;
         }
     }
 
-  return 0;
+  return TRUE;
 }
 
-static int
+bfd_boolean
 bfd_mach_o_read_symtab_symbols (bfd *abfd)
 {
   bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
   bfd_mach_o_symtab_command *sym = mdata->symtab;
   unsigned long i;
-  int ret;
 
   if (sym == NULL || sym->symbols)
     {
       /* Return now if there are no symbols or if already loaded.  */
-      return 0;
+      return TRUE;
     }
 
   sym->symbols = bfd_alloc (abfd, sym->nsyms * sizeof (bfd_mach_o_asymbol));
@@ -1977,47 +3083,19 @@
   if (sym->symbols == NULL)
     {
       (*_bfd_error_handler) (_("bfd_mach_o_read_symtab_symbols: unable to allocate memory for symbols"));
-      return -1;
+      return FALSE;
     }
 
-  ret = bfd_mach_o_read_symtab_strtab (abfd);
-  if (ret != 0)
-    return ret;
+  if (!bfd_mach_o_read_symtab_strtab (abfd))
+    return FALSE;
 
   for (i = 0; i < sym->nsyms; i++)
     {
-      ret = bfd_mach_o_read_symtab_symbol (abfd, sym, &sym->symbols[i], i);
-      if (ret != 0)
-	return ret;
+      if (!bfd_mach_o_read_symtab_symbol (abfd, sym, &sym->symbols[i], i))
+	return FALSE;
     }
 
-  return 0;
-}
-
-int
-bfd_mach_o_read_dysymtab_symbol (bfd *abfd,
-                                 bfd_mach_o_dysymtab_command *dysym,
-                                 bfd_mach_o_symtab_command *sym,
-                                 bfd_mach_o_asymbol *s,
-                                 unsigned long i)
-{
-  unsigned long isymoff = dysym->indirectsymoff + (i * 4);
-  unsigned long sym_index;
-  unsigned char raw[4];
-
-  BFD_ASSERT (i < dysym->nindirectsyms);
-
-  if (bfd_seek (abfd, isymoff, SEEK_SET) != 0
-      || bfd_bread (raw, sizeof (raw), abfd) != sizeof (raw))
-    {
-      (*_bfd_error_handler)
-        (_("bfd_mach_o_read_dysymtab_symbol: unable to read %lu bytes at %lu"),
-         (unsigned long) sizeof (raw), isymoff);
-      return -1;
-    }
-  sym_index = bfd_h_get_32 (abfd, raw);
-
-  return bfd_mach_o_read_symtab_symbol (abfd, sym, s, sym_index);
+  return TRUE;
 }
 
 static const char *
@@ -2097,6 +3175,7 @@
     case BFD_MACH_O_LC_LOAD_WEAK_DYLIB:
     case BFD_MACH_O_LC_ID_DYLIB:
     case BFD_MACH_O_LC_REEXPORT_DYLIB:
+    case BFD_MACH_O_LC_LOAD_UPWARD_DYLIB:
       break;
     default:
       BFD_FAIL ();
@@ -2134,6 +3213,32 @@
 }
 
 static int
+bfd_mach_o_read_fvmlib (bfd *abfd, bfd_mach_o_load_command *command)
+{
+  bfd_mach_o_fvmlib_command *fvm = &command->command.fvmlib;
+  struct mach_o_fvmlib_command_external raw;
+  unsigned int nameoff;
+
+  if (bfd_seek (abfd, command->offset + BFD_MACH_O_LC_SIZE, SEEK_SET) != 0
+      || bfd_bread (&raw, sizeof (raw), abfd) != sizeof (raw))
+    return -1;
+
+  nameoff = bfd_h_get_32 (abfd, raw.name);
+  fvm->minor_version = bfd_h_get_32 (abfd, raw.minor_version);
+  fvm->header_addr = bfd_h_get_32 (abfd, raw.header_addr);
+
+  fvm->name_offset = command->offset + nameoff;
+  fvm->name_len = command->len - nameoff;
+  fvm->name_str = bfd_alloc (abfd, fvm->name_len);
+  if (fvm->name_str == NULL)
+    return -1;
+  if (bfd_seek (abfd, fvm->name_offset, SEEK_SET) != 0
+      || bfd_bread (fvm->name_str, fvm->name_len, abfd) != fvm->name_len)
+    return -1;
+  return 0;
+}
+
+static int
 bfd_mach_o_read_thread (bfd *abfd, bfd_mach_o_load_command *command)
 {
   bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
@@ -2329,7 +3434,7 @@
             }
         }
     }
-  
+
   if (cmd->ntoc != 0)
     {
       unsigned int i;
@@ -2546,6 +3651,64 @@
   return TRUE;
 }
 
+static bfd_boolean
+bfd_mach_o_read_encryption_info (bfd *abfd, bfd_mach_o_load_command *command)
+{
+  bfd_mach_o_encryption_info_command *cmd = &command->command.encryption_info;
+  struct mach_o_encryption_info_command_external raw;
+
+  if (bfd_seek (abfd, command->offset + BFD_MACH_O_LC_SIZE, SEEK_SET) != 0
+      || bfd_bread (&raw, sizeof (raw), abfd) != sizeof (raw))
+    return FALSE;
+
+  cmd->cryptoff = bfd_get_32 (abfd, raw.cryptoff);
+  cmd->cryptsize = bfd_get_32 (abfd, raw.cryptsize);
+  cmd->cryptid = bfd_get_32 (abfd, raw.cryptid);
+  return TRUE;
+}
+
+static bfd_boolean
+bfd_mach_o_read_main (bfd *abfd, bfd_mach_o_load_command *command)
+{
+  bfd_mach_o_main_command *cmd = &command->command.main;
+  struct mach_o_entry_point_command_external raw;
+
+  if (bfd_seek (abfd, command->offset + BFD_MACH_O_LC_SIZE, SEEK_SET) != 0
+      || bfd_bread (&raw, sizeof (raw), abfd) != sizeof (raw))
+    return FALSE;
+
+  cmd->entryoff = bfd_get_64 (abfd, raw.entryoff);
+  cmd->stacksize = bfd_get_64 (abfd, raw.stacksize);
+  return TRUE;
+}
+
+static bfd_boolean
+bfd_mach_o_read_source_version (bfd *abfd, bfd_mach_o_load_command *command)
+{
+  bfd_mach_o_source_version_command *cmd = &command->command.source_version;
+  struct mach_o_source_version_command_external raw;
+  bfd_uint64_t ver;
+
+  if (bfd_seek (abfd, command->offset + BFD_MACH_O_LC_SIZE, SEEK_SET) != 0
+      || bfd_bread (&raw, sizeof (raw), abfd) != sizeof (raw))
+    return FALSE;
+
+  ver = bfd_get_64 (abfd, raw.version);
+  /* Note: we use a serie of shift to avoid shift > 32 (for which gcc
+     generates warnings) in case of the host doesn't support 64 bit
+     integers.  */
+  cmd->e = ver & 0x3ff;
+  ver >>= 10;
+  cmd->d = ver & 0x3ff;
+  ver >>= 10;
+  cmd->c = ver & 0x3ff;
+  ver >>= 10;
+  cmd->b = ver & 0x3ff;
+  ver >>= 10;
+  cmd->a = ver & 0xffffff;
+  return TRUE;
+}
+
 static int
 bfd_mach_o_read_segment (bfd *abfd,
                          bfd_mach_o_load_command *command,
@@ -2681,6 +3844,7 @@
     case BFD_MACH_O_LC_ID_DYLIB:
     case BFD_MACH_O_LC_LOAD_WEAK_DYLIB:
     case BFD_MACH_O_LC_REEXPORT_DYLIB:
+    case BFD_MACH_O_LC_LOAD_UPWARD_DYLIB:
       if (bfd_mach_o_read_dylib (abfd, command) != 0)
 	return -1;
       break;
@@ -2690,6 +3854,9 @@
       break;
     case BFD_MACH_O_LC_LOADFVMLIB:
     case BFD_MACH_O_LC_IDFVMLIB:
+      if (bfd_mach_o_read_fvmlib (abfd, command) != 0)
+	return -1;
+      break;
     case BFD_MACH_O_LC_IDENT:
     case BFD_MACH_O_LC_FVMFILE:
     case BFD_MACH_O_LC_PREPAGE:
@@ -2718,9 +3885,15 @@
     case BFD_MACH_O_LC_CODE_SIGNATURE:
     case BFD_MACH_O_LC_SEGMENT_SPLIT_INFO:
     case BFD_MACH_O_LC_FUNCTION_STARTS:
+    case BFD_MACH_O_LC_DATA_IN_CODE:
+    case BFD_MACH_O_LC_DYLIB_CODE_SIGN_DRS:
       if (bfd_mach_o_read_linkedit (abfd, command) != 0)
 	return -1;
       break;
+    case BFD_MACH_O_LC_ENCRYPTION_INFO:
+      if (!bfd_mach_o_read_encryption_info (abfd, command))
+	return -1;
+      break;
     case BFD_MACH_O_LC_DYLD_INFO:
       if (bfd_mach_o_read_dyld_info (abfd, command) != 0)
 	return -1;
@@ -2730,9 +3903,17 @@
       if (!bfd_mach_o_read_version_min (abfd, command))
 	return -1;
       break;
+    case BFD_MACH_O_LC_MAIN:
+      if (!bfd_mach_o_read_main (abfd, command))
+	return -1;
+      break;
+    case BFD_MACH_O_LC_SOURCE_VERSION:
+      if (!bfd_mach_o_read_source_version (abfd, command))
+	return -1;
+      break;
     default:
-      (*_bfd_error_handler) (_("unable to read unknown load command 0x%lx"),
-			     (unsigned long) command->type);
+      (*_bfd_error_handler)(_("%B: unknown load command 0x%lx"),
+         abfd, (unsigned long) command->type);
       break;
     }
 
@@ -2785,7 +3966,7 @@
     }
 }
 
-int
+static bfd_boolean
 bfd_mach_o_scan_start_address (bfd *abfd)
 {
   bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
@@ -2793,20 +3974,30 @@
   unsigned long i;
 
   for (i = 0; i < mdata->header.ncmds; i++)
-    {
-      if ((mdata->commands[i].type == BFD_MACH_O_LC_THREAD) ||
-	  (mdata->commands[i].type == BFD_MACH_O_LC_UNIXTHREAD))
-	{
-	  if (cmd == NULL)
-	    cmd = &mdata->commands[i].command.thread;
-	  else
-	    return 0;
-	}
-    }
+    if ((mdata->commands[i].type == BFD_MACH_O_LC_THREAD) ||
+        (mdata->commands[i].type == BFD_MACH_O_LC_UNIXTHREAD))
+      {
+        cmd = &mdata->commands[i].command.thread;
+        break;
+      }
+    else if (mdata->commands[i].type == BFD_MACH_O_LC_MAIN
+	     && mdata->nsects > 1)
+      {
+	bfd_mach_o_main_command *main_cmd = &mdata->commands[i].command.main;
+	bfd_mach_o_section *text_sect = mdata->sections[0];
+	if (text_sect)
+	  {
+	    abfd->start_address = main_cmd->entryoff
+	      + (text_sect->addr - text_sect->offset);
+	    return TRUE;
+	  }
+      }
 
+  /* An object file has no start address, so do not fail if not found.  */
   if (cmd == NULL)
-    return 0;
+    return TRUE;
 
+  /* FIXME: create a subtarget hook ?  */
   for (i = 0; i < cmd->nflavours; i++)
     {
       if ((mdata->header.cputype == BFD_MACH_O_CPU_TYPE_I386)
@@ -2817,7 +4008,7 @@
 
 	  if (bfd_seek (abfd, cmd->flavours[i].offset + 40, SEEK_SET) != 0
               || bfd_bread (buf, 4, abfd) != 4)
-	    return -1;
+	    return FALSE;
 
 	  abfd->start_address = bfd_h_get_32 (abfd, buf);
 	}
@@ -2828,7 +4019,7 @@
 
 	  if (bfd_seek (abfd, cmd->flavours[i].offset + 0, SEEK_SET) != 0
               || bfd_bread (buf, 4, abfd) != 4)
-	    return -1;
+	    return FALSE;
 
 	  abfd->start_address = bfd_h_get_32 (abfd, buf);
 	}
@@ -2839,7 +4030,7 @@
 
           if (bfd_seek (abfd, cmd->flavours[i].offset + 0, SEEK_SET) != 0
               || bfd_bread (buf, 8, abfd) != 8)
-            return -1;
+            return FALSE;
 
           abfd->start_address = bfd_h_get_64 (abfd, buf);
         }
@@ -2850,13 +4041,13 @@
 
           if (bfd_seek (abfd, cmd->flavours[i].offset + (16 * 8), SEEK_SET) != 0
               || bfd_bread (buf, 8, abfd) != 8)
-            return -1;
+            return FALSE;
 
           abfd->start_address = bfd_h_get_64 (abfd, buf);
         }
     }
 
-  return 0;
+  return TRUE;
 }
 
 bfd_boolean
@@ -2876,7 +4067,7 @@
   return bfd_default_set_arch_mach (abfd, arch, machine);
 }
 
-int
+static bfd_boolean
 bfd_mach_o_scan (bfd *abfd,
 		 bfd_mach_o_header *header,
 		 bfd_mach_o_data_struct *mdata)
@@ -2912,9 +4103,10 @@
 				   &cputype, &cpusubtype);
   if (cputype == bfd_arch_unknown)
     {
-      (*_bfd_error_handler) (_("bfd_mach_o_scan: unknown architecture 0x%lx/0x%lx"),
-			     header->cputype, header->cpusubtype);
-      return -1;
+      (*_bfd_error_handler)
+        (_("bfd_mach_o_scan: unknown architecture 0x%lx/0x%lx"),
+         header->cputype, header->cpusubtype);
+      return FALSE;
     }
 
   bfd_set_arch_mach (abfd, cputype, cpusubtype);
@@ -2924,7 +4116,7 @@
       mdata->commands = bfd_alloc
         (abfd, header->ncmds * sizeof (bfd_mach_o_load_command));
       if (mdata->commands == NULL)
-	return -1;
+	return FALSE;
 
       for (i = 0; i < header->ncmds; i++)
 	{
@@ -2939,15 +4131,16 @@
 	    }
 
 	  if (bfd_mach_o_read_command (abfd, cur) < 0)
-	    return -1;
+	    return FALSE;
 	}
     }
 
-  if (bfd_mach_o_scan_start_address (abfd) < 0)
-    return -1;
-
+  /* Sections should be flatten before scanning start address.  */
   bfd_mach_o_flatten_sections (abfd);
-  return 0;
+  if (!bfd_mach_o_scan_start_address (abfd))
+    return FALSE;
+
+  return TRUE;
 }
 
 bfd_boolean
@@ -2971,6 +4164,7 @@
   mdata->commands = NULL;
   mdata->nsects = 0;
   mdata->sections = NULL;
+  mdata->dyn_reloc_cache = NULL;
 
   return TRUE;
 }
@@ -2998,10 +4192,9 @@
                      bfd_mach_o_filetype filetype,
                      bfd_mach_o_cpu_type cputype)
 {
-  struct bfd_preserve preserve;
   bfd_mach_o_header header;
+  bfd_mach_o_data_struct *mdata;
 
-  preserve.marker = NULL;
   if (!bfd_mach_o_read_header (abfd, &header))
     goto wrong;
 
@@ -3029,17 +4222,7 @@
       if (header.cputype != cputype)
         goto wrong;
     }
-  else
-    {
-      switch (header.cputype)
-        {
-        case BFD_MACH_O_CPU_TYPE_I386:
-          /* Handled by mach-o-i386 */
-          goto wrong;
-        default:
-          break;
-        }
-    }
+
   if (filetype)
     {
       if (header.filetype != filetype)
@@ -3057,24 +4240,19 @@
         }
     }
 
-  preserve.marker = bfd_zalloc (abfd, sizeof (bfd_mach_o_data_struct));
-  if (preserve.marker == NULL
-      || !bfd_preserve_save (abfd, &preserve))
+  mdata = (bfd_mach_o_data_struct *) bfd_zalloc (abfd, sizeof (*mdata));
+  if (mdata == NULL)
     goto fail;
 
-  if (bfd_mach_o_scan (abfd, &header,
-		       (bfd_mach_o_data_struct *) preserve.marker) != 0)
+  if (!bfd_mach_o_scan (abfd, &header, mdata))
     goto wrong;
 
-  bfd_preserve_finish (abfd, &preserve);
   return abfd->xvec;
 
  wrong:
   bfd_set_error (bfd_error_wrong_format);
 
  fail:
-  if (preserve.marker != NULL)
-    bfd_preserve_restore (abfd, &preserve);
   return NULL;
 }
 
@@ -3158,6 +4336,42 @@
   return NULL;
 }
 
+/* Set the filename for a fat binary member ABFD, whose bfd architecture is
+   ARCH_TYPE/ARCH_SUBTYPE and corresponding entry in header is ENTRY.
+   Set arelt_data and origin fields too.  */
+
+static void
+bfd_mach_o_fat_member_init (bfd *abfd,
+                            enum bfd_architecture arch_type,
+                            unsigned long arch_subtype,
+                            mach_o_fat_archentry *entry)
+{
+  struct areltdata *areltdata;
+  /* Create the member filename. Use ARCH_NAME.  */
+  const bfd_arch_info_type *ap = bfd_lookup_arch (arch_type, arch_subtype);
+
+  if (ap)
+    {
+      /* Use the architecture name if known.  */
+      abfd->filename = ap->printable_name;
+    }
+  else
+    {
+      /* Forge a uniq id.  */
+      const size_t namelen = 2 + 8 + 1 + 2 + 8 + 1;
+      char *name = bfd_alloc (abfd, namelen);
+      snprintf (name, namelen, "0x%lx-0x%lx",
+                entry->cputype, entry->cpusubtype);
+      abfd->filename = name;
+    }
+
+  areltdata = bfd_zmalloc (sizeof (struct areltdata));
+  areltdata->parsed_size = entry->size;
+  abfd->arelt_data = areltdata;
+  abfd->iostream = NULL;
+  abfd->origin = entry->offset;
+}
+
 bfd *
 bfd_mach_o_openr_next_archived_file (bfd *archive, bfd *prev)
 {
@@ -3173,9 +4387,13 @@
 
   /* Find index of previous entry.  */
   if (prev == NULL)
-    i = 0;	/* Start at first one.  */
+    {
+      /* Start at first one.  */
+      i = 0;
+    }
   else
     {
+      /* Find index of PREV.  */
       for (i = 0; i < adata->nfat_arch; i++)
 	{
 	  if (adata->archentries[i].offset == prev->origin)
@@ -3188,8 +4406,10 @@
 	  bfd_set_error (bfd_error_bad_value);
 	  return NULL;
 	}
-    i++;	/* Get next entry.  */
-  }
+
+      /* Get next entry.  */
+      i++;
+    }
 
   if (i >= adata->nfat_arch)
     {
@@ -3202,37 +4422,42 @@
   if (nbfd == NULL)
     return NULL;
 
-  nbfd->origin = entry->offset;
-
   bfd_mach_o_convert_architecture (entry->cputype, entry->cpusubtype,
 				   &arch_type, &arch_subtype);
-  /* Create the member filename.
-     Use FILENAME:ARCH_NAME.  */
-  {
-    char *s = NULL;
-    const char *arch_name;
-    size_t arch_file_len = strlen (bfd_get_filename (archive));
 
-    arch_name = bfd_printable_arch_mach (arch_type, arch_subtype);
-    s = bfd_malloc (arch_file_len + 1 + strlen (arch_name) + 1);
-    if (s == NULL)
-      return NULL;
-    memcpy (s, bfd_get_filename (archive), arch_file_len);
-    s[arch_file_len] = ':';
-    strcpy (s + arch_file_len + 1, arch_name);
-    nbfd->filename = s;
-  }
-  nbfd->iostream = NULL;
+  bfd_mach_o_fat_member_init (nbfd, arch_type, arch_subtype, entry);
+
   bfd_set_arch_mach (nbfd, arch_type, arch_subtype);
 
   return nbfd;
 }
 
+/* Analogous to stat call.  */
+
+static int
+bfd_mach_o_fat_stat_arch_elt (bfd *abfd, struct stat *buf)
+{
+  if (abfd->arelt_data == NULL)
+    {
+      bfd_set_error (bfd_error_invalid_operation);
+      return -1;
+    }
+
+  buf->st_mtime = 0;
+  buf->st_uid = 0;
+  buf->st_gid = 0;
+  buf->st_mode = 0644;
+  buf->st_size = arelt_size (abfd);
+
+  return 0;
+}
+
 /* If ABFD format is FORMAT and architecture is ARCH, return it.
    If ABFD is a fat image containing a member that corresponds to FORMAT
    and ARCH, returns it.
    In other case, returns NULL.
    This function allows transparent uses of fat images.  */
+
 bfd *
 bfd_mach_o_fat_extract (bfd *abfd,
 			bfd_format format,
@@ -3272,10 +4497,7 @@
       if (res == NULL)
 	return NULL;
 
-      res->origin = e->offset;
-
-      res->filename = strdup (abfd->filename);
-      res->iostream = NULL;
+      bfd_mach_o_fat_member_init (res, cpu_type, cpu_subtype, e);
 
       if (bfd_check_format (res, format))
 	{
@@ -3342,217 +4564,67 @@
     }
 }
 
-typedef struct bfd_mach_o_xlat_name
-{
-  const char *name;
-  unsigned long val;
-}
-bfd_mach_o_xlat_name;
+/* The following two tables should be kept, as far as possible, in order of
+   most frequently used entries to optimize their use from gas.  */
 
-static void
-bfd_mach_o_print_flags (const bfd_mach_o_xlat_name *table,
-                        unsigned long val,
-                        FILE *file)
-{
-  int first = 1;
-
-  for (; table->name; table++)
-    {
-      if (table->val & val)
-        {
-          if (!first)
-            fprintf (file, "+");
-          fprintf (file, "%s", table->name);
-          val &= ~table->val;
-          first = 0;
-        }
-    }
-  if (val)
-    {
-      if (!first)
-        fprintf (file, "+");
-      fprintf (file, "0x%lx", val);
-      return;
-    }
-  if (first)
-    fprintf (file, "-");
-}
-
-static const char *
-bfd_mach_o_get_name_or_null (const bfd_mach_o_xlat_name *table,
-                             unsigned long val)
-{
-  for (; table->name; table++)
-    if (table->val == val)
-      return table->name;
-  return NULL;
-}
-
-static const char *
-bfd_mach_o_get_name (const bfd_mach_o_xlat_name *table, unsigned long val)
-{
-  const char *res = bfd_mach_o_get_name_or_null (table, val);
-
-  if (res == NULL)
-    return "*UNKNOWN*";
-  else
-    return res;
-}
-
-static bfd_mach_o_xlat_name bfd_mach_o_cpu_name[] =
-{
-  { "vax", BFD_MACH_O_CPU_TYPE_VAX },
-  { "mc680x0", BFD_MACH_O_CPU_TYPE_MC680x0 },
-  { "i386", BFD_MACH_O_CPU_TYPE_I386 },
-  { "mips", BFD_MACH_O_CPU_TYPE_MIPS },
-  { "mc98000", BFD_MACH_O_CPU_TYPE_MC98000 },
-  { "hppa", BFD_MACH_O_CPU_TYPE_HPPA },
-  { "arm", BFD_MACH_O_CPU_TYPE_ARM },
-  { "mc88000", BFD_MACH_O_CPU_TYPE_MC88000 },
-  { "sparc", BFD_MACH_O_CPU_TYPE_SPARC },
-  { "i860", BFD_MACH_O_CPU_TYPE_I860 },
-  { "alpha", BFD_MACH_O_CPU_TYPE_ALPHA },
-  { "powerpc", BFD_MACH_O_CPU_TYPE_POWERPC },
-  { "powerpc_64", BFD_MACH_O_CPU_TYPE_POWERPC_64 },
-  { "x86_64", BFD_MACH_O_CPU_TYPE_X86_64 },
-  { NULL, 0}
-};
-
-static bfd_mach_o_xlat_name bfd_mach_o_filetype_name[] = 
-{
-  { "object", BFD_MACH_O_MH_OBJECT },
-  { "execute", BFD_MACH_O_MH_EXECUTE },
-  { "fvmlib", BFD_MACH_O_MH_FVMLIB },
-  { "core", BFD_MACH_O_MH_CORE },
-  { "preload", BFD_MACH_O_MH_PRELOAD },
-  { "dylib", BFD_MACH_O_MH_DYLIB },
-  { "dylinker", BFD_MACH_O_MH_DYLINKER },
-  { "bundle", BFD_MACH_O_MH_BUNDLE },
-  { "dylib_stub", BFD_MACH_O_MH_DYLIB_STUB },
-  { "dym", BFD_MACH_O_MH_DSYM },
-  { "kext_bundle", BFD_MACH_O_MH_KEXT_BUNDLE },
-  { NULL, 0}
-};
-
-static bfd_mach_o_xlat_name bfd_mach_o_header_flags_name[] = 
-{
-  { "noundefs", BFD_MACH_O_MH_NOUNDEFS },
-  { "incrlink", BFD_MACH_O_MH_INCRLINK },
-  { "dyldlink", BFD_MACH_O_MH_DYLDLINK },
-  { "bindatload", BFD_MACH_O_MH_BINDATLOAD },
-  { "prebound", BFD_MACH_O_MH_PREBOUND },
-  { "split_segs", BFD_MACH_O_MH_SPLIT_SEGS },
-  { "lazy_init", BFD_MACH_O_MH_LAZY_INIT },
-  { "twolevel", BFD_MACH_O_MH_TWOLEVEL },
-  { "force_flat", BFD_MACH_O_MH_FORCE_FLAT },
-  { "nomultidefs", BFD_MACH_O_MH_NOMULTIDEFS },
-  { "nofixprebinding", BFD_MACH_O_MH_NOFIXPREBINDING },
-  { "prebindable", BFD_MACH_O_MH_PREBINDABLE },
-  { "allmodsbound", BFD_MACH_O_MH_ALLMODSBOUND },
-  { "subsections_via_symbols", BFD_MACH_O_MH_SUBSECTIONS_VIA_SYMBOLS },
-  { "canonical", BFD_MACH_O_MH_CANONICAL },
-  { "weak_defines", BFD_MACH_O_MH_WEAK_DEFINES },
-  { "binds_to_weak", BFD_MACH_O_MH_BINDS_TO_WEAK },
-  { "allow_stack_execution", BFD_MACH_O_MH_ALLOW_STACK_EXECUTION },
-  { "root_safe", BFD_MACH_O_MH_ROOT_SAFE },
-  { "setuid_safe", BFD_MACH_O_MH_SETUID_SAFE },
-  { "no_reexported_dylibs", BFD_MACH_O_MH_NO_REEXPORTED_DYLIBS },
-  { "pie", BFD_MACH_O_MH_PIE },
-  { NULL, 0}
-};
-
-static bfd_mach_o_xlat_name bfd_mach_o_section_type_name[] = 
+const bfd_mach_o_xlat_name bfd_mach_o_section_type_name[] =
 {
   { "regular", BFD_MACH_O_S_REGULAR},
+  { "coalesced", BFD_MACH_O_S_COALESCED},
   { "zerofill", BFD_MACH_O_S_ZEROFILL},
   { "cstring_literals", BFD_MACH_O_S_CSTRING_LITERALS},
   { "4byte_literals", BFD_MACH_O_S_4BYTE_LITERALS},
   { "8byte_literals", BFD_MACH_O_S_8BYTE_LITERALS},
+  { "16byte_literals", BFD_MACH_O_S_16BYTE_LITERALS},
   { "literal_pointers", BFD_MACH_O_S_LITERAL_POINTERS},
+  { "mod_init_func_pointers", BFD_MACH_O_S_MOD_INIT_FUNC_POINTERS},
+  { "mod_fini_func_pointers", BFD_MACH_O_S_MOD_FINI_FUNC_POINTERS},
+  { "gb_zerofill", BFD_MACH_O_S_GB_ZEROFILL},
+  { "interposing", BFD_MACH_O_S_INTERPOSING},
+  { "dtrace_dof", BFD_MACH_O_S_DTRACE_DOF},
   { "non_lazy_symbol_pointers", BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS},
   { "lazy_symbol_pointers", BFD_MACH_O_S_LAZY_SYMBOL_POINTERS},
   { "symbol_stubs", BFD_MACH_O_S_SYMBOL_STUBS},
-  { "mod_init_func_pointers", BFD_MACH_O_S_MOD_INIT_FUNC_POINTERS},
-  { "mod_fini_func_pointers", BFD_MACH_O_S_MOD_FINI_FUNC_POINTERS},
-  { "coalesced", BFD_MACH_O_S_COALESCED},
-  { "gb_zerofill", BFD_MACH_O_S_GB_ZEROFILL},
-  { "interposing", BFD_MACH_O_S_INTERPOSING},
-  { "16byte_literals", BFD_MACH_O_S_16BYTE_LITERALS},
-  { "dtrace_dof", BFD_MACH_O_S_DTRACE_DOF},
   { "lazy_dylib_symbol_pointers", BFD_MACH_O_S_LAZY_DYLIB_SYMBOL_POINTERS},
   { NULL, 0}
 };
 
-static bfd_mach_o_xlat_name bfd_mach_o_section_attribute_name[] = 
+const bfd_mach_o_xlat_name bfd_mach_o_section_attribute_name[] =
 {
+  { "pure_instructions", BFD_MACH_O_S_ATTR_PURE_INSTRUCTIONS },
+  { "some_instructions", BFD_MACH_O_S_ATTR_SOME_INSTRUCTIONS },
   { "loc_reloc", BFD_MACH_O_S_ATTR_LOC_RELOC },
   { "ext_reloc", BFD_MACH_O_S_ATTR_EXT_RELOC },
-  { "some_instructions", BFD_MACH_O_S_ATTR_SOME_INSTRUCTIONS },
   { "debug", BFD_MACH_O_S_ATTR_DEBUG },
-  { "modifying_code", BFD_MACH_O_S_SELF_MODIFYING_CODE },
   { "live_support", BFD_MACH_O_S_ATTR_LIVE_SUPPORT },
   { "no_dead_strip", BFD_MACH_O_S_ATTR_NO_DEAD_STRIP },
   { "strip_static_syms", BFD_MACH_O_S_ATTR_STRIP_STATIC_SYMS },
   { "no_toc", BFD_MACH_O_S_ATTR_NO_TOC },
-  { "pure_instructions", BFD_MACH_O_S_ATTR_PURE_INSTRUCTIONS },
+  { "self_modifying_code", BFD_MACH_O_S_SELF_MODIFYING_CODE },
+  { "modifying_code", BFD_MACH_O_S_SELF_MODIFYING_CODE },
   { NULL, 0}
 };
 
-static bfd_mach_o_xlat_name bfd_mach_o_load_command_name[] = 
-{
-  { "segment", BFD_MACH_O_LC_SEGMENT},
-  { "symtab", BFD_MACH_O_LC_SYMTAB},
-  { "symseg", BFD_MACH_O_LC_SYMSEG},
-  { "thread", BFD_MACH_O_LC_THREAD},
-  { "unixthread", BFD_MACH_O_LC_UNIXTHREAD},
-  { "loadfvmlib", BFD_MACH_O_LC_LOADFVMLIB},
-  { "idfvmlib", BFD_MACH_O_LC_IDFVMLIB},
-  { "ident", BFD_MACH_O_LC_IDENT},
-  { "fvmfile", BFD_MACH_O_LC_FVMFILE},
-  { "prepage", BFD_MACH_O_LC_PREPAGE},
-  { "dysymtab", BFD_MACH_O_LC_DYSYMTAB},
-  { "load_dylib", BFD_MACH_O_LC_LOAD_DYLIB},
-  { "id_dylib", BFD_MACH_O_LC_ID_DYLIB},
-  { "load_dylinker", BFD_MACH_O_LC_LOAD_DYLINKER},
-  { "id_dylinker", BFD_MACH_O_LC_ID_DYLINKER},
-  { "prebound_dylib", BFD_MACH_O_LC_PREBOUND_DYLIB},
-  { "routines", BFD_MACH_O_LC_ROUTINES},
-  { "sub_framework", BFD_MACH_O_LC_SUB_FRAMEWORK},
-  { "sub_umbrella", BFD_MACH_O_LC_SUB_UMBRELLA},
-  { "sub_client", BFD_MACH_O_LC_SUB_CLIENT},
-  { "sub_library", BFD_MACH_O_LC_SUB_LIBRARY},
-  { "twolevel_hints", BFD_MACH_O_LC_TWOLEVEL_HINTS},
-  { "prebind_cksum", BFD_MACH_O_LC_PREBIND_CKSUM},
-  { "load_weak_dylib", BFD_MACH_O_LC_LOAD_WEAK_DYLIB},
-  { "segment_64", BFD_MACH_O_LC_SEGMENT_64},
-  { "routines_64", BFD_MACH_O_LC_ROUTINES_64},
-  { "uuid", BFD_MACH_O_LC_UUID},
-  { "rpath", BFD_MACH_O_LC_RPATH},
-  { "code_signature", BFD_MACH_O_LC_CODE_SIGNATURE},
-  { "segment_split_info", BFD_MACH_O_LC_SEGMENT_SPLIT_INFO},
-  { "reexport_dylib", BFD_MACH_O_LC_REEXPORT_DYLIB},
-  { "lazy_load_dylib", BFD_MACH_O_LC_LAZY_LOAD_DYLIB},
-  { "encryption_info", BFD_MACH_O_LC_ENCRYPTION_INFO},
-  { "dyld_info", BFD_MACH_O_LC_DYLD_INFO},
-  { "load_upward_lib", BFD_MACH_O_LC_LOAD_UPWARD_DYLIB},
-  { "version_min_macosx", BFD_MACH_O_LC_VERSION_MIN_MACOSX},
-  { "version_min_iphoneos", BFD_MACH_O_LC_VERSION_MIN_IPHONEOS},
-  { "function_starts", BFD_MACH_O_LC_FUNCTION_STARTS},
-  { "dyld_environment", BFD_MACH_O_LC_DYLD_ENVIRONMENT},
-  { NULL, 0}
-};
-
-/* Get the section type from NAME.  Return -1 if NAME is unknown.  */
+/* Get the section type from NAME.  Return 256 if NAME is unknown.  */
 
 unsigned int
-bfd_mach_o_get_section_type_from_name (const char *name)
+bfd_mach_o_get_section_type_from_name (bfd *abfd, const char *name)
 {
-  bfd_mach_o_xlat_name *x;
+  const bfd_mach_o_xlat_name *x;
+  bfd_mach_o_backend_data *bed = bfd_mach_o_get_backend_data (abfd);
 
   for (x = bfd_mach_o_section_type_name; x->name; x++)
     if (strcmp (x->name, name) == 0)
-      return x->val;
-  return (unsigned int)-1;
+      {
+	/* We found it... does the target support it?  */
+	if (bed->bfd_mach_o_section_type_valid_for_target == NULL
+	    || bed->bfd_mach_o_section_type_valid_for_target (x->val))
+	  return x->val; /* OK.  */
+	else
+	  break; /* Not supported.  */
+      }
+  /* Maximum section ID = 0xff.  */
+  return 256;
 }
 
 /* Get the section attribute from NAME.  Return -1 if NAME is unknown.  */
@@ -3560,7 +4632,7 @@
 unsigned int
 bfd_mach_o_get_section_attribute_from_name (const char *name)
 {
-  bfd_mach_o_xlat_name *x;
+  const bfd_mach_o_xlat_name *x;
 
   for (x = bfd_mach_o_section_attribute_name; x->name; x++)
     if (strcmp (x->name, name) == 0)
@@ -3568,514 +4640,6 @@
   return (unsigned int)-1;
 }
 
-static void
-bfd_mach_o_print_private_header (bfd *abfd, FILE *file)
-{
-  bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
-  bfd_mach_o_header *h = &mdata->header;
-
-  fputs (_("Mach-O header:\n"), file);
-  fprintf (file, _(" magic     : %08lx\n"), h->magic);
-  fprintf (file, _(" cputype   : %08lx (%s)\n"), h->cputype,
-           bfd_mach_o_get_name (bfd_mach_o_cpu_name, h->cputype));
-  fprintf (file, _(" cpusubtype: %08lx\n"), h->cpusubtype);
-  fprintf (file, _(" filetype  : %08lx (%s)\n"),
-           h->filetype,
-           bfd_mach_o_get_name (bfd_mach_o_filetype_name, h->filetype));
-  fprintf (file, _(" ncmds     : %08lx (%lu)\n"), h->ncmds, h->ncmds);
-  fprintf (file, _(" sizeofcmds: %08lx\n"), h->sizeofcmds);
-  fprintf (file, _(" flags     : %08lx ("), h->flags);
-  bfd_mach_o_print_flags (bfd_mach_o_header_flags_name, h->flags, file);
-  fputs (_(")\n"), file);
-  fprintf (file, _(" reserved  : %08x\n"), h->reserved);
-}
-
-static void
-bfd_mach_o_print_section_map (bfd *abfd, FILE *file)
-{
-  bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
-  unsigned int i;
-  unsigned int sec_nbr = 0;
-
-  fputs (_("Segments and Sections:\n"), file);
-  fputs (_(" #: Segment name     Section name     Address\n"), file);
-
-  for (i = 0; i < mdata->header.ncmds; i++)
-    {
-      bfd_mach_o_segment_command *seg;
-      bfd_mach_o_section *sec;
-
-      if (mdata->commands[i].type != BFD_MACH_O_LC_SEGMENT
-	  && mdata->commands[i].type != BFD_MACH_O_LC_SEGMENT_64)
-	continue;
-
-      seg = &mdata->commands[i].command.segment;
-
-      fprintf (file, "[Segment %-16s ", seg->segname);
-      fprintf_vma (file, seg->vmaddr);
-      fprintf (file, "-");
-      fprintf_vma  (file, seg->vmaddr + seg->vmsize - 1);
-      fputc (' ', file);
-      fputc (seg->initprot & BFD_MACH_O_PROT_READ ? 'r' : '-', file);
-      fputc (seg->initprot & BFD_MACH_O_PROT_WRITE ? 'w' : '-', file);
-      fputc (seg->initprot & BFD_MACH_O_PROT_EXECUTE ? 'x' : '-', file);
-      fprintf (file, "]\n");
-
-      for (sec = seg->sect_head; sec != NULL; sec = sec->next)
-	{
-	  fprintf (file, "%02u: %-16s %-16s ", ++sec_nbr,
-		   sec->segname, sec->sectname);
-	  fprintf_vma (file, sec->addr);
-	  fprintf (file, " ");
-	  fprintf_vma  (file, sec->size);
-	  fprintf (file, " %08lx\n", sec->flags);
-	}
-    }
-}
-
-static void
-bfd_mach_o_print_section (bfd *abfd ATTRIBUTE_UNUSED,
-                          bfd_mach_o_section *sec, FILE *file)
-{
-  fprintf (file, " Section: %-16s %-16s (bfdname: %s)\n",
-           sec->sectname, sec->segname, sec->bfdsection->name);
-  fprintf (file, "  addr: ");
-  fprintf_vma (file, sec->addr);
-  fprintf (file, " size: ");
-  fprintf_vma  (file, sec->size);
-  fprintf (file, " offset: ");
-  fprintf_vma (file, sec->offset);
-  fprintf (file, "\n");
-  fprintf (file, "  align: %ld", sec->align);
-  fprintf (file, "  nreloc: %lu  reloff: ", sec->nreloc);
-  fprintf_vma (file, sec->reloff);
-  fprintf (file, "\n");
-  fprintf (file, "  flags: %08lx (type: %s", sec->flags,
-           bfd_mach_o_get_name (bfd_mach_o_section_type_name,
-                                sec->flags & BFD_MACH_O_SECTION_TYPE_MASK));
-  fprintf (file, " attr: ");
-  bfd_mach_o_print_flags (bfd_mach_o_section_attribute_name,
-                          sec->flags & BFD_MACH_O_SECTION_ATTRIBUTES_MASK,
-                          file);
-  fprintf (file, ")\n");
-  switch (sec->flags & BFD_MACH_O_SECTION_TYPE_MASK)
-    {
-    case BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS:
-    case BFD_MACH_O_S_LAZY_SYMBOL_POINTERS:
-    case BFD_MACH_O_S_SYMBOL_STUBS:
-      fprintf (file, "  first indirect sym: %lu", sec->reserved1);
-      fprintf (file, " (%u entries)",
-               bfd_mach_o_section_get_nbr_indirect (abfd, sec));
-      break;
-    default:
-      fprintf (file, "  reserved1: 0x%lx", sec->reserved1);
-      break;
-    }
-  switch (sec->flags & BFD_MACH_O_SECTION_TYPE_MASK)
-    {
-    case BFD_MACH_O_S_SYMBOL_STUBS:
-      fprintf (file, "  stub size: %lu", sec->reserved2);
-      break;
-    default:
-      fprintf (file, "  reserved2: 0x%lx", sec->reserved2);
-      break;
-    }
-  fprintf (file, "  reserved3: 0x%lx\n", sec->reserved3);
-}
-
-static void
-bfd_mach_o_print_segment (bfd *abfd ATTRIBUTE_UNUSED,
-                          bfd_mach_o_load_command *cmd, FILE *file)
-{
-  bfd_mach_o_segment_command *seg = &cmd->command.segment;
-  bfd_mach_o_section *sec;
-
-  fprintf (file, " name: %s\n", *seg->segname ? seg->segname : "*none*");
-  fprintf (file, "    vmaddr: ");
-  fprintf_vma (file, seg->vmaddr);
-  fprintf (file, "   vmsize: ");
-  fprintf_vma  (file, seg->vmsize);
-  fprintf (file, "\n");
-  fprintf (file, "   fileoff: ");
-  fprintf_vma (file, seg->fileoff);
-  fprintf (file, " filesize: ");
-  fprintf_vma (file, (bfd_vma)seg->filesize);
-  fprintf (file, " endoff: ");
-  fprintf_vma (file, (bfd_vma)(seg->fileoff + seg->filesize));
-  fprintf (file, "\n");
-  fprintf (file, "   nsects: %lu  ", seg->nsects);
-  fprintf (file, " flags: %lx\n", seg->flags);
-  for (sec = seg->sect_head; sec != NULL; sec = sec->next)
-    bfd_mach_o_print_section (abfd, sec, file);
-}
-
-static void
-bfd_mach_o_print_dysymtab (bfd *abfd ATTRIBUTE_UNUSED,
-                           bfd_mach_o_load_command *cmd, FILE *file)
-{
-  bfd_mach_o_dysymtab_command *dysymtab = &cmd->command.dysymtab;
-  bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
-  unsigned int i;
-
-  fprintf (file, "              local symbols: idx: %10lu  num: %-8lu",
-           dysymtab->ilocalsym, dysymtab->nlocalsym);
-  fprintf (file, " (nxtidx: %lu)\n",
-           dysymtab->ilocalsym + dysymtab->nlocalsym);
-  fprintf (file, "           external symbols: idx: %10lu  num: %-8lu",
-           dysymtab->iextdefsym, dysymtab->nextdefsym);
-  fprintf (file, " (nxtidx: %lu)\n",
-           dysymtab->iextdefsym + dysymtab->nextdefsym);
-  fprintf (file, "          undefined symbols: idx: %10lu  num: %-8lu",
-           dysymtab->iundefsym, dysymtab->nundefsym);
-  fprintf (file, " (nxtidx: %lu)\n",
-           dysymtab->iundefsym + dysymtab->nundefsym);
-  fprintf (file, "           table of content: off: 0x%08lx  num: %-8lu",
-           dysymtab->tocoff, dysymtab->ntoc);
-  fprintf (file, " (endoff: 0x%08lx)\n",
-           dysymtab->tocoff 
-           + dysymtab->ntoc * BFD_MACH_O_TABLE_OF_CONTENT_SIZE); 
-  fprintf (file, "               module table: off: 0x%08lx  num: %-8lu",
-           dysymtab->modtaboff, dysymtab->nmodtab);
-  fprintf (file, " (endoff: 0x%08lx)\n",
-           dysymtab->modtaboff + dysymtab->nmodtab 
-           * (mach_o_wide_p (&mdata->header) ? 
-              BFD_MACH_O_DYLIB_MODULE_64_SIZE : BFD_MACH_O_DYLIB_MODULE_SIZE));
-  fprintf (file, "   external reference table: off: 0x%08lx  num: %-8lu",
-           dysymtab->extrefsymoff, dysymtab->nextrefsyms);
-  fprintf (file, " (endoff: 0x%08lx)\n",
-           dysymtab->extrefsymoff 
-           + dysymtab->nextrefsyms * BFD_MACH_O_REFERENCE_SIZE);
-  fprintf (file, "      indirect symbol table: off: 0x%08lx  num: %-8lu",
-           dysymtab->indirectsymoff, dysymtab->nindirectsyms);
-  fprintf (file, " (endoff: 0x%08lx)\n",
-           dysymtab->indirectsymoff 
-           + dysymtab->nindirectsyms * BFD_MACH_O_INDIRECT_SYMBOL_SIZE);
-  fprintf (file, "  external relocation table: off: 0x%08lx  num: %-8lu",
-           dysymtab->extreloff, dysymtab->nextrel);
-  fprintf (file, " (endoff: 0x%08lx)\n",
-           dysymtab->extreloff + dysymtab->nextrel * BFD_MACH_O_RELENT_SIZE);
-  fprintf (file, "     local relocation table: off: 0x%08lx  num: %-8lu",
-           dysymtab->locreloff, dysymtab->nlocrel);
-  fprintf (file, " (endoff: 0x%08lx)\n",
-           dysymtab->locreloff + dysymtab->nlocrel * BFD_MACH_O_RELENT_SIZE);
-  
-  if (dysymtab->ntoc > 0
-      || dysymtab->nindirectsyms > 0
-      || dysymtab->nextrefsyms > 0)
-    {
-      /* Try to read the symbols to display the toc or indirect symbols.  */
-      bfd_mach_o_read_symtab_symbols (abfd);
-    }
-  else if (dysymtab->nmodtab > 0)
-    {
-      /* Try to read the strtab to display modules name.  */
-      bfd_mach_o_read_symtab_strtab (abfd);
-    }
-  
-  for (i = 0; i < dysymtab->nmodtab; i++)
-    {
-      bfd_mach_o_dylib_module *module = &dysymtab->dylib_module[i];
-      fprintf (file, "  module %u:\n", i);
-      fprintf (file, "   name: %lu", module->module_name_idx);
-      if (mdata->symtab && mdata->symtab->strtab)
-        fprintf (file, ": %s",
-                 mdata->symtab->strtab + module->module_name_idx);
-      fprintf (file, "\n");
-      fprintf (file, "   extdefsym: idx: %8lu  num: %lu\n",
-               module->iextdefsym, module->nextdefsym);
-      fprintf (file, "      refsym: idx: %8lu  num: %lu\n",
-               module->irefsym, module->nrefsym);
-      fprintf (file, "    localsym: idx: %8lu  num: %lu\n",
-               module->ilocalsym, module->nlocalsym);
-      fprintf (file, "      extrel: idx: %8lu  num: %lu\n",
-               module->iextrel, module->nextrel);
-      fprintf (file, "        init: idx: %8u  num: %u\n",
-               module->iinit, module->ninit);
-      fprintf (file, "        term: idx: %8u  num: %u\n",
-               module->iterm, module->nterm);
-      fprintf (file, "   objc_module_info: addr: ");
-      fprintf_vma (file, module->objc_module_info_addr);
-      fprintf (file, "  size: %lu\n", module->objc_module_info_size);
-    }
-
-  if (dysymtab->ntoc > 0)
-    {
-      bfd_mach_o_symtab_command *symtab = mdata->symtab;
-      
-      fprintf (file, "  table of content: (symbol/module)\n");
-      for (i = 0; i < dysymtab->ntoc; i++)
-        {
-          bfd_mach_o_dylib_table_of_content *toc = &dysymtab->dylib_toc[i];
-          
-          fprintf (file, "   %4u: ", i);
-          if (symtab && symtab->symbols && toc->symbol_index < symtab->nsyms)
-            {
-              const char *name = symtab->symbols[toc->symbol_index].symbol.name;
-              fprintf (file, "%s (%lu)", name ? name : "*invalid*",
-                       toc->symbol_index);
-            }
-          else
-            fprintf (file, "%lu", toc->symbol_index);
-          
-          fprintf (file, " / ");
-          if (symtab && symtab->strtab
-              && toc->module_index < dysymtab->nmodtab)
-            {
-              bfd_mach_o_dylib_module *mod;
-              mod = &dysymtab->dylib_module[toc->module_index];
-              fprintf (file, "%s (%lu)",
-                       symtab->strtab + mod->module_name_idx,
-                       toc->module_index);
-            }
-          else
-            fprintf (file, "%lu", toc->module_index);
-          
-          fprintf (file, "\n");
-        }
-    }
-
-  if (dysymtab->nindirectsyms != 0)
-    {
-      fprintf (file, "  indirect symbols:\n");
-
-      for (i = 0; i < mdata->nsects; i++)
-        {
-          bfd_mach_o_section *sec = mdata->sections[i];
-          unsigned int j, first, last;
-          bfd_mach_o_symtab_command *symtab = mdata->symtab;
-          bfd_vma addr;
-          bfd_vma entry_size;
-      
-          switch (sec->flags & BFD_MACH_O_SECTION_TYPE_MASK)
-            {
-            case BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS:
-            case BFD_MACH_O_S_LAZY_SYMBOL_POINTERS:
-            case BFD_MACH_O_S_SYMBOL_STUBS:
-              first = sec->reserved1;
-              last = first + bfd_mach_o_section_get_nbr_indirect (abfd, sec);
-              addr = sec->addr;
-              entry_size = bfd_mach_o_section_get_entry_size (abfd, sec);
-              fprintf (file, "  for section %s.%s:\n",
-                       sec->segname, sec->sectname);
-              for (j = first; j < last; j++)
-                {
-                  unsigned int isym = dysymtab->indirect_syms[j];
-                  
-                  fprintf (file, "   ");
-                  fprintf_vma (file, addr);
-                  fprintf (file, " %5u: 0x%08x", j, isym);
-                  if (isym & BFD_MACH_O_INDIRECT_SYMBOL_LOCAL)
-                    fprintf (file, " LOCAL");
-                  if (isym & BFD_MACH_O_INDIRECT_SYMBOL_ABS)
-                    fprintf (file, " ABSOLUTE");
-                  if (symtab && symtab->symbols
-                      && isym < symtab->nsyms
-                      && symtab->symbols[isym].symbol.name)
-                    fprintf (file, " %s", symtab->symbols[isym].symbol.name);
-                  fprintf (file, "\n");
-                  addr += entry_size;
-                }
-              break;
-            default:
-              break;
-            }
-        }
-    }
-  if (dysymtab->nextrefsyms > 0)
-    {
-      bfd_mach_o_symtab_command *symtab = mdata->symtab;
-      
-      fprintf (file, "  external reference table: (symbol flags)\n");
-      for (i = 0; i < dysymtab->nextrefsyms; i++)
-        {
-          bfd_mach_o_dylib_reference *ref = &dysymtab->ext_refs[i];
-          
-          fprintf (file, "   %4u: %5lu 0x%02lx", i, ref->isym, ref->flags);
-          if (symtab && symtab->symbols
-              && ref->isym < symtab->nsyms
-              && symtab->symbols[ref->isym].symbol.name)
-            fprintf (file, " %s", symtab->symbols[ref->isym].symbol.name);
-          fprintf (file, "\n");
-        }
-    }
-
-}
-
-static void
-bfd_mach_o_print_dyld_info (bfd *abfd ATTRIBUTE_UNUSED,
-                            bfd_mach_o_load_command *cmd, FILE *file)
-{
-  bfd_mach_o_dyld_info_command *info = &cmd->command.dyld_info;
-
-  fprintf (file, "       rebase: off: 0x%08x  size: %-8u\n",
-           info->rebase_off, info->rebase_size);
-  fprintf (file, "         bind: off: 0x%08x  size: %-8u\n",
-           info->bind_off, info->bind_size);
-  fprintf (file, "    weak bind: off: 0x%08x  size: %-8u\n",
-           info->weak_bind_off, info->weak_bind_size);
-  fprintf (file, "    lazy bind: off: 0x%08x  size: %-8u\n",
-           info->lazy_bind_off, info->lazy_bind_size);
-  fprintf (file, "       export: off: 0x%08x  size: %-8u\n",
-           info->export_off, info->export_size);
-}
-
-bfd_boolean
-bfd_mach_o_bfd_print_private_bfd_data (bfd *abfd, void * ptr)
-{
-  bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
-  FILE *file = (FILE *) ptr;
-  unsigned int i;
-
-  bfd_mach_o_print_private_header (abfd, file);
-  fputc ('\n', file);
-
-  for (i = 0; i < mdata->header.ncmds; i++)
-    {
-      bfd_mach_o_load_command *cmd = &mdata->commands[i];
-      const char *cmd_name;
-      
-      cmd_name = bfd_mach_o_get_name_or_null
-        (bfd_mach_o_load_command_name, cmd->type);
-      fprintf (file, "Load command ");
-      if (cmd_name == NULL)
-        fprintf (file, "0x%02x:", cmd->type);
-      else
-        fprintf (file, "%s:", cmd_name);
-
-      switch (cmd->type)
-	{
-	case BFD_MACH_O_LC_SEGMENT:
-	case BFD_MACH_O_LC_SEGMENT_64:
-          bfd_mach_o_print_segment (abfd, cmd, file);
-	  break;
-	case BFD_MACH_O_LC_UUID:
-	  {
-	    bfd_mach_o_uuid_command *uuid = &cmd->command.uuid;
-	    unsigned int j;
-
-	    for (j = 0; j < sizeof (uuid->uuid); j ++)
-	      fprintf (file, " %02x", uuid->uuid[j]);
-	    fputc ('\n', file);
-	  }
-	  break;
-	case BFD_MACH_O_LC_LOAD_DYLIB:
-	case BFD_MACH_O_LC_LOAD_WEAK_DYLIB:
-	case BFD_MACH_O_LC_REEXPORT_DYLIB:
-	case BFD_MACH_O_LC_ID_DYLIB:
-	  {
-	    bfd_mach_o_dylib_command *dylib = &cmd->command.dylib;
-	    fprintf (file, " %s\n", dylib->name_str);
-	    fprintf (file, "            time stamp: 0x%08lx\n",
-		     dylib->timestamp);
-	    fprintf (file, "       current version: 0x%08lx\n",
-		     dylib->current_version);
-	    fprintf (file, "  comptibility version: 0x%08lx\n",
-		     dylib->compatibility_version);
-	    break;
-	  }
-	case BFD_MACH_O_LC_LOAD_DYLINKER:
-	case BFD_MACH_O_LC_ID_DYLINKER:
-          fprintf (file, " %s\n", cmd->command.dylinker.name_str);
-          break;
-	case BFD_MACH_O_LC_SYMTAB:
-	  {
-	    bfd_mach_o_symtab_command *symtab = &cmd->command.symtab;
-	    fprintf (file,
-                     "\n"
-		     "   symoff: 0x%08x    nsyms: %8u  (endoff: 0x%08x)\n",
-                     symtab->symoff, symtab->nsyms,
-                     symtab->symoff + symtab->nsyms 
-                     * (mach_o_wide_p (&mdata->header) 
-                        ? BFD_MACH_O_NLIST_64_SIZE : BFD_MACH_O_NLIST_SIZE));
-	    fprintf (file,
-		     "   stroff: 0x%08x  strsize: %8u  (endoff: 0x%08x)\n",
-		     symtab->stroff, symtab->strsize,
-                     symtab->stroff + symtab->strsize);
-	    break;
-	  }
-	case BFD_MACH_O_LC_DYSYMTAB:
-          fprintf (file, "\n");
-          bfd_mach_o_print_dysymtab (abfd, cmd, file);
-          break;
-        case BFD_MACH_O_LC_CODE_SIGNATURE:
-        case BFD_MACH_O_LC_SEGMENT_SPLIT_INFO:
-        case BFD_MACH_O_LC_FUNCTION_STARTS:
-	  {
-	    bfd_mach_o_linkedit_command *linkedit = &cmd->command.linkedit;
-	    fprintf
-              (file, "\n"
-               "  dataoff: 0x%08lx  datasize: 0x%08lx  (endoff: 0x%08lx)\n",
-               linkedit->dataoff, linkedit->datasize,
-               linkedit->dataoff + linkedit->datasize);
-            break;
-          }
-        case BFD_MACH_O_LC_SUB_FRAMEWORK:
-        case BFD_MACH_O_LC_SUB_UMBRELLA:
-        case BFD_MACH_O_LC_SUB_LIBRARY:
-        case BFD_MACH_O_LC_SUB_CLIENT:
-        case BFD_MACH_O_LC_RPATH:
-	  {
-	    bfd_mach_o_str_command *str = &cmd->command.str;
-	    fprintf (file, " %s\n", str->str);
-            break;
-          }
-        case BFD_MACH_O_LC_THREAD:
-        case BFD_MACH_O_LC_UNIXTHREAD:
-          {
-            bfd_mach_o_thread_command *thread = &cmd->command.thread;
-            unsigned int j;
-            bfd_mach_o_backend_data *bed = bfd_mach_o_get_backend_data (abfd);
-
-            fprintf (file, " nflavours: %lu\n", thread->nflavours);
-            for (j = 0; j < thread->nflavours; j++)
-              {
-                bfd_mach_o_thread_flavour *flavour = &thread->flavours[j];
-
-                fprintf (file, "  %2u: flavour: 0x%08lx  offset: 0x%08lx"
-                         "  size: 0x%08lx\n",
-                         j, flavour->flavour, flavour->offset,
-                         flavour->size);
-                if (bed->_bfd_mach_o_print_thread)
-                  {
-                    char *buf = bfd_malloc (flavour->size);
-
-                    if (buf
-                        && bfd_seek (abfd, flavour->offset, SEEK_SET) == 0
-                        && (bfd_bread (buf, flavour->size, abfd) 
-                            == flavour->size))
-                      (*bed->_bfd_mach_o_print_thread)(abfd, flavour,
-                                                       file, buf);
-                    free (buf);
-                  }
-              }
-            break;
-          }
-	case BFD_MACH_O_LC_DYLD_INFO:
-          fprintf (file, "\n");
-          bfd_mach_o_print_dyld_info (abfd, cmd, file);
-          break;
-	case BFD_MACH_O_LC_VERSION_MIN_MACOSX:
-	case BFD_MACH_O_LC_VERSION_MIN_IPHONEOS:
-          {
-            bfd_mach_o_version_min_command *ver = &cmd->command.version_min;
-
-            fprintf (file, " %u.%u.%u\n", ver->rel, ver->maj, ver->min);
-          }
-          break;
-	default:
-	  fprintf (file, "\n");
-          fprintf (file, "  offset: 0x%08lx\n", (unsigned long)cmd->offset);
-          fprintf (file, "    size: 0x%08lx\n", (unsigned long)cmd->len);
-	  break;
-	}
-      fputc ('\n', file);
-    }
-
-  bfd_mach_o_print_section_map (abfd, file);
-
-  return TRUE;
-}
-
 int
 bfd_mach_o_core_fetch_environment (bfd *abfd,
 				   unsigned char **rbuf,
@@ -4188,18 +4752,225 @@
   return 0;
 }
 
-#define bfd_mach_o_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup 
+static bfd_mach_o_uuid_command *
+bfd_mach_o_lookup_uuid_command (bfd *abfd)
+{
+  bfd_mach_o_load_command *uuid_cmd;
+  int ncmd = bfd_mach_o_lookup_command (abfd, BFD_MACH_O_LC_UUID, &uuid_cmd);
+  if (ncmd != 1)
+    return FALSE;
+  return &uuid_cmd->command.uuid;
+}
+
+/* Return true if ABFD is a dSYM file and its UUID matches UUID_CMD. */
+
+static bfd_boolean
+bfd_mach_o_dsym_for_uuid_p (bfd *abfd, const bfd_mach_o_uuid_command *uuid_cmd)
+{
+  bfd_mach_o_uuid_command *dsym_uuid_cmd;
+
+  BFD_ASSERT (abfd);
+  BFD_ASSERT (uuid_cmd);
+
+  if (!bfd_check_format (abfd, bfd_object))
+    return FALSE;
+
+  if (bfd_get_flavour (abfd) != bfd_target_mach_o_flavour
+      || bfd_mach_o_get_data (abfd) == NULL
+      || bfd_mach_o_get_data (abfd)->header.filetype != BFD_MACH_O_MH_DSYM)
+    return FALSE;
+
+  dsym_uuid_cmd = bfd_mach_o_lookup_uuid_command (abfd);
+  if (dsym_uuid_cmd == NULL)
+    return FALSE;
+
+  if (memcmp (uuid_cmd->uuid, dsym_uuid_cmd->uuid,
+              sizeof (uuid_cmd->uuid)) != 0)
+    return FALSE;
+
+  return TRUE;
+}
+
+/* Find a BFD in DSYM_FILENAME which matches ARCH and UUID_CMD.
+   The caller is responsible for closing the returned BFD object and
+   its my_archive if the returned BFD is in a fat dSYM. */
+
+static bfd *
+bfd_mach_o_find_dsym (const char *dsym_filename,
+                      const bfd_mach_o_uuid_command *uuid_cmd,
+                      const bfd_arch_info_type *arch)
+{
+  bfd *base_dsym_bfd, *dsym_bfd;
+
+  BFD_ASSERT (uuid_cmd);
+
+  base_dsym_bfd = bfd_openr (dsym_filename, NULL);
+  if (base_dsym_bfd == NULL)
+    return NULL;
+
+  dsym_bfd = bfd_mach_o_fat_extract (base_dsym_bfd, bfd_object, arch);
+  if (bfd_mach_o_dsym_for_uuid_p (dsym_bfd, uuid_cmd))
+    return dsym_bfd;
+
+  bfd_close (dsym_bfd);
+  if (base_dsym_bfd != dsym_bfd)
+    bfd_close (base_dsym_bfd);
+
+  return NULL;
+}
+
+/* Return a BFD created from a dSYM file for ABFD.
+   The caller is responsible for closing the returned BFD object, its
+   filename, and its my_archive if the returned BFD is in a fat dSYM. */
+
+static bfd *
+bfd_mach_o_follow_dsym (bfd *abfd)
+{
+  char *dsym_filename;
+  bfd_mach_o_uuid_command *uuid_cmd;
+  bfd *dsym_bfd, *base_bfd = abfd;
+  const char *base_basename;
+
+  if (abfd == NULL || bfd_get_flavour (abfd) != bfd_target_mach_o_flavour)
+    return NULL;
+
+  if (abfd->my_archive)
+    base_bfd = abfd->my_archive;
+  /* BFD may have been opened from a stream. */
+  if (base_bfd->filename == NULL)
+    {
+      bfd_set_error (bfd_error_invalid_operation);
+      return NULL;
+    }
+  base_basename = lbasename (base_bfd->filename);
+
+  uuid_cmd = bfd_mach_o_lookup_uuid_command (abfd);
+  if (uuid_cmd == NULL)
+    return NULL;
+
+  /* TODO: We assume the DWARF file has the same as the binary's.
+     It seems apple's GDB checks all files in the dSYM bundle directory.
+     http://opensource.apple.com/source/gdb/gdb-1708/src/gdb/macosx/macosx-tdep.c
+  */
+  dsym_filename = (char *)bfd_malloc (strlen (base_bfd->filename)
+                                       + strlen (dsym_subdir) + 1
+                                       + strlen (base_basename) + 1);
+  sprintf (dsym_filename, "%s%s/%s",
+           base_bfd->filename, dsym_subdir, base_basename);
+
+  dsym_bfd = bfd_mach_o_find_dsym (dsym_filename, uuid_cmd,
+                                   bfd_get_arch_info (abfd));
+  if (dsym_bfd == NULL)
+    free (dsym_filename);
+
+  return dsym_bfd;
+}
+
+bfd_boolean
+bfd_mach_o_find_nearest_line (bfd *abfd,
+			      asection *section,
+			      asymbol **symbols,
+			      bfd_vma offset,
+			      const char **filename_ptr,
+			      const char **functionname_ptr,
+			      unsigned int *line_ptr)
+{
+  bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
+  if (mdata == NULL)
+    return FALSE;
+  switch (mdata->header.filetype)
+    {
+    case BFD_MACH_O_MH_OBJECT:
+      break;
+    case BFD_MACH_O_MH_EXECUTE:
+    case BFD_MACH_O_MH_DYLIB:
+    case BFD_MACH_O_MH_BUNDLE:
+    case BFD_MACH_O_MH_KEXT_BUNDLE:
+      if (mdata->dwarf2_find_line_info == NULL)
+        {
+          mdata->dsym_bfd = bfd_mach_o_follow_dsym (abfd);
+          /* When we couldn't find dSYM for this binary, we look for
+             the debug information in the binary itself. In this way,
+             we won't try finding separated dSYM again because
+             mdata->dwarf2_find_line_info will be filled. */
+          if (! mdata->dsym_bfd)
+            break;
+          if (! _bfd_dwarf2_slurp_debug_info (abfd, mdata->dsym_bfd,
+                                              dwarf_debug_sections, symbols,
+                                              &mdata->dwarf2_find_line_info))
+            return FALSE;
+        }
+      break;
+    default:
+      return FALSE;
+    }
+  if (_bfd_dwarf2_find_nearest_line (abfd, dwarf_debug_sections,
+				     section, symbols, offset,
+				     filename_ptr, functionname_ptr,
+				     line_ptr, NULL, 0,
+				     &mdata->dwarf2_find_line_info))
+    return TRUE;
+  return FALSE;
+}
+
+bfd_boolean
+bfd_mach_o_close_and_cleanup (bfd *abfd)
+{
+  bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
+  if (bfd_get_format (abfd) == bfd_object && mdata != NULL)
+    {
+      _bfd_dwarf2_cleanup_debug_info (abfd, &mdata->dwarf2_find_line_info);
+      bfd_mach_o_free_cached_info (abfd);
+      if (mdata->dsym_bfd != NULL)
+        {
+          bfd *fat_bfd = mdata->dsym_bfd->my_archive;
+          char *dsym_filename = (char *)(fat_bfd
+                                         ? fat_bfd->filename
+                                         : mdata->dsym_bfd->filename);
+          bfd_close (mdata->dsym_bfd);
+          mdata->dsym_bfd = NULL;
+          if (fat_bfd)
+            bfd_close (fat_bfd);
+          free (dsym_filename);
+        }
+    }
+
+  if (bfd_get_format (abfd) == bfd_archive
+      && abfd->xvec == &mach_o_fat_vec)
+    return TRUE;
+  return _bfd_generic_close_and_cleanup (abfd);
+}
+
+bfd_boolean bfd_mach_o_free_cached_info (bfd *abfd)
+{
+  bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
+  asection *asect;
+  free (mdata->dyn_reloc_cache);
+  mdata->dyn_reloc_cache = NULL;
+  for (asect = abfd->sections; asect != NULL; asect = asect->next)
+    {
+      free (asect->relocation);
+      asect->relocation = NULL;
+    }
+
+  return TRUE;
+}
+
+#define bfd_mach_o_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
 #define bfd_mach_o_bfd_reloc_name_lookup _bfd_norelocs_bfd_reloc_name_lookup
 
 #define bfd_mach_o_swap_reloc_in NULL
 #define bfd_mach_o_swap_reloc_out NULL
 #define bfd_mach_o_print_thread NULL
+#define bfd_mach_o_tgt_seg_table NULL
+#define bfd_mach_o_section_type_valid_for_tgt NULL
 
 #define TARGET_NAME 		mach_o_be_vec
 #define TARGET_STRING     	"mach-o-be"
 #define TARGET_ARCHITECTURE	bfd_arch_unknown
 #define TARGET_BIG_ENDIAN 	1
 #define TARGET_ARCHIVE 		0
+#define TARGET_PRIORITY		1
 #include "mach-o-target.c"
 
 #undef TARGET_NAME
@@ -4207,12 +4978,14 @@
 #undef TARGET_ARCHITECTURE
 #undef TARGET_BIG_ENDIAN
 #undef TARGET_ARCHIVE
+#undef TARGET_PRIORITY
 
 #define TARGET_NAME 		mach_o_le_vec
 #define TARGET_STRING 		"mach-o-le"
 #define TARGET_ARCHITECTURE	bfd_arch_unknown
 #define TARGET_BIG_ENDIAN 	0
 #define TARGET_ARCHIVE 		0
+#define TARGET_PRIORITY		1
 
 #include "mach-o-target.c"
 
@@ -4221,6 +4994,7 @@
 #undef TARGET_ARCHITECTURE
 #undef TARGET_BIG_ENDIAN
 #undef TARGET_ARCHIVE
+#undef TARGET_PRIORITY
 
 /* Not yet handled: creating an archive.  */
 #define bfd_mach_o_mkarchive                      _bfd_noarchive_mkarchive
@@ -4234,7 +5008,7 @@
 #define bfd_mach_o_truncate_arname                _bfd_noarchive_truncate_arname
 #define bfd_mach_o_write_armap                    _bfd_noarchive_write_armap
 #define bfd_mach_o_get_elt_at_index               _bfd_noarchive_get_elt_at_index
-#define bfd_mach_o_generic_stat_arch_elt          _bfd_noarchive_generic_stat_arch_elt
+#define bfd_mach_o_generic_stat_arch_elt          bfd_mach_o_fat_stat_arch_elt
 #define bfd_mach_o_update_armap_timestamp         _bfd_noarchive_update_armap_timestamp
 
 #define TARGET_NAME 		mach_o_fat_vec
@@ -4242,6 +5016,7 @@
 #define TARGET_ARCHITECTURE	bfd_arch_unknown
 #define TARGET_BIG_ENDIAN 	1
 #define TARGET_ARCHIVE 		1
+#define TARGET_PRIORITY		0
 
 #include "mach-o-target.c"
 
@@ -4250,3 +5025,4 @@
 #undef TARGET_ARCHITECTURE
 #undef TARGET_BIG_ENDIAN
 #undef TARGET_ARCHIVE
+#undef TARGET_PRIORITY
diff --git a/bfd/mach-o.h b/bfd/mach-o.h
index 53d97da..916028f 100644
--- a/bfd/mach-o.h
+++ b/bfd/mach-o.h
@@ -1,5 +1,6 @@
 /* Mach-O support for BFD.
-   Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008, 2009
+   Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008, 2009, 2011,
+   2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -41,6 +42,18 @@
 }
 bfd_mach_o_header;
 
+typedef struct bfd_mach_o_asymbol
+{
+  /* The actual symbol which the rest of BFD works with.  */
+  asymbol symbol;
+
+  /* Mach-O symbol fields.  */
+  unsigned char n_type;
+  unsigned char n_sect;
+  unsigned short n_desc;
+}
+bfd_mach_o_asymbol;
+
 #define BFD_MACH_O_SEGNAME_SIZE 16
 #define BFD_MACH_O_SECTNAME_SIZE 16
 
@@ -63,6 +76,12 @@
   /* Corresponding bfd section.  */
   asection *bfdsection;
 
+  /* An array holding the indirect symbols for this section.
+     NULL values indicate local symbols.
+     The number of symbols is determined from the section size and type.  */
+
+  bfd_mach_o_asymbol **indirect_syms;
+
   /* Simply linked list.  */
   struct bfd_mach_o_section *next;
 }
@@ -70,7 +89,7 @@
 
 typedef struct bfd_mach_o_segment_command
 {
-  char segname[16 + 1];
+  char segname[BFD_MACH_O_SEGNAME_SIZE + 1];
   bfd_vma vmaddr;
   bfd_vma vmsize;
   bfd_vma fileoff;
@@ -104,17 +123,14 @@
 }
 bfd_mach_o_reloc_info;
 
-typedef struct bfd_mach_o_asymbol
-{
-  /* The actual symbol which the rest of BFD works with.  */
-  asymbol symbol;
-
-  /* Fields from Mach-O symbol.  */
-  unsigned char n_type;
-  unsigned char n_sect;
-  unsigned short n_desc;
-}
-bfd_mach_o_asymbol;
+/* The symbol table is sorted like this:
+ (1) local.
+	(otherwise in order of generation)
+ (2) external defined
+	(sorted by name)
+ (3) external undefined / common
+	(sorted by name)
+*/
 
 typedef struct bfd_mach_o_symtab_command
 {
@@ -438,10 +454,20 @@
 }
 bfd_mach_o_str_command;
 
+typedef struct bfd_mach_o_fvmlib_command
+{
+  unsigned int name_offset;
+  unsigned int name_len;
+  char *name_str;
+  unsigned int minor_version;
+  unsigned int header_addr;
+}
+bfd_mach_o_fvmlib_command;
+
 typedef struct bfd_mach_o_dyld_info_command
 {
   /* File offset and size to rebase info.  */
-  unsigned int rebase_off; 
+  unsigned int rebase_off;
   unsigned int rebase_size;
 
   /* File offset and size of binding info.  */
@@ -471,6 +497,31 @@
 }
 bfd_mach_o_version_min_command;
 
+typedef struct bfd_mach_o_encryption_info_command
+{
+  unsigned int cryptoff;
+  unsigned int cryptsize;
+  unsigned int cryptid;
+}
+bfd_mach_o_encryption_info_command;
+
+typedef struct bfd_mach_o_main_command
+{
+  bfd_uint64_t entryoff;
+  bfd_uint64_t stacksize;
+}
+bfd_mach_o_main_command;
+
+typedef struct bfd_mach_o_source_version_command
+{
+  unsigned int a;
+  unsigned short b;
+  unsigned short c;
+  unsigned short d;
+  unsigned short e;
+}
+bfd_mach_o_source_version_command;
+
 typedef struct bfd_mach_o_load_command
 {
   bfd_mach_o_load_command_type type;
@@ -491,6 +542,10 @@
     bfd_mach_o_str_command str;
     bfd_mach_o_dyld_info_command dyld_info;
     bfd_mach_o_version_min_command version_min;
+    bfd_mach_o_encryption_info_command encryption_info;
+    bfd_mach_o_fvmlib_command fvmlib;
+    bfd_mach_o_main_command main;
+    bfd_mach_o_source_version_command source_version;
   }
   command;
 }
@@ -507,7 +562,7 @@
   unsigned long nsects;
   bfd_mach_o_section **sections;
 
-  /* Used while writting: current length of the output file.  This is used
+  /* Used while writing: current length of the output file.  This is used
      to allocate space in the file.  */
   ufile_ptr filelen;
 
@@ -516,19 +571,26 @@
      is expected.  */
   bfd_mach_o_symtab_command *symtab;
   bfd_mach_o_dysymtab_command *dysymtab;
+
+  /* A place to stash dwarf2 info for this bfd.  */
+  void *dwarf2_find_line_info;
+
+  /* BFD of .dSYM file. */
+  bfd *dsym_bfd;
+
+  /* Cache of dynamic relocs. */
+  arelent *dyn_reloc_cache;
 }
 bfd_mach_o_data_struct;
 
-/* Target specific routines.  */
-typedef struct bfd_mach_o_backend_data
+typedef struct bfd_mach_o_xlat_name
 {
-  enum bfd_architecture arch;
-  bfd_boolean (*_bfd_mach_o_swap_reloc_in)(arelent *, bfd_mach_o_reloc_info *);
-  bfd_boolean (*_bfd_mach_o_swap_reloc_out)(arelent *, bfd_mach_o_reloc_info *);
-  bfd_boolean (*_bfd_mach_o_print_thread)(bfd *, bfd_mach_o_thread_flavour *,
-                                          void *, char *);
+  const char *name;
+  unsigned long val;
 }
-bfd_mach_o_backend_data;
+bfd_mach_o_xlat_name;
+
+/* Target specific routines.  */
 
 #define bfd_mach_o_get_data(abfd) ((abfd)->tdata.mach_o_data)
 #define bfd_mach_o_get_backend_data(abfd) \
@@ -539,9 +601,6 @@
   ((bfd_mach_o_section *)(sec)->used_by_bfd)
 
 bfd_boolean bfd_mach_o_valid (bfd *);
-int bfd_mach_o_read_dysymtab_symbol (bfd *, bfd_mach_o_dysymtab_command *, bfd_mach_o_symtab_command *, bfd_mach_o_asymbol *, unsigned long);
-int bfd_mach_o_scan_start_address (bfd *);
-int bfd_mach_o_scan (bfd *, bfd_mach_o_header *, bfd_mach_o_data_struct *);
 bfd_boolean bfd_mach_o_mkobject_init (bfd *);
 const bfd_target *bfd_mach_o_object_p (bfd *);
 const bfd_target *bfd_mach_o_core_p (bfd *);
@@ -557,9 +616,10 @@
 bfd_boolean bfd_mach_o_bfd_copy_private_section_data (bfd *, asection *,
                                                       bfd *, asection *);
 bfd_boolean bfd_mach_o_bfd_copy_private_bfd_data (bfd *, bfd *);
+bfd_boolean bfd_mach_o_bfd_set_private_flags (bfd *, flagword);
 long bfd_mach_o_get_symtab_upper_bound (bfd *);
 long bfd_mach_o_canonicalize_symtab (bfd *, asymbol **);
-long bfd_mach_o_get_synthetic_symtab (bfd *, long, asymbol **, long, 
+long bfd_mach_o_get_synthetic_symtab (bfd *, long, asymbol **, long,
                                       asymbol **, asymbol **ret);
 long bfd_mach_o_get_reloc_upper_bound (bfd *, asection *);
 long bfd_mach_o_canonicalize_reloc (bfd *, asection *, arelent **, asymbol **);
@@ -567,8 +627,7 @@
 long bfd_mach_o_canonicalize_dynamic_reloc (bfd *, arelent **, asymbol **);
 asymbol *bfd_mach_o_make_empty_symbol (bfd *);
 void bfd_mach_o_get_symbol_info (bfd *, asymbol *, symbol_info *);
-void bfd_mach_o_print_symbol (bfd *, PTR, asymbol *, bfd_print_symbol_type);
-bfd_boolean bfd_mach_o_bfd_print_private_bfd_data (bfd *, PTR);
+void bfd_mach_o_print_symbol (bfd *, void *, asymbol *, bfd_print_symbol_type);
 int bfd_mach_o_sizeof_headers (bfd *, struct bfd_link_info *);
 unsigned long bfd_mach_o_stack_addr (enum bfd_mach_o_cpu_type);
 int bfd_mach_o_core_fetch_environment (bfd *, unsigned char **, unsigned int *);
@@ -583,11 +642,70 @@
                                              file_ptr, bfd_size_type);
 unsigned int bfd_mach_o_version (bfd *);
 
-unsigned int bfd_mach_o_get_section_type_from_name (const char *);
+unsigned int bfd_mach_o_get_section_type_from_name (bfd *, const char *);
 unsigned int bfd_mach_o_get_section_attribute_from_name (const char *);
-void bfd_mach_o_normalize_section_name (const char *, const char *,
-                                        const char **, flagword *);
+
+void bfd_mach_o_convert_section_name_to_bfd (bfd *, const char *, const char *,
+					     const char **, flagword *);
+bfd_boolean bfd_mach_o_find_nearest_line (bfd *, asection *, asymbol **,
+                                          bfd_vma, const char **,
+                                          const char **, unsigned int *);
+bfd_boolean bfd_mach_o_close_and_cleanup (bfd *);
+bfd_boolean bfd_mach_o_free_cached_info (bfd *);
+
+unsigned int bfd_mach_o_section_get_nbr_indirect (bfd *, bfd_mach_o_section *);
+unsigned int bfd_mach_o_section_get_entry_size (bfd *, bfd_mach_o_section *);
+bfd_boolean bfd_mach_o_read_symtab_symbols (bfd *);
+bfd_boolean bfd_mach_o_read_symtab_strtab (bfd *abfd);
+
+/* A placeholder in case we need to suppress emitting the dysymtab for some
+   reason (e.g. compatibility with older system versions).  */
+#define bfd_mach_o_should_emit_dysymtab(x) TRUE
+
+extern const bfd_mach_o_xlat_name bfd_mach_o_section_attribute_name[];
+extern const bfd_mach_o_xlat_name bfd_mach_o_section_type_name[];
 
 extern const bfd_target mach_o_fat_vec;
 
+/* Interfaces between BFD names and Mach-O names.  */
+
+typedef struct mach_o_section_name_xlat
+{
+  const char *bfd_name;
+  const char *mach_o_name;
+  flagword bfd_flags;
+  unsigned int macho_sectype;
+  unsigned int macho_secattr;
+  unsigned int sectalign;
+} mach_o_section_name_xlat;
+
+typedef struct mach_o_segment_name_xlat
+{
+  const char *segname;
+  const mach_o_section_name_xlat *sections;
+} mach_o_segment_name_xlat;
+
+const mach_o_section_name_xlat *
+bfd_mach_o_section_data_for_mach_sect (bfd *, const char *, const char *);
+const mach_o_section_name_xlat *
+bfd_mach_o_section_data_for_bfd_name (bfd *, const char *, const char **);
+
+typedef struct bfd_mach_o_backend_data
+{
+  enum bfd_architecture arch;
+  bfd_boolean (*_bfd_mach_o_swap_reloc_in)(arelent *, bfd_mach_o_reloc_info *);
+  bfd_boolean (*_bfd_mach_o_swap_reloc_out)(arelent *, bfd_mach_o_reloc_info *);
+  bfd_boolean (*_bfd_mach_o_print_thread)(bfd *, bfd_mach_o_thread_flavour *,
+                                          void *, char *);
+  const mach_o_segment_name_xlat *segsec_names_xlat;
+  bfd_boolean (*bfd_mach_o_section_type_valid_for_target) (unsigned long);
+}
+bfd_mach_o_backend_data;
+
+/* Values used in symbol.udata.i, to signal that the mach-o-specific data in the
+   symbol are not yet set, or need validation (where this is possible).  */
+
+#define SYM_MACHO_FIELDS_UNSET ((bfd_vma) -1)
+#define SYM_MACHO_FIELDS_NOT_VALIDATED ((bfd_vma) -2)
+
 #endif /* _BFD_MACH_O_H_ */
diff --git a/bfd/makefile.vms b/bfd/makefile.vms
index 3c7f721..5534822 100644
--- a/bfd/makefile.vms
+++ b/bfd/makefile.vms
@@ -5,11 +5,26 @@
 #
 # Created by Klaus K"ampf, [email protected]
 #
+#   Copyright 2012 Free Software Foundation
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
 #
 
 ifeq ($(ARCH),IA64)
 HOSTFILE=alphavms.h
-OBJS:=cpu-ia64.obj,elf64-ia64.obj,elfxx-ia64.obj,elf64-ia64.obj,\
+OBJS:=cpu-ia64.obj,elfxx-ia64.obj,elf64-ia64-vms.obj,\
   vms-misc.obj,vms-lib.obj,elf-strtab.obj,corefile.obj,stabs.obj,\
   merge.obj,elf-eh-frame.obj,elflink.obj,elf-attrs.obj,dwarf1.obj,elf64.obj
 DEFS=SELECT_VECS="&bfd_elf64_ia64_vms_vec",\
diff --git a/bfd/merge.c b/bfd/merge.c
index aef3cf3..0e49fae 100644
--- a/bfd/merge.c
+++ b/bfd/merge.c
@@ -885,3 +885,17 @@
   *psec = entry->secinfo->sec;
   return entry->u.index + (secinfo->contents + offset - p);
 }
+
+/* Tidy up when done.  */
+
+void
+_bfd_merge_sections_free (void *xsinfo)
+{
+  struct sec_merge_info *sinfo;
+
+  for (sinfo = (struct sec_merge_info *) xsinfo; sinfo; sinfo = sinfo->next)
+    {
+      bfd_hash_table_free (&sinfo->htab->table);
+      free (sinfo->htab);
+    }
+}
diff --git a/bfd/mipsbsd.c b/bfd/mipsbsd.c
index 915e7bf..202c23f 100644
--- a/bfd/mipsbsd.c
+++ b/bfd/mipsbsd.c
@@ -1,6 +1,6 @@
 /* BFD backend for MIPS BSD (a.out) binaries.
    Copyright 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-   2005, 2007, 2009, 2011 Free Software Foundation, Inc.
+   2005, 2007, 2009, 2011, 2012 Free Software Foundation, Inc.
    Written by Ralph Campbell.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -49,11 +49,11 @@
 #define SET_ARCH_MACH(ABFD, EXEC) \
   MY(set_arch_mach) (ABFD, N_MACHTYPE (EXEC)); \
   MY(choose_reloc_size) (ABFD);
-static void MY(set_arch_mach) PARAMS ((bfd *abfd, unsigned long machtype));
-static void MY(choose_reloc_size) PARAMS ((bfd *abfd));
+static void MY(set_arch_mach) (bfd *, unsigned long);
+static void MY(choose_reloc_size) (bfd *);
 
 #define MY_write_object_contents MY(write_object_contents)
-static bfd_boolean MY(write_object_contents) PARAMS ((bfd *abfd));
+static bfd_boolean MY(write_object_contents) (bfd *);
 
 /* We can't use MY(x) here because it leads to a recursive call to CONCAT2
    when expanded inside JUMP_TABLE.  */
@@ -72,15 +72,13 @@
 #include "aout-target.h"
 
 static bfd_reloc_status_type mips_fix_jmp_addr
-  PARAMS ((bfd *, arelent *, struct bfd_symbol *, PTR, asection *,
-	   bfd *, char **));
+  (bfd *, arelent *, struct bfd_symbol *, void *, asection *,
+   bfd *, char **);
 
-long MY(canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **, asymbol **));
+long MY(canonicalize_reloc) (bfd *, sec_ptr, arelent **, asymbol **);
 
 static void
-MY(set_arch_mach) (abfd, machtype)
-     bfd *abfd;
-     unsigned long machtype;
+MY(set_arch_mach) (bfd *abfd, unsigned long machtype)
 {
   enum bfd_architecture arch;
   unsigned int machine;
@@ -109,8 +107,7 @@
 
 /* Determine the size of a relocation entry, based on the architecture */
 static void
-MY (choose_reloc_size) (abfd)
-     bfd *abfd;
+MY (choose_reloc_size) (bfd *abfd)
 {
   switch (bfd_get_arch (abfd))
     {
@@ -129,8 +126,7 @@
   file header, symbols, and relocation.  */
 
 static bfd_boolean
-MY (write_object_contents) (abfd)
-     bfd *abfd;
+MY (write_object_contents) (bfd *abfd)
 {
   struct external_exec exec_bytes;
   struct internal_exec *execp = exec_hdr (abfd);
@@ -195,20 +191,18 @@
    program counter, then we need to signal an error.  */
 
 static bfd_reloc_status_type
-mips_fix_jmp_addr (abfd, reloc_entry, symbol, data, input_section, output_bfd,
-		   error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc_entry;
-     struct bfd_symbol *symbol;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *input_section;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+mips_fix_jmp_addr (bfd *abfd ATTRIBUTE_UNUSED,
+		   arelent *reloc_entry,
+		   struct bfd_symbol *symbol,
+		   void * data ATTRIBUTE_UNUSED,
+		   asection *input_section,
+		   bfd *output_bfd,
+		   char **error_message ATTRIBUTE_UNUSED)
 {
   bfd_vma relocation, pc;
 
   /* If this is a partial relocation, just continue.  */
-  if (output_bfd != (bfd *)NULL)
+  if (output_bfd != (bfd *) NULL)
     return bfd_reloc_continue;
 
   /* If this is an undefined symbol, return error */
@@ -242,19 +236,13 @@
    when the low bits are added at run time.  */
 
 static bfd_reloc_status_type
-mips_fix_hi16_s PARAMS ((bfd *, arelent *, asymbol *, PTR,
-			 asection *, bfd *, char **));
-
-static bfd_reloc_status_type
-mips_fix_hi16_s (abfd, reloc_entry, symbol, data, input_section,
-		 output_bfd, error_message)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     arelent *reloc_entry;
-     asymbol *symbol;
-     PTR data ATTRIBUTE_UNUSED;
-     asection *input_section ATTRIBUTE_UNUSED;
-     bfd *output_bfd;
-     char **error_message ATTRIBUTE_UNUSED;
+mips_fix_hi16_s (bfd *abfd ATTRIBUTE_UNUSED,
+		 arelent *reloc_entry,
+		 asymbol *symbol,
+		 void * data ATTRIBUTE_UNUSED,
+		 asection *input_section ATTRIBUTE_UNUSED,
+		 bfd *output_bfd,
+		 char **error_message ATTRIBUTE_UNUSED)
 {
   bfd_vma relocation;
 
@@ -284,7 +272,8 @@
   return bfd_reloc_continue;
 }
 
-static reloc_howto_type mips_howto_table_ext[] = {
+static reloc_howto_type mips_howto_table_ext[] =
+{
   {MIPS_RELOC_32,      0, 2, 32, FALSE, 0,  complain_overflow_bitfield, 0,
 	"32",       FALSE, 0, 0xffffffff, FALSE},
   {MIPS_RELOC_JMP,     2, 2, 26, FALSE, 0, complain_overflow_dont,
@@ -304,9 +293,8 @@
 static reloc_howto_type *
 MY(reloc_type_lookup) (bfd *abfd, bfd_reloc_code_real_type code)
 {
-
   if (bfd_get_arch (abfd) != bfd_arch_mips)
-    return 0;
+    return NULL;
 
   switch (code)
     {
@@ -324,13 +312,13 @@
     case BFD_RELOC_LO16:
       return (&mips_howto_table_ext[MIPS_RELOC_LO16]);
     default:
-      return 0;
+      return NULL;
     }
 }
 
 static reloc_howto_type *
 MY(reloc_name_lookup) (bfd *abfd ATTRIBUTE_UNUSED,
-			     const char *r_name)
+		       const char *r_name)
 {
   unsigned int i;
 
@@ -347,11 +335,10 @@
 /* This is just like the standard aoutx.h version but we need to do our
    own mapping of external reloc type values to howto entries.  */
 long
-MY(canonicalize_reloc) (abfd, section, relptr, symbols)
-      bfd *abfd;
-      sec_ptr section;
-      arelent **relptr;
-      asymbol **symbols;
+MY(canonicalize_reloc) (bfd *abfd,
+			sec_ptr section,
+			arelent **relptr,
+			asymbol **symbols)
 {
   arelent *tblptr = section->relocation;
   unsigned int count, c;
@@ -395,7 +382,8 @@
   return section->reloc_count;
 }
 
-static const struct aout_backend_data MY(backend_data) = {
+static const struct aout_backend_data MY(backend_data) =
+{
   0,				/* zmagic contiguous */
   1,				/* text incl header */
   0,				/* entry is text address */
@@ -414,7 +402,7 @@
 extern const bfd_target aout_mips_big_vec;
 
 const bfd_target aout_mips_little_vec =
-  {
+{
     "a.out-mips-little",		/* name */
     bfd_target_aout_flavour,
     BFD_ENDIAN_LITTLE,		/* target byte order (little) */
@@ -452,7 +440,7 @@
 
     & aout_mips_big_vec,
 
-    (PTR) MY_backend_data
+    MY_backend_data
   };
 
 const bfd_target aout_mips_big_vec =
@@ -494,5 +482,5 @@
 
     & aout_mips_little_vec,
 
-    (PTR) MY_backend_data
+    MY_backend_data
   };
diff --git a/bfd/mmo.c b/bfd/mmo.c
index dc45f31..cd7b0fc 100644
--- a/bfd/mmo.c
+++ b/bfd/mmo.c
@@ -1,6 +1,5 @@
 /* BFD back-end for mmo objects (MMIX-specific object-format).
-   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright 2001-2013 Free Software Foundation, Inc.
    Written by Hans-Peter Nilsson ([email protected]).
    Infrastructure and other bits originally copied from srec.c and
    binary.c.
@@ -363,7 +362,7 @@
 static void mmo_find_sec_w_addr_grow (bfd *, asection *, void *);
 static asection *mmo_make_section (bfd *, const char *);
 static void mmo_get_symbol_info (bfd *, asymbol *, symbol_info *);
-static void mmo_print_symbol (bfd *, void *, asymbol *, 
+static void mmo_print_symbol (bfd *, void *, asymbol *,
 			      bfd_print_symbol_type);
 static void mmo_init (void);
 static bfd_boolean mmo_mkobject (bfd *);
@@ -662,8 +661,9 @@
       if (sec == NULL)
 	return NULL;
 
-      if (! sec->user_set_vma)
-	bfd_set_section_vma (abfd, sec, vma);
+      if (! sec->user_set_vma && ! bfd_set_section_vma (abfd, sec, vma))
+	return NULL;
+
       if (! bfd_set_section_flags (abfd, sec,
 				   bfd_get_section_flags (abfd, sec)
 				   | SEC_CODE | SEC_LOAD | SEC_ALLOC))
@@ -676,8 +676,9 @@
       if (sec == NULL)
 	return NULL;
 
-      if (! sec->user_set_vma)
-	bfd_set_section_vma (abfd, sec, vma);
+      if (! sec->user_set_vma && ! bfd_set_section_vma (abfd, sec, vma))
+	return NULL;
+
       if (! bfd_set_section_flags (abfd, sec,
 				   bfd_get_section_flags (abfd, sec)
 				   | SEC_LOAD | SEC_ALLOC))
@@ -692,8 +693,9 @@
   /* If there's still no suitable section, make a new one.  */
   sprintf (sec_name, ".MMIX.sec.%d", abfd->tdata.mmo_data->sec_no++);
   sec = mmo_make_section (abfd, sec_name);
-  if (! sec->user_set_vma)
-    bfd_set_section_vma (abfd, sec, vma);
+
+  if (! sec->user_set_vma && ! bfd_set_section_vma (abfd, sec, vma))
+    return NULL;
 
   if (! bfd_set_section_flags (abfd, sec,
 			       bfd_get_section_flags (abfd, sec)
@@ -787,21 +789,21 @@
 mmo_write_chunk (bfd *abfd, const bfd_byte *loc, unsigned int len)
 {
   bfd_boolean retval = TRUE;
+  struct mmo_data_struct *mmop = abfd->tdata.mmo_data;
 
   /* Fill up a tetra from bytes remaining from a previous chunk.  */
-  if (abfd->tdata.mmo_data->byte_no != 0)
+  if (mmop->byte_no != 0)
     {
-      while (abfd->tdata.mmo_data->byte_no < 4 && len != 0)
+      while (mmop->byte_no < 4 && len != 0)
 	{
-	  abfd->tdata.mmo_data->buf[abfd->tdata.mmo_data->byte_no++] = *loc++;
+	  mmop->buf[mmop->byte_no++] = *loc++;
 	  len--;
 	}
 
-      if (abfd->tdata.mmo_data->byte_no == 4)
+      if (mmop->byte_no == 4)
 	{
-	  mmo_write_tetra (abfd,
-			   bfd_get_32 (abfd, abfd->tdata.mmo_data->buf));
-	  abfd->tdata.mmo_data->byte_no = 0;
+	  mmo_write_tetra (abfd, bfd_get_32 (abfd, mmop->buf));
+	  mmop->byte_no = 0;
 	}
     }
 
@@ -811,7 +813,7 @@
 	mmo_write_tetra_raw (abfd, LOP_QUOTE_NEXT);
 
       retval = (retval
-		&& ! abfd->tdata.mmo_data->have_error
+		&& ! mmop->have_error
 		&& 4 == bfd_bwrite (loc, 4, abfd));
 
       loc += 4;
@@ -820,12 +822,12 @@
 
   if (len)
     {
-      memcpy (abfd->tdata.mmo_data->buf, loc, len);
-      abfd->tdata.mmo_data->byte_no = len;
+      memcpy (mmop->buf, loc, len);
+      mmop->byte_no = len;
     }
 
   if (! retval)
-    abfd->tdata.mmo_data->have_error = TRUE;
+    mmop->have_error = TRUE;
   return retval;
 }
 
@@ -1536,6 +1538,7 @@
   long stab_loc = -1;
   char *file_names[256];
 
+  abfd->symcount = 0;
   memset (file_names, 0, sizeof (file_names));
 
   if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
diff --git a/bfd/netbsd-core.c b/bfd/netbsd-core.c
index bc97742..695d3f5 100644
--- a/bfd/netbsd-core.c
+++ b/bfd/netbsd-core.c
@@ -1,6 +1,6 @@
 /* BFD back end for NetBSD style core files
    Copyright 1988, 1989, 1991, 1992, 1993, 1996, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005, 2006, 2007
+   2002, 2003, 2004, 2005, 2006, 2007, 2012
    Free Software Foundation, Inc.
    Written by Paul Kranenburg, EUR
 
@@ -316,5 +316,5 @@
 
     NULL,
 
-    (PTR) 0			        /* Backend_data.  */
+    NULL			        /* Backend_data.  */
   };
diff --git a/bfd/nlm32-i386.c b/bfd/nlm32-i386.c
index f1451c5..28b4433 100644
--- a/bfd/nlm32-i386.c
+++ b/bfd/nlm32-i386.c
@@ -1,5 +1,5 @@
 /* Support for 32-bit i386 NLM (NetWare Loadable Module)
-   Copyright 1993, 1994, 2000, 2001, 2002, 2003, 2005, 2007
+   Copyright 1993, 1994, 2000, 2001, 2002, 2003, 2005, 2007, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -233,7 +233,7 @@
 static bfd_boolean
 nlm_i386_mangle_relocs (bfd *abfd,
 			asection *sec,
-			const PTR data,
+			const void * data,
 			bfd_vma offset,
 			bfd_size_type count)
 {
diff --git a/bfd/nlm32-ppc.c b/bfd/nlm32-ppc.c
index b8c5852..ef5bfa9 100644
--- a/bfd/nlm32-ppc.c
+++ b/bfd/nlm32-ppc.c
@@ -1,6 +1,6 @@
 /* Support for 32-bit PowerPC NLM (NetWare Loadable Module)
    Copyright 1994, 1995, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2007 Free Software Foundation, Inc.
+   2007, 2012 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -19,8 +19,8 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 
 /* The format of a PowerPC NLM changed.  Define OLDFORMAT to get the
diff --git a/bfd/ns32knetbsd.c b/bfd/ns32knetbsd.c
index 6b636ae..fe0a688 100644
--- a/bfd/ns32knetbsd.c
+++ b/bfd/ns32knetbsd.c
@@ -1,6 +1,6 @@
 /* BFD back-end for NetBSD/ns32k a.out-ish binaries.
    Copyright 1990, 1991, 1992, 1994, 1995, 1998, 2000, 2001, 2002, 2005,
-   2007  Free Software Foundation, Inc.
+   2007, 2012  Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -46,6 +46,7 @@
    for me -- IWD.  */
 #define MY_bfd_reloc_type_lookup ns32kaout_bfd_reloc_type_lookup
 
+#include "sysdep.h"
 #include "bfd.h"		/* To ensure following declaration is OK.  */
 
 const struct reloc_howto_struct * MY_bfd_reloc_type_lookup (bfd *, bfd_reloc_code_real_type);
diff --git a/bfd/oasys.c b/bfd/oasys.c
index 11d2440..ebb12e8 100644
--- a/bfd/oasys.c
+++ b/bfd/oasys.c
@@ -906,9 +906,11 @@
 
   if (length > (size_t) sizeof (r.module_name))
     length = sizeof (r.module_name);
+  else if (length < (size_t) sizeof (r.module_name))
+    (void) memset (r.module_name + length, ' ',
+		   sizeof (r.module_name) - length);
 
   (void) memcpy (r.module_name, abfd->filename, length);
-  (void) memset (r.module_name + length, ' ', sizeof (r.module_name) - length);
 
   r.version_number = OASYS_VERSION_NUMBER;
   r.rev_number = OASYS_REV_NUMBER;
diff --git a/bfd/opncls.c b/bfd/opncls.c
index 9d33f39..cd9c826 100644
--- a/bfd/opncls.c
+++ b/bfd/opncls.c
@@ -1,7 +1,5 @@
 /* opncls.c -- open and close a BFD.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
-   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-   Free Software Foundation, Inc.
+   Copyright 1990-2013 Free Software Foundation, Inc.
 
    Written by Cygnus Support.
 
@@ -86,7 +84,7 @@
   nbfd->iostream = NULL;
   nbfd->where = 0;
   if (!bfd_hash_table_init_n (& nbfd->section_htab, bfd_section_hash_newfunc,
-			      sizeof (struct section_hash_entry), 251))
+			      sizeof (struct section_hash_entry), 13))
     {
       free (nbfd);
       return NULL;
@@ -107,6 +105,8 @@
   return nbfd;
 }
 
+static const struct bfd_iovec opncls_iovec;
+
 /* Allocate a new BFD as a member of archive OBFD.  */
 
 bfd *
@@ -119,6 +119,8 @@
     return NULL;
   nbfd->xvec = obfd->xvec;
   nbfd->iovec = obfd->iovec;
+  if (obfd->iovec == &opncls_iovec)
+    nbfd->iostream = obfd->iostream;
   nbfd->my_archive = obfd;
   nbfd->direction = read_direction;
   nbfd->target_defaulted = obfd->target_defaulted;
@@ -127,7 +129,7 @@
 
 /* Delete a BFD.  */
 
-void
+static void
 _bfd_delete_bfd (bfd *abfd)
 {
   if (abfd->memory)
@@ -135,6 +137,8 @@
       bfd_hash_table_free (&abfd->section_htab);
       objalloc_free ((struct objalloc *) abfd->memory);
     }
+
+  free (abfd->arelt_data);
   free (abfd);
 }
 
@@ -180,7 +184,7 @@
 	Return a pointer to the created BFD.  If @var{fd} is not -1,
 	then <<fdopen>> is used to open the file; otherwise, <<fopen>>
 	is used.  @var{mode} is passed directly to <<fopen>> or
-	<<fdopen>>. 
+	<<fdopen>>.
 
 	Calls <<bfd_find_target>>, so @var{target} is interpreted as by
 	that function.
@@ -190,6 +194,8 @@
 	If <<NULL>> is returned then an error has occured.   Possible errors
 	are <<bfd_error_no_memory>>, <<bfd_error_invalid_target>> or
 	<<system_call>> error.
+
+	On error, @var{fd} is always closed.
 */
 
 bfd *
@@ -200,15 +206,21 @@
 
   nbfd = _bfd_new_bfd ();
   if (nbfd == NULL)
-    return NULL;
+    {
+      if (fd != -1)
+	close (fd);
+      return NULL;
+    }
 
   target_vec = bfd_find_target (target, nbfd);
   if (target_vec == NULL)
     {
+      if (fd != -1)
+	close (fd);
       _bfd_delete_bfd (nbfd);
       return NULL;
     }
-  
+
 #ifdef HAVE_FDOPEN
   if (fd != -1)
     nbfd->iostream = fdopen (fd, mode);
@@ -227,7 +239,7 @@
 
   /* Figure out whether the user is opening the file for reading,
      writing, or both, by looking at the MODE argument.  */
-  if ((mode[0] == 'r' || mode[0] == 'w' || mode[0] == 'a') 
+  if ((mode[0] == 'r' || mode[0] == 'w' || mode[0] == 'a')
       && mode[1] == '+')
     nbfd->direction = both_direction;
   else if (mode[0] == 'r')
@@ -241,12 +253,13 @@
       return NULL;
     }
   nbfd->opened_once = TRUE;
+
   /* If we opened the file by name, mark it cacheable; we can close it
      and reopen it later.  However, if a file descriptor was provided,
      then it may have been opened with special flags that make it
      unsafe to close and reopen the file.  */
   if (fd == -1)
-    bfd_set_cacheable (nbfd, TRUE);
+    (void) bfd_set_cacheable (nbfd, TRUE);
 
   return nbfd;
 }
@@ -307,6 +320,8 @@
 
 	Possible errors are <<bfd_error_no_memory>>,
 	<<bfd_error_invalid_target>> and <<bfd_error_system_call>>.
+
+	On error, @var{fd} is closed.
 */
 
 bfd *
@@ -323,6 +338,10 @@
   fdflags = fcntl (fd, F_GETFL, NULL);
   if (fdflags == -1)
     {
+      int save = errno;
+
+      close (fd);
+      errno = save;
       bfd_set_error (bfd_error_system_call);
       return NULL;
     }
@@ -693,8 +712,6 @@
 bfd_close (bfd *abfd)
 {
   bfd_boolean ret;
-  bfd *nbfd;
-  bfd *next;
 
   if (bfd_write_p (abfd))
     {
@@ -702,17 +719,10 @@
 	return FALSE;
     }
 
-  /* Close nested archives (if this bfd is a thin archive).  */
-  for (nbfd = abfd->nested_archives; nbfd; nbfd = next)
-    {
-      next = nbfd->archive_next;
-      bfd_close (nbfd);
-    }
-
   if (! BFD_SEND (abfd, _close_and_cleanup, (abfd)))
     return FALSE;
 
-  ret = abfd->iovec->bclose (abfd);
+  ret = abfd->iovec->bclose (abfd) == 0;
 
   if (ret)
     _maybe_make_executable (abfd);
@@ -1038,10 +1048,11 @@
 
    This facilitates "optional" provision of debugging information, without
    having to provide two complete copies of every binary object (with and
-   without debug symbols).
-*/
+   without debug symbols).  */
 
-#define GNU_DEBUGLINK	".gnu_debuglink"
+#define GNU_DEBUGLINK		".gnu_debuglink"
+#define GNU_DEBUGALTLINK	".gnu_debugaltlink"
+
 /*
 FUNCTION
 	bfd_calc_gnu_debuglink_crc32
@@ -1124,25 +1135,27 @@
   crc = ~crc & 0xffffffff;
   for (end = buf + len; buf < end; ++ buf)
     crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8);
-  return ~crc & 0xffffffff;;
+  return ~crc & 0xffffffff;
 }
 
 
 /*
-INTERNAL_FUNCTION
-	get_debug_link_info
+FUNCTION
+	bfd_get_debug_link_info
 
 SYNOPSIS
-	char *get_debug_link_info (bfd *abfd, unsigned long *crc32_out);
+	char *bfd_get_debug_link_info (bfd *abfd, unsigned long *crc32_out);
 
 DESCRIPTION
 	fetch the filename and CRC32 value for any separate debuginfo
 	associated with @var{abfd}. Return NULL if no such info found,
-	otherwise return filename and update @var{crc32_out}.
+	otherwise return filename and update @var{crc32_out}.  The
+	returned filename is allocated with @code{malloc}; freeing it
+	is the responsibility of the caller.
 */
 
-static char *
-get_debug_link_info (bfd *abfd, unsigned long *crc32_out)
+char *
+bfd_get_debug_link_info (bfd *abfd, unsigned long *crc32_out)
 {
   asection *sect;
   unsigned long crc32;
@@ -1177,6 +1190,54 @@
 }
 
 /*
+FUNCTION
+	bfd_get_alt_debug_link_info
+
+SYNOPSIS
+	char *bfd_get_alt_debug_link_info (bfd *abfd, unsigned long *crc32_out);
+
+DESCRIPTION
+	Fetch the filename and BuildID value for any alternate debuginfo
+	associated with @var{abfd}.  Return NULL if no such info found,
+	otherwise return filename and update @var{buildid_out}.  The
+	returned filename is allocated with @code{malloc}; freeing it
+	is the responsibility of the caller.
+*/
+
+char *
+bfd_get_alt_debug_link_info (bfd * abfd, unsigned long * buildid_out)
+{
+  asection *sect;
+  bfd_byte *contents;
+  int buildid_offset;
+  char *name;
+
+  BFD_ASSERT (abfd);
+  BFD_ASSERT (buildid_out);
+
+  sect = bfd_get_section_by_name (abfd, GNU_DEBUGALTLINK);
+
+  if (sect == NULL)
+    return NULL;
+
+  if (!bfd_malloc_and_get_section (abfd, sect, & contents))
+    {
+      if (contents != NULL)
+	free (contents);
+      return NULL;
+    }
+
+  /* BuildID value is stored after the filename, aligned up to 4 bytes.  */
+  name = (char *) contents;
+  buildid_offset = strlen (name) + 1;
+  buildid_offset = (buildid_offset + 3) & ~3;
+
+  * buildid_out = bfd_get_32 (abfd, contents + buildid_offset);
+
+  return name;
+}
+
+/*
 INTERNAL_FUNCTION
 	separate_debug_file_exists
 
@@ -1211,6 +1272,37 @@
   return crc == file_crc;
 }
 
+/*
+INTERNAL_FUNCTION
+	separate_alt_debug_file_exists
+
+SYNOPSIS
+	bfd_boolean separate_alt_debug_file_exists
+	  (char *name, unsigned long crc32);
+
+DESCRIPTION
+	Checks to see if @var{name} is a file and if its BuildID
+	matches @var{buildid}.
+*/
+
+static bfd_boolean
+separate_alt_debug_file_exists (const char *name,
+				const unsigned long buildid ATTRIBUTE_UNUSED)
+{
+  FILE *f;
+
+  BFD_ASSERT (name);
+
+  f = real_fopen (name, FOPEN_RB);
+  if (f == NULL)
+    return FALSE;
+
+  /* FIXME: Add code to check buildid.  */
+
+  fclose (f);
+
+  return TRUE;
+}
 
 /*
 INTERNAL_FUNCTION
@@ -1220,16 +1312,24 @@
 	char *find_separate_debug_file (bfd *abfd);
 
 DESCRIPTION
-	Searches @var{abfd} for a reference to separate debugging
-	information, scans various locations in the filesystem, including
-	the file tree rooted at @var{debug_file_directory}, and returns a
-	filename of such debugging information if the file is found and has
-	matching CRC32.  Returns NULL if no reference to debugging file
-	exists, or file cannot be found.
+	Searches @var{abfd} for a section called @var{section_name} which
+	is expected to contain a reference to a file containing separate
+	debugging information.  The function scans various locations in
+	the filesystem, including the file tree rooted at
+	@var{debug_file_directory}, and returns the first matching
+	filename that it finds.  If @var{check_crc} is TRUE then the
+	contents of the file must also match the CRC value contained in
+	@var{section_name}.  Returns NULL if no valid file could be found.
 */
 
+typedef char *      (* get_func_type) (bfd *, unsigned long *);
+typedef bfd_boolean (* check_func_type) (const char *, const unsigned long);
+
 static char *
-find_separate_debug_file (bfd *abfd, const char *debug_file_directory)
+find_separate_debug_file (bfd *           abfd,
+			  const char *    debug_file_directory,
+			  get_func_type   get_func,
+			  check_func_type check_func)
 {
   char *base;
   char *dir;
@@ -1250,7 +1350,8 @@
       return NULL;
     }
 
-  base = get_debug_link_info (abfd, & crc32);
+  base = get_func (abfd, & crc32);
+    
   if (base == NULL)
     return NULL;
 
@@ -1289,37 +1390,22 @@
                   + strlen (base)
                   + 1);
   if (debugfile == NULL)
-    {
-      free (base);
-      free (dir);
-      free (canon_dir);
-      return NULL;
-    }
+    goto found; /* Actually this returns NULL.  */
 
   /* First try in the same directory as the original file:  */
   strcpy (debugfile, dir);
   strcat (debugfile, base);
 
-  if (separate_debug_file_exists (debugfile, crc32))
-    {
-      free (base);
-      free (dir);
-      free (canon_dir);
-      return debugfile;
-    }
+  if (check_func (debugfile, crc32))
+    goto found;
 
   /* Then try in a subdirectory called .debug.  */
   strcpy (debugfile, dir);
   strcat (debugfile, ".debug/");
   strcat (debugfile, base);
 
-  if (separate_debug_file_exists (debugfile, crc32))
-    {
-      free (base);
-      free (dir);
-      free (canon_dir);
-      return debugfile;
-    }
+  if (check_func (debugfile, crc32))
+    goto found;
 
   /* Then try in the global debugfile directory.  */
   strcpy (debugfile, debug_file_directory);
@@ -1331,19 +1417,18 @@
   strcat (debugfile, canon_dir);
   strcat (debugfile, base);
 
-  if (separate_debug_file_exists (debugfile, crc32))
-    {
-      free (base);
-      free (dir);
-      free (canon_dir);
-      return debugfile;
-    }
+  if (check_func (debugfile, crc32))
+    goto found;
 
+  /* Failed to find the file.  */
   free (debugfile);
+  debugfile = NULL;
+
+ found:
   free (base);
   free (dir);
   free (canon_dir);
-  return NULL;
+  return debugfile;
 }
 
 
@@ -1376,7 +1461,43 @@
 char *
 bfd_follow_gnu_debuglink (bfd *abfd, const char *dir)
 {
-  return find_separate_debug_file (abfd, dir);
+  return find_separate_debug_file (abfd, dir,
+				   bfd_get_debug_link_info,
+				   separate_debug_file_exists);
+}
+
+/*
+FUNCTION
+	bfd_follow_gnu_debugaltlink
+
+SYNOPSIS
+	char *bfd_follow_gnu_debugaltlink (bfd *abfd, const char *dir);
+
+DESCRIPTION
+
+	Takes a BFD and searches it for a .gnu_debugaltlink section.  If this
+	section is found, it examines the section for the name of a file
+	containing auxiliary debugging information.  It	then searches the
+	filesystem for this file in a set of standard locations, including
+	the directory tree rooted at @var{dir}, and if found returns the
+	full filename.
+
+	If @var{dir} is NULL, it will search a default path configured into
+	libbfd at build time.  [FIXME: This feature is not currently
+	implemented].
+
+RETURNS
+	<<NULL>> on any errors or failure to locate the debug file,
+	otherwise a pointer to a heap-allocated string containing the
+	filename.  The caller is responsible for freeing this string.
+*/
+
+char *
+bfd_follow_gnu_debugaltlink (bfd *abfd, const char *dir)
+{
+  return find_separate_debug_file (abfd, dir,
+				   bfd_get_alt_debug_link_info,
+				   separate_alt_debug_file_exists);
 }
 
 /*
diff --git a/bfd/osf-core.c b/bfd/osf-core.c
index d613bdb..ed5fbbe 100644
--- a/bfd/osf-core.c
+++ b/bfd/osf-core.c
@@ -1,6 +1,6 @@
 /* BFD back-end for OSF/1 core files.
    Copyright 1993, 1994, 1995, 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007, 2010, 2011 Free Software Foundation, Inc.
+   2007, 2010, 2011, 2012 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -34,18 +34,8 @@
 
 /* forward declarations */
 
-static asection *make_bfd_asection
-  PARAMS ((bfd *, const char *, flagword, bfd_size_type, bfd_vma, file_ptr));
-static const bfd_target *osf_core_core_file_p
-  PARAMS ((bfd *));
-static char *osf_core_core_file_failing_command
-  PARAMS ((bfd *));
-static int osf_core_core_file_failing_signal
-  PARAMS ((bfd *));
 #define osf_core_core_file_matches_executable_p generic_core_file_matches_executable_p
 #define osf_core_core_file_pid _bfd_nocore_core_file_pid
-static void swap_abort
-  PARAMS ((void));
 
 /* These are stored in the bfd's tdata */
 
@@ -56,17 +46,16 @@
 };
 
 #define core_hdr(bfd) ((bfd)->tdata.osf_core_data)
-#define core_signal(bfd) (core_hdr(bfd)->sig)
+#define core_signal(bfd)  (core_hdr(bfd)->sig)
 #define core_command(bfd) (core_hdr(bfd)->cmd)
 
 static asection *
-make_bfd_asection (abfd, name, flags, size, vma, filepos)
-     bfd *abfd;
-     const char *name;
-     flagword flags;
-     bfd_size_type size;
-     bfd_vma vma;
-     file_ptr filepos;
+make_bfd_asection (bfd *abfd,
+		   const char *name,
+		   flagword flags,
+		   bfd_size_type size,
+		   bfd_vma vma,
+		   file_ptr filepos)
 {
   asection *asect;
 
@@ -83,8 +72,7 @@
 }
 
 static const bfd_target *
-osf_core_core_file_p (abfd)
-     bfd *abfd;
+osf_core_core_file_p (bfd *abfd)
 {
   int val;
   int i;
@@ -93,7 +81,7 @@
   bfd_size_type amt;
 
   amt = sizeof core_header;
-  val = bfd_bread ((PTR) &core_header, amt, abfd);
+  val = bfd_bread (& core_header, amt, abfd);
   if (val != sizeof core_header)
     return NULL;
 
@@ -114,7 +102,7 @@
       flagword flags;
 
       amt = sizeof core_scnhdr;
-      val = bfd_bread ((PTR) &core_scnhdr, amt, abfd);
+      val = bfd_bread (& core_scnhdr, amt, abfd);
       if (val != sizeof core_scnhdr)
 	break;
 
@@ -161,24 +149,22 @@
 }
 
 static char *
-osf_core_core_file_failing_command (abfd)
-     bfd *abfd;
+osf_core_core_file_failing_command (bfd *abfd)
 {
   return core_command (abfd);
 }
 
 static int
-osf_core_core_file_failing_signal (abfd)
-     bfd *abfd;
+osf_core_core_file_failing_signal (bfd *abfd)
 {
   return core_signal (abfd);
 }
 
 /* If somebody calls any byte-swapping routines, shoot them.  */
 static void
-swap_abort()
+swap_abort (void)
 {
-  abort(); /* This way doesn't require any declaration for ANSI to fuck up */
+  abort (); /* This way doesn't require any declaration for ANSI to fuck up */
 }
 
 #define	NO_GET ((bfd_vma (*) (const void *)) swap_abort)
@@ -236,5 +222,5 @@
 
     NULL,
 
-    (PTR) 0			/* backend_data */
+    NULL			/* backend_data */
   };
diff --git a/bfd/pc532-mach.c b/bfd/pc532-mach.c
index b472006..9252333 100644
--- a/bfd/pc532-mach.c
+++ b/bfd/pc532-mach.c
@@ -76,14 +76,10 @@
 #define MY_exec_header_not_counted 1
 
 reloc_howto_type *ns32kaout_bfd_reloc_type_lookup
-  PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
-
-static bfd_boolean MY(write_object_contents)
-  PARAMS ((bfd *abfd));
+  (bfd *abfd, bfd_reloc_code_real_type code);
 
 static bfd_boolean
-MY(write_object_contents) (abfd)
-     bfd *abfd;
+MY(write_object_contents) (bfd *abfd)
 {
   struct external_exec exec_bytes;
   struct internal_exec *execp = exec_hdr (abfd);
diff --git a/bfd/pdp11.c b/bfd/pdp11.c
index e815a43..1560f17 100644
--- a/bfd/pdp11.c
+++ b/bfd/pdp11.c
@@ -340,7 +340,7 @@
       if (bfd_seek (abfd, (file_ptr) (N_TRELOFF(*execp)), SEEK_SET) != 0
 	  || !NAME (aout, squirt_out_relocs) (abfd, obj_textsec (abfd))
 	  || bfd_seek (abfd, (file_ptr) (N_DRELOFF(*execp)), SEEK_SET) != 0
-	  || !NAME (aout, squirt_out_relocs) (abfd, obj_datasec (abfd)))  
+	  || !NAME (aout, squirt_out_relocs) (abfd, obj_datasec (abfd)))
 	return FALSE;
     }
 
@@ -2459,7 +2459,7 @@
   struct aout_link_hash_table *ret;
   bfd_size_type amt = sizeof (struct aout_link_hash_table);
 
-  ret = bfd_alloc (abfd, amt);
+  ret = bfd_malloc (amt);
   if (ret == NULL)
     return NULL;
   if (! NAME (aout, link_hash_table_init) (ret, abfd,
@@ -2895,7 +2895,7 @@
 aout_link_write_other_symbol (struct bfd_hash_entry *bh, void *data)
 {
   struct aout_link_hash_entry *h = (struct aout_link_hash_entry *) bh;
-  struct aout_final_link_info *finfo = (struct aout_final_link_info *) data;
+  struct aout_final_link_info *flaginfo = (struct aout_final_link_info *) data;
   bfd *output_bfd;
   int type;
   bfd_vma val;
@@ -2910,12 +2910,12 @@
 	return TRUE;
     }
 
-  output_bfd = finfo->output_bfd;
+  output_bfd = flaginfo->output_bfd;
 
   if (aout_backend_info (output_bfd)->write_dynamic_symbol != NULL)
     {
       if (! ((*aout_backend_info (output_bfd)->write_dynamic_symbol)
-	     (output_bfd, finfo->info, h)))
+	     (output_bfd, flaginfo->info, h)))
 	{
 	  /* FIXME: No way to handle errors.  */
 	  abort ();
@@ -2929,9 +2929,9 @@
 
   /* An indx of -2 means the symbol must be written.  */
   if (h->indx != -2
-      && (finfo->info->strip == strip_all
-	  || (finfo->info->strip == strip_some
-	      && bfd_hash_lookup (finfo->info->keep_hash, h->root.root.string,
+      && (flaginfo->info->strip == strip_all
+	  || (flaginfo->info->strip == strip_some
+	      && bfd_hash_lookup (flaginfo->info->keep_hash, h->root.root.string,
 				  FALSE, FALSE) == NULL)))
     return TRUE;
 
@@ -2986,7 +2986,7 @@
     }
 
   H_PUT_8 (output_bfd, type, outsym.e_type);
-  indx = add_to_stringtab (output_bfd, finfo->strtab, h->root.root.string,
+  indx = add_to_stringtab (output_bfd, flaginfo->strtab, h->root.root.string,
 			   FALSE);
   if (indx == (bfd_size_type) -1)
     /* FIXME: No way to handle errors.  */
@@ -2996,12 +2996,12 @@
   PUT_WORD (output_bfd, val, outsym.e_value);
 
   amt = EXTERNAL_NLIST_SIZE;
-  if (bfd_seek (output_bfd, finfo->symoff, SEEK_SET) != 0
+  if (bfd_seek (output_bfd, flaginfo->symoff, SEEK_SET) != 0
       || bfd_bwrite ((void *) &outsym, amt, output_bfd) != amt)
     /* FIXME: No way to handle errors.  */
     abort ();
 
-  finfo->symoff += amt;
+  flaginfo->symoff += amt;
   h->indx = obj_aout_external_sym_count (output_bfd);
   ++obj_aout_external_sym_count (output_bfd);
 
@@ -3011,7 +3011,7 @@
 /* Handle a link order which is supposed to generate a reloc.  */
 
 static bfd_boolean
-aout_link_reloc_link_order (struct aout_final_link_info *finfo,
+aout_link_reloc_link_order (struct aout_final_link_info *flaginfo,
 			    asection *o,
 			    struct bfd_link_order *p)
 {
@@ -3033,7 +3033,7 @@
 	r_index = N_ABS | N_EXT;
       else
 	{
-	  BFD_ASSERT (pr->u.section->owner == finfo->output_bfd);
+	  BFD_ASSERT (pr->u.section->owner == flaginfo->output_bfd);
 	  r_index = pr->u.section->target_index;
 	}
     }
@@ -3044,7 +3044,7 @@
       BFD_ASSERT (p->type == bfd_symbol_reloc_link_order);
       r_extern = 1;
       h = ((struct aout_link_hash_entry *)
-	   bfd_wrapped_link_hash_lookup (finfo->output_bfd, finfo->info,
+	   bfd_wrapped_link_hash_lookup (flaginfo->output_bfd, flaginfo->info,
 					 pr->u.name, FALSE, FALSE, TRUE));
       if (h != NULL
 	  && h->indx >= 0)
@@ -3057,35 +3057,35 @@
 	     symbol.  */
 	  h->indx = -2;
 	  h->written = FALSE;
-	  if (!aout_link_write_other_symbol (&h->root.root, finfo))
+	  if (!aout_link_write_other_symbol (&h->root.root, flaginfo))
 	    return FALSE;
 	  r_index = h->indx;
 	}
       else
 	{
-	  if (! ((*finfo->info->callbacks->unattached_reloc)
-		 (finfo->info, pr->u.name, NULL, NULL, (bfd_vma) 0)))
+	  if (! ((*flaginfo->info->callbacks->unattached_reloc)
+		 (flaginfo->info, pr->u.name, NULL, NULL, (bfd_vma) 0)))
 	    return FALSE;
 	  r_index = 0;
 	}
     }
 
-  howto = bfd_reloc_type_lookup (finfo->output_bfd, pr->reloc);
+  howto = bfd_reloc_type_lookup (flaginfo->output_bfd, pr->reloc);
   if (howto == 0)
     {
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
     }
 
-  if (o == obj_textsec (finfo->output_bfd))
-    reloff_ptr = &finfo->treloff;
-  else if (o == obj_datasec (finfo->output_bfd))
-    reloff_ptr = &finfo->dreloff;
+  if (o == obj_textsec (flaginfo->output_bfd))
+    reloff_ptr = &flaginfo->treloff;
+  else if (o == obj_datasec (flaginfo->output_bfd))
+    reloff_ptr = &flaginfo->dreloff;
   else
     abort ();
 
 #ifdef MY_put_reloc
-  MY_put_reloc(finfo->output_bfd, r_extern, r_index, p->offset, howto,
+  MY_put_reloc(flaginfo->output_bfd, r_extern, r_index, p->offset, howto,
 	       &srel);
 #else
   {
@@ -3103,8 +3103,8 @@
     r_relative = (howto->type & 32) != 0;
     r_length = howto->size;
 
-    PUT_WORD (finfo->output_bfd, p->offset, srel.r_address);
-    if (bfd_header_big_endian (finfo->output_bfd))
+    PUT_WORD (flaginfo->output_bfd, p->offset, srel.r_address);
+    if (bfd_header_big_endian (flaginfo->output_bfd))
       {
 	srel.r_index[0] = r_index >> 16;
 	srel.r_index[1] = r_index >> 8;
@@ -3150,7 +3150,7 @@
       buf = bfd_zmalloc (size);
       if (buf == NULL)
 	return FALSE;
-      r = MY_relocate_contents (howto, finfo->output_bfd,
+      r = MY_relocate_contents (howto, flaginfo->output_bfd,
 				pr->addend, buf);
       switch (r)
 	{
@@ -3160,10 +3160,10 @@
 	case bfd_reloc_outofrange:
 	  abort ();
 	case bfd_reloc_overflow:
-	  if (! ((*finfo->info->callbacks->reloc_overflow)
-		 (finfo->info, NULL,
+	  if (! ((*flaginfo->info->callbacks->reloc_overflow)
+		 (flaginfo->info, NULL,
 		  (p->type == bfd_section_reloc_link_order
-		   ? bfd_section_name (finfo->output_bfd,
+		   ? bfd_section_name (flaginfo->output_bfd,
 				       pr->u.section)
 		   : pr->u.name),
 		  howto->name, pr->addend, NULL,
@@ -3174,7 +3174,7 @@
 	    }
 	  break;
 	}
-      ok = bfd_set_section_contents (finfo->output_bfd, o,
+      ok = bfd_set_section_contents (flaginfo->output_bfd, o,
 				     (void *) buf,
 				     (file_ptr) p->offset,
 				     size);
@@ -3183,19 +3183,19 @@
 	return FALSE;
     }
 
-  rel_size = obj_reloc_entry_size (finfo->output_bfd);
-  if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0
-      || bfd_bwrite (rel_ptr, rel_size, finfo->output_bfd) != rel_size)
+  rel_size = obj_reloc_entry_size (flaginfo->output_bfd);
+  if (bfd_seek (flaginfo->output_bfd, *reloff_ptr, SEEK_SET) != 0
+      || bfd_bwrite (rel_ptr, rel_size, flaginfo->output_bfd) != rel_size)
     return FALSE;
 
   *reloff_ptr += rel_size;
 
   /* Assert that the relocs have not run into the symbols, and that n
      the text relocs have not run into the data relocs.  */
-  BFD_ASSERT (*reloff_ptr <= obj_sym_filepos (finfo->output_bfd)
-	      && (reloff_ptr != &finfo->treloff
+  BFD_ASSERT (*reloff_ptr <= obj_sym_filepos (flaginfo->output_bfd)
+	      && (reloff_ptr != &flaginfo->treloff
 		  || (*reloff_ptr
-		      <= obj_datasec (finfo->output_bfd)->rel_filepos)));
+		      <= obj_datasec (flaginfo->output_bfd)->rel_filepos)));
 
   return TRUE;
 }
@@ -3217,7 +3217,7 @@
 }
 
 static bfd_boolean
-pdp11_aout_link_input_section (struct aout_final_link_info *finfo,
+pdp11_aout_link_input_section (struct aout_final_link_info *flaginfo,
 			       bfd *input_bfd,
 			       asection *input_section,
 			       bfd_byte *relocs,
@@ -3237,18 +3237,18 @@
   bfd_byte *rel;
   bfd_byte *rel_end;
 
-  output_bfd = finfo->output_bfd;
+  output_bfd = flaginfo->output_bfd;
   check_dynamic_reloc = aout_backend_info (output_bfd)->check_dynamic_reloc;
 
   BFD_ASSERT (obj_reloc_entry_size (input_bfd) == RELOC_SIZE);
   BFD_ASSERT (input_bfd->xvec->header_byteorder
 	      == output_bfd->xvec->header_byteorder);
 
-  relocatable = finfo->info->relocatable;
+  relocatable = flaginfo->info->relocatable;
   syms = obj_aout_external_syms (input_bfd);
   strings = obj_aout_external_strings (input_bfd);
   sym_hashes = obj_aout_sym_hashes (input_bfd);
-  symbol_map = finfo->symbol_map;
+  symbol_map = flaginfo->symbol_map;
 
   rel = relocs;
   rel_end = rel + rel_size;
@@ -3337,7 +3337,7 @@
 			      h->indx = -2;
 			      h->written = FALSE;
 			      if (!aout_link_write_other_symbol (&h->root.root,
-								 finfo))
+								 flaginfo))
 				return FALSE;
 			    }
 			  r_index = h->indx;
@@ -3348,8 +3348,8 @@
 
 			  name = strings + GET_WORD (input_bfd,
 						     syms[r_index].e_strx);
-			  if (! ((*finfo->info->callbacks->unattached_reloc)
-				 (finfo->info, name, input_bfd, input_section,
+			  if (! ((*flaginfo->info->callbacks->unattached_reloc)
+				 (flaginfo->info, name, input_bfd, input_section,
 				  r_addr)))
 			    return FALSE;
 			  r_index = 0;
@@ -3444,7 +3444,7 @@
 	      bfd_boolean skip;
 
 	      if (! ((*check_dynamic_reloc)
-		     (finfo->info, input_bfd, input_section, h,
+		     (flaginfo->info, input_bfd, input_section, h,
 		      (void *) rel, contents, &skip, &relocation)))
 		return FALSE;
 	      if (skip)
@@ -3454,7 +3454,7 @@
 	  /* Now warn if a global symbol is undefined.  We could not
              do this earlier, because check_dynamic_reloc might want
              to skip this reloc.  */
-	  if (hundef && ! finfo->info->shared)
+	  if (hundef && ! flaginfo->info->shared)
 	    {
 	      const char *name;
 
@@ -3462,8 +3462,8 @@
 		name = h->root.root.string;
 	      else
 		name = strings + GET_WORD (input_bfd, syms[r_index].e_strx);
-	      if (! ((*finfo->info->callbacks->undefined_symbol)
-		     (finfo->info, name, input_bfd, input_section,
+	      if (! ((*flaginfo->info->callbacks->undefined_symbol)
+		     (flaginfo->info, name, input_bfd, input_section,
 		      r_addr, TRUE)))
 		return FALSE;
 	    }
@@ -3497,8 +3497,8 @@
 		    s = aout_reloc_type_to_section (input_bfd, r_type);
 		    name = bfd_section_name (input_bfd, s);
 		  }
-		if (! ((*finfo->info->callbacks->reloc_overflow)
-		       (finfo->info, (h ? &h->root : NULL), name,
+		if (! ((*flaginfo->info->callbacks->reloc_overflow)
+		       (flaginfo->info, (h ? &h->root : NULL), name,
 			howto->name, (bfd_vma) 0, input_bfd,
 			input_section, r_addr)))
 		  return FALSE;
@@ -3514,7 +3514,7 @@
 /* Link an a.out section into the output file.  */
 
 static bfd_boolean
-aout_link_input_section (struct aout_final_link_info *finfo,
+aout_link_input_section (struct aout_final_link_info *flaginfo,
 			 bfd *input_bfd,
 			 asection *input_section,
 			 file_ptr *reloff_ptr,
@@ -3526,7 +3526,7 @@
   /* Get the section contents.  */
   input_size = input_section->size;
   if (! bfd_get_section_contents (input_bfd, input_section,
-				  (void *) finfo->contents,
+				  (void *) flaginfo->contents,
 				  (file_ptr) 0, input_size))
     return FALSE;
 
@@ -3536,7 +3536,7 @@
     relocs = aout_section_data (input_section)->relocs;
   else
     {
-      relocs = finfo->relocs;
+      relocs = flaginfo->relocs;
       if (rel_size > 0)
 	{
 	  if (bfd_seek (input_bfd, input_section->rel_filepos, SEEK_SET) != 0
@@ -3546,36 +3546,36 @@
     }
 
   /* Relocate the section contents.  */
-  if (! pdp11_aout_link_input_section (finfo, input_bfd, input_section,
+  if (! pdp11_aout_link_input_section (flaginfo, input_bfd, input_section,
 				       (bfd_byte *) relocs,
-				       rel_size, finfo->contents))
+				       rel_size, flaginfo->contents))
     return FALSE;
 
   /* Write out the section contents.  */
-  if (! bfd_set_section_contents (finfo->output_bfd,
+  if (! bfd_set_section_contents (flaginfo->output_bfd,
 				  input_section->output_section,
-				  (void *) finfo->contents,
+				  (void *) flaginfo->contents,
 				  (file_ptr) input_section->output_offset,
 				  input_size))
     return FALSE;
 
   /* If we are producing relocatable output, the relocs were
      modified, and we now write them out.  */
-  if (finfo->info->relocatable && rel_size > 0)
+  if (flaginfo->info->relocatable && rel_size > 0)
     {
-      if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0)
+      if (bfd_seek (flaginfo->output_bfd, *reloff_ptr, SEEK_SET) != 0)
 	return FALSE;
-      if (bfd_bwrite (relocs, rel_size, finfo->output_bfd) != rel_size)
+      if (bfd_bwrite (relocs, rel_size, flaginfo->output_bfd) != rel_size)
 	return FALSE;
       *reloff_ptr += rel_size;
 
       /* Assert that the relocs have not run into the symbols, and
 	 that if these are the text relocs they have not run into the
 	 data relocs.  */
-      BFD_ASSERT (*reloff_ptr <= obj_sym_filepos (finfo->output_bfd)
-		  && (reloff_ptr != &finfo->treloff
+      BFD_ASSERT (*reloff_ptr <= obj_sym_filepos (flaginfo->output_bfd)
+		  && (reloff_ptr != &flaginfo->treloff
 		      || (*reloff_ptr
-			  <= obj_datasec (finfo->output_bfd)->rel_filepos)));
+			  <= obj_datasec (flaginfo->output_bfd)->rel_filepos)));
     }
 
   return TRUE;
@@ -3584,7 +3584,7 @@
 /* Link an a.out input BFD into the output file.  */
 
 static bfd_boolean
-aout_link_input_bfd (struct aout_final_link_info *finfo, bfd *input_bfd)
+aout_link_input_bfd (struct aout_final_link_info *flaginfo, bfd *input_bfd)
 {
   BFD_ASSERT (bfd_get_format (input_bfd) == bfd_object);
 
@@ -3592,16 +3592,16 @@
   if ((input_bfd->flags & DYNAMIC) != 0
       && aout_backend_info (input_bfd)->link_dynamic_object != NULL)
     return ((*aout_backend_info (input_bfd)->link_dynamic_object)
-	    (finfo->info, input_bfd));
+	    (flaginfo->info, input_bfd));
 
   /* Get the symbols.  We probably have them already, unless
-     finfo->info->keep_memory is FALSE.  */
+     flaginfo->info->keep_memory is FALSE.  */
   if (! aout_get_external_symbols (input_bfd))
     return FALSE;
 
   /* Write out the symbols and get a map of the new indices.  The map
-     is placed into finfo->symbol_map.  */
-  if (! aout_link_write_symbols (finfo, input_bfd))
+     is placed into flaginfo->symbol_map.  */
+  if (! aout_link_write_symbols (flaginfo, input_bfd))
     return FALSE;
 
   /* Relocate and write out the sections.  These functions use the
@@ -3610,17 +3610,17 @@
      link, which will normally be the case.  */
   if (obj_textsec (input_bfd)->linker_mark)
     {
-      if (! aout_link_input_section (finfo, input_bfd,
+      if (! aout_link_input_section (flaginfo, input_bfd,
 				     obj_textsec (input_bfd),
-				     &finfo->treloff,
+				     &flaginfo->treloff,
 				     exec_hdr (input_bfd)->a_trsize))
 	return FALSE;
     }
   if (obj_datasec (input_bfd)->linker_mark)
     {
-      if (! aout_link_input_section (finfo, input_bfd,
+      if (! aout_link_input_section (flaginfo, input_bfd,
 				     obj_datasec (input_bfd),
-				     &finfo->dreloff,
+				     &flaginfo->dreloff,
 				     exec_hdr (input_bfd)->a_drsize))
 	return FALSE;
     }
@@ -3628,7 +3628,7 @@
   /* If we are not keeping memory, we don't need the symbols any
      longer.  We still need them if we are keeping memory, because the
      strings in the hash table point into them.  */
-  if (! finfo->info->keep_memory)
+  if (! flaginfo->info->keep_memory)
     {
       if (! aout_link_free_symbols (input_bfd))
 	return FALSE;
@@ -3982,7 +3982,7 @@
    symbol indices into a symbol_map.  */
 
 static bfd_boolean
-aout_link_write_symbols (struct aout_final_link_info *finfo, bfd *input_bfd)
+aout_link_write_symbols (struct aout_final_link_info *flaginfo, bfd *input_bfd)
 {
   bfd *output_bfd;
   bfd_size_type sym_count;
@@ -3998,23 +3998,23 @@
   bfd_boolean pass;
   bfd_boolean skip_next;
 
-  output_bfd = finfo->output_bfd;
+  output_bfd = flaginfo->output_bfd;
   sym_count = obj_aout_external_sym_count (input_bfd);
   strings = obj_aout_external_strings (input_bfd);
-  strip = finfo->info->strip;
-  discard = finfo->info->discard;
-  outsym = finfo->output_syms;
+  strip = flaginfo->info->strip;
+  discard = flaginfo->info->discard;
+  outsym = flaginfo->output_syms;
 
   /* First write out a symbol for this object file, unless we are
      discarding such symbols.  */
   if (strip != strip_all
       && (strip != strip_some
-	  || bfd_hash_lookup (finfo->info->keep_hash, input_bfd->filename,
+	  || bfd_hash_lookup (flaginfo->info->keep_hash, input_bfd->filename,
 			      FALSE, FALSE) != NULL)
       && discard != discard_all)
     {
       H_PUT_8 (output_bfd, N_TEXT, outsym->e_type);
-      strtab_index = add_to_stringtab (output_bfd, finfo->strtab,
+      strtab_index = add_to_stringtab (output_bfd, flaginfo->strtab,
 				       input_bfd->filename, FALSE);
       if (strtab_index == (bfd_size_type) -1)
 	return FALSE;
@@ -4033,7 +4033,7 @@
   sym = obj_aout_external_syms (input_bfd);
   sym_end = sym + sym_count;
   sym_hash = obj_aout_sym_hashes (input_bfd);
-  symbol_map = finfo->symbol_map;
+  symbol_map = flaginfo->symbol_map;
   memset (symbol_map, 0, (size_t) sym_count * sizeof *symbol_map);
   for (; sym < sym_end; sym++, sym_hash++, symbol_map++)
     {
@@ -4132,7 +4132,7 @@
 		skip = TRUE;
 	      break;
 	    case strip_some:
-	      if (bfd_hash_lookup (finfo->info->keep_hash, name, FALSE, FALSE)
+	      if (bfd_hash_lookup (flaginfo->info->keep_hash, name, FALSE, FALSE)
 		  == NULL)
 		skip = TRUE;
 	      break;
@@ -4360,8 +4360,8 @@
 	      /* If we have already included a header file with the
                  same value, then replace this one with an N_EXCL
                  symbol.  */
-	      copy = ! finfo->info->keep_memory;
-	      incl_entry = aout_link_includes_lookup (&finfo->includes,
+	      copy = ! flaginfo->info->keep_memory;
+	      incl_entry = aout_link_includes_lookup (&flaginfo->includes,
 						      name, TRUE, copy);
 	      if (incl_entry == NULL)
 		return FALSE;
@@ -4372,7 +4372,7 @@
 		{
 		  /* This is the first time we have seen this header
                      file with this set of stabs strings.  */
-		  t = bfd_hash_allocate (&finfo->includes.root,
+		  t = bfd_hash_allocate (&flaginfo->includes.root,
 					 sizeof *t);
 		  if (t == NULL)
 		    return FALSE;
@@ -4419,7 +4419,7 @@
 	 write out.  */
       H_PUT_8 (output_bfd, type, outsym->e_type);
       copy = FALSE;
-      if (! finfo->info->keep_memory)
+      if (! flaginfo->info->keep_memory)
 	{
 	  /* name points into a string table which we are going to
 	     free.  If there is a hash table entry, use that string.
@@ -4429,7 +4429,7 @@
 	  else
 	    copy = TRUE;
 	}
-      strtab_index = add_to_stringtab (output_bfd, finfo->strtab,
+      strtab_index = add_to_stringtab (output_bfd, flaginfo->strtab,
 				       name, copy);
       if (strtab_index == (bfd_size_type) -1)
 	return FALSE;
@@ -4441,17 +4441,17 @@
     }
 
   /* Write out the output symbols we have just constructed.  */
-  if (outsym > finfo->output_syms)
+  if (outsym > flaginfo->output_syms)
     {
       bfd_size_type size;
 
-      if (bfd_seek (output_bfd, finfo->symoff, SEEK_SET) != 0)
+      if (bfd_seek (output_bfd, flaginfo->symoff, SEEK_SET) != 0)
 	return FALSE;
-      size = outsym - finfo->output_syms;
+      size = outsym - flaginfo->output_syms;
       size *= EXTERNAL_NLIST_SIZE;
-      if (bfd_bwrite ((void *) finfo->output_syms, size, output_bfd) != size)
+      if (bfd_bwrite ((void *) flaginfo->output_syms, size, output_bfd) != size)
 	return FALSE;
-      finfo->symoff += size;
+      flaginfo->symoff += size;
     }
 
   return TRUE;
diff --git a/bfd/pe-arm.c b/bfd/pe-arm.c
index 4c46a7a..909221f 100644
--- a/bfd/pe-arm.c
+++ b/bfd/pe-arm.c
@@ -60,6 +60,8 @@
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
 { COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".zdebug"), \
+  COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
 { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
 
diff --git a/bfd/pe-i386.c b/bfd/pe-i386.c
index 9da6413..b26243a 100644
--- a/bfd/pe-i386.c
+++ b/bfd/pe-i386.c
@@ -38,6 +38,8 @@
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
 { COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".zdebug"), \
+  COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
 { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
 
diff --git a/bfd/pe-x86_64.c b/bfd/pe-x86_64.c
index b739cc4..79d34d7 100644
--- a/bfd/pe-x86_64.c
+++ b/bfd/pe-x86_64.c
@@ -17,7 +17,7 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.
-   
+
    Written by Kai Tietz, OneVision Software GmbH&CoKg.  */
 
 #include "sysdep.h"
@@ -52,6 +52,8 @@
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
 { COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".zdebug"), \
+  COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
 { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
 
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index e506546..287e4a2 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -1,6 +1,5 @@
 /* Support for the generic parts of PE/PEI; the common executable parts.
-   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
+   Copyright 1995-2013 Free Software Foundation, Inc.
    Written by Cygnus Solutions.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -461,7 +460,7 @@
   {
     int idx;
 
-    for (idx = 0; idx < 16; idx++)
+    for (idx = 0; idx < a->NumberOfRvaAndSizes; idx++)
       {
         /* If data directory is empty, rva also should be 0.  */
 	int size =
@@ -591,9 +590,6 @@
 
   extra->NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES;
 
-  /* First null out all data directory entries.  */
-  memset (extra->DataDirectory, 0, sizeof (extra->DataDirectory));
-
   add_data_entry (abfd, extra, 0, ".edata", ib);
   add_data_entry (abfd, extra, 2, ".rsrc", ib);
   add_data_entry (abfd, extra, 3, ".pdata", ib);
@@ -796,7 +792,10 @@
   H_PUT_16 (abfd, filehdr_in->f_magic, filehdr_out->f_magic);
   H_PUT_16 (abfd, filehdr_in->f_nscns, filehdr_out->f_nscns);
 
-  H_PUT_32 (abfd, time (0), filehdr_out->f_timdat);
+  /* Only use a real timestamp if the option was chosen.  */
+  if ((pe_data (abfd)->insert_timestamp))
+    H_PUT_32 (abfd, time(0), filehdr_out->f_timdat);
+
   PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr,
 		      filehdr_out->f_symptr);
   H_PUT_32 (abfd, filehdr_in->f_nsyms, filehdr_out->f_nsyms);
@@ -2442,7 +2441,7 @@
      /* According to PECOFF sepcifications by Microsoft version 8.2
 	the TLS data directory consists of 4 pointers, followed
 	by two 4-byte integer. This implies that the total size
-	is different for 32-bit and 64-bit executables.  */ 
+	is different for 32-bit and 64-bit executables.  */
 #if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64)
       pe_data (abfd)->pe_opthdr.DataDirectory[PE_TLS_TABLE].Size = 0x18;
 #else
diff --git a/bfd/pef-traceback.h b/bfd/pef-traceback.h
index e1887e2..77ba47a 100644
--- a/bfd/pef-traceback.h
+++ b/bfd/pef-traceback.h
@@ -15,7 +15,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software 
+   along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
@@ -26,12 +26,12 @@
     sys/debug.h), which occurs, usually, one per procedure (routine). The table is marked by
     a multiple of 4 32-bit word of zeroes in the instruction space. The traceback table is
     also referred to as "procedure-end table".
- 
+
     The AIX traceback table representation on which this header is based is defined as a
     series of bit field struct specifications. Bit fields are compiler dependent! Thus,
     the definitions presented here follow the original header and the existing documentation
     (such as it is), but define the fields as BIT MASKS and other macros. The mask names,
-    however, where chosen as the original field names to give some compatibility with the 
+    however, where chosen as the original field names to give some compatibility with the
     original header and to agree with the documentation.  */
 
 #ifndef __TRACEBACK__
@@ -50,7 +50,7 @@
 #define TB_RPG 10U		/* RPG */
 #define TB_PL8 11U		/* PL8 */
 #define TB_ASM 12U		/* Asm */
- 
+
 /* Flags 1.  */
 
 #define TB_GLOBALLINK 0x80U	/* Routine is Global Linkage.  */
@@ -59,9 +59,9 @@
 #define TB_INT_PROC 0x10U	/* Internal leaf routine.  */
 #define TB_HAS_CTL 0x08U	/* Has controlled automatic storage.  */
 #define TB_TOCLESS 0X04U	/* Routine has no TOC.  */
-#define TB_FP_PRESENT 0x02U	/* Routine has floating point ops.  */ 
+#define TB_FP_PRESENT 0x02U	/* Routine has floating point ops.  */
 #define TB_LOG_ABORT 0x01U	/* fp_present && log/abort compiler opt.  */
- 
+
 /* Flags 2.  */
 
 #define TB_INT_HNDL 0x80U	/* Routine is an interrupt handler.  */
@@ -70,15 +70,15 @@
 #define TB_CL_DIS_inv 0x1CU	/* On-condition directives (see below).  */
 #define TB_SAVES_CR 0x02U	/* Routine saves the CR.  */
 #define TB_SAVES_LR 0x01U	/* Routine saves the LR.  */
-  
+
 /* cl_dis_inv "on condition" settings:  */
- 
+
 #define TB_CL_DIS_INV(x) (((x) & cl_dis_inv) >> 2U)
 
 #define TB_WALK_ONCOND 0U	/* Walk stack without restoring state.  */
 #define TB_DISCARD_ONCOND 1U	/* Walk stack and discard.  */
 #define TB_INVOKE_ONCOND 2U	/* Invoke a specific system routine.  */
- 
+
 /* Flags 3.  */
 
 #define TB_STORES_BC 0x80U	/* Routine saves frame ptr of caller.  */
@@ -87,7 +87,7 @@
 				/* (Last reg saved is ALWAYS fpr31).  */
 
 #define TB_NUM_FPR_SAVED(x) ((x) & fpr_saved)
- 
+
 /* Flags 4.  */
 
 #define TB_HAS_VEC_INFO 0x80U	/* Routine uses vectors.  */
@@ -96,12 +96,12 @@
 				/* (Last reg saved is ALWAYS gpr31).  */
 
 #define TB_NUM_GPR_SAVED(x) ((x) & gpr_saved)
- 
+
 /* Flags 5.  */
 
 #define TB_FLOATPARAMS 0xfeU	/* Number of floating point parameters.  */
 #define TB_PARAMSONSTK 0X01U	/* All parameters are on the stack.  */
- 
+
 #define TB_NUM_FLOATPARAMS(X) (((x) & floatparams) >> 1U)
 
 /* Traceback_table (fixed portion).  */
@@ -133,7 +133,7 @@
 /* Order and type encoding of parameters:  */
 struct traceback_table_fixedparams
 {
-  unsigned long paraminfo;		
+  unsigned long paraminfo;
 };
 
 /* Left-justified bit-encoding as follows:  */
@@ -169,7 +169,7 @@
 /* Controlled automatic storage info:  */
 struct traceback_table_anchors
 {
-  unsigned long ctl_info;	/* Number of controlled automatic anchors.  */ 
+  unsigned long ctl_info;	/* Number of controlled automatic anchors.  */
   long ctl_info_disp[1];	/* Array of stack displacements where each.  */
 };				/* Anchor is located (array STARTS here).  */
 
@@ -205,12 +205,12 @@
 #define TB_HAS_VARARGS 0x01U	/* Routine has a variable argument list.  */
 
 #define TB_NUM_VR_SAVED(x) (((x) & TB_VR_SAVED) >> 2U)
- 
+
   unsigned char vec_flags2;	/* Vec info bits #2:  */
 
 #define TB_VECTORPARAMS 0xfeU	/* Number of vector parameters.  */
 #define TB_VEC_PRESENT 0x01U	/* Routine uses at least one vec instr.  */
- 
+
 #define VECPARAMS(x) (((x) & TB_VECTORPARAMS) >> 1U)
 };
 
diff --git a/bfd/pef.c b/bfd/pef.c
index d4ad33a..6c52e0f 100644
--- a/bfd/pef.c
+++ b/bfd/pef.c
@@ -19,6 +19,10 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
+/* PEF (Preferred Executable Format) is the binary file format for late
+   classic Mac OS versions (before Darwin).  It is supported by both m68k
+   and PowerPc.  It is also called CFM (Code Fragment Manager).  */
+
 #include "sysdep.h"
 #include "safe-ctype.h"
 #include "pef.h"
@@ -503,10 +507,9 @@
 }
 
 int
-bfd_pef_scan (abfd, header, mdata)
-     bfd *abfd;
-     bfd_pef_header *header;
-     bfd_pef_data_struct *mdata;
+bfd_pef_scan (bfd *abfd,
+	      bfd_pef_header *header,
+	      bfd_pef_data_struct *mdata)
 {
   unsigned int i;
   enum bfd_architecture cputype;
@@ -580,34 +583,28 @@
 static const bfd_target *
 bfd_pef_object_p (bfd *abfd)
 {
-  struct bfd_preserve preserve;
   bfd_pef_header header;
+  bfd_pef_data_struct *mdata;
 
-  preserve.marker = NULL;
   if (bfd_pef_read_header (abfd, &header) != 0)
     goto wrong;
 
   if (header.tag1 != BFD_PEF_TAG1 || header.tag2 != BFD_PEF_TAG2)
     goto wrong;
 
-  preserve.marker = bfd_zalloc (abfd, sizeof (bfd_pef_data_struct));
-  if (preserve.marker == NULL
-      || !bfd_preserve_save (abfd, &preserve))
+  mdata = (bfd_pef_data_struct *) bfd_zalloc (abfd, sizeof (*mdata));
+  if (mdata == NULL)
     goto fail;
 
-  if (bfd_pef_scan (abfd, &header,
-		    (bfd_pef_data_struct *) preserve.marker) != 0)
+  if (bfd_pef_scan (abfd, &header, mdata))
     goto wrong;
 
-  bfd_preserve_finish (abfd, &preserve);
   return abfd->xvec;
 
  wrong:
   bfd_set_error (bfd_error_wrong_format);
 
  fail:
-  if (preserve.marker != NULL)
-    bfd_preserve_restore (abfd, &preserve);
   return NULL;
 }
 
@@ -1121,7 +1118,6 @@
 static const bfd_target *
 bfd_pef_xlib_object_p (bfd *abfd)
 {
-  struct bfd_preserve preserve;
   bfd_pef_xlib_header header;
 
   if (bfd_pef_xlib_read_header (abfd, &header) != 0)
@@ -1138,20 +1134,12 @@
       return NULL;
     }
 
-  if (! bfd_preserve_save (abfd, &preserve))
-    {
-      bfd_set_error (bfd_error_wrong_format);
-      return NULL;
-    }
-
   if (bfd_pef_xlib_scan (abfd, &header) != 0)
     {
-      bfd_preserve_restore (abfd, &preserve);
       bfd_set_error (bfd_error_wrong_format);
       return NULL;
     }
 
-  bfd_preserve_finish (abfd, &preserve);
   return abfd->xvec;
 }
 
diff --git a/bfd/pef.h b/bfd/pef.h
index db8d18c..d73ff37 100644
--- a/bfd/pef.h
+++ b/bfd/pef.h
@@ -19,6 +19,7 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
+#include "sysdep.h"
 #include "bfd.h"
 
 #include <stdio.h>
diff --git a/bfd/pei-x86_64.c b/bfd/pei-x86_64.c
index fdc6205..6139ca2 100644
--- a/bfd/pei-x86_64.c
+++ b/bfd/pei-x86_64.c
@@ -17,7 +17,7 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.
-   
+
    Written by Kai Tietz, OneVision Software GmbH&CoKg.  */
 
 #include "sysdep.h"
@@ -384,7 +384,7 @@
 			      : pex_regs[(unsigned int) ui.FrameRegister]);
 
       pex64_xdata_print_uwd_codes (file, &ui, pc_addr);
-      
+
       /* Now we need end of this xdata block.  */
       addr += ui.SizeOfBlock;
       if (addr < end_addr)
diff --git a/bfd/peicode.h b/bfd/peicode.h
index 5d10029..64ca092 100644
--- a/bfd/peicode.h
+++ b/bfd/peicode.h
@@ -1,6 +1,5 @@
 /* Support for the generic parts of PE/PEI, for BFD.
-   Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
+   Copyright 1995-2013 Free Software Foundation, Inc.
    Written by Cygnus Solutions.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -122,6 +121,9 @@
 }
 pe_ILF_vars;
 #endif /* COFF_IMAGE_WITH_PE */
+
+const bfd_target *coff_real_object_p
+  (bfd *, unsigned, struct internal_filehdr *, struct internal_aouthdr *);
 
 #ifndef NO_COFF_RELOCS
 static void
@@ -148,7 +150,7 @@
   H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx);
   H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type);
 
-#ifdef SWAP_OUT_RELOC_OFFSET 
+#ifdef SWAP_OUT_RELOC_OFFSET
   SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset);
 #endif
 #ifdef SWAP_OUT_RELOC_EXTRA
@@ -158,6 +160,11 @@
 }
 #endif /* not NO_COFF_RELOCS */
 
+#ifdef COFF_IMAGE_WITH_PE
+#undef FILHDR
+#define FILHDR struct external_PEI_IMAGE_hdr
+#endif
+
 static void
 coff_swap_filehdr_in (bfd * abfd, void * src, void * dst)
 {
@@ -349,7 +356,7 @@
       && pe_data (ibfd) != NULL
       && pe_data (ibfd)->real_flags & IMAGE_FILE_LARGE_ADDRESS_AWARE)
     pe_data (obfd)->real_flags |= IMAGE_FILE_LARGE_ADDRESS_AWARE;
-      
+
   if (!_bfd_XX_bfd_copy_private_bfd_data_common (ibfd, obfd))
     return FALSE;
 
@@ -545,7 +552,7 @@
   sprintf (vars->string_ptr, "%s%s", prefix, symbol_name);
 
   if (section == NULL)
-    section = (asection_ptr) & bfd_und_section;
+    section = bfd_und_section_ptr;
 
   /* Initialise the external symbol.  */
   H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table,
@@ -601,7 +608,7 @@
 
   bfd_set_section_flags (vars->abfd, sec, flags | extra_flags);
 
-  bfd_set_section_alignment (vars->abfd, sec, 2);
+  (void) bfd_set_section_alignment (vars->abfd, sec, 2);
 
   /* Check that we will not run out of space.  */
   BFD_ASSERT (vars->data + size < vars->bim->buffer + vars->bim->size);
@@ -884,14 +891,14 @@
       if (import_name_type != IMPORT_NAME)
 	{
 	  char c = symbol[0];
-	  
+
 	  /* Check that we don't remove for targets with empty
 	     USER_LABEL_PREFIX the leading underscore.  */
 	  if ((c == '_' && abfd->xvec->symbol_leading_char != 0)
 	      || c == '@' || c == '?')
 	    symbol++;
 	}
-      
+
       len = strlen (symbol);
       if (import_name_type == IMPORT_NAME_UNDECORATE)
 	{
@@ -1247,6 +1254,9 @@
   bfd_byte buffer[4];
   struct external_PEI_DOS_hdr dos_hdr;
   struct external_PEI_IMAGE_hdr image_hdr;
+  struct internal_filehdr internal_f;
+  struct internal_aouthdr internal_a;
+  file_ptr opt_hdr_size;
   file_ptr offset;
 
   /* Detect if this a Microsoft Import Library Format element.  */
@@ -1302,17 +1312,38 @@
       return NULL;
     }
 
-  /* Here is the hack.  coff_object_p wants to read filhsz bytes to
-     pick up the COFF header for PE, see "struct external_PEI_filehdr"
-     in include/coff/pe.h.  We adjust so that that will work. */
-  if (bfd_seek (abfd, (file_ptr) (offset - sizeof (dos_hdr)), SEEK_SET) != 0)
+  /* Swap file header, so that we get the location for calling
+     real_object_p.  */
+  bfd_coff_swap_filehdr_in (abfd, (PTR)&image_hdr, &internal_f);
+
+  if (! bfd_coff_bad_format_hook (abfd, &internal_f)
+      || internal_f.f_opthdr > bfd_coff_aoutsz (abfd))
     {
-      if (bfd_get_error () != bfd_error_system_call)
-	bfd_set_error (bfd_error_wrong_format);
+      bfd_set_error (bfd_error_wrong_format);
       return NULL;
     }
 
-  return coff_object_p (abfd);
+  /* Read the optional header, which has variable size.  */
+  opt_hdr_size = internal_f.f_opthdr;
+
+  if (opt_hdr_size != 0)
+    {
+      PTR opthdr;
+
+      opthdr = bfd_alloc (abfd, opt_hdr_size);
+      if (opthdr == NULL)
+	return NULL;
+      if (bfd_bread (opthdr, opt_hdr_size, abfd)
+	  != (bfd_size_type) opt_hdr_size)
+	return NULL;
+
+      bfd_coff_swap_aouthdr_in (abfd, opthdr, (PTR) & internal_a);
+    }
+
+  return coff_real_object_p (abfd, internal_f.f_nscns, &internal_f,
+                            (opt_hdr_size != 0
+                             ? &internal_a
+                             : (struct internal_aouthdr *) NULL));
 }
 
 #define coff_object_p pe_bfd_object_p
diff --git a/bfd/plugin.c b/bfd/plugin.c
index 064e273..3306607 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -1,5 +1,5 @@
 /* Plugin support for BFD.
-   Copyright 2009, 2010, 2011
+   Copyright 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -19,21 +19,57 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "config.h"
+#include "sysdep.h"
 #include "bfd.h"
 
 #if BFD_SUPPORTS_PLUGINS
 
 #include <assert.h>
+#ifdef HAVE_DLFCN_H
 #include <dlfcn.h>
+#elif defined (HAVE_WINDOWS_H)
+#include <windows.h>
+#else
+#error Unknown how to handle dynamic-load-libraries.
+#endif
 #include <stdarg.h>
 #include "plugin-api.h"
-#include "sysdep.h"
 #include "plugin.h"
 #include "libbfd.h"
 #include "libiberty.h"
 #include <dirent.h>
 
+#if !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H)
+
+#define RTLD_NOW 0      /* Dummy value.  */
+
+static void *
+dlopen (const char *file, int mode ATTRIBUTE_UNUSED)
+{
+  return LoadLibrary (file);
+}
+
+static void *
+dlsym (void *handle, const char *name)
+{
+  return GetProcAddress (handle, name);
+}
+
+static int ATTRIBUTE_UNUSED
+dlclose (void *handle)
+{
+  FreeLibrary (handle);
+  return 0;
+}
+
+static const char *
+dlerror (void)
+{
+  return "Unable to load DLL.";
+}
+
+#endif /* !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H)  */
+
 #define bfd_plugin_close_and_cleanup                  _bfd_generic_close_and_cleanup
 #define bfd_plugin_bfd_free_cached_info               _bfd_generic_bfd_free_cached_info
 #define bfd_plugin_new_section_hook                   _bfd_generic_new_section_hook
@@ -101,7 +137,7 @@
 {
   bfd *abfd = handle;
   struct plugin_data_struct *plugin_data =
-    bfd_alloc (abfd, sizeof (plugin_data_struct));;
+    bfd_alloc (abfd, sizeof (plugin_data_struct));
 
   plugin_data->nsyms = nsyms;
   plugin_data->syms = syms;
@@ -364,7 +400,7 @@
 convert_flags (const struct ld_plugin_symbol *sym)
 {
  switch (sym->def)
-   { 
+   {
    case LDPK_DEF:
    case LDPK_COMMON:
    case LDPK_UNDEF:
@@ -396,7 +432,7 @@
 
   for (i = 0; i < nsyms; i++)
     {
-      asymbol *s = bfd_alloc (abfd, sizeof (asymbol)); 
+      asymbol *s = bfd_alloc (abfd, sizeof (asymbol));
 
       BFD_ASSERT (s);
       alocation[i] = s;
diff --git a/bfd/po/BLD-POTFILES.in b/bfd/po/BLD-POTFILES.in
index 15a0174..b86829c 100644
--- a/bfd/po/BLD-POTFILES.in
+++ b/bfd/po/BLD-POTFILES.in
@@ -1,7 +1,9 @@
 bfd_stdint.h
 bfdver.h
+elf32-aarch64.c
 elf32-ia64.c
 elf32-target.h
+elf64-aarch64.c
 elf64-ia64.c
 elf64-target.h
 peigen.c
diff --git a/bfd/po/SRC-POTFILES.in b/bfd/po/SRC-POTFILES.in
index a30fa3c..b179a47 100644
--- a/bfd/po/SRC-POTFILES.in
+++ b/bfd/po/SRC-POTFILES.in
@@ -61,6 +61,7 @@
 coffswap.h
 compress.c
 corefile.c
+cpu-aarch64.c
 cpu-alpha.c
 cpu-arc.c
 cpu-arm.c
@@ -73,6 +74,7 @@
 cpu-d10v.c
 cpu-d30v.c
 cpu-dlx.c
+cpu-epiphany.c
 cpu-fr30.c
 cpu-frv.c
 cpu-h8300.c
@@ -85,6 +87,7 @@
 cpu-ia64.c
 cpu-ip2k.c
 cpu-iq2000.c
+cpu-k1om.c
 cpu-l1om.c
 cpu-lm32.c
 cpu-m10200.c
@@ -95,14 +98,18 @@
 cpu-m68hc12.c
 cpu-m68k.c
 cpu-m88k.c
+cpu-m9s12x.c
+cpu-m9s12xg.c
 cpu-mcore.c
 cpu-mep.c
+cpu-metag.c
 cpu-microblaze.c
 cpu-mips.c
 cpu-mmix.c
 cpu-moxie.c
 cpu-msp430.c
 cpu-mt.c
+cpu-nios2.c
 cpu-ns32k.c
 cpu-openrisc.c
 cpu-or32.c
@@ -110,6 +117,7 @@
 cpu-pj.c
 cpu-plugin.c
 cpu-powerpc.c
+cpu-rl78.c
 cpu-rs6000.c
 cpu-rx.c
 cpu-s390.c
@@ -125,10 +133,12 @@
 cpu-tilegx.c
 cpu-tilepro.c
 cpu-v850.c
+cpu-v850_rh850.c
 cpu-vax.c
 cpu-w65.c
 cpu-we32k.c
 cpu-xc16x.c
+cpu-xgate.c
 cpu-xstormy16.c
 cpu-xtensa.c
 cpu-z80.c
@@ -144,8 +154,10 @@
 elf-eh-frame.c
 elf-hppa.h
 elf-ifunc.c
+elf-linux-psinfo.h
 elf-m10200.c
 elf-m10300.c
+elf-nacl.c
 elf-strtab.c
 elf-vxworks.c
 elf.c
@@ -161,6 +173,7 @@
 elf32-d10v.c
 elf32-d30v.c
 elf32-dlx.c
+elf32-epiphany.c
 elf32-fr30.c
 elf32-frv.c
 elf32-gen.c
@@ -183,15 +196,18 @@
 elf32-m88k.c
 elf32-mcore.c
 elf32-mep.c
+elf32-metag.c
 elf32-microblaze.c
 elf32-mips.c
 elf32-moxie.c
 elf32-msp430.c
 elf32-mt.c
+elf32-nios2.c
 elf32-openrisc.c
 elf32-or32.c
 elf32-pj.c
 elf32-ppc.c
+elf32-rl78.c
 elf32-rx.c
 elf32-s390.c
 elf32-score.c
@@ -208,6 +224,7 @@
 elf32-v850.c
 elf32-vax.c
 elf32-xc16x.c
+elf32-xgate.c
 elf32-xstormy16.c
 elf32-xtensa.c
 elf32.c
@@ -215,6 +232,7 @@
 elf64-gen.c
 elf64-hppa.c
 elf64-hppa.h
+elf64-ia64-vms.c
 elf64-mips.c
 elf64-mmix.c
 elf64-ppc.c
@@ -228,6 +246,7 @@
 elfcore.h
 elflink.c
 elfn32-mips.c
+elfxx-aarch64.c
 elfxx-ia64.c
 elfxx-mips.c
 elfxx-sparc.c
diff --git a/bfd/po/bfd.pot b/bfd/po/bfd.pot
index 38ce82f..b7d5a1e 100644
--- a/bfd/po/bfd.pot
+++ b/bfd/po/bfd.pot
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2011-06-02 14:25+0100\n"
+"POT-Creation-Date: 2011-10-25 11:58+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <[email protected]>\n"
@@ -45,28 +45,28 @@
 "%s: can not represent section for symbol `%s' in a.out object file format"
 msgstr ""
 
-#: aoutx.h:1579 vms-alpha.c:7668
+#: aoutx.h:1579 vms-alpha.c:7671
 msgid "*unknown*"
 msgstr ""
 
-#: aoutx.h:4017 aoutx.h:4343
+#: aoutx.h:4018 aoutx.h:4344
 msgid "%P: %B: unexpected relocation type\n"
 msgstr ""
 
-#: aoutx.h:5374
+#: aoutx.h:5375
 #, c-format
 msgid "%s: relocatable link from %s to %s not supported"
 msgstr ""
 
-#: archive.c:2194
+#: archive.c:2203
 msgid "Warning: writing archive was slow: rewriting timestamp\n"
 msgstr ""
 
-#: archive.c:2482
+#: archive.c:2491
 msgid "Reading archive file mod timestamp"
 msgstr ""
 
-#: archive.c:2506
+#: archive.c:2515
 msgid "Writing updated armap timestamp"
 msgstr ""
 
@@ -189,13 +189,13 @@
 msgid "Warning: Writing section `%s' to huge (ie negative) file offset 0x%lx."
 msgstr ""
 
-#: bout.c:1146 elf-m10300.c:2075 elf32-avr.c:1654 elf32-frv.c:5731
-#: elfxx-sparc.c:2796 reloc.c:5677 reloc16.c:162 elf32-ia64.c:360
+#: bout.c:1146 elf-m10300.c:2063 elf32-avr.c:1654 elf32-frv.c:5734
+#: elfxx-sparc.c:2802 reloc.c:6115 reloc16.c:162 elf32-ia64.c:360
 #: elf64-ia64.c:360
 msgid "%P%F: --relax and -r may not be used together\n"
 msgstr ""
 
-#: cache.c:226
+#: cache.c:227
 msgid "reopening %B: %s\n"
 msgstr ""
 
@@ -225,8 +225,8 @@
 msgid "%B: unsupported relocation: ALPHA_R_GPRELLOW"
 msgstr ""
 
-#: coff-alpha.c:1575 elf32-m32r.c:2493 elf64-alpha.c:4079 elf64-alpha.c:4228
-#: elf32-ia64.c:3845 elf64-ia64.c:3845
+#: coff-alpha.c:1575 elf32-m32r.c:2484 elf64-alpha.c:4074 elf64-alpha.c:4224
+#: elf32-ia64.c:3839 elf64-ia64.c:3839
 msgid "%B: unknown relocation type %d"
 msgstr ""
 
@@ -240,7 +240,7 @@
 msgid "%B: unable to find ARM glue '%s' for `%s'"
 msgstr ""
 
-#: coff-arm.c:1369 elf32-arm.c:6980
+#: coff-arm.c:1369 elf32-arm.c:7023
 #, c-format
 msgid ""
 "%B(%s): warning: interworking not enabled.\n"
@@ -268,14 +268,14 @@
 msgid "error: %B is compiled for APCS-%d, whereas %B is compiled for APCS-%d"
 msgstr ""
 
-#: coff-arm.c:2226 elf32-arm.c:15580
+#: coff-arm.c:2226 elf32-arm.c:15621
 #, c-format
 msgid ""
 "error: %B passes floats in float registers, whereas %B passes them in "
 "integer registers"
 msgstr ""
 
-#: coff-arm.c:2229 elf32-arm.c:15584
+#: coff-arm.c:2229 elf32-arm.c:15625
 #, c-format
 msgid ""
 "error: %B passes floats in integer registers, whereas %B passes them in "
@@ -296,12 +296,12 @@
 "position independent"
 msgstr ""
 
-#: coff-arm.c:2274 elf32-arm.c:15649
+#: coff-arm.c:2274 elf32-arm.c:15690
 #, c-format
 msgid "Warning: %B supports interworking, whereas %B does not"
 msgstr ""
 
-#: coff-arm.c:2277 elf32-arm.c:15655
+#: coff-arm.c:2277 elf32-arm.c:15696
 #, c-format
 msgid "Warning: %B does not support interworking, whereas %B does"
 msgstr ""
@@ -311,7 +311,7 @@
 msgid "private flags = %x:"
 msgstr ""
 
-#: coff-arm.c:2309 elf32-arm.c:11752
+#: coff-arm.c:2309 elf32-arm.c:11806
 #, c-format
 msgid " [floats passed in float registers]"
 msgstr ""
@@ -321,7 +321,7 @@
 msgid " [floats passed in integer registers]"
 msgstr ""
 
-#: coff-arm.c:2314 elf32-arm.c:11755
+#: coff-arm.c:2314 elf32-arm.c:11809
 #, c-format
 msgid " [position independent]"
 msgstr ""
@@ -346,14 +346,14 @@
 msgid " [interworking not supported]"
 msgstr ""
 
-#: coff-arm.c:2370 elf32-arm.c:10787
+#: coff-arm.c:2370 elf32-arm.c:10841
 #, c-format
 msgid ""
 "Warning: Not setting interworking flag of %B since it has already been "
 "specified as non-interworking"
 msgstr ""
 
-#: coff-arm.c:2374 elf32-arm.c:10791
+#: coff-arm.c:2374 elf32-arm.c:10845
 #, c-format
 msgid "Warning: Clearing the interworking flag of %B due to outside request"
 msgstr ""
@@ -368,20 +368,20 @@
 msgid "relocation `%s' not yet implemented"
 msgstr ""
 
-#: coff-i860.c:605 coff-tic54x.c:398 coffcode.h:5192
+#: coff-i860.c:605 coff-tic54x.c:398 coffcode.h:5198
 msgid "%B: warning: illegal symbol index %ld in relocs"
 msgstr ""
 
-#: coff-i960.c:143 coff-i960.c:506
+#: coff-i960.c:144 coff-i960.c:507
 msgid "uncertain calling convention for non-COFF symbol"
 msgstr ""
 
-#: coff-m68k.c:506 elf32-bfin.c:5689 elf32-cr16.c:2897 elf32-m68k.c:4677
+#: coff-m68k.c:506 elf32-bfin.c:5690 elf32-cr16.c:2897 elf32-m68k.c:4677
 msgid "unsupported reloc type"
 msgstr ""
 
-#: coff-mips.c:688 elf32-mips.c:1014 elf32-score.c:430 elf32-score7.c:330
-#: elf64-mips.c:2019 elfn32-mips.c:1832
+#: coff-mips.c:688 elf32-mips.c:1516 elf32-score.c:431 elf32-score7.c:330
+#: elf64-mips.c:2618 elfn32-mips.c:2431
 msgid "GP relative relocation when _gp not defined"
 msgstr ""
 
@@ -389,17 +389,17 @@
 msgid "Unrecognized reloc"
 msgstr ""
 
-#: coff-rs6000.c:2676
+#: coff-rs6000.c:2720
 #, c-format
 msgid "%s: unsupported relocation type 0x%02x"
 msgstr ""
 
-#: coff-rs6000.c:2761
+#: coff-rs6000.c:2805
 #, c-format
 msgid "%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"
 msgstr ""
 
-#: coff-rs6000.c:3512 coff64-rs6000.c:2111
+#: coff-rs6000.c:3556 coff64-rs6000.c:2111
 msgid "%B: symbol `%s' has unrecognized smclas %d"
 msgstr ""
 
@@ -423,76 +423,80 @@
 msgid "ignoring reloc %s\n"
 msgstr ""
 
-#: coffcode.h:991
+#: coffcode.h:997
 msgid "%B: warning: COMDAT symbol '%s' does not match section name '%s'"
 msgstr ""
 
 #. Generate a warning message rather using the 'unhandled'
 #. variable as this will allow some .sys files generate by
 #. other toolchains to be processed.  See bugzilla issue 196.
-#: coffcode.h:1215
+#: coffcode.h:1221
 msgid ""
 "%B: Warning: Ignoring section flag IMAGE_SCN_MEM_NOT_PAGED in section %s"
 msgstr ""
 
-#: coffcode.h:1282
+#: coffcode.h:1288
 msgid "%B (%s): Section flag %s (0x%x) ignored"
 msgstr ""
 
-#: coffcode.h:2424
+#: coffcode.h:2430
 #, c-format
 msgid "Unrecognized TI COFF target id '0x%x'"
 msgstr ""
 
-#: coffcode.h:2738
+#: coffcode.h:2744
 msgid "%B: reloc against a non-existant symbol index: %ld"
 msgstr ""
 
-#: coffcode.h:3296
+#: coffcode.h:3302
 msgid "%B: too many sections (%d)"
 msgstr ""
 
-#: coffcode.h:3712
+#: coffcode.h:3718
 msgid "%B: section %s: string table overflow at offset %ld"
 msgstr ""
 
-#: coffcode.h:4517
+#: coffcode.h:4523
 msgid "%B: warning: line number table read failed"
 msgstr ""
 
-#: coffcode.h:4547
+#: coffcode.h:4553
 msgid "%B: warning: illegal symbol index %ld in line numbers"
 msgstr ""
 
-#: coffcode.h:4561
+#: coffcode.h:4567
 msgid "%B: warning: duplicate line number information for `%s'"
 msgstr ""
 
-#: coffcode.h:4961
+#: coffcode.h:4967
 msgid "%B: Unrecognized storage class %d for %s symbol `%s'"
 msgstr ""
 
-#: coffcode.h:5087
+#: coffcode.h:5093
 msgid "warning: %B: local symbol `%s' has no section"
 msgstr ""
 
-#: coffcode.h:5231
+#: coffcode.h:5237
 msgid "%B: illegal relocation type %d at address 0x%lx"
 msgstr ""
 
-#: coffgen.c:1578
+#: coffgen.c:1595
 msgid "%B: bad string table size %lu"
 msgstr ""
 
-#: cofflink.c:533 elflink.c:4353
+#: coffgen.c:2500 elflink.c:12689 linker.c:3122
+msgid "%F%P: already_linked_table: %E\n"
+msgstr ""
+
+#: cofflink.c:533 elflink.c:4323
 msgid "Warning: type of symbol `%s' changed from %d to %d in %B"
 msgstr ""
 
-#: cofflink.c:2330
+#: cofflink.c:2329
 msgid "%B: relocs in section `%A', but it has no contents"
 msgstr ""
 
-#: cofflink.c:2392 elflink.c:9554
+#: cofflink.c:2391 elflink.c:9545
 msgid ""
 "%X`%s' referenced in section `%A' of %B: defined in discarded section `%A' "
 "of %B\n"
@@ -517,117 +521,117 @@
 msgid "warning: unable to update contents of %s section in %s"
 msgstr ""
 
-#: dwarf2.c:490
+#: dwarf2.c:496
 #, c-format
 msgid "Dwarf Error: Can't find %s section."
 msgstr ""
 
-#: dwarf2.c:518
+#: dwarf2.c:525
 #, c-format
 msgid "Dwarf Error: Offset (%lu) greater than or equal to %s size (%lu)."
 msgstr ""
 
-#: dwarf2.c:940
+#: dwarf2.c:949
 #, c-format
 msgid "Dwarf Error: Invalid or unhandled FORM value: %u."
 msgstr ""
 
-#: dwarf2.c:1191
+#: dwarf2.c:1200
 msgid "Dwarf Error: mangled line number section (bad file number)."
 msgstr ""
 
-#: dwarf2.c:1443
+#: dwarf2.c:1453
 #, c-format
 msgid "Dwarf Error: Unhandled .debug_line version %d."
 msgstr ""
 
-#: dwarf2.c:1465
+#: dwarf2.c:1475
 msgid "Dwarf Error: Invalid maximum operations per instruction."
 msgstr ""
 
-#: dwarf2.c:1652
+#: dwarf2.c:1662
 msgid "Dwarf Error: mangled line number section."
 msgstr ""
 
-#: dwarf2.c:1978 dwarf2.c:2098 dwarf2.c:2383
+#: dwarf2.c:1989 dwarf2.c:2109 dwarf2.c:2394
 #, c-format
 msgid "Dwarf Error: Could not find abbrev number %u."
 msgstr ""
 
-#: dwarf2.c:2344
+#: dwarf2.c:2355
 #, c-format
 msgid ""
 "Dwarf Error: found dwarf version '%u', this reader only handles version 2, 3 "
 "and 4 information."
 msgstr ""
 
-#: dwarf2.c:2351
+#: dwarf2.c:2362
 #, c-format
 msgid ""
 "Dwarf Error: found address size '%u', this reader can not handle sizes "
 "greater than '%u'."
 msgstr ""
 
-#: dwarf2.c:2374
+#: dwarf2.c:2385
 #, c-format
 msgid "Dwarf Error: Bad abbrev number: %u."
 msgstr ""
 
-#: ecoff.c:1237
+#: ecoff.c:1239
 #, c-format
 msgid "Unknown basic type %d"
 msgstr ""
 
-#: ecoff.c:1494
+#: ecoff.c:1496
 #, c-format
 msgid ""
 "\n"
 "      End+1 symbol: %ld"
 msgstr ""
 
-#: ecoff.c:1501 ecoff.c:1504
+#: ecoff.c:1503 ecoff.c:1506
 #, c-format
 msgid ""
 "\n"
 "      First symbol: %ld"
 msgstr ""
 
-#: ecoff.c:1516
+#: ecoff.c:1518
 #, c-format
 msgid ""
 "\n"
 "      End+1 symbol: %-7ld   Type:  %s"
 msgstr ""
 
-#: ecoff.c:1523
+#: ecoff.c:1525
 #, c-format
 msgid ""
 "\n"
 "      Local symbol: %ld"
 msgstr ""
 
-#: ecoff.c:1531
+#: ecoff.c:1533
 #, c-format
 msgid ""
 "\n"
 "      struct; End+1 symbol: %ld"
 msgstr ""
 
-#: ecoff.c:1536
+#: ecoff.c:1538
 #, c-format
 msgid ""
 "\n"
 "      union; End+1 symbol: %ld"
 msgstr ""
 
-#: ecoff.c:1541
+#: ecoff.c:1543
 #, c-format
 msgid ""
 "\n"
 "      enum; End+1 symbol: %ld"
 msgstr ""
 
-#: ecoff.c:1547
+#: ecoff.c:1549
 #, c-format
 msgid ""
 "\n"
@@ -644,16 +648,16 @@
 msgid "error: %B: Object tag '%d, %s' is incompatible with tag '%d, %s'"
 msgstr ""
 
-#: elf-eh-frame.c:913
+#: elf-eh-frame.c:917
 msgid "%P: error in %B(%A); no .eh_frame_hdr table will be created.\n"
 msgstr ""
 
-#: elf-eh-frame.c:1165
+#: elf-eh-frame.c:1189
 msgid ""
 "%P: fde encoding in %B(%A) prevents .eh_frame_hdr table being created.\n"
 msgstr ""
 
-#: elf-eh-frame.c:1583
+#: elf-eh-frame.c:1605
 msgid "%P: DW_EH_PE_datarel unspecified for this architecture.\n"
 msgstr ""
 
@@ -664,74 +668,73 @@
 "pie\n"
 msgstr ""
 
-#: elf-m10200.c:450 elf-m10300.c:1571 elf32-avr.c:1221 elf32-bfin.c:3209
-#: elf32-cr16.c:1482 elf32-cr16c.c:780 elf32-cris.c:2077 elf32-crx.c:922
-#: elf32-d10v.c:509 elf32-fr30.c:609 elf32-frv.c:4102 elf32-h8300.c:509
-#: elf32-i860.c:1211 elf32-ip2k.c:1468 elf32-iq2000.c:684 elf32-lm32.c:1168
-#: elf32-m32c.c:553 elf32-m32r.c:3111 elf32-m68hc1x.c:1138 elf32-mep.c:535
-#: elf32-microblaze.c:1231 elf32-moxie.c:282 elf32-msp430.c:486 elf32-mt.c:395
-#: elf32-openrisc.c:404 elf32-score.c:2731 elf32-score7.c:2540
-#: elf32-spu.c:5042 elf32-v850.c:2143 elf32-xstormy16.c:941 elf64-mmix.c:1522
+#: elf-m10200.c:450 elf-m10300.c:1563 elf32-avr.c:1221 elf32-bfin.c:3213
+#: elf32-cr16.c:1482 elf32-cr16c.c:780 elf32-cris.c:2081 elf32-crx.c:922
+#: elf32-d10v.c:509 elf32-epiphany.c:556 elf32-fr30.c:609 elf32-frv.c:4105
+#: elf32-h8300.c:509 elf32-i860.c:1211 elf32-ip2k.c:1468 elf32-iq2000.c:684
+#: elf32-lm32.c:1168 elf32-m32c.c:553 elf32-m32r.c:3106 elf32-m68hc1x.c:1138
+#: elf32-mep.c:535 elf32-microblaze.c:1231 elf32-moxie.c:282
+#: elf32-msp430.c:486 elf32-mt.c:395 elf32-openrisc.c:404 elf32-score.c:2729
+#: elf32-score7.c:2537 elf32-spu.c:5044 elf32-tilepro.c:3214 elf32-v850.c:2143
+#: elf32-xstormy16.c:935 elf64-mmix.c:1590 elfxx-tilegx.c:3577
 msgid "internal error: out of range error"
 msgstr ""
 
-#: elf-m10200.c:454 elf-m10300.c:1575 elf32-avr.c:1225 elf32-bfin.c:3213
-#: elf32-cr16.c:1486 elf32-cr16c.c:784 elf32-cris.c:2081 elf32-crx.c:926
-#: elf32-d10v.c:513 elf32-fr30.c:613 elf32-frv.c:4106 elf32-h8300.c:513
+#: elf-m10200.c:454 elf-m10300.c:1567 elf32-avr.c:1225 elf32-bfin.c:3217
+#: elf32-cr16.c:1486 elf32-cr16c.c:784 elf32-cris.c:2085 elf32-crx.c:926
+#: elf32-d10v.c:513 elf32-fr30.c:613 elf32-frv.c:4109 elf32-h8300.c:513
 #: elf32-i860.c:1215 elf32-iq2000.c:688 elf32-lm32.c:1172 elf32-m32c.c:557
-#: elf32-m32r.c:3115 elf32-m68hc1x.c:1142 elf32-mep.c:539
+#: elf32-m32r.c:3110 elf32-m68hc1x.c:1142 elf32-mep.c:539
 #: elf32-microblaze.c:1235 elf32-moxie.c:286 elf32-msp430.c:490
-#: elf32-openrisc.c:408 elf32-score.c:2735 elf32-score7.c:2544
-#: elf32-spu.c:5046 elf32-v850.c:2147 elf32-xstormy16.c:945 elf64-mmix.c:1526
-#: elfxx-mips.c:9193
+#: elf32-openrisc.c:408 elf32-score.c:2733 elf32-score7.c:2541
+#: elf32-spu.c:5048 elf32-tilepro.c:3218 elf32-v850.c:2147
+#: elf32-xstormy16.c:939 elf64-mmix.c:1594 elfxx-mips.c:9465
+#: elfxx-tilegx.c:3581
 msgid "internal error: unsupported relocation error"
 msgstr ""
 
 #: elf-m10200.c:458 elf32-cr16.c:1490 elf32-cr16c.c:788 elf32-crx.c:930
-#: elf32-d10v.c:517 elf32-h8300.c:517 elf32-lm32.c:1176 elf32-m32r.c:3119
-#: elf32-m68hc1x.c:1146 elf32-microblaze.c:1239 elf32-score.c:2739
-#: elf32-score7.c:2548 elf32-spu.c:5050
+#: elf32-d10v.c:517 elf32-h8300.c:517 elf32-lm32.c:1176 elf32-m32r.c:3114
+#: elf32-m68hc1x.c:1146 elf32-microblaze.c:1239 elf32-score.c:2737
+#: elf32-score7.c:2545 elf32-spu.c:5052
 msgid "internal error: dangerous error"
 msgstr ""
 
-#: elf-m10200.c:462 elf-m10300.c:1591 elf32-avr.c:1233 elf32-bfin.c:3221
-#: elf32-cr16.c:1494 elf32-cr16c.c:792 elf32-cris.c:2089 elf32-crx.c:934
-#: elf32-d10v.c:521 elf32-fr30.c:621 elf32-frv.c:4114 elf32-h8300.c:521
-#: elf32-i860.c:1223 elf32-ip2k.c:1483 elf32-iq2000.c:696 elf32-lm32.c:1180
-#: elf32-m32c.c:565 elf32-m32r.c:3123 elf32-m68hc1x.c:1150 elf32-mep.c:547
-#: elf32-microblaze.c:1243 elf32-moxie.c:294 elf32-msp430.c:498 elf32-mt.c:403
-#: elf32-openrisc.c:416 elf32-score.c:2748 elf32-score7.c:2552
-#: elf32-spu.c:5054 elf32-v850.c:2167 elf32-xstormy16.c:953 elf64-mmix.c:1534
+#: elf-m10200.c:462 elf-m10300.c:1580 elf32-avr.c:1233 elf32-bfin.c:3225
+#: elf32-cr16.c:1494 elf32-cr16c.c:792 elf32-cris.c:2093 elf32-crx.c:934
+#: elf32-d10v.c:521 elf32-epiphany.c:571 elf32-fr30.c:621 elf32-frv.c:4117
+#: elf32-h8300.c:521 elf32-i860.c:1223 elf32-ip2k.c:1483 elf32-iq2000.c:696
+#: elf32-lm32.c:1180 elf32-m32c.c:565 elf32-m32r.c:3118 elf32-m68hc1x.c:1150
+#: elf32-mep.c:547 elf32-microblaze.c:1243 elf32-moxie.c:294
+#: elf32-msp430.c:498 elf32-mt.c:403 elf32-openrisc.c:416 elf32-score.c:2746
+#: elf32-score7.c:2549 elf32-spu.c:5056 elf32-tilepro.c:3226 elf32-v850.c:2167
+#: elf32-xstormy16.c:947 elf64-mmix.c:1602 elfxx-tilegx.c:3589
 msgid "internal error: unknown error"
 msgstr ""
 
-#: elf-m10300.c:1515 elf32-arm.c:10365 elf32-i386.c:4107 elf32-m32r.c:2604
-#: elf32-m68k.c:4156 elf32-s390.c:3010 elf32-sh.c:4223 elf32-xtensa.c:3067
-#: elf64-s390.c:2985 elf64-sh64.c:1636 elf64-x86-64.c:3882 elfxx-sparc.c:3807
+#: elf-m10300.c:1507 elf32-arm.c:10419 elf32-i386.c:4264 elf32-m32r.c:2599
+#: elf32-m68k.c:4156 elf32-s390.c:3003 elf32-sh.c:4218 elf32-tilepro.c:3117
+#: elf32-xtensa.c:3066 elf64-s390.c:2978 elf64-sh64.c:1640 elf64-x86-64.c:4110
+#: elfxx-sparc.c:3835 elfxx-tilegx.c:3500
 msgid "%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"
 msgstr ""
 
-#: elf-m10300.c:1580
+#: elf-m10300.c:1572
 msgid ""
 "error: inappropriate relocation type for shared library (did you forget -"
 "fpic?)"
 msgstr ""
 
-#: elf-m10300.c:1583
-msgid ""
-"%B: error: taking the address of protected function '%s' cannot be done when "
-"making a shared library"
-msgstr ""
-
-#: elf-m10300.c:1586
+#: elf-m10300.c:1575
 msgid "internal error: suspicious relocation type used in shared library"
 msgstr ""
 
-#: elf-m10300.c:4384 elf32-arm.c:12743 elf32-cr16.c:2451 elf32-cris.c:3044
-#: elf32-hppa.c:1894 elf32-i370.c:503 elf32-i386.c:2043 elf32-lm32.c:1868
-#: elf32-m32r.c:1927 elf32-m68k.c:3252 elf32-s390.c:1652 elf32-sh.c:2931
-#: elf32-tic6x.c:2160 elf32-vax.c:1040 elf64-s390.c:1635 elf64-sh64.c:3377
-#: elf64-x86-64.c:1985 elfxx-sparc.c:2104
+#: elf-m10300.c:4372 elf32-arm.c:12800 elf32-cr16.c:2451 elf32-cris.c:3057
+#: elf32-hppa.c:1894 elf32-i370.c:503 elf32-i386.c:2182 elf32-lm32.c:1868
+#: elf32-m32r.c:1927 elf32-m68k.c:3253 elf32-s390.c:1652 elf32-sh.c:2931
+#: elf32-tic6x.c:2162 elf32-tilepro.c:1940 elf32-vax.c:1041 elf64-s390.c:1635
+#: elf64-sh64.c:3381 elf64-x86-64.c:2176 elfxx-sparc.c:2119
+#: elfxx-tilegx.c:2261
 #, c-format
 msgid "dynamic variable `%s' is zero size"
 msgstr ""
@@ -756,7 +759,7 @@
 msgid "%B: no group info for section %A"
 msgstr ""
 
-#: elf.c:737 elf.c:3121 elflink.c:10144
+#: elf.c:737 elf.c:3121 elflink.c:10135
 msgid "%B: warning: sh_link not set for section `%A'"
 msgstr ""
 
@@ -857,421 +860,423 @@
 msgid "%B: section %A lma %#lx adjusted to %#lx"
 msgstr ""
 
-#: elf.c:4774
+#: elf.c:4776
 msgid "%B: section `%A' can't be allocated in segment %d"
 msgstr ""
 
-#: elf.c:4822
+#: elf.c:4824
 msgid "%B: warning: allocated section `%s' not in segment"
 msgstr ""
 
-#: elf.c:5322
+#: elf.c:5324
 msgid "%B: symbol `%s' required but not present"
 msgstr ""
 
-#: elf.c:5660
+#: elf.c:5662
 msgid "%B: warning: Empty loadable segment detected, is this intentional ?\n"
 msgstr ""
 
-#: elf.c:6688
+#: elf.c:6692
 #, c-format
 msgid ""
 "Unable to find equivalent output section for symbol '%s' from section '%s'"
 msgstr ""
 
-#: elf.c:7684
+#: elf.c:7692
 msgid "%B: unsupported relocation type %s"
 msgstr ""
 
-#: elf32-arm.c:3590
+#: elf32-arm.c:3617
 msgid ""
 "%B(%s): warning: interworking not enabled.\n"
 "  first occurrence: %B: Thumb call to ARM"
 msgstr ""
 
-#: elf32-arm.c:3637
+#: elf32-arm.c:3664
 msgid ""
 "%B(%s): warning: interworking not enabled.\n"
 "  first occurrence: %B: ARM call to Thumb"
 msgstr ""
 
-#: elf32-arm.c:3849 elf32-arm.c:5286
+#: elf32-arm.c:3878 elf32-arm.c:5315
 #, c-format
 msgid "%s: cannot create stub entry %s"
 msgstr ""
 
-#: elf32-arm.c:5402
+#: elf32-arm.c:5431
 #, c-format
 msgid "unable to find THUMB glue '%s' for '%s'"
 msgstr ""
 
-#: elf32-arm.c:5438
+#: elf32-arm.c:5467
 #, c-format
 msgid "unable to find ARM glue '%s' for '%s'"
 msgstr ""
 
-#: elf32-arm.c:5964
+#: elf32-arm.c:6005
 msgid "%B: BE8 images only valid in big-endian mode."
 msgstr ""
 
 #. Give a warning, but do as the user requests anyway.
-#: elf32-arm.c:6194
+#: elf32-arm.c:6235
 msgid ""
 "%B: warning: selected VFP11 erratum workaround is not necessary for target "
 "architecture"
 msgstr ""
 
-#: elf32-arm.c:6738 elf32-arm.c:6758
+#: elf32-arm.c:6779 elf32-arm.c:6799
 msgid "%B: unable to find VFP11 veneer `%s'"
 msgstr ""
 
-#: elf32-arm.c:6806
+#: elf32-arm.c:6848
 #, c-format
 msgid "Invalid TARGET2 relocation type '%s'."
 msgstr ""
 
-#: elf32-arm.c:6890
+#: elf32-arm.c:6933
 msgid ""
 "%B(%s): warning: interworking not enabled.\n"
 "  first occurrence: %B: thumb call to arm"
 msgstr ""
 
-#: elf32-arm.c:7674
+#: elf32-arm.c:7717
 msgid "%B(%A+0x%lx):unexpected Thumb instruction '0x%x' in TLS trampoline"
 msgstr ""
 
-#: elf32-arm.c:7713
+#: elf32-arm.c:7756
 msgid "%B(%A+0x%lx):unexpected ARM instruction '0x%x' in TLS trampoline"
 msgstr ""
 
-#: elf32-arm.c:8166
+#: elf32-arm.c:8209
 msgid "\\%B: Warning: Arm BLX instruction targets Arm function '%s'."
 msgstr ""
 
-#: elf32-arm.c:8575
+#: elf32-arm.c:8622
 msgid "%B: Warning: Thumb BLX instruction targets thumb function '%s'."
 msgstr ""
 
-#: elf32-arm.c:9408
+#: elf32-arm.c:9460
 msgid ""
 "%B(%A+0x%lx):unexpected Thumb instruction '0x%x' referenced by TLS_GOTDESC"
 msgstr ""
 
-#: elf32-arm.c:9431
+#: elf32-arm.c:9483
 msgid ""
 "%B(%A+0x%lx):unexpected ARM instruction '0x%x' referenced by TLS_GOTDESC"
 msgstr ""
 
-#: elf32-arm.c:9460
+#: elf32-arm.c:9512
 msgid "%B(%A+0x%lx): R_ARM_TLS_LE32 relocation not permitted in shared object"
 msgstr ""
 
-#: elf32-arm.c:9675
+#: elf32-arm.c:9727
 msgid ""
 "%B(%A+0x%lx): Only ADD or SUB instructions are allowed for ALU group "
 "relocations"
 msgstr ""
 
-#: elf32-arm.c:9715 elf32-arm.c:9802 elf32-arm.c:9885 elf32-arm.c:9970
+#: elf32-arm.c:9767 elf32-arm.c:9854 elf32-arm.c:9937 elf32-arm.c:10022
 msgid "%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"
 msgstr ""
 
-#: elf32-arm.c:10209 elf32-sh.c:4112 elf64-sh64.c:1544
+#: elf32-arm.c:10261 elf32-sh.c:4103 elf64-sh64.c:1544
 msgid "%B(%A+0x%lx): %s relocation against SEC_MERGE section"
 msgstr ""
 
-#: elf32-arm.c:10320 elf32-m68k.c:4191 elf32-xtensa.c:2805
+#: elf32-arm.c:10372 elf32-m68k.c:4191 elf32-xtensa.c:2802
 msgid "%B(%A+0x%lx): %s used with TLS symbol %s"
 msgstr ""
 
-#: elf32-arm.c:10321 elf32-m68k.c:4192 elf32-xtensa.c:2806
+#: elf32-arm.c:10373 elf32-m68k.c:4192 elf32-xtensa.c:2803
 msgid "%B(%A+0x%lx): %s used with non-TLS symbol %s"
 msgstr ""
 
-#: elf32-arm.c:10399 elf32-tic6x.c:2751
+#: elf32-arm.c:10453 elf32-tic6x.c:2753
 msgid "out of range"
 msgstr ""
 
-#: elf32-arm.c:10403 elf32-tic6x.c:2755
+#: elf32-arm.c:10457 elf32-tic6x.c:2757
 msgid "unsupported relocation"
 msgstr ""
 
-#: elf32-arm.c:10411 elf32-tic6x.c:2763
+#: elf32-arm.c:10465 elf32-tic6x.c:2765
 msgid "unknown error"
 msgstr ""
 
-#: elf32-arm.c:10836
+#: elf32-arm.c:10890
 msgid ""
 "Warning: Clearing the interworking flag of %B because non-interworking code "
 "in %B has been linked with it"
 msgstr ""
 
-#: elf32-arm.c:10930
+#: elf32-arm.c:10984
 msgid "%B: Unknown mandatory EABI object attribute %d"
 msgstr ""
 
-#: elf32-arm.c:10938
+#: elf32-arm.c:10992
 msgid "Warning: %B: Unknown EABI object attribute %d"
 msgstr ""
 
-#: elf32-arm.c:11119
+#: elf32-arm.c:11173
 msgid "error: %B: Unknown CPU architecture"
 msgstr ""
 
-#: elf32-arm.c:11157
+#: elf32-arm.c:11211
 msgid "error: %B: Conflicting CPU architectures %d/%d"
 msgstr ""
 
-#: elf32-arm.c:11206
+#: elf32-arm.c:11260
 msgid ""
 "Error: %B has both the current and legacy Tag_MPextension_use attributes"
 msgstr ""
 
-#: elf32-arm.c:11231
+#: elf32-arm.c:11285
 msgid "error: %B uses VFP register arguments, %B does not"
 msgstr ""
 
-#: elf32-arm.c:11376
+#: elf32-arm.c:11430
 msgid "error: %B: unable to merge virtualization attributes with %B"
 msgstr ""
 
-#: elf32-arm.c:11402
+#: elf32-arm.c:11456
 msgid "error: %B: Conflicting architecture profiles %c/%c"
 msgstr ""
 
-#: elf32-arm.c:11503
+#: elf32-arm.c:11557
 msgid "Warning: %B: Conflicting platform configuration"
 msgstr ""
 
-#: elf32-arm.c:11512
+#: elf32-arm.c:11566
 msgid "error: %B: Conflicting use of R9"
 msgstr ""
 
-#: elf32-arm.c:11524
+#: elf32-arm.c:11578
 msgid "error: %B: SB relative addressing conflicts with use of R9"
 msgstr ""
 
-#: elf32-arm.c:11537
+#: elf32-arm.c:11591
 msgid ""
 "warning: %B uses %u-byte wchar_t yet the output is to use %u-byte wchar_t; "
 "use of wchar_t values across objects may fail"
 msgstr ""
 
-#: elf32-arm.c:11568
+#: elf32-arm.c:11622
 msgid ""
 "warning: %B uses %s enums yet the output is to use %s enums; use of enum "
 "values across objects may fail"
 msgstr ""
 
-#: elf32-arm.c:11580
+#: elf32-arm.c:11634
 msgid "error: %B uses iWMMXt register arguments, %B does not"
 msgstr ""
 
-#: elf32-arm.c:11597
+#: elf32-arm.c:11651
 msgid "error: fp16 format mismatch between %B and %B"
 msgstr ""
 
-#: elf32-arm.c:11621
+#: elf32-arm.c:11675
 msgid "DIV usage mismatch between %B and %B"
 msgstr ""
 
-#: elf32-arm.c:11640
+#: elf32-arm.c:11694
 msgid "%B has has both the current and legacy Tag_MPextension_use attributes"
 msgstr ""
 
 #. Ignore init flag - it may not be set, despite the flags field
 #. containing valid data.
 #. Ignore init flag - it may not be set, despite the flags field containing valid data.
-#: elf32-arm.c:11728 elf32-bfin.c:5075 elf32-cris.c:4162 elf32-m68hc1x.c:1282
-#: elf32-m68k.c:1235 elf32-score.c:3996 elf32-score7.c:3803 elf32-vax.c:528
-#: elfxx-mips.c:12857
+#: elf32-arm.c:11782 elf32-bfin.c:5079 elf32-cris.c:4169 elf32-m68hc1x.c:1282
+#: elf32-m68k.c:1236 elf32-score.c:3994 elf32-score7.c:3800 elf32-vax.c:529
+#: elfxx-mips.c:14103
 #, c-format
 msgid "private flags = %lx:"
 msgstr ""
 
-#: elf32-arm.c:11737
+#: elf32-arm.c:11791
 #, c-format
 msgid " [interworking enabled]"
 msgstr ""
 
-#: elf32-arm.c:11745
+#: elf32-arm.c:11799
 #, c-format
 msgid " [VFP float format]"
 msgstr ""
 
-#: elf32-arm.c:11747
+#: elf32-arm.c:11801
 #, c-format
 msgid " [Maverick float format]"
 msgstr ""
 
-#: elf32-arm.c:11749
+#: elf32-arm.c:11803
 #, c-format
 msgid " [FPA float format]"
 msgstr ""
 
-#: elf32-arm.c:11758
+#: elf32-arm.c:11812
 #, c-format
 msgid " [new ABI]"
 msgstr ""
 
-#: elf32-arm.c:11761
+#: elf32-arm.c:11815
 #, c-format
 msgid " [old ABI]"
 msgstr ""
 
-#: elf32-arm.c:11764
+#: elf32-arm.c:11818
 #, c-format
 msgid " [software FP]"
 msgstr ""
 
-#: elf32-arm.c:11773
+#: elf32-arm.c:11827
 #, c-format
 msgid " [Version1 EABI]"
 msgstr ""
 
-#: elf32-arm.c:11776 elf32-arm.c:11787
+#: elf32-arm.c:11830 elf32-arm.c:11841
 #, c-format
 msgid " [sorted symbol table]"
 msgstr ""
 
-#: elf32-arm.c:11778 elf32-arm.c:11789
+#: elf32-arm.c:11832 elf32-arm.c:11843
 #, c-format
 msgid " [unsorted symbol table]"
 msgstr ""
 
-#: elf32-arm.c:11784
+#: elf32-arm.c:11838
 #, c-format
 msgid " [Version2 EABI]"
 msgstr ""
 
-#: elf32-arm.c:11792
+#: elf32-arm.c:11846
 #, c-format
 msgid " [dynamic symbols use segment index]"
 msgstr ""
 
-#: elf32-arm.c:11795
+#: elf32-arm.c:11849
 #, c-format
 msgid " [mapping symbols precede others]"
 msgstr ""
 
-#: elf32-arm.c:11802
+#: elf32-arm.c:11856
 #, c-format
 msgid " [Version3 EABI]"
 msgstr ""
 
-#: elf32-arm.c:11806
+#: elf32-arm.c:11860
 #, c-format
 msgid " [Version4 EABI]"
 msgstr ""
 
-#: elf32-arm.c:11810
+#: elf32-arm.c:11864
 #, c-format
 msgid " [Version5 EABI]"
 msgstr ""
 
-#: elf32-arm.c:11813
+#: elf32-arm.c:11867
 #, c-format
 msgid " [BE8]"
 msgstr ""
 
-#: elf32-arm.c:11816
+#: elf32-arm.c:11870
 #, c-format
 msgid " [LE8]"
 msgstr ""
 
-#: elf32-arm.c:11822
+#: elf32-arm.c:11876
 #, c-format
 msgid " <EABI version unrecognised>"
 msgstr ""
 
-#: elf32-arm.c:11829
+#: elf32-arm.c:11883
 #, c-format
 msgid " [relocatable executable]"
 msgstr ""
 
-#: elf32-arm.c:11832
+#: elf32-arm.c:11886
 #, c-format
 msgid " [has entry point]"
 msgstr ""
 
-#: elf32-arm.c:11837
+#: elf32-arm.c:11891
 #, c-format
 msgid "<Unrecognised flag bits set>"
 msgstr ""
 
-#: elf32-arm.c:12135 elf32-i386.c:1323 elf32-s390.c:1000 elf32-tic6x.c:2827
-#: elf32-xtensa.c:1009 elf64-s390.c:960 elf64-x86-64.c:1172 elfxx-sparc.c:1370
+#: elf32-arm.c:12189 elf32-i386.c:1461 elf32-s390.c:1000 elf32-tic6x.c:2829
+#: elf32-tilepro.c:1336 elf32-xtensa.c:1009 elf64-s390.c:960
+#: elf64-x86-64.c:1364 elfxx-sparc.c:1371 elfxx-tilegx.c:1586
 msgid "%B: bad symbol index: %d"
 msgstr ""
 
-#: elf32-arm.c:12283 elf64-x86-64.c:1370 elf64-x86-64.c:1541 elfxx-mips.c:7949
+#: elf32-arm.c:12337 elf64-x86-64.c:1561 elf64-x86-64.c:1732 elfxx-mips.c:8223
 msgid ""
 "%B: relocation %s against `%s' can not be used when making a shared object; "
 "recompile with -fPIC"
 msgstr ""
 
-#: elf32-arm.c:13412
+#: elf32-arm.c:13460
 #, c-format
 msgid "Errors encountered processing file %s"
 msgstr ""
 
-#: elf32-arm.c:14795
+#: elf32-arm.c:14837
 msgid "%B: error: Cortex-A8 erratum stub is allocated in unsafe location"
 msgstr ""
 
 #. There's not much we can do apart from complain if this
 #. happens.
-#: elf32-arm.c:14822
+#: elf32-arm.c:14864
 msgid "%B: error: Cortex-A8 erratum stub out of range (input file too large)"
 msgstr ""
 
-#: elf32-arm.c:14916 elf32-arm.c:14938
+#: elf32-arm.c:14958 elf32-arm.c:14980
 msgid "%B: error: VFP11 veneer out of range"
 msgstr ""
 
-#: elf32-arm.c:15477
+#: elf32-arm.c:15518
 msgid "error: %B is already in final BE8 format"
 msgstr ""
 
-#: elf32-arm.c:15553
+#: elf32-arm.c:15594
 msgid ""
 "error: Source object %B has EABI version %d, but target %B has EABI version "
 "%d"
 msgstr ""
 
-#: elf32-arm.c:15569
+#: elf32-arm.c:15610
 msgid "error: %B is compiled for APCS-%d, whereas target %B uses APCS-%d"
 msgstr ""
 
-#: elf32-arm.c:15594
+#: elf32-arm.c:15635
 msgid "error: %B uses VFP instructions, whereas %B does not"
 msgstr ""
 
-#: elf32-arm.c:15598
+#: elf32-arm.c:15639
 msgid "error: %B uses FPA instructions, whereas %B does not"
 msgstr ""
 
-#: elf32-arm.c:15608
+#: elf32-arm.c:15649
 msgid "error: %B uses Maverick instructions, whereas %B does not"
 msgstr ""
 
-#: elf32-arm.c:15612
+#: elf32-arm.c:15653
 msgid "error: %B does not use Maverick instructions, whereas %B does"
 msgstr ""
 
-#: elf32-arm.c:15631
+#: elf32-arm.c:15672
 msgid "error: %B uses software FP, whereas %B uses hardware FP"
 msgstr ""
 
-#: elf32-arm.c:15635
+#: elf32-arm.c:15676
 msgid "error: %B uses hardware FP, whereas %B uses software FP"
 msgstr ""
 
-#: elf32-avr.c:1229 elf32-bfin.c:3217 elf32-cris.c:2085 elf32-fr30.c:617
-#: elf32-frv.c:4110 elf32-i860.c:1219 elf32-ip2k.c:1479 elf32-iq2000.c:692
-#: elf32-m32c.c:561 elf32-mep.c:543 elf32-moxie.c:290 elf32-msp430.c:494
-#: elf32-mt.c:399 elf32-openrisc.c:412 elf32-v850.c:2151 elf32-xstormy16.c:949
-#: elf64-mmix.c:1530
+#: elf32-avr.c:1229 elf32-bfin.c:3221 elf32-cris.c:2089 elf32-epiphany.c:567
+#: elf32-fr30.c:617 elf32-frv.c:4113 elf32-i860.c:1219 elf32-ip2k.c:1479
+#: elf32-iq2000.c:692 elf32-m32c.c:561 elf32-mep.c:543 elf32-moxie.c:290
+#: elf32-msp430.c:494 elf32-mt.c:399 elf32-openrisc.c:412 elf32-tilepro.c:3222
+#: elf32-v850.c:2151 elf32-xstormy16.c:943 elf64-mmix.c:1598
+#: elfxx-tilegx.c:3585
 msgid "internal error: dangerous relocation"
 msgstr ""
 
@@ -1283,181 +1288,181 @@
 msgid "relocation should be even number"
 msgstr ""
 
-#: elf32-bfin.c:1591
+#: elf32-bfin.c:1593
 msgid "%B(%A+0x%lx): unresolvable relocation against symbol `%s'"
 msgstr ""
 
-#: elf32-bfin.c:1624 elf32-i386.c:4150 elf32-m68k.c:4233 elf32-s390.c:3062
-#: elf64-s390.c:3037 elf64-x86-64.c:3923
+#: elf32-bfin.c:1626 elf32-i386.c:4307 elf32-m68k.c:4233 elf32-s390.c:3055
+#: elf64-s390.c:3030 elf64-x86-64.c:4151
 msgid "%B(%A+0x%lx): reloc against `%s': error %d"
 msgstr ""
 
-#: elf32-bfin.c:2723
+#: elf32-bfin.c:2725
 msgid "%B: relocation at `%A+0x%x' references symbol `%s' with nonzero addend"
 msgstr ""
 
-#: elf32-bfin.c:2737
+#: elf32-bfin.c:2741
 msgid "relocation references symbol not defined in the module"
 msgstr ""
 
-#: elf32-bfin.c:2834
+#: elf32-bfin.c:2838
 msgid "R_BFIN_FUNCDESC references dynamic symbol with nonzero addend"
 msgstr ""
 
-#: elf32-bfin.c:2875 elf32-bfin.c:2998
+#: elf32-bfin.c:2879 elf32-bfin.c:3002
 msgid "cannot emit fixups in read-only section"
 msgstr ""
 
-#: elf32-bfin.c:2906 elf32-bfin.c:3036 elf32-lm32.c:1103 elf32-sh.c:5021
+#: elf32-bfin.c:2910 elf32-bfin.c:3040 elf32-lm32.c:1103 elf32-sh.c:5016
 msgid "cannot emit dynamic relocations in read-only section"
 msgstr ""
 
-#: elf32-bfin.c:2956
+#: elf32-bfin.c:2960
 msgid "R_BFIN_FUNCDESC_VALUE references dynamic symbol with nonzero addend"
 msgstr ""
 
-#: elf32-bfin.c:3121
+#: elf32-bfin.c:3125
 msgid "relocations between different segments are not supported"
 msgstr ""
 
-#: elf32-bfin.c:3122
+#: elf32-bfin.c:3126
 msgid "warning: relocation references a different segment"
 msgstr ""
 
-#: elf32-bfin.c:4967
+#: elf32-bfin.c:4971
 msgid "%B: unsupported relocation type %i"
 msgstr ""
 
-#: elf32-bfin.c:5121 elf32-frv.c:6805
+#: elf32-bfin.c:5125 elf32-frv.c:6808
 #, c-format
 msgid "%s: cannot link non-fdpic object file into fdpic executable"
 msgstr ""
 
-#: elf32-bfin.c:5125 elf32-frv.c:6809
+#: elf32-bfin.c:5129 elf32-frv.c:6812
 #, c-format
 msgid "%s: cannot link fdpic object file into non-fdpic executable"
 msgstr ""
 
-#: elf32-bfin.c:5279
+#: elf32-bfin.c:5283
 #, c-format
 msgid "*** check this relocation %s"
 msgstr ""
 
-#: elf32-cris.c:1172
+#: elf32-cris.c:1176
 msgid "%B, section %A: unresolvable relocation %s against symbol `%s'"
 msgstr ""
 
-#: elf32-cris.c:1234
+#: elf32-cris.c:1238
 msgid "%B, section %A: No PLT nor GOT for relocation %s against symbol `%s'"
 msgstr ""
 
-#: elf32-cris.c:1236
+#: elf32-cris.c:1240
 msgid "%B, section %A: No PLT for relocation %s against symbol `%s'"
 msgstr ""
 
-#: elf32-cris.c:1242 elf32-cris.c:1375 elf32-cris.c:1635 elf32-cris.c:1718
-#: elf32-cris.c:1871 elf32-tic6x.c:2660
+#: elf32-cris.c:1246 elf32-cris.c:1379 elf32-cris.c:1639 elf32-cris.c:1722
+#: elf32-cris.c:1875 elf32-tic6x.c:2662
 msgid "[whose name is lost]"
 msgstr ""
 
-#: elf32-cris.c:1361 elf32-tic6x.c:2645
+#: elf32-cris.c:1365 elf32-tic6x.c:2647
 msgid ""
 "%B, section %A: relocation %s with non-zero addend %d against local symbol"
 msgstr ""
 
-#: elf32-cris.c:1369 elf32-cris.c:1712 elf32-cris.c:1865 elf32-tic6x.c:2653
+#: elf32-cris.c:1373 elf32-cris.c:1716 elf32-cris.c:1869 elf32-tic6x.c:2655
 msgid ""
 "%B, section %A: relocation %s with non-zero addend %d against symbol `%s'"
 msgstr ""
 
-#: elf32-cris.c:1395
+#: elf32-cris.c:1399
 msgid "%B, section %A: relocation %s is not allowed for global symbol: `%s'"
 msgstr ""
 
-#: elf32-cris.c:1411
+#: elf32-cris.c:1415
 msgid "%B, section %A: relocation %s with no GOT created"
 msgstr ""
 
 #. We shouldn't get here for GCC-emitted code.
-#: elf32-cris.c:1626
+#: elf32-cris.c:1630
 msgid ""
 "%B, section %A: relocation %s has an undefined reference to `%s', perhaps a "
 "declaration mixup?"
 msgstr ""
 
-#: elf32-cris.c:1998
+#: elf32-cris.c:2002
 msgid ""
 "%B, section %A: relocation %s is not allowed for symbol: `%s' which is "
 "defined outside the program, perhaps a declaration mixup?"
 msgstr ""
 
-#: elf32-cris.c:2051
+#: elf32-cris.c:2055
 msgid "(too many global variables for -fpic: recompile with -fPIC)"
 msgstr ""
 
-#: elf32-cris.c:2058
+#: elf32-cris.c:2062
 msgid ""
 "(thread-local data too big for -fpic or -msmall-tls: recompile with -fPIC or "
 "-mno-small-tls)"
 msgstr ""
 
-#: elf32-cris.c:3248
+#: elf32-cris.c:3261
 msgid ""
 "%B, section %A:\n"
 "  v10/v32 compatible object %s must not contain a PIC relocation"
 msgstr ""
 
-#: elf32-cris.c:3353
+#: elf32-cris.c:3366
 msgid ""
 "%B, section %A:\n"
 "  relocation %s not valid in a shared object; typically an option mixup, "
 "recompile with -fPIC"
 msgstr ""
 
-#: elf32-cris.c:3567
+#: elf32-cris.c:3580
 msgid ""
 "%B, section %A:\n"
 "  relocation %s should not be used in a shared object; recompile with -fPIC"
 msgstr ""
 
-#: elf32-cris.c:3992
+#: elf32-cris.c:4002
 msgid ""
 "%B, section `%A', to symbol `%s':\n"
 "  relocation %s should not be used in a shared object; recompile with -fPIC"
 msgstr ""
 
-#: elf32-cris.c:4111
+#: elf32-cris.c:4118
 msgid "Unexpected machine number"
 msgstr ""
 
-#: elf32-cris.c:4165
+#: elf32-cris.c:4172
 #, c-format
 msgid " [symbols have a _ prefix]"
 msgstr ""
 
-#: elf32-cris.c:4168
+#: elf32-cris.c:4175
 #, c-format
 msgid " [v10 and v32]"
 msgstr ""
 
-#: elf32-cris.c:4171
+#: elf32-cris.c:4178
 #, c-format
 msgid " [v32]"
 msgstr ""
 
-#: elf32-cris.c:4216
+#: elf32-cris.c:4223
 msgid "%B: uses _-prefixed symbols, but writing file with non-prefixed symbols"
 msgstr ""
 
-#: elf32-cris.c:4217
+#: elf32-cris.c:4224
 msgid "%B: uses non-prefixed symbols, but writing file with _-prefixed symbols"
 msgstr ""
 
-#: elf32-cris.c:4236
+#: elf32-cris.c:4243
 msgid "%B contains CRIS v32 code, incompatible with previous objects"
 msgstr ""
 
-#: elf32-cris.c:4238
+#: elf32-cris.c:4245
 msgid "%B contains non-CRIS-v32 code, incompatible with previous objects"
 msgstr ""
 
@@ -1471,6 +1476,11 @@
 msgid "BFD Link Error: jump (PC rel26) to section (%s) not supported"
 msgstr ""
 
+#. Only if it's not an unresolved symbol.
+#: elf32-epiphany.c:563 elf32-ip2k.c:1475
+msgid "unsupported relocation between data/insn address spaces"
+msgstr ""
+
 #: elf32-frv.c:1509 elf32-frv.c:1658
 msgid "relocation requires zero addend"
 msgstr ""
@@ -1479,107 +1489,107 @@
 msgid "%H: relocation to `%s+%v' may have caused the error above\n"
 msgstr ""
 
-#: elf32-frv.c:2902
+#: elf32-frv.c:2905
 msgid "%H: relocation references symbol not defined in the module\n"
 msgstr ""
 
-#: elf32-frv.c:2978
+#: elf32-frv.c:2981
 msgid "%H: R_FRV_GETTLSOFF not applied to a call instruction\n"
 msgstr ""
 
-#: elf32-frv.c:3019
+#: elf32-frv.c:3022
 msgid "%H: R_FRV_GOTTLSDESC12 not applied to an lddi instruction\n"
 msgstr ""
 
-#: elf32-frv.c:3090
+#: elf32-frv.c:3093
 msgid "%H: R_FRV_GOTTLSDESCHI not applied to a sethi instruction\n"
 msgstr ""
 
-#: elf32-frv.c:3127
+#: elf32-frv.c:3130
 msgid "%H: R_FRV_GOTTLSDESCLO not applied to a setlo or setlos instruction\n"
 msgstr ""
 
-#: elf32-frv.c:3174
+#: elf32-frv.c:3177
 msgid "%H: R_FRV_TLSDESC_RELAX not applied to an ldd instruction\n"
 msgstr ""
 
-#: elf32-frv.c:3258
+#: elf32-frv.c:3261
 msgid "%H: R_FRV_GETTLSOFF_RELAX not applied to a calll instruction\n"
 msgstr ""
 
-#: elf32-frv.c:3312
+#: elf32-frv.c:3315
 msgid "%H: R_FRV_GOTTLSOFF12 not applied to an ldi instruction\n"
 msgstr ""
 
-#: elf32-frv.c:3342
+#: elf32-frv.c:3345
 msgid "%H: R_FRV_GOTTLSOFFHI not applied to a sethi instruction\n"
 msgstr ""
 
-#: elf32-frv.c:3371
+#: elf32-frv.c:3374
 msgid "%H: R_FRV_GOTTLSOFFLO not applied to a setlo or setlos instruction\n"
 msgstr ""
 
-#: elf32-frv.c:3401
+#: elf32-frv.c:3404
 msgid "%H: R_FRV_TLSOFF_RELAX not applied to an ld instruction\n"
 msgstr ""
 
-#: elf32-frv.c:3446
+#: elf32-frv.c:3449
 msgid "%H: R_FRV_TLSMOFFHI not applied to a sethi instruction\n"
 msgstr ""
 
-#: elf32-frv.c:3473
+#: elf32-frv.c:3476
 msgid "R_FRV_TLSMOFFLO not applied to a setlo or setlos instruction\n"
 msgstr ""
 
-#: elf32-frv.c:3594
+#: elf32-frv.c:3597
 msgid "%H: R_FRV_FUNCDESC references dynamic symbol with nonzero addend\n"
 msgstr ""
 
-#: elf32-frv.c:3635 elf32-frv.c:3757
+#: elf32-frv.c:3638 elf32-frv.c:3760
 msgid "%H: cannot emit fixups in read-only section\n"
 msgstr ""
 
-#: elf32-frv.c:3666 elf32-frv.c:3800
+#: elf32-frv.c:3669 elf32-frv.c:3803
 msgid "%H: cannot emit dynamic relocations in read-only section\n"
 msgstr ""
 
-#: elf32-frv.c:3715
+#: elf32-frv.c:3718
 msgid ""
 "%H: R_FRV_FUNCDESC_VALUE references dynamic symbol with nonzero addend\n"
 msgstr ""
 
-#: elf32-frv.c:3971
+#: elf32-frv.c:3974
 msgid "%H: reloc against `%s' references a different segment\n"
 msgstr ""
 
-#: elf32-frv.c:4121
+#: elf32-frv.c:4124
 msgid "%H: reloc against `%s': %s\n"
 msgstr ""
 
-#: elf32-frv.c:6397
+#: elf32-frv.c:6400
 msgid "%B: unsupported relocation type %i\n"
 msgstr ""
 
-#: elf32-frv.c:6719
+#: elf32-frv.c:6722
 #, c-format
 msgid ""
 "%s: compiled with %s and linked with modules that use non-pic relocations"
 msgstr ""
 
-#: elf32-frv.c:6772 elf32-iq2000.c:845 elf32-m32c.c:807
+#: elf32-frv.c:6775 elf32-iq2000.c:845 elf32-m32c.c:807
 #, c-format
 msgid "%s: compiled with %s and linked with modules compiled with %s"
 msgstr ""
 
-#: elf32-frv.c:6784
+#: elf32-frv.c:6787
 #, c-format
 msgid ""
 "%s: uses different unknown e_flags (0x%lx) fields than previous modules (0x"
 "%lx)"
 msgstr ""
 
-#: elf32-frv.c:6834 elf32-iq2000.c:882 elf32-m32c.c:843 elf32-mt.c:576
-#: elf32-rx.c:2937
+#: elf32-frv.c:6837 elf32-iq2000.c:882 elf32-m32c.c:843 elf32-mt.c:576
+#: elf32-rx.c:3001
 #, c-format
 msgid "private flags = 0x%lx:"
 msgstr ""
@@ -1588,7 +1598,7 @@
 msgid "%B: Relocations in generic ELF (EM: %d)"
 msgstr ""
 
-#: elf32-hppa.c:850 elf32-hppa.c:3610
+#: elf32-hppa.c:850 elf32-hppa.c:3598
 msgid "%B(%A+0x%lx): cannot reach %s, recompile with -ffunction-sections"
 msgstr ""
 
@@ -1598,85 +1608,87 @@
 "with -fPIC"
 msgstr ""
 
-#: elf32-hppa.c:2803
+#: elf32-hppa.c:2791
 msgid "%B: duplicate export stub %s"
 msgstr ""
 
-#: elf32-hppa.c:3449
+#: elf32-hppa.c:3437
 msgid ""
 "%B(%A+0x%lx): %s fixup for insn 0x%x is not supported in a non-shared link"
 msgstr ""
 
-#: elf32-hppa.c:4296
+#: elf32-hppa.c:4284
 msgid "%B(%A+0x%lx): cannot handle %s for %s"
 msgstr ""
 
-#: elf32-hppa.c:4608
+#: elf32-hppa.c:4603
 msgid ".got section not immediately after .plt section"
 msgstr ""
 
 #. Unknown relocation.
-#: elf32-i386.c:372 elf32-m68k.c:383 elf32-ppc.c:1675 elf32-s390.c:379
-#: elf32-tic6x.c:2682 elf64-ppc.c:2285 elf64-s390.c:403 elf64-x86-64.c:243
+#: elf32-i386.c:373 elf32-m68k.c:384 elf32-ppc.c:1676 elf32-s390.c:379
+#: elf32-tic6x.c:2684 elf64-ppc.c:2300 elf64-s390.c:403 elf64-x86-64.c:265
 msgid "%B: invalid relocation type %d"
 msgstr ""
 
-#: elf32-i386.c:1266 elf64-x86-64.c:1116
+#: elf32-i386.c:1404 elf64-x86-64.c:1308
 msgid ""
 "%B: TLS transition from %s to %s against `%s' at 0x%lx in section `%A' failed"
 msgstr ""
 
-#: elf32-i386.c:1411 elf32-i386.c:3090 elf64-x86-64.c:1296 elf64-x86-64.c:2909
-#: elfxx-sparc.c:3077
+#: elf32-i386.c:1549 elf32-i386.c:3244 elf64-x86-64.c:1487 elf64-x86-64.c:3125
+#: elfxx-sparc.c:3083
 msgid "%B: relocation %s against STT_GNU_IFUNC symbol `%s' isn't handled by %s"
 msgstr ""
 
-#: elf32-i386.c:1573 elf32-s390.c:1182 elf32-sh.c:6367 elf32-xtensa.c:1182
-#: elf64-s390.c:1151 elfxx-sparc.c:1547
+#: elf32-i386.c:1711 elf32-s390.c:1182 elf32-sh.c:6362 elf32-tilepro.c:1434
+#: elf32-xtensa.c:1182 elf64-s390.c:1151 elfxx-sparc.c:1548
+#: elfxx-tilegx.c:1701
 msgid "%B: `%s' accessed both as normal and thread local symbol"
 msgstr ""
 
-#: elf32-i386.c:2405 elf64-x86-64.c:2320
+#: elf32-i386.c:2539 elf64-x86-64.c:2506
 msgid "%P: %B: warning: relocation against `%s' in readonly section `%A'.\n"
 msgstr ""
 
-#: elf32-i386.c:2496 elf64-x86-64.c:2407
+#: elf32-i386.c:2629 elf64-x86-64.c:2593
 msgid "%P: %B: warning: relocation in readonly section `%A'.\n"
 msgstr ""
 
-#: elf32-i386.c:2932
+#: elf32-i386.c:3086 elf32-tilepro.c:2557 elfxx-tilegx.c:2871
 msgid "%B: unrecognized relocation (0x%x) in section `%A'"
 msgstr ""
 
-#: elf32-i386.c:3339 elf64-x86-64.c:3295
+#: elf32-i386.c:3494 elf64-x86-64.c:3513
 msgid "hidden symbol"
 msgstr ""
 
-#: elf32-i386.c:3342 elf64-x86-64.c:3298
+#: elf32-i386.c:3497 elf64-x86-64.c:3516
 msgid "internal symbol"
 msgstr ""
 
-#: elf32-i386.c:3345 elf64-x86-64.c:3301
+#: elf32-i386.c:3500 elf64-x86-64.c:3519
 msgid "protected symbol"
 msgstr ""
 
-#: elf32-i386.c:3348 elf64-x86-64.c:3304
+#: elf32-i386.c:3503 elf64-x86-64.c:3522
 msgid "symbol"
 msgstr ""
 
-#: elf32-i386.c:3353
+#: elf32-i386.c:3508
 msgid ""
 "%B: relocation R_386_GOTOFF against undefined %s `%s' can not be used when "
 "making a shared object"
 msgstr ""
 
-#: elf32-i386.c:3363
+#: elf32-i386.c:3518
 msgid ""
 "%B: relocation R_386_GOTOFF against protected function `%s' can not be used "
 "when making a shared object"
 msgstr ""
 
-#: elf32-i386.c:4660 elf64-x86-64.c:4378
+#: elf32-i386.c:4839 elf32-tilepro.c:3467 elf64-x86-64.c:4609
+#: elfxx-tilegx.c:3847
 #, c-format
 msgid "discarded output section: `%A'"
 msgstr ""
@@ -1700,11 +1712,6 @@
 msgid "ip2k linker: redundant page instruction at 0x%08lx (dest = 0x%08lx)."
 msgstr ""
 
-#. Only if it's not an unresolved symbol.
-#: elf32-ip2k.c:1475
-msgid "unsupported relocation between data/insn address spaces"
-msgstr ""
-
 #: elf32-iq2000.c:858 elf32-m32c.c:819
 #, c-format
 msgid "%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"
@@ -1726,30 +1733,30 @@
 msgid "SDA relocation when _SDA_BASE_ not defined"
 msgstr ""
 
-#: elf32-m32r.c:3048
+#: elf32-m32r.c:3043
 msgid "%B: The target (%s) of an %s relocation is in the wrong section (%A)"
 msgstr ""
 
-#: elf32-m32r.c:3576
+#: elf32-m32r.c:3571
 msgid "%B: Instruction set mismatch with previous modules"
 msgstr ""
 
-#: elf32-m32r.c:3597
+#: elf32-m32r.c:3592
 #, c-format
 msgid "private flags = %lx"
 msgstr ""
 
-#: elf32-m32r.c:3602
+#: elf32-m32r.c:3597
 #, c-format
 msgid ": m32r instructions"
 msgstr ""
 
-#: elf32-m32r.c:3603
+#: elf32-m32r.c:3598
 #, c-format
 msgid ": m32rx instructions"
 msgstr ""
 
-#: elf32-m32r.c:3604
+#: elf32-m32r.c:3599
 #, c-format
 msgid ": m32r2 instructions"
 msgstr ""
@@ -1791,7 +1798,7 @@
 msgid "%B: linking files compiled for HCS12 with others compiled for HC12"
 msgstr ""
 
-#: elf32-m68hc1x.c:1257 elf32-ppc.c:4214 elf64-sparc.c:705 elfxx-mips.c:12719
+#: elf32-m68hc1x.c:1257 elf32-ppc.c:4227 elf64-sparc.c:706 elfxx-mips.c:13965
 msgid "%B: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"
 msgstr ""
 
@@ -1840,19 +1847,19 @@
 msgid " [memory=flat]"
 msgstr ""
 
-#: elf32-m68k.c:1250 elf32-m68k.c:1251 vms-alpha.c:7311 vms-alpha.c:7326
+#: elf32-m68k.c:1251 elf32-m68k.c:1252 vms-alpha.c:7314 vms-alpha.c:7329
 msgid "unknown"
 msgstr ""
 
-#: elf32-m68k.c:1714
+#: elf32-m68k.c:1715
 msgid "%B: GOT overflow: Number of relocations with 8-bit offset > %d"
 msgstr ""
 
-#: elf32-m68k.c:1720
+#: elf32-m68k.c:1721
 msgid "%B: GOT overflow: Number of relocations with 8- or 16-bit offset > %d"
 msgstr ""
 
-#: elf32-m68k.c:3959
+#: elf32-m68k.c:3957
 msgid "%B(%A+0x%lx): R_68K_TLS_LE32 relocation not permitted in shared object"
 msgstr ""
 
@@ -1898,7 +1905,8 @@
 msgid "%s: The target (%s) of an %s relocation is in the wrong section (%s)"
 msgstr ""
 
-#: elf32-microblaze.c:1155 elfxx-sparc.c:3451
+#: elf32-microblaze.c:1155 elf32-tilepro.c:2891 elfxx-sparc.c:3457
+#: elfxx-tilegx.c:3230
 msgid "%B: probably compiled without -fPIC?"
 msgstr ""
 
@@ -1906,224 +1914,235 @@
 msgid "%B: bad relocation section name `%s'"
 msgstr ""
 
-#: elf32-mips.c:1045 elf64-mips.c:2084 elfn32-mips.c:1888
+#: elf32-mips.c:1549 elf64-mips.c:2683 elfn32-mips.c:2487
 msgid "literal relocation occurs for an external symbol"
 msgstr ""
 
-#: elf32-mips.c:1085 elf32-score.c:569 elf32-score7.c:469 elf64-mips.c:2127
-#: elfn32-mips.c:1929
+#: elf32-mips.c:1596 elf32-score.c:570 elf32-score7.c:469 elf64-mips.c:2726
+#: elfn32-mips.c:2528
 msgid "32bits gp relative relocation occurs for an external symbol"
 msgstr ""
 
-#: elf32-ppc.c:1740
+#: elf32-ppc.c:1741
 #, c-format
 msgid "generic linker can't handle %s"
 msgstr ""
 
-#: elf32-ppc.c:2183
+#: elf32-ppc.c:2184
 msgid "corrupt %s section in %B"
 msgstr ""
 
-#: elf32-ppc.c:2202
+#: elf32-ppc.c:2203
 msgid "unable to read in %s section from %B"
 msgstr ""
 
-#: elf32-ppc.c:2243
+#: elf32-ppc.c:2244
 msgid "warning: unable to set size of %s section in %B"
 msgstr ""
 
-#: elf32-ppc.c:2293
+#: elf32-ppc.c:2294
 msgid "failed to allocate space for new APUinfo section."
 msgstr ""
 
-#: elf32-ppc.c:2312
+#: elf32-ppc.c:2313
 msgid "failed to compute new APUinfo section."
 msgstr ""
 
-#: elf32-ppc.c:2315
+#: elf32-ppc.c:2316
 msgid "failed to install new APUinfo section."
 msgstr ""
 
-#: elf32-ppc.c:3343
+#: elf32-ppc.c:3356
 msgid "%B: relocation %s cannot be used when making a shared object"
 msgstr ""
 
 #. It does not make sense to have a procedure linkage
 #. table entry for a local symbol.
-#: elf32-ppc.c:3687
-msgid "%H: %s reloc against local symbol\n"
+#: elf32-ppc.c:3700
+msgid "%P: %H: %s reloc against local symbol\n"
 msgstr ""
 
-#: elf32-ppc.c:4026 elf32-ppc.c:4041 elfxx-mips.c:12423 elfxx-mips.c:12449
-#: elfxx-mips.c:12471 elfxx-mips.c:12497
+#: elf32-ppc.c:4039 elf32-ppc.c:4054 elfxx-mips.c:13651 elfxx-mips.c:13677
+#: elfxx-mips.c:13699 elfxx-mips.c:13725
 msgid "Warning: %B uses hard float, %B uses soft float"
 msgstr ""
 
-#: elf32-ppc.c:4029 elf32-ppc.c:4033
+#: elf32-ppc.c:4042 elf32-ppc.c:4046
 msgid ""
 "Warning: %B uses double-precision hard float, %B uses single-precision hard "
 "float"
 msgstr ""
 
-#: elf32-ppc.c:4037
+#: elf32-ppc.c:4050
 msgid "Warning: %B uses soft float, %B uses single-precision hard float"
 msgstr ""
 
-#: elf32-ppc.c:4044 elf32-ppc.c:4048 elfxx-mips.c:12403 elfxx-mips.c:12407
+#: elf32-ppc.c:4057 elf32-ppc.c:4061 elfxx-mips.c:13631 elfxx-mips.c:13635
 msgid "Warning: %B uses unknown floating point ABI %d"
 msgstr ""
 
-#: elf32-ppc.c:4090 elf32-ppc.c:4094
+#: elf32-ppc.c:4103 elf32-ppc.c:4107
 msgid "Warning: %B uses unknown vector ABI %d"
 msgstr ""
 
-#: elf32-ppc.c:4098
+#: elf32-ppc.c:4111
 msgid "Warning: %B uses vector ABI \"%s\", %B uses \"%s\""
 msgstr ""
 
-#: elf32-ppc.c:4115 elf32-ppc.c:4118
+#: elf32-ppc.c:4128 elf32-ppc.c:4131
 msgid "Warning: %B uses r3/r4 for small structure returns, %B uses memory"
 msgstr ""
 
-#: elf32-ppc.c:4121 elf32-ppc.c:4125
+#: elf32-ppc.c:4134 elf32-ppc.c:4138
 msgid "Warning: %B uses unknown small structure return convention %d"
 msgstr ""
 
-#: elf32-ppc.c:4179
+#: elf32-ppc.c:4192
 msgid ""
 "%B: compiled with -mrelocatable and linked with modules compiled normally"
 msgstr ""
 
-#: elf32-ppc.c:4187
+#: elf32-ppc.c:4200
 msgid ""
 "%B: compiled normally and linked with modules compiled with -mrelocatable"
 msgstr ""
 
-#: elf32-ppc.c:4275
-msgid "Using bss-plt due to %B"
+#: elf32-ppc.c:4309
+msgid "%P: bss-plt forced due to %B\n"
+msgstr ""
+
+#: elf32-ppc.c:4312
+msgid "%P: bss-plt forced by profiling\n"
 msgstr ""
 
 #. 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 optimization.
-#: elf32-ppc.c:4771 elf64-ppc.c:7778
+#: elf32-ppc.c:4809 elf64-ppc.c:7858
 msgid "%H arg lost __tls_get_addr, TLS optimization disabled\n"
 msgstr ""
 
-#: elf32-ppc.c:5006 elf64-ppc.c:6494
-#, c-format
-msgid "dynamic variable `%s' is zero size\n"
+#: elf32-ppc.c:5044 elf64-ppc.c:6528
+msgid "%P: dynamic variable `%s' is zero size\n"
 msgstr ""
 
-#: elf32-ppc.c:7204 elf64-ppc.c:12431
-msgid "%B: unknown relocation type %d for symbol %s\n"
+#: elf32-ppc.c:7263 elf64-ppc.c:12675
+msgid "%P: %B: unknown relocation type %d for symbol %s\n"
 msgstr ""
 
-#: elf32-ppc.c:7465
-msgid "%H: non-zero addend on %s reloc against `%s'\n"
+#: elf32-ppc.c:7524
+msgid "%P: %H: non-zero addend on %s reloc against `%s'\n"
 msgstr ""
 
-#: elf32-ppc.c:7661 elf64-ppc.c:12936
-msgid "%H: relocation %s for indirect function %s unsupported\n"
+#: elf32-ppc.c:7720 elf64-ppc.c:13181
+msgid "%P: %H: relocation %s for indirect function %s unsupported\n"
 msgstr ""
 
-#: elf32-ppc.c:7889 elf32-ppc.c:7919 elf32-ppc.c:7966
+#: elf32-ppc.c:7948 elf32-ppc.c:7978 elf32-ppc.c:8025
 msgid ""
-"%B: the target (%s) of a %s relocation is in the wrong output section (%s)\n"
+"%P: %B: the target (%s) of a %s relocation is in the wrong output section "
+"(%s)\n"
 msgstr ""
 
-#: elf32-ppc.c:8038
-msgid "%B: relocation %s is not yet supported for symbol %s\n"
+#: elf32-ppc.c:8097
+msgid "%P: %B: relocation %s is not yet supported for symbol %s\n"
 msgstr ""
 
-#: elf32-ppc.c:8097 elf64-ppc.c:13237
-msgid "%H: unresolvable %s relocation against symbol `%s'\n"
+#: elf32-ppc.c:8158 elf64-ppc.c:13467
+msgid "%P: %H: unresolvable %s relocation against symbol `%s'\n"
 msgstr ""
 
-#: elf32-ppc.c:8144 elf64-ppc.c:13282
-msgid "%H: %s reloc against `%s': error %d\n"
+#: elf32-ppc.c:8205 elf64-ppc.c:13512
+msgid "%P: %H: %s reloc against `%s': error %d\n"
 msgstr ""
 
-#: elf32-ppc.c:8635
-#, c-format
-msgid "%s not defined in linker created %s\n"
+#: elf32-ppc.c:8696
+msgid "%P: %s not defined in linker created %s\n"
 msgstr ""
 
-#: elf32-rx.c:553
+#: elf32-rx.c:563
 msgid "%B:%A: Warning: deprecated Red Hat reloc "
 msgstr ""
 
-#: elf32-rx.c:1095
+#. Check for unsafe relocs in PID mode.  These are any relocs where
+#. an absolute address is being computed.  There are special cases
+#. for relocs against symbols that are known to be referenced in
+#. crt0.o before the PID base address register has been initialised.
+#: elf32-rx.c:581
+msgid "%B(%A): unsafe PID relocation %s at 0x%08lx (against %s in %s)"
+msgstr ""
+
+#: elf32-rx.c:1157
 msgid "Warning: RX_SYM reloc with an unknown symbol"
 msgstr ""
 
-#: elf32-rx.c:1260
+#: elf32-rx.c:1324
 msgid "%B(%A): error: call to undefined function '%s'"
 msgstr ""
 
-#: elf32-rx.c:1274
+#: elf32-rx.c:1338
 msgid "%B(%A): warning: unaligned access to symbol '%s' in the small data area"
 msgstr ""
 
-#: elf32-rx.c:1278
+#: elf32-rx.c:1342
 msgid "%B(%A): internal error: out of range error"
 msgstr ""
 
-#: elf32-rx.c:1282
+#: elf32-rx.c:1346
 msgid "%B(%A): internal error: unsupported relocation error"
 msgstr ""
 
-#: elf32-rx.c:1286
+#: elf32-rx.c:1350
 msgid "%B(%A): internal error: dangerous relocation"
 msgstr ""
 
-#: elf32-rx.c:1290
+#: elf32-rx.c:1354
 msgid "%B(%A): internal error: unknown error"
 msgstr ""
 
-#: elf32-rx.c:2940
+#: elf32-rx.c:3004
 #, c-format
 msgid " [64-bit doubles]"
 msgstr ""
 
-#: elf32-rx.c:2942
+#: elf32-rx.c:3006
 #, c-format
 msgid " [dsp]"
 msgstr ""
 
-#: elf32-s390.c:2209 elf64-s390.c:2196
+#: elf32-s390.c:2200 elf64-s390.c:2187
 msgid "%B(%A+0x%lx): invalid instruction for TLS relocation %s"
 msgstr ""
 
-#: elf32-score.c:1522 elf32-score7.c:1382 elfxx-mips.c:3324
+#: elf32-score.c:1520 elf32-score7.c:1379 elfxx-mips.c:3435
 msgid "not enough GOT space for local GOT entries"
 msgstr ""
 
-#: elf32-score.c:2744
+#: elf32-score.c:2742
 msgid "address not word align"
 msgstr ""
 
-#: elf32-score.c:2829 elf32-score7.c:2634
+#: elf32-score.c:2827 elf32-score7.c:2631
 #, c-format
 msgid "%s: Malformed reloc detected for section %s"
 msgstr ""
 
-#: elf32-score.c:2880 elf32-score7.c:2685
+#: elf32-score.c:2878 elf32-score7.c:2682
 msgid "%B: CALL15 reloc at 0x%lx not against global symbol"
 msgstr ""
 
-#: elf32-score.c:3999 elf32-score7.c:3806
+#: elf32-score.c:3997 elf32-score7.c:3803
 #, c-format
 msgid " [pic]"
 msgstr ""
 
-#: elf32-score.c:4003 elf32-score7.c:3810
+#: elf32-score.c:4001 elf32-score7.c:3807
 #, c-format
 msgid " [fix dep]"
 msgstr ""
 
-#: elf32-score.c:4045 elf32-score7.c:3852
+#: elf32-score.c:4043 elf32-score7.c:3849
 msgid "%B: warning: linking PIC files with non-PIC files"
 msgstr ""
 
@@ -2171,76 +2190,76 @@
 msgid "%B: 0x%lx: fatal: reloc overflow while relaxing"
 msgstr ""
 
-#: elf32-sh.c:4057 elf64-sh64.c:1514
+#: elf32-sh.c:4048 elf64-sh64.c:1514
 msgid "Unexpected STO_SH5_ISA32 on local symbol is not handled"
 msgstr ""
 
-#: elf32-sh.c:4304
+#: elf32-sh.c:4299
 msgid "%B: 0x%lx: fatal: unaligned branch target for relax-support relocation"
 msgstr ""
 
-#: elf32-sh.c:4337 elf32-sh.c:4352
+#: elf32-sh.c:4332 elf32-sh.c:4347
 msgid "%B: 0x%lx: fatal: unaligned %s relocation 0x%lx"
 msgstr ""
 
-#: elf32-sh.c:4366
+#: elf32-sh.c:4361
 msgid "%B: 0x%lx: fatal: R_SH_PSHA relocation %d not in range -32..32"
 msgstr ""
 
-#: elf32-sh.c:4380
+#: elf32-sh.c:4375
 msgid "%B: 0x%lx: fatal: R_SH_PSHL relocation %d not in range -32..32"
 msgstr ""
 
-#: elf32-sh.c:4524 elf32-sh.c:4994
+#: elf32-sh.c:4519 elf32-sh.c:4989
 msgid "%B(%A+0x%lx): cannot emit fixup to `%s' in read-only section"
 msgstr ""
 
-#: elf32-sh.c:5101
+#: elf32-sh.c:5096
 msgid "%B(%A+0x%lx): %s relocation against external symbol \"%s\""
 msgstr ""
 
-#: elf32-sh.c:5574
+#: elf32-sh.c:5569
 #, c-format
 msgid "%X%C: relocation to \"%s\" references a different segment\n"
 msgstr ""
 
-#: elf32-sh.c:5580
+#: elf32-sh.c:5575
 #, c-format
 msgid "%C: warning: relocation to \"%s\" references a different segment\n"
 msgstr ""
 
-#: elf32-sh.c:6358 elf32-sh.c:6441
+#: elf32-sh.c:6353 elf32-sh.c:6436
 msgid "%B: `%s' accessed both as normal and FDPIC symbol"
 msgstr ""
 
-#: elf32-sh.c:6363 elf32-sh.c:6445
+#: elf32-sh.c:6358 elf32-sh.c:6440
 msgid "%B: `%s' accessed both as FDPIC and thread local symbol"
 msgstr ""
 
-#: elf32-sh.c:6393
+#: elf32-sh.c:6388
 msgid "%B: Function descriptor relocation with non-zero addend"
 msgstr ""
 
-#: elf32-sh.c:6629 elf64-alpha.c:4648
+#: elf32-sh.c:6624 elf64-alpha.c:4652
 msgid "%B: TLS local exec code cannot be linked into shared objects"
 msgstr ""
 
-#: elf32-sh64.c:223 elf64-sh64.c:2314
+#: elf32-sh64.c:223 elf64-sh64.c:2318
 #, c-format
 msgid "%s: compiled as 32-bit object and %s is 64-bit"
 msgstr ""
 
-#: elf32-sh64.c:226 elf64-sh64.c:2317
+#: elf32-sh64.c:226 elf64-sh64.c:2321
 #, c-format
 msgid "%s: compiled as 64-bit object and %s is 32-bit"
 msgstr ""
 
-#: elf32-sh64.c:228 elf64-sh64.c:2319
+#: elf32-sh64.c:228 elf64-sh64.c:2323
 #, c-format
 msgid "%s: object size does not match that of target %s"
 msgstr ""
 
-#: elf32-sh64.c:451 elf64-sh64.c:2833
+#: elf32-sh64.c:451 elf64-sh64.c:2837
 #, c-format
 msgid "%s: encountered datalabel symbol in input"
 msgstr ""
@@ -2272,11 +2291,11 @@
 msgid "%s: could not write out sorted .cranges entries"
 msgstr ""
 
-#: elf32-sparc.c:89
+#: elf32-sparc.c:90
 msgid "%B: compiled for a 64 bit system and target is 32 bit"
 msgstr ""
 
-#: elf32-sparc.c:102
+#: elf32-sparc.c:103
 msgid "%B: linking little endian files with big endian files"
 msgstr ""
 
@@ -2408,7 +2427,7 @@
 msgid "fatal error while creating .fixup"
 msgstr ""
 
-#: elf32-spu.c:5006
+#: elf32-spu.c:5008
 msgid "%B(%s+0x%lx): unresolvable %s relocation against symbol `%s'"
 msgstr ""
 
@@ -2420,43 +2439,43 @@
 msgid "warning: generating a shared library containing non-PID code"
 msgstr ""
 
-#: elf32-tic6x.c:2539
+#: elf32-tic6x.c:2541
 msgid "%B: SB-relative relocation but __c6xabi_DSBT_BASE not defined"
 msgstr ""
 
-#: elf32-tic6x.c:2759
+#: elf32-tic6x.c:2761
 msgid "dangerous relocation"
 msgstr ""
 
-#: elf32-tic6x.c:3740
+#: elf32-tic6x.c:3733
 msgid "%B: error: unknown mandatory EABI object attribute %d"
 msgstr ""
 
-#: elf32-tic6x.c:3748
+#: elf32-tic6x.c:3741
 msgid "%B: warning: unknown EABI object attribute %d"
 msgstr ""
 
-#: elf32-tic6x.c:3860 elf32-tic6x.c:3868
+#: elf32-tic6x.c:3853 elf32-tic6x.c:3861
 msgid "error: %B requires more stack alignment than %B preserves"
 msgstr ""
 
-#: elf32-tic6x.c:3878 elf32-tic6x.c:3887
+#: elf32-tic6x.c:3871 elf32-tic6x.c:3880
 msgid "error: unknown Tag_ABI_array_object_alignment value in %B"
 msgstr ""
 
-#: elf32-tic6x.c:3896 elf32-tic6x.c:3905
+#: elf32-tic6x.c:3889 elf32-tic6x.c:3898
 msgid "error: unknown Tag_ABI_array_object_align_expected value in %B"
 msgstr ""
 
-#: elf32-tic6x.c:3913 elf32-tic6x.c:3920
+#: elf32-tic6x.c:3906 elf32-tic6x.c:3913
 msgid "error: %B requires more array alignment than %B preserves"
 msgstr ""
 
-#: elf32-tic6x.c:3942
+#: elf32-tic6x.c:3935
 msgid "warning: %B and %B differ in wchar_t size"
 msgstr ""
 
-#: elf32-tic6x.c:3960
+#: elf32-tic6x.c:3953
 msgid "warning: %B and %B differ in whether code is compiled for DSBT"
 msgstr ""
 
@@ -2540,44 +2559,44 @@
 msgid "v850e2v3 architecture"
 msgstr ""
 
-#: elf32-vax.c:531
+#: elf32-vax.c:532
 #, c-format
 msgid " [nonpic]"
 msgstr ""
 
-#: elf32-vax.c:534
+#: elf32-vax.c:535
 #, c-format
 msgid " [d-float]"
 msgstr ""
 
-#: elf32-vax.c:537
+#: elf32-vax.c:538
 #, c-format
 msgid " [g-float]"
 msgstr ""
 
-#: elf32-vax.c:654
+#: elf32-vax.c:655
 #, c-format
 msgid ""
 "%s: warning: GOT addend of %ld to `%s' does not match previous GOT addend of "
 "%ld"
 msgstr ""
 
-#: elf32-vax.c:1587
+#: elf32-vax.c:1585
 #, c-format
 msgid "%s: warning: PLT addend of %d to `%s' from %s section ignored"
 msgstr ""
 
-#: elf32-vax.c:1714
+#: elf32-vax.c:1712
 #, c-format
 msgid "%s: warning: %s relocation against symbol `%s' from %s section"
 msgstr ""
 
-#: elf32-vax.c:1720
+#: elf32-vax.c:1718
 #, c-format
 msgid "%s: warning: %s relocation to 0x%x from %s section"
 msgstr ""
 
-#: elf32-xstormy16.c:451 elf32-ia64.c:2342 elf64-ia64.c:2342
+#: elf32-xstormy16.c:451 elf32-ia64.c:2336 elf64-ia64.c:2336
 msgid "non-zero addend in @fptr reloc"
 msgstr ""
 
@@ -2585,50 +2604,50 @@
 msgid "%B(%A): invalid property table"
 msgstr ""
 
-#: elf32-xtensa.c:2780
+#: elf32-xtensa.c:2777
 msgid "%B(%A+0x%lx): relocation offset out of range (size=0x%x)"
 msgstr ""
 
-#: elf32-xtensa.c:2859 elf32-xtensa.c:2980
+#: elf32-xtensa.c:2856 elf32-xtensa.c:2977
 msgid "dynamic relocation in read-only section"
 msgstr ""
 
-#: elf32-xtensa.c:2956
+#: elf32-xtensa.c:2953
 msgid "TLS relocation invalid without dynamic sections"
 msgstr ""
 
-#: elf32-xtensa.c:3173
+#: elf32-xtensa.c:3172
 msgid "internal inconsistency in size of .got.loc section"
 msgstr ""
 
-#: elf32-xtensa.c:3486
+#: elf32-xtensa.c:3485
 msgid "%B: incompatible machine type. Output is 0x%x. Input is 0x%x"
 msgstr ""
 
-#: elf32-xtensa.c:4715 elf32-xtensa.c:4723
+#: elf32-xtensa.c:4714 elf32-xtensa.c:4722
 msgid "Attempt to convert L32R/CALLX to CALL failed"
 msgstr ""
 
-#: elf32-xtensa.c:6333 elf32-xtensa.c:6409 elf32-xtensa.c:7525
+#: elf32-xtensa.c:6332 elf32-xtensa.c:6408 elf32-xtensa.c:7524
 msgid ""
 "%B(%A+0x%lx): could not decode instruction; possible configuration mismatch"
 msgstr ""
 
-#: elf32-xtensa.c:7265
+#: elf32-xtensa.c:7264
 msgid ""
 "%B(%A+0x%lx): could not decode instruction for XTENSA_ASM_SIMPLIFY "
 "relocation; possible configuration mismatch"
 msgstr ""
 
-#: elf32-xtensa.c:9024
+#: elf32-xtensa.c:9023
 msgid "invalid relocation address"
 msgstr ""
 
-#: elf32-xtensa.c:9073
+#: elf32-xtensa.c:9072
 msgid "overflow after relaxation"
 msgstr ""
 
-#: elf32-xtensa.c:10205
+#: elf32-xtensa.c:10204
 msgid "%B(%A+0x%lx): unexpected fix for %s relocation"
 msgstr ""
 
@@ -2636,27 +2655,27 @@
 msgid "GPDISP relocation did not find ldah and lda instructions"
 msgstr ""
 
-#: elf64-alpha.c:2495
+#: elf64-alpha.c:2497
 msgid "%B: .got subsegment exceeds 64K (size %d)"
 msgstr ""
 
-#: elf64-alpha.c:4392 elf64-alpha.c:4404
+#: elf64-alpha.c:4387 elf64-alpha.c:4399
 msgid "%B: gp-relative relocation against dynamic symbol %s"
 msgstr ""
 
-#: elf64-alpha.c:4430 elf64-alpha.c:4565
+#: elf64-alpha.c:4425 elf64-alpha.c:4565
 msgid "%B: pc-relative relocation against dynamic symbol %s"
 msgstr ""
 
-#: elf64-alpha.c:4458
+#: elf64-alpha.c:4453
 msgid "%B: change in gp: BRSGP %s"
 msgstr ""
 
-#: elf64-alpha.c:4483
+#: elf64-alpha.c:4478
 msgid "<unknown>"
 msgstr ""
 
-#: elf64-alpha.c:4488
+#: elf64-alpha.c:4483
 msgid "%B: !samegp reloc against symbol without .prologue: %s"
 msgstr ""
 
@@ -2668,24 +2687,38 @@
 msgid "%B: pc-relative relocation against undefined weak symbol %s"
 msgstr ""
 
-#: elf64-alpha.c:4632
+#: elf64-alpha.c:4636
 msgid "%B: dtp-relative relocation against dynamic symbol %s"
 msgstr ""
 
-#: elf64-alpha.c:4655
+#: elf64-alpha.c:4659
 msgid "%B: tp-relative relocation against dynamic symbol %s"
 msgstr ""
 
-#: elf64-hppa.c:2094
+#: elf64-hppa.c:2083
 #, c-format
 msgid "stub entry for %s cannot load .plt, dp offset = %ld"
 msgstr ""
 
-#: elf64-hppa.c:3292
-msgid "%B(%A+0x%lx): cannot reach %s"
+#: elf64-hppa.c:3275
+msgid "%B(%A+0x"
 msgstr ""
 
-#: elf64-mmix.c:1177
+#: elf64-mmix.c:1034
+msgid ""
+"invalid input relocation when producing non-ELF, non-mmo format output.\n"
+" Please use the objcopy program to convert from ELF or mmo,\n"
+" or assemble using \"-no-expand\" (for gcc, \"-Wa,-no-expand\""
+msgstr ""
+
+#: elf64-mmix.c:1218
+msgid ""
+"invalid input relocation when producing non-ELF, non-mmo format output.\n"
+" Please use the objcopy program to convert from ELF or mmo,\n"
+" or compile using the gcc-option \"-mno-base-addresses\"."
+msgstr ""
+
+#: elf64-mmix.c:1244
 #, c-format
 msgid ""
 "%s: Internal inconsistency error for value for\n"
@@ -2693,135 +2726,133 @@
 "%08lx\n"
 msgstr ""
 
-#: elf64-mmix.c:1607
+#: elf64-mmix.c:1670
 #, c-format
 msgid ""
 "%s: base-plus-offset relocation against register symbol: (unknown) in %s"
 msgstr ""
 
-#: elf64-mmix.c:1612
+#: elf64-mmix.c:1675
 #, c-format
 msgid "%s: base-plus-offset relocation against register symbol: %s in %s"
 msgstr ""
 
-#: elf64-mmix.c:1656
+#: elf64-mmix.c:1719
 #, c-format
 msgid "%s: register relocation against non-register symbol: (unknown) in %s"
 msgstr ""
 
-#: elf64-mmix.c:1661
+#: elf64-mmix.c:1724
 #, c-format
 msgid "%s: register relocation against non-register symbol: %s in %s"
 msgstr ""
 
-#: elf64-mmix.c:1698
+#: elf64-mmix.c:1761
 #, c-format
 msgid "%s: directive LOCAL valid only with a register or absolute value"
 msgstr ""
 
-#: elf64-mmix.c:1726
+#: elf64-mmix.c:1789
 #, c-format
 msgid ""
 "%s: LOCAL directive: Register $%ld is not a local register.  First global "
 "register is $%ld."
 msgstr ""
 
-#: elf64-mmix.c:2190
+#: elf64-mmix.c:2253
 #, c-format
 msgid ""
 "%s: Error: multiple definition of `%s'; start of %s is set in a earlier "
 "linked file\n"
 msgstr ""
 
-#: elf64-mmix.c:2248
+#: elf64-mmix.c:2311
 msgid "Register section has contents\n"
 msgstr ""
 
-#: elf64-mmix.c:2440
+#: elf64-mmix.c:2503
 #, c-format
 msgid ""
 "Internal inconsistency: remaining %u != max %u.\n"
 "  Please report this bug."
 msgstr ""
 
-#: elf64-ppc.c:2744 libbfd.c:1012
-msgid "%B: compiled for a big endian system and target is little endian"
+#: elf64-ppc.c:4185
+msgid "%P: %B: cannot create stub entry %s\n"
 msgstr ""
 
-#: elf64-ppc.c:2747 libbfd.c:1014
-msgid "%B: compiled for a little endian system and target is big endian"
-msgstr ""
-
-#: elf64-ppc.c:4160
-msgid "%B: cannot create stub entry %s\n"
-msgstr ""
-
-#: elf64-ppc.c:6484
-#, c-format
+#: elf64-ppc.c:6518
 msgid ""
-"copy reloc against `%s' requires lazy plt linking; avoid setting "
+"%P: copy reloc against `%s' requires lazy plt linking; avoid setting "
 "LD_BIND_NOW=1 or upgrade gcc\n"
 msgstr ""
 
-#: elf64-ppc.c:6912
-msgid "dynreloc miscount for %B, section %A\n"
+#: elf64-ppc.c:6788
+msgid "%B: undefined symbol on R_PPC64_TOCSAVE relocation"
 msgstr ""
 
-#: elf64-ppc.c:6996
+#: elf64-ppc.c:6992
+msgid "%P: dynreloc miscount for %B, section %A\n"
+msgstr ""
+
+#: elf64-ppc.c:7076
 msgid "%B: .opd is not a regular array of opd entries"
 msgstr ""
 
-#: elf64-ppc.c:7005
+#: elf64-ppc.c:7085
 msgid "%B: unexpected reloc type %u in .opd section"
 msgstr ""
 
-#: elf64-ppc.c:7026
+#: elf64-ppc.c:7106
 msgid "%B: undefined sym `%s' in .opd section"
 msgstr ""
 
-#: elf64-ppc.c:7584
+#: elf64-ppc.c:7664
 msgid "%H __tls_get_addr lost arg, TLS optimization disabled\n"
 msgstr ""
 
-#: elf64-ppc.c:7929 elf64-ppc.c:8450
+#: elf64-ppc.c:8003 elf64-ppc.c:8564
 #, c-format
 msgid "%s defined on removed toc entry"
 msgstr ""
 
-#: elf64-ppc.c:9474
-#, c-format
-msgid "cannot find opd entry toc for %s\n"
+#: elf64-ppc.c:8521
+msgid "%P: %H: %s relocation references optimized away TOC entry\n"
 msgstr ""
 
-#: elf64-ppc.c:9556
-#, c-format
-msgid "long branch stub `%s' offset overflow\n"
+#: elf64-ppc.c:9598
+msgid "%P: cannot find opd entry toc for %s\n"
 msgstr ""
 
-#: elf64-ppc.c:9615
-#, c-format
-msgid "can't find branch stub `%s'\n"
+#: elf64-ppc.c:9680
+msgid "%P: long branch stub `%s' offset overflow\n"
 msgstr ""
 
-#: elf64-ppc.c:9677 elf64-ppc.c:9819
-#, c-format
-msgid "linkage table error against `%s'\n"
+#: elf64-ppc.c:9739
+msgid "%P: can't find branch stub `%s'\n"
 msgstr ""
 
-#: elf64-ppc.c:9993
-#, c-format
-msgid "can't build branch stub `%s'\n"
+#: elf64-ppc.c:9801 elf64-ppc.c:9943
+msgid "%P: linkage table error against `%s'\n"
 msgstr ""
 
-#: elf64-ppc.c:10814
+#: elf64-ppc.c:10126
+msgid "%P: can't build branch stub `%s'\n"
+msgstr ""
+
+#: elf64-ppc.c:10941
 msgid "%B section %A exceeds stub group size"
 msgstr ""
 
-#: elf64-ppc.c:11457
-msgid "stubs don't match calculated size\n"
+#: elf64-ppc.c:11666 elf64-ppc.c:11699
+msgid "%P: %s offset too large for .eh_frame sdata4 encoding"
 msgstr ""
 
-#: elf64-ppc.c:11469
+#: elf64-ppc.c:11744
+msgid "%P: stubs don't match calculated size\n"
+msgstr ""
+
+#: elf64-ppc.c:11756
 #, c-format
 msgid ""
 "linker stubs in %u group%s\n"
@@ -2832,106 +2863,106 @@
 "  plt call     %lu"
 msgstr ""
 
-#: elf64-ppc.c:11819
-msgid "%H: %s used with TLS symbol %s\n"
+#: elf64-ppc.c:12042
+msgid "%P: %H: %s used with TLS symbol %s\n"
 msgstr ""
 
-#: elf64-ppc.c:11820
-msgid "%H: %s used with non-TLS symbol %s\n"
+#: elf64-ppc.c:12043
+msgid "%P: %H: %s used with non-TLS symbol %s\n"
 msgstr ""
 
-#: elf64-ppc.c:12318
+#: elf64-ppc.c:12556
 msgid ""
-"%H: automatic multiple TOCs not supported using your crt files; recompile "
-"with -mminimal-toc or upgrade gcc\n"
+"%P: %H: automatic multiple TOCs not supported using your crt files; "
+"recompile with -mminimal-toc or upgrade gcc\n"
 msgstr ""
 
-#: elf64-ppc.c:12324
+#: elf64-ppc.c:12562
 msgid ""
-"%H: sibling call optimization to `%s' does not allow automatic multiple "
+"%P: %H: sibling call optimization to `%s' does not allow automatic multiple "
 "TOCs; recompile with -mminimal-toc or -fno-optimize-sibling-calls, or make `"
 "%s' extern\n"
 msgstr ""
 
-#: elf64-ppc.c:13041
-msgid "%B: relocation %s is not supported for symbol %s\n"
+#: elf64-ppc.c:13286
+msgid "%P: %B: relocation %s is not supported for symbol %s\n"
 msgstr ""
 
-#: elf64-ppc.c:13218
-msgid "%H: error: %s not a multiple of %u\n"
+#: elf64-ppc.c:13446
+msgid "%P: %H: error: %s not a multiple of %u\n"
 msgstr ""
 
-#: elf64-sh64.c:1682
+#: elf64-sh64.c:1686
 #, c-format
 msgid "%s: error: unaligned relocation type %d at %08x reloc %08x\n"
 msgstr ""
 
-#: elf64-sparc.c:445
+#: elf64-sparc.c:446
 msgid "%B: Only registers %%g[2367] can be declared using STT_REGISTER"
 msgstr ""
 
-#: elf64-sparc.c:465
+#: elf64-sparc.c:466
 msgid "Register %%g%d used incompatibly: %s in %B, previously %s in %B"
 msgstr ""
 
-#: elf64-sparc.c:488
+#: elf64-sparc.c:489
 msgid "Symbol `%s' has differing types: REGISTER in %B, previously %s in %B"
 msgstr ""
 
-#: elf64-sparc.c:533
+#: elf64-sparc.c:534
 msgid "Symbol `%s' has differing types: %s in %B, previously REGISTER in %B"
 msgstr ""
 
-#: elf64-sparc.c:686
+#: elf64-sparc.c:687
 msgid "%B: linking UltraSPARC specific with HAL specific code"
 msgstr ""
 
-#: elf64-x86-64.c:1236
+#: elf64-x86-64.c:1427
 msgid "%B: relocation %s against symbol `%s' isn't supported in x32 mode"
 msgstr ""
 
-#: elf64-x86-64.c:1465
+#: elf64-x86-64.c:1656
 msgid "%B: '%s' accessed both as normal and thread local symbol"
 msgstr ""
 
-#: elf64-x86-64.c:2934
+#: elf64-x86-64.c:3150
 msgid ""
 "%B: relocation %s against STT_GNU_IFUNC symbol `%s' has non-zero addend: %d"
 msgstr ""
 
-#: elf64-x86-64.c:3193
+#: elf64-x86-64.c:3411
 msgid ""
 "%B: relocation R_X86_64_GOTOFF64 against protected function `%s' can not be "
 "used when making a shared object"
 msgstr ""
 
-#: elf64-x86-64.c:3305
+#: elf64-x86-64.c:3523
 msgid "; recompile with -fPIC"
 msgstr ""
 
-#: elf64-x86-64.c:3310
+#: elf64-x86-64.c:3528
 msgid ""
 "%B: relocation %s against %s `%s' can not be used when making a shared object"
 "%s"
 msgstr ""
 
-#: elf64-x86-64.c:3312
+#: elf64-x86-64.c:3530
 msgid ""
 "%B: relocation %s against undefined %s `%s' can not be used when making a "
 "shared object%s"
 msgstr ""
 
-#: elfcode.h:827
+#: elfcode.h:767
 #, c-format
 msgid "warning: %s has a corrupt string table index - ignoring"
 msgstr ""
 
-#: elfcode.h:1237
+#: elfcode.h:1177
 #, c-format
 msgid "%s: version count (%ld) does not match symbol count (%ld)"
 msgstr ""
 
-#: elfcode.h:1491
+#: elfcode.h:1431
 #, c-format
 msgid "%s(%s): relocation %d has invalid symbol index %ld"
 msgstr ""
@@ -2940,377 +2971,387 @@
 msgid "Warning: %B is truncated: expected core file size >= %lu, found: %lu."
 msgstr ""
 
-#: elflink.c:1119
+#: elflink.c:1117
 msgid ""
 "%s: TLS definition in %B section %A mismatches non-TLS definition in %B "
 "section %A"
 msgstr ""
 
-#: elflink.c:1123
+#: elflink.c:1121
 msgid "%s: TLS reference in %B mismatches non-TLS reference in %B"
 msgstr ""
 
-#: elflink.c:1127
+#: elflink.c:1125
 msgid "%s: TLS definition in %B section %A mismatches non-TLS reference in %B"
 msgstr ""
 
-#: elflink.c:1131
+#: elflink.c:1129
 msgid "%s: TLS reference in %B mismatches non-TLS definition in %B section %A"
 msgstr ""
 
-#: elflink.c:1764
+#: elflink.c:1762
 msgid "%B: unexpected redefinition of indirect versioned symbol `%s'"
 msgstr ""
 
-#: elflink.c:2077
+#: elflink.c:2063
 msgid "%B: version node not found for symbol %s"
 msgstr ""
 
-#: elflink.c:2167
+#: elflink.c:2154
 msgid ""
 "%B: bad reloc symbol index (0x%lx >= 0x%lx) for offset 0x%lx in section `%A'"
 msgstr ""
 
-#: elflink.c:2178
+#: elflink.c:2165
 msgid ""
 "%B: non-zero symbol index (0x%lx) for offset 0x%lx in section `%A' when the "
 "object file has no symbol table"
 msgstr ""
 
-#: elflink.c:2368
+#: elflink.c:2355
 msgid "%B: relocation size mismatch in %B section %A"
 msgstr ""
 
-#: elflink.c:2663
+#: elflink.c:2639
 #, c-format
 msgid "warning: type and size of dynamic symbol `%s' are not defined"
 msgstr ""
 
-#: elflink.c:3421
+#: elflink.c:3391
 msgid "%P: alternate ELF machine code found (%d) in %B, expecting %d\n"
 msgstr ""
 
-#: elflink.c:4067
+#: elflink.c:4037
 msgid "%B: %s: invalid version %u (max %d)"
 msgstr ""
 
-#: elflink.c:4103
+#: elflink.c:4073
 msgid "%B: %s: invalid needed version %d"
 msgstr ""
 
-#: elflink.c:4299
+#: elflink.c:4269
 msgid ""
 "Warning: alignment %u of common symbol `%s' in %B is greater than the "
 "alignment (%u) of its section %A"
 msgstr ""
 
-#: elflink.c:4305
+#: elflink.c:4275
 msgid "Warning: alignment %u of symbol `%s' in %B is smaller than %u in %B"
 msgstr ""
 
-#: elflink.c:4320
+#: elflink.c:4290
 msgid "Warning: size of symbol `%s' changed from %lu in %B to %lu in %B"
 msgstr ""
 
-#: elflink.c:4489
+#: elflink.c:4463
 msgid "%B: undefined reference to symbol '%s'"
 msgstr ""
 
-#: elflink.c:4492
+#: elflink.c:4466
 msgid ""
 "note: '%s' is defined in DSO %B so try adding it to the linker command line"
 msgstr ""
 
-#: elflink.c:5795
+#: elflink.c:5781
 #, c-format
 msgid "%s: undefined version: %s"
 msgstr ""
 
-#: elflink.c:5863
+#: elflink.c:5849
 msgid "%B: .preinit_array section is not allowed in DSO"
 msgstr ""
 
-#: elflink.c:7617
+#: elflink.c:7604
 #, c-format
 msgid "undefined %s reference in complex symbol: %s"
 msgstr ""
 
-#: elflink.c:7771
+#: elflink.c:7758
 #, c-format
 msgid "unknown operator '%c' in complex symbol"
 msgstr ""
 
-#: elflink.c:8110 elflink.c:8127 elflink.c:8164 elflink.c:8181
+#: elflink.c:8097 elflink.c:8114 elflink.c:8151 elflink.c:8168
 msgid "%B: Unable to sort relocs - they are in more than one size"
 msgstr ""
 
-#: elflink.c:8141 elflink.c:8195
+#: elflink.c:8128 elflink.c:8182
 msgid "%B: Unable to sort relocs - they are of an unknown size"
 msgstr ""
 
-#: elflink.c:8246
+#: elflink.c:8233
 msgid "Not enough memory to sort relocations"
 msgstr ""
 
-#: elflink.c:8439
+#: elflink.c:8426
 msgid "%B: Too many sections: %d (>= %d)"
 msgstr ""
 
-#: elflink.c:8686
+#: elflink.c:8675
 msgid "%B: internal symbol `%s' in %B is referenced by DSO"
 msgstr ""
 
-#: elflink.c:8688
+#: elflink.c:8677
 msgid "%B: hidden symbol `%s' in %B is referenced by DSO"
 msgstr ""
 
-#: elflink.c:8690
+#: elflink.c:8679
 msgid "%B: local symbol `%s' in %B is referenced by DSO"
 msgstr ""
 
-#: elflink.c:8785
+#: elflink.c:8776
 msgid "%B: could not find output section %A for input section %A"
 msgstr ""
 
-#: elflink.c:8908
+#: elflink.c:8899
 msgid "%B: protected symbol `%s' isn't defined"
 msgstr ""
 
-#: elflink.c:8910
+#: elflink.c:8901
 msgid "%B: internal symbol `%s' isn't defined"
 msgstr ""
 
-#: elflink.c:8912
+#: elflink.c:8903
 msgid "%B: hidden symbol `%s' isn't defined"
 msgstr ""
 
-#: elflink.c:9441
+#: elflink.c:9432
 msgid "error: %B: size of section %A is not multiple of address size"
 msgstr ""
 
-#: elflink.c:9488
+#: elflink.c:9479
 msgid ""
 "error: %B contains a reloc (0x%s) for section %A that references a non-"
 "existent global symbol"
 msgstr ""
 
-#: elflink.c:10223
+#: elflink.c:10214
 msgid "%A has both ordered [`%A' in %B] and unordered [`%A' in %B] sections"
 msgstr ""
 
-#: elflink.c:10228
+#: elflink.c:10219
 #, c-format
 msgid "%A has both ordered and unordered sections"
 msgstr ""
 
-#: elflink.c:10793
+#: elflink.c:10784
 msgid "%B: file class %s incompatible with %s"
 msgstr ""
 
-#: elflink.c:11104 elflink.c:11148
+#: elflink.c:11093 elflink.c:11137
 msgid "%B: could not find output section %s"
 msgstr ""
 
-#: elflink.c:11109
+#: elflink.c:11098
 #, c-format
 msgid "warning: %s section has zero size"
 msgstr ""
 
-#: elflink.c:11214
+#: elflink.c:11143
+#, c-format
+msgid "warning: section '%s' is being made into a note"
+msgstr ""
+
+#: elflink.c:11212
+msgid "%P%X: read-only segment has dynamic relocations.\n"
+msgstr ""
+
+#: elflink.c:11215
 msgid "%P: warning: creating a DT_TEXTREL in a shared object.\n"
 msgstr ""
 
-#: elflink.c:11401
+#: elflink.c:11402
 msgid "%P%X: can not read symbols: %E\n"
 msgstr ""
 
-#: elflink.c:11750
+#: elflink.c:11792
 msgid "Removing unused section '%s' in file '%B'"
 msgstr ""
 
-#: elflink.c:11962
+#: elflink.c:11998
 msgid "Warning: gc-sections option ignored"
 msgstr ""
 
-#: elflink.c:12511
-msgid "%B: ignoring duplicate section `%A'"
+#: elflink.c:12277
+#, c-format
+msgid "Unrecognized INPUT_SECTION_FLAG %s\n"
 msgstr ""
 
-#: elflink.c:12518 elflink.c:12525
-msgid "%B: duplicate section `%A' has different size"
-msgstr ""
-
-#: elflink.c:12533 elflink.c:12538
-msgid "%B: warning: could not read contents of section `%A'"
-msgstr ""
-
-#: elflink.c:12542
-msgid "%B: warning: duplicate section `%A' has different contents"
-msgstr ""
-
-#: elflink.c:12643 linker.c:3086
-msgid "%F%P: already_linked_table: %E\n"
-msgstr ""
-
-#: elfxx-mips.c:1221
+#: elfxx-mips.c:1234
 msgid "static procedure (no name)"
 msgstr ""
 
-#: elfxx-mips.c:5628
+#: elfxx-mips.c:5259
+msgid "MIPS16 and microMIPS functions cannot call each other"
+msgstr ""
+
+#: elfxx-mips.c:5856
 msgid ""
 "%B: %A+0x%lx: Direct jumps between ISA modes are not allowed; consider "
 "recompiling with interlinking enabled."
 msgstr ""
 
-#: elfxx-mips.c:6288 elfxx-mips.c:6511
+#: elfxx-mips.c:6519 elfxx-mips.c:6742
 msgid "%B: Warning: bad `%s' option size %u smaller than its header"
 msgstr ""
 
-#: elfxx-mips.c:7262 elfxx-mips.c:7387
+#: elfxx-mips.c:7495 elfxx-mips.c:7620
 msgid "%B: Warning: cannot determine the target function for stub section `%s'"
 msgstr ""
 
-#: elfxx-mips.c:7516
+#: elfxx-mips.c:7749
 msgid "%B: Malformed reloc detected for section %s"
 msgstr ""
 
-#: elfxx-mips.c:7556
+#: elfxx-mips.c:7801
 msgid "%B: GOT reloc at 0x%lx not expected in executables"
 msgstr ""
 
-#: elfxx-mips.c:7678
+#: elfxx-mips.c:7930
 msgid "%B: CALL16 reloc at 0x%lx not against global symbol"
 msgstr ""
 
-#: elfxx-mips.c:8372
+#: elfxx-mips.c:8645
 #, c-format
 msgid "non-dynamic relocations refer to dynamic symbol %s"
 msgstr ""
 
-#: elfxx-mips.c:9075
+#: elfxx-mips.c:9347
 msgid ""
 "%B: Can't find matching LO16 reloc against `%s' for %s at 0x%lx in section `"
 "%A'"
 msgstr ""
 
-#: elfxx-mips.c:9214
+#: elfxx-mips.c:9486
 msgid ""
 "small-data section exceeds 64KB; lower small-data size limit (see option -G)"
 msgstr ""
 
-#: elfxx-mips.c:12038
+#: elfxx-mips.c:9505
+msgid "JALX to a non-word-aligned address"
+msgstr ""
+
+#: elfxx-mips.c:13266
 #, c-format
 msgid "%s: illegal section name `%s'"
 msgstr ""
 
-#: elfxx-mips.c:12417 elfxx-mips.c:12443
+#: elfxx-mips.c:13645 elfxx-mips.c:13671
 msgid "Warning: %B uses -msingle-float, %B uses -mdouble-float"
 msgstr ""
 
-#: elfxx-mips.c:12429 elfxx-mips.c:12485
+#: elfxx-mips.c:13657 elfxx-mips.c:13713
 msgid "Warning: %B uses -msingle-float, %B uses -mips32r2 -mfp64"
 msgstr ""
 
-#: elfxx-mips.c:12455 elfxx-mips.c:12491
+#: elfxx-mips.c:13683 elfxx-mips.c:13719
 msgid "Warning: %B uses -mdouble-float, %B uses -mips32r2 -mfp64"
 msgstr ""
 
-#: elfxx-mips.c:12533
+#: elfxx-mips.c:13761
 msgid "%B: endianness incompatible with that of the selected emulation"
 msgstr ""
 
-#: elfxx-mips.c:12544
+#: elfxx-mips.c:13772
 msgid "%B: ABI is incompatible with that of the selected emulation"
 msgstr ""
 
-#: elfxx-mips.c:12628
+#: elfxx-mips.c:13856
 msgid "%B: warning: linking abicalls files with non-abicalls files"
 msgstr ""
 
-#: elfxx-mips.c:12645
+#: elfxx-mips.c:13873
 msgid "%B: linking 32-bit code with 64-bit code"
 msgstr ""
 
-#: elfxx-mips.c:12673
+#: elfxx-mips.c:13901
 msgid "%B: linking %s module with previous %s modules"
 msgstr ""
 
-#: elfxx-mips.c:12696
+#: elfxx-mips.c:13924
 msgid "%B: ABI mismatch: linking %s module with previous %s modules"
 msgstr ""
 
-#: elfxx-mips.c:12860
+#: elfxx-mips.c:13948
+msgid "%B: ASE mismatch: linking %s module with previous %s modules"
+msgstr ""
+
+#: elfxx-mips.c:14106
 #, c-format
 msgid " [abi=O32]"
 msgstr ""
 
-#: elfxx-mips.c:12862
+#: elfxx-mips.c:14108
 #, c-format
 msgid " [abi=O64]"
 msgstr ""
 
-#: elfxx-mips.c:12864
+#: elfxx-mips.c:14110
 #, c-format
 msgid " [abi=EABI32]"
 msgstr ""
 
-#: elfxx-mips.c:12866
+#: elfxx-mips.c:14112
 #, c-format
 msgid " [abi=EABI64]"
 msgstr ""
 
-#: elfxx-mips.c:12868
+#: elfxx-mips.c:14114
 #, c-format
 msgid " [abi unknown]"
 msgstr ""
 
-#: elfxx-mips.c:12870
+#: elfxx-mips.c:14116
 #, c-format
 msgid " [abi=N32]"
 msgstr ""
 
-#: elfxx-mips.c:12872
+#: elfxx-mips.c:14118
 #, c-format
 msgid " [abi=64]"
 msgstr ""
 
-#: elfxx-mips.c:12874
+#: elfxx-mips.c:14120
 #, c-format
 msgid " [no abi set]"
 msgstr ""
 
-#: elfxx-mips.c:12895
+#: elfxx-mips.c:14141
 #, c-format
 msgid " [unknown ISA]"
 msgstr ""
 
-#: elfxx-mips.c:12906
+#: elfxx-mips.c:14155
 #, c-format
 msgid " [not 32bitmode]"
 msgstr ""
 
-#: elfxx-sparc.c:595
+#: elfxx-sparc.c:596
 #, c-format
 msgid "invalid relocation type %d"
 msgstr ""
 
-#: i386linux.c:454 m68klinux.c:458 sparclinux.c:452
+#: elfxx-tilegx.c:3952
+msgid "%B: Cannot link together %s and %s objects."
+msgstr ""
+
+#: i386linux.c:451 m68klinux.c:456 sparclinux.c:450
 #, c-format
 msgid "Output file requires shared library `%s'\n"
 msgstr ""
 
-#: i386linux.c:462 m68klinux.c:466 sparclinux.c:460
+#: i386linux.c:459 m68klinux.c:464 sparclinux.c:458
 #, c-format
 msgid "Output file requires shared library `%s.so.%s'\n"
 msgstr ""
 
-#: i386linux.c:651 i386linux.c:701 m68klinux.c:658 m68klinux.c:706
-#: sparclinux.c:650 sparclinux.c:700
+#: i386linux.c:648 i386linux.c:698 m68klinux.c:656 m68klinux.c:704
+#: sparclinux.c:648 sparclinux.c:698
 #, c-format
 msgid "Symbol %s not defined for fixups\n"
 msgstr ""
 
-#: i386linux.c:725 m68klinux.c:730 sparclinux.c:724
+#: i386linux.c:722 m68klinux.c:728 sparclinux.c:722
 msgid "Warning: fixup count mismatch\n"
 msgstr ""
 
@@ -3381,6 +3422,14 @@
 msgid "%B: unable to get decompressed section %A"
 msgstr ""
 
+#: libbfd.c:1012
+msgid "%B: compiled for a big endian system and target is little endian"
+msgstr ""
+
+#: libbfd.c:1014
+msgid "%B: compiled for a little endian system and target is big endian"
+msgstr ""
+
 #: libbfd.c:1043
 #, c-format
 msgid "Deprecated %s called at %s line %d in %s\n"
@@ -3391,140 +3440,148 @@
 msgid "Deprecated %s called\n"
 msgstr ""
 
-#: linker.c:1859
+#: linker.c:1872
 msgid "%B: indirect symbol `%s' to `%s' is a loop"
 msgstr ""
 
-#: linker.c:2726
+#: linker.c:2736
 #, c-format
 msgid "Attempt to do relocatable link with %s input and %s output"
 msgstr ""
 
-#: linker.c:3053
-msgid "%B: warning: ignoring duplicate section `%A'\n"
+#: linker.c:3021
+msgid "%B: ignoring duplicate section `%A'\n"
 msgstr ""
 
-#: linker.c:3067
-msgid "%B: warning: duplicate section `%A' has different size\n"
+#: linker.c:3030 linker.c:3039
+msgid "%B: duplicate section `%A' has different size\n"
 msgstr ""
 
-#: mach-o.c:381
+#: linker.c:3047 linker.c:3052
+msgid "%B: could not read contents of section `%A'\n"
+msgstr ""
+
+#: linker.c:3056
+msgid "%B: duplicate section `%A' has different contents\n"
+msgstr ""
+
+#: mach-o.c:407
 msgid "bfd_mach_o_canonicalize_symtab: unable to load symbols"
 msgstr ""
 
-#: mach-o.c:1253
+#: mach-o.c:1301
 #, c-format
 msgid "unable to write unknown load command 0x%lx"
 msgstr ""
 
-#: mach-o.c:1654
+#: mach-o.c:1789
 #, c-format
 msgid "bfd_mach_o_read_symtab_symbol: unable to read %d bytes at %lu"
 msgstr ""
 
-#: mach-o.c:1671
+#: mach-o.c:1807
 #, c-format
-msgid "bfd_mach_o_read_symtab_symbol: symbol name out of range (%lu >= %lu)"
+msgid "bfd_mach_o_read_symtab_symbol: name out of range (%lu >= %lu)"
 msgstr ""
 
-#: mach-o.c:1756
+#: mach-o.c:1892
 #, c-format
 msgid ""
 "bfd_mach_o_read_symtab_symbol: symbol \"%s\" specified invalid section %d "
 "(max %lu): setting to undefined"
 msgstr ""
 
-#: mach-o.c:1764
+#: mach-o.c:1900
 #, c-format
 msgid ""
 "bfd_mach_o_read_symtab_symbol: symbol \"%s\" is unsupported 'indirect' "
 "reference: setting to undefined"
 msgstr ""
 
-#: mach-o.c:1770
+#: mach-o.c:1906
 #, c-format
 msgid ""
 "bfd_mach_o_read_symtab_symbol: symbol \"%s\" specified invalid type field 0x"
 "%x: setting to undefined"
 msgstr ""
 
-#: mach-o.c:1840
+#: mach-o.c:1979
 msgid "bfd_mach_o_read_symtab_symbols: unable to allocate memory for symbols"
 msgstr ""
 
-#: mach-o.c:1874
+#: mach-o.c:2014
 #, c-format
 msgid "bfd_mach_o_read_dysymtab_symbol: unable to read %lu bytes at %lu"
 msgstr ""
 
-#: mach-o.c:2556
+#: mach-o.c:2734
 #, c-format
 msgid "unable to read unknown load command 0x%lx"
 msgstr ""
 
-#: mach-o.c:2736
+#: mach-o.c:2915
 #, c-format
 msgid "bfd_mach_o_scan: unknown architecture 0x%lx/0x%lx"
 msgstr ""
 
-#: mach-o.c:2832
+#: mach-o.c:3011
 #, c-format
 msgid "unknown header byte-order value 0x%lx"
 msgstr ""
 
-#: mach-o.c:3402
+#: mach-o.c:3577
 msgid "Mach-O header:\n"
 msgstr ""
 
-#: mach-o.c:3403
+#: mach-o.c:3578
 #, c-format
 msgid " magic     : %08lx\n"
 msgstr ""
 
-#: mach-o.c:3404
+#: mach-o.c:3579
 #, c-format
 msgid " cputype   : %08lx (%s)\n"
 msgstr ""
 
-#: mach-o.c:3406
+#: mach-o.c:3581
 #, c-format
 msgid " cpusubtype: %08lx\n"
 msgstr ""
 
-#: mach-o.c:3407
+#: mach-o.c:3582
 #, c-format
 msgid " filetype  : %08lx (%s)\n"
 msgstr ""
 
-#: mach-o.c:3410
+#: mach-o.c:3585
 #, c-format
 msgid " ncmds     : %08lx (%lu)\n"
 msgstr ""
 
-#: mach-o.c:3411
+#: mach-o.c:3586
 #, c-format
 msgid " sizeofcmds: %08lx\n"
 msgstr ""
 
-#: mach-o.c:3412
+#: mach-o.c:3587
 #, c-format
 msgid " flags     : %08lx ("
 msgstr ""
 
-#: mach-o.c:3414 vms-alpha.c:7671
+#: mach-o.c:3589 vms-alpha.c:7674
 msgid ")\n"
 msgstr ""
 
-#: mach-o.c:3415
+#: mach-o.c:3590
 #, c-format
 msgid " reserved  : %08x\n"
 msgstr ""
 
-#: mach-o.c:3425
+#: mach-o.c:3600
 msgid "Segments and Sections:\n"
 msgstr ""
 
-#: mach-o.c:3426
+#: mach-o.c:3601
 msgid " #: Segment name     Section name     Address\n"
 msgstr ""
 
@@ -3705,7 +3762,7 @@
 msgid "%B: bad pair/reflo after refhi\n"
 msgstr ""
 
-#: pef.c:519
+#: pef.c:520
 #, c-format
 msgid "bfd_pef_scan: unknown architecture 0x%lx"
 msgstr ""
@@ -3741,21 +3798,21 @@
 msgid "%B: Unrecognised import name type; %x"
 msgstr ""
 
-#: peicode.h:1162
+#: peicode.h:1166
 msgid "%B: Unrecognised machine type (0x%x) in Import Library Format archive"
 msgstr ""
 
-#: peicode.h:1174
+#: peicode.h:1178
 msgid ""
 "%B: Recognised but unhandled machine type (0x%x) in Import Library Format "
 "archive"
 msgstr ""
 
-#: peicode.h:1192
+#: peicode.h:1196
 msgid "%B: size field is zero in Import Library Format header"
 msgstr ""
 
-#: peicode.h:1223
+#: peicode.h:1227
 msgid "%B: string not null terminated in ILF object file."
 msgstr ""
 
@@ -3808,6 +3865,10 @@
 msgid "Partition[%d] length = 0x%.8lx (%ld)\n"
 msgstr ""
 
+#: reloc.c:6160
+msgid "INPUT_SECTION_FLAGS are not supported.\n"
+msgstr ""
+
 #: rs6000-core.c:448
 #, c-format
 msgid "%s: warning core file truncated"
@@ -3909,1821 +3970,1825 @@
 msgid "SEC_RELOC with no relocs in section %s"
 msgstr ""
 
-#: vms-alpha.c:3822 vms-alpha.c:4053
+#: vms-alpha.c:3822 vms-alpha.c:4049
 #, c-format
 msgid "Size error in section %s"
 msgstr ""
 
-#: vms-alpha.c:3992
+#: vms-alpha.c:3991
 msgid "Spurious ALPHA_R_BSR reloc"
 msgstr ""
 
-#: vms-alpha.c:4040
+#: vms-alpha.c:4036
 #, c-format
 msgid "Unhandled relocation %s"
 msgstr ""
 
-#: vms-alpha.c:4330
+#: vms-alpha.c:4326
 #, c-format
 msgid "unknown source command %d"
 msgstr ""
 
-#: vms-alpha.c:4391
+#: vms-alpha.c:4387
 msgid "DST__K_SET_LINUM_INCR not implemented"
 msgstr ""
 
-#: vms-alpha.c:4397
+#: vms-alpha.c:4393
 msgid "DST__K_SET_LINUM_INCR_W not implemented"
 msgstr ""
 
-#: vms-alpha.c:4403
+#: vms-alpha.c:4399
 msgid "DST__K_RESET_LINUM_INCR not implemented"
 msgstr ""
 
-#: vms-alpha.c:4409
+#: vms-alpha.c:4405
 msgid "DST__K_BEG_STMT_MODE not implemented"
 msgstr ""
 
-#: vms-alpha.c:4415
+#: vms-alpha.c:4411
 msgid "DST__K_END_STMT_MODE not implemented"
 msgstr ""
 
-#: vms-alpha.c:4442
+#: vms-alpha.c:4438
 msgid "DST__K_SET_PC not implemented"
 msgstr ""
 
-#: vms-alpha.c:4448
+#: vms-alpha.c:4444
 msgid "DST__K_SET_PC_W not implemented"
 msgstr ""
 
-#: vms-alpha.c:4454
+#: vms-alpha.c:4450
 msgid "DST__K_SET_PC_L not implemented"
 msgstr ""
 
-#: vms-alpha.c:4460
+#: vms-alpha.c:4456
 msgid "DST__K_SET_STMTNUM not implemented"
 msgstr ""
 
-#: vms-alpha.c:4503
+#: vms-alpha.c:4499
 #, c-format
 msgid "unknown line command %d"
 msgstr ""
 
-#: vms-alpha.c:4957 vms-alpha.c:4974 vms-alpha.c:4988 vms-alpha.c:5003
-#: vms-alpha.c:5015 vms-alpha.c:5026 vms-alpha.c:5038
+#: vms-alpha.c:4953 vms-alpha.c:4970 vms-alpha.c:4984 vms-alpha.c:4999
+#: vms-alpha.c:5011 vms-alpha.c:5022 vms-alpha.c:5034
 #, c-format
 msgid "Unknown reloc %s + %s"
 msgstr ""
 
-#: vms-alpha.c:5093
+#: vms-alpha.c:5089
 #, c-format
 msgid "Unknown reloc %s"
 msgstr ""
 
-#: vms-alpha.c:5106
+#: vms-alpha.c:5102
 msgid "Invalid section index in ETIR"
 msgstr ""
 
-#: vms-alpha.c:5153
+#: vms-alpha.c:5109
+msgid "Relocation for non-REL psect"
+msgstr ""
+
+#: vms-alpha.c:5156
 #, c-format
 msgid "Unknown symbol in command %s"
 msgstr ""
 
-#: vms-alpha.c:5668
+#: vms-alpha.c:5671
 #, c-format
 msgid "  EMH %u (len=%u): "
 msgstr ""
 
-#: vms-alpha.c:5677
+#: vms-alpha.c:5680
 #, c-format
 msgid "Module header\n"
 msgstr ""
 
-#: vms-alpha.c:5678
+#: vms-alpha.c:5681
 #, c-format
 msgid "   structure level: %u\n"
 msgstr ""
 
-#: vms-alpha.c:5679
+#: vms-alpha.c:5682
 #, c-format
 msgid "   max record size: %u\n"
 msgstr ""
 
-#: vms-alpha.c:5682
+#: vms-alpha.c:5685
 #, c-format
 msgid "   module name    : %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:5684
+#: vms-alpha.c:5687
 #, c-format
 msgid "   module version : %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:5686
+#: vms-alpha.c:5689
 #, c-format
 msgid "   compile date   : %.17s\n"
 msgstr ""
 
-#: vms-alpha.c:5691
+#: vms-alpha.c:5694
 #, c-format
 msgid "Language Processor Name\n"
 msgstr ""
 
-#: vms-alpha.c:5692
+#: vms-alpha.c:5695
 #, c-format
 msgid "   language name: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:5699
+#: vms-alpha.c:5702
 #, c-format
 msgid "Source Files Header\n"
 msgstr ""
 
-#: vms-alpha.c:5700
+#: vms-alpha.c:5703
 #, c-format
 msgid "   file: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:5707
+#: vms-alpha.c:5710
 #, c-format
 msgid "Title Text Header\n"
 msgstr ""
 
-#: vms-alpha.c:5708
+#: vms-alpha.c:5711
 #, c-format
 msgid "   title: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:5715
+#: vms-alpha.c:5718
 #, c-format
 msgid "Copyright Header\n"
 msgstr ""
 
-#: vms-alpha.c:5716
+#: vms-alpha.c:5719
 #, c-format
 msgid "   copyright: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:5722
+#: vms-alpha.c:5725
 #, c-format
 msgid "unhandled emh subtype %u\n"
 msgstr ""
 
-#: vms-alpha.c:5732
+#: vms-alpha.c:5735
 #, c-format
 msgid "  EEOM (len=%u):\n"
 msgstr ""
 
-#: vms-alpha.c:5733
+#: vms-alpha.c:5736
 #, c-format
 msgid "   number of cond linkage pairs: %u\n"
 msgstr ""
 
-#: vms-alpha.c:5735
+#: vms-alpha.c:5738
 #, c-format
 msgid "   completion code: %u\n"
 msgstr ""
 
-#: vms-alpha.c:5739
+#: vms-alpha.c:5742
 #, c-format
 msgid "   transfer addr flags: 0x%02x\n"
 msgstr ""
 
-#: vms-alpha.c:5740
+#: vms-alpha.c:5743
 #, c-format
 msgid "   transfer addr psect: %u\n"
 msgstr ""
 
-#: vms-alpha.c:5742
+#: vms-alpha.c:5745
 #, c-format
 msgid "   transfer address   : 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:5751
+#: vms-alpha.c:5754
 msgid " WEAK"
 msgstr ""
 
-#: vms-alpha.c:5753
+#: vms-alpha.c:5756
 msgid " DEF"
 msgstr ""
 
-#: vms-alpha.c:5755
+#: vms-alpha.c:5758
 msgid " UNI"
 msgstr ""
 
-#: vms-alpha.c:5757 vms-alpha.c:5778
+#: vms-alpha.c:5760 vms-alpha.c:5781
 msgid " REL"
 msgstr ""
 
-#: vms-alpha.c:5759
+#: vms-alpha.c:5762
 msgid " COMM"
 msgstr ""
 
-#: vms-alpha.c:5761
+#: vms-alpha.c:5764
 msgid " VECEP"
 msgstr ""
 
-#: vms-alpha.c:5763
+#: vms-alpha.c:5766
 msgid " NORM"
 msgstr ""
 
-#: vms-alpha.c:5765
+#: vms-alpha.c:5768
 msgid " QVAL"
 msgstr ""
 
-#: vms-alpha.c:5772
+#: vms-alpha.c:5775
 msgid " PIC"
 msgstr ""
 
-#: vms-alpha.c:5774
+#: vms-alpha.c:5777
 msgid " LIB"
 msgstr ""
 
-#: vms-alpha.c:5776
+#: vms-alpha.c:5779
 msgid " OVR"
 msgstr ""
 
-#: vms-alpha.c:5780
+#: vms-alpha.c:5783
 msgid " GBL"
 msgstr ""
 
-#: vms-alpha.c:5782
+#: vms-alpha.c:5785
 msgid " SHR"
 msgstr ""
 
-#: vms-alpha.c:5784
+#: vms-alpha.c:5787
 msgid " EXE"
 msgstr ""
 
-#: vms-alpha.c:5786
+#: vms-alpha.c:5789
 msgid " RD"
 msgstr ""
 
-#: vms-alpha.c:5788
+#: vms-alpha.c:5791
 msgid " WRT"
 msgstr ""
 
-#: vms-alpha.c:5790
+#: vms-alpha.c:5793
 msgid " VEC"
 msgstr ""
 
-#: vms-alpha.c:5792
+#: vms-alpha.c:5795
 msgid " NOMOD"
 msgstr ""
 
-#: vms-alpha.c:5794
+#: vms-alpha.c:5797
 msgid " COM"
 msgstr ""
 
-#: vms-alpha.c:5796
+#: vms-alpha.c:5799
 msgid " 64B"
 msgstr ""
 
-#: vms-alpha.c:5805
+#: vms-alpha.c:5808
 #, c-format
 msgid "  EGSD (len=%u):\n"
 msgstr ""
 
-#: vms-alpha.c:5817
+#: vms-alpha.c:5820
 #, c-format
 msgid "  EGSD entry %2u (type: %u, len: %u): "
 msgstr ""
 
-#: vms-alpha.c:5829
+#: vms-alpha.c:5832
 #, c-format
 msgid "PSC - Program section definition\n"
 msgstr ""
 
-#: vms-alpha.c:5830 vms-alpha.c:5847
+#: vms-alpha.c:5833 vms-alpha.c:5850
 #, c-format
 msgid "   alignment  : 2**%u\n"
 msgstr ""
 
-#: vms-alpha.c:5831 vms-alpha.c:5848
+#: vms-alpha.c:5834 vms-alpha.c:5851
 #, c-format
 msgid "   flags      : 0x%04x"
 msgstr ""
 
-#: vms-alpha.c:5835
+#: vms-alpha.c:5838
 #, c-format
 msgid "   alloc (len): %u (0x%08x)\n"
 msgstr ""
 
-#: vms-alpha.c:5836 vms-alpha.c:5893 vms-alpha.c:5942
+#: vms-alpha.c:5839 vms-alpha.c:5896 vms-alpha.c:5945
 #, c-format
 msgid "   name       : %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:5846
+#: vms-alpha.c:5849
 #, c-format
 msgid "SPSC - Shared Image Program section def\n"
 msgstr ""
 
-#: vms-alpha.c:5852
+#: vms-alpha.c:5855
 #, c-format
 msgid "   alloc (len)   : %u (0x%08x)\n"
 msgstr ""
 
-#: vms-alpha.c:5853
+#: vms-alpha.c:5856
 #, c-format
 msgid "   image offset  : 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:5855
+#: vms-alpha.c:5858
 #, c-format
 msgid "   symvec offset : 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:5857
+#: vms-alpha.c:5860
 #, c-format
 msgid "   name          : %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:5870
+#: vms-alpha.c:5873
 #, c-format
 msgid "SYM - Global symbol definition\n"
 msgstr ""
 
-#: vms-alpha.c:5871 vms-alpha.c:5931 vms-alpha.c:5952 vms-alpha.c:5971
+#: vms-alpha.c:5874 vms-alpha.c:5934 vms-alpha.c:5955 vms-alpha.c:5974
 #, c-format
 msgid "   flags: 0x%04x"
 msgstr ""
 
-#: vms-alpha.c:5874
+#: vms-alpha.c:5877
 #, c-format
 msgid "   psect offset: 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:5878
+#: vms-alpha.c:5881
 #, c-format
 msgid "   code address: 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:5880
+#: vms-alpha.c:5883
 #, c-format
 msgid "   psect index for entry point : %u\n"
 msgstr ""
 
-#: vms-alpha.c:5883 vms-alpha.c:5959 vms-alpha.c:5978
+#: vms-alpha.c:5886 vms-alpha.c:5962 vms-alpha.c:5981
 #, c-format
 msgid "   psect index : %u\n"
 msgstr ""
 
-#: vms-alpha.c:5885 vms-alpha.c:5961 vms-alpha.c:5980
+#: vms-alpha.c:5888 vms-alpha.c:5964 vms-alpha.c:5983
 #, c-format
 msgid "   name        : %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:5892
+#: vms-alpha.c:5895
 #, c-format
 msgid "SYM - Global symbol reference\n"
 msgstr ""
 
-#: vms-alpha.c:5904
+#: vms-alpha.c:5907
 #, c-format
 msgid "IDC - Ident Consistency check\n"
 msgstr ""
 
-#: vms-alpha.c:5905
+#: vms-alpha.c:5908
 #, c-format
 msgid "   flags         : 0x%08x"
 msgstr ""
 
-#: vms-alpha.c:5909
+#: vms-alpha.c:5912
 #, c-format
 msgid "   id match      : %x\n"
 msgstr ""
 
-#: vms-alpha.c:5911
+#: vms-alpha.c:5914
 #, c-format
 msgid "   error severity: %x\n"
 msgstr ""
 
-#: vms-alpha.c:5914
+#: vms-alpha.c:5917
 #, c-format
 msgid "   entity name   : %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:5916
+#: vms-alpha.c:5919
 #, c-format
 msgid "   object name   : %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:5919
+#: vms-alpha.c:5922
 #, c-format
 msgid "   binary ident  : 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:5922
+#: vms-alpha.c:5925
 #, c-format
 msgid "   ascii ident   : %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:5930
+#: vms-alpha.c:5933
 #, c-format
 msgid "SYMG - Universal symbol definition\n"
 msgstr ""
 
-#: vms-alpha.c:5934
+#: vms-alpha.c:5937
 #, c-format
 msgid "   symbol vector offset: 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:5936
+#: vms-alpha.c:5939
 #, c-format
 msgid "   entry point: 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:5938
+#: vms-alpha.c:5941
 #, c-format
 msgid "   proc descr : 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:5940
+#: vms-alpha.c:5943
 #, c-format
 msgid "   psect index: %u\n"
 msgstr ""
 
-#: vms-alpha.c:5951
+#: vms-alpha.c:5954
 #, c-format
 msgid "SYMV - Vectored symbol definition\n"
 msgstr ""
 
-#: vms-alpha.c:5955
+#: vms-alpha.c:5958
 #, c-format
 msgid "   vector      : 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:5957 vms-alpha.c:5976
+#: vms-alpha.c:5960 vms-alpha.c:5979
 #, c-format
 msgid "   psect offset: %u\n"
 msgstr ""
 
-#: vms-alpha.c:5970
+#: vms-alpha.c:5973
 #, c-format
 msgid "SYMM - Global symbol definition with version\n"
 msgstr ""
 
-#: vms-alpha.c:5974
+#: vms-alpha.c:5977
 #, c-format
 msgid "   version mask: 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:5985
+#: vms-alpha.c:5988
 #, c-format
 msgid "unhandled egsd entry type %u\n"
 msgstr ""
 
-#: vms-alpha.c:6019
+#: vms-alpha.c:6022
 #, c-format
 msgid "    linkage index: %u, replacement insn: 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:6022
+#: vms-alpha.c:6025
 #, c-format
 msgid "    psect idx 1: %u, offset 1: 0x%08x %08x\n"
 msgstr ""
 
-#: vms-alpha.c:6026
+#: vms-alpha.c:6029
 #, c-format
 msgid "    psect idx 2: %u, offset 2: 0x%08x %08x\n"
 msgstr ""
 
-#: vms-alpha.c:6031
+#: vms-alpha.c:6034
 #, c-format
 msgid "    psect idx 3: %u, offset 3: 0x%08x %08x\n"
 msgstr ""
 
-#: vms-alpha.c:6036
+#: vms-alpha.c:6039
 #, c-format
 msgid "    global name: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:6046
+#: vms-alpha.c:6049
 #, c-format
 msgid "  %s (len=%u+%u):\n"
 msgstr ""
 
-#: vms-alpha.c:6061
+#: vms-alpha.c:6064
 #, c-format
 msgid "   (type: %3u, size: 4+%3u): "
 msgstr ""
 
-#: vms-alpha.c:6065
+#: vms-alpha.c:6068
 #, c-format
 msgid "STA_GBL (stack global) %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:6069
+#: vms-alpha.c:6072
 #, c-format
 msgid "STA_LW (stack longword) 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:6073
+#: vms-alpha.c:6076
 #, c-format
 msgid "STA_QW (stack quadword) 0x%08x %08x\n"
 msgstr ""
 
-#: vms-alpha.c:6078
+#: vms-alpha.c:6081
 #, c-format
 msgid "STA_PQ (stack psect base + offset)\n"
 msgstr ""
 
-#: vms-alpha.c:6079
+#: vms-alpha.c:6082
 #, c-format
 msgid "    psect: %u, offset: 0x%08x %08x\n"
 msgstr ""
 
-#: vms-alpha.c:6085
+#: vms-alpha.c:6088
 #, c-format
 msgid "STA_LI (stack literal)\n"
 msgstr ""
 
-#: vms-alpha.c:6088
+#: vms-alpha.c:6091
 #, c-format
 msgid "STA_MOD (stack module)\n"
 msgstr ""
 
-#: vms-alpha.c:6091
+#: vms-alpha.c:6094
 #, c-format
 msgid "STA_CKARG (compare procedure argument)\n"
 msgstr ""
 
-#: vms-alpha.c:6095
+#: vms-alpha.c:6098
 #, c-format
 msgid "STO_B (store byte)\n"
 msgstr ""
 
-#: vms-alpha.c:6098
+#: vms-alpha.c:6101
 #, c-format
 msgid "STO_W (store word)\n"
 msgstr ""
 
-#: vms-alpha.c:6101
+#: vms-alpha.c:6104
 #, c-format
 msgid "STO_LW (store longword)\n"
 msgstr ""
 
-#: vms-alpha.c:6104
+#: vms-alpha.c:6107
 #, c-format
 msgid "STO_QW (store quadword)\n"
 msgstr ""
 
-#: vms-alpha.c:6110
+#: vms-alpha.c:6113
 #, c-format
 msgid "STO_IMMR (store immediate repeat) %u bytes\n"
 msgstr ""
 
-#: vms-alpha.c:6117
+#: vms-alpha.c:6120
 #, c-format
 msgid "STO_GBL (store global) %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:6121
+#: vms-alpha.c:6124
 #, c-format
 msgid "STO_CA (store code address) %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:6125
+#: vms-alpha.c:6128
 #, c-format
 msgid "STO_RB (store relative branch)\n"
 msgstr ""
 
-#: vms-alpha.c:6128
+#: vms-alpha.c:6131
 #, c-format
 msgid "STO_AB (store absolute branch)\n"
 msgstr ""
 
-#: vms-alpha.c:6131
+#: vms-alpha.c:6134
 #, c-format
 msgid "STO_OFF (store offset to psect)\n"
 msgstr ""
 
-#: vms-alpha.c:6137
+#: vms-alpha.c:6140
 #, c-format
 msgid "STO_IMM (store immediate) %u bytes\n"
 msgstr ""
 
-#: vms-alpha.c:6144
+#: vms-alpha.c:6147
 #, c-format
 msgid "STO_GBL_LW (store global longword) %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:6148
+#: vms-alpha.c:6151
 #, c-format
 msgid "STO_OFF (store LP with procedure signature)\n"
 msgstr ""
 
-#: vms-alpha.c:6151
+#: vms-alpha.c:6154
 #, c-format
 msgid "STO_BR_GBL (store branch global) *todo*\n"
 msgstr ""
 
-#: vms-alpha.c:6154
+#: vms-alpha.c:6157
 #, c-format
 msgid "STO_BR_PS (store branch psect + offset) *todo*\n"
 msgstr ""
 
-#: vms-alpha.c:6158
+#: vms-alpha.c:6161
 #, c-format
 msgid "OPR_NOP (no-operation)\n"
 msgstr ""
 
-#: vms-alpha.c:6161
+#: vms-alpha.c:6164
 #, c-format
 msgid "OPR_ADD (add)\n"
 msgstr ""
 
-#: vms-alpha.c:6164
+#: vms-alpha.c:6167
 #, c-format
 msgid "OPR_SUB (substract)\n"
 msgstr ""
 
-#: vms-alpha.c:6167
+#: vms-alpha.c:6170
 #, c-format
 msgid "OPR_MUL (multiply)\n"
 msgstr ""
 
-#: vms-alpha.c:6170
+#: vms-alpha.c:6173
 #, c-format
 msgid "OPR_DIV (divide)\n"
 msgstr ""
 
-#: vms-alpha.c:6173
+#: vms-alpha.c:6176
 #, c-format
 msgid "OPR_AND (logical and)\n"
 msgstr ""
 
-#: vms-alpha.c:6176
+#: vms-alpha.c:6179
 #, c-format
 msgid "OPR_IOR (logical inclusive or)\n"
 msgstr ""
 
-#: vms-alpha.c:6179
+#: vms-alpha.c:6182
 #, c-format
 msgid "OPR_EOR (logical exclusive or)\n"
 msgstr ""
 
-#: vms-alpha.c:6182
+#: vms-alpha.c:6185
 #, c-format
 msgid "OPR_NEG (negate)\n"
 msgstr ""
 
-#: vms-alpha.c:6185
+#: vms-alpha.c:6188
 #, c-format
 msgid "OPR_COM (complement)\n"
 msgstr ""
 
-#: vms-alpha.c:6188
+#: vms-alpha.c:6191
 #, c-format
 msgid "OPR_INSV (insert field)\n"
 msgstr ""
 
-#: vms-alpha.c:6191
+#: vms-alpha.c:6194
 #, c-format
 msgid "OPR_ASH (arithmetic shift)\n"
 msgstr ""
 
-#: vms-alpha.c:6194
+#: vms-alpha.c:6197
 #, c-format
 msgid "OPR_USH (unsigned shift)\n"
 msgstr ""
 
-#: vms-alpha.c:6197
+#: vms-alpha.c:6200
 #, c-format
 msgid "OPR_ROT (rotate)\n"
 msgstr ""
 
-#: vms-alpha.c:6200
+#: vms-alpha.c:6203
 #, c-format
 msgid "OPR_SEL (select)\n"
 msgstr ""
 
-#: vms-alpha.c:6203
+#: vms-alpha.c:6206
 #, c-format
 msgid "OPR_REDEF (redefine symbol to curr location)\n"
 msgstr ""
 
-#: vms-alpha.c:6206
+#: vms-alpha.c:6209
 #, c-format
 msgid "OPR_REDEF (define a literal)\n"
 msgstr ""
 
-#: vms-alpha.c:6210
+#: vms-alpha.c:6213
 #, c-format
 msgid "STC_LP (store cond linkage pair)\n"
 msgstr ""
 
-#: vms-alpha.c:6214
+#: vms-alpha.c:6217
 #, c-format
 msgid "STC_LP_PSB (store cond linkage pair + signature)\n"
 msgstr ""
 
-#: vms-alpha.c:6215
+#: vms-alpha.c:6218
 #, c-format
 msgid "   linkage index: %u, procedure: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:6218
+#: vms-alpha.c:6221
 #, c-format
 msgid "   signature: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:6221
+#: vms-alpha.c:6224
 #, c-format
 msgid "STC_GBL (store cond global)\n"
 msgstr ""
 
-#: vms-alpha.c:6222
+#: vms-alpha.c:6225
 #, c-format
 msgid "   linkage index: %u, global: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:6226
+#: vms-alpha.c:6229
 #, c-format
 msgid "STC_GCA (store cond code address)\n"
 msgstr ""
 
-#: vms-alpha.c:6227
+#: vms-alpha.c:6230
 #, c-format
 msgid "   linkage index: %u, procedure name: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:6231
+#: vms-alpha.c:6234
 #, c-format
 msgid "STC_PS (store cond psect + offset)\n"
 msgstr ""
 
-#: vms-alpha.c:6233
+#: vms-alpha.c:6236
 #, c-format
 msgid "   linkage index: %u, psect: %u, offset: 0x%08x %08x\n"
 msgstr ""
 
-#: vms-alpha.c:6240
+#: vms-alpha.c:6243
 #, c-format
 msgid "STC_NOP_GBL (store cond NOP at global addr)\n"
 msgstr ""
 
-#: vms-alpha.c:6244
+#: vms-alpha.c:6247
 #, c-format
 msgid "STC_NOP_PS (store cond NOP at psect + offset)\n"
 msgstr ""
 
-#: vms-alpha.c:6248
+#: vms-alpha.c:6251
 #, c-format
 msgid "STC_BSR_GBL (store cond BSR at global addr)\n"
 msgstr ""
 
-#: vms-alpha.c:6252
+#: vms-alpha.c:6255
 #, c-format
 msgid "STC_BSR_PS (store cond BSR at psect + offset)\n"
 msgstr ""
 
-#: vms-alpha.c:6256
+#: vms-alpha.c:6259
 #, c-format
 msgid "STC_LDA_GBL (store cond LDA at global addr)\n"
 msgstr ""
 
-#: vms-alpha.c:6260
+#: vms-alpha.c:6263
 #, c-format
 msgid "STC_LDA_PS (store cond LDA at psect + offset)\n"
 msgstr ""
 
-#: vms-alpha.c:6264
+#: vms-alpha.c:6267
 #, c-format
 msgid "STC_BOH_GBL (store cond BOH at global addr)\n"
 msgstr ""
 
-#: vms-alpha.c:6268
+#: vms-alpha.c:6271
 #, c-format
 msgid "STC_BOH_PS (store cond BOH at psect + offset)\n"
 msgstr ""
 
-#: vms-alpha.c:6273
+#: vms-alpha.c:6276
 #, c-format
 msgid "STC_NBH_GBL (store cond or hint at global addr)\n"
 msgstr ""
 
-#: vms-alpha.c:6277
+#: vms-alpha.c:6280
 #, c-format
 msgid "STC_NBH_PS (store cond or hint at psect + offset)\n"
 msgstr ""
 
-#: vms-alpha.c:6281
+#: vms-alpha.c:6284
 #, c-format
 msgid "CTL_SETRB (set relocation base)\n"
 msgstr ""
 
-#: vms-alpha.c:6287
+#: vms-alpha.c:6290
 #, c-format
 msgid "CTL_AUGRB (augment relocation base) %u\n"
 msgstr ""
 
-#: vms-alpha.c:6291
+#: vms-alpha.c:6294
 #, c-format
 msgid "CTL_DFLOC (define location)\n"
 msgstr ""
 
-#: vms-alpha.c:6294
+#: vms-alpha.c:6297
 #, c-format
 msgid "CTL_STLOC (set location)\n"
 msgstr ""
 
-#: vms-alpha.c:6297
+#: vms-alpha.c:6300
 #, c-format
 msgid "CTL_STKDL (stack defined location)\n"
 msgstr ""
 
-#: vms-alpha.c:6300 vms-alpha.c:6714
+#: vms-alpha.c:6303 vms-alpha.c:6717
 #, c-format
 msgid "*unhandled*\n"
 msgstr ""
 
-#: vms-alpha.c:6330 vms-alpha.c:6369
+#: vms-alpha.c:6333 vms-alpha.c:6372
 #, c-format
 msgid "cannot read GST record length\n"
 msgstr ""
 
 #. Ill-formed.
-#: vms-alpha.c:6351
+#: vms-alpha.c:6354
 #, c-format
 msgid "cannot find EMH in first GST record\n"
 msgstr ""
 
-#: vms-alpha.c:6377
+#: vms-alpha.c:6380
 #, c-format
 msgid "cannot read GST record header\n"
 msgstr ""
 
-#: vms-alpha.c:6390
+#: vms-alpha.c:6393
 #, c-format
 msgid " corrupted GST\n"
 msgstr ""
 
-#: vms-alpha.c:6398
+#: vms-alpha.c:6401
 #, c-format
 msgid "cannot read GST record\n"
 msgstr ""
 
-#: vms-alpha.c:6427
+#: vms-alpha.c:6430
 #, c-format
 msgid " unhandled EOBJ record type %u\n"
 msgstr ""
 
-#: vms-alpha.c:6450
+#: vms-alpha.c:6453
 #, c-format
 msgid "  bitcount: %u, base addr: 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:6463
+#: vms-alpha.c:6466
 #, c-format
 msgid "   bitmap: 0x%08x (count: %u):\n"
 msgstr ""
 
-#: vms-alpha.c:6470
+#: vms-alpha.c:6473
 #, c-format
 msgid " %08x"
 msgstr ""
 
-#: vms-alpha.c:6495
+#: vms-alpha.c:6498
 #, c-format
 msgid "  image %u (%u entries)\n"
 msgstr ""
 
-#: vms-alpha.c:6500
+#: vms-alpha.c:6503
 #, c-format
 msgid "   offset: 0x%08x, val: 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:6521
+#: vms-alpha.c:6524
 #, c-format
 msgid "  image %u (%u entries), offsets:\n"
 msgstr ""
 
-#: vms-alpha.c:6528
+#: vms-alpha.c:6531
 #, c-format
 msgid " 0x%08x"
 msgstr ""
 
 #. 64 bits.
-#: vms-alpha.c:6650
+#: vms-alpha.c:6653
 #, c-format
 msgid "64 bits *unhandled*\n"
 msgstr ""
 
-#: vms-alpha.c:6654
+#: vms-alpha.c:6657
 #, c-format
 msgid "class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:6665
+#: vms-alpha.c:6668
 #, c-format
 msgid "non-contiguous array of %s\n"
 msgstr ""
 
-#: vms-alpha.c:6669
+#: vms-alpha.c:6672
 #, c-format
 msgid "dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"
 msgstr ""
 
-#: vms-alpha.c:6673
+#: vms-alpha.c:6676
 #, c-format
 msgid "arsize: %u, a0: 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:6677
+#: vms-alpha.c:6680
 #, c-format
 msgid "Strides:\n"
 msgstr ""
 
-#: vms-alpha.c:6682
+#: vms-alpha.c:6685
 #, c-format
 msgid "[%u]: %u\n"
 msgstr ""
 
-#: vms-alpha.c:6687
+#: vms-alpha.c:6690
 #, c-format
 msgid "Bounds:\n"
 msgstr ""
 
-#: vms-alpha.c:6692
+#: vms-alpha.c:6695
 #, c-format
 msgid "[%u]: Lower: %u, upper: %u\n"
 msgstr ""
 
-#: vms-alpha.c:6704
+#: vms-alpha.c:6707
 #, c-format
 msgid "unaligned bit-string of %s\n"
 msgstr ""
 
-#: vms-alpha.c:6708
+#: vms-alpha.c:6711
 #, c-format
 msgid "base: %u, pos: %u\n"
 msgstr ""
 
-#: vms-alpha.c:6728
+#: vms-alpha.c:6731
 #, c-format
 msgid "vflags: 0x%02x, value: 0x%08x "
 msgstr ""
 
-#: vms-alpha.c:6734
+#: vms-alpha.c:6737
 #, c-format
 msgid "(no value)\n"
 msgstr ""
 
-#: vms-alpha.c:6737
+#: vms-alpha.c:6740
 #, c-format
 msgid "(not active)\n"
 msgstr ""
 
-#: vms-alpha.c:6740
+#: vms-alpha.c:6743
 #, c-format
 msgid "(not allocated)\n"
 msgstr ""
 
-#: vms-alpha.c:6743
+#: vms-alpha.c:6746
 #, c-format
 msgid "(descriptor)\n"
 msgstr ""
 
-#: vms-alpha.c:6747
+#: vms-alpha.c:6750
 #, c-format
 msgid "(trailing value)\n"
 msgstr ""
 
-#: vms-alpha.c:6750
+#: vms-alpha.c:6753
 #, c-format
 msgid "(value spec follows)\n"
 msgstr ""
 
-#: vms-alpha.c:6753
+#: vms-alpha.c:6756
 #, c-format
 msgid "(at bit offset %u)\n"
 msgstr ""
 
-#: vms-alpha.c:6756
+#: vms-alpha.c:6759
 #, c-format
 msgid "(reg: %u, disp: %u, indir: %u, kind: "
 msgstr ""
 
-#: vms-alpha.c:6763
+#: vms-alpha.c:6766
 msgid "literal"
 msgstr ""
 
-#: vms-alpha.c:6766
+#: vms-alpha.c:6769
 msgid "address"
 msgstr ""
 
-#: vms-alpha.c:6769
+#: vms-alpha.c:6772
 msgid "desc"
 msgstr ""
 
-#: vms-alpha.c:6772
+#: vms-alpha.c:6775
 msgid "reg"
 msgstr ""
 
-#: vms-alpha.c:6847
+#: vms-alpha.c:6850
 #, c-format
 msgid "Debug symbol table:\n"
 msgstr ""
 
-#: vms-alpha.c:6858
+#: vms-alpha.c:6861
 #, c-format
 msgid "cannot read DST header\n"
 msgstr ""
 
-#: vms-alpha.c:6863
+#: vms-alpha.c:6866
 #, c-format
 msgid " type: %3u, len: %3u (at 0x%08x): "
 msgstr ""
 
-#: vms-alpha.c:6877
+#: vms-alpha.c:6880
 #, c-format
 msgid "cannot read DST symbol\n"
 msgstr ""
 
-#: vms-alpha.c:6920
+#: vms-alpha.c:6923
 #, c-format
 msgid "standard data: %s\n"
 msgstr ""
 
-#: vms-alpha.c:6923 vms-alpha.c:7007
+#: vms-alpha.c:6926 vms-alpha.c:7010
 #, c-format
 msgid "    name: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:6930
+#: vms-alpha.c:6933
 #, c-format
 msgid "modbeg\n"
 msgstr ""
 
-#: vms-alpha.c:6931
+#: vms-alpha.c:6934
 #, c-format
 msgid "   flags: %d, language: %u, major: %u, minor: %u\n"
 msgstr ""
 
-#: vms-alpha.c:6937 vms-alpha.c:7203
+#: vms-alpha.c:6940 vms-alpha.c:7206
 #, c-format
 msgid "   module name: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:6940
+#: vms-alpha.c:6943
 #, c-format
 msgid "   compiler   : %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:6945
+#: vms-alpha.c:6948
 #, c-format
 msgid "modend\n"
 msgstr ""
 
-#: vms-alpha.c:6952
+#: vms-alpha.c:6955
 msgid "rtnbeg\n"
 msgstr ""
 
-#: vms-alpha.c:6953
+#: vms-alpha.c:6956
 #, c-format
 msgid "    flags: %u, address: 0x%08x, pd-address: 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:6958
+#: vms-alpha.c:6961
 #, c-format
 msgid "    routine name: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:6966
+#: vms-alpha.c:6969
 #, c-format
 msgid "rtnend: size 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:6974
+#: vms-alpha.c:6977
 #, c-format
 msgid "prolog: bkpt address 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:6982
+#: vms-alpha.c:6985
 #, c-format
 msgid "epilog: flags: %u, count: %u\n"
 msgstr ""
 
-#: vms-alpha.c:6991
+#: vms-alpha.c:6994
 #, c-format
 msgid "blkbeg: address: 0x%08x, name: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:7000
+#: vms-alpha.c:7003
 #, c-format
 msgid "blkend: size: 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:7006
+#: vms-alpha.c:7009
 #, c-format
 msgid "typspec (len: %u)\n"
 msgstr ""
 
-#: vms-alpha.c:7013
+#: vms-alpha.c:7016
 #, c-format
 msgid "septyp, name: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:7022
+#: vms-alpha.c:7025
 #, c-format
 msgid "recbeg: name: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:7029
+#: vms-alpha.c:7032
 #, c-format
 msgid "recend\n"
 msgstr ""
 
-#: vms-alpha.c:7032
+#: vms-alpha.c:7035
 #, c-format
 msgid "enumbeg, len: %u, name: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:7036
+#: vms-alpha.c:7039
 #, c-format
 msgid "enumelt, name: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:7040
+#: vms-alpha.c:7043
 #, c-format
 msgid "enumend\n"
 msgstr ""
 
-#: vms-alpha.c:7057
+#: vms-alpha.c:7060
 #, c-format
 msgid "discontiguous range (nbr: %u)\n"
 msgstr ""
 
-#: vms-alpha.c:7059
+#: vms-alpha.c:7062
 #, c-format
 msgid "    address: 0x%08x, size: %u\n"
 msgstr ""
 
-#: vms-alpha.c:7069
+#: vms-alpha.c:7072
 #, c-format
 msgid "line num  (len: %u)\n"
 msgstr ""
 
-#: vms-alpha.c:7086
+#: vms-alpha.c:7089
 #, c-format
 msgid "delta_pc_w %u\n"
 msgstr ""
 
-#: vms-alpha.c:7093
+#: vms-alpha.c:7096
 #, c-format
 msgid "incr_linum(b): +%u\n"
 msgstr ""
 
-#: vms-alpha.c:7099
+#: vms-alpha.c:7102
 #, c-format
 msgid "incr_linum_w: +%u\n"
 msgstr ""
 
-#: vms-alpha.c:7105
+#: vms-alpha.c:7108
 #, c-format
 msgid "incr_linum_l: +%u\n"
 msgstr ""
 
-#: vms-alpha.c:7111
+#: vms-alpha.c:7114
 #, c-format
 msgid "set_line_num(w) %u\n"
 msgstr ""
 
-#: vms-alpha.c:7116
+#: vms-alpha.c:7119
 #, c-format
 msgid "set_line_num_b %u\n"
 msgstr ""
 
-#: vms-alpha.c:7121
+#: vms-alpha.c:7124
 #, c-format
 msgid "set_line_num_l %u\n"
 msgstr ""
 
-#: vms-alpha.c:7126
+#: vms-alpha.c:7129
 #, c-format
 msgid "set_abs_pc: 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:7130
+#: vms-alpha.c:7133
 #, c-format
 msgid "delta_pc_l: +0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:7135
+#: vms-alpha.c:7138
 #, c-format
 msgid "term(b): 0x%02x"
 msgstr ""
 
-#: vms-alpha.c:7137
+#: vms-alpha.c:7140
 #, c-format
 msgid "        pc: 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:7142
+#: vms-alpha.c:7145
 #, c-format
 msgid "term_w: 0x%04x"
 msgstr ""
 
-#: vms-alpha.c:7144
+#: vms-alpha.c:7147
 #, c-format
 msgid "    pc: 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:7150
+#: vms-alpha.c:7153
 #, c-format
 msgid "delta pc +%-4d"
 msgstr ""
 
-#: vms-alpha.c:7153
+#: vms-alpha.c:7156
 #, c-format
 msgid "    pc: 0x%08x line: %5u\n"
 msgstr ""
 
-#: vms-alpha.c:7158
+#: vms-alpha.c:7161
 #, c-format
 msgid "    *unhandled* cmd %u\n"
 msgstr ""
 
-#: vms-alpha.c:7173
+#: vms-alpha.c:7176
 #, c-format
 msgid "source (len: %u)\n"
 msgstr ""
 
-#: vms-alpha.c:7187
+#: vms-alpha.c:7190
 #, c-format
 msgid "   declfile: len: %u, flags: %u, fileid: %u\n"
 msgstr ""
 
-#: vms-alpha.c:7191
+#: vms-alpha.c:7194
 #, c-format
 msgid "   rms: cdt: 0x%08x %08x, ebk: 0x%08x, ffb: 0x%04x, rfo: %u\n"
 msgstr ""
 
-#: vms-alpha.c:7200
+#: vms-alpha.c:7203
 #, c-format
 msgid "   filename   : %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:7209
+#: vms-alpha.c:7212
 #, c-format
 msgid "   setfile %u\n"
 msgstr ""
 
-#: vms-alpha.c:7214 vms-alpha.c:7219
+#: vms-alpha.c:7217 vms-alpha.c:7222
 #, c-format
 msgid "   setrec %u\n"
 msgstr ""
 
-#: vms-alpha.c:7224 vms-alpha.c:7229
+#: vms-alpha.c:7227 vms-alpha.c:7232
 #, c-format
 msgid "   setlnum %u\n"
 msgstr ""
 
-#: vms-alpha.c:7234 vms-alpha.c:7239
+#: vms-alpha.c:7237 vms-alpha.c:7242
 #, c-format
 msgid "   deflines %u\n"
 msgstr ""
 
-#: vms-alpha.c:7243
+#: vms-alpha.c:7246
 #, c-format
 msgid "   formfeed\n"
 msgstr ""
 
-#: vms-alpha.c:7247
+#: vms-alpha.c:7250
 #, c-format
 msgid "   *unhandled* cmd %u\n"
 msgstr ""
 
-#: vms-alpha.c:7259
+#: vms-alpha.c:7262
 #, c-format
 msgid "*unhandled* dst type %u\n"
 msgstr ""
 
-#: vms-alpha.c:7291
+#: vms-alpha.c:7294
 #, c-format
 msgid "cannot read EIHD\n"
 msgstr ""
 
-#: vms-alpha.c:7294
+#: vms-alpha.c:7297
 #, c-format
 msgid "EIHD: (size: %u, nbr blocks: %u)\n"
 msgstr ""
 
-#: vms-alpha.c:7297
+#: vms-alpha.c:7300
 #, c-format
 msgid " majorid: %u, minorid: %u\n"
 msgstr ""
 
-#: vms-alpha.c:7305
+#: vms-alpha.c:7308
 msgid "executable"
 msgstr ""
 
-#: vms-alpha.c:7308
+#: vms-alpha.c:7311
 msgid "linkable image"
 msgstr ""
 
-#: vms-alpha.c:7314
+#: vms-alpha.c:7317
 #, c-format
 msgid " image type: %u (%s)"
 msgstr ""
 
-#: vms-alpha.c:7320
+#: vms-alpha.c:7323
 msgid "native"
 msgstr ""
 
-#: vms-alpha.c:7323
+#: vms-alpha.c:7326
 msgid "CLI"
 msgstr ""
 
-#: vms-alpha.c:7329
+#: vms-alpha.c:7332
 #, c-format
 msgid ", subtype: %u (%s)\n"
 msgstr ""
 
-#: vms-alpha.c:7335
+#: vms-alpha.c:7338
 #, c-format
 msgid " offsets: isd: %u, activ: %u, symdbg: %u, imgid: %u, patch: %u\n"
 msgstr ""
 
-#: vms-alpha.c:7339
+#: vms-alpha.c:7342
 #, c-format
 msgid " fixup info rva: "
 msgstr ""
 
-#: vms-alpha.c:7341
+#: vms-alpha.c:7344
 #, c-format
 msgid ", symbol vector rva: "
 msgstr ""
 
-#: vms-alpha.c:7344
+#: vms-alpha.c:7347
 #, c-format
 msgid ""
 "\n"
 " version array off: %u\n"
 msgstr ""
 
-#: vms-alpha.c:7348
+#: vms-alpha.c:7351
 #, c-format
 msgid " img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:7354
+#: vms-alpha.c:7357
 #, c-format
 msgid " linker flags: %08x:"
 msgstr ""
 
-#: vms-alpha.c:7384
+#: vms-alpha.c:7387
 #, c-format
 msgid " ident: 0x%08x, sysver: 0x%08x, match ctrl: %u, symvect_size: %u\n"
 msgstr ""
 
-#: vms-alpha.c:7390
+#: vms-alpha.c:7393
 #, c-format
 msgid " BPAGE: %u"
 msgstr ""
 
-#: vms-alpha.c:7396
+#: vms-alpha.c:7399
 #, c-format
 msgid ", ext fixup offset: %u, no_opt psect off: %u"
 msgstr ""
 
-#: vms-alpha.c:7399
+#: vms-alpha.c:7402
 #, c-format
 msgid ", alias: %u\n"
 msgstr ""
 
-#: vms-alpha.c:7407
+#: vms-alpha.c:7410
 #, c-format
 msgid "system version array information:\n"
 msgstr ""
 
-#: vms-alpha.c:7411
+#: vms-alpha.c:7414
 #, c-format
 msgid "cannot read EIHVN header\n"
 msgstr ""
 
-#: vms-alpha.c:7421
+#: vms-alpha.c:7424
 #, c-format
 msgid "cannot read EIHVN version\n"
 msgstr ""
 
-#: vms-alpha.c:7424
+#: vms-alpha.c:7427
 #, c-format
 msgid "   %02u "
 msgstr ""
 
-#: vms-alpha.c:7428
+#: vms-alpha.c:7431
 msgid "BASE_IMAGE       "
 msgstr ""
 
-#: vms-alpha.c:7431
+#: vms-alpha.c:7434
 msgid "MEMORY_MANAGEMENT"
 msgstr ""
 
-#: vms-alpha.c:7434
+#: vms-alpha.c:7437
 msgid "IO               "
 msgstr ""
 
-#: vms-alpha.c:7437
+#: vms-alpha.c:7440
 msgid "FILES_VOLUMES    "
 msgstr ""
 
-#: vms-alpha.c:7440
+#: vms-alpha.c:7443
 msgid "PROCESS_SCHED    "
 msgstr ""
 
-#: vms-alpha.c:7443
+#: vms-alpha.c:7446
 msgid "SYSGEN           "
 msgstr ""
 
-#: vms-alpha.c:7446
+#: vms-alpha.c:7449
 msgid "CLUSTERS_LOCKMGR "
 msgstr ""
 
-#: vms-alpha.c:7449
+#: vms-alpha.c:7452
 msgid "LOGICAL_NAMES    "
 msgstr ""
 
-#: vms-alpha.c:7452
+#: vms-alpha.c:7455
 msgid "SECURITY         "
 msgstr ""
 
-#: vms-alpha.c:7455
+#: vms-alpha.c:7458
 msgid "IMAGE_ACTIVATOR  "
 msgstr ""
 
-#: vms-alpha.c:7458
+#: vms-alpha.c:7461
 msgid "NETWORKS         "
 msgstr ""
 
-#: vms-alpha.c:7461
+#: vms-alpha.c:7464
 msgid "COUNTERS         "
 msgstr ""
 
-#: vms-alpha.c:7464
+#: vms-alpha.c:7467
 msgid "STABLE           "
 msgstr ""
 
-#: vms-alpha.c:7467
+#: vms-alpha.c:7470
 msgid "MISC             "
 msgstr ""
 
-#: vms-alpha.c:7470
+#: vms-alpha.c:7473
 msgid "CPU              "
 msgstr ""
 
-#: vms-alpha.c:7473
+#: vms-alpha.c:7476
 msgid "VOLATILE         "
 msgstr ""
 
-#: vms-alpha.c:7476
+#: vms-alpha.c:7479
 msgid "SHELL            "
 msgstr ""
 
-#: vms-alpha.c:7479
+#: vms-alpha.c:7482
 msgid "POSIX            "
 msgstr ""
 
-#: vms-alpha.c:7482
+#: vms-alpha.c:7485
 msgid "MULTI_PROCESSING "
 msgstr ""
 
-#: vms-alpha.c:7485
+#: vms-alpha.c:7488
 msgid "GALAXY           "
 msgstr ""
 
-#: vms-alpha.c:7488
+#: vms-alpha.c:7491
 msgid "*unknown*        "
 msgstr ""
 
-#: vms-alpha.c:7491
+#: vms-alpha.c:7494
 #, c-format
 msgid ": %u.%u\n"
 msgstr ""
 
-#: vms-alpha.c:7504 vms-alpha.c:7763
+#: vms-alpha.c:7507 vms-alpha.c:7766
 #, c-format
 msgid "cannot read EIHA\n"
 msgstr ""
 
-#: vms-alpha.c:7507
+#: vms-alpha.c:7510
 #, c-format
 msgid "Image activation:  (size=%u)\n"
 msgstr ""
 
-#: vms-alpha.c:7509
+#: vms-alpha.c:7512
 #, c-format
 msgid " First address : 0x%08x 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:7512
+#: vms-alpha.c:7515
 #, c-format
 msgid " Second address: 0x%08x 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:7515
+#: vms-alpha.c:7518
 #, c-format
 msgid " Third address : 0x%08x 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:7518
+#: vms-alpha.c:7521
 #, c-format
 msgid " Fourth address: 0x%08x 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:7521
+#: vms-alpha.c:7524
 #, c-format
 msgid " Shared image  : 0x%08x 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:7532
+#: vms-alpha.c:7535
 #, c-format
 msgid "cannot read EIHI\n"
 msgstr ""
 
-#: vms-alpha.c:7535
+#: vms-alpha.c:7538
 #, c-format
 msgid "Image identification: (major: %u, minor: %u)\n"
 msgstr ""
 
-#: vms-alpha.c:7538
+#: vms-alpha.c:7541
 #, c-format
 msgid " image name       : %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:7540
+#: vms-alpha.c:7543
 #, c-format
 msgid " link time        : %s\n"
 msgstr ""
 
-#: vms-alpha.c:7542
+#: vms-alpha.c:7545
 #, c-format
 msgid " image ident      : %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:7544
+#: vms-alpha.c:7547
 #, c-format
 msgid " linker ident     : %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:7546
+#: vms-alpha.c:7549
 #, c-format
 msgid " image build ident: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:7556
+#: vms-alpha.c:7559
 #, c-format
 msgid "cannot read EIHS\n"
 msgstr ""
 
-#: vms-alpha.c:7559
+#: vms-alpha.c:7562
 #, c-format
 msgid "Image symbol & debug table: (major: %u, minor: %u)\n"
 msgstr ""
 
-#: vms-alpha.c:7564
+#: vms-alpha.c:7567
 #, c-format
 msgid " debug symbol table : vbn: %u, size: %u (0x%x)\n"
 msgstr ""
 
-#: vms-alpha.c:7568
+#: vms-alpha.c:7571
 #, c-format
 msgid " global symbol table: vbn: %u, records: %u\n"
 msgstr ""
 
-#: vms-alpha.c:7572
+#: vms-alpha.c:7575
 #, c-format
 msgid " debug module table : vbn: %u, size: %u\n"
 msgstr ""
 
-#: vms-alpha.c:7585
+#: vms-alpha.c:7588
 #, c-format
 msgid "cannot read EISD\n"
 msgstr ""
 
-#: vms-alpha.c:7595
+#: vms-alpha.c:7598
 #, c-format
 msgid ""
 "Image section descriptor: (major: %u, minor: %u, size: %u, offset: %u)\n"
 msgstr ""
 
-#: vms-alpha.c:7602
+#: vms-alpha.c:7605
 #, c-format
 msgid " section: base: 0x%08x%08x size: 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:7607
+#: vms-alpha.c:7610
 #, c-format
 msgid " flags: 0x%04x"
 msgstr ""
 
-#: vms-alpha.c:7644
+#: vms-alpha.c:7647
 #, c-format
 msgid " vbn: %u, pfc: %u, matchctl: %u type: %u ("
 msgstr ""
 
-#: vms-alpha.c:7650
+#: vms-alpha.c:7653
 msgid "NORMAL"
 msgstr ""
 
-#: vms-alpha.c:7653
+#: vms-alpha.c:7656
 msgid "SHRFXD"
 msgstr ""
 
-#: vms-alpha.c:7656
+#: vms-alpha.c:7659
 msgid "PRVFXD"
 msgstr ""
 
-#: vms-alpha.c:7659
+#: vms-alpha.c:7662
 msgid "SHRPIC"
 msgstr ""
 
-#: vms-alpha.c:7662
+#: vms-alpha.c:7665
 msgid "PRVPIC"
 msgstr ""
 
-#: vms-alpha.c:7665
+#: vms-alpha.c:7668
 msgid "USRSTACK"
 msgstr ""
 
-#: vms-alpha.c:7673
+#: vms-alpha.c:7676
 #, c-format
 msgid " ident: 0x%08x, name: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:7683
+#: vms-alpha.c:7686
 #, c-format
 msgid "cannot read DMT\n"
 msgstr ""
 
-#: vms-alpha.c:7687
+#: vms-alpha.c:7690
 #, c-format
 msgid "Debug module table:\n"
 msgstr ""
 
-#: vms-alpha.c:7696
+#: vms-alpha.c:7699
 #, c-format
 msgid "cannot read DMT header\n"
 msgstr ""
 
-#: vms-alpha.c:7701
+#: vms-alpha.c:7704
 #, c-format
 msgid " module offset: 0x%08x, size: 0x%08x, (%u psects)\n"
 msgstr ""
 
-#: vms-alpha.c:7711
+#: vms-alpha.c:7714
 #, c-format
 msgid "cannot read DMT psect\n"
 msgstr ""
 
-#: vms-alpha.c:7714
+#: vms-alpha.c:7717
 #, c-format
 msgid "  psect start: 0x%08x, length: %u\n"
 msgstr ""
 
-#: vms-alpha.c:7727
+#: vms-alpha.c:7730
 #, c-format
 msgid "cannot read DST\n"
 msgstr ""
 
-#: vms-alpha.c:7737
+#: vms-alpha.c:7740
 #, c-format
 msgid "cannot read GST\n"
 msgstr ""
 
-#: vms-alpha.c:7741
+#: vms-alpha.c:7744
 #, c-format
 msgid "Global symbol table:\n"
 msgstr ""
 
-#: vms-alpha.c:7769
+#: vms-alpha.c:7772
 #, c-format
 msgid "Image activator fixup: (major: %u, minor: %u)\n"
 msgstr ""
 
-#: vms-alpha.c:7772
+#: vms-alpha.c:7775
 #, c-format
 msgid "  iaflink : 0x%08x %08x\n"
 msgstr ""
 
-#: vms-alpha.c:7775
+#: vms-alpha.c:7778
 #, c-format
 msgid "  fixuplnk: 0x%08x %08x\n"
 msgstr ""
 
-#: vms-alpha.c:7778
+#: vms-alpha.c:7781
 #, c-format
 msgid "  size : %u\n"
 msgstr ""
 
-#: vms-alpha.c:7780
+#: vms-alpha.c:7783
 #, c-format
 msgid "  flags: 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:7784
+#: vms-alpha.c:7787
 #, c-format
 msgid "  qrelfixoff: %5u, lrelfixoff: %5u\n"
 msgstr ""
 
-#: vms-alpha.c:7788
+#: vms-alpha.c:7791
 #, c-format
 msgid "  qdotadroff: %5u, ldotadroff: %5u\n"
 msgstr ""
 
-#: vms-alpha.c:7792
+#: vms-alpha.c:7795
 #, c-format
 msgid "  codeadroff: %5u, lpfixoff  : %5u\n"
 msgstr ""
 
-#: vms-alpha.c:7795
+#: vms-alpha.c:7798
 #, c-format
 msgid "  chgprtoff : %5u\n"
 msgstr ""
 
-#: vms-alpha.c:7798
+#: vms-alpha.c:7801
 #, c-format
 msgid "  shlstoff  : %5u, shrimgcnt : %5u\n"
 msgstr ""
 
-#: vms-alpha.c:7800
+#: vms-alpha.c:7803
 #, c-format
 msgid "  shlextra  : %5u, permctx   : %5u\n"
 msgstr ""
 
-#: vms-alpha.c:7803
+#: vms-alpha.c:7806
 #, c-format
 msgid "  base_va : 0x%08x\n"
 msgstr ""
 
-#: vms-alpha.c:7805
+#: vms-alpha.c:7808
 #, c-format
 msgid "  lppsbfixoff: %5u\n"
 msgstr ""
 
-#: vms-alpha.c:7813
+#: vms-alpha.c:7816
 #, c-format
 msgid " Shareable images:\n"
 msgstr ""
 
-#: vms-alpha.c:7817
+#: vms-alpha.c:7820
 #, c-format
 msgid "  %u: size: %u, flags: 0x%02x, name: %.*s\n"
 msgstr ""
 
-#: vms-alpha.c:7824
+#: vms-alpha.c:7827
 #, c-format
 msgid " quad-word relocation fixups:\n"
 msgstr ""
 
-#: vms-alpha.c:7829
+#: vms-alpha.c:7832
 #, c-format
 msgid " long-word relocation fixups:\n"
 msgstr ""
 
-#: vms-alpha.c:7834
+#: vms-alpha.c:7837
 #, c-format
 msgid " quad-word .address reference fixups:\n"
 msgstr ""
 
-#: vms-alpha.c:7839
+#: vms-alpha.c:7842
 #, c-format
 msgid " long-word .address reference fixups:\n"
 msgstr ""
 
-#: vms-alpha.c:7844
+#: vms-alpha.c:7847
 #, c-format
 msgid " Code Address Reference Fixups:\n"
 msgstr ""
 
-#: vms-alpha.c:7849
+#: vms-alpha.c:7852
 #, c-format
 msgid " Linkage Pairs Referece Fixups:\n"
 msgstr ""
 
-#: vms-alpha.c:7858
+#: vms-alpha.c:7861
 #, c-format
 msgid " Change Protection (%u entries):\n"
 msgstr ""
 
-#: vms-alpha.c:7863
+#: vms-alpha.c:7866
 #, c-format
 msgid "  base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "
 msgstr ""
 
 #. FIXME: we do not yet support relocatable link.  It is not obvious
 #. how to do it for debug infos.
-#: vms-alpha.c:8694
+#: vms-alpha.c:8706
 msgid "%P: relocatable link is not supported\n"
 msgstr ""
 
-#: vms-alpha.c:8764
+#: vms-alpha.c:8776
 msgid "%P: multiple entry points: in modules %B and %B\n"
 msgstr ""
 
-#: vms-lib.c:1421
+#: vms-lib.c:1423
 #, c-format
 msgid "could not open shared image '%s' from '%s'"
 msgstr ""
@@ -5788,23 +5853,23 @@
 msgid "warning: attempt to export undefined symbol `%s'"
 msgstr ""
 
-#: xcofflink.c:3681
+#: xcofflink.c:3678
 msgid "error: undefined symbol __rtinit"
 msgstr ""
 
-#: xcofflink.c:4060
+#: xcofflink.c:4057
 msgid "%B: loader reloc in unrecognized section `%s'"
 msgstr ""
 
-#: xcofflink.c:4071
+#: xcofflink.c:4068
 msgid "%B: `%s' in loader reloc but not loader sym"
 msgstr ""
 
-#: xcofflink.c:4087
+#: xcofflink.c:4084
 msgid "%B: loader reloc in read-only section %A"
 msgstr ""
 
-#: xcofflink.c:5109
+#: xcofflink.c:5106
 #, c-format
 msgid "TOC overflow: 0x%lx > 0x10000; try -mminimal-toc when compiling"
 msgstr ""
@@ -5815,77 +5880,77 @@
 "branch."
 msgstr ""
 
-#: elf32-ia64.c:2290 elf64-ia64.c:2290
+#: elf32-ia64.c:2284 elf64-ia64.c:2284
 msgid "@pltoff reloc against local symbol"
 msgstr ""
 
-#: elf32-ia64.c:3693 elf64-ia64.c:3693
+#: elf32-ia64.c:3687 elf64-ia64.c:3687
 #, c-format
 msgid "%s: short data segment overflowed (0x%lx >= 0x400000)"
 msgstr ""
 
-#: elf32-ia64.c:3704 elf64-ia64.c:3704
+#: elf32-ia64.c:3698 elf64-ia64.c:3698
 #, c-format
 msgid "%s: __gp does not cover short data segment"
 msgstr ""
 
-#: elf32-ia64.c:3971 elf64-ia64.c:3971
+#: elf32-ia64.c:3965 elf64-ia64.c:3965
 msgid "%B: non-pic code with imm relocation against dynamic symbol `%s'"
 msgstr ""
 
-#: elf32-ia64.c:4038 elf64-ia64.c:4038
+#: elf32-ia64.c:4032 elf64-ia64.c:4032
 msgid "%B: @gprel relocation against dynamic symbol %s"
 msgstr ""
 
-#: elf32-ia64.c:4101 elf64-ia64.c:4101
+#: elf32-ia64.c:4095 elf64-ia64.c:4095
 msgid "%B: linking non-pic code in a position independent executable"
 msgstr ""
 
-#: elf32-ia64.c:4238 elf64-ia64.c:4238
+#: elf32-ia64.c:4232 elf64-ia64.c:4232
 msgid "%B: @internal branch to dynamic symbol %s"
 msgstr ""
 
-#: elf32-ia64.c:4240 elf64-ia64.c:4240
+#: elf32-ia64.c:4234 elf64-ia64.c:4234
 msgid "%B: speculation fixup to dynamic symbol %s"
 msgstr ""
 
-#: elf32-ia64.c:4242 elf64-ia64.c:4242
+#: elf32-ia64.c:4236 elf64-ia64.c:4236
 msgid "%B: @pcrel relocation against dynamic symbol %s"
 msgstr ""
 
-#: elf32-ia64.c:4439 elf64-ia64.c:4439
+#: elf32-ia64.c:4433 elf64-ia64.c:4433
 msgid "unsupported reloc"
 msgstr ""
 
-#: elf32-ia64.c:4477 elf64-ia64.c:4477
+#: elf32-ia64.c:4471 elf64-ia64.c:4471
 msgid ""
 "%B: missing TLS section for relocation %s against `%s' at 0x%lx in section `"
 "%A'."
 msgstr ""
 
-#: elf32-ia64.c:4492 elf64-ia64.c:4492
+#: elf32-ia64.c:4486 elf64-ia64.c:4486
 msgid ""
 "%B: Can't relax br (%s) to `%s' at 0x%lx in section `%A' with size 0x%lx (> "
 "0x1000000)."
 msgstr ""
 
-#: elf32-ia64.c:4754 elf64-ia64.c:4754
+#: elf32-ia64.c:4748 elf64-ia64.c:4748
 msgid "%B: linking trap-on-NULL-dereference with non-trapping files"
 msgstr ""
 
-#: elf32-ia64.c:4763 elf64-ia64.c:4763
+#: elf32-ia64.c:4757 elf64-ia64.c:4757
 msgid "%B: linking big-endian files with little-endian files"
 msgstr ""
 
-#: elf32-ia64.c:4772 elf64-ia64.c:4772
+#: elf32-ia64.c:4766 elf64-ia64.c:4766
 msgid "%B: linking 64-bit files with 32-bit files"
 msgstr ""
 
-#: elf32-ia64.c:4781 elf64-ia64.c:4781
+#: elf32-ia64.c:4775 elf64-ia64.c:4775
 msgid "%B: linking constant-gp files with non-constant-gp files"
 msgstr ""
 
-#: elf32-ia64.c:4791 elf64-ia64.c:4791
+#: elf32-ia64.c:4785 elf64-ia64.c:4785
 msgid "%B: linking auto-pic files with non-auto-pic files"
 msgstr ""
 
diff --git a/bfd/po/es.po b/bfd/po/es.po
index a166338..cbdfe90 100644
--- a/bfd/po/es.po
+++ b/bfd/po/es.po
@@ -1,14 +1,14 @@
-# Mensajes en español para bfd 2.20.90.
-# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+# Mensajes en español para bfd 2.22.90.
+# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 # This file is distributed under the same license as the binutils package.
-# Cristian Othón Martínez Vera <[email protected]>, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+# Cristian Othón Martínez Vera <[email protected]>, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: bfd 2.20.90\n"
+"Project-Id-Version: bfd 2.22.90\n"
 "Report-Msgid-Bugs-To: [email protected]\n"
-"POT-Creation-Date: 2010-11-05 11:31+0100\n"
-"PO-Revision-Date: 2011-08-24 11:47-0500\n"
+"POT-Creation-Date: 2011-10-25 11:58+0100\n"
+"PO-Revision-Date: 2012-07-27 12:29-0500\n"
 "Last-Translator: Cristian Othón Martínez Vera <[email protected]>\n"
 "Language-Team: Spanish <[email protected]>\n"
 "Language: es\n"
@@ -43,133 +43,133 @@
 msgid "%s: can not represent section for symbol `%s' in a.out object file format"
 msgstr "%s: no se puede representar la sección para el símbolo `%s' en el formato de fichero objeto a.out"
 
-#: aoutx.h:1579 vms-alpha.c:7649
+#: aoutx.h:1579 vms-alpha.c:7671
 msgid "*unknown*"
 msgstr "*desconocido*"
 
-#: aoutx.h:4007 aoutx.h:4333
+#: aoutx.h:4018 aoutx.h:4344
 msgid "%P: %B: unexpected relocation type\n"
 msgstr "%P: %B: tipo de reubicación inesperado\n"
 
-#: aoutx.h:5364
+#: aoutx.h:5375
 #, c-format
 msgid "%s: relocatable link from %s to %s not supported"
 msgstr "%s: no se admite el enlace reubicable de %s a %s"
 
-#: archive.c:2125
+#: archive.c:2203
 msgid "Warning: writing archive was slow: rewriting timestamp\n"
 msgstr "Aviso: la escritura del fichero fue lenta: se reescribe la marca de tiempo\n"
 
 # ¡Uff! Si utilizáramos file=archivo, esta traducción sería imposible. cfuga
-#: archive.c:2416
+#: archive.c:2491
 msgid "Reading archive file mod timestamp"
 msgstr "Se lee la marca de tiempo modificada del fichero en el archivo"
 
-#: archive.c:2440
+#: archive.c:2515
 msgid "Writing updated armap timestamp"
 msgstr "Se escribe la marca de tiempo actualizada de armap"
 
-#: bfd.c:395
+#: bfd.c:398
 msgid "No error"
 msgstr "No hay error"
 
-#: bfd.c:396
+#: bfd.c:399
 msgid "System call error"
 msgstr "Error en la llamada al sistema"
 
-#: bfd.c:397
+#: bfd.c:400
 msgid "Invalid bfd target"
 msgstr "Objetivo bfd inválido"
 
-#: bfd.c:398
+#: bfd.c:401
 msgid "File in wrong format"
 msgstr "Fichero en formato erróneo"
 
-#: bfd.c:399
+#: bfd.c:402
 msgid "Archive object file in wrong format"
 msgstr "Archivo de ficheros objeto en formato erróneo"
 
-#: bfd.c:400
+#: bfd.c:403
 msgid "Invalid operation"
 msgstr "Operación inválida"
 
-#: bfd.c:401
+#: bfd.c:404
 msgid "Memory exhausted"
 msgstr "Memoria agotada"
 
-#: bfd.c:402
+#: bfd.c:405
 msgid "No symbols"
 msgstr "No hay símbolos"
 
-#: bfd.c:403
+#: bfd.c:406
 msgid "Archive has no index; run ranlib to add one"
 msgstr "El archivo no tiene índice; ejecute ranlib para agregar uno"
 
-#: bfd.c:404
+#: bfd.c:407
 msgid "No more archived files"
 msgstr "No hay más ficheros archivados"
 
-#: bfd.c:405
+#: bfd.c:408
 msgid "Malformed archive"
 msgstr "Archivo malformado"
 
-#: bfd.c:406
+#: bfd.c:409
 msgid "File format not recognized"
 msgstr "No se reconoce el formato del fichero"
 
-#: bfd.c:407
+#: bfd.c:410
 msgid "File format is ambiguous"
 msgstr "El formato del fichero es ambiguo"
 
-#: bfd.c:408
+#: bfd.c:411
 msgid "Section has no contents"
 msgstr "La sección no tiene contenido"
 
-#: bfd.c:409
+#: bfd.c:412
 msgid "Nonrepresentable section on output"
 msgstr "Sección no representable en la salida"
 
-#: bfd.c:410
+#: bfd.c:413
 msgid "Symbol needs debug section which does not exist"
 msgstr "Un símbolo requiere de una sección de depuración, la cual no existe"
 
-#: bfd.c:411
+#: bfd.c:414
 msgid "Bad value"
 msgstr "Valor erróneo"
 
-#: bfd.c:412
+#: bfd.c:415
 msgid "File truncated"
 msgstr "Fichero truncado"
 
-#: bfd.c:413
+#: bfd.c:416
 msgid "File too big"
 msgstr "El fichero es demasiado grande"
 
-#: bfd.c:414
+#: bfd.c:417
 #, c-format
 msgid "Error reading %s: %s"
 msgstr "Error al leer %s: %s"
 
-#: bfd.c:415
+#: bfd.c:418
 msgid "#<Invalid error code>"
 msgstr "#<Código de error inválido>"
 
-#: bfd.c:939
+#: bfd.c:945
 #, c-format
 msgid "BFD %s assertion fail %s:%d"
 msgstr "falló la aseveración BFD %s %s:%d"
 
-#: bfd.c:951
+#: bfd.c:957
 #, c-format
 msgid "BFD %s internal error, aborting at %s line %d in %s\n"
 msgstr "error interno de BFD %s, se aborta en %s línea %d en %s\n"
 
-#: bfd.c:955
+#: bfd.c:961
 #, c-format
 msgid "BFD %s internal error, aborting at %s line %d\n"
 msgstr "error interno de BFD %s, se aborta en %s línea %d\n"
 
-#: bfd.c:957
+#: bfd.c:963
 msgid "Please report this bug.\n"
 msgstr "Por favor reporte este bicho.\n"
 
@@ -188,13 +188,13 @@
 msgid "Warning: Writing section `%s' to huge (ie negative) file offset 0x%lx."
 msgstr "Aviso: Se escribe la sección `%s' a un desplazamiento de fichero grande (pe negativo) 0x%lx."
 
-#: bout.c:1146 elf-m10300.c:2063 elf32-avr.c:1640 elf32-frv.c:5740
-#: elfxx-sparc.c:2795 reloc.c:5646 reloc16.c:162 elf32-ia64.c:842
-#: elf64-ia64.c:842
+#: bout.c:1146 elf-m10300.c:2063 elf32-avr.c:1654 elf32-frv.c:5734
+#: elfxx-sparc.c:2802 reloc.c:6115 reloc16.c:162 elf32-ia64.c:360
+#: elf64-ia64.c:360
 msgid "%P%F: --relax and -r may not be used together\n"
 msgstr "%P%F: --relax y -r no se pueden usar juntos\n"
 
-#: cache.c:226
+#: cache.c:227
 msgid "reopening %B: %s\n"
 msgstr "se reabre %B: %s\n"
 
@@ -226,8 +226,8 @@
 msgid "%B: unsupported relocation: ALPHA_R_GPRELLOW"
 msgstr "%B: tipo de reubicación no admitida: ALPHA_R_GPRELLOW"
 
-#: coff-alpha.c:1575 elf32-m32r.c:2493 elf64-alpha.c:3991 elf64-alpha.c:4140
-#: elf32-ia64.c:4582 elf64-ia64.c:4582
+#: coff-alpha.c:1575 elf32-m32r.c:2484 elf64-alpha.c:4074 elf64-alpha.c:4224
+#: elf32-ia64.c:3839 elf64-ia64.c:3839
 msgid "%B: unknown relocation type %d"
 msgstr "%B: tipo de reubicación %d desconocido"
 
@@ -241,7 +241,7 @@
 msgid "%B: unable to find ARM glue '%s' for `%s'"
 msgstr "%B: no se puede encontrar el pegamento ARM '%s' para `%s'"
 
-#: coff-arm.c:1369 elf32-arm.c:6501
+#: coff-arm.c:1369 elf32-arm.c:7023
 #, c-format
 msgid ""
 "%B(%s): warning: interworking not enabled.\n"
@@ -261,7 +261,7 @@
 "  primer suceso: %B: llamada thumb a arm\n"
 "  considere reenlazar con --support-old-code activado"
 
-#: coff-arm.c:1754 coff-tic80.c:695 cofflink.c:3043
+#: coff-arm.c:1754 coff-tic80.c:695 cofflink.c:3081
 msgid "%B: bad reloc address 0x%lx in section `%A'"
 msgstr "%B: dirección de reubicación 0x%lx errónea en la sección `%A'"
 
@@ -274,12 +274,12 @@
 msgid "error: %B is compiled for APCS-%d, whereas %B is compiled for APCS-%d"
 msgstr "error: %B está compilado para APCS-%d, mientras que %B está compilado para APCS-%d"
 
-#: coff-arm.c:2226 elf32-arm.c:14105
+#: coff-arm.c:2226 elf32-arm.c:15621
 #, c-format
 msgid "error: %B passes floats in float registers, whereas %B passes them in integer registers"
 msgstr "error: %B pasa números de coma flotante en registros de coma flotante, mientras que %B los pasa en registros enteros"
 
-#: coff-arm.c:2229 elf32-arm.c:14109
+#: coff-arm.c:2229 elf32-arm.c:15625
 #, c-format
 msgid "error: %B passes floats in integer registers, whereas %B passes them in float registers"
 msgstr "error: %B pasa números de coma flotante en registros enteros, mientras que %B los pasa en registros de coma flotante"
@@ -294,12 +294,12 @@
 msgid "error: %B is compiled as absolute position code, whereas target %B is position independent"
 msgstr "error: %B está compilado como código de posición absoluta, mientras que el objetivo %B es independiente de posición"
 
-#: coff-arm.c:2274 elf32-arm.c:14174
+#: coff-arm.c:2274 elf32-arm.c:15690
 #, c-format
 msgid "Warning: %B supports interworking, whereas %B does not"
 msgstr "Aviso: %B admite interoperabilidad, mientras que %B no"
 
-#: coff-arm.c:2277 elf32-arm.c:14180
+#: coff-arm.c:2277 elf32-arm.c:15696
 #, c-format
 msgid "Warning: %B does not support interworking, whereas %B does"
 msgstr "Aviso: %B no admite interoperabilidad, mientras que %B sí"
@@ -309,7 +309,7 @@
 msgid "private flags = %x:"
 msgstr "opciones privadas = %x:"
 
-#: coff-arm.c:2309 elf32-arm.c:10492
+#: coff-arm.c:2309 elf32-arm.c:11806
 #, c-format
 msgid " [floats passed in float registers]"
 msgstr "[números de coma flotante pasados en registros de coma flotante]"
@@ -319,7 +319,7 @@
 msgid " [floats passed in integer registers]"
 msgstr "[números de coma flotante pasados en registros enteros]"
 
-#: coff-arm.c:2314 elf32-arm.c:10495
+#: coff-arm.c:2314 elf32-arm.c:11809
 #, c-format
 msgid " [position independent]"
 msgstr "[independiente de posición]"
@@ -344,12 +344,12 @@
 msgid " [interworking not supported]"
 msgstr "[no admite interoperabilidad]"
 
-#: coff-arm.c:2370 elf32-arm.c:9520
+#: coff-arm.c:2370 elf32-arm.c:10841
 #, c-format
 msgid "Warning: Not setting interworking flag of %B since it has already been specified as non-interworking"
 msgstr "Aviso: No se establece la opción de interoperabilidad de %B ya que se había especificado con anterioridad como no interoperable"
 
-#: coff-arm.c:2374 elf32-arm.c:9524
+#: coff-arm.c:2374 elf32-arm.c:10845
 #, c-format
 msgid "Warning: Clearing the interworking flag of %B due to outside request"
 msgstr "Aviso: Se limpia la opción de interoperabilidad de %B debido a una petición externa"
@@ -361,23 +361,23 @@
 
 #: coff-i860.c:147
 #, c-format
-msgid "Relocation `%s' not yet implemented\n"
-msgstr "La reubicación `%s' aún no está implementada\n"
+msgid "relocation `%s' not yet implemented"
+msgstr "la reubicación `%s' aún no se implementa"
 
-#: coff-i860.c:605 coff-tic54x.c:398 coffcode.h:5147
+#: coff-i860.c:605 coff-tic54x.c:398 coffcode.h:5198
 msgid "%B: warning: illegal symbol index %ld in relocs"
 msgstr "%B: aviso: índice de símbolos %ld ilegal en reubicaciones"
 
-#: coff-i960.c:143 coff-i960.c:506
+#: coff-i960.c:144 coff-i960.c:507
 msgid "uncertain calling convention for non-COFF symbol"
 msgstr "convención de llamada incierta para un símbolo que no es COFF"
 
-#: coff-m68k.c:506 elf32-bfin.c:5678 elf32-cr16.c:2897 elf32-m68k.c:4672
+#: coff-m68k.c:506 elf32-bfin.c:5690 elf32-cr16.c:2897 elf32-m68k.c:4677
 msgid "unsupported reloc type"
 msgstr "no se admite el tipo de reubicación"
 
-#: coff-mips.c:688 elf32-mips.c:1014 elf32-score.c:430 elf32-score7.c:330
-#: elf64-mips.c:2019 elfn32-mips.c:1832
+#: coff-mips.c:688 elf32-mips.c:1516 elf32-score.c:431 elf32-score7.c:330
+#: elf64-mips.c:2618 elfn32-mips.c:2431
 msgid "GP relative relocation when _gp not defined"
 msgstr "reubicación relativa a GP cuando _gp no está definido"
 
@@ -385,20 +385,25 @@
 msgid "Unrecognized reloc"
 msgstr "No se reconoce la reubicación"
 
-#: coff-rs6000.c:2794
+#: coff-rs6000.c:2720
 #, c-format
 msgid "%s: unsupported relocation type 0x%02x"
 msgstr "%s: no se admite el tipo de reubicación 0x%02x"
 
-#: coff-rs6000.c:2887
+#: coff-rs6000.c:2805
 #, c-format
 msgid "%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"
 msgstr "%s: reubicación de TOC en 0x%x al símbolo `%s' sin entrada TOC"
 
-#: coff-rs6000.c:3652 coff64-rs6000.c:2175
+#: coff-rs6000.c:3556 coff64-rs6000.c:2111
 msgid "%B: symbol `%s' has unrecognized smclas %d"
 msgstr "%B: el símbolo `%s' tiene smclas %d que no se reconoce"
 
+#: coff-sh.c:521
+#, c-format
+msgid "SH Error: unknown reloc type %d"
+msgstr "Error SH: tipo de reubicación %d desconocido"
+
 #: coff-tic4x.c:195 coff-tic54x.c:299 coff-tic80.c:458
 #, c-format
 msgid "Unrecognized reloc type 0x%x"
@@ -414,80 +419,88 @@
 msgid "ignoring reloc %s\n"
 msgstr "se descarta la reubicación %s\n"
 
-#: coffcode.h:973
+#: coffcode.h:997
 msgid "%B: warning: COMDAT symbol '%s' does not match section name '%s'"
 msgstr "%B: aviso: el símbolo COMDAT '%s' no coincide con el nombre de sección '%s'"
 
 #. Generate a warning message rather using the 'unhandled'
 #. variable as this will allow some .sys files generate by
 #. other toolchains to be processed.  See bugzilla issue 196.
-#: coffcode.h:1197
+#: coffcode.h:1221
 msgid "%B: Warning: Ignoring section flag IMAGE_SCN_MEM_NOT_PAGED in section %s"
 msgstr "%B: Aviso: Se descarta la opción de sección IMAGE_SCN_MEM_NOT_PAGED en la sección %s"
 
-#: coffcode.h:1264
+#: coffcode.h:1288
 msgid "%B (%s): Section flag %s (0x%x) ignored"
 msgstr "%B (%s): Se descarta la opción de sección %s (0x%x)"
 
-#: coffcode.h:2390
+#: coffcode.h:2430
 #, c-format
 msgid "Unrecognized TI COFF target id '0x%x'"
 msgstr "No se reconoce el id de objetivo COFF TI '0x%x'"
 
-#: coffcode.h:2704
+#: coffcode.h:2744
 msgid "%B: reloc against a non-existant symbol index: %ld"
 msgstr "%B: reubicación contra un índice de símbolo que no existe: %ld"
 
-#: coffcode.h:3262
+#: coffcode.h:3302
 msgid "%B: too many sections (%d)"
 msgstr "%B: Demasiadas secciones (%d)"
 
-#: coffcode.h:3676
+#: coffcode.h:3718
 msgid "%B: section %s: string table overflow at offset %ld"
 msgstr "%B: sección %s: desbordamiento de tabla de cadenas en el desplazamiento %ld"
 
-#: coffcode.h:4481
+#: coffcode.h:4523
 msgid "%B: warning: line number table read failed"
 msgstr "%B: aviso: falló la lectura de tabla de números de línea"
 
-#: coffcode.h:4511
+#: coffcode.h:4553
 msgid "%B: warning: illegal symbol index %ld in line numbers"
 msgstr "%B: aviso: índice de símbolos %ld ilegal en los números de línea"
 
-#: coffcode.h:4525
+#: coffcode.h:4567
 msgid "%B: warning: duplicate line number information for `%s'"
 msgstr "%B: aviso: información de números de línea duplicada para `%s'"
 
-#: coffcode.h:4916
+#: coffcode.h:4967
 msgid "%B: Unrecognized storage class %d for %s symbol `%s'"
 msgstr "%B: No se reconoce la clase de almacenamiento %d para %s símbolo `%s'"
 
-#: coffcode.h:5042
+#: coffcode.h:5093
 msgid "warning: %B: local symbol `%s' has no section"
 msgstr "aviso: %B: el símbolo local `%s' no tiene sección"
 
-#: coffcode.h:5186
+#: coffcode.h:5237
 msgid "%B: illegal relocation type %d at address 0x%lx"
 msgstr "%B: tipo de reubicación %d ilegal en la dirección 0x%lx"
 
-#: coffgen.c:1573
+#: coffgen.c:1595
 msgid "%B: bad string table size %lu"
 msgstr "%B: tamaño de tabla de cadenas %lu erróneo"
 
-#: cofflink.c:524 elflink.c:4339
+#: coffgen.c:2500 elflink.c:12689 linker.c:3122
+msgid "%F%P: already_linked_table: %E\n"
+msgstr "%F%P: already_linked_table: %E\n"
+
+#: cofflink.c:533 elflink.c:4323
 msgid "Warning: type of symbol `%s' changed from %d to %d in %B"
 msgstr "Aviso: el tipo del símbolo `%s' cambió de %d a %d en %B"
 
-#: cofflink.c:2321
+#: cofflink.c:2329
 msgid "%B: relocs in section `%A', but it has no contents"
 msgstr "%B: reubicaciones en la sección `%A', pero no tiene contenido"
 
-#: cofflink.c:2652 coffswap.h:826
+#: cofflink.c:2391 elflink.c:9545
+msgid "%X`%s' referenced in section `%A' of %B: defined in discarded section `%A' of %B\n"
+msgstr "%X`%s' referido en la sección `%A' de %B: se definió en la sección descartada `%A' de %B\n"
+
+#: cofflink.c:2690 coffswap.h:826
 #, c-format
 msgid "%s: %s: reloc overflow: 0x%lx > 0xffff"
 msgstr "%s: %s: desbordamiento de reubicación: 0x%lx > 0xffff"
 
-#: cofflink.c:2661 coffswap.h:812
+#: cofflink.c:2699 coffswap.h:812
 #, c-format
 msgid "%s: warning: %s: line number overflow: 0x%lx > 0xffff"
 msgstr "%s: aviso: %s: desbordamiento de número de línea: 0x%lx > 0xffff"
@@ -501,64 +514,64 @@
 msgid "warning: unable to update contents of %s section in %s"
 msgstr "aviso: no se puede actualizar el contenido de la sección %s en %s"
 
-#: dwarf2.c:490
+#: dwarf2.c:496
 #, c-format
 msgid "Dwarf Error: Can't find %s section."
 msgstr "Error de Dwarf: No se puede encontrar la sección %s."
 
-#: dwarf2.c:518
+#: dwarf2.c:525
 #, c-format
 msgid "Dwarf Error: Offset (%lu) greater than or equal to %s size (%lu)."
 msgstr "Error de Dwarf: El desplazamiento (%lu) es mayor que o igual que el tamaño de %s (%lu)."
 
-#: dwarf2.c:940
+#: dwarf2.c:949
 #, c-format
 msgid "Dwarf Error: Invalid or unhandled FORM value: %u."
 msgstr "Error de Dwarf: Valor de FORM sin manejar o inválido: %u."
 
-#: dwarf2.c:1191
+#: dwarf2.c:1200
 msgid "Dwarf Error: mangled line number section (bad file number)."
 msgstr "Error de Dwarf: sección de números de línea revuelta (número de fichero erróneo)."
 
-#: dwarf2.c:1443
+#: dwarf2.c:1453
 #, c-format
 msgid "Dwarf Error: Unhandled .debug_line version %d."
 msgstr "Error de Dwarf: .debug_line versión %d sin manejar."
 
-#: dwarf2.c:1465
+#: dwarf2.c:1475
 msgid "Dwarf Error: Invalid maximum operations per instruction."
 msgstr "Error de Dwarf: Máximo de operaciones por instrucción inválido."
 
-#: dwarf2.c:1652
+#: dwarf2.c:1662
 msgid "Dwarf Error: mangled line number section."
 msgstr "Error de Dwarf: sección de números de línea revuelta."
 
-#: dwarf2.c:1978 dwarf2.c:2098 dwarf2.c:2382
+#: dwarf2.c:1989 dwarf2.c:2109 dwarf2.c:2394
 #, c-format
 msgid "Dwarf Error: Could not find abbrev number %u."
 msgstr "Error de Dwarf: No se puede encontrar el número de abreviatura %u."
 
-#: dwarf2.c:2343
+#: dwarf2.c:2355
 #, c-format
 msgid "Dwarf Error: found dwarf version '%u', this reader only handles version 2, 3 and 4 information."
 msgstr "Error de Dwarf: se encontró la versión de dwarf '%u', este lector solamente maneja información de las versiones 2, 3 y 4."
 
-#: dwarf2.c:2350
+#: dwarf2.c:2362
 #, c-format
 msgid "Dwarf Error: found address size '%u', this reader can not handle sizes greater than '%u'."
 msgstr "Error de Dwarf: se encontró el tamaño de dirección '%u', este lector no puede manejar tamaños más grandes que '%u'."
 
-#: dwarf2.c:2373
+#: dwarf2.c:2385
 #, c-format
 msgid "Dwarf Error: Bad abbrev number: %u."
 msgstr "Error de Dwarf: Número de abreviación erróneo: %u."
 
-#: ecoff.c:1237
+#: ecoff.c:1239
 #, c-format
 msgid "Unknown basic type %d"
 msgstr "Tipo básico %d desconocido"
 
-#: ecoff.c:1494
+#: ecoff.c:1496
 #, c-format
 msgid ""
 "\n"
@@ -567,7 +580,7 @@
 "\n"
 "      Símbolo final+1: %ld"
 
-#: ecoff.c:1501 ecoff.c:1504
+#: ecoff.c:1503 ecoff.c:1506
 #, c-format
 msgid ""
 "\n"
@@ -576,7 +589,7 @@
 "\n"
 "      Primer símbolo: %ld"
 
-#: ecoff.c:1516
+#: ecoff.c:1518
 #, c-format
 msgid ""
 "\n"
@@ -585,7 +598,7 @@
 "\n"
 "      Símbolo final+1: %-7ld Tipo: %s"
 
-#: ecoff.c:1523
+#: ecoff.c:1525
 #, c-format
 msgid ""
 "\n"
@@ -594,7 +607,7 @@
 "\n"
 "      Símbolo local: %ld"
 
-#: ecoff.c:1531
+#: ecoff.c:1533
 #, c-format
 msgid ""
 "\n"
@@ -603,7 +616,7 @@
 "\n"
 "      struct; símbolo final+1: %ld"
 
-#: ecoff.c:1536
+#: ecoff.c:1538
 #, c-format
 msgid ""
 "\n"
@@ -612,7 +625,7 @@
 "\n"
 "      union; símbolo final+1: %ld"
 
-#: ecoff.c:1541
+#: ecoff.c:1543
 #, c-format
 msgid ""
 "\n"
@@ -621,7 +634,7 @@
 "\n"
 "      enum; símbolo final+1: %ld"
 
-#: ecoff.c:1547
+#: ecoff.c:1549
 #, c-format
 msgid ""
 "\n"
@@ -638,79 +651,87 @@
 msgid "error: %B: Object tag '%d, %s' is incompatible with tag '%d, %s'"
 msgstr "error: %B: La etiqueta de objeto '%d, %s' es incompatible con la etiqueta '%d, %s'"
 
-#: elf-eh-frame.c:913
+#: elf-eh-frame.c:917
 msgid "%P: error in %B(%A); no .eh_frame_hdr table will be created.\n"
 msgstr "%P: error en %B(%A); no se creará la tabla .eh_frame_hdr.\n"
 
-#: elf-eh-frame.c:1165
+#: elf-eh-frame.c:1189
 msgid "%P: fde encoding in %B(%A) prevents .eh_frame_hdr table being created.\n"
 msgstr "%P: la codificación fde en %B(%A) previene la creación de la tabla .eh_frame_hdr.\n"
 
+#: elf-eh-frame.c:1605
+msgid "%P: DW_EH_PE_datarel unspecified for this architecture.\n"
+msgstr "%P: DW_EH_PE_datarel sin especificar para esta arquitectura.\n"
+
 #: elf-ifunc.c:179
 msgid "%F%P: dynamic STT_GNU_IFUNC symbol `%s' with pointer equality in `%B' can not be used when making an executable; recompile with -fPIE and relink with -pie\n"
 msgstr "%F%P: el símbolo STT_GNU_IFUNC dinámico `%s' con igualdad de puntero en `%B' no se puede usar al hacer un ejecutable; recompile con -fPIE y reenlace con -pie\n"
 
-#: elf-m10200.c:450 elf-m10300.c:1560 elf32-avr.c:1263 elf32-bfin.c:3193
-#: elf32-cr16.c:1482 elf32-cr16c.c:780 elf32-cris.c:2077 elf32-crx.c:922
-#: elf32-d10v.c:509 elf32-fr30.c:609 elf32-frv.c:4111 elf32-h8300.c:509
-#: elf32-i860.c:1211 elf32-ip2k.c:1468 elf32-iq2000.c:684 elf32-lm32.c:1168
-#: elf32-m32c.c:553 elf32-m32r.c:3111 elf32-m68hc1x.c:1138 elf32-mep.c:534
-#: elf32-microblaze.c:1231 elf32-moxie.c:282 elf32-msp430.c:486 elf32-mt.c:395
-#: elf32-openrisc.c:404 elf32-score.c:2731 elf32-score7.c:2540
-#: elf32-spu.c:5042 elf32-v850.c:2143 elf32-xstormy16.c:941 elf64-mmix.c:1522
+#: elf-m10200.c:450 elf-m10300.c:1563 elf32-avr.c:1221 elf32-bfin.c:3213
+#: elf32-cr16.c:1482 elf32-cr16c.c:780 elf32-cris.c:2081 elf32-crx.c:922
+#: elf32-d10v.c:509 elf32-epiphany.c:556 elf32-fr30.c:609 elf32-frv.c:4105
+#: elf32-h8300.c:509 elf32-i860.c:1211 elf32-ip2k.c:1468 elf32-iq2000.c:684
+#: elf32-lm32.c:1168 elf32-m32c.c:553 elf32-m32r.c:3106 elf32-m68hc1x.c:1138
+#: elf32-mep.c:535 elf32-microblaze.c:1231 elf32-moxie.c:282
+#: elf32-msp430.c:486 elf32-mt.c:395 elf32-openrisc.c:404 elf32-score.c:2729
+#: elf32-score7.c:2537 elf32-spu.c:5044 elf32-tilepro.c:3214 elf32-v850.c:2143
+#: elf32-xstormy16.c:935 elf64-mmix.c:1590 elfxx-tilegx.c:3577
 msgid "internal error: out of range error"
 msgstr "error interno: error fuera de rango"
 
-#: elf-m10200.c:454 elf-m10300.c:1564 elf32-avr.c:1267 elf32-bfin.c:3197
-#: elf32-cr16.c:1486 elf32-cr16c.c:784 elf32-cris.c:2081 elf32-crx.c:926
-#: elf32-d10v.c:513 elf32-fr30.c:613 elf32-frv.c:4115 elf32-h8300.c:513
+#: elf-m10200.c:454 elf-m10300.c:1567 elf32-avr.c:1225 elf32-bfin.c:3217
+#: elf32-cr16.c:1486 elf32-cr16c.c:784 elf32-cris.c:2085 elf32-crx.c:926
+#: elf32-d10v.c:513 elf32-fr30.c:613 elf32-frv.c:4109 elf32-h8300.c:513
 #: elf32-i860.c:1215 elf32-iq2000.c:688 elf32-lm32.c:1172 elf32-m32c.c:557
-#: elf32-m32r.c:3115 elf32-m68hc1x.c:1142 elf32-mep.c:538
+#: elf32-m32r.c:3110 elf32-m68hc1x.c:1142 elf32-mep.c:539
 #: elf32-microblaze.c:1235 elf32-moxie.c:286 elf32-msp430.c:490
-#: elf32-openrisc.c:408 elf32-score.c:2735 elf32-score7.c:2544
-#: elf32-spu.c:5046 elf32-v850.c:2147 elf32-xstormy16.c:945 elf64-mmix.c:1526
-#: elfxx-mips.c:9186
+#: elf32-openrisc.c:408 elf32-score.c:2733 elf32-score7.c:2541
+#: elf32-spu.c:5048 elf32-tilepro.c:3218 elf32-v850.c:2147
+#: elf32-xstormy16.c:939 elf64-mmix.c:1594 elfxx-mips.c:9465
+#: elfxx-tilegx.c:3581
 msgid "internal error: unsupported relocation error"
 msgstr "error interno: no se admite el error de reubicación"
 
 #: elf-m10200.c:458 elf32-cr16.c:1490 elf32-cr16c.c:788 elf32-crx.c:930
-#: elf32-d10v.c:517 elf32-h8300.c:517 elf32-lm32.c:1176 elf32-m32r.c:3119
-#: elf32-m68hc1x.c:1146 elf32-microblaze.c:1239 elf32-score.c:2739
-#: elf32-score7.c:2548 elf32-spu.c:5050
+#: elf32-d10v.c:517 elf32-h8300.c:517 elf32-lm32.c:1176 elf32-m32r.c:3114
+#: elf32-m68hc1x.c:1146 elf32-microblaze.c:1239 elf32-score.c:2737
+#: elf32-score7.c:2545 elf32-spu.c:5052
 msgid "internal error: dangerous error"
 msgstr "error interno: error peligroso"
 
-#: elf-m10200.c:462 elf-m10300.c:1577 elf32-avr.c:1275 elf32-bfin.c:3205
-#: elf32-cr16.c:1494 elf32-cr16c.c:792 elf32-cris.c:2089 elf32-crx.c:934
-#: elf32-d10v.c:521 elf32-fr30.c:621 elf32-frv.c:4123 elf32-h8300.c:521
-#: elf32-i860.c:1223 elf32-ip2k.c:1483 elf32-iq2000.c:696 elf32-lm32.c:1180
-#: elf32-m32c.c:565 elf32-m32r.c:3123 elf32-m68hc1x.c:1150 elf32-mep.c:546
-#: elf32-microblaze.c:1243 elf32-moxie.c:294 elf32-msp430.c:498 elf32-mt.c:403
-#: elf32-openrisc.c:416 elf32-score.c:2748 elf32-score7.c:2552
-#: elf32-spu.c:5054 elf32-v850.c:2167 elf32-xstormy16.c:953 elf64-mmix.c:1534
+#: elf-m10200.c:462 elf-m10300.c:1580 elf32-avr.c:1233 elf32-bfin.c:3225
+#: elf32-cr16.c:1494 elf32-cr16c.c:792 elf32-cris.c:2093 elf32-crx.c:934
+#: elf32-d10v.c:521 elf32-epiphany.c:571 elf32-fr30.c:621 elf32-frv.c:4117
+#: elf32-h8300.c:521 elf32-i860.c:1223 elf32-ip2k.c:1483 elf32-iq2000.c:696
+#: elf32-lm32.c:1180 elf32-m32c.c:565 elf32-m32r.c:3118 elf32-m68hc1x.c:1150
+#: elf32-mep.c:547 elf32-microblaze.c:1243 elf32-moxie.c:294
+#: elf32-msp430.c:498 elf32-mt.c:403 elf32-openrisc.c:416 elf32-score.c:2746
+#: elf32-score7.c:2549 elf32-spu.c:5056 elf32-tilepro.c:3226 elf32-v850.c:2167
+#: elf32-xstormy16.c:947 elf64-mmix.c:1602 elfxx-tilegx.c:3589
 msgid "internal error: unknown error"
 msgstr "error interno: error desconocido"
 
-#: elf-m10300.c:1504 elf32-arm.c:9098 elf32-i386.c:4081 elf32-m32r.c:2604
-#: elf32-m68k.c:4156 elf32-ppc.c:8089 elf32-s390.c:3010 elf32-sh.c:4223
-#: elf32-xtensa.c:3067 elf64-ppc.c:13115 elf64-s390.c:2985 elf64-sh64.c:1636
-#: elf64-x86-64.c:3719 elfxx-sparc.c:3806
+#: elf-m10300.c:1507 elf32-arm.c:10419 elf32-i386.c:4264 elf32-m32r.c:2599
+#: elf32-m68k.c:4156 elf32-s390.c:3003 elf32-sh.c:4218 elf32-tilepro.c:3117
+#: elf32-xtensa.c:3066 elf64-s390.c:2978 elf64-sh64.c:1640 elf64-x86-64.c:4110
+#: elfxx-sparc.c:3835 elfxx-tilegx.c:3500
 msgid "%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"
 msgstr "%B(%A+0x%lx): reubicación %s sin resolución contra el símbolo `%s'"
 
-#: elf-m10300.c:1569
+#: elf-m10300.c:1572
 msgid "error: inappropriate relocation type for shared library (did you forget -fpic?)"
 msgstr "error: tipo de reubicación inapropiada para la biblioteca compartida (¿olvidó -fpic?)"
 
-#: elf-m10300.c:1572
+#: elf-m10300.c:1575
 msgid "internal error: suspicious relocation type used in shared library"
 msgstr "error interno: se usó un tipo de reubicación sospechosa en la biblioteca compartida"
 
-#: elf-m10300.c:4372 elf32-arm.c:11392 elf32-cr16.c:2451 elf32-cris.c:3044
-#: elf32-hppa.c:1894 elf32-i370.c:503 elf32-i386.c:2036 elf32-lm32.c:1868
-#: elf32-m32r.c:1927 elf32-m68k.c:3252 elf32-ppc.c:4994 elf32-s390.c:1652
-#: elf32-sh.c:2931 elf32-vax.c:1040 elf64-ppc.c:6483 elf64-s390.c:1635
-#: elf64-sh64.c:3377 elf64-x86-64.c:1871 elfxx-sparc.c:2104
+#: elf-m10300.c:4372 elf32-arm.c:12800 elf32-cr16.c:2451 elf32-cris.c:3057
+#: elf32-hppa.c:1894 elf32-i370.c:503 elf32-i386.c:2182 elf32-lm32.c:1868
+#: elf32-m32r.c:1927 elf32-m68k.c:3253 elf32-s390.c:1652 elf32-sh.c:2931
+#: elf32-tic6x.c:2162 elf32-tilepro.c:1940 elf32-vax.c:1041 elf64-s390.c:1635
+#: elf64-sh64.c:3381 elf64-x86-64.c:2176 elfxx-sparc.c:2119
+#: elfxx-tilegx.c:2261
 #, c-format
 msgid "dynamic variable `%s' is zero size"
 msgstr "la variable dinámica `%s' es de tamaño cero"
@@ -735,7 +756,7 @@
 msgid "%B: no group info for section %A"
 msgstr "%B: no hay información de grupo para la sección %A"
 
-#: elf.c:737 elf.c:3090 elflink.c:10062
+#: elf.c:737 elf.c:3121 elflink.c:10135
 msgid "%B: warning: sh_link not set for section `%A'"
 msgstr "%B: aviso: no se estableció sh_link para la sección `%A'"
 
@@ -751,11 +772,11 @@
 msgid "%B: unable to initialize commpress status for section %s"
 msgstr "%B: no se puede inicializar el estado comprimido de la sección %s"
 
-#: elf.c:1050
+#: elf.c:1061
 msgid "%B: unable to initialize decommpress status for section %s"
 msgstr "%B: no se puede inicializar el estado descomprimido de la sección %s"
 
-#: elf.c:1158
+#: elf.c:1181
 #, c-format
 msgid ""
 "\n"
@@ -764,7 +785,7 @@
 "\n"
 "Encabezado del Programa:\n"
 
-#: elf.c:1200
+#: elf.c:1223
 #, c-format
 msgid ""
 "\n"
@@ -773,7 +794,7 @@
 "\n"
 "Sección Dinámica:\n"
 
-#: elf.c:1336
+#: elf.c:1359
 #, c-format
 msgid ""
 "\n"
@@ -782,7 +803,7 @@
 "\n"
 "Definiciones de versión:\n"
 
-#: elf.c:1361
+#: elf.c:1384
 #, c-format
 msgid ""
 "\n"
@@ -791,82 +812,82 @@
 "\n"
 "Referencias de versión:\n"
 
-#: elf.c:1366
+#: elf.c:1389
 #, c-format
 msgid "  required from %s:\n"
 msgstr "  se requere desde %s:\n"
 
-#: elf.c:1773
+#: elf.c:1796
 msgid "%B: invalid link %lu for reloc section %s (index %u)"
 msgstr "%B: enlace %lu inválido para la sección de reubicación %s (índice %u)"
 
-#: elf.c:1943
+#: elf.c:1966
 msgid "%B: don't know how to handle allocated, application specific section `%s' [0x%8x]"
 msgstr "%B: no se sabe cómo manejar la sección específica alojada de la aplicación `%s' [0x%8x]"
 
-#: elf.c:1955
+#: elf.c:1978
 msgid "%B: don't know how to handle processor specific section `%s' [0x%8x]"
 msgstr "%B: no se sabe cómo manejar la sección específica de procesador `%s' [0x%8x]"
 
-#: elf.c:1966
+#: elf.c:1989
 msgid "%B: don't know how to handle OS specific section `%s' [0x%8x]"
 msgstr "%B: no se sabe cómo manejar la sección específica de SO `%s' [0x%8x]"
 
-#: elf.c:1976
+#: elf.c:1999
 msgid "%B: don't know how to handle section `%s' [0x%8x]"
 msgstr "%B: no se sabe cómo manejar la sección `%s' [0x%8x]"
 
-#: elf.c:2603
+#: elf.c:2634
 #, c-format
 msgid "warning: section `%A' type changed to PROGBITS"
 msgstr "aviso: el tipo de la sección `%A' cambió a PROGBITS"
 
-#: elf.c:3047
+#: elf.c:3078
 msgid "%B: sh_link of section `%A' points to discarded section `%A' of `%B'"
 msgstr "%B: sh_link de la sección `%A' apunta a la sección descartada `%A' de `%B'"
 
-#: elf.c:3070
+#: elf.c:3101
 msgid "%B: sh_link of section `%A' points to removed section `%A' of `%B'"
 msgstr "%B: sh_link de la sección `%A' apunta a la sección eliminada `%A' de `%B'"
 
-#: elf.c:4480
+#: elf.c:4527
 msgid "%B: The first section in the PT_DYNAMIC segment is not the .dynamic section"
 msgstr "%B: La primera sección en el segmento PT_DYNAMIC no es la sección .dynamic"
 
-#: elf.c:4507
+#: elf.c:4554
 msgid "%B: Not enough room for program headers, try linking with -N"
 msgstr "%B: No hay suficiente espacio para los encabezados del programa, pruebe enlazar con -N"
 
-#: elf.c:4594
+#: elf.c:4641
 msgid "%B: section %A lma %#lx adjusted to %#lx"
 msgstr "%B: la sección %A lma %#lx se ajusta a %#lx"
 
-#: elf.c:4713
+#: elf.c:4776
 msgid "%B: section `%A' can't be allocated in segment %d"
 msgstr "%B: la sección `%A' no se puede asignar en el segmento %d"
 
-#: elf.c:4761
+#: elf.c:4824
 msgid "%B: warning: allocated section `%s' not in segment"
 msgstr "%B: aviso: la sección asignada `%s' no está en el segmento"
 
-#: elf.c:5257
+#: elf.c:5324
 msgid "%B: symbol `%s' required but not present"
 msgstr "%B: se requiere el símbolo `%s' pero no está presente"
 
-#: elf.c:5595
+#: elf.c:5662
 msgid "%B: warning: Empty loadable segment detected, is this intentional ?\n"
 msgstr "%B: aviso: Se detectó un segmento cargable vacío, ¿ esto es intencional ?\n"
 
-#: elf.c:6622
+#: elf.c:6692
 #, c-format
 msgid "Unable to find equivalent output section for symbol '%s' from section '%s'"
 msgstr "No se puede encontrar la sección de salida equivalente para el símbolo '%s' de la sección '%s'"
 
-#: elf.c:7611
+#: elf.c:7692
 msgid "%B: unsupported relocation type %s"
 msgstr "%B: no se admite el tipo de reubicación %s"
 
-#: elf32-arm.c:3183
+#: elf32-arm.c:3617
 msgid ""
 "%B(%s): warning: interworking not enabled.\n"
 "  first occurrence: %B: Thumb call to ARM"
@@ -874,7 +895,7 @@
 "%B(%s): aviso: no se activó la interoperabilidad.\n"
 "  primer suceso: %B: llamada Thumb a ARM"
 
-#: elf32-arm.c:3226
+#: elf32-arm.c:3664
 msgid ""
 "%B(%s): warning: interworking not enabled.\n"
 "  first occurrence: %B: ARM call to Thumb"
@@ -882,40 +903,40 @@
 "%B(%s): aviso: no se activó la interoperabilidad.\n"
 "  primer suceso: %B: llamada ARM a Thumb"
 
-#: elf32-arm.c:3432 elf32-arm.c:4807
+#: elf32-arm.c:3878 elf32-arm.c:5315
 #, c-format
 msgid "%s: cannot create stub entry %s"
 msgstr "%s: no se puede crear la entrada de cabo %s"
 
-#: elf32-arm.c:4923
+#: elf32-arm.c:5431
 #, c-format
 msgid "unable to find THUMB glue '%s' for '%s'"
 msgstr "no se puede encontrar el pegamento THUMB '%s' para `%s'"
 
-#: elf32-arm.c:4959
+#: elf32-arm.c:5467
 #, c-format
 msgid "unable to find ARM glue '%s' for '%s'"
 msgstr "no se puede encontrar el pegamento ARM '%s' para `%s'"
 
-#: elf32-arm.c:5485
+#: elf32-arm.c:6005
 msgid "%B: BE8 images only valid in big-endian mode."
 msgstr "%B: las imágenes BE8 sólo son válidas en modo big-endian."
 
 #. Give a warning, but do as the user requests anyway.
-#: elf32-arm.c:5715
+#: elf32-arm.c:6235
 msgid "%B: warning: selected VFP11 erratum workaround is not necessary for target architecture"
 msgstr "%B: aviso: no se necesita la alternativa para evitar la errata del VFP11 seleccionado para la arquitectura objetivo"
 
-#: elf32-arm.c:6259 elf32-arm.c:6279
+#: elf32-arm.c:6779 elf32-arm.c:6799
 msgid "%B: unable to find VFP11 veneer `%s'"
 msgstr "%B: no se puede encontrar la chapa de VFP11 `%s'"
 
-#: elf32-arm.c:6327
+#: elf32-arm.c:6848
 #, c-format
 msgid "Invalid TARGET2 relocation type '%s'."
 msgstr "Tipo de reubicación TARGET2 '%s' inválido."
 
-#: elf32-arm.c:6411
+#: elf32-arm.c:6933
 msgid ""
 "%B(%s): warning: interworking not enabled.\n"
 "  first occurrence: %B: thumb call to arm"
@@ -923,425 +944,451 @@
 "%s(%s): aviso: no se activó la interoperabilidad.\n"
 "  primer suceso: %B: llamada thumb a arm"
 
-#: elf32-arm.c:7130
+#: elf32-arm.c:7717
+msgid "%B(%A+0x%lx):unexpected Thumb instruction '0x%x' in TLS trampoline"
+msgstr "%B(%A+0x%lx):instrucción Thumb '0x%x' inesperada en el trampolín TLS"
+
+#: elf32-arm.c:7756
+msgid "%B(%A+0x%lx):unexpected ARM instruction '0x%x' in TLS trampoline"
+msgstr "%B(%A+0x%lx):instrucción ARM '0x%x' inesperada en el trampolín TLS"
+
+#: elf32-arm.c:8209
 msgid "\\%B: Warning: Arm BLX instruction targets Arm function '%s'."
 msgstr "\\%B: Aviso: La instrucción Arm BLX apunta a la función Arm '%s'."
 
-#: elf32-arm.c:7541
+#: elf32-arm.c:8622
 msgid "%B: Warning: Thumb BLX instruction targets thumb function '%s'."
 msgstr "%B: Aviso: La instrucción Thumb BLX apunta a la función thumb '%s'."
 
-#: elf32-arm.c:8223
+#: elf32-arm.c:9460
+msgid "%B(%A+0x%lx):unexpected Thumb instruction '0x%x' referenced by TLS_GOTDESC"
+msgstr "%B(%A+0x%lx):instrucción Thumb '0x%x' inesperada referenciada por TLS_GOTDESC"
+
+#: elf32-arm.c:9483
+msgid "%B(%A+0x%lx):unexpected ARM instruction '0x%x' referenced by TLS_GOTDESC"
+msgstr "%B(%A+0x%lx):instrucción ARM '0x%x' inesperada referenciada por TLS_GOTDESC"
+
+#: elf32-arm.c:9512
 msgid "%B(%A+0x%lx): R_ARM_TLS_LE32 relocation not permitted in shared object"
 msgstr "%B(%A+0x%lx): la reubicación R_ARM_TLS_LE32 no se permite en objetos compartidos"
 
-#: elf32-arm.c:8438
+#: elf32-arm.c:9727
 msgid "%B(%A+0x%lx): Only ADD or SUB instructions are allowed for ALU group relocations"
 msgstr "%B(%A+0x%lx): Sólo se permiten las instrucciones ADD o SUB en las reubicaciones de grupo ALU"
 
-#: elf32-arm.c:8478 elf32-arm.c:8565 elf32-arm.c:8648 elf32-arm.c:8733
+#: elf32-arm.c:9767 elf32-arm.c:9854 elf32-arm.c:9937 elf32-arm.c:10022
 msgid "%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"
 msgstr "%B(%A+0x%lx): Desborde al dividirse 0x%lx para la reubicación de grupo %s"
 
-#: elf32-arm.c:8963 elf32-sh.c:4112 elf64-sh64.c:1544
+#: elf32-arm.c:10261 elf32-sh.c:4103 elf64-sh64.c:1544
 msgid "%B(%A+0x%lx): %s relocation against SEC_MERGE section"
 msgstr "%B(%A+0x%lx): reubicación %s contra la sección SEC_MERGE"
 
-#: elf32-arm.c:9074 elf32-m68k.c:4191 elf32-xtensa.c:2805 elf64-ppc.c:11689
+#: elf32-arm.c:10372 elf32-m68k.c:4191 elf32-xtensa.c:2802
 msgid "%B(%A+0x%lx): %s used with TLS symbol %s"
 msgstr "%B(%A+0x%lx): se usó %s con el símbolo TLS %s"
 
-#: elf32-arm.c:9075 elf32-m68k.c:4192 elf32-xtensa.c:2806 elf64-ppc.c:11690
+#: elf32-arm.c:10373 elf32-m68k.c:4192 elf32-xtensa.c:2803
 msgid "%B(%A+0x%lx): %s used with non-TLS symbol %s"
 msgstr "%B(%A+0x%lx): se usó %s con el símbolo %s que no es TLS"
 
-#: elf32-arm.c:9132 elf32-tic6x.c:1632
+#: elf32-arm.c:10453 elf32-tic6x.c:2753
 msgid "out of range"
 msgstr "fuera de rango"
 
-#: elf32-arm.c:9136 elf32-tic6x.c:1636
+#: elf32-arm.c:10457 elf32-tic6x.c:2757
 msgid "unsupported relocation"
 msgstr "no se admite la reubicación"
 
-#: elf32-arm.c:9144 elf32-tic6x.c:1644
+#: elf32-arm.c:10465 elf32-tic6x.c:2765
 msgid "unknown error"
 msgstr "error desconocido"
 
-#: elf32-arm.c:9569
+#: elf32-arm.c:10890
 msgid "Warning: Clearing the interworking flag of %B because non-interworking code in %B has been linked with it"
 msgstr "Aviso: Se limpia la opción de interoperación en %B porque se ha enlazado con él código no interoperable en %B"
 
-#: elf32-arm.c:9663
+#: elf32-arm.c:10984
 msgid "%B: Unknown mandatory EABI object attribute %d"
 msgstr "%B: Atributo de objeto EABI obligatorio %d desconocido"
 
-#: elf32-arm.c:9671
+#: elf32-arm.c:10992
 msgid "Warning: %B: Unknown EABI object attribute %d"
 msgstr "Aviso: %B: Atributo de objeto EABI %d desconocido"
 
-#: elf32-arm.c:9852
+#: elf32-arm.c:11173
 msgid "error: %B: Unknown CPU architecture"
 msgstr "error: %B: Arquitectura de CPU desconocida"
 
-#: elf32-arm.c:9890
+#: elf32-arm.c:11211
 msgid "error: %B: Conflicting CPU architectures %d/%d"
 msgstr "error: %B: Arquitecturas de CPU en conflicto %d/%d"
 
-#: elf32-arm.c:9942
+#: elf32-arm.c:11260
 msgid "Error: %B has both the current and legacy Tag_MPextension_use attributes"
 msgstr "Error: %B tiene al mismo tiempo los atributos Tag_MPextension_use actuales y antiguos"
 
-#: elf32-arm.c:9967
+#: elf32-arm.c:11285
 msgid "error: %B uses VFP register arguments, %B does not"
 msgstr "error: %B utiliza argumentos de registro VFP, mientras que %B no"
 
-#: elf32-arm.c:10112
+#: elf32-arm.c:11430
 msgid "error: %B: unable to merge virtualization attributes with %B"
 msgstr "error: %B: no se pueden mezclar los atributos de virtualización con %B"
 
-#: elf32-arm.c:10138
+#: elf32-arm.c:11456
 msgid "error: %B: Conflicting architecture profiles %c/%c"
 msgstr "error: %B: Perfiles de arquitecturas en conflicto %c/%c"
 
-#: elf32-arm.c:10239
+#: elf32-arm.c:11557
 msgid "Warning: %B: Conflicting platform configuration"
 msgstr "Aviso: %B: Configuración de plataformas en conflicto"
 
-#: elf32-arm.c:10248
+#: elf32-arm.c:11566
 msgid "error: %B: Conflicting use of R9"
 msgstr "error: %B: Uso en conflicto de R9"
 
-#: elf32-arm.c:10260
+#: elf32-arm.c:11578
 msgid "error: %B: SB relative addressing conflicts with use of R9"
 msgstr "error: %B: El direccionamiento relativo a SB tiene conflictos con el uso de R9"
 
-#: elf32-arm.c:10273
+#: elf32-arm.c:11591
 msgid "warning: %B uses %u-byte wchar_t yet the output is to use %u-byte wchar_t; use of wchar_t values across objects may fail"
 msgstr "aviso: %B usa wchar_t de %u bytes aunque la salida usa wchar_t de %u bytes; el uso de valores wchar_t entre objetos puede fallar"
 
-#: elf32-arm.c:10304
+#: elf32-arm.c:11622
 msgid "warning: %B uses %s enums yet the output is to use %s enums; use of enum values across objects may fail"
 msgstr "aviso: %B usa enums %s aunque la salida usa enums %s; el uso de valores enum entre objetos puede fallar"
 
-#: elf32-arm.c:10316
+#: elf32-arm.c:11634
 msgid "error: %B uses iWMMXt register arguments, %B does not"
 msgstr "error: %B utiliza argumentos de registro iWMMXt, mientras que %B no"
 
-#: elf32-arm.c:10333
+#: elf32-arm.c:11651
 msgid "error: fp16 format mismatch between %B and %B"
 msgstr "error: no coincide el formato fp16 entre %B y %B"
 
-#: elf32-arm.c:10357
+#: elf32-arm.c:11675
 msgid "DIV usage mismatch between %B and %B"
 msgstr "no coincide el uso de DIV entre %B y %B"
 
-#: elf32-arm.c:10376
+#: elf32-arm.c:11694
 msgid "%B has has both the current and legacy Tag_MPextension_use attributes"
 msgstr "%B tiene al mismo tiempo los atributos actuales y antiguos de Tag_MPextension"
 
 #. Ignore init flag - it may not be set, despite the flags field
 #. containing valid data.
 #. Ignore init flag - it may not be set, despite the flags field containing valid data.
-#: elf32-arm.c:10468 elf32-bfin.c:5065 elf32-cris.c:4162 elf32-m68hc1x.c:1282
-#: elf32-m68k.c:1235 elf32-score.c:3996 elf32-score7.c:3803 elf32-vax.c:528
-#: elfxx-mips.c:12842
+#: elf32-arm.c:11782 elf32-bfin.c:5079 elf32-cris.c:4169 elf32-m68hc1x.c:1282
+#: elf32-m68k.c:1236 elf32-score.c:3994 elf32-score7.c:3800 elf32-vax.c:529
+#: elfxx-mips.c:14103
 #, c-format
 msgid "private flags = %lx:"
 msgstr "opciones privadas = %lx:"
 
-#: elf32-arm.c:10477
+#: elf32-arm.c:11791
 #, c-format
 msgid " [interworking enabled]"
 msgstr " [interoperabilidad activada]"
 
-#: elf32-arm.c:10485
+#: elf32-arm.c:11799
 #, c-format
 msgid " [VFP float format]"
 msgstr " [formato de coma flotante VFP]"
 
-#: elf32-arm.c:10487
+#: elf32-arm.c:11801
 #, c-format
 msgid " [Maverick float format]"
 msgstr " [formato de coma flotante Maverick]"
 
-#: elf32-arm.c:10489
+#: elf32-arm.c:11803
 #, c-format
 msgid " [FPA float format]"
 msgstr " [formato de coma flotante FPA]"
 
-#: elf32-arm.c:10498
+#: elf32-arm.c:11812
 #, c-format
 msgid " [new ABI]"
 msgstr " [ABI nuevo]"
 
-#: elf32-arm.c:10501
+#: elf32-arm.c:11815
 #, c-format
 msgid " [old ABI]"
 msgstr " [ABI antiguo]"
 
-#: elf32-arm.c:10504
+#: elf32-arm.c:11818
 #, c-format
 msgid " [software FP]"
 msgstr " [FP por software]"
 
-#: elf32-arm.c:10513
+#: elf32-arm.c:11827
 #, c-format
 msgid " [Version1 EABI]"
 msgstr " [EABI Version1]"
 
-#: elf32-arm.c:10516 elf32-arm.c:10527
+#: elf32-arm.c:11830 elf32-arm.c:11841
 #, c-format
 msgid " [sorted symbol table]"
 msgstr " [tabla de símbolos ordenados]"
 
-#: elf32-arm.c:10518 elf32-arm.c:10529
+#: elf32-arm.c:11832 elf32-arm.c:11843
 #, c-format
 msgid " [unsorted symbol table]"
 msgstr " [tabla de símbolos sin ordenar]"
 
-#: elf32-arm.c:10524
+#: elf32-arm.c:11838
 #, c-format
 msgid " [Version2 EABI]"
 msgstr " [EABI Version2]"
 
-#: elf32-arm.c:10532
+#: elf32-arm.c:11846
 #, c-format
 msgid " [dynamic symbols use segment index]"
 msgstr " [los símbolos dinámicos utilizan índices de segmento]"
 
-#: elf32-arm.c:10535
+#: elf32-arm.c:11849
 #, c-format
 msgid " [mapping symbols precede others]"
 msgstr " [el mapeo de símbolos precede a otros]"
 
-#: elf32-arm.c:10542
+#: elf32-arm.c:11856
 #, c-format
 msgid " [Version3 EABI]"
 msgstr " [EABI Version3]"
 
-#: elf32-arm.c:10546
+#: elf32-arm.c:11860
 #, c-format
 msgid " [Version4 EABI]"
 msgstr " [EABI Version4]"
 
-#: elf32-arm.c:10550
+#: elf32-arm.c:11864
 #, c-format
 msgid " [Version5 EABI]"
 msgstr " [EABI Version5]"
 
-#: elf32-arm.c:10553
+#: elf32-arm.c:11867
 #, c-format
 msgid " [BE8]"
 msgstr " [BE8]"
 
-#: elf32-arm.c:10556
+#: elf32-arm.c:11870
 #, c-format
 msgid " [LE8]"
 msgstr " [LE8]"
 
-#: elf32-arm.c:10562
+#: elf32-arm.c:11876
 #, c-format
 msgid " <EABI version unrecognised>"
 msgstr " <no se reconoce la versión de EABI>"
 
-#: elf32-arm.c:10569
+#: elf32-arm.c:11883
 #, c-format
 msgid " [relocatable executable]"
 msgstr " [ejecutable reubicable]"
 
-#: elf32-arm.c:10572
+#: elf32-arm.c:11886
 #, c-format
 msgid " [has entry point]"
 msgstr " [tiene punto de entrada]"
 
-#: elf32-arm.c:10577
+#: elf32-arm.c:11891
 #, c-format
 msgid "<Unrecognised flag bits set>"
 msgstr "<No se reconoce el conjunto de bits de opción>"
 
-#: elf32-arm.c:10824 elf32-i386.c:1322 elf32-s390.c:1000 elf32-xtensa.c:1009
-#: elf64-s390.c:960 elf64-x86-64.c:1105 elfxx-sparc.c:1370
+#: elf32-arm.c:12189 elf32-i386.c:1461 elf32-s390.c:1000 elf32-tic6x.c:2829
+#: elf32-tilepro.c:1336 elf32-xtensa.c:1009 elf64-s390.c:960
+#: elf64-x86-64.c:1364 elfxx-sparc.c:1371 elfxx-tilegx.c:1586
 msgid "%B: bad symbol index: %d"
 msgstr "%B: índice de símbolos erróneo: %d"
 
-#: elf32-arm.c:10946 elf64-x86-64.c:1265 elf64-x86-64.c:1434 elfxx-mips.c:7942
+#: elf32-arm.c:12337 elf64-x86-64.c:1561 elf64-x86-64.c:1732 elfxx-mips.c:8223
 msgid "%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"
 msgstr "%B: no se puede usar la reubicación %s contra `%s' cuando se hace un objeto compartido; recompile con -fPIC"
 
-#: elf32-arm.c:11948
+#: elf32-arm.c:13460
 #, c-format
 msgid "Errors encountered processing file %s"
 msgstr "Se encontraron errores al procesar el fichero %s"
 
-#: elf32-arm.c:13334
+#: elf32-arm.c:14837
 msgid "%B: error: Cortex-A8 erratum stub is allocated in unsafe location"
 msgstr "%B: error: el cabo de errores Cortex-A8 se aloja en una ubicación insegura"
 
 #. There's not much we can do apart from complain if this
 #. happens.
-#: elf32-arm.c:13361
+#: elf32-arm.c:14864
 msgid "%B: error: Cortex-A8 erratum stub out of range (input file too large)"
 msgstr "%B: error: el cabo de errores Cortex-A8 está fuera de rango (el fichero de entrada es demasiado grande)"
 
-#: elf32-arm.c:13455 elf32-arm.c:13477
+#: elf32-arm.c:14958 elf32-arm.c:14980
 msgid "%B: error: VFP11 veneer out of range"
 msgstr "%B: error: la chapa VFP11 está fuera de rango"
 
-#: elf32-arm.c:14002
+#: elf32-arm.c:15518
 msgid "error: %B is already in final BE8 format"
 msgstr "error: %B ya está en el formato BE8 final"
 
-#: elf32-arm.c:14078
+#: elf32-arm.c:15594
 msgid "error: Source object %B has EABI version %d, but target %B has EABI version %d"
 msgstr "error: El objeto fuente %B tiene EABI versión %d, pero el objetivo %B tiene EABI versión %d"
 
-#: elf32-arm.c:14094
+#: elf32-arm.c:15610
 msgid "error: %B is compiled for APCS-%d, whereas target %B uses APCS-%d"
 msgstr "error: %B está compilado para APCS-%d mientras que el objetivo %B usa APCS-%d"
 
-#: elf32-arm.c:14119
+#: elf32-arm.c:15635
 msgid "error: %B uses VFP instructions, whereas %B does not"
 msgstr "error: %B utiliza instrucciones VFP, mientras que %B no"
 
-#: elf32-arm.c:14123
+#: elf32-arm.c:15639
 msgid "error: %B uses FPA instructions, whereas %B does not"
 msgstr "error: %B utiliza instrucciones FPA, mientras que %B no"
 
-#: elf32-arm.c:14133
+#: elf32-arm.c:15649
 msgid "error: %B uses Maverick instructions, whereas %B does not"
 msgstr "error: %B utiliza instrucciones Maverick, mientras que %B no"
 
-#: elf32-arm.c:14137
+#: elf32-arm.c:15653
 msgid "error: %B does not use Maverick instructions, whereas %B does"
 msgstr "error: %B no utiliza instrucciones Maverick, mientras que %B sí"
 
-#: elf32-arm.c:14156
+#: elf32-arm.c:15672
 msgid "error: %B uses software FP, whereas %B uses hardware FP"
 msgstr "error: %B utiliza FP de software, mientras que %B utiliza FP de hardware"
 
-#: elf32-arm.c:14160
+#: elf32-arm.c:15676
 msgid "error: %B uses hardware FP, whereas %B uses software FP"
 msgstr "error: %B utiliza FP de hardware, mientras que %B utiliza FP de software"
 
-#: elf32-avr.c:1271 elf32-bfin.c:3201 elf32-cris.c:2085 elf32-fr30.c:617
-#: elf32-frv.c:4119 elf32-i860.c:1219 elf32-ip2k.c:1479 elf32-iq2000.c:692
-#: elf32-m32c.c:561 elf32-mep.c:542 elf32-moxie.c:290 elf32-msp430.c:494
-#: elf32-mt.c:399 elf32-openrisc.c:412 elf32-v850.c:2151 elf32-xstormy16.c:949
-#: elf64-mmix.c:1530
+#: elf32-avr.c:1229 elf32-bfin.c:3221 elf32-cris.c:2089 elf32-epiphany.c:567
+#: elf32-fr30.c:617 elf32-frv.c:4113 elf32-i860.c:1219 elf32-ip2k.c:1479
+#: elf32-iq2000.c:692 elf32-m32c.c:561 elf32-mep.c:543 elf32-moxie.c:290
+#: elf32-msp430.c:494 elf32-mt.c:399 elf32-openrisc.c:412 elf32-tilepro.c:3222
+#: elf32-v850.c:2151 elf32-xstormy16.c:943 elf64-mmix.c:1598
+#: elfxx-tilegx.c:3585
 msgid "internal error: dangerous relocation"
 msgstr "error interno: reubicación peligrosa"
 
-#: elf32-avr.c:2400 elf32-hppa.c:598 elf32-m68hc1x.c:166 elf64-ppc.c:4175
+#: elf32-avr.c:2415 elf32-hppa.c:598 elf32-m68hc1x.c:166
 msgid "%B: cannot create stub entry %s"
 msgstr "%B: no se puede crear la entrada de cabo %s"
 
-#: elf32-bfin.c:1575
+#: elf32-bfin.c:107 elf32-bfin.c:363
+msgid "relocation should be even number"
+msgstr "la reubicación debe ser un número non"
+
+#: elf32-bfin.c:1593
 msgid "%B(%A+0x%lx): unresolvable relocation against symbol `%s'"
 msgstr "%B(%A+0x%lx): reubicación sin resolución contra el símbolo `%s'"
 
-#: elf32-bfin.c:1608 elf32-i386.c:4123 elf32-m68k.c:4233 elf32-s390.c:3062
-#: elf64-s390.c:3037 elf64-x86-64.c:3759
+#: elf32-bfin.c:1626 elf32-i386.c:4307 elf32-m68k.c:4233 elf32-s390.c:3055
+#: elf64-s390.c:3030 elf64-x86-64.c:4151
 msgid "%B(%A+0x%lx): reloc against `%s': error %d"
 msgstr "%B(%A+0x%lx): reubicación contra `%s': error %d"
 
-#: elf32-bfin.c:2707
+#: elf32-bfin.c:2725
 msgid "%B: relocation at `%A+0x%x' references symbol `%s' with nonzero addend"
 msgstr "%B: la reubicación en `%A+0x%x' referencía al símbolo `%s' con adición que no es cero"
 
-#: elf32-bfin.c:2721 elf32-frv.c:2901
+#: elf32-bfin.c:2741
 msgid "relocation references symbol not defined in the module"
 msgstr "la reubicación referencía un símbolo que no está definido en el módulo"
 
-#: elf32-bfin.c:2818
+#: elf32-bfin.c:2838
 msgid "R_BFIN_FUNCDESC references dynamic symbol with nonzero addend"
 msgstr "R_BFIN_FUNCDESC referencía un símbolo dinámico con adición que no es cero"
 
-#: elf32-bfin.c:2859 elf32-bfin.c:2982 elf32-frv.c:3638 elf32-frv.c:3759
+#: elf32-bfin.c:2879 elf32-bfin.c:3002
 msgid "cannot emit fixups in read-only section"
 msgstr "no se pueden emitir composturas en la sección de sólo lectura"
 
-#: elf32-bfin.c:2890 elf32-bfin.c:3020 elf32-frv.c:3669 elf32-frv.c:3803
-#: elf32-lm32.c:1103 elf32-sh.c:5021
+#: elf32-bfin.c:2910 elf32-bfin.c:3040 elf32-lm32.c:1103 elf32-sh.c:5016
 msgid "cannot emit dynamic relocations in read-only section"
 msgstr "no se pueden emitir reubicaciones dinámicas en la sección de sólo lectura"
 
-#: elf32-bfin.c:2940
+#: elf32-bfin.c:2960
 msgid "R_BFIN_FUNCDESC_VALUE references dynamic symbol with nonzero addend"
 msgstr "R_BFIN_FUNCDESC_VALUE referencía un símbolo dinámico con adición que no es cero"
 
-#: elf32-bfin.c:3105
+#: elf32-bfin.c:3125
 msgid "relocations between different segments are not supported"
 msgstr "no se admiten las reubicaciones entre segmentos diferentes"
 
-#: elf32-bfin.c:3106
+#: elf32-bfin.c:3126
 msgid "warning: relocation references a different segment"
 msgstr "aviso: la reubicación referencía un segmento diferente"
 
-#: elf32-bfin.c:4957 elf32-frv.c:6406
+#: elf32-bfin.c:4971
 msgid "%B: unsupported relocation type %i"
 msgstr "%B: no se admite el tipo de reubicación %i"
 
-#: elf32-bfin.c:5111 elf32-frv.c:6814
+#: elf32-bfin.c:5125 elf32-frv.c:6808
 #, c-format
 msgid "%s: cannot link non-fdpic object file into fdpic executable"
 msgstr "%s: no se puede enlazar el fichero objeto que no es fdpic en un ejecutable fdpic"
 
-#: elf32-bfin.c:5115 elf32-frv.c:6818
+#: elf32-bfin.c:5129 elf32-frv.c:6812
 #, c-format
 msgid "%s: cannot link fdpic object file into non-fdpic executable"
 msgstr "%s: no se puede enlazar el fichero objeto fdpic en un ejecutable que no es fdpic"
 
-#: elf32-cris.c:1172
+#: elf32-bfin.c:5283
+#, c-format
+msgid "*** check this relocation %s"
+msgstr "*** revisar esta reubicación %s"
+
+#: elf32-cris.c:1176
 msgid "%B, section %A: unresolvable relocation %s against symbol `%s'"
 msgstr "%B, sección %A: reubicación %s sin resolución contra el símbolo `%s'"
 
-#: elf32-cris.c:1234
+#: elf32-cris.c:1238
 msgid "%B, section %A: No PLT nor GOT for relocation %s against symbol `%s'"
 msgstr "%B, sección %A: No hay PLT ni GOT para la reubicación %s contra el símbolo `%s'"
 
-#: elf32-cris.c:1236
+#: elf32-cris.c:1240
 msgid "%B, section %A: No PLT for relocation %s against symbol `%s'"
 msgstr "%B, sección %A: No hay PLT para la reubicación %s contra el símbolo `%s'"
 
-#: elf32-cris.c:1242 elf32-cris.c:1375 elf32-cris.c:1635 elf32-cris.c:1718
-#: elf32-cris.c:1871
+#: elf32-cris.c:1246 elf32-cris.c:1379 elf32-cris.c:1639 elf32-cris.c:1722
+#: elf32-cris.c:1875 elf32-tic6x.c:2662
 msgid "[whose name is lost]"
 msgstr "[cuyo nombre está perdido]"
 
-#: elf32-cris.c:1361
+#: elf32-cris.c:1365 elf32-tic6x.c:2647
 msgid "%B, section %A: relocation %s with non-zero addend %d against local symbol"
 msgstr "%B, sección %A: reubicación %s con adición %d que no es cero contra el símbolo local"
 
-#: elf32-cris.c:1369 elf32-cris.c:1712 elf32-cris.c:1865
+#: elf32-cris.c:1373 elf32-cris.c:1716 elf32-cris.c:1869 elf32-tic6x.c:2655
 msgid "%B, section %A: relocation %s with non-zero addend %d against symbol `%s'"
 msgstr "%B, sección %A: reubicación %s con adición %d que no es cero contra el símbolo `%s'"
 
-#: elf32-cris.c:1395
+#: elf32-cris.c:1399
 msgid "%B, section %A: relocation %s is not allowed for global symbol: `%s'"
 msgstr "%B, sección %A: no se permite la reubicación %s para el símbolo global: `%s'"
 
-#: elf32-cris.c:1411
+#: elf32-cris.c:1415
 msgid "%B, section %A: relocation %s with no GOT created"
 msgstr "%B, sección %A: la reubicación %s sin GOT creado"
 
 #. We shouldn't get here for GCC-emitted code.
-#: elf32-cris.c:1626
+#: elf32-cris.c:1630
 msgid "%B, section %A: relocation %s has an undefined reference to `%s', perhaps a declaration mixup?"
 msgstr "%B, sección %A: la reubicación %s tiene una referencia sin definir a `%s', ¿tal vez una confusión en la declaración?"
 
-#: elf32-cris.c:1998
+#: elf32-cris.c:2002
 msgid "%B, section %A: relocation %s is not allowed for symbol: `%s' which is defined outside the program, perhaps a declaration mixup?"
 msgstr "%B, sección %A: no se permite la reubicación %s para el símbolo: `%s' el cual se define fuera del programa, ¿tal vez una confusión en la declaración?"
 
-#: elf32-cris.c:2051
+#: elf32-cris.c:2055
 msgid "(too many global variables for -fpic: recompile with -fPIC)"
 msgstr "(demasiadas variables globales para -fpic: recompile con -fPIC)"
 
-#: elf32-cris.c:2058
+#: elf32-cris.c:2062
 msgid "(thread-local data too big for -fpic or -msmall-tls: recompile with -fPIC or -mno-small-tls)"
 msgstr "(datos thread-local demasiado grandes para -fpic o -msmall-tls: recompile con -fPIC o -mno-small-tls)"
 
-#: elf32-cris.c:3248
+#: elf32-cris.c:3261
 msgid ""
 "%B, section %A:\n"
 "  v10/v32 compatible object %s must not contain a PIC relocation"
@@ -1349,7 +1396,7 @@
 "%B, sección %A:\n"
 "  el objeto %s compatible con v10/v32 no debe contener una reubicación PIC"
 
-#: elf32-cris.c:3353
+#: elf32-cris.c:3366
 msgid ""
 "%B, section %A:\n"
 "  relocation %s not valid in a shared object; typically an option mixup, recompile with -fPIC"
@@ -1357,7 +1404,7 @@
 "%B, sección %A:\n"
 "  la reubicación %s no es válida en un objeto compartido; es una confusión de opción típica, recompile con -fPIC"
 
-#: elf32-cris.c:3567
+#: elf32-cris.c:3580
 msgid ""
 "%B, section %A:\n"
 "  relocation %s should not be used in a shared object; recompile with -fPIC"
@@ -1365,7 +1412,7 @@
 "%B, sección %A:\n"
 "  la reubicación %s no se debe usar en un objeto compartido; recompile con -fPIC"
 
-#: elf32-cris.c:3992
+#: elf32-cris.c:4002
 msgid ""
 "%B, section `%A', to symbol `%s':\n"
 "  relocation %s should not be used in a shared object; recompile with -fPIC"
@@ -1373,130 +1420,161 @@
 "%B, sección `%A', para el símbolo `%s':\n"
 "  la reubicación %s no se debe usar en un objeto compartido; recompile con -fPIC"
 
-#: elf32-cris.c:4111
+#: elf32-cris.c:4118
 msgid "Unexpected machine number"
 msgstr "Número de máquina inesperado"
 
-#: elf32-cris.c:4165
+#: elf32-cris.c:4172
 #, c-format
 msgid " [symbols have a _ prefix]"
 msgstr " [los símbolos tiene un prefijo _]"
 
-#: elf32-cris.c:4168
+#: elf32-cris.c:4175
 #, c-format
 msgid " [v10 and v32]"
 msgstr " [v10 y v32]"
 
-#: elf32-cris.c:4171
+#: elf32-cris.c:4178
 #, c-format
 msgid " [v32]"
 msgstr " [v32]"
 
-#: elf32-cris.c:4216
+#: elf32-cris.c:4223
 msgid "%B: uses _-prefixed symbols, but writing file with non-prefixed symbols"
 msgstr "%B: se usan símbolos con prefijo _, pero se escribe el fichero con símbolos sin prefijo"
 
-#: elf32-cris.c:4217
+#: elf32-cris.c:4224
 msgid "%B: uses non-prefixed symbols, but writing file with _-prefixed symbols"
 msgstr "%B: se usan símbolos sin prefijo, pero se escribe el fichero con símbolos con prefijo _"
 
-#: elf32-cris.c:4236
+#: elf32-cris.c:4243
 msgid "%B contains CRIS v32 code, incompatible with previous objects"
 msgstr "%B contiene código CRIS v32, incompatible con objetos previos"
 
-#: elf32-cris.c:4238
+#: elf32-cris.c:4245
 msgid "%B contains non-CRIS-v32 code, incompatible with previous objects"
 msgstr "%B contiene código que no es CRIS v32, incompatible con objetos previos"
 
+#: elf32-dlx.c:142
+#, c-format
+msgid "BFD Link Error: branch (PC rel16) to section (%s) not supported"
+msgstr "Error de Enlazado BFD: no se admite la ramificación (PC rel16) a la sección (%s)"
+
+#: elf32-dlx.c:204
+#, c-format
+msgid "BFD Link Error: jump (PC rel26) to section (%s) not supported"
+msgstr "Error de Enlazado BFD: no se admite el salto (PC rel26) a la sección (%s)"
+
+#. Only if it's not an unresolved symbol.
+#: elf32-epiphany.c:563 elf32-ip2k.c:1475
+msgid "unsupported relocation between data/insn address spaces"
+msgstr "no se admite la reubicación entre espacios de direcciones datos/insn"
+
 #: elf32-frv.c:1509 elf32-frv.c:1658
 msgid "relocation requires zero addend"
 msgstr "la reubicación requiere una adición cero"
 
 #: elf32-frv.c:2888
-msgid "%B(%A+0x%x): relocation to `%s+%x' may have caused the error above"
-msgstr "%B(%A+0x%x): la reubicación a `%s+%x' tal vez causó el error anterior"
+msgid "%H: relocation to `%s+%v' may have caused the error above\n"
+msgstr "%H: la reubicación a `%s+%v' tal vez causó el error anterior\n"
 
-#: elf32-frv.c:2977
-msgid "R_FRV_GETTLSOFF not applied to a call instruction"
-msgstr "no se aplicó R_FRV_GETTLSOFF a una instrucción call"
+#: elf32-frv.c:2905
+msgid "%H: relocation references symbol not defined in the module\n"
+msgstr "%H: la reubicación referencía un símbolo que no está definido en el módulo\n"
 
-#: elf32-frv.c:3019
-msgid "R_FRV_GOTTLSDESC12 not applied to an lddi instruction"
-msgstr "no se aplicó R_FRV_GOTTLSDESC12 a una instrucción lddi"
+#: elf32-frv.c:2981
+msgid "%H: R_FRV_GETTLSOFF not applied to a call instruction\n"
+msgstr "%H: no se aplicó R_FRV_GETTLSOFF a una instrucción call\n"
 
-#: elf32-frv.c:3090
-msgid "R_FRV_GOTTLSDESCHI not applied to a sethi instruction"
-msgstr "no se aplicó R_FRV_GOTTLSDESCHI a una instrucción sethi"
+#: elf32-frv.c:3022
+msgid "%H: R_FRV_GOTTLSDESC12 not applied to an lddi instruction\n"
+msgstr "%H: no se aplicó R_FRV_GOTTLSDESC12 a una instrucción lddi\n"
 
-#: elf32-frv.c:3127
-msgid "R_FRV_GOTTLSDESCLO not applied to a setlo or setlos instruction"
-msgstr "no se aplicó R_FRV_GOTTLSDESCLO a una instrucción setlo o setlos"
+#: elf32-frv.c:3093
+msgid "%H: R_FRV_GOTTLSDESCHI not applied to a sethi instruction\n"
+msgstr "%H: no se aplicó R_FRV_GOTTLSDESCHI a una instrucción sethi\n"
 
-#: elf32-frv.c:3175
-msgid "R_FRV_TLSDESC_RELAX not applied to an ldd instruction"
-msgstr "no se aplicó R_FRV_GOTTLSDESC_RELAX a una instrucción ldd"
+#: elf32-frv.c:3130
+msgid "%H: R_FRV_GOTTLSDESCLO not applied to a setlo or setlos instruction\n"
+msgstr "%H: no se aplicó R_FRV_GOTTLSDESCLO a una instrucción setlo o setlos\n"
 
-#: elf32-frv.c:3259
-msgid "R_FRV_GETTLSOFF_RELAX not applied to a calll instruction"
-msgstr "no se aplicó R_FRV_GETTLSOFF_RELAX a una instrucción calll"
+#: elf32-frv.c:3177
+msgid "%H: R_FRV_TLSDESC_RELAX not applied to an ldd instruction\n"
+msgstr "%H: no se aplicó R_FRV_GOTTLSDESC_RELAX a una instrucción ldd\n"
 
-#: elf32-frv.c:3314
-msgid "R_FRV_GOTTLSOFF12 not applied to an ldi instruction"
-msgstr "no se aplicó R_FRV_GOTTLSOFF12 a una instrucción ldi"
+#: elf32-frv.c:3261
+msgid "%H: R_FRV_GETTLSOFF_RELAX not applied to a calll instruction\n"
+msgstr "%H: no se aplicó R_FRV_GETTLSOFF_RELAX a una instrucción calll\n"
 
-#: elf32-frv.c:3344
-msgid "R_FRV_GOTTLSOFFHI not applied to a sethi instruction"
-msgstr "no se aplicó R_FRV_GOTTLSOFFHI a una instrucción sethi"
+#: elf32-frv.c:3315
+msgid "%H: R_FRV_GOTTLSOFF12 not applied to an ldi instruction\n"
+msgstr "%H: no se aplicó R_FRV_GOTTLSOFF12 a una instrucción ldi\n"
 
-#: elf32-frv.c:3373
-msgid "R_FRV_GOTTLSOFFLO not applied to a setlo or setlos instruction"
-msgstr "no se aplicó R_FRV_GOTTLSOFFLO a una instrucción setlo o setlos"
+#: elf32-frv.c:3345
+msgid "%H: R_FRV_GOTTLSOFFHI not applied to a sethi instruction\n"
+msgstr "%H: no se aplicó R_FRV_GOTTLSOFFHI a una instrucción sethi\n"
+
+#: elf32-frv.c:3374
+msgid "%H: R_FRV_GOTTLSOFFLO not applied to a setlo or setlos instruction\n"
+msgstr "%H: no se aplicó R_FRV_GOTTLSOFFLO a una instrucción setlo o setlos\n"
 
 #: elf32-frv.c:3404
-msgid "R_FRV_TLSOFF_RELAX not applied to an ld instruction"
-msgstr "no se aplicó R_FRV_TLSOFF_RELAX a una instrucción ld"
+msgid "%H: R_FRV_TLSOFF_RELAX not applied to an ld instruction\n"
+msgstr "%H: no se aplicó R_FRV_TLSOFF_RELAX a una instrucción ld\n"
 
 #: elf32-frv.c:3449
-msgid "R_FRV_TLSMOFFHI not applied to a sethi instruction"
-msgstr "no se aplicó R_FRV_TLSMOFFHI a una instrucción sethi"
+msgid "%H: R_FRV_TLSMOFFHI not applied to a sethi instruction\n"
+msgstr "%H: no se aplicó R_FRV_TLSMOFFHI a una instrucción sethi\n"
 
 #: elf32-frv.c:3476
-msgid "R_FRV_TLSMOFFLO not applied to a setlo or setlos instruction"
-msgstr "no se aplicó R_FRV_TLSMOFFLO a una instrucción setlo o setlos"
+msgid "R_FRV_TLSMOFFLO not applied to a setlo or setlos instruction\n"
+msgstr "no se aplicó R_FRV_TLSMOFFLO a una instrucción setlo o setlos\n"
 
 #: elf32-frv.c:3597
-msgid "R_FRV_FUNCDESC references dynamic symbol with nonzero addend"
-msgstr "R_FRV_FUNCDESC referencía un símbolo dinámico con adición que no es cero"
+msgid "%H: R_FRV_FUNCDESC references dynamic symbol with nonzero addend\n"
+msgstr "%H: R_FRV_FUNCDESC referencía un símbolo dinámico con adición que no es cero\n"
 
-#: elf32-frv.c:3717
-msgid "R_FRV_FUNCDESC_VALUE references dynamic symbol with nonzero addend"
-msgstr "R_FRV_FUNCDESC_VALUE referencía un símbolo dinámico con adición que no es cero"
+#: elf32-frv.c:3638 elf32-frv.c:3760
+msgid "%H: cannot emit fixups in read-only section\n"
+msgstr "%H: no se pueden emitir composturas en la sección de sólo lectura\n"
 
-#: elf32-frv.c:3974 elf32-frv.c:4130
-msgid "%B(%A+0x%lx): reloc against `%s': %s"
-msgstr "%B(%A+0x%lx): reubicación contra `%s': %s"
+#: elf32-frv.c:3669 elf32-frv.c:3803
+msgid "%H: cannot emit dynamic relocations in read-only section\n"
+msgstr "%H: no se pueden emitir reubicaciones dinámicas en la sección de sólo lectura\n"
 
-#: elf32-frv.c:3976 elf32-frv.c:3980
-msgid "relocation references a different segment"
-msgstr "la reubicación referencía un segmento diferente"
+#: elf32-frv.c:3718
+msgid "%H: R_FRV_FUNCDESC_VALUE references dynamic symbol with nonzero addend\n"
+msgstr "%H: R_FRV_FUNCDESC_VALUE referencía un símbolo dinámico con adición que no es cero\n"
 
-#: elf32-frv.c:6728
+#: elf32-frv.c:3974
+msgid "%H: reloc against `%s' references a different segment\n"
+msgstr "%H: la reubicación contra `%s' referencía un segmento diferente\n"
+
+#: elf32-frv.c:4124
+msgid "%H: reloc against `%s': %s\n"
+msgstr "%H: reubicación contra `%s': %s\n"
+
+#: elf32-frv.c:6400
+msgid "%B: unsupported relocation type %i\n"
+msgstr "%B: no se admite el tipo de reubicación %i\n"
+
+#: elf32-frv.c:6722
 #, c-format
 msgid "%s: compiled with %s and linked with modules that use non-pic relocations"
 msgstr "%s: compilado con %s y enlazado con módulos que usan reubicaciones que no son pic"
 
-#: elf32-frv.c:6781 elf32-iq2000.c:845 elf32-m32c.c:807
+#: elf32-frv.c:6775 elf32-iq2000.c:845 elf32-m32c.c:807
 #, c-format
 msgid "%s: compiled with %s and linked with modules compiled with %s"
 msgstr "%s: compilado con %s y enlazado con módulos compilados con %s"
 
-#: elf32-frv.c:6793
+#: elf32-frv.c:6787
 #, c-format
 msgid "%s: uses different unknown e_flags (0x%lx) fields than previous modules (0x%lx)"
 msgstr "%s: usa campos e_flags desconocidos (0x%lx) diferentes a aquéllos de los módulos previos (0x%lx)"
 
-#: elf32-frv.c:6843 elf32-iq2000.c:882 elf32-m32c.c:843 elf32-mt.c:576
-#: elf32-rx.c:2925
+#: elf32-frv.c:6837 elf32-iq2000.c:882 elf32-m32c.c:843 elf32-mt.c:576
+#: elf32-rx.c:3001
 #, c-format
 msgid "private flags = 0x%lx:"
 msgstr "opciones privadas = 0x%lx:"
@@ -1505,7 +1583,7 @@
 msgid "%B: Relocations in generic ELF (EM: %d)"
 msgstr "%B: Reubicaciones en ELF genérico (EM: %d)"
 
-#: elf32-hppa.c:850 elf32-hppa.c:3610
+#: elf32-hppa.c:850 elf32-hppa.c:3598
 msgid "%B(%A+0x%lx): cannot reach %s, recompile with -ffunction-sections"
 msgstr "%B(%A+0x%lx): no se puede alcanzar %s, recompile con -ffuntion-sections"
 
@@ -1513,71 +1591,81 @@
 msgid "%B: relocation %s can not be used when making a shared object; recompile with -fPIC"
 msgstr "%B: no se puede usar la reubicación %s cuando se hace un objeto compartido; recompile con -fPIC"
 
-#: elf32-hppa.c:2803
+#: elf32-hppa.c:2791
 msgid "%B: duplicate export stub %s"
 msgstr "%B: cabo de exportación %s duplicado"
 
-#: elf32-hppa.c:3449
+#: elf32-hppa.c:3437
 msgid "%B(%A+0x%lx): %s fixup for insn 0x%x is not supported in a non-shared link"
 msgstr "%B(%A+0x%lx): la compostura %s para la insn 0x%x no se admite en un enlazado que no es compartido"
 
-#: elf32-hppa.c:4296
+#: elf32-hppa.c:4284
 msgid "%B(%A+0x%lx): cannot handle %s for %s"
 msgstr "%B(%A+0x%lx): no se puede manejar %s para %s"
 
-#: elf32-hppa.c:4608
+#: elf32-hppa.c:4603
 msgid ".got section not immediately after .plt section"
 msgstr "la sección .got no está inmediatamente después de la sección .plt"
 
 #. Unknown relocation.
-#: elf32-i386.c:371 elf32-m68k.c:383 elf32-ppc.c:1674 elf32-s390.c:379
-#: elf32-tic6x.c:1563 elf64-ppc.c:2284 elf64-s390.c:403 elf64-x86-64.c:234
+#: elf32-i386.c:373 elf32-m68k.c:384 elf32-ppc.c:1676 elf32-s390.c:379
+#: elf32-tic6x.c:2684 elf64-ppc.c:2300 elf64-s390.c:403 elf64-x86-64.c:265
 msgid "%B: invalid relocation type %d"
 msgstr "%B: tipo de reubicación %d inválido"
 
-#: elf32-i386.c:1265 elf64-x86-64.c:1049
+#: elf32-i386.c:1404 elf64-x86-64.c:1308
 msgid "%B: TLS transition from %s to %s against `%s' at 0x%lx in section `%A' failed"
 msgstr "%B: falló la transición TLS de %s para %s contra `%s' en 0x%lx en la sección `%A'"
 
-#: elf32-i386.c:1408 elf32-i386.c:3068 elf64-x86-64.c:1194 elf64-x86-64.c:2780
-#: elfxx-sparc.c:3076
+#: elf32-i386.c:1549 elf32-i386.c:3244 elf64-x86-64.c:1487 elf64-x86-64.c:3125
+#: elfxx-sparc.c:3083
 msgid "%B: relocation %s against STT_GNU_IFUNC symbol `%s' isn't handled by %s"
 msgstr "%B: la reubicación %s contra el símbolo STT_GNU_IFUNC `%s' no es manejada por %s"
 
-#: elf32-i386.c:1570 elf32-s390.c:1182 elf32-sh.c:6367 elf32-xtensa.c:1182
-#: elf64-s390.c:1151 elfxx-sparc.c:1547
+#: elf32-i386.c:1711 elf32-s390.c:1182 elf32-sh.c:6362 elf32-tilepro.c:1434
+#: elf32-xtensa.c:1182 elf64-s390.c:1151 elfxx-sparc.c:1548
+#: elfxx-tilegx.c:1701
 msgid "%B: `%s' accessed both as normal and thread local symbol"
 msgstr "%B: se accedió `%s' como un símbolo normal y un símbolo local de hilo"
 
-#: elf32-i386.c:2910
+#: elf32-i386.c:2539 elf64-x86-64.c:2506
+msgid "%P: %B: warning: relocation against `%s' in readonly section `%A'.\n"
+msgstr "%P: %B: aviso: reubicación contra `%s' en la sección de sólo lectura `%A'.\n"
+
+#: elf32-i386.c:2629 elf64-x86-64.c:2593
+msgid "%P: %B: warning: relocation in readonly section `%A'.\n"
+msgstr "%P: %B: aviso: reubicación en la sección de sólo lectura `%A'.\n"
+
+#: elf32-i386.c:3086 elf32-tilepro.c:2557 elfxx-tilegx.c:2871
 msgid "%B: unrecognized relocation (0x%x) in section `%A'"
 msgstr "%B: no se reconoce la dirección de reubicación (0x%lx) en la sección `%A'"
 
-#: elf32-i386.c:3317 elf64-x86-64.c:3174
+#: elf32-i386.c:3494 elf64-x86-64.c:3513
 msgid "hidden symbol"
 msgstr "símbolo oculto"
 
-#: elf32-i386.c:3320 elf64-x86-64.c:3177
+#: elf32-i386.c:3497 elf64-x86-64.c:3516
 msgid "internal symbol"
 msgstr "símbolo interno"
 
-#: elf32-i386.c:3323 elf64-x86-64.c:3180
+#: elf32-i386.c:3500 elf64-x86-64.c:3519
 msgid "protected symbol"
 msgstr "símbolo protegido"
 
-#: elf32-i386.c:3326 elf64-x86-64.c:3183
+#: elf32-i386.c:3503 elf64-x86-64.c:3522
 msgid "symbol"
 msgstr "símbolo"
 
-#: elf32-i386.c:3331
+#: elf32-i386.c:3508
 msgid "%B: relocation R_386_GOTOFF against undefined %s `%s' can not be used when making a shared object"
 msgstr "%B: no se puede usar la reubicación R_386_GOTOFF contra %s indefinida `%s' cuando se hace un objeto compartido"
 
-#: elf32-i386.c:3341
+#: elf32-i386.c:3518
 msgid "%B: relocation R_386_GOTOFF against protected function `%s' can not be used when making a shared object"
 msgstr "%B: no se puede usar la reubicación R_386_GOTOFF contra la función protegida `%s' cuando se hace un objeto compartido"
 
-#: elf32-i386.c:4633 elf64-x86-64.c:4206
+#: elf32-i386.c:4839 elf32-tilepro.c:3467 elf64-x86-64.c:4609
+#: elfxx-tilegx.c:3847
 #, c-format
 msgid "discarded output section: `%A'"
 msgstr "se descarta la sección de salida: `%A'"
@@ -1600,11 +1688,6 @@
 msgid "ip2k linker: redundant page instruction at 0x%08lx (dest = 0x%08lx)."
 msgstr "enlazador ip2k: instrucción de página redundante en 0x%08lx (dest = 0x%08lx)."
 
-#. Only if it's not an unresolved symbol.
-#: elf32-ip2k.c:1475
-msgid "unsupported relocation between data/insn address spaces"
-msgstr "no se admite la reubicación entre espacios de direcciones datos/insn"
-
 #: elf32-iq2000.c:858 elf32-m32c.c:819
 #, c-format
 msgid "%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"
@@ -1626,30 +1709,30 @@
 msgid "SDA relocation when _SDA_BASE_ not defined"
 msgstr "reubicación SDA cuando _SDA_BASE_ no está definido"
 
-#: elf32-m32r.c:3048
+#: elf32-m32r.c:3043
 msgid "%B: The target (%s) of an %s relocation is in the wrong section (%A)"
 msgstr "%B: El objetivo (%s) de una reubicación %s está en la sección errónea (%A)"
 
-#: elf32-m32r.c:3576
+#: elf32-m32r.c:3571
 msgid "%B: Instruction set mismatch with previous modules"
 msgstr "%B: El conjunto de instrucciones no coincide con módulos previos"
 
-#: elf32-m32r.c:3597
+#: elf32-m32r.c:3592
 #, c-format
 msgid "private flags = %lx"
 msgstr "opciones privadas = %lx"
 
-#: elf32-m32r.c:3602
+#: elf32-m32r.c:3597
 #, c-format
 msgid ": m32r instructions"
 msgstr ": instrucciones m32r"
 
-#: elf32-m32r.c:3603
+#: elf32-m32r.c:3598
 #, c-format
 msgid ": m32rx instructions"
 msgstr ": instrucciones m32rx"
 
-#: elf32-m32r.c:3604
+#: elf32-m32r.c:3599
 #, c-format
 msgid ": m32r2 instructions"
 msgstr ": instrucciones m32r2"
@@ -1681,7 +1764,7 @@
 msgid "%B: linking files compiled for HCS12 with others compiled for HC12"
 msgstr "%B: se enlazan ficheros compilados para HCS12, con otros compilados para HC12"
 
-#: elf32-m68hc1x.c:1257 elf32-ppc.c:4232 elf64-sparc.c:703 elfxx-mips.c:12704
+#: elf32-m68hc1x.c:1257 elf32-ppc.c:4227 elf64-sparc.c:706 elfxx-mips.c:13965
 msgid "%B: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"
 msgstr "%B: usa campos de e_flags diferentes (0x%lx) que los módulos previos (0x%lx)"
 
@@ -1730,19 +1813,19 @@
 msgid " [memory=flat]"
 msgstr " [memoria=plana]"
 
-#: elf32-m68k.c:1250 elf32-m68k.c:1251 vms-alpha.c:7292 vms-alpha.c:7307
+#: elf32-m68k.c:1251 elf32-m68k.c:1252 vms-alpha.c:7314 vms-alpha.c:7329
 msgid "unknown"
 msgstr "desconocido"
 
-#: elf32-m68k.c:1714
+#: elf32-m68k.c:1715
 msgid "%B: GOT overflow: Number of relocations with 8-bit offset > %d"
 msgstr "%B: desbordamiento de GOT: Número de reubicaciones con desplazamiento de 8-bit > %d"
 
-#: elf32-m68k.c:1720
+#: elf32-m68k.c:1721
 msgid "%B: GOT overflow: Number of relocations with 8- or 16-bit offset > %d"
 msgstr "%B: desbordamiento de GOT: Número de reubicaciones con desplazamiento de 8 o 16-bit > %d"
 
-#: elf32-m68k.c:3959
+#: elf32-m68k.c:3957
 msgid "%B(%A+0x%lx): R_68K_TLS_LE32 relocation not permitted in shared object"
 msgstr "%B(%A+0x%lx): la reubicación R_68K_TLS_LE32 no se permite en objetos compartidos"
 
@@ -1754,15 +1837,26 @@
 msgid "%B: Unknown relocation type %d\n"
 msgstr "%B: Tipo de reubicación %d desconocido\n"
 
-#: elf32-mep.c:647
+#. Pacify gcc -Wall.
+#: elf32-mep.c:157
+#, c-format
+msgid "mep: no reloc for code %d"
+msgstr "mep: no hay reubicación para el código %d"
+
+#: elf32-mep.c:163
+#, c-format
+msgid "MeP: howto %d has type %d"
+msgstr "MeP: howto %d tiene el tipo %d"
+
+#: elf32-mep.c:648
 msgid "%B and %B are for different cores"
 msgstr "%B y %B son para núcleos diferentes"
 
-#: elf32-mep.c:664
+#: elf32-mep.c:665
 msgid "%B and %B are for different configurations"
 msgstr "%B y %B son para configuraciones diferentes"
 
-#: elf32-mep.c:701
+#: elf32-mep.c:702
 #, c-format
 msgid "private flags = 0x%lx"
 msgstr "opciones privadas = 0x%lx"
@@ -1777,210 +1871,238 @@
 msgid "%s: The target (%s) of an %s relocation is in the wrong section (%s)"
 msgstr "%s: El objetivo (%s) de una reubicación %s está en la sección errónea (%s)"
 
-#: elf32-microblaze.c:1155 elfxx-sparc.c:3450
+#: elf32-microblaze.c:1155 elf32-tilepro.c:2891 elfxx-sparc.c:3457
+#: elfxx-tilegx.c:3230
 msgid "%B: probably compiled without -fPIC?"
 msgstr "%B: ¿Compilado probablemente sin -fPIC?"
 
-#: elf32-microblaze.c:2074 elflink.c:12601
+#: elf32-microblaze.c:2074
 msgid "%B: bad relocation section name `%s'"
 msgstr "%B: nombre de sección de reubicación `%s' erróneo"
 
-#: elf32-mips.c:1045 elf64-mips.c:2084 elfn32-mips.c:1888
+#: elf32-mips.c:1549 elf64-mips.c:2683 elfn32-mips.c:2487
 msgid "literal relocation occurs for an external symbol"
 msgstr "la reubicación literal sucede para un símbolo externo"
 
-#: elf32-mips.c:1085 elf32-score.c:569 elf32-score7.c:469 elf64-mips.c:2127
-#: elfn32-mips.c:1929
+#: elf32-mips.c:1596 elf32-score.c:570 elf32-score7.c:469 elf64-mips.c:2726
+#: elfn32-mips.c:2528
 msgid "32bits gp relative relocation occurs for an external symbol"
 msgstr "la reubicación relativa a gp de 32bits sucede para un símbolo externo"
 
-#: elf32-ppc.c:1739
+#: elf32-ppc.c:1741
 #, c-format
 msgid "generic linker can't handle %s"
 msgstr "el enlazador genérico no puede manejar %s"
 
-#: elf32-ppc.c:2180
+#: elf32-ppc.c:2184
 msgid "corrupt %s section in %B"
 msgstr "sección %s corrupta en %B"
 
-#: elf32-ppc.c:2199
+#: elf32-ppc.c:2203
 msgid "unable to read in %s section from %B"
 msgstr "no se puede leer en la sección %s desde %B"
 
-#: elf32-ppc.c:2240
+#: elf32-ppc.c:2244
 msgid "warning: unable to set size of %s section in %B"
 msgstr "aviso: no se puede establecer el tamaño de la sección %s en %B"
 
-#: elf32-ppc.c:2290
+#: elf32-ppc.c:2294
 msgid "failed to allocate space for new APUinfo section."
 msgstr "no se puede reservar espacio para la nueva sección APUinfo."
 
-#: elf32-ppc.c:2309
+#: elf32-ppc.c:2313
 msgid "failed to compute new APUinfo section."
 msgstr "no se puede calcular la nueva sección APUinfo."
 
-#: elf32-ppc.c:2312
+#: elf32-ppc.c:2316
 msgid "failed to install new APUinfo section."
 msgstr "no se puede instalar la nueva sección APUinfo."
 
-#: elf32-ppc.c:3358
+#: elf32-ppc.c:3356
 msgid "%B: relocation %s cannot be used when making a shared object"
 msgstr "%B: no se puede usar la reubicación %s cuando se hace un objeto compartido"
 
 #. It does not make sense to have a procedure linkage
 #. table entry for a local symbol.
-#: elf32-ppc.c:3702
-msgid "%B(%A+0x%lx): %s reloc against local symbol"
-msgstr "%B(%A+0x%lx): reubicación %s contra un símbolo local"
+#: elf32-ppc.c:3700
+msgid "%P: %H: %s reloc against local symbol\n"
+msgstr "%P: %H: reubicación %s contra un símbolo local\n"
 
-#: elf32-ppc.c:4044 elf32-ppc.c:4059 elfxx-mips.c:12411 elfxx-mips.c:12437
-#: elfxx-mips.c:12459 elfxx-mips.c:12485
+#: elf32-ppc.c:4039 elf32-ppc.c:4054 elfxx-mips.c:13651 elfxx-mips.c:13677
+#: elfxx-mips.c:13699 elfxx-mips.c:13725
 msgid "Warning: %B uses hard float, %B uses soft float"
 msgstr "Aviso: %B usa coma flotante hard, %B usa coma flotante soft"
 
-#: elf32-ppc.c:4047 elf32-ppc.c:4051
+#: elf32-ppc.c:4042 elf32-ppc.c:4046
 msgid "Warning: %B uses double-precision hard float, %B uses single-precision hard float"
 msgstr "Aviso: %B usa coma flotante hard de doble precisión, %B usa coma flotante hard de precisión simple"
 
-#: elf32-ppc.c:4055
+#: elf32-ppc.c:4050
 msgid "Warning: %B uses soft float, %B uses single-precision hard float"
 msgstr "Aviso: %B usa coma flotante soft, %B usa coma flotante hard de precisión simple"
 
-#: elf32-ppc.c:4062 elf32-ppc.c:4066 elfxx-mips.c:12391 elfxx-mips.c:12395
+#: elf32-ppc.c:4057 elf32-ppc.c:4061 elfxx-mips.c:13631 elfxx-mips.c:13635
 msgid "Warning: %B uses unknown floating point ABI %d"
 msgstr "Aviso: %B usa la ABI de coma flotante desconocida %d"
 
-#: elf32-ppc.c:4108 elf32-ppc.c:4112
+#: elf32-ppc.c:4103 elf32-ppc.c:4107
 msgid "Warning: %B uses unknown vector ABI %d"
 msgstr "Aviso: %B usa la ABI de vector desconocida %d"
 
-#: elf32-ppc.c:4116
+#: elf32-ppc.c:4111
 msgid "Warning: %B uses vector ABI \"%s\", %B uses \"%s\""
 msgstr "Aviso: %B usa la ABI de vector \"%s\", %B usa \"%s\""
 
-#: elf32-ppc.c:4133 elf32-ppc.c:4136
+#: elf32-ppc.c:4128 elf32-ppc.c:4131
 msgid "Warning: %B uses r3/r4 for small structure returns, %B uses memory"
 msgstr "Aviso: %B usa r3/r4 para devoluciones de estructura small, %B usa memoria"
 
-#: elf32-ppc.c:4139 elf32-ppc.c:4143
+#: elf32-ppc.c:4134 elf32-ppc.c:4138
 msgid "Warning: %B uses unknown small structure return convention %d"
 msgstr "Aviso: %B usa la convención de devolución de estructura small %d"
 
-#: elf32-ppc.c:4197
+#: elf32-ppc.c:4192
 msgid "%B: compiled with -mrelocatable and linked with modules compiled normally"
 msgstr "%B: compilado con -mrelocatable y enlazado con módulos compilados de forma normal"
 
-#: elf32-ppc.c:4205
+#: elf32-ppc.c:4200
 msgid "%B: compiled normally and linked with modules compiled with -mrelocatable"
 msgstr "%B: compilado de forma normal y enlazado con módulos compilados con -mrelocatable"
 
-#: elf32-ppc.c:4293
-msgid "Using bss-plt due to %B"
-msgstr "Se usa bss-plt debido a %B"
+#: elf32-ppc.c:4309
+msgid "%P: bss-plt forced due to %B\n"
+msgstr "%P: se fuerza bss-plt debido a %B\n"
 
-#: elf32-ppc.c:7192 elf64-ppc.c:12307
-msgid "%B: unknown relocation type %d for symbol %s"
-msgstr "%B: tipo de reubicación %d desconocido para el símbolo %s"
+#: elf32-ppc.c:4312
+msgid "%P: bss-plt forced by profiling\n"
+msgstr "%P: se fuerza bss-plt por análisis de perfil\n"
 
-#: elf32-ppc.c:7453
-msgid "%B(%A+0x%lx): non-zero addend on %s reloc against `%s'"
-msgstr "%B(%A+0x%lx): adición que no es cero en la reubicación %s contra `%s'"
+#. 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 optimization.
+#: elf32-ppc.c:4809 elf64-ppc.c:7858
+msgid "%H arg lost __tls_get_addr, TLS optimization disabled\n"
+msgstr "%H el argumento perdió __tls_get_addr, se desactiva la optimización TLS\n"
 
-#: elf32-ppc.c:7651 elf64-ppc.c:12812
-msgid "%B(%A+0x%lx): relocation %s for indirect function %s unsupported"
-msgstr "%B(%A+0x%lx): no se admite la reubicación %s para la función indirecta %s"
+#: elf32-ppc.c:5044 elf64-ppc.c:6528
+msgid "%P: dynamic variable `%s' is zero size\n"
+msgstr "%P: la variable dinámica `%s' es de tamaño cero\n"
 
-#: elf32-ppc.c:7881 elf32-ppc.c:7911 elf32-ppc.c:7958
-msgid "%B: the target (%s) of a %s relocation is in the wrong output section (%s)"
-msgstr "%B: el objetivo (%s) de una reubicación %s está en la sección de salida errónea (%s)"
+#: elf32-ppc.c:7263 elf64-ppc.c:12675
+msgid "%P: %B: unknown relocation type %d for symbol %s\n"
+msgstr "%P: %B: tipo de reubicación %d desconocida para el símbolo %s\n"
 
-#: elf32-ppc.c:8030
-msgid "%B: relocation %s is not yet supported for symbol %s."
-msgstr "%B: la reubicación %s aún no se admite para el símbolo %s."
+#: elf32-ppc.c:7524
+msgid "%P: %H: non-zero addend on %s reloc against `%s'\n"
+msgstr "%P: %H: adición que no es cero en la reubicación %s contra `%s'\n"
 
-#: elf32-ppc.c:8138 elf64-ppc.c:13162
-msgid "%B(%A+0x%lx): %s reloc against `%s': error %d"
-msgstr "%B(%A+0x%lx): reubicación %s contra `%s': error %d"
+#: elf32-ppc.c:7720 elf64-ppc.c:13181
+msgid "%P: %H: relocation %s for indirect function %s unsupported\n"
+msgstr "%P: %H: no se admite la reubicación %s para la función indirecta %s\n"
 
-#: elf32-ppc.c:8629
-#, c-format
-msgid "%s not defined in linker created %s"
-msgstr "no se definió %s en el %s creado por el enlazador"
+#: elf32-ppc.c:7948 elf32-ppc.c:7978 elf32-ppc.c:8025
+msgid "%P: %B: the target (%s) of a %s relocation is in the wrong output section (%s)\n"
+msgstr "%P: %B: el objetivo (%s) de una reubicación %s está en la sección de salida errónea (%s)\n"
 
-#: elf32-rx.c:544
+#: elf32-ppc.c:8097
+msgid "%P: %B: relocation %s is not yet supported for symbol %s\n"
+msgstr "%P: %B: la reubicación %s aún no se admite para el símbolo %s\n"
+
+#: elf32-ppc.c:8158 elf64-ppc.c:13467
+msgid "%P: %H: unresolvable %s relocation against symbol `%s'\n"
+msgstr "%P: %H: reubicación %s sin resolución contra el símbolo `%s'\n"
+
+#: elf32-ppc.c:8205 elf64-ppc.c:13512
+msgid "%P: %H: %s reloc against `%s': error %d\n"
+msgstr "%P: %H: reubicación %s contra `%s': error %d\n"
+
+#: elf32-ppc.c:8696
+msgid "%P: %s not defined in linker created %s\n"
+msgstr "%P: no se definió %s en el %s creado por el enlazador\n"
+
+#: elf32-rx.c:563
 msgid "%B:%A: Warning: deprecated Red Hat reloc "
 msgstr "%B:%A: Aviso: reubicación Red Hat obsoleta"
 
-#: elf32-rx.c:1086
+#. Check for unsafe relocs in PID mode.  These are any relocs where
+#. an absolute address is being computed.  There are special cases
+#. for relocs against symbols that are known to be referenced in
+#. crt0.o before the PID base address register has been initialised.
+#: elf32-rx.c:581
+msgid "%B(%A): unsafe PID relocation %s at 0x%08lx (against %s in %s)"
+msgstr "%B(%A): aviso: reubicación PID %s insegura en 0x%08lx (contra %s en %s)"
+
+#: elf32-rx.c:1157
 msgid "Warning: RX_SYM reloc with an unknown symbol"
 msgstr "Aviso: reubicación RX_SYM con un símbolo desconocido"
 
-#: elf32-rx.c:1251
+#: elf32-rx.c:1324
 msgid "%B(%A): error: call to undefined function '%s'"
 msgstr "%B(%A): error: llamada a la función sin definir '%s'"
 
-#: elf32-rx.c:1265
+#: elf32-rx.c:1338
 msgid "%B(%A): warning: unaligned access to symbol '%s' in the small data area"
 msgstr "%B(%A): aviso: acceso sin alinear al símbolo '%s' en el área de datos small"
 
-#: elf32-rx.c:1269
+#: elf32-rx.c:1342
 msgid "%B(%A): internal error: out of range error"
 msgstr "%B(%A): error interno: error fuera de rango"
 
-#: elf32-rx.c:1273
+#: elf32-rx.c:1346
 msgid "%B(%A): internal error: unsupported relocation error"
 msgstr "%B(%A): error interno: no se admite el error de reubicación"
 
-#: elf32-rx.c:1277
+#: elf32-rx.c:1350
 msgid "%B(%A): internal error: dangerous relocation"
 msgstr "%B(%A): error interno: reubicación peligrosa"
 
-#: elf32-rx.c:1281
+#: elf32-rx.c:1354
 msgid "%B(%A): internal error: unknown error"
 msgstr "%B(%A): error interno: error desconocido"
 
-#: elf32-rx.c:2928
+#: elf32-rx.c:3004
 #, c-format
 msgid " [64-bit doubles]"
 msgstr " [dobles de 64-bit]"
 
-#: elf32-rx.c:2930
+#: elf32-rx.c:3006
 #, c-format
 msgid " [dsp]"
 msgstr " [dsp]"
 
-#: elf32-s390.c:2209 elf64-s390.c:2196
+#: elf32-s390.c:2200 elf64-s390.c:2187
 msgid "%B(%A+0x%lx): invalid instruction for TLS relocation %s"
 msgstr "%B(%A+0x%lx): instrucción inválida para la reubicación TLS %s"
 
-#: elf32-score.c:1522 elf32-score7.c:1382 elfxx-mips.c:3323
+#: elf32-score.c:1520 elf32-score7.c:1379 elfxx-mips.c:3435
 msgid "not enough GOT space for local GOT entries"
 msgstr "no hay suficiente espacio GOT para entradas GOT locales"
 
-#: elf32-score.c:2744
+#: elf32-score.c:2742
 msgid "address not word align"
 msgstr "la dirección no está alineada a word"
 
-#: elf32-score.c:2829 elf32-score7.c:2634
+#: elf32-score.c:2827 elf32-score7.c:2631
 #, c-format
 msgid "%s: Malformed reloc detected for section %s"
 msgstr "%s: Se detectó una reubicación malformada para la sección %s"
 
-#: elf32-score.c:2880 elf32-score7.c:2685
+#: elf32-score.c:2878 elf32-score7.c:2682
 msgid "%B: CALL15 reloc at 0x%lx not against global symbol"
 msgstr "%B: la reubicación CALL15 en 0x%lx no es contra un símbolo global"
 
-#: elf32-score.c:3999 elf32-score7.c:3806
+#: elf32-score.c:3997 elf32-score7.c:3803
 #, c-format
 msgid " [pic]"
 msgstr " [pic]"
 
-#: elf32-score.c:4003 elf32-score7.c:3810
+#: elf32-score.c:4001 elf32-score7.c:3807
 #, c-format
 msgid " [fix dep]"
 msgstr " [fix dep]"
 
-#: elf32-score.c:4045 elf32-score7.c:3852
+#: elf32-score.c:4043 elf32-score7.c:3849
 msgid "%B: warning: linking PIC files with non-PIC files"
 msgstr "%B: aviso: se enlazan ficheros PIC con ficheros que no son PIC"
 
@@ -1992,7 +2114,7 @@
 msgid "%B: Unrecognised .directive command: %s"
 msgstr "%B: No se reconoce la orden .directive: %s"
 
-#: elf32-sh-symbian.c:503
+#: elf32-sh-symbian.c:504
 msgid "%B: Failed to add renamed symbol %s"
 msgstr "%B: Falló al agregar el símbolo renombrado %s"
 
@@ -2028,76 +2150,76 @@
 msgid "%B: 0x%lx: fatal: reloc overflow while relaxing"
 msgstr "%B: 0x%lx: fatal: desbordamiento de reubicación durante la relajación"
 
-#: elf32-sh.c:4057 elf64-sh64.c:1514
+#: elf32-sh.c:4048 elf64-sh64.c:1514
 msgid "Unexpected STO_SH5_ISA32 on local symbol is not handled"
 msgstr "No se maneja un STO_SH5_ISA32 inesperado en un símbolo local"
 
-#: elf32-sh.c:4304
+#: elf32-sh.c:4299
 msgid "%B: 0x%lx: fatal: unaligned branch target for relax-support relocation"
 msgstr "%B: 0x%lx: fatal: objetivo de ramificación sin alineación para la reubicación de soporte de relajamiento"
 
-#: elf32-sh.c:4337 elf32-sh.c:4352
+#: elf32-sh.c:4332 elf32-sh.c:4347
 msgid "%B: 0x%lx: fatal: unaligned %s relocation 0x%lx"
 msgstr "%B: 0x%lx: fatal: reubicación %s sin alineación 0x%lx"
 
-#: elf32-sh.c:4366
+#: elf32-sh.c:4361
 msgid "%B: 0x%lx: fatal: R_SH_PSHA relocation %d not in range -32..32"
 msgstr "%B: 0x%lx: fatal: la reubicación R_SH_PSHA %d no está en el rango -32..32"
 
-#: elf32-sh.c:4380
+#: elf32-sh.c:4375
 msgid "%B: 0x%lx: fatal: R_SH_PSHL relocation %d not in range -32..32"
 msgstr "%B: 0x%lx: fatal: la reubicación R_SH_PSHL %d no está en el rango -32..32"
 
-#: elf32-sh.c:4524 elf32-sh.c:4994
+#: elf32-sh.c:4519 elf32-sh.c:4989
 msgid "%B(%A+0x%lx): cannot emit fixup to `%s' in read-only section"
 msgstr "%B(%A+0x%lx): no se pueden emitir composturas para `%s' en la sección de sólo lectura"
 
-#: elf32-sh.c:5101
+#: elf32-sh.c:5096
 msgid "%B(%A+0x%lx): %s relocation against external symbol \"%s\""
 msgstr "%B(%A+0x%lx): reubicación %s contra el símbolo externo \"%s\""
 
-#: elf32-sh.c:5574
+#: elf32-sh.c:5569
 #, c-format
 msgid "%X%C: relocation to \"%s\" references a different segment\n"
 msgstr "%X%C: la reubicación de \"%s\" referencía un segmento diferente\n"
 
-#: elf32-sh.c:5580
+#: elf32-sh.c:5575
 #, c-format
 msgid "%C: warning: relocation to \"%s\" references a different segment\n"
 msgstr "%C: aviso: la reubicación de \"%s\" referencía un segmento diferente\n"
 
-#: elf32-sh.c:6358 elf32-sh.c:6441
+#: elf32-sh.c:6353 elf32-sh.c:6436
 msgid "%B: `%s' accessed both as normal and FDPIC symbol"
 msgstr "%B: se accedió `%s' como un símbolo normal y un símbolo FDPIC"
 
-#: elf32-sh.c:6363 elf32-sh.c:6445
+#: elf32-sh.c:6358 elf32-sh.c:6440
 msgid "%B: `%s' accessed both as FDPIC and thread local symbol"
 msgstr "%B: se accedió `%s' como un símbolo FDPIC y un símbolo local de hilo"
 
-#: elf32-sh.c:6393
+#: elf32-sh.c:6388
 msgid "%B: Function descriptor relocation with non-zero addend"
 msgstr "%B: Reubicación de descriptor de función con adición que no es cero"
 
-#: elf32-sh.c:6629 elf64-alpha.c:4560
+#: elf32-sh.c:6624 elf64-alpha.c:4652
 msgid "%B: TLS local exec code cannot be linked into shared objects"
 msgstr "%B: el código de ejecución local TLS no se puede enlazar en objetos compartidos"
 
-#: elf32-sh64.c:223 elf64-sh64.c:2314
+#: elf32-sh64.c:223 elf64-sh64.c:2318
 #, c-format
 msgid "%s: compiled as 32-bit object and %s is 64-bit"
 msgstr "%s: compilado como un objeto de 32-bit y %s es de 64-bit"
 
-#: elf32-sh64.c:226 elf64-sh64.c:2317
+#: elf32-sh64.c:226 elf64-sh64.c:2321
 #, c-format
 msgid "%s: compiled as 64-bit object and %s is 32-bit"
 msgstr "%s: compilado como un objeto de 64-bit y %s es de 32-bit"
 
-#: elf32-sh64.c:228 elf64-sh64.c:2319
+#: elf32-sh64.c:228 elf64-sh64.c:2323
 #, c-format
 msgid "%s: object size does not match that of target %s"
 msgstr "%s: el tamaño del objeto no coincide con el tamaño del objetivo %s"
 
-#: elf32-sh64.c:451 elf64-sh64.c:2833
+#: elf32-sh64.c:451 elf64-sh64.c:2837
 #, c-format
 msgid "%s: encountered datalabel symbol in input"
 msgstr "%s: se encontró un símbolo datalabel en la entrada"
@@ -2129,11 +2251,11 @@
 msgid "%s: could not write out sorted .cranges entries"
 msgstr "%s: no se pueden escribir las entradas .cranges ordenadas"
 
-#: elf32-sparc.c:89
+#: elf32-sparc.c:90
 msgid "%B: compiled for a 64 bit system and target is 32 bit"
 msgstr "%B: compilado para un sistema de 64 bit y el objetivo es de 32 bit"
 
-#: elf32-sparc.c:102
+#: elf32-sparc.c:103
 msgid "%B: linking little endian files with big endian files"
 msgstr "%B: se enlazan ficheros little endian con ficheros big endian"
 
@@ -2179,7 +2301,7 @@
 msgid "overlay stub relocation overflow"
 msgstr "desbordamiento de la reubicación de cabo de sobreescritura"
 
-#: elf32-spu.c:1960 elf64-ppc.c:11327
+#: elf32-spu.c:1960
 msgid "stubs don't match calculated size"
 msgstr "los cabos no coinciden con el tamaño calculado"
 
@@ -2265,56 +2387,58 @@
 msgid "fatal error while creating .fixup"
 msgstr "error fatal al crear .fixup"
 
-#: elf32-spu.c:5006
+#: elf32-spu.c:5008
 msgid "%B(%s+0x%lx): unresolvable %s relocation against symbol `%s'"
 msgstr "%B(%s+0x%lx): reubicación %s sin resolución contra el símbolo `%s'"
 
-#: elf32-tic6x.c:1539
+#: elf32-tic6x.c:1602
+msgid "warning: generating a shared library containing non-PIC code"
+msgstr "aviso: se genera una biblioteca compartida que contiene código que no esPIC"
+
+#: elf32-tic6x.c:1607
+msgid "warning: generating a shared library containing non-PID code"
+msgstr "aviso: se genera una biblioteca compartida que contiene código que no es PID"
+
+#: elf32-tic6x.c:2541
 msgid "%B: SB-relative relocation but __c6xabi_DSBT_BASE not defined"
 msgstr "%B: reubicación relativa a SB pero _c6xabi_DSBT_BASE no está definido"
 
-#. Shared libraries and exception handling support not
-#. implemented.
-#: elf32-tic6x.c:1554
-msgid "%B: relocation type %d not implemented"
-msgstr "%B: el tipo de reubicación %d aún no está implementado"
-
-#: elf32-tic6x.c:1640
+#: elf32-tic6x.c:2761
 msgid "dangerous relocation"
 msgstr "reubicación peligrosa"
 
-#: elf32-tic6x.c:1788 elf32-tic6x.c:1796
+#: elf32-tic6x.c:3733
+msgid "%B: error: unknown mandatory EABI object attribute %d"
+msgstr "%B: error: atributo de objeto EABI obligatorio %d desconocido"
+
+#: elf32-tic6x.c:3741
+msgid "%B: warning: unknown EABI object attribute %d"
+msgstr "%B: aviso: atributo de objeto EABI %d desconocido"
+
+#: elf32-tic6x.c:3853 elf32-tic6x.c:3861
 msgid "error: %B requires more stack alignment than %B preserves"
 msgstr "error: %B requiere más alineación de pila que la que %B preserva"
 
-#: elf32-tic6x.c:1806 elf32-tic6x.c:1815
+#: elf32-tic6x.c:3871 elf32-tic6x.c:3880
 msgid "error: unknown Tag_ABI_array_object_alignment value in %B"
 msgstr "error: valor de Tag_ABI_array_object_alignment desconocido en %B"
 
-#: elf32-tic6x.c:1824 elf32-tic6x.c:1833
+#: elf32-tic6x.c:3889 elf32-tic6x.c:3898
 msgid "error: unknown Tag_ABI_array_object_align_expected value in %B"
 msgstr "error: valor de Tag_ABI_array_object_align_expected desconocido en %B"
 
-#: elf32-tic6x.c:1841 elf32-tic6x.c:1848
+#: elf32-tic6x.c:3906 elf32-tic6x.c:3913
 msgid "error: %B requires more array alignment than %B preserves"
 msgstr "error: %B requiere más alineación de matriz que la que %B preserva"
 
-#: elf32-tic6x.c:1870
+#: elf32-tic6x.c:3935
 msgid "warning: %B and %B differ in wchar_t size"
 msgstr "aviso: %B y %B difieren en tamaño wchar_t"
 
-#: elf32-tic6x.c:1888
+#: elf32-tic6x.c:3953
 msgid "warning: %B and %B differ in whether code is compiled for DSBT"
 msgstr "aviso: %B y %B difieren en si el código está compilado para DSBT"
 
-#: elf32-tic6x.c:1898
-msgid "warning: %B and %B differ in position-dependence of data addressing"
-msgstr "aviso: %B y %B difieren en el direccionamiento de datos dependiente de posición"
-
-#: elf32-tic6x.c:1908
-msgid "warning: %B and %B differ in position-dependence of code addressing"
-msgstr "aviso: %B y %B difieren en el direccionamiento de código dependiente de posición"
-
 #: elf32-v850.c:173
 #, c-format
 msgid "Variable `%s' cannot occupy in multiple small data regions"
@@ -2341,9 +2465,8 @@
 msgstr "La variable `%s' no puede estar simultáneamente en las regiones de datos zero y tiny"
 
 #: elf32-v850.c:483
-#, c-format
-msgid "FAILED to find previous HI16 reloc\n"
-msgstr "FALLO para encontrar la reubicación HI16 previa\n"
+msgid "FAILED to find previous HI16 reloc"
+msgstr "FALLO para encontrar la reubicación HI16 previa"
 
 #: elf32-v850.c:2155
 msgid "could not locate special linker symbol __gp"
@@ -2392,42 +2515,42 @@
 msgid "v850e2v3 architecture"
 msgstr "arquitectura v850e2v3"
 
-#: elf32-vax.c:531
+#: elf32-vax.c:532
 #, c-format
 msgid " [nonpic]"
 msgstr " [no pic]"
 
-#: elf32-vax.c:534
+#: elf32-vax.c:535
 #, c-format
 msgid " [d-float]"
 msgstr " [flotante-d]"
 
-#: elf32-vax.c:537
+#: elf32-vax.c:538
 #, c-format
 msgid " [g-float]"
 msgstr " [flotante-g]"
 
-#: elf32-vax.c:654
+#: elf32-vax.c:655
 #, c-format
 msgid "%s: warning: GOT addend of %ld to `%s' does not match previous GOT addend of %ld"
 msgstr "%s: aviso: la adición GOT de %ld a `%s' no coincide con la adición previa GOT de %ld"
 
-#: elf32-vax.c:1587
+#: elf32-vax.c:1585
 #, c-format
 msgid "%s: warning: PLT addend of %d to `%s' from %s section ignored"
 msgstr "%s: aviso: se descarta la adición PLT de %d a `%s' de la sección %s"
 
-#: elf32-vax.c:1714
+#: elf32-vax.c:1712
 #, c-format
 msgid "%s: warning: %s relocation against symbol `%s' from %s section"
 msgstr "%s: aviso: reubicación %s contra el símbolo `%s' de la sección %s"
 
-#: elf32-vax.c:1720
+#: elf32-vax.c:1718
 #, c-format
 msgid "%s: warning: %s relocation to 0x%x from %s section"
 msgstr "%s: aviso: reubicación %s a 0x%x de la sección %s"
 
-#: elf32-xstormy16.c:451 elf32-ia64.c:2861 elf64-ia64.c:2861
+#: elf32-xstormy16.c:451 elf32-ia64.c:2336 elf64-ia64.c:2336
 msgid "non-zero addend in @fptr reloc"
 msgstr "adición que no es cero en la reubicación @fptr"
 
@@ -2435,47 +2558,47 @@
 msgid "%B(%A): invalid property table"
 msgstr "%B(%A): tabla de propiedades inválida"
 
-#: elf32-xtensa.c:2780
+#: elf32-xtensa.c:2777
 msgid "%B(%A+0x%lx): relocation offset out of range (size=0x%x)"
 msgstr "%B(%A+0x%lx): desplazamiento de reubicación fuera de rango (tamaño=0x%x)"
 
-#: elf32-xtensa.c:2859 elf32-xtensa.c:2980
+#: elf32-xtensa.c:2856 elf32-xtensa.c:2977
 msgid "dynamic relocation in read-only section"
 msgstr "reubicación dinámica en la sección de sólo lectura"
 
-#: elf32-xtensa.c:2956
+#: elf32-xtensa.c:2953
 msgid "TLS relocation invalid without dynamic sections"
 msgstr "reubicación TLS inválida sin secciones dinámicas"
 
-#: elf32-xtensa.c:3173
+#: elf32-xtensa.c:3172
 msgid "internal inconsistency in size of .got.loc section"
 msgstr "inconsistencia interna en el tamaño de la sección .got.loc"
 
-#: elf32-xtensa.c:3486
+#: elf32-xtensa.c:3485
 msgid "%B: incompatible machine type. Output is 0x%x. Input is 0x%x"
 msgstr "%B: tipo de máquina incompatible. La salida es 0x%x. La entrada es 0x%x"
 
-#: elf32-xtensa.c:4715 elf32-xtensa.c:4723
+#: elf32-xtensa.c:4714 elf32-xtensa.c:4722
 msgid "Attempt to convert L32R/CALLX to CALL failed"
 msgstr "Falló el intento de convertir L32R/CALLX a CALL"
 
-#: elf32-xtensa.c:6333 elf32-xtensa.c:6409 elf32-xtensa.c:7525
+#: elf32-xtensa.c:6332 elf32-xtensa.c:6408 elf32-xtensa.c:7524
 msgid "%B(%A+0x%lx): could not decode instruction; possible configuration mismatch"
 msgstr "%B(%A+0x%lx): no se puede decodificar la instrucción; posible falta de coincidencia de la configuración"
 
-#: elf32-xtensa.c:7265
+#: elf32-xtensa.c:7264
 msgid "%B(%A+0x%lx): could not decode instruction for XTENSA_ASM_SIMPLIFY relocation; possible configuration mismatch"
 msgstr "%B(%A+0x%lx): no se puede decodificar la instrucción para la reubicación XTENSA_ASM_SIMPLIFY; posible falta de coincidencia de la configuración"
 
-#: elf32-xtensa.c:9024
+#: elf32-xtensa.c:9023
 msgid "invalid relocation address"
 msgstr "dirección de reubicación inválida"
 
-#: elf32-xtensa.c:9073
+#: elf32-xtensa.c:9072
 msgid "overflow after relaxation"
 msgstr "desbordamiento después de la relajación"
 
-#: elf32-xtensa.c:10205
+#: elf32-xtensa.c:10204
 msgid "%B(%A+0x%lx): unexpected fix for %s relocation"
 msgstr "%B(%A+0x%lx): compostura inesperada para la reubicación %s"
 
@@ -2483,56 +2606,76 @@
 msgid "GPDISP relocation did not find ldah and lda instructions"
 msgstr "la reubicación GPDISP no encontró las instrucciones ldah y lda"
 
-#: elf64-alpha.c:2408
+#: elf64-alpha.c:2497
 msgid "%B: .got subsegment exceeds 64K (size %d)"
 msgstr "%B: el subsegmento .got excede los 64K (tamaño %d)"
 
-#: elf64-alpha.c:4304 elf64-alpha.c:4316
+#: elf64-alpha.c:4387 elf64-alpha.c:4399
 msgid "%B: gp-relative relocation against dynamic symbol %s"
 msgstr "%B: reubicación relativa a gp contra el símbolo dinámico %s"
 
-#: elf64-alpha.c:4342 elf64-alpha.c:4477
+#: elf64-alpha.c:4425 elf64-alpha.c:4565
 msgid "%B: pc-relative relocation against dynamic symbol %s"
 msgstr "%B: reubicación relativa a pc contra el símbolo dinámico %s"
 
-#: elf64-alpha.c:4370
+#: elf64-alpha.c:4453
 msgid "%B: change in gp: BRSGP %s"
 msgstr "%B: cambio en gp: BRSGP %s"
 
-#: elf64-alpha.c:4395
+#: elf64-alpha.c:4478
 msgid "<unknown>"
 msgstr "<desconocido>"
 
-#: elf64-alpha.c:4400
+#: elf64-alpha.c:4483
 msgid "%B: !samegp reloc against symbol without .prologue: %s"
 msgstr "%B: reubicación !samegp contra un símbolo sin .prologue: %s"
 
-#: elf64-alpha.c:4452
+#: elf64-alpha.c:4540
 msgid "%B: unhandled dynamic relocation against %s"
 msgstr "%B: reubicación dinámica sin manejar contra %s"
 
-#: elf64-alpha.c:4484
+#: elf64-alpha.c:4572
 msgid "%B: pc-relative relocation against undefined weak symbol %s"
 msgstr "%B: reubicación relativa a pc contra el símbolo débil sin definir %s"
 
-#: elf64-alpha.c:4544
+#: elf64-alpha.c:4636
 msgid "%B: dtp-relative relocation against dynamic symbol %s"
 msgstr "%B: reubicación relativa a dtp contra el símbolo dinámico %s"
 
-#: elf64-alpha.c:4567
+#: elf64-alpha.c:4659
 msgid "%B: tp-relative relocation against dynamic symbol %s"
 msgstr "%B: reubicación relativa a tp contra el símbolo dinámico %s"
 
-#: elf64-hppa.c:2101
+#: elf64-hppa.c:2083
 #, c-format
 msgid "stub entry for %s cannot load .plt, dp offset = %ld"
 msgstr "la entrada de cabo para %s no puede cargar .plt, desplazamiento dp = %ld"
 
-#: elf64-hppa.c:3299
-msgid "%B(%A+0x%lx): cannot reach %s"
-msgstr "%B(%A+0x%lx): no se puede alcanzar %s"
+#: elf64-hppa.c:3275
+msgid "%B(%A+0x"
+msgstr "%B(%A+0x"
 
-#: elf64-mmix.c:1177
+#: elf64-mmix.c:1034
+msgid ""
+"invalid input relocation when producing non-ELF, non-mmo format output.\n"
+" Please use the objcopy program to convert from ELF or mmo,\n"
+" or assemble using \"-no-expand\" (for gcc, \"-Wa,-no-expand\""
+msgstr ""
+"reubicación de entrada inválida al producir el formato de salida que no\n"
+" es mmo ni ELF.  Por favor utilice el programa objcopy para convertir de\n"
+" ELF o mmo, o ensamble utilizando \"-no-expand\" (para gcc, \"-Wa, -no-expand\""
+
+#: elf64-mmix.c:1218
+msgid ""
+"invalid input relocation when producing non-ELF, non-mmo format output.\n"
+" Please use the objcopy program to convert from ELF or mmo,\n"
+" or compile using the gcc-option \"-mno-base-addresses\"."
+msgstr ""
+"reubicación de entrada inválida al producir el formato de salida que no\n"
+" es mmo ni ELF. Por favor utilice el programa objcopy para converitr de\n"
+" ELF o mmo, o compile utilizando la opción de gcc \"-mno-base-addresses\"."
+
+#: elf64-mmix.c:1244
 #, c-format
 msgid ""
 "%s: Internal inconsistency error for value for\n"
@@ -2541,46 +2684,46 @@
 "%s: Error de inconsistencia interna para el valor para\n"
 " un registro global colocado por el enlazador: enlazado: 0x%lx%08lx != relajado: 0x%lx%08lx\n"
 
-#: elf64-mmix.c:1607
+#: elf64-mmix.c:1670
 #, c-format
 msgid "%s: base-plus-offset relocation against register symbol: (unknown) in %s"
 msgstr "%s: reubicación base-más-desplazamiento contra un símbolo de registro: (desconocido) en %s"
 
-#: elf64-mmix.c:1612
+#: elf64-mmix.c:1675
 #, c-format
 msgid "%s: base-plus-offset relocation against register symbol: %s in %s"
 msgstr "%s: reubicación base-más-desplazamiento contra un símbolo de registro: %s en %s"
 
-#: elf64-mmix.c:1656
+#: elf64-mmix.c:1719
 #, c-format
 msgid "%s: register relocation against non-register symbol: (unknown) in %s"
 msgstr "%s: reubicación de registro contra un símbolo que no es registro: (desconocido) en %s"
 
-#: elf64-mmix.c:1661
+#: elf64-mmix.c:1724
 #, c-format
 msgid "%s: register relocation against non-register symbol: %s in %s"
 msgstr "%s: reubicación de registro contra un símbolo que no es registro: %s en %s"
 
-#: elf64-mmix.c:1698
+#: elf64-mmix.c:1761
 #, c-format
 msgid "%s: directive LOCAL valid only with a register or absolute value"
 msgstr "%s: la directiva LOCAL sólo es válida con un registro o un valor absoluto"
 
-#: elf64-mmix.c:1726
+#: elf64-mmix.c:1789
 #, c-format
 msgid "%s: LOCAL directive: Register $%ld is not a local register.  First global register is $%ld."
 msgstr "%s: directiva LOCAL: El registro $%ld no es un registro local.  El primer registro global es $%ld."
 
-#: elf64-mmix.c:2190
+#: elf64-mmix.c:2253
 #, c-format
 msgid "%s: Error: multiple definition of `%s'; start of %s is set in a earlier linked file\n"
 msgstr "%s: Error: definición múltiple de `%s'; el inicio de %s está definido en un fichero enlazado con anterioridad\n"
 
-#: elf64-mmix.c:2248
+#: elf64-mmix.c:2311
 msgid "Register section has contents\n"
 msgstr "La sección de registros no tiene contenido\n"
 
-#: elf64-mmix.c:2440
+#: elf64-mmix.c:2503
 #, c-format
 msgid ""
 "Internal inconsistency: remaining %u != max %u.\n"
@@ -2589,65 +2732,80 @@
 "Inconsistencia interna: %u restante != %u máximo.\n"
 "  Por favor reporte este bicho."
 
-#: elf64-ppc.c:2741 libbfd.c:997
-msgid "%B: compiled for a big endian system and target is little endian"
-msgstr "%B: compilado para un sistema big endian y el objetivo es little endian"
+#: elf64-ppc.c:4185
+msgid "%P: %B: cannot create stub entry %s\n"
+msgstr "%P: %B: no se puede crear la entrada de cabo %s\n"
 
-#: elf64-ppc.c:2744 libbfd.c:999
-msgid "%B: compiled for a little endian system and target is big endian"
-msgstr "%B: compilado para un sistema little endian y el objetivo es big endian"
+#: elf64-ppc.c:6518
+msgid "%P: copy reloc against `%s' requires lazy plt linking; avoid setting LD_BIND_NOW=1 or upgrade gcc\n"
+msgstr "%P: la reubicación de copia contra `%s' requiere de enlazado plt flojo; evite establecer LD_BIND_NOW=1 o actualice gcc\n"
 
-#: elf64-ppc.c:6473
-#, c-format
-msgid "copy reloc against `%s' requires lazy plt linking; avoid setting LD_BIND_NOW=1 or upgrade gcc"
-msgstr "la reubicación de copia contra `%s' requiere de enlazado plt flojo; evite establecer LD_BIND_NOW=1 o actualice gcc"
+#: elf64-ppc.c:6788
+msgid "%B: undefined symbol on R_PPC64_TOCSAVE relocation"
+msgstr "%B: símbolo sin definir en la reubicación R_PPC64_TOCSAVE"
 
-#: elf64-ppc.c:6901
-msgid "dynreloc miscount for %B, section %A"
-msgstr "cuenta errónea de la reubicación dinámica de %B, sección %A"
+#: elf64-ppc.c:6992
+msgid "%P: dynreloc miscount for %B, section %A\n"
+msgstr "%P: cuenta errónea de la reubicación dinámica de %B, sección %A\n"
 
-#: elf64-ppc.c:6985
+#: elf64-ppc.c:7076
 msgid "%B: .opd is not a regular array of opd entries"
 msgstr "%B: .opd no es una matriz regular de entradas opd"
 
-#: elf64-ppc.c:6994
+#: elf64-ppc.c:7085
 msgid "%B: unexpected reloc type %u in .opd section"
 msgstr "%B: tipo de reubicación %u inesperado en la sección .opd"
 
-#: elf64-ppc.c:7015
+#: elf64-ppc.c:7106
 msgid "%B: undefined sym `%s' in .opd section"
 msgstr "%B: símbolo `%s' sin definir en la sección .opd"
 
-#: elf64-ppc.c:7877 elf64-ppc.c:8392
+#: elf64-ppc.c:7664
+msgid "%H __tls_get_addr lost arg, TLS optimization disabled\n"
+msgstr "%H se perdió el argumento __tls_get_addr, se desactiva la optimización TLS\n"
+
+#: elf64-ppc.c:8003 elf64-ppc.c:8564
 #, c-format
 msgid "%s defined on removed toc entry"
 msgstr "se definió %s en la entrada toc eliminada"
 
-#: elf64-ppc.c:9459
-#, c-format
-msgid "long branch stub `%s' offset overflow"
-msgstr "desbordamiento del desplazamiento de stub de ramificación long `%s'"
+#: elf64-ppc.c:8521
+msgid "%P: %H: %s relocation references optimized away TOC entry\n"
+msgstr "%P: %H: la reubicación %s referencía una entrada TOC optimizada por fuera\n"
 
-#: elf64-ppc.c:9518
-#, c-format
-msgid "can't find branch stub `%s'"
-msgstr "no se puede encontrar la ramificación de cabo `%s'"
+#: elf64-ppc.c:9598
+msgid "%P: cannot find opd entry toc for %s\n"
+msgstr "%P: no se puede encontrar la tabla de contenidos de la entrada opd para %s\n"
 
-#: elf64-ppc.c:9580 elf64-ppc.c:9716
-#, c-format
-msgid "linkage table error against `%s'"
-msgstr "error de la tabla de enlazado contra `%s'"
+#: elf64-ppc.c:9680
+msgid "%P: long branch stub `%s' offset overflow\n"
+msgstr "%P: desbordamiento del desplazamiento de stub de ramificación long `%s'\n"
 
-#: elf64-ppc.c:9886
-#, c-format
-msgid "can't build branch stub `%s'"
-msgstr "no se puede construir la ramificación de cabos `%s'"
+#: elf64-ppc.c:9739
+msgid "%P: can't find branch stub `%s'\n"
+msgstr "%P: no se puede encontrar la ramificación de cabo `%s'\n"
 
-#: elf64-ppc.c:10684
+#: elf64-ppc.c:9801 elf64-ppc.c:9943
+msgid "%P: linkage table error against `%s'\n"
+msgstr "%P: error de la tabla de enlazado contra `%s'\n"
+
+#: elf64-ppc.c:10126
+msgid "%P: can't build branch stub `%s'\n"
+msgstr "%P: no se puede construir la ramificación de cabos `%s'\n"
+
+#: elf64-ppc.c:10941
 msgid "%B section %A exceeds stub group size"
 msgstr "%B sección %A excede el tamaño de grupo de cabos"
 
-#: elf64-ppc.c:11339
+#: elf64-ppc.c:11666 elf64-ppc.c:11699
+msgid "%P: %s offset too large for .eh_frame sdata4 encoding"
+msgstr "%P: el desplazamiento %s es demasiado grande para la codificación sdata4 .eh_frame"
+
+#: elf64-ppc.c:11744
+msgid "%P: stubs don't match calculated size\n"
+msgstr "%P: los cabos no coinciden con el tamaño calculado\n"
+
+#: elf64-ppc.c:11756
 #, c-format
 msgid ""
 "linker stubs in %u group%s\n"
@@ -2664,82 +2822,94 @@
 "  ajuste toc long %lu\n"
 "  llamada plt     %lu"
 
-#: elf64-ppc.c:12190
-msgid "%B(%A+0x%lx): automatic multiple TOCs not supported using your crt files; recompile with -mminimal-toc or upgrade gcc"
-msgstr "%B(%A+0x%lx): no se admiten los TOCs múltiples automáticos, utilizando sus ficheros crt; recompile con -mminimal-toc o actualice gcc"
+#: elf64-ppc.c:12042
+msgid "%P: %H: %s used with TLS symbol %s\n"
+msgstr "%P: %H: se usó %s con el símbolo TLS %s\n"
 
-#: elf64-ppc.c:12198
-msgid "%B(%A+0x%lx): sibling call optimization to `%s' does not allow automatic multiple TOCs; recompile with -mminimal-toc or -fno-optimize-sibling-calls, or make `%s' extern"
-msgstr "%B(%A+0x%lx): la optimización de llamada hermana a `%s' no permite TOCs múltiples automáticos; recompile con -mminimal-toc ó -fno-optimize-sibling-calls, o vuelva `%s' externa"
+#: elf64-ppc.c:12043
+msgid "%P: %H: %s used with non-TLS symbol %s\n"
+msgstr "%P: %H: se usó %s con el símbolo %s que no es TLS\n"
 
-#: elf64-ppc.c:12919
-msgid "%B: relocation %s is not supported for symbol %s."
-msgstr "%B: no se admite la reubicación %s para el símbolo %s."
+#: elf64-ppc.c:12556
+msgid "%P: %H: automatic multiple TOCs not supported using your crt files; recompile with -mminimal-toc or upgrade gcc\n"
+msgstr "%P: %H: no se admiten los TOCs múltiples automáticos, utilizando sus ficheros crt; recompile con -mminimal-toc o actualice gcc\n"
 
-#: elf64-ppc.c:13096
-msgid "%B: error: relocation %s not a multiple of %d"
-msgstr "%B: error: la reubicación %s no es un múltiplo de %d"
+#: elf64-ppc.c:12562
+msgid "%P: %H: sibling call optimization to `%s' does not allow automatic multiple TOCs; recompile with -mminimal-toc or -fno-optimize-sibling-calls, or make `%s' extern\n"
+msgstr "%P: %H: la optimización de llamada hermana a `%s' no permite TOCs múltiples automáticos; recompile con -mminimal-toc ó -fno-optimize-sibling-calls, o vuelva `%s' externa\n"
 
-#: elf64-sh64.c:1682
+#: elf64-ppc.c:13286
+msgid "%P: %B: relocation %s is not supported for symbol %s\n"
+msgstr "%P: %B: no se admite la reubicación %s para el símbolo %s\n"
+
+#: elf64-ppc.c:13446
+msgid "%P: %H: error: %s not a multiple of %u\n"
+msgstr "%P: %H: error: %s no es un múltiplo de %u\n"
+
+#: elf64-sh64.c:1686
 #, c-format
 msgid "%s: error: unaligned relocation type %d at %08x reloc %08x\n"
 msgstr "%s: error: tipo de reubicación %d sin alinear en %08x reubicación %08x\n"
 
-#: elf64-sparc.c:444
+#: elf64-sparc.c:446
 msgid "%B: Only registers %%g[2367] can be declared using STT_REGISTER"
 msgstr "%B: Solamente los registros %%g[2367] se pueden declarar utilizando STT_REGISTER"
 
-#: elf64-sparc.c:464
+#: elf64-sparc.c:466
 msgid "Register %%g%d used incompatibly: %s in %B, previously %s in %B"
 msgstr "El registro %%g%d se usó de forma incompatible: %s en %B, previamente %s en %B"
 
-#: elf64-sparc.c:487
+#: elf64-sparc.c:489
 msgid "Symbol `%s' has differing types: REGISTER in %B, previously %s in %B"
 msgstr "El símbolo `%s' tiene tipos divergentes: REGISTER en %B, previamente %s en %B"
 
-#: elf64-sparc.c:532
+#: elf64-sparc.c:534
 msgid "Symbol `%s' has differing types: %s in %B, previously REGISTER in %B"
 msgstr "El símbolo `%s' tiene tipos divergentes: %s en %B, previamente REGISTER en %B"
 
-#: elf64-sparc.c:684
+#: elf64-sparc.c:687
 msgid "%B: linking UltraSPARC specific with HAL specific code"
 msgstr "%B: se enlaza código específico de UltraSPARC con código específico de HAL"
 
-#: elf64-x86-64.c:1360
+#: elf64-x86-64.c:1427
+msgid "%B: relocation %s against symbol `%s' isn't supported in x32 mode"
+msgstr "%B: la reubicación %s contra el símbolo `%s' no se admite en modo x32"
+
+#: elf64-x86-64.c:1656
 msgid "%B: '%s' accessed both as normal and thread local symbol"
 msgstr "%B: se accedió a '%s' como un símbolo normal y como un símbolo local de hilo"
 
-#: elf64-x86-64.c:2801
+#: elf64-x86-64.c:3150
 msgid "%B: relocation %s against STT_GNU_IFUNC symbol `%s' has non-zero addend: %d"
 msgstr "%B: la reubicación %s contra el símbolo STT_GNU_IFUNC `%s' con adición que no es cero: %d"
 
-#: elf64-x86-64.c:3073
+#: elf64-x86-64.c:3411
 msgid "%B: relocation R_X86_64_GOTOFF64 against protected function `%s' can not be used when making a shared object"
 msgstr "%B: no se puede usar la reubicación R_X86_64_GOTOFF contra la función protegida `%s' cuando se hace un objeto compartido"
 
-#: elf64-x86-64.c:3184
+#: elf64-x86-64.c:3523
 msgid "; recompile with -fPIC"
 msgstr "; recompile con -fPIC"
 
-#: elf64-x86-64.c:3189
+#: elf64-x86-64.c:3528
 msgid "%B: relocation %s against %s `%s' can not be used when making a shared object%s"
 msgstr "%B: no se puede usar la reubicación %s contra %s `%s' cuando se hace un objeto compartido%s"
 
-#: elf64-x86-64.c:3191
+#: elf64-x86-64.c:3530
 msgid "%B: relocation %s against undefined %s `%s' can not be used when making a shared object%s"
 msgstr "%B: no se puede usar la reubicación %s contra %s sin definir `%s' cuando se hace un objeto compartido%s"
 
-#: elfcode.h:826
+#: elfcode.h:767
 #, c-format
 msgid "warning: %s has a corrupt string table index - ignoring"
 msgstr "aviso: %s tiene un índice de tablas de cadenas corrupto - se descarta"
 
-#: elfcode.h:1236
+#: elfcode.h:1177
 #, c-format
 msgid "%s: version count (%ld) does not match symbol count (%ld)"
 msgstr "%s: la cuenta de versión (%ld) no coincide con la cuenta de símbolos (%ld)"
 
-#: elfcode.h:1476
+#: elfcode.h:1431
 #, c-format
 msgid "%s(%s): relocation %d has invalid symbol index %ld"
 msgstr "%s(%s): la reubicación %d tiene un índice de símbolo %ld inválido"
@@ -2748,342 +2918,372 @@
 msgid "Warning: %B is truncated: expected core file size >= %lu, found: %lu."
 msgstr "Aviso: se truncó %B: se esperaba el tamaño de fichero core >= %lu, se encontró: %lu."
 
-#: elflink.c:1119
+#: elflink.c:1117
 msgid "%s: TLS definition in %B section %A mismatches non-TLS definition in %B section %A"
 msgstr "%s: la definición TLS en %B sección %A no coincide con la definición que no es TLS en %B sección %A"
 
-#: elflink.c:1123
+#: elflink.c:1121
 msgid "%s: TLS reference in %B mismatches non-TLS reference in %B"
 msgstr "%s: la referencia TLS en %B no coincide con la referencia que no es TLS en %B"
 
-#: elflink.c:1127
+#: elflink.c:1125
 msgid "%s: TLS definition in %B section %A mismatches non-TLS reference in %B"
 msgstr "%s: la definición TLS en %B sección %A no coincide con la referencia que no es TLS en %B"
 
-#: elflink.c:1131
+#: elflink.c:1129
 msgid "%s: TLS reference in %B mismatches non-TLS definition in %B section %A"
 msgstr "%s: la referencia TLS en %B no coincide con la definición que no es TLS en %B sección %A"
 
-#: elflink.c:1763
+#: elflink.c:1762
 msgid "%B: unexpected redefinition of indirect versioned symbol `%s'"
 msgstr "%B: redefinición inesperada del símbolo con versión indirecta `%s'"
 
-#: elflink.c:2076
+#: elflink.c:2063
 msgid "%B: version node not found for symbol %s"
 msgstr "%B: no se encuentra la versión del nodo para el símbolo %s"
 
-#: elflink.c:2166
+#: elflink.c:2154
 msgid "%B: bad reloc symbol index (0x%lx >= 0x%lx) for offset 0x%lx in section `%A'"
 msgstr "%B: índice de símbolos de reubicación inválido (0x%lx >= 0x%lx) erróneo para el desplazamiento 0x%lx en la sección `%A'"
 
-#: elflink.c:2177
+#: elflink.c:2165
 msgid "%B: non-zero symbol index (0x%lx) for offset 0x%lx in section `%A' when the object file has no symbol table"
 msgstr "%B: índice de símbolos que no es cero (0x%lx) para el desplazamiento 0x%lx) en la sección `%A' cuando el fichero objeto no tiene tabla de símbolos"
 
-#: elflink.c:2367
+#: elflink.c:2355
 msgid "%B: relocation size mismatch in %B section %A"
 msgstr "%B: el tamaño de reubicación no coincide en %B sección %A"
 
-#: elflink.c:2662
+#: elflink.c:2639
 #, c-format
 msgid "warning: type and size of dynamic symbol `%s' are not defined"
 msgstr "aviso: el tipo y tamaño del símbolo dinámico `%s' no están definidos"
 
-#: elflink.c:3418
+#: elflink.c:3391
 msgid "%P: alternate ELF machine code found (%d) in %B, expecting %d\n"
 msgstr "%P: se encontró código máquina ELF alternativo (%d) en %B, se espera %d\n"
 
-#: elflink.c:4050
+#: elflink.c:4037
 msgid "%B: %s: invalid version %u (max %d)"
 msgstr "%B: %s: versión %u inválida (máximo %d)"
 
-#: elflink.c:4086
+#: elflink.c:4073
 msgid "%B: %s: invalid needed version %d"
 msgstr "%B: %s: versión requerida %d inválida"
 
-#: elflink.c:4285
+#: elflink.c:4269
 msgid "Warning: alignment %u of common symbol `%s' in %B is greater than the alignment (%u) of its section %A"
 msgstr "Aviso: la alineación %u del símbolo común `%s' en %B es más grande que la alineación (%u) de su sección %A"
 
-#: elflink.c:4291
+#: elflink.c:4275
 msgid "Warning: alignment %u of symbol `%s' in %B is smaller than %u in %B"
 msgstr "Aviso: la alineación %u del símbolo `%s' en %B es más pequeña que %u en %B"
 
-#: elflink.c:4306
+#: elflink.c:4290
 msgid "Warning: size of symbol `%s' changed from %lu in %B to %lu in %B"
 msgstr "Aviso: el tamaño del símbolo `%s' cambió de %lu en %B a %lu en %B"
 
-#: elflink.c:4472
+#: elflink.c:4463
 msgid "%B: undefined reference to symbol '%s'"
 msgstr "%B: referencia sin definir al símbolo '%s'"
 
-#: elflink.c:4475
+#: elflink.c:4466
 msgid "note: '%s' is defined in DSO %B so try adding it to the linker command line"
 msgstr "nota: se define '%s' en DSO %B así que se tratará de agregarlo a la línea de órdenes del enlazador"
 
-#: elflink.c:5779
+#: elflink.c:5781
 #, c-format
 msgid "%s: undefined version: %s"
 msgstr "%s: versión sin definir: %s"
 
-#: elflink.c:5847
+#: elflink.c:5849
 msgid "%B: .preinit_array section is not allowed in DSO"
 msgstr "%B: no se permite la sección .preinit_array en DSO"
 
-#: elflink.c:7598
+#: elflink.c:7604
 #, c-format
 msgid "undefined %s reference in complex symbol: %s"
 msgstr "referencia %s sin definir en el símbolo complejo: %s"
 
-#: elflink.c:7752
+#: elflink.c:7758
 #, c-format
 msgid "unknown operator '%c' in complex symbol"
 msgstr "operador desconocido '%c' en el símbolo complejo"
 
-#: elflink.c:8091 elflink.c:8108 elflink.c:8145 elflink.c:8162
+#: elflink.c:8097 elflink.c:8114 elflink.c:8151 elflink.c:8168
 msgid "%B: Unable to sort relocs - they are in more than one size"
 msgstr "%B: No se pueden ordenar las reubicaciones - son de tamaños diferentes"
 
-#: elflink.c:8122 elflink.c:8176
+#: elflink.c:8128 elflink.c:8182
 msgid "%B: Unable to sort relocs - they are of an unknown size"
 msgstr "%B: No se pueden ordenar las reubicaciones - son de tamaño desconocido"
 
-#: elflink.c:8227
+#: elflink.c:8233
 msgid "Not enough memory to sort relocations"
 msgstr "No hay suficiente memoria para ordenar las reubicaciones"
 
-#: elflink.c:8420
+#: elflink.c:8426
 msgid "%B: Too many sections: %d (>= %d)"
 msgstr "%B: Demasiadas secciones:  %d (>= %d)"
 
-#: elflink.c:8663
-msgid "%B: %s symbol `%s' in %B is referenced by DSO"
-msgstr "%B: el símbolo %s `%s' en %B está referenciado por DSO"
+#: elflink.c:8675
+msgid "%B: internal symbol `%s' in %B is referenced by DSO"
+msgstr "%B: el símbolo interno `%s' en %B está referenciado por DSO"
 
-#: elflink.c:8754
+#: elflink.c:8677
+msgid "%B: hidden symbol `%s' in %B is referenced by DSO"
+msgstr "%B: el símbolo oculto `%s' en %B está referenciado por DSO"
+
+#: elflink.c:8679
+msgid "%B: local symbol `%s' in %B is referenced by DSO"
+msgstr "%B: el símbolo local `%s' en %B está referenciado por DSO"
+
+#: elflink.c:8776
 msgid "%B: could not find output section %A for input section %A"
 msgstr "%B: no se puede encontrar la sección de salida %A para la sección de entrada %A"
 
-#: elflink.c:8874
-msgid "%B: %s symbol `%s' isn't defined"
-msgstr "%B: el símbolo %s `%s' no está definido"
+#: elflink.c:8899
+msgid "%B: protected symbol `%s' isn't defined"
+msgstr "%B: el símbolo protegido `%s' no está definido"
 
-#: elflink.c:9428
+#: elflink.c:8901
+msgid "%B: internal symbol `%s' isn't defined"
+msgstr "%B: el símbolo interno `%s' no está definido"
+
+#: elflink.c:8903
+msgid "%B: hidden symbol `%s' isn't defined"
+msgstr "%B: el símbolo oculto `%s' no está definido"
+
+#: elflink.c:9432
+msgid "error: %B: size of section %A is not multiple of address size"
+msgstr "error: %B: el tamaño de la sección %A no es un múltiplo del tamaño de la dirección"
+
+#: elflink.c:9479
 msgid "error: %B contains a reloc (0x%s) for section %A that references a non-existent global symbol"
 msgstr "error: %B contiene una reubicación (0x%s) para la sección %A que refiere a un símbolo global que no existe"
 
-#: elflink.c:9494
-msgid "%X`%s' referenced in section `%A' of %B: defined in discarded section `%A' of %B\n"
-msgstr "%X`%s' referido en la sección `%A' de %B: se definió en la sección descartada `%A' de %B\n"
-
-#: elflink.c:10141
+#: elflink.c:10214
 msgid "%A has both ordered [`%A' in %B] and unordered [`%A' in %B] sections"
 msgstr "%A tiene tanto secciones ordenadas [`%A' en %B] como desordenadas [`%A' en %B]"
 
-#: elflink.c:10146
+#: elflink.c:10219
 #, c-format
 msgid "%A has both ordered and unordered sections"
 msgstr "%A tiene secciones tanto ordenadas como desordenadas"
 
-#: elflink.c:10992 elflink.c:11036
+#: elflink.c:10784
+msgid "%B: file class %s incompatible with %s"
+msgstr "%B: el fichero de clase %s es incompatible con %s"
+
+#: elflink.c:11093 elflink.c:11137
 msgid "%B: could not find output section %s"
 msgstr "%B: no se puede encontrar la sección de salida %s"
 
-#: elflink.c:10997
+#: elflink.c:11098
 #, c-format
 msgid "warning: %s section has zero size"
 msgstr "aviso: la sección %s es de tamaño cero"
 
-#: elflink.c:11102
+#: elflink.c:11143
+#, c-format
+msgid "warning: section '%s' is being made into a note"
+msgstr "aviso: la sección '%s' se está convirtiendo en una nota"
+
+#: elflink.c:11212
+msgid "%P%X: read-only segment has dynamic relocations.\n"
+msgstr "%P%X: un segmento de sólo lectura tiene reubicaciones dinámicas.\n"
+
+#: elflink.c:11215
 msgid "%P: warning: creating a DT_TEXTREL in a shared object.\n"
 msgstr "%P: aviso: se crea un DT_TEXTREL en un objeto compartido.\n"
 
-#: elflink.c:11289
+#: elflink.c:11402
 msgid "%P%X: can not read symbols: %E\n"
 msgstr "%P%X: no se pueden leer símbolos: %E\n"
 
-#: elflink.c:11638
+#: elflink.c:11792
 msgid "Removing unused section '%s' in file '%B'"
 msgstr "Se elimina la sección sin uso '%s' en el fichero '%B'"
 
-#: elflink.c:11850
+#: elflink.c:11998
 msgid "Warning: gc-sections option ignored"
 msgstr "Aviso: se descarta la opción gc-sections"
 
-#: elflink.c:12399
-msgid "%B: ignoring duplicate section `%A'"
-msgstr "%B: se descarta la sección duplicada `%A'"
+#: elflink.c:12277
+#, c-format
+msgid "Unrecognized INPUT_SECTION_FLAG %s\n"
+msgstr "No se reconoce INPUT_SECTION_FLAG %s\n"
 
-#: elflink.c:12406 elflink.c:12413
-msgid "%B: duplicate section `%A' has different size"
-msgstr "%B: la sección duplicada `%A' tiene tamaño diferente"
-
-#: elflink.c:12421 elflink.c:12426
-msgid "%B: warning: could not read contents of section `%A'"
-msgstr "%B: aviso: no se puede leer el contenido de la sección `%A'"
-
-#: elflink.c:12430
-msgid "%B: warning: duplicate section `%A' has different contents"
-msgstr "%B: aviso: la sección duplicada `%A' tiene contenido diferente"
-
-#: elflink.c:12531 linker.c:3138
-msgid "%F%P: already_linked_table: %E\n"
-msgstr "%F%P: already_linked_table: %E\n"
-
-#: elfxx-mips.c:1220
+#: elfxx-mips.c:1234
 msgid "static procedure (no name)"
 msgstr "procedimiento estático (sin nombre)"
 
-#: elfxx-mips.c:5623
+#: elfxx-mips.c:5259
+msgid "MIPS16 and microMIPS functions cannot call each other"
+msgstr "las funciones MIPS16 y microMIPS no se pueden llamar unas a otras"
+
+#: elfxx-mips.c:5856
 msgid "%B: %A+0x%lx: Direct jumps between ISA modes are not allowed; consider recompiling with interlinking enabled."
 msgstr "%B: %A+0x%lx: No se permiten los saltos directos entre modos ISA; considere recompilar con el entrelazado activado."
 
-#: elfxx-mips.c:6280 elfxx-mips.c:6503
+#: elfxx-mips.c:6519 elfxx-mips.c:6742
 msgid "%B: Warning: bad `%s' option size %u smaller than its header"
 msgstr "%B: Aviso: el tamaño de opción `%s' %u erróneo es más pequeño que su encabezado"
 
-#: elfxx-mips.c:7254 elfxx-mips.c:7379
+#: elfxx-mips.c:7495 elfxx-mips.c:7620
 msgid "%B: Warning: cannot determine the target function for stub section `%s'"
 msgstr "%B: Aviso: no se puede determinar la función objetivo para la sección de cabo `%s'"
 
-#: elfxx-mips.c:7508
+#: elfxx-mips.c:7749
 msgid "%B: Malformed reloc detected for section %s"
 msgstr "%B: Se detectó una reubicación malformada para la sección %s"
 
-#: elfxx-mips.c:7548
+#: elfxx-mips.c:7801
 msgid "%B: GOT reloc at 0x%lx not expected in executables"
 msgstr "%B: no se esperaba la reubicación GOT en 0x%lx en ejecutables"
 
-#: elfxx-mips.c:7670
+#: elfxx-mips.c:7930
 msgid "%B: CALL16 reloc at 0x%lx not against global symbol"
 msgstr "%B: la reubicación CALL16 en 0x%lx no es contra un símbolo global"
 
-#: elfxx-mips.c:8365
+#: elfxx-mips.c:8645
 #, c-format
 msgid "non-dynamic relocations refer to dynamic symbol %s"
 msgstr "reubicaciones que no son dinámicas se refieren al símbolo dinámico %s"
 
-#: elfxx-mips.c:9068
+#: elfxx-mips.c:9347
 msgid "%B: Can't find matching LO16 reloc against `%s' for %s at 0x%lx in section `%A'"
 msgstr "%B: No se puede encontrar una reubicación LO16 coincidente contra `%s' para %s en 0x%lx en la sección `%A'"
 
-#: elfxx-mips.c:9207
+#: elfxx-mips.c:9486
 msgid "small-data section exceeds 64KB; lower small-data size limit (see option -G)"
 msgstr "la sección small-data excede los 64KB; disminuya el límite de tamaño de small-data (vea la opción -G)"
 
-#: elfxx-mips.c:12027
+#: elfxx-mips.c:9505
+msgid "JALX to a non-word-aligned address"
+msgstr "JALX a una dirección que no está alineada con word"
+
+#: elfxx-mips.c:13266
 #, c-format
 msgid "%s: illegal section name `%s'"
 msgstr "%s: nombre de sección `%s' ilegal"
 
-#: elfxx-mips.c:12405 elfxx-mips.c:12431
+#: elfxx-mips.c:13645 elfxx-mips.c:13671
 msgid "Warning: %B uses -msingle-float, %B uses -mdouble-float"
 msgstr "Aviso: %B usa -msingle-float, %B usa -mdouble-float"
 
-#: elfxx-mips.c:12417 elfxx-mips.c:12473
+#: elfxx-mips.c:13657 elfxx-mips.c:13713
 msgid "Warning: %B uses -msingle-float, %B uses -mips32r2 -mfp64"
 msgstr "Aviso: %B usa -msingle-float, %B usa -mips32r2 -mfp64"
 
-#: elfxx-mips.c:12443 elfxx-mips.c:12479
+#: elfxx-mips.c:13683 elfxx-mips.c:13719
 msgid "Warning: %B uses -mdouble-float, %B uses -mips32r2 -mfp64"
 msgstr "Aviso: %B usa -mdouble-float, %B usa -mips32r2 -mfp64"
 
-#: elfxx-mips.c:12521
+#: elfxx-mips.c:13761
 msgid "%B: endianness incompatible with that of the selected emulation"
 msgstr "%B: la endianez es incompatible con aquella de la emulación seleccionada"
 
-#: elfxx-mips.c:12532
+#: elfxx-mips.c:13772
 msgid "%B: ABI is incompatible with that of the selected emulation"
 msgstr "%B: la ABI es incompatible con aquella de la emulación seleccionada"
 
-#: elfxx-mips.c:12613
+#: elfxx-mips.c:13856
 msgid "%B: warning: linking abicalls files with non-abicalls files"
 msgstr "%B: aviso: se enlazan ficheros de llamadas abi con ficheros que no son de llamadas abi"
 
-#: elfxx-mips.c:12630
+#: elfxx-mips.c:13873
 msgid "%B: linking 32-bit code with 64-bit code"
 msgstr "%B: se enlaza código de 32-bit con código de 64-bit"
 
-#: elfxx-mips.c:12658
+#: elfxx-mips.c:13901
 msgid "%B: linking %s module with previous %s modules"
 msgstr "%B: se enlaza el módulo %s con módulos %s previos"
 
-#: elfxx-mips.c:12681
+#: elfxx-mips.c:13924
 msgid "%B: ABI mismatch: linking %s module with previous %s modules"
 msgstr "%B: no coincide ABI: se enlaza el módulo %s con módulos %s previos"
 
-#: elfxx-mips.c:12845
+#: elfxx-mips.c:13948
+msgid "%B: ASE mismatch: linking %s module with previous %s modules"
+msgstr "%B: no coincide ASE: se enlaza el módulo %s con módulos %s previos"
+
+#: elfxx-mips.c:14106
 #, c-format
 msgid " [abi=O32]"
 msgstr " [abi=O32]"
 
-#: elfxx-mips.c:12847
+#: elfxx-mips.c:14108
 #, c-format
 msgid " [abi=O64]"
 msgstr " [abi=O64]"
 
-#: elfxx-mips.c:12849
+#: elfxx-mips.c:14110
 #, c-format
 msgid " [abi=EABI32]"
 msgstr " [abi=EABI32]"
 
-#: elfxx-mips.c:12851
+#: elfxx-mips.c:14112
 #, c-format
 msgid " [abi=EABI64]"
 msgstr " [abi=EABI64]"
 
-#: elfxx-mips.c:12853
+#: elfxx-mips.c:14114
 #, c-format
 msgid " [abi unknown]"
 msgstr " [abi desconocido]"
 
-#: elfxx-mips.c:12855
+#: elfxx-mips.c:14116
 #, c-format
 msgid " [abi=N32]"
 msgstr " [abi=N32]"
 
-#: elfxx-mips.c:12857
+#: elfxx-mips.c:14118
 #, c-format
 msgid " [abi=64]"
 msgstr " [abi=64]"
 
-#: elfxx-mips.c:12859
+#: elfxx-mips.c:14120
 #, c-format
 msgid " [no abi set]"
 msgstr " [no hay conjunto abi]"
 
-#: elfxx-mips.c:12880
+#: elfxx-mips.c:14141
 #, c-format
 msgid " [unknown ISA]"
 msgstr " [ISA desconocido]"
 
-#: elfxx-mips.c:12891
+#: elfxx-mips.c:14155
 #, c-format
 msgid " [not 32bitmode]"
 msgstr " [no es modo 32bit]"
 
-#: elfxx-sparc.c:595
+#: elfxx-sparc.c:596
 #, c-format
 msgid "invalid relocation type %d"
 msgstr "tipo de reubicación %d inválido"
 
-#: i386linux.c:454 m68klinux.c:458 sparclinux.c:452
+#: elfxx-tilegx.c:3952
+msgid "%B: Cannot link together %s and %s objects."
+msgstr "%B: No se pueden enlazar juntos los objetos %s y %s."
+
+#: i386linux.c:451 m68klinux.c:456 sparclinux.c:450
 #, c-format
 msgid "Output file requires shared library `%s'\n"
 msgstr "El fichero de salida requiere la biblioteca compartida `%s'\n"
 
-#: i386linux.c:462 m68klinux.c:466 sparclinux.c:460
+#: i386linux.c:459 m68klinux.c:464 sparclinux.c:458
 #, c-format
 msgid "Output file requires shared library `%s.so.%s'\n"
 msgstr "El fichero de salida requiere la biblioteca compartida `%s.so.%s'\n"
 
-#: i386linux.c:651 i386linux.c:701 m68klinux.c:658 m68klinux.c:706
-#: sparclinux.c:650 sparclinux.c:700
+#: i386linux.c:648 i386linux.c:698 m68klinux.c:656 m68klinux.c:704
+#: sparclinux.c:648 sparclinux.c:698
 #, c-format
 msgid "Symbol %s not defined for fixups\n"
 msgstr "El símbolo %s no está definido para composturas\n"
 
-#: i386linux.c:725 m68klinux.c:730 sparclinux.c:724
+#: i386linux.c:722 m68klinux.c:728 sparclinux.c:722
 msgid "Warning: fixup count mismatch\n"
 msgstr "Aviso: no coincide la cuenta de composturas\n"
 
@@ -3154,86 +3354,160 @@
 msgid "%B: unable to get decompressed section %A"
 msgstr "%B: no se puede obtener la sección %A descomprimida"
 
-#: libbfd.c:1027
+#: libbfd.c:1012
+msgid "%B: compiled for a big endian system and target is little endian"
+msgstr "%B: compilado para un sistema big endian y el objetivo es little endian"
+
+#: libbfd.c:1014
+msgid "%B: compiled for a little endian system and target is big endian"
+msgstr "%B: compilado para un sistema little endian y el objetivo es big endian"
+
+#: libbfd.c:1043
 #, c-format
 msgid "Deprecated %s called at %s line %d in %s\n"
 msgstr "Se llamó a %s que es obsoleto en %s línea %d en %s\n"
 
-#: libbfd.c:1030
+#: libbfd.c:1046
 #, c-format
 msgid "Deprecated %s called\n"
 msgstr "Se llamó a %s que es obsoleto\n"
 
-#: linker.c:1911
+#: linker.c:1872
 msgid "%B: indirect symbol `%s' to `%s' is a loop"
 msgstr "%B: el símbolo indirecto `%s' para `%s' es un ciclo"
 
-#: linker.c:2778
+#: linker.c:2736
 #, c-format
 msgid "Attempt to do relocatable link with %s input and %s output"
 msgstr "Se intentó hacer un enlace reubicable con entrada %s y salida %s"
 
-#: linker.c:3105
-msgid "%B: warning: ignoring duplicate section `%A'\n"
-msgstr "%B: aviso: se descarta la sección duplicada `%A'\n"
+#: linker.c:3021
+msgid "%B: ignoring duplicate section `%A'\n"
+msgstr "%B: se descarta la sección duplicada `%A'\n"
 
-#: linker.c:3119
-msgid "%B: warning: duplicate section `%A' has different size\n"
-msgstr "%B: aviso: la sección duplicada `%A' es de tamaño diferente\n"
+#: linker.c:3030 linker.c:3039
+msgid "%B: duplicate section `%A' has different size\n"
+msgstr "%B: la sección duplicada `%A' tiene tamaño diferente\n"
 
-#: mach-o.c:3403
+#: linker.c:3047 linker.c:3052
+msgid "%B: could not read contents of section `%A'\n"
+msgstr "%B: no se puede leer el contenido de la sección `%A'\n"
+
+#: linker.c:3056
+msgid "%B: duplicate section `%A' has different contents\n"
+msgstr "%B: la sección duplicada `%A' tiene contenido diferente\n"
+
+#: mach-o.c:407
+msgid "bfd_mach_o_canonicalize_symtab: unable to load symbols"
+msgstr "bfd_mach_o_canonicalize_symtab: no se pueden cargar símbolos"
+
+#: mach-o.c:1301
+#, c-format
+msgid "unable to write unknown load command 0x%lx"
+msgstr "no se puede escribir la orden load 0x%lx desconocida"
+
+#: mach-o.c:1789
+#, c-format
+msgid "bfd_mach_o_read_symtab_symbol: unable to read %d bytes at %lu"
+msgstr "bfd_mach_o_read_symtab_symbol: no se pueden leer %d bytes en %lu"
+
+#: mach-o.c:1807
+#, c-format
+msgid "bfd_mach_o_read_symtab_symbol: name out of range (%lu >= %lu)"
+msgstr "bfd_mach_o_read_symtab_symbol: nombre fuera de rango (%lu >= %lu)"
+
+#: mach-o.c:1892
+#, c-format
+msgid "bfd_mach_o_read_symtab_symbol: symbol \"%s\" specified invalid section %d (max %lu): setting to undefined"
+msgstr "bfd_mach_o_read_symtab_symbol: el símbolo \"%s\" especificó la sección inválida %d (máximo %lu): se cambia a indefinido"
+
+#: mach-o.c:1900
+#, c-format
+msgid "bfd_mach_o_read_symtab_symbol: symbol \"%s\" is unsupported 'indirect' reference: setting to undefined"
+msgstr "bfd_mach_o_read_symtab_symbol: el símbolo \"%s\" no admite la referencia 'indirect': se cambia a indefinido"
+
+#: mach-o.c:1906
+#, c-format
+msgid "bfd_mach_o_read_symtab_symbol: symbol \"%s\" specified invalid type field 0x%x: setting to undefined"
+msgstr "bfd_mach_o_read_symtab_symbol: el símbolo \"%s\" especificó el campo de tipo 0x%x inválido: se cambia a indefinido"
+
+#: mach-o.c:1979
+msgid "bfd_mach_o_read_symtab_symbols: unable to allocate memory for symbols"
+msgstr "bfd_mach_o_read_symtab_symbols: no se puede reservar memoria para símbolos"
+
+#: mach-o.c:2014
+#, c-format
+msgid "bfd_mach_o_read_dysymtab_symbol: unable to read %lu bytes at %lu"
+msgstr "bfd_mach_o_read_dysymtab_symbol: no se pueden leer %lu bytes en %lu"
+
+#: mach-o.c:2734
+#, c-format
+msgid "unable to read unknown load command 0x%lx"
+msgstr "no se puede leer la orden load 0x%lx desconocida"
+
+#: mach-o.c:2915
+#, c-format
+msgid "bfd_mach_o_scan: unknown architecture 0x%lx/0x%lx"
+msgstr "bfd_mach_o_scan: arquitectura 0x%lx/0x%lx desconocida"
+
+#: mach-o.c:3011
+#, c-format
+msgid "unknown header byte-order value 0x%lx"
+msgstr "valor de encabezado de orden de byte 0x%lx desconocido"
+
+#: mach-o.c:3577
 msgid "Mach-O header:\n"
 msgstr "encabezado de Mach-O:\n"
 
-#: mach-o.c:3404
+#: mach-o.c:3578
 #, c-format
 msgid " magic     : %08lx\n"
 msgstr " magic     : %08lx\n"
 
-#: mach-o.c:3405
+#: mach-o.c:3579
 #, c-format
 msgid " cputype   : %08lx (%s)\n"
 msgstr " tipocpu   : %08lx (%s)\n"
 
-#: mach-o.c:3407
+#: mach-o.c:3581
 #, c-format
 msgid " cpusubtype: %08lx\n"
 msgstr " subtipocpu: %08lx\n"
 
-#: mach-o.c:3408
+#: mach-o.c:3582
 #, c-format
 msgid " filetype  : %08lx (%s)\n"
 msgstr " tipofich  : %08lx (%s)\n"
 
-#: mach-o.c:3411
+#: mach-o.c:3585
 #, c-format
 msgid " ncmds     : %08lx (%lu)\n"
 msgstr " nordenes  : %08lx (%lu)\n"
 
-#: mach-o.c:3412
+#: mach-o.c:3586
 #, c-format
 msgid " sizeofcmds: %08lx\n"
 msgstr " tamordenes: %08lx\n"
 
-#: mach-o.c:3413
+#: mach-o.c:3587
 #, c-format
 msgid " flags     : %08lx ("
 msgstr " opciones  : %08lx ("
 
-#: mach-o.c:3415 vms-alpha.c:7652
+#: mach-o.c:3589 vms-alpha.c:7674
 msgid ")\n"
 msgstr ")\n"
 
-#: mach-o.c:3416
+#: mach-o.c:3590
 #, c-format
 msgid " reserved  : %08x\n"
 msgstr " reservado : %08x\n"
 
-#: mach-o.c:3426
+#: mach-o.c:3600
 msgid "Segments and Sections:\n"
 msgstr "Segmentos y Secciones:\n"
 
-#: mach-o.c:3427
+#: mach-o.c:3601
 msgid " #: Segment name     Section name     Address\n"
 msgstr " #: Nombre segmento  Nombre sección   Dirección\n"
 
@@ -3397,6 +3671,11 @@
 msgid "%B: bad pair/reflo after refhi\n"
 msgstr "%B: pair/reflo erróneo después de refhi\n"
 
+#: pef.c:520
+#, c-format
+msgid "bfd_pef_scan: unknown architecture 0x%lx"
+msgstr "bfd_pef_scan: arquitectura 0x%lx desconocida"
+
 #: pei-x86_64.c:444
 #, c-format
 msgid "warning: .pdata section size (%ld) is not a multiple of %d\n"
@@ -3430,19 +3709,19 @@
 msgid "%B: Unrecognised import name type; %x"
 msgstr "%B: No se reconoce el tipo de nombre de importación; %x"
 
-#: peicode.h:1162
+#: peicode.h:1166
 msgid "%B: Unrecognised machine type (0x%x) in Import Library Format archive"
 msgstr "%B: No se reconoce el tipo de máquina (0x%x) en el archivo de Formato de Importación de Bibliotecas"
 
-#: peicode.h:1174
+#: peicode.h:1178
 msgid "%B: Recognised but unhandled machine type (0x%x) in Import Library Format archive"
 msgstr "%B: Se reconoce el tipo de máquina (0x%x) pero no se maneja en el archivo de Formato de Importación de Bibliotecas"
 
-#: peicode.h:1192
+#: peicode.h:1196
 msgid "%B: size field is zero in Import Library Format header"
 msgstr "%B: el tamaño del campo es cero en el encabezado del Formato de Importación de Bibliotecas"
 
-#: peicode.h:1223
+#: peicode.h:1227
 msgid "%B: string not null terminated in ILF object file."
 msgstr "%B: cadena que no termina en null en el fichero objeto ILF."
 
@@ -3499,6 +3778,15 @@
 msgid "Partition[%d] length = 0x%.8lx (%ld)\n"
 msgstr "Partición[%d] longitud = 0x%.8lx (%ld)\n"
 
+#: reloc.c:6160
+msgid "INPUT_SECTION_FLAGS are not supported.\n"
+msgstr "No se admite INPUT_SECTION_FLAGS.\n"
+
+#: rs6000-core.c:448
+#, c-format
+msgid "%s: warning core file truncated"
+msgstr "%s: aviso de fichero core trunco"
+
 #: som.c:5471
 #, c-format
 msgid ""
@@ -3528,32 +3816,32 @@
 msgid "Unsupported .stab relocation"
 msgstr "No se admite la reubicación .stab"
 
-#: vms-alpha.c:1287
+#: vms-alpha.c:1299
 #, c-format
 msgid "Unknown EGSD subtype %d"
 msgstr "Subtipo de EGSD %d desconocido"
 
-#: vms-alpha.c:1318
+#: vms-alpha.c:1330
 #, c-format
 msgid "Stack overflow (%d) in _bfd_vms_push"
 msgstr "Desbordamiento de la pila (%d) en _bfd_vms_push"
 
-#: vms-alpha.c:1331
+#: vms-alpha.c:1343
 msgid "Stack underflow in _bfd_vms_pop"
 msgstr "Desbordamiento por debajo de la pila en _bfd_vms_pop"
 
 #. These names have not yet been added to this switch statement.
-#: vms-alpha.c:1568
+#: vms-alpha.c:1580
 #, c-format
 msgid "unknown ETIR command %d"
 msgstr "orden ETIR %d desconocida"
 
-#: vms-alpha.c:1755
+#: vms-alpha.c:1767
 #, c-format
 msgid "bad section index in %s"
 msgstr "índice de sección erróneo en %s"
 
-#: vms-alpha.c:1768
+#: vms-alpha.c:1780
 #, c-format
 msgid "unsupported STA cmd %s"
 msgstr "no se admite la orden STA %s"
@@ -3563,1389 +3851,1393 @@
 #. Rotate.
 #. Redefine symbol to current location.
 #. Define a literal.
-#: vms-alpha.c:1944 vms-alpha.c:1975 vms-alpha.c:2222
+#: vms-alpha.c:1956 vms-alpha.c:1987 vms-alpha.c:2234
 #, c-format
 msgid "%s: not supported"
 msgstr "%s: no se admite"
 
-#: vms-alpha.c:1950
+#: vms-alpha.c:1962
 #, c-format
 msgid "%s: not implemented"
 msgstr "%s: sin implementar"
 
-#: vms-alpha.c:2206
+#: vms-alpha.c:2218
 #, c-format
 msgid "invalid use of %s with contexts"
 msgstr "uso inválido de %s en contextos"
 
-#: vms-alpha.c:2240
+#: vms-alpha.c:2252
 #, c-format
 msgid "reserved cmd %d"
 msgstr "orden %d reservada"
 
-#: vms-alpha.c:2325
+#: vms-alpha.c:2337
 msgid "Object module NOT error-free !\n"
 msgstr "¡ El módulo objeto NO está libre de errores !\n"
 
-#: vms-alpha.c:2754
+#: vms-alpha.c:2766
 #, c-format
 msgid "Symbol %s replaced by %s\n"
 msgstr "Se reemplazó el símbolo %s por %s\n"
 
-#: vms-alpha.c:3757
+#: vms-alpha.c:3769
 #, c-format
 msgid "SEC_RELOC with no relocs in section %s"
 msgstr "SEC_RELOC sin reubicaciones en la sección %s"
 
-#: vms-alpha.c:3810 vms-alpha.c:4041
+#: vms-alpha.c:3822 vms-alpha.c:4049
 #, c-format
 msgid "Size error in section %s"
 msgstr "Error de tamaño en la sección %s"
 
-#: vms-alpha.c:3980
+#: vms-alpha.c:3991
 msgid "Spurious ALPHA_R_BSR reloc"
 msgstr "Reubicación ALPHA_R_BSR espuria"
 
-#: vms-alpha.c:4028
+#: vms-alpha.c:4036
 #, c-format
 msgid "Unhandled relocation %s"
 msgstr "Reubicación %s sin manejar"
 
-#: vms-alpha.c:4318
+#: vms-alpha.c:4326
 #, c-format
 msgid "unknown source command %d"
 msgstr "orden fuente %d desconocida"
 
-#: vms-alpha.c:4379
+#: vms-alpha.c:4387
 msgid "DST__K_SET_LINUM_INCR not implemented"
 msgstr "DST__K_SET_LINUM_INCR sin implementar"
 
-#: vms-alpha.c:4385
+#: vms-alpha.c:4393
 msgid "DST__K_SET_LINUM_INCR_W not implemented"
 msgstr "DST__K_SET_LINUM_INCR_W sin implementar"
 
-#: vms-alpha.c:4391
+#: vms-alpha.c:4399
 msgid "DST__K_RESET_LINUM_INCR not implemented"
 msgstr "DST__K_RESET_LINUM_INCR sin implementar"
 
-#: vms-alpha.c:4397
+#: vms-alpha.c:4405
 msgid "DST__K_BEG_STMT_MODE not implemented"
 msgstr "DST__K_BEG_STMT_MODE sin implementar"
 
-#: vms-alpha.c:4403
+#: vms-alpha.c:4411
 msgid "DST__K_END_STMT_MODE not implemented"
 msgstr "DST__K_END_STMT_MODE sin implementar"
 
-#: vms-alpha.c:4430
+#: vms-alpha.c:4438
 msgid "DST__K_SET_PC not implemented"
 msgstr "DST__K_SET_PC sin implementar"
 
-#: vms-alpha.c:4436
+#: vms-alpha.c:4444
 msgid "DST__K_SET_PC_W not implemented"
 msgstr "DST__K_SET_PC_W sin implementar"
 
-#: vms-alpha.c:4442
+#: vms-alpha.c:4450
 msgid "DST__K_SET_PC_L not implemented"
 msgstr "DST__K_SET_PC_L sin implementar"
 
-#: vms-alpha.c:4448
+#: vms-alpha.c:4456
 msgid "DST__K_SET_STMTNUM not implemented"
 msgstr "DST__K_SET_STMTNUM sin implementar"
 
-#: vms-alpha.c:4491
+#: vms-alpha.c:4499
 #, c-format
 msgid "unknown line command %d"
 msgstr "orden de línea %d desconocida"
 
-#: vms-alpha.c:4938 vms-alpha.c:4955 vms-alpha.c:4969 vms-alpha.c:4984
-#: vms-alpha.c:4996 vms-alpha.c:5007 vms-alpha.c:5019
+#: vms-alpha.c:4953 vms-alpha.c:4970 vms-alpha.c:4984 vms-alpha.c:4999
+#: vms-alpha.c:5011 vms-alpha.c:5022 vms-alpha.c:5034
 #, c-format
 msgid "Unknown reloc %s + %s"
 msgstr "Reubicación %s + %s desconocida"
 
-#: vms-alpha.c:5074
+#: vms-alpha.c:5089
 #, c-format
 msgid "Unknown reloc %s"
 msgstr "Reubicación %s desconocida"
 
-#: vms-alpha.c:5087
+#: vms-alpha.c:5102
 msgid "Invalid section index in ETIR"
 msgstr "Índice de sección inválido en ETIR"
 
-#: vms-alpha.c:5134
+#: vms-alpha.c:5109
+msgid "Relocation for non-REL psect"
+msgstr "Reubicación para psect que no es REL"
+
+#: vms-alpha.c:5156
 #, c-format
 msgid "Unknown symbol in command %s"
 msgstr "Símbolo desconocido en la orden %s"
 
-#: vms-alpha.c:5649
+#: vms-alpha.c:5671
 #, c-format
 msgid "  EMH %u (len=%u): "
 msgstr "  EMH %u (lon=%u): "
 
-#: vms-alpha.c:5658
+#: vms-alpha.c:5680
 #, c-format
 msgid "Module header\n"
 msgstr "Encabezado de módulo\n"
 
-#: vms-alpha.c:5659
+#: vms-alpha.c:5681
 #, c-format
 msgid "   structure level: %u\n"
 msgstr "   nivel estruct  : %u\n"
 
-#: vms-alpha.c:5660
+#: vms-alpha.c:5682
 #, c-format
 msgid "   max record size: %u\n"
 msgstr "   tam reg máximo : %u\n"
 
-#: vms-alpha.c:5663
+#: vms-alpha.c:5685
 #, c-format
 msgid "   module name    : %.*s\n"
 msgstr "   nombre módulo  : %.*s\n"
 
-#: vms-alpha.c:5665
+#: vms-alpha.c:5687
 #, c-format
 msgid "   module version : %.*s\n"
 msgstr "   versión módulo : %.*s\n"
 
-#: vms-alpha.c:5667
+#: vms-alpha.c:5689
 #, c-format
 msgid "   compile date   : %.17s\n"
 msgstr "   fecha compil   : %.17s\n"
 
-#: vms-alpha.c:5672
+#: vms-alpha.c:5694
 #, c-format
 msgid "Language Processor Name\n"
 msgstr "Nombre de Procesador de Lenguaje\n"
 
-#: vms-alpha.c:5673
+#: vms-alpha.c:5695
 #, c-format
 msgid "   language name: %.*s\n"
 msgstr "   nombre lenguaje: %.*s\n"
 
-#: vms-alpha.c:5680
+#: vms-alpha.c:5702
 #, c-format
 msgid "Source Files Header\n"
 msgstr "Encabezado de Ficheros Fuente\n"
 
-#: vms-alpha.c:5681
+#: vms-alpha.c:5703
 #, c-format
 msgid "   file: %.*s\n"
 msgstr "   fichero: %.*s\n"
 
-#: vms-alpha.c:5688
+#: vms-alpha.c:5710
 #, c-format
 msgid "Title Text Header\n"
 msgstr "Encabezado de Texto de Título\n"
 
-#: vms-alpha.c:5689
+#: vms-alpha.c:5711
 #, c-format
 msgid "   title: %.*s\n"
 msgstr "   título: %.*s\n"
 
-#: vms-alpha.c:5696
+#: vms-alpha.c:5718
 #, c-format
 msgid "Copyright Header\n"
 msgstr "Encabezado de Copyright\n"
 
-#: vms-alpha.c:5697
+#: vms-alpha.c:5719
 #, c-format
 msgid "   copyright: %.*s\n"
 msgstr "   copyright: %.*s\n"
 
-#: vms-alpha.c:5703
+#: vms-alpha.c:5725
 #, c-format
 msgid "unhandled emh subtype %u\n"
 msgstr "subtipo emh %u sin manejar\n"
 
-#: vms-alpha.c:5713
+#: vms-alpha.c:5735
 #, c-format
 msgid "  EEOM (len=%u):\n"
 msgstr "  EEOM (lon=%u):\n"
 
-#: vms-alpha.c:5714
+#: vms-alpha.c:5736
 #, c-format
 msgid "   number of cond linkage pairs: %u\n"
 msgstr "   número de pares de enlace cond: %u\n"
 
-#: vms-alpha.c:5716
+#: vms-alpha.c:5738
 #, c-format
 msgid "   completion code: %u\n"
 msgstr "   código de completado: %u\n"
 
-#: vms-alpha.c:5720
+#: vms-alpha.c:5742
 #, c-format
 msgid "   transfer addr flags: 0x%02x\n"
 msgstr "   ops dirección transf: 0x%02x\n"
 
-#: vms-alpha.c:5721
+#: vms-alpha.c:5743
 #, c-format
 msgid "   transfer addr psect: %u\n"
 msgstr "   psect dirección transf: %u\n"
 
-#: vms-alpha.c:5723
+#: vms-alpha.c:5745
 #, c-format
 msgid "   transfer address   : 0x%08x\n"
 msgstr "   dirección transf   : 0x%08x\n"
 
-#: vms-alpha.c:5732
+#: vms-alpha.c:5754
 msgid " WEAK"
 msgstr " WEAK"
 
-#: vms-alpha.c:5734
+#: vms-alpha.c:5756
 msgid " DEF"
 msgstr " DEF"
 
-#: vms-alpha.c:5736
+#: vms-alpha.c:5758
 msgid " UNI"
 msgstr " UNI"
 
-#: vms-alpha.c:5738 vms-alpha.c:5759
+#: vms-alpha.c:5760 vms-alpha.c:5781
 msgid " REL"
 msgstr " REL"
 
-#: vms-alpha.c:5740
+#: vms-alpha.c:5762
 msgid " COMM"
 msgstr " COMM"
 
-#: vms-alpha.c:5742
+#: vms-alpha.c:5764
 msgid " VECEP"
 msgstr " VECEP"
 
-#: vms-alpha.c:5744
+#: vms-alpha.c:5766
 msgid " NORM"
 msgstr " NORM"
 
-#: vms-alpha.c:5746
+#: vms-alpha.c:5768
 msgid " QVAL"
 msgstr " QVAL"
 
-#: vms-alpha.c:5753
+#: vms-alpha.c:5775
 msgid " PIC"
 msgstr " PIC"
 
-#: vms-alpha.c:5755
+#: vms-alpha.c:5777
 msgid " LIB"
 msgstr " LIB"
 
-#: vms-alpha.c:5757
+#: vms-alpha.c:5779
 msgid " OVR"
 msgstr " OVR"
 
-#: vms-alpha.c:5761
+#: vms-alpha.c:5783
 msgid " GBL"
 msgstr " GBL"
 
-#: vms-alpha.c:5763
+#: vms-alpha.c:5785
 msgid " SHR"
 msgstr " SHR"
 
-#: vms-alpha.c:5765
+#: vms-alpha.c:5787
 msgid " EXE"
 msgstr " EXE"
 
-#: vms-alpha.c:5767
+#: vms-alpha.c:5789
 msgid " RD"
 msgstr " RD"
 
-#: vms-alpha.c:5769
+#: vms-alpha.c:5791
 msgid " WRT"
 msgstr " WRT"
 
-#: vms-alpha.c:5771
+#: vms-alpha.c:5793
 msgid " VEC"
 msgstr " VEC"
 
-#: vms-alpha.c:5773
+#: vms-alpha.c:5795
 msgid " NOMOD"
 msgstr " NOMOD"
 
-#: vms-alpha.c:5775
+#: vms-alpha.c:5797
 msgid " COM"
 msgstr " COM"
 
-#: vms-alpha.c:5777
+#: vms-alpha.c:5799
 msgid " 64B"
 msgstr " 64B"
 
-#: vms-alpha.c:5786
+#: vms-alpha.c:5808
 #, c-format
 msgid "  EGSD (len=%u):\n"
 msgstr "  EGSD (lon=%u):\n"
 
-#: vms-alpha.c:5798
+#: vms-alpha.c:5820
 #, c-format
 msgid "  EGSD entry %2u (type: %u, len: %u): "
 msgstr " entrada EGSD %2u (tipo: %u, lon: %u): "
 
-#: vms-alpha.c:5810
+#: vms-alpha.c:5832
 #, c-format
 msgid "PSC - Program section definition\n"
 msgstr "PSC - Definición de sección de programa\n"
 
-#: vms-alpha.c:5811 vms-alpha.c:5828
+#: vms-alpha.c:5833 vms-alpha.c:5850
 #, c-format
 msgid "   alignment  : 2**%u\n"
 msgstr "   alineación : 2**%u\n"
 
-#: vms-alpha.c:5812 vms-alpha.c:5829
+#: vms-alpha.c:5834 vms-alpha.c:5851
 #, c-format
 msgid "   flags      : 0x%04x"
 msgstr "   opciones   : 0x%04x"
 
-#: vms-alpha.c:5816
+#: vms-alpha.c:5838
 #, c-format
 msgid "   alloc (len): %u (0x%08x)\n"
 msgstr "   aloj (lon) : %u (0x%08x)\n"
 
-#: vms-alpha.c:5817 vms-alpha.c:5874 vms-alpha.c:5923
+#: vms-alpha.c:5839 vms-alpha.c:5896 vms-alpha.c:5945
 #, c-format
 msgid "   name       : %.*s\n"
 msgstr "   nombre     : %.*s\n"
 
-#: vms-alpha.c:5827
+#: vms-alpha.c:5849
 #, c-format
 msgid "SPSC - Shared Image Program section def\n"
 msgstr "SPSC - def sección Programa de Imagen Compartida\n"
 
-#: vms-alpha.c:5833
+#: vms-alpha.c:5855
 #, c-format
 msgid "   alloc (len)   : %u (0x%08x)\n"
 msgstr "   aloj (lon)    : %u (0x%08x)\n"
 
-#: vms-alpha.c:5834
+#: vms-alpha.c:5856
 #, c-format
 msgid "   image offset  : 0x%08x\n"
 msgstr "   despl imagen  : 0x%08x\n"
 
-#: vms-alpha.c:5836
+#: vms-alpha.c:5858
 #, c-format
 msgid "   symvec offset : 0x%08x\n"
 msgstr "   despl symvec  : 0x%08x\n"
 
-#: vms-alpha.c:5838
+#: vms-alpha.c:5860
 #, c-format
 msgid "   name          : %.*s\n"
 msgstr "   name          : %.*s\n"
 
-#: vms-alpha.c:5851
+#: vms-alpha.c:5873
 #, c-format
 msgid "SYM - Global symbol definition\n"
 msgstr "SYM - Definición de símbolo global\n"
 
-#: vms-alpha.c:5852 vms-alpha.c:5912 vms-alpha.c:5933 vms-alpha.c:5952
+#: vms-alpha.c:5874 vms-alpha.c:5934 vms-alpha.c:5955 vms-alpha.c:5974
 #, c-format
 msgid "   flags: 0x%04x"
 msgstr "   opciones: 0x%04x"
 
-#: vms-alpha.c:5855
+#: vms-alpha.c:5877
 #, c-format
 msgid "   psect offset: 0x%08x\n"
 msgstr "   despl psect: 0x%08x\n"
 
-#: vms-alpha.c:5859
+#: vms-alpha.c:5881
 #, c-format
 msgid "   code address: 0x%08x\n"
 msgstr "   dirección código: 0x%08x\n"
 
-#: vms-alpha.c:5861
+#: vms-alpha.c:5883
 #, c-format
 msgid "   psect index for entry point : %u\n"
 msgstr "   índice psect para punto de entrada : %u\n"
 
-#: vms-alpha.c:5864 vms-alpha.c:5940 vms-alpha.c:5959
+#: vms-alpha.c:5886 vms-alpha.c:5962 vms-alpha.c:5981
 #, c-format
 msgid "   psect index : %u\n"
 msgstr "   índice psect : %u\n"
 
-#: vms-alpha.c:5866 vms-alpha.c:5942 vms-alpha.c:5961
+#: vms-alpha.c:5888 vms-alpha.c:5964 vms-alpha.c:5983
 #, c-format
 msgid "   name        : %.*s\n"
 msgstr "   nombre      : %.*s\n"
 
-#: vms-alpha.c:5873
+#: vms-alpha.c:5895
 #, c-format
 msgid "SYM - Global symbol reference\n"
 msgstr "SYM - Referencia de símbolo global\n"
 
-#: vms-alpha.c:5885
+#: vms-alpha.c:5907
 #, c-format
 msgid "IDC - Ident Consistency check\n"
 msgstr "IDC - Revisor de Consistencia de Identación\n"
 
-#: vms-alpha.c:5886
+#: vms-alpha.c:5908
 #, c-format
 msgid "   flags         : 0x%08x"
 msgstr "   opciones      : 0x%08x"
 
-#: vms-alpha.c:5890
+#: vms-alpha.c:5912
 #, c-format
 msgid "   id match      : %x\n"
 msgstr "   coinc id      : %x\n"
 
-#: vms-alpha.c:5892
+#: vms-alpha.c:5914
 #, c-format
 msgid "   error severity: %x\n"
 msgstr "   severidad err : %x\n"
 
-#: vms-alpha.c:5895
+#: vms-alpha.c:5917
 #, c-format
 msgid "   entity name   : %.*s\n"
 msgstr "   nombre entidad: %.*s\n"
 
-#: vms-alpha.c:5897
+#: vms-alpha.c:5919
 #, c-format
 msgid "   object name   : %.*s\n"
 msgstr "   nombre objeto : %.*s\n"
 
-#: vms-alpha.c:5900
+#: vms-alpha.c:5922
 #, c-format
 msgid "   binary ident  : 0x%08x\n"
 msgstr "   ident binaria : 0x%08x\n"
 
-#: vms-alpha.c:5903
+#: vms-alpha.c:5925
 #, c-format
 msgid "   ascii ident   : %.*s\n"
 msgstr "   ident ascii   : %.*s\n"
 
-#: vms-alpha.c:5911
+#: vms-alpha.c:5933
 #, c-format
 msgid "SYMG - Universal symbol definition\n"
 msgstr "SYMG - Definición de símbolo universal\n"
 
-#: vms-alpha.c:5915
+#: vms-alpha.c:5937
 #, c-format
 msgid "   symbol vector offset: 0x%08x\n"
 msgstr "   despl vector símbolo: 0x%08x\n"
 
-#: vms-alpha.c:5917
+#: vms-alpha.c:5939
 #, c-format
 msgid "   entry point: 0x%08x\n"
 msgstr "   punto de entrada: 0x%08x\n"
 
-#: vms-alpha.c:5919
+#: vms-alpha.c:5941
 #, c-format
 msgid "   proc descr : 0x%08x\n"
 msgstr "   descr proc : 0x%08x\n"
 
-#: vms-alpha.c:5921
+#: vms-alpha.c:5943
 #, c-format
 msgid "   psect index: %u\n"
 msgstr "   índice psect: %u\n"
 
-#: vms-alpha.c:5932
+#: vms-alpha.c:5954
 #, c-format
 msgid "SYMV - Vectored symbol definition\n"
 msgstr "SYMV - Definición de símbolo vectorizado\n"
 
-#: vms-alpha.c:5936
+#: vms-alpha.c:5958
 #, c-format
 msgid "   vector      : 0x%08x\n"
 msgstr "   vector      : 0x%08x\n"
 
-#: vms-alpha.c:5938 vms-alpha.c:5957
+#: vms-alpha.c:5960 vms-alpha.c:5979
 #, c-format
 msgid "   psect offset: %u\n"
 msgstr "   despl psect : %u\n"
 
-#: vms-alpha.c:5951
+#: vms-alpha.c:5973
 #, c-format
 msgid "SYMM - Global symbol definition with version\n"
 msgstr "SYMM - Definición de símbolo global con versión\n"
 
-#: vms-alpha.c:5955
+#: vms-alpha.c:5977
 #, c-format
 msgid "   version mask: 0x%08x\n"
 msgstr "   máscara versión: 0x%08x\n"
 
-#: vms-alpha.c:5966
+#: vms-alpha.c:5988
 #, c-format
 msgid "unhandled egsd entry type %u\n"
 msgstr "tipo de entrada egsd %u sin manejar\n"
 
-#: vms-alpha.c:6000
+#: vms-alpha.c:6022
 #, c-format
 msgid "    linkage index: %u, replacement insn: 0x%08x\n"
 msgstr "    índice enlace: %u, insn reemplazo: 0x%08x\n"
 
-#: vms-alpha.c:6003
+#: vms-alpha.c:6025
 #, c-format
 msgid "    psect idx 1: %u, offset 1: 0x%08x %08x\n"
 msgstr "    ind psect 1: %u, despl 1: 0x%08x %08x\n"
 
-#: vms-alpha.c:6007
+#: vms-alpha.c:6029
 #, c-format
 msgid "    psect idx 2: %u, offset 2: 0x%08x %08x\n"
 msgstr "    ind psect 2: %u, despl 2: 0x%08x %08x\n"
 
-#: vms-alpha.c:6012
+#: vms-alpha.c:6034
 #, c-format
 msgid "    psect idx 3: %u, offset 3: 0x%08x %08x\n"
 msgstr "    ind psect 3: %u, despl 3: 0x%08x %08x\n"
 
-#: vms-alpha.c:6017
+#: vms-alpha.c:6039
 #, c-format
 msgid "    global name: %.*s\n"
 msgstr "    nombre global: %.*s\n"
 
-#: vms-alpha.c:6027
+#: vms-alpha.c:6049
 #, c-format
 msgid "  %s (len=%u+%u):\n"
 msgstr "  %s (lon=%u+%u):\n"
 
-#: vms-alpha.c:6042
+#: vms-alpha.c:6064
 #, c-format
 msgid "   (type: %3u, size: 4+%3u): "
 msgstr "   (tipo: %3u, tam: 4+%3u): "
 
-#: vms-alpha.c:6046
+#: vms-alpha.c:6068
 #, c-format
 msgid "STA_GBL (stack global) %.*s\n"
 msgstr "STA_GBL (pila global) %.*s\n"
 
-#: vms-alpha.c:6050
+#: vms-alpha.c:6072
 #, c-format
 msgid "STA_LW (stack longword) 0x%08x\n"
 msgstr "STA_LW (pila longword) 0x%08x\n"
 
-#: vms-alpha.c:6054
+#: vms-alpha.c:6076
 #, c-format
 msgid "STA_QW (stack quadword) 0x%08x %08x\n"
 msgstr "STA_QW (pila quadword) 0x%08x %08x\n"
 
-#: vms-alpha.c:6059
+#: vms-alpha.c:6081
 #, c-format
 msgid "STA_PQ (stack psect base + offset)\n"
 msgstr "STA_PQ (pila psect base + despl)\n"
 
-#: vms-alpha.c:6060
+#: vms-alpha.c:6082
 #, c-format
 msgid "    psect: %u, offset: 0x%08x %08x\n"
 msgstr "    psect: %u, despl: 0x%08x %08x\n"
 
-#: vms-alpha.c:6066
+#: vms-alpha.c:6088
 #, c-format
 msgid "STA_LI (stack literal)\n"
 msgstr "STA_LI (pila literal)\n"
 
-#: vms-alpha.c:6069
+#: vms-alpha.c:6091
 #, c-format
 msgid "STA_MOD (stack module)\n"
 msgstr "STA_MOD (pila módulo)\n"
 
-#: vms-alpha.c:6072
+#: vms-alpha.c:6094
 #, c-format
 msgid "STA_CKARG (compare procedure argument)\n"
 msgstr "STA_CKARG (compara argumentos de procedimientos)\n"
 
-#: vms-alpha.c:6076
+#: vms-alpha.c:6098
 #, c-format
 msgid "STO_B (store byte)\n"
 msgstr "STO_B (almacena byte)\n"
 
-#: vms-alpha.c:6079
+#: vms-alpha.c:6101
 #, c-format
 msgid "STO_W (store word)\n"
 msgstr "STO_W (almacena word)\n"
 
-#: vms-alpha.c:6082
+#: vms-alpha.c:6104
 #, c-format
 msgid "STO_LW (store longword)\n"
 msgstr "STO_LW (almacena longword)\n"
 
-#: vms-alpha.c:6085
+#: vms-alpha.c:6107
 #, c-format
 msgid "STO_QW (store quadword)\n"
 msgstr "STO_QW (almacena quadword)\n"
 
-#: vms-alpha.c:6091
+#: vms-alpha.c:6113
 #, c-format
 msgid "STO_IMMR (store immediate repeat) %u bytes\n"
 msgstr "STO_IMMR (almacena inmediato repetido) %u bytes\n"
 
-#: vms-alpha.c:6098
+#: vms-alpha.c:6120
 #, c-format
 msgid "STO_GBL (store global) %.*s\n"
 msgstr "STO_GBL (almacena global) %.*s\n"
 
-#: vms-alpha.c:6102
+#: vms-alpha.c:6124
 #, c-format
 msgid "STO_CA (store code address) %.*s\n"
 msgstr "STO_CA (almacena direcc código) %.*s\n"
 
-#: vms-alpha.c:6106
+#: vms-alpha.c:6128
 #, c-format
 msgid "STO_RB (store relative branch)\n"
 msgstr "STO_RB (almacena ramif relativa)\n"
 
-#: vms-alpha.c:6109
+#: vms-alpha.c:6131
 #, c-format
 msgid "STO_AB (store absolute branch)\n"
 msgstr "STO_AB (almacena ramif absoluta)\n"
 
-#: vms-alpha.c:6112
+#: vms-alpha.c:6134
 #, c-format
 msgid "STO_OFF (store offset to psect)\n"
 msgstr "STO_OFF (almacena despl para psect)\n"
 
-#: vms-alpha.c:6118
+#: vms-alpha.c:6140
 #, c-format
 msgid "STO_IMM (store immediate) %u bytes\n"
 msgstr "STO_IMM (almacena inmediato) %u bytes\n"
 
-#: vms-alpha.c:6125
+#: vms-alpha.c:6147
 #, c-format
 msgid "STO_GBL_LW (store global longword) %.*s\n"
 msgstr "STO_GBL_LW (almacena global longword) %.*s\n"
 
-#: vms-alpha.c:6129
+#: vms-alpha.c:6151
 #, c-format
 msgid "STO_OFF (store LP with procedure signature)\n"
 msgstr "STO_OFF (almacena LP con firma de procedimiento)\n"
 
-#: vms-alpha.c:6132
+#: vms-alpha.c:6154
 #, c-format
 msgid "STO_BR_GBL (store branch global) *todo*\n"
 msgstr "STO_BR_GBL (almacena ramif global) *pend*\n"
 
-#: vms-alpha.c:6135
+#: vms-alpha.c:6157
 #, c-format
 msgid "STO_BR_PS (store branch psect + offset) *todo*\n"
 msgstr "STO_BR_PS (almacena ramif psect + despl) *pend*\n"
 
-#: vms-alpha.c:6139
+#: vms-alpha.c:6161
 #, c-format
 msgid "OPR_NOP (no-operation)\n"
 msgstr "OPR_NOP (no operación)\n"
 
-#: vms-alpha.c:6142
+#: vms-alpha.c:6164
 #, c-format
 msgid "OPR_ADD (add)\n"
 msgstr "OPR_ADD (adición)\n"
 
-#: vms-alpha.c:6145
+#: vms-alpha.c:6167
 #, c-format
 msgid "OPR_SUB (substract)\n"
 msgstr "OPR_SUB (sustracción)\n"
 
-#: vms-alpha.c:6148
+#: vms-alpha.c:6170
 #, c-format
 msgid "OPR_MUL (multiply)\n"
 msgstr "OPR_MUL (multiplicación)\n"
 
-#: vms-alpha.c:6151
+#: vms-alpha.c:6173
 #, c-format
 msgid "OPR_DIV (divide)\n"
 msgstr "OPR_DIV (división)\n"
 
-#: vms-alpha.c:6154
+#: vms-alpha.c:6176
 #, c-format
 msgid "OPR_AND (logical and)\n"
 msgstr "OPR_AND (and lógico)\n"
 
-#: vms-alpha.c:6157
+#: vms-alpha.c:6179
 #, c-format
 msgid "OPR_IOR (logical inclusive or)\n"
 msgstr "OPR_IOR (or lógico inclusivo)\n"
 
-#: vms-alpha.c:6160
+#: vms-alpha.c:6182
 #, c-format
 msgid "OPR_EOR (logical exclusive or)\n"
 msgstr "OPR_EOR (or lógico exclusivo)\n"
 
-#: vms-alpha.c:6163
+#: vms-alpha.c:6185
 #, c-format
 msgid "OPR_NEG (negate)\n"
 msgstr "OPR_NEG (negación)\n"
 
-#: vms-alpha.c:6166
+#: vms-alpha.c:6188
 #, c-format
 msgid "OPR_COM (complement)\n"
 msgstr "OPR_COM (complemento)\n"
 
-#: vms-alpha.c:6169
+#: vms-alpha.c:6191
 #, c-format
 msgid "OPR_INSV (insert field)\n"
 msgstr "OPR_INSV (insertar campo)\n"
 
-#: vms-alpha.c:6172
+#: vms-alpha.c:6194
 #, c-format
 msgid "OPR_ASH (arithmetic shift)\n"
 msgstr "OPR_ASH (despl aritmético)\n"
 
-#: vms-alpha.c:6175
+#: vms-alpha.c:6197
 #, c-format
 msgid "OPR_USH (unsigned shift)\n"
 msgstr "OPR_USH (despl sin signo)\n"
 
-#: vms-alpha.c:6178
+#: vms-alpha.c:6200
 #, c-format
 msgid "OPR_ROT (rotate)\n"
 msgstr "OPR_ROT (rotación)\n"
 
-#: vms-alpha.c:6181
+#: vms-alpha.c:6203
 #, c-format
 msgid "OPR_SEL (select)\n"
 msgstr "OPR_SEL (selección)\n"
 
-#: vms-alpha.c:6184
+#: vms-alpha.c:6206
 #, c-format
 msgid "OPR_REDEF (redefine symbol to curr location)\n"
 msgstr "OPR_REDEF (redefine símbolo a la ubicación actual)\n"
 
-#: vms-alpha.c:6187
+#: vms-alpha.c:6209
 #, c-format
 msgid "OPR_REDEF (define a literal)\n"
 msgstr "OPR_REDEF (define una literal)\n"
 
-#: vms-alpha.c:6191
+#: vms-alpha.c:6213
 #, c-format
 msgid "STC_LP (store cond linkage pair)\n"
 msgstr "STC_LP (almacena par de enlace cond)\n"
 
-#: vms-alpha.c:6195
+#: vms-alpha.c:6217
 #, c-format
 msgid "STC_LP_PSB (store cond linkage pair + signature)\n"
 msgstr "STC_LP_PSB (almacena par de enlace cond + firma)\n"
 
-#: vms-alpha.c:6196
+#: vms-alpha.c:6218
 #, c-format
 msgid "   linkage index: %u, procedure: %.*s\n"
 msgstr "   índice enlace: %u, procedimiento: %.*s\n"
 
-#: vms-alpha.c:6199
+#: vms-alpha.c:6221
 #, c-format
 msgid "   signature: %.*s\n"
 msgstr "   firma: %.*s\n"
 
-#: vms-alpha.c:6202
+#: vms-alpha.c:6224
 #, c-format
 msgid "STC_GBL (store cond global)\n"
 msgstr "STC_GBL (almacena cond global)\n"
 
-#: vms-alpha.c:6203
+#: vms-alpha.c:6225
 #, c-format
 msgid "   linkage index: %u, global: %.*s\n"
 msgstr "   índice enlace: %u, global: %.*s\n"
 
-#: vms-alpha.c:6207
+#: vms-alpha.c:6229
 #, c-format
 msgid "STC_GCA (store cond code address)\n"
 msgstr "STC_GCA (almacena dirección de código cond)\n"
 
-#: vms-alpha.c:6208
+#: vms-alpha.c:6230
 #, c-format
 msgid "   linkage index: %u, procedure name: %.*s\n"
 msgstr "   índice enlace: %u, nombre procedimiento: %.*s\n"
 
-#: vms-alpha.c:6212
+#: vms-alpha.c:6234
 #, c-format
 msgid "STC_PS (store cond psect + offset)\n"
 msgstr "STC_PS (almacena psect cond + despl)\n"
 
-#: vms-alpha.c:6214
+#: vms-alpha.c:6236
 #, c-format
 msgid "   linkage index: %u, psect: %u, offset: 0x%08x %08x\n"
 msgstr "   índice enlace: %u, psect: %u, despl: 0x%08x %08x\n"
 
-#: vms-alpha.c:6221
+#: vms-alpha.c:6243
 #, c-format
 msgid "STC_NOP_GBL (store cond NOP at global addr)\n"
 msgstr "STC_NOP_GBL (almacena NOP cond en dirección global)\n"
 
-#: vms-alpha.c:6225
+#: vms-alpha.c:6247
 #, c-format
 msgid "STC_NOP_PS (store cond NOP at psect + offset)\n"
 msgstr "STC_NOP_PS (almacena NOP cond en psect + despl)\n"
 
-#: vms-alpha.c:6229
+#: vms-alpha.c:6251
 #, c-format
 msgid "STC_BSR_GBL (store cond BSR at global addr)\n"
 msgstr "STC_BSR_GBL (almacena BSR cond en dirección global)\n"
 
-#: vms-alpha.c:6233
+#: vms-alpha.c:6255
 #, c-format
 msgid "STC_BSR_PS (store cond BSR at psect + offset)\n"
 msgstr "STC_BSR_PS (almacena BSR cond en psect + despl)\n"
 
-#: vms-alpha.c:6237
+#: vms-alpha.c:6259
 #, c-format
 msgid "STC_LDA_GBL (store cond LDA at global addr)\n"
 msgstr "STC_LDA_GBL (almacena LDA cond en dirección global)\n"
 
-#: vms-alpha.c:6241
+#: vms-alpha.c:6263
 #, c-format
 msgid "STC_LDA_PS (store cond LDA at psect + offset)\n"
 msgstr "STC_LDA_PS (almacena LDA cond en psect + despl)\n"
 
-#: vms-alpha.c:6245
+#: vms-alpha.c:6267
 #, c-format
 msgid "STC_BOH_GBL (store cond BOH at global addr)\n"
 msgstr "STC_BOH_GBL (almacena BOH cond en dirección global)\n"
 
-#: vms-alpha.c:6249
+#: vms-alpha.c:6271
 #, c-format
 msgid "STC_BOH_PS (store cond BOH at psect + offset)\n"
 msgstr "STC_BOH_PS (almacena BOH cond en psect + despl)\n"
 
-#: vms-alpha.c:6254
+#: vms-alpha.c:6276
 #, c-format
 msgid "STC_NBH_GBL (store cond or hint at global addr)\n"
 msgstr "STC_NBH_GBL (almacena cond o pista en dirección global)\n"
 
-#: vms-alpha.c:6258
+#: vms-alpha.c:6280
 #, c-format
 msgid "STC_NBH_PS (store cond or hint at psect + offset)\n"
 msgstr "STC_NBH_PS (almacena cond o pista en psect + despl)\n"
 
-#: vms-alpha.c:6262
+#: vms-alpha.c:6284
 #, c-format
 msgid "CTL_SETRB (set relocation base)\n"
 msgstr "CTL_SETRB (define base de reubicación)\n"
 
-#: vms-alpha.c:6268
+#: vms-alpha.c:6290
 #, c-format
 msgid "CTL_AUGRB (augment relocation base) %u\n"
 msgstr "CTL_AUGRB (aumenta base de reubicación) %u\n"
 
-#: vms-alpha.c:6272
+#: vms-alpha.c:6294
 #, c-format
 msgid "CTL_DFLOC (define location)\n"
 msgstr "CTL_DFLOC (define ubicación)\n"
 
-#: vms-alpha.c:6275
+#: vms-alpha.c:6297
 #, c-format
 msgid "CTL_STLOC (set location)\n"
 msgstr "CTL_STLOC (establece ubicación)\n"
 
-#: vms-alpha.c:6278
+#: vms-alpha.c:6300
 #, c-format
 msgid "CTL_STKDL (stack defined location)\n"
 msgstr "CTL_STKDL (ubicación definida de pila)\n"
 
-#: vms-alpha.c:6281 vms-alpha.c:6695
+#: vms-alpha.c:6303 vms-alpha.c:6717
 #, c-format
 msgid "*unhandled*\n"
 msgstr "*sin manejar*\n"
 
-#: vms-alpha.c:6311 vms-alpha.c:6350
+#: vms-alpha.c:6333 vms-alpha.c:6372
 #, c-format
 msgid "cannot read GST record length\n"
 msgstr "no se puede leer la longitud del registro GST\n"
 
 #. Ill-formed.
-#: vms-alpha.c:6332
+#: vms-alpha.c:6354
 #, c-format
 msgid "cannot find EMH in first GST record\n"
 msgstr "no se puede encontrar EMH en el primer registro GST\n"
 
-#: vms-alpha.c:6358
+#: vms-alpha.c:6380
 #, c-format
 msgid "cannot read GST record header\n"
 msgstr "no se puede leer el encabezado del registro GST\n"
 
-#: vms-alpha.c:6371
+#: vms-alpha.c:6393
 #, c-format
 msgid " corrupted GST\n"
 msgstr " GST corrupto\n"
 
-#: vms-alpha.c:6379
+#: vms-alpha.c:6401
 #, c-format
 msgid "cannot read GST record\n"
 msgstr "no se puede leer el registro GST\n"
 
-#: vms-alpha.c:6408
+#: vms-alpha.c:6430
 #, c-format
 msgid " unhandled EOBJ record type %u\n"
 msgstr " tipo de registro EOBJ %u sin manejar\n"
 
-#: vms-alpha.c:6431
+#: vms-alpha.c:6453
 #, c-format
 msgid "  bitcount: %u, base addr: 0x%08x\n"
 msgstr "  cuenta bit: %u, direcc base: 0x%08x\n"
 
-#: vms-alpha.c:6444
+#: vms-alpha.c:6466
 #, c-format
 msgid "   bitmap: 0x%08x (count: %u):\n"
 msgstr "   mapa bit: 0x%08x (cuenta: %u):\n"
 
-#: vms-alpha.c:6451
+#: vms-alpha.c:6473
 #, c-format
 msgid " %08x"
 msgstr " %08x"
 
-#: vms-alpha.c:6476
+#: vms-alpha.c:6498
 #, c-format
 msgid "  image %u (%u entries)\n"
 msgstr "  imagen %u (%u entradas)\n"
 
-#: vms-alpha.c:6481
+#: vms-alpha.c:6503
 #, c-format
 msgid "   offset: 0x%08x, val: 0x%08x\n"
 msgstr "   despl: 0x%08x, val: 0x%08x\n"
 
-#: vms-alpha.c:6502
+#: vms-alpha.c:6524
 #, c-format
 msgid "  image %u (%u entries), offsets:\n"
 msgstr " imagen %u (%u entradas), desplazamientos:\n"
 
-#: vms-alpha.c:6509
+#: vms-alpha.c:6531
 #, c-format
 msgid " 0x%08x"
 msgstr " 0x%08x"
 
 #. 64 bits.
-#: vms-alpha.c:6631
+#: vms-alpha.c:6653
 #, c-format
 msgid "64 bits *unhandled*\n"
 msgstr "64 bits *sin manejar*\n"
 
-#: vms-alpha.c:6635
+#: vms-alpha.c:6657
 #, c-format
 msgid "class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"
 msgstr "clase: %u, tipod: %u, long: %u, puntero: 0x%08x\n"
 
-#: vms-alpha.c:6646
+#: vms-alpha.c:6668
 #, c-format
 msgid "non-contiguous array of %s\n"
 msgstr "matriz no contigua de %s\n"
 
-#: vms-alpha.c:6650
+#: vms-alpha.c:6672
 #, c-format
 msgid "dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"
 msgstr "dimct: %u, aops: 0x%02x, dígitos: %u, escala: %u\n"
 
-#: vms-alpha.c:6654
+#: vms-alpha.c:6676
 #, c-format
 msgid "arsize: %u, a0: 0x%08x\n"
 msgstr "artam: %u, a0: 0x%08x\n"
 
-#: vms-alpha.c:6658
+#: vms-alpha.c:6680
 #, c-format
 msgid "Strides:\n"
 msgstr "Estribos:\n"
 
-#: vms-alpha.c:6663
+#: vms-alpha.c:6685
 #, c-format
 msgid "[%u]: %u\n"
 msgstr "[%u]: %u\n"
 
-#: vms-alpha.c:6668
+#: vms-alpha.c:6690
 #, c-format
 msgid "Bounds:\n"
 msgstr "Límites:\n"
 
-#: vms-alpha.c:6673
+#: vms-alpha.c:6695
 #, c-format
 msgid "[%u]: Lower: %u, upper: %u\n"
 msgstr "[%u]: Inferior: %u, superior: %u\n"
 
-#: vms-alpha.c:6685
+#: vms-alpha.c:6707
 #, c-format
 msgid "unaligned bit-string of %s\n"
 msgstr "cadena de bit sin alinear de %s\n"
 
-#: vms-alpha.c:6689
+#: vms-alpha.c:6711
 #, c-format
 msgid "base: %u, pos: %u\n"
 msgstr "base: %u, pos: %u\n"
 
-#: vms-alpha.c:6709
+#: vms-alpha.c:6731
 #, c-format
 msgid "vflags: 0x%02x, value: 0x%08x "
 msgstr "vops: 0x%02x, valor: 0x%08x "
 
-#: vms-alpha.c:6715
+#: vms-alpha.c:6737
 #, c-format
 msgid "(no value)\n"
 msgstr "(sin valor)\n"
 
-#: vms-alpha.c:6718
+#: vms-alpha.c:6740
 #, c-format
 msgid "(not active)\n"
 msgstr "(no activo)\n"
 
-#: vms-alpha.c:6721
+#: vms-alpha.c:6743
 #, c-format
 msgid "(not allocated)\n"
 msgstr "(sin ubicar)\n"
 
-#: vms-alpha.c:6724
+#: vms-alpha.c:6746
 #, c-format
 msgid "(descriptor)\n"
 msgstr "(descriptor)\n"
 
-#: vms-alpha.c:6728
+#: vms-alpha.c:6750
 #, c-format
 msgid "(trailing value)\n"
 msgstr "(valor restante)\n"
 
-#: vms-alpha.c:6731
+#: vms-alpha.c:6753
 #, c-format
 msgid "(value spec follows)\n"
 msgstr "(valor spec a continuación)\n"
 
-#: vms-alpha.c:6734
+#: vms-alpha.c:6756
 #, c-format
 msgid "(at bit offset %u)\n"
 msgstr "(en el despl de bit %u)\n"
 
-#: vms-alpha.c:6737
+#: vms-alpha.c:6759
 #, c-format
 msgid "(reg: %u, disp: %u, indir: %u, kind: "
 msgstr "(reg: %u, disp: %u, indir: %u, género: "
 
-#: vms-alpha.c:6744
+#: vms-alpha.c:6766
 msgid "literal"
 msgstr "literal"
 
-#: vms-alpha.c:6747
+#: vms-alpha.c:6769
 msgid "address"
 msgstr "dirección"
 
-#: vms-alpha.c:6750
+#: vms-alpha.c:6772
 msgid "desc"
 msgstr "desc"
 
-#: vms-alpha.c:6753
+#: vms-alpha.c:6775
 msgid "reg"
 msgstr "reg"
 
-#: vms-alpha.c:6828
+#: vms-alpha.c:6850
 #, c-format
 msgid "Debug symbol table:\n"
 msgstr "Tabla de símbolos de depuración:\n"
 
-#: vms-alpha.c:6839
+#: vms-alpha.c:6861
 #, c-format
 msgid "cannot read DST header\n"
 msgstr "no se puede leer el encabezado DST\n"
 
-#: vms-alpha.c:6844
+#: vms-alpha.c:6866
 #, c-format
 msgid " type: %3u, len: %3u (at 0x%08x): "
 msgstr " tipo: %3u, lon: %3u (en 0x%08x): "
 
-#: vms-alpha.c:6858
+#: vms-alpha.c:6880
 #, c-format
 msgid "cannot read DST symbol\n"
 msgstr "no se puede leer el símbolo DST\n"
 
-#: vms-alpha.c:6901
+#: vms-alpha.c:6923
 #, c-format
 msgid "standard data: %s\n"
 msgstr "datos estándar: %s\n"
 
-#: vms-alpha.c:6904 vms-alpha.c:6988
+#: vms-alpha.c:6926 vms-alpha.c:7010
 #, c-format
 msgid "    name: %.*s\n"
 msgstr "    nombre: %.*s\n"
 
-#: vms-alpha.c:6911
+#: vms-alpha.c:6933
 #, c-format
 msgid "modbeg\n"
 msgstr "modini\n"
 
-#: vms-alpha.c:6912
+#: vms-alpha.c:6934
 #, c-format
 msgid "   flags: %d, language: %u, major: %u, minor: %u\n"
 msgstr "   ops: %d, lenguaje: %u, mayor: %u, menor: %u\n"
 
-#: vms-alpha.c:6918 vms-alpha.c:7184
+#: vms-alpha.c:6940 vms-alpha.c:7206
 #, c-format
 msgid "   module name: %.*s\n"
 msgstr "   nom módulo : %.*s\n"
 
-#: vms-alpha.c:6921
+#: vms-alpha.c:6943
 #, c-format
 msgid "   compiler   : %.*s\n"
 msgstr "   compilador : %.*s\n"
 
-#: vms-alpha.c:6926
+#: vms-alpha.c:6948
 #, c-format
 msgid "modend\n"
 msgstr "modfin\n"
 
-#: vms-alpha.c:6933
+#: vms-alpha.c:6955
 msgid "rtnbeg\n"
 msgstr "rtnini\n"
 
-#: vms-alpha.c:6934
+#: vms-alpha.c:6956
 #, c-format
 msgid "    flags: %u, address: 0x%08x, pd-address: 0x%08x\n"
 msgstr "    ops: %u, dirección: 0x%08x, direcc-pd: 0x%08x\n"
 
-#: vms-alpha.c:6939
+#: vms-alpha.c:6961
 #, c-format
 msgid "    routine name: %.*s\n"
 msgstr "    nom rutina  : %.*s\n"
 
-#: vms-alpha.c:6947
+#: vms-alpha.c:6969
 #, c-format
 msgid "rtnend: size 0x%08x\n"
 msgstr "rtnfin: tam 0x%08x\n"
 
-#: vms-alpha.c:6955
+#: vms-alpha.c:6977
 #, c-format
 msgid "prolog: bkpt address 0x%08x\n"
 msgstr "prolog: dirección bkpt 0x%08x\n"
 
-#: vms-alpha.c:6963
+#: vms-alpha.c:6985
 #, c-format
 msgid "epilog: flags: %u, count: %u\n"
 msgstr "epilog: ops: %u, cuenta: %u\n"
 
-#: vms-alpha.c:6972
+#: vms-alpha.c:6994
 #, c-format
 msgid "blkbeg: address: 0x%08x, name: %.*s\n"
 msgstr "blkini: dirección: 0x%08x, nombre: %.*s\n"
 
-#: vms-alpha.c:6981
+#: vms-alpha.c:7003
 #, c-format
 msgid "blkend: size: 0x%08x\n"
 msgstr "blkfin: tam: 0x%08x\n"
 
-#: vms-alpha.c:6987
+#: vms-alpha.c:7009
 #, c-format
 msgid "typspec (len: %u)\n"
 msgstr "espectip (lon: %u)\n"
 
-#: vms-alpha.c:6994
+#: vms-alpha.c:7016
 #, c-format
 msgid "septyp, name: %.*s\n"
 msgstr "septip, nombre: %.*s\n"
 
-#: vms-alpha.c:7003
+#: vms-alpha.c:7025
 #, c-format
 msgid "recbeg: name: %.*s\n"
 msgstr "recini: nombre: %.*s\n"
 
-#: vms-alpha.c:7010
+#: vms-alpha.c:7032
 #, c-format
 msgid "recend\n"
 msgstr "recfin\n"
 
-#: vms-alpha.c:7013
+#: vms-alpha.c:7035
 #, c-format
 msgid "enumbeg, len: %u, name: %.*s\n"
 msgstr "enuini, lon: %u, nombre: %.*s\n"
 
-#: vms-alpha.c:7017
+#: vms-alpha.c:7039
 #, c-format
 msgid "enumelt, name: %.*s\n"
 msgstr "enufin, nombre: %.*s\n"
 
-#: vms-alpha.c:7021
+#: vms-alpha.c:7043
 #, c-format
 msgid "enumend\n"
 msgstr "enufin\n"
 
-#: vms-alpha.c:7038
+#: vms-alpha.c:7060
 #, c-format
 msgid "discontiguous range (nbr: %u)\n"
 msgstr "rango discontinuo (nbr: %u)\n"
 
-#: vms-alpha.c:7040
+#: vms-alpha.c:7062
 #, c-format
 msgid "    address: 0x%08x, size: %u\n"
 msgstr "    dirección: 0x%08x, tamaño: %u\n"
 
-#: vms-alpha.c:7050
+#: vms-alpha.c:7072
 #, c-format
 msgid "line num  (len: %u)\n"
 msgstr "num línea (lon: %u)\n"
 
-#: vms-alpha.c:7067
+#: vms-alpha.c:7089
 #, c-format
 msgid "delta_pc_w %u\n"
 msgstr "delta_pc_w %u\n"
 
-#: vms-alpha.c:7074
+#: vms-alpha.c:7096
 #, c-format
 msgid "incr_linum(b): +%u\n"
 msgstr "incr_linum(b): +%u\n"
 
-#: vms-alpha.c:7080
+#: vms-alpha.c:7102
 #, c-format
 msgid "incr_linum_w: +%u\n"
 msgstr "incr_linum_w: +%u\n"
 
-#: vms-alpha.c:7086
+#: vms-alpha.c:7108
 #, c-format
 msgid "incr_linum_l: +%u\n"
 msgstr "incr_linum_l: +%u\n"
 
-#: vms-alpha.c:7092
+#: vms-alpha.c:7114
 #, c-format
 msgid "set_line_num(w) %u\n"
 msgstr "set_line_num(w) %u\n"
 
-#: vms-alpha.c:7097
+#: vms-alpha.c:7119
 #, c-format
 msgid "set_line_num_b %u\n"
 msgstr "set_line_num_b %u\n"
 
-#: vms-alpha.c:7102
+#: vms-alpha.c:7124
 #, c-format
 msgid "set_line_num_l %u\n"
 msgstr "set_line_num_l %u\n"
 
-#: vms-alpha.c:7107
+#: vms-alpha.c:7129
 #, c-format
 msgid "set_abs_pc: 0x%08x\n"
 msgstr "set_abs_pc: 0x%08x\n"
 
-#: vms-alpha.c:7111
+#: vms-alpha.c:7133
 #, c-format
 msgid "delta_pc_l: +0x%08x\n"
 msgstr "delta_pc_l: +0x%08x\n"
 
-#: vms-alpha.c:7116
+#: vms-alpha.c:7138
 #, c-format
 msgid "term(b): 0x%02x"
 msgstr "term(b): 0x%02x"
 
-#: vms-alpha.c:7118
+#: vms-alpha.c:7140
 #, c-format
 msgid "        pc: 0x%08x\n"
 msgstr "        pc: 0x%08x\n"
 
-#: vms-alpha.c:7123
+#: vms-alpha.c:7145
 #, c-format
 msgid "term_w: 0x%04x"
 msgstr "term_w: 0x%04x"
 
-#: vms-alpha.c:7125
+#: vms-alpha.c:7147
 #, c-format
 msgid "    pc: 0x%08x\n"
 msgstr "    pc: 0x%08x\n"
 
-#: vms-alpha.c:7131
+#: vms-alpha.c:7153
 #, c-format
 msgid "delta pc +%-4d"
 msgstr "delta pc +%-4d"
 
-#: vms-alpha.c:7134
+#: vms-alpha.c:7156
 #, c-format
 msgid "    pc: 0x%08x line: %5u\n"
 msgstr "    pc: 0x%08x línea: %5u\n"
 
-#: vms-alpha.c:7139
+#: vms-alpha.c:7161
 #, c-format
 msgid "    *unhandled* cmd %u\n"
 msgstr "    *sin manejar* ord %u\n"
 
-#: vms-alpha.c:7154
+#: vms-alpha.c:7176
 #, c-format
 msgid "source (len: %u)\n"
 msgstr "fuente (lon: %u)\n"
 
-#: vms-alpha.c:7168
+#: vms-alpha.c:7190
 #, c-format
 msgid "   declfile: len: %u, flags: %u, fileid: %u\n"
 msgstr "   declfich: lon: %u, ops: %u, fichid: %u\n"
 
-#: vms-alpha.c:7172
+#: vms-alpha.c:7194
 #, c-format
 msgid "   rms: cdt: 0x%08x %08x, ebk: 0x%08x, ffb: 0x%04x, rfo: %u\n"
 msgstr "   rms: cdt: 0x%08x %08x, ebk: 0x%08x, ffb: 0x%04x, rfo: %u\n"
 
-#: vms-alpha.c:7181
+#: vms-alpha.c:7203
 #, c-format
 msgid "   filename   : %.*s\n"
 msgstr "   nomfichero : %.*s\n"
 
-#: vms-alpha.c:7190
+#: vms-alpha.c:7212
 #, c-format
 msgid "   setfile %u\n"
 msgstr "   setfile %u\n"
 
-#: vms-alpha.c:7195 vms-alpha.c:7200
+#: vms-alpha.c:7217 vms-alpha.c:7222
 #, c-format
 msgid "   setrec %u\n"
 msgstr "   setrect %u\n"
 
-#: vms-alpha.c:7205 vms-alpha.c:7210
+#: vms-alpha.c:7227 vms-alpha.c:7232
 #, c-format
 msgid "   setlnum %u\n"
 msgstr "   setlnum %u\n"
 
-#: vms-alpha.c:7215 vms-alpha.c:7220
+#: vms-alpha.c:7237 vms-alpha.c:7242
 #, c-format
 msgid "   deflines %u\n"
 msgstr "   deflines %u\n"
 
-#: vms-alpha.c:7224
+#: vms-alpha.c:7246
 #, c-format
 msgid "   formfeed\n"
 msgstr "   alimforma\n"
 
-#: vms-alpha.c:7228
+#: vms-alpha.c:7250
 #, c-format
 msgid "   *unhandled* cmd %u\n"
 msgstr "   *sin manejar* ord %u\n"
 
-#: vms-alpha.c:7240
+#: vms-alpha.c:7262
 #, c-format
 msgid "*unhandled* dst type %u\n"
 msgstr "tipo dst %u *sin manejar*\n"
 
-#: vms-alpha.c:7272
+#: vms-alpha.c:7294
 #, c-format
 msgid "cannot read EIHD\n"
 msgstr "no se puede leer EIHD\n"
 
-#: vms-alpha.c:7275
+#: vms-alpha.c:7297
 #, c-format
 msgid "EIHD: (size: %u, nbr blocks: %u)\n"
 msgstr "EIHD: (tamaño: %u, bloques nbr: %u)\n"
 
-#: vms-alpha.c:7278
+#: vms-alpha.c:7300
 #, c-format
 msgid " majorid: %u, minorid: %u\n"
 msgstr " idmayor: %u, idmenor: %u\n"
 
-#: vms-alpha.c:7286
+#: vms-alpha.c:7308
 msgid "executable"
 msgstr "ejecutable"
 
-#: vms-alpha.c:7289
+#: vms-alpha.c:7311
 msgid "linkable image"
 msgstr "imagen enlazable"
 
-#: vms-alpha.c:7295
+#: vms-alpha.c:7317
 #, c-format
 msgid " image type: %u (%s)"
 msgstr " tipo imagen: %u (%s)"
 
-#: vms-alpha.c:7301
+#: vms-alpha.c:7323
 msgid "native"
 msgstr "nativa"
 
-#: vms-alpha.c:7304
+#: vms-alpha.c:7326
 msgid "CLI"
 msgstr "CLI"
 
-#: vms-alpha.c:7310
+#: vms-alpha.c:7332
 #, c-format
 msgid ", subtype: %u (%s)\n"
 msgstr ", subtipo: %u (%s)\n"
 
-#: vms-alpha.c:7316
+#: vms-alpha.c:7338
 #, c-format
 msgid " offsets: isd: %u, activ: %u, symdbg: %u, imgid: %u, patch: %u\n"
 msgstr " despls: isd: %u, activ: %u, simdep: %u, idimg: %u, parche: %u\n"
 
-#: vms-alpha.c:7320
+#: vms-alpha.c:7342
 #, c-format
 msgid " fixup info rva: "
 msgstr " info compos rva: "
 
-#: vms-alpha.c:7322
+#: vms-alpha.c:7344
 #, c-format
 msgid ", symbol vector rva: "
 msgstr "  vector símbolo rva: "
 
-#: vms-alpha.c:7325
+#: vms-alpha.c:7347
 #, c-format
 msgid ""
 "\n"
@@ -4954,465 +5246,465 @@
 "\n"
 " matriz versión despl: %u\n"
 
-#: vms-alpha.c:7329
+#: vms-alpha.c:7351
 #, c-format
 msgid " img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"
 msgstr " cuenta I/O img: %u, canales nbr: %u, pri req: %08x%08x\n"
 
-#: vms-alpha.c:7335
+#: vms-alpha.c:7357
 #, c-format
 msgid " linker flags: %08x:"
 msgstr " opciones de enlazador: %08x:"
 
-#: vms-alpha.c:7365
+#: vms-alpha.c:7387
 #, c-format
 msgid " ident: 0x%08x, sysver: 0x%08x, match ctrl: %u, symvect_size: %u\n"
 msgstr " ident: 0x%08x, versis: 0x%08x, ctrl coinc: %u, tam_vectsim: %u\n"
 
-#: vms-alpha.c:7371
+#: vms-alpha.c:7393
 #, c-format
 msgid " BPAGE: %u"
 msgstr " BPAGE: %u"
 
-#: vms-alpha.c:7377
+#: vms-alpha.c:7399
 #, c-format
 msgid ", ext fixup offset: %u, no_opt psect off: %u"
 msgstr ", ext comp despl: %u, no_opt desp psect: %u"
 
-#: vms-alpha.c:7380
+#: vms-alpha.c:7402
 #, c-format
 msgid ", alias: %u\n"
 msgstr ", alias: %u\n"
 
-#: vms-alpha.c:7388
+#: vms-alpha.c:7410
 #, c-format
 msgid "system version array information:\n"
 msgstr "información de matriz de versión de sistema:\n"
 
-#: vms-alpha.c:7392
+#: vms-alpha.c:7414
 #, c-format
 msgid "cannot read EIHVN header\n"
 msgstr "no se puede leer el encabezado EIHVN\n"
 
-#: vms-alpha.c:7402
+#: vms-alpha.c:7424
 #, c-format
 msgid "cannot read EIHVN version\n"
 msgstr "no se puede leer la versión EIHVN\n"
 
-#: vms-alpha.c:7405
+#: vms-alpha.c:7427
 #, c-format
 msgid "   %02u "
 msgstr "   %02u "
 
-#: vms-alpha.c:7409
+#: vms-alpha.c:7431
 msgid "BASE_IMAGE       "
 msgstr "IMAGEN_BASE      "
 
-#: vms-alpha.c:7412
+#: vms-alpha.c:7434
 msgid "MEMORY_MANAGEMENT"
 msgstr "ADMIN_MEMORIA"
 
-#: vms-alpha.c:7415
+#: vms-alpha.c:7437
 msgid "IO               "
 msgstr "ES               "
 
-#: vms-alpha.c:7418
+#: vms-alpha.c:7440
 msgid "FILES_VOLUMES    "
 msgstr "VOL_FICHEROS     "
 
-#: vms-alpha.c:7421
+#: vms-alpha.c:7443
 msgid "PROCESS_SCHED    "
 msgstr "CALEND_PROCESOS  "
 
-#: vms-alpha.c:7424
+#: vms-alpha.c:7446
 msgid "SYSGEN           "
 msgstr "GENSIS           "
 
-#: vms-alpha.c:7427
+#: vms-alpha.c:7449
 msgid "CLUSTERS_LOCKMGR "
 msgstr "ADMBLOQ_CLUSTERS "
 
-#: vms-alpha.c:7430
+#: vms-alpha.c:7452
 msgid "LOGICAL_NAMES    "
 msgstr "NOMBRES_LOGICOS  "
 
-#: vms-alpha.c:7433
+#: vms-alpha.c:7455
 msgid "SECURITY         "
 msgstr "SEGURIDAD        "
 
-#: vms-alpha.c:7436
+#: vms-alpha.c:7458
 msgid "IMAGE_ACTIVATOR  "
 msgstr "ACTIVADOR_IMAGEN "
 
-#: vms-alpha.c:7439
+#: vms-alpha.c:7461
 msgid "NETWORKS         "
 msgstr "REDES            "
 
-#: vms-alpha.c:7442
+#: vms-alpha.c:7464
 msgid "COUNTERS         "
 msgstr "CONTADORES       "
 
-#: vms-alpha.c:7445
+#: vms-alpha.c:7467
 msgid "STABLE           "
 msgstr "ESTABLE          "
 
-#: vms-alpha.c:7448
+#: vms-alpha.c:7470
 msgid "MISC             "
 msgstr "MISC             "
 
-#: vms-alpha.c:7451
+#: vms-alpha.c:7473
 msgid "CPU              "
 msgstr "CPU              "
 
-#: vms-alpha.c:7454
+#: vms-alpha.c:7476
 msgid "VOLATILE         "
 msgstr "VOLÁTIL          "
 
-#: vms-alpha.c:7457
+#: vms-alpha.c:7479
 msgid "SHELL            "
 msgstr "SHELL            "
 
-#: vms-alpha.c:7460
+#: vms-alpha.c:7482
 msgid "POSIX            "
 msgstr "POSIX            "
 
-#: vms-alpha.c:7463
+#: vms-alpha.c:7485
 msgid "MULTI_PROCESSING "
 msgstr "MULTI_PROCESAM   "
 
-#: vms-alpha.c:7466
+#: vms-alpha.c:7488
 msgid "GALAXY           "
 msgstr "GALAXIA          "
 
-#: vms-alpha.c:7469
+#: vms-alpha.c:7491
 msgid "*unknown*        "
 msgstr "*desconocido*    "
 
-#: vms-alpha.c:7472
+#: vms-alpha.c:7494
 #, c-format
 msgid ": %u.%u\n"
 msgstr ": %u.%u\n"
 
-#: vms-alpha.c:7485 vms-alpha.c:7744
+#: vms-alpha.c:7507 vms-alpha.c:7766
 #, c-format
 msgid "cannot read EIHA\n"
 msgstr "no se puede leer EIHA\n"
 
-#: vms-alpha.c:7488
+#: vms-alpha.c:7510
 #, c-format
 msgid "Image activation:  (size=%u)\n"
 msgstr "Activa imagen   : (tamaño=%u)\n"
 
-#: vms-alpha.c:7490
+#: vms-alpha.c:7512
 #, c-format
 msgid " First address : 0x%08x 0x%08x\n"
 msgstr " Primera direcc: 0x%08x 0x%08x\n"
 
-#: vms-alpha.c:7493
+#: vms-alpha.c:7515
 #, c-format
 msgid " Second address: 0x%08x 0x%08x\n"
 msgstr " Segunda direcc: 0x%08x 0x%08x\n"
 
-#: vms-alpha.c:7496
+#: vms-alpha.c:7518
 #, c-format
 msgid " Third address : 0x%08x 0x%08x\n"
 msgstr " Tercera direcc: 0x%08x 0x%08x\n"
 
-#: vms-alpha.c:7499
+#: vms-alpha.c:7521
 #, c-format
 msgid " Fourth address: 0x%08x 0x%08x\n"
 msgstr " Cuarta direcc : 0x%08x 0x%08x\n"
 
-#: vms-alpha.c:7502
+#: vms-alpha.c:7524
 #, c-format
 msgid " Shared image  : 0x%08x 0x%08x\n"
 msgstr " Imagen compar : 0x%08x 0x%08x\n"
 
-#: vms-alpha.c:7513
+#: vms-alpha.c:7535
 #, c-format
 msgid "cannot read EIHI\n"
 msgstr "no se puede leer EIHI\n"
 
-#: vms-alpha.c:7516
+#: vms-alpha.c:7538
 #, c-format
 msgid "Image identification: (major: %u, minor: %u)\n"
 msgstr "Identificación de imagen: (mayor: %u, menor: %u)\n"
 
-#: vms-alpha.c:7519
+#: vms-alpha.c:7541
 #, c-format
 msgid " image name       : %.*s\n"
 msgstr " nombre de imagen : %.*s\n"
 
-#: vms-alpha.c:7521
+#: vms-alpha.c:7543
 #, c-format
 msgid " link time        : %s\n"
 msgstr " hora enlazado    : %s\n"
 
-#: vms-alpha.c:7523
+#: vms-alpha.c:7545
 #, c-format
 msgid " image ident      : %.*s\n"
 msgstr " ident imagen     : %.*s\n"
 
-#: vms-alpha.c:7525
+#: vms-alpha.c:7547
 #, c-format
 msgid " linker ident     : %.*s\n"
 msgstr " ident enlazador  : %.*s\n"
 
-#: vms-alpha.c:7527
+#: vms-alpha.c:7549
 #, c-format
 msgid " image build ident: %.*s\n"
 msgstr " ident const imagen: %.*s\n"
 
-#: vms-alpha.c:7537
+#: vms-alpha.c:7559
 #, c-format
 msgid "cannot read EIHS\n"
 msgstr "no se puede leer EIHS\n"
 
-#: vms-alpha.c:7540
+#: vms-alpha.c:7562
 #, c-format
 msgid "Image symbol & debug table: (major: %u, minor: %u)\n"
 msgstr "Símbolo de imagen y tabla de depuración: (mayor: %u, menor %u)\n"
 
-#: vms-alpha.c:7545
+#: vms-alpha.c:7567
 #, c-format
 msgid " debug symbol table : vbn: %u, size: %u (0x%x)\n"
 msgstr " tabla de símbolos de depuración : vbn: %u, tam: %u (0x%x)\n"
 
-#: vms-alpha.c:7549
+#: vms-alpha.c:7571
 #, c-format
 msgid " global symbol table: vbn: %u, records: %u\n"
 msgstr " tabla de símbolos globales      : vbn: %u, registros: %u\n"
 
-#: vms-alpha.c:7553
+#: vms-alpha.c:7575
 #, c-format
 msgid " debug module table : vbn: %u, size: %u\n"
 msgstr " tabla de módulo de depuración   : vbn: %u, tam: %u\n"
 
-#: vms-alpha.c:7566
+#: vms-alpha.c:7588
 #, c-format
 msgid "cannot read EISD\n"
 msgstr "no se puede leer EISD\n"
 
-#: vms-alpha.c:7576
+#: vms-alpha.c:7598
 #, c-format
 msgid "Image section descriptor: (major: %u, minor: %u, size: %u, offset: %u)\n"
 msgstr "Descriptor de sección de imagen: (mayor: %u, menor: %u, tam: %u, despl: %u)\n"
 
-#: vms-alpha.c:7583
+#: vms-alpha.c:7605
 #, c-format
 msgid " section: base: 0x%08x%08x size: 0x%08x\n"
 msgstr " sección: base: 0x%08x%08x tam: 0x%08x\n"
 
-#: vms-alpha.c:7588
+#: vms-alpha.c:7610
 #, c-format
 msgid " flags: 0x%04x"
 msgstr " opciones: %04x"
 
-#: vms-alpha.c:7625
+#: vms-alpha.c:7647
 #, c-format
 msgid " vbn: %u, pfc: %u, matchctl: %u type: %u ("
 msgstr " vbn: %u, pfc: %u, coincctl: %u tipo: %u ("
 
-#: vms-alpha.c:7631
+#: vms-alpha.c:7653
 msgid "NORMAL"
 msgstr "NORMAL"
 
-#: vms-alpha.c:7634
+#: vms-alpha.c:7656
 msgid "SHRFXD"
 msgstr "SHRFXD"
 
-#: vms-alpha.c:7637
+#: vms-alpha.c:7659
 msgid "PRVFXD"
 msgstr "PRVFXD"
 
-#: vms-alpha.c:7640
+#: vms-alpha.c:7662
 msgid "SHRPIC"
 msgstr "SHRPIC"
 
-#: vms-alpha.c:7643
+#: vms-alpha.c:7665
 msgid "PRVPIC"
 msgstr "PRVPIC"
 
-#: vms-alpha.c:7646
+#: vms-alpha.c:7668
 msgid "USRSTACK"
 msgstr "USRSTACK"
 
-#: vms-alpha.c:7654
+#: vms-alpha.c:7676
 #, c-format
 msgid " ident: 0x%08x, name: %.*s\n"
 msgstr " ident: 0x%08x, nombre: %.*s\n"
 
-#: vms-alpha.c:7664
+#: vms-alpha.c:7686
 #, c-format
 msgid "cannot read DMT\n"
 msgstr "no se puede leer DMT\n"
 
-#: vms-alpha.c:7668
+#: vms-alpha.c:7690
 #, c-format
 msgid "Debug module table:\n"
 msgstr "Tabla de módulos de depuración\n"
 
-#: vms-alpha.c:7677
+#: vms-alpha.c:7699
 #, c-format
 msgid "cannot read DMT header\n"
 msgstr "no se puede leer el encabezado DMT\n"
 
-#: vms-alpha.c:7682
+#: vms-alpha.c:7704
 #, c-format
 msgid " module offset: 0x%08x, size: 0x%08x, (%u psects)\n"
 msgstr " despl módulo: 0x%08x, tam: 0x%08x, (%u psects)\n"
 
-#: vms-alpha.c:7692
+#: vms-alpha.c:7714
 #, c-format
 msgid "cannot read DMT psect\n"
 msgstr "no se puede leer el psect DMT\n"
 
-#: vms-alpha.c:7695
+#: vms-alpha.c:7717
 #, c-format
 msgid "  psect start: 0x%08x, length: %u\n"
 msgstr "  psect inicio: 0x%08x, long: %u\n"
 
-#: vms-alpha.c:7708
+#: vms-alpha.c:7730
 #, c-format
 msgid "cannot read DST\n"
 msgstr "no se puede leer DST\n"
 
-#: vms-alpha.c:7718
+#: vms-alpha.c:7740
 #, c-format
 msgid "cannot read GST\n"
 msgstr "no se puede leer GST\n"
 
-#: vms-alpha.c:7722
+#: vms-alpha.c:7744
 #, c-format
 msgid "Global symbol table:\n"
 msgstr "Tabla de símbolos global:\n"
 
-#: vms-alpha.c:7750
+#: vms-alpha.c:7772
 #, c-format
 msgid "Image activator fixup: (major: %u, minor: %u)\n"
 msgstr "Compostura de activador de imagen: (mayor: %u, menor: %u)\n"
 
-#: vms-alpha.c:7753
+#: vms-alpha.c:7775
 #, c-format
 msgid "  iaflink : 0x%08x %08x\n"
 msgstr "  iafenl  : 0x%08x %08x\n"
 
-#: vms-alpha.c:7756
+#: vms-alpha.c:7778
 #, c-format
 msgid "  fixuplnk: 0x%08x %08x\n"
 msgstr "  compenl : 0x%08x %08x\n"
 
-#: vms-alpha.c:7759
+#: vms-alpha.c:7781
 #, c-format
 msgid "  size : %u\n"
 msgstr "  tam  : %u\n"
 
-#: vms-alpha.c:7761
+#: vms-alpha.c:7783
 #, c-format
 msgid "  flags: 0x%08x\n"
 msgstr "  ops  : 0x%08x\n"
 
-#: vms-alpha.c:7765
+#: vms-alpha.c:7787
 #, c-format
 msgid "  qrelfixoff: %5u, lrelfixoff: %5u\n"
 msgstr "  qrelfixoff: %5u, lrelfixoff: %5u\n"
 
-#: vms-alpha.c:7769
+#: vms-alpha.c:7791
 #, c-format
 msgid "  qdotadroff: %5u, ldotadroff: %5u\n"
 msgstr "  qdotadroff: %5u, ldotadroff: %5u\n"
 
-#: vms-alpha.c:7773
+#: vms-alpha.c:7795
 #, c-format
 msgid "  codeadroff: %5u, lpfixoff  : %5u\n"
 msgstr "  codeadroff: %5u, lpfixoff  : %5u\n"
 
-#: vms-alpha.c:7776
+#: vms-alpha.c:7798
 #, c-format
 msgid "  chgprtoff : %5u\n"
 msgstr "  chgprtoff : %5u\n"
 
-#: vms-alpha.c:7779
+#: vms-alpha.c:7801
 #, c-format
 msgid "  shlstoff  : %5u, shrimgcnt : %5u\n"
 msgstr "  shlstoff  : %5u, shrimgcnt : %5u\n"
 
-#: vms-alpha.c:7781
+#: vms-alpha.c:7803
 #, c-format
 msgid "  shlextra  : %5u, permctx   : %5u\n"
 msgstr "  shlextra  : %5u, permctx   : %5u\n"
 
-#: vms-alpha.c:7784
+#: vms-alpha.c:7806
 #, c-format
 msgid "  base_va : 0x%08x\n"
 msgstr "  base_va : 0x%08x\n"
 
-#: vms-alpha.c:7786
+#: vms-alpha.c:7808
 #, c-format
 msgid "  lppsbfixoff: %5u\n"
 msgstr "  lppsbfixoff: %5u\n"
 
-#: vms-alpha.c:7794
+#: vms-alpha.c:7816
 #, c-format
 msgid " Shareable images:\n"
 msgstr " Imágenes compartibles:\n"
 
-#: vms-alpha.c:7798
+#: vms-alpha.c:7820
 #, c-format
 msgid "  %u: size: %u, flags: 0x%02x, name: %.*s\n"
 msgstr "  %u: tam: %u, opts: 0x%02x, nombre: %.*s\n"
 
-#: vms-alpha.c:7805
+#: vms-alpha.c:7827
 #, c-format
 msgid " quad-word relocation fixups:\n"
 msgstr " composturas de reubicación quad-word:\n"
 
-#: vms-alpha.c:7810
+#: vms-alpha.c:7832
 #, c-format
 msgid " long-word relocation fixups:\n"
 msgstr " composturas de reubicación long-word:\n"
 
-#: vms-alpha.c:7815
+#: vms-alpha.c:7837
 #, c-format
 msgid " quad-word .address reference fixups:\n"
 msgstr " composturas de referencia .address quad-word:\n"
 
-#: vms-alpha.c:7820
+#: vms-alpha.c:7842
 #, c-format
 msgid " long-word .address reference fixups:\n"
 msgstr " composturas de referencia .address long-word:\n"
 
-#: vms-alpha.c:7825
+#: vms-alpha.c:7847
 #, c-format
 msgid " Code Address Reference Fixups:\n"
 msgstr " Composturas de Referencias de Dirección de Código:\n"
 
-#: vms-alpha.c:7830
+#: vms-alpha.c:7852
 #, c-format
 msgid " Linkage Pairs Referece Fixups:\n"
 msgstr " Composturas de Referencias de Pares de Enlazado\n"
 
-#: vms-alpha.c:7839
+#: vms-alpha.c:7861
 #, c-format
 msgid " Change Protection (%u entries):\n"
 msgstr " Cambiar Protección (%u entradas):\n"
 
-#: vms-alpha.c:7844
+#: vms-alpha.c:7866
 #, c-format
 msgid "  base: 0x%08x %08x, size: 0x%08x, prot: 0x%08x "
 msgstr "  base: 0x%08x %08x, tam: 0x%08x, prot: 0x%08x "
 
 #. FIXME: we do not yet support relocatable link.  It is not obvious
 #. how to do it for debug infos.
-#: vms-alpha.c:8676
+#: vms-alpha.c:8706
 msgid "%P: relocatable link is not supported\n"
 msgstr "%P: no se admite el enlace reubicable\n"
 
-#: vms-alpha.c:8746
+#: vms-alpha.c:8776
 msgid "%P: multiple entry points: in modules %B and %B\n"
 msgstr "%P: puntos de entrada múltiples: en los módulos %B y %B\n"
 
-#: vms-lib.c:1421
+#: vms-lib.c:1423
 #, c-format
 msgid "could not open shared image '%s' from '%s'"
 msgstr "no se puede abrir la imagen compartida '%s' desde '%s'"
@@ -5435,140 +5727,140 @@
 msgid "%s: dynamic object with no .loader section"
 msgstr "%s: objeto dinámico sin sección .loader"
 
-#: xcofflink.c:1415
+#: xcofflink.c:1416
 msgid "%B: `%s' has line numbers but no enclosing section"
 msgstr "%B: `%s' tiene números de línea pero no una sección contenedora"
 
-#: xcofflink.c:1467
+#: xcofflink.c:1468
 msgid "%B: class %d symbol `%s' has no aux entries"
 msgstr "%B: clase %d símbolo `%s' no tiene entradas auxiliares"
 
-#: xcofflink.c:1489
+#: xcofflink.c:1490
 msgid "%B: symbol `%s' has unrecognized csect type %d"
 msgstr "%B: el símbolo `%s' tiene un tipo csect %d que no se reconoce"
 
-#: xcofflink.c:1501
+#: xcofflink.c:1502
 msgid "%B: bad XTY_ER symbol `%s': class %d scnum %d scnlen %d"
 msgstr "%B: símbolo XTY_ER `%s' erróneo: clase %d scnum %d scnlen %d"
 
-#: xcofflink.c:1530
+#: xcofflink.c:1531
 msgid "%B: XMC_TC0 symbol `%s' is class %d scnlen %d"
 msgstr "%B: símbolo XMC_TCO `%s' es clase %d scnlen %d"
 
-#: xcofflink.c:1676
+#: xcofflink.c:1677
 msgid "%B: csect `%s' not in enclosing section"
 msgstr "%B: csect `%s' no está contenido en una sección"
 
-#: xcofflink.c:1783
+#: xcofflink.c:1784
 msgid "%B: misplaced XTY_LD `%s'"
 msgstr "%B: XTY_LD `%s' mal ubicado"
 
-#: xcofflink.c:2102
+#: xcofflink.c:2103
 msgid "%B: reloc %s:%d not in csect"
 msgstr "%B: la reubicación %s:%d no está en csect"
 
-#: xcofflink.c:3186
+#: xcofflink.c:3194
 #, c-format
 msgid "%s: no such symbol"
 msgstr "%s: no hay tal símbolo"
 
-#: xcofflink.c:3291
+#: xcofflink.c:3299
 #, c-format
 msgid "warning: attempt to export undefined symbol `%s'"
 msgstr "aviso: se intenta exportar el símbolo sin definir `%s'"
 
-#: xcofflink.c:3673
+#: xcofflink.c:3678
 msgid "error: undefined symbol __rtinit"
 msgstr "error: símbolo __rtinit sin definir"
 
-#: xcofflink.c:4052
+#: xcofflink.c:4057
 msgid "%B: loader reloc in unrecognized section `%s'"
 msgstr "%B: reubicación del cargador en la sección `%s' que no se reconoce"
 
-#: xcofflink.c:4063
+#: xcofflink.c:4068
 msgid "%B: `%s' in loader reloc but not loader sym"
 msgstr "%B: `%s' en la reubicación del cargador pero no es un símbolo del cargador"
 
-#: xcofflink.c:4079
+#: xcofflink.c:4084
 msgid "%B: loader reloc in read-only section %A"
 msgstr "%B: reubicación del cargador en la sección de sólo lectura %A"
 
-#: xcofflink.c:5097
+#: xcofflink.c:5106
 #, c-format
 msgid "TOC overflow: 0x%lx > 0x10000; try -mminimal-toc when compiling"
 msgstr "Desbordamiento de TOC: 0x%lx > 0x10000; pruebe -mminimal-toc al compilar"
 
-#: elf32-ia64.c:1110 elf64-ia64.c:1110
+#: elf32-ia64.c:628 elf64-ia64.c:628
 msgid "%B: Can't relax br at 0x%lx in section `%A'. Please use brl or indirect branch."
 msgstr "%B: No se puede relajar br en 0x%lx en la sección `%A'. Por favor use brl o ramificación indirecta."
 
-#: elf32-ia64.c:2809 elf64-ia64.c:2809
+#: elf32-ia64.c:2284 elf64-ia64.c:2284
 msgid "@pltoff reloc against local symbol"
 msgstr "reubicación @pltoff contra un símbolo local"
 
-#: elf32-ia64.c:4430 elf64-ia64.c:4430
+#: elf32-ia64.c:3687 elf64-ia64.c:3687
 #, c-format
 msgid "%s: short data segment overflowed (0x%lx >= 0x400000)"
 msgstr "%s: segmento de datos short desbordado (0x%lx >= 0x400000)"
 
-#: elf32-ia64.c:4441 elf64-ia64.c:4441
+#: elf32-ia64.c:3698 elf64-ia64.c:3698
 #, c-format
 msgid "%s: __gp does not cover short data segment"
 msgstr "%s: __gp no cubre el segmento de datos short"
 
-#: elf32-ia64.c:4708 elf64-ia64.c:4708
+#: elf32-ia64.c:3965 elf64-ia64.c:3965
 msgid "%B: non-pic code with imm relocation against dynamic symbol `%s'"
 msgstr "%B: código que no es pic con reubicación imm contra el símbolo dinámico %s"
 
-#: elf32-ia64.c:4775 elf64-ia64.c:4775
+#: elf32-ia64.c:4032 elf64-ia64.c:4032
 msgid "%B: @gprel relocation against dynamic symbol %s"
 msgstr "%B: reubicación @gprel contra el símbolo dinámico %s"
 
-#: elf32-ia64.c:4838 elf64-ia64.c:4838
+#: elf32-ia64.c:4095 elf64-ia64.c:4095
 msgid "%B: linking non-pic code in a position independent executable"
 msgstr "%B: se enlaza código que no es pic en un ejecutable independiente de posición"
 
-#: elf32-ia64.c:4975 elf64-ia64.c:4975
+#: elf32-ia64.c:4232 elf64-ia64.c:4232
 msgid "%B: @internal branch to dynamic symbol %s"
 msgstr "%B: ramificación @internal al símbolo dinámico %s"
 
-#: elf32-ia64.c:4977 elf64-ia64.c:4977
+#: elf32-ia64.c:4234 elf64-ia64.c:4234
 msgid "%B: speculation fixup to dynamic symbol %s"
 msgstr "%B: compostura de especulación al símbolo dinámico %s"
 
-#: elf32-ia64.c:4979 elf64-ia64.c:4979
+#: elf32-ia64.c:4236 elf64-ia64.c:4236
 msgid "%B: @pcrel relocation against dynamic symbol %s"
 msgstr "%B: reubicación @pcrel contra el símbolo dinámico %s"
 
-#: elf32-ia64.c:5176 elf64-ia64.c:5176
+#: elf32-ia64.c:4433 elf64-ia64.c:4433
 msgid "unsupported reloc"
 msgstr "no se admite la reubicación"
 
-#: elf32-ia64.c:5214 elf64-ia64.c:5214
+#: elf32-ia64.c:4471 elf64-ia64.c:4471
 msgid "%B: missing TLS section for relocation %s against `%s' at 0x%lx in section `%A'."
 msgstr "%B: falta la sección TLS para la reubicación %s contra `%s' en 0x%lx en la sección `%A'."
 
-#: elf32-ia64.c:5229 elf64-ia64.c:5229
+#: elf32-ia64.c:4486 elf64-ia64.c:4486
 msgid "%B: Can't relax br (%s) to `%s' at 0x%lx in section `%A' with size 0x%lx (> 0x1000000)."
 msgstr "%B: No se puede relajar br (%s) a `%s' en 0x%lx en la sección `%A' con tamaño 0x%lx (> 0x1000000)."
 
-#: elf32-ia64.c:5491 elf64-ia64.c:5491
+#: elf32-ia64.c:4748 elf64-ia64.c:4748
 msgid "%B: linking trap-on-NULL-dereference with non-trapping files"
 msgstr "%B: se enlaza deferencias-captura-en-NULL con ficheros que no son de captura"
 
-#: elf32-ia64.c:5500 elf64-ia64.c:5500
+#: elf32-ia64.c:4757 elf64-ia64.c:4757
 msgid "%B: linking big-endian files with little-endian files"
 msgstr "%B: se enlazan ficheros big-endian con ficheros little-endian"
 
-#: elf32-ia64.c:5509 elf64-ia64.c:5509
+#: elf32-ia64.c:4766 elf64-ia64.c:4766
 msgid "%B: linking 64-bit files with 32-bit files"
 msgstr "%B: se enlazan ficheros de 64-bit con ficheros de 32-bit"
 
-#: elf32-ia64.c:5518 elf64-ia64.c:5518
+#: elf32-ia64.c:4775 elf64-ia64.c:4775
 msgid "%B: linking constant-gp files with non-constant-gp files"
 msgstr "%B: se enlazan ficheros de gp constante con ficheros con gp no constante"
 
-#: elf32-ia64.c:5528 elf64-ia64.c:5528
+#: elf32-ia64.c:4785 elf64-ia64.c:4785
 msgid "%B: linking auto-pic files with non-auto-pic files"
 msgstr "%B: se enlazan ficheros de pic automático con ficheros sin pic automático"
 
@@ -5949,10 +6241,34 @@
 msgid "%B: unable to fill in DataDictionary[PE_IMPORT_ADDRESS_TABLE(12)] because .idata$6 is missing"
 msgstr "%B: no se puede llenar DataDictionary[PE_IMPORT_ADDRESS_TABLE(12)] porque falta .idata$6"
 
-#: peigen.c:2436 pepigen.c:2436 pex64igen.c:2436
+#: peigen.c:2438 pepigen.c:2438 pex64igen.c:2438
 msgid "%B: unable to fill in DataDictionary[9] because __tls_used is missing"
 msgstr "%B: no se puede llenar DataDictionary[9] porque falta __tls_used"
 
+#~ msgid "%B: error: taking the address of protected function '%s' cannot be done when making a shared library"
+#~ msgstr "%B: error: no se puede tomar la dirección de la función protegida '%s' cuando se hace una biblioteca compartida"
+
+#~ msgid "%B(%A+0x%lx): cannot reach %s"
+#~ msgstr "%B(%A+0x%lx): no se puede alcanzar %s"
+
+#~ msgid "%B: warning: ignoring duplicate section `%A'\n"
+#~ msgstr "%B: aviso: se descarta la sección duplicada `%A'\n"
+
+#~ msgid "%B: warning: duplicate section `%A' has different size\n"
+#~ msgstr "%B: aviso: la sección duplicada `%A' es de tamaño diferente\n"
+
+#~ msgid "relocation references a different segment"
+#~ msgstr "la reubicación referencía un segmento diferente"
+
+#~ msgid "%B: relocation type %d not implemented"
+#~ msgstr "%B: el tipo de reubicación %d aún no está implementado"
+
+#~ msgid "warning: %B and %B differ in position-dependence of data addressing"
+#~ msgstr "aviso: %B y %B difieren en el direccionamiento de datos dependiente de posición"
+
+#~ msgid "warning: %B and %B differ in position-dependence of code addressing"
+#~ msgstr "aviso: %B y %B difieren en el direccionamiento de código dependiente de posición"
+
 #~ msgid "Can't Make it a Short Jump"
 #~ msgstr "No se Puede Convertir en un Salto Corto"
 
@@ -6145,15 +6461,9 @@
 #~ msgid "missing IHIHALF reloc"
 #~ msgstr "reubicación IHIHALF faltante"
 
-#~ msgid "%B(%A): warning: unresolvable relocation %d against symbol `%s'"
-#~ msgstr "%B(%A): aviso: reubicación %d sin resolución contra el símbolo `%s'"
-
 #~ msgid "%s: warning: unresolvable relocation against symbol `%s' from %s section"
 #~ msgstr "%s: aviso: reubicación sin resolución contra el símbolo `%s' de la sección %s"
 
-#~ msgid "%B(%A): unresolvable relocation against symbol `%s'"
-#~ msgstr "%B(%A+0x%lx): reubicación sin resolución contra el símbolo `%s'"
-
 #~ msgid "Symbol %s has no GOT subsection for offset 0x%x"
 #~ msgstr "El símbolo %s no tiene subsección GOT para el desplazamiento 0x%x"
 
@@ -6336,9 +6646,6 @@
 #~ msgid "TIR_S_C_OPR_REDEF not supported"
 #~ msgstr "TIR_S_C_OPR_REDEF no se admite"
 
-#~ msgid "TIR_S_C_OPR_DFLIT not supported"
-#~ msgstr "TIR_S_C_OPR_DFLIT no se admite"
-
 #~ msgid "TIR_S_C_CTL_DFLOC not fully implemented"
 #~ msgstr "TIR_S_C_CTL_DFLOC no está completamente implementado"
 
diff --git a/bfd/po/fi.po b/bfd/po/fi.po
index 341ca76..c2d751c 100644
--- a/bfd/po/fi.po
+++ b/bfd/po/fi.po
@@ -1,16 +1,17 @@
-# Finnish messages for bfd
-# Copyright © 2007, 2009, 2010 Free Software Foundation, Inc.
+# Finnish messages for bfd.
+# Copyright © 2007, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 # This file is distributed under the same license as the binutils package.
-# Jorma Karvonen <[email protected]>, 2007, 2009, 2010.
+# Jorma Karvonen <