summaryrefslogtreecommitdiff
path: root/absl
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2023-04-10 14:57:45 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-04-10 14:59:05 -0700
commit2927340217c37328319b5869285a6dcdbc13e7a7 (patch)
tree4d38e8d5e5753783e328a5953a5cf859f8333891 /absl
parent3ac60094416a4a8841556a75ca01a0043d461672 (diff)
Extend ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS to support HWASAN
PiperOrigin-RevId: 523220096 Change-Id: Iaffea2c9c4d112839ca8c2c7f130f72c3d7cc35b
Diffstat (limited to 'absl')
-rw-r--r--absl/base/attributes.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/absl/base/attributes.h b/absl/base/attributes.h
index a6572d08..df2c458f 100644
--- a/absl/base/attributes.h
+++ b/absl/base/attributes.h
@@ -211,11 +211,20 @@
// out of bounds or does other scary things with memory.
// NOTE: GCC supports AddressSanitizer(asan) since 4.8.
// https://gcc.gnu.org/gcc-4.8/changes.html
-#if ABSL_HAVE_ATTRIBUTE(no_sanitize_address)
+#if defined(ABSL_HAVE_ADDRESS_SANITIZER) && \
+ ABSL_HAVE_ATTRIBUTE(no_sanitize_address)
#define ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
-#elif defined(_MSC_VER) && _MSC_VER >= 1928
+#elif defined(ABSL_HAVE_ADDRESS_SANITIZER) && defined(_MSC_VER) && \
+ _MSC_VER >= 1928
// https://docs.microsoft.com/en-us/cpp/cpp/no-sanitize-address
#define ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS __declspec(no_sanitize_address)
+#elif defined(ABSL_HAVE_HWADDRESS_SANITIZER) && ABSL_HAVE_ATTRIBUTE(no_sanitize)
+// HWAddressSanitizer is a sanitizer similar to AddressSanitizer, which uses CPU
+// features to detect similar bugs with less CPU and memory overhead.
+// NOTE: GCC supports HWAddressSanitizer(hwasan) since 11.
+// https://gcc.gnu.org/gcc-11/changes.html
+#define ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS \
+ __attribute__((no_sanitize("hwaddress")))
#else
#define ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS
#endif