Skip to content

Commit 6dfa9cf

Browse files
committed
feat: Allow unknown ELF machine types
1 parent 0068c8a commit 6dfa9cf

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/structures/elf.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,10 @@ pub fn parse_elf_header(elf_data: &[u8]) -> Result<ELFHeader, StructureError> {
241241
(219, "CSR Kalimba architecture family"),
242242
(220, "Zilog Z80"),
243243
(221, "Controls and Data Services VISIUMcore processor"),
244-
(222, "FTDI Chip FT32 high performance 32-bit RISC architecture"),
244+
(
245+
222,
246+
"FTDI Chip FT32 high performance 32-bit RISC architecture",
247+
),
245248
(223, "Moxie processor family"),
246249
(224, "AMD GPU architecture"),
247250
(243, "RISC-V"),
@@ -296,11 +299,14 @@ pub fn parse_elf_header(elf_data: &[u8]) -> Result<ELFHeader, StructureError> {
296299
// Sanity check the remaining ELF header fields
297300
if elf_info["version"] == EXPECTED_VERSION
298301
&& elf_types.contains_key(&elf_info["type"])
299-
&& elf_machines.contains_key(&elf_info["machine"])
300302
{
301303
// Set the ELF info fields
302304
elf_hdr_info.exe_type = elf_types[&elf_info["type"]].to_string();
303-
elf_hdr_info.machine = elf_machines[&elf_info["machine"]].to_string();
305+
elf_hdr_info.machine = elf_machines
306+
.get(&elf_info["machine"])
307+
// Use 'Unknown' as a fallback for the machine type
308+
.unwrap_or(&"Unknown")
309+
.to_string();
304310

305311
return Ok(elf_hdr_info);
306312
}

0 commit comments

Comments
 (0)