10.5.5.7 Output Section Data

Explicit bytes of data may be inserted into an output section by using BYTE, SHORT, or LONG 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.

The BYTE, SHORT, or LONG commands store one, two, or four 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. On PIC32A architectures the full 32-bit value will be loaded.

Data 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) } }

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.

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 (see 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.