From 540d161bcb526efef2152f8e791a02e0361f2aae Mon Sep 17 00:00:00 2001 From: Sunil Nimmagadda Date: Fri, 30 Oct 2026 14:41:56 +0530 Subject: header: Set some correct defaults. --- elf/header.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'elf/header.lua') diff --git a/elf/header.lua b/elf/header.lua index c0b8eab..a5fc78a 100644 --- a/elf/header.lua +++ b/elf/header.lua @@ -37,13 +37,15 @@ function M.normalize(hdr) hdr.abiversion = hdr.abiversion or 0 hdr.version = hdr.version or ec.VERSION hdr.entry = hdr.entry or 0 - hdr.phoff = hdr.phoff or 0 + hdr.phoff = hdr.phoff or ((hdr.class == ec.Class.bit32) and 0x34 or 0x40) hdr.shoff = hdr.shoff or 0 hdr.flags = hdr.flags or 0 hdr.ehsize = hdr.ehsize or ((hdr.class == ec.Class.bit32) and 0x34 or 0x40) - hdr.phentsize = hdr.phentsize or 0 + hdr.phentsize = hdr.phentsize or + ((hdr.class == ec.Class.bit32) and 0x20 or 0x38) hdr.phnum = hdr.phnum or 0 - hdr.shentsize = hdr.shentsize or 0 + hdr.shentsize = hdr.shentsize or + ((hdr.class == ec.Class.bit32) and 0x28 or 0x40) hdr.shnum = hdr.shnum or 0 hdr.shstrndx = hdr.shstrndx or 0 end -- cgit v1.3