Input sections, output sections, regions, and program segments
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 rules.
A region contains up to four 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. Any XO output section is first, followed by the RO output section, then 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 scatter-loading.
- Program segment
A program segment corresponds to a load region and contains execution regions. Program segments hold information such as text and data.
NoteWith armlink, the maximum size of a program segment is 2GB.
NoteXO memory is supported only for ARMv7-M and ARMv8-M architectures.
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. However, this 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 segment. In the final image, the XO segment immediately precedes the RO segment, unless otherwise specified by a scatter file or the