linkerldlinker-scripts

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!


Solution

  • 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;