EmbDev.net

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


von Joe D. (jdupre)


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

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.