asan.h (ASAN_STACK_MAGIC_PARTIAL): Remove.
authorMaxim Ostapenko <m.ostapenko@samsung.com>
Tue, 8 Nov 2016 22:15:35 +0000 (22:15 +0000)
committerMaxim Ostapenko <chefmax@gcc.gnu.org>
Tue, 8 Nov 2016 22:15:35 +0000 (00:15 +0200)
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
gcc/asan.c
gcc/asan.h
gcc/sanitizer.def
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/asan/null-deref-1.c

index 76b2d3f232905234aaf41ac50c6f6671a3d83eda..ab2dd5e209f6a5452384693dd08a2defcec72b9a 100644 (file)
@@ -1,4 +1,14 @@
-2016-11-08  David Edelsohn  <dje.gcc@gmail.com>
+2016-11-09  Maxim Ostapenko  <m.ostapenko@samsung.com>
+
+       * 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  <dje.gcc@gmail.com>
 
        * dwarf2asm.c (USE_LINKONCE_INDIRECT): Test XCOFF_DEBUGGING_INFO
        at runtime.
index 1e0ce8df64673b93eba3d81daf9ae6112da7078a..6e93ea3aba5595d1395823465291e1eb995bb78c 100644 (file)
@@ -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<constructor_elt, va_gc> *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);
 }
index 042af1ff799fec880112b578a43d366d8976582d..f63a108dc87eb0919f6dd4ca87e46358fdc3bf67 100644 (file)
@@ -59,7 +59,6 @@ extern hash_set <tree> *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
 
index c11c95a7e23a954875888d80c40b7116af1b5f6b..3db08a7b7029bd1996f8b85029ec3cd6f65d5a04 100644 (file)
@@ -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.  */
index 2b561e817b02d01d68ec02478bc18377ac5fd9bf..ec91ad60e2c49699496c1349bb7c1139f5c36ea5 100644 (file)
@@ -1,3 +1,7 @@
+2016-11-09  Maxim Ostapenko  <m.ostapenko@samsung.com>
+
+       * c-c++-common/asan/null-deref-1.c: Adjust testcase.
+
 2016-11-08  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/68440
index 45d35ac2de3589675571114a7de3dd00848ab230..f4f8f37a795a53d2ed24cbed9c5c21db2f702020 100644 (file)
@@ -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)" } */