"""Synthetic tests: no Apple binaries or executable host code required.""" import collections import struct import unittest from unicorn import Uc, UC_ARCH_ARM64, UC_MODE_ARM, UC_PROT_READ, UC_PROT_WRITE, UC_PROT_EXEC, UcError from unicorn import arm64_const as a from rosetta_execution import ( Harness, Segment, _parse_macho, _parse_fixups, BASE, HEAP, HEAP_SIZE, STACK, STACK_SIZE, HOOK, PAGE, REG, MASK64, MAX_MAPPING, ) def model(): harness = Harness.__new__(Harness) harness.u = Uc(UC_ARCH_ARM64, UC_MODE_ARM) harness.u.mem_map(HEAP, HEAP_SIZE, UC_PROT_READ | UC_PROT_WRITE) harness.u.mem_map(STACK, STACK_SIZE, UC_PROT_READ | UC_PROT_WRITE) harness.u.mem_map(BASE, PAGE, UC_PROT_READ | UC_PROT_EXEC) harness.next = HEAP harness.map_next = 0x100000000 harness.allocations = {} harness.mappings = {} harness.segments = [Segment(0, PAGE, 0, PAGE, UC_PROT_READ | UC_PROT_EXEC)] harness.events = [] harness.pcs = collections.deque(maxlen=16) harness.hooks = {HOOK: "_memmove"} harness.errno = 0 return harness def macho(): """Small dylib with one RW segment, one export, one chain pointer.""" data = bytearray(PAGE) commands = ( struct.pack("