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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201760 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rui Ueyama
2014-02-20 06:51:07 +00:00
parent ccb98645b6
commit 6fac32b176
4 changed files with 33 additions and 3 deletions

View File

@ -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;
}