From: "H.J. Lu" <hjl.tools@gmail.com>
To: Alan Modra <amodra@gmail.com>
Cc: Kaylee Blake <klkblake@gmail.com>, Binutils <binutils@sourceware.org>
Subject: Re: RFC: [PATCH] ELF: Don't require section header on ELF objects
Date: Sun, 8 Mar 2020 19:35:56 -0700 [thread overview]
Message-ID: <CAMe9rOpp5mZdQh+uK5s4fReyxXpazQK0CJLbYPRgAbWzuQw7vw@mail.gmail.com> (raw)
In-Reply-To: <20200309022309.GK5384@bubble.grove.modra.org>
On Sun, Mar 8, 2020 at 7:23 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Mon, Mar 09, 2020 at 12:29:48PM +1030, Kaylee Blake wrote:
> > 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:
> > >> 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
>
> It doesn't. The snippet of .dynsym I posted was from a binary with
> DT_GNU_HASH. elflink.c:_bfd_elf_link_renumber_dynsyms should convince
> you that any ordering seen is by chance.
>
> >, and my understanding is
> > that DT_GNU_HASH in fact requires this behaviour.
>
> Apparently not. ;-)
>
> > 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.
>
x86 backend does:
if (!local_undefweak
&& !h->def_regular
&& (h->plt.offset != (bfd_vma) -1
|| eh->plt_got.offset != (bfd_vma) -1))
{
/* Mark the symbol as undefined, rather than as defined in
the .plt section. Leave the value if there were any
relocations where pointer equality matters (this is a clue
for the dynamic linker, to make function pointer
comparisons work between an application and shared
library), otherwise set it to zero. If a function is only
called from a binary, there is no need to slow down
shared libraries because of that. */
sym->st_shndx = SHN_UNDEF;
if (!h->pointer_equality_needed)
sym->st_value = 0;
}
Entries in DT_GNU_HASH were originally defined. A backend
may change some entries to undefined. I think my patch is OK.
--
H.J.
next prev parent reply other threads:[~2020-03-09 2:36 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-08 17:59 H.J. Lu
2020-03-08 18:06 ` H.J. Lu
2020-03-08 23:35 ` Alan Modra
2020-03-08 23:46 ` H.J. Lu
2020-03-09 0:02 ` H.J. Lu
2020-03-09 0:02 ` Kaylee Blake
2020-03-09 0:05 ` Alan Modra
2020-03-09 1:36 ` H.J. Lu
2020-03-09 1:59 ` Kaylee Blake
2020-03-09 2:23 ` Alan Modra
2020-03-09 2:35 ` H.J. Lu [this message]
2020-03-09 4:14 ` H.J. Lu
2020-03-09 4:59 ` Kaylee Blake
2020-03-09 11:56 ` Alan Modra
2020-03-08 23:24 ` Kaylee Blake
2020-03-08 23:29 ` H.J. Lu
2020-03-08 23:38 ` Alan Modra
2020-03-08 23:45 ` H.J. Lu
2020-03-12 2:14 ` Fangrui Song
2020-03-09 8:13 ` Florian Weimer
2020-03-09 12:54 ` Kaylee Blake
2020-03-09 13:06 ` Florian Weimer
2020-03-09 13:14 ` Kaylee Blake
2020-03-09 13:16 ` Florian Weimer
2020-03-09 13:28 ` Kaylee Blake
2020-03-09 13:29 ` Florian Weimer
2020-03-09 13:45 ` Kaylee Blake
2020-03-09 13:54 ` H.J. Lu
2020-03-09 14:02 ` Kaylee Blake
2020-03-09 14:52 ` Florian Weimer
2020-03-09 15:07 ` Kaylee Blake
2020-03-09 15:29 ` Florian Weimer
2020-03-09 13:44 ` Alan Modra
2020-03-09 13:54 ` Kaylee Blake
2020-03-09 22:34 ` Alan Modra
2020-03-10 0:14 ` H.J. Lu
2020-03-09 14:34 ` Michael Matz
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=CAMe9rOpp5mZdQh+uK5s4fReyxXpazQK0CJLbYPRgAbWzuQw7vw@mail.gmail.com \
--to=hjl.tools@gmail.com \
--cc=amodra@gmail.com \
--cc=binutils@sourceware.org \
--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).