This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] ld: fix ABSOLUTE for general expressions


On Mon, Jul 18, 2016 at 05:34:06PM +0200, Tristan Gingold wrote:
> Hello,
> 
> it appears that ABSOLUTE(x) doesn't generate an absolute value when X is not a symbol, it looks like it works only for symbols.
> See the testcase for an example.
[snip]
> +SECTIONS
> +{
> +  .text 0x100 :
> +  {
> +    *(.text)
> +   _stack_start = ABSOLUTE(0x0800);
> +  }
> +}

I think what you're missing is that a plain number inside an output
section statement is section relative, if the number is used as an
address.

So, for example, the following sets x to .text+0x800.

SECTIONS
{
  .text 0x100 :
  {
    *(.text)
   x = 0x800;
  }
}

and

SECTIONS
{
  .text 0x100 :
  {
    *(.text)
   . = 0x800;
  }
}

sets the value of dot to 0x800 relative to the start of .text.

So I think that for consistency

SECTIONS
{
  .text 0x100 :
  {
    *(.text)
   _stack_start = ABSOLUTE(0x0800);
  }
}

should set _stack_start to the value 0x900.

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]