summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/COFFObjectFile.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2017-06-22 01:10:29 +0000
committerReid Kleckner <rnk@google.com>2017-06-22 01:10:29 +0000
commitb7d716c06f15138dac800eaf0b76523d2acdc39c (patch)
tree0c64820e39f3cf5bc8c44b1fd0a1db04bf11fc5f /llvm/lib/Object/COFFObjectFile.cpp
parentef5817579ba51ee2f4c701d1d7bd6199fbb254d7 (diff)
downloadbcm5719-llvm-b7d716c06f15138dac800eaf0b76523d2acdc39c.tar.gz
bcm5719-llvm-b7d716c06f15138dac800eaf0b76523d2acdc39c.zip
[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
Diffstat (limited to 'llvm/lib/Object/COFFObjectFile.cpp')
-rw-r--r--llvm/lib/Object/COFFObjectFile.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp
index 579c8dde366..9a760d86e7e 100644
--- a/llvm/lib/Object/COFFObjectFile.cpp
+++ b/llvm/lib/Object/COFFObjectFile.cpp
@@ -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();
}
OpenPOWER on IntegriCloud