This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Alternate character for dollar sign in $ORIGIN?
- From: Matt Rice <ratmice at gmail dot com>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: Nick Clifton <nickc at redhat dot com>, noloader at gmail dot com, Binutils <binutils at sourceware dot org>
- Date: Tue, 4 Jun 2019 14:44:40 +0000
- Subject: Re: Alternate character for dollar sign in $ORIGIN?
- References: <CAH8yC8nMzTeAWUVa6c=Y504tXZUbdq0aMJmVXbv29+L9Sh_y=g@mail.gmail.com> <1461b09c-ea04-4b9b-9ca8-6c57446e0ffc@redhat.com> <mvm5zpl8obr.fsf@suse.de>
On Tue, Jun 4, 2019 at 1:36 PM Andreas Schwab <schwab@suse.de> wrote:
>
> On Jun 04 2019, Nick Clifton <nickc@redhat.com> wrote:
>
> > Hi Jeffrey,
> >
> >> Does GNU allow an alternate character?
> >
> > No. :-(
> >
> > The relevant code is in ..._search_needed() in ld/emultempl/elf32.em
> > where there is:
> >
> > while ((var = strchr (filename + offset, '$')) != NULL)
> >
> > So either you are going to have to get creative about escaping the dollar
> > sign, or else generate a patch for the linker...
>
> You would also need to change the runtime linker. It's part of the ABI.
Not necessarily, ld could turn whatever new alternate character into $
in the dynamic section,
If linking with gcc, perhaps you could do so via a gcc plugin, and let
gcc do the replacement passing the $ to ld directly, so not bother
patching ld at all (guess it's possible but have not tried?)
If we actually feel the need for a new alternate character a more
round-about way to actually add a new alternate character (to the
runtime linker) is via the rtld-audit interface, But that doesn't
afaik have a linkable mechanism on glibc, as such it is currently only
doable via environment variable LD_AUDIT...
There was one for solaris, /lib/secure
https://illumos.org/man/1/ld.so.1#security
but with that you can add new substitution sequences, not natively
understood by the runtime linker...here is an example, it uses $, but
it could be anything...
I wouldn't mind spending effort to write a patch for rtld, but it's a bit hairy,
anyhow here is an example using the environment variable...
https://gitlab.com/ratmice/framework-plugin/blob/master/Makefile#L49
https://gitlab.com/ratmice/framework-plugin/blob/master/audit.c
dlopening: https://gitlab.com/ratmice/framework-plugin/blob/master/test-exec.c#L9