On Thu, Jan 16, 2014 at 02:55:37PM +0100, Samuel Jones wrote:
I have the following linker script:
TOTO = 1024;
TOTO += 1024;
SECTIONS
{
.rodata TOTO :
{
__toto_symbol_abs = ABSOLUTE(TOTO);
*(.rodata)
*(.rodata.*)
}
}
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?
See https://sourceware.org/ml/binutils/2012-12/msg00155.html
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
other symbols..
Fortunately we already have some machinery in ld to track such
symbols, but it needs some modification.