[llvm-readobj] Dump the COFF image load config

This includes the safe SEH tables and the control flow guard function
table. LLD will emit the guard table soon, and I need a tool that dumps
them for testing.

llvm-svn: 305979
This commit is contained in:
Reid Kleckner
2017-06-22 01:10:29 +00:00
parent ef5817579b
commit b7d716c06f
8 changed files with 337 additions and 11 deletions

View File

@@ -650,6 +650,23 @@ std::error_code COFFObjectFile::initDebugDirectoryPtr() {
return std::error_code();
}
std::error_code COFFObjectFile::initLoadConfigPtr() {
// Get the RVA of the debug directory. Do nothing if it does not exist.
const data_directory *DataEntry;
if (getDataDirectory(COFF::LOAD_CONFIG_TABLE, DataEntry))
return std::error_code();
// Do nothing if the RVA is NULL.
if (DataEntry->RelativeVirtualAddress == 0)
return std::error_code();
uintptr_t IntPtr = 0;
if (std::error_code EC = getRvaPtr(DataEntry->RelativeVirtualAddress, IntPtr))
return EC;
LoadConfig = (const void *)IntPtr;
return std::error_code();
}
COFFObjectFile::COFFObjectFile(MemoryBufferRef Object, std::error_code &EC)
: ObjectFile(Binary::ID_COFF, Object), COFFHeader(nullptr),
COFFBigObjHeader(nullptr), PE32Header(nullptr), PE32PlusHeader(nullptr),
@@ -784,6 +801,9 @@ COFFObjectFile::COFFObjectFile(MemoryBufferRef Object, std::error_code &EC)
if ((EC = initDebugDirectoryPtr()))
return;
if ((EC = initLoadConfigPtr()))
return;
EC = std::error_code();
}