#!/usr/bin/env python3 # fat.py out in1 in2 ... : combine thin Mach-O files into a fat binary. import struct, sys out, ins = sys.argv[1], sys.argv[2:] slices = [] for p in ins: d = open(p, 'rb').read(); ct, cs = struct.unpack('IIIII', ct, cs, off, len(d), al); body += b'\0' * (off - hdr - len(body)) + d; off += len(d) open(out, 'wb').write(struct.pack('>II', 0xcafebabe, len(slices)) + ents + body)