Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 26 Jan 2018 15:21:37 +0100
From: Szabolcs Nagy <>
Subject: Re: BUG: $ORIGIN does not seem to work

* Stefan Fröberg <> [2018-01-26 15:39:23 +0200]:
> On glibc the following:
> gcc  -o x -Wl,-rpath='$ORIGIN/lib' x.c -L ./lib -lcrypto
> or
> gcc  -o x -Wl,-rpath,'$ORIGIN/lib' x.c -L ./lib -lcrypto
> Gives me binary with relative library path
> ldd x
> (0x00007ffcb6bee000)
> * => /home/wizard/kal-el/lib/
> (0x00007f0bc3593000)**
> * => /lib64/ (0x00007f0bc31e2000)
> => /lib64/ (0x00007f0bc2fde000)
> => /lib64/ (0x00007f0bc2dc7000)
>     /lib64/ (0x00007f0bc39d2000)
> cp -rap kal-el/* batman/
> ldd x
> (0x00007ffdbf0b6000)
> * => /home/wizard/batman/lib/
> (0x00007fb682149000)**
> * => /lib64/ (0x00007fb681d98000)
> => /lib64/ (0x00007fb681b94000)
> => /lib64/ (0x00007fb68197d000)
>     /lib64/ (0x00007fb682588000)
> But trying the same with musl does not seem to work?
> ldd x
> /lib/ (0x7f07372e2000)
> => /lib/ (0x7f07372e2000)
> and if i remove the -L ./lib from the command it uses system library
> gcc  -o x -Wl,-rpath,'$ORIGIN/lib'  x.c   -lcrypto
> ldd xx
>     /lib/ (0x7fdd8618d000)
> => /usr/lib/ (0x7fdd85ed7000)
> => /lib/ (0x7fdd8618d000)

$ORIGIN in rpath works fine in musl

you are doing something wrong

but it's hard to tell what: your ldd command is looking at
the wrong binary, we don't know what ldd you are using (e.g.
use ld-* --list foo to make this explicit), it's
not clear if the binary has $ORIGIN set up correctly since
you showed a gcc command line instead of readelf -d of the
generated executable, we don't know what paths have the
library and what paths the ldso tried (you can check this
by strace).

(there are some differences between musl and glibc:
e.g. glibc expands $ORIGIN in dlopen too while musl does
not, however in your case musl should work)

Powered by blists - more mailing lists

Your e-mail address:

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