aboutsummaryrefslogtreecommitdiff
path: root/clang/docs
diff options
context:
space:
mode:
authorAhmed Bougacha <ahmed@bougacha.org>2024-06-20 12:09:54 -0700
committerGitHub <noreply@github.com>2024-06-20 12:09:54 -0700
commit7c814c13d0df6dbd0ef6a8b2be214d3f6edbb566 (patch)
tree1b86178fc5466607e05b338924be525d1d01b0d5 /clang/docs
parent50b919378186ebb59e2dd402720f6ea8576d2477 (diff)
downloadllvm-7c814c13d0df6dbd0ef6a8b2be214d3f6edbb566.zip
llvm-7c814c13d0df6dbd0ef6a8b2be214d3f6edbb566.tar.gz
llvm-7c814c13d0df6dbd0ef6a8b2be214d3f6edbb566.tar.bz2
[clang] Define ptrauth_sign_constant builtin. (#93904)
This is a constant-expression equivalent to ptrauth_sign_unauthenticated. Its constant nature lets us guarantee a non-attackable sequence is generated, unlike ptrauth_sign_unauthenticated which we generally discourage using. It being a constant also allows its usage in global initializers, though requiring constant pointers and discriminators. The value must be a constant expression of pointer type which evaluates to a non-null pointer. The key must be a constant expression of type ptrauth_key. The extra data must be a constant expression of pointer or integer type; if an integer, it will be coerced to ptrauth_extra_data_t. The result will have the same type as the original value. This can be used in constant expressions. Co-authored-by: John McCall <rjmccall@apple.com>
Diffstat (limited to 'clang/docs')
-rw-r--r--clang/docs/PointerAuthentication.rst19
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/docs/PointerAuthentication.rst b/clang/docs/PointerAuthentication.rst
index 130e657..68674f3 100644
--- a/clang/docs/PointerAuthentication.rst
+++ b/clang/docs/PointerAuthentication.rst
@@ -356,6 +356,25 @@ Given that ``signedPointer`` matches the layout for signed pointers signed with
the given key, extract the raw pointer from it. This operation does not trap
and cannot fail, even if the pointer is not validly signed.
+``ptrauth_sign_constant``
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. code-block:: c
+
+ ptrauth_sign_constant(pointer, key, discriminator)
+
+Return a signed pointer for a constant address in a manner which guarantees
+a non-attackable sequence.
+
+``pointer`` must be a constant expression of pointer type which evaluates to
+a non-null pointer.
+``key`` must be a constant expression of type ``ptrauth_key``.
+``discriminator`` must be a constant expression of pointer or integer type;
+if an integer, it will be coerced to ``ptrauth_extra_data_t``.
+The result will have the same type as ``pointer``.
+
+This can be used in constant expressions.
+
``ptrauth_sign_unauthenticated``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^