Overlinking in base

Baptiste Daroussin bapt at FreeBSD.org
Wed Nov 5 13:00:02 UTC 2014


On Wed, Nov 05, 2014 at 02:54:31PM +0200, Konstantin Belousov wrote:
> On Wed, Nov 05, 2014 at 12:38:39PM +0100, Baptiste Daroussin wrote:
> > Hi all,
> > 
> > We do overlink a lot in the base system.
> > 
> > I wrote a script to check overlinking on the final binaries and running it on
> > /usr/bin files I got the following results:
> > https://wiki.freebsd.org/Overlinking
> > 
> > Most of the overlink are due to LDADD having all the recursive libraries which
> > for dynamic linking we do not need.
> > 
> > We might need them for static linking, but I think we should fix those.
> Fix how ?  Static libraries do not record dependencies, and linker
> must get list of all libraries to satisfy undefined symbols.
> 
> > 
> > I think anyway a binary Makefile should only declare its direct dependencies and
> > not the dependencies of its dependencies.
> No, this is wrong definition of overlinking.  Binary X, which depends
> on liba.so and libb.so, is overlinked, only when there is no symbol from
> libb.so which is directly referenced from X.  Mere fact that liba.so
> needs libb.so and X records DT_NEEDED for both a and b, is not enough.

That is what I do check and what I'm referencing, a good example is bsdtar which
links to all compression libs while libarchive itself does not expose any
symbols from them.

> 
> Could you, please, share the script to see how the overlinking is
> checked ?

Here you are:
https://people.freebsd.org/~bapt/check-links.sh

Beware it is dirty :)

Run it as check-links.sh nameofthebinary

Best regards,
Bapt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20141105/b425972b/attachment.sig>


More information about the freebsd-arch mailing list