LLVM 20.0.0git
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
llvm::jitlink::ELFLinkGraphBuilder< ELFT > Class Template Referenceabstract

LinkGraph building code that's specific to the given ELFT, but common across all architectures. More...

#include "ExecutionEngine/JITLink/ELFLinkGraphBuilder.h"

Inheritance diagram for llvm::jitlink::ELFLinkGraphBuilder< ELFT >:
Inheritance graph
[legend]

Public Member Functions

 ELFLinkGraphBuilder (const object::ELFFile< ELFT > &Obj, Triple TT, SubtargetFeatures Features, StringRef FileName, LinkGraph::GetEdgeKindNameFunction GetEdgeKindName)
 
ELFLinkGraphBuildersetProcessDebugSections (bool ProcessDebugSections)
 Debug sections are included in the graph by default.
 
Expected< std::unique_ptr< LinkGraph > > buildGraph ()
 Attempt to construct and return the LinkGraph.
 
virtual Error addRelocations ()=0
 Call to derived class to handle relocations.
 
template<typename RelocHandlerFunction >
Error forEachRelaRelocation (const typename ELFT::Shdr &RelSect, RelocHandlerFunction &&Func)
 
template<typename RelocHandlerFunction >
Error forEachRelRelocation (const typename ELFT::Shdr &RelSect, RelocHandlerFunction &&Func)
 

Protected Types

using ELFSectionIndex = unsigned
 
using ELFSymbolIndex = unsigned
 

Protected Member Functions

bool isRelocatable () const
 
void setGraphBlock (ELFSectionIndex SecIndex, Block *B)
 
BlockgetGraphBlock (ELFSectionIndex SecIndex)
 
void setGraphSymbol (ELFSymbolIndex SymIndex, Symbol &Sym)
 
SymbolgetGraphSymbol (ELFSymbolIndex SymIndex)
 
Expected< std::pair< Linkage, Scope > > getSymbolLinkageAndScope (const typename ELFT::Sym &Sym, StringRef Name)
 
virtual TargetFlagsType makeTargetFlags (const typename ELFT::Sym &Sym)
 Set the target flags on the given Symbol.
 
virtual orc::ExecutorAddrDiff getRawOffset (const typename ELFT::Sym &Sym, TargetFlagsType Flags)
 Get the physical offset of the symbol on the target platform.
 
Error prepare ()
 
Error graphifySections ()
 
Error graphifySymbols ()
 
virtual bool excludeSection (const typename ELFT::Shdr &Sect) const
 Override in derived classes to suppress certain sections in the link graph.
 
template<typename RelocHandlerMethod >
Error forEachRelaRelocation (const typename ELFT::Shdr &RelSect, RelocHandlerMethod &&Func)
 Traverse all matching ELFT::Rela relocation records in the given section.
 
template<typename RelocHandlerMethod >
Error forEachRelRelocation (const typename ELFT::Shdr &RelSect, RelocHandlerMethod &&Func)
 Traverse all matching ELFT::Rel relocation records in the given section.
 
template<typename ClassT , typename RelocHandlerMethod >
Error forEachRelaRelocation (const typename ELFT::Shdr &RelSect, ClassT *Instance, RelocHandlerMethod &&Method)
 Traverse all matching rela relocation records in the given section.
 
template<typename ClassT , typename RelocHandlerMethod >
Error forEachRelRelocation (const typename ELFT::Shdr &RelSect, ClassT *Instance, RelocHandlerMethod &&Method)
 Traverse all matching rel relocation records in the given section.
 

Protected Attributes

const ELFFileObj
 
ELFFile::Elf_Shdr_Range Sections
 
const ELFFile::Elf_Shdr * SymTabSec = nullptr
 
StringRef SectionStringTab
 
bool ProcessDebugSections = true
 
DenseMap< ELFSectionIndex, Block * > GraphBlocks
 
DenseMap< ELFSymbolIndex, Symbol * > GraphSymbols
 
DenseMap< const typename ELFFile::Elf_Shdr *, ArrayRef< typename ELFFile::Elf_Word > > ShndxTables
 

Additional Inherited Members

Detailed Description

template<typename ELFT>
class llvm::jitlink::ELFLinkGraphBuilder< ELFT >

LinkGraph building code that's specific to the given ELFT, but common across all architectures.

Definition at line 57 of file ELFLinkGraphBuilder.h.

Member Typedef Documentation

◆ ELFSectionIndex

template<typename ELFT >
using llvm::jitlink::ELFLinkGraphBuilder< ELFT >::ELFSectionIndex = unsigned
protected

Definition at line 81 of file ELFLinkGraphBuilder.h.

◆ ELFSymbolIndex

template<typename ELFT >
using llvm::jitlink::ELFLinkGraphBuilder< ELFT >::ELFSymbolIndex = unsigned
protected

