diff options
author | Shoaib Meenai <smeenai@fb.com> | 2017-03-26 17:10:11 +0000 |
---|---|---|
committer | Shoaib Meenai <smeenai@fb.com> | 2017-03-26 17:10:11 +0000 |
commit | 7375448893c9c46a1a03a7dd3eaa2f6c63845738 (patch) | |
tree | 9c6ae84d71f924b2c475eb1a6e90cad8f2ee9add /llvm | |
parent | b71bb80c2debeab7128ce9be440d6601260910cd (diff) | |
download | bcm5719-llvm-7375448893c9c46a1a03a7dd3eaa2f6c63845738.tar.gz bcm5719-llvm-7375448893c9c46a1a03a7dd3eaa2f6c63845738.zip |
[llvm-readobj] Prefer ILT to IAT for reading COFF imports
We're seeing binutils ld produce binaries where the import address
table's NameRVA entry is actually a VA instead (i.e. it's already base
relocated), which llvm-readobj then chokes on. Both dumpbin and the
Windows loader are able to handle these binaries correctly, however, and
we can make llvm-readobj handle them correctly too by iterating the
import lookup table (which doesn't have a relocated NameRVA) rather than
the import address table.
The import lookup table and the import address table are supposed to be
identical on disk, and prior to r277298 the import lookup table would be
used by `llvm-readobj -coff-imports` anyway, so this shouldn't have any
functional change (except in the case of our malformed binaries). The
import lookup table can apparently be missing when using old Borland
linkers, so fall back to the import address table in that case.
Resolves PR31766.
Differential Revision: https://reviews.llvm.org/D31362
llvm-svn: 298812
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/tools/llvm-readobj/COFFDumper.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp index 10427654167..3c6ab1f5f7f 100644 --- a/llvm/tools/llvm-readobj/COFFDumper.cpp +++ b/llvm/tools/llvm-readobj/COFFDumper.cpp @@ -1439,12 +1439,18 @@ void COFFDumper::printCOFFImports() { StringRef Name; error(I.getName(Name)); W.printString("Name", Name); - uint32_t Addr; - error(I.getImportLookupTableRVA(Addr)); - W.printHex("ImportLookupTableRVA", Addr); - error(I.getImportAddressTableRVA(Addr)); - W.printHex("ImportAddressTableRVA", Addr); - printImportedSymbols(I.imported_symbols()); + uint32_t ILTAddr; + error(I.getImportLookupTableRVA(ILTAddr)); + W.printHex("ImportLookupTableRVA", ILTAddr); + uint32_t IATAddr; + error(I.getImportAddressTableRVA(IATAddr)); + W.printHex("ImportAddressTableRVA", IATAddr); + // The import lookup table can be missing with certain older linkers, so + // fall back to the import address table in that case. + if (ILTAddr) + printImportedSymbols(I.lookup_table_symbols()); + else + printImportedSymbols(I.imported_symbols()); } // Delay imports |