In r253839 the default behaviour of ld(1) was changed such that all
libraries that need to be linked into an executable or library have to be
listed on the command line explicitly.  This commit fixes a bug in ld(1)
where it would scan dependencies of the libraries on the command line and
link them if needed if they were also found in ld.so.cache.

The important bit of the patch is the initialisation of needed.by such that
libraries found by scanning dependencies are marked as such and not used in
the link.

The patch is a backport of binutils git commit
d5c8b1f8561426b41aa5330ed60f578178fe6be2

The author gave permission to use it under GPLv2 terms.

PR:		192062
Exp-run by:	antoine
MFC after:	1 week


git-svn-id: svn+ssh://svn.freebsd.org/base/head@270757 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f