• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clangxx_hwasan -fomit-frame-pointer -momit-leaf-frame-pointer \
2 // RUN:   -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
3 // RUN: %clangxx_hwasan -fomit-frame-pointer -momit-leaf-frame-pointer \
4 // RUN:   -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
5 // RUN: %clangxx_hwasan -fomit-frame-pointer -momit-leaf-frame-pointer \
6 // RUN:   -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
7 // RUN: %clangxx_hwasan -fomit-frame-pointer -momit-leaf-frame-pointer \
8 // RUN:   -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
9 
10 // This test ensures that the CFA is implemented properly for slow
11 // (non-frame-pointer) unwinding.
12 #include <sanitizer/hwasan_interface.h>
13 #include <stdio.h>
14 #include <stdlib.h>
15 
f(int * p)16 __attribute__((noinline)) void f(int *p) { *p = 3; }
17 
18 // CHECK: ERROR: HWAddressSanitizer:
19 // CHECK: #0 {{.*}} in f(int*) {{.*}}register-dump-no-fp.cpp:[[@LINE-3]]
20 
main()21 int main() {
22   __hwasan_enable_allocator_tagging();
23 
24   int *volatile a = new int;
25   a = (int *)__hwasan_tag_pointer(a, 0);
26   f(a);
27   // CHECK: #1 {{.*}} in main {{.*}}register-dump-no-fp.cpp:[[@LINE-1]]
28 }
29