[PATCH 0/7] ELF: Don't require section header on ELF objects
H.J. Lu
hjl.tools@gmail.com
Thu Mar 19 01:32:40 GMT 2020
More information about the Binutils mailing list
Thu Mar 19 01:32:40 GMT 2020
- Previous message (by thread): [PATCH 0/7] ELF: Don't require section header on ELF objects
- Next message (by thread): [PATCH 0/7] ELF: Don't require section header on ELF objects
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Mar 18, 2020 at 5:48 PM Fangrui Song <i@maskray.me> wrote: > > >Section header isn't mandatory on ELF executable nor shared library. > >This patch set adds a new linker option, -z nosectionheader, to omit > >ELF section header when building an executable or shared library, 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 entries, 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 undefined symbols are placed > >before defined ones, the highest symbol index in DT_GNU_HASH and > >DT_MIPS_XHASH is the highest dynamic symbol table index. > > > > > >H.J. Lu (5): > > bfd: Reconstruct dynamic symbol table from PT_DYNAMIC segment > > readelf: Compute dynamic symbol table size from hash table > > binutils: Add --remove-section-header tests > > ld: Add tests for -z nosectionheader and --remove-section-header > > ld: Add -z nosectionheader test to bootstrap.exp > > > >Kaylee Blake (2): > > ELF: Don't require section header on ELF objects > > ld: Add a simple test for -z nosectionheader > For objcopy --remove-section-header, we can probably implement an > enhanced feature --strip-sections first. eu-strip and llvm-objcopy > (since https://reviews.llvm.org/D38335) have --strip-sections. I have renamed --remove-section-header to --strip-sections on users/hjl/pr25617/master branch: https://gitlab.com/x86-binutils/binutils-gdb/-/tree/users/hjl/pr25617/master Kaylee, is your paper work with FSF in order? I will submit the updated patch set after your paper is on file with FSF. > --strip-sections strips the section header table and sections not > covered by a segment. In llvm-objcopy, a non-SHF_ALLOC section can > covered by a segment. I think objcopy does it by default. > > For -z nosectionheader, I am questioning about the potential use case. > As others have commented on the thread "ELF: Don't require section header on ELF objects", > such shared objects should not be used for link. For runtime only use > cases, perhaps we can do that with a post-processing tool. -z nosectionheader works on both executable and shared library. The use case for shared library can be dlopen-only shared library. > > For readelf dumping of PT_DYNAMIC and DT_GNU_HASH, I think they are useful features. I submitted a separate readelf patch: https://sourceware.org/pipermail/binutils/2020-March/110211.html Thanks. -- H.J.
- Previous message (by thread): [PATCH 0/7] ELF: Don't require section header on ELF objects
- Next message (by thread): [PATCH 0/7] ELF: Don't require section header on ELF objects
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list