 
 
The linker script language includes a number of builtin functions for use in linker script expressions.
ABSOLUTE(exp)
ADDR(section)
symbol_1 and symbol_2 are assigned
identical values:
SECTIONS { ...
  .output1 :
    { 
    start_of_output_1 = ABSOLUTE(.);
    ...
    }
  .output :
    {
    symbol_1 = ADDR(.output1);
    symbol_2 = start_of_output_1;
    }
... }
ALIGN(exp)
.) aligned to the next exp
boundary.  exp must be an expression whose value is a power of
two.  This is equivalent to
(. + exp - 1) & ~(exp - 1)
ALIGN doesn't change the value of the location counter---it just
does 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 Output Section Address).  The second use
of ALIGN is used to defines the value of a symbol.
The builtin function NEXT is closely related to ALIGN.
BLOCK(exp)
ALIGN, for compatibility with older linker
scripts.  It is most often seen when setting the address of an output
section.
DEFINED(symbol)
begin' to the first location in
the `.text' section---but if a symbol called `begin' already
existed, its value is preserved:
SECTIONS { ...
  .text : {
    begin = DEFINED(begin) ? begin : . ;
    ...
  }
  ...
}
LOADADDR(section)
ADDR, but it may be different if the AT
attribute is used in the output section definition (see Output Section LMA).
MAX(exp1, exp2)
MIN(exp1, exp2)
NEXT(exp)
ALIGN(exp); unless you
use the MEMORY command to define discontinuous memory for the
output file, the two functions are equivalent.
SIZEOF(section)
symbol_1 and symbol_2 are assigned identical values:
SECTIONS{ ...
  .output {
    .start = . ;
    ...
    .end = . ;
    }
  symbol_1 = .end - .start ;
  symbol_2 = SIZEOF(.output);
... }
SIZEOF_HEADERS
sizeof_headers
When producing an ELF output file, if the linker script uses the
SIZEOF_HEADERS builtin function, the linker must compute the
number of program headers before it has determined all the section
addresses and sizes.  If the linker later discovers that it needs
additional program headers, it will report an error `not enough room for program headers'.  To avoid this error, you must avoid using
the SIZEOF_HEADERS function, or you must rework your linker
script to avoid forcing the linker to use additional program headers, or
you must define the program headers yourself using the PHDRS
command (see PHDRS).
Packaging copyright © 1988-2000 OAR Corporation Context copyright by each document's author. See Free Software Foundation for information.