ld.info: Output Section Data

Go forward to Output Section Keywords
Go backward to Input Section
Go up to SECTIONS
Go to the top op ld

Output section data

   You can include explicit bytes of data in an output section by using
`BYTE', `SHORT', `LONG', `QUAD', or `SQUAD' as an output section
command.  Each keyword is followed by an expression in parentheses
providing the value to store (*note Expressions::).  The value of the
expression is stored at the current value of the location counter.
   The `BYTE', `SHORT', `LONG', and `QUAD' commands store one, two,
four, and eight bytes (respectively).  After storing the bytes, the
location counter is incremented by the number of bytes stored.
   For example, this will store the byte 1 followed by the four byte
value of the symbol `addr':
     BYTE(1)
     LONG(addr)
   When using a 64 bit host or target, `QUAD' and `SQUAD' are the same;
they both store an 8 byte, or 64 bit, value.  When both host and target
are 32 bits, an expression is computed as 32 bits.  In this case `QUAD'
stores a 32 bit value zero extended to 64 bits, and `SQUAD' stores a 32
bit value sign extended to 64 bits.
   If the object file format of the output file has an explicit
endianness, which is the normal case, the value will be stored in that
endianness.  When the object file format does not have an explicit
endianness, as is true of, for example, S-records, the value will be
stored in the endianness of the first input object file.
   Note - these commands only work inside a section description and not
between them, so the following will produce an error from the linker:
     SECTIONS { .text : { *(.text) } LONG(1) .data : { *(.data) } }
   whereas this will work:
     SECTIONS { .text : { *(.text) ; LONG(1) } .data : { *(.data) } }
   You may use the `FILL' command to set the fill pattern for the
current section.  It is followed by an expression in parentheses.  Any
otherwise unspecified regions of memory within the section (for example,
gaps left due to the required alignment of input sections) are filled
with the two least significant bytes of the expression, repeated as
necessary.  A `FILL' statement covers memory locations after the point
at which it occurs in the section definition; by including more than
one `FILL' statement, you can have different fill patterns in different
parts of an output section.
   This example shows how to fill unspecified regions of memory with the
value `0x9090':
     FILL(0x9090)
   The `FILL' command is similar to the `=FILLEXP' output section
attribute (*note Output Section Fill::), but it only affects the part
of the section following the `FILL' command, rather than the entire
section.  If both are used, the `FILL' command takes precedence.