]> gcc.gnu.org Git - gcc.git/commitdiff
arm.c (arm_asan_shadow_offset): New function.
authorChristophe Lyon <christophe.lyon@linaro.org>
Tue, 7 May 2013 14:17:50 +0000 (14:17 +0000)
committerChristophe Lyon <clyon@gcc.gnu.org>
Tue, 7 May 2013 14:17:50 +0000 (16:17 +0200)
2013-05-06  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/
* config/arm/arm.c (arm_asan_shadow_offset): New function.
(TARGET_ASAN_SHADOW_OFFSET): Define.
* config/arm/linux-eabi.h (ASAN_CC1_SPEC): Define.
(LINUX_OR_ANDROID_CC): Add ASAN_CC1_SPEC.

libsanitizer/
* configure.tgt: Add ARM pattern.

testsuite/
* lib/target-supports.exp (check_effective_target_hw): New
function.
* c-c++-common/asan/clone-test-1.c: Call
check_effective_target_hw.
* c-c++-common/asan/rlimit-mmap-test-1.c: Likewise.
* c-c++-common/asan/heap-overflow-1.c: Update regexps to accept
possible decorations.
* c-c++-common/asan/null-deref-1.c: Likewise.
* c-c++-common/asan/stack-overflow-1.c: Likewise.
* c-c++-common/asan/strncpy-overflow-1.c: Likewise.
* c-c++-common/asan/use-after-free-1.c: Likewise.
* g++.dg/asan/deep-thread-stack-1.C: Likewise.
* g++.dg/asan/large-func-test-1.C: Likewise.

From-SVN: r198683

16 files changed:
gcc/ChangeLog
gcc/config/arm/arm.c
gcc/config/arm/linux-eabi.h
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/asan/clone-test-1.c
gcc/testsuite/c-c++-common/asan/heap-overflow-1.c
gcc/testsuite/c-c++-common/asan/null-deref-1.c
gcc/testsuite/c-c++-common/asan/rlimit-mmap-test-1.c
gcc/testsuite/c-c++-common/asan/stack-overflow-1.c
gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c
gcc/testsuite/c-c++-common/asan/use-after-free-1.c
gcc/testsuite/g++.dg/asan/deep-thread-stack-1.C
gcc/testsuite/g++.dg/asan/large-func-test-1.C
gcc/testsuite/lib/target-supports.exp
libsanitizer/ChangeLog
libsanitizer/configure.tgt

index ab43501c3642133dd9c633de461d45c8d9e90ac5..8276e8ae0aefb923d3c6f14411b52443cf443970 100644 (file)
@@ -1,3 +1,10 @@
+2013-05-07  Christophe Lyon  <christophe.lyon@linaro.org>
+
+       * config/arm/arm.c (arm_asan_shadow_offset): New function.
+       (TARGET_ASAN_SHADOW_OFFSET): Define.
+       * config/arm/linux-eabi.h (ASAN_CC1_SPEC): Define.
+       (LINUX_OR_ANDROID_CC): Add ASAN_CC1_SPEC.
+
 2013-05-07  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
        * gimple-ssa-strength-reduction.c (MAX_INCR_VEC_LEN): New constant.
index 0b97cf89d18b780827d6dd42fa3baad3985e49a2..170dcb7042852977f9a7f98bad2228e1bf693e37 100644 (file)
@@ -281,6 +281,7 @@ static unsigned arm_add_stmt_cost (void *data, int count,
 
 static void arm_canonicalize_comparison (int *code, rtx *op0, rtx *op1,
                                         bool op0_preserve_value);
+static unsigned HOST_WIDE_INT arm_asan_shadow_offset (void);
 \f
 /* Table of machine attributes.  */
 static const struct attribute_spec arm_attribute_table[] =
@@ -657,6 +658,9 @@ static const struct attribute_spec arm_attribute_table[] =
 #define TARGET_CANONICALIZE_COMPARISON \
   arm_canonicalize_comparison
 
+#undef TARGET_ASAN_SHADOW_OFFSET
+#define TARGET_ASAN_SHADOW_OFFSET arm_asan_shadow_offset
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 \f
 /* Obstack for minipool constant handling.  */
@@ -28062,4 +28066,12 @@ arm_validize_comparison (rtx *comparison, rtx * op1, rtx * op2)
 
 }
 
+/* Implement the TARGET_ASAN_SHADOW_OFFSET hook.  */
+
+static unsigned HOST_WIDE_INT
+arm_asan_shadow_offset (void)
+{
+  return (unsigned HOST_WIDE_INT) 1 << 29;
+}
+
 #include "gt-arm.h"
index 23671a788c23b5735494f95be69bad39f99c690f..cb0aad19c344c3c20a9d8ee354544e7292317d25 100644 (file)
   LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC,                         \
                       LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC)
 
+#undef  ASAN_CC1_SPEC
+#define ASAN_CC1_SPEC "%{fsanitize=*:-funwind-tables}"
+
 #undef  CC1_SPEC
 #define CC1_SPEC                                                       \
-  LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC,                       \
-                      GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC)
+  LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC " " ASAN_CC1_SPEC,     \
+                      GNU_USER_TARGET_CC1_SPEC " " ASAN_CC1_SPEC " "   \
+                      ANDROID_CC1_SPEC)
 
 #define CC1PLUS_SPEC \
   LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC)
index 2351411254bcb1676def3dce6273324efef780ac..78ee04fbe8ddb781257cc54a86628c0260fa5cbf 100644 (file)
@@ -1,3 +1,19 @@
+2013-05-07  Christophe Lyon  <christophe.lyon@linaro.org>
+
+       * lib/target-supports.exp (check_effective_target_hw): New
+       function.
+       * c-c++-common/asan/clone-test-1.c: Call
+       check_effective_target_hw.
+       * c-c++-common/asan/rlimit-mmap-test-1.c: Likewise.
+       * c-c++-common/asan/heap-overflow-1.c: Update regexps to accept
+       possible decorations.
+       * c-c++-common/asan/null-deref-1.c: Likewise.
+       * c-c++-common/asan/stack-overflow-1.c: Likewise.
+       * c-c++-common/asan/strncpy-overflow-1.c: Likewise.
+       * c-c++-common/asan/use-after-free-1.c: Likewise.
+       * g++.dg/asan/deep-thread-stack-1.C: Likewise.
+       * g++.dg/asan/large-func-test-1.C: Likewise.
+
 2013-05-07  Sofiane Naci  <sofiane.naci@arm.com>
 
        * gcc.target/aarch64/scalar_intrinsics.c: Update.
index d9acc0dcfc487abc3c86cd7991f02082709f4068..fd187aaadd2d7ffca62f4cecc308555e35f05ad6 100644 (file)
@@ -3,6 +3,7 @@
 
 /* { dg-do run { target { *-*-linux* } } } */
 /* { dg-require-effective-target clone } */
+/* { dg-require-effective-target hw } */
 /* { dg-options "-D_GNU_SOURCE" } */
 
 #include <stdio.h>
index 43d47a3b2514cb288ddfc06fbbff310102f3a313..996909d3c8e3d8888a4a283ea05124eee55b838c 100644 (file)
@@ -25,7 +25,7 @@ int main(int argc, char **argv) {
 
 /* { dg-output "READ of size 1 at 0x\[0-9a-f\]+ thread T0.*(\n|\r\n|\r)" } */
 /* { dg-output "    #0 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*heap-overflow-1.c:21|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
-/* { dg-output "0x\[0-9a-f\]+ is located 0 bytes to the right of 10-byte region\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*0x\[0-9a-f\]+ is located 0 bytes to the right of 10-byte region\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
 /* { dg-output "    #0 0x\[0-9a-f\]+ (in _*(interceptor_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
 /* { dg-output "    #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*heap-overflow-1.c:19|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
index 2eee98621bfb04e74a36b10e0a006eb5c9421eec..14ec514aa9add892e61cd0dd3796ed8bd51bfdfd 100644 (file)
@@ -18,6 +18,6 @@ int main()
 
 /* { dg-output "ERROR: AddressSanitizer:? SEGV on unknown address\[^\n\r]*" } */
 /* { dg-output "0x\[0-9a-f\]+ \[^\n\r]*pc 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "AddressSanitizer can not provide additional info.*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*AddressSanitizer can not provide additional info.*(\n|\r\n|\r)" } */
 /* { dg-output "    #0 0x\[0-9a-f\]+ (in \[^\n\r]*NullDeref\[^\n\r]* (\[^\n\r]*null-deref-1.c:10|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
 /* { dg-output "    #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*null-deref-1.c:15|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
index 0b3d2ae6fa0c215197d497c0d9eec312a509fd61..9dbbc85f4f30b5ccbf4bd7bb83a73001de1786c2 100644 (file)
@@ -2,6 +2,7 @@
 
 /* { dg-do run { target setrlimit } } */
 /* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
+/* { dg-require-effective-target hw } */
 /* { dg-shouldfail "asan" } */
 
 #include <stdlib.h>
index 790aa5eb366d2103156c5a39ed72acb7494158c1..5f563561935d0c5be5143e78daafeb50a685d3ed 100644 (file)
@@ -19,4 +19,4 @@ int main() {
 
 /* { dg-output "READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } */
 /* { dg-output "    #0 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*stack-overflow-1.c:16|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
-/* { dg-output "Address 0x\[0-9a-f\]+ is\[^\n\r]*frame <main>" } */
+/* { dg-output "\[^\n\r]*Address 0x\[0-9a-f\]+ is\[^\n\r]*frame <main>" } */
index 10b3ad76d0400af6aa907f201f336a3de7488d9d..3ed9fd6dd5c21e579cd0a4042a883692bdf737e1 100644 (file)
@@ -15,7 +15,7 @@ int main(int argc, char **argv) {
 /* { dg-output "WRITE of size \[0-9\]* at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } */
 /* { dg-output "    #0 0x\[0-9a-f\]+ (in _*(interceptor_|)strncpy|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
 /* { dg-output "    #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*strncpy-overflow-1.c:11|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
-/* { dg-output "0x\[0-9a-f\]+ is located 0 bytes to the right of 9-byte region\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*0x\[0-9a-f\]+ is located 0 bytes to the right of 9-byte region\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
 /* { dg-output "    #0 0x\[0-9a-f\]+ (in _*(interceptor_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
 /* { dg-output "    #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*strncpy-overflow-1.c:10|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
index 939feeb91ee424740a9080480f53cd2241598c7f..25e9be827f0f6d7a82019aff86d013e3c98c47a9 100644 (file)
@@ -11,12 +11,12 @@ int main() {
 
 /* { dg-output "ERROR: AddressSanitizer:? heap-use-after-free on address\[^\n\r]*" } */
 /* { dg-output "0x\[0-9a-f\]+ at pc 0x\[0-9a-f\]+ bp 0x\[0-9a-f\]+ sp 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*READ of size 1 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } */
 /* { dg-output "    #0 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*use-after-free-1.c:9|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
-/* { dg-output "0x\[0-9a-f\]+ is located 5 bytes inside of 10-byte region .0x\[0-9a-f\]+,0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } */
-/* { dg-output "freed by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*0x\[0-9a-f\]+ is located 5 bytes inside of 10-byte region .0x\[0-9a-f\]+,0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*freed by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
 /* { dg-output "    #0 0x\[0-9a-f\]+ (in _*(interceptor_|)free|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
 /* { dg-output "    #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*use-after-free-1.c:8|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */
-/* { dg-output "previously allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*previously allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } */
 /* { dg-output "    #0 0x\[0-9a-f\]+ (in _*(interceptor_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
 /* { dg-output "    #1 0x\[0-9a-f\]+ (in _*main (\[^\n\r]*use-after-free-1.c:7|\[^\n\r]*:0)|\[(\])\[^\n\r]*(\n|\r\n|\r)" } */
index 12d8a7a64eadcb7cb1d47f277d4d2bd3eba141aa..d5d85c42d93f3883372eee444f4e56c5f0f3d8e5 100644 (file)
@@ -45,9 +45,9 @@ int main(int argc, char *argv[]) {
 }
 
 // { dg-output "ERROR: AddressSanitizer: heap-use-after-free.*(\n|\r\n|\r)" }
-// { dg-output "WRITE of size 4 at 0x\[0-9a-f\]+ thread T(\[0-9\]+).*(\n|\r\n|\r)" }
-// { dg-output "freed by thread T(\[0-9\]+) here:.*(\n|\r\n|\r)" }
-// { dg-output "previously allocated by thread T(\[0-9\]+) here:.*(\n|\r\n|\r)" }
+// { dg-output "\[^\n\r]*WRITE of size 4 at 0x\[0-9a-f\]+ thread T(\[0-9\]+).*(\n|\r\n|\r)" }
+// { dg-output "\[^\n\r]*freed by thread T(\[0-9\]+) here:.*(\n|\r\n|\r)" }
+// { dg-output "\[^\n\r]*previously allocated by thread T(\[0-9\]+) here:.*(\n|\r\n|\r)" }
 // { dg-output "Thread T\\2 created by T(\[0-9\]+) here:.*(\n|\r\n|\r)" }
 // { dg-output "Thread T\\8 created by T0 here:.*(\n|\r\n|\r)" }
 // { dg-output "Thread T\\4 created by T(\[0-9\]+) here:.*(\n|\r\n|\r)" }
index 32808e7a8bbabb7922b663e2ce698721932a4218..9344c3bcff62040982e177b51e2733c9f25db88f 100644 (file)
@@ -37,9 +37,9 @@ int main() {
 
 // { dg-output "ERROR: AddressSanitizer:? heap-buffer-overflow on address\[^\n\r]*" }
 // { dg-output "0x\[0-9a-f\]+ at pc 0x\[0-9a-f\]+ bp 0x\[0-9a-f\]+ sp 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" }
-// { dg-output "READ of size 4 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" }
+// { dg-output "\[^\n\r]*READ of size 4 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" }
 // { dg-output "    #0 0x\[0-9a-f\]+ (in \[^\n\r]*LargeFunction\[^\n\r]*(large-func-test-1.C:18|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" }
-// { dg-output "0x\[0-9a-f\]+ is located 44 bytes to the right of 400-byte region.*(\n|\r\n|\r)" }
-// { dg-output "allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" }
+// { dg-output "\[^\n\r]*0x\[0-9a-f\]+ is located 44 bytes to the right of 400-byte region.*(\n|\r\n|\r)" }
+// { dg-output "\[^\n\r]*allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" }
 // { dg-output "    #0( 0x\[0-9a-f\]+ (in _*(interceptor_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" }
 // { dg-output "    #1|) 0x\[0-9a-f\]+ (in (operator new|_*_Zn\[aw\]\[mj\])|\[(\])\[^\n\r]*(\n|\r\n|\r)" }
index 45c8b8487f060922e7296e6a21fbfd8643ec32e9..28b6b6d9ffd3c350551f51b19f6efb0e42bac6c1 100644 (file)
@@ -4668,6 +4668,33 @@ proc check_effective_target_simulator { } {
     return 0
 }
 
+# Return 1 if programs are intended to be run on hardware rather than
+# on a simulator
+
+proc check_effective_target_hw { } {
+
+    # All "src/sim" simulators set this one.
+    if [board_info target exists is_simulator] {
+       if [board_info target is_simulator] {
+         return 0
+       } else {
+         return 1
+       }
+    }
+
+    # The "sid" simulators don't set that one, but at least they set
+    # this one.
+    if [board_info target exists slow_simulator] {
+       if [board_info target slow_simulator] {
+         return 0
+       } else {
+         return 1
+       }
+    }
+
+    return 1
+}
+
 # Return 1 if the target is a VxWorks kernel.
 
 proc check_effective_target_vxworks_kernel { } {
index 6d8d8af4e73420b10b88515c762b056540d4f1d2..8cc31a318fc819abf2f8f8468d9881168b2b7d5d 100644 (file)
@@ -1,3 +1,7 @@
+2013-05-07  Christophe Lyon  <christophe.lyon@linaro.org>
+
+       * configure.tgt: Add ARM pattern.
+
 2013-03-22  Jakub Jelinek  <jakub@redhat.com>
 
        PR other/43620
index 265da01a13c96179f8cf51eb0d1d14d12192bce5..bdfc22e3718f40992ac0545b2d34f5806c0bb27f 100644 (file)
@@ -29,6 +29,8 @@ case "${target}" in
        ;;
   sparc*-*-linux*)
        ;;
+  arm*-*-linux*)
+       ;;
   x86_64-*-darwin[1]* | i?86-*-darwin[1]*)
        TSAN_SUPPORTED=no
        ;;
This page took 0.141955 seconds and 5 git commands to generate.