From: Benjamin Peterson Date: Mon, 27 Apr 2015 00:33:38 +0000 (-0400) Subject: allow 2.7 to be built with asan (closes #24061) X-Git-Tag: v2.7.10rc1~19 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b529c249214096a6e08a50399692d124c26dba29;p=thirdparty%2FPython%2Fcpython.git allow 2.7 to be built with asan (closes #24061) --- diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index 14342065550e..85eee611530a 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -1,5 +1,23 @@ #include "Python.h" +#if defined(__has_feature) /* Clang */ + #if __has_feature(address_sanitizer) /* is ASAN enabled? */ + #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS \ + __attribute__((no_address_safety_analysis)) \ + __attribute__ ((noinline)) + #else + #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS + #endif +#else + #if defined(__SANITIZE_ADDRESS__) /* GCC 4.8.x, is ASAN enabled? */ + #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS \ + __attribute__((no_address_safety_analysis)) \ + __attribute__ ((noinline)) + #else + #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS + #endif +#endif + #ifdef WITH_PYMALLOC #ifdef HAVE_MMAP @@ -971,6 +989,7 @@ redirect: /* free */ #undef PyObject_Free +ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS void PyObject_Free(void *p) { @@ -1201,6 +1220,7 @@ redirect: */ #undef PyObject_Realloc +ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS void * PyObject_Realloc(void *p, size_t nbytes) {