From 6fc839183d88a1529224a6a326dc2098e0229550 Mon Sep 17 00:00:00 2001 From: Sunil Nimmagadda Date: Tue, 27 Oct 2026 09:55:23 +0530 Subject: 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. --- elf/header.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'elf/header.lua') 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 -- cgit v1.3