From: "H.J. Lu" <hjl.tools@gmail.com>
To: Fangrui Song <i@maskray.me>, Kaylee Blake <klkblake@gmail.com>
Cc: Binutils <binutils@sourceware.org>
Subject: Re: [PATCH 0/7] ELF: Don't require section header on ELF objects
Date: Wed, 18 Mar 2020 18:32:40 -0700 [thread overview]
Message-ID: <CAMe9rOrFZEiaGvvPf+JiSCpK7ByU2xWmgvvGYg9VfZaiqD1fPA@mail.gmail.com> (raw)
In-Reply-To: <20200319004818.GA17438@gmail.com>
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.
next prev parent reply other threads:[~2020-03-19 1:33 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-08 23:42 H.J. Lu
2020-03-08 23:42 ` [PATCH 1/7] " H.J. Lu
2020-03-08 23:42 ` [PATCH 2/7] bfd: Reconstruct dynamic symbol table from PT_DYNAMIC segment H.J. Lu
2020-03-08 23:42 ` [PATCH 3/7] readelf: Compute dynamic symbol table size from hash table H.J. Lu
2020-03-08 23:42 ` [PATCH 4/7] ld: Add a simple test for -z nosectionheader H.J. Lu
2020-03-08 23:42 ` [PATCH 5/7] binutils: Add --remove-section-header tests H.J. Lu
2020-03-08 23:42 ` [PATCH 6/7] ld: Add tests for -z nosectionheader and --remove-section-header H.J. Lu
2020-03-08 23:42 ` [PATCH 7/7] ld: Add -z nosectionheader test to bootstrap.exp H.J. Lu
2020-03-19 0:48 ` [PATCH 0/7] ELF: Don't require section header on ELF objects Fangrui Song
2020-03-19 1:32 ` H.J. Lu [this message]
2020-03-19 1:45 ` Kaylee Blake
2020-05-02 14:19 ` H.J. Lu
[not found] ` <06c41571-09ef-d107-ee21-38af17f6d20b@gmail.com>
2020-08-07 13:11 ` Has FSF stopped processing copyright paperwork? H.J. Lu
2020-08-07 13:28 ` Richard Biener
2020-08-14 15:25 ` Kaylee Blake
2021-04-02 13:45 ` H.J. Lu
2021-04-02 15:21 ` Mark Wielaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAMe9rOrFZEiaGvvPf+JiSCpK7ByU2xWmgvvGYg9VfZaiqD1fPA@mail.gmail.com \
--to=hjl.tools@gmail.com \
--cc=binutils@sourceware.org \
--cc=i@maskray.me \
--cc=klkblake@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).