diff options
Diffstat (limited to 'llvm/lib/ExecutionEngine')
-rw-r--r-- | llvm/lib/ExecutionEngine/ExecutionEngine.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/ExecutionEngine/MCJIT/MCJIT.h | 4 | ||||
-rw-r--r-- | llvm/lib/ExecutionEngine/RuntimeDyld/ObjectImageCommon.h | 2 | ||||
-rw-r--r-- | llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp | 39 |
5 files changed, 27 insertions, 29 deletions
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp index 4ef6e73c131..f112e08b42b 100644 --- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp @@ -124,7 +124,7 @@ void ExecutionEngine::addObjectFile(std::unique_ptr<object::ObjectFile> O) { llvm_unreachable("ExecutionEngine subclass doesn't implement addObjectFile."); } -void ExecutionEngine::addArchive(std::unique_ptr<object::Archive> A) { +void ExecutionEngine::addArchive(object::OwningBinary<object::Archive> A) { llvm_unreachable("ExecutionEngine subclass doesn't implement addArchive."); } diff --git a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp index 65e2aba29ee..9583fb2add6 100644 --- a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp +++ b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp @@ -119,7 +119,7 @@ void MCJIT::addObjectFile(std::unique_ptr<object::ObjectFile> Obj) { NotifyObjectEmitted(*LoadedObject); } -void MCJIT::addArchive(std::unique_ptr<object::Archive> A) { +void MCJIT::addArchive(object::OwningBinary<object::Archive> A) { Archives.push_back(std::move(A)); } @@ -161,8 +161,8 @@ ObjectBufferStream* MCJIT::emitObject(Module *M) { if (ObjCache) { // MemoryBuffer is a thin wrapper around the actual memory, so it's OK // to create a temporary object here and delete it after the call. - std::unique_ptr<MemoryBuffer> MB = CompiledObject->getMemBuffer(); - ObjCache->notifyObjectCompiled(M, MB.get()); + MemoryBufferRef MB = CompiledObject->getMemBuffer(); + ObjCache->notifyObjectCompiled(M, MB); } return CompiledObject.release(); @@ -295,7 +295,8 @@ uint64_t MCJIT::getSymbolAddress(const std::string &Name, if (Addr) return Addr; - for (std::unique_ptr<object::Archive> &A : Archives) { + for (object::OwningBinary<object::Archive> &OB : Archives) { + object::Archive *A = OB.getBinary().get(); // Look for our symbols in each Archive object::Archive::child_iterator ChildIt = A->findSym(Name); if (ChildIt != A->child_end()) { diff --git a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.h b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.h index 6a814db5ef2..4bf6d2939e7 100644 --- a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.h +++ b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.h @@ -216,7 +216,7 @@ class MCJIT : public ExecutionEngine { OwningModuleContainer OwnedModules; - SmallVector<std::unique_ptr<object::Archive>, 2> Archives; + SmallVector<object::OwningBinary<object::Archive>, 2> Archives; typedef SmallVector<ObjectImage *, 2> LoadedObjectList; LoadedObjectList LoadedObjects; @@ -240,7 +240,7 @@ public: /// @{ void addModule(std::unique_ptr<Module> M) override; void addObjectFile(std::unique_ptr<object::ObjectFile> O) override; - void addArchive(std::unique_ptr<object::Archive> O) override; + void addArchive(object::OwningBinary<object::Archive> O) override; bool removeModule(Module *M) override; /// FindFunctionNamed - Search all of the active modules to find the one that diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/ObjectImageCommon.h b/llvm/lib/ExecutionEngine/RuntimeDyld/ObjectImageCommon.h index 3d65eaaacd7..ddf0e89b408 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/ObjectImageCommon.h +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/ObjectImageCommon.h @@ -48,7 +48,7 @@ public: { // FIXME: error checking? createObjectFile returns an ErrorOr<ObjectFile*> // and should probably be checked for failure. - std::unique_ptr<MemoryBuffer> Buf = Buffer->getMemBuffer(); + MemoryBufferRef Buf = Buffer->getMemBuffer(); ObjFile = std::move(object::ObjectFile::createObjectFile(Buf).get()); } ObjectImageCommon(std::unique_ptr<object::ObjectFile> Input) diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp index abf29a7a960..b3c94b38628 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -55,9 +55,9 @@ template <class ELFT> class DyldELFObject : public ELFObjectFile<ELFT> { public: DyldELFObject(std::unique_ptr<ObjectFile> UnderlyingFile, - std::unique_ptr<MemoryBuffer> Wrapper, std::error_code &ec); + MemoryBufferRef Wrapper, std::error_code &ec); - DyldELFObject(std::unique_ptr<MemoryBuffer> Wrapper, std::error_code &ec); + DyldELFObject(MemoryBufferRef Wrapper, std::error_code &ec); void updateSectionAddress(const SectionRef &Sec, uint64_t Addr); void updateSymbolAddress(const SymbolRef &Sym, uint64_t Addr); @@ -109,17 +109,15 @@ public: // actual memory. Ultimately, the Binary parent class will take ownership of // this MemoryBuffer object but not the underlying memory. template <class ELFT> -DyldELFObject<ELFT>::DyldELFObject(std::unique_ptr<MemoryBuffer> Wrapper, - std::error_code &EC) - : ELFObjectFile<ELFT>(std::move(Wrapper), EC) { +DyldELFObject<ELFT>::DyldELFObject(MemoryBufferRef Wrapper, std::error_code &EC) + : ELFObjectFile<ELFT>(Wrapper, EC) { this->isDyldELFObject = true; } template <class ELFT> DyldELFObject<ELFT>::DyldELFObject(std::unique_ptr<ObjectFile> UnderlyingFile, - std::unique_ptr<MemoryBuffer> Wrapper, - std::error_code &EC) - : ELFObjectFile<ELFT>(std::move(Wrapper), EC), + MemoryBufferRef Wrapper, std::error_code &EC) + : ELFObjectFile<ELFT>(Wrapper, EC), UnderlyingFile(std::move(UnderlyingFile)) { this->isDyldELFObject = true; } @@ -185,29 +183,28 @@ RuntimeDyldELF::createObjectImageFromFile(std::unique_ptr<object::ObjectFile> Ob return nullptr; std::error_code ec; - std::unique_ptr<MemoryBuffer> Buffer( - MemoryBuffer::getMemBuffer(ObjFile->getData(), "", false)); + MemoryBufferRef Buffer = ObjFile->getMemoryBufferRef(); if (ObjFile->getBytesInAddress() == 4 && ObjFile->isLittleEndian()) { auto Obj = llvm::make_unique<DyldELFObject<ELFType<support::little, 2, false>>>( - std::move(ObjFile), std::move(Buffer), ec); + std::move(ObjFile), Buffer, ec); return new ELFObjectImage<ELFType<support::little, 2, false>>( nullptr, std::move(Obj)); } else if (ObjFile->getBytesInAddress() == 4 && !ObjFile->isLittleEndian()) { auto Obj = llvm::make_unique<DyldELFObject<ELFType<support::big, 2, false>>>( - std::move(ObjFile), std::move(Buffer), ec); + std::move(ObjFile), Buffer, ec); return new ELFObjectImage<ELFType<support::big, 2, false>>(nullptr, std::move(Obj)); } else if (ObjFile->getBytesInAddress() == 8 && !ObjFile->isLittleEndian()) { auto Obj = llvm::make_unique<DyldELFObject<ELFType<support::big, 2, true>>>( - std::move(ObjFile), std::move(Buffer), ec); + std::move(ObjFile), Buffer, ec); return new ELFObjectImage<ELFType<support::big, 2, true>>(nullptr, std::move(Obj)); } else if (ObjFile->getBytesInAddress() == 8 && ObjFile->isLittleEndian()) { auto Obj = llvm::make_unique<DyldELFObject<ELFType<support::little, 2, true>>>( - std::move(ObjFile), std::move(Buffer), ec); + std::move(ObjFile), Buffer, ec); return new ELFObjectImage<ELFType<support::little, 2, true>>( nullptr, std::move(Obj)); } else @@ -222,31 +219,31 @@ ObjectImage *RuntimeDyldELF::createObjectImage(ObjectBuffer *Buffer) { (uint8_t)Buffer->getBufferStart()[ELF::EI_DATA]); std::error_code ec; - std::unique_ptr<MemoryBuffer> Buf = Buffer->getMemBuffer(); + MemoryBufferRef Buf = Buffer->getMemBuffer(); if (Ident.first == ELF::ELFCLASS32 && Ident.second == ELF::ELFDATA2LSB) { auto Obj = llvm::make_unique<DyldELFObject<ELFType<support::little, 4, false>>>( - std::move(Buf), ec); + Buf, ec); return new ELFObjectImage<ELFType<support::little, 4, false>>( Buffer, std::move(Obj)); } else if (Ident.first == ELF::ELFCLASS32 && Ident.second == ELF::ELFDATA2MSB) { auto Obj = - llvm::make_unique<DyldELFObject<ELFType<support::big, 4, false>>>( - std::move(Buf), ec); + llvm::make_unique<DyldELFObject<ELFType<support::big, 4, false>>>(Buf, + ec); return new ELFObjectImage<ELFType<support::big, 4, false>>(Buffer, std::move(Obj)); } else if (Ident.first == ELF::ELFCLASS64 && Ident.second == ELF::ELFDATA2MSB) { auto Obj = llvm::make_unique<DyldELFObject<ELFType<support::big, 8, true>>>( - std::move(Buf), ec); + Buf, ec); return new ELFObjectImage<ELFType<support::big, 8, true>>(Buffer, std::move(Obj)); } else if (Ident.first == ELF::ELFCLASS64 && Ident.second == ELF::ELFDATA2LSB) { auto Obj = - llvm::make_unique<DyldELFObject<ELFType<support::little, 8, true>>>( - std::move(Buf), ec); + llvm::make_unique<DyldELFObject<ELFType<support::little, 8, true>>>(Buf, + ec); return new ELFObjectImage<ELFType<support::little, 8, true>>(Buffer, std::move(Obj)); } else llvm_unreachable("Unexpected ELF format"); |