summaryrefslogtreecommitdiff
path: root/test/cfi
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2016-01-28 00:37:54 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2016-01-28 00:37:54 +0000
commitb73838d55ad6824bb055971ee57d3db186fb6caf (patch)
treef378aa67bef0420376886b43240bc63a266b1e84 /test/cfi
parente34470ea0b7db132d41715542db49aaaece57387 (diff)
[cfi] Fix recovery from out-of-bounds vtable error.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@259007 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/cfi')
-rw-r--r--test/cfi/cross-dso/target_out_of_bounds.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/test/cfi/cross-dso/target_out_of_bounds.cpp b/test/cfi/cross-dso/target_out_of_bounds.cpp
index b7449c942..fbd664bce 100644
--- a/test/cfi/cross-dso/target_out_of_bounds.cpp
+++ b/test/cfi/cross-dso/target_out_of_bounds.cpp
@@ -20,9 +20,13 @@ int main(int argc, char *argv[]) {
// enough to handle unaddressable vtables. TODO: fix this.
void *empty = calloc(1, 128);
uintptr_t v = (uintptr_t)empty + 64;
- A *volatile p = new A();
- for (uintptr_t *q = (uintptr_t *)p; q < (uintptr_t *)(p + 1); ++q)
+ char *volatile p = reinterpret_cast<char *>(new A());
+ for (uintptr_t *q = (uintptr_t *)p; q < (uintptr_t *)(p + sizeof(A)); ++q)
*q = v;
+
+ // CHECK: runtime error: control flow integrity check for type 'A' failed during cast
+ A *volatile pa = reinterpret_cast<A *>(p);
+
// CHECK: untime error: control flow integrity check for type 'A' failed during virtual call
- p->f();
+ pa->f();
}