[compiler-rt] r348986 - [hwasan] Link ubsan_cxx to shared runtime library.

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 12 14:56:00 PST 2018


Author: eugenis
Date: Wed Dec 12 14:56:00 2018
New Revision: 348986

URL: http://llvm.org/viewvc/llvm-project?rev=348986&view=rev
Log:
[hwasan] Link ubsan_cxx to shared runtime library.

Summary: This is needed for C++-specific ubsan and cfi error reporting to work.

Reviewers: kcc, vitalybuka

Subscribers: srhines, kubamracek, mgorny, llvm-commits

Differential Revision: https://reviews.llvm.org/D55589

Added:
    compiler-rt/trunk/test/hwasan/TestCases/cfi.cc
Modified:
    compiler-rt/trunk/lib/hwasan/CMakeLists.txt

Modified: compiler-rt/trunk/lib/hwasan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/hwasan/CMakeLists.txt?rev=348986&r1=348985&r2=348986&view=diff
==============================================================================
--- compiler-rt/trunk/lib/hwasan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/hwasan/CMakeLists.txt Wed Dec 12 14:56:00 2018
@@ -145,6 +145,7 @@ foreach(arch ${HWASAN_SUPPORTED_ARCH})
             RTSanitizerCommonCoverage
             RTSanitizerCommonSymbolizer
             RTUbsan
+            RTUbsan_cxx
             # The only purpose of RTHWAsan_dynamic_version_script_dummy is to
             # carry a dependency of the shared runtime on the version script.
             # Replacing it with a straightforward

Added: compiler-rt/trunk/test/hwasan/TestCases/cfi.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/hwasan/TestCases/cfi.cc?rev=348986&view=auto
==============================================================================
--- compiler-rt/trunk/test/hwasan/TestCases/cfi.cc (added)
+++ compiler-rt/trunk/test/hwasan/TestCases/cfi.cc Wed Dec 12 14:56:00 2018
@@ -0,0 +1,18 @@
+// RUN: %clang_hwasan -fsanitize=cfi -fno-sanitize-trap=cfi -flto -fvisibility=hidden -fuse-ld=lld %s -o %t
+// RUN: not %run %t 2>&1 | FileCheck %s
+
+// REQUIRES: android
+
+// Smoke test for CFI + HWASAN.
+
+struct A {
+  virtual void f();
+};
+
+void A::f() {}
+
+int main() {
+  // CHECK: control flow integrity check for type {{.*}} failed during cast to unrelated type
+  A *a = reinterpret_cast<A *>(reinterpret_cast<void *>(&main));
+  (void)a;
+}




More information about the llvm-commits mailing list