diff options
Diffstat (limited to 'llvm/lib/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.cpp')
-rw-r--r-- | llvm/lib/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.cpp | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/llvm/lib/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.cpp b/llvm/lib/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.cpp index cdac367e11a3..ec82081937e2 100644 --- a/llvm/lib/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.cpp +++ b/llvm/lib/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.cpp @@ -94,8 +94,8 @@ uint8_t *EPCGenericRTDyldMemoryManager::allocateDataSection( } void EPCGenericRTDyldMemoryManager::reserveAllocationSpace( - uintptr_t CodeSize, uint32_t CodeAlign, uintptr_t RODataSize, - uint32_t RODataAlign, uintptr_t RWDataSize, uint32_t RWDataAlign) { + uintptr_t CodeSize, Align CodeAlign, uintptr_t RODataSize, + Align RODataAlign, uintptr_t RWDataSize, Align RWDataAlign) { { std::lock_guard<std::mutex> Lock(M); @@ -103,15 +103,15 @@ void EPCGenericRTDyldMemoryManager::reserveAllocationSpace( if (!ErrMsg.empty()) return; - if (!isPowerOf2_32(CodeAlign) || CodeAlign > EPC.getPageSize()) { + if (CodeAlign > EPC.getPageSize()) { ErrMsg = "Invalid code alignment in reserveAllocationSpace"; return; } - if (!isPowerOf2_32(RODataAlign) || RODataAlign > EPC.getPageSize()) { + if (RODataAlign > EPC.getPageSize()) { ErrMsg = "Invalid ro-data alignment in reserveAllocationSpace"; return; } - if (!isPowerOf2_32(RWDataAlign) || RWDataAlign > EPC.getPageSize()) { + if (RWDataAlign > EPC.getPageSize()) { ErrMsg = "Invalid rw-data alignment in reserveAllocationSpace"; return; } @@ -142,7 +142,7 @@ void EPCGenericRTDyldMemoryManager::reserveAllocationSpace( } std::lock_guard<std::mutex> Lock(M); - Unmapped.push_back(AllocGroup()); + Unmapped.push_back(SectionAllocGroup()); Unmapped.back().RemoteCode = { *TargetAllocAddr, ExecutorAddrDiff(alignTo(CodeSize, EPC.getPageSize()))}; Unmapped.back().RemoteROData = { @@ -170,10 +170,11 @@ void EPCGenericRTDyldMemoryManager::registerEHFrames(uint8_t *Addr, return; ExecutorAddr LA(LoadAddr); - for (auto &Alloc : llvm::reverse(Unfinalized)) { - if (Alloc.RemoteCode.contains(LA) || Alloc.RemoteROData.contains(LA) || - Alloc.RemoteRWData.contains(LA)) { - Alloc.UnfinalizedEHFrames.push_back({LA, Size}); + for (auto &SecAllocGroup : llvm::reverse(Unfinalized)) { + if (SecAllocGroup.RemoteCode.contains(LA) || + SecAllocGroup.RemoteROData.contains(LA) || + SecAllocGroup.RemoteRWData.contains(LA)) { + SecAllocGroup.UnfinalizedEHFrames.push_back({LA, Size}); return; } } @@ -204,35 +205,29 @@ bool EPCGenericRTDyldMemoryManager::finalizeMemory(std::string *ErrMsg) { LLVM_DEBUG(dbgs() << "Allocator " << (void *)this << " finalizing:\n"); // If there's an error then bail out here. - std::vector<AllocGroup> Allocs; + std::vector<SectionAllocGroup> SecAllocGroups; { std::lock_guard<std::mutex> Lock(M); if (ErrMsg && !this->ErrMsg.empty()) { *ErrMsg = std::move(this->ErrMsg); return true; } - std::swap(Allocs, Unfinalized); + std::swap(SecAllocGroups, Unfinalized); } // Loop over unfinalized objects to make finalization requests. - for (auto &ObjAllocs : Allocs) { + for (auto &SecAllocGroup : SecAllocGroups) { - tpctypes::WireProtectionFlags SegProts[3] = { - tpctypes::toWireProtectionFlags( - static_cast<sys::Memory::ProtectionFlags>(sys::Memory::MF_READ | - sys::Memory::MF_EXEC)), - tpctypes::toWireProtectionFlags(sys::Memory::MF_READ), - tpctypes::toWireProtectionFlags( - static_cast<sys::Memory::ProtectionFlags>(sys::Memory::MF_READ | - sys::Memory::MF_WRITE))}; + MemProt SegMemProts[3] = {MemProt::Read | MemProt::Exec, MemProt::Read, + MemProt::Read | MemProt::Write}; - ExecutorAddrRange *RemoteAddrs[3] = {&ObjAllocs.RemoteCode, - &ObjAllocs.RemoteROData, - &ObjAllocs.RemoteRWData}; + ExecutorAddrRange *RemoteAddrs[3] = {&SecAllocGroup.RemoteCode, + &SecAllocGroup.RemoteROData, + &SecAllocGroup.RemoteRWData}; - std::vector<Alloc> *SegSections[3] = {&ObjAllocs.CodeAllocs, - &ObjAllocs.RODataAllocs, - &ObjAllocs.RWDataAllocs}; + std::vector<SectionAlloc> *SegSections[3] = {&SecAllocGroup.CodeAllocs, + &SecAllocGroup.RODataAllocs, + &SecAllocGroup.RWDataAllocs}; tpctypes::FinalizeRequest FR; std::unique_ptr<char[]> AggregateContents[3]; @@ -240,7 +235,7 @@ bool EPCGenericRTDyldMemoryManager::finalizeMemory(std::string *ErrMsg) { for (unsigned I = 0; I != 3; ++I) { FR.Segments.push_back({}); auto &Seg = FR.Segments.back(); - Seg.Prot = SegProts[I]; + Seg.AG = SegMemProts[I]; Seg.Addr = RemoteAddrs[I]->Start; for (auto &SecAlloc : *SegSections[I]) { Seg.Size = alignTo(Seg.Size, SecAlloc.Align); @@ -261,7 +256,7 @@ bool EPCGenericRTDyldMemoryManager::finalizeMemory(std::string *ErrMsg) { Seg.Content = {AggregateContents[I].get(), SecOffset}; } - for (auto &Frame : ObjAllocs.UnfinalizedEHFrames) + for (auto &Frame : SecAllocGroup.UnfinalizedEHFrames) FR.Actions.push_back( {cantFail( WrapperFunctionCall::Create<SPSArgList<SPSExecutorAddrRange>>( @@ -297,7 +292,8 @@ bool EPCGenericRTDyldMemoryManager::finalizeMemory(std::string *ErrMsg) { } void EPCGenericRTDyldMemoryManager::mapAllocsToRemoteAddrs( - RuntimeDyld &Dyld, std::vector<Alloc> &Allocs, ExecutorAddr NextAddr) { + RuntimeDyld &Dyld, std::vector<SectionAlloc> &Allocs, + ExecutorAddr NextAddr) { for (auto &Alloc : Allocs) { NextAddr.setValue(alignTo(NextAddr.getValue(), Alloc.Align)); LLVM_DEBUG({ |