Memory management on .lcf

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Memory management on .lcf

3,937 Views
Kremer
Contributor I
 Hi all
 
 Can someone help me about where can i find good informations about those types of data presented on .lcf file.
 I´ve been through the Coldfire_Build_Tools_Reference.pdf wich explains the .lcf file programming but i´m still not able to understand the data types like:
 
.text
.rodata
.data
.sdata
.sbss
.bss
 
 Please, any informations will be great.
 
 Regards
 Alex
 
Labels (1)
0 Kudos
Reply
3 Replies

1,250 Views
SimonMarsden_de
Contributor II
Hi Alex,

Sorry, I don't know where this is documented. Perhaps the following explanation would help?

(1) The .text section contains your program's executable instructions

(2) The .rodata section contains any read-only data. For example, in C you could write:

const int myconstant = 0x1234;


The compiler would place 'myconstant' in the .rodata section. It will also place string data in this section if you set CodeWarrior's options appropriately. For example:

printf ("Hello world\n");


The string "Hello world\n" is placed in .rodata.

Since the data in .rodata never gets modified, it's common to locate it in Flash memory along with your executable code.

(3) The .data section contains data that's modifiable by your code (i.e. non-constant data), and that is initialised with a non-zero value. For example:

int myinteger = 0x1234;


(3) The .bss section contains data that's modifiable by your code, but not initialised, or initialised to zero. For example:

char myarray [256];


(4) Now come the harder ones - .sdata and .sbss. These are the Small Data and Small BSS sections. The idea of these sections is to allow the compiler to generate more efficient code to access commonly used data items.

You can tell the compiler to place any data item which is less than a certain size into .sdata or .sbss, rather than the normal .data/.bss (See the CodeWarrior 'ColdFire Processor' options pane).

The Linker Control File collects all .sdata items together into a single lump, and follows this by all the .sbss items. At runtime, the A5 register is set up to point to the mid-point - i.e. the end of the .sdata/start of .sbss. This is usually a linker-defined label called __SDA_BASE.

For an item located in the .sdata or .sbss section, the compiler generates a more efficient instruction to access it, using A5-relative addressing instead of absolute addressing. This typically reduces the instruction size by 2 bytes.


Hope this helps get you started.


Simon
0 Kudos
Reply

1,250 Views
AndrewLohmann
Contributor I
Hi


I posted a similar question at:
http://forums.freescale.com/freescale/board/message?board.id=CWCFCOMM&thread.id=1429

I am using CW 5.02 for powerPC  and it has two more sections which I guess should be placed if flash. could you confirm or correct my assumption? Those sections are:

 extab 
 extabindex


Regards
Andrew
0 Kudos
Reply

1,250 Views
Kremer
Contributor I
 Thank you Simon for your explanation.
  It is very helpful. I was kind of guessing those data types, but there´s no room for guess in binary world !!!
 So I assume data types like .text, .rodata, .data and .bss are mandatory on every single lcf file the user can write. Not placing them shall generate errors or warnings at least.
 The other 2 data types (.sbss and .sdata) can be placed or not, but the aplication shall work fine if those 2 types aren´t placed.
 
 Thank you again
 
 Regards
 Alex
0 Kudos
Reply