about summary refs log tree commit diff homepage
path: root/scripts/build/v-sanitizer.inc
diff options
context:
space:
mode:
authorMartin Nowack <m.nowack@imperial.ac.uk>2023-02-23 22:01:12 +0000
committerCristian Cadar <c.cadar@imperial.ac.uk>2023-03-17 22:38:16 +0000
commitca60811f5d55254bec378919430dd0e7e6e5cdd1 (patch)
treedbd4f7a78929eb959e26755c22e5157808a09862 /scripts/build/v-sanitizer.inc
parentdd492f8763f13312c17eb67af33e3e90217a30e1 (diff)
downloadklee-ca60811f5d55254bec378919430dd0e7e6e5cdd1.tar.gz
Update build scripts
* Support for Ubuntu 22.04
* Remove support for Python2
* Better separation between sanitizer builds and non-sanitizer builds
* Fix build of metaSMT on newer Ubuntu versions
* Use ninja to build LLVM
* Simplifying building arbitrary LLVM configurations, e.g. different
  LLVM sanitizer builds (MemSan, UBSan, ASan)
* Use MemSan with origin tracking
* Build sqlite3 container correctly
* Add support to provide sqlite3 version number
Diffstat (limited to 'scripts/build/v-sanitizer.inc')
-rw-r--r--scripts/build/v-sanitizer.inc28
1 files changed, 26 insertions, 2 deletions
diff --git a/scripts/build/v-sanitizer.inc b/scripts/build/v-sanitizer.inc
index b86ef23f..09005df0 100644
--- a/scripts/build/v-sanitizer.inc
+++ b/scripts/build/v-sanitizer.inc
@@ -75,8 +75,8 @@ setup_variables_sanitizer() {
     # Undefined Behaviour Sanitizer
     if [ "${sanitizer}" == "undefined" ]; then
       echo "Using UBSan"
-      flags=("-fsanitize=undefined" "-fno-omit-frame-pointer" "-g"
-             "-fno-sanitize-recover=undefined")
+      # Allow to recover from any undefined behaviour
+      flags=("-fsanitize=undefined" "-fno-omit-frame-pointer" "-g" "-fsanitize-recover=signed-integer-overflow,alignment,vptr")
       SANITIZER_CXX_FLAGS+=("${flags[@]}")
       SANITIZER_C_FLAGS+=("${flags[@]}")
       SANITIZER_LD_FLAGS+=("${flags[@]}")
@@ -87,6 +87,30 @@ setup_variables_sanitizer() {
     # Memory Sanitizer
     if [ "${sanitizer}" == "memory" ]; then
       echo "Using Memory Sanitizer"
+      # Generate full sanitizer ignore file.
+      cat "${DIR}/sanitizer/"*.txt > "${BASE}/sanitizer_ignore.txt"
+      flags=("-fsanitize=memory" "-fno-omit-frame-pointer" "-g" "-fsanitize-memory-track-origins" "-fsanitize-ignorelist=${BASE}/sanitizer_ignore.txt")
+
+      if [[ -n "${LLVM_VERSION:-}" ]]; then
+        # Workaround as we have to pull in MemSan-instrumented libcxx
+        local LLVM_BUILD_LIBCXX="${BASE}/llvm-${LLVM_VERSION}0-install_NO_D_A_memsan-libcxx"
+        if [[ -d "${LLVM_BUILD_LIBCXX}" ]]; then
+          SANITIZER_CXX_FLAGS+=(
+            "-nostdinc++"
+            "-isystem ${LLVM_BUILD_LIBCXX}/include"
+            "-isystem ${LLVM_BUILD_LIBCXX}/include/c++/v1"
+          )
+          SANITIZER_LD_FLAGS+=(
+            "-lc++abi"
+            "-Wl,--rpath=${LLVM_BUILD_LIBCXX}/lib"
+            "-L${LLVM_BUILD_LIBCXX}/lib"
+            "-stdlib=libc++"
+          )
+        fi
+      fi
+      SANITIZER_CXX_FLAGS+=("${flags[@]}")
+      SANITIZER_C_FLAGS+=("${flags[@]}")
+      SANITIZER_LD_FLAGS+=("${flags[@]}")
       SANITIZER_SUFFIX+="_memsan"
       continue
     fi