diff options
author | Rui Ueyama <ruiu@google.com> | 2013-07-18 22:44:20 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2013-07-18 22:44:20 +0000 |
commit | 06bd2061fc40bfa3560bc200c396595cc4ed3a2e (patch) | |
tree | adef2adcdab62610167d4c0b6558b3c48ae7be5c /tools/llvm-readobj | |
parent | b05ad799e7dc19d7c88576820b1cf16b43a4de9e (diff) | |
download | external_llvm-06bd2061fc40bfa3560bc200c396595cc4ed3a2e.zip external_llvm-06bd2061fc40bfa3560bc200c396595cc4ed3a2e.tar.gz external_llvm-06bd2061fc40bfa3560bc200c396595cc4ed3a2e.tar.bz2 |
COFFDumper: Dump data directory entries.
Summary:
Dump optional data directory entries in the PE/COFF header, so that
we can test the output of LLD linker. This patch updates the test binary
file, but the source of the binary is the same. I just re-linked the file.
I don't know how the previous file was linked, but the previous file did
not have any data directory entries for some reason.
Reviewers: rafael
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1148
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186623 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-readobj')
-rw-r--r-- | tools/llvm-readobj/COFFDumper.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/llvm-readobj/COFFDumper.cpp b/tools/llvm-readobj/COFFDumper.cpp index 1ceb8fc..2f309e3 100644 --- a/tools/llvm-readobj/COFFDumper.cpp +++ b/tools/llvm-readobj/COFFDumper.cpp @@ -60,6 +60,8 @@ private: void printRelocation(section_iterator SecI, relocation_iterator RelI); + void printDataDirectory(uint32_t Index, const std::string &FieldName); + void printX64UnwindInfo(); void printRuntimeFunction( @@ -560,6 +562,14 @@ void COFFDumper::cacheRelocations() { } } +void COFFDumper::printDataDirectory(uint32_t Index, const std::string &FieldName) { + const data_directory *Data; + if (Obj->getDataDirectory(Index, Data)) + return; + W.printHex(FieldName + "RVA", Data->RelativeVirtualAddress); + W.printHex(FieldName + "Size", Data->Size); +} + void COFFDumper::printFileHeaders() { // Print COFF header const coff_file_header *COFFHeader = 0; @@ -621,6 +631,20 @@ void COFFDumper::printFileHeaders() { W.printNumber("SizeOfHeapReserve", PEHeader->SizeOfHeapReserve); W.printNumber("SizeOfHeapCommit", PEHeader->SizeOfHeapCommit); W.printNumber("NumberOfRvaAndSize", PEHeader->NumberOfRvaAndSize); + + if (PEHeader->NumberOfRvaAndSize > 0) { + DictScope D(W, "DataDirectory"); + static const char * const directory[] = { + "ExportTable", "ImportTable", "ResourceTable", "ExceptionTable", + "CertificateTable", "BaseRelocationTable", "Debug", "Architecture", + "GlobalPtr", "TLSTable", "LoadConfigTable", "BoundImport", "IAT", + "DelayImportDescriptor", "CLRRuntimeHeader", "Reserved" + }; + + for (uint32_t i = 0; i < PEHeader->NumberOfRvaAndSize; ++i) { + printDataDirectory(i, directory[i]); + } + } } } |