add linux-posix + linux-baremetal recipes

This commit is contained in:
2026-03-12 13:45:33 +01:00
parent 66eb0b3814
commit 50c6e9adea
3 changed files with 255 additions and 107 deletions

100
flake.nix
View File

@ -273,8 +273,14 @@ rec {
''; '';
}; };
libiwasm = buildtype: flags: mkLibiwasm = {
i386_pkgs.stdenv.mkDerivation { buildenv,
platform,
buildtype,
cflags,
extraCmakeFlags ? [],
}:
buildenv.mkDerivation {
pname = "libiwasm"; pname = "libiwasm";
version = "2.4.4"; version = "2.4.4";
@ -289,33 +295,64 @@ rec {
nativeBuildInputs = with pkgs; [cmake]; nativeBuildInputs = with pkgs; [cmake];
cmakeBuildType = buildtype; cmakeBuildType = buildtype;
cmakeFlags = [ cmakeFlags =
"-DCMAKE_SYSTEM_NAME=Generic" extraCmakeFlags
"-DCMAKE_SYSTEM_PROCESSOR=i386" ++ [
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY" "-DCMAKE_VERBOSE_MAKEFILE=ON"
"-DCMAKE_COLOR_DIAGNOSTICS=ON"
"-DCMAKE_VERBOSE_MAKEFILE=ON" "-DWAMR_BUILD_PLATFORM=${platform}"
"-DCMAKE_COLOR_DIAGNOSTICS=ON" "-DWAMR_BUILD_TARGET=X86_32"
"-DWAMR_BUILD_AOT=1"
"-DWAMR_BUILD_PLATFORM=baremetal" "-DWAMR_BUILD_WAMR_COMPILER=0"
"-DWAMR_BUILD_TARGET=X86_32" "-DWAMR_BUILD_INTERP=1"
"-DWAMR_BUILD_AOT=1" "-DWAMR_BUILD_FAST_INTERP=0"
"-DWAMR_BUILD_WAMR_COMPILER=0" "-DWAMR_BUILD_JIT=0"
"-DWAMR_BUILD_INTERP=1" "-DWAMR_BUILD_FAST_JIT=0"
"-DWAMR_BUILD_FAST_INTERP=0" "-DWAMR_BUILD_LIBC_BUILTIN=1"
"-DWAMR_BUILD_JIT=0" "-DWAMR_BUILD_LIBC_WASI=0"
"-DWAMR_BUILD_FAST_JIT=0" "-DWAMR_BUILD_SIMD=0"
"-DWAMR_BUILD_LIBC_BUILTIN=1" ];
"-DWAMR_BUILD_LIBC_WASI=0"
"-DWAMR_BUILD_SIMD=0"
];
# Since GCC 15, implicit declarations are an error. Disable this. # Since GCC 15, implicit declarations are an error. Disable this.
NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration " + flags; NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration " + cflags;
}; };
libiwasm_debug = libiwasm "Debug" "-O0 -ggdb"; libiwasm-baremetal-debug = mkLibiwasm {
libiwasm_release = libiwasm "Release" "-O2 -ggdb -DNDEBUG"; buildenv = i386_pkgs.stdenv;
platform = "baremetal";
buildtype = "Debug";
cflags = "-O0 -ggdb";
extraCmakeFlags = [
"-DCMAKE_SYSTEM_NAME=Generic"
"-DCMAKE_SYSTEM_PROCESSOR=i386"
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
];
};
libiwasm-baremetal-release = mkLibiwasm {
buildenv = i386_pkgs.stdenv;
platform = "baremetal";
buildtype = "Release";
cflags = "-O2 -ggdb -DNDEBUG";
extraCmakeFlags = [
"-DCMAKE_SYSTEM_NAME=Generic"
"-DCMAKE_SYSTEM_PROCESSOR=i386"
"-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
];
};
libiwasm-linux-debug = mkLibiwasm {
buildenv = pkgs.multiStdenv;
platform = "linux";
buildtype = "Debug";
cflags = "-O0 -ggdb";
};
libiwasm-linux-release = mkLibiwasm {
buildenv = pkgs.multiStdenv;
platform = "linux";
buildtype = "Release";
cflags = "-O2 -ggdb -DNDEBUG";
};
# =========================================================================================== # ===========================================================================================
# Specify dependencies # Specify dependencies
@ -329,6 +366,7 @@ rec {
# - Interpreters needed by patchShebangs for build scripts (with the --build flag), which can be the case for e.g. perl # - Interpreters needed by patchShebangs for build scripts (with the --build flag), which can be the case for e.g. perl
nativeBuildInputs = with pkgs; [ nativeBuildInputs = with pkgs; [
just just
gdb
xxd xxd
wabt wabt
grub2 grub2
@ -398,7 +436,6 @@ rec {
wasi-sdk = wasi-sdk; wasi-sdk = wasi-sdk;
iwasm = iwasm; iwasm = iwasm;
wamrc = wamrc; wamrc = wamrc;
libiwasm = libiwasm_release;
}; };
apps = { apps = {
default = flake-utils.lib.mkApp {drv = fail-bin;}; default = flake-utils.lib.mkApp {drv = fail-bin;};
@ -406,7 +443,6 @@ rec {
wasi-sdk = wasi-sdk; wasi-sdk = wasi-sdk;
iwasm = iwasm; iwasm = iwasm;
wamrc = wamrc; wamrc = wamrc;
libiwasm = libiwasm_release;
}; };
devShells = { devShells = {
@ -427,10 +463,14 @@ rec {
FAIL_SHARE = "${fail-bin}/share"; FAIL_SHARE = "${fail-bin}/share";
WASI_ROOT = wasi-sdk; WASI_ROOT = wasi-sdk;
WAMR_ROOT = wamr; WAMR_ROOT = wamr;
LIBIWASM_DEBUG = "${libiwasm_debug}/lib"; LIBIWASM_DEBUG = "${libiwasm-baremetal-debug}/lib";
LIBIWASM_RELEASE = "${libiwasm_release}/lib"; LIBIWASM_RELEASE = "${libiwasm-baremetal-release}/lib";
CROSSCC = "${i386_pkgs.buildPackages.gcc}/bin/i386-elf-gcc"; LIBIWASM_LINUX_DEBUG = "${libiwasm-linux-debug}/lib";
CROSSCXX = "${i386_pkgs.buildPackages.gcc}/bin/i386-elf-g++"; LIBIWASM_LINUX_RELEASE = "${libiwasm-linux-release}/lib";
CROSS_CC = "${i386_pkgs.stdenv.cc}/bin/i386-elf-gcc";
CROSS_CXX = "${i386_pkgs.stdenv.cc}/bin/i386-elf-g++";
LINUX_CC = "${pkgs.multiStdenv.cc}/bin/gcc";
LINUX_CXX = "${pkgs.multiStdenv.cc}/bin/g++";
}; };
}; };
}); });

