This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] Prefer ILT to IAT for reading COFF imports
ClosedPublic

Authored by smeenai on Mar 24 2017, 6:15 PM.

Details

Summary

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.

Event Timeline

smeenai created this revision.Mar 24 2017, 6:15 PM
compnerd accepted this revision.Mar 26 2017, 9:27 AM
compnerd added inline comments.
tools/llvm-readobj/COFFDumper.cpp
1442

ILT would be better I think than ImportLookupTable

1445

IAT would be better than ImportAddressTable I think

This revision is now accepted and ready to land.Mar 26 2017, 9:27 AM
smeenai added inline comments.Mar 26 2017, 10:14 AM
tools/llvm-readobj/COFFDumper.cpp
1442

Will change before committing.

1445

Will change before committing.

This revision was automatically updated to reflect the committed changes.