public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 0/7] Libsanitizer merge from upstream r285547.
       [not found] <CGME20161107082229eucas1p2b7db548c790652a933f5f0d55fe76e50@eucas1p2.samsung.com>
@ 2016-11-07  8:22 ` Maxim Ostapenko
       [not found]   ` <CGME20161107082413eucas1p1d3db8c4db2923df60cdbaa499b3e2b02@eucas1p1.samsung.com>
                     ` (8 more replies)
  0 siblings, 9 replies; 28+ messages in thread
From: Maxim Ostapenko @ 2016-11-07  8:22 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jakub Jelinek, Kostya Serebryany, Yuri Gribov

Hi,

this patch set performs libsanitizer merge from upstream.

Patch 1 is the library merge itself.

Patch 2 is the reapplied change for SPARC by David S. Miller.

Patch 3 changes heuristic for extracting last PC from stack frame for 
ARM in fast unwind routine. More details can be found here 
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61771).

Patch 4 replaces Jakub's fix for 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63888 and removes 
CheckODRViolationViaPoisoning call from RegisterGlobal to avoid false 
positive odr violation reports.

Patch 5 combines necessary compiler changes.

Patch 6 adds several new tests, backported from upstream.

Patch 7 adds support for ASan odr indicators at compiler side.

The whole patch set was regtested/bootstrapped/ASan bootstrapped on 
x86_64-unknown-linux-gnu and i386-unknown-linux-gnu.
Also, passed regression tests on arm-linux-gnueabi and aarch64-linux 
under QEMU.

-Maxim

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 2/7] Libsanitizer merge from upstream r285547.
       [not found]   ` <CGME20161107082413eucas1p1d3db8c4db2923df60cdbaa499b3e2b02@eucas1p1.samsung.com>
@ 2016-11-07  8:24     ` Maxim Ostapenko
  0 siblings, 0 replies; 28+ messages in thread
From: Maxim Ostapenko @ 2016-11-07  8:24 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jakub Jelinek, Kostya Serebryany, Yuri Gribov

[-- Attachment #1: Type: text/plain, Size: 59 bytes --]

This is just reapplied patch for SPARC by David S. Miller.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-libsanitizer.patch --]
[-- Type: text/x-diff; name="0002-libsanitizer.patch", Size: 7177 bytes --]

From 0ff8d1c408b076970c323361922c35033aaae245 Mon Sep 17 00:00:00 2001
From: Maxim Ostapenko <m.ostapenko@samsung.com>
Date: Tue, 25 Oct 2016 20:00:43 +0300
Subject: [PATCH 2/7] libsanitizer/

	PR sanitizer/63958
	Reapply:
	2014-10-14  David S. Miller  <davem@davemloft.net>

	* sanitizer_common/sanitizer_platform_limits_linux.cc (time_t):
	Define at __kernel_time_t, as needed for sparc.
	(struct __old_kernel_stat): Don't check if __sparc__ is defined.
	* libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
	(__sanitizer): Define struct___old_kernel_stat_sz,
	struct_kernel_stat_sz, and struct_kernel_stat64_sz for sparc.
	(__sanitizer_ipc_perm): Adjust for sparc targets.
	(__sanitizer_shmid_ds): Likewsie.
	(__sanitizer_sigaction): Likewise.
	(IOC_SIZE): Likewsie.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229113 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libsanitizer/ChangeLog                             | 17 +++++++
 .../sanitizer_platform_limits_linux.cc             |  4 +-
 .../sanitizer_platform_limits_posix.h              | 59 +++++++++++++++++++++-
 3 files changed, 77 insertions(+), 3 deletions(-)

diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog
index eaf907c..10b1207 100644
--- a/libsanitizer/ChangeLog
+++ b/libsanitizer/ChangeLog
@@ -1,5 +1,22 @@
 2016-11-07  Maxim Ostapenko  <m.ostapenko@samsung.com>
 
+	PR sanitizer/63958
+	Reapply:
+	2014-10-14  David S. Miller  <davem@davemloft.net>
+
+	* sanitizer_common/sanitizer_platform_limits_linux.cc (time_t):
+	Define at __kernel_time_t, as needed for sparc.
+	(struct __old_kernel_stat): Don't check if __sparc__ is defined.
+	* libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
+	(__sanitizer): Define struct___old_kernel_stat_sz,
+	struct_kernel_stat_sz, and struct_kernel_stat64_sz for sparc.
+	(__sanitizer_ipc_perm): Adjust for sparc targets.
+	(__sanitizer_shmid_ds): Likewsie.
+	(__sanitizer_sigaction): Likewise.
+	(IOC_SIZE): Likewsie.
+
+2016-11-07  Maxim Ostapenko  <m.ostapenko@samsung.com>
+
 	* All source files: Merge from upstream 285547.
 	* configure.tgt (SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS): New
 	variable.
diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc
index edc6730..23a0148 100644
--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc
@@ -36,6 +36,7 @@
 #define uid_t __kernel_uid_t
 #define gid_t __kernel_gid_t
 #define off_t __kernel_off_t
+#define time_t __kernel_time_t
 // This header seems to contain the definitions of _kernel_ stat* structs.
 #include <asm/stat.h>
 #undef ino_t
@@ -62,7 +63,8 @@ namespace __sanitizer {
 }  // namespace __sanitizer
 
 #if !defined(__powerpc64__) && !defined(__x86_64__) && !defined(__aarch64__)\
-                            && !defined(__mips__) && !defined(__s390__)
+                            && !defined(__mips__) && !defined(__s390__)\
+                            && !defined(__sparc__)
 COMPILER_CHECK(struct___old_kernel_stat_sz == sizeof(struct __old_kernel_stat));
 #endif
 
diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
index 17906d3..d1a3051 100644
--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -85,6 +85,14 @@ namespace __sanitizer {
 #elif defined(__s390x__)
   const unsigned struct_kernel_stat_sz = 144;
   const unsigned struct_kernel_stat64_sz = 0;
+#elif defined(__sparc__) && defined(__arch64__)
+  const unsigned struct___old_kernel_stat_sz = 0;
+  const unsigned struct_kernel_stat_sz = 104;
+  const unsigned struct_kernel_stat64_sz = 144;
+#elif defined(__sparc__) && !defined(__arch64__)
+  const unsigned struct___old_kernel_stat_sz = 0;
+  const unsigned struct_kernel_stat_sz = 64;
+  const unsigned struct_kernel_stat64_sz = 104;
 #endif
   struct __sanitizer_perf_event_attr {
     unsigned type;
@@ -107,7 +115,7 @@ namespace __sanitizer {
 
 #if defined(__powerpc64__) || defined(__s390__)
   const unsigned struct___old_kernel_stat_sz = 0;
-#else
+#elif !defined(__sparc__)
   const unsigned struct___old_kernel_stat_sz = 32;
 #endif
 
@@ -198,6 +206,18 @@ namespace __sanitizer {
     unsigned short __pad1;
     unsigned long __unused1;
     unsigned long __unused2;
+#elif defined(__sparc__)
+# if defined(__arch64__)
+    unsigned mode;
+    unsigned short __pad1;
+# else
+    unsigned short __pad1;
+    unsigned short mode;
+    unsigned short __pad2;
+# endif
+    unsigned short __seq;
+    unsigned long long __unused1;
+    unsigned long long __unused2;
 #else
     unsigned short mode;
     unsigned short __pad1;
@@ -215,6 +235,26 @@ namespace __sanitizer {
 
   struct __sanitizer_shmid_ds {
     __sanitizer_ipc_perm shm_perm;
+  #if defined(__sparc__)
+  # if !defined(__arch64__)
+    u32 __pad1;
+  # endif
+    long shm_atime;
+  # if !defined(__arch64__)
+    u32 __pad2;
+  # endif
+    long shm_dtime;
+  # if !defined(__arch64__)
+    u32 __pad3;
+  # endif
+    long shm_ctime;
+    uptr shm_segsz;
+    int shm_cpid;
+    int shm_lpid;
+    unsigned long shm_nattch;
+    unsigned long __glibc_reserved1;
+    unsigned long __glibc_reserved2;
+  #else
   #ifndef __powerpc__
     uptr shm_segsz;
   #elif !defined(__powerpc64__)
@@ -252,6 +292,7 @@ namespace __sanitizer {
     uptr __unused4;
     uptr __unused5;
   #endif
+#endif
   };
 #elif SANITIZER_FREEBSD
   struct __sanitizer_ipc_perm {
@@ -586,9 +627,13 @@ namespace __sanitizer {
     __sanitizer_sigset_t sa_mask;
 #endif
 #ifndef __mips__
+#if defined(__sparc__)
+    unsigned long sa_flags;
+#else
     int sa_flags;
 #endif
 #endif
+#endif
 #if SANITIZER_LINUX
     void (*sa_restorer)();
 #endif
@@ -849,7 +894,7 @@ struct __sanitizer_cookie_io_functions_t {
 
 #define IOC_NRBITS 8
 #define IOC_TYPEBITS 8
-#if defined(__powerpc__) || defined(__powerpc64__) || defined(__mips__)
+#if defined(__powerpc__) || defined(__powerpc64__) || defined(__mips__) || defined(__sparc__)
 #define IOC_SIZEBITS 13
 #define IOC_DIRBITS 3
 #define IOC_NONE 1U
@@ -879,7 +924,17 @@ struct __sanitizer_cookie_io_functions_t {
 #define IOC_DIR(nr) (((nr) >> IOC_DIRSHIFT) & IOC_DIRMASK)
 #define IOC_TYPE(nr) (((nr) >> IOC_TYPESHIFT) & IOC_TYPEMASK)
 #define IOC_NR(nr) (((nr) >> IOC_NRSHIFT) & IOC_NRMASK)
+
+#if defined(__sparc__)
+// In sparc the 14 bits SIZE field overlaps with the
+// least significant bit of DIR, so either IOC_READ or
+// IOC_WRITE shall be 1 in order to get a non-zero SIZE.
+# define IOC_SIZE(nr)                       \
+  ((((((nr) >> 29) & 0x7) & (4U|2U)) == 0)? \
+   0 : (((nr) >> 16) & 0x3fff))
+#else
 #define IOC_SIZE(nr) (((nr) >> IOC_SIZESHIFT) & IOC_SIZEMASK)
+#endif
 
   extern unsigned struct_ifreq_sz;
   extern unsigned struct_termios_sz;
-- 
1.9.1


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 3/7] Libsanitizer merge from upstream r285547.
       [not found]   ` <CGME20161107082451eucas1p2fe6f13bf569875cd62ccd673bc7db73a@eucas1p2.samsung.com>
@ 2016-11-07  8:25     ` Maxim Ostapenko
  0 siblings, 0 replies; 28+ messages in thread
From: Maxim Ostapenko @ 2016-11-07  8:25 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jakub Jelinek, Kostya Serebryany, Yuri Gribov

[-- Attachment #1: Type: text/plain, Size: 165 bytes --]

This patch adjusts the fix for 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61771 to extract the last 
PC from the stack frame if no valid FP is available for ARM.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0003-libsanitizer.patch --]
[-- Type: text/x-diff; name="0003-libsanitizer.patch", Size: 1962 bytes --]

From 6dc6e4f761080cf19a161fb0e27c1fd584688f40 Mon Sep 17 00:00:00 2001
From: Maxim Ostapenko <m.ostapenko@samsung.com>
Date: Tue, 25 Oct 2016 20:27:37 +0300
Subject: [PATCH 3/7] libsanitizer/

	* sanitizer_common/sanitizer_stacktrace.cc (GetCanonicFrame): Assume we
	compiled code with GCC when extracting the caller PC for ARM if no
	valid frame pointer is available.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229115 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libsanitizer/ChangeLog                                | 6 ++++++
 libsanitizer/sanitizer_common/sanitizer_stacktrace.cc | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog
index 10b1207..7e4f89f 100644
--- a/libsanitizer/ChangeLog
+++ b/libsanitizer/ChangeLog
@@ -1,5 +1,11 @@
 2016-11-07  Maxim Ostapenko  <m.ostapenko@samsung.com>
 
+	* sanitizer_common/sanitizer_stacktrace.cc (GetCanonicFrame): Assume we
+	compiled code with GCC when extracting the caller PC for ARM if no
+	valid frame pointer is available.
+
+2016-11-07  Maxim Ostapenko  <m.ostapenko@samsung.com>
+
 	PR sanitizer/63958
 	Reapply:
 	2014-10-14  David S. Miller  <davem@davemloft.net>
diff --git a/libsanitizer/sanitizer_common/sanitizer_stacktrace.cc b/libsanitizer/sanitizer_common/sanitizer_stacktrace.cc
index 531f256..cbb3af2 100644
--- a/libsanitizer/sanitizer_common/sanitizer_stacktrace.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_stacktrace.cc
@@ -55,8 +55,8 @@ static inline uhwptr *GetCanonicFrame(uptr bp,
   // Nope, this does not look right either. This means the frame after next does
   // not have a valid frame pointer, but we can still extract the caller PC.
   // Unfortunately, there is no way to decide between GCC and LLVM frame
-  // layouts. Assume LLVM.
-  return bp_prev;
+  // layouts. Assume GCC.
+  return bp_prev - 1;
 #else
   return (uhwptr*)bp;
 #endif
-- 
1.9.1


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 4/7] Libsanitizer merge from upstream r285547.
       [not found]   ` <CGME20161107082555eucas1p217136a7bc11b9033cad23d9579361228@eucas1p2.samsung.com>
@ 2016-11-07  8:26     ` Maxim Ostapenko
  0 siblings, 0 replies; 28+ messages in thread
From: Maxim Ostapenko @ 2016-11-07  8:26 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jakub Jelinek, Kostya Serebryany, Yuri Gribov

[-- Attachment #1: Type: text/plain, Size: 699 bytes --]

This is rewritten Jakub's fix for 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63888. Upstream now 
supports new approach for ODR violation detection: compiler emits new 
__odr_asan_XXX symbol for each instrumented global that indicates 
whether this global was already registered and the library checks this 
indicator symbol at runtime.
However, to preserve compatibility, the library still can fall to old, 
incompatible with GCC approach of ODR violation detection (say, when the 
odr indicator symbol wasn't emitted e.g. for static variable, libasan 
tries the old method). To avoid this, this patch removes 
CheckODRViolationViaPoisoning call and leaves only 
CheckODRViolationViaIndicator.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0004-libsanitizer.patch --]
[-- Type: text/x-diff; name="0004-libsanitizer.patch", Size: 2793 bytes --]

From 5cd9a7cb1c2dd668e533bee1bc15e367d367d84f Mon Sep 17 00:00:00 2001
From: Maxim Ostapenko <m.ostapenko@samsung.com>
Date: Fri, 28 Oct 2016 10:22:35 +0300
Subject: [PATCH 4/7] libsanitizer/

	* asan/asan_globals.cc (RegisterGlobal): Do not call
	CheckODRViolationViaPoisoning.
	(CheckODRViolationViaPoisoning): Remove.
---
 libsanitizer/ChangeLog            |  6 ++++++
 libsanitizer/asan/asan_globals.cc | 19 -------------------
 2 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog
index 7e4f89f..d439f45 100644
--- a/libsanitizer/ChangeLog
+++ b/libsanitizer/ChangeLog
@@ -1,5 +1,11 @@
 2016-11-07  Maxim Ostapenko  <m.ostapenko@samsung.com>
 
+	* asan/asan_globals.cc (RegisterGlobal): Do not call
+	CheckODRViolationViaPoisoning.
+	(CheckODRViolationViaPoisoning): Remove.
+
+2016-11-07  Maxim Ostapenko  <m.ostapenko@samsung.com>
+
 	* sanitizer_common/sanitizer_stacktrace.cc (GetCanonicFrame): Assume we
 	compiled code with GCC when extracting the caller PC for ARM if no
 	valid frame pointer is available.
diff --git a/libsanitizer/asan/asan_globals.cc b/libsanitizer/asan/asan_globals.cc
index 007fce72..f229292 100644
--- a/libsanitizer/asan/asan_globals.cc
+++ b/libsanitizer/asan/asan_globals.cc
@@ -147,23 +147,6 @@ static void CheckODRViolationViaIndicator(const Global *g) {
   }
 }
 
-// Check ODR violation for given global G by checking if it's already poisoned.
-// We use this method in case compiler doesn't use private aliases for global
-// variables.
-static void CheckODRViolationViaPoisoning(const Global *g) {
-  if (__asan_region_is_poisoned(g->beg, g->size_with_redzone)) {
-    // This check may not be enough: if the first global is much larger
-    // the entire redzone of the second global may be within the first global.
-    for (ListOfGlobals *l = list_of_all_globals; l; l = l->next) {
-      if (g->beg == l->g->beg &&
-          (flags()->detect_odr_violation >= 2 || g->size != l->g->size) &&
-          !IsODRViolationSuppressed(g->name))
-        ReportODRViolation(g, FindRegistrationSite(g),
-                           l->g, FindRegistrationSite(l->g));
-    }
-  }
-}
-
 // Clang provides two different ways for global variables protection:
 // it can poison the global itself or its private alias. In former
 // case we may poison same symbol multiple times, that can help us to
@@ -211,8 +194,6 @@ static void RegisterGlobal(const Global *g) {
     // where two globals with the same name are defined in different modules.
     if (UseODRIndicator(g))
       CheckODRViolationViaIndicator(g);
-    else
-      CheckODRViolationViaPoisoning(g);
   }
   if (CanPoisonMemory())
     PoisonRedZones(*g);
-- 
1.9.1


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 5/7] Libsanitizer merge from upstream r285547.
       [not found]   ` <CGME20161107082654eucas1p229c86ef02d8c2a90e0ffff113eca5ee7@eucas1p2.samsung.com>
@ 2016-11-07  8:27     ` Maxim Ostapenko
  0 siblings, 0 replies; 28+ messages in thread
From: Maxim Ostapenko @ 2016-11-07  8:27 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jakub Jelinek, Kostya Serebryany, Yuri Gribov

[-- Attachment #1: Type: text/plain, Size: 251 bytes --]

This patch just combines minimal necessary changes to support new 
libasan ABI. This patch doesn't try to implement odr indicators at 
compiler part, it simply pass a zero stub to runtime. The actual 
implementation of odr indicators goes in patch 7.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0005-libsanitizer-merge-from-upstream-r285547-compiler-pa.patch --]
[-- Type: text/x-diff; name="0005-libsanitizer-merge-from-upstream-r285547-compiler-pa.patch", Size: 5756 bytes --]

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(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f29b9b5..943e21c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/asan.c b/gcc/asan.c
index c6d9240..fdc84bd 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -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);
 }
diff --git a/gcc/asan.h b/gcc/asan.h
index 7ec693f..a259b1a 100644
--- a/gcc/asan.h
+++ b/gcc/asan.h
@@ -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
diff --git a/gcc/sanitizer.def b/gcc/sanitizer.def
index 303c1e4..ac85096 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 051ae83..49fab6e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
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)" } */
-- 
1.9.1


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 6/7] Libsanitizer merge from upstream r285547.
       [not found]   ` <CGME20161107082842eucas1p19cbcb798ace4eb86d8ea1460fb6ed8e0@eucas1p1.samsung.com>
