[libcxx-commits] [compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)

Anatoly Trosinenko via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 29 07:13:00 PDT 2025


================
@@ -103,10 +104,68 @@
 #define _LIBCXXABI_DTOR_FUNC
 #endif
 
-#if __cplusplus < 201103L
-#  define _LIBCXXABI_NOEXCEPT throw()
-#else
-#  define _LIBCXXABI_NOEXCEPT noexcept
+#if __has_include(<ptrauth.h>)
+#  include <ptrauth.h>
 #endif
 
+#if __has_extension(ptrauth_qualifier)
+
+// The actual value of the discriminators listed below is not important
+// beyond their impact on ABI. The derivation of the constants is only
+// being included for the purpose of maintaining a record of how they
+// were originally produced.
+
+// ptrauth_string_discriminator("__cxa_exception::actionRecord") == 0xFC91
+#  define __ptrauth_cxxabi_action_record \
+          __ptrauth(ptrauth_key_process_dependent_data, 1, 0xFC91)
+
+// ptrauth_string_discriminator("__cxa_exception::languageSpecificData") == 0xE8EE
+#  define __ptrauth_cxxabi_lsd \
+          __ptrauth(ptrauth_key_process_dependent_data, 1, 0xE8EE)
+
+// ptrauth_string_discriminator("__cxa_exception::catchTemp") == 0xFA58
+#  define __ptrauth_cxxabi_catch_temp \
+          __ptrauth(ptrauth_key_process_dependent_data, 1, 0xFA58)
+
+// ptrauth_string_discriminator("__cxa_exception::adjustedPtr") == 0x99E4
+#  define __ptrauth_cxxabi_adjusted_ptr \
+          __ptrauth(ptrauth_key_process_dependent_data, 1, 0x99E4)
+
+// ptrauth_string_discriminator("__cxa_exception::unexpectedHandler") == 0x99A9
+#  define __ptrauth_cxxabi_unexpected_handler \
+          __ptrauth(ptrauth_key_function_pointer, 1, 0x99A9)
+
+// ptrauth_string_discriminator("__cxa_exception::terminateHandler") == 0x0886)
+#  define __ptrauth_cxxabi_terminate_handler \
+          __ptrauth(ptrauth_key_function_pointer, 1, 0x886)
+
+// ptrauth_string_discriminator("__cxa_exception::exceptionDestructor") == 0xC088
+#  define __ptrauth_cxxabi_exception_destructor \
+          __ptrauth(ptrauth_key_function_pointer, 1, 0xC088)
+
+#  else
+
+#  define __ptrauth_cxxabi_action_record
+#  define __ptrauth_cxxabi_lsd
+#  define __ptrauth_cxxabi_catch_temp
+#  define __ptrauth_cxxabi_adjusted_ptr
+#  define __ptrauth_cxxabi_unexpected_handler
+#  define __ptrauth_cxxabi_terminate_handler
+#  define __ptrauth_cxxabi_exception_destructor
+
+#  endif
+
+// Helper wrappers for pointer auth qualifiers because we use a lot of variants
+// Suffixes:
+//  * _RI : qualifier is __ptrauth_restricted_intptr
+//  * PDD : key is ptrauth_key_process_dependent_data
+//  * FN  : key is ptrauth_key_function_pointer
+#define _LIBCXXABI_PTRAUTH_PDD(__discriminator)                                                                        \
+  _LIBCXXABI_PTRAUTH(ptrauth_key_process_dependent_data, /*__address_discriminated=*/1, __discriminator)
+#define _LIBCXXABI_PTRAUTH_FN(__discriminator)                                                                         \
+  _LIBCXXABI_PTRAUTH(ptrauth_key_function_pointer, /*__address_discriminated=*/1, __discriminator)
+#define _LIBCXXABI_PTRAUTH_RI_PDD(__discriminator)                                                                     \
+  _LIBCXXABI_PTRAUTH_RESTRICTED_INTPTR(ptrauth_key_process_dependent_data, /*__address_discriminated=*/1,              \
+                                       __discriminator)
+
----------------
atrosinenko wrote:

This seems to be unused now.

https://github.com/llvm/llvm-project/pull/143230


More information about the libcxx-commits mailing list