diff --git a/static_core/BUILD.gn b/static_core/BUILD.gn index 0ca0daa4f0a7ada9dd218119767e0bb3f3d752eb..0ca73ea0c4c5e36ffc6fd93469c0c8db352bf981 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 8b8135273e4823640fc078e153f17973a20de091..198a8d41c6128e4d28a73c3ca30520b4d88f9d0e 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 d912358439832728b7c20ee7580ed35567cd5bf7..47ca57cd5107f88cbd082b9bd0b7dd9e1ad078fe 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 }