소스 검색

rewrite __aeabi_read_tp in asm

__aeabi_read_tp used to call c code, but that was incorrect as the
arm runtime abi specifies special pcs for this function: it is only
allowed to clobber r0, ip, lr and cpsr.

maintainer's note: the old code explicitly saved and restored all
general-purpose registers which are call-clobbered in the normal
calling convention, so it's unlikely that any real-world compilers
produced code that could break. however theoretically they could have
chosen to use floating point registers, in which case the caller's
values of those registers would be clobbered.
Szabolcs Nagy 6 년 전
부모
커밋
056f9d818e
2개의 변경된 파일6개의 추가작업 그리고 12개의 파일을 삭제
  1. 6 4
      src/thread/arm/__aeabi_read_tp.s
  2. 0 8
      src/thread/arm/__aeabi_read_tp_c.c

+ 6 - 4
src/thread/arm/__aeabi_read_tp.s

@@ -2,7 +2,9 @@
 .global __aeabi_read_tp
 .type __aeabi_read_tp,%function
 __aeabi_read_tp:
-	push {r1,r2,r3,lr}
-	bl __aeabi_read_tp_c
-	pop {r1,r2,r3,lr}
-	bx lr
+	ldr r0,1f
+	add r0,r0,pc
+	ldr r0,[r0]
+2:	bx r0
+	.align 2
+1:	.word __a_gettp_ptr - 2b

+ 0 - 8
src/thread/arm/__aeabi_read_tp_c.c

@@ -1,8 +0,0 @@
-#include "pthread_impl.h"
-#include <stdint.h>
-
-__attribute__((__visibility__("hidden")))
-void *__aeabi_read_tp_c(void)
-{
-	return TP_ADJ(__pthread_self());
-}