pub enum Fragment {
Fixed {
bytes: FragmentBytes,
relocation: Option<Relocation>,
span: Span,
},
Align {
alignment: u32,
fill: u8,
max_skip: Option<u32>,
use_nop: bool,
span: Span,
},
Relaxable {
short_bytes: InstrBytes,
short_reloc_offset: usize,
short_relocation: Option<Relocation>,
long_bytes: InstrBytes,
long_relocation: Relocation,
is_long: bool,
span: Span,
},
Org {
target: u64,
fill: u8,
span: Span,
},
}Expand description
A fragment of assembled output.
The linker operates on an ordered list of fragments. During branch
relaxation the sizes of Fragment::Relaxable and Fragment::Align
fragments may change, but they only ever grow (monotonic), which
guarantees convergence.
Variants§
Fixed
Fixed-size bytes with optional relocation.
Fields
bytes: FragmentBytesThe raw assembled bytes (inline for instructions, heap for large data).
relocation: Option<Relocation>Optional relocation to apply to these bytes.
Align
Alignment padding — size depends on preceding layout.
When use_nop is true (x86/x86-64 code alignment with no explicit
fill byte), pad with Intel-recommended multi-byte NOP sequences
instead of repeating a single fill byte.
Fields
Relaxable
A relaxable branch instruction.
Starts in short form (rel8). If the linker determines the target is beyond ±127 bytes it promotes to the long form (rel32) and re-lays out. Promotion is irreversible (Szymanski monotonic growth).
Fields
short_bytes: InstrBytesShort-form bytes (e.g. [0xEB, 0x00] for JMP rel8).
short_relocation: Option<Relocation>Optional relocation for the short form. When Some, the linker
applies this relocation to short_bytes instead of raw byte-patching.
Used for RISC-V B-type branches.
long_bytes: InstrBytesLong-form bytes (e.g. [0xE9, 0,0,0,0] for JMP rel32).
long_relocation: RelocationRelocation for the long form (contains label, offset, etc.).
Org
Advance the location counter to an absolute address, padding with
fill bytes. If the target is behind the current position, an
error is raised during emission.