aboutsummaryrefslogtreecommitdiff
path: root/mkelf.lua
diff options
context:
space:
mode:
Diffstat (limited to 'mkelf.lua')
-rw-r--r--mkelf.lua28
1 files changed, 25 insertions, 3 deletions
diff --git a/mkelf.lua b/mkelf.lua
index f4dd67d..51927d0 100644
--- a/mkelf.lua
+++ b/mkelf.lua
@@ -15,11 +15,21 @@ local function setup_header(state)
if type(t) ~= "table" then
error("header must be a table", 2)
end
- if state.hopts == nil then
- state.hopts = t
- else
+ if state.hopts ~= nil then
error("multiple headers are disallowed", 2)
end
+ if not t.class then error("class is required in header", 2) end
+ if not t.data then error("data is required in header", 2) end
+ if not t.type then error("type is required in header", 2) end
+ if not t.machine then error("machine is required in header", 2) end
+ -- Can't pack without these values being valid.
+ if t.class ~= ec.Class.bit32 and t.class ~= ec.Class.bit64 then
+ error("class must be Class.bit32 or Class.bit64 in header", 2)
+ end
+ if t.data ~= ec.Endian.little and t.data ~= ec.Endian.big then
+ error("data must be Endian.little or Endian.big in header", 2)
+ end
+ state.hopts = t
end
end
@@ -32,6 +42,9 @@ local function setup_segments(state)
if type(s) ~= "table" then
error(("segment #%d must be a table"):format(i), 2)
end
+ if not s.type then
+ error(("type is required in segment #%d"):format(i), 2)
+ end
table.insert(state.sgopts, s)
end
end
@@ -46,6 +59,15 @@ local function setup_sections(state)
if type(s) ~= "table" then
error(("section #%d must be a table"):format(i), 2)
end
+ if not s.name then
+ error(("name is required in section"):format(i), 2)
+ end
+ if not s.type then
+ error(("type is required in section"):format(i), 2)
+ end
+ if not s.flags then
+ error(("flags required in section"):format(i), 2)
+ end
table.insert(state.scopts, s)
end
end