[PATCH] D55799: [asan] Restore ODR-violation detection on vtables
Vitaly Buka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 18 14:26:48 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349555: [asan] Restore ODR-violation detection on vtables (authored by vitalybuka, committed by ).
Herald added a subscriber: delcypher.
Changed prior to commit:
https://reviews.llvm.org/D55799?vs=178572&id=178787#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55799/new/
https://reviews.llvm.org/D55799
Files:
compiler-rt/trunk/test/asan/TestCases/Linux/odr-vtable.cc
llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/trunk/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
Index: llvm/trunk/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
===================================================================
--- llvm/trunk/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
+++ llvm/trunk/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll
@@ -14,4 +14,4 @@
; CHECK: @__asan_global_c = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [56 x i8] }* @c to i64), i64 8, i64 64, i64 ptrtoint ([2 x i8]* @___asan_gen_.3 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 -1 }
-; CHECK: @__asan_global_d = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [56 x i8] }* @d to i64), i64 8, i64 64, i64 ptrtoint ([2 x i8]* @___asan_gen_.4 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 -1 }
+; CHECK: @__asan_global_d = private global { i64, i64, i64, i64, i64, i64, i64, i64 } { i64 ptrtoint ({ [2 x i32], [56 x i8] }* @d to i64), i64 8, i64 64, i64 ptrtoint ([2 x i8]* @___asan_gen_.4 to i64), i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 0 }
Index: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -2199,8 +2199,8 @@
// ODR check is not useful for the following, but we see false reports
// caused by linker optimizations.
- if (NewGlobal->hasLocalLinkage() || NewGlobal->hasGlobalUnnamedAddr() ||
- NewGlobal->hasLinkOnceODRLinkage() || NewGlobal->hasWeakODRLinkage()) {
+ if (NewGlobal->hasLocalLinkage() || NewGlobal->hasLinkOnceODRLinkage() ||
+ NewGlobal->hasWeakODRLinkage()) {
ODRIndicator = ConstantExpr::getIntToPtr(ConstantInt::get(IntptrTy, -1),
IRB.getInt8PtrTy());
} else if (UseOdrIndicator) {
Index: compiler-rt/trunk/test/asan/TestCases/Linux/odr-vtable.cc
===================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/odr-vtable.cc
+++ compiler-rt/trunk/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'
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55799.178787.patch
Type: text/x-patch
Size: 2886 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181218/69fad8b2/attachment.bin>
More information about the llvm-commits
mailing list