From 58ff32f7129c6118cd7f1dbff92318669f70f974 Mon Sep 17 00:00:00 2001 From: Keyv Chan Date: Sat, 17 May 2025 15:50:07 +0800 Subject: [PATCH] fix hwasan build Signed-off-by: chenkeyu --- static_core/BUILD.gn | 6 +++++- static_core/libpandabase/macros.h | 6 +++++- static_core/runtime/entrypoints/entrypoints.cpp | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/static_core/BUILD.gn b/static_core/BUILD.gn index 0ca0daa4f0..0ca73ea0c4 100644 --- a/static_core/BUILD.gn +++ b/static_core/BUILD.gn @@ -305,7 +305,11 @@ config("ark_config") { if (is_asan) { cflags_cc += [ "-g" ] - defines += [ "__SANITIZE_ADDRESS__" ] + if (defined(use_hwasan) && use_hwasan) { + defines += [ "__SANITIZE_HWADDRESS__" ] + } else { + defines += [ "__SANITIZE_ADDRESS__" ] + } print("ASAN is enabled") } diff --git a/static_core/libpandabase/macros.h b/static_core/libpandabase/macros.h index 8b8135273e..198a8d41c6 100644 --- a/static_core/libpandabase/macros.h +++ b/static_core/libpandabase/macros.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -289,6 +289,7 @@ extern "C" void AnnotateIgnoreWritesEnd(const char *file, int line); #define NO_UB_SANITIZE #endif // USE_UB_SANITIZER +#ifndef __SANITIZE_HWADDRESS__ // for clang #if defined(__has_feature) #if __has_feature(address_sanitizer) @@ -299,6 +300,9 @@ extern "C" void AnnotateIgnoreWritesEnd(const char *file, int line); #if defined(__SANITIZE_ADDRESS__) #define USE_ADDRESS_SANITIZER #endif +#else +#define NO_ADDRESS_SANITIZE +#endif #if defined(USE_ADDRESS_SANITIZER) #if __GNUC__ < 8 && !defined(__clang__) diff --git a/static_core/runtime/entrypoints/entrypoints.cpp b/static_core/runtime/entrypoints/entrypoints.cpp index d912358439..47ca57cd51 100644 --- a/static_core/runtime/entrypoints/entrypoints.cpp +++ b/static_core/runtime/entrypoints/entrypoints.cpp @@ -129,7 +129,7 @@ extern "C" void AnnotateSanitizersEntrypoint([[maybe_unused]] void const *addr, TSAN_ANNOTATE_HAPPENS_BEFORE(const_cast(addr)); #endif #ifdef PANDA_ASAN_ON - __asan_unpoison_memory_region(addr, size); + ASAN_UNPOISON_MEMORY_REGION(addr, size); #endif } -- Gitee