summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuxuan Chen <ych@meta.com>2025-10-22 12:06:31 -0700
committerYuxuan Chen <ych@meta.com>2025-10-22 12:06:31 -0700
commitad2687d5d850878d97b2227644601edcb6e235e5 (patch)
treea09d3137a6a5a1b971fc092a897dbd7b29970887
parent9a2e825c13655d955054bb65be5fc010c7ed69e3 (diff)
[compiler-rt] Check if the compiler supports __has_feature firstusers/yuxuanchen1997/compiler-rt-check-ptrauth-with-gcc-compat
-rw-r--r--compiler-rt/lib/builtins/gcc_personality_v0.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler-rt/lib/builtins/gcc_personality_v0.c b/compiler-rt/lib/builtins/gcc_personality_v0.c
index 3ed17fa788c2..1107c1087bc6 100644
--- a/compiler-rt/lib/builtins/gcc_personality_v0.c
+++ b/compiler-rt/lib/builtins/gcc_personality_v0.c
@@ -30,7 +30,13 @@ EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, void *, PCONTEXT,
_Unwind_Personality_Fn);
#endif
+#if defined(__has_feature)
#if __has_feature(ptrauth_calls)
+#define __compiler_rt_use_ptrauth
+#endif
+#endif
+
+#ifdef __compiler_rt_use_ptrauth
#include <ptrauth.h>
// `__ptrauth_restricted_intptr` is a feature of apple clang that predates
@@ -292,7 +298,7 @@ COMPILER_RT_ABI _Unwind_Reason_Code __gcc_personality_v0(
_Unwind_SetGR(context, __builtin_eh_return_data_regno(1), 0);
size_t __ptrauth_gcc_personality_lpad landingPad =
funcStart + landingPadOffset;
-#if __has_feature(ptrauth_calls)
+#ifdef __compiler_rt_use_ptrauth
uintptr_t stackPointer = _Unwind_GetGR(context, -2);
const uintptr_t existingDiscriminator = ptrauth_blend_discriminator(
&landingPad, __ptrauth_gcc_personality_lpad_disc);