diff options
| author | Sunil Nimmagadda <sunil@nimmagadda.net> | 2026-11-08 22:17:00 +0530 |
|---|---|---|
| committer | Sunil Nimmagadda <sunil@nimmagadda.net> | 2026-11-08 22:31:05 +0530 |
| commit | df9370112ddce1995637c80c58024733a0a9c1ba (patch) | |
| tree | d9c4c684fd19d366d74b73f273a5cc8d5ca7b10f /elf/header.lua | |
| parent | 9bf8cf708ef6aca2e0c2e5107157545f15a96273 (diff) | |
Some header methods tests.
Use table.concat and try to to retain line order for quick visual
check between pack() and testcases.
Diffstat (limited to 'elf/header.lua')
| -rw-r--r-- | elf/header.lua | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/elf/header.lua b/elf/header.lua index 179e3bd..751ff9a 100644 --- a/elf/header.lua +++ b/elf/header.lua @@ -90,15 +90,17 @@ end ---@return string ---@nodiscard function M.pack(hdr) - return string.pack( - "BBBBBBBBBxxxxxxx" .. fmt.endian(hdr.data) .. "I2I2I4" - .. string.rep(fmt.word(hdr.class), 3) .. "I4I2I2I2I2I2I2", - hdr.magic[1], hdr.magic[2], hdr.magic[3], hdr.magic[4], hdr.class, + return string.pack(table.concat({ + "BBBBBBBBBxxxxxxx", + fmt.endian(hdr.data), + "I2I2I4", + string.rep(fmt.word(hdr.class), 3), + "I4I2I2I2I2I2I2", + }), hdr.magic[1], hdr.magic[2], hdr.magic[3], hdr.magic[4], hdr.class, hdr.data, hdr.ident_version, hdr.osabi, hdr.abiversion, hdr.type, hdr.machine, hdr.version, hdr.entry, hdr.phoff, hdr.shoff, hdr.flags, hdr.ehsize, hdr.phentsize, hdr.phnum, hdr.shentsize, hdr.shnum, - hdr.shstrndx - ) + hdr.shstrndx) end return M |
