Memory Segment

In the memory segment, available memory is divided into segments. The memory segment format looks like the following listing.

Listing: Sample MEMORY segment
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:

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.