Posted on:
I have some initialized variables that I want to place in a special area of RAM. I want the initialized values stored in ROM after the load area for .ramcode. Like this:
. = ALIGN(4); _ramcodeload = .; /* at this point "dot" is still in ROM */ .ramcode : { _ramcodestart = .; *(.ramcode); _ramcodeend = .; } > ram . = ALIGN(4); _where_am_i = .; /* Now in RAM. This is = _ramcodeend + alignment */ /* ALIGN(4) only works on the "dot" location marker */ _usbload = ( LOADADDR(.ramcode) + SIZEOF(.ramcode) ); .usbram : AT ( _usbload ) /* I want _usbload aligned! */ { _usbstart = .; *(.usbram) _usbend = .; } > usbram |
But the end of .ramcode stored in ROM may not be aligned. How I do I force the linker to align where the initialized values for the .usbram section are to be stored in ROM?
Posted on:
Placeing . = ALIGN(4); inside the definitions of the output-sections should do. This can be checked by looking into the map-file and/or symbol-list. If it does not work, please create a minimal example with all needed files for a "make all" to reproduce the issue, pack it into a zip-archive and attach it to a message.
Posted on:
I replaced
_usbload = ( LOADADDR(.ramcode) + SIZEOF(.ramcode) );
.usbram : AT ( _usbload ) /* I want _usbload aligned! */
{
_usbstart = .;
*(.usbram)
_usbend = .;
} > usbram |
with
.usbram :
{
_usbstart = .;
*(.usbram)
_usbend = .;
} > usbram AT>flash
_usbload = LOADADDR(.usbram); |
and the alignment happens automatically.