|
25 | 25 |
|
26 | 26 | // CXXABI depends on defintions in libunwind as pointer auth couples the
|
27 | 27 | // definitions
|
28 |
| -#include "libunwind.h" |
| 28 | +# include "libunwind.h" |
29 | 29 |
|
30 | 30 | // The actual value of the discriminators listed below is not important.
|
31 | 31 | // The derivation of the constants is only being included for the purpose
|
32 | 32 | // of maintaining a record of how they were originally produced.
|
33 | 33 |
|
34 | 34 | // ptrauth_string_discriminator("scan_results::languageSpecificData") == 0xE50D)
|
35 |
| -#define __ptrauth_scan_results_lsd \ |
36 |
| - __ptrauth(ptrauth_key_process_dependent_code, 1, 0xE50D) |
| 35 | +# define __ptrauth_scan_results_lsd __ptrauth(ptrauth_key_process_dependent_code, 1, 0xE50D) |
37 | 36 |
|
38 | 37 | // ptrauth_string_discriminator("scan_results::actionRecord") == 0x9823
|
39 |
| -#define __ptrauth_scan_results_action_record \ |
40 |
| - __ptrauth(ptrauth_key_process_dependent_code, 1, 0x9823) |
| 38 | +# define __ptrauth_scan_results_action_record __ptrauth(ptrauth_key_process_dependent_code, 1, 0x9823) |
41 | 39 |
|
42 | 40 | // scan result is broken up as we have a manual re-sign that requires each component
|
43 |
| -#define __ptrauth_scan_results_landingpad_key ptrauth_key_process_dependent_code |
| 41 | +# define __ptrauth_scan_results_landingpad_key ptrauth_key_process_dependent_code |
44 | 42 | // ptrauth_string_discriminator("scan_results::landingPad") == 0xD27C
|
45 |
| -#define __ptrauth_scan_results_landingpad_disc 0xD27C |
46 |
| -#define __ptrauth_scan_results_landingpad \ |
47 |
| - __ptrauth(__ptrauth_scan_results_landingpad_key, 1, __ptrauth_scan_results_landingpad_disc) |
48 |
| - |
49 |
| -#if __has_extension(__ptrauth_restricted_intptr) |
50 |
| -#define __ptrauth_scan_results_landingpad_intptr \ |
51 |
| - __ptrauth_restricted_intptr(__ptrauth_scan_results_landingpad_key, 1, \ |
52 |
| - __ptrauth_scan_results_landingpad_disc) |
53 |
| -#else |
54 |
| -#define __ptrauth_scan_results_landingpad_intptr \ |
55 |
| - __ptrauth(__ptrauth_scan_results_landingpad_key, 1, \ |
56 |
| - __ptrauth_scan_results_landingpad_disc) |
57 |
| -#endif |
| 43 | +# define __ptrauth_scan_results_landingpad_disc 0xD27C |
| 44 | +# define __ptrauth_scan_results_landingpad \ |
| 45 | + __ptrauth(__ptrauth_scan_results_landingpad_key, 1, __ptrauth_scan_results_landingpad_disc) |
| 46 | + |
| 47 | +# if __has_extension(__ptrauth_restricted_intptr) |
| 48 | +# define __ptrauth_scan_results_landingpad_intptr \ |
| 49 | + __ptrauth_restricted_intptr(__ptrauth_scan_results_landingpad_key, 1, __ptrauth_scan_results_landingpad_disc) |
| 50 | +# else |
| 51 | +# define __ptrauth_scan_results_landingpad_intptr \ |
| 52 | + __ptrauth(__ptrauth_scan_results_landingpad_key, 1, __ptrauth_scan_results_landingpad_disc) |
| 53 | +# endif |
58 | 54 |
|
59 | 55 | #else
|
60 |
| -#define __ptrauth_scan_results_lsd |
61 |
| -#define __ptrauth_scan_results_action_record |
62 |
| -#define __ptrauth_scan_results_landingpad |
63 |
| -#define __ptrauth_scan_results_landingpad_intptr |
| 56 | +# define __ptrauth_scan_results_lsd |
| 57 | +# define __ptrauth_scan_results_action_record |
| 58 | +# define __ptrauth_scan_results_landingpad |
| 59 | +# define __ptrauth_scan_results_landingpad_intptr |
64 | 60 | #endif
|
65 | 61 |
|
66 |
| - |
67 | 62 | // TODO: This is a temporary workaround for libc++abi to recognize that it's being
|
68 | 63 | // built against LLVM's libunwind. LLVM's libunwind started reporting _LIBUNWIND_VERSION
|
69 | 64 | // 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;
|
577 | 572 | struct scan_results
|
578 | 573 | {
|
579 | 574 | int64_t ttypeIndex; // > 0 catch handler, < 0 exception spec handler, == 0 a cleanup
|
580 |
| - action_ptr_t actionRecord; // Currently unused. Retained to ease future maintenance. |
581 |
| - lsd_ptr_t languageSpecificData; // Needed only for __cxa_call_unexpected |
582 |
| - landing_pad_t landingPad; // null -> nothing found, else something found |
| 575 | + action_ptr_t actionRecord; // Currently unused. Retained to ease future maintenance. |
| 576 | + lsd_ptr_t languageSpecificData; // Needed only for __cxa_call_unexpected |
| 577 | + landing_pad_t landingPad; // null -> nothing found, else something found |
583 | 578 | void* adjustedPtr; // Used in cxa_exception.cpp
|
584 | 579 | _Unwind_Reason_Code reason; // One of _URC_FATAL_PHASE1_ERROR,
|
585 | 580 | // _URC_FATAL_PHASE2_ERROR,
|
@@ -634,14 +629,11 @@ set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context,
|
634 | 629 | auto stackPointer = _Unwind_GetGR(context, UNW_REG_SP);
|
635 | 630 | // We manually re-sign the IP as the __ptrauth qualifiers cannot
|
636 | 631 | // express the required relationship with the destination address
|
637 |
| - const auto existingDiscriminator = ptrauth_blend_discriminator( |
638 |
| - &results.landingPad, __ptrauth_scan_results_landingpad_disc); |
| 632 | + const auto existingDiscriminator = |
| 633 | + ptrauth_blend_discriminator(&results.landingPad, __ptrauth_scan_results_landingpad_disc); |
639 | 634 | unw_word_t newIP /* opaque __ptrauth(ptrauth_key_return_address, stackPointer, 0) */ =
|
640 |
| - (unw_word_t)ptrauth_auth_and_resign(*(void* const*)&results.landingPad, |
641 |
| - __ptrauth_scan_results_landingpad_key, |
642 |
| - existingDiscriminator, |
643 |
| - ptrauth_key_return_address, |
644 |
| - stackPointer); |
| 635 | + (unw_word_t)ptrauth_auth_and_resign(*(void* const*)&results.landingPad, __ptrauth_scan_results_landingpad_key, |
| 636 | + existingDiscriminator, ptrauth_key_return_address, stackPointer); |
645 | 637 | _Unwind_SetIP(context, newIP);
|
646 | 638 | #else
|
647 | 639 | _Unwind_SetIP(context, results.landingPad);
|
|
0 commit comments