9.5.5.7 Output Section Data
Explicit bytes of data may be inserted into an output section by using BYTE
, SHORT
, LONG
or QUAD
as an output section command. Each keyword is followed by an expression in parentheses providing the value to store. The value of the expression is stored at the current value of the location counter.
BYTE
, SHORT
, LONG
and QUAD
commands store one, two, four and eight bytes (respectively). For
example, this command will store the four byte value of the symbol addr
:LONG(addr)
After storing the bytes, the location counter is incremented by the number of bytes stored.
SECTIONS { .text : { *(.text) } LONG(1) .data : { *(.data) } }
whereas
this will
work:SECTIONS { .text : { *(.text) ; LONG(1) } .data : { *(.data) } }
The FILL
command may be used 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, different fill patterns may be used in different parts of an output section.
0x9090
:FILL(0x9090)
The FILL
command is similar to the
=fillexp
output section attribute (see 9.5.5.9 Output Section Attributes), 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.