LLVM 22.0.0git
|
LinkGraph building code that's specific to the given ELFT, but common across all architectures. More...
#include "ExecutionEngine/JITLink/ELFLinkGraphBuilder.h"
Public Member Functions | |
ELFLinkGraphBuilder (const object::ELFFile< ELFT > &Obj, std::shared_ptr< orc::SymbolStringPool > SSP, Triple TT, SubtargetFeatures Features, StringRef FileName, LinkGraph::GetEdgeKindNameFunction GetEdgeKindName) | |
ELFLinkGraphBuilder & | setProcessDebugSections (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) |
Public Member Functions inherited from llvm::jitlink::ELFLinkGraphBuilderBase | |
ELFLinkGraphBuilderBase (std::unique_ptr< LinkGraph > G) | |
virtual | ~ELFLinkGraphBuilderBase () |
Protected Types | |
using | ELFSectionIndex = unsigned |
using | ELFSymbolIndex = unsigned |
Protected Member Functions | |
bool | isRelocatable () const |
void | setGraphBlock (ELFSectionIndex SecIndex, Block *B) |
Block * | getGraphBlock (ELFSectionIndex SecIndex) |
void | setGraphSymbol (ELFSymbolIndex SymIndex, Symbol &Sym) |
Symbol * | getGraphSymbol (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 Member Functions inherited from llvm::jitlink::ELFLinkGraphBuilderBase | |
Section & | getCommonSection () |
Protected Attributes | |
const ELFFile & | Obj |
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 |
Protected Attributes inherited from llvm::jitlink::ELFLinkGraphBuilderBase | |
std::unique_ptr< LinkGraph > | G |
Additional Inherited Members | |
Static Protected Member Functions inherited from llvm::jitlink::ELFLinkGraphBuilderBase | |
static bool | isDwarfSection (StringRef SectionName) |
LinkGraph building code that's specific to the given ELFT, but common across all architectures.
Definition at line 57 of file ELFLinkGraphBuilder.h.
|
protected |
Definition at line 82 of file ELFLinkGraphBuilder.h.
|
protected |
Definition at line 83 of file ELFLinkGraphBuilder.h.
llvm::jitlink::ELFLinkGraphBuilder< ELFT >::ELFLinkGraphBuilder | ( | const object::ELFFile< ELFT > & | Obj, |
std::shared_ptr< orc::SymbolStringPool > | SSP, | ||
Triple | TT, | ||
SubtargetFeatures | Features, | ||
StringRef | FileName, | ||
LinkGraph::GetEdgeKindNameFunction | GetEdgeKindName ) |
Definition at line 192 of file ELFLinkGraphBuilder.h.
References llvm::dbgs(), llvm::jitlink::ELFLinkGraphBuilderBase::ELFLinkGraphBuilderBase(), LLVM_DEBUG, llvm::move(), and Obj.
Referenced by llvm::jitlink::ELFLinkGraphBuilder_riscv< ELFT >::ELFLinkGraphBuilder_riscv(), and setProcessDebugSections().
|
pure virtual |
Call to derived class to handle relocations.
These require architecture specific knowledge to map to JITLink edge kinds.
Referenced by buildGraph().
Expected< std::unique_ptr< LinkGraph > > llvm::jitlink::ELFLinkGraphBuilder< ELFT >::buildGraph | ( | ) |
Attempt to construct and return the LinkGraph.
Definition at line 205 of file ELFLinkGraphBuilder.h.
References addRelocations(), llvm::jitlink::ELFLinkGraphBuilderBase::G, graphifySections(), graphifySymbols(), isRelocatable(), llvm::make_error(), and prepare.
Referenced by llvm::jitlink::createLinkGraphFromELFObject_aarch32(), llvm::jitlink::createLinkGraphFromELFObject_ppc64(), llvm::jitlink::createLinkGraphFromELFObject_riscv(), llvm::jitlink::createLinkGraphFromELFObject_x86(), and llvm::jitlink::createLinkGraphFromELFObject_x86_64().
|
inlineprotectedvirtual |
Override in derived classes to suppress certain sections in the link graph.
Definition at line 127 of file ELFLinkGraphBuilder.h.
Referenced by graphifySections().
|
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().
Error llvm::jitlink::ELFLinkGraphBuilder< ELFT >::forEachRelaRelocation | ( | const typename ELFT::Shdr & | RelSect, |
RelocHandlerFunction && | Func ) |
Definition at line 596 of file ELFLinkGraphBuilder.h.
|
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().
|
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().
Error llvm::jitlink::ELFLinkGraphBuilder< ELFT >::forEachRelRelocation | ( | const typename ELFT::Shdr & | RelSect, |
RelocHandlerFunction && | Func ) |
Definition at line 646 of file ELFLinkGraphBuilder.h.
|
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().
|
inlineprotected |
Definition at line 94 of file ELFLinkGraphBuilder.h.
References GraphBlocks.
Referenced by graphifySymbols().
|
inlineprotected |
Definition at line 103 of file ELFLinkGraphBuilder.h.
References GraphSymbols.
|
inlineprotectedvirtual |
Get the physical offset of the symbol on the target platform.
Definition at line 116 of file ELFLinkGraphBuilder.h.
Referenced by graphifySymbols().
|
protected |
Definition at line 226 of file ELFLinkGraphBuilder.h.
References llvm::jitlink::Default, llvm::jitlink::Hidden, llvm::inconvertibleErrorCode(), llvm::jitlink::Local, llvm::make_error(), llvm::ELF::STB_GLOBAL, llvm::ELF::STB_GNU_UNIQUE, llvm::ELF::STB_LOCAL, llvm::ELF::STB_WEAK, llvm::jitlink::Strong, llvm::ELF::STV_DEFAULT, llvm::ELF::STV_HIDDEN, llvm::ELF::STV_INTERNAL, llvm::ELF::STV_PROTECTED, and llvm::jitlink::Weak.
Referenced by graphifySymbols().
|
protected |
Definition at line 313 of file ELFLinkGraphBuilder.h.
References B(), llvm::Data, llvm::dbgs(), excludeSection(), llvm::orc::Exec, llvm::jitlink::ELFLinkGraphBuilderBase::G, isDwarfSection(), LLVM_DEBUG, llvm::make_error(), llvm::orc::NoAlloc, Obj, ProcessDebugSections, llvm::orc::Read, Sections, SectionStringTab, setGraphBlock(), llvm::ELF::SHF_ALLOC, llvm::ELF::SHF_EXECINSTR, llvm::ELF::SHF_WRITE, llvm::ELF::SHT_ARM_EXIDX, llvm::ELF::SHT_NOBITS, llvm::ELF::SHT_NULL, llvm::Error::success(), and llvm::orc::Write.
Referenced by buildGraph().
|
protected |
Definition at line 413 of file ELFLinkGraphBuilder.h.
References B(), llvm::dbgs(), llvm::jitlink::Default, llvm::formatv(), llvm::jitlink::ELFLinkGraphBuilderBase::G, llvm::jitlink::ELFLinkGraphBuilderBase::getCommonSection(), llvm::object::getExtendedSymbolTableIndex(), getGraphBlock(), getRawOffset(), getSymbolLinkageAndScope(), llvm::orc::ExecutorAddr::getValue(), llvm::inconvertibleErrorCode(), LLVM_DEBUG, llvm::jitlink::Local, llvm::make_error(), makeTargetFlags(), Obj, llvm::Offset, Sections, SectionStringTab, setGraphSymbol(), llvm::ELF::SHN_XINDEX, ShndxTables, llvm::ELF::STB_GLOBAL, llvm::ELF::STB_LOCAL, llvm::ELF::STB_WEAK, llvm::jitlink::Strong, llvm::ELF::STT_FILE, llvm::ELF::STT_FUNC, llvm::ELF::STT_NOTYPE, llvm::ELF::STT_OBJECT, llvm::ELF::STT_SECTION, llvm::ELF::STT_TLS, llvm::Error::success(), SymTabSec, llvm::toString(), and llvm::jitlink::Weak.
Referenced by buildGraph().
|
inlineprotected |
Definition at line 85 of file ELFLinkGraphBuilder.h.
References llvm::ELF::ET_REL, and Obj.
Referenced by buildGraph().
|
inlineprotectedvirtual |
Set the target flags on the given Symbol.
Definition at line 111 of file ELFLinkGraphBuilder.h.
Referenced by graphifySymbols().
|
protected |
Definition at line 271 of file ELFLinkGraphBuilder.h.
References llvm::dbgs(), llvm::jitlink::ELFLinkGraphBuilderBase::G, LLVM_DEBUG, llvm::make_error(), Obj, Sections, SectionStringTab, ShndxTables, llvm::ELF::SHT_SYMTAB, llvm::ELF::SHT_SYMTAB_SHNDX, llvm::Error::success(), and SymTabSec.
|
inlineprotected |
Definition at line 89 of file ELFLinkGraphBuilder.h.
References assert(), B(), and GraphBlocks.
Referenced by graphifySections().
|
inlineprotected |
Definition at line 98 of file ELFLinkGraphBuilder.h.
References assert(), and GraphSymbols.
Referenced by graphifySymbols().
|
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.
|
protected |
Definition at line 184 of file ELFLinkGraphBuilder.h.
Referenced by getGraphBlock(), and setGraphBlock().
|
protected |
Definition at line 185 of file ELFLinkGraphBuilder.h.
Referenced by getGraphSymbol(), and setGraphSymbol().
|
protected |
Definition at line 175 of file ELFLinkGraphBuilder.h.
Referenced by ELFLinkGraphBuilder(), llvm::jitlink::ELFLinkGraphBuilder_riscv< ELFT >::ELFLinkGraphBuilder_riscv(), graphifySections(), graphifySymbols(), isRelocatable(), and prepare().
|
protected |
Definition at line 180 of file ELFLinkGraphBuilder.h.
Referenced by graphifySections(), and setProcessDebugSections().
|
protected |
Definition at line 177 of file ELFLinkGraphBuilder.h.
Referenced by graphifySections(), graphifySymbols(), and prepare().
|
protected |
Definition at line 179 of file ELFLinkGraphBuilder.h.
Referenced by graphifySections(), graphifySymbols(), and prepare().
|
protected |
Definition at line 188 of file ELFLinkGraphBuilder.h.
Referenced by graphifySymbols(), and prepare().
|
protected |
Definition at line 178 of file ELFLinkGraphBuilder.h.
Referenced by graphifySymbols(), and prepare().