This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new de460b5a10 mm_ubsan: add dummy to bypass runtime actions
de460b5a10 is described below
commit de460b5a101c35501e45c7224276009337b62c42
Author: buxiasen <[email protected]>
AuthorDate: Tue Jul 9 00:32:34 2024 +0800
mm_ubsan: add dummy to bypass runtime actions
Signed-off-by: buxiasen <[email protected]>
---
mm/Kconfig | 7 +++++
mm/ubsan/ubsan.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 85 insertions(+)
diff --git a/mm/Kconfig b/mm/Kconfig
index a4ec8eb0c6..42af2c5330 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -338,6 +338,13 @@ config MM_UBSAN_TRAP_ON_ERROR
The undefined instruction trap should cause your program to
crash,
save the code space significantly.
+config MM_UBSAN_DUMMY
+ bool "Bypass Undefined Behaviour Sanitizer Runtime Actions"
+ default n
+ depends on MM_UBSAN
+ ---help---
+ Keep UBSAN compile time but disable runtime actions.
+
config MM_FILL_ALLOCATIONS
bool "Fill allocations with debug value"
default n
diff --git a/mm/ubsan/ubsan.c b/mm/ubsan/ubsan.c
index dd85bb7b46..bfd86a10ec 100644
--- a/mm/ubsan/ubsan.c
+++ b/mm/ubsan/ubsan.c
@@ -29,6 +29,8 @@
#include "ubsan.h"
+#ifndef CONFIG_MM_UBSAN_DUMMY
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
@@ -388,3 +390,79 @@ void __ubsan_handle_dynamic_type_cache_miss(FAR void *data,
{
ubsan_prologue_epilogue(data, "dynamic-type-cache-miss");
}
+
+#else
+void __ubsan_handle_out_of_bounds(FAR void *data, FAR void *index)
+{
+}
+
+void __ubsan_handle_shift_out_of_bounds(FAR void *data,
+ FAR void *lhs, FAR void *rhs)
+{
+}
+
+void __ubsan_handle_divrem_overflow(FAR void *data,
+ FAR void *lhs, FAR void *rhs)
+{
+}
+
+void __ubsan_handle_alignment_assumption(FAR void *data, uintptr_t ptr,
+ uintptr_t align, uintptr_t offset)
+{
+}
+
+void __ubsan_handle_type_mismatch(FAR struct type_mismatch_data *data,
+ FAR void *ptr)
+{
+}
+
+void __ubsan_handle_type_mismatch_v1(FAR void *_data, FAR void *ptr)
+{
+}
+
+void __ubsan_handle_builtin_unreachable(FAR void *data)
+{
+ PANIC();
+}
+
+void __ubsan_handle_nonnull_arg(FAR void *data)
+{
+}
+
+void __ubsan_handle_add_overflow(FAR void *data,
+ FAR void *lhs, FAR void *rhs)
+{
+}
+
+void __ubsan_handle_sub_overflow(FAR void *data,
+ FAR void *lhs, FAR void *rhs)
+{
+}
+
+void __ubsan_handle_mul_overflow(FAR void *data,
+ FAR void *lhs, FAR void *rhs)
+{
+}
+
+void __ubsan_handle_load_invalid_value(FAR void *data, FAR void *ptr)
+{
+}
+
+void __ubsan_handle_negate_overflow(FAR void *data, FAR void *ptr)
+{
+}
+
+void __ubsan_handle_pointer_overflow(FAR void *data,
+ FAR void *ptr, FAR void *result)
+{
+}
+
+void __ubsan_handle_invalid_builtin(FAR void *data)
+{
+}
+
+void __ubsan_handle_dynamic_type_cache_miss(FAR void *data,
+ FAR void *ptr, FAR void *hash)
+{
+}
+#endif