51
51
#include < atomic>
52
52
#endif
53
53
54
+ #if __has_feature(ptrauth_calls)
55
+ #include < ptrauth.h>
56
+ #endif
57
+
58
+
59
+ template <typename T>
60
+ static inline
61
+ T *
62
+ get_vtable (T *vtable) {
63
+ #if __has_feature(ptrauth_calls)
64
+ vtable = ptrauth_strip (vtable, ptrauth_key_cxx_vtable_pointer);
65
+ #endif
66
+ return vtable;
67
+ }
68
+
54
69
static inline
55
70
bool
56
71
is_equal (const std::type_info* x, const std::type_info* y, bool use_strcmp)
@@ -103,6 +118,7 @@ void dyn_cast_get_derived_info(derived_object_info* info, const void* static_ptr
103
118
info->dynamic_type = *(reinterpret_cast <const __class_type_info* const *>(ptr_to_ti_proxy));
104
119
#else
105
120
void **vtable = *static_cast <void ** const *>(static_ptr);
121
+ vtable = get_vtable (vtable);
106
122
info->offset_to_derived = reinterpret_cast <ptrdiff_t >(vtable[-2 ]);
107
123
info->dynamic_ptr = static_cast <const char *>(static_ptr) + info->offset_to_derived ;
108
124
info->dynamic_type = static_cast <const __class_type_info*>(vtable[-1 ]);
@@ -561,6 +577,7 @@ __base_class_type_info::has_unambiguous_public_base(__dynamic_cast_info* info,
561
577
offset_to_base = __offset_flags >> __offset_shift;
562
578
if (is_virtual) {
563
579
const char * vtable = *static_cast <const char * const *>(adjustedPtr);
580
+ vtable = get_vtable (vtable);
564
581
offset_to_base = update_offset_to_base (vtable, offset_to_base);
565
582
}
566
583
} else if (!is_virtual) {
@@ -1501,6 +1518,7 @@ __base_class_type_info::search_above_dst(__dynamic_cast_info* info,
1501
1518
if (__offset_flags & __virtual_mask)
1502
1519
{
1503
1520
const char * vtable = *static_cast <const char *const *>(current_ptr);
1521
+ vtable = get_vtable (vtable);
1504
1522
offset_to_base = update_offset_to_base (vtable, offset_to_base);
1505
1523
}
1506
1524
__base_type->search_above_dst (info, dst_ptr,
@@ -1521,6 +1539,7 @@ __base_class_type_info::search_below_dst(__dynamic_cast_info* info,
1521
1539
if (__offset_flags & __virtual_mask)
1522
1540
{
1523
1541
const char * vtable = *static_cast <const char *const *>(current_ptr);
1542
+ vtable = get_vtable (vtable);
1524
1543
offset_to_base = update_offset_to_base (vtable, offset_to_base);
1525
1544
}
1526
1545
__base_type->search_below_dst (info,
0 commit comments