This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: PR ld/3223: ld fails to link correct variables from linker script
On Tue, Sep 26, 2006 at 05:41:25PM -0700, H. J. Lu wrote:
> On Wed, Sep 27, 2006 at 09:20:32AM +0930, Alan Modra wrote:
> > On Tue, Sep 26, 2006 at 06:54:14AM -0700, H. J. Lu wrote:
> > > On Tue, Sep 26, 2006 at 08:11:57PM +0930, Alan Modra wrote:
> > > > I think it is quite reasonable to remove empty output sections, even
> > > > those used to define symbols via the linker script (the symbols
> > > > become absolute). The case for ignoring linker script VMA and LMA
> > > > assignments isn't so strong, particularly since doing so can affect
> > > > following sections. I think it would be safest if we went back to
> > > > always obeying them, even for ALIGN expressions. Alternatively, we
> > > > could completely ignore the VMA and LMA assignments on empty output
> > > > sections. I agree that the current situation, where we take note of
> > > > the VMA only within the section, is silly.
> > >
> > > Obey ALIGN expressions on empty output sections will break x86-64. I
> > > noticed that when I was building glibc on x86-64.
> >
> > How does it break, and why? If you were using an older linker that
>
> I will take a look at why after I come back from my vacation.
>
> > didn't remove empty output sections, then of course the linker would
> > obey the ALIGN expression in a section VMA.
>
> But the older linker doesn't have
>
> .ldata ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE)
> - 1)) : {
> *(.ldata .ldata.* .gnu.linkonce.l.*)
> . = ALIGN(. != 0 ? 64 / 8 : 1);
> }
> . = ALIGN(64 / 8);
> _end = .; PROVIDE (end = .);
This VMA expression is more than just a simple ALIGN. Ideally, I guess
you'd like the linker to *not* take notice of the VMA in this case if
.ldata turned out to be empty, as obeying the VMA expression puts _end
MAXPAGESIZE past the actual end.
I still think that special cases for certain types of VMA expression
is bad design. Obey them all, or ignore all VMAs on empty output
sections.
--
Alan Modra
IBM OzLabs - Linux Technology Centre