[binutils-gdb] Define BFD_ASAN to detect asan
Alan Modra via Binutils-cvs <[email protected]>
| Newsgroups | gmane.comp.gnu.binutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f1a664fa55a9ec301b5139788ee033005dd31db6 commit f1a664fa55a9ec301b5139788ee033005dd31db6 Author: Alan Modra <[email protected]> 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