]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gas: elf: Relax rules for SHF_STRING sections
authorRichard Earnshaw <rearnsha@arm.com>
Fri, 17 Jan 2025 15:03:47 +0000 (15:03 +0000)
committerRichard Earnshaw <rearnsha@arm.com>
Mon, 20 Jan 2025 10:07:15 +0000 (10:07 +0000)
commitc3190b22b03ab147a048395546a8abfa7a4c47de
treee8665d8f704a0f5fc9d8daf6ce7a1715ef9bdc6b
parentbf2da5d57d7532855e56538a4a7242c705b1d27d
gas: elf: Relax rules for SHF_STRING sections

Commit af3394d97a8c5187085c0eec5fb03e8da88db5fb allowed sections
declared with "S" (SHF_STRING) to specify the entity size, but then
would warn if the entity size was omitted, as with the old syntax.

Unfortunately, since specifying the entity size is incompatible with
binutils 2.43 or earlier, this makes it impossible to specify a
strings section in source code without generating an assembly warning
(the new syntax isn't supported in older assemblers and the old syntax
generates warnings).

Nevertheless, the old code was wrong in that it did not set the entity
size at all, in contravention of the ELF specification (though to date
there are no known cases where this mattered outside of mergeable
sections).

Fix this by permitting the original syntax without a warning again,
but by defaulting the entity size to 1.  This is compatible with the
most common case of strings being byte-based.

Added some tests for the various flavours of declaration that we
support.
gas/config/obj-elf.c
gas/doc/as.texi
gas/testsuite/gas/elf/elf.exp
gas/testsuite/gas/elf/string.d [new file with mode: 0644]
gas/testsuite/gas/elf/string.s [new file with mode: 0644]