public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Linker Bug or Design Intent (Absolute symbols in zero sized sections)
@ 2006-09-26 14:33 Vivek Goyal
  2006-09-26 14:49 ` H. J. Lu
  0 siblings, 1 reply; 43+ messages in thread
From: Vivek Goyal @ 2006-09-26 14:33 UTC (permalink / raw)
  To: binutils

Hi,

I got a query. Ld behaviour does not seem to be conforming to what is 
mentioned in "info ld"

I was going through the info ld and found following in the section 3.6.7 
"Output Section Discarding"

    "If you use anything other than an input section description as an
output section command, such as a symbol assignment, then the output
section will always be created, even if there are no matching input
sections."

I am compiling my kernel and I don't seem to be getting above mentioned 
behaviour. For, example vmlinux.ld.S has got following code.

   .smp_altinstructions : AT(ADDR(.smp_altinstructions) - LOAD_OFFSET) {
         __smp_alt_begin = .;
         __smp_alt_instructions = .;
         *(.smp_altinstructions)
         __smp_alt_instructions_end = .;
   }


In finally generated executable, thre is no section as 
.smp_altinstructions and symbols __smp_alt_begin, __smp_alt_instructions
and __smp_alt_instructions_end have become absolute symbols.

Looks like there was no section .smp_altinstructions present in input 
files hence linker did not create output section and made symbols 
absolute. This does not match the behaviour as stated in "info ld". Is 
this a bug or design intent?

I am using GNU ld version 2.17.50.0.3-1

HOW AM I IMPACTED:
--------------------

Now we are trying to make i386 kernel fully relocatable. We compile the 
kernel with option --emit-relocs and use this relocation information to 
relocate the kernel at run time. But as per the specifications absolute 
symbols are not to be relocated.

Now, above compiler makes some symbols absolute and these symbols are 
not relocated and kernel code fails at some point. In this case kernel 
fails because it is trying to free memory between symbol __smp_alt_begin 
and another symbol present in other section. __smp_alt_begin is now 
absolute and does not get relocated and kernel ends up trying to free a 
wrong portion of memory.

Do you have any thoughts about what's the right way of fixing the issue? 
  Its a linker bug or it should be fixed in kernel?

Thanks
Vivek

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-26 14:33 Linker Bug or Design Intent (Absolute symbols in zero sized sections) Vivek Goyal
@ 2006-09-26 14:49 ` H. J. Lu
  2006-09-26 14:52   ` Vivek Goyal
  0 siblings, 1 reply; 43+ messages in thread
From: H. J. Lu @ 2006-09-26 14:49 UTC (permalink / raw)
  To: Vivek Goyal; +Cc: binutils

On Tue, Sep 26, 2006 at 10:11:25AM -0400, Vivek Goyal wrote:
> Now, above compiler makes some symbols absolute and these symbols are 
> not relocated and kernel code fails at some point. In this case kernel 
> fails because it is trying to free memory between symbol __smp_alt_begin 
> and another symbol present in other section. __smp_alt_begin is now 
> absolute and does not get relocated and kernel ends up trying to free a 
> wrong portion of memory.
> 

Why do you want to free a memory which doesn't exist?


H.J.

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-26 14:49 ` H. J. Lu
@ 2006-09-26 14:52   ` Vivek Goyal
  2006-09-26 15:13     ` H. J. Lu
  0 siblings, 1 reply; 43+ messages in thread
From: Vivek Goyal @ 2006-09-26 14:52 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

H. J. Lu wrote:
> On Tue, Sep 26, 2006 at 10:11:25AM -0400, Vivek Goyal wrote:
> 
>>Now, above compiler makes some symbols absolute and these symbols are 
>>not relocated and kernel code fails at some point. In this case kernel 
>>fails because it is trying to free memory between symbol __smp_alt_begin 
>>and another symbol present in other section. __smp_alt_begin is now 
>>absolute and does not get relocated and kernel ends up trying to free a 
>>wrong portion of memory.
>>
> 
> 
> Why do you want to free a memory which doesn't exist?

Well, based on various CONFIG options, some init sections might be 
created when kernel is compiled. Memory belonging to these sections is 
freed once initialization is over.

In the above case, kernel defines following three sections in ld script 
and tries to free up memory __smp_alt_being and __smp_alt_end. From a 
programming perspective one can always do.

If (__smp_alt_being < __smp_alt_end)
	Free up memory;



   .smp_altinstructions : AT(ADDR(.smp_altinstructions) - LOAD_OFFSET) {
         __smp_alt_begin = .;
         __smp_alt_instructions = .;
         *(.smp_altinstructions)
         __smp_alt_instructions_end = .;
   }
   . = ALIGN(4);
   .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
         __smp_locks = .;
         *(.smp_locks)
         __smp_locks_end = .;
   }
   .smp_altinstr_replacement : AT(ADDR(.smp_altinstr_replacement) - 
LOAD_OFFSET) {
         *(.smp_altinstr_replacement)
         . = ALIGN(4096);
         __smp_alt_end = .;
   }

Thanks
Vivek

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-26 14:52   ` Vivek Goyal
@ 2006-09-26 15:13     ` H. J. Lu
  2006-09-26 15:41       ` Daniel Jacobowitz
  0 siblings, 1 reply; 43+ messages in thread
From: H. J. Lu @ 2006-09-26 15:13 UTC (permalink / raw)
  To: Vivek Goyal; +Cc: binutils

On Tue, Sep 26, 2006 at 10:26:05AM -0400, Vivek Goyal wrote:
> H. J. Lu wrote:
> >On Tue, Sep 26, 2006 at 10:11:25AM -0400, Vivek Goyal wrote:
> >
> >>Now, above compiler makes some symbols absolute and these symbols are 
> >>not relocated and kernel code fails at some point. In this case kernel 
> >>fails because it is trying to free memory between symbol __smp_alt_begin 
> >>and another symbol present in other section. __smp_alt_begin is now 
> >>absolute and does not get relocated and kernel ends up trying to free a 
> >>wrong portion of memory.
> >>
> >
> >
> >Why do you want to free a memory which doesn't exist?
> 
> Well, based on various CONFIG options, some init sections might be 
> created when kernel is compiled. Memory belonging to these sections is 
> freed once initialization is over.
> 
> In the above case, kernel defines following three sections in ld script 
> and tries to free up memory __smp_alt_being and __smp_alt_end. From a 
> programming perspective one can always do.
> 
> If (__smp_alt_being < __smp_alt_end)
> 	Free up memory;
> 

I think for --emit-relocs, we can keep an empty output section if its
address is taken.

Of course, we need to update linker doc.

H.J.

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-26 15:13     ` H. J. Lu
@ 2006-09-26 15:41       ` Daniel Jacobowitz
  2006-09-26 15:54         ` Vivek Goyal
  2006-09-26 16:14         ` H. J. Lu
  0 siblings, 2 replies; 43+ messages in thread
From: Daniel Jacobowitz @ 2006-09-26 15:41 UTC (permalink / raw)
  To: H. J. Lu; +Cc: Vivek Goyal, binutils

On Tue, Sep 26, 2006 at 07:51:59AM -0700, H. J. Lu wrote:
> I think for --emit-relocs, we can keep an empty output section if its
> address is taken.
> 
> Of course, we need to update linker doc.

I think we're being too specific to this case.

Why are we changing what the linker script clearly defines as section
relative symbols to absolute symbols?  This isn't the only use case
I've encountered where that will break.  We should either discard the
symbols, or leave the empty section.

-- 
Daniel Jacobowitz
CodeSourcery

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-26 15:41       ` Daniel Jacobowitz
@ 2006-09-26 15:54         ` Vivek Goyal
  2006-09-26 16:21           ` H. J. Lu
  2006-09-26 16:14         ` H. J. Lu
  1 sibling, 1 reply; 43+ messages in thread
From: Vivek Goyal @ 2006-09-26 15:54 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: H. J. Lu, binutils

Daniel Jacobowitz wrote:
> On Tue, Sep 26, 2006 at 07:51:59AM -0700, H. J. Lu wrote:
> 
>>I think for --emit-relocs, we can keep an empty output section if its
>>address is taken.
>>
>>Of course, we need to update linker doc.
> 
> 
> I think we're being too specific to this case.
> 
> Why are we changing what the linker script clearly defines as section
> relative symbols to absolute symbols?  This isn't the only use case
> I've encountered where that will break.  We should either discard the
> symbols, or leave the empty section.
> 

I think retaining the zero sized section might be more logical otherwise 
a user who has specifically defined a section relative symbol in linker 
script file will be surprised to know that in some cases symbol is not 
present at all.

Thanks
Vivek

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-26 15:41       ` Daniel Jacobowitz
  2006-09-26 15:54         ` Vivek Goyal
@ 2006-09-26 16:14         ` H. J. Lu
  2006-09-26 16:40           ` Vivek Goyal
  2006-09-26 17:57           ` Vivek Goyal
  1 sibling, 2 replies; 43+ messages in thread
From: H. J. Lu @ 2006-09-26 16:14 UTC (permalink / raw)
  To: Vivek Goyal, binutils

On Tue, Sep 26, 2006 at 10:58:10AM -0400, Daniel Jacobowitz wrote:
> On Tue, Sep 26, 2006 at 07:51:59AM -0700, H. J. Lu wrote:
> > I think for --emit-relocs, we can keep an empty output section if its
> > address is taken.
> > 
> > Of course, we need to update linker doc.
> 
> I think we're being too specific to this case.
> 
> Why are we changing what the linker script clearly defines as section
> relative symbols to absolute symbols?  This isn't the only use case
> I've encountered where that will break.  We should either discard the

Please open a bug report with a testcase for each different issue.

Thanks.


H.J.

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-26 15:54         ` Vivek Goyal
@ 2006-09-26 16:21           ` H. J. Lu
  2006-09-26 16:30             ` Vivek Goyal
  0 siblings, 1 reply; 43+ messages in thread
From: H. J. Lu @ 2006-09-26 16:21 UTC (permalink / raw)
  To: Vivek Goyal; +Cc: Daniel Jacobowitz, binutils

On Tue, Sep 26, 2006 at 11:06:19AM -0400, Vivek Goyal wrote:
> Daniel Jacobowitz wrote:
> >On Tue, Sep 26, 2006 at 07:51:59AM -0700, H. J. Lu wrote:
> >
> >>I think for --emit-relocs, we can keep an empty output section if its
> >>address is taken.
> >>
> >>Of course, we need to update linker doc.
> >
> >
> >I think we're being too specific to this case.
> >
> >Why are we changing what the linker script clearly defines as section
> >relative symbols to absolute symbols?  This isn't the only use case
> >I've encountered where that will break.  We should either discard the
> >symbols, or leave the empty section.
> >
> 
> I think retaining the zero sized section might be more logical otherwise 
> a user who has specifically defined a section relative symbol in linker 
> script file will be surprised to know that in some cases symbol is not 
> present at all.


I think removing empty output sections isn't a bad idea. Otherwise,
a normal executable/DSO may have many empty output sections since
the default linker scripts may have many unused output sections.

However, I agree that removing empty output sections shouldn't lead
to many surprises for user. I think linker

1. Should remove an empty output section if it isn't used to define
section relative symbol which may be changed at run time.
2. Shouldn't convert a section relative symbol to absolute symbol
if it may be changed at run time.
3. Should preserve the pre-set constant VMA of an empty output section.

Is there anything I missed?


H.J.

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-26 16:21           ` H. J. Lu
@ 2006-09-26 16:30             ` Vivek Goyal
  2006-09-26 16:44               ` H. J. Lu
  0 siblings, 1 reply; 43+ messages in thread
From: Vivek Goyal @ 2006-09-26 16:30 UTC (permalink / raw)
  To: H. J. Lu; +Cc: Daniel Jacobowitz, binutils

H. J. Lu wrote:
> On Tue, Sep 26, 2006 at 11:06:19AM -0400, Vivek Goyal wrote:
> 
>>Daniel Jacobowitz wrote:
>>
>>>On Tue, Sep 26, 2006 at 07:51:59AM -0700, H. J. Lu wrote:
>>>
>>>
>>>>I think for --emit-relocs, we can keep an empty output section if its
>>>>address is taken.
>>>>
>>>>Of course, we need to update linker doc.
>>>
>>>
>>>I think we're being too specific to this case.
>>>
>>>Why are we changing what the linker script clearly defines as section
>>>relative symbols to absolute symbols?  This isn't the only use case
>>>I've encountered where that will break.  We should either discard the
>>>symbols, or leave the empty section.
>>>
>>
>>I think retaining the zero sized section might be more logical otherwise 
>>a user who has specifically defined a section relative symbol in linker 
>>script file will be surprised to know that in some cases symbol is not 
>>present at all.
> 
> 
> 
> I think removing empty output sections isn't a bad idea. Otherwise,
> a normal executable/DSO may have many empty output sections since
> the default linker scripts may have many unused output sections.
> 
> However, I agree that removing empty output sections shouldn't lead
> to many surprises for user. I think linker
> 
> 1. Should remove an empty output section if it isn't used to define
> section relative symbol which may be changed at run time.
> 2. Shouldn't convert a section relative symbol to absolute symbol
> if it may be changed at run time.

How does one determine at compile time if a section relative symbol will 
be modified or not? ("if it may be changed at run time?").

> 3. Should preserve the pre-set constant VMA of an empty output section.
> 
> Is there anything I missed?  

I think if we just stick to the behaviour as described in "info ld" that 
should be good enough. So linker will get rid of zero sized sections 
except in following situation.

3.6.7 Output Section Discarding
-------------------------------

    "If you use anything other than an input section description as an
output section command, such as a symbol assignment, then the output
section will always be created, even if there are no matching input
sections."

Thanks
Vivek

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-26 16:14         ` H. J. Lu
@ 2006-09-26 16:40           ` Vivek Goyal
  2006-09-26 17:57           ` Vivek Goyal
  1 sibling, 0 replies; 43+ messages in thread
From: Vivek Goyal @ 2006-09-26 16:40 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

H. J. Lu wrote:
> On Tue, Sep 26, 2006 at 10:58:10AM -0400, Daniel Jacobowitz wrote:
> 
>>On Tue, Sep 26, 2006 at 07:51:59AM -0700, H. J. Lu wrote:
>>
>>>I think for --emit-relocs, we can keep an empty output section if its
>>>address is taken.
>>>
>>>Of course, we need to update linker doc.
>>
>>I think we're being too specific to this case.
>>
>>Why are we changing what the linker script clearly defines as section
>>relative symbols to absolute symbols?  This isn't the only use case
>>I've encountered where that will break.  We should either discard the
> 
> 
> Please open a bug report with a testcase for each different issue.


Thanks. I will open the bug report right away.

Thanks
Vivek

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-26 16:30             ` Vivek Goyal
@ 2006-09-26 16:44               ` H. J. Lu
  2006-09-26 16:45                 ` Vivek Goyal
                                   ` (2 more replies)
  0 siblings, 3 replies; 43+ messages in thread
From: H. J. Lu @ 2006-09-26 16:44 UTC (permalink / raw)
  To: Vivek Goyal; +Cc: Daniel Jacobowitz, binutils

On Tue, Sep 26, 2006 at 12:14:36PM -0400, Vivek Goyal wrote:
> H. J. Lu wrote:
> >On Tue, Sep 26, 2006 at 11:06:19AM -0400, Vivek Goyal wrote:
> >
> >>Daniel Jacobowitz wrote:
> >>
> >>>On Tue, Sep 26, 2006 at 07:51:59AM -0700, H. J. Lu wrote:
> >>>
> >>>
> >>>>I think for --emit-relocs, we can keep an empty output section if its
> >>>>address is taken.
> >>>>
> >>>>Of course, we need to update linker doc.
> >>>
> >>>
> >>>I think we're being too specific to this case.
> >>>
> >>>Why are we changing what the linker script clearly defines as section
> >>>relative symbols to absolute symbols?  This isn't the only use case
> >>>I've encountered where that will break.  We should either discard the
> >>>symbols, or leave the empty section.
> >>>
> >>
> >>I think retaining the zero sized section might be more logical otherwise 
> >>a user who has specifically defined a section relative symbol in linker 
> >>script file will be surprised to know that in some cases symbol is not 
> >>present at all.
> >
> >
> >
> >I think removing empty output sections isn't a bad idea. Otherwise,
> >a normal executable/DSO may have many empty output sections since
> >the default linker scripts may have many unused output sections.
> >
> >However, I agree that removing empty output sections shouldn't lead
> >to many surprises for user. I think linker
> >
> >1. Should remove an empty output section if it isn't used to define
> >section relative symbol which may be changed at run time.
> >2. Shouldn't convert a section relative symbol to absolute symbol
> >if it may be changed at run time.
> 
> How does one determine at compile time if a section relative symbol will 
> be modified or not? ("if it may be changed at run time?").

How can you reasonably modify a section relative symbol at run time?
Do you need to use --emit-relocs?

> 
> >3. Should preserve the pre-set constant VMA of an empty output section.
> >
> >Is there anything I missed?  
> 
> I think if we just stick to the behaviour as described in "info ld" that 
> should be good enough. So linker will get rid of zero sized sections 
> except in following situation.
> 
> 3.6.7 Output Section Discarding
> -------------------------------
> 
>    "If you use anything other than an input section description as an
> output section command, such as a symbol assignment, then the output
> section will always be created, even if there are no matching input
> sections."

Convert section relative symbol to absolute shouldn't be a problem
in most cases. If we know it may be a problem at link time, we can
keep it section relative.

H.J.

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-26 16:44               ` H. J. Lu
@ 2006-09-26 16:45                 ` Vivek Goyal
  2006-09-26 17:01                 ` Daniel Jacobowitz
  2006-09-26 17:48                 ` Paul Koning
  2 siblings, 0 replies; 43+ messages in thread
From: Vivek Goyal @ 2006-09-26 16:45 UTC (permalink / raw)
  To: H. J. Lu; +Cc: Daniel Jacobowitz, binutils

H. J. Lu wrote:
> On Tue, Sep 26, 2006 at 12:14:36PM -0400, Vivek Goyal wrote:
> 
>>H. J. Lu wrote:
>>
>>>On Tue, Sep 26, 2006 at 11:06:19AM -0400, Vivek Goyal wrote:
>>>
>>>
>>>>Daniel Jacobowitz wrote:
>>>>
>>>>
>>>>>On Tue, Sep 26, 2006 at 07:51:59AM -0700, H. J. Lu wrote:
>>>>>
>>>>>
>>>>>
>>>>>>I think for --emit-relocs, we can keep an empty output section if its
>>>>>>address is taken.
>>>>>>
>>>>>>Of course, we need to update linker doc.
>>>>>
>>>>>
>>>>>I think we're being too specific to this case.
>>>>>
>>>>>Why are we changing what the linker script clearly defines as section
>>>>>relative symbols to absolute symbols?  This isn't the only use case
>>>>>I've encountered where that will break.  We should either discard the
>>>>>symbols, or leave the empty section.
>>>>>
>>>>
>>>>I think retaining the zero sized section might be more logical otherwise 
>>>>a user who has specifically defined a section relative symbol in linker 
>>>>script file will be surprised to know that in some cases symbol is not 
>>>>present at all.
>>>
>>>
>>>
>>>I think removing empty output sections isn't a bad idea. Otherwise,
>>>a normal executable/DSO may have many empty output sections since
>>>the default linker scripts may have many unused output sections.
>>>
>>>However, I agree that removing empty output sections shouldn't lead
>>>to many surprises for user. I think linker
>>>
>>>1. Should remove an empty output section if it isn't used to define
>>>section relative symbol which may be changed at run time.
>>>2. Shouldn't convert a section relative symbol to absolute symbol
>>>if it may be changed at run time.
>>
>>How does one determine at compile time if a section relative symbol will 
>>be modified or not? ("if it may be changed at run time?").
> 
> 
> How can you reasonably modify a section relative symbol at run time?
> Do you need to use --emit-relocs?

I need --emit-relocs as it retains the relocation information in finally 
linked executable and I use that relocation information to relocate the 
image to a different address at run time. It is just a matter of going 
through all the relocation entries and adding an offset value.

Sorry I don't understand the first question very well. The moment a 
symbol is section relative and if section is moved at run time, I will 
be walking through and procesing all the relocations generated wrt to 
that symbol at run time.


Thanks
Vivek

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-26 16:44               ` H. J. Lu
  2006-09-26 16:45                 ` Vivek Goyal
@ 2006-09-26 17:01                 ` Daniel Jacobowitz
  2006-09-26 23:50                   ` Alan Modra
  2006-09-26 17:48                 ` Paul Koning
  2 siblings, 1 reply; 43+ messages in thread
From: Daniel Jacobowitz @ 2006-09-26 17:01 UTC (permalink / raw)
  To: H. J. Lu; +Cc: Vivek Goyal, binutils

On Tue, Sep 26, 2006 at 09:30:24AM -0700, H. J. Lu wrote:
> Convert section relative symbol to absolute shouldn't be a problem
> in most cases. If we know it may be a problem at link time, we can
> keep it section relative.

You keep saying this, but on various platforms it isn't true.  Section
relative symbols move with an object if it is relocated in any way.
Absolute symbols don't.  So, for instance any application which reads
the symbol table of a shared library can tell the difference.

And there are plenty of known platforms (e.g. Windows, SymbianOS,
VxWorks) where the distance between segments changes at load time,
so converting a relative symbol into an absolute one makes it useless;
we must be able to figure out which segment it was relative to.

-- 
Daniel Jacobowitz
CodeSourcery

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-26 16:44               ` H. J. Lu
  2006-09-26 16:45                 ` Vivek Goyal
  2006-09-26 17:01                 ` Daniel Jacobowitz
@ 2006-09-26 17:48                 ` Paul Koning
  2006-09-26 23:53                   ` Alan Modra
  2 siblings, 1 reply; 43+ messages in thread
From: Paul Koning @ 2006-09-26 17:48 UTC (permalink / raw)
  To: hjl; +Cc: vgoyal, drow, binutils

>>>>> "H" == H J Lu <hjl@lucon.org> writes:

 H> Convert section relative symbol to absolute shouldn't be a problem
 H> in most cases. If we know it may be a problem at link time, we can
 H> keep it section relative.

But what benefit is there in converting symbols from relative to
absolute?  It seems more logical to leave them alone, always.

	   paul

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-26 16:14         ` H. J. Lu
  2006-09-26 16:40           ` Vivek Goyal
@ 2006-09-26 17:57           ` Vivek Goyal
  2006-09-26 20:23             ` H. J. Lu
  1 sibling, 1 reply; 43+ messages in thread
From: Vivek Goyal @ 2006-09-26 17:57 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

H. J. Lu wrote:
> On Tue, Sep 26, 2006 at 10:58:10AM -0400, Daniel Jacobowitz wrote:
> 
>>On Tue, Sep 26, 2006 at 07:51:59AM -0700, H. J. Lu wrote:
>>
>>>I think for --emit-relocs, we can keep an empty output section if its
>>>address is taken.
>>>
>>>Of course, we need to update linker doc.
>>
>>I think we're being too specific to this case.
>>
>>Why are we changing what the linker script clearly defines as section
>>relative symbols to absolute symbols?  This isn't the only use case
>>I've encountered where that will break.  We should either discard the
> 
> 
> Please open a bug report with a testcase for each different issue.
> 

Opened a bug numbered 3267 for this issue at http://sourceware.org/bugzilla

-Vivek

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-26 17:57           ` Vivek Goyal
@ 2006-09-26 20:23             ` H. J. Lu
  0 siblings, 0 replies; 43+ messages in thread
From: H. J. Lu @ 2006-09-26 20:23 UTC (permalink / raw)
  To: Vivek Goyal; +Cc: binutils

On Tue, Sep 26, 2006 at 12:54:46PM -0400, Vivek Goyal wrote:
> H. J. Lu wrote:
> >On Tue, Sep 26, 2006 at 10:58:10AM -0400, Daniel Jacobowitz wrote:
> >
> >>On Tue, Sep 26, 2006 at 07:51:59AM -0700, H. J. Lu wrote:
> >>
> >>>I think for --emit-relocs, we can keep an empty output section if its
> >>>address is taken.
> >>>
> >>>Of course, we need to update linker doc.
> >>
> >>I think we're being too specific to this case.
> >>
> >>Why are we changing what the linker script clearly defines as section
> >>relative symbols to absolute symbols?  This isn't the only use case
> >>I've encountered where that will break.  We should either discard the
> >
> >
> >Please open a bug report with a testcase for each different issue.
> >
> 
> Opened a bug numbered 3267 for this issue at http://sourceware.org/bugzilla

It looks like we shouldn't convert section relative symbols in linker
script to absolute symbol. We still need to do decide if/how we should
remove an empty section which doesn't have a symbol relative to it.

1. If the empty section doesn't set VMA, removing it doesn't change
the next section VMA.
2. If its VMA is set to a constant, removing it will change the next
section VMA.
3. If its VMA is set to an expression, removing it may change the next
section VMA.

I'd like to totally remove the empty section and set the next section
VMA to "dot" for #1 and #3. For #2, we remove the empty section and
set to the next section VMA to the constant VMA of the removed empty
section.


H.J.

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-26 17:01                 ` Daniel Jacobowitz
@ 2006-09-26 23:50                   ` Alan Modra
  2006-09-27  1:51                     ` Daniel Jacobowitz
  0 siblings, 1 reply; 43+ messages in thread
From: Alan Modra @ 2006-09-26 23:50 UTC (permalink / raw)
  To: H. J. Lu, Vivek Goyal, binutils

On Tue, Sep 26, 2006 at 12:45:20PM -0400, Daniel Jacobowitz wrote:
> On Tue, Sep 26, 2006 at 09:30:24AM -0700, H. J. Lu wrote:
> > Convert section relative symbol to absolute shouldn't be a problem
> > in most cases. If we know it may be a problem at link time, we can
> > keep it section relative.
> 
> You keep saying this, but on various platforms it isn't true.  Section
> relative symbols move with an object if it is relocated in any way.
> Absolute symbols don't.

This isn't true for the common ELF targets.  An absolute symbol in a
shared library is effectively relative to the base of the shared lib.
A sad consequence of defining syms like _GLOBAL_OFFSET_TABLE_ and
_DYNAMIC as absolute.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-26 17:48                 ` Paul Koning
@ 2006-09-26 23:53                   ` Alan Modra
  2006-09-28 17:01                     ` Paul Brook
  0 siblings, 1 reply; 43+ messages in thread
From: Alan Modra @ 2006-09-26 23:53 UTC (permalink / raw)
  To: Paul Koning; +Cc: hjl, vgoyal, drow, binutils

On Tue, Sep 26, 2006 at 12:52:11PM -0400, Paul Koning wrote:
> >>>>> "H" == H J Lu <hjl@lucon.org> writes:
> 
>  H> Convert section relative symbol to absolute shouldn't be a problem
>  H> in most cases. If we know it may be a problem at link time, we can
>  H> keep it section relative.
> 
> But what benefit is there in converting symbols from relative to
> absolute?  It seems more logical to leave them alone, always.

We are talking about the case where the section defining the symbol
is removed from the output.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-26 23:50                   ` Alan Modra
@ 2006-09-27  1:51                     ` Daniel Jacobowitz
  2006-09-27  3:09                       ` Daniel Jacobowitz
  0 siblings, 1 reply; 43+ messages in thread
From: Daniel Jacobowitz @ 2006-09-27  1:51 UTC (permalink / raw)
  To: binutils, binutils; +Cc: H. J. Lu, Vivek Goyal

On Wed, Sep 27, 2006 at 08:57:14AM +0930, Alan Modra wrote:
> On Tue, Sep 26, 2006 at 12:45:20PM -0400, Daniel Jacobowitz wrote:
> > On Tue, Sep 26, 2006 at 09:30:24AM -0700, H. J. Lu wrote:
> > > Convert section relative symbol to absolute shouldn't be a problem
> > > in most cases. If we know it may be a problem at link time, we can
> > > keep it section relative.
> > 
> > You keep saying this, but on various platforms it isn't true.  Section
> > relative symbols move with an object if it is relocated in any way.
> > Absolute symbols don't.
> 
> This isn't true for the common ELF targets.  An absolute symbol in a
> shared library is effectively relative to the base of the shared lib.
> A sad consequence of defining syms like _GLOBAL_OFFSET_TABLE_ and
> _DYNAMIC as absolute.

Which I tried to change, you may recall :-)  For those platforms which
do care, absolute _G_O_T_ is a serious problem, and there's a knob for
it.

-- 
Daniel Jacobowitz
CodeSourcery

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-27  1:51                     ` Daniel Jacobowitz
@ 2006-09-27  3:09                       ` Daniel Jacobowitz
  0 siblings, 0 replies; 43+ messages in thread
From: Daniel Jacobowitz @ 2006-09-27  3:09 UTC (permalink / raw)
  To: binutils, binutils; +Cc: H. J. Lu, Vivek Goyal

On Wed, Sep 27, 2006 at 08:57:14AM +0930, Alan Modra wrote:
> On Tue, Sep 26, 2006 at 12:45:20PM -0400, Daniel Jacobowitz wrote:
> > On Tue, Sep 26, 2006 at 09:30:24AM -0700, H. J. Lu wrote:
> > > Convert section relative symbol to absolute shouldn't be a problem
> > > in most cases. If we know it may be a problem at link time, we can
> > > keep it section relative.
> > 
> > You keep saying this, but on various platforms it isn't true.  Section
> > relative symbols move with an object if it is relocated in any way.
> > Absolute symbols don't.
> 
> This isn't true for the common ELF targets.  An absolute symbol in a
> shared library is effectively relative to the base of the shared lib.
> A sad consequence of defining syms like _GLOBAL_OFFSET_TABLE_ and
> _DYNAMIC as absolute.

Which I tried to change, you may recall :-)  For those platforms which
do care, absolute _G_O_T_ is a serious problem, and there's a knob for
it.

-- 
Daniel Jacobowitz
CodeSourcery

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-26 23:53                   ` Alan Modra
@ 2006-09-28 17:01                     ` Paul Brook
  2006-09-28 17:05                       ` Paul Brook
                                         ` (2 more replies)
  0 siblings, 3 replies; 43+ messages in thread
From: Paul Brook @ 2006-09-28 17:01 UTC (permalink / raw)
  To: binutils; +Cc: Alan Modra, Paul Koning, hjl, vgoyal, drow, binutils

On Wednesday 27 September 2006 00:28, Alan Modra wrote:
> On Tue, Sep 26, 2006 at 12:52:11PM -0400, Paul Koning wrote:
> > >>>>> "H" == H J Lu <hjl@lucon.org> writes:
> >
> >  H> Convert section relative symbol to absolute shouldn't be a problem
> >  H> in most cases. If we know it may be a problem at link time, we can
> >  H> keep it section relative.
> >
> > But what benefit is there in converting symbols from relative to
> > absolute?  It seems more logical to leave them alone, always.
>
> We are talking about the case where the section defining the symbol
> is removed from the output.

If we remove the section shouldn't we also remove the symbol?

Paul

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-28 17:01                     ` Paul Brook
@ 2006-09-28 17:05                       ` Paul Brook
  2006-09-28 18:37                       ` H. J. Lu
  2006-09-29  6:42                       ` Linker Bug or Design Intent (Absolute symbols in zero sized sections) Alan Modra
  2 siblings, 0 replies; 43+ messages in thread
From: Paul Brook @ 2006-09-28 17:05 UTC (permalink / raw)
  To: binutils; +Cc: Alan Modra, Paul Koning, hjl, vgoyal, drow, binutils

On Wednesday 27 September 2006 00:28, Alan Modra wrote:
> On Tue, Sep 26, 2006 at 12:52:11PM -0400, Paul Koning wrote:
> > >>>>> "H" == H J Lu <hjl@lucon.org> writes:
> >
> >  H> Convert section relative symbol to absolute shouldn't be a problem
> >  H> in most cases. If we know it may be a problem at link time, we can
> >  H> keep it section relative.
> >
> > But what benefit is there in converting symbols from relative to
> > absolute?  It seems more logical to leave them alone, always.
>
> We are talking about the case where the section defining the symbol
> is removed from the output.

