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 | b7e1ab795944263b663593085f7fee404f72475f (patch) | |
tree | 976a61779ab0ff43e9606c9d37db917397ee6825 /tools/llvm-objdump/COFFDump.cpp | |
parent | 3fd813ef423e23d7f57ed3784d423ca503cd3578 (diff) | |
download | llvm-b7e1ab795944263b663593085f7fee404f72475f.tar.gz llvm-b7e1ab795944263b663593085f7fee404f72475f.tar.bz2 llvm-b7e1ab795944263b663593085f7fee404f72475f.tar.xz |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201638 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-objdump/COFFDump.cpp')
-rw-r--r-- | tools/llvm-objdump/COFFDump.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tools/llvm-objdump/COFFDump.cpp b/tools/llvm-objdump/COFFDump.cpp index f6f0f15197..883786d4f6 100644 --- a/tools/llvm-objdump/COFFDump.cpp +++ b/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); } |