Key archive member labels/placements by member offset so two same-named members cannot overwrite each other; add a dupnamed fixture asserting distinct address ranges. Treat an empty / index as absent, require ASCII decimal sizes, validate odd-member padding and final bounds, and dedupe index entries by member offset. Document the -l/archive ordering and the unit gate's FLIB_LIB/M4_SDK prerequisite (the real-LIB case is skipped with a reason when absent). Accept the 1990 tools' metadata section bits (0x100/0x400) on allocated sections, which the M6 flib/rts members use, while still writing classic output flags. Add M6_LINKER=tms-link to runtime.sh and i64.sh: after GSPA, link the same M6.OBJ + flib.lib/rts.lib with tms-link, compare allocated bytes/symbols to the GSPLNK oracle, and run the same MAME marker checks. M8 native-lib now compares tms-link's raw pre-coff-check image. Add loud-path fixtures for index lies, BSD names, duplicate / and // tables, bad/missing padding, non-ASCII sizes and -l resolution failure; strengthen the no-index exclusion test; add 1990-flag and M5_NATIVE_LINKER docs.
97 lines
3.7 KiB
Bash
Executable File
97 lines
3.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# M8 native-library gate: link a real driver against the 1987 FLIB.LIB and
|
|
# RTS.LIB through tools/tms-link, run it in MAME, and compare the allocated
|
|
# image and public symbols with the GSPLNK 2.00 oracle.
|
|
#
|
|
# The driver uses flib FD$ADD/FD$MUL/FD$DTOI (double arithmetic and fptosi)
|
|
# and rts.lib _isascii. The GSPLNK run never reaches MAME; the tms-link run
|
|
# must report the loader status, place .text with 0 differing bytes, and pass
|
|
# the marker check.
|
|
#
|
|
# scripts/tests/m8/native-lib.sh
|
|
#
|
|
# Overridable: LLVM_BIN TMS_LLC TMS_CLANG MAME DOSBOX DOSBOX_CONF SDK_IMG
|
|
# M8_NATIVE_LIB_WORK M8_NATIVE_LIB_SDK M7COFF
|
|
# LOADER_AT LOADER_END MAME_TIMEOUT DOSBOX_TIMEOUT
|
|
set -eu
|
|
|
|
ROOT=$(cd "$(dirname "$0")/../../.." && pwd)
|
|
DIR=$ROOT/scripts/m8
|
|
WORK=${M8_NATIVE_LIB_WORK:-$ROOT/build/m8-native-lib}
|
|
SDK=${M8_NATIVE_LIB_SDK:-$ROOT/build/m4-sdk}
|
|
M7COFF=${M7COFF:-$ROOT/build/llvm-clean/llvm/test/CodeGen/TMS34010/m7coff.py}
|
|
|
|
fail() {
|
|
echo "M8 native lib: FAIL: $*" >&2
|
|
exit 1
|
|
}
|
|
|
|
[ -f "$DIR/libcheck.c" ] || fail "missing driver: $DIR/libcheck.c"
|
|
[ -f "$DIR/lib-entry.asm" ] || fail "missing entry: $DIR/lib-entry.asm"
|
|
[ -f "$DIR/lib-check.lua" ] || fail "missing checker: $DIR/lib-check.lua"
|
|
[ -f "$M7COFF" ] || fail "independent TI-COFF reader not found: $M7COFF"
|
|
|
|
rm -rf "$WORK"
|
|
mkdir -p "$WORK"
|
|
|
|
RUN_ENV="M4_NATIVE=1
|
|
M4_SOURCES=$DIR/libcheck.c
|
|
M4_ENTRY=$DIR/lib-entry.asm
|
|
M4_CHECK_LUA=$DIR/lib-check.lua
|
|
M4_SDK=$SDK
|
|
M4_NATIVE_LIBS=FLIB.LIB
|
|
M4_NATIVE_RTS=1"
|
|
|
|
echo "== GSPLNK oracle link (no MAME)"
|
|
# shellcheck disable=SC2086
|
|
env $RUN_ENV \
|
|
M4_WORK="$WORK/gsplnk" \
|
|
M4_COFF="$WORK/gsplnk/m4.coff" \
|
|
M4_SKIP_MAME=1 \
|
|
"$ROOT/scripts/m4/run.sh" > "$WORK/gsplnk.log" 2>&1 \
|
|
|| { tail -30 "$WORK/gsplnk.log" >&2; fail "GSPLNK oracle link failed"; }
|
|
grep -q '^M4 LINK: PASS' "$WORK/gsplnk.log" \
|
|
|| { tail -30 "$WORK/gsplnk.log" >&2; fail "GSPLNK oracle did not pass"; }
|
|
[ -f "$WORK/gsplnk/m4.coff" ] || fail "GSPLNK produced no image"
|
|
|
|
echo "== tms-link archive link and MAME"
|
|
# shellcheck disable=SC2086
|
|
env $RUN_ENV \
|
|
M4_LINKER=tms-link \
|
|
M4_WORK="$WORK/tmslink" \
|
|
M4_COFF="$WORK/tmslink/m4.coff" \
|
|
LOADER_AT="${LOADER_AT:-2500}" \
|
|
LOADER_END="${LOADER_END:-3400}" \
|
|
"$ROOT/scripts/m4/run.sh" > "$WORK/tmslink.log" 2>&1 \
|
|
|| { tail -40 "$WORK/tmslink.log" >&2; fail "tms-link archive run failed"; }
|
|
grep -q '^M8 LIB MAME: PASS' "$WORK/tmslink/mame.log" \
|
|
|| { tail -40 "$WORK/tmslink/mame.log" >&2; \
|
|
fail "tms-link MAME markers failed"; }
|
|
grep -q 'LOADER: result status=0 (OK)' "$WORK/tmslink/mame.log" \
|
|
|| fail "loader did not accept the tms-link image"
|
|
grep -q 'placed \.text .* 0 differing' "$WORK/tmslink/mame.log" \
|
|
|| fail "loader did not verify the placed .text bytes"
|
|
|
|
echo "== GSPLNK vs raw tms-link allocated bytes and symbols"
|
|
[ -f "$WORK/tmslink/M4.RAW.OUT" ] \
|
|
|| fail "tms-link did not preserve its pre-repair image"
|
|
cmp -s "$WORK/tmslink/M4.RAW.OUT" "$WORK/tmslink/m4.coff" \
|
|
|| fail "tms-link image changed during coff-check repair"
|
|
python3 "$ROOT/scripts/tests/m8/coff-parity.py" \
|
|
"$M7COFF" "$WORK/gsplnk/m4.coff" "$WORK/tmslink/M4.RAW.OUT" \
|
|
|| fail "raw tms-link image differs from GSPLNK"
|
|
|
|
# The library members are visible in the map, and no unrelated member was
|
|
# pulled in. (The marker check already proved the actual calls ran.)
|
|
MAP=$WORK/tmslink/m4.map
|
|
for sym in FD\$ADD FD\$MUL FD\$DTOI _isascii _fp_error; do
|
|
grep -q " ${sym}\$" "$MAP" || fail "tms-link map has no $sym"
|
|
done
|
|
for sym in FD\$DIV FD\$NEG FD\$EQ FS\$ADD _printf; do
|
|
if grep -q " ${sym}\$" "$MAP"; then
|
|
fail "tms-link map has an unneeded member symbol: $sym"
|
|
fi
|
|
done
|
|
|
|
echo "M8 native lib: PASS (FD\$ADD/FD\$MUL/FD\$DTOI + _isascii, GSPLNK parity)"
|