3.3.3 Section alignment with the linker

The linker ensures each input section starts at an address that is a multiple of the input section alignment.

When input sections have been ordered and before the base addresses are fixed, armlink inserts padding, if required, to force each input section to start at an address that is a multiple of the input section alignment.
The linker permits ELF program headers and output sections to be aligned on a four-byte boundary regardless of the maximum alignment of the input sections. This enables armlink to minimize the amount of padding that it inserts into the image.
If you require strict conformance with the ELF specification then use the --no_legacyalign option. The linker faults the base address of a region if it is not aligned so padding might be inserted to ensure compliance. When --no_legacyalign is used the region alignment is the maximum alignment of any input section contained by the region.
If you are using scatter-loading, you can increase the alignment of a load region or execution region with the ALIGN attribute. For example, you can change an execution region that is normally four-byte aligned to be eight-byte aligned. However, you cannot reduce the natural alignment. For example, you cannot force two-byte alignment on a region that is normally four-byte aligned.
Related concepts
7.9 Creation of regions on page boundaries
8.6.11 Example of aligning a base address in execution space but still tightly packed in load space
Related reference
9.66 --legacyalign, --no_legacyalign
8.3.3 Load region attributes
8.4.3 Execution region attributes
Non-ConfidentialPDF file icon PDF versionARM DUI0377G
Copyright © 2007, 2008, 2011, 2012, 2014, 2015 ARM. All rights reserved.