public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "Fāng-ruì Sòng" <maskray@google.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: "H.J. Lu" <hjl.tools@gmail.com>,
	GNU C Library <libc-alpha@sourceware.org>,
	"Carlos O'Donell" <carlos@redhat.com>,
	Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	 Joseph Myers <joseph@codesourcery.com>
Subject: Re: [PATCH v2] elf: Avoid nested functions in the loader (all ports) [BZ #27220]
Date: Thu, 23 Sep 2021 10:34:09 -0700	[thread overview]
Message-ID: <CAFP8O3KztG2z+Gw3-fBZngZveD9=U+bW7u-JgJH4MMpn3Wz3NA@mail.gmail.com> (raw)
In-Reply-To: <87v92rnrkg.fsf@oldenburg.str.redhat.com>

On Thu, Sep 23, 2021 at 10:13 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * Fāng-ruì Sòng:
>
> > For elf/dl-reloc.os on x86-64, I think the nested function version can
> > use *(rbp - offset) to get some arguments.
> > The new version needs more instructions but the cost is small compared
> > with the expensive _dl_lookup_symbol_x.
>
> I have a patch that reduces the number of _dl_lookup_symbol_x calls for
> the self-relocation (bootstrap or not):
>
>   [v3,3/3] elf: Rework exception handling in the dynamic loader [BZ #25486]
>   <https://patchwork.sourceware.org/project/glibc/patch/05e1b5b43416eba58f2bab968320fa3d38e33479.1607085588.git.fweimer@redhat.com/>
>
> It needs rebase on the current tree.
>
> We recently lost the internal _r_debug reference, which is probably a
> bug.  Other architectures have some other crud in ld.so.  But I think we
> can get the number of symbols used in self-relocation down to zero on
> all architectures fairly easily.
>
> Once we do that, how much of the bootstrap relocation goo is really
> left?
>
> Thanks,
> Florian
>

If self-relocations means relocations used in rtld.c and
elf/dl-reloc-static-pie.o:

The new version doesn't cause differences near _dl_lookup_symbol_x call sites.
I think the relocation code sequence doesn't change.

@@ -5757,7 +5789,7 @@
                        push    0
                        push    1
                        call     <L509>
-               0000000000004ec7:  R_X86_64_PLT32       _dl_lookup_symbol_x-0x4
+               0000000000004f27:  R_X86_64_PLT32       _dl_lookup_symbol_x-0x4
 <L509>:
                        pop     r8
                        pop     r9

The new rtld.os is slightly larger, but I guess that it is just
because GCC inlines one more place.

  reply	other threads:[~2021-09-23 17:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-23  7:17 Fangrui Song
2021-09-23  8:07 ` Andreas Schwab
2021-09-23  8:17   ` Fangrui Song
2021-09-23  8:39     ` Andreas Schwab
2021-09-23 13:08       ` Zack Weinberg
2021-09-23 16:11         ` Fangrui Song
2021-09-23 16:19 ` H.J. Lu
2021-09-23 16:58   ` Fāng-ruì Sòng
2021-09-23 17:13     ` Florian Weimer
2021-09-23 17:34       ` Fāng-ruì Sòng [this message]
2021-09-23 17:40         ` Florian Weimer
2021-09-23 19:05 ` Fangrui Song
2021-09-23 21:48   ` Florian Weimer
2021-09-23 22:41     ` Fāng-ruì Sòng
2021-09-24  5:58       ` Florian Weimer
2021-09-24  7:23         ` Florian Weimer
2021-09-24  7:32         ` Fāng-ruì Sòng
2021-09-24  8:27           ` Florian Weimer

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='CAFP8O3KztG2z+Gw3-fBZngZveD9=U+bW7u-JgJH4MMpn3Wz3NA@mail.gmail.com' \
    --to=maskray@google.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=carlos@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=hjl.tools@gmail.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    /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).