LLVM 20.0.0git
|
A utility class to expose symbols from a static library. More...
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
Public Types | |
using | GetObjectFileInterface = unique_function< Expected< MaterializationUnit::Interface >(ExecutionSession &ES, MemoryBufferRef ObjBuffer)> |
Interface builder function for objects loaded from this archive. | |
using | VisitMembersFunction = unique_function< Error(MemoryBufferRef)> |
Callback for visiting archive members at construction time. | |
Public Member Functions | |
const std::set< std::string > & | getImportedDynamicLibraries () const |
Returns a list of filenames of dynamic libraries that this archive has imported. | |
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 () |
virtual Error | tryToGenerate (LookupState &LS, LookupKind K, JITDylib &JD, JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &LookupSet)=0 |
DefinitionGenerators should override this method to insert new definitions into the parent JITDylib. | |
Static Public Member Functions | |
static VisitMembersFunction | loadAllObjectFileMembers (ObjectLayer &L, JITDylib &JD) |
A VisitMembersFunction that unconditionally loads all object files from the archive. | |
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 269 of file ExecutionUtils.h.
using llvm::orc::StaticLibraryDefinitionGenerator::GetObjectFileInterface = unique_function<Expected<MaterializationUnit::Interface>( ExecutionSession &ES, MemoryBufferRef ObjBuffer)> |
Interface builder function for objects loaded from this archive.
Definition at line 272 of file ExecutionUtils.h.
using llvm::orc::StaticLibraryDefinitionGenerator::VisitMembersFunction = unique_function<Error(MemoryBufferRef)> |
Callback for visiting archive members at construction time.
Con be used to pre-load archive members.
Definition at line 278 of file ExecutionUtils.h.
|
static |
Try to create a StaticLibrarySearchGenerator from the given memory buffer and Archive object.
Definition at line 307 of file ExecutionUtils.cpp.
References llvm::orc::Archive, llvm::consumeError(), and llvm::Error::success().
Referenced by Create(), llvm::orc::COFFPlatform::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 341 of file ExecutionUtils.cpp.
References B, llvm::object::Archive::create(), Create(), llvm::object::createBinary(), llvm::orc::getMachOSliceRangeForTriple(), and llvm::inconvertibleErrorCode().
|
inline |
Returns a list of filenames of dynamic libraries that this archive has imported.
This class does not load these libraries by itself. User is responsible for making sure these libraries are available to the JITDylib.
Definition at line 319 of file ExecutionUtils.h.
|
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 293 of file ExecutionUtils.cpp.
References Create(), llvm::orc::loadLinkableFile(), and llvm::orc::Required.
Referenced by llvm::orc::MachOPlatform::Create(), llvm::orc::ELFNixPlatform::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 278 of file ExecutionUtils.cpp.
References llvm::file_magic::coff_object, llvm::file_magic::elf_relocatable, llvm::MemoryBuffer::getMemBuffer(), llvm::identify_magic(), llvm::file_magic::macho_object, and llvm::Error::success().
|
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 385 of file ExecutionUtils.cpp.
References llvm::orc::ObjectLayer::add(), llvm::orc::ObjectLayer::getExecutionSession(), llvm::MemoryBuffer::getMemBuffer(), I, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), Name, llvm::orc::Static, and llvm::Error::success().