aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / crates / aienos-artifact-tool / fixtures / p2_5 / assemble.sh
| 1 | #!/usr/bin/env bash |
| 2 | # Reassemble every P2-5 probe from probe.S into OUT_DIR/<probe>/code.bin. |
| 3 | # The committed code.bin files are the qualification inputs; this script |
| 4 | # only exists to prove they are exactly what probe.S assembles to. |
| 5 | # Needs an AArch64 GNU `as` and `objcopy` (native on the Spark). |
| 6 | set -euo pipefail |
| 7 | |
| 8 | here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 9 | out="${1:?usage: assemble.sh OUT_DIR}" |
| 10 | as_bin="${AS:-as}" |
| 11 | objcopy_bin="${OBJCOPY:-objcopy}" |
| 12 | if [[ "$(uname -m)" != "aarch64" ]]; then |
| 13 | as_bin="${AS:-aarch64-linux-gnu-as}" |
| 14 | objcopy_bin="${OBJCOPY:-aarch64-linux-gnu-objcopy}" |
| 15 | fi |
| 16 | |
| 17 | for probe in p25exec p25wx p25spin; do |
| 18 | mkdir -p "${out}/${probe}" |
| 19 | "${as_bin}" -o "${out}/${probe}/probe.o" "${here}/${probe}/probe.S" |
| 20 | # A probe must be fully resolved: no relocations, so the bytes the kernel |
| 21 | # authenticates are the bytes that execute, with no loader fix-ups. |
| 22 | if command -v readelf >/dev/null; then |
| 23 | if readelf -r "${out}/${probe}/probe.o" | grep -q "Relocation section"; then |
| 24 | echo "FAIL ${probe} has relocations" >&2 |
| 25 | exit 1 |
| 26 | fi |
| 27 | fi |
| 28 | "${objcopy_bin}" -O binary -j .text "${out}/${probe}/probe.o" "${out}/${probe}/code.bin" |
| 29 | done |