mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: BUG: $ORIGIN does not seem to work
Date: Fri, 26 Jan 2018 15:21:37 +0100	[thread overview]
Message-ID: <20180126142137.GH4418@port70.net> (raw)
In-Reply-To: <17b31628-04b5-3181-4623-046ffc4c0cab@petroprogram.com>

* Stefan Fröberg <stefan.froberg@petroprogram.com> [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
>     linux-vdso.so.1 (0x00007ffcb6bee000)
> *    libcrypto.so.1.0.0 => /home/wizard/kal-el/lib/libcrypto.so.1.0.0
> (0x00007f0bc3593000)**
> *    libc.so.6 => /lib64/libc.so.6 (0x00007f0bc31e2000)
>     libdl.so.2 => /lib64/libdl.so.2 (0x00007f0bc2fde000)
>     libz.so.1 => /lib64/libz.so.1 (0x00007f0bc2dc7000)
>     /lib64/ld-linux-x86-64.so.2 (0x00007f0bc39d2000)
> 
> cp -rap kal-el/* batman/
> ldd x
>     linux-vdso.so.1 (0x00007ffdbf0b6000)
> *    libcrypto.so.1.0.0 => /home/wizard/batman/lib/libcrypto.so.1.0.0
> (0x00007fb682149000)**
> *    libc.so.6 => /lib64/libc.so.6 (0x00007fb681d98000)
>     libdl.so.2 => /lib64/libdl.so.2 (0x00007fb681b94000)
>     libz.so.1 => /lib64/libz.so.1 (0x00007fb68197d000)
>     /lib64/ld-linux-x86-64.so.2 (0x00007fb682588000)
> 
> 
> But trying the same with musl does not seem to work?
> ldd x
> /lib/ld-musl-x86_64.so.1 (0x7f07372e2000)
>     libc.so => /lib/ld-musl-x86_64.so.1 (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/ld-musl-x86_64.so.1 (0x7fdd8618d000)
>     libcrypto.so.1.1 => /usr/lib/libcrypto.so.1.1 (0x7fdd85ed7000)
>     libc.so => /lib/ld-musl-x86_64.so.1 (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-*-musl.so.1 --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)


  reply	other threads:[~2018-01-26 14:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-26 13:39 Stefan Fröberg
2018-01-26 14:21 ` Szabolcs Nagy [this message]
2018-01-26 23:50   ` Stefan Fröberg
2018-01-27 11:07     ` Szabolcs Nagy
2018-01-27 16:20       ` Stefan Fröberg
2018-01-27 16:42         ` Rich Felker
2018-01-27 17:14           ` Stefan Fröberg
2018-01-27 19:26         ` Szabolcs Nagy
2018-01-27 22:07           ` Stefan Fröberg
2018-01-28  0:54             ` Szabolcs Nagy
2018-02-07 17:35               ` Rich Felker
2018-02-07 20:28                 ` Szabolcs Nagy
2018-01-26 16:34 ` Rich Felker
2018-01-26 21:28   ` Stefan Fröberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180126142137.GH4418@port70.net \
    --to=nsz@port70.net \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).