@ 2016-11-07  8:28     ` Maxim Ostapenko
  0 siblings, 0 replies; 28+ messages in thread
From: Maxim Ostapenko @ 2016-11-07  8:28 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jakub Jelinek, Kostya Serebryany, Yuri Gribov

[-- Attachment #1: Type: text/plain, Size: 61 bytes --]

This patch just adds several tests backported from upstream.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0006-Backport-several-testcases-for-ASan-from-upstream.patch --]
[-- Type: text/x-diff; name="0006-Backport-several-testcases-for-ASan-from-upstream.patch", Size: 18166 bytes --]

From b4677ed64e7aee1af7772750e0b18ed8271f4757 Mon Sep 17 00:00:00 2001
From: Maxim Ostapenko <m.ostapenko@samsung.com>
Date: Tue, 1 Nov 2016 16:52:13 +0300
Subject: [PATCH 6/7] Backport several testcases for ASan from upstream.

gcc/

	* asan.h (asan_intercepted_p): Handle BUILT_IN_STRCSPN,
	BUILT_IN_STRPBRK, BUILT_IN_STRSPN and BUILT_IN_STRSTR.

gcc/testsuite/

	* c-c++-common/asan/default_options.h: New file.
	* c-c++-common/asan/strcasestr-1.c: New test.
	* c-c++-common/asan/strcasestr-2.c: Likewise.
	* c-c++-common/asan/strcspn-1.c: Likewise.
	* c-c++-common/asan/strcspn-2.c: Likewise.
	* c-c++-common/asan/strpbrk-1.c: Likewise.
	* c-c++-common/asan/strpbrk-2.c: Likewise.
	* c-c++-common/asan/strspn-1.c: Likewise.
	* c-c++-common/asan/strspn-2.c: Likewise.
	* c-c++-common/asan/strstr-1.c: Likewise.
	* c-c++-common/asan/strstr-2.c: Likewise.
	* c-c++-common/asan/halt_on_error_suppress_equal_pcs-1.c: Likewise.
---
 gcc/ChangeLog                                      |  5 +++
 gcc/asan.h                                         |  4 +++
 gcc/testsuite/ChangeLog                            | 15 +++++++++
 gcc/testsuite/c-c++-common/asan/default_options.h  |  9 +++++
 .../asan/halt_on_error_suppress_equal_pcs-1.c      | 38 ++++++++++++++++++++++
 gcc/testsuite/c-c++-common/asan/strcasestr-1.c     | 32 ++++++++++++++++++
 gcc/testsuite/c-c++-common/asan/strcasestr-2.c     | 32 ++++++++++++++++++
 gcc/testsuite/c-c++-common/asan/strcspn-1.c        | 31 ++++++++++++++++++
 gcc/testsuite/c-c++-common/asan/strcspn-2.c        | 31 ++++++++++++++++++
 gcc/testsuite/c-c++-common/asan/strpbrk-1.c        | 31 ++++++++++++++++++
 gcc/testsuite/c-c++-common/asan/strpbrk-2.c        | 31 ++++++++++++++++++
 gcc/testsuite/c-c++-common/asan/strspn-1.c         | 31 ++++++++++++++++++
 gcc/testsuite/c-c++-common/asan/strspn-2.c         | 31 ++++++++++++++++++
 gcc/testsuite/c-c++-common/asan/strstr-1.c         | 31 ++++++++++++++++++
 gcc/testsuite/c-c++-common/asan/strstr-2.c         | 31 ++++++++++++++++++
 15 files changed, 383 insertions(+)
 create mode 100644 gcc/testsuite/c-c++-common/asan/default_options.h
 create mode 100644 gcc/testsuite/c-c++-common/asan/halt_on_error_suppress_equal_pcs-1.c
 create mode 100644 gcc/testsuite/c-c++-common/asan/strcasestr-1.c
 create mode 100644 gcc/testsuite/c-c++-common/asan/strcasestr-2.c
 create mode 100644 gcc/testsuite/c-c++-common/asan/strcspn-1.c
 create mode 100644 gcc/testsuite/c-c++-common/asan/strcspn-2.c
 create mode 100644 gcc/testsuite/c-c++-common/asan/strpbrk-1.c
 create mode 100644 gcc/testsuite/c-c++-common/asan/strpbrk-2.c
 create mode 100644 gcc/testsuite/c-c++-common/asan/strspn-1.c
 create mode 100644 gcc/testsuite/c-c++-common/asan/strspn-2.c
 create mode 100644 gcc/testsuite/c-c++-common/asan/strstr-1.c
 create mode 100644 gcc/testsuite/c-c++-common/asan/strstr-2.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 943e21c..1da0ef9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
 2016-11-07  Maxim Ostapenko  <m.ostapenko@samsung.com>
 
+	* asan.h (asan_intercepted_p): Handle BUILT_IN_STRCSPN,
+	BUILT_IN_STRPBRK, BUILT_IN_STRSPN and BUILT_IN_STRSTR.
+
+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.
diff --git a/gcc/asan.h b/gcc/asan.h
index a259b1a..b96395b 100644
--- a/gcc/asan.h
+++ b/gcc/asan.h
@@ -102,6 +102,10 @@ asan_intercepted_p (enum built_in_function fcode)
 	 || fcode == BUILT_IN_STRNCASECMP
 	 || fcode == BUILT_IN_STRNCAT
 	 || fcode == BUILT_IN_STRNCMP
+	 || fcode == BUILT_IN_STRCSPN
+	 || fcode == BUILT_IN_STRPBRK
+	 || fcode == BUILT_IN_STRSPN
+	 || fcode == BUILT_IN_STRSTR
 	 || fcode == BUILT_IN_STRNCPY;
 }
 #endif /* TREE_ASAN */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 49fab6e..afa77a8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,20 @@
 2016-11-07  Maxim Ostapenko  <m.ostapenko@samsung.com>
 
+	* c-c++-common/asan/default_options.h: New file.
+	* c-c++-common/asan/strcasestr-1.c: New test.
+	* c-c++-common/asan/strcasestr-2.c: Likewise.
+	* c-c++-common/asan/strcspn-1.c: Likewise.
+	* c-c++-common/asan/strcspn-2.c: Likewise.
+	* c-c++-common/asan/strpbrk-1.c: Likewise.
+	* c-c++-common/asan/strpbrk-2.c: Likewise.
+	* c-c++-common/asan/strspn-1.c: Likewise.
+	* c-c++-common/asan/strspn-2.c: Likewise.
+	* c-c++-common/asan/strstr-1.c: Likewise.
+	* c-c++-common/asan/strstr-2.c: Likewise.
+	* c-c++-common/asan/halt_on_error_suppress_equal_pcs-1.c: Likewise.
+
+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>
diff --git a/gcc/testsuite/c-c++-common/asan/default_options.h b/gcc/testsuite/c-c++-common/asan/default_options.h
new file mode 100644
index 0000000..1e5c486
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/default_options.h
@@ -0,0 +1,9 @@
+#ifdef __cplusplus
+extern "C"
+#endif
+const char *
+__asan_default_options ()
+{
+  /* The asan_default_options string should be defined in testcase.  */
+  return asan_default_options;
+}
diff --git a/gcc/testsuite/c-c++-common/asan/halt_on_error_suppress_equal_pcs-1.c b/gcc/testsuite/c-c++-common/asan/halt_on_error_suppress_equal_pcs-1.c
new file mode 100644
index 0000000..df44a04
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/halt_on_error_suppress_equal_pcs-1.c
@@ -0,0 +1,38 @@
+/* Test suppress_equal_pcs in recovery mode.  */
+/* { dg-do run } */
+/* { dg-options "-fsanitize-recover=address" } */
+
+static const char asan_default_options[] = "halt_on_error=false:suppress_equal_pcs=true";
+#include "default_options.h"
+
+#define ACCESS_ARRAY_FIVE_ELEMENTS(array, i)                                   \
+  array[i] = i;                                                                \
+  array[i + 1] = i + 1;                                                        \
+  array[i + 2] = i + 2;                                                        \
+  array[i + 3] = i + 3;                                                        \
+  array[i + 4] = i + 4;
+
+volatile int ten = 10;
+unsigned kNumIterations = 10;
+
+int
+main (int argc, char **argv)
+{
+  char a[10];
+  char b[10];
+
+  for (int i = 0; i < kNumIterations; ++i)
+    {
+      volatile int res = a[ten + i];
+      a[i + ten] = res + 3;
+      res = a[ten + i];
+    }
+  return 0;
+}
+
+/* { dg-output "\[^\n\r]*READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */
+/* { dg-output "\[^\n\r]*WRITE of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */
+/* { dg-output "\[^\n\r]*READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */
+/* { dg-prune-output "\[^\n\r]*READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */
+/* { dg-prune-output "\[^\n\r]*WRITE of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */
+/* { dg-prune-output "\[^\n\r]*READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r).*" } */
diff --git a/gcc/testsuite/c-c++-common/asan/strcasestr-1.c b/gcc/testsuite/c-c++-common/asan/strcasestr-1.c
new file mode 100644
index 0000000..a3e58df
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/strcasestr-1.c
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-shouldfail "asan" } */
+
+#include <assert.h>
+#include <sanitizer/asan_interface.h>
+
+static const char asan_default_options[] = "strict_string_checks=true";
+#include "default_options.h"
+
+#ifndef __cplusplus
+#define _GNU_SOURCE
+#else
+extern "C"
+#endif
+char *strcasestr (const char *haystack, const char *needle);
+
+int
+main (int argc, char **argv)
+{
+  char *r = 0;
+  char s2[] = "c";
+  char s1[4] = "abC";
+  __asan_poison_memory_region ((char *) &s1[2], 2);
+  r = strcasestr (s1, s2);
+  assert (r == s1 + 2);
+  return 0;
+}
+
+/* { dg-output "READ of size 4 at .* thread T0.*" } */
+/* { dg-output ".*(main)?.*strcasestr-1.(c:24)?.*" } */
+/* { dg-output "is located in stack of thread T0 at offset.*" } */
+/* { dg-output "\[^\n\r]*Address 0x\[0-9a-f\]+ is located in stack of thread T0.*(\n|\r\n|\r)" */
diff --git a/gcc/testsuite/c-c++-common/asan/strcasestr-2.c b/gcc/testsuite/c-c++-common/asan/strcasestr-2.c
new file mode 100644
index 0000000..f21d162
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/strcasestr-2.c
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-shouldfail "asan" } */
+
+#include <assert.h>
+#include <sanitizer/asan_interface.h>
+
+static const char asan_default_options[] = "strict_string_checks=true";
+#include "default_options.h"
+
+#ifndef __cplusplus
+#define _GNU_SOURCE
+#else
+extern "C"
+#endif
+char *strcasestr (const char *haystack, const char *needle);
+
+int
+main (int argc, char **argv)
+{
+  char *r = 0;
+  char s1[] = "ab";
+  char s2[4] = "cba";
+  __asan_poison_memory_region ((char *) &s2[2], 2);
+  r = strcasestr (s1, s2);
+  assert (r == 0);
+  return 0;
+}
+
+/* { dg-output "READ of size 4 at .* thread T0.*" } */
+/* { dg-output ".*(main)?.*strcasestr-2.(c:24)?.*" } */
+/* { dg-output "is located in stack of thread T0 at offset.*" } */
+/* { dg-output "\[^\n\r]*Address 0x\[0-9a-f\]+ is located in stack of thread T0.*(\n|\r\n|\r)" */
diff --git a/gcc/testsuite/c-c++-common/asan/strcspn-1.c b/gcc/testsuite/c-c++-common/asan/strcspn-1.c
new file mode 100644
index 0000000..8a95bac
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/strcspn-1.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-shouldfail "asan" } */
+
+#include <assert.h>
+#include <sanitizer/asan_interface.h>
+
+static const char asan_default_options[] = "strict_string_checks=true";
+#include "default_options.h"
+
+#ifdef __cplusplus
+extern "C"
+#endif
+__SIZE_TYPE__
+strcspn (const char *s, const char *reject);
+
+int
+main (int argc, char **argv)
+{
+  __SIZE_TYPE__ r;
+  char s2[] = "ab";
+  char s1[4] = "caB";
+  __asan_poison_memory_region ((char *) &s1[2], 2);
+  r = strcspn (s1, s2);
+  assert (r == 1);
+  return 0;
+}
+
+/* { dg-output "READ of size 4 at .* thread T0.*" } */
+/* { dg-output ".*(main)?.*strcspn-1.(c:23)?.*" } */
+/* { dg-output "is located in stack of thread T0 at offset.*" } */
+/* { dg-output "\[^\n\r]*Address 0x\[0-9a-f\]+ is located in stack of thread T0.*(\n|\r\n|\r)" */
diff --git a/gcc/testsuite/c-c++-common/asan/strcspn-2.c b/gcc/testsuite/c-c++-common/asan/strcspn-2.c
new file mode 100644
index 0000000..d605a41
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/strcspn-2.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-shouldfail "asan" } */
+
+#include <assert.h>
+#include <sanitizer/asan_interface.h>
+
+static const char asan_default_options[] = "strict_string_checks=true";
+#include "default_options.h"
+
+#ifdef __cplusplus
+extern "C"
+#endif
+__SIZE_TYPE__
+strcspn (const char *s, const char *reject);
+
+int
+main (int argc, char **argv)
+{
+  __SIZE_TYPE__ r;
+  char s1[] = "ab";
+  char s2[4] = "abc";
+  __asan_poison_memory_region ((char *) &s2[2], 2);
+  r = strcspn (s1, s2);
+  assert (r == 0);
+  return 0;
+}
+
+/* { dg-output "READ of size 4 at .* thread T0.*" } */
+/* { dg-output ".*(main)?.*strcspn-2.(c:23)?.*" } */
+/* { dg-output "is located in stack of thread T0 at offset.*" } */
+/* { dg-output "\[^\n\r]*Address 0x\[0-9a-f\]+ is located in stack of thread T0.*(\n|\r\n|\r)" */
diff --git a/gcc/testsuite/c-c++-common/asan/strpbrk-1.c b/gcc/testsuite/c-c++-common/asan/strpbrk-1.c
new file mode 100644
index 0000000..f4c2590
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/strpbrk-1.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-shouldfail "asan" } */
+
+#include <assert.h>
+#include <sanitizer/asan_interface.h>
+
+static const char asan_default_options[] = "strict_string_checks=true";
+#include "default_options.h"
+
+#ifdef __cplusplus
+extern "C"
+#endif
+char *
+strpbrk (const char *s, const char *accept);
+
+int
+main (int argc, char **argv)
+{
+  char *r;
+  char s2[] = "ab";
+  char s1[4] = "cab";
+  __asan_poison_memory_region ((char *) &s1[2], 2);
+  r = strpbrk (s1, s2);
+  assert (r == s1 + 1);
+  return 0;
+}
+
+/* { dg-output "READ of size 4 at .* thread T0.*" } */
+/* { dg-output ".*(main)?.*strpbrk-1.(c:23)?.*" } */
+/* { dg-output "is located in stack of thread T0 at offset.*" } */
+/* { dg-output "\[^\n\r]*Address 0x\[0-9a-f\]+ is located in stack of thread T0.*(\n|\r\n|\r)" */
diff --git a/gcc/testsuite/c-c++-common/asan/strpbrk-2.c b/gcc/testsuite/c-c++-common/asan/strpbrk-2.c
new file mode 100644
index 0000000..4558694
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/strpbrk-2.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-shouldfail "asan" } */
+
+#include <assert.h>
+#include <sanitizer/asan_interface.h>
+
+static const char asan_default_options[] = "strict_string_checks=true";
+#include "default_options.h"
+
+#ifdef __cplusplus
+extern "C"
+#endif
+char *
+strpbrk (const char *s, const char *accept);
+
+int
+main (int argc, char **argv)
+{
+  char *r;
+  char s1[] = "c";
+  char s2[4] = "bca";
+  __asan_poison_memory_region ((char *) &s2[2], 2);
+  r = strpbrk (s1, s2);
+  assert (r == s1);
+  return 0;
+}
+
+/* { dg-output "READ of size 4 at .* thread T0.*" } */
+/* { dg-output ".*(main)?.*strpbrk-2.(c:23)?.*" } */
+/* { dg-output "is located in stack of thread T0 at offset.*" } */
+/* { dg-output "\[^\n\r]*Address 0x\[0-9a-f\]+ is located in stack of thread T0.*(\n|\r\n|\r)" */
diff --git a/gcc/testsuite/c-c++-common/asan/strspn-1.c b/gcc/testsuite/c-c++-common/asan/strspn-1.c
new file mode 100644
index 0000000..63d96ba
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/strspn-1.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-shouldfail "asan" } */
+
+#include <assert.h>
+#include <sanitizer/asan_interface.h>
+
+static const char asan_default_options[] = "strict_string_checks=true";
+#include "default_options.h"
+
+#ifdef __cplusplus
+extern "C"
+#endif
+__SIZE_TYPE__
+strspn (const char *s, const char *reject);
+
+int
+main (int argc, char **argv)
+{
+  __SIZE_TYPE__ r;
+  char s2[] = "ab";
+  char s1[4] = "acb";
+  __asan_poison_memory_region ((char *) &s1[2], 2);
+  r = strspn (s1, s2);
+  assert (r == 1);
+  return 0;
+}
+
+/* { dg-output "READ of size 4 at .* thread T0.*" } */
+/* { dg-output ".*(main)?.*strspn-1.(c:23)?.*" } */
+/* { dg-output "is located in stack of thread T0 at offset.*" } */
+/* { dg-output "\[^\n\r]*Address 0x\[0-9a-f\]+ is located in stack of thread T0.*(\n|\r\n|\r)" */
diff --git a/gcc/testsuite/c-c++-common/asan/strspn-2.c b/gcc/testsuite/c-c++-common/asan/strspn-2.c
new file mode 100644
index 0000000..ac7a742
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/strspn-2.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-shouldfail "asan" } */
+
+#include <assert.h>
+#include <sanitizer/asan_interface.h>
+
+static const char asan_default_options[] = "strict_string_checks=true";
+#include "default_options.h"
+
+#ifdef __cplusplus
+extern "C"
+#endif
+__SIZE_TYPE__
+strspn (const char *s, const char *reject);
+
+int
+main (int argc, char **argv)
+{
+  size_t r;
+  char s1[] = "bbc";
+  char s2[5] = "abcd";
+  __asan_poison_memory_region ((char *) &s2[3], 2);
+  r = strspn (s1, s2);
+  assert (r >= 2);
+  return 0;
+}
+
+/* { dg-output "READ of size 5 at .* thread T0.*" } */
+/* { dg-output ".*(main)?.*strspn-2.(c:23)?.*" } */
+/* { dg-output "is located in stack of thread T0 at offset.*" } */
+/* { dg-output "\[^\n\r]*Address 0x\[0-9a-f\]+ is located in stack of thread T0.*(\n|\r\n|\r)" */
diff --git a/gcc/testsuite/c-c++-common/asan/strstr-1.c b/gcc/testsuite/c-c++-common/asan/strstr-1.c
new file mode 100644
index 0000000..2c59e53
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/strstr-1.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-shouldfail "asan" } */
+
+#include <assert.h>
+#include <sanitizer/asan_interface.h>
+
+static const char asan_default_options[] = "strict_string_checks=true";
+#include "default_options.h"
+
+#ifdef __cplusplus
+extern "C"
+#endif
+char *
+strstr (const char *haystack, const char *needle);
+
+int
+main (int argc, char **argv)
+{
+  char *r = 0;
+  char s2[] = "c";
+  char s1[4] = "acb";
+  __asan_poison_memory_region ((char *) &s1[2], 2);
+  r = strstr (s1, s2);
+  assert (r == s1 + 1);
+  return 0;
+}
+
+/* { dg-output "READ of size 4 at .* thread T0.*" } */
+/* { dg-output ".*(main)?.*strstr-1.(c:23)?.*" } */
+/* { dg-output "is located in stack of thread T0 at offset.*" } */
+/* { dg-output "\[^\n\r]*Address 0x\[0-9a-f\]+ is located in stack of thread T0.*(\n|\r\n|\r)" */
diff --git a/gcc/testsuite/c-c++-common/asan/strstr-2.c b/gcc/testsuite/c-c++-common/asan/strstr-2.c
new file mode 100644
index 0000000..785293c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/strstr-2.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-shouldfail "asan" } */
+
+#include <assert.h>
+#include <sanitizer/asan_interface.h>
+
+static const char asan_default_options[] = "strict_string_checks=true";
+#include "default_options.h"
+
+#ifdef __cplusplus
+extern "C"
+#endif
+char *
+strstr (const char *haystack, const char *needle);
+
+int
+main (int argc, char **argv)
+{
+  char *r = 0;
+  char s1[] = "ab";
+  char s2[4] = "cab";
+  __asan_poison_memory_region ((char *) &s2[2], 2);
+  r = strstr (s1, s2);
+  assert (r == 0);
+  return 0;
+}
+
+/* { dg-output "READ of size 4 at .* thread T0.*" } */
+/* { dg-output ".*(main)?.*strstr-2.(c:23)?.*" } */
+/* { dg-output "is located in stack of thread T0 at offset.*" } */
+/* { dg-output "\[^\n\r]*Address 0x\[0-9a-f\]+ is located in stack of thread T0.*(\n|\r\n|\r)" */
-- 
1.9.1


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 7/7] Libsanitizer merge from upstream r285547.
       [not found]   ` <CGME20161107083119eucas1p25c96348950eded7dd68ae9813db3c2cb@eucas1p2.samsung.com>
