diff options
| -rw-r--r-- | elf/test.lua | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/elf/test.lua b/elf/test.lua index a0f7a38..dda8f78 100644 --- a/elf/test.lua +++ b/elf/test.lua @@ -118,19 +118,37 @@ local function hex_to_bytes(hex) end test("header.pack 64_le_x86-64", function () - local header = { + local h = { class = ec.Class.bit64, data = ec.Endian.little, type = ec.Type.exec, machine = ec.Machine.x86_64, } local expected = hex_to_bytes(table.concat({ + -- "BBBBBBBBBxxxxxxx" "7f454c46020101000000000000000000", + -- "I2I2I4" "02003e0001000000", - "000000000000000040000000000000000000000000000000", - "00000000400038000000400000000000", + -- string.rep(fmt.word(hdr.class), 3), where I8 is selected + table.concat({ + "0000000000000000", -- entry + "4000000000000000", -- phoff + "0000000000000000", -- shoff + }), + -- "I4I2I2I2I2I2I2" + table.concat({ + "00000000", -- flags + "4000", -- ehsize + "3800", -- phentsize + "0000", -- phnum + "4000", -- shentsize + "0000", -- shnum + "0000", -- shstrndx + }) })) - assert(elf_header.pack(elf_header.normalize(header)) == expected, "mismatch") + local actual = elf_header.pack(elf_header.normalize(h)) + assert(#actual == 64, "invalid ELF64 header size") + assert(actual == expected, "mismatch") end) -- Test segment.lua |
