Skip to content

Commit 1020085

Browse files
committed
[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 llvm-svn: 348986
1 parent 967ce40 commit 1020085

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

compiler-rt/lib/hwasan/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ foreach(arch ${HWASAN_SUPPORTED_ARCH})
145145
RTSanitizerCommonCoverage
146146
RTSanitizerCommonSymbolizer
147147
RTUbsan
148+
RTUbsan_cxx
148149
# The only purpose of RTHWAsan_dynamic_version_script_dummy is to
149150
# carry a dependency of the shared runtime on the version script.
150151
# Replacing it with a straightforward
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %clang_hwasan -fsanitize=cfi -fno-sanitize-trap=cfi -flto -fvisibility=hidden -fuse-ld=lld %s -o %t
2+
// RUN: not %run %t 2>&1 | FileCheck %s
3+
4+
// REQUIRES: android
5+
6+
// Smoke test for CFI + HWASAN.
7+
8+
struct A {
9+
virtual void f();
10+
};
11+
12+
void A::f() {}
13+
14+
int main() {
15+
// CHECK: control flow integrity check for type {{.*}} failed during cast to unrelated type
16+
A *a = reinterpret_cast<A *>(reinterpret_cast<void *>(&main));
17+
(void)a;
18+
}

0 commit comments

Comments
 (0)