Alternate character for dollar sign in $ORIGIN?

Matt Rice ratmice@gmail.com
Tue Jun 4 14:44:00 GMT 2019


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



More information about the Binutils mailing list