Topic : Controlling the location of functios in memory

Forum : ST7/STM8

Original Post
Post Information Post
June 29, 2012 - 10:42pm
Guest

Hi All,

I am looking into how the linker handles memory relocation and have a few questions.

First some background is needed:
For our application we require two different spaces in data and code space and communication stack space, and an application space. In other IDEs (IAR, for instance) it is possible to supply to supply a linker file that defines the memory addresses that each of these use and also allows a name definition that is then used in the .c files to define in which space each function resides.

I have looked through the linker manual and see that it mentions memory relocation and custom relocation order, but this only seems to allow you to control the order that the objects are placed in that the data or code sections, not allow the definition of two separate spaces inside the code and data sections.

How would we best achieve what I am describing?

Thanks.

Replies
Post Information Post
+1
0
-1
July 2, 2012 - 1:40pm
Raisonance Support Team

Hi,

The relocation directives such as CODE or DATA allow to set the order of the routines or data blocks, but first of all the set the address you want them to be.

This is described in 5.3 Absolute relocation in the ST7/STM8 Linker Manual.

You can group all routines from a C file using regular expressions.
To set the code of the Towers example at 0x9500:
CODE(%\?PR\?\?.*TOWERS(09500h))

% indicates that regular expressions are in use.
The ? must be escaped with \
.* matches zero or more characters.

Use DATA directive to set addresses in data.

Regards,

Stéphane