5151#include < atomic>
5252#endif
5353
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+
5469static inline
5570bool
5671is_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
103118 info->dynamic_type = *(reinterpret_cast <const __class_type_info* const *>(ptr_to_ti_proxy));
104119#else
105120 void **vtable = *static_cast <void ** const *>(static_ptr);
121+ vtable = get_vtable (vtable);
106122 info->offset_to_derived = reinterpret_cast <ptrdiff_t >(vtable[-2 ]);
107123 info->dynamic_ptr = static_cast <const char *>(static_ptr) + info->offset_to_derived ;
108124 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,
561577 offset_to_base = __offset_flags >> __offset_shift;
562578 if (is_virtual) {
563579 const char * vtable = *static_cast <const char * const *>(adjustedPtr);
580+ vtable = get_vtable (vtable);
564581 offset_to_base = update_offset_to_base (vtable, offset_to_base);
565582 }
566583 } else if (!is_virtual) {
@@ -1501,6 +1518,7 @@ __base_class_type_info::search_above_dst(__dynamic_cast_info* info,
15011518 if (__offset_flags & __virtual_mask)
15021519 {
15031520 const char * vtable = *static_cast <const char *const *>(current_ptr);
1521+ vtable = get_vtable (vtable);
15041522 offset_to_base = update_offset_to_base (vtable, offset_to_base);
15051523 }
15061524 __base_type->search_above_dst (info, dst_ptr,
@@ -1521,6 +1539,7 @@ __base_class_type_info::search_below_dst(__dynamic_cast_info* info,
15211539 if (__offset_flags & __virtual_mask)
15221540 {
15231541 const char * vtable = *static_cast <const char *const *>(current_ptr);
1542+ vtable = get_vtable (vtable);
15241543 offset_to_base = update_offset_to_base (vtable, offset_to_base);
15251544 }
15261545 __base_type->search_below_dst (info,
0 commit comments