brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 314e7d3 Raw
45 lines · cpp
1// RUN: %clangxx_asan -O0 -x c %s -o %t && not %env_asan_opts=fast_unwind_on_malloc=1 %run %t 2>&1 | FileCheck %s2// RUN: %clangxx_asan -O1 -x c %s -o %t && not %env_asan_opts=fast_unwind_on_malloc=1 %run %t 2>&1 | FileCheck %s3// RUN: %clangxx_asan -O2 -x c %s -o %t && not %env_asan_opts=fast_unwind_on_malloc=1 %run %t 2>&1 | FileCheck %s4// RUN: %clangxx_asan -O3 -x c %s -o %t && not %env_asan_opts=fast_unwind_on_malloc=1 %run %t 2>&1 | FileCheck %s5 6// REQUIRES: (arm-target-arch || armhf-target-arch), fast-unwinder-works7 8#include <stdlib.h>9 10__attribute__((noinline))11int boom() {12  volatile int three = 3;13  char * volatile s = (char *)malloc(three);14// CHECK: #1 0x{{.*}} in boom {{.*}}clang_gcc_abi.cpp:[[@LINE-1]]15  return s[three]; //BOOM16}17 18__attribute__((naked, noinline)) void gcc_abi() {19// CHECK: #2 0x{{.*}} in gcc_abi {{.*}}clang_gcc_abi.cpp:[[@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.cpp:[[@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 41int main() {42  clang_abi();43// CHECK: #4 0x{{.*}} in main {{.*}}clang_gcc_abi.cpp:[[@LINE-1]]44}45