Table of Contents Previous topic Next topic
LINKER->Linker Scripts->Linker Script Language->Output Section Definition
An output section definition specifies the location and contents of an output section.
The format for a section definition is as follows:
<output section name> <output section attributes> :
{
<section definition content>
} > <memory region name>
If the output section attributes define the run-time location of the output section then the allocation to memory region name is omitted.
Also it the output section is part of a group then the allocation to memory region name is normally omitted.
The output section attributes are optional and can include a run-time address expression, a storage address expression, an alignment specification and a type specification. These are described later.
The section definition content consists of the input sections to be included in the output sections and assigment expressions.
A simple example of an output section definition is:
__mysegment :
{
__mysegment_start = .;
*(.mysegment)
__mysegment_end = .;
} > flash_memory
This tells the linker to put the output section named __mysegment into the memory region named flash_memory.
This output section contains only one input section and this is the relocatable section named .mysegment.
The identifier __mysegment_start is assigned the execution address of the beginning of the .mysegments input section.
The identifier __mysegment_end is assigned the execution address one byte past the end of the .mysegment input section.
The identifiers __mysegment_start and __mysegment_end can be used later in the script file and also within the program source code.