1 /* Thread-local storage handling in the ELF dynamic linker. ARM version.
2 Copyright (C) 2006-2013 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
24 @ emit debug information with cfi
25 @ use arm-specific pseudos for unwinding itself
27 .hidden _dl_tlsdesc_return
28 .global _dl_tlsdesc_return
29 .type _dl_tlsdesc_return,#function
38 .size _dl_tlsdesc_return, .-_dl_tlsdesc_return
40 .hidden _dl_tlsdesc_undefweak
41 .global _dl_tlsdesc_undefweak
42 .type _dl_tlsdesc_undefweak,#function
46 _dl_tlsdesc_undefweak:
52 .size _dl_tlsdesc_undefweak, .-_dl_tlsdesc_undefweak
55 .hidden _dl_tlsdesc_dynamic
56 .global _dl_tlsdesc_dynamic
57 .type _dl_tlsdesc_dynamic,#function
61 The assembly code that follows is a rendition of the following
62 C code, hand-optimized a little bit.
65 _dl_tlsdesc_dynamic(struct tlsdesc *tdp)
67 struct tlsdesc_dynamic_arg *td = tdp->argument.pointer;
68 dtv_t *dtv = (dtv_t *)THREAD_DTV();
69 if (__builtin_expect (td->gen_count <= dtv[0].counter
70 && dtv[td->tlsinfo.ti_module].pointer.val
71 != TLS_DTV_UNALLOCATED,
73 return dtv[td->tlsinfo.ti_module].pointer.val +
74 td->tlsinfo.ti_offset - __builtin_thread_pointer();
76 return __tls_get_addr (&td->tlsinfo) - __builtin_thread_pointer();
84 /* Our calling convention is to clobber r0, r1 and the processor
85 flags. All others that are modified must be saved */
88 cfi_adjust_cfa_offset (16)
92 cfi_rel_offset (lr,12)
95 mov r4, r0 /* r4 = tp */
97 ldr r2, [r1, #8] /* gen_count */
102 ldr r2, [r0, r3, lsl #3]
113 #if defined (__ARM_ARCH_4T__) && defined (__THUMB_INTERWORK__)
115 cfi_adjust_cfa_offset (-16)
126 .size _dl_tlsdesc_dynamic, .-_dl_tlsdesc_dynamic
129 /* lazy resolved for tls descriptors. */
130 .hidden _dl_tlsdesc_lazy_resolver
131 .global _dl_tlsdesc_lazy_resolver
132 .type _dl_tlsdesc_lazy_resolver,#function
136 _dl_tlsdesc_lazy_resolver:
137 /* r0 points at the tlsdesc,
139 r2 was pushed by the trampoline and used as a temp,
140 we need to pop it here.
141 We push the remaining call-clobbered registers here, and also
142 R1 -- to keep the stack correctly aligned. */
143 /* Tell the unwinder that r2 has already been pushed. */
145 cfi_adjust_cfa_offset (4)
146 cfi_rel_offset (r2, 0)
147 .save {r0,r1,r3,ip,lr}
148 push {r0, r1, r3, ip, lr}
149 cfi_adjust_cfa_offset (20)
150 cfi_rel_offset (r0, 0)
151 cfi_rel_offset (r1, 4)
152 cfi_rel_offset (r3, 8)
153 cfi_rel_offset (ip, 12)
154 cfi_rel_offset (lr, 16)
155 bl _dl_tlsdesc_lazy_resolver_fixup
156 pop {r0, r1, r3, ip, lr}
157 cfi_adjust_cfa_offset (-20)
164 cfi_adjust_cfa_offset (-4)
170 .size _dl_tlsdesc_lazy_resolver, .-_dl_tlsdesc_lazy_resolver
172 /* Holder for lazy tls descriptors being resolve in another thread.
173 Same ABI as the lazy resolver itself. */
174 .hidden _dl_tlsdesc_resolve_hold
175 .global _dl_tlsdesc_resolve_hold
176 .type _dl_tlsdesc_resolve_hold,#function
180 _dl_tlsdesc_resolve_hold:
181 /* Tell the unwinder that r2 has already been pushed. */
183 cfi_adjust_cfa_offset (4)
184 cfi_rel_offset (r2, 0)
185 .save {r0,r1,r3,ip,lr}
186 push {r0, r1, r3, ip, lr}
187 cfi_adjust_cfa_offset (20)
188 cfi_rel_offset (r0, 0)
189 cfi_rel_offset (r1, 4)
190 cfi_rel_offset (r3, 8)
191 cfi_rel_offset (ip, 12)
192 cfi_rel_offset (lr, 16)
193 adr r2, _dl_tlsdesc_resolve_hold
194 bl _dl_tlsdesc_resolve_hold_fixup
195 pop {r0, r1, r3, ip, lr}
196 cfi_adjust_cfa_offset (-20)
203 cfi_adjust_cfa_offset (-4)
209 .size _dl_tlsdesc_resolve_hold, .-_dl_tlsdesc_resolve_hold