aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/COFFObjectFile.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2014-02-20 06:51:07 +0000
committerRui Ueyama <ruiu@google.com>2014-02-20 06:51:07 +0000
commit215a586c4b9a3a17edd7ed9ef80afbeb15d9bc09 (patch)
tree5453d976c7290bfd5dcffc58600a9af8be0f0cb8 /llvm/lib/Object/COFFObjectFile.cpp
parenta864ce741e1214c01b62a18973fa47e10787d401 (diff)
downloadllvm-215a586c4b9a3a17edd7ed9ef80afbeb15d9bc09.zip
llvm-215a586c4b9a3a17edd7ed9ef80afbeb15d9bc09.tar.gz
llvm-215a586c4b9a3a17edd7ed9ef80afbeb15d9bc09.tar.bz2
llvm-objdump/COFF: Print SEH table addresses.
SEH table addresses are VA in COFF file. In this patch we convert VA to RVA before printing it, because dumpbin prints them as RVAs. llvm-svn: 201760
Diffstat (limited to 'llvm/lib/Object/COFFObjectFile.cpp')
-rw-r--r--llvm/lib/Object/COFFObjectFile.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp
index a1bbc56..85b2f0b 100644
--- a/llvm/lib/Object/COFFObjectFile.cpp
+++ b/llvm/lib/Object/COFFObjectFile.cpp
@@ -381,15 +381,21 @@ error_code COFFObjectFile::initSymbolTablePtr() {
return object_error::success;
}
+// Returns the file offset for the given VA.
+error_code COFFObjectFile::getVaPtr(uint32_t Addr, uintptr_t &Res) const {
+ uint32_t ImageBase = PE32Header ? PE32Header->ImageBase : PE32PlusHeader->ImageBase;
+ return getRvaPtr(Addr - ImageBase, Res);
+}
+
// Returns the file offset for the given RVA.
-error_code COFFObjectFile::getRvaPtr(uint32_t Rva, uintptr_t &Res) const {
+error_code COFFObjectFile::getRvaPtr(uint32_t Addr, uintptr_t &Res) const {
for (section_iterator I = section_begin(), E = section_end(); I != E;
++I) {
const coff_section *Section = getCOFFSection(I);
uint32_t SectionStart = Section->VirtualAddress;
uint32_t SectionEnd = Section->VirtualAddress + Section->VirtualSize;
- if (SectionStart <= Rva && Rva < SectionEnd) {
- uint32_t Offset = Rva - SectionStart;
+ if (SectionStart <= Addr && Addr < SectionEnd) {
+ uint32_t Offset = Addr - SectionStart;
Res = uintptr_t(base()) + Section->PointerToRawData + Offset;
return object_error::success;
}