sots-re/verify/results/research-completion-abi-independent/reproduce_run_eba7860308317f839eb35392.py

87 lines
3.3 KiB
Python

#!/usr/bin/env python3
"""Reproduce static ABI windows; writes only this verifier session's result directory."""
import hashlib
import json
import pathlib
import subprocess
ROOT = pathlib.Path("/home/alex/sots-re")
OUT = ROOT / "verify/results/research-completion-abi-independent/run-eba7860308317f839eb35392"
EXE = ROOT / "dumps/sots.exe"
OBJDUMP = pathlib.Path("/usr/bin/objdump")
WINDOWS = [
("dedup-narrow", "D", 0x00825D40, 0x00825E65),
("dedup-wide", "D", 0x00825D40, 0x00825E67),
("string-ne", "D", 0x0046F8C0, 0x0046F8F0),
("string-compare", "D", 0x004236A0, 0x0042370D),
("byte-compare", "D", 0x00422720, 0x00422796),
("observed-ctor", "D", 0x008562A0, 0x0085630D),
("observed-append", "D", 0x007B7320, 0x007B739F),
("observed-realloc", "D", 0x007B34E0, 0x007B35EF),
("observed-copy", "D", 0x0079A150, 0x0079A1D9),
("player-append", "D", 0x0086C580, 0x0086C62E),
("player-copy", "D", 0x007693F0, 0x007694C0),
("player-dtor", "D", 0x0061AE90, 0x0061AEFC),
("observed-alloc", "D", 0x0057E590, 0x0057E5E4),
("string-assign", "D", 0x004249A0, 0x00424ADA),
("allocator-thunks", "D", 0x00924FAA, 0x00924FBC),
("turn-get-create", "D", 0x00885380, 0x00885500),
("prune", "D", 0x00879EB0, 0x0087A020),
("turn-append", "D", 0x00884CB0, 0x00884DC0),
("turn-grow", "D", 0x008841A0, 0x00884440),
("nested-dtor", "D", 0x00629580, 0x00629620),
("nested-copy", "D", 0x00779850, 0x00779A20),
("turn-dtor", "D", 0x0062E120, 0x0062E190),
("turn-alloc", "D", 0x006E8F50, 0x006E8FB0),
("turn-range-copy", "D", 0x0077FED0, 0x00780040),
("player-range-copy", "D", 0x007725A0, 0x007726D0),
("player-alloc", "D", 0x0078AF40, 0x0078AFA8),
("player-ctor", "D", 0x0084EE30, 0x0084EEF4),
("turn-vtable", "s", 0x00A0F070, 0x00A0F0A0),
]
def sha256(data: bytes) -> str:
return hashlib.sha256(data).hexdigest()
OUT.mkdir(exist_ok=False)
records = []
for name, mode, start, stop in WINDOWS:
args = [str(OBJDUMP), f"-{mode}"]
if mode == "D":
args.append("-Mintel")
args += [f"--start-address=0x{start:08x}", f"--stop-address=0x{stop:08x}", str(EXE)]
proc = subprocess.run(args, cwd=ROOT, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False)
stdout_path = OUT / f"{name}.stdout.txt"
stderr_path = OUT / f"{name}.stderr.txt"
stdout_path.write_bytes(proc.stdout)
stderr_path.write_bytes(proc.stderr)
instruction_lines = sum(
1 for line in proc.stdout.splitlines()
if line.lstrip()[:1].isdigit() and b":" in line
)
records.append({
"name": name,
"argv": args,
"start": f"0x{start:08x}",
"stop": f"0x{stop:08x}",
"returncode": proc.returncode,
"stdout_bytes": len(proc.stdout),
"stdout_sha256": sha256(proc.stdout),
"stderr_bytes": len(proc.stderr),
"stderr_sha256": sha256(proc.stderr),
"instruction_lines": instruction_lines,
})
manifest = {
"session": "run-eba7860308317f839eb35392",
"cwd": str(ROOT),
"input": {"path": str(EXE), "sha256": sha256(EXE.read_bytes())},
"tool": {"path": str(OBJDUMP), "sha256": sha256(OBJDUMP.read_bytes())},
"windows": records,
}
(OUT / "manifest.json").write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8")
if any(r["returncode"] != 0 or r["stdout_bytes"] == 0 for r in records):
raise SystemExit(1)