@ 2016-11-07  8:31     ` Maxim Ostapenko
  2016-11-07  8:52       ` Jakub Jelinek
  0 siblings, 1 reply; 28+ messages in thread
From: Maxim Ostapenko @ 2016-11-07  8:31 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jakub Jelinek, Kostya Serebryany, Yuri Gribov

[-- Attachment #1: Type: text/plain, Size: 494 bytes --]

This patch tries to implement odr indicators functionality at compiler 
side.
We emit new __odr_asan_XXX symbol for each instrumented global that 
indicates whether this global was already registered and the library 
checks this indicator symbol at runtime. For some globals (e.g. static 
or hidden) the odr indicator is not needed, thus we can skip the 
indicator for them and pass zero to runtime.
If this patch is undesirable at this stage, we can probably postpone it 
until GCC 8 though.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0007-Add-support-for-ASan-odr_indicator.patch --]
[-- Type: text/x-diff; name="0007-Add-support-for-ASan-odr_indicator.patch", Size: 8927 bytes --]

From 137f139972a89259b9d8521e13ecb76fd2cef433 Mon Sep 17 00:00:00 2001
From: Maxim Ostapenko <m.ostapenko@samsung.com>
Date: Fri, 28 Oct 2016 10:22:03 +0300
Subject: [PATCH 7/7] Add support for ASan odr_indicator.

config/

	* bootstrap-asan.mk: Replace LSAN_OPTIONS=detect_leaks=0 with
	ASAN_OPTIONS=detect_leaks=0:use_odr_indicator=1.

gcc/

	* asan.c (asan_global_struct): Refactor.
	(create_odr_indicator): New function.
	(asan_needs_odr_indicator_p): Likewise.
	(is_odr_indicator): Likewise.
	(asan_add_global): Introduce odr_indicator_ptr. Pass it into global's
	constructor.
	(asan_protect_global): Do not protect odr indicators.

gcc/testsuite/

	* c-c++-common/asan/no-redundant-odr-indicators-1.c: New test.
---
 config/ChangeLog                                   |  5 ++
 config/bootstrap-asan.mk                           |  2 +-
 gcc/ChangeLog                                      | 10 +++
 gcc/asan.c                                         | 76 +++++++++++++++++++---
 gcc/testsuite/ChangeLog                            |  4 ++
 .../asan/no-redundant-odr-indicators-1.c           | 17 +++++
 6 files changed, 105 insertions(+), 9 deletions(-)
 create mode 100644 gcc/testsuite/c-c++-common/asan/no-redundant-odr-indicators-1.c

diff --git a/config/ChangeLog b/config/ChangeLog
index 3b0092b..0c75185 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,8 @@
+2016-11-07  Maxim Ostapenko  <m.ostapenko@samsung.com>
+
+	* bootstrap-asan.mk: Replace LSAN_OPTIONS=detect_leaks=0 with
+	ASAN_OPTIONS=detect_leaks=0:use_odr_indicator=1.
+
 2016-06-21  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
 
 	* elf.m4: Remove interix support.
diff --git a/config/bootstrap-asan.mk b/config/bootstrap-asan.mk
index 70baaf9..e73d4c2 100644
--- a/config/bootstrap-asan.mk
+++ b/config/bootstrap-asan.mk
@@ -1,7 +1,7 @@
 # This option enables -fsanitize=address for stage2 and stage3.
 
 # Suppress LeakSanitizer in bootstrap.
-export LSAN_OPTIONS="detect_leaks=0"
+export ASAN_OPTIONS=detect_leaks=0:use_odr_indicator=1
 
 STAGE2_CFLAGS += -fsanitize=address
 STAGE3_CFLAGS += -fsanitize=address
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1da0ef9..527cafa 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,15 @@
 2016-11-07  Maxim Ostapenko  <m.ostapenko@samsung.com>
 
+	* asan.c (asan_global_struct): Refactor.
+	(create_odr_indicator): New function.
+	(asan_needs_odr_indicator_p): Likewise.
+	(is_odr_indicator): Likewise.
+	(asan_add_global): Introduce odr_indicator_ptr. Pass it into global's
+	constructor.
+	(asan_protect_global): Do not protect odr indicators.
+
+2016-11-07  Maxim Ostapenko  <m.ostapenko@samsung.com>
+
 	* asan.h (asan_intercepted_p): Handle BUILT_IN_STRCSPN,
 	BUILT_IN_STRPBRK, BUILT_IN_STRSPN and BUILT_IN_STRSTR.
 
diff --git a/gcc/asan.c b/gcc/asan.c
index fdc84bd..b54110a 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1329,6 +1329,16 @@ asan_needs_local_alias (tree decl)
   return DECL_WEAK (decl) || !targetm.binds_local_p (decl);
 }
 
+/* Return true if DECL, a global var, is an artificial ODR indicator symbol
+   therefore doesn't need protection.  */
+
+static bool
+is_odr_indicator (tree decl)
+{
+  const char *sym_name = IDENTIFIER_POINTER (DECL_NAME (decl));
+  return strstr(sym_name, "_.__odr_asan_") == sym_name;
+}
+
 /* Return true if DECL is a VAR_DECL that should be protected
    by Address Sanitizer, by appending a red zone with protected
    shadow memory after it and aligning it to at least
@@ -1377,7 +1387,8 @@ asan_protect_global (tree decl)
       || ASAN_RED_ZONE_SIZE * BITS_PER_UNIT > MAX_OFILE_ALIGNMENT
       || !valid_constant_size_p (DECL_SIZE_UNIT (decl))
       || DECL_ALIGN_UNIT (decl) > 2 * ASAN_RED_ZONE_SIZE
-      || TREE_TYPE (decl) == ubsan_get_source_location_type ())
+      || TREE_TYPE (decl) == ubsan_get_source_location_type ()
+      || is_odr_indicator (decl))
     return false;
 
   rtl = DECL_RTL (decl);
@@ -2197,14 +2208,15 @@ asan_dynamic_init_call (bool after_p)
 static tree
 asan_global_struct (void)
 {
-  static const char *field_names[8]
+  static const char *field_names[]
     = { "__beg", "__size", "__size_with_redzone",
-	"__name", "__module_name", "__has_dynamic_init", "__location", "__odr_indicator"};
-  tree fields[8], ret;
-  int i;
+	"__name", "__module_name", "__has_dynamic_init", "__location",
+	"__odr_indicator"};
+  tree fields[ARRAY_SIZE (field_names)], ret;
+  unsigned i;
 
   ret = make_node (RECORD_TYPE);
-  for (i = 0; i < 8; i++)
+  for (i = 0; i < ARRAY_SIZE (field_names); i++)
     {
       fields[i]
 	= build_decl (UNKNOWN_LOCATION, FIELD_DECL,
@@ -2226,6 +2238,52 @@ asan_global_struct (void)
   return ret;
 }
 
+/* Create and return odr indicator symbol for DECL.
+   TYPE is __asan_global struct type as returned by asan_global_struct.  */
+
+static tree
+create_odr_indicator (tree decl, tree type)
+{
+  char sym_name[100], tmp_name[100];
+  static int lasan_odr_ind_cnt = 0;
+  tree uptr = TREE_TYPE (DECL_CHAIN (TYPE_FIELDS (type)));
+
+  snprintf (tmp_name, sizeof (tmp_name), "__odr_asan_%s_",
+	    IDENTIFIER_POINTER (DECL_NAME (decl)));
+  ASM_GENERATE_INTERNAL_LABEL (sym_name, tmp_name, ++lasan_odr_ind_cnt);
+  char *asterisk = sym_name;
+  while ((asterisk = strchr (asterisk, '*')))
+    *asterisk = '_';
+  tree var = build_decl (UNKNOWN_LOCATION, VAR_DECL, get_identifier (sym_name),
+			 char_type_node);
+  TREE_ADDRESSABLE (var) = TREE_ADDRESSABLE (decl);
+  TREE_READONLY (var) = 0;
+  TREE_THIS_VOLATILE (var) = 1;
+  DECL_GIMPLE_REG_P (var) = DECL_GIMPLE_REG_P (decl);
+  DECL_ARTIFICIAL (var) = 1;
+  DECL_IGNORED_P (var) = DECL_IGNORED_P (decl);
+  TREE_STATIC (var) = 1;
+  TREE_PUBLIC (var) = 1;
+  DECL_VISIBILITY (var) = DECL_VISIBILITY (decl);
+  TREE_USED (var) = 1;
+  tree ctor = build_constructor_va (TREE_TYPE (var), 1, NULL_TREE,
+				    build_int_cst (unsigned_type_node, 0));
+  TREE_CONSTANT (ctor) = 1;
+  TREE_STATIC (ctor) = 1;
+  DECL_INITIAL (var) = ctor;
+  varpool_node::finalize_decl (var);
+  return fold_convert (uptr, build_fold_addr_expr (var));
+}
+
+/* Return true if DECL, a global var, might be overridden and needs
+   an additional odr indicator symbol.  */
+
+static bool
+asan_needs_odr_indicator_p (tree decl)
+{
+  return !DECL_ARTIFICIAL (decl) && !DECL_WEAK (decl) && TREE_PUBLIC (decl);
+}
+
 /* Append description of a single global DECL into vector V.
    TYPE is __asan_global struct type as returned by asan_global_struct.  */
 
@@ -2266,6 +2324,9 @@ asan_add_global (tree decl, tree type, vec<constructor_elt, va_gc> *v)
       assemble_alias (refdecl, DECL_ASSEMBLER_NAME (decl));
     }
 
+  tree odr_indicator_ptr = asan_needs_odr_indicator_p (decl)
+			     ? create_odr_indicator (decl, type)
+			     : build_int_cst (uptr, 0);
   CONSTRUCTOR_APPEND_ELT (vinner, NULL_TREE,
 			  fold_convert (const_ptr_type_node,
 					build_fold_addr_expr (refdecl)));
@@ -2313,8 +2374,7 @@ 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));
+  CONSTRUCTOR_APPEND_ELT(vinner, NULL_TREE, odr_indicator_ptr);
   init = build_constructor (type, vinner);
   CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, init);
 }
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index afa77a8..7d11a7c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
 2016-11-07  Maxim Ostapenko  <m.ostapenko@samsung.com>
 
+	* c-c++-common/asan/no-redundant-odr-indicators-1.c: New test.
+
+2016-11-07  Maxim Ostapenko  <m.ostapenko@samsung.com>
+
 	* c-c++-common/asan/default_options.h: New file.
 	* c-c++-common/asan/strcasestr-1.c: New test.
 	* c-c++-common/asan/strcasestr-2.c: Likewise.
diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-odr-indicators-1.c b/gcc/testsuite/c-c++-common/asan/no-redundant-odr-indicators-1.c
new file mode 100644
index 0000000..ff1f272
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/no-redundant-odr-indicators-1.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
+
+/* Local variables should not have odr indicators.  */
+static int a = 2;
+/* Thread local variables should not have odr indicators.  */
+__thread int b = 3;
+/* Externally visible  variables should have odr indicators.  */
+int c = 1;
+
+int main () {
+    return 0;
+}
+
+/* { dg-final { scan-assembler-not ".*odr_asan_a.*" } } */
+/* { dg-final { scan-assembler-not ".*odr_asan_b.*" } } */
+/* { dg-final { scan-assembler ".*odr_asan_c.*" } } */
-- 
1.9.1


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 1/7] Libsanitizer merge from upstream r285547.
  2016-11-07  8:22 ` [PATCH 0/7] Libsanitizer merge from upstream r285547 Maxim Ostapenko
                     ` (5 preceding siblings ...)
       [not found]   ` <CGME20161107083119eucas1p25c96348950eded7dd68ae9813db3c2cb@eucas1p2.samsung.com>
@ 2016-11-07  8:34   ` Maxim Ostapenko
  2016-11-07  8:40   ` [PATCH 0/7] " Jakub Jelinek
  2016-11-07 10:04   ` Jakub Jelinek
  8 siblings, 0 replies; 28+ messages in thread
From: Maxim Ostapenko @ 2016-11-07  8:34 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jakub Jelinek, Kostya Serebryany, Yuri Gribov

[-- Attachment #1: Type: text/plain, Size: 135 bytes --]

This patch performs the library merge itself.
The patch was too big for my mail client, so I needed to compress it. 
Sorry about that.

[-- Attachment #2: 0001-libsanitizer-merge-from-upstream-r285547.patch.tar.gz --]
[-- Type: application/gzip, Size: 262087 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 0/7] Libsanitizer merge from upstream r285547.
  2016-11-07  8:22 ` [PATCH 0/7] Libsanitizer merge from upstream r285547 Maxim Ostapenko
                     ` (6 preceding siblings ...)
  2016-11-07  8:34   ` [PATCH 1/7] Libsanitizer merge from upstream r285547 Maxim Ostapenko
@ 2016-11-07  8:40   ` Jakub Jelinek
  2016-11-07  9:14     ` Maxim Ostapenko
  2016-11-07 10:04   ` Jakub Jelinek
  8 siblings, 1 reply; 28+ messages in thread
From: Jakub Jelinek @ 2016-11-07  8:40 UTC (permalink / raw)
  To: Maxim Ostapenko; +Cc: GCC Patches, Kostya Serebryany, Yuri Gribov

On Mon, Nov 07, 2016 at 11:22:28AM +0300, Maxim Ostapenko wrote:
> this patch set performs libsanitizer merge from upstream.
> 
> Patch 1 is the library merge itself.
> 
> Patch 2 is the reapplied change for SPARC by David S. Miller.
> 
> Patch 3 changes heuristic for extracting last PC from stack frame for ARM in
> fast unwind routine. More details can be found here
> (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61771).
> 
> Patch 4 replaces Jakub's fix for
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63888 and removes
> CheckODRViolationViaPoisoning call from RegisterGlobal to avoid false
> positive odr violation reports.
> 
> Patch 5 combines necessary compiler changes.
> 
> Patch 6 adds several new tests, backported from upstream.
> 
> Patch 7 adds support for ASan odr indicators at compiler side.
> 
> The whole patch set was regtested/bootstrapped/ASan bootstrapped on
> x86_64-unknown-linux-gnu and i386-unknown-linux-gnu.
> Also, passed regression tests on arm-linux-gnueabi and aarch64-linux under
> QEMU.

So, libasan.so.* is again ABI incompatible, but libtsan and libubsan stay
(hopefully) backwards ABI compatible?

	Jakub

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 7/7] Libsanitizer merge from upstream r285547.
  2016-11-07  8:31     ` [PATCH 7/7] " Maxim Ostapenko
@ 2016-11-07  8:52       ` Jakub Jelinek
  2016-11-14  8:44         ` [PATCH v2] Support ASan ODR indicators at compiler side Maxim Ostapenko
  0 siblings, 1 reply; 28+ messages in thread
From: Jakub Jelinek @ 2016-11-07  8:52 UTC (permalink / raw)
  To: Maxim Ostapenko; +Cc: GCC Patches, Kostya Serebryany, Yuri Gribov

On Mon, Nov 07, 2016 at 11:31:18AM +0300, Maxim Ostapenko wrote:
> --- a/gcc/asan.c
> +++ b/gcc/asan.c
> @@ -1329,6 +1329,16 @@ asan_needs_local_alias (tree decl)
>    return DECL_WEAK (decl) || !targetm.binds_local_p (decl);
>  }
>  
> +/* Return true if DECL, a global var, is an artificial ODR indicator symbol
> +   therefore doesn't need protection.  */
> +
> +static bool
> +is_odr_indicator (tree decl)
> +{
> +  const char *sym_name = IDENTIFIER_POINTER (DECL_NAME (decl));
> +  return strstr(sym_name, "_.__odr_asan_") == sym_name;

Formatting, missing space before (.
Plus strstr (x, y) == x is very inefficient, strncmp would be cheaper.
But more importantly, you are relying on what exactly does
ASM_GENERATE_INTERNAL_LABEL, that differs between targets, not all of them
e.g. allow . in symbol names, other targets use $, others can only use _,
etc.  I think you'd better just add "asan odr indicator" attribute
(including the spaces, so it isn't something users can add to their
variables) to the artificial vars and lookup_attribute in the
is_odr_indicator predicate (after testing some cheap flags like
DECL_ARTIFICIAL).

> +  tree var = build_decl (UNKNOWN_LOCATION, VAR_DECL, get_identifier (sym_name),
> +			 char_type_node);
> +  TREE_ADDRESSABLE (var) = TREE_ADDRESSABLE (decl);

How is addressability of the original decl related to addressability of the
indicator?  If you take address of the indicator (it is stored in the
structure), it should be just 1.

> +  TREE_READONLY (var) = 0;
> +  TREE_THIS_VOLATILE (var) = 1;
> +  DECL_GIMPLE_REG_P (var) = DECL_GIMPLE_REG_P (decl);

Again, how is this related?  Just store 0.

> +  DECL_ARTIFICIAL (var) = 1;
> +  DECL_IGNORED_P (var) = DECL_IGNORED_P (decl);

The indicators should be surely not recorded in debug info, so DEC_IGNORED_P
should be 1.

> +  TREE_STATIC (var) = 1;
> +  TREE_PUBLIC (var) = 1;
> +  DECL_VISIBILITY (var) = DECL_VISIBILITY (decl);

Are they meant to have the same visibility and be exported from DSOs if the
original var is?

> @@ -2313,8 +2374,7 @@ 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));
> +  CONSTRUCTOR_APPEND_ELT(vinner, NULL_TREE, odr_indicator_ptr);

Formatting, missing space before (, both in this patch and in the previous
one.

	Jakub

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 0/7] Libsanitizer merge from upstream r285547.
  2016-11-07  8:40   ` [PATCH 0/7] " Jakub Jelinek
@ 2016-11-07  9:14     ` Maxim Ostapenko
  2016-11-07  9:20       ` Jakub Jelinek
  0 siblings, 1 reply; 28+ messages in thread
From: Maxim Ostapenko @ 2016-11-07  9:14 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: GCC Patches, Kostya Serebryany, Yuri Gribov

[-- Attachment #1: Type: text/plain, Size: 1757 bytes --]



On 07/11/16 11:39, Jakub Jelinek wrote:
> On Mon, Nov 07, 2016 at 11:22:28AM +0300, Maxim Ostapenko wrote:
>> this patch set performs libsanitizer merge from upstream.
>>
>> Patch 1 is the library merge itself.
>>
>> Patch 2 is the reapplied change for SPARC by David S. Miller.
>>
>> Patch 3 changes heuristic for extracting last PC from stack frame for ARM in
>> fast unwind routine. More details can be found here
>> (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61771).
>>
>> Patch 4 replaces Jakub's fix for
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63888 and removes
>> CheckODRViolationViaPoisoning call from RegisterGlobal to avoid false
>> positive odr violation reports.
>>
>> Patch 5 combines necessary compiler changes.
>>
>> Patch 6 adds several new tests, backported from upstream.
>>
>> Patch 7 adds support for ASan odr indicators at compiler side.
>>
>> The whole patch set was regtested/bootstrapped/ASan bootstrapped on
>> x86_64-unknown-linux-gnu and i386-unknown-linux-gnu.
>> Also, passed regression tests on arm-linux-gnueabi and aarch64-linux under
>> QEMU.
> So, libasan.so.* is again ABI incompatible, but libtsan and libubsan stay
> (hopefully) backwards ABI compatible?


libubsan is definitely compatible.
For libtsan we have several changes:

1) Several interceptors (34 of them) were added and 
__interceptor_lstat{64} were removed.
2) __interceptor_strchr has change in its parameters type:
__interceptor_strchr(char*, int) -> __interceptor_strchr(const char*, int)
3) tsan's internal type __tsan::ReportDesc has several changes, but it 
seems that this doesn't introduce ABI incompatibility with compiler side.

