From: David Majnemer Date: Fri, 31 Jul 2015 17:40:24 +0000 (+0000) Subject: [COFF] Consider the ImageBase when reporting section addresses X-Git-Tag: studio-1.4~1109 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c6a071b58c008ad383ddbc0768ccd82206f6826;p=platform%2Fupstream%2Fllvm.git [COFF] Consider the ImageBase when reporting section addresses This lets us reenable the lld test disabled in r243758. llvm-svn: 243761 --- diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index ed63f3a..d110b92 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -177,7 +177,7 @@ ErrorOr 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 {