From: Paul Sokolovsky <pmiscml@gmail.com>
To: Rich Felker <dalias@libc.org>
Cc: musl@lists.openwall.com
Subject: Re: [musl] foreign-dlopen: dlopen() from static binary, again (and not the way you think!)
Date: Thu, 23 Apr 2020 12:16:26 +0300 [thread overview]
Message-ID: <20200423121627.3e4d3ecd@zenbook> (raw)
In-Reply-To: <20200423023941.GQ11469@brightrain.aerifal.cx>
Hello,
On Wed, 22 Apr 2020 22:39:41 -0400
Rich Felker <dalias@libc.org> wrote:
[]
> > Oh, forgot to say that I'm not looking for a way to load a
> > particular musl-dynlinked shared library into musl-staticlinked
> > binary. So, arguments like "but you'll need to carry around musl's
> > libc.so" don't apply. What I'm looking for is a way to have a
> > static closed-world application, but let it, at the user's request,
> > to interface with whatever system may be outside.
[]
> > of concept code is at
https://github.com/pfalcon/foreign-dlopen .
>
> In your example it looks like you're foreign_dlopen'ing glibc. That
> simply *can't* work, because part of the interface contract of all
> glibc functions is that they're called with the thread pointer
> register (%gs or %fs on i386 or x86_64 respectively) pointing to a
> glibc TCB, which will not be the case when they're invoked from a
> musl-linked (or other non-glibc-linked) program.
Thanks for the response and for the word of warning. As I mentioned,
this is essentially a proof of concept, and so far was tested only by
calling glibc's printf() from a host app which was either linked with
glibc itself or -nostdlib and static. And that was already more than
with any other ELF loader which I tried (which worked for simple
functions like write(), but crashed in anything more complex like
printf()).
But it certainly doesn't touch a case you describe, when "foreign" vs
local libc expect different values of %gs/%fs (so apparently, "foreign
function call" facility would need to swap them around a call).
>
> If you relax to the case where you're not doing that, and instead only
> opening *pure library* code which has no tie-in to global state or TLS
> contracts, then it should be able to work.
>
> Rich
--
Best regards,
Paul mailto:pmiscml@gmail.com
next prev parent reply other threads:[~2020-04-23 9:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-22 23:25 Paul Sokolovsky
2020-04-23 2:39 ` Rich Felker
2020-04-23 9:16 ` Paul Sokolovsky [this message]
2020-04-23 12:22 ` Szabolcs Nagy
2020-04-23 16:24 ` Rich Felker
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=20200423121627.3e4d3ecd@zenbook \
--to=pmiscml@gmail.com \
--cc=dalias@libc.org \
--cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).