LLVM 20.0.0git
Classes | Public Types | Public Member Functions | Friends | List of all members
llvm::RuntimeDyld Class Reference

#include "llvm/ExecutionEngine/RuntimeDyld.h"

Classes

class  LoadedObjectInfo
 Information about the loaded object. More...
 
class  MemoryManager
 Memory Management. More...
 

Public Types

using NotifyStubEmittedFunction = std::function< void(StringRef FileName, StringRef SectionName, StringRef SymbolName, unsigned SectionID, uint32_t StubOffset)>
 

Public Member Functions

void reassignSectionAddress (unsigned SectionID, uint64_t Addr)
 
 RuntimeDyld (MemoryManager &MemMgr, JITSymbolResolver &Resolver)
 Construct a RuntimeDyld instance.
 
 RuntimeDyld (const RuntimeDyld &)=delete
 
RuntimeDyldoperator= (const RuntimeDyld &)=delete
 
 ~RuntimeDyld ()
 
std::unique_ptr< LoadedObjectInfoloadObject (const object::ObjectFile &O)
 Add the referenced object file to the list of objects to be loaded and relocated.
 
void * getSymbolLocalAddress (StringRef Name) const
 Get the address of our local copy of the symbol.
 
unsigned getSymbolSectionID (StringRef Name) const
 Get the section ID for the section containing the given symbol.
 
JITEvaluatedSymbol getSymbol (StringRef Name) const
 Get the target address and flags for the named symbol.
 
std::map< StringRef, JITEvaluatedSymbolgetSymbolTable () const
 Returns a copy of the symbol table.
 
void resolveRelocations ()
 Resolve the relocations for all symbols we currently know about.
 
void mapSectionAddress (const void *LocalAddress, uint64_t TargetAddress)
 Map a section to its target address space value.
 
StringRef getSectionContent (unsigned SectionID) const
 Returns the section's working memory.
 
uint64_t getSectionLoadAddress (unsigned SectionID) const
 If the section was loaded, return the section's load address, otherwise return std::nullopt.
 
void setNotifyStubEmitted (NotifyStubEmittedFunction NotifyStubEmitted)
 Set the NotifyStubEmitted callback.
 
void registerEHFrames ()
 Register any EH frame sections that have been loaded but not previously registered with the memory manager.
 
void deregisterEHFrames ()
 
bool hasError ()
 
StringRef getErrorString ()
 
void setProcessAllSections (bool ProcessAllSections)
 By default, only sections that are "required for execution" are passed to the RTDyldMemoryManager, and other sections are discarded.
 
void finalizeWithMemoryManagerLocking ()
 Perform all actions needed to make the code owned by this RuntimeDyld instance executable:
 

Friends

void jitLinkForORC (object::OwningBinary< object::ObjectFile > O, RuntimeDyld::MemoryManager &MemMgr, JITSymbolResolver &Resolver, bool ProcessAllSections, unique_function< Error(const object::ObjectFile &Obj, LoadedObjectInfo &, std::map< StringRef, JITEvaluatedSymbol >)> OnLoaded, unique_function< void(object::OwningBinary< object::ObjectFile > O, std::unique_ptr< LoadedObjectInfo >, Error)> OnEmitted)
 

Detailed Description

Definition at line 58 of file RuntimeDyld.h.

Member Typedef Documentation

◆ NotifyStubEmittedFunction

using llvm::RuntimeDyld::NotifyStubEmittedFunction = std::function<void( StringRef FileName, StringRef SectionName, StringRef SymbolName, unsigned SectionID, uint32_t StubOffset)>

Definition at line 64 of file RuntimeDyld.h.

Constructor & Destructor Documentation

◆ RuntimeDyld() [1/2]

llvm::RuntimeDyld::RuntimeDyld ( RuntimeDyld::MemoryManager MemMgr,
JITSymbolResolver Resolver 
)

Construct a RuntimeDyld instance.

Definition at line 1294 of file RuntimeDyld.cpp.

◆ RuntimeDyld() [2/2]

llvm::RuntimeDyld::RuntimeDyld ( const RuntimeDyld )
delete

◆ ~RuntimeDyld()

llvm::RuntimeDyld::~RuntimeDyld ( )
default

Member Function Documentation

◆ deregisterEHFrames()

void llvm::RuntimeDyld::deregisterEHFrames ( )

Definition at line 1437 of file RuntimeDyld.cpp.

Referenced by llvm::MCJIT::~MCJIT().

◆ finalizeWithMemoryManagerLocking()

void llvm::RuntimeDyld::finalizeWithMemoryManagerLocking ( )

Perform all actions needed to make the code owned by this RuntimeDyld instance executable:

1) Apply relocations. 2) Register EH frames. 3) Update memory permissions*.

  • Finalization is potentially recursive**, and the 3rd step will only be applied by the outermost call to finalize. This allows different RuntimeDyld instances to share a memory manager without the innermost finalization locking the memory and causing relocation fixup errors in outer instances.

** Recursive finalization occurs when one RuntimeDyld instances needs the address of a symbol owned by some other instance in order to apply relocations.

Definition at line 1411 of file RuntimeDyld.cpp.

References llvm::RuntimeDyld::MemoryManager::finalizeMemory(), registerEHFrames(), and resolveRelocations().

◆ getErrorString()

StringRef llvm::RuntimeDyld::getErrorString ( )

◆ getSectionContent()

StringRef llvm::RuntimeDyld::getSectionContent ( unsigned  SectionID) const