Definition at line 82 of file ELFLinkGraphBuilder.h.

Constructor & Destructor Documentation

◆ ELFLinkGraphBuilder()

template<typename ELFT >
llvm::jitlink::ELFLinkGraphBuilder< ELFT >::ELFLinkGraphBuilder ( const object::ELFFile< ELFT > &  Obj,
Triple  TT,
SubtargetFeatures  Features,
StringRef  FileName,
LinkGraph::GetEdgeKindNameFunction  GetEdgeKindName 
)

Definition at line 191 of file ELFLinkGraphBuilder.h.

References llvm::dbgs(), and LLVM_DEBUG.

Member Function Documentation

◆ addRelocations()

template<typename ELFT >
virtual Error llvm::jitlink::ELFLinkGraphBuilder< ELFT >::addRelocations ( )
pure virtual

Call to derived class to handle relocations.

These require architecture specific knowledge to map to JITLink edge kinds.

◆ buildGraph()

template<typename ELFT >
Expected< std::unique_ptr< LinkGraph > > llvm::jitlink::ELFLinkGraphBuilder< ELFT >::buildGraph

◆ excludeSection()

template<typename ELFT >
virtual bool llvm::jitlink::ELFLinkGraphBuilder< ELFT >::excludeSection ( const typename ELFT::Shdr &  Sect) const
inlineprotectedvirtual

Override in derived classes to suppress certain sections in the link graph.

Definition at line 126 of file ELFLinkGraphBuilder.h.

◆ forEachRelaRelocation() [1/3]

template<typename ELFT >
template<typename ClassT , typename RelocHandlerMethod >
Error llvm::jitlink::ELFLinkGraphBuilder< ELFT >::forEachRelaRelocation ( const typename ELFT::Shdr &  RelSect,
ClassT *  Instance,
RelocHandlerMethod &&  Method 
)
inlineprotected

Traverse all matching rela relocation records in the given section.

Convenience wrapper to allow passing a member function for the handler.

Definition at line 152 of file ELFLinkGraphBuilder.h.

References llvm::jitlink::ELFLinkGraphBuilder< ELFT >::forEachRelaRelocation().

◆ forEachRelaRelocation() [2/3]

template<typename ELFT >
template<typename RelocHandlerFunction >
Error llvm::jitlink::ELFLinkGraphBuilder< ELFT >::forEachRelaRelocation ( const typename ELFT::Shdr &  RelSect,
RelocHandlerFunction &&  Func 
)

◆ forEachRelaRelocation() [3/3]

template<typename ELFT >
template<typename RelocHandlerMethod >
Error llvm::jitlink::ELFLinkGraphBuilder< ELFT >::forEachRelaRelocation ( const typename ELFT::Shdr &  RelSect,
RelocHandlerMethod &&  Func 
)
protected

Traverse all matching ELFT::Rela relocation records in the given section.

The handler function Func should be callable with this signature: Error(const typename ELFT::Rela &, const typename ELFT::Shdr &, Section &)

Referenced by llvm::jitlink::ELFLinkGraphBuilder< ELFT >::forEachRelaRelocation().

◆ forEachRelRelocation() [1/3]

template<typename ELFT >
template<typename ClassT , typename RelocHandlerMethod >
Error llvm::jitlink::ELFLinkGraphBuilder< ELFT >::forEachRelRelocation ( const typename ELFT::Shdr &  RelSect,
ClassT *  Instance,
RelocHandlerMethod &&  Method 
)
inlineprotected

Traverse all matching rel relocation records in the given section.

Convenience wrapper to allow passing a member function for the handler.

Definition at line 165 of file ELFLinkGraphBuilder.h.

References llvm::jitlink::ELFLinkGraphBuilder< ELFT >::forEachRelRelocation().

◆ forEachRelRelocation() [2/3]

template<typename ELFT >
template<typename RelocHandlerFunction >
Error llvm::jitlink::ELFLinkGraphBuilder< ELFT >::forEachRelRelocation ( const typename ELFT::Shdr &  RelSect,
RelocHandlerFunction &&  Func 
)

◆ forEachRelRelocation() [3/3]

template<typename ELFT >
template<typename RelocHandlerMethod >
Error llvm::jitlink::ELFLinkGraphBuilder< ELFT >::forEachRelRelocation ( const typename ELFT::Shdr &  RelSect,
RelocHandlerMethod &&  Func 
)
protected

Traverse all matching ELFT::Rel relocation records in the given section.

The handler function Func should be callable with this signature: Error(const typename ELFT::Rel &, const typename ELFT::Shdr &, Section &)

Referenced by llvm::jitlink::ELFLinkGraphBuilder< ELFT >::forEachRelRelocation().

◆ getGraphBlock()

template<typename ELFT >
Block * llvm::jitlink::ELFLinkGraphBuilder< ELFT >::getGraphBlock ( ELFSectionIndex  SecIndex)
inlineprotected

