File tree Expand file tree Collapse file tree 2 files changed +46
-4
lines changed
Expand file tree Collapse file tree 2 files changed +46
-4
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ PHP NEWS
1515- Opcache:
1616 . Fixed bug GH-20081 (access to uninitialized vars in preload_load()).
1717 (Arnaud)
18+ . Fixed bug GH-20121 (JIT broken in ZTS builds on MacOS 15).
19+ (Arnaud, Shivam Mathur)
1820
1921- SPL:
2022 . Fixed bug GH-20101 (SplHeap/SplPriorityQueue serialization
Original file line number Diff line number Diff line change 2323
2424#include <stdint.h>
2525#include <unistd.h>
26+ #include <mach-o/dyld.h>
2627
2728TSRMLS_CACHE_EXTERN ();
2829
30+ /* Thunk format used since dydl 1284 (approx. MacOS 15)
31+ * https://github.com/apple-oss-distributions/dyld/blob/9307719dd8dc9b385daa412b03cfceb897b2b398/libdyld/ThreadLocalVariables.h#L146 */
32+ #if defined(__x86_64__ ) || defined(__aarch64__ )
33+ struct TLV_Thunkv2
34+ {
35+ void * func ;
36+ uint32_t key ;
37+ uint32_t offset ;
38+ };
39+ #else
40+ struct TLV_Thunkv2
41+ {
42+ void * func ;
43+ uint16_t key ;
44+ uint16_t offset ;
45+ };
46+ #endif
47+
48+ /* Thunk format used in earlier versions */
49+ struct TLV_Thunkv1
50+ {
51+ void * func ;
52+ size_t key ;
53+ size_t offset ;
54+ };
55+
2956zend_result zend_jit_resolve_tsrm_ls_cache_offsets (
3057 size_t * tcb_offset ,
3158 size_t * module_index ,
@@ -37,12 +64,25 @@ zend_result zend_jit_resolve_tsrm_ls_cache_offsets(
3764 }
3865
3966#if defined(__x86_64__ )
40- size_t * ti ;
67+ struct TLV_Thunkv2 * thunk ;
4168 __asm__ __volatile__(
4269 "leaq __tsrm_ls_cache(%%rip),%0"
43- : "=r" (ti ));
44- * module_offset = ti [2 ];
45- * module_index = ti [1 ] * 8 ;
70+ : "=r" (thunk ));
71+
72+ /* Detect dyld 1284: With dyld 1284, thunk->func will be _tlv_get_addr.
73+ * Unfortunately this symbol is private, but we can find it
74+ * as _tlv_bootstrap+8: https://github.com/apple-oss-distributions/dyld/blob/9307719dd8dc9b385daa412b03cfceb897b2b398/libdyld/threadLocalHelpers.s#L54
75+ * In earlier versions, thunk->func will be tlv_get_addr, which is not
76+ * _tlv_bootstrap+8.
77+ */
78+ if (thunk -> func == (void * )((char * )_tlv_bootstrap + 8 )) {
79+ * module_offset = thunk -> offset ;
80+ * module_index = (size_t )thunk -> key * 8 ;
81+ } else {
82+ struct TLV_Thunkv1 * thunkv1 = (struct TLV_Thunkv1 * ) thunk ;
83+ * module_offset = thunkv1 -> offset ;
84+ * module_index = thunkv1 -> key * 8 ;
85+ }
4686
4787 return SUCCESS ;
4888#endif
You can’t perform that action at this time.
0 commit comments