LLVM 20.0.0git
|
Classes | |
class | GOTTableManager |
Global Offset Table Builder. More... | |
class | PLTTableManager |
Procedure Linkage Table Builder. More... | |
Enumerations | |
enum | EdgeKind_aarch64 : Edge::Kind { Pointer64 = Edge::FirstRelocation , Pointer64Authenticated , Pointer32 , Delta64 , Delta32 , NegDelta64 , NegDelta32 , Branch26PCRel , TestAndBranch14PCRel , CondBranch19PCRel , MoveWide16 , LDRLiteral19 , ADRLiteral21 , Page21 , PageOffset12 , GotPageOffset15 , RequestGOTAndTransformToPage21 , RequestGOTAndTransformToPageOffset12 , RequestGOTAndTransformToPageOffset15 , RequestGOTAndTransformToDelta32 , RequestTLVPAndTransformToPage21 , RequestTLVPAndTransformToPageOffset12 , RequestTLSDescEntryAndTransformToPage21 , RequestTLSDescEntryAndTransformToPageOffset12 } |
Represents aarch64 fixups and other aarch64-specific edge kinds. More... | |
Functions | |
const char * | getEdgeKindName (Edge::Kind K) |
Returns a string name for the given aarch64 edge. | |
bool | isLoadStoreImm12 (uint32_t Instr) |
bool | isTestAndBranchImm14 (uint32_t Instr) |
bool | isCondBranchImm19 (uint32_t Instr) |
bool | isCompAndBranchImm19 (uint32_t Instr) |
bool | isADR (uint32_t Instr) |
bool | isLDRLiteral (uint32_t Instr) |
unsigned | getPageOffset12Shift (uint32_t Instr) |
bool | isMoveWideImm16 (uint32_t Instr) |
unsigned | getMoveWide16Shift (uint32_t Instr) |
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) |
const char * | getPointerSigningFunctionSectionName () |
Returns the name of the pointer signing function section. | |
Error | createEmptyPointerSigningFunction (LinkGraph &G) |
Creates a pointer signing function section, block, and symbol to reserve space for a signing function for this LinkGraph. | |
Error | lowerPointer64AuthEdgesToSigningFunction (LinkGraph &G) |
Given a LinkGraph containing Pointer64Authenticated edges, transform those edges to Pointer64 and add signing code to the pointer signing function (which must already have been created by the createEmptyPointerSigningFunction pass above). | |
template<typename AppendFtor > | |
static Error | writeMovRegRegSeq (AppendFtor &Append, uint64_t DstReg, uint64_t SrcReg) |
template<typename AppendFtor > | |
static Error | writeMovRegImm64Seq (AppendFtor &Append, uint64_t Reg, uint64_t Imm) |
template<typename AppendFtor > | |
static Error | writePACSignSeq (AppendFtor &Append, unsigned DstReg, orc::ExecutorAddr RawAddr, unsigned RawAddrReg, unsigned DiscriminatorReg, unsigned Key, uint64_t EncodedDiscriminator, bool AddressDiversify) |
template<typename AppendFtor > | |
static Error | writeStoreRegSeq (AppendFtor &Append, unsigned DstLocReg, unsigned SrcReg) |
Variables | |
constexpr uint64_t | PointerSize = 8 |
aarch64 pointer size. | |
const char | NullPointerContent [PointerSize] |
AArch64 null pointer content. | |
const char | PointerJumpStubContent [12] |
const char | ReentryTrampolineContent [8] |
AArch64 reentry trampoline. | |
Represents aarch64 fixups and other aarch64-specific edge kinds.
Enumerator | |
---|---|
Pointer64 | A plain 64-bit pointer value relocation. Fixup expression: Fixup <- Target + Addend : uint64 |
Pointer64Authenticated | An arm64e authenticated pointer relocation. The addend contains a 64-bit struct containing the authentication parameters: Addend encoding: int32_t addend; uint16_t diversityData; uint16_t hasAddressDiversity : 1; uint16_t key : 2; uint16_t zeroes : 12; uint16_t authenticated : 1; Note: This means that the addend cannot be interpreted as a plain offset prior to lowering. Authenticated pointer edges cannot be fixed up directly by JITLink as the signing keys are held in the executing process. They can be removed from the graph by a combination of the createEmptyPointerSigningFunction pass (post-prune) and the lowerPointer64AuthEdgesToSigningFunction pass (pre-fixup). Together these passes construct a signing function that will be run in the executing process to write the signed pointers to the fixup locations. Fixup expression: NONE Errors:
|
Pointer32 | A plain 32-bit pointer value relocation. Fixup expression: Fixup <- Target + Addend : uint32 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 : int64 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:
|
Branch26PCRel | A 26-bit PC-relative branch. Represents a PC-relative call or branch to a target within +/-128Mb. The target must be 32-bit aligned. Fixup expression: Fixup <- (Target - Fixup + Addend) >> 2 : int26 Notes: The '26' in the name refers to the number operand bits and follows the naming convention used by the corresponding ELF and MachO relocations. Since the low two bits must be zero (because of the 32-bit alignment of the target) the operand is effectively a signed 28-bit number. Errors:
|
TestAndBranch14PCRel | A 14-bit PC-relative test and branch. Represents a PC-relative test and branch to a target within +/-32Kb. The target must be 32-bit aligned. Fixup expression: Fixup <- (Target - Fixup + Addend) >> 2 : int14 Notes: The '14' in the name refers to the number operand bits and follows the naming convention used by the corresponding ELF relocation. Since the low two bits must be zero (because of the 32-bit alignment of the target) the operand is effectively a signed 16-bit number. Errors:
|
CondBranch19PCRel | A 19-bit PC-relative conditional branch. Represents a PC-relative conditional branch to a target within +/-1Mb. The target must be 32-bit aligned. Fixup expression: Fixup <- (Target - Fixup + Addend) >> 2 : int19 Notes: The '19' in the name refers to the number operand bits and follows the naming convention used by the corresponding ELF relocation. Since the low two bits must be zero (because of the 32-bit alignment of the target) the operand is effectively a signed 21-bit number. Errors:
|
MoveWide16 | A 16-bit slice of the target address (which slice depends on the instruction at the fixup location). Used to fix up MOVK/MOVN/MOVZ instructions. Fixup expression: Fixup <- (Target + Addend) >> Shift : uint16 where Shift is encoded in the instruction at the fixup location. |
LDRLiteral19 | The signed 21-bit delta from the fixup to the target. Typically used to load a pointers at a PC-relative offset of +/- 1Mb. The target must be 32-bit aligned. Fixup expression: Fixup <- (Target - Fixup + Addend) >> 2 : int19 Notes: The '19' in the name refers to the number operand bits and follows the naming convention used by the corresponding ELF relocation. Since the low two bits must be zero (because of the 32-bit alignment of the target) the operand is effectively a signed 21-bit number. Errors:
|
ADRLiteral21 | The signed 21-bit delta from the fixup to the target. Fixup expression: Fixup <- Target - Fixup + Addend : int21 Notes: For ADR fixups. Errors:
|
Page21 | The signed 21-bit delta from the fixup page to the page containing the target. Fixup expression: Fixup <- (((Target + Addend) & ~0xfff) - (Fixup & ~0xfff)) >> 12 : int21 Notes: For ADRP fixups. Errors:
|
PageOffset12 | The 12-bit (potentially shifted) offset of the target within its page. Typically used to fix up LDR immediates. Fixup expression: Fixup <- ((Target + Addend) >> Shift) & 0xfff : uint12 where Shift is encoded in the size field of the instruction. Errors:
|
GotPageOffset15 | The 15-bit offset of the GOT entry from the GOT table. Used for load/store instructions addressing a GOT entry. Fixup expression: Fixup <- ((Target + Addend - Page(GOT))) & 0x7fff) >> 3 : uint12 Errors:
|
RequestGOTAndTransformToPage21 | A GOT entry getter/constructor, transformed to Page21 pointing at the GOT entry for the original target. Indicates that this edge should be transformed into a Page21 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:
|
RequestGOTAndTransformToPageOffset12 | A GOT entry getter/constructor, transformed to Pageoffset12 pointing at the GOT entry for the original target. Indicates that this edge should be transformed into a PageOffset12 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:
|
RequestGOTAndTransformToPageOffset15 | A GOT entry getter/constructor, transformed to Pageoffset15 pointing at the GOT entry for the original target. Indicates that this edge should be transformed into a GotPageOffset15 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. Fixup expression: NONE 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:
|
RequestTLVPAndTransformToPage21 | A TLVP entry getter/constructor, transformed to Page21. Indicates that this edge should be transformed into a Page21 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:
|
RequestTLVPAndTransformToPageOffset12 | A TLVP entry getter/constructor, transformed to PageOffset12. Indicates that this edge should be transformed into a PageOffset12 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:
|
RequestTLSDescEntryAndTransformToPage21 | A TLSDesc entry getter/constructor, transformed to Page21. Indicates that this edge should be transformed into a Page21 targeting the TLSDesc entry for the edge's current target. A TLSDesc entry for the target should be created if one does not already exist. Fixup expression: NONE Errors:
|
RequestTLSDescEntryAndTransformToPageOffset12 | A TLSDesc entry getter/constructor, transformed to PageOffset12. Indicates that this edge should be transformed into a PageOffset12 targeting the TLSDesc entry for the edge's current target. A TLSDesc entry for the target should be created if one does not already exist. Fixup expression: NONE Errors:
|
|
inline |
Apply fixup expression for edge to block content.
Definition at line 495 of file aarch64.h.
References ADRLiteral21, assert(), B, Branch26PCRel, CondBranch19PCRel, Delta32, Delta64, E, G, llvm::jitlink::Symbol::getAddress(), getEdgeKindName(), getMoveWide16Shift(), getPageOffset12Shift(), llvm::orc::ExecutorAddr::getValue(), GotPageOffset15, isADR(), isCompAndBranchImm19(), isCondBranchImm19(), isLDRLiteral(), isMoveWideImm16(), isTestAndBranchImm14(), LDRLiteral19, llvm::jitlink::makeTargetOutOfRangeError(), MoveWide16, NegDelta32, NegDelta64, Page21, PageOffset12, Pointer32, Pointer64, llvm::Error::success(), and TestAndBranch14PCRel.
|
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 721 of file aarch64.h.
References B, G, NullPointerContent, and Pointer64.
Referenced by llvm::jitlink::aarch64::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 750 of file aarch64.h.
References createPointerJumpStubBlock(), G, and PointerJumpStubContent.
Referenced by llvm::jitlink::aarch64::PLTTableManager::createEntry().
|
inline |
Definition at line 776 of file aarch64.h.
References createReentryTrampolineBlock(), G, and ReentryTrampolineContent.
Referenced by llvm::orc::JITLinkReentryTrampolines::Create().
Creates a pointer signing function section, block, and symbol to reserve space for a signing function for this LinkGraph.
Clients should insert this pass in the post-prune phase, and add the paired lowerPointer64AuthEdgesToSigningFunction pass to the pre-fixup phase.
No new Pointer64Auth edges can be inserted into the graph between when this pass is run and when the pass below runs (since there will not be sufficient space reserved in the signing function to write the signing code for them).
Clients should insert this pass in the post-prune phase, and add the paired lowerPointer64AuthEdgesToSigningFunction pass to the pre-fixup phase.
Definition at line 211 of file aarch64.cpp.
References B, llvm::dbgs(), E, llvm::orc::Exec, llvm::orc::Finalize, llvm::formatv(), G, getPointerSigningFunctionSectionName(), LLVM_DEBUG, Pointer64Authenticated, llvm::orc::Read, and llvm::Error::success().
Referenced by llvm::jitlink::link_MachO_arm64().
|
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: 32-bit alignment-offset: 0 address: highest allowable: (~11U)
Definition at line 737 of file aarch64.h.
References B, G, Page21, PageOffset12, and PointerJumpStubContent.
Referenced by createAnonymousPointerJumpStub().
|
inline |
Create a block of N reentry trampolines.
Definition at line 767 of file aarch64.h.
References B, Branch26PCRel, G, and ReentryTrampolineContent.
Referenced by createAnonymousReentryTrampoline().
const char * llvm::jitlink::aarch64::getEdgeKindName | ( | Edge::Kind | K | ) |
Returns a string name for the given aarch64 edge.
For debugging purposes only
Definition at line 37 of file aarch64.cpp.
References ADRLiteral21, Branch26PCRel, CondBranch19PCRel, Delta32, Delta64, llvm::jitlink::getGenericEdgeKindName(), GotPageOffset15, LDRLiteral19, MoveWide16, NegDelta32, NegDelta64, Page21, PageOffset12, Pointer32, Pointer64, RequestGOTAndTransformToDelta32, RequestGOTAndTransformToPage21, RequestGOTAndTransformToPageOffset12, RequestGOTAndTransformToPageOffset15, RequestTLSDescEntryAndTransformToPage21, RequestTLSDescEntryAndTransformToPageOffset12, RequestTLVPAndTransformToPage21, RequestTLVPAndTransformToPageOffset12, and TestAndBranch14PCRel.
Referenced by applyFixup().
Definition at line 460 of file aarch64.h.
References isLoadStoreImm12().
Referenced by applyFixup().
Returns the name of the pointer signing function section.
Definition at line 205 of file aarch64.cpp.
Referenced by createEmptyPointerSigningFunction(), and lowerPointer64AuthEdgesToSigningFunction().
Definition at line 444 of file aarch64.h.
Referenced by applyFixup().
Definition at line 439 of file aarch64.h.
Referenced by applyFixup().
Definition at line 434 of file aarch64.h.
Referenced by applyFixup().
Definition at line 449 of file aarch64.h.
Referenced by applyFixup().
Definition at line 424 of file aarch64.h.
Referenced by getPageOffset12Shift().
Definition at line 476 of file aarch64.h.
Referenced by applyFixup(), and getMoveWide16Shift().
Definition at line 429 of file aarch64.h.
Referenced by applyFixup().
Given a LinkGraph containing Pointer64Authenticated edges, transform those edges to Pointer64 and add signing code to the pointer signing function (which must already have been created by the createEmptyPointerSigningFunction pass above).
Given a LinkGraph containing Pointer64Auth edges, transform those edges to Pointer64 and add code to sign the pointers in the executor.
This function will add a $__ptrauth_sign section with finalization-lifetime containing an anonymous function that will sign all pointers in the graph. An allocation action will be added to run this function during finalization.
Definition at line 265 of file aarch64.cpp.
References assert(), B, llvm::cantFail(), llvm::dbgs(), E, llvm::formatv(), G, getPointerSigningFunctionSectionName(), LLVM_DEBUG, Pointer64Authenticated, llvm::Error::success(), llvm::BinaryStreamWriter::writeInteger(), writeMovRegImm64Seq(), writePACSignSeq(), and writeStoreRegSeq().
Referenced by llvm::jitlink::link_MachO_arm64().
|
static |
Definition at line 111 of file aarch64.cpp.
References assert(), I, Reg, and llvm::Error::success().
Referenced by lowerPointer64AuthEdgesToSigningFunction(), and writePACSignSeq().
|
static |
Definition at line 92 of file aarch64.cpp.
References assert(), and llvm::Error::success().
Referenced by writePACSignSeq().
|
static |
Definition at line 144 of file aarch64.cpp.
References assert(), writeMovRegImm64Seq(), and writeMovRegRegSeq().
Referenced by lowerPointer64AuthEdgesToSigningFunction().
|
static |
Definition at line 189 of file aarch64.cpp.
References assert().
Referenced by lowerPointer64AuthEdgesToSigningFunction().
AArch64 null pointer content.
Definition at line 23 of file aarch64.cpp.
Referenced by createAnonymousPointer().
Definition at line 26 of file aarch64.cpp.
Referenced by createAnonymousPointerJumpStub(), and createPointerJumpStubBlock().
|
constexpr |
AArch64 reentry trampoline.
Contains the instruction sequence for a trampoline that stores its return address (and stack pointer) on the stack and calls the given reentry symbol: STP x29, x30, [sp, #-16]! BL <reentry-symbol>
Definition at line 32 of file aarch64.cpp.
Referenced by createAnonymousReentryTrampoline(), and createReentryTrampolineBlock().