README

#machv/code_object

This package is the final reusable boundary between target emission and an embedding runtime. It stores copied machine-code bytes together with typed relocations, trap sites, safepoints, root locations, and target-neutral unwind directives.

build validates architecture-specific alignment, bounds, relocation kinds, known instruction encodings, and unwind state transitions before an object can escape. An unwind directive's offset is the code offset immediately after the prologue instruction that establishes the described state. Saved-register locations are relative to the canonical frame address.

This package deliberately does not encode platform unwind formats, register unwind data with the host, resolve runtime symbols, allocate executable memory, or apply relocations. Those operations belong to the embedding product.

#
CodeObjectVerifyError

pub suberror CodeObjectVerifyError {
EmptyCode
MisalignedCodeSize(size~ : Int)
InvalidRelocation(index~ : Int, message~ : String)
DuplicateRelocationOffset(offset~ : Int)
InvalidSourceSite(index~ : Int, offset~ : Int)
InvalidTrapSite(index~ : Int, offset~ : Int)
InvalidSafepointSite(index~ : Int, offset~ : Int)
InvalidRootLocation(safepoint~ : Int, root~ : Int)
InvalidStackMap(safepoint~ : Int)
InvalidUnwindDirective(index~ : Int, message~ : String)
} derive(Eq,
Debug
)

#
Architecture

pub(all) enum Architecture {
AArch64
X64
} derive(Eq,
Debug
)

#
RegisterBank

pub(all) enum RegisterBank {
Int
FpVector
} derive(Eq,
Debug
)

#
Relocation

pub struct Relocation {
offset : Int
kind : RelocationKind
target : RelocationTarget
addend : Int64
} derive(Eq,
Debug
)

#
Relocation::new

fn Relocation::new(offset : Int, kind : RelocationKind, target : RelocationTarget, addend? : Int64) -> Relocation

#
RelocationKind

pub(all) enum RelocationKind {
AArch64Call26
AArch64Jump26
AArch64Page21
AArch64PageOffset12
X64PcRelative32
Absolute64
} derive(Eq,
Debug
)

#
RootLocation

pub(all) enum RootLocation {
Register(RegisterBank, Int)
Stack(offset~ : Int, ty~ :
ValueType
)
} derive(Eq,
Debug
)

#
SourceSite

pub struct SourceSite {
offset : Int
source :
SourceLocation

} derive(Eq,
Debug
)

#
SourceSite::new

#
UnlinkedCodeObject

pub struct UnlinkedCodeObject {
// private fields
} derive(
Debug
)

#
UnlinkedCodeObject::architecture

#
UnlinkedCodeObject::code

fn UnlinkedCodeObject::code(self : UnlinkedCodeObject) -> Array[Byte]

#
UnlinkedCodeObject::relocations

#
UnlinkedCodeObject::safepoints

#
UnlinkedCodeObject::sources

#
UnlinkedCodeObject::traps

#
UnlinkedCodeObject::unwind

#
UnlinkedCodeObject::verify

#
UnwindDirective

pub struct UnwindDirective {
offset : Int
operation : UnwindOperation
} derive(Eq,
Debug
)

#
UnwindDirective::new

fn UnwindDirective::new(offset : Int, operation : UnwindOperation) -> UnwindDirective

#
UnwindOperation

pub(all) enum UnwindOperation {
StackAlloc(size~ : Int)
SetFramePointer(RegisterBank, Int, cfa_offset~ : Int)
SaveRegister(RegisterBank, Int, cfa_offset~ : Int)
} derive(Eq,
Debug
)

#
build

fn build(architecture : Architecture, code : Array[Byte], relocations? : Array[Relocation], sources? : Array[SourceSite], traps? : Array[TrapSite], safepoints? : Array[SafepointSite], unwind? : Array[UnwindDirective]) -> UnlinkedCodeObject raise CodeObjectVerifyError

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io