aboutsummaryrefslogtreecommitdiff
path: root/elf/header.lua
diff options
context:
space:
mode:
Diffstat (limited to 'elf/header.lua')
-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