From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12406 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Stefan_Fr=c3=b6berg?= Newsgroups: gmane.linux.lib.musl.general Subject: BUG: $ORIGIN does not seem to work Date: Fri, 26 Jan 2018 15:39:23 +0200 Message-ID: <17b31628-04b5-3181-4623-046ffc4c0cab@petroprogram.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------DDA2B4A2D49A5AB87F5F9869" X-Trace: blaine.gmane.org 1516974021 13923 195.159.176.226 (26 Jan 2018 13:40:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 26 Jan 2018 13:40:21 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 To: musl@lists.openwall.com Original-X-From: musl-return-12422-gllmg-musl=m.gmane.org@lists.openwall.com Fri Jan 26 14:40:17 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1ef4Em-0002vg-7F for gllmg-musl@m.gmane.org; Fri, 26 Jan 2018 14:40:12 +0100 Original-Received: (qmail 3133 invoked by uid 550); 26 Jan 2018 13:42:13 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 3094 invoked from network); 26 Jan 2018 13:42:12 -0000 Content-Language: en-US Xref: news.gmane.org gmane.linux.lib.musl.general:12406 Archived-At: This is a multi-part message in MIME format. --------------DDA2B4A2D49A5AB87F5F9869 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hello 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) GCC version 7.2 and musl 1.1.18 GCC configured with the following: gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-musl/7.2.0/lto-wrapper Target: x86_64-linux-musl Configured with: ../configure --prefix=/usr --build=x86_64-linux-musl --enable-languages=c,c++,lto --disable-multilib --disable-nls --disable-libmudflap --disable-libsanitizer --with-system-zlib --disable-werror --enable-gold=yes --enable-ld=yes --enable-plugin --enable-plugins --enable-lto --enable-default-pie --enable-default-ssp --with-linker-hash-style=gnu --enable-libgomp --with-fpmath=sse Thread model: posix gcc version 7.2.0 (GCC) Best regards Stefan Fröberg x.c ------------------------------ #include #include int main(void) {     OPENSSL_init_crypto(OPENSSL_INIT_NO_ADD_ALL_CIPHERS|OPENSSL_INIT_NO_ADD_ALL_DIGESTS,NULL);     return(0); } --------------DDA2B4A2D49A5AB87F5F9869 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

Hello

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)


GCC version 7.2 and musl 1.1.18

GCC configured with the following:
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-musl/7.2.0/lto-wrapper
Target: x86_64-linux-musl
Configured with: ../configure --prefix=/usr --build=x86_64-linux-musl --enable-languages=c,c++,lto --disable-multilib --disable-nls --disable-libmudflap --disable-libsanitizer --with-system-zlib --disable-werror --enable-gold=yes --enable-ld=yes --enable-plugin --enable-plugins --enable-lto --enable-default-pie --enable-default-ssp --with-linker-hash-style=gnu --enable-libgomp --with-fpmath=sse
Thread model: posix
gcc version 7.2.0 (GCC)


Best regards
Stefan Fröberg

x.c
------------------------------
#include <stdio.h>
#include <openssl/ssl.h>

int main(void)
{
    OPENSSL_init_crypto(OPENSSL_INIT_NO_ADD_ALL_CIPHERS|OPENSSL_INIT_NO_ADD_ALL_DIGESTS,NULL);
    return(0);
}

--------------DDA2B4A2D49A5AB87F5F9869--