| 1 |
// RUN: %clang_cc1 %s -triple=aarch64-unknown-fuchsia -o - -emit-llvm -fsanitize=hwaddress | FileCheck %s |
| 2 |
|
| 3 |
/// The usual vtable will have default visibility. In this case, the actual |
| 4 |
/// vtable is hidden and the alias is made public. With hwasan enabled, we want |
| 5 |
/// to ensure the local one self-referenced in the hidden vtable is not |
| 6 |
/// hwasan-instrumented. |
| 7 |
// CHECK-DAG: @_ZTV1A.local = internal unnamed_addr constant { [3 x i32] } { [3 x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint (ptr @_ZTI1A.rtti_proxy to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr dso_local_equivalent @_ZN1A3fooEv to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32)] }, no_sanitize_hwaddress, align 4 |
| 8 |
// CHECK-DAG: @_ZTV1A = unnamed_addr alias { [3 x i32] }, ptr @_ZTV1A.local |
| 9 |
// CHECK-DAG: @_ZTI1A.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr @_ZTI1A, no_sanitize_hwaddress, comdat |
| 10 |
|
| 11 |
class A { |
| 12 |
public: |
| 13 |
virtual void foo(); |
| 14 |
}; |
| 15 |
|
| 16 |
void A::foo() {} |
| 17 |
|
| 18 |
void A_foo(A *a) { |
| 19 |
a->foo(); |
| 20 |
} |
| 21 |
|
| 22 |
/// If the vtable happens to be hidden, then the alias is not needed. In this |
| 23 |
/// case, the original vtable struct itself should be unsanitized. |
| 24 |
// CHECK-DAG: @_ZTV1B = hidden unnamed_addr constant { [3 x i32] } { [3 x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint (ptr @_ZTI1B.rtti_proxy to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1B, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr dso_local_equivalent @_ZN1B3fooEv to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1B, i32 0, i32 0, i32 2) to i64)) to i32)] }, no_sanitize_hwaddress, align 4 |
| 25 |
// CHECK-DAG: @_ZTI1B.rtti_proxy = linkonce_odr hidden unnamed_addr constant ptr @_ZTI1B, no_sanitize_hwaddress, comdat |
| 26 |
|
| 27 |
class __attribute__((visibility("hidden"))) B { |
| 28 |
public: |
| 29 |
virtual void foo(); |
| 30 |
}; |
| 31 |
|
| 32 |
void B::foo() {} |
| 33 |
|
| 34 |
void B_foo(B *b) { |
| 35 |
b->foo(); |
| 36 |
} |