LLVM 19.0.0git
Public Types | Public Member Functions | Static Public Member Functions | List of all members
llvm::orc::StaticLibraryDefinitionGenerator Class Reference

A utility class to expose symbols from a static library. More...

#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"

Inheritance diagram for llvm::orc::StaticLibraryDefinitionGenerator:
Inheritance graph
[legend]

Public Types

using GetObjectFileInterface = unique_function< Expected< MaterializationUnit::Interface >(ExecutionSession &ES, MemoryBufferRef ObjBuffer)>
 

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 Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > Load (ObjectLayer &L, const char *FileName, 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, 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, GetObjectFileInterface GetObjFileInterface=GetObjectFileInterface())
 Try to create a StaticLibrarySearchGenerator from the given memory buffer.
 

Detailed Description

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.

Member Typedef Documentation

◆ GetObjectFileInterface

Definition at line 272 of file ExecutionUtils.h.

Member Function Documentation

◆ Create() [1/2]

Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > llvm::orc::StaticLibraryDefinitionGenerator::Create ( ObjectLayer L,
std::unique_ptr< MemoryBuffer ArchiveBuffer,
GetObjectFileInterface  GetObjFileInterface = GetObjectFileInterface() 
)
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 339 of file ExecutionUtils.cpp.

References B, llvm::object::Archive::create(), Create(), llvm::object::createBinary(), and llvm::inconvertibleErrorCode().

◆ Create() [2/2]

Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > llvm::orc::StaticLibraryDefinitionGenerator::Create ( ObjectLayer L,
std::unique_ptr< MemoryBuffer ArchiveBuffer,
std::unique_ptr< object::Archive Archive,
GetObjectFileInterface  GetObjFileInterface = GetObjectFileInterface() 
)
static

Try to create a StaticLibrarySearchGenerator from the given memory buffer and Archive object.

Definition at line 320 of file ExecutionUtils.cpp.

References llvm::Error::success().

Referenced by llvm::orc::COFFPlatform::Create(), Create(), llvm::orc::LLJIT::linkStaticLibraryInto(), Load(), and llvm::orc::ExecutorNativePlatform::operator()().

◆ getImportedDynamicLibraries()

const std::set< std::string > & llvm::orc::StaticLibraryDefinitionGenerator::getImportedDynamicLibraries ( ) const
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 avaliable to the JITDylib.

Definition at line 306 of file ExecutionUtils.h.

◆ Load()

Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > llvm::orc::StaticLibraryDefinitionGenerator::Load ( ObjectLayer L,
const char FileName,
GetObjectFileInterface  GetObjFileInterface = GetObjectFileInterface() 
)
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 274 of file ExecutionUtils.cpp.

References B, Create(), llvm::object::createBinary(), llvm::createFileError(), llvm::formatv(), llvm::MemoryBuffer::getFileSlice(), and llvm::inconvertibleErrorCode().

Referenced by llvm::orc::MachOPlatform::Create(), llvm::orc::ELFNixPlatform::Create(), llvm::orc::LLJIT::linkStaticLibraryInto(), and LLVMOrcCreateStaticLibrarySearchGeneratorForPath().

◆ tryToGenerate()

Error llvm::orc::StaticLibraryDefinitionGenerator::tryToGenerate ( LookupState LS,
LookupKind  K,
JITDylib JD,
JITDylibLookupFlags  JDLookupFlags,
const SymbolLookupSet LookupSet 
)
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 382 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().


The documentation for this class was generated from the following files: