SPRU513Y August 2001 – June 2022 SM320F28335-EP
The linker assigns each output section two locations in target memory: the location where the section will be loaded and the location where it will be run. Usually, these are the same, and you can think of each section as having only a single address. The process of locating the output section in the target's memory and assigning its address(es) is called placement. For more information about using separate load and run placement, see Section 9.6.6.
If you do not tell the linker how to allocate a section, it uses a default algorithm to place the section. Generally, the linker puts sections wherever they fit into configured memory. You can override the default placement for a section by defining it within a SECTIONS directive and providing instructions on how to allocate it.
You control placement by specifying one or more allocation parameters. Each parameter consists of a keyword, an optional equal sign or greater-than sign, and a value optionally enclosed in parentheses. If load and run placement are separate, all parameters following the keyword LOAD apply to load placement, and those following the keyword RUN apply to run placement. The allocation parameters are:
Binding | allocates a section
at a specific address.
|
Named memory | allocates the
section into a range defined in the MEMORY directive with the specified name (like
SLOW_MEM) or attributes.
|
Alignment | uses the align or
palign keyword to specify the section must start on an address boundary.
|
Blocking | uses the block
keyword to specify the section must fit between two address aligned to the blocking
factor. If a section is too large, it starts on an address boundary.
|
Page | specifies the
memory page to be used (see Section 9.6.8). If PAGE is not specified, the linker allocates initialized sections to PAGE 0
(program memory) and uninitialized sections to PAGE 1 (data memory).
|
For the load (usually the only) allocation, use a greater-than sign and omit the load keyword:
.text: > SLOW_MEM
.text: {...} > SLOW_MEM
.text: > 0x4000
If more than one parameter is used, you can string them together as follows:
.text: > SLOW_MEM align 16 PAGE 2
Or if you prefer, use parentheses for readability:
.text: load = (SLOW_MEM align(16)) page 2
You can also use an input section specification to identify the sections from input files that are combined to form an output section. See Section 9.6.5.3.