3.1.2 Input sections, output sections, regions, and program
An object or image file is constructed from a hierarchy of input sections, output sections, regions, and program segments.
- Input section
- An input section is an individual section from an input object file.
It contains code, initialized data, or describes a fragment of memory that is not
initialized or that must be set to zero before the image can execute. These properties
are represented by attributes such as RO, RW, XO, and ZI. These attributes are used by
armlink to group input sections into bigger
building blocks called output sections and regions.
- Output section
- An output section is a group of input sections that have the same RO,
RW, XO, or ZI attribute, and that are placed contiguously in memory by the linker. An
output section has the same attributes as its constituent input sections. Within an
output section, the input sections are sorted according to the section placement
- A region contains up to three output sections depending on the
contents and the number of sections with different attributes. By default, the output
sections in a region are sorted according to their attributes:
- If no XO output sections are present, then the RO output section
is placed first, followed by the RW output section, and finally the ZI output
- If all code in the execution region is execute-only, then an XO
output section is placed first, followed by the RW output section, and finally the
ZI output section.
A region typically maps onto a physical memory device, such as ROM, RAM, or
peripheral. You can change the order of output sections using
- Program segment
A program segment corresponds to a load region and contains execution
regions. Program segments hold information such as text and data.
Note: With armlink, the maximum size
of a program segment is 2GB.
Considerations when execute-only sections are present
Be aware of the following when execute-only
(XO) sections are present:
- You can mix XO and non-XO sections in the same execution region. In this
case, the XO section loses its XO property and results in the output of a RO section.
- If an input file has one or more XO sections then the linker generates a
separate XO ELF execution region if the XO and RO sections are in distinct regions. In the
final image, the XO execution region immediately precedes the RO execution region, unless
otherwise specified by a scatter file or the