Prevent unaligned access under ASan builds
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
diff --git a/library/common.h b/library/common.h
index e502b5d..3925a79 100644
--- a/library/common.h
+++ b/library/common.h
@@ -73,11 +73,12 @@
*
* This list is incomplete.
*/
-#if defined(__i386__) || defined(__amd64__) || defined( __x86_64__) \
+#if (defined(__i386__) || defined(__amd64__) || defined( __x86_64__) \
|| defined(__ARM_FEATURE_UNALIGNED) \
|| defined(__aarch64__) \
|| defined(__ARM_ARCH_8__) || defined(__ARM_ARCH_8A__) || defined(__ARM_ARCH_8M__) \
- || defined(__ARM_ARCH_7A__)
+ || defined(__ARM_ARCH_7A__)) \
+ && (!(defined(__has_feature) && __has_feature(undefined_behavior_sanitizer)))
#define MBEDTLS_ALLOW_UNALIGNED_ACCESS
#endif