summaryrefslogtreecommitdiff
path: root/mkelf.lua
diff options
context:
space:
mode:
Diffstat (limited to 'mkelf.lua')
-rw-r--r--mkelf.lua7
1 files changed, 5 insertions, 2 deletions
diff --git a/mkelf.lua b/mkelf.lua
index 521b408..eb76d16 100644
--- a/mkelf.lua
+++ b/mkelf.lua
@@ -95,6 +95,10 @@ local Machine <const> = {
---@field shnum integer
---@field shstrndx integer
+local function efmt(endian)
+ return (endian == Endian.big) and ">" or "<"
+end
+
---@param hdr ElfHeader
---@nodiscard
local function ElfHeader_pack(hdr)
@@ -105,9 +109,8 @@ local function ElfHeader_pack(hdr)
hdr.ident_version,
hdr.osabi,
hdr.abiversion)
- local e = (hdr.data == Endian.big) and ">" or "<"
local sz = (hdr.class == Class.bit64) and "I8" or "I4"
- local h = string.pack(e .. "I2I2I4" ..
+ local h = string.pack(efmt(hdr.data) .. "I2I2I4" ..
sz .. sz .. sz ..
"I4I2I2I2I2I2I2",
hdr.type,