[binutils-gdb] Define BFD_ASAN to detect asan
Alan Modra
amodra@sourceware.org
Mon Mar 2 23:55:39 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f1a664fa55a9ec301b5139788ee033005dd31db6
commit f1a664fa55a9ec301b5139788ee033005dd31db6
Author: Alan Modra <amodra@gmail.com>
Date: Tue Mar 3 10:20:54 2026 +1030
Define BFD_ASAN to detect asan
Diff:
---
bfd/bfd-in.h | 10 ++++++++++
bfd/bfd-in2.h | 10 ++++++++++
2 files changed, 20 insertions(+)
diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index 751f0ad3cbb..8650fa12d82 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -151,6 +151,16 @@ struct orl;
? (((bfd_vma) (this) + ((boundary) - 1)) & ~ (bfd_vma) ((boundary)-1)) \
: ~ (bfd_vma) 0)
+/* Detect whether we are compiling with -fsanitize=address. */
+#ifndef BFD_ASAN
+# if ((defined (__SANITIZE_ADDRESS__) && __SANITIZE_ADDRESS__) \
+ || (defined __has_feature && __has_feature (address_sanitizer)))
+# define BFD_ASAN 1
+# else
+# define BFD_ASAN 0
+# endif
+#endif
+
/* Return TRUE if the start of STR matches PREFIX, FALSE otherwise. */
static inline bool
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 2b6811c72b2..cd5307beef4 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -158,6 +158,16 @@ struct orl;
? (((bfd_vma) (this) + ((boundary) - 1)) & ~ (bfd_vma) ((boundary)-1)) \
: ~ (bfd_vma) 0)
+/* Detect whether we are compiling with -fsanitize=address. */
+#ifndef BFD_ASAN
+# if ((defined (__SANITIZE_ADDRESS__) && __SANITIZE_ADDRESS__) \
+ || (defined __has_feature && __has_feature (address_sanitizer)))
+# define BFD_ASAN 1
+# else
+# define BFD_ASAN 0
+# endif
+#endif
+
/* Return TRUE if the start of STR matches PREFIX, FALSE otherwise. */
static inline bool
More information about the Binutils-cvs
mailing list