@@ -192,18 +192,6 @@ zend_result zend_jit_resolve_tsrm_ls_cache_offsets(
192192
193193 /* Code was changed by the linker. Check if we recognize the updated code */
194194
195- // movz x0, #0, lsl #16
196- if ((insn [0 ] & ~AARCH64_MOVZ_IMM_MASK ) != 0xd2a00000 ) {
197- zend_accel_error (ACCEL_LOG_DEBUG , "movz insn does not match: 0x%08" PRIx32 "\n" , insn [0 ]);
198- return FAILURE ;
199- }
200-
201- // movk x0, #0x10
202- if ((insn [1 ] & ~AARCH64_MOVK_IMM_MASK ) != 0xf2800000 ) {
203- zend_accel_error (ACCEL_LOG_DEBUG , "movk insn does not match: 0x%08" PRIx32 "\n" , insn [1 ]);
204- return FAILURE ;
205- }
206-
207195 // nop
208196 for (int i = 0 ; i < 2 ; i ++ ) {
209197 if (insn [2 + i ] != AARCH64_NOP ) {
@@ -212,12 +200,29 @@ zend_result zend_jit_resolve_tsrm_ls_cache_offsets(
212200 }
213201 }
214202
215- /* Extract immediate values */
203+ if ((insn [0 ] & ~AARCH64_ADRP_IMM_MASK ) == 0x90000000 ) {
204+ /* initial-exec */
205+ // ldr x0, [x0, #any]
206+ if ((insn [1 ] & ~AARCH64_LDR_UNSIGNED_IMM_MASK ) != 0xf9400000 ) {
207+ zend_accel_error (ACCEL_LOG_DEBUG , "ldr insn does not match: 0x%08" PRIx32 "\n" , insn [1 ]);
208+ return FAILURE ;
209+ }
210+ } else {
211+ /* local-exec */
212+ // movz x0, #0, lsl #16
213+ if ((insn [0 ] & ~AARCH64_MOVZ_IMM_MASK ) != 0xd2a00000 ) {
214+ zend_accel_error (ACCEL_LOG_DEBUG , "movz insn does not match: 0x%08" PRIx32 "\n" , insn [0 ]);
215+ return FAILURE ;
216+ }
217+
218+ // movk x0, #0x10
219+ if ((insn [1 ] & ~AARCH64_MOVK_IMM_MASK ) != 0xf2800000 ) {
220+ zend_accel_error (ACCEL_LOG_DEBUG , "movk insn does not match: 0x%08" PRIx32 "\n" , insn [1 ]);
221+ return FAILURE ;
222+ }
223+ }
216224
217- uint64_t movz_imm = (insn [0 ] & AARCH64_MOVZ_IMM_MASK ) >> 5 ;
218- uint64_t movz_shift = (((insn [0 ] & AARCH64_MOVZ_HW_MASK ) >> 21 ) << 4 );
219- uint64_t movk_imm = (insn [1 ] & AARCH64_MOVK_IMM_MASK ) >> 5 ;
220- uint64_t offset = (movz_imm << movz_shift ) | movk_imm ;
225+ uintptr_t offset = (uintptr_t )addr - (uintptr_t )thread_pointer ;
221226
222227 if ((uintptr_t )& _tsrm_ls_cache - (uintptr_t )thread_pointer == offset ) {
223228 zend_accel_error (ACCEL_LOG_DEBUG , "static tls at offset %" PRIxPTR " from thread pointer (inferred from code)\n" , offset );
0 commit comments