LLVM 22.0.0git
|
A utility class to expose symbols from a static library. More...
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
Public Types | |
using | GetObjectFileInterface |
Interface builder function for objects loaded from this archive. | |
using | VisitMembersFunction |
Callback for visiting archive members at construction time. |
Public Member Functions | |
Error | tryToGenerate (LookupState &LS, LookupKind K, JITDylib &JD, JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &Symbols) override |
DefinitionGenerators should override this method to insert new definitions into the parent JITDylib. | |
Public Member Functions inherited from llvm::orc::DefinitionGenerator | |
virtual | ~DefinitionGenerator () |
Static Public Member Functions | |
static VisitMembersFunction | loadAllObjectFileMembers (ObjectLayer &L, JITDylib &JD) |
A VisitMembersFunction that unconditionally loads all object files from the archive. | |
static std::unique_ptr< MemoryBuffer > | createMemberBuffer (object::Archive &A, MemoryBufferRef BufRef, size_t Index) |
static Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > | Load (ObjectLayer &L, const char *FileName, VisitMembersFunction VisitMembers=VisitMembersFunction(), GetObjectFileInterface GetObjFileInterface=GetObjectFileInterface()) |
Try to create a StaticLibraryDefinitionGenerator from the given path. | |
static Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > | Create (ObjectLayer &L, std::unique_ptr< MemoryBuffer > ArchiveBuffer, std::unique_ptr< object::Archive > Archive, VisitMembersFunction VisitMembers=VisitMembersFunction(), GetObjectFileInterface GetObjFileInterface=GetObjectFileInterface()) |
Try to create a StaticLibrarySearchGenerator from the given memory buffer and Archive object. | |
static Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > | Create (ObjectLayer &L, std::unique_ptr< MemoryBuffer > ArchiveBuffer, VisitMembersFunction VisitMembers=VisitMembersFunction(), GetObjectFileInterface GetObjFileInterface=GetObjectFileInterface()) |
Try to create a StaticLibrarySearchGenerator from the given memory buffer. |
A utility class to expose symbols from a static library.
If an instance of this class is attached to a JITDylib as a fallback definition generator, then any symbol found in the archive will result in the containing object being added to the JITDylib.
Definition at line 270 of file ExecutionUtils.h.
Interface builder function for objects loaded from this archive.
Definition at line 273 of file ExecutionUtils.h.
Callback for visiting archive members at construction time.
Can be used to pre-load members.
Callbacks are provided with a reference to the underlying archive, a MemoryBufferRef covering the bytes for the given member, and the index of the given member.
Implementations should return true if the given member file should be loadable via the generator, false if it should not, and an Error if the member is malformed in a way that renders the archive itself invalid.
Note: Linkers typically ignore invalid files within archives, so it's expected that implementations will usually return false (i.e. not-loadable) for malformed buffers, and will only return an Error in exceptional circumstances.
Definition at line 292 of file ExecutionUtils.h.
|
static |
Try to create a StaticLibrarySearchGenerator from the given memory buffer and Archive object.
Definition at line 309 of file ExecutionUtils.cpp.
References llvm::consumeError(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), and llvm::Error::success().
Referenced by llvm::orc::COFFPlatform::Create(), Create(), llvm::orc::LLJIT::linkStaticLibraryInto(), Load(), and llvm::orc::ExecutorNativePlatform::operator()().
|
static |
Try to create a StaticLibrarySearchGenerator from the given memory buffer.
This call will succeed if the buffer contains a valid archive, otherwise it will return an error.
This call will succeed if the buffer contains a valid static library or a MachO universal binary containing a static library that is compatible with the ExecutionSession's triple. Otherwise it will return an error.
Definition at line 372 of file ExecutionUtils.cpp.
References B(), Create(), llvm::object::Archive::create(), llvm::object::createBinary(), llvm::dyn_cast(), llvm::orc::getMachOSliceRangeForTriple(), llvm::inconvertibleErrorCode(), llvm::isa(), and llvm::make_error().
|
static |
Definition at line 483 of file ExecutionUtils.cpp.
References A(), llvm::MemoryBufferRef::getBuffer(), llvm::MemoryBufferRef::getBufferIdentifier(), llvm::MemoryBuffer::getMemBuffer(), and llvm::StringRef::str().
Referenced by loadAllObjectFileMembers(), llvm::orc::ForceLoadMachOArchiveMembers::operator()(), and tryToGenerate().
|
static |
Try to create a StaticLibraryDefinitionGenerator from the given path.
This call will succeed if the file at the given path is a static library or a MachO universal binary containing a static library that is compatible with the ExecutionSession's triple. Otherwise it will return an error.
Definition at line 295 of file ExecutionUtils.cpp.
References Create(), llvm::orc::loadLinkableFile(), and llvm::orc::Required.
Referenced by llvm::orc::ELFNixPlatform::Create(), llvm::orc::MachOPlatform::Create(), llvm::orc::LLJIT::linkStaticLibraryInto(), and LLVMOrcCreateStaticLibrarySearchGeneratorForPath().
|
static |
A VisitMembersFunction that unconditionally loads all object files from the archive.
Archive members that are not valid object files will be skipped.
Definition at line 275 of file ExecutionUtils.cpp.
References A(), llvm::file_magic::coff_object, createMemberBuffer(), llvm::file_magic::elf_relocatable, llvm::identify_magic(), and llvm::file_magic::macho_object.
|
overridevirtual |
DefinitionGenerators should override this method to insert new definitions into the parent JITDylib.
K specifies the kind of this lookup. JD specifies the target JITDylib being searched, and JDLookupFlags specifies whether the search should match against hidden symbols. Finally, Symbols describes the set of unresolved symbols and their associated lookup flags.
Implements llvm::orc::DefinitionGenerator.
Definition at line 416 of file ExecutionUtils.cpp.
References _, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::count(), createMemberBuffer(), llvm::orc::Static, llvm::Error::success(), and ToRemove.