#!/usr/bin/env python3 # fillsize.py - stamp image_size into the arm64 Image header of a # built binary. the linker cannot know the final file size, the # header field stays 0 through the link, this runs after objcopy. import struct import sys path = sys.argv[1] d = bytearray(open(path, 'rb').read()) assert d[0x38:0x3c] == b'ARM\x64', 'no Image magic, refusing to stamp' struct.pack_into('