about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorMartin Nowack <m.nowack@imperial.ac.uk>2019-03-10 21:02:03 +0000
committerCristian Cadar <c.cadar@imperial.ac.uk>2019-03-12 16:41:27 +0000
commit0afe438667c2173c458c5f45adfe99506a076c61 (patch)
tree29b78f624d7c44288a5563db1157e9a19e658ccd
parent07e70c253a62563780c09235b1c30ac482184e03 (diff)
downloadklee-0afe438667c2173c458c5f45adfe99506a076c61.tar.gz
Add integer sanitizer to UBSan
-rw-r--r--scripts/build/v-sanitizer.inc25
1 files changed, 14 insertions, 11 deletions
diff --git a/scripts/build/v-sanitizer.inc b/scripts/build/v-sanitizer.inc
index be9b3b39..9d605377 100644
--- a/scripts/build/v-sanitizer.inc
+++ b/scripts/build/v-sanitizer.inc
@@ -30,24 +30,29 @@ setup_variables_sanitizer() {
     SANITIZER_SUFFIX=""
     return 0
   fi
+
+  [[ -n ${SANITIZER_INIT+X} ]] && return 0
+  SANITIZER_INIT=1
+
   # Remove ":" separator
   local sanitizers
   local e
   local sorted_sanitizers
-  
+
   IFS=":" read -r -a sanitizers <<< "${SANITIZER_BUILD}"
   sorted_sanitizers=( $( for e in "${sanitizers[@]}"; do echo "$e"; done | sort) )
-  
-  	
+  SANITIZERS=("${sorted_sanitizers[@]}")
+
+
   # Set variables used by clients.
   ## Build variables
   [[ -z ${SANITIZER_CXX_FLAGS+x} ]] && SANITIZER_CXX_FLAGS=("")
   [[ -z ${SANITIZER_C_FLAGS+x} ]] && SANITIZER_C_FLAGS=("")
   [[ -z ${SANITIZER_LD_FLAGS+x} ]] && SANITIZER_LD_FLAGS=("")
-  
+
   # Docker_suffix
   SANITIZER_SUFFIX=""
-  
+
   local flags
   for sanitizer in "${sorted_sanitizers[@]}"; do
     [[ -z "${sanitizer}" ]] && continue
@@ -61,28 +66,26 @@ setup_variables_sanitizer() {
       SANITIZER_SUFFIX+="_asan"
       continue
     fi
-  
+
     # Undefined Behaviour Sanitizer
     if [ "${sanitizer}" == "undefined" ]; then
       echo "Using UBSan"
-      flags=("-fsanitize=undefined" "-fno-omit-frame-pointer" "-g")
+      flags=("-fsanitize=undefined" "-fno-omit-frame-pointer" "-g" "-fsanitize=integer")
       SANITIZER_CXX_FLAGS+=("${flags[@]}")
       SANITIZER_C_FLAGS+=("${flags[@]}")
       SANITIZER_LD_FLAGS+=("${flags[@]}" "-lubsan" "-fuse-ld=gold")
       SANITIZER_SUFFIX+="_ubsan"
       continue
     fi
-  
+
     # Undefined Behaviour Sanitizer
     if [ "${sanitizer}" == "memory" ]; then
       echo "Using Memory Sanitizer"
       SANITIZER_SUFFIX+="_memsan"
       continue
     fi
-  
+
     echo "Unknown sanitizer: $sanitizer"
     exit 1
   done
-  
-  SANITIZERS=("${sorted_sanitizers[@]}")
   }
\ No newline at end of file