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: ld bug when self-referential variables are used as output section addresses ?

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
other symbols..

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.

Samuel Jones

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