aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/MachOObjectFile.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2011-10-12 22:37:10 +0000
committerOwen Anderson <resistor@mac.com>2011-10-12 22:37:10 +0000
commit000721f0583052d84557bad52ab8301086bdd467 (patch)
tree9d842164a88995df5d6ea9536066456ecf4893d1 /llvm/lib/Object/MachOObjectFile.cpp
parent66443ce9bcd7992341dba25334710d79f4e6818f (diff)
downloadllvm-000721f0583052d84557bad52ab8301086bdd467.zip
llvm-000721f0583052d84557bad52ab8301086bdd467.tar.gz
llvm-000721f0583052d84557bad52ab8301086bdd467.tar.bz2
The VMAs stored in the symbol table of a MachO file are absolute addresses, not offsets from the section.
llvm-svn: 141828
Diffstat (limited to 'llvm/lib/Object/MachOObjectFile.cpp')
-rw-r--r--llvm/lib/Object/MachOObjectFile.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index 86d87ed..507df58 100644
--- a/llvm/lib/Object/MachOObjectFile.cpp
+++ b/llvm/lib/Object/MachOObjectFile.cpp
@@ -126,36 +126,36 @@ error_code MachOObjectFile::getSymbolName(DataRefImpl DRI,
error_code MachOObjectFile::getSymbolOffset(DataRefImpl DRI,
uint64_t &Result) const {
+ uint64_t SectionOffset;
+ uint8_t SectionIndex;
if (MachOObj->is64Bit()) {
InMemoryStruct<macho::Symbol64TableEntry> Entry;
getSymbol64TableEntry(DRI, Entry);
Result = Entry->Value;
+ SectionIndex = Entry->SectionIndex;
} else {
InMemoryStruct<macho::SymbolTableEntry> Entry;
getSymbolTableEntry(DRI, Entry);
Result = Entry->Value;
+ SectionIndex = Entry->SectionIndex;
}
+ getSectionAddress(Sections[SectionIndex-1], SectionOffset);
+ Result -= SectionOffset;
+
return object_error::success;
}
error_code MachOObjectFile::getSymbolAddress(DataRefImpl DRI,
uint64_t &Result) const {
- uint64_t SymbolOffset;
- uint8_t SectionIndex;
if (MachOObj->is64Bit()) {
InMemoryStruct<macho::Symbol64TableEntry> Entry;
getSymbol64TableEntry(DRI, Entry);
- SymbolOffset = Entry->Value;
- SectionIndex = Entry->SectionIndex;
+ Result = Entry->Value;
} else {
InMemoryStruct<macho::SymbolTableEntry> Entry;
getSymbolTableEntry(DRI, Entry);
- SymbolOffset = Entry->Value;
- SectionIndex = Entry->SectionIndex;
+ Result = Entry->Value;
}
- getSectionAddress(Sections[SectionIndex-1], Result);
- Result += SymbolOffset;
-
return object_error::success;
}