MEMORY

Starts the LCF memory segment, which defines segments of target memory.

MEMORY { memory_spec[, memory_spec] }
  
Parameters

memory_spec

segmentName: 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 should be a numeric value, such as 0x80000400.

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:

Remarks

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,the segment start address should be specified correctly.

Example

MEMORY Directive Example is an example use of the MEMORY directive.

Listing 1. MEMORY Directive Example
MEMORY {
    TEXT (RX)  :  ORIGIN = 0x00003000, LENGTH = 0

    DATA (RW)  :  ORIGIN = 0x5000, LENGTH = 0

    }