13#ifndef LLVM_EXECUTIONENGINE_JITLINK_X86_H
14#define LLVM_EXECUTIONENGINE_JITLINK_X86_H
185 const Symbol *GOTSymbol) {
188 char *BlockWorkingMem =
B.getAlreadyMutableContent().data();
189 char *FixupPtr = BlockWorkingMem +
E.getOffset();
190 auto FixupAddress =
B.getAddress() +
E.getOffset();
192 switch (
E.getKind()) {
194 uint32_t Value =
E.getTarget().getAddress().getValue() +
E.getAddend();
200 int32_t
Value =
E.getTarget().getAddress() - FixupAddress +
E.getAddend();
206 uint32_t Value =
E.getTarget().getAddress().getValue() +
E.getAddend();
215 int32_t
Value =
E.getTarget().getAddress() - FixupAddress +
E.getAddend();
224 int32_t
Value =
E.getTarget().getAddress() - FixupAddress +
E.getAddend();
230 assert(GOTSymbol &&
"No GOT section symbol");
232 E.getTarget().getAddress() - GOTSymbol->
getAddress() +
E.getAddend();
240 int32_t
Value =
E.getTarget().getAddress() - FixupAddress +
E.getAddend();
246 return make_error<JITLinkError>(
247 "In graph " +
G.getName() +
", section " +
B.getSection().getName() +
278 Symbol *InitialTarget =
nullptr,
283 B.addEdge(
Pointer32, 0, *InitialTarget, InitialAddend);
284 return G.addAnonymousSymbol(
B, 0,
PointerSize,
false,
false);
301 2, PointerSymbol, 0);
312 return G.addAnonymousSymbol(
323 Edge::Kind KindToSet = Edge::Invalid;
324 switch (
E.getKind()) {
337 assert(KindToSet != Edge::Invalid &&
338 "Fell through switch, but no new kind to set");
340 dbgs() <<
" Fixing " <<
G.getEdgeKindName(
E.getKind()) <<
" edge at "
341 <<
B->getFixupAddress(
E) <<
" (" <<
B->getAddress() <<
" + "
342 <<
formatv(
"{0:x}",
E.getOffset()) <<
")\n";
344 E.setKind(KindToSet);
373 dbgs() <<
" Fixing " <<
G.getEdgeKindName(
E.getKind()) <<
" edge at "
374 <<
B->getFixupAddress(
E) <<
" (" <<
B->getAddress() <<
" + "
375 <<
formatv(
"{0:x}",
E.getOffset()) <<
")\n";
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_LIKELY(EXPR)
#define DEBUG_WITH_TYPE(TYPE,...)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
StringRef - Represent a constant reference to a string, i.e.
Target - Wrapper for Target specific information.
LLVM Value Representation.
An Addressable with content and edges.
Represents fixups and constraints in the LinkGraph.
Represents an object file section.
orc::ExecutorAddr getAddress() const
Returns the address of this symbol.
A CRTP base for tables that are built on demand, e.g.
Symbol & getEntryForTarget(LinkGraph &G, Symbol &Target)
Return the constructed entry.
Global Offset Table Builder.
static StringRef getSectionName()
Symbol & createEntry(LinkGraph &G, Symbol &Target)
bool visitEdge(LinkGraph &G, Block *B, Edge &E)
Procedure Linkage Table Builder.
Symbol & createEntry(LinkGraph &G, Symbol &Target)
bool visitEdge(LinkGraph &G, Block *B, Edge &E)
PLTTableManager(GOTTableManager &GOT)
static StringRef getSectionName()
Section & getStubsSection(LinkGraph &G)
Represents an address in the executor process.
EdgeKind_x86
Represets x86 fixups.
@ BranchPCRel32ToPtrJumpStubBypassable
A relaxable version of BranchPCRel32ToPtrJumpStub.
@ RequestGOTAndTransformToDelta32FromGOT
A GOT entry offset within GOT getter/constructor, transformed to Delta32FromGOT pointing at the GOT e...
@ Pointer16
A plain 16-bit pointer value relocation.
@ BranchPCRel32
A 32-bit PC-relative branch.
@ PCRel32
A 32-bit PC-relative relocation.
@ PCRel16
A 16-bit PC-relative relocation.
@ BranchPCRel32ToPtrJumpStub
A 32-bit PC-relative branch to a pointer jump stub.
@ Pointer32
A plain 32-bit pointer value relocation.
@ Delta32FromGOT
A 32-bit GOT delta.
Block & createPointerJumpStubBlock(LinkGraph &G, Section &StubSection, Symbol &PointerSymbol)
Create a jump stub block that jumps via the pointer at the given symbol.
LLVM_ABI const char NullPointerContent[PointerSize]
x86 null pointer content.
Symbol & createAnonymousPointerJumpStub(LinkGraph &G, Section &StubSection, Symbol &PointerSymbol)
Create a jump stub that jumps via the pointer at the given symbol and an anonymous symbol pointing to...
LLVM_ABI const char * getEdgeKindName(Edge::Kind K)
Returns a string name for the given x86 edge.
LLVM_ABI Error optimizeGOTAndStubAccesses(LinkGraph &G)
Optimize the GOT and Stub relocations if the edge target address is in range.
constexpr uint32_t PointerSize
x86 pointer size.
Symbol & createAnonymousPointer(LinkGraph &G, Section &PointerSection, Symbol *InitialTarget=nullptr, uint64_t InitialAddend=0)
Creates a new pointer block in the given section and returns an anonymous symbol pointing to it.
LLVM_ABI const char PointerJumpStubContent[6]
x86 pointer jump stub content.
Error applyFixup(LinkGraph &G, Block &B, const Edge &E, const Symbol *GOTSymbol)
Apply fixup expression for edge to block content.
LLVM_ABI Error makeTargetOutOfRangeError(const LinkGraph &G, const Block &B, const Edge &E)
Create an out of range error for the given edge in the given block.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.