diff options
author | Siddhesh Poyarekar <siddhesh@gotplt.org> | 2022-05-11 19:13:09 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@gotplt.org> | 2022-05-11 19:13:09 +0530 |
commit | 546c6210eb08f583ee4f53a0fd7886b6c958c7fa (patch) | |
tree | 7dfd892e7d6541a1e1b943cf5bdac901a509d64c | |
parent | a92ed39c416b2a92f404d9851fdfea5cae7e6b21 (diff) | |
download | gcc-546c6210eb08f583ee4f53a0fd7886b6c958c7fa.zip gcc-546c6210eb08f583ee4f53a0fd7886b6c958c7fa.tar.gz gcc-546c6210eb08f583ee4f53a0fd7886b6c958c7fa.tar.bz2 |
middle-end/70090: Register __bdos for sanitizers if necessary
The asan initializer registers __builtin_object_size for languages that
don't have it, e.g. Fortran. Register __builtin_dynamic_object_size too
(we need both because __builtin_dynamic_object_size computation may
involve generating __builtin_object_size as a fallback) so that
gfortran.dg/ubsan/bind-c-intent-out-2.f90 does not crash anymore.
gcc/ChangeLog:
PR middle-end/70090
* asan.cc (initialize_sanitizer_builtins): Register
__builtin_dynamic_object_size if necessary.
Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
-rw-r--r-- | gcc/asan.cc | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/gcc/asan.cc b/gcc/asan.cc index ef59b77..4b583e5 100644 --- a/gcc/asan.cc +++ b/gcc/asan.cc @@ -3457,14 +3457,22 @@ initialize_sanitizer_builtins (void) #include "sanitizer.def" - /* -fsanitize=object-size uses __builtin_object_size, but that might - not be available for e.g. Fortran at this point. We use - DEF_SANITIZER_BUILTIN here only as a convenience macro. */ - if ((flag_sanitize & SANITIZE_OBJECT_SIZE) - && !builtin_decl_implicit_p (BUILT_IN_OBJECT_SIZE)) - DEF_SANITIZER_BUILTIN_1 (BUILT_IN_OBJECT_SIZE, "object_size", - BT_FN_SIZE_CONST_PTR_INT, - ATTR_PURE_NOTHROW_LEAF_LIST); + /* -fsanitize=object-size uses __builtin_dynamic_object_size and + __builtin_object_size, but they might not be available for e.g. Fortran at + this point. We use DEF_SANITIZER_BUILTIN here only as a convenience + macro. */ + if (flag_sanitize & SANITIZE_OBJECT_SIZE) + { + if (!builtin_decl_implicit_p (BUILT_IN_OBJECT_SIZE)) + DEF_SANITIZER_BUILTIN_1 (BUILT_IN_OBJECT_SIZE, "object_size", + BT_FN_SIZE_CONST_PTR_INT, + ATTR_PURE_NOTHROW_LEAF_LIST); + if (!builtin_decl_implicit_p (BUILT_IN_DYNAMIC_OBJECT_SIZE)) + DEF_SANITIZER_BUILTIN_1 (BUILT_IN_DYNAMIC_OBJECT_SIZE, + "dynamic_object_size", + BT_FN_SIZE_CONST_PTR_INT, + ATTR_PURE_NOTHROW_LEAF_LIST); + } #undef DEF_SANITIZER_BUILTIN_1 #undef DEF_SANITIZER_BUILTIN |