1 //===-- sanitizer_ptrauth.h -------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef SANITIZER_PTRAUTH_H
10 #define SANITIZER_PTRAUTH_H
12 #if __has_feature(ptrauth_calls)
14 #elif defined(__ARM_FEATURE_PAC_DEFAULT) && !defined(__APPLE__)
15 inline unsigned long ptrauth_strip(void* __value
, unsigned int __key
) {
16 // On the stack the link register is protected with Pointer
17 // Authentication Code when compiled with -mbranch-protection.
18 // Let's stripping the PAC unconditionally because xpaclri is in
19 // the NOP space so will do nothing when it is not enabled or not available.
23 "hint #7\n\t" // xpaclri
30 #define ptrauth_auth_data(__value, __old_key, __old_data) __value
31 #define ptrauth_string_discriminator(__string) ((int)0)
33 // Copied from <ptrauth.h>
34 #define ptrauth_strip(__value, __key) __value
35 #define ptrauth_auth_data(__value, __old_key, __old_data) __value
36 #define ptrauth_string_discriminator(__string) ((int)0)
39 #define STRIP_PAC_PC(pc) ((uptr)ptrauth_strip(pc, 0))
41 #endif // SANITIZER_PTRAUTH_H