diff options
author | Rui Ueyama <ruiu@google.com> | 2014-01-16 07:05:49 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2014-01-16 07:05:49 +0000 |
commit | fb432acff8c160749ac99576ec8da2a3f1987bc4 (patch) | |
tree | a3a92d288771698ee6d3a8ec96cea0f88683a72d /tools/llvm-objdump | |
parent | 9dcfdf61a843665ef2ab07ad5d8c0b213ef4b059 (diff) | |
download | llvm-fb432acff8c160749ac99576ec8da2a3f1987bc4.tar.gz llvm-fb432acff8c160749ac99576ec8da2a3f1987bc4.tar.bz2 llvm-fb432acff8c160749ac99576ec8da2a3f1987bc4.tar.xz |
llmv-objdump/COFF: Print export table contents.
This patch adds the capability to dump export table contents. An example
output is this:
Export Table:
Ordinal RVA Name
5 0x2008 exportfn1
6 0x2010 exportfn2
By adding this feature to llvm-objdump, we will be able to use it to check
export table contents in LLD's tests. Currently we are doing binary
comparison in the tests, which is fragile and not readable to humans.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199358 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-objdump')
-rw-r--r-- | tools/llvm-objdump/COFFDump.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/tools/llvm-objdump/COFFDump.cpp b/tools/llvm-objdump/COFFDump.cpp index 9c380100e8..df9c2cf2da 100644 --- a/tools/llvm-objdump/COFFDump.cpp +++ b/tools/llvm-objdump/COFFDump.cpp @@ -271,6 +271,36 @@ static void printImportTables(const COFFObjectFile *Obj) { } } +// Prints export tables. The export table is a table containing the list of +// exported symbol from the DLL. +static void printExportTable(const COFFObjectFile *Obj) { + outs() << "Export Table:\n"; + export_directory_iterator I = Obj->export_directory_begin(); + export_directory_iterator E = Obj->export_directory_end(); + if (I == E) + return; + outs() << " Ordinal RVA Name\n"; + error_code EC; + for (; I != E; I = I.increment(EC)) { + if (EC) + return; + uint32_t Ordinal; + if (I->getOrdinal(Ordinal)) + return; + uint32_t RVA; + if (I->getExportRVA(RVA)) + return; + outs() << format(" % 4d %# 8x", Ordinal, RVA); + + StringRef Name; + if (I->getName(Name)) + continue; + if (!Name.empty()) + outs() << " " << Name; + outs() << "\n"; + } +} + void llvm::printCOFFUnwindInfo(const COFFObjectFile *Obj) { const coff_file_header *Header; if (error(Obj->getCOFFHeader(Header))) return; @@ -399,5 +429,7 @@ void llvm::printCOFFUnwindInfo(const COFFObjectFile *Obj) { } void llvm::printCOFFFileHeader(const object::ObjectFile *Obj) { - printImportTables(dyn_cast<const COFFObjectFile>(Obj)); + const COFFObjectFile *file = dyn_cast<const COFFObjectFile>(Obj); + printImportTables(file); + printExportTable(file); } |