diff options
| author | Sunil Nimmagadda <sunil@nimmagadda.net> | 2026-10-27 09:55:23 +0530 |
|---|---|---|
| committer | Sunil Nimmagadda <sunil@nimmagadda.net> | 2026-10-27 10:00:50 +0530 |
| commit | 6fc839183d88a1529224a6a326dc2098e0229550 (patch) | |
| tree | 8fb7ef12aee03083e2e24ecb3ada2b09cff89593 /elf | |
| parent | 7666b630b49861ef9d533686ac364929af136a58 (diff) | |
Make sure all fields are accounted.
By the time normalize() finishes there shouldn't be a need to check
for individual fields defined or not.
Diffstat (limited to 'elf')
| -rw-r--r-- | elf/header.lua | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/elf/header.lua b/elf/header.lua index 3efce7b..4ea8434 100644 --- a/elf/header.lua +++ b/elf/header.lua @@ -26,6 +26,12 @@ local ec = require("elf.constants") local M = {} function M.normalize(hdr) + assert(type(hdr) == "table", "header must be a table") + assert(hdr.class ~= nil, "missing header field: class") + assert(hdr.data ~= nil, "missing header field: data") + assert(hdr.type ~= nil, "missing header field: type") + assert(hdr.machine ~= nil, "missing header field: machine") + hdr.magic = hdr.magic or { 0x7f, 0x45, 0x4c, 0x46 } hdr.ident_version = hdr.ident_version or ec.VERSION hdr.osabi = hdr.osabi or ec.Osabi.sysv |
