13#ifndef LIB_EXECUTIONENGINE_JITLINK_MACHOLINKGRAPHBUILDER_H
14#define LIB_EXECUTIONENGINE_JITLINK_MACHOLINKGRAPHBUILDER_H
45 assert((!
Name || !
Name->empty()) &&
"Name must be none or non-empty");
54 std::optional<StringRef>
Name;
79 const char *
Data =
nullptr;
87 std::shared_ptr<orc::SymbolStringPool> SSP,
Triple TT,
100 template <
typename... ArgTs>
111 auto I = IndexToSection.find(
Index);
112 assert(
I != IndexToSection.end() &&
"No section recorded at index");
120 auto I = IndexToSection.find(
Index);
121 if (
I == IndexToSection.end())
122 return make_error<JITLinkError>(
"No section recorded for index " +
131 auto I = IndexToSymbol.find(
Index);
132 if (
I == IndexToSymbol.end())
133 return make_error<JITLinkError>(
"No symbol at index " +
135 assert(
I->second &&
"Null symbol at index");
146 return std::prev(
I)->second;
157 return make_error<JITLinkError>(
"No symbol covering address " +
163 static bool isAltEntry(
const NormalizedSymbol &NSym);
186 void setCanonicalSymbol(NormalizedSection &NSec,
Symbol &
Sym) {
187 auto *&CanonicalSymEntry = NSec.CanonicalSymbols[
Sym.getAddress()];
191 assert((!CanonicalSymEntry || CanonicalSymEntry->getSize() == 0) &&
192 "Duplicate canonical symbol at address");
193 CanonicalSymEntry = &
Sym;
196 Section &getCommonSection();
197 void addSectionStartSymAndBlock(
unsigned SecIndex, Section &GraphSec,
202 Error createNormalizedSections();
203 Error createNormalizedSymbols();
207 Error graphifyRegularSymbols();
213 Symbol &createStandardGraphSymbol(NormalizedSymbol &
Sym, Block &
B,
214 size_t Size,
bool IsText,
215 bool IsNoDeadStrip,
bool IsCanonical);
218 Error graphifySectionsWithCustomParsers();
221 Error graphifyCStringSection(NormalizedSection &NSec,
222 std::vector<NormalizedSymbol *> NSyms);
229 std::unique_ptr<LinkGraph>
G;
231 bool SubsectionsViaSymbols =
false;
233 Section *CommonSection =
nullptr;
243 : CompactUnwindSectionName(CompactUnwindSectionName) {}
This file defines the StringMap class.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static std::optional< TypeSize > getPointerSize(const Value *V, const DataLayout &DL, const TargetLibraryInfo &TLI, const Function *F)
This file defines the DenseMap class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const Value * getAddress(const DbgVariableIntrinsic *DVI)
Allocate memory in an ever growing pool, as if by bump-pointer.
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringRef - Represent a constant reference to a string, i.e.
Manages the enabling and disabling of subtarget specific features.
Triple - Helper class for working with autoconf configuration names.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
A pass to split up __LD,__compact_unwind sections.
CompactUnwindSplitter(StringRef CompactUnwindSectionName)
Error operator()(LinkGraph &G)
const char *(*)(Edge::Kind) GetEdgeKindNameFunction
orc::ExecutorAddr Address
std::map< orc::ExecutorAddr, Symbol * > CanonicalSymbols
static bool isDebugSection(const NormalizedSection &NSec)
void addCustomSectionParser(StringRef SectionName, SectionParserFunction Parse)
const object::MachOObjectFile & getObject() const
virtual ~MachOLinkGraphBuilder()
virtual Error addRelocations()=0
std::function< Error(NormalizedSection &S)> SectionParserFunction
static Scope getScope(StringRef Name, uint8_t Type)
static bool isZeroFillSection(const NormalizedSection &NSec)
Expected< Symbol & > findSymbolByAddress(NormalizedSection &NSec, orc::ExecutorAddr Address)
Returns the symbol with the highest address not greater than the search address, or an error if no su...
Expected< NormalizedSymbol & > findSymbolByIndex(uint64_t Index)
Try to get the symbol at the given index.
LinkGraph & getGraph() const
Expected< std::unique_ptr< LinkGraph > > buildGraph()
NormalizedSection & getSectionByIndex(unsigned Index)
Index is zero-based (MachO section indexes are usually one-based) and assumed to be in-range.
NormalizedSymbol & createNormalizedSymbol(ArgTs &&... Args)
Create a symbol.
static Linkage getLinkage(uint16_t Desc)
Symbol * getSymbolByAddress(NormalizedSection &NSec, orc::ExecutorAddr Address)
Returns the symbol with the highest address not greater than the search address, or null if no such s...
static bool isAltEntry(const NormalizedSymbol &NSym)
MachO::relocation_info getRelocationInfo(const object::relocation_iterator RelItr)
Expected< NormalizedSection & > findSectionByIndex(unsigned Index)
Try to get the section at the given index.
Represents an object file section.
MachO::any_relocation_info getRelocation(DataRefImpl Rel) const
Represents an address in the executor process.
Linkage
Describes symbol linkage. This can be used to resolve definition clashes.
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
This is an optimization pass for GlobalISel generic memory operations.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
Description of the encoding of one expression Op.
NormalizedSymbol & operator=(const NormalizedSymbol &)=delete
std::optional< StringRef > Name
NormalizedSymbol(NormalizedSymbol &&)=delete
NormalizedSymbol & operator=(NormalizedSymbol &&)=delete
NormalizedSymbol(const NormalizedSymbol &)=delete