[lld] Fix --exclude-libs broken when --whole-archive is used
authorOleg Ranevskyy <oranevskyy@accesssoftek.com>
Tue, 31 Oct 2017 13:51:06 +0000 (13:51 +0000)
committerOleg Ranevskyy <oranevskyy@accesssoftek.com>
Tue, 31 Oct 2017 13:51:06 +0000 (13:51 +0000)
commit0cf24ed9aaacfcd65221e882359307e5b8f320b8
tree1fbc0e6f6566f42f748b4e3f0396cb471c8d8215
parentf753bfeeec449dcd0e56bfa98b359598e4798b1f
[lld] Fix --exclude-libs broken when --whole-archive is used

Summary:
**Problem**
`--exclude-libs` does not work for static libraries affected by the `--whole-archive` option.

**Description**
`--exclude-libs` creates a list of static library paths and does library lookups in this list.
`--whole-archive` splits the static libraries that follow it into separate objects. As a result, lld no longer sees static libraries among linked files and does no `--exclude-libs` lookups.

**Solution**
The proposed solution is to make `--exclude-libs` consider object files too. When lld finds an object file it checks whether this file originates from an archive and, if so, looks the archive up in the `--exclude-libs` list.

Reviewers: ruiu, rafael

Reviewed By: ruiu

Subscribers: asl, ikudrin, llvm-commits, emaste

Tags: #lld

Differential Revision: https://reviews.llvm.org/D39353

llvm-svn: 316998
lld/ELF/Driver.cpp
lld/test/ELF/exclude-libs.s