This is the mail archive of the
mailing list for the binutils project.
Re: ld bug when self-referential variables are used as output section addresses ?
- From: Samuel Jones <sjones at kalray dot eu>
- To: binutils at sourceware dot org
- Date: Mon, 20 Jan 2014 14:25:59 +0100
- Subject: Re: ld bug when self-referential variables are used as output section addresses ?
- Authentication-results: sourceware.org; auth=none
- References: <52D7E4D9 dot 5050904 at kalray dot eu> <20140120111215 dot GN5390 at bubble dot grove dot modra dot org>
On 20/01/14 12:12, Alan Modra wrote:
On Thu, Jan 16, 2014 at 02:55:37PM +0100, Samuel Jones wrote:
I have the following linker script:
TOTO = 1024;
TOTO += 1024;
.rodata TOTO :
__toto_symbol_abs = ABSOLUTE(TOTO);
When I link this example with the latest ld, the section ".rodata"
is placed at 1024, whereas I would have expected 2048.
__toto_symbol_abs gets the value 2048.
With ld 2.22.52 .rodata is placed at 2048. I believe this commit by
Alan Modra changed ld's behaviour:
4194268f43623a5f893b9a92b0456d3cb43ab915. My understanding of the
patch is that it delays the evaluation of self-referential
expressions until section sizing has been completed. We depended on
the previous behaviour for correct placement of output sections
(mostly calculating alignment constraints).
Is what I observe expected behaviour? If so is there any way to
achieve what I want apart from using static single assignment? And
why the change?
Clearly, your linker script is quite reasonable. No matter how many
times the script is evaluated, you should get the same result. The
tricky part is differentiating expressions involving self-assignment
to absolute symbols with a previous linker script definition from all
Fortunately we already have some machinery in ld to track such
symbols, but it needs some modification.
Thanks for this patch. I confirm that it fixes my problem.