diff options
Diffstat (limited to 'mkelf.lua')
| -rw-r--r-- | mkelf.lua | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -99,12 +99,18 @@ end ---@param sections Section[] ---@return string local function elf_pack(header, segments, sections) - local parts = { elf.header.pack(header) } - for _, sg in ipairs(segments) do - parts[#parts + 1] = elf.segment.pack(sg, header.data, header.class) + local ok, b = pcall(elf.header.pack, header) + if not ok then error(("header: %s"):format(b), 0) end + local parts = { b } + for i, sg in ipairs(segments) do + local sgok, sgb = pcall(elf.segment.pack, sg, header.data, header.class) + if not sgok then error(("segment #%d: %s"):format(i, sgb), 0) end + parts[#parts + 1] = sgb end - for _, sc in ipairs(sections) do - parts[#parts + 1] = elf.section.pack(sc, header.data, header.class) + for i, sc in ipairs(sections) do + local scok, scb = pcall(elf.section.pack, sc, header.data, header.class) + if not scok then error(("section #%d: %s"):format(i, scb), 0) end + parts[#parts + 1] = scb end return table.concat(parts) end |
