From 30b4b736ad7fc84d2b35d734f2fde9737a387415 Mon Sep 17 00:00:00 2001 From: Patrick Weber Date: Tue, 13 Feb 2024 13:06:21 +0100 Subject: [PATCH] Added 32 bit support which is needed for unicorn. --- src/decode.rs | 1 + src/elf.rs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/decode.rs b/src/decode.rs index dcfa7d1..a627b2b 100644 --- a/src/decode.rs +++ b/src/decode.rs @@ -21,6 +21,7 @@ use thiserror::Error; pub const INSTRUCTION_SIZE: usize = 4; pub const WORD_SIZE: usize = 8; +pub const WORD_SIZE32BIT: usize = 4; #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Error)] pub enum DecodingError { diff --git a/src/elf.rs b/src/elf.rs index dc9eb50..6484dc5 100644 --- a/src/elf.rs +++ b/src/elf.rs @@ -21,6 +21,7 @@ pub struct Program { pub code: ProgramSegment, pub data: ProgramSegment, pub instruction_range: Range, + pub is64: bool, } impl Program { @@ -81,9 +82,9 @@ where } fn extract_program(raw: &[u8], elf: &Elf) -> Result { - if elf.is_lib || !elf.is_64 || !elf.little_endian { + if elf.is_lib || !elf.little_endian { return Err(RiscuError::InvalidRiscu( - "has to be an executable, 64bit, static, little endian binary", + "has to be an executable, little endian binary", )); } @@ -192,6 +193,7 @@ fn extract_program(raw: &[u8], elf: &Elf) -> Result { content: [data_segment.to_vec(), vec![0; data_padding]].concat(), }, instruction_range, + is64: elf.is_64, }) }