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 int boom() { 12 volatile int three = 3; 13 char *s = (char *)malloc(three); 14 // CHECK: #1 0x{{.*}} in boom {{.*}}clang_gcc_abi.cc:[[@LINE-1]] 15 return s[three]; //BOOM 16 } 17 18 __attribute__((naked, noinline)) void gcc_abi() { 19 // CHECK: #2 0x{{.*}} in gcc_abi {{.*}}clang_gcc_abi.cc:[[@LINE+1]] 20 asm volatile("str fp, [sp, #-8]!\n\t" 21 "str lr, [sp, #4]\n\t" 22 "add fp, sp, #4\n\t" 23 "bl boom\n\t" 24 "sub sp, fp, #4\n\t" 25 "ldr fp, [sp]\n\t" 26 "add sp, sp, #4\n\t" 27 "ldr pc, [sp], #4\n\t" 28 ); 29 } 30 31 __attribute__((naked, noinline)) void clang_abi() { 32 // CHECK: #3 0x{{.*}} in clang_abi {{.*}}clang_gcc_abi.cc:[[@LINE+1]] 33 asm volatile("push {r11, lr}\n\t" 34 "mov r11, sp\n\t" 35 "bl gcc_abi\n\t" 36 "add r0, r0, #1\n\t" 37 "pop {r11, pc}\n\t" 38 ); 39 } 40 41 int main() { 42 clang_abi(); 43 // CHECK: #4 0x{{.*}} in main {{.*}}clang_gcc_abi.cc:[[@LINE-1]] 44 } 45