From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: dynamic linking (Re: [musl] musl and android)
Date: Thu, 15 Jan 2015 08:34:45 -0500 [thread overview]
Message-ID: <20150115133445.GQ4574@brightrain.aerifal.cx> (raw)
In-Reply-To: <20150115130432.GZ14316@example.net>
On Thu, Jan 15, 2015 at 02:04:32PM +0100, u-wsnj@aetey.se wrote:
> On Thu, Jan 15, 2015 at 07:15:36AM -0500, Rich Felker wrote:
> > > > and executing the program via a wrapper script that manually invokes
> > > > the dynamic linker (so the hard-coded PT_INTERP pathname isn't
> > > > needed).
>
> > > Actually I believe (and know from long time experience) this to be
> > > the only "sane"/robust/general way to run dynamically linked executables.
> >
> > It depends on your perspective. If you're viewing them as
> > self-contained entities, then yes, but if you're viewing them as
> > something running in an existing library ecosystem, there's no
> > problem.
>
> Right, it depends. For the second perspective you seem to imply that
> an "ecosystem" is to be managed in a certain way.
>
> Binaries belonging to my "library ecosystems" still can be subject to
> the C library tests and upgrades on a per-binary basis, not only "all
> binaries belonging to the same ecosystem at once", which is of course
> possible as well.
>
> This would be impossible if I'd rely on the hardcoded loader path.
That's why I said i depends on your perspective. From your perspective
this does not work. From most traditional distributions' perspectives,
it does.
> > > I don't think that the implications of hardcoding the interpreter
> > > path were well understood when dynamic linking was first deployed,
> > > the hardcoding merely became percepted as the only/natural approach
> > > when the purpose was to cheaply imitate the behaviour of statically
> > > linked programs. (This mimics the #!/... which is similarly
> > > limited/broken. The plain text scripts are though relatively easy
> > > to modify to hack around the limitation, according to local curcumstances)
> >
> > I think this could be fixed easily by having the kernel support
> > $ORIGIN in PT_INTERP.
>
> Unfortunately, no. $ORIGIN does not and can not replace a run time
> choice of the dynamic loader. As a simple example, consider a binary on
> a readonly media. How would you convince the kernel to run a different
> loader than assumed (among others) by the path to the mount point of
> the media? In my eyes the mounting of the media (possibly with lots of
> binaries on it) and running a certain loader for a certain binary are
> very different things and do not have to / should not depend on each other.
If you're distributing the binary and dynamic loader/libc and all
libraries it needs together, I'd assume they'd all be in the same
directory, or else in ../lib/ relative to the binary. In that case
$ORIGIN works perfectly fine. Note that $ORIGIN is _not_ an
environment variable; it's a dynamic-linker feature for locating
libraries relative to the ELF file (main executable or other library)
that needs (via DT_NEEDED) them, and the same concept would work for
PT_INTERP.
Rich
next prev parent reply other threads:[~2015-01-15 13:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-15 9:13 musl and android Рысь
2015-01-15 11:01 ` Rich Felker
2015-01-15 12:00 ` dynamic linking (Re: [musl] musl and android) u-wsnj
2015-01-15 12:15 ` Rich Felker
2015-01-15 13:04 ` u-wsnj
2015-01-15 13:34 ` Rich Felker [this message]
2015-01-15 15:56 ` OT: " u-wsnj
2015-01-15 13:53 ` musl and android Рысь
2015-01-18 6:32 ` Рысь
2015-01-18 6:44 ` Rich Felker
2015-01-18 8:01 ` Рысь
2015-01-18 16:40 ` Rich Felker
2015-01-19 18:00 ` Рысь
2015-01-21 10:34 ` Рысь
2015-01-21 18:36 ` Rich Felker
2015-01-22 2:37 ` Рысь
2015-01-31 15:08 ` Рысь
2015-02-03 5:52 ` 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=20150115133445.GQ4574@brightrain.aerifal.cx \
--to=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).