Skip to main content

Module registry

Module registry 

Source
Expand description

Open registry of ArchCodec factories.

Arch crates register a factory function at process startup (typically from <crate>::register()); resolution happens at the entry of every compile / decompile pipeline call that needs to encode arch-specific instructions.

The registry takes raw (arch_name, e_machine) pairs rather than an AST type — that’s how this crate stays independent of ud-ast (which would otherwise cause a cycle through ud-arch-x86). Callers (ud-translate) extract the pair from a parsed ud_ast::Module and feed it in.

Functions§

factory_count
Number of factories currently registered. Cheap; intended for tests and diagnostics.
for_arch
Resolve the codec for an (arch_name, e_machine) pair. Returns the first matching factory’s result, or ArchError::UnknownArch if nothing claims it.
register
Register a codec factory. Each arch crate exposes a register() pub fn that calls this once.

Type Aliases§

CodecFactory
A codec factory: inspects an (arch_name, e_machine) pair and returns a codec instance if it recognises the arch, else None. arch_name is the lowercase friendly arch identifier from the parsed @module block ("x86_64", "bpf", etc.); e_machine is the numeric ELF machine type (EM_BPF = 247, EM_SBF = 263, …) — useful for sub-arch dispatch (e.g. distinguishing Linux eBPF from Solana SBF when both carry arch = "bpf").