You can set the fill pattern for an entire section by using
‘=fillexp’. fillexp is an expression
(see Expressions in Linker Scripts). Any otherwise unspecified regions of memory
within the output section (for example, gaps left due to the required
alignment of input sections) will be filled with the value, repeated as
necessary. If the fill expression is a simple hex number, ie. a string
of hex digit starting with ‘0x’ and without a trailing ‘k’ or ‘M’, then
an arbitrarily long sequence of hex digits can be used to specify the
fill pattern; Leading zeros become part of the pattern too. For all
other cases, including extra parentheses or a unary +
, the fill
pattern is the four least significant bytes of the value of the
expression. If the value is less than four bytes in size then it will
be zero extended to four bytes. In all cases, the number is big-endian.
Fill Value Fill Pattern 0x90 90 90 90 90 0x0090 00 90 00 90 144 00 00 00 90
You can also change the fill value with a FILL
command in the
output section commands; (see Output Section Data).
Here is a simple example:
SECTIONS { .text : { *(.text) } =0x90909090 }