diff options
Diffstat (limited to 'mkelf.lua')
| -rw-r--r-- | mkelf.lua | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -86,7 +86,9 @@ local function loadconfig(fn) return state.header, state.segments, state.sections end -local function main() +local M = {} + +function M.main() local outfn = "a.out" local infn local i = 1 @@ -106,8 +108,8 @@ local function main() -- TODO check against headerOptions not normalized header. if header.phnum == 0 then header.phnum = #segments end if header.shnum == 0 then header.shnum = #sections end - local out <close> = io.open(outfn, "wb") - if out == nil then die("failed to open %s", outfn) end + local out <close>, err = io.open(outfn, "wb") + if out == nil then die("failed to open: %s", outfn, err) end out:write(elf.header.pack(header)) for _, segment in ipairs(segments) do out:write(elf.segment.pack(segment, header.data, header.class)) @@ -117,4 +119,4 @@ local function main() end end -main() +return M |
