SLAU131V October 2004 – February 2020
/*******************************************************/
/* Sample command file with MEMORY directive */
/*******************************************************/
file1.c.obj file2.c.obj /* Input files */
--output_file=prog.out /* Options */
MEMORY
{
FLASH (RX): origin = 0x1100 length = 0xEEE0
RAM (RX): origin = 0x0200 length = 0x0800
}
The general syntax for the MEMORY directive is: | |
MEMORY | |
{ | |
name 1 [(attr)] : origin = expr, length = expr [, fill = constant] [ LAST(sym)] | |
. | |
. | |
name n [(attr)] : origin = expr, length = expr [, fill = constant] [ LAST(sym)] | |
} |
name | names a memory range. A memory name can be one to 64 characters; valid characters include A-Z, a-z, $, ., and _. The names have no special significance to the linker; they simply identify memory ranges. Memory range names are internal to the linker and are not retained in the output file or in the symbol table. All memory ranges must have unique names and must not overlap. | |
attr | specifies one to four attributes associated with the named range. Attributes are optional; when used, they must be enclosed in parentheses. Attributes restrict the allocation of output sections into certain memory ranges. If you do not use any attributes, you can allocate any output section into any range with no restrictions. Any memory for which no attributes are specified (including all memory in the default model) has all four attributes. Valid attributes are: | |
R | specifies that the memory can be read. | |
W | specifies that the memory can be written to. | |
X | specifies that the memory can contain executable code. | |
I | specifies that the memory can be initialized. | |
origin | specifies the starting address of a memory range; enter as origin, org, or o. The value, specified in bytes, is a 16-bit integer constant expression, which can be decimal, octal, or hexadecimal. | |
length | specifies the length of a memory range; enter as length, len, or l. The value, specified in bytes, is a 32-bit integer constant expression, which can be decimal, octal, or hexadecimal. | |
fill | specifies a fill character for the memory range; enter as fill or f. Fills are optional. The value is an integer constant and can be decimal, octal, or hexadecimal. The fill value is used to fill areas of the memory range that are not allocated to a section. (See Section 8.5.9.3 for virtual filling of memory ranges when using Error Correcting Code (ECC).) | |
LAST | optionally specifies a symbol that can be used at run-time to find the address of the last allocated byte in the memory range. See Section 8.5.10.8. |
NOTE
Filling Memory RangesIf you specify fill values for large memory ranges, your output file will be very large because filling a memory range (even with 0s) causes raw data to be generated for all unallocated blocks of memory in the range.
The following example specifies a memory range with the R and W attributes and a fill constant of 0FFFFh:
MEMORY
{
RFILE (RW) : o = 0x0020, l = 0x1000, f = 0x0FFFF
}
You normally use the MEMORY directive in conjunction with the SECTIONS directive to control placement of output sections. For more information about the SECTIONS directive, see Section 8.5.5.