================
@@ -199,6 +199,25 @@ typedef __UINTPTR_TYPE__ ptrauth_generic_signature_t;
ptrauth_auth_and_resign(__value, __old_key, __old_data,
\
ptrauth_key_function_pointer, 0)
+/* Cast a value to the given type without changing any signature.
+
+ The type must be a pointer sized type compatible with the __ptrauth
+ qualifier.
+ The value must be an expression with a non-address diversified pointer
+ authentication schema, and will be converted to an rvalue prior to the cast.
+ The result has type given by the first argument.
+
+ The result has an identical bit-pattern to the input pointer. */
+#define ptrauth_nop_cast(__type, __value)
\
+ ({
\
+ union {
\
+ typeof(*(__value)) *__fptr;
\
+ typeof(__type) __opaque;
\
+ } __storage;
\
+ __storage.__fptr = (__value);
\
+ __storage.__opaque;
\
----------------
kovdan01 wrote:
While this should be valid in C, in C++ reading from the member of the union
that wasn't most recently written is technically UB:
https://en.cppreference.com/w/cpp/language/union.html.
I think we need to conform to C++ standard and use smth like `memcpy` for doing
such a trick.
https://github.com/llvm/llvm-project/pull/161027
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits