diff options
author | Jim Grosbach <grosbach@apple.com> | 2012-01-21 00:21:53 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2012-01-21 00:21:53 +0000 |
commit | 93391348dc00b4078463515149eeb214796f553d (patch) | |
tree | ec968ae8bd8c5a327e8451dbe838c2a44b3ba1b3 /lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp | |
parent | 12a8863828879168ffd634df09f3aa91b0b256ee (diff) | |
download | llvm-93391348dc00b4078463515149eeb214796f553d.tar.gz llvm-93391348dc00b4078463515149eeb214796f553d.tar.bz2 llvm-93391348dc00b4078463515149eeb214796f553d.tar.xz |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148604 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp')
-rw-r--r-- | lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp index 1926af8885..fb005bba45 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp @@ -272,16 +272,18 @@ loadSegment64(const MachOObject *Obj, // 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. |