Full abidiff listing is attached.

So, I suppose libtsan is also compatible.

-Maxim

>
> 	Jakub
>
>
>


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: abidiff-tsan.diff --]
[-- Type: text/x-diff; name="abidiff-tsan.diff", Size: 9629 bytes --]

Functions changes summary: 4 Removed, 3 Changed (70 filtered out), 34 Added functions
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
Function symbols changes summary: 0 Removed, 10 Added function symbols not referenced by debug info
Variable symbols changes summary: 0 Removed, 0 Added variable symbol not referenced by debug info

4 Removed functions:

  'function int __interceptor_lstat(const char*, void*)'    {lstat, aliases __interceptor_lstat}
  'function int __interceptor_lstat64(const char*, void*)'    {lstat64, aliases __interceptor_lstat64}
  'function int __interceptor_stat(const char*, void*)'    {__interceptor_stat, aliases stat}
  'function int __interceptor_stat64(const char*, void*)'    {stat64, aliases __interceptor_stat64}

34 Added functions:

  'function char* __interceptor_ctermid(char*)'    {__interceptor_ctermid, aliases ctermid}
  'function int __interceptor_epoll_pwait(int, void*, int, int, void*)'    {epoll_pwait, aliases __interceptor_epoll_pwait}
  'function int __interceptor_eventfd_read(int, __sanitizer::u64*)'    {eventfd_read, aliases __interceptor_eventfd_read}
  'function int __interceptor_eventfd_write(int, __sanitizer::u64)'    {__interceptor_eventfd_write, aliases eventfd_write}
  'function void* __interceptor_memmem(SIZE_T, SIZE_T)'    {__interceptor_memmem, aliases memmem}
  'function int __interceptor_pthread_sigmask(int, const __sanitizer::__sanitizer_sigset_t*, __sanitizer::__sanitizer_sigset_t*)'    {__interceptor_pthread_sigmask, aliases pthread_sigmask}
  'function SSIZE_T __interceptor_recvfrom(int, void*, SIZE_T, int, void*, int*)'    {__interceptor_recvfrom, aliases recvfrom}
  'function SSIZE_T __interceptor_sendto(int, void*, SIZE_T, int, void*, int)'    {__interceptor_sendto, aliases sendto}
  'function int __interceptor_sigblock(int)'    {sigblock, aliases __interceptor_sigblock}
  'function int __interceptor_sigsetmask(int)'    {sigsetmask, aliases __interceptor_sigsetmask}
  'function SIZE_T __interceptor_strnlen(const char*, SIZE_T)'    {__interceptor_strnlen, aliases strnlen}
  'function int __interceptor_ttyname_r(int, char*, SIZE_T)'    {__interceptor_ttyname_r, aliases ttyname_r}
  'function void __sanitizer_cov_trace_pc_guard_init()'    {__sanitizer_cov_trace_pc_guard_init}
  'function int __sanitizer_install_malloc_and_free_hooks(void (typedef __sanitizer::uptr)*, void ()*)'    {__sanitizer_install_malloc_and_free_hooks}
  'function void __sanitizer_set_report_fd(void*)'    {__sanitizer_set_report_fd}
  'function void __sanitizer_symbolize_global(__sanitizer::uptr, const char*, char*, __sanitizer::uptr)'    {__sanitizer_symbolize_global}
  'function void __sanitizer_symbolize_pc(__sanitizer::uptr, const char*, char*, __sanitizer::uptr)'    {__sanitizer_symbolize_pc}
  'function void __sanitizer_syscall_post_impl_rt_sigaction(long int, long int, const __sanitizer::__sanitizer_kernel_sigaction_t*, __sanitizer::__sanitizer_kernel_sigaction_t*, SIZE_T)'    {__sanitizer_syscall_post_impl_rt_sigaction}
  'function void __sanitizer_syscall_post_impl_sigaction(long int, long int, const __sanitizer::__sanitizer_kernel_sigaction_t*, __sanitizer::__sanitizer_kernel_sigaction_t*)'    {__sanitizer_syscall_post_impl_sigaction}
  'function void __sanitizer_syscall_pre_impl_rt_sigaction(long int, const __sanitizer::__sanitizer_kernel_sigaction_t*, __sanitizer::__sanitizer_kernel_sigaction_t*, SIZE_T)'    {__sanitizer_syscall_pre_impl_rt_sigaction}
  'function void __sanitizer_syscall_pre_impl_sigaction(long int, const __sanitizer::__sanitizer_kernel_sigaction_t*, __sanitizer::__sanitizer_kernel_sigaction_t*)'    {__sanitizer_syscall_pre_impl_sigaction}
  'function void __tsan::__tsan_on_report(const __tsan::ReportDesc*)'    {__tsan_on_report}
  'function bool __tsan::__tsan_symbolize_external(__sanitizer::uptr, char*, __sanitizer::uptr, char*, __sanitizer::uptr, int*, int*)'    {__tsan_symbolize_external}
  'function const char* __tsan_default_suppressions()'    {__tsan_default_suppressions}
  'function void* __tsan_get_current_report()'    {__tsan_get_current_report}
  'function int __tsan_get_report_data(void*, const char**, int*, int*, int*, int*, int*, int*, int*, void**, __sanitizer::uptr)'    {__tsan_get_report_data}
  'function int __tsan_get_report_loc(void*, __sanitizer::uptr, const char**, void**, __sanitizer::uptr*, __sanitizer::uptr*, int*, int*, int*, void**, __sanitizer::uptr)'    {__tsan_get_report_loc}
  'function int __tsan_get_report_mop(void*, __sanitizer::uptr, int*, void**, int*, int*, int*, void**, __sanitizer::uptr)'    {__tsan_get_report_mop}
  'function int __tsan_get_report_mutex(void*, __sanitizer::uptr, __sanitizer::uptr*, void**, int*, void**, __sanitizer::uptr)'    {__tsan_get_report_mutex}
  'function int __tsan_get_report_stack(void*, __sanitizer::uptr, void**, __sanitizer::uptr)'    {__tsan_get_report_stack}
  'function int __tsan_get_report_thread(void*, __sanitizer::uptr, int*, __sanitizer::uptr*, int*, const char**, int*, void**, __sanitizer::uptr)'    {__tsan_get_report_thread}
  'function int __tsan_get_report_unique_tid(void*, __sanitizer::uptr, int*)'    {__tsan_get_report_unique_tid}
  'function void __tsan_testonly_barrier_init(__sanitizer::u64*, __sanitizer::u32)'    {__tsan_testonly_barrier_init}
  'function void __tsan_testonly_barrier_wait(__sanitizer::u64*)'    {__tsan_testonly_barrier_wait}

3 functions with some indirect sub-type change:

  [C]'function void* __interceptor_memmove(void*, void*, __sanitizer::uptr)' has some indirect sub-type changes:
    Please note that the symbol of this function is memmove
     and it aliases symbol: __interceptor_memmove
    parameter 2 of type 'void*' changed:
      entity changed from 'void*' to 'typedef __sanitizer::uptr'
    parameter 3 of type 'typedef __sanitizer::uptr' was removed


  [C]'function char* __interceptor_strchr(char*, int)' has some indirect sub-type changes:
    Please note that the symbol of this function is __interceptor_strchr
     and it aliases symbol: strchr
    parameter 1 of type 'char*' changed:
      in pointed to type 'char':
        entity changed from 'char' to 'const char'

  [C]'function bool __tsan::OnReport(const __tsan::ReportDesc*, bool)' has some indirect sub-type changes:
    parameter 1 of type 'const __tsan::ReportDesc*' has sub-type changes:
      in pointed to type 'const __tsan::ReportDesc':
        in unqualified underlying type 'class __tsan::ReportDesc':
          2 data member changes (1 filtered):
           type of '__tsan::ReportType __tsan::ReportDesc::typ' changed:
             1 enumerator insertion:
               '__tsan::ReportType::ReportTypeMutexInvalidAccess' value '7'

             6 enumerator changes:
               '__tsan::ReportType::ReportTypeMutexBadUnlock' from value '7' to '8'
               '__tsan::ReportType::ReportTypeMutexBadReadLock' from value '8' to '9'
               '__tsan::ReportType::ReportTypeMutexBadReadUnlock' from value '9' to '10'
               '__tsan::ReportType::ReportTypeSignalUnsafe' from value '10' to '11'
               '__tsan::ReportType::ReportTypeErrnoInSignal' from value '11' to '12'
               '__tsan::ReportType::ReportTypeDeadlock' from value '12' to '13'


           type of '__tsan::Vector<__tsan::ReportLocation*> __tsan::ReportDesc::locs' changed:
             1 data member changes (2 filtered):
              type of '__tsan::ReportLocation** __tsan::Vector<__tsan::ReportLocation*>::begin_' changed:
                in pointed to type '__tsan::ReportLocation*':
                  in pointed to type 'struct __tsan::ReportLocation':
                    type size changed from 704 to 832 bits
                    7 data member changes:
                     type of '__sanitizer::DataInfo __tsan::ReportLocation::global' changed:
                       type size changed from 320 to 448 bits
                       2 data member insertions:
                         'char* __sanitizer::DataInfo::file', at offset 128 (in bits)
                         '__sanitizer::uptr __sanitizer::DataInfo::line', at offset 192 (in bits)
                       3 data member changes:
                        'char* __sanitizer::DataInfo::name' offset changed from 128 to 256 (in bits)
                        '__sanitizer::uptr __sanitizer::DataInfo::start' offset changed from 192 to 320 (in bits)
                        '__sanitizer::uptr __sanitizer::DataInfo::size' offset changed from 256 to 384 (in bits)

                     '__sanitizer::uptr __tsan::ReportLocation::heap_chunk_start' offset changed from 384 to 512 (in bits)
                     '__sanitizer::uptr __tsan::ReportLocation::heap_chunk_size' offset changed from 448 to 576 (in bits)
                     'int __tsan::ReportLocation::tid' offset changed from 512 to 640 (in bits)
                     'int __tsan::ReportLocation::fd' offset changed from 544 to 672 (in bits)
                     'bool __tsan::ReportLocation::suppressable' offset changed from 576 to 704 (in bits)
                     '__tsan::ReportStack* __tsan::ReportLocation::stack' offset changed from 640 to 768 (in bits)





10 Added function symbols not referenced by debug info:

  __sanitizer_cov_trace_cmp1
  __sanitizer_cov_trace_cmp2
  __sanitizer_cov_trace_cmp4
  __sanitizer_cov_trace_cmp8
  __sanitizer_cov_trace_div4
  __sanitizer_cov_trace_div8
  __sanitizer_cov_trace_gep
  __sanitizer_cov_trace_pc_guard
  __sanitizer_cov_trace_pc_indir
  internal_sigreturn


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 0/7] Libsanitizer merge from upstream r285547.
  2016-11-07  9:14     ` Maxim Ostapenko
@ 2016-11-07  9:20       ` Jakub Jelinek
  2016-11-07  9:28         ` Yuri Gribov
  2016-11-07 10:02         ` Maxim Ostapenko
  0 siblings, 2 replies; 28+ messages in thread
From: Jakub Jelinek @ 2016-11-07  9:20 UTC (permalink / raw)
  To: Maxim Ostapenko; +Cc: GCC Patches, Kostya Serebryany, Yuri Gribov

On Mon, Nov 07, 2016 at 12:14:39PM +0300, Maxim Ostapenko wrote:
> libubsan is definitely compatible.

Nice.

> For libtsan we have several changes:
> 
> 1) Several interceptors (34 of them) were added and __interceptor_lstat{64}
> were removed.

That is bad, I think we need to readd those and perhaps just do what
lstat*/stat* do.  Weren't we solving the same thing a year ago on some other
symbol?

> 2) __interceptor_strchr has change in its parameters type:
> __interceptor_strchr(char*, int) -> __interceptor_strchr(const char*, int)

That is not a big deal, the function is extern "C".

> 3) tsan's internal type __tsan::ReportDesc has several changes, but it seems
> that this doesn't introduce ABI incompatibility with compiler side.

If __tsan::ReportDesc is not defined in publicly installed headers, I think
we are fine.

	Jakub

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 0/7] Libsanitizer merge from upstream r285547.
  2016-11-07  9:20       ` Jakub Jelinek
@ 2016-11-07  9:28         ` Yuri Gribov
  2016-11-07  9:38           ` Maxim Ostapenko
  2016-11-07 10:02         ` Maxim Ostapenko
  1 sibling, 1 reply; 28+ messages in thread
From: Yuri Gribov @ 2016-11-07  9:28 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Maxim Ostapenko, GCC Patches, Kostya Serebryany

On Mon, Nov 7, 2016 at 9:20 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Mon, Nov 07, 2016 at 12:14:39PM +0300, Maxim Ostapenko wrote:
>> libubsan is definitely compatible.
>
> Nice.
>
>> For libtsan we have several changes:
>>
>> 1) Several interceptors (34 of them) were added and __interceptor_lstat{64}
>> were removed.
>
> That is bad, I think we need to readd those and perhaps just do what
> lstat*/stat* do.  Weren't we solving the same thing a year ago on some other
> symbol?
>
>> 2) __interceptor_strchr has change in its parameters type:
>> __interceptor_strchr(char*, int) -> __interceptor_strchr(const char*, int)
>
> That is not a big deal, the function is extern "C".
>
>> 3) tsan's internal type __tsan::ReportDesc has several changes, but it seems
>> that this doesn't introduce ABI incompatibility with compiler side.
>
> If __tsan::ReportDesc is not defined in publicly installed headers, I think
> we are fine.

As a side note, why is it in the list of exported symbols?

-I

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 0/7] Libsanitizer merge from upstream r285547.
  2016-11-07  9:28         ` Yuri Gribov
@ 2016-11-07  9:38           ` Maxim Ostapenko
  0 siblings, 0 replies; 28+ messages in thread
From: Maxim Ostapenko @ 2016-11-07  9:38 UTC (permalink / raw)
  To: Yuri Gribov, Jakub Jelinek; +Cc: GCC Patches, Kostya Serebryany

On 07/11/16 12:28, Yuri Gribov wrote:
> On Mon, Nov 7, 2016 at 9:20 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>> On Mon, Nov 07, 2016 at 12:14:39PM +0300, Maxim Ostapenko wrote:
>>> libubsan is definitely compatible.
>> Nice.
>>
>>> For libtsan we have several changes:
>>>
>>> 1) Several interceptors (34 of them) were added and __interceptor_lstat{64}
>>> were removed.
>> That is bad, I think we need to readd those and perhaps just do what
>> lstat*/stat* do.  Weren't we solving the same thing a year ago on some other
>> symbol?
>>
>>> 2) __interceptor_strchr has change in its parameters type:
>>> __interceptor_strchr(char*, int) -> __interceptor_strchr(const char*, int)
>> That is not a big deal, the function is extern "C".
>>
>>> 3) tsan's internal type __tsan::ReportDesc has several changes, but it seems
>>> that this doesn't introduce ABI incompatibility with compiler side.
>> If __tsan::ReportDesc is not defined in publicly installed headers, I think
>> we are fine.
> As a side note, why is it in the list of exported symbols?

Because it appears as a type of parameter of exported __tsan::OnReport 
function:

// Can be overriden by an application/test to intercept reports.
#ifdef TSAN_EXTERNAL_HOOKS
bool OnReport(const ReportDesc *rep, bool suppressed);
#else
SANITIZER_WEAK_CXX_DEFAULT_IMPL
bool OnReport(const ReportDesc *rep, bool suppressed) {
   (void)rep;
   return suppressed;
}
#endif

