This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Alternate character for dollar sign in $ORIGIN?

On Tue, Jun 4, 2019 at 1:36 PM Andreas Schwab <> wrote:
> On Jun 04 2019, Nick Clifton <> 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

but with that you can add new substitution sequences, not natively
understood by the runtime 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...

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]