Skip to content
This repository has been archived by the owner on May 21, 2019. It is now read-only.

Commit

Permalink
[asan] Read extra flags from a system property on activation on Android.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200550 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
eugenis committed Jan 31, 2014
1 parent 8468840 commit 763799a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/asan/asan_activation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ void AsanActivate() {
common_flags()->malloc_context_size =
asan_deactivated_flags.malloc_context_size;

ParseExtraActivationFlags();

asan_is_deactivated = false;
VReport(
1,
Expand Down
2 changes: 2 additions & 0 deletions lib/asan/asan_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ void PlatformTSDDtor(void *tsd);

void AppendToErrorMessageBuffer(const char *buffer);

void ParseExtraActivationFlags();

// Platfrom-specific options.
#if SANITIZER_MAC
bool PlatformHasDifferentMemcpyAndMemmove();
Expand Down
15 changes: 15 additions & 0 deletions lib/asan/asan_rtl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,17 @@ void InitializeFlags(Flags *f, const char *env) {
}
}

// 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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions lib/sanitizer_common/sanitizer_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions lib/sanitizer_common/sanitizer_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

#if SANITIZER_ANDROID
#include <android/log.h>
#include <sys/system_properties.h>
#endif

// <linux/time.h>
Expand Down Expand Up @@ -697,6 +698,11 @@ uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg,
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) {
Expand Down

0 comments on commit 763799a

Please sign in to comment.