ref: 3a291593726a3f0eff5e59983e84de20d0bf294c
parent: 97ff0463f40f6d7be26ba90e85fbf021bc2368ad
parent: 39ee898f89bec5aa6137df5ea3179b3564a328aa
author: Johann Koenig <johannkoenig@google.com>
date: Thu Sep 27 11:08:12 EDT 2018
Merge "add cfi sanitizer"
--- a/tools/set_analyzer_env.sh
+++ b/tools/set_analyzer_env.sh
@@ -13,6 +13,7 @@
case "${sanitizer}" in
address) ;;
+ cfi) ;;
integer) ;;
memory) ;;
thread) ;;
@@ -20,7 +21,7 @@
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 @@
# 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++"
@@ -99,6 +107,9 @@
set -x
export ASAN_OPTIONS="${sanitizer_options}"
set +x
+ ;;
+ cfi)
+ # No environment settings
;;
memory)
set -x