]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Define BFD_ASAN to detect asan
authorAlan Modra <amodra@gmail.com>
Mon, 2 Mar 2026 23:50:54 +0000 (10:20 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 2 Mar 2026 23:55:13 +0000 (10:25 +1030)
bfd/bfd-in.h
bfd/bfd-in2.h

index 751f0ad3cbb8a3eee24cd438a4e92d8ce82b46dc..8650fa12d820175d46db4c4e4c55081da075fa2b 100644 (file)
@@ -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
index 2b6811c72b20c3036b9f3f4227471beb5cd09093..cd5307beef4fec93244d20b5168483ab35a27d43 100644 (file)
@@ -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