[ELF] Only mark as DT_NEEDED libs that are strictly necessary

Enhances the creation of an ELF dynamic executable by avoiding recording
unnecessary shared libraries as NEEDED to load a program.

To do this, we must keep track of not only symbols that were referenced but
also of COPY relocations, which steal the symbol from a shared library but does
not store from which lib this symbol came from. To fix this, this commit changes
ObjectSymbol to store the original library from which this symbol came. With
this information, we are able to build a list of the exact shared libraries that
must be marked as DT_NEEDED, instead of blindly marking all shared libraries as
needed.

This logic originally came from the MIPS backend with some adaptation.

Reviewers: atanasyan, shankar.easwaran

http://reviews.llvm.org/D5574


git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@219353 91177308-0d34-0410-b5e6-96231b3b80d8