[PATCH] ld: fix ABSOLUTE for general expressions
Alan Modra
amodra@gmail.com
Tue Jul 19 01:02:00 GMT 2016
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
More information about the Binutils
mailing list