#!/bin/sh # M3 ROM symbol validation: the four Xlib entry points used by the compiled # client must exist in the v2.2 table, sit in the ROM's bit range, be 16-bit # aligned, and disassemble to a plausible function prologue. # # This is a regression check, not a re-extraction: dwt/gui/xhello.asm and the # termtris xlib.h are the evidence that these entries work. XMapWindow is the # true map entry (MapWindow request opcode 8); 0x3FD645B0 is XRaiseWindow # (ConfigureWindow opcode 12), never a mapping call. M4 extends the table for # XImage/XEvent and validates every entry independently in # scripts/m4/validate-syms.sh. # # scripts/m3/validate-syms.sh [symbols/vt1200-v22.syms] # # Overridable: M3_SYMS DIS34 ROM set -eu ROOT=$(cd "$(dirname "$0")/../.." && pwd) SYMS=${1:-${M3_SYMS:-$ROOT/symbols/vt1200-v22.syms}} DIS34=${DIS34:-$ROOT/vendor/vt1200/tools/smart34010/dis34} ROM=${ROM:-$ROOT/vendor/vt1200/vt1200_v22.bin} ROM_LO=$((0x3F200000)) ROM_HI=$((0x3FFFFFFF)) fail() { echo "m3 validate-syms: FAIL: $*" >&2 exit 1 } [ -f "$SYMS" ] || fail "symbol file not found: $SYMS" [ -x "$DIS34" ] || fail "dis34 not found or not executable: $DIS34" [ -f "$ROM" ] || fail "ROM image not found: $ROM" check_sym() { # check_sym NAME EXPECTED_HEX name=$1 expected=$2 got=$(awk -v n="$name" '$1 == n { print $2; exit }' "$SYMS") [ -n "$got" ] || fail "$SYMS has no $name entry" [ "$got" = "$expected" ] \ || fail "$name is $got, expected $expected (the xhello.asm-proven entry)" addr=$((got)) [ "$addr" -ge "$ROM_LO" ] && [ "$addr" -le "$ROM_HI" ] \ || fail "$name $got is outside the ROM bit range 3F200000h..3FFFFFFFh" [ $((addr % 16)) -eq 0 ] \ || fail "$name $got is not 16-bit aligned" off=$(( (addr - ROM_LO) / 8 )) first=$("$DIS34" -b "$got" -s "$off" "$ROM" 2>/dev/null | awk 'NF && $1 !~ /^L[0-9A-Fa-f]+:$/ { print tolower($1); exit }') [ -n "$first" ] || fail "$name $got disassembled to nothing" case " move mmtm setf cmp addi " in *" $first "*) ;; *) fail "$name $got starts with '$first', not a plausible function prologue" ;; esac echo " ok $name $got: $first ..." } check_sym XOpenDisplay 0x3F9C2570 check_sym XCreateSimpleWindow 0x3FD41B90 check_sym XMapWindow 0x3FD64F60 check_sym XSync 0x3FD9F6B0 echo "m3 validate-syms: PASS (four v2.2 Xlib entries in ROM, aligned, prologues valid)"