Skip to content

Commit fd5c9f7

Browse files
committed
update libcxxabi formatting
1 parent 972edcb commit fd5c9f7

File tree

4 files changed

+36
-53
lines changed

4 files changed

+36
-53
lines changed

libcxxabi/include/__cxxabi_config.h

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,32 +110,25 @@
110110
#if __has_feature(ptrauth_calls)
111111

112112
// ptrauth_string_discriminator("__cxa_exception::actionRecord") == 0xFC91
113-
# define __ptrauth_cxxabi_action_record \
114-
__ptrauth(ptrauth_key_process_dependent_data, 1, 0xFC91)
113+
# define __ptrauth_cxxabi_action_record __ptrauth(ptrauth_key_process_dependent_data, 1, 0xFC91)
115114

116115
// ptrauth_string_discriminator("__cxa_exception::languageSpecificData") == 0xE8EE
117-
# define __ptrauth_cxxabi_lsd \
118-
__ptrauth(ptrauth_key_process_dependent_data, 1, 0xE8EE)
116+
# define __ptrauth_cxxabi_lsd __ptrauth(ptrauth_key_process_dependent_data, 1, 0xE8EE)
119117

120118
// ptrauth_string_discriminator("__cxa_exception::catchTemp") == 0xFA58
121-
# define __ptrauth_cxxabi_catch_temp \
122-
__ptrauth(ptrauth_key_process_dependent_data, 1, 0xFA58)
119+
# define __ptrauth_cxxabi_catch_temp __ptrauth(ptrauth_key_process_dependent_data, 1, 0xFA58)
123120

124121
// ptrauth_string_discriminator("__cxa_exception::adjustedPtr") == 0x99E4
125-
# define __ptrauth_cxxabi_adjusted_ptr \
126-
__ptrauth(ptrauth_key_process_dependent_data, 1, 0x99E4)
122+
# define __ptrauth_cxxabi_adjusted_ptr __ptrauth(ptrauth_key_process_dependent_data, 1, 0x99E4)
127123

128124
// ptrauth_string_discriminator("__cxa_exception::unexpectedHandler") == 0x99A9
129-
# define __ptrauth_cxxabi_unexpected_handler \
130-
__ptrauth(ptrauth_key_function_pointer, 1, 0x99A9)
125+
# define __ptrauth_cxxabi_unexpected_handler __ptrauth(ptrauth_key_function_pointer, 1, 0x99A9)
131126

132127
// ptrauth_string_discriminator("__cxa_exception::terminateHandler") == 0x0886)
133-
# define __ptrauth_cxxabi_terminate_handler \
134-
__ptrauth(ptrauth_key_function_pointer, 1, 0x886)
128+
# define __ptrauth_cxxabi_terminate_handler __ptrauth(ptrauth_key_function_pointer, 1, 0x886)
135129

136130
// ptrauth_string_discriminator("__cxa_exception::exceptionDestructor") == 0xC088
137-
# define __ptrauth_cxxabi_exception_destructor \
138-
__ptrauth(ptrauth_key_function_pointer, 1, 0xC088)
131+
# define __ptrauth_cxxabi_exception_destructor __ptrauth(ptrauth_key_function_pointer, 1, 0xC088)
139132

140133
#else
141134

libcxxabi/src/cxa_exception.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ void *__cxa_allocate_exception(size_t thrown_size) throw() {
194194
static_cast<__cxa_exception *>((void *)(raw_buffer + header_offset));
195195
// We warn on memset to a non-trivially castable type. We might want to
196196
// change that diagnostic to not fire on a trivially obvious zero fill.
197-
::memset(static_cast<void *>(exception_header), 0, actual_size);
197+
::memset(static_cast<void*>(exception_header), 0, actual_size);
198198
return thrown_object_from_cxa_exception(exception_header);
199199
}
200200

libcxxabi/src/cxa_exception.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ struct _LIBCXXABI_HIDDEN __cxa_exception {
4747
// In Wasm, a destructor returns its argument
4848
void *(_LIBCXXABI_DTOR_FUNC *exceptionDestructor)(void *);
4949
#else
50-
void (_LIBCXXABI_DTOR_FUNC* __ptrauth_cxxabi_exception_destructor
51-
exceptionDestructor)(void*);
50+
void(_LIBCXXABI_DTOR_FUNC* __ptrauth_cxxabi_exception_destructor exceptionDestructor)(void*);
5251
#endif
5352
std::unexpected_handler __ptrauth_cxxabi_unexpected_handler unexpectedHandler;
5453
std::terminate_handler __ptrauth_cxxabi_terminate_handler terminateHandler;
@@ -89,8 +88,7 @@ struct _LIBCXXABI_HIDDEN __cxa_dependent_exception {
8988
#endif
9089

9190
std::type_info *exceptionType;
92-
void (_LIBCXXABI_DTOR_FUNC* __ptrauth_cxxabi_exception_destructor
93-
exceptionDestructor)(void*);
91+
void(_LIBCXXABI_DTOR_FUNC* __ptrauth_cxxabi_exception_destructor exceptionDestructor)(void*);
9492
std::unexpected_handler __ptrauth_cxxabi_unexpected_handler unexpectedHandler;
9593
std::terminate_handler __ptrauth_cxxabi_terminate_handler terminateHandler;
9694

libcxxabi/src/cxa_personality.cpp

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,45 +25,40 @@
2525

2626
// CXXABI depends on defintions in libunwind as pointer auth couples the
2727
// definitions
28-
#include "libunwind.h"
28+
# include "libunwind.h"
2929

3030
// The actual value of the discriminators listed below is not important.
3131
// The derivation of the constants is only being included for the purpose
3232
// of maintaining a record of how they were originally produced.
3333

3434
// 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)
3736

3837
// 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)
4139

4240
// 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
4442
// 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
5854

5955
#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
6460
#endif
6561

66-
6762
// TODO: This is a temporary workaround for libc++abi to recognize that it's being
6863
// built against LLVM's libunwind. LLVM's libunwind started reporting _LIBUNWIND_VERSION
6964
// 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;
577572
struct scan_results
578573
{
579574
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
583578
void* adjustedPtr; // Used in cxa_exception.cpp
584579
_Unwind_Reason_Code reason; // One of _URC_FATAL_PHASE1_ERROR,
585580
// _URC_FATAL_PHASE2_ERROR,
@@ -634,14 +629,11 @@ set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context,
634629
auto stackPointer = _Unwind_GetGR(context, UNW_REG_SP);
635630
// We manually re-sign the IP as the __ptrauth qualifiers cannot
636631
// 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);
639634
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);
645637
_Unwind_SetIP(context, newIP);
646638
#else
647639
_Unwind_SetIP(context, results.landingPad);

0 commit comments

Comments
 (0)