If we remove the section shouldn't we also remove the symbol?

Paul

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-28 17:01                     ` Paul Brook
  2006-09-28 17:05                       ` Paul Brook
@ 2006-09-28 18:37                       ` H. J. Lu
  2006-09-28 18:53                         ` H. J. Lu
  2006-10-10 16:41                         ` Jakub Jelinek
  2006-09-29  6:42                       ` Linker Bug or Design Intent (Absolute symbols in zero sized sections) Alan Modra
  2 siblings, 2 replies; 43+ messages in thread
From: H. J. Lu @ 2006-09-28 18:37 UTC (permalink / raw)
  To: Paul Brook; +Cc: binutils, Alan Modra, Paul Koning, vgoyal, drow, binutils

On Thu, Sep 28, 2006 at 05:42:29PM +0100, Paul Brook wrote:
> On Wednesday 27 September 2006 00:28, Alan Modra wrote:
> > On Tue, Sep 26, 2006 at 12:52:11PM -0400, Paul Koning wrote:
> > > >>>>> "H" == H J Lu <hjl@lucon.org> writes:
> > >
> > >  H> Convert section relative symbol to absolute shouldn't be a problem
> > >  H> in most cases. If we know it may be a problem at link time, we can
> > >  H> keep it section relative.
> > >
> > > But what benefit is there in converting symbols from relative to
> > > absolute?  It seems more logical to leave them alone, always.
> >
> > We are talking about the case where the section defining the symbol
> > is removed from the output.
> 
> If we remove the section shouldn't we also remove the symbol?

I have checked in a patch not to remove an empty section if there is
a symbol relative to it.


H.J.

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-28 18:37                       ` H. J. Lu
@ 2006-09-28 18:53                         ` H. J. Lu
  2006-10-10 16:41                         ` Jakub Jelinek
  1 sibling, 0 replies; 43+ messages in thread
From: H. J. Lu @ 2006-09-28 18:53 UTC (permalink / raw)
  To: Paul Brook; +Cc: binutils, Alan Modra, Paul Koning, vgoyal, drow, binutils

On Thu, Sep 28, 2006 at 05:42:29PM +0100, Paul Brook wrote:
> On Wednesday 27 September 2006 00:28, Alan Modra wrote:
> > On Tue, Sep 26, 2006 at 12:52:11PM -0400, Paul Koning wrote:
> > > >>>>> "H" == H J Lu <hjl@lucon.org> writes:
> > >
> > >  H> Convert section relative symbol to absolute shouldn't be a problem
> > >  H> in most cases. If we know it may be a problem at link time, we can
> > >  H> keep it section relative.
> > >
> > > But what benefit is there in converting symbols from relative to
> > > absolute?  It seems more logical to leave them alone, always.
> >
> > We are talking about the case where the section defining the symbol
> > is removed from the output.
> 
> If we remove the section shouldn't we also remove the symbol?

I have checked in a patch not to remove an empty section if there is
a symbol relative to it.


H.J.

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-28 17:01                     ` Paul Brook
  2006-09-28 17:05                       ` Paul Brook
  2006-09-28 18:37                       ` H. J. Lu
@ 2006-09-29  6:42                       ` Alan Modra
  2006-09-29  8:06                         ` Alan Modra
  2 siblings, 1 reply; 43+ messages in thread
From: Alan Modra @ 2006-09-29  6:42 UTC (permalink / raw)
  To: Paul Brook; +Cc: binutils, Paul Koning, hjl, vgoyal, drow, binutils

On Thu, Sep 28, 2006 at 05:42:29PM +0100, Paul Brook wrote:
> If we remove the section shouldn't we also remove the symbol?

The idea was to support a script like the following.  When .data is
empty and removed, you might still want __data_start defined.  The
user has defined __data_start in .data because he wants the start
sym adjusted for any alignment that might occur due to input .data
section alignment.

 .data :
 {
   __data_start = .;
   *(.data)
 }
 .data2 :
 {
   *(.data2)
 }
 __data_end = .;


-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-29  6:42                       ` Linker Bug or Design Intent (Absolute symbols in zero sized sections) Alan Modra
@ 2006-09-29  8:06                         ` Alan Modra
  0 siblings, 0 replies; 43+ messages in thread
From: Alan Modra @ 2006-09-29  8:06 UTC (permalink / raw)
  To: Paul Brook; +Cc: binutils, Paul Koning, hjl, vgoyal, drow, binutils

On Thu, Sep 28, 2006 at 05:42:29PM +0100, Paul Brook wrote:
> If we remove the section shouldn't we also remove the symbol?

The idea was to support a script like the following.  When .data is
empty and removed, you might still want __data_start defined.  The
user has defined __data_start in .data because he wants the start
sym adjusted for any alignment that might occur due to input .data
section alignment.

 .data :
 {
   __data_start = .;
   *(.data)
 }
 .data2 :
 {
   *(.data2)
 }
 __data_end = .;


-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-09-28 18:37                       ` H. J. Lu
  2006-09-28 18:53                         ` H. J. Lu
@ 2006-10-10 16:41                         ` Jakub Jelinek
  2006-10-10 16:51                           ` Jakub Jelinek
  2006-10-11  3:52                           ` Jakub Jelinek
  1 sibling, 2 replies; 43+ messages in thread
From: Jakub Jelinek @ 2006-10-10 16:41 UTC (permalink / raw)
  To: H. J. Lu
  Cc: Paul Brook, binutils, Alan Modra, Paul Koning, vgoyal, drow, binutils

On Thu, Sep 28, 2006 at 09:52:51AM -0700, H. J. Lu wrote:
> On Thu, Sep 28, 2006 at 05:42:29PM +0100, Paul Brook wrote:
> > On Wednesday 27 September 2006 00:28, Alan Modra wrote:
> > > On Tue, Sep 26, 2006 at 12:52:11PM -0400, Paul Koning wrote:
> > > > >>>>> "H" == H J Lu <hjl@lucon.org> writes:
> > > >
> > > >  H> Convert section relative symbol to absolute shouldn't be a problem
> > > >  H> in most cases. If we know it may be a problem at link time, we can
> > > >  H> keep it section relative.
> > > >
> > > > But what benefit is there in converting symbols from relative to
> > > > absolute?  It seems more logical to leave them alone, always.
> > >
> > > We are talking about the case where the section defining the symbol
> > > is removed from the output.
> > 
> > If we remove the section shouldn't we also remove the symbol?
> 
> I have checked in a patch not to remove an empty section if there is
> a symbol relative to it.

This has an ugly drawback that now almost every executable has
  [15] .preinit_array    PREINIT_ARRAY   0000000010010a94 010a94 000000 00 WA  0   0  1
  [16] .init_array       INIT_ARRAY      0000000010010a94 010a94 000000 00 WA  0   0  1
  [17] .fini_array       FINI_ARRAY      0000000010010a94 010a94 000000 00 WA  0   0  1
Can't we at least come up with PROVIDES/PROVIDES_HIDDEN variants that would
allow these symbols turned into absolute and/or to absolute 0 if the
section is empty and not output such empty sections and use that in the
builtin linker script?

It is nice kernel can now do its dirty hacks, but the userland shouldn't
suffer because of that.

	Jakub

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-10-10 16:41                         ` Jakub Jelinek
@ 2006-10-10 16:51                           ` Jakub Jelinek
  2006-10-11  3:52                           ` Jakub Jelinek
  1 sibling, 0 replies; 43+ messages in thread
From: Jakub Jelinek @ 2006-10-10 16:51 UTC (permalink / raw)
  To: H. J. Lu
  Cc: Paul Brook, binutils, Alan Modra, Paul Koning, vgoyal, drow, binutils

On Thu, Sep 28, 2006 at 09:52:51AM -0700, H. J. Lu wrote:
> On Thu, Sep 28, 2006 at 05:42:29PM +0100, Paul Brook wrote:
> > On Wednesday 27 September 2006 00:28, Alan Modra wrote:
> > > On Tue, Sep 26, 2006 at 12:52:11PM -0400, Paul Koning wrote:
> > > > >>>>> "H" == H J Lu <hjl@lucon.org> writes:
> > > >
> > > >  H> Convert section relative symbol to absolute shouldn't be a problem
> > > >  H> in most cases. If we know it may be a problem at link time, we can
> > > >  H> keep it section relative.
> > > >
> > > > But what benefit is there in converting symbols from relative to
> > > > absolute?  It seems more logical to leave them alone, always.
> > >
> > > We are talking about the case where the section defining the symbol
> > > is removed from the output.
> > 
> > If we remove the section shouldn't we also remove the symbol?
> 
> I have checked in a patch not to remove an empty section if there is
> a symbol relative to it.

This has an ugly drawback that now almost every executable has
  [15] .preinit_array    PREINIT_ARRAY   0000000010010a94 010a94 000000 00 WA  0   0  1
  [16] .init_array       INIT_ARRAY      0000000010010a94 010a94 000000 00 WA  0   0  1
  [17] .fini_array       FINI_ARRAY      0000000010010a94 010a94 000000 00 WA  0   0  1
Can't we at least come up with PROVIDES/PROVIDES_HIDDEN variants that would
allow these symbols turned into absolute and/or to absolute 0 if the
section is empty and not output such empty sections and use that in the
builtin linker script?

It is nice kernel can now do its dirty hacks, but the userland shouldn't
suffer because of that.

	Jakub

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-10-10 16:41                         ` Jakub Jelinek
  2006-10-10 16:51                           ` Jakub Jelinek
@ 2006-10-11  3:52                           ` Jakub Jelinek
  2006-10-11  7:12                             ` Jakub Jelinek
  2006-10-11  8:04                             ` Alan Modra
  1 sibling, 2 replies; 43+ messages in thread
From: Jakub Jelinek @ 2006-10-11  3:52 UTC (permalink / raw)
  To: H. J. Lu
  Cc: Paul Brook, binutils, Alan Modra, Paul Koning, vgoyal, drow, binutils

On Tue, Oct 10, 2006 at 06:34:23PM +0200, Jakub Jelinek wrote:
> This has an ugly drawback that now almost every executable has
>   [15] .preinit_array    PREINIT_ARRAY   0000000010010a94 010a94 000000 00 WA  0   0  1
>   [16] .init_array       INIT_ARRAY      0000000010010a94 010a94 000000 00 WA  0   0  1
>   [17] .fini_array       FINI_ARRAY      0000000010010a94 010a94 000000 00 WA  0   0  1
> Can't we at least come up with PROVIDES/PROVIDES_HIDDEN variants that would
> allow these symbols turned into absolute and/or to absolute 0 if the
> section is empty and not output such empty sections and use that in the
> builtin linker script?
> 
> It is nice kernel can now do its dirty hacks, but the userland shouldn't
> suffer because of that.

On x86_64, e.g. tmpdir/dl2b and most of the other test binaries are now
unnecessarily 2MB+ big:

Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            0000000000000000 000000 000000 00      0   0  0
  [ 1] .interp           PROGBITS        00000000004001c8 0001c8 00001c 00   A  0   0  1
  [ 2] .note.ABI-tag     NOTE            00000000004001e4 0001e4 000020 00   A  0   0  4
  [ 3] .hash             HASH            0000000000400208 000208 000048 04   A  4   0  8
  [ 4] .dynsym           DYNSYM          0000000000400250 000250 000138 18   A  5   1  8
  [ 5] .dynstr           STRTAB          0000000000400388 000388 000093 00   A  0   0  1
  [ 6] .gnu.version      VERSYM          000000000040041c 00041c 00001a 02   A  4   0  2
  [ 7] .gnu.version_r    VERNEED         0000000000400438 000438 000020 00   A  5   1  8
  [ 8] .rela.dyn         RELA            0000000000400458 000458 000030 18   A  4   0  8
  [ 9] .rela.plt         RELA            0000000000400488 000488 000048 18   A  4  11  8
  [10] .init             PROGBITS        00000000004004d0 0004d0 000018 00  AX  0   0  4
  [11] .plt              PROGBITS        00000000004004e8 0004e8 000040 10  AX  0   0  4
  [12] .text             PROGBITS        0000000000400530 000530 000208 00  AX  0   0 16
  [13] .fini             PROGBITS        0000000000400738 000738 00000e 00  AX  0   0  4
  [14] .rodata           PROGBITS        0000000000400748 000748 00001d 00   A  0   0  8
  [15] .eh_frame         PROGBITS        0000000000400768 000768 0000a4 00   A  0   0  8
  [16] .preinit_array    PREINIT_ARRAY   000000000060080c 20080c 000000 00  WA  0   0  1
  [17] .init_array       INIT_ARRAY      000000000060080c 20080c 000000 00  WA  0   0  1
  [18] .fini_array       FINI_ARRAY      000000000060080c 20080c 000000 00  WA  0   0  1
  [19] .ctors            PROGBITS        0000000000600810 000810 000010 00  WA  0   0  8
  [20] .dtors            PROGBITS        0000000000600820 000820 000010 00  WA  0   0  8
  [21] .jcr              PROGBITS        0000000000600830 000830 000008 00  WA  0   0  8
  [22] .dynamic          DYNAMIC         0000000000600838 000838 0001a0 10  WA  5   0  8
  [23] .got              PROGBITS        00000000006009d8 0009d8 000008 08  WA  0   0  8
  [24] .got.plt          PROGBITS        00000000006009e0 0009e0 000030 08  WA  0   0  8
  [25] .data             PROGBITS        0000000000600a10 000a10 000010 00  WA  0   0  8
  [26] .bss              NOBITS          0000000000600a20 000a20 000008 00  WA  0   0  4
  [27] .comment          PROGBITS        0000000000000000 20080c 000114 00      0   0  1
  [28] .debug_aranges    PROGBITS        0000000000000000 200920 000030 00      0   0  1
  [29] .debug_pubnames   PROGBITS        0000000000000000 200950 000023 00      0   0  1
  [30] .debug_info       PROGBITS        0000000000000000 200973 000339 00      0   0  1
  [31] .debug_abbrev     PROGBITS        0000000000000000 200cac 0000dd 00      0   0  1
  [32] .debug_line       PROGBITS        0000000000000000 200d89 0000eb 00      0   0  1
  [33] .debug_frame      PROGBITS        0000000000000000 200e78 000050 00      0   0  8
  [34] .debug_str        PROGBITS        0000000000000000 200ec8 000220 01  MS  0   0  1
  [35] .debug_loc        PROGBITS        0000000000000000 2010e8 000038 00      0   0  1
  [36] .shstrtab         STRTAB          0000000000000000 201120 000168 00      0   0  1
  [37] .symtab           SYMTAB          0000000000000000 201c48 000780 18     38  60  8
  [38] .strtab           STRTAB          0000000000000000 2023c8 000246 00      0   0  1

and prelink isn't exactly excited about such sh_offset jumps here and
there.  This patch adds a REMOVE_EMPTY output section flag which
when present in the linker script basically undoes the PR ld/3223
changes for that section, so if the section is empty and there are any
symbols defined in it, they are changed into absolute ones.
For .preinit_array/.init_array/.fini_array libc certainly won't mind
that, if the start and end symbols are equal, it won't do anything, no
matter what values those symbols have.

On ppc, I'm still getting zero size .sdata.
Here we have:
  .sdata          :
  {
    PROVIDE (_SDA_BASE_ = 32768);
    *(.sdata .sdata.* .gnu.linkonce.s.*)
  }
Either we could add here REMOVE_EMPTY flag, or, perhaps better, not consider
at least symbol = absolute value assignments as section relative,
so adding something like:
  && tree->assign.src->type.node_class != etree_value
to the tests that check if section_relative_symbol should be set.

2006-10-11  Jakub Jelinek  <jakub@redhat.com>

	* ldgram.y (REMOVE_EMPTY): New token.
	(sect_constraint): Add it.
	* ldlex.l (REMOVE_EMPTY): Add.
	* ldlang.h (lang_output_section_statement_type): Add remove_empty.
	* ldlang.c (lang_output_section_statement_lookup_1): Handle
	REMOVE_EMPTY.
	(lang_size_sections_1): If remove_empty, don't set
	section_relative_symbol.
	* scripttempl/elf.sc: Add REMOVE_EMPTY to .init_array, .fini_array
	and .preinit_array.

--- ld/ldlang.c.jj	2006-09-27 06:18:15.000000000 +0200
+++ ld/ldlang.c	2006-10-11 00:19:48.000000000 +0200
@@ -1226,6 +1226,13 @@ lang_output_section_statement_lookup_1 (
   struct out_section_hash_entry *entry;
   struct out_section_hash_entry *last_ent;
   unsigned long hash;
+  bfd_boolean remove_empty = FALSE;
+
+  if (constraint == REMOVE_EMPTY)
+    {
+      remove_empty = TRUE;
+      constraint = 0;
+    }
 
   entry = ((struct out_section_hash_entry *)
 	   bfd_hash_lookup (&output_section_statement_table, name,
@@ -1271,6 +1278,8 @@ lang_output_section_statement_lookup_1 (
 
   entry->s.output_section_statement.name = name;
   entry->s.output_section_statement.constraint = constraint;
+  if (remove_empty)
+    entry->s.output_section_statement.remove_empty = 1;
   return &entry->s.output_section_statement;
 }
 
@@ -4640,7 +4649,8 @@ lang_size_sections_1
 	    if ((tree->type.node_class == etree_provided 
 		 || tree->type.node_class == etree_assign)
 		&& (tree->assign.dst [0] != '.'
-		    || tree->assign.dst [1] != '\0'))
+		    || tree->assign.dst [1] != '\0')
+		&& !output_section_statement->remove_empty)
 	      output_section_statement->section_relative_symbol = 1;
 
 	    if (!output_section_statement->ignored)
--- ld/ldgram.y.jj	2006-09-07 19:16:34.000000000 +0200
+++ ld/ldgram.y	2006-10-11 00:10:32.000000000 +0200
@@ -150,7 +150,7 @@ static int error_index;
 %token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START
 %token <name> VERS_TAG VERS_IDENTIFIER
 %token GLOBAL LOCAL VERSIONK INPUT_VERSION_SCRIPT
-%token KEEP ONLY_IF_RO ONLY_IF_RW SPECIAL
+%token KEEP ONLY_IF_RO ONLY_IF_RW REMOVE_EMPTY SPECIAL
 %token EXCLUDE_FILE
 %token CONSTANT
 %type <versyms> vers_defns
@@ -907,6 +907,7 @@ opt_subalign:
 sect_constraint:
 		ONLY_IF_RO { $$ = ONLY_IF_RO; }
 	|	ONLY_IF_RW { $$ = ONLY_IF_RW; }
+	|	REMOVE_EMPTY { $$ = REMOVE_EMPTY; }
 	|	SPECIAL { $$ = SPECIAL; }
 	|	{ $$ = 0; }
 	;
--- ld/scripttempl/elf.sc.jj	2006-09-24 08:23:15.000000000 +0200
+++ ld/scripttempl/elf.sc	2006-10-11 00:26:15.000000000 +0200
@@ -380,20 +380,20 @@ cat <<EOF
   .tdata	${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
   .tbss		${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
 
-  .preinit_array   ${RELOCATING-0} :
+  .preinit_array   ${RELOCATING-0} : ${RELOCATING+${CREATE_SHLIB-REMOVE_EMPTY}}
   {
     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}}
     KEEP (*(.preinit_array))
     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}}
   }
-  .init_array   ${RELOCATING-0} :
+  .init_array   ${RELOCATING-0} : ${RELOCATING+${CREATE_SHLIB-REMOVE_EMPTY}}
   {
      ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}}
      KEEP (*(SORT(.init_array.*)))
      KEEP (*(.init_array))
      ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}}
   }
-  .fini_array   ${RELOCATING-0} :
+  .fini_array   ${RELOCATING-0} : ${RELOCATING+${CREATE_SHLIB-REMOVE_EMPTY}}
   {
     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}}
     KEEP (*(.fini_array))
--- ld/ldlang.h.jj	2006-09-27 06:18:15.000000000 +0200
+++ ld/ldlang.h	2006-10-11 00:07:20.000000000 +0200
@@ -157,6 +157,9 @@ typedef struct lang_output_section_state
   unsigned int ignored : 1; 
   /* If there is a symbol relative to this section.  */
   unsigned int section_relative_symbol : 1; 
+  /* If this section should be removed when empty, even when it
+     contains section relative symbols.  */
+  unsigned int remove_empty : 1;
 } lang_output_section_statement_type;
 
 typedef struct
--- ld/ldlex.l.jj	2006-09-07 19:16:34.000000000 +0200
+++ ld/ldlex.l	2006-10-10 23:59:54.000000000 +0200
@@ -1,7 +1,7 @@
 %{
 
 /* Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005  Free Software Foundation, Inc.
+   2000, 2001, 2002, 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
 
    This file is part of GLD, the Gnu Linker.
 
@@ -304,6 +304,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([
 <EXPRESSION,BOTH,SCRIPT>"OVERLAY"	{ RTOKEN(OVERLAY);}
 <EXPRESSION,BOTH,SCRIPT>"ONLY_IF_RO"	{ RTOKEN(ONLY_IF_RO); }
 <EXPRESSION,BOTH,SCRIPT>"ONLY_IF_RW"	{ RTOKEN(ONLY_IF_RW); }
+<EXPRESSION,BOTH,SCRIPT>"REMOVE_EMPTY"	{ RTOKEN(REMOVE_EMPTY); }
 <EXPRESSION,BOTH,SCRIPT>"SPECIAL"	{ RTOKEN(SPECIAL); }
 <BOTH,SCRIPT>"o"			{ RTOKEN(ORIGIN);}
 <BOTH,SCRIPT>"org"			{ RTOKEN(ORIGIN);}

	Jakub

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-10-11  3:52                           ` Jakub Jelinek
@ 2006-10-11  7:12                             ` Jakub Jelinek
  2006-10-11  8:04                             ` Alan Modra
  1 sibling, 0 replies; 43+ messages in thread
From: Jakub Jelinek @ 2006-10-11  7:12 UTC (permalink / raw)
  To: H. J. Lu
  Cc: Paul Brook, binutils, Alan Modra, Paul Koning, vgoyal, drow, binutils

On Tue, Oct 10, 2006 at 06:34:23PM +0200, Jakub Jelinek wrote:
> This has an ugly drawback that now almost every executable has
>   [15] .preinit_array    PREINIT_ARRAY   0000000010010a94 010a94 000000 00 WA  0   0  1
>   [16] .init_array       INIT_ARRAY      0000000010010a94 010a94 000000 00 WA  0   0  1
>   [17] .fini_array       FINI_ARRAY      0000000010010a94 010a94 000000 00 WA  0   0  1
> Can't we at least come up with PROVIDES/PROVIDES_HIDDEN variants that would
> allow these symbols turned into absolute and/or to absolute 0 if the
> section is empty and not output such empty sections and use that in the
> builtin linker script?
> 
> It is nice kernel can now do its dirty hacks, but the userland shouldn't
> suffer because of that.

On x86_64, e.g. tmpdir/dl2b and most of the other test binaries are now
unnecessarily 2MB+ big:

Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            0000000000000000 000000 000000 00      0   0  0
  [ 1] .interp           PROGBITS        00000000004001c8 0001c8 00001c 00   A  0   0  1
  [ 2] .note.ABI-tag     NOTE            00000000004001e4 0001e4 000020 00   A  0   0  4
  [ 3] .hash             HASH            0000000000400208 000208 000048 04   A  4   0  8
  [ 4] .dynsym           DYNSYM          0000000000400250 000250 000138 18   A  5   1  8
  [ 5] .dynstr           STRTAB          0000000000400388 000388 000093 00   A  0   0  1
  [ 6] .gnu.version      VERSYM          000000000040041c 00041c 00001a 02   A  4   0  2
  [ 7] .gnu.version_r    VERNEED         0000000000400438 000438 000020 00   A  5   1  8
  [ 8] .rela.dyn         RELA            0000000000400458 000458 000030 18   A  4   0  8
  [ 9] .rela.plt         RELA            0000000000400488 000488 000048 18   A  4  11  8
  [10] .init             PROGBITS        00000000004004d0 0004d0 000018 00  AX  0   0  4
  [11] .plt              PROGBITS        00000000004004e8 0004e8 000040 10  AX  0   0  4
  [12] .text             PROGBITS        0000000000400530 000530 000208 00  AX  0   0 16
  [13] .fini             PROGBITS        0000000000400738 000738 00000e 00  AX  0   0  4
  [14] .rodata           PROGBITS        0000000000400748 000748 00001d 00   A  0   0  8
  [15] .eh_frame         PROGBITS        0000000000400768 000768 0000a4 00   A  0   0  8
  [16] .preinit_array    PREINIT_ARRAY   000000000060080c 20080c 000000 00  WA  0   0  1
  [17] .init_array       INIT_ARRAY      000000000060080c 20080c 000000 00  WA  0   0  1
  [18] .fini_array       FINI_ARRAY      000000000060080c 20080c 000000 00  WA  0   0  1
  [19] .ctors            PROGBITS        0000000000600810 000810 000010 00  WA  0   0  8
  [20] .dtors            PROGBITS        0000000000600820 000820 000010 00  WA  0   0  8
  [21] .jcr              PROGBITS        0000000000600830 000830 000008 00  WA  0   0  8
  [22] .dynamic          DYNAMIC         0000000000600838 000838 0001a0 10  WA  5   0  8
  [23] .got              PROGBITS        00000000006009d8 0009d8 000008 08  WA  0   0  8
  [24] .got.plt          PROGBITS        00000000006009e0 0009e0 000030 08  WA  0   0  8
  [25] .data             PROGBITS        0000000000600a10 000a10 000010 00  WA  0   0  8
  [26] .bss              NOBITS          0000000000600a20 000a20 000008 00  WA  0   0  4
  [27] .comment          PROGBITS        0000000000000000 20080c 000114 00      0   0  1
  [28] .debug_aranges    PROGBITS        0000000000000000 200920 000030 00      0   0  1
  [29] .debug_pubnames   PROGBITS        0000000000000000 200950 000023 00      0   0  1
  [30] .debug_info       PROGBITS        0000000000000000 200973 000339 00      0   0  1
  [31] .debug_abbrev     PROGBITS        0000000000000000 200cac 0000dd 00      0   0  1
  [32] .debug_line       PROGBITS        0000000000000000 200d89 0000eb 00      0   0  1
  [33] .debug_frame      PROGBITS        0000000000000000 200e78 000050 00      0   0  8
  [34] .debug_str        PROGBITS        0000000000000000 200ec8 000220 01  MS  0   0  1
  [35] .debug_loc        PROGBITS        0000000000000000 2010e8 000038 00      0   0  1
  [36] .shstrtab         STRTAB          0000000000000000 201120 000168 00      0   0  1
  [37] .symtab           SYMTAB          0000000000000000 201c48 000780 18     38  60  8
  [38] .strtab           STRTAB          0000000000000000 2023c8 000246 00      0   0  1

and prelink isn't exactly excited about such sh_offset jumps here and
there.  This patch adds a REMOVE_EMPTY output section flag which
when present in the linker script basically undoes the PR ld/3223
changes for that section, so if the section is empty and there are any
symbols defined in it, they are changed into absolute ones.
For .preinit_array/.init_array/.fini_array libc certainly won't mind
that, if the start and end symbols are equal, it won't do anything, no
matter what values those symbols have.

On ppc, I'm still getting zero size .sdata.
Here we have:
  .sdata          :
  {
    PROVIDE (_SDA_BASE_ = 32768);
    *(.sdata .sdata.* .gnu.linkonce.s.*)
  }
Either we could add here REMOVE_EMPTY flag, or, perhaps better, not consider
at least symbol = absolute value assignments as section relative,
so adding something like:
  && tree->assign.src->type.node_class != etree_value
to the tests that check if section_relative_symbol should be set.

2006-10-11  Jakub Jelinek  <jakub@redhat.com>

	* ldgram.y (REMOVE_EMPTY): New token.
	(sect_constraint): Add it.
	* ldlex.l (REMOVE_EMPTY): Add.
	* ldlang.h (lang_output_section_statement_type): Add remove_empty.
	* ldlang.c (lang_output_section_statement_lookup_1): Handle
	REMOVE_EMPTY.
	(lang_size_sections_1): If remove_empty, don't set
	section_relative_symbol.
	* scripttempl/elf.sc: Add REMOVE_EMPTY to .init_array, .fini_array
	and .preinit_array.

--- ld/ldlang.c.jj	2006-09-27 06:18:15.000000000 +0200
+++ ld/ldlang.c	2006-10-11 00:19:48.000000000 +0200
@@ -1226,6 +1226,13 @@ lang_output_section_statement_lookup_1 (
   struct out_section_hash_entry *entry;
   struct out_section_hash_entry *last_ent;
   unsigned long hash;
+  bfd_boolean remove_empty = FALSE;
+
+  if (constraint == REMOVE_EMPTY)
+    {
+      remove_empty = TRUE;
+      constraint = 0;
+    }
 
   entry = ((struct out_section_hash_entry *)
 	   bfd_hash_lookup (&output_section_statement_table, name,
@@ -1271,6 +1278,8 @@ lang_output_section_statement_lookup_1 (
 
   entry->s.output_section_statement.name = name;
   entry->s.output_section_statement.constraint = constraint;
+  if (remove_empty)
+    entry->s.output_section_statement.remove_empty = 1;
   return &entry->s.output_section_statement;
 }
 
@@ -4640,7 +4649,8 @@ lang_size_sections_1
 	    if ((tree->type.node_class == etree_provided 
 		 || tree->type.node_class == etree_assign)
 		&& (tree->assign.dst [0] != '.'
-		    || tree->assign.dst [1] != '\0'))
+		    || tree->assign.dst [1] != '\0')
+		&& !output_section_statement->remove_empty)
 	      output_section_statement->section_relative_symbol = 1;
 
 	    if (!output_section_statement->ignored)
--- ld/ldgram.y.jj	2006-09-07 19:16:34.000000000 +0200
+++ ld/ldgram.y	2006-10-11 00:10:32.000000000 +0200
@@ -150,7 +150,7 @@ static int error_index;
 %token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START
 %token <name> VERS_TAG VERS_IDENTIFIER
 %token GLOBAL LOCAL VERSIONK INPUT_VERSION_SCRIPT
-%token KEEP ONLY_IF_RO ONLY_IF_RW SPECIAL
+%token KEEP ONLY_IF_RO ONLY_IF_RW REMOVE_EMPTY SPECIAL
 %token EXCLUDE_FILE
 %token CONSTANT
 %type <versyms> vers_defns
@@ -907,6 +907,7 @@ opt_subalign:
 sect_constraint:
 		ONLY_IF_RO { $$ = ONLY_IF_RO; }
 	|	ONLY_IF_RW { $$ = ONLY_IF_RW; }
+	|	REMOVE_EMPTY { $$ = REMOVE_EMPTY; }
 	|	SPECIAL { $$ = SPECIAL; }
 	|	{ $$ = 0; }
 	;
--- ld/scripttempl/elf.sc.jj	2006-09-24 08:23:15.000000000 +0200
+++ ld/scripttempl/elf.sc	2006-10-11 00:26:15.000000000 +0200
@@ -380,20 +380,20 @@ cat <<EOF
   .tdata	${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
   .tbss		${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
 
-  .preinit_array   ${RELOCATING-0} :
+  .preinit_array   ${RELOCATING-0} : ${RELOCATING+${CREATE_SHLIB-REMOVE_EMPTY}}
   {
     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}}
     KEEP (*(.preinit_array))
     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}}
   }
