File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 178178if test "x$ub_sanitizer" = "xyes"; then
179179 AX_CHECK_COMPILE_FLAG ( [ -fsanitize=undefined] , [ AM_CFLAGS="$AM_CFLAGS -fsanitize=undefined"] )
180180 AX_CHECK_LINK_FLAG ( [ -fsanitize=undefined] , [ LDFLAGS="$LDFLAGS -fsanitize=undefined"] )
181+ # ubsan complains about unaligned reads/writes even though they are legal
182+ # on x86 archs. Force alignment adjustment to avoid false positives.
183+ AX_CHECK_COMPILE_FLAG ( [ -DAVOID_UNALIGNED_ACCESS=1] , [ AM_CFLAGS="$AM_CFLAGS -DAVOID_UNALIGNED_ACCESS=1"] )
181184fi
182185
183186# -flax-vector-conversions is needed for our arm assembly
Original file line number Diff line number Diff line change 3232#define HAVE_BSWAP_64 0
3333#endif
3434
35- #if defined(HAVE_UNALIGNED_ACCESS ) && defined(__arm__ )
36- /* arm unaligned access is incomplete, in that e.g. byte swap instructions
37- * can fault on unaligned addresses where a normal load/store would be fine.
38- * Since the compiler can optimise some of our accesses into operations like
39- * byte swaps, treat this platform as though it doesn't have unaligned access.
35+ #if defined(AVOID_UNALIGNED_ACCESS ) || (defined(HAVE_UNALIGNED_ACCESS ) && defined(__arm__ ))
36+ /* Disable unaligned access when:
37+ * 1) Explicitly asked to via AVOID_UNALIGNED_ACCESS (e.g. for ubsan builds)
38+ * 2) For arm builds where unaligned access is incomplete, in that e.g. byte
39+ * swap instructions can fault on unaligned addresses where a normal load/store
40+ * would be fine. Since the compiler can optimise some of our accesses into
41+ * operations like byte swaps, treat this platform as though it doesn't have
42+ * unaligned access.
4043 */
4144#undef HAVE_UNALIGNED_ACCESS
4245#define HAVE_UNALIGNED_ACCESS 0
You can’t perform that action at this time.
0 commit comments