This function can be overridden by application for debugging purpose though.

>
> -I
>
>
>

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 0/7] Libsanitizer merge from upstream r285547.
  2016-11-07  9:20       ` Jakub Jelinek
  2016-11-07  9:28         ` Yuri Gribov
@ 2016-11-07 10:02         ` Maxim Ostapenko
  1 sibling, 0 replies; 28+ messages in thread
From: Maxim Ostapenko @ 2016-11-07 10:02 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: GCC Patches, Kostya Serebryany, Yuri Gribov

On 07/11/16 12:20, Jakub Jelinek wrote:
> On Mon, Nov 07, 2016 at 12:14:39PM +0300, Maxim Ostapenko wrote:
>> libubsan is definitely compatible.
> Nice.
>
>> For libtsan we have several changes:
>>
>> 1) Several interceptors (34 of them) were added and __interceptor_lstat{64}
>> were removed.
> That is bad, I think we need to readd those and perhaps just do what
> lstat*/stat* do.  Weren't we solving the same thing a year ago on some other
> symbol?

Yeah, that was __tls_get_addr. Actually,  *stat interceptors were moved 
from tsan to common, but it seems that lstat/lstat64 were missed. This 
should be fixed upstream, I suppose.

>> 2) __interceptor_strchr has change in its parameters type:
>> __interceptor_strchr(char*, int) -> __interceptor_strchr(const char*, int)
> That is not a big deal, the function is extern "C".
>
>> 3) tsan's internal type __tsan::ReportDesc has several changes, but it seems
>> that this doesn't introduce ABI incompatibility with compiler side.
> If __tsan::ReportDesc is not defined in publicly installed headers, I think
> we are fine.

I don't see __tsan::ReportDesc in any tsan interface header:

$ grep -nr ReportDesc libsanitizer/tsan/tsan_interface*
$

But since tsan has weak

SANITIZER_WEAK_CXX_DEFAULT_IMPL
bool OnReport(const ReportDesc *rep, bool suppressed {
...
}

that can be overwritten by C++ application (in debugging purposes 
though), is it OK to not change libtsan version?

>
> 	Jakub
>
>
>

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 0/7] Libsanitizer merge from upstream r285547.
  2016-11-07  8:22 ` [PATCH 0/7] Libsanitizer merge from upstream r285547 Maxim Ostapenko
                     ` (7 preceding siblings ...)
  2016-11-07  8:40   ` [PATCH 0/7] " Jakub Jelinek
@ 2016-11-07 10:04   ` Jakub Jelinek
  2016-11-07 10:34     ` Maxim Ostapenko
  8 siblings, 1 reply; 28+ messages in thread
From: Jakub Jelinek @ 2016-11-07 10:04 UTC (permalink / raw)
  To: Maxim Ostapenko; +Cc: GCC Patches, Kostya Serebryany, Yuri Gribov

On Mon, Nov 07, 2016 at 11:22:28AM +0300, Maxim Ostapenko wrote:
> Hi,
> 
> this patch set performs libsanitizer merge from upstream.
> 
> Patch 1 is the library merge itself.
> 
> Patch 2 is the reapplied change for SPARC by David S. Miller.
> 
> Patch 3 changes heuristic for extracting last PC from stack frame for ARM in
> fast unwind routine. More details can be found here
> (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61771).
> 
> Patch 4 replaces Jakub's fix for
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63888 and removes
> CheckODRViolationViaPoisoning call from RegisterGlobal to avoid false
> positive odr violation reports.
> 
> Patch 5 combines necessary compiler changes.
> 
> Patch 6 adds several new tests, backported from upstream.

The patches 1-6 are ok for trunk now, if you fix the missing space
before ( in patch 5.

> Patch 7 adds support for ASan odr indicators at compiler side.

This one can be applied incrementally once the issues reported in there
are resolved.

And the libtsan ABI stuff (__intercept*stat*) can be resolved incrementally
too.

Thanks.

	Jakub

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 0/7] Libsanitizer merge from upstream r285547.
  2016-11-07 10:04   ` Jakub Jelinek
@ 2016-11-07 10:34     ` Maxim Ostapenko
  0 siblings, 0 replies; 28+ messages in thread
From: Maxim Ostapenko @ 2016-11-07 10:34 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: GCC Patches, Kostya Serebryany, Yuri Gribov

On 07/11/16 13:04, Jakub Jelinek wrote:
> On Mon, Nov 07, 2016 at 11:22:28AM +0300, Maxim Ostapenko wrote:
>> Hi,
>>
>> this patch set performs libsanitizer merge from upstream.
>>
>> Patch 1 is the library merge itself.
>>
>> Patch 2 is the reapplied change for SPARC by David S. Miller.
>>
>> Patch 3 changes heuristic for extracting last PC from stack frame for ARM in
>> fast unwind routine. More details can be found here
>> (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61771).
>>
>> Patch 4 replaces Jakub's fix for
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63888 and removes
>> CheckODRViolationViaPoisoning call from RegisterGlobal to avoid false
>> positive odr violation reports.
>>
>> Patch 5 combines necessary compiler changes.
>>
>> Patch 6 adds several new tests, backported from upstream.
> The patches 1-6 are ok for trunk now, if you fix the missing space
> before ( in patch 5.

Ok, I'm going to land these shortly, thank you for review.

>
>> Patch 7 adds support for ASan odr indicators at compiler side.
> This one can be applied incrementally once the issues reported in there
> are resolved.

Yes, I'll fix the patch.

>
> And the libtsan ABI stuff (__intercept*stat*) can be resolved incrementally
> too.
>
> Thanks.
>
> 	Jakub
>
>
>

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH v2] Support ASan ODR indicators at compiler side.
  2016-11-07  8:52       ` Jakub Jelinek
@ 2016-11-14  8:44         ` Maxim Ostapenko
  2016-11-21 11:38           ` Jakub Jelinek
  0 siblings, 1 reply; 28+ messages in thread
From: Maxim Ostapenko @ 2016-11-14  8:44 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: GCC Patches, Yuri Gribov

[-- Attachment #1: Type: text/plain, Size: 315 bytes --]

Hi,

this is the second attempt to support ASan odr indicators in GCC. I've 
fixed issues with several flags (e.g.TREE_ADDRESSABLE) and introduced 
new "asan odr indicator" attribute to distinguish indicators from other 
symbols.
Looks better now?

Tested and ASan bootstrapped on x86_64-unknown-linux-gnu.

-Maxim

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: odr_indicators-1.diff --]
[-- Type: text/x-diff; name="odr_indicators-1.diff", Size: 10010 bytes --]

config/

	* bootstrap-asan.mk: Replace LSAN_OPTIONS=detect_leaks=0 with
	ASAN_OPTIONS=detect_leaks=0:use_odr_indicator=1.

gcc/

	* asan.c (asan_global_struct): Refactor.
	(create_odr_indicator): New function.
	(asan_needs_odr_indicator_p): Likewise.
	(is_odr_indicator): Likewise.
	(asan_add_global): Introduce odr_indicator_ptr. Pass it into global's
	constructor.
	(asan_protect_global): Do not protect odr indicators.

gcc/c-family/

	* c-attribs.c (asan odr indicator): New attribute.
	(handle_asan_odr_indicator_attribute): New function.

gcc/testsuite/

	* c-c++-common/asan/no-redundant-odr-indicators-1.c: New test.

diff --git a/config/ChangeLog b/config/ChangeLog
index 3b0092b..0c75185 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,8 @@
+2016-11-14  Maxim Ostapenko  <m.ostapenko@samsung.com>
+
+	* bootstrap-asan.mk: Replace LSAN_OPTIONS=detect_leaks=0 with
+	ASAN_OPTIONS=detect_leaks=0:use_odr_indicator=1.
+
 2016-06-21  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
 
 	* elf.m4: Remove interix support.
diff --git a/config/bootstrap-asan.mk b/config/bootstrap-asan.mk
index 70baaf9..e73d4c2 100644
--- a/config/bootstrap-asan.mk
+++ b/config/bootstrap-asan.mk
@@ -1,7 +1,7 @@
 # This option enables -fsanitize=address for stage2 and stage3.
 
 # Suppress LeakSanitizer in bootstrap.
-export LSAN_OPTIONS="detect_leaks=0"
+export ASAN_OPTIONS=detect_leaks=0:use_odr_indicator=1
 
 STAGE2_CFLAGS += -fsanitize=address
 STAGE3_CFLAGS += -fsanitize=address
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a76e3e8..64744b9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2016-11-14  Maxim Ostapenko  <m.ostapenko@samsung.com>
+
+	* asan.c (asan_global_struct): Refactor.
+	(create_odr_indicator): New function.
+	(asan_needs_odr_indicator_p): Likewise.
+	(is_odr_indicator): Likewise.
+	(asan_add_global): Introduce odr_indicator_ptr. Pass it into global's
+	constructor.
+	(asan_protect_global): Do not protect odr indicators.
+
 2016-11-09  Kugan Vivekanandarajah  <kuganv@linaro.org>
 
 	* ipa-cp.c (ipa_get_jf_pass_through_result): Handle unary expressions.
diff --git a/gcc/asan.c b/gcc/asan.c
index 6e93ea3..1191ebe 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1388,6 +1388,16 @@ asan_needs_local_alias (tree decl)
   return DECL_WEAK (decl) || !targetm.binds_local_p (decl);
 }
 
+/* Return true if DECL, a global var, is an artificial ODR indicator symbol
+   therefore doesn't need protection.  */
+
+static bool
+is_odr_indicator (tree decl)
+{
+  return DECL_ARTIFICIAL (decl)
+	 && lookup_attribute ("asan odr indicator", DECL_ATTRIBUTES (decl));
+}
+
 /* Return true if DECL is a VAR_DECL that should be protected
    by Address Sanitizer, by appending a red zone with protected
    shadow memory after it and aligning it to at least
@@ -1436,7 +1446,8 @@ asan_protect_global (tree decl)
       || ASAN_RED_ZONE_SIZE * BITS_PER_UNIT > MAX_OFILE_ALIGNMENT
       || !valid_constant_size_p (DECL_SIZE_UNIT (decl))
       || DECL_ALIGN_UNIT (decl) > 2 * ASAN_RED_ZONE_SIZE
-      || TREE_TYPE (decl) == ubsan_get_source_location_type ())
+      || TREE_TYPE (decl) == ubsan_get_source_location_type ()
+      || is_odr_indicator (decl))
     return false;
 
   rtl = DECL_RTL (decl);
@@ -2266,14 +2277,15 @@ asan_dynamic_init_call (bool after_p)
 static tree
 asan_global_struct (void)
 {
-  static const char *field_names[8]
+  static const char *field_names[]
     = { "__beg", "__size", "__size_with_redzone",
-	"__name", "__module_name", "__has_dynamic_init", "__location", "__odr_indicator"};
-  tree fields[8], ret;
-  int i;
+	"__name", "__module_name", "__has_dynamic_init", "__location",
+	"__odr_indicator"};
+  tree fields[ARRAY_SIZE (field_names)], ret;
+  unsigned i;
 
   ret = make_node (RECORD_TYPE);
-  for (i = 0; i < 8; i++)
+  for (i = 0; i < ARRAY_SIZE (field_names); i++)
     {
       fields[i]
 	= build_decl (UNKNOWN_LOCATION, FIELD_DECL,
@@ -2295,6 +2307,56 @@ asan_global_struct (void)
   return ret;
 }
 
+/* Create and return odr indicator symbol for DECL.
+   TYPE is __asan_global struct type as returned by asan_global_struct.  */
+
+static tree
+create_odr_indicator (tree decl, tree type)
+{
+  char sym_name[100], tmp_name[100];
+  static int lasan_odr_ind_cnt = 0;
+  tree uptr = TREE_TYPE (DECL_CHAIN (TYPE_FIELDS (type)));
+
+  snprintf (tmp_name, sizeof (tmp_name), "__odr_asan_%s_",
+	    IDENTIFIER_POINTER (DECL_NAME (decl)));
+  ASM_GENERATE_INTERNAL_LABEL (sym_name, tmp_name, ++lasan_odr_ind_cnt);
+  char *asterisk = sym_name;
+  while ((asterisk = strchr (asterisk, '*')))
+    *asterisk = '_';
+  tree var = build_decl (UNKNOWN_LOCATION, VAR_DECL, get_identifier (sym_name),
+			 char_type_node);
+  TREE_ADDRESSABLE (var) = 1;
+  TREE_READONLY (var) = 0;
+  TREE_THIS_VOLATILE (var) = 1;
+  DECL_GIMPLE_REG_P (var) = 0;
+  DECL_ARTIFICIAL (var) = 1;
+  DECL_IGNORED_P (var) = 1;
+  TREE_STATIC (var) = 1;
+  TREE_PUBLIC (var) = 1;
+  DECL_VISIBILITY (var) = VISIBILITY_DEFAULT;
+  DECL_VISIBILITY_SPECIFIED (var) = 1;
+
+  TREE_USED (var) = 1;
+  tree ctor = build_constructor_va (TREE_TYPE (var), 1, NULL_TREE,
+				    build_int_cst (unsigned_type_node, 0));
+  TREE_CONSTANT (ctor) = 1;
+  TREE_STATIC (ctor) = 1;
+  DECL_INITIAL (var) = ctor;
+  DECL_ATTRIBUTES (var) = tree_cons (get_identifier ("asan odr indicator"),
+				     NULL, DECL_ATTRIBUTES (var));
+  varpool_node::finalize_decl (var);
+  return fold_convert (uptr, build_fold_addr_expr (var));
+}
+
+/* Return true if DECL, a global var, might be overridden and needs
+   an additional odr indicator symbol.  */
+
+static bool
+asan_needs_odr_indicator_p (tree decl)
+{
+  return !DECL_ARTIFICIAL (decl) && !DECL_WEAK (decl) && TREE_PUBLIC (decl);
+}
+
 /* Append description of a single global DECL into vector V.
    TYPE is __asan_global struct type as returned by asan_global_struct.  */
 
@@ -2335,6 +2397,9 @@ asan_add_global (tree decl, tree type, vec<constructor_elt, va_gc> *v)
       assemble_alias (refdecl, DECL_ASSEMBLER_NAME (decl));
     }
 
+  tree odr_indicator_ptr = asan_needs_odr_indicator_p (decl)
+			     ? create_odr_indicator (decl, type)
+			     : build_int_cst (uptr, 0);
   CONSTRUCTOR_APPEND_ELT (vinner, NULL_TREE,
 			  fold_convert (const_ptr_type_node,
 					build_fold_addr_expr (refdecl)));
@@ -2382,8 +2447,7 @@ 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));
+  CONSTRUCTOR_APPEND_ELT (vinner, NULL_TREE, odr_indicator_ptr);
   init = build_constructor (type, vinner);
   CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, init);
 }
diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index 925f1b2..44b1f51 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -57,6 +57,8 @@ static tree handle_no_address_safety_analysis_attribute (tree *, tree, tree,
 							 int, bool *);
 static tree handle_no_sanitize_undefined_attribute (tree *, tree, tree, int,
 						    bool *);
+static tree handle_asan_odr_indicator_attribute (tree *, tree, tree, int,
+						    bool *);
 static tree handle_stack_protect_attribute (tree *, tree, tree, int, bool *);
 static tree handle_noinline_attribute (tree *, tree, tree, int, bool *);
 static tree handle_noclone_attribute (tree *, tree, tree, int, bool *);
@@ -292,6 +294,9 @@ const struct attribute_spec c_common_attribute_table[] =
   { "no_sanitize_undefined",  0, 0, true, false, false,
 			      handle_no_sanitize_undefined_attribute,
 			      false },
+  { "asan odr indicator",     0, 0, true, false, false,
+			      handle_asan_odr_indicator_attribute,
+			      false },
   { "warning",		      1, 1, true,  false, false,
 			      handle_error_attribute, false },
   { "error",		      1, 1, true,  false, false,
@@ -591,6 +596,22 @@ handle_no_sanitize_undefined_attribute (tree *node, tree name, tree, int,
   return NULL_TREE;
 }
 
+/* Handle an "asan odr indicator" attribute; arguments as in
+   struct attribute_spec.handler.  */
+
+static tree
+handle_asan_odr_indicator_attribute (tree *node, tree name, tree, int,
+				     bool *no_add_attrs)
+{
+  if (!VAR_P (*node))
+    {
+      warning (OPT_Wattributes, "%qE attribute ignored", name);
+      *no_add_attrs = true;
+    }
+
+  return NULL_TREE;
+}
+
 /* Handle a "stack_protect" attribute; arguments as in
    struct attribute_spec.handler.  */
 
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e822e6f..67361a3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2016-11-14  Maxim Ostapenko  <m.ostapenko@samsung.com>
+
+	* c-c++-common/asan/no-redundant-odr-indicators-1.c: New test.
+
 2016-11-09  Kugan Vivekanandarajah  <kuganv@linaro.org>
 
 	* gcc.dg/ipa/vrp7.c: New test.
diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-odr-indicators-1.c b/gcc/testsuite/c-c++-common/asan/no-redundant-odr-indicators-1.c
new file mode 100644
index 0000000..ff1f272
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/no-redundant-odr-indicators-1.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
+
+/* Local variables should not have odr indicators.  */
+static int a = 2;
+/* Thread local variables should not have odr indicators.  */
+__thread int b = 3;
+/* Externally visible  variables should have odr indicators.  */
+int c = 1;
+
+int main () {
+    return 0;
+}
+
+/* { dg-final { scan-assembler-not ".*odr_asan_a.*" } } */
+/* { dg-final { scan-assembler-not ".*odr_asan_b.*" } } */
+/* { dg-final { scan-assembler ".*odr_asan_c.*" } } */

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2] Support ASan ODR indicators at compiler side.
  2016-11-14  8:44         ` [PATCH v2] Support ASan ODR indicators at compiler side Maxim Ostapenko
