From: Owen Anderson Date: Wed, 12 Oct 2011 22:37:10 +0000 (+0000) Subject: The VMAs stored in the symbol table of a MachO file are absolute addresses, not offse... X-Git-Tag: android-x86-6.0-r1~928^2~338 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=95f8db4d4d0110182d721586a006748b30e4fc82;p=android-x86%2Fexternal-llvm.git The VMAs stored in the symbol table of a MachO file are absolute addresses, not offsets from the section. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141828 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp index 86d87ed0f2f..507df5865eb 100644 --- a/lib/Object/MachOObjectFile.cpp +++ b/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 Entry; getSymbol64TableEntry(DRI, Entry); Result = Entry->Value; + SectionIndex = Entry->SectionIndex; } else { InMemoryStruct 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 Entry; getSymbol64TableEntry(DRI, Entry); - SymbolOffset = Entry->Value; - SectionIndex = Entry->SectionIndex; + Result = Entry->Value; } else { InMemoryStruct Entry; getSymbolTableEntry(DRI, Entry); - SymbolOffset = Entry->Value; - SectionIndex = Entry->SectionIndex; + Result = Entry->Value; } - getSectionAddress(Sections[SectionIndex-1], Result); - Result += SymbolOffset; - return object_error::success; }