5050#include < atomic>
5151#endif
5252
53+ #if __has_feature(ptrauth_calls)
54+ #include < ptrauth.h>
55+ #endif
56+
57+
58+ template <typename T>
59+ static inline
60+ T *
61+ get_vtable (T *vtable) {
62+ #if __has_feature(ptrauth_calls)
63+ vtable = ptrauth_strip (vtable, ptrauth_key_cxx_vtable_pointer);
64+ #endif
65+ return vtable;
66+ }
67+
5368static inline
5469bool
5570is_equal (const std::type_info* x, const std::type_info* y, bool use_strcmp)
@@ -102,6 +117,7 @@ void dyn_cast_get_derived_info(derived_object_info* info, const void* static_ptr
102117 info->dynamic_type = *(reinterpret_cast <const __class_type_info* const *>(ptr_to_ti_proxy));
103118#else
104119 void **vtable = *static_cast <void ** const *>(static_ptr);
120+ vtable = get_vtable (vtable);
105121 info->offset_to_derived = reinterpret_cast <ptrdiff_t >(vtable[-2 ]);
106122 info->dynamic_ptr = static_cast <const char *>(static_ptr) + info->offset_to_derived ;
107123 info->dynamic_type = static_cast <const __class_type_info*>(vtable[-1 ]);
@@ -556,6 +572,7 @@ __base_class_type_info::has_unambiguous_public_base(__dynamic_cast_info* info,
556572 if (__offset_flags & __virtual_mask)
557573 {
558574 const char * vtable = *static_cast <const char *const *>(adjustedPtr);
575+ vtable = get_vtable (vtable);
559576 offset_to_base = update_offset_to_base (vtable, offset_to_base);
560577 }
561578 }
@@ -1475,6 +1492,7 @@ __base_class_type_info::search_above_dst(__dynamic_cast_info* info,
14751492 if (__offset_flags & __virtual_mask)
14761493 {
14771494 const char * vtable = *static_cast <const char *const *>(current_ptr);
1495+ vtable = get_vtable (vtable);
14781496 offset_to_base = update_offset_to_base (vtable, offset_to_base);
14791497 }
14801498 __base_type->search_above_dst (info, dst_ptr,
@@ -1495,6 +1513,7 @@ __base_class_type_info::search_below_dst(__dynamic_cast_info* info,
14951513 if (__offset_flags & __virtual_mask)
14961514 {
14971515 const char * vtable = *static_cast <const char *const *>(current_ptr);
1516+ vtable = get_vtable (vtable);
14981517 offset_to_base = update_offset_to_base (vtable, offset_to_base);
14991518 }
15001519 __base_type->search_below_dst (info,
0 commit comments