Skip to content

Commit 2927340

Browse files
Abseil Teamcopybara-github
authored andcommitted
Extend ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS to support HWASAN
PiperOrigin-RevId: 523220096 Change-Id: Iaffea2c9c4d112839ca8c2c7f130f72c3d7cc35b
1 parent 3ac6009 commit 2927340

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

absl/base/attributes.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,20 @@
211211
// out of bounds or does other scary things with memory.
212212
// NOTE: GCC supports AddressSanitizer(asan) since 4.8.
213213
// https://gcc.gnu.org/gcc-4.8/changes.html
214-
#if ABSL_HAVE_ATTRIBUTE(no_sanitize_address)
214+
#if defined(ABSL_HAVE_ADDRESS_SANITIZER) && \
215+
ABSL_HAVE_ATTRIBUTE(no_sanitize_address)
215216
#define ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
216-
#elif defined(_MSC_VER) && _MSC_VER >= 1928
217+
#elif defined(ABSL_HAVE_ADDRESS_SANITIZER) && defined(_MSC_VER) && \
218+
_MSC_VER >= 1928
217219
// https://docs.microsoft.com/en-us/cpp/cpp/no-sanitize-address
218220
#define ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS __declspec(no_sanitize_address)
221+
#elif defined(ABSL_HAVE_HWADDRESS_SANITIZER) && ABSL_HAVE_ATTRIBUTE(no_sanitize)
222+
// HWAddressSanitizer is a sanitizer similar to AddressSanitizer, which uses CPU
223+
// features to detect similar bugs with less CPU and memory overhead.
224+
// NOTE: GCC supports HWAddressSanitizer(hwasan) since 11.
225+
// https://gcc.gnu.org/gcc-11/changes.html
226+
#define ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS \
227+
__attribute__((no_sanitize("hwaddress")))
219228
#else
220229
#define ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS
221230
#endif

0 commit comments

Comments
 (0)