Skip to content

BrowserEngineCore macOS xcode16.3 b1

Rolf Bjarne Kvinge edited this page Feb 24, 2025 · 1 revision

#BrowserEngineCore.framework

diff -ruN /Applications/Xcode_16.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BrowserEngineCore.framework/Headers/BEMemory.h /Applications/Xcode_16.3.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BrowserEngineCore.framework/Headers/BEMemory.h
--- /Applications/Xcode_16.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BrowserEngineCore.framework/Headers/BEMemory.h	2024-11-10 09:40:37
+++ /Applications/Xcode_16.3.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/BrowserEngineCore.framework/Headers/BEMemory.h	2025-02-07 19:27:01
@@ -49,15 +49,20 @@
 __attribute__((noinline))
 BROWSERENGINE_EXPORT int be_memory_inline_jit_restrict_with_witness_supported(void);
 
-// This is the globally unique diversifier used in the implementation
-// of be_memory_inline_jit_restrict_rwx_to_rw_with_witness_impl
-// Ensure that your implementation does not use this diversifier for anything else.
+/*
+   This is the globally unique diversifier used in the implementation
+   of be_memory_inline_jit_restrict_rwx_to_rw_with_witness_impl
+   Ensure that your implementation does not use this diversifier for anything else.
+*/
 #define BE_JIT_WRITE_PROTECT_TAG 0x4a4954l
 
 #define _BE_STRINGIZE(exp) #exp
 #define _BE_STRINGIZE_VALUE_OF(exp) _BE_STRINGIZE(exp)
 #define _BE_SYMBOL_STRING(name) "_" #name
 
+#define _BE_INST_PACIBZ ".int 0xd503235f"
+#define _BE_INST_PACIB_X0_X1 ".int 0xdac10420"
+
 /*
     These functions that can toggle JIT R^X permissions, while enforcing
     control flow integrity using PAC. This function is intended to be used
@@ -116,17 +121,24 @@
 #ifdef __arm64e__
     ".arch_extension pauth" "\n"
 #endif
-    "adr x0, %=f" "\n"
+    "adr x0, %=2f" "\n"
 
     "movz x1, #" _BE_STRINGIZE_VALUE_OF(((BE_JIT_WRITE_PROTECT_TAG >>  0) & 0xFFFF)) ", lsl #0 \n"
     "movk x1, #" _BE_STRINGIZE_VALUE_OF(((BE_JIT_WRITE_PROTECT_TAG >> 16) & 0xFFFF)) ", lsl #16\n"
 
 #ifdef __arm64e__
     "pacib x0, x1" "\n"
-#endif
+#else
+    "mov x30, x1" "\n"
+    _BE_INST_PACIBZ "\n"
+    "cmp x30, x1" "\n"
+    "beq %=1f" "\n"
+    _BE_INST_PACIB_X0_X1 "\n"
+    "%=1:" "\n"
+#endif // !__arm64e__
 
     "bl " _BE_SYMBOL_STRING(be_memory_inline_jit_restrict_rwx_to_rw_with_witness_impl) "\n"
-    "%=:" "\n"
+    "%=2:" "\n"
     "nop" "\n"
     : /* no output */
     : /* no input */
@@ -156,6 +168,9 @@
     : "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r16", "r17", "lr", "memory", "cc"
     );
 }
+
+#undef _BE_INST_PACIBZ
+#undef _BE_INST_PACIB_X0_X1
 
 #undef _BE_STRINGIZE
 #undef _BE_STRINGIZE_VALUE_OF
Clone this wiki locally