In the memory segment, available memory is divided into segments. The memory segment format looks like the following listing.
MEMORY { segment_1 (RWX): ORIGIN = 0x8000, LENGTH = 0x1000 segment_2 (RWX): ORIGIN = AFTER(segment_1), LENGTH = 0 segment_3 (RWX): ORIGIN = 0x4000, LENGTH = 0x1000, INITVAL = 0xABCD data (RW) : ORIGIN = 0x2000, LENGTH = 0x0000 #segment_name (RW) : ORIGIN = memory address, LENGTH = segment #length #and so on... }
The first memory segment definition ( segment_1) can be broken down as follows:
Example
Assume for above example that there is a program section of length 0xF00 words and it is placed in segment_ 3
section{
program_section_0x0F00;
}>segment_ 3
Then, the resulting memory map will have ( 0x1000-0xF00=0x100) words at the end of segment_3 that will be initialized with the pattern specified in INITVAL = 0xABCD .
Memory segments with RWX attributes are placed into P: memory while RW attributes are placed into X: memory.
If you cannot predict how much space a segment will occupy, you can use the function AFTER and LENGTH = 0 (unlimited length) to fill in the unknown values.