pub struct Relocation {
pub offset: usize,
pub size: u8,
pub label: Rc<str>,
pub kind: RelocKind,
pub addend: i64,
pub trailing_bytes: u8,
}Expand description
A relocation record for unresolved labels.
Fields§
§offset: usizeOffset within the instruction bytes where the relocation target is.
size: u8Size of the relocation field in bytes (1, 2, or 4).
label: Rc<str>The label name to resolve. Stored as Rc<str> so that cloning during
relocation propagation and linker resolution is a cheap refcount bump
instead of a heap allocation.
kind: RelocKindHow the linker patches the target address into the instruction bytes.
addend: i64The addend for the relocation (constant offset).
trailing_bytes: u8Number of instruction bytes that follow the relocation field.
For x86 RIP-relative relocations, the CPU computes EA = RIP + disp where
RIP = address of the byte AFTER the entire instruction. When a trailing
immediate follows the displacement, we need this to calculate the correct
RIP at link time: rip = reloc_addr + size + trailing_bytes.
Trait Implementations§
Source§impl Clone for Relocation
impl Clone for Relocation
Source§fn clone(&self) -> Relocation
fn clone(&self) -> Relocation
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more