Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Tue, 4 Sep 2018 10:38:21 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: How to use MUSL without installing it?

On Tue, Sep 04, 2018 at 02:00:03PM +0100, Jon Chesterfield wrote:
> Hi Rich,
> 
> I think this would be a great feature. A relative path to the loader means
> applications can run from wherever the user puts them. Currently achievable
> with static linking.
> 
> I've been considering linking an application into the (modified) loader to
> get a similar result. I think that's workable but haven't cut the code yet.
> 
> Could you sketch the design you have in mind?

The basic idea is not to have a PT_INTERP, and instead work like
static pie or the dynamic linker's entry point, where the entry point
code is responsible for self-relocation. It would then locate itself
(depends on /proc!), construct the ldso pathname relative to itself,
mmap ldso, patch up argv to match what ldso would get from the kernel,
and jump to ldso's entry point.

Unfortunately that would result in the main program partly being
relocated twice, and relocation is not idempotent on archs that use
REL style relocations, only ones that use RELA. So before passing off
execution to ldso, there needs to be a step that reverses all the
relocations that were already performed to put the main program back
in a pristine state. This could possibly be done with MADV_DONTNEED
but I don't like relying on that...

Rich


> I'm actually working on a design to allow direct invocation of
> > dynamic-linked programs without absolute dynamic linker paths, but it
> > will be a while before it's done and included in musl.
> >
> > Rich
> >

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.