diff options
author | Max Ostapenko <m.ostapenko@partner.samsung.com> | 2015-10-21 10:40:54 +0300 |
---|---|---|
committer | Maxim Ostapenko <chefmax@gcc.gnu.org> | 2015-10-21 10:40:54 +0300 |
commit | 89e302b80c8b283a0e073a92fb2d52ad7ccb6eb8 (patch) | |
tree | b7543b32302329374f126d54ffc91193bf4f4f25 /gcc/asan.c | |
parent | 696d846a56cc12549f080c6c87e6a0272bdb29f1 (diff) | |
download | gcc-89e302b80c8b283a0e073a92fb2d52ad7ccb6eb8.zip gcc-89e302b80c8b283a0e073a92fb2d52ad7ccb6eb8.tar.gz gcc-89e302b80c8b283a0e073a92fb2d52ad7ccb6eb8.tar.bz2 |
libsanitizer merge from upstream r250806, compiler part.
gcc/
* asan.c (asan_emit_stack_protection): Don't pass local stack to
asan_stack_malloc_[n] anymore. Check if asan_stack_malloc_[n] returned
NULL and use local stack than.
(asan_finish_file): Insert __asan_version_mismatch_check_v[n] call
in addition to __asan_init.
* sanitizer.def (BUILT_IN_ASAN_INIT): Rename to __asan_init.
(BUILT_IN_ASAN_VERSION_MISMATCH_CHECK): Add new builtin call.
* asan.h (asan_intercepted_p): Handle new string builtins.
* ubsan.c (ubsan_use_new_style_p): New function.
(ubsan_instrument_float_cast): If location is unknown, assign
input_location to loc. Propagate loc to ubsan_create_data if
ubsan_use_new_style_p returned true.
config/
* bootstrap-asan.mk: Replace ASAN_OPTIONS=detect_leaks with
LSAN_OPTIONS=detect_leaks.
gcc/testsuite/
* c-c++-common/ubsan/float-cast-overflow-10.c: Adjust test.
* c-c++-common/ubsan/float-cast-overflow-8.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-9.c: Likewise.
* g++.dg/asan/default-options-1.C: Likewise.
From-SVN: r229112
Diffstat (limited to 'gcc/asan.c')
-rw-r--r-- | gcc/asan.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -1132,12 +1132,16 @@ asan_emit_stack_protection (rtx base, rtx pbase, unsigned int alignb, snprintf (buf, sizeof buf, "__asan_stack_malloc_%d", use_after_return_class); ret = init_one_libfunc (buf); - rtx addr = convert_memory_address (ptr_mode, base); - ret = emit_library_call_value (ret, NULL_RTX, LCT_NORMAL, ptr_mode, 2, + ret = emit_library_call_value (ret, NULL_RTX, LCT_NORMAL, ptr_mode, 1, GEN_INT (asan_frame_size + base_align_bias), - TYPE_MODE (pointer_sized_int_node), - addr, ptr_mode); + TYPE_MODE (pointer_sized_int_node)); + /* __asan_stack_malloc_[n] returns a pointer to fake stack if succeeded + and NULL otherwise. Check RET value is NULL here and jump over the + BASE reassignment in this case. Otherwise, reassign BASE to RET. */ + int very_unlikely = REG_BR_PROB_BASE / 2000 - 1; + emit_cmp_and_jump_insns (ret, const0_rtx, EQ, NULL_RTX, + VOIDmode, 0, lab, very_unlikely); ret = convert_memory_address (Pmode, ret); emit_move_insn (base, ret); emit_label (lab); @@ -2470,6 +2474,8 @@ asan_finish_file (void) { tree fn = builtin_decl_implicit (BUILT_IN_ASAN_INIT); append_to_statement_list (build_call_expr (fn, 0), &asan_ctor_statements); + fn = builtin_decl_implicit (BUILT_IN_ASAN_VERSION_MISMATCH_CHECK); + append_to_statement_list (build_call_expr (fn, 0), &asan_ctor_statements); } FOR_EACH_DEFINED_VARIABLE (vnode) if (TREE_ASM_WRITTEN (vnode->decl) |