Differential validation and fuzzing

Install qemu-aarch64 and an AArch64 cross compiler outside ScarletNX, then run:

python3 tools/gnuabi_diff.py --scarletnx build/gnuabi/scarletnx-gnuabi \
    --suite all --fuzz 100 --seed 1000
python3 tools/gnuabi_diff.py --scarletnx build/gnuabi/scarletnx-gnuabi \
    /tmp/libc-aarch64

The fixtures are freestanding static ELF files. The CPU suite covers arithmetic, branching, unaligned memory, floating point, SIMD, exclusive atomics, a function crossing a 4 KiB instruction boundary, and initial stack alignment. The syscall suite exercises tmpfs, devfs, procfs, descriptor and metadata calls, clocks, random reads, and unsupported-call errors. The PIE suite verifies ET_DYN, PC-relative global accesses, and BSS initialization. The optional libc.c fixture exercises static libc startup, allocation, memory operations, and formatted output. The threads suite (threads.c, signals.c, restart.c, sigsuspend.c, wake.c and close.c, with thread_start.S) covers threads, futexes, signal frames, rt_sigreturn, SA_RESTART, rt_sigsuspend, a network wait after a signal and a descriptor closed during a call on it; CTest runs it as gnuabi_threads (skipped without Clang and LLD). The litmus suite (litmus.c) runs the Arm memory model's orderings in guest threads, one image per test: store buffering, message passing with DMB ISH, with STLR and LDAR, and with the split barrier DMB ISHST and DMB ISHLD, weak read coherence on three threads, and a plain load in a spin loop. Every outcome it reports must be one the model allows, and tests/litmus/ states the same tests for herd7. CTest runs it as gnuabi_litmus and gnuabi_litmus_lld, skipped without a compiler that emits AArch64 and a linker that builds the image, and gnuabi_litmus_self checks the driver's own decisions on every host. The standalone self_modify.S fixture must exit 42 after replacing a compiled instruction, as must rewrite.S, which rewrites code that already ran; fetch_fault.S must fault after removing the executing page's execute permission. These intentional faults should be checked directly rather than passed to the default differential success suite.

Seeded fuzzing generates unsigned integer and memory programs with reproducible source; it is an initial corpus generator rather than complete ISA coverage. Each generated fixture must exit zero. Existing input ELFs may intentionally return another status. The tool compares exact stdout bytes and exit status, detects timeouts and crashes, and optionally compares stderr with --compare-stderr. Avoid comparing printed timestamps, process IDs, random values, filesystem enumeration order, or host-specific paths. Tests should assert their properties and print deterministic results instead.

Failures are retained under build/gnuabi-failures by default. Each case includes the ELF, available source and seed, stdin, both output streams, compiler command, ELF SHA-256, timings, original commands, and replay commands in result.json. --keep-success also retains matching cases. Use --timeout to allow host compilation of larger ELFs and --compile-timeout for fixture cross compilation.

Clang plus LLD can build the freestanding suites without a target libc:

python3 tools/gnuabi_diff.py --scarletnx build/gnuabi/scarletnx-gnuabi \
    --suite all --cc clang --cc-arg=--target=aarch64-linux-gnu \
    --cc-arg=-fuse-ld=lld --qemu /path/to/qemu-aarch64

Source-boundary and transitive CMake dependency checks run as runtime_architecture in CTest. The harness unit tests intentionally create an output mismatch and verify that a reproducible ELF and both results are saved.


Made from docs/platforms/gnuabi/README.md at 69237645142c. GPL-3.0-or-later.