@ 2016-11-21 11:38           ` Jakub Jelinek
  2016-11-21 11:44             ` Yuri Gribov
  2016-12-01 10:26             ` [PATCH v3] " Maxim Ostapenko
  0 siblings, 2 replies; 28+ messages in thread
From: Jakub Jelinek @ 2016-11-21 11:38 UTC (permalink / raw)
  To: Maxim Ostapenko; +Cc: GCC Patches, Yuri Gribov

On Mon, Nov 14, 2016 at 11:44:26AM +0300, Maxim Ostapenko wrote:
> this is the second attempt to support ASan odr indicators in GCC. I've fixed
> issues with several flags (e.g.TREE_ADDRESSABLE) and introduced new "asan
> odr indicator" attribute to distinguish indicators from other symbols.
> Looks better now?
> 
> Tested and ASan bootstrapped on x86_64-unknown-linux-gnu.
> 
> -Maxim

> config/
> 
> 	* bootstrap-asan.mk: Replace LSAN_OPTIONS=detect_leaks=0 with
> 	ASAN_OPTIONS=detect_leaks=0:use_odr_indicator=1.
> 
> gcc/
> 
> 	* asan.c (asan_global_struct): Refactor.
> 	(create_odr_indicator): New function.
> 	(asan_needs_odr_indicator_p): Likewise.
> 	(is_odr_indicator): Likewise.
> 	(asan_add_global): Introduce odr_indicator_ptr. Pass it into global's
> 	constructor.
> 	(asan_protect_global): Do not protect odr indicators.
> 
> gcc/c-family/
> 
> 	* c-attribs.c (asan odr indicator): New attribute.
> 	(handle_asan_odr_indicator_attribute): New function.
> 
> gcc/testsuite/
> 
> 	* c-c++-common/asan/no-redundant-odr-indicators-1.c: New test.
> 
> diff --git a/config/ChangeLog b/config/ChangeLog
> index 3b0092b..0c75185 100644
> --- a/config/ChangeLog
> +++ b/config/ChangeLog
> @@ -1,3 +1,8 @@
> +2016-11-14  Maxim Ostapenko  <m.ostapenko@samsung.com>
> +
> +	* bootstrap-asan.mk: Replace LSAN_OPTIONS=detect_leaks=0 with
> +	ASAN_OPTIONS=detect_leaks=0:use_odr_indicator=1.
> +
>  2016-06-21  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
>  
>  	* elf.m4: Remove interix support.
> diff --git a/config/bootstrap-asan.mk b/config/bootstrap-asan.mk
> index 70baaf9..e73d4c2 100644
> --- a/config/bootstrap-asan.mk
> +++ b/config/bootstrap-asan.mk
> @@ -1,7 +1,7 @@
>  # This option enables -fsanitize=address for stage2 and stage3.
>  
>  # Suppress LeakSanitizer in bootstrap.
> -export LSAN_OPTIONS="detect_leaks=0"
> +export ASAN_OPTIONS=detect_leaks=0:use_odr_indicator=1
>  
>  STAGE2_CFLAGS += -fsanitize=address
>  STAGE3_CFLAGS += -fsanitize=address
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index a76e3e8..64744b9 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,3 +1,13 @@
> +2016-11-14  Maxim Ostapenko  <m.ostapenko@samsung.com>
> +
> +	* asan.c (asan_global_struct): Refactor.
> +	(create_odr_indicator): New function.
> +	(asan_needs_odr_indicator_p): Likewise.
> +	(is_odr_indicator): Likewise.
> +	(asan_add_global): Introduce odr_indicator_ptr. Pass it into global's
> +	constructor.
> +	(asan_protect_global): Do not protect odr indicators.
> +
>  2016-11-09  Kugan Vivekanandarajah  <kuganv@linaro.org>
>  
>  	* ipa-cp.c (ipa_get_jf_pass_through_result): Handle unary expressions.
> diff --git a/gcc/asan.c b/gcc/asan.c
> index 6e93ea3..1191ebe 100644
> --- a/gcc/asan.c
> +++ b/gcc/asan.c
> @@ -1388,6 +1388,16 @@ asan_needs_local_alias (tree decl)
>    return DECL_WEAK (decl) || !targetm.binds_local_p (decl);
>  }
>  
> +/* Return true if DECL, a global var, is an artificial ODR indicator symbol
> +   therefore doesn't need protection.  */
> +
> +static bool
> +is_odr_indicator (tree decl)
> +{
> +  return DECL_ARTIFICIAL (decl)
> +	 && lookup_attribute ("asan odr indicator", DECL_ATTRIBUTES (decl));

Better use
  return (DECL_ARTIFICIAL (decl)
	  && lookup_attribute ("asan odr indicator", DECL_ATTRIBUTES (decl)));
at least emacs users most likely need that.

> -	"__name", "__module_name", "__has_dynamic_init", "__location", "__odr_indicator"};
> -  tree fields[8], ret;
> -  int i;
> +	"__name", "__module_name", "__has_dynamic_init", "__location",
> +	"__odr_indicator"};

Please put space before };.

> +/* Create and return odr indicator symbol for DECL.
> +   TYPE is __asan_global struct type as returned by asan_global_struct.  */
> +
> +static tree
> +create_odr_indicator (tree decl, tree type)
> +{
> +  char sym_name[100], tmp_name[100];
> +  static int lasan_odr_ind_cnt = 0;
> +  tree uptr = TREE_TYPE (DECL_CHAIN (TYPE_FIELDS (type)));
> +
> +  snprintf (tmp_name, sizeof (tmp_name), "__odr_asan_%s_",
> +	    IDENTIFIER_POINTER (DECL_NAME (decl)));
> +  ASM_GENERATE_INTERNAL_LABEL (sym_name, tmp_name, ++lasan_odr_ind_cnt);

This is just weird.  DECL_NAME in theory could be NULL, or can be a symbol
much longer than 100 bytes, at which point you have strlen (tmp_name) == 99
and ASM_GENERATE_INTERNAL_LABEL will just misbehave.
I fail to see why you need tmp_name at all, I'd go just with
  char sym_name[40];
  ASM_GENERATE_INTERNAL_LABEL (sym_name, "LASANODR", ++lasan_odr_ind_cnt);
or so.

> +  char *asterisk = sym_name;
> +  while ((asterisk = strchr (asterisk, '*')))
> +    *asterisk = '_';

Can't * be just at the beginning?  And other ASM_GENERATE_INTERNAL_LABEL +
build_decl with get_identifier spots in asan.c certainly don't strip any.

> @@ -2335,6 +2397,9 @@ asan_add_global (tree decl, tree type, vec<constructor_elt, va_gc> *v)
>        assemble_alias (refdecl, DECL_ASSEMBLER_NAME (decl));
>      }
>  
> +  tree odr_indicator_ptr = asan_needs_odr_indicator_p (decl)
> +			     ? create_odr_indicator (decl, type)
> +			     : build_int_cst (uptr, 0);

Again for emacs users I think you want () around the whole RHS.

> +/* Handle an "asan odr indicator" attribute; arguments as in
> +   struct attribute_spec.handler.  */
> +
> +static tree
> +handle_asan_odr_indicator_attribute (tree *node, tree name, tree, int,
> +				     bool *no_add_attrs)
> +{
> +  if (!VAR_P (*node))
> +    {
> +      warning (OPT_Wattributes, "%qE attribute ignored", name);
> +      *no_add_attrs = true;
> +    }

Why not just return NULL_TREE and all arguments nameless?
This isn't user accessible attribute, so it shouldn't be misplaced.

	Jakub

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2] Support ASan ODR indicators at compiler side.
  2016-11-21 11:38           ` Jakub Jelinek
@ 2016-11-21 11:44             ` Yuri Gribov
  2016-11-21 11:50               ` Jakub Jelinek
  2016-12-01 10:26             ` [PATCH v3] " Maxim Ostapenko
  1 sibling, 1 reply; 28+ messages in thread
From: Yuri Gribov @ 2016-11-21 11:44 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Maxim Ostapenko, GCC Patches

On Mon, Nov 21, 2016 at 11:38 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Mon, Nov 14, 2016 at 11:44:26AM +0300, Maxim Ostapenko wrote:
>> this is the second attempt to support ASan odr indicators in GCC. I've fixed
>> issues with several flags (e.g.TREE_ADDRESSABLE) and introduced new "asan
>> odr indicator" attribute to distinguish indicators from other symbols.
>> Looks better now?
>>
>> Tested and ASan bootstrapped on x86_64-unknown-linux-gnu.
>>
>> -Maxim
>
>> config/
>>
>>       * bootstrap-asan.mk: Replace LSAN_OPTIONS=detect_leaks=0 with
>>       ASAN_OPTIONS=detect_leaks=0:use_odr_indicator=1.
>>
>> gcc/
>>
>>       * asan.c (asan_global_struct): Refactor.
>>       (create_odr_indicator): New function.
>>       (asan_needs_odr_indicator_p): Likewise.
>>       (is_odr_indicator): Likewise.
>>       (asan_add_global): Introduce odr_indicator_ptr. Pass it into global's
>>       constructor.
>>       (asan_protect_global): Do not protect odr indicators.
>>
>> gcc/c-family/
>>
>>       * c-attribs.c (asan odr indicator): New attribute.
>>       (handle_asan_odr_indicator_attribute): New function.
>>
>> gcc/testsuite/
>>
>>       * c-c++-common/asan/no-redundant-odr-indicators-1.c: New test.
>>
>> diff --git a/config/ChangeLog b/config/ChangeLog
>> index 3b0092b..0c75185 100644
>> --- a/config/ChangeLog
>> +++ b/config/ChangeLog
>> @@ -1,3 +1,8 @@
>> +2016-11-14  Maxim Ostapenko  <m.ostapenko@samsung.com>
>> +
>> +     * bootstrap-asan.mk: Replace LSAN_OPTIONS=detect_leaks=0 with
>> +     ASAN_OPTIONS=detect_leaks=0:use_odr_indicator=1.
>> +
>>  2016-06-21  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
>>
>>       * elf.m4: Remove interix support.
>> diff --git a/config/bootstrap-asan.mk b/config/bootstrap-asan.mk
>> index 70baaf9..e73d4c2 100644
>> --- a/config/bootstrap-asan.mk
>> +++ b/config/bootstrap-asan.mk
>> @@ -1,7 +1,7 @@
>>  # This option enables -fsanitize=address for stage2 and stage3.
>>
>>  # Suppress LeakSanitizer in bootstrap.
>> -export LSAN_OPTIONS="detect_leaks=0"
>> +export ASAN_OPTIONS=detect_leaks=0:use_odr_indicator=1
>>
>>  STAGE2_CFLAGS += -fsanitize=address
>>  STAGE3_CFLAGS += -fsanitize=address
>> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
>> index a76e3e8..64744b9 100644
>> --- a/gcc/ChangeLog
>> +++ b/gcc/ChangeLog
>> @@ -1,3 +1,13 @@
>> +2016-11-14  Maxim Ostapenko  <m.ostapenko@samsung.com>
>> +
>> +     * asan.c (asan_global_struct): Refactor.
>> +     (create_odr_indicator): New function.
>> +     (asan_needs_odr_indicator_p): Likewise.
>> +     (is_odr_indicator): Likewise.
>> +     (asan_add_global): Introduce odr_indicator_ptr. Pass it into global's
>> +     constructor.
>> +     (asan_protect_global): Do not protect odr indicators.
>> +
>>  2016-11-09  Kugan Vivekanandarajah  <kuganv@linaro.org>
>>
>>       * ipa-cp.c (ipa_get_jf_pass_through_result): Handle unary expressions.
>> diff --git a/gcc/asan.c b/gcc/asan.c
>> index 6e93ea3..1191ebe 100644
>> --- a/gcc/asan.c
>> +++ b/gcc/asan.c
>> @@ -1388,6 +1388,16 @@ asan_needs_local_alias (tree decl)
>>    return DECL_WEAK (decl) || !targetm.binds_local_p (decl);
>>  }
>>
>> +/* Return true if DECL, a global var, is an artificial ODR indicator symbol
>> +   therefore doesn't need protection.  */
>> +
>> +static bool
>> +is_odr_indicator (tree decl)
>> +{
>> +  return DECL_ARTIFICIAL (decl)
>> +      && lookup_attribute ("asan odr indicator", DECL_ATTRIBUTES (decl));
>
> Better use
>   return (DECL_ARTIFICIAL (decl)
>           && lookup_attribute ("asan odr indicator", DECL_ATTRIBUTES (decl)));
> at least emacs users most likely need that.
>
>> -     "__name", "__module_name", "__has_dynamic_init", "__location", "__odr_indicator"};
>> -  tree fields[8], ret;
>> -  int i;
>> +     "__name", "__module_name", "__has_dynamic_init", "__location",
>> +     "__odr_indicator"};
>
> Please put space before };.
>
>> +/* Create and return odr indicator symbol for DECL.
>> +   TYPE is __asan_global struct type as returned by asan_global_struct.  */
>> +
>> +static tree
>> +create_odr_indicator (tree decl, tree type)
>> +{
>> +  char sym_name[100], tmp_name[100];
>> +  static int lasan_odr_ind_cnt = 0;
>> +  tree uptr = TREE_TYPE (DECL_CHAIN (TYPE_FIELDS (type)));
>> +
>> +  snprintf (tmp_name, sizeof (tmp_name), "__odr_asan_%s_",
>> +         IDENTIFIER_POINTER (DECL_NAME (decl)));
>> +  ASM_GENERATE_INTERNAL_LABEL (sym_name, tmp_name, ++lasan_odr_ind_cnt);
>
> This is just weird.  DECL_NAME in theory could be NULL, or can be a symbol
> much longer than 100 bytes, at which point you have strlen (tmp_name) == 99
> and ASM_GENERATE_INTERNAL_LABEL will just misbehave.
> I fail to see why you need tmp_name at all, I'd go just with
>   char sym_name[40];
>   ASM_GENERATE_INTERNAL_LABEL (sym_name, "LASANODR", ++lasan_odr_ind_cnt);
> or so.

Given that feature is quite new and hasn't been tested too much (it's
off by default in Clang), having a descriptive name may aid with
debugging bug reports.

>> +  char *asterisk = sym_name;
>> +  while ((asterisk = strchr (asterisk, '*')))
>> +    *asterisk = '_';
>
> Can't * be just at the beginning?  And other ASM_GENERATE_INTERNAL_LABEL +
> build_decl with get_identifier spots in asan.c certainly don't strip any.
>
>> @@ -2335,6 +2397,9 @@ asan_add_global (tree decl, tree type, vec<constructor_elt, va_gc> *v)
>>        assemble_alias (refdecl, DECL_ASSEMBLER_NAME (decl));
>>      }
>>
>> +  tree odr_indicator_ptr = asan_needs_odr_indicator_p (decl)
>> +                          ? create_odr_indicator (decl, type)
>> +                          : build_int_cst (uptr, 0);
>
> Again for emacs users I think you want () around the whole RHS.
>
>> +/* Handle an "asan odr indicator" attribute; arguments as in
>> +   struct attribute_spec.handler.  */
>> +
>> +static tree
>> +handle_asan_odr_indicator_attribute (tree *node, tree name, tree, int,
>> +                                  bool *no_add_attrs)
>> +{
>> +  if (!VAR_P (*node))
>> +    {
>> +      warning (OPT_Wattributes, "%qE attribute ignored", name);
>> +      *no_add_attrs = true;
>> +    }
>
> Why not just return NULL_TREE and all arguments nameless?
> This isn't user accessible attribute, so it shouldn't be misplaced.
>
>         Jakub

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2] Support ASan ODR indicators at compiler side.
  2016-11-21 11:44             ` Yuri Gribov
@ 2016-11-21 11:50               ` Jakub Jelinek
  2016-11-21 12:09                 ` Yuri Gribov
  0 siblings, 1 reply; 28+ messages in thread
From: Jakub Jelinek @ 2016-11-21 11:50 UTC (permalink / raw)
  To: Yuri Gribov; +Cc: Maxim Ostapenko, GCC Patches

On Mon, Nov 21, 2016 at 11:43:56AM +0000, Yuri Gribov wrote:
> > This is just weird.  DECL_NAME in theory could be NULL, or can be a symbol
> > much longer than 100 bytes, at which point you have strlen (tmp_name) == 99
> > and ASM_GENERATE_INTERNAL_LABEL will just misbehave.
> > I fail to see why you need tmp_name at all, I'd go just with
> >   char sym_name[40];
> >   ASM_GENERATE_INTERNAL_LABEL (sym_name, "LASANODR", ++lasan_odr_ind_cnt);
> > or so.
> 
> Given that feature is quite new and hasn't been tested too much (it's
> off by default in Clang), having a descriptive name may aid with
> debugging bug reports.

What would those symbols help with in debugging bug reports?
You need to have a source reproducer anyway, then anybody can try it
himself.  Even from just pure *.s file, you can look up where the
.LASANODR1234 is used and from there find the corresponding symbol.
Plus, as I said, with 95 chars or longer symbols (approx.) you get a buffer
overflow.  We don't use descriptive symbols in other internal asan, dwarf2
etc. labels.

	Jakub

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2] Support ASan ODR indicators at compiler side.
  2016-11-21 11:50               ` Jakub Jelinek
@ 2016-11-21 12:09                 ` Yuri Gribov
  2016-11-21 12:17                   ` Jakub Jelinek
  0 siblings, 1 reply; 28+ messages in thread
From: Yuri Gribov @ 2016-11-21 12:09 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Maxim Ostapenko, GCC Patches

On Mon, Nov 21, 2016 at 11:50 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Mon, Nov 21, 2016 at 11:43:56AM +0000, Yuri Gribov wrote:
>> > This is just weird.  DECL_NAME in theory could be NULL, or can be a symbol
>> > much longer than 100 bytes, at which point you have strlen (tmp_name) == 99
>> > and ASM_GENERATE_INTERNAL_LABEL will just misbehave.
>> > I fail to see why you need tmp_name at all, I'd go just with
>> >   char sym_name[40];
>> >   ASM_GENERATE_INTERNAL_LABEL (sym_name, "LASANODR", ++lasan_odr_ind_cnt);
>> > or so.
>>
>> Given that feature is quite new and hasn't been tested too much (it's
>> off by default in Clang), having a descriptive name may aid with
>> debugging bug reports.
>
> What would those symbols help with in debugging bug reports?
> You need to have a source reproducer anyway, then anybody can try it
> himself.

Well, in case of some weird symbol error at startup we can at least
understand which library/symbol to blame.

> Even from just pure *.s file, you can look up where the
> .LASANODR1234 is used and from there find the corresponding symbol.
> Plus, as I said, with 95 chars or longer symbols (approx.) you get a buffer
> overflow.  We don't use descriptive symbols in other internal asan, dwarf2
> etc. labels.

Note that indicators need to have default visibility so simple scheme
like this will cause runtime collisions.

-Iurii

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2] Support ASan ODR indicators at compiler side.
  2016-11-21 12:09                 ` Yuri Gribov
