* How to prohibit shared library binding in absolute path?
@ 2011-03-21 6:28 Pan ruochen
2011-03-21 6:44 ` Ralf Wildenhues
0 siblings, 1 reply; 2+ messages in thread
From: Pan ruochen @ 2011-03-21 6:28 UTC (permalink / raw)
To: binutils
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How to prohibit shared library binding in absolute path?
2011-03-21 6:28 How to prohibit shared library binding in absolute path? Pan ruochen
@ 2011-03-21 6:44 ` Ralf Wildenhues
0 siblings, 0 replies; 2+ messages in thread
From: Ralf Wildenhues @ 2011-03-21 6:44 UTC (permalink / raw)
To: Pan ruochen; +Cc: binutils
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-03-21 6:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-21 6:28 How to prohibit shared library binding in absolute path? Pan ruochen
2011-03-21 6:44 ` Ralf Wildenhues
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 read-only IMAP folder(s) and NNTP newsgroup(s).