[compiler-rt] r349555 - [asan] Restore ODR-violation detection on vtables

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 18 14:23:30 PST 2018


Author: vitalybuka
Date: Tue Dec 18 14:23:30 2018
New Revision: 349555

URL: http://llvm.org/viewvc/llvm-project?rev=349555&view=rev
Log:
[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

Added:
    compiler-rt/trunk/test/asan/TestCases/Linux/odr-vtable.cc

Added: compiler-rt/trunk/test/asan/TestCases/Linux/odr-vtable.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/odr-vtable.cc?rev=349555&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/odr-vtable.cc (added)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/odr-vtable.cc Tue Dec 18 14:23:30 2018
@@ -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'




More information about the llvm-commits mailing list