objc-ptrauth.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (c) 2017 Apple Inc. All Rights Reserved.
  3. *
  4. * @APPLE_LICENSE_HEADER_START@
  5. *
  6. * This file contains Original Code and/or Modifications of Original Code
  7. * as defined in and that are subject to the Apple Public Source License
  8. * Version 2.0 (the 'License'). You may not use this file except in
  9. * compliance with the License. Please obtain a copy of the License at
  10. * http://www.opensource.apple.com/apsl/ and read it before using this
  11. * file.
  12. *
  13. * The Original Code and all software distributed under the License are
  14. * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  15. * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  16. * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
  18. * Please see the License for the specific language governing rights and
  19. * limitations under the License.
  20. *
  21. * @APPLE_LICENSE_HEADER_END@
  22. */
  23. #ifndef _OBJC_PTRAUTH_H_
  24. #define _OBJC_PTRAUTH_H_
  25. #include <objc/objc.h>
  26. // On some architectures, method lists and method caches store signed IMPs.
  27. // StorageSignedFunctionPointer is declared by libclosure.
  28. #include <Block_private.h>
  29. // fixme simply include ptrauth.h once all build trains have it
  30. #if __has_include (<ptrauth.h>)
  31. #include <ptrauth.h>
  32. #else
  33. #define ptrauth_strip(__value, __key) __value
  34. #define ptrauth_blend_discriminator(__pointer, __integer) ((uintptr_t)0)
  35. #define ptrauth_sign_constant(__value, __key, __data) __value
  36. #define ptrauth_sign_unauthenticated(__value, __key, __data) __value
  37. #define ptrauth_auth_and_resign(__value, __old_key, __old_data, __new_key, __new_data) __value
  38. #define ptrauth_auth_function(__value, __old_key, __old_data) __value
  39. #define ptrauth_auth_data(__value, __old_key, __old_data) __value
  40. #define ptrauth_string_discriminator(__string) ((int)0)
  41. #define ptrauth_sign_generic_data(__value, __data) ((ptrauth_generic_signature_t)0)
  42. #define __ptrauth_function_pointer
  43. #define __ptrauth_return_address
  44. #define __ptrauth_block_invocation_pointer
  45. #define __ptrauth_block_copy_helper
  46. #define __ptrauth_block_destroy_helper
  47. #define __ptrauth_block_byref_copy_helper
  48. #define __ptrauth_block_byref_destroy_helper
  49. #define __ptrauth_objc_method_list_imp
  50. #define __ptrauth_cxx_vtable_pointer
  51. #define __ptrauth_cxx_vtt_vtable_pointer
  52. #define __ptrauth_swift_heap_object_destructor
  53. #define __ptrauth_cxx_virtual_function_pointer(__declkey)
  54. #define __ptrauth_swift_function_pointer(__typekey)
  55. #define __ptrauth_swift_class_method_pointer(__declkey)
  56. #define __ptrauth_swift_protocol_witness_function_pointer(__declkey)
  57. #define __ptrauth_swift_value_witness_function_pointer(__key)
  58. #endif
  59. #if __has_feature(ptrauth_calls)
  60. // Method lists use process-independent signature for compatibility.
  61. // Method caches use process-dependent signature for extra protection.
  62. // (fixme not yet __ptrauth(...) because of `stp` inline asm in objc-cache.mm)
  63. using MethodListIMP = IMP __ptrauth_objc_method_list_imp;
  64. using MethodCacheIMP =
  65. StorageSignedFunctionPointer<IMP, ptrauth_key_process_dependent_code>;
  66. #else
  67. using MethodListIMP = IMP;
  68. using MethodCacheIMP = IMP;
  69. #endif
  70. // _OBJC_PTRAUTH_H_
  71. #endif