diff --git a/elf/elf.odin b/elf/elf.odin
@@ -22,8 +22,11 @@ ET_DYN :: 3
ET_CORE :: 4
EM_386 :: 3
-EM_X86_64 :: 62
+EM_MIPS :: 8
+EM_PPC :: 20
+EM_PPC64 :: 21
EM_ARM :: 40
+EM_X86_64 :: 62
EM_AARCH64 :: 183
EM_RISCV :: 243
diff --git a/elf/elf_test.odin b/elf/elf_test.odin
@@ -183,14 +183,23 @@ test_parse_header_machine_riscv :: proc(t: ^testing.T) {
data := make([]u8, 64)
defer delete(data)
make_elf64_header(data, ET_EXEC, EM_RISCV)
-
+
header, err := parse_header(data)
-
+
testing.expect(t, err == "")
testing.expect(t, header.machine == EM_RISCV, "machine should be RISC-V")
}
@(test)
+test_machine_str_covers_firmware_arches :: proc(t: ^testing.T) {
+ testing.expect_value(t, machine_to_str(EM_MIPS), "MIPS")
+ testing.expect_value(t, machine_to_str(EM_PPC), "PowerPC")
+ testing.expect_value(t, machine_to_str(EM_PPC64), "PowerPC64")
+ testing.expect_value(t, machine_to_str(EM_ARM), "ARM")
+ testing.expect_value(t, machine_to_str(EM_AARCH64), "AArch64")
+}
+
+@(test)
test_read_u16_le_basic :: proc(t: ^testing.T) {
data := []u8{0x01, 0x02}
diff --git a/elf/printer.odin b/elf/printer.odin
@@ -130,8 +130,11 @@ type_to_str :: proc(t: u16) -> string {
machine_to_str :: proc(m: u16) -> string {
switch m {
case EM_386: return "x86 (i386)"
- case EM_X86_64: return "x86-64"
+ case EM_MIPS: return "MIPS"
+ case EM_PPC: return "PowerPC"
+ case EM_PPC64: return "PowerPC64"
case EM_ARM: return "ARM"
+ case EM_X86_64: return "x86-64"
case EM_AARCH64: return "AArch64"
case EM_RISCV: return "RISC-V"
}
| | |