This is an archive of the discontinued LLVM Phabricator instance.

llvm-readobj: print COFF import table
ClosedPublic

Authored by ruiu on Oct 1 2014, 6:06 PM.

Details

Reviewers
majnemer
Summary

This patch adds a new flag "-coff-imports" to llvm-readobj. When the flag
is given, the command prints out the COFF import table.

Currently only the import table directory will be printed. I'm going to make
another patch to print out the imported symbols.

The implementation of import directory entry iterator in COFFObjectFile.cpp
was buggy. This patch fixes that too.

Diff Detail

Event Timeline

ruiu updated this revision to Diff 14301.Oct 1 2014, 6:06 PM
ruiu retitled this revision from to llvm-readobj: print COFF import table.
ruiu updated this object.
ruiu edited the test plan for this revision. (Show Details)
ruiu added a reviewer: majnemer.
ruiu added a subscriber: Unknown Object (MLST).
majnemer edited edge metadata.Oct 1 2014, 9:48 PM

You don't check to see if the import table is RVA based.

tools/llvm-readobj/COFFDumper.cpp
887–888

We should probably add an iterator_range for this, then you can use a range-based for loop.

890

Name

893

Addr1 and Addr2

Alternatively, you could do:

if (error(I->getImportLookupTableRVA(Addr))) return;
W.printHex("ImportLookupTableRVA", Addr);
if (error(I->getImportAddressTableRVA(Addr))) return;
W.printHex("ImportAddressTableRVA", Addr);
ruiu added a comment.Oct 2 2014, 10:02 AM

There's no notion of VA/RVA flag in the import table.
Maybe you are talking about the delay-load import table?
That's different from the (regular) import table.

tools/llvm-readobj/COFFDumper.cpp
887–888

Yeah, maybe we should, but not in this patch. All the other iterators in COFFObjects.cpp are written this way, so they should be updated all at once.

890

Done

893

Done

majnemer accepted this revision.Oct 2 2014, 12:04 PM
majnemer edited edge metadata.

LGTM

This revision is now accepted and ready to land.Oct 2 2014, 12:04 PM
Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in r218891.