From 33f6f98faa86c61b9895db0d71e0e88a9ae4fa59 Mon Sep 17 00:00:00 2001
From: Maxim Ostapenko <m.ostapenko@samsung.com>
Date: Tue, 25 Oct 2016 20:34:23 +0300
Subject: [PATCH 5/7] libsanitizer merge from upstream r285547, compiler part.
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.
---
gcc/ChangeLog | 10 ++++++++++
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, 25 insertions(+), 9 deletions(-)
@@ -1,3 +1,13 @@
+2016-11-07 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-10-30 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
PR tree-optimization/71915
@@ -1214,7 +1214,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;
}
@@ -2191,19 +2191,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,
@@ -2312,6 +2313,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);
}
@@ -53,7 +53,6 @@ extern alias_set_type asan_shadow_set;
#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_FRAME_MAGIC 0x41b58ab3
@@ -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. */
@@ -1,3 +1,7 @@
+2016-11-07 Maxim Ostapenko <m.ostapenko@samsung.com>
+
+ * c-c++-common/asan/null-deref-1.c: Adjust testcase.
+
2016-10-30 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
PR tree-optimization/71915
@@ -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)" } */
--
1.9.1