[compiler-rt] r200550 - [asan] Read extra flags from a system property on activation on Android.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Fri Jan 31 06:36:55 PST 2014
Author: eugenis
Date: Fri Jan 31 08:36:55 2014
New Revision: 200550
URL: http://llvm.org/viewvc/llvm-project?rev=200550&view=rev
Log:
[asan] Read extra flags from a system property on activation on Android.
Modified:
compiler-rt/trunk/lib/asan/asan_activation.cc
compiler-rt/trunk/lib/asan/asan_internal.h
compiler-rt/trunk/lib/asan/asan_rtl.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
Modified: compiler-rt/trunk/lib/asan/asan_activation.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_activation.cc?rev=200550&r1=200549&r2=200550&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_activation.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_activation.cc Fri Jan 31 08:36:55 2014
@@ -57,6 +57,8 @@ void AsanActivate() {
common_flags()->malloc_context_size =
asan_deactivated_flags.malloc_context_size;
+ ParseExtraActivationFlags();
+
asan_is_deactivated = false;
VReport(
1,
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=200550&r1=200549&r2=200550&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_internal.h Fri Jan 31 08:36:55 2014
@@ -87,6 +87,8 @@ void PlatformTSDDtor(void *tsd);
void AppendToErrorMessageBuffer(const char *buffer);
+void ParseExtraActivationFlags();
+
// Platfrom-specific options.
#if SANITIZER_MAC
bool PlatformHasDifferentMemcpyAndMemmove();
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=200550&r1=200549&r2=200550&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Fri Jan 31 08:36:55 2014
@@ -209,6 +209,17 @@ void InitializeFlags(Flags *f, const cha
}
}
+// Parse flags that may change between startup and activation.
+// On Android they come from a system property.
+// On other platforms this is no-op.
+void ParseExtraActivationFlags() {
+ char buf[100];
+ GetExtraActivationFlags(buf, sizeof(buf));
+ ParseFlagsFromString(flags(), buf);
+ if (buf[0] != '\0')
+ VReport(1, "Extra activation flags: %s\n", buf);
+}
+
// -------------------------- Globals --------------------- {{{1
int asan_inited;
bool asan_init_is_running;
@@ -413,6 +424,10 @@ static void AsanInitInternal() {
// initialization steps look at flags().
const char *options = GetEnv("ASAN_OPTIONS");
InitializeFlags(flags(), options);
+
+ if (!flags()->start_deactivated)
+ ParseExtraActivationFlags();
+
__sanitizer_set_report_path(common_flags()->log_path);
__asan_option_detect_stack_use_after_return =
flags()->detect_stack_use_after_return;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=200550&r1=200549&r2=200550&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h Fri Jan 31 08:36:55 2014
@@ -506,8 +506,10 @@ F IndirectExternCall(F f) {
#if SANITIZER_ANDROID
void AndroidLogWrite(const char *buffer);
+void GetExtraActivationFlags(char *buf, uptr size);
#else
INLINE void AndroidLogWrite(const char *buffer_unused) {}
+INLINE void GetExtraActivationFlags(char *buf, uptr size) { *buf = '\0'; }
#endif
} // namespace __sanitizer
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc?rev=200550&r1=200549&r2=200550&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc Fri Jan 31 08:36:55 2014
@@ -51,6 +51,7 @@
#if SANITIZER_ANDROID
#include <android/log.h>
+#include <sys/system_properties.h>
#endif
// <linux/time.h>
@@ -697,6 +698,11 @@ uptr internal_clone(int (*fn)(void *), v
void AndroidLogWrite(const char *buffer) {
__android_log_write(ANDROID_LOG_INFO, NULL, buffer);
}
+
+void GetExtraActivationFlags(char *buf, uptr size) {
+ CHECK(size > PROP_VALUE_MAX);
+ __system_property_get("asan.options", buf);
+}
#endif
bool IsDeadlySignal(int signum) {
More information about the llvm-commits
mailing list