262
justfile
View File

@ -7,10 +7,31 @@ WASI_ROOT := env("WASI_ROOT")
WAMR_ROOT := env("WAMR_ROOT") WAMR_ROOT := env("WAMR_ROOT")
LIBIWASM_DEBUG := env("LIBIWASM_DEBUG") LIBIWASM_DEBUG := env("LIBIWASM_DEBUG")
LIBIWASM_RELEASE := env("LIBIWASM_RELEASE") LIBIWASM_RELEASE := env("LIBIWASM_RELEASE")
CROSS_CC := env("CROSSCC") LIBIWASM_LINUX_DEBUG := env("LIBIWASM_LINUX_DEBUG")
CROSS_CXX := env("CROSSCXX") LIBIWASM_LINUX_RELEASE := env("LIBIWASM_LINUX_RELEASE")
CROSS_CC := env("CROSS_CC")
LINUX_CC := env("LINUX_CC")
# C -> WASM # =================================================================================================================== #
# Helper recipes
# =================================================================================================================== #
[default]
[private]
list:
@just --list --unsorted
[private]
create-build-dir module:
mkdir -p {{ BUILD_DIR }}-{{ module }}
[doc("Delete the build directory")]
clean module:
rm -rf {{ BUILD_DIR }}-{{ module }}
# =================================================================================================================== #
# Build WASM module recipes
# =================================================================================================================== #
WASI_CC := f"{{WASI_ROOT}}/bin/clang" WASI_CC := f"{{WASI_ROOT}}/bin/clang"
WASI_CFLAGS := "\ WASI_CFLAGS := "\
@ -26,9 +47,6 @@ WASI_CFLAGS := "\
-Wl,--export=__heap_base \ -Wl,--export=__heap_base \
-Wl,--export=__data_end \ -Wl,--export=__data_end \
" "
# WASM -> AOT
WAMRC := "wamrc" WAMRC := "wamrc"
WAMRCFLAGS := "\ WAMRCFLAGS := "\
--target=i386 \ --target=i386 \
@ -37,7 +55,25 @@ WAMRCFLAGS := "\
" "
XXD := "xxd" XXD := "xxd"
# Load AOT from WAMR (FAIL+Baremetal) [doc("C -> WASM: Compile a C function to a WASM module using WASI-SDK")]
[group("build-module")]
build-wasm-module module: (create-build-dir module)
{{ WASI_CC }} {{ WASI_CFLAGS }} targets/wasm-module/{{ module }}.c -o {{ BUILD_DIR }}-{{ module }}/wasm_module.wasm
[doc("WASM -> AOT: Compile a WASM module ahead-of-time using WAMR")]
[group("build-module")]
build-wasm-aot module: (build-wasm-module module)
{{ WAMRC }} {{ WAMRCFLAGS }} -o {{ BUILD_DIR }}-{{ module }}/wasm_module.aot {{ BUILD_DIR }}-{{ module }}/wasm_module.wasm
[doc("AOT -> C-Array: Dump a WASM module compiled ahead-of-time to a binary array")]
[group("build-module")]
build-wasm-aot-array module: (build-wasm-aot module)
{{ XXD }} -i {{ BUILD_DIR }}-{{ module }}/wasm_module.aot > {{ BUILD_DIR }}-{{ module }}/wasm_module_array.c
# =================================================================================================================== #
# Host program recipes
# =================================================================================================================== #
# FAIL*
CROSS_CFLAGS := "\ CROSS_CFLAGS := "\
-I./targets/wasm-host \ -I./targets/wasm-host \
@ -66,38 +102,63 @@ CROSS_INCLUDES := f"\
-I{{WAMR_ROOT}}/core/shared/platform/baremetal \ -I{{WAMR_ROOT}}/core/shared/platform/baremetal \
" "
# Build recipes # LINUX-POSIX
[default] LINUX_CFLAGS := "\
[private] -I./targets/wasm-host \
list: -O0 \
@just --list --unsorted -m32 \
-ffunction-sections \
-fdata-sections \
-ggdb \
"
LINUX_LDFLAGS := f"\
-Wl,--build-id=none \
-m32 \
-Wl,-rpath,{{LIBIWASM_LINUX_DEBUG}} \
-L{{LIBIWASM_LINUX_DEBUG}} \
-liwasm \
-lm \
"
LINUX_INCLUDES := f"\
-I{{WAMR_ROOT}}/core/iwasm/include \
-I{{WAMR_ROOT}}/core/shared/utils \
-I{{WAMR_ROOT}}/core/shared/platform/linux \
"
[private] # LINUX-Baremetal
create-build-dir module:
mkdir -p {{ BUILD_DIR }}-{{ module }}
[doc("Delete the build directory")] LINUX_BAREMETAL_CFLAGS := "\
clean module: -I./targets/wasm-host \
rm -rf {{ BUILD_DIR }}-{{ module }} -O0 \
-m32 \
-ffunction-sections \
-fdata-sections \
-ffreestanding \
-ggdb \
"
LINUX_BAREMETAL_LDFLAGS := f"\
-Wl,--build-id=none \
-static \
-nostdlib \
-m32 \
-L{{LIBIWASM_DEBUG}} \
-liwasm \
-lc \
-lgcc \
-lm \
--entry main \
"
LINUX_BAREMETAL_INCLUDES := f"\
-I{{WAMR_ROOT}}/core/iwasm/include \
-I{{WAMR_ROOT}}/core/shared/utils \
-I{{WAMR_ROOT}}/core/shared/platform/baremetal \
"
[doc("C -> WASM: Compile a C function to a WASM module using WASI-SDK")] # TODO: Grave mistake to template the commands depending on the target... Should've used shebang recipes instead
[group("build")]
build-wasm-module module: (create-build-dir module)
{{ WASI_CC }} {{ WASI_CFLAGS }} targets/wasm-module/{{ module }}.c -o {{ BUILD_DIR }}-{{ module }}/wasm_module.wasm
[doc("WASM -> AOT: Compile a WASM module ahead-of-time using WAMR")]
[group("build")]
build-wasm-aot module: (build-wasm-module module)
{{ WAMRC }} {{ WAMRCFLAGS }} -o {{ BUILD_DIR }}-{{ module }}/wasm_module.aot {{ BUILD_DIR }}-{{ module }}/wasm_module.wasm
[doc("AOT -> C-Array: Dump a WASM module compiled ahead-of-time to a binary array")]
[group("build")]
build-wasm-aot-array module: (build-wasm-aot module)
{{ XXD }} -i {{ BUILD_DIR }}-{{ module }}/wasm_module.aot > {{ BUILD_DIR }}-{{ module }}/wasm_module_array.c
[doc("Compile C-Host: The host uses WAMR to load the AOT module")] [doc("Compile C-Host: The host uses WAMR to load the AOT module")]
[group("build")] [group("build-host")]
build-wasm-host module target="fail": (build-wasm-aot-array module) build-wasm-host module target="fail": (build-wasm-aot-array module)
cp targets/wasm-host/{{ target }}.c {{ BUILD_DIR }}-{{ module }}/module_host.c cp targets/wasm-host/{{ target }}.c {{ BUILD_DIR }}-{{ module }}/module_host.c
sed -i \ sed -i \
@ -105,50 +166,53 @@ build-wasm-host module target="fail": (build-wasm-aot-array module)
-e "s/__WASM_ARRAY__/build_{{ module }}_wasm_module_aot/g" \ -e "s/__WASM_ARRAY__/build_{{ module }}_wasm_module_aot/g" \
-e "s/__WASM_ARRAY_LEN__/build_{{ module }}_wasm_module_aot_len/g" \ -e "s/__WASM_ARRAY_LEN__/build_{{ module }}_wasm_module_aot_len/g" \
{{ BUILD_DIR }}-{{ module }}/module_host.c {{ BUILD_DIR }}-{{ module }}/module_host.c
{{ CROSS_CC }} {{ CROSS_CFLAGS }} {{ CROSS_INCLUDES }} \
-c {{ BUILD_DIR }}-{{ module }}/module_host.c \ # Build depending on the target platform
-o {{ BUILD_DIR }}-{{ module }}/system.o {{ if target == "fail" { CROSS_CC + " " + CROSS_CFLAGS + " " + CROSS_INCLUDES } else if target == "linux" { LINUX_CC + " " + LINUX_CFLAGS + " " + LINUX_INCLUDES } else if target == "linux-baremetal" { CROSS_CC + " " + LINUX_BAREMETAL_CFLAGS + " " + LINUX_BAREMETAL_INCLUDES } else { error("invalid target") } }} \
-c {{ BUILD_DIR }}-{{ module }}/module_host.c \
-o {{ BUILD_DIR }}-{{ module }}/system.o
[doc("Compile bootloader")] [doc("Compile bootloader")]
[group("build")] [group("build-host")]
build-system-startup module: build-system-startup module target="fail":
{{ CROSS_CC }} targets/startup.s {{ CROSS_CFLAGS }} -c -o {{ BUILD_DIR }}-{{ module }}/startup.o {{ if target == "fail" { CROSS_CC } else if target == "linux" { LINUX_CC } else if target == "linux-baremetal" { CROSS_CC } else { error("invalid target") } }} \
targets/startup.s \
{{ if target == "fail" { CROSS_CFLAGS } else if target == "linux" { LINUX_CFLAGS } else if target == "linux-baremetal" { LINUX_BAREMETAL_CFLAGS } else { error("invalid target") } }} \
-c -o {{ BUILD_DIR }}-{{ module }}/startup.o
[doc("Compile newlib syscall stubs")] [doc("Compile newlib syscall stubs")]
[group("build")] [group("build-host")]
build-system-syscalls module: build-system-syscalls module target="fail":
{{ CROSS_CC }} targets/syscalls.c {{ CROSS_CFLAGS }} -c -o {{ BUILD_DIR }}-{{ module }}/syscalls.o {{ if target == "fail" { CROSS_CC } else if target == "linux" { LINUX_CC } else if target == "linux-baremetal" { CROSS_CC } else { error("invalid target") } }} \
targets/syscalls.c \
{{ if target == "fail" { CROSS_CFLAGS } else if target == "linux" { LINUX_CFLAGS } else if target == "linux-baremetal" { LINUX_BAREMETAL_CFLAGS } else { error("invalid target") } }} \
-c -o {{ BUILD_DIR }}-{{ module }}/syscalls.o
[doc("Link C-Host, syscall stubs and bootloader")] [doc("Link C-Host, syscall stubs and bootloader")]
[group("build")] [group("build-host")]
build-system module target="fail": (build-wasm-host module target) (build-system-syscalls module) (build-system-startup module) link-system module target="fail": (build-wasm-host module target) (build-system-syscalls module target) (build-system-startup module target)
{{ CROSS_CC }} -Wl,-T targets/linker.ld \ {{ if target == "fail" { CROSS_CC } else if target == "linux" { LINUX_CC } else if target == "linux-baremetal" { CROSS_CC } else { error("invalid target") } }} \
{{ if target == "fail" { "-Wl,-T targets/linker.ld" } else { "" } }} \
{{ BUILD_DIR }}-{{ module }}/system.o \ {{ BUILD_DIR }}-{{ module }}/system.o \
{{ BUILD_DIR }}-{{ module }}/syscalls.o \ {{ if target == "fail" { f"{{BUILD_DIR}}-{{module}}/syscalls.o" + " " + f"{{BUILD_DIR}}-{{module}}/startup.o" } else { "" } }} \
{{ BUILD_DIR }}-{{ module }}/startup.o \ {{ if target == "linux-baremetal" { f"{{BUILD_DIR}}-{{module}}/syscalls.o" } else { "" } }} \
{{ CROSS_LDFLAGS }} -o {{ BUILD_DIR }}-{{ module }}/system.elf {{ if target == "fail" { CROSS_LDFLAGS } else if target == "linux" { LINUX_LDFLAGS } else if target == "linux-baremetal" { LINUX_BAREMETAL_LDFLAGS } else { error("invalid target") } }} \
-o {{ BUILD_DIR }}-{{ module }}/system.elf
[doc("Create bootdisk")] [doc("Create bootdisk")]
[group("build")] [group("build-host")]
build-iso module target="fail": (build-system module target) build-iso module target="fail": (link-system module target)
mkdir -p {{ BUILD_DIR }}-{{ module }}/grub/boot/grub mkdir -p {{ BUILD_DIR }}-{{ module }}/grub/boot/grub
cp targets/grub.cfg {{ BUILD_DIR }}-{{ module }}/grub/boot/grub/ cp targets/grub.cfg {{ BUILD_DIR }}-{{ module }}/grub/boot/grub/
cp {{ BUILD_DIR }}-{{ module }}/system.elf {{ BUILD_DIR }}-{{ module }}/grub/boot/ cp {{ BUILD_DIR }}-{{ module }}/system.elf {{ BUILD_DIR }}-{{ module }}/grub/boot/
grub-mkrescue -o {{ BUILD_DIR }}-{{ module }}/system.iso {{ BUILD_DIR }}-{{ module }}/grub grub-mkrescue -o {{ BUILD_DIR }}-{{ module }}/system.iso {{ BUILD_DIR }}-{{ module }}/grub
# FAIL* recipes # =================================================================================================================== #
# MySQL recipes
BOCHS_RUNNER := "bochs-experiment-runner.py" # =================================================================================================================== #
FAIL_TRACE := "fail-x86-tracing"
FAIL_DUMP := "dump-trace"
FAIL_IMPORT := "import-trace --database-option-file ./db.conf"
FAIL_PRUNE := "prune-trace --database-option-file ./db.conf"
FAIL_SERVER := "generic-experiment-server --database-option-file ./db.conf"
FAIL_INJECT := "generic-experiment-client"
RESULT_BROWSER := "resultbrowser.py -c ./db.conf"
[doc("Start MySQL container to receive FAIL* trace/campaign results")] [doc("Start MySQL container to receive FAIL* trace/campaign results")]
[group("fail")] [group("fail-db")]
start-db: start-db:
docker run -d \ docker run -d \
--name fail-db \ --name fail-db \
@ -160,20 +224,33 @@ start-db:
mysql mysql
[doc("Connect to MySQL database using DBeaver")] [doc("Connect to MySQL database using DBeaver")]
[group("fail")] [group("fail-db")]
connect-db: connect-db:
dbeaver -con "name=fail|driver=mysql|host=localhost|port=3306|database=fail|user=fail|password=fail" dbeaver -con "name=fail|driver=mysql|host=localhost|port=3306|database=fail|user=fail|password=fail"
[doc("Stop MySQL container")] [doc("Stop MySQL container")]
[group("fail")] [group("fail-db")]
stop-db: stop-db:
docker stop fail-db docker stop fail-db
[doc("Remove MySQL container")] [doc("Remove MySQL container")]
[group("fail")] [group("fail-db")]
remove-db: remove-db:
docker container rm fail-db docker container rm fail-db
# =================================================================================================================== #
# FAIL* recipes
# =================================================================================================================== #
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"
[doc("Trace a golden run using FAIL*")] [doc("Trace a golden run using FAIL*")]
[group("fail")] [group("fail")]
trace module: trace module:
@ -201,33 +278,50 @@ trace module:
[doc("Import a FAIL* golden run trace")] [doc("Import a FAIL* golden run trace")]
[group("fail")] [group("fail")]
import module: import module:
{{ FAIL_IMPORT }} -t {{ BUILD_DIR }}-{{ module }}/trace.pb -i MemoryImporter \ {{ FAIL_IMPORT }} --database-option-file ./db.conf -t {{ BUILD_DIR }}-{{ module }}/trace.pb \
-i MemoryImporter \
-e {{ BUILD_DIR }}-{{ module }}/system.elf -v {{ module }} -b mem -e {{ BUILD_DIR }}-{{ module }}/system.elf -v {{ module }} -b mem
{{ FAIL_IMPORT }} -t {{ BUILD_DIR }}-{{ module }}/trace.pb -i RegisterImporter \ {{ FAIL_IMPORT }} --database-option-file ./db.conf -t {{ BUILD_DIR }}-{{ module }}/trace.pb \
-i RegisterImporter \
-e {{ BUILD_DIR }}-{{ module }}/system.elf -v {{ module }} -b regs --flags -e {{ BUILD_DIR }}-{{ module }}/system.elf -v {{ module }} -b regs --flags
{{ FAIL_IMPORT }} -t {{ BUILD_DIR }}-{{ module }}/trace.pb -i RegisterImporter \ {{ FAIL_IMPORT }} --database-option-file ./db.conf -t {{ BUILD_DIR }}-{{ module }}/trace.pb \
-i RegisterImporter \
-e {{ BUILD_DIR }}-{{ module }}/system.elf -v {{ module }} -b ip --no-gp --ip -e {{ BUILD_DIR }}-{{ module }}/system.elf -v {{ module }} -b ip --no-gp --ip
{{ FAIL_IMPORT }} -t {{ BUILD_DIR }}-{{ module }}/trace.pb -i ElfImporter --objdump objdump \
{{ FAIL_IMPORT }} --database-option-file ./db.conf -t {{ BUILD_DIR }}-{{ module }}/trace.pb \
-i ElfImporter --objdump objdump \
-e {{ BUILD_DIR }}-{{ module }}/system.elf -v {{ module }} -b ip -e {{ BUILD_DIR }}-{{ module }}/system.elf -v {{ module }} -b ip
{{ FAIL_IMPORT }} -t {{ BUILD_DIR }}-{{ module }}/trace.pb -i ElfImporter --objdump objdump \ {{ FAIL_IMPORT }} --database-option-file ./db.conf -t {{ BUILD_DIR }}-{{ module }}/trace.pb \
-i ElfImporter --objdump objdump \
-e {{ BUILD_DIR }}-{{ module }}/system.elf -v {{ module }} -b mem -e {{ BUILD_DIR }}-{{ module }}/system.elf -v {{ module }} -b mem
{{ FAIL_IMPORT }} -t {{ BUILD_DIR }}-{{ module }}/trace.pb -i ElfImporter --objdump objdump \ {{ FAIL_IMPORT }} --database-option-file ./db.conf -t {{ BUILD_DIR }}-{{ module }}/trace.pb \
-i ElfImporter --objdump objdump \
-e {{ BUILD_DIR }}-{{ module }}/system.elf -v {{ module }} -b regs -e {{ BUILD_DIR }}-{{ module }}/system.elf -v {{ module }} -b regs
{{ FAIL_IMPORT }} -t {{ BUILD_DIR }}-{{ module }}/trace.pb -i ElfImporter --objdump objdump \
{{ FAIL_IMPORT }} --database-option-file ./db.conf -t {{ BUILD_DIR }}-{{ module }}/trace.pb \
-i ElfImporter --objdump objdump \
-e {{ BUILD_DIR }}-{{ module }}/system.elf -v {{ module }} -b ip --sources -e {{ BUILD_DIR }}-{{ module }}/system.elf -v {{ module }} -b ip --sources
{{ FAIL_IMPORT }} -t {{ BUILD_DIR }}-{{ module }}/trace.pb -i ElfImporter --objdump objdump \ {{ FAIL_IMPORT }} --database-option-file ./db.conf -t {{ BUILD_DIR }}-{{ module }}/trace.pb \
-i ElfImporter --objdump objdump \
-e {{ BUILD_DIR }}-{{ module }}/system.elf -v {{ module }} -b mem --sources -e {{ BUILD_DIR }}-{{ module }}/system.elf -v {{ module }} -b mem --sources
{{ FAIL_IMPORT }} -t {{ BUILD_DIR }}-{{ module }}/trace.pb -i ElfImporter --objdump objdump \ {{ FAIL_IMPORT }} --database-option-file ./db.conf -t {{ BUILD_DIR }}-{{ module }}/trace.pb \
-i ElfImporter --objdump objdump \
-e {{ BUILD_DIR }}-{{ module }}/system.elf -v {{ module }} -b regs --sources -e {{ BUILD_DIR }}-{{ module }}/system.elf -v {{ module }} -b regs --sources
{{ FAIL_PRUNE }} -v {{ module }} -b %% --overwrite
{{ FAIL_PRUNE }} --database-option-file ./db.conf -v {{ module }} -b %% --overwrite
@echo "Next step: \"just server {{ module }}\"" @echo "Next step: \"just server {{ module }}\""
[doc("Start the FAIL* campaign server")] [doc("Start the FAIL* campaign server")]
[group("fail")] [group("fail")]
server module: server module:
{{ FAIL_SERVER }} -v {{ module }} -b % --inject-single-bit --inject-registers & {{ FAIL_SERVER }} --database-option-file ./db.conf -v {{ module }} -b % --inject-single-bit --inject-registers &
@echo "Next step: \"just client {{ module }}\"" @echo "Next step: \"just client {{ module }}\""
[doc("Stop the FAIL* campaign server")]
[group("fail")]
stop-server:
pkill -f {{ FAIL_SERVER }}
[doc("Start a FAIL* campaign client")] [doc("Start a FAIL* campaign client")]
[group("fail")] [group("fail")]
client module: client module:
@ -244,7 +338,7 @@ client module:
-Wf,--timeout=500000 \ -Wf,--timeout=500000 \
-Wf,--ok-marker=ok_marker \ -Wf,--ok-marker=ok_marker \
-Wf,--fail-marker=fail_marker \ -Wf,--fail-marker=fail_marker \
2>/dev/null | grep -B 2 -A 8 'INJECT' > /dev/null
@echo "Next step: \"just result {{ module }}\" or \"just resultbrowser\"" @echo "Next step: \"just result {{ module }}\" or \"just resultbrowser\""
[doc("Query FAIL* marker statistics from the database")] [doc("Query FAIL* marker statistics from the database")]
@ -263,4 +357,18 @@ result module:
[doc("Start the FAIL* resultbrowser")] [doc("Start the FAIL* resultbrowser")]
[group("fail")] [group("fail")]
resultbrowser: resultbrowser:
{{ RESULT_BROWSER }} --host=0.0.0.0 --port=5000 {{ RESULT_BROWSER }} -c ./db.conf --host=0.0.0.0 --port=5000
# =================================================================================================================== #
# Debugging recipes
# =================================================================================================================== #
[doc("Launch radare2 at os_main")]
[group("debug")]
radare module:
radare2 -AA -c "s dbg.os_main; pdf" {{ BUILD_DIR }}-{{ module }}/system.elf
[doc("Launch gdb")]
[group("debug")]
gdb module:
gdb --tui {{ BUILD_DIR }}-{{ module }}/system.elf