Returns the section's working memory.

Definition at line 1422 of file RuntimeDyld.cpp.

References assert().

◆ getSectionLoadAddress()

uint64_t llvm::RuntimeDyld::getSectionLoadAddress ( unsigned  SectionID) const

If the section was loaded, return the section's load address, otherwise return std::nullopt.

Definition at line 1427 of file RuntimeDyld.cpp.

References assert().

◆ getSymbol()

JITEvaluatedSymbol llvm::RuntimeDyld::getSymbol ( StringRef  Name) const

Get the target address and flags for the named symbol.

This address is the one used for relocation.

Definition at line 1384 of file RuntimeDyld.cpp.

References Name.

Referenced by llvm::MCJIT::findExistingSymbol(), and llvm::MCJIT::getPointerToFunction().

◆ getSymbolLocalAddress()

void * llvm::RuntimeDyld::getSymbolLocalAddress ( StringRef  Name) const

Get the address of our local copy of the symbol.

This may or may not be the address used for relocation (clients can copy the data around and resolve relocatons based on where they put it).

Definition at line 1373 of file RuntimeDyld.cpp.

References Name.

◆ getSymbolSectionID()

unsigned llvm::RuntimeDyld::getSymbolSectionID ( StringRef  Name) const

Get the section ID for the section containing the given symbol.

Definition at line 1379 of file RuntimeDyld.cpp.

References assert(), and Name.

◆ getSymbolTable()

std::map< StringRef, JITEvaluatedSymbol > llvm::RuntimeDyld::getSymbolTable ( ) const

Returns a copy of the symbol table.

This can be used by on-finalized callbacks to extract the symbol table before throwing away the RuntimeDyld instance. Because the map keys (StringRefs) are backed by strings inside the RuntimeDyld instance, the map should be processed before the RuntimeDyld instance is discarded.

Definition at line 1390 of file RuntimeDyld.cpp.

Referenced by llvm::jitLinkForORC().

◆ hasError()

bool llvm::RuntimeDyld::hasError ( )

◆ loadObject()

std::unique_ptr< RuntimeDyld::LoadedObjectInfo > llvm::RuntimeDyld::loadObject ( const object::ObjectFile O)

◆ mapSectionAddress()

void llvm::RuntimeDyld::mapSectionAddress ( const void *  LocalAddress,
uint64_t  TargetAddress 
)

Map a section to its target address space value.

Map the address of a JIT section as returned from the memory manager to the address in the target process as the running code will see it. This is the address which will be used for relocation resolution.

Definition at line 1402 of file RuntimeDyld.cpp.

Referenced by llvm::MCJIT::mapSectionAddress().

◆ operator=()

RuntimeDyld & llvm::RuntimeDyld::operator= ( const RuntimeDyld )
delete

◆ reassignSectionAddress()

void llvm::RuntimeDyld::reassignSectionAddress ( unsigned  SectionID,
uint64_t  Addr 
)

Definition at line 1398 of file RuntimeDyld.cpp.

References Addr.

◆ registerEHFrames()

void llvm::RuntimeDyld::registerEHFrames ( )

Register any EH frame sections that have been loaded but not previously registered with the memory manager.

Note, RuntimeDyld is responsible for identifying the EH frame and calling the memory manager with the EH frame section data. However, the memory manager itself will handle the actual target-specific EH frame registration.

Definition at line 1432 of file RuntimeDyld.cpp.

Referenced by llvm::MCJIT::finalizeLoadedModules(), and finalizeWithMemoryManagerLocking().

◆ resolveRelocations()

void llvm::RuntimeDyld::resolveRelocations ( )

Resolve the relocations for all symbols we currently know about.

Definition at line 1396 of file RuntimeDyld.cpp.

Referenced by llvm::MCJIT::finalizeLoadedModules(), and finalizeWithMemoryManagerLocking().

◆ setNotifyStubEmitted()

void llvm::RuntimeDyld::setNotifyStubEmitted ( NotifyStubEmittedFunction  NotifyStubEmitted)
inline

Set the NotifyStubEmitted callback.

This is used for debugging purposes. A callback is made for each stub that is generated.

Definition at line 238 of file RuntimeDyld.h.

◆ setProcessAllSections()

void llvm::RuntimeDyld::setProcessAllSections ( bool  ProcessAllSections)
inline

By default, only sections that are "required for execution" are passed to the RTDyldMemoryManager, and other sections are discarded.

Passing 'true' to this method will cause RuntimeDyld to pass all sections to its memory manager regardless of whether they are "required to execute" in the usual sense. This is useful for inspecting metadata sections that may not contain relocations, E.g. Debug info, stackmaps.

Must be called before the first object file is loaded.

Definition at line 262 of file RuntimeDyld.h.

References assert().

Referenced by llvm::jitLinkForORC(), and llvm::MCJIT::setProcessAllSections().

Friends And Related Function Documentation

◆ jitLinkForORC

void jitLinkForORC ( object::OwningBinary< object::ObjectFile O,
RuntimeDyld::MemoryManager MemMgr,
JITSymbolResolver Resolver,
bool  ProcessAllSections,
unique_function< Error(const object::ObjectFile &Obj, LoadedObjectInfo &, std::map< StringRef, JITEvaluatedSymbol >)>  OnLoaded,
unique_function< void(object::OwningBinary< object::ObjectFile > O, std::unique_ptr< LoadedObjectInfo >, Error)>  OnEmitted 
)
friend

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