.so dynamic library mangling tool

Peter L. Peres plp-ysDPMY98cNQDDBjDh4tngg at public.gmane.org
Mon Dec 6 08:30:54 UTC 2004


On Sun, 5 Dec 2004, Steve Harvey wrote:

> On Sun, Dec 05, 2004 at 06:18:56PM +0200, Peter L. Peres wrote:
>>
>> ld -shared -fpic -soname=libZ.so.6 ... -o /lib/hacked/libc.so.6 would work
>> great imho.
>
>  I was going to suggest using ld in this manner, however when I try
> copying a test library (adding a NEEDED entry), the filesize shrinks
> dramatically (to 8% of its original size!).
>
> ld  -shared -fpic -lz  --whole-archive libe2p.so.2.3 -o /tmp/libe2p2.so.2.3
> ls -l libe2p.so.2.3 /tmp/libe2p2.so.2.3
>
> -rwxr-xr-x    1 sgh      users        1380 Dec  5 21:13 /tmp/libe2p2.so.2.3*
> -rwxr-xr-x    1 root     root        16696 Dec 10  2002 libe2p.so.2.3*
>
>  A good idea of the amount of lost metadata can be shown by  readelf -a
> run against each one.  From just the size difference, I was loath to
> recommend such an approach.  Since Sergey is running Gentoo, I didn't
> think it would be untoward to suggest rebuilding a library (as a non-
> root user to be safe).

That would be good assuming he has the sources (he hasn't). The dynamic 
linking above does not lose data, it builds a stub library. Run ldd on the 
output library to see why. The real problem is that some dynamic linkers 
do not like this kind of recursion. ymmv. Afaik, it works under linux 
(current ld.so.2 etc).

Peter
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list