Skip to content

Commit

Permalink
o1vm/ELF: rename parse_riscv32i in parse_riscv32
Browse files Browse the repository at this point in the history
The ELF loader should be the same either it is riscv32i or riscv32im. Therefore,
renaming into riscv32 (ISA + 32bits only support) makes sense.
  • Loading branch information
dannywillems committed Nov 19, 2024
1 parent fe054c8 commit 241a86b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions o1vm/src/elf_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use log::debug;
use std::{collections::HashMap, path::Path};

/// Parse an ELF file and return the parsed data as a structure that is expected
/// by the o1vm RISC-V 32i edition.
/// by the o1vm RISC-V 32 bits edition.
// FIXME: parametrize by an architecture. We should return a state depending on the
// architecture. In the meantime, we can have parse_riscv32i and parse_mips.
// FIXME: for now, we return a State structure, either for RISC-V 32i or MIPS.
// We should return a structure specifically built for the o1vm, and not tight
// to Cannon. It will be done in a future PR to avoid breaking the current code
// and have a huge diff.
pub fn parse_riscv32i(path: &Path) -> Result<State, String> {
pub fn parse_riscv32(path: &Path) -> Result<State, String> {
debug!("Start parsing the ELF file to load a RISC-V 32i compatible state");
let file_data = std::fs::read(path).expect("Could not read file.");
let slice = file_data.as_slice();
Expand Down
2 changes: 1 addition & 1 deletion o1vm/tests/test_elf_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn test_correctly_parsing_elf() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32i/fibonacci",
));
let state = o1vm::elf_loader::parse_riscv32i(&path).unwrap();
let state = o1vm::elf_loader::parse_riscv32(&path).unwrap();

// This is the output we get by running objdump -d fibonacci
assert_eq!(state.pc, 69932);
Expand Down
2 changes: 1 addition & 1 deletion o1vm/tests/test_riscv_elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn test_no_action() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32i/no-action",
));
let state = o1vm::elf_loader::parse_riscv32i(&path).unwrap();
let state = o1vm::elf_loader::parse_riscv32(&path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);
// This is the output we get by running objdump -d no-action
assert_eq!(witness.registers.current_instruction_pointer, 69844);
Expand Down

0 comments on commit 241a86b

Please sign in to comment.