RFC: [PATCH] ELF: Don't require section header on ELF objects
Kaylee Blake
klkblake@gmail.com
Mon Mar 9 01:59:48 GMT 2020
More information about the Binutils mailing list
Mon Mar 9 01:59:48 GMT 2020
- Previous message (by thread): RFC: [PATCH] ELF: Don't require section header on ELF objects
- Next message (by thread): RFC: [PATCH] ELF: Don't require section header on ELF objects
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 9/3/20 12:06 pm, H.J. Lu wrote: > On Sun, Mar 8, 2020 at 5:05 PM Alan Modra <amodra@gmail.com> wrote: >> >> 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 >> > > I will make 2 changes: > > 1. Update -z nosectionheader to guarantee that the last entry in > dynamic symbol table > is defined. > 2. Update --remove-section-header to issue an error if the last entry > in dynamic symbol > table is undefined. > With some testing, it seems like ld will emit an ordered symbol table iff it's using the DT_GNU_HASH hash table style, and my understanding is that DT_GNU_HASH in fact requires this behaviour. So in that case, we don't need to do an additional check, because we only need the ordering if we are looking up through DT_GNU_HASH instead of DT_HASH. -- Kaylee Blake <klkblake@gmail.com> C is the worst language, except for all the others.
- Previous message (by thread): RFC: [PATCH] ELF: Don't require section header on ELF objects
- Next message (by thread): RFC: [PATCH] ELF: Don't require section header on ELF objects
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list