summaryrefslogtreecommitdiffstats
path: root/gcc/testsuite/c-c++-common/asan
Commit message (Collapse)AuthorAgeFilesLines
* 2014-10-25 Yury Gribov <y.gribov@samsung.com>ygribov2014-10-241-0/+20
| | | | | | | | | | | PR sanitizer/63638 * asan.c (enum asan_check_flags): Fixed ASAN_CHECK_LAST. * c-c++-common/asan/pr63638.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@216677 138bc75d-0d04-0410-961f-82ee72b054a4
* 2014-10-20 Yury Gribov <y.gribov@samsung.com>ygribov2014-10-202-0/+84
| | | | | | | | | | | Backported from mainline 2014-05-30 Jakub Jelinek <jakub@redhat.com> * c-c++-common/asan/misalign-1.c: New test. * c-c++-common/asan/misalign-2.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@216459 138bc75d-0d04-0410-961f-82ee72b054a4
* * asan.c (instrument_derefs): Allow instrumentation of odd-sizedjakub2014-10-172-2/+2
| | | | | | | | | | | | accesses even for -fsanitize=address. (execute_sanopt): Only allow use_calls for -fsanitize=kernel-address. * c-c++-common/asan/instrument-with-calls-1.c: Add -fno-sanitize=address -fsanitize=kernel-address to dg-options. * c-c++-common/asan/instrument-with-calls-2.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@216408 138bc75d-0d04-0410-961f-82ee72b054a4
* 2014-10-16 Yury Gribov <y.gribov@samsung.com>ygribov2014-10-162-0/+21
| | | | | | | | | | | | | | | | | | | | Backport from mainline 2014-09-01 Yury Gribov <y.gribov@samsung.com> PR sanitizer/61897 PR sanitizer/62140 * asan.c (asan_mem_ref_get_end): Handle non-ptroff_t lengths. (build_check_stmt): Likewise. (instrument_strlen_call): Likewise. (asan_expand_check_ifn): Likewise and fix types. (maybe_cast_to_ptrmode): New function. * c-c++-common/asan/pr62140-1.c: New test. * c-c++-common/asan/pr62140-2.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@216332 138bc75d-0d04-0410-961f-82ee72b054a4
* 2014-10-16 Yury Gribov <y.gribov@samsung.com>ygribov2014-10-165-0/+138
| | | | | | | | | | | | | | | | | | | | | | | Backport from mainline 2014-08-18 Yury Gribov <y.gribov@samsung.com> PR sanitizer/62089 * asan.c (instrument_derefs): Fix bitfield check. * c-c++-common/asan/pr62089.c: New test. * c-c++-common/asan/bitfield-1.c: New test. * c-c++-common/asan/bitfield-2.c: New test. * c-c++-common/asan/bitfield-3.c: New test. * c-c++-common/asan/bitfield-4.c: New test. Backport from mainline 2014-08-28 Yury Gribov <y.gribov@samsung.com> * c-c++-common/asan/pr62089.c: Fix test on 32-bit platforms. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@216331 138bc75d-0d04-0410-961f-82ee72b054a4
* Move inlining of Asan memory checks to sanopt pass.ygribov2014-10-1611-54/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change asan-instrumentation-with-call-threshold to more closely match LLVM. 2014-10-16 Yury Gribov <y.gribov@samsung.com> Backport from mainline 2014-08-11 Yury Gribov <y.gribov@samsung.com> * asan.c (asan_check_flags): New enum. (build_check_stmt_with_calls): Removed function. (build_check_stmt): Split inlining logic to asan_expand_check_ifn. (instrument_derefs): Rename parameter. (instrument_mem_region_access): Rename parameter. (instrument_strlen_call): Likewise. (asan_expand_check_ifn): New function. (asan_instrument): Remove old code. (pass_sanopt::execute): Change handling of asan-instrumentation-with-call-threshold. (asan_clear_shadow): Fix formatting. (asan_function_start): Likewise. (asan_emit_stack_protection): Likewise. * doc/invoke.texi (asan-instrumentation-with-call-threshold): Update description. * internal-fn.c (expand_ASAN_CHECK): New function. * internal-fn.def (ASAN_CHECK): New internal function. * params.def (PARAM_ASAN_INSTRUMENTATION_WITH_CALL_THRESHOLD): Update description. (PARAM_ASAN_USE_AFTER_RETURN): Likewise. * tree.c: Small comment fix. * c-c++-common/asan/inc.c: Update test. * c-c++-common/asan/instrument-with-calls-2.c: Likewise. * c-c++-common/asan/no-redundant-instrumentation-1.c: Likewise. * c-c++-common/asan/no-redundant-instrumentation-2.c: Likewise. * c-c++-common/asan/no-redundant-instrumentation-3.c: Likewise. * c-c++-common/asan/no-redundant-instrumentation-4.c: Likewise. * c-c++-common/asan/no-redundant-instrumentation-5.c: Likewise. * c-c++-common/asan/no-redundant-instrumentation-6.c: Likewise. * c-c++-common/asan/no-redundant-instrumentation-7.c: Likewise. * c-c++-common/asan/no-redundant-instrumentation-8.c: Likewise. * c-c++-common/asan/no-redundant-instrumentation-9.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@216330 138bc75d-0d04-0410-961f-82ee72b054a4
* Do not instrument first byte in strlen if already instrumented.ygribov2014-10-161-0/+13
| | | | | | | | | | | | | | | 2014-10-16 Yury Gribov <y.gribov@samsung.com> Backport from mainline 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. * c-c++-common/asan/no-redundant-instrumentation-9.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@216327 138bc75d-0d04-0410-961f-82ee72b054a4
* New asan-instrumentation-with-call-thresholdygribov2014-10-1611-21/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | parameter. 2014-10-16 Yury Gribov <y.gribov@samsung.com> Backport from mainline 2014-06-16 Yury Gribov <y.gribov@samsung.com> * asan.c (check_func): New function. (maybe_create_ssa_name): Likewise. (build_check_stmt_with_calls): Likewise. (use_calls_p): Likewise. (report_error_func): Change interface. (build_check_stmt): Allow non-integer lengths; add support for new parameter. (asan_instrument): Likewise. (instrument_mem_region_access): Moved code to build_check_stmt. (instrument_derefs): Likewise. (instrument_strlen_call): Likewise. * cfgcleanup.c (old_insns_match_p): Add support for new functions. * doc/invoke.texi: Describe new parameter. * params.def: Define new parameter. * params.h: Likewise. * sanitizer.def: Describe new builtins. * c-c++-common/asan/instrument-with-calls-1.c: New test. * c-c++-common/asan/instrument-with-calls-2.c: Likewise. * c-c++-common/asan/no-redundant-instrumentation-1.c: Update test patterns. * c-c++-common/asan/no-redundant-instrumentation-2.c: Likewise. * c-c++-common/asan/no-redundant-instrumentation-4.c: Likewise. * c-c++-common/asan/no-redundant-instrumentation-5.c: Likewise. * c-c++-common/asan/no-redundant-instrumentation-6.c: Likewise. * c-c++-common/asan/no-redundant-instrumentation-7.c: Likewise. * c-c++-common/asan/no-redundant-instrumentation-8.c: Likewise. Backport from mainline 2014-06-16 Yury Gribov <y.gribov@samsung.com> * asan.c (build_check_stmt): Fix maybe-uninitialized warning. Backport from mainline 2014-06-18 Yury Gribov <y.gribov@samsung.com> PR sanitizer/61530 * asan.c (build_check_stmt): Add condition. * c-c++-common/asan/pr61530.c: New test. Backport from mainline 2014-06-18 Yury Gribov <y.gribov@samsung.com> PR sanitizer/61547 * asan.c (instrument_strlen_call): Fixed instrumentation of trailing byte. * c-c++-common/asan/strlen-overflow-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@216326 138bc75d-0d04-0410-961f-82ee72b054a4
* 2014-10-16 Yury Gribov <y.gribov@samsung.com>ygribov2014-10-161-0/+14
| | | | | | | | | | | | | | | | | | | Backport from mainline 2014-05-14 Yury Gribov <y.gribov@samsung.com> PR sanitizer/61100 * Makefile.am (nodist_saninclude_HEADERS): Install public headers. * Makefile.in: Regenerate. * c-c++-common/asan/asan-interface-1.c: New test. * lib/asan-dg.exp (asan_include_flags): New function. (asan_init): Call asan_include_flags to obtain path to sanitizer headers. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@216322 138bc75d-0d04-0410-961f-82ee72b054a4
* 2014-01-23 Dominique Dhumieres <dominiq@lps.ens.fr>chefmax2014-01-231-1/+1
| | | | | | | | | PR sanitizer/59897 * c-c++-common/asan/use-after-return-1.c: Fixed to pass on darwin. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206961 138bc75d-0d04-0410-961f-82ee72b054a4
* 2014-01-10 Max Ostapenko <m.ostapenko@partner.samsung.com>chefmax2014-01-101-0/+16
| | | | | | | * c-c++-common/asan/no-asan-stack.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206515 138bc75d-0d04-0410-961f-82ee72b054a4
* PR sanitizer/59136jakub2014-01-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libsanitizer/ * sanitizer_common/Makefile.am (AM_CXXFLAGS): If LIBBACKTRACE_SUPPORTED add -DSANITIZER_LIBBACKTRACE and -I/-include flags. * lsan/Makefile.am (liblsan_la_LIBADD): Add libsanitizer_libbacktrace.la if LIBBACKTRACE_SUPPORTED. * tsan/Makefile.am (libtsan_la_LIBADD): Likewise. * ubsan/Makefile.am (libubsan_la_LIBADD): Likewise. * asan/Makefile.am (libasan_la_LIBADD): Likewise. * Makefile.am (SUBDIRS): If LIBBACKTRACE_SUPPORTED add libbacktrace. * README.gcc: Document that also lsan and ubsan are maintained in compiler-rt upstream. * libbacktrace/Makefile.am: New file. * libbacktrace/backtrace-rename.h: New file. * libbacktrace/backtrace-supported.h.in: New file. * libbacktrace/bridge.cc: New file. * configure.ac: Add tests needed for libbacktrace build within libsanitizer. * sanitizer_common/Makefile.in: Regenerated. * lsan/Makefile.in: Regenerated. * tsan/Makefile.in: Regenerated. * ubsan/Makefile.in: Regenerated. * libbacktrace/Makefile.in: Generated. * config.h.in: Regenerated. * configure: Regenerated. * Makefile.in: Regenerated. * interception/Makefile.in: Regenerated. * asan/Makefile.in: Regenerated. * aclocal.m4: Regenerated. testsuite/ * c-c++-common/asan/strip-path-prefix-1.c: Allow also the filename:line instead of (modulename+offset) form with stripped initial / from the filename. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206475 138bc75d-0d04-0410-961f-82ee72b054a4
* 2014-01-09 Max Ostapenko <m.ostapenko@partner.samsung.com>chefmax2014-01-095-0/+105
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* 2013-12-05 Yury Gribov <y.gribov@samsung.com>ygribov2013-12-052-2/+2
| | | | | | | | | PR sanitizer/59369 * c-c++-common/asan/pr59063-1.c: Disable on non-Linux platforms. * c-c++-common/asan/pr59063-2.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205699 138bc75d-0d04-0410-961f-82ee72b054a4
* libsanitizer merge from upstream r196090kcc2013-12-051-1/+0
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205695 138bc75d-0d04-0410-961f-82ee72b054a4
* gcc/ygribov2013-11-292-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2013-11-29 Jakub Jelinek <jakub@redhat.com> Yury Gribov <y.gribov@samsung.com> PR sanitizer/59063 * config/gnu-user.h: Removed old code for setting up sanitizer libs. * gcc.c: Using libsanitizer spec instead of explicit libs. gcc/testsuite/ 2013-11-29 Jakub Jelinek <jakub@redhat.com> Yury Gribov <y.gribov@samsung.com> PR sanitizer/59063 * c-c++-common/asan/pr59063-1.c: New test. * c-c++-common/asan/pr59063-2.c: Likewise. * lib/asan-dg.exp: Add path to libsanitizer.spec to cflags. * lib/ubsan-dg.exp: Likewise. libsanitizer/ 2013-11-29 Jakub Jelinek <jakub@redhat.com> Yury Gribov <y.gribov@samsung.com> PR sanitizer/59063 * libsanitizer.spec.in: Add spec file to hold link flags for various sanitizer libs. * configure.ac: Check whether clock_* routines come from librt. * asan/Makefile.am (libasan_la_LDFLAGS): Libs now come from configure.ac. * tsan/Makefile.am (libtsan_la_LDFLAGS): Likewise. * ubsan/Makefile.am (libubsan_la_LDFLAGS): Likewise. * lsan/Makefile.am (liblsan_la_LDFLAGS): Likewise. * asan/Makefile.in: Regenerate. * interception/Makefile.in: Regenerate. * lsan/Makefile.in: Regenerate. * sanitizer_common/Makefile.in: Regenerate. * tsan/Makefile.in: Regenerate. * ubsan/Makefile.in: Regenerate. * Makefile.in: Regenerate. * configure: Regenerate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205524 138bc75d-0d04-0410-961f-82ee72b054a4
* PR sanitizer/59061jakub2013-11-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * common.opt (static-liblsan): Add. * config/gnu-user.h (STATIC_LIBLSAN_LIBS, STATIC_LIBUBSAN_LIBS): Define. * flag-types.h (enum sanitize_code): Add SANITIZE_LEAK. Renumber SANITIZE_SHIFT, SANITIZE_DIVIDE, SANITIZE_UNREACHABLE, SANITIZE_VLA, SANITIZE_RETURN. * opts.c (common_handle_option): Handle -fsanitize=leak. * gcc.c (ADD_STATIC_LIBLSAN_LIBS, LIBLSAN_SPEC): Define. (LIBUBSAN_SPEC): Don't test LIBUBSAN_EARLY_SPEC. (LIBUBSAN_EARLY_SPEC): Remove. (SANITIZER_EARLY_SPEC): Don't do anything for libubsan. (SANITIZER_SPEC): Add -fsanitize=leak handling. (sanitize_spec_function): Handle %sanitize(leak). * doc/invoke.texi (-static-liblsan, -fsanitize=leak): Document. * c-c++-common/asan/no-redundant-instrumentation-7.c: Fix cleanup-tree-dump directive. * configure.tgt: Set LSAN_SUPPORTED=yes for x86_64-linux. * configure.ac (LSAN_SUPPORTED): New AM_CONDITIONAL. * configure: Regenerated. * lsan/Makefile.am (toolexeclib_LTLIBRARIES, lsan_files, liblsan_la_SOURCES, liblsan_la_LIBADD, liblsan_la_LDFLAGS): Add. * lsan/Makefile.in: Regenerated. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205290 138bc75d-0d04-0410-961f-82ee72b054a4
* * sanitizer.def (BUILT_IN_ASAN_BEFORE_DYNAMIC_INIT,jakub2013-11-221-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | BUILT_IN_ASAN_AFTER_DYNAMIC_INIT): New. * asan.c (instrument_derefs): Handle also VAR_DECL loads/stores. Don't instrument accesses to VAR_DECLs which are known to fit into their bounds and the vars are known to have shadow bytes indicating allowed access. (asan_dynamic_init_call): New function. (asan_add_global): If vnode->dynamically_initialized, set __has_dynamic_init to 1 instead of 0. (initialize_sanitizer_builtins): Add BT_FN_VOID_CONST_PTR var. * asan.h (asan_dynamic_init_call): New prototype. * cgraph.h (varpool_node): Add dynamically_initialized bitfield. cp/ * decl2.c: Include asan.h. (one_static_initialization_or_destruction): If -fsanitize=address, init is non-NULL and guard is NULL, set vnode->dynamically_initialized. (do_static_initialization_or_destruction): Call __asan_{before,after}_dynamic_init around the static initialization. testsuite/ * c-c++-common/asan/no-redundant-instrumentation-1.c: Tweak to avoid optimizing away some __asan_report* calls. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205282 138bc75d-0d04-0410-961f-82ee72b054a4
* Allow integer literals as addresses in instrumented builtins.ygribov2013-11-071-0/+7
| | | | | | | | | | | | | | gcc/ PR sanitizer/59029 * gcc/asan.c (get_mem_refs_of_builtin_call): Allow integer literals as addresses in instrumented builtins. gcc-testsuite/ PR sanitizer/59029 * c-c++-common/asan/pr59029.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204508 138bc75d-0d04-0410-961f-82ee72b054a4
* libsanitizer merge from upstream r191666kcc2013-11-041-1/+2
| | | | | | | | This may break gcc-asan on Mac, will follow up separately. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204368 138bc75d-0d04-0410-961f-82ee72b054a4
* 2013-05-06 Christophe Lyon <christophe.lyon@linaro.org>clyon2013-05-077-10/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | gcc/ * config/arm/arm.c (arm_asan_shadow_offset): New function. (TARGET_ASAN_SHADOW_OFFSET): Define. * config/arm/linux-eabi.h (ASAN_CC1_SPEC): Define. (LINUX_OR_ANDROID_CC): Add ASAN_CC1_SPEC. libsanitizer/ * configure.tgt: Add ARM pattern. testsuite/ * lib/target-supports.exp (check_effective_target_hw): New function. * c-c++-common/asan/clone-test-1.c: Call check_effective_target_hw. * c-c++-common/asan/rlimit-mmap-test-1.c: Likewise. * c-c++-common/asan/heap-overflow-1.c: Update regexps to accept possible decorations. * c-c++-common/asan/null-deref-1.c: Likewise. * c-c++-common/asan/stack-overflow-1.c: Likewise. * c-c++-common/asan/strncpy-overflow-1.c: Likewise. * c-c++-common/asan/use-after-free-1.c: Likewise. * g++.dg/asan/deep-thread-stack-1.C: Likewise. * g++.dg/asan/large-func-test-1.C: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198683 138bc75d-0d04-0410-961f-82ee72b054a4
* PR sanitizer/56454jakub2013-02-281-5/+33
| | | | | | | | | | | | | | | | | | | | | | | | * asan.c (gate_asan): Lookup no_sanitize_address instead of no_address_safety_analysis attribute. * doc/extend.texi (no_address_safety_attribute): Rename to no_sanitize_address attribute, mention no_address_safety_analysis attribute as deprecated alias. * c-common.c (handle_no_sanitize_address_attribute): New function. (c_common_attribute_table): Add no_sanitize_address attribute. (handle_no_address_safety_analysis_attribute): Add no_sanitize_address attribute, not no_address_safety_analysis attribute. * g++.dg/asan/default-options-1.C (__asan_default_options): Use no_sanitize_address attribute rather than no_address_safety_analysis. * g++.dg/asan/sanitizer_test_utils.h (ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS): Likewise. * c-c++-common/asan/attrib-1.c: Test no_sanitize_address attribute in addition to no_address_safety_analysis. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@196361 138bc75d-0d04-0410-961f-82ee72b054a4
* [asan] Fix for PR asan/56330dodji2013-02-167-1/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | gcc/ * asan.c (get_mem_refs_of_builtin_call): White space and style cleanup. (instrument_mem_region_access): Do not forget to always put instrumentation of the of 'base' and 'base + len' in a "if (len != 0) statement, even for cases where either 'base' or 'base + len' are not instrumented -- because they have been previously instrumented. Simplify the logic by putting all the statements instrument 'base + len' inside a sequence, and then insert that sequence right before the current insertion point. Then, to instrument 'base + len', just get an iterator on that statement. And do not forget to update the pointer to iterator the function received as argument. gcc/testsuite/ * c-c++-common/asan/no-redundant-instrumentation-4.c: New test file. * c-c++-common/asan/no-redundant-instrumentation-5.c: Likewise. * c-c++-common/asan/no-redundant-instrumentation-6.c: Likewise. * c-c++-common/asan/no-redundant-instrumentation-7.c: Likewise. * c-c++-common/asan/no-redundant-instrumentation-8.c: Likewise. * c-c++-common/asan/pr56330.c: Likewise. * c-c++-common/asan/no-redundant-instrumentation-1.c (test1): Ensure the size argument of __builtin_memcpy is a constant. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@196102 138bc75d-0d04-0410-961f-82ee72b054a4
* [asan] Fix a thinko leading to a crashdodji2013-02-141-0/+10
| | | | | | | | | | | | | | | | | It appeared that in my previous patch, a stupid thinko can lead to a crash when instrumenting some builtin functionsK. Fixed thus. Bootstrapped and tested against trunk on x86_64-unknown-linux-gnu. gcc/ * asan.c (instrument_builtin_call): Really put the length of the second source argument into src1_len. gcc/testsuite/ * c-c++-common/asan/memcmp-2.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@196044 138bc75d-0d04-0410-961f-82ee72b054a4
* libsanitizer merge from upstream r175049kcc2013-02-132-2/+2
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@196009 138bc75d-0d04-0410-961f-82ee72b054a4
* [asan] Avoid instrumenting duplicated memory access in the same basic blockdodji2013-02-134-0/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Like what Address Sanitizer does in LLVM, this patch avoids instrumented duplicated memory accesses in the same basic blocks. The approach taken is very conservative, to keep the pass simple, for a start. A memory access is considered to be a pair made of an expression tree representing the beginning of the memory region that is accessed and a the size of the access, in byte. For now that size is either 1, 2, 4, 8 or 16 bytes. The patch builds a hash table of the memory accesses that have been instrumented in the current basic block. Then it walks the gimple statements of the current basic block. For each statement, it tests if the memory regions it references have already been instrumented. If not, the statement is instrumented and each memory references that are actually instrumented are added to the hash table. When a memory region is accessed (usually through builtin functions like memset), then what gets added to the hash table is actually two memory accesses: one for the beginning of the region, and the other for the its end. When the patch crosses a function call that is not a built-in function that we ought to instrument, the hash table is cleared, because that function call can possibly e.g free some memory that was instrumented. Likewise, when a new basic block is visited, the hash table is cleared. I guess we could be smarter than just unconditionally clearing the hash table in this later case, but this is what asan@llvm does, and for now, I thought starting in a conservative manner might have some value. The hash table is destroyed at the end of the pass. Bootstrapped and tested against trunk on x86-64-unknown-linux-gnu. gcc/ * Makefile.in (asan.o): Add new dependency on hash-table.h * asan.c (struct asan_mem_ref, struct mem_ref_hasher): New types. (asan_mem_ref_init, asan_mem_ref_get_end, get_mem_ref_hash_table) (has_stmt_been_instrumented_p, empty_mem_ref_hash_table) (free_mem_ref_resources, has_mem_ref_been_instrumented) (has_stmt_been_instrumented_p, update_mem_ref_hash_table) (get_mem_ref_of_assignment): New functions. (get_mem_refs_of_builtin_call): Extract from instrument_builtin_call and tweak a little bit to make it fit with the new signature. (instrument_builtin_call): Use the new get_mem_refs_of_builtin_call. Use gimple_call_builtin_p instead of is_gimple_builtin_call. (instrument_derefs, instrument_mem_region_access): Insert the instrumented memory reference into the hash table. (maybe_instrument_assignment): Renamed instrument_assignment into this, and change it to advance the iterator when instrumentation actually happened and return true in that case. This makes it homogeneous with maybe_instrument_assignment, and thus give a chance to callers to be more 'regular'. (transform_statements): Clear the memory reference hash table whenever we enter a new BB, when we cross a function call, or when we are done transforming statements. Use maybe_instrument_assignment instead of instrumentation. No more need to special case maybe_instrument_assignment and advance the iterator after calling it; it's now handled just like maybe_instrument_call. Update comment. gcc/testsuite/ * c-c++-common/asan/no-redundant-instrumentation-1.c: New test. * testsuite/c-c++-common/asan/no-redundant-instrumentation-2.c: Likewise. * testsuite/c-c++-common/asan/no-redundant-instrumentation-3.c: Likewise. * testsuite/c-c++-common/asan/inc.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@196008 138bc75d-0d04-0410-961f-82ee72b054a4
* PR testsuite/56053jakub2013-01-283-9/+28
| | | | | | | | | | | | * c-c++-common/asan/heap-overflow-1.c: Don't include stdlib.h and string.h. Provide memset, malloc and free prototypes, adjust line numbers in dg-output. * c-c++-common/asan/stack-overflow-1.c: Don't include string.h. Provide memset prototype and adjust line numbers in dg-output. * c-c++-common/asan/global-overflow-1.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@195505 138bc75d-0d04-0410-961f-82ee72b054a4
* PR sanitizer/55844jakub2013-01-081-1/+1
| | | | | | | | * c-c++-common/asan/null-deref-1.c: Add -fno-shrink-wrap to dg-options. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@195005 138bc75d-0d04-0410-961f-82ee72b054a4
* * lib/gcc-dg.exp (${tool}_load): Handle non-existingjakub2012-12-1214-4/+324
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | set_target_env_var the same as if it is empty list. (dg-set-target-env-var): Fix up error message. (set-target-env-var): Record both preexisting env var values as well as info that env wasn't set. (restore-target-env-var): Iterate on reversed list, if second sublist element is 1, setenv the env var to the third sublist element, otherwise unsetenv it. (gcc-dg-runtest): Don't initialize set_target_env_var. (dg-test): Unset set_target_env_var if it was set. * g++.dg/asan/deep-tail-call-1.C: Whitespace fixes. Don't rely on argc being one. * g++.dg/asan/interception-malloc-test-1.C: Only run on linux. Whitespace fixes. Avoid unnecessary * sizeof(char). * g++.dg/asan/deep-thread-stack-1.C: Add -lasan -lpthread to dg-options. Whitespace fixes. * g++.dg/asan/deep-stack-uaf-1.C: Skip for -flto. Whitespace fixes. * g++.dg/asan/interception-test-1.C: Whitespace fixes. * g++.dg/asan/interception-failure-test-1.C: Whitespace fixes. Avoid unnecessary * sizeof(char). Remove // CHECK: comment. * g++.dg/asan/default-options-1.C: Whitespace fixes. * g++.dg/asan/symbolize-callback-1.C: Whitespace fixes. Make first __asan_symbolize argument unnamed. Avoid unnecessary * sizeof(char). * g++.dg/asan/large-func-test-1.C: Whitespace fixes. Don't rely on argc being one. Allow both _Znwj and _Znwm as operator new. Ignore everything in the backtrace above operator new. Fix up dg-output regexps. * c-c++-common/asan/null-deref-1.c: Add -fno-omit-frame-pointer and for x86 -mno-omit-leaf-frame-pointer. Fix up dg-output regexps. * c-c++-common/asan/clone-test-1.c: Whitespace fixes. Return non-zero on failures. Avoid pointless PASS dg-output check. Remove bogus dg-shouldfail. * c-c++-common/asan/sanity-check-pure-c-1.c: Fix up dg-output regexps. Avoid unnecessary * sizeof(char). * c-c++-common/asan/heap-overflow-1.c: Fix up dg-output regexps. Don't rely on argc being one. * c-c++-common/asan/sleep-before-dying-1.c: Whitespace fixes. Avoid unnecessary * sizeof(char). * c-c++-common/asan/rlimit-mmap-test-1.c: Whitespace fixes. * c-c++-common/asan/stack-overflow-1.c: Fix up dg-output regexps. * c-c++-common/asan/global-overflow-1.c: Add -fno-builtin-memset. Fix up dg-output regexps. * c-c++-common/asan/strncpy-overflow-1.c: Fix up dg-output regexps. * c-c++-common/asan/memcmp-1.c: Don't rely on argc being one. * c-c++-common/asan/use-after-free-1.c: Fix up dg-output regexps. * c-c++-common/asan/swapcontext-test-1.c: Don't rely on argc being one. * c-c++-common/asan/force-inline-opt0-1.c: Remove dg-skip-if. * c-c++-common/asan/strip-path-prefix-1.c: Whitespace fixes. Avoid unnecessary * sizeof(char). 2012-12-12 Wei Mi <wmi@google.com> * lib/target-supports.exp (check_effective_target_dlopen, check_effective_target_clone, check_effective_target_setrlimit, check_effective_target_swapcontext): New procedures. * lib/gcc-dg.exp (${tool}_load): Handle dg-set-target-env-var. (dg-set-target-env-var, set-target-env-var, restore-target-env-var): New procedures. (gcc-dg-runtest): Set set_target_env_var. * g++.dg/asan/symbolize-callback-1.C: New test. * g++.dg/asan/shared-lib-test-1-so.cc: New file. * g++.dg/asan/deep-tail-call-1.C: New test. * g++.dg/asan/default-options-1.C: New test. * g++.dg/asan/interception-test-1.C: New test. * g++.dg/asan/dlclose-test-1-so.cc: New file. * g++.dg/asan/deep-thread-stack-1.C: New test. * g++.dg/asan/interception-malloc-test-1.C: New test. * g++.dg/asan/deep-stack-uaf-1.C: New test. * g++.dg/asan/large-func-test-1.C: New test. * g++.dg/asan/interception-failure-test-1.C: New test. * c-c++-common/asan/strip-path-prefix-1.c: New test. * c-c++-common/asan/force-inline-opt0-1.c: New test. * c-c++-common/asan/swapcontext-test-1.c: New test. * c-c++-common/asan/null-deref-1.c: New test. * c-c++-common/asan/global-overflow-1.c: New test. * c-c++-common/asan/strncpy-overflow-1.c: New test. * c-c++-common/asan/rlimit-mmap-test-1.c: New test. * c-c++-common/asan/stack-overflow-1.c: New test. * c-c++-common/asan/use-after-free-1.c: New test. * c-c++-common/asan/sanity-check-pure-c-1.c: New test. * c-c++-common/asan/clone-test-1.c: New test. * c-c++-common/asan/heap-overflow-1.c: New test. * c-c++-common/asan/sleep-before-dying-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@194458 138bc75d-0d04-0410-961f-82ee72b054a4
* [libsanitizer] merge from upstream r168514kcc2012-11-231-1/+1
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193756 138bc75d-0d04-0410-961f-82ee72b054a4
* PR sanitizer/55435jakub2012-11-231-0/+34
| | | | | | | | | | | | | | | | | * c-common.c (handle_no_address_safety_analysis_attribute): New function. (c_common_attribute_table): Add no_address_safety_analysis. * asan.c (gate_asan): Don't instrument functions with no_address_safety_analysis attribute. (gate_asan_O0): Use !optimize && gate_asan (). * doc/extend.texi (no_address_safety_analysis): Document new function attribute. * c-c++-common/asan/attrib-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193748 138bc75d-0d04-0410-961f-82ee72b054a4
* * lib/asan-dg.exp: New file.jakub2012-11-141-0/+18
* gcc.dg/asan/asan.exp: New file. * g++.dg/dg.exp: Prune also asan tests. * g++.dg/asan/asan.exp: New file. * c-c++-common/asan/memcmp-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193511 138bc75d-0d04-0410-961f-82ee72b054a4
OpenPOWER on IntegriCloud