This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
How to prohibit shared library binding in absolute path?
- From: Pan ruochen <panruochen at gmail dot com>
- To: binutils <binutils at sourceware dot org>
- Date: Mon, 21 Mar 2011 14:28:47 +0800
- Subject: How to prohibit shared library binding in absolute path?
Hi All,
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
$readelf -a foo | grep Shared
?0x00000001 (NEEDED)???????????????????? Shared library:
[/home/admin/x1/libs1.so]
?0x00000001 (NEEDED)???????????????????? Shared library: [libs2.so]
?0x00000001 (NEEDED)???????????????????? Shared library: [libc.so.6]
The shared libraries couldn't be moved to other directories since `foo' inform
the dynamic linker that libs1.so must be inside the directory /home/admin/x1.
This will cause problems for cross building.
I expect to get while linking agaist /home/admin/x1/libs1.so:
$readelf -a foo | grep Shared
?0x00000001 (NEEDED)???????????????????? Shared library: [libs1.so]
?0x00000001 (NEEDED)???????????????????? Shared library: [libs2.so]
?0x00000001 (NEEDED)???????????????????? Shared library: [libc.so.6]
How to do?
PRC
Mar 21,2011