libloong - Rust Bindings
Rust bindings for the libloong LoongArch emulator.
Quick Start
Add to your Cargo.toml:
[]
= "0.1"
Example: Running a LoongArch ELF
use Machine;
use fs;
Calling Guest Functions
// Call by name and get integer return value
machine.vmcall?;
let result = machine.return_value;
println!;
// Call by address
let func_addr = machine.address_of;
machine.vmcall?;
let result = machine.return_value;
// For functions returning floats:
machine.vmcall?;
let result_f32 = machine.return_value_f32;
let result_f64 = machine.return_value_f64;
Building
Requirements:
- CMake 3.15+
- C++20 compiler (GCC 14+ or Clang 18+)
- Rust 1.70+
The build script automatically builds the C++ library using CMake.
Examples
Run the examples (test programs are located in ../tests/programs/):
Building LoongArch Programs
The -Wl,-Ttext-segment=0x200000 flag is required for the flat memory model.
Features
binary-translation (enabled by default)
Enables JIT compilation for better performance. This feature requires network access during build phase (although only once).
To disable:
[]
= { = "0.1", = false }