This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] ld: fix ABSOLUTE for general expressions
- From: Alan Modra <amodra at gmail dot com>
- To: Tristan Gingold <gingold at adacore dot com>
- Cc: binutils <binutils at sourceware dot org>
- Date: Tue, 19 Jul 2016 10:32:11 +0930
- Subject: Re: [PATCH] ld: fix ABSOLUTE for general expressions
- Authentication-results: sourceware.org; auth=none
- References: <F8E6EE0B-49F3-4986-B48E-45AD57BD0D7C@adacore.com>
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