LLVM 22.0.0git
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 >:
[legend]

Public Member Functions

 ELFLinkGraphBuilder (const object::ELFFile< ELFT > &Obj, std::shared_ptr< orc::SymbolStringPool > SSP, 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 82 of file ELFLinkGraphBuilder.h.

◆ ELFSymbolIndex

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

Definition at line 83 of file ELFLinkGraphBuilder.h.

Constructor & Destructor Documentation

◆ ELFLinkGraphBuilder()

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.

Referenced by buildGraph().

◆ 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 127 of file ELFLinkGraphBuilder.h.

Referenced by graphifySections().

◆ 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 153 of file ELFLinkGraphBuilder.h.

References forEachRelaRelocation().

◆ forEachRelaRelocation() [2/3]

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

Definition at line 596 of file ELFLinkGraphBuilder.h.

◆ 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 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 166 of file ELFLinkGraphBuilder.h.

References forEachRelRelocation().

◆ forEachRelRelocation() [2/3]

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

Definition at line 646 of file ELFLinkGraphBuilder.h.

◆ 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 forEachRelRelocation().

◆ getGraphBlock()

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

Definition at line 94 of file ELFLinkGraphBuilder.h.

References GraphBlocks.

Referenced by graphifySymbols().

◆ getGraphSymbol()

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

Definition at line 103 of file ELFLinkGraphBuilder.h.

References GraphSymbols.

◆ 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 116 of file ELFLinkGraphBuilder.h.

Referenced by graphifySymbols().

◆ getSymbolLinkageAndScope()

◆ graphifySections()

◆ graphifySymbols()

◆ isRelocatable()

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

Definition at line 85 of file ELFLinkGraphBuilder.h.

References llvm::ELF::ET_REL, and Obj.

Referenced by buildGraph().

◆ 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 111 of file ELFLinkGraphBuilder.h.

Referenced by graphifySymbols().

◆ prepare()

◆ setGraphBlock()

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

Definition at line 89 of file ELFLinkGraphBuilder.h.

References assert(), B(), and GraphBlocks.

Referenced by graphifySections().

◆ setGraphSymbol()

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

Definition at line 98 of file ELFLinkGraphBuilder.h.

References assert(), and GraphSymbols.

Referenced by graphifySymbols().

◆ 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 69 of file ELFLinkGraphBuilder.h.

References ELFLinkGraphBuilder(), and ProcessDebugSections.

Member Data Documentation

◆ GraphBlocks

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

Definition at line 184 of file ELFLinkGraphBuilder.h.

Referenced by getGraphBlock(), and setGraphBlock().

◆ GraphSymbols

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

Definition at line 185 of file ELFLinkGraphBuilder.h.

Referenced by getGraphSymbol(), and setGraphSymbol().

◆ Obj

◆ ProcessDebugSections

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

Definition at line 180 of file ELFLinkGraphBuilder.h.

Referenced by graphifySections(), and setProcessDebugSections().

◆ Sections

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

Definition at line 177 of file ELFLinkGraphBuilder.h.

Referenced by graphifySections(), graphifySymbols(), and prepare().

◆ SectionStringTab

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

Definition at line 179 of file ELFLinkGraphBuilder.h.

Referenced by graphifySections(), graphifySymbols(), and prepare().

◆ ShndxTables

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

Definition at line 188 of file ELFLinkGraphBuilder.h.

Referenced by graphifySymbols(), and prepare().

◆ SymTabSec

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

Definition at line 178 of file ELFLinkGraphBuilder.h.

Referenced by graphifySymbols(), and prepare().


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