From fbdb92ebffaadd025bf1258c11537d3061cef124 Mon Sep 17 00:00:00 2001 From: Maxim Ostapenko Date: Tue, 8 Nov 2016 22:15:35 +0000 Subject: [PATCH] asan.h (ASAN_STACK_MAGIC_PARTIAL): Remove. gcc/ * asan.h (ASAN_STACK_MAGIC_PARTIAL): Remove. * asan.c (ASAN_STACK_MAGIC_PARTIAL): Replace with ASAN_STACK_MAGIC_MIDDLE. (asan_global_struct): Increase the size of fields. (asan_add_global): Add new field constructor. * sanitizer.def (__asan_version_mismatch_check_v6): Replace with __asan_version_mismatch_check_v8. gcc/testsuite/ * c-c++-common/asan/null-deref-1.c: Adjust testcase. From-SVN: r241983 --- gcc/ChangeLog | 12 +++++++++++- gcc/asan.c | 13 ++++++++----- gcc/asan.h | 1 - gcc/sanitizer.def | 2 +- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/c-c++-common/asan/null-deref-1.c | 4 ++-- 6 files changed, 26 insertions(+), 10 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 76b2d3f..ab2dd5e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,14 @@ -2016-11-08 David Edelsohn +2016-11-09 Maxim Ostapenko + + * asan.h (ASAN_STACK_MAGIC_PARTIAL): Remove. + * asan.c (ASAN_STACK_MAGIC_PARTIAL): Replace with + ASAN_STACK_MAGIC_MIDDLE. + (asan_global_struct): Increase the size of fields. + (asan_add_global): Add new field constructor. + * sanitizer.def (__asan_version_mismatch_check_v6): Replace with + __asan_version_mismatch_check_v8. + + 2016-11-08 David Edelsohn * dwarf2asm.c (USE_LINKONCE_INDIRECT): Test XCOFF_DEBUGGING_INFO at runtime. diff --git a/gcc/asan.c b/gcc/asan.c index 1e0ce8d..6e93ea3 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -1242,7 +1242,7 @@ asan_emit_stack_protection (rtx base, rtx pbase, unsigned int alignb, shadow_bytes[i] = offset - aoff; } else - shadow_bytes[i] = ASAN_STACK_MAGIC_PARTIAL; + shadow_bytes[i] = ASAN_STACK_MAGIC_MIDDLE; emit_move_insn (shadow_mem, asan_shadow_cst (shadow_bytes)); offset = aoff; } @@ -2260,19 +2260,20 @@ asan_dynamic_init_call (bool after_p) const void *__module_name; uptr __has_dynamic_init; __asan_global_source_location *__location; + char *__odr_indicator; } type. */ static tree asan_global_struct (void) { - static const char *field_names[7] + static const char *field_names[8] = { "__beg", "__size", "__size_with_redzone", - "__name", "__module_name", "__has_dynamic_init", "__location"}; - tree fields[7], ret; + "__name", "__module_name", "__has_dynamic_init", "__location", "__odr_indicator"}; + tree fields[8], ret; int i; ret = make_node (RECORD_TYPE); - for (i = 0; i < 7; i++) + for (i = 0; i < 8; i++) { fields[i] = build_decl (UNKNOWN_LOCATION, FIELD_DECL, @@ -2381,6 +2382,8 @@ asan_add_global (tree decl, tree type, vec *v) else locptr = build_int_cst (uptr, 0); CONSTRUCTOR_APPEND_ELT (vinner, NULL_TREE, locptr); + /* TODO: support ODR indicators. */ + CONSTRUCTOR_APPEND_ELT (vinner, NULL_TREE, build_int_cst (uptr, 0)); init = build_constructor (type, vinner); CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, init); } diff --git a/gcc/asan.h b/gcc/asan.h index 042af1f..f63a108 100644 --- a/gcc/asan.h +++ b/gcc/asan.h @@ -59,7 +59,6 @@ extern hash_set *asan_used_labels; #define ASAN_STACK_MAGIC_LEFT 0xf1 #define ASAN_STACK_MAGIC_MIDDLE 0xf2 #define ASAN_STACK_MAGIC_RIGHT 0xf3 -#define ASAN_STACK_MAGIC_PARTIAL 0xf4 #define ASAN_STACK_MAGIC_USE_AFTER_RET 0xf5 #define ASAN_STACK_MAGIC_USE_AFTER_SCOPE 0xf8 diff --git a/gcc/sanitizer.def b/gcc/sanitizer.def index c11c95a..3db08a7 100644 --- a/gcc/sanitizer.def +++ b/gcc/sanitizer.def @@ -34,7 +34,7 @@ DEF_BUILTIN_STUB(BEGIN_SANITIZER_BUILTINS, (const char *)0) DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_INIT, "__asan_init", BT_FN_VOID, ATTR_NOTHROW_LEAF_LIST) DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_VERSION_MISMATCH_CHECK, - "__asan_version_mismatch_check_v6", + "__asan_version_mismatch_check_v8", BT_FN_VOID, ATTR_NOTHROW_LEAF_LIST) /* Do not reorder the BUILT_IN_ASAN_{REPORT,CHECK}* builtins, e.g. cfgcleanup.c relies on this order. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2b561e8..ec91ad6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2016-11-09 Maxim Ostapenko + + * c-c++-common/asan/null-deref-1.c: Adjust testcase. + 2016-11-08 Janus Weil PR fortran/68440 diff --git a/gcc/testsuite/c-c++-common/asan/null-deref-1.c b/gcc/testsuite/c-c++-common/asan/null-deref-1.c index 45d35ac..f4f8f37 100644 --- a/gcc/testsuite/c-c++-common/asan/null-deref-1.c +++ b/gcc/testsuite/c-c++-common/asan/null-deref-1.c @@ -17,6 +17,6 @@ int main() } /* { dg-output "ERROR: AddressSanitizer:? SEGV on unknown address\[^\n\r]*" } */ -/* { dg-output "0x\[0-9a-f\]+ \[^\n\r]*pc 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } */ -/* { dg-output "\[^\n\r]* #0 0x\[0-9a-f\]+ +(in \[^\n\r]*NullDeref\[^\n\r]* (\[^\n\r]*null-deref-1.c:10|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "0x\[0-9a-f\]+ \[^\n\r]*pc 0x\[0-9a-f\]+.*(\n|\r\n|\r)" } */ +/* { dg-output " #0 0x\[0-9a-f\]+ +(in \[^\n\r]*NullDeref\[^\n\r]* (\[^\n\r]*null-deref-1.c:10|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ /* { dg-output " #1 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*null-deref-1.c:15|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */ -- 2.7.4