LLVM 20.0.0git
|
Classes | |
class | GOTTableManager |
Global Offset Table Builder. More... | |
class | PLTTableManager |
Procedure Linkage Table Builder. More... | |
Enumerations | |
enum | EdgeKind_x86_64 : Edge::Kind { Pointer64 = Edge::FirstRelocation , Pointer32 , Pointer32Signed , Pointer16 , Pointer8 , Delta64 , Delta32 , Delta16 , Delta8 , NegDelta64 , NegDelta32 , Size64 , Size32 , Delta64FromGOT , BranchPCRel32 , PCRel32 , BranchPCRel32ToPtrJumpStub , BranchPCRel32ToPtrJumpStubBypassable , RequestGOTAndTransformToDelta32 , RequestGOTAndTransformToDelta64 , RequestGOTAndTransformToDelta64FromGOT , PCRel32GOTLoadRelaxable , PCRel32GOTLoadREXRelaxable , RequestGOTAndTransformToPCRel32GOTLoadREXRelaxable , RequestGOTAndTransformToPCRel32GOTLoadRelaxable , PCRel32TLVPLoadREXRelaxable , RequestTLSDescInGOTAndTransformToDelta32 , RequestTLVPAndTransformToPCRel32TLVPLoadREXRelaxable , FirstPlatformRelocation } |
Represents x86-64 fixups and other x86-64-specific edge kinds. More... | |
Functions | |
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. | |
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. | |
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 it. | |
Block & | createReentryTrampolineBlock (LinkGraph &G, Section &TrampolineSection, Symbol &ReentrySymbol) |
Create a block of N reentry trampolines. | |
Symbol & | createAnonymousReentryTrampoline (LinkGraph &G, Section &TrampolineSection, Symbol &ReentrySymbol) |
Error | optimizeGOTAndStubAccesses (LinkGraph &G) |
Optimize the GOT and Stub relocations if the edge target address is in range. | |
Variables | |
constexpr uint64_t | PointerSize = 8 |
x86_64 pointer size. | |
const char | NullPointerContent [PointerSize] |
x86-64 null pointer content. | |
const char | PointerJumpStubContent [6] |
x86-64 pointer jump stub content. | |
const char | ReentryTrampolineContent [5] |
x86-64 reentry trampoline. | |
Represents x86-64 fixups and other x86-64-specific edge kinds.
Enumerator | |
---|---|
Pointer64 | A plain 64-bit pointer value relocation. Fixup expression: Fixup <- Target + Addend : uint64 |
Pointer32 | A plain 32-bit pointer value relocation. Fixup expression: Fixup <- Target + Addend : uint32 Errors:
|
Pointer32Signed | A signed 32-bit pointer value relocation. Fixup expression: Fixup <- Target + Addend : int32 Errors:
|
Pointer16 | A plain 16-bit pointer value relocation. Fixup expression: Fixup <- Target + Addend : uint16 Errors:
|
Pointer8 | A plain 8-bit pointer value relocation. Fixup expression: Fixup <- Target + Addend : uint8 Errors:
|
Delta64 | A 64-bit delta. Delta from the fixup to the target. Fixup expression: Fixup <- Target - Fixup + Addend : int64 |
Delta32 | A 32-bit delta. Delta from the fixup to the target. Fixup expression: Fixup <- Target - Fixup + Addend : int32 Errors:
|
Delta16 | A 16-bit delta. Delta from the fixup to the target. Fixup expression: Fixup <- Target - Fixup + Addend : int16 Errors:
|
Delta8 | An 8-bit delta. Delta from the fixup to the target. Fixup expression: Fixup <- Target - Fixup + Addend : int8 Errors:
|
NegDelta64 | A 64-bit negative delta. Delta from target back to the fixup. Fixup expression: Fixup <- Fixup - Target + Addend : int64 |
NegDelta32 | A 32-bit negative delta. Delta from the target back to the fixup. Fixup expression: Fixup <- Fixup - Target + Addend : int32 Errors:
|
Size64 | A 64-bit size relocation. Fixup expression: Fixup <- Size + Addend : uint64 |
Size32 | A 32-bit size relocation. Fixup expression: Fixup <- Size + Addend : uint32 Errors:
|
Delta64FromGOT | A 64-bit GOT delta. Delta from the global offset table to the target Fixup expression: Fixup <- Target - GOTSymbol + Addend : int64 Errors:
|
BranchPCRel32 | A 32-bit PC-relative branch. Represents a PC-relative call or branch to a target. This can be used to identify, record, and/or patch call sites. The fixup expression for this kind includes an implicit offset to account for the PC (unlike the Delta edges) so that a Branch32PCRel with a target T and addend zero is a call/branch to the start (offset zero) of T. Fixup expression: Fixup <- Target - (Fixup + 4) + Addend : int32 Errors:
|
PCRel32 | A 32-bit PC-relative relocation. Represents a data/control flow instruction using PC-relative addressing to a target. The fixup expression for this kind includes an implicit offset to account for the PC (unlike the Delta edges) so that a PCRel32 with a target T and addend zero is a call/branch to the start (offset zero) of T. Fixup expression: Fixup <- Target - (Fixup + 4) + Addend : int32 Errors:
|
BranchPCRel32ToPtrJumpStub | A 32-bit PC-relative branch to a pointer jump stub. The target of this relocation should be a pointer jump stub of the form: .text
jmpq *tgtptr(%rip)
; ...
.data
tgtptr:
.quad 0
This edge kind has the same fixup expression as BranchPCRel32, but further identifies the call/branch as being to a pointer jump stub. For edges of this kind the jump stub should not be bypassed (use BranchPCRel32ToPtrJumpStubBypassable for that), but the pointer location target may be recorded to allow manipulation at runtime. Fixup expression: Fixup <- Target - Fixup + Addend - 4 : int32 Errors:
|
BranchPCRel32ToPtrJumpStubBypassable | A relaxable version of BranchPCRel32ToPtrJumpStub. The edge kind has the same fixup expression as BranchPCRel32ToPtrJumpStub, but identifies the call/branch as being to a pointer jump stub that may be bypassed with a direct jump to the ultimate target if the ultimate target is within range of the fixup location. Fixup expression: Fixup <- Target - Fixup + Addend - 4: int32 Errors:
|
RequestGOTAndTransformToDelta32 | A GOT entry getter/constructor, transformed to Delta32 pointing at the GOT entry for the original target. Indicates that this edge should be transformed into a Delta32 targeting the GOT entry for the edge's current target, maintaining the same addend. A GOT entry for the target should be created if one does not already exist. Edges of this kind are usually handled by a GOT builder pass inserted by default. Fixup expression: NONE Errors:
|
RequestGOTAndTransformToDelta64 | A GOT entry getter/constructor, transformed to Delta64 pointing at the GOT entry for the original target. Indicates that this edge should be transformed into a Delta64 targeting the GOT entry for the edge's current target, maintaining the same addend. A GOT entry for the target should be created if one does not already exist. Edges of this kind are usually handled by a GOT builder pass inserted by default. Fixup expression: NONE Errors:
|
RequestGOTAndTransformToDelta64FromGOT | A GOT entry offset within GOT getter/constructor, transformed to Delta64FromGOT pointing at the GOT entry for the original target. Indicates that this edge should be transformed into a Delta64FromGOT targeting the GOT entry for the edge's current target, maintaining the same addend. A GOT entry for the target should be created if one does not already exist. Edges of this kind are usually handled by a GOT builder pass inserted by default Fixup expression: NONE Errors:
|
PCRel32GOTLoadRelaxable | A PC-relative load of a GOT entry, relaxable if GOT entry target is in-range of the fixup. TODO: Explain the optimization Fixup expression Fixup <- Target - (Fixup + 4) + Addend : int32 Errors:
|
PCRel32GOTLoadREXRelaxable | A PC-relative REX load of a GOT entry, relaxable if GOT entry target is in-range of the fixup. If the GOT entry target is in-range of the fixup then the load from the GOT may be replaced with a direct memory address calculation. Fixup expression: Fixup <- Target - (Fixup + 4) + Addend : int32 Errors:
|
RequestGOTAndTransformToPCRel32GOTLoadREXRelaxable | A GOT entry getter/constructor, transformed to PCRel32ToGOTLoadREXRelaxable pointing at the GOT entry for the original target. Indicates that this edge should be lowered to a PC32ToGOTLoadREXRelaxable targeting the GOT entry for the edge's current target, maintaining the same addend. A GOT entry for the target should be created if one does not already exist. Edges of this kind are usually lowered by a GOT builder pass inserted by default. Fixup expression: NONE Errors:
|
RequestGOTAndTransformToPCRel32GOTLoadRelaxable | A GOT entry getter/constructor, transformed to PCRel32ToGOTLoadRelaxable pointing at the GOT entry for the original target. Indicates that this edge should be lowered to a PC32ToGOTLoadRelaxable targeting the GOT entry for the edge's current target, maintaining the same addend. A GOT entry for the target should be created if one does not already exist. Edges of this kind are usually lowered by a GOT builder pass inserted by default. Fixup expression: NONE Errors:
|
PCRel32TLVPLoadREXRelaxable | A PC-relative REX load of a Thread Local Variable Pointer (TLVP) entry, relaxable if the TLVP entry target is in-range of the fixup. If the TLVP entry target is in-range of the fixup then the load from the TLVP may be replaced with a direct memory address calculation. The target of this edge must be a thread local variable entry of the form .quad <tlv getter thunk> .quad <tlv key> .quad <tlv initializer> Fixup expression: Fixup <- Target - (Fixup + 4) + Addend : int32 Errors:
|
RequestTLSDescInGOTAndTransformToDelta32 | TODO: Explain the generic edge kind. |
RequestTLVPAndTransformToPCRel32TLVPLoadREXRelaxable | A TLVP entry getter/constructor, transformed to Delta32ToTLVPLoadREXRelaxable. Indicates that this edge should be transformed into a Delta32ToTLVPLoadREXRelaxable targeting the TLVP entry for the edge's current target. A TLVP entry for the target should be created if one does not already exist. Fixup expression: NONE Errors:
|
FirstPlatformRelocation |
|
inline |
Apply fixup expression for edge to block content.
Definition at line 438 of file x86_64.h.
References assert(), B, BranchPCRel32, BranchPCRel32ToPtrJumpStub, BranchPCRel32ToPtrJumpStubBypassable, Delta16, Delta32, Delta64, Delta64FromGOT, Delta8, E, G, llvm::jitlink::Symbol::getAddress(), getEdgeKindName(), LLVM_LIKELY, llvm::jitlink::makeTargetOutOfRangeError(), NegDelta32, NegDelta64, PCRel32, PCRel32GOTLoadRelaxable, PCRel32GOTLoadREXRelaxable, PCRel32TLVPLoadREXRelaxable, Pointer16, Pointer32, Pointer32Signed, Pointer64, Pointer8, Size32, Size64, and llvm::Error::success().
|
inline |
Creates a new pointer block in the given section and returns an anonymous symbol pointing to it.
If InitialTarget is given then an Pointer64 relocation will be added to the block pointing at InitialTarget.
The pointer block will have the following default values: alignment: 64-bit alignment-offset: 0 address: highest allowable (~7U)
Definition at line 608 of file x86_64.h.
References B, G, NullPointerContent, and Pointer64.
Referenced by llvm::jitlink::x86_64::GOTTableManager::createEntry().
|
inline |
Create a jump stub that jumps via the pointer at the given symbol and an anonymous symbol pointing to it.
Return the anonymous symbol.
The stub block will be created by createPointerJumpStubBlock.
Definition at line 636 of file x86_64.h.
References createPointerJumpStubBlock(), and G.
Referenced by llvm::jitlink::x86_64::PLTTableManager::createEntry().
|
inline |
Definition at line 661 of file x86_64.h.
References createReentryTrampolineBlock(), G, and ReentryTrampolineContent.
Referenced by llvm::orc::JITLinkReentryTrampolines::Create().
|
inline |
Create a jump stub block that jumps via the pointer at the given symbol.
The stub block will have the following default values: alignment: 8-bit alignment-offset: 0 address: highest allowable: (~5U)
Definition at line 624 of file x86_64.h.
References B, BranchPCRel32, G, and PointerJumpStubContent.
Referenced by createAnonymousPointerJumpStub().
|
inline |
Create a block of N reentry trampolines.
Definition at line 652 of file x86_64.h.
References B, BranchPCRel32, G, and ReentryTrampolineContent.
Referenced by createAnonymousReentryTrampoline().
const char * llvm::jitlink::x86_64::getEdgeKindName | ( | Edge::Kind | K | ) |
Returns a string name for the given x86-64 edge.
For debugging purposes only.
Definition at line 21 of file x86_64.cpp.
References BranchPCRel32, BranchPCRel32ToPtrJumpStub, BranchPCRel32ToPtrJumpStubBypassable, Delta16, Delta32, Delta64, Delta64FromGOT, Delta8, llvm::jitlink::getGenericEdgeKindName(), NegDelta32, NegDelta64, PCRel32, PCRel32GOTLoadRelaxable, PCRel32GOTLoadREXRelaxable, PCRel32TLVPLoadREXRelaxable, Pointer16, Pointer32, Pointer32Signed, Pointer64, Pointer8, RequestGOTAndTransformToDelta32, RequestGOTAndTransformToDelta64, RequestGOTAndTransformToDelta64FromGOT, RequestGOTAndTransformToPCRel32GOTLoadRelaxable, RequestGOTAndTransformToPCRel32GOTLoadREXRelaxable, RequestTLVPAndTransformToPCRel32TLVPLoadREXRelaxable, Size32, and Size64.
Referenced by applyFixup(), llvm::jitlink::getCOFFX86RelocationKindName(), and optimizeGOTAndStubAccesses().
Optimize the GOT and Stub relocations if the edge target address is in range.
Definition at line 92 of file x86_64.cpp.
References assert(), B, BranchPCRel32, BranchPCRel32ToPtrJumpStubBypassable, llvm::dbgs(), Delta32, E, G, getEdgeKindName(), llvm::orc::ExecutorAddr::getValue(), LLVM_DEBUG, PCRel32GOTLoadRelaxable, PCRel32GOTLoadREXRelaxable, Pointer32, PointerJumpStubContent, llvm::jitlink::printEdge(), and llvm::Error::success().
Referenced by llvm::jitlink::link_ELF_x86_64(), and llvm::jitlink::link_MachO_x86_64().
x86-64 null pointer content.
Definition at line 82 of file x86_64.cpp.
Referenced by createAnonymousPointer().
x86-64 pointer jump stub content.
Contains the instruction sequence for an indirect jump via an in-memory pointer: jmpq *ptr(rip)
Definition at line 85 of file x86_64.cpp.
Referenced by createPointerJumpStubBlock(), and optimizeGOTAndStubAccesses().
|
constexpr |
x86_64 pointer size.
Definition at line 586 of file x86_64.h.
Referenced by llvm::jitlink::link_ELF_x86_64().
x86-64 reentry trampoline.
Contains the instruction sequence for a trampoline that stores its return address on the stack and calls <reentry-symbol>: call <reentry-symbol>
Definition at line 88 of file x86_64.cpp.
Referenced by createAnonymousReentryTrampoline(), and createReentryTrampolineBlock().