diff options
author | chefmax <chefmax@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-07-07 14:31:18 +0000 |
---|---|---|
committer | chefmax <chefmax@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-07-07 14:31:18 +0000 |
commit | a3127434faad3a3bc58923573d536a1a9338ac86 (patch) | |
tree | db570b973c519ea2a1d227f61cc00851a179b8e7 /gcc | |
parent | f6e77fc4095c59ee44ff66dc6df8b9621bab08d0 (diff) | |
download | gcc-a3127434faad3a3bc58923573d536a1a9338ac86.tar.gz |
Do not instrument first byte in strlen if already instrumented.
gcc/
* asan.c (instrument_strlen_call): Do not instrument first byte in strlen
if already instrumented.
gcc/testsuite/
* c-c++-common/asan/no-redundant-instrumentation-9.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@212332 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/asan.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-9.c | 13 |
4 files changed, 25 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f1115223d11..69cc4d2f7a1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-06-24 Max Ostapenko <m.ostapenko@partner.samsung.com> + + * asan.c (instrument_strlen_call): Do not instrument first byte in strlen + if already instrumented. + 2014-07-07 Kyrylo Tkachov <kyrylo.tkachov@arm.com> * config/arm/arm.opt (mwords-little-endian): Delete. diff --git a/gcc/asan.c b/gcc/asan.c index 9eeafa897cf..20d78df5e15 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -2026,6 +2026,7 @@ instrument_strlen_call (gimple_stmt_iterator *iter) location_t loc = gimple_location (call); tree str_arg = gimple_call_arg (call, 0); + bool start_instrumented = has_mem_ref_been_instrumented (str_arg, 1); tree cptr_type = build_pointer_type (char_type_node); gimple str_arg_ssa = @@ -2037,7 +2038,8 @@ instrument_strlen_call (gimple_stmt_iterator *iter) build_check_stmt (loc, gimple_assign_lhs (str_arg_ssa), NULL_TREE, 1, iter, /*non_zero_len_p*/true, /*before_p=*/true, - /*is_store=*/false, /*is_scalar_access*/true, /*align*/0); + /*is_store=*/false, /*is_scalar_access*/true, /*align*/0, + start_instrumented, start_instrumented); gimple g = gimple_build_assign_with_ops (POINTER_PLUS_EXPR, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 75b9bf7e9cc..fae51c2ffbe 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-06-24 Max Ostapenko <m.ostapenko@partner.samsung.com> + + * c-c++-common/asan/no-redundant-instrumentation-9.c: New test. + 2014-07-07 Paolo Carlini <paolo.carlini@oracle.com> PR c++/58898 diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-9.c b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-9.c new file mode 100644 index 00000000000..c6575ad0b94 --- /dev/null +++ b/gcc/testsuite/c-c++-common/asan/no-redundant-instrumentation-9.c @@ -0,0 +1,13 @@ +/* { dg-options "-fdump-tree-asan0" } */ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */ + +__SIZE_TYPE__ +f (char *a) +{ + a[0] = '1'; + return __builtin_strlen (a); +} + +/* { dg-final { scan-tree-dump-times "__asan_report_load1" 1 "asan0" } } */ +/* { dg-final { cleanup-tree-dump "asan0" } } */ |