[COFF] Consider the ImageBase when reporting section addresses

This lets us reenable the lld test disabled in r243758.

llvm-svn: 243761
This commit is contained in:
David Majnemer 2015-07-31 17:40:24 +00:00
parent cd6a4665e0
commit 7c6a071b58
1 changed files with 10 additions and 2 deletions

View File

@ -177,7 +177,7 @@ ErrorOr<uint64_t> COFFObjectFile::getSymbolAddress(DataRefImpl Ref) const {
if (PE32Header)
Result += PE32Header->ImageBase;
else if (PE32PlusHeader)
Result += PE32Header->ImageBase;
Result += PE32PlusHeader->ImageBase;
return Result;
}
@ -274,7 +274,15 @@ std::error_code COFFObjectFile::getSectionName(DataRefImpl Ref,
uint64_t COFFObjectFile::getSectionAddress(DataRefImpl Ref) const {
const coff_section *Sec = toSec(Ref);
return Sec->VirtualAddress;
uint64_t Result = Sec->VirtualAddress;
// The section VirtualAddress does not include ImageBase, and we want to
// return virtual addresses.
if (PE32Header)
Result += PE32Header->ImageBase;
else if (PE32PlusHeader)
Result += PE32PlusHeader->ImageBase;
return Result;
}
uint64_t COFFObjectFile::getSectionSize(DataRefImpl Ref) const {