aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorSunil Nimmagadda <sunil@nimmagadda.net>2026-11-09 12:30:33 +0530
committerSunil Nimmagadda <sunil@nimmagadda.net>2026-11-09 12:30:33 +0530
commit93b82c4ff7924594a708993f609fc4700c5c428f (patch)
treeca13975166f223de1d8ea9488910fa3132028513 /elf
parentb56fa87e13a9a97c77f035e4ae1934b52560acfb (diff)
Do a flat table.concat.
Diffstat (limited to 'elf')
-rw-r--r--elf/test.lua138
1 files changed, 65 insertions, 73 deletions
diff --git a/elf/test.lua b/elf/test.lua
index edd5f7d..9da65e9 100644
--- a/elf/test.lua
+++ b/elf/test.lua
@@ -125,27 +125,23 @@ test("header.pack 64_le_x86-64", function ()
machine = ec.Machine.x86_64,
}
local expected = hex_to_bytes(table.concat({
- -- "BBBBBBBBBxxxxxxx"
- "7f454c46020101000000000000000000",
- -- "I2I2I4"
- "02003e0001000000",
- -- string.rep(fmt.word(hdr.class), 3), where I8 is selected
- table.concat({
+ -- "BBBBBBBBBxxxxxxx"
+ "7f454c46020101000000000000000000",
+ -- "I2I2I4"
+ "02003e0001000000",
+ -- string.rep(fmt.word(hdr.class), 3), where I8 is selected
"0000000000000000", -- entry
"4000000000000000", -- phoff
"0000000000000000", -- shoff
- }),
- -- "I4I2I2I2I2I2I2"
- table.concat({
- "00000000", -- flags
- "4000", -- ehsize
- "3800", -- phentsize
- "0000", -- phnum
- "4000", -- shentsize
- "0000", -- shnum
- "0000", -- shstrndx
- })
- }))
+ -- "I4I2I2I2I2I2I2"
+ "00000000", -- flags
+ "4000", -- ehsize
+ "3800", -- phentsize
+ "0000", -- phnum
+ "4000", -- shentsize
+ "0000", -- shnum
+ "0000" -- shstrndx
+ }))
local actual = elf_header.pack(elf_header.normalize(h))
assert(#actual == 64, "invalid ELF64 header size")
assert(actual == expected, "mismatch")
@@ -169,27 +165,23 @@ test("header.pack 32_le_i386", function ()
shstrndx = 0x3e3f,
}
local expected = hex_to_bytes(table.concat({
- -- "BBBBBBBBBxxxxxxx"
- "7f454c46010101000000000000000000",
- -- "I2I2I4"
- "0200030001000000",
- -- string.rep(fmt.word(hdr.class), 3), where I4 is selected
- table.concat({
- "04030201", -- entry
- "14131211", -- phoff
- "24232221", -- shoff
- }),
- -- "I4I2I2I2I2I2I2"
- table.concat({
- "34333231", -- flags
- "3534", -- ehsize
- "3736", -- phentsize
- "3938", -- phnum
- "3b3a", -- shentsize
- "3d3c", -- shnum
- "3f3e", -- shstrndx
- }),
- }))
+ -- "BBBBBBBBBxxxxxxx"
+ "7f454c46010101000000000000000000",
+ -- "I2I2I4"
+ "0200030001000000",
+ -- string.rep(fmt.word(hdr.class), 3), where I4 is selected
+ "04030201", -- entry
+ "14131211", -- phoff
+ "24232221", -- shoff
+ -- "I4I2I2I2I2I2I2"
+ "34333231", -- flags
+ "3534", -- ehsize
+ "3736", -- phentsize
+ "3938", -- phnum
+ "3b3a", -- shentsize
+ "3d3c", -- shnum
+ "3f3e" -- shstrndx
+ }))
local actual = elf_header.pack(elf_header.normalize(header))
assert(#actual == 52, "invalid ELF32 header size")
assert(actual == expected, "mismatch")
@@ -213,23 +205,23 @@ test("header.pack 32_be_i386", function ()
shstrndx = 0x3e3f,
}
local expected = hex_to_bytes(table.concat({
- -- "BBBBBBBBBxxxxxxx"
- "7f454c46010201000000000000000000",
- -- "I2I2I4"
- "0002000300000001",
- -- string.rep(fmt.word(hdr.class), 3), where I4 is selected
- "01020304", -- entry
- "11121314", -- phoff
- "21222324", -- shoff
- -- "I4I2I2I2I2I2I2"
- "31323334", -- flags
- "3435", -- ehsize
- "3637", -- phentsize
- "3839", -- phnum
- "3a3b", -- shentsize
- "3c3d", -- shnum
- "3e3f", -- shstrndx
- }))
+ -- "BBBBBBBBBxxxxxxx"
+ "7f454c46010201000000000000000000",
+ -- "I2I2I4"
+ "0002000300000001",
+ -- string.rep(fmt.word(hdr.class), 3), where I4 is selected
+ "01020304", -- entry
+ "11121314", -- phoff
+ "21222324", -- shoff
+ -- "I4I2I2I2I2I2I2"
+ "31323334", -- flags
+ "3435", -- ehsize
+ "3637", -- phentsize
+ "3839", -- phnum
+ "3a3b", -- shentsize
+ "3c3d", -- shnum
+ "3e3f" -- shstrndx
+ }))
local actual = elf_header.pack(elf_header.normalize(header))
assert(#actual == 52, "invalid ELF32 header size")
assert(actual == expected, "mismatch")
@@ -253,23 +245,23 @@ test("header.pack 64_be_x86-64", function ()
shstrndx = 0x3e3f,
}
local expected = hex_to_bytes(table.concat({
- -- "BBBBBBBBBxxxxxxx"
- "7f454c46020201000000000000000000",
- -- "I2I2I4"
- "0002003e00000001",
- -- string.rep(fmt.word(hdr.class), 3), where I8 is selected
- "0102030405060708",
- "1112131415161718",
- "2122232425262728",
- -- "I4I2I2I2I2I2I2"
- "31323334", -- flags
- "3435", -- ehsize
- "3637", -- phentsize
- "3839", -- phnum
- "3a3b", -- shentsize
- "3c3d", -- shnum
- "3e3f", -- shstrndx
- }))
+ -- "BBBBBBBBBxxxxxxx"
+ "7f454c46020201000000000000000000",
+ -- "I2I2I4"
+ "0002003e00000001",
+ -- string.rep(fmt.word(hdr.class), 3), where I8 is selected
+ "0102030405060708",
+ "1112131415161718",
+ "2122232425262728",
+ -- "I4I2I2I2I2I2I2"
+ "31323334", -- flags
+ "3435", -- ehsize
+ "3637", -- phentsize
+ "3839", -- phnum
+ "3a3b", -- shentsize
+ "3c3d", -- shnum
+ "3e3f" -- shstrndx
+ }))
local actual = elf_header.pack(elf_header.normalize(header))
assert(#actual == 64, "invalid ELF64 header size")
assert(actual == expected, "mismatch")