[llvm-commits] [llvm] r148604 - /llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp

Jim Grosbach grosbach at apple.com
Fri Jan 20 16:21:53 PST 2012


Author: grosbach
Date: Fri Jan 20 18:21:53 2012
New Revision: 148604

URL: http://llvm.org/viewvc/llvm-project?rev=148604&view=rev
Log:
RuntimeDyld alignment adjustment from MachO file.

The MachO file stores section alignment as log2(alignment-in-bytes). The
allocation routines want the raw alignment-in-bytes value, so adjust
for that.

Modified:
    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp

Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp?rev=148604&r1=148603&r2=148604&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp Fri Jan 20 18:21:53 2012
@@ -272,16 +272,18 @@
     // Allocate memory via the MM for the section.
     uint8_t *Buffer;
     uint32_t SectionID = Sections.size();
+    unsigned Align = 1 << Sect->Align; // .o file has log2 alignment.
     if (Sect->Flags == 0x80000400)
-      Buffer = MemMgr->allocateCodeSection(Sect->Size, Sect->Align, SectionID);
+      Buffer = MemMgr->allocateCodeSection(Sect->Size, Align, SectionID);
     else
-      Buffer = MemMgr->allocateDataSection(Sect->Size, Sect->Align, SectionID);
+      Buffer = MemMgr->allocateDataSection(Sect->Size, Align, SectionID);
 
     DEBUG(dbgs() << "Loading "
                  << ((Sect->Flags == 0x80000400) ? "text" : "data")
                  << " (ID #" << SectionID << ")"
                  << " '" << Sect->SegmentName << ","
                  << Sect->Name << "' of size " << Sect->Size
+                 << " (align " << Align << ")"
                  << " to address " << Buffer << ".\n");
 
     // Copy the payload from the object file into the allocated buffer.





More information about the llvm-commits mailing list