Loading...
src/threadLocalHelpers.s dyld-353.2.1 dyld-852
--- dyld/dyld-353.2.1/src/threadLocalHelpers.s
+++ dyld/dyld-852/src/threadLocalHelpers.s
@@ -228,16 +228,31 @@
 	.globl _tlv_get_addr
 	.private_extern _tlv_get_addr
 _tlv_get_addr:
+#if __LP64__
 	ldr		x16, [x0, #8]			// get key from descriptor
+#else
+	ldr		w16, [x0, #4]			// get key from descriptor
+#endif
 	mrs		x17, TPIDRRO_EL0
 	and		x17, x17, #-8			// clear low 3 bits???
+#if __LP64__
 	ldr		x17, [x17, x16, lsl #3]	// get thread allocation address for this key
+#else
+	ldr		w17, [x17, x16, lsl #2]	// get thread allocation address for this key
+#endif
 	cbz		x17, LlazyAllocate		// if NULL, lazily allocate
+#if __LP64__
 	ldr		x16, [x0, #16]			// get offset from descriptor
+#else
+	ldr		w16, [x0, #8]			// get offset from descriptor
+#endif
 	add		x0, x17, x16			// return allocation+offset
 	ret		lr
 
 LlazyAllocate:
+#if __has_feature(ptrauth_returns)
+	pacibsp
+#endif
 	stp		fp, lr, [sp, #-16]!
 	mov		fp, sp
 	sub		sp, sp, #288
@@ -258,7 +273,11 @@
 	mov		x0, x16					// use key from descriptor as parameter
 	bl		_tlv_allocate_and_initialize_for_key
 	ldp		x16, x17, [sp], #16		// pop descriptor
+#if __LP64__
 	ldr		x16, [x16, #16]			// get offset from descriptor
+#else
+	ldr		w16, [x16, #8]			// get offset from descriptor
+#endif
 	add		x0, x0, x16				// return allocation+offset
 
 	ldp		q6,  q7,  [sp], #32
@@ -276,28 +295,43 @@
 
 	mov		sp, fp
 	ldp		fp, lr, [sp], #16
-	ret		lr
-
-#endif
-
-#if 0
+#if __has_feature(ptrauth_returns)
+	retab
+#else
+	ret
+#endif
+
+#endif
+
 #if __arm__
 	// returns address of TLV in r0, all other registers preserved
+	.align 2
 	.globl _tlv_get_addr
 	.private_extern _tlv_get_addr
 _tlv_get_addr:
-	push	{r1,r2,r3,r7,lr}				
-	mov		r7,r0							// save descriptor in r7
+	push	{r1,r2,r3,r7,lr}
+#if __ARM_ARCH_7K__
+	sub		sp, sp, #12						// align stack to 16 bytes
+#endif
+	mov		r7, r0							// save descriptor in r7
 	ldr		r0, [r7, #4]					// get key from descriptor
 	bl		_pthread_getspecific			// get thread value
 	cmp		r0, #0
 	bne		L2								// if NULL, lazily allocate
+#if __ARM_ARCH_7K__
+	vpush	{d0, d1, d2, d3, d4, d5, d6, d7}
+#endif
 	ldr		r0, [r7, #4]					// get key from descriptor
 	bl		_tlv_allocate_and_initialize_for_key
+#if __ARM_ARCH_7K__
+	vpop	{d0, d1, d2, d3, d4, d5, d6, d7}
+#endif
 L2:	ldr		r1, [r7, #8]					// get offset from descriptor
 	add		r0, r1, r0						// add offset into allocation block
+#if __ARM_ARCH_7K__
+	add		sp, sp, #12
+#endif
 	pop		{r1,r2,r3,r7,pc}
-#endif
 #endif
 
 	.subsections_via_symbols