◆ getGraphSymbol()

template<typename ELFT >
Symbol * llvm::jitlink::ELFLinkGraphBuilder< ELFT >::getGraphSymbol ( ELFSymbolIndex  SymIndex)
inlineprotected

◆ getRawOffset()

template<typename ELFT >
virtual orc::ExecutorAddrDiff llvm::jitlink::ELFLinkGraphBuilder< ELFT >::getRawOffset ( const typename ELFT::Sym &  Sym,
TargetFlagsType  Flags 
)
inlineprotectedvirtual

Get the physical offset of the symbol on the target platform.

Definition at line 115 of file ELFLinkGraphBuilder.h.

References Sym.

◆ getSymbolLinkageAndScope()

template<typename ELFT >
Expected< std::pair< Linkage, Scope > > llvm::jitlink::ELFLinkGraphBuilder< ELFT >::getSymbolLinkageAndScope ( const typename ELFT::Sym &  Sym,
StringRef  Name 
)
protected

◆ graphifySections()

template<typename ELFT >
Error llvm::jitlink::ELFLinkGraphBuilder< ELFT >::graphifySections
protected

◆ graphifySymbols()

template<typename ELFT >
Error llvm::jitlink::ELFLinkGraphBuilder< ELFT >::graphifySymbols
protected

◆ isRelocatable()

template<typename ELFT >
bool llvm::jitlink::ELFLinkGraphBuilder< ELFT >::isRelocatable ( ) const
inlineprotected

◆ makeTargetFlags()

template<typename ELFT >
virtual TargetFlagsType llvm::jitlink::ELFLinkGraphBuilder< ELFT >::makeTargetFlags ( const typename ELFT::Sym &  Sym)
inlineprotectedvirtual

Set the target flags on the given Symbol.

Definition at line 110 of file ELFLinkGraphBuilder.h.

◆ prepare()

template<typename ELFT >
Error llvm::jitlink::ELFLinkGraphBuilder< ELFT >::prepare
protected

◆ setGraphBlock()

template<typename ELFT >
void llvm::jitlink::ELFLinkGraphBuilder< ELFT >::setGraphBlock ( ELFSectionIndex  SecIndex,
Block B 
)
inlineprotected

◆ setGraphSymbol()

template<typename ELFT >
void llvm::jitlink::ELFLinkGraphBuilder< ELFT >::setGraphSymbol ( ELFSymbolIndex  SymIndex,
Symbol Sym 
)
inlineprotected

◆ setProcessDebugSections()

template<typename ELFT >
ELFLinkGraphBuilder & llvm::jitlink::ELFLinkGraphBuilder< ELFT >::setProcessDebugSections ( bool  ProcessDebugSections)
inline

Debug sections are included in the graph by default.

Use setProcessDebugSections(false) to ignore them if debug info is not needed.

Definition at line 68 of file ELFLinkGraphBuilder.h.

References llvm::jitlink::ELFLinkGraphBuilder< ELFT >::ProcessDebugSections.

Member Data Documentation

◆ GraphBlocks

template<typename ELFT >
DenseMap<ELFSectionIndex, Block *> llvm::jitlink::ELFLinkGraphBuilder< ELFT >::GraphBlocks
protected

◆ GraphSymbols

template<typename ELFT >
DenseMap<ELFSymbolIndex, Symbol *> llvm::jitlink::ELFLinkGraphBuilder< ELFT >::GraphSymbols
protected

◆ Obj

template<typename ELFT >
const ELFFile& llvm::jitlink::ELFLinkGraphBuilder< ELFT >::Obj
protected

◆ ProcessDebugSections

template<typename ELFT >
bool llvm::jitlink::ELFLinkGraphBuilder< ELFT >::ProcessDebugSections = true
protected

◆ Sections

template<typename ELFT >
ELFFile::Elf_Shdr_Range llvm::jitlink::ELFLinkGraphBuilder< ELFT >::Sections
protected

Definition at line 176 of file ELFLinkGraphBuilder.h.

◆ SectionStringTab

template<typename ELFT >
StringRef llvm::jitlink::ELFLinkGraphBuilder< ELFT >::SectionStringTab
protected

Definition at line 178 of file ELFLinkGraphBuilder.h.

◆ ShndxTables

template<typename ELFT >
DenseMap<const typename ELFFile::Elf_Shdr *, ArrayRef<typename ELFFile::Elf_Word> > llvm::jitlink::ELFLinkGraphBuilder< ELFT >::ShndxTables
protected

Definition at line 187 of file ELFLinkGraphBuilder.h.

◆ SymTabSec

template<typename ELFT >
const ELFFile::Elf_Shdr* llvm::jitlink::ELFLinkGraphBuilder< ELFT >::SymTabSec = nullptr
protected

Definition at line 177 of file ELFLinkGraphBuilder.h.


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