summaryrefslogtreecommitdiff
path: root/elf/constants.lua
diff options
context:
space:
mode:
authorSunil Nimmagadda <sunil@nimmagadda.net>2026-10-23 22:43:44 +0530
committerSunil Nimmagadda <sunil@nimmagadda.net>2026-10-23 22:44:48 +0530
commit79f6b161f892f621a909ce1df99b3c680f3682a2 (patch)
tree7647bed7ccaa977f3cd28dcc8283ceef63265e57 /elf/constants.lua
parentd46e3e7761a133d58b6c77058473d9edc8a54744 (diff)
Refactor: Move to an elf module.
While here, define a elf.d.lua to help author type check configuration file.
Diffstat (limited to 'elf/constants.lua')
-rw-r--r--elf/constants.lua101
1 files changed, 101 insertions, 0 deletions
diff --git a/elf/constants.lua b/elf/constants.lua
new file mode 100644
index 0000000..b06b275
--- /dev/null
+++ b/elf/constants.lua
@@ -0,0 +1,101 @@
+local M = {}
+
+M.VERSION = 1
+
+---@enum Osabi
+M.Osabi = {
+ sysv = 0x00,
+ hpux = 0x01,
+ netbsd = 0x02,
+ linux = 0x03,
+ hurd = 0x04,
+ solaris = 0x06,
+ aix = 0x07,
+ irix = 0x08,
+ freebsd = 0x09,
+ tru64 = 0x0a,
+ modesto = 0x0b,
+ openbsd = 0x0c,
+ openvms = 0x0d,
+ nsk = 0x0e,
+ aros = 0x0f,
+ fenixos = 0x10,
+ cloudabi = 0x11,
+ openvos = 0x12,
+}
+
+---@enum Class
+M.Class = {
+ bit32 = 0x1,
+ bit64 = 0x2,
+}
+
+---@enum Endian
+M.Endian = {
+ little = 0x1,
+ big = 0x2,
+}
+
+---@enum Type
+M.Type = {
+ none = 0x00,
+ rel = 0x01,
+ exec = 0x02,
+ dyn = 0x03,
+ core = 0x04,
+ loos = 0xfe00,
+ hios = 0xfeff,
+ loproc = 0xff00,
+ hiproc = 0xffff,
+}
+
+---@enum Machine
+M.Machine = {
+ none = 0x00,
+ m32 = 0x01, -- AT&T WE 32100
+ sparc = 0x02, -- SPARC
+ i386 = 0x03, -- Intel 80386
+ m68k = 0x04, -- Motorola 68000 (M68k)
+ m88k = 0x05, -- Motorola 88000 (M88k)
+ mcu = 0x06, -- Intel MCU
+ i860 = 0x07, -- Intel 80860
+ mips = 0x08, -- MIPS
+
+ s370 = 0x09, -- IBM System/370
+ mipsrs3le = 0x0a, -- MIPS RS3000 Little Endian
+ parisc = 0x0f, -- Hewlett-Packard PA-RISC
+ vpp500 = 0x11, -- Fujitsu VPP500
+ sparc32 = 0x12, -- Enhanced instruction set SPARC
+ i960 = 0x13, -- Intel 80960
+ ppc = 0x14, -- PowerPC
+ ppc64 = 0x15, -- PowerPC (64-bit)
+ s390 = 0x16, -- IBM System/390
+ spu = 0x17, -- IBM SPC/SPU
+ v800 = 0x24, -- NEC V800
+ fr20 = 0x25, -- Fujitsu FR20
+ -- todo
+}
+
+---@enum SegmentType
+M.SegmentType = {
+ null = 0x00000000,
+ load = 0x00000001,
+ dynamic = 0x00000002,
+ interp = 0x00000003,
+ note = 0x00000004,
+ shlib = 0x00000005,
+ phdr = 0x00000006,
+ tls = 0x00000007,
+ loos = 0x60000000,
+ hios = 0x6FFFFFFF,
+ loproc = 0x70000000,
+ hiproc = 0x7FFFFFFF,
+}
+
+M.SegmentFlags = {
+ x = 0x1,
+ w = 0x2,
+ r = 0x4,
+}
+
+return M