diff options
author | Reid Kleckner <reid@kleckner.net> | 2015-07-31 16:14:22 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2015-07-31 16:14:22 +0000 |
commit | 47ea9ece1a17735d4f57f3dd84d86b9102b752cf (patch) | |
tree | 3fbd60e0282ba9d8df6aa000a6dedb7e93ee1c60 /llvm/lib/Object | |
parent | bb42b030219710676ecb224bd3748641ff828c86 (diff) | |
download | bcm5719-llvm-47ea9ece1a17735d4f57f3dd84d86b9102b752cf.tar.gz bcm5719-llvm-47ea9ece1a17735d4f57f3dd84d86b9102b752cf.zip |
[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
Diffstat (limited to 'llvm/lib/Object')
-rw-r--r-- | llvm/lib/Object/COFFObjectFile.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index 1ae8059a021..ed63f3a64e0 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -171,6 +171,14 @@ ErrorOr<uint64_t> 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; } |