This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, AArch64] Enable Address sanitizer and UB sanitizer


Hi,

The attached patch enables the address and undefined behavior sanitizers.

I have tested it on AArch64 hardware, and asan.exp tests pass, but a
few ubsan.exp tests fail as follows:
FAIL: c-c++-common/ubsan/float-cast-overflow-1.c   -O3 -g  execution test
FAIL: c-c++-common/ubsan/float-cast-overflow-1.c   -O2 -flto
-flto-partition=none  execution test
FAIL: c-c++-common/ubsan/float-cast-overflow-2.c   -O3 -g  execution test
FAIL: c-c++-common/ubsan/float-cast-overflow-3.c   -O3 -g  execution test
FAIL: c-c++-common/ubsan/float-cast-overflow-4.c   -O2  execution test
FAIL: c-c++-common/ubsan/float-cast-overflow-4.c   -O3 -g  execution test
FAIL: c-c++-common/ubsan/overflow-int128.c   -O0  (internal compiler error)
FAIL: c-c++-common/ubsan/overflow-int128.c   -O0  (test for excess errors)
FAIL: c-c++-common/ubsan/overflow-int128.c   -O1  (internal compiler error)
FAIL: c-c++-common/ubsan/overflow-int128.c   -O1  (test for excess errors)
FAIL: c-c++-common/ubsan/overflow-int128.c   -O2  (internal compiler error)
FAIL: c-c++-common/ubsan/overflow-int128.c   -O2  (test for excess errors)
FAIL: c-c++-common/ubsan/overflow-int128.c   -O3 -fomit-frame-pointer
(internal compiler error)
FAIL: c-c++-common/ubsan/overflow-int128.c   -O3 -fomit-frame-pointer
(test for excess errors)
FAIL: c-c++-common/ubsan/overflow-int128.c   -O3 -g  (internal compiler error)
FAIL: c-c++-common/ubsan/overflow-int128.c   -O3 -g  (test for excess errors)
FAIL: c-c++-common/ubsan/overflow-int128.c   -Os  (internal compiler error)
FAIL: c-c++-common/ubsan/overflow-int128.c   -Os  (test for excess errors)
FAIL: c-c++-common/ubsan/overflow-int128.c   -O2 -flto
-flto-partition=none  (internal compiler error)
FAIL: c-c++-common/ubsan/overflow-int128.c   -O2 -flto
-flto-partition=none  (test for excess errors)
FAIL: c-c++-common/ubsan/overflow-int128.c   -O2 -flto  (internal
compiler error)
FAIL: c-c++-common/ubsan/overflow-int128.c   -O2 -flto  (test for excess errors)
FAIL: gcc.dg/ubsan/float-cast-overflow-bf.c   -O3 -g  execution test

I think all these failures need to be addressed separately, and should
not prevent from adding the functionality since most of them pass.

Note that an update of libsanitizer is required, to include at least
revision 209641 (which fixes internal_fork for AArch64).

OK for trunk?

Christophe.

2014-09-05  Christophe Lyon <christophe.lyon@linaro.org>
        gcc/
        * config/aarch64/aarch64-linux.h (ASAN_CC1_SPEC): Define.
        (CC1_SPEC): Define.
        * config/aarch64/aarch64.c (aarch64_asan_shadow_offset): New function.
        (TARGET_ASAN_SHADOW_OFFSET): Define.

        libsanitizer/
        * configure.tgt: Add AArch64 pattern.
diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
index 8d20310..2278516 100644
--- a/gcc/config/aarch64/aarch64-linux.h
+++ b/gcc/config/aarch64/aarch64-linux.h
@@ -23,6 +23,12 @@
 
 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
 
+#undef  ASAN_CC1_SPEC
+#define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}"
+
+#undef  CC1_SPEC
+#define CC1_SPEC GNU_USER_TARGET_CC1_SPEC ASAN_CC1_SPEC
+
 #define CPP_SPEC "%{pthread:-D_REENTRANT}"
 
 #define LINUX_TARGET_LINK_SPEC  "%{h*}		\
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index c3c871e..39b9fd2 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -9826,6 +9826,14 @@ aarch64_expand_movmem (rtx *operands)
   return true;
 }
 
+/* Implement the TARGET_ASAN_SHADOW_OFFSET hook.  */
+
+static unsigned HOST_WIDE_INT
+aarch64_asan_shadow_offset (void)
+{
+  return (HOST_WIDE_INT_1 << 36);
+}
+
 #undef TARGET_ADDRESS_COST
 #define TARGET_ADDRESS_COST aarch64_address_cost
 
@@ -10072,6 +10080,9 @@ aarch64_expand_movmem (rtx *operands)
 #undef TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS
 #define TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS true
 
+#undef TARGET_ASAN_SHADOW_OFFSET
+#define TARGET_ASAN_SHADOW_OFFSET aarch64_asan_shadow_offset
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-aarch64.h"
diff --git a/libsanitizer/configure.tgt b/libsanitizer/configure.tgt
index 6de4a65..2c302ab 100644
--- a/libsanitizer/configure.tgt
+++ b/libsanitizer/configure.tgt
@@ -35,6 +35,8 @@ case "${target}" in
 	;;
   arm*-*-linux*)
 	;;
+  aarch64*-*-linux*)
+	;;
   x86_64-*-darwin[1]* | i?86-*-darwin[1]*)
 	TSAN_SUPPORTED=no
 	;;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]