ALIGN in Linker Scripts

Jayanga Kaushalya picture Jayanga Kaushalya · Dec 10, 2011 · Viewed 17.7k times · Source

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!

Answer

Employed Russian picture Employed Russian · Dec 11, 2011

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;