Unit + integration coverage for the session's work: incremental project graph/index, pcode encoder, unreachable/dead-branch, equiv/cross-TU, div-by-zero/sign-conversion/int-truncation, use-after-free, quality-precision, scan-router profile, source TU runner, detector plan, and the eval fixtures.
32 lines
1.4 KiB
Bash
Executable file
32 lines
1.4 KiB
Bash
Executable file
#!/bin/sh
|
|
# Build the binary CWE fixtures on Linux with a NATIVE gcc/clang (no zig
|
|
# checked-arithmetic runtime) — the "clean" toolchain recipe that macOS cannot
|
|
# produce (macOS clang cannot link a Linux ELF; zig cc is the only macOS
|
|
# cross-compiler and links in zig's checked-arithmetic runtime).
|
|
#
|
|
# Usage (from the repo root, Docker required):
|
|
# docker run --rm \
|
|
# -v "$PWD/tests/fixtures/binary/cwe:/fixtures:ro" \
|
|
# -v "$PWD/tests/fixtures/binary/cwe-linux:/out" \
|
|
# ubuntu:24.04 sh tests/fixtures/binary/build-linux.sh
|
|
#
|
|
# x86-64 ELF: use the gcc cross-compiler (gcc links the multiarch glibc cleanly;
|
|
# clang's --sysroot=... misses libc.so.6 on Debian/Ubuntu multiarch). Native
|
|
# aarch64 ELF: plain `clang` on an arm64 host. On GitHub Actions (ubuntu-latest,
|
|
# x86-64), plain `gcc` produces x86-64 ELF natively — no cross-compile needed.
|
|
set -e
|
|
|
|
apt-get update -qq >/dev/null 2>&1
|
|
apt-get install -y -qq gcc gcc-x86-64-linux-gnu >/dev/null 2>&1
|
|
|
|
mkdir -p /out
|
|
HOST_ARCH="$(uname -m)"
|
|
for c in cwe121_bof cwe369_div0 cwe190_overflow cwe476_nullderef cwe416_uaf clean; do
|
|
if [ "$HOST_ARCH" = "x86_64" ]; then
|
|
gcc -O0 -fno-stack-protector -s -o "/out/$c.elf" "/fixtures/$c.c"
|
|
else
|
|
# arm64 host: cross-compile x86-64 with gcc (matches the zig cc -target x86_64-linux-gnu recipe)
|
|
x86_64-linux-gnu-gcc -O0 -fno-stack-protector -s -o "/out/$c.elf" "/fixtures/$c.c"
|
|
fi
|
|
echo "built $c.elf ($HOST_ARCH)"
|
|
done
|