From cc5e2ae695cfe199044ef614b2dfc1991095bcc0 Mon Sep 17 00:00:00 2001 From: Sunil Nimmagadda Date: Fri, 30 Oct 2026 11:35:52 +0530 Subject: Untangle segment vs segments. Let the elf module handle just a single segment/section while the wrapper does the iteration. --- elf/section.lua | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'elf/section.lua') diff --git a/elf/section.lua b/elf/section.lua index ca9953e..8f84b35 100644 --- a/elf/section.lua +++ b/elf/section.lua @@ -11,34 +11,36 @@ local fmt = require("elf.fmt") ---@field info? integer ---@field addralign? integer ---@field entsize? integer - ----@class Sections local M = {} ----@param sections Sections +function M.normalize(section) + -- TODO +end + +function M.validate(section) + --TODO +end + +---@param section Section ---@param endian Endian ---@return string ---@nodiscard -function M.pack(sections, endian, class) - local s = {} - for i, section in ipairs(sections) do - s[i] = string.pack(fmt.endian(endian) .. - "I4I4" .. - string.rep(fmt.word(class), 4) .. - "I4I4" .. - string.rep(fmt.word(class), 2), - section.name, - section.type, - section.flags, - section.addr, - section.offset, - section.size, - section.link, - section.info, - section.addralign, - section.entsize) - end - return table.concat(s) +function M.pack(section, endian, class) + return string.pack(fmt.endian(endian) .. + "I4I4" .. + string.rep(fmt.word(class), 4) .. + "I4I4" .. + string.rep(fmt.word(class), 2), + section.name, + section.type, + section.flags, + section.addr, + section.offset, + section.size, + section.link, + section.info, + section.addralign, + section.entsize) end return M -- cgit v1.3