From 0628fce629b2d3bc80fc693f80838a4940b038bc Mon Sep 17 00:00:00 2001 From: Slava Barinov Date: Wed, 12 Jul 2017 11:21:11 +0300 Subject: [PATCH] [asan] Revert ABI changes after ASan patches backporting gcc/ * asan.c: Remove __odr_indicator usage. * asan_globals.cc: Likewise. libsanitizer/ * asan/asan_init_version.h: Revert asan version to 6. * asan/asan_interface_internal.h: Remove __odr_indicator. * asan/libtool-version: Revert shared object version to 3. Change-Id: I9f1c1766b7d00d659f9f47468f9293aeb52a0faf Signed-off-by: Slava Barinov --- gcc/asan.c | 11 ++---- libsanitizer/asan/asan_globals.cc | 57 ++--------------------------- libsanitizer/asan/asan_init_version.h | 4 +- libsanitizer/asan/asan_interface_internal.h | 1 - libsanitizer/asan/libtool-version | 2 +- 5 files changed, 12 insertions(+), 63 deletions(-) diff --git a/gcc/asan.c b/gcc/asan.c index 89ee451..2483eec 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -2189,20 +2189,19 @@ 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[8] + static const char *field_names[] = { "__beg", "__size", "__size_with_redzone", - "__name", "__module_name", "__has_dynamic_init", "__location", "__odr_indicator"}; - tree fields[8], ret; + "__name", "__module_name", "__has_dynamic_init", "__location"}; + tree fields[ARRAY_SIZE(field_names)], ret; int 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, @@ -2315,8 +2314,6 @@ asan_add_global (tree decl, tree type, vec *v) else locptr = build_int_cst (uptr, 0); CONSTRUCTOR_APPEND_ELT (vinner, NULL_TREE, locptr); - /* TODO: support ODR indicators. */ - CONSTRUCTOR_APPEND_ELT (vinner, NULL_TREE, build_int_cst (uptr, 0)); init = build_constructor (type, vinner); CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, init); } diff --git a/libsanitizer/asan/asan_globals.cc b/libsanitizer/asan/asan_globals.cc index 007fce72..ca37710 100644 --- a/libsanitizer/asan/asan_globals.cc +++ b/libsanitizer/asan/asan_globals.cc @@ -127,26 +127,6 @@ enum GlobalSymbolState { REGISTERED = 1 }; -// Check ODR violation for given global G via special ODR indicator. We use -// this method in case compiler instruments global variables through their -// local aliases. -static void CheckODRViolationViaIndicator(const Global *g) { - u8 *odr_indicator = reinterpret_cast(g->odr_indicator); - if (*odr_indicator == UNREGISTERED) { - *odr_indicator = REGISTERED; - return; - } - // If *odr_indicator is DEFINED, some module have already registered - // externally visible symbol with the same name. This is an ODR violation. - for (ListOfGlobals *l = list_of_all_globals; l; l = l->next) { - if (g->odr_indicator == l->g->odr_indicator && - (flags()->detect_odr_violation >= 2 || g->size != l->g->size) && - !IsODRViolationSuppressed(g->name)) - ReportODRViolation(g, FindRegistrationSite(g), - l->g, FindRegistrationSite(l->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. @@ -164,28 +144,6 @@ static void CheckODRViolationViaPoisoning(const Global *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 -// cheaply detect ODR violation: if we try to poison an already poisoned -// global, we have ODR violation error. -// In latter case, we poison each symbol exactly once, so we use special -// indicator symbol to perform similar check. -// In either case, compiler provides a special odr_indicator field to Global -// structure, that can contain two kinds of values: -// 1) Non-zero value. In this case, odr_indicator is an address of -// corresponding indicator variable for given global. -// 2) Zero. This means that we don't use private aliases for global variables -// and can freely check ODR violation with the first method. -// -// This routine chooses between two different methods of ODR violation -// detection. -static inline bool UseODRIndicator(const Global *g) { - // Use ODR indicator method iff use_odr_indicator flag is set and - // indicator symbol address is not 0. - return flags()->use_odr_indicator && g->odr_indicator > 0; -} - // Register a global variable. // This function may be called more than once for every global // so we store the globals in a map. @@ -206,13 +164,12 @@ static void RegisterGlobal(const Global *g) { CHECK(AddrIsAlignedByGranularity(g->beg)); } CHECK(AddrIsAlignedByGranularity(g->size_with_redzone)); - if (flags()->detect_odr_violation) { + if (0 && flags()->detect_odr_violation) { // Try detecting ODR (One Definition Rule) violation, i.e. the situation // where two globals with the same name are defined in different modules. - if (UseODRIndicator(g)) - CheckODRViolationViaIndicator(g); - else - CheckODRViolationViaPoisoning(g); + // NOTE: Currently ODR check is switched off in order to maintain ABI + // compatibility. + CheckODRViolationViaPoisoning(g); } if (CanPoisonMemory()) PoisonRedZones(*g); @@ -243,12 +200,6 @@ static void UnregisterGlobal(const Global *g) { // We unpoison the shadow memory for the global but we do not remove it from // the list because that would require O(n^2) time with the current list // implementation. It might not be worth doing anyway. - - // Release ODR indicator. - if (UseODRIndicator(g)) { - u8 *odr_indicator = reinterpret_cast(g->odr_indicator); - *odr_indicator = UNREGISTERED; - } } void StopInitOrderChecking() { diff --git a/libsanitizer/asan/asan_init_version.h b/libsanitizer/asan/asan_init_version.h index 51e8324..901b493 100644 --- a/libsanitizer/asan/asan_init_version.h +++ b/libsanitizer/asan/asan_init_version.h @@ -30,7 +30,9 @@ extern "C" { // v6=>v7: added 'odr_indicator' to __asan_global // v7=>v8: added '__asan_(un)register_image_globals' functions for dead // stripping support on Mach-O platforms - #define __asan_version_mismatch_check __asan_version_mismatch_check_v8 + // NOTE: The version is reverted back to v6 since we don't want ABI change + // which requires rebuild of whole Tizen. + #define __asan_version_mismatch_check __asan_version_mismatch_check_v6 } #endif // ASAN_INIT_VERSION_H diff --git a/libsanitizer/asan/asan_interface_internal.h b/libsanitizer/asan/asan_interface_internal.h index 05605a8..1576857 100644 --- a/libsanitizer/asan/asan_interface_internal.h +++ b/libsanitizer/asan/asan_interface_internal.h @@ -54,7 +54,6 @@ extern "C" { uptr has_dynamic_init; // Non-zero if the global has dynamic initializer. __asan_global_source_location *location; // Source location of a global, // or NULL if it is unknown. - uptr odr_indicator; // The address of the ODR indicator symbol. }; // These functions can be called on some platforms to find globals in the same diff --git a/libsanitizer/asan/libtool-version b/libsanitizer/asan/libtool-version index 0f14ee3..7e838a5 100644 --- a/libsanitizer/asan/libtool-version +++ b/libsanitizer/asan/libtool-version @@ -3,4 +3,4 @@ # a separate file so that version updates don't involve re-running # automake. # CURRENT:REVISION:AGE -4:0:0 +3:0:0 -- 2.7.4