diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2015-02-21 01:36:08 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2015-02-21 01:36:08 +0000 |
commit | 4f329a291f815d455decdbccb3c61a22226f43f1 (patch) | |
tree | b8b202369090b42fc0230ccff2eb28814dd8a042 /test/cfi/overwrite.cpp | |
parent | 061391b2a6bc3cded72268ab3af4677cb6fca45e (diff) |
CFI: Add tests for 32-bit, 64-bit and memory bitsets. Break optimization in more places.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@230116 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/cfi/overwrite.cpp')
-rw-r--r-- | test/cfi/overwrite.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/cfi/overwrite.cpp b/test/cfi/overwrite.cpp index 74cb3fdcb..d7e58d927 100644 --- a/test/cfi/overwrite.cpp +++ b/test/cfi/overwrite.cpp @@ -1,6 +1,15 @@ // RUN: %clangxx_cfi -o %t %s // RUN: not --crash %t 2>&1 | FileCheck --check-prefix=CFI %s +// RUN: %clangxx_cfi -DB32 -o %t %s +// RUN: not --crash %t 2>&1 | FileCheck --check-prefix=CFI %s + +// RUN: %clangxx_cfi -DB64 -o %t %s +// RUN: not --crash %t 2>&1 | FileCheck --check-prefix=CFI %s + +// RUN: %clangxx_cfi -DBM -o %t %s +// RUN: not --crash %t 2>&1 | FileCheck --check-prefix=CFI %s + // RUN: %clangxx -o %t %s // RUN: %t 2>&1 | FileCheck --check-prefix=NCFI %s @@ -10,6 +19,7 @@ // attempting to make a call through it. #include <stdio.h> +#include "utils.h" struct A { virtual void f(); @@ -24,8 +34,24 @@ void foo() { void *fake_vtable[] = { (void *)&foo }; int main() { +#ifdef B32 + break_optimization(new Deriver<A, 0>); +#endif + +#ifdef B64 + break_optimization(new Deriver<A, 0>); + break_optimization(new Deriver<A, 1>); +#endif + +#ifdef BM + break_optimization(new Deriver<A, 0>); + break_optimization(new Deriver<A, 1>); + break_optimization(new Deriver<A, 2>); +#endif + A *a = new A; *((void **)a) = fake_vtable; // UB here + break_optimization(a); // CFI: 1 // NCFI: 1 |