diff options
author | Oliver Hunt <oliver@apple.com> | 2025-09-04 13:05:55 -0700 |
---|---|---|
committer | Oliver Hunt <oliver@apple.com> | 2025-09-04 13:05:55 -0700 |
commit | 1e5b4cb9fe008b3c74d3e5a4d9185ad7c718961d (patch) | |
tree | 2d81bf850a7c44965ccd711fabdc74004e38f2cf | |
parent | 4091c7af6aef5b1d42d37f65036aa3ca560ff218 (diff) | |
download | llvm-users/ojhunt/pointer-authenticated-unwinding.zip llvm-users/ojhunt/pointer-authenticated-unwinding.tar.gz llvm-users/ojhunt/pointer-authenticated-unwinding.tar.bz2 |
update libcxxabi formattingusers/ojhunt/pointer-authenticated-unwinding
-rw-r--r-- | libcxxabi/include/__cxxabi_config.h | 21 | ||||
-rw-r--r-- | libcxxabi/src/cxa_exception.cpp | 2 | ||||
-rw-r--r-- | libcxxabi/src/cxa_exception.h | 6 | ||||
-rw-r--r-- | libcxxabi/src/cxa_personality.cpp | 60 |
4 files changed, 36 insertions, 53 deletions
diff --git a/libcxxabi/include/__cxxabi_config.h b/libcxxabi/include/__cxxabi_config.h index 672926e..51b82124 100644 --- a/libcxxabi/include/__cxxabi_config.h +++ b/libcxxabi/include/__cxxabi_config.h @@ -110,32 +110,25 @@ #if __has_feature(ptrauth_calls) // ptrauth_string_discriminator("__cxa_exception::actionRecord") == 0xFC91 -# define __ptrauth_cxxabi_action_record \ - __ptrauth(ptrauth_key_process_dependent_data, 1, 0xFC91) +# define __ptrauth_cxxabi_action_record __ptrauth(ptrauth_key_process_dependent_data, 1, 0xFC91) // ptrauth_string_discriminator("__cxa_exception::languageSpecificData") == 0xE8EE -# define __ptrauth_cxxabi_lsd \ - __ptrauth(ptrauth_key_process_dependent_data, 1, 0xE8EE) +# define __ptrauth_cxxabi_lsd __ptrauth(ptrauth_key_process_dependent_data, 1, 0xE8EE) // ptrauth_string_discriminator("__cxa_exception::catchTemp") == 0xFA58 -# define __ptrauth_cxxabi_catch_temp \ - __ptrauth(ptrauth_key_process_dependent_data, 1, 0xFA58) +# define __ptrauth_cxxabi_catch_temp __ptrauth(ptrauth_key_process_dependent_data, 1, 0xFA58) // ptrauth_string_discriminator("__cxa_exception::adjustedPtr") == 0x99E4 -# define __ptrauth_cxxabi_adjusted_ptr \ - __ptrauth(ptrauth_key_process_dependent_data, 1, 0x99E4) +# define __ptrauth_cxxabi_adjusted_ptr __ptrauth(ptrauth_key_process_dependent_data, 1, 0x99E4) // ptrauth_string_discriminator("__cxa_exception::unexpectedHandler") == 0x99A9 -# define __ptrauth_cxxabi_unexpected_handler \ - __ptrauth(ptrauth_key_function_pointer, 1, 0x99A9) +# define __ptrauth_cxxabi_unexpected_handler __ptrauth(ptrauth_key_function_pointer, 1, 0x99A9) // ptrauth_string_discriminator("__cxa_exception::terminateHandler") == 0x0886) -# define __ptrauth_cxxabi_terminate_handler \ - __ptrauth(ptrauth_key_function_pointer, 1, 0x886) +# define __ptrauth_cxxabi_terminate_handler __ptrauth(ptrauth_key_function_pointer, 1, 0x886) // ptrauth_string_discriminator("__cxa_exception::exceptionDestructor") == 0xC088 -# define __ptrauth_cxxabi_exception_destructor \ - __ptrauth(ptrauth_key_function_pointer, 1, 0xC088) +# define __ptrauth_cxxabi_exception_destructor __ptrauth(ptrauth_key_function_pointer, 1, 0xC088) #else diff --git a/libcxxabi/src/cxa_exception.cpp b/libcxxabi/src/cxa_exception.cpp index 8a77e8c..73ba21c 100644 --- a/libcxxabi/src/cxa_exception.cpp +++ b/libcxxabi/src/cxa_exception.cpp @@ -194,7 +194,7 @@ void *__cxa_allocate_exception(size_t thrown_size) throw() { static_cast<__cxa_exception *>((void *)(raw_buffer + header_offset)); // We warn on memset to a non-trivially castable type. We might want to // change that diagnostic to not fire on a trivially obvious zero fill. - ::memset(static_cast<void *>(exception_header), 0, actual_size); + ::memset(static_cast<void*>(exception_header), 0, actual_size); return thrown_object_from_cxa_exception(exception_header); } diff --git a/libcxxabi/src/cxa_exception.h b/libcxxabi/src/cxa_exception.h index 97be422..aa8969e 100644 --- a/libcxxabi/src/cxa_exception.h +++ b/libcxxabi/src/cxa_exception.h @@ -47,8 +47,7 @@ struct _LIBCXXABI_HIDDEN __cxa_exception { // In Wasm, a destructor returns its argument void *(_LIBCXXABI_DTOR_FUNC *exceptionDestructor)(void *); #else - void (_LIBCXXABI_DTOR_FUNC* __ptrauth_cxxabi_exception_destructor - exceptionDestructor)(void*); + void(_LIBCXXABI_DTOR_FUNC* __ptrauth_cxxabi_exception_destructor exceptionDestructor)(void*); #endif std::unexpected_handler __ptrauth_cxxabi_unexpected_handler unexpectedHandler; std::terminate_handler __ptrauth_cxxabi_terminate_handler terminateHandler; @@ -89,8 +88,7 @@ struct _LIBCXXABI_HIDDEN __cxa_dependent_exception { #endif std::type_info *exceptionType; - void (_LIBCXXABI_DTOR_FUNC* __ptrauth_cxxabi_exception_destructor - exceptionDestructor)(void*); + void(_LIBCXXABI_DTOR_FUNC* __ptrauth_cxxabi_exception_destructor exceptionDestructor)(void*); std::unexpected_handler __ptrauth_cxxabi_unexpected_handler unexpectedHandler; std::terminate_handler __ptrauth_cxxabi_terminate_handler terminateHandler; diff --git a/libcxxabi/src/cxa_personality.cpp b/libcxxabi/src/cxa_personality.cpp index e3c8e7b..81ad3a0 100644 --- a/libcxxabi/src/cxa_personality.cpp +++ b/libcxxabi/src/cxa_personality.cpp @@ -25,45 +25,40 @@ // CXXABI depends on defintions in libunwind as pointer auth couples the // definitions -#include "libunwind.h" +# include "libunwind.h" // The actual value of the discriminators listed below is not important. // The derivation of the constants is only being included for the purpose // of maintaining a record of how they were originally produced. // ptrauth_string_discriminator("scan_results::languageSpecificData") == 0xE50D) -#define __ptrauth_scan_results_lsd \ - __ptrauth(ptrauth_key_process_dependent_code, 1, 0xE50D) +# define __ptrauth_scan_results_lsd __ptrauth(ptrauth_key_process_dependent_code, 1, 0xE50D) // ptrauth_string_discriminator("scan_results::actionRecord") == 0x9823 -#define __ptrauth_scan_results_action_record \ - __ptrauth(ptrauth_key_process_dependent_code, 1, 0x9823) +# define __ptrauth_scan_results_action_record __ptrauth(ptrauth_key_process_dependent_code, 1, 0x9823) // scan result is broken up as we have a manual re-sign that requires each component -#define __ptrauth_scan_results_landingpad_key ptrauth_key_process_dependent_code +# define __ptrauth_scan_results_landingpad_key ptrauth_key_process_dependent_code // ptrauth_string_discriminator("scan_results::landingPad") == 0xD27C -#define __ptrauth_scan_results_landingpad_disc 0xD27C -#define __ptrauth_scan_results_landingpad \ - __ptrauth(__ptrauth_scan_results_landingpad_key, 1, __ptrauth_scan_results_landingpad_disc) - -#if __has_extension(__ptrauth_restricted_intptr) -#define __ptrauth_scan_results_landingpad_intptr \ - __ptrauth_restricted_intptr(__ptrauth_scan_results_landingpad_key, 1, \ - __ptrauth_scan_results_landingpad_disc) -#else -#define __ptrauth_scan_results_landingpad_intptr \ - __ptrauth(__ptrauth_scan_results_landingpad_key, 1, \ - __ptrauth_scan_results_landingpad_disc) -#endif +# define __ptrauth_scan_results_landingpad_disc 0xD27C +# define __ptrauth_scan_results_landingpad \ + __ptrauth(__ptrauth_scan_results_landingpad_key, 1, __ptrauth_scan_results_landingpad_disc) + +# if __has_extension(__ptrauth_restricted_intptr) +# define __ptrauth_scan_results_landingpad_intptr \ + __ptrauth_restricted_intptr(__ptrauth_scan_results_landingpad_key, 1, __ptrauth_scan_results_landingpad_disc) +# else +# define __ptrauth_scan_results_landingpad_intptr \ + __ptrauth(__ptrauth_scan_results_landingpad_key, 1, __ptrauth_scan_results_landingpad_disc) +# endif #else -#define __ptrauth_scan_results_lsd -#define __ptrauth_scan_results_action_record -#define __ptrauth_scan_results_landingpad -#define __ptrauth_scan_results_landingpad_intptr +# define __ptrauth_scan_results_lsd +# define __ptrauth_scan_results_action_record +# define __ptrauth_scan_results_landingpad +# define __ptrauth_scan_results_landingpad_intptr #endif - // TODO: This is a temporary workaround for libc++abi to recognize that it's being // built against LLVM's libunwind. LLVM's libunwind started reporting _LIBUNWIND_VERSION // in LLVM 15 -- we can remove this workaround after shipping LLVM 17. Once we remove @@ -577,9 +572,9 @@ typedef void* __ptrauth_scan_results_landingpad landing_pad_ptr_t; struct scan_results { int64_t ttypeIndex; // > 0 catch handler, < 0 exception spec handler, == 0 a cleanup - action_ptr_t actionRecord; // Currently unused. Retained to ease future maintenance. - lsd_ptr_t languageSpecificData; // Needed only for __cxa_call_unexpected - landing_pad_t landingPad; // null -> nothing found, else something found + action_ptr_t actionRecord; // Currently unused. Retained to ease future maintenance. + lsd_ptr_t languageSpecificData; // Needed only for __cxa_call_unexpected + landing_pad_t landingPad; // null -> nothing found, else something found void* adjustedPtr; // Used in cxa_exception.cpp _Unwind_Reason_Code reason; // One of _URC_FATAL_PHASE1_ERROR, // _URC_FATAL_PHASE2_ERROR, @@ -634,14 +629,11 @@ set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context, auto stackPointer = _Unwind_GetGR(context, UNW_REG_SP); // We manually re-sign the IP as the __ptrauth qualifiers cannot // express the required relationship with the destination address - const auto existingDiscriminator = ptrauth_blend_discriminator( - &results.landingPad, __ptrauth_scan_results_landingpad_disc); + const auto existingDiscriminator = + ptrauth_blend_discriminator(&results.landingPad, __ptrauth_scan_results_landingpad_disc); unw_word_t newIP /* opaque __ptrauth(ptrauth_key_return_address, stackPointer, 0) */ = - (unw_word_t)ptrauth_auth_and_resign(*(void* const*)&results.landingPad, - __ptrauth_scan_results_landingpad_key, - existingDiscriminator, - ptrauth_key_return_address, - stackPointer); + (unw_word_t)ptrauth_auth_and_resign(*(void* const*)&results.landingPad, __ptrauth_scan_results_landingpad_key, + existingDiscriminator, ptrauth_key_return_address, stackPointer); _Unwind_SetIP(context, newIP); #else _Unwind_SetIP(context, results.landingPad); |