What does the ALIGN keyword do in linker scripts? I read many tutorials about linker scripts but I cant understand what really ALIGN do. Can any one explain it simply. Thanks!
The /FILEALIGN linker option lets you specify the alignment of sections written to your output file as a multiple of an specified size.
You write a linker script as a series of commands. Each command is either a keyword, possibly followed by arguments or an assignment to a symbol. You may separate commands using semicolons. Whitespace is generally ignored.
An absolute expression type is one in which the symbol contains the value that it will have in the output file; a relocatable expression type is one in which the value is expressed as a fixed offset from the base of a section. The type of the expression is controlled by its position in the script file.
In the linker script, I defined PROVIDE(__KERNEL_BEGIN__ = .); . I looked at the assembly. The first method, __KERNEL_BEGIN__ , provides the exact address. The second one, __KERNEL_BEGIN__ = [address] , looks up a value at the address.
A typical usage is
. = ALIGN(8);
This means: insert padding bytes until current location becomes aligned on 8-byte boundary. That is:
while ((current_location & 7) != 0)
*current_location++ = padding_value;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With