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.

From 5cd9a7cb1c2dd668e533bee1bc15e367d367d84f Mon Sep 17 00:00:00 2001
From: Maxim Ostapenko <m.ostape...@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.ostape...@samsung.com>
 
+	* asan/asan_globals.cc (RegisterGlobal): Do not call
+	CheckODRViolationViaPoisoning.
+	(CheckODRViolationViaPoisoning): Remove.
+
+2016-11-07  Maxim Ostapenko  <m.ostape...@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

Reply via email to