diff options
| author | Sunil Nimmagadda <sunil@nimmagadda.net> | 2026-11-04 21:16:40 +0530 |
|---|---|---|
| committer | Sunil Nimmagadda <sunil@nimmagadda.net> | 2026-11-04 21:16:40 +0530 |
| commit | be6b03a9cfa83535bb258f554aaf237fdb623bf1 (patch) | |
| tree | 83770b5faf863a72f847983a3048ea662efd44cd /elf/header.lua | |
| parent | 85f772997fae437faa8c3313a9296e6deca2d3db (diff) | |
Honor these user specified header fields.
Diffstat (limited to 'elf/header.lua')
| -rw-r--r-- | elf/header.lua | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/elf/header.lua b/elf/header.lua index ca50391..de939d9 100644 --- a/elf/header.lua +++ b/elf/header.lua @@ -64,6 +64,19 @@ function M.normalize(hdropts) 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 + ehsize = hdropts.ehsize or 0x34 + phentsize = hdropts.phentsize or 0x20 + shentsize = hdropts.shentsize or 0x28 + else + phoff = hdropts.phoff or 0x40 + ehsize = hdropts.ehsize or 0x40 + phentsize = hdropts.phentsize or 0x38 + shentsize = hdropts.shentsize or 0x40 + end + return { magic = hdropts.magic or { 0x7f, 0x45, 0x4c, 0x46 }, class = hdropts.class, @@ -80,10 +93,10 @@ function M.normalize(hdropts) phnum = hdropts.phnum or 0, shnum = hdropts.shnum or 0, shstrndx = hdropts.shstrndx or 0, - phoff = (hdropts.class == ec.Class.bit32) and 0x34 or 0x40, - ehsize = (hdropts.class == ec.Class.bit32) and 0x34 or 0x40, - phentsize = (hdropts.class == ec.Class.bit32) and 0x20 or 0x38, - shentsize = (hdropts.class == ec.Class.bit32) and 0x28 or 0x40, + phoff = phoff, + ehsize = ehsize, + phentsize = phentsize, + shentsize = shentsize, } end |
