[compiler-rt] [libcxxabi] [libunwind] [runtimes][PAC] Harden unwinding when possible (#138571) (PR #143230)
Anatoly Trosinenko via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 29 07:13:02 PDT 2025
================
@@ -30,6 +30,50 @@ EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, void *, PCONTEXT,
_Unwind_Personality_Fn);
#endif
+#if __has_feature(ptrauth_qualifier)
+#include <ptrauth.h>
+#endif
+
+#if defined(__APPLE__) && __has_feature(ptrauth_qualifier)
+#if __has_feature(ptrauth_restricted_intptr_qualifier)
+#define __ptrauth_gcc_personality_intptr(key, addressDiscriminated, \
+ discriminator) \
+ __ptrauth_restricted_intptr(key, addressDiscriminated, discriminator)
+#else
+#define __ptrauth_gcc_personality_intptr(key, addressDiscriminated, \
+ discriminator) \
+ __ptrauth(key, addressDiscriminated, discriminator)
+#endif
+#else
+#define __ptrauth_gcc_personality_intptr(...)
+#endif
+
+// The actual value of the discriminators listed below is not important.
+// 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("__gcc_personality_v0'funcStart") == 0xDFEB
+#define __ptrauth_gcc_personality_func_start \
+ __ptrauth_gcc_personality_intptr(ptrauth_key_function_pointer, 1, 0xDFEB)
+
+// ptrauth_string_discriminator("__gcc_personality_v0'start") == 0x52DC
+#define __ptrauth_gcc_start \
+ __ptrauth_gcc_personality_intptr(ptrauth_key_function_pointer, 1, 0x52DC)
+
+// ptrauth_string_discriminator("__gcc_personality_v0'length") == 0xFFF7
+#define __ptrauth_gcc_length \
+ __ptrauth_gcc_personality_intptr(ptrauth_key_function_pointer, 1, 0xFFF7)
+
+// ptrauth_string_discriminator("__gcc_personality_v0'landingPadOffset") == 0x6498
+#define __ptrauth_gcc_personality_lpoffset \
+ __ptrauth_gcc_personality_intptr(ptrauth_key_function_pointer, 1, 0x6498)
+
+// ptrauth_string_discriminator("__gcc_personality_v0'landingPad")
+#define __ptrauth_personality_lpad_disc 0xA134
----------------
atrosinenko wrote:
Another possibly unintentional difference: `__ptrauth_personality` prefix.
https://github.com/llvm/llvm-project/pull/143230
More information about the llvm-commits
mailing list