Skip to main content

javm_transpiler/
lib.rs

1//! RISC-V ELF to PVM2 transpiler.
2//!
3//! Converts RISC-V rv64em+C+Zbb+Zba+Zbs+Zicond+Zicclsm+custom-0 ELF binaries
4//! into PVM2 program blobs suitable for execution by the JAR PVM2
5//! engine (interpreter / x86 recompiler).
6
7pub mod elf;
8pub mod layout;
9pub mod linker;
10
11use thiserror::Error;
12
13#[derive(Error, Debug)]
14pub enum TranspileError {
15    #[error("ELF parse error: {0}")]
16    ElfParse(String),
17    #[error("unsupported RISC-V instruction at offset {offset:#x}: {detail}")]
18    UnsupportedInstruction { offset: usize, detail: String },
19    #[error("unsupported relocation: {0}")]
20    UnsupportedRelocation(String),
21    #[error("register mapping error: RISC-V register {0} has no PVM equivalent")]
22    RegisterMapping(u8),
23    #[error("code too large: {0} bytes")]
24    CodeTooLarge(usize),
25    #[error("invalid section: {0}")]
26    InvalidSection(String),
27}