loadaddr forward ref problem

Alan Modra amodra@bigpond.net.au
Thu Mar 1 22:40:00 GMT 2007


On Thu, Mar 01, 2007 at 02:03:10PM +0000, Nathan Sidwell wrote:
> Should we accept the following linker script?
> 
> SECTIONS
> {
>   .text :
>   {
>     _start  = .;
>     LONG (__data_load)
>   }
>   .data :
>   {
>     __data_load = LOADADDR (.data);
>   }
> }

In an ideal world I guess we would accept this.  We should know the
vma and lma at the start of the section, so be able to use them in
assignment expressions.  However, we don't know the size of the
section at that point and ld uses one flag, processed_vma, to check
for both vma and size validity.  For that reason, and because ld
wants to know the section size before setting the lma (see "dot moved
backward" warning), we don't allow ADDR, LOADADDR and SIZEOF to refer
to the current section until the section closing brace, except in the
case of AT expression setting lma.

> The linker script can be made to work by moving the __data_load assignment 
> outside of the .data section.  Is that the right way to handle this issue?

For now, yes.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Binutils mailing list