Skip to content

Commit d6375dd

Browse files
committed
yet more cleaning up
1 parent 26b7d70 commit d6375dd

File tree

20 files changed

+49
-64
lines changed

20 files changed

+49
-64
lines changed

compiler-rt/lib/builtins/crtbegin.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
#include <ptrauth.h>
1717
#endif
1818

19-
#if __has_feature(ptrauth_calls) || defined(__PTRAUTH__)
20-
#define __crtbegin_has_ptrauth 1
21-
#else
22-
#define __crtbegin_has_ptrauth 0
23-
#endif
24-
2519
__attribute__((visibility("hidden"))) void *__dso_handle = &__dso_handle;
2620

2721
#ifdef EH_USE_FRAME_REGISTRY
@@ -72,7 +66,7 @@ __attribute__((section(".init_array"), used)) static void *__init =
7266
ptrauth_sign_constant(&__do_init, ptrauth_key_init_fini_pointer,
7367
__ptrauth_init_fini_discriminator);
7468
# endif
75-
# elif __crtbegin_has_ptrauth
69+
# elif __has_feature(ptrauth_calls)
7670
# ifdef __aarch64__
7771
// If ptrauth_init_fini feature is not present, compiler emits raw unsigned
7872
// pointers in .init_array. Use inline assembly to avoid implicit signing of
@@ -154,7 +148,7 @@ __attribute__((section(".fini_array"), used)) static void *__fini =
154148
ptrauth_sign_constant(&__do_fini, ptrauth_key_init_fini_pointer,
155149
__ptrauth_init_fini_discriminator);
156150
# endif
157-
# elif __crtbegin_has_ptrauth
151+
# elif __has_feature(ptrauth_calls)
158152
# ifdef __aarch64__
159153
// If ptrauth_init_fini feature is not present, compiler emits raw unsigned
160154
// pointers in .fini_array. Use inline assembly to avoid implicit signing of

compiler-rt/lib/builtins/gcc_personality_v0.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, void *, PCONTEXT,
3030
_Unwind_Personality_Fn);
3131
#endif
3232

33-
#if __has_feature(ptrauth_calls) || defined(__PTRAUTH__)
33+
#if __has_feature(ptrauth_calls)
3434
#include <ptrauth.h>
3535

36-
#define __gcc_personality_has_ptrauth 1
37-
3836
#if __has_feature(ptrauth_restricted_intptr_qualifier)
3937
#define __ptrauth_gcc_personality_intptr(key, addressDiscriminated, \
4038
discriminator) \
@@ -45,7 +43,6 @@ EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, void *, PCONTEXT,
4543
__ptrauth(key, addressDiscriminated, discriminator)
4644
#endif
4745
#else
48-
#define __gcc_personality_has_ptrauth 0
4946
#define __ptrauth_gcc_personality_intptr(...)
5047
#endif
5148

