9.6.7.3 Align Built-in Function
The
ALIGN(exp) built-in function
returns the location counter (.) aligned to the next exp boundary. The
argument, exp, must be an expression whose value is a
power of two. This is equivalent
to(. + exp - 1) & ~(exp - 1)ALIGN built-in function doesn’t change
the value of the location counter; it just performs arithmetic on it. Here is an example
which aligns the output .data section to the next 0x2000 byte boundary after the preceding section and sets a
variable within the section to the next 0x8000 boundary
after the input sections:SECTIONS { ...
.data ALIGN(0x2000): {
*(.data)
variable = ALIGN(0x8000);
}
...
}The first use of ALIGN in this example
specifies the location of a section because it is used as the optional address attribute of a
section definition (see Sections Command). The second use of ALIGN is used to define the value of
a symbol.
The built-in function NEXT is closely related to ALIGN.
