[asan] Add openlog() on Android.
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Wed, 7 Sep 2016 22:56:02 +0000 (22:56 +0000)
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Wed, 7 Sep 2016 22:56:02 +0000 (22:56 +0000)
Normally, syslog() uses argv[0] for the log tag; bionic, however,
would crash in syslog() before libc constructor unless the log
tag is explicitly set with openlog().

llvm-svn: 280875

compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc

index a37bdf1..d3965eb 100644 (file)
 
 #if SANITIZER_ANDROID
 #include <android/api-level.h>
+#include <syslog.h>
 #endif
 
 #if SANITIZER_ANDROID && __ANDROID_API__ < 21
 #include <android/log.h>
-#else
-#include <syslog.h>
 #endif
 
 #if !SANITIZER_ANDROID
@@ -521,6 +520,7 @@ uptr GetRSS() {
 static atomic_uint8_t android_log_initialized;
 
 void AndroidLogInit() {
+  openlog(GetProcessName(), 0, LOG_USER);
   atomic_store(&android_log_initialized, 1, memory_order_release);
 }