public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* linker allocation order VS declaration order
@ 2012-07-31  9:09 Hua Yanghao
  2012-07-31 13:38 ` nick clifton
  0 siblings, 1 reply; 3+ messages in thread
From: Hua Yanghao @ 2012-07-31  9:09 UTC (permalink / raw)
  To: binutils

Hi,
While porting an old arm RVDS based code to arm-GCC,
I found a behavior difference regarding variable allocation order
with regard to its declaration order in C file.

I know this is bad design and should not be relied on,
but that's the burden must be carried for the porting.

For example, if in a C file, two variable declared:
int a;
int b;

After compilation, a and b is in bss section (common section).
The linker script could be:
.bss 0x8000 : { *(COMMON) }

Here the RVDS always place a @ 0x8000 and b @ 0x8004,
however for GNU/Binutils the placement is completely random.
Sometimes if I initialized a and b to 0, which in theory should have
no difference but in reality do change the address for a and b.

So here my question is,in GNU/ld is there any way to make the
variable allocation order (or assignment order) exactly the same
as the declaration order?

Thanks,
Yanghao

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-08-01  2:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-31  9:09 linker allocation order VS declaration order Hua Yanghao
2012-07-31 13:38 ` nick clifton
2012-08-01  2:08   ` Hua Yanghao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).