Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ALIGN in Linker Scripts

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!

like image 216
Jayanga Kaushalya Avatar asked Dec 10 '11 16:12

Jayanga Kaushalya


People also ask

What is align in linker file?

The /FILEALIGN linker option lets you specify the alignment of sections written to your output file as a multiple of an specified size.

How do you write a script linker?

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.

What is absolute in linker?

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.

How do you declare a variable in a linker script?

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.


1 Answers

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;
like image 184
Employed Russian Avatar answered Sep 20 '22 18:09

Employed Russian