[llvm-commits] [llvm] r141828 - /llvm/trunk/lib/Object/MachOObjectFile.cpp

Owen Anderson resistor at mac.com
Wed Oct 12 15:37:10 PDT 2011


Author: resistor
Date: Wed Oct 12 17:37:10 2011
New Revision: 141828

URL: http://llvm.org/viewvc/llvm-project?rev=141828&view=rev
Log:
The VMAs stored in the symbol table of a MachO file are absolute addresses, not offsets from the section.

Modified:
    llvm/trunk/lib/Object/MachOObjectFile.cpp

Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=141828&r1=141827&r2=141828&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Wed Oct 12 17:37:10 2011
@@ -126,36 +126,36 @@
 
 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;
 }
 





More information about the llvm-commits mailing list