Files
lab-rv32i-freertos-sw-timer/scripts/check_abi.sh
T
2026-07-21 19:14:20 +02:00

18 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env sh
set -eu
nm=${RISCV_NM:-riscv64-unknown-elf-nm}
readelf=${RISCV_READELF:-riscv64-unknown-elf-readelf}
elf=build/task01_sw_timer/prog.elf
if "$nm" -C -u "$elf" | grep -Eq '__cxa_|_Unwind_|std::|libstdc\+\+'; then echo "hosted C++ runtime dependency" >&2; exit 1; fi
if "$nm" -C --defined-only "$elf" | grep -Eq 'vtable for|typeinfo for|typeinfo name for'; then echo "virtual/RTTI metadata" >&2; exit 1; fi
if "$readelf" -S "$elf" | grep -Eq '\.init_array|\.eh_frame|\.gcc_except_table'; then echo "initializer/exception/unwind section" >&2; exit 1; fi
for symbol in software_timer_debug_checkpoint g_start_commands_accepted g_one_shot_tick g_periodic_ticks g_timer_pass; do
if ! "$nm" --defined-only "$elf" | grep -Fq "$symbol"; then echo "missing evidence: $symbol" >&2; exit 1; fi
done
for symbol in g_one_shot_storage g_periodic_storage g_verifier_tcb g_verifier_stack; do
if ! "$nm" -C --defined-only "$elf" | grep -E "[[:space:]][bB][[:space:]].*$symbol" >/dev/null; then
echo "static storage is not in .bss: $symbol" >&2; exit 1
fi
done
echo "PASS ABI: timer/task control storage in .bss; wrapper has no C++ runtime"