File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -592,6 +592,36 @@ The result value is never zero and always within range for both the
592592
593593This can be used in constant expressions.
594594
595+ ``ptrauth_type_discriminator ``
596+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
597+
598+ .. code-block :: c
599+
600+ ptrauth_type_discriminator(type)
601+
602+ Compute the constant discriminator derived from the given type, as is computed
603+ for automatically type diversified schemas.
604+
605+ ``type `` must be a type. The result has the type ``ptrauth_extra_data_t ``.
606+
607+ This can be used in constant expressions.
608+
609+ ``ptrauth_function_pointer_type_discriminator ``
610+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
611+
612+ .. code-block :: c
613+
614+ ptrauth_function_pointer_type_discriminator(function_type)
615+
616+ Compute the constant discriminator derived from the provided function type, for
617+ use in contexts where the default function authentication schema. If function
618+ pointer type diversity is enabled, this is equivalent to
619+ `ptrauth_type_discriminator(function_type) `, if it is not enabled this is `0 `.
620+
621+ ``function_type `` must be a function type. The result has the type ``ptrauth_extra_data_t ``.
622+
623+ This can be used in constant expressions.
624+
595625``ptrauth_strip ``
596626^^^^^^^^^^^^^^^^^
597627
Original file line number Diff line number Diff line change @@ -241,6 +241,18 @@ typedef __UINTPTR_TYPE__ ptrauth_generic_signature_t;
241241#define ptrauth_type_discriminator (__type ) \
242242 __builtin_ptrauth_type_discriminator(__type)
243243
244+ /* Compute the constant discriminator used by Clang to sign pointers with the
245+ given C function pointer type.
246+
247+ A call to this function is an integer constant expression. */
248+ #if __has_feature (ptrauth_function_pointer_type_discrimination )
249+ #define ptrauth_function_pointer_type_discriminator (__type ) \
250+ __builtin_ptrauth_type_discriminator(__type)
251+ #else
252+ #define ptrauth_function_pointer_type_discriminator (__type ) \
253+ ((ptrauth_extra_data_t)0)
254+ #endif
255+
244256/* Compute a signature for the given pair of pointer-sized values.
245257 The order of the arguments is significant.
246258
@@ -372,6 +384,8 @@ typedef __UINTPTR_TYPE__ ptrauth_generic_signature_t;
372384 })
373385
374386#define ptrauth_type_discriminator (__type ) ((ptrauth_extra_data_t)0)
387+ #define ptrauth_function_pointer_type_discriminator (__type ) \
388+ ((ptrauth_extra_data_t)0)
375389
376390#define ptrauth_sign_generic_data (__value , __data ) \
377391 ({ \
You can’t perform that action at this time.
0 commit comments