User`s guide

ELF Linker and Command Language
Structure of Linker Command Files
288
Targeting MC56F83xx/DSP5685x Controllers
Memory Segment
In the memory segment, available memory is divided into segments. The memory
segment format looks like Listing 10.1
.
Listing 10.1 Sample MEMORY Segment
MEMORY {
segment_1 (RWX): ORIGIN = 0x8000, LENGTH = 0x1000
segment_2 (RWX): ORIGIN = AFTER(segment_1), LENGTH = 0
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:
•the (RWX) portion of the segment definition pertains to the ELF access permission
of the segment. The (RWX) flags imply read, write, and execute access.
ORIGIN represents the start address of the memory segment (in this case
0x8000).
LENGTH represents the size of the memory segment (in this case 0x1000).
Memory segments with RWX attributes are placed in to 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.
Closure Blocks
The linker is very good at deadstripping unused code and data. Sometimes, however,
symbols need to be kept in the output file even if they are never directly referenced.
Interrupt handlers, for example, are usually linked at special addresses, without any
explicit jumps to transfer control to these places.
Closure blocks provide a way to make symbols immune from deadstripping. The
closure is transitive, meaning that symbols referenced by the symbol being closed are
also forced into closure, as are any symbols referenced by those symbols, and so on.