Whole document tree
    

Whole document tree

Untitled Document: MEMORY
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.3 Memory Layout

The linker's default configuration permits allocation of all available memory. You can override this configuration by using the 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
is a name used internally by the linker to refer to the region. Any symbol name may be used. The region names are stored in a separate name space, and will not conflict with symbols, file names or section names. Use distinct names to specify multiple regions.

(attr)
is an optional list of attributes that specify whether to use a particular memory to place sections that are not listed in the linker script. Valid attribute lists must be made up of the characters "ALIRWX" that match section attributes. If you omit the attribute list, you may omit the parentheses around it as well. The attributes currently supported are:

`Letter'
Section Attribute

`R'
Read-only sections.

`W'
Read/write sections.

`X'
Sections containing executable code.

`A'
Allocated sections.

`I'
Initialized sections.

`L'
Same as I.

`!'
Invert the sense of any of the following attributes.

origin
is the start address of the region in physical memory. It is an expression that must evaluate to a constant before memory allocation is performed. The keyword ORIGIN may be abbreviated to org or o (but not, for example, `ORG').

len
is the size in bytes of the region (an expression). The keyword 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. The rom memory region will get all sections without an explicit memory register that are either read-only or contain code, while the ram memory region will get the sections.

 
MEMORY 
  {
  rom (rx)  : ORIGIN = 0, LENGTH = 256K
  ram (!rx) : 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 3.4.4 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.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by root on January, 30 2002 using texi2html