summaryrefslogtreecommitdiff
path: root/elf/fmt.lua
diff options
context:
space:
mode:
Diffstat (limited to 'elf/fmt.lua')
-rw-r--r--elf/fmt.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/elf/fmt.lua b/elf/fmt.lua
new file mode 100644
index 0000000..44498d4
--- /dev/null
+++ b/elf/fmt.lua
@@ -0,0 +1,17 @@
+local constants = require("elf.constants")
+
+local M = {}
+
+---@param endian Endian
+---@nodiscard
+function M.endian(endian)
+ return (endian == constants.Endian.big) and ">" or "<"
+end
+
+---@param class Class
+---@nodiscard
+function M.word(class)
+ return (class == constants.Class.bit64) and "I8" or "I4"
+end
+
+return M