EmbDev.net

Forum: ARM programming with GCC/GNU tools How to align load address?

Author: Joe Dupre (jdupre)
Posted on: 2009-06-05 23:58

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?
Author: Martin Thomas (Guest)
Posted on: 2009-06-06 10:37

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.
Author: Joe Dupre (jdupre)
Posted on: 2009-06-11 02:03

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.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]





Note: the original post is older than 6 Months.

webmaster@embdev.netContactAdvertising on EmbDev.net