Skip to content

Commit

Permalink
Merge pull request #8 from Jety567/main
Browse files Browse the repository at this point in the history
Added 32 bit support which is needed for unicorn.
  • Loading branch information
ckirsch authored Jun 17, 2024
2 parents 77c25b8 + 30b4b73 commit 41aea0f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub struct Program {
pub code: ProgramSegment<u8>,
pub data: ProgramSegment<u8>,
pub instruction_range: Range<u64>,
pub is64: bool,
}

impl Program {
Expand Down Expand Up @@ -81,9 +82,9 @@ where
}

fn extract_program(raw: &[u8], elf: &Elf) -> Result<Program, RiscuError> {
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",
));
}

Expand Down Expand Up @@ -192,6 +193,7 @@ fn extract_program(raw: &[u8], elf: &Elf) -> Result<Program, RiscuError> {
content: [data_segment.to_vec(), vec![0; data_padding]].concat(),
},
instruction_range,
is64: elf.is_64,
})
}

Expand Down

0 comments on commit 41aea0f

Please sign in to comment.