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
impl Linker
Sourcepub fn new_label(&mut self) -> DynamicLabel
pub fn new_label(&mut self) -> DynamicLabel
Allocates a new dynamic label.
Sourcepub fn bind(
&mut self,
block: BlockId,
label: DynamicLabel,
position: usize,
) -> Result<(), LinkError>
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.
Sourcepub fn add_fixup(
&mut self,
block: BlockId,
at: usize,
target: DynamicLabel,
kind: BranchRelocKind,
) -> Result<(), LinkError>
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.
Sourcepub fn resolve(&self) -> Result<Vec<ResolvedPatch>, LinkError>
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.
Sourcepub fn resolve_for_block(
&self,
block: BlockId,
) -> Result<Vec<ResolvedFixup>, LinkError>
pub fn resolve_for_block( &self, block: BlockId, ) -> Result<Vec<ResolvedFixup>, LinkError>
Sourcepub fn patch_writer(
&self,
block: BlockId,
writer: &mut CodeWriter<'_>,
) -> Result<(), LinkPatchError>
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.