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_7 / assemble.sh
| 1 | #!/usr/bin/env bash |
| 2 | # Reassemble every PI5-7 cut 3 probe from probe.S into OUT_DIR/<probe>/code.bin. |
| 3 | # The committed code.bin files are the Raspberry Pi 5 qualification inputs (kernel read at 0x210000, kernel |
| 4 | # write at 0x2000000, the addresses the Pi image's own mmu_switch / memory lines print); this script proves |
| 5 | # they are exactly what probe.S assembles to, and builds other platforms' variants (the QEMU twin gate |
| 6 | # passes the addresses its own kernel prints): |
| 7 | # KREAD_ADDR=0x40000000 KWRITE_ADDR=0x4a000000 assemble.sh OUT_DIR |
| 8 | # Needs an AArch64 GNU `as` and `objcopy` (native on the Spark). |
| 9 | set -euo pipefail |
| 10 | |
| 11 | here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 12 | out="${1:?usage: assemble.sh OUT_DIR}" |
| 13 | as_bin="${AS:-as}" |
| 14 | objcopy_bin="${OBJCOPY:-objcopy}" |
| 15 | if [[ "$(uname -m)" != "aarch64" ]]; then |
| 16 | as_bin="${AS:-aarch64-linux-gnu-as}" |
| 17 | objcopy_bin="${OBJCOPY:-aarch64-linux-gnu-objcopy}" |
| 18 | fi |
| 19 | kread="${KREAD_ADDR:-0x210000}" |
| 20 | kwrite="${KWRITE_ADDR:-0x2000000}" |
| 21 | [[ "${kread}" =~ ^0x[0-9a-fA-F]{1,16}$ && "${kwrite}" =~ ^0x[0-9a-fA-F]{1,16}$ ]] || { echo "FAIL addresses must be 0x<hex>" >&2; exit 1; } |
| 22 | |
| 23 | for probe in p27kread p27kwrite p27priv; do |
| 24 | mkdir -p "${out}/${probe}" |
| 25 | "${as_bin}" --defsym "KADDR=$([[ ${probe} == p27kread ]] && echo "${kread}" || echo "${kwrite}")" \ |
| 26 | -o "${out}/${probe}/probe.o" "${here}/${probe}/probe.S" |
| 27 | # A probe must be fully resolved: no relocations, so the bytes the kernel authenticates are the bytes |
| 28 | # that execute, with no loader fix-ups. |
| 29 | if command -v readelf >/dev/null; then |
| 30 | if readelf -r "${out}/${probe}/probe.o" | grep -q "Relocation section"; then |
| 31 | echo "FAIL ${probe} has relocations" >&2 |
| 32 | exit 1 |
| 33 | fi |
| 34 | fi |
| 35 | "${objcopy_bin}" -O binary -j .text "${out}/${probe}/probe.o" "${out}/${probe}/code.bin" |
| 36 | done |