[compiler-rt] r177397 - [sanitizer] Move ASan platform macros to sanitizer_common and rename them appropriately.

Alexey Samsonov samsonov at google.com
Tue Mar 19 07:07:52 PDT 2013


On Tue, Mar 19, 2013 at 5:54 PM, Evgeniy Stepanov <eugeni.stepanov at gmail.com
> wrote:

> Author: eugenis
> Date: Tue Mar 19 08:54:41 2013
> New Revision: 177397
>
> URL: http://llvm.org/viewvc/llvm-project?rev=177397&view=rev
> Log:
> [sanitizer] Move ASan platform macros to sanitizer_common and rename them
> appropriately.
>
> Modified:
>     compiler-rt/trunk/lib/asan/asan_internal.h
>     compiler-rt/trunk/lib/asan/asan_linux.cc
>     compiler-rt/trunk/lib/asan/asan_mac.h
>     compiler-rt/trunk/lib/asan/asan_malloc_linux.cc
>     compiler-rt/trunk/lib/asan/asan_mapping.h
>     compiler-rt/trunk/lib/asan/asan_new_delete.cc
>     compiler-rt/trunk/lib/asan/asan_rtl.cc
>     compiler-rt/trunk/lib/asan/asan_thread_registry.cc
>     compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h
>
> Modified: compiler-rt/trunk/lib/asan/asan_internal.h
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=177397&r1=177396&r2=177397&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/asan/asan_internal.h (original)
> +++ compiler-rt/trunk/lib/asan/asan_internal.h Tue Mar 19 08:54:41 2013
> @@ -21,39 +21,8 @@
>  #include "sanitizer_common/sanitizer_stacktrace.h"
>  #include "sanitizer_common/sanitizer_libc.h"
>
> -#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32)
> -# error "This operating system is not supported by AddressSanitizer"
> -#endif
> -
>  #define ASAN_DEFAULT_FAILURE_EXITCODE 1
>
> -#if defined(__linux__)
> -# define ASAN_LINUX   1
> -#else
> -# define ASAN_LINUX   0
> -#endif
> -
> -#if defined(__APPLE__)
> -# define ASAN_MAC     1
> -#else
> -# define ASAN_MAC     0
> -#endif
> -
> -#if defined(_WIN32)
> -# define ASAN_WINDOWS 1
> -#else
> -# define ASAN_WINDOWS 0
> -#endif
> -
> -#if defined(__ANDROID__) || defined(ANDROID)
> -# define ASAN_ANDROID 1
> -#else
> -# define ASAN_ANDROID 0
> -#endif
> -
> -
> -#define ASAN_POSIX (ASAN_LINUX || ASAN_MAC)
> -
>  #if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
>  # error "The AddressSanitizer run-time should not be"
>          " instrumented by AddressSanitizer"
> @@ -63,7 +32,7 @@
>
>  // If set, asan will install its own SEGV signal handler.
>  #ifndef ASAN_NEEDS_SEGV
> -# if ASAN_ANDROID == 1
> +# if SANITIZER_ANDROID == 1
>  #  define ASAN_NEEDS_SEGV 0
>  # else
>  #  define ASAN_NEEDS_SEGV 1
> @@ -92,7 +61,7 @@
>  #endif
>
>  #ifndef ASAN_USE_PREINIT_ARRAY
> -# define ASAN_USE_PREINIT_ARRAY (ASAN_LINUX && !ASAN_ANDROID)
> +# define ASAN_USE_PREINIT_ARRAY (SANITIZER_LINUX && !SANITIZER_ANDROID)
>  #endif
>
>  // All internal functions in asan reside inside the __asan namespace
>
> Modified: compiler-rt/trunk/lib/asan/asan_linux.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_linux.cc?rev=177397&r1=177396&r2=177397&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/asan/asan_linux.cc (original)
> +++ compiler-rt/trunk/lib/asan/asan_linux.cc Tue Mar 19 08:54:41 2013
> @@ -31,7 +31,7 @@
>  #include <unistd.h>
>  #include <unwind.h>
>
> -#if !ASAN_ANDROID
> +#if !SANITIZER_ANDROID
>  // FIXME: where to get ucontext on Android?
>  #include <sys/ucontext.h>
>  #endif
> @@ -50,7 +50,7 @@ void *AsanDoesNotSupportStaticLinkage()
>  }
>
>  void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
> -#if ASAN_ANDROID
> +#if SANITIZER_ANDROID
>    *pc = *sp = *bp = 0;
>  #elif defined(__arm__)
>    ucontext_t *ucontext = (ucontext_t*)context;
> @@ -119,7 +119,7 @@ void GetStackTrace(StackTrace *stack, up
>    }
>  }
>
> -#if !ASAN_ANDROID
> +#if !SANITIZER_ANDROID
>  void ReadContextStack(void *context, uptr *stack, uptr *ssize) {
>    ucontext_t *ucp = (ucontext_t*)context;
>    *stack = (uptr)ucp->uc_stack.ss_sp;
>
> Modified: compiler-rt/trunk/lib/asan/asan_mac.h
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_mac.h?rev=177397&r1=177396&r2=177397&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/asan/asan_mac.h (original)
> +++ compiler-rt/trunk/lib/asan/asan_mac.h Tue Mar 19 08:54:41 2013
> @@ -11,8 +11,8 @@
>  //
>  // Mac-specific ASan definitions.
>
>  //===----------------------------------------------------------------------===//
> -#ifndef ASAN_MAC_H
> -#define ASAN_MAC_H
> +#ifndef SANITIZER_MAC_H
> +#define SANITIZER_MAC_H
>

I don't think you should modify header guards.


>
>  // CF_RC_BITS, the layout of CFRuntimeBase and __CFStrIsConstant are
> internal
>  // and subject to change in further CoreFoundation versions. Apple does
> not
> @@ -54,4 +54,4 @@ void MaybeReplaceCFAllocator();
>
>  }  // namespace __asan
>
> -#endif  // ASAN_MAC_H
> +#endif  // SANITIZER_MAC_H
>
> Modified: compiler-rt/trunk/lib/asan/asan_malloc_linux.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_malloc_linux.cc?rev=177397&r1=177396&r2=177397&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/asan/asan_malloc_linux.cc (original)
> +++ compiler-rt/trunk/lib/asan/asan_malloc_linux.cc Tue Mar 19 08:54:41
> 2013
> @@ -21,7 +21,7 @@
>  #include "asan_stack.h"
>  #include "asan_thread_registry.h"
>
> -#if ASAN_ANDROID
> +#if SANITIZER_ANDROID
>  DECLARE_REAL_AND_INTERCEPTOR(void*, malloc, uptr size)
>  DECLARE_REAL_AND_INTERCEPTOR(void, free, void *ptr)
>  DECLARE_REAL_AND_INTERCEPTOR(void*, calloc, uptr nmemb, uptr size)
>
> Modified: compiler-rt/trunk/lib/asan/asan_mapping.h
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_mapping.h?rev=177397&r1=177396&r2=177397&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/asan/asan_mapping.h (original)
> +++ compiler-rt/trunk/lib/asan/asan_mapping.h Tue Mar 19 08:54:41 2013
> @@ -56,7 +56,7 @@ extern SANITIZER_INTERFACE_ATTRIBUTE upt
>  # define SHADOW_SCALE (__asan_mapping_scale)
>  # define SHADOW_OFFSET (__asan_mapping_offset)
>  #else
> -# if ASAN_ANDROID
> +# if SANITIZER_ANDROID
>  #  define SHADOW_SCALE (3)
>  #  define SHADOW_OFFSET (0)
>  # else
> @@ -67,7 +67,7 @@ extern SANITIZER_INTERFACE_ATTRIBUTE upt
>  #   if defined(__powerpc64__)
>  #    define SHADOW_OFFSET (1ULL << 41)
>  #   else
> -#    if ASAN_MAC
> +#    if SANITIZER_MAC
>  #     define SHADOW_OFFSET (1ULL << 44)
>  #    else
>  #     define SHADOW_OFFSET 0x7fff8000ULL
>
> Modified: compiler-rt/trunk/lib/asan/asan_new_delete.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_new_delete.cc?rev=177397&r1=177396&r2=177397&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/asan/asan_new_delete.cc (original)
> +++ compiler-rt/trunk/lib/asan/asan_new_delete.cc Tue Mar 19 08:54:41 2013
> @@ -29,7 +29,7 @@ using namespace __asan;  // NOLINT
>
>  // On Android new() goes through malloc interceptors.
>  // See also
> https://code.google.com/p/address-sanitizer/issues/detail?id=131.
> -#if !ASAN_ANDROID
> +#if !SANITIZER_ANDROID
>
>  // Fake std::nothrow_t to avoid including <new>.
>  namespace std {
>
> Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=177397&r1=177396&r2=177397&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
> +++ compiler-rt/trunk/lib/asan/asan_rtl.cc Tue Mar 19 08:54:41 2013
> @@ -169,7 +169,7 @@ void InitializeFlags(Flags *f, const cha
>    f->poison_heap = true;
>    // Turn off alloc/dealloc mismatch checker on Mac for now.
>    // TODO(glider): Fix known issues and enable this back.
> -  f->alloc_dealloc_mismatch = (ASAN_MAC == 0);;
> +  f->alloc_dealloc_mismatch = (SANITIZER_MAC == 0);;
>    f->use_stack_depot = true;  // Only affects allocator2.
>    f->strict_memcmp = true;
>
> @@ -462,7 +462,7 @@ void __asan_init() {
>    bool full_shadow_is_available =
>        MemoryRangeIsAvailable(shadow_start, shadow_end);
>
> -#if ASAN_LINUX && defined(__x86_64__) && !ASAN_FIXED_MAPPING
> +#if SANITIZER_LINUX && defined(__x86_64__) && !ASAN_FIXED_MAPPING
>    if (!full_shadow_is_available) {
>      kMidMemBeg = kLowMemEnd < 0x3000000000ULL ? 0x3000000000ULL : 0;
>      kMidMemEnd = kLowMemEnd < 0x3000000000ULL ? 0x4fffffffffULL : 0;
>
> Modified: compiler-rt/trunk/lib/asan/asan_thread_registry.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_thread_registry.cc?rev=177397&r1=177396&r2=177397&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/asan/asan_thread_registry.cc (original)
> +++ compiler-rt/trunk/lib/asan/asan_thread_registry.cc Tue Mar 19 08:54:41
> 2013
> @@ -70,7 +70,7 @@ AsanThread *AsanThreadRegistry::GetMain(
>  AsanThread *AsanThreadRegistry::GetCurrent() {
>    AsanThreadSummary *summary = (AsanThreadSummary *)AsanTSDGet();
>    if (!summary) {
> -#if ASAN_ANDROID
> +#if SANITIZER_ANDROID
>      // On Android, libc constructor is called _after_ asan_init, and
> cleans up
>      // TSD. Try to figure out if this is still the main thread by the
> stack
>      // address. We are not entirely sure that we have correct main thread
>
> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h?rev=177397&r1=177396&r2=177397&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h
> (original)
> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h Tue
> Mar 19 08:54:41 2013
> @@ -13,6 +13,37 @@
>  #ifndef SANITIZER_DEFS_H
>  #define SANITIZER_DEFS_H
>
> +#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32)
> +# error "This operating system is not supported"
> +#endif
> +
> +#if defined(__linux__)
> +# define SANITIZER_LINUX   1
> +#else
> +# define SANITIZER_LINUX   0
> +#endif
> +
> +#if defined(__APPLE__)
> +# define SANITIZER_MAC     1
> +#else
> +# define SANITIZER_MAC     0
> +#endif
> +
> +#if defined(_WIN32)
> +# define SANITIZER_WINDOWS 1
> +#else
> +# define SANITIZER_WINDOWS 0
> +#endif
> +
> +#if defined(__ANDROID__) || defined(ANDROID)
> +# define SANITIZER_ANDROID 1
> +#else
> +# define SANITIZER_ANDROID 0
> +#endif
> +
> +#define SANITIZER_POSIX (SANITIZER_LINUX || SANITIZER_MAC)
> +
> +
>  #if defined(_WIN32)
>  // FIXME find out what we need on Windows. __declspec(dllexport) ?
>  # define SANITIZER_INTERFACE_ATTRIBUTE
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>



-- 
Alexey Samsonov, MSK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130319/14b69e1c/attachment.html>


More information about the llvm-commits mailing list