]> git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/asan/TestCases/Linux/clang_gcc_abi.cc
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / compiler-rt / test / asan / TestCases / Linux / clang_gcc_abi.cc
1 // RUN: %clangxx_asan -O0 -x c %s -o %t && not %run %t 2>&1 | FileCheck %s
2 // RUN: %clangxx_asan -O1 -x c %s -o %t && not %run %t 2>&1 | FileCheck %s
3 // RUN: %clangxx_asan -O2 -x c %s -o %t && not %run %t 2>&1 | FileCheck %s
4 // RUN: %clangxx_asan -O3 -x c %s -o %t && not %run %t 2>&1 | FileCheck %s
5
6 // REQUIRES: arm-supported-target
7 // XFAIL: armv7l-unknown-linux-gnueabihf
8
9 #include <stdlib.h>
10
11 __attribute__((noinline))
12 int boom() {
13 volatile int three = 3;
14 char * volatile s = (char *)malloc(three);
15 // CHECK: #1 0x{{.*}} in boom {{.*}}clang_gcc_abi.cc:[[@LINE-1]]
16 return s[three]; //BOOM
17 }
18
19 __attribute__((naked, noinline)) void gcc_abi() {
20 // CHECK: #2 0x{{.*}} in gcc_abi {{.*}}clang_gcc_abi.cc:[[@LINE+1]]
21 asm volatile("str fp, [sp, #-8]!\n\t"
22 "str lr, [sp, #4]\n\t"
23 "add fp, sp, #4\n\t"
24 "bl boom\n\t"
25 "sub sp, fp, #4\n\t"
26 "ldr fp, [sp]\n\t"
27 "add sp, sp, #4\n\t"
28 "ldr pc, [sp], #4\n\t"
29 );
30 }
31
32 __attribute__((naked, noinline)) void clang_abi() {
33 // CHECK: #3 0x{{.*}} in clang_abi {{.*}}clang_gcc_abi.cc:[[@LINE+1]]
34 asm volatile("push {r11, lr}\n\t"
35 "mov r11, sp\n\t"
36 "bl gcc_abi\n\t"
37 "add r0, r0, #1\n\t"
38 "pop {r11, pc}\n\t"
39 );
40 }
41
42 int main() {
43 clang_abi();
44 // CHECK: #4 0x{{.*}} in main {{.*}}clang_gcc_abi.cc:[[@LINE-1]]
45 }