Skip to content

Commit

Permalink
wip: ELF file support
Browse files Browse the repository at this point in the history
  • Loading branch information
morganthomas committed Apr 4, 2024
1 parent cf05780 commit 57d16fa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion elf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ pub fn load_elf_object_file(file: Vec<u8>) -> Program {
let mut data: BTreeMap<u32, Word<u8>> = BTreeMap::new();
for (section_header, section_data) in data_sections {
for i in 0 .. (section_header.sh_size / 4) as usize {
data.insert(section_header.sh_addr.try_into().unwrap(),
data.insert(<u64 as TryInto<u32>>::try_into(section_header.sh_addr).unwrap()
+ <usize as TryInto<u32>>::try_into(i*4).unwrap(),
Word([section_data[i*4], section_data[i*4+1], section_data[i*4+2], section_data[i*4+3]]));
}
}
Expand Down

0 comments on commit 57d16fa

Please sign in to comment.