[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ld bug when self-referential variables are used as output section addres

From: Samuel Jones
Subject: ld bug when self-referential variables are used as output section addresses ?
Date: Thu, 16 Jan 2014 14:55:37 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7


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?

I used the following command:

ld -T test.ld main.o -o main

where main.o is simply:

int main(void){return 0;}

compiled with:
gcc -c main.c

I'd be very grateful for any information on this issue.

Best Regards,

Samuel Jones
Kalray SA - www.kalray.eu

reply via email to

[Prev in Thread] Current Thread [Next in Thread]