#!/usr/bin/env python3 # SPDX-License-Identifier: AGPL-3.0-or-later """ @file compare_tensix_load_images.py @brief Compare what a Tensix ELF puts on the card: entry address, every PT_LOAD (virtual and physical address, file and memory size, bytes) and the `.segments` limits record. Two images that agree on all of it load identically, whatever their symbol tables or section headers say. Usage: compare_tensix_load_images.py Prints LOAD-IDENTICAL, or each difference; exit 0 / 1. The gate for a linker-script change (clean-room Phase 3): a layout that does not move must leave every image LOAD-IDENTICAL. @status Added 2026-10-08. @issues None @todo None """ import struct import sys PT_LOAD = 1 def load_view(path): """(entry, [(vaddr, paddr, filesz, memsz, bytes)], segments-record bytes or None).""" with open(path, "rb") as handle: blob = handle.read() if blob[:4] != b"\x7fELF" or blob[4] != 1 or blob[5] != 1: sys.exit("%s: not a 32-bit little-endian ELF" % path) (entry, phoff, shoff) = struct.unpack_from("