aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorSunil Nimmagadda <sunil@nimmagadda.net>2026-10-30 14:41:56 +0530
committerSunil Nimmagadda <sunil@nimmagadda.net>2026-10-30 14:50:21 +0530
commit540d161bcb526efef2152f8e791a02e0361f2aae (patch)
treeb8769e66496039235707973ea213e4442f12a9e6 /elf
parentd7520a75f01194a22f433c682e99b4482808f443 (diff)
header: Set some correct defaults.
Diffstat (limited to 'elf')
-rw-r--r--elf/header.lua8
1 files changed, 5 insertions, 3 deletions
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