This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Release 2.21.1 [again]


On Thu, May 26, 2011 at 09:54:31AM +0200, Tristan Gingold wrote:
> my understanding is that there is neither pending work nor pending patch for the 2.21.1 release.
> If I am wrong, please speak-up now.  My plan is to make this release in the next weeks.

I took a look at a diff between mainline and 2.21 to see what was
missing.

This applies fixes already on mainline to 2.21 for the following PRs
	PR 12365
	PR 12613
	PR 12632
	PR 12739
	PR 12753
	PR 12760
	PR 12763

I've also applied a number of other small fixes, ones that were
obvious or where I could easily determine that the benefits outweighed
the risk just from the diff.  I largely ignored target specific files.

bfd/
	Apply from mainline
	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-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-23  Nick Clifton  <nickc@redhat.com>
	* elf-m10300.c (mn10300_elf_mkobject): New function.
	(bfd_elf32_mkobject): Define.

	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-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-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-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  Anders Kaseorg  <andersk@ksplice.com>
	PR 12739
	* libbfd.c (bfd_get_8, bfd_get_signed_8): Use const cast.
	* bfd-in2.h: Regenerate.

	2011-04-28  Tom Tromey  <tromey@redhat.com>
	* bfdio.c (memory_bstat): Pass correct size to memset.

	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-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-07  Cary Coutant  <ccoutant@google.com>
	* dwarf2.c (scan_unit_for_symbols): Check for DW_AT_specification.

	2011-03-03  Michael Snyder  <msnyder@vmware.com>
	* aoutx.h (aout_final_link): Use sizeof int not sizeof int*.
	(aout_link_write_other_symbol): Missing break statement.

	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-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.

binutils/
	Apply from mainline
	2011-05-18  Nick Clifton  <nickc@redhat.com>
	PR binutils/12753
	* nm.c (filter_symbols): Treat unique symbols as global symbols.
	* doc/binutils.texi (nm): Mention that some lowercase letters
	actually indicate global symbols.

	2011-05-07  Alan Modra  <amodra@gmail.com>
	* objcopy.c (copy_archive): Check bfd_openw result in unknown object
	case.  Rewrite without goto.

	2011-04-03  H.J. Lu  <hongjiu.lu@intel.com>
	PR binutils/12632
	* objcopy.c (copy_unknown_object): Make the archive element
	readable.

binutils/testsuite/
	Apply from mainline
	2011-05-18  Nick Clifton  <nickc@redhat.com>
	PR binutils/12753
	* lib/utils-lib.exp (run_dump_test): Allow nm as a program.
	* binutils-all/nm.exp: Test running "nm -g" on an object file
	containing a unique symbol.

gas/
	Apply from mainline
	2011-03-18  Alan Modra  <amodra@gmail.com>
	* input-scrub.c (line_numberT): Delete.
	(input_scrub_close): Reset line counters.
	* messages.c (as_show_where): Don't print invalid line number.
	(as_warn_internal, as_bad_internal): Likewise.

	2011-03-18  Alan Modra  <amodra@gmail.com>
	* read.c (read_a_source_file): Remove md_after_pass_hook.
	Move "quit" label before set of dot_symbol.
	* config/tc-d10v.h (md_after_pass_hook): Don't define.
	* config/tc-d30v.h (md_after_pass_hook): Likewise.
	* config/tc-m32r.h (md_after_pass_hook): Likewise.
	(md_cleanup): Define to call m32r_fill_insn.

	2011-03-10  Alan Modra  <amodra@gmail.com>
	* gas/config/obj-elf.h (ELF_TARGET_SYMBOL_FIELDS,
	TARGET_SYMBOL_FIELDS): Don't define.
	* gas/config/tc-arc.c (arc_common): Use correct symbol "local" field.

	2011-03-09  Michael Snyder  <msnyder@vmware.com>
	* dwarf2dbg.c (emit_fixed_inc_line_addr): Correct assert.

gas/testsuite/
	Apply from mainline
	2011-03-18  Alan Modra  <amodra@gmail.com>
	* gas/i386/inval-equ-2.l: Adjust expected error.
	* gas/symver/symver2.l: Likewise.

include/
	Apply from mainline
	2011-05-17  Alan Modra  <amodra@gmail.com>
	PR ld/12760
	* bfdlink.h (struct bfd_link_callbacks <notice>): Add "flags" and
	"string" param.

	2011-05-16  Alan Modra  <amodra@gmail.com>
	* bfdlink.h (struct bfd_link_hash_entry): Remove u.undef.weak field.

	2011-04-25  Jan Kratochvil  <jan.kratochvil@redhat.com>
	* bfdlink.h (ENUM_BITFIELD): Remove.
	* ansidecl.h (ENUM_BITFIELD): New, from gcc/system.h.

ld/
	Apply from mainline
	2011-05-23  Alan Modra  <amodra@gmail.com>
	PR 12763
	* ldlang.c (lang_output_section_find_by_flags): Match orphan .sdata2
	like sections to existing .sdata2, and similarly for orphan TLS
	sections.
	* emultempl/elf32.em (place_orphan): Exclude .tbss from orphan_bss.

	2011-05-17  Alan Modra  <amodra@gmail.com>
	PR ld/12760
	* ldmain.c (notice): Add "flags" and "string" param.
	* plugin.c (plugin_notice): Likewise.  Handle indirect, warning
	and constructor syms.

	2010-05-16  Daniel Jacobowitz  <dan@codesourcery.com>
	* ldlang.c (print_assignment): Use the symbol's section if we
	use its value.
	* ldexp.c (exp_fold_tree_1): Skip self-assignment.  Expand
	comment on copying symbol type.

	2011-05-07  Dave Korn  <dave.korn.cygwin@gmail.com>
	PR ld/12365
	* scripttempl/pe.sc (__rt_psrelocs_start): New symbol definition.
	(__rt_psrelocs_end): Likewise.
	(__rt_psrelocs_size): Likewise difference between the above.
	(__RUNTIME_PSEUDO_RELOC_LIST_END__): Move outside .rdata section
	immediately after end of pseudo-reloc data.
	(___RUNTIME_PSEUDO_RELOC_LIST_END___): Likewise.
	(__RUNTIME_PSEUDO_RELOC_LIST__): Move outside .rdata section and
	calculate backward from list end.
	(___RUNTIME_PSEUDO_RELOC_LIST___): Likewise.
	* scripttempl/pep.sc: Likewise.

	2011-03-29  Alan Modra  <amodra@gmail.com>
	PR ld/12613
	* ldlex.l (lex_warn_invalid): Don't assume char is unsigned.

	2011-03-10  Dave Korn  <dave.korn.cygwin@gmail.com>
	* emultempl/pe.em (gld_${EMULATION_NAME}_place_orphan): Preserve
	alignment of input sections when creating orphan output sections
	during relocatable link.
	* emultempl/pep.em (gld_${EMULATION_NAME}_place_orphan): Likewise.

	2011-02-14  Mike Frysinger  <vapier@gentoo.org>
	* ldlang.c (lang_vers_match): Declare a new c_sym, assign it to
	the bfd_demangle of sym, change users of sym to c_sym when not
	already demangling, and free when done.  Change callers of
	cplus_demangle to bfd_demangle.

ld/testsuite/
	Apply from mainline
	2011-05-24  Hans-Peter Nilsson  <hp@axis.com>
	* ld-cris/tls-e-tpoffcomm1.d: Adjust for second PR12763 change,
	setting TLS file offset.

	2011-05-21  Hans-Peter Nilsson  <hp@axis.com>
	* ld-cris/tls-e-tpoffcomm1.d: Adjust for PR12763 change removing
	empty program header.

	2011-05-07  Dave Korn  <dave.korn.cygwin@gmail.com>
	PR ld/12365
	* ld-plugin/plugin-7.d: Allow underscore in error message.
	* ld-plugin/plugin-8.d: Likewise.

Index: bfd/aoutx.h
===================================================================
RCS file: /cvs/src/src/bfd/aoutx.h,v
retrieving revision 1.84.2.1
diff -u -p -r1.84.2.1 aoutx.h
--- bfd/aoutx.h	1 Feb 2011 12:25:32 -0000	1.84.2.1
+++ bfd/aoutx.h	29 May 2011 03:23:00 -0000
@@ -3637,6 +3637,7 @@ aout_link_write_other_symbol (struct aou
     case bfd_link_hash_undefweak:
       type = N_WEAKU;
       val = 0;
+      break;
     case bfd_link_hash_indirect:
       /* We ignore these symbols, since the indirected symbol is
 	 already in the hash table.  */
@@ -5448,7 +5449,7 @@ NAME (aout, final_link) (bfd *abfd,
   /* Allocate buffers to hold section contents and relocs.  */
   aout_info.contents = (bfd_byte *) bfd_malloc (max_contents_size);
   aout_info.relocs = bfd_malloc (max_relocs_size);
-  aout_info.symbol_map = (int *) bfd_malloc (max_sym_count * sizeof (int *));
+  aout_info.symbol_map = (int *) bfd_malloc (max_sym_count * sizeof (int));
   aout_info.output_syms = (struct external_nlist *)
       bfd_malloc ((max_sym_count + 1) * sizeof (struct external_nlist));
   if ((aout_info.contents == NULL && max_contents_size != 0)
Index: bfd/archive.c
===================================================================
RCS file: /cvs/src/src/bfd/archive.c,v
retrieving revision 1.69.2.3
diff -u -p -r1.69.2.3 archive.c
--- bfd/archive.c	4 Mar 2011 01:44:21 -0000	1.69.2.3
+++ bfd/archive.c	29 May 2011 03:23:01 -0000
@@ -661,10 +661,6 @@ _bfd_get_elt_at_filepos (bfd *archive, f
   if (_bfd_add_bfd_to_archive_cache (archive, filepos, n_nfd))
     return n_nfd;
 
-  /* Huh?  */
-  /* FIXME:  n_nfd isn't allocated in the archive's memory pool.
-     If we reach this point, I think bfd_release will abort.  */
-  bfd_release (archive, n_nfd);
   bfd_release (archive, new_areldata);
   return NULL;
 }
Index: bfd/bfdio.c
===================================================================
RCS file: /cvs/src/src/bfd/bfdio.c,v
retrieving revision 1.27
diff -u -p -r1.27 bfdio.c
--- bfd/bfdio.c	9 Jun 2010 13:28:31 -0000	1.27
+++ bfd/bfdio.c	29 May 2011 03:23:04 -0000
@@ -1,7 +1,7 @@
 /* Low-level I/O routines for BFDs.
 
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011
    Free Software Foundation, Inc.
 
    Written by Cygnus Support.
@@ -577,7 +577,7 @@ memory_bstat (bfd *abfd, struct stat *st
 {
   struct bfd_in_memory *bim = (struct bfd_in_memory *) abfd->iostream;
 
-  memset (statbuf, 0, sizeof (statbuf));
+  memset (statbuf, 0, sizeof (*statbuf));
   statbuf->st_size = bim->size;
 
   return 0;
Index: bfd/coff-aux.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-aux.c,v
retrieving revision 1.10.10.1
diff -u -p -r1.10.10.1 coff-aux.c
--- bfd/coff-aux.c	27 Apr 2011 07:17:36 -0000	1.10.10.1
+++ bfd/coff-aux.c	29 May 2011 03:23:04 -0000
@@ -105,7 +105,8 @@ coff_m68k_aux_link_add_one_symbol (info,
 	  && (bfd_hash_lookup (info->notice_hash, name, FALSE, FALSE)
 	      != (struct bfd_hash_entry *) NULL))
 	{
-	  if (! (*info->callbacks->notice) (info, h, abfd, section, value))
+	  if (! (*info->callbacks->notice) (info, h, abfd, section, value,
+					    flags, string))
 	    return FALSE;
 	}
 
Index: bfd/coffcode.h
===================================================================
RCS file: /cvs/src/src/bfd/coffcode.h,v
retrieving revision 1.171
diff -u -p -r1.171 coffcode.h
--- bfd/coffcode.h	4 Nov 2010 16:03:22 -0000	1.171
+++ bfd/coffcode.h	29 May 2011 03:23:06 -0000
@@ -3295,6 +3295,8 @@ coff_compute_section_file_positions (bfd
       if (!(current->flags & SEC_HAS_CONTENTS))
 	continue;
 
+      current->rawsize = current->size;
+
 #ifdef COFF_IMAGE_WITH_PE
       /* Make sure we skip empty sections in a PE image.  */
       if (current->size == 0)
@@ -3361,7 +3363,7 @@ coff_compute_section_file_positions (bfd
 
 #ifdef COFF_IMAGE_WITH_PE
       /* Set the padded size.  */
-      current->size = (current->size + page_size -1) & -page_size;
+      current->size = (current->size + page_size - 1) & -page_size;
 #endif
 
       sofar += current->size;
@@ -4852,7 +4854,7 @@ coff_slurp_symbol_table (bfd * abfd)
 		 to the symbol instead of the index.  FIXME: This
 		 should use a union.  */
 	      src->u.syment.n_value =
-		(long) (native_symbols + src->u.syment.n_value);
+		(long) (intptr_t) (native_symbols + src->u.syment.n_value);
 	      dst->symbol.value = src->u.syment.n_value;
 	      src->fix_value = 1;
 	      break;
Index: bfd/coffgen.c
===================================================================
RCS file: /cvs/src/src/bfd/coffgen.c,v
retrieving revision 1.78
diff -u -p -r1.78 coffgen.c
--- bfd/coffgen.c	27 Apr 2010 14:42:50 -0000	1.78
+++ bfd/coffgen.c	29 May 2011 03:23:07 -0000
@@ -915,6 +915,9 @@ coff_write_symbol (bfd *abfd,
   unsigned int numaux = native->u.syment.n_numaux;
   int type = native->u.syment.n_type;
   int n_sclass = (int) native->u.syment.n_sclass;
+  asection *output_section = symbol->section->output_section
+			       ? symbol->section->output_section
+			       : symbol->section;
   void * buf;
   bfd_size_type symesz;
 
@@ -933,7 +936,7 @@ coff_write_symbol (bfd *abfd,
 
   else
     native->u.syment.n_scnum =
-      symbol->section->output_section->target_index;
+      output_section->target_index;
 
   coff_fix_symbol_name (abfd, symbol, native, string_size_p,
 			debug_string_section_p, debug_string_size_p);
@@ -990,6 +993,9 @@ coff_write_alien_symbol (bfd *abfd,
 {
   combined_entry_type *native;
   combined_entry_type dummy;
+  asection *output_section = symbol->section->output_section
+			       ? symbol->section->output_section
+			       : symbol->section;
 
   native = &dummy;
   native->u.syment.n_type = T_NULL;
@@ -1015,12 +1021,11 @@ coff_write_alien_symbol (bfd *abfd,
     }
   else
     {
-      native->u.syment.n_scnum =
-	symbol->section->output_section->target_index;
+      native->u.syment.n_scnum = output_section->target_index;
       native->u.syment.n_value = (symbol->value
 				  + symbol->section->output_offset);
       if (! obj_pe (abfd))
-	native->u.syment.n_value += symbol->section->output_section->vma;
+	native->u.syment.n_value += output_section->vma;
 
       /* Copy the any flags from the file header into the symbol.
          FIXME: Why?  */
Index: bfd/cofflink.c
===================================================================
RCS file: /cvs/src/src/bfd/cofflink.c,v
retrieving revision 1.74.2.1
diff -u -p -r1.74.2.1 cofflink.c
--- bfd/cofflink.c	1 Feb 2011 12:25:33 -0000	1.74.2.1
+++ bfd/cofflink.c	29 May 2011 03:23:08 -0000
@@ -2365,6 +2365,35 @@ _bfd_coff_link_input_bfd (struct coff_fi
 	  if (internal_relocs == NULL)
 	    return FALSE;
 
+	  /* Run through the relocs looking for relocs against symbols
+	     coming from discarded sections and complain about them.  */
+	  irel = internal_relocs;
+	  for (; irel < &internal_relocs[o->reloc_count]; irel++)
+	    {
+	      struct coff_link_hash_entry *h;
+	      asection *ps = NULL;
+	      long symndx = irel->r_symndx;
+	      if (symndx < 0)
+		continue;
+	      h = obj_coff_sym_hashes (input_bfd)[symndx];
+	      if (h == NULL)
+		continue;
+	      while (h->root.type == bfd_link_hash_indirect
+		     || h->root.type == bfd_link_hash_warning)
+		h = (struct coff_link_hash_entry *) h->root.u.i.link;
+	      if (h->root.type == bfd_link_hash_defined
+		  || h->root.type == bfd_link_hash_defweak)
+		ps = h->root.u.def.section;
+	      if (ps == NULL)
+		continue;
+	      /* Complain if definition comes from an excluded section.  */
+	      if (ps->flags & SEC_EXCLUDE)
+		(*finfo->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);
+	    }
+
 	  /* Call processor specific code to relocate the section
              contents.  */
 	  if (! bfd_coff_relocate_section (output_bfd, finfo->info,
Index: bfd/configure.in
===================================================================
RCS file: /cvs/src/src/bfd/configure.in,v
retrieving revision 1.287.2.4
diff -u -p -r1.287.2.4 configure.in
--- bfd/configure.in	1 Apr 2011 12:04:25 -0000	1.287.2.4
+++ bfd/configure.in	29 May 2011 03:23:15 -0000
@@ -488,9 +488,13 @@ changequote([,])dnl
     BFD_HAVE_SYS_PROCFS_TYPE(pxstatus_t)
     BFD_HAVE_SYS_PROCFS_TYPE(pstatus32_t)
     BFD_HAVE_SYS_PROCFS_TYPE(prpsinfo_t)
+    BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(prpsinfo_t, pr_pid)
     BFD_HAVE_SYS_PROCFS_TYPE(prpsinfo32_t)
+    BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(prpsinfo32_t, pr_pid)
     BFD_HAVE_SYS_PROCFS_TYPE(psinfo_t)
+    BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(psinfo_t, pr_pid)
     BFD_HAVE_SYS_PROCFS_TYPE(psinfo32_t)
+    BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(psinfo32_t, pr_pid)
     BFD_HAVE_SYS_PROCFS_TYPE(lwpstatus_t)
     BFD_HAVE_SYS_PROCFS_TYPE(lwpxstatus_t)
     BFD_HAVE_SYS_PROCFS_TYPE_MEMBER(lwpstatus_t, pr_context)
Index: bfd/dwarf2.c
===================================================================
RCS file: /cvs/src/src/bfd/dwarf2.c,v
retrieving revision 1.138
diff -u -p -r1.138 dwarf2.c
--- bfd/dwarf2.c	29 Oct 2010 12:10:23 -0000	1.138
+++ bfd/dwarf2.c	29 May 2011 03:23:16 -0000
@@ -2164,6 +2164,7 @@ scan_unit_for_symbols (struct comp_unit 
 		  break;
 
 		case DW_AT_abstract_origin:
+		case DW_AT_specification:
 		  func->name = find_abstract_instance_name (unit, &attr);
 		  break;
 
Index: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.313.2.2
diff -u -p -r1.313.2.2 elf-bfd.h
--- bfd/elf-bfd.h	27 Apr 2011 07:17:36 -0000	1.313.2.2
+++ bfd/elf-bfd.h	29 May 2011 03:23:17 -0000
@@ -229,11 +229,7 @@ struct elf_link_hash_entry
 };
 
 /* Will references to this symbol always reference the symbol
-   in this object?  STV_PROTECTED is excluded from the visibility test
-   here so that function pointer comparisons work properly.  Since
-   function symbols not defined in an app are set to their .plt entry,
-   it's necessary for shared libs to also reference the .plt even
-   though the symbol is really local to the shared lib.  */
+   in this object?  */
 #define SYMBOL_REFERENCES_LOCAL(INFO, H) \
   _bfd_elf_symbol_refs_local_p (H, INFO, 0)
 
Index: bfd/elf-m10300.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-m10300.c,v
retrieving revision 1.106
diff -u -p -r1.106 elf-m10300.c
--- bfd/elf-m10300.c	25 Oct 2010 15:54:13 -0000	1.106
+++ bfd/elf-m10300.c	29 May 2011 03:23:19 -0000
@@ -4882,6 +4882,22 @@ _bfd_mn10300_elf_reloc_type_class (const
     }
 }
 
+/* Allocate space for an MN10300 extension to the bfd elf data structure.  */
+
+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),
+				  MN10300_ELF_DATA);
+}
+
+#define bfd_elf32_mkobject	mn10300_elf_mkobject
+
 #ifndef ELF_ARCH
 #define TARGET_LITTLE_SYM	bfd_elf32_mn10300_vec
 #define TARGET_LITTLE_NAME	"elf32-mn10300"
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.524.2.2
diff -u -p -r1.524.2.2 elf.c
--- bfd/elf.c	27 Apr 2011 07:17:36 -0000	1.524.2.2
+++ bfd/elf.c	29 May 2011 03:23:22 -0000
@@ -976,7 +976,9 @@ _bfd_elf_make_section_from_shdr (bfd *ab
       phdr = elf_tdata (abfd)->phdr;
       for (i = 0; i < elf_elfheader (abfd)->e_phnum; i++, phdr++)
 	{
-	  if (phdr->p_type == PT_LOAD
+	  if (((phdr->p_type == PT_LOAD
+		&& (hdr->sh_flags & SHF_TLS) == 0)
+	       || phdr->p_type == PT_TLS)
 	      && ELF_SECTION_IN_SEGMENT (hdr, phdr))
 	    {
 	      if ((flags & SEC_LOAD) == 0)
@@ -3980,8 +3982,12 @@ _bfd_elf_map_sections_to_segments (bfd *
 	  phdr_in_segment = FALSE;
 	}
 
-      /* Create a final PT_LOAD program segment.  */
-      if (last_hdr != NULL)
+      /* Create a final PT_LOAD program segment, but not if it's just
+	 for .tbss.  */
+      if (last_hdr != NULL
+	  && (i - phdr_index != 1
+	      || ((last_hdr->flags & (SEC_THREAD_LOCAL | SEC_LOAD))
+		  != SEC_THREAD_LOCAL)))
 	{
 	  m = make_mapping (abfd, sections, phdr_index, i, phdr_in_segment);
 	  if (m == NULL)
@@ -4661,11 +4667,24 @@ assign_file_positions_for_load_sections 
 	    }
 	  else
 	    {
-	      if (p->p_type == PT_LOAD)
+	      if (p->p_type == PT_LOAD
+		  || (this_hdr->sh_type == SHT_NOBITS
+		      && (this_hdr->sh_flags & SHF_TLS) != 0
+		      && this_hdr->sh_offset == 0))
 		{
-		  this_hdr->sh_offset = sec->filepos = off;
-		  if (this_hdr->sh_type != SHT_NOBITS)
-		    off += this_hdr->sh_size;
+		  if (this_hdr->sh_type == SHT_NOBITS)
+		    {
+		      /* These sections don't really need sh_offset,
+			 but give them one anyway.  */
+		      bfd_vma adjust = vma_page_aligned_bias (this_hdr->sh_addr,
+							      off, align);
+		      this_hdr->sh_offset = sec->filepos = off + adjust;
+		    }
+		  else
+		    {
+		      this_hdr->sh_offset = sec->filepos = off;
+		      off += this_hdr->sh_size;
+		    }
 		}
 
 	      if (this_hdr->sh_type != SHT_NOBITS)
@@ -4731,7 +4750,8 @@ assign_file_positions_for_load_sections 
 
 	      sec = m->sections[i];
 	      this_hdr = &(elf_section_data(sec)->this_hdr);
-	      if (!ELF_SECTION_IN_SEGMENT_1 (this_hdr, p, check_vma, 0))
+	      if (!ELF_SECTION_IN_SEGMENT_1 (this_hdr, p, check_vma, 0)
+		  && !ELF_TBSS_SPECIAL (this_hdr, p))
 		{
 		  (*_bfd_error_handler)
 		    (_("%B: section `%A' can't be allocated in segment %d"),
@@ -4902,17 +4922,21 @@ assign_file_positions_for_non_load_secti
 	      && (p->p_type != PT_NOTE
 		  || bfd_get_format (abfd) != bfd_core))
 	    {
-	      Elf_Internal_Shdr *hdr;
-	      asection *sect;
-
 	      BFD_ASSERT (!m->includes_filehdr && !m->includes_phdrs);
 
-	      sect = m->sections[m->count - 1];
-	      hdr = &elf_section_data (sect)->this_hdr;
-	      p->p_filesz = sect->filepos - m->sections[0]->filepos;
-	      if (hdr->sh_type != SHT_NOBITS)
-		p->p_filesz += hdr->sh_size;
+	      p->p_filesz = 0;
 	      p->p_offset = m->sections[0]->filepos;
+	      for (i = m->count; i-- != 0;)
+		{
+		  asection *sect = m->sections[i];
+		  Elf_Internal_Shdr *hdr = &elf_section_data (sect)->this_hdr;
+		  if (hdr->sh_type != SHT_NOBITS)
+		    {
+		      p->p_filesz = (sect->filepos - m->sections[0]->filepos
+				     + hdr->sh_size);
+		      break;
+		    }
+		}
 	    }
 	}
       else if (m->includes_filehdr)
@@ -7975,6 +7999,9 @@ elfcore_grok_psinfo (bfd *abfd, Elf_Inte
 
       memcpy (&psinfo, note->descdata, sizeof (psinfo));
 
+#if defined (HAVE_PSINFO_T_PR_PID) || defined (HAVE_PRPSINFO_T_PR_PID)
+      elf_tdata (abfd)->core_pid = psinfo.pr_pid;
+#endif
       elf_tdata (abfd)->core_program
 	= _bfd_elfcore_strndup (abfd, psinfo.pr_fname,
 				sizeof (psinfo.pr_fname));
@@ -7991,6 +8018,9 @@ elfcore_grok_psinfo (bfd *abfd, Elf_Inte
 
       memcpy (&psinfo, note->descdata, sizeof (psinfo));
 
+#if defined (HAVE_PSINFO32_T_PR_PID) || defined (HAVE_PRPSINFO32_T_PR_PID)
+      elf_tdata (abfd)->core_pid = psinfo.pr_pid;
+#endif
       elf_tdata (abfd)->core_program
 	= _bfd_elfcore_strndup (abfd, psinfo.pr_fname,
 				sizeof (psinfo.pr_fname));
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.290.2.3
diff -u -p -r1.290.2.3 elf32-ppc.c
--- bfd/elf32-ppc.c	27 Apr 2011 07:17:37 -0000	1.290.2.3
+++ bfd/elf32-ppc.c	29 May 2011 03:23:25 -0000
@@ -1881,6 +1881,8 @@ ppc_elf_grok_psinfo (bfd *abfd, Elf_Inte
       return FALSE;
 
     case 128:		/* Linux/PPC elf_prpsinfo.  */
+      elf_tdata (abfd)->core_pid
+	= bfd_get_32 (abfd, note->descdata + 16);
       elf_tdata (abfd)->core_program
 	= _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
       elf_tdata (abfd)->core_command
Index: bfd/elf32-rx.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-rx.c,v
retrieving revision 1.5.2.1
diff -u -p -r1.5.2.1 elf32-rx.c
--- bfd/elf32-rx.c	23 May 2011 19:50:38 -0000	1.5.2.1
+++ bfd/elf32-rx.c	29 May 2011 03:23:26 -0000
@@ -20,6 +20,7 @@
 
 #include "sysdep.h"
 #include "bfd.h"
+#include "bfd_stdint.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
 #include "elf/rx.h"
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.339.2.10
diff -u -p -r1.339.2.10 elf64-ppc.c
--- bfd/elf64-ppc.c	13 May 2011 05:58:02 -0000	1.339.2.10
+++ bfd/elf64-ppc.c	29 May 2011 03:23:31 -0000
@@ -2670,6 +2670,8 @@ ppc64_elf_grok_psinfo (bfd *abfd, Elf_In
   if (note->descsz != 136)
     return FALSE;
 
+  elf_tdata (abfd)->core_pid
+    = bfd_get_32 (abfd, note->descdata + 24);
   elf_tdata (abfd)->core_program
     = _bfd_elfcore_strndup (abfd, note->descdata + 40, 16);
   elf_tdata (abfd)->core_command
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.388.2.2
diff -u -p -r1.388.2.2 elflink.c
--- bfd/elflink.c	27 Apr 2011 07:17:38 -0000	1.388.2.2
+++ bfd/elflink.c	29 May 2011 03:23:35 -0000
@@ -2881,8 +2881,10 @@ _bfd_elf_symbol_refs_local_p (struct elf
     return TRUE;
 
   /* Function pointer equality tests may require that STV_PROTECTED
-     symbols be treated as dynamic symbols, even when we know that the
-     dynamic linker will resolve them locally.  */
+     symbols be treated as dynamic symbols.  If the address of a
+     function not defined in an executable is set to that function's
+     plt entry in the executable, then the address of the function in
+     a shared library must also be the plt entry in the executable.  */
   return local_protected;
 }
 
@@ -3814,7 +3816,7 @@ error_free_dyn:
       /* Make a special call to the linker "notice" function to
 	 tell it that we are about to handle an as-needed lib.  */
       if (!(*info->callbacks->notice) (info, NULL, abfd, NULL,
-				       notice_as_needed))
+				       notice_as_needed, 0, NULL))
 	goto error_free_vers;
 
       /* Clone the symbol table and sym hashes.  Remember some
@@ -4240,10 +4242,7 @@ error_free_dyn:
 		 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))
+	  if (align > old_alignment)
 	    h->root.u.c.p->alignment_power = align;
 	  else
 	    h->root.u.c.p->alignment_power = old_alignment;
@@ -4561,7 +4560,7 @@ error_free_dyn:
       /* Make a special call to the linker "notice" function to
 	 tell it that symbols added for crefs may need to be removed.  */
       if (!(*info->callbacks->notice) (info, NULL, abfd, NULL,
-				       notice_not_needed))
+				       notice_not_needed, 0, NULL))
 	goto error_free_vers;
 
       free (old_tab);
@@ -4575,7 +4574,7 @@ error_free_dyn:
   if (old_tab != NULL)
     {
       if (!(*info->callbacks->notice) (info, NULL, abfd, NULL,
-				       notice_needed))
+				       notice_needed, 0, NULL))
 	goto error_free_vers;
       free (old_tab);
       old_tab = NULL;
@@ -5724,11 +5723,12 @@ bfd_elf_size_dynamic_sections (bfd *outp
 	    {
 	      const char *verstr, *name;
 	      size_t namelen, verlen, newlen;
-	      char *newname, *p;
+	      char *newname, *p, leading_char;
 	      struct elf_link_hash_entry *newh;
 
+	      leading_char = bfd_get_symbol_leading_char (output_bfd);
 	      name = d->pattern;
-	      namelen = strlen (name);
+	      namelen = strlen (name) + (leading_char != '\0');
 	      verstr = t->name;
 	      verlen = strlen (verstr);
 	      newlen = namelen + verlen + 3;
@@ -5736,7 +5736,8 @@ bfd_elf_size_dynamic_sections (bfd *outp
 	      newname = (char *) bfd_malloc (newlen);
 	      if (newname == NULL)
 		return FALSE;
-	      memcpy (newname, name, namelen);
+	      newname[0] = leading_char;
+	      memcpy (newname + (leading_char != '\0'), name, namelen);
 
 	      /* Check the hidden versioned definition.  */
 	      p = newname + namelen;
@@ -6538,10 +6539,13 @@ bfd_elf_size_dynsym_hash_dynstr (bfd *ou
 	    }
 	  else
 	    {
-	      unsigned long int maskwords, maskbitslog2;
+	      unsigned long int maskwords, maskbitslog2, x;
 	      BFD_ASSERT (cinfo.min_dynindx != -1);
 
-	      maskbitslog2 = bfd_log2 (cinfo.nsyms) + 1;
+	      x = cinfo.nsyms;
+	      maskbitslog2 = 1;
+	      while ((x >>= 1) != 0)
+		++maskbitslog2;
 	      if (maskbitslog2 < 3)
 		maskbitslog2 = 5;
 	      else if ((1 << (maskbitslog2 - 2)) & cinfo.nsyms)
Index: bfd/elfxx-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-ia64.c,v
retrieving revision 1.228.2.1
diff -u -p -r1.228.2.1 elfxx-ia64.c
--- bfd/elfxx-ia64.c	1 Feb 2011 12:25:33 -0000	1.228.2.1
+++ bfd/elfxx-ia64.c	29 May 2011 03:23:37 -0000
@@ -636,7 +636,7 @@ elfNN_ia64_relax_br (bfd_byte *contents,
   bfd_byte *hit_addr;
 
   hit_addr = (bfd_byte *) (contents + off);
-  br_slot = (long) hit_addr & 0x3;
+  br_slot = (intptr_t) hit_addr & 0x3;
   hit_addr -= br_slot;
   t0 = bfd_getl64 (hit_addr + 0);
   t1 = bfd_getl64 (hit_addr + 8);
@@ -738,7 +738,7 @@ elfNN_ia64_relax_brl (bfd_byte *contents
   bfd_vma t0, t1, i0, i1, i2;
 
   hit_addr = (bfd_byte *) (contents + off);
-  hit_addr -= (long) hit_addr & 0x3;
+  hit_addr -= (intptr_t) hit_addr & 0x3;
   t0 = bfd_getl64 (hit_addr);
   t1 = bfd_getl64 (hit_addr + 8);
 
@@ -3874,7 +3874,7 @@ elfNN_ia64_install_value (bfd_byte *hit_
   switch (opnd)
     {
     case IA64_OPND_IMMU64:
-      hit_addr -= (long) hit_addr & 0x3;
+      hit_addr -= (intptr_t) hit_addr & 0x3;
       t0 = bfd_getl64 (hit_addr);
       t1 = bfd_getl64 (hit_addr + 8);
 
@@ -3903,7 +3903,7 @@ elfNN_ia64_install_value (bfd_byte *hit_
       break;
 
     case IA64_OPND_TGT64:
-      hit_addr -= (long) hit_addr & 0x3;
+      hit_addr -= (intptr_t) hit_addr & 0x3;
       t0 = bfd_getl64 (hit_addr);
       t1 = bfd_getl64 (hit_addr + 8);
 
@@ -3928,7 +3928,7 @@ elfNN_ia64_install_value (bfd_byte *hit_
       break;
 
     default:
-      switch ((long) hit_addr & 0x3)
+      switch ((intptr_t) hit_addr & 0x3)
 	{
 	case 0: shift =  5; break;
 	case 1: shift = 14; hit_addr += 3; break;
Index: bfd/libbfd.c
===================================================================
RCS file: /cvs/src/src/bfd/libbfd.c,v
retrieving revision 1.53.2.1
diff -u -p -r1.53.2.1 libbfd.c
--- bfd/libbfd.c	1 Feb 2011 12:25:34 -0000	1.53.2.1
+++ bfd/libbfd.c	29 May 2011 03:23:38 -0000
@@ -431,9 +431,9 @@ DESCRIPTION
 .#define bfd_put_signed_8 \
 .  bfd_put_8
 .#define bfd_get_8(abfd, ptr) \
-.  (*(unsigned char *) (ptr) & 0xff)
+.  (*(const unsigned char *) (ptr) & 0xff)
 .#define bfd_get_signed_8(abfd, ptr) \
-.  (((*(unsigned char *) (ptr) & 0xff) ^ 0x80) - 0x80)
+.  (((*(const unsigned char *) (ptr) & 0xff) ^ 0x80) - 0x80)
 .
 .#define bfd_put_16(abfd, val, ptr) \
 .  BFD_SEND (abfd, bfd_putx16, ((val),(ptr)))
@@ -968,8 +968,12 @@ bfd_log2 (bfd_vma x)
 {
   unsigned int result = 0;
 
-  while ((x = (x >> 1)) != 0)
+  if (x <= 1)
+    return result;
+  --x;
+  do
     ++result;
+  while ((x >>= 1) != 0);
   return result;
 }
 
Index: bfd/linker.c
===================================================================
RCS file: /cvs/src/src/bfd/linker.c,v
retrieving revision 1.77.2.2
diff -u -p -r1.77.2.2 linker.c
--- bfd/linker.c	27 Apr 2011 07:17:41 -0000	1.77.2.2
+++ bfd/linker.c	29 May 2011 03:23:39 -0000
@@ -1607,7 +1607,8 @@ _bfd_generic_link_add_one_symbol (struct
       || (info->notice_hash != NULL
 	  && bfd_hash_lookup (info->notice_hash, name, FALSE, FALSE) != NULL))
     {
-      if (! (*info->callbacks->notice) (info, h, abfd, section, value))
+      if (! (*info->callbacks->notice) (info, h,
+					abfd, section, value, flags, string))
 	return FALSE;
     }
 
@@ -1640,7 +1641,6 @@ _bfd_generic_link_add_one_symbol (struct
 	  /* Make a new weak undefined symbol.  */
 	  h->type = bfd_link_hash_undefweak;
 	  h->u.undef.abfd = abfd;
-	  h->u.undef.weak = abfd;
 	  break;
 
 	case CDEF:
Index: bfd/peXXigen.c
===================================================================
RCS file: /cvs/src/src/bfd/peXXigen.c,v
retrieving revision 1.67
diff -u -p -r1.67 peXXigen.c
--- bfd/peXXigen.c	22 Sep 2010 08:01:56 -0000	1.67
+++ bfd/peXXigen.c	29 May 2011 03:23:40 -0000
@@ -2449,15 +2449,23 @@ _bfd_XXi_final_link_postscript (bfd * ab
 
     if (sec)
       {
-	bfd_size_type x = sec->rawsize ? sec->rawsize : sec->size;
+	bfd_size_type x = sec->rawsize;
+	bfd_byte *tmp_data = NULL;
 
-	if (x && bfd_get_section_contents (abfd, sec, pfinfo->contents, 0, x))
+	if (x)
+	  tmp_data = bfd_malloc (x);
+
+	if (tmp_data != NULL)
 	  {
-	    qsort (pfinfo->contents,
-	    	   (size_t) ((sec->size <x ? sec->size : x) / 12),
-	    	   12, sort_x64_pdata);
-	    bfd_set_section_contents (pfinfo->output_bfd, sec,
-	    			      pfinfo->contents, 0, x);
+	    if (bfd_get_section_contents (abfd, sec, tmp_data, 0, x))
+	      {
+		qsort (tmp_data,
+		       (size_t) (x / 12),
+		       12, sort_x64_pdata);
+		bfd_set_section_contents (pfinfo->output_bfd, sec,
+					  tmp_data, 0, x);
+	      }
+	    free (tmp_data);
 	  }
       }
   }
Index: bfd/vms-alpha.c
===================================================================
RCS file: /cvs/src/src/bfd/vms-alpha.c,v
retrieving revision 1.37.2.1
diff -u -p -r1.37.2.1 vms-alpha.c
--- bfd/vms-alpha.c	1 Feb 2011 12:25:34 -0000	1.37.2.1
+++ bfd/vms-alpha.c	29 May 2011 03:23:43 -0000
@@ -1709,7 +1709,7 @@ _bfd_vms_slurp_etir (bfd *abfd, struct b
 #if VMS_DEBUG
       _bfd_vms_debug (4, "etir: %s(%d)\n",
                       _bfd_vms_etir_name (cmd), cmd);
-      _bfd_hexdump (8, ptr, cmd_length - 4, (long) ptr);
+      _bfd_hexdump (8, ptr, cmd_length - 4, (intptr_t) ptr);
 #endif
 
       switch (cmd)
Index: bfd/hosts/x86-64linux.h
===================================================================
RCS file: /cvs/src/src/bfd/hosts/x86-64linux.h,v
retrieving revision 1.2
diff -u -p -r1.2 x86-64linux.h
--- bfd/hosts/x86-64linux.h	10 Apr 2010 22:52:37 -0000	1.2
+++ bfd/hosts/x86-64linux.h	29 May 2011 03:23:43 -0000
@@ -40,6 +40,8 @@ typedef unsigned int uint32_t;
 
 #undef HAVE_PRPSINFO32_T
 #define HAVE_PRPSINFO32_T
+#undef HAVE_PRPSINFO32_T_PR_PID
+#define HAVE_PRPSINFO32_T_PR_PID
 
 #undef HAVE_PRSTATUS32_T
 #define HAVE_PRSTATUS32_T
Index: binutils/nm.c
===================================================================
RCS file: /cvs/src/src/binutils/nm.c,v
retrieving revision 1.65
diff -u -p -r1.65 nm.c
--- binutils/nm.c	8 Oct 2010 15:12:29 -0000	1.65
+++ binutils/nm.c	29 May 2011 03:23:48 -0000
@@ -436,6 +436,8 @@ filter_symbols (bfd *abfd, bfd_boolean i
       else if (external_only)
 	keep = ((sym->flags & BSF_GLOBAL) != 0
 		|| (sym->flags & BSF_WEAK) != 0
+		/* PR binutls/12753: Unique symbols are global too.  */
+		|| (sym->flags & BSF_GNU_UNIQUE) != 0
 		|| bfd_is_und_section (sym->section)
 		|| bfd_is_com_section (sym->section));
       else
Index: binutils/objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.147.2.1
diff -u -p -r1.147.2.1 objcopy.c
--- binutils/objcopy.c	1 Feb 2011 12:25:36 -0000	1.147.2.1
+++ binutils/objcopy.c	29 May 2011 03:23:49 -0000
@@ -1,6 +1,6 @@
 /* objcopy.c -- copy object file from input to output, optionally massaging it.
    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
 
    This file is part of GNU Binutils.
@@ -1399,7 +1399,9 @@ copy_unknown_object (bfd *ibfd, bfd *obf
       ncopied += tocopy;
     }
 
-  chmod (bfd_get_filename (obfd), buf.st_mode);
+  /* We should at least to be able to read it back when copying an
+     unknown object in an archive.  */
+  chmod (bfd_get_filename (obfd), buf.st_mode | S_IRUSR);
   free (cbuf);
   return TRUE;
 }
@@ -2022,6 +2024,7 @@ copy_archive (bfd *ibfd, bfd *obfd, cons
       struct stat buf;
       int stat_status = 0;
       bfd_boolean del = TRUE;
+      bfd_boolean ok_object;
 
       /* Create an output file for this member.  */
       output_name = concat (dir, "/",
@@ -2059,44 +2062,42 @@ copy_archive (bfd *ibfd, bfd *obfd, cons
       l->obfd = NULL;
       list = l;
 
-      if (bfd_check_format (this_element, bfd_object))
+      ok_object = bfd_check_format (this_element, bfd_object);
+      if (!ok_object)
+	bfd_nonfatal_message (NULL, this_element, NULL,
+			      _("Unable to recognise the format of file"));
+
+      /* PR binutils/3110: Cope with archives
+	 containing multiple target types.  */
+      if (force_output_target || !ok_object)
+	output_bfd = bfd_openw (output_name, output_target);
+      else
+	output_bfd = bfd_openw (output_name, bfd_get_target (this_element));
+
+      if (output_bfd == NULL)
 	{
-	  /* PR binutils/3110: Cope with archives
-	     containing multiple target types.  */
-	  if (force_output_target)
-	    output_bfd = bfd_openw (output_name, output_target);
-	  else
-	    output_bfd = bfd_openw (output_name, bfd_get_target (this_element));
+	  bfd_nonfatal_message (output_name, NULL, NULL, NULL);
+	  status = 1;
+	  return;
+	}
 
-	  if (output_bfd == NULL)
+      if (ok_object)
+	{
+	  del = !copy_object (this_element, output_bfd, input_arch);
+
+	  if (del && bfd_get_arch (this_element) == bfd_arch_unknown)
+	    /* Try again as an unknown object file.  */
+	    ok_object = FALSE;
+	  else if (!bfd_close (output_bfd))
 	    {
 	      bfd_nonfatal_message (output_name, NULL, NULL, NULL);
+	      /* Error in new object file. Don't change archive.  */
 	      status = 1;
-	      return;
 	    }
-
- 	  del = ! copy_object (this_element, output_bfd, input_arch);
-
-	  if (! del
-	      || bfd_get_arch (this_element) != bfd_arch_unknown)
-	    {
-	      if (!bfd_close (output_bfd))
-		{
-		  bfd_nonfatal_message (output_name, NULL, NULL, NULL);
-		  /* Error in new object file. Don't change archive.  */
-		  status = 1;
-		}
-	    }
-	  else
-	    goto copy_unknown_element;
 	}
-      else
-	{
-	  bfd_nonfatal_message (NULL, this_element, NULL,
-				_("Unable to recognise the format of file"));
 
-	  output_bfd = bfd_openw (output_name, output_target);
-copy_unknown_element:
+      if (!ok_object)
+	{
 	  del = !copy_unknown_object (this_element, output_bfd);
 	  if (!bfd_close_all_done (output_bfd))
 	    {
Index: binutils/doc/binutils.texi
===================================================================
RCS file: /cvs/src/src/binutils/doc/binutils.texi,v
retrieving revision 1.173.2.1
diff -u -p -r1.173.2.1 binutils.texi
--- binutils/doc/binutils.texi	1 Feb 2011 12:25:36 -0000	1.173.2.1
+++ binutils/doc/binutils.texi	29 May 2011 03:23:52 -0000
@@ -724,7 +724,9 @@ hexadecimal by default.
 @item
 The symbol type.  At least the following types are used; others are, as
 well, depending on the object file format.  If lowercase, the symbol is
-local; if uppercase, the symbol is global (external).
+usually local; if uppercase, the symbol is global (external).  There
+are however a few lowercase symbols that are shown for special global
+symbols (@code{u}, @code{v} and @code{w}).
 
 @c Some more detail on exactly what these symbol types are used for
 @c would be nice.
Index: binutils/testsuite/binutils-all/nm.exp
===================================================================
RCS file: /cvs/src/src/binutils/testsuite/binutils-all/nm.exp,v
retrieving revision 1.5
diff -u -p -r1.5 nm.exp
--- binutils/testsuite/binutils-all/nm.exp	2 Sep 2009 07:22:32 -0000	1.5
+++ binutils/testsuite/binutils-all/nm.exp	29 May 2011 03:23:57 -0000
@@ -98,6 +98,41 @@ if {![info exists vars(text_symbol)] \
     pass "nm -g"
 }
 
+if [is_elf_format] {
+    # PR binutils/12753
+    # Test nm -g on a unique global symbol.
+
+    # Only some targets support unique symbols.
+    if {([istarget "i?86-*-*"]
+	 || [istarget "x86_64-*-*"]
+	 || [istarget "arm-*-*"]
+	 || [istarget "powerpc*-*-*"]
+	 || [istarget "sparc*-*-*"])} then {
+
+	if {![binutils_assemble $srcdir/$subdir/unique.s tmpdir/unique.o]} then {
+	    fail "nm -g on unique symbols (assembling)"
+	} else {
+	    if [is_remote host] {
+		set tmpfile [remote_download host tmpdir/unique.o]
+	    } else {
+		set tmpfile tmpdir/unique.o
+	    }
+	
+	    set got [binutils_run $NM "$NMFLAGS -g $tmpfile"]
+
+	    if [regexp "u foo" $got] then {
+		pass "nm -g on unique symbols"
+	    } else {
+		fail "nm -g on unique symbols"
+	    }
+
+	    if { $verbose < 1 } {
+		remote_file host delete "tmpdir/unique.o"
+	    }
+	}
+   }
+}
+
 # Test nm -P
 
 # This test does not work correctly on ECOFF targets, because ECOFF
Index: binutils/testsuite/lib/utils-lib.exp
===================================================================
RCS file: /cvs/src/src/binutils/testsuite/lib/utils-lib.exp,v
retrieving revision 1.20.2.1
diff -u -p -r1.20.2.1 utils-lib.exp
--- binutils/testsuite/lib/utils-lib.exp	10 Feb 2011 03:41:06 -0000	1.20.2.1
+++ binutils/testsuite/lib/utils-lib.exp	29 May 2011 03:23:57 -0000
@@ -354,6 +354,7 @@ proc run_dump_test { name {extra_options
 	}
 	strings	{ set program strings }
 	elfedit { set program elfedit }
+	nm      { set program nm }
 	default	{
 	    perror "unrecognized program option $opts(PROG) in $file.d"
 	    unresolved $testname
Index: gas/dwarf2dbg.c
===================================================================
RCS file: /cvs/src/src/gas/dwarf2dbg.c,v
retrieving revision 1.107
diff -u -p -r1.107 dwarf2dbg.c
--- gas/dwarf2dbg.c	5 Jul 2010 15:07:19 -0000	1.107
+++ gas/dwarf2dbg.c	29 May 2011 03:23:59 -0000
@@ -1080,7 +1080,7 @@ emit_fixed_inc_line_addr (int line_delta
       symbolS *to_sym;
       expressionS exp;
 
-      gas_assert (pexp->X_op = O_subtract);
+      gas_assert (pexp->X_op == O_subtract);
       to_sym = pexp->X_add_symbol;
 
       *p++ = DW_LNS_extended_op;
Index: gas/input-scrub.c
===================================================================
RCS file: /cvs/src/src/gas/input-scrub.c,v
retrieving revision 1.23
diff -u -p -r1.23 input-scrub.c
--- gas/input-scrub.c	30 Mar 2010 23:20:25 -0000	1.23
+++ gas/input-scrub.c	29 May 2011 03:23:59 -0000
@@ -1,6 +1,6 @@
 /* input_scrub.c - Break up input buffers into whole numbers of lines.
    Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   2000, 2001, 2003, 2005, 2006, 2007, 2008
+   2000, 2001, 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
@@ -99,10 +99,9 @@ int macro_nest;
 static char *physical_input_file;
 static char *logical_input_file;
 
-typedef unsigned int line_numberT;	/* 1-origin line number in a source file.  */
+/* 1-origin line number in a source file.  */
 /* A line ends in '\n' or eof.  */
-
-static line_numberT physical_input_line;
+static unsigned int physical_input_line;
 static int logical_input_line;
 
 /* Struct used to save the state of the input handler during include files */
@@ -114,7 +113,7 @@ struct input_save {
   unsigned int        buffer_length;
   char *              physical_input_file;
   char *              logical_input_file;
-  line_numberT        physical_input_line;
+  unsigned int        physical_input_line;
   int                 logical_input_line;
   int                 sb_index;
   sb                  from_sb;
@@ -303,6 +302,8 @@ void
 input_scrub_close (void)
 {
   input_file_close ();
+  physical_input_line = 0;
+  logical_input_line = -1;
 }
 
 char *
Index: gas/messages.c
===================================================================
RCS file: /cvs/src/src/gas/messages.c,v
retrieving revision 1.23
diff -u -p -r1.23 messages.c
--- gas/messages.c	3 Jun 2010 07:36:04 -0000	1.23
+++ gas/messages.c	29 May 2011 03:23:59 -0000
@@ -1,6 +1,6 @@
 /* messages.c - error reporter -
    Copyright 1987, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2001,
-   2003, 2004, 2005, 2006, 2007, 2008
+   2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
    This file is part of GAS, the GNU Assembler.
 
@@ -113,7 +113,12 @@ as_show_where (void)
   as_where (&file, &line);
   identify (file);
   if (file)
-    fprintf (stderr, "%s:%u: ", file, line);
+    {
+      if (line != 0)
+	fprintf (stderr, "%s:%u: ", file, line);
+      else
+	fprintf (stderr, "%s: ", file);
+    }
 }
 
 /* Send to stderr a string as a warning, and locate warning
@@ -146,7 +151,12 @@ as_warn_internal (char *file, unsigned i
 
   identify (file);
   if (file)
-    fprintf (stderr, "%s:%u: ", file, line);
+    {
+      if (line != 0)
+	fprintf (stderr, "%s:%u: ", file, line);
+      else
+	fprintf (stderr, "%s: ", file);
+    }
   fprintf (stderr, _("Warning: "));
   fputs (buffer, stderr);
   (void) putc ('\n', stderr);
@@ -207,7 +217,12 @@ as_bad_internal (char *file, unsigned in
 
   identify (file);
   if (file)
-    fprintf (stderr, "%s:%u: ", file, line);
+    {
+      if (line != 0)
+	fprintf (stderr, "%s:%u: ", file, line);
+      else
+	fprintf (stderr, "%s: ", file);
+    }
   fprintf (stderr, _("Error: "));
   fputs (buffer, stderr);
   (void) putc ('\n', stderr);
Index: gas/read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.167.2.2
diff -u -p -r1.167.2.2 read.c
--- gas/read.c	17 Mar 2011 11:00:47 -0000	1.167.2.2
+++ gas/read.c	29 May 2011 03:24:01 -0000
@@ -1124,14 +1124,10 @@ read_a_source_file (char *name)
 	  /* Report unknown char as error.  */
 	  demand_empty_rest_of_line ();
 	}
-
-#ifdef md_after_pass_hook
-      md_after_pass_hook ();
-#endif
     }
-  symbol_set_value_now (&dot_symbol);
 
  quit:
+  symbol_set_value_now (&dot_symbol);
 
 #ifdef md_cleanup
   md_cleanup ();
Index: gas/config/obj-elf.h
===================================================================
RCS file: /cvs/src/src/gas/config/obj-elf.h,v
retrieving revision 1.38
diff -u -p -r1.38 obj-elf.h
--- gas/config/obj-elf.h	23 Oct 2010 18:05:08 -0000	1.38
+++ gas/config/obj-elf.h	29 May 2011 03:24:01 -0000
@@ -1,6 +1,7 @@
 /* ELF object file format.
    Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005, 2006, 2007, 2009  Free Software Foundation, Inc.
+   2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011
+   Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -80,14 +81,6 @@ struct elf_obj_sy
 
 #define OBJ_SYMFIELD_TYPE struct elf_obj_sy
 
-/* Symbol fields used by the ELF back end.  */
-#define ELF_TARGET_SYMBOL_FIELDS unsigned int local:1;
-
-/* Don't change this; change ELF_TARGET_SYMBOL_FIELDS instead.  */
-#ifndef TARGET_SYMBOL_FIELDS
-#define TARGET_SYMBOL_FIELDS ELF_TARGET_SYMBOL_FIELDS
-#endif
-
 #ifndef FALSE
 #define FALSE 0
 #define TRUE  !FALSE
Index: gas/config/tc-arc.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arc.c,v
retrieving revision 1.47
diff -u -p -r1.47 tc-arc.c
--- gas/config/tc-arc.c	25 Sep 2009 19:13:26 -0000	1.47
+++ gas/config/tc-arc.c	29 May 2011 03:24:02 -0000
@@ -1,6 +1,6 @@
 /* tc-arc.c -- Assembler for the ARC
    Copyright 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2006, 2007, 2009  Free Software Foundation, Inc.
+   2006, 2007, 2009, 2011  Free Software Foundation, Inc.
    Contributed by Doug Evans (dje@cygnus.com).
 
    This file is part of GAS, the GNU Assembler.
@@ -934,7 +934,7 @@ arc_common (int localScope)
       S_SET_SIZE       (symbolP, size);
       S_SET_SEGMENT    (symbolP, bss_section);
       S_CLEAR_EXTERNAL (symbolP);
-      symbolP->local = 1;
+      symbol_get_obj (symbolP)->local = 1;
       subseg_set (old_sec, old_subsec);
     }
   else
Index: gas/config/tc-d10v.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-d10v.h,v
retrieving revision 1.20
diff -u -p -r1.20 tc-d10v.h
--- gas/config/tc-d10v.h	3 Aug 2010 10:53:10 -0000	1.20
+++ gas/config/tc-d10v.h	29 May 2011 03:24:02 -0000
@@ -1,6 +1,6 @@
 /* tc-d10v.h -- Header file for tc-d10v.c.
    Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2005, 2007, 2009,
-   2010 Free Software Foundation, Inc.
+   2010, 2011 Free Software Foundation, Inc.
    Written by Martin Hunt, Cygnus Support.
 
    This file is part of GAS, the GNU Assembler.
@@ -47,7 +47,6 @@ long md_pcrel_from_section (struct fix *
 
 int d10v_cleanup (void);
 void d10v_frob_label (symbolS *);
-#define md_after_pass_hook()	     d10v_cleanup ()
 #define md_cleanup()		     d10v_cleanup ()
 #define md_do_align(a,b,c,d,e)	     d10v_cleanup ()
 #define tc_frob_label(sym)	     d10v_frob_label (sym)
Index: gas/config/tc-d30v.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-d30v.h,v
retrieving revision 1.15
diff -u -p -r1.15 tc-d30v.h
--- gas/config/tc-d30v.h	2 Sep 2009 07:24:20 -0000	1.15
+++ gas/config/tc-d30v.h	29 May 2011 03:24:02 -0000
@@ -1,5 +1,5 @@
 /* tc-310v.h -- Header file for tc-d30v.c.
-   Copyright 1997, 1998, 2000, 2001, 2002, 2005, 2007, 2009
+   Copyright 1997, 1998, 2000, 2001, 2002, 2005, 2007, 2009, 2011
    Free Software Foundation, Inc.
    Written by Martin Hunt, Cygnus Support.
 
@@ -46,7 +46,6 @@ extern long md_pcrel_from_section (struc
 #define md_number_to_chars           number_to_chars_bigendian
 
 int d30v_cleanup (int);
-#define md_after_pass_hook()	     d30v_cleanup (FALSE)
 #define md_cleanup()		     d30v_cleanup (FALSE)
 #define TC_START_LABEL(ch, s, ptr)      (ch == ':' && d30v_cleanup (FALSE))
 void d30v_start_line (void);
Index: gas/config/tc-m32r.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-m32r.h,v
retrieving revision 1.23
diff -u -p -r1.23 tc-m32r.h
--- gas/config/tc-m32r.h	2 Sep 2009 07:24:20 -0000	1.23
+++ gas/config/tc-m32r.h	29 May 2011 03:24:02 -0000
@@ -1,6 +1,6 @@
 /* tc-m32r.h -- Header file for tc-m32r.c.
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2007, 2009 Free Software Foundation, Inc.
+   2007, 2009, 2011 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
@@ -101,10 +101,9 @@ extern int m32r_force_relocation (struct
 
 /* Ensure insns at labels are aligned to 32 bit boundaries.  */
 int m32r_fill_insn (int);
-#define md_after_pass_hook()	m32r_fill_insn (1)
 #define TC_START_LABEL(ch, s, ptr)	(ch == ':' && m32r_fill_insn (0))
 
-#define md_cleanup                 m32r_elf_section_change_hook
+#define md_cleanup()               m32r_fill_insn (1)
 #define md_elf_section_change_hook m32r_elf_section_change_hook
 extern void m32r_elf_section_change_hook (void);
 
Index: gas/testsuite/gas/i386/inval-equ-2.l
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/i386/inval-equ-2.l,v
retrieving revision 1.1
diff -u -p -r1.1 inval-equ-2.l
--- gas/testsuite/gas/i386/inval-equ-2.l	3 Mar 2008 15:28:58 -0000	1.1
+++ gas/testsuite/gas/i386/inval-equ-2.l	29 May 2011 03:24:07 -0000
@@ -1,7 +1,7 @@
 .*: Assembler messages:
-.*:8: Error: .*
-.*:8: Error: .*
-.*:8: Error: .*
+.*: Error: .*
+.*: Error: .*
+.*: Error: .*
 GAS LISTING .*
 
 
Index: gas/testsuite/gas/symver/symver2.l
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/symver/symver2.l,v
retrieving revision 1.1
diff -u -p -r1.1 symver2.l
--- gas/testsuite/gas/symver/symver2.l	13 Nov 2000 21:36:14 -0000	1.1
+++ gas/testsuite/gas/symver/symver2.l	29 May 2011 03:24:10 -0000
@@ -1,2 +1,2 @@
 .*: Assembler messages:
-.*:8: Error: invalid attempt to declare external version name as default in symbol `foo@@version1'
+.*: Error: invalid attempt to declare external version name as default in symbol `foo@@version1'
Index: include/ansidecl.h
===================================================================
RCS file: /cvs/src/src/include/ansidecl.h,v
retrieving revision 1.28
diff -u -p -r1.28 ansidecl.h
--- include/ansidecl.h	5 Jan 2010 21:10:23 -0000	1.28
+++ include/ansidecl.h	29 May 2011 03:24:10 -0000
@@ -416,6 +416,15 @@ So instead we use the macro below and te
 #define EXPORTED_CONST const
 #endif
 
+/* Be conservative and only use enum bitfields with GCC.
+   FIXME: provide a complete autoconf test for buggy enum bitfields.  */
+
+#if (GCC_VERSION > 2000)
+#define ENUM_BITFIELD(TYPE) __extension__ enum TYPE
+#else
+#define ENUM_BITFIELD(TYPE) unsigned int
+#endif
+
 #ifdef __cplusplus
 }
 #endif
Index: include/bfdlink.h
===================================================================
RCS file: /cvs/src/src/include/bfdlink.h,v
retrieving revision 1.82.2.1
diff -u -p -r1.82.2.1 bfdlink.h
--- include/bfdlink.h	27 Apr 2011 07:17:42 -0000	1.82.2.1
+++ include/bfdlink.h	29 May 2011 03:24:10 -0000
@@ -23,12 +23,6 @@
 #ifndef BFDLINK_H
 #define BFDLINK_H
 
-#if (__GNUC__ * 1000 + __GNUC_MINOR__ > 2000)
-#define ENUM_BITFIELD(TYPE) __extension__ enum TYPE
-#else
-#define ENUM_BITFIELD(TYPE) unsigned int
-#endif
-
 /* Which symbols to strip during a link.  */
 enum bfd_link_strip
 {
@@ -128,7 +122,6 @@ struct bfd_link_hash_entry
 	     undefined symbol list.  */
 	  struct bfd_link_hash_entry *next;
 	  bfd *abfd;		/* BFD symbol was found in.  */
-	  bfd *weak;		/* BFD weak symbol was found in.  */
 	} undef;
       /* bfd_link_hash_defined, bfd_link_hash_defweak.  */
       struct
@@ -579,10 +572,13 @@ struct bfd_link_callbacks
   /* A function which is called when a symbol in notice_hash is
      defined or referenced.  H is the symbol.  ABFD, SECTION and
      ADDRESS are the (new) value of the symbol.  If SECTION is
-     bfd_und_section, this is a reference.  */
+     bfd_und_section, this is a reference.  FLAGS are the symbol
+     BSF_* flags.  STRING is the name of the symbol to indirect to if
+     the sym is indirect, or the warning string if a warning sym.  */
   bfd_boolean (*notice)
     (struct bfd_link_info *, struct bfd_link_hash_entry *h,
-     bfd *abfd, asection *section, bfd_vma address);
+     bfd *abfd, asection *section, bfd_vma address, flagword flags,
+     const char *string);
   /* Error or warning link info message.  */
   void (*einfo)
     (const char *fmt, ...);
Index: ld/ldexp.c
===================================================================
RCS file: /cvs/src/src/ld/ldexp.c,v
retrieving revision 1.87.2.2
diff -u -p -r1.87.2.2 ldexp.c
--- ld/ldexp.c	3 May 2011 15:16:40 -0000	1.87.2.2
+++ ld/ldexp.c	29 May 2011 03:24:12 -0000
@@ -832,6 +832,8 @@ exp_fold_tree_1 (etree_type *tree)
 	}
       else
 	{
+	  etree_type *name;
+
 	  struct bfd_link_hash_entry *h = NULL;
 
 	  if (tree->type.node_class == etree_provide)
@@ -849,6 +851,23 @@ exp_fold_tree_1 (etree_type *tree)
 		}
 	    }
 
+	  name = tree->assign.src;
+	  if (name->type.node_class == etree_trinary)
+	    {
+	      exp_fold_tree_1 (name->trinary.cond);
+	      if (expld.result.valid_p)
+		name = (expld.result.value
+			? name->trinary.lhs : name->trinary.rhs);
+	    }
+
+	  if (name->type.node_class == etree_name
+	      && name->type.node_code == NAME
+	      && strcmp (tree->assign.dst, name->name.name) == 0)
+	    /* Leave it alone.  Do not replace a symbol with its own
+	       output address, in case there is another section sizing
+	       pass.  Folding does not preserve input sections.  */
+	    break;
+
 	  exp_fold_tree_1 (tree->assign.src);
 	  if (expld.result.valid_p
 	      || (expld.phase == lang_first_phase_enum
@@ -876,7 +895,8 @@ exp_fold_tree_1 (etree_type *tree)
 		tree->type.node_class = etree_provided;
 
 	      /* Copy the symbol type if this is a simple assignment of
-	         one symbol to annother.  */
+	         one symbol to another.  This could be more general
+		 (e.g. a ?: operator with NAMEs in each branch).  */
 	      if (tree->assign.src->type.node_class == etree_name)
 		{
 		  struct bfd_link_hash_entry *hsrc;
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.347.2.5
diff -u -p -r1.347.2.5 ldlang.c
--- ld/ldlang.c	16 May 2011 00:53:46 -0000	1.347.2.5
+++ ld/ldlang.c	29 May 2011 03:24:15 -0000
@@ -1526,8 +1526,14 @@ lang_output_section_find_by_flags (const
 	    }
 	  flags ^= sec->flags;
 	  if (!(flags & (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD
-			 | SEC_READONLY))
-	      && !(look->flags & (SEC_SMALL_DATA | SEC_THREAD_LOCAL)))
+			 | SEC_READONLY | SEC_SMALL_DATA))
+	      || (!(flags & (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD
+			     | SEC_READONLY))
+		  && !(look->flags & SEC_SMALL_DATA))
+	      || (!(flags & (SEC_THREAD_LOCAL | SEC_ALLOC))
+		  && (look->flags & SEC_THREAD_LOCAL)
+		  && (!(flags & SEC_LOAD)
+		      || (look->flags & SEC_LOAD))))
 	    found = look;
 	}
     }
@@ -3995,9 +4001,8 @@ print_assignment (lang_assignment_statem
 	  if (h)
 	    {
 	      value = h->u.def.value;
-
-	      if (expld.result.section != NULL)
-		value += expld.result.section->vma;
+	      value += h->u.def.section->output_section->vma;
+	      value += h->u.def.section->output_offset;
 
 	      minfo ("[0x%V]", value);
 	    }
@@ -7387,19 +7392,29 @@ lang_vers_match (struct bfd_elf_version_
 		 struct bfd_elf_version_expr *prev,
 		 const char *sym)
 {
+  const char *c_sym;
   const char *cxx_sym = sym;
   const char *java_sym = sym;
   struct bfd_elf_version_expr *expr = NULL;
+  enum demangling_styles curr_style;
+
+  curr_style = CURRENT_DEMANGLING_STYLE;
+  cplus_demangle_set_style (no_demangling);
+  c_sym = bfd_demangle (link_info.output_bfd, sym, DMGL_NO_OPTS);
+  if (!c_sym)
+    c_sym = sym;
+  cplus_demangle_set_style (curr_style);
 
   if (head->mask & BFD_ELF_VERSION_CXX_TYPE)
     {
-      cxx_sym = cplus_demangle (sym, DMGL_PARAMS | DMGL_ANSI);
+      cxx_sym = bfd_demangle (link_info.output_bfd, sym,
+			      DMGL_PARAMS | DMGL_ANSI);
       if (!cxx_sym)
 	cxx_sym = sym;
     }
   if (head->mask & BFD_ELF_VERSION_JAVA_TYPE)
     {
-      java_sym = cplus_demangle (sym, DMGL_JAVA);
+      java_sym = bfd_demangle (link_info.output_bfd, sym, DMGL_JAVA);
       if (!java_sym)
 	java_sym = sym;
     }
@@ -7413,10 +7428,10 @@ lang_vers_match (struct bfd_elf_version_
 	case 0:
 	  if (head->mask & BFD_ELF_VERSION_C_TYPE)
 	    {
-	      e.pattern = sym;
+	      e.pattern = c_sym;
 	      expr = (struct bfd_elf_version_expr *)
                   htab_find ((htab_t) head->htab, &e);
-	      while (expr && strcmp (expr->pattern, sym) == 0)
+	      while (expr && strcmp (expr->pattern, c_sym) == 0)
 		if (expr->mask == BFD_ELF_VERSION_C_TYPE)
 		  goto out_ret;
 		else
@@ -7474,12 +7489,14 @@ lang_vers_match (struct bfd_elf_version_
       else if (expr->mask == BFD_ELF_VERSION_CXX_TYPE)
 	s = cxx_sym;
       else
-	s = sym;
+	s = c_sym;
       if (fnmatch (expr->pattern, s, 0) == 0)
 	break;
     }
 
  out_ret:
+  if (c_sym != sym)
+    free ((char *) c_sym);
   if (cxx_sym != sym)
     free ((char *) cxx_sym);
   if (java_sym != sym)
Index: ld/ldlex.l
===================================================================
RCS file: /cvs/src/src/ld/ldlex.l,v
retrieving revision 1.47.2.2
diff -u -p -r1.47.2.2 ldlex.l
--- ld/ldlex.l	1 Apr 2011 12:04:29 -0000	1.47.2.2
+++ ld/ldlex.l	29 May 2011 03:24:15 -0000
@@ -688,7 +688,7 @@ lex_warn_invalid (char *where, char *wha
 
   if (! ISPRINT (*what))
     {
-      sprintf (buf, "\\%03o", (unsigned int) *what);
+      sprintf (buf, "\\%03o", *(unsigned char *) what);
       what = buf;
     }
 
Index: ld/ldmain.c
===================================================================
RCS file: /cvs/src/src/ld/ldmain.c,v
retrieving revision 1.145.2.3
diff -u -p -r1.145.2.3 ldmain.c
--- ld/ldmain.c	27 Apr 2011 07:17:43 -0000	1.145.2.3
+++ ld/ldmain.c	29 May 2011 03:24:15 -0000
@@ -151,7 +151,7 @@ static bfd_boolean unattached_reloc
   (struct bfd_link_info *, const char *, bfd *, asection *, bfd_vma);
 static bfd_boolean notice
   (struct bfd_link_info *, struct bfd_link_hash_entry *,
-   bfd *, asection *, bfd_vma);
+   bfd *, asection *, bfd_vma, flagword, const char *);
 
 static struct bfd_link_callbacks link_callbacks =
 {
@@ -1483,7 +1483,9 @@ notice (struct bfd_link_info *info,
 	struct bfd_link_hash_entry *h,
 	bfd *abfd,
 	asection *section,
-	bfd_vma value)
+	bfd_vma value,
+	flagword flags ATTRIBUTE_UNUSED,
+	const char *string ATTRIBUTE_UNUSED)
 {
   const char *name;
 
Index: ld/plugin.c
===================================================================
RCS file: /cvs/src/src/ld/plugin.c,v
retrieving revision 1.7.2.5
diff -u -p -r1.7.2.5 plugin.c
--- ld/plugin.c	16 May 2011 00:54:45 -0000	1.7.2.5
+++ ld/plugin.c	29 May 2011 03:24:16 -0000
@@ -125,9 +125,9 @@ static const enum ld_plugin_tag tv_heade
 static const size_t tv_header_size = ARRAY_SIZE (tv_header_tags);
 
 /* Forward references.  */
-static bfd_boolean plugin_notice (struct bfd_link_info *info,
-				  struct bfd_link_hash_entry *h, bfd *abfd,
-				  asection *section, bfd_vma value);
+static bfd_boolean plugin_notice (struct bfd_link_info *,
+				  struct bfd_link_hash_entry *, bfd *,
+				  asection *, bfd_vma, flagword, const char *);
 
 #if !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H)
 
@@ -908,7 +908,9 @@ plugin_notice (struct bfd_link_info *inf
 	       struct bfd_link_hash_entry *h,
 	       bfd *abfd,
 	       asection *section,
-	       bfd_vma value)
+	       bfd_vma value,
+	       flagword flags,
+	       const char *string)
 {
   if (h != NULL)
     {
@@ -918,8 +920,33 @@ plugin_notice (struct bfd_link_info *inf
       if (is_ir_dummy_bfd (abfd))
 	return TRUE;
 
+      /* Making an indirect symbol counts as a reference unless this
+	 is a brand new symbol.  */
+      if (bfd_is_ind_section (section)
+	  || (flags & BSF_INDIRECT) != 0)
+	{
+	  if (h->type != bfd_link_hash_new)
+	    {
+	      struct bfd_link_hash_entry *inh;
+
+	      h->non_ir_ref = TRUE;
+	      inh = bfd_wrapped_link_hash_lookup (abfd, info, string, FALSE,
+						  FALSE, FALSE);
+	      if (inh != NULL)
+		inh->non_ir_ref = TRUE;
+	    }
+	}
+
+      /* Nothing to do here for warning symbols.  */
+      else if ((flags & BSF_WARNING) != 0)
+	;
+
+      /* Nothing to do here for constructor symbols.  */
+      else if ((flags & BSF_CONSTRUCTOR) != 0)
+	;
+
       /* If this is a ref, set non_ir_ref.  */
-      if (bfd_is_und_section (section))
+      else if (bfd_is_und_section (section))
 	h->non_ir_ref = TRUE;
 
       /* Otherwise, it must be a new def.  Ensure any symbol defined
@@ -945,6 +972,7 @@ plugin_notice (struct bfd_link_info *inf
       || (info->notice_hash != NULL
 	  && bfd_hash_lookup (info->notice_hash, h->root.string,
 			      FALSE, FALSE) != NULL))
-    return (*orig_callbacks->notice) (info, h, abfd, section, value);
+    return (*orig_callbacks->notice) (info, h,
+				      abfd, section, value, flags, string);
   return TRUE;
 }
Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.214.2.1
diff -u -p -r1.214.2.1 elf32.em
--- ld/emultempl/elf32.em	1 Feb 2011 12:25:47 -0000	1.214.2.1
+++ ld/emultempl/elf32.em	29 May 2011 03:24:17 -0000
@@ -1919,7 +1919,7 @@ gld${EMULATION_NAME}_place_orphan (asect
 	   && ((iself && sh_type == SHT_NOTE)
 	       || (!iself && CONST_STRNEQ (secname, ".note"))))
     place = &hold[orphan_interp];
-  else if ((s->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
+  else if ((s->flags & (SEC_LOAD | SEC_HAS_CONTENTS | SEC_THREAD_LOCAL)) == 0)
     place = &hold[orphan_bss];
   else if ((s->flags & SEC_SMALL_DATA) != 0)
     place = &hold[orphan_sdata];
Index: ld/emultempl/pe.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pe.em,v
retrieving revision 1.162.2.2
diff -u -p -r1.162.2.2 pe.em
--- ld/emultempl/pe.em	28 Apr 2011 15:33:57 -0000	1.162.2.2
+++ ld/emultempl/pe.em	29 May 2011 03:24:18 -0000
@@ -2009,10 +2009,17 @@ gld_${EMULATION_NAME}_place_orphan (asec
 		     ->output_section_statement);
 	}
 
-      /* All sections in an executable must be aligned to a page boundary.  */
+      /* All sections in an executable must be aligned to a page boundary.
+	 In a relocatable link, just preserve the incoming alignment; the
+	 address is discarded by lang_insert_orphan in that case, anyway.  */
       address = exp_unop (ALIGN_K, exp_nameop (NAME, "__section_alignment__"));
       os = lang_insert_orphan (s, secname, constraint, after, place, address,
 			       &add_child);
+      if (link_info.relocatable)
+	{
+	  os->section_alignment = s->alignment_power;
+	  os->bfd_section->alignment_power = s->alignment_power;
+	}
     }
 
   /* If the section name has a '\$', sort it with the other '\$'
Index: ld/emultempl/pep.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pep.em,v
retrieving revision 1.38.2.1
diff -u -p -r1.38.2.1 pep.em
--- ld/emultempl/pep.em	1 Feb 2011 12:25:47 -0000	1.38.2.1
+++ ld/emultempl/pep.em	29 May 2011 03:24:19 -0000
@@ -1745,10 +1745,17 @@ gld_${EMULATION_NAME}_place_orphan (asec
 		     ->output_section_statement);
 	}
 
-      /* All sections in an executable must be aligned to a page boundary.  */
+      /* All sections in an executable must be aligned to a page boundary.
+	 In a relocatable link, just preserve the incoming alignment; the
+	 address is discarded by lang_insert_orphan in that case, anyway.  */
       address = exp_unop (ALIGN_K, exp_nameop (NAME, "__section_alignment__"));
       os = lang_insert_orphan (s, secname, constraint, after, place, address,
 			       &add_child);
+      if (link_info.relocatable)
+	{
+	  os->section_alignment = s->alignment_power;
+	  os->bfd_section->alignment_power = s->alignment_power;
+	}
     }
 
   /* If the section name has a '\$', sort it with the other '\$'
Index: ld/scripttempl/pe.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/pe.sc,v
retrieving revision 1.24
diff -u -p -r1.24 pe.sc
--- ld/scripttempl/pe.sc	4 Nov 2010 16:03:24 -0000	1.24
+++ ld/scripttempl/pe.sc	29 May 2011 03:24:20 -0000
@@ -106,12 +106,15 @@ SECTIONS
   .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
   {
     ${R_RDATA}
-    ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = .;}
-    ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = .;}
+    ${RELOCATING+__rt_psrelocs_start = .;}
     *(.rdata_runtime_pseudo_reloc)
-    ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
-    ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
+    ${RELOCATING+__rt_psrelocs_end = .;}
   }
+  ${RELOCATING+__rt_psrelocs_size = __rt_psrelocs_end - __rt_psrelocs_start;}
+  ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
+  ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
+  ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;}
+  ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;}
 
   .eh_frame ${RELOCATING+BLOCK(__section_alignment__)} :
   {
Index: ld/scripttempl/pep.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/pep.sc,v
retrieving revision 1.13
diff -u -p -r1.13 pep.sc
--- ld/scripttempl/pep.sc	4 Nov 2010 16:03:25 -0000	1.13
+++ ld/scripttempl/pep.sc	29 May 2011 03:24:20 -0000
@@ -107,12 +107,15 @@ SECTIONS
   .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
   {
     ${R_RDATA}
-    ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = .;}
-    ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = .;}
+    ${RELOCATING+__rt_psrelocs_start = .;}
     *(.rdata_runtime_pseudo_reloc)
-    ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
-    ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
+    ${RELOCATING+__rt_psrelocs_end = .;}
   }
+  ${RELOCATING+__rt_psrelocs_size = __rt_psrelocs_end - __rt_psrelocs_start;}
+  ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
+  ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;}
+  ${RELOCATING+___RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;}
+  ${RELOCATING+__RUNTIME_PSEUDO_RELOC_LIST__ = . - __rt_psrelocs_size;}
 
   .eh_frame ${RELOCATING+BLOCK(__section_alignment__)} :
   {
Index: ld/testsuite/ld-cris/tls-e-tpoffcomm1.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-cris/tls-e-tpoffcomm1.d,v
retrieving revision 1.1
diff -u -p -r1.1 tls-e-tpoffcomm1.d
--- ld/testsuite/ld-cris/tls-e-tpoffcomm1.d	25 Mar 2009 03:04:21 -0000	1.1
+++ ld/testsuite/ld-cris/tls-e-tpoffcomm1.d	29 May 2011 03:24:21 -0000
@@ -11,35 +11,33 @@
 
 Program Header:
     LOAD off    0x0+ vaddr 0x0+80000 paddr 0x0+80000 align 2\*\*13
-         filesz 0x0+a4 memsz 0x0+a4 flags r-x
-    LOAD off    0x0+a4 vaddr 0x0+820a4 paddr 0x0+820a4 align 2\*\*13
-         filesz 0x0+ memsz 0x0+ flags rw-
-     TLS off    0x0+a4 vaddr 0x0+820a4 paddr 0x0+820a4 align 2\*\*2
+         filesz 0x0+84 memsz 0x0+84 flags r-x
+     TLS off    0x0+84 vaddr 0x0+82084 paddr 0x0+82084 align 2\*\*2
          filesz 0x0+ memsz 0x0+8 flags r--
 private flags = 0:
 
 Sections:
 Idx Name          Size      VMA       LMA       File off  Algn
-  0 .text         0+10  0+80094  0+80094  0+94  2\*\*1
+  0 .text         0+10  0+80074  0+80074  0+74  2\*\*1
                   CONTENTS, ALLOC, LOAD, READONLY, CODE
-  1 .tbss         0+8  0+820a4  0+820a4  0+a4  2\*\*2
+  1 .tbss         0+8  0+82084  0+82084  0+84  2\*\*2
                   ALLOC, THREAD_LOCAL
 SYMBOL TABLE:
-0+80094 l    d  .text	0+ .text
-0+820a4 l    d  .tbss	0+ .tbss
-0+80098 l     F .text	0+c do_test
-0+80094 g       .text	0+ _start
-0+820a4 g       \*ABS\*	0+ __bss_start
+0+80074 l    d  .text	0+ .text
+0+82084 l    d  .tbss	0+ .tbss
+0+80078 l     F .text	0+c do_test
+0+80074 g       .text	0+ _start
+0+82084 g       \*ABS\*	0+ __bss_start
 0+ g       .tbss	0+4 foo
-0+820a4 g       \*ABS\*	0+ _edata
-0+820c0 g       \*ABS\*	0+ _end
+0+82084 g       \*ABS\*	0+ _edata
+0+820a0 g       \*ABS\*	0+ _end
 0+4 g       .tbss	0+4 bar
 #...
 Disassembly of section .text:
 
-00080094 <_start>:
-   80094:	41b2                	moveq 1,\$r11
+00080074 <_start>:
+   80074:	41b2                	moveq 1,\$r11
 #...
-00080098 <do_test>:
-   80098:	2f0e f8ff ffff      	add.d 0xfffffff8,\$r0
-   8009e:	2f1e fcff ffff      	add.d 0xfffffffc,\$r1
+00080078 <do_test>:
+   80078:	2f0e f8ff ffff      	add.d 0xfffffff8,\$r0
+   8007e:	2f1e fcff ffff      	add.d 0xfffffffc,\$r1
Index: ld/testsuite/ld-plugin/plugin-7.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-plugin/plugin-7.d,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 plugin-7.d
--- ld/testsuite/ld-plugin/plugin-7.d	27 Apr 2011 07:17:45 -0000	1.1.2.1
+++ ld/testsuite/ld-plugin/plugin-7.d	29 May 2011 03:24:23 -0000
@@ -26,6 +26,6 @@ hook called: claim_file tmpdir/func.o \[
 hook called: claim_file tmpdir/text.o \[@0/.* not claimed
 #...
 hook called: all symbols read.
-`func' referenced in section `\.text.*' of tmpdir/main.o: defined in discarded section .*
+`_?func' referenced in section `\.text.*' of tmpdir/main.o: defined in discarded section .*
 hook called: cleanup.
 #...
Index: ld/testsuite/ld-plugin/plugin-8.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-plugin/plugin-8.d,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 plugin-8.d
--- ld/testsuite/ld-plugin/plugin-8.d	27 Apr 2011 07:17:45 -0000	1.1.2.1
+++ ld/testsuite/ld-plugin/plugin-8.d	29 May 2011 03:24:23 -0000
@@ -30,6 +30,6 @@ hook called: claim_file tmpdir/text.o \[
 hook called: all symbols read.
 Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
 Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY
-`func' referenced in section `\.text.*' of tmpdir/main.o: defined in discarded section .*
+`_?func' referenced in section `\.text.*' of tmpdir/main.o: defined in discarded section .*
 hook called: cleanup.
 #...


-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]