Merge GDB 7.5.1

Merge bug fixes:
* Remove normal elf formats from nacl target in bfd/configure.bfd
* Force usage of AT_ENTRY_POINT mode for calling user functions.
* Update gdb/configure.tgt to exclude solib.o that is linked twice otherwise.

Review URL: https://codereview.chromium.org/11969036
diff --git a/ChangeLog b/ChangeLog
index 27e4379..f4fbf7e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,83 @@
+2012-06-28  Christophe Lyon <christophe.lyon@st.com>
+
+	* configure.ac (CFLAGS_FOR_TARGET, CXXFLAGS_FOR_TARGET): Make sure
+	they contain -O2.
+	* configure: Regenerate.
+
+2012-05-14  Catherine Moore  <clm@codesourcery.com>
+
+	* NEWS:  Mention PowerPC VLE port.
+
+2012-05-11  Mike Frysinger  <vapier@gentoo.org>
+
+	* MAINTAINERS (config/): Move to intl/ section.
+	(compile; depcomp; install-sh; missing; ylwrap): Likewise.
+
+2012-05-09  Nick Clifton  <nickc@redhat.com>
+	    Paul Smith  <psmith@gnu.org>
+
+	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  <mcgrathr@google.com>
+
+	* configure.ac (ENABLE_GOLD): Consider *-*-nacl* targets ELF.
+	* configure: Regenerate.
+
+2012-04-25  Joel Brobecker  <brobecker@adacore.com>
+
+	* config.sub: Update to 2012-04-18 version from official repo.
+
+2012-03-19  Tristan Gingold  <gingold@adacore.com>
+
+	* configure.ac (ia64*-*-*vms*): Add support for ld.
+	* configure: Regenerate.
+
+2012-03-14  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+	* 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  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+	* configure.ac (enable_libgomp): Remove *-*-osf*.
+	(with_stabs): Remove alpha*-*-osf*.
+	* configure: Regenerate.
+
+2012-03-09  Jeff Johnston  <jjohnstn@redhat.com>
+
+	* 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  <jjohnstn@redhat.com>
+
+	* COPYING.NEWLIB: Remove two unused licenses.
+
+2012-03-05  Tristan Gingold  <gingold@adacore.com>
+
+	* configure.ac: Enable gdb and readline for ia64*-*-*vms*.
+	* configure: Regenerate.
+
+2012-02-21  Joern Rennecke  <joern.rennecke@embecosm.com>
+
+	* COPYING.NEWLIB: Add Adapteva notice.
+	* COPYING.LIBGLOSS: Add Adapteva notice.
+
+2011-12-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+	* configure: Regenerate.
+
+2011-12-15  Jeff Johnston  <jjohnstn@redhat.com>
+
+	* COPYING.LIBGLOSS: Add GPL with exception license.
+
 2011-11-09  Roland McGrath  <mcgrathr@google.com>
 
 	* configure.ac: Add tool checks for READELF and READELF_FOR_TARGET.
@@ -46,7 +126,7 @@
 	2011-09-09  Linas Vepstas  <linasvepstas@gmail.com>
 	    Ben Elliston  <bje@gnu.org>
 
-        * config.sub (hexagon, hexagon-*): New.
+	* config.sub (hexagon, hexagon-*): New.
 
 	2011-08-23  Roland McGrath  <mcgrathr@google.com>
 
@@ -535,11 +615,11 @@
 
 	* config.guess: Update to version 2011-02-02
 	* config.sub: Update to version 2011-02-24
-	
+
 2011-03-03  Sebastian Pop  <sebastian.pop@amd.com>
 
-        * configure.ac: Adjust test of with_ppl.
-        * configure: Regenerated.
+	* configure.ac: Adjust test of with_ppl.
+	* configure: Regenerated.
 
 2011-03-02  Sebastian Pop  <sebastian.pop@amd.com>
 
@@ -1146,11 +1226,11 @@
 	* lt~obsolete.m4: Likewise.
 
 2010-01-07  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
-            Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+	    Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
 	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.
 
@@ -1563,8 +1643,8 @@
 2009-06-03  Jerome Guitton  <guitton@adacore.com>
 	    Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
-        * 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  <bje@au.ibm.com>
 
@@ -3727,7 +3807,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.
 
@@ -5048,8 +5128,8 @@
 
 2003-12-21  Bernardo Innocenti  <bernie@develer.com>
 
- 	* 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  <neroden@gcc.gnu.org>
 
@@ -13138,8 +13218,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  (ian@cygnus.com)
 
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/bfd/ChangeLog b/bfd/ChangeLog
index 65ba31d..da9e6a2 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3164 +1,2089 @@
-2012-01-05  Jan Kratochvil  <jan.kratochvil@redhat.com>
+2012-07-13  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
 
-	Fix zero registers core files when built by gcc-4.7.
-	* elf64-x86-64.c: Update copyright year.
-	(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.
+	* 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.
 
-2011-12-21  Ulrich Weigand  <ulrich.weigand@linaro.org>
+2012-07-13  Nick Clifton  <nickc@redhat.com>
 
-	* elf32-arm.c (elf32_arm_nabi_grok_psinfo): Fill in core_pid.
+	* 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.
 
-2011-12-13  Tristan Gingold  <gingold@adacore.com>
+2012-07-09  Alan Modra  <amodra@gmail.com>
 
-	* 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.
+	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.
 
-2011-12-13  Chung-Lin Tang  <cltang@codesourcery.com>
+2012-07-03  H.J. Lu  <hongjiu.lu@intel.com>
 
-	* elfxx-mips.c (mips_elf_calculate_relocation): Correct
-	R_MIPS16_HI16/R_MIPS16_LO16 handling of two cleared lower bits,
-	update comments.
+	* elf.c (assign_section_numbers): Check if number of sections
+	>= SHN_LORESERVE.
+	* elfcode.h (elf_object_p): Likewise.
 
-2011-12-12  Iain Sandoe  <iains@gcc.gnu.org>
+2012-07-03  Nick Clifton  <nickc@redhat.com>
 
-	* mach-o.c (bfd_mach_o_read_section_32): Null-terminate sectname.
-	(bfd_mach_o_read_section_64): Likewise.
+	* archive.c (bsd_write_armap): Catch attempts to create an archive
+	with indicies bigger than 4Gb.
+	(coff_write_armap): Likewise.
 
-2011-12-11  John Davis Anglin  <dave.anglin@nrc-cnrc.gc.ca>
+2012-07-03  H.J. Lu  <hongjiu.lu@intel.com>
 
-	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.
+	PR binutils/14319
+	* elf.c (_bfd_elf_make_section_from_shdr): Don't compress empty
+	debug section.
 
-2011-12-10  David Daney  <david.daney@cavium.com>
+2012-07-03  H.J. Lu  <hongjiu.lu@intel.com>
 
-	* 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.
+	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.
 
-2011-12-08  Andrew Pinski  <apinski@cavium.com>
-            Adam Nemet  <anemet@caviumnetworks.com>
+2012-07-03  Alan Modra  <amodra@gmail.com>
 
-	* 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.
+	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.
 
-2011-12-07  Alan Modra  <amodra@gmail.com>
+2012-07-02  Alan Modra  <amodra@gmail.com>
 
-	PR ld/12772
-	* elflink.c (elf_gc_sweep_symbol): Discard unmarked symbols
-	defined in shared libraries.
+	* 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.
 
-2011-12-07  Tristan Gingold  <gingold@adacore.com>
+2012-07-01  Andreas Schwab  <schwab@linux-m68k.org>
 
-	* 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  <uweigand@de.ibm.com>
-
-	* 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  <gingold@adacore.com>
-
-	* mach-o.c (bfd_mach_o_read_symtab_symbol): Accept indirect symbols.
-
-2011-12-05  Tristan Gingold  <gingold@adacore.com>
-
-	* 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  <gingold@adacore.com>
-
-	* mach-o.c (bfd_mach_o_read_command): Add the bfd in the error
+	* elf.c (_bfd_elf_make_section_from_shdr): Fix typo in 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  <amodra@gmail.com>
+2012-06-29  H.J. Lu  <hongjiu.lu@intel.com>
 
-	PR ld/13468
-	* elflink.c (bfd_elf_final_link): Don't segfault when checking
-	for DT_TEXTREL and .dynamic does not exist.
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Return FALSE
+	on unresolvable relocation.
 
-2011-12-03  Alan Modra  <amodra@gmail.com>
+2012-06-29  H.J. Lu  <hongjiu.lu@intel.com>
 
-	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.
+	* archive.c (_bfd_compute_and_write_armap): Simplify global
+	symbol handling.
 
-2011-12-01  Mikael Pettersson  <mikpe@it.uu.se>
+2012-06-29  Nick Clifton  <nickc@redhat.com>
 
-	* 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.
+	PR ld/14189
+	* elf32-arm.c (elf32_arm_check_relocs): Do not increment refcount
+	for locally bound symbols.
 
-2011-12-01  Hans-Peter Nilsson  <hp@axis.com>
+2012-06-29  Alan Modra  <amodra@gmail.com>
 
-	* 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  <apinski@cavium.com>
-
-	* archures.c (bfd_mach_mips_octeonp): New macro.
+	* 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.
-	* 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.
+	* 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.
 
-2011-11-23  Tristan Gingold  <gingold@adacore.com>
+2012-06-29  Alan Modra  <amodra@gmail.com>
 
-	* vms-lib.c (get_idxlen): Add comments.  Fix type in sizeof.
-	(vms_write_index): Add comments.
+	* 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.
 
-2011-11-22  DJ Delorie  <dj@redhat.com>
+2012-06-28  Roland McGrath  <mcgrathr@google.com>
 
-	* elf32-rx.c (rx_elf_object_p): Add more checks for "scanning" to
-	avoid using the special non-swapping target when not explicitly
-	requested.
+	* elf32-arm.c (elf32_arm_populate_plt_entry): Use int32_t for
+	displacement calculation in nacl_p case.
 
-2011-11-22  Daniel Calcoen  <Daniel.Calcoen@cern.ch>
+2012-06-28  Nick Clifton  <nickc@redhat.com>
 
-	* elf32-rx.c (rx_elf_object_p): Correct typo: lma->vma.
-
-2011-11-22  Tristan Gingold  <gingold@adacore.com>
-
-	* mach-o.c (bfd_mach_o_print_symbol): Display COM for common
-	symbols.  Print section name in brackets.
-
-2011-11-21  Andreas Tobler  <andreast@fgznet.ch>
-
-	* config.bfd: Add vectors for powerpc and powerpc64-freebsd.
-	* configure.in (TDEFINES): Add rules for powerpc*-freebsd.
+	* po/uk.po: New Ukranian translation.
+	* configure.in (ALL_LINGUAS): Add uk.
 	* 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  <philipp@thogro.org>
+2012-06-26  Alan Modra  <amodra@gmail.com>
 
-	* elf32-arm.c (elf32_thumb_to_arm_stub): Sync message so that it
-	needs to be translated only once.
+	* 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.
 
-2011-11-16  Maciej W. Rozycki  <macro@codesourcery.com>
+2012-06-22  Roland McGrath  <mcgrathr@google.com>
 
-	* 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.
+	* 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.
 
-2011-11-15  Alan Modra  <amodra@gmail.com>
-	    Andreas Tobler  <andreast@fgznet.ch>
+2012-06-22  Andreas Schwab  <schwab@linux-m68k.org>
 
-	* 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.
+	* elf32-m68k.c (elf_m68k_finish_dynamic_symbol): Don't make
+	_GLOBAL_OFFSET_TABLE_ and _DYNAMIC absolute.
 
-2011-11-14  Maxim Kuvyrkov  <maxim@codesourcery.com>
+2012-06-22  Alan Modra  <amodra@gmail.com>
 
-	* elfxx-mips.c (mips_n64_exec_plt0_entry): Use 64-bit move.
+	* elf64-ppc.c (ppc64_elf_func_desc_adjust): Don't emit out-of-line
+	save/restore functions when relocatable.  Make "funcs" static.
 
-2011-11-08  Nick Clifton  <nickc@redhat.com>
+2012-06-18  Hans-Peter Nilsson  <hp@axis.com>
 
-	* elf-m10300.c (mn10300_elf_relax_section): Fix check for an
-	immediate move into an address register.
+	* elf32-cris.c (cris_elf_plt_sym_val): Rewrite to work in presence
+	of merged .got and .got.plt entries.
 
-2011-11-09  Alan Modra  <amodra@gmail.com>
+2012-06-18  John Szakmeister  <john@szakmeister.net>
 
-	* elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Mark syms in
-	executables when export_dynamic.
+	* elf32-arm.c (elf32_arm_final_link_relocate): Correct return value.
 
-2011-11-08  Alan Modra  <amodra@gmail.com>
+2012-06-17  Hans-Peter Nilsson  <hp@axis.com>
 
-	* 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.
+	* 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.
 
-2011-11-06  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
+2012-06-13  Nick Clifton  <nickc@redhat.com>
 
-	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.
+	* 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.
 
-2011-11-02  DJ Delorie  <dj@redhat.com>
+2012-06-12  H.J. Lu  <hongjiu.lu@intel.com>
 
-	* elf32-rl78.c (rl78_elf_merge_private_bfd_data): Delete unused
-	variable.
+	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.
 
-2011-11-02  Jan Beulich  <jbeulich@suse.com>
+2012-06-12  Alan Modra  <amodra@gmail.com>
 
-	* 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.
+	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.
 
-2011-11-01  DJ Delorie  <dj@redhat.com>
+2012-06-11  H.J. Lu  <hongjiu.lu@intel.com>
 
-	* 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.
+	* elf.c (assign_file_positions_for_non_load_sections): Reindent.
+
+2012-06-11  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* elf.c (_bfd_elf_map_sections_to_segments): Reindent.
+
+2012-06-06  Alan Modra  <amodra@gmail.com>
+
+	* 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  <jan.kratochvil@redhat.com>
+
+	* 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  <amodra@gmail.com>
+
+	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  <siddhesh@redhat.com>
+
+	* 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  <amodra@gmail.com>
+
+	PR binutils/13897
+	* elf64-ppc.c (opd_entry_value): Rewrite cache code.
+
+2012-05-29  Tom Tromey  <tromey@redhat.com>
+
+	* opncls.c (bfd_fopen): Always close fd on failure.
+	(bfd_fdopenr): Likewise.
+
+2012-05-27  Alan Modra  <amodra@gmail.com>
+
+	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  <hongjiu.lu@intel.com>
+
+	* 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  <amodra@gmail.com>
+
+	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  <amodra@gmail.com>
+
+	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  <amodra@gmail.com>
+
+	* elf-eh-frame.c (_bfd_elf_maybe_strip_eh_frame_hdr): Handle
+        BFDs with multiple .eh_frame sections.
+
+2012-05-23  Alan Modra  <amodra@gmail.com>
+
+	PR ld/13909
+	* elflink.c (bfd_elf_discard_info): Don't ignore dynamic BFDs.
+
+2012-05-22  H.J. Lu  <hongjiu.lu@intel.com>
+
+	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  <amodra@gmail.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	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  <hongjiu.lu@intel.com>
+
+	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  <amodra@gmail.com>
+
+	* 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  <schwab@linux-m68k.org>
+
+	* 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  <macro@linux-mips.org>
+
+	* 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  <macro@linux-mips.org>
+
+	* 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  <macro@linux-mips.org>
+
+	* 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  <macro@linux-mips.org>
+
+	* 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  <amodra@gmail.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	* 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  <mcgrathr@google.com>
+
+	* 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  <palves@redhat.com>
+
+	* mach-o.h: Don't include sysdep.h.
+
+2012-05-18  Nick Clifton  <nickc@redhat.com>
+
+	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  <schwab@linux-m68k.org>
+
+	* aclocal.m4: Regenerate.
+	* Makefile.in: Regenerate.
+
+2012-05-17  Daniel Richard G.  <skunk@iskunk.org>
+	    Nick Clifton  <nickc@redhat.com>
+
+	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  <macro@linux-mips.org>
+	    Alan Modra  <amodra@gmail.com>
+
+	* 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  <amodra@gmail.com>
+
+	* 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  <amodra@gmail.com>
+
+	* 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  <sergiodj@redhat.com>
+
+	* 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  <avr@gjlay.de>
+
+	PR target/13503
+	* reloc.c: Rename BFD_RELOC_AVR_8_HHI to BFD_RELOC_AVR_8_HLO.
+	* bfd-in2.h: Regenerate.
+	* libbfd.h: Regenrate.
+	* 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.  <skunk@iskunk.org>
+
+	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  <amodra@gmail.com>
+
+	* 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  <amodra@gmail.com>
+
+	* 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  <amodra@gmail.com>
+
+	* archive.c (_bfd_generic_read_ar_hdr_mag):  Ensure sscanf
+	stops at end of ar_size field.
+
+2012-05-16  Alan Modra  <amodra@gmail.com>
+
+ 	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 <jsm@jsm-net.demon.co.uk>
+	    Stephane Carrez <stcarrez@nerim.fr>
+
+	* 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.
-	* configure: Regenerate.
 	* libbfd.h: Regenerate.
-	* cpu-rl78.c: New file.
-	* elf32-rl78.c: New file.
 
-2011-10-26  Nick Clifton  <nickc@redhat.com>
+2012-05-14  James Lemke  <jwlemke@codesourcery.com>
+	    Catherine Moore  <clm@codesourcery.com>
 
-	PR ld/13049
-	* elf64-ppc.c (STUB_SUFFIX): Revert previous delta.
-	* elf32-hppa.c (STUB_SUFFIX): Likewise.
+	* 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.
 
-2011-10-25  Joern Rennecke  <joern.rennecke@embecosm.com>
+2012-05-14  Catherine Moore  <clm@codesourcery.com>
 
-	* 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.
+	* 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  <avr@gjlay.de>
+
+	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.
-	* configure: Regenerate.
-	* libbfd.h: Regenerate.
-	* po/SRC-POTFILES.in: Regenerate.
-	* po/bfd.pot: Regenerate.
-	* cpu-epiphany.c: New file.
-	* elf32-epiphany.c: New file.
+	* libbfd.h: Regenrate.
+	* 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.
 
-2011-10-24  Maciej W. Rozycki  <macro@codesourcery.com>
+2012-05-10  H.J. Lu  <hongjiu.lu@intel.com>
 
-	* elfxx-mips.c (_bfd_mips_elf_symbol_processing): Remove
-	assertions.
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Use int in x32
+	addend overflow check.
 
-2011-10-24  Eugeniy Meshcheryakov  <eugen@debian.org>
+2012-05-10  DJ Delorie  <dj@redhat.com>
 
-	PR ld/13273
-	* elf32-arm.c (elf32_arm_merge_eabi_attributes): Do not warn about
-	identical TAG_PCS_config attributes.
+	* elf32-rx.c (rx_elf_object_p): Ignore empty segments.
 
-2011-10-24  Nick Clifton  <nickc@redhat.com>
+2012-05-10  H.J. Lu  <hongjiu.lu@intel.com>
 
-	* po/ja.po: Updated Japanese translation.
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Display signed
+	hex number in x32 addend overflow check.
 
-2011-10-24  Pau Garcia i Quiles  <pgquiles@elpauer.org>
+2012-05-10  H.J. Lu  <hongjiu.lu@intel.com>
 
-	PR binutils/13292
-	* bfd-in.h: Include <sys/stat.h> rather than forward defining
-	struct stat.
-	* bfd-in2.h: Regenerate.
+	* elf64-x86-64.c (elf_x86_64_reloc_type_class): Handle
+	R_X86_64_RELATIVE64.
 
-2011-10-21  H.J. Lu  <hongjiu.lu@intel.com>
+2012-05-09  H.J. Lu  <hongjiu.lu@intel.com>
 
-	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): Check addend
+	overflow for R_X86_64_RELATIVE64.
 
-	* elf64-x86-64.c (elf_x86_64_relocate_section): Replace
-	R_X86_64_IRELATIVE with R_X86_64_RELATIVE.
+2012-05-08  Ben Cheng  <bccheng@google.com>
 
-2011-10-21  H.J. Lu  <hongjiu.lu@intel.com>.
+	* elf.c: Preserve the original p_align and p_flags if they are
+	valid.
 
-	* elf32-i386.c (elf_i386_relocate_section): Fix a typo in
-	comments.
-	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
+2012-05-07  Alan Modra  <amodra@gmail.com>
 
-2011-10-21  H.J. Lu  <hongjiu.lu@intel.com>
+	* elf64-ia64-vms.c (elf64_ia64_relocate_section): Update
+	RELOC_AGAINST_DISCARDED_SECTION invocation.
 
-	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.
+2012-05-07  Hans-Peter Nilsson  <hp@axis.com>
 
-	* 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.
+	* elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): Declare and use
+	local variable i_ instead of assuming and using a variable i.
 
-2011-10-20  Nick Clifton  <nickc@redhat.com>
+2012-05-07  Maciej W. Rozycki  <macro@linux-mips.org>
 
-	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  <amodra@gmail.com>
-
-	* 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  <amodra@gmail.com>
-
-	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.
+	* 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): 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.
 
-2011-10-19  Alan Modra  <amodra@gmail.com>
+2012-05-05  Alan Modra  <amodra@gmail.com>
 
-	PR ld/13311
-	* elflink.c (elf_link_output_extsym): Correct test for warning when
-	forced local executable syms are referenced from shared libraries.
+	PR ld/14052
+	PR ld/13621
+	* linker.c (_bfd_nearby_section): Revert 2012-02-13 change.
 
-2011-10-19  Alan Modra  <amodra@gmail.com>
+2012-05-05  Alan Modra  <amodra@gmail.com>
 
-	PR ld/13254
-	* elflink.c (bfd_elf_final_link): Emit error_textrel error.
-
-2011-10-18  David S. Miller  <davem@davemloft.net>
-
-	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  <amodra@gmail.com>
-
-	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  <hp@axis.com>
-
-	* 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  <richard.sandiford@linaro.org>
-
-	* elf32-arm.c (elf32_arm_final_link_relocate): Mark PLT calls via
-	stubs as resolved.
-
-2011-10-11  Alan Modra  <amodra@gmail.com>
-
-	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  <amodra@gmail.com>
-
-	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  <nickc@redhat.com>
-
-	* 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  <amodra@gmail.com>
-
-	* 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  <hongjiu.lu@intel.com>
-
-	PR ld/13250
-	* elflink.c (elf_link_add_object_symbols): Preserve the maximum
-	alignment and size for common symbols.
-
-2011-10-08  Alan Modra  <amodra@gmail.com>
-
-	PR ld/13229
-	PR ld/13244
-	* elflink.c (elf_link_add_object_symbols): Don't make IR symbols
-	dynamic.
-
-2011-10-08  Alan Modra  <amodra@gmail.com>
-
-	PR ld/13229
-	* elflink.c (elf_link_output_extsym): Strip defined plugin symbols
-	even when strip_discarded is false.
-
-2011-10-05  Kai Tietz  <ktietz@redhat.com>
-
-	* 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  <dj@redhat.com>
-	    Nick Clifton  <nickc@redhat.com>
-
-	* 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  <gingold@adacore.com>
-
-	* 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  <amodra@gmail.com>
-
-	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  <amodra@gmail.com>
-
-	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  <hongjiu.lu@intel.com>
-
-	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  <ktietz@redhat.com>
-
-	* coffcode.h (sec_to_styp_flags): Handle
-	SEC_LINK_DUPLICATES_SAME_CONTENTS, and
-	SEC_LINK_DUPLICATES_SAME_SIZE.
-
-2011-09-22  Tristan Gingold  <gingold@adacore.com>
-
-	* configure.in: Bump version to 2.22.51
-	* configure: Regenerate.
-
-2011-09-21  David S. Miller  <davem@davemloft.net>
-
-	* 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  <gingold@adacore.com>
-
-	* 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  <hongjiu.lu@intel.com>
-
-	PR ld/13177
-	* elflink.c (elf_gc_sweep_symbol): Also hide symbols without PLT
-	nor GOT references.
-
-2011-09-15  H.J. Lu  <hongjiu.lu@intel.com>
-
-	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  <hongjiu.lu@intel.com>
-
-	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  <ktietz@redhat.com>
-
-	* peicode.h (pe_ILF_build_a_bfd): Don't remove leading underscore
-	for targets without symbol_leading_char.
-
-2011-09-08  Bernd Jendrissek  <bernd.jendrissek@gmail.com>
-
-	* bfdwin.c (bfd_get_file_window): Fix memory leak.
-
-2011-09-07  Alan Modra  <amodra@gmail.com>
-
-	PR ld/13131
-	* bfd/elf64-ppc.c (adjust_toc_syms): Ensure ppc64_elf_howto_table
-	is initialized.
-
-2011-09-06  Alan Modra  <amodra@gmail.com>
-
-	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  <christophe.lyon@st.com>
-
-	* elf32-arm.c (elf32_arm_output_arch_local_syms): Skip excluded
-	sections.
-
-2011-08-26  Nick Clifton  <nickc@redhat.com>
-
-	* po/es.po: Updated Spanish translation.
-
-2011-08-19  Alan Modra  <amodra@gmail.com>
-
-	* 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  <gingold@adacore.com>
-
-	* mach-o.c (bfd_mach_o_read_segment): Initialize list.
-
-2011-08-17  Tristan Gingold  <gingold@adacore.com>
-
-	* mach-o.c (bfd_mach_o_write_section_32): Fix typo.
-
-2011-08-17  Alan Modra  <amodra@gmail.com>
-
-	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.
+	* 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.
 
-2011-08-14  Alan Modra  <amodra@gmail.com>
+2012-05-03  Sean Keys  <skeys@ipdatasys.com>
 
-	* elf32-ppc.c (ppc_elf_select_plt_layout): Force bss-plt when
-	shared and call to _mcount will go via plt.
+	* 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.
 
-2011-08-14  Alan Modra  <amodra@gmail.com>
+2012-05-03  Tristan Gingold  <gingold@adacore.com>
 
-	* 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.
+	* dwarf2.c (decode_line_info): Ignore
+	DW_LNE_HP_source_file_correlation.
 
-2011-08-12  H.J. Lu  <hongjiu.lu@intel.com>
+2012-05-01  Nick Clifton  <nickc@redhat.com>
 
-	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.
+	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.
 
-2011-08-09  Matthew Gretton-Dann  <matthew.gretton-dann@arm.com>
+2012-04-26  Mark Wielaard  <mjw@redhat.com>
 
-	* 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.
+	* dwarf2.c (scan_unit_for_symbols): Account for DW_AT_high_pc
+	possibly being relative to DW_AT_low_pc.
+	(parse_comp_unit): Likewise.
 
-2011-08-08  Tristan Gingold  <gingold@adacore.com>
+2012-04-26  Andreas Schwab  <schwab@linux-m68k.org>
 
-	* 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.
+	* 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.
 
-2011-08-08  Tristan Gingold  <gingold@adacore.com>
+2012-04-26  Hans-Peter Nilsson  <hp@axis.com>
 
-	* 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.
+	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.
 
-2011-08-08  Tristan Gingold  <gingold@adacore.com>
+2012-04-24  Hans-Peter Nilsson  <hp@axis.com>
 
-	* 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.
+	PR ld/13990
+	* elf32-arm.c (elf32_arm_gc_sweep_hook): Handle a forced-local
+	symbol, where PLT refcount is set to -1.
 
-2011-08-08  Tristan Gingold  <gingold@adacore.com>
+2012-04-24  Alan Modra  <amodra@gmail.com>
 
-	* 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.
+	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.
 
-2011-08-08  Tristan Gingold  <gingold@adacore.com>
-
-	* 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  <gingold@adacore.com>
-
-	* 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  <kettenis@gnu.org>
-
-	* netbsd-core.c (netbsd_core_vec): Init match_priority field.
-
-2011-08-05  Alan Modra  <amodra@gmail.com>
-
-	* 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  <amodra@gmail.com>
-
-	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-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.
 
-2011-08-05  Alan Modra  <amodra@gmail.com>
+2012-04-20  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
 
-	* 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.
+	* elf32-s390.c (ELF_DYNAMIC_INTERPRETER): Set to the GCC default.
+	* elf64-s390.c (ELF_DYNAMIC_INTERPRETER): Set to the GCC default.
 
-2011-08-04  Tristan Gingold  <gingold@adacore.com>
+2012-04-19  Thomas Schwinge  <thomas@codesourcery.com>
 
-	* vms-alpha.c (_bfd_vms_write_eeom): Round vms_linkage_index.
-	(_bfd_vms_write_etir): Initialize vms_linkage_index to 0.
+	* 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.
 
-2011-08-03  Tristan Gingold  <gingold@adacore.com>
+2012-04-17  Kaz Kojima  <kkojima@rr.iij4u.or.jp>
 
-	* mach-o.c (bfd_mach_o_canonicalize_symtab): Handle no symbols case.
-	(bfd_mach_o_read_symtab_symbols): Return if no symbols.
+	* elf32-sh.c (allocate_dynrelocs): Don't allocate dynamic
+	relocations when LE conversion happens on the IE tls symbol.
 
-2011-08-02  Maciej W. Rozycki  <macro@codesourcery.com>
+2012-04-17  Roland McGrath  <mcgrathr@google.com>
 
-	* 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.
+	* elf64-x86-64.c (elf_x86_64_nacl_plt0_entry): Fix nop padding
+	so that 32-byte boundary is a proper instruction boundary.
 
-2011-08-02  Alan Modra  <amodra@gmail.com>
+2012-04-17  Tristan Gingold  <gingold@adacore.com>
 
-	* 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.
+	* vms-lib.c (_bfd_vms_lib_get_module): Append .obj extension to
+	member of an object archive.<
 
-2011-08-01  H.J. Lu  <hongjiu.lu@intel.com>
+2012-04-17  Tristan Gingold  <gingold@adacore.com>
 
-	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.
+	* 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.
 
-	* bfd-in2.h: Regenerated.
+2012-04-16  Maciej W. Rozycki  <macro@linux-mips.org>
 
-	* 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.
+	* elfxx-mips.c (mips16_stub_symndx): Handle n64 compound relocs.
+	(_bfd_mips_elf_check_relocs): Update accordingly.
 
-	* 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.
+2012-04-13  Alan Modra  <amodra@gmail.com>
 
-2011-07-29  Maciej W. Rozycki  <macro@codesourcery.com>
+	PR ld/13947
+	* elflink.c (bfd_elf_final_link): Set reloc_count to 0 for
+	reloc sections.
 
-	* elfxx-mips.c (check_br32): Fix return type.
+2012-04-12  David S. Miller  <davem@davemloft.net>
 
-2011-07-29  Maciej W. Rozycki  <macro@codesourcery.com>
+	* 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.
 
-	* elfxx-mips.c (bz_insn_16): Correct opcode mask.
+2012-04-12  Roland McGrath  <mcgrathr@google.com>
 
-2011-07-29  Maciej W. Rozycki  <macro@codesourcery.com>
-
-	* 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  <mcgrathr@google.com>
-
-	* 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.
+	* 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.
 
-	* 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.
+2012-04-12  Tristan Gingold  <gingold@adacore.com>
 
-	* 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.
+	* 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.
 
-	* 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.
+2012-04-11  Nick Clifton  <nickc@redhat.com>
 
-2011-07-28  Mikulas Patocka  <mikulas@artax.karlin.mff.cuni.cz>
+	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.
 
-	* elf64-hppa.c (elf_hppa_final_link_relocate): Fix handling of out
-	of range branches.
+2012-04-09  Roland McGrath  <mcgrathr@google.com>
 
-2011-07-26  Jakub Jelinek  <jakub@redhat.com>
+	* 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.
 
-	* dwarf2.c (dwarf_debug_sections): Add .debug_macro
-	and .zdebug_macro entry.
-	(dwarf_debug_section_enum): Add debug_macro.
+2012-04-03  Roland McGrath  <mcgrathr@google.com>
 
-2011-07-26  Alan Modra  <amodra@gmail.com>
-
-	* 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  <hp@bitrange.com>
-
-	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  <fu@mips.com>
-	    Ilie Garbacea  <ilie@mips.com>
-	    Maciej W. Rozycki  <macro@codesourcery.com>
-	    Joseph Myers  <joseph@codesourcery.com>
-	    Catherine Moore  <clm@codesourcery.com>
-	    Richard Sandiford  <rdsandiford@googlemail.com>
-
-	* 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  <hongjiu.lu@intel.com>
-
-	* Makefile.am (ALL_MACHINES): Add cpu-k1om.lo.
-	(ALL_MACHINES_CFILES): Add cpu-k1om.c.
+	* 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.
-
-	* 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.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.
 
-	* cpu-k1om.c: New.
+2012-03-31  Andreas Schwab  <schwab@linux-m68k.org>
 
-	* elf64-x86-64.c (elf64_k1om_elf_object_p): New.
-	(bfd_elf64_k1om_vec): Likewise.
-	(bfd_elf64_k1om_freebsd_vec): Likewise.
+	* elf32-m68k.c (elf_m68k_relocate_section): Allow
+	R_68K_TLS_LE{8,16,32} for PIE.
 
-	* 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.
+2012-03-30  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
 
-2011-07-20  Jan Kratochvil  <jan.kratochvil@redhat.com>
+	* elf64-s390.c: Fix several comments regarding PLT entry
+	description.
+	* elf32-s390.c: Likewise.
 
-	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.
+2012-03-30  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
 
-2011-07-15  Alan Modra  <amodra@gmail.com>
+	* 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.
 
-	* configure.in: Bump version.
-	* configure: Regenerate.
+2012-03-30  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
 
-2011-07-14  Alan Modra  <amodra@gmail.com>
+	* 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.
 
-	* linker.c (_bfd_generic_section_already_linked): Set l_flags.
-	* elf-bfd.h (struct already_linked): Forward declare.
+2012-03-30  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
 
-2011-07-14  Alan Modra  <amodra@gmail.com>
+	* elf32-s390.c (struct elf_s390_dyn_relocs): Remove.
+	Rename all occurrences in the file to elf_dyn_relocs.
+	* elf64-s390.c: Likewise.
 
-	* elflink.c (_bfd_elf_fix_symbol_flags): Loop on indirect syms.
-	(_bfd_elf_adjust_dynamic_symbol): Remove FIXME.
+2012-03-30  Alan Modra  <amodra@gmail.com>
 
-2011-07-14  Alan Modra  <amodra@gmail.com>
-
-	* 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  <nickc@redhat.com>
-
-	* elf32-arm.c (elf32_arm_section_flags): Delete.
-	(elf_backend_section_flags): Remove.
-
-2011-07-11  H.J. Lu  <hongjiu.lu@intel.com>
-
-	PR ld/12982
-	* elflink.c (bfd_elf_size_dynamic_sections): Also skip BFD_PLUGIN
-	when setting stack_flags.
-
-2011-07-11  Catherine Moore  <clm@codesourcery.com>
-
-	* 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  <hongjiu.lu@intel.com>
-
-	PR ld/12978
-	* elfnn-ia64.c (count_dyn_reloc): Fix a typo.
-
-2011-07-09  Alan Modra  <amodra@gmail.com>
-
-	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  <hongjiu.lu@intel.com>
-
-	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  <gingold@adacore.com>
-
-	* mach-o.h: Move loader related definitions to
-	include/mach-o/loader.h.  Include it.
-
-2011-07-05  H.J. Lu  <hongjiu.lu@intel.com>
-
-	* elf64-x86-64.c (elf_backend_post_process_headers): Always
-	define to _bfd_elf_set_osabi.
-
-2011-07-03  Samuel Thibault  <samuel.thibault@gnu.org>
-	    Thomas Schwinge  <thomas@schwinge.name>
-
-	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  <iant@google.com>
-
-	* elf32-i386.c (elf_i386_eh_frame_plt): Correct expression: change
-	DW_OP_lit3 to DW_OP_lit2.
-
-2011-07-01  Alan Modra  <amodra@gmail.com>
-
-	* 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  <bernds@codesourcery.com>
-
-	* bfd/elf32-tic6x.c (elf32_tic6x_set_osabi): Also set it if
-	link_info is NULL.
-
-2011-06-28  Tristan Gingold  <gingold@adacore.com>
-
-	* 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 <fawzi.mohamed@nokia.com>
-
-	* mach-o.c (bfd_mach_o_read_command): Also ignore
-	BFD_MACH_O_LC_ROUTINES_64.
-
-2011-06-27  Tristan Gingold  <gingold@adacore.com>
-
-	* vms-alpha.c (_bfd_vms_write_etir): Use 'section' to get current
-	section target index.
-
-2011-06-27  Nick Clifton  <nickc@redhat.com>
-
-	* cisco-core.c (cisco_core_little_vec): Add initialization of
-	match_priority field.
-
-2011-06-27  Tristan Gingold  <gingold@adacore.com>
-
-	* 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  <gingold@adacore.com>
-
-	* vms-misc.c (vms_time_to_time_t): Adjust overflow detection.
-	Add comment.
-
-2011-06-25  H.J. Lu  <hongjiu.lu@intel.com>
-
-	* 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  <jan.kratochvil@redhat.com>
-
-	* 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  <rth@redhat.com>
-
-	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  <gingold@adacore.com>
-
-	* vms-alpha.c (alpha_vms_slurp_relocs): Add a guard for relocs in the
-	absolute section.
-
-2011-06-24  Alan Modra  <amodra@gmail.com>
-
-	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  <kkojima@rr.iij4u.or.jp>
-
-	* 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  <rth@redhat.com>
-
-	* 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  <ramana.radhakrishnan@linaro.org>
-
-	* elf32-arm.c (elf32_arm_final_link_relocate): Allow R_ARM_TLS_LE32
-	for PIE.
-
-2011-06-22  Alan Modra  <amodra@gmail.com>
-
-	* elflink.c (_bfd_elf_merge_symbol): Allow type changes for
-	plugin symbols.  Fix segfault on linker scrip defined syms.
-
-2011-06-20  Jakub Jelinek  <jakub@redhat.com>
-
-	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  <hongjiu.lu@intel.com>
-
-	* elf64-x86-64.c (elf_backend_post_process_headers): Defined
-	for x32.
-
-2011-06-16  H.J. Lu  <hongjiu.lu@intel.com>
-
-	* 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  <hongjiu.lu@intel.com>
-
-	* elf64-x86-64.c (elf_x86_64_grok_prstatus): Support x32.
-	(elf_x86_64_grok_psinfo): Likewise.
-
-2011-06-16  Nick Clifton  <nickc@redhat.com>
-
-	* elf.c (elf_find_function): Fail if not provided with a symbol
-	table.
-
-2011-06-15  Ulrich Weigand  <ulrich.weigand@linaro.org>
-
-	* 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  <rth@redhat.com>
-
-	* 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  <amodra@gmail.com>
-
-	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  <amodra@gmail.com>
-
-	* 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  <amodra@gmail.com>
-
-	* 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  <amodra@gmail.com>
-
-	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  <nickc@redhat.com>
-
-	* 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  <walt@tilera.com>
-
-	* 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  <amodra@gmail.com>
-
-	* 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  <nickc@redhat.com>
-
-	* 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  <gingold@adacore.com>
-
-	* 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  <gingold@adacore.com>
-
-	* bfd.c (bfd_get_sign_extend_vma): Handle aixcoff.
-
-2011-06-09  Nick Clifton  <nickc@redhat.com>
-
-	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  <hongjiu.lu@intel.com>
-
-	* elf64-x86-64.c (elf_x86_64_check_relocs): Allow R_X86_64_64
-	relocations in SEC_DEBUGGING sections when building shared
+	* elflink.c (_bfd_elf_gc_mark_reloc): Don't delve into dynamic
 	libraries.
 
-2011-06-08  H.J. Lu  <hongjiu.lu@intel.com>
+2012-03-29  Alan Modra  <amodra@gmail.com>
 
-	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  <gingold@adacore.com>
-
-	* makefile.vms (OBJS): Add elfxx-ia64.obj
-	Remove vax case.
-
-2011-06-08  Alan Modra  <amodra@gmail.com>
-
-	* aix386-core.c, * cisco-core.c, * hpux-core.c, * osf-core.c,
-	* sco5-core.c: Init match_priority field.
-
-2011-06-08  Alan Modra  <amodra@gmail.com>
-
-	* elflink.c (_bfd_elf_archive_symbol_lookup): Follow warning and
-	indirect links here.
-
-2011-06-07  Joel Brobecker  <brobecker@adacore.com>
-
-	* irix-core.c (irix_core_vec): Add match_priority field.
-
-2011-06-06  Alan Modra  <amodra@gmail.com>
-
-	* 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-in.h (bfd_get_arch_size, bfd_get_sign_extend_vma): Delete.
 	* bfd-in2.h: Regenerate.
 
-2011-06-04  H.J. Lu  <hongjiu.lu@intel.com>
+2012-03-23  Alan Modra  <amodra@gmail.com>
 
-	PR ld/12842
-	* elfcode.h (elf_object_p): Revert the last change.
+	* elf.c (assign_file_positions_for_non_load_sections): Don't warn
+	on empty alloc sections.
 
-2011-06-04  Alan Modra  <amodra@gmail.com>
+2012-03-23  Alan Modra  <amodra@gmail.com>
 
-	* 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.
+	* 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.
 
-2011-06-03  Bertram Felgenhauer  <bertram.felgenhauer@gmail.com>
+2012-03-23  Alan Modra  <amodra@gmail.com>
 
-	PR ld/12682
-	* hash.c (higher_primer_number): Add more, small, prime numbers.
-	(bfd_hash_set_default_size): Likewise.
+	PR binutils/13894
+	* elf64-ppc.c (opd_entry_value): Read full symbol table when
+	sym hashes unavailable.
 
-2011-06-02  Nick Clifton  <nickc@redhat.com>
+2012-03-21  Eliot Dresselhaus  <eliot@sonic.net>
 
-	* 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.
+	* elf32-tic6x.c (elf32_tic6x_merge_private_bfd_data): Return TRUE
+	for non-C6X objects.
 
-2011-06-01  DJ Delorie  <dj@redhat.com>
+2012-03-20  Kai Tietz  <ktietz@redhat.com>
 
-	* 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  <hongjiu.lu@intel.com>
-
-	* 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  <nickc@redhat.com>
-
-	* archive.c (adjust_relative_path): Fix comment to prevent it
-	corrupting the auto-generated bfd.h.
-
-2011-05-31  Paul Brook  <paul@codesourcery.com>
-
-	* 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  <paul@codesourcery.com>
-
-	* 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  <nickc@redhat.com>
-
-	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  <hongjiu.lu@intel.com>
-
-	PR ld/12809
-	* elf64-x86-64.c (elf_x86_64_relocate_section): Handle
-	R_X86_64_TPOFF64 in executable.
-
-2011-05-26  Alan Modra  <amodra@gmail.com>
-
-	* 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  <gingold@adacore.com>
-
-	* 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  <dj@redhat.com>
-
-	* 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  <nickc@redhat.com>
-
-	* elf-m10300.c (mn10300_elf_mkobject): New function.
-	(bfd_elf32_mkobject): Define.
-
-2011-05-23  Alan Modra  <amodra@gmail.com>
-
-	* 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  <amodra@gmail.com>
-
-	* 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  <amodra@gmail.com>
-
-	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  <amodra@gmail.com>
-
-	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  <bernds@codesourcery.com>
-
-	* 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  <nickc@redhat.com>
-
-	PR ld/12761
-	* elflink.c (elf_link_add_object_symbols): Process .gnu.warning
-	sections when building shared libraries.
-
-2011-05-18  Rafał Krypa  <r.krypa@samsung.com>
-
-	PR ld/12778
-	* elf32-arm.c (elf32_arm_gc_sweep_hook): Use the computed dynamic
-	reloc pointer.
-
-2011-05-18  Tristan Gingold  <gingold@adacore.com>
-
-	* 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  <gingold@adacore.com>
-
-	* 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  <kikairoya@gmail.com>
-
-	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  <amodra@gmail.com>
-
-	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  <amodra@gmail.com>
-
-	* linker.c (_bfd_generic_link_add_one_symbol): Don't init u.undef.weak.
-
-2011-05-15  Richard Sandiford  <rdsandiford@googlemail.com>
-
-	* 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  <bernds@codesourcery.com>
-
-	* 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  <jbeulich@novell.com>
-
-	* config.bfd: Add targets x86_64-*-pe and x86_64-*-pep.
-
-2011-05-12  Jan Kratochvil  <jan.kratochvil@redhat.com>
-
-	* config.in: Regenerated.
+	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.
-	* 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.
+	* config.in: Regenerated.
 
-2011-05-10  Jan Kratochvil  <jan.kratochvil@redhat.com>
+2012-03-20  H.J. Lu  <hongjiu.lu@intel.com>
 
-	* 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.
+	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.
 
-2011-05-09  Paul Brook  <paul@codesourcery.com>
+	* 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.
 
-	* bfd-in.h (elf32_tic6x_fix_exidx_coverage): Add prototype.
+2012-03-16  Roland McGrath  <mcgrathr@google.com>
+
+	* 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  <matthew.gretton-dann@arm.com>
+
+	* 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  <mcgrathr@google.com>
+
+	* 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  <mcgrathr@google.com>
+
+	* 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  <amodra@gmail.com>
+
+	* 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  <edmar@freescale.com>
+
+	* archures.c: Add bfd_mach_ppc_e5500 and bfd_mach_ppc_e6500.
 	* 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.
+	* cpu-powerpc.c (bfd_powerpc_archs): Add entries for
+	bfd_mach_ppc_e5500 and bfd_mach_ppc_e6500.
 
-2011-05-09  Paul Brook  <paul@codesourcery.com>
+2012-03-09  H.J. Lu  <hongjiu.lu@intel.com>
 
-	* elf32-tic6x.c (is_tic6x_elf_unwind_section_name,
-	elf32_tic6x_fake_sections): New functions.
-	(elf_backend_fake_sections): Define.
+	PR ld/13817
+	* elf32-i386.c (elf_i386_relocate_section): Restore
+	R_386_IRELATIVE.
 
-2011-05-09  Paul Brook  <paul@codesourcery.com>
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Restore
+	R_X86_64_IRELATIVE.
 
-	* elf32-tic6x.c (elf32_tic6x_gc_mark_extra_sections): New function.
-	(elf_backend_gc_mark_extra_sections): Define.
+2012-03-08  Tristan Gingold  <gingold@adacore.com>
 
-2011-05-07  Dave Korn  <dave.korn.cygwin@gmail.com>
+	* vms-lib.c (_bfd_vms_lib_write_archive_contents): Set maximum
+	keylen according to archive kind.  Set nextvbn and nextrfa lhd
+	fields.  Add comments.
 
-	PR ld/12365
-	* cofflink.c (bfd_coff_link_input_bfd): Check for and warn about
-	references to symbols defined in discarded sections.
+2012-03-07  Nick Clifton  <nickc@redhat.com>
 
-2011-05-07  Dave Korn  <dave.korn.cygwin@gmail.com>
+	* 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.
 
-	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.
+2012-03-06  Jakub Jelinek  <jakub@redhat.com>
 
-2011-05-07  H.J. Lu  <hongjiu.lu@intel.com>
+	* elf64-x86-64.c (elf_x86_64_relocate_section): For R_X86_64_RELATIVE
+	set relocate to TRUE.
 
-	PR ld/12730
-	* elf.c (_bfd_elf_section_offset): Check SEC_ELF_REVERSE_COPY.
+2012-03-05  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
-	* elflink.c (elf_link_input_bfd): Reverse copy .ctors/.dtors
-	sections if needed.
+	PR ld/12152
+	* elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Also ignore
+	overflows for R_SPARC_UA32 in .stab sections.
 
-	* section.c (SEC_ELF_REVERSE_COPY): New.
+2012-03-01  Alan Modra  <amodra@gmail.com>
+
+	* elfxx-tilegx.c (tilegx_elf_relocate_section): Silence bogus warning.
+
+2012-02-27  Alan Modra  <amodra@gmail.com>
+
+	* 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  <amodra@gmail.com>
+
+	* elf32-spu.c (build_stub): Fix malloc under-allocation.
+
+2012-02-25  Walter Lee  <walt@tilera.com>
+	* 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  <walt@tilera.com>
+
+	* 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  <nickc@redhat.com>
+
+	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  <idsandoe@googlemail.com>
+
+	* 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  <idsandoe@googlemail.com>
+
+	* 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  <gingold@adacore.com>
+
+	* 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  <Andreas.Krebbel@de.ibm.com>
+
+	* elf32-s390.c (elf_s390_relocate_section): Support basr in the
+	GD->LE and LD->LE optimizations.
+
+2012-02-16  Alan Modra  <amodra@gmail.com>
+
+	PR binutils/13355
+	* elf32-rx.c (elf32_rx_relax_section): Correct width check.
+
+2012-02-13  Richard Henderson  <rth@redhat.com>
+
+	PR ld/13621
+	* linker.c (fix_syms): Force symbols outside any section into
+	bfd_abs_section_ptr.
+
+2012-02-13  Alan Modra  <amodra@gmail.com>
+
+	* 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  <jan.kratochvil@redhat.com>
+	    Nick Clifton  <nickc@redhat.com>
+
+	* oasys.c (oasys_write_header): Fix compilation warning on zero-sized
+	memset.
+
+2012-02-10  Iain Sandoe  <idsandoe@googlemail.com>
+
+	* 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  <idsandoe@googlemail.com>
+
+	* 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  <gingold@adacore.com>
+
+	* elfnn-ia64.c (elfNN_vms_object_p): Change comparison operator
+	to avoid infinite loop.  Add comments.
+
+2012-02-09  H.J. Lu  <hongjiu.lu@intel.com>
+
+	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  <amodra@gmail.com>
+
+	* 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  <amodra@gmail.com>
+
+	* 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 (vidya.praveen@atmel.com)
+
+	PR bfd/13410
+	* elf32-avr.c (elf32_avr_relax_section): Correct the
+	condition that qualifies the candidates for relaxation.
+
+2012-02-02  Tristan Gingold  <gingold@adacore.com>
+
+	* bfdio.c (real_fopen): Remove unused vms_modes variable.
+
+2012-02-02  Tristan Gingold  <gingold@adacore.com>
+
+	* mach-o.c (bfd_mach_o_read_header): Silent uninitialized
+	variable warning.
+
+2012-02-02  Tristan Gingold  <gingold@adacore.com>
+
+	* archive.c (bfd_slurp_armap): Fix thinko in cast.
+
+2012-01-31  H.J. Lu  <hongjiu.lu@intel.com>
+
+	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.
 
-2011-05-07  Anders Kaseorg  <andersk@ksplice.com>
+2012-01-27  Michael Eager  <eager@eagercon.com>
 
-	PR 12739
-	* libbfd.c (bfd_get_8, bfd_get_signed_8): Use const cast.
-	* bfd-in2.h: Regenerate.
+	* elf32-microblaze.c (create_got_section):
+	Reuse existing .rela.got section.
 
-2011-05-06  Tristan Gingold  <gingold@adacore.com>
+2012-01-23  Alan Modra  <amodra@gmail.com>
 
-	* 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.
+	* 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.
 
-2011-05-06  Richard Sandiford  <richard.sandiford@linaro.org>
+2012-01-20  Francois Gouget  <fgouget@codeweavers.com>
 
-	* 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  <bernds@codesourcery.com>
-
-	* 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  <gingold@adacore.com>
-
-	* 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  <amodra@gmail.com>
-
-	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  <paul@codesourcery.com>
-
-
-	* 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  <amodra@gmail.com>
-
-	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  <hongjiu.lu@intel.com>
-
-	* elf64-x86-64.c (elf_x86_64_merge_symbol): Correct parameter
-	names.
-
-2011-04-28  Tom Tromey  <tromey@redhat.com>
-
-	* bfdio.c (memory_bstat): Pass correct size to memset.
-
-2011-04-28  Mike Frysinger  <vapier@gentoo.org>
-
-	* dwarf2.c (dwarf_debug_sections): Mark const.
-	* elf.c (special_sections): Likewise.
-	* libbfd-in.h (dwarf_debug_sections): Likewise.
+	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.
 
-2011-04-26  Kai Tietz  <ktietz@redhat.com>
+2012-01-20  Ulrich Weigand  <ulrich.weigand@linaro.org>
 
-	* coffcode.h (sec_to_styp_flags): Allow linkonce for
-	debugging sections.
+	* 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.
 
-2011-04-26  Tristan Gingold  <gingold@adacore.com>
+2012-01-19  Tristan Gingold  <gingold@adacore.com>
 
-	* coff64-rs6000.c: Convert to ISO-C.  Remove PARAMS and PTR macros.
+	* pef.c: Add a comment.
+	* xsym.c: Likewise.
 
-2011-04-24  Alan Modra  <amodra@gmail.com>
+2012-01-17  Alan Modra  <amodra@gmail.com>
 
-	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.
+	* 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.
 
-2011-04-22  H.J. Lu  <hongjiu.lu@intel.com>
+2012-01-16  Daniel Green  <venix1@gmail.com>
 
-	* 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.
+	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.
 
-2011-04-21  H.J. Lu  <hongjiu.lu@intel.com>
+2012-01-13  Iain Sandoe  <idsandoe@googlemail.com>
 
-	PR ld/12694
-	* elf32-i386.c (elf_i386_readonly_dynrelocs): Skip local IFUNC
-	symbols.
-	* elf64-x86-64.c (elf_x86_64_readonly_dynrelocs): Likewise.
+	* mach-o.c (bfd_mach_o_build_dysymtab_command): Handle absolute
+	indirect symbols.
 
-2011-04-21  H.J. Lu  <hongjiu.lu@intel.com>
+2012-01-13  Iain Sandoe  <idsandoe@googlemail.com>
 
-	* 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.
+	* mach-o.c (bfd_mach_o_write_relocs): Move computation of relocs file
+	position from here... to (bfd_mach_o_build_seg_command): Here.
 
-2011-04-20  Tristan Gingold  <gingold@adacore.com>
+2012-01-12  Iain Sandoe  <idsandoe@googlemail.com>
 
-	* config.bfd (alpha*-*-*vms*, ia64*-*-*vms*): Define targ_selvecs.
+	* 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.
 
-2011-04-20  Alan Modra  <amodra@gmail.com>
+2012-01-11  Iain Sandoe  <idsandoe@googlemail.com>
 
-	* 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.
+	* 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.
 
-2011-04-20  Jan Kratochvil  <jan.kratochvil@redhat.com>
+2012-01-11  Iain Sandoe  <idsandoe@googlemail.com>
 
-	* elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): Fix +1 overrun of
-	memmove elements.
+	* mach-o.c (bfd_mach_o_build_commands): Make the building of each
+	command type independent.
 
-2011-04-20  Alan Modra  <amodra@gmail.com>
+2012-01-11  Alan Modra  <amodra@gmail.com>
 
-	* 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  <amodra@gmail.com>
-
-	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  <amodra@gmail.com>
-
-	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  <gingold@adacore.com>
-
-	* coff-rs6000.c: Convert to ISO-C.  Remove PARAMS macro.
-
-2011-04-18  Alan Modra  <amodra@gmail.com>
-
-	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  <jan.kratochvil@redhat.com>
-
-	* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Do not check for
-	SEC_LOAD.
-
-2011-04-15  Sergio Durigan Junior  <sergiodj@redhat.com>
-
-	* 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
+	* 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.
 
-2011-04-12  Richard Henderson  <rth@redhat.com>
+2012-01-10  H.J. Lu  <hongjiu.lu@intel.com>
 
-	* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Do not
-	exclude empty .got sections.
+	PR ld/13581
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Remove ABI_64_P
+	check on R_X86_64_PCXX.
 
-2011-04-11  H.J. Lu  <hongjiu.lu@intel.com>
+2012-01-10  Tristan Gingold  <gingold@adacore.com>
 
-	* elf32-i386.c (elf_i386_reloc_type_lookup): Fix the out of bound
-	array access for BFD_RELOC_386_IRELATIVE.
+	* mach-o.c (bfd_mach_o_build_commands): Avoid uninitialized false
+	warning.
 
-2011-04-11  Bernd Schmidt  <bernds@codesourcery.com>
+2012-01-10  Tristan Gingold  <gingold@adacore.com>
 
-	* elf32-tic6x.c (elf32_tic6x_check_relocs): Initialize pc_count field.
+	* 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.
 
-2011-04-11  Mark Wielaard  <mjw@redhat.com>
+2012-01-09  Iain Sandoe  <idsandoe@googlemail.com>
 
-	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.
+	* 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.
 
-2011-04-11  Alan Modra  <amodra@gmail.com>
+2012-01-06  Nick Clifton  <nickc@redhat.com>
 
-	* 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.
+	PR binutils/13121
+	* reloc.c (bfd_generic_lookup_section_flags): Rename 'finfo' to
+	'flaginfo' to avoid conflicts with AIX system headers.
 
-2011-04-10  Richard Sandiford  <rdsandiford@googlemail.com>
+2012-01-06  Tristan Gingold  <gingold@adacore.com>
 
-	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.
+	* bfdio.c (bfd_bread): Use arelt_size macro.
 
-2011-04-09  H.J. Lu  <hongjiu.lu@intel.com>
+2012-01-06  Tristan Gingold  <gingold@adacore.com>
 
-	* elf32-i386.c: Update copyright year.
-	* elf64-x86-64.c: Likewise.
+	* config.bfd (i[3-7]86-*-darwin*): Define targ64_selvecs.
 
-2011-04-09  Kai Tietz  <ktietz@redhat.com>
+2012-01-05  Nick Clifton  <nickc@redhat.com>
 
-	* 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.
+	PR ld/12161
+	* elf32-avr.c (elf32_avr_relax_delete_bytes): Read in relocs if
+	necessary.
 
-2011-04-09  H.J. Lu  <hongjiu.lu@intel.com>
+2012-01-05  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
-	* elf32-i386.c (elf_i386_relocate_section): Return relocation
-	error on unsupported relocation.
-	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
+	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.
 
-2011-04-09  H.J. Lu  <hongjiu.lu@intel.com>
+2012-01-04  Tristan Gingold  <gingold@adacore.com>
 
-	PR binutils/12657
-	* hosts/x86-64linux.h (elf_prstatus32): Replace __pid_t with
-	pid_t.
+	* mach-o.c (bfd_mach_o_fat_stat_arch_elt): New function.
+	(bfd_mach_o_generic_stat_arch_elt): Adjust.
 
-2011-04-08  H.J. Lu  <hongjiu.lu@intel.com>
+2012-01-04  Tristan Gingold  <gingold@adacore.com>
 
-	PR ld/12654
-	* elf32-i386.c (elf_i386_relocate_section): Check !executable
-	instead of shared for R_386_TLS_LDO_32.
+	* 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.
 
-2011-04-08  Tristan Gingold  <gingold@adacore.com>
+2012-01-04  Tristan Gingold  <gingold@adacore.com>
 
-	* Makefile.am (SOURCE_HFILES): Remove xcoff-target.h
-	* coff-pmac: Remove
-	* xcoff-target.h: Remove
-	* Makefile.in: Regenerate.
+	* 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.
 
-2011-04-07  Cary Coutant  <ccoutant@google.com>
+2012-01-04  Tristan Gingold  <gingold@adacore.com>
 
-	* dwarf2.c (scan_unit_for_symbols): Check for DW_AT_specification.
+	* mach-o.h (bfd_mach_o_fvmlib_command): New structure.
+	(bfd_mach_o_load_command): Add fvmlib field.
 
-2011-04-07  Paul Brook  <paul@codesourcery.com>
+	* mach-o.c (bfd_mach_o_read_fvmlib): New function.
+	(bfd_mach_o_read_command): Handle fvmlib.
 
-	* 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.
+2012-01-04  Tristan Gingold  <gingold@adacore.com>
 
-2011-04-06  Joseph Myers  <joseph@codesourcery.com>
+	* mach-o.c (bfd_mach_o_convert_architecture): Reindent.
+	Decode msubtype for ARM.
 
-	* 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.
+2012-01-04  Tristan Gingold  <gingold@adacore.com>
 
-2011-04-01  Tristan Gingold  <gingold@adacore.com>
+	* mach-o.c (bfd_mach_o_get_synthetic_symtab): Add comments.
 
-	* elfxx-ia64.c: include bfd_stdint.h
+2012-01-04  Tristan Gingold  <gingold@adacore.com>
 
-2011-03-31  Jan Kratochvil  <jan.kratochvil@redhat.com>
+	* mach-o.h: Reindent header.
+	(bfd_mach_o_encryption_info_command): New structure.
+	(bfd_mach_o_load_command): Add encryption_info field.
 
-	* elf32-tic6x.c (elf32_tic6x_relocate_section): Remove unused variable
-	dynobj and its initialization.
+	* 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.
 
-2011-03-31  Tristan Gingold  <gingold@adacore.com>
+2012-01-04  Shinichiro Hamaji  <shinichiro.hamaji@gmail.com>
 
-	* 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.
+	* 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.
 
-2011-03-31  Tristan Gingold  <gingold@adacore.com>
+2012-01-03  Iain Sandoe  <idsandoe@googlemail.com>
 
-	* 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
+	* 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.
 
-2011-03-31  Bernd Schmidt  <bernds@codesourcery.com>
+2012-01-03  Iain Sandoe  <idsandoe@googlemail.com>
 
-	* 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.
+	* mach-o.c (bfd_mach_o_mangle_symbols): Correct typo.
 
-	* 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.
+2012-01-03  Iain Sandoe  <idsandoe@googlemail.com>
 
-2011-03-31  Tristan Gingold  <gingold@adacore.com>
+	* 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.
 
-	* coffcode.h (coff_slurp_symbol_table): Silently discard C_NULL
-	entry on xcoff when value is C_NULL_VALUE.
-
-2011-03-31  Tristan Gingold  <gingold@adacore.com>
-
-	* libcoff-in.h (exec_hdr): Remove.
-	* libcoff.h: Regenerate.
-
-2011-03-30  Nick Clifton  <nickc@redhat.com>
-
-	* po/da.po: Updated Danish translation.
-
-2011-03-29  Richard Henderson  <rth@redhat.com>
-
-	* 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  <binutils@marino.st>
-
-	* 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  <msnyder@vmware.com>
-
-	* coffcode.h (coff_set_alignment_hook): Check return of bfd_seek.
-
-2011-03-25  Tristan Gingold  <gingold@adacore.com>
-
-	* vms-alpha.c (_bfd_vms_find_nearest_dst_line): Allow the use
-	of find_nearest_line on object files.
-
-2011-03-25  Tristan Gingold  <gingold@adacore.com>
-
-	* 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  <amodra@gmail.com>
-
-	* 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  <eric.weddington@atmel.com>
-
-	* bfd-in2.h: Regenerate.
-
-2011-03-22  Eric B. Weddington  <eric.weddington@atmel.com>
-
-	* 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  <richard.sandiford@linaro.org>
-
-	* 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  <richard.sandiford@linaro.org>
-
-	* 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  <richard.sandiford@linaro.org>
-
-	* 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  <richard.sandiford@linaro.org>
-
-	* 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  <richard.sandiford@linaro.org>
-
-	* 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  <richard.sandiford@linaro.org>
-
-	* 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  <hongjiu.lu@intel.com>
-
-	* 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  <amodra@gmail.com>
-
-	* elf64-ppc.c (ppc64_elf_relocate_section): Provide section/offset
-	for LO_DS error message and correct multiple.
-
-2011-03-10  Alan Modra  <amodra@gmail.com>
-
-	* 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  <msnyder@vmware.com>
-
-	* 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  <amodra@gmail.com>
-
-	* 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  <msnyder@vmware.com>
-
-	* 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  <hongjiu.lu@intel.com>
-
-	* 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  <bernds@codesourcery.com>
-
-	* elflink.c (is_reloc_section): Remove function.
-	(get_dynamic_reloc_section_name): Construct string manually.
-
-2011-02-28  Kai Tietz  <kai.tietz@onevision.com>
-
-	* 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  <amodra@gmail.com>
-
-	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 <respindola@mozilla.com>
-
-	* 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  <schwab@redhat.com>
-
-	* 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  <gingold@adacore.com>
-
-	* vms-alpha.c (alpha_vms_link_add_archive_symbols): Add a comment.
-
-2011-02-15  Alan Modra  <amodra@gmail.com>
-
-	* elf64-ppc.c (ppc64_elf_edit_toc): Reinstate second read of
-	toc relocs.  Fuss over free(NULL).
-
-2011-02-14  Mike Frysinger  <vapier@gentoo.org>
-
-	* elflink.c (bfd_elf_size_dynamic_sections): Add
-	bfd_get_symbol_leading_char to the start of newname.
-
-2011-02-13  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
-
-	* configure: Regenerate.
-
-2011-02-09  Alan Modra  <amodra@gmail.com>
-
-	* 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  <nickc@redhat.com>
-
-	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  <amodra@gmail.com>
-
-	* 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  <amodra@gmail.com>
-
-	* 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  <joseph@codesourcery.com>
-
-	* elf32-ppc.c (ppc_elf_link_hash_newfunc): Initialize has_sda_refs
-	field.
-
-2011-01-22  Richard Sandiford  <rdsandiford@googlemail.com>
-
-	* elfxx-mips.c (_bfd_mips_elf_merge_private_bfd_data): Ignore
-	common sections too.
-
-2011-01-18  H.J. Lu  <hongjiu.lu@intel.com>
-
-	* elf64-x86-64.c (elf_backend_want_plt_sym): Redefine to 0 after
-	Solaris target.
-
-2011-01-18  Pierre Muller  <muller@ics.u-strasbg.fr>
-
-	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  <richard.sandiford@linaro.org>
-
-	* 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  <richard.sandiford@linaro.org>
-
-	* elf32-arm.c (elf32_arm_gc_sweep_hook): Remove all registered
-	dynamic relocs for the removed section.
-
-2011-01-15  H.J. Lu  <hongjiu.lu@intel.com>
-
-	* elf64-x86-64.c (elf_x86_64_check_relocs): Check invalid x32
-	relocations.
-
-2011-01-14  H.J. Lu  <hongjiu.lu@intel.com>
-
-	* 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  <amodra@gmail.com>
-
-	* 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  <hongjiu.lu@intel.com>
-
-	* 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  <grassman@gmail.com>
-
-	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  <nathan@codesourcery.com>
-	    Glauber de Oliveira Costa  <glommer@gmail.com>
-
-	* 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  <hongjiu.lu@intel.com>
-
-	* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Optimized.
-
-2011-01-06  H.J. Lu  <hongjiu.lu@intel.com>
-
-	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  <dj@redhat.com>
-
-	* 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  <hongjiu.lu@intel.com>
-
-	* 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
+For older changes see ChangeLog-2011
 
 Local Variables:
 mode: change-log
diff --git a/bfd/ChangeLog-2011 b/bfd/ChangeLog-2011
new file mode 100644
index 0000000..9af9565
--- /dev/null
+++ b/bfd/ChangeLog-2011
@@ -0,0 +1,3383 @@
+2011-12-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* elf32-rl78.c (rl78_elf_relocate_section, rl78_dump_symtab)
+	(rl78_elf_relax_section): Remove debug prints.
+
+2011-12-23  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* elf32-rl78.c (rl78_elf_relocate_section, rl78_elf_relax_section): Use
+	BFD_VMA_FMT.
+
+2011-12-23  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* elf32-rl78.c (prev_alignment, sec_start): Remove unused variables.
+
+2011-12-23  Tristan Gingold  <gingold@adacore.com>
+
+	* vms-lib.c (vms_traverse_index): Move pointer update code.
+
+2011-12-22  DJ Delorie  <dj@redhat.com>
+
+	* 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  <schwidefsky@de.ibm.com>
+
+	* 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  <ulrich.weigand@linaro.org>
+
+	* elf32-arm.c (elf32_arm_nabi_grok_psinfo): Fill in core_pid.
+
+2011-12-19  Iain Sandoe  <idsandoe@googlemail.com>
+
+	* 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  <cltang@codesourcery.com>
+
+	* 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  <cltang@codesourcery.com>
+	    Catherine Moore  <clm@codesourcery.com>
+	    Sandra Loosemore  <sandra@codesourcery.com>
+	    Richard Sandiford  <rdsandiford@googlemail.com>
+
+	* 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  <shinichiro.hamaji@gmail.com>
+
+	* 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  <kevinb@redhat.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	* elf64-x86-64.c (ELF32_DYNAMIC_INTERPRETER): Set to
+	 "/lib/ldx32.so.1".
+
+2011-12-15  Iain Sandoe  <iains@gcc.gnu.org>
+
+	* 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  <shinichiro.hamaji@gmail.com>
+
+	* 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  <iains@gcc.gnu.org>
+
+	* 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  <nickc@redhat.com>
+
+	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  <iains@gcc.gnu.org>
+
+	* 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  <shinichiro.hamaji@gmail.com>
+
+	* 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  <gingold@adacore.com>
+
+	* 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  <cltang@codesourcery.com>
+
+	* 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  <iains@gcc.gnu.org>
+
+	* 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  <dave.anglin@nrc-cnrc.gc.ca>
+
+	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  <david.daney@cavium.com>
+
+	* 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  <apinski@cavium.com>
+            Adam Nemet  <anemet@caviumnetworks.com>
+
+	* 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  <amodra@gmail.com>
+
+	PR ld/12772
+	* elflink.c (elf_gc_sweep_symbol): Discard unmarked symbols
+	defined in shared libraries.
+
+2011-12-07  Tristan Gingold  <gingold@adacore.com>
+
+	* 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  <uweigand@de.ibm.com>
+
+	* 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  <gingold@adacore.com>
+
+	* mach-o.c (bfd_mach_o_read_symtab_symbol): Accept indirect symbols.
+
+2011-12-05  Tristan Gingold  <gingold@adacore.com>
+
+	* 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  <gingold@adacore.com>
+
+	* 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  <amodra@gmail.com>
+
+	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  <amodra@gmail.com>
+
+	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  <mikpe@it.uu.se>
+
+	* 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  <hp@axis.com>
+
+	* 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  <apinski@cavium.com>
+
+	* 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  <gingold@adacore.com>
+
+	* vms-lib.c (get_idxlen): Add comments.  Fix type in sizeof.
+	(vms_write_index): Add comments.
+
+2011-11-22  DJ Delorie  <dj@redhat.com>
+
+	* 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  <Daniel.Calcoen@cern.ch>
+
+	* elf32-rx.c (rx_elf_object_p): Correct typo: lma->vma.
+
+2011-11-22  Tristan Gingold  <gingold@adacore.com>
+
+	* mach-o.c (bfd_mach_o_print_symbol): Display COM for common
+	symbols.  Print section name in brackets.
+
+2011-11-21  Andreas Tobler  <andreast@fgznet.ch>
+
+	* 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  <philipp@thogro.org>
+
+	* 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  <macro@codesourcery.com>
+
+	* 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  <amodra@gmail.com>
+	    Andreas Tobler  <andreast@fgznet.ch>
+
+	* 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  <maxim@codesourcery.com>
+
+	* elfxx-mips.c (mips_n64_exec_plt0_entry): Use 64-bit move.
+
+2011-11-08  Nick Clifton  <nickc@redhat.com>
+
+	* elf-m10300.c (mn10300_elf_relax_section): Fix check for an
+	immediate move into an address register.
+
+2011-11-09  Alan Modra  <amodra@gmail.com>
+
+	* elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Mark syms in
+	executables when export_dynamic.
+
+2011-11-08  Alan Modra  <amodra@gmail.com>
+
+	* 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  <dave.anglin@nrc-cnrc.gc.ca>
+
+	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  <dj@redhat.com>
+
+	* elf32-rl78.c (rl78_elf_merge_private_bfd_data): Delete unused
+	variable.
+
+2011-11-02  Jan Beulich  <jbeulich@suse.com>
+
+	* 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  <dj@redhat.com>
+
+	* 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  <nickc@redhat.com>
+
+	PR ld/13049
+	* elf64-ppc.c (STUB_SUFFIX): Revert previous delta.
+	* elf32-hppa.c (STUB_SUFFIX): Likewise.
+
+2011-10-25  Joern Rennecke  <joern.rennecke@embecosm.com>
+
+	* 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  <macro@codesourcery.com>
+
+	* elfxx-mips.c (_bfd_mips_elf_symbol_processing): Remove
+	assertions.
+
+2011-10-24  Eugeniy Meshcheryakov  <eugen@debian.org>
+
+	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  <nickc@redhat.com>
+
+	* po/ja.po: Updated Japanese translation.
+
+2011-10-24  Pau Garcia i Quiles  <pgquiles@elpauer.org>
+
+	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  <hongjiu.lu@intel.com>
+
+	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  <hongjiu.lu@intel.com>.
+
+	* 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  <hongjiu.lu@intel.com>
+
+	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  <nickc@redhat.com>
+
+	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  <amodra@gmail.com>
+
+	* 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  <amodra@gmail.com>
+
+	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  <amodra@gmail.com>
+
+	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  <amodra@gmail.com>
+
+	PR ld/13254
+	* elflink.c (bfd_elf_final_link): Emit error_textrel error.
+
+2011-10-18  David S. Miller  <davem@davemloft.net>
+
+	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  <amodra@gmail.com>
+
+	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  <hp@axis.com>
+
+	* 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  <richard.sandiford@linaro.org>
+
+	* elf32-arm.c (elf32_arm_final_link_relocate): Mark PLT calls via
+	stubs as resolved.
+
+2011-10-11  Alan Modra  <amodra@gmail.com>
+
+	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  <amodra@gmail.com>
+
+	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  <nickc@redhat.com>
+
+	* 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  <amodra@gmail.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	PR ld/13250
+	* elflink.c (elf_link_add_object_symbols): Preserve the maximum
+	alignment and size for common symbols.
+
+2011-10-08  Alan Modra  <amodra@gmail.com>
+
+	PR ld/13229
+	PR ld/13244
+	* elflink.c (elf_link_add_object_symbols): Don't make IR symbols
+	dynamic.
+
+2011-10-08  Alan Modra  <amodra@gmail.com>
+
+	PR ld/13229
+	* elflink.c (elf_link_output_extsym): Strip defined plugin symbols
+	even when strip_discarded is false.
+
+2011-10-05  Kai Tietz  <ktietz@redhat.com>
+
+	* 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  <dj@redhat.com>
+	    Nick Clifton  <nickc@redhat.com>
+
+	* 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  <gingold@adacore.com>
+
+	* 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  <amodra@gmail.com>
+
+	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  <amodra@gmail.com>
+
+	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  <hongjiu.lu@intel.com>
+
+	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  <ktietz@redhat.com>
+
+	* coffcode.h (sec_to_styp_flags): Handle
+	SEC_LINK_DUPLICATES_SAME_CONTENTS, and
+	SEC_LINK_DUPLICATES_SAME_SIZE.
+
+2011-09-22  Tristan Gingold  <gingold@adacore.com>
+
+	* configure.in: Bump version to 2.22.51
+	* configure: Regenerate.
+
+2011-09-21  David S. Miller  <davem@davemloft.net>
+
+	* 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  <gingold@adacore.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	PR ld/13177
+	* elflink.c (elf_gc_sweep_symbol): Also hide symbols without PLT
+	nor GOT references.
+
+2011-09-15  H.J. Lu  <hongjiu.lu@intel.com>
+
+	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  <hongjiu.lu@intel.com>
+
+	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  <ktietz@redhat.com>
+
+	* peicode.h (pe_ILF_build_a_bfd): Don't remove leading underscore
+	for targets without symbol_leading_char.
+
+2011-09-08  Bernd Jendrissek  <bernd.jendrissek@gmail.com>
+
+	* bfdwin.c (bfd_get_file_window): Fix memory leak.
+
+2011-09-07  Alan Modra  <amodra@gmail.com>
+
+	PR ld/13131
+	* bfd/elf64-ppc.c (adjust_toc_syms): Ensure ppc64_elf_howto_table
+	is initialized.
+
+2011-09-06  Alan Modra  <amodra@gmail.com>
+
+	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  <christophe.lyon@st.com>
+
+	* elf32-arm.c (elf32_arm_output_arch_local_syms): Skip excluded
+	sections.
+
+2011-08-26  Nick Clifton  <nickc@redhat.com>
+
+	* po/es.po: Updated Spanish translation.
+
+2011-08-19  Alan Modra  <amodra@gmail.com>
+
+	* 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  <gingold@adacore.com>
+
+	* mach-o.c (bfd_mach_o_read_segment): Initialize list.
+
+2011-08-17  Tristan Gingold  <gingold@adacore.com>
+
+	* mach-o.c (bfd_mach_o_write_section_32): Fix typo.
+
+2011-08-17  Alan Modra  <amodra@gmail.com>
+
+	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  <amodra@gmail.com>
+
+	* 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  <amodra@gmail.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	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  <matthew.gretton-dann@arm.com>
+
+	* 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  <gingold@adacore.com>
+
+	* 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  <gingold@adacore.com>
+
+	* 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  <gingold@adacore.com>
+
+	* 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  <gingold@adacore.com>
+
+	* 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  <gingold@adacore.com>
+
+	* 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  <gingold@adacore.com>
+
+	* 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  <kettenis@gnu.org>
+
+	* netbsd-core.c (netbsd_core_vec): Init match_priority field.
+
+2011-08-05  Alan Modra  <amodra@gmail.com>
+
+	* 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  <amodra@gmail.com>
+
+	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  <amodra@gmail.com>
+
+	* 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  <gingold@adacore.com>
+
+	* 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  <gingold@adacore.com>
+
+	* 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  <macro@codesourcery.com>
+
+	* 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  <amodra@gmail.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	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  <macro@codesourcery.com>
+
+	* elfxx-mips.c (check_br32): Fix return type.
+
+2011-07-29  Maciej W. Rozycki  <macro@codesourcery.com>
+
+	* elfxx-mips.c (bz_insn_16): Correct opcode mask.
+
+2011-07-29  Maciej W. Rozycki  <macro@codesourcery.com>
+
+	* 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  <mcgrathr@google.com>
+
+	* 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  <mikulas@artax.karlin.mff.cuni.cz>
+
+	* elf64-hppa.c (elf_hppa_final_link_relocate): Fix handling of out
+	of range branches.
+
+2011-07-26  Jakub Jelinek  <jakub@redhat.com>
+
+	* dwarf2.c (dwarf_debug_sections): Add .debug_macro
+	and .zdebug_macro entry.
+	(dwarf_debug_section_enum): Add debug_macro.
+
+2011-07-26  Alan Modra  <amodra@gmail.com>
+
+	* 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  <hp@bitrange.com>
+
+	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  <fu@mips.com>
+	    Ilie Garbacea  <ilie@mips.com>
+	    Maciej W. Rozycki  <macro@codesourcery.com>
+	    Joseph Myers  <joseph@codesourcery.com>
+	    Catherine Moore  <clm@codesourcery.com>
+	    Richard Sandiford  <rdsandiford@googlemail.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	* 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  <jan.kratochvil@redhat.com>
+
+	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  <amodra@gmail.com>
+
+	* configure.in: Bump version.
+	* configure: Regenerate.
+
+2011-07-14  Alan Modra  <amodra@gmail.com>
+
+	* linker.c (_bfd_generic_section_already_linked): Set l_flags.
+	* elf-bfd.h (struct already_linked): Forward declare.
+
+2011-07-14  Alan Modra  <amodra@gmail.com>
+
+	* elflink.c (_bfd_elf_fix_symbol_flags): Loop on indirect syms.
+	(_bfd_elf_adjust_dynamic_symbol): Remove FIXME.
+
+2011-07-14  Alan Modra  <amodra@gmail.com>
+
+	* 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  <nickc@redhat.com>
+
+	* elf32-arm.c (elf32_arm_section_flags): Delete.
+	(elf_backend_section_flags): Remove.
+
+2011-07-11  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR ld/12982
+	* elflink.c (bfd_elf_size_dynamic_sections): Also skip BFD_PLUGIN
+	when setting stack_flags.
+
+2011-07-11  Catherine Moore  <clm@codesourcery.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	PR ld/12978
+	* elfnn-ia64.c (count_dyn_reloc): Fix a typo.
+
+2011-07-09  Alan Modra  <amodra@gmail.com>
+
+	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  <hongjiu.lu@intel.com>
+
+	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  <gingold@adacore.com>
+
+	* mach-o.h: Move loader related definitions to
+	include/mach-o/loader.h.  Include it.
+
+2011-07-05  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* elf64-x86-64.c (elf_backend_post_process_headers): Always
+	define to _bfd_elf_set_osabi.
+
+2011-07-03  Samuel Thibault  <samuel.thibault@gnu.org>
+	    Thomas Schwinge  <thomas@schwinge.name>
+
+	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  <iant@google.com>
+
+	* elf32-i386.c (elf_i386_eh_frame_plt): Correct expression: change
+	DW_OP_lit3 to DW_OP_lit2.
+
+2011-07-01  Alan Modra  <amodra@gmail.com>
+
+	* 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  <bernds@codesourcery.com>
+
+	* bfd/elf32-tic6x.c (elf32_tic6x_set_osabi): Also set it if
+	link_info is NULL.
+
+2011-06-28  Tristan Gingold  <gingold@adacore.com>
+
+	* 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 <fawzi.mohamed@nokia.com>
+
+	* mach-o.c (bfd_mach_o_read_command): Also ignore
+	BFD_MACH_O_LC_ROUTINES_64.
+
+2011-06-27  Tristan Gingold  <gingold@adacore.com>
+
+	* vms-alpha.c (_bfd_vms_write_etir): Use 'section' to get current
+	section target index.
+
+2011-06-27  Nick Clifton  <nickc@redhat.com>
+
+	* cisco-core.c (cisco_core_little_vec): Add initialization of
+	match_priority field.
+
+2011-06-27  Tristan Gingold  <gingold@adacore.com>
+
+	* 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  <gingold@adacore.com>
+
+	* vms-misc.c (vms_time_to_time_t): Adjust overflow detection.
+	Add comment.
+
+2011-06-25  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* 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  <jan.kratochvil@redhat.com>
+
+	* 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  <rth@redhat.com>
+
+	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  <gingold@adacore.com>
+
+	* vms-alpha.c (alpha_vms_slurp_relocs): Add a guard for relocs in the
+	absolute section.
+
+2011-06-24  Alan Modra  <amodra@gmail.com>
+
+	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  <kkojima@rr.iij4u.or.jp>
+
+	* 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  <rth@redhat.com>
+
+	* 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  <ramana.radhakrishnan@linaro.org>
+
+	* elf32-arm.c (elf32_arm_final_link_relocate): Allow R_ARM_TLS_LE32
+	for PIE.
+
+2011-06-22  Alan Modra  <amodra@gmail.com>
+
+	* elflink.c (_bfd_elf_merge_symbol): Allow type changes for
+	plugin symbols.  Fix segfault on linker scrip defined syms.
+
+2011-06-20  Jakub Jelinek  <jakub@redhat.com>
+
+	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  <hongjiu.lu@intel.com>
+
+	* elf64-x86-64.c (elf_backend_post_process_headers): Defined
+	for x32.
+
+2011-06-16  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	* elf64-x86-64.c (elf_x86_64_grok_prstatus): Support x32.
+	(elf_x86_64_grok_psinfo): Likewise.
+
+2011-06-16  Nick Clifton  <nickc@redhat.com>
+
+	* elf.c (elf_find_function): Fail if not provided with a symbol
+	table.
+
+2011-06-15  Ulrich Weigand  <ulrich.weigand@linaro.org>
+
+	* 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  <rth@redhat.com>
+
+	* 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  <amodra@gmail.com>
+
+	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  <amodra@gmail.com>
+
+	* 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  <amodra@gmail.com>
+
+	* 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  <amodra@gmail.com>
+
+	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  <nickc@redhat.com>
+
+	* 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  <walt@tilera.com>
+
+	* 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  <amodra@gmail.com>
+
+	* 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  <nickc@redhat.com>
+
+	* 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  <gingold@adacore.com>
+
+	* 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  <gingold@adacore.com>
+
+	* bfd.c (bfd_get_sign_extend_vma): Handle aixcoff.
+
+2011-06-09  Nick Clifton  <nickc@redhat.com>
+
+	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  <hongjiu.lu@intel.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	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  <gingold@adacore.com>
+
+	* makefile.vms (OBJS): Add elfxx-ia64.obj
+	Remove vax case.
+
+2011-06-08  Alan Modra  <amodra@gmail.com>
+
+	* aix386-core.c, * cisco-core.c, * hpux-core.c, * osf-core.c,
+	* sco5-core.c: Init match_priority field.
+
+2011-06-08  Alan Modra  <amodra@gmail.com>
+
+	* elflink.c (_bfd_elf_archive_symbol_lookup): Follow warning and
+	indirect links here.
+
+2011-06-07  Joel Brobecker  <brobecker@adacore.com>
+
+	* irix-core.c (irix_core_vec): Add match_priority field.
+
+2011-06-06  Alan Modra  <amodra@gmail.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	PR ld/12842
+	* elfcode.h (elf_object_p): Revert the last change.
+
+2011-06-04  Alan Modra  <amodra@gmail.com>
+
+	* 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  <bertram.felgenhauer@gmail.com>
+
+	PR ld/12682
+	* hash.c (higher_primer_number): Add more, small, prime numbers.
+	(bfd_hash_set_default_size): Likewise.
+
+2011-06-02  Nick Clifton  <nickc@redhat.com>
+
+	* 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  <dj@redhat.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	* 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  <nickc@redhat.com>
+
+	* archive.c (adjust_relative_path): Fix comment to prevent it
+	corrupting the auto-generated bfd.h.
+
+2011-05-31  Paul Brook  <paul@codesourcery.com>
+
+	* 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  <paul@codesourcery.com>
+
+	* 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  <nickc@redhat.com>
+
+	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  <hongjiu.lu@intel.com>
+
+	PR ld/12809
+	* elf64-x86-64.c (elf_x86_64_relocate_section): Handle
+	R_X86_64_TPOFF64 in executable.
+
+2011-05-26  Alan Modra  <amodra@gmail.com>
+
+	* 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  <gingold@adacore.com>
+
+	* 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  <dj@redhat.com>
+
+	* 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  <nickc@redhat.com>
+
+	* elf-m10300.c (mn10300_elf_mkobject): New function.
+	(bfd_elf32_mkobject): Define.
+
+2011-05-23  Alan Modra  <amodra@gmail.com>
+
+	* 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  <amodra@gmail.com>
+
+	* 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  <amodra@gmail.com>
+
+	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  <amodra@gmail.com>
+
+	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  <bernds@codesourcery.com>
+
+	* 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  <nickc@redhat.com>
+
+	PR ld/12761
+	* elflink.c (elf_link_add_object_symbols): Process .gnu.warning
+	sections when building shared libraries.
+
+2011-05-18  Rafał Krypa  <r.krypa@samsung.com>
+
+	PR ld/12778
+	* elf32-arm.c (elf32_arm_gc_sweep_hook): Use the computed dynamic
+	reloc pointer.
+
+2011-05-18  Tristan Gingold  <gingold@adacore.com>
+
+	* 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  <gingold@adacore.com>
+
+	* 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  <kikairoya@gmail.com>
+
+	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  <amodra@gmail.com>
+
+	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  <amodra@gmail.com>
+
+	* linker.c (_bfd_generic_link_add_one_symbol): Don't init u.undef.weak.
+
+2011-05-15  Richard Sandiford  <rdsandiford@googlemail.com>
+
+	* 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  <bernds@codesourcery.com>
+
+	* 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  <jbeulich@novell.com>
+
+	* config.bfd: Add targets x86_64-*-pe and x86_64-*-pep.
+
+2011-05-12  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* 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  <jan.kratochvil@redhat.com>
+
+	* 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  <paul@codesourcery.com>
+
+	* 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  <paul@codesourcery.com>
+
+	* 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  <paul@codesourcery.com>
+
+	* elf32-tic6x.c (elf32_tic6x_gc_mark_extra_sections): New function.
+	(elf_backend_gc_mark_extra_sections): Define.
+
+2011-05-07  Dave Korn  <dave.korn.cygwin@gmail.com>
+
+	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  <dave.korn.cygwin@gmail.com>
+
+	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  <hongjiu.lu@intel.com>
+
+	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  <andersk@ksplice.com>
+
+	PR 12739
+	* libbfd.c (bfd_get_8, bfd_get_signed_8): Use const cast.
+	* bfd-in2.h: Regenerate.
+
+2011-05-06  Tristan Gingold  <gingold@adacore.com>
+
+	* 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  <richard.sandiford@linaro.org>
+
+	* 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  <bernds@codesourcery.com>
+
+	* 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  <gingold@adacore.com>
+
+	* 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  <amodra@gmail.com>
+
+	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  <paul@codesourcery.com>
+
+
+	* 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  <amodra@gmail.com>
+
+	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  <hongjiu.lu@intel.com>
+
+	* elf64-x86-64.c (elf_x86_64_merge_symbol): Correct parameter
+	names.
+
+2011-04-28  Tom Tromey  <tromey@redhat.com>
+
+	* bfdio.c (memory_bstat): Pass correct size to memset.
+
+2011-04-28  Mike Frysinger  <vapier@gentoo.org>
+
+	* 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  <ktietz@redhat.com>
+
+	* coffcode.h (sec_to_styp_flags): Allow linkonce for
+	debugging sections.
+
+2011-04-26  Tristan Gingold  <gingold@adacore.com>
+
+	* coff64-rs6000.c: Convert to ISO-C.  Remove PARAMS and PTR macros.
+
+2011-04-24  Alan Modra  <amodra@gmail.com>
+
+	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  <hongjiu.lu@intel.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	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  <hongjiu.lu@intel.com>
+
+	* 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  <gingold@adacore.com>
+
+	* config.bfd (alpha*-*-*vms*, ia64*-*-*vms*): Define targ_selvecs.
+
+2011-04-20  Alan Modra  <amodra@gmail.com>
+
+	* 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  <jan.kratochvil@redhat.com>
+
+	* elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): Fix +1 overrun of
+	memmove elements.
+
+2011-04-20  Alan Modra  <amodra@gmail.com>
+
+	* 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  <amodra@gmail.com>
+
+	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  <amodra@gmail.com>
+
+	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  <gingold@adacore.com>
+
+	* coff-rs6000.c: Convert to ISO-C.  Remove PARAMS macro.
+
+2011-04-18  Alan Modra  <amodra@gmail.com>
+
+	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  <jan.kratochvil@redhat.com>
+
+	* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Do not check for
+	SEC_LOAD.
+
+2011-04-15  Sergio Durigan Junior  <sergiodj@redhat.com>
+
+	* 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  <rth@redhat.com>
+
+	* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Do not
+	exclude empty .got sections.
+
+2011-04-11  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* 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  <bernds@codesourcery.com>
+
+	* elf32-tic6x.c (elf32_tic6x_check_relocs): Initialize pc_count field.
+
+2011-04-11  Mark Wielaard  <mjw@redhat.com>
+
+	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  <amodra@gmail.com>
+
+	* 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  <rdsandiford@googlemail.com>
+
+	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  <hongjiu.lu@intel.com>
+
+	* elf32-i386.c: Update copyright year.
+	* elf64-x86-64.c: Likewise.
+
+2011-04-09  Kai Tietz  <ktietz@redhat.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	PR binutils/12657
+	* hosts/x86-64linux.h (elf_prstatus32): Replace __pid_t with
+	pid_t.
+
+2011-04-08  H.J. Lu  <hongjiu.lu@intel.com>
+
+	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  <gingold@adacore.com>
+
+	* Makefile.am (SOURCE_HFILES): Remove xcoff-target.h
+	* coff-pmac: Remove
+	* xcoff-target.h: Remove
+	* Makefile.in: Regenerate.
+
+2011-04-07  Cary Coutant  <ccoutant@google.com>
+
+	* dwarf2.c (scan_unit_for_symbols): Check for DW_AT_specification.
+
+2011-04-07  Paul Brook  <paul@codesourcery.com>
+
+	* 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  <joseph@codesourcery.com>
+
+	* 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  <gingold@adacore.com>
+
+	* elfxx-ia64.c: include bfd_stdint.h
+
+2011-03-31  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* elf32-tic6x.c (elf32_tic6x_relocate_section): Remove unused variable
+	dynobj and its initialization.
+
+2011-03-31  Tristan Gingold  <gingold@adacore.com>
+
+	* 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  <gingold@adacore.com>
+
+	* 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  <bernds@codesourcery.com>
+
+	* 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  <gingold@adacore.com>
+
+	* coffcode.h (coff_slurp_symbol_table): Silently discard C_NULL
+	entry on xcoff when value is C_NULL_VALUE.
+
+2011-03-31  Tristan Gingold  <gingold@adacore.com>
+
+	* libcoff-in.h (exec_hdr): Remove.
+	* libcoff.h: Regenerate.
+
+2011-03-30  Nick Clifton  <nickc@redhat.com>
+
+	* po/da.po: Updated Danish translation.
+
+2011-03-29  Richard Henderson  <rth@redhat.com>
+
+	* 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  <binutils@marino.st>
+
+	* 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  <msnyder@vmware.com>
+
+	* coffcode.h (coff_set_alignment_hook): Check return of bfd_seek.
+
+2011-03-25  Tristan Gingold  <gingold@adacore.com>
+
+	* vms-alpha.c (_bfd_vms_find_nearest_dst_line): Allow the use
+	of find_nearest_line on object files.
+
+2011-03-25  Tristan Gingold  <gingold@adacore.com>
+
+	* 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  <amodra@gmail.com>
+
+	* 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  <eric.weddington@atmel.com>
+
+	* bfd-in2.h: Regenerate.
+
+2011-03-22  Eric B. Weddington  <eric.weddington@atmel.com>
+
+	* 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  <richard.sandiford@linaro.org>
+
+	* 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  <richard.sandiford@linaro.org>
+
+	* 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  <richard.sandiford@linaro.org>
+
+	* 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  <richard.sandiford@linaro.org>
+
+	* 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  <richard.sandiford@linaro.org>
+
+	* 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  <richard.sandiford@linaro.org>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	* 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  <amodra@gmail.com>
+
+	* elf64-ppc.c (ppc64_elf_relocate_section): Provide section/offset
+	for LO_DS error message and correct multiple.
+
+2011-03-10  Alan Modra  <amodra@gmail.com>
+
+	* 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  <msnyder@vmware.com>
+
+	* 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  <amodra@gmail.com>
+
+	* 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  <msnyder@vmware.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	* 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  <bernds@codesourcery.com>
+
+	* elflink.c (is_reloc_section): Remove function.
+	(get_dynamic_reloc_section_name): Construct string manually.
+
+2011-02-28  Kai Tietz  <kai.tietz@onevision.com>
+
+	* 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  <amodra@gmail.com>
+
+	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 <respindola@mozilla.com>
+
+	* 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  <schwab@redhat.com>
+
+	* 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  <gingold@adacore.com>
+
+	* vms-alpha.c (alpha_vms_link_add_archive_symbols): Add a comment.
+
+2011-02-15  Alan Modra  <amodra@gmail.com>
+
+	* elf64-ppc.c (ppc64_elf_edit_toc): Reinstate second read of
+	toc relocs.  Fuss over free(NULL).
+
+2011-02-14  Mike Frysinger  <vapier@gentoo.org>
+
+	* elflink.c (bfd_elf_size_dynamic_sections): Add
+	bfd_get_symbol_leading_char to the start of newname.
+
+2011-02-13  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+
+	* configure: Regenerate.
+
+2011-02-09  Alan Modra  <amodra@gmail.com>
+
+	* 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  <nickc@redhat.com>
+
+	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  <amodra@gmail.com>
+
+	* 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  <amodra@gmail.com>
+
+	* 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  <joseph@codesourcery.com>
+
+	* elf32-ppc.c (ppc_elf_link_hash_newfunc): Initialize has_sda_refs
+	field.
+
+2011-01-22  Richard Sandiford  <rdsandiford@googlemail.com>
+
+	* elfxx-mips.c (_bfd_mips_elf_merge_private_bfd_data): Ignore
+	common sections too.
+
+2011-01-18  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* elf64-x86-64.c (elf_backend_want_plt_sym): Redefine to 0 after
+	Solaris target.
+
+2011-01-18  Pierre Muller  <muller@ics.u-strasbg.fr>
+
+	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  <richard.sandiford@linaro.org>
+
+	* 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  <richard.sandiford@linaro.org>
+
+	* elf32-arm.c (elf32_arm_gc_sweep_hook): Remove all registered
+	dynamic relocs for the removed section.
+
+2011-01-15  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* elf64-x86-64.c (elf_x86_64_check_relocs): Check invalid x32
+	relocations.
+
+2011-01-14  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* 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  <amodra@gmail.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	* 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  <grassman@gmail.com>
+
+	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  <nathan@codesourcery.com>
+	    Glauber de Oliveira Costa  <glommer@gmail.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Optimized.
+
+2011-01-06  H.J. Lu  <hongjiu.lu@intel.com>
+
+	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  <dj@redhat.com>
+
+	* 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  <hongjiu.lu@intel.com>
+
+	* 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
+
+Local Variables:
+mode: change-log
+left-margin: 8
+fill-column: 74
+version-control: never
+End:
diff --git a/bfd/Makefile.am b/bfd/Makefile.am
index 8f4fbee..b7271cc 100644
--- a/bfd/Makefile.am
+++ b/bfd/Makefile.am
@@ -105,6 +105,8 @@
 	cpu-m32r.lo \
 	cpu-m68hc11.lo \
 	cpu-m68hc12.lo \
+	cpu-m9s12x.lo \
+	cpu-m9s12xg.lo \
 	cpu-m68k.lo \
 	cpu-m88k.lo \
 	cpu-mcore.lo \
@@ -142,6 +144,7 @@
 	cpu-w65.lo \
 	cpu-we32k.lo \
 	cpu-xc16x.lo \
+	cpu-xgate.lo \
 	cpu-xstormy16.lo \
 	cpu-xtensa.lo \
 	cpu-z80.lo \
@@ -182,6 +185,8 @@
 	cpu-m32r.c \
 	cpu-m68hc11.c \
 	cpu-m68hc12.c \
+	cpu-m9s12x.c \
+	cpu-m9s12xg.c \
 	cpu-m68k.c \
 	cpu-m88k.c \
 	cpu-mcore.c \
@@ -219,6 +224,7 @@
 	cpu-w65.c \
 	cpu-we32k.c \
 	cpu-xc16x.c \
+	cpu-xgate.c \
 	cpu-xstormy16.c \
 	cpu-xtensa.c \
 	cpu-z80.c \
@@ -275,6 +281,7 @@
 	elf-ifunc.lo \
 	elf-m10200.lo \
 	elf-m10300.lo \
+	elf-nacl.lo \
 	elf-strtab.lo \
 	elf-vxworks.lo \
 	elf.lo \
@@ -336,6 +343,7 @@
 	elf32-v850.lo \
 	elf32-vax.lo \
 	elf32-xc16x.lo \
+	elf32-xgate.lo \
 	elf32-xstormy16.lo \
 	elf32-xtensa.lo \
 	elf32.lo \
@@ -461,6 +469,7 @@
 	elf-ifunc.c \
 	elf-m10200.c \
 	elf-m10300.c \
+	elf-nacl.c \
 	elf-strtab.c \
 	elf-vxworks.c \
 	elf.c \
@@ -522,6 +531,7 @@
 	elf32-v850.c \
 	elf32-vax.c \
 	elf32-xc16x.c \
+	elf32-xgate.c \
 	elf32-xstormy16.c \
 	elf32-xtensa.c \
 	elf32.c \
@@ -609,6 +619,7 @@
 	coff-x86_64.lo \
 	coff64-rs6000.lo \
 	demo64.lo \
+	elf-nacl.lo \
 	elf32-ia64.lo \
 	elf32-score.lo \
 	elf32-score7.lo \
@@ -616,6 +627,7 @@
 	elf64-gen.lo \
 	elf64-hppa.lo \
 	elf64-ia64.lo \
+	elf64-ia64-vms.lo \
 	elf64-mips.lo \
 	elf64-mmix.lo \
 	elf64-ppc.lo \
@@ -645,11 +657,13 @@
 	coff-x86_64.c \
 	coff64-rs6000.c \
 	demo64.c \
+	elf-nacl.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 \
diff --git a/bfd/Makefile.in b/bfd/Makefile.in
index 437bafc..8ee6681 100644
--- a/bfd/Makefile.in
+++ b/bfd/Makefile.in
@@ -47,7 +47,8 @@
 	$(top_srcdir)/po/Make-in $(srcdir)/../depcomp \
 	$(am__bfdinclude_HEADERS_DIST)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/../bfd/bfd.m4 \
+	$(top_srcdir)/../bfd/warning.m4 $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/depstand.m4 \
 	$(top_srcdir)/../config/gettext-sister.m4 \
 	$(top_srcdir)/../config/largefile.m4 \
@@ -60,7 +61,6 @@
 	$(top_srcdir)/../config/stdint.m4 $(top_srcdir)/../libtool.m4 \
 	$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
 	$(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
-	$(top_srcdir)/bfd.m4 $(top_srcdir)/warning.m4 \
 	$(top_srcdir)/acinclude.m4 $(top_srcdir)/../config/zlib.m4 \
 	$(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@@ -404,6 +404,8 @@
 	cpu-m32r.lo \
 	cpu-m68hc11.lo \
 	cpu-m68hc12.lo \
+	cpu-m9s12x.lo \
+	cpu-m9s12xg.lo \
 	cpu-m68k.lo \
 	cpu-m88k.lo \
 	cpu-mcore.lo \
@@ -441,6 +443,7 @@
 	cpu-w65.lo \
 	cpu-we32k.lo \
 	cpu-xc16x.lo \
+	cpu-xgate.lo \
 	cpu-xstormy16.lo \
 	cpu-xtensa.lo \
 	cpu-z80.lo \
@@ -481,6 +484,8 @@
 	cpu-m32r.c \
 	cpu-m68hc11.c \
 	cpu-m68hc12.c \
+	cpu-m9s12x.c \
+	cpu-m9s12xg.c \
 	cpu-m68k.c \
 	cpu-m88k.c \
 	cpu-mcore.c \
@@ -518,6 +523,7 @@
 	cpu-w65.c \
 	cpu-we32k.c \
 	cpu-xc16x.c \
+	cpu-xgate.c \
 	cpu-xstormy16.c \
 	cpu-xtensa.c \
 	cpu-z80.c \
@@ -575,6 +581,7 @@
 	elf-ifunc.lo \
 	elf-m10200.lo \
 	elf-m10300.lo \
+	elf-nacl.lo \
 	elf-strtab.lo \
 	elf-vxworks.lo \
 	elf.lo \
@@ -636,6 +643,7 @@
 	elf32-v850.lo \
 	elf32-vax.lo \
 	elf32-xc16x.lo \
+	elf32-xgate.lo \
 	elf32-xstormy16.lo \
 	elf32-xtensa.lo \
 	elf32.lo \
@@ -761,6 +769,7 @@
 	elf-ifunc.c \
 	elf-m10200.c \
 	elf-m10300.c \
+	elf-nacl.c \
 	elf-strtab.c \
 	elf-vxworks.c \
 	elf.c \
@@ -822,6 +831,7 @@
 	elf32-v850.c \
 	elf32-vax.c \
 	elf32-xc16x.c \
+	elf32-xgate.c \
 	elf32-xstormy16.c \
 	elf32-xtensa.c \
 	elf32.c \
@@ -910,6 +920,7 @@
 	coff-x86_64.lo \
 	coff64-rs6000.lo \
 	demo64.lo \
+	elf-nacl.lo \
 	elf32-ia64.lo \
 	elf32-score.lo \
 	elf32-score7.lo \
@@ -917,6 +928,7 @@
 	elf64-gen.lo \
 	elf64-hppa.lo \
 	elf64-ia64.lo \
+	elf64-ia64-vms.lo \
 	elf64-mips.lo \
 	elf64-mmix.lo \
 	elf64-ppc.lo \
@@ -946,11 +958,13 @@
 	coff-x86_64.c \
 	coff64-rs6000.c \
 	demo64.c \
+	elf-nacl.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 \
@@ -1292,6 +1306,8 @@
 @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-microblaze.Plo@am__quote@
@@ -1327,6 +1343,7 @@
 @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@
@@ -1341,6 +1358,7 @@
 @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@
@@ -1405,12 +1423,14 @@
 @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-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@
diff --git a/bfd/aclocal.m4 b/bfd/aclocal.m4
index d9e743e..bf4ef1d 100644
--- a/bfd/aclocal.m4
+++ b/bfd/aclocal.m4
@@ -968,6 +968,8 @@
 AC_SUBST([am__untar])
 ]) # _AM_PROG_TAR
 
+m4_include([../bfd/bfd.m4])
+m4_include([../bfd/warning.m4])
 m4_include([../config/acx.m4])
 m4_include([../config/depstand.m4])
 m4_include([../config/gettext-sister.m4])
@@ -984,6 +986,4 @@
 m4_include([../ltsugar.m4])
 m4_include([../ltversion.m4])
 m4_include([../lt~obsolete.m4])
-m4_include([bfd.m4])
-m4_include([warning.m4])
 m4_include([acinclude.m4])
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 <TRANLE@INTELLICORP.COM>.
    Converted to back end form by Ian Lance Taylor <ian@cygnus.com>.
@@ -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 (rwe@pegasus.esprit.ec.org)
 
    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 (idall@eleceng.adelaide.edu.au).
 
    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-tic30.c b/bfd/aout-tic30.c
index 0b01177..f3b0d36 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 (steve@pm.cse.rmit.edu.au)
 
@@ -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.  */
diff --git a/bfd/aout0.c b/bfd/aout0.c
index e87af00..7cec377 100644
--- a/bfd/aout0.c
+++ b/bfd/aout0.c
@@ -1,5 +1,5 @@
 /* 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.
 
@@ -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..fe57755 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -1,7 +1,7 @@
 /* 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.
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
+   2012  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.
@@ -147,7 +147,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 +169,7 @@
 {
   static char buf[20];
   size_t len;
+
   snprintf (buf, sizeof (buf), fmt, val);
   len = strlen (buf);
   if (len < n)
@@ -178,6 +180,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 +298,7 @@
 {
   htab_t hash_table = bfd_ardata (arch_bfd)->cache;
   struct ar_cache m;
+
   m.ptr = filepos;
 
   if (hash_table)
@@ -288,7 +314,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 +322,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;
@@ -350,7 +376,7 @@
        abfd = abfd->archive_next)
     {
       if (filename_cmp (filename, abfd->filename) == 0)
-        return abfd;
+	return abfd;
     }
   target = NULL;
   if (!arch_bfd->target_defaulted)
@@ -390,10 +416,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 +450,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 +458,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 +476,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;
@@ -581,12 +612,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 +630,35 @@
 
       /* 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)
+	    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))
+	    {
+	      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;
+	}
       /* 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;
@@ -727,13 +752,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.  */
@@ -925,7 +948,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 *);
@@ -979,7 +1002,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;
@@ -1079,21 +1102,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;
@@ -1250,7 +1273,7 @@
 
       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);
@@ -1276,7 +1299,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)
@@ -1366,7 +1389,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 +1412,7 @@
 
   rpath = lrealpath (ref_path);
   refp = rpath == NULL ? ref_path : rpath;
- 
+
   /* Remove common leading path elements.  */
   for (;;)
     {
@@ -1415,7 +1438,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 +1449,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 +1554,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 +1617,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 +1649,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 +1684,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 +1701,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 +1726,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 +1749,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 +1793,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;
 }
@@ -1870,7 +1895,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 +1904,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 +1913,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 +2160,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 +2180,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 +2311,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 +2345,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);
@@ -2379,6 +2408,9 @@
   unsigned int count;
   struct ar_hdr hdr;
   long uid, gid;
+  file_ptr max_first_real = 1;
+
+  max_first_real <<= 31;
 
   firstreal = mapsize + elength + sizeof (struct ar_hdr) + SARMAG;
 
@@ -2406,10 +2438,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))
@@ -2426,16 +2459,25 @@
 	{
 	  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.  */
+      if (firstreal >= max_first_real)
+	{
+	  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 +2545,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 +2589,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 +2606,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 +2640,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;
     }
 
diff --git a/bfd/archive64.c b/bfd/archive64.c
index bbc4c3f..f3a13d3 100644
--- a/bfd/archive64.c
+++ b/bfd/archive64.c
@@ -1,6 +1,6 @@
 /* MIPS-specific support for 64-bit ELF
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007,
-   2010  Free Software Foundation, Inc.
+   2010, 2012  Free Software Foundation, Inc.
    Ian Lance Taylor, Cygnus Support
    Linker support added by Mark Mitchell, CodeSourcery, LLC.
    <mark@codesourcery.com>
@@ -169,8 +169,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.: */
diff --git a/bfd/archures.c b/bfd/archures.c
index f609534..a23534b 100644
--- a/bfd/archures.c
+++ b/bfd/archures.c
@@ -1,7 +1,7 @@
 /* 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.
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
+   2012 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.
@@ -241,7 +241,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
@@ -263,6 +266,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
@@ -438,7 +443,9 @@
 .  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,
@@ -453,6 +460,7 @@
 .  bfd_arch_tilegx, {* Tilera TILE-Gx *}
 .#define bfd_mach_tilepro   1
 .#define bfd_mach_tilegx    1
+.#define bfd_mach_tilegx32  2
 .  bfd_arch_last
 .  };
 */
@@ -485,6 +493,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;
@@ -523,6 +537,8 @@
 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;
@@ -565,6 +581,7 @@
 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;
 
@@ -605,6 +622,8 @@
     &bfd_m32r_arch,
     &bfd_m68hc11_arch,
     &bfd_m68hc12_arch,
+    &bfd_m9s12x_arch,
+    &bfd_m9s12xg_arch,
     &bfd_m68k_arch,
     &bfd_m88k_arch,
     &bfd_mcore_arch,
@@ -644,6 +663,7 @@
     &bfd_xstormy16_arch,
     &bfd_xtensa_arch,
     &bfd_xc16x_arch,
+    &bfd_xgate_arch,
     &bfd_z80_arch,
     &bfd_z8k_arch,
 #endif
@@ -814,6 +834,7 @@
   32, 32, 8, bfd_arch_unknown, 0, "unknown", "unknown", 2, TRUE,
   bfd_default_compatible,
   bfd_default_scan,
+  bfd_arch_default_fill,
   0,
 };
 
@@ -1309,3 +1330,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 40ed786..5300b14 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -1,8 +1,8 @@
 /* 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.
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
+   2012 Free Software Foundation, Inc.
 
    Contributed by Cygnus Support.
 
@@ -25,6 +25,11 @@
 #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
@@ -273,18 +278,19 @@
 
 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)
 
@@ -297,11 +303,11 @@
     ? (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)
+   && (sec)->sec_info_type != SEC_INFO_TYPE_MERGE		\
+   && (sec)->sec_info_type != SEC_INFO_TYPE_JUST_SYMS)
 
 typedef enum bfd_print_symbol
 {
@@ -692,19 +698,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 *);
 
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 2bb0ec7..c1c5e90 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -8,8 +8,8 @@
 /* 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.
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
+   2012 Free Software Foundation, Inc.
 
    Contributed by Cygnus Support.
 
@@ -32,6 +32,11 @@
 #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
@@ -280,18 +285,19 @@
 
 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)
 
@@ -304,11 +310,11 @@
     ? (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)
+   && (sec)->sec_info_type != SEC_INFO_TYPE_MERGE		\
+   && (sec)->sec_info_type != SEC_INFO_TYPE_JUST_SYMS)
 
 typedef enum bfd_print_symbol
 {
@@ -699,19 +705,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 *);
 
@@ -1383,11 +1385,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;
@@ -1517,9 +1519,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;
@@ -1547,28 +1546,25 @@
 
 /* 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 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 (&std_section[0])
+/* Pointer to the undefined section.  */
+#define bfd_und_section_ptr (&std_section[1])
+/* Pointer to the absolute section.  */
+#define bfd_abs_section_ptr (&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 (&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)              \
@@ -1683,8 +1679,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,                 \
@@ -1698,9 +1694,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,                           \
                                                                        \
@@ -1712,6 +1705,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,
@@ -1947,7 +1944,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
@@ -1969,6 +1969,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
@@ -2144,7 +2146,9 @@
   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,
@@ -2159,6 +2163,7 @@
   bfd_arch_tilegx, /* Tilera TILE-Gx */
 #define bfd_mach_tilepro   1
 #define bfd_mach_tilegx    1
+#define bfd_mach_tilegx32  2
   bfd_arch_last
   };
 
@@ -2181,6 +2186,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;
@@ -2591,6 +2602,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,
@@ -2786,6 +2801,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,
@@ -2947,6 +2971,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,
@@ -3060,6 +3103,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,
@@ -3782,14 +3842,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.  */
@@ -4061,6 +4113,18 @@
 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,
@@ -4229,6 +4293,7 @@
   BFD_RELOC_390_GOT20,
   BFD_RELOC_390_GOTPLT20,
   BFD_RELOC_390_TLS_GOTIE20,
+  BFD_RELOC_390_IRELATIVE,
 
 /* Score relocations
 Low 16 bit for load/store  */
@@ -4444,6 +4509,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,
@@ -4810,6 +4952,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,
 
@@ -4940,6 +5085,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,
@@ -4959,6 +5110,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,
@@ -5018,52 +5177,44 @@
   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_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_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_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,
@@ -5600,6 +5751,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
@@ -5680,8 +5840,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))
@@ -6157,8 +6317,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/bfd.c b/bfd/bfd.c
index 7c14c7a..640b420 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -797,6 +797,88 @@
 {
   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;
+}
 
 /*
 SECTION
@@ -942,8 +1024,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
@@ -1374,8 +1456,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))
diff --git a/bfd/bfdio.c b/bfd/bfdio.c
index 841c781..43a7684 100644
--- a/bfd/bfdio.c
+++ b/bfd/bfdio.c
@@ -87,7 +87,6 @@
 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.
@@ -185,7 +184,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 +233,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 +312,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);
diff --git a/bfd/cache.c b/bfd/cache.c
index 5ddbbe4..574d8b2 100644
--- a/bfd/cache.c
+++ b/bfd/cache.c
@@ -198,7 +198,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)
@@ -563,15 +563,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 +601,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..7155a63 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;
@@ -308,15 +304,13 @@
 }
 
 char *
-cisco_core_file_failing_command (abfd)
-     bfd *abfd ATTRIBUTE_UNUSED;
+cisco_core_file_failing_command (bfd *abfd ATTRIBUTE_UNUSED)
 {
   return NULL;
 }
 
 int
-cisco_core_file_failing_signal (abfd)
-     bfd *abfd ATTRIBUTE_UNUSED;
+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..62e5c9c 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 <sac@cygnus.com> and
    Ian Lance Taylor <ian@cygnus.com>.
@@ -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;
@@ -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,13 +2233,13 @@
 {
   /* 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, 
@@ -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 (troy@cbme.unsw.edu.au)
    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..4cdf1ac 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;
 
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 <rth@tamu.edu>.
 
@@ -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..0f1de57 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, <sac@cygnus.com>.
 
@@ -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) \
@@ -224,13 +202,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 +218,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..1fae964 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, <sac@cygnus.com>.
 
@@ -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;
diff --git a/bfd/coff-i386.c b/bfd/coff-i386.c
index 2f17a55..f69f502 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;
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 <davidm@hpl.hp.com>
 
@@ -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..cdcdde2 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, ian@cygnus.com.
@@ -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,13 +1246,13 @@
 {
   /* 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, 
@@ -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  <ivang@opencores.org>
 
@@ -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..fa04933 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 (krk@cygnus.com)
 
@@ -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,55 +299,19 @@
 /* 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.  */
@@ -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;
@@ -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;
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index ffa7a65..2a968bf 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.
@@ -40,20 +40,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 +129,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 **);
@@ -451,7 +451,7 @@
 
 
 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;
@@ -474,7 +474,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;
@@ -498,8 +498,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;
@@ -608,15 +608,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:
@@ -1263,7 +1263,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;
 
@@ -1279,7 +1279,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.  */
@@ -1318,7 +1318,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;
 
@@ -1337,7 +1337,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.  */
@@ -1390,7 +1390,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);
@@ -1429,7 +1429,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);
@@ -1456,7 +1456,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);
@@ -1489,7 +1489,7 @@
 
 /* Read the archive header in an XCOFF archive.  */
 
-PTR
+void *
 _bfd_xcoff_read_ar_hdr (bfd *abfd)
 {
   bfd_size_type namlen;
@@ -1505,7 +1505,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);
@@ -1537,7 +1537,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);
@@ -1572,7 +1572,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.  */
@@ -1713,7 +1713,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))
@@ -2230,20 +2230,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;
     }
@@ -2254,7 +2254,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;
     }
 
@@ -2268,7 +2268,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;
     }
@@ -2281,7 +2281,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;
 
@@ -2509,7 +2509,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;
     }
@@ -2517,7 +2517,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;
 
@@ -2559,7 +2559,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;
 
@@ -2576,7 +2576,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;
 
@@ -2593,7 +2593,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;
 
@@ -2614,7 +2614,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;
 
@@ -2635,7 +2635,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;
@@ -2649,7 +2649,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;
@@ -2665,7 +2665,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;
 
@@ -2678,7 +2678,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;
 
@@ -4163,7 +4163,7 @@
     /* Opposite endian version, none exists */
     NULL,
 
-    (void *) &bfd_xcoff_backend_data,
+    & bfd_xcoff_backend_data,
   };
 
 /* xcoff-powermac target
@@ -4418,5 +4418,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, <sac@cygnus.com>.
@@ -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 (steve@pm.cse.rmit.edu.au)
 
@@ -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..5814faf 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 (m.hayes@elec.canterbury.ac.nz)
 
@@ -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,16 +261,16 @@
 
 
 /* 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, 0, '_', 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, 0, '_', &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, 0, '_', &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, 0, '_', &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);
diff --git a/bfd/coff-tic54x.c b/bfd/coff-tic54x.c
index 3c353da..9afba42 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 (twall@cygnus.com)
 
@@ -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;
@@ -367,24 +345,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 +448,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 +494,7 @@
 
     & tic54x_coff0_vec,
 
-    (PTR) & ticoff0_swap_table
+    & ticoff0_swap_table
   };
 
 /* TI COFF v1, DOS tools (little-endian headers).  */
@@ -564,7 +540,7 @@
 
     & tic54x_coff0_beh_vec,
 
-    (PTR) & ticoff1_swap_table
+    & ticoff1_swap_table
 };
 
 /* TI COFF v1, SPARC tools (big-endian headers).  */
@@ -610,7 +586,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..4bd96fc 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 (fnf@cygnus.com)
 
@@ -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;
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, <sac@cygnus.com>.
 
    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..4f00b78 100644
--- a/bfd/coff-x86_64.c
+++ b/bfd/coff-x86_64.c
@@ -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
 	{
diff --git a/bfd/cofflink.c b/bfd/cofflink.c
index 1ebdfdd..dd3e4b1 100644
--- a/bfd/cofflink.c
+++ b/bfd/cofflink.c
@@ -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)
@@ -873,31 +873,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 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,7 +943,7 @@
 	}
     }
 
-  if (finfo.info->strip != strip_all && finfo.info->discard != discard_all)
+  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)
@@ -970,14 +970,14 @@
 		continue;
 
 	      /* See if we are discarding symbols with this name.  */
-	      if ((finfo.info->strip == strip_some
-		   && (bfd_hash_lookup (finfo.info->keep_hash,
+	      if ((flaginfo.info->strip == strip_some
+		   && (bfd_hash_lookup (flaginfo.info->keep_hash,
 					bfd_asymbol_name(sym), FALSE, FALSE)
 		       == NULL))
-		  || (((finfo.info->discard == discard_sec_merge
+		  || (((flaginfo.info->discard == discard_sec_merge
 			&& (bfd_get_section (sym)->flags & SEC_MERGE)
-			&& ! finfo.info->relocatable)
-		       || finfo.info->discard == discard_l)
+			&& ! flaginfo.info->relocatable)
+		       || flaginfo.info->discard == discard_l)
 		      && bfd_is_local_label_name (sub, bfd_asymbol_name(sym))))
 		continue;
 
@@ -994,34 +994,34 @@
 		  bfd_boolean hash = ! (abfd->flags & BFD_TRADITIONAL_FORMAT);
 		  bfd_size_type indx;
 
-		  indx = _bfd_stringtab_add (finfo.strtab,
+		  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, finfo.outsyms);
+		  bfd_coff_swap_sym_out (abfd, &isym, flaginfo.outsyms);
 		  rewrite = TRUE;
 		}
 
 	      if (isym.n_sclass == C_FILE)
 		{
-		  if (finfo.last_file_index != -1)
+		  if (flaginfo.last_file_index != -1)
 		    {
-		      finfo.last_file.n_value = obj_raw_syment_count (abfd);
-		      bfd_coff_swap_sym_out (abfd, &finfo.last_file,
-					     finfo.outsyms);
-		      pos = obj_sym_filepos (abfd) + finfo.last_file_index
+		      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;
 		    }
-		  finfo.last_file_index = obj_raw_syment_count (abfd);
-		  finfo.last_file = isym;
+		  flaginfo.last_file_index = obj_raw_syment_count (abfd);
+		  flaginfo.last_file = isym;
 		}
 
 	      if (rewrite
 		  && (bfd_seek (abfd, pos, SEEK_SET) != 0
-		      || bfd_bwrite (finfo.outsyms, symesz, abfd) != symesz))
+		      || bfd_bwrite (flaginfo.outsyms, symesz, abfd) != symesz))
 		goto error_return;
 
 	      obj_raw_syment_count (abfd) += written;
@@ -1029,65 +1029,65 @@
 	}
     }
 
-  if (! bfd_coff_final_link_postscript (abfd, & finfo))
+  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;
     }
 
@@ -1096,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)
@@ -1136,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)
 	    {
@@ -1162,7 +1162,7 @@
 	      
 	      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;
@@ -1179,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.  */
@@ -1212,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
@@ -1222,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.  */
@@ -1238,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;
@@ -1411,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;
 
@@ -1433,11 +1433,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)
@@ -1451,7 +1451,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;
     }
 }
 
@@ -1459,7 +1459,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;
@@ -1485,7 +1485,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);
@@ -1494,7 +1494,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)
@@ -1505,27 +1505,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)
@@ -1565,9 +1565,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;
@@ -1579,7 +1579,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)
@@ -1609,7 +1609,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;
 	    }
@@ -1634,7 +1634,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
@@ -1652,8 +1652,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];
@@ -1663,11 +1663,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;
 	}
@@ -1675,7 +1675,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)
@@ -1702,7 +1702,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;
@@ -1779,7 +1779,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;
 		    }
@@ -1858,7 +1858,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;
@@ -1913,7 +1913,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;
@@ -1928,19 +1928,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)));
 		    }
@@ -1952,23 +1952,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.  */
@@ -2014,10 +2014,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)
     {
@@ -2088,7 +2088,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;
@@ -2113,15 +2113,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;
 			}
 		    }
@@ -2131,7 +2131,7 @@
 		    {
 		      long symindx;
 
-		      symindx = finfo->sym_indices[indx];
+		      symindx = flaginfo->sym_indices[indx];
 		      if (symindx < 0)
 			auxp->x_sym.x_tagndx.l = 0;
 		      else
@@ -2151,12 +2151,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;
@@ -2165,13 +2165,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,
@@ -2187,13 +2187,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))
@@ -2202,14 +2202,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);
 			}
@@ -2234,8 +2234,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)
 	{
@@ -2261,13 +2261,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)
@@ -2284,7 +2284,7 @@
 		{
 		  long indx;
 
-		  indx = finfo->sym_indices[iline.l_addr.l_symndx];
+		  indx = flaginfo->sym_indices[iline.l_addr.l_symndx];
 
 		  if (indx < 0)
 		    {
@@ -2310,7 +2310,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)
@@ -2319,7 +2319,7 @@
 			{
 			  void *auxptr;
 
-			  auxptr = (finfo->outsyms
+			  auxptr = (flaginfo->outsyms
 				    + ((indx - syment_base + 1)
 				       * osymesz));
 			  bfd_coff_swap_aux_in (output_bfd, auxptr,
@@ -2328,7 +2328,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);
@@ -2349,9 +2349,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;
@@ -2362,30 +2362,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;
@@ -2427,9 +2427,9 @@
       else
 	{
 	  bfd_size_type x = o->rawsize ? o->rawsize : o->size;
-	  if (! bfd_get_section_contents (input_bfd, o, finfo->contents, 0, x))
+	  if (! bfd_get_section_contents (input_bfd, o, flaginfo->contents, 0, x))
 	    return FALSE;
-	  contents = finfo->contents;
+	  contents = flaginfo->contents;
 	}
 
       if ((o->flags & SEC_RELOC) != 0)
@@ -2441,12 +2441,12 @@
 	  /* 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)));
+			       : flaginfo->internal_relocs)));
 	  if (internal_relocs == NULL)
 	    return FALSE;
 
@@ -2473,7 +2473,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);
@@ -2481,15 +2481,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;
@@ -2498,7 +2498,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++)
 		{
@@ -2515,7 +2515,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;
@@ -2545,7 +2545,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
@@ -2558,15 +2558,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;
 			}
@@ -2588,13 +2588,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;
 
@@ -2607,14 +2607,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)
     {
@@ -2627,9 +2627,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;
@@ -2660,7 +2660,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;
@@ -2685,11 +2685,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;
@@ -2706,7 +2706,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;
@@ -2717,23 +2717,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;
     }
 
@@ -2771,7 +2771,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),
@@ -2780,7 +2780,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),
@@ -2797,10 +2797,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);
@@ -2816,7 +2816,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;
 
@@ -2829,10 +2829,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;
@@ -2845,7 +2845,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)
 {
@@ -2884,8 +2884,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)
@@ -2908,9 +2908,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));
@@ -2933,7 +2933,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)
@@ -2951,8 +2951,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..52c884c 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"
diff --git a/bfd/config.bfd b/bfd/config.bfd
index 396a24c..783d1f3 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -85,8 +85,8 @@
 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 ;;
@@ -105,6 +105,7 @@
 v850*)		 targ_archs=bfd_v850_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 ;;
@@ -216,6 +217,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"
@@ -507,9 +520,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
     ;;
@@ -572,7 +586,9 @@
     ;;
   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*)
@@ -606,11 +622,17 @@
     targ_selvecs="bfd_elf32_i386_vec i386netbsd_vec i386coff_vec i386pei_vec x86_64pei_vec bfd_elf64_l1om_vec bfd_elf64_k1om_vec"
     want64=true
     ;;
-  x86_64-*-linux-* | x86_64-*-nacl*)
+  x86_64-*-linux-*)
     targ_defvec=bfd_elf64_x86_64_vec
     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-*-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)
     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"
@@ -1506,8 +1528,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
 
@@ -1551,7 +1577,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
     ;;
diff --git a/bfd/config.in b/bfd/config.in
index 98157e1..20b619d 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(__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
 
@@ -245,6 +252,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 c679417..75e580d 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -3988,7 +3988,7 @@
 
 # Define the identity of the package.
  PACKAGE=bfd
- VERSION=2.22.51
+ VERSION=2.22.52
 
 
 cat >>confdefs.h <<_ACEOF
@@ -12217,6 +12217,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 +12319,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
@@ -13508,6 +13511,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 :
@@ -15184,11 +15203,12 @@
     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" ;;
@@ -15209,11 +15229,11 @@
     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" ;;
@@ -15226,10 +15246,11 @@
     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" ;;
@@ -15302,7 +15323,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" ;;
@@ -15313,6 +15335,7 @@
     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 ;;
@@ -15324,7 +15347,7 @@
     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_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 ;;
@@ -15341,19 +15364,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" ;;
@@ -18748,4 +18774,3 @@
 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
 fi
 
-
diff --git a/bfd/configure.in b/bfd/configure.in
index 83376e5..5922961 100644
--- a/bfd/configure.in
+++ b/bfd/configure.in
@@ -8,7 +8,7 @@
 AC_CANONICAL_TARGET
 AC_ISC_POSIX
 
-AM_INIT_AUTOMAKE(bfd, 2.22.51)
+AM_INIT_AUTOMAKE(bfd, 2.22.52)
 
 dnl These must be called before LT_INIT, because it may want
 dnl to call AC_CHECK_PROG.
@@ -109,7 +109,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 +117,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(__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 +141,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
 
@@ -190,6 +199,9 @@
 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)
@@ -683,18 +695,19 @@
     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_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" ;;
@@ -708,11 +721,11 @@
     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" ;;
@@ -725,10 +738,11 @@
     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" ;;
@@ -801,7 +815,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" ;;
@@ -812,6 +827,7 @@
     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 ;;
@@ -823,7 +839,7 @@
     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_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 ;;
@@ -840,19 +856,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" ;;
@@ -1148,4 +1167,3 @@
 AC_SUBST(pdfdir)
 
 AC_OUTPUT
-
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 (dje@cygnus.com).
 
@@ -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..21a8d0f 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[] =
 {
diff --git a/bfd/cpu-avr.c b/bfd/cpu-avr.c
index 07ba6dc..37ccee1 100644
--- a/bfd/cpu-avr.c
+++ b/bfd/cpu-avr.c
@@ -96,6 +96,7 @@
   default,			/* Is this the default ?  */	\
   compatible,							\
   bfd_default_scan,						\
+  bfd_arch_default_fill,					\
   next								\
 }
 
diff --git a/bfd/cpu-bfin.c b/bfd/cpu-bfin.c
index 37e314b..ec515ea 100644
--- a/bfd/cpu-bfin.c
+++ b/bfd/cpu-bfin.c
@@ -35,6 +35,7 @@
     4,                	/* Section align power.  */
     TRUE,             	/* The one and only.  */
     bfd_default_compatible, 
-    bfd_default_scan ,
+    bfd_default_scan,
+    bfd_arch_default_fill,
     0,
   };
diff --git a/bfd/cpu-cr16.c b/bfd/cpu-cr16.c
index 6c77738..bcaaf60 100644
--- a/bfd/cpu-cr16.c
+++ b/bfd/cpu-cr16.c
@@ -35,6 +35,7 @@
     1,                /* Unsigned int section alignment power.  */
     TRUE,             /* The one and only.  */
     bfd_default_compatible, 
-    bfd_default_scan ,
+    bfd_default_scan,
+    bfd_arch_default_fill,
     0,
   };
diff --git a/bfd/cpu-cr16c.c b/bfd/cpu-cr16c.c
index e8ee1db..7653f2c 100644
--- a/bfd/cpu-cr16c.c
+++ b/bfd/cpu-cr16c.c
@@ -34,6 +34,7 @@
     1,
     TRUE, 	/* The one and only.  */
     bfd_default_compatible, 
-    bfd_default_scan ,
+    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..8edd2ca 100644
--- a/bfd/cpu-crx.c
+++ b/bfd/cpu-crx.c
@@ -35,6 +35,7 @@
     1,      	/* Unsigned int section alignment power.  */
     TRUE, 	/* The one and only.  */
     bfd_default_compatible, 
-    bfd_default_scan ,
+    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
index 13427c1..9cf723e 100644
--- a/bfd/cpu-epiphany.c
+++ b/bfd/cpu-epiphany.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.  */
 };
 
@@ -52,5 +53,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_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..e667a03 100644
--- a/bfd/cpu-h8300.c
+++ b/bfd/cpu-h8300.c
@@ -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..4cb59ed 100644
--- a/bfd/cpu-i386.c
+++ b/bfd/cpu-i386.c
@@ -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,83 @@
   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);
+}
+
 static const bfd_arch_info_type bfd_x64_32_arch_intel_syntax =
 {
   64, /* 64 bits in a word */
@@ -51,6 +132,7 @@
   FALSE,
   bfd_i386_compatible,
   bfd_default_scan,
+  bfd_arch_i386_long_nop_fill,
   0
 };
 
@@ -67,6 +149,7 @@
   FALSE,
   bfd_i386_compatible,
   bfd_default_scan,
+  bfd_arch_i386_long_nop_fill,
   &bfd_x64_32_arch_intel_syntax,
 };
 
@@ -83,6 +166,7 @@
   TRUE,
   bfd_i386_compatible,
   bfd_default_scan,
+  bfd_arch_i386_short_nop_fill,
   &bfd_x86_64_arch_intel_syntax
 };
 
@@ -99,6 +183,7 @@
   FALSE,
   bfd_i386_compatible,
   bfd_default_scan,
+  bfd_arch_i386_short_nop_fill,
   &bfd_i386_arch_intel_syntax
 };
 
@@ -115,6 +200,7 @@
   FALSE,
   bfd_i386_compatible,
   bfd_default_scan,
+  bfd_arch_i386_long_nop_fill,
   &i8086_arch
 };
 
@@ -131,6 +217,7 @@
   FALSE,
   bfd_i386_compatible,
   bfd_default_scan,
+  bfd_arch_i386_long_nop_fill,
   &bfd_x64_32_arch
 };
 
@@ -147,5 +234,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.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..5222a91 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 <jon@beniston.com>
 
    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_lm32_arch = 
@@ -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..009ff04 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[] =
   {
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-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 ed86f11..c55cbf0 100644
--- a/bfd/cpu-mips.c
+++ b/bfd/cpu-mips.c
@@ -55,6 +55,7 @@
     DEFAULT,						\
     mips_compatible,					\
     bfd_default_scan,					\
+    bfd_arch_default_fill,				\
     NEXT,						\
   }
 
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..f514fe7 100644
--- a/bfd/cpu-moxie.c
+++ b/bfd/cpu-moxie.c
@@ -35,6 +35,7 @@
     2,                /* Unsigned int section alignment power.  */
     TRUE,             /* The one and only.  */
     bfd_default_compatible, 
-    bfd_default_scan ,
+    bfd_default_scan,
+    bfd_arch_default_fill,
     0,
   };
diff --git a/bfd/cpu-msp430.c b/bfd/cpu-msp430.c
index 63c301a..bcaa4e7 100644
--- a/bfd/cpu-msp430.c
+++ b/bfd/cpu-msp430.c
@@ -1,5 +1,6 @@
 /* BFD library support routines for the MSP architecture.
-   Copyright (C) 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2005, 2007, 2012
+   Free Software Foundation, Inc.
    Contributed by Dmitry Diky <diwil@mail.ru>
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -23,8 +24,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 +55,7 @@
   default,			/* The default machine.  */	\
   compatible,							\
   bfd_default_scan,						\
+  bfd_arch_default_fill,					\
   next								\
 }
 
@@ -93,21 +110,3 @@
 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-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
index 66024ae..6fb72e6 100644
--- a/bfd/cpu-rl78.c
+++ b/bfd/cpu-rl78.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-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..1a581e4 100644
--- a/bfd/cpu-s390.c
+++ b/bfd/cpu-s390.c
@@ -36,6 +36,7 @@
     TRUE, /* the default */
     bfd_default_compatible,
     bfd_default_scan,
+    bfd_arch_default_fill,
     NULL
 };
 
@@ -52,5 +53,6 @@
     TRUE, /* the default */
     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 (brain.lin@sunplusct.com)
    Mei Ligang (ligang@sunnorth.com.cn)
@@ -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..6fe6c15 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
 };
 
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 (m.hayes@elec.canterbury.ac.nz)
 
@@ -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..d124220 100644
--- a/bfd/cpu-v850.c
+++ b/bfd/cpu-v850.c
@@ -26,7 +26,7 @@
 
 #define N(number, print, default, next)  \
 {  32, 32, 8, bfd_arch_v850, number, "v850", print, 2, default, \
-     bfd_default_compatible, bfd_default_scan, next }
+   bfd_default_compatible, bfd_default_scan, bfd_arch_default_fill, next }
 
 #define NEXT NULL
 
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..3d28659 100644
--- a/bfd/cpu-xc16x.c
+++ b/bfd/cpu-xc16x.c
@@ -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..37a7e38 100644
--- a/bfd/doc/ChangeLog
+++ b/bfd/doc/ChangeLog
@@ -1,3 +1,7 @@
+2012-02-27  Alan Modra  <amodra@gmail.com>
+
+	* chew.c (print_stack_level, main): Use %ld to print stack delta.
+
 2010-10-28  Matthias Klose  <doko@ubuntu.com>
 
 	* bfd.texinfo: Add directory section for info document.
diff --git a/bfd/doc/archures.texi b/bfd/doc/archures.texi
index dec9e01..726ba0a 100644
--- a/bfd/doc/archures.texi
+++ b/bfd/doc/archures.texi
@@ -206,7 +206,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
@@ -228,6 +231,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
@@ -403,7 +408,9 @@
   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,
@@ -418,6 +425,7 @@
   bfd_arch_tilegx, /* Tilera TILE-Gx */
 #define bfd_mach_tilepro   1
 #define bfd_mach_tilegx    1
+#define bfd_mach_tilegx32  2
   bfd_arch_last
   @};
 @end example
@@ -449,6 +457,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;
@@ -654,3 +668,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.info b/bfd/doc/bfd.info
index 7488f92..f38bee1 100644
--- a/bfd/doc/bfd.info
+++ b/bfd/doc/bfd.info
Binary files differ
diff --git a/bfd/doc/bfdt.texi b/bfd/doc/bfdt.texi
index 8b82750..ad9f3e2 100644
--- a/bfd/doc/bfdt.texi
+++ b/bfd/doc/bfdt.texi
@@ -419,6 +419,43 @@
 @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.
+
 @section Miscellaneous
 
 
@@ -713,8 +750,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))
diff --git a/bfd/doc/bfdver.texi b/bfd/doc/bfdver.texi
index 86eaaaa..41a451b 100644
--- a/bfd/doc/bfdver.texi
+++ b/bfd/doc/bfdver.texi
@@ -1,4 +1,4 @@
-@set VERSION 2.22.51
+@set VERSION 2.22.52
 @set VERSION_PACKAGE (GNU Binutils) 
-@set UPDATED April 2012
+@set UPDATED November 2012
 @set BUGURL @uref{http://www.sourceware.org/bugzilla/}
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/opncls.texi b/bfd/doc/opncls.texi
index eddf66a..1562ea5 100644
--- a/bfd/doc/opncls.texi
+++ b/bfd/doc/opncls.texi
@@ -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}
diff --git a/bfd/doc/reloc.texi b/bfd/doc/reloc.texi
index d1fb2c8..b1f9bb9 100644
--- a/bfd/doc/reloc.texi
+++ b/bfd/doc/reloc.texi
@@ -662,6 +662,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 +862,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.
@@ -1015,6 +1028,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
@@ -1126,6 +1158,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
@@ -1849,14 +1898,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
@@ -2127,6 +2168,18 @@
 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
@@ -2296,6 +2349,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
@@ -2510,6 +2566,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
@@ -2875,6 +3008,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
@@ -3004,6 +3140,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
@@ -3023,6 +3165,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
@@ -3082,52 +3232,44 @@
 @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_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_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_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
@@ -3219,12 +3361,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..cc6ee94 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;
@@ -503,28 +500,25 @@
 
 /* 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 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 (&std_section[0])
+/* Pointer to the undefined section.  */
+#define bfd_und_section_ptr (&std_section[1])
+/* Pointer to the absolute section.  */
+#define bfd_abs_section_ptr (&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 (&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}
diff --git a/bfd/doc/syms.texi b/bfd/doc/syms.texi
index d5dc659..3d66380 100644
--- a/bfd/doc/syms.texi
+++ b/bfd/doc/syms.texi
@@ -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..e56e560 100644
--- a/bfd/doc/targets.texi
+++ b/bfd/doc/targets.texi
@@ -467,8 +467,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 577f278..d31b849 100644
--- a/bfd/dwarf2.c
+++ b/bfd/dwarf2.c
@@ -405,8 +405,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;
 
@@ -503,7 +503,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;
 	}
@@ -522,7 +522,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;
@@ -1014,20 +1015,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
@@ -1248,12 +1256,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;
@@ -1281,7 +1293,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;
@@ -1401,6 +1413,7 @@
   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, &stash->debug_sections[debug_line],
@@ -1581,15 +1594,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.  */
@@ -1604,8 +1617,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;
 
@@ -1620,7 +1633,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:
@@ -1658,8 +1671,12 @@
 		  (void) 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 +1695,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 +1736,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;
@@ -1851,8 +1869,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;
 	    }
 	}
@@ -1900,8 +1919,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;
 	}
     }
@@ -1986,8 +2005,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
@@ -2052,7 +2071,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;
 	}
@@ -2078,7 +2097,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;
@@ -2092,6 +2111,7 @@
       struct varinfo *var;
       bfd_vma low_pc = 0;
       bfd_vma high_pc = 0;
+      bfd_boolean high_pc_relative = FALSE;
 
       abbrev_number = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
       info_ptr += bytes_read;
@@ -2197,6 +2217,7 @@
 
 		case DW_AT_high_pc:
 		  high_pc = attr.u.val;
+		  high_pc_relative = attr.form != DW_FORM_addr;
 		  break;
 
 		case DW_AT_ranges:
@@ -2275,9 +2296,12 @@
 	    }
 	}
 
+      if (high_pc_relative)
+	high_pc += low_pc;
+
       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;
 	}
 
@@ -2291,8 +2315,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;
@@ -2338,6 +2362,7 @@
   bfd_vma low_pc = 0;
   bfd_vma high_pc = 0;
   bfd *abfd = stash->bfd_ptr;
+  bfd_boolean high_pc_relative = FALSE;
 
   version = read_2_bytes (abfd, info_ptr);
   info_ptr += 2;
@@ -2352,23 +2377,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;
     }
@@ -2376,14 +2407,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;
     }
@@ -2392,7 +2423,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;
     }
@@ -2435,11 +2466,13 @@
 	  /* 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:
 	  high_pc = attr.u.val;
+	  high_pc_relative = attr.form != DW_FORM_addr;
 	  break;
 
 	case DW_AT_ranges:
@@ -2467,9 +2500,11 @@
 	  break;
 	}
     }
+  if (high_pc_relative)
+    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,25 +2774,43 @@
 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,
-                  debug_sections[debug_info].uncompressed_name) == 0)
+      look = debug_sections[debug_info].uncompressed_name;
+      msec = bfd_get_section_by_name (abfd, look);
+      if (msec != NULL)
 	return msec;
 
-      if (debug_sections[debug_info].compressed_name != NULL
-          && strcmp (msec->name,
-                     debug_sections[debug_info].compressed_name) == 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;
@@ -2831,7 +2884,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;
 
@@ -2925,8 +2978,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;
 	}
     }
@@ -3117,6 +3170,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;
+
+  *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;
+	}
+    }
+
+  /* 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;
+  stash->syms = symbols;
+  stash->bfd_ptr = debug_bfd;
+
+  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.
@@ -3157,18 +3326,17 @@
   bfd_vma found = FALSE;
   bfd_boolean do_line;
 
+  *filename_ptr = NULL;
+  if (functionname_ptr != NULL)
+    *functionname_ptr = NULL;
+  *linenumber_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;
-      stash->debug_sections = debug_sections;
-    }
-
   /* 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)
@@ -3197,110 +3365,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 (! *pinfo)
-    {
-      bfd *debug_bfd;
-      bfd_size_type total_size;
-      asection *msec;
-
-      *pinfo = stash;
-
-      msec = find_debug_info (abfd, debug_sections, 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,
-                                          debug_sections, 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, 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))
-	    goto done;
-	}
-      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)
-	    goto done;
-
-	  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)))
-		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, debug_sections, 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;
 
@@ -3330,6 +3399,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,
@@ -3343,7 +3413,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,
@@ -3456,7 +3527,7 @@
 	}
     }
 
-done:
+ done:
   if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
     unset_sections (stash);
 
@@ -3527,17 +3598,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)
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index b76266d..3b65c0e 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -1,6 +1,6 @@
 /* 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
+   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
    Original version by Per Bothner.
    Full support added by Ian Lance Taylor, ian@cygnus.com.
@@ -73,8 +73,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 +234,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;
diff --git a/bfd/ecofflink.c b/bfd/ecofflink.c
index 25b67fa..2ec2886 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, <ian@cygnus.com>.
 
    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;
@@ -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;
@@ -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))
 		{
@@ -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/elf-attrs.c b/bfd/elf-attrs.c
index 569e846..4237af5 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.
@@ -428,7 +428,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 +440,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 +455,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 486b76e..889ce12 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -1,6 +1,6 @@
 /* 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
+   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -428,6 +428,7 @@
   TIC6X_ELF_DATA,
   X86_64_ELF_DATA,
   XTENSA_ELF_DATA,
+  XGATE_ELF_DATA,
   TILEGX_ELF_DATA,
   TILEPRO_ELF_DATA,
   GENERIC_ELF_DATA
@@ -1185,7 +1186,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.  */
@@ -1221,6 +1223,12 @@
   /* Return TRUE if type is a function symbol type.  */
   bfd_boolean (*is_function_type) (unsigned int type);
 
+  /* If the ELF symbol SYM might be a function in SEC, return the
+     function size and set *CODE_OFF to the function's entry point,
+     otherwise return zero.  */
+  bfd_size_type (*maybe_function_sym) (const asymbol *sym, asection *sec,
+				       bfd_vma *code_off);
+
   /* Used to handle bad SHF_LINK_ORDER input.  */
   bfd_error_handler_type link_order_error_handler;
 
@@ -1361,6 +1369,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;
@@ -1413,14 +1424,14 @@
   void *sec_info;
 };
 
-#define elf_section_data(sec)  ((struct bfd_elf_section_data*)(sec)->used_by_bfd)
+#define elf_section_data(sec) ((struct bfd_elf_section_data*)(sec)->used_by_bfd)
 #define elf_linked_to_section(sec) (elf_section_data(sec)->linked_to)
-#define elf_section_type(sec)  (elf_section_data(sec)->this_hdr.sh_type)
-#define elf_section_flags(sec) (elf_section_data(sec)->this_hdr.sh_flags)
-#define elf_group_name(sec)    (elf_section_data(sec)->group.name)
-#define elf_group_id(sec)      (elf_section_data(sec)->group.id)
-#define elf_next_in_group(sec) (elf_section_data(sec)->next_in_group)
-#define elf_fde_list(sec)      (elf_section_data(sec)->fde_list)
+#define elf_section_type(sec)	(elf_section_data(sec)->this_hdr.sh_type)
+#define elf_section_flags(sec)	(elf_section_data(sec)->this_hdr.sh_flags)
+#define elf_group_name(sec)	(elf_section_data(sec)->group.name)
+#define elf_group_id(sec)	(elf_section_data(sec)->group.id)
+#define elf_next_in_group(sec)	(elf_section_data(sec)->next_in_group)
+#define elf_fde_list(sec)	(elf_section_data(sec)->fde_list)
 #define elf_sec_group(sec)	(elf_section_data(sec)->sec_group)
 
 #define xvec_get_elf_backend_data(xvec) \
@@ -1807,8 +1818,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
@@ -1942,6 +1952,8 @@
   (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 *);
 
@@ -2132,9 +2144,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);
@@ -2200,10 +2209,13 @@
 
 extern bfd_boolean _bfd_elf_is_function_type (unsigned int);
 
+extern bfd_size_type _bfd_elf_maybe_function_sym (const asymbol *, asection *,
+						  bfd_vma *);
+
 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);
@@ -2250,10 +2262,10 @@
 
 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);
@@ -2403,10 +2415,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))			\
@@ -2418,23 +2432,28 @@
 	rel_hdr = _bfd_elf_single_rel_hdr (input_section->output_section); \
 									\
 	/* Avoid empty output section.  */				\
-	if (rel_hdr->sh_size > rel_hdr->sh_entsize)			\
+	if (rel_hdr->sh_size > count * rel_hdr->sh_entsize)		\
 	  {								\
-	    rel_hdr->sh_size -= rel_hdr->sh_entsize;			\
+	    rel_hdr->sh_size -= count * rel_hdr->sh_entsize;		\
 	    rel_hdr = _bfd_elf_single_rel_hdr (input_section);		\
-	    rel_hdr->sh_size -= rel_hdr->sh_entsize;			\
+	    rel_hdr->sh_size -= count * 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--;							\
+	    input_section->reloc_count -= count;			\
+	    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;								\
   }
 
diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
index 54142b2..a75d806 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 <jakub@redhat.com>.
 
    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;
@@ -1247,6 +1247,26 @@
   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);
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 fa33b4a..709ea16 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,15 +479,131 @@
 	 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 */
@@ -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)
@@ -707,6 +1087,7 @@
 	}
 
       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 +1102,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 +1134,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 +1239,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 +1260,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 +1320,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 +1429,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 +1461,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 +1668,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 +1682,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 +1699,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 +1724,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 +1742,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 +1765,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 +1785,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 +1886,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 +1988,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 +2005,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 +2024,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 +2060,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 +2071,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))
@@ -1512,9 +2109,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;
@@ -1571,6 +2168,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");
@@ -1581,11 +2181,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;
 	    }
 	}
     }
@@ -2581,6 +3179,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;
@@ -2611,6 +3210,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;
@@ -2766,7 +3384,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;
 
@@ -2862,9 +3480,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)
@@ -3304,9 +3920,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;
@@ -3949,11 +4563,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 *
@@ -3976,6 +4617,11 @@
     }
 
   ret->flags = 0;
+  ret->tls_ldm_got.refcount = 0;
+  ret->tls_ldm_got.offset = -1;
+  ret->tls_ldm_got.got_allocated = 0;
+  ret->tls_ldm_got.rel_emitted = 0;
+
   amt = sizeof (struct elf_link_hash_table);
   ret->static_hash_table = bfd_malloc (amt);
   if (ret->static_hash_table == NULL)
@@ -4154,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)
@@ -4176,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;
@@ -4187,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
@@ -4221,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;
 
@@ -4239,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;
@@ -4262,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
@@ -4301,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
@@ -4328,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);
 
@@ -4367,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
@@ -4384,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;
@@ -4410,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)
@@ -4424,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;
@@ -4437,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.  */
@@ -4580,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)
     {
@@ -4598,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
@@ -4677,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)
@@ -4722,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
@@ -4754,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)
     {
@@ -4824,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)
@@ -4846,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;
 	}
     }
 
@@ -4887,12 +5552,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);
 }
 
@@ -4948,7 +5608,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..842e367
--- /dev/null
+++ b/bfd/elf-nacl.c
@@ -0,0 +1,215 @@
+/* Native Client support for ELF
+   Copyright 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., 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.  */
+
+#include "sysdep.h"
+#include "bfd.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;
+}
+
+static bfd_boolean
+segment_nonexecutable_and_has_contents (struct elf_segment_map *seg)
+{
+  bfd_boolean any_contents = FALSE;
+  unsigned int i;
+  for (i = 0; i < seg->count; ++i)
+    {
+      if (seg->sections[i]->flags & SEC_CODE)
+        return FALSE;
+      if (seg->sections[i]->flags & SEC_HAS_CONTENTS)
+        any_contents = TRUE;
+    }
+  return any_contents;
+}
+
+
+/* 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)
+{
+  struct elf_segment_map **m = &elf_tdata (abfd)->segment_map;
+  struct elf_segment_map **first_load = NULL;
+  struct elf_segment_map **last_load = NULL;
+  bfd_boolean moved_headers = FALSE;
+
+  if (info != NULL && info->user_phdrs)
+    /* The linker script used PHDRS explicitly, so don't change what the
+       user asked for.  */
+    return TRUE;
+
+  while (*m != NULL)
+    {
+      struct elf_segment_map *seg = *m;
+
+      if (seg->p_type == PT_LOAD)
+        {
+          /* 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 (!segment_executable (*m))
+                return TRUE;
+              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_nonexecutable_and_has_contents (seg))
+            {
+              /* 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;
+            }
+        }
+
+      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 ATTRIBUTE_UNUSED)
+{
+  struct elf_segment_map **m = &elf_tdata (abfd)->segment_map;
+  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;
+
+          first_seg->next = next_next;
+          *first_load_seg = next_seg;
+
+          next_seg->next = first_next;
+          *next_load_seg = first_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;
+}
diff --git a/bfd/elf-nacl.h b/bfd/elf-nacl.h
new file mode 100644
index 0000000..417c7e3
--- /dev/null
+++ b/bfd/elf-nacl.h
@@ -0,0 +1,24 @@
+/* Native Client support for ELF
+   Copyright 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., 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 *);
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-vxworks.c b/bfd/elf-vxworks.c
index 06edf8d..11dfb10 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;
@@ -280,7 +281,8 @@
     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:
diff --git a/bfd/elf.c b/bfd/elf.c
index f1e4882..48e5d68 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1,7 +1,7 @@
 /* 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
+   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.
@@ -1025,7 +1025,7 @@
       else
 	{
 	  /* Normal section.  Check if we should compress.  */
-	  if ((abfd->flags & BFD_COMPRESS))
+	  if ((abfd->flags & BFD_COMPRESS) && newsect->size != 0)
 	    action = compress;
 	}
 
@@ -1038,7 +1038,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;
 	    }
@@ -1058,7 +1058,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;
 	    }
@@ -1646,7 +1646,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;
@@ -1699,6 +1707,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;
@@ -2527,7 +2545,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;
@@ -2996,6 +3014,13 @@
       _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));
 
@@ -3071,7 +3096,7 @@
 	      if (link_info != NULL)
 		{
 		  /* Check discarded linkonce section.  */
-		  if (elf_discarded_section (s))
+		  if (discarded_section (s))
 		    {
 		      asection *kept;
 		      (*_bfd_error_handler)
@@ -3225,9 +3250,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)
 {
@@ -3242,7 +3264,7 @@
 }
 
 /* Don't output section symbols for sections that are not going to be
-   output.  */
+   output, or that are duplicates.  */
 
 static bfd_boolean
 ignore_section_sym (bfd *abfd, asymbol *sym)
@@ -3250,9 +3272,13 @@
   return ((sym->flags & BSF_SECTION_SYM) != 0
 	  && !(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)
 {
@@ -3294,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;
 
@@ -3308,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
@@ -3343,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;
     }
@@ -3744,6 +3769,10 @@
   bfd_boolean no_user_phdrs;
 
   no_user_phdrs = elf_tdata (abfd)->segment_map == NULL;
+
+  if (info != NULL)
+    info->user_phdrs = !no_user_phdrs;
+
   if (no_user_phdrs && bfd_count_sections (abfd) != 0)
     {
       asection *s;
@@ -4130,18 +4159,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)
@@ -4351,7 +4387,7 @@
       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)
@@ -4546,8 +4582,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)
@@ -4574,7 +4608,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;
@@ -4797,6 +4830,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;
@@ -4820,12 +4854,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,
@@ -4853,6 +4888,7 @@
   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;
@@ -4873,12 +4909,59 @@
 	  phdrs_paddr = p->p_paddr;
 	  if (m->includes_filehdr)
 	    {
+	      hdrs_segment = m;
 	      phdrs_vaddr += bed->s->sizeof_ehdr;
 	      phdrs_paddr += bed->s->sizeof_ehdr;
 	    }
 	}
     }
 
+  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_tdata (abfd)->segment_map; 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_tdata (abfd)->segment_map, p = phdrs;
        m != NULL;
        m = m->next, p++)
@@ -4886,21 +4969,27 @@
       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_tdata (abfd)->segment_map, 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
 	    {
@@ -4926,8 +5015,15 @@
 	      else
 		abort ();
 	      p->p_memsz = p->p_filesz;
-	      p->p_align = 1;
-	      p->p_flags = (lp->p_flags & ~PF_W);
+	      /* 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)
+		p->p_flags = (lp->p_flags & ~PF_W);
 	    }
 	  else
 	    {
@@ -5427,7 +5523,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.
@@ -6147,7 +6243,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)
@@ -7378,65 +7474,74 @@
 		   const char **filename_ptr,
 		   const char **functionname_ptr)
 {
-  const char *filename;
-  asymbol *func, *file;
-  bfd_vma low_func;
-  asymbol **p;
-  /* ??? Given multiple file symbols, it is impossible to reliably
-     choose the right file name for global symbols.  File symbols are
-     local symbols, and thus all file symbols must sort before any
-     global symbols.  The ELF spec may be interpreted to say that a
-     file symbol must sort before other local symbols, but currently
-     ld -r doesn't do this.  So, for ld -r output, it is possible to
-     make a better choice of file name for local symbols by ignoring
-     file symbols appearing after a given local symbol.  */
-  enum { nothing_seen, symbol_seen, file_after_symbol_seen } state;
-  const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+  static asection *last_section;
+  static asymbol *func;
+  static const char *filename;
+  static bfd_size_type func_size;
 
   if (symbols == NULL)
     return FALSE;
 
-  filename = NULL;
-  func = NULL;
-  file = NULL;
-  low_func = 0;
-  state = nothing_seen;
-
-  for (p = symbols; *p != NULL; p++)
+  if (last_section != section
+      || func == NULL
+      || offset < func->value
+      || offset >= func->value + func_size)
     {
-      elf_symbol_type *q;
-      unsigned int type;
+      asymbol *file;
+      bfd_vma low_func;
+      asymbol **p;
+      /* ??? Given multiple file symbols, it is impossible to reliably
+	 choose the right file name for global symbols.  File symbols are
+	 local symbols, and thus all file symbols must sort before any
+	 global symbols.  The ELF spec may be interpreted to say that a
+	 file symbol must sort before other local symbols, but currently
+	 ld -r doesn't do this.  So, for ld -r output, it is possible to
+	 make a better choice of file name for local symbols by ignoring
+	 file symbols appearing after a given local symbol.  */
+      enum { nothing_seen, symbol_seen, file_after_symbol_seen } state;
+      const struct elf_backend_data *bed = get_elf_backend_data (abfd);
 
-      q = (elf_symbol_type *) *p;
+      filename = NULL;
+      func = NULL;
+      file = NULL;
+      low_func = 0;
+      state = nothing_seen;
+      func_size = 0;
+      last_section = section;
 
-      type = ELF_ST_TYPE (q->internal_elf_sym.st_info);
-      switch (type)
+      for (p = symbols; *p != NULL; p++)
 	{
-	case STT_FILE:
-	  file = &q->symbol;
-	  if (state == symbol_seen)
-	    state = file_after_symbol_seen;
-	  continue;
-	default:
-	  if (!bed->is_function_type (type))
-	    break;
-	case STT_NOTYPE:
-	  if (bfd_get_section (&q->symbol) == section
-	      && q->symbol.value >= low_func
-	      && q->symbol.value <= offset)
+	  asymbol *sym = *p;
+	  bfd_vma code_off;
+	  bfd_size_type size;
+
+	  if ((sym->flags & BSF_FILE) != 0)
 	    {
-	      func = (asymbol *) q;
-	      low_func = q->symbol.value;
+	      file = sym;
+	      if (state == symbol_seen)
+		state = file_after_symbol_seen;
+	      continue;
+	    }
+
+	  size = bed->maybe_function_sym (sym, section, &code_off);
+	  if (size != 0
+	      && code_off <= offset
+	      && (code_off > low_func
+		  || (code_off == low_func
+		      && size > func_size)))
+	    {
+	      func = sym;
+	      func_size = size;
+	      low_func = code_off;
 	      filename = NULL;
 	      if (file != NULL
-		  && (ELF_ST_BIND (q->internal_elf_sym.st_info) == STB_LOCAL
+		  && ((sym->flags & BSF_LOCAL) != 0
 		      || state != file_after_symbol_seen))
 		filename = bfd_asymbol_name (file);
 	    }
-	  break;
+	  if (state == nothing_seen)
+	    state = symbol_seen;
 	}
-      if (state == nothing_seen)
-	state = symbol_seen;
     }
 
   if (func == NULL)
@@ -7698,11 +7803,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_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);
@@ -8889,7 +8995,6 @@
   return buf;
 }
 
-#if defined (HAVE_PRPSINFO_T) || defined (HAVE_PSINFO_T)
 char *
 elfcore_write_prpsinfo (bfd  *abfd,
 			char *buf,
@@ -8897,7 +9002,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)
@@ -8909,6 +9013,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)
     {
@@ -8924,7 +9029,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
@@ -8941,12 +9046,14 @@
       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_prstatus (bfd *abfd,
 			char *buf,
@@ -8955,7 +9062,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)
@@ -8968,6 +9074,7 @@
 	return ret;
     }
 
+#if defined (HAVE_PRSTATUS_T)
 #if defined (HAVE_PRSTATUS32_T)
   if (bed->s->elfclass == ELFCLASS32)
     {
@@ -8977,7 +9084,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
@@ -8989,12 +9096,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,
@@ -9447,7 +9557,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,
@@ -9478,7 +9588,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,
@@ -9494,10 +9604,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)
@@ -9528,7 +9638,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);
@@ -9633,7 +9743,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);
@@ -9685,3 +9795,27 @@
   return (type == STT_FUNC
 	  || type == STT_GNU_IFUNC);
 }
+
+/* If the ELF symbol SYM might be a function in SEC, return the
+   function size and set *CODE_OFF to the function's entry point,
+   otherwise return zero.  */
+
+bfd_size_type
+_bfd_elf_maybe_function_sym (const asymbol *sym, asection *sec,
+			     bfd_vma *code_off)
+{
+  bfd_size_type size;
+
+  if ((sym->flags & (BSF_SECTION_SYM | BSF_FILE | BSF_OBJECT
+		     | BSF_THREAD_LOCAL | BSF_RELC | BSF_SRELC)) != 0
+      || sym->section != sec)
+    return 0;
+
+  *code_off = sym->value;
+  size = 0;
+  if (!(sym->flags & BSF_SYNTHETIC))
+    size = ((elf_symbol_type *) sym)->internal_elf_sym.st_size;
+  if (size == 0)
+    size = 1;
+  return size;
+}
diff --git a/bfd/elf32-am33lin.c b/bfd/elf32-am33lin.c
index 177a714..dd2aed4 100644
--- a/bfd/elf32-am33lin.c
+++ b/bfd/elf32-am33lin.c
@@ -50,6 +50,7 @@
       default:
 	return FALSE;
 
+      case 184:
       case 188:		/* Linux/am33 */
 	/* pr_cursig */
 	elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 31ea861..bc1f195 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -1,6 +1,6 @@
 /* 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.
+   2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -23,9 +23,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"
 
@@ -1988,6 +1990,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
@@ -1995,6 +2045,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;
@@ -2029,24 +2080,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
+{
+  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 */ 
-  };
+  0x00000018, /* 4:   .word  _GLOBAL_OFFSET_TABLE_ - 2b - 8 */
+};
 
 #ifdef FOUR_WORD_PLT
 
@@ -2055,22 +2106,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
 
@@ -2079,72 +2130,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: */
+  0xe7dfcf1f, 	/* bfc	ip, #30, #2			*/
+  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: */
+  0xe7dfcf1f,		/* bfc	ip, #30, #2			*/
+  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)
@@ -2154,12 +2244,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
@@ -2173,154 +2263,154 @@
 
 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) */
 };
 
 /* Cortex-A8 erratum-workaround stubs.  */
@@ -2329,32 +2419,32 @@
    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.  */
+};
 
 /* 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
@@ -2364,7 +2454,7 @@
    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
@@ -2405,7 +2495,8 @@
   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 */
@@ -2420,7 +2511,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
 };
@@ -2573,7 +2665,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;
@@ -2587,7 +2680,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;
@@ -2602,7 +2696,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;
@@ -2625,7 +2720,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;
@@ -2686,14 +2782,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
@@ -2701,25 +2797,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)			\
@@ -2829,6 +2925,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;
 
@@ -2853,7 +2952,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;
@@ -3149,7 +3248,7 @@
   bfd *dynobj;
   asection *s;
   flagword flags;
-  
+
   htab = elf32_arm_hash_table (info);
   dynobj = htab->root.dynobj;
   bed = get_elf_backend_data (dynobj);
@@ -3157,27 +3256,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;
@@ -3205,10 +3305,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)
     {
@@ -3359,6 +3459,7 @@
   ret->use_blx = 0;
   ret->vxworks_p = 0;
   ret->symbian_p = 0;
+  ret->nacl_p = 0;
   ret->use_rel = 1;
   ret->sym_cache.abfd = NULL;
   ret->obfd = abfd;
@@ -3527,7 +3628,7 @@
       else
 	splt = globals->root.splt;
       if (splt != NULL)
-	{	
+	{
 	  use_plt = 1;
 
 	  /* Note when dealing with PLT entries: the main PLT stub is in
@@ -3811,7 +3912,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 *
@@ -3849,10 +3950,10 @@
 	}
       htab->stub_group[section->id].stub_sec = stub_sec;
     }
-  
+
   if (link_sec_p)
     *link_sec_p = link_sec;
-  
+
   return stub_sec;
 }
 
@@ -3920,7 +4021,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);
@@ -3928,7 +4029,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:
@@ -3974,7 +4075,7 @@
     case arm_stub_long_branch_v4t_thumb_tls_pic:
     case arm_stub_a8_veneer_blx:
       return 4;
-    
+
     default:
       abort ();  /* Should be unreachable.  */
     }
@@ -4512,7 +4613,7 @@
       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->sec_info_type == SEC_INFO_TYPE_JUST_SYMS)
           || (section->output_section == bfd_abs_section_ptr))
         continue;
 
@@ -4947,13 +5048,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)
@@ -4979,7 +5080,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)
 		    {
@@ -5524,9 +5625,9 @@
      .arm                               mov  lr, pc
      b func                             bx   r6
                                         .arm
-		 		    ;; back_to_thumb       
+		 		    ;; back_to_thumb
                  		        ldmia r13! {r6, lr}
- 				        bx    lr           
+ 				        bx    lr
                                     __func_addr:
                                         .word        func  */
 
@@ -5554,7 +5655,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;
 	}
@@ -5563,7 +5664,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);
@@ -5619,7 +5720,7 @@
   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);
@@ -5695,7 +5796,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);
@@ -5786,7 +5887,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);
@@ -5893,12 +5994,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))
@@ -5963,7 +6064,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)
@@ -6583,7 +6684,7 @@
       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
+	  || 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;
@@ -6918,8 +7019,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);
@@ -7108,8 +7209,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);
@@ -7162,8 +7263,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);
@@ -7197,8 +7298,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);
@@ -7354,6 +7455,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
@@ -7514,6 +7627,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
@@ -7654,18 +7806,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;
@@ -7721,7 +7873,7 @@
 	  return bfd_reloc_notsupported;
 	}
       break;
-      
+
     case R_ARM_TLS_DESCSEQ:
       /* arm insn.  */
       insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
@@ -7767,7 +7919,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)
@@ -7779,7 +7931,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;
@@ -9200,9 +9352,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);
 
@@ -9243,7 +9395,7 @@
 				   + 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;
@@ -9261,13 +9413,13 @@
 			    !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);
+			    globals->root.sgotplt->contents + offplt
+			    + globals->sgotplt_jump_table_size + 4);
 	      }
 	    if (tls_type & GOT_TLS_GD)
 	      {
@@ -9387,9 +9539,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;
@@ -9402,10 +9555,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))
 		  {
@@ -9438,11 +9591,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);
@@ -9479,7 +9632,7 @@
 		  case 0xe0:	/* add */
 		    value = -8;
 		    break;
-		    
+
 		  default:
 		    (*_bfd_error_handler)
 		      (_("%B(%A+0x%lx):unexpected ARM instruction '0x%x' referenced by TLS_GOTDESC"),
@@ -9488,7 +9641,7 @@
 		    return bfd_reloc_notsupported;
 		  }
 	      }
- 
+
 	    value += ((globals->root.sgotplt->output_section->vma
 		       + globals->root.sgotplt->output_offset + off)
 		      - (input_section->output_section->vma
@@ -9514,7 +9667,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);
@@ -10222,7 +10375,7 @@
 		   rel->r_offset, TRUE))
 		return FALSE;
 	    }
-	  
+
 	  if (globals->use_rel)
 	    {
 	      relocation = (sec->output_section->vma
@@ -10331,9 +10484,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)
 	{
@@ -10387,7 +10540,7 @@
          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)))
        {
@@ -10399,7 +10552,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,
@@ -10495,11 +10648,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;
@@ -10557,7 +10710,7 @@
 
 /* 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).
@@ -10565,8 +10718,7 @@
    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,
@@ -10585,15 +10737,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_ARM_EXIDX)
 	    continue;
-	  
+
 	  if (elf_sec->linked_to)
 	    {
 	      Elf_Internal_Shdr *linked_hdr
@@ -10655,13 +10807,13 @@
       hdr = &elf_section_data (exidx_sec)->this_hdr;
       if (hdr->sh_type != SHT_ARM_EXIDX)
         continue;
-      
+
       exidx_arm_data = get_arm_elf_section_data (exidx_sec);
       if (exidx_arm_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))
@@ -10713,7 +10865,7 @@
       /* 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);
 
@@ -10734,7 +10886,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;
 
@@ -10807,6 +10959,43 @@
   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;
+	  }
+
+	return bfd_mach_arm_5TE;
+      }
+
+    default:
+      return bfd_mach_arm_unknown;
+    }
+}
+
 /* Set the right machine number.  */
 
 static bfd_boolean
@@ -10816,15 +11005,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;
 }
 
@@ -11219,6 +11408,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.  */
 
@@ -11660,29 +11889,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:
@@ -11694,7 +11916,7 @@
 		{
 		  _bfd_error_handler
 		    (_("%B has has both the current and legacy "
-		       "Tag_MPextension_use attributes"), 
+		       "Tag_MPextension_use attributes"),
 		     ibfd);
 		  result = FALSE;
 		}
@@ -12074,8 +12296,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--;
@@ -12168,7 +12401,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++)
     {
@@ -12240,14 +12473,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;
 		}
 
@@ -12436,7 +12669,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++;
@@ -12797,13 +13031,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
@@ -12813,18 +13040,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;
     }
@@ -13014,7 +13241,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.  */
@@ -13023,7 +13250,7 @@
 
 	      /* 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))
@@ -13266,7 +13493,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;
@@ -13478,10 +13705,10 @@
     {
       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.  */
       if (!(info->flags & DF_BIND_NOW))
@@ -13589,9 +13816,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)
@@ -13664,7 +13891,7 @@
 		 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;
@@ -13765,7 +13992,7 @@
 		    const unsigned long *template, unsigned count)
 {
   unsigned ix;
-  
+
   for (ix = 0; ix != count; ix++)
     {
       unsigned long insn = template[ix];
@@ -13798,7 +14025,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)
     {
@@ -14007,6 +14234,25 @@
 	      SWAP_RELOC_OUT (htab) (output_bfd, &rel,
 				     htab->srelplt2->contents);
 	    }
+	  else if (htab->nacl_p)
+	    {
+	      unsigned int i;
+
+	      got_displacement = got_address + 8 - (plt_address + 16);
+
+	      put_arm_insn (htab, output_bfd,
+			    elf32_arm_nacl_plt0_entry[0]
+			    | arm_movw_immediate (got_displacement),
+			    splt->contents + 0);
+	      put_arm_insn (htab, output_bfd,
+			    elf32_arm_nacl_plt0_entry[1]
+			    | arm_movt_immediate (got_displacement),
+			    splt->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],
+			      splt->contents + (i * 4));
+	    }
 	  else
 	    {
 	      got_displacement = got_address - (plt_address + 16);
@@ -14045,7 +14291,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);
 
@@ -14062,13 +14308,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)
@@ -14235,7 +14481,7 @@
 
 typedef struct
 {
-  void *finfo;
+  void *flaginfo;
   struct bfd_link_info *info;
   asection *sec;
   int sec_shndx;
@@ -14270,7 +14516,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.
@@ -14324,6 +14570,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;
@@ -14392,7 +14643,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
@@ -14504,7 +14755,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 *,
@@ -14522,7 +14773,7 @@
 
   check_use_blx (htab);
 
-  osi.finfo = finfo;
+  osi.flaginfo = flaginfo;
   osi.info = info;
   osi.func = func;
 
@@ -14559,8 +14810,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);
@@ -14582,8 +14833,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);
@@ -14599,8 +14850,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);
@@ -14650,6 +14901,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))
@@ -14689,7 +14945,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;
@@ -14703,9 +14959,9 @@
       if (!elf32_arm_output_map_sym (&osi, ARM_MAP_DATA,
 				     htab->tls_trampoline + 12))
 	return FALSE;
-#endif 
+#endif
     }
-  
+
   return TRUE;
 }
 
@@ -14768,23 +15024,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;
 };
@@ -15022,7 +15279,7 @@
 	  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,
@@ -15040,7 +15297,7 @@
 		      in_index++;
 		      add_to_offsets += 8;
 		      break;
-		    
+
 		    case INSERT_EXIDX_CANTUNWIND_AT_END:
 		      {
 		        asection *text_sec = edit_node->linked_section;
@@ -15070,7 +15327,7 @@
 		      }
 		      break;
 		    }
-		  
+
 		  edit_node = edit_node->next;
 		}
 	    }
@@ -15360,7 +15617,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
@@ -15414,11 +15671,78 @@
 #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));
+}
+
+#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_MAXPAGESIZE
+#define ELF_MAXPAGESIZE			0x10000
+
+#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
+
 /* VxWorks Targets.  */
 
 #undef  TARGET_LITTLE_SYM
diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c
index 6d20aef..38e41df 100644
--- a/bfd/elf32-avr.c
+++ b/bfd/elf32-avr.c
@@ -1,6 +1,7 @@
 /* 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.
+   2010, 2011, 2012
+   Free Software Foundation, Inc.
    Contributed by Denis Chertykov <denisc@overta.ru>
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -516,6 +517,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 +597,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
@@ -1189,9 +1235,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 +1549,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, FALSE);
+
+       for (irelend = irel + isec->reloc_count;
             irel < irelend;
             irel++)
          {
@@ -1564,6 +1617,9 @@
 	   /* else...Reference symbol is extern.  No need for adjusting
 	      the addend.  */
 	 }
+
+       if (elf_section_data (isec)->relocs == NULL)
+	 free (irelend - isec->reloc_count);
      }
   }
 
@@ -1649,6 +1705,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 +1871,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 +1954,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);
diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c
index f88e5d4..6173433 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;
 
@@ -1224,20 +1223,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;
@@ -1444,9 +1444,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 +1483,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 +1547,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
@@ -1676,8 +1676,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++)
@@ -1996,10 +1996,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;
 
@@ -2034,7 +2034,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;
@@ -2100,7 +2100,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;
 
@@ -2155,9 +2155,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)
@@ -2665,9 +2664,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;
@@ -3387,8 +3386,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
@@ -3401,14 +3400,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;
@@ -3446,8 +3445,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;
@@ -3455,8 +3454,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;
@@ -3470,7 +3469,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;
@@ -3497,7 +3496,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;
@@ -3543,27 +3543,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;
@@ -4246,7 +4246,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;
@@ -4296,11 +4296,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;
 
@@ -4348,9 +4348,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;
@@ -4433,7 +4432,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;
@@ -4546,7 +4545,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)
     {
@@ -4598,9 +4597,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;
 
@@ -5063,7 +5061,7 @@
 
 /* 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;
@@ -5211,14 +5209,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)
     {
@@ -5245,9 +5243,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;
 
@@ -5263,8 +5261,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
@@ -5322,7 +5320,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;
@@ -5376,7 +5374,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
@@ -5387,7 +5385,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;
@@ -5450,7 +5448,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;
@@ -5481,7 +5479,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;
@@ -5495,7 +5493,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;
@@ -5508,7 +5506,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;
     }
@@ -5521,7 +5519,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
@@ -5632,16 +5630,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;
@@ -5661,7 +5655,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;
diff --git a/bfd/elf32-cr16.c b/bfd/elf32-cr16.c
index 0118131..97fa569 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;
@@ -752,24 +752,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;
@@ -1047,7 +1045,7 @@
           }
         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)
               {
@@ -1096,7 +1094,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)
                {
@@ -1431,9 +1429,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;
@@ -2278,10 +2276,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 +2287,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 +2295,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 +2313,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 +2378,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 +2418,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 +2428,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 +2469,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 +2483,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 +2638,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 +2683,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
@@ -2753,9 +2717,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)
     {
diff --git a/bfd/elf32-cr16c.c b/bfd/elf32-cr16c.c
index ca2d7cb..ea22701 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.
@@ -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 563e2c0..c9316ee 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;
@@ -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)
@@ -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
@@ -972,14 +911,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 +1002,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 ++)
@@ -1184,9 +1121,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;
@@ -1204,7 +1141,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);
@@ -1336,7 +1273,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
@@ -1652,7 +1589,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)
@@ -1661,7 +1598,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);
@@ -1805,7 +1742,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)
@@ -1877,7 +1814,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;
@@ -1936,7 +1874,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)
@@ -2192,9 +2130,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));
 
@@ -2291,8 +2229,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
@@ -2337,8 +2275,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
@@ -2363,9 +2300,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;
@@ -2373,16 +2309,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;
@@ -2560,8 +2496,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++)
@@ -2718,16 +2654,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
@@ -2738,9 +2722,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;
 
@@ -2770,8 +2752,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;
@@ -2818,9 +2800,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;
 
@@ -2852,10 +2832,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);
 
@@ -2949,7 +2928,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
@@ -3008,13 +2987,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);
 
@@ -3052,13 +3031,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
@@ -3069,18 +3041,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;
@@ -3271,7 +3243,7 @@
 	    }
 
 	  if (sgot == NULL)
-	    sgot = bfd_get_section_by_name (dynobj, ".got");
+	    sgot = bfd_get_linker_section (dynobj, ".got");
 
 	  if (local_got_refcounts == NULL)
 	    {
@@ -3331,17 +3303,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;
@@ -3787,7 +3757,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;
@@ -3804,7 +3774,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;
     }
@@ -3963,9 +3933,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;
@@ -4019,9 +3988,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;
 
@@ -4044,7 +4012,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);
 
@@ -4074,8 +4042,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;
@@ -4090,9 +4057,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;
 
@@ -4125,9 +4091,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)
     {
@@ -4157,9 +4122,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;
 
@@ -4185,9 +4148,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;
 
@@ -4264,9 +4225,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))
@@ -4285,8 +4244,7 @@
 }
 
 static enum elf_reloc_type_class
-elf_cris_reloc_type_class (rela)
-     const Elf_Internal_Rela *rela;
+elf_cris_reloc_type_class (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..940f357 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.
 
@@ -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..246e5f5 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 (hunt@cygnus.com).
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -463,9 +463,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-epiphany.c b/bfd/elf32-epiphany.c
index d5e61a2..b427ef3 100644
--- a/bfd/elf32-epiphany.c
+++ b/bfd/elf32-epiphany.c
@@ -1,5 +1,5 @@
 /* Adapteva epiphany specific support for 32-bit ELF
-   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2011
+   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2011, 2012
    Free Software Foundation, Inc.
    Contributed by Embecosm on behalf of Adapteva, Inc.
 
@@ -524,9 +524,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-fr30.c b/bfd/elf32-fr30.c
index 97b0d29..fe7cf92 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;
diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c
index e4e7f24..271ec02 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 [] =
 {
@@ -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;
@@ -4159,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
@@ -4234,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
@@ -4248,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;
@@ -4293,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;
@@ -4302,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;
@@ -4351,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;
@@ -4370,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;
@@ -4418,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;
 
@@ -4436,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;
@@ -5504,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;
@@ -5681,7 +5614,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;
@@ -5913,7 +5846,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);
 
@@ -6150,11 +6083,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;
@@ -6410,8 +6342,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)
     {
@@ -6432,8 +6363,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)
@@ -6443,9 +6373,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;
@@ -6455,9 +6383,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)
@@ -6550,9 +6476,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;
@@ -6820,10 +6744,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;
diff --git a/bfd/elf32-h8300.c b/bfd/elf32-h8300.c
index 95d3983..388d220 100644
--- a/bfd/elf32-h8300.c
+++ b/bfd/elf32-h8300.c
@@ -1,6 +1,6 @@
 /* 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.
+   2007, 2008, 2009, 2010, 2012 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -52,12 +52,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 */
@@ -304,7 +305,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)
@@ -460,9 +461,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;
@@ -699,7 +700,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;
@@ -1523,7 +1524,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 dcf6df0..dc3053c 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -1,6 +1,6 @@
 /* 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
+   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    Original code by
@@ -1005,14 +1005,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.  */
@@ -1898,13 +1898,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
@@ -1922,7 +1915,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;
@@ -2232,7 +2225,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;
@@ -3741,10 +3734,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)
@@ -4513,7 +4506,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..5998db7 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 linas@linas.org
 
@@ -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;
 	}
@@ -876,20 +869,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 +945,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 +1131,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 d187305..7d3652d 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
    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"
@@ -1000,9 +1001,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))
@@ -1014,22 +1015,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;
@@ -2177,13 +2173,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
@@ -2197,7 +2186,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;
@@ -2570,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");
 	  if (s == NULL)
 	    abort ();
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
@@ -2709,7 +2698,7 @@
      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.
-     
+
      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)
@@ -2730,7 +2719,7 @@
 				  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_.  */
+         entries and there is no reference to _GLOBAL_OFFSET_TABLE_.  */
       if ((got == NULL
 	   || !got->ref_regular_nonweak)
 	  && (htab->elf.sgotplt->size
@@ -2746,6 +2735,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;
@@ -2757,11 +2754,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.  */
@@ -2772,6 +2765,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
@@ -2819,11 +2820,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)
     {
@@ -3196,9 +3199,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;
@@ -3257,7 +3260,6 @@
 		  bfd_byte *loc;
 		  asection *sreloc;
 		  bfd_vma offset;
-		  bfd_boolean relocate;
 
 		  /* Need a dynamic relocation to get the real function
 		     adddress.  */
@@ -3278,14 +3280,15 @@
 		      || info->executable)
 		    {
 		      /* This symbol is resolved locally.  */
-		      outrel.r_info = ELF32_R_INFO (0, R_386_RELATIVE);
-		      relocate = TRUE;
+		      outrel.r_info = ELF32_R_INFO (0, R_386_IRELATIVE);
+		      bfd_put_32 (output_bfd,
+				  (h->root.u.def.value
+				   + h->root.u.def.section->output_section->vma
+				   + h->root.u.def.section->output_offset),
+				  contents + offset);
 		    }
 		  else
-		    {
-		      outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
-		      relocate = FALSE;
-		    }
+		    outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
 
 		  sreloc = htab->elf.irelifunc;
 		  loc = sreloc->contents;
@@ -3298,8 +3301,7 @@
 		     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.  */
-		  if (! relocate)
-		    continue;
+		  continue;
 		}
 	      /* FALLTHROUGH */
 	    case R_386_PC32:
@@ -3511,6 +3513,7 @@
 		  return FALSE;
 		}
 	      else if (!info->executable
+		       && !SYMBOLIC_BIND (info, h)
 		       && h->type == STT_FUNC
 		       && ELF_ST_VISIBILITY (h->other) == STV_PROTECTED)
 		{
@@ -4606,17 +4609,6 @@
       bfd_elf32_swap_reloc_out (output_bfd, &rel, loc);
     }
 
-  /* 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;
 }
 
@@ -4670,7 +4662,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)
@@ -4855,7 +4847,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
@@ -4872,7 +4865,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,
@@ -5117,7 +5110,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] =
@@ -5211,8 +5207,17 @@
 #undef	elf_backend_arch_data
 #define elf_backend_arch_data	&elf_i386_nacl_arch_bed
 
+#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
+
 #include "elf32-target.h"
 
+/* Restore defaults.  */
+#undef	elf_backend_modify_segment_map
+#undef	elf_backend_modify_program_headers
+
 /* VxWorks support.  */
 
 #undef	TARGET_LITTLE_SYM
diff --git a/bfd/elf32-i860.c b/bfd/elf32-i860.c
index 00c8ca7..f50e51b 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 <jle@cygnus.com>.
@@ -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..d696a27 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.
@@ -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..079a962 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.
@@ -633,9 +633,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-lm32.c b/bfd/elf32-lm32.c
index 07add20..8d530a4 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 <jon@beniston.com>
 
    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"
@@ -217,8 +217,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 +228,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 +250,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;
@@ -893,9 +895,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 +1033,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
@@ -1346,7 +1349,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 +1359,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 +1432,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 +1730,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
@@ -1863,13 +1867,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 +1888,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 +2143,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 +2369,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 +2391,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 +2487,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 +2515,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 +2528,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 +2536,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 +2554,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))
diff --git a/bfd/elf32-m32c.c b/bfd/elf32-m32c.c
index cf7ad99..b2b12ca 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.
@@ -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 ++)
     {
@@ -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)
 	{
@@ -633,13 +633,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;
@@ -692,7 +693,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 +721,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);
@@ -829,7 +830,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;
@@ -984,8 +985,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 +1016,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 +1030,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 +1043,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 +1330,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 +1380,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;
diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c
index 37d995d..e3e3bb0 100644
--- a/bfd/elf32-m32r.c
+++ b/bfd/elf32-m32r.c
@@ -1,6 +1,6 @@
 /* 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.
+   2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -1625,9 +1625,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 +1661,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 +1689,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 +1702,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 +1710,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 +1728,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 +1897,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 +1918,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 +2177,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;
@@ -2620,9 +2588,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)
 	{
@@ -2821,7 +2789,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
@@ -3014,7 +2983,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
@@ -3311,8 +3280,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
@@ -3357,7 +3325,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)
     {
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 (stcarrez@nerim.fr)
    (Heavily copied from the D10V port by Martin Hunt (hunt@cygnus.com))
@@ -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 (stcarrez@nerim.fr)
    (Heavily copied from the D10V port by Martin Hunt (hunt@cygnus.com))
@@ -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..d862c9f 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 (stcarrez@nerim.fr)
 
    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
 {
@@ -214,6 +214,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
@@ -935,6 +949,7 @@
       bfd_vma insn_page;
       bfd_boolean is_far = 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);
@@ -970,9 +985,9 @@
 	  is_far = (h && (h->other & STO_M68HC12_FAR));
 	}
 
-      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 +1030,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 ((elf_elfheader (input_bfd)->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,
@@ -1109,10 +1168,18 @@
             relocation = phys_addr;
           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)
 	{
@@ -1303,6 +1370,9 @@
   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;
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 (stcarrez@nerim.fr)
 
@@ -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 bd660e9..6946841 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++)
@@ -1145,9 +1113,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 +1123,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 +2432,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 +2441,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 +2545,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;
@@ -2675,24 +2638,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;
@@ -2827,7 +2788,7 @@
 		 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;
 	    }
@@ -3130,9 +3091,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;
@@ -3182,7 +3142,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
@@ -3209,12 +3169,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);
 
@@ -3252,13 +3212,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
@@ -3269,18 +3222,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;
@@ -3292,9 +3245,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;
@@ -3309,7 +3261,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;
@@ -3322,7 +3274,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;
     }
@@ -3336,7 +3288,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
@@ -3464,9 +3416,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;
@@ -3486,6 +3437,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;
     }
 
@@ -3639,16 +3602,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;
@@ -3717,9 +3678,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;
@@ -3741,7 +3702,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;
@@ -3816,7 +3777,7 @@
 
 	    if (sgot == NULL)
 	      {
-		sgot = bfd_get_section_by_name (dynobj, ".got");
+		sgot = bfd_get_linker_section (dynobj, ".got");
 		BFD_ASSERT (sgot != NULL);
 	      }
 
@@ -3887,7 +3848,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);
 		      }
 
@@ -3955,7 +3916,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 "
@@ -3991,7 +3952,7 @@
 
 	  if (splt == NULL)
 	    {
-	      splt = bfd_get_section_by_name (dynobj, ".plt");
+	      splt = bfd_get_linker_section (dynobj, ".plt");
 	      BFD_ASSERT (splt != NULL);
 	    }
 
@@ -4010,7 +3971,7 @@
 
 	  if (splt == NULL)
 	    {
-	      splt = bfd_get_section_by_name (dynobj, ".plt");
+	      splt = bfd_get_linker_section (dynobj, ".plt");
 	      BFD_ASSERT (splt != NULL);
 	    }
 
@@ -4264,11 +4225,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;
 
@@ -4291,9 +4251,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
@@ -4358,8 +4318,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;
@@ -4482,8 +4442,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
@@ -4495,20 +4454,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;
@@ -4516,16 +4468,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;
@@ -4652,7 +4604,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;
@@ -4790,8 +4742,7 @@
 }
 
 static enum elf_reloc_type_class
-elf32_m68k_reloc_type_class (rela)
-     const Elf_Internal_Rela *rela;
+elf32_m68k_reloc_type_class (const Elf_Internal_Rela *rela)
 {
   switch ((int) ELF32_R_TYPE (rela->r_info))
     {
@@ -4816,6 +4767,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
@@ -4855,6 +4869,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..288394f 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;
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-microblaze.c b/bfd/elf32-microblaze.c
index b180dc4..27b569e 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"
@@ -839,7 +839,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 +868,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 +884,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 +913,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;
@@ -1875,12 +1875,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
@@ -2079,18 +2080,19 @@
 		      htab->elf.dynobj = abfd;
 		    dynobj = htab->elf.dynobj;
 
-		    sreloc = bfd_get_section_by_name (dynobj, name);
+		    sreloc = bfd_get_linker_section (dynobj, name);
 		    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;
+			sreloc = bfd_make_section_anyway_with_flags (dynobj,
+								     name,
+								     flags);
 			if (sreloc == NULL
-			    || ! bfd_set_section_flags (dynobj, sreloc, flags)
 			    || ! bfd_set_section_alignment (dynobj, sreloc, 2))
 			  return FALSE;
 		      }
@@ -2166,11 +2168,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))
@@ -2867,8 +2869,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
@@ -2906,14 +2907,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 +2969,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 +3005,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;
diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
index fd3d4ba..61e8b45 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[] =
@@ -1796,6 +1901,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[] =
diff --git a/bfd/elf32-moxie.c b/bfd/elf32-moxie.c
index 8463599..c1a793e 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;
diff --git a/bfd/elf32-msp430.c b/bfd/elf32-msp430.c
index 9a5fb2a..c0459f4 100644
--- a/bfd/elf32-msp430.c
+++ b/bfd/elf32-msp430.c
@@ -1,5 +1,5 @@
 /*  MSP430-specific support for 32-bit ELF
-    Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2010
+    Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2012
     Free Software Foundation, Inc.
     Contributed by Dmitry Diky <diwil@mail.ru>
 
@@ -454,9 +454,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-mt.c b/bfd/elf32-mt.c
index 1be5d00..c03d8f4 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.
@@ -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;
diff --git a/bfd/elf32-openrisc.c b/bfd/elf32-openrisc.c
index ada738e..2b002ab 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, jrydberg@opencores.org
 
@@ -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;
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 18922dc..3d0a2d9 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.
 
@@ -38,12 +38,21 @@
 #include "elf-vxworks.h"
 #include "dwarf2.h"
 
+typedef enum split16_format_type
+{
+  split16a_type = 0,
+  split16d_type
+}
+split16_format_type;
+
 /* RELA relocations are used here.  */
 
 static bfd_reloc_status_type ppc_elf_addr16_ha_reloc
   (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 +1401,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 */  /* FIXME: Does this apply to split relocs? */
+	 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 */
+	 0x1f00fff,		/* 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 */
+	 0x1f00fff,		/* 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 */
+	 0x1f00fff,		/* 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 */
+	 0x1f00fff,		/* 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 */
+	 0x1f00fff,		/* 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 */
+	 0x1f00fff,		/* 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) */
@@ -1628,6 +1893,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;
@@ -1920,7 +2214,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 +2246,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 +2341,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_tdata (abfd)->segment_map; 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
@@ -2732,7 +3112,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 +3209,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 +3229,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 +3303,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 +3312,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 +3326,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 ();
 
@@ -3620,10 +4000,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;
@@ -3631,6 +4022,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)
 	    {
@@ -3647,6 +4049,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)
@@ -4244,6 +4648,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.  */
@@ -5045,13 +5467,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
@@ -5075,7 +5490,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;
 
@@ -5589,7 +6004,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;
@@ -5829,7 +6244,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;
@@ -5874,7 +6290,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)
 	    {
@@ -5977,6 +6394,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;
 }
 
@@ -6231,7 +6708,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
@@ -6886,7 +7363,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
@@ -6895,7 +7372,7 @@
 	  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)
@@ -7618,6 +8095,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:
@@ -7893,8 +8373,10 @@
 	      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;
@@ -7944,7 +8426,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")
@@ -7976,7 +8458,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")))
 	      {
@@ -7991,9 +8473,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;
@@ -8005,7 +8531,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")
@@ -8050,7 +8576,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.  */
 
@@ -8061,6 +8605,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:
@@ -8555,14 +9200,6 @@
   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;
 }
 
@@ -8603,9 +9240,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;
 
@@ -8997,17 +9634,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
@@ -9016,47 +9646,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))
@@ -9099,7 +9690,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
@@ -9120,6 +9711,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
@@ -9132,6 +9724,8 @@
 #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"
 
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
index 92c01b0..f116839 100644
--- a/bfd/elf32-rl78.c
+++ b/bfd/elf32-rl78.c
@@ -1,5 +1,5 @@
 /* Renesas RL78 specific support for 32-bit ELF.
-   Copyright (C) 2011
+   Copyright (C) 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -85,7 +85,7 @@
   EMPTY_HOWTO (0x2a),
   EMPTY_HOWTO (0x2b),
   EMPTY_HOWTO (0x2c),
-  EMPTY_HOWTO (0x2d),
+  RL78REL (RH_RELAX, 0,  0, 0, dont,     FALSE),
 
   EMPTY_HOWTO (0x2e),
   EMPTY_HOWTO (0x2f),
@@ -234,7 +234,8 @@
   { 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_ABS16U,	R_RL78_ABS16U },
+  { BFD_RELOC_RL78_RELAX,	R_RL78_RH_RELAX }
 };
 
 static reloc_howto_type *
@@ -424,7 +425,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 ++)
     {
@@ -470,9 +471,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)
 	{
@@ -496,20 +497,8 @@
 	    else
 	      plt_offset = elf_local_got_offsets (input_bfd) + r_symndx;
 
-	    /*	    printf("%s: rel %x plt %d\n", h ? h->root.root.string : "(none)",
-		    relocation, *plt_offset);*/
-	    if (valid_16bit_address (relocation))
+	    if (! valid_16bit_address (relocation))
 	      {
-	        /* If the symbol is in range for a 16-bit address, we should
-		   have deallocated the plt entry in relax_section.  */
-	        BFD_ASSERT (*plt_offset == (bfd_vma) -1);
-	      }
-	    else
-	      {
-		/* If the symbol is out of range for a 16-bit address,
-		   we must have allocated a plt entry.  */
-		BFD_ASSERT (*plt_offset != (bfd_vma) -1);
-
 		/* 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)
@@ -575,6 +564,9 @@
 	case R_RL78_NONE:
 	  break;
 
+	case R_RL78_RH_RELAX:
+	  break;
+
 	case R_RL78_DIR8S_PCREL:
 	  RANGE (-128, 127);
 	  OP (0) = relocation;
@@ -656,6 +648,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:
@@ -1132,18 +1134,6 @@
 	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,
-	      (unsigned long) isym->st_value,
-	      (unsigned long) isym->st_size,
-	      isym->st_name,
-	      bfd_elf_string_from_elf_section (abfd, symtab_hdr->sh_link,
-					       isym->st_name),
-	      isym->st_info, st_info_str, st_info_stb_str,
-	      isym->st_other, st_other_str,
-	      isym->st_shndx, st_shndx_str);
     }
   if (free_internal)
     free (internal_syms);
@@ -1218,13 +1208,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;
@@ -1273,18 +1264,24 @@
   bfd *dynobj;
   asection *splt;
 
-  /* As an extra sanity check, verify that all plt entries have
-     been filled in.  */
+  /* 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 ((dynobj = elf_hash_table (info)->dynobj) != NULL
-      && (splt = bfd_get_section_by_name (dynobj, ".plt")) != NULL)
+  if (info->relax_trip > 0)
     {
-      bfd_byte *contents = splt->contents;
-      unsigned int i, size = splt->size;
-      for (i = 0; i < size; i += 4)
+      if ((dynobj = elf_hash_table (info)->dynobj) != NULL
+	  && (splt = bfd_get_linker_section (dynobj, ".plt")) != NULL)
 	{
-	  unsigned int x = bfd_get_32 (dynobj, contents + i);
-	  BFD_ASSERT (x != 0);
+	  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);
+	    }
 	}
     }
 
@@ -1305,7 +1302,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);
@@ -1329,8 +1326,7 @@
 };
 
 static bfd_boolean
-rl78_relax_plt_check (struct elf_link_hash_entry *h,
-                      PTR xdata)
+rl78_relax_plt_check (struct elf_link_hash_entry *h, void * xdata)
 {
   struct relax_plt_data *data = (struct relax_plt_data *) xdata;
 
@@ -1361,8 +1357,7 @@
    previously had a plt entry, give it a new entry offset.  */
 
 static bfd_boolean
-rl78_relax_plt_realloc (struct elf_link_hash_entry *h,
-                        PTR xdata)
+rl78_relax_plt_realloc (struct elf_link_hash_entry *h, void * xdata)
 {
   bfd_vma *entry = (bfd_vma *) xdata;
 
@@ -1503,6 +1498,485 @@
   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,
@@ -1510,12 +1984,463 @@
      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 \
+      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)
+	{
+	  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.  */
+	      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;
 }
 
diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c
index 0ceed85..771867f 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.
@@ -521,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)
 	{
@@ -1653,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);
@@ -1926,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;
@@ -2115,7 +2115,7 @@
 		   /* Decodable bits.  */
 		   && (insn[0] & 0xcc) == 0xcc
 		   /* Width.  */
-		   && (insn[0] & 0x30) != 3
+		   && (insn[0] & 0x30) != 0x30
 		   /* Register MSBs.  */
 		   && (insn[1] & 0x88)  == 0x00)
 	    {
@@ -2219,7 +2219,7 @@
 		   /* Decodable bits.  */
 		   && (insn[0] & 0xc3) == 0xc3
 		   /* Width.  */
-		   && (insn[0] & 0x30) != 3
+		   && (insn[0] & 0x30) != 0x30
 		   /* Register MSBs.  */
 		   && (insn[1] & 0x88)  == 0x00)
 	    {
@@ -3060,7 +3060,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,
@@ -3084,7 +3085,8 @@
       bsec = abfd->sections;
       while (bsec)
 	{
-	  if (phdr[i].p_vaddr <= bsec->vma
+	  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);
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index 2cfd53e..8d654d5 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,67 +25,15 @@
 #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[] =
@@ -211,6 +159,8 @@
 	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),
 };
 
 /* GNU extension to record C++ vtable hierarchy.  */
@@ -220,9 +170,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)
     {
@@ -324,6 +273,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 +308,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 +336,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,15 +351,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 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;
@@ -455,9 +401,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 +414,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 +429,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 +455,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 +473,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 +483,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 +495,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 +513,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 +591,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 +600,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 +634,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 +645,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 +689,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 +708,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 +721,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 +741,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 +771,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,8 +781,7 @@
 /* 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);
@@ -794,11 +798,11 @@
       return NULL;
     }
 
-  ret->sgot = NULL;
-  ret->sgotplt = NULL;
-  ret->srelgot = NULL;
-  ret->splt = NULL;
-  ret->srelplt = NULL;
+  ret->elf.sgot = NULL;
+  ret->elf.sgotplt = NULL;
+  ret->elf.srelgot = NULL;
+  ret->elf.splt = NULL;
+  ret->elf.srelplt = NULL;
   ret->sdynbss = NULL;
   ret->srelbss = NULL;
   ret->tls_ldm_got.refcount = 0;
@@ -811,9 +815,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 +823,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 +837,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 +864,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 +877,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 +928,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 +958,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 +971,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,7 +1002,31 @@
 	}
 
       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 (!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];
@@ -1039,24 +1062,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,13 +1080,34 @@
 	    }
 	}
 
+      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_PLT16DBL:
@@ -1212,7 +1248,7 @@
 	case R_390_PC16DBL:
 	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 +1258,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
@@ -1265,8 +1304,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 +1335,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 +1346,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 +1354,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;
@@ -1389,6 +1427,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 +1436,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 +1457,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 +1474,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);
@@ -1529,8 +1589,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 +1610,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 +1690,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 +1709,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 +1724,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 +1739,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 +1752,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 +1772,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 +1798,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 +1831,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 +1852,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 +1863,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 +1888,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 +1966,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 +1992,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 +2011,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 +2029,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 +2067,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 +2083,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 +2121,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 +2192,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 +2211,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 +2230,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 +2242,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 +2256,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 +2275,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 +2313,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 +2336,52 @@
 	{
 	  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_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 +2393,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 +2420,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 +2453,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 +2462,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,7 +2504,7 @@
 		  else
 		    {
 		      bfd_put_32 (output_bfd, relocation,
-				  htab->sgot->contents + off);
+				  base_got->contents + off);
 		      h->got.offset |= 1;
 		    }
 		}
@@ -2386,7 +2526,7 @@
 	      else
 		{
 		  bfd_put_32 (output_bfd, relocation,
-			      htab->sgot->contents + off);
+			      htab->elf.sgot->contents + off);
 
 		  if (info->shared)
 		    {
@@ -2394,12 +2534,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 +2555,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 +2563,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,13 +2577,13 @@
 	     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;
 
@@ -2459,7 +2599,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 +2607,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;
 
@@ -2482,16 +2627,22 @@
 	     this symbol resolve the symbol directly.  */
 	  if (   h == NULL
 	      || h->plt.offset == (bfd_vma) -1
-	      || htab->splt == NULL)
+	      || htab->elf.splt == NULL)
 	    {
-	      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;
 
@@ -2502,6 +2653,67 @@
 	case R_390_PC16DBL:
 	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;
 
@@ -2668,7 +2880,7 @@
 	      continue;
 	    }
 
-	  if (htab->sgot == NULL)
+	  if (htab->elf.sgot == NULL)
 	    abort ();
 
 	  if (h != NULL)
@@ -2691,11 +2903,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 +2919,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 +2931,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 +2954,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 +2986,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 +3005,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 +3016,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 +3074,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 +3131,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 +3151,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 +3159,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 +3190,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 +3209,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);
@@ -3007,6 +3239,8 @@
 	   howto->name,
 	   h->root.root.string);
 
+    do_relocation:
+
       if (r_type == R_390_20
 	  || r_type == R_390_GOT20
 	  || r_type == R_390_GOTPLT20
@@ -3063,17 +3297,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);
 
@@ -3087,131 +3467,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;
+	    }
 	}
     }
 
@@ -3226,11 +3614,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
@@ -3238,9 +3626,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);
@@ -3252,13 +3668,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);
     }
 
@@ -3298,8 +3715,7 @@
    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 Elf_Internal_Rela *rela)
 {
   switch ((int) ELF32_R_TYPE (rela->r_info))
     {
@@ -3317,23 +3733,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;
@@ -3351,15 +3768,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;
 	    }
@@ -3368,72 +3785,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;
@@ -3519,6 +3946,7 @@
 #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..01a602b 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 (brain.lin@sunplusct.com)
@@ -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)
         {
@@ -3123,7 +3123,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 +3259,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 +3417,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 +3432,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 +3489,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?  */
@@ -3568,7 +3568,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)
diff --git a/bfd/elf32-score7.c b/bfd/elf32-score7.c
index 3e98bfc..3615a1e 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 (brain.lin@sunplusct.com)
    Mei Ligang (ligang@sunnorth.com.cn)
@@ -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)
         {
@@ -2928,7 +2928,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 +3066,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 +3224,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 +3239,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 +3297,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?  */
@@ -3377,7 +3377,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)
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index 780a3bf..cbd00aa 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
+   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;
 };
@@ -2621,39 +2622,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 +2708,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 +2737,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 +2750,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 +2758,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 +2777,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 +2902,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 +2919,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 +3053,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 +3079,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)
@@ -3446,7 +3418,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 +3760,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 +3776,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 +3955,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 +4023,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)
@@ -4240,9 +4215,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;
@@ -4698,8 +4673,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);
 			}
 
@@ -5020,7 +4995,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);
 		  }
 
@@ -5310,7 +5285,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);
 		}
 
@@ -6093,7 +6068,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;
 
@@ -7167,8 +7142,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
@@ -7204,7 +7178,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)
     {
diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c
index cff9185..28628f8 100644
--- a/bfd/elf32-spu.c
+++ b/bfd/elf32-spu.c
@@ -1,6 +1,7 @@
 /* SPU specific support for 32-bit ELF
 
-   Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+   Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012
+   Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -1425,7 +1426,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;
 
@@ -4895,9 +4896,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;
diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c
index 19287fe..dbe2c16 100644
--- a/bfd/elf32-tic6x.c
+++ b/bfd/elf32-tic6x.c
@@ -1,5 +1,5 @@
 /* 32-bit ELF support for TI C6X
-   Copyright 2010, 2011
+   Copyright 2010, 2011, 2012
    Free Software Foundation, Inc.
    Contributed by Joseph Myers <joseph@codesourcery.com>
    		  Bernd Schmidt  <bernds@codesourcery.com>
@@ -1670,9 +1670,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))
@@ -1849,8 +1849,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
@@ -2157,13 +2157,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 +2170,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 +2327,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)
 	{
@@ -3312,7 +3305,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;
@@ -3614,7 +3607,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,6 +4011,9 @@
   if (!_bfd_generic_verify_endian_match (ibfd, obfd))
     return FALSE;
 
+  if (! is_tic6x_elf (ibfd) || ! is_tic6x_elf (obfd))
+    return TRUE;
+
   if (!elf32_tic6x_merge_attributes (ibfd, obfd))
     return FALSE;
 
diff --git a/bfd/elf32-tilegx.c b/bfd/elf32-tilegx.c
index 902e9ba..1b4884b 100644
--- a/bfd/elf32-tilegx.c
+++ b/bfd/elf32-tilegx.c
@@ -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 7b08aff..fa883e1 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 },
@@ -745,7 +804,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 +904,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])))
@@ -1152,8 +1224,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 +1297,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 +1360,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.  */
@@ -1348,8 +1513,21 @@
 	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
 	}
 
+      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 +1536,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 +1633,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 +1720,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
@@ -1725,6 +1921,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 +1955,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 +2133,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 +2147,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;
@@ -2040,7 +2231,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 +2427,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 +2665,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 +2810,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 +2874,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 +2893,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:
@@ -2908,6 +3300,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 +3347,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 +3355,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)
 	    {
@@ -3360,8 +3775,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
@@ -3436,14 +3850,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);
diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c
index 9e6f77d..11fbbb4 100644
--- a/bfd/elf32-v850.c
+++ b/bfd/elf32-v850.c
@@ -1,6 +1,7 @@
 /* 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.
+   2006, 2007, 2008, 2009, 2010, 2011, 2012
+   Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -2093,9 +2094,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-vax.c b/bfd/elf32-vax.c
index 643381c..84ec972 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 <matt@3am-software.com>.
 
@@ -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.  */
@@ -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;
 
@@ -613,24 +613,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;
@@ -967,7 +966,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
@@ -997,13 +996,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 +1035,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 +1045,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;
@@ -1092,7 +1084,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;
@@ -1105,13 +1097,13 @@
 	 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");
+      s = bfd_get_linker_section (dynobj, ".rela.got");
       if (s != NULL)
 	s->size = 0;
-      s = bfd_get_section_by_name (dynobj, ".got.plt");
+      s = bfd_get_linker_section (dynobj, ".got.plt");
       if (s != NULL)
 	s->size = 0;
-      s = bfd_get_section_by_name (dynobj, ".got");
+      s = bfd_get_linker_section (dynobj, ".got");
       if (s != NULL)
 	s->size = 0;
     }
@@ -1130,7 +1122,7 @@
      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 +1261,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;
 
@@ -1291,7 +1283,7 @@
    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;
@@ -1306,8 +1298,8 @@
   if (dynobj == NULL)
     return TRUE;
 
-  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)
@@ -1450,9 +1442,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;
@@ -1477,7 +1469,7 @@
 
 	    if (sgot == NULL)
 	      {
-		sgot = bfd_get_section_by_name (dynobj, ".got");
+		sgot = bfd_get_linker_section (dynobj, ".got");
 		BFD_ASSERT (sgot != NULL);
 	      }
 
@@ -1553,13 +1545,13 @@
 
 	  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 +1690,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 +1807,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,8 +1871,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
@@ -1923,8 +1913,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
@@ -1955,16 +1944,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;
diff --git a/bfd/elf32-xc16x.c b/bfd/elf32-xc16x.c
index 11d9840..b7e0d41 100644
--- a/bfd/elf32-xc16x.c
+++ b/bfd/elf32-xc16x.c
@@ -1,5 +1,5 @@
 /* Infineon XC16X-specific support for 16-bit ELF.
-   Copyright 2006, 2007, 2009, 2010  Free Software Foundation, Inc.
+   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)
diff --git a/bfd/elf32-xgate.c b/bfd/elf32-xgate.c
new file mode 100644
index 0000000..bd62438
--- /dev/null
+++ b/bfd/elf32-xgate.c
@@ -0,0 +1,732 @@
+/* Freescale XGATE-specific support for 32-bit ELF
+   Copyright 2010, 2011, 2012
+   Free Software Foundation, Inc.
+   Contributed by Sean Keys(skeys@ipdatasys.com)
+
+   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 */
+	 0x00ff, /* src_mask */
+	 0x00ff, /* 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_generic_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_malloc (amt);
+  if (ret == (struct xgate_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),
+      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_malloc (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)))
+    return NULL;
+
+  ret->stub_bfd = NULL;
+  ret->stub_section = 0;
+  ret->add_stub_section = NULL;
+  ret->sym_cache.abfd = 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 (skeys@ipdatasys.com)
+   (Heavily copied from the HC11 port by Stephane Carrez (stcarrez@nerim.fr))
+
+   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..c657b84 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.
@@ -456,18 +456,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 +716,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 +780,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 +822,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 +970,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 877ab6f..2de9480 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.
@@ -1414,11 +1414,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 +1435,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 +1475,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 +1637,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 +1713,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;
@@ -2656,9 +2657,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)
 	{
@@ -3275,7 +3276,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
@@ -8962,9 +8963,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
@@ -10275,7 +10276,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);
 }
 
 
@@ -10296,7 +10297,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);
 }
 
 
@@ -10675,7 +10676,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];
@@ -10685,7 +10686,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);
 
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index 94ea685..40e4bfb 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
+   Free Software Foundation, Inc.
    Contributed by Richard Henderson <rth@tamu.edu>.
 
    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.  */
@@ -356,7 +357,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 +370,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 +422,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 +1377,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;
@@ -1506,7 +1507,7 @@
 	  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;
 
@@ -1548,7 +1549,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;
@@ -2102,7 +2103,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;
 
@@ -2391,7 +2392,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;
 
@@ -2543,7 +2544,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;
@@ -2588,7 +2590,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;
 
@@ -2598,7 +2600,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)
     {
@@ -2614,7 +2616,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;
     }
 }
@@ -2773,7 +2775,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;
     }
@@ -2823,7 +2825,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);
@@ -2859,7 +2861,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;
@@ -3169,7 +3171,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)
@@ -3754,7 +3756,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;
@@ -4107,10 +4109,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)
@@ -4154,7 +4156,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;
 
@@ -4165,7 +4167,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;
@@ -4265,7 +4267,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)
 	    {
@@ -4316,9 +4318,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;
@@ -4727,7 +4729,7 @@
 
 	    if (r_symndx < symtab_hdr->sh_info
 		&& sec != NULL && howto->pc_relative
-		&& elf_discarded_section (sec))
+		&& discarded_section (sec))
 	      break;
 
 	    if (h != NULL)
@@ -4781,9 +4783,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)
@@ -4853,7 +4855,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;
@@ -4918,7 +4920,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)
     {
@@ -4926,8 +4928,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;
@@ -4935,7 +4937,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;
@@ -5102,7 +5104,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)
@@ -5206,7 +5208,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)
@@ -5253,7 +5255,7 @@
 	  einfo.failed = FALSE;
 	  elf_link_hash_traverse (elf_hash_table (info),
 				  elf64_alpha_output_extsym,
-				  (PTR) &einfo);
+				  &einfo);
 	  if (einfo.failed)
 	    return FALSE;
 
diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index 057a92d..62efef3 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.
+   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"
@@ -415,16 +416,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;
@@ -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;
     }
@@ -2491,7 +2492,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)
     {
@@ -3919,9 +3920,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;
diff --git a/bfd/elf64-ia64-vms.c b/bfd/elf64-ia64-vms.c
new file mode 100644
index 0000000..ef78374
--- /dev/null
+++ b/bfd/elf64-ia64-vms.c
@@ -0,0 +1,5604 @@
+/* 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 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_generic_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;
+
+	  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 (strcmp (h->root.root.string, "_DYNAMIC") == 0
+      || 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 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;
+      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 a427985..e02f969 100644
--- a/bfd/elf64-mips.c
+++ b/bfd/elf64-mips.c
@@ -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[] =
@@ -1686,6 +1791,111 @@
 	 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 */
+	 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 */
+	 FALSE,			/* 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 */
+	 FALSE,			/* 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 */
+	 FALSE,			/* 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 */
+	 FALSE,			/* 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 */
+	 FALSE,			/* 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 */
+	 FALSE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
 };
 
 static reloc_howto_type micromips_elf64_howto_table_rel[] =
@@ -2498,6 +2708,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 +3119,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[] =
@@ -3906,7 +4126,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.  */
diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c
index ecc9ad0..3195075 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 <hp@bitrange.com>
 
@@ -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.  */
@@ -2093,9 +2038,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 +2055,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 +2078,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 +2142,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 +2161,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 +2203,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 +2232,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 +2279,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 +2306,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 +2384,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 +2456,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 +2547,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 +2596,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 +2800,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 4560599..50dad3b 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 <info@swox.com>,
    based on elf32-ppc.c by Ian Lance Taylor.
    Largely rewritten by Alan Modra.
@@ -55,7 +55,7 @@
 static bfd_reloc_status_type ppc64_elf_unhandled_reloc
   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 static bfd_vma opd_entry_value
-  (asection *, bfd_vma, asection **, bfd_vma *);
+  (asection *, bfd_vma, asection **, bfd_vma *, bfd_boolean);
 
 #define TARGET_LITTLE_SYM	bfd_elf64_powerpcle_vec
 #define TARGET_LITTLE_NAME	"elf64-powerpcle"
@@ -105,6 +105,7 @@
 #define elf_backend_gc_sweep_hook	      ppc64_elf_gc_sweep_hook
 #define elf_backend_adjust_dynamic_symbol     ppc64_elf_adjust_dynamic_symbol
 #define elf_backend_hide_symbol		      ppc64_elf_hide_symbol
+#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_init_index_section	      _bfd_elf_init_2_index_sections
@@ -152,6 +153,13 @@
 #define ADDIS_R2_R2	0x3c420000	/* addis %r2,%r2,off@ha  */
 #define ADDI_R2_R2	0x38420000	/* addi  %r2,%r2,off@l   */
 
+#define XOR_R11_R11_R11	0x7d6b5a78	/* xor   %r11,%r11,%r11  */
+#define ADD_R12_R12_R11	0x7d8c5a14	/* add   %r12,%r12,%r11  */
+#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_R11_0R2	0xe9620000	/* ld	 %r11,xxx+0(%r2) */
 #define LD_R2_0R2	0xe8420000	/* ld	 %r2,xxx+0(%r2)  */
 
@@ -2339,7 +2347,7 @@
     {
       bfd_vma dest = opd_entry_value (symbol->section,
 				      symbol->value + reloc_entry->addend,
-				      NULL, NULL);
+				      NULL, NULL, FALSE);
       if (dest != (bfd_vma) -1)
 	reloc_entry->addend = dest - (symbol->value
 				      + symbol->section->output_section->vma
@@ -2356,8 +2364,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
@@ -2374,7 +2382,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
@@ -2714,7 +2722,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);
@@ -3584,7 +3592,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 {
@@ -3752,14 +3761,20 @@
   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 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;
 
@@ -4230,7 +4245,7 @@
 								 ".eh_frame",
 								 flags);
       if (htab->glink_eh_frame == NULL
-	  || !bfd_set_section_alignment (abfd, htab->glink_eh_frame, 2))
+	  || !bfd_set_section_alignment (dynobj, htab->glink_eh_frame, 2))
 	return FALSE;
     }
 
@@ -4293,7 +4308,7 @@
       if (! _bfd_elf_create_got_section (htab->elf.dynobj, info))
 	return FALSE;
 
-      htab->got = bfd_get_section_by_name (htab->elf.dynobj, ".got");
+      htab->got = bfd_get_linker_section (htab->elf.dynobj, ".got");
       if (!htab->got)
 	abort ();
     }
@@ -4332,12 +4347,12 @@
     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->got = bfd_get_linker_section (dynobj, ".got");
+  htab->plt = bfd_get_linker_section (dynobj, ".plt");
+  htab->relplt = bfd_get_linker_section (dynobj, ".rela.plt");
+  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
       || (!info->shared && !htab->relbss))
@@ -5507,14 +5522,16 @@
 opd_entry_value (asection *opd_sec,
 		 bfd_vma offset,
 		 asection **code_sec,
-		 bfd_vma *code_off)
+		 bfd_vma *code_off,
+		 bfd_boolean in_code_sec)
 {
   bfd *opd_bfd = opd_sec->owner;
   Elf_Internal_Rela *relocs;
   Elf_Internal_Rela *lo, *hi, *look;
   bfd_vma val;
 
-  /* No relocs implies we are linking a --just-symbols object.  */
+  /* No relocs implies we are linking a --just-symbols object, or looking
+     at a final linked executable with addr2line or somesuch.  */
   if (opd_sec->reloc_count == 0)
     {
       char buf[8];
@@ -5526,11 +5543,22 @@
       if (code_sec != NULL)
 	{
 	  asection *sec, *likely = NULL;
-	  for (sec = opd_bfd->sections; sec != NULL; sec = sec->next)
-	    if (sec->vma <= val
-		&& (sec->flags & SEC_LOAD) != 0
-		&& (sec->flags & SEC_ALLOC) != 0)
-	      likely = sec;
+
+	  if (in_code_sec)
+	    {
+	      sec = *code_sec;
+	      if (sec->vma <= val
+		  && val < sec->vma + sec->size)
+		likely = sec;
+	      else
+		val = -1;
+	    }
+	  else
+	    for (sec = opd_bfd->sections; sec != NULL; sec = sec->next)
+	      if (sec->vma <= val
+		  && (sec->flags & SEC_LOAD) != 0
+		  && (sec->flags & SEC_ALLOC) != 0)
+		likely = sec;
 	  if (likely != NULL)
 	    {
 	      *code_sec = likely;
@@ -5569,15 +5597,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;
@@ -5606,7 +5637,12 @@
 	      if (code_off != NULL)
 		*code_off = val;
 	      if (code_sec != NULL)
-		*code_sec = sec;
+		{
+		  if (in_code_sec && *code_sec != sec)
+		    return -1;
+		  else
+		    *code_sec = sec;
+		}
 	      if (sec != NULL && sec->output_section != NULL)
 		val += sec->output_section->vma + sec->output_offset;
 	    }
@@ -5617,6 +5653,55 @@
   return val;
 }
 
+/* If the ELF symbol SYM might be a function in SEC, return the
+   function size and set *CODE_OFF to the function's entry point,
+   otherwise return zero.  */
+
+static bfd_size_type
+ppc64_elf_maybe_function_sym (const asymbol *sym, asection *sec,
+			      bfd_vma *code_off)
+{
+  bfd_size_type size;
+
+  if ((sym->flags & (BSF_SECTION_SYM | BSF_FILE | BSF_OBJECT
+		     | BSF_THREAD_LOCAL | BSF_RELC | BSF_SRELC)) != 0)
+    return 0;
+
+  size = 0;
+  if (!(sym->flags & BSF_SYNTHETIC))
+    size = ((elf_symbol_type *) sym)->internal_elf_sym.st_size;
+
+  if (strcmp (sym->section->name, ".opd") == 0)
+    {
+      if (opd_entry_value (sym->section, sym->value,
+			   &sec, code_off, TRUE) == (bfd_vma) -1)
+	return 0;
+      /* An old ABI binary with dot-syms has a size of 24 on the .opd
+	 symbol.  This size has nothing to do with the code size of the
+	 function, which is what we're supposed to return, but the
+	 code size isn't available without looking up the dot-sym.
+	 However, doing that would be a waste of time particularly
+	 since elf_find_function will look at the dot-sym anyway.
+	 Now, elf_find_function will keep the largest size of any
+	 function sym found at the code address of interest, so return
+	 1 here to avoid it incorrectly caching a larger function size
+	 for a small function.  This does mean we return the wrong
+	 size for a new-ABI function of size 24, but all that does is
+	 disable caching for such functions.  */
+      if (size == 24)
+	size = 1;
+    }
+  else
+    {
+      if (sym->section != sec)
+	return 0;
+      *code_off = sym->value;
+    }
+  if (size == 0)
+    size = 1;
+  return size;
+}
+
 /* Return true if symbol is defined in a regular object file.  */
 
 static bfd_boolean
@@ -5694,7 +5779,7 @@
       else if (get_opd_info (eh->elf.root.u.def.section) != NULL
 	       && opd_entry_value (eh->elf.root.u.def.section,
 				   eh->elf.root.u.def.value,
-				   &sec, NULL) != (bfd_vma) -1)
+				   &sec, NULL, FALSE) != (bfd_vma) -1)
 	sec->flags |= SEC_KEEP;
 
       sec = eh->elf.root.u.def.section;
@@ -5745,7 +5830,7 @@
       else if (get_opd_info (eh->elf.root.u.def.section) != NULL
 	       && opd_entry_value (eh->elf.root.u.def.section,
 				   eh->elf.root.u.def.value,
-				   &code_sec, NULL) != (bfd_vma) -1)
+				   &code_sec, NULL, FALSE) != (bfd_vma) -1)
 	code_sec->flags |= SEC_KEEP;
     }
 
@@ -5805,7 +5890,7 @@
 	      else if (get_opd_info (eh->elf.root.u.def.section) != NULL
 		       && opd_entry_value (eh->elf.root.u.def.section,
 					   eh->elf.root.u.def.value,
-					   &rsec, NULL) != (bfd_vma) -1)
+					   &rsec, NULL, FALSE) != (bfd_vma) -1)
 		eh->elf.root.u.def.section->gc_mark = 1;
 	      else
 		rsec = h->root.u.def.section;
@@ -6274,7 +6359,7 @@
       && opd_entry_value (fdh->elf.root.u.def.section,
 			  fdh->elf.root.u.def.value,
 			  &fh->elf.root.u.def.section,
-			  &fh->elf.root.u.def.value) != (bfd_vma) -1)
+			  &fh->elf.root.u.def.value, FALSE) != (bfd_vma) -1)
     {
       fh->elf.root.type = fdh->elf.root.type;
       fh->elf.forced_local = 1;
@@ -6383,7 +6468,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 },
@@ -6409,9 +6494,10 @@
 
   /* 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);
 
@@ -6530,13 +6616,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
@@ -6551,7 +6630,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;
@@ -6852,7 +6931,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;
@@ -7033,7 +7112,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)
@@ -8077,8 +8156,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;
@@ -8091,7 +8170,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)
@@ -8201,7 +8280,7 @@
 		goto error_ret;
 
 	      if (sym_sec == NULL
-		  || elf_discarded_section (sym_sec))
+		  || discarded_section (sym_sec))
 		continue;
 
 	      if (!SYMBOL_CALLS_LOCAL (info, h))
@@ -8281,7 +8360,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)
@@ -8503,7 +8582,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,
@@ -9061,7 +9140,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;
@@ -9471,21 +9550,126 @@
   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 11,xxx(2)		ld 11,xxx(2)
+   .	mtctr 11		mtctr 11
+   .	xor 11,11,11		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 = PLT_CALL_STUB_SIZE;
+
+  if (!(ALWAYS_EMIT_R2SAVE
+	|| stub_entry->stub_type == ppc_stub_plt_call_r2save))
+    size -= 4;
+  if (!htab->plt_static_chain)
+    size -= 4;
+  if (htab->plt_thread_safe)
+    size += 8;
+  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;
+  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_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_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) / PLT_ENTRY_SIZE;
+      bfd_vma glinkoff = GLINK_CALL_STUB_SIZE + pltindex * 8;
+      bfd_vma to, from;
+
+      if (pltindex > 32767)
+	glinkoff += (pltindex - 32767) * 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);
@@ -9498,7 +9682,7 @@
 	    }
 	  else
 	    {
-	      r[2].r_offset = r[1].r_offset + 8;
+	      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)
@@ -9509,7 +9693,9 @@
 		}
 	    }
 	}
-      bfd_put_32 (obfd, STD_R2_40R1, p),			p += 4;
+      if (ALWAYS_EMIT_R2SAVE
+	  || stub_entry->stub_type == ppc_stub_plt_call_r2save)
+	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))
@@ -9518,16 +9704,22 @@
 	  offset = 0;
 	}
       bfd_put_32 (obfd, MTCTR_R11, p),				p += 4;
+      if (use_fake_dep)
+	{
+	  bfd_put_32 (obfd, XOR_R11_R11_R11, p),		p += 4;
+	  bfd_put_32 (obfd, ADD_R12_R12_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;
     }
   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))
 	    {
@@ -9537,7 +9729,7 @@
 	    }
 	  else
 	    {
-	      r[1].r_offset = r[0].r_offset + 8;
+	      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)
@@ -9548,7 +9740,9 @@
 		}
 	    }
 	}
-      bfd_put_32 (obfd, STD_R2_40R1, p),			p += 4;
+      if (ALWAYS_EMIT_R2SAVE
+	  || stub_entry->stub_type == ppc_stub_plt_call_r2save)
+	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))
 	{
@@ -9556,11 +9750,23 @@
 	  offset = 0;
 	}
       bfd_put_32 (obfd, MTCTR_R11, p),				p += 4;
+      if (use_fake_dep)
+	{
+	  bfd_put_32 (obfd, XOR_R11_R11_R11, 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;
-      bfd_put_32 (obfd, BCTR, p),				p += 4;
     }
+  if (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, p),		p += 4;
+    }
+  else
+    bfd_put_32 (obfd, BCTR, p),					p += 4;
   return p;
 }
 
@@ -9581,9 +9787,12 @@
 #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;
@@ -9596,7 +9805,7 @@
 
   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;
@@ -9943,6 +10152,7 @@
       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)
@@ -10009,6 +10219,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)
 	{
@@ -10028,11 +10247,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;
 
@@ -10052,6 +10269,7 @@
 				       "long_branch_r2off",
 				       "plt_branch",
 				       "plt_branch_r2off",
+				       "plt_call",
 				       "plt_call" };
 
       len1 = strlen (stub_str[stub_entry->stub_type - 1]);
@@ -10102,7 +10320,8 @@
   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;
@@ -10118,18 +10337,9 @@
 	      - 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
@@ -10344,7 +10554,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;
@@ -10372,7 +10584,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;
 
@@ -10741,7 +10954,8 @@
 		  sym_value += adjust;
 		}
 
-	      dest = opd_entry_value (sym_sec, sym_value, &sym_sec, NULL);
+	      dest = opd_entry_value (sym_sec, sym_value,
+				      &sym_sec, NULL, FALSE);
 	      if (dest == (bfd_vma) -1)
 		continue;
 	    }
@@ -11098,7 +11312,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;
@@ -11108,6 +11323,40 @@
     return FALSE;
 
   htab->plt_static_chain = plt_static_chain;
+  htab->plt_stub_align = plt_stub_align;
+  if (plt_thread_safe == -1)
+    {
+      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;
@@ -11281,7 +11530,7 @@
 			  sym_value += adjust;
 			}
 		      dest = opd_entry_value (sym_sec, sym_value,
-					      &code_sec, &code_value);
+					      &code_sec, &code_value, FALSE);
 		      if (dest != (bfd_vma) -1)
 			{
 			  destination = dest;
@@ -11342,10 +11591,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;
@@ -11361,6 +11614,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;
 		    }
 
@@ -11380,7 +11635,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;
@@ -11443,9 +11699,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;
@@ -11456,10 +11712,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)
@@ -11689,17 +11957,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;
@@ -11707,6 +11979,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;
@@ -11739,6 +12013,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;
@@ -11776,7 +12052,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.  */
@@ -11785,6 +12070,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)
@@ -11818,14 +12111,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;
 }
@@ -11925,8 +12220,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.  */
@@ -12036,10 +12331,10 @@
 	}
       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)
@@ -12558,6 +12853,7 @@
 	  stub_entry = ppc_get_stub_entry (input_section, sec, fdh, rel, 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))
 	    {
@@ -12586,7 +12882,8 @@
 
 	      if (!can_plt_call)
 		{
-		  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)
 		    {
 		      /* If this is a plain branch rather than a branch
 			 and link, don't require a nop.  However, don't
@@ -12633,7 +12930,8 @@
 		}
 
 	      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;
 	    }
 
@@ -12646,7 +12944,7 @@
 	      bfd_vma off = (relocation + addend
 			     - sec->output_section->vma
 			     - sec->output_offset);
-	      bfd_vma dest = opd_entry_value (sec, off, NULL, NULL);
+	      bfd_vma dest = opd_entry_value (sec, off, NULL, NULL, FALSE);
 	      if (dest != (bfd_vma) -1)
 		{
 		  relocation = dest;
@@ -12679,7 +12977,10 @@
 			    + stub_entry->stub_sec->output_section->vma);
 	      addend = 0;
 
- 	      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)
@@ -12688,7 +12989,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
@@ -13626,7 +13927,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;
@@ -13695,10 +13996,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;
 }
 
@@ -13739,7 +14036,7 @@
     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)
     {
@@ -13867,7 +14164,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))
diff --git a/bfd/elf64-ppc.h b/bfd/elf64-ppc.h
index 9026c56..2728b27 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.
@@ -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 7d3e882..8512fc0 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 (schwidefsky@de.ibm.com).
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -25,69 +25,19 @@
 #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[] =
 {
@@ -219,6 +169,9 @@
 	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),
+
 };
 
 /* GNU extension to record C++ vtable hierarchy.  */
@@ -228,9 +181,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)
     {
@@ -346,6 +298,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 +335,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 +363,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 +378,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;
@@ -478,9 +427,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 +440,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 +455,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 +489,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 +528,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 +548,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 +559,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 +603,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 +622,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 +635,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 +654,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 +684,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,8 +694,7 @@
 /* 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);
@@ -749,11 +711,11 @@
       return NULL;
     }
 
-  ret->sgot = NULL;
-  ret->sgotplt = NULL;
-  ret->srelgot = NULL;
-  ret->splt = NULL;
-  ret->srelplt = NULL;
+  ret->elf.sgot = NULL;
+  ret->elf.sgotplt = NULL;
+  ret->elf.srelgot = NULL;
+  ret->elf.splt = NULL;
+  ret->elf.srelplt = NULL;
   ret->sdynbss = NULL;
   ret->srelbss = NULL;
   ret->tls_ldm_got.refcount = 0;
@@ -778,10 +740,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 +762,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 +784,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 +797,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 +848,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 +913,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,7 +926,31 @@
 	}
 
       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 (!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];
@@ -1002,25 +988,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 +1008,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,7 +1034,10 @@
 	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_PLT16DBL:
@@ -1183,7 +1184,7 @@
 	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 +1194,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
@@ -1237,8 +1241,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 +1272,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 +1283,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;
@@ -1391,8 +1394,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 +1411,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);
@@ -1513,8 +1533,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 +1560,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 +1634,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 +1653,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 +1670,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 +1690,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 +1701,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 +1721,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 +1747,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 +1780,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 +1801,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 +1812,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 +1837,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 +1914,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 +1962,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 +1980,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 +2018,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 +2034,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 +2073,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 +2144,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 +2164,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 +2183,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 +2195,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 +2209,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 +2269,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 +2292,55 @@
 	{
 	  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_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 +2352,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 +2380,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 +2414,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 +2423,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,7 +2464,7 @@
 		  else
 		    {
 		      bfd_put_64 (output_bfd, relocation,
-				  htab->sgot->contents + off);
+				  base_got->contents + off);
 		      h->got.offset |= 1;
 		    }
 		}
@@ -2376,7 +2486,7 @@
 	      else
 		{
 		  bfd_put_64 (output_bfd, relocation,
-			      htab->sgot->contents + off);
+			      htab->elf.sgot->contents + off);
 
 		  if (info->shared)
 		    {
@@ -2384,12 +2494,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 +2515,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 +2523,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,13 +2538,13 @@
 	     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;
 
@@ -2451,17 +2561,21 @@
 	    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
 		 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;
 
@@ -2475,16 +2589,22 @@
 	     this symbol resolve the symbol directly.  */
 	  if (   h == NULL
 	      || h->plt.offset == (bfd_vma) -1
-	      || htab->splt == NULL)
+	      || htab->elf.splt == NULL)
 	    {
-	      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;
 
@@ -2497,6 +2617,68 @@
 	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;
 
@@ -2667,7 +2849,7 @@
 	      continue;
 	    }
 
-	  if (htab->sgot == NULL)
+	  if (htab->elf.sgot == NULL)
 	    abort ();
 
 	  if (h != NULL)
@@ -2690,11 +2872,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 +2888,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 +2900,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 +2923,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 +2955,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 +2974,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 +2985,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 +3043,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.  */
@@ -2982,6 +3164,8 @@
 	   howto->name,
 	   h->root.root.string);
 
+    do_relocation:
+
       if (r_type == R_390_20
 	  || r_type == R_390_GOT20
 	  || r_type == R_390_GOTPLT20
@@ -3038,6 +3222,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.  */
 
@@ -3048,6 +3318,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)
@@ -3062,78 +3333,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;
+	    }
 	}
     }
 
@@ -3147,21 +3422,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);
@@ -3173,13 +3471,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);
     }
 
@@ -3219,8 +3518,7 @@
    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 Elf_Internal_Rela *rela)
 {
   switch ((int) ELF64_R_TYPE (rela->r_info))
     {
@@ -3244,19 +3542,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;
@@ -3274,15 +3574,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;
 
@@ -3294,7 +3594,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;
 	    }
@@ -3303,52 +3603,72 @@
 	}
 
       /* 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)
+      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;
 }
 
@@ -3362,7 +3682,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.  */
@@ -3437,8 +3756,24 @@
 #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 9202477..ce5436d 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)
@@ -1661,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;
@@ -1797,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);
 	    }
 
@@ -1820,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);
 	    }
 
@@ -1914,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
@@ -1949,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);
 	    }
 
@@ -1974,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);
 	    }
 
@@ -2012,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);
 	    }
 
@@ -2490,24 +2490,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;
@@ -3159,7 +3157,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;
@@ -3186,9 +3184,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;
@@ -3196,30 +3195,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
@@ -3228,8 +3203,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;
 
@@ -3246,10 +3221,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;
@@ -3308,7 +3283,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
@@ -3336,13 +3311,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);
 
@@ -3376,13 +3351,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
@@ -3393,18 +3361,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;
@@ -3456,7 +3424,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;
@@ -3469,7 +3437,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;
     }
@@ -3638,9 +3606,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
@@ -3741,8 +3709,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
@@ -3787,8 +3755,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
@@ -3821,9 +3788,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)
     {
@@ -3906,7 +3873,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..e9b76e5 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;
diff --git a/bfd/elf64-tilegx.c b/bfd/elf64-tilegx.c
index e30ca80..bd5f653 100644
--- a/bfd/elf64-tilegx.c
+++ b/bfd/elf64-tilegx.c
@@ -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 fe0db0e..a29ba8a 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -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"
@@ -508,7 +509,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
@@ -585,6 +586,70 @@
   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_backend_data(abfd) \
+  ((const struct elf_x86_64_backend_data *) \
+   get_elf_backend_data (abfd)->arch_data)
+
+#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
@@ -721,8 +786,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;
     }
@@ -839,7 +904,7 @@
   ret->tls_ld_got.refcount = 0;
   ret->sgotplt_jump_table_size = 0;
   ret->tls_module_base = NULL;
-  ret->next_jump_slot_index = 0; 
+  ret->next_jump_slot_index = 0;
   ret->next_irelative_index = 0;
 
   if (ABI_64_P (abfd))
@@ -905,31 +970,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;
 }
@@ -1009,6 +1069,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.  */
 
@@ -1107,7 +1175,7 @@
 
       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
@@ -2007,7 +2075,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)
@@ -2166,13 +2234,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
@@ -2190,7 +2251,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);
@@ -2214,6 +2275,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;
@@ -2225,6 +2287,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.  */
@@ -2232,7 +2295,7 @@
       && h->def_regular)
     return _bfd_elf_allocate_ifunc_dyn_relocs (info, h,
 					       &eh->dyn_relocs,
-					       PLT_ENTRY_SIZE,
+					       plt_entry_size,
 					       GOT_ENTRY_SIZE);
   else if (htab->elf.dynamic_sections_created
 	   && h->plt.refcount > 0)
@@ -2254,7 +2317,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;
 
@@ -2271,7 +2334,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.  */
@@ -2536,7 +2599,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;
@@ -2695,9 +2758,9 @@
 	  /* 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);
 	}
     }
 
@@ -2709,7 +2772,7 @@
 				  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_.  */
+	 entries and there is no refeence to _GLOBAL_OFFSET_TABLE_.  */
       if ((got == NULL
 	   || !got->ref_regular_nonweak)
 	  && (htab->elf.sgotplt->size
@@ -2725,6 +2788,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
+	= (const struct elf_x86_64_backend_data *) bed->arch_data;
+      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;
@@ -2738,6 +2812,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
@@ -2789,11 +2864,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
+	= (const struct elf_x86_64_backend_data *) bed->arch_data;
+
+      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)
     {
@@ -2835,7 +2915,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);
 
@@ -2988,6 +3068,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));
 
@@ -3030,7 +3111,7 @@
 	}
 
       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
@@ -3057,7 +3138,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;
 	    }
@@ -3072,9 +3153,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;
@@ -3133,7 +3214,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)
@@ -3156,7 +3237,6 @@
 		{
 		  Elf_Internal_Rela outrel;
 		  asection *sreloc;
-		  bfd_boolean relocate;
 
 		  /* Need a dynamic relocation to get the real function
 		     address.  */
@@ -3176,15 +3256,15 @@
 		      || info->executable)
 		    {
 		      /* This symbol is resolved locally.  */
-		      outrel.r_info = htab->r_info (0, R_X86_64_RELATIVE);
-		      outrel.r_addend = relocation;
-		      relocate = FALSE;
+		      outrel.r_info = htab->r_info (0, R_X86_64_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 = htab->r_info (h->dynindx, r_type);
 		      outrel.r_addend = 0;
-		      relocate = FALSE;
 		    }
 
 		  sreloc = htab->elf.irelifunc;
@@ -3195,8 +3275,7 @@
 		     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.  */
-		  if (! relocate)
-		    continue;
+		  continue;
 		}
 	      /* FALLTHROUGH */
 	    case R_X86_64_PC32:
@@ -3220,13 +3299,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;
 		    }
@@ -3235,9 +3314,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.
 
@@ -3293,14 +3372,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;
 		}
@@ -3331,7 +3410,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;
 		    }
 		}
@@ -3396,8 +3475,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)
@@ -3429,7 +3509,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)
@@ -3472,7 +3552,6 @@
 	case R_X86_64_PC16:
 	case R_X86_64_PC32:
 	  if (info->shared
-	      && ABI_64_P (output_bfd)
 	      && (input_section->flags & SEC_ALLOC) != 0
 	      && (input_section->flags & SEC_READONLY) != 0
 	      && h != NULL)
@@ -3612,6 +3691,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
 		    {
@@ -4101,13 +4210,16 @@
 	       && 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);
+	{
+	  (*_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,
@@ -4161,9 +4273,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)
@@ -4217,39 +4331,38 @@
 
       if (plt == htab->elf.splt)
 	{
-	  got_offset = h->plt.offset / PLT_ENTRY_SIZE - 1;
+	  got_offset = h->plt.offset / abed->plt_entry_size - 1;
 	  got_offset = (got_offset + 3) * GOT_ENTRY_SIZE;
 	}
       else
 	{
-	  got_offset = h->plt.offset / PLT_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);
+		  (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.  */
@@ -4283,10 +4396,10 @@
 	{
 	  /* Put relocation index.  */
 	  bfd_put_32 (output_bfd, plt_index,
-		      plt->contents + h->plt.offset + 7);
+		      plt->contents + h->plt.offset + abed->plt_reloc_offset);
 	  /* Put offset for jmp .PLT0.  */
-	  bfd_put_32 (output_bfd, - (h->plt.offset + PLT_ENTRY_SIZE),
-		      plt->contents + h->plt.offset + 12);
+	  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);
@@ -4399,13 +4512,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;
 }
 
@@ -4418,7 +4524,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);
@@ -4433,6 +4539,7 @@
   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;
@@ -4452,13 +4559,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)
     {
@@ -4534,8 +4643,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,
@@ -4545,20 +4654,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)
 	    {
@@ -4566,8 +4675,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.  */
@@ -4579,10 +4687,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
@@ -4590,8 +4699,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);
 	    }
 	}
     }
@@ -4626,7 +4736,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
@@ -4642,8 +4753,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,
@@ -4671,7 +4781,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
@@ -5024,6 +5134,189 @@
 
 #include "elf64-target.h"
 
+/* Native Client support.  */
+
+#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.  */
+    0x2e, 0x0f, 0x1f, 0x84, 0, 0, 0, 0, 0, /* nopl %cs: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_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
+
+#include "elf64-target.h"
+
+/* Native Client x32 support.  */
+
+#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_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
+
 /* Intel L1OM support.  */
 
 static bfd_boolean
@@ -5052,10 +5345,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"
 
@@ -5126,18 +5426,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
@@ -5145,17 +5438,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 b7e0226..30bda73 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
@@ -633,8 +633,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;
 	}
 
@@ -1097,8 +1098,28 @@
       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)
+	{
+	  asection *sec;
+
+	  sec = bfd_section_from_elf_index (abfd, count);
+	  if (sec != NULL)
+	    {
+	      if (sec->contents == NULL)
+		{
+		  /* Force rereading from file.  */
+		  sec->flags &= ~SEC_IN_MEMORY;
+		  if (! bfd_malloc_and_get_section (abfd, sec, & sec->contents))
+		    continue;
+		}
+	      if (sec->contents != NULL)
+		(*process) (sec->contents, i_shdr.sh_size, arg);
+	    }
+	}
     }
 
   return TRUE;
@@ -1430,7 +1451,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
 	{
@@ -1595,7 +1616,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/elflink.c b/bfd/elflink.c
index 1d1ca0b..574b6e2 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -1,6 +1,6 @@
 /* ELF linking support for BFD.
    Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007, 2008, 2009, 2010, 2011
+   2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -104,8 +104,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;
@@ -779,8 +779,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,6 +892,33 @@
     }
 }
 
+/* Mark if a symbol has a definition in a dynamic object or is
+   weak in all dynamic objects.  */
+
+static void
+_bfd_elf_mark_dynamic_def_weak (struct elf_link_hash_entry *h,
+				asection *sec, int bind)
+{
+  if (!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;
+	}
+    }
+}
+
 /* 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
@@ -921,6 +947,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;
@@ -937,7 +964,7 @@
   /* 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)
+      && sec->sec_info_type == SEC_INFO_TYPE_JUST_SYMS)
     {
       *skip = TRUE;
       return TRUE;
@@ -959,8 +986,9 @@
   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;
@@ -1136,23 +1164,11 @@
   /* 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 (newdyn)
     {
-      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;
-	}
+      _bfd_elf_mark_dynamic_def_weak (h, sec, bind);
+      if (h != hi)
+	_bfd_elf_mark_dynamic_def_weak (hi, sec, bind);
     }
 
   /* If the old symbol has non-default visibility, we ignore the new
@@ -1164,6 +1180,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.
 
@@ -1216,15 +1233,15 @@
 	    h = *sym_hash;
 	}
 
-      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,11 +1251,18 @@
 	  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;
+      h->dynamic_def = 0;
       /* FIXME: Should we check type and size for protected symbol?  */
       h->size = 0;
       h->type = 0;
@@ -1717,6 +1741,7 @@
 	  if (! dynamic)
 	    {
 	      if (! info->executable
+		  || hi->def_dynamic
 		  || hi->ref_dynamic)
 		*dynsym = TRUE;
 	    }
@@ -2510,23 +2535,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 +2731,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 +3054,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;
@@ -3079,7 +3102,7 @@
       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 +3145,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 +3164,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 +3200,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 +3249,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 +3281,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
 	{
@@ -3499,7 +3523,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
@@ -3834,6 +3858,7 @@
       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;
@@ -3896,7 +3921,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.  */
@@ -4166,6 +4191,9 @@
 	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;
@@ -4354,25 +4382,38 @@
 		      h->ref_dynamic = 1;
 		    }
 		}
-	      if (! info->executable
-		  || h->def_dynamic
-		  || h->ref_dynamic)
+
+	      /* 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;
+		{
+		  h->ref_dynamic = 1;
+		  hi->ref_dynamic = 1;
+		}
 	      else
 		{
 		  h->def_dynamic = 1;
 		  h->dynamic_def = 1;
+		  hi->def_dynamic = 1;
+		  hi->dynamic_def = 1;
 		}
-	      if (h->def_regular
-		  || h->ref_regular
-		  || (h->u.weakdef != NULL
-		      && ! new_weakdef
-		      && h->u.weakdef->dynindx != -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;
 	    }
 
@@ -4686,7 +4727,6 @@
 	  struct elf_link_hash_entry *hlook;
 	  asection *slook;
 	  bfd_vma vlook;
-	  long ilook;
 	  size_t i, j, idx;
 
 	  hlook = weaks;
@@ -4700,14 +4740,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 +4760,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 +4912,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;
 	    }
 	}
     }
@@ -5586,17 +5637,9 @@
       && ! (*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 +5649,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)
@@ -5874,7 +5917,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 +5942,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 +6220,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 +6332,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 +6416,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 +6436,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 +6494,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 +6548,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 +6676,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 +6691,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 +6726,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)
@@ -7413,6 +7449,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 +7459,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 +7538,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 +7567,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 +7580,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 +7649,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 +7709,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 +7719,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 +7740,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 +7757,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)						\
@@ -8319,24 +8359,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 +8385,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 +8398,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 +8413,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 +8488,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 +8639,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 +8659,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 +8671,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 +8690,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 +8710,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))
+      && !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 +8733,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 +8755,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;
@@ -8767,14 +8823,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 +8853,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 +8903,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 +8956,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 +8970,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 +8979,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 +9019,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 +9052,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 +9070,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 +9095,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 +9185,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 +9205,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 +9234,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 +9245,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 +9282,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 +9293,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 +9306,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 +9314,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 +9332,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 +9380,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 +9424,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 +9434,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 +9447,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 +9475,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 +9507,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 +9521,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 +9575,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 +9613,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 +9635,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 +9649,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 +9669,7 @@
 			  asection *kept;
 
 			  kept = _bfd_elf_check_kept_section (sec,
-							      finfo->info);
+							      flinfo->info);
 			  if (kept != NULL)
 			    {
 			      *ps = kept;
@@ -9588,17 +9700,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 +9740,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 +9762,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 +9780,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 +9791,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 +9824,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 +9861,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 +9877,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 +9908,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 +9968,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;
 	  }
@@ -10265,7 +10366,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 +10403,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 +10510,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);
@@ -10556,22 +10664,22 @@
   /* 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 +10694,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 +10721,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 +10731,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 +10747,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 +10853,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 +10911,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 +10929,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 +10959,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 +10972,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 +11048,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 +11069,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 +11093,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 +11105,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;
@@ -10983,7 +11118,7 @@
   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 +11149,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;
@@ -11190,7 +11325,7 @@
       /* Check for DT_TEXTREL (late, in case the backend removes it).  */
       if (((info->warn_shared_textrel && info->shared)
 	   || info->error_textrel)
-	  && (o = bfd_get_section_by_name (dynobj, ".dynamic")) != NULL)
+	  && (o = bfd_get_linker_section (dynobj, ".dynamic")) != NULL)
 	{
 	  bfd_byte *dyncon, *dynconend;
 
@@ -11231,9 +11366,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,
@@ -11277,28 +11410,28 @@
 	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);
+  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 = abfd->sections; o != NULL; o = o->next)
     {
       struct bfd_elf_section_data *esdo = elf_section_data (o);
@@ -11323,28 +11456,28 @@
   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);
+  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 = abfd->sections; o != NULL; o = o->next)
     {
       struct bfd_elf_section_data *esdo = elf_section_data (o);
@@ -11575,6 +11708,12 @@
 	     || h->root.type == bfd_link_hash_warning)
 	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.  */
+      if (h->u.weakdef != NULL)
+	h->u.weakdef->mark = 1;
       return (*gc_mark_hook) (sec, info, cookie->rel, h, NULL);
     }
 
@@ -11597,7 +11736,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;
@@ -12008,12 +12148,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);
@@ -12229,58 +12371,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 {
@@ -12423,7 +12580,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;
@@ -12439,7 +12596,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;
@@ -12473,24 +12630,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
@@ -12513,8 +12667,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,
@@ -12522,6 +12676,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
@@ -12757,7 +12912,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;
@@ -12793,17 +12948,16 @@
       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)
 	    {
 	      if (! bfd_set_section_alignment (dynobj, reloc_sec, alignment))
diff --git a/bfd/elfn32-mips.c b/bfd/elfn32-mips.c
index 7a08dc8..6728371 100644
--- a/bfd/elfn32-mips.c
+++ b/bfd/elfn32-mips.c
@@ -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[] =
@@ -1651,6 +1756,111 @@
 	 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 */
+	 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 */
+	 FALSE,			/* 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 */
+	 FALSE,			/* 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 */
+	 FALSE,			/* 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 */
+	 FALSE,			/* 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 */
+	 FALSE,			/* 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 */
+	 FALSE,			/* partial_inplace */
+	 0x0000ffff,		/* src_mask */
+	 0x0000ffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
 };
 
 static reloc_howto_type elf_micromips_howto_table_rel[] =
@@ -2724,6 +2934,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[] =
diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c
index 3e2ee0b..7021ff5 100644
--- a/bfd/elfnn-ia64.c
+++ b/bfd/elfnn-ia64.c
@@ -1,6 +1,6 @@
 /* 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.
+   2008, 2009, 2010, 2011, 2012  Free Software Foundation, Inc.
    Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -41,14 +41,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 +178,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 +522,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
@@ -1416,7 +1408,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 +1429,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;
@@ -1478,13 +1470,13 @@
 
 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 +1494,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 +1513,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;
 
@@ -1560,12 +1552,12 @@
   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;
@@ -1994,13 +1986,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 +2006,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 +2041,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 +2081,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))
@@ -2666,7 +2659,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 +2694,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 +2741,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 +2778,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 +2805,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 +2822,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 +2989,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 +3046,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 +3537,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 +3854,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 +3912,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;
@@ -4620,8 +4613,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 +4786,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;
@@ -4978,268 +4971,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 +5103,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-mips.c b/bfd/elfxx-mips.c
index f493517..9478f16 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -1,6 +1,6 @@
 /* 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
+   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    Most of the information added by Ian Lance Taylor, Cygnus Support,
@@ -529,6 +529,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	\
@@ -1453,14 +1460,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);
 
@@ -1575,9 +1585,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)
@@ -1586,11 +1597,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.  */
@@ -1615,7 +1647,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)
@@ -1689,12 +1721,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;
@@ -1724,6 +1750,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)
@@ -1864,6 +1895,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:
@@ -1991,19 +2029,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
@@ -2816,16 +2860,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)))
@@ -4788,12 +4832,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)))
@@ -4830,7 +4874,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;
@@ -4882,9 +4926,11 @@
     |= 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;
@@ -4911,7 +4957,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
@@ -4925,7 +4972,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:
@@ -4933,6 +4979,9 @@
     case R_MICROMIPS_PC23_S2:
       return TRUE;
 
+    case R_MIPS16_26:
+      return !target_is_16_bit_code_p;
+
     default:
       return FALSE;
     }
@@ -5193,14 +5242,28 @@
 	 have already noticed that we were going to need the
 	 stub.  */
       if (local_p)
-	sec = elf_tdata (input_bfd)->local_stubs[r_symndx];
+	{
+	  sec = 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;
     }
@@ -5250,7 +5313,8 @@
   /* 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);
@@ -5322,6 +5386,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:
@@ -5491,6 +5558,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);
@@ -5499,17 +5567,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;
@@ -5642,6 +5715,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:
@@ -6104,7 +6180,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)
@@ -7146,7 +7222,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))
@@ -7162,9 +7238,9 @@
     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)))
@@ -7173,10 +7249,10 @@
 
   if ((IRIX_COMPAT (abfd) == ict_irix5 || IRIX_COMPAT (abfd) == ict_none)
       && !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)))
@@ -7214,19 +7290,20 @@
 	}
 
       /* 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");
+      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");
+      s = bfd_get_linker_section (abfd, ".dynstr");
       if (s != NULL)
 	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");
+      s = bfd_get_linker_section (abfd, ".dynamic");
       if (s != NULL)
 	bfd_set_section_alignment (abfd, s, MIPS_ELF_LOG_FILE_ALIGN (abfd));
     }
@@ -7256,7 +7333,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";
@@ -7283,15 +7360,15 @@
     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
@@ -7498,7 +7575,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)
@@ -7623,7 +7700,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)
@@ -7775,8 +7852,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:
@@ -7789,6 +7864,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:
@@ -7926,7 +8006,9 @@
 	    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)
@@ -8023,12 +8105,14 @@
 	  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))
 	    {
@@ -8038,6 +8122,7 @@
 	  /* 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.  */
@@ -8583,7 +8668,8 @@
 	  /* 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->sgotplt->size
+	      += get_elf_backend_data (dynobj)->got_header_size;
 
 	  /* On VxWorks, also allocate room for the header's
 	     .rela.plt.unloaded entries.  */
@@ -8944,7 +9030,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;
@@ -8969,7 +9055,7 @@
     }
 
   /* 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);
 
@@ -9242,6 +9328,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
@@ -9307,9 +9442,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))
 	{
@@ -9623,9 +9762,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);
 
@@ -10374,7 +10513,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;
@@ -10720,7 +10859,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;
@@ -12325,7 +12464,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;
@@ -13172,15 +13311,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;
diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c
index fe18a62..e14afaf 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)
     {
@@ -1656,6 +1700,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 +1725,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;
@@ -1956,6 +2002,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 +2028,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 +2162,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 +2176,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 +2191,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 +2471,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 +2532,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 +2627,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 +2742,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)
 	{
@@ -2970,9 +3010,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;
@@ -3283,6 +3323,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 +3348,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
@@ -3878,6 +3920,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;
@@ -4069,7 +4130,9 @@
 		   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),
@@ -4432,8 +4495,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
@@ -4672,13 +4735,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))
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index 96ecce3..5a6cae0 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -1,6 +1,6 @@
 /* Target definitions for NN-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.
@@ -655,6 +655,10 @@
 #define elf_backend_is_function_type _bfd_elf_is_function_type
 #endif
 
+#ifndef elf_backend_maybe_function_sym
+#define elf_backend_maybe_function_sym _bfd_elf_maybe_function_sym
+#endif
+
 #ifndef elf_match_priority
 #define elf_match_priority \
   (ELF_ARCH == bfd_arch_unknown ? 2 : ELF_OSABI == ELFOSABI_NONE ? 1 : 0)
@@ -750,6 +754,7 @@
   elf_backend_merge_symbol,
   elf_backend_hash_symbol,
   elf_backend_is_function_type,
+  elf_backend_maybe_function_sym,
   elf_backend_link_order_error_handler,
   elf_backend_relplt_name,
   ELF_MACHINE_ALT1,
diff --git a/bfd/elfxx-tilegx.c b/bfd/elfxx-tilegx.c
index 2aaa3d3..6f748ec 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 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),
+  /* These relocs are currently not defined.  */
+  EMPTY_HOWTO (66),
+  EMPTY_HOWTO (67),
+  EMPTY_HOWTO (68),
+  EMPTY_HOWTO (69),
+  EMPTY_HOWTO (70),
+  EMPTY_HOWTO (71),
 
   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),
+  /* These relocs are currently not defined.  */
+  EMPTY_HOWTO (76),
+  EMPTY_HOWTO (77),
 
   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,12 @@
 
   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),
+  EMPTY_HOWTO (94),
+  EMPTY_HOWTO (95),
+  EMPTY_HOWTO (96),
+  EMPTY_HOWTO (97),
+  EMPTY_HOWTO (98),
+  EMPTY_HOWTO (99),
 
 #define TILEGX_IMM16_HOWTO_LAST_TLS_IE(name, rshift) \
   HOWTO (name, rshift, 1, 16, FALSE, 0, \
@@ -543,8 +546,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 +567,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 +713,28 @@
   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_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_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_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 +744,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 +844,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 +944,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)
@@ -1003,6 +1027,18 @@
   create_Imm16_X1,
   create_Imm16_X0,
   create_Imm16_X1,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  NULL,
+  create_Imm16_X0,
+  create_Imm16_X1,
+  create_Imm16_X0,
+  create_Imm16_X1,
+  NULL,
+  NULL,
   create_Imm16_X0,
   create_Imm16_X1,
   create_Imm16_X0,
@@ -1015,34 +1051,20 @@
   create_Imm16_X1,
   create_Imm16_X0,
   create_Imm16_X1,
+  NULL,
+  NULL,
+  create_Imm16_X0,
+  create_Imm16_X1,
+  NULL,
+  NULL,
+  NULL,
+  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,
-  create_Imm16_X0,
-  create_Imm16_X1,
-  create_Imm16_X0,
-  create_Imm16_X1,
-  create_Imm16_X0,
-  create_Imm16_X1,
-  create_Imm16_X0,
-  create_Imm16_X1,
-  create_Imm16_X0,
-  create_Imm16_X1,
-  create_Imm16_X0,
-  create_Imm16_X1,
-  create_Imm16_X0,
-  create_Imm16_X1,
-  create_Imm16_X0,
-  create_Imm16_X1,
-  create_Imm16_X0,
-  create_Imm16_X1,
-  create_Imm16_X0,
-  create_Imm16_X1
 };
 
 static void
@@ -1402,23 +1424,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 +1451,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 +1497,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 +1560,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 +1652,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 +1671,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;
@@ -1598,39 +1725,36 @@
 	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
 	}
 
+      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 +1762,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,6 +1836,24 @@
 	    }
 	  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:
 	  /* This symbol requires a procedure linkage table entry.  We
 	     actually build the entry in adjust_dynamic_symbol,
@@ -1805,16 +1939,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
@@ -2008,51 +2141,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 +2170,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;
@@ -2256,13 +2367,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 +2381,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;
@@ -2361,7 +2465,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 +2655,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 +2893,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 +3076,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 +3140,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 +3159,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)
@@ -3248,92 +3663,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 +3792,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 +3816,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);
@@ -3726,8 +4116,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
@@ -3806,14 +4195,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 = tilegx_finish_dyn (output_bfd, info, dynobj, sdyn, splt);
diff --git a/bfd/hash.c b/bfd/hash.c
index 1de2c2a..f2dce4c 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 <sac@cygnus.com>
 
    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])
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..33a6808 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,8 +199,7 @@
 /* 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);
@@ -257,7 +235,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 +246,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 +275,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 +301,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 +399,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 +520,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 +532,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 +574,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 +725,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/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 ccc6c65..baffaea 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,13 @@
 #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.  */
 };
 
 #define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size)
@@ -115,6 +117,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.  */
 
@@ -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 *);
@@ -454,7 +459,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 *)) \
@@ -548,7 +553,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 *);
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index d08c2ba..1d95fd8 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,13 @@
 #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.  */
 };
 
 #define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size)
@@ -120,6 +122,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.  */
 
@@ -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 *);
@@ -459,7 +464,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 *)) \
@@ -553,7 +558,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 *);
@@ -1002,6 +1015,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",
@@ -1086,6 +1103,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",
@@ -1206,6 +1230,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",
@@ -1308,6 +1343,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",
@@ -1714,8 +1766,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",
@@ -1834,6 +1884,9 @@
   "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",
@@ -1943,6 +1996,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",
@@ -2060,6 +2114,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",
@@ -2318,6 +2390,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",
@@ -2386,6 +2459,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",
@@ -2405,6 +2484,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",
@@ -2462,52 +2549,44 @@
   "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_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_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_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",
@@ -2531,8 +2610,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 *);
@@ -2556,4 +2635,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/linker.c b/bfd/linker.c
index 7a01e11..3caec96 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;
 }
@@ -2664,7 +2665,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);
@@ -3123,6 +3131,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 +3217,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;
 	}
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..9bbbd44 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,8 +198,7 @@
 /* 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);
@@ -262,7 +237,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 +248,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 +277,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 +303,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 +401,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 +523,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 +535,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 +580,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 +728,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..e7688ab 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,10 +331,66 @@
   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_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
 
@@ -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 5e12f84..a2aa573 100644
--- a/bfd/mach-o-target.c
+++ b/bfd/mach-o-target.c
@@ -25,14 +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
@@ -48,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
@@ -97,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 =
@@ -119,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 0a614c3..1f9fc17 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -1,6 +1,6 @@
 /* Mach-O support for BFD.
    Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-   2009, 2010, 2011
+   2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -29,6 +29,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
@@ -87,118 +89,314 @@
    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},
+    { 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;
 
@@ -215,43 +413,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;
 
@@ -271,16 +472,23 @@
           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.
@@ -325,10 +533,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;
 }
 
@@ -337,10 +552,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;
 }
 
@@ -362,6 +587,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
@@ -417,6 +658,8 @@
   return nsyms;
 }
 
+/* Create synthetic symbols for indirect symbols.  */
+
 long
 bfd_mach_o_get_synthetic_symtab (bfd *abfd,
                                  long symcount ATTRIBUTE_UNUSED,
@@ -436,19 +679,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");
     }
@@ -473,6 +720,7 @@
         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;
@@ -580,7 +828,7 @@
 
 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)
 {
@@ -588,8 +836,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;
@@ -598,17 +850,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;
@@ -688,6 +975,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,
@@ -697,20 +1013,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];
@@ -721,42 +1045,62 @@
               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)
-        {
+      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)
           sym = syms + num;
-          reloc.r_extern = 1;
-        }
-      else
+      else if (reloc.r_scattered
+	       || (reloc.r_type != BFD_MACH_O_GENERIC_RELOC_PAIR))
         {
           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;
+        }
+      else /* ... The 'symnum' in a non-scattered PAIR will be 0x00ffffff.  */
+        {
+          /* 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 thoough the
+             section symbol is probably not needed here, because NULL symbol
+             values cause an assert in generic BFD code.  */
+          sym = (res - 1)->sym_ptr_ptr;
         }
       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;
@@ -810,21 +1154,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;
 }
@@ -836,7 +1184,7 @@
 
   if (mdata->dysymtab == NULL)
     return 1;
-  return (mdata->dysymtab->nextrel + mdata->dysymtab->nlocrel)
+  return (mdata->dysymtab->nextrel + mdata->dysymtab->nlocrel + 1)
     * sizeof (arelent *);
 }
 
@@ -859,35 +1207,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;
@@ -900,13 +1289,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;
 
@@ -938,15 +1320,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)
@@ -1099,18 +1475,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;
         }
@@ -1173,8 +1555,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)
@@ -1182,15 +1814,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)
@@ -1198,9 +1837,15 @@
               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;
           
@@ -1208,15 +1853,82 @@
             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;
 }
 
@@ -1226,27 +1938,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;
@@ -1276,6 +1975,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:
@@ -1288,7 +1991,6 @@
 	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:
@@ -1344,110 +2046,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;
+      
+      /* 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 (msect->flags == 0)
-        {
-          /* We suppose it hasn't been set.  Convert from BFD flags.  */
-          bfd_mach_o_set_section_flags_from_bfd (abfd, sec);
+      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;
 }
 
@@ -1462,8 +2547,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;
 
@@ -1497,7 +2582,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;
 }
 
@@ -1564,6 +2649,8 @@
 
   if (mach_o_wide_p (header))
     header->reserved = (*get32) (raw.reserved);
+  else
+    header->reserved = 0;
 
   return TRUE;
 }
@@ -1572,11 +2659,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)
@@ -1584,21 +2673,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;
+	  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);
@@ -1614,6 +2706,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.  */
@@ -1817,7 +2912,7 @@
   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;
@@ -1848,13 +2943,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)
@@ -2111,6 +3202,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);
@@ -2523,6 +3640,22 @@
   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 int
 bfd_mach_o_read_segment (bfd *abfd,
                          bfd_mach_o_load_command *command,
@@ -2668,6 +3801,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:
@@ -2699,6 +3835,10 @@
       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;
@@ -2709,7 +3849,7 @@
 	return -1;
       break;
     default:
-      (*_bfd_error_handler)(_("%B: unable to read unknown load command 0x%lx"),
+      (*_bfd_error_handler)(_("%B: unknown load command 0x%lx"),
          abfd, (unsigned long) command->type);
       break;
     }
@@ -2947,6 +4087,7 @@
   mdata->commands = NULL;
   mdata->nsects = 0;
   mdata->sections = NULL;
+  mdata->dyn_reloc_cache = NULL;
 
   return TRUE;
 }
@@ -3005,17 +4146,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)
@@ -3134,6 +4265,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_zalloc (abfd, 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)
 {
@@ -3149,9 +4316,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)
@@ -3164,8 +4335,10 @@
 	  bfd_set_error (bfd_error_bad_value);
 	  return NULL;
 	}
-    i++;	/* Get next entry.  */
-  }
+
+      /* Get next entry.  */
+      i++;
+    }
 
   if (i >= adata->nfat_arch)
     {
@@ -3178,24 +4351,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 ARCH_NAME.  */
-  nbfd->filename = bfd_printable_arch_mach (arch_type, arch_subtype);
-  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,
@@ -3235,10 +4426,7 @@
       if (res == NULL)
 	return NULL;
 
-      res->origin = e->offset;
-
-      res->filename = bfd_printable_arch_mach (cpu_type, cpu_subtype);
-      res->iostream = NULL;
+      bfd_mach_o_fat_member_init (res, cpu_type, cpu_subtype, e);
 
       if (bfd_check_format (res, format))
 	{
@@ -3305,54 +4493,67 @@
     }
 }
 
+/* The following two tables should be kept, as far as possible, in order of
+   most frequently used entries to optimize their use from gas.  */
+
 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}
 };
 
 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}
 };
 
-/* 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)
 {
   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.  */
@@ -3480,18 +4681,222 @@
   return 0;
 }
 
+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, 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);
+        }
+    }
+
+  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
@@ -3499,12 +4904,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"
 
@@ -3513,6 +4920,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
@@ -3526,7 +4934,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
@@ -3534,6 +4942,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"
 
@@ -3542,3 +4951,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 d85224e..f228df0 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,6 +454,16 @@
 }
 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.  */
@@ -471,6 +497,14 @@
 }
 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_load_command
 {
   bfd_mach_o_load_command_type type;
@@ -491,6 +525,8 @@
     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;
   }
   command;
 }
@@ -507,7 +543,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,6 +552,15 @@
      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;
 
@@ -527,15 +572,6 @@
 bfd_mach_o_xlat_name;
 
 /* Target specific routines.  */
-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 *);
-}
-bfd_mach_o_backend_data;
 
 #define bfd_mach_o_get_data(abfd) ((abfd)->tdata.mach_o_data)
 #define bfd_mach_o_get_backend_data(abfd) \
@@ -561,6 +597,7 @@
 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, 
@@ -571,7 +608,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);
+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 *);
@@ -586,19 +623,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/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/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..7c1d2f9 100644
--- a/bfd/opncls.c
+++ b/bfd/opncls.c
@@ -1,6 +1,6 @@
 /* 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
+   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012
    Free Software Foundation, Inc.
 
    Written by Cygnus Support.
@@ -190,6 +190,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,11 +202,17 @@
 
   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;
     }
@@ -307,6 +315,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 +333,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;
     }
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..04b7164 100644
--- a/bfd/pdp11.c
+++ b/bfd/pdp11.c
@@ -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/pef.c b/bfd/pef.c
index d4ad33a..ca4c454 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;
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/peicode.h b/bfd/peicode.h
index 5d10029..e835792 100644
--- a/bfd/peicode.h
+++ b/bfd/peicode.h
@@ -1,6 +1,7 @@
 /* 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.
+   2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
+   Free Software Foundation, Inc.
    Written by Cygnus Solutions.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -545,7 +546,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,
diff --git a/bfd/plugin.c b/bfd/plugin.c
index 064e273..8d2c4b2 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
diff --git a/bfd/po/SRC-POTFILES.in b/bfd/po/SRC-POTFILES.in
index 7154688..ccdb207 100644
--- a/bfd/po/SRC-POTFILES.in
+++ b/bfd/po/SRC-POTFILES.in
@@ -112,6 +112,7 @@
 cpu-pj.c
 cpu-plugin.c
 cpu-powerpc.c
+cpu-rl78.c
 cpu-rs6000.c
 cpu-rx.c
 cpu-s390.c
@@ -195,6 +196,7 @@
 elf32-or32.c
 elf32-pj.c
 elf32-ppc.c
+elf32-rl78.c
 elf32-rx.c
 elf32-s390.c
 elf32-score.c
diff --git a/bfd/po/uk.gmo b/bfd/po/uk.gmo
new file mode 100644
index 0000000..a85f3e1
--- /dev/null
+++ b/bfd/po/uk.gmo
Binary files differ
diff --git a/bfd/po/uk.po b/bfd/po/uk.po
new file mode 100644
index 0000000..99cdeed
--- /dev/null
+++ b/bfd/po/uk.po
@@ -0,0 +1,6122 @@
+# bfd Ukrainian translation
+# Copyright (C) 2012 Free Software Foundation, Inc.
+# This file is distributed under the same license as the binutils package.
+#
+# Yuri Chornoivan <yurchor@ukr.net>, 2012.
+msgid ""
+msgstr ""
+"Project-Id-Version: bfd 2.21.53\n"
+"Report-Msgid-Bugs-To: bug-binutils@gnu.org\n"
+"POT-Creation-Date: 2011-06-02 14:25+0100\n"
+"PO-Revision-Date: 2012-06-23 17:57+0300\n"
+"Last-Translator: Yuri Chornoivan <yurchor@ukr.net>\n"
+"Language-Team: Ukrainian <translation-team-uk@lists.sourceforge.net>\n"
+"Language: uk\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
+"X-Generator: Lokalize 1.5\n"
+
+#: aout-adobe.c:127
+msgid "%B: Unknown section type in a.out.adobe file: %x\n"
+msgstr "%B: невідомий тип розділу у файлі a.out.adobe: %x\n"
+
+#: aout-cris.c:199
+#, c-format
+msgid "%s: Invalid relocation type exported: %d"
+msgstr "%s: експортовано некоректний тип пересування: %d"
+
+#: aout-cris.c:242
+msgid "%B: Invalid relocation type imported: %d"
+msgstr "%B: імпортовано некоректний тип пересування: %d"
+
+#: aout-cris.c:253
+msgid "%B: Bad relocation record imported: %d"
+msgstr "%B: імпортовано помилковий запис пересування: %d"
+
+#: aoutx.h:1273 aoutx.h:1611
+#, c-format
+msgid "%s: can not represent section `%s' in a.out object file format"
+msgstr "%s: відтворення розділу «%s» у форматі об’єктних файлів a.out неможливе"
+
+#: aoutx.h:1577
+#, c-format
+msgid "%s: can not represent section for symbol `%s' in a.out object file format"
+msgstr "%s: відтворення розділу для символу «%s» у форматі об’єктних файлів a.out неможливе"
+
+#: aoutx.h:1579 vms-alpha.c:7668
+msgid "*unknown*"
+msgstr "*невідомо*"
+
+#: aoutx.h:4017 aoutx.h:4343
+msgid "%P: %B: unexpected relocation type\n"
+msgstr "%P: %B: неочікуваний тип пересування\n"
+
+#: aoutx.h:5374
+#, c-format
+msgid "%s: relocatable link from %s to %s not supported"
+msgstr "%s: підтримки придатних до пересування посилань з %s до %s не передбачено"
+
+#: archive.c:2194
+msgid "Warning: writing archive was slow: rewriting timestamp\n"
+msgstr "Попередження: записування архіву було повільним: перезаписуємо часову позначку\n"
+
+#: archive.c:2482
+msgid "Reading archive file mod timestamp"
+msgstr "Читання часової позначки mod архівного файла"
+
+#: archive.c:2506
+msgid "Writing updated armap timestamp"
+msgstr "Записування оновленої часової позначки armap"
+
+#: bfd.c:398
+msgid "No error"
+msgstr "Немає помилок"
+
+#: bfd.c:399
+msgid "System call error"
+msgstr "Помилка системного виклику"
+
+#: bfd.c:400
+msgid "Invalid bfd target"
+msgstr "Некоректне призначення bfd"
+
+#: bfd.c:401
+msgid "File in wrong format"
+msgstr "Файл у помилковому форматі"
+
+#: bfd.c:402
+msgid "Archive object file in wrong format"
+msgstr "Архівний об’єктний файл у помилковому форматі"
+
+#: bfd.c:403
+msgid "Invalid operation"
+msgstr "Некоректна дія"
+
+#: bfd.c:404
+msgid "Memory exhausted"
+msgstr "Пам’ять вичерпано"
+
+#: bfd.c:405
+msgid "No symbols"
+msgstr "Немає символів"
+
+#: bfd.c:406
+msgid "Archive has no index; run ranlib to add one"
+msgstr "У архіві немає покажчика; запустіть ranlib, щоб його додати"
+
+#: bfd.c:407
+msgid "No more archived files"
+msgstr "Більше архівованих файлів немає"
+
+#: bfd.c:408
+msgid "Malformed archive"
+msgstr "Архів з пошкодженим форматуванням"
+
+#: bfd.c:409
+msgid "File format not recognized"
+msgstr "Формат файла не розпізнано"
+
+#: bfd.c:410
+msgid "File format is ambiguous"
+msgstr "Формат файла є неоднозначним"
+
+#: bfd.c:411
+msgid "Section has no contents"
+msgstr "Розділ не має вмісту"
+
+#: bfd.c:412
+msgid "Nonrepresentable section on output"
+msgstr "Розділ, непридатний для виведення даних"
+
+#: bfd.c:413
+msgid "Symbol needs debug section which does not exist"
+msgstr "Символ потребує розділу діагностики, якого не існує"
+
+#: bfd.c:414
+msgid "Bad value"
+msgstr "помилкове значення"
+
+#: bfd.c:415
+msgid "File truncated"
+msgstr "Файл обрізано"
+
+#: bfd.c:416
+msgid "File too big"
+msgstr "Файл є надто великим"
+
+#: bfd.c:417
+#, c-format
+msgid "Error reading %s: %s"
+msgstr "Помилка під час читання %s: %s"
+
+#: bfd.c:418
+msgid "#<Invalid error code>"
+msgstr "#<некоректний код помилки>"
+
+#: bfd.c:945
+#, c-format
+msgid "BFD %s assertion fail %s:%d"
+msgstr "Оператором контролю BFD %s виявлено помилку %s:%d"
+
+#: bfd.c:957
+#, c-format
+msgid "BFD %s internal error, aborting at %s line %d in %s\n"
+msgstr "Внутрішня помилка BFD %s, перериваємо роботу у %s, рядок %d у %s\n"
+
+#: bfd.c:961
+#, c-format
+msgid "BFD %s internal error, aborting at %s line %d\n"
+msgstr "Внутрішня помилка BFD %s, перериваємо роботу у %s, рядок %d\n"
+
+#: bfd.c:963
+msgid "Please report this bug.\n"
+msgstr "Будь ласка, повідомте про цю ваду.\n"
+
+#: bfdwin.c:206
+#, c-format
+msgid "not mapping: data=%lx mapped=%d\n"
+msgstr "не відображено: дані=%lx відображено=%d\n"
+
+#: bfdwin.c:209
+#, c-format
+msgid "not mapping: env var not set\n"
+msgstr "не відображено: не встановлено змінну середовища var\n"
+
+#: binary.c:271
+#, c-format
+msgid "Warning: Writing section `%s' to huge (ie negative) file offset 0x%lx."
+msgstr "Попередження: виконується запис розділу «%s» за надто великим (тобто від’ємним) відступом у файлі, 0x%lx."
+
+#: 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
+#: elf64-ia64.c:360
+msgid "%P%F: --relax and -r may not be used together\n"
+msgstr "%P%F: --relax і -r не можна використовувати одночасно\n"
+
+#: cache.c:226
+msgid "reopening %B: %s\n"
+msgstr "повторне відкриття %B: %s\n"
+
+#: coff-alpha.c:491
+msgid ""
+"%B: Cannot handle compressed Alpha binaries.\n"
+"   Use compiler flags, or objZ, to generate uncompressed binaries."
+msgstr ""
+"%B: обробка стиснутих двійкових файлів Alpha неможлива.\n"
+"   Скористайтеся прапорцями компілятора або objZ для створення нестиснених двійкових файлів."
+
+#: coff-alpha.c:648
+msgid "%B: unknown/unsupported relocation type %d"
+msgstr "%B: невідомий або непідтримуваний тип пересування %d"
+
+#: coff-alpha.c:900 coff-alpha.c:937 coff-alpha.c:2025 coff-mips.c:1003
+msgid "GP relative relocation used when GP not defined"
+msgstr "Використано відносне пересування GP, втім, GP не визначено"
+
+#: coff-alpha.c:1502
+msgid "using multiple gp values"
+msgstr "використовується декілька значень gp"
+
+#: coff-alpha.c:1561
+msgid "%B: unsupported relocation: ALPHA_R_GPRELHIGH"
+msgstr "%B: пересування, підтримки якого не передбачено: ALPHA_R_GPRELHIGH"
+
+#: coff-alpha.c:1568
+msgid "%B: unsupported relocation: ALPHA_R_GPRELLOW"
+msgstr "%B: пересування, підтримки якого не передбачено: ALPHA_R_GPRELLOW"
+
+#: coff-alpha.c:1575 elf32-m32r.c:2493 elf64-alpha.c:4079 elf64-alpha.c:4228
+#: elf32-ia64.c:3845 elf64-ia64.c:3845
+msgid "%B: unknown relocation type %d"
+msgstr "%B: невідомий тип пересування %d"
+
+#: coff-arm.c:1038
+#, c-format
+msgid "%B: unable to find THUMB glue '%s' for `%s'"
+msgstr "%B: не вдалося знайти склейку THUMB «%s» для «%s»"
+
+#: coff-arm.c:1067
+#, c-format
+msgid "%B: unable to find ARM glue '%s' for `%s'"
+msgstr "%B: не вдалося знайти склейку ARM «%s» для «%s»"
+
+#: coff-arm.c:1369 elf32-arm.c:6980
+#, c-format
+msgid ""
+"%B(%s): warning: interworking not enabled.\n"
+"  first occurrence: %B: arm call to thumb"
+msgstr ""
+"%B(%s): попередження: сумісну роботу не увімкнено.\n"
+"  перша згадка: %B: виклик arm до thumb"
+
+#: coff-arm.c:1459
+#, c-format
+msgid ""
+"%B(%s): warning: interworking not enabled.\n"
+"  first occurrence: %B: thumb call to arm\n"
+"  consider relinking with --support-old-code enabled"
+msgstr ""
+"%B(%s): попередження: сумісну роботу не увімкнено.\n"
+"  перша згадка: %B: виклик arm до arm\n"
+"  спробуйте повторне об’єднання з увімкненим --support-old-code"
+
+#: coff-arm.c:1754 coff-tic80.c:695 cofflink.c:3081
+msgid "%B: bad reloc address 0x%lx in section `%A'"
+msgstr "%B: помилкова адреса пересування 0x%lx у розділі «%A»"
+
+#: coff-arm.c:2079
+msgid "%B: illegal symbol index in reloc: %d"
+msgstr "%B: некоректний індекс символу у пересуванні: %d"
+
+#: coff-arm.c:2210
+#, c-format
+msgid "error: %B is compiled for APCS-%d, whereas %B is compiled for APCS-%d"
+msgstr "помилка: %B зібрано для APCS-%d, а %B зібрано для APCS-%d"
+
+#: coff-arm.c:2226 elf32-arm.c:15580
+#, c-format
+msgid "error: %B passes floats in float registers, whereas %B passes them in integer registers"
+msgstr "помилка: %B передає числа з рухомою комою до регістрів, а %B передає їх у цілочисельні регістри"
+
+#: coff-arm.c:2229 elf32-arm.c:15584
+#, c-format
+msgid "error: %B passes floats in integer registers, whereas %B passes them in float registers"
+msgstr "помилка: %B передає цілі числа до регістрів, а %B передає їх у регістри чисел з рухомою комою"
+
+#: coff-arm.c:2243
+#, c-format
+msgid "error: %B is compiled as position independent code, whereas target %B is absolute position"
+msgstr "помилка: %B зібрано як код з незалежним позиціюванням, а призначення %B визначено у форматі абсолютної позиції"
+
+#: coff-arm.c:2246
+#, c-format
+msgid "error: %B is compiled as absolute position code, whereas target %B is position independent"
+msgstr "помилка: %B зібрано як код з абсолютним позиціюванням, а призначення %B визначено у форматі незалежної позиції"
+
+#: coff-arm.c:2274 elf32-arm.c:15649
+#, c-format
+msgid "Warning: %B supports interworking, whereas %B does not"
+msgstr "Попередження: у %B передбачено сумісну роботу, а у %B не передбачено"
+
+#: coff-arm.c:2277 elf32-arm.c:15655
+#, c-format
+msgid "Warning: %B does not support interworking, whereas %B does"
+msgstr "Попередження: у %B не передбачено сумісної роботи, а у %B передбачено"
+
+#: coff-arm.c:2301
+#, c-format
+msgid "private flags = %x:"
+msgstr "закриті прапорці = %x:"
+
+#: coff-arm.c:2309 elf32-arm.c:11752
+#, c-format
+msgid " [floats passed in float registers]"
+msgstr " [числа з рухомою комою передано до регістрів чисел з рухомою комою]"
+
+#: coff-arm.c:2311
+#, c-format
+msgid " [floats passed in integer registers]"
+msgstr " [числа з рухомою комою передано до цілочисельних регістрів]"
+
+#: coff-arm.c:2314 elf32-arm.c:11755
+#, c-format
+msgid " [position independent]"
+msgstr " [незалежний від позиції]"
+
+#: coff-arm.c:2316
+#, c-format
+msgid " [absolute position]"
+msgstr " [з абсолютним позиціюванням]"
+
+#: coff-arm.c:2320
+#, c-format
+msgid " [interworking flag not initialised]"
+msgstr " [прапорець сумісної роботи не ініціалізовано]"
+
+#: coff-arm.c:2322
+#, c-format
+msgid " [interworking supported]"
+msgstr " [підтримується сумісна робота]"
+
+#: coff-arm.c:2324
+#, c-format
+msgid " [interworking not supported]"
+msgstr " [сумісна робота не підтримується]"
+
+#: coff-arm.c:2370 elf32-arm.c:10787
+#, c-format
+msgid "Warning: Not setting interworking flag of %B since it has already been specified as non-interworking"
+msgstr "Попередження: прапорець сумісної роботи у %B не встановлено, оскільки його вже було визначено так, щоб він забороняв сумісну роботу"
+
+#: coff-arm.c:2374 elf32-arm.c:10791
+#, c-format
+msgid "Warning: Clearing the interworking flag of %B due to outside request"
+msgstr "Попередження: знято прапорець сумісної роботи у %B у відповідь на запит ззовні"
+
+#: coff-h8300.c:1122
+#, c-format
+msgid "cannot handle R_MEM_INDIRECT reloc when using %s output"
+msgstr "пересування неможливо обробити R_MEM_INDIRECT, якщо використано виведення до %s"
+
+#: coff-i860.c:147
+#, c-format
+msgid "relocation `%s' not yet implemented"
+msgstr "пересування «%s» ще не реалізовано"
+
+#: coff-i860.c:605 coff-tic54x.c:398 coffcode.h:5192
+msgid "%B: warning: illegal symbol index %ld in relocs"
+msgstr "%B: попередження: некоректний індекс символу %ld у пересуваннях"
+
+#: coff-i960.c:143 coff-i960.c:506
+msgid "uncertain calling convention for non-COFF symbol"
+msgstr "непевні правила виклику для символу поза COFF"
+
+#: coff-m68k.c:506 elf32-bfin.c:5689 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
+msgid "GP relative relocation when _gp not defined"
+msgstr "відносне пересування GP, але _gp не визначено"
+
+#: coff-or32.c:229
+msgid "Unrecognized reloc"
+msgstr "Нерозпізнане пересування"
+
+#: coff-rs6000.c:2676
+#, c-format
+msgid "%s: unsupported relocation type 0x%02x"
+msgstr "%s: непідтримуваний тип пересування 0x%02x"
+
+#: coff-rs6000.c:2761
+#, c-format
+msgid "%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"
+msgstr "%s: пересування TOC за адресою 0x%x до символу «%s», який немає запису у TOC"
+
+#: coff-rs6000.c:3512 coff64-rs6000.c:2111
+msgid "%B: symbol `%s' has unrecognized smclas %d"
+msgstr "%B: символ «%s» належить до нерозпізнаного smclas %d"
+
+#: coff-sh.c:521
+#, c-format
+msgid "SH Error: unknown reloc type %d"
+msgstr "Помилка SH: невідомий тип пересування, %d"
+
+#: coff-tic4x.c:195 coff-tic54x.c:299 coff-tic80.c:458
+#, c-format
+msgid "Unrecognized reloc type 0x%x"
+msgstr "Нерозпізнаний тип пересування 0x%x"
+
+#: coff-tic4x.c:240
+#, c-format
+msgid "%s: warning: illegal symbol index %ld in relocs"
+msgstr "%s: попередження: некоректний індекс символу %ld у пересуваннях"
+
+#: coff-w65.c:367
+#, c-format
+msgid "ignoring reloc %s\n"
+msgstr "ігноруємо пересування %s\n"
+
+#: coffcode.h:991
+msgid "%B: warning: COMDAT symbol '%s' does not match section name '%s'"
+msgstr "%B: попередження: символ COMDAT «%s» не відповідає назві розділу «%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:1215
+msgid "%B: Warning: Ignoring section flag IMAGE_SCN_MEM_NOT_PAGED in section %s"
+msgstr "%B: попередження: ігноруємо прапорець розділу IMAGE_SCN_MEM_NOT_PAGED у розділі %s"
+
+#: coffcode.h:1282
+msgid "%B (%s): Section flag %s (0x%x) ignored"
+msgstr "%B (%s): прапорець розділу %s (0x%x) проігноровано"
+
+#: coffcode.h:2424
+#, c-format
+msgid "Unrecognized TI COFF target id '0x%x'"
+msgstr "Нерозпізнаний ідентифікатор призначення TI COFF, «0x%x»"
+
+#: coffcode.h:2738
+msgid "%B: reloc against a non-existant symbol index: %ld"
+msgstr "%B: пересування за нествореним індексом символу: %ld"
+
+#: coffcode.h:3296
+msgid "%B: too many sections (%d)"
+msgstr "%B: занадто багато розділів (%d)"
+
+#: coffcode.h:3712
+msgid "%B: section %s: string table overflow at offset %ld"
+msgstr "%B: розділ %s: переповнення таблиці рядків за відступом %ld"
+
+#: coffcode.h:4517
+msgid "%B: warning: line number table read failed"
+msgstr "%B: попередження: помилка читання з таблиці номерів рядків"
+
+#: coffcode.h:4547
+msgid "%B: warning: illegal symbol index %ld in line numbers"
+msgstr "%B: попередження: некоректний індекс символу %ld у номерах рядків"
+
+#: coffcode.h:4561
+msgid "%B: warning: duplicate line number information for `%s'"
+msgstr "%B: попередження: дублювання даних щодо номерів рядків для «%s»"
+
+#: coffcode.h:4961
+msgid "%B: Unrecognized storage class %d for %s symbol `%s'"
+msgstr "%B: невідомий клас зберігання даних %d для символу %s «%s»"
+
+#: coffcode.h:5087
+msgid "warning: %B: local symbol `%s' has no section"
+msgstr "попередження: %B: локальний символ «%s» не має розділу"
+
+#: coffcode.h:5231
+msgid "%B: illegal relocation type %d at address 0x%lx"
+msgstr "%B: некоректний тип пересування %d за адресою 0x%lx"
+
+#: coffgen.c:1578
+msgid "%B: bad string table size %lu"
+msgstr "%B: помилковий розмір таблиці рядків %lu"
+
+#: cofflink.c:533 elflink.c:4353
+msgid "Warning: type of symbol `%s' changed from %d to %d in %B"
+msgstr "Попередження: тип символу «%s» змінено з %d на %d у %B"
+
+#: cofflink.c:2330
+msgid "%B: relocs in section `%A', but it has no contents"
+msgstr "%B: пересування у розділі «%A», але у цьому розділі немає змісту"
+
+#: cofflink.c:2392 elflink.c:9554
+msgid "%X`%s' referenced in section `%A' of %B: defined in discarded section `%A' of %B\n"
+msgstr "На %X«%s» посилається розділ «%A» %B: визначено у відкинутому розділі «%A» %B\n"
+
+#: cofflink.c:2690 coffswap.h:826
+#, c-format
+msgid "%s: %s: reloc overflow: 0x%lx > 0xffff"
+msgstr "%s: %s: переповнення під час пересування: 0x%lx > 0xffff"
+
+#: cofflink.c:2699 coffswap.h:812
+#, c-format
+msgid "%s: warning: %s: line number overflow: 0x%lx > 0xffff"
+msgstr "%s: попередження: %s: переповнення номера рядка: 0x%lx > 0xffff"
+
+#: cpu-arm.c:189 cpu-arm.c:200
+msgid "error: %B is compiled for the EP9312, whereas %B is compiled for XScale"
+msgstr "помилка: B зібрано для EP9312, а %B зібрано для XScale"
+
+#: cpu-arm.c:333
+#, c-format
+msgid "warning: unable to update contents of %s section in %s"
+msgstr "попередження: не вдалося оновити зміст розділу %s у %s"
+
+#: dwarf2.c:490
+#, c-format
+msgid "Dwarf Error: Can't find %s section."
+msgstr "Помилка dwarf: не вдалося знайти розділ %s."
+
+#: dwarf2.c:518
+#, c-format
+msgid "Dwarf Error: Offset (%lu) greater than or equal to %s size (%lu)."
+msgstr "Помилка dwarf: відступ (%lu) є більшим або рівним за розмір %s (%lu)."
+
+#: dwarf2.c:940
+#, c-format
+msgid "Dwarf Error: Invalid or unhandled FORM value: %u."
+msgstr "Помилка dwarf: некоректне або непридатне до обробки значення FORM: %u."
+
+#: dwarf2.c:1191
+msgid "Dwarf Error: mangled line number section (bad file number)."
+msgstr "Помилка dwarf: пошкоджений розділ номерів рядків (помилковий номер файла)."
+
+#: dwarf2.c:1443
+#, c-format
+msgid "Dwarf Error: Unhandled .debug_line version %d."
+msgstr "Помилка dwarf: непридатна до обробки версія .debug_line, %d."
+
+#: dwarf2.c:1465
+msgid "Dwarf Error: Invalid maximum operations per instruction."
+msgstr "Помилка dwarf: некоректна максимальна кількість дій на команду."
+
+#: dwarf2.c:1652
+msgid "Dwarf Error: mangled line number section."
+msgstr "Помилка dwarf: пошкоджений розділ номерів рядків."
+
+#: dwarf2.c:1978 dwarf2.c:2098 dwarf2.c:2383
+#, c-format
+msgid "Dwarf Error: Could not find abbrev number %u."
+msgstr "Помилка dwarf: не вдалося знайти скорочений номер %u."
+
+#: dwarf2.c:2344
+#, c-format
+msgid "Dwarf Error: found dwarf version '%u', this reader only handles version 2, 3 and 4 information."
+msgstr "Помилка dwarf: виявлено версію dwarf «%u», але у цій функції читання передбачено обробку лише версій даних 2, 3 і 4."
+
+#: dwarf2.c:2351
+#, c-format
+msgid "Dwarf Error: found address size '%u', this reader can not handle sizes greater than '%u'."
+msgstr "Помилка у dwarf: виявлено розмір адреси «%u», втім у функції читання не передбачено розмірів, що перевищують «%u»."
+
+#: dwarf2.c:2374
+#, c-format
+msgid "Dwarf Error: Bad abbrev number: %u."
+msgstr "Помилка dwarf: помилковий скорочений номер: %u."
+
+#: ecoff.c:1237
+#, c-format
+msgid "Unknown basic type %d"
+msgstr "Невідомий основний тип %d"
+
+#: ecoff.c:1494
+#, c-format
+msgid ""
+"\n"
+"      End+1 symbol: %ld"
+msgstr ""
+"\n"
+"      Символ за кінцем: %ld"
+
+#: ecoff.c:1501 ecoff.c:1504
+#, c-format
+msgid ""
+"\n"
+"      First symbol: %ld"
+msgstr ""
+"\n"
+"      Перший символ: %ld"
+
+#: ecoff.c:1516
+#, c-format
+msgid ""
+"\n"
+"      End+1 symbol: %-7ld   Type:  %s"
+msgstr ""
+"\n"
+"      Символ за кінцем: %-7ld   Тип:  %s"
+
+#: ecoff.c:1523
+#, c-format
+msgid ""
+"\n"
+"      Local symbol: %ld"
+msgstr ""
+"\n"
+"      Локальний символ: %ld"
+
+#: ecoff.c:1531
+#, c-format
+msgid ""
+"\n"
+"      struct; End+1 symbol: %ld"
+msgstr ""
+"\n"
+"      struct; символ за кінцем: %ld"
+
+#: ecoff.c:1536
+#, c-format
+msgid ""
+"\n"
+"      union; End+1 symbol: %ld"
+msgstr ""
+"\n"
+"      union; символ за кінцем: %ld"
+
+#: ecoff.c:1541
+#, c-format
+msgid ""
+"\n"
+"      enum; End+1 symbol: %ld"
+msgstr ""
+"\n"
+"      enum; символ за кінцем: %ld"
+
+#: ecoff.c:1547
+#, c-format
+msgid ""
+"\n"
+"      Type: %s"
+msgstr ""
+"\n"
+"      Тип: %s"
+
+#: elf-attrs.c:569
+msgid "error: %B: Object has vendor-specific contents that must be processed by the '%s' toolchain"
+msgstr "помилка: %B: у об’єкті містяться дані у специфічному форматі, ці дані має бути оброблено набором інструментів «%s»"
+
+#: elf-attrs.c:578
+msgid "error: %B: Object tag '%d, %s' is incompatible with tag '%d, %s'"
+msgstr "помилка: %B: мітка об’єкта «%d, %s» несумісна з міткою «%d, %s»"
+
+#: elf-eh-frame.c:913
+msgid "%P: error in %B(%A); no .eh_frame_hdr table will be created.\n"
+msgstr "%P: помилка у %B(%A); таблицю .eh_frame_hdr не буде створено.\n"
+
+#: elf-eh-frame.c:1165
+msgid "%P: fde encoding in %B(%A) prevents .eh_frame_hdr table being created.\n"
+msgstr "%P: кодування fde у %B(%A) перешкоджає створенню таблиці .eh_frame_hdr.\n"
+
+#: elf-eh-frame.c:1583
+msgid "%P: DW_EH_PE_datarel unspecified for this architecture.\n"
+msgstr "%P: DW_EH_PE_datarel не визначено для цієї архітектури.\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 ""
+
+#: 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
+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
+#: 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-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
+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
+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
+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
+msgid "%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"
+msgstr "%B(%A+0x%lx): нерозв’язне пересування %s щодо символу «%s»"
+
+#: elf-m10300.c:1580
+msgid "error: inappropriate relocation type for shared library (did you forget -fpic?)"
+msgstr "помилка: невідповідний тип пересування для бібліотеки спільного використання (забули -fpic?)"
+
+#: elf-m10300.c:1583
+msgid "%B: error: taking the address of protected function '%s' cannot be done when making a shared library"
+msgstr "%B: помилка: не можна виконувати отримання адреси захищеної функції «%s» під час створення бібліотеки спільного використання"
+
+#: elf-m10300.c:1586
+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
+#, c-format
+msgid "dynamic variable `%s' is zero size"
+msgstr "динамічна змінна «%s» має нульовий розмір"
+
+#: elf.c:334
+msgid "%B: invalid string offset %u >= %lu for section `%s'"
+msgstr "%B: некоректний відступ рядка, %u >= %lu, для розділу «%s»"
+
+#: elf.c:446
+msgid "%B symbol number %lu references nonexistent SHT_SYMTAB_SHNDX section"
+msgstr "%B номер символу %lu посилається на розділ SHT_SYMTAB_SHNDX, якого не існує"
+
+#: elf.c:602
+msgid "%B: Corrupt size field in group section header: 0x%lx"
+msgstr "%B: пошкоджені дані поля розміру у заголовку розділу груп: 0x%lx"
+
+#: elf.c:638
+msgid "%B: invalid SHT_GROUP entry"
+msgstr "%B: некоректний запис SHT_GROUP"
+
+#: elf.c:708
+msgid "%B: no group info for section %A"
+msgstr "%B: немає даних щодо групи для розділу %A"
+
+#: elf.c:737 elf.c:3121 elflink.c:10144
+msgid "%B: warning: sh_link not set for section `%A'"
+msgstr "%B: попередження: не встановлено sh_link для розділу «%A»"
+
+#: elf.c:756
+msgid "%B: sh_link [%d] in section `%A' is incorrect"
+msgstr "%B: sh_link [%d] у розділі «%A» є некоректним"
+
+#: elf.c:791
+msgid "%B: unknown [%d] section `%s' in group [%s]"
+msgstr "%B: невідомий [%d] розділ «%s» у групі [%s]"
+
+#: elf.c:1041
+msgid "%B: unable to initialize commpress status for section %s"
+msgstr "%B: не вдалося ініціалізувати стан стискання для розділу %s"
+
+#: elf.c:1061
+msgid "%B: unable to initialize decommpress status for section %s"
+msgstr "%B: не вдалося ініціалізувати стан розпакування для розділу %s"
+
+#: elf.c:1181
+#, c-format
+msgid ""
+"\n"
+"Program Header:\n"
+msgstr ""
+"\n"
+"Заголовок програми:\n"
+
+#: elf.c:1223
+#, c-format
+msgid ""
+"\n"
+"Dynamic Section:\n"
+msgstr ""
+"\n"
+"Динамічний розділ:\n"
+
+#: elf.c:1359
+#, c-format
+msgid ""
+"\n"
+"Version definitions:\n"
+msgstr ""
+"\n"
+"Визначення версій:\n"
+
+#: elf.c:1384
+#, c-format
+msgid ""
+"\n"
+"Version References:\n"
+msgstr ""
+"\n"
+"Посилання на версії:\n"
+
+#: elf.c:1389
+#, c-format
+msgid "  required from %s:\n"
+msgstr "  потрібні %s:\n"
+
+#: elf.c:1796
+msgid "%B: invalid link %lu for reloc section %s (index %u)"
+msgstr "%B: некоректне посилання %lu для розділу пересування %s (індекс %u)"
+
+#: elf.c:1966
+msgid "%B: don't know how to handle allocated, application specific section `%s' [0x%8x]"
+msgstr "%B: спосіб обробки розміщеного невідомий, специфічний для програми розділ «%s» [0x%8x]"
+
+#: elf.c:1978
+msgid "%B: don't know how to handle processor specific section `%s' [0x%8x]"
+msgstr "%B: спосіб обробки специфічного для процесора розділу `%s' [0x%8x] невідомий"
+
+#: elf.c:1989
+msgid "%B: don't know how to handle OS specific section `%s' [0x%8x]"
+msgstr "%B: спосіб обробки специфічного для ОС розділу «%s» [0x%8x] невідомий"
+
+#: elf.c:1999
+msgid "%B: don't know how to handle section `%s' [0x%8x]"
+msgstr "%B: спосіб обробки розділу «%s» [0x%8x] невідомий"
+
+#: elf.c:2634
+#, c-format
+msgid "warning: section `%A' type changed to PROGBITS"
+msgstr "попередження: тип розділу «%A» змінено на PROGBITS"
+
+#: elf.c:3078
+msgid "%B: sh_link of section `%A' points to discarded section `%A' of `%B'"
+msgstr "%B: sh_link розділу «%A» вказує на відкинутий розділ «%A» «%B»"
+
+#: elf.c:3101
+msgid "%B: sh_link of section `%A' points to removed section `%A' of `%B'"
+msgstr "%B: sh_link розділу «%A» вказує на вилучений розділ «%A» «%B»"
+
+#: elf.c:4527
+msgid "%B: The first section in the PT_DYNAMIC segment is not the .dynamic section"
+msgstr "%B: перший розділ у сегменті PT_DYNAMIC не є розділом .dynamic"
+
+#: elf.c:4554
+msgid "%B: Not enough room for program headers, try linking with -N"
+msgstr "%B: недостатньо місця для заголовків програми, спробуйте виконати компонування з -N"
+
+#: elf.c:4641
+msgid "%B: section %A lma %#lx adjusted to %#lx"
+msgstr "%B: lma %#lx розділу %A скориговано до %#lx"
+
+#: elf.c:4774
+msgid "%B: section `%A' can't be allocated in segment %d"
+msgstr "%B: розділ «%A» не може бути розподілено у сегменті %d"
+
+#: elf.c:4822
+msgid "%B: warning: allocated section `%s' not in segment"
+msgstr "%B: попередження: розподілений розділ «%s» перебуває за межами сегмента"
+
+#: elf.c:5322
+msgid "%B: symbol `%s' required but not present"
+msgstr "%B: потрібен символ «%s», але його немає"
+
+#: elf.c:5660
+msgid "%B: warning: Empty loadable segment detected, is this intentional ?\n"
+msgstr "%B: попередження: виявлено порожній завантажувальний сегмент, так і треба?\n"
+
+#: elf.c:6688
+#, c-format
+msgid "Unable to find equivalent output section for symbol '%s' from section '%s'"
+msgstr "Не вдалося знайти рівноцінний розділ виведення даних для символу «%s» з розділу «%s»"
+
+#: elf.c:7684
+msgid "%B: unsupported relocation type %s"
+msgstr "%B: непідтримуваний тип пересування %s"
+
+#: elf32-arm.c:3590
+msgid ""
+"%B(%s): warning: interworking not enabled.\n"
+"  first occurrence: %B: Thumb call to ARM"
+msgstr ""
+"%B(%s): попередження: сумісну роботу не увімкнено.\n"
+"  перша згадка: %B: виклик thumb до ARM"
+
+#: elf32-arm.c:3637
+msgid ""
+"%B(%s): warning: interworking not enabled.\n"
+"  first occurrence: %B: ARM call to Thumb"
+msgstr ""
+"%B(%s): попередження: сумісну роботу не увімкнено.\n"
+"  перша згадка: %B: виклик ARM до Thumb"
+
+#: elf32-arm.c:3849 elf32-arm.c:5286
+#, c-format
+msgid "%s: cannot create stub entry %s"
+msgstr "%s: не вдалося створити шаблонний запис %s"
+
+#: elf32-arm.c:5402
+#, c-format
+msgid "unable to find THUMB glue '%s' for '%s'"
+msgstr "не вдалося знайти склейку THUMB «%s» для «%s»"
+
+#: elf32-arm.c:5438
+#, c-format
+msgid "unable to find ARM glue '%s' for '%s'"
+msgstr "не вдалося знайти склейку ARM «%s» для «%s»"
+
+#: elf32-arm.c:5964
+msgid "%B: BE8 images only valid in big-endian mode."
+msgstr "%B: образи BE8 є чинними лише у режимі big-endian."
+
+#. Give a warning, but do as the user requests anyway.
+#: elf32-arm.c:6194
+msgid "%B: warning: selected VFP11 erratum workaround is not necessary for target architecture"
+msgstr "%B: попередження: вибраний спосіб уникнення помилки VFP11 не є необхідним для архітектури призначення"
+
+#: elf32-arm.c:6738 elf32-arm.c:6758
+msgid "%B: unable to find VFP11 veneer `%s'"
+msgstr ""
+
+#: elf32-arm.c:6806
+#, c-format
+msgid "Invalid TARGET2 relocation type '%s'."
+msgstr "Некоректний тип пересування у TARGET2, «%s»."
+
+#: elf32-arm.c:6890
+msgid ""
+"%B(%s): warning: interworking not enabled.\n"
+"  first occurrence: %B: thumb call to arm"
+msgstr ""
+"%B(%s): попередження: сумісну роботу не увімкнено.\n"
+"  перша згадка: %B: виклик thumb до arm"
+
+#: elf32-arm.c:7674
+msgid "%B(%A+0x%lx):unexpected Thumb instruction '0x%x' in TLS trampoline"
+msgstr ""
+
+#: elf32-arm.c:7713
+msgid "%B(%A+0x%lx):unexpected ARM instruction '0x%x' in TLS trampoline"
+msgstr ""
+
+#: elf32-arm.c:8166
+msgid "\\%B: Warning: Arm BLX instruction targets Arm function '%s'."
+msgstr ""
+
+#: elf32-arm.c:8575
+msgid "%B: Warning: Thumb BLX instruction targets thumb function '%s'."
+msgstr ""
+
+#: elf32-arm.c:9408
+msgid "%B(%A+0x%lx):unexpected Thumb instruction '0x%x' referenced by TLS_GOTDESC"
+msgstr ""
+
+#: elf32-arm.c:9431
+msgid "%B(%A+0x%lx):unexpected ARM instruction '0x%x' referenced by TLS_GOTDESC"
+msgstr ""
+
+#: elf32-arm.c:9460
+msgid "%B(%A+0x%lx): R_ARM_TLS_LE32 relocation not permitted in shared object"
+msgstr ""
+
+#: elf32-arm.c:9675
+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
+msgid "%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"
+msgstr "%B(%A+0x%lx): переповнення під час спроби поділу 0x%lx з метою групового пересування %s"
+
+#: elf32-arm.c:10209 elf32-sh.c:4112 elf64-sh64.c:1544
+msgid "%B(%A+0x%lx): %s relocation against SEC_MERGE section"
+msgstr "%B(%A+0x%lx): пересування %s щодо розділу SEC_MERGE"
+
+#: elf32-arm.c:10320 elf32-m68k.c:4191 elf32-xtensa.c:2805
+msgid "%B(%A+0x%lx): %s used with TLS symbol %s"
+msgstr "%B(%A+0x%lx): %s використовується з символом TLS %s"
+
+#: elf32-arm.c:10321 elf32-m68k.c:4192 elf32-xtensa.c:2806
+msgid "%B(%A+0x%lx): %s used with non-TLS symbol %s"
+msgstr "%B(%A+0x%lx): %s використовується з символом поза TLS %s"
+
+#: elf32-arm.c:10399 elf32-tic6x.c:2751
+msgid "out of range"
+msgstr "поза діапазоном"
+
+#: elf32-arm.c:10403 elf32-tic6x.c:2755
+msgid "unsupported relocation"
+msgstr "непідтримуване пересування"
+
+#: elf32-arm.c:10411 elf32-tic6x.c:2763
+msgid "unknown error"
+msgstr "невідома помилка"
+
+#: elf32-arm.c:10836
+msgid "Warning: Clearing the interworking flag of %B because non-interworking code in %B has been linked with it"
+msgstr ""
+
+#: elf32-arm.c:10930
+msgid "%B: Unknown mandatory EABI object attribute %d"
+msgstr "%B: невідомий обов’язковий атрибути об’єкта EABI %d"
+
+#: elf32-arm.c:10938
+msgid "Warning: %B: Unknown EABI object attribute %d"
+msgstr "Попередження: %B: невідомий атрибут об’єкта EABI %d"
+
+#: elf32-arm.c:11119
+msgid "error: %B: Unknown CPU architecture"
+msgstr "помилка: %B: невідома архітектура процесора"
+
+#: elf32-arm.c:11157
+msgid "error: %B: Conflicting CPU architectures %d/%d"
+msgstr "помилка: %B: конфлікт архітектур процесорів %d/%d"
+
+#: elf32-arm.c:11206
+msgid "Error: %B has both the current and legacy Tag_MPextension_use attributes"
+msgstr "Помилка: для %B визначено одразу обидва атрибути Tag_MPextension_use, current і legacy"
+
+#: elf32-arm.c:11231
+msgid "error: %B uses VFP register arguments, %B does not"
+msgstr "помилка: у %B використовуються аргументи регістри VFP, а у %B — ні"
+
+#: elf32-arm.c:11376
+msgid "error: %B: unable to merge virtualization attributes with %B"
+msgstr "помилка: %B: об’єднання атрибутів віртуалізації з %B неможливе"
+
+#: elf32-arm.c:11402
+msgid "error: %B: Conflicting architecture profiles %c/%c"
+msgstr "помилка: %B: конфлікт профілів архітектур, %c/%c"
+
+#: elf32-arm.c:11503
+msgid "Warning: %B: Conflicting platform configuration"
+msgstr "Попередження: %B: конфлікт налаштувань платформ"
+
+#: elf32-arm.c:11512
+msgid "error: %B: Conflicting use of R9"
+msgstr "помилка: %B: конфлікт у використанні R9"
+
+#: elf32-arm.c:11524
+msgid "error: %B: SB relative addressing conflicts with use of R9"
+msgstr "помилка: %B: використання відносної адресації SB конфліктує з використанням R9"
+
+#: elf32-arm.c:11537
+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
+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
+msgid "error: %B uses iWMMXt register arguments, %B does not"
+msgstr "помилка: у %B використовуються аргументи-регістри iWMMXt, а у %B — ні"
+
+#: elf32-arm.c:11597
+msgid "error: fp16 format mismatch between %B and %B"
+msgstr "помилка: розбіжності у визначенні форматування fp16 між %B та %B"
+
+#: elf32-arm.c:11621
+msgid "DIV usage mismatch between %B and %B"
+msgstr "розбіжності у використанні DIV між %B та %B"
+
+#: elf32-arm.c:11640
+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
+#, c-format
+msgid "private flags = %lx:"
+msgstr "закриті прапорці = %lx:"
+
+#: elf32-arm.c:11737
+#, c-format
+msgid " [interworking enabled]"
+msgstr " [увімкнено сумісну роботу]"
+
+#: elf32-arm.c:11745
+#, c-format
+msgid " [VFP float format]"
+msgstr " [формат float VFP]"
+
+#: elf32-arm.c:11747
+#, c-format
+msgid " [Maverick float format]"
+msgstr " [формат float Maverick]"
+
+#: elf32-arm.c:11749
+#, c-format
+msgid " [FPA float format]"
+msgstr " [формат float FPA]"
+
+#: elf32-arm.c:11758
+#, c-format
+msgid " [new ABI]"
+msgstr " [новий ABI]"
+
+#: elf32-arm.c:11761
+#, c-format
+msgid " [old ABI]"
+msgstr " [старий ABI]"
+
+#: elf32-arm.c:11764
+#, c-format
+msgid " [software FP]"
+msgstr " [програмна FP]"
+
+#: elf32-arm.c:11773
+#, c-format
+msgid " [Version1 EABI]"
+msgstr " [Версія1 EABI]"
+
+#: elf32-arm.c:11776 elf32-arm.c:11787
+#, c-format
+msgid " [sorted symbol table]"
+msgstr " [впорядкована таблиця символів]"
+
+#: elf32-arm.c:11778 elf32-arm.c:11789
+#, c-format
+msgid " [unsorted symbol table]"
+msgstr " [невпорядкована таблиця символів]"
+
+#: elf32-arm.c:11784
+#, c-format
+msgid " [Version2 EABI]"
+msgstr " [Версія2 EABI]"
+
+#: elf32-arm.c:11792
+#, c-format
+msgid " [dynamic symbols use segment index]"
+msgstr " [динамічні символи використовують індекс сегмента]"
+
+#: elf32-arm.c:11795
+#, c-format
+msgid " [mapping symbols precede others]"
+msgstr " [символи відображення передують іншим]"
+
+#: elf32-arm.c:11802
+#, c-format
+msgid " [Version3 EABI]"
+msgstr " [Версія3 EABI]"
+
+#: elf32-arm.c:11806
+#, c-format
+msgid " [Version4 EABI]"
+msgstr " [Версія4 EABI]"
+
+#: elf32-arm.c:11810
+#, c-format
+msgid " [Version5 EABI]"
+msgstr " [Версія5 EABI]"
+
+#: elf32-arm.c:11813
+#, c-format
+msgid " [BE8]"
+msgstr " [BE8]"
+
+#: elf32-arm.c:11816
+#, c-format
+msgid " [LE8]"
+msgstr " [LE8]"
+
+#: elf32-arm.c:11822
+#, c-format
+msgid " <EABI version unrecognised>"
+msgstr " <нерозпізнана версія EABI>"
+
+#: elf32-arm.c:11829
+#, c-format
+msgid " [relocatable executable]"
+msgstr " [придатний до пересування виконуваний файл]"
+
+#: elf32-arm.c:11832
+#, c-format
+msgid " [has entry point]"
+msgstr " [має вхідну точку]"
+
+#: elf32-arm.c:11837
+#, 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
+msgid "%B: bad symbol index: %d"
+msgstr "%B: помилковий індекс символу: %d"
+
+#: elf32-arm.c:12283 elf64-x86-64.c:1370 elf64-x86-64.c:1541 elfxx-mips.c:7949
+msgid "%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"
+msgstr ""
+
+#: elf32-arm.c:13412
+#, c-format
+msgid "Errors encountered processing file %s"
+msgstr "Під час обробки файла сталися помилки, %s"
+
+#: elf32-arm.c:14795
+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
+msgid "%B: error: Cortex-A8 erratum stub out of range (input file too large)"
+msgstr ""
+
+#: elf32-arm.c:14916 elf32-arm.c:14938
+msgid "%B: error: VFP11 veneer out of range"
+msgstr ""
+
+#: elf32-arm.c:15477
+msgid "error: %B is already in final BE8 format"
+msgstr ""
+
+#: elf32-arm.c:15553
+msgid "error: Source object %B has EABI version %d, but target %B has EABI version %d"
+msgstr ""
+
+#: elf32-arm.c:15569
+msgid "error: %B is compiled for APCS-%d, whereas target %B uses APCS-%d"
+msgstr ""
+
+#: elf32-arm.c:15594
+msgid "error: %B uses VFP instructions, whereas %B does not"
+msgstr ""
+
+#: elf32-arm.c:15598
+msgid "error: %B uses FPA instructions, whereas %B does not"
+msgstr ""
+
+#: elf32-arm.c:15608
+msgid "error: %B uses Maverick instructions, whereas %B does not"
+msgstr ""
+
+#: elf32-arm.c:15612
+msgid "error: %B does not use Maverick instructions, whereas %B does"
+msgstr ""
+
+#: elf32-arm.c:15631
+msgid "error: %B uses software FP, whereas %B uses hardware FP"
+msgstr ""
+
+#: elf32-arm.c:15635
+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
+msgid "internal error: dangerous relocation"
+msgstr "внутрішня помилка: небезпечне пересування"
+
+#: elf32-avr.c:2415 elf32-hppa.c:598 elf32-m68hc1x.c:166
+msgid "%B: cannot create stub entry %s"
+msgstr "%B: не вдалося створити шаблонний запис %s"
+
+#: elf32-bfin.c:107 elf32-bfin.c:363
+msgid "relocation should be even number"
+msgstr "пересування має бути вказано парним числом"
+
+#: elf32-bfin.c:1591
+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
+msgid "%B(%A+0x%lx): reloc against `%s': error %d"
+msgstr "%B(%A+0x%lx): пересування щодо «%s»: помилка %d"
+
+#: elf32-bfin.c:2723
+msgid "%B: relocation at `%A+0x%x' references symbol `%s' with nonzero addend"
+msgstr ""
+
+#: elf32-bfin.c:2737
+msgid "relocation references symbol not defined in the module"
+msgstr "пересування посилається на символ, який не визначено у модулі"
+
+#: elf32-bfin.c:2834
+msgid "R_BFIN_FUNCDESC references dynamic symbol with nonzero addend"
+msgstr ""
+
+#: elf32-bfin.c:2875 elf32-bfin.c:2998
+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
+msgid "cannot emit dynamic relocations in read-only section"
+msgstr ""
+
+#: elf32-bfin.c:2956
+msgid "R_BFIN_FUNCDESC_VALUE references dynamic symbol with nonzero addend"
+msgstr ""
+
+#: elf32-bfin.c:3121
+msgid "relocations between different segments are not supported"
+msgstr "підтримки пересування між різними сегментами не передбачено"
+
+#: elf32-bfin.c:3122
+msgid "warning: relocation references a different segment"
+msgstr "попередження: у пересуванні виявлено посилання на інший сегмент"
+
+#: elf32-bfin.c:4967
+msgid "%B: unsupported relocation type %i"
+msgstr "%B: непідтримуваний тип пересування %i"
+
+#: elf32-bfin.c:5121 elf32-frv.c:6805
+#, c-format
+msgid "%s: cannot link non-fdpic object file into fdpic executable"
+msgstr ""
+
+#: elf32-bfin.c:5125 elf32-frv.c:6809
+#, c-format
+msgid "%s: cannot link fdpic object file into non-fdpic executable"
+msgstr ""
+
+#: elf32-bfin.c:5279
+#, c-format
+msgid "*** check this relocation %s"
+msgstr "*** перевірте це пересування: %s"
+
+#: elf32-cris.c:1172
+msgid "%B, section %A: unresolvable relocation %s against symbol `%s'"
+msgstr ""
+
+#: elf32-cris.c:1234
+msgid "%B, section %A: No PLT nor GOT for relocation %s against symbol `%s'"
+msgstr ""
+
+#: elf32-cris.c:1236
+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
+msgid "[whose name is lost]"
+msgstr "[чию назву втрачено]"
+
+#: elf32-cris.c:1361 elf32-tic6x.c:2645
+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
+msgid "%B, section %A: relocation %s with non-zero addend %d against symbol `%s'"
+msgstr ""
+
+#: elf32-cris.c:1395
+msgid "%B, section %A: relocation %s is not allowed for global symbol: `%s'"
+msgstr ""
+
+#: elf32-cris.c:1411
+msgid "%B, section %A: relocation %s with no GOT created"
+msgstr ""
+
+#. We shouldn't get here for GCC-emitted code.
+#: elf32-cris.c:1626
+msgid "%B, section %A: relocation %s has an undefined reference to `%s', perhaps a declaration mixup?"
+msgstr ""
+
+#: elf32-cris.c:1998
+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
+msgid "(too many global variables for -fpic: recompile with -fPIC)"
+msgstr ""
+
+#: elf32-cris.c:2058
+msgid "(thread-local data too big for -fpic or -msmall-tls: recompile with -fPIC or -mno-small-tls)"
+msgstr ""
+
+#: elf32-cris.c:3248
+msgid ""
+"%B, section %A:\n"
+"  v10/v32 compatible object %s must not contain a PIC relocation"
+msgstr ""
+
+#: elf32-cris.c:3353
+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
+msgid ""
+"%B, section %A:\n"
+"  relocation %s should not be used in a shared object; recompile with -fPIC"
+msgstr ""
+
+#: elf32-cris.c:3992
+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
+msgid "Unexpected machine number"
+msgstr "Неочікуваний номер машини"
+
+#: elf32-cris.c:4165
+#, c-format
+msgid " [symbols have a _ prefix]"
+msgstr " [символи містять префікс _]"
+
+#: elf32-cris.c:4168
+#, c-format
+msgid " [v10 and v32]"
+msgstr " [v10 та v32]"
+
+#: elf32-cris.c:4171
+#, c-format
+msgid " [v32]"
+msgstr " [v32]"
+
+#: elf32-cris.c:4216
+msgid "%B: uses _-prefixed symbols, but writing file with non-prefixed symbols"
+msgstr ""
+
+#: elf32-cris.c:4217
+msgid "%B: uses non-prefixed symbols, but writing file with _-prefixed symbols"
+msgstr ""
+
+#: elf32-cris.c:4236
+msgid "%B contains CRIS v32 code, incompatible with previous objects"
+msgstr ""
+
+#: elf32-cris.c:4238
+msgid "%B contains non-CRIS-v32 code, incompatible with previous objects"
+msgstr ""
+
+#: elf32-dlx.c:142
+#, c-format
+msgid "BFD Link Error: branch (PC rel16) to section (%s) not supported"
+msgstr ""
+
+#: elf32-dlx.c:204
+#, c-format
+msgid "BFD Link Error: jump (PC rel26) to section (%s) not supported"
+msgstr ""
+
+#: elf32-frv.c:1509 elf32-frv.c:1658
+msgid "relocation requires zero addend"
+msgstr ""
+
+#: elf32-frv.c:2888
+msgid "%H: relocation to `%s+%v' may have caused the error above\n"
+msgstr ""
+
+#: elf32-frv.c:2902
+msgid "%H: relocation references symbol not defined in the module\n"
+msgstr ""
+
+#: elf32-frv.c:2978
+msgid "%H: R_FRV_GETTLSOFF not applied to a call instruction\n"
+msgstr ""
+
+#: elf32-frv.c:3019
+msgid "%H: R_FRV_GOTTLSDESC12 not applied to an lddi instruction\n"
+msgstr ""
+
+#: elf32-frv.c:3090
+msgid "%H: R_FRV_GOTTLSDESCHI not applied to a sethi instruction\n"
+msgstr ""
+
+#: elf32-frv.c:3127
+msgid "%H: R_FRV_GOTTLSDESCLO not applied to a setlo or setlos instruction\n"
+msgstr ""
+
+#: elf32-frv.c:3174
+msgid "%H: R_FRV_TLSDESC_RELAX not applied to an ldd instruction\n"
+msgstr ""
+
+#: elf32-frv.c:3258
+msgid "%H: R_FRV_GETTLSOFF_RELAX not applied to a calll instruction\n"
+msgstr ""
+
+#: elf32-frv.c:3312
+msgid "%H: R_FRV_GOTTLSOFF12 not applied to an ldi instruction\n"
+msgstr ""
+
+#: elf32-frv.c:3342
+msgid "%H: R_FRV_GOTTLSOFFHI not applied to a sethi instruction\n"
+msgstr ""
+
+#: elf32-frv.c:3371
+msgid "%H: R_FRV_GOTTLSOFFLO not applied to a setlo or setlos instruction\n"
+msgstr ""
+
+#: elf32-frv.c:3401
+msgid "%H: R_FRV_TLSOFF_RELAX not applied to an ld instruction\n"
+msgstr ""
+
+#: elf32-frv.c:3446
+msgid "%H: R_FRV_TLSMOFFHI not applied to a sethi instruction\n"
+msgstr ""
+
+#: elf32-frv.c:3473
+msgid "R_FRV_TLSMOFFLO not applied to a setlo or setlos instruction\n"
+msgstr ""
+
+#: elf32-frv.c:3594
+msgid "%H: R_FRV_FUNCDESC references dynamic symbol with nonzero addend\n"
+msgstr ""
+
+#: elf32-frv.c:3635 elf32-frv.c:3757
+msgid "%H: cannot emit fixups in read-only section\n"
+msgstr ""
+
+#: elf32-frv.c:3666 elf32-frv.c:3800
+msgid "%H: cannot emit dynamic relocations in read-only section\n"
+msgstr ""
+
+#: elf32-frv.c:3715
+msgid "%H: R_FRV_FUNCDESC_VALUE references dynamic symbol with nonzero addend\n"
+msgstr ""
+
+#: elf32-frv.c:3971
+msgid "%H: reloc against `%s' references a different segment\n"
+msgstr ""
+
+#: elf32-frv.c:4121
+msgid "%H: reloc against `%s': %s\n"
+msgstr "%H: пересування щодо «%s»: %s\n"
+
+#: elf32-frv.c:6397
+msgid "%B: unsupported relocation type %i\n"
+msgstr "%B: непідтримуваний тип пересування %i\n"
+
+#: elf32-frv.c:6719
+#, 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
+#, c-format
+msgid "%s: compiled with %s and linked with modules compiled with %s"
+msgstr ""
+
+#: elf32-frv.c:6784
+#, 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
+#, c-format
+msgid "private flags = 0x%lx:"
+msgstr "закриті прапорці = 0x%lx:"
+
+#: elf32-gen.c:69 elf64-gen.c:69
+msgid "%B: Relocations in generic ELF (EM: %d)"
+msgstr ""
+
+#: elf32-hppa.c:850 elf32-hppa.c:3610
+msgid "%B(%A+0x%lx): cannot reach %s, recompile with -ffunction-sections"
+msgstr ""
+
+#: elf32-hppa.c:1284
+msgid "%B: relocation %s can not be used when making a shared object; recompile with -fPIC"
+msgstr ""
+
+#: elf32-hppa.c:2803
+msgid "%B: duplicate export stub %s"
+msgstr ""
+
+#: elf32-hppa.c:3449
+msgid "%B(%A+0x%lx): %s fixup for insn 0x%x is not supported in a non-shared link"
+msgstr ""
+
+#: elf32-hppa.c:4296
+msgid "%B(%A+0x%lx): cannot handle %s for %s"
+msgstr ""
+
+#: elf32-hppa.c:4608
+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
+msgid "%B: invalid relocation type %d"
+msgstr "%B: некоректний тип пересування %d"
+
+#: elf32-i386.c:1266 elf64-x86-64.c:1116
+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
+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
+msgid "%B: `%s' accessed both as normal and thread local symbol"
+msgstr ""
+
+#: elf32-i386.c:2405 elf64-x86-64.c:2320
+msgid "%P: %B: warning: relocation against `%s' in readonly section `%A'.\n"
+msgstr ""
+
+#: elf32-i386.c:2496 elf64-x86-64.c:2407
+msgid "%P: %B: warning: relocation in readonly section `%A'.\n"
+msgstr ""
+
+#: elf32-i386.c:2932
+msgid "%B: unrecognized relocation (0x%x) in section `%A'"
+msgstr ""
+
+#: elf32-i386.c:3339 elf64-x86-64.c:3295
+msgid "hidden symbol"
+msgstr "прихований символ"
+
+#: elf32-i386.c:3342 elf64-x86-64.c:3298
+msgid "internal symbol"
+msgstr "внутрішній символ"
+
+#: elf32-i386.c:3345 elf64-x86-64.c:3301
+msgid "protected symbol"
+msgstr "захищений символ"
+
+#: elf32-i386.c:3348 elf64-x86-64.c:3304
+msgid "symbol"
+msgstr "символ"
+
+#: elf32-i386.c:3353
+msgid "%B: relocation R_386_GOTOFF against undefined %s `%s' can not be used when making a shared object"
+msgstr ""
+
+#: elf32-i386.c:3363
+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
+#, c-format
+msgid "discarded output section: `%A'"
+msgstr "відкинуто розділ виведення даних: «%A»"
+
+#: elf32-ip2k.c:857 elf32-ip2k.c:863 elf32-ip2k.c:930 elf32-ip2k.c:936
+msgid "ip2k relaxer: switch table without complete matching relocation information."
+msgstr ""
+
+#: elf32-ip2k.c:880 elf32-ip2k.c:963
+msgid "ip2k relaxer: switch table header corrupt."
+msgstr ""
+
+#: elf32-ip2k.c:1292
+#, c-format
+msgid "ip2k linker: missing page instruction at 0x%08lx (dest = 0x%08lx)."
+msgstr ""
+
+#: elf32-ip2k.c:1308
+#, c-format
+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 "непідтримуване пересування між просторами адрес data та 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)"
+msgstr "%s: використовуються інші поля e_flags (0x%lx) ніж у попередніх модулях (0x%lx)"
+
+#: elf32-lm32.c:706
+msgid "global pointer relative relocation when _gp not defined"
+msgstr "відносне перенесення загального вказівника без визначення _gp"
+
+#: elf32-lm32.c:761
+msgid "global pointer relative address out of range"
+msgstr "відносна адреса загального вказівника лежить за межами дозволеного діапазону"
+
+#: elf32-lm32.c:1057
+msgid "internal error: addend should be zero for R_LM32_16_GOT"
+msgstr "внутрішня помилка: доданок має бути нульовим для R_LM32_16_GOT"
+
+#: elf32-m32r.c:1453
+msgid "SDA relocation when _SDA_BASE_ not defined"
+msgstr "перенесення SDA без визначення _SDA_BASE_"
+
+#: elf32-m32r.c:3048
+msgid "%B: The target (%s) of an %s relocation is in the wrong section (%A)"
+msgstr ""
+
+#: elf32-m32r.c:3576
+msgid "%B: Instruction set mismatch with previous modules"
+msgstr "%B: невідповідність набору команду цього модуля наборам команд попередніх модулів"
+
+#: elf32-m32r.c:3597
+#, c-format
+msgid "private flags = %lx"
+msgstr "закриті прапорці = %lx"
+
+#: elf32-m32r.c:3602
+#, c-format
+msgid ": m32r instructions"
+msgstr ": команди m32r"
+
+#: elf32-m32r.c:3603
+#, c-format
+msgid ": m32rx instructions"
+msgstr ": команди m32rx"
+
+#: elf32-m32r.c:3604
+#, c-format
+msgid ": m32r2 instructions"
+msgstr ": команди m32r2"
+
+#: elf32-m68hc1x.c:1050
+#, c-format
+msgid "Reference to the far symbol `%s' using a wrong relocation may result in incorrect execution"
+msgstr ""
+
+#: elf32-m68hc1x.c:1073
+#, c-format
+msgid "banked address [%lx:%04lx] (%lx) is not in the same bank as current banked address [%lx:%04lx] (%lx)"
+msgstr ""
+
+#: elf32-m68hc1x.c:1092
+#, c-format
+msgid "reference to a banked address [%lx:%04lx] in the normal address space at %04lx"
+msgstr ""
+
+#: elf32-m68hc1x.c:1225
+msgid "%B: linking files compiled for 16-bit integers (-mshort) and others for 32-bit integers"
+msgstr ""
+
+#: elf32-m68hc1x.c:1232
+msgid "%B: linking files compiled for 32-bit double (-fshort-double) and others for 64-bit double"
+msgstr ""
+
+#: elf32-m68hc1x.c:1241
+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
+msgid "%B: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"
+msgstr ""
+
+#: elf32-m68hc1x.c:1285
+#, c-format
+msgid "[abi=32-bit int, "
+msgstr "[abi=32-бітове ціле, "
+
+#: elf32-m68hc1x.c:1287
+#, c-format
+msgid "[abi=16-bit int, "
+msgstr "[abi=16-бітове ціле, "
+
+#: elf32-m68hc1x.c:1290
+#, c-format
+msgid "64-bit double, "
+msgstr "64-бітове double, "
+
+#: elf32-m68hc1x.c:1292
+#, c-format
+msgid "32-bit double, "
+msgstr "32-бітове double, "
+
+#: elf32-m68hc1x.c:1295
+#, c-format
+msgid "cpu=HC11]"
+msgstr "процесор=HC11]"
+
+#: elf32-m68hc1x.c:1297
+#, c-format
+msgid "cpu=HCS12]"
+msgstr "процесор=HCS12]"
+
+#: elf32-m68hc1x.c:1299
+#, c-format
+msgid "cpu=HC12]"
+msgstr "процесор=HC12]"
+
+#: elf32-m68hc1x.c:1302
+#, c-format
+msgid " [memory=bank-model]"
+msgstr ""
+
+#: elf32-m68hc1x.c:1304
+#, c-format
+msgid " [memory=flat]"
+msgstr ""
+
+#: elf32-m68k.c:1250 elf32-m68k.c:1251 vms-alpha.c:7311 vms-alpha.c:7326
+msgid "unknown"
+msgstr "невідомо"
+
+#: elf32-m68k.c:1714
+msgid "%B: GOT overflow: Number of relocations with 8-bit offset > %d"
+msgstr ""
+
+#: elf32-m68k.c:1720
+msgid "%B: GOT overflow: Number of relocations with 8- or 16-bit offset > %d"
+msgstr ""
+
+#: elf32-m68k.c:3959
+msgid "%B(%A+0x%lx): R_68K_TLS_LE32 relocation not permitted in shared object"
+msgstr ""
+
+#: elf32-mcore.c:99 elf32-mcore.c:442
+msgid "%B: Relocation %s (%d) is not currently supported.\n"
+msgstr ""
+
+#: elf32-mcore.c:428
+msgid "%B: Unknown relocation type %d\n"
+msgstr "%B: невідомий тип пересування %d\n"
+
+#. Pacify gcc -Wall.
+#: elf32-mep.c:157
+#, c-format
+msgid "mep: no reloc for code %d"
+msgstr "mep: немає пересування для коду %d"
+
+#: elf32-mep.c:163
+#, c-format
+msgid "MeP: howto %d has type %d"
+msgstr "MeP: howto %d належить до типу %d"
+
+#: elf32-mep.c:648
+msgid "%B and %B are for different cores"
+msgstr "%B і %B призначено для різних ядер"
+
+#: elf32-mep.c:665
+msgid "%B and %B are for different configurations"
+msgstr "%B і %B призначено для різних конфігурацій"
+
+#: elf32-mep.c:702
+#, c-format
+msgid "private flags = 0x%lx"
+msgstr "закриті прапорці = 0x%lx"
+
+#: elf32-microblaze.c:742
+#, c-format
+msgid "%s: unknown relocation type %d"
+msgstr "%s: невідомий тип пересування %d"
+
+#: elf32-microblaze.c:867 elf32-microblaze.c:912
+#, c-format
+msgid "%s: The target (%s) of an %s relocation is in the wrong section (%s)"
+msgstr ""
+
+#: elf32-microblaze.c:1155 elfxx-sparc.c:3451
+msgid "%B: probably compiled without -fPIC?"
+msgstr "%B: ймовірно зібрано без -fPIC?"
+
+#: elf32-microblaze.c:2074
+msgid "%B: bad relocation section name `%s'"
+msgstr "%B: помилкова назва розділу для пересування «%s»"
+
+#: elf32-mips.c:1045 elf64-mips.c:2084 elfn32-mips.c:1888
+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
+msgid "32bits gp relative relocation occurs for an external symbol"
+msgstr ""
+
+#: elf32-ppc.c:1740
+#, c-format
+msgid "generic linker can't handle %s"
+msgstr "типовий компонувальник не може обробляти %s"
+
+#: elf32-ppc.c:2183
+msgid "corrupt %s section in %B"
+msgstr "пошкоджений розділ %s у %B"
+
+#: elf32-ppc.c:2202
+msgid "unable to read in %s section from %B"
+msgstr "читання у розділі %s неможливе з %B"
+
+#: elf32-ppc.c:2243
+msgid "warning: unable to set size of %s section in %B"
+msgstr "попередження: не вдалося встановити для розміру розділу %s значення %B"
+
+#: elf32-ppc.c:2293
+msgid "failed to allocate space for new APUinfo section."
+msgstr "не вдалося розмістити новий розділ APUinfo."
+
+#: elf32-ppc.c:2312
+msgid "failed to compute new APUinfo section."
+msgstr "не вдалося обчислити новий розділ APUinfo."
+
+#: elf32-ppc.c:2315
+msgid "failed to install new APUinfo section."
+msgstr "не вдалося встановити новий розділ APUinfo."
+
+#: elf32-ppc.c:3343
+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"
+msgstr "%H: %s пересування за локальним символом\n"
+
+#: elf32-ppc.c:4026 elf32-ppc.c:4041 elfxx-mips.c:12423 elfxx-mips.c:12449
+#: elfxx-mips.c:12471 elfxx-mips.c:12497
+msgid "Warning: %B uses hard float, %B uses soft float"
+msgstr ""
+
+#: elf32-ppc.c:4029 elf32-ppc.c:4033
+msgid "Warning: %B uses double-precision hard float, %B uses single-precision hard float"
+msgstr ""
+
+#: elf32-ppc.c:4037
+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
+msgid "Warning: %B uses unknown floating point ABI %d"
+msgstr ""
+
+#: elf32-ppc.c:4090 elf32-ppc.c:4094
+msgid "Warning: %B uses unknown vector ABI %d"
+msgstr "Попередження: %B використовує невідомий векторний ABI %d"
+
+#: elf32-ppc.c:4098
+msgid "Warning: %B uses vector ABI \"%s\", %B uses \"%s\""
+msgstr ""
+
+#: elf32-ppc.c:4115 elf32-ppc.c:4118
+msgid "Warning: %B uses r3/r4 for small structure returns, %B uses memory"
+msgstr ""
+
+#: elf32-ppc.c:4121 elf32-ppc.c:4125
+msgid "Warning: %B uses unknown small structure return convention %d"
+msgstr ""
+
+#: elf32-ppc.c:4179
+msgid "%B: compiled with -mrelocatable and linked with modules compiled normally"
+msgstr ""
+
+#: elf32-ppc.c:4187
+msgid "%B: compiled normally and linked with modules compiled with -mrelocatable"
+msgstr ""
+
+#: elf32-ppc.c:4275
+msgid "Using bss-plt due to %B"
+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
+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"
+msgstr "динамічна змінна «%s» має нульовий розмір\n"
+
+#: elf32-ppc.c:7204 elf64-ppc.c:12431
+msgid "%B: unknown relocation type %d for symbol %s\n"
+msgstr "%B: невідомий тип пересування %d для символу %s\n"
+
+#: elf32-ppc.c:7465
+msgid "%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"
+msgstr ""
+
+#: elf32-ppc.c:7889 elf32-ppc.c:7919 elf32-ppc.c:7966
+msgid "%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"
+msgstr ""
+
+#: elf32-ppc.c:8097 elf64-ppc.c:13237
+msgid "%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"
+msgstr ""
+
+#: elf32-ppc.c:8635
+#, c-format
+msgid "%s not defined in linker created %s\n"
+msgstr ""
+
+#: elf32-rx.c:553
+msgid "%B:%A: Warning: deprecated Red Hat reloc "
+msgstr "%B:%A: попередження: застарілий формат пересування Red Hat "
+
+#: elf32-rx.c:1095
+msgid "Warning: RX_SYM reloc with an unknown symbol"
+msgstr ""
+
+#: elf32-rx.c:1260
+msgid "%B(%A): error: call to undefined function '%s'"
+msgstr ""
+
+#: elf32-rx.c:1274
+msgid "%B(%A): warning: unaligned access to symbol '%s' in the small data area"
+msgstr ""
+
+#: elf32-rx.c:1278
+msgid "%B(%A): internal error: out of range error"
+msgstr "%B(%A): внутрішня помилка: вихід за межі діапазону"
+
+#: elf32-rx.c:1282
+msgid "%B(%A): internal error: unsupported relocation error"
+msgstr "%B(%A): внутрішня помилка: непідтримувана помилка пересування"
+
+#: elf32-rx.c:1286
+msgid "%B(%A): internal error: dangerous relocation"
+msgstr "%B(%A): внутрішня помилка: небезпечне пересування"
+
+#: elf32-rx.c:1290
+msgid "%B(%A): internal error: unknown error"
+msgstr "%B(%A): внутрішня помилка: невідома помилка"
+
+#: elf32-rx.c:2940
+#, c-format
+msgid " [64-bit doubles]"
+msgstr " [64-бітові double]"
+
+#: elf32-rx.c:2942
+#, c-format
+msgid " [dsp]"
+msgstr " [dsp]"
+
+#: elf32-s390.c:2209 elf64-s390.c:2196
+msgid "%B(%A+0x%lx): invalid instruction for TLS relocation %s"
+msgstr ""
+
+#: elf32-score.c:1522 elf32-score7.c:1382 elfxx-mips.c:3324
+msgid "not enough GOT space for local GOT entries"
+msgstr ""
+
+#: elf32-score.c:2744
+msgid "address not word align"
+msgstr "адресу не вирівняно за межею слова"
+
+#: elf32-score.c:2829 elf32-score7.c:2634
+#, c-format
+msgid "%s: Malformed reloc detected for section %s"
+msgstr "%s: для розділу %s виявлено помилку у форматуванні перенесення"
+
+#: elf32-score.c:2880 elf32-score7.c:2685
+msgid "%B: CALL15 reloc at 0x%lx not against global symbol"
+msgstr ""
+
+#: elf32-score.c:3999 elf32-score7.c:3806
+#, c-format
+msgid " [pic]"
+msgstr " [pic]"
+
+#: elf32-score.c:4003 elf32-score7.c:3810
+#, c-format
+msgid " [fix dep]"
+msgstr ""
+
+#: elf32-score.c:4045 elf32-score7.c:3852
+msgid "%B: warning: linking PIC files with non-PIC files"
+msgstr ""
+
+#: elf32-sh-symbian.c:130
+msgid "%B: IMPORT AS directive for %s conceals previous IMPORT AS"
+msgstr ""
+
+#: elf32-sh-symbian.c:383
+msgid "%B: Unrecognised .directive command: %s"
+msgstr "%B: нерозпізнана команда .directive: %s"
+
+#: elf32-sh-symbian.c:504
+msgid "%B: Failed to add renamed symbol %s"
+msgstr "%B: не вдалося додати перейменований символ %s"
+
+#: elf32-sh.c:568
+msgid "%B: 0x%lx: warning: bad R_SH_USES offset"
+msgstr "%B: 0x%lx: попередження: помилковий відступ R_SH_USES"
+
+#: elf32-sh.c:580
+msgid "%B: 0x%lx: warning: R_SH_USES points to unrecognized insn 0x%x"
+msgstr ""
+
+#: elf32-sh.c:597
+msgid "%B: 0x%lx: warning: bad R_SH_USES load offset"
+msgstr "%B: 0x%lx: попередження: помилковий відступ завантаження R_SH_USES"
+
+#: elf32-sh.c:612
+msgid "%B: 0x%lx: warning: could not find expected reloc"
+msgstr "%B: 0x%lx: попередження: не вдалося знайти очікуване пересування"
+
+#: elf32-sh.c:640
+msgid "%B: 0x%lx: warning: symbol in unexpected section"
+msgstr "%B: 0x%lx: попередження: символ у неочікуваному розділі"
+
+#: elf32-sh.c:766
+msgid "%B: 0x%lx: warning: could not find expected COUNT reloc"
+msgstr "%B: 0x%lx: попередження: не вдалося знайти очікуване пересування COUNT"
+
+#: elf32-sh.c:775
+msgid "%B: 0x%lx: warning: bad count"
+msgstr "%B: 0x%lx: попередження: помилковий лічильник"
+
+#: elf32-sh.c:1179 elf32-sh.c:1549
+msgid "%B: 0x%lx: fatal: reloc overflow while relaxing"
+msgstr ""
+
+#: elf32-sh.c:4057 elf64-sh64.c:1514
+msgid "Unexpected STO_SH5_ISA32 on local symbol is not handled"
+msgstr ""
+
+#: elf32-sh.c:4304
+msgid "%B: 0x%lx: fatal: unaligned branch target for relax-support relocation"
+msgstr ""
+
+#: elf32-sh.c:4337 elf32-sh.c:4352
+msgid "%B: 0x%lx: fatal: unaligned %s relocation 0x%lx"
+msgstr "%B: 0x%lx: критична помилка: невирівняне пересування %s, 0x%lx"
+
+#: elf32-sh.c:4366
+msgid "%B: 0x%lx: fatal: R_SH_PSHA relocation %d not in range -32..32"
+msgstr ""
+
+#: elf32-sh.c:4380
+msgid "%B: 0x%lx: fatal: R_SH_PSHL relocation %d not in range -32..32"
+msgstr ""
+
+#: elf32-sh.c:4524 elf32-sh.c:4994
+msgid "%B(%A+0x%lx): cannot emit fixup to `%s' in read-only section"
+msgstr ""
+
+#: elf32-sh.c:5101
+msgid "%B(%A+0x%lx): %s relocation against external symbol \"%s\""
+msgstr "%B(%A+0x%lx): пересування %s за зовнішнім символом «%s»"
+
+#: elf32-sh.c:5574
+#, c-format
+msgid "%X%C: relocation to \"%s\" references a different segment\n"
+msgstr "%X%C: пересування за «%s» посилається на інший сегмент\n"
+
+#: elf32-sh.c:5580
+#, c-format
+msgid "%C: warning: relocation to \"%s\" references a different segment\n"
+msgstr "%C: попередження: пересування за «%s» посилається на інший сегмент\n"
+
+#: elf32-sh.c:6358 elf32-sh.c:6441
+msgid "%B: `%s' accessed both as normal and FDPIC symbol"
+msgstr ""
+
+#: elf32-sh.c:6363 elf32-sh.c:6445
+msgid "%B: `%s' accessed both as FDPIC and thread local symbol"
+msgstr ""
+
+#: elf32-sh.c:6393
+msgid "%B: Function descriptor relocation with non-zero addend"
+msgstr ""
+
+#: elf32-sh.c:6629 elf64-alpha.c:4648
+msgid "%B: TLS local exec code cannot be linked into shared objects"
+msgstr ""
+
+#: elf32-sh64.c:223 elf64-sh64.c:2314
+#, c-format
+msgid "%s: compiled as 32-bit object and %s is 64-bit"
+msgstr "%s: зібрано як 32- бітовий об’єкт, а %s є 64-бітовим"
+
+#: elf32-sh64.c:226 elf64-sh64.c:2317
+#, c-format
+msgid "%s: compiled as 64-bit object and %s is 32-bit"
+msgstr "%s: зібрано як 64-бітовий об’єкт, а %s є 32-бітовим"
+
+#: elf32-sh64.c:228 elf64-sh64.c:2319
+#, c-format
+msgid "%s: object size does not match that of target %s"
+msgstr "%s: розмір об’єкта не збігається з розміром призначення %s"
+
+#: elf32-sh64.c:451 elf64-sh64.c:2833
+#, c-format
+msgid "%s: encountered datalabel symbol in input"
+msgstr ""
+
+#: elf32-sh64.c:528
+msgid "PTB mismatch: a SHmedia address (bit 0 == 1)"
+msgstr ""
+
+#: elf32-sh64.c:531
+msgid "PTA mismatch: a SHcompact address (bit 0 == 0)"
+msgstr ""
+
+#: elf32-sh64.c:549
+#, c-format
+msgid "%s: GAS error: unexpected PTB insn with R_SH_PT_16"
+msgstr ""
+
+#: elf32-sh64.c:598
+msgid "%B: error: unaligned relocation type %d at %08x reloc %p\n"
+msgstr ""
+
+#: elf32-sh64.c:674
+#, c-format
+msgid "%s: could not write out added .cranges entries"
+msgstr ""
+
+#: elf32-sh64.c:734
+#, c-format
+msgid "%s: could not write out sorted .cranges entries"
+msgstr "%s: не вдалося виконати запис впорядкованих записів .cranges"
+
+#: elf32-sparc.c:89
+msgid "%B: compiled for a 64 bit system and target is 32 bit"
+msgstr "%B: зібрано для 64-бітової системи, системою ж призначення є 32-бітова"
+
+#: elf32-sparc.c:102
+msgid "%B: linking little endian files with big endian files"
+msgstr "%B: компонування файлів зі зворотним порядком байтів з файлами з прямим порядком байтів"
+
+#: elf32-spu.c:719
+msgid "%X%P: overlay section %A does not start on a cache line.\n"
+msgstr ""
+
+#: elf32-spu.c:727
+msgid "%X%P: overlay section %A is larger than a cache line.\n"
+msgstr ""
+
+#: elf32-spu.c:747
+msgid "%X%P: overlay section %A is not in cache area.\n"
+msgstr ""
+
+#: elf32-spu.c:787
+msgid "%X%P: overlay sections %A and %A do not start at the same address.\n"
+msgstr ""
+
+#: elf32-spu.c:1011
+msgid "warning: call to non-function symbol %s defined in %B"
+msgstr ""
+
+#: elf32-spu.c:1361
+msgid "%A:0x%v lrlive .brinfo (%u) differs from analysis (%u)\n"
+msgstr ""
+
+#: elf32-spu.c:1880
+msgid "%B is not allowed to define %s"
+msgstr "%B не може визначати %s"
+
+#: elf32-spu.c:1888
+#, c-format
+msgid "you are not allowed to define %s in a script"
+msgstr "не можна визначати %s у скрипті"
+
+#: elf32-spu.c:1922
+#, c-format
+msgid "%s in overlay section"
+msgstr ""
+
+#: elf32-spu.c:1951
+msgid "overlay stub relocation overflow"
+msgstr ""
+
+#: elf32-spu.c:1960
+msgid "stubs don't match calculated size"
+msgstr ""
+
+#: elf32-spu.c:2542
+#, c-format
+msgid "warning: %s overlaps %s\n"
+msgstr ""
+
+#: elf32-spu.c:2558
+#, c-format
+msgid "warning: %s exceeds section size\n"
+msgstr ""
+
+#: elf32-spu.c:2589
+msgid "%A:0x%v not found in function table\n"
+msgstr "%A:0x%v не знайдено у таблиці функцій\n"
+
+#: elf32-spu.c:2729
+msgid "%B(%A+0x%v): call to non-code section %B(%A), analysis incomplete\n"
+msgstr "%B(%A+0x%v): виклик розділу, який не містить код, %B(%A), аналіз є неповним\n"
+
+#: elf32-spu.c:3297
+#, c-format
+msgid "Stack analysis will ignore the call from %s to %s\n"
+msgstr "Під час аналізу стека буде проігноровано виклик з %s до %s\n"
+
+#: elf32-spu.c:3988
+msgid "  %s: 0x%v\n"
+msgstr "  %s: 0x%v\n"
+
+#: elf32-spu.c:3989
+msgid "%s: 0x%v 0x%v\n"
+msgstr "%s: 0x%v 0x%v\n"
+
+#: elf32-spu.c:3994
+msgid "  calls:\n"
+msgstr "  виклики:\n"
+
+#: elf32-spu.c:4002
+#, c-format
+msgid "   %s%s %s\n"
+msgstr "   %s%s %s\n"
+
+#: elf32-spu.c:4307
+#, c-format
+msgid "%s duplicated in %s\n"
+msgstr "%s повторюється у %s\n"
+
+#: elf32-spu.c:4311
+#, c-format
+msgid "%s duplicated\n"
+msgstr "%s дубльовано\n"
+
+#: elf32-spu.c:4318
+msgid "sorry, no support for duplicate object files in auto-overlay script\n"
+msgstr ""
+
+#: elf32-spu.c:4359
+msgid "non-overlay size of 0x%v plus maximum overlay size of 0x%v exceeds local store\n"
+msgstr ""
+
+#: elf32-spu.c:4514
+msgid "%B:%A%s exceeds overlay size\n"
+msgstr ""
+
+#: elf32-spu.c:4676
+msgid "Stack size for call graph root nodes.\n"
+msgstr ""
+
+#: elf32-spu.c:4677
+msgid ""
+"\n"
+"Stack size for functions.  Annotations: '*' max stack, 't' tail call\n"
+msgstr ""
+
+#: elf32-spu.c:4687
+msgid "Maximum stack required is 0x%v\n"
+msgstr "Максимальний потрібний розмір стека — 0x%v\n"
+
+#: elf32-spu.c:4778
+msgid "fatal error while creating .fixup"
+msgstr "критична помилка під час спроби створення .fixup"
+
+#: elf32-spu.c:5006
+msgid "%B(%s+0x%lx): unresolvable %s relocation against symbol `%s'"
+msgstr "%B(%s+0x%lx): нерозв’язне пересування %s щодо символу «%s»"
+
+#: elf32-tic6x.c:1602
+msgid "warning: generating a shared library containing non-PIC code"
+msgstr "попередження: створюється бібліотека спільного використання, яка містить код, несумісний з PIC"
+
+#: elf32-tic6x.c:1607
+msgid "warning: generating a shared library containing non-PID code"
+msgstr ""
+
+#: elf32-tic6x.c:2539
+msgid "%B: SB-relative relocation but __c6xabi_DSBT_BASE not defined"
+msgstr ""
+
+#: elf32-tic6x.c:2759
+msgid "dangerous relocation"
+msgstr "небезпечне пересування"
+
+#: elf32-tic6x.c:3740
+msgid "%B: error: unknown mandatory EABI object attribute %d"
+msgstr ""
+
+#: elf32-tic6x.c:3748
+msgid "%B: warning: unknown EABI object attribute %d"
+msgstr ""
+
+#: elf32-tic6x.c:3860 elf32-tic6x.c:3868
+msgid "error: %B requires more stack alignment than %B preserves"
+msgstr ""
+
+#: elf32-tic6x.c:3878 elf32-tic6x.c:3887
+msgid "error: unknown Tag_ABI_array_object_alignment value in %B"
+msgstr ""
+
+#: elf32-tic6x.c:3896 elf32-tic6x.c:3905
+msgid "error: unknown Tag_ABI_array_object_align_expected value in %B"
+msgstr ""
+
+#: elf32-tic6x.c:3913 elf32-tic6x.c:3920
+msgid "error: %B requires more array alignment than %B preserves"
+msgstr ""
+
+#: elf32-tic6x.c:3942
+msgid "warning: %B and %B differ in wchar_t size"
+msgstr ""
+
+#: elf32-tic6x.c:3960
+msgid "warning: %B and %B differ in whether code is compiled for DSBT"
+msgstr ""
+
+#: elf32-v850.c:173
+#, c-format
+msgid "Variable `%s' cannot occupy in multiple small data regions"
+msgstr ""
+
+#: elf32-v850.c:176
+#, c-format
+msgid "Variable `%s' can only be in one of the small, zero, and tiny data regions"
+msgstr ""
+
+#: elf32-v850.c:179
+#, c-format
+msgid "Variable `%s' cannot be in both small and zero data regions simultaneously"
+msgstr ""
+
+#: elf32-v850.c:182
+#, c-format
+msgid "Variable `%s' cannot be in both small and tiny data regions simultaneously"
+msgstr ""
+
+#: elf32-v850.c:185
+#, c-format
+msgid "Variable `%s' cannot be in both zero and tiny data regions simultaneously"
+msgstr ""
+
+#: elf32-v850.c:483
+msgid "FAILED to find previous HI16 reloc"
+msgstr "НЕ ВДАЛОСЯ знайти попереднє пересування HI16"
+
+#: elf32-v850.c:2155
+msgid "could not locate special linker symbol __gp"
+msgstr "не вдалося знайти спеціальний символ компонувальника __gp"
+
+#: elf32-v850.c:2159
+msgid "could not locate special linker symbol __ep"
+msgstr "не вдалося знайти спеціальний символ компонувальника __ep"
+
+#: elf32-v850.c:2163
+msgid "could not locate special linker symbol __ctbp"
+msgstr "не вдалося знайти спеціальний символ компонувальника __ctbp"
+
+#: elf32-v850.c:2341
+msgid "%B: Architecture mismatch with previous modules"
+msgstr "%B: невідповідність архітектур з попередніми модулями"
+
+#. xgettext:c-format.
+#: elf32-v850.c:2360
+#, c-format
+msgid "private flags = %lx: "
+msgstr "закриті прапорці = %lx: "
+
+#: elf32-v850.c:2365
+#, c-format
+msgid "v850 architecture"
+msgstr "архітектура v850"
+
+#: elf32-v850.c:2366
+#, c-format
+msgid "v850e architecture"
+msgstr "архітектура v850e"
+
+#: elf32-v850.c:2367
+#, c-format
+msgid "v850e1 architecture"
+msgstr "архітектура v850e1"
+
+#: elf32-v850.c:2368
+#, c-format
+msgid "v850e2 architecture"
+msgstr "архітектура v850e2"
+
+#: elf32-v850.c:2369
+#, c-format
+msgid "v850e2v3 architecture"
+msgstr "архітектура v850e2v3"
+
+#: elf32-vax.c:531
+#, c-format
+msgid " [nonpic]"
+msgstr ""
+
+#: elf32-vax.c:534
+#, c-format
+msgid " [d-float]"
+msgstr ""
+
+#: elf32-vax.c:537
+#, c-format
+msgid " [g-float]"
+msgstr ""
+
+#: elf32-vax.c:654
+#, c-format
+msgid "%s: warning: GOT addend of %ld to `%s' does not match previous GOT addend of %ld"
+msgstr ""
+
+#: elf32-vax.c:1587
+#, c-format
+msgid "%s: warning: PLT addend of %d to `%s' from %s section ignored"
+msgstr ""
+
+#: elf32-vax.c:1714
+#, c-format
+msgid "%s: warning: %s relocation against symbol `%s' from %s section"
+msgstr ""
+
+#: elf32-vax.c:1720
+#, 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
+msgid "non-zero addend in @fptr reloc"
+msgstr ""
+
+#: elf32-xtensa.c:918
+msgid "%B(%A): invalid property table"
+msgstr ""
+
+#: elf32-xtensa.c:2780
+msgid "%B(%A+0x%lx): relocation offset out of range (size=0x%x)"
+msgstr ""
+
+#: elf32-xtensa.c:2859 elf32-xtensa.c:2980
+msgid "dynamic relocation in read-only section"
+msgstr ""
+
+#: elf32-xtensa.c:2956
+msgid "TLS relocation invalid without dynamic sections"
+msgstr ""
+
+#: elf32-xtensa.c:3173
+msgid "internal inconsistency in size of .got.loc section"
+msgstr ""
+
+#: elf32-xtensa.c:3486
+msgid "%B: incompatible machine type. Output is 0x%x. Input is 0x%x"
+msgstr ""
+
+#: elf32-xtensa.c:4715 elf32-xtensa.c:4723
+msgid "Attempt to convert L32R/CALLX to CALL failed"
+msgstr ""
+
+#: elf32-xtensa.c:6333 elf32-xtensa.c:6409 elf32-xtensa.c:7525
+msgid "%B(%A+0x%lx): could not decode instruction; possible configuration mismatch"
+msgstr ""
+
+#: elf32-xtensa.c:7265
+msgid "%B(%A+0x%lx): could not decode instruction for XTENSA_ASM_SIMPLIFY relocation; possible configuration mismatch"
+msgstr ""
+
+#: elf32-xtensa.c:9024
+msgid "invalid relocation address"
+msgstr ""
+
+#: elf32-xtensa.c:9073
+msgid "overflow after relaxation"
+msgstr ""
+
+#: elf32-xtensa.c:10205
+msgid "%B(%A+0x%lx): unexpected fix for %s relocation"
+msgstr ""
+
+#: elf64-alpha.c:460
+msgid "GPDISP relocation did not find ldah and lda instructions"
+msgstr ""
+
+#: elf64-alpha.c:2495
+msgid "%B: .got subsegment exceeds 64K (size %d)"
+msgstr ""
+
+#: elf64-alpha.c:4392 elf64-alpha.c:4404
+msgid "%B: gp-relative relocation against dynamic symbol %s"
+msgstr ""
+
+#: elf64-alpha.c:4430 elf64-alpha.c:4565
+msgid "%B: pc-relative relocation against dynamic symbol %s"
+msgstr ""
+
+#: elf64-alpha.c:4458
+msgid "%B: change in gp: BRSGP %s"
+msgstr ""
+
+#: elf64-alpha.c:4483
+msgid "<unknown>"
+msgstr ""
+
+#: elf64-alpha.c:4488
+msgid "%B: !samegp reloc against symbol without .prologue: %s"
+msgstr ""
+
+#: elf64-alpha.c:4540
+msgid "%B: unhandled dynamic relocation against %s"
+msgstr ""
+
+#: elf64-alpha.c:4572
+msgid "%B: pc-relative relocation against undefined weak symbol %s"
+msgstr ""
+
+#: elf64-alpha.c:4632
+msgid "%B: dtp-relative relocation against dynamic symbol %s"
+msgstr ""
+
+#: elf64-alpha.c:4655
+msgid "%B: tp-relative relocation against dynamic symbol %s"
+msgstr ""
+
+#: elf64-hppa.c:2094
+#, 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"
+msgstr ""
+
+#: elf64-mmix.c:1177
+#, c-format
+msgid ""
+"%s: Internal inconsistency error for value for\n"
+" linker-allocated global register: linked: 0x%lx%08lx != relaxed: 0x%lx%08lx\n"
+msgstr ""
+
+#: elf64-mmix.c:1607
+#, c-format
+msgid "%s: base-plus-offset relocation against register symbol: (unknown) in %s"
+msgstr ""
+
+#: elf64-mmix.c:1612
+#, c-format
+msgid "%s: base-plus-offset relocation against register symbol: %s in %s"
+msgstr ""
+
+#: elf64-mmix.c:1656
+#, c-format
+msgid "%s: register relocation against non-register symbol: (unknown) in %s"
+msgstr ""
+
+#: elf64-mmix.c:1661
+#, c-format
+msgid "%s: register relocation against non-register symbol: %s in %s"
+msgstr ""
+
+#: elf64-mmix.c:1698
+#, c-format
+msgid "%s: directive LOCAL valid only with a register or absolute value"
+msgstr ""
+
+#: elf64-mmix.c:1726
+#, c-format
+msgid "%s: LOCAL directive: Register $%ld is not a local register.  First global register is $%ld."
+msgstr ""
+
+#: elf64-mmix.c:2190
+#, 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
+msgid "Register section has contents\n"
+msgstr ""
+
+#: elf64-mmix.c:2440
+#, 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"
+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
+msgid "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"
+msgstr ""
+
+#: elf64-ppc.c:6996
+msgid "%B: .opd is not a regular array of opd entries"
+msgstr ""
+
+#: elf64-ppc.c:7005
+msgid "%B: unexpected reloc type %u in .opd section"
+msgstr ""
+
+#: elf64-ppc.c:7026
+msgid "%B: undefined sym `%s' in .opd section"
+msgstr ""
+
+#: elf64-ppc.c:7584
+msgid "%H __tls_get_addr lost arg, TLS optimization disabled\n"
+msgstr ""
+
+#: elf64-ppc.c:7929 elf64-ppc.c:8450
+#, 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"
+msgstr ""
+
+#: elf64-ppc.c:9556
+#, c-format
+msgid "long branch stub `%s' offset overflow\n"
+msgstr ""
+
+#: elf64-ppc.c:9615
+#, c-format
+msgid "can't find branch stub `%s'\n"
+msgstr ""
+
+#: elf64-ppc.c:9677 elf64-ppc.c:9819
+#, c-format
+msgid "linkage table error against `%s'\n"
+msgstr ""
+
+#: elf64-ppc.c:9993
+#, c-format
+msgid "can't build branch stub `%s'\n"
+msgstr ""
+
+#: elf64-ppc.c:10814
+msgid "%B section %A exceeds stub group size"
+msgstr ""
+
+#: elf64-ppc.c:11457
+msgid "stubs don't match calculated size\n"
+msgstr ""
+
+#: elf64-ppc.c:11469
+#, c-format
+msgid ""
+"linker stubs in %u group%s\n"
+"  branch       %lu\n"
+"  toc adjust   %lu\n"
+"  long branch  %lu\n"
+"  long toc adj %lu\n"
+"  plt call     %lu"
+msgstr ""
+
+#: elf64-ppc.c:11819
+msgid "%H: %s used with TLS symbol %s\n"
+msgstr ""
+
+#: elf64-ppc.c:11820
+msgid "%H: %s used with non-TLS symbol %s\n"
+msgstr ""
+
+#: elf64-ppc.c:12318
+msgid "%H: automatic multiple TOCs not supported using your crt files; recompile with -mminimal-toc or upgrade gcc\n"
+msgstr ""
+
+#: elf64-ppc.c:12324
+msgid "%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"
+msgstr ""
+
+#: elf64-ppc.c:13218
+msgid "%H: error: %s not a multiple of %u\n"
+msgstr ""
+
+#: elf64-sh64.c:1682
+#, c-format
+msgid "%s: error: unaligned relocation type %d at %08x reloc %08x\n"
+msgstr ""
+
+#: elf64-sparc.c:445
+msgid "%B: Only registers %%g[2367] can be declared using STT_REGISTER"
+msgstr ""
+
+#: elf64-sparc.c:465
+msgid "Register %%g%d used incompatibly: %s in %B, previously %s in %B"
+msgstr ""
+
+#: elf64-sparc.c:488
+msgid "Symbol `%s' has differing types: REGISTER in %B, previously %s in %B"
+msgstr ""
+
+#: elf64-sparc.c:533
+msgid "Symbol `%s' has differing types: %s in %B, previously REGISTER in %B"
+msgstr ""
+
+#: elf64-sparc.c:686
+msgid "%B: linking UltraSPARC specific with HAL specific code"
+msgstr ""
+
+#: elf64-x86-64.c:1236
+msgid "%B: relocation %s against symbol `%s' isn't supported in x32 mode"
+msgstr ""
+
+#: elf64-x86-64.c:1465
+msgid "%B: '%s' accessed both as normal and thread local symbol"
+msgstr ""
+
+#: elf64-x86-64.c:2934
+msgid "%B: relocation %s against STT_GNU_IFUNC symbol `%s' has non-zero addend: %d"
+msgstr ""
+
+#: elf64-x86-64.c:3193
+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
+msgid "; recompile with -fPIC"
+msgstr ""
+
+#: elf64-x86-64.c:3310
+msgid "%B: relocation %s against %s `%s' can not be used when making a shared object%s"
+msgstr ""
+
+#: elf64-x86-64.c:3312
+msgid "%B: relocation %s against undefined %s `%s' can not be used when making a shared object%s"
+msgstr ""
+
+#: elfcode.h:827
+#, c-format
+msgid "warning: %s has a corrupt string table index - ignoring"
+msgstr ""
+
+#: elfcode.h:1237
+#, c-format
+msgid "%s: version count (%ld) does not match symbol count (%ld)"
+msgstr ""
+
+#: elfcode.h:1491
+#, c-format
+msgid "%s(%s): relocation %d has invalid symbol index %ld"
+msgstr ""
+
+#: elfcore.h:312
+msgid "Warning: %B is truncated: expected core file size >= %lu, found: %lu."
+msgstr ""
+
+#: elflink.c:1119
+msgid "%s: TLS definition in %B section %A mismatches non-TLS definition in %B section %A"
+msgstr ""
+
+#: elflink.c:1123
+msgid "%s: TLS reference in %B mismatches non-TLS reference in %B"
+msgstr ""
+
+#: elflink.c:1127
+msgid "%s: TLS definition in %B section %A mismatches non-TLS reference in %B"
+msgstr ""
+
+#: elflink.c:1131
+msgid "%s: TLS reference in %B mismatches non-TLS definition in %B section %A"
+msgstr ""
+
+#: elflink.c:1764
+msgid "%B: unexpected redefinition of indirect versioned symbol `%s'"
+msgstr ""
+
+#: elflink.c:2077
+msgid "%B: version node not found for symbol %s"
+msgstr ""
+
+#: elflink.c:2167
+msgid "%B: bad reloc symbol index (0x%lx >= 0x%lx) for offset 0x%lx in section `%A'"
+msgstr ""
+
+#: elflink.c:2178
+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
+msgid "%B: relocation size mismatch in %B section %A"
+msgstr ""
+
+#: elflink.c:2663
+#, c-format
+msgid "warning: type and size of dynamic symbol `%s' are not defined"
+msgstr ""
+
+#: elflink.c:3421
+msgid "%P: alternate ELF machine code found (%d) in %B, expecting %d\n"
+msgstr ""
+
+#: elflink.c:4067
+msgid "%B: %s: invalid version %u (max %d)"
+msgstr ""
+
+#: elflink.c:4103
+msgid "%B: %s: invalid needed version %d"
+msgstr ""
+
+#: elflink.c:4299
+msgid "Warning: alignment %u of common symbol `%s' in %B is greater than the alignment (%u) of its section %A"
+msgstr ""
+
+#: elflink.c:4305
+msgid "Warning: alignment %u of symbol `%s' in %B is smaller than %u in %B"
+msgstr ""
+
+#: elflink.c:4320
+msgid "Warning: size of symbol `%s' changed from %lu in %B to %lu in %B"
+msgstr ""
+
+#: elflink.c:4489
+msgid "%B: undefined reference to symbol '%s'"
+msgstr ""
+
+#: elflink.c:4492
+msgid "note: '%s' is defined in DSO %B so try adding it to the linker command line"
+msgstr ""
+
+#: elflink.c:5795
+#, c-format
+msgid "%s: undefined version: %s"
+msgstr ""
+
+#: elflink.c:5863
+msgid "%B: .preinit_array section is not allowed in DSO"
+msgstr ""
+
+#: elflink.c:7617
+#, c-format
+msgid "undefined %s reference in complex symbol: %s"
+msgstr ""
+
+#: elflink.c:7771
+#, c-format
+msgid "unknown operator '%c' in complex symbol"
+msgstr ""
+
+#: elflink.c:8110 elflink.c:8127 elflink.c:8164 elflink.c:8181
+msgid "%B: Unable to sort relocs - they are in more than one size"
+msgstr ""
+
+#: elflink.c:8141 elflink.c:8195
+msgid "%B: Unable to sort relocs - they are of an unknown size"
+msgstr ""
+
+#: elflink.c:8246
+msgid "Not enough memory to sort relocations"
+msgstr ""
+
+#: elflink.c:8439
+msgid "%B: Too many sections: %d (>= %d)"
+msgstr ""
+
+#: elflink.c:8686
+msgid "%B: internal symbol `%s' in %B is referenced by DSO"
+msgstr ""
+
+#: elflink.c:8688
+msgid "%B: hidden symbol `%s' in %B is referenced by DSO"
+msgstr ""
+
+#: elflink.c:8690
+msgid "%B: local symbol `%s' in %B is referenced by DSO"
+msgstr ""
+
+#: elflink.c:8785
+msgid "%B: could not find output section %A for input section %A"
+msgstr ""
+
+#: elflink.c:8908
+msgid "%B: protected symbol `%s' isn't defined"
+msgstr ""
+
+#: elflink.c:8910
+msgid "%B: internal symbol `%s' isn't defined"
+msgstr ""
+
+#: elflink.c:8912
+msgid "%B: hidden symbol `%s' isn't defined"
+msgstr ""
+
+#: elflink.c:9441
+msgid "error: %B: size of section %A is not multiple of address size"
+msgstr ""
+
+#: elflink.c:9488
+msgid "error: %B contains a reloc (0x%s) for section %A that references a non-existent global symbol"
+msgstr ""
+
+#: elflink.c:10223
+msgid "%A has both ordered [`%A' in %B] and unordered [`%A' in %B] sections"
+msgstr ""
+
+#: elflink.c:10228
+#, c-format
+msgid "%A has both ordered and unordered sections"
+msgstr ""
+
+#: elflink.c:10793
+msgid "%B: file class %s incompatible with %s"
+msgstr ""
+
+#: elflink.c:11104 elflink.c:11148
+msgid "%B: could not find output section %s"
+msgstr ""
+
+#: elflink.c:11109
+#, c-format
+msgid "warning: %s section has zero size"
+msgstr ""
+
+#: elflink.c:11214
+msgid "%P: warning: creating a DT_TEXTREL in a shared object.\n"
+msgstr ""
+
+#: elflink.c:11401
+msgid "%P%X: can not read symbols: %E\n"
+msgstr ""
+
+#: elflink.c:11750
+msgid "Removing unused section '%s' in file '%B'"
+msgstr ""
+
+#: elflink.c:11962
+msgid "Warning: gc-sections option ignored"
+msgstr ""
+
+#: elflink.c:12511
+msgid "%B: ignoring duplicate section `%A'"
+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
+msgid "static procedure (no name)"
+msgstr ""
+
+#: elfxx-mips.c:5628
+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
+msgid "%B: Warning: bad `%s' option size %u smaller than its header"
+msgstr ""
+
+#: elfxx-mips.c:7262 elfxx-mips.c:7387
+msgid "%B: Warning: cannot determine the target function for stub section `%s'"
+msgstr ""
+
+#: elfxx-mips.c:7516
+msgid "%B: Malformed reloc detected for section %s"
+msgstr ""
+
+#: elfxx-mips.c:7556
+msgid "%B: GOT reloc at 0x%lx not expected in executables"
+msgstr ""
+
+#: elfxx-mips.c:7678
+msgid "%B: CALL16 reloc at 0x%lx not against global symbol"
+msgstr ""
+
+#: elfxx-mips.c:8372
+#, c-format
+msgid "non-dynamic relocations refer to dynamic symbol %s"
+msgstr ""
+
+#: elfxx-mips.c:9075
+msgid "%B: Can't find matching LO16 reloc against `%s' for %s at 0x%lx in section `%A'"
+msgstr ""
+
+#: elfxx-mips.c:9214
+msgid "small-data section exceeds 64KB; lower small-data size limit (see option -G)"
+msgstr ""
+
+#: elfxx-mips.c:12038
+#, c-format
+msgid "%s: illegal section name `%s'"
+msgstr ""
+
+#: elfxx-mips.c:12417 elfxx-mips.c:12443
+msgid "Warning: %B uses -msingle-float, %B uses -mdouble-float"
+msgstr ""
+
+#: elfxx-mips.c:12429 elfxx-mips.c:12485
+msgid "Warning: %B uses -msingle-float, %B uses -mips32r2 -mfp64"
+msgstr ""
+
+#: elfxx-mips.c:12455 elfxx-mips.c:12491
+msgid "Warning: %B uses -mdouble-float, %B uses -mips32r2 -mfp64"
+msgstr ""
+
+#: elfxx-mips.c:12533
+msgid "%B: endianness incompatible with that of the selected emulation"
+msgstr ""
+
+#: elfxx-mips.c:12544
+msgid "%B: ABI is incompatible with that of the selected emulation"
+msgstr ""
+
+#: elfxx-mips.c:12628
+msgid "%B: warning: linking abicalls files with non-abicalls files"
+msgstr ""
+
+#: elfxx-mips.c:12645
+msgid "%B: linking 32-bit code with 64-bit code"
+msgstr ""
+
+#: elfxx-mips.c:12673
+msgid "%B: linking %s module with previous %s modules"
+msgstr ""
+
+#: elfxx-mips.c:12696
+msgid "%B: ABI mismatch: linking %s module with previous %s modules"
+msgstr ""
+
+#: elfxx-mips.c:12860
+#, c-format
+msgid " [abi=O32]"
+msgstr ""
+
+#: elfxx-mips.c:12862
+#, c-format
+msgid " [abi=O64]"
+msgstr ""
+
+#: elfxx-mips.c:12864
+#, c-format
+msgid " [abi=EABI32]"
+msgstr ""
+
+#: elfxx-mips.c:12866
+#, c-format
+msgid " [abi=EABI64]"
+msgstr ""
+
+#: elfxx-mips.c:12868
+#, c-format
+msgid " [abi unknown]"
+msgstr ""
+
+#: elfxx-mips.c:12870
+#, c-format
+msgid " [abi=N32]"
+msgstr ""
+
+#: elfxx-mips.c:12872
+#, c-format
+msgid " [abi=64]"
+msgstr ""
+
+#: elfxx-mips.c:12874
+#, c-format
+msgid " [no abi set]"
+msgstr ""
+
+#: elfxx-mips.c:12895
+#, c-format
+msgid " [unknown ISA]"
+msgstr ""
+
+#: elfxx-mips.c:12906
+#, c-format
+msgid " [not 32bitmode]"
+msgstr ""
+
+#: elfxx-sparc.c:595
+#, c-format
+msgid "invalid relocation type %d"
+msgstr ""
+
+#: i386linux.c:454 m68klinux.c:458 sparclinux.c:452
+#, c-format
+msgid "Output file requires shared library `%s'\n"
+msgstr ""
+
+#: i386linux.c:462 m68klinux.c:466 sparclinux.c:460
+#, 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
+#, c-format
+msgid "Symbol %s not defined for fixups\n"
+msgstr ""
+
+#: i386linux.c:725 m68klinux.c:730 sparclinux.c:724
+msgid "Warning: fixup count mismatch\n"
+msgstr ""
+
+#: ieee.c:159
+#, c-format
+msgid "%s: string too long (%d chars, max 65535)"
+msgstr ""
+
+#: ieee.c:286
+#, c-format
+msgid "%s: unrecognized symbol `%s' flags 0x%x"
+msgstr ""
+
+#: ieee.c:792
+msgid "%B: unimplemented ATI record %u for symbol %u"
+msgstr ""
+
+#: ieee.c:816
+msgid "%B: unexpected ATN type %d in external part"
+msgstr ""
+
+#: ieee.c:838
+msgid "%B: unexpected type after ATN"
+msgstr ""
+
+#: ihex.c:230
+msgid "%B:%d: unexpected character `%s' in Intel Hex file"
+msgstr ""
+
+#: ihex.c:337
+msgid "%B:%u: bad checksum in Intel Hex file (expected %u, found %u)"
+msgstr ""
+
+#: ihex.c:392
+msgid "%B:%u: bad extended address record length in Intel Hex file"
+msgstr ""
+
+#: ihex.c:409
+msgid "%B:%u: bad extended start address length in Intel Hex file"
+msgstr ""
+
+#: ihex.c:426
+msgid "%B:%u: bad extended linear address record length in Intel Hex file"
+msgstr ""
+
+#: ihex.c:443
+msgid "%B:%u: bad extended linear start address length in Intel Hex file"
+msgstr ""
+
+#: ihex.c:460
+msgid "%B:%u: unrecognized ihex type %u in Intel Hex file"
+msgstr ""
+
+#: ihex.c:579
+msgid "%B: internal error in ihex_read_section"
+msgstr ""
+
+#: ihex.c:613
+msgid "%B: bad section length in ihex_read_section"
+msgstr ""
+
+#: ihex.c:826
+#, c-format
+msgid "%s: address 0x%s out of range for Intel Hex file"
+msgstr ""
+
+#: libbfd.c:863
+msgid "%B: unable to get decompressed section %A"
+msgstr ""
+
+#: libbfd.c:1043
+#, c-format
+msgid "Deprecated %s called at %s line %d in %s\n"
+msgstr ""
+
+#: libbfd.c:1046
+#, c-format
+msgid "Deprecated %s called\n"
+msgstr ""
+
+#: linker.c:1859
+msgid "%B: indirect symbol `%s' to `%s' is a loop"
+msgstr ""
+
+#: linker.c:2726
+#, 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"
+msgstr ""
+
+#: linker.c:3067
+msgid "%B: warning: duplicate section `%A' has different size\n"
+msgstr ""
+
+#: mach-o.c:381
+msgid "bfd_mach_o_canonicalize_symtab: unable to load symbols"
+msgstr ""
+
+#: mach-o.c:1253
+#, c-format
+msgid "unable to write unknown load command 0x%lx"
+msgstr ""
+
+#: mach-o.c:1654
+#, c-format
+msgid "bfd_mach_o_read_symtab_symbol: unable to read %d bytes at %lu"
+msgstr ""
+
+#: mach-o.c:1671
+#, c-format
+msgid "bfd_mach_o_read_symtab_symbol: symbol name out of range (%lu >= %lu)"
+msgstr ""
+
+#: mach-o.c:1756
+#, 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
+#, c-format
+msgid "bfd_mach_o_read_symtab_symbol: symbol \"%s\" is unsupported 'indirect' reference: setting to undefined"
+msgstr ""
+
+#: mach-o.c:1770
+#, 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
+msgid "bfd_mach_o_read_symtab_symbols: unable to allocate memory for symbols"
+msgstr ""
+
+#: mach-o.c:1874
+#, c-format
+msgid "bfd_mach_o_read_dysymtab_symbol: unable to read %lu bytes at %lu"
+msgstr ""
+
+#: mach-o.c:2556
+#, c-format
+msgid "unable to read unknown load command 0x%lx"
+msgstr ""
+
+#: mach-o.c:2736
+#, c-format
+msgid "bfd_mach_o_scan: unknown architecture 0x%lx/0x%lx"
+msgstr ""
+
+#: mach-o.c:2832
+#, c-format
+msgid "unknown header byte-order value 0x%lx"
+msgstr ""
+
+#: mach-o.c:3402
+msgid "Mach-O header:\n"
+msgstr ""
+
+#: mach-o.c:3403
+#, c-format
+msgid " magic     : %08lx\n"
+msgstr ""
+
+#: mach-o.c:3404
+#, c-format
+msgid " cputype   : %08lx (%s)\n"
+msgstr ""
+
+#: mach-o.c:3406
+#, c-format
+msgid " cpusubtype: %08lx\n"
+msgstr ""
+
+#: mach-o.c:3407
+#, c-format
+msgid " filetype  : %08lx (%s)\n"
+msgstr ""
+
+#: mach-o.c:3410
+#, c-format
+msgid " ncmds     : %08lx (%lu)\n"
+msgstr ""
+
+#: mach-o.c:3411
+#, c-format
+msgid " sizeofcmds: %08lx\n"
+msgstr ""
+
+#: mach-o.c:3412
+#, c-format
+msgid " flags     : %08lx ("
+msgstr ""
+
+#: mach-o.c:3414 vms-alpha.c:7671
+msgid ")\n"
+msgstr ")\n"
+
+#: mach-o.c:3415
+#, c-format
+msgid " reserved  : %08x\n"
+msgstr ""
+
+#: mach-o.c:3425
+msgid "Segments and Sections:\n"
+msgstr ""
+
+#: mach-o.c:3426
+msgid " #: Segment name     Section name     Address\n"
+msgstr ""
+
+#: merge.c:832
+#, c-format
+msgid "%s: access beyond end of merged section (%ld)"
+msgstr ""
+
+#: mmo.c:456
+#, c-format
+msgid "%s: No core to allocate section name %s\n"
+msgstr ""
+
+#: mmo.c:531
+#, c-format
+msgid "%s: No core to allocate a symbol %d bytes long\n"
+msgstr ""
+
+#: mmo.c:1187
+#, c-format
+msgid "%s: invalid mmo file: initialization value for $255 is not `Main'\n"
+msgstr ""
+
+#: mmo.c:1332
+#, c-format
+msgid "%s: unsupported wide character sequence 0x%02X 0x%02X after symbol name starting with `%s'\n"
+msgstr ""
+
+#: mmo.c:1565
+#, c-format
+msgid "%s: invalid mmo file: unsupported lopcode `%d'\n"
+msgstr ""
+
+#: mmo.c:1575
+#, c-format
+msgid "%s: invalid mmo file: expected YZ = 1 got YZ = %d for lop_quote\n"
+msgstr ""
+
+#: mmo.c:1611
+#, c-format
+msgid "%s: invalid mmo file: expected z = 1 or z = 2, got z = %d for lop_loc\n"
+msgstr ""
+
+#: mmo.c:1657
+#, c-format
+msgid "%s: invalid mmo file: expected z = 1 or z = 2, got z = %d for lop_fixo\n"
+msgstr ""
+
+#: mmo.c:1696
+#, c-format
+msgid "%s: invalid mmo file: expected y = 0, got y = %d for lop_fixrx\n"
+msgstr ""
+
+#: mmo.c:1705
+#, c-format
+msgid "%s: invalid mmo file: expected z = 16 or z = 24, got z = %d for lop_fixrx\n"
+msgstr ""
+
+#: mmo.c:1728
+#, c-format
+msgid "%s: invalid mmo file: leading byte of operand word must be 0 or 1, got %d for lop_fixrx\n"
+msgstr ""
+
+#: mmo.c:1751
+#, c-format
+msgid "%s: cannot allocate file name for file number %d, %d bytes\n"
+msgstr ""
+
+#: mmo.c:1771
+#, c-format
+msgid "%s: invalid mmo file: file number %d `%s', was already entered as `%s'\n"
+msgstr ""
+
+#: mmo.c:1784
+#, c-format
+msgid "%s: invalid mmo file: file name for number %d was not specified before use\n"
+msgstr ""
+
+#: mmo.c:1890
+#, c-format
+msgid "%s: invalid mmo file: fields y and z of lop_stab non-zero, y: %d, z: %d\n"
+msgstr ""
+
+#: mmo.c:1926
+#, c-format
+msgid "%s: invalid mmo file: lop_end not last item in file\n"
+msgstr ""
+
+#: mmo.c:1939
+#, c-format
+msgid "%s: invalid mmo file: YZ of lop_end (%ld) not equal to the number of tetras to the preceding lop_stab (%ld)\n"
+msgstr ""
+
+#: mmo.c:2649
+#, c-format
+msgid "%s: invalid symbol table: duplicate symbol `%s'\n"
+msgstr ""
+
+#: mmo.c:2889
+#, c-format
+msgid "%s: Bad symbol definition: `Main' set to %s rather than the start address %s\n"
+msgstr ""
+
+#: mmo.c:2981
+#, c-format
+msgid "%s: warning: symbol table too large for mmo, larger than 65535 32-bit words: %d.  Only `Main' will be emitted.\n"
+msgstr ""
+
+#: mmo.c:3026
+#, c-format
+msgid "%s: internal error, symbol table changed size from %d to %d words\n"
+msgstr ""
+
+#: mmo.c:3078
+#, c-format
+msgid "%s: internal error, internal register section %s had contents\n"
+msgstr ""
+
+#: mmo.c:3129
+#, c-format
+msgid "%s: no initialized registers; section length 0\n"
+msgstr ""
+
+#: mmo.c:3135
+#, c-format
+msgid "%s: too many initialized registers; section length %ld\n"
+msgstr ""
+
+#: mmo.c:3140
+#, c-format
+msgid "%s: invalid start address for initialized registers of length %ld: 0x%lx%08lx\n"
+msgstr ""
+
+#: oasys.c:882
+#, c-format
+msgid "%s: can not represent section `%s' in oasys"
+msgstr ""
+
+#: osf-core.c:140
+#, c-format
+msgid "Unhandled OSF/1 core file section type %d\n"
+msgstr ""
+
+#: pe-mips.c:607
+msgid "%B: `ld -r' not supported with PE MIPS objects\n"
+msgstr ""
+
+#. OK, at this point the following variables are set up:
+#. src = VMA of the memory we're fixing up
+#. mem = pointer to memory we're fixing up
+#. val = VMA of what we need to refer to.
+#: pe-mips.c:719
+msgid "%B: unimplemented %s\n"
+msgstr "%B: нереалізований %s\n"
+
+#: pe-mips.c:745
+msgid "%B: jump too far away\n"
+msgstr ""
+
+#: pe-mips.c:771
+msgid "%B: bad pair/reflo after refhi\n"
+msgstr ""
+
+#: pef.c:519
+#, c-format
+msgid "bfd_pef_scan: unknown architecture 0x%lx"
+msgstr ""
+
+#: pei-x86_64.c:444
+#, c-format
+msgid "warning: .pdata section size (%ld) is not a multiple of %d\n"
+msgstr "попередження: розмір розділу .pdata (%ld) не є кратним до %d\n"
+
+#: pei-x86_64.c:448 peigen.c:1618 peigen.c:1801 pepigen.c:1618 pepigen.c:1801
+#: pex64igen.c:1618 pex64igen.c:1801
+#, c-format
+msgid ""
+"\n"
+"The Function Table (interpreted .pdata section contents)\n"
+msgstr ""
+
+#: pei-x86_64.c:450
+#, c-format
+msgid "vma:\t\t\tBeginAddress\t EndAddress\t  UnwindData\n"
+msgstr ""
+
+#. XXX code yet to be written.
+#: peicode.h:751
+msgid "%B: Unhandled import type; %x"
+msgstr ""
+
+#: peicode.h:756
+msgid "%B: Unrecognised import type; %x"
+msgstr ""
+
+#: peicode.h:770
+msgid "%B: Unrecognised import name type; %x"
+msgstr ""
+
+#: peicode.h:1162
+msgid "%B: Unrecognised machine type (0x%x) in Import Library Format archive"
+msgstr ""
+
+#: peicode.h:1174
+msgid "%B: Recognised but unhandled machine type (0x%x) in Import Library Format archive"
+msgstr ""
+
+#: peicode.h:1192
+msgid "%B: size field is zero in Import Library Format header"
+msgstr ""
+
+#: peicode.h:1223
+msgid "%B: string not null terminated in ILF object file."
+msgstr ""
+
+#: ppcboot.c:414
+#, c-format
+msgid ""
+"\n"
+"ppcboot header:\n"
+msgstr ""
+"\n"
+"Заголовок ppcboot:\n"
+
+#: ppcboot.c:415
+#, c-format
+msgid "Entry offset        = 0x%.8lx (%ld)\n"
+msgstr "Відступ входу       = 0x%.8lx (%ld)\n"
+
+#: ppcboot.c:417
+#, c-format
+msgid "Length              = 0x%.8lx (%ld)\n"
+msgstr "Довжина             = 0x%.8lx (%ld)\n"
+
+#: ppcboot.c:421
+#, c-format
+msgid "Flag field          = 0x%.2x\n"
+msgstr ""
+
+#: ppcboot.c:427
+#, c-format
+msgid "Partition name      = \"%s\"\n"
+msgstr "Назва розділу       = \"%s\"\n"
+
+#: ppcboot.c:446
+#, c-format
+msgid ""
+"\n"
+"Partition[%d] start  = { 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x }\n"
+msgstr ""
+"\n"
+"Початок розділу[%d]  = { 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x }\n"
+
+#: ppcboot.c:452
+#, c-format
+msgid "Partition[%d] end    = { 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x }\n"
+msgstr "Кінець розділу[%d]   = { 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x }\n"
+
+#: ppcboot.c:458
+#, c-format
+msgid "Partition[%d] sector = 0x%.8lx (%ld)\n"
+msgstr "Сектор розділу[%d]   = 0x%.8lx (%ld)\n"
+
+#: ppcboot.c:460
+#, c-format
+msgid "Partition[%d] length = 0x%.8lx (%ld)\n"
+msgstr "Довжина розділу[%d] = 0x%.8lx (%ld)\n"
+
+#: rs6000-core.c:448
+#, c-format
+msgid "%s: warning core file truncated"
+msgstr ""
+
+#: som.c:5471
+#, c-format
+msgid ""
+"\n"
+"Exec Auxiliary Header\n"
+msgstr ""
+
+#: som.c:5776
+msgid "som_sizeof_headers unimplemented"
+msgstr "som_sizeof_headers не реалізовано"
+
+#: srec.c:261
+msgid "%B:%d: Unexpected character `%s' in S-record file\n"
+msgstr ""
+
+#: srec.c:567 srec.c:600
+msgid "%B:%d: Bad checksum in S-record file\n"
+msgstr ""
+
+#: stabs.c:279
+msgid "%B(%A+0x%lx): Stabs entry has invalid string index."
+msgstr ""
+
+#: syms.c:1079
+msgid "Unsupported .stab relocation"
+msgstr "Непідтримуване пересування .stab"
+
+#: vms-alpha.c:1299
+#, c-format
+msgid "Unknown EGSD subtype %d"
+msgstr ""
+
+#: vms-alpha.c:1330
+#, c-format
+msgid "Stack overflow (%d) in _bfd_vms_push"
+msgstr ""
+
+#: vms-alpha.c:1343
+msgid "Stack underflow in _bfd_vms_pop"
+msgstr ""
+
+#. These names have not yet been added to this switch statement.
+#: vms-alpha.c:1580
+#, c-format
+msgid "unknown ETIR command %d"
+msgstr ""
+
+#: vms-alpha.c:1767
+#, c-format
+msgid "bad section index in %s"
+msgstr "помилковий номер розділу у %s"
+
+#: vms-alpha.c:1780
+#, c-format
+msgid "unsupported STA cmd %s"
+msgstr ""
+
+#. Insert field.
+#. Unsigned shift.
+#. Rotate.
+#. Redefine symbol to current location.
+#. Define a literal.
+#: vms-alpha.c:1956 vms-alpha.c:1987 vms-alpha.c:2234
+#, c-format
+msgid "%s: not supported"
+msgstr "%s: підтримки не передбачено"
+
+#: vms-alpha.c:1962
+#, c-format
+msgid "%s: not implemented"
+msgstr "%s: не реалізовано"
+
+#: vms-alpha.c:2218
+#, c-format
+msgid "invalid use of %s with contexts"
+msgstr ""
+
+#: vms-alpha.c:2252
+#, c-format
+msgid "reserved cmd %d"
+msgstr ""
+
+#: vms-alpha.c:2337
+msgid "Object module NOT error-free !\n"
+msgstr ""
+
+#: vms-alpha.c:2766
+#, c-format
+msgid "Symbol %s replaced by %s\n"
+msgstr "Символ %s замінено на %s\n"
+
+#: vms-alpha.c:3769
+#, c-format
+msgid "SEC_RELOC with no relocs in section %s"
+msgstr ""
+
+#: vms-alpha.c:3822 vms-alpha.c:4053
+#, c-format
+msgid "Size error in section %s"
+msgstr "Помилка у розмірі у розділі %s"
+
+#: vms-alpha.c:3992
+msgid "Spurious ALPHA_R_BSR reloc"
+msgstr ""
+
+#: vms-alpha.c:4040
+#, c-format
+msgid "Unhandled relocation %s"
+msgstr ""
+
+#: vms-alpha.c:4330
+#, c-format
+msgid "unknown source command %d"
+msgstr "невідома початкова команда %d"
+
+#: vms-alpha.c:4391
+msgid "DST__K_SET_LINUM_INCR not implemented"
+msgstr "DST__K_SET_LINUM_INCR не реалізовано"
+
+#: vms-alpha.c:4397
+msgid "DST__K_SET_LINUM_INCR_W not implemented"
+msgstr "DST__K_SET_LINUM_INCR_W не реалізовано"
+
+#: vms-alpha.c:4403
+msgid "DST__K_RESET_LINUM_INCR not implemented"
+msgstr "DST__K_RESET_LINUM_INCR не реалізовано"
+
+#: vms-alpha.c:4409
+msgid "DST__K_BEG_STMT_MODE not implemented"
+msgstr "DST__K_BEG_STMT_MODE не реалізовано"
+
+#: vms-alpha.c:4415
+msgid "DST__K_END_STMT_MODE not implemented"
+msgstr "DST__K_END_STMT_MODE не реалізовано"
+
+#: vms-alpha.c:4442
+msgid "DST__K_SET_PC not implemented"
+msgstr "DST__K_SET_PC не реалізовано"
+
+#: vms-alpha.c:4448
+msgid "DST__K_SET_PC_W not implemented"
+msgstr "DST__K_SET_PC_W не реалізовано"
+
+#: vms-alpha.c:4454
+msgid "DST__K_SET_PC_L not implemented"
+msgstr "DST__K_SET_PC_L не реалізовано"
+
+#: vms-alpha.c:4460
+msgid "DST__K_SET_STMTNUM not implemented"
+msgstr "DST__K_SET_STMTNUM не реалізовано"
+
+#: vms-alpha.c:4503
+#, c-format
+msgid "unknown line command %d"
+msgstr "невідома рядкова команда %d"
+
+#: 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
+#, c-format
+msgid "Unknown reloc %s + %s"
+msgstr ""
+
+#: vms-alpha.c:5093
+#, c-format
+msgid "Unknown reloc %s"
+msgstr ""
+
+#: vms-alpha.c:5106
+msgid "Invalid section index in ETIR"
+msgstr ""
+
+#: vms-alpha.c:5153
+#, c-format
+msgid "Unknown symbol in command %s"
+msgstr ""
+
+#: vms-alpha.c:5668
+#, c-format
+msgid "  EMH %u (len=%u): "
+msgstr ""
+
+#: vms-alpha.c:5677
+#, c-format
+msgid "Module header\n"
+msgstr ""
+
+#: vms-alpha.c:5678
+#, c-format
+msgid "   structure level: %u\n"
+msgstr ""
+
+#: vms-alpha.c:5679
+#, c-format
+msgid "   max record size: %u\n"
+msgstr ""
+
+#: vms-alpha.c:5682
+#, c-format
+msgid "   module name    : %.*s\n"
+msgstr "   назва модуля   : %.*s\n"
+
+#: vms-alpha.c:5684
+#, c-format
+msgid "   module version : %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:5686
+#, c-format
+msgid "   compile date   : %.17s\n"
+msgstr ""
+
+#: vms-alpha.c:5691
+#, c-format
+msgid "Language Processor Name\n"
+msgstr ""
+
+#: vms-alpha.c:5692
+#, c-format
+msgid "   language name: %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:5699
+#, c-format
+msgid "Source Files Header\n"
+msgstr ""
+
+#: vms-alpha.c:5700
+#, c-format
+msgid "   file: %.*s\n"
+msgstr "   файл: %.*s\n"
+
+#: vms-alpha.c:5707
+#, c-format
+msgid "Title Text Header\n"
+msgstr ""
+
+#: vms-alpha.c:5708
+#, c-format
+msgid "   title: %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:5715
+#, c-format
+msgid "Copyright Header\n"
+msgstr ""
+
+#: vms-alpha.c:5716
+#, c-format
+msgid "   copyright: %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:5722
+#, c-format
+msgid "unhandled emh subtype %u\n"
+msgstr ""
+
+#: vms-alpha.c:5732
+#, c-format
+msgid "  EEOM (len=%u):\n"
+msgstr ""
+
+#: vms-alpha.c:5733
+#, c-format
+msgid "   number of cond linkage pairs: %u\n"
+msgstr ""
+
+#: vms-alpha.c:5735
+#, c-format
+msgid "   completion code: %u\n"
+msgstr ""
+
+#: vms-alpha.c:5739
+#, c-format
+msgid "   transfer addr flags: 0x%02x\n"
+msgstr ""
+
+#: vms-alpha.c:5740
+#, c-format
+msgid "   transfer addr psect: %u\n"
+msgstr ""
+
+#: vms-alpha.c:5742
+#, c-format
+msgid "   transfer address   : 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:5751
+msgid " WEAK"
+msgstr " WEAK"
+
+#: vms-alpha.c:5753
+msgid " DEF"
+msgstr " DEF"
+
+#: vms-alpha.c:5755
+msgid " UNI"
+msgstr " UNI"
+
+#: vms-alpha.c:5757 vms-alpha.c:5778
+msgid " REL"
+msgstr ""
+
+#: vms-alpha.c:5759
+msgid " COMM"
+msgstr " COMM"
+
+#: vms-alpha.c:5761
+msgid " VECEP"
+msgstr ""
+
+#: vms-alpha.c:5763
+msgid " NORM"
+msgstr " NORM"
+
+#: vms-alpha.c:5765
+msgid " QVAL"
+msgstr ""
+
+#: vms-alpha.c:5772
+msgid " PIC"
+msgstr " PIC"
+
+#: vms-alpha.c:5774
+msgid " LIB"
+msgstr " LIB"
+
+#: vms-alpha.c:5776
+msgid " OVR"
+msgstr " OVR"
+
+#: vms-alpha.c:5780
+msgid " GBL"
+msgstr ""
+
+#: vms-alpha.c:5782
+msgid " SHR"
+msgstr " SHR"
+
+#: vms-alpha.c:5784
+msgid " EXE"
+msgstr ""
+
+#: vms-alpha.c:5786
+msgid " RD"
+msgstr " RD"
+
+#: vms-alpha.c:5788
+msgid " WRT"
+msgstr ""
+
+#: vms-alpha.c:5790
+msgid " VEC"
+msgstr " VEC"
+
+#: vms-alpha.c:5792
+msgid " NOMOD"
+msgstr ""
+
+#: vms-alpha.c:5794
+msgid " COM"
+msgstr " COM"
+
+#: vms-alpha.c:5796
+msgid " 64B"
+msgstr " 64B"
+
+#: vms-alpha.c:5805
+#, c-format
+msgid "  EGSD (len=%u):\n"
+msgstr ""
+
+#: vms-alpha.c:5817
+#, c-format
+msgid "  EGSD entry %2u (type: %u, len: %u): "
+msgstr ""
+
+#: vms-alpha.c:5829
+#, c-format
+msgid "PSC - Program section definition\n"
+msgstr ""
+
+#: vms-alpha.c:5830 vms-alpha.c:5847
+#, c-format
+msgid "   alignment  : 2**%u\n"
+msgstr ""
+
+#: vms-alpha.c:5831 vms-alpha.c:5848
+#, c-format
+msgid "   flags      : 0x%04x"
+msgstr ""
+
+#: vms-alpha.c:5835
+#, c-format
+msgid "   alloc (len): %u (0x%08x)\n"
+msgstr ""
+
+#: vms-alpha.c:5836 vms-alpha.c:5893 vms-alpha.c:5942
+#, c-format
+msgid "   name       : %.*s\n"
+msgstr "   назва      : %.*s\n"
+
+#: vms-alpha.c:5846
+#, c-format
+msgid "SPSC - Shared Image Program section def\n"
+msgstr ""
+
+#: vms-alpha.c:5852
+#, c-format
+msgid "   alloc (len)   : %u (0x%08x)\n"
+msgstr ""
+
+#: vms-alpha.c:5853
+#, c-format
+msgid "   image offset  : 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:5855
+#, c-format
+msgid "   symvec offset : 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:5857
+#, c-format
+msgid "   name          : %.*s\n"
+msgstr "   назва         : %.*s\n"
+
+#: vms-alpha.c:5870
+#, 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
+#, c-format
+msgid "   flags: 0x%04x"
+msgstr ""
+
+#: vms-alpha.c:5874
+#, c-format
+msgid "   psect offset: 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:5878
+#, c-format
+msgid "   code address: 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:5880
+#, c-format
+msgid "   psect index for entry point : %u\n"
+msgstr ""
+
+#: vms-alpha.c:5883 vms-alpha.c:5959 vms-alpha.c:5978
+#, c-format
+msgid "   psect index : %u\n"
+msgstr "   індекс psect: %u\n"
+
+#: vms-alpha.c:5885 vms-alpha.c:5961 vms-alpha.c:5980
+#, c-format
+msgid "   name        : %.*s\n"
+msgstr "   назва       : %.*s\n"
+
+#: vms-alpha.c:5892
+#, c-format
+msgid "SYM - Global symbol reference\n"
+msgstr ""
+
+#: vms-alpha.c:5904
+#, c-format
+msgid "IDC - Ident Consistency check\n"
+msgstr ""
+
+#: vms-alpha.c:5905
+#, c-format
+msgid "   flags         : 0x%08x"
+msgstr ""
+
+#: vms-alpha.c:5909
+#, c-format
+msgid "   id match      : %x\n"
+msgstr ""
+
+#: vms-alpha.c:5911
+#, c-format
+msgid "   error severity: %x\n"
+msgstr ""
+
+#: vms-alpha.c:5914
+#, c-format
+msgid "   entity name   : %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:5916
+#, c-format
+msgid "   object name   : %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:5919
+#, c-format
+msgid "   binary ident  : 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:5922
+#, c-format
+msgid "   ascii ident   : %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:5930
+#, c-format
+msgid "SYMG - Universal symbol definition\n"
+msgstr ""
+
+#: vms-alpha.c:5934
+#, c-format
+msgid "   symbol vector offset: 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:5936
+#, c-format
+msgid "   entry point: 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:5938
+#, c-format
+msgid "   proc descr : 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:5940
+#, c-format
+msgid "   psect index: %u\n"
+msgstr "   індекс psect: %u\n"
+
+#: vms-alpha.c:5951
+#, c-format
+msgid "SYMV - Vectored symbol definition\n"
+msgstr ""
+
+#: vms-alpha.c:5955
+#, c-format
+msgid "   vector      : 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:5957 vms-alpha.c:5976
+#, c-format
+msgid "   psect offset: %u\n"
+msgstr ""
+
+#: vms-alpha.c:5970
+#, c-format
+msgid "SYMM - Global symbol definition with version\n"
+msgstr ""
+
+#: vms-alpha.c:5974
+#, c-format
+msgid "   version mask: 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:5985
+#, c-format
+msgid "unhandled egsd entry type %u\n"
+msgstr ""
+
+#: vms-alpha.c:6019
+#, c-format
+msgid "    linkage index: %u, replacement insn: 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:6022
+#, c-format
+msgid "    psect idx 1: %u, offset 1: 0x%08x %08x\n"
+msgstr ""
+
+#: vms-alpha.c:6026
+#, c-format
+msgid "    psect idx 2: %u, offset 2: 0x%08x %08x\n"
+msgstr ""
+
+#: vms-alpha.c:6031
+#, c-format
+msgid "    psect idx 3: %u, offset 3: 0x%08x %08x\n"
+msgstr ""
+
+#: vms-alpha.c:6036
+#, c-format
+msgid "    global name: %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:6046
+#, c-format
+msgid "  %s (len=%u+%u):\n"
+msgstr ""
+
+#: vms-alpha.c:6061
+#, c-format
+msgid "   (type: %3u, size: 4+%3u): "
+msgstr ""
+
+#: vms-alpha.c:6065
+#, c-format
+msgid "STA_GBL (stack global) %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:6069
+#, c-format
+msgid "STA_LW (stack longword) 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:6073
+#, c-format
+msgid "STA_QW (stack quadword) 0x%08x %08x\n"
+msgstr ""
+
+#: vms-alpha.c:6078
+#, c-format
+msgid "STA_PQ (stack psect base + offset)\n"
+msgstr ""
+
+#: vms-alpha.c:6079
+#, c-format
+msgid "    psect: %u, offset: 0x%08x %08x\n"
+msgstr ""
+
+#: vms-alpha.c:6085
+#, c-format
+msgid "STA_LI (stack literal)\n"
+msgstr ""
+
+#: vms-alpha.c:6088
+#, c-format
+msgid "STA_MOD (stack module)\n"
+msgstr ""
+
+#: vms-alpha.c:6091
+#, c-format
+msgid "STA_CKARG (compare procedure argument)\n"
+msgstr ""
+
+#: vms-alpha.c:6095
+#, c-format
+msgid "STO_B (store byte)\n"
+msgstr ""
+
+#: vms-alpha.c:6098
+#, c-format
+msgid "STO_W (store word)\n"
+msgstr ""
+
+#: vms-alpha.c:6101
+#, c-format
+msgid "STO_LW (store longword)\n"
+msgstr ""
+
+#: vms-alpha.c:6104
+#, c-format
+msgid "STO_QW (store quadword)\n"
+msgstr ""
+
+#: vms-alpha.c:6110
+#, c-format
+msgid "STO_IMMR (store immediate repeat) %u bytes\n"
+msgstr ""
+
+#: vms-alpha.c:6117
+#, c-format
+msgid "STO_GBL (store global) %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:6121
+#, c-format
+msgid "STO_CA (store code address) %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:6125
+#, c-format
+msgid "STO_RB (store relative branch)\n"
+msgstr ""
+
+#: vms-alpha.c:6128
+#, c-format
+msgid "STO_AB (store absolute branch)\n"
+msgstr ""
+
+#: vms-alpha.c:6131
+#, c-format
+msgid "STO_OFF (store offset to psect)\n"
+msgstr ""
+
+#: vms-alpha.c:6137
+#, c-format
+msgid "STO_IMM (store immediate) %u bytes\n"
+msgstr ""
+
+#: vms-alpha.c:6144
+#, c-format
+msgid "STO_GBL_LW (store global longword) %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:6148
+#, c-format
+msgid "STO_OFF (store LP with procedure signature)\n"
+msgstr ""
+
+#: vms-alpha.c:6151
+#, c-format
+msgid "STO_BR_GBL (store branch global) *todo*\n"
+msgstr ""
+
+#: vms-alpha.c:6154
+#, c-format
+msgid "STO_BR_PS (store branch psect + offset) *todo*\n"
+msgstr ""
+
+#: vms-alpha.c:6158
+#, c-format
+msgid "OPR_NOP (no-operation)\n"
+msgstr ""
+
+#: vms-alpha.c:6161
+#, c-format
+msgid "OPR_ADD (add)\n"
+msgstr ""
+
+#: vms-alpha.c:6164
+#, c-format
+msgid "OPR_SUB (substract)\n"
+msgstr ""
+
+#: vms-alpha.c:6167
+#, c-format
+msgid "OPR_MUL (multiply)\n"
+msgstr ""
+
+#: vms-alpha.c:6170
+#, c-format
+msgid "OPR_DIV (divide)\n"
+msgstr ""
+
+#: vms-alpha.c:6173
+#, c-format
+msgid "OPR_AND (logical and)\n"
+msgstr ""
+
+#: vms-alpha.c:6176
+#, c-format
+msgid "OPR_IOR (logical inclusive or)\n"
+msgstr ""
+
+#: vms-alpha.c:6179
+#, c-format
+msgid "OPR_EOR (logical exclusive or)\n"
+msgstr ""
+
+#: vms-alpha.c:6182
+#, c-format
+msgid "OPR_NEG (negate)\n"
+msgstr ""
+
+#: vms-alpha.c:6185
+#, c-format
+msgid "OPR_COM (complement)\n"
+msgstr ""
+
+#: vms-alpha.c:6188
+#, c-format
+msgid "OPR_INSV (insert field)\n"
+msgstr ""
+
+#: vms-alpha.c:6191
+#, c-format
+msgid "OPR_ASH (arithmetic shift)\n"
+msgstr ""
+
+#: vms-alpha.c:6194
+#, c-format
+msgid "OPR_USH (unsigned shift)\n"
+msgstr ""
+
+#: vms-alpha.c:6197
+#, c-format
+msgid "OPR_ROT (rotate)\n"
+msgstr ""
+
+#: vms-alpha.c:6200
+#, c-format
+msgid "OPR_SEL (select)\n"
+msgstr ""
+
+#: vms-alpha.c:6203
+#, c-format
+msgid "OPR_REDEF (redefine symbol to curr location)\n"
+msgstr ""
+
+#: vms-alpha.c:6206
+#, c-format
+msgid "OPR_REDEF (define a literal)\n"
+msgstr ""
+
+#: vms-alpha.c:6210
+#, c-format
+msgid "STC_LP (store cond linkage pair)\n"
+msgstr ""
+
+#: vms-alpha.c:6214
+#, c-format
+msgid "STC_LP_PSB (store cond linkage pair + signature)\n"
+msgstr ""
+
+#: vms-alpha.c:6215
+#, c-format
+msgid "   linkage index: %u, procedure: %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:6218
+#, c-format
+msgid "   signature: %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:6221
+#, c-format
+msgid "STC_GBL (store cond global)\n"
+msgstr ""
+
+#: vms-alpha.c:6222
+#, c-format
+msgid "   linkage index: %u, global: %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:6226
+#, c-format
+msgid "STC_GCA (store cond code address)\n"
+msgstr ""
+
+#: vms-alpha.c:6227
+#, c-format
+msgid "   linkage index: %u, procedure name: %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:6231
+#, c-format
+msgid "STC_PS (store cond psect + offset)\n"
+msgstr ""
+
+#: vms-alpha.c:6233
+#, c-format
+msgid "   linkage index: %u, psect: %u, offset: 0x%08x %08x\n"
+msgstr ""
+
+#: vms-alpha.c:6240
+#, c-format
+msgid "STC_NOP_GBL (store cond NOP at global addr)\n"
+msgstr ""
+
+#: vms-alpha.c:6244
+#, c-format
+msgid "STC_NOP_PS (store cond NOP at psect + offset)\n"
+msgstr ""
+
+#: vms-alpha.c:6248
+#, c-format
+msgid "STC_BSR_GBL (store cond BSR at global addr)\n"
+msgstr ""
+
+#: vms-alpha.c:6252
+#, c-format
+msgid "STC_BSR_PS (store cond BSR at psect + offset)\n"
+msgstr ""
+
+#: vms-alpha.c:6256
+#, c-format
+msgid "STC_LDA_GBL (store cond LDA at global addr)\n"
+msgstr ""
+
+#: vms-alpha.c:6260
+#, c-format
+msgid "STC_LDA_PS (store cond LDA at psect + offset)\n"
+msgstr ""
+
+#: vms-alpha.c:6264
+#, c-format
+msgid "STC_BOH_GBL (store cond BOH at global addr)\n"
+msgstr ""
+
+#: vms-alpha.c:6268
+#, c-format
+msgid "STC_BOH_PS (store cond BOH at psect + offset)\n"
+msgstr ""
+
+#: vms-alpha.c:6273
+#, c-format
+msgid "STC_NBH_GBL (store cond or hint at global addr)\n"
+msgstr ""
+
+#: vms-alpha.c:6277
+#, c-format
+msgid "STC_NBH_PS (store cond or hint at psect + offset)\n"
+msgstr ""
+
+#: vms-alpha.c:6281
+#, c-format
+msgid "CTL_SETRB (set relocation base)\n"
+msgstr ""
+
+#: vms-alpha.c:6287
+#, c-format
+msgid "CTL_AUGRB (augment relocation base) %u\n"
+msgstr ""
+
+#: vms-alpha.c:6291
+#, c-format
+msgid "CTL_DFLOC (define location)\n"
+msgstr "CTL_DFLOC (визначити розташування)\n"
+
+#: vms-alpha.c:6294
+#, c-format
+msgid "CTL_STLOC (set location)\n"
+msgstr "CTL_STLOC (вказати розташування)\n"
+
+#: vms-alpha.c:6297
+#, c-format
+msgid "CTL_STKDL (stack defined location)\n"
+msgstr "CTL_STKDL (розташування, визначене стеком)\n"
+
+#: vms-alpha.c:6300 vms-alpha.c:6714
+#, c-format
+msgid "*unhandled*\n"
+msgstr "*не оброблено*\n"
+
+#: vms-alpha.c:6330 vms-alpha.c:6369
+#, c-format
+msgid "cannot read GST record length\n"
+msgstr "не вдалося прочитати довжину запису GST\n"
+
+#. Ill-formed.
+#: vms-alpha.c:6351
+#, c-format
+msgid "cannot find EMH in first GST record\n"
+msgstr ""
+
+#: vms-alpha.c:6377
+#, c-format
+msgid "cannot read GST record header\n"
+msgstr "не вдалося прочитати заголовок запису GST\n"
+
+#: vms-alpha.c:6390
+#, c-format
+msgid " corrupted GST\n"
+msgstr " пошкоджений GST\n"
+
+#: vms-alpha.c:6398
+#, c-format
+msgid "cannot read GST record\n"
+msgstr "не вдалося прочитати запис GST\n"
+
+#: vms-alpha.c:6427
+#, c-format
+msgid " unhandled EOBJ record type %u\n"
+msgstr ""
+
+#: vms-alpha.c:6450
+#, c-format
+msgid "  bitcount: %u, base addr: 0x%08x\n"
+msgstr "  кількість бітів: %u, базова адреса: 0x%08x\n"
+
+#: vms-alpha.c:6463
+#, c-format
+msgid "   bitmap: 0x%08x (count: %u):\n"
+msgstr ""
+
+#: vms-alpha.c:6470
+#, c-format
+msgid " %08x"
+msgstr " %08x"
+
+#: vms-alpha.c:6495
+#, c-format
+msgid "  image %u (%u entries)\n"
+msgstr "  образ %u (%u записів)\n"
+
+#: vms-alpha.c:6500
+#, c-format
+msgid "   offset: 0x%08x, val: 0x%08x\n"
+msgstr "   відступ: 0x%08x, значення: 0x%08x\n"
+
+#: vms-alpha.c:6521
+#, c-format
+msgid "  image %u (%u entries), offsets:\n"
+msgstr ""
+
+#: vms-alpha.c:6528
+#, c-format
+msgid " 0x%08x"
+msgstr " 0x%08x"
+
+#. 64 bits.
+#: vms-alpha.c:6650
+#, c-format
+msgid "64 bits *unhandled*\n"
+msgstr ""
+
+#: vms-alpha.c:6654
+#, c-format
+msgid "class: %u, dtype: %u, length: %u, pointer: 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:6665
+#, c-format
+msgid "non-contiguous array of %s\n"
+msgstr "розривний масив %s\n"
+
+#: vms-alpha.c:6669
+#, c-format
+msgid "dimct: %u, aflags: 0x%02x, digits: %u, scale: %u\n"
+msgstr ""
+
+#: vms-alpha.c:6673
+#, c-format
+msgid "arsize: %u, a0: 0x%08x\n"
+msgstr "arsize: %u, a0: 0x%08x\n"
+
+#: vms-alpha.c:6677
+#, c-format
+msgid "Strides:\n"
+msgstr "Кроки:\n"
+
+#: vms-alpha.c:6682
+#, c-format
+msgid "[%u]: %u\n"
+msgstr "[%u]: %u\n"
+
+#: vms-alpha.c:6687
+#, c-format
+msgid "Bounds:\n"
+msgstr "Межі:\n"
+
+#: vms-alpha.c:6692
+#, c-format
+msgid "[%u]: Lower: %u, upper: %u\n"
+msgstr "[%u]: нижня: %u, верхня: %u\n"
+
+#: vms-alpha.c:6704
+#, c-format
+msgid "unaligned bit-string of %s\n"
+msgstr "невирівняний бітовий рядок %s\n"
+
+#: vms-alpha.c:6708
+#, c-format
+msgid "base: %u, pos: %u\n"
+msgstr "основа: %u, позиція: %u\n"
+
+#: vms-alpha.c:6728
+#, c-format
+msgid "vflags: 0x%02x, value: 0x%08x "
+msgstr "vflags: 0x%02x, значення: 0x%08x "
+
+#: vms-alpha.c:6734
+#, c-format
+msgid "(no value)\n"
+msgstr "(нема значення)\n"
+
+#: vms-alpha.c:6737
+#, c-format
+msgid "(not active)\n"
+msgstr "(неактивне)\n"
+
+#: vms-alpha.c:6740
+#, c-format
+msgid "(not allocated)\n"
+msgstr "(не розміщено)\n"
+
+#: vms-alpha.c:6743
+#, c-format
+msgid "(descriptor)\n"
+msgstr "(дескриптор)\n"
+
+#: vms-alpha.c:6747
+#, c-format
+msgid "(trailing value)\n"
+msgstr ""
+
+#: vms-alpha.c:6750
+#, c-format
+msgid "(value spec follows)\n"
+msgstr ""
+
+#: vms-alpha.c:6753
+#, c-format
+msgid "(at bit offset %u)\n"
+msgstr ""
+
+#: vms-alpha.c:6756
+#, c-format
+msgid "(reg: %u, disp: %u, indir: %u, kind: "
+msgstr ""
+
+#: vms-alpha.c:6763
+msgid "literal"
+msgstr "літерал"
+
+#: vms-alpha.c:6766
+msgid "address"
+msgstr "адреса"
+
+#: vms-alpha.c:6769
+msgid "desc"
+msgstr "деск"
+
+#: vms-alpha.c:6772
+msgid "reg"
+msgstr "рег"
+
+#: vms-alpha.c:6847
+#, c-format
+msgid "Debug symbol table:\n"
+msgstr "Таблиця символів зневаджування:\n"
+
+#: vms-alpha.c:6858
+#, c-format
+msgid "cannot read DST header\n"
+msgstr "не вдалося прочитати заголовок DST\n"
+
+#: vms-alpha.c:6863
+#, c-format
+msgid " type: %3u, len: %3u (at 0x%08x): "
+msgstr " тип: %3u, довжина: %3u (за 0x%08x): "
+
+#: vms-alpha.c:6877
+#, c-format
+msgid "cannot read DST symbol\n"
+msgstr "не вдалося прочитати символ DST\n"
+
+#: vms-alpha.c:6920
+#, c-format
+msgid "standard data: %s\n"
+msgstr "стандартні дані: %s\n"
+
+#: vms-alpha.c:6923 vms-alpha.c:7007
+#, c-format
+msgid "    name: %.*s\n"
+msgstr "    назва: %.*s\n"
+
+#: vms-alpha.c:6930
+#, c-format
+msgid "modbeg\n"
+msgstr "modbeg\n"
+
+#: vms-alpha.c:6931
+#, c-format
+msgid "   flags: %d, language: %u, major: %u, minor: %u\n"
+msgstr "   прапорці: %d, мова: %u, старший: %u, молодший: %u\n"
+
+#: vms-alpha.c:6937 vms-alpha.c:7203
+#, c-format
+msgid "   module name: %.*s\n"
+msgstr "   назва модуля: %.*s\n"
+
+#: vms-alpha.c:6940
+#, c-format
+msgid "   compiler   : %.*s\n"
+msgstr "   компілятор : %.*s\n"
+
+#: vms-alpha.c:6945
+#, c-format
+msgid "modend\n"
+msgstr "modend\n"
+
+#: vms-alpha.c:6952
+msgid "rtnbeg\n"
+msgstr "rtnbeg\n"
+
+#: vms-alpha.c:6953
+#, c-format
+msgid "    flags: %u, address: 0x%08x, pd-address: 0x%08x\n"
+msgstr "    прапорці: %u, адреса: 0x%08x, pd-адреса: 0x%08x\n"
+
+#: vms-alpha.c:6958
+#, c-format
+msgid "    routine name: %.*s\n"
+msgstr "    назва процедури: %.*s\n"
+
+#: vms-alpha.c:6966
+#, c-format
+msgid "rtnend: size 0x%08x\n"
+msgstr "rtnend: розмір 0x%08x\n"
+
+#: vms-alpha.c:6974
+#, c-format
+msgid "prolog: bkpt address 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:6982
+#, c-format
+msgid "epilog: flags: %u, count: %u\n"
+msgstr ""
+
+#: vms-alpha.c:6991
+#, c-format
+msgid "blkbeg: address: 0x%08x, name: %.*s\n"
+msgstr "blkbeg: адреса: 0x%08x, назва: %.*s\n"
+
+#: vms-alpha.c:7000
+#, c-format
+msgid "blkend: size: 0x%08x\n"
+msgstr "blkend: розмір: 0x%08x\n"
+
+#: vms-alpha.c:7006
+#, c-format
+msgid "typspec (len: %u)\n"
+msgstr ""
+
+#: vms-alpha.c:7013
+#, c-format
+msgid "septyp, name: %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:7022
+#, c-format
+msgid "recbeg: name: %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:7029
+#, c-format
+msgid "recend\n"
+msgstr "recend\n"
+
+#: vms-alpha.c:7032
+#, c-format
+msgid "enumbeg, len: %u, name: %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:7036
+#, c-format
+msgid "enumelt, name: %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:7040
+#, c-format
+msgid "enumend\n"
+msgstr ""
+
+#: vms-alpha.c:7057
+#, c-format
+msgid "discontiguous range (nbr: %u)\n"
+msgstr "розривний діапазон (nbr: %u)\n"
+
+#: vms-alpha.c:7059
+#, c-format
+msgid "    address: 0x%08x, size: %u\n"
+msgstr "    адреса: 0x%08x, розмір: %u\n"
+
+#: vms-alpha.c:7069
+#, c-format
+msgid "line num  (len: %u)\n"
+msgstr ""
+
+#: vms-alpha.c:7086
+#, c-format
+msgid "delta_pc_w %u\n"
+msgstr "delta_pc_w %u\n"
+
+#: vms-alpha.c:7093
+#, c-format
+msgid "incr_linum(b): +%u\n"
+msgstr "incr_linum(b): +%u\n"
+
+#: vms-alpha.c:7099
+#, c-format
+msgid "incr_linum_w: +%u\n"
+msgstr "incr_linum_w: +%u\n"
+
+#: vms-alpha.c:7105
+#, c-format
+msgid "incr_linum_l: +%u\n"
+msgstr "incr_linum_l: +%u\n"
+
+#: vms-alpha.c:7111
+#, c-format
+msgid "set_line_num(w) %u\n"
+msgstr "set_line_num(w) %u\n"
+
+#: vms-alpha.c:7116
+#, c-format
+msgid "set_line_num_b %u\n"
+msgstr "set_line_num_b %u\n"
+
+#: vms-alpha.c:7121
+#, c-format
+msgid "set_line_num_l %u\n"
+msgstr "set_line_num_l %u\n"
+
+#: vms-alpha.c:7126
+#, c-format
+msgid "set_abs_pc: 0x%08x\n"
+msgstr "set_abs_pc: 0x%08x\n"
+
+#: vms-alpha.c:7130
+#, c-format
+msgid "delta_pc_l: +0x%08x\n"
+msgstr "delta_pc_l: +0x%08x\n"
+
+#: vms-alpha.c:7135
+#, c-format
+msgid "term(b): 0x%02x"
+msgstr ""
+
+#: vms-alpha.c:7137
+#, c-format
+msgid "        pc: 0x%08x\n"
+msgstr "        pc: 0x%08x\n"
+
+#: vms-alpha.c:7142
+#, c-format
+msgid "term_w: 0x%04x"
+msgstr "term_w: 0x%04x"
+
+#: vms-alpha.c:7144
+#, c-format
+msgid "    pc: 0x%08x\n"
+msgstr "    pc: 0x%08x\n"
+
+#: vms-alpha.c:7150
+#, c-format
+msgid "delta pc +%-4d"
+msgstr ""
+
+#: vms-alpha.c:7153
+#, c-format
+msgid "    pc: 0x%08x line: %5u\n"
+msgstr ""
+
+#: vms-alpha.c:7158
+#, c-format
+msgid "    *unhandled* cmd %u\n"
+msgstr ""
+
+#: vms-alpha.c:7173
+#, c-format
+msgid "source (len: %u)\n"
+msgstr "джерело (довжина: %u)\n"
+
+#: vms-alpha.c:7187
+#, c-format
+msgid "   declfile: len: %u, flags: %u, fileid: %u\n"
+msgstr ""
+
+#: vms-alpha.c:7191
+#, c-format
+msgid "   rms: cdt: 0x%08x %08x, ebk: 0x%08x, ffb: 0x%04x, rfo: %u\n"
+msgstr ""
+
+#: vms-alpha.c:7200
+#, c-format
+msgid "   filename   : %.*s\n"
+msgstr "   назва файла: %.*s\n"
+
+#: vms-alpha.c:7209
+#, c-format
+msgid "   setfile %u\n"
+msgstr ""
+
+#: vms-alpha.c:7214 vms-alpha.c:7219
+#, c-format
+msgid "   setrec %u\n"
+msgstr ""
+
+#: vms-alpha.c:7224 vms-alpha.c:7229
+#, c-format
+msgid "   setlnum %u\n"
+msgstr ""
+
+#: vms-alpha.c:7234 vms-alpha.c:7239
+#, c-format
+msgid "   deflines %u\n"
+msgstr ""
+
+#: vms-alpha.c:7243
+#, c-format
+msgid "   formfeed\n"
+msgstr ""
+
+#: vms-alpha.c:7247
+#, c-format
+msgid "   *unhandled* cmd %u\n"
+msgstr ""
+
+#: vms-alpha.c:7259
+#, c-format
+msgid "*unhandled* dst type %u\n"
+msgstr ""
+
+#: vms-alpha.c:7291
+#, c-format
+msgid "cannot read EIHD\n"
+msgstr "не вдалося прочитати EIHD\n"
+
+#: vms-alpha.c:7294
+#, c-format
+msgid "EIHD: (size: %u, nbr blocks: %u)\n"
+msgstr ""
+
+#: vms-alpha.c:7297
+#, c-format
+msgid " majorid: %u, minorid: %u\n"
+msgstr ""
+
+#: vms-alpha.c:7305
+msgid "executable"
+msgstr "виконуваний"
+
+#: vms-alpha.c:7308
+msgid "linkable image"
+msgstr "компонований образ"
+
+#: vms-alpha.c:7314
+#, c-format
+msgid " image type: %u (%s)"
+msgstr " тип образу: %u (%s)"
+
+#: vms-alpha.c:7320
+msgid "native"
+msgstr "стандартний"
+
+#: vms-alpha.c:7323
+msgid "CLI"
+msgstr "CLI"
+
+#: vms-alpha.c:7329
+#, c-format
+msgid ", subtype: %u (%s)\n"
+msgstr ", підтип: %u (%s)\n"
+
+#: vms-alpha.c:7335
+#, c-format
+msgid " offsets: isd: %u, activ: %u, symdbg: %u, imgid: %u, patch: %u\n"
+msgstr ""
+
+#: vms-alpha.c:7339
+#, c-format
+msgid " fixup info rva: "
+msgstr ""
+
+#: vms-alpha.c:7341
+#, c-format
+msgid ", symbol vector rva: "
+msgstr ""
+
+#: vms-alpha.c:7344
+#, c-format
+msgid ""
+"\n"
+" version array off: %u\n"
+msgstr ""
+
+#: vms-alpha.c:7348
+#, c-format
+msgid " img I/O count: %u, nbr channels: %u, req pri: %08x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:7354
+#, c-format
+msgid " linker flags: %08x:"
+msgstr " прапорці компонувальника: %08x:"
+
+#: vms-alpha.c:7384
+#, c-format
+msgid " ident: 0x%08x, sysver: 0x%08x, match ctrl: %u, symvect_size: %u\n"
+msgstr ""
+
+#: vms-alpha.c:7390
+#, c-format
+msgid " BPAGE: %u"
+msgstr ""
+
+#: vms-alpha.c:7396
+#, c-format
+msgid ", ext fixup offset: %u, no_opt psect off: %u"
+msgstr ""
+
+#: vms-alpha.c:7399
+#, c-format
+msgid ", alias: %u\n"
+msgstr ", псевдонім: %u\n"
+
+#: vms-alpha.c:7407
+#, c-format
+msgid "system version array information:\n"
+msgstr "масив даних щодо версії системи:\n"
+
+#: vms-alpha.c:7411
+#, c-format
+msgid "cannot read EIHVN header\n"
+msgstr "не вдалося прочитати заголовок EIHVN\n"
+
+#: vms-alpha.c:7421
+#, c-format
+msgid "cannot read EIHVN version\n"
+msgstr "не вдалося прочитати версію EIHVN\n"
+
+#: vms-alpha.c:7424
+#, c-format
+msgid "   %02u "
+msgstr "   %02u "
+
+#: vms-alpha.c:7428
+msgid "BASE_IMAGE       "
+msgstr ""
+
+#: vms-alpha.c:7431
+msgid "MEMORY_MANAGEMENT"
+msgstr ""
+
+#: vms-alpha.c:7434
+msgid "IO               "
+msgstr "IO               "
+
+#: vms-alpha.c:7437
+msgid "FILES_VOLUMES    "
+msgstr ""
+
+#: vms-alpha.c:7440
+msgid "PROCESS_SCHED    "
+msgstr ""
+
+#: vms-alpha.c:7443
+msgid "SYSGEN           "
+msgstr ""
+
+#: vms-alpha.c:7446
+msgid "CLUSTERS_LOCKMGR "
+msgstr ""
+
+#: vms-alpha.c:7449
+msgid "LOGICAL_NAMES    "
+msgstr "LOGICAL_NAMES    "
+
+#: vms-alpha.c:7452
+msgid "SECURITY         "
+msgstr "SECURITY         "
+
+#: vms-alpha.c:7455
+msgid "IMAGE_ACTIVATOR  "
+msgstr "IMAGE_ACTIVATOR  "
+
+#: vms-alpha.c:7458
+msgid "NETWORKS         "
+msgstr "NETWORKS         "
+
+#: vms-alpha.c:7461
+msgid "COUNTERS         "
+msgstr "COUNTERS         "
+
+#: vms-alpha.c:7464
+msgid "STABLE           "
+msgstr "STABLE           "
+
+#: vms-alpha.c:7467
+msgid "MISC             "
+msgstr "MISC             "
+
+#: vms-alpha.c:7470
+msgid "CPU              "
+msgstr "CPU              "
+
+#: vms-alpha.c:7473
+msgid "VOLATILE         "
+msgstr "VOLATILE         "
+
+#: vms-alpha.c:7476
+msgid "SHELL            "
+msgstr "SHELL            "
+
+#: vms-alpha.c:7479
+msgid "POSIX            "
+msgstr "POSIX            "
+
+#: vms-alpha.c:7482
+msgid "MULTI_PROCESSING "
+msgstr "MULTI_PROCESSING "
+
+#: vms-alpha.c:7485
+msgid "GALAXY           "
+msgstr "GALAXY           "
+
+#: vms-alpha.c:7488
+msgid "*unknown*        "
+msgstr "*невідомо*       "
+
+#: vms-alpha.c:7491
+#, c-format
+msgid ": %u.%u\n"
+msgstr ": %u.%u\n"
+
+#: vms-alpha.c:7504 vms-alpha.c:7763
+#, c-format
+msgid "cannot read EIHA\n"
+msgstr ""
+
+#: vms-alpha.c:7507
+#, c-format
+msgid "Image activation:  (size=%u)\n"
+msgstr ""
+
+#: vms-alpha.c:7509
+#, c-format
+msgid " First address : 0x%08x 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:7512
+#, c-format
+msgid " Second address: 0x%08x 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:7515
+#, c-format
+msgid " Third address : 0x%08x 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:7518
+#, c-format
+msgid " Fourth address: 0x%08x 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:7521
+#, c-format
+msgid " Shared image  : 0x%08x 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:7532
+#, c-format
+msgid "cannot read EIHI\n"
+msgstr ""
+
+#: vms-alpha.c:7535
+#, c-format
+msgid "Image identification: (major: %u, minor: %u)\n"
+msgstr ""
+
+#: vms-alpha.c:7538
+#, c-format
+msgid " image name       : %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:7540
+#, c-format
+msgid " link time        : %s\n"
+msgstr ""
+
+#: vms-alpha.c:7542
+#, c-format
+msgid " image ident      : %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:7544
+#, c-format
+msgid " linker ident     : %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:7546
+#, c-format
+msgid " image build ident: %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:7556
+#, c-format
+msgid "cannot read EIHS\n"
+msgstr ""
+
+#: vms-alpha.c:7559
+#, c-format
+msgid "Image symbol & debug table: (major: %u, minor: %u)\n"
+msgstr ""
+
+#: vms-alpha.c:7564
+#, c-format
+msgid " debug symbol table : vbn: %u, size: %u (0x%x)\n"
+msgstr ""
+
+#: vms-alpha.c:7568
+#, c-format
+msgid " global symbol table: vbn: %u, records: %u\n"
+msgstr ""
+
+#: vms-alpha.c:7572
+#, c-format
+msgid " debug module table : vbn: %u, size: %u\n"
+msgstr ""
+
+#: vms-alpha.c:7585
+#, c-format
+msgid "cannot read EISD\n"
+msgstr ""
+
+#: vms-alpha.c:7595
+#, c-format
+msgid "Image section descriptor: (major: %u, minor: %u, size: %u, offset: %u)\n"
+msgstr ""
+
+#: vms-alpha.c:7602
+#, c-format
+msgid " section: base: 0x%08x%08x size: 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:7607
+#, c-format
+msgid " flags: 0x%04x"
+msgstr ""
+
+#: vms-alpha.c:7644
+#, c-format
+msgid " vbn: %u, pfc: %u, matchctl: %u type: %u ("
+msgstr ""
+
+#: vms-alpha.c:7650
+msgid "NORMAL"
+msgstr "NORMAL"
+
+#: vms-alpha.c:7653
+msgid "SHRFXD"
+msgstr "SHRFXD"
+
+#: vms-alpha.c:7656
+msgid "PRVFXD"
+msgstr "PRVFXD"
+
+#: vms-alpha.c:7659
+msgid "SHRPIC"
+msgstr "SHRPIC"
+
+#: vms-alpha.c:7662
+msgid "PRVPIC"
+msgstr "PRVPIC"
+
+#: vms-alpha.c:7665
+msgid "USRSTACK"
+msgstr ""
+
+#: vms-alpha.c:7673
+#, c-format
+msgid " ident: 0x%08x, name: %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:7683
+#, c-format
+msgid "cannot read DMT\n"
+msgstr ""
+
+#: vms-alpha.c:7687
+#, c-format
+msgid "Debug module table:\n"
+msgstr ""
+
+#: vms-alpha.c:7696
+#, c-format
+msgid "cannot read DMT header\n"
+msgstr ""
+
+#: vms-alpha.c:7701
+#, c-format
+msgid " module offset: 0x%08x, size: 0x%08x, (%u psects)\n"
+msgstr ""
+
+#: vms-alpha.c:7711
+#, c-format
+msgid "cannot read DMT psect\n"
+msgstr ""
+
+#: vms-alpha.c:7714
+#, c-format
+msgid "  psect start: 0x%08x, length: %u\n"
+msgstr ""
+
+#: vms-alpha.c:7727
+#, c-format
+msgid "cannot read DST\n"
+msgstr ""
+
+#: vms-alpha.c:7737
+#, c-format
+msgid "cannot read GST\n"
+msgstr ""
+
+#: vms-alpha.c:7741
+#, c-format
+msgid "Global symbol table:\n"
+msgstr ""
+
+#: vms-alpha.c:7769
+#, c-format
+msgid "Image activator fixup: (major: %u, minor: %u)\n"
+msgstr ""
+
+#: vms-alpha.c:7772
+#, c-format
+msgid "  iaflink : 0x%08x %08x\n"
+msgstr ""
+
+#: vms-alpha.c:7775
+#, c-format
+msgid "  fixuplnk: 0x%08x %08x\n"
+msgstr ""
+
+#: vms-alpha.c:7778
+#, c-format
+msgid "  size : %u\n"
+msgstr ""
+
+#: vms-alpha.c:7780
+#, c-format
+msgid "  flags: 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:7784
+#, c-format
+msgid "  qrelfixoff: %5u, lrelfixoff: %5u\n"
+msgstr ""
+
+#: vms-alpha.c:7788
+#, c-format
+msgid "  qdotadroff: %5u, ldotadroff: %5u\n"
+msgstr ""
+
+#: vms-alpha.c:7792
+#, c-format
+msgid "  codeadroff: %5u, lpfixoff  : %5u\n"
+msgstr ""
+
+#: vms-alpha.c:7795
+#, c-format
+msgid "  chgprtoff : %5u\n"
+msgstr ""
+
+#: vms-alpha.c:7798
+#, c-format
+msgid "  shlstoff  : %5u, shrimgcnt : %5u\n"
+msgstr ""
+
+#: vms-alpha.c:7800
+#, c-format
+msgid "  shlextra  : %5u, permctx   : %5u\n"
+msgstr ""
+
+#: vms-alpha.c:7803
+#, c-format
+msgid "  base_va : 0x%08x\n"
+msgstr ""
+
+#: vms-alpha.c:7805
+#, c-format
+msgid "  lppsbfixoff: %5u\n"
+msgstr ""
+
+#: vms-alpha.c:7813
+#, c-format
+msgid " Shareable images:\n"
+msgstr ""
+
+#: vms-alpha.c:7817
+#, c-format
+msgid "  %u: size: %u, flags: 0x%02x, name: %.*s\n"
+msgstr ""
+
+#: vms-alpha.c:7824
+#, c-format
+msgid " quad-word relocation fixups:\n"
+msgstr ""
+
+#: vms-alpha.c:7829
+#, c-format
+msgid " long-word relocation fixups:\n"
+msgstr ""
+
+#: vms-alpha.c:7834
+#, c-format
+msgid " quad-word .address reference fixups:\n"
+msgstr ""
+
+#: vms-alpha.c:7839
+#, c-format
+msgid " long-word .address reference fixups:\n"
+msgstr ""
+
+#: vms-alpha.c:7844
+#, c-format
+msgid " Code Address Reference Fixups:\n"
+msgstr ""
+
+#: vms-alpha.c:7849
+#, c-format
+msgid " Linkage Pairs Referece Fixups:\n"
+msgstr ""
+
+#: vms-alpha.c:7858
+#, c-format
+msgid " Change Protection (%u entries):\n"
+msgstr ""
+
+#: vms-alpha.c:7863
+#, 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
+msgid "%P: relocatable link is not supported\n"
+msgstr ""
+
+#: vms-alpha.c:8764
+msgid "%P: multiple entry points: in modules %B and %B\n"
+msgstr ""
+
+#: vms-lib.c:1421
+#, c-format
+msgid "could not open shared image '%s' from '%s'"
+msgstr ""
+
+#: vms-misc.c:360
+msgid "_bfd_vms_output_counted called with zero bytes"
+msgstr ""
+
+#: vms-misc.c:365
+msgid "_bfd_vms_output_counted called with too many bytes"
+msgstr ""
+
+#: xcofflink.c:836
+#, c-format
+msgid "%s: XCOFF shared object when not producing XCOFF output"
+msgstr ""
+
+#: xcofflink.c:857
+#, c-format
+msgid "%s: dynamic object with no .loader section"
+msgstr ""
+
+#: xcofflink.c:1416
+msgid "%B: `%s' has line numbers but no enclosing section"
+msgstr ""
+
+#: xcofflink.c:1468
+msgid "%B: class %d symbol `%s' has no aux entries"
+msgstr ""
+
+#: xcofflink.c:1490
+msgid "%B: symbol `%s' has unrecognized csect type %d"
+msgstr ""
+
+#: xcofflink.c:1502
+msgid "%B: bad XTY_ER symbol `%s': class %d scnum %d scnlen %d"
+msgstr ""
+
+#: xcofflink.c:1531
+msgid "%B: XMC_TC0 symbol `%s' is class %d scnlen %d"
+msgstr ""
+
+#: xcofflink.c:1677
+msgid "%B: csect `%s' not in enclosing section"
+msgstr ""
+
+#: xcofflink.c:1784
+msgid "%B: misplaced XTY_LD `%s'"
+msgstr ""
+
+#: xcofflink.c:2103
+msgid "%B: reloc %s:%d not in csect"
+msgstr ""
+
+#: xcofflink.c:3194
+#, c-format
+msgid "%s: no such symbol"
+msgstr ""
+
+#: xcofflink.c:3299
+#, c-format
+msgid "warning: attempt to export undefined symbol `%s'"
+msgstr ""
+
+#: xcofflink.c:3681
+msgid "error: undefined symbol __rtinit"
+msgstr ""
+
+#: xcofflink.c:4060
+msgid "%B: loader reloc in unrecognized section `%s'"
+msgstr ""
+
+#: xcofflink.c:4071
+msgid "%B: `%s' in loader reloc but not loader sym"
+msgstr ""
+
+#: xcofflink.c:4087
+msgid "%B: loader reloc in read-only section %A"
+msgstr ""
+
+#: xcofflink.c:5109
+#, c-format
+msgid "TOC overflow: 0x%lx > 0x10000; try -mminimal-toc when compiling"
+msgstr ""
+
+#: 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 ""
+
+#: elf32-ia64.c:2290 elf64-ia64.c:2290
+msgid "@pltoff reloc against local symbol"
+msgstr ""
+
+#: elf32-ia64.c:3693 elf64-ia64.c:3693
+#, c-format
+msgid "%s: short data segment overflowed (0x%lx >= 0x400000)"
+msgstr ""
+
+#: elf32-ia64.c:3704 elf64-ia64.c:3704
+#, c-format
+msgid "%s: __gp does not cover short data segment"
+msgstr ""
+
+#: elf32-ia64.c:3971 elf64-ia64.c:3971
+msgid "%B: non-pic code with imm relocation against dynamic symbol `%s'"
+msgstr ""
+
+#: elf32-ia64.c:4038 elf64-ia64.c:4038
+msgid "%B: @gprel relocation against dynamic symbol %s"
+msgstr ""
+
+#: elf32-ia64.c:4101 elf64-ia64.c:4101
+msgid "%B: linking non-pic code in a position independent executable"
+msgstr ""
+
+#: elf32-ia64.c:4238 elf64-ia64.c:4238
+msgid "%B: @internal branch to dynamic symbol %s"
+msgstr ""
+
+#: elf32-ia64.c:4240 elf64-ia64.c:4240
+msgid "%B: speculation fixup to dynamic symbol %s"
+msgstr ""
+
+#: elf32-ia64.c:4242 elf64-ia64.c:4242
+msgid "%B: @pcrel relocation against dynamic symbol %s"
+msgstr ""
+
+#: elf32-ia64.c:4439 elf64-ia64.c:4439
+msgid "unsupported reloc"
+msgstr ""
+
+#: elf32-ia64.c:4477 elf64-ia64.c:4477
+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
+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
+msgid "%B: linking trap-on-NULL-dereference with non-trapping files"
+msgstr ""
+
+#: elf32-ia64.c:4763 elf64-ia64.c:4763
+msgid "%B: linking big-endian files with little-endian files"
+msgstr ""
+
+#: elf32-ia64.c:4772 elf64-ia64.c:4772
+msgid "%B: linking 64-bit files with 32-bit files"
+msgstr ""
+
+#: elf32-ia64.c:4781 elf64-ia64.c:4781
+msgid "%B: linking constant-gp files with non-constant-gp files"
+msgstr ""
+
+#: elf32-ia64.c:4791 elf64-ia64.c:4791
+msgid "%B: linking auto-pic files with non-auto-pic files"
+msgstr ""
+
+#: peigen.c:1002 pepigen.c:1002 pex64igen.c:1002
+#, c-format
+msgid "%s: line number overflow: 0x%lx > 0xffff"
+msgstr "%s: переповнення номерів рядків; 0x%lx > 0xffff"
+
+#: peigen.c:1029 pepigen.c:1029 pex64igen.c:1029
+msgid "Export Directory [.edata (or where ever we found it)]"
+msgstr ""
+
+#: peigen.c:1030 pepigen.c:1030 pex64igen.c:1030
+msgid "Import Directory [parts of .idata]"
+msgstr "Каталог імпортування [частини .idata]"
+
+#: peigen.c:1031 pepigen.c:1031 pex64igen.c:1031
+msgid "Resource Directory [.rsrc]"
+msgstr "Каталог ресурсів [.rsrc]"
+
+#: peigen.c:1032 pepigen.c:1032 pex64igen.c:1032
+msgid "Exception Directory [.pdata]"
+msgstr "Каталог виключень [.pdata]"
+
+#: peigen.c:1033 pepigen.c:1033 pex64igen.c:1033
+msgid "Security Directory"
+msgstr "Каталог захисту"
+
+#: peigen.c:1034 pepigen.c:1034 pex64igen.c:1034
+msgid "Base Relocation Directory [.reloc]"
+msgstr "Каталог базового пересування [.reloc]"
+
+#: peigen.c:1035 pepigen.c:1035 pex64igen.c:1035
+msgid "Debug Directory"
+msgstr "Каталог діагностики"
+
+#: peigen.c:1036 pepigen.c:1036 pex64igen.c:1036
+msgid "Description Directory"
+msgstr "Каталог описів"
+
+#: peigen.c:1037 pepigen.c:1037 pex64igen.c:1037
+msgid "Special Directory"
+msgstr "Особливий каталог"
+
+#: peigen.c:1038 pepigen.c:1038 pex64igen.c:1038
+msgid "Thread Storage Directory [.tls]"
+msgstr "Каталог зберігання потоків [.tls]"
+
+#: peigen.c:1039 pepigen.c:1039 pex64igen.c:1039
+msgid "Load Configuration Directory"
+msgstr ""
+
+#: peigen.c:1040 pepigen.c:1040 pex64igen.c:1040
+msgid "Bound Import Directory"
+msgstr ""
+
+#: peigen.c:1041 pepigen.c:1041 pex64igen.c:1041
+msgid "Import Address Table Directory"
+msgstr ""
+
+#: peigen.c:1042 pepigen.c:1042 pex64igen.c:1042
+msgid "Delay Import Directory"
+msgstr "Каталог відкладеного імпортування"
+
+#: peigen.c:1043 pepigen.c:1043 pex64igen.c:1043
+msgid "CLR Runtime Header"
+msgstr "Динамічний заголовок CLR"
+
+#: peigen.c:1044 pepigen.c:1044 pex64igen.c:1044
+msgid "Reserved"
+msgstr "Зарезервовано"
+
+#: peigen.c:1104 pepigen.c:1104 pex64igen.c:1104
+#, c-format
+msgid ""
+"\n"
+"There is an import table, but the section containing it could not be found\n"
+msgstr ""
+"\n"
+"Існує таблиця імпортування, але розділу, що її містить не знайдено\n"
+
+#: peigen.c:1109 pepigen.c:1109 pex64igen.c:1109
+#, c-format
+msgid ""
+"\n"
+"There is an import table in %s at 0x%lx\n"
+msgstr ""
+"\n"
+"У %s зберігається таблиця імпортування у 0x%lx\n"
+
+#: peigen.c:1151 pepigen.c:1151 pex64igen.c:1151
+#, c-format
+msgid ""
+"\n"
+"Function descriptor located at the start address: %04lx\n"
+msgstr ""
+"\n"
+"Дескриптор функції розташовано за початковою адресою %04lx\n"
+
+#: peigen.c:1154 pepigen.c:1154 pex64igen.c:1154
+#, c-format
+msgid "\tcode-base %08lx toc (loadable/actual) %08lx/%08lx\n"
+msgstr ""
+
+#: peigen.c:1162 pepigen.c:1162 pex64igen.c:1162
+#, c-format
+msgid ""
+"\n"
+"No reldata section! Function descriptor not decoded.\n"
+msgstr ""
+"\n"
+"Немає розділу reldata! Дескриптор функції не розшифровано.\n"
+
+#: peigen.c:1167 pepigen.c:1167 pex64igen.c:1167
+#, c-format
+msgid ""
+"\n"
+"The Import Tables (interpreted %s section contents)\n"
+msgstr ""
+"\n"
+"Таблиця імпортування (оброблений вміст розділу %s)\n"
+
+#: peigen.c:1170 pepigen.c:1170 pex64igen.c:1170
+#, c-format
+msgid ""
+" vma:            Hint    Time      Forward  DLL       First\n"
+"                 Table   Stamp     Chain    Name      Thunk\n"
+msgstr ""
+
+#: peigen.c:1218 pepigen.c:1218 pex64igen.c:1218
+#, c-format
+msgid ""
+"\n"
+"\tDLL Name: %s\n"
+msgstr ""
+"\n"
+"\tНазва DLL: %s\n"
+
+#: peigen.c:1229 pepigen.c:1229 pex64igen.c:1229
+#, c-format
+msgid "\tvma:  Hint/Ord Member-Name Bound-To\n"
+msgstr ""
+
+#: peigen.c:1254 pepigen.c:1254 pex64igen.c:1254
+#, c-format
+msgid ""
+"\n"
+"There is a first thunk, but the section containing it could not be found\n"
+msgstr ""
+
+#: peigen.c:1415 pepigen.c:1415 pex64igen.c:1415
+#, c-format
+msgid ""
+"\n"
+"There is an export table, but the section containing it could not be found\n"
+msgstr ""
+
+#: peigen.c:1424 pepigen.c:1424 pex64igen.c:1424
+#, c-format
+msgid ""
+"\n"
+"There is an export table in %s, but it does not fit into that section\n"
+msgstr ""
+
+#: peigen.c:1430 pepigen.c:1430 pex64igen.c:1430
+#, c-format
+msgid ""
+"\n"
+"There is an export table in %s at 0x%lx\n"
+msgstr ""
+
+#: peigen.c:1458 pepigen.c:1458 pex64igen.c:1458
+#, c-format
+msgid ""
+"\n"
+"The Export Tables (interpreted %s section contents)\n"
+"\n"
+msgstr ""
+
+#: peigen.c:1462 pepigen.c:1462 pex64igen.c:1462
+#, c-format
+msgid "Export Flags \t\t\t%lx\n"
+msgstr "Прапорці експортування\t\t%lx\n"
+
+#: peigen.c:1465 pepigen.c:1465 pex64igen.c:1465
+#, c-format
+msgid "Time/Date stamp \t\t%lx\n"
+msgstr "Позначка часу/дати\t\t%lx\n"
+
+#: peigen.c:1468 pepigen.c:1468 pex64igen.c:1468
+#, c-format
+msgid "Major/Minor \t\t\t%d/%d\n"
+msgstr ""
+
+#: peigen.c:1471 pepigen.c:1471 pex64igen.c:1471
+#, c-format
+msgid "Name \t\t\t\t"
+msgstr "Назва\t\t\t\t"
+
+#: peigen.c:1477 pepigen.c:1477 pex64igen.c:1477
+#, c-format
+msgid "Ordinal Base \t\t\t%ld\n"
+msgstr "Основа впорядковування\t\t%ld\n"
+
+#: peigen.c:1480 pepigen.c:1480 pex64igen.c:1480
+#, c-format
+msgid "Number in:\n"
+msgstr "Номер у:\n"
+
+#: peigen.c:1483 pepigen.c:1483 pex64igen.c:1483
+#, c-format
+msgid "\tExport Address Table \t\t%08lx\n"
+msgstr "\tТаблиця експортованих адрес \t\t%08lx\n"
+
+#: peigen.c:1487 pepigen.c:1487 pex64igen.c:1487
+#, c-format
+msgid "\t[Name Pointer/Ordinal] Table\t%08lx\n"
+msgstr ""
+
+#: peigen.c:1490 pepigen.c:1490 pex64igen.c:1490
+#, c-format
+msgid "Table Addresses\n"
+msgstr "Табличні адреси\n"
+
+#: peigen.c:1493 pepigen.c:1493 pex64igen.c:1493
+#, c-format
+msgid "\tExport Address Table \t\t"
+msgstr "\tТаблиця експортованих адрес \t\t"
+
+#: peigen.c:1498 pepigen.c:1498 pex64igen.c:1498
+#, c-format
+msgid "\tName Pointer Table \t\t"
+msgstr ""
+
+#: peigen.c:1503 pepigen.c:1503 pex64igen.c:1503
+#, c-format
+msgid "\tOrdinal Table \t\t\t"
+msgstr "\tТаблиця номерів \t\t\t"
+
+#: peigen.c:1517 pepigen.c:1517 pex64igen.c:1517
+#, c-format
+msgid ""
+"\n"
+"Export Address Table -- Ordinal Base %ld\n"
+msgstr ""
+
+#: peigen.c:1536 pepigen.c:1536 pex64igen.c:1536
+msgid "Forwarder RVA"
+msgstr ""
+
+#: peigen.c:1547 pepigen.c:1547 pex64igen.c:1547
+msgid "Export RVA"
+msgstr "Експортований RVA"
+
+#: peigen.c:1554 pepigen.c:1554 pex64igen.c:1554
+#, c-format
+msgid ""
+"\n"
+"[Ordinal/Name Pointer] Table\n"
+msgstr ""
+
+#: peigen.c:1614 peigen.c:1797 pepigen.c:1614 pepigen.c:1797 pex64igen.c:1614
+#: pex64igen.c:1797
+#, c-format
+msgid "Warning, .pdata section size (%ld) is not a multiple of %d\n"
+msgstr "Попередження: розмір розділу .pdata (%ld) не є кратним до %d\n"
+
+#: peigen.c:1621 pepigen.c:1621 pex64igen.c:1621
+#, c-format
+msgid " vma:\t\t\tBegin Address    End Address      Unwind Info\n"
+msgstr ""
+
+#: peigen.c:1623 pepigen.c:1623 pex64igen.c:1623
+#, c-format
+msgid ""
+" vma:\t\tBegin    End      EH       EH       PrologEnd  Exception\n"
+"     \t\tAddress  Address  Handler  Data     Address    Mask\n"
+msgstr ""
+
+#: peigen.c:1697 pepigen.c:1697 pex64igen.c:1697
+#, c-format
+msgid " Register save millicode"
+msgstr " Мілікод збереження регістра"
+
+#: peigen.c:1700 pepigen.c:1700 pex64igen.c:1700
+#, c-format
+msgid " Register restore millicode"
+msgstr " Мілікод відновлення регістра"
+
+#: peigen.c:1703 pepigen.c:1703 pex64igen.c:1703
+#, c-format
+msgid " Glue code sequence"
+msgstr ""
+
+#: peigen.c:1803 pepigen.c:1803 pex64igen.c:1803
+#, c-format
+msgid ""
+" vma:\t\tBegin    Prolog   Function Flags    Exception EH\n"
+"     \t\tAddress  Length   Length   32b exc  Handler   Data\n"
+msgstr ""
+
+#: peigen.c:1929 pepigen.c:1929 pex64igen.c:1929
+#, c-format
+msgid ""
+"\n"
+"\n"
+"PE File Base Relocations (interpreted .reloc section contents)\n"
+msgstr ""
+
+#: peigen.c:1958 pepigen.c:1958 pex64igen.c:1958
+#, c-format
+msgid ""
+"\n"
+"Virtual Address: %08lx Chunk size %ld (0x%lx) Number of fixups %ld\n"
+msgstr ""
+
+#: peigen.c:1971 pepigen.c:1971 pex64igen.c:1971
+#, c-format
+msgid "\treloc %4d offset %4x [%4lx] %s"
+msgstr "\tпересування %4d відступ %4x [%4lx] %s"
+
+#. The MS dumpbin program reportedly ands with 0xff0f before
+#. printing the characteristics field.  Not sure why.  No reason to
+#. emulate it here.
+#: peigen.c:2010 pepigen.c:2010 pex64igen.c:2010
+#, c-format
+msgid ""
+"\n"
+"Characteristics 0x%x\n"
+msgstr ""
+"\n"
+"Характеристики 0x%x\n"
+
+#: peigen.c:2310 pepigen.c:2310 pex64igen.c:2310
+msgid "%B: unable to fill in DataDictionary[1] because .idata$2 is missing"
+msgstr "%B: не вдалося заповнити DataDictionary[1], оскільки не вистачає .idata$2"
+
+#: peigen.c:2330 pepigen.c:2330 pex64igen.c:2330
+msgid "%B: unable to fill in DataDictionary[1] because .idata$4 is missing"
+msgstr "%B: не вдалося заповнити DataDictionary[1], оскільки не вистачає .idata$4"
+
+#: peigen.c:2351 pepigen.c:2351 pex64igen.c:2351
+msgid "%B: unable to fill in DataDictionary[12] because .idata$5 is missing"
+msgstr "%B: не вдалося заповнити DataDictionary[12], оскільки не вистачає .idata$5"
+
+#: peigen.c:2371 pepigen.c:2371 pex64igen.c:2371
+msgid "%B: unable to fill in DataDictionary[PE_IMPORT_ADDRESS_TABLE (12)] because .idata$6 is missing"
+msgstr "%B: не вдалося заповнити DataDictionary[PE_IMPORT_ADDRESS_TABLE (12)], оскільки не вистачає .idata$6"
+
+#: peigen.c:2413 pepigen.c:2413 pex64igen.c:2413
+msgid "%B: unable to fill in DataDictionary[PE_IMPORT_ADDRESS_TABLE(12)] because .idata$6 is missing"
+msgstr "%B: не вдалося заповнити DataDictionary[PE_IMPORT_ADDRESS_TABLE(12)], оскільки .idata$6 не вистачає"
+
+#: peigen.c:2438 pepigen.c:2438 pex64igen.c:2438
+msgid "%B: unable to fill in DataDictionary[9] because __tls_used is missing"
+msgstr ""
diff --git a/bfd/ppcboot.c b/bfd/ppcboot.c
index c2b4c3b..b0718d8 100644
--- a/bfd/ppcboot.c
+++ b/bfd/ppcboot.c
@@ -1,6 +1,6 @@
 /* BFD back-end for PPCbug boot records.
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007, 2008, 2009, 2011 Free Software Foundation, Inc.
+   2007, 2008, 2009, 2011, 2012 Free Software Foundation, Inc.
    Written by Michael Meissner, Cygnus Support, <meissner@cygnus.com>
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -40,7 +40,8 @@
 #include "libbfd.h"
 
 /* PPCbug location structure */
-typedef struct ppcboot_location {
+typedef struct ppcboot_location
+{
   bfd_byte	ind;
   bfd_byte	head;
   bfd_byte	sector;
@@ -48,7 +49,8 @@
 } ppcboot_location_t;
 
 /* PPCbug partition table layout */
-typedef struct ppcboot_partition {
+typedef struct ppcboot_partition
+{
   ppcboot_location_t	partition_begin;	/* partition begin */
   ppcboot_location_t	partition_end;		/* partition end */
   bfd_byte		sector_begin[4];	/* 32-bit start RBA (zero-based), little endian */
@@ -56,7 +58,8 @@
 } ppcboot_partition_t;
 
 /* PPCbug boot layout.  */
-typedef struct ppcboot_hdr {
+typedef struct ppcboot_hdr
+{
   bfd_byte		pc_compatibility[446];	/* x86 instruction field */
   ppcboot_partition_t	partition[4];		/* partition information */
   bfd_byte		signature[2];		/* 0x55 and 0xaa */
@@ -80,7 +83,8 @@
 #define PPC_IND 0x41
 
 /* Information needed for ppcboot header */
-typedef struct ppcboot_data {
+typedef struct ppcboot_data
+{
   ppcboot_hdr_t	header;				/* raw header */
   asection *sec;				/* single section */
 } ppcboot_data_t;
@@ -89,28 +93,13 @@
    a start symbol, an end symbol, and an absolute length symbol.  */
 #define PPCBOOT_SYMS 3
 
-static bfd_boolean ppcboot_mkobject PARAMS ((bfd *));
-static const bfd_target *ppcboot_object_p PARAMS ((bfd *));
-static bfd_boolean ppcboot_set_arch_mach
-  PARAMS ((bfd *, enum bfd_architecture, unsigned long));
-static bfd_boolean ppcboot_get_section_contents
-  PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
-static long ppcboot_get_symtab_upper_bound PARAMS ((bfd *));
-static char *mangle_name PARAMS ((bfd *, char *));
-static long ppcboot_canonicalize_symtab PARAMS ((bfd *, asymbol **));
-static void ppcboot_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
-static bfd_boolean ppcboot_set_section_contents
-  PARAMS ((bfd *, asection *, const PTR, file_ptr, bfd_size_type));
-static bfd_boolean ppcboot_bfd_print_private_bfd_data PARAMS ((bfd *, PTR));
-
-#define ppcboot_set_tdata(abfd, ptr) ((abfd)->tdata.any = (PTR) (ptr))
+#define ppcboot_set_tdata(abfd, ptr) ((abfd)->tdata.any = (ptr))
 #define ppcboot_get_tdata(abfd) ((ppcboot_data_t *) ((abfd)->tdata.any))
 
 /* Create a ppcboot object.  Invoked via bfd_set_format.  */
 
 static bfd_boolean
-ppcboot_mkobject (abfd)
-     bfd *abfd;
+ppcboot_mkobject (bfd *abfd)
 {
   if (!ppcboot_get_tdata (abfd))
     {
@@ -124,10 +113,9 @@
 
 /* Set the architecture to PowerPC */
 static bfd_boolean
-ppcboot_set_arch_mach (abfd, arch, machine)
-     bfd *abfd;
-     enum bfd_architecture arch;
-     unsigned long machine;
+ppcboot_set_arch_mach (bfd *abfd,
+		       enum bfd_architecture arch,
+		       unsigned long machine)
 {
   if (arch == bfd_arch_unknown)
     arch = bfd_arch_powerpc;
@@ -144,8 +132,7 @@
    being ppcboot.  */
 
 static const bfd_target *
-ppcboot_object_p (abfd)
-     bfd *abfd;
+ppcboot_object_p (bfd *abfd)
 {
   struct stat statbuf;
   asection *sec;
@@ -175,7 +162,7 @@
       return NULL;
     }
 
-  if (bfd_bread ((PTR) &hdr, (bfd_size_type) sizeof (hdr), abfd)
+  if (bfd_bread (&hdr, (bfd_size_type) sizeof (hdr), abfd)
       != sizeof (hdr))
     {
       if (bfd_get_error () != bfd_error_system_call)
@@ -218,7 +205,7 @@
   ppcboot_mkobject (abfd);
   tdata = ppcboot_get_tdata (abfd);
   tdata->sec = sec;
-  memcpy ((PTR) &tdata->header, (PTR) &hdr, sizeof (ppcboot_hdr_t));
+  memcpy (&tdata->header, &hdr, sizeof (ppcboot_hdr_t));
 
   ppcboot_set_arch_mach (abfd, bfd_arch_powerpc, 0L);
   return abfd->xvec;
@@ -232,12 +219,11 @@
 /* Get contents of the only section.  */
 
 static bfd_boolean
-ppcboot_get_section_contents (abfd, section, location, offset, count)
-     bfd *abfd;
-     asection *section ATTRIBUTE_UNUSED;
-     PTR location;
-     file_ptr offset;
-     bfd_size_type count;
+ppcboot_get_section_contents (bfd *abfd,
+			      asection *section ATTRIBUTE_UNUSED,
+			      void * location,
+			      file_ptr offset,
+			      bfd_size_type count)
 {
   if (bfd_seek (abfd, offset + (file_ptr) sizeof (ppcboot_hdr_t), SEEK_SET) != 0
       || bfd_bread (location, count, abfd) != count)
@@ -249,8 +235,7 @@
 /* Return the amount of memory needed to read the symbol table.  */
 
 static long
-ppcboot_get_symtab_upper_bound (abfd)
-     bfd *abfd ATTRIBUTE_UNUSED;
+ppcboot_get_symtab_upper_bound (bfd *abfd ATTRIBUTE_UNUSED)
 {
   return (PPCBOOT_SYMS + 1) * sizeof (asymbol *);
 }
@@ -259,9 +244,7 @@
 /* Create a symbol name based on the bfd's filename.  */
 
 static char *
-mangle_name (abfd, suffix)
-     bfd *abfd;
-     char *suffix;
+mangle_name (bfd *abfd, char *suffix)
 {
   bfd_size_type size;
   char *buf;
@@ -289,9 +272,7 @@
 /* Return the symbol table.  */
 
 static long
-ppcboot_canonicalize_symtab (abfd, alocation)
-     bfd *abfd;
-     asymbol **alocation;
+ppcboot_canonicalize_symtab (bfd *abfd, asymbol **alocation)
 {
   asection *sec = ppcboot_get_tdata (abfd)->sec;
   asymbol *syms;
@@ -339,10 +320,9 @@
 /* Get information about a symbol.  */
 
 static void
-ppcboot_get_symbol_info (ignore_abfd, symbol, ret)
-     bfd *ignore_abfd ATTRIBUTE_UNUSED;
-     asymbol *symbol;
-     symbol_info *ret;
+ppcboot_get_symbol_info (bfd *ignore_abfd ATTRIBUTE_UNUSED,
+			 asymbol *symbol,
+			 symbol_info *ret)
 {
   bfd_symbol_info (symbol, ret);
 }
@@ -360,12 +340,11 @@
 /* Write section contents of a ppcboot file.  */
 
 static bfd_boolean
-ppcboot_set_section_contents (abfd, sec, data, offset, size)
-     bfd *abfd;
-     asection *sec;
-     const PTR data;
-     file_ptr offset;
-     bfd_size_type size;
+ppcboot_set_section_contents (bfd *abfd,
+			      asection *sec,
+			      const void * data,
+			      file_ptr offset,
+			      bfd_size_type size)
 {
   if (! abfd->output_has_begun)
     {
@@ -401,14 +380,12 @@
 /* Print out the program headers.  */
 
 static bfd_boolean
-ppcboot_bfd_print_private_bfd_data (abfd, farg)
-     bfd *abfd;
-     PTR farg;
+ppcboot_bfd_print_private_bfd_data (bfd *abfd, void * farg)
 {
   FILE *f = (FILE *)farg;
   ppcboot_data_t *tdata = ppcboot_get_tdata (abfd);
-  long entry_offset = bfd_getl_signed_32 ((PTR) tdata->header.entry_offset);
-  long length = bfd_getl_signed_32 ((PTR) tdata->header.length);
+  long entry_offset = bfd_getl_signed_32 (tdata->header.entry_offset);
+  long length = bfd_getl_signed_32 (tdata->header.length);
   int i;
 
   fprintf (f, _("\nppcboot header:\n"));
@@ -428,8 +405,8 @@
 
   for (i = 0; i < 4; i++)
     {
-      long sector_begin  = bfd_getl_signed_32 ((PTR) tdata->header.partition[i].sector_begin);
-      long sector_length = bfd_getl_signed_32 ((PTR) tdata->header.partition[i].sector_length);
+      long sector_begin  = bfd_getl_signed_32 (tdata->header.partition[i].sector_begin);
+      long sector_length = bfd_getl_signed_32 (tdata->header.partition[i].sector_length);
 
       /* Skip all 0 entries */
       if (!tdata->header.partition[i].partition_begin.ind
diff --git a/bfd/ptrace-core.c b/bfd/ptrace-core.c
index 77eaaeb..9f6ffdf 100644
--- a/bfd/ptrace-core.c
+++ b/bfd/ptrace-core.c
@@ -1,6 +1,6 @@
 /* BFD backend for core files which use the ptrace_user structure
    Copyright 1993, 1994, 1995, 1996, 1998, 1999, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007  Free Software Foundation, Inc.
+   2005, 2006, 2007, 2012  Free Software Foundation, Inc.
    The structure of this file is based on trad-core.c written by John Gilmore
    of Cygnus Support.
    Modified to work with the ptrace_user structure by Kevin A. Buettner.
@@ -35,31 +35,29 @@
 #include <sys/ptrace.h>
 
 struct trad_core_struct
-  {
-    asection *data_section;
-    asection *stack_section;
-    asection *reg_section;
-    struct ptrace_user u;
-  };
+{
+  asection *data_section;
+  asection *stack_section;
+  asection *reg_section;
+  struct ptrace_user u;
+};
 
-#define core_upage(bfd) (&((bfd)->tdata.trad_core_data->u))
-#define core_datasec(bfd) ((bfd)->tdata.trad_core_data->data_section)
+#define core_upage(bfd)  (&((bfd)->tdata.trad_core_data->u))
+#define core_datasec(bfd)  ((bfd)->tdata.trad_core_data->data_section)
 #define core_stacksec(bfd) ((bfd)->tdata.trad_core_data->stack_section)
-#define core_regsec(bfd) ((bfd)->tdata.trad_core_data->reg_section)
+#define core_regsec(bfd)   ((bfd)->tdata.trad_core_data->reg_section)
 
 /* forward declarations */
 
-const bfd_target *ptrace_unix_core_file_p PARAMS ((bfd *abfd));
-char * ptrace_unix_core_file_failing_command PARAMS ((bfd *abfd));
-int ptrace_unix_core_file_failing_signal PARAMS ((bfd *abfd));
+const bfd_target *ptrace_unix_core_file_p (bfd *abfd);
+char * ptrace_unix_core_file_failing_command (bfd *abfd);
+int ptrace_unix_core_file_failing_signal (bfd *abfd);
 #define ptrace_unix_core_file_matches_executable_p generic_core_file_matches_executable_p
 #define ptrace_unix_core_file_pid _bfd_nocore_core_file_pid
-static void swap_abort PARAMS ((void));
+static void swap_abort (void);
 
 const bfd_target *
-ptrace_unix_core_file_p (abfd)
-     bfd *abfd;
-
+ptrace_unix_core_file_p (bfd *abfd)
 {
   int val;
   struct ptrace_user u;
@@ -137,10 +135,10 @@
 }
 
 char *
-ptrace_unix_core_file_failing_command (abfd)
-     bfd *abfd;
+ptrace_unix_core_file_failing_command (bfd *abfd)
 {
   char *com = abfd->tdata.trad_core_data->u.pt_comm;
+
   if (*com)
     return com;
   else
@@ -148,15 +146,14 @@
 }
 
 int
-ptrace_unix_core_file_failing_signal (abfd)
-     bfd *abfd;
+ptrace_unix_core_file_failing_signal (bfd *abfd)
 {
   return abfd->tdata.trad_core_data->u.pt_sigframe.sig_num;
 }
 
 /* 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 */
 }
@@ -215,7 +212,7 @@
 
     NULL,
 
-    (PTR) 0			/* backend_data */
+    NULL			/* backend_data */
   };
 
 #endif /* PTRACE_CORE */
diff --git a/bfd/reloc.c b/bfd/reloc.c
index e0b5f62..19c1f96 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -1,6 +1,7 @@
 /* BFD support for handling relocation entries.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
+   2012
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -1942,6 +1943,14 @@
   BFD_RELOC_SPARC_L44
 ENUMX
   BFD_RELOC_SPARC_REGISTER
+ENUMX
+  BFD_RELOC_SPARC_H34
+ENUMX
+  BFD_RELOC_SPARC_SIZE32
+ENUMX
+  BFD_RELOC_SPARC_SIZE64
+ENUMX
+  BFD_RELOC_SPARC_WDISP10
 ENUMDOC
   SPARC64 relocations
 
@@ -2247,6 +2256,23 @@
   MIPS16 low 16 bits.
 
 ENUM
+  BFD_RELOC_MIPS16_TLS_GD
+ENUMX
+  BFD_RELOC_MIPS16_TLS_LDM
+ENUMX
+  BFD_RELOC_MIPS16_TLS_DTPREL_HI16
+ENUMX
+  BFD_RELOC_MIPS16_TLS_DTPREL_LO16
+ENUMX
+  BFD_RELOC_MIPS16_TLS_GOTTPREL
+ENUMX
+  BFD_RELOC_MIPS16_TLS_TPREL_HI16
+ENUMX
+  BFD_RELOC_MIPS16_TLS_TPREL_LO16
+ENUMDOC
+  MIPS16 TLS relocations
+
+ENUM
   BFD_RELOC_MIPS_LITERAL
 ENUMX
   BFD_RELOC_MICROMIPS_LITERAL
@@ -2530,6 +2556,36 @@
   The addend of this reloc is an alignment power that must
   be honoured at the offset's location, regardless of linker
   relaxation.
+ENUM
+  BFD_RELOC_MN10300_TLS_GD
+ENUMX
+  BFD_RELOC_MN10300_TLS_LD
+ENUMX
+  BFD_RELOC_MN10300_TLS_LDO
+ENUMX
+  BFD_RELOC_MN10300_TLS_GOTIE
+ENUMX
+  BFD_RELOC_MN10300_TLS_IE
+ENUMX
+  BFD_RELOC_MN10300_TLS_LE
+ENUMX
+  BFD_RELOC_MN10300_TLS_DTPMOD
+ENUMX
+  BFD_RELOC_MN10300_TLS_DTPOFF
+ENUMX
+  BFD_RELOC_MN10300_TLS_TPOFF
+ENUMDOC
+  Various TLS-related relocations.
+ENUM
+  BFD_RELOC_MN10300_32_PCREL
+ENUMDOC
+  This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the
+  instruction.
+ENUM
+  BFD_RELOC_MN10300_16_PCREL
+ENUMDOC
+  This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the
+  instruction.
 COMMENT
 
 ENUM
@@ -2750,6 +2806,40 @@
 ENUMX
   BFD_RELOC_PPC_EMB_RELSDA
 ENUMX
+  BFD_RELOC_PPC_VLE_REL8
+ENUMX
+  BFD_RELOC_PPC_VLE_REL15
+ENUMX
+  BFD_RELOC_PPC_VLE_REL24
+ENUMX
+  BFD_RELOC_PPC_VLE_LO16A
+ENUMX
+  BFD_RELOC_PPC_VLE_LO16D
+ENUMX
+  BFD_RELOC_PPC_VLE_HI16A
+ENUMX
+  BFD_RELOC_PPC_VLE_HI16D
+ENUMX
+  BFD_RELOC_PPC_VLE_HA16A
+ENUMX
+  BFD_RELOC_PPC_VLE_HA16D
+ENUMX
+  BFD_RELOC_PPC_VLE_SDA21
+ENUMX
+  BFD_RELOC_PPC_VLE_SDA21_LO
+ENUMX
+  BFD_RELOC_PPC_VLE_SDAREL_LO16A
+ENUMX
+  BFD_RELOC_PPC_VLE_SDAREL_LO16D
+ENUMX
+  BFD_RELOC_PPC_VLE_SDAREL_HI16A
+ENUMX
+  BFD_RELOC_PPC_VLE_SDAREL_HI16D
+ENUMX
+  BFD_RELOC_PPC_VLE_SDAREL_HA16A
+ENUMX
+  BFD_RELOC_PPC_VLE_SDAREL_HA16D
+ENUMX
   BFD_RELOC_PPC64_HIGHER
 ENUMX
   BFD_RELOC_PPC64_HIGHER_S
@@ -3904,16 +3994,6 @@
   BFD_RELOC_V850_DATA
 ENUMDOC
   start data in text.
-ENUM
-  BFD_RELOC_MN10300_32_PCREL
-ENUMDOC
-  This is a 32bit pcrel reloc for the mn10300, offset by two bytes in the
-  instruction.
-ENUM
-  BFD_RELOC_MN10300_16_PCREL
-ENUMDOC
-  This is a 16bit pcrel reloc for the mn10300, offset by two bytes in the
-  instruction.
 
 ENUM
   BFD_RELOC_TIC30_LDP
@@ -4314,6 +4394,21 @@
 ENUMDOC
   This is a 6 bit reloc for the AVR that stores offset for adiw/sbiw
   instructions
+ENUM
+  BFD_RELOC_AVR_8_LO
+ENUMDOC
+  This is a 8 bit reloc for the AVR that stores bits 0..7 of a symbol
+  in .byte lo8(symbol)
+ENUM
+  BFD_RELOC_AVR_8_HI
+ENUMDOC
+  This is a 8 bit reloc for the AVR that stores bits 8..15 of a symbol
+  in .byte hi8(symbol)
+ENUM
+  BFD_RELOC_AVR_8_HLO
+ENUMDOC
+  This is a 8 bit reloc for the AVR that stores bits 16..23 of a symbol
+  in .byte hlo8(symbol)
 
 ENUM
   BFD_RELOC_RL78_NEG8
@@ -4599,6 +4694,11 @@
   Long displacement extension.
 
 ENUM
+  BFD_RELOC_390_IRELATIVE
+ENUMDOC
+  STT_GNU_IFUNC relocation.
+
+ENUM
   BFD_RELOC_SCORE_GPREL15
 ENUMDOC
   Score relocations
@@ -4933,7 +5033,101 @@
 ENUMDOC
   Motorola 68HC12 reloc.
   This is the 5 bits of a value.
-
+ENUM
+  BFD_RELOC_XGATE_RL_JUMP
+ENUMDOC
+  Freescale XGATE reloc.
+  This reloc marks the beginning of a bra/jal instruction.
+ENUM
+  BFD_RELOC_XGATE_RL_GROUP
+ENUMDOC
+  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.
+ENUM
+  BFD_RELOC_XGATE_LO16
+ENUMDOC
+  Freescale XGATE reloc.
+  This is the 16-bit lower part of an address.  It is used for the '16-bit'
+  instructions.
+ENUM
+  BFD_RELOC_XGATE_GPAGE
+ENUMDOC
+  Freescale XGATE reloc.
+ENUM
+  BFD_RELOC_XGATE_24
+ENUMDOC
+  Freescale XGATE reloc.
+ENUM
+  BFD_RELOC_XGATE_PCREL_9
+ENUMDOC
+  Freescale XGATE reloc.
+  This is a 9-bit pc-relative reloc.
+ENUM
+  BFD_RELOC_XGATE_PCREL_10
+ENUMDOC
+  Freescale XGATE reloc.
+  This is a 10-bit pc-relative reloc.
+ENUM
+  BFD_RELOC_XGATE_IMM8_LO
+ENUMDOC
+  Freescale XGATE reloc.
+  This is the 16-bit lower part of an address.  It is used for the '16-bit'
+  instructions.
+ENUM
+  BFD_RELOC_XGATE_IMM8_HI
+ENUMDOC
+  Freescale XGATE reloc.
+  This is the 16-bit higher part of an address.  It is used for the '16-bit'
+  instructions.
+ENUM
+  BFD_RELOC_XGATE_IMM3
+ENUMDOC
+  Freescale XGATE reloc.
+  This is a 3-bit pc-relative reloc.
+ENUM
+  BFD_RELOC_XGATE_IMM4
+ENUMDOC
+  Freescale XGATE reloc.
+  This is a 4-bit pc-relative reloc.
+ENUM
+  BFD_RELOC_XGATE_IMM5
+ENUMDOC
+  Freescale XGATE reloc.
+  This is a 5-bit pc-relative reloc.
+ENUM
+  BFD_RELOC_M68HC12_9B
+ENUMDOC
+  Motorola 68HC12 reloc.
+  This is the 9 bits of a value.
+ENUM
+  BFD_RELOC_M68HC12_16B
+ENUMDOC
+  Motorola 68HC12 reloc.
+  This is the 16 bits of a value.
+ENUM
+  BFD_RELOC_M68HC12_9_PCREL
+ENUMDOC
+  Motorola 68HC12/XGATE reloc.
+  This is a PCREL9 branch.
+ENUM
+  BFD_RELOC_M68HC12_10_PCREL
+ENUMDOC
+  Motorola 68HC12/XGATE reloc.
+  This is a PCREL10 branch.
+ENUM
+  BFD_RELOC_M68HC12_LO8XG
+ENUMDOC
+  Motorola 68HC12/XGATE reloc.
+  This is the 8 bit low part of an absolute address and immediately precedes
+  a matching HI8XG part.
+ENUM
+  BFD_RELOC_M68HC12_HI8XG
+ENUMDOC
+  Motorola 68HC12/XGATE reloc.
+  This is the 8 bit high part of an absolute address and immediately follows
+  a matching LO8XG part.
 ENUM
   BFD_RELOC_16C_NUM08
 ENUMX
@@ -5577,6 +5771,10 @@
   Difference between two section addreses.  Must be followed by a
   BFD_RELOC_MACH_O_PAIR.
 ENUM
+  BFD_RELOC_MACH_O_LOCAL_SECTDIFF
+ENUMDOC
+  Like BFD_RELOC_MACH_O_SECTDIFF but with a local symbol.
+ENUM
   BFD_RELOC_MACH_O_PAIR
 ENUMDOC
   Pair of relocation.  Contains the first symbol.
@@ -5778,6 +5976,18 @@
 ENUMX
   BFD_RELOC_TILEPRO_SHAMT_Y1
 ENUMX
+  BFD_RELOC_TILEPRO_TLS_GD_CALL
+ENUMX
+  BFD_RELOC_TILEPRO_IMM8_X0_TLS_GD_ADD
+ENUMX
+  BFD_RELOC_TILEPRO_IMM8_X1_TLS_GD_ADD
+ENUMX
+  BFD_RELOC_TILEPRO_IMM8_Y0_TLS_GD_ADD
+ENUMX
+  BFD_RELOC_TILEPRO_IMM8_Y1_TLS_GD_ADD
+ENUMX
+  BFD_RELOC_TILEPRO_TLS_IE_LOAD
+ENUMX
   BFD_RELOC_TILEPRO_IMM16_X0_TLS_GD
 ENUMX
   BFD_RELOC_TILEPRO_IMM16_X1_TLS_GD
@@ -5815,6 +6025,22 @@
   BFD_RELOC_TILEPRO_TLS_DTPOFF32
 ENUMX
   BFD_RELOC_TILEPRO_TLS_TPOFF32
+ENUMX
+  BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE
+ENUMX
+  BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE
+ENUMX
+  BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_LO
+ENUMX
+  BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_LO
+ENUMX
+  BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_HI
+ENUMX
+  BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_HI
+ENUMX
+  BFD_RELOC_TILEPRO_IMM16_X0_TLS_LE_HA
+ENUMX
+  BFD_RELOC_TILEPRO_IMM16_X1_TLS_LE_HA
 ENUMDOC
   Tilera TILEPro Relocations.
 
@@ -5933,18 +6159,6 @@
 ENUMX
   BFD_RELOC_TILEGX_IMM16_X1_HW0_GOT
 ENUMX
-  BFD_RELOC_TILEGX_IMM16_X0_HW1_GOT
-ENUMX
-  BFD_RELOC_TILEGX_IMM16_X1_HW1_GOT
-ENUMX
-  BFD_RELOC_TILEGX_IMM16_X0_HW2_GOT
-ENUMX
-  BFD_RELOC_TILEGX_IMM16_X1_HW2_GOT
-ENUMX
-  BFD_RELOC_TILEGX_IMM16_X0_HW3_GOT
-ENUMX
-  BFD_RELOC_TILEGX_IMM16_X1_HW3_GOT
-ENUMX
   BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_GOT
 ENUMX
   BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_GOT
@@ -5953,25 +6167,21 @@
 ENUMX
   BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_GOT
 ENUMX
-  BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_GOT
-ENUMX
-  BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_GOT
-ENUMX
   BFD_RELOC_TILEGX_IMM16_X0_HW0_TLS_GD
 ENUMX
   BFD_RELOC_TILEGX_IMM16_X1_HW0_TLS_GD
 ENUMX
-  BFD_RELOC_TILEGX_IMM16_X0_HW1_TLS_GD
+  BFD_RELOC_TILEGX_IMM16_X0_HW0_TLS_LE
 ENUMX
-  BFD_RELOC_TILEGX_IMM16_X1_HW1_TLS_GD
+  BFD_RELOC_TILEGX_IMM16_X1_HW0_TLS_LE
 ENUMX
-  BFD_RELOC_TILEGX_IMM16_X0_HW2_TLS_GD
+  BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_TLS_LE
 ENUMX
-  BFD_RELOC_TILEGX_IMM16_X1_HW2_TLS_GD
+  BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_TLS_LE
 ENUMX
-  BFD_RELOC_TILEGX_IMM16_X0_HW3_TLS_GD
+  BFD_RELOC_TILEGX_IMM16_X0_HW1_LAST_TLS_LE
 ENUMX
-  BFD_RELOC_TILEGX_IMM16_X1_HW3_TLS_GD
+  BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_TLS_LE
 ENUMX
   BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_TLS_GD
 ENUMX
@@ -5981,26 +6191,10 @@
 ENUMX
   BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_TLS_GD
 ENUMX
-  BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_TLS_GD
-ENUMX
-  BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_TLS_GD
-ENUMX
   BFD_RELOC_TILEGX_IMM16_X0_HW0_TLS_IE
 ENUMX
   BFD_RELOC_TILEGX_IMM16_X1_HW0_TLS_IE
 ENUMX
-  BFD_RELOC_TILEGX_IMM16_X0_HW1_TLS_IE
-ENUMX
-  BFD_RELOC_TILEGX_IMM16_X1_HW1_TLS_IE
-ENUMX
-  BFD_RELOC_TILEGX_IMM16_X0_HW2_TLS_IE
-ENUMX
-  BFD_RELOC_TILEGX_IMM16_X1_HW2_TLS_IE
-ENUMX
-  BFD_RELOC_TILEGX_IMM16_X0_HW3_TLS_IE
-ENUMX
-  BFD_RELOC_TILEGX_IMM16_X1_HW3_TLS_IE
-ENUMX
   BFD_RELOC_TILEGX_IMM16_X0_HW0_LAST_TLS_IE
 ENUMX
   BFD_RELOC_TILEGX_IMM16_X1_HW0_LAST_TLS_IE
@@ -6009,10 +6203,6 @@
 ENUMX
   BFD_RELOC_TILEGX_IMM16_X1_HW1_LAST_TLS_IE
 ENUMX
-  BFD_RELOC_TILEGX_IMM16_X0_HW2_LAST_TLS_IE
-ENUMX
-  BFD_RELOC_TILEGX_IMM16_X1_HW2_LAST_TLS_IE
-ENUMX
   BFD_RELOC_TILEGX_TLS_DTPMOD64
 ENUMX
   BFD_RELOC_TILEGX_TLS_DTPOFF64
@@ -6024,6 +6214,26 @@
   BFD_RELOC_TILEGX_TLS_DTPOFF32
 ENUMX
   BFD_RELOC_TILEGX_TLS_TPOFF32
+ENUMX
+  BFD_RELOC_TILEGX_TLS_GD_CALL
+ENUMX
+  BFD_RELOC_TILEGX_IMM8_X0_TLS_GD_ADD
+ENUMX
+  BFD_RELOC_TILEGX_IMM8_X1_TLS_GD_ADD
+ENUMX
+  BFD_RELOC_TILEGX_IMM8_Y0_TLS_GD_ADD
+ENUMX
+  BFD_RELOC_TILEGX_IMM8_Y1_TLS_GD_ADD
+ENUMX
+  BFD_RELOC_TILEGX_TLS_IE_LOAD
+ENUMX
+  BFD_RELOC_TILEGX_IMM8_X0_TLS_ADD
+ENUMX
+  BFD_RELOC_TILEGX_IMM8_X1_TLS_ADD
+ENUMX
+  BFD_RELOC_TILEGX_IMM8_Y0_TLS_ADD
+ENUMX
+  BFD_RELOC_TILEGX_IMM8_Y1_TLS_ADD
 ENUMDOC
   Tilera TILE-Gx Relocations.
 
@@ -6210,23 +6420,26 @@
 	bfd_generic_lookup_section_flags
 
 SYNOPSIS
-	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 *);
 
 DESCRIPTION
 	Provides default handling for section flags lookup
 	-- i.e., does nothing.
+	Returns FALSE if the section should be omitted, otherwise TRUE.
 */
 
-void
+bfd_boolean
 bfd_generic_lookup_section_flags (struct bfd_link_info *info ATTRIBUTE_UNUSED,
-				  struct flag_info *finfo) 
+				  struct flag_info *flaginfo,
+				  asection *section ATTRIBUTE_UNUSED)
 {
-  if (finfo != NULL)
+  if (flaginfo != NULL)
     {
       (*_bfd_error_handler) (_("INPUT_SECTION_FLAGS are not supported.\n"));
-      return;
+      return FALSE;
     }
+  return TRUE;
 }
 
 /*
@@ -6314,7 +6527,7 @@
 	  bfd_reloc_status_type r;
 
 	  symbol = *(*parent)->sym_ptr_ptr;
-	  if (symbol->section && elf_discarded_section (symbol->section))
+	  if (symbol->section && discarded_section (symbol->section))
 	    {
 	      bfd_byte *p;
 	      static reloc_howto_type none_howto
@@ -6324,7 +6537,7 @@
 	      p = data + (*parent)->address * bfd_octets_per_byte (input_bfd);
 	      _bfd_clear_contents ((*parent)->howto, input_bfd, input_section,
 				   p);
-	      (*parent)->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+	      (*parent)->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
 	      (*parent)->addend = 0;
 	      (*parent)->howto = &none_howto;
 	      r = bfd_reloc_ok;
@@ -6373,6 +6586,15 @@
 		    goto error_return;
 		  break;
 		case bfd_reloc_outofrange:
+		  /* PR ld/13730:
+		     This error can result when processing some partially
+		     complete binaries.  Do not abort, but issue an error
+		     message instead.  */
+		  link_info->callbacks->einfo
+		    (_("%X%P: %B(%A): relocation \"%R\" goes out of range\n"),
+		     abfd, input_section, * parent);
+		  goto error_return;
+
 		default:
 		  abort ();
 		  break;
diff --git a/bfd/reloc16.c b/bfd/reloc16.c
index 768b288..31fc15d 100644
--- a/bfd/reloc16.c
+++ b/bfd/reloc16.c
@@ -1,6 +1,7 @@
 /* 8 and 16 bit COFF relocation functions, for BFD.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2001,
-   2002, 2003, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
+   2002, 2003, 2004, 2005, 2007, 2008, 2009, 2012
+   Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -43,10 +44,9 @@
 #include "libcoff.h"
 
 bfd_vma
-bfd_coff_reloc16_get_value (reloc, link_info, input_section)
-     arelent *reloc;
-     struct bfd_link_info *link_info;
-     asection *input_section;
+bfd_coff_reloc16_get_value (arelent *reloc,
+			    struct bfd_link_info *link_info,
+			    asection *input_section)
 {
   bfd_vma value;
   asymbol *symbol = *(reloc->sym_ptr_ptr);
@@ -104,11 +104,10 @@
 }
 
 void
-bfd_perform_slip (abfd, slip, input_section, value)
-     bfd *abfd;
-     unsigned int slip;
-     asection *input_section;
-     bfd_vma value;
+bfd_perform_slip (bfd *abfd,
+		  unsigned int slip,
+		  asection *input_section,
+		  bfd_vma value)
 {
   asymbol **s;
 
@@ -143,11 +142,10 @@
 }
 
 bfd_boolean
-bfd_coff_reloc16_relax_section (abfd, input_section, link_info, again)
-     bfd *abfd;
-     asection *input_section;
-     struct bfd_link_info *link_info;
-     bfd_boolean *again;
+bfd_coff_reloc16_relax_section (bfd *abfd,
+				asection *input_section,
+				struct bfd_link_info *link_info,
+				bfd_boolean *again)
 {
   /* Get enough memory to hold the stuff.  */
   bfd *input_bfd = input_section->owner;
@@ -247,18 +245,13 @@
 }
 
 bfd_byte *
-bfd_coff_reloc16_get_relocated_section_contents (in_abfd,
-						 link_info,
-						 link_order,
-						 data,
-						 relocatable,
-						 symbols)
-     bfd *in_abfd;
-     struct bfd_link_info *link_info;
-     struct bfd_link_order *link_order;
-     bfd_byte *data;
-     bfd_boolean relocatable;
-     asymbol **symbols;
+bfd_coff_reloc16_get_relocated_section_contents
+  (bfd *in_abfd,
+   struct bfd_link_info *link_info,
+   struct bfd_link_order *link_order,
+   bfd_byte *data,
+   bfd_boolean relocatable,
+   asymbol **symbols)
 {
   /* Get enough memory to hold the stuff.  */
   bfd *input_bfd = link_order->u.indirect.section->owner;
diff --git a/bfd/riscix.c b/bfd/riscix.c
index 0d07d01..7e24fd9 100644
--- a/bfd/riscix.c
+++ b/bfd/riscix.c
@@ -1,6 +1,6 @@
 /* BFD back-end for RISC iX (Acorn, arm) binaries.
    Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004,
-   2005, 2007, 2010 Free Software Foundation, Inc.
+   2005, 2007, 2010, 2012 Free Software Foundation, Inc.
    Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -207,7 +207,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;
 
@@ -341,10 +341,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/sco5-core.c b/bfd/sco5-core.c
index 2eea7ff..896a970 100644
--- a/bfd/sco5-core.c
+++ b/bfd/sco5-core.c
@@ -1,6 +1,6 @@
 /* BFD back end for SCO5 core files (U-area and raw sections)
    Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-   2010, 2011
+   2010, 2011, 2012
    Free Software Foundation, Inc.
    Written by Jouke Numan <jnuman@hiscom.nl>
 
@@ -45,24 +45,16 @@
 
 /* forward declarations */
 
-static asection *make_bfd_asection
-  PARAMS ((bfd *, const char *, flagword, bfd_size_type, bfd_vma, file_ptr));
-static struct user *read_uarea PARAMS ((bfd *, int));
-const bfd_target *sco5_core_file_p PARAMS ((bfd *abfd));
-char *sco5_core_file_failing_command PARAMS ((bfd *abfd));
-int sco5_core_file_failing_signal PARAMS ((bfd *abfd));
 #define sco5_core_file_matches_executable_p generic_core_file_matches_executable_p
 #define sco5_core_file_pid _bfd_nocore_core_file_pid
-static void swap_abort PARAMS ((void));
 
 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;
 
@@ -78,10 +70,7 @@
 }
 
 static struct user *
-read_uarea(abfd, filepos)
-     bfd *abfd;
-     int filepos;
-
+read_uarea (bfd *abfd, int filepos)
 {
   struct sco5_core_struct *rawptr;
   bfd_size_type amt = sizeof (struct sco5_core_struct);
@@ -115,8 +104,7 @@
 }
 
 const bfd_target *
-sco5_core_file_p (abfd)
-     bfd *abfd;
+sco5_core_file_p (bfd *abfd)
 {
   int coffset_siz, val, nsecs, cheadoffs;
   int coresize;
@@ -327,8 +315,7 @@
 }
 
 char *
-sco5_core_file_failing_command (abfd)
-     bfd *abfd;
+sco5_core_file_failing_command (bfd *abfd)
 {
   char *com = abfd->tdata.sco5_core_data->u.u_comm;
   if (*com)
@@ -338,8 +325,7 @@
 }
 
 int
-sco5_core_file_failing_signal (ignore_abfd)
-     bfd *ignore_abfd;
+sco5_core_file_failing_signal (bfd *ignore_abfd)
 {
   return ((ignore_abfd->tdata.sco5_core_data->u.u_sysabort != 0)
 	  ? ignore_abfd->tdata.sco5_core_data->u.u_sysabort
@@ -348,7 +334,7 @@
 
 /* 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 */
 }
@@ -408,5 +394,5 @@
 
     NULL,
 
-    (PTR) 0			/* backend_data */
+    NULL			/* backend_data */
   };
diff --git a/bfd/section.c b/bfd/section.c
index 7c1f750..a3b7c56 100644
--- a/bfd/section.c
+++ b/bfd/section.c
@@ -1,6 +1,7 @@
 /* Object file "section" support for the BFD library.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
+   2012
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -382,11 +383,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;
@@ -516,9 +517,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;
@@ -546,28 +544,25 @@
 .
 .{* 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 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 (&std_section[0])
+.{* Pointer to the undefined section.  *}
+.#define bfd_und_section_ptr (&std_section[1])
+.{* Pointer to the absolute section.  *}
+.#define bfd_abs_section_ptr (&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 (&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)		\
@@ -682,8 +677,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,			\
@@ -697,9 +692,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,				\
 .									\
@@ -715,10 +707,10 @@
  /* the_bfd, name, value, attr, section [, udata] */
 #ifdef __STDC__
 #define GLOBAL_SYM_INIT(NAME, SECTION) \
-  { 0, NAME, 0, BSF_SECTION_SYM, (asection *) SECTION, { 0 }}
+  { 0, NAME, 0, BSF_SECTION_SYM, SECTION, { 0 }}
 #else
 #define GLOBAL_SYM_INIT(NAME, SECTION) \
-  { 0, NAME, 0, BSF_SECTION_SYM, (asection *) SECTION }
+  { 0, NAME, 0, BSF_SECTION_SYM, SECTION }
 #endif
 
 /* These symbols are global, not specific to any BFD.  Therefore, anything
@@ -726,20 +718,21 @@
 
 static const asymbol global_syms[] =
 {
-  GLOBAL_SYM_INIT (BFD_COM_SECTION_NAME, &bfd_com_section),
-  GLOBAL_SYM_INIT (BFD_UND_SECTION_NAME, &bfd_und_section),
-  GLOBAL_SYM_INIT (BFD_ABS_SECTION_NAME, &bfd_abs_section),
-  GLOBAL_SYM_INIT (BFD_IND_SECTION_NAME, &bfd_ind_section)
+  GLOBAL_SYM_INIT (BFD_COM_SECTION_NAME, bfd_com_section_ptr),
+  GLOBAL_SYM_INIT (BFD_UND_SECTION_NAME, bfd_und_section_ptr),
+  GLOBAL_SYM_INIT (BFD_ABS_SECTION_NAME, bfd_abs_section_ptr),
+  GLOBAL_SYM_INIT (BFD_IND_SECTION_NAME, bfd_ind_section_ptr)
 };
 
-#define STD_SECTION(SEC, FLAGS, NAME, IDX)				\
-  asection SEC = BFD_FAKE_SECTION(SEC, FLAGS, &global_syms[IDX],	\
-				  NAME, IDX)
+#define STD_SECTION(NAME, IDX, FLAGS) \
+  BFD_FAKE_SECTION(std_section[IDX], FLAGS, &global_syms[IDX], NAME, IDX)
 
-STD_SECTION (bfd_com_section, SEC_IS_COMMON, BFD_COM_SECTION_NAME, 0);
-STD_SECTION (bfd_und_section, 0, BFD_UND_SECTION_NAME, 1);
-STD_SECTION (bfd_abs_section, 0, BFD_ABS_SECTION_NAME, 2);
-STD_SECTION (bfd_ind_section, 0, BFD_IND_SECTION_NAME, 3);
+asection std_section[] = {
+  STD_SECTION (BFD_COM_SECTION_NAME, 0, SEC_IS_COMMON),
+  STD_SECTION (BFD_UND_SECTION_NAME, 1, 0),
+  STD_SECTION (BFD_ABS_SECTION_NAME, 2, 0),
+  STD_SECTION (BFD_IND_SECTION_NAME, 3, 0)
+};
 #undef STD_SECTION
 
 /* Initialize an entry in the section hash table.  */
@@ -852,14 +845,8 @@
 	asection *bfd_get_section_by_name (bfd *abfd, const char *name);
 
 DESCRIPTION
-	Run through @var{abfd} and return the one of the
-	<<asection>>s whose name matches @var{name}, otherwise <<NULL>>.
-	@xref{Sections}, for more information.
-
-	This should only be used in special cases; the normal way to process
-	all sections of a given name is to use <<bfd_map_over_sections>> and
-	<<strcmp>> on the name (or better yet, base it on the section flags
-	or something else) for each section.
+	Return the most recently created section attached to @var{abfd}
+	named @var{name}.  Return NULL if no such section exists.
 */
 
 asection *
@@ -876,6 +863,63 @@
 
 /*
 FUNCTION
+       bfd_get_next_section_by_name
+
+SYNOPSIS
+       asection *bfd_get_next_section_by_name (asection *sec);
+
+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.
+*/
+
+asection *
+bfd_get_next_section_by_name (asection *sec)
+{
+  struct section_hash_entry *sh;
+  const char *name;
+  unsigned long hash;
+
+  sh = ((struct section_hash_entry *)
+	((char *) sec - offsetof (struct section_hash_entry, section)));
+
+  hash = sh->root.hash;
+  name = sec->name;
+  for (sh = (struct section_hash_entry *) sh->root.next;
+       sh != NULL;
+       sh = (struct section_hash_entry *) sh->root.next)
+    if (sh->root.hash == hash
+       && strcmp (sh->root.string, name) == 0)
+      return &sh->section;
+
+  return NULL;
+}
+
+/*
+FUNCTION
+	bfd_get_linker_section
+
+SYNOPSIS
+	asection *bfd_get_linker_section (bfd *abfd, const char *name);
+
+DESCRIPTION
+	Return the linker created section attached to @var{abfd}
+	named @var{name}.  Return NULL if no such section exists.
+*/
+
+asection *
+bfd_get_linker_section (bfd *abfd, const char *name)
+{
+  asection *sec = bfd_get_section_by_name (abfd, name);
+
+  while (sec != NULL && (sec->flags & SEC_LINKER_CREATED) == 0)
+    sec = bfd_get_next_section_by_name (sec);
+  return sec;
+}
+
+/*
+FUNCTION
 	bfd_get_section_by_name_if
 
 SYNOPSIS
diff --git a/bfd/som.c b/bfd/som.c
index 0726f84..efaf400 100644
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -1,7 +1,7 @@
 /* bfd back-end for HP PA-RISC SOM objects.
    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.
 
    Contributed by the Center for Software Science at the
    University of Utah.
@@ -23,8 +23,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"
diff --git a/bfd/som.h b/bfd/som.h
index c456abe..cf8dcbf 100644
--- a/bfd/som.h
+++ b/bfd/som.h
@@ -1,6 +1,6 @@
 /* HP PA-RISC SOM object file format:  definitions internal to BFD.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2001,
-   2002, 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+   2002, 2003, 2004, 2005, 2007, 2008, 2012 Free Software Foundation, Inc.
 
    Contributed by the Center for Software Science at the
    University of Utah (pa-gdb-bugs@cs.utah.edu).
@@ -63,7 +63,7 @@
       unsigned int hppa_arg_reloc;
       unsigned int hppa_priv_level;
     } ap;
-    PTR any;
+    void * any;
   }
   tc_data;
 
diff --git a/bfd/sparclinux.c b/bfd/sparclinux.c
index b7fef22..6edfeeb 100644
--- a/bfd/sparclinux.c
+++ b/bfd/sparclinux.c
@@ -1,6 +1,6 @@
 /* BFD back-end for linux flavored sparc 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.
@@ -49,15 +49,10 @@
    becomes important.  */
 
 static void MY_final_link_callback
-  PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *));
-
-static bfd_boolean sparclinux_bfd_final_link
-  PARAMS ((bfd *abfd, struct bfd_link_info *info));
+  (bfd *, file_ptr *, file_ptr *, file_ptr *);
 
 static bfd_boolean
-sparclinux_bfd_final_link (abfd, info)
-     bfd *abfd;
-     struct bfd_link_info *info;
+sparclinux_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);
@@ -67,11 +62,8 @@
 
 /* Set the machine type correctly.  */
 
-static bfd_boolean sparclinux_write_object_contents PARAMS ((bfd *abfd));
-
 static bfd_boolean
-sparclinux_write_object_contents (abfd)
-     bfd *abfd;
+sparclinux_write_object_contents (bfd *abfd)
 {
   struct external_exec exec_bytes;
   struct internal_exec *execp = exec_hdr (abfd);
@@ -170,31 +162,13 @@
   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;
 
@@ -221,8 +195,7 @@
 /* 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);
@@ -258,7 +231,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
@@ -269,11 +242,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;
 
@@ -299,12 +271,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;
@@ -326,18 +297,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;
@@ -548,9 +517,8 @@
    are required.  */
 
 bfd_boolean
-bfd_sparclinux_size_dynamic_sections (output_bfd, info)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
+bfd_sparclinux_size_dynamic_sections (bfd *output_bfd,
+				      struct bfd_link_info *info)
 {
   struct fixup *f;
   asection *s;
@@ -561,7 +529,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 +571,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;
@@ -755,7 +721,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/sparclynx.c b/bfd/sparclynx.c
index 93f9a87..c8a6aa0 100644
--- a/bfd/sparclynx.c
+++ b/bfd/sparclynx.c
@@ -1,6 +1,6 @@
 /* BFD support for Sparc binaries under LynxOS.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1998, 2000,
-   2001, 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
+   2001, 2002, 2003, 2005, 2007, 2012 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -37,15 +37,15 @@
 #include "aout/stab_gnu.h"
 #include "aout/ar.h"
 
-void NAME (lynx,set_arch_mach) PARAMS ((bfd *, unsigned long));
-static void choose_reloc_size PARAMS ((bfd *));
-static bfd_boolean NAME (aout,sparclynx_write_object_contents) PARAMS ((bfd *));
+void NAME (lynx,set_arch_mach) (bfd *, unsigned long);
+static void choose_reloc_size (bfd *);
+static bfd_boolean NAME (aout,sparclynx_write_object_contents) (bfd *);
 
 /* This is needed to reject a NewsOS file, e.g. in
    gdb/testsuite/gdb.t10/crossload.exp. <kingdon@cygnus.com>
    I needed to add M_UNKNOWN to recognize a 68000 object, so this will
    probably no longer reject a NewsOS object.  <ian@cygnus.com>.  */
-#define MACHTYPE_OK(mtype) ((mtype) == M_UNKNOWN \
+#define MACHTYPE_OK(mtype) (   (mtype) == M_UNKNOWN \
 			    || (mtype) == M_68010 \
 			    || (mtype) == M_68020 \
 			    || (mtype) == M_SPARC)
@@ -70,9 +70,7 @@
    @end table  */
 
 void
-NAME(lynx,set_arch_mach) (abfd, machtype)
-     bfd *abfd;
-     unsigned long machtype;
+NAME(lynx,set_arch_mach) (bfd *abfd, unsigned long machtype)
 {
   /* Determine the architecture and machine type of the object file.  */
   enum bfd_architecture arch;
@@ -130,8 +128,7 @@
 /* Determine the size of a relocation entry, based on the architecture.  */
 
 static void
-choose_reloc_size (abfd)
-     bfd *abfd;
+choose_reloc_size (bfd *abfd)
 {
   switch (bfd_get_arch (abfd))
     {
@@ -149,8 +146,7 @@
   file header, symbols, and relocation.  */
 
 static bfd_boolean
-NAME(aout,sparclynx_write_object_contents) (abfd)
-     bfd *abfd;
+NAME(aout,sparclynx_write_object_contents) (bfd *abfd)
 {
   struct external_exec exec_bytes;
   struct internal_exec *execp = exec_hdr (abfd);
@@ -190,11 +186,10 @@
 }
 
 #define MY_set_sizes sparclynx_set_sizes
-static bfd_boolean sparclynx_set_sizes PARAMS ((bfd *));
+static bfd_boolean sparclynx_set_sizes (bfd *);
 
 static bfd_boolean
-sparclynx_set_sizes (abfd)
-     bfd *abfd;
+sparclynx_set_sizes (bfd *abfd)
 {
   switch (bfd_get_arch (abfd))
     {
@@ -228,7 +223,7 @@
 #define MY_bfd_debug_info_start		bfd_void
 #define MY_bfd_debug_info_end		bfd_void
 #define MY_bfd_debug_info_accumulate	\
-		(void (*) PARAMS ((bfd *, struct bfd_section *))) bfd_void
+		(void (*) (bfd *, struct bfd_section *)) bfd_void
 
 #define MY_write_object_contents	NAME(aout,sparclynx_write_object_contents)
 #define MY_backend_data			&sparclynx_aout_backend
diff --git a/bfd/stab-syms.c b/bfd/stab-syms.c
index 9e9274f..8e65ddc 100644
--- a/bfd/stab-syms.c
+++ b/bfd/stab-syms.c
@@ -1,5 +1,5 @@
 /* Table of stab names for the BFD library.
-   Copyright 1990, 1991, 1992, 1994, 1995, 1996, 2000, 2005, 2007
+   Copyright 1990, 1991, 1992, 1994, 1995, 1996, 2000, 2005, 2007, 2012
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -20,6 +20,7 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
+#include "sysdep.h"
 #include "bfd.h"
 
 #define ARCH_SIZE 32		/* Value doesn't matter.  */
diff --git a/bfd/sunos.c b/bfd/sunos.c
index 8ef25ed..028fb28 100644
--- a/bfd/sunos.c
+++ b/bfd/sunos.c
@@ -1,6 +1,6 @@
 /* BFD backend for SunOS binaries.
    Copyright 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011
+   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -28,6 +28,7 @@
    the tokens.  */
 #define MY(OP) CONCAT2 (sunos_big_,OP)
 
+#include "sysdep.h"
 #include "bfd.h"
 #include "bfdlink.h"
 #include "libaout.h"
@@ -747,49 +748,53 @@
       /* The .dynamic section holds the basic dynamic information: the
 	 sun4_dynamic structure, the dynamic debugger information, and
 	 the sun4_dynamic_link structure.  */
-      s = bfd_make_section_with_flags (abfd, ".dynamic", flags);
+      s = bfd_make_section_anyway_with_flags (abfd, ".dynamic", flags);
       if (s == NULL
 	  || ! bfd_set_section_alignment (abfd, s, 2))
 	return FALSE;
 
       /* The .got section holds the global offset table.  The address
 	 is put in the ld_got field.  */
-      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, 2))
 	return FALSE;
 
       /* The .plt section holds the procedure linkage table.  The
 	 address is put in the ld_plt field.  */
-      s = bfd_make_section_with_flags (abfd, ".plt", flags | SEC_CODE);
+      s = bfd_make_section_anyway_with_flags (abfd, ".plt", flags | SEC_CODE);
       if (s == NULL
 	  || ! bfd_set_section_alignment (abfd, s, 2))
 	return FALSE;
 
       /* The .dynrel section holds the dynamic relocs.  The address is
 	 put in the ld_rel field.  */
-      s = bfd_make_section_with_flags (abfd, ".dynrel", flags | SEC_READONLY);
+      s = bfd_make_section_anyway_with_flags (abfd, ".dynrel",
+					      flags | SEC_READONLY);
       if (s == NULL
 	  || ! bfd_set_section_alignment (abfd, s, 2))
 	return FALSE;
 
       /* The .hash section holds the dynamic hash table.  The address
 	 is put in the ld_hash field.  */
-      s = bfd_make_section_with_flags (abfd, ".hash", flags | SEC_READONLY);
+      s = bfd_make_section_anyway_with_flags (abfd, ".hash",
+					      flags | SEC_READONLY);
       if (s == NULL
 	  || ! bfd_set_section_alignment (abfd, s, 2))
 	return FALSE;
 
       /* The .dynsym section holds the dynamic symbols.  The address
 	 is put in the ld_stab field.  */
-      s = bfd_make_section_with_flags (abfd, ".dynsym", flags | SEC_READONLY);
+      s = bfd_make_section_anyway_with_flags (abfd, ".dynsym",
+					      flags | SEC_READONLY);
       if (s == NULL
 	  || ! bfd_set_section_alignment (abfd, s, 2))
 	return FALSE;
 
       /* The .dynstr section holds the dynamic symbol string table.
 	 The address is put in the ld_symbols field.  */
-      s = bfd_make_section_with_flags (abfd, ".dynstr", flags | SEC_READONLY);
+      s = bfd_make_section_anyway_with_flags (abfd, ".dynstr",
+					      flags | SEC_READONLY);
       if (s == NULL
 	  || ! bfd_set_section_alignment (abfd, s, 2))
 	return FALSE;
@@ -804,7 +809,7 @@
 
       dynobj = sunos_hash_table (info)->dynobj;
 
-      s = bfd_get_section_by_name (dynobj, ".got");
+      s = bfd_get_linker_section (dynobj, ".got");
       if (s->size == 0)
 	s->size = BYTES_IN_WORD;
 
@@ -1324,11 +1329,11 @@
 	  if (! sunos_create_dynamic_sections (abfd, info, FALSE))
 	    return FALSE;
 	  dynobj = sunos_hash_table (info)->dynobj;
-	  splt = bfd_get_section_by_name (dynobj, ".plt");
-	  srel = bfd_get_section_by_name (dynobj, ".dynrel");
+	  splt = bfd_get_linker_section (dynobj, ".plt");
+	  srel = bfd_get_linker_section (dynobj, ".dynrel");
 	  BFD_ASSERT (splt != NULL && srel != NULL);
 
-	  sgot = bfd_get_section_by_name (dynobj, ".got");
+	  sgot = bfd_get_linker_section (dynobj, ".got");
 	  BFD_ASSERT (sgot != NULL);
 	  if (sgot->size == 0)
 	    sgot->size = BYTES_IN_WORD;
@@ -1474,9 +1479,9 @@
 	      if (! sunos_create_dynamic_sections (abfd, info, FALSE))
 		return FALSE;
 	      dynobj = sunos_hash_table (info)->dynobj;
-	      splt = bfd_get_section_by_name (dynobj, ".plt");
-	      sgot = bfd_get_section_by_name (dynobj, ".got");
-	      srel = bfd_get_section_by_name (dynobj, ".dynrel");
+	      splt = bfd_get_linker_section (dynobj, ".plt");
+	      sgot = bfd_get_linker_section (dynobj, ".got");
+	      srel = bfd_get_linker_section (dynobj, ".dynrel");
 	      BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
 
 	      /* Make sure we have an initial entry in the .got table.  */
@@ -1542,9 +1547,9 @@
 		  if (! sunos_create_dynamic_sections (abfd, info, TRUE))
 		    return FALSE;
 		  dynobj = sunos_hash_table (info)->dynobj;
-		  splt = bfd_get_section_by_name (dynobj, ".plt");
-		  sgot = bfd_get_section_by_name (dynobj, ".got");
-		  srel = bfd_get_section_by_name (dynobj, ".dynrel");
+		  splt = bfd_get_linker_section (dynobj, ".plt");
+		  sgot = bfd_get_linker_section (dynobj, ".got");
+		  srel = bfd_get_linker_section (dynobj, ".dynrel");
 		  BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
 		}
 
@@ -1589,9 +1594,9 @@
 	  if (! sunos_create_dynamic_sections (abfd, info, FALSE))
 	    return FALSE;
 	  dynobj = sunos_hash_table (info)->dynobj;
-	  splt = bfd_get_section_by_name (dynobj, ".plt");
-	  sgot = bfd_get_section_by_name (dynobj, ".got");
-	  srel = bfd_get_section_by_name (dynobj, ".dynrel");
+	  splt = bfd_get_linker_section (dynobj, ".plt");
+	  sgot = bfd_get_linker_section (dynobj, ".got");
+	  srel = bfd_get_linker_section (dynobj, ".dynrel");
 	  BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
 
 	  /* Make sure we have an initial entry in the .got table.  */
@@ -1814,7 +1819,7 @@
 	 regular symbols includes the debugging symbols, which have
 	 long names and are often duplicated in several object files.
 	 There are no debugging symbols in the dynamic symbols.  */
-      s = bfd_get_section_by_name (dynobj, ".dynstr");
+      s = bfd_get_linker_section (dynobj, ".dynstr");
       BFD_ASSERT (s != NULL);
       contents = bfd_realloc (s->contents, s->size + len + 1);
       if (contents == NULL)
@@ -1833,7 +1838,7 @@
       hash &= 0x7fffffff;
       hash %= sunos_hash_table (info)->bucketcount;
 
-      s = bfd_get_section_by_name (dynobj, ".hash");
+      s = bfd_get_linker_section (dynobj, ".hash");
       BFD_ASSERT (s != NULL);
 
       if (GET_SWORD (dynobj, s->contents + hash * HASH_ENTRY_SIZE) == -1)
@@ -1930,14 +1935,14 @@
 	  ++sunos_hash_table (info)->dynsymcount;
 	  h->dynindx = -2;
 	}
+      s = bfd_get_linker_section (dynobj, ".got");
+      BFD_ASSERT (s != NULL);
       h->root.root.type = bfd_link_hash_defined;
-      h->root.root.u.def.section = bfd_get_section_by_name (dynobj, ".got");
+      h->root.root.u.def.section = s;
 
       /* If the .got section is more than 0x1000 bytes, we set
 	 __GLOBAL_OFFSET_TABLE_ to be 0x1000 bytes into the section,
 	 so that 13 bit relocations have a greater chance of working.  */
-      s = bfd_get_section_by_name (dynobj, ".got");
-      BFD_ASSERT (s != NULL);
       if (s->size >= 0x1000)
 	h->root.root.u.def.value = 0x1000;
       else
@@ -1950,7 +1955,7 @@
      up the dynamic linking information.  */
   if (sunos_hash_table (info)->dynamic_sections_needed)
     {
-      *sdynptr = bfd_get_section_by_name (dynobj, ".dynamic");
+      *sdynptr = bfd_get_linker_section (dynobj, ".dynamic");
 
       /* The .dynamic section is always the same size.  */
       s = *sdynptr;
@@ -1967,7 +1972,7 @@
 	 symbols.  We build the dynamic symbol string table (.dynstr)
 	 in a traversal of the symbol table using
 	 sunos_scan_dynamic_symbol.  */
-      s = bfd_get_section_by_name (dynobj, ".dynsym");
+      s = bfd_get_linker_section (dynobj, ".dynsym");
       BFD_ASSERT (s != NULL);
       s->size = dynsymcount * sizeof (struct external_nlist);
       s->contents = bfd_alloc (output_bfd, s->size);
@@ -1988,7 +1993,7 @@
 	bucketcount = dynsymcount;
       else
 	bucketcount = 1;
-      s = bfd_get_section_by_name (dynobj, ".hash");
+      s = bfd_get_linker_section (dynobj, ".hash");
       BFD_ASSERT (s != NULL);
       hashalloc = (dynsymcount + bucketcount - 1) * HASH_ENTRY_SIZE;
       s->contents = bfd_zalloc (dynobj, hashalloc);
@@ -2012,7 +2017,7 @@
       /* The SunOS native linker seems to align the total size of the
 	 symbol strings to a multiple of 8.  I don't know if this is
 	 important, but it can't hurt much.  */
-      s = bfd_get_section_by_name (dynobj, ".dynstr");
+      s = bfd_get_linker_section (dynobj, ".dynstr");
       BFD_ASSERT (s != NULL);
       if ((s->size & 7) != 0)
 	{
@@ -2031,7 +2036,7 @@
 
   /* Now that we have worked out the sizes of the procedure linkage
      table and the dynamic relocs, allocate storage for them.  */
-  s = bfd_get_section_by_name (dynobj, ".plt");
+  s = bfd_get_linker_section (dynobj, ".plt");
   BFD_ASSERT (s != NULL);
   if (s->size != 0)
     {
@@ -2055,7 +2060,7 @@
 	}
     }
 
-  s = bfd_get_section_by_name (dynobj, ".dynrel");
+  s = bfd_get_linker_section (dynobj, ".dynrel");
   if (s->size != 0)
     {
       s->contents = bfd_alloc (dynobj, s->size);
@@ -2067,7 +2072,7 @@
   s->reloc_count = 0;
 
   /* Make space for the global offset table.  */
-  s = bfd_get_section_by_name (dynobj, ".got");
+  s = bfd_get_linker_section (dynobj, ".got");
   s->contents = bfd_alloc (dynobj, s->size);
   if (s->contents == NULL)
     return FALSE;
@@ -2113,10 +2118,10 @@
       bfd_vma r_address;
 
       dynobj = sunos_hash_table (info)->dynobj;
-      splt = bfd_get_section_by_name (dynobj, ".plt");
+      splt = bfd_get_linker_section (dynobj, ".plt");
       p = splt->contents + h->plt_offset;
 
-      s = bfd_get_section_by_name (dynobj, ".dynrel");
+      s = bfd_get_linker_section (dynobj, ".dynrel");
 
       r_address = (splt->output_section->vma
 		   + splt->output_offset
@@ -2300,7 +2305,7 @@
       return TRUE;
     }
 
-  s = bfd_get_section_by_name (sunos_hash_table (info)->dynobj, ".dynsym");
+  s = bfd_get_linker_section (sunos_hash_table (info)->dynobj, ".dynsym");
   BFD_ASSERT (s != NULL);
   outsym = ((struct external_nlist *)
 	    (s->contents + h->dynindx * EXTERNAL_NLIST_SIZE));
@@ -2355,7 +2360,7 @@
       asection *splt;
 
       /* Redirect the relocation to the PLT entry.  */
-      splt = bfd_get_section_by_name (dynobj, ".plt");
+      splt = bfd_get_linker_section (dynobj, ".plt");
       *relocationp = (splt->output_section->vma
 		      + splt->output_offset
 		      + h->plt_offset);
@@ -2450,7 +2455,7 @@
 
       BFD_ASSERT (got_offsetp != NULL && *got_offsetp != 0);
 
-      sgot = bfd_get_section_by_name (dynobj, ".got");
+      sgot = bfd_get_linker_section (dynobj, ".got");
 
       /* We set the least significant bit to indicate whether we have
 	 already initialized the GOT entry.  */
@@ -2472,7 +2477,7 @@
 	      /* We need to create a GLOB_DAT or 32 reloc to tell the
 		 dynamic linker to fill in this entry in the table.  */
 
-	      s = bfd_get_section_by_name (dynobj, ".dynrel");
+	      s = bfd_get_linker_section (dynobj, ".dynrel");
 	      BFD_ASSERT (s != NULL);
 	      BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj)
 			  < s->size);
@@ -2602,7 +2607,7 @@
 
   /* It looks like this is a reloc we are supposed to copy.  */
 
-  s = bfd_get_section_by_name (dynobj, ".dynrel");
+  s = bfd_get_linker_section (dynobj, ".dynrel");
   BFD_ASSERT (s != NULL);
   BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj) < s->size);
 
@@ -2700,7 +2705,7 @@
 
   dynobj = sunos_hash_table (info)->dynobj;
 
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
   BFD_ASSERT (sdyn != NULL);
 
   /* Finish up the .need section.  The linker emulation code filled it
@@ -2730,7 +2735,7 @@
 
   /* The first entry in the .got section is the address of the
      dynamic information, unless this is a shared library.  */
-  s = bfd_get_section_by_name (dynobj, ".got");
+  s = bfd_get_linker_section (dynobj, ".got");
   BFD_ASSERT (s != NULL);
   if (info->shared || sdyn->size == 0)
     PUT_WORD (dynobj, 0, s->contents);
@@ -2792,30 +2797,30 @@
 	PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
 		  esdl.ld_rules);
 
-      s = bfd_get_section_by_name (dynobj, ".got");
+      s = bfd_get_linker_section (dynobj, ".got");
       BFD_ASSERT (s != NULL);
       PUT_WORD (dynobj, s->output_section->vma + s->output_offset,
 		esdl.ld_got);
 
-      s = bfd_get_section_by_name (dynobj, ".plt");
+      s = bfd_get_linker_section (dynobj, ".plt");
       BFD_ASSERT (s != NULL);
       PUT_WORD (dynobj, s->output_section->vma + s->output_offset,
 		esdl.ld_plt);
       PUT_WORD (dynobj, s->size, esdl.ld_plt_sz);
 
-      s = bfd_get_section_by_name (dynobj, ".dynrel");
+      s = bfd_get_linker_section (dynobj, ".dynrel");
       BFD_ASSERT (s != NULL);
       BFD_ASSERT (s->reloc_count * obj_reloc_entry_size (dynobj)
 		  == s->size);
       PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
 		esdl.ld_rel);
 
-      s = bfd_get_section_by_name (dynobj, ".hash");
+      s = bfd_get_linker_section (dynobj, ".hash");
       BFD_ASSERT (s != NULL);
       PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
 		esdl.ld_hash);
 
-      s = bfd_get_section_by_name (dynobj, ".dynsym");
+      s = bfd_get_linker_section (dynobj, ".dynsym");
       BFD_ASSERT (s != NULL);
       PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
 		esdl.ld_stab);
@@ -2825,7 +2830,7 @@
       PUT_WORD (dynobj, (bfd_vma) sunos_hash_table (info)->bucketcount,
 		esdl.ld_buckets);
 
-      s = bfd_get_section_by_name (dynobj, ".dynstr");
+      s = bfd_get_linker_section (dynobj, ".dynstr");
       BFD_ASSERT (s != NULL);
       PUT_WORD (dynobj, s->output_section->filepos + s->output_offset,
 		esdl.ld_symbols);
diff --git a/bfd/syms.c b/bfd/syms.c
index e819eae..bf5a488 100644
--- a/bfd/syms.c
+++ b/bfd/syms.c
@@ -1,6 +1,6 @@
 /* Generic symbol-table support for the BFD library.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
+   2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2012
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -107,6 +107,7 @@
 	which has been created using <<bfd_make_empty_symbol>>.  Here is an
 	example showing the creation of a symbol table with only one element:
 
+|	#include "sysdep.h"
 |	#include "bfd.h"
 |	int main (void)
 |	{
diff --git a/bfd/sysdep.h b/bfd/sysdep.h
index 20ef56d..b4fed10 100644
--- a/bfd/sysdep.h
+++ b/bfd/sysdep.h
@@ -23,6 +23,10 @@
 #ifndef BFD_SYSDEP_H
 #define BFD_SYSDEP_H
 
+#ifdef PACKAGE
+#error sysdep.h must be included in lieu of config.h
+#endif
+
 #include "config.h"
 
 #include "ansidecl.h"
diff --git a/bfd/targets.c b/bfd/targets.c
index 4cf8e8f..cfa91a8 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -1,6 +1,6 @@
 /* Generic target-file-type support for the BFD library.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
@@ -497,8 +497,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 *);
@@ -596,6 +597,7 @@
 extern const bfd_target bfd_elf32_big_generic_vec;
 extern const bfd_target bfd_elf32_bigarc_vec;
 extern const bfd_target bfd_elf32_bigarm_vec;
+extern const bfd_target bfd_elf32_bigarm_nacl_vec;
 extern const bfd_target bfd_elf32_bigarm_symbian_vec;
 extern const bfd_target bfd_elf32_bigarm_vxworks_vec;
 extern const bfd_target bfd_elf32_bigmips_vec;
@@ -634,6 +636,7 @@
 extern const bfd_target bfd_elf32_little_generic_vec;
 extern const bfd_target bfd_elf32_littlearc_vec;
 extern const bfd_target bfd_elf32_littlearm_vec;
+extern const bfd_target bfd_elf32_littlearm_nacl_vec;
 extern const bfd_target bfd_elf32_littlearm_symbian_vec;
 extern const bfd_target bfd_elf32_littlearm_vxworks_vec;
 extern const bfd_target bfd_elf32_littlemips_vec;
@@ -704,7 +707,8 @@
 extern const bfd_target bfd_elf32_tic6x_elf_le_vec;
 extern const bfd_target bfd_elf32_tic6x_linux_be_vec;
 extern const bfd_target bfd_elf32_tic6x_linux_le_vec;
-extern const bfd_target bfd_elf32_tilegx_vec;
+extern const bfd_target bfd_elf32_tilegx_be_vec;
+extern const bfd_target bfd_elf32_tilegx_le_vec;
 extern const bfd_target bfd_elf32_tilepro_vec;
 extern const bfd_target bfd_elf32_tradbigmips_vec;
 extern const bfd_target bfd_elf32_tradlittlemips_vec;
@@ -714,6 +718,7 @@
 extern const bfd_target bfd_elf32_v850_vec;
 extern const bfd_target bfd_elf32_vax_vec;
 extern const bfd_target bfd_elf32_xc16x_vec;
+extern const bfd_target bfd_elf32_xgate_vec;
 extern const bfd_target bfd_elf32_xstormy16_vec;
 extern const bfd_target bfd_elf32_xtensa_be_vec;
 extern const bfd_target bfd_elf32_xtensa_le_vec;
@@ -743,14 +748,17 @@
 extern const bfd_target bfd_elf64_sparc_vec;
 extern const bfd_target bfd_elf64_sparc_freebsd_vec;
 extern const bfd_target bfd_elf64_sparc_sol2_vec;
-extern const bfd_target bfd_elf64_tilegx_vec;
+extern const bfd_target bfd_elf64_tilegx_be_vec;
+extern const bfd_target bfd_elf64_tilegx_le_vec;
 extern const bfd_target bfd_elf64_tradbigmips_vec;
 extern const bfd_target bfd_elf64_tradlittlemips_vec;
 extern const bfd_target bfd_elf64_tradbigmips_freebsd_vec;
 extern const bfd_target bfd_elf64_tradlittlemips_freebsd_vec;
 extern const bfd_target bfd_elf64_x86_64_freebsd_vec;
+extern const bfd_target bfd_elf64_x86_64_nacl_vec;
 extern const bfd_target bfd_elf64_x86_64_sol2_vec;
 extern const bfd_target bfd_elf64_x86_64_vec;
+extern const bfd_target bfd_elf32_x86_64_nacl_vec;
 extern const bfd_target bfd_elf32_x86_64_vec;
 extern const bfd_target bfd_elf64_l1om_freebsd_vec;
 extern const bfd_target bfd_elf64_l1om_vec;
@@ -1073,7 +1081,8 @@
 	&bfd_elf32_spu_vec,
 	&bfd_elf32_tic6x_be_vec,
 	&bfd_elf32_tic6x_le_vec,
-	&bfd_elf32_tilegx_vec,
+	&bfd_elf32_tilegx_be_vec,
+	&bfd_elf32_tilegx_le_vec,
 	&bfd_elf32_tilepro_vec,
 	&bfd_elf32_tradbigmips_vec,
 	&bfd_elf32_tradlittlemips_vec,
@@ -1083,6 +1092,7 @@
 	&bfd_elf32_v850_vec,
 	&bfd_elf32_vax_vec,
 	&bfd_elf32_xc16x_vec,
+	&bfd_elf32_xgate_vec,
 	&bfd_elf32_xstormy16_vec,
 	&bfd_elf32_xtensa_be_vec,
 	&bfd_elf32_xtensa_le_vec,
@@ -1113,14 +1123,17 @@
 	&bfd_elf64_sparc_vec,
 	&bfd_elf64_sparc_freebsd_vec,
 	&bfd_elf64_sparc_sol2_vec,
-	&bfd_elf64_tilegx_vec,
+	&bfd_elf64_tilegx_be_vec,
+	&bfd_elf64_tilegx_le_vec,
 	&bfd_elf64_tradbigmips_vec,
 	&bfd_elf64_tradlittlemips_vec,
 	&bfd_elf64_tradbigmips_freebsd_vec,
 	&bfd_elf64_tradlittlemips_freebsd_vec,
 	&bfd_elf64_x86_64_freebsd_vec,
+	&bfd_elf64_x86_64_nacl_vec,
 	&bfd_elf64_x86_64_sol2_vec,
 	&bfd_elf64_x86_64_vec,
+	&bfd_elf32_x86_64_nacl_vec,
 	&bfd_elf32_x86_64_vec,
 	&bfd_elf64_l1om_freebsd_vec,
 	&bfd_elf64_l1om_vec,
diff --git a/bfd/ticoff.h b/bfd/ticoff.h
index e2c9316..d34ca21 100644
--- a/bfd/ticoff.h
+++ b/bfd/ticoff.h
@@ -21,9 +21,8 @@
 #define	F_LSYMS		F_LSYMS_TICOFF
 
 static bfd_boolean
-ticoff0_bad_format_hook (abfd, filehdr)
-     bfd *abfd;
-     PTR filehdr;
+ticoff0_bad_format_hook (bfd * abfd,
+			 void * filehdr)
 {
   struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
 
@@ -34,9 +33,8 @@
 }
 
 static bfd_boolean
-ticoff1_bad_format_hook (abfd, filehdr)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     PTR filehdr;
+ticoff1_bad_format_hook (bfd * abfd ATTRIBUTE_UNUSED,
+			 void * filehdr)
 {
   struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
 
@@ -49,9 +47,8 @@
 /* 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;
diff --git a/bfd/trad-core.c b/bfd/trad-core.c
index 4b9d14d..da52c31 100644
--- a/bfd/trad-core.c
+++ b/bfd/trad-core.c
@@ -1,6 +1,6 @@
 /* BFD back end for traditional Unix core files (U-area and raw sections)
    Copyright 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2011
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2011, 2012
    Free Software Foundation, Inc.
    Written by John Gilmore of Cygnus Support.
 
@@ -60,26 +60,21 @@
   struct user u;
 };
 
-#define core_upage(bfd) (&((bfd)->tdata.trad_core_data->u))
-#define core_datasec(bfd) ((bfd)->tdata.trad_core_data->data_section)
+#define core_upage(bfd)  (&((bfd)->tdata.trad_core_data->u))
+#define core_datasec(bfd)  ((bfd)->tdata.trad_core_data->data_section)
 #define core_stacksec(bfd) ((bfd)->tdata.trad_core_data->stack_section)
-#define core_regsec(bfd) ((bfd)->tdata.trad_core_data->reg_section)
+#define core_regsec(bfd)   ((bfd)->tdata.trad_core_data->reg_section)
 
 /* forward declarations */
 
-const bfd_target *trad_unix_core_file_p PARAMS ((bfd *abfd));
-char * trad_unix_core_file_failing_command PARAMS ((bfd *abfd));
-int trad_unix_core_file_failing_signal PARAMS ((bfd *abfd));
 #define trad_unix_core_file_matches_executable_p generic_core_file_matches_executable_p
 #define trad_unix_core_file_pid _bfd_nocore_core_file_pid
-static void swap_abort PARAMS ((void));
+
 
 /* Handle 4.2-style (and perhaps also sysV-style) core dump file.  */
 
-const bfd_target *
-trad_unix_core_file_p (abfd)
-     bfd *abfd;
-
+static const bfd_target *
+trad_unix_core_file_p (bfd *abfd)
 {
   int val;
   struct user u;
@@ -236,9 +231,8 @@
   return NULL;
 }
 
-char *
-trad_unix_core_file_failing_command (abfd)
-     bfd *abfd;
+static char *
+trad_unix_core_file_failing_command (bfd *abfd)
 {
 #ifndef NO_CORE_COMMAND
   char *com = abfd->tdata.trad_core_data->u.u_comm;
@@ -249,9 +243,8 @@
     return 0;
 }
 
-int
-trad_unix_core_file_failing_signal (ignore_abfd)
-     bfd *ignore_abfd ATTRIBUTE_UNUSED;
+static int
+trad_unix_core_file_failing_signal (bfd *ignore_abfd ATTRIBUTE_UNUSED)
 {
 #ifdef TRAD_UNIX_CORE_FILE_FAILING_SIGNAL
   return TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(ignore_abfd);
@@ -262,7 +255,7 @@
 
 /* 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 */
 }
@@ -322,5 +315,5 @@
 
     NULL,
 
-    (PTR) 0			/* backend_data */
+    NULL			/* backend_data */
   };
diff --git a/bfd/versados.c b/bfd/versados.c
index 7f7766a..ae6f671 100644
--- a/bfd/versados.c
+++ b/bfd/versados.c
@@ -1,6 +1,6 @@
 /* BFD back-end for VERSAdos-E objects.
    Copyright 1995, 1996, 1998, 1999, 2000, 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 of Cygnus Support <sac@cygnus.com>.
 
    Versados is a Motorola trademark.
@@ -287,7 +287,7 @@
 	  sec->flags |= SEC_ALLOC;
 	  break;
 	case ESD_XDEF_IN_ABS:
-	  sec = (asection *) & bfd_abs_section;
+	  sec = bfd_abs_section_ptr;
 	case ESD_XDEF_IN_SEC:
 	  {
 	    int snum = VDATA (abfd)->def_idx++;
@@ -768,7 +768,7 @@
 	  int esdid = (int) (size_t) src[count].sym_ptr_ptr;
 
 	  if (esdid == 0)
-	    src[count].sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+	    src[count].sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
 	  else if (esdid < ES_BASE)
 	    {
 	      /* Section relative thing.  */
diff --git a/bfd/version.h b/bfd/version.h
index f246094..ecf6d14 100644
--- a/bfd/version.h
+++ b/bfd/version.h
@@ -1,4 +1,4 @@
-#define BFD_VERSION_DATE 20111213
+#define BFD_VERSION_DATE 20120718
 #define BFD_VERSION @bfd_version@
 #define BFD_VERSION_STRING  @bfd_version_package@ @bfd_version_string@
 #define REPORT_BUGS_TO @report_bugs_to@
diff --git a/bfd/vms-lib.c b/bfd/vms-lib.c
index b325d74..fa23b78 100644
--- a/bfd/vms-lib.c
+++ b/bfd/vms-lib.c
@@ -35,7 +35,8 @@
 #endif
 
 /* Maximum key length (which is also the maximum symbol length in archive).  */
-#define MAX_KEYLEN 129
+#define MAX_KEYLEN 128
+#define MAX_EKEYLEN 1024
 
 /* DCX Submaps.  */
 
@@ -277,6 +278,9 @@
       if (idx_vbn == 0)
         return FALSE;
 
+      /* Point to the next index entry.  */
+      p = keyname + keylen;
+
       if (idx_off == RFADEF__C_INDEX)
         {
           /* Indirect entry.  Recurse.  */
@@ -368,9 +372,6 @@
                 return FALSE;
             }
         }
-
-      /* Point to the next index entry.  */
-      p = keyname + keylen;
     }
 
   return TRUE;
@@ -1295,6 +1296,7 @@
   struct lib_tdata *tdata = bfd_libdata (abfd);
   bfd *res;
   file_ptr file_off;
+  char *name;
 
   /* Sanity check.  */
   if (modidx >= tdata->nbr_modules)
@@ -1356,7 +1358,25 @@
       res->origin = file_off + tdata->mhd_size;
     }
 
-  res->filename = tdata->modules[modidx].name;
+  /* Set filename.  */
+  name = tdata->modules[modidx].name;
+  switch (tdata->type)
+    {
+    case LBR__C_TYP_IOBJ:
+    case LBR__C_TYP_EOBJ:
+      /* For object archives, append .obj to mimic standard behaviour.  */
+      {
+	size_t namelen = strlen (name);
+	char *name1 = bfd_alloc (res, namelen + 4 + 1);
+	memcpy (name1, name, namelen);
+	strcpy (name1 + namelen, ".obj");
+	name = name1;
+      }
+      break;
+    default:
+      break;
+    }
+  res->filename = name;
 
   tdata->cache[modidx] = res;
 
@@ -1567,15 +1587,23 @@
                  struct lib_index *idx, unsigned int nbr, unsigned int *vbn,
                  unsigned int *topvbn, bfd_boolean is_elfidx)
 {
+  /* The index is organized as a tree.  This function implements a naive
+     algorithm to balance the tree: it fills the leaves, and create a new
+     branch when all upper leaves and branches are full.  We only keep in
+     memory a path to the current leaf.  */
   unsigned int i;
   int j;
   int level;
+  /* Disk blocks for the current path.  */
   struct vms_indexdef *rblk[MAX_LEVEL];
+  /* Info on the current blocks.  */
   struct idxblk
   {
-    unsigned int vbn;
-    unsigned short len;
-    unsigned short lastlen;
+    unsigned int vbn;		/* VBN of the block.  */
+    /* The last entry is identified so that it could be copied to the
+       parent block.  */
+    unsigned short len;		/* Length up to the last entry.  */
+    unsigned short lastlen;	/* Length of the last entry.  */
   } blk[MAX_LEVEL];
 
   /* The kbn blocks are used to store long symbol names.  */
@@ -1614,7 +1642,7 @@
 
       idxlen = get_idxlen (idx, is_elfidx);
 
-      if (is_elfidx && idx->namlen >= MAX_KEYLEN)
+      if (is_elfidx && idx->namlen > MAX_KEYLEN)
         {
           /* If the key (ie name) is too long, write it in the kbn block.  */
           unsigned int kl = idx->namlen;
@@ -1693,7 +1721,7 @@
          block and all the blocks below it.  */
       for (j = 0; j < level; j++)
         if (blk[j].len + blk[j].lastlen + idxlen > INDEXDEF__BLKSIZ)
-          flush = j + 1;
+	  flush = j + 1;
 
       for (j = 0; j < level; j++)
         {
@@ -1714,23 +1742,25 @@
                     }
                   blk[level].vbn = (*vbn)++;
                   blk[level].len = 0;
-                  blk[level].lastlen = 0;
+                  blk[level].lastlen = blk[j].lastlen;
 
                   level++;
                 }
 
-              /* Update parent block: write the new entry.  */
+              /* Update parent block: write the last entry from the current
+		 block.  */
               if (abfd != NULL)
                 {
                   struct vms_rfa *rfa;
 
+		  /* Pointer to the last entry in parent block.  */
+		  rfa = (struct vms_rfa *)(rblk[j + 1]->keys + blk[j + 1].len);
+
                   /* Copy the whole entry.  */
-                  memcpy (rblk[j + 1]->keys + blk[j + 1].len,
-                          rblk[j]->keys + blk[j].len,
-                          blk[j].lastlen);
+		  BFD_ASSERT (blk[j + 1].lastlen == blk[j].lastlen);
+                  memcpy (rfa, rblk[j]->keys + blk[j].len, blk[j].lastlen);
                   /* Fix the entry (which in always the first field of an
 		     entry.  */
-                  rfa = (struct vms_rfa *)(rblk[j + 1]->keys + blk[j + 1].len);
                   bfd_putl32 (blk[j].vbn, rfa->vbn);
                   bfd_putl16 (RFADEF__C_INDEX, rfa->offset);
                 }
@@ -1740,7 +1770,7 @@
                   /* And allocate it.  Do it only on the block that won't be
                      flushed (so that the parent of the parent can be
                      updated too).  */
-                  blk[j + 1].len += blk[j].lastlen;
+                  blk[j + 1].len += blk[j + 1].lastlen;
                   blk[j + 1].lastlen = 0;
                 }
 
@@ -1761,6 +1791,7 @@
           /* Append it to the block.  */
           if (j == 0)
             {
+	      /* Keep the previous last entry.  */
               blk[j].len += blk[j].lastlen;
 
               if (abfd != NULL)
@@ -1805,12 +1836,14 @@
                       memcpy (en->keyname, idx->name, idx->namlen);
                     }
                 }
-            }
-
-          blk[j].lastlen = idxlen;
+	    }
+	  /* The last added key can now be the last one all blocks in the
+	     path.  */
+	  blk[j].lastlen = idxlen;
         }
     }
 
+  /* Save VBN of the root.  */
   if (topvbn != NULL)
     *topvbn = blk[level - 1].vbn;
 
@@ -1827,6 +1860,7 @@
 
       en = rblk[j - 1]->keys + blk[j - 1].len;
       par = rblk[j]->keys + blk[j].len;
+      BFD_ASSERT (blk[j].lastlen == blk[j - 1].lastlen);
       memcpy (par, en, blk[j - 1].lastlen);
       rfa = (struct vms_rfa *)par;
       bfd_putl32 (blk[j - 1].vbn, rfa->vbn);
@@ -1848,6 +1882,7 @@
     {
       if (vms_write_block (abfd, kbn_vbn, kbn_blk) != TRUE)
         return FALSE;
+      free (kbn_blk);
     }
 
   return TRUE;
@@ -2006,6 +2041,7 @@
   unsigned int mod_idx_vbn;
   unsigned int sym_idx_vbn;
   bfd_boolean is_elfidx = tdata->kind == vms_lib_ia64;
+  unsigned int max_keylen = is_elfidx ? MAX_EKEYLEN : MAX_KEYLEN;
 
   /* Count the number of modules (and do a first sanity check).  */
   nbr_modules = 0;
@@ -2037,7 +2073,7 @@
        current != NULL;
        current = current->archive_next, i++)
     {
-      int nl;
+      unsigned int nl;
 
       modules[i].abfd = current;
       modules[i].name = vms_get_module_name (current->filename, FALSE);
@@ -2045,7 +2081,7 @@
 
       /* FIXME: silently truncate long names ?  */
       nl = strlen (modules[i].name);
-      modules[i].namlen = (nl > MAX_KEYLEN ? MAX_KEYLEN : nl);
+      modules[i].namlen = (nl > max_keylen ? max_keylen : nl);
     }
 
   /* Create the module index.  */
@@ -2236,20 +2272,27 @@
     bfd_putl32 (nbr_modules, lhd->modcnt);
     bfd_putl32 (nbr_modules, lhd->modhdrs);
 
+    /* Number of blocks for index.  */
+    bfd_putl32 (nbr_mod_iblk + nbr_sym_iblk, lhd->idxblks);
     bfd_putl32 (vbn - 1, lhd->hipreal);
     bfd_putl32 (vbn - 1, lhd->hiprusd);
 
+    /* VBN of the next free block.  */
+    bfd_putl32 ((off / VMS_BLOCK_SIZE) + 1, lhd->nextvbn);
+    bfd_putl32 ((off / VMS_BLOCK_SIZE) + 1, lhd->nextrfa + 0);
+    bfd_putl16 (0, lhd->nextrfa + 4);
+
     /* First index (modules name).  */
     idd_flags = IDD__FLAGS_ASCII | IDD__FLAGS_VARLENIDX
       | IDD__FLAGS_NOCASECMP | IDD__FLAGS_NOCASENTR;
     bfd_putl16 (idd_flags, idd->flags);
-    bfd_putl16 (MAX_KEYLEN, idd->keylen);
+    bfd_putl16 (max_keylen + 1, idd->keylen);
     bfd_putl16 (mod_idx_vbn, idd->vbn);
     idd++;
 
     /* Second index (symbols name).  */
     bfd_putl16 (idd_flags, idd->flags);
-    bfd_putl16 (MAX_KEYLEN, idd->keylen);
+    bfd_putl16 (max_keylen + 1, idd->keylen);
     bfd_putl16 (sym_idx_vbn, idd->vbn);
     idd++;
 
@@ -2303,5 +2346,5 @@
 
   NULL,
 
-  (PTR) 0
+  NULL
 };
diff --git a/bfd/xsym.c b/bfd/xsym.c
index 01434e1..e0819a9 100644
--- a/bfd/xsym.c
+++ b/bfd/xsym.c
@@ -1,6 +1,6 @@
 /* xSYM symbol-file support for BFD.
    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.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -19,8 +19,10 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
    MA 02110-1301, USA.  */
 
-#include "alloca-conf.h"
+/* xSYM is the debugging format used by CodeWarrior on Mac OS classic.  */
+
 #include "sysdep.h"
+#include "alloca-conf.h"
 #include "xsym.h"
 #include "bfd.h"
 #include "libbfd.h"
diff --git a/bfd/xsym.h b/bfd/xsym.h
index 85e173a..87c4546 100644
--- a/bfd/xsym.h
+++ b/bfd/xsym.h
@@ -1,5 +1,5 @@
 /* xSYM symbol-file support for BFD.
-   Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007
+   Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2012
    Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -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>
 
@@ -549,7 +550,7 @@
 extern bfd_boolean bfd_sym_mkobject
   (bfd *);
 extern void bfd_sym_print_symbol
-  (bfd *, PTR, asymbol *, bfd_print_symbol_type);
+  (bfd *, void *, asymbol *, bfd_print_symbol_type);
 extern bfd_boolean bfd_sym_valid
   (bfd *);
 extern unsigned char * bfd_sym_read_name_table
diff --git a/config.sub b/config.sub
index 78176a4..59bb593 100755
--- a/config.sub
+++ b/config.sub
@@ -2,9 +2,9 @@
 # Configuration validation subroutine script.
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
 #   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-#   2011 Free Software Foundation, Inc.
+#   2011, 2012 Free Software Foundation, Inc.
 
-timestamp='2011-10-29'
+timestamp='2012-04-18'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -21,9 +21,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
-# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-# 02110-1301, USA.
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -76,8 +74,8 @@
 GNU config.sub ($timestamp)
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free
-Software Foundation, Inc.
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
+Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -132,6 +130,10 @@
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
+  android-linux)
+    os=-linux-android
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
+    ;;
   *)
     basic_machine=`echo $1 | sed 's/-[^-]*$//'`
     if [ $basic_machine != $1 ]
@@ -223,6 +225,12 @@
 	-isc*)
 		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
 		;;
+	-lynx*178)
+		os=-lynxos178
+		;;
+	-lynx*5)
+		os=-lynxos5
+		;;
 	-lynx*)
 		os=-lynxos
 		;;
@@ -247,6 +255,7 @@
 	# Some are omitted here because they have special meanings below.
 	1750a | 580 \
 	| a29k \
+	| aarch64 | aarch64_be \
 	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
 	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
 	| am33_2.0 \
@@ -319,8 +328,7 @@
 	c6x)
 		basic_machine=tic6x-unknown
 		;;
-	m6811 | m68hc11 | m6812 | m68hc12 | picochip)
-		# Motorola 68HC11/12.
+	m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
 		basic_machine=$basic_machine-unknown
 		os=-none
 		;;
@@ -333,7 +341,10 @@
 	strongarm | thumb | xscale)
 		basic_machine=arm-unknown
 		;;
-
+	xgate)
+		basic_machine=$basic_machine-unknown
+		os=-none
+		;;
 	xscaleeb)
 		basic_machine=armeb-unknown
 		;;
@@ -356,6 +367,7 @@
 	# Recognize the basic CPU types with company name.
 	580-* \
 	| a29k-* \
+	| aarch64-* | aarch64_be-* \
 	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
 	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
 	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
@@ -719,7 +731,6 @@
 	i370-ibm* | ibm*)
 		basic_machine=i370-ibm
 		;;
-# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
 	i*86v32)
 		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
 		os=-sysv32
@@ -816,6 +827,10 @@
 	ms1-*)
 		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
 		;;
+	msys)
+		basic_machine=i386-pc
+		os=-msys
+		;;
 	mvs)
 		basic_machine=i370-ibm
 		os=-mvs
@@ -1343,7 +1358,7 @@
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -chorusos* | -chorusrdb* | -cegcc* \
-	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
 	      | -mingw32* | -linux-gnu* | -linux-android* \
 	      | -linux-newlib* | -linux-uclibc* \
 	      | -uxpv* | -beos* | -mpeix* | -udk* \
@@ -1555,9 +1570,6 @@
 		;;
 	m68000-sun)
 		os=-sunos3
-		# This also exists in the configure program, but was not the
-		# default.
-		# os=-sunos4
 		;;
 	m68*-cisco)
 		os=-aout
diff --git a/config/ChangeLog b/config/ChangeLog
index ea203bc..42fcfce 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,62 @@
+2012-05-29  Joseph Myers  <joseph@codesourcery.com>
+
+	* mt-sde: Fix typos.
+	* stdint.m4: Fix typos.
+	* tcl.m4: Fix typos.
+
+2012-04-03  Tristan Gingold  <gingold@adacore.com>
+
+	* mmap.m4: Use *vms* instead of vms*.
+
+2012-04-02  Tristan Gingold  <gingold@adacore.com>
+
+	* math.m4 (GCC_CHECK_MATH_FUNC): Remove if-present
+	argument.  Define the variable.
+
+2012-03-26  Tristan Gingold  <gingold@adacore.com>
+
+	* math.m4: New file.
+
+2012-03-12  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+	* weakref.m4 (GCC_CHECK_ELF_STYLE_WEAKREF): Remove
+	alpha*-dec-osf*.
+
+2012-01-22  Douglas B Rupp  <rupp@gnat.com>
+
+	* config/mh-interix: Remove as unneeded.
+	* config/picflag.m4 (i[[34567]]86-*-interix3*):
+        Change triplet to i[[34567]]86-*-interix[[3-9]]*.
+
+2012-01-04  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
+
+	PR bootstrap/51734
+	* picflag.m4: Remove s390 case statement.
+
+2011-12-20  Andreas Schwab  <schwab@linux-m68k.org>
+
+	* warnings.m4 (ACX_PROG_CC_WARNING_OPTS): Avoid leading dash in
+	expr call.
+
+2011-12-19  Andreas Schwab  <schwab@linux-m68k.org>
+
+	PR bootstrap/51388
+	* warnings.m4 (ACX_PROG_CC_WARNING_OPTS)
+	(ACX_PROG_CC_WARNING_ALMOST_PEDANTIC): Run the test without the
+	no- prefix.
+
+2011-12-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+	* acx.m4 (Test for GNAT): Update comment and add quotes in final test.
+
+2011-11-22  Iain Sandoe  <iains@gcc.gnu.org>
+
+	* weakref.m4: New file.
+
+2011-11-09  Richard Henderson  <rth@redhat.com>
+
+	* asmcfi.m4: New file.
+
 2011-11-02  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
 	* mh-interix (LIBGCC2_DEBUG_CFLAGS): Remove.
@@ -10,6 +69,15 @@
 
 	* elf.m4 (target_elf): Remove *-netware*.
 
+2011-07-06  Uros Bizjak  <ubizjak@gmail.com>
+
+	* mt-alphaieee (GOCFLAGS_FOR_TARGET): Add -mieee.
+
+2011-06-15  Mike Stump  <mikestump@comcast.net>
+
+	PR target/49461
+	* mh-darwin: Turn off -pie on darwin11 and later.
+
 2011-04-20  Eric Botcazou  <ebotcazou@adacore.com>
 
 	* bootstrap-lto.mk: Remove obsolete requirement.
diff --git a/config/acx.m4 b/config/acx.m4
index b559c03..9ff31eb 100644
--- a/config/acx.m4
+++ b/config/acx.m4
@@ -356,9 +356,9 @@
 ac_c_preproc_warn_flag=yes])# AC_PROG_CPP_WERROR
 
 # Test for GNAT.
-# We require the gnatbind program, and a compiler driver that
-# understands Ada.  We use the user's CC setting, already found,
-# and possibly add $1 to the command-line parameters.
+# We require the gnatbind & gnatmake programs, as well as a compiler driver
+# that understands Ada.  We use the user's CC setting, already found, and
+# possibly add $1 to the command-line parameters.
 #
 # Sets the shell variable have_gnat to yes or no as appropriate, and
 # substitutes GNATBIND and GNATMAKE.
@@ -387,7 +387,7 @@
 fi
 rm -f conftest.*])
 
-if test x$GNATBIND != xno && test x$GNATMAKE != xno && test x$acx_cv_cc_gcc_supports_ada != xno; then
+if test "x$GNATBIND" != xno && test "x$GNATMAKE" != xno && test x$acx_cv_cc_gcc_supports_ada != xno; then
   have_gnat=yes
 else
   have_gnat=no
diff --git a/config/asmcfi.m4 b/config/asmcfi.m4
new file mode 100644
index 0000000..a725aa1
--- /dev/null
+++ b/config/asmcfi.m4
@@ -0,0 +1,15 @@
+;; Cribbed from libffi
+
+AC_DEFUN([GCC_AS_CFI_PSEUDO_OP],
+[AC_CACHE_CHECK([assembler .cfi pseudo-op support],
+    gcc_cv_as_cfi_pseudo_op, [
+    gcc_cv_as_cfi_pseudo_op=unknown
+    AC_TRY_COMPILE([asm (".cfi_startproc\n\t.cfi_endproc");],,
+		   [gcc_cv_as_cfi_pseudo_op=yes],
+		   [gcc_cv_as_cfi_pseudo_op=no])
+ ])
+ if test "x$gcc_cv_as_cfi_pseudo_op" = xyes; then
+    AC_DEFINE(HAVE_AS_CFI_PSEUDO_OP, 1,
+	      [Define if your assembler supports .cfi_* directives.])
+ fi
+])
diff --git a/config/math.m4 b/config/math.m4
new file mode 100644
index 0000000..23835f2
--- /dev/null
+++ b/config/math.m4
@@ -0,0 +1,50 @@
+dnl GCC_CHECK_LIBM
+dnl
+dnl Check whether -lm is available.  This is a pre-requisite for
+dnl GCC_CHECK_MATH_FUNC so that it will link with -lm.
+AC_DEFUN([GCC_CHECK_LIBM],
+[AC_CHECK_LIB([m],[sin])])
+
+dnl GCC_CHECK_MATH_HEADERS
+dnl
+dnl Check for math.h and complex.h.  This is a pre-requisite for
+dnl GCC_CHECK_MATH_FUNC so that it includes the right headers.
+dnl (Some systems, such as AIX or OpenVMS may define macro for math
+dnl  functions).
+AC_DEFUN([GCC_CHECK_MATH_HEADERS],
+[AC_CHECK_HEADERS_ONCE(math.h complex.h)])
+
+dnl GCC_CHECK_MATH_FUNC([name])
+dnl
+dnl Check whether math function NAME is available on the system (by compiling
+dnl and linking a C program) and run define HAVE_name on success.
+dnl
+dnl Note that OpenVMS system insists on including complex.h before math.h
+AC_DEFUN([GCC_CHECK_MATH_FUNC],
+[
+  AC_REQUIRE([GCC_CHECK_LIBM])
+  AC_REQUIRE([GCC_CHECK_MATH_HEADERS])
+  AC_CACHE_CHECK([for $1], [gcc_cv_math_func_$1],
+		 [AC_LINK_IFELSE([
+#ifdef HAVE_COMPLEX_H
+#include <complex.h>
+#endif
+#ifdef HAVE_MATH_H
+#include <math.h>
+#endif
+
+int (*ptr)() = (int (*)())$1;
+
+int
+main ()
+{
+  return 0;
+}
+],
+[gcc_cv_math_func_$1=yes],
+[gcc_cv_math_func_$1=no])])
+  if test $gcc_cv_math_func_$1 = yes; then
+    AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1),[1],
+                       [Define to 1 if you have the `$1' function.])
+  fi
+])
diff --git a/config/mh-darwin b/config/mh-darwin
index 66f68b6..19bf265 100644
--- a/config/mh-darwin
+++ b/config/mh-darwin
@@ -1,5 +1,7 @@
 # The -mdynamic-no-pic ensures that the compiler executable is built without
 # position-independent-code -- the usual default on Darwin. This fix speeds
 # compiles by 3-5%.
-
 BOOT_CFLAGS += -mdynamic-no-pic
+
+# Ensure we don't try and use -pie, as it is incompatible with pch.
+BOOT_LDFLAGS += `case ${host} in *-*-darwin[1][1-9]*) echo -Wl,-no_pie ;; esac;`
diff --git a/config/mh-interix b/config/mh-interix
deleted file mode 100644
index 3be195b..0000000
--- a/config/mh-interix
+++ /dev/null
@@ -1,2 +0,0 @@
-# The shell may not be in /bin. 
-SHELL = sh
diff --git a/config/mh-ppc-aix b/config/mh-ppc-aix
index 4a97d81..a866f7f 100644
--- a/config/mh-ppc-aix
+++ b/config/mh-ppc-aix
@@ -5,4 +5,4 @@
 # don't do it any more.
 BOOT_ADAFLAGS = -gnatapg
 BOOT_LDFLAGS = -Wl,-bbigtoc
-LDFLAGS = `case $(CC) in *gcc*) echo -Wl,-bbigtoc ;; esac;`
+LDFLAGS = `case '$(CC)' in *gcc*) echo -Wl,-bbigtoc ;; esac;`
diff --git a/config/mmap.m4 b/config/mmap.m4
new file mode 100644
index 0000000..fba0d9d
--- /dev/null
+++ b/config/mmap.m4
@@ -0,0 +1,97 @@
+dnl ----------------------------------------------------------------------
+dnl This whole bit snagged from gcc
+
+dnl
+dnl mmap(2) blacklisting.  Some platforms provide the mmap library routine
+dnl but don't support all of the features we need from it.
+dnl
+AC_DEFUN([GCC_AC_FUNC_MMAP_BLACKLIST],
+[
+AC_CHECK_HEADER([sys/mman.h],
+		[gcc_header_sys_mman_h=yes], [gcc_header_sys_mman_h=no])
+AC_CHECK_FUNC([mmap], [gcc_func_mmap=yes], [gcc_func_mmap=no])
+if test "$gcc_header_sys_mman_h" != yes \
+ || test "$gcc_func_mmap" != yes; then
+   gcc_cv_func_mmap_file=no
+   gcc_cv_func_mmap_dev_zero=no
+   gcc_cv_func_mmap_anon=no
+else
+   AC_CACHE_CHECK([whether read-only mmap of a plain file works], 
+  gcc_cv_func_mmap_file,
+  [# Add a system to this blacklist if 
+   # mmap(0, stat_size, PROT_READ, MAP_PRIVATE, fd, 0) doesn't return a
+   # memory area containing the same data that you'd get if you applied
+   # read() to the same fd.  The only system known to have a problem here
+   # is VMS, where text files have record structure.
+   case "$host_os" in
+     *vms* | ultrix*)
+        gcc_cv_func_mmap_file=no ;;
+     *)
+        gcc_cv_func_mmap_file=yes;;
+   esac])
+   AC_CACHE_CHECK([whether mmap from /dev/zero works],
+  gcc_cv_func_mmap_dev_zero,
+  [# Add a system to this blacklist if it has mmap() but /dev/zero
+   # does not exist, or if mmapping /dev/zero does not give anonymous
+   # zeroed pages with both the following properties:
+   # 1. If you map N consecutive pages in with one call, and then
+   #    unmap any subset of those pages, the pages that were not
+   #    explicitly unmapped remain accessible.
+   # 2. If you map two adjacent blocks of memory and then unmap them
+   #    both at once, they must both go away.
+   # Systems known to be in this category are Windows (all variants),
+   # VMS, and Darwin.
+   case "$host_os" in
+     *vms* | cygwin* | pe | mingw* | darwin* | ultrix* | hpux10* | hpux11.00)
+        gcc_cv_func_mmap_dev_zero=no ;;
+     *)
+        gcc_cv_func_mmap_dev_zero=yes;;
+   esac])
+
+   # Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for.
+   AC_CACHE_CHECK([for MAP_ANON(YMOUS)], gcc_cv_decl_map_anon,
+    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[#include <sys/types.h>
+#include <sys/mman.h>
+#include <unistd.h>
+
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+],
+[int n = MAP_ANONYMOUS;])],
+    gcc_cv_decl_map_anon=yes,
+    gcc_cv_decl_map_anon=no)])
+
+   if test $gcc_cv_decl_map_anon = no; then
+     gcc_cv_func_mmap_anon=no
+   else
+     AC_CACHE_CHECK([whether mmap with MAP_ANON(YMOUS) works],
+     gcc_cv_func_mmap_anon,
+  [# Add a system to this blacklist if it has mmap() and MAP_ANON or
+   # MAP_ANONYMOUS, but using mmap(..., MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
+   # doesn't give anonymous zeroed pages with the same properties listed
+   # above for use of /dev/zero.
+   # Systems known to be in this category are Windows, VMS, and SCO Unix.
+   case "$host_os" in
+     *vms* | cygwin* | pe | mingw* | sco* | udk* )
+        gcc_cv_func_mmap_anon=no ;;
+     *)
+        gcc_cv_func_mmap_anon=yes;;
+   esac])
+   fi
+fi
+
+if test $gcc_cv_func_mmap_file = yes; then
+  AC_DEFINE(HAVE_MMAP_FILE, 1,
+	    [Define if read-only mmap of a plain file works.])
+fi
+if test $gcc_cv_func_mmap_dev_zero = yes; then
+  AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
+	    [Define if mmap of /dev/zero works.])
+fi
+if test $gcc_cv_func_mmap_anon = yes; then
+  AC_DEFINE(HAVE_MMAP_ANON, 1,
+	    [Define if mmap with MAP_ANON(YMOUS) works.])
+fi
+])
diff --git a/config/mt-alphaieee b/config/mt-alphaieee
index 9c20531..80c17cd 100644
--- a/config/mt-alphaieee
+++ b/config/mt-alphaieee
@@ -1,2 +1,3 @@
 CFLAGS_FOR_TARGET += -mieee
 CXXFLAGS_FOR_TARGET += -mieee
+GOCFLAGS_FOR_TARGET += -mieee
diff --git a/config/mt-sde b/config/mt-sde
index cb20420..d6992e4 100644
--- a/config/mt-sde
+++ b/config/mt-sde
@@ -5,6 +5,6 @@
 # as they have the D-to-I redirect for PC-relative loads.  -mno-gpopt
 # has two purposes: it allows libraries to be used in situations where
 # $gp != our _gp, and it allows them to be built with -G8 while
-# retaining link compability with -G0 and -G4.
+# retaining link compatibility with -G0 and -G4.
 CFLAGS_FOR_TARGET += -Os -minterlink-mips16 -mcode-xonly -mno-gpopt
 CXXFLAGS_FOR_TARGET += -Os -minterlink-mips16 -mcode-xonly -mno-gpopt
diff --git a/config/picflag.m4 b/config/picflag.m4
index f6f1b44..bd81812 100644
--- a/config/picflag.m4
+++ b/config/picflag.m4
@@ -19,7 +19,7 @@
 	;;
     i[[34567]]86-*-cygwin* | i[[34567]]86-*-mingw* | x86_64-*-mingw*)
 	;;
-    i[[34567]]86-*-interix3*)
+    i[[34567]]86-*-interix[[3-9]]*)
 	# Interix 3.x gcc -fpic/-fPIC options generate broken code.
 	# Instead, we relocate shared libraries at runtime.
 	;;
@@ -51,9 +51,6 @@
     m68k-*-*)
 	$1=-fpic
 	;;
-    s390*-*-*)
-	$1=-fpic
-	;;
     # FIXME: Override -fPIC default in libgcc only? 
     sh-*-linux* | sh[[2346lbe]]*-*-linux*)
 	$1=-fpic
diff --git a/config/stdint.m4 b/config/stdint.m4
index fbdd586..61898a7 100644
--- a/config/stdint.m4
+++ b/config/stdint.m4
@@ -18,7 +18,7 @@
 dnl existence of an include file <stdint.h> that defines a set of
 dnl typedefs, especially uint8_t,int32_t,uintptr_t.
 dnl Many older installations will not provide this file, but some will
-dnl have the very same definitions in <inttypes.h>. In other enviroments
+dnl have the very same definitions in <inttypes.h>. In other environments
 dnl we can use the inet-types in <sys/types.h> which would define the
 dnl typedefs int8_t and u_int8_t respectivly.
 dnl
diff --git a/config/tcl.m4 b/config/tcl.m4
index 900a2ce..59a0c7e 100644
--- a/config/tcl.m4
+++ b/config/tcl.m4
@@ -290,7 +290,7 @@
     elif test "`uname -s`" = "Darwin"; then
 	# If Tcl was built as a framework, attempt to use the libraries
 	# from the framework at the given location so that linking works
-	# against Tcl.framework installed in an arbitary location.
+	# against Tcl.framework installed in an arbitrary location.
 	case ${TCL_DEFS} in
 	    *TCL_FRAMEWORK*)
 		if test -f "${TCL_BIN_DIR}/${TCL_LIB_FILE}"; then
@@ -373,7 +373,7 @@
     elif test "`uname -s`" = "Darwin"; then
 	# If Tk was built as a framework, attempt to use the libraries
 	# from the framework at the given location so that linking works
-	# against Tk.framework installed in an arbitary location.
+	# against Tk.framework installed in an arbitrary location.
 	case ${TK_DEFS} in
 	    *TK_FRAMEWORK*)
 		if test -f "${TK_BIN_DIR}/${TK_LIB_FILE}"; then
@@ -815,7 +815,7 @@
 #
 #	Defines the following variable:
 #
-#	MAN_FLAGS -	The apropriate flags for installManPage
+#	MAN_FLAGS -	The appropriate flags for installManPage
 #			according to the user's selection.
 #
 #--------------------------------------------------------------------
diff --git a/config/warnings.m4 b/config/warnings.m4
index 3801c85..b64b594 100644
--- a/config/warnings.m4
+++ b/config/warnings.m4
@@ -1,6 +1,6 @@
 # Autoconf include file defining macros related to compile-time warnings.
 
-# Copyright 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
+# Copyright 2004, 2005, 2007, 2009, 2011 Free Software Foundation, Inc.
 
 #This file is part of GCC.
 
@@ -28,7 +28,13 @@
 m4_expand_once([acx_Var=
 ],m4_quote(acx_Var=))dnl
 save_CFLAGS="$CFLAGS"
-for option in $1; do
+for real_option in $1; do
+  # Do the check with the no- prefix removed since gcc silently
+  # accepts any -Wno-* option on purpose
+  case $real_option in
+    -Wno-*) option=-W`expr x$real_option : 'x-Wno-\(.*\)'` ;;
+    *) option=$real_option ;;
+  esac
   AS_VAR_PUSHDEF([acx_Woption], [acx_cv_prog_cc_warning_$option])
   AC_CACHE_CHECK([whether $CC supports $option], acx_Woption,
     [CFLAGS="$option"
@@ -37,14 +43,14 @@
       [AS_VAR_SET(acx_Woption, no)])
   ])
   AS_IF([test AS_VAR_GET(acx_Woption) = yes],
-        [acx_Var="$acx_Var${acx_Var:+ }$option"])
+        [acx_Var="$acx_Var${acx_Var:+ }$real_option"])
   AS_VAR_POPDEF([acx_Woption])dnl
 done
 CFLAGS="$save_CFLAGS"
 m4_popdef([acx_Var])dnl
 ])# ACX_PROG_CC_WARNING_OPTS
 
-# ACX_PROG_CC_WARNING_ALMOST_PEDANTIC(WARNINGS, [VARIABLE = WARN_PEDANTIC)
+# ACX_PROG_CC_WARNING_ALMOST_PEDANTIC(WARNINGS, [VARIABLE = WARN_PEDANTIC])
 #   Append to VARIABLE "-pedantic" + the argument, if the compiler is GCC
 #   and accepts all of those options simultaneously, otherwise to nothing.
 AC_DEFUN([ACX_PROG_CC_WARNING_ALMOST_PEDANTIC],
@@ -53,11 +59,14 @@
 AC_SUBST(acx_Var)dnl
 m4_expand_once([acx_Var=
 ],m4_quote(acx_Var=))dnl
-AS_VAR_PUSHDEF([acx_Pedantic], [acx_cv_prog_cc_pedantic_$1])dnl
+# Do the check with the no- prefix removed from the warning options
+# since gcc silently accepts any -Wno-* option on purpose
+m4_pushdef([acx_Woptions], [m4_bpatsubst([$1], [-Wno-], [-W])])dnl
+AS_VAR_PUSHDEF([acx_Pedantic], [acx_cv_prog_cc_pedantic_]acx_Woptions)dnl
 AS_IF([test "$GCC" = yes],
-[AC_CACHE_CHECK([whether $CC supports -pedantic $1], acx_Pedantic,
+[AC_CACHE_CHECK([whether $CC supports -pedantic ]acx_Woptions, acx_Pedantic,
 [save_CFLAGS="$CFLAGS"
-CFLAGS="-pedantic $1"
+CFLAGS="-pedantic acx_Woptions"
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
    [AS_VAR_SET(acx_Pedantic, yes)],
    [AS_VAR_SET(acx_Pedantic, no)])
@@ -66,6 +75,7 @@
       [acx_Var="$acx_Var${acx_Var:+ }-pedantic $1"])
 ])
 AS_VAR_POPDEF([acx_Pedantic])dnl
+m4_popdef([acx_Woptions])dnl
 m4_popdef([acx_Var])dnl
 ])# ACX_PROG_CC_WARNING_ALMOST_PEDANTIC
 
diff --git a/config/weakref.m4 b/config/weakref.m4
new file mode 100644
index 0000000..ecb8567
--- /dev/null
+++ b/config/weakref.m4
@@ -0,0 +1,47 @@
+
+dnl Check if the target supports weak.
+AC_DEFUN([GCC_CHECK_ATTRIBUTE_WEAK], [
+  AC_CACHE_CHECK([whether the target supports weak],
+		 ac_cv_have_attribute_weak, [
+  weakref_m4_saved_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -Werror"
+  AC_TRY_COMPILE([void __attribute__((weak)) foo(void) { }],
+		 [], ac_cv_have_attribute_weak=yes,
+		 ac_cv_have_attribute_weak=no)
+  CFLAGS="$weakref_m4_saved_CFLAGS"])
+  if test x"$ac_cv_have_attribute_weak" = xyes; then
+    AC_DEFINE(HAVE_ATTRIBUTE_WEAK, 1,
+      [Define to 1 if the target supports __attribute__((weak)).])
+  fi])
+
+dnl Check whether weak refs work like the ELF ones.
+dnl This means that the weak reference works without having to satify 
+dnl linkage for the item.
+dnl There are targets (at least Darwin) where we have fully functional
+dnl weakrefs at runtime, but must supply the referenced item at link time.
+AC_DEFUN([GCC_CHECK_ELF_STYLE_WEAKREF], [
+  AC_CACHE_CHECK([whether weak refs work like ELF],
+                  ac_cv_have_elf_style_weakref, [
+  weakref_m4_saved_CFLAGS="$CFLAGS"
+  case "${host}" in
+    *-apple-darwin*) CFLAGS="$CFLAGS -Wl,-undefined,dynamic_lookup" ;;
+    *) ;;
+  esac  
+  AC_RUN_IFELSE([AC_LANG_SOURCE([[
+extern void fNotToBeFound(void) __attribute__((weak));
+int main () 
+{
+  if (fNotToBeFound)
+    return 1;
+  else
+    return 0;
+}
+]])], ac_cv_have_elf_style_weakref=yes, ac_cv_have_elf_style_weakref=no, [
+case "${host}" in
+  *-apple-darwin[[89]]*) ac_cv_have_elf_style_weakref=no ;;
+  *) ac_cv_have_elf_style_weakref=yes;;
+esac])CFLAGS="$weakref_m4_saved_CFLAGS"])
+if test x"$ac_cv_have_elf_style_weakref" = xyes; then
+  AC_DEFINE(HAVE_ELF_STYLE_WEAKREF, 1, [Define to 1 if target has a weakref that works like the ELF one.])
+fi])
+
diff --git a/configure b/configure
index 9a0086c..6079e6c 100755
--- a/configure
+++ b/configure
@@ -2869,7 +2869,7 @@
       *-*-elf* | *-*-sysv4* | *-*-unixware* | *-*-eabi* | hppa*64*-*-hpux* \
       | *-*-linux* | frv-*-uclinux* | *-*-irix5* | *-*-irix6* \
       | *-*-netbsd* | *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* \
-      | *-*-solaris2* | *-*-nto*)
+      | *-*-solaris2* | *-*-nto* | *-*-nacl*)
         case "${target}" in
           *-*-linux*aout* | *-*-linux*oldld*)
             ;;
@@ -3054,7 +3054,7 @@
 	;;
     *-*-netbsd* | *-*-freebsd* | *-*-openbsd* | *-*-dragonfly*)
 	;;
-    *-*-solaris2* | *-*-irix6* | *-*-osf* | *-*-hpux11*)
+    *-*-solaris2* | *-*-hpux11*)
 	;;
     *-*-darwin* | *-*-aix*)
 	;;
@@ -3093,7 +3093,9 @@
     noconfigdirs="$noconfigdirs target-libssp"
     ;;
   rl78-*-*)
-    # Dereferencing -1 is a compile-time error
+    # libssp uses a misaligned load to trigger a fault, but the RL78
+    # doesn't fault for those - instead, it gives a build-time error
+    # for explicit misaligned loads.
     noconfigdirs="$noconfigdirs target-libssp"
     ;;
 esac
@@ -3143,7 +3145,7 @@
     ;;
   m68k-*-*)
     ;;
-  mips-sgi-irix6.* | mips*-*-rtems*)
+  mips*-*-rtems*)
     ;;
   mips*-*-linux*)
     ;;
@@ -3259,13 +3261,6 @@
   rs6000-*-aix*)
     noconfigdirs="$noconfigdirs ${libgcj}"
     ;;
-  mips*-*-irix6*)
-    # Linking libjava exceeds command-line length limits on at least
-    # IRIX 6.2, but not on IRIX 6.5.
-    # Also, boehm-gc won't build on IRIX 6.5, according to Jeffrey Oldham
-    # <oldham@codesourcery.com>
-    noconfigdirs="$noconfigdirs ${libgcj}"
-    ;;
   *-*-lynxos*)
     noconfigdirs="$noconfigdirs ${libgcj}"
     ;;
@@ -3503,8 +3498,7 @@
     noconfigdirs="$noconfigdirs libgui itcl ld"
     ;;
   ia64*-*-*vms*)
-    # No gdb or ld support yet.
-    noconfigdirs="$noconfigdirs readline libgui itcl gdb ld"
+    noconfigdirs="$noconfigdirs libgui itcl"
     ;;
   i[3456789]86-w64-mingw*)
     ;;
@@ -4977,7 +4971,7 @@
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_cc_gcc_supports_ada" >&5
 $as_echo "$acx_cv_cc_gcc_supports_ada" >&6; }
 
-if test x$GNATBIND != xno && test x$GNATMAKE != xno && test x$acx_cv_cc_gcc_supports_ada != xno; then
+if test "x$GNATBIND" != xno && test "x$GNATMAKE" != xno && test x$acx_cv_cc_gcc_supports_ada != xno; then
   have_gnat=yes
 else
   have_gnat=no
@@ -5195,9 +5189,16 @@
   gmplibs="-L$with_mpfr_lib $gmplibs"
 fi
 if test "x$with_mpfr$with_mpfr_include$with_mpfr_lib" = x && test -d ${srcdir}/mpfr; then
-  gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/'"$lt_cv_objdir $gmplibs"
-  gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr -I$$s/mpfr '"$gmpinc"
-  extra_mpc_mpfr_configure_flags='--with-mpfr-include=$$s/mpfr --with-mpfr-lib=$$r/$(HOST_SUBDIR)/mpfr/'"$lt_cv_objdir"
+  # MPFR v3.1.0 moved the sources into a src sub-directory.
+  if test -d ${srcdir}/mpfr/src; then
+    gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/src/'"$lt_cv_objdir $gmplibs"
+    gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr/src -I$$s/mpfr/src '"$gmpinc"
+    extra_mpc_mpfr_configure_flags='--with-mpfr-include=$$s/mpfr/src --with-mpfr-lib=$$r/$(HOST_SUBDIR)/mpfr/src/'"$lt_cv_objdir"
+  else
+    gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/'"$lt_cv_objdir $gmplibs"
+    gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr -I$$s/mpfr '"$gmpinc"
+    extra_mpc_mpfr_configure_flags='--with-mpfr-include=$$s/mpfr --with-mpfr-lib=$$r/$(HOST_SUBDIR)/mpfr/'"$lt_cv_objdir"
+  fi
   # Do not test the mpfr version.  Assume that it is sufficient, since
   # it is in the source tree, and the library has not been built yet
   # but it would be included on the link line in the version check below
@@ -6666,11 +6667,11 @@
   CFLAGS_FOR_TARGET=$CFLAGS
   case " $CFLAGS " in
     *" -O2 "*) ;;
-    *) CFLAGS_FOR_TARGET="-O2 $CFLAGS" ;;
+    *) CFLAGS_FOR_TARGET="-O2 $CFLAGS_FOR_TARGET" ;;
   esac
   case " $CFLAGS " in
     *" -g "* | *" -g3 "*) ;;
-    *) CFLAGS_FOR_TARGET="-g $CFLAGS" ;;
+    *) CFLAGS_FOR_TARGET="-g $CFLAGS_FOR_TARGET" ;;
   esac
 fi
 
@@ -6679,11 +6680,11 @@
   CXXFLAGS_FOR_TARGET=$CXXFLAGS
   case " $CXXFLAGS " in
     *" -O2 "*) ;;
-    *) CXXFLAGS_FOR_TARGET="-O2 $CXXFLAGS" ;;
+    *) CXXFLAGS_FOR_TARGET="-O2 $CXXFLAGS_FOR_TARGET" ;;
   esac
   case " $CXXFLAGS " in
     *" -g "* | *" -g3 "*) ;;
-    *) CXXFLAGS_FOR_TARGET="-g $CXXFLAGS" ;;
+    *) CXXFLAGS_FOR_TARGET="-g $CXXFLAGS_FOR_TARGET" ;;
   esac
 fi
 
@@ -6873,18 +6874,6 @@
     ;;
 esac
 
-# Default to using --with-stabs for certain targets.
-if test x${with_stabs} = x ; then
-  case "${target}" in
-  mips*-*-irix[56]*)
-    ;;
-  mips*-*-* | alpha*-*-osf*)
-    with_stabs=yes;
-    extra_host_args="${extra_host_args} --with-stabs"
-    ;;
-  esac
-fi
-
 # Some systems (e.g., one of the i386-aix systems the gas testers are
 # using) don't handle "\$" correctly, so don't use it here.
 tooldir='${exec_prefix}'/${target_noncanonical}
diff --git a/configure.ac b/configure.ac
index 9ef2e35..d68b5f3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
 #   Copyright (C) 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.
 #
 # This file is free software; you can redistribute it and/or modify it
@@ -112,11 +112,11 @@
 ### or a host dependent tool.  Then put it into the appropriate list
 ### (library or tools, host or target), doing a dependency sort.
 
-# Subdirs will be configured in the order listed in build_configdirs, 
+# Subdirs will be configured in the order listed in build_configdirs,
 # configdirs, or target_configdirs; see the serialization section below.
 
-# Dependency sorting is only needed when *configuration* must be done in 
-# a particular order.  In all cases a dependency should be specified in 
+# Dependency sorting is only needed when *configuration* must be done in
+# a particular order.  In all cases a dependency should be specified in
 # the Makefile, whether or not it's implicitly specified here.
 
 # Double entries in build_configdirs, configdirs, or target_configdirs may
@@ -209,7 +209,7 @@
   is_cross_compiler=no
 else
   is_cross_compiler=yes
-fi	
+fi
 
 # Find the build and target subdir names.
 GCC_TOPLEV_SUBDIRS
@@ -245,7 +245,7 @@
   noconfigdirs="$noconfigdirs zlib"
 fi
 
-# some tools are so dependent upon X11 that if we're not building with X, 
+# some tools are so dependent upon X11 that if we're not building with X,
 # it's not even worth trying to configure, much less build, that tool.
 
 case ${with_x} in
@@ -253,7 +253,7 @@
   no)
     skipdirs="${skipdirs} tk itcl libgui"
     # We won't be able to build gdbtk without X.
-    enable_gdbtk=no 
+    enable_gdbtk=no
     ;;
   *)  echo "*** bad value \"${with_x}\" for -with-x flag; ignored" 1>&2 ;;
 esac
@@ -313,7 +313,7 @@
       *-*-elf* | *-*-sysv4* | *-*-unixware* | *-*-eabi* | hppa*64*-*-hpux* \
       | *-*-linux* | frv-*-uclinux* | *-*-irix5* | *-*-irix6* \
       | *-*-netbsd* | *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* \
-      | *-*-solaris2* | *-*-nto*)
+      | *-*-solaris2* | *-*-nto* | *-*-nacl*)
         case "${target}" in
           *-*-linux*aout* | *-*-linux*oldld*)
             ;;
@@ -379,7 +379,7 @@
 # Only spaces may be used in this macro; not newlines or tabs.
 unsupported_languages=
 
-# Remove more programs from consideration, based on the host or 
+# Remove more programs from consideration, based on the host or
 # target this usually means that a port of the program doesn't
 # exist yet.
 
@@ -483,7 +483,7 @@
 	;;
     *-*-netbsd* | *-*-freebsd* | *-*-openbsd* | *-*-dragonfly*)
 	;;
-    *-*-solaris2* | *-*-irix6* | *-*-osf* | *-*-hpux11*)
+    *-*-solaris2* | *-*-hpux11*)
 	;;
     *-*-darwin* | *-*-aix*)
 	;;
@@ -519,7 +519,9 @@
     noconfigdirs="$noconfigdirs target-libssp"
     ;;
   rl78-*-*)
-    # Dereferencing -1 is a compile-time error
+    # libssp uses a misaligned load to trigger a fault, but the RL78
+    # doesn't fault for those - instead, it gives a build-time error
+    # for explicit misaligned loads.
     noconfigdirs="$noconfigdirs target-libssp"
     ;;
 esac
@@ -569,7 +571,7 @@
     ;;
   m68k-*-*)
     ;;
-  mips-sgi-irix6.* | mips*-*-rtems*)
+  mips*-*-rtems*)
     ;;
   mips*-*-linux*)
     ;;
@@ -685,16 +687,9 @@
   rs6000-*-aix*)
     noconfigdirs="$noconfigdirs ${libgcj}"
     ;;
-  mips*-*-irix6*)
-    # Linking libjava exceeds command-line length limits on at least
-    # IRIX 6.2, but not on IRIX 6.5.
-    # Also, boehm-gc won't build on IRIX 6.5, according to Jeffrey Oldham
-    # <oldham@codesourcery.com>
-    noconfigdirs="$noconfigdirs ${libgcj}"
-    ;;
   *-*-lynxos*)
     noconfigdirs="$noconfigdirs ${libgcj}"
-    ;; 
+    ;;
 esac
 
 # Default libgloss CPU subdirectory.
@@ -779,7 +774,7 @@
     ;;
   *-*-lynxos*)
     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
-    ;; 
+    ;;
   *-*-mingw*)
     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
     ;;
@@ -929,8 +924,7 @@
     noconfigdirs="$noconfigdirs libgui itcl ld"
     ;;
   ia64*-*-*vms*)
-    # No gdb or ld support yet.
-    noconfigdirs="$noconfigdirs readline libgui itcl gdb ld"
+    noconfigdirs="$noconfigdirs libgui itcl"
     ;;
   i[[3456789]]86-w64-mingw*)
     ;;
@@ -1084,7 +1078,7 @@
   hppa*-hp-hpux*)
     host_makefile_frag="config/mh-pa"
     ;;
-  hppa*-*)	
+  hppa*-*)
     host_makefile_frag="config/mh-pa"
     ;;
   *-*-darwin*)
@@ -1283,9 +1277,16 @@
   gmplibs="-L$with_mpfr_lib $gmplibs"
 fi
 if test "x$with_mpfr$with_mpfr_include$with_mpfr_lib" = x && test -d ${srcdir}/mpfr; then
-  gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/'"$lt_cv_objdir $gmplibs"
-  gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr -I$$s/mpfr '"$gmpinc"
-  extra_mpc_mpfr_configure_flags='--with-mpfr-include=$$s/mpfr --with-mpfr-lib=$$r/$(HOST_SUBDIR)/mpfr/'"$lt_cv_objdir"
+  # MPFR v3.1.0 moved the sources into a src sub-directory.
+  if test -d ${srcdir}/mpfr/src; then
+    gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/src/'"$lt_cv_objdir $gmplibs"
+    gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr/src -I$$s/mpfr/src '"$gmpinc"
+    extra_mpc_mpfr_configure_flags='--with-mpfr-include=$$s/mpfr/src --with-mpfr-lib=$$r/$(HOST_SUBDIR)/mpfr/src/'"$lt_cv_objdir"
+  else
+    gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/'"$lt_cv_objdir $gmplibs"
+    gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr -I$$s/mpfr '"$gmpinc"
+    extra_mpc_mpfr_configure_flags='--with-mpfr-include=$$s/mpfr --with-mpfr-lib=$$r/$(HOST_SUBDIR)/mpfr/'"$lt_cv_objdir"
+  fi
   # Do not test the mpfr version.  Assume that it is sufficient, since
   # it is in the source tree, and the library has not been built yet
   # but it would be included on the link line in the version check below
@@ -1780,7 +1781,7 @@
       # an apparent bug in bash 1.12 on linux.
       ${srcdir}/gcc/[[*]]/config-lang.in) ;;
       *)
-        # From the config-lang.in, get $language, $target_libs, 
+        # From the config-lang.in, get $language, $target_libs,
         # $lang_dirs, $boot_language, and $build_by_default
         language=
         target_libs=
@@ -2025,7 +2026,7 @@
 build_configdirs_all="$build_configdirs"
 build_configdirs=
 for i in ${build_configdirs_all} ; do
-  j=`echo $i | sed -e s/build-//g` 
+  j=`echo $i | sed -e s/build-//g`
   if test -f ${srcdir}/$j/configure ; then
     build_configdirs="${build_configdirs} $i"
   fi
@@ -2042,7 +2043,7 @@
 target_configdirs_all="$target_configdirs"
 target_configdirs=
 for i in ${target_configdirs_all} ; do
-  j=`echo $i | sed -e s/target-//g` 
+  j=`echo $i | sed -e s/target-//g`
   if test -f ${srcdir}/$j/configure ; then
     target_configdirs="${target_configdirs} $i"
   fi
@@ -2093,7 +2094,7 @@
 
 copy_dirs=
 
-AC_ARG_WITH([build-sysroot], 
+AC_ARG_WITH([build-sysroot],
   [AS_HELP_STRING([--with-build-sysroot=SYSROOT],
 		  [use sysroot as the system root during the build])],
   [if test x"$withval" != x ; then
@@ -2124,11 +2125,11 @@
   CFLAGS_FOR_TARGET=$CFLAGS
   case " $CFLAGS " in
     *" -O2 "*) ;;
-    *) CFLAGS_FOR_TARGET="-O2 $CFLAGS" ;;
+    *) CFLAGS_FOR_TARGET="-O2 $CFLAGS_FOR_TARGET" ;;
   esac
   case " $CFLAGS " in
     *" -g "* | *" -g3 "*) ;;
-    *) CFLAGS_FOR_TARGET="-g $CFLAGS" ;;
+    *) CFLAGS_FOR_TARGET="-g $CFLAGS_FOR_TARGET" ;;
   esac
 fi
 AC_SUBST(CFLAGS_FOR_TARGET)
@@ -2137,11 +2138,11 @@
   CXXFLAGS_FOR_TARGET=$CXXFLAGS
   case " $CXXFLAGS " in
     *" -O2 "*) ;;
-    *) CXXFLAGS_FOR_TARGET="-O2 $CXXFLAGS" ;;
+    *) CXXFLAGS_FOR_TARGET="-O2 $CXXFLAGS_FOR_TARGET" ;;
   esac
   case " $CXXFLAGS " in
     *" -g "* | *" -g3 "*) ;;
-    *) CXXFLAGS_FOR_TARGET="-g $CXXFLAGS" ;;
+    *) CXXFLAGS_FOR_TARGET="-g $CXXFLAGS_FOR_TARGET" ;;
   esac
 fi
 AC_SUBST(CXXFLAGS_FOR_TARGET)
@@ -2184,11 +2185,11 @@
 # This is done by determining whether or not the appropriate directory
 # is available, and by checking whether or not specific configurations
 # have requested that this magic not happen.
-# 
-# The command line options always override the explicit settings in 
+#
+# The command line options always override the explicit settings in
 # configure.in, and the settings in configure.in override this magic.
 #
-# If the default for a toolchain is to use GNU as and ld, and you don't 
+# If the default for a toolchain is to use GNU as and ld, and you don't
 # want to do that, then you should use the --without-gnu-as and
 # --without-gnu-ld options for the configure script.  Similarly, if
 # the default is to use the included zlib and you don't want to do that,
@@ -2289,7 +2290,7 @@
     target_makefile_frag="config/mt-gnu"
     ;;
   *-*-aix4.[[3456789]]* | *-*-aix[[56789]].*)
-    # nm and ar from AIX 4.3 and above require -X32_64 flag to all ar and nm 
+    # nm and ar from AIX 4.3 and above require -X32_64 flag to all ar and nm
     # commands to handle both 32-bit and 64-bit objects.  These flags are
     # harmless if we're using GNU nm or ar.
     extra_arflags_for_target=" -X32_64"
@@ -2331,18 +2332,6 @@
     ;;
 esac
 
-# Default to using --with-stabs for certain targets.
-if test x${with_stabs} = x ; then
-  case "${target}" in
-  mips*-*-irix[[56]]*)
-    ;;
-  mips*-*-* | alpha*-*-osf*)
-    with_stabs=yes;
-    extra_host_args="${extra_host_args} --with-stabs"
-    ;;
-  esac
-fi
-
 # Some systems (e.g., one of the i386-aix systems the gas testers are
 # using) don't handle "\$" correctly, so don't use it here.
 tooldir='${exec_prefix}'/${target_noncanonical}
@@ -2375,7 +2364,7 @@
   if test -s conftest || test -s conftest.exe ; then
     we_are_ok=yes
   fi
-fi 
+fi
 case $we_are_ok in
   no)
     echo 1>&2 "*** The command '${CC} -o conftest ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} conftest.c' failed."
@@ -2745,7 +2734,7 @@
 # --program-suffix have been applied to it.  Autoconf has already
 # doubled dollar signs and backslashes in program_transform_name; we want
 # the backslashes un-doubled, and then the entire thing wrapped in single
-# quotes, because this will be expanded first by make and then by the shell. 
+# quotes, because this will be expanded first by make and then by the shell.
 # Also, because we want to override the logic in subdir configure scripts to
 # choose program_transform_name, replace any s,x,x, with s,y,y,.
 sed -e "s,\\\\\\\\,\\\\,g; s,','\\\\'',g; s/s,x,x,/s,y,y,/" <<EOF_SED > conftestsed.out
@@ -3070,7 +3059,7 @@
 AC_SUBST(CXXFLAGS)
 
 # Target tools.
-AC_ARG_WITH([build-time-tools], 
+AC_ARG_WITH([build-time-tools],
   [AS_HELP_STRING([--with-build-time-tools=PATH],
 		  [use given path to find target tools during the build])],
   [case x"$withval" in
@@ -3175,7 +3164,7 @@
 else
   MAINTAINER_MODE_TRUE='#'
   MAINTAINER_MODE_FALSE=
-fi	
+fi
 MAINT=$MAINTAINER_MODE_TRUE
 AC_SUBST(MAINT)dnl
 
diff --git a/cpu/ChangeLog b/cpu/ChangeLog
index d04a554..bd82d13 100644
--- a/cpu/ChangeLog
+++ b/cpu/ChangeLog
@@ -1,3 +1,12 @@
+2012-02-27  Alan Modra  <amodra@gmail.com>
+
+	* mt.opc (print_dollarhex): Trim values to 32 bits.
+
+2011-12-15  Nick Clifton  <nickc@redhat.com>
+
+	* frv.opc (parse_uhi16): Fix handling of %hi operator on 64-bit
+	hosts.
+
 2011-10-26  Joern Rennecke  <joern.rennecke@embecosm.com>
 
 	* epiphany.opc (parse_branch_addr): Fix type of valuep.
diff --git a/cpu/frv.opc b/cpu/frv.opc
index f81cef0..869155d 100644
--- a/cpu/frv.opc
+++ b/cpu/frv.opc
@@ -1343,11 +1343,11 @@
 	  if (errmsg == NULL
 	      && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
 	    {
-	      /* If bfd_vma is wider than 32 bits, but we have a sign-
-		 or zero-extension, truncate it.  */
-	      if (value >= - ((bfd_vma)1 << 31)
-		  || value <= ((bfd_vma)1 << 31) - (bfd_vma)1)
-		value &= (((bfd_vma)1 << 16) << 16) - 1;
+ 	      /* If value is wider than 32 bits then be
+ 		 careful about how we extract bits 16-31.  */
+ 	      if (sizeof (value) > 4)
+ 		value &= (((bfd_vma)1 << 16) << 16) - 1;
+
 	      value >>= 16;
 	    }
 	  *valuep = value;
diff --git a/cpu/mt.opc b/cpu/mt.opc
index 3da6d0e..d988cc2 100644
--- a/cpu/mt.opc
+++ b/cpu/mt.opc
@@ -1,5 +1,5 @@
 /* Morpho Technologies mRISC opcode support, for GNU Binutils.  -*- C -*-
-   Copyright 2001, 2007, 2008, 2009 Free Software Foundation, Inc.
+   Copyright 2001, 2007, 2008, 2009, 2012 Free Software Foundation, Inc.
 
    Contributed by Red Hat Inc; developed under contract from
    Morpho Technologies.
@@ -447,7 +447,7 @@
 {
   disassemble_info *info = (disassemble_info *) dis_info;
 
-  info->fprintf_func (info->stream, "$%lx", value);
+  info->fprintf_func (info->stream, "$%lx", value & 0xffffffff);
 
   if (0)
     print_normal (cd, dis_info, value, attrs, pc, length);
diff --git a/djunpack.bat b/djunpack.bat
index 7dc1489..0566c1d 100644
--- a/djunpack.bat
+++ b/djunpack.bat
@@ -17,8 +17,8 @@
 Rem The following 2 lines need to be changed with each new GDB release, to

 Rem be identical to the name of the top-level directory where the GDB

 Rem distribution unpacks itself.

-set GDBVER=gdb-7.4.1

-if "%GDBVER%"=="gdb-7.4.1" GoTo EnvOk

+set GDBVER=gdb-7.5.1

+if "%GDBVER%"=="gdb-7.5.1" GoTo EnvOk

 Rem If their environment space is too small, re-exec with a larger one

 command.com /e:4096 /c %0 %1

 GoTo End

diff --git a/gdb/.dir-locals.el b/gdb/.dir-locals.el
new file mode 100644
index 0000000..8eca9e0
--- /dev/null
+++ b/gdb/.dir-locals.el
@@ -0,0 +1,24 @@
+;; Emacs settings.
+;; Copyright (C) 2012 Free Software Foundation, Inc.
+
+;; 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, see <http://www.gnu.org/licenses/>.
+
+(
+ (tcl-mode . ((tcl-indent-level . 4)
+	      (tcl-continued-indent-level . 4)
+	      (indent-tabs-mode . t)))
+ (nil . ((bug-reference-url-format . "http://sourceware.org/bugzilla/show_bug.cgi?id=%s")))
+ (c-mode . ((c-file-style . "GNU")
+	    (indent-tabs-mode . t)))
+)
diff --git a/gdb/.gitignore b/gdb/.gitignore
index ea3a4f9..7a0dd1a 100644
--- a/gdb/.gitignore
+++ b/gdb/.gitignore
@@ -9,6 +9,7 @@
 /gdb
 /gdbtui
 /init.c
+/jit-reader.h
 /jv-exp.c
 /m2-exp.c
 /objc-exp.c
diff --git a/gdb/CONTRIBUTE b/gdb/CONTRIBUTE
index 2d24bba..cdec246 100644
--- a/gdb/CONTRIBUTE
+++ b/gdb/CONTRIBUTE
@@ -71,9 +71,9 @@
 	documentation (i.e., .texi files).
 
 	The patch itself. If you are accessing the CVS repository use
-	"cvs update; cvs diff -cp"; else, use "diff -cp OLD NEW" or
-	"diff -up OLD NEW". If your version of diff does not support
-	these options, then get the latest version of GNU diff.
+	"cvs update; cvs diff -up"; else, use "diff -up OLD NEW". If
+	your version of diff does not support these options, then get
+	the latest version of GNU diff.
 
 	We accept patches as plain text (preferred for the compilers
 	themselves), MIME attachments (preferred for the web pages),
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 67a46b4..4df03c5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,29 +1,5457 @@
+2012-11-29  Joel Brobecker  <brobecker@adacore.com>
+
+	* version.in: Update GDB version number to 7.5.1.
+
+2012-11-15  Luis Machado  <lgustavo@codesourcery.com>
+
+	* value.c (value_actual_type): Check for TYPE_CODE_STRUCT
+	target types.
+
+2012-11-10  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR backtrace/14646
+	PR gdb/14647
+	* i386-tdep.h (gdbarch_tdep): Remove sp_regnum_from_eax and
+	pc_regnum_from_eax.
+	* i386-tdep.c (i386_gdbarch_init): Don't use sp_regnum_from_eax
+	nor pc_regnum_from_eax.
+	* amd64-tdep.c (amd64_x32_init_abi): Don't set sp_regnum_from_eax
+	nor pc_regnum_from_eax.
+
+2012-10-11  Doug Evans  <dje@google.com>
+
+	PR breakpoints/14643.
+	* linespec.c (struct ls_parser): New member keyword_ok.
+	(linespec_lexer_lex_string): Add comment.
+	(linespec_lexer_lex_one): Ignore keywords if it's the wrong place
+	for one.
+	(parse_linespec): Set keyword_ok.
+
+2012-10-06  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	Fix crash during stepping on ppc32.
+	* ppc-linux-tdep.c (powerpc_linux_in_dynsym_resolve_code): Test NULL
+	SYM.
+
+2012-09-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* common/linux-ptrace.c: Change __i386__ to __i386__ || __x86_64__.
+	(linux_ptrace_test_ret_to_nx): Extend comment for x86_64.  Change
+	__i386__ to __i386__ || __x86_64__. Extend code also for __x86_64__.
+	Extend code also for PaX support.  Convert all gdb_assert to warning
+	calls.
+
+2012-09-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	Implement auto-load user conveniences suggested by Doug Evans.
+	* auto-load.c: Include top.h.
+	(file_is_auto_load_safe): New variable advice_printed.  Print advice.
+	(_initialize_auto_load): New variable scripts_directory_help.  Mention
+	GDBPY_AUTO_FILE_NAME and GDB_AUTO_FILE_NAME for set auto-load
+	scripts-directory.  Document in online help one can use also files for
+	set auto-load safe-path.
+	* python/py-auto-load.c: (GDBPY_AUTO_FILE_NAME): Move it from here ...
+	* python/python.h (GDBPY_AUTO_FILE_NAME): ... to here.
+
+2012-09-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	PR 14119
+	* frame.c (skip_inlined_frames): Skip also TAILCALL_FRAME frames.
+	(frame_pop): Drop also TAILCALL_FRAME frames.
+	* infcmd.c (finish_command): Ignore also TAILCALL_FRAME frames.
+
+2012-09-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
+	    Pedro Alves  <palves@redhat.com>
+
+	PR 14548
+	* infrun.c (handle_inferior_event): Do not reverse-continue back to the
+	function start if we are already at function start.  Both for
+	reverse-next and for reverse-step into function without line number
+	info.
+
+2012-08-29  Doug Evans  <dje@google.com>
+
+	* main.c (print_gdb_help): Remove reference to
+	--use-deprecated-index-sections.
+
+2012-08-27  Eli Zaretskii  <eliz@gnu.org>
+	    Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* auto-load.c (auto_load_objfile_script): Rename to ...
+	(auto_load_objfile_script_1): ... here, change variable realname to
+	parameter realname, document it, add return value, add variable retval.
+	(auto_load_objfile_script): New function.
+
+2012-08-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* cli/cli-decode.c (print_doc_line): Keep skipping '.' and ',' not
+	followed by a whitespace.
+
+2012-08-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	PR gdb/14494.
+	* dwarf2read.c (dwarf2_locate_sections): Move variable aflag here.
+	Move the SEC_HAS_CONTENTS check here - for any NAMES use.
+	(dwarf2_locate_sections) <eh_frame>: Move the variable and check from
+	here.
+
+2012-08-22  Keith Seitz  <keiths@redhat.com>
+
+	* defs.h: Include build-gnulib/config.h
+
+2012-08-21  Pierre Muller  <muller@ics.u-strasbg.fr>
+
+	* symfile.c (allocate_symtab): Use host_address_to_string
+	function instead of cast of pointer to long which is not
+	compatible with x86_64-w64-mingw32 build.
+
+2012-08-17  Joel Brobecker  <brobecker@adacore.com>
+
+	* version.in: Set version to 7.5.0.20120817-cvs.
+
+2012-08-17  Joel Brobecker  <brobecker@adacore.com>
+
+	GDB 7.5 released.
+
+2012-08-17  Joel Brobecker  <brobecker@adacore.com>
+
+	* version.in: Update GDB version number to 7.5.
+
+2012-08-16  Tom Tromey  <tromey@redhat.com>
+
+	PR python/14386:
+	* varobj.c (update_dynamic_varobj_children): Don't call
+	PyIter_Check.
+
+2012-08-06  Tom Tromey  <tromey@redhat.com>
+
+	* dwarf2-frame.c (clear_pointer_cleanup): New function.
+	(dwarf2_frame_cache): Use it.
+	* frame-unwind.h (frame_sniffer_ftype): Document prologue
+	cache initialization constraint.
+
+2012-08-06  Tom Tromey  <tromey@redhat.com>
+
+	PR cli/14392:
+	* cli/cli-cmds.c (list_command): Filter 'sals_end'.
+
+2012-08-03  Tom Tromey  <tromey@redhat.com>
+
+	* dwarf2-frame.c (dwarf2_frame_cache): Call do_cleanups before
+	return.
+
+2012-08-02  Ulrich Weigand  <ulrich.weigand@linaro.org>
+
+	* inf-child.c (inf_child_fileio_pwrite): If pwrite fails, fall back
+	to attempting lseek/write.
+	(inf_child_fileio_pread): Likewise for pread.
+
+2012-08-01  Richard Henderson  <rth@redhat.com>
+
+	* configure.tgt (m32c-*-*) [gdb_target_obs]: Remove prologue-value.o.
+	(mep-*-*) [gdb_target_obs]: Likewise.
+
+2012-08-01  Ulrich Weigand  <ulrich.weigand@linaro.org>
+
+	* arm-linux-nat.c (arm_linux_hw_breakpoint_initialize): Do not
+	attempt to 4-byte-align HW breakpoint addresses for Thumb.
+
+2012-07-31  Andreas Schwab  <schwab@linux-m68k.org>
+
+	* ppc-linux-tdep.c (ppc_linux_init_abi): Register
+	linux_get_siginfo_type.
+
+2012-07-31  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* infcall.c (call_function_by_hand): Move BP_ADDR comment to
+	AT_ENTRY_POINT.
+	(call_function_by_hand) <ON_STACK>: Call write_memory with
+	gdbarch_breakpoint_from_pc, if possible.
+	(call_function_by_hand) <AT_ENTRY_POINT>: The BP_ADDR comment is moved
+	here.
+
+2012-07-30  Keith Seitz  <keiths@redhat.com>
+
+	* linespec.c (linespec_lexer_lex_number): A number followed
+	by quotes is a valid number, too.
+
+2012-07-26  Keith Seitz  <keiths@redhat.com>
+
+	* linespec.c (linespec_lexer_lex_number): The input
+	is also a valid number if the next character is a comma
+	or colon.
+
+2012-07-25  Ralf Corsépius  <ralf.corsepius@rtems.org>
+
+	* configure.tgt: Add v850*-*-rtems*.
+
+2012-07-25  Hui Zhu  <hui_zhu@mentor.com>
+
+	* linespec.c (linespec_lexer_lex_number): Update comments,
+	change the return and add check to make sure the input is
+	the decimal numbers.
+	(linespec_lexer_lex_one): If linespec_lexer_lex_number return
+	false, call linespec_lexer_lex_string.
+
+2012-07-24  Marc Khouzam  <marc.khouzam@ericsson.com>
+
+	* breakpoint.c (create_breakpoint): Store condition for pending
+	breakpoints.
+
+2012-07-23  Keith Seitz  <keiths@redhat.com>
+
+	* linespec.c (convert_linespec_to_sal): Don't add
+	any symbols to the result vector if symbol_to_sal
+	returns zero.
+
+2012-07-20  Doug Evans  <dje@google.com>
+
+	* NEWS: Document new options "set/show use-deprecated-index-sections",
+	and delete reference to --use-deprecated-index-sections.
+	* symfile.h (use_deprecated_index_sections): Delete.
+	* dwarf2read.c (use_deprecated_index_sections): Make static.
+	(read_index_from_section): Update wording of how to load
+	deprecated index sections.
+	(_initialize_dwarf2_read): New options
+	"set/show use-deprecated-index-sections".
+	* main.c (captured_main): Delete --use-deprecated-index-sections.
+
+2012-07-18  Joel Brobecker  <brobecker@adacore.com>
+
+	* version.in: Set version to 7.4.91.20120718-cvs.
+
+2012-07-18  Joel Brobecker  <brobecker@adacore.com>
+
+	GDB 7.4.91 released.
+
+2012-07-18  Joel Brobecker  <brobecker@adacore.com>
+
+	* NEWS: Replace "Changes since GDB 7.4" with "Changes in GDB 7.5".
+
+2012-07-18  Joel Brobecker  <brobecker@adacore.com>
+
+	* version.in: Update GDB version number to 7.4.91.
+
+2012-07-18  Joel Brobecker  <brobecker@adacore.com>
+
+	* configure.ac (development): Set to false.
+	* configure: Regenerate.
+
+2012-07-18  Joel Brobecker  <brobecker@adacore.com>
+
+	GDB 7.5 branch created (branch timestamp: 2012-07-18 03:22 UTC)
+	* version.in: Bump version to 7.4.90.20120718-cvs.
+
+2012-07-16  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	PR 11914
+	* f-valprint.c (info_common_command): New variable frame_id.
+	Reinitialize FI form FRAME_ID after each print_variable_and_value.
+	* printcmd.c (print_variable_and_value): Extend function comment.
+	Add comment for invalidated FRAME.
+	* stack.c (backtrace_command_1): New variable frame_id.  Reinitialize
+	FI form FRAME_ID after each print_frame_local_vars.
+	(struct print_variable_and_value_data): Change frame to frame_id.
+	(do_print_variable_and_value): New variable frame, initialize it from
+	p->frame_id.  Add comment for invalidated FRAME.
+	(print_frame_local_vars, print_frame_arg_vars): New function comment.
+	Update CB_DATA.FRAME to CB_DATA.FRAME_ID initialization.  Add comment
+	for invalidated FRAME.
+
+2012-07-16  Marc Khouzam  <marc.khouzam@ericsson.com>
+	    Pedro Alves  <palves@redhat.com>
+
+	* linux-nat.c (linux_nat_detach): Don't unregister from the event
+	loop.
+
+2012-07-16  Tom Tromey  <tromey@redhat.com>
+
+	* jv-typeprint.c (c_type_print_varspec_suffix): Don't declare.
+
+2012-07-15  Doug Evans  <dje@google.com>
+
+	* dwarf2read.c (stmt_list_hash): New struct.
+	(type_unit_group): Embed "per_cu" member, remove pointer.
+	New union member "t", move member "tus" into it, all uses updated.
+	New member "hash", replaces member "line_offset, all uses updated.
+	(quick_file_names): Replace member "offset" with "hash", all uses
+	updated.
+	(hash_stmt_list_entry, eq_stmt_list_entry): New functions.
+	(hash_file_name_entry, eq_file_name_entry): Call them.
+	(hash_type_unit_group, eq_type_unit_group): Ditto.
+	(dw2_get_cu, dw2_get_primary_cu): Replace assert with a better one.
+	(dw2_get_file_names_reader): Fix file name table calculation for TUs.
+	(dw2_get_file_names): Update.
+	(create_type_unit_group): Replace "per_cu" arg with "cu".
+	All callers updated.  Fix "quick" (.gdb_index) handling.
+	(get_type_unit_group): Replace "per_cu" arg with "cu".
+	All callers updated.
+	(build_type_unit_groups): Don't reset tu_stats.
+
+	* symtab.c (filename_seen_cache): Delete members "tab_alloc_size",
+	"tab_cur_size".  Change member "tab" to be a htab_t.
+	(create_filename_seen_cache): Update.
+	(clear_filename_seen_cache, delete_filename_seen_cache): Update.
+	(filename_seen): Update.
+
+2012-07-13  Doug Evans  <dje@google.com>
+
+	* symtab.c (filename_seen): Update comment.
+
+2012-07-13  Jan Kratochvil  <jan.kratochvil@redhat.com>
+	    Doug Evans  <dje@google.com>
+
+	* buildsym.c (end_symtab_1): Split it to ...
+	(end_symtab_get_static_block): ... this ...
+	(end_symtab_from_static_block): ... and this function.
+	(end_symtab, end_expandable_symtab): Call them.
+	* buildsym.h (end_symtab_get_static_block)
+	(end_symtab_from_static_block): New declarations.
+	* dwarf2read.c (process_full_comp_unit): New variable static_block.
+	Set its valid CU ranges.
+
+2012-07-13  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* dwarf2loc.c (disassemble_dwarf_expression): Handle
+	DW_OP_GNU_parameter_ref.
+
+2012-07-13  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* dwarf2read.c (read_call_site_scope): Do not gdb_assert for invalid
+	read-in CALL_SITE_PARAMETER_PARAM_OFFSET.
+
+2012-07-13  Doug Evans  <dje@google.com>
+
+	* symtab.c (output_source_filename): Delete unnecessary forward decl.
+	(filename_seen_cache): New struct.
+	(INITIAL_FILENAME_SEEN_CACHE_SIZE): New macro.
+	(create_filename_seen_cache): New function.
+	(clear_filename_seen_cache, delete_filename_seen_cache): New functions.
+	(filename_seen): Delete arg "first".  New arg "cache".  All callers
+	updated.
+	(output_source_filename_data): New struct.
+	(output_source_filename): Delete arg "first".  New arg "data".
+	All callers updated.
+	(sources_info): Delete local "first".  New locals "data", "cleanups".
+	Rewrite to use filename_seen_cache.
+	(add_partial_filename_data): Delete member "first".  New member
+	"filename_seen_cache".  All uses updated.
+	(make_source_files_completion_list): Rewrite to use
+	filename_seen_cache.
+
+2012-07-12  Doug Evans  <dje@google.com>
+
+	* psymtab.c (map_symbol_filenames_psymtab): Skip shared psymtabs.
+
+2012-07-10  Doug Evans  <dje@google.com>
+
+	PR gdb/13498
+	* dwarf2read.c (dwarf2_per_objfile): New members n_type_unit_groups,
+	all_type_unit_groups, type_unit_groups, tu_stats.
+	(dwarf2_per_cu_data): Move "imported_symtabs" into new union "s".
+	All uses updated.  Add type_unit_group to union "s".
+	(type_unit_group): New struct.
+	(IS_TYPE_UNIT_GROUP): New macro.
+	(abbrev_table): Delete unused member "section".
+	(dw2_do_instantiate_symtab): Early exit if type_unit_group.
+	(dw2_get_cu): Assert not used with type_unit_group.
+	(dw2_get_primary_cu): New function.
+	(dw2_build_type_unit_groups_reader): New function.
+	(dw2_build_type_unit_groups): New function.
+	(dw2_get_file_names): Assert not called on type units.
+	(dw2_map_symtabs_matching_filename): Call dw2_build_type_unit_groups.
+	Redo loop to iterate over type unit groups instead of type units.
+	(dw2_expand_symtabs_matching, dw2_map_symbol_filenames): Ditto.
+	(read_abbrev_offset): New function.
+	(init_cutu_and_read_dies): New arg "abbrev_table".  All callers
+	updated.
+	(create_partial_symtab): New function.
+	(process_psymtab_comp_unit_reader): Assert not used with type units.
+	Call create_partial_symtab.
+	(process_psymtab_type_unit): Delete.
+	(hash_type_unit_group, eq_type_unit_group): New functions.
+	(allocate_type_unit_groups_table): New function.
+	(NO_STMT_LIST_TYPE_UNIT_PSYMTAB): New macro.
+	(NO_STMT_LIST_TYPE_UNIT_PSYMTAB_SIZE): New macro.
+	(create_type_unit_group, get_type_unit_group): New functions.
+	(tu_abbrev_offset): New struct.
+	(sort_tu_by_abbrev_offset): New function.
+	(add_type_unit_group_to_table): New function.
+	(build_type_unit_groups): New function.
+	(build_type_psymtabs_reader): New function.
+	(build_type_psymtab_dependencies): New function.
+	(build_type_psymtabs): Rewrite.
+	(scan_partial_symbols): Flag an error if a DW_TAG_imported_unit
+	is seen in a type unit.
+	(process_queue): Move symtab expansion debugging printfs here.
+	Call process_full_type_unit for type units.
+	(compute_symtab_includes): Assert not called for type units.
+	(process_cu_includes): Don't call compute_symtab_includes for
+	type units.
+	(process_full_type_unit): New function.
+	(process_imported_unit_die): Flag an error if called for type units.
+	(handle_DW_AT_stmt_list): Delete arg "want_line_info".  All callers
+	updated.  Assert not called for type units.
+	(read_file_scope): Call dwarf2_start_symtab.
+	(setup_type_unit_groups): New function.
+	(read_type_unit_scope): Rewrite.
+	(abbrev_table_read_table): Initialize abbrev_table->offset.
+	(abbrev_table_free_cleanup): New function.
+	(dwarf2_start_symtab): New function.
+	(load_full_type_unit): Assert not called for type unit groups.
+	* buildsym.c (finish_block_internal): New arg "expandable".
+	All callers updated.
+	(start_symtab): Move most contents to ...
+	(restart_symtab): ... here.  New function.
+	(reset_symtab_globals): New function.
+	(end_symtab_1): Renamed from end_symtab.  New arg "expandable".
+	Call reset_symtab_globals.
+	(end_symtab, end_expandable_symtab): New functions.
+	(set_missing_symtab, augment_type_symtab): New functions.
+	* buildsym.h (end_expandable_symtab): Declare.
+	(augment_type_symtab, restart_symtab): Declare.
+	* psympriv.h (struct partial_symtab): New member "anonymous".
+	* psymtab.c (partial_map_symtabs_matching_filename): Ignore
+	anonymous psymtabs.
+	(read_psymtabs_with_filename): Ditto.
+	(map_symbol_filenames_psymtab, psymtab_to_fullname): Ditto.
+	(expand_symtabs_matching_via_partial): Ditto.
+	(dump_psymtab): Update.
+	* dictionary.c (dict_add_pending): New function.
+	* dictionary.h (dict_add_pending): Declare.
+
+2012-07-09  Doug Evans  <dje@google.com>
+
+	* buildsym.c (start_subfile): Remove unnecessary check for
+	name == NULL.
+
+	* psymtab.c (allocate_psymtab): Use host_address_to_string.
+
+	* dwarf2read.c (load_full_type_unit): Simplify.
+
+	* dwarf2read.c (dwarf2_per_objfile): Change type of all_type_units
+	to struct signatured_type **.  All uses updated.
+
+	* dwarf2read.c (dwarf2_attr_no_follow): Delete unused arg "cu".
+	All callers updated.
+
+2012-07-09  Tom Tromey  <tromey@redhat.com>
+
+	* c-exp.y (check_parameter_typelist): New function.
+	(parameter_typelist): Call it.
+	* eval.c (make_params): Handle '(void)' case.
+	* gdbtypes.c (lookup_function_type_with_arguments): Handle
+	'(void)' case.
+
+2012-07-07  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* common/linux-ptrace.c: Include gdb_assert.h.
+	<__i386__> (linux_ptrace_test_ret_to_nx_instr): New declaration.
+	<__i386__>: Include sys/reg.h, sys/mman.h, signal.h, sys/wait.h and
+	stdint.h.
+	(linux_ptrace_test_ret_to_nx, linux_ptrace_init_warnings): New
+	functions.
+	* common/linux-ptrace.h (linux_ptrace_init_warnings): New declarations.
+	* linux-nat.c (linux_child_post_attach)
+	(linux_child_post_startup_inferior): Call linux_ptrace_init_warnings.
+
+2012-07-07  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* linux-thread-db.c (thread_db_find_new_threads_silently): Do not apply
+	nptl <2.7 bug workaround for core files.
+
+2012-07-06  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* linux-nat.c (resume_lwp, linux_nat_resume): Remove LP->SIGINFO
+	clearing.
+	(save_siginfo): Remove.
+	(stop_wait_callback, linux_nat_filter_event): Remove the save_siginfo
+	call.
+	(resume_stopped_resumed_lwps): Remove LP->SIGINFO clearing.
+	(linux_nat_get_siginfo): Use PTRACE_GETSIGINFO.
+	* linux-nat.h (struct lwp_info): Remove field siginfo.
+
+2012-07-06  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	Code cleanup for the next patch.
+	* arm-linux-nat.c (arm_linux_stopped_data_address): Change variable
+	siginfo_p to siginfo, update its users incl. the linux_nat_get_siginfo
+	call for it.
+	* ia64-linux-nat.c (ia64_linux_stopped_data_address): Likewise.
+	(ia64_linux_stopped_data_address):
+	* linux-nat.c (linux_nat_get_siginfo): Add parameter siginfo, change
+	the return value.
+	* linux-nat.h (linux_nat_get_siginfo): Likewise.
+	* ppc-linux-nat.c (ppc_linux_stopped_data_address): Change variable
+	siginfo_p to siginfo, update its users incl. the linux_nat_get_siginfo
+	call for it.
+
+2012-07-06  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	PR 14321
+	* findcmd.c (parse_find_args): New variable pattern_buf_size_need.
+	Increase buffer sizes to 2x we need, not just 2x of the previous size.
+
+2012-07-06  Tom Tromey  <tromey@redhat.com>
+
+	* c-exp.y (DOTDOTDOT): New token.
+	(func_mod, exp): Use parameter_typelist.
+	(parameter_typelist): New production.
+	(tokentab3): Add "..." token.
+	* eval.c (make_params): Handle varargs.
+	* gdbtypes.c (lookup_function_type_with_arguments): Handle
+	varargs.
+
+2012-07-06  Tom Tromey  <tromey@redhat.com>
+
+	PR exp/9608:
+	* c-exp.y (%union) <tvec>: Change type.
+	(func_mod): Now uses <tvec> type.
+	(exp): Update for tvec change.
+	(direct_abs_decl): Push the typelist.
+	(func_mod): Return a typelist.
+	(nonempty_typelist): Update for tvec change.
+	* gdbtypes.c (lookup_function_type_with_arguments): New function.
+	* gdbtypes.h (lookup_function_type_with_arguments): Declare.
+	* parse.c (pop_type_list): New function.
+	(push_typelist): New function.
+	(follow_types): Handle tp_function_with_arguments.
+	* parser-defs.h (type_ptr): New typedef.  Define a VEC.
+	(enum type_pieces) <tp_function_with_arguments>: New constant.
+	(union type_stack_elt) <typelist_val>: New field.
+	(push_typelist): Declare.
+
+2012-07-06  Tom Tromey  <tromey@redhat.com>
+
+	* c-exp.y (%union) <type_stack>: New field.
+	(abs_decl, direct_abs_decl): Use <type_stack> type.  Update.
+	(ptr_operator_ts): New production.
+	(ptype): Update.
+	* parse.c (type_stack_reserve): New function.
+	(check_type_stack_depth): Use it.
+	(pop_type_stack, append_type_stack, push_type_stack)
+	(get_type_stack, type_stack_cleanup): New functions.
+	(follow_types): Handle tp_type_stack.
+	(_initialize_parse): Simplify initialization.
+	* parser-defs.h (enum type_pieces) <tp_type_stack>: New
+	constant.
+	(union type_stack_elt) <stack_val>: New field.
+	(get_type_stack, append_type_stack, push_type_stack)
+	(type_stack_cleanup): Declare.
+
+2012-07-06  Tom Tromey  <tromey@redhat.com>
+
+	* parser-defs.h (type_stack, type_stack_size, type_stack_depth):
+	Remove.
+	(struct type_stack): New.
+	* parse.c (type_stack, type_stack_size, type_stack_depth):
+	Remove.
+	(type_stac