Starts the LCF memory segment, which defines segments of target memory.
MEMORY { memory_spec[, memory_spec] }
memory_spec
segmentName (accessFlags) : ORIGIN = address, LENGTH = length [> fileName]
segmentName
Name for a new segment of target memory. Consists of alphanumeric characters; can include the underscore character.
accessFlags
ELF-access permission flags - R = read, W = write, or X = execute.
address
A memory address, such as 0x80000400, or an AFTER command. The format of the AFTER command is AFTER (name[, name]); this command specifies placement of the new memory segment at the end of the named segments.
length
Size of the new memory segment: a value greater than zero. Optionally, the value zero for autolength, in which the linker allocates space for all the data and code of the segment. (Autolength cannot increase the amount of target memory, so the feature can lead to overflow.)
fileName
Optional, binary-file destination. The linker writes the segment to this binary file on disk, instead of to an ELF program header. The linker puts this binary file in the same folder as the ELF output file. This option has two variants:
The LCF contains only one MEMORY directive, but this directive can define as many memory segments as you wish.
For each memory segment, the ORIGIN keyword introduces the starting address, and the LENGTH keyword introduces the length value.
There is no overflow checking for the autolength feature. To prevent overflow, you should use the AFTER keyword to specify the segment's starting address.
If an AFTER keyword has multiple parameter values, the linker uses the highest memory address.
For more information, see the subsection Memory Segment.
The following listing is an example use of the MEMORY directive.
MEMORY { TEXT (RX) : ORIGIN = 0x00003000, LENGTH = 0 DATA (RW) : ORIGIN = AFTER(TEXT), LENGTH = 0 }