RFC: [PATCH] ELF: Don't require section header on ELF objects
Alan Modra
amodra@gmail.com
Mon Mar 9 22:34:49 GMT 2020
On Tue, Mar 10, 2020 at 12:24:51AM +1030, Kaylee Blake wrote:
> On 10/3/20 12:14 am, Alan Modra wrote:
> > On Mon, Mar 09, 2020 at 11:24:44PM +1030, Kaylee Blake wrote:
> >> On 9/3/20 6:43 pm, Florian Weimer wrote:
> >>> In my opinion, it should NOT be possible to link against objects
> >>> without section headers. Lack of section headers clearly marks the
> >>> object as a run-time only object. This is useful if you want to
> >>> prevent developers to create DT_NEEDED dependencies on internal
> >>> libraries, for example.
> >
> > I agree.
> >
> >> For shared objects without debug symbols, the section header table is
> >> ~2kB on average of redundant data. I'm also not a fan of the
> >> inconsistency of having shared libraries that the dynamic linker is
> >> perfectly happy to load, but ld can't link against, especially since
> >> this seems like an oversight rather than an intended design decision.
> >
> > The ELF spec designed things that way. See figure 4.1 which I'll try
> > to represent in text.
> >
> > Figure 4-1: Object File Format
> >
> > |----------------------| |----------------------|
> > | ELF Header | | ELF Header |
> > |----------------------| |----------------------|
> > | Program header table | | Program header table |
> > | optional | | required |
> > |----------------------| |----------------------|
> > | Section 1 | | Segment 1 |
> > |----------------------| |----------------------|
> > | ... | | Segment 2 |
> > |----------------------| |----------------------|
> > | Section n | | Segment 3 |
> > |----------------------| |----------------------|
> > | ... | | ... |
> > |----------------------| |----------------------|
> > | Section header table | | Section header table |
> > | required | | optional |
> > |----------------------| |----------------------|
> > Linking View Execution View
> >
>
> I had interpreted that table in combination to various other references
> to which things are required vs optional in shared objects as meaning
> that the "execution view" applied to executables and shared objects, and
> the "linking view" applied to relocatable objects. You're saying that
> that table should be interpreted as saying that if a shared object is to
> be linkable, the spec is requiring it to have both sets of headers?
Yes. Just below the table: "Files used during linking must have a
section header table".
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list