@@ -287,7 +284,7 @@ COMPILER_RT_ABI _Unwind_Reason_Code __gcc_personality_v0(
287284
_Unwind_SetGR(context, __builtin_eh_return_data_regno(1), 0);
288285
size_t __ptrauth_gcc_personality_lpad landingPad =
289286
funcStart + landingPadOffset;
290-
#if __gcc_personality_has_ptrauth
287+
#if __has_feature(ptrauth_calls)
291288
uintptr_t stackPointer = _Unwind_GetGR(context, -2);
292289
const uintptr_t existingDiscriminator =
293290
ptrauth_blend_discriminator(&landingPad,

compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef SANITIZER_PTRAUTH_H
1010
#define SANITIZER_PTRAUTH_H
1111

12-
#if __has_feature(ptrauth_calls) || defined(__PTRAUTH__)
12+
#if __has_feature(ptrauth_calls)
1313
# include <ptrauth.h>
1414
#elif defined(__ARM_FEATURE_PAC_DEFAULT) && !defined(__APPLE__)
1515
// On the stack the link register is protected with Pointer

compiler-rt/test/asan/TestCases/Darwin/linked-only.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <string.h>
1111

1212
#include "sanitizer/asan_interface.h"
13-
#if __has_feature(ptrauth_calls) || defined(__PTRAUTH__)
13+
#if __has_feature(ptrauth_calls)
1414
# include <ptrauth.h>
1515
#endif
1616

@@ -27,7 +27,7 @@ int main(int argc, char *argv[]) {
2727
// CHECK: =-1=
2828

2929
char *mainptr;
30-
#if __has_feature(ptrauth_calls) || defined(__PTRAUTH__)
30+
#if __has_feature(ptrauth_calls)
3131
mainptr = (char *)ptrauth_strip((void *)&main, ptrauth_key_return_address);
3232
#else
3333
mainptr = (char *)&main;

compiler-rt/test/asan/TestCases/zero_page_pc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
# define __has_feature(x) 0
1010
#endif
1111

12-
#if __has_feature(ptrauth_calls) || defined(__PTRAUTH__)
12+
#if __has_feature(ptrauth_calls)
1313
# include <ptrauth.h>
1414
#endif
1515

1616
typedef void void_f();
1717
int main() {
1818
void_f *func = (void_f *)0x4;
19-
#if __has_feature(ptrauth_calls) || defined(__PTRAUTH__)
19+
#if __has_feature(ptrauth_calls)
2020
func = ptrauth_sign_unauthenticated(
2121
func, ptrauth_key_function_pointer, 0);
2222
#endif

compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include <cstdint>
1010
#include <cstdio>
11-
#if __has_feature(ptrauth_calls) || defined(__PTRAUTH__)
11+
#if __has_feature(ptrauth_calls)
1212
#include <ptrauth.h>
1313
#else
1414
#define ptrauth_strip(__value, __key) (__value)

compiler-rt/test/ubsan/TestCases/TypeCheck/vptr-corrupted-vtable-itanium.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66

77
#include <typeinfo>
88

9-
#if __has_feature(ptrauth_calls) || defined(__PTRAUTH__)
10-
#define __has_ptrauth 1
9+
#if __has_feature(ptrauth_calls)
1110
#include <ptrauth.h>
1211
#else
13-
#define __has_ptrauth 0
1412
#endif
1513

1614
struct S {
@@ -31,7 +29,7 @@ int main(int argc, char **argv) {
3129
S Obj;
3230
void *Ptr = &Obj;
3331
void *VtablePtr = *reinterpret_cast<void**>(Ptr);
34-
#if __has_ptrauth
32+
#if __has_feature(ptrauth_calls)
3533
VtablePtr = ptrauth_strip(VtablePtr, 0);
3634
#endif
3735
VtablePrefix* Prefix = reinterpret_cast<VtablePrefix*>(VtablePtr) - 1;
@@ -42,7 +40,7 @@ int main(int argc, char **argv) {
4240

4341
// Hack Vtable ptr for Obj.
4442
void *FakeVtablePtr = static_cast<void*>(&FakePrefix[1]);
45-
#if __has_ptrauth
43+
#if __has_feature(ptrauth_calls)
4644
FakeVtablePtr = ptrauth_sign_unauthenticated(
4745
FakeVtablePtr, ptrauth_key_cxx_vtable_pointer, 0);
4846
#endif

libcxx/src/include/overridable_function.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <__config>
1414
#include <cstdint>
1515

16-
#if __ptrauth_cxxabi_has_ptrauth
16+
#if __has_feature(ptrauth_calls)
1717
# include <ptrauth.h>
1818
#endif
1919

@@ -83,7 +83,7 @@ _LIBCPP_HIDE_FROM_ABI inline bool __is_function_overridden() noexcept {
8383
uintptr_t __end = reinterpret_cast<uintptr_t>(&__lcxx_override_end);
8484
uintptr_t __ptr = reinterpret_cast<uintptr_t>(_Func);
8585

86-
# if __ptrauth_cxxabi_has_ptrauth
86+
# if __has_feature(ptrauth_calls)
8787
// We must pass a void* to ptrauth_strip since it only accepts a pointer type. Also, in particular,
8888
// we must NOT pass a function pointer, otherwise we will strip the function pointer, and then attempt
8989
// to authenticate and re-sign it when casting it to a uintptr_t again, which will fail because we just
@@ -117,7 +117,7 @@ _LIBCPP_HIDE_FROM_ABI inline bool __is_function_overridden() noexcept {
117117
uintptr_t __end = reinterpret_cast<uintptr_t>(&__stop___lcxx_override);
118118
uintptr_t __ptr = reinterpret_cast<uintptr_t>(_Func);
119119

120-
# if __ptrauth_cxxabi_has_ptrauth
120+
# if __has_feature(ptrauth_calls)
121121
// We must pass a void* to ptrauth_strip since it only accepts a pointer type. See full explanation above.
122122
__ptr = reinterpret_cast<uintptr_t>(ptrauth_strip(reinterpret_cast<void*>(__ptr), ptrauth_key_function_pointer));
123123
# endif

libcxxabi/include/__cxxabi_config.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@
107107
# include <ptrauth.h>
108108
#endif
109109

110-
#if __has_feature(ptrauth_calls) || defined(__PTRAUTH__)
111-
112-
# define __ptrauth_cxxabi_has_ptrauth 1
110+
#if __has_feature(ptrauth_calls)
113111

114112
// ptrauth_string_discriminator("__cxa_exception::actionRecord") == 0xFC91
115113
# define __ptrauth_cxxabi_action_record \
@@ -141,8 +139,6 @@
141139

142140
#else
143141

144-
# define __ptrauth_cxxabi_has_ptrauth 0
145-
146142
# define __ptrauth_cxxabi_action_record
147143
# define __ptrauth_cxxabi_lsd
148144
# define __ptrauth_cxxabi_catch_temp

libcxxabi/src/cxa_exception.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ void *__cxa_allocate_exception(size_t thrown_size) throw() {
192192
std::terminate();
193193
__cxa_exception *exception_header =
194194
static_cast<__cxa_exception *>((void *)(raw_buffer + header_offset));
195-
::memset(exception_header, 0, actual_size);
195+
// We warn on memset to a non-trivially castable type. We might want to
196+
// change that diagnostic to not fire on a trivially obvious zero fill.
197+
::memset(static_cast<void *>(exception_header), 0, actual_size);
196198
return thrown_object_from_cxa_exception(exception_header);
197199
}
198200

0 commit comments

Comments
 (0)