diff options
author | Rui Ueyama <ruiu@google.com> | 2014-02-19 03:53:11 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2014-02-19 03:53:11 +0000 |
commit | c514a8041fa9e3f73963efe20369d76f5f490ec4 (patch) | |
tree | 5c6fb51b53bb8c653f7f8ee549cd388583b29a87 /llvm/tools/llvm-objdump | |
parent | 9c37cbdb86f82d3110786c9d08634de217f85f2d (diff) | |
download | bcm5719-llvm-c514a8041fa9e3f73963efe20369d76f5f490ec4.tar.gz bcm5719-llvm-c514a8041fa9e3f73963efe20369d76f5f490ec4.zip |
llvm-objdump/COFF: Print load configuration table.
Load Configuration Table may contain a pointer to SEH table. This patch is to
print the offset to the table. Printing SEH table contents is a TODO.
The layout of Layout Configuration Table is described in Microsoft PE/COFF
Object File Format Spec, but the table's offset/size descriptions seems to be
totally wrong, at least in revision 8.3 of the spec. I believe the table in
this patch is the correct one.
llvm-svn: 201638
Diffstat (limited to 'llvm/tools/llvm-objdump')
-rw-r--r-- | llvm/tools/llvm-objdump/COFFDump.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/llvm/tools/llvm-objdump/COFFDump.cpp b/llvm/tools/llvm-objdump/COFFDump.cpp index f6f0f15197b..883786d4f66 100644 --- a/llvm/tools/llvm-objdump/COFFDump.cpp +++ b/llvm/tools/llvm-objdump/COFFDump.cpp @@ -233,6 +233,46 @@ static void printCOFFSymbolAddress(llvm::raw_ostream &Out, Out << format(" + 0x%04x", Disp); } +static void printLoadConfiguration(const COFFObjectFile *Obj) { + const coff_file_header *Header; + if (error(Obj->getCOFFHeader(Header))) + return; + // Currently only x86 is supported + if (Header->Machine != COFF::IMAGE_FILE_MACHINE_I386) + return; + + const data_directory *DataDir; + if (error(Obj->getDataDirectory(COFF::LOAD_CONFIG_TABLE, DataDir))) + return; + uintptr_t IntPtr = 0; + if (DataDir->RelativeVirtualAddress == 0) + return; + if (error(Obj->getRvaPtr(DataDir->RelativeVirtualAddress, IntPtr))) + return; + const coff_load_configuration32 *LoadConf = + reinterpret_cast<const coff_load_configuration32 *>(IntPtr); + + outs() << "Load configuration:" + << "\n Timestamp: " << LoadConf->TimeDateStamp + << "\n Major Version: " << LoadConf->MajorVersion + << "\n Minor Version: " << LoadConf->MinorVersion + << "\n GlobalFlags Clear: " << LoadConf->GlobalFlagsClear + << "\n GlobalFlags Set: " << LoadConf->GlobalFlagsSet + << "\n Critical Section Default Timeout: " << LoadConf->CriticalSectionDefaultTimeout + << "\n Decommit Free Block Threshold: " << LoadConf->DeCommitFreeBlockThreshold + << "\n Decommit Total Free Threshold: " << LoadConf->DeCommitTotalFreeThreshold + << "\n Lock Prefix Table: " << LoadConf->LockPrefixTable + << "\n Maximum Allocation Size: " << LoadConf->MaximumAllocationSize + << "\n Virtual Memory Threshold: " << LoadConf->VirtualMemoryThreshold + << "\n Process Affinity Mask: " << LoadConf->ProcessAffinityMask + << "\n Process Heap Flags: " << LoadConf->ProcessHeapFlags + << "\n CSD Version: " << LoadConf->CSDVersion + << "\n Security Cookie: " << LoadConf->SecurityCookie + << "\n SEH Table: " << LoadConf->SEHandlerTable + << "\n SEH Count: " << LoadConf->SEHandlerCount + << "\n\n"; +} + // Prints import tables. The import table is a table containing the list of // DLL name and symbol names which will be linked by the loader. static void printImportTables(const COFFObjectFile *Obj) { @@ -431,6 +471,7 @@ void llvm::printCOFFUnwindInfo(const COFFObjectFile *Obj) { void llvm::printCOFFFileHeader(const object::ObjectFile *Obj) { const COFFObjectFile *file = dyn_cast<const COFFObjectFile>(Obj); + printLoadConfiguration(file); printImportTables(file); printExportTable(file); } |