On 4/16/20 10:38 AM, Mark Wielaard wrote:
> glibc elf.h has defined SHF_EXCLUDE since 2003, apparently because
> Solaris defined it. I cannot find when it was introduced in Solaris.
> The Solaris documentation describes it as:
>
> SHF_EXCLUDE This section is excluded from input to the link-edit of
> an executable or shared object. This flag is ignored if the
> SHF_ALLOC flag is also set, or if relocations exist against the
> section.
I expected this to take longer, but it's actually a pretty short
story. SHF_EXCLUDE was added to Solaris in 1996, in a PSARC case
entitled 'PSARC/1996/249 Addition of SHF_EXCLUDE Section Attribute Flag'.
The case was filed by my partner in crime of many years, Rod Evans.
And it was born as a psABI definition, for all our psABIs.
Here are the important details:
> Addition of a new attribute SHF_EXCLUDE
> =======================================
>
> Description
> -----------
> This is a proposal to add a definition for a new section header
> attribute, SHF_EXCLUDE, in the following header files:
> /usr/include/sys/elf_386.h
> /usr/include/sys/elf_SPARC.h
> /usr/include/sys/elf_ppc.h
> The SHF_EXCLUDE flag has the value 0x80000000
>
> Motivation
> ----------
> The motivation for this addition is to support the new section
> flag defined by PowerPC ABI.
>
> The new SHF_EXCLUDE flag is documented in:
> SYSTEM V APPILICATION BINARY INTERFACE
> PowerPC Processor Supplement
> September 1995
>
> The document describes the use of the flag as:
> The SHF_EXCLUDE flag specifies that the link editor is to
> exclude this section from executable and shared objects that
> it builds when those objects are not to be further relocated.
> SHF_EXCLUDE has the value 0x80000000.
>
> In addition to PowerPC requirement, and to be consistant with other
> ELF/link-editor feature, this attribute should be available on our
> other supported platforms.
>
> The linker needs to be modified to handle the sections
> with the new attribute on. Therefor the SHF_EXCLUDE flag
> has to be defined in a header file.
The requirement for "our other supported platforms" came from our
compiler group, which immediately found general use for it.
Hence, Sun added SHF_EXCLUDE in 1996, predating the gABI meetings
that happened in the early 2000's. It was born as a psABI value
on all the platforms of the time, and it seems that the reason
it was done as a psABI value rather than as a generic one is because
it was already in the PPC psABI, and we might not have been in
a position to have the PPC psABI changed.
I think it's probably also true that since this was before the
gABI meetings of the early 2000s, that having it be a psABI
value wasn't seen as being significantly different than as
a generic value, and so, didn't worry anyone (again, just guessing).
I don't know if SHF_EXCLUDE was discussed in those gABI meetings,
but SHF_EXCLUDE would have been in the Solaris headers at that
time, so it must have been at least seen by others at that time.
It's amusing to note that while we likely made this a psABI
value to accommodate the Power psABI, we only released one version
of Solaris for the PPC, Solaris 2.5.1. The PPC port was canceled
before the next (2.6) release.
Given the age and widespread use of this existing value on all
platforms, my preference would be that we continue with this
as is, and that new psABIs adopt SHF_EXCLUDE, or at least refrain
from assigning its value (0x80000000) for any other purpose.
Given that you're seeing widespread us of it in gcc and clang,
I think we'd be safe to formalize what already seems to be
a defacto standard.
- Ali