-  .init_array   ${RELOCATING-0} :
+  .init_array   ${RELOCATING-0} : ${RELOCATING+${CREATE_SHLIB-REMOVE_EMPTY}}
   {
      ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}}
      KEEP (*(SORT(.init_array.*)))
      KEEP (*(.init_array))
      ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}}
   }
-  .fini_array   ${RELOCATING-0} :
+  .fini_array   ${RELOCATING-0} : ${RELOCATING+${CREATE_SHLIB-REMOVE_EMPTY}}
   {
     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}}
     KEEP (*(.fini_array))
--- ld/ldlang.h.jj	2006-09-27 06:18:15.000000000 +0200
+++ ld/ldlang.h	2006-10-11 00:07:20.000000000 +0200
@@ -157,6 +157,9 @@ typedef struct lang_output_section_state
   unsigned int ignored : 1; 
   /* If there is a symbol relative to this section.  */
   unsigned int section_relative_symbol : 1; 
+  /* If this section should be removed when empty, even when it
+     contains section relative symbols.  */
+  unsigned int remove_empty : 1;
 } lang_output_section_statement_type;
 
 typedef struct
--- ld/ldlex.l.jj	2006-09-07 19:16:34.000000000 +0200
+++ ld/ldlex.l	2006-10-10 23:59:54.000000000 +0200
@@ -1,7 +1,7 @@
 %{
 
 /* Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005  Free Software Foundation, Inc.
+   2000, 2001, 2002, 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
 
    This file is part of GLD, the Gnu Linker.
 
@@ -304,6 +304,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([
 <EXPRESSION,BOTH,SCRIPT>"OVERLAY"	{ RTOKEN(OVERLAY);}
 <EXPRESSION,BOTH,SCRIPT>"ONLY_IF_RO"	{ RTOKEN(ONLY_IF_RO); }
 <EXPRESSION,BOTH,SCRIPT>"ONLY_IF_RW"	{ RTOKEN(ONLY_IF_RW); }
+<EXPRESSION,BOTH,SCRIPT>"REMOVE_EMPTY"	{ RTOKEN(REMOVE_EMPTY); }
 <EXPRESSION,BOTH,SCRIPT>"SPECIAL"	{ RTOKEN(SPECIAL); }
 <BOTH,SCRIPT>"o"			{ RTOKEN(ORIGIN);}
 <BOTH,SCRIPT>"org"			{ RTOKEN(ORIGIN);}

	Jakub

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-10-11  3:52                           ` Jakub Jelinek
  2006-10-11  7:12                             ` Jakub Jelinek
@ 2006-10-11  8:04                             ` Alan Modra
  2006-10-11 14:08                               ` Alan Modra
  2006-10-11 14:19                               ` Jakub Jelinek
  1 sibling, 2 replies; 43+ messages in thread
From: Alan Modra @ 2006-10-11  8:04 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: H. J. Lu, Paul Brook, binutils, Paul Koning, vgoyal, drow, binutils

On Wed, Oct 11, 2006 at 01:19:22AM +0200, Jakub Jelinek wrote:
> Either we could add here REMOVE_EMPTY flag, or, perhaps better, not consider
> at least symbol = absolute value assignments as section relative,

Sections containing symbols really do need to stay, for --emit-relocs
and dynamic relocs.  Or at least, we need to do something to make them
work properly.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-10-11  8:04                             ` Alan Modra
@ 2006-10-11 14:08                               ` Alan Modra
  2006-10-11 14:19                               ` Jakub Jelinek
  1 sibling, 0 replies; 43+ messages in thread
From: Alan Modra @ 2006-10-11 14:08 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: H. J. Lu, Paul Brook, binutils, Paul Koning, vgoyal, drow, binutils

On Wed, Oct 11, 2006 at 01:19:22AM +0200, Jakub Jelinek wrote:
> Either we could add here REMOVE_EMPTY flag, or, perhaps better, not consider
> at least symbol = absolute value assignments as section relative,

Sections containing symbols really do need to stay, for --emit-relocs
and dynamic relocs.  Or at least, we need to do something to make them
work properly.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-10-11  8:04                             ` Alan Modra
  2006-10-11 14:08                               ` Alan Modra
@ 2006-10-11 14:19                               ` Jakub Jelinek
  2006-10-11 14:45                                 ` Jakub Jelinek
  2006-10-12 10:18                                 ` Alan Modra
  1 sibling, 2 replies; 43+ messages in thread
From: Jakub Jelinek @ 2006-10-11 14:19 UTC (permalink / raw)
  To: H. J. Lu, Paul Brook, binutils, Paul Koning, vgoyal, drow, binutils

On Wed, Oct 11, 2006 at 01:23:05PM +0930, Alan Modra wrote:
> On Wed, Oct 11, 2006 at 01:19:22AM +0200, Jakub Jelinek wrote:
> > Either we could add here REMOVE_EMPTY flag, or, perhaps better, not consider
> > at least symbol = absolute value assignments as section relative,
> 
> Sections containing symbols really do need to stay, for --emit-relocs
> and dynamic relocs.  Or at least, we need to do something to make them
> work properly.

Dynamic relocs aren't an issue here, in both cases we are talking about
executables and the the __{{pre,}init,fini}_array_{start,end} symbols
are PROVIDE_HIDDEN and __SDA_BASE__ likely should be PROVIDE_HIDDEN too
(and, furthermore for __SDA_BASE__ using section relative symbol is wrong,
as it is assigned a constant value, unrelated to the current section
(and in any case tweaked by the ppc backend; if there is non-empty
.sdata, __SDA_BASE__ is even ABS, only when it is empty it is section
relative ATM)).  For --emit-relocs and the init/fini array symbols
we again don't care what exact values they have, as long as a post-linking
tool doesn't want to add things into one of the previously empty
.init_array etc. sections.  But, such tool either would need to be
aware what these symbols mean and set them properly after inserting
stuff there, the *_array_start one to the beginning of the section and
*_array_end to the end of the section, or it would do the wrong thing
(kept either both symbols at the beginning, or end of the section it
grew, in any case for the _start code this would mean there is no such
section).

Against emitting empty sections speaks both that it is a wasted space
in section header table/.shstrtab, but more importantly that empty
sections are an endless source of bugs (as shown yesterday e.g.
on x86-64) in almost every tool that needs to deal with them.
This is not the first time ld didn't get sh_offsets for empty sections
right, I remember fighting with that several times in prelink, strip/objcopy
was messing them up in the past too and prelink had bugs in handling them
too.

	Jakub

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-10-11 14:19                               ` Jakub Jelinek
@ 2006-10-11 14:45                                 ` Jakub Jelinek
  2006-10-12 10:18                                 ` Alan Modra
  1 sibling, 0 replies; 43+ messages in thread
From: Jakub Jelinek @ 2006-10-11 14:45 UTC (permalink / raw)
  To: H. J. Lu, Paul Brook, binutils, Paul Koning, vgoyal, drow, binutils

On Wed, Oct 11, 2006 at 01:23:05PM +0930, Alan Modra wrote:
> On Wed, Oct 11, 2006 at 01:19:22AM +0200, Jakub Jelinek wrote:
> > Either we could add here REMOVE_EMPTY flag, or, perhaps better, not consider
> > at least symbol = absolute value assignments as section relative,
> 
> Sections containing symbols really do need to stay, for --emit-relocs
> and dynamic relocs.  Or at least, we need to do something to make them
> work properly.

Dynamic relocs aren't an issue here, in both cases we are talking about
executables and the the __{{pre,}init,fini}_array_{start,end} symbols
are PROVIDE_HIDDEN and __SDA_BASE__ likely should be PROVIDE_HIDDEN too
(and, furthermore for __SDA_BASE__ using section relative symbol is wrong,
as it is assigned a constant value, unrelated to the current section
(and in any case tweaked by the ppc backend; if there is non-empty
.sdata, __SDA_BASE__ is even ABS, only when it is empty it is section
relative ATM)).  For --emit-relocs and the init/fini array symbols
we again don't care what exact values they have, as long as a post-linking
tool doesn't want to add things into one of the previously empty
.init_array etc. sections.  But, such tool either would need to be
aware what these symbols mean and set them properly after inserting
stuff there, the *_array_start one to the beginning of the section and
*_array_end to the end of the section, or it would do the wrong thing
(kept either both symbols at the beginning, or end of the section it
grew, in any case for the _start code this would mean there is no such
section).

Against emitting empty sections speaks both that it is a wasted space
in section header table/.shstrtab, but more importantly that empty
sections are an endless source of bugs (as shown yesterday e.g.
on x86-64) in almost every tool that needs to deal with them.
This is not the first time ld didn't get sh_offsets for empty sections
right, I remember fighting with that several times in prelink, strip/objcopy
was messing them up in the past too and prelink had bugs in handling them
too.

	Jakub

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-10-11 14:19                               ` Jakub Jelinek
  2006-10-11 14:45                                 ` Jakub Jelinek
@ 2006-10-12 10:18                                 ` Alan Modra
  2006-10-12 14:37                                   ` Alan Modra
                                                     ` (2 more replies)
  1 sibling, 3 replies; 43+ messages in thread
From: Alan Modra @ 2006-10-12 10:18 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: H. J. Lu, Paul Brook, binutils, Paul Koning, vgoyal, drow, binutils

On Wed, Oct 11, 2006 at 09:11:26AM +0200, Jakub Jelinek wrote:
> On Wed, Oct 11, 2006 at 01:23:05PM +0930, Alan Modra wrote:
> > On Wed, Oct 11, 2006 at 01:19:22AM +0200, Jakub Jelinek wrote:
> > > Either we could add here REMOVE_EMPTY flag, or, perhaps better, not consider
> > > at least symbol = absolute value assignments as section relative,
> > 
> > Sections containing symbols really do need to stay, for --emit-relocs
> > and dynamic relocs.  Or at least, we need to do something to make them
> > work properly.
> 
> Dynamic relocs aren't an issue here

Well, yes, but they are a problem in other sections when building shared
libs.  I'd like to see a general solution rather than a hack that only
works for some sections.

> Against emitting empty sections speaks both that it is a wasted space
> in section header table/.shstrtab, but more importantly that empty
> sections are an endless source of bugs

Agreed.

If we are to remove them, then 
a) Detecting a symbol assignment in a linker script should result in the
   section alignment and vma being honoured.
b) All the ELF backends will need changes so that removed output section
   syms are never used when emitting relocs.  At the same time, we may
   as well just use one section sym for all relocs (or two for targets
   that might want to relocate the data segment separately from the text
   segment).
c) _bfd_fix_excluded_sec_syms should be changed to not create absolute
   syms.

Comments?

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-10-12 10:18                                 ` Alan Modra
@ 2006-10-12 14:37                                   ` Alan Modra
  2006-10-13 10:58                                   ` Jakub Jelinek
  2006-10-17 16:02                                   ` Dynamic section symbols, ignored output sections Alan Modra
  2 siblings, 0 replies; 43+ messages in thread
From: Alan Modra @ 2006-10-12 14:37 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: H. J. Lu, Paul Brook, binutils, Paul Koning, vgoyal, drow, binutils

On Wed, Oct 11, 2006 at 09:11:26AM +0200, Jakub Jelinek wrote:
> On Wed, Oct 11, 2006 at 01:23:05PM +0930, Alan Modra wrote:
> > On Wed, Oct 11, 2006 at 01:19:22AM +0200, Jakub Jelinek wrote:
> > > Either we could add here REMOVE_EMPTY flag, or, perhaps better, not consider
> > > at least symbol = absolute value assignments as section relative,
> > 
> > Sections containing symbols really do need to stay, for --emit-relocs
> > and dynamic relocs.  Or at least, we need to do something to make them
> > work properly.
> 
> Dynamic relocs aren't an issue here

Well, yes, but they are a problem in other sections when building shared
libs.  I'd like to see a general solution rather than a hack that only
works for some sections.

> Against emitting empty sections speaks both that it is a wasted space
> in section header table/.shstrtab, but more importantly that empty
> sections are an endless source of bugs

Agreed.

If we are to remove them, then 
a) Detecting a symbol assignment in a linker script should result in the
   section alignment and vma being honoured.
b) All the ELF backends will need changes so that removed output section
   syms are never used when emitting relocs.  At the same time, we may
   as well just use one section sym for all relocs (or two for targets
   that might want to relocate the data segment separately from the text
   segment).
c) _bfd_fix_excluded_sec_syms should be changed to not create absolute
   syms.

Comments?

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-10-12 10:18                                 ` Alan Modra
  2006-10-12 14:37                                   ` Alan Modra
@ 2006-10-13 10:58                                   ` Jakub Jelinek
  2006-10-13 11:10                                     ` Alan Modra
  2006-10-17 16:02                                   ` Dynamic section symbols, ignored output sections Alan Modra
  2 siblings, 1 reply; 43+ messages in thread
From: Jakub Jelinek @ 2006-10-13 10:58 UTC (permalink / raw)
  To: H. J. Lu, Paul Brook, binutils, Paul Koning, vgoyal, drow, binutils

On Thu, Oct 12, 2006 at 01:13:41PM +0930, Alan Modra wrote:
> > Against emitting empty sections speaks both that it is a wasted space
> > in section header table/.shstrtab, but more importantly that empty
> > sections are an endless source of bugs
> 
> Agreed.
> 
> If we are to remove them, then 
> a) Detecting a symbol assignment in a linker script should result in the
>    section alignment and vma being honoured.

Not sure what are we doing ATM here.

> b) All the ELF backends will need changes so that removed output section
>    syms are never used when emitting relocs.  At the same time, we may
>    as well just use one section sym for all relocs (or two for targets
>    that might want to relocate the data segment separately from the text
>    segment).

Sure.

> c) _bfd_fix_excluded_sec_syms should be changed to not create absolute
>    syms.

And instead have the nearest section in the same loadable segment in
st_shndx?

	Jakub

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-10-13 10:58                                   ` Jakub Jelinek
@ 2006-10-13 11:10                                     ` Alan Modra
  2006-10-13 11:26                                       ` Alan Modra
  0 siblings, 1 reply; 43+ messages in thread
From: Alan Modra @ 2006-10-13 11:10 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: H. J. Lu, Paul Brook, binutils, Paul Koning, vgoyal, drow, binutils

On Thu, Oct 12, 2006 at 10:34:09AM -0400, Jakub Jelinek wrote:
> On Thu, Oct 12, 2006 at 01:13:41PM +0930, Alan Modra wrote:
> > > Against emitting empty sections speaks both that it is a wasted space
> > > in section header table/.shstrtab, but more importantly that empty
> > > sections are an endless source of bugs
> > 
> > Agreed.
> > 
> > If we are to remove them, then 
> > a) Detecting a symbol assignment in a linker script should result in the
> >    section alignment and vma being honoured.
> 
> Not sure what are we doing ATM here.

The wrong thing..

> > b) All the ELF backends will need changes so that removed output section
> >    syms are never used when emitting relocs.  At the same time, we may
> >    as well just use one section sym for all relocs (or two for targets
> >    that might want to relocate the data segment separately from the text
> >    segment).
> 
> Sure.
> 
> > c) _bfd_fix_excluded_sec_syms should be changed to not create absolute
> >    syms.
> 
> And instead have the nearest section in the same loadable segment in
> st_shndx?

Something like that.  I figured on just using the closest preceding
section.  BTW, I started throwing a patch together to do (b).

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: Linker Bug or Design Intent (Absolute symbols in zero sized sections)
  2006-10-13 11:10                                     ` Alan Modra
@ 2006-10-13 11:26                                       ` Alan Modra
  0 siblings, 0 replies; 43+ messages in thread
From: Alan Modra @ 2006-10-13 11:26 UTC (permalink / raw)
  To: Jakub Jelinek
  Cc: H. J. Lu, Paul Brook, binutils, Paul Koning, vgoyal, drow, binutils

On Thu, Oct 12, 2006 at 10:34:09AM -0400, Jakub Jelinek wrote:
> On Thu, Oct 12, 2006 at 01:13:41PM +0930, Alan Modra wrote:
> > > Against emitting empty sections speaks both that it is a wasted space
> > > in section header table/.shstrtab, but more importantly that empty
> > > sections are an endless source of bugs
> > 
> > Agreed.
> > 
> > If we are to remove them, then 
> > a) Detecting a symbol assignment in a linker script should result in the
> >    section alignment and vma being honoured.
> 
> Not sure what are we doing ATM here.

The wrong thing..

> > b) All the ELF backends will need changes so that removed output section
> >    syms are never used when emitting relocs.  At the same time, we may
> >    as well just use one section sym for all relocs (or two for targets
> >    that might want to relocate the data segment separately from the text
> >    segment).
> 
> Sure.
> 
> > c) _bfd_fix_excluded_sec_syms should be changed to not create absolute
> >    syms.
> 
> And instead have the nearest section in the same loadable segment in
> st_shndx?

Something like that.  I figured on just using the closest preceding
section.  BTW, I started throwing a patch together to do (b).

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Dynamic section symbols, ignored output sections
  2006-10-12 10:18                                 ` Alan Modra
  2006-10-12 14:37                                   ` Alan Modra
  2006-10-13 10:58                                   ` Jakub Jelinek
@ 2006-10-17 16:02                                   ` Alan Modra
  2006-10-19 14:55                                     ` ligang
  2006-10-22  0:25                                     ` Jakub Jelinek
  2 siblings, 2 replies; 43+ messages in thread
From: Alan Modra @ 2006-10-17 16:02 UTC (permalink / raw)
  To: binutils; +Cc: Mei Ligang

On Thu, Oct 12, 2006 at 01:13:41PM +0930, Alan Modra wrote:
> a) Detecting a symbol assignment in a linker script should result in the
>    section alignment and vma being honoured.
> b) All the ELF backends will need changes so that removed output section
>    syms are never used when emitting relocs.  At the same time, we may
>    as well just use one section sym for all relocs (or two for targets
>    that might want to relocate the data segment separately from the text
>    segment).
> c) _bfd_fix_excluded_sec_syms should be changed to not create absolute
>    syms.

This patch does all of the above, plus adjusts the ld testsuite for
the changes.  A number of ELF targets will now use no dynamic section
symbols while others will just use one (or two when TLS is involved).
I started looking at FRV, and decided to leave the dyn sym change to a
target maintainer because it seemed likely to me that I'd break
something..  I also won't commit the S+core patch included here until
I get the OK from Mei Ligang;  It changes elf32-score.c to use the
zero index symbol on dynamic relocations rather than use section
symbols.  This is desirable on a new target as it should speed ld.so
slightly, but of course the dynamic linker support needs to be
available.


bfd/
	* elf-bfd.h (struct elf_link_hash_table): Reorder.  Add
	text_index_section and data_index_section.
	(struct elf_backend_data): Add elf_backend_init_index_section.
	(_bfd_elf_init_1_index_section): Declare.
	(_bfd_elf_init_2_index_sections): Declare.
	* elfxx-target.h (elf_backend_init_index_section): Define.
	(elfNN_bed): Init new field.
	* elflink.c (_bfd_elf_link_omit_section_dynsym): Keep first tls
	section and text_index_section plus data_index_section.
	(_bfd_elf_link_renumber_dynsyms): Clear dynindx on omitted sections.
	(_bfd_elf_init_1_index_section): New function.
	(_bfd_elf_init_2_index_sections): New function.
	(bfd_elf_size_dynsym_hash_dynstr): Call elf_backend_init_index_section.
	(elf_link_input_bfd): When emitting relocs, use text_index_section
	and data_index_section for removed sections.
	* elf-m10300.c (elf_backend_omit_section_dynsym): Define.
	* elf32-i386.c: Likewise.
	* elf32-m32r.c: Likewise.
	* elf32-sh.c: Likewise.
	* elf32-xstormy16.c: Likewise.
	* elf32-xtensa.c: Likewise.
	* elf64-alpha.c: Likewise.
	* elf64-hppa.c: Likewise.
	* elf64-mmix.c: Likewise.
	* elf64-sh64.c: Likewise.
	* elfxx-ia64.c: Likewise.
	* elf32-score.c: Likewise.  Formatting.
	(score_elf_create_dynamic_relocation): Remove code copied from mips.
	Don't use section syms in dynamic relocs.  Remove unused param.
	(score_elf_final_link_relocate): Remove unused param.
	* elf32-arm.c (elf32_arm_final_link_relocate): Use text_index_section
	and data_index_section sym for relocs against sections with no dynamic
	section sym.
	(elf_backend_init_index_section): Define.
	* elf32-cris.c: Similarly.
	* elf32-hppa.c: Similarly.
	* elf32-i370.c: Similarly.
	* elf32-m68k.c: Similarly.
	* elf32-mips.c: Similarly.
	* elf32-ppc.c: Similarly.
	* elf32-s390.c: Similarly.
	* elf32-sparc.c: Similarly.
	* elf32-vax.c: Similarly.
	* elf64-mips.c: Similarly.
	* elf64-ppc.c: Similarly.
	* elf64-s390.c: Similarly.
	* elf64-sparc.c: Similarly.
	* elf64-x86-64.c: Similarly.
	* elfn32-mips.c: Similarly.
	* elfxx-mips.c: Similarly.
	* elfxx-sparc.c: Similarly.
	* linker.c (fix_syms): Base symbols in removed sections on
	previous section in preference to using absolute section.

ld/
	* ldlang.c (strip_excluded_output_sections): Do strip sections
	that define syms, but don't ignore them.
	* ld.texinfo (Output Section Discarding): Revise.
	* emultempl/armcoff.em (gld${EMULATION_NAME}_finish): Always call
	finish_default.

ld/testsuite/
	* ld-arm/mixed-app.sym, ld-cris/ldsym1.d, ld-cris/libdso-12.d,
	ld-cris/v32-ba-1.d, ld-elf/orphan.d, ld-elf/orphan2.d,
	ld-i386/tlsbin.rd, ld-i386/tlsbindesc.rd, ld-i386/tlsdesc.rd,
	ld-i386/tlsdesc.sd, ld-i386/tlsgdesc.rd, ld-i386/tlsnopic.rd,
	ld-i386/tlspic.rd, ld-ia64/tlspic.rd, ld-mips-elf/eh-frame1-n32.d,
	ld-mips-elf/eh-frame1-n64.d, ld-mips-elf/eh-frame2-n32.d,
	ld-mips-elf/eh-frame2-n64.d, ld-mips-elf/mips-elf.exp,
	ld-mips-elf/rel32-n32.d, ld-mips-elf/rel32-o32.d, ld-mips-elf/rel64.d,
	ld-mips-elf/tls-multi-got-1.got, ld-mips-elf/tls-multi-got-1.r,
	ld-mips-elf/tlsdyn-o32-1.d, ld-mips-elf/tlsdyn-o32-1.got,
	ld-mips-elf/tlsdyn-o32-2.d, ld-mips-elf/tlsdyn-o32-2.got,
	ld-mips-elf/tlsdyn-o32-3.d, ld-mips-elf/tlsdyn-o32-3.got,
	ld-mips-elf/tlsdyn-o32.d, ld-mips-elf/tlsdyn-o32.got,
	ld-mips-elf/tlslib-o32-hidden.got, ld-mips-elf/tlslib-o32-ver.got,
	ld-mips-elf/tlslib-o32.got, ld-mmix/bpo-10.d, ld-powerpc/tlsso.g,
	ld-powerpc/tlsso.r, ld-powerpc/tlsso32.d, ld-powerpc/tlsso32.g,
	ld-powerpc/tlsso32.r, ld-powerpc/tlstocso.g, ld-powerpc/tlstocso.r,
	ld-s390/tlspic.rd, ld-s390/tlspic_64.rd, ld-scripts/empty-address-1.d,
	ld-scripts/empty-address-3c.d, ld-scripts/empty-orphan.t,
	ld-sh/shared-1.d, ld-sh/tlspic-2.d, ld-sparc/tlssunbin32.rd,
	ld-sparc/tlssunbin64.rd, ld-sparc/tlssunpic32.rd,
	ld-sparc/tlssunpic64.rd, ld-x86-64/tlsdesc.pd, ld-x86-64/tlsdesc.rd,
	ld-x86-64/tlspic.rd: Update for section sym changes.

Index: bfd/elf-bfd.h
===================================================================
RCS file: /cvs/src/src/bfd/elf-bfd.h,v
retrieving revision 1.215
diff -u -p -r1.215 elf-bfd.h
--- bfd/elf-bfd.h	3 Oct 2006 13:15:39 -0000	1.215
+++ bfd/elf-bfd.h	16 Oct 2006 23:43:38 -0000
@@ -345,6 +345,10 @@ struct elf_link_hash_table
      when linking against or generating a shared object.  */
   bfd_boolean dynamic_sections_created;
 
+  /* True if this target has relocatable executables, so needs dynamic
+     section symbols.  */
+  bfd_boolean is_relocatable_executable;
+
   /* The BFD used to hold special sections created by the linker.
      This will be the first BFD found which requires these sections to
      be created.  */
@@ -378,6 +382,12 @@ struct elf_link_hash_table
      included in the link.  */
   struct bfd_link_needed_list *needed;
 
+  /* Sections in the output bfd that provides a section symbol
+     to be used by relocations emitted against local symbols.
+     Most targets will not use data_index_section.  */
+  asection *text_index_section;
+  asection *data_index_section;
+
   /* The _GLOBAL_OFFSET_TABLE_ symbol.  */
   struct elf_link_hash_entry *hgot;
 
@@ -406,10 +416,6 @@ struct elf_link_hash_table
 
   /* A linked list of BFD's loaded in the link.  */
   struct elf_link_loaded_list *loaded;
-
-  /* True if this target has relocatable executables, so needs dynamic
-     section symbols.  */
-  bfd_boolean is_relocatable_executable;
 };
 
 /* Look up an entry in an ELF linker hash table.  */
@@ -766,6 +772,11 @@ struct elf_backend_data
   bfd_boolean (*elf_backend_size_dynamic_sections)
     (bfd *output_bfd, struct bfd_link_info *info);
 
+  /* Set TEXT_INDEX_SECTION and DATA_INDEX_SECTION, the output sections
+     we keep to use as a base for relocs and symbols.  */
+  void (*elf_backend_init_index_section)
+    (bfd *output_bfd, struct bfd_link_info *info);
+
   /* The RELOCATE_SECTION function is called by the ELF backend linker
      to handle the relocations for a section.
 
@@ -1697,6 +1708,10 @@ extern bfd_boolean _bfd_elf_create_got_s
   (bfd *, struct bfd_link_info *);
 extern struct elf_link_hash_entry *_bfd_elf_define_linkage_sym
   (bfd *, struct bfd_link_info *, asection *, const char *);
+extern void _bfd_elf_init_1_index_section
+  (bfd *, struct bfd_link_info *);
+extern void _bfd_elf_init_2_index_sections
+  (bfd *, struct bfd_link_info *);
 
 extern bfd_boolean _bfd_elfcore_make_pseudosection
   (bfd *, char *, size_t, ufile_ptr);
Index: bfd/elfxx-target.h
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-target.h,v
retrieving revision 1.98
diff -u -p -r1.98 elfxx-target.h
--- bfd/elfxx-target.h	28 Sep 2006 13:27:31 -0000	1.98
+++ bfd/elfxx-target.h	16 Oct 2006 23:44:51 -0000
@@ -381,6 +381,10 @@
 #ifndef elf_backend_size_dynamic_sections
 #define elf_backend_size_dynamic_sections 0
 #endif
+#ifndef elf_backend_init_index_section
+#define elf_backend_init_index_section \
+ ((void (*) (bfd *, struct bfd_link_info *)) bfd_void)
+#endif
 #ifndef elf_backend_relocate_section
 #define elf_backend_relocate_section	0
 #endif
@@ -603,6 +607,7 @@ static struct elf_backend_data elfNN_bed
   elf_backend_adjust_dynamic_symbol,
   elf_backend_always_size_sections,
   elf_backend_size_dynamic_sections,
+  elf_backend_init_index_section,
   elf_backend_relocate_section,
   elf_backend_finish_dynamic_symbol,
   elf_backend_finish_dynamic_sections,
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.233
diff -u -p -r1.233 elflink.c
--- bfd/elflink.c	2 Oct 2006 22:52:19 -0000	1.233
+++ bfd/elflink.c	16 Oct 2006 23:44:39 -0000
@@ -712,6 +712,8 @@ _bfd_elf_link_omit_section_dynsym (bfd *
 				   struct bfd_link_info *info,
 				   asection *p)
 {
+  struct elf_link_hash_table *htab;
+
   switch (elf_section_data (p)->this_hdr.sh_type)
     {
     case SHT_PROGBITS:
@@ -719,15 +721,21 @@ _bfd_elf_link_omit_section_dynsym (bfd *
       /* If sh_type is yet undecided, assume it could be
 	 SHT_PROGBITS/SHT_NOBITS.  */
     case SHT_NULL:
