[PATCH] gas: elf: Relax rules for SHF_STRING sections
Fangrui Song
i@maskray.me
Sat Jan 18 05:45:47 GMT 2025
On Fri, Jan 17, 2025 at 10:26 AM Richard Earnshaw <rearnsha@arm.com> wrote:
>
> 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).
I also replied on
https://sourceware.org/pipermail/binutils/2025-January/138826.html
The traditional sh_entsize=0, SHF_STRINGS behavior for "S" probably
implies that assembly files should not take gas's "S" behavior as
guaranteed or a feature.
> 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.
Could the assembly files drop "S" as SHF_STRINGS without SHF_MERGE
doesn't serve a purpose?
sh_entsize=1 seems fine, but the warning makes sense as well.
More information about the Binutils
mailing list