From 47ea9ece1a17735d4f57f3dd84d86b9102b752cf Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Fri, 31 Jul 2015 16:14:22 +0000 Subject: [COFF] Return symbol VAs instead of RVAs for PE files This makes llvm-nm consistent with binutils nm on executables and DLLs. For a vanilla hello world executable, the address of main should include the default image base of 0x400000. llvm-svn: 243755 --- llvm/lib/Object/COFFObjectFile.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'llvm/lib/Object/COFFObjectFile.cpp') diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index 1ae8059..ed63f3a 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -171,6 +171,14 @@ ErrorOr COFFObjectFile::getSymbolAddress(DataRefImpl Ref) const { if (std::error_code EC = getSection(SectionNumber, Section)) return EC; Result += Section->VirtualAddress; + + // The section VirtualAddress does not include ImageBase, and we want to + // return virtual addresses. + if (PE32Header) + Result += PE32Header->ImageBase; + else if (PE32PlusHeader) + Result += PE32Header->ImageBase; + return Result; } -- cgit v1.1