222 lines
6.8 KiB
Plaintext
222 lines
6.8 KiB
Plaintext
import "wasm.just"
|
|
import "fail.just"
|
|
|
|
BUILD_DIR := "build"
|
|
|
|
# Load environment variables set by "nix develop"-shell
|
|
|
|
FAIL_SHARE := env("FAIL_SHARE")
|
|
WASI_ROOT := env("WASI_ROOT")
|
|
WAMR_ROOT := env("WAMR_ROOT")
|
|
LIBIWASM_DEBUG := env("LIBIWASM_DEBUG")
|
|
LIBIWASM_RELEASE := env("LIBIWASM_RELEASE")
|
|
LIBIWASM_LINUX_DEBUG := env("LIBIWASM_LINUX_DEBUG")
|
|
LIBIWASM_LINUX_RELEASE := env("LIBIWASM_LINUX_RELEASE")
|
|
CROSS_CC := env("CROSS_CC")
|
|
LINUX_CC := env("LINUX_CC")
|
|
|
|
# FAIL* variables
|
|
|
|
FAIL_SERVER_PORT := "1111"
|
|
RESULTBROWSER_PORT := "5000"
|
|
BOCHS_RUNNER := "bochs-experiment-runner.py"
|
|
FAIL_TRACE := "fail-x86-tracing"
|
|
FAIL_DUMP := "dump-trace"
|
|
FAIL_IMPORT := "import-trace"
|
|
FAIL_PRUNE := "prune-trace"
|
|
FAIL_SERVER := "generic-experiment-server"
|
|
FAIL_INJECT := "generic-experiment-client"
|
|
RESULT_BROWSER := "resultbrowser.py"
|
|
|
|
# =================================================================================================================== #
|
|
# Helper recipes
|
|
# =================================================================================================================== #
|
|
|
|
[default]
|
|
[private]
|
|
list:
|
|
@just --list
|
|
|
|
[private]
|
|
create-build-dir module:
|
|
mkdir -p {{ BUILD_DIR }}-{{ module }}
|
|
|
|
[doc("Delete the build directory")]
|
|
clean module:
|
|
rm -rf {{ BUILD_DIR }}-{{ module }}
|
|
|
|
# =================================================================================================================== #
|
|
# MySQL recipes
|
|
# =================================================================================================================== #
|
|
|
|
[doc("Start MySQL container to receive FAIL* trace/campaign results")]
|
|
[group("3: fail db")]
|
|
start-db:
|
|
docker run -d \
|
|
--name fail-db \
|
|
-e MYSQL_ROOT_PASSWORD=fail \
|
|
-e MYSQL_USER=fail \
|
|
-e MYSQL_PASSWORD=fail \
|
|
-e MYSQL_DATABASE=fail \
|
|
-p 3306:3306 \
|
|
mysql
|
|
|
|
[doc("Connect to MySQL database using DBeaver")]
|
|
[group("3: fail db")]
|
|
connect-db:
|
|
dbeaver -con "name=fail|driver=mysql|host=localhost|port=3306|database=fail|user=fail|password=fail"
|
|
|
|
[doc("Stop MySQL container")]
|
|
[group("3: fail db")]
|
|
stop-db:
|
|
docker stop fail-db
|
|
|
|
[doc("Remove MySQL container")]
|
|
[group("3: fail db")]
|
|
remove-db:
|
|
docker container rm fail-db
|
|
|
|
# =================================================================================================================== #
|
|
# Debugging recipes
|
|
# =================================================================================================================== #
|
|
|
|
[doc("Launch gdb")]
|
|
[group("debug")]
|
|
gdb module:
|
|
gdb --tui {{ BUILD_DIR }}-{{ module }}/system.elf
|
|
|
|
# [doc("Launch radare2 at address and disassemble")]
|
|
# [group("debug")]
|
|
# r2 module addr="dbg.os_main":
|
|
# # -e asm.section=true
|
|
# # -e asm.bytes=true
|
|
# radare2 -AA \
|
|
# -c "f TARGET @ {{ addr }}; s {{ addr }}; pd-- 30" \
|
|
# -e asm.syntax=intel \
|
|
# -e asm.lines=false \
|
|
# -e asm.xrefs=true \
|
|
# -e asm.flags=true \
|
|
# -e asm.comments=true \
|
|
# -e asm.functions=true \
|
|
# -e asm.var=true \
|
|
# -e asm.cmt.right=true \
|
|
# -e asm.dwarf=true \
|
|
# -e asm.pseudo=false \
|
|
# -e asm.describe=false \
|
|
# -e bin.relocs.apply=true \
|
|
# {{ BUILD_DIR }}-{{ module }}/system.elf
|
|
|
|
[doc("Launch radare2 at address (interactive)")]
|
|
[group("debug")]
|
|
r2i module addr="dbg.os_main":
|
|
# -e asm.section=true
|
|
# -e asm.bytes=true
|
|
radare2 -AA \
|
|
-c "s {{ addr }}" \
|
|
-e scr.color=3 \
|
|
-e scr.scrollbar=0 \
|
|
-e scr.responsive=true \
|
|
-e scr.interactive=true \
|
|
-e scr.utf8=true \
|
|
-e scr.utf8.curvy=true \
|
|
-e asm.syntax=intel \
|
|
-e asm.lines=false \
|
|
-e asm.xrefs=true \
|
|
-e asm.flags=true \
|
|
-e asm.comments=true \
|
|
-e asm.functions=true \
|
|
-e asm.var=true \
|
|
-e asm.cmt.right=true \
|
|
-e asm.dwarf=true \
|
|
-e asm.pseudo=false \
|
|
-e asm.describe=false \
|
|
-e bin.relocs.apply=true \
|
|
{{ BUILD_DIR }}-{{ module }}/system.elf
|
|
|
|
# =================================================================================================================== #
|
|
# Just do it
|
|
# =================================================================================================================== #
|
|
|
|
[arg("mode", pattern="c|aot|interp", help="Which WASM mode to use")]
|
|
[arg("target", pattern="fail|linux|linux-baremetal", help="Which platform to compile for")]
|
|
[doc("Perform all steps for a fail/linux/linux-bm build with aot/interp WASM")]
|
|
[group("5: just do it")]
|
|
build module="__help" target="fail" mode="aot":
|
|
#!/usr/bin/env sh
|
|
|
|
if [ "{{ module }}" = "__help" ]; then
|
|
just --usage build
|
|
exit 0
|
|
fi
|
|
|
|
just clean {{ module }}
|
|
just create-build-dir {{ module }}
|
|
|
|
if [ "{{ mode }}" = "aot" ]; then
|
|
just build-wasm-module {{ module }}
|
|
just build-wasm-aot {{ module }}
|
|
just build-wasm-aot-array {{ module }}
|
|
|
|
just prepare-aot-host {{ module }} {{ target }}
|
|
just build-wasm-host {{ module }} {{ target }}
|
|
|
|
just build-system-startup {{ module }} {{ target }}
|
|
just build-system-syscalls {{ module }} {{ target }}
|
|
just link-system {{ module }} {{ target }}
|
|
elif [ "{{ mode }}" = "interp" ]; then
|
|
just build-wasm-module {{ module }}
|
|
just build-wasm-interp-array {{ module }}
|
|
|
|
just prepare-interp-host {{ module }} {{ target }}
|
|
just build-wasm-host {{ module }} {{ target }}
|
|
|
|
just build-system-startup {{ module }} {{ target }}
|
|
just build-system-syscalls {{ module }} {{ target }}
|
|
just link-system {{ module }} {{ target }}
|
|
elif [ "{{ mode }}" = "c" ]; then
|
|
just build-c-module {{ module }} {{ target }}
|
|
|
|
just build-c-host {{ module }} {{ target }}
|
|
|
|
just build-system-startup {{ module }} {{ target }}
|
|
just link-c-system {{ module }} {{ target }}
|
|
else
|
|
echo "unknown mode: {{ mode }}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
just build-iso {{ module }}
|
|
|
|
[doc("Run binary")]
|
|
[group("5: just do it")]
|
|
run module:
|
|
{{ BUILD_DIR }}-{{ module }}/system.elf
|
|
|
|
[doc("Send binaries to mars")]
|
|
[group("5: just do it")]
|
|
upload module:
|
|
scp -r {{ BUILD_DIR }}-{{ module }} mars:~/Documents/failnix/{{ BUILD_DIR }}-{{ module }}
|
|
|
|
[doc("Send markers to local")]
|
|
[group("5: just do it")]
|
|
download-markers:
|
|
scp mars:~/Documents/failnix/markers.csv ./markers.csv
|
|
|
|
[doc("Perform all steps for a FAIL* campaign")]
|
|
[group("5: just do it")]
|
|
inject module:
|
|
just start-db
|
|
@echo "Waiting for database..."
|
|
sleep 20
|
|
|
|
just trace {{ module }}
|
|
just import {{ module }}
|
|
just server {{ module }}
|
|
just client {{ module }}
|
|
just result {{ module }}
|
|
|
|
[doc("Copy build directory to injections/ with timestamp")]
|
|
[group("5: just do it")]
|
|
archive module suffix:
|
|
cp -rv {{ BUILD_DIR }}-{{ module }} ./injections/`date +%Y-%m-%d_%H-%M`_{{ module }}_"{{ suffix }}"
|