From f6cbd11364883d765a24245f119dfa6de716c068 Mon Sep 17 00:00:00 2001 From: Lyssia Seiden Date: Sun, 16 Nov 2025 16:58:09 -0800 Subject: [PATCH 1/2] remove bugged ISA checks from sailsim-riscv.cpp --- lib/src/sailsim_riscv.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/lib/src/sailsim_riscv.cpp b/lib/src/sailsim_riscv.cpp index 6fc16a3..6ca5352 100644 --- a/lib/src/sailsim_riscv.cpp +++ b/lib/src/sailsim_riscv.cpp @@ -106,17 +106,9 @@ sailsim_isa_t sailsim_detect_elf_isa(const char* elf_path) { } try { - ELF elf = ELF::open(elf_path); - ISA elf_isa = elf.isa(); - - switch (elf_isa) { - case ISA::RISCV: - return SAILSIM_ISA_RISCV; - case ISA::ARM: - return SAILSIM_ISA_ARM; - default: - return SAILSIM_ISA_UNKNOWN; - } + // this throws if the elf isnt RISC-V + ELF _elf = ELF::open(elf_path); + return SAILSIM_ISA_RISCV; } catch (const std::exception& e) { return SAILSIM_ISA_UNKNOWN; } @@ -205,15 +197,9 @@ bool sailsim_load_elf(sailsim_context_t* ctx, const char* elf_path) { try { // Load ELF file using ELF class from elf_loader.h + // Throws if elf is not RISC-V ELF elf = ELF::open(elf_path); - // Validate this is a RISC-V ELF file - ISA elf_isa = elf.isa(); - if (elf_isa != ISA::RISCV) { - ctx->last_error = "ELF file is not RISC-V (this library only supports RISC-V)"; - return false; - } - // Load segments into memory using RISC-V write_mem elf.load([](uint64_t addr, const uint8_t* data, uint64_t len) { for (uint64_t i = 0; i < len; i++) { From d239b5a97d8ab65ceac6f3f86bb3fe387767a515 Mon Sep 17 00:00:00 2001 From: Lyssia Seiden Date: Mon, 17 Nov 2025 15:43:44 -0800 Subject: [PATCH 2/2] fix formatting --- lib/src/sailsim_riscv.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/sailsim_riscv.cpp b/lib/src/sailsim_riscv.cpp index 6ca5352..bf86f2b 100644 --- a/lib/src/sailsim_riscv.cpp +++ b/lib/src/sailsim_riscv.cpp @@ -106,7 +106,7 @@ sailsim_isa_t sailsim_detect_elf_isa(const char* elf_path) { } try { - // this throws if the elf isnt RISC-V + // throws if the elf isnt RISC-V ELF _elf = ELF::open(elf_path); return SAILSIM_ISA_RISCV; } catch (const std::exception& e) { @@ -197,7 +197,7 @@ bool sailsim_load_elf(sailsim_context_t* ctx, const char* elf_path) { try { // Load ELF file using ELF class from elf_loader.h - // Throws if elf is not RISC-V + // throws if the elf isnt RISC-V ELF elf = ELF::open(elf_path); // Load segments into memory using RISC-V write_mem