| |||
| Home > Image structure and generation > Section alignment with the linker | |||
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.