svn commit: r279192 - in vendor/compiler-rt/dist: cmake lib lib/asan lib/asan/scripts lib/asan/tests lib/builtins lib/dfsan lib/lsan lib/msan lib/msan/tests lib/sanitizer_common lib/sanitizer_commo...
Dimitry Andric
dim at FreeBSD.org
Sun Feb 22 22:43:48 UTC 2015
Author: dim
Date: Sun Feb 22 22:43:40 2015
New Revision: 279192
URL: https://svnweb.freebsd.org/changeset/base/279192
Log:
Import compiler-rt trunk r230183.
https://llvm.org/svn/llvm-project/compiler-rt/trunk@230183
Added:
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_interface_internal.h (contents, props changed)
vendor/compiler-rt/dist/test/asan/TestCases/Windows/globals_multiple_dlls.cc (contents, props changed)
vendor/compiler-rt/dist/test/asan/TestCases/Windows/oom.cc (contents, props changed)
vendor/compiler-rt/dist/test/asan/TestCases/Windows/symbols_path.cc (contents, props changed)
vendor/compiler-rt/dist/test/cfi/
vendor/compiler-rt/dist/test/cfi/CMakeLists.txt (contents, props changed)
vendor/compiler-rt/dist/test/cfi/anon-namespace.cpp (contents, props changed)
vendor/compiler-rt/dist/test/cfi/lit.cfg
vendor/compiler-rt/dist/test/cfi/lit.site.cfg.in (contents, props changed)
vendor/compiler-rt/dist/test/cfi/multiple-inheritance.cpp (contents, props changed)
vendor/compiler-rt/dist/test/cfi/overwrite.cpp (contents, props changed)
vendor/compiler-rt/dist/test/cfi/simple-fail.cpp (contents, props changed)
vendor/compiler-rt/dist/test/cfi/simple-pass.cpp (contents, props changed)
vendor/compiler-rt/dist/test/cfi/utils.h (contents, props changed)
vendor/compiler-rt/dist/test/cfi/vdtor.cpp (contents, props changed)
vendor/compiler-rt/dist/test/tsan/signal_segv_handler.cc (contents, props changed)
Deleted:
vendor/compiler-rt/dist/lib/dfsan/Makefile.mk
vendor/compiler-rt/dist/lib/msan/Makefile.mk
vendor/compiler-rt/dist/lib/tsan/Makefile.mk
vendor/compiler-rt/dist/lib/tsan/rtl/Makefile.mk
Modified:
vendor/compiler-rt/dist/cmake/config-ix.cmake
vendor/compiler-rt/dist/lib/Makefile.mk
vendor/compiler-rt/dist/lib/asan/README.txt
vendor/compiler-rt/dist/lib/asan/asan_flags.cc
vendor/compiler-rt/dist/lib/asan/asan_flags.h
vendor/compiler-rt/dist/lib/asan/asan_flags.inc
vendor/compiler-rt/dist/lib/asan/asan_globals.cc
vendor/compiler-rt/dist/lib/asan/asan_interface_internal.h
vendor/compiler-rt/dist/lib/asan/asan_internal.h
vendor/compiler-rt/dist/lib/asan/asan_linux.cc
vendor/compiler-rt/dist/lib/asan/asan_mac.cc
vendor/compiler-rt/dist/lib/asan/asan_rtl.cc
vendor/compiler-rt/dist/lib/asan/asan_suppressions.cc
vendor/compiler-rt/dist/lib/asan/asan_win.cc
vendor/compiler-rt/dist/lib/asan/asan_win_dll_thunk.cc
vendor/compiler-rt/dist/lib/asan/asan_win_dynamic_runtime_thunk.cc
vendor/compiler-rt/dist/lib/asan/scripts/asan_device_setup
vendor/compiler-rt/dist/lib/asan/tests/asan_noinst_test.cc
vendor/compiler-rt/dist/lib/builtins/clear_cache.c
vendor/compiler-rt/dist/lib/dfsan/dfsan.cc
vendor/compiler-rt/dist/lib/lsan/Makefile.mk
vendor/compiler-rt/dist/lib/lsan/lsan.cc
vendor/compiler-rt/dist/lib/lsan/lsan_allocator.cc
vendor/compiler-rt/dist/lib/lsan/lsan_common.cc
vendor/compiler-rt/dist/lib/lsan/lsan_common.h
vendor/compiler-rt/dist/lib/lsan/lsan_flags.inc
vendor/compiler-rt/dist/lib/msan/msan.cc
vendor/compiler-rt/dist/lib/msan/tests/msan_test.cc
vendor/compiler-rt/dist/lib/sanitizer_common/CMakeLists.txt
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common.cc
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common.h
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common_libcdep.cc
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_common_syscalls.inc
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_coverage_libcdep.cc
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_flag_parser.h
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_flags.cc
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_flags.inc
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_internal_defs.h
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_libignore.cc
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_libignore.h
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_linux.cc
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_linux.h
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_linux_libcdep.cc
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_platform_interceptors.h
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_platform_limits_posix.h
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_posix.cc
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_suppressions.cc
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_suppressions.h
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_symbolizer_win.cc
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_syscall_generic.inc
vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_win.cc
vendor/compiler-rt/dist/lib/sanitizer_common/tests/sanitizer_linux_test.cc
vendor/compiler-rt/dist/lib/sanitizer_common/tests/sanitizer_suppressions_test.cc
vendor/compiler-rt/dist/lib/tsan/CMakeLists.txt
vendor/compiler-rt/dist/lib/tsan/dd/dd_rtl.cc
vendor/compiler-rt/dist/lib/tsan/go/build.bat
vendor/compiler-rt/dist/lib/tsan/go/buildgo.sh
vendor/compiler-rt/dist/lib/tsan/rtl/tsan_defs.h
vendor/compiler-rt/dist/lib/tsan/rtl/tsan_flags.cc
vendor/compiler-rt/dist/lib/tsan/rtl/tsan_flags.inc
vendor/compiler-rt/dist/lib/tsan/rtl/tsan_interceptors.cc
vendor/compiler-rt/dist/lib/tsan/rtl/tsan_interface_atomic.cc
vendor/compiler-rt/dist/lib/tsan/rtl/tsan_platform.h
vendor/compiler-rt/dist/lib/tsan/rtl/tsan_platform_linux.cc
vendor/compiler-rt/dist/lib/tsan/rtl/tsan_report.cc
vendor/compiler-rt/dist/lib/tsan/rtl/tsan_rtl.cc
vendor/compiler-rt/dist/lib/tsan/rtl/tsan_rtl.h
vendor/compiler-rt/dist/lib/tsan/rtl/tsan_rtl_report.cc
vendor/compiler-rt/dist/lib/tsan/rtl/tsan_rtl_thread.cc
vendor/compiler-rt/dist/lib/tsan/rtl/tsan_stat.cc
vendor/compiler-rt/dist/lib/tsan/rtl/tsan_suppressions.cc
vendor/compiler-rt/dist/lib/tsan/rtl/tsan_suppressions.h
vendor/compiler-rt/dist/lib/tsan/rtl/tsan_trace.h
vendor/compiler-rt/dist/lib/tsan/tests/CMakeLists.txt
vendor/compiler-rt/dist/lib/ubsan/CMakeLists.txt
vendor/compiler-rt/dist/lib/ubsan/ubsan_diag.cc
vendor/compiler-rt/dist/lib/ubsan/ubsan_diag.h
vendor/compiler-rt/dist/lib/ubsan/ubsan_flags.inc
vendor/compiler-rt/dist/lib/ubsan/ubsan_handlers.cc
vendor/compiler-rt/dist/lib/ubsan/ubsan_handlers_cxx.cc
vendor/compiler-rt/dist/lib/ubsan/ubsan_init.cc
vendor/compiler-rt/dist/make/platform/clang_linux.mk
vendor/compiler-rt/dist/test/CMakeLists.txt
vendor/compiler-rt/dist/test/asan/CMakeLists.txt
vendor/compiler-rt/dist/test/asan/TestCases/Windows/dll_host.cc
vendor/compiler-rt/dist/test/asan/TestCases/dlclose-test.cc
vendor/compiler-rt/dist/test/asan/TestCases/gc-test.cc
vendor/compiler-rt/dist/test/asan/lit.cfg
vendor/compiler-rt/dist/test/lit.common.cfg
vendor/compiler-rt/dist/test/lit.common.configured.in
vendor/compiler-rt/dist/test/lsan/lit.common.cfg
vendor/compiler-rt/dist/test/msan/mmap_below_shadow.cc
vendor/compiler-rt/dist/test/msan/strlen_of_shadow.cc
vendor/compiler-rt/dist/test/msan/vector_select.cc
vendor/compiler-rt/dist/test/sanitizer_common/TestCases/Linux/ptrace.cc
vendor/compiler-rt/dist/test/tsan/global_race.cc
vendor/compiler-rt/dist/test/tsan/global_race2.cc
vendor/compiler-rt/dist/test/tsan/global_race3.cc
vendor/compiler-rt/dist/test/tsan/map32bit.cc
vendor/compiler-rt/dist/test/tsan/mmap_large.cc
vendor/compiler-rt/dist/test/tsan/test.h
vendor/compiler-rt/dist/test/ubsan/TestCases/TypeCheck/Function/function.cpp
vendor/compiler-rt/dist/test/ubsan/TestCases/TypeCheck/null.cpp
vendor/compiler-rt/dist/test/ubsan/TestCases/TypeCheck/vptr-virtual-base.cpp
vendor/compiler-rt/dist/test/ubsan/TestCases/TypeCheck/vptr.cpp
Modified: vendor/compiler-rt/dist/cmake/config-ix.cmake
==============================================================================
--- vendor/compiler-rt/dist/cmake/config-ix.cmake Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/cmake/config-ix.cmake Sun Feb 22 22:43:40 2015 (r279192)
@@ -199,7 +199,7 @@ filter_available_targets(SANITIZER_COMMO
filter_available_targets(ASAN_SUPPORTED_ARCH
x86_64 i386 i686 powerpc64 powerpc64le arm mips mipsel mips64 mips64el)
filter_available_targets(DFSAN_SUPPORTED_ARCH x86_64 mips64 mips64el)
-filter_available_targets(LSAN_SUPPORTED_ARCH x86_64)
+filter_available_targets(LSAN_SUPPORTED_ARCH x86_64 mips64 mips64el)
# LSan common files should be available on all architectures supported
# by other sanitizers (even if they build into dummy object files).
filter_available_targets(LSAN_COMMON_SUPPORTED_ARCH
@@ -207,7 +207,7 @@ filter_available_targets(LSAN_COMMON_SUP
filter_available_targets(MSAN_SUPPORTED_ARCH x86_64 mips64 mips64el)
filter_available_targets(PROFILE_SUPPORTED_ARCH x86_64 i386 i686 arm mips mips64
mipsel mips64el aarch64 powerpc64 powerpc64le)
-filter_available_targets(TSAN_SUPPORTED_ARCH x86_64)
+filter_available_targets(TSAN_SUPPORTED_ARCH x86_64 mips64 mips64el)
filter_available_targets(UBSAN_SUPPORTED_ARCH x86_64 i386 i686 arm aarch64 mips mipsel mips64 mips64el)
if(ANDROID)
Modified: vendor/compiler-rt/dist/lib/Makefile.mk
==============================================================================
--- vendor/compiler-rt/dist/lib/Makefile.mk Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/Makefile.mk Sun Feb 22 22:43:40 2015 (r279192)
@@ -12,11 +12,8 @@ SubDirs :=
# Add submodules.
SubDirs += asan
SubDirs += builtins
-SubDirs += dfsan
SubDirs += interception
SubDirs += lsan
-SubDirs += msan
SubDirs += profile
SubDirs += sanitizer_common
-SubDirs += tsan
SubDirs += ubsan
Modified: vendor/compiler-rt/dist/lib/asan/README.txt
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/README.txt Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/asan/README.txt Sun Feb 22 22:43:40 2015 (r279192)
@@ -1,7 +1,6 @@
AddressSanitizer RT
================================
-This directory contains sources of the AddressSanitizer (asan) runtime library.
-We are in the process of integrating AddressSanitizer with LLVM, stay tuned.
+This directory contains sources of the AddressSanitizer (ASan) runtime library.
Directory structure:
README.txt : This file.
@@ -13,14 +12,13 @@ tests/* : ASan unit tests.
Also ASan runtime needs the following libraries:
lib/interception/ : Machinery used to intercept function calls.
-lib/sanitizer_common/ : Code shared between ASan and TSan.
+lib/sanitizer_common/ : Code shared between various sanitizers.
-Currently ASan runtime can be built by both make and cmake build systems.
-(see compiler-rt/make and files Makefile.mk for make-based build and
-files CMakeLists.txt for cmake-based build).
+ASan runtime currently also embeds part of LeakSanitizer runtime for
+leak detection (lib/lsan/lsan_common.{cc,h}).
-ASan unit and output tests work only with cmake. You may run this
-command from the root of your cmake build tree:
+ASan runtime can only be built by CMake. You can run ASan tests
+from the root of your CMake build tree:
make check-asan
Modified: vendor/compiler-rt/dist/lib/asan/asan_flags.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_flags.cc Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/asan/asan_flags.cc Sun Feb 22 22:43:40 2015 (r279192)
@@ -46,18 +46,15 @@ void Flags::SetDefaults() {
#undef ASAN_FLAG
}
-void RegisterAsanFlags(FlagParser *parser, Flags *f) {
+static void RegisterAsanFlags(FlagParser *parser, Flags *f) {
#define ASAN_FLAG(Type, Name, DefaultValue, Description) \
RegisterFlag(parser, #Name, Description, &f->Name);
#include "asan_flags.inc"
#undef ASAN_FLAG
}
-void InitializeFlags(Flags *f) {
- FlagParser parser;
- RegisterAsanFlags(&parser, f);
- RegisterCommonFlags(&parser);
-
+void InitializeFlags() {
+ // Set the default values and prepare for parsing ASan and common flags.
SetCommonFlagsDefaults();
{
CommonFlags cf;
@@ -68,28 +65,44 @@ void InitializeFlags(Flags *f) {
cf.intercept_tls_get_addr = true;
OverrideCommonFlags(cf);
}
-
- const int kDefaultQuarantineSizeMb = (ASAN_LOW_MEMORY) ? 1UL << 6 : 1UL << 8;
+ Flags *f = flags();
f->SetDefaults();
- // Override from compile definition.
- const char *compile_def = MaybeUseAsanDefaultOptionsCompileDefinition();
- parser.ParseString(compile_def);
+ FlagParser asan_parser;
+ RegisterAsanFlags(&asan_parser, f);
+ RegisterCommonFlags(&asan_parser);
+
+ // Set the default values and prepare for parsing LSan flags (which can also
+ // overwrite common flags).
+#if CAN_SANITIZE_LEAKS
+ __lsan::Flags *lf = __lsan::flags();
+ lf->SetDefaults();
+
+ FlagParser lsan_parser;
+ __lsan::RegisterLsanFlags(&lsan_parser, lf);
+ RegisterCommonFlags(&lsan_parser);
+#endif
+
+ // Override from ASan compile definition.
+ const char *asan_compile_def = MaybeUseAsanDefaultOptionsCompileDefinition();
+ asan_parser.ParseString(asan_compile_def);
// Override from user-specified string.
- const char *default_options = MaybeCallAsanDefaultOptions();
- parser.ParseString(default_options);
+ const char *asan_default_options = MaybeCallAsanDefaultOptions();
+ asan_parser.ParseString(asan_default_options);
// Override from command line.
- const char *env = GetEnv("ASAN_OPTIONS");
- if (env) parser.ParseString(env);
+ asan_parser.ParseString(GetEnv("ASAN_OPTIONS"));
+#if CAN_SANITIZE_LEAKS
+ lsan_parser.ParseString(GetEnv("LSAN_OPTIONS"));
+#endif
// Let activation flags override current settings. On Android they come
// from a system property. On other platforms this is no-op.
if (!flags()->start_deactivated) {
char buf[100];
GetExtraActivationFlags(buf, sizeof(buf));
- parser.ParseString(buf);
+ asan_parser.ParseString(buf);
}
SetVerbosity(common_flags()->verbosity);
@@ -97,7 +110,10 @@ void InitializeFlags(Flags *f) {
// TODO(eugenis): dump all flags at verbosity>=2?
if (Verbosity()) ReportUnrecognizedFlags();
- if (common_flags()->help) parser.PrintFlagDescriptions();
+ if (common_flags()->help) {
+ // TODO(samsonov): print all of the flags (ASan, LSan, common).
+ asan_parser.PrintFlagDescriptions();
+ }
// Flag validation:
if (!CAN_SANITIZE_LEAKS && common_flags()->detect_leaks) {
@@ -127,8 +143,11 @@ void InitializeFlags(Flags *f) {
}
if (f->quarantine_size >= 0)
f->quarantine_size_mb = f->quarantine_size >> 20;
- if (f->quarantine_size_mb < 0)
+ if (f->quarantine_size_mb < 0) {
+ const int kDefaultQuarantineSizeMb =
+ (ASAN_LOW_MEMORY) ? 1UL << 6 : 1UL << 8;
f->quarantine_size_mb = kDefaultQuarantineSizeMb;
+ }
}
} // namespace __asan
Modified: vendor/compiler-rt/dist/lib/asan/asan_flags.h
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_flags.h Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/asan/asan_flags.h Sun Feb 22 22:43:40 2015 (r279192)
@@ -41,8 +41,8 @@ extern Flags asan_flags_dont_use_directl
inline Flags *flags() {
return &asan_flags_dont_use_directly;
}
-void RegisterAsanFlags(FlagParser *parser, Flags *f);
-void InitializeFlags(Flags *f);
+
+void InitializeFlags();
} // namespace __asan
Modified: vendor/compiler-rt/dist/lib/asan/asan_flags.inc
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_flags.inc Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/asan/asan_flags.inc Sun Feb 22 22:43:40 2015 (r279192)
@@ -142,3 +142,4 @@ ASAN_FLAG(int, detect_odr_violation, 2,
"have different sizes")
ASAN_FLAG(bool, dump_instruction_bytes, false,
"If true, dump 16 bytes starting at the instruction that caused SEGV")
+ASAN_FLAG(const char *, suppressions, "", "Suppressions file name.")
Modified: vendor/compiler-rt/dist/lib/asan/asan_globals.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_globals.cc Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/asan/asan_globals.cc Sun Feb 22 22:43:40 2015 (r279192)
@@ -182,6 +182,8 @@ static void RegisterGlobal(const Global
static void UnregisterGlobal(const Global *g) {
CHECK(asan_inited);
+ if (flags()->report_globals >= 2)
+ ReportGlobal(*g, "Removed");
CHECK(flags()->report_globals);
CHECK(AddrIsInMem(g->beg));
CHECK(AddrIsAlignedByGranularity(g->beg));
@@ -208,6 +210,20 @@ void StopInitOrderChecking() {
}
}
+#if SANITIZER_WINDOWS // Should only be called on Windows.
+SANITIZER_INTERFACE_ATTRIBUTE
+void UnregisterGlobalsInRange(void *beg, void *end) {
+ if (!flags()->report_globals)
+ return;
+ BlockingMutexLock lock(&mu_for_globals);
+ for (ListOfGlobals *l = list_of_all_globals; l; l = l->next) {
+ void *address = (void *)l->g->beg;
+ if (beg <= address && address < end)
+ UnregisterGlobal(l->g);
+ }
+}
+#endif
+
} // namespace __asan
// ---------------------- Interface ---------------- {{{1
Modified: vendor/compiler-rt/dist/lib/asan/asan_interface_internal.h
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_interface_internal.h Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/asan/asan_interface_internal.h Sun Feb 22 22:43:40 2015 (r279192)
@@ -9,8 +9,11 @@
//
// This file is a part of AddressSanitizer, an address sanity checker.
//
-// This header can be included by the instrumented program to fetch
-// data (mostly allocator statistics) from ASan runtime library.
+// This header declares the AddressSanitizer runtime interface functions.
+// The runtime library has to define these functions so the instrumented program
+// could call them.
+//
+// See also include/sanitizer/asan_interface.h
//===----------------------------------------------------------------------===//
#ifndef ASAN_INTERFACE_INTERNAL_H
#define ASAN_INTERFACE_INTERNAL_H
Modified: vendor/compiler-rt/dist/lib/asan/asan_internal.h
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_internal.h Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/asan/asan_internal.h Sun Feb 22 22:43:40 2015 (r279192)
@@ -93,6 +93,7 @@ void AsanCheckIncompatibleRT();
void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp);
void AsanOnSIGSEGV(int, void *siginfo, void *context);
+void DisableReexec();
void MaybeReexec();
void ReadContextStack(void *context, uptr *stack, uptr *ssize);
void AsanPlatformThreadInit();
Modified: vendor/compiler-rt/dist/lib/asan/asan_linux.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_linux.cc Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/asan/asan_linux.cc Sun Feb 22 22:43:40 2015 (r279192)
@@ -68,6 +68,10 @@ asan_rt_version_t __asan_rt_version;
namespace __asan {
+void DisableReexec() {
+ // No need to re-exec on Linux.
+}
+
void MaybeReexec() {
// No need to re-exec on Linux.
}
Modified: vendor/compiler-rt/dist/lib/asan/asan_mac.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_mac.cc Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/asan/asan_mac.cc Sun Feb 22 22:43:40 2015 (r279192)
@@ -101,7 +101,15 @@ void LeakyResetEnv(const char *name, con
}
}
+static bool reexec_disabled = false;
+
+void DisableReexec() {
+ reexec_disabled = true;
+}
+
void MaybeReexec() {
+ if (reexec_disabled) return;
+
// Make sure the dynamic ASan runtime library is preloaded so that the
// wrappers work. If it is not, set DYLD_INSERT_LIBRARIES and re-exec
// ourselves.
Modified: vendor/compiler-rt/dist/lib/asan/asan_rtl.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_rtl.cc Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/asan/asan_rtl.cc Sun Feb 22 22:43:40 2015 (r279192)
@@ -314,7 +314,7 @@ static void AsanInitInternal() {
// Initialize flags. This must be done early, because most of the
// initialization steps look at flags().
- InitializeFlags(flags());
+ InitializeFlags();
SetCanPoisonMemory(flags()->poison_heap);
SetMallocContextSize(common_flags()->malloc_context_size);
@@ -440,7 +440,7 @@ static void AsanInitInternal() {
SanitizerInitializeUnwinder();
#if CAN_SANITIZE_LEAKS
- __lsan::InitCommonLsan(false);
+ __lsan::InitCommonLsan();
if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit) {
Atexit(__lsan::DoLeakCheck);
}
Modified: vendor/compiler-rt/dist/lib/asan/asan_suppressions.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_suppressions.cc Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/asan/asan_suppressions.cc Sun Feb 22 22:43:40 2015 (r279192)
@@ -15,57 +15,62 @@
#include "asan_suppressions.h"
#include "asan_stack.h"
+#include "sanitizer_common/sanitizer_placement_new.h"
#include "sanitizer_common/sanitizer_suppressions.h"
#include "sanitizer_common/sanitizer_symbolizer.h"
namespace __asan {
-static bool suppressions_inited = false;
+ALIGNED(64) static char suppression_placeholder[sizeof(SuppressionContext)];
+static SuppressionContext *suppression_ctx = nullptr;
+static const char kInterceptorName[] = "interceptor_name";
+static const char kInterceptorViaFunction[] = "interceptor_via_fun";
+static const char kInterceptorViaLibrary[] = "interceptor_via_lib";
+static const char *kSuppressionTypes[] = {
+ kInterceptorName, kInterceptorViaFunction, kInterceptorViaLibrary};
void InitializeSuppressions() {
- CHECK(!suppressions_inited);
- SuppressionContext::InitIfNecessary();
- suppressions_inited = true;
+ CHECK_EQ(nullptr, suppression_ctx);
+ suppression_ctx = new (suppression_placeholder) // NOLINT
+ SuppressionContext(kSuppressionTypes, ARRAY_SIZE(kSuppressionTypes));
+ suppression_ctx->ParseFromFile(flags()->suppressions);
}
bool IsInterceptorSuppressed(const char *interceptor_name) {
- CHECK(suppressions_inited);
- SuppressionContext *ctx = SuppressionContext::Get();
+ CHECK(suppression_ctx);
Suppression *s;
// Match "interceptor_name" suppressions.
- return ctx->Match(interceptor_name, SuppressionInterceptorName, &s);
+ return suppression_ctx->Match(interceptor_name, kInterceptorName, &s);
}
bool HaveStackTraceBasedSuppressions() {
- CHECK(suppressions_inited);
- SuppressionContext *ctx = SuppressionContext::Get();
- return ctx->HasSuppressionType(SuppressionInterceptorViaFunction) ||
- ctx->HasSuppressionType(SuppressionInterceptorViaLibrary);
+ CHECK(suppression_ctx);
+ return suppression_ctx->HasSuppressionType(kInterceptorViaFunction) ||
+ suppression_ctx->HasSuppressionType(kInterceptorViaLibrary);
}
bool IsStackTraceSuppressed(const StackTrace *stack) {
- CHECK(suppressions_inited);
if (!HaveStackTraceBasedSuppressions())
return false;
- SuppressionContext *ctx = SuppressionContext::Get();
+ CHECK(suppression_ctx);
Symbolizer *symbolizer = Symbolizer::GetOrInit();
Suppression *s;
for (uptr i = 0; i < stack->size && stack->trace[i]; i++) {
uptr addr = stack->trace[i];
- if (ctx->HasSuppressionType(SuppressionInterceptorViaLibrary)) {
+ if (suppression_ctx->HasSuppressionType(kInterceptorViaLibrary)) {
const char *module_name;
uptr module_offset;
// Match "interceptor_via_lib" suppressions.
if (symbolizer->GetModuleNameAndOffsetForPC(addr, &module_name,
&module_offset) &&
- ctx->Match(module_name, SuppressionInterceptorViaLibrary, &s)) {
+ suppression_ctx->Match(module_name, kInterceptorViaLibrary, &s)) {
return true;
}
}
- if (ctx->HasSuppressionType(SuppressionInterceptorViaFunction)) {
+ if (suppression_ctx->HasSuppressionType(kInterceptorViaFunction)) {
SymbolizedStack *frames = symbolizer->SymbolizePC(addr);
for (SymbolizedStack *cur = frames; cur; cur = cur->next) {
const char *function_name = cur->info.function;
@@ -73,7 +78,8 @@ bool IsStackTraceSuppressed(const StackT
continue;
}
// Match "interceptor_via_fun" suppressions.
- if (ctx->Match(function_name, SuppressionInterceptorViaFunction, &s)) {
+ if (suppression_ctx->Match(function_name, kInterceptorViaFunction,
+ &s)) {
frames->ClearAll();
return true;
}
Modified: vendor/compiler-rt/dist/lib/asan/asan_win.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_win.cc Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/asan/asan_win.cc Sun Feb 22 22:43:40 2015 (r279192)
@@ -60,6 +60,10 @@ void PlatformTSDDtor(void *tsd) {
AsanThread::TSDDtor(tsd);
}
// ---------------------- Various stuff ---------------- {{{1
+void DisableReexec() {
+ // No need to re-exec on Windows.
+}
+
void MaybeReexec() {
// No need to re-exec on Windows.
}
Modified: vendor/compiler-rt/dist/lib/asan/asan_win_dll_thunk.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_win_dll_thunk.cc Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/asan/asan_win_dll_thunk.cc Sun Feb 22 22:43:40 2015 (r279192)
@@ -294,7 +294,43 @@ INTERFACE_FUNCTION(__asan_stack_free_8)
INTERFACE_FUNCTION(__asan_stack_free_9)
INTERFACE_FUNCTION(__asan_stack_free_10)
+// FIXME: we might want to have a sanitizer_win_dll_thunk?
+INTERFACE_FUNCTION(__sanitizer_annotate_contiguous_container)
+INTERFACE_FUNCTION(__sanitizer_cov)
+INTERFACE_FUNCTION(__sanitizer_cov_dump)
+INTERFACE_FUNCTION(__sanitizer_cov_indir_call16)
+INTERFACE_FUNCTION(__sanitizer_cov_init)
INTERFACE_FUNCTION(__sanitizer_cov_module_init)
+INTERFACE_FUNCTION(__sanitizer_cov_trace_basic_block)
+INTERFACE_FUNCTION(__sanitizer_cov_trace_func_enter)
+INTERFACE_FUNCTION(__sanitizer_cov_with_check)
+INTERFACE_FUNCTION(__sanitizer_free_hook)
+INTERFACE_FUNCTION(__sanitizer_get_allocated_size)
+INTERFACE_FUNCTION(__sanitizer_get_coverage_guards)
+INTERFACE_FUNCTION(__sanitizer_get_current_allocated_bytes)
+INTERFACE_FUNCTION(__sanitizer_get_estimated_allocated_size)
+INTERFACE_FUNCTION(__sanitizer_get_free_bytes)
+INTERFACE_FUNCTION(__sanitizer_get_heap_size)
+INTERFACE_FUNCTION(__sanitizer_get_ownership)
+INTERFACE_FUNCTION(__sanitizer_get_total_unique_coverage)
+INTERFACE_FUNCTION(__sanitizer_get_unmapped_bytes)
+INTERFACE_FUNCTION(__sanitizer_malloc_hook)
+INTERFACE_FUNCTION(__sanitizer_maybe_open_cov_file)
+INTERFACE_FUNCTION(__sanitizer_print_stack_trace)
+INTERFACE_FUNCTION(__sanitizer_ptr_cmp)
+INTERFACE_FUNCTION(__sanitizer_ptr_sub)
+INTERFACE_FUNCTION(__sanitizer_report_error_summary)
+INTERFACE_FUNCTION(__sanitizer_reset_coverage)
+INTERFACE_FUNCTION(__sanitizer_sandbox_on_notify)
+INTERFACE_FUNCTION(__sanitizer_set_death_callback)
+INTERFACE_FUNCTION(__sanitizer_set_report_path)
+INTERFACE_FUNCTION(__sanitizer_unaligned_load16)
+INTERFACE_FUNCTION(__sanitizer_unaligned_load32)
+INTERFACE_FUNCTION(__sanitizer_unaligned_load64)
+INTERFACE_FUNCTION(__sanitizer_unaligned_store16)
+INTERFACE_FUNCTION(__sanitizer_unaligned_store32)
+INTERFACE_FUNCTION(__sanitizer_unaligned_store64)
+INTERFACE_FUNCTION(__sanitizer_verify_contiguous_container)
// TODO(timurrrr): Add more interface functions on the as-needed basis.
Modified: vendor/compiler-rt/dist/lib/asan/asan_win_dynamic_runtime_thunk.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/asan_win_dynamic_runtime_thunk.cc Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/asan/asan_win_dynamic_runtime_thunk.cc Sun Feb 22 22:43:40 2015 (r279192)
@@ -23,10 +23,11 @@
// Using #ifdef rather than relying on Makefiles etc.
// simplifies the build procedure.
#ifdef ASAN_DYNAMIC_RUNTIME_THUNK
-extern "C" {
-__declspec(dllimport) int __asan_set_seh_filter();
-__declspec(dllimport) int __asan_should_detect_stack_use_after_return();
+#include <windows.h>
+#include <psapi.h>
+extern "C" {
+////////////////////////////////////////////////////////////////////////////////
// Define a copy of __asan_option_detect_stack_use_after_return that should be
// used when linking an MD runtime with a set of object files on Windows.
//
@@ -37,16 +38,82 @@ __declspec(dllimport) int __asan_should_
// with a MT or MD runtime and we don't want to use ugly __imp_ names on Windows
// just to work around this issue, let's clone the a variable that is
// constant after initialization anyways.
+__declspec(dllimport) int __asan_should_detect_stack_use_after_return();
int __asan_option_detect_stack_use_after_return =
__asan_should_detect_stack_use_after_return();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// For some reason, the MD CRT doesn't call the C/C++ terminators as MT does.
+// To work around this, for each DLL we schedule a call to
+// UnregisterGlobalsInRange atexit() specifying the address range of the DLL
+// image to unregister globals in that range. We don't do the same
+// for the main module (.exe) as the asan_globals.cc allocator is destroyed
+// by the time UnregisterGlobalsInRange is executed.
+// See PR22545 for the details.
+namespace __asan {
+__declspec(dllimport)
+void UnregisterGlobalsInRange(void *beg, void *end);
+}
+
+namespace {
+void *this_module_base, *this_module_end;
+
+void UnregisterGlobals() {
+ __asan::UnregisterGlobalsInRange(this_module_base, this_module_end);
+}
+
+int ScheduleUnregisterGlobals() {
+ HMODULE this_module = 0;
+ // Increments the reference counter of the DLL module, so need to call
+ // FreeLibrary later.
+ if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
+ (LPCTSTR)&UnregisterGlobals, &this_module))
+ return 1;
+
+ // Skip the main module.
+ if (this_module == GetModuleHandle(0))
+ return 0;
+
+ MODULEINFO mi;
+ bool success =
+ GetModuleInformation(GetCurrentProcess(), this_module, &mi, sizeof(mi));
+ if (!FreeLibrary(this_module))
+ return 2;
+ if (!success)
+ return 3;
-// Set the ASan-specific SEH handler at the end of CRT initialization of each
-// module (see asan_win.cc for the details).
+ this_module_base = mi.lpBaseOfDll;
+ this_module_end = (char*)mi.lpBaseOfDll + mi.SizeOfImage;
+
+ return atexit(UnregisterGlobals);
+}
+} // namespace
+
+///////////////////////////////////////////////////////////////////////////////
+// ASan SEH handling.
+extern "C" __declspec(dllimport) int __asan_set_seh_filter();
+static int SetSEHFilter() { return __asan_set_seh_filter(); }
+
+///////////////////////////////////////////////////////////////////////////////
+// We schedule some work at start-up by placing callbacks to our code to the
+// list of CRT C initializers.
+//
+// First, declare sections we'll be using:
+#pragma section(".CRT$XID", long, read) // NOLINT
+#pragma section(".CRT$XIZ", long, read) // NOLINT
+
+// We need to call 'atexit(UnregisterGlobals);' after atexit() is initialized
+// (.CRT$XIC) but before the C++ constructors (.CRT$XCA).
+__declspec(allocate(".CRT$XID"))
+static int (*__asan_schedule_unregister_globals)() = ScheduleUnregisterGlobals;
+
+// We need to set the ASan-specific SEH handler at the end of CRT initialization
+// of each module (see also asan_win.cc).
//
// Unfortunately, putting a pointer to __asan_set_seh_filter into
// __asan_intercept_seh gets optimized out, so we have to use an extra function.
-static int SetSEHFilter() { return __asan_set_seh_filter(); }
-#pragma section(".CRT$XIZ", long, read) // NOLINT
-__declspec(allocate(".CRT$XIZ")) int (*__asan_seh_interceptor)() = SetSEHFilter;
-}
+extern "C" __declspec(allocate(".CRT$XIZ"))
+int (*__asan_seh_interceptor)() = SetSEHFilter;
+
#endif // ASAN_DYNAMIC_RUNTIME_THUNK
Modified: vendor/compiler-rt/dist/lib/asan/scripts/asan_device_setup
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/scripts/asan_device_setup Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/asan/scripts/asan_device_setup Sun Feb 22 22:43:40 2015 (r279192)
@@ -18,6 +18,7 @@ revert=no
extra_options=
device=
lib=
+use_su=0
function usage {
echo "usage: $0 [--revert] [--device device-id] [--lib path] [--extra-options options]"
@@ -26,13 +27,70 @@ function usage {
echo " --extra-options: Extra ASAN_OPTIONS."
echo " --device: Install to the given device. Use 'adb devices' to find"
echo " device-id."
+ echo " --use-su: Use 'su -c' prefix for every adb command instead of using"
+ echo " 'adb root' once."
echo
exit 1
}
+function adb_push {
+ if [ $use_su -eq 0 ]; then
+ $ADB push "$1" "$2"
+ else
+ local FILENAME=$(basename $1)
+ $ADB push "$1" "/data/local/tmp/$FILENAME"
+ $ADB shell su -c "rm \\\"$2/$FILENAME\\\"" >&/dev/null
+ $ADB shell su -c "cat \\\"/data/local/tmp/$FILENAME\\\" > \\\"$2/$FILENAME\\\""
+ $ADB shell su -c "rm \\\"/data/local/tmp/$FILENAME\\\""
+ fi
+}
+
+function adb_remount {
+ if [ $use_su -eq 0 ]; then
+ $ADB remount
+ else
+ local STORAGE=`$ADB shell mount | grep /system | cut -d ' ' -f1`
+ if [ "$STORAGE" != "" ]; then
+ echo Remounting $STORAGE at /system
+ $ADB shell su -c "mount -o remount,rw $STORAGE /system"
+ else
+ echo Failed to get storage device name for "/system" mount point
+ fi
+ fi
+}
+
+function adb_shell {
+ if [ $use_su -eq 0 ]; then
+ $ADB shell $@
+ else
+ $ADB shell su -c "$*"
+ fi
+}
+
+function adb_root {
+ if [ $use_su -eq 0 ]; then
+ $ADB root
+ fi
+}
+
+function adb_wait_for_device {
+ $ADB wait-for-device
+}
+
+function adb_pull {
+ if [ $use_su -eq 0 ]; then
+ $ADB pull "$1" "$2"
+ else
+ local FILENAME=$(basename $1)
+ $ADB shell rm "/data/local/tmp/$FILENAME" >&/dev/null
+ $ADB shell su -c "[ -f \\\"$1\\\" ] && cat \\\"$1\\\" > \\\"/data/local/tmp/$FILENAME\\\" && chown root.shell \\\"/data/local/tmp/$FILENAME\\\" && chmod 755 \\\"/data/local/tmp/$FILENAME\\\"" &&
+ $ADB pull "/data/local/tmp/$FILENAME" "$2" >&/dev/null && $ADB shell "rm \"/data/local/tmp/$FILENAME\""
+ fi
+}
+
function get_device_arch { # OUTVAR
local _outvar=$1
- local _ABI=$($ADB shell getprop ro.product.cpu.abi)
+ local _ABI=$(adb_shell getprop ro.product.cpu.abi)
local _ARCH=
if [[ $_ABI == x86* ]]; then
_ARCH=i686
@@ -74,6 +132,9 @@ while [[ $# > 0 ]]; do
fi
device="$1"
;;
+ --use-su)
+ use_su=1
+ ;;
*)
usage
;;
@@ -86,12 +147,25 @@ if [[ x$device != x ]]; then
ADB="$ADB -s $device"
fi
+if [ $use_su -eq 1 ]; then
+ # Test if 'su' is present on the device
+ SU_TEST_OUT=`$ADB shell su -c "echo foo" 2>&1 | sed 's/\r$//'`
+ if [ $? != 0 -o "$SU_TEST_OUT" != "foo" ]; then
+ echo "ERROR: Cannot use 'su -c':"
+ echo "$ adb shell su -c \"echo foo\""
+ echo $SU_TEST_OUT
+ echo "Check that 'su' binary is correctly installed on the device or omit"
+ echo " --use-su flag"
+ exit 1
+ fi
+fi
+
echo '>> Remounting /system rw'
-$ADB wait-for-device
-$ADB root
-$ADB wait-for-device
-$ADB remount
-$ADB wait-for-device
+adb_wait_for_device
+adb_root
+adb_wait_for_device
+adb_remount
+adb_wait_for_device
get_device_arch ARCH
echo "Target architecture: $ARCH"
@@ -100,22 +174,24 @@ ASAN_RT="libclang_rt.asan-$ARCH-android.
if [[ x$revert == xyes ]]; then
echo '>> Uninstalling ASan'
- if ! $ADB shell readlink /system/bin/app_process | grep 'app_process' >&/dev/null; then
+ if ! adb_shell ls -l /system/bin/app_process | grep -o '\->.*app_process' >&/dev/null; then
echo '>> Pre-L device detected.'
- $ADB shell mv /system/bin/app_process.real /system/bin/app_process
- $ADB shell rm /system/bin/asanwrapper
- $ADB shell rm /system/lib/$ASAN_RT
+ adb_shell mv /system/bin/app_process.real /system/bin/app_process
+ adb_shell rm /system/bin/asanwrapper
else
- $ADB shell rm /system/bin/app_process.wrap
- $ADB shell rm /system/bin/asanwrapper
- $ADB shell rm /system/lib/$ASAN_RT
- $ADB shell rm /system/bin/app_process
- $ADB shell ln -s /system/bin/app_process32 /system/bin/app_process
+ adb_shell rm /system/bin/app_process.wrap
+ adb_shell rm /system/bin/asanwrapper
+ adb_shell rm /system/bin/app_process
+ adb_shell ln -s /system/bin/app_process32 /system/bin/app_process
fi
echo '>> Restarting shell'
- $ADB shell stop
- $ADB shell start
+ adb_shell stop
+ adb_shell start
+
+ # Remove the library on the last step to give a chance to the 'su' binary to
+ # be executed without problem.
+ adb_shell rm /system/lib/$ASAN_RT
echo '>> Done'
exit 0
@@ -146,28 +222,28 @@ TMPDIROLD="$TMPDIRBASE/old"
TMPDIR="$TMPDIRBASE/new"
mkdir "$TMPDIROLD"
-RELEASE=$($ADB shell getprop ro.build.version.release)
+RELEASE=$(adb_shell getprop ro.build.version.release)
PRE_L=0
if echo "$RELEASE" | grep '^4\.' >&/dev/null; then
PRE_L=1
fi
-if ! $ADB shell readlink /system/bin/app_process | grep 'app_process' >&/dev/null; then
+if ! adb_shell ls -l /system/bin/app_process | grep -o '\->.*app_process' >&/dev/null; then
- if $ADB pull /system/bin/app_process.real /dev/null >&/dev/null; then
+ if adb_pull /system/bin/app_process.real /dev/null >&/dev/null; then
echo '>> Old-style ASan installation detected. Reverting.'
- $ADB shell mv /system/bin/app_process.real /system/bin/app_process
+ adb_shell mv /system/bin/app_process.real /system/bin/app_process
fi
echo '>> Pre-L device detected. Setting up app_process symlink.'
- $ADB shell mv /system/bin/app_process /system/bin/app_process32
- $ADB shell ln -s /system/bin/app_process32 /system/bin/app_process
+ adb_shell mv /system/bin/app_process /system/bin/app_process32
+ adb_shell ln -s /system/bin/app_process32 /system/bin/app_process
fi
echo '>> Copying files from the device'
-$ADB pull /system/bin/app_process.wrap "$TMPDIROLD" || true
-$ADB pull /system/bin/asanwrapper "$TMPDIROLD" || true
-$ADB pull /system/lib/"$ASAN_RT" "$TMPDIROLD" || true
+adb_pull /system/bin/app_process.wrap "$TMPDIROLD" || true
+adb_pull /system/bin/asanwrapper "$TMPDIROLD" || true
+adb_pull /system/lib/"$ASAN_RT" "$TMPDIROLD" || true
cp -r "$TMPDIROLD" "$TMPDIR"
if [[ -f "$TMPDIR/app_process.wrap" ]]; then
@@ -213,52 +289,52 @@ EOF
if ! ( cd "$TMPDIRBASE" && diff -qr old/ new/ ) ; then
echo '>> Pushing files to the device'
- $ADB push "$TMPDIR/$ASAN_RT" /system/lib/
- $ADB push "$TMPDIR/app_process.wrap" /system/bin/app_process.wrap
- $ADB push "$TMPDIR/asanwrapper" /system/bin/asanwrapper
+ adb_push "$TMPDIR/$ASAN_RT" /system/lib/
+ adb_push "$TMPDIR/app_process.wrap" /system/bin
+ adb_push "$TMPDIR/asanwrapper" /system/bin
- $ADB shell rm /system/bin/app_process
- $ADB shell ln -s /system/bin/app_process.wrap /system/bin/app_process
+ adb_shell rm /system/bin/app_process
+ adb_shell ln -s /system/bin/app_process.wrap /system/bin/app_process
- $ADB shell chown root.shell \
+ adb_shell chown root.shell \
/system/lib/"$ASAN_RT" \
/system/bin/app_process.wrap \
/system/bin/asanwrapper
- $ADB shell chmod 644 \
+ adb_shell chmod 644 \
/system/lib/"$ASAN_RT"
- $ADB shell chmod 755 \
+ adb_shell chmod 755 \
/system/bin/app_process.wrap \
/system/bin/asanwrapper
# Make SELinux happy by keeping app_process wrapper and the shell
# it runs on in zygote domain.
ENFORCING=0
- if $ADB shell getenforce | grep Enforcing >/dev/null; then
+ if adb_shell getenforce | grep Enforcing >/dev/null; then
# Sometimes shell is not allowed to change file contexts.
# Temporarily switch to permissive.
ENFORCING=1
- $ADB shell setenforce 0
+ adb_shell setenforce 0
fi
- $ADB shell cp /system/bin/sh /system/bin/sh-from-zygote
+ adb_shell cp /system/bin/sh /system/bin/sh-from-zygote
if [[ PRE_L -eq 1 ]]; then
CTX=u:object_r:system_file:s0
else
CTX=u:object_r:zygote_exec:s0
fi
- $ADB shell chcon $CTX \
+ adb_shell chcon $CTX \
/system/bin/sh-from-zygote \
/system/bin/app_process.wrap \
/system/bin/app_process32
if [ $ENFORCING == 1 ]; then
- $ADB shell setenforce 1
+ adb_shell setenforce 1
fi
echo '>> Restarting shell (asynchronous)'
- $ADB shell stop
- $ADB shell start
+ adb_shell stop
+ adb_shell start
echo '>> Please wait until the device restarts'
else
Modified: vendor/compiler-rt/dist/lib/asan/tests/asan_noinst_test.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/asan/tests/asan_noinst_test.cc Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/asan/tests/asan_noinst_test.cc Sun Feb 22 22:43:40 2015 (r279192)
@@ -33,7 +33,10 @@
// Make sure __asan_init is called before any test case is run.
struct AsanInitCaller {
- AsanInitCaller() { __asan_init(); }
+ AsanInitCaller() {
+ __asan::DisableReexec();
+ __asan_init();
+ }
};
static AsanInitCaller asan_init_caller;
Modified: vendor/compiler-rt/dist/lib/builtins/clear_cache.c
==============================================================================
--- vendor/compiler-rt/dist/lib/builtins/clear_cache.c Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/builtins/clear_cache.c Sun Feb 22 22:43:40 2015 (r279192)
@@ -22,10 +22,10 @@
#include <machine/sysarch.h>
#endif
-#if defined(__ANDROID__) && defined(__mips__)
+#if defined(__mips__)
#include <sys/cachectl.h>
#include <sys/syscall.h>
- #ifdef __LP64__
+ #if defined(__ANDROID__) && defined(__LP64__)
/*
* clear_mips_cache - Invalidates instruction cache for Mips.
*/
@@ -109,10 +109,10 @@ void __clear_cache(void *start, void *en
#else
compilerrt_abort();
#endif
-#elif defined(__ANDROID__) && defined(__mips__)
+#elif defined(__mips__)
const uintptr_t start_int = (uintptr_t) start;
const uintptr_t end_int = (uintptr_t) end;
- #ifdef __LP64__
+ #if defined(__ANDROID__) && defined(__LP64__)
// Call synci implementation for short address range.
const uintptr_t address_range_limit = 256;
if ((end_int - start_int) <= address_range_limit) {
Modified: vendor/compiler-rt/dist/lib/dfsan/dfsan.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/dfsan/dfsan.cc Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/dfsan/dfsan.cc Sun Feb 22 22:43:40 2015 (r279192)
@@ -317,18 +317,18 @@ void Flags::SetDefaults() {
#undef DFSAN_FLAG
}
-void RegisterDfsanFlags(FlagParser *parser, Flags *f) {
+static void RegisterDfsanFlags(FlagParser *parser, Flags *f) {
#define DFSAN_FLAG(Type, Name, DefaultValue, Description) \
RegisterFlag(parser, #Name, Description, &f->Name);
#include "dfsan_flags.inc"
#undef DFSAN_FLAG
}
-static void InitializeFlags(Flags &f, const char *env) {
+static void InitializeFlags() {
FlagParser parser;
- RegisterDfsanFlags(&parser, &f);
- f.SetDefaults();
- parser.ParseString(env);
+ RegisterDfsanFlags(&parser, &flags());
+ flags().SetDefaults();
+ parser.ParseString(GetEnv("DFSAN_OPTIONS"));
}
static void dfsan_fini() {
@@ -363,8 +363,7 @@ static void dfsan_init(int argc, char **
if (!(init_addr >= kUnusedAddr && init_addr < kAppAddr))
Mprotect(kUnusedAddr, kAppAddr - kUnusedAddr);
- InitializeFlags(flags(), GetEnv("DFSAN_OPTIONS"));
-
+ InitializeFlags();
InitializeInterceptors();
// Register the fini callback to run when the program terminates successfully
Modified: vendor/compiler-rt/dist/lib/lsan/Makefile.mk
==============================================================================
--- vendor/compiler-rt/dist/lib/lsan/Makefile.mk Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/lsan/Makefile.mk Sun Feb 22 22:43:40 2015 (r279192)
@@ -20,9 +20,6 @@ Dependencies := $(wildcard $(Dir)/*.h)
Dependencies += $(wildcard $(Dir)/../interception/*.h)
Dependencies += $(wildcard $(Dir)/../sanitizer_common/*.h)
-# Define a convenience variable for all the lsan functions.
-LsanFunctions := $(Sources:%.cc=%)
-
# lsan functions used in another sanitizers.
LsanCommonSources := $(foreach file,$(wildcard $(Dir)/lsan_common*.cc),$(notdir $(file)))
LsanCommonFunctions := $(LsanCommonSources:%.cc=%)
Modified: vendor/compiler-rt/dist/lib/lsan/lsan.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/lsan/lsan.cc Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/lsan/lsan.cc Sun Feb 22 22:43:40 2015 (r279192)
@@ -15,6 +15,7 @@
#include "lsan.h"
#include "sanitizer_common/sanitizer_flags.h"
+#include "sanitizer_common/sanitizer_flag_parser.h"
#include "sanitizer_common/sanitizer_stacktrace.h"
#include "lsan_allocator.h"
#include "lsan_common.h"
@@ -34,13 +35,42 @@ bool WordIsPoisoned(uptr addr) {
using namespace __lsan; // NOLINT
+static void InitializeFlags() {
+ // Set all the default values.
+ SetCommonFlagsDefaults();
+ {
+ CommonFlags cf;
+ cf.CopyFrom(*common_flags());
+ cf.external_symbolizer_path = GetEnv("LSAN_SYMBOLIZER_PATH");
+ cf.malloc_context_size = 30;
+ cf.detect_leaks = true;
+ OverrideCommonFlags(cf);
+ }
+
+ Flags *f = flags();
+ f->SetDefaults();
+
+ FlagParser parser;
+ RegisterLsanFlags(&parser, f);
+ RegisterCommonFlags(&parser);
+
+ parser.ParseString(GetEnv("LSAN_OPTIONS"));
+
+ SetVerbosity(common_flags()->verbosity);
+
+ if (Verbosity()) ReportUnrecognizedFlags();
+
+ if (common_flags()->help) parser.PrintFlagDescriptions();
+}
+
extern "C" void __lsan_init() {
CHECK(!lsan_init_is_running);
if (lsan_inited)
return;
lsan_init_is_running = true;
SanitizerToolName = "LeakSanitizer";
- InitCommonLsan(true);
+ InitializeFlags();
+ InitCommonLsan();
InitializeAllocator();
InitTlsSize();
InitializeInterceptors();
Modified: vendor/compiler-rt/dist/lib/lsan/lsan_allocator.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/lsan/lsan_allocator.cc Sun Feb 22 22:31:36 2015 (r279191)
+++ vendor/compiler-rt/dist/lib/lsan/lsan_allocator.cc Sun Feb 22 22:43:40 2015 (r279192)
@@ -25,10 +25,6 @@ extern "C" void *memset(void *ptr, int v
namespace __lsan {
-static const uptr kMaxAllowedMallocSize = 8UL << 30;
-static const uptr kAllocatorSpace = 0x600000000000ULL;
-static const uptr kAllocatorSize = 0x40000000000ULL; // 4T.
-
struct ChunkMetadata {
bool allocated : 8; // Must be first.
ChunkTag tag : 2;
@@ -36,8 +32,22 @@ struct ChunkMetadata {
u32 stack_trace_id;
};
+#if defined(__mips64)
+static const uptr kMaxAllowedMallocSize = 4UL << 30;
+static const uptr kRegionSizeLog = 20;
+static const uptr kNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kRegionSizeLog;
+typedef TwoLevelByteMap<(kNumRegions >> 12), 1 << 12> ByteMap;
+typedef CompactSizeClassMap SizeClassMap;
+typedef SizeClassAllocator32<0, SANITIZER_MMAP_RANGE_SIZE,
+ sizeof(ChunkMetadata), SizeClassMap, kRegionSizeLog, ByteMap>
+ PrimaryAllocator;
+#else
+static const uptr kMaxAllowedMallocSize = 8UL << 30;
+static const uptr kAllocatorSpace = 0x600000000000ULL;
+static const uptr kAllocatorSize = 0x40000000000ULL; // 4T.
typedef SizeClassAllocator64<kAllocatorSpace, kAllocatorSize,
sizeof(ChunkMetadata), DefaultSizeClassMap> PrimaryAllocator;
+#endif
typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache;
typedef LargeMmapAllocator<> SecondaryAllocator;
typedef CombinedAllocator<PrimaryAllocator, AllocatorCache,
Modified: vendor/compiler-rt/dist/lib/lsan/lsan_common.cc
==============================================================================
--- vendor/compiler-rt/dist/lib/lsan/lsan_common.cc Sun Feb 22 22:31:36 2015 (r279191)
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-vendor
mailing list