From 2cd16020bc114223ae2d82049bf2592499527d62 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 27 Feb 2025 10:47:08 +0800 Subject: [PATCH] [Compier-RT][HWASAN] set asan.options logpath Signed-off-by: Eric --- compiler-rt/lib/asan/asan_rtl.cpp | 6 ++++-- compiler-rt/lib/hwasan/hwasan.cpp | 6 ++++-- .../lib/sanitizer_common/sanitizer_linux_libcdep.cpp | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/compiler-rt/lib/asan/asan_rtl.cpp b/compiler-rt/lib/asan/asan_rtl.cpp index cbbdcf7914b0..33b6b2dc9dee 100644 --- a/compiler-rt/lib/asan/asan_rtl.cpp +++ b/compiler-rt/lib/asan/asan_rtl.cpp @@ -419,9 +419,11 @@ static void AsanInitInternal() { __asan_option_detect_stack_use_after_return = flags()->detect_stack_use_after_return; - +// OHOS_LOCAL Begin +#if !SANITIZER_OHOS __sanitizer::InitializePlatformEarly(); - +#endif +// OHOS_LOCAL End // Setup internal allocator callback. SetLowLevelAllocateMinAlignment(ASAN_SHADOW_GRANULARITY); SetLowLevelAllocateCallback(OnLowLevelAllocate); diff --git a/compiler-rt/lib/hwasan/hwasan.cpp b/compiler-rt/lib/hwasan/hwasan.cpp index 41c0c8b51fdf..b8838ccbbe23 100644 --- a/compiler-rt/lib/hwasan/hwasan.cpp +++ b/compiler-rt/lib/hwasan/hwasan.cpp @@ -334,9 +334,11 @@ __attribute__((constructor(0))) void __hwasan_init() { // Install tool-specific callbacks in sanitizer_common. SetCheckUnwindCallback(CheckUnwind); - +// OHOS_LOCAL Begin +#if !SANITIZER_OHOS __sanitizer_set_report_path(common_flags()->log_path); - +#endif +// OHOS_LOCAL End AndroidTestTlsSlot(); DisableCoreDumperIfNecessary(); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp index 610876331aab..80476dae7f9c 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp @@ -1063,7 +1063,7 @@ static bool ShouldLogAfterPrintf() { } extern "C" SANITIZER_WEAK_ATTRIBUTE int musl_log(const char *fmt, ...); -extern "C" SANITIZER_WEAK_ATTRIBUTE int ohos_dfx_log(const char *s); +extern "C" SANITIZER_WEAK_ATTRIBUTE int ohos_dfx_log(const char *s, const char *p); void WriteOneLineToSyslog(const char *s) { if (&musl_log) { musl_log(s); @@ -1097,7 +1097,7 @@ void LogMessageOnPrintf(const char *str) { // disk. The ohos_dfx_log may perform dynamic memory allocation, potentiallt // leading to the sanitizer triggering a recursive call. safe_to_call_printf = false; - ohos_dfx_log(str); + ohos_dfx_log(str, common_flags()->log_path); safe_to_call_printf = true; } #endif -- Gitee