glibc and $ORIGIN

Ryan Arnold
Tue May 5 22:19:00 GMT 2009

On Tue, May 5, 2009 at 5:05 PM, Mike Frysinger <> wrote:
> On Tuesday 05 May 2009 17:44:16 Fabiano Sidler wrote:
>> I'd like to build a system unfixed to absolute paths, so with
>>   LDFLAGS += '-z origin'
>>   LD_RUN_PATH = '$ORIGIN/../lib'
>> Unfortunately, the glibc seems not to support it. Am I wrong or
>> is there a work-around for this?
> $ORIGIN on the glibc libs themselves will not work.  $ORIGIN on any other ELF
> should work just fine.  the ldso must always be in /lib/.
> -mike

There are ways to get around this but they're not for the faint of
heart.  The following wiki shows how one can tell the compiler that
the loader lives elsewhere:

And one can debug using the following trick:

Most people only use this for debugging GLIBC builds.  I don't
recommend it for production environments unless the entire toolchain
is standalone.

A better alternative is a chroot jail with GLIBC installed into the
chroot / directory.

Ryan S. Arnold

More information about the Libc-help mailing list