diff options
| -rw-r--r-- | mkelf.lua | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -75,14 +75,22 @@ local function setup_env(state) }) end +---@param fn string | nil +---@return Header, Segment[], Section[] local function loadconfig(fn) - local state = { header = nil, segments = {}, sections = {} } + local state = { + ---@type Header? + header = nil, + segments = {}, + sections = {}, + } local env = setup_env(state) local chunk, err = loadfile(fn, "t", env) if not chunk then die("%s", err) end -- TODO sandbox against malformed configs local ok, perr = pcall(chunk) if not ok then die("%s", perr) end + if not state.header then die("header missing") end return state.header, state.segments, state.sections end @@ -119,7 +127,6 @@ function M.main() i = i + 1 end local header, segments, sections = loadconfig(infn) - if not header then die("header missing") end -- 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 |
