From e371ae712fd6a771677e45df32becd67c47edbf4 Mon Sep 17 00:00:00 2001 From: "Thomas A." Date: Wed, 6 Mar 2024 09:49:34 -0800 Subject: [PATCH 1/2] FIx Building For ARM64 --- runtime/isa.h | 3 ++- runtime/objc-object.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/runtime/isa.h b/runtime/isa.h index 8b552c2..2faf4d3 100644 --- a/runtime/isa.h +++ b/runtime/isa.h @@ -57,7 +57,8 @@ # if __arm64__ // ARM64 simulators have a larger address space, so use the ARM64e // scheme even when simulators build for ARM64-not-e. -# if __has_feature(ptrauth_calls) || TARGET_OS_SIMULATOR +// DARLING: For the time being, we want to support older arm64 devices that don't support arm64e. +# if __has_feature(ptrauth_calls) || TARGET_OS_SIMULATOR || DARLING # define ISA_MASK 0x007ffffffffffff8ULL # define ISA_MAGIC_MASK 0x0000000000000001ULL # define ISA_MAGIC_VALUE 0x0000000000000001ULL diff --git a/runtime/objc-object.h b/runtime/objc-object.h index d15d5a8..1cf6694 100644 --- a/runtime/objc-object.h +++ b/runtime/objc-object.h @@ -182,7 +182,8 @@ inline void isa_t::setClass(Class newCls, UNUSED_WITHOUT_PTRAUTH objc_object *obj) { // Match the conditional in isa.h. -#if __has_feature(ptrauth_calls) || TARGET_OS_SIMULATOR +// DARLING: For the time being, we want to support older arm64 devices that don't support arm64e. +#if __has_feature(ptrauth_calls) || TARGET_OS_SIMULATOR || DARLING # if ISA_SIGNING_SIGN_MODE == ISA_SIGNING_SIGN_NONE // No signing, just use the raw pointer. uintptr_t signedCls = (uintptr_t)newCls; From e61237767ef228838c23ca2bb02097eb9f12e7be Mon Sep 17 00:00:00 2001 From: "Thomas A." Date: Thu, 30 May 2024 08:19:21 -0700 Subject: [PATCH 2/2] Increase FAST_DATA_MASK Mask The user space address space on Linux is higher compared to macOS. As a result, we need to increase the FAST_DATA_MASK mask. Co-authored-by: Sergey Bugaev --- runtime/objc-runtime-new.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/runtime/objc-runtime-new.h b/runtime/objc-runtime-new.h index f44a0d0..7883931 100644 --- a/runtime/objc-runtime-new.h +++ b/runtime/objc-runtime-new.h @@ -123,7 +123,17 @@ // _tryRetain/_isDeallocating/retainWeakReference/allowsWeakReference #define FAST_HAS_DEFAULT_RR (1UL<<2) // data pointer +#ifdef DARLING +// XNU only supports up to 47-bit address space on AArch64 +// (see T0SZ_BOOT in osfmk/arm64/proc_reg.h), but Linux +// normally uses 48-bit one, and can support 52-bit one +// on hardware with FEAT_LVA. Fortunately, Apple doesn't +// seem to use the upper bits for any flags, so we can just +// extend the mask to cover them. +#define FAST_DATA_MASK 0xfffffffffffffff8UL +#else #define FAST_DATA_MASK 0x00007ffffffffff8UL +#endif #if __arm64__ // class or superclass has .cxx_construct/.cxx_destruct implementation