test/bounce — format-bounce stress corpus
Stresses kit's object read/write/reloc, archive, and partial-link machinery by taking one compiled program and bouncing its relocatable object through chains of format conversions and toolchain transforms, relinking, and checking the result still computes the right answer. Cross-arch run coverage lives elsewhere (test/link, test/smoke); this corpus exercises the format paths, not the arches.
Run with make test-bounce (opt-in; needs podman/qemu + a host cc).
Cases
cases/NN_name.c each define int bounce_main(void) returning a value in
[0,127]. They are portable LP64 integer C, so the host-cc result is the
oracle every target and every bounce chain must reproduce. crt/crt.c is
the freestanding _start: it calls bounce_main with a normal C call (so
the compiler emits a real cross-TU relocation — the edge under test) and
exits via exit_group with the return value.
Chains
For each (arch, case, -O level) the program is compiled to one .o, then
each chain rebuilds an executable from it and runs it:
| Chain | Transform | Stresses |
|---|---|---|
direct |
link straight through | baseline |
macho_rt |
ELF → Mach-O → ELF (objcopy) | macho_emit/macho_read + reloc xlate |
coff_rt |
ELF → COFF → ELF (objcopy) | coff_emit/coff_read + reloc xlate |
tri_rt |
ELF → Mach-O → COFF → ELF | chained round-trip |
ldr |
ld -r partial-link merge → link |
relocatable output |
strip_dbg |
objcopy --strip-debug → link |
strip + reduced symtab |
ar |
ar rcs → on-demand link |
GNU archive index r/w + symbol resolution |
A chain only runs where every format it routes through is a real kit target for that arch:
| Format | Arches |
|---|---|
| ELF | all (Linux / freestanding) |
| COFF | x64, aarch64 (Windows) |
| Mach-O | aarch64 only (Apple Silicon; kit does not target x64 Mach-O) |
So macho_rt/tri_rt run on aarch64 only, coff_rt on aarch64+x64, and
the ELF-only chains everywhere.
Arches
Defaults to the host-native Linux arch (no emulation). Sweep others with
KIT_BOUNCE_ARCHES="aarch64 x64 rv64". Optimization levels default to
0 1 (override with KIT_BOUNCE_OPTS).
Conventions
Skip-vs-fail mirrors the smoke harness: a skip counts as failure unless
KIT_TEST_ALLOW_SKIP=1. Add a case by dropping a cases/NN_name.c that
defines bounce_main; no other wiring is needed.