LLVM 17.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]
Collaboration diagram for llvm::orc::StaticLibraryDefinitionGenerator:
Collaboration 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 > > Load (ObjectLayer &L, const char *FileName, const Triple &TT, 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, 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 260 of file ExecutionUtils.h.

Member Typedef Documentation

◆ GetObjectFileInterface

Definition at line 263 of file ExecutionUtils.h.

Member Function Documentation

◆ Create()

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.

Definition at line 336 of file ExecutionUtils.cpp.

References llvm::Error::success().

Referenced by Load().

◆ 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 294 of file ExecutionUtils.h.

◆ Load() [1/2]

Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > llvm::orc::StaticLibraryDefinitionGenerator::Load ( ObjectLayer L,
const char FileName,
const Triple TT,
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 given triple. Otherwise it will return an error.

Definition at line 286 of file ExecutionUtils.cpp.

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

◆ Load() [2/2]

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 is a valid archive, otherwise it will return an error.

Definition at line 274 of file ExecutionUtils.cpp.

References Create(), llvm::createFileError(), and llvm::MemoryBuffer::getFile().

Referenced by llvm::orc::ELFNixPlatform::Create(), llvm::orc::MachOPlatform::Create(), 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 351 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: