[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: mklibs.py: library naming

On Tue Dec 18, 2001 at 05:38:59PM -0800, Matt Kraai wrote:
> Howdy,
> I'd like to make mklibs.py create the minimum number of directory
> entries for the libraries it reduces.  Unfortunately, my
> understanding of shared libraries is almost non-existent, so I'd
> appreciate a little help.  Is it necessary and sufficient to
> create a file named `lib<name>.so.<version>' for each library?

Here is the deal.  The way to know what is needed is by running
the ldd app.  For example:

    $ ldd /bin/true 
            libc.so.6 => /lib/libc.so.6 (0x4001f000)
	    /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
    $ readelf -d /bin/true | grep NEEDED
     0x00000001 (NEEDED)                     Shared library: [libc.so.6]
    $ readlink /lib/libc.so.6
Here, ldd tells us that /bin/true requires a library named
"libc.so.6".  ldd lists everything tagged as NEEDED in the ELF
header (and then recurses through the NEEDED things for each item
it finds till all dependancies are resolved).  Anyway, back to
ldd -- the stuff after the arrow ("/lib/libc.so.6") is where the
shared library loader has located a suitably named library.  In
this case (to make library upgrades on the desktop easy) Debian
has the suitably named library be a symlink created by ldconfig.
So we can read the link and see that this in fact points
elsewhere ("libc-2.2.4.so") but the fact that symlinks are used
at all on the boot floppies (where we never upgrade libraries) is
simply a waste of inodes (burning 4k a pop for ext2 if I recall

The last item, /lib/ld-linux.so.2, you will noticed has a hard
coded path.  This is because that is the shared library load,
which in fact is an ELF interpreter.  Check it out:

    $ readelf -l /bin/true | grep -A1 INTERP
      INTERP         0x0000f4 0x080480f4 0x080480f4 0x00013 0x00013 R 0x1
	  [Requesting program interpreter: /lib/ld-linux.so.2]

Anyway, enough pedantry.  On to the good stuff.  The simplest way
to install the correct libraries and not waste time with ldconfig
and thereby not waste space with symlinks, is to do something
like, which I wrote up a few years ago.


Erik B. Andersen             http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--

Attachment: checklibs.pl
Description: Perl program

Attachment: pgpDvJVFv_Nvq.pgp
Description: PGP signature

Reply to: