set_analyzer_env.sh: improve cfi diagnostics
authorJames Zern <jzern@google.com>
Fri, 15 Mar 2019 06:07:23 +0000 (23:07 -0700)
committerJames Zern <jzern@google.com>
Fri, 15 Mar 2019 06:07:23 +0000 (23:07 -0700)
use -fno-sanitize-trap=cfi to allow a diagnostic to be printed rather
than aborting with a SIGILL.

https://clang.llvm.org/docs/ControlFlowIntegrity.html#trapping-and-diagnostics

Change-Id: I4517cafe3c7b7305ba4845dbadf9fb679c686843

tools/set_analyzer_env.sh

index 814a0e7..8ee0c4f 100644 (file)
@@ -30,7 +30,7 @@ case "${sanitizer}" in
   *)
     echo "Usage: source set_analyzer_env.sh [<sanitizer>|clear]"
     echo "  Supported sanitizers:"
-    echo "    address integer memory thread undefined"
+    echo "    address cfi integer memory thread undefined"
     return 1
     ;;
 esac
@@ -77,8 +77,8 @@ 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"
+  cflags="${cflags} -fno-sanitize-trap=cfi -flto -fvisibility=hidden"
+  ldflags="${ldflags} -fno-sanitize-trap=cfi -flto -fuse-ld=gold"
   export AR="llvm-ar"
 fi