@ 2016-11-21 12:17                   ` Jakub Jelinek
  2016-11-21 12:19                     ` Maxim Ostapenko
  2016-11-21 12:43                     ` Maxim Ostapenko
  0 siblings, 2 replies; 28+ messages in thread
From: Jakub Jelinek @ 2016-11-21 12:17 UTC (permalink / raw)
  To: Yuri Gribov; +Cc: Maxim Ostapenko, GCC Patches

On Mon, Nov 21, 2016 at 12:09:30PM +0000, Yuri Gribov wrote:
> On Mon, Nov 21, 2016 at 11:50 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> > On Mon, Nov 21, 2016 at 11:43:56AM +0000, Yuri Gribov wrote:
> >> > This is just weird.  DECL_NAME in theory could be NULL, or can be a symbol
> >> > much longer than 100 bytes, at which point you have strlen (tmp_name) == 99
> >> > and ASM_GENERATE_INTERNAL_LABEL will just misbehave.
> >> > I fail to see why you need tmp_name at all, I'd go just with
> >> >   char sym_name[40];
> >> >   ASM_GENERATE_INTERNAL_LABEL (sym_name, "LASANODR", ++lasan_odr_ind_cnt);
> >> > or so.
> >>
> >> Given that feature is quite new and hasn't been tested too much (it's
> >> off by default in Clang), having a descriptive name may aid with
> >> debugging bug reports.
> >
> > What would those symbols help with in debugging bug reports?
> > You need to have a source reproducer anyway, then anybody can try it
> > himself.
> 
> Well, in case of some weird symbol error at startup we can at least
> understand which library/symbol to blame.
> 
> > Even from just pure *.s file, you can look up where the
> > .LASANODR1234 is used and from there find the corresponding symbol.
> > Plus, as I said, with 95 chars or longer symbols (approx.) you get a buffer
> > overflow.  We don't use descriptive symbols in other internal asan, dwarf2
> > etc. labels.
> 
> Note that indicators need to have default visibility so simple scheme
> like this will cause runtime collisions.

But then why do you use ASM_GENERATE_INTERNAL_LABEL?  That is for internal
labels.  If the indicators are visible outside of TUs, then their mangling
is an ABI thing.  In that case you shouldn't add any kind of counter
to them, but you should use something like __asan_odr.<name> or something
similar, and if . is not supported in symbol names, use $ instead and if
neither, then just disable the odr indicators.

Or how exactly are these odr indicators supposed to work?

	Jakub

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2] Support ASan ODR indicators at compiler side.
  2016-11-21 12:17                   ` Jakub Jelinek
@ 2016-11-21 12:19                     ` Maxim Ostapenko
  2016-11-21 12:43                     ` Maxim Ostapenko
  1 sibling, 0 replies; 28+ messages in thread
From: Maxim Ostapenko @ 2016-11-21 12:19 UTC (permalink / raw)
  To: Jakub Jelinek, Yuri Gribov; +Cc: GCC Patches

On 21/11/16 15:17, Jakub Jelinek wrote:
> On Mon, Nov 21, 2016 at 12:09:30PM +0000, Yuri Gribov wrote:
>> On Mon, Nov 21, 2016 at 11:50 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>>> On Mon, Nov 21, 2016 at 11:43:56AM +0000, Yuri Gribov wrote:
>>>>> This is just weird.  DECL_NAME in theory could be NULL, or can be a symbol
>>>>> much longer than 100 bytes, at which point you have strlen (tmp_name) == 99
>>>>> and ASM_GENERATE_INTERNAL_LABEL will just misbehave.
>>>>> I fail to see why you need tmp_name at all, I'd go just with
>>>>>    char sym_name[40];
>>>>>    ASM_GENERATE_INTERNAL_LABEL (sym_name, "LASANODR", ++lasan_odr_ind_cnt);
>>>>> or so.
>>>> Given that feature is quite new and hasn't been tested too much (it's
>>>> off by default in Clang), having a descriptive name may aid with
>>>> debugging bug reports.
>>> What would those symbols help with in debugging bug reports?
>>> You need to have a source reproducer anyway, then anybody can try it
>>> himself.
>> Well, in case of some weird symbol error at startup we can at least
>> understand which library/symbol to blame.
>>
>>> Even from just pure *.s file, you can look up where the
>>> .LASANODR1234 is used and from there find the corresponding symbol.
>>> Plus, as I said, with 95 chars or longer symbols (approx.) you get a buffer
>>> overflow.  We don't use descriptive symbols in other internal asan, dwarf2
>>> etc. labels.
>> Note that indicators need to have default visibility so simple scheme
>> like this will cause runtime collisions.
> But then why do you use ASM_GENERATE_INTERNAL_LABEL?  That is for internal
> labels.  If the indicators are visible outside of TUs, then their mangling
> is an ABI thing.  In that case you shouldn't add any kind of counter
> to them, but you should use something like __asan_odr.<name> or something
> similar, and if . is not supported in symbol names, use $ instead and if
> neither, then just disable the odr indicators.
>
> Or how exactly are these odr indicators supposed to work?

Yes, you just caught an error, __asan_odr.<name> is right thing to do 
here. I'm sorry about this.

>
> 	Jakub
>
>
>

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v2] Support ASan ODR indicators at compiler side.
  2016-11-21 12:17                   ` Jakub Jelinek
  2016-11-21 12:19                     ` Maxim Ostapenko
@ 2016-11-21 12:43                     ` Maxim Ostapenko
  1 sibling, 0 replies; 28+ messages in thread
From: Maxim Ostapenko @ 2016-11-21 12:43 UTC (permalink / raw)
  To: Jakub Jelinek, Yuri Gribov; +Cc: GCC Patches

On 21/11/16 15:17, Jakub Jelinek wrote:
> On Mon, Nov 21, 2016 at 12:09:30PM +0000, Yuri Gribov wrote:
>> On Mon, Nov 21, 2016 at 11:50 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>>> On Mon, Nov 21, 2016 at 11:43:56AM +0000, Yuri Gribov wrote:
>>>>> This is just weird.  DECL_NAME in theory could be NULL, or can be a symbol
>>>>> much longer than 100 bytes, at which point you have strlen (tmp_name) == 99
>>>>> and ASM_GENERATE_INTERNAL_LABEL will just misbehave.
>>>>> I fail to see why you need tmp_name at all, I'd go just with
>>>>>    char sym_name[40];
>>>>>    ASM_GENERATE_INTERNAL_LABEL (sym_name, "LASANODR", ++lasan_odr_ind_cnt);
>>>>> or so.
>>>> Given that feature is quite new and hasn't been tested too much (it's
>>>> off by default in Clang), having a descriptive name may aid with
>>>> debugging bug reports.
>>> What would those symbols help with in debugging bug reports?
>>> You need to have a source reproducer anyway, then anybody can try it
>>> himself.
>> Well, in case of some weird symbol error at startup we can at least
>> understand which library/symbol to blame.
>>
>>> Even from just pure *.s file, you can look up where the
>>> .LASANODR1234 is used and from there find the corresponding symbol.
>>> Plus, as I said, with 95 chars or longer symbols (approx.) you get a buffer
>>> overflow.  We don't use descriptive symbols in other internal asan, dwarf2
>>> etc. labels.
>> Note that indicators need to have default visibility so simple scheme
>> like this will cause runtime collisions.
> But then why do you use ASM_GENERATE_INTERNAL_LABEL?  That is for internal
> labels.  If the indicators are visible outside of TUs, then their mangling
> is an ABI thing.  In that case you shouldn't add any kind of counter
> to them, but you should use something like __asan_odr.<name> or something
> similar, and if . is not supported in symbol names, use $ instead and if
> neither, then just disable the odr indicators.
>
> Or how exactly are these odr indicators supposed to work?

Odr indicators act as visible "delegates" of protected by ASan globals 
(their private aliases actually). We introduce them to catch cross-dso 
symbols clashing at runtime.
Of course, some people intentionally use ELF interposition and ASan 
would generate false alarm there, but a) we can use suppressions to 
avoid false alarms here and b) I believe in most cases such an alarm 
would indicate a real bug in user's code.

-Maxim

>
> 	Jakub
>
>
>

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH v3] Support ASan ODR indicators at compiler side.
  2016-11-21 11:38           ` Jakub Jelinek
  2016-11-21 11:44             ` Yuri Gribov
@ 2016-12-01 10:26             ` Maxim Ostapenko
  2016-12-01 10:42               ` Jakub Jelinek
  1 sibling, 1 reply; 28+ messages in thread
From: Maxim Ostapenko @ 2016-12-01 10:26 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jakub Jelinek, Yuri Gribov

[-- Attachment #1: Type: text/plain, Size: 353 bytes --]

Hi,

this is the third attempt to support ASan odr indicators in GCC. I've 
fixed the issue with odr indicator name (now we don't use 
ASM_GENERATE_INTERNAL_LABEL and use XALLOCAVEC for avoid overflow).
Also several style issues from previous review were covered.
How does it look now?

Tested and ASan bootstrapped on x86_64-unknown-linux-gnu.

-Maxim

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: odr_indicators-3.diff --]
[-- Type: text/x-diff; name="odr_indicators-3.diff", Size: 10080 bytes --]

commit 35cb5eb935bb1e29357e93f8e9a4e87fb4e9f511
Author: Maxim Ostapenko <m.ostapenko@samsung.com>
Date:   Fri Oct 28 10:22:03 2016 +0300

    Add support for ASan odr_indicator.
    
    config/
    
    	* bootstrap-asan.mk: Replace LSAN_OPTIONS=detect_leaks=0 with
    	ASAN_OPTIONS=detect_leaks=0:use_odr_indicator=1.
    
    gcc/
    
    	* asan.c (asan_global_struct): Refactor.
    	(create_odr_indicator): New function.
    	(asan_needs_odr_indicator_p): Likewise.
    	(is_odr_indicator): Likewise.
    	(asan_add_global): Introduce odr_indicator_ptr. Pass it into global's
    	constructor.
    	(asan_protect_global): Do not protect odr indicators.
    
    gcc/testsuite/
    
    	* c-c++-common/asan/no-redundant-odr-indicators-1.c: New test.

diff --git a/config/ChangeLog b/config/ChangeLog
index ed59787..a5d5ff5 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,8 @@
+2016-12-01  Maxim Ostapenko  <m.ostapenko@samsung.com>
+
+	* bootstrap-asan.mk: Replace LSAN_OPTIONS=detect_leaks=0 with
+	ASAN_OPTIONS=detect_leaks=0:use_odr_indicator=1.
+
 2016-11-30  Matthias Klose  <doko@ubuntu.com>
 
 	* pkg.m4: New file.
diff --git a/config/bootstrap-asan.mk b/config/bootstrap-asan.mk
index 70baaf9..e73d4c2 100644
--- a/config/bootstrap-asan.mk
+++ b/config/bootstrap-asan.mk
@@ -1,7 +1,7 @@
 # This option enables -fsanitize=address for stage2 and stage3.
 
 # Suppress LeakSanitizer in bootstrap.
-export LSAN_OPTIONS="detect_leaks=0"
+export ASAN_OPTIONS=detect_leaks=0:use_odr_indicator=1
 
 STAGE2_CFLAGS += -fsanitize=address
 STAGE3_CFLAGS += -fsanitize=address
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b3cc6305..f19ac9d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2016-12-01  Maxim Ostapenko  <m.ostapenko@samsung.com>
+
+	* asan.c (asan_global_struct): Refactor.
+	(create_odr_indicator): New function.
+	(asan_needs_odr_indicator_p): Likewise.
+	(is_odr_indicator): Likewise.
+	(asan_add_global): Introduce odr_indicator_ptr. Pass it into global's
+	constructor.
+	(asan_protect_global): Do not protect odr indicators.
+
 2016-12-01  Jakub Jelinek  <jakub@redhat.com>
 
 	PR target/78614
diff --git a/gcc/asan.c b/gcc/asan.c
index cb5d615..9db7481 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1388,6 +1388,16 @@ asan_needs_local_alias (tree decl)
   return DECL_WEAK (decl) || !targetm.binds_local_p (decl);
 }
 
+/* Return true if DECL, a global var, is an artificial ODR indicator symbol
+   therefore doesn't need protection.  */
+
+static bool
+is_odr_indicator (tree decl)
+{
+  return (DECL_ARTIFICIAL (decl)
+	  && lookup_attribute ("asan odr indicator", DECL_ATTRIBUTES (decl)));
+}
+
 /* Return true if DECL is a VAR_DECL that should be protected
    by Address Sanitizer, by appending a red zone with protected
    shadow memory after it and aligning it to at least
@@ -1436,7 +1446,8 @@ asan_protect_global (tree decl)
       || ASAN_RED_ZONE_SIZE * BITS_PER_UNIT > MAX_OFILE_ALIGNMENT
       || !valid_constant_size_p (DECL_SIZE_UNIT (decl))
       || DECL_ALIGN_UNIT (decl) > 2 * ASAN_RED_ZONE_SIZE
-      || TREE_TYPE (decl) == ubsan_get_source_location_type ())
+      || TREE_TYPE (decl) == ubsan_get_source_location_type ()
+      || is_odr_indicator (decl))
     return false;
 
   rtl = DECL_RTL (decl);
@@ -2266,14 +2277,15 @@ asan_dynamic_init_call (bool after_p)
 static tree
 asan_global_struct (void)
 {
-  static const char *field_names[8]
+  static const char *field_names[]
     = { "__beg", "__size", "__size_with_redzone",
-	"__name", "__module_name", "__has_dynamic_init", "__location", "__odr_indicator"};
-  tree fields[8], ret;
-  int i;
+	"__name", "__module_name", "__has_dynamic_init", "__location",
+	"__odr_indicator" };
+  tree fields[ARRAY_SIZE (field_names)], ret;
+  unsigned i;
 
   ret = make_node (RECORD_TYPE);
-  for (i = 0; i < 8; i++)
+  for (i = 0; i < ARRAY_SIZE (field_names); i++)
     {
       fields[i]
 	= build_decl (UNKNOWN_LOCATION, FIELD_DECL,
@@ -2295,6 +2307,60 @@ asan_global_struct (void)
   return ret;
 }
 
+/* Create and return odr indicator symbol for DECL.
+   TYPE is __asan_global struct type as returned by asan_global_struct.  */
+
+static tree
+create_odr_indicator (tree decl, tree type)
+{
+  char *name;
+  tree uptr = TREE_TYPE (DECL_CHAIN (TYPE_FIELDS (type)));
+  tree decl_name
+    = (HAS_DECL_ASSEMBLER_NAME_P (decl) ? DECL_ASSEMBLER_NAME (decl)
+					: DECL_NAME (decl));
+  /* DECL_NAME theoretically might be NULL.  Bail out with 0 in this case.  */
+  if (decl_name == NULL_TREE)
+    return build_int_cst (uptr, 0);
+  int len = strlen (IDENTIFIER_POINTER (decl_name))
+	    + sizeof ("__odr_asan_") + 1;
+  name = XALLOCAVEC (char, len);
+  name[len] = '\0';
+  snprintf (name, len, "__odr_asan_%s", IDENTIFIER_POINTER (decl_name));
+  tree var = build_decl (UNKNOWN_LOCATION, VAR_DECL, get_identifier (name),
+			 char_type_node);
+  TREE_ADDRESSABLE (var) = 1;
+  TREE_READONLY (var) = 0;
+  TREE_THIS_VOLATILE (var) = 1;
+  DECL_GIMPLE_REG_P (var) = 0;
+  DECL_ARTIFICIAL (var) = 1;
+  DECL_IGNORED_P (var) = 1;
+  TREE_STATIC (var) = 1;
+  TREE_PUBLIC (var) = 1;
+  DECL_VISIBILITY (var) = DECL_VISIBILITY (decl);
+  DECL_VISIBILITY_SPECIFIED (var) = DECL_VISIBILITY_SPECIFIED (decl);
+
+  TREE_USED (var) = 1;
+  tree ctor = build_constructor_va (TREE_TYPE (var), 1, NULL_TREE,
+				    build_int_cst (unsigned_type_node, 0));
+  TREE_CONSTANT (ctor) = 1;
+  TREE_STATIC (ctor) = 1;
+  DECL_INITIAL (var) = ctor;
+  DECL_ATTRIBUTES (var) = tree_cons (get_identifier ("asan odr indicator"),
+				     NULL, DECL_ATTRIBUTES (var));
+  make_decl_rtl (var);
+  varpool_node::finalize_decl (var);
+  return fold_convert (uptr, build_fold_addr_expr (var));
+}
+
+/* Return true if DECL, a global var, might be overridden and needs
+   an additional odr indicator symbol.  */
+
+static bool
+asan_needs_odr_indicator_p (tree decl)
+{
+  return !DECL_ARTIFICIAL (decl) && !DECL_WEAK (decl) && TREE_PUBLIC (decl);
+}
+
 /* Append description of a single global DECL into vector V.
    TYPE is __asan_global struct type as returned by asan_global_struct.  */
 
@@ -2335,6 +2401,9 @@ asan_add_global (tree decl, tree type, vec<constructor_elt, va_gc> *v)
       assemble_alias (refdecl, DECL_ASSEMBLER_NAME (decl));
     }
 
+  tree odr_indicator_ptr
+    = (asan_needs_odr_indicator_p (decl) ? create_odr_indicator (decl, type)
+					 : build_int_cst (uptr, 0));
   CONSTRUCTOR_APPEND_ELT (vinner, NULL_TREE,
 			  fold_convert (const_ptr_type_node,
 					build_fold_addr_expr (refdecl)));
@@ -2382,8 +2451,7 @@ 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));
+  CONSTRUCTOR_APPEND_ELT (vinner, NULL_TREE, odr_indicator_ptr);
   init = build_constructor (type, vinner);
   CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, init);
 }
diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index 964efe9..f5adade 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -57,6 +57,8 @@ static tree handle_no_address_safety_analysis_attribute (tree *, tree, tree,
 							 int, bool *);
 static tree handle_no_sanitize_undefined_attribute (tree *, tree, tree, int,
 						    bool *);
+static tree handle_asan_odr_indicator_attribute (tree *, tree, tree, int,
+						 bool *);
 static tree handle_stack_protect_attribute (tree *, tree, tree, int, bool *);
 static tree handle_noinline_attribute (tree *, tree, tree, int, bool *);
 static tree handle_noclone_attribute (tree *, tree, tree, int, bool *);
@@ -292,6 +294,9 @@ const struct attribute_spec c_common_attribute_table[] =
   { "no_sanitize_undefined",  0, 0, true, false, false,
 			      handle_no_sanitize_undefined_attribute,
 			      false },
+  { "asan odr indicator",     0, 0, true, false, false,
+			      handle_asan_odr_indicator_attribute,
+			      false },
   { "warning",		      1, 1, true,  false, false,
 			      handle_error_attribute, false },
   { "error",		      1, 1, true,  false, false,
@@ -591,6 +596,15 @@ handle_no_sanitize_undefined_attribute (tree *node, tree name, tree, int,
   return NULL_TREE;
 }
 
+/* Handle an "asan odr indicator" attribute; arguments as in
+   struct attribute_spec.handler.  */
+
+static tree
+handle_asan_odr_indicator_attribute (tree *, tree, tree, int, bool *)
+{
+  return NULL_TREE;
+}
+
 /* Handle a "stack_protect" attribute; arguments as in
    struct attribute_spec.handler.  */
 
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index bf4bd8a..e570594 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2016-12-01  Maxim Ostapenko  <m.ostapenko@samsung.com>
+
+	* c-c++-common/asan/no-redundant-odr-indicators-1.c: New test.
+
 2016-12-01  Segher Boessenkool  <segher@kernel.crashing.org>
 
 	PR rtl-optimization/78607
diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-odr-indicators-1.c b/gcc/testsuite/c-c++-common/asan/no-redundant-odr-indicators-1.c
new file mode 100644
index 0000000..ff1f272
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/no-redundant-odr-indicators-1.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
+
+/* Local variables should not have odr indicators.  */
+static int a = 2;
+/* Thread local variables should not have odr indicators.  */
+__thread int b = 3;
+/* Externally visible  variables should have odr indicators.  */
+int c = 1;
+
+int main () {
+    return 0;
+}
+
+/* { dg-final { scan-assembler-not ".*odr_asan_a.*" } } */
+/* { dg-final { scan-assembler-not ".*odr_asan_b.*" } } */
+/* { dg-final { scan-assembler ".*odr_asan_c.*" } } */

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v3] Support ASan ODR indicators at compiler side.
  2016-12-01 10:26             ` [PATCH v3] " Maxim Ostapenko
