summaryrefslogtreecommitdiff
path: root/include/llvm/Object/COFF.h
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2014-01-16 07:05:49 +0000
committerRui Ueyama <ruiu@google.com>2014-01-16 07:05:49 +0000
commitfb432acff8c160749ac99576ec8da2a3f1987bc4 (patch)
treea3a92d288771698ee6d3a8ec96cea0f88683a72d /include/llvm/Object/COFF.h
parent9dcfdf61a843665ef2ab07ad5d8c0b213ef4b059 (diff)
downloadllvm-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 'include/llvm/Object/COFF.h')
-rw-r--r--include/llvm/Object/COFF.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/llvm/Object/COFF.h b/include/llvm/Object/COFF.h
index 431029045f..f9d0c6e525 100644
--- a/include/llvm/Object/COFF.h
+++ b/include/llvm/Object/COFF.h
@@ -24,7 +24,9 @@ namespace llvm {
namespace object {
class ImportDirectoryEntryRef;
+class ExportDirectoryEntryRef;
typedef content_iterator<ImportDirectoryEntryRef> import_directory_iterator;
+typedef content_iterator<ExportDirectoryEntryRef> export_directory_iterator;
/// The DOS compatible header at the front of all PE/COFF executables.
struct dos_header {
@@ -245,6 +247,7 @@ struct coff_aux_section_definition {
class COFFObjectFile : public ObjectFile {
private:
friend class ImportDirectoryEntryRef;
+ friend class ExportDirectoryEntryRef;
const coff_file_header *COFFHeader;
const pe32_header *PE32Header;
const data_directory *DataDirectory;
@@ -254,6 +257,7 @@ private:
uint32_t StringTableSize;
const import_directory_table_entry *ImportDirectory;
uint32_t NumberOfImportDirectory;
+ const export_directory_table_entry *ExportDirectory;
error_code getString(uint32_t offset, StringRef &Res) const;
@@ -263,6 +267,7 @@ private:
error_code initSymbolTablePtr();
error_code initImportTablePtr();
+ error_code initExportTablePtr();
protected:
virtual error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const;
@@ -336,6 +341,8 @@ public:
import_directory_iterator import_directory_begin() const;
import_directory_iterator import_directory_end() const;
+ export_directory_iterator export_directory_begin() const;
+ export_directory_iterator export_directory_end() const;
error_code getHeader(const coff_file_header *&Res) const;
error_code getCOFFHeader(const coff_file_header *&Res) const;
@@ -388,6 +395,26 @@ private:
uint32_t Index;
const COFFObjectFile *OwningObject;
};
+
+// The iterator for the export directory table entry.
+class ExportDirectoryEntryRef {
+public:
+ ExportDirectoryEntryRef() : OwningObject(0) {}
+ ExportDirectoryEntryRef(const export_directory_table_entry *Table, uint32_t I,
+ const COFFObjectFile *Owner)
+ : ExportTable(Table), Index(I), OwningObject(Owner) {}
+
+ bool operator==(const ExportDirectoryEntryRef &Other) const;
+ error_code getNext(ExportDirectoryEntryRef &Result) const;
+ error_code getOrdinal(uint32_t &Result) const;
+ error_code getExportRVA(uint32_t &Result) const;
+ error_code getName(StringRef &Result) const;
+
+private:
+ const export_directory_table_entry *ExportTable;
+ uint32_t Index;
+ const COFFObjectFile *OwningObject;
+};
} // end namespace object
} // end namespace llvm