summaryrefslogtreecommitdiff
path: root/test/asan/TestCases
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2018-12-18 22:23:30 +0000
committerVitaly Buka <vitalybuka@google.com>2018-12-18 22:23:30 +0000
commite5234636b7b6844d6ad373d67b86b2764716f13d (patch)
treed83a006b3853a41d644883db6f762d57c2ec1462 /test/asan/TestCases
parentdceff363658aa209fc5e3ccc85b10be1575631e5 (diff)
downloadcompiler-rt-e5234636b7b6844d6ad373d67b86b2764716f13d.tar.gz
[asan] Restore ODR-violation detection on vtables
Summary: unnamed_addr is still useful for detecting of ODR violations on vtables Still unnamed_addr with lld and --icf=safe or --icf=all can trigger false reports which can be avoided with --icf=none or by using private aliases with -fsanitize-address-use-odr-indicator Reviewers: eugenis Reviewed By: eugenis Subscribers: kubamracek, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D55799 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@349555 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/asan/TestCases')
-rw-r--r--test/asan/TestCases/Linux/odr-vtable.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/asan/TestCases/Linux/odr-vtable.cc b/test/asan/TestCases/Linux/odr-vtable.cc
new file mode 100644
index 000000000..70ea4c970
--- /dev/null
+++ b/test/asan/TestCases/Linux/odr-vtable.cc
@@ -0,0 +1,26 @@
+// RUN: %clangxx_asan -fno-rtti -DBUILD_SO1 -fPIC -shared %s -o %t1.so
+// RUN: %clangxx_asan -fno-rtti -DBUILD_SO2 -fPIC -shared %s -o %t2.so
+// RUN: %clangxx_asan -fno-rtti %t1.so %t2.so %s -Wl,-R. -o %t
+// RUN: %env_asan_opts=fast_unwind_on_malloc=0:detect_odr_violation=2 not %run %t 2>&1 | FileCheck %s
+
+struct XYZ {
+ virtual void foo();
+};
+
+#if defined(BUILD_SO1)
+
+void XYZ::foo() {}
+
+#elif defined(BUILD_SO2)
+
+void XYZ::foo() {}
+
+#else
+
+int main() {}
+
+#endif
+
+// CHECK: AddressSanitizer: odr-violation
+// CHECK-NEXT: 'vtable for XYZ'
+// CHECK-NEXT: 'vtable for XYZ'