[libcxx-commits] [libcxx] [PAC] Make __is_function_overridden pauth-aware on ELF platforms (PR #107498)

Anton Korobeynikov via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 9 12:30:52 PDT 2024


https://github.com/asl updated https://github.com/llvm/llvm-project/pull/107498

>From c3c9611d33964f025771d078b9f41aa54963de42 Mon Sep 17 00:00:00 2001
From: Anton Korobeynikov <anton at korobeynikov.info>
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 e83ca7be7befaf..6c70f6242ddd63 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<uintptr_t>(&__stop___lcxx_override);
   uintptr_t __ptr   = reinterpret_cast<uintptr_t>(__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<uintptr_t>(ptrauth_strip(reinterpret_cast<void*>(__ptr), ptrauth_key_function_pointer));
+#  endif
+
   return __ptr < __start || __ptr > __end;
 }
 _LIBCPP_END_NAMESPACE_STD



More information about the libcxx-commits mailing list