interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / seed / qualification / om2 / oracle / sha / entry.py

23 lines · 1122 bytes Raw Blame History
1#!/usr/bin/python3
2# SPDX-License-Identifier: Apache-2.0
3# ORACLE-side harness transform (outside the delivered closure), L836 phaseB/sha-f5d14cb2.
4# leakscan seeds its analysis only at word 0 (or the direct B there). The S4 multi-export artifact
5# starts with E entry words `b <export k>` (NATIVE-ABI.md "Multi-entry code"; the binding enters
6# export k at byte 4k). For export k this writes a copy whose word 0 is the B that word k encodes,
7# re-based to byte 0 (imm26 + k), so the scanner starts exactly where the binding enters export k.
8# Every other byte is unchanged. Usage: entry.py ARTIFACT K OUT
9import struct
10import sys
11
12art = bytearray(open(sys.argv[1], "rb").read())
13k = int(sys.argv[2])
14w = struct.unpack_from("<I", art, 4 * k)[0]
15if w & 0xFC000000 != 0x14000000:
16 sys.exit(f"word {k} is not B: {w:#010x}")
17imm = w & 0x03FFFFFF
18imm = imm - (1 << 26) if imm & (1 << 25) else imm
19tgt = 4 * k + 4 * imm
20new = 0x14000000 | ((tgt // 4) & 0x03FFFFFF)
21struct.pack_into("<I", art, 0, new)
22open(sys.argv[3], "wb").write(art)
23print(f"export {k}: word {k} = {w:#010x} -> target byte {tgt:#x}; word 0 = {new:#010x}")