This is the mail archive of the 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 19 Jul 2016, at 03:02, Alan Modra <> wrote:
> 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]
>> +{
>> +  .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.

But, this is not what the doc says:

Return the absolute (non-relocatable, as opposed to non-negative) value of the expression exp. Primarily useful to assign an absolute value to a symbol within a section definition, where symbol values are normally section relative.

I think the doc is clear, and according to it:

 .text 0x100 :
  _stack_start = ABSOLUTE(0x0800);

should set _stack_start to the value 0x800 (and not 0x900).

I am not against allowing only symbols for operand of ABSOLUTE.  I think this would be much clearer and still backward compatible in practice.

The rule you gave 'a plain number inside an output section statement is section relative' is not well defined.
For example, how to apply it to:
  x = 0x80 + 4;
I know how ld would understand it: this is section_vma + 0x84.  But this is not exactly your rule!


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