summaryrefslogtreecommitdiff
path: root/src/ldso/aarch64/tlsdesc.s
blob: 04d97e730431a957dab6c2bbc7dfa0242265c20e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// size_t __tlsdesc_static(size_t *a)
// {
// 	return a[1];
// }
.global __tlsdesc_static
.hidden __tlsdesc_static
.type __tlsdesc_static,@function
__tlsdesc_static:
	ldr x0,[x0,#8]
	ret

.hidden __tls_get_new

// size_t __tlsdesc_dynamic(size_t *a)
// {
// 	struct {size_t modidx,off;} *p = (void*)a[1];
// 	size_t *dtv = *(size_t**)(tp - 8);
// 	if (p->modidx <= dtv[0])
// 		return dtv[p->modidx] + p->off - tp;
// 	return __tls_get_new(p) - tp;
// }
.global __tlsdesc_dynamic
.hidden __tlsdesc_dynamic
.type __tlsdesc_dynamic,@function
__tlsdesc_dynamic:
	stp x1,x2,[sp,#-16]!
	mrs x1,tpidr_el0      // tp
	ldr x0,[x0,#8]        // p
	ldp x0,x2,[x0]        // p->modidx, p->off
	sub x2,x2,x1          // p->off - tp
	ldr x1,[x1,#-8]       // dtv
	ldr x1,[x1,x0,lsl #3] // dtv[p->modidx]
	add x0,x1,x2          // dtv[p->modidx] + p->off - tp
	ldp x1,x2,[sp],#16
	ret