This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: How to prohibit shared library binding in absolute path?
- From: Ralf Wildenhues <Ralf dot Wildenhues at gmx dot de>
- To: Pan ruochen <panruochen at gmail dot com>
- Cc: binutils <binutils at sourceware dot org>
- Date: Mon, 21 Mar 2011 07:44:06 +0100
- Subject: Re: How to prohibit shared library binding in absolute path?
- References: <AANLkTinn=j_7hujXNBfYQgvQgqX=75aEeYjp_2g=J_Rv@mail.gmail.com>
Hello Pan,
* Pan ruochen wrote on Mon, Mar 21, 2011 at 07:28:47AM CET:
> I link an application against some shared libraries in absolute-path format.
> The linker writes the absolute path into the output application.
>
> $gcc -fpic -shared -fvisibility=hidden -O2 -o libs1.so s1.c
> $gcc -fpic -shared -fvisibility=hidden -O2 -o libs2.so s2.c
> $gcc -O2 -o foo -Wl,-rpath=. main.c /home/admin/x1/libs1.so libs2.so
To avoid that, give the libraries a soname to get that recorded in
DT_NEEDED of consumers, rather than the name of the library used for
linking: -Wl,-soname,libs1.so
Cheers,
Ralf