public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Fengkai Sun <qcloud1014@gmail.com>
To: libc-help@sourceware.org
Subject: The correctness of dlopen-ing a PIE executable
Date: Tue, 4 May 2021 00:20:24 +0800	[thread overview]
Message-ID: <CAF6YOcMOC4NsbfbEWwrb+9vYLxD_7aiFVR2O329=_KP-6=USmg@mail.gmail.com> (raw)

Hi list,

I'm very interested in the idea of dynamically loading a PIE
executable using dlopen, and I found a patch at:
https://sourceware.org/bugzilla/show_bug.cgi?id=11754

However, as the comment(
https://sourceware.org/bugzilla/show_bug.cgi?id=11754#c13) below suggests,
this is a bad idea. So glibc explicitly forbids it in dl-load.c.

But in this question:
https://stackoverflow.com/questions/64659713/why-does-dynamically-loading-of-pies-no-longer-work-in-glibc,
the author shows that:

* recompile the executable using -fPIC, which eliminates relocation type
R_X86_64_COPY, will fix the bug in
https://sourceware.org/bugzilla/show_bug.cgi?id=11754#c15
* constructors, relocations, and thread local variables seem to work OK

I know that the reasons the author above listed are probably not
exhaustive, so I want to make it clear that is there any irrecoverable
problem that prevents dlopen to load PIE executable correctly?(suppose we
force the executable enable -fPIC )
If so, how will a modified loader manage to solve that, as mentioned in
https://sourceware.org/bugzilla/show_bug.cgi?id=11754#c16  ?

Thank you very much.


Best,
Fengkai

                 reply	other threads:[~2021-05-03 16:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='CAF6YOcMOC4NsbfbEWwrb+9vYLxD_7aiFVR2O329=_KP-6=USmg@mail.gmail.com' \
    --to=qcloud1014@gmail.com \
    --cc=libc-help@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).