bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ld 2.16 bug in linker script ?


From: Alan Modra
Subject: Re: ld 2.16 bug in linker script ?
Date: Mon, 17 Oct 2005 16:00:11 +0930
User-agent: Mutt/1.4i

On Tue, Oct 11, 2005 at 07:27:45PM +0200, Philippe Biondi wrote:
> On Mon, 10 Oct 2005, Alan Modra wrote:
> 
> >On Sun, Oct 09, 2005 at 05:28:15PM +0200, Philippe Biondi wrote:
> >>but I think these two linker scripts should be equivalent.
> >
> >No, you haven't specified where .got should go (*).  ld is free to place
> >unspecified sections where it likes.
> >
> >*) Which is quite foolish, given that you defined a symbol that belongs
> >in .got, __GLOBAL_OFFSET_TABLE__.
> 
> For me _GLOBAL_OFFSET_TABLE_ is only a linker symbol. It will not be 
> present in the GOT. I don't understand why setting its value to "." would 
> not be taken into account (maybe is it a special symbol ?).

Yes, it's used when accessing constants and addresses placed in the .got
section.  If it isn't defined in the right place, access to the .got
will likely not work correctly.

> And I don't 
> see any semantic difference between the 2 linker scripts, so that I'm a 
> bit confused they are interpreted differently.

The difference is that .got is placed before the __GLOBAL_OFFSET_TABLE__
assignment in one case, and placed after it in the other.

> As a side note, this script also fails to work as I would expect (but I'm 
> not an expert on this) :
> 
> SECTIONS {
>         /DISCARD/ : {
>                 *(.stab*)
>                 *(.comment)
>                 *(.note)
>         }
>         _GLOBAL_OFFSET_TABLE_ = .;
>         all : {*(.got, .text, .rodata, .rdata, .data, .bss) }
> }

Not surprising.  You've mixed all .got, .text, .rodata etc. sections
together.  See "Input Section Basics" in the ld info file.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre




reply via email to

[Prev in Thread] Current Thread [Next in Thread]