MEMORY
command. The
MEMORY
command describes the location and size of blocks of
memory in the target. By using it carefully, you can describe which
memory regions may be used by the linker, and which memory regions it
must avoid. The linker does not shuffle sections to fit into the
available regions, but does move the requested sections into the correct
regions and issue errors when the regions become too full.
A command file may contain at most one use of the MEMORY
command; however, you can define as many blocks of memory within it as
you wish. The syntax is:
MEMORY { name (attr) : ORIGIN = origin, LENGTH = len ... }
name
(attr)
ld
beyond checking that the
attribute list is valid. Valid attribute lists must be made up of the
characters "LIRWX
". If you omit the attribute list, you may
omit the parentheses around it as well.
origin
ORIGIN
may be
abbreviated to org
or o
(but not, for example, `ORG').
len
LENGTH
may be abbreviated to len
or l
.
For example, to specify that memory has two regions available for
allocation--one starting at 0 for 256 kilobytes, and the other
starting at 0x40000000
for four megabytes:
MEMORY { rom : ORIGIN = 0, LENGTH = 256K ram : org = 0x40000000, l = 4M }
Once you have defined a region of memory named mem, you can direct
specific output sections there by using a command ending in
`>mem' within the SECTIONS
command (see section Optional Section Attributes). If the combined output sections directed to a region are too
big for the region, the linker will issue an error message.