precedence. @xref{Output Section Fill}, for details on the fill
expression.
+Note - normally the value of @code{expression} is zero extended to 4
+bytes when used to fill gaps. Thus @samp{FILL(144)} will fill a
+region with repeats of the pattern @samp{0 0 0 144}. The value is
+treated as a big-endian number, so for example
+@samp{FILL(22 * 256 + 23)} will fill the region with repeats of the
+pattern @samp {0 0 22 23}. If the expression results in a value with
+more than 4 significant bytes only the least 4 bytes of the value will
+be used.
+
+The above rules do not apply when the @code{expression} is a simple
+hexadecimal number. In this case zero extension is not performed and
+all bytes are significant. So @samp{FILL(0x90)} will fill a region with
+repeats of @samp{0x90} with no zero bytes, and @samp{FILL(0x9192)}
+will fill the region with repeats of @samp{0x91 0x92}. Zero bytes
+in a hexadecimal expression are significant even at the start, so
+@samp{FILL(0x0090)} will fill a region with repeats of @samp{0x00 0x90}.
+
+Hexadecimal numbers can be longer than 4 bytes, and all of the bytes
+are significant, so @samp{FILL(0x123456789a)} will fill a region with
+repeats of the 5 byte sequence @samp{0x12 0x34 0x56 0x78 0x9a}.
+Excess bytes in a hexadecimal value beyond the size of a region will
+be silently ignored.
+
+The above only applies to hexadecimal numbers specified as
+@samp{0x[0-9][a-f][A-F]}. Hexadecimal numbers specified with a
+@samp{$} prefix, or a @samp{h}, @samp{H}, @samp{x} or @samp{X} suffix
+will follow the normal fill value rules. This also applies to
+expressions that involve hexadecimal numbers, and hexadecimal numbers
+that have a magnitude suffix.
+
@kindex LINKER_VERSION
@cindex LINKER_VERSION
The @code{LINKER_VERSION} command inserts a string containing the
fill pattern; Leading zeros become part of the pattern too. For all
other cases, including extra parentheses or a unary @code{+}, the fill
pattern is the four least significant bytes of the value of the
-expression. In all cases, the number is big-endian.
+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.
+
+@smallexample
+Fill Value Fill Pattern
+0x90 90 90 90 90
+0x0090 00 90 00 90
+144 00 00 00 90
+@end smallexample
You can also change the fill value with a @code{FILL} command in the
output section commands; (@pxref{Output Section Data}).
--- /dev/null
+#source: fill_0.s
+#ld: -T fill2.t
+#readelf: -x.foo
+#notarget: ![is_elf_format]
+# See PR 30865 - a fill value expressed as a simple hexadecimal
+# number behaves differently from other fill values.
+
+Hex dump of section '.foo':
+ 0x00000000 00000000 00000090 91919191 00000092 ................
+ 0x00000010 00000093 00025000 00969500 00000097 ................
+ 0x00000020 00010203 04050607 04050607 04050607 ................
+ 0x00000030 08090a0b ffffffff .*
--- /dev/null
+SECTIONS {
+ .foo :
+ {
+ . += 4;
+ FILL (144) # Decimal values zero extend to 4 bytes. Fills with: 00 00 00 90
+ . += 4;
+ FILL (0x91) # Hex values do not zero extend. Fills with: 91 91 91 91
+ . += 4;
+ FILL ($92) # A dollar prefix indicates a hex values that does zero extend. Fills with: 00 00 00 92
+ . += 4;
+ FILL (93H) # An H suffix does the same. Fills with: 00 00 00 93
+ . += 4;
+ FILL (0x94K) # A hex value with a manitude suffix zero extends. Fills with: 00 02 50 00
+ . += 4;
+ FILL (0x009695) # Zeros in hex values are significant. Values are big-endian. Fills with: 00 96 95 00
+ . += 4;
+ FILL (0x90+0x7) # An expression containing hex values also zero extends. Fills with: 00 00 00 97
+ . += 4;
+ FILL (0x0001020304050607) # Hex values can be used to specify fills with more than 4 bytes. Fills with: 00 01 02 03 04 05 06 07
+ . += 8;
+ FILL ($0001020304050607) # But non-hex or $-hex or suffix-hex values cannot. Fills with 04 05 06 07 04 05 06 07
+ . += 8;
+ FILL (0x08090a0b0c0d0e0f) # Extra bytes at the end of a value are silently ignored. Fills with 08 09 0a 0b
+ . += 4;
+ LONG(0xffffffff)
+ } =0
+
+ /DISCARD/ : { *(*) }
+}