diff options
| author | Rui Ueyama <ruiu@google.com> | 2014-01-16 20:50:34 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2014-01-16 20:50:34 +0000 |
| commit | da49d0d44c6b7f19a1535c899926e3c4131c6567 (patch) | |
| tree | d44dbafa1801a997e39e8e64c8cdef9be4106960 /llvm | |
| parent | 1792ebc1ab12a0b24c05063721af489d2373ce8d (diff) | |
| download | bcm5719-llvm-da49d0d44c6b7f19a1535c899926e3c4131c6567.tar.gz bcm5719-llvm-da49d0d44c6b7f19a1535c899926e3c4131c6567.zip | |
llvm-objdump/COFF: Print DLL name in the export table header.
llvm-svn: 199422
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/Object/COFF.h | 4 | ||||
| -rw-r--r-- | llvm/lib/Object/COFFObjectFile.cpp | 12 | ||||
| -rw-r--r-- | llvm/test/tools/llvm-objdump/coff-private-headers.test | 1 | ||||
| -rw-r--r-- | llvm/tools/llvm-objdump/COFFDump.cpp | 6 |
4 files changed, 20 insertions, 3 deletions
diff --git a/llvm/include/llvm/Object/COFF.h b/llvm/include/llvm/Object/COFF.h index f9d0c6e525a..b8555370e05 100644 --- a/llvm/include/llvm/Object/COFF.h +++ b/llvm/include/llvm/Object/COFF.h @@ -406,9 +406,11 @@ public: bool operator==(const ExportDirectoryEntryRef &Other) const; error_code getNext(ExportDirectoryEntryRef &Result) const; + + error_code getDllName(StringRef &Result) const; error_code getOrdinal(uint32_t &Result) const; error_code getExportRVA(uint32_t &Result) const; - error_code getName(StringRef &Result) const; + error_code getSymbolName(StringRef &Result) const; private: const export_directory_table_entry *ExportTable; diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index 3663cd9c9a6..4709612167c 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -949,6 +949,16 @@ ExportDirectoryEntryRef::getNext(ExportDirectoryEntryRef &Result) const { return object_error::success; } +// Returns the name of the current export symbol. If the symbol is exported only +// by ordinal, the empty string is set as a result. +error_code ExportDirectoryEntryRef::getDllName(StringRef &Result) const { + uintptr_t IntPtr = 0; + if (error_code EC = OwningObject->getRvaPtr(ExportTable->NameRVA, IntPtr)) + return EC; + Result = StringRef(reinterpret_cast<const char *>(IntPtr)); + return object_error::success; +} + // Returns the export ordinal of the current export symbol. error_code ExportDirectoryEntryRef::getOrdinal(uint32_t &Result) const { Result = ExportTable->OrdinalBase + Index; @@ -968,7 +978,7 @@ error_code ExportDirectoryEntryRef::getExportRVA(uint32_t &Result) const { // Returns the name of the current export symbol. If the symbol is exported only // by ordinal, the empty string is set as a result. -error_code ExportDirectoryEntryRef::getName(StringRef &Result) const { +error_code ExportDirectoryEntryRef::getSymbolName(StringRef &Result) const { uintptr_t IntPtr = 0; if (error_code EC = OwningObject->getRvaPtr( ExportTable->OrdinalTableRVA, IntPtr)) diff --git a/llvm/test/tools/llvm-objdump/coff-private-headers.test b/llvm/test/tools/llvm-objdump/coff-private-headers.test index bc16443bbaf..7d1bde72a00 100644 --- a/llvm/test/tools/llvm-objdump/coff-private-headers.test +++ b/llvm/test/tools/llvm-objdump/coff-private-headers.test @@ -11,6 +11,7 @@ IMPORT-NEXT: 365 ExitProcess // RUN: FileCheck -check-prefix=EXPORT %s EXPORT: Export Table: +EXPORT-NEXT: DLL name: export.test.tmp3.dll EXPORT-NEXT: Ordinal RVA Name EXPORT-NEXT: 5 0x2008 EXPORT-NEXT: 6 0x2010 exportfn2 diff --git a/llvm/tools/llvm-objdump/COFFDump.cpp b/llvm/tools/llvm-objdump/COFFDump.cpp index df9c2cf2dac..10f34ecd589 100644 --- a/llvm/tools/llvm-objdump/COFFDump.cpp +++ b/llvm/tools/llvm-objdump/COFFDump.cpp @@ -279,6 +279,10 @@ static void printExportTable(const COFFObjectFile *Obj) { export_directory_iterator E = Obj->export_directory_end(); if (I == E) return; + StringRef DllName; + if (I->getDllName(DllName)) + return; + outs() << " DLL name: " << DllName << "\n"; outs() << " Ordinal RVA Name\n"; error_code EC; for (; I != E; I = I.increment(EC)) { @@ -293,7 +297,7 @@ static void printExportTable(const COFFObjectFile *Obj) { outs() << format(" % 4d %# 8x", Ordinal, RVA); StringRef Name; - if (I->getName(Name)) + if (I->getSymbolName(Name)) continue; if (!Name.empty()) outs() << " " << Name; |

