ld bug in the location counter calculation?

Nick Clifton nickc@redhat.com
Tue Apr 7 07:57:00 GMT 2009


Hi Tehn Yit,

> Thanks for the answer. I guess my interpretation of the ld
> documentation is incorrect.

No - the documentation itself is incorrect.  The sentence that says:

   "Specifying @var{address} for a section will change the
    value of the location counter."

Should actually read:

   "Specifying @var{address} for a section will change the
    value of the location counter, provided that the section
    is non-empty.  (Empty sections are ignored)."

I will be checking in a patch to update the documentation.

> What is the normal practice to force the dot address to be at
> _DATA_END_ for both empty and non-empty sections?

   Put the address before the start of the .data section.  Ie change 
your linker script to be like this:

   /* append .data; it will be copied by crt0 to final __DATA_START__ */
   . = ALIGN(4);
   __INIT_DATA_START__ = .;

   . = __DATA_START__ ;

   .data : AT ( __INIT_DATA_START__ )
   {
     *(.data)


Cheers
   Nick



More information about the Binutils mailing list