@ 2016-12-01 10:42               ` Jakub Jelinek
  2016-12-01 11:25                 ` Maxim Ostapenko
  0 siblings, 1 reply; 28+ messages in thread
From: Jakub Jelinek @ 2016-12-01 10:42 UTC (permalink / raw)
  To: Maxim Ostapenko; +Cc: GCC Patches, Yuri Gribov

On Thu, Dec 01, 2016 at 01:25:43PM +0300, Maxim Ostapenko wrote:
> +  int len = strlen (IDENTIFIER_POINTER (decl_name))
> +	    + sizeof ("__odr_asan_") + 1;

Please use size_t len instead of int len.  Why the + 1?  sizeof ("__odr_asan_")
should be already strlen ("__odr_asan_") + 1.

> +  name = XALLOCAVEC (char, len);
> +  name[len] = '\0';

This is buffer overflow.  Why do you need it at all?

> +  snprintf (name, len, "__odr_asan_%s", IDENTIFIER_POINTER (decl_name));

This should zero terminate the string.

Also, shouldn't this be followed by:
#ifndef NO_DOT_IN_LABEL
  name[sizeof ("__odr_asan") - 1] = '.';
#elif !defined(NO_DOLLAR_IN_LABEL)
  name[sizeof ("__odr_asan") - 1] = '$';
#endif

to make it not possible to clash with user symbols __odr_asan_foobar etc.
if possible (on targets which don't allow dots nor dollars in labels that is
not really possible, but at least elsewhere).

That said, if the __odr_asan* symbols are exported, it is part of ABI, so
what exactly does LLVM use in those cases?

> +/* { dg-final { scan-assembler-not ".*odr_asan_a.*" } } */
> +/* { dg-final { scan-assembler-not ".*odr_asan_b.*" } } */
> +/* { dg-final { scan-assembler ".*odr_asan_c.*" } } */

The .* on either side makes no sense, please remove those.
And, if the dot or dollar is replacing _, you need to use "odr_asan.a"
etc. in the regexps.

Otherwise LGTM.

	Jakub

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v3] Support ASan ODR indicators at compiler side.
  2016-12-01 10:42               ` Jakub Jelinek
@ 2016-12-01 11:25                 ` Maxim Ostapenko
  0 siblings, 0 replies; 28+ messages in thread
From: Maxim Ostapenko @ 2016-12-01 11:25 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: GCC Patches, Yuri Gribov

[-- Attachment #1: Type: text/plain, Size: 1752 bytes --]

Jakub, thank you for review. I'll commit following patch if no issues 
occur after regtesting and bootstrapping.

On 01/12/16 13:42, Jakub Jelinek wrote:
> On Thu, Dec 01, 2016 at 01:25:43PM +0300, Maxim Ostapenko wrote:
>> +  int len = strlen (IDENTIFIER_POINTER (decl_name))
>> +	    + sizeof ("__odr_asan_") + 1;
> Please use size_t len instead of int len.  Why the + 1?  sizeof ("__odr_asan_")
> should be already strlen ("__odr_asan_") + 1.
>
>> +  name = XALLOCAVEC (char, len);
>> +  name[len] = '\0';
> This is buffer overflow.  Why do you need it at all?
>
>> +  snprintf (name, len, "__odr_asan_%s", IDENTIFIER_POINTER (decl_name));
> This should zero terminate the string.
>
> Also, shouldn't this be followed by:
> #ifndef NO_DOT_IN_LABEL
>    name[sizeof ("__odr_asan") - 1] = '.';
> #elif !defined(NO_DOLLAR_IN_LABEL)
>    name[sizeof ("__odr_asan") - 1] = '$';
> #endif
>
> to make it not possible to clash with user symbols __odr_asan_foobar etc.
> if possible (on targets which don't allow dots nor dollars in labels that is
> not really possible, but at least elsewhere).
>
> That said, if the __odr_asan* symbols are exported, it is part of ABI, so
> what exactly does LLVM use in those cases?

AFAIR LLVM doesn't have such a protection. But I agree that preventing 
symbols clashing is reasonable here. So it should be added to LLVM though.

-Maxim

>
>> +/* { dg-final { scan-assembler-not ".*odr_asan_a.*" } } */
>> +/* { dg-final { scan-assembler-not ".*odr_asan_b.*" } } */
>> +/* { dg-final { scan-assembler ".*odr_asan_c.*" } } */
> The .* on either side makes no sense, please remove those.
> And, if the dot or dollar is replacing _, you need to use "odr_asan.a"
> etc. in the regexps.
>
> Otherwise LGTM.
>
> 	Jakub
>
>
>


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: odr_indicators-4.diff --]
[-- Type: text/x-diff; name="odr_indicators-4.diff", Size: 9433 bytes --]

diff --git a/config/ChangeLog b/config/ChangeLog
index ed59787..a5d5ff5 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,8 @@
+2016-12-01  Maxim Ostapenko  <m.ostapenko@samsung.com>
+
+	* bootstrap-asan.mk: Replace LSAN_OPTIONS=detect_leaks=0 with
+	ASAN_OPTIONS=detect_leaks=0:use_odr_indicator=1.
+
 2016-11-30  Matthias Klose  <doko@ubuntu.com>
 
 	* pkg.m4: New file.
diff --git a/config/bootstrap-asan.mk b/config/bootstrap-asan.mk
index 70baaf9..e73d4c2 100644
--- a/config/bootstrap-asan.mk
+++ b/config/bootstrap-asan.mk
@@ -1,7 +1,7 @@
 # This option enables -fsanitize=address for stage2 and stage3.
 
 # Suppress LeakSanitizer in bootstrap.
-export LSAN_OPTIONS="detect_leaks=0"
+export ASAN_OPTIONS=detect_leaks=0:use_odr_indicator=1
 
 STAGE2_CFLAGS += -fsanitize=address
 STAGE3_CFLAGS += -fsanitize=address
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b3cc6305..f19ac9d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2016-12-01  Maxim Ostapenko  <m.ostapenko@samsung.com>
+
+	* asan.c (asan_global_struct): Refactor.
+	(create_odr_indicator): New function.
+	(asan_needs_odr_indicator_p): Likewise.
+	(is_odr_indicator): Likewise.
+	(asan_add_global): Introduce odr_indicator_ptr. Pass it into global's
+	constructor.
+	(asan_protect_global): Do not protect odr indicators.
+
 2016-12-01  Jakub Jelinek  <jakub@redhat.com>
 
 	PR target/78614
diff --git a/gcc/asan.c b/gcc/asan.c
index cb5d615..5af9547 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1388,6 +1388,16 @@ asan_needs_local_alias (tree decl)
   return DECL_WEAK (decl) || !targetm.binds_local_p (decl);
 }
 
+/* Return true if DECL, a global var, is an artificial ODR indicator symbol
+   therefore doesn't need protection.  */
+
+static bool
+is_odr_indicator (tree decl)
+{
+  return (DECL_ARTIFICIAL (decl)
+	  && lookup_attribute ("asan odr indicator", DECL_ATTRIBUTES (decl)));
+}
+
 /* Return true if DECL is a VAR_DECL that should be protected
    by Address Sanitizer, by appending a red zone with protected
    shadow memory after it and aligning it to at least
@@ -1436,7 +1446,8 @@ asan_protect_global (tree decl)
       || ASAN_RED_ZONE_SIZE * BITS_PER_UNIT > MAX_OFILE_ALIGNMENT
       || !valid_constant_size_p (DECL_SIZE_UNIT (decl))
       || DECL_ALIGN_UNIT (decl) > 2 * ASAN_RED_ZONE_SIZE
-      || TREE_TYPE (decl) == ubsan_get_source_location_type ())
+      || TREE_TYPE (decl) == ubsan_get_source_location_type ()
+      || is_odr_indicator (decl))
     return false;
 
   rtl = DECL_RTL (decl);
@@ -2266,14 +2277,15 @@ asan_dynamic_init_call (bool after_p)
 static tree
 asan_global_struct (void)
 {
-  static const char *field_names[8]
+  static const char *field_names[]
     = { "__beg", "__size", "__size_with_redzone",
-	"__name", "__module_name", "__has_dynamic_init", "__location", "__odr_indicator"};
-  tree fields[8], ret;
-  int i;
+	"__name", "__module_name", "__has_dynamic_init", "__location",
+	"__odr_indicator" };
+  tree fields[ARRAY_SIZE (field_names)], ret;
+  unsigned i;
 
   ret = make_node (RECORD_TYPE);
-  for (i = 0; i < 8; i++)
+  for (i = 0; i < ARRAY_SIZE (field_names); i++)
     {
       fields[i]
 	= build_decl (UNKNOWN_LOCATION, FIELD_DECL,
@@ -2295,6 +2307,63 @@ asan_global_struct (void)
   return ret;
 }
 
+/* Create and return odr indicator symbol for DECL.
+   TYPE is __asan_global struct type as returned by asan_global_struct.  */
+
+static tree
+create_odr_indicator (tree decl, tree type)
+{
+  char *name;
+  tree uptr = TREE_TYPE (DECL_CHAIN (TYPE_FIELDS (type)));
+  tree decl_name
+    = (HAS_DECL_ASSEMBLER_NAME_P (decl) ? DECL_ASSEMBLER_NAME (decl)
+					: DECL_NAME (decl));
+  /* DECL_NAME theoretically might be NULL.  Bail out with 0 in this case.  */
+  if (decl_name == NULL_TREE)
+    return build_int_cst (uptr, 0);
+  size_t len = strlen (IDENTIFIER_POINTER (decl_name)) + sizeof ("__odr_asan_");
+  name = XALLOCAVEC (char, len);
+  snprintf (name, len, "__odr_asan_%s", IDENTIFIER_POINTER (decl_name));
+#ifndef NO_DOT_IN_LABEL
+  name[sizeof ("__odr_asan") - 1] = '.';
+#elif !defined(NO_DOLLAR_IN_LABEL)
+  name[sizeof ("__odr_asan") - 1] = '$';
+#endif
+  tree var = build_decl (UNKNOWN_LOCATION, VAR_DECL, get_identifier (name),
+			 char_type_node);
+  TREE_ADDRESSABLE (var) = 1;
+  TREE_READONLY (var) = 0;
+  TREE_THIS_VOLATILE (var) = 1;
+  DECL_GIMPLE_REG_P (var) = 0;
+  DECL_ARTIFICIAL (var) = 1;
+  DECL_IGNORED_P (var) = 1;
+  TREE_STATIC (var) = 1;
+  TREE_PUBLIC (var) = 1;
+  DECL_VISIBILITY (var) = DECL_VISIBILITY (decl);
+  DECL_VISIBILITY_SPECIFIED (var) = DECL_VISIBILITY_SPECIFIED (decl);
+
+  TREE_USED (var) = 1;
+  tree ctor = build_constructor_va (TREE_TYPE (var), 1, NULL_TREE,
+				    build_int_cst (unsigned_type_node, 0));
+  TREE_CONSTANT (ctor) = 1;
+  TREE_STATIC (ctor) = 1;
+  DECL_INITIAL (var) = ctor;
+  DECL_ATTRIBUTES (var) = tree_cons (get_identifier ("asan odr indicator"),
+				     NULL, DECL_ATTRIBUTES (var));
+  make_decl_rtl (var);
+  varpool_node::finalize_decl (var);
+  return fold_convert (uptr, build_fold_addr_expr (var));
+}
+
+/* Return true if DECL, a global var, might be overridden and needs
+   an additional odr indicator symbol.  */
+
+static bool
+asan_needs_odr_indicator_p (tree decl)
+{
+  return !DECL_ARTIFICIAL (decl) && !DECL_WEAK (decl) && TREE_PUBLIC (decl);
+}
+
 /* Append description of a single global DECL into vector V.
    TYPE is __asan_global struct type as returned by asan_global_struct.  */
 
@@ -2335,6 +2404,9 @@ asan_add_global (tree decl, tree type, vec<constructor_elt, va_gc> *v)
       assemble_alias (refdecl, DECL_ASSEMBLER_NAME (decl));
     }
 
+  tree odr_indicator_ptr
+    = (asan_needs_odr_indicator_p (decl) ? create_odr_indicator (decl, type)
+					 : build_int_cst (uptr, 0));
   CONSTRUCTOR_APPEND_ELT (vinner, NULL_TREE,
 			  fold_convert (const_ptr_type_node,
 					build_fold_addr_expr (refdecl)));
@@ -2382,8 +2454,7 @@ 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));
+  CONSTRUCTOR_APPEND_ELT (vinner, NULL_TREE, odr_indicator_ptr);
   init = build_constructor (type, vinner);
   CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, init);
 }
diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index 964efe9..f5adade 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -57,6 +57,8 @@ static tree handle_no_address_safety_analysis_attribute (tree *, tree, tree,
 							 int, bool *);
 static tree handle_no_sanitize_undefined_attribute (tree *, tree, tree, int,
 						    bool *);
+static tree handle_asan_odr_indicator_attribute (tree *, tree, tree, int,
+						 bool *);
 static tree handle_stack_protect_attribute (tree *, tree, tree, int, bool *);
 static tree handle_noinline_attribute (tree *, tree, tree, int, bool *);
 static tree handle_noclone_attribute (tree *, tree, tree, int, bool *);
@@ -292,6 +294,9 @@ const struct attribute_spec c_common_attribute_table[] =
   { "no_sanitize_undefined",  0, 0, true, false, false,
 			      handle_no_sanitize_undefined_attribute,
 			      false },
+  { "asan odr indicator",     0, 0, true, false, false,
+			      handle_asan_odr_indicator_attribute,
+			      false },
   { "warning",		      1, 1, true,  false, false,
 			      handle_error_attribute, false },
   { "error",		      1, 1, true,  false, false,
@@ -591,6 +596,15 @@ handle_no_sanitize_undefined_attribute (tree *node, tree name, tree, int,
   return NULL_TREE;
 }
 
+/* Handle an "asan odr indicator" attribute; arguments as in
+   struct attribute_spec.handler.  */
+
+static tree
+handle_asan_odr_indicator_attribute (tree *, tree, tree, int, bool *)
+{
+  return NULL_TREE;
+}
+
 /* Handle a "stack_protect" attribute; arguments as in
    struct attribute_spec.handler.  */
 
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index bf4bd8a..e570594 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2016-12-01  Maxim Ostapenko  <m.ostapenko@samsung.com>
+
+	* c-c++-common/asan/no-redundant-odr-indicators-1.c: New test.
+
 2016-12-01  Segher Boessenkool  <segher@kernel.crashing.org>
 
 	PR rtl-optimization/78607
diff --git a/gcc/testsuite/c-c++-common/asan/no-redundant-odr-indicators-1.c b/gcc/testsuite/c-c++-common/asan/no-redundant-odr-indicators-1.c
new file mode 100644
index 0000000..9231264
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/no-redundant-odr-indicators-1.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
+
+/* Local variables should not have odr indicators.  */
+static int a = 2;
+/* Thread local variables should not have odr indicators.  */
+__thread int b = 3;
+/* Externally visible  variables should have odr indicators.  */
+int c = 1;
+
+int main () {
+    return 0;
+}
+
+/* { dg-final { scan-assembler-not "odr_asan\[\.\$\]a" } } */
+/* { dg-final { scan-assembler-not "odr_asan\[\.\$\]b" } } */
+/* { dg-final { scan-assembler "odr_asan\[\.\$\]c" } } */

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2016-12-01 11:25 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20161107082229eucas1p2b7db548c790652a933f5f0d55fe76e50@eucas1p2.samsung.com>
2016-11-07  8:22 ` [PATCH 0/7] Libsanitizer merge from upstream r285547 Maxim Ostapenko
     [not found]   ` <CGME20161107082413eucas1p1d3db8c4db2923df60cdbaa499b3e2b02@eucas1p1.samsung.com>
2016-11-07  8:24     ` [PATCH 2/7] " Maxim Ostapenko
     [not found]   ` <CGME20161107082451eucas1p2fe6f13bf569875cd62ccd673bc7db73a@eucas1p2.samsung.com>
2016-11-07  8:25     ` [PATCH 3/7] " Maxim Ostapenko
     [not found]   ` <CGME20161107082555eucas1p217136a7bc11b9033cad23d9579361228@eucas1p2.samsung.com>
2016-11-07  8:26     ` [PATCH 4/7] " Maxim Ostapenko
     [not found]   ` <CGME20161107082654eucas1p229c86ef02d8c2a90e0ffff113eca5ee7@eucas1p2.samsung.com>
2016-11-07  8:27     ` [PATCH 5/7] " Maxim Ostapenko
     [not found]   ` <CGME20161107082842eucas1p19cbcb798ace4eb86d8ea1460fb6ed8e0@eucas1p1.samsung.com>
2016-11-07  8:28     ` [PATCH 6/7] " Maxim Ostapenko
     [not found]   ` <CGME20161107083119eucas1p25c96348950eded7dd68ae9813db3c2cb@eucas1p2.samsung.com>
2016-11-07  8:31     ` [PATCH 7/7] " Maxim Ostapenko
2016-11-07  8:52       ` Jakub Jelinek
2016-11-14  8:44         ` [PATCH v2] Support ASan ODR indicators at compiler side Maxim Ostapenko
2016-11-21 11:38           ` Jakub Jelinek
2016-11-21 11:44             ` Yuri Gribov
2016-11-21 11:50               ` Jakub Jelinek
2016-11-21 12:09                 ` Yuri Gribov
2016-11-21 12:17                   ` Jakub Jelinek
2016-11-21 12:19                     ` Maxim Ostapenko
2016-11-21 12:43                     ` Maxim Ostapenko
2016-12-01 10:26             ` [PATCH v3] " Maxim Ostapenko
2016-12-01 10:42               ` Jakub Jelinek
2016-12-01 11:25                 ` Maxim Ostapenko
2016-11-07  8:34   ` [PATCH 1/7] Libsanitizer merge from upstream r285547 Maxim Ostapenko
2016-11-07  8:40   ` [PATCH 0/7] " Jakub Jelinek
2016-11-07  9:14     ` Maxim Ostapenko
2016-11-07  9:20       ` Jakub Jelinek
2016-11-07  9:28         ` Yuri Gribov
2016-11-07  9:38           ` Maxim Ostapenko
2016-11-07 10:02         ` Maxim Ostapenko
2016-11-07 10:04   ` Jakub Jelinek
2016-11-07 10:34     ` Maxim Ostapenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).