Skip to content

Commit 8689cf8

Browse files
committed
[swift-inspect] Compute ptrauth mask when building for plain ARM64.
This allows an ARM64 swift-inspect to correctly read from an ARM64e target process. We compute a ptrauth mask by stripping all bits above MACH_VM_MAX_ADDRESS. This strips more than we strictly need, but it works.
1 parent 9f76c19 commit 8689cf8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tools/swift-inspect/Sources/SymbolicationShims/SymbolicationShims.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#if defined(__APPLE__)
1414

15+
#include <mach/vm_param.h>
1516
#include <stdint.h>
1617
#include <ptrauth.h>
1718

@@ -26,6 +27,10 @@ struct Range {
2627
static inline uintptr_t GetPtrauthMask(void) {
2728
#if __has_feature(ptrauth_calls)
2829
return (uintptr_t)ptrauth_strip((void*)0x0007ffffffffffff, 0);
30+
#elif __arm64__ && __LP64__
31+
// Mask all bits above the top of MACH_VM_MAX_ADDRESS, which will
32+
// match the above ptrauth_strip.
33+
return (uintptr_t)~0ull >> __builtin_clzll(MACH_VM_MAX_ADDRESS);
2934
#else
3035
return (uintptr_t)~0ull;
3136
#endif

0 commit comments

Comments
 (0)