13 #ifndef LIB_EXECUTIONENGINE_JITLINK_MACHOLINKGRAPHBUILDER_H 14 #define LIB_EXECUTIONENGINE_JITLINK_MACHOLINKGRAPHBUILDER_H 40 : Name(Name), Value(Value), Type(Type), Sect(Sect), Desc(Desc), L(L),
42 assert((!Name || !Name->empty()) &&
"Name must be none or non-empty");
71 uint64_t Alignment = 0;
73 const char *
Data =
nullptr;
90 template <
typename... ArgTs>
101 auto I = IndexToSection.find(Index);
102 assert(
I != IndexToSection.end() &&
"No section recorded at index");
110 auto I = IndexToSection.find(Index);
111 if (
I == IndexToSection.end())
112 return make_error<JITLinkError>(
"No section recorded for index " +
121 if (Index >= IndexToSymbol.size())
122 return make_error<JITLinkError>(
"Symbol index out of range");
123 auto *Sym = IndexToSymbol[
Index];
125 return make_error<JITLinkError>(
"No symbol at index " +
133 auto I = AddrToCanonicalSymbol.upper_bound(Address);
134 if (
I == AddrToCanonicalSymbol.begin())
136 return std::prev(
I)->second;
144 if (Address < Sym->getAddress() + Sym->getSize())
146 return make_error<JITLinkError>(
"No symbol covering address " +
158 void setCanonicalSymbol(
Symbol &Sym) {
159 auto *&CanonicalSymEntry = AddrToCanonicalSymbol[Sym.
getAddress()];
163 assert((!CanonicalSymEntry || CanonicalSymEntry->getSize() == 0) &&
164 "Duplicate canonical symbol at address");
165 CanonicalSymEntry = &Sym;
169 void addSectionStartSymAndBlock(
Section &GraphSec, uint64_t
Address,
173 Error createNormalizedSections();
174 Error createNormalizedSymbols();
178 Error graphifyRegularSymbols();
181 Error graphifySectionsWithCustomParsers();
188 std::unique_ptr<LinkGraph>
G;
191 Section *CommonSection =
nullptr;
194 std::map<JITTargetAddress, Symbol *> AddrToCanonicalSymbol;
201 #endif // LIB_EXECUTIONENGINE_JITLINK_MACHOLINKGRAPHBUILDER_H Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface ...
virtual ~MachOLinkGraphBuilder()
Expected< NormalizedSection & > findSectionByIndex(unsigned Index)
Try to get the section at the given index.
static Linkage getLinkage(uint16_t Desc)
This class represents lattice values for constants.
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
static bool isAltEntry(const NormalizedSymbol &NSym)
Tagged union holding either a T or a Error.
NormalizedSection & getSectionByIndex(unsigned Index)
Index is zero-based (MachO section indexes are usually one-based) and assumed to be in-range...
LinkGraph & getGraph() const
Expected< NormalizedSymbol & > findSymbolByIndex(uint64_t Index)
Try to get the symbol at the given index.
static uint64_t getPointerSize(const Value *V, const DataLayout &DL, const TargetLibraryInfo &TLI, const Function *F)
uint64_t JITTargetAddress
Represents an address in the target process's address space.
Represents an object file section.
The instances of the Type class are immutable: once they are created, they are never changed...
Allocate memory in an ever growing pool, as if by bump-pointer.
friend class MachOLinkGraphBuilder
Symbol * getSymbolByAddress(JITTargetAddress Address)
Returns the symbol with the highest address not greater than the search address, or null if no such s...
Expected< Symbol & > findSymbolByAddress(JITTargetAddress Address)
Returns the symbol with the highest address not greater than the search address, or an error if no su...
Optional< StringRef > Name
JITTargetAddress getAddress() const
Returns the address of this symbol.
static Scope getScope(StringRef Name, uint8_t Type)
NormalizedSymbol & createNormalizedSymbol(ArgTs &&... Args)
Create a symbol.
NormalizedSymbol & operator=(const NormalizedSymbol &)=delete
Linkage
Describes symbol linkage.
void addCustomSectionParser(StringRef SectionName, SectionParserFunction Parse)
Expected< std::unique_ptr< LinkGraph > > buildGraph()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
virtual Error addRelocations()=0
Lightweight error class with error context and mandatory checking.
StringRef - Represent a constant reference to a string, i.e.
const object::MachOObjectFile & getObject() const
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
std::function< Error(NormalizedSection &S)> SectionParserFunction