+      htab = elf_hash_table (info);
+      if (p == htab->tls_sec)
+	return FALSE;
+
+      if (htab->text_index_section != NULL)
+	return p != htab->text_index_section && p != htab->data_index_section;
+
       if (strcmp (p->name, ".got") == 0
 	  || strcmp (p->name, ".got.plt") == 0
 	  || strcmp (p->name, ".plt") == 0)
 	{
 	  asection *ip;
-	  bfd *dynobj = elf_hash_table (info)->dynobj;
 
-	  if (dynobj != NULL
-	      && (ip = bfd_get_section_by_name (dynobj, p->name)) != NULL
+	  if (htab->dynobj != NULL
+	      && (ip = bfd_get_section_by_name (htab->dynobj, p->name)) != NULL
 	      && (ip->flags & SEC_LINKER_CREATED)
 	      && ip->output_section == p)
 	    return TRUE;
@@ -763,6 +771,8 @@ _bfd_elf_link_renumber_dynsyms (bfd *out
 	    && (p->flags & SEC_ALLOC) != 0
 	    && !(*bed->elf_backend_omit_section_dynsym) (output_bfd, info, p))
 	  elf_section_data (p)->dynindx = ++dynsymcount;
+	else
+	  elf_section_data (p)->dynindx = 0;
     }
   *section_sym_count = dynsymcount;
 
@@ -5932,16 +5942,65 @@ bfd_elf_size_dynamic_sections (bfd *outp
   return TRUE;
 }
 
+/* Find the first non-excluded output section.  We'll use its
+   section symbol for some emitted relocs.  */
+void
+_bfd_elf_init_1_index_section (bfd *output_bfd, struct bfd_link_info *info)
+{
+  asection *s;
+
+  for (s = output_bfd->sections; s != NULL; s = s->next)
+    if ((s->flags & (SEC_EXCLUDE | SEC_ALLOC)) == SEC_ALLOC
+	&& !_bfd_elf_link_omit_section_dynsym (output_bfd, info, s))
+      {
+	elf_hash_table (info)->text_index_section = s;
+	break;
+      }
+}
+
+/* Find two non-excluded output sections, one for code, one for data.
+   We'll use their section symbols for some emitted relocs.  */
+void
+_bfd_elf_init_2_index_sections (bfd *output_bfd, struct bfd_link_info *info)
+{
+  asection *s;
+
+  for (s = output_bfd->sections; s != NULL; s = s->next)
+    if (((s->flags & (SEC_EXCLUDE | SEC_ALLOC | SEC_READONLY))
+	 == (SEC_ALLOC | SEC_READONLY))
+	&& !_bfd_elf_link_omit_section_dynsym (output_bfd, info, s))
+      {
+	elf_hash_table (info)->text_index_section = s;
+	break;
+      }
+
+  for (s = output_bfd->sections; s != NULL; s = s->next)
+    if (((s->flags & (SEC_EXCLUDE | SEC_ALLOC | SEC_READONLY)) == SEC_ALLOC)
+	&& !_bfd_elf_link_omit_section_dynsym (output_bfd, info, s))
+      {
+	elf_hash_table (info)->data_index_section = s;
+	break;
+      }
+
+  if (elf_hash_table (info)->text_index_section == NULL)
+    elf_hash_table (info)->text_index_section
+      = elf_hash_table (info)->data_index_section;
+}
+
 bfd_boolean
 bfd_elf_size_dynsym_hash_dynstr (bfd *output_bfd, struct bfd_link_info *info)
 {
+  const struct elf_backend_data *bed;
+
   if (!is_elf_hash_table (info->hash))
     return TRUE;
 
+  bed = get_elf_backend_data (output_bfd);
+  (*bed->elf_backend_init_index_section) (output_bfd, info);
+
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       bfd *dynobj;
-      const struct elf_backend_data *bed;
       asection *s;
       bfd_size_type dynsymcount;
       unsigned long section_sym_count;
@@ -5980,7 +6039,6 @@ bfd_elf_size_dynsym_hash_dynstr (bfd *ou
 	 section as we went along in elf_link_add_object_symbols.  */
       s = bfd_get_section_by_name (dynobj, ".dynsym");
       BFD_ASSERT (s != NULL);
-      bed = get_elf_backend_data (output_bfd);
       s->size = dynsymcount * bed->s->sizeof_sym;
 
       if (dynsymcount != 0)
@@ -7769,6 +7827,24 @@ elf_link_input_bfd (struct elf_final_lin
 			  if (!bfd_is_abs_section (osec))
 			    {
 			      r_symndx = osec->target_index;
+			      if (r_symndx == 0)
+				{
+				  struct elf_link_hash_table *htab;
+				  asection *oi;
+
+				  htab = elf_hash_table (finfo->info);
+				  oi = htab->text_index_section;
+				  if ((osec->flags & SEC_READONLY) == 0
+				      && htab->data_index_section != NULL)
+				    oi = htab->data_index_section;
+
+				  if (oi != NULL)
+				    {
+				      irela->r_addend += osec->vma - oi->vma;
+				      r_symndx = oi->target_index;
+				    }
+				}
+
 			      BFD_ASSERT (r_symndx != 0);
 			    }
 			}
Index: bfd/elf-m10300.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-m10300.c,v
retrieving revision 1.76
diff -u -p -r1.76 elf-m10300.c
--- bfd/elf-m10300.c	28 Sep 2006 13:27:32 -0000	1.76
+++ bfd/elf-m10300.c	16 Oct 2006 23:43:41 -0000
@@ -4756,6 +4756,8 @@ _bfd_mn10300_elf_reloc_type_class (const
   _bfd_mn10300_elf_adjust_dynamic_symbol
 #define elf_backend_size_dynamic_sections \
   _bfd_mn10300_elf_size_dynamic_sections
+#define elf_backend_omit_section_dynsym \
+  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
 #define elf_backend_finish_dynamic_symbol \
   _bfd_mn10300_elf_finish_dynamic_symbol
 #define elf_backend_finish_dynamic_sections \
Index: bfd/elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.166
diff -u -p -r1.166 elf32-i386.c
--- bfd/elf32-i386.c	28 Sep 2006 13:27:32 -0000	1.166
+++ bfd/elf32-i386.c	16 Oct 2006 23:43:53 -0000
@@ -3872,6 +3872,8 @@ elf_i386_hash_symbol (struct elf_link_ha
 #define elf_backend_relocate_section	      elf_i386_relocate_section
 #define elf_backend_size_dynamic_sections     elf_i386_size_dynamic_sections
 #define elf_backend_always_size_sections      elf_i386_always_size_sections
+#define elf_backend_omit_section_dynsym \
+  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
 #define elf_backend_plt_sym_val		      elf_i386_plt_sym_val
 #define elf_backend_hash_symbol		      elf_i386_hash_symbol
 
Index: bfd/elf32-m32r.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m32r.c,v
retrieving revision 1.82
diff -u -p -r1.82 elf32-m32r.c
--- bfd/elf32-m32r.c	28 Sep 2006 13:27:32 -0000	1.82
+++ bfd/elf32-m32r.c	16 Oct 2006 23:43:55 -0000
@@ -4141,6 +4141,8 @@ m32r_elf_reloc_type_class (const Elf_Int
 #define elf_backend_create_dynamic_sections     m32r_elf_create_dynamic_sections
 #define bfd_elf32_bfd_link_hash_table_create    m32r_elf_link_hash_table_create
 #define elf_backend_size_dynamic_sections       m32r_elf_size_dynamic_sections
+#define elf_backend_omit_section_dynsym \
+  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
 #define elf_backend_finish_dynamic_sections     m32r_elf_finish_dynamic_sections
 #define elf_backend_adjust_dynamic_symbol       m32r_elf_adjust_dynamic_symbol
 #define elf_backend_finish_dynamic_symbol       m32r_elf_finish_dynamic_symbol
Index: bfd/elf32-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sh.c,v
retrieving revision 1.143
diff -u -p -r1.143 elf32-sh.c
--- bfd/elf32-sh.c	28 Sep 2006 13:27:32 -0000	1.143
+++ bfd/elf32-sh.c	16 Oct 2006 23:44:08 -0000
@@ -6028,6 +6028,8 @@ sh_elf_plt_sym_val (bfd_vma i, const ase
 					sh_elf_always_size_sections
 #define elf_backend_size_dynamic_sections \
 					sh_elf_size_dynamic_sections
+#define elf_backend_omit_section_dynsym \
+  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
 #define elf_backend_finish_dynamic_symbol \
 					sh_elf_finish_dynamic_symbol
 #define elf_backend_finish_dynamic_sections \
Index: bfd/elf32-xstormy16.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xstormy16.c,v
retrieving revision 1.35
diff -u -p -r1.35 elf32-xstormy16.c
--- bfd/elf32-xstormy16.c	28 Sep 2006 13:27:33 -0000	1.35
+++ bfd/elf32-xstormy16.c	16 Oct 2006 23:44:09 -0000
@@ -999,6 +999,8 @@ xstormy16_elf_gc_mark_hook (asection *se
 #define elf_backend_check_relocs                xstormy16_elf_check_relocs
 #define elf_backend_always_size_sections \
   xstormy16_elf_always_size_sections
+#define elf_backend_omit_section_dynsym \
+  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
 #define elf_backend_finish_dynamic_sections \
   xstormy16_elf_finish_dynamic_sections
 
Index: bfd/elf32-xtensa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xtensa.c,v
retrieving revision 1.73
diff -u -p -r1.73 elf32-xtensa.c
--- bfd/elf32-xtensa.c	12 Oct 2006 21:56:18 -0000	1.73
+++ bfd/elf32-xtensa.c	16 Oct 2006 23:44:14 -0000
@@ -9844,6 +9844,8 @@ static const struct bfd_elf_special_sect
 #define elf_backend_reloc_type_class	     elf_xtensa_reloc_type_class
 #define elf_backend_relocate_section	     elf_xtensa_relocate_section
 #define elf_backend_size_dynamic_sections    elf_xtensa_size_dynamic_sections
+#define elf_backend_omit_section_dynsym \
+  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
 #define elf_backend_special_sections	     elf_xtensa_special_sections
 #define elf_backend_action_discarded	     elf_xtensa_action_discarded
 
Index: bfd/elf64-alpha.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-alpha.c,v
retrieving revision 1.153
diff -u -p -r1.153 elf64-alpha.c
--- bfd/elf64-alpha.c	16 Sep 2006 18:12:14 -0000	1.153
+++ bfd/elf64-alpha.c	16 Oct 2006 23:44:17 -0000
@@ -5275,6 +5275,8 @@ static const struct elf_size_info alpha_
   elf64_alpha_always_size_sections
 #define elf_backend_size_dynamic_sections \
   elf64_alpha_size_dynamic_sections
+#define elf_backend_omit_section_dynsym \
+  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
 #define elf_backend_relocate_section \
   elf64_alpha_relocate_section
 #define elf_backend_finish_dynamic_symbol \
Index: bfd/elf64-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-hppa.c,v
retrieving revision 1.74
diff -u -p -r1.74 elf64-hppa.c
--- bfd/elf64-hppa.c	16 Sep 2006 18:12:14 -0000	1.74
+++ bfd/elf64-hppa.c	16 Oct 2006 23:44:19 -0000
@@ -2820,6 +2820,8 @@ const struct elf_size_info hppa64_elf_si
 					elf64_hppa_create_dynamic_sections
 #define elf_backend_post_process_headers	elf64_hppa_post_process_headers
 
+#define elf_backend_omit_section_dynsym \
+  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
 #define elf_backend_adjust_dynamic_symbol \
 					elf64_hppa_adjust_dynamic_symbol
 
Index: bfd/elf64-mmix.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-mmix.c,v
retrieving revision 1.50
diff -u -p -r1.50 elf64-mmix.c
--- bfd/elf64-mmix.c	28 Sep 2006 13:27:32 -0000	1.50
+++ bfd/elf64-mmix.c	16 Oct 2006 23:44:22 -0000
@@ -2916,6 +2916,8 @@ mmix_elf_relax_section (abfd, sec, link_
 
 #define elf_backend_check_relocs	mmix_elf_check_relocs
 #define elf_backend_symbol_processing	mmix_elf_symbol_processing
+#define elf_backend_omit_section_dynsym \
+  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
 
 #define bfd_elf64_bfd_is_local_label_name \
 	mmix_elf_is_local_label_name
Index: bfd/elf64-sh64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-sh64.c,v
retrieving revision 1.69
diff -u -p -r1.69 elf64-sh64.c
--- bfd/elf64-sh64.c	28 Sep 2006 13:27:33 -0000	1.69
+++ bfd/elf64-sh64.c	16 Oct 2006 23:44:30 -0000
@@ -4094,6 +4094,8 @@ static const struct bfd_elf_special_sect
 					sh64_elf64_adjust_dynamic_symbol
 #define elf_backend_size_dynamic_sections \
 					sh64_elf64_size_dynamic_sections
+#define elf_backend_omit_section_dynsym \
+  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
 #define elf_backend_finish_dynamic_symbol \
 					sh64_elf64_finish_dynamic_symbol
 #define elf_backend_finish_dynamic_sections \
Index: bfd/elfxx-ia64.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-ia64.c,v
retrieving revision 1.191
diff -u -p -r1.191 elfxx-ia64.c
--- bfd/elfxx-ia64.c	16 Oct 2006 17:21:44 -0000	1.191
+++ bfd/elfxx-ia64.c	16 Oct 2006 23:44:42 -0000
@@ -5762,6 +5762,8 @@ elfNN_hpux_backend_symbol_processing (bf
 	elfNN_ia64_adjust_dynamic_symbol
 #define elf_backend_size_dynamic_sections \
 	elfNN_ia64_size_dynamic_sections
+#define elf_backend_omit_section_dynsym \
+  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
 #define elf_backend_relocate_section \
 	elfNN_ia64_relocate_section
 #define elf_backend_finish_dynamic_symbol \
Index: bfd/elf32-score.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-score.c,v
retrieving revision 1.3
diff -u -p -r1.3 elf32-score.c
--- bfd/elf32-score.c	28 Sep 2006 13:27:32 -0000	1.3
+++ bfd/elf32-score.c	16 Oct 2006 23:44:05 -0000
@@ -1184,7 +1184,7 @@ score_elf_create_dynamic_relocation (bfd
 				     struct bfd_link_info *info,
 				     const Elf_Internal_Rela *rel,
 				     struct score_elf_link_hash_entry *h,
-				     asection *sec, bfd_vma symbol,
+				     bfd_vma symbol,
 				     bfd_vma *addendp, asection *input_section)
 {
   Elf_Internal_Rela outrel[3];
@@ -1238,35 +1238,7 @@ score_elf_create_dynamic_relocation (bfd
     }
   else
     {
-      if (sec != NULL && bfd_is_abs_section (sec))
-	indx = 0;
-      else if (sec == NULL || sec->owner == NULL)
-	{
-	  bfd_set_error (bfd_error_bad_value);
-	  return FALSE;
-	}
-      else
-	{
-	  indx = elf_section_data (sec->output_section)->dynindx;
-	  if (indx == 0)
-	    abort ();
-	}
-
-      /* Instead of generating a relocation using the section
-	 symbol, we may as well make it a fully relative
-	 relocation.  We want to avoid generating relocations to
-	 local symbols because we used to generate them
-	 incorrectly, without adding the original symbol value,
-	 which is mandated by the ABI for section symbols.  In
-	 order to give dynamic loaders and applications time to
-	 phase out the incorrect use, we refrain from emitting
-	 section-relative relocations.  It's not like they're
-	 useful, after all.  This should be a bit more efficient
-	 as well.  */
-      /* ??? Although this behavior is compatible with glibc's ld.so,
-	 the ABI says that relocations against STN_UNDEF should have
-	 a symbol value of 0.  Irix rld honors this, so relocations
-	 against STN_UNDEF have no effect.  */
+      indx = 0;
       defined_p = TRUE;
     }
 
@@ -1868,7 +1840,6 @@ score_elf_final_link_relocate (reloc_how
 			       Elf_Internal_Rela *relocs,
 			       bfd_vma symbol,
 			       struct bfd_link_info *info,
-			       asection *sym_sec,
 			       const char *sym_name ATTRIBUTE_UNUSED,
 			       int sym_flags ATTRIBUTE_UNUSED,
 			       struct score_elf_link_hash_entry *h,
@@ -2029,7 +2000,7 @@ score_elf_final_link_relocate (reloc_how
              to the dynamic linker.  */
 	  value = addend;
 	  if (!score_elf_create_dynamic_relocation (output_bfd, info, rel, h,
-						    sym_sec, symbol, &value,
+						    symbol, &value,
 						    input_section))
 	    return bfd_reloc_undefined;
 	}
@@ -2438,7 +2409,7 @@ _bfd_score_elf_relocate_section (bfd *ou
 
       r = score_elf_final_link_relocate (howto, input_bfd, output_bfd,
                                          input_section, contents, rel, relocs,
-                                         relocation, info, sec, name,
+                                         relocation, info, name,
                                          (h ? ELF_ST_TYPE ((unsigned int)h->root.root.type) :
 					 ELF_ST_TYPE ((unsigned int)sym->st_info)), h, local_sections,
                                          gp_disp_p);
@@ -3825,41 +3796,52 @@ elf32_score_new_section_hook (bfd *abfd,
 #define ELF_MACHINE_CODE                EM_SCORE
 #define ELF_MAXPAGESIZE                 0x8000
 
-#define elf_info_to_howto                             0
-#define elf_info_to_howto_rel                         _bfd_score_info_to_howto
-#define elf_backend_relocate_section                  _bfd_score_elf_relocate_section
-#define elf_backend_check_relocs                      _bfd_score_elf_check_relocs
-#define elf_backend_add_symbol_hook                   _bfd_score_elf_add_symbol_hook
-#define elf_backend_symbol_processing                 _bfd_score_elf_symbol_processing
-#define elf_backend_link_output_symbol_hook           _bfd_score_elf_link_output_symbol_hook
-#define elf_backend_section_from_bfd_section          _bfd_score_elf_section_from_bfd_section
-#define elf_backend_adjust_dynamic_symbol             _bfd_score_elf_adjust_dynamic_symbol
-#define elf_backend_always_size_sections              _bfd_score_elf_always_size_sections
-#define elf_backend_size_dynamic_sections             _bfd_score_elf_size_dynamic_sections
-#define elf_backend_create_dynamic_sections           _bfd_score_elf_create_dynamic_sections
-#define elf_backend_finish_dynamic_symbol             _bfd_score_elf_finish_dynamic_symbol
-#define elf_backend_finish_dynamic_sections           _bfd_score_elf_finish_dynamic_sections
-#define elf_backend_fake_sections                     _bfd_score_elf_fake_sections
-#define elf_backend_section_processing                _bfd_score_elf_section_processing
-#define elf_backend_write_section                     _bfd_score_elf_write_section
-#define elf_backend_copy_indirect_symbol              _bfd_score_elf_copy_indirect_symbol
-#define elf_backend_hide_symbol                       _bfd_score_elf_hide_symbol
-#define elf_backend_discard_info                      _bfd_score_elf_discard_info
-#define elf_backend_ignore_discarded_relocs           _bfd_score_elf_ignore_discarded_relocs
-#define elf_backend_gc_mark_hook                      _bfd_score_elf_gc_mark_hook
-#define elf_backend_grok_prstatus                     _bfd_score_elf_grok_prstatus
-#define elf_backend_grok_psinfo                       _bfd_score_elf_grok_psinfo
-#define elf_backend_can_gc_sections                   1
-#define elf_backend_want_plt_sym                      0
-#define elf_backend_got_header_size                   (4 * SCORE_RESERVED_GOTNO)
-#define elf_backend_plt_header_size                   0
-#define elf_backend_collect                           TRUE
-#define elf_backend_type_change_ok                    TRUE
-
-#define bfd_elf32_bfd_reloc_type_lookup               elf32_score_reloc_type_lookup
-#define bfd_elf32_bfd_link_hash_table_create          elf32_score_link_hash_table_create
-#define bfd_elf32_bfd_print_private_bfd_data          elf32_score_print_private_bfd_data
-#define bfd_elf32_bfd_merge_private_bfd_data          elf32_score_merge_private_bfd_data
-#define bfd_elf32_new_section_hook                    elf32_score_new_section_hook
+#define elf_info_to_howto               0
+#define elf_info_to_howto_rel           _bfd_score_info_to_howto
+#define elf_backend_relocate_section    _bfd_score_elf_relocate_section
+#define elf_backend_check_relocs        _bfd_score_elf_check_relocs
+#define elf_backend_add_symbol_hook     _bfd_score_elf_add_symbol_hook
+#define elf_backend_symbol_processing   _bfd_score_elf_symbol_processing
+#define elf_backend_link_output_symbol_hook \
+  _bfd_score_elf_link_output_symbol_hook
+#define elf_backend_section_from_bfd_section \
+  _bfd_score_elf_section_from_bfd_section
+#define elf_backend_adjust_dynamic_symbol \
+  _bfd_score_elf_adjust_dynamic_symbol
+#define elf_backend_always_size_sections \
+  _bfd_score_elf_always_size_sections
+#define elf_backend_size_dynamic_sections \
+  _bfd_score_elf_size_dynamic_sections
+#define elf_backend_omit_section_dynsym \
+  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
+#define elf_backend_create_dynamic_sections \
+  _bfd_score_elf_create_dynamic_sections
+#define elf_backend_finish_dynamic_symbol \
+  _bfd_score_elf_finish_dynamic_symbol
+#define elf_backend_finish_dynamic_sections \
+  _bfd_score_elf_finish_dynamic_sections
+#define elf_backend_fake_sections         _bfd_score_elf_fake_sections
+#define elf_backend_section_processing    _bfd_score_elf_section_processing
+#define elf_backend_write_section         _bfd_score_elf_write_section
+#define elf_backend_copy_indirect_symbol  _bfd_score_elf_copy_indirect_symbol
+#define elf_backend_hide_symbol           _bfd_score_elf_hide_symbol
+#define elf_backend_discard_info          _bfd_score_elf_discard_info
+#define elf_backend_ignore_discarded_relocs \
+  _bfd_score_elf_ignore_discarded_relocs
+#define elf_backend_gc_mark_hook          _bfd_score_elf_gc_mark_hook
+#define elf_backend_grok_prstatus         _bfd_score_elf_grok_prstatus
+#define elf_backend_grok_psinfo           _bfd_score_elf_grok_psinfo
+#define elf_backend_can_gc_sections       1
+#define elf_backend_want_plt_sym          0
+#define elf_backend_got_header_size       (4 * SCORE_RESERVED_GOTNO)
+#define elf_backend_plt_header_size       0
+#define elf_backend_collect               TRUE
+#define elf_backend_type_change_ok        TRUE
+
+#define bfd_elf32_bfd_reloc_type_lookup      elf32_score_reloc_type_lookup
+#define bfd_elf32_bfd_link_hash_table_create elf32_score_link_hash_table_create
+#define bfd_elf32_bfd_print_private_bfd_data elf32_score_print_private_bfd_data
+#define bfd_elf32_bfd_merge_private_bfd_data elf32_score_merge_private_bfd_data
+#define bfd_elf32_new_section_hook           elf32_score_new_section_hook
 
 #include "elf32-target.h"
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.92
diff -u -p -r1.92 elf32-arm.c
--- bfd/elf32-arm.c	28 Sep 2006 13:27:32 -0000	1.92
+++ bfd/elf32-arm.c	16 Oct 2006 23:43:46 -0000
@@ -3731,6 +3739,8 @@ elf32_arm_final_link_relocate (reloc_how
 		value |= 1;
 	      if (globals->symbian_p)
 		{
+		  asection *osec;
+
 		  /* On Symbian OS, the data segment and text segement
 		     can be relocated independently.  Therefore, we
 		     must indicate the segment to which this
@@ -3738,11 +3748,27 @@ elf32_arm_final_link_relocate (reloc_how
 		     use any symbol in the right segment; we just use
 		     the section symbol as it is convenient.  (We
 		     cannot use the symbol given by "h" directly as it
-		     will not appear in the dynamic symbol table.)  */
+		     will not appear in the dynamic symbol table.)
+
+		     Note that the dynamic linker ignores the section
+		     symbol value, so we don't subtract osec->vma
+		     from the emitted reloc addend.  */
 		  if (sym_sec)
-		    symbol = elf_section_data (sym_sec->output_section)->dynindx;
+		    osec = sym_sec->output_section;
 		  else
-		    symbol = elf_section_data (input_section->output_section)->dynindx;
+		    osec = input_section->output_section;
+		  symbol = elf_section_data (osec)->dynindx;
+		  if (symbol == 0)
+		    {
+		      struct elf_link_hash_table *htab = elf_hash_table (info);
+
+		      if ((osec->flags & SEC_READONLY) == 0
+			  && htab->data_index_section != NULL)
+			osec = htab->data_index_section;
+		      else
+			osec = htab->text_index_section;
+		      symbol = elf_section_data (osec)->dynindx;
+		    }
 		  BFD_ASSERT (symbol != 0);
 		}
 	      else
@@ -9494,6 +9521,7 @@ const struct elf_size_info elf32_arm_siz
 #define elf_backend_finish_dynamic_sections	elf32_arm_finish_dynamic_sections
 #define elf_backend_link_output_symbol_hook	elf32_arm_output_symbol_hook
 #define elf_backend_size_dynamic_sections	elf32_arm_size_dynamic_sections
+#define elf_backend_init_index_section		_bfd_elf_init_2_index_sections
 #define elf_backend_post_process_headers	elf32_arm_post_process_headers
 #define elf_backend_reloc_type_class		elf32_arm_reloc_type_class
 #define elf_backend_object_p			elf32_arm_object_p
Index: bfd/elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.75
diff -u -p -r1.75 elf32-cris.c
--- bfd/elf32-cris.c	28 Sep 2006 13:27:32 -0000	1.75
+++ bfd/elf32-cris.c	16 Oct 2006 23:43:47 -0000
@@ -1430,11 +1430,12 @@ cris_elf_relocate_section (output_bfd, i
 		}
 	      else
 		{
+		  outrel.r_addend = relocation + rel->r_addend;
+
 		  if (r_type == R_CRIS_32)
 		    {
 		      relocate = TRUE;
 		      outrel.r_info = ELF32_R_INFO (0, R_CRIS_RELATIVE);
-		      outrel.r_addend = relocation + rel->r_addend;
 		    }
 		  else
 		    {
@@ -1451,13 +1452,24 @@ cris_elf_relocate_section (output_bfd, i
 			{
 			  asection *osec;
 
+			  /* We are turning this relocation into one
+			     against a section symbol.  It would be
+			     proper to subtract the symbol's value,
+			     osec->vma, from the emitted reloc addend,
+			     but ld.so expects buggy relocs.  */
 			  osec = sec->output_section;
 			  indx = elf_section_data (osec)->dynindx;
-			  BFD_ASSERT (indx > 0);
+			  if (indx == 0)
+			    {
+			      struct elf_cris_link_hash_table *htab;
+			      htab = elf_cris_hash_table (info);
+			      osec = htab->root.text_index_section;
+			      indx = elf_section_data (osec)->dynindx;
+			    }
+			  BFD_ASSERT (indx != 0);
 			}
 
 		      outrel.r_info = ELF32_R_INFO (indx, r_type);
-		      outrel.r_addend = relocation + rel->r_addend;
 		    }
 		}
 
@@ -3390,6 +3402,7 @@ elf_cris_reloc_type_class (rela)
 	elf_cris_adjust_dynamic_symbol
 #define elf_backend_size_dynamic_sections \
 	elf_cris_size_dynamic_sections
+#define elf_backend_init_index_section		_bfd_elf_init_1_index_section
 #define elf_backend_finish_dynamic_symbol \
 	elf_cris_finish_dynamic_symbol
 #define elf_backend_finish_dynamic_sections \
Index: bfd/elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.147
diff -u -p -r1.147 elf32-hppa.c
--- bfd/elf32-hppa.c	28 Sep 2006 13:27:32 -0000	1.147
+++ bfd/elf32-hppa.c	16 Oct 2006 23:43:50 -0000
@@ -4024,17 +4024,22 @@ elf32_hppa_relocate_section (bfd *output
 		      && sym_sec->output_section != NULL
 		      && ! bfd_is_abs_section (sym_sec))
 		    {
-		      /* Skip this relocation if the output section has
-			 been discarded.  */
-		      if (bfd_is_abs_section (sym_sec->output_section))
-			break;
+		      asection *osec;
+
+		      osec = sym_sec->output_section;
+		      indx = elf_section_data (osec)->dynindx;
+		      if (indx == 0)
+			{
+			  osec = htab->etab.text_index_section;
+			  indx = elf_section_data (osec)->dynindx;
+			}
+		      BFD_ASSERT (indx != 0);
 
-		      indx = elf_section_data (sym_sec->output_section)->dynindx;
 		      /* We are turning this relocation into one
 			 against a section symbol, so subtract out the
 			 output section's address but not the offset
 			 of the input section in the output section.  */
-		      outrel.r_addend -= sym_sec->output_section->vma;
+		      outrel.r_addend -= osec->vma;
 		    }
 
 		  outrel.r_info = ELF32_R_INFO (indx, r_type);
@@ -4642,6 +4647,7 @@ elf32_hppa_elf_get_symbol_type (Elf_Inte
 #define elf_backend_finish_dynamic_symbol    elf32_hppa_finish_dynamic_symbol
 #define elf_backend_finish_dynamic_sections  elf32_hppa_finish_dynamic_sections
 #define elf_backend_size_dynamic_sections    elf32_hppa_size_dynamic_sections
+#define elf_backend_init_index_section	     _bfd_elf_init_1_index_section
 #define elf_backend_gc_mark_hook	     elf32_hppa_gc_mark_hook
 #define elf_backend_gc_sweep_hook	     elf32_hppa_gc_sweep_hook
 #define elf_backend_grok_prstatus	     elf32_hppa_grok_prstatus
Index: bfd/elf32-i370.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i370.c,v
retrieving revision 1.55
diff -u -p -r1.55 elf32-i370.c
--- bfd/elf32-i370.c	16 Sep 2006 18:12:13 -0000	1.55
+++ bfd/elf32-i370.c	16 Oct 2006 23:43:51 -0000
@@ -1290,9 +1290,21 @@ i370_elf_relocate_section (bfd *output_b
 			{
 			  asection *osec;
 
+			  /* We are turning this relocation into one
+			     against a section symbol.  It would be
+			     proper to subtract the symbol's value,
+			     osec->vma, from the emitted reloc addend,
+			     but ld.so expects buggy relocs.  */
 			  osec = sec->output_section;
 			  indx = elf_section_data (osec)->dynindx;
-			  BFD_ASSERT(indx > 0);
+			  if (indx == 0)
+			    {
+			      struct elf_link_hash_table *htab;
+			      htab = elf_hash_table (info);
+			      osec = htab->text_index_section;
+			      indx = elf_section_data (osec)->dynindx;
+			    }
+			  BFD_ASSERT (indx != 0);
 #ifdef DEBUG
 			  if (indx <= 0)
 			    {
@@ -1427,6 +1439,7 @@ i370_elf_post_process_headers (bfd * abf
    link glibc's ld.so without errors.  */
 #define elf_backend_create_dynamic_sections	i370_elf_create_dynamic_sections
 #define elf_backend_size_dynamic_sections	i370_elf_size_dynamic_sections
+#define elf_backend_init_index_section		_bfd_elf_init_1_index_section
 #define elf_backend_finish_dynamic_sections	i370_elf_finish_dynamic_sections
 #define elf_backend_fake_sections		i370_elf_fake_sections
 #define elf_backend_section_from_shdr		i370_elf_section_from_shdr
Index: bfd/elf32-m68k.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68k.c,v
retrieving revision 1.92
diff -u -p -r1.92 elf32-m68k.c
--- bfd/elf32-m68k.c	28 Sep 2006 13:27:32 -0000	1.92
+++ bfd/elf32-m68k.c	16 Oct 2006 23:43:59 -0000
@@ -1833,11 +1833,12 @@ elf_m68k_relocate_section (output_bfd, i
 	      else
 		{
 		  /* This symbol is local, or marked to become local.  */
+		  outrel.r_addend = relocation + rel->r_addend;
+
 		  if (r_type == R_68K_32)
 		    {
 		      relocate = TRUE;
 		      outrel.r_info = ELF32_R_INFO (0, R_68K_RELATIVE);
-		      outrel.r_addend = relocation + rel->r_addend;
 		    }
 		  else
 		    {
@@ -1854,13 +1855,24 @@ elf_m68k_relocate_section (output_bfd, i
 			{
 			  asection *osec;
 
+			  /* We are turning this relocation into one
+			     against a section symbol.  It would be
+			     proper to subtract the symbol's value,
+			     osec->vma, from the emitted reloc addend,
+			     but ld.so expects buggy relocs.  */
 			  osec = sec->output_section;
 			  indx = elf_section_data (osec)->dynindx;
-			  BFD_ASSERT (indx > 0);
+			  if (indx == 0)
+			    {
+			      struct elf_link_hash_table *htab;
+			      htab = elf_hash_table (info);
+			      osec = htab->text_index_section;
+			      indx = elf_section_data (osec)->dynindx;
+			    }
+			  BFD_ASSERT (indx != 0);
 			}
 
 		      outrel.r_info = ELF32_R_INFO (indx, r_type);
-		      outrel.r_addend = relocation + rel->r_addend;
 		    }
 		}
 
@@ -2418,6 +2430,7 @@ elf_m68k_plt_sym_val (bfd_vma i, const a
 					elf_m68k_adjust_dynamic_symbol
 #define elf_backend_size_dynamic_sections \
 					elf_m68k_size_dynamic_sections
+#define elf_backend_init_index_section	_bfd_elf_init_1_index_section
 #define elf_backend_relocate_section	elf_m68k_relocate_section
 #define elf_backend_finish_dynamic_symbol \
 					elf_m68k_finish_dynamic_symbol
Index: bfd/elf32-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-mips.c,v
retrieving revision 1.191
diff -u -p -r1.191 elf32-mips.c
--- bfd/elf32-mips.c	15 Aug 2006 18:28:47 -0000	1.191
+++ bfd/elf32-mips.c	16 Oct 2006 23:43:59 -0000
@@ -1513,6 +1513,7 @@ static const struct ecoff_debug_swap mip
 					_bfd_mips_elf_always_size_sections
 #define elf_backend_size_dynamic_sections \
 					_bfd_mips_elf_size_dynamic_sections
+#define elf_backend_init_index_section	_bfd_elf_init_1_index_section
 #define elf_backend_relocate_section	_bfd_mips_elf_relocate_section
 #define elf_backend_finish_dynamic_symbol \
 					_bfd_mips_elf_finish_dynamic_symbol
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.204
diff -u -p -r1.204 elf32-ppc.c
--- bfd/elf32-ppc.c	28 Sep 2006 13:27:32 -0000	1.204
+++ bfd/elf32-ppc.c	16 Oct 2006 23:44:01 -0000
@@ -6280,9 +6280,14 @@ ppc_elf_relocate_section (bfd *output_bf
 			     but ld.so expects buggy relocs.  */
 			  osec = sec->output_section;
 			  indx = elf_section_data (osec)->dynindx;
-			  BFD_ASSERT (indx > 0);
+			  if (indx == 0)
+			    {
+			      osec = htab->elf.text_index_section;
+			      indx = elf_section_data (osec)->dynindx;
+			    }
+			  BFD_ASSERT (indx != 0);
 #ifdef DEBUG
-			  if (indx <= 0)
+			  if (indx == 0)
 			    printf ("indx=%ld section=%s flags=%08x name=%s\n",
 				    indx, osec->name, osec->flags,
 				    h->root.root.string);
@@ -7472,6 +7477,7 @@ ppc_elf_finish_dynamic_sections (bfd *ou
 #define elf_backend_get_sec_type_attr		ppc_elf_get_sec_type_attr
 #define elf_backend_plt_sym_val			ppc_elf_plt_sym_val
 #define elf_backend_action_discarded		ppc_elf_action_discarded
+#define elf_backend_init_index_section		_bfd_elf_init_1_index_section
 
 #include "elf32-target.h"
 
Index: bfd/elf32-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-s390.c,v
retrieving revision 1.87
diff -u -p -r1.87 elf32-s390.c
--- bfd/elf32-s390.c	28 Sep 2006 13:27:32 -0000	1.87
+++ bfd/elf32-s390.c	16 Oct 2006 23:44:02 -0000
@@ -2630,14 +2630,18 @@ elf_s390_relocate_section (output_bfd, i
 
 			  osec = sec->output_section;
 			  sindx = elf_section_data (osec)->dynindx;
-			  BFD_ASSERT (sindx > 0);
+			  if (sindx == 0)
+			    {
+			      osec = htab->elf.text_index_section;
+			      sindx = elf_section_data (osec)->dynindx;
+			    }
+			  BFD_ASSERT (sindx != 0);
 
 			  /* We are turning this relocation into one
 			     against a section symbol, so subtract out
 			     the output section's address but not the
 			     offset of the input section in the output
 			     section.  */
-
 			  outrel.r_addend -= osec->vma;
 			}
 		      outrel.r_info = ELF32_R_INFO (sindx, r_type);
@@ -3542,6 +3546,7 @@ elf_s390_plt_sym_val (bfd_vma i, const a
 #define elf_backend_reloc_type_class	      elf_s390_reloc_type_class
 #define elf_backend_relocate_section	      elf_s390_relocate_section
 #define elf_backend_size_dynamic_sections     elf_s390_size_dynamic_sections
+#define elf_backend_init_index_section	      _bfd_elf_init_1_index_section
 #define elf_backend_reloc_type_class	      elf_s390_reloc_type_class
 #define elf_backend_grok_prstatus	      elf_s390_grok_prstatus
 #define elf_backend_plt_sym_val		      elf_s390_plt_sym_val
Index: bfd/elf32-sparc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sparc.c,v
retrieving revision 1.85
diff -u -p -r1.85 elf32-sparc.c
--- bfd/elf32-sparc.c	30 May 2006 16:45:31 -0000	1.85
+++ bfd/elf32-sparc.c	16 Oct 2006 23:44:08 -0000
@@ -207,6 +207,7 @@ elf32_sparc_reloc_type_class (const Elf_
 #define elf_backend_gc_mark_hook	_bfd_sparc_elf_gc_mark_hook
 #define elf_backend_gc_sweep_hook       _bfd_sparc_elf_gc_sweep_hook
 #define elf_backend_plt_sym_val		_bfd_sparc_elf_plt_sym_val
+#define elf_backend_init_index_section	_bfd_elf_init_1_index_section
 
 #define elf_backend_can_gc_sections 1
 #define elf_backend_can_refcount 1
Index: bfd/elf32-vax.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-vax.c,v
retrieving revision 1.38
diff -u -p -r1.38 elf32-vax.c
--- bfd/elf32-vax.c	28 Sep 2006 13:27:32 -0000	1.38
+++ bfd/elf32-vax.c	16 Oct 2006 23:44:09 -0000
@@ -1680,9 +1680,21 @@ elf_vax_relocate_section (bfd *output_bf
 			{
 			  asection *osec;
 
+			  /* We are turning this relocation into one
+			     against a section symbol.  It would be
+			     proper to subtract the symbol's value,
+			     osec->vma, from the emitted reloc addend,
+			     but ld.so expects buggy relocs.  */
 			  osec = sec->output_section;
 			  indx = elf_section_data (osec)->dynindx;
-			  BFD_ASSERT (indx > 0);
+			  if (indx == 0)
+			    {
+			      struct elf_link_hash_table *htab;
+			      htab = elf_hash_table (info);
+			      osec = htab->text_index_section;
+			      indx = elf_section_data (osec)->dynindx;
+			    }
+			  BFD_ASSERT (indx != 0);
 			}
 
 		      outrel.r_info = ELF32_R_INFO (indx, r_type);
@@ -2062,6 +2074,7 @@ elf_vax_finish_dynamic_sections (bfd *ou
 					elf_vax_adjust_dynamic_symbol
 #define elf_backend_size_dynamic_sections \
 					elf_vax_size_dynamic_sections
+#define elf_backend_init_index_section	_bfd_elf_init_1_index_section
 #define elf_backend_relocate_section	elf_vax_relocate_section
 #define elf_backend_finish_dynamic_symbol \
 					elf_vax_finish_dynamic_symbol
Index: bfd/elf64-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-mips.c,v
retrieving revision 1.76
diff -u -p -r1.76 elf64-mips.c
--- bfd/elf64-mips.c	15 Aug 2006 18:28:48 -0000	1.76
+++ bfd/elf64-mips.c	16 Oct 2006 23:44:20 -0000
@@ -3034,6 +3034,7 @@ const struct elf_size_info mips_elf64_si
 				_bfd_mips_elf_always_size_sections
 #define elf_backend_size_dynamic_sections \
 				_bfd_mips_elf_size_dynamic_sections
+#define elf_backend_init_index_section	_bfd_elf_init_1_index_section
 #define elf_backend_relocate_section    _bfd_mips_elf_relocate_section
 #define elf_backend_finish_dynamic_symbol \
 				_bfd_mips_elf_finish_dynamic_symbol
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.247
diff -u -p -r1.247 elf64-ppc.c
--- bfd/elf64-ppc.c	1 Oct 2006 13:59:21 -0000	1.247
+++ bfd/elf64-ppc.c	16 Oct 2006 23:44:26 -0000
@@ -97,6 +97,7 @@ static bfd_vma opd_entry_value
 #define elf_backend_hide_symbol		      ppc64_elf_hide_symbol
 #define elf_backend_always_size_sections      ppc64_elf_func_desc_adjust
 #define elf_backend_size_dynamic_sections     ppc64_elf_size_dynamic_sections
+#define elf_backend_init_index_section	      _bfd_elf_init_2_index_sections
 #define elf_backend_action_discarded	      ppc64_elf_action_discarded
 #define elf_backend_relocate_section	      ppc64_elf_relocate_section
 #define elf_backend_finish_dynamic_symbol     ppc64_elf_finish_dynamic_symbol
@@ -10840,6 +10841,17 @@ ppc64_elf_relocate_section (bfd *output_
 			  osec = sec->output_section;
 			  indx = elf_section_data (osec)->dynindx;
 
+			  if (indx == 0)
+			    {
+			      if ((osec->flags & SEC_READONLY) == 0
+				  && htab->elf.data_index_section != NULL)
+				osec = htab->elf.data_index_section;
+			      else
+				osec = htab->elf.text_index_section;
+			      indx = elf_section_data (osec)->dynindx;
+			    }
+			  BFD_ASSERT (indx != 0);
+
 			  /* We are turning this relocation into one
 			     against a section symbol, so subtract out
 			     the output section's address but not the
Index: bfd/elf64-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-s390.c,v
retrieving revision 1.87
diff -u -p -r1.87 elf64-s390.c
--- bfd/elf64-s390.c	28 Sep 2006 13:27:32 -0000	1.87
+++ bfd/elf64-s390.c	16 Oct 2006 23:44:29 -0000
@@ -2611,14 +2611,19 @@ elf_s390_relocate_section (output_bfd, i
 
 			  osec = sec->output_section;
 			  sindx = elf_section_data (osec)->dynindx;
-			  BFD_ASSERT (sindx > 0);
+
+			  if (sindx == 0)
+			    {
+			      osec = htab->elf.text_index_section;
+			      sindx = elf_section_data (osec)->dynindx;
+			    }
+			  BFD_ASSERT (sindx != 0);
 
 			  /* We are turning this relocation into one
 			     against a section symbol, so subtract out
 			     the output section's address but not the
 			     offset of the input section in the output
 			     section.  */
-
 			  outrel.r_addend -= osec->vma;
 			}
 		      outrel.r_info = ELF64_R_INFO (sindx, r_type);
@@ -3449,6 +3454,7 @@ const struct elf_size_info s390_elf64_si
 #define elf_backend_reloc_type_class	      elf_s390_reloc_type_class
 #define elf_backend_relocate_section	      elf_s390_relocate_section
 #define elf_backend_size_dynamic_sections     elf_s390_size_dynamic_sections
+#define elf_backend_init_index_section	      _bfd_elf_init_1_index_section
 #define elf_backend_reloc_type_class	      elf_s390_reloc_type_class
 #define elf_backend_plt_sym_val		      elf_s390_plt_sym_val
 
Index: bfd/elf64-sparc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-sparc.c,v
retrieving revision 1.108
diff -u -p -r1.108 elf64-sparc.c
--- bfd/elf64-sparc.c	30 May 2006 16:45:31 -0000	1.108
+++ bfd/elf64-sparc.c	16 Oct 2006 23:44:31 -0000
@@ -889,6 +889,8 @@ const struct elf_size_info elf64_sparc_s
   _bfd_sparc_elf_gc_mark_hook
 #define elf_backend_gc_sweep_hook \
   _bfd_sparc_elf_gc_sweep_hook
+#define elf_backend_init_index_section \
+  _bfd_elf_init_1_index_section
 
 #define elf_backend_can_gc_sections 1
 #define elf_backend_can_refcount 1
Index: bfd/elf64-x86-64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-x86-64.c,v
retrieving revision 1.126
diff -u -p -r1.126 elf64-x86-64.c
--- bfd/elf64-x86-64.c	29 Sep 2006 13:24:11 -0000	1.126
+++ bfd/elf64-x86-64.c	16 Oct 2006 23:44:34 -0000
@@ -2457,9 +2457,19 @@ elf64_x86_64_relocate_section (bfd *outp
 			{
 			  asection *osec;
 
+			  /* We are turning this relocation into one
+			     against a section symbol.  It would be
+			     proper to subtract the symbol's value,
+			     osec->vma, from the emitted reloc addend,
+			     but ld.so expects buggy relocs.  */
 			  osec = sec->output_section;
 			  sindx = elf_section_data (osec)->dynindx;
-			  BFD_ASSERT (sindx > 0);
+			  if (sindx == 0)
+			    {
+			      asection *oi = htab->elf.text_index_section;
+			      sindx = elf_section_data (oi)->dynindx;
+			    }
+			  BFD_ASSERT (sindx != 0);
 			}
 
 		      outrel.r_info = ELF64_R_INFO (sindx, r_type);
@@ -3657,6 +3667,7 @@ static const struct bfd_elf_special_sect
 #define elf_backend_relocate_section	    elf64_x86_64_relocate_section
 #define elf_backend_size_dynamic_sections   elf64_x86_64_size_dynamic_sections
 #define elf_backend_always_size_sections    elf64_x86_64_always_size_sections
+#define elf_backend_init_index_section	    _bfd_elf_init_1_index_section
 #define elf_backend_plt_sym_val		    elf64_x86_64_plt_sym_val
 #define elf_backend_object_p		    elf64_x86_64_elf_object_p
 #define bfd_elf64_mkobject		    elf64_x86_64_mkobject
Index: bfd/elfn32-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfn32-mips.c,v
retrieving revision 1.34
diff -u -p -r1.34 elfn32-mips.c
--- bfd/elfn32-mips.c	15 Aug 2006 18:28:48 -0000	1.34
+++ bfd/elfn32-mips.c	16 Oct 2006 23:44:40 -0000
@@ -2301,6 +2301,7 @@ static const struct ecoff_debug_swap mip
 					_bfd_mips_elf_always_size_sections
 #define elf_backend_size_dynamic_sections \
 					_bfd_mips_elf_size_dynamic_sections
+#define elf_backend_init_index_section	_bfd_elf_init_1_index_section
 #define elf_backend_relocate_section	_bfd_mips_elf_relocate_section
 #define elf_backend_finish_dynamic_symbol \
 					_bfd_mips_elf_finish_dynamic_symbol
Index: bfd/elfxx-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-mips.c,v
retrieving revision 1.183
diff -u -p -r1.183 elfxx-mips.c
--- bfd/elfxx-mips.c	28 Sep 2006 13:27:32 -0000	1.183
+++ bfd/elfxx-mips.c	16 Oct 2006 23:44:48 -0000
@@ -4801,6 +4801,11 @@ mips_elf_create_dynamic_relocation (bfd 
 	{
 	  indx = elf_section_data (sec->output_section)->dynindx;
 	  if (indx == 0)
+	    {
+	      asection *osec = htab->root.text_index_section;
+	      indx = elf_section_data (osec)->dynindx;
+	    }
+	  if (indx == 0)
 	    abort ();
 	}
 
Index: bfd/elfxx-sparc.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-sparc.c,v
retrieving revision 1.26
diff -u -p -r1.26 elfxx-sparc.c
--- bfd/elfxx-sparc.c	13 Oct 2006 21:03:40 -0000	1.26
+++ bfd/elfxx-sparc.c	16 Oct 2006 23:44:51 -0000
@@ -2864,6 +2864,8 @@ _bfd_sparc_elf_relocate_section (bfd *ou
 		    {
 		      long indx;
 
+		      outrel.r_addend = relocation + rel->r_addend;
+
 		      if (is_plt)
 			sec = htab->splt;
 
@@ -2878,9 +2880,20 @@ _bfd_sparc_elf_relocate_section (bfd *ou
 			{
 			  asection *osec;
 
+			  /* We are turning this relocation into one
+			     against a section symbol.  It would be
+			     proper to subtract the symbol's value,
+			     osec->vma, from the emitted reloc addend,
+			     but ld.so expects buggy relocs.  */
 			  osec = sec->output_section;
 			  indx = elf_section_data (osec)->dynindx;
 
+			  if (indx == 0)
+			    {
+			      osec = htab->elf.text_index_section;
+			      indx = elf_section_data (osec)->dynindx;
+			    }
+
 			  /* FIXME: we really should be able to link non-pic
 			     shared libraries.  */
 			  if (indx == 0)
@@ -2894,8 +2907,8 @@ _bfd_sparc_elf_relocate_section (bfd *ou
 			    }
 			}
 
-		      outrel.r_info = SPARC_ELF_R_INFO (htab, rel, indx, r_type);
-		      outrel.r_addend = relocation + rel->r_addend;
+		      outrel.r_info = SPARC_ELF_R_INFO (htab, rel, indx,
+							r_type);
 		    }
 		}
 
Index: bfd/linker.c
===================================================================
RCS file: /cvs/src/src/bfd/linker.c,v
retrieving revision 1.54
diff -u -p -r1.54 linker.c
--- bfd/linker.c	16 Sep 2006 18:12:14 -0000	1.54
+++ bfd/linker.c	17 Oct 2006 01:52:03 -0000
@@ -3073,7 +3073,7 @@ _bfd_generic_section_already_linked (bfd
   bfd_section_already_linked_table_insert (already_linked_list, sec);
 }
 
-/* Convert symbols in excluded output sections to absolute.  */
+/* Convert symbols in excluded output sections to use a kept section.  */
 
 static bfd_boolean
 fix_syms (struct bfd_link_hash_entry *h, void *data)
@@ -3092,8 +3092,27 @@ fix_syms (struct bfd_link_hash_entry *h,
 	  && (s->output_section->flags & SEC_EXCLUDE) != 0
 	  && bfd_section_removed_from_list (obfd, s->output_section))
 	{
+	  asection *op;
+	  for (op = s->output_section->prev; op != NULL; op = op->prev)
+	    if ((op->flags & SEC_EXCLUDE) == 0
+		&& !bfd_section_removed_from_list (obfd, op))
+	      break;
+	  if (op == NULL)
+	    {
+	      if (s->output_section->prev != NULL)
+		op = s->output_section->prev->next;
+	      else
+		op = s->output_section->owner->sections;
+	      for (; op != NULL; op = op->next)
+		if ((op->flags & SEC_EXCLUDE) == 0
+		    && !bfd_section_removed_from_list (obfd, op))
+		  break;
+	      if (op == NULL)
+		op = bfd_abs_section_ptr;
+	    }
 	  h->u.def.value += s->output_offset + s->output_section->vma;
-	  h->u.def.section = bfd_abs_section_ptr;
+	  h->u.def.value -= op->vma;
+	  h->u.def.section = op;
 	}
     }
 
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.241
diff -u -p -r1.241 ldlang.c
--- ld/ldlang.c	11 Oct 2006 14:58:19 -0000	1.241
+++ ld/ldlang.c	16 Oct 2006 23:45:21 -0000
@@ -3342,7 +3342,6 @@ strip_excluded_output_sections (void)
 	continue;
 
       exclude = (output_section->rawsize == 0
-		 && !os->section_relative_symbol
 		 && (output_section->flags & SEC_KEEP) == 0
 		 && !bfd_section_removed_from_list (output_bfd,
 						    output_section));
@@ -3372,7 +3371,8 @@ strip_excluded_output_sections (void)
 	{
 	  /* We don't set bfd_section to NULL since bfd_section of the
 	     removed output section statement may still be used.  */
-	  os->ignored = TRUE;
+	  if (!os->section_relative_symbol)
+	    os->ignored = TRUE;
 	  output_section->flags |= SEC_EXCLUDE;
 	  bfd_section_list_remove (output_bfd, output_section);
 	  output_bfd->section_count--;
Index: ld/ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.176
diff -u -p -r1.176 ld.texinfo
--- ld/ld.texinfo	27 Sep 2006 04:18:15 -0000	1.176
+++ ld/ld.texinfo	17 Oct 2006 04:21:55 -0000
@@ -3684,21 +3684,23 @@ scripts.
 @cindex discarding sections
 @cindex sections, discarding
 @cindex removing sections
-The linker will not create output section which do not have any
-contents.  This is for convenience when referring to input sections that
-may or may not be present in any of the input files.  For example:
+The linker will not create output sections with no contents.  This is
+for convenience when referring to input sections that may or may not
+be present in any of the input files.  For example:
 @smallexample
 .foo : @{ *(.foo) @}
 @end smallexample
 @noindent
 will only create a @samp{.foo} section in the output file if there is a
-@samp{.foo} section in at least one input file.
-
-If you use anything other than an input section description as an output
-section command, such as a symbol assignment, then the output section
-will always be created, even if there are no matching input sections.
-When a section is discarded, its address (@xref{Output Section Address})
-will also be ignored.
+@samp{.foo} section in at least one input file, and if the input
+sections are not all empty.  Other link script directives that allocate
+space in an output section will also create the output section.
+
+The linker will ignore address assignments (@xref{Output Section Address})
+on discarded output sections, except when the linker script defines
+symbols in the output section.  In that case the linker will obey
+the address assignments, possibly advancing dot and/or current lma
+even though the section is discarded.
 
 @cindex /DISCARD/
 The special output section name @samp{/DISCARD/} may be used to discard
Index: ld/emultempl/armcoff.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/armcoff.em,v
retrieving revision 1.23
diff -u -p -r1.23 armcoff.em
--- ld/emultempl/armcoff.em	4 Aug 2005 06:22:13 -0000	1.23
+++ ld/emultempl/armcoff.em	16 Oct 2006 23:45:22 -0000
@@ -154,45 +154,46 @@ gld${EMULATION_NAME}_after_open (void)
 static void
 gld${EMULATION_NAME}_finish (void)
 {
-  struct bfd_link_hash_entry * h;
-
-  if (thumb_entry_symbol == NULL)
-    return;
-
-  h = bfd_link_hash_lookup (link_info.hash, thumb_entry_symbol,
-			    FALSE, FALSE, TRUE);
-
-  if (h != (struct bfd_link_hash_entry *) NULL
-      && (h->type == bfd_link_hash_defined
-	  || h->type == bfd_link_hash_defweak)
-      && h->u.def.section->output_section != NULL)
+  if (thumb_entry_symbol != NULL)
     {
-      static char buffer[32];
-      bfd_vma val;
+      struct bfd_link_hash_entry * h;
 
-      /* Special procesing is required for a Thumb entry symbol.  The
-	 bottom bit of its address must be set.  */
-      val = (h->u.def.value
-	     + bfd_get_section_vma (output_bfd,
-				    h->u.def.section->output_section)
-	     + h->u.def.section->output_offset);
-
-      val |= 1;
-
-      /* Now convert this value into a string and store it in entry_symbol
-	 where the lang_finish() function will pick it up.  */
-      buffer[0] = '0';
-      buffer[1] = 'x';
-
-      sprintf_vma (buffer + 2, val);
-
-      if (entry_symbol.name != NULL && entry_from_cmdline)
-	einfo (_("%P: warning: '--thumb-entry %s' is overriding '-e %s'\n"),
-	       thumb_entry_symbol, entry_symbol.name);
-      entry_symbol.name = buffer;
+      h = bfd_link_hash_lookup (link_info.hash, thumb_entry_symbol,
+				FALSE, FALSE, TRUE);
+
+      if (h != (struct bfd_link_hash_entry *) NULL
+	  && (h->type == bfd_link_hash_defined
+	      || h->type == bfd_link_hash_defweak)
+	  && h->u.def.section->output_section != NULL)
+	{
+	  static char buffer[32];
+	  bfd_vma val;
+
+	  /* Special procesing is required for a Thumb entry symbol.  The
+	     bottom bit of its address must be set.  */
+	  val = (h->u.def.value
+		 + bfd_get_section_vma (output_bfd,
+					h->u.def.section->output_section)
+		 + h->u.def.section->output_offset);
+
+	  val |= 1;
+
+	  /* Now convert this value into a string and store it in entry_symbol
+	     where the lang_finish() function will pick it up.  */
+	  buffer[0] = '0';
+	  buffer[1] = 'x';
+
+	  sprintf_vma (buffer + 2, val);
+
+	  if (entry_symbol.name != NULL && entry_from_cmdline)
+	    einfo (_("%P: warning: '--thumb-entry %s' is overriding '-e %s'\n"),
+		   thumb_entry_symbol, entry_symbol.name);
+	  entry_symbol.name = buffer;
+	}
+      else
+	einfo (_("%P: warning: connot find thumb start symbol %s\n"),
+	       thumb_entry_symbol);
     }
-  else
-    einfo (_("%P: warning: connot find thumb start symbol %s\n"), thumb_entry_symbol);
 
   finish_default ();
 }
Index: ld/testsuite/ld-arm/mixed-app.sym
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-arm/mixed-app.sym,v
retrieving revision 1.3
diff -u -p -r1.3 mixed-app.sym
--- ld/testsuite/ld-arm/mixed-app.sym	15 Aug 2005 15:39:44 -0000	1.3
+++ ld/testsuite/ld-arm/mixed-app.sym	16 Oct 2006 23:45:23 -0000
@@ -9,7 +9,7 @@ Symbol table for image:
    ..  ..: 0*[^0]*.*   20    FUNC GLOBAL DEFAULT UND lib_func1
    ..  ..: ........     0  NOTYPE GLOBAL DEFAULT ABS __exidx_start
    ..  ..: ........     0  NOTYPE GLOBAL DEFAULT  11 __data_start
-   ..  ..: ........     0  NOTYPE GLOBAL DEFAULT ABS _stack
+   ..  ..: ........     0  NOTYPE GLOBAL DEFAULT  12 _stack
    ..  ..: ........     0  NOTYPE GLOBAL DEFAULT ABS __end__
    ..  ..: ........     0  NOTYPE GLOBAL DEFAULT ABS __bss_start
    ..  ..: .......0     0    FUNC GLOBAL DEFAULT   8 app_func2
Index: ld/testsuite/ld-cris/ldsym1.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-cris/ldsym1.d,v
retrieving revision 1.3
diff -u -p -r1.3 ldsym1.d
--- ld/testsuite/ld-cris/ldsym1.d	4 Nov 2004 15:04:05 -0000	1.3
+++ ld/testsuite/ld-cris/ldsym1.d	16 Oct 2006 23:45:23 -0000
@@ -13,7 +13,7 @@
 
 Disassembly of section \.text:
 
-0+ <__start>:
+0+ <(__start|__Stext)>:
    0:	0f05                	nop 
 
 0+2 <expfn>:
Index: ld/testsuite/ld-cris/libdso-12.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-cris/libdso-12.d,v
retrieving revision 1.6
diff -u -p -r1.6 libdso-12.d
--- ld/testsuite/ld-cris/libdso-12.d	15 Aug 2005 15:39:45 -0000	1.6
+++ ld/testsuite/ld-cris/libdso-12.d	16 Oct 2006 23:45:23 -0000
@@ -12,40 +12,40 @@
 
 DYNAMIC SYMBOL TABLE:
 #...
-0+252 g    DF \.text	0+12 dsofn4
-0+248 g    DF \.text	0+2 expfn
-0+2310 g    DO \.data	0+4 expobj
+0+23e g    DF \.text	0+12 dsofn4
+0+234 g    DF \.text	0+2 expfn
+0+22fc g    DO \.data	0+4 expobj
 #...
-0+24a g    DF \.text	0+8 dsofn3
+0+236 g    DF \.text	0+8 dsofn3
 #...
 0+      D  \*UND\*	0+ dsofn
 #...
 Contents of section \.rela\.got:
- 01d4 0c230000 0a050000 00000000           .*
+ 01c0 f8220000 0a040000 00000000           .*
 Contents of section \.rela\.plt:
- 01e0 04230000 0b030000 00000000 08230000  .*
- 01f0 0b0b0000 00000000                    .*
+ 01cc f0220000 0b020000 00000000 f4220000  .*
+ 01dc 0b0a0000 00000000                    .*
 Contents of section \.plt:
- 01f8 84e20401 7e7a3f7a 04f26ffa bf09b005  .*
- 0208 00000000 00000000 00006f0d 0c000000  .*
- 0218 6ffabf09 b0053f7e 00000000 bf0ed4ff  .*
- 0228 ffffb005 6f0d1000 00006ffa bf09b005  .*
- 0238 3f7e0c00 0000bf0e baffffff b005      .*
+ 01e4 84e20401 7e7a3f7a 04f26ffa bf09b005  .*
+ 01f4 00000000 00000000 00006f0d 0c000000  .*
+ 0204 6ffabf09 b0053f7e 00000000 bf0ed4ff  .*
+ 0214 ffffb005 6f0d1000 00006ffa bf09b005  .*
+ 0224 3f7e0c00 0000bf0e baffffff b005      .*
 Contents of section \.text:
- 0246 b005b005 bfbee2ff ffffb005 7f0da620  .*
- 0256 00005f0d 1400bfbe b6ffffff b0050000  .*
+ 0232 b005b005 bfbee2ff ffffb005 7f0da620  .*
+ 0242 00005f0d 1400bfbe b6ffffff b0050000  .*
 Contents of section \.dynamic:
- 2268 04000000 94000000 05000000 98010000  .*
- 2278 06000000 d8000000 0a000000 3a000000  .*
- 2288 0b000000 10000000 03000000 f8220000  .*
- 2298 02000000 18000000 14000000 07000000  .*
- 22a8 17000000 e0010000 07000000 d4010000  .*
- 22b8 08000000 0c000000 09000000 0c000000  .*
- 22c8 00000000 00000000 00000000 00000000  .*
- 22d8 00000000 00000000 00000000 00000000  .*
- 22e8 00000000 00000000 00000000 00000000  .*
+ 2254 04000000 94000000 05000000 84010000  .*
+ 2264 06000000 d4000000 0a000000 3a000000  .*
+ 2274 0b000000 10000000 03000000 e4220000  .*
+ 2284 02000000 18000000 14000000 07000000  .*
+ 2294 17000000 cc010000 07000000 c0010000  .*
+ 22a4 08000000 0c000000 09000000 0c000000  .*
+ 22b4 00000000 00000000 00000000 00000000  .*
+ 22c4 00000000 00000000 00000000 00000000  .*
+ 22d4 00000000 00000000 00000000 00000000  .*
 Contents of section \.got:
- 22f8 68220000 00000000 00000000 1e020000  .*
- 2308 38020000 00000000                    .*
+ 22e4 54220000 00000000 00000000 0a020000  .*
+ 22f4 24020000 00000000                    .*
 Contents of section \.data:
- 2310 00000000                             .*
+ 22fc 00000000                             .*
Index: ld/testsuite/ld-cris/v32-ba-1.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-cris/v32-ba-1.d,v
retrieving revision 1.4
diff -u -p -r1.4 v32-ba-1.d
--- ld/testsuite/ld-cris/v32-ba-1.d	1 Sep 2005 01:47:25 -0000	1.4
+++ ld/testsuite/ld-cris/v32-ba-1.d	16 Oct 2006 23:45:23 -0000
@@ -10,7 +10,7 @@
 
 Disassembly of section \.text:
 
-0+ <a>:
+0+ <(a|__Stext)>:
    0:	bf0e 0800 0000      	ba 8 <b>
    6:	5e82                	moveq 30,r8
 
Index: ld/testsuite/ld-elf/orphan.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-elf/orphan.d,v
retrieving revision 1.2
diff -u -p -r1.2 orphan.d
--- ld/testsuite/ld-elf/orphan.d	24 Oct 2005 23:06:19 -0000	1.2
+++ ld/testsuite/ld-elf/orphan.d	16 Oct 2006 23:45:23 -0000
@@ -4,6 +4,7 @@
 
 #...
   \[[ 0-9]+\] \.(text|notbad)[ \t]+PROGBITS[ \t0-9a-f]+AX?.*
+#...
   \[[ 0-9]+\] \.(text|notbad)[ \t]+PROGBITS[ \t0-9a-f]+AX?.*
   \[[ 0-9]+\] \.data[ \t]+PROGBITS[ \t0-9a-f]+WA.*
 #...
Index: ld/testsuite/ld-elf/orphan2.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-elf/orphan2.d,v
retrieving revision 1.3
diff -u -p -r1.3 orphan2.d
--- ld/testsuite/ld-elf/orphan2.d	19 Dec 2005 15:07:28 -0000	1.3
+++ ld/testsuite/ld-elf/orphan2.d	16 Oct 2006 23:45:23 -0000
@@ -4,5 +4,6 @@
 
 #...
   \[[ 0-9]+\] \.text[ \t]+PROGBITS[ \t0-9a-f]+AX?.*
+#...
   \[[ 0-9]+\] \.modinfo[ \t]+PROGBITS[ \t0-9a-f]+A.*
 #pass
Index: ld/testsuite/ld-i386/tlsbin.rd
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-i386/tlsbin.rd,v
retrieving revision 1.10
diff -u -p -r1.10 tlsbin.rd
--- ld/testsuite/ld-i386/tlsbin.rd	2 Jun 2006 00:31:59 -0000	1.10
+++ ld/testsuite/ld-i386/tlsbin.rd	16 Oct 2006 23:45:24 -0000
@@ -70,7 +70,7 @@ Relocation section '.rel.plt' at offset 
  Offset +Info +Type +Sym.Value  Sym. Name
 [0-9a-f ]+R_386_JUMP_SLOT +[0-9a-f]+ +___tls_get_addr
 
-Symbol table '.dynsym' contains 13 entries:
+Symbol table '.dynsym' contains [0-9]+ entries:
  +Num: +Value  Size Type +Bind +Vis +Ndx Name
  +[0-9]+: 0+ +0 NOTYPE  LOCAL  DEFAULT  UND *
  +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT  UND sG3
Index: ld/testsuite/ld-i386/tlsbindesc.rd
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-i386/tlsbindesc.rd,v
retrieving revision 1.4
diff -u -p -r1.4 tlsbindesc.rd
--- ld/testsuite/ld-i386/tlsbindesc.rd	2 Jun 2006 00:31:59 -0000	1.4
+++ ld/testsuite/ld-i386/tlsbindesc.rd	16 Oct 2006 23:45:24 -0000
@@ -64,7 +64,7 @@ Relocation section '.rel.dyn' at offset 
 0+804a0fc  00000825 R_386_TLS_TPOFF32 0+ +sG1
 0+804a100  00000b0e R_386_TLS_TPOFF +0+ +sG8
 
-Symbol table '.dynsym' contains 12 entries:
+Symbol table '.dynsym' contains [0-9]+ entries:
  +Num: +Value  Size Type +Bind +Vis +Ndx Name
  +[0-9]+: 0+ +0 NOTYPE  LOCAL  DEFAULT  UND *
  +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT  UND sG3
Index: ld/testsuite/ld-i386/tlsdesc.rd
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-i386/tlsdesc.rd,v
retrieving revision 1.4
diff -u -p -r1.4 tlsdesc.rd
--- ld/testsuite/ld-i386/tlsdesc.rd	2 Jun 2006 00:31:59 -0000	1.4
+++ ld/testsuite/ld-i386/tlsdesc.rd	16 Oct 2006 23:45:24 -0000
@@ -49,41 +49,38 @@ Program Headers:
 
 Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 20 entries:
  Offset +Info +Type +Sym.Value +Sym. Name
-[0-9a-f]+ +0+25 R_386_TLS_TPOFF32
-[0-9a-f]+ +0+0e R_386_TLS_TPOFF *
-[0-9a-f]+ +0+25 R_386_TLS_TPOFF32
-[0-9a-f]+ +0+0e R_386_TLS_TPOFF *
-[0-9a-f]+ +0+0e R_386_TLS_TPOFF *
-[0-9a-f]+ +0+0e R_386_TLS_TPOFF *
-[0-9a-f]+ +0+25 R_386_TLS_TPOFF32
-[0-9a-f]+ +0+25 R_386_TLS_TPOFF32
-[0-9a-f]+ +0+0e R_386_TLS_TPOFF *
-[0-9a-f]+ +0+25 R_386_TLS_TPOFF32
-[0-9a-f]+ +0+0e R_386_TLS_TPOFF *
-[0-9a-f]+ +0+0e R_386_TLS_TPOFF *
-[0-9a-f]+ +0+0e R_386_TLS_TPOFF *
-[0-9a-f]+ +0+0e R_386_TLS_TPOFF *
-[0-9a-f]+ +0+25 R_386_TLS_TPOFF32
-[0-9a-f]+ +0+50e R_386_TLS_TPOFF   0+8   sg3
-[0-9a-f]+ +0+625 R_386_TLS_TPOFF32 0+c   sg4
-[0-9a-f]+ +0+60e R_386_TLS_TPOFF   0+c   sg4
-[0-9a-f]+ +0+70e R_386_TLS_TPOFF   0+10   sg5
-[0-9a-f]+ +0+b25 R_386_TLS_TPOFF32 0+4   sg2
+[0-9a-f ]+R_386_TLS_TPOFF32
+[0-9a-f ]+R_386_TLS_TPOFF *
+[0-9a-f ]+R_386_TLS_TPOFF32
+[0-9a-f ]+R_386_TLS_TPOFF *
+[0-9a-f ]+R_386_TLS_TPOFF *
+[0-9a-f ]+R_386_TLS_TPOFF *
+[0-9a-f ]+R_386_TLS_TPOFF32
+[0-9a-f ]+R_386_TLS_TPOFF32
+[0-9a-f ]+R_386_TLS_TPOFF *
+[0-9a-f ]+R_386_TLS_TPOFF32
+[0-9a-f ]+R_386_TLS_TPOFF *
+[0-9a-f ]+R_386_TLS_TPOFF *
+[0-9a-f ]+R_386_TLS_TPOFF *
+[0-9a-f ]+R_386_TLS_TPOFF *
+[0-9a-f ]+R_386_TLS_TPOFF32
+[0-9a-f ]+R_386_TLS_TPOFF   0+8   sg3
+[0-9a-f ]+R_386_TLS_TPOFF32 0+c   sg4
+[0-9a-f ]+R_386_TLS_TPOFF   0+c   sg4
+[0-9a-f ]+R_386_TLS_TPOFF   0+10   sg5
+[0-9a-f ]+R_386_TLS_TPOFF32 0+4   sg2
 
 Relocation section '.rel.plt' at offset 0x[0-9a-f]+ contains 5 entries:
  Offset     Info    Type            Sym.Value  Sym. Name
-[0-9a-f]+ +0+829 R_386_TLS_DESC * 0+   sg1
-[0-9a-f]+ +0+29 R_386_TLS_DESC *
-[0-9a-f]+ +0+29 R_386_TLS_DESC *
-[0-9a-f]+ +0+29 R_386_TLS_DESC *
-[0-9a-f]+ +0+29 R_386_TLS_DESC *
+[0-9a-f ]+R_386_TLS_DESC * 0+   sg1
+[0-9a-f ]+R_386_TLS_DESC *
+[0-9a-f ]+R_386_TLS_DESC *
+[0-9a-f ]+R_386_TLS_DESC *
+[0-9a-f ]+R_386_TLS_DESC *
 
-Symbol table '.dynsym' contains 16 entries:
+Symbol table '.dynsym' contains [0-9]+ entries:
  +Num: + Value  Size Type + Bind +Vis +Ndx Name
  +[0-9]+: 0+ +0 NOTYPE  LOCAL  DEFAULT  UND *
- +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL  DEFAULT +6 *
- +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL  DEFAULT +7 *
- +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL  DEFAULT +8 *
  +[0-9]+: 0+1c +0 TLS +GLOBAL DEFAULT +7 sg8
  +[0-9]+: 0+8 +0 TLS +GLOBAL DEFAULT +7 sg3
  +[0-9]+: 0+c +0 TLS +GLOBAL DEFAULT +7 sg4
Index: ld/testsuite/ld-i386/tlsdesc.sd
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-i386/tlsdesc.sd,v
retrieving revision 1.1
diff -u -p -r1.1 tlsdesc.sd
--- ld/testsuite/ld-i386/tlsdesc.sd	18 Jan 2006 21:07:49 -0000	1.1
+++ ld/testsuite/ld-i386/tlsdesc.sd	16 Oct 2006 23:45:24 -0000
@@ -14,7 +14,7 @@ Contents of section \.got:
  [0-9a-f]+ 6c000000 b4ffffff 4c000000 68000000  .*
  [0-9a-f]+ 50000000 70000000 00000000 bcffffff  .*
 Contents of section \.got\.plt:
- [0-9a-f]+ ec150000 00000000 00000000 00000000  .*
+ [0-9a-f]+ b0150000 00000000 00000000 00000000  .*
  [0-9a-f]+ 20000000 00000000 60000000 00000000  .*
  [0-9a-f]+ 00000000 00000000 00000000 00000000  .*
  [0-9a-f]+ 40000000 +.*
Index: ld/testsuite/ld-i386/tlsgdesc.rd
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-i386/tlsgdesc.rd,v
retrieving revision 1.2
diff -u -p -r1.2 tlsgdesc.rd
--- ld/testsuite/ld-i386/tlsgdesc.rd	2 Jun 2006 00:31:59 -0000	1.2
+++ ld/testsuite/ld-i386/tlsgdesc.rd	16 Oct 2006 23:45:24 -0000
@@ -45,25 +45,24 @@ Program Headers:
 
 Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 8 entries:
  Offset +Info +Type +Sym.Value +Sym. Name
-[0-9a-f]+ +0+225 R_386_TLS_TPOFF32 0+   sG3
-[0-9a-f]+ +0+30e R_386_TLS_TPOFF   0+   sG5
-[0-9a-f]+ +0+423 R_386_TLS_DTPMOD3 0+   sG2
-[0-9a-f]+ +0+424 R_386_TLS_DTPOFF3 0+   sG2
-[0-9a-f]+ +0+50e R_386_TLS_TPOFF   0+   sG4
-[0-9a-f]+ +0+725 R_386_TLS_TPOFF32 0+   sG6
-[0-9a-f]+ +0+923 R_386_TLS_DTPMOD3 0+   sG1
-[0-9a-f]+ +0+924 R_386_TLS_DTPOFF3 0+   sG1
+[0-9a-f ]+R_386_TLS_TPOFF32 0+   sG3
+[0-9a-f ]+R_386_TLS_TPOFF   0+   sG5
+[0-9a-f ]+R_386_TLS_DTPMOD3 0+   sG2
+[0-9a-f ]+R_386_TLS_DTPOFF3 0+   sG2
+[0-9a-f ]+R_386_TLS_TPOFF   0+   sG4
+[0-9a-f ]+R_386_TLS_TPOFF32 0+   sG6
+[0-9a-f ]+R_386_TLS_DTPMOD3 0+   sG1
+[0-9a-f ]+R_386_TLS_DTPOFF3 0+   sG1
 
 Relocation section '.rel.plt' at offset 0x[0-9a-f]+ contains 3 entries:
  Offset     Info    Type            Sym.Value  Sym. Name
-[0-9a-f]+  0+c07 R_386_JUMP_SLOT   0+   ___tls_get_addr
-[0-9a-f]+  0+929 R_386_TLS_DESC    0+   sG1
-[0-9a-f]+  0+429 R_386_TLS_DESC    0+   sG2
+[0-9a-f ]+R_386_JUMP_SLOT   0+   ___tls_get_addr
+[0-9a-f ]+R_386_TLS_DESC    0+   sG1
+[0-9a-f ]+R_386_TLS_DESC    0+   sG2
 
-Symbol table '.dynsym' contains 13 entries:
+Symbol table '.dynsym' contains [0-9]+ entries:
  +Num: + Value  Size Type + Bind +Vis +Ndx Name
  +[0-9]+: 0+ +0 NOTYPE  LOCAL  DEFAULT  UND *
- +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL  DEFAULT +7 *
  +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT  UND sG3
  +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT  UND sG5
  +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT  UND sG2
Index: ld/testsuite/ld-i386/tlsnopic.rd
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-i386/tlsnopic.rd,v
retrieving revision 1.11
diff -u -p -r1.11 tlsnopic.rd
--- ld/testsuite/ld-i386/tlsnopic.rd	2 Jun 2006 00:31:59 -0000	1.11
+++ ld/testsuite/ld-i386/tlsnopic.rd	16 Oct 2006 23:45:24 -0000
@@ -69,11 +69,9 @@ Relocation section '.rel.dyn' at offset 
 [0-9a-f ]+R_386_TLS_TPOFF   0+   sg2
 
 
-Symbol table '.dynsym' contains 12 entries:
+Symbol table '.dynsym' contains [0-9]+ entries:
  +Num: +Value  Size Type +Bind +Vis +Ndx Name
  +[0-9]+: 0+ +0 NOTYPE  LOCAL  DEFAULT  UND *
- +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL  DEFAULT +5 *
- +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL  DEFAULT +6 *
  +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT  UND sg3
  +[0-9]+: 0+ +0 TLS +GLOBAL DEFAULT  UND sg4
  +[0-9]+: 0+1000 +0 FUNC +GLOBAL DEFAULT +5 fn3
Index: ld/testsuite/ld-i386/tlspic.rd
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-i386/tlspic.rd,v
retrieving revision 1.10
diff -u -p -r1.10 tlspic.rd
--- ld/testsuite/ld-i386/tlspic.rd	2 Jun 2006 00:31:59 -0000	1.10
+++ ld/testsuite/ld-i386/tlspic.rd	16 Oct 2006 23:45:24 -0000
@@ -81,12 +81,9 @@ Relocation section '.rel.plt' at offset 
  Offset +Info +Type +Sym.Value +Sym. Name
 [0-9a-f ]+R_386_JUMP_SLOT   0+   ___tls_get_addr
 
-Symbol table '.dynsym' contains 17 entries:
+Symbol table '.dynsym' contains [0-9]+ entries:
  +Num: +Value  Size Type +Bind +Vis +Ndx Name
  +[0-9]+: 0+ +0 NOTYPE  LOCAL  DEFAULT  UND *
- +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL  DEFAULT +7 *
- +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL  DEFAULT +8 *
- +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL  DEFAULT +9 *
  +[0-9]+: 0+1c +0 TLS +GLOBAL DEFAULT +8 sg8
  +[0-9]+: 0+8 +0 TLS +GLOBAL DEFAULT +8 sg3
  +[0-9]+: 0+c +0 TLS +GLOBAL DEFAULT +8 sg4
Index: ld/testsuite/ld-ia64/tlspic.rd
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-ia64/tlspic.rd,v
retrieving revision 1.12
diff -u -p -r1.12 tlspic.rd
--- ld/testsuite/ld-ia64/tlspic.rd	2 Jun 2006 00:31:59 -0000	1.12
+++ ld/testsuite/ld-ia64/tlspic.rd	16 Oct 2006 23:45:24 -0000
@@ -59,11 +59,6 @@ Relocation section '.rela.IA_64.pltoff' 
 Symbol table '.dynsym' contains [0-9]+ entries:
  +Num: +Value +Size Type +Bind +Vis +Ndx Name
 .* NOTYPE +LOCAL +DEFAULT +UND *
-.* SECTION LOCAL +DEFAULT +7 *
-.* SECTION LOCAL +DEFAULT +8 *
-.* SECTION LOCAL +DEFAULT +10 *
-.* SECTION LOCAL +DEFAULT +11 *
-.* SECTION LOCAL +DEFAULT +14 *
 .* TLS +GLOBAL DEFAULT +10 sg8
 .* TLS +GLOBAL DEFAULT +10 sg3
 .* TLS +GLOBAL DEFAULT +10 sg4
Index: ld/testsuite/ld-mips-elf/eh-frame1-n32.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/eh-frame1-n32.d,v
retrieving revision 1.1
diff -u -p -r1.1 eh-frame1-n32.d
--- ld/testsuite/ld-mips-elf/eh-frame1-n32.d	16 Nov 2004 10:16:30 -0000	1.1
+++ ld/testsuite/ld-mips-elf/eh-frame1-n32.d	16 Oct 2006 23:45:24 -0000
@@ -7,19 +7,19 @@
 
 Relocation section '\.rel\.dyn' .*:
  *Offset .*
-00000000  00000000 R_MIPS_NONE *
+00000000  [0-9a-f]+ R_MIPS_NONE *
 # Initial PCs for the FDEs attached to CIE 0xbc
-000300dc  00000003 R_MIPS_REL32 *
-000300f0  00000003 R_MIPS_REL32 *
+000300dc  [0-9a-f]+ R_MIPS_REL32 *
+000300f0  [0-9a-f]+ R_MIPS_REL32 *
 # Likewise CIE 0x220
-00030240  00000003 R_MIPS_REL32 *
-00030254  00000003 R_MIPS_REL32 *
-0003008b  00000503 R_MIPS_REL32      00000000   foo
-000300d0  00000503 R_MIPS_REL32      00000000   foo
-0003010e  00000503 R_MIPS_REL32      00000000   foo
-000301ef  00000503 R_MIPS_REL32      00000000   foo
-00030234  00000503 R_MIPS_REL32      00000000   foo
-00030272  00000503 R_MIPS_REL32      00000000   foo
+00030240  [0-9a-f]+ R_MIPS_REL32 *
+00030254  [0-9a-f]+ R_MIPS_REL32 *
+0003008b  [0-9a-f]+ R_MIPS_REL32      00000000   foo
+000300d0  [0-9a-f]+ R_MIPS_REL32      00000000   foo
+0003010e  [0-9a-f]+ R_MIPS_REL32      00000000   foo
+000301ef  [0-9a-f]+ R_MIPS_REL32      00000000   foo
+00030234  [0-9a-f]+ R_MIPS_REL32      00000000   foo
+00030272  [0-9a-f]+ R_MIPS_REL32      00000000   foo
 #...
 The section \.eh_frame contains:
 
Index: ld/testsuite/ld-mips-elf/eh-frame1-n64.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/eh-frame1-n64.d,v
retrieving revision 1.1
diff -u -p -r1.1 eh-frame1-n64.d
--- ld/testsuite/ld-mips-elf/eh-frame1-n64.d	16 Nov 2004 10:16:30 -0000	1.1
+++ ld/testsuite/ld-mips-elf/eh-frame1-n64.d	16 Oct 2006 23:45:24 -0000
@@ -7,39 +7,39 @@
 
 Relocation section '\.rel\.dyn' .*:
  *Offset .*
-000000000000  000000000000 R_MIPS_NONE *
+000000000000  [0-9a-f]+ R_MIPS_NONE *
  *Type2: R_MIPS_NONE *
  *Type3: R_MIPS_NONE *
 # Initial PCs for the FDEs attached to CIE 0x120
-000000030148  000000001203 R_MIPS_REL32 *
+000000030148  [0-9a-f]+ R_MIPS_REL32 *
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
-000000030168  000000001203 R_MIPS_REL32 *
+000000030168  [0-9a-f]+ R_MIPS_REL32 *
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
 # Likewise CIE 0x340
-000000030368  000000001203 R_MIPS_REL32 *
+000000030368  [0-9a-f]+ R_MIPS_REL32 *
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
-000000030388  000000001203 R_MIPS_REL32 *
+000000030388  [0-9a-f]+ R_MIPS_REL32 *
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
-0000000300cb  000500001203 R_MIPS_REL32      0000000000000000 foo
+0000000300cb  [0-9a-f]+ R_MIPS_REL32      0000000000000000 foo
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
-000000030138  000500001203 R_MIPS_REL32      0000000000000000 foo
+000000030138  [0-9a-f]+ R_MIPS_REL32      0000000000000000 foo
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
-000000030192  000500001203 R_MIPS_REL32      0000000000000000 foo
+000000030192  [0-9a-f]+ R_MIPS_REL32      0000000000000000 foo
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
-0000000302eb  000500001203 R_MIPS_REL32      0000000000000000 foo
+0000000302eb  [0-9a-f]+ R_MIPS_REL32      0000000000000000 foo
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
-000000030358  000500001203 R_MIPS_REL32      0000000000000000 foo
+000000030358  [0-9a-f]+ R_MIPS_REL32      0000000000000000 foo
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
-0000000303b2  000500001203 R_MIPS_REL32      0000000000000000 foo
+0000000303b2  [0-9a-f]+ R_MIPS_REL32      0000000000000000 foo
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
 #...
Index: ld/testsuite/ld-mips-elf/eh-frame2-n32.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/eh-frame2-n32.d,v
retrieving revision 1.1
diff -u -p -r1.1 eh-frame2-n32.d
--- ld/testsuite/ld-mips-elf/eh-frame2-n32.d	17 Jan 2005 17:44:41 -0000	1.1
+++ ld/testsuite/ld-mips-elf/eh-frame2-n32.d	16 Oct 2006 23:45:24 -0000
@@ -7,19 +7,19 @@
 
 Relocation section '\.rel\.dyn' .*:
  *Offset .*
-00000000  00000000 R_MIPS_NONE *
+00000000  [0-9a-f]+ R_MIPS_NONE *
 # Initial PCs for the FDEs attached to CIE 0xb8
-000300d8  00000003 R_MIPS_REL32 *
-000300ec  00000003 R_MIPS_REL32 *
+000300d8  [0-9a-f]+ R_MIPS_REL32 *
+000300ec  [0-9a-f]+ R_MIPS_REL32 *
 # Likewise CIE 0x218
-00030238  00000003 R_MIPS_REL32 *
-0003024c  00000003 R_MIPS_REL32 *
-0003008b  00000503 R_MIPS_REL32      00000000   foo
-000300cc  00000503 R_MIPS_REL32      00000000   foo
-0003010a  00000503 R_MIPS_REL32      00000000   foo
-000301eb  00000503 R_MIPS_REL32      00000000   foo
-0003022c  00000503 R_MIPS_REL32      00000000   foo
-0003026a  00000503 R_MIPS_REL32      00000000   foo
+00030238  [0-9a-f]+ R_MIPS_REL32 *
+0003024c  [0-9a-f]+ R_MIPS_REL32 *
+0003008b  [0-9a-f]+ R_MIPS_REL32      00000000   foo
+000300cc  [0-9a-f]+ R_MIPS_REL32      00000000   foo
+0003010a  [0-9a-f]+ R_MIPS_REL32      00000000   foo
+000301eb  [0-9a-f]+ R_MIPS_REL32      00000000   foo
+0003022c  [0-9a-f]+ R_MIPS_REL32      00000000   foo
+0003026a  [0-9a-f]+ R_MIPS_REL32      00000000   foo
 #...
 The section \.eh_frame contains:
 
Index: ld/testsuite/ld-mips-elf/eh-frame2-n64.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/eh-frame2-n64.d,v
retrieving revision 1.1
diff -u -p -r1.1 eh-frame2-n64.d
--- ld/testsuite/ld-mips-elf/eh-frame2-n64.d	17 Jan 2005 17:44:41 -0000	1.1
+++ ld/testsuite/ld-mips-elf/eh-frame2-n64.d	16 Oct 2006 23:45:24 -0000
@@ -7,39 +7,39 @@
 
 Relocation section '\.rel\.dyn' .*:
  *Offset .*
-000000000000  000000000000 R_MIPS_NONE *
+000000000000  [0-9a-f]+ R_MIPS_NONE *
  *Type2: R_MIPS_NONE *
  *Type3: R_MIPS_NONE *
 # Initial PCs for the FDEs attached to CIE 0x118
-000000030140  000000001203 R_MIPS_REL32 *
+000000030140  [0-9a-f]+ R_MIPS_REL32 *
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
-000000030160  000000001203 R_MIPS_REL32 *
+000000030160  [0-9a-f]+ R_MIPS_REL32 *
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
 # Likewise CIE 0x330
-000000030358  000000001203 R_MIPS_REL32 *
+000000030358  [0-9a-f]+ R_MIPS_REL32 *
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
-000000030378  000000001203 R_MIPS_REL32 *
+000000030378  [0-9a-f]+ R_MIPS_REL32 *
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
-0000000300cb  000500001203 R_MIPS_REL32      0000000000000000 foo
+0000000300cb  [0-9a-f]+ R_MIPS_REL32      0000000000000000 foo
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
-000000030130  000500001203 R_MIPS_REL32      0000000000000000 foo
+000000030130  [0-9a-f]+ R_MIPS_REL32      0000000000000000 foo
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
-00000003018a  000500001203 R_MIPS_REL32      0000000000000000 foo
+00000003018a  [0-9a-f]+ R_MIPS_REL32      0000000000000000 foo
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
-0000000302e3  000500001203 R_MIPS_REL32      0000000000000000 foo
+0000000302e3  [0-9a-f]+ R_MIPS_REL32      0000000000000000 foo
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
-000000030348  000500001203 R_MIPS_REL32      0000000000000000 foo
+000000030348  [0-9a-f]+ R_MIPS_REL32      0000000000000000 foo
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
-0000000303a2  000500001203 R_MIPS_REL32      0000000000000000 foo
+0000000303a2  [0-9a-f]+ R_MIPS_REL32      0000000000000000 foo
  *Type2: R_MIPS_64 *
  *Type3: R_MIPS_NONE *
 #...
Index: ld/testsuite/ld-mips-elf/mips-elf.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/mips-elf.exp,v
retrieving revision 1.39
diff -u -p -r1.39 mips-elf.exp
--- ld/testsuite/ld-mips-elf/mips-elf.exp	18 Sep 2006 18:21:42 -0000	1.39
+++ ld/testsuite/ld-mips-elf/mips-elf.exp	16 Oct 2006 23:45:24 -0000
@@ -147,14 +147,13 @@ run_dump_test "hash1c"
 
 if {[istarget mips*-*-linux*]} {
      # The number of symbols that are always included in the symbol table
-     # for these tests.  The 5 are:
+     # for these tests.  The 4 are:
      #
      #     the null symbol entry
      #     the .MIPS.stubs section symbol
-     #     the .text section symbol
      #     _gp
      #     _GLOBAL_OFFSET_TABLE_
-     set base_syms 5
+     set base_syms 4
      foreach dynsym { 7fff 8000 fff0 10000 2fe80 } {
 	 run_ld_link_tests \
 	     [list [list \
Index: ld/testsuite/ld-mips-elf/rel32-n32.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/rel32-n32.d,v
retrieving revision 1.8
diff -u -p -r1.8 rel32-n32.d
--- ld/testsuite/ld-mips-elf/rel32-n32.d	4 Feb 2006 08:28:29 -0000	1.8
+++ ld/testsuite/ld-mips-elf/rel32-n32.d	16 Oct 2006 23:45:24 -0000
@@ -6,10 +6,10 @@
 
 Relocation section '.rel.dyn' at offset .* contains 2 entries:
  Offset     Info    Type            Sym.Value  Sym. Name
-00000000  00000000 R_MIPS_NONE      
-000002d0  00000003 R_MIPS_REL32     
+[0-9a-f ]+R_MIPS_NONE      
+[0-9a-f ]+R_MIPS_REL32     
 
 Hex dump of section '.text':
-  0x000002c0 00000000 00000000 00000000 00000000 ................
-  0x000002d0 000002d0 00000000 00000000 00000000 ................
-  0x000002e0 00000000 00000000 00000000 00000000 ................
+  0x000002b0 00000000 00000000 00000000 00000000 ................
+  0x000002c0 000002c0 00000000 00000000 00000000 ................
+  0x000002d0 00000000 00000000 00000000 00000000 ................
Index: ld/testsuite/ld-mips-elf/rel32-o32.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/rel32-o32.d,v
retrieving revision 1.7
diff -u -p -r1.7 rel32-o32.d
--- ld/testsuite/ld-mips-elf/rel32-o32.d	4 Feb 2006 08:28:29 -0000	1.7
+++ ld/testsuite/ld-mips-elf/rel32-o32.d	16 Oct 2006 23:45:24 -0000
@@ -6,10 +6,10 @@
 
 Relocation section '.rel.dyn' at offset .* contains 2 entries:
  Offset     Info    Type            Sym.Value  Sym. Name
-00000000  00000000 R_MIPS_NONE      
-000002f0  00000003 R_MIPS_REL32     
+[0-9a-f ]+R_MIPS_NONE      
+[0-9a-f ]+R_MIPS_REL32     
 
 Hex dump of section '.text':
+  0x000002c0 00000000 00000000 00000000 00000000 ................
+  0x000002d0 000002d0 00000000 00000000 00000000 ................
   0x000002e0 00000000 00000000 00000000 00000000 ................
-  0x000002f0 000002f0 00000000 00000000 00000000 ................
-  0x00000300 00000000 00000000 00000000 00000000 ................
Index: ld/testsuite/ld-mips-elf/rel64.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/rel64.d,v
retrieving revision 1.7
diff -u -p -r1.7 rel64.d
--- ld/testsuite/ld-mips-elf/rel64.d	4 Feb 2006 08:28:29 -0000	1.7
+++ ld/testsuite/ld-mips-elf/rel64.d	16 Oct 2006 23:45:24 -0000
@@ -6,14 +6,14 @@
 
 Relocation section '.rel.dyn' at offset .* contains 2 entries:
   Offset          Info           Type           Sym. Value    Sym. Name
-000000000000  000000000000 R_MIPS_NONE      
-                    Type2: R_MIPS_NONE      
-                    Type3: R_MIPS_NONE      
-000000000450  000000001203 R_MIPS_REL32     
-                    Type2: R_MIPS_64        
-                    Type3: R_MIPS_NONE      
+[0-9a-f ]+R_MIPS_NONE      
+ +Type2: R_MIPS_NONE      
+ +Type3: R_MIPS_NONE      
+[0-9a-f ]+R_MIPS_REL32     
+ +Type2: R_MIPS_64        
+ +Type3: R_MIPS_NONE      
 
 Hex dump of section '.text':
-  0x00000440 00000000 00000000 00000000 00000000 ................
-  0x00000450 00000000 00000450 00000000 00000000 ................
-  0x00000460 00000000 00000000 00000000 00000000 ................
+  0x00000430 00000000 00000000 00000000 00000000 ................
+  0x00000440 00000000 00000440 00000000 00000000 ................
+  0x00000450 00000000 00000000 00000000 00000000 ................
Index: ld/testsuite/ld-mips-elf/tls-multi-got-1.got
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/tls-multi-got-1.got,v
retrieving revision 1.3
diff -u -p -r1.3 tls-multi-got-1.got
--- ld/testsuite/ld-mips-elf/tls-multi-got-1.got	5 Jul 2006 16:01:38 -0000	1.3
+++ ld/testsuite/ld-mips-elf/tls-multi-got-1.got	16 Oct 2006 23:45:24 -0000
@@ -4,17 +4,17 @@
 DYNAMIC RELOCATION RECORDS
 OFFSET   TYPE              VALUE 
 00000000 R_MIPS_NONE       \*ABS\*
-001495d0 R_MIPS_TLS_DTPMOD32  \*ABS\*
-0013f948 R_MIPS_TLS_DTPMOD32  \*ABS\*
-001495dc R_MIPS_TLS_DTPMOD32  tlsvar_gd
-001495e0 R_MIPS_TLS_DTPREL32  tlsvar_gd
-0013f954 R_MIPS_TLS_DTPMOD32  tlsvar_gd
-0013f958 R_MIPS_TLS_DTPREL32  tlsvar_gd
-001495d8 R_MIPS_TLS_TPREL32  tlsvar_ie
-0013f950 R_MIPS_TLS_TPREL32  tlsvar_ie
-00143f7c R_MIPS_REL32      sym_1_9526
+001495c0 R_MIPS_TLS_DTPMOD32  \*ABS\*
+0013f938 R_MIPS_TLS_DTPMOD32  \*ABS\*
+001495cc R_MIPS_TLS_DTPMOD32  tlsvar_gd
+001495d0 R_MIPS_TLS_DTPREL32  tlsvar_gd
+0013f944 R_MIPS_TLS_DTPMOD32  tlsvar_gd
+0013f948 R_MIPS_TLS_DTPREL32  tlsvar_gd
+001495c8 R_MIPS_TLS_TPREL32  tlsvar_ie
+0013f940 R_MIPS_TLS_TPREL32  tlsvar_ie
+00143f6c R_MIPS_REL32      sym_1_9526
 #...
-00139bd0 R_MIPS_REL32      sym_2_8654
+00139bc0 R_MIPS_REL32      sym_2_8654
 00000000 R_MIPS_NONE       \*ABS\*
 00000000 R_MIPS_NONE       \*ABS\*
 00000000 R_MIPS_NONE       \*ABS\*
@@ -40,19 +40,19 @@ OFFSET   TYPE              VALUE 
 
 
 Contents of section .got:
- 122420 00000000 80000000 00000000 00000000  ................
- 122430 00000000 00000000 00000000 00000000  ................
- 122440 00000000 00000000 00000000 00000000  ................
- 122450 00000000 000d8048 000d66a4 000d2054  .......H..f... T
+ 122410 00000000 80000000 00000000 00000000  .*
+ 122420 00000000 00000000 00000000 00000000  .*
+ 122430 00000000 00000000 00000000 00000000  .*
+ 122440 00000000 000d8038 000d6694 000d2044  .*
 #...
- 13f930 00000000 00000000 00000000 00000000  ................
- 13f940 00000000 00000000 00000000 00000000  ................
- 13f950 00000000 00000000 00000000 00000000  ................
- 13f960 80000000 00000000 00000000 00000000  ................
+ 13f920 00000000 00000000 00000000 00000000  .*
+ 13f930 00000000 00000000 00000000 00000000  .*
+ 13f940 00000000 00000000 00000000 00000000  .*
+ 13f950 80000000 00000000 00000000 00000000  .*
 #...
- 1495a0 00000000 00000000 00000000 00000000  ................
- 1495b0 00000000 00000000 00000000 00000000  ................
- 1495c0 00000000 00000000 00000000 00000000  ................
- 1495d0 00000000 00000000 00000000 00000000  ................
- 1495e0 00000000                             ....            
+ 149590 00000000 00000000 00000000 00000000  .*
+ 1495a0 00000000 00000000 00000000 00000000  .*
+ 1495b0 00000000 00000000 00000000 00000000  .*
+ 1495c0 00000000 00000000 00000000 00000000  .*
+ 1495d0 00000000                             .*
 #pass
Index: ld/testsuite/ld-mips-elf/tls-multi-got-1.r
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/tls-multi-got-1.r,v
retrieving revision 1.3
diff -u -p -r1.3 tls-multi-got-1.r
--- ld/testsuite/ld-mips-elf/tls-multi-got-1.r	5 Jul 2006 16:01:38 -0000	1.3
+++ ld/testsuite/ld-mips-elf/tls-multi-got-1.r	16 Oct 2006 23:45:24 -0000
@@ -2,60 +2,39 @@
 Dynamic section at offset 0xec contains 19 entries:
   Tag        Type                         Name/Value
  0x00000004 \(HASH\)                       0x1ac
- 0x00000005 \(STRTAB\)                     0x71db8
- 0x00000006 \(SYMTAB\)                     0x23ad8
+ 0x00000005 \(STRTAB\).*
+ 0x00000006 \(SYMTAB\).*
  0x0000000a \(STRSZ\)                      220091 \(bytes\)
  0x0000000b \(SYMENT\)                     16 \(bytes\)
  0x00000015 \(DEBUG\)                      0x0
- 0x00000003 \(PLTGOT\)                     0x122420
- 0x00000011 \(REL\)                        0xa7974
+ 0x00000003 \(PLTGOT\)                     0x122410
+ 0x00000011 \(REL\)                        0xa7960
  0x00000012 \(RELSZ\)                      160072 \(bytes\)
  0x00000013 \(RELENT\)                     8 \(bytes\)
  0x70000001 \(MIPS_RLD_VERSION\)           1
  0x70000005 \(MIPS_FLAGS\)                 NOTPOT
  0x70000006 \(MIPS_BASE_ADDRESS\)          0
  0x7000000a \(MIPS_LOCAL_GOTNO\)           13
- 0x70000011 \(MIPS_SYMTABNO\)              20014
+ 0x70000011 \(MIPS_SYMTABNO\)              20013
  0x70000012 \(MIPS_UNREFEXTNO\)            11
- 0x70000013 \(MIPS_GOTSYM\)                0xe
+ 0x70000013 \(MIPS_GOTSYM\)                0xd
  0x0000001e \(FLAGS\)                      STATIC_TLS
  0x00000000 \(NULL\)                       0x0
 
 Relocation section '\.rel\.dyn' at offset 0x[0-9a-f]+ contains 20031 entries:
  Offset     Info    Type            Sym.Value  Sym. Name
-00000000  00000000 R_MIPS_NONE      
-001495d0  00000026 R_MIPS_TLS_DTPMOD
-0013f948  00000026 R_MIPS_TLS_DTPMOD
-001495dc  00000626 R_MIPS_TLS_DTPMOD 00000000   tlsvar_gd
-001495e0  00000627 R_MIPS_TLS_DTPREL 00000000   tlsvar_gd
-0013f954  00000626 R_MIPS_TLS_DTPMOD 00000000   tlsvar_gd
-0013f958  00000627 R_MIPS_TLS_DTPREL 00000000   tlsvar_gd
-001495d8  00000b2f R_MIPS_TLS_TPREL3 00000004   tlsvar_ie
-0013f950  00000b2f R_MIPS_TLS_TPREL3 00000004   tlsvar_ie
-00143f7c  00000e03 R_MIPS_REL32      000d8048   sym_1_9526
-00143768  00000f03 R_MIPS_REL32      000d66a4   sym_1_7885
+[0-9a-f ]+R_MIPS_NONE      
+[0-9a-f ]+R_MIPS_TLS_DTPMOD
+[0-9a-f ]+R_MIPS_TLS_DTPMOD
+[0-9a-f ]+R_MIPS_TLS_DTPMOD 00000000   tlsvar_gd
+[0-9a-f ]+R_MIPS_TLS_DTPREL 00000000   tlsvar_gd
+[0-9a-f ]+R_MIPS_TLS_DTPMOD 00000000   tlsvar_gd
+[0-9a-f ]+R_MIPS_TLS_DTPREL 00000000   tlsvar_gd
+[0-9a-f ]+R_MIPS_TLS_TPREL3 00000004   tlsvar_ie
+[0-9a-f ]+R_MIPS_TLS_TPREL3 00000004   tlsvar_ie
+[0-9a-f ]+R_MIPS_REL32      000d8038   sym_1_9526
+[0-9a-f ]+R_MIPS_REL32      000d6694   sym_1_7885
+#...
+[0-9a-f ]+R_MIPS_REL32      000cf2a4   sym_1_0465
+[0-9a-f ]+R_MIPS_REL32      000e0ee8   sym_2_8654
 #...
-0014070c  004e2c03 R_MIPS_REL32      000cf2b4   sym_1_0465
-00139bd0  004e2d03 R_MIPS_REL32      000e0ef8   sym_2_8654
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
-00000000  00000000 R_MIPS_NONE      
Index: ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d,v
retrieving revision 1.2
diff -u -p -r1.2 tlsdyn-o32-1.d
--- ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d	4 Feb 2006 08:28:29 -0000	1.2
+++ ld/testsuite/ld-mips-elf/tlsdyn-o32-1.d	16 Oct 2006 23:45:25 -0000
@@ -5,7 +5,7 @@ Disassembly of section .text:
 
 .* <__start>:
   .*:	3c1c0fc0 	lui	gp,0xfc0
-  .*:	279c7b70 	addiu	gp,gp,31600
+  .*:	279c7ba0 	addiu	gp,gp,31648
   .*:	0399e021 	addu	gp,gp,t9
   .*:	27bdfff0 	addiu	sp,sp,-16
   .*:	afbe0008 	sw	s8,8\(sp\)
@@ -55,7 +55,7 @@ Disassembly of section .text:
 
 .* <other>:
   .*:	3c1c0fc0 	lui	gp,0xfc0
-  .*:	279c7ab0 	addiu	gp,gp,31408
+  .*:	279c7ae0 	addiu	gp,gp,31456
   .*:	0399e021 	addu	gp,gp,t9
   .*:	27bdfff0 	addiu	sp,sp,-16
   .*:	afbe0008 	sw	s8,8\(sp\)
Index: ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got,v
retrieving revision 1.2
diff -u -p -r1.2 tlsdyn-o32-1.got
--- ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got	4 Feb 2006 08:28:29 -0000	1.2
+++ ld/testsuite/ld-mips-elf/tlsdyn-o32-1.got	16 Oct 2006 23:45:25 -0000
@@ -4,16 +4,16 @@
 DYNAMIC RELOCATION RECORDS
 OFFSET   TYPE              VALUE 
 00000000 R_MIPS_NONE       \*ABS\*
-10000044 R_MIPS_TLS_DTPMOD32  tlsbin_gd
-10000048 R_MIPS_TLS_DTPREL32  tlsbin_gd
-10000038 R_MIPS_TLS_DTPMOD32  tlsvar_gd
-1000003c R_MIPS_TLS_DTPREL32  tlsvar_gd
-10000040 R_MIPS_TLS_TPREL32  tlsvar_ie
-1000004c R_MIPS_TLS_TPREL32  tlsbin_ie
+10000054 R_MIPS_TLS_DTPMOD32  tlsbin_gd
+10000058 R_MIPS_TLS_DTPREL32  tlsbin_gd
+10000048 R_MIPS_TLS_DTPMOD32  tlsvar_gd
+1000004c R_MIPS_TLS_DTPREL32  tlsvar_gd
+10000050 R_MIPS_TLS_TPREL32  tlsvar_ie
+1000005c R_MIPS_TLS_TPREL32  tlsbin_ie
 
 
 Contents of section .got:
- 10000010 00000000 80000000 00000000 00000000  ................
- 10000020 00000000 00000000 00000000 0040053c  .............@..
- 10000030 00000001 00000000 00000000 00000000  ................
- 10000040 00000000 00000000 00000000 00000000  ................
+ 10000020 00000000 80000000 00000000 00000000  ................
+ 10000030 00000000 00000000 00000000 0040051c  .............@..
+ 10000040 00000001 00000000 00000000 00000000  ................
+ 10000050 00000000 00000000 00000000 00000000  ................
Index: ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d,v
retrieving revision 1.2
diff -u -p -r1.2 tlsdyn-o32-2.d
--- ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d	4 Feb 2006 08:28:29 -0000	1.2
+++ ld/testsuite/ld-mips-elf/tlsdyn-o32-2.d	16 Oct 2006 23:45:25 -0000
@@ -5,7 +5,7 @@ Disassembly of section .text:
 
 .* <__start>:
   .*:	3c1c0fc0 	lui	gp,0xfc0
-  .*:	279c7b70 	addiu	gp,gp,31600
+  .*:	279c7ba0 	addiu	gp,gp,31648
   .*:	0399e021 	addu	gp,gp,t9
   .*:	27bdfff0 	addiu	sp,sp,-16
   .*:	afbe0008 	sw	s8,8\(sp\)
@@ -55,7 +55,7 @@ Disassembly of section .text:
 
 .* <other>:
   .*:	3c1c0fc0 	lui	gp,0xfc0
-  .*:	279c7ab0 	addiu	gp,gp,31408
+  .*:	279c7ae0 	addiu	gp,gp,31456
   .*:	0399e021 	addu	gp,gp,t9
   .*:	27bdfff0 	addiu	sp,sp,-16
   .*:	afbe0008 	sw	s8,8\(sp\)
Index: ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got,v
retrieving revision 1.2
diff -u -p -r1.2 tlsdyn-o32-2.got
--- ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got	4 Feb 2006 08:28:29 -0000	1.2
+++ ld/testsuite/ld-mips-elf/tlsdyn-o32-2.got	16 Oct 2006 23:45:25 -0000
@@ -4,17 +4,17 @@
 DYNAMIC RELOCATION RECORDS
 OFFSET   TYPE              VALUE 
 00000000 R_MIPS_NONE       \*ABS\*
-10000048 R_MIPS_TLS_DTPMOD32  tlsbin_gd
-1000004c R_MIPS_TLS_DTPREL32  tlsbin_gd
-1000003c R_MIPS_TLS_DTPMOD32  tlsvar_gd
-10000040 R_MIPS_TLS_DTPREL32  tlsvar_gd
-10000044 R_MIPS_TLS_TPREL32  tlsvar_ie
-10000050 R_MIPS_TLS_TPREL32  tlsbin_ie
+10000058 R_MIPS_TLS_DTPMOD32  tlsbin_gd
+1000005c R_MIPS_TLS_DTPREL32  tlsbin_gd
+1000004c R_MIPS_TLS_DTPMOD32  tlsvar_gd
+10000050 R_MIPS_TLS_DTPREL32  tlsvar_gd
+10000054 R_MIPS_TLS_TPREL32  tlsvar_ie
+10000060 R_MIPS_TLS_TPREL32  tlsbin_ie
 
 
 Contents of section .got:
- 10000010 00000000 80000000 00000000 00000000  ................
- 10000020 00000000 00000000 00000000 00000000  ................
- 10000030 0040053c 00000001 00000000 00000000  .@.<............
- 10000040 00000000 00000000 00000000 00000000  ................
- 10000050 00000000 00000000 00000000 00000000  ................
+ 10000020 00000000 80000000 00000000 00000000  .*
+ 10000030 00000000 00000000 00000000 00000000  .*
+ 10000040 0040051c 00000001 00000000 00000000  .*
+ 10000050 00000000 00000000 00000000 00000000  .*
+ 10000060 00000000 00000000 00000000 00000000  .*
Index: ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d,v
retrieving revision 1.2
diff -u -p -r1.2 tlsdyn-o32-3.d
--- ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d	4 Feb 2006 08:28:29 -0000	1.2
+++ ld/testsuite/ld-mips-elf/tlsdyn-o32-3.d	16 Oct 2006 23:45:25 -0000
@@ -5,7 +5,7 @@ Disassembly of section .text:
 
 .* <other>:
   .*:	3c1c0fc0 	lui	gp,0xfc0
-  .*:	279c7b70 	addiu	gp,gp,31600
+  .*:	279c7ba0 	addiu	gp,gp,31648
   .*:	0399e021 	addu	gp,gp,t9
   .*:	27bdfff0 	addiu	sp,sp,-16
   .*:	afbe0008 	sw	s8,8\(sp\)
@@ -51,7 +51,7 @@ Disassembly of section .text:
 
 .* <__start>:
   .*:	3c1c0fc0 	lui	gp,0xfc0
-  .*:	279c7ac0 	addiu	gp,gp,31424
+  .*:	279c7af0 	addiu	gp,gp,31472
   .*:	0399e021 	addu	gp,gp,t9
   .*:	27bdfff0 	addiu	sp,sp,-16
   .*:	afbe0008 	sw	s8,8\(sp\)
Index: ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got,v
retrieving revision 1.2
diff -u -p -r1.2 tlsdyn-o32-3.got
--- ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got	4 Feb 2006 08:28:29 -0000	1.2
+++ ld/testsuite/ld-mips-elf/tlsdyn-o32-3.got	16 Oct 2006 23:45:25 -0000
@@ -4,17 +4,17 @@
 DYNAMIC RELOCATION RECORDS
 OFFSET   TYPE              VALUE 
 00000000 R_MIPS_NONE       \*ABS\*
-10000048 R_MIPS_TLS_DTPMOD32  tlsbin_gd
-1000004c R_MIPS_TLS_DTPREL32  tlsbin_gd
-1000003c R_MIPS_TLS_DTPMOD32  tlsvar_gd
-10000040 R_MIPS_TLS_DTPREL32  tlsvar_gd
-10000044 R_MIPS_TLS_TPREL32  tlsvar_ie
-10000050 R_MIPS_TLS_TPREL32  tlsbin_ie
+10000058 R_MIPS_TLS_DTPMOD32  tlsbin_gd
+1000005c R_MIPS_TLS_DTPREL32  tlsbin_gd
+1000004c R_MIPS_TLS_DTPMOD32  tlsvar_gd
+10000050 R_MIPS_TLS_DTPREL32  tlsvar_gd
+10000054 R_MIPS_TLS_TPREL32  tlsvar_ie
+10000060 R_MIPS_TLS_TPREL32  tlsbin_ie
 
 
 Contents of section .got:
- 10000010 00000000 80000000 00000000 00000000  ................
- 10000020 00000000 00000000 00000000 00000000  ................
- 10000030 004005ec 00000001 00000000 00000000  .@..............
- 10000040 00000000 00000000 00000000 00000000  ................
+ 10000020 00000000 80000000 00000000 00000000  ................
+ 10000030 00000000 00000000 00000000 00000000  ................
+ 10000040 004005cc 00000001 00000000 00000000  .@..............
  10000050 00000000 00000000 00000000 00000000  ................
+ 10000060 00000000 00000000 00000000 00000000  ................
Index: ld/testsuite/ld-mips-elf/tlsdyn-o32.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/tlsdyn-o32.d,v
retrieving revision 1.2
diff -u -p -r1.2 tlsdyn-o32.d
--- ld/testsuite/ld-mips-elf/tlsdyn-o32.d	4 Feb 2006 08:28:29 -0000	1.2
+++ ld/testsuite/ld-mips-elf/tlsdyn-o32.d	16 Oct 2006 23:45:25 -0000
@@ -5,7 +5,7 @@ Disassembly of section .text:
 
 .* <__start>:
   .*:	3c1c0fc0 	lui	gp,0xfc0
-  .*:	279c7bb0 	addiu	gp,gp,31664
+  .*:	279c7bc0 	addiu	gp,gp,31680
   .*:	0399e021 	addu	gp,gp,t9
   .*:	27bdfff0 	addiu	sp,sp,-16
   .*:	afbe0008 	sw	s8,8\(sp\)
Index: ld/testsuite/ld-mips-elf/tlsdyn-o32.got
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/tlsdyn-o32.got,v
retrieving revision 1.2
diff -u -p -r1.2 tlsdyn-o32.got
--- ld/testsuite/ld-mips-elf/tlsdyn-o32.got	4 Feb 2006 08:28:29 -0000	1.2
+++ ld/testsuite/ld-mips-elf/tlsdyn-o32.got	16 Oct 2006 23:45:25 -0000
@@ -4,16 +4,16 @@ tmpdir/tls-dynamic-o32:     file format 
 DYNAMIC RELOCATION RECORDS
 OFFSET   TYPE              VALUE 
 00000000 R_MIPS_NONE       \*ABS\*
-10000038 R_MIPS_TLS_DTPMOD32  tlsbin_gd
-1000003c R_MIPS_TLS_DTPREL32  tlsbin_gd
-10000048 R_MIPS_TLS_DTPMOD32  tlsvar_gd
-1000004c R_MIPS_TLS_DTPREL32  tlsvar_gd
-10000044 R_MIPS_TLS_TPREL32  tlsbin_ie
-10000040 R_MIPS_TLS_TPREL32  tlsvar_ie
+10000048 R_MIPS_TLS_DTPMOD32  tlsbin_gd
+1000004c R_MIPS_TLS_DTPREL32  tlsbin_gd
+10000058 R_MIPS_TLS_DTPMOD32  tlsvar_gd
+1000005c R_MIPS_TLS_DTPREL32  tlsvar_gd
+10000054 R_MIPS_TLS_TPREL32  tlsbin_ie
+10000050 R_MIPS_TLS_TPREL32  tlsvar_ie
 
 
 Contents of section .got:
- 10000010 00000000 80000000 00000000 00000000  ................
- 10000020 00000000 00000000 00000000 004004fc  ................
- 10000030 00000001 00000000 00000000 00000000  ................
- 10000040 00000000 00000000 00000000 00000000  ................
+ 10000020 00000000 80000000 00000000 00000000  ................
+ 10000030 00000000 00000000 00000000 004004fc  ................
+ 10000040 00000001 00000000 00000000 00000000  ................
+ 10000050 00000000 00000000 00000000 00000000  ................
Index: ld/testsuite/ld-mips-elf/tlslib-o32-hidden.got
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/tlslib-o32-hidden.got,v
retrieving revision 1.2
diff -u -p -r1.2 tlslib-o32-hidden.got
--- ld/testsuite/ld-mips-elf/tlslib-o32-hidden.got	4 Feb 2006 08:28:29 -0000	1.2
+++ ld/testsuite/ld-mips-elf/tlslib-o32-hidden.got	16 Oct 2006 23:45:25 -0000
@@ -4,13 +4,13 @@
 DYNAMIC RELOCATION RECORDS
 OFFSET   TYPE              VALUE 
 00000000 R_MIPS_NONE       \*ABS\*
-000403fc R_MIPS_TLS_DTPMOD32  \*ABS\*
-000403f4 R_MIPS_TLS_DTPMOD32  \*ABS\*
-000403f0 R_MIPS_TLS_TPREL32  \*ABS\*
+000403cc R_MIPS_TLS_DTPMOD32  \*ABS\*
+000403c4 R_MIPS_TLS_DTPMOD32  \*ABS\*
+000403c0 R_MIPS_TLS_TPREL32  \*ABS\*
 
 
 Contents of section .got:
- 403d0 00000000 80000000 00000000 00000000  ................
- 403e0 00000000 00000000 00000000 000003a0  ................
- 403f0 00000008 00000000 00000000 00000000  ................
- 40400 ffff8004                             ....            
+ 403a0 00000000 80000000 00000000 00000000  ................
+ 403b0 00000000 00000000 00000000 00000370  ................
+ 403c0 00000008 00000000 00000000 00000000  ................
+ 403d0 ffff8004                             ....            
Index: ld/testsuite/ld-mips-elf/tlslib-o32-ver.got
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/tlslib-o32-ver.got,v
retrieving revision 1.3
diff -u -p -r1.3 tlslib-o32-ver.got
--- ld/testsuite/ld-mips-elf/tlslib-o32-ver.got	13 Jul 2006 10:58:47 -0000	1.3
+++ ld/testsuite/ld-mips-elf/tlslib-o32-ver.got	16 Oct 2006 23:45:25 -0000
@@ -4,14 +4,14 @@
 DYNAMIC RELOCATION RECORDS
 OFFSET   TYPE              VALUE 
 00000000 R_MIPS_NONE       \*ABS\*
-00040544 R_MIPS_TLS_DTPMOD32  \*ABS\*
-0004054c R_MIPS_TLS_DTPMOD32  tlsvar_gd
-00040550 R_MIPS_TLS_DTPREL32  tlsvar_gd
-00040540 R_MIPS_TLS_TPREL32  tlsvar_ie
+00040514 R_MIPS_TLS_DTPMOD32  \*ABS\*
+0004051c R_MIPS_TLS_DTPMOD32  tlsvar_gd
+00040520 R_MIPS_TLS_DTPREL32  tlsvar_gd
+00040510 R_MIPS_TLS_TPREL32  tlsvar_ie
 
 
 Contents of section .got:
- 40520 00000000 80000000 00000000 00000000  ................
- 40530 00000000 00000000 00000000 000004f0  ................
- 40540 00000000 00000000 00000000 00000000  ................
- 40550 00000000                             ....            
+ 404f0 00000000 80000000 00000000 00000000  ................
+ 40500 00000000 00000000 00000000 000004c0  ................
+ 40510 00000000 00000000 00000000 00000000  ................
+ 40520 00000000                             ....            
Index: ld/testsuite/ld-mips-elf/tlslib-o32.got
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mips-elf/tlslib-o32.got,v
retrieving revision 1.3
diff -u -p -r1.3 tlslib-o32.got
--- ld/testsuite/ld-mips-elf/tlslib-o32.got	13 Jul 2006 10:58:47 -0000	1.3
+++ ld/testsuite/ld-mips-elf/tlslib-o32.got	16 Oct 2006 23:45:25 -0000
@@ -4,14 +4,14 @@ tmpdir/tlslib-o32.so:     file format el
 DYNAMIC RELOCATION RECORDS
 OFFSET   TYPE              VALUE 
 00000000 R_MIPS_NONE       \*ABS\*
-000404a4 R_MIPS_TLS_DTPMOD32  \*ABS\*
-000404ac R_MIPS_TLS_DTPMOD32  tlsvar_gd
-000404b0 R_MIPS_TLS_DTPREL32  tlsvar_gd
-000404a0 R_MIPS_TLS_TPREL32  tlsvar_ie
+00040474 R_MIPS_TLS_DTPMOD32  \*ABS\*
+0004047c R_MIPS_TLS_DTPMOD32  tlsvar_gd
+00040480 R_MIPS_TLS_DTPREL32  tlsvar_gd
+00040470 R_MIPS_TLS_TPREL32  tlsvar_ie
 
 
 Contents of section .got:
- 40480 00000000 80000000 00000000 00000000  ................
- 40490 00000000 00000000 00000000 00000450  ................
- 404a0 00000000 00000000 00000000 00000000  ................
- 404b0 00000000                             ....            
+ 40450 00000000 80000000 00000000 00000000  ................
+ 40460 00000000 00000000 00000000 00000420  ................
+ 40470 00000000 00000000 00000000 00000000  ................
+ 40480 00000000                             ....            
Index: ld/testsuite/ld-mmix/bpo-10.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-mmix/bpo-10.d,v
retrieving revision 1.10
diff -u -p -r1.10 bpo-10.d
--- ld/testsuite/ld-mmix/bpo-10.d	2 Jun 2006 00:32:00 -0000	1.10
+++ ld/testsuite/ld-mmix/bpo-10.d	16 Oct 2006 23:45:25 -0000
@@ -16,7 +16,7 @@ SYMBOL TABLE:
 2000000000000000 g       \*ABS\*	0+ __bss_start
 2000000000000000 g       \*ABS\*	0+ _edata
 2000000000000000 g       \*ABS\*	0+ _end
-0+4 g       \*ABS\*	0+ _start\.
+0+4 g       \.init	0+ _start\.
 
 Contents of section \.init:
  0000 e37704a6                             .*
Index: ld/testsuite/ld-powerpc/tlsso.g
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-powerpc/tlsso.g,v
retrieving revision 1.6
diff -u -p -r1.6 tlsso.g
--- ld/testsuite/ld-powerpc/tlsso.g	10 Jul 2006 21:40:25 -0000	1.6
+++ ld/testsuite/ld-powerpc/tlsso.g	16 Oct 2006 23:45:25 -0000
@@ -7,7 +7,7 @@
 .*: +file format elf64-powerpc
 
 Contents of section \.got:
-.* 00000000 000187b8 00000000 00000000  .*
+.* 00000000 00018780 00000000 00000000  .*
 .* 00000000 00000000 00000000 00000000  .*
 .* 00000000 00000000 00000000 00000000  .*
 .* 00000000 00000000 00000000 00000000  .*
Index: ld/testsuite/ld-powerpc/tlsso.r
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-powerpc/tlsso.r,v
retrieving revision 1.17
diff -u -p -r1.17 tlsso.r
--- ld/testsuite/ld-powerpc/tlsso.r	10 Jul 2006 21:40:25 -0000	1.17
+++ ld/testsuite/ld-powerpc/tlsso.r	16 Oct 2006 23:45:25 -0000
@@ -49,9 +49,9 @@ Relocation section '\.rela\.dyn' at offs
 [0-9a-f ]+R_PPC64_TPREL16 +0+60 le0 \+ 0
 [0-9a-f ]+R_PPC64_TPREL16_HA +0+68 le1 \+ 0
 [0-9a-f ]+R_PPC64_TPREL16_LO +0+68 le1 \+ 0
-[0-9a-f ]+R_PPC64_TPREL16_DS +0+10630 \.tdata \+ 28
-[0-9a-f ]+R_PPC64_TPREL16_HA +0+10630 \.tdata \+ 30
-[0-9a-f ]+R_PPC64_TPREL16_LO +0+10630 \.tdata \+ 30
+[0-9a-f ]+R_PPC64_TPREL16_DS +0+105f8 \.tdata \+ 28
+[0-9a-f ]+R_PPC64_TPREL16_HA +0+105f8 \.tdata \+ 30
+[0-9a-f ]+R_PPC64_TPREL16_LO +0+105f8 \.tdata \+ 30
 [0-9a-f ]+R_PPC64_DTPMOD64 +0+
 [0-9a-f ]+R_PPC64_DTPMOD64 +0+
 [0-9a-f ]+R_PPC64_DTPREL64 +0+
@@ -72,8 +72,6 @@ Symbol table '\.dynsym' contains .* entr
 .* NOTYPE +LOCAL +DEFAULT +UND 
 .* SECTION LOCAL +DEFAULT +6 
 .* SECTION LOCAL +DEFAULT +7 
-.* SECTION LOCAL +DEFAULT +8 
-.* SECTION LOCAL +DEFAULT +9 
 .* TLS +GLOBAL DEFAULT +UND gd
 .* TLS +GLOBAL DEFAULT +8 le0
 .* NOTYPE +GLOBAL DEFAULT +UND __tls_get_addr
Index: ld/testsuite/ld-powerpc/tlsso32.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-powerpc/tlsso32.d,v
retrieving revision 1.13
diff -u -p -r1.13 tlsso32.d
--- ld/testsuite/ld-powerpc/tlsso32.d	10 Jul 2006 21:40:25 -0000	1.13
+++ ld/testsuite/ld-powerpc/tlsso32.d	16 Oct 2006 23:45:25 -0000
@@ -42,5 +42,5 @@ Disassembly of section \.got:
 .* <\.got>:
 	\.\.\.
 .*:	4e 80 00 21 	blrl
-.*:	00 01 04 00 	.*
+.*:	00 01 03 ec 	.*
 	\.\.\.
Index: ld/testsuite/ld-powerpc/tlsso32.g
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-powerpc/tlsso32.g,v
retrieving revision 1.9
diff -u -p -r1.9 tlsso32.g
--- ld/testsuite/ld-powerpc/tlsso32.g	10 Jul 2006 21:40:25 -0000	1.9
+++ ld/testsuite/ld-powerpc/tlsso32.g	16 Oct 2006 23:45:25 -0000
@@ -9,5 +9,5 @@
 Contents of section \.got:
 .* 00000000 00000000 00000000 00000000  .*
 .* 00000000 00000000 00000000 00000000  .*
-.* 00000000 4e800021 00010400 00000000  .*
+.* 00000000 4e800021 000103ec 00000000  .*
 .* 00000000                             .*
Index: ld/testsuite/ld-powerpc/tlsso32.r
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-powerpc/tlsso32.r,v
retrieving revision 1.17
diff -u -p -r1.17 tlsso32.r
--- ld/testsuite/ld-powerpc/tlsso32.r	10 Jul 2006 21:40:25 -0000	1.17
+++ ld/testsuite/ld-powerpc/tlsso32.r	16 Oct 2006 23:45:25 -0000
@@ -52,9 +52,9 @@ Relocation section '\.rela\.dyn' at offs
 [0-9a-f ]+R_PPC_TPREL16 +0+30 +le0 \+ 0
 [0-9a-f ]+R_PPC_TPREL16_HA +0+34 +le1 \+ 0
 [0-9a-f ]+R_PPC_TPREL16_LO +0+34 +le1 \+ 0
-[0-9a-f ]+R_PPC_TPREL16 +0+103e4 +\.tdata \+ 103f8
-[0-9a-f ]+R_PPC_TPREL16_HA +0+103e4 +\.tdata \+ 103fc
-[0-9a-f ]+R_PPC_TPREL16_LO +0+103e4 +\.tdata \+ 103fc
+[0-9a-f ]+R_PPC_TPREL16 +0+103d0 +\.tdata \+ 103e4
+[0-9a-f ]+R_PPC_TPREL16_HA +0+103d0 +\.tdata \+ 103e8
+[0-9a-f ]+R_PPC_TPREL16_LO +0+103d0 +\.tdata \+ 103e8
 [0-9a-f ]+R_PPC_DTPMOD32 +0+
 [0-9a-f ]+R_PPC_DTPREL32 +0+
 [0-9a-f ]+R_PPC_DTPMOD32 +0+
@@ -73,7 +73,6 @@ Symbol table '\.dynsym' contains [0-9]+ 
 .* NOTYPE +LOCAL +DEFAULT +UND 
 .* SECTION LOCAL +DEFAULT +6 
 .* SECTION LOCAL +DEFAULT +7 
-.* SECTION LOCAL +DEFAULT +8 
 .* TLS +GLOBAL DEFAULT +UND gd
 .* TLS +GLOBAL DEFAULT +8 le0
 .* NOTYPE +GLOBAL DEFAULT +UND __tls_get_addr
Index: ld/testsuite/ld-powerpc/tlstocso.g
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-powerpc/tlstocso.g,v
retrieving revision 1.7
diff -u -p -r1.7 tlstocso.g
--- ld/testsuite/ld-powerpc/tlstocso.g	10 Jul 2006 21:40:25 -0000	1.7
+++ ld/testsuite/ld-powerpc/tlstocso.g	16 Oct 2006 23:45:25 -0000
@@ -7,7 +7,7 @@
 .*: +file format elf64-powerpc
 
 Contents of section \.got:
-.* 00000000 00018700 00000000 00000000  .*
+.* 00000000 000186c8 00000000 00000000  .*
 .* 00000000 00000000 00000000 00000000  .*
 .* 00000000 00000000 00000000 00000000  .*
 .* 00000000 00000000 00000000 00000000  .*
Index: ld/testsuite/ld-powerpc/tlstocso.r
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-powerpc/tlstocso.r,v
retrieving revision 1.17
diff -u -p -r1.17 tlstocso.r
--- ld/testsuite/ld-powerpc/tlstocso.r	2 Jun 2006 07:53:30 -0000	1.17
+++ ld/testsuite/ld-powerpc/tlstocso.r	16 Oct 2006 23:45:25 -0000
@@ -67,8 +67,6 @@ Symbol table '\.dynsym' contains [0-9]+ 
 .* NOTYPE +LOCAL +DEFAULT +UND 
 .* SECTION LOCAL +DEFAULT +6 
 .* SECTION LOCAL +DEFAULT +7 
-.* SECTION LOCAL +DEFAULT +8 
-.* SECTION LOCAL +DEFAULT +9 
 .* TLS +GLOBAL DEFAULT +UND gd
 .* TLS +GLOBAL DEFAULT +8 le0
 .* NOTYPE +GLOBAL DEFAULT +UND __tls_get_addr
Index: ld/testsuite/ld-s390/tlspic.rd
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-s390/tlspic.rd,v
retrieving revision 1.9
diff -u -p -r1.9 tlspic.rd
--- ld/testsuite/ld-s390/tlspic.rd	2 Jun 2006 00:32:00 -0000	1.9
+++ ld/testsuite/ld-s390/tlspic.rd	16 Oct 2006 23:45:25 -0000
@@ -73,7 +73,6 @@ Symbol table '.dynsym' contains [0-9]+ e
 .* NOTYPE  LOCAL  DEFAULT  UND 
 .* SECTION LOCAL  DEFAULT +7 
 .* SECTION LOCAL  DEFAULT +8 
-.* SECTION LOCAL  DEFAULT +9 
 .* TLS +GLOBAL DEFAULT +8 sg8
 .* TLS +GLOBAL DEFAULT +8 sg3
 .* TLS +GLOBAL DEFAULT +8 sg4
Index: ld/testsuite/ld-s390/tlspic_64.rd
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-s390/tlspic_64.rd,v
retrieving revision 1.8
diff -u -p -r1.8 tlspic_64.rd
--- ld/testsuite/ld-s390/tlspic_64.rd	2 Jun 2006 07:53:30 -0000	1.8
+++ ld/testsuite/ld-s390/tlspic_64.rd	16 Oct 2006 23:45:25 -0000
@@ -73,7 +73,6 @@ Symbol table '.dynsym' contains [0-9]+ e
 .* NOTYPE  LOCAL  DEFAULT  UND 
 .* SECTION LOCAL  DEFAULT +7 
 .* SECTION LOCAL  DEFAULT +8 
-.* SECTION LOCAL  DEFAULT +9 
 .* TLS +GLOBAL DEFAULT +8 sg8
 .* TLS +GLOBAL DEFAULT +8 sg3
 .* TLS +GLOBAL DEFAULT +8 sg4
Index: ld/testsuite/ld-scripts/empty-address-1.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-scripts/empty-address-1.d,v
retrieving revision 1.1
diff -u -p -r1.1 empty-address-1.d
--- ld/testsuite/ld-scripts/empty-address-1.d	27 Sep 2006 04:18:16 -0000	1.1
+++ ld/testsuite/ld-scripts/empty-address-1.d	16 Oct 2006 23:45:25 -0000
@@ -4,5 +4,5 @@
 0+0 T _start
 #...
 0+2000000 A __data_end
-0+2000000 D __data_start
+0+2000000 [ADT] __data_start
 #pass
Index: ld/testsuite/ld-scripts/empty-address-3c.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-scripts/empty-address-3c.d,v
retrieving revision 1.1
diff -u -p -r1.1 empty-address-3c.d
--- ld/testsuite/ld-scripts/empty-address-3c.d	27 Sep 2006 04:18:16 -0000	1.1
+++ ld/testsuite/ld-scripts/empty-address-3c.d	16 Oct 2006 23:45:25 -0000
@@ -6,5 +6,5 @@
 #...
 0+1010 A __data_end
 #...
-0+1010 D __data_start
+0+1010 [ADT] __data_start
 #pass
Index: ld/testsuite/ld-scripts/empty-orphan.t
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-scripts/empty-orphan.t,v
retrieving revision 1.2
diff -u -p -r1.2 empty-orphan.t
--- ld/testsuite/ld-scripts/empty-orphan.t	19 May 2006 06:10:03 -0000	1.2
+++ ld/testsuite/ld-scripts/empty-orphan.t	16 Oct 2006 23:45:25 -0000
@@ -17,6 +17,6 @@ SECTIONS
    .text : { *(.text) } > text_mem : text_phdr
    .data : { *(.data) } > data_mem : data_phdr
    .bss : { *(.bss) } > data_mem : data_phdr
-   /DISCARD/ : { *(.reginfo) }
+   /DISCARD/ : { *(.reginfo) *(.glue*) }
    /* .orphan_data is an orphan */
 }
Index: ld/testsuite/ld-sh/shared-1.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-sh/shared-1.d,v
retrieving revision 1.9
diff -u -p -r1.9 shared-1.d
--- ld/testsuite/ld-sh/shared-1.d	15 Aug 2005 15:39:48 -0000	1.9
+++ ld/testsuite/ld-sh/shared-1.d	16 Oct 2006 23:45:25 -0000
@@ -13,10 +13,10 @@
 
 Relocation section '\.rela\.text' at offset 0x[0-9a-f]+ contains 1 entries:
 .*
-000001b0  000000a5 R_SH_RELATIVE +000001b4
+0000019c +[0-9a-f]+ R_SH_RELATIVE +000001a0
 
 Hex dump of section '\.rela\.text':
-  0x0000019c          000001b4 000000a5 000001b0 .*
+  0x00000188          000001a0 000000a5 0000019c .*
 
 Hex dump of section '\.text':
-  0x000001a8          000001b4 00090009 00090009 .*
+  0x00000194          000001a0 00090009 00090009 .*
Index: ld/testsuite/ld-sh/tlspic-2.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-sh/tlspic-2.d,v
retrieving revision 1.11
diff -u -p -r1.11 tlspic-2.d
--- ld/testsuite/ld-sh/tlspic-2.d	29 Sep 2006 12:37:28 -0000	1.11
+++ ld/testsuite/ld-sh/tlspic-2.d	16 Oct 2006 23:45:25 -0000
@@ -68,10 +68,6 @@ Relocation section '\.rela\.plt' at offs
 Symbol table '\.dynsym' contains [0-9]+ entries:
  +Num: +Value +Size Type +Bind +Vis +Ndx Name
 .* NOTYPE +LOCAL +DEFAULT  UND *
-.* SECTION LOCAL  DEFAULT +7 *
-.* SECTION LOCAL  DEFAULT +8 *
-.* SECTION LOCAL  DEFAULT +9 *
-.* SECTION LOCAL  DEFAULT +11 *
 .* NOTYPE  GLOBAL DEFAULT  UND __tls_get_addr
 .* TLS +GLOBAL DEFAULT +8 sg1
 #...
Index: ld/testsuite/ld-sparc/tlssunbin32.rd
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-sparc/tlssunbin32.rd,v
retrieving revision 1.8
diff -u -p -r1.8 tlssunbin32.rd
--- ld/testsuite/ld-sparc/tlssunbin32.rd	2 Jun 2006 00:32:00 -0000	1.8
+++ ld/testsuite/ld-sparc/tlssunbin32.rd	16 Oct 2006 23:45:25 -0000
@@ -88,7 +88,7 @@ Symbol table '.symtab' contains 64 entri
 .* TLS +LOCAL +DEFAULT +8 bl7
 .* TLS +LOCAL +DEFAULT +8 bl8
 .* OBJECT +LOCAL +HIDDEN +9 _DYNAMIC
-.* OBJECT +LOCAL +HIDDEN +ABS _PROCEDURE_LINKAGE_TABLE_
+.* OBJECT +LOCAL +HIDDEN +10 _PROCEDURE_LINKAGE_TABLE_
 .* OBJECT +LOCAL +HIDDEN +10 _GLOBAL_OFFSET_TABLE_
 .* TLS +GLOBAL DEFAULT +7 sg8
 .* TLS +GLOBAL DEFAULT +8 bg8
Index: ld/testsuite/ld-sparc/tlssunbin64.rd
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-sparc/tlssunbin64.rd,v
retrieving revision 1.5
diff -u -p -r1.5 tlssunbin64.rd
--- ld/testsuite/ld-sparc/tlssunbin64.rd	2 Jun 2006 00:32:00 -0000	1.5
+++ ld/testsuite/ld-sparc/tlssunbin64.rd	16 Oct 2006 23:45:25 -0000
@@ -88,7 +88,7 @@ Symbol table '.symtab' contains 64 entri
 .* TLS +LOCAL +DEFAULT +8 bl7
 .* TLS +LOCAL +DEFAULT +8 bl8
 .* OBJECT +LOCAL +HIDDEN +9 _DYNAMIC
-.* OBJECT +LOCAL +HIDDEN +ABS _PROCEDURE_LINKAGE_TABLE_
+.* OBJECT +LOCAL +HIDDEN +10 _PROCEDURE_LINKAGE_TABLE_
 .* OBJECT +LOCAL +HIDDEN +10 _GLOBAL_OFFSET_TABLE_
 .* TLS +GLOBAL DEFAULT +7 sg8
 .* TLS +GLOBAL DEFAULT +8 bg8
Index: ld/testsuite/ld-sparc/tlssunpic32.rd
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-sparc/tlssunpic32.rd,v
retrieving revision 1.7
diff -u -p -r1.7 tlssunpic32.rd
--- ld/testsuite/ld-sparc/tlssunpic32.rd	2 Jun 2006 00:32:00 -0000	1.7
+++ ld/testsuite/ld-sparc/tlssunpic32.rd	16 Oct 2006 23:45:26 -0000
@@ -64,7 +64,6 @@ Symbol table '.dynsym' contains [0-9]+ e
 .* NOTYPE +LOCAL +DEFAULT +UND *
 .* SECTION LOCAL +DEFAULT +6 *
 .* SECTION LOCAL +DEFAULT +7 *
-.* SECTION LOCAL +DEFAULT +8 *
 .* SECTION LOCAL +DEFAULT +10 *
 .* TLS +GLOBAL DEFAULT +7 sg8
 .* TLS +GLOBAL DEFAULT +7 sg3
Index: ld/testsuite/ld-sparc/tlssunpic64.rd
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-sparc/tlssunpic64.rd,v
retrieving revision 1.4
diff -u -p -r1.4 tlssunpic64.rd
--- ld/testsuite/ld-sparc/tlssunpic64.rd	2 Jun 2006 00:32:00 -0000	1.4
+++ ld/testsuite/ld-sparc/tlssunpic64.rd	16 Oct 2006 23:45:26 -0000
@@ -64,7 +64,6 @@ Symbol table '.dynsym' contains [0-9]+ e
 .* NOTYPE +LOCAL +DEFAULT +UND *
 .* SECTION LOCAL +DEFAULT +6 *
 .* SECTION LOCAL +DEFAULT +7 *
-.* SECTION LOCAL +DEFAULT +8 *
 .* SECTION LOCAL +DEFAULT +10 *
 .* TLS +GLOBAL DEFAULT +7 sg8
 .* TLS +GLOBAL DEFAULT +7 sg3
Index: ld/testsuite/ld-x86-64/tlsdesc.pd
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-x86-64/tlsdesc.pd,v
retrieving revision 1.3
diff -u -p -r1.3 tlsdesc.pd
--- ld/testsuite/ld-x86-64/tlsdesc.pd	30 Jun 2006 14:16:13 -0000	1.3
+++ ld/testsuite/ld-x86-64/tlsdesc.pd	16 Oct 2006 23:45:26 -0000
@@ -9,12 +9,12 @@
 
 Disassembly of section .plt:
 
-0000000000000470 <.*@plt-0x10>:
- 470:	ff 35 e2 0e 20 00    	pushq  2100962\(%rip\)        # 201358 <_GLOBAL_OFFSET_TABLE_\+0x8>
- 476:	ff 25 e4 0e 20 00    	jmpq   \*2100964\(%rip\)        # 201360 <_GLOBAL_OFFSET_TABLE_\+0x10>
- 47c:	0f 1f 40 00          	nopl   0x0\(%rax\)
-0000000000000480 <.*@plt>:
- 480:	ff 35 d2 0e 20 00    	pushq  2100946\(%rip\)        # 201358 <_GLOBAL_OFFSET_TABLE_\+0x8>
- 486:	ff 25 bc 0e 20 00    	jmpq   \*2100924\(%rip\)        # 201348 <_DYNAMIC\+0x190>
- 48c:	0f 1f 40 00          	nopl   0x0\(%rax\)
+[0-9a-f]+ <.*@plt-0x10>:
+ [0-9a-f]+:	ff 35 .. .. 20 00    	pushq  .*\(%rip\)        # 201358 <_GLOBAL_OFFSET_TABLE_\+0x8>
+ [0-9a-f]+:	ff 25 .. .. 20 00    	jmpq   \*.*\(%rip\)        # 201360 <_GLOBAL_OFFSET_TABLE_\+0x10>
+ [0-9a-f]+:	0f 1f 40 00          	nopl   0x0\(%rax\)
+[0-9a-f]+ <.*@plt>:
+ [0-9a-f]+:	ff 35 .. .. 20 00    	pushq  .*\(%rip\)        # 201358 <_GLOBAL_OFFSET_TABLE_\+0x8>
+ [0-9a-f]+:	ff 25 .. .. 20 00    	jmpq   \*.*\(%rip\)        # 201348 <_DYNAMIC\+0x190>
+ [0-9a-f]+:	0f 1f 40 00          	nopl   0x0\(%rax\)
 
Index: ld/testsuite/ld-x86-64/tlsdesc.rd
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-x86-64/tlsdesc.rd,v
retrieving revision 1.5
diff -u -p -r1.5 tlsdesc.rd
--- ld/testsuite/ld-x86-64/tlsdesc.rd	2 Jun 2006 00:32:00 -0000	1.5
+++ ld/testsuite/ld-x86-64/tlsdesc.rd	16 Oct 2006 23:45:26 -0000
@@ -15,7 +15,7 @@ Section Headers:
   \[ 3\] .dynstr +.*
   \[ 4\] .rela.dyn +.*
   \[ 5\] .rela.plt +.*
-  \[ 6\] .plt +PROGBITS +0+470 0+470 0+20 10 +AX +0 +0 +4
+  \[ 6\] .plt +PROGBITS +0+450 0+450 0+20 10 +AX +0 +0 +4
   \[ 7\] .text +PROGBITS +0+1000 0+1000 0+154 00 +AX +0 +0 4096
   \[ 8\] .tdata +PROGBITS +0+201154 0+1154 0+60 00 WAT +0 +0 +1
   \[ 9\] .tbss +NOBITS +0+2011b4 0+11b4 0+20 00 WAT +0 +0 +1
@@ -59,7 +59,7 @@ Dynamic section at offset 0x[0-9a-f]+ co
  0x[0-9a-f]+ +\(PLTRELSZ\).*
  0x[0-9a-f]+ +\(PLTREL\).*
  0x[0-9a-f]+ +\(JMPREL\).*
- 0x[0-9a-f]+ +\(TLSDESC_PLT\) +0x480
+ 0x[0-9a-f]+ +\(TLSDESC_PLT\) +0x460
  0x[0-9a-f]+ +\(TLSDESC_GOT\) +0x201348
  0x[0-9a-f]+ +\(RELA\).*
  0x[0-9a-f]+ +\(RELASZ\).*
@@ -69,29 +69,28 @@ Dynamic section at offset 0x[0-9a-f]+ co
 
 Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 8 entries:
  +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
-0+201308  0+12 R_X86_64_TPOFF64 +0+24
-0+201310  0+12 R_X86_64_TPOFF64 +0+30
-0+201318  0+12 R_X86_64_TPOFF64 +0+64
-0+201328  0+12 R_X86_64_TPOFF64 +0+50
-0+201330  0+12 R_X86_64_TPOFF64 +0+70
-0+201340  0+12 R_X86_64_TPOFF64 +0+44
-0+201320  0+700000012 R_X86_64_TPOFF64 +0+10 sg5 \+ 0
-0+201338  0+b00000012 R_X86_64_TPOFF64 +0+4 sg2 \+ 0
+0+201308  [0-9a-f]+ R_X86_64_TPOFF64 +0+24
+0+201310  [0-9a-f]+ R_X86_64_TPOFF64 +0+30
+0+201318  [0-9a-f]+ R_X86_64_TPOFF64 +0+64
+0+201328  [0-9a-f]+ R_X86_64_TPOFF64 +0+50
+0+201330  [0-9a-f]+ R_X86_64_TPOFF64 +0+70
+0+201340  [0-9a-f]+ R_X86_64_TPOFF64 +0+44
+0+201320  [0-9a-f]+ R_X86_64_TPOFF64 +0+10 sg5 \+ 0
+0+201338  [0-9a-f]+ R_X86_64_TPOFF64 +0+4 sg2 \+ 0
 
 Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 5 entries:
  +Offset +Info +Type +Symbol's Value  Symbol's Name \+ Addend
-0+201398  0+800000024 R_X86_64_TLSDESC +0+ sg1 \+ 0
-0+201368  0+24 R_X86_64_TLSDESC +0+20
-0+2013a8  0+24 R_X86_64_TLSDESC +0+40
-0+201378  0+24 R_X86_64_TLSDESC +0+60
-0+201388  0+24 R_X86_64_TLSDESC +0+
+0+201398  [0-9a-f]+ R_X86_64_TLSDESC +0+ sg1 \+ 0
+0+201368  [0-9a-f]+ R_X86_64_TLSDESC +0+20
+0+2013a8  [0-9a-f]+ R_X86_64_TLSDESC +0+40
+0+201378  [0-9a-f]+ R_X86_64_TLSDESC +0+60
+0+201388  [0-9a-f]+ R_X86_64_TLSDESC +0+
 
-Symbol table '.dynsym' contains 16 entries:
+Symbol table '.dynsym' contains [0-9]+ entries:
  +Num: +Value +Size Type +Bind +Vis +Ndx Name
  +[0-9]+: 0+ +0 NOTYPE  LOCAL  DEFAULT  UND *
  +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL  DEFAULT +7 *
  +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL  DEFAULT +8 *
- +[0-9]+: [0-9a-f]+ +0 SECTION LOCAL  DEFAULT +9 *
  +[0-9]+: 0+1c +0 TLS +GLOBAL DEFAULT +8 sg8
  +[0-9]+: 0+8 +0 TLS +GLOBAL DEFAULT +8 sg3
  +[0-9]+: 0+c +0 TLS +GLOBAL DEFAULT +8 sg4
Index: ld/testsuite/ld-x86-64/tlspic.rd
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-x86-64/tlspic.rd,v
retrieving revision 1.11
diff -u -p -r1.11 tlspic.rd
--- ld/testsuite/ld-x86-64/tlspic.rd	2 Jun 2006 00:32:00 -0000	1.11
+++ ld/testsuite/ld-x86-64/tlspic.rd	16 Oct 2006 23:45:26 -0000
@@ -74,7 +74,6 @@ Symbol table '.dynsym' contains [0-9]+ e
 .* NOTYPE  LOCAL  DEFAULT  UND *
 .* SECTION LOCAL  DEFAULT +7 *
 .* SECTION LOCAL  DEFAULT +8 *
-.* SECTION LOCAL  DEFAULT +9 *
 .* TLS +GLOBAL DEFAULT +8 sg8
 .* TLS +GLOBAL DEFAULT +8 sg3
 .* TLS +GLOBAL DEFAULT +8 sg4

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

* Re: Dynamic section symbols, ignored output sections
  2006-10-17 16:02                                   ` Dynamic section symbols, ignored output sections Alan Modra
@ 2006-10-19 14:55                                     ` ligang
  2006-10-22  0:25                                     ` Jakub Jelinek
  1 sibling, 0 replies; 43+ messages in thread
From: ligang @ 2006-10-19 14:55 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

Alan Modra <amodra@bigpond.net.au> wrote on 2006-10-17 21:24:27:

> On Thu, Oct 12, 2006 at 01:13:41PM +0930, Alan Modra wrote:
> > a) Detecting a symbol assignment in a linker script should result in 
the
> >    section alignment and vma being honoured.
> > b) All the ELF backends will need changes so that removed output 
section
> >    syms are never used when emitting relocs.  At the same time, we may
> >    as well just use one section sym for all relocs (or two for targets
> >    that might want to relocate the data segment separately from the 
text
> >    segment).
> > c) _bfd_fix_excluded_sec_syms should be changed to not create absolute
> >    syms.
> 
> This patch does all of the above, plus adjusts the ld testsuite for
> the changes.  A number of ELF targets will now use no dynamic section
> symbols while others will just use one (or two when TLS is involved).
> I started looking at FRV, and decided to leave the dyn sym change to a
> target maintainer because it seemed likely to me that I'd break
> something..  I also won't commit the S+core patch included here until
> I get the OK from Mei Ligang;  It changes elf32-score.c to use the
> zero index symbol on dynamic relocations rather than use section
> symbols.  This is desirable on a new target as it should speed ld.so
> slightly, but of course the dynamic linker support needs to be
> available.
 
It is OK.
 
> Alan Modra
> IBM OzLabs - Linux Technology Centre

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

* Re: Dynamic section symbols, ignored output sections
  2006-10-17 16:02                                   ` Dynamic section symbols, ignored output sections Alan Modra
  2006-10-19 14:55                                     ` ligang
@ 2006-10-22  0:25                                     ` Jakub Jelinek
  2006-10-23 14:13                                       ` Alan Modra
  1 sibling, 1 reply; 43+ messages in thread
From: Jakub Jelinek @ 2006-10-22  0:25 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

On Tue, Oct 17, 2006 at 10:54:27PM +0930, Alan Modra wrote:
> This patch does all of the above, plus adjusts the ld testsuite for
> the changes.

Thanks a lot for this, seems to work fine here.

Only a minor nit, IMHO using the preceeding section isn't always
the best choice.  E.g. .init_array etc. sections usually start the
RW segment (unless there is .tdata or .tbss) and those are often zero sized,
yet contain __init_array_{start,end} etc. symbols.  With current CVS
binutils those symbols are attached to the preceeding section, which
is typically in the RX segment many KBs/MBs away, while there is
usually a section right after the removed .init_array which is kept.
The following patch prefers to use the next section if symbol's value
is not within the preceeding section (or equal to its end) and if
there is a following section that starts at vma equal to symbol value.
Is this ok for trunk or do you prefer to always choose the preceeding
section?

2006-10-21  Jakub Jelinek  <jakub@redhat.com>

	* linker.c (fix_syms): Base symbols in removed sections on
	next section if it has the same vma as the symbol value.

--- bfd/linker.c.jj	2006-10-21 12:55:56.000000000 +0200
+++ bfd/linker.c	2006-10-21 21:31:34.000000000 +0200
@@ -3093,6 +3093,7 @@ fix_syms (struct bfd_link_hash_entry *h,
 	  && bfd_section_removed_from_list (obfd, s->output_section))
 	{
 	  asection *op;
+	  h->u.def.value += s->output_offset + s->output_section->vma;
 	  for (op = s->output_section->prev; op != NULL; op = op->prev)
 	    if ((op->flags & SEC_EXCLUDE) == 0
 		&& !bfd_section_removed_from_list (obfd, op))
@@ -3110,7 +3111,21 @@ fix_syms (struct bfd_link_hash_entry *h,
 	      if (op == NULL)
 		op = bfd_abs_section_ptr;
 	    }
-	  h->u.def.value += s->output_offset + s->output_section->vma;
+	  else if (h->u.def.value > op->vma + op->size)
+	    {
+	      /* If symbol value is equal to the start of the next
+		 section, prefer the next section.  */
+	      asection *op2 = s->output_section->prev->next;
+	      for (; op2 != NULL; op2 = op2->next)
+		if (op2->vma != h->u.def.value)
+		  break;
+		else if ((op2->flags & SEC_EXCLUDE) == 0
+			 && !bfd_section_removed_from_list (obfd, op2))
+		  {
+		    op = op2;
+		    break;
+		  }
+	    }
 	  h->u.def.value -= op->vma;
 	  h->u.def.section = op;
 	}

	Jakub

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

* Re: Dynamic section symbols, ignored output sections
  2006-10-22  0:25                                     ` Jakub Jelinek
@ 2006-10-23 14:13                                       ` Alan Modra
  0 siblings, 0 replies; 43+ messages in thread
From: Alan Modra @ 2006-10-23 14:13 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: binutils

On Sat, Oct 21, 2006 at 09:41:54PM +0200, Jakub Jelinek wrote:
> On Tue, Oct 17, 2006 at 10:54:27PM +0930, Alan Modra wrote:
> > This patch does all of the above, plus adjusts the ld testsuite for
> > the changes.
> 
> Thanks a lot for this, seems to work fine here.
> 
> Only a minor nit, IMHO using the preceeding section isn't always
> the best choice.

Yes, I was lazy.

>  E.g. .init_array etc. sections usually start the
> RW segment (unless there is .tdata or .tbss) and those are often zero sized,
> yet contain __init_array_{start,end} etc. symbols.  With current CVS
> binutils those symbols are attached to the preceeding section, which
> is typically in the RX segment many KBs/MBs away, while there is
> usually a section right after the removed .init_array which is kept.
> The following patch prefers to use the next section if symbol's value
> is not within the preceeding section (or equal to its end) and if
> there is a following section that starts at vma equal to symbol value.
> Is this ok for trunk or do you prefer to always choose the preceeding
> section?

Hmm.  I prefer something different.  :-)  What we really want is to
choose a section in the same segment as the removed section would
have been if it was kept.  Also, I think it a good idea to avoid
changing a symbol from a TLS section to non-TLS and vice versa.
We can make a reasonable guess about section to segment mapping from
the section flags.

	* linker.c (fix_syms): Choose best of previous and next
	section based on section flags and vma.

Index: bfd/linker.c
===================================================================
RCS file: /cvs/src/src/bfd/linker.c,v
retrieving revision 1.55
diff -u -p -r1.55 linker.c
--- bfd/linker.c	17 Oct 2006 13:41:47 -0000	1.55
+++ bfd/linker.c	23 Oct 2006 02:32:09 -0000
@@ -3092,25 +3092,62 @@ fix_syms (struct bfd_link_hash_entry *h,
 	  && (s->output_section->flags & SEC_EXCLUDE) != 0
 	  && bfd_section_removed_from_list (obfd, s->output_section))
 	{
-	  asection *op;
-	  for (op = s->output_section->prev; op != NULL; op = op->prev)
+	  asection *op, *op1;
+
+	  h->u.def.value += s->output_offset + s->output_section->vma;
+
+	  /* Find preceding kept section.  */
+	  for (op1 = s->output_section->prev; op1 != NULL; op1 = op1->prev)
+	    if ((op1->flags & SEC_EXCLUDE) == 0
+		&& !bfd_section_removed_from_list (obfd, op1))
+	      break;
+
+	  /* Find following kept section.  Start at prev->next because
+	     other sections may have been added after S was removed.  */
+	  if (s->output_section->prev != NULL)
+	    op = s->output_section->prev->next;
+	  else
+	    op = s->output_section->owner->sections;
+	  for (; op != NULL; op = op->next)
 	    if ((op->flags & SEC_EXCLUDE) == 0
 		&& !bfd_section_removed_from_list (obfd, op))
 	      break;
-	  if (op == NULL)
+
+	  /* Choose better of two sections, based on flags.  The idea
+	     is to choose a section that will be in the same segment
+	     as S would have been if it was kept.  */
+	  if (op1 == NULL)
 	    {
-	      if (s->output_section->prev != NULL)
-		op = s->output_section->prev->next;
-	      else
-		op = s->output_section->owner->sections;
-	      for (; op != NULL; op = op->next)
-		if ((op->flags & SEC_EXCLUDE) == 0
-		    && !bfd_section_removed_from_list (obfd, op))
-		  break;
 	      if (op == NULL)
 		op = bfd_abs_section_ptr;
 	    }
-	  h->u.def.value += s->output_offset + s->output_section->vma;
+	  else if (op == NULL)
+	    op = op1;
+	  else if (((op1->flags ^ op->flags)
+		    & (SEC_ALLOC | SEC_THREAD_LOCAL)) != 0)
+	    {
+	      if (((op->flags ^ s->flags)
+		   & (SEC_ALLOC | SEC_THREAD_LOCAL)) != 0)
+		op = op1;
+	    }
+	  else if (((op1->flags ^ op->flags) & SEC_READONLY) != 0)
+	    {
+	      if (((op->flags ^ s->flags) & SEC_READONLY) != 0)
+		op = op1;
+	    }
+	  else if (((op1->flags ^ op->flags) & SEC_CODE) != 0)
+	    {
+	      if (((op->flags ^ s->flags) & SEC_CODE) != 0)
+		op = op1;
+	    }
+	  else
+	    {
+	      /* Flags we care about are the same.  Prefer the following
+		 section if that will result in a positive valued sym.  */
+	      if (h->u.def.value < op->vma)
+		op = op1;
+	    }
+
 	  h->u.def.value -= op->vma;
 	  h->u.def.section = op;
 	}

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

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

end of thread, other threads:[~2006-10-23  2:35 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-26 14:33 Linker Bug or Design Intent (Absolute symbols in zero sized sections) Vivek Goyal
2006-09-26 14:49 ` H. J. Lu
2006-09-26 14:52   ` Vivek Goyal
2006-09-26 15:13     ` H. J. Lu
2006-09-26 15:41       ` Daniel Jacobowitz
2006-09-26 15:54         ` Vivek Goyal
2006-09-26 16:21           ` H. J. Lu
2006-09-26 16:30             ` Vivek Goyal
2006-09-26 16:44               ` H. J. Lu
2006-09-26 16:45                 ` Vivek Goyal
2006-09-26 17:01                 ` Daniel Jacobowitz
2006-09-26 23:50                   ` Alan Modra
2006-09-27  1:51                     ` Daniel Jacobowitz
2006-09-27  3:09                       ` Daniel Jacobowitz
2006-09-26 17:48                 ` Paul Koning
2006-09-26 23:53                   ` Alan Modra
2006-09-28 17:01                     ` Paul Brook
2006-09-28 17:05                       ` Paul Brook
2006-09-28 18:37                       ` H. J. Lu
2006-09-28 18:53                         ` H. J. Lu
2006-10-10 16:41                         ` Jakub Jelinek
2006-10-10 16:51                           ` Jakub Jelinek
2006-10-11  3:52                           ` Jakub Jelinek
2006-10-11  7:12                             ` Jakub Jelinek
2006-10-11  8:04                             ` Alan Modra
2006-10-11 14:08                               ` Alan Modra
2006-10-11 14:19                               ` Jakub Jelinek
2006-10-11 14:45                                 ` Jakub Jelinek
2006-10-12 10:18                                 ` Alan Modra
2006-10-12 14:37                                   ` Alan Modra
2006-10-13 10:58                                   ` Jakub Jelinek
2006-10-13 11:10                                     ` Alan Modra
2006-10-13 11:26                                       ` Alan Modra
2006-10-17 16:02                                   ` Dynamic section symbols, ignored output sections Alan Modra
2006-10-19 14:55                                     ` ligang
2006-10-22  0:25                                     ` Jakub Jelinek
2006-10-23 14:13                                       ` Alan Modra
2006-09-29  6:42                       ` Linker Bug or Design Intent (Absolute symbols in zero sized sections) Alan Modra
2006-09-29  8:06                         ` Alan Modra
2006-09-26 16:14         ` H. J. Lu
2006-09-26 16:40           ` Vivek Goyal
2006-09-26 17:57           ` Vivek Goyal
2006-09-26 20:23             ` H. J. Lu

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