Skip to content

Commit 9fd523c

Browse files
committed
Update to prioritise __PTRAUTH__ where possible
1 parent b3dce55 commit 9fd523c

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

clang/docs/PointerAuthentication.rst

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -400,17 +400,25 @@ Feature testing
400400
Whether the current target uses pointer authentication can be tested for with
401401
a number of different tests.
402402

403-
- ``__has_feature(ptrauth_intrinsics)`` is true if ``<ptrauth.h>`` provides its
404-
normal interface. This may be true even on targets where pointer
405-
authentication is not enabled by default.
403+
- ``__PTRAUTH__`` macro is defined if ``<ptrauth.h>`` provides its normal
404+
interface. This implies support for the pointer authentication intrinsics
405+
and the ``__ptrauth`` qualifier.
406406

407407
- ``__has_feature(ptrauth_returns)`` is true if the target uses pointer
408408
authentication to protect return addresses.
409409

410410
- ``__has_feature(ptrauth_calls)`` is true if the target uses pointer
411-
authentication to protect indirect branches. This implies
412-
``__has_feature(ptrauth_returns)`` and
413-
``__has_feature(ptrauth_intrinsics)``.
411+
authentication to protect indirect branches. On arm64e this implies
412+
``__has_feature(ptrauth_returns)``, ``__has_feature(ptrauth_intrinsics)``,
413+
and the ``__PTRAUTH__`` macro.
414+
415+
- For backwards compatibility purposes ``__has_feature(ptrauth_intrinsics)``
416+
and ``__has_feature(ptrauth_qualifier)`` are available on arm64e targets.
417+
These features are synonymous with each other, and are equivalent to testing
418+
for the ``__PTRAUTH__`` macro definition. Use of these features should be
419+
restricted to cases where backwards compatibility is required, and should be
420+
paired with ``defined(__PTRAUTH__)``.
421+
414422

415423
Clang provides several other tests only for historical purposes; for current
416424
purposes they are all equivalent to ``ptrauth_calls``.
@@ -848,7 +856,7 @@ functions can also be signed with address diversity:
848856

849857
.. code-block:: c
850858
851-
#if __has_feature(ptrauth_calls)
859+
#if defined(__PTRAUTH__)
852860
#define objectOperation(discriminator) \
853861
__ptrauth(ptrauth_key_function_pointer, 1, discriminator)
854862
#else

0 commit comments

Comments
 (0)