13#ifndef LLVM_EXECUTIONENGINE_JITLINK_X86_64_H
14#define LLVM_EXECUTIONENGINE_JITLINK_X86_64_H
439 const Symbol *GOTSymbol) {
440 using namespace support;
442 char *BlockWorkingMem =
B.getAlreadyMutableContent().data();
443 char *FixupPtr = BlockWorkingMem +
E.getOffset();
444 auto FixupAddress =
B.getAddress() +
E.getOffset();
446 switch (
E.getKind()) {
449 uint64_t Value =
E.getTarget().getAddress().getValue() +
E.getAddend();
450 *(ulittle64_t *)FixupPtr =
Value;
455 uint64_t Value =
E.getTarget().getAddress().getValue() +
E.getAddend();
457 *(ulittle32_t *)FixupPtr =
Value;
463 int64_t
Value =
E.getTarget().getAddress().getValue() +
E.getAddend();
465 *(little32_t *)FixupPtr =
Value;
472 uint64_t Value =
E.getTarget().getAddress().getValue() +
E.getAddend();
474 *(ulittle16_t *)FixupPtr =
Value;
481 uint64_t Value =
E.getTarget().getAddress().getValue() +
E.getAddend();
497 E.getTarget().getAddress() - (FixupAddress + 4) +
E.getAddend();
499 *(little32_t *)FixupPtr =
Value;
506 int64_t
Value =
E.getTarget().getAddress() - FixupAddress +
E.getAddend();
507 *(little64_t *)FixupPtr =
Value;
512 int64_t
Value =
E.getTarget().getAddress() - FixupAddress +
E.getAddend();
514 *(little32_t *)FixupPtr =
Value;
521 int64_t
Value =
E.getTarget().getAddress() - FixupAddress +
E.getAddend();
523 *(little16_t *)FixupPtr =
Value;
530 int64_t
Value =
E.getTarget().getAddress() - FixupAddress +
E.getAddend();
539 int64_t
Value = FixupAddress -
E.getTarget().getAddress() +
E.getAddend();
540 *(little64_t *)FixupPtr =
Value;
545 int64_t
Value = FixupAddress -
E.getTarget().getAddress() +
E.getAddend();
547 *(little32_t *)FixupPtr =
Value;
555 *(ulittle64_t *)FixupPtr =
Value;
562 *(ulittle32_t *)FixupPtr =
Value;
569 assert(GOTSymbol &&
"No GOT section symbol");
571 E.getTarget().getAddress() - GOTSymbol->
getAddress() +
E.getAddend();
572 *(little64_t *)FixupPtr =
Value;
577 return make_error<JITLinkError>(
578 "In graph " +
G.getName() +
", section " +
B.getSection().getName() +
609 Symbol *InitialTarget =
nullptr,
614 B.addEdge(
Pointer64, 0, *InitialTarget, InitialAddend);
615 return G.addAnonymousSymbol(
B, 0, 8,
false,
false);
639 return G.addAnonymousSymbol(
664 return G.addAnonymousSymbol(
676 switch (
E.getKind()) {
702 "Fell through switch, but no new kind to set");
704 dbgs() <<
" Fixing " <<
G.getEdgeKindName(
E.getKind()) <<
" edge at "
705 <<
B->getFixupAddress(
E) <<
" (" <<
B->getAddress() <<
" + "
706 <<
formatv(
"{0:x}",
E.getOffset()) <<
")\n";
708 E.setKind(KindToSet);
737 dbgs() <<
" Fixing " <<
G.getEdgeKindName(
E.getKind()) <<
" edge at "
738 <<
B->getFixupAddress(
E) <<
" (" <<
B->getAddress() <<
" + "
739 <<
formatv(
"{0:x}",
E.getOffset()) <<
")\n";
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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
Symbol & createEntry(LinkGraph &G, Symbol &Target)
static StringRef getSectionName()
bool visitEdge(LinkGraph &G, Block *B, Edge &E)
Procedure Linkage Table Builder.
PLTTableManager(GOTTableManager &GOT)
Symbol & createEntry(LinkGraph &G, Symbol &Target)
static StringRef getSectionName()
bool visitEdge(LinkGraph &G, Block *B, Edge &E)
Section & getStubsSection(LinkGraph &G)
Represents an address in the executor process.
const char * getEdgeKindName(Edge::Kind K)
Returns a string name for the given x86-64 edge.
Block & createReentryTrampolineBlock(LinkGraph &G, Section &TrampolineSection, Symbol &ReentrySymbol)
Create a block of N reentry trampolines.
Error applyFixup(LinkGraph &G, Block &B, const Edge &E, const Symbol *GOTSymbol)
Apply fixup expression for edge to block content.
Symbol & createAnonymousReentryTrampoline(LinkGraph &G, Section &TrampolineSection, Symbol &ReentrySymbol)
constexpr uint64_t PointerSize
x86_64 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.
Block & createPointerJumpStubBlock(LinkGraph &G, Section &StubSection, Symbol &PointerSymbol)
Create a jump stub block that jumps via the pointer at the given symbol.
const char NullPointerContent[PointerSize]
x86-64 null pointer content.
Error optimizeGOTAndStubAccesses(LinkGraph &G)
Optimize the GOT and Stub relocations if the edge target address is in range.
const char ReentryTrampolineContent[5]
x86-64 reentry trampoline.
const char PointerJumpStubContent[6]
x86-64 pointer jump stub content.
EdgeKind_x86_64
Represents x86-64 fixups and other x86-64-specific edge kinds.
@ Delta64FromGOT
A 64-bit GOT delta.
@ RequestTLSDescInGOTAndTransformToDelta32
TODO: Explain the generic edge kind.
@ Pointer32
A plain 32-bit pointer value relocation.
@ RequestGOTAndTransformToDelta32
A GOT entry getter/constructor, transformed to Delta32 pointing at the GOT entry for the original tar...
@ Pointer8
A plain 8-bit pointer value relocation.
@ PCRel32GOTLoadRelaxable
A PC-relative load of a GOT entry, relaxable if GOT entry target is in-range of the fixup.
@ Pointer32Signed
A signed 32-bit pointer value relocation.
@ BranchPCRel32
A 32-bit PC-relative branch.
@ RequestGOTAndTransformToDelta64
A GOT entry getter/constructor, transformed to Delta64 pointing at the GOT entry for the original tar...
@ RequestTLVPAndTransformToPCRel32TLVPLoadREXRelaxable
A TLVP entry getter/constructor, transformed to Delta32ToTLVPLoadREXRelaxable.
@ RequestGOTAndTransformToDelta64FromGOT
A GOT entry offset within GOT getter/constructor, transformed to Delta64FromGOT pointing at the GOT e...
@ PCRel32TLVPLoadREXRelaxable
A PC-relative REX load of a Thread Local Variable Pointer (TLVP) entry, relaxable if the TLVP entry t...
@ PCRel32
A 32-bit PC-relative relocation.
@ PCRel32GOTLoadREXRelaxable
A PC-relative REX load of a GOT entry, relaxable if GOT entry target is in-range of the fixup.
@ Size64
A 64-bit size relocation.
@ NegDelta64
A 64-bit negative delta.
@ Pointer16
A plain 16-bit pointer value relocation.
@ RequestGOTAndTransformToPCRel32GOTLoadRelaxable
A GOT entry getter/constructor, transformed to PCRel32ToGOTLoadRelaxable pointing at the GOT entry fo...
@ Pointer64
A plain 64-bit pointer value relocation.
@ Size32
A 32-bit size relocation.
@ BranchPCRel32ToPtrJumpStub
A 32-bit PC-relative branch to a pointer jump stub.
@ RequestGOTAndTransformToPCRel32GOTLoadREXRelaxable
A GOT entry getter/constructor, transformed to PCRel32ToGOTLoadREXRelaxable pointing at the GOT entry...
@ BranchPCRel32ToPtrJumpStubBypassable
A relaxable version of BranchPCRel32ToPtrJumpStub.
@ NegDelta32
A 32-bit negative delta.
@ FirstPlatformRelocation
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...
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.
This is an optimization pass for GlobalISel generic memory operations.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.