EmbDev.net

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


von Joe D. (jdupre)


Rate this post
0 useful
not useful
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:
1
. = ALIGN(4);
2
_ramcodeload = .;     /* at this point "dot" is still in ROM */
3
.ramcode : 
4
{
5
   _ramcodestart = .;
6
   *(.ramcode);
7
   _ramcodeend = .;
8
} > ram
9
10
. = ALIGN(4);
11
_where_am_i = .;     /* Now in RAM. This is = _ramcodeend + alignment */
12
/* ALIGN(4) only works on the "dot" location marker */
13
14
_usbload = ( LOADADDR(.ramcode) + SIZEOF(.ramcode) );
15
.usbram : AT ( _usbload )     /* I want _usbload aligned! */
16
{
17
   _usbstart    = .;
18
   *(.usbram)
19
   _usbend    = .;
20
} > 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?

von Martin Thomas (Guest)


Rate this post
0 useful
not useful
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.

von Joe D. (jdupre)


Rate this post
0 useful
not useful
I replaced
1
_usbload = ( LOADADDR(.ramcode) + SIZEOF(.ramcode) );
2
.usbram : AT ( _usbload )     /* I want _usbload aligned! */
3
{
4
   _usbstart    = .;
5
   *(.usbram)
6
   _usbend    = .;
7
} > usbram

with
1
.usbram : 
2
{
3
   _usbstart    = .;
4
   *(.usbram)
5
   _usbend    = .;
6
} > usbram AT>flash
7
_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]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.