13#ifndef LLVM_EXECUTIONENGINE_JITLINK_X86_64_H
14#define LLVM_EXECUTIONENGINE_JITLINK_X86_64_H
408 const Symbol *GOTSymbol) {
409 using namespace support;
411 char *BlockWorkingMem =
B.getAlreadyMutableContent().data();
412 char *FixupPtr = BlockWorkingMem +
E.getOffset();
413 auto FixupAddress =
B.getAddress() +
E.getOffset();
415 switch (
E.getKind()) {
418 uint64_t Value =
E.getTarget().getAddress().getValue() +
E.getAddend();
419 *(ulittle64_t *)FixupPtr =
Value;
424 uint64_t Value =
E.getTarget().getAddress().getValue() +
E.getAddend();
426 *(ulittle32_t *)FixupPtr =
Value;
432 int64_t
Value =
E.getTarget().getAddress().getValue() +
E.getAddend();
434 *(little32_t *)FixupPtr =
Value;
441 uint64_t Value =
E.getTarget().getAddress().getValue() +
E.getAddend();
443 *(ulittle16_t *)FixupPtr =
Value;
450 uint64_t Value =
E.getTarget().getAddress().getValue() +
E.getAddend();
452 *(uint8_t *)FixupPtr =
Value;
466 E.getTarget().getAddress() - (FixupAddress + 4) +
E.getAddend();
468 *(little32_t *)FixupPtr =
Value;
475 int64_t
Value =
E.getTarget().getAddress() - FixupAddress +
E.getAddend();
476 *(little64_t *)FixupPtr =
Value;
481 int64_t
Value =
E.getTarget().getAddress() - FixupAddress +
E.getAddend();
483 *(little32_t *)FixupPtr =
Value;
490 int64_t
Value =
E.getTarget().getAddress() - FixupAddress +
E.getAddend();
499 int64_t
Value = FixupAddress -
E.getTarget().getAddress() +
E.getAddend();
500 *(little64_t *)FixupPtr =
Value;
505 int64_t
Value = FixupAddress -
E.getTarget().getAddress() +
E.getAddend();
507 *(little32_t *)FixupPtr =
Value;
513 assert(GOTSymbol &&
"No GOT section symbol");
515 E.getTarget().getAddress() - GOTSymbol->
getAddress() +
E.getAddend();
516 *(little64_t *)FixupPtr =
Value;
521 return make_error<JITLinkError>(
522 "In graph " +
G.getName() +
", section " +
B.getSection().getName() +
553 Symbol *InitialTarget =
nullptr,
558 B.addEdge(
Pointer64, 0, *InitialTarget, InitialAddend);
559 return G.addAnonymousSymbol(
B, 0, 8,
false,
false);
583 return G.addAnonymousSymbol(
595 switch (
E.getKind()) {
621 "Fell through switch, but no new kind to set");
623 dbgs() <<
" Fixing " <<
G.getEdgeKindName(
E.getKind()) <<
" edge at "
624 <<
B->getFixupAddress(
E) <<
" (" <<
B->getAddress() <<
" + "
625 <<
formatv(
"{0:x}",
E.getOffset()) <<
")\n";
627 E.setKind(KindToSet);
656 dbgs() <<
" Fixing " <<
G.getEdgeKindName(
E.getKind()) <<
" edge at "
657 <<
B->getFixupAddress(
E) <<
" (" <<
B->getAddress() <<
" + "
658 <<
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, X)
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.
Error applyFixup(LinkGraph &G, Block &B, const Edge &E, const Symbol *GOTSymbol)
Apply fixup expression for edge to block content.
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 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.
@ 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.
@ 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(const char *Fmt, Ts &&...Vals) -> formatv_object< decltype(std::make_tuple(support::detail::build_format_adapter(std::forward< Ts >(Vals))...))>
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.