From c3c9611d33964f025771d078b9f41aa54963de42 Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Thu, 5 Sep 2024 18:12:24 -0700 Subject: [PATCH] Make __is_function_overridden pauth-aware on ELF platforms --- libcxx/src/include/overridable_function.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libcxx/src/include/overridable_function.h b/libcxx/src/include/overridable_function.h index e83ca7be7befa..6c70f6242ddd6 100644 --- a/libcxx/src/include/overridable_function.h +++ b/libcxx/src/include/overridable_function.h @@ -116,6 +116,11 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no uintptr_t __end = reinterpret_cast(&__stop___lcxx_override); uintptr_t __ptr = reinterpret_cast(__fptr); +# if __has_feature(ptrauth_calls) + // We must pass a void* to ptrauth_strip since it only accepts a pointer type. See full explanation above. + __ptr = reinterpret_cast(ptrauth_strip(reinterpret_cast(__ptr), ptrauth_key_function_pointer)); +# endif + return __ptr < __start || __ptr > __end; } _LIBCPP_END_NAMESPACE_STD