Files
clang-p2996/compiler-rt/test/hwasan/TestCases/stack-uar-dynamic.c
Matt Morehouse 0867edfc64 [HWASan] Add basic stack tagging support for LAM.
Adds the basic instrumentation needed for stack tagging.

Currently does not support stack short granules or TLS stack histories,
since a different code path is followed for the callback instrumentation
we use.

We may simply wait to support these two features until we switch to
a custom calling convention.

Patch By: xiangzhangllvm, morehouse

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D102901
2021-06-11 08:21:17 -07:00

27 lines
598 B
C

// RUN: %clang_hwasan -g %s -o %t && not %run %t 2>&1 | FileCheck %s
// Dynamic allocation of stack objects does not affect FP, so the backend should
// still be using FP-relative debug info locations that we can use to find stack
// objects.
// Stack histories are currently not recorded on x86.
// XFAIL: x86_64
__attribute((noinline))
char *buggy(int b) {
char c[64];
char *volatile p = c;
if (b) {
p = __builtin_alloca(64);
p = c;
}
return p;
}
int main() {
char *p = buggy(1);
// CHECK: Potentially referenced stack objects:
// CHECK-NEXT: c in buggy
p[0] = 0;
}