Skip to main content

Linker

Struct Linker 

Source
pub struct Linker { /* private fields */ }
Expand description

Independent dynamic-label/fixup manager.

This type intentionally stores only label/fixup metadata and can manage multiple code writers via BlockId.

Implementations§

Source§

impl Linker

Source

pub fn new() -> Self

Creates an empty linker state.

Source

pub fn new_block(&mut self) -> BlockId

Allocates a new logical code block id.

Source

pub fn new_label(&mut self) -> DynamicLabel

Allocates a new dynamic label.

Source

pub fn bind( &mut self, block: BlockId, label: DynamicLabel, position: usize, ) -> Result<(), LinkError>

Binds a dynamic label to a concrete word position in one block.

§Errors

Returns LinkError::UnknownLabel if label was not allocated by this linker, or LinkError::LabelAlreadyBound if the label is already bound.

Source

pub fn add_fixup( &mut self, block: BlockId, at: usize, target: DynamicLabel, kind: BranchRelocKind, ) -> Result<(), LinkError>

Adds one pending relocation fixup for a dynamic label.

§Errors

Returns LinkError::UnknownLabel if target was not allocated by this linker.

Source

pub fn resolve(&self) -> Result<Vec<ResolvedPatch>, LinkError>

Resolves all pending fixups across every block.

§Errors

Returns LinkError::LabelUnbound for unresolved labels or LinkError::CrossBlockRelocationUnsupported for cross-block fixups.

Source

pub fn resolve_for_block( &self, block: BlockId, ) -> Result<Vec<ResolvedFixup>, LinkError>

Resolves pending fixups for one block.

§Errors

Returns LinkError when a label is missing, unbound, or cross-block.

Source

pub fn patch_writer( &self, block: BlockId, writer: &mut CodeWriter<'_>, ) -> Result<(), LinkPatchError>

Resolves and applies all fixups for one block onto writer.

§Errors

Returns LinkPatchError::Link when metadata resolution fails, or LinkPatchError::Assemble when in-place patching fails.

Trait Implementations§

Source§

impl Default for Linker

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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, 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.