summaryrefslogtreecommitdiffstats
path: root/gcc/asan.c
diff options
context:
space:
mode:
authorchefmax <chefmax@138bc75d-0d04-0410-961f-82ee72b054a4>2014-01-09 07:31:05 +0000
committerchefmax <chefmax@138bc75d-0d04-0410-961f-82ee72b054a4>2014-01-09 07:31:05 +0000
commitbf2b7c225c336e6e5acc38b731e62caa11e74976 (patch)
tree58efd7774e722299ff68ff8583b43da062decab9 /gcc/asan.c
parent964c78273df75a75884113f4bcbab851fa074e0e (diff)
downloadppe42-gcc-bf2b7c225c336e6e5acc38b731e62caa11e74976.tar.gz
ppe42-gcc-bf2b7c225c336e6e5acc38b731e62caa11e74976.zip
2014-01-09 Max Ostapenko <m.ostapenko@partner.samsung.com>
* cfgexpand.c (expand_stack_vars): Optionally disable asan stack protection. (expand_used_vars): Likewise. (partition_stack_vars): Likewise. * asan.c (asan_emit_stack_protection): Optionally disable after return stack usage. (instrument_derefs): Optionally disable memory access instrumentation. (instrument_builtin_call): Likewise. (instrument_strlen_call): Likewise. (asan_protect_global): Optionally disable global variables protection. * doc/invoke.texi: Added doc for new options. * params.def: Added new options. * params.h: Likewise. 2014-01-09 Max Ostapenko <m.ostapenko@partner.samsung.com> * c-c++-common/asan/no-asan-globals.c: New test. * c-c++-common/asan/no-instrument-reads.c: Likewise. * c-c++-common/asan/no-instrument-writes.c: Likewise. * c-c++-common/asan/use-after-return-1.c: Likewise. * c-c++-common/asan/no-use-after-return.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206458 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/asan.c')
-rw-r--r--gcc/asan.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/asan.c b/gcc/asan.c
index e077153a969..53992a81b18 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -53,6 +53,7 @@ along with GCC; see the file COPYING3. If not see
#include "gimple-builder.h"
#include "ubsan.h"
#include "predict.h"
+#include "params.h"
/* AddressSanitizer finds out-of-bounds and use-after-free bugs
with <2x slowdown on average.
@@ -1003,7 +1004,8 @@ asan_emit_stack_protection (rtx base, rtx pbase, unsigned int alignb,
str_cst = asan_pp_string (&asan_pp);
/* Emit the prologue sequence. */
- if (asan_frame_size > 32 && asan_frame_size <= 65536 && pbase)
+ if (asan_frame_size > 32 && asan_frame_size <= 65536 && pbase
+ && ASAN_USE_AFTER_RETURN)
{
use_after_return_class = floor_log2 (asan_frame_size - 1) - 5;
/* __asan_stack_malloc_N guarantees alignment
@@ -1239,6 +1241,9 @@ asan_needs_local_alias (tree decl)
bool
asan_protect_global (tree decl)
{
+ if (!ASAN_GLOBALS)
+ return false;
+
rtx rtl, symbol;
if (TREE_CODE (decl) == STRING_CST)
@@ -1568,6 +1573,11 @@ static void
instrument_derefs (gimple_stmt_iterator *iter, tree t,
location_t location, bool is_store)
{
+ if (is_store && !ASAN_INSTRUMENT_WRITES)
+ return;
+ if (!is_store && !ASAN_INSTRUMENT_READS)
+ return;
+
tree type, base;
HOST_WIDE_INT size_in_bytes;
@@ -1897,6 +1907,9 @@ instrument_strlen_call (gimple_stmt_iterator *iter)
static bool
instrument_builtin_call (gimple_stmt_iterator *iter)
{
+ if (!ASAN_MEMINTRIN)
+ return false;
+
bool iter_advanced_p = false;
gimple call = gsi_stmt (*iter);
OpenPOWER on IntegriCloud