Skip to main content

RelocKind

Enum RelocKind 

Source
pub enum RelocKind {
Show 23 variants X86Relative, Absolute, ArmBranch24, ArmLdrLit, ArmAdr, ThumbBranch8, ThumbBranch11, ThumbBl, ThumbBranchW, ThumbCondBranchW, ThumbLdrLit8, Aarch64Jump26, Aarch64Branch19, Aarch64Branch14, Aarch64LdrLit19, Aarch64Adr21, Aarch64Adrp, Aarch64AdrpAddPair, RvJal20, RvBranch12, RvAuipc20, RvCBranch8, RvCJump11,
}
Expand description

How the linker should patch the relocation target into the instruction.

Variants§

§

X86Relative

x86 RIP-relative: raw i8/i32 displacement written at offset. trailing_bytes accounts for any immediate after the disp field.

§

Absolute

Absolute address written as raw LE bytes (1/2/4/8).

§

ArmBranch24

ARM32 B/BL: PC-relative offset >> 2 in bits 23:0 of the 32-bit word.

§

ArmLdrLit

ARM32 LDR literal (PC-relative): 12-bit offset in bits 11:0, U-bit in bit 23.

§

ArmAdr

ARM32 ADR (data-processing immediate): 8-bit value with 4-bit rotation in bits 11:0, ADD/SUB opcode in bits 24:21, U-sense via opcode (ADD=0x4, SUB=0x2).

§

ThumbBranch8

Thumb-2 conditional branch (16-bit): 8-bit signed offset >> 1 in bits 7:0. Range: ±256 bytes from PC+4.

§

ThumbBranch11

Thumb unconditional branch (16-bit): 11-bit signed offset >> 1 in bits 10:0. Range: ±2 KB from PC+4.

§

ThumbBl

Thumb-2 BL (32-bit): 25-bit offset across two halfwords. Range: ±16 MB.

§

ThumbBranchW

Thumb-2 B.W (32-bit wide unconditional branch): 24-bit offset. Range: ±16 MB.

§

ThumbCondBranchW

Thumb-2 B.cond.W (32-bit wide conditional branch): 20-bit offset. Range: ±1 MB.

§

ThumbLdrLit8

Thumb LDR Rt, [PC, #imm8×4]: 8-bit word-aligned PC-relative literal load. Range: 0–1020 bytes forward only. PC = (instr_addr + 4) & ~3.

§

Aarch64Jump26

AArch64 B/BL: PC-relative offset >> 2 in bits 25:0 of the 32-bit word.

§

Aarch64Branch19

AArch64 B.cond / CBZ / CBNZ: PC-relative offset >> 2 in bits 23:5.

§

Aarch64Branch14

AArch64 TBZ / TBNZ: PC-relative offset >> 2 in bits 18:5 (14-bit imm).

§

Aarch64LdrLit19

AArch64 LDR (literal): PC-relative offset >> 2 in bits 23:5.

§

Aarch64Adr21

AArch64 ADR: PC-relative offset with immhi (bits 23:5) and immlo (bits 30:29).

§

Aarch64Adrp

AArch64 ADRP: page-relative offset with immhi/immlo, target &= ~0xFFF.

§

Aarch64AdrpAddPair

AArch64 ADRP+ADD pair (8 bytes): ADR relaxation long form. The first word is ADRP (patched with page offset), the second word is ADD (patched with lo12 = target & 0xFFF).

§

RvJal20

RISC-V JAL: PC-relative offset in J-type immediate (bits 31:12), ±1MB range.

§

RvBranch12

RISC-V B-type branch: PC-relative offset in B-type immediate (bits 31:7), ±4KB range.

§

RvAuipc20

RISC-V AUIPC: upper 20 bits of PC-relative offset (bits 31:12).

§

RvCBranch8

RISC-V C-extension CB-type branch: 9-bit signed PC-relative offset (±256 B).

§

RvCJump11

RISC-V C-extension CJ-type jump: 12-bit signed PC-relative offset (±2 KB).

Trait Implementations§

Source§

impl Clone for RelocKind

Source§

fn clone(&self) -> RelocKind

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RelocKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for RelocKind

Source§

fn eq(&self, other: &RelocKind) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for RelocKind

Source§

impl Eq for RelocKind

Source§

impl StructuralPartialEq for RelocKind

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.