On 10/8/25 5:32 PM, Cary Coutant wrote:
> This is why I didn't say it must be 0. If we say it's meaningless and
> isn't used, why would anything think their link editor is broken if it
> puts an arbitrary file offset there?
A good link-editor never writes garbage, so if I see non-zero
values, and I'm told they're meaningless, I'm going to conclude
that something is fishy. Either they're meaningful, and the spec
isn't telling me something I should know, or they're not, and the
link-editor shouldn't be giving them non-zero values, so there's
a bug to fix. One way or the other, something seems off, and I'm
going to dig.
> I guess I wouldn't be opposed to a note that some tools might use the
> field that way, but I don't want to make it look anything like a
> requirement.
Me either, which is why I called it an informational convention:
> Note that many link-editors follow a convention of
> setting sh_offset to the offset at which data would
> be found if the section were not SHT_NOBITS. These
> values are purely informational.
I accept that it didn't land as intended, but you can see
the effort to explain without requiring.
>
> I also don't want to open up the possibility that some psABI might coopt
> the sh_offset field for another purpose, so maybe a bit more careful
> wording is needed. Maybe rather than replace the existing wording "...
> contains the conceptual file offset", we could simply add a note that
> the conceptual file offset could be any valid file offset within the file.
We don't want some psABI to assign added meaning to sh_offset, whether
it's a valid offset or not though, do we? It occurs to me that one merit
of the old "offset where bits would go if there were bits" definition is
that it takes away any wiggle room for such coopting.
Rather than "any valid file offset", why not limit things to the 2
cases we actually condone? Something like:
A section of this type occupies no space in the file but
otherwise resembles SHT_PROGBITS. Because this section
contains no bytes, the sh_offset member has no meaning and
is not used. It may be set to 0, or alternatively, to the file
offset that the link editor would have assigned the section
if the type had been SHT_PROGBITS.
- Ali