aboutsummaryrefslogtreecommitdiff
path: root/gcc/asan.c
diff options
context:
space:
mode:
authorMaxim Ostapenko <m.ostapenko@samsung.com>2017-07-06 16:05:00 +0000
committerMaxim Ostapenko <chefmax@gcc.gnu.org>2017-07-06 19:05:00 +0300
commit5094f7d540ff2f8ccbb3b78a0962a07ffa5960cb (patch)
treeabe11990d7fbf767d605ed325548aeca19664586 /gcc/asan.c
parente3174bdf35c172f69daf08350401aa177f8f1498 (diff)
downloadgcc-5094f7d540ff2f8ccbb3b78a0962a07ffa5960cb.zip
gcc-5094f7d540ff2f8ccbb3b78a0962a07ffa5960cb.tar.gz
gcc-5094f7d540ff2f8ccbb3b78a0962a07ffa5960cb.tar.bz2
asan.h (asan_sanitize_allocas_p): Declare.
gcc/ * asan.h (asan_sanitize_allocas_p): Declare. * asan.c (asan_sanitize_allocas_p): New function. (handle_builtin_stack_restore): Bail out if !asan_sanitize_allocas_p. (handle_builtin_alloca): Likewise. * cfgexpand.c (expand_used_vars): Do not add allocas unpoisoning stuff if !asan_sanitize_allocas_p. * params.def (asan-instrument-allocas): Add new option. * params.h (ASAN_PROTECT_ALLOCAS): Define. * opts.c (common_handle_option): Disable allocas sanitization for KASan by default. gcc/testsuite/ * c-c++-common/asan/kasan-alloca-1.c: New test. * c-c++-common/asan/kasan-alloca-2.c: Likewise. From-SVN: r250032
Diffstat (limited to 'gcc/asan.c')
-rw-r--r--gcc/asan.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/asan.c b/gcc/asan.c
index 252e59f..95004d7 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -310,6 +310,12 @@ asan_sanitize_stack_p (void)
return (sanitize_flags_p (SANITIZE_ADDRESS) && ASAN_STACK);
}
+bool
+asan_sanitize_allocas_p (void)
+{
+ return (asan_sanitize_stack_p () && ASAN_PROTECT_ALLOCAS);
+}
+
/* Checks whether section SEC should be sanitized. */
static bool
@@ -569,7 +575,7 @@ get_last_alloca_addr ()
static void
handle_builtin_stack_restore (gcall *call, gimple_stmt_iterator *iter)
{
- if (!iter)
+ if (!iter || !asan_sanitize_allocas_p ())
return;
tree last_alloca = get_last_alloca_addr ();
@@ -607,7 +613,7 @@ handle_builtin_stack_restore (gcall *call, gimple_stmt_iterator *iter)
static void
handle_builtin_alloca (gcall *call, gimple_stmt_iterator *iter)
{
- if (!iter)
+ if (!iter || !asan_sanitize_allocas_p ())
return;
gassign *g;