]> granicus.if.org Git - libvpx/commitdiff
add cfi sanitizer
authorJohann <johann.koenig@duck.com>
Wed, 26 Sep 2018 23:52:54 +0000 (16:52 -0700)
committerJohann <johann.koenig@duck.com>
Wed, 26 Sep 2018 23:52:54 +0000 (16:52 -0700)
Change-Id: I4262bb631c248ad188f09a37d774d1759695b0d7

tools/set_analyzer_env.sh

index 17869ee890438629006bbb8920e00a8a04f8841d..814a0e7fd0d1e5a699b54753c5be98f43293e1cc 100644 (file)
@@ -13,6 +13,7 @@ sanitizer="${1}"
 
 case "${sanitizer}" in
   address) ;;
+  cfi) ;;
   integer) ;;
   memory) ;;
   thread) ;;
@@ -20,7 +21,7 @@ case "${sanitizer}" in
   clear)
     echo "Clearing environment:"
     set -x
-    unset CC CXX LD
+    unset CC CXX LD AR
     unset CFLAGS CXXFLAGS LDFLAGS
     unset ASAN_OPTIONS MSAN_OPTIONS TSAN_OPTIONS UBSAN_OPTIONS
     set +x
@@ -74,6 +75,13 @@ cflags="${cflags} -fno-omit-frame-pointer"
 # Exact backtraces.
 cflags="${cflags} -fno-optimize-sibling-calls"
 
+if [ "${sanitizer}" = "cfi" ]; then
+  # https://clang.llvm.org/docs/ControlFlowIntegrity.html
+  cflags="${cflags} -flto -fvisibility=hidden"
+  ldflags="${ldflags} -flto -fuse-ld=gold"
+  export AR="llvm-ar"
+fi
+
 set -x
 export CC="clang"
 export CXX="clang++"
@@ -100,6 +108,9 @@ case "${sanitizer}" in
     export ASAN_OPTIONS="${sanitizer_options}"
     set +x
     ;;
+  cfi)
+    # No environment settings
+    ;;
   memory)
     set -x
     export MSAN_OPTIONS="${sanitizer_options}"