public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Release 2.21.1 ?
@ 2011-03-15  8:21 Tristan Gingold
  2011-03-15 13:24 ` Ian Lance Taylor
                   ` (6 more replies)
  0 siblings, 7 replies; 30+ messages in thread
From: Tristan Gingold @ 2011-03-15  8:21 UTC (permalink / raw)
  To: Binutils

Hi,

now that gcc 4.6 is released, I'd like to know if binutils developers want a new binutils release.
Opinions are welcome...

[ I think that not all patches have been back-ported, so do not hesitate to ping me ]

Tristan

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-03-15  8:21 Release 2.21.1 ? Tristan Gingold
@ 2011-03-15 13:24 ` Ian Lance Taylor
  2011-03-15 17:28 ` Jakub Jelinek
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 30+ messages in thread
From: Ian Lance Taylor @ 2011-03-15 13:24 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: Binutils

Tristan Gingold <gingold@adacore.com> writes:

> now that gcc 4.6 is released, I'd like to know if binutils developers want a new binutils release.

I would like to see a binutils 2.21.1 release at some point.

Ian

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-03-15  8:21 Release 2.21.1 ? Tristan Gingold
  2011-03-15 13:24 ` Ian Lance Taylor
@ 2011-03-15 17:28 ` Jakub Jelinek
  2011-03-15 17:30 ` Matthias Klose
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 30+ messages in thread
From: Jakub Jelinek @ 2011-03-15 17:28 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: Binutils

On Tue, Mar 15, 2011 at 09:21:37AM +0100, Tristan Gingold wrote:
> now that gcc 4.6 is released, I'd like to know if binutils developers want a new binutils release.

Just small correction, gcc 4.6.0 hasn't been released, but it will be hopefully soon.
Only gcc 4.6.0-rc1 has been pushed for testing...

	Jakub

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-03-15  8:21 Release 2.21.1 ? Tristan Gingold
  2011-03-15 13:24 ` Ian Lance Taylor
  2011-03-15 17:28 ` Jakub Jelinek
@ 2011-03-15 17:30 ` Matthias Klose
  2011-03-15 17:51   ` Dave Korn
  2011-03-16  4:03 ` Mike Frysinger
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 30+ messages in thread
From: Matthias Klose @ 2011-03-15 17:30 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: Binutils

On 15.03.2011 09:21, Tristan Gingold wrote:
> now that gcc 4.6 is released, I'd like to know if binutils developers want a new binutils release.
> Opinions are welcome...
> 
> [ I think that not all patches have been back-ported, so do not hesitate to ping me ]

what is the status of Dave Korn's plugin patches?

  Matthias

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-03-15 17:30 ` Matthias Klose
@ 2011-03-15 17:51   ` Dave Korn
  2011-03-16  7:52     ` Tristan Gingold
  0 siblings, 1 reply; 30+ messages in thread
From: Dave Korn @ 2011-03-15 17:51 UTC (permalink / raw)
  To: Matthias Klose; +Cc: Tristan Gingold, Binutils

On 15/03/2011 17:30, Matthias Klose wrote:
> On 15.03.2011 09:21, Tristan Gingold wrote:
>> now that gcc 4.6 is released, I'd like to know if binutils developers want a new binutils release.
>> Opinions are welcome...
>>
>> [ I think that not all patches have been back-ported, so do not hesitate to ping me ]
> 
> what is the status of Dave Korn's plugin patches?
> 
>   Matthias

  There's still one outstanding LTO issue that needs solving on HEAD and then
a backport of all the plugin-api updates to the branch.  The one outstanding
issue is the pr12365/2-stage link discussion which I'm about to revive, having
spent the past little while trying a few different approaches.

    cheers,
      DaveK

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-03-15  8:21 Release 2.21.1 ? Tristan Gingold
                   ` (2 preceding siblings ...)
  2011-03-15 17:30 ` Matthias Klose
@ 2011-03-16  4:03 ` Mike Frysinger
  2011-03-16  8:49   ` Tristan Gingold
  2011-03-20 21:41 ` Mike Frysinger
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 30+ messages in thread
From: Mike Frysinger @ 2011-03-16  4:03 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: Text/Plain, Size: 441 bytes --]

On Tuesday, March 15, 2011 04:21:37 Tristan Gingold wrote:
> [ I think that not all patches have been back-ported, so do not hesitate to
> ping me ]

my understanding is that binutils-2.21 does not build a relocatable x86 
kernel, but this commit from master fixes it:
http://sourceware.org/git/?p=binutils.git;a=commit;h=5daebc6a6606a30e60716f5bdee3d2018b560e8e

so that'd be a good one to backport if a new release is done
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-03-15 17:51   ` Dave Korn
@ 2011-03-16  7:52     ` Tristan Gingold
  0 siblings, 0 replies; 30+ messages in thread
From: Tristan Gingold @ 2011-03-16  7:52 UTC (permalink / raw)
  To: Dave Korn; +Cc: Matthias Klose, Binutils


On Mar 15, 2011, at 6:50 PM, Dave Korn wrote:

> On 15/03/2011 17:30, Matthias Klose wrote:
>> On 15.03.2011 09:21, Tristan Gingold wrote:
>>> now that gcc 4.6 is released, I'd like to know if binutils developers want a new binutils release.
>>> Opinions are welcome...
>>> 
>>> [ I think that not all patches have been back-ported, so do not hesitate to ping me ]
>> 
>> what is the status of Dave Korn's plugin patches?
>> 
>>  Matthias
> 
>  There's still one outstanding LTO issue that needs solving on HEAD and then
> a backport of all the plugin-api updates to the branch.  The one outstanding
> issue is the pr12365/2-stage link discussion which I'm about to revive, having
> spent the past little while trying a few different approaches.

I think Dave's plugin patches should be included in 2.21.1 - so I will wait until the backport.

Tristan.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-03-16  4:03 ` Mike Frysinger
@ 2011-03-16  8:49   ` Tristan Gingold
  2011-03-16 12:19     ` Alan Modra
  2011-03-17 12:21     ` Alan Modra
  0 siblings, 2 replies; 30+ messages in thread
From: Tristan Gingold @ 2011-03-16  8:49 UTC (permalink / raw)
  To: Mike Frysinger, Alan Modra; +Cc: binutils


On Mar 16, 2011, at 5:03 AM, Mike Frysinger wrote:

> On Tuesday, March 15, 2011 04:21:37 Tristan Gingold wrote:
>> [ I think that not all patches have been back-ported, so do not hesitate to
>> ping me ]
> 
> my understanding is that binutils-2.21 does not build a relocatable x86 
> kernel, but this commit from master fixes it:
> http://sourceware.org/git/?p=binutils.git;a=commit;h=5daebc6a6606a30e60716f5bdee3d2018b560e8e
> 
> so that'd be a good one to backport if a new release is done

This patch is supposed to be in 2.21:

	2010-12-20  Alan Modra  <amodra@gmail.com>
	PR ld/12327
	* ld.texinfo (Expression Section): Describe treatment of numbers
	and absolute symbols.
	* ldemul.c (after_open_default): Look up __ld_compatibility.
	* ldexp.c (fold_name): Convert absolute symbols to numbers when
	inside output section definitions, or when __ld_compatibility >= 221.
	(exp_fold_tree_1): Convert numbers to absolute when not in output
	section definition and __ld_compatibility < 221.  Don't always
	convert values outside an output section definition to absolute.
	* ldexp.h (uses_defined): Comment.
	* ldlang.c (ld_compatibility): New variable.
	* ldlang.h (ld_compatibility): Declare.
	* emultempl/aix.em, * emultempl/armcoff.em, * emultempl/beos.em,
	* emultempl/elf32.em, * emultempl/genelf.em, * emultempl/lnk960.em,
	* emultempl/m68kcoff.em, * emultempl/mmo.em, * emultempl/pe.em,
	* emultempl/pep.em, * emultempl/sunos.em, * emultempl/z80.em: Call
	after_open_default from after_open function.

But it looks like it was only partially backported (chunks still apply to ldlang.[ch] and ldemul.c)

Alan ?

Tristan.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-03-16  8:49   ` Tristan Gingold
@ 2011-03-16 12:19     ` Alan Modra
  2011-03-17 12:21     ` Alan Modra
  1 sibling, 0 replies; 30+ messages in thread
From: Alan Modra @ 2011-03-16 12:19 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: Mike Frysinger, binutils

On Wed, Mar 16, 2011 at 09:49:19AM +0100, Tristan Gingold wrote:
> But it looks like it was only partially backported (chunks still apply to ldlang.[ch] and ldemul.c)

I'll take a look tomorrow.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-03-16  8:49   ` Tristan Gingold
  2011-03-16 12:19     ` Alan Modra
@ 2011-03-17 12:21     ` Alan Modra
  2011-03-17 12:39       ` Tristan Gingold
  1 sibling, 1 reply; 30+ messages in thread
From: Alan Modra @ 2011-03-17 12:21 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: Mike Frysinger, binutils

On Wed, Mar 16, 2011 at 09:49:19AM +0100, Tristan Gingold wrote:
> This patch is supposed to be in 2.21:
> 
> 	2010-12-20  Alan Modra  <amodra@gmail.com>
[snip]
> But it looks like it was only partially backported (chunks still apply to ldlang.[ch] and ldemul.c)
> 
> Alan ?

Nothing appears to be missing.  A followup patch 2011-01-13 no doubt
removed those hunks.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-03-17 12:21     ` Alan Modra
@ 2011-03-17 12:39       ` Tristan Gingold
  0 siblings, 0 replies; 30+ messages in thread
From: Tristan Gingold @ 2011-03-17 12:39 UTC (permalink / raw)
  To: Alan Modra; +Cc: Mike Frysinger, binutils


On Mar 17, 2011, at 1:21 PM, Alan Modra wrote:

> On Wed, Mar 16, 2011 at 09:49:19AM +0100, Tristan Gingold wrote:
>> This patch is supposed to be in 2.21:
>> 
>> 	2010-12-20  Alan Modra  <amodra@gmail.com>
> [snip]
>> But it looks like it was only partially backported (chunks still apply to ldlang.[ch] and ldemul.c)
>> 
>> Alan ?
> 
> Nothing appears to be missing.  A followup patch 2011-01-13 no doubt
> removed those hunks.

Fine.  Thank you for the investigation.

Tristan.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-03-15  8:21 Release 2.21.1 ? Tristan Gingold
                   ` (3 preceding siblings ...)
  2011-03-16  4:03 ` Mike Frysinger
@ 2011-03-20 21:41 ` Mike Frysinger
  2011-03-23 16:00   ` Tristan Gingold
  2011-05-16  7:47 ` Andreas Krebbel
  2011-05-26  7:54 ` Release 2.21.1 [again] Tristan Gingold
  6 siblings, 1 reply; 30+ messages in thread
From: Mike Frysinger @ 2011-03-20 21:41 UTC (permalink / raw)
  To: binutils; +Cc: Tristan Gingold

[-- Attachment #1: Type: Text/Plain, Size: 363 bytes --]

On Tuesday, March 15, 2011 04:21:37 Tristan Gingold wrote:
> [ I think that not all patches have been back-ported, so do not hesitate to
> ping me ]

this one would be good in the branch:
http://sourceware.org/git/?p=binutils.git;a=commitdiff;h=3963724636741cd14e6de65267731c15cd492ecf

without this, glibc crashes when building for some cpus (like C3-2's)
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-03-20 21:41 ` Mike Frysinger
@ 2011-03-23 16:00   ` Tristan Gingold
  0 siblings, 0 replies; 30+ messages in thread
From: Tristan Gingold @ 2011-03-23 16:00 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: binutils


On Mar 20, 2011, at 10:22 PM, Mike Frysinger wrote:

> On Tuesday, March 15, 2011 04:21:37 Tristan Gingold wrote:
>> [ I think that not all patches have been back-ported, so do not hesitate to
>> ping me ]
> 
> this one would be good in the branch:
> http://sourceware.org/git/?p=binutils.git;a=commitdiff;h=3963724636741cd14e6de65267731c15cd492ecf
> 
> without this, glibc crashes when building for some cpus (like C3-2's)

Done.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-03-15  8:21 Release 2.21.1 ? Tristan Gingold
                   ` (4 preceding siblings ...)
  2011-03-20 21:41 ` Mike Frysinger
@ 2011-05-16  7:47 ` Andreas Krebbel
  2011-05-16  7:53   ` Tristan Gingold
  2011-05-16 10:05   ` Marek Polacek
  2011-05-26  7:54 ` Release 2.21.1 [again] Tristan Gingold
  6 siblings, 2 replies; 30+ messages in thread
From: Andreas Krebbel @ 2011-05-16  7:47 UTC (permalink / raw)
  To: gingold; +Cc: binutils

On 03/15/2011 09:21 AM, Tristan Gingold wrote:
> Hi,
> 
> now that gcc 4.6 is released, I'd like to know if binutils developers want a new binutils release.
> Opinions are welcome...
> 
> [ I think that not all patches have been back-ported, so do not hesitate to ping me ]

Although it isn't a binutils bugfix I need a backport of:

[PATCH] S/390: Support the .machine pseudo
http://sourceware.org/ml/binutils/2011-04/msg00191.html

in a binutils release asap in order to fix a glibc s390 build issue with the iconv modules:

[PATCH] S/390: Use .machine to prevent AS from complaining about z9-109 instructions in
iconv modules
http://sources.redhat.com/ml/libc-alpha/2011-04/msg00021.html

Would you accept a backport of this patch in the 2.21 branch?

Bye,

-Andreas-

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-05-16  7:47 ` Andreas Krebbel
@ 2011-05-16  7:53   ` Tristan Gingold
  2011-05-17 17:31     ` Andreas Krebbel
  2011-05-16 10:05   ` Marek Polacek
  1 sibling, 1 reply; 30+ messages in thread
From: Tristan Gingold @ 2011-05-16  7:53 UTC (permalink / raw)
  To: Andreas Krebbel; +Cc: binutils


On May 16, 2011, at 9:47 AM, Andreas Krebbel wrote:

> On 03/15/2011 09:21 AM, Tristan Gingold wrote:
>> Hi,
>> 
>> now that gcc 4.6 is released, I'd like to know if binutils developers want a new binutils release.
>> Opinions are welcome...
>> 
>> [ I think that not all patches have been back-ported, so do not hesitate to ping me ]
> 
> Although it isn't a binutils bugfix I need a backport of:
> 
> [PATCH] S/390: Support the .machine pseudo
> http://sourceware.org/ml/binutils/2011-04/msg00191.html
> 
> in a binutils release asap in order to fix a glibc s390 build issue with the iconv modules:
> 
> [PATCH] S/390: Use .machine to prevent AS from complaining about z9-109 instructions in
> iconv modules
> http://sources.redhat.com/ml/libc-alpha/2011-04/msg00021.html
> 
> Would you accept a backport of this patch in the 2.21 branch?

Yes, that's OK.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-05-16  7:47 ` Andreas Krebbel
  2011-05-16  7:53   ` Tristan Gingold
@ 2011-05-16 10:05   ` Marek Polacek
  1 sibling, 0 replies; 30+ messages in thread
From: Marek Polacek @ 2011-05-16 10:05 UTC (permalink / raw)
  To: Andreas Krebbel; +Cc: gingold, binutils

On 05/16/2011 09:47 AM, Andreas Krebbel wrote:
> [PATCH] S/390: Support the .machine pseudo
> http://sourceware.org/ml/binutils/2011-04/msg00191.html
> 
> in a binutils release asap in order to fix a glibc s390 build issue with the iconv modules:

Perfect, thanks a lot Andreas.  I'll try to rebuild glibc when this is out.

	Marek

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-05-16  7:53   ` Tristan Gingold
@ 2011-05-17 17:31     ` Andreas Krebbel
  2011-05-18  7:03       ` Tristan Gingold
  0 siblings, 1 reply; 30+ messages in thread
From: Andreas Krebbel @ 2011-05-17 17:31 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: binutils

> Yes, that's OK.

Here is the backport for 2.21 of:

[PATCH] S/390: Support the .machine pseudo
http://sourceware.org/ml/binutils/2011-04/msg00191.html

the backported patch also includes the trivial change:

[Committed] S/390: gas: Add -march=all
http://sourceware.org/ml/binutils/2011-03/msg00355.html

Ok for 2.21?

Bye,

-Andreas-


2011-05-17  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>

	Backported from mainline
	2011-03-18  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>

	* config/tc-s390.c (md_parse_option): Add -march=all option which
	switches to the highest available CPU.

	2011-04-14  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>

	* config/tc-s390.c (s390_machine): New prototype.
	(md_pseudo_table): New pseudo-op .machine.
	(s390_opcode_hash): Initialize to NULL.
	(s390_parse_cpu): New function.
	(md_parse_option): Use s390_parse_cpu.
	(s390_setup_opcodes): New function.
	(md_begin): Use s390_setup_opcodes.
	(s390_machine): New hook handling the new .machine pseudo.

	* doc/c-s390.texi: Document the new pseudo op .machine.


2011-05-17  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>

	    Backported from mainline
	    2011-04-14  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>

	    * gas/s390/zarch-machine.s: New testcase.
	    * gas/s390/zarch-machine.d: New testcase output.
	    * gas/s390/s390.exp: Execute the new testcase.


Index: gas/config/tc-s390.c
===================================================================
--- gas/config/tc-s390.c.orig
+++ gas/config/tc-s390.c
@@ -85,6 +85,7 @@ static void s390_elf_cons (int);
 static void s390_bss (int);
 static void s390_insn (int);
 static void s390_literals (int);
+static void s390_machine (int);
 
 const pseudo_typeS md_pseudo_table[] =
 {
@@ -99,6 +100,7 @@ const pseudo_typeS md_pseudo_table[] =
   { "quad",     s390_elf_cons,  8 },
   { "ltorg",    s390_literals,  0 },
   { "string",   stringer,       8 + 1 },
+  { "machine",  s390_machine,   0 },
   { NULL,	NULL,		0 }
 };
 
@@ -293,7 +295,7 @@ register_name (expressionS *expressionP)
 static struct hash_control *s390_opformat_hash;
 
 /* Opcode hash table.  */
-static struct hash_control *s390_opcode_hash;
+static struct hash_control *s390_opcode_hash = NULL;
 
 /* Flags to set in the elf header */
 static flagword s390_flags = 0;
@@ -350,6 +352,35 @@ s390_target_format (void)
   return s390_arch_size == 64 ? "elf64-s390" : "elf32-s390";
 }
 
+/* Map a CPU string as given with -march= or .machine to the
+   respective enum s390_opcode_cpu_val value.  0xffffffff is returned
+   in case of an error.  */
+
+static unsigned int
+s390_parse_cpu (char *arg)
+{
+  if (strcmp (arg, "g5") == 0)
+    return S390_OPCODE_G5;
+  else if (strcmp (arg, "g6") == 0)
+    return S390_OPCODE_G6;
+  else if (strcmp (arg, "z900") == 0)
+    return S390_OPCODE_Z900;
+  else if (strcmp (arg, "z990") == 0)
+    return S390_OPCODE_Z990;
+  else if (strcmp (arg, "z9-109") == 0)
+    return S390_OPCODE_Z9_109;
+  else if (strcmp (arg, "z9-ec") == 0)
+    return S390_OPCODE_Z9_EC;
+  else if (strcmp (arg, "z10") == 0)
+    return S390_OPCODE_Z10;
+  else if (strcmp (arg, "z196") == 0)
+    return S390_OPCODE_Z196;
+  else if (strcmp (arg, "all") == 0)
+    return S390_OPCODE_MAXCPU - 1;
+  else
+    return -1;
+}
+
 int
 md_parse_option (int c, char *arg)
 {
@@ -382,23 +413,9 @@ md_parse_option (int c, char *arg)
 
       else if (arg != NULL && strncmp (arg, "arch=", 5) == 0)
 	{
-	  if (strcmp (arg + 5, "g5") == 0)
-	    current_cpu = S390_OPCODE_G5;
-	  else if (strcmp (arg + 5, "g6") == 0)
-	    current_cpu = S390_OPCODE_G6;
-	  else if (strcmp (arg + 5, "z900") == 0)
-	    current_cpu = S390_OPCODE_Z900;
-	  else if (strcmp (arg + 5, "z990") == 0)
-	    current_cpu = S390_OPCODE_Z990;
-	  else if (strcmp (arg + 5, "z9-109") == 0)
-	    current_cpu = S390_OPCODE_Z9_109;
-	  else if (strcmp (arg + 5, "z9-ec") == 0)
-	    current_cpu = S390_OPCODE_Z9_EC;
-	  else if (strcmp (arg + 5, "z10") == 0)
-	    current_cpu = S390_OPCODE_Z10;
-	  else if (strcmp (arg + 5, "z196") == 0)
-	    current_cpu = S390_OPCODE_Z196;
-	  else
+	  current_cpu = s390_parse_cpu (arg + 5);
+
+	  if (current_cpu == (unsigned int)-1)
 	    {
 	      as_bad (_("invalid switch -m%s"), arg);
 	      return 0;
@@ -454,42 +471,20 @@ md_show_usage (FILE *stream)
         -Qy, -Qn          ignored\n"));
 }
 
-/* This function is called when the assembler starts up.  It is called
-   after the options have been parsed and the output file has been
-   opened.  */
+/* Generate the hash table mapping mnemonics to struct s390_opcode.
+   This table is built at startup and whenever the CPU level is
+   changed using .machine.  */
 
-void
-md_begin (void)
+static void
+s390_setup_opcodes (void)
 {
   register const struct s390_opcode *op;
   const struct s390_opcode *op_end;
   bfd_boolean dup_insn = FALSE;
   const char *retval;
 
-  /* Give a warning if the combination -m64-bit and -Aesa is used.  */
-  if (s390_arch_size == 64 && current_cpu < S390_OPCODE_Z900)
-    as_warn (_("The 64 bit file format is used without esame instructions."));
-
-  s390_cie_data_alignment = -s390_arch_size / 8;
-
-  /* Set the ELF flags if desired.  */
-  if (s390_flags)
-    bfd_set_private_flags (stdoutput, s390_flags);
-
-  /* Insert the opcode formats into a hash table.  */
-  s390_opformat_hash = hash_new ();
-
-  op_end = s390_opformats + s390_num_opformats;
-  for (op = s390_opformats; op < op_end; op++)
-    {
-      retval = hash_insert (s390_opformat_hash, op->name, (void *) op);
-      if (retval != (const char *) NULL)
-	{
-	  as_bad (_("Internal assembler error for instruction format %s"),
-		  op->name);
-	  dup_insn = TRUE;
-	}
-    }
+  if (s390_opcode_hash != NULL)
+    hash_die (s390_opcode_hash);
 
   /* Insert the opcodes into a hash table.  */
   s390_opcode_hash = hash_new ();
@@ -521,11 +516,50 @@ md_begin (void)
 
   if (dup_insn)
     abort ();
+}
+
+/* This function is called when the assembler starts up.  It is called
+   after the options have been parsed and the output file has been
+   opened.  */
+
+void
+md_begin (void)
+{
+  register const struct s390_opcode *op;
+  const struct s390_opcode *op_end;
+  bfd_boolean dup_insn = FALSE;
+  const char *retval;
+
+  /* Give a warning if the combination -m64-bit and -Aesa is used.  */
+  if (s390_arch_size == 64 && current_cpu < S390_OPCODE_Z900)
+    as_warn (_("The 64 bit file format is used without esame instructions."));
+
+  s390_cie_data_alignment = -s390_arch_size / 8;
+
+  /* Set the ELF flags if desired.  */
+  if (s390_flags)
+    bfd_set_private_flags (stdoutput, s390_flags);
+
+  /* Insert the opcode formats into a hash table.  */
+  s390_opformat_hash = hash_new ();
+
+  op_end = s390_opformats + s390_num_opformats;
+  for (op = s390_opformats; op < op_end; op++)
+    {
+      retval = hash_insert (s390_opformat_hash, op->name, (void *) op);
+      if (retval != (const char *) NULL)
+	{
+	  as_bad (_("Internal assembler error for instruction format %s"),
+		  op->name);
+	  dup_insn = TRUE;
+	}
+    }
+
+  s390_setup_opcodes ();
 
   record_alignment (text_section, 2);
   record_alignment (data_section, 2);
   record_alignment (bss_section, 2);
-
 }
 
 /* Called after all assembly has been done.  */
@@ -1753,6 +1787,72 @@ s390_literals (int ignore ATTRIBUTE_UNUS
   lpe_count = 0;
 }
 
+/* The .machine pseudo op allows to switch to a different CPU level in
+   the asm listing.  The current CPU setting can be stored on a stack
+   with .machine push and restored with .machined pop.  */
+
+static void
+s390_machine (int ignore ATTRIBUTE_UNUSED)
+{
+  char *cpu_string;
+#define MAX_HISTORY 100
+  static unsigned int *cpu_history;
+  static int curr_hist;
+
+  SKIP_WHITESPACE ();
+
+  if (*input_line_pointer == '"')
+    {
+      int len;
+      cpu_string = demand_copy_C_string (&len);
+    }
+  else
+    {
+      char c;
+      cpu_string = input_line_pointer;
+      c = get_symbol_end ();
+      cpu_string = xstrdup (cpu_string);
+      *input_line_pointer = c;
+    }
+
+  if (cpu_string != NULL)
+    {
+      unsigned int old_cpu = current_cpu;
+      unsigned int new_cpu;
+      char *p;
+
+      for (p = cpu_string; *p != 0; p++)
+	*p = TOLOWER (*p);
+
+      if (strcmp (cpu_string, "push") == 0)
+	{
+	  if (cpu_history == NULL)
+	    cpu_history = xmalloc (MAX_HISTORY * sizeof (*cpu_history));
+
+	  if (curr_hist >= MAX_HISTORY)
+	    as_bad (_(".machine stack overflow"));
+	  else
+	    cpu_history[curr_hist++] = current_cpu;
+	}
+      else if (strcmp (cpu_string, "pop") == 0)
+	{
+	  if (curr_hist <= 0)
+	    as_bad (_(".machine stack underflow"));
+	  else
+	    current_cpu = cpu_history[--curr_hist];
+	}
+      else if ((new_cpu = s390_parse_cpu (cpu_string)) != (unsigned int)-1)
+	current_cpu = new_cpu;
+      else
+	as_bad (_("invalid machine `%s'"), cpu_string);
+
+      if (current_cpu != old_cpu)
+	s390_setup_opcodes ();
+    }
+
+  demand_empty_rest_of_line ();
+}
+
 char *
 md_atof (int type, char *litp, int *sizep)
 {
Index: gas/doc/c-s390.texi
===================================================================
--- gas/doc/c-s390.texi.orig
+++ gas/doc/c-s390.texi
@@ -851,6 +851,17 @@ ELF extension documentation @samp{ELF Ha
 @item .ltorg
 This directive causes the current contents of the literal pool to be
 dumped to the current location (@ref{s390 Literal Pool Entries}).
+
+@cindex @code{.machine} directive, s390
+@item .machine string
+This directive allows you to change the machine for which code is
+generated.  @code{string} may be any of the @code{-march=} selection
+options (without the -march=), @code{push}, or @code{pop}.
+@code{.machine push} saves the currently selected cpu, which may be
+restored with @code{.machine pop}.  Be aware that the cpu string has
+to be put into double quotes in case it contains characters not
+appropriate for identifiers.  So you have to write @code{"z9-109"}
+instead of just @code{z9-109}.
 @end table
 
 @node s390 Floating Point
Index: gas/testsuite/gas/s390/zarch-machine.d
===================================================================
--- /dev/null
+++ gas/testsuite/gas/s390/zarch-machine.d
@@ -0,0 +1,12 @@
+#name: s390x machine
+#objdump: -dr
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+.* <foo>:
+.*:	e3 95 af ff 00 08 [ 	]*ag	%r9,4095\(%r5,%r10\)
+.*:	eb d6 65 b3 01 6a [ 	]*asi	5555\(%r6\),-42
+.*:	e3 95 af ff 00 18 [ 	]*agf	%r9,4095\(%r5,%r10\)
+.*:	07 07 [ 	]*nopr	%r7
Index: gas/testsuite/gas/s390/zarch-machine.s
===================================================================
--- /dev/null
+++ gas/testsuite/gas/s390/zarch-machine.s
@@ -0,0 +1,8 @@
+.text
+foo:
+	ag	%r9,4095(%r5,%r10)
+.machine push
+.machine z10
+	asi	5555(%r6),-42
+.machine pop
+	agf	%r9,4095(%r5,%r10)
Index: gas/testsuite/gas/s390/s390.exp
===================================================================
--- gas/testsuite/gas/s390/s390.exp.orig
+++ gas/testsuite/gas/s390/s390.exp
@@ -27,4 +27,5 @@ if [expr [istarget "s390-*-*"] ||  [ista
     run_dump_test "zarch-z196" "{as -m64} {as -march=z196}"
     run_dump_test "zarch-reloc" "{as -m64}"
     run_dump_test "zarch-operands" "{as -m64} {as -march=z9-109}"
+    run_dump_test "zarch-machine" "{as -m64} {as -march=z900}"
 }

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-05-17 17:31     ` Andreas Krebbel
@ 2011-05-18  7:03       ` Tristan Gingold
  0 siblings, 0 replies; 30+ messages in thread
From: Tristan Gingold @ 2011-05-18  7:03 UTC (permalink / raw)
  To: Andreas Krebbel; +Cc: binutils


On May 17, 2011, at 7:30 PM, Andreas Krebbel wrote:

>> Yes, that's OK.
> 
> Here is the backport for 2.21 of:
> 
> [PATCH] S/390: Support the .machine pseudo
> http://sourceware.org/ml/binutils/2011-04/msg00191.html
> 
> the backported patch also includes the trivial change:
> 
> [Committed] S/390: gas: Add -march=all
> http://sourceware.org/ml/binutils/2011-03/msg00355.html
> 
> Ok for 2.21?

Sure.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Release 2.21.1 [again]
  2011-03-15  8:21 Release 2.21.1 ? Tristan Gingold
                   ` (5 preceding siblings ...)
  2011-05-16  7:47 ` Andreas Krebbel
@ 2011-05-26  7:54 ` Tristan Gingold
  2011-05-29  7:57   ` Alan Modra
  6 siblings, 1 reply; 30+ messages in thread
From: Tristan Gingold @ 2011-05-26  7:54 UTC (permalink / raw)
  To: binutils Development

Hi,

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.

Tristan.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 [again]
  2011-05-26  7:54 ` Release 2.21.1 [again] Tristan Gingold
@ 2011-05-29  7:57   ` Alan Modra
  2011-05-29 17:18     ` Alan Modra
                       ` (2 more replies)
  0 siblings, 3 replies; 30+ messages in thread
From: Alan Modra @ 2011-05-29  7:57 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: binutils Development

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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 [again]
  2011-05-29  7:57   ` Alan Modra
@ 2011-05-29 17:18     ` Alan Modra
  2011-05-29 17:26     ` Alan Modra
  2011-05-29 20:55     ` Alan Modra
  2 siblings, 0 replies; 30+ messages in thread
From: Alan Modra @ 2011-05-29 17:18 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: binutils Development

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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 [again]
  2011-05-29  7:57   ` Alan Modra
  2011-05-29 17:18     ` Alan Modra
@ 2011-05-29 17:26     ` Alan Modra
  2011-05-29 20:55     ` Alan Modra
  2 siblings, 0 replies; 30+ messages in thread
From: Alan Modra @ 2011-05-29 17:26 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: binutils Development

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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 [again]
  2011-05-29  7:57   ` Alan Modra
  2011-05-29 17:18     ` Alan Modra
  2011-05-29 17:26     ` Alan Modra
@ 2011-05-29 20:55     ` Alan Modra
  2 siblings, 0 replies; 30+ messages in thread
From: Alan Modra @ 2011-05-29 20:55 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: binutils Development

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

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-03-16  9:37   ` Sedat Dilek
@ 2011-03-16 15:34     ` Sedat Dilek
  0 siblings, 0 replies; 30+ messages in thread
From: Sedat Dilek @ 2011-03-16 15:34 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: binutils, amodra, H.J. Lu, H. Peter Anvin

On Wed, Mar 16, 2011 at 10:37 AM, Sedat Dilek
<sedat.dilek@googlemail.com> wrote:
> On Wed, Mar 16, 2011 at 9:50 AM, Tristan Gingold <gingold@adacore.com> wrote:
>>
>> On Mar 16, 2011, at 7:44 AM, Sedat Dilek wrote:
>>
>>> Hi,
>>>
>>> while handling several breakages in linux-next kernel, it showed PR
>>> gas/12519 (see [1]) is somehow incomplete as it gives no pointer to
>>> the symbol name in case of an error.
>>> "Mention symbol name in non-constant .size expression." (see [2]) as a
>>> follow-up patch definitely helps to enlighten developer's where to dig
>>> into occuring problems.
>>> "Revert the last change on gas/elf/bad-size.err." (see [3]) is a fixup to [2].
>>>
>>> It would be nice to see [2] and [3] backported to 2.21-branch.
>>
>> Why not.
>>
>> Does it make sense to generate a warning instead of an error in 2.21.1 for backward bug-compatibility ?
>> Alan, what's your opinion ?
>>
>> Tristan.
>>
>>
>
> H.J. offered a proposal patch ("PATCH: Add
> --size-check=[error|warning]") [1] with an easy switch opportunity and
> H. Peter Anvin illustrated how the warning switch can be used from
> command-line [2].
>
> IIRC there was no official decision what will be the default behaviour:
> binutils developers mostly advocate "error" as default, whereas  a lot
> of Linux kernel developers want "warning" as default.
>
> Unfortunately, I could not apply (and test) H.J.'s proposal patch and
> requested a proper one [3].
>
> - Sedat -
>
>
> [1] http://sourceware.org/ml/binutils/2011-03/msg00214.html
> [2] http://sourceware.org/ml/binutils/2011-03/msg00283.html
> [3] http://sourceware.org/ml/binutils/2011-03/msg00263.html
>

Hi,

I have cherry-picked commit 8bba209217cab2e7fb949768ffc4a5d40ecc144a
("Add --size-check=[error|warning].") from upstream and built a Debian
package on top of binutils (2.21.0.20110302-2) source package.

I returned to the linux-next (next-20110308) which I reported as
"broken" and currently building a new kernel (it's not finished yet,
make -j=1).

Instructions:

$ cd $BUILD_DIR
$ make CC='gcc -Wa,--size-check=warning'

Check current build-log:

$ egrep 'Assembler messages:|Warning: .size expression with symbol'
build.log
/home/sd/src/linux-2.6/linux-2.6.38-rc7/debian/build/source_i386_none/arch/x86/kernel/entry_32.S:
Assembler messages:
/home/sd/src/linux-2.6/linux-2.6.38-rc7/debian/build/source_i386_none/arch/x86/kernel/entry_32.S:1421:
Warning: .size expression with symbol `apf_page_fault' does not
evaluate to a constant
/home/sd/src/linux-2.6/linux-2.6.38-rc7/debian/build/source_i386_none/arch/x86/kernel/acpi/wakeup_rm.S:
Assembler messages:
/home/sd/src/linux-2.6/linux-2.6.38-rc7/debian/build/source_i386_none/arch/x86/kernel/acpi/wakeup_rm.S:12:
Warning: .size expression with symbol `wakeup_code_start' does not
evaluate to a constant
...

Nice, it works as expected :-).
( These were the two places I discovered, but this time the kernel
building is not interrupted. )

/me is just fine with the default behaviour of (my freshly-built)
binutils/as "--size-check=error".

Thanks to all involved people for their help, especially to H.J. for
providing a patch and solution!

Regards,
- Sedat -

P.S.: These 3 patches should be backported to 2.21-branch.

$ LC_ALL=C ls -l patches
total 16
-rw-r--r-- 1 sd sd 3137 Mar 16 14:45
0001-Mention-symbol-name-in-non-constant-.size-expression.patch
-rw-r--r-- 1 sd sd  948 Mar 16 14:45
0002-Revert-the-last-change-on-gas-elf-bad-size.err.patch
-rw-r--r-- 1 sd sd 7782 Mar 16 14:45 0003-Add-size-check-error-warning.patch

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-03-16 12:44     ` H.J. Lu
@ 2011-03-16 12:47       ` Tristan Gingold
  0 siblings, 0 replies; 30+ messages in thread
From: Tristan Gingold @ 2011-03-16 12:47 UTC (permalink / raw)
  To: H.J. Lu; +Cc: sedat.dilek, binutils, Alan Modra


On Mar 16, 2011, at 1:44 PM, H.J. Lu wrote:

> On Wed, Mar 16, 2011 at 5:16 AM, Alan Modra <amodra@gmail.com> wrote:
>> On Wed, Mar 16, 2011 at 09:50:35AM +0100, Tristan Gingold wrote:
>>> 
>>> On Mar 16, 2011, at 7:44 AM, Sedat Dilek wrote:
>>> 
>>>> Hi,
>>>> 
>>>> while handling several breakages in linux-next kernel, it showed PR
>>>> gas/12519 (see [1]) is somehow incomplete as it gives no pointer to
>>>> the symbol name in case of an error.
>>>> "Mention symbol name in non-constant .size expression." (see [2]) as a
>>>> follow-up patch definitely helps to enlighten developer's where to dig
>>>> into occuring problems.
>>>> "Revert the last change on gas/elf/bad-size.err." (see [3]) is a fixup to [2].
>>>> 
>>>> It would be nice to see [2] and [3] backported to 2.21-branch.
>>> 
>>> Why not.
>>> 
>>> Does it make sense to generate a warning instead of an error in 2.21.1 for backward bug-compatibility ?
>>> Alan, what's your opinion ?
>> 
>> Well, it's plain wrong to accept bad expressions and have gas try to
>> guess what typos mean, so I think it should be an error.  The size
>> info matters to some people.  Ask gdb developers, or anyone writing
>> code analysis and optimization tools.
>> 
>> I also think it highly likely that new binutils and/or gcc will break
>> kernel bisection in other areas.  For that reason I'm inclined to
>> discount the kernel list histrionics over the .size fix.  Kernel
>> kiddies are just going to have to learn to deal with toolchain
>> evolution.
>> 
> 
> Can I apply my size error patch?

Sure.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-03-16 12:17   ` Alan Modra
@ 2011-03-16 12:44     ` H.J. Lu
  2011-03-16 12:47       ` Tristan Gingold
  0 siblings, 1 reply; 30+ messages in thread
From: H.J. Lu @ 2011-03-16 12:44 UTC (permalink / raw)
  To: Tristan Gingold, sedat.dilek, binutils; +Cc: Alan Modra

On Wed, Mar 16, 2011 at 5:16 AM, Alan Modra <amodra@gmail.com> wrote:
> On Wed, Mar 16, 2011 at 09:50:35AM +0100, Tristan Gingold wrote:
>>
>> On Mar 16, 2011, at 7:44 AM, Sedat Dilek wrote:
>>
>> > Hi,
>> >
>> > while handling several breakages in linux-next kernel, it showed PR
>> > gas/12519 (see [1]) is somehow incomplete as it gives no pointer to
>> > the symbol name in case of an error.
>> > "Mention symbol name in non-constant .size expression." (see [2]) as a
>> > follow-up patch definitely helps to enlighten developer's where to dig
>> > into occuring problems.
>> > "Revert the last change on gas/elf/bad-size.err." (see [3]) is a fixup to [2].
>> >
>> > It would be nice to see [2] and [3] backported to 2.21-branch.
>>
>> Why not.
>>
>> Does it make sense to generate a warning instead of an error in 2.21.1 for backward bug-compatibility ?
>> Alan, what's your opinion ?
>
> Well, it's plain wrong to accept bad expressions and have gas try to
> guess what typos mean, so I think it should be an error.  The size
> info matters to some people.  Ask gdb developers, or anyone writing
> code analysis and optimization tools.
>
> I also think it highly likely that new binutils and/or gcc will break
> kernel bisection in other areas.  For that reason I'm inclined to
> discount the kernel list histrionics over the .size fix.  Kernel
> kiddies are just going to have to learn to deal with toolchain
> evolution.
>

Can I apply my size error patch?

Thanks.


-- 
H.J.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-03-16  8:50 ` Tristan Gingold
  2011-03-16  9:37   ` Sedat Dilek
@ 2011-03-16 12:17   ` Alan Modra
  2011-03-16 12:44     ` H.J. Lu
  1 sibling, 1 reply; 30+ messages in thread
From: Alan Modra @ 2011-03-16 12:17 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: sedat.dilek, binutils

On Wed, Mar 16, 2011 at 09:50:35AM +0100, Tristan Gingold wrote:
> 
> On Mar 16, 2011, at 7:44 AM, Sedat Dilek wrote:
> 
> > Hi,
> > 
> > while handling several breakages in linux-next kernel, it showed PR
> > gas/12519 (see [1]) is somehow incomplete as it gives no pointer to
> > the symbol name in case of an error.
> > "Mention symbol name in non-constant .size expression." (see [2]) as a
> > follow-up patch definitely helps to enlighten developer's where to dig
> > into occuring problems.
> > "Revert the last change on gas/elf/bad-size.err." (see [3]) is a fixup to [2].
> > 
> > It would be nice to see [2] and [3] backported to 2.21-branch.
> 
> Why not.
> 
> Does it make sense to generate a warning instead of an error in 2.21.1 for backward bug-compatibility ?
> Alan, what's your opinion ?

Well, it's plain wrong to accept bad expressions and have gas try to
guess what typos mean, so I think it should be an error.  The size
info matters to some people.  Ask gdb developers, or anyone writing
code analysis and optimization tools.

I also think it highly likely that new binutils and/or gcc will break
kernel bisection in other areas.  For that reason I'm inclined to
discount the kernel list histrionics over the .size fix.  Kernel
kiddies are just going to have to learn to deal with toolchain
evolution.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-03-16  8:50 ` Tristan Gingold
@ 2011-03-16  9:37   ` Sedat Dilek
  2011-03-16 15:34     ` Sedat Dilek
  2011-03-16 12:17   ` Alan Modra
  1 sibling, 1 reply; 30+ messages in thread
From: Sedat Dilek @ 2011-03-16  9:37 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: binutils

On Wed, Mar 16, 2011 at 9:50 AM, Tristan Gingold <gingold@adacore.com> wrote:
>
> On Mar 16, 2011, at 7:44 AM, Sedat Dilek wrote:
>
>> Hi,
>>
>> while handling several breakages in linux-next kernel, it showed PR
>> gas/12519 (see [1]) is somehow incomplete as it gives no pointer to
>> the symbol name in case of an error.
>> "Mention symbol name in non-constant .size expression." (see [2]) as a
>> follow-up patch definitely helps to enlighten developer's where to dig
>> into occuring problems.
>> "Revert the last change on gas/elf/bad-size.err." (see [3]) is a fixup to [2].
>>
>> It would be nice to see [2] and [3] backported to 2.21-branch.
>
> Why not.
>
> Does it make sense to generate a warning instead of an error in 2.21.1 for backward bug-compatibility ?
> Alan, what's your opinion ?
>
> Tristan.
>
>

H.J. offered a proposal patch ("PATCH: Add
--size-check=[error|warning]") [1] with an easy switch opportunity and
H. Peter Anvin illustrated how the warning switch can be used from
command-line [2].

IIRC there was no official decision what will be the default behaviour:
binutils developers mostly advocate "error" as default, whereas  a lot
of Linux kernel developers want "warning" as default.

Unfortunately, I could not apply (and test) H.J.'s proposal patch and
requested a proper one [3].

- Sedat -


[1] http://sourceware.org/ml/binutils/2011-03/msg00214.html
[2] http://sourceware.org/ml/binutils/2011-03/msg00283.html
[3] http://sourceware.org/ml/binutils/2011-03/msg00263.html

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
  2011-03-16  6:44 Release 2.21.1 ? Sedat Dilek
@ 2011-03-16  8:50 ` Tristan Gingold
  2011-03-16  9:37   ` Sedat Dilek
  2011-03-16 12:17   ` Alan Modra
  0 siblings, 2 replies; 30+ messages in thread
From: Tristan Gingold @ 2011-03-16  8:50 UTC (permalink / raw)
  To: sedat.dilek; +Cc: binutils


On Mar 16, 2011, at 7:44 AM, Sedat Dilek wrote:

> Hi,
> 
> while handling several breakages in linux-next kernel, it showed PR
> gas/12519 (see [1]) is somehow incomplete as it gives no pointer to
> the symbol name in case of an error.
> "Mention symbol name in non-constant .size expression." (see [2]) as a
> follow-up patch definitely helps to enlighten developer's where to dig
> into occuring problems.
> "Revert the last change on gas/elf/bad-size.err." (see [3]) is a fixup to [2].
> 
> It would be nice to see [2] and [3] backported to 2.21-branch.

Why not.

Does it make sense to generate a warning instead of an error in 2.21.1 for backward bug-compatibility ?
Alan, what's your opinion ?

Tristan.

^ permalink raw reply	[flat|nested] 30+ messages in thread

* Re: Release 2.21.1 ?
@ 2011-03-16  6:44 Sedat Dilek
  2011-03-16  8:50 ` Tristan Gingold
  0 siblings, 1 reply; 30+ messages in thread
From: Sedat Dilek @ 2011-03-16  6:44 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: binutils

Hi,

while handling several breakages in linux-next kernel, it showed PR
gas/12519 (see [1]) is somehow incomplete as it gives no pointer to
the symbol name in case of an error.
"Mention symbol name in non-constant .size expression." (see [2]) as a
follow-up patch definitely helps to enlighten developer's where to dig
into occuring problems.
"Revert the last change on gas/elf/bad-size.err." (see [3]) is a fixup to [2].

It would be nice to see [2] and [3] backported to 2.21-branch.

Thanks.

Regards,
- Sedat -

[1] http://sourceware.org/git/?p=binutils.git;a=commit;h=345bbf7731af2912390e72b86807eb1b2af3e27b
[2] http://sourceware.org/git/?p=binutils.git;a=commit;h=b9521fc0be7945fc842ce1197e241a023378125d
[3] http://sourceware.org/git/?p=binutils.git;a=commit;h=cbd141bb69f791de7ea1581abe7afb34f0c61288

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2011-05-29  8:50 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-15  8:21 Release 2.21.1 ? Tristan Gingold
2011-03-15 13:24 ` Ian Lance Taylor
2011-03-15 17:28 ` Jakub Jelinek
2011-03-15 17:30 ` Matthias Klose
2011-03-15 17:51   ` Dave Korn
2011-03-16  7:52     ` Tristan Gingold
2011-03-16  4:03 ` Mike Frysinger
2011-03-16  8:49   ` Tristan Gingold
2011-03-16 12:19     ` Alan Modra
2011-03-17 12:21     ` Alan Modra
2011-03-17 12:39       ` Tristan Gingold
2011-03-20 21:41 ` Mike Frysinger
2011-03-23 16:00   ` Tristan Gingold
2011-05-16  7:47 ` Andreas Krebbel
2011-05-16  7:53   ` Tristan Gingold
2011-05-17 17:31     ` Andreas Krebbel
2011-05-18  7:03       ` Tristan Gingold
2011-05-16 10:05   ` Marek Polacek
2011-05-26  7:54 ` Release 2.21.1 [again] Tristan Gingold
2011-05-29  7:57   ` Alan Modra
2011-05-29 17:18     ` Alan Modra
2011-05-29 17:26     ` Alan Modra
2011-05-29 20:55     ` Alan Modra
2011-03-16  6:44 Release 2.21.1 ? Sedat Dilek
2011-03-16  8:50 ` Tristan Gingold
2011-03-16  9:37   ` Sedat Dilek
2011-03-16 15:34     ` Sedat Dilek
2011-03-16 12:17   ` Alan Modra
2011-03-16 12:44     ` H.J. Lu
2011-03-16 12:47       ` Tristan Gingold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).