brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · d92cb4c Raw
49 lines · cpp
1// RUN: mkdir -p %t.dir && cd %t.dir2// RUN: %clangxx -g -DSHARED_LIB %s -fPIC -shared -o %dynamiclib %ld_flags_rpath_so3// RUN: %clangxx_cfi_diag -g %s -o %t.dir/EXE %ld_flags_rpath_exe4// RUN: %run %t.dir/EXE 2>&1 | FileCheck %s5 6// REQUIRES: cxxabi7// UNSUPPORTED: target={{.*windows-msvc.*}}8 9#include <stdio.h>10#include <string.h>11 12struct A {13  virtual void f();14};15 16void *create_B();17 18#ifdef SHARED_LIB19 20struct B {21  virtual void f();22};23void B::f() {}24 25void *create_B() {26  return (void *)(new B());27}28 29#else30 31void A::f() {}32 33int main(int argc, char *argv[]) {34  void *p = create_B();35  // CHECK: runtime error: control flow integrity check for type 'A' failed during cast to unrelated type36  // CHECK: invalid vtable37  // CHECK: check failed in {{.*}}, vtable located in {{.*}}libtarget_uninstrumented.cpp.dynamic.so38  A *a = (A *)p;39  memset(p, 0, sizeof(A));40 41  // CHECK: runtime error: control flow integrity check for type 'A' failed during cast to unrelated type42  // CHECK: invalid vtable43  // CHECK: check failed in {{.*}}, vtable located in (unknown)44  a = (A *)p;45  // CHECK: done46  fprintf(stderr, "done %p\n", a);47}48#endif49