packaging: Add -marm and -fno-omit-frame-pointer
[platform/upstream/gcc.git] / gcc / testsuite / c-c++-common / asan / fast-unwind.c
1 /* { dg-do compile { target arm*-*-*} } */
2 /* { dg-options "-fno-builtin-malloc -fno-builtin-free -fno-builtin-memset
3  * -fno-omit-frame-pointer -marm -Wa,-mimplicit-it=arm" } */
4 /* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
5 /* { dg-shouldfail "asan" } */
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 void *memset (void *, int, __SIZE_TYPE__);
12 void *malloc (__SIZE_TYPE__);
13 void free (void *);
14
15 const char *
16 __asan_default_options () {
17   return "fast_unwind_on_fatal=true";
18 }
19
20 #ifdef __cplusplus
21 }
22 #endif
23 volatile int ten = 10;
24 __attribute__ ((noinline)) int
25 foo ()
26 {
27   char *x = (char *) malloc (10);
28   memset(x, 0, 10);
29   int res = x[ten]; /* BOOOM */
30   free(x);
31   return res;
32 }
33
34 __attribute__ ((noinline)) int
35 bar ()
36 {
37   return foo ();
38 }
39
40 int
41 main (int argc, char **argv)
42 {
43   return bar ();
44 }
45
46 /* { dg-output "READ of size 1 at 0x\[0-9a-f\]+ thread T0.*(\n|\r\n|\r)" } */
47 /* { dg-output "    #0 0x\[0-9a-f\]+ +(in \[^\n\r]*foo\[^\n\r]*fast-unwind.c:29|\[(\]).*(\n|\r\n|\r)" } */
48 /* { dg-output "    #1 0x\[0-9a-f\]+ +(in \[^\n\r]*bar\[^\n\r]*fast-unwind.c:37|\[(\]).*(\n|\r\n|\r)" } */
49 /* { dg-output "    #2 0x\[0-9a-f\]+ +(in _*main (\[^\n\r]*fast-unwind.c:43|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } */