ld: pe: Fix linking against Microsoft import libraries with multiple DLLs
Initially, since
c6c37250e98f113755e0d787f7070e2ac80ce77e (in 1999),
in order to fix linking against Microsoft import libraries, ld did
internally rename members of such libraries. At that point, the
criteria for being considered a Microsoft import library was that
every archive member had the same name (no regard for exactly what
that name was).
This was later amended in
44dbf3639f127af46d569ad96b6242dfbc4c0a89
(in 2003) to allow for Microsoft import libraries with intermixed
static object files. At this point, the criteria were extended, so
that all members following the first member named *.dll either had
the exact same member name, or be named *.obj. (Curiously, this would
allow members with any name if it precedes the first one named *.dll.)
In practice, Microsoft style import libraries can contain
members for linking against more than one DLL (built by merging
multiple regular import libraries into one).
Instead of trying to do validation of the whole archive before
considering it a Microsoft style import library, relax the criteria
for doing the member renaming: If an archive member is named *.dll
and it contains .idata sections, assume that that member is a
Microsoft import file, and apply the renaming scheme.
This works for imports for any number of DLLs in the same library,
intermixed with other static object files (regardless of their
names), and vastly simplifies the code.
LLVM generates Microsoft style import libraries, and Rust builds
seem to bundle up multiple import libraries together with some
Rust specific static objects. This fixes linking directly against
them with ld.bfd.