diff options
| -rw-r--r-- | elf/section.lua | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/elf/section.lua b/elf/section.lua index 8f84b35..801a1d8 100644 --- a/elf/section.lua +++ b/elf/section.lua @@ -14,13 +14,30 @@ local fmt = require("elf.fmt") local M = {} function M.normalize(section) - -- TODO + if type(section) ~= "table" then error("section must be a table", 3) end + if not section.name then error("name is required in section", 3) end + if not section.type then error("type is required in section", 3) end + if not section.flags then error("flags required in section", 3) end + + section.addr = section.addr or 0 + section.offset = section.offset or 0 + section.size = section.size or 0 + section.link = section.link or 0 + section.info = section.info or 0 + section.addralign = section.addralign or 0 + section.entsize = section.entsize or 0 end function M.validate(section) --TODO end +local function section_index(name) + -- TODO + + return 42 +end + ---@param section Section ---@param endian Endian ---@return string @@ -31,7 +48,7 @@ function M.pack(section, endian, class) string.rep(fmt.word(class), 4) .. "I4I4" .. string.rep(fmt.word(class), 2), - section.name, + section_index(section.name), section.type, section.flags, section.addr, |
