xref: /llvm-project/compiler-rt/test/hwasan/TestCases/hwasan_symbolize_stack_uas.cpp (revision f3f465ed144b47223caa091b5ea65d7234955aa1)
1 // RUN: rm -rf %t; mkdir %t
2 // RUN: %clang_hwasan -Wl,--build-id -g %s -o %t/hwasan_uas
3 // RUN: %env_hwasan_opts=symbolize=0 not %run %t/hwasan_uas 2>&1 | hwasan_symbolize --symbols %t --index | FileCheck %s
4 
5 // This doesn't work on X86, because that uses instrument-with-calls which
6 // disables frame records.
7 // REQUIRES: aarch64-target-arch
8 
9 #include <sanitizer/hwasan_interface.h>
10 #include <stdlib.h>
11 
12 static volatile char sink;
13 
14 int main(int argc, char **argv) {
15   volatile char *y;
16   {
17     volatile char x[10];
18     y = &x[0];
19   }
20   sink = *y;
21   // CHECK: Potentially referenced stack object:
22   // CHECK:   0 bytes inside a variable "x" in stack frame of function "main"
23   // CHECK:   at {{.*}}hwasan_symbolize_stack_uas.cpp:[[@LINE-6]]
24   return 0;
25 }
26