aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorSunil Nimmagadda <sunil@nimmagadda.net>2026-11-05 23:25:40 +0530
committerSunil Nimmagadda <sunil@nimmagadda.net>2026-11-05 23:25:40 +0530
commit763930302205c61e4909dc429d61e33624d61d6b (patch)
treee5b134e786b38cc9566221b9ca33195e70821a87 /elf
parent6f83d9020a1788b0fa1d1b1fac658f2c8d704bd9 (diff)
Move all the validations to correct place.
Diffstat (limited to 'elf')
-rw-r--r--elf/header.lua14
-rw-r--r--elf/section.lua4
-rw-r--r--elf/segment.lua2
3 files changed, 0 insertions, 20 deletions
diff --git a/elf/header.lua b/elf/header.lua
index de939d9..179e3bd 100644
--- a/elf/header.lua
+++ b/elf/header.lua
@@ -50,20 +50,6 @@ local M = {}
---@param hdropts HeaderOptions
---@return Header
function M.normalize(hdropts)
- -- TODO drop these error() and return, let callers report.
- if not hdropts.class then error("class is required in header", 3) end
- if not hdropts.data then error("data is required in header", 3) end
- if not hdropts.type then error("type is required in header", 3) end
- if not hdropts.machine then error("machine is required in header", 3) end
-
- -- Can't pack without these values being valid.
- if hdropts.class ~= ec.Class.bit32 and hdropts.class ~= ec.Class.bit64 then
- error("class must be Class.bit32 or Class.bit64 in header", 3)
- end
- if hdropts.data ~= ec.Endian.little and hdropts.data ~= ec.Endian.big then
- error("data must be Endian.little or Endian.big in header", 3)
- end
-
local phoff, ehsize, phentsize, shentsize
if hdropts.class == ec.Class.bit32 then
phoff = hdropts.phoff or 0x34
diff --git a/elf/section.lua b/elf/section.lua
index 7849d48..ed625c4 100644
--- a/elf/section.lua
+++ b/elf/section.lua
@@ -31,10 +31,6 @@ local M = {}
---@param secopts SectionOptions
---@return Section
function M.normalize(secopts)
- if not secopts.name then error("name is required in section", 3) end
- if not secopts.type then error("type is required in section", 3) end
- if not secopts.flags then error("flags required in section", 3) end
-
return {
name = secopts.name,
type = secopts.type,
diff --git a/elf/segment.lua b/elf/segment.lua
index 89d0c47..555cc54 100644
--- a/elf/segment.lua
+++ b/elf/segment.lua
@@ -30,8 +30,6 @@ local M = {}
---@param segopts SegmentOptions
---@return Segment
function M.normalize(segopts)
- if not segopts.type then error("type is required in segment", 3) end
-
return {
type = segopts.type,
flags = segopts.flags or 0,