RFC: [PATCH] ELF: Don't require section header on ELF objects
Alan Modra
amodra@gmail.com
Mon Mar 9 00:05:43 GMT 2020
On Sun, Mar 08, 2020 at 04:46:51PM -0700, H.J. Lu wrote:
> On Sun, Mar 8, 2020 at 4:35 PM Alan Modra <amodra@gmail.com> wrote:
> >
> > On Sun, Mar 08, 2020 at 11:06:33AM -0700, H.J. Lu wrote:
> > > On Sun, Mar 8, 2020 at 10:59 AM H.J. Lu <hjl.tools@gmail.com> wrote:
> > > >
> > > > Any comments?
> > > >
> > > > Kaylee, do you have copyright paper with FSF?
> > > >
> > > > H.J.
> > > > ---
> > > > Section header isn't mandatory on ELF executable nor shared library.
> > > > This patch adds a new linker option, -z nosectionheader, to omit ELF
> > > > section header when building an executable or shared library, adds
> > > > an objcopy and strip option, --remove-section-header, to remove ELF
> > > > section header from an executable or shared library.
> > > >
> > > > The PT_DYNAMIC segment contains DT_HASH/DT_GNU_HASH/DT_MIPS_XHASH,
> > > > DT_STRTAB, DT_SYMTAB, DT_STRSZ and DT_SYMENT, which can be used to
> > > > reconstruct dynamic symbol table when section header isn't available.
> > > > For DT_HASH, the number of dynamic symbol table entries equals the
> > > > number of chains. For DT_GNU_HASH/DT_MIPS_XHASH, only defined symbols
> > > > with non-STB_LOCAL indings are in hash table. Since in dynamic symbol
> > > > table, all symbols with STB_LOCAL binding are placed before symbols with
> > > > other bindings and all defined symbols are placed before undefined ones,
> > >
> > > It should read
> > >
> > > ---
> > > all symbols with STB_LOCAL binding are placed
> > > before symbols with other bindings and all undefined symbols are placed
> > > before defined ones,
> > > ---
> >
> > That's new to me. I don't think there is any ordering in .dynsym
> > among non-local symbols.
>
> I will get clarification from gABI group.
Well we certainly don't do such sorting. For example, from a freshly
build ld/ld-new --enable-targets=all
148: 0000000000f08380 4 OBJECT GLOBAL DEFAULT 25 opterr@GLIBC_2.2.5 (3)
149: 0000000000402f80 0 FUNC GLOBAL DEFAULT UND calloc@GLIBC_2.2.5 (3)
150: 0000000000881536 35 FUNC GLOBAL DEFAULT 13 _obstack_allocated_p
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list