2011-03-05 03:39:15 +00:00
|
|
|
/* Thread-local storage handling in the ELF dynamic linker. ARM version.
|
2017-01-01 00:14:16 +00:00
|
|
|
Copyright (C) 2006-2017 Free Software Foundation, Inc.
|
2011-03-05 03:39:15 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-03-09 23:56:38 +00:00
|
|
|
License along with the GNU C Library. If not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
2011-03-05 03:39:15 +00:00
|
|
|
|
|
|
|
#include <sysdep.h>
|
2013-03-18 22:00:44 +00:00
|
|
|
#include <arm-features.h>
|
2011-03-05 03:39:15 +00:00
|
|
|
#include <tls.h>
|
|
|
|
#include "tlsdesc.h"
|
|
|
|
|
|
|
|
.text
|
|
|
|
@ emit debug information with cfi
|
|
|
|
@ use arm-specific pseudos for unwinding itself
|
2013-02-28 00:36:47 +00:00
|
|
|
CFI_SECTIONS
|
2011-03-05 03:39:15 +00:00
|
|
|
.hidden _dl_tlsdesc_return
|
|
|
|
.global _dl_tlsdesc_return
|
|
|
|
.type _dl_tlsdesc_return,#function
|
|
|
|
cfi_startproc
|
2013-04-19 18:33:01 +00:00
|
|
|
eabi_fnstart
|
2011-03-05 03:39:15 +00:00
|
|
|
.align 2
|
|
|
|
_dl_tlsdesc_return:
|
Remove sfi_* annotations from ARM assembly files.
This semi-mechanical patch removes all uses and definitions of the
sfi_breg, sfi_pld, and sfi_sp macros from various ARM-specific
assembly files. These were only used by NaCl.
* sysdeps/arm/sysdep.h
(ARM_SFI_MACROS, sfi_breg, sfi_pld, sfi_sp): Delete definitions.
* sysdeps/arm/__longjmp.S, sysdeps/arm/add_n.S
* sysdeps/arm/addmul_1.S, sysdeps/arm/arm-mcount.S
* sysdeps/arm/armv6/rawmemchr.S, sysdeps/arm/armv6/strchr.S
* sysdeps/arm/armv6/strcpy.S, sysdeps/arm/armv6/strlen.S
* sysdeps/arm/armv6/strrchr.S, sysdeps/arm/armv6t2/memchr.S
* sysdeps/arm/armv6t2/strlen.S
* sysdeps/arm/armv7/multiarch/memcpy_impl.S
* sysdeps/arm/armv7/strcmp.S, sysdeps/arm/dl-tlsdesc.S
* sysdeps/arm/memcpy.S, sysdeps/arm/memmove.S
* sysdeps/arm/memset.S, sysdeps/arm/setjmp.S
* sysdeps/arm/strlen.S, sysdeps/arm/submul_1.S:
Remove all uses of sfi_breg, sfi_pld, and sfi_sp.
2017-05-12 00:36:15 +00:00
|
|
|
ldr r0, [r0]
|
2011-03-05 03:39:15 +00:00
|
|
|
BX (lr)
|
2013-04-19 18:33:01 +00:00
|
|
|
eabi_fnend
|
2011-03-05 03:39:15 +00:00
|
|
|
cfi_endproc
|
|
|
|
.size _dl_tlsdesc_return, .-_dl_tlsdesc_return
|
|
|
|
|
|
|
|
.hidden _dl_tlsdesc_undefweak
|
|
|
|
.global _dl_tlsdesc_undefweak
|
|
|
|
.type _dl_tlsdesc_undefweak,#function
|
|
|
|
cfi_startproc
|
2013-04-19 18:33:01 +00:00
|
|
|
eabi_fnstart
|
2011-03-05 03:39:15 +00:00
|
|
|
.align 2
|
|
|
|
_dl_tlsdesc_undefweak:
|
2013-02-14 04:10:45 +00:00
|
|
|
GET_TLS (r1)
|
2011-03-05 03:39:15 +00:00
|
|
|
rsb r0, r0, #0
|
|
|
|
BX (lr)
|
|
|
|
cfi_endproc
|
2013-04-19 18:33:01 +00:00
|
|
|
eabi_fnend
|
2011-03-05 03:39:15 +00:00
|
|
|
.size _dl_tlsdesc_undefweak, .-_dl_tlsdesc_undefweak
|
|
|
|
|
|
|
|
#ifdef SHARED
|
|
|
|
.hidden _dl_tlsdesc_dynamic
|
|
|
|
.global _dl_tlsdesc_dynamic
|
|
|
|
.type _dl_tlsdesc_dynamic,#function
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
The assembly code that follows is a rendition of the following
|
|
|
|
C code, hand-optimized a little bit.
|
|
|
|
|
|
|
|
ptrdiff_t
|
|
|
|
_dl_tlsdesc_dynamic(struct tlsdesc *tdp)
|
|
|
|
{
|
|
|
|
struct tlsdesc_dynamic_arg *td = tdp->argument.pointer;
|
|
|
|
dtv_t *dtv = (dtv_t *)THREAD_DTV();
|
|
|
|
if (__builtin_expect (td->gen_count <= dtv[0].counter
|
|
|
|
&& dtv[td->tlsinfo.ti_module].pointer.val
|
|
|
|
!= TLS_DTV_UNALLOCATED,
|
|
|
|
1))
|
|
|
|
return dtv[td->tlsinfo.ti_module].pointer.val +
|
|
|
|
td->tlsinfo.ti_offset - __builtin_thread_pointer();
|
|
|
|
|
|
|
|
return __tls_get_addr (&td->tlsinfo) - __builtin_thread_pointer();
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
cfi_startproc
|
2013-04-19 18:33:01 +00:00
|
|
|
eabi_fnstart
|
2011-03-05 03:39:15 +00:00
|
|
|
.align 2
|
|
|
|
_dl_tlsdesc_dynamic:
|
|
|
|
/* Our calling convention is to clobber r0, r1 and the processor
|
|
|
|
flags. All others that are modified must be saved */
|
2013-04-19 18:33:01 +00:00
|
|
|
eabi_save ({r2,r3,r4,lr})
|
2013-02-15 05:00:14 +00:00
|
|
|
push {r2,r3,r4,lr}
|
2011-03-05 03:39:15 +00:00
|
|
|
cfi_adjust_cfa_offset (16)
|
|
|
|
cfi_rel_offset (r2,0)
|
|
|
|
cfi_rel_offset (r3,4)
|
|
|
|
cfi_rel_offset (r4,8)
|
|
|
|
cfi_rel_offset (lr,12)
|
Remove sfi_* annotations from ARM assembly files.
This semi-mechanical patch removes all uses and definitions of the
sfi_breg, sfi_pld, and sfi_sp macros from various ARM-specific
assembly files. These were only used by NaCl.
* sysdeps/arm/sysdep.h
(ARM_SFI_MACROS, sfi_breg, sfi_pld, sfi_sp): Delete definitions.
* sysdeps/arm/__longjmp.S, sysdeps/arm/add_n.S
* sysdeps/arm/addmul_1.S, sysdeps/arm/arm-mcount.S
* sysdeps/arm/armv6/rawmemchr.S, sysdeps/arm/armv6/strchr.S
* sysdeps/arm/armv6/strcpy.S, sysdeps/arm/armv6/strlen.S
* sysdeps/arm/armv6/strrchr.S, sysdeps/arm/armv6t2/memchr.S
* sysdeps/arm/armv6t2/strlen.S
* sysdeps/arm/armv7/multiarch/memcpy_impl.S
* sysdeps/arm/armv7/strcmp.S, sysdeps/arm/dl-tlsdesc.S
* sysdeps/arm/memcpy.S, sysdeps/arm/memmove.S
* sysdeps/arm/memset.S, sysdeps/arm/setjmp.S
* sysdeps/arm/strlen.S, sysdeps/arm/submul_1.S:
Remove all uses of sfi_breg, sfi_pld, and sfi_sp.
2017-05-12 00:36:15 +00:00
|
|
|
ldr r1, [r0] /* td */
|
2013-02-14 04:10:45 +00:00
|
|
|
GET_TLS (lr)
|
2011-03-05 03:39:15 +00:00
|
|
|
mov r4, r0 /* r4 = tp */
|
Remove sfi_* annotations from ARM assembly files.
This semi-mechanical patch removes all uses and definitions of the
sfi_breg, sfi_pld, and sfi_sp macros from various ARM-specific
assembly files. These were only used by NaCl.
* sysdeps/arm/sysdep.h
(ARM_SFI_MACROS, sfi_breg, sfi_pld, sfi_sp): Delete definitions.
* sysdeps/arm/__longjmp.S, sysdeps/arm/add_n.S
* sysdeps/arm/addmul_1.S, sysdeps/arm/arm-mcount.S
* sysdeps/arm/armv6/rawmemchr.S, sysdeps/arm/armv6/strchr.S
* sysdeps/arm/armv6/strcpy.S, sysdeps/arm/armv6/strlen.S
* sysdeps/arm/armv6/strrchr.S, sysdeps/arm/armv6t2/memchr.S
* sysdeps/arm/armv6t2/strlen.S
* sysdeps/arm/armv7/multiarch/memcpy_impl.S
* sysdeps/arm/armv7/strcmp.S, sysdeps/arm/dl-tlsdesc.S
* sysdeps/arm/memcpy.S, sysdeps/arm/memmove.S
* sysdeps/arm/memset.S, sysdeps/arm/setjmp.S
* sysdeps/arm/strlen.S, sysdeps/arm/submul_1.S:
Remove all uses of sfi_breg, sfi_pld, and sfi_sp.
2017-05-12 00:36:15 +00:00
|
|
|
ldr r0, [r0]
|
|
|
|
ldr r2, [r1, #8] /* gen_count */
|
|
|
|
ldr r3, [r0]
|
2011-03-05 03:39:15 +00:00
|
|
|
cmp r2, r3
|
|
|
|
bhi 1f
|
Remove sfi_* annotations from ARM assembly files.
This semi-mechanical patch removes all uses and definitions of the
sfi_breg, sfi_pld, and sfi_sp macros from various ARM-specific
assembly files. These were only used by NaCl.
* sysdeps/arm/sysdep.h
(ARM_SFI_MACROS, sfi_breg, sfi_pld, sfi_sp): Delete definitions.
* sysdeps/arm/__longjmp.S, sysdeps/arm/add_n.S
* sysdeps/arm/addmul_1.S, sysdeps/arm/arm-mcount.S
* sysdeps/arm/armv6/rawmemchr.S, sysdeps/arm/armv6/strchr.S
* sysdeps/arm/armv6/strcpy.S, sysdeps/arm/armv6/strlen.S
* sysdeps/arm/armv6/strrchr.S, sysdeps/arm/armv6t2/memchr.S
* sysdeps/arm/armv6t2/strlen.S
* sysdeps/arm/armv7/multiarch/memcpy_impl.S
* sysdeps/arm/armv7/strcmp.S, sysdeps/arm/dl-tlsdesc.S
* sysdeps/arm/memcpy.S, sysdeps/arm/memmove.S
* sysdeps/arm/memset.S, sysdeps/arm/setjmp.S
* sysdeps/arm/strlen.S, sysdeps/arm/submul_1.S:
Remove all uses of sfi_breg, sfi_pld, and sfi_sp.
2017-05-12 00:36:15 +00:00
|
|
|
ldr r3, [r1]
|
2013-03-18 22:00:44 +00:00
|
|
|
#ifndef ARM_NO_INDEX_REGISTER
|
2011-03-05 03:39:15 +00:00
|
|
|
ldr r2, [r0, r3, lsl #3]
|
2013-03-18 22:00:44 +00:00
|
|
|
#else
|
|
|
|
add lr, r0, r3, lsl #3
|
Remove sfi_* annotations from ARM assembly files.
This semi-mechanical patch removes all uses and definitions of the
sfi_breg, sfi_pld, and sfi_sp macros from various ARM-specific
assembly files. These were only used by NaCl.
* sysdeps/arm/sysdep.h
(ARM_SFI_MACROS, sfi_breg, sfi_pld, sfi_sp): Delete definitions.
* sysdeps/arm/__longjmp.S, sysdeps/arm/add_n.S
* sysdeps/arm/addmul_1.S, sysdeps/arm/arm-mcount.S
* sysdeps/arm/armv6/rawmemchr.S, sysdeps/arm/armv6/strchr.S
* sysdeps/arm/armv6/strcpy.S, sysdeps/arm/armv6/strlen.S
* sysdeps/arm/armv6/strrchr.S, sysdeps/arm/armv6t2/memchr.S
* sysdeps/arm/armv6t2/strlen.S
* sysdeps/arm/armv7/multiarch/memcpy_impl.S
* sysdeps/arm/armv7/strcmp.S, sysdeps/arm/dl-tlsdesc.S
* sysdeps/arm/memcpy.S, sysdeps/arm/memmove.S
* sysdeps/arm/memset.S, sysdeps/arm/setjmp.S
* sysdeps/arm/strlen.S, sysdeps/arm/submul_1.S:
Remove all uses of sfi_breg, sfi_pld, and sfi_sp.
2017-05-12 00:36:15 +00:00
|
|
|
ldr r2, [lr]
|
2013-03-18 22:00:44 +00:00
|
|
|
#endif
|
2011-03-05 03:39:15 +00:00
|
|
|
cmn r2, #1
|
2013-02-14 04:27:09 +00:00
|
|
|
ittt ne
|
2011-03-05 03:39:15 +00:00
|
|
|
ldrne r3, [r1, #4]
|
|
|
|
addne r3, r2, r3
|
|
|
|
rsbne r0, r4, r3
|
|
|
|
bne 2f
|
|
|
|
1: mov r0, r1
|
|
|
|
bl __tls_get_addr
|
|
|
|
rsb r0, r4, r0
|
2013-02-15 06:15:55 +00:00
|
|
|
2:
|
2013-03-18 22:00:44 +00:00
|
|
|
#if ((defined (__ARM_ARCH_4T__) && defined (__THUMB_INTERWORK__)) \
|
|
|
|
|| defined (ARM_ALWAYS_BX))
|
2013-02-15 06:15:55 +00:00
|
|
|
pop {r2,r3,r4, lr}
|
2011-03-05 03:39:15 +00:00
|
|
|
cfi_adjust_cfa_offset (-16)
|
|
|
|
cfi_restore (lr)
|
|
|
|
cfi_restore (r4)
|
|
|
|
cfi_restore (r3)
|
|
|
|
cfi_restore (r2)
|
2013-02-15 06:15:55 +00:00
|
|
|
bx lr
|
|
|
|
#else
|
|
|
|
pop {r2,r3,r4, pc}
|
|
|
|
#endif
|
2013-04-19 18:33:01 +00:00
|
|
|
eabi_fnend
|
2011-03-05 03:39:15 +00:00
|
|
|
cfi_endproc
|
|
|
|
.size _dl_tlsdesc_dynamic, .-_dl_tlsdesc_dynamic
|
|
|
|
#endif /* SHARED */
|
|
|
|
|
|
|
|
/* lazy resolved for tls descriptors. */
|
|
|
|
.hidden _dl_tlsdesc_lazy_resolver
|
|
|
|
.global _dl_tlsdesc_lazy_resolver
|
|
|
|
.type _dl_tlsdesc_lazy_resolver,#function
|
|
|
|
cfi_startproc
|
2013-04-19 18:33:01 +00:00
|
|
|
eabi_fnstart
|
2011-03-05 03:39:15 +00:00
|
|
|
.align 2
|
|
|
|
_dl_tlsdesc_lazy_resolver:
|
|
|
|
/* r0 points at the tlsdesc,
|
|
|
|
r1 points at the GOT
|
|
|
|
r2 was pushed by the trampoline and used as a temp,
|
|
|
|
we need to pop it here.
|
|
|
|
We push the remaining call-clobbered registers here, and also
|
|
|
|
R1 -- to keep the stack correctly aligned. */
|
|
|
|
/* Tell the unwinder that r2 has already been pushed. */
|
2013-04-19 18:33:01 +00:00
|
|
|
eabi_save ({r2})
|
2011-03-05 03:39:15 +00:00
|
|
|
cfi_adjust_cfa_offset (4)
|
|
|
|
cfi_rel_offset (r2, 0)
|
2013-04-19 18:33:01 +00:00
|
|
|
eabi_save ({r0,r1,r3,ip,lr})
|
2013-02-15 05:00:14 +00:00
|
|
|
push {r0, r1, r3, ip, lr}
|
2011-03-05 03:39:15 +00:00
|
|
|
cfi_adjust_cfa_offset (20)
|
|
|
|
cfi_rel_offset (r0, 0)
|
|
|
|
cfi_rel_offset (r1, 4)
|
|
|
|
cfi_rel_offset (r3, 8)
|
|
|
|
cfi_rel_offset (ip, 12)
|
|
|
|
cfi_rel_offset (lr, 16)
|
|
|
|
bl _dl_tlsdesc_lazy_resolver_fixup
|
2013-02-15 05:00:14 +00:00
|
|
|
pop {r0, r1, r3, ip, lr}
|
2011-03-05 03:39:15 +00:00
|
|
|
cfi_adjust_cfa_offset (-20)
|
|
|
|
cfi_restore (lr)
|
|
|
|
cfi_restore (ip)
|
|
|
|
cfi_restore (r3)
|
|
|
|
cfi_restore (r1)
|
|
|
|
cfi_restore (r0)
|
2013-02-15 05:00:14 +00:00
|
|
|
pop {r2}
|
2011-03-05 03:39:15 +00:00
|
|
|
cfi_adjust_cfa_offset (-4)
|
|
|
|
cfi_restore (r2)
|
Remove sfi_* annotations from ARM assembly files.
This semi-mechanical patch removes all uses and definitions of the
sfi_breg, sfi_pld, and sfi_sp macros from various ARM-specific
assembly files. These were only used by NaCl.
* sysdeps/arm/sysdep.h
(ARM_SFI_MACROS, sfi_breg, sfi_pld, sfi_sp): Delete definitions.
* sysdeps/arm/__longjmp.S, sysdeps/arm/add_n.S
* sysdeps/arm/addmul_1.S, sysdeps/arm/arm-mcount.S
* sysdeps/arm/armv6/rawmemchr.S, sysdeps/arm/armv6/strchr.S
* sysdeps/arm/armv6/strcpy.S, sysdeps/arm/armv6/strlen.S
* sysdeps/arm/armv6/strrchr.S, sysdeps/arm/armv6t2/memchr.S
* sysdeps/arm/armv6t2/strlen.S
* sysdeps/arm/armv7/multiarch/memcpy_impl.S
* sysdeps/arm/armv7/strcmp.S, sysdeps/arm/dl-tlsdesc.S
* sysdeps/arm/memcpy.S, sysdeps/arm/memmove.S
* sysdeps/arm/memset.S, sysdeps/arm/setjmp.S
* sysdeps/arm/strlen.S, sysdeps/arm/submul_1.S:
Remove all uses of sfi_breg, sfi_pld, and sfi_sp.
2017-05-12 00:36:15 +00:00
|
|
|
ldr r1, [r0, #4]
|
2011-03-05 03:39:15 +00:00
|
|
|
BX (r1)
|
2013-04-19 18:33:01 +00:00
|
|
|
eabi_fnend
|
2011-03-05 03:39:15 +00:00
|
|
|
cfi_endproc
|
|
|
|
.size _dl_tlsdesc_lazy_resolver, .-_dl_tlsdesc_lazy_resolver
|
|
|
|
|
|
|
|
/* Holder for lazy tls descriptors being resolve in another thread.
|
2014-05-23 14:24:30 +00:00
|
|
|
|
|
|
|
Our calling convention is to clobber r0, r1 and the processor
|
|
|
|
flags. All others that are modified must be saved */
|
2011-03-05 03:39:15 +00:00
|
|
|
.hidden _dl_tlsdesc_resolve_hold
|
|
|
|
.global _dl_tlsdesc_resolve_hold
|
|
|
|
.type _dl_tlsdesc_resolve_hold,#function
|
|
|
|
cfi_startproc
|
2013-04-19 18:33:01 +00:00
|
|
|
eabi_fnstart
|
2011-03-05 03:39:15 +00:00
|
|
|
.align 2
|
|
|
|
_dl_tlsdesc_resolve_hold:
|
2015-10-14 15:58:41 +00:00
|
|
|
/* r0 is saved so its original value can be used after the call and
|
|
|
|
r1 is saved only to keep the stack aligned. (r0 points to the tls
|
|
|
|
descriptor, it is passed to _dl_tlsdesc_resolve_hold_fixup which
|
|
|
|
is a void function that may clobber r0, later r0 is used to load
|
|
|
|
the new resolver.) */
|
|
|
|
eabi_save ({r0,r1,r2,r3,ip,lr})
|
|
|
|
push {r0, r1, r2, r3, ip, lr}
|
|
|
|
cfi_adjust_cfa_offset (24)
|
|
|
|
cfi_rel_offset (r0, 0)
|
|
|
|
cfi_rel_offset (r1, 4)
|
|
|
|
cfi_rel_offset (r2, 8)
|
|
|
|
cfi_rel_offset (r3, 12)
|
|
|
|
cfi_rel_offset (ip, 16)
|
|
|
|
cfi_rel_offset (lr, 20)
|
2014-05-23 14:24:30 +00:00
|
|
|
adr r1, _dl_tlsdesc_resolve_hold
|
2011-03-05 03:39:15 +00:00
|
|
|
bl _dl_tlsdesc_resolve_hold_fixup
|
2015-10-14 15:58:41 +00:00
|
|
|
pop {r0, r1, r2, r3, ip, lr}
|
|
|
|
cfi_adjust_cfa_offset (-24)
|
2011-03-05 03:39:15 +00:00
|
|
|
cfi_restore (lr)
|
|
|
|
cfi_restore (ip)
|
|
|
|
cfi_restore (r3)
|
|
|
|
cfi_restore (r2)
|
2015-10-14 15:58:41 +00:00
|
|
|
cfi_restore (r1)
|
|
|
|
cfi_restore (r0)
|
Remove sfi_* annotations from ARM assembly files.
This semi-mechanical patch removes all uses and definitions of the
sfi_breg, sfi_pld, and sfi_sp macros from various ARM-specific
assembly files. These were only used by NaCl.
* sysdeps/arm/sysdep.h
(ARM_SFI_MACROS, sfi_breg, sfi_pld, sfi_sp): Delete definitions.
* sysdeps/arm/__longjmp.S, sysdeps/arm/add_n.S
* sysdeps/arm/addmul_1.S, sysdeps/arm/arm-mcount.S
* sysdeps/arm/armv6/rawmemchr.S, sysdeps/arm/armv6/strchr.S
* sysdeps/arm/armv6/strcpy.S, sysdeps/arm/armv6/strlen.S
* sysdeps/arm/armv6/strrchr.S, sysdeps/arm/armv6t2/memchr.S
* sysdeps/arm/armv6t2/strlen.S
* sysdeps/arm/armv7/multiarch/memcpy_impl.S
* sysdeps/arm/armv7/strcmp.S, sysdeps/arm/dl-tlsdesc.S
* sysdeps/arm/memcpy.S, sysdeps/arm/memmove.S
* sysdeps/arm/memset.S, sysdeps/arm/setjmp.S
* sysdeps/arm/strlen.S, sysdeps/arm/submul_1.S:
Remove all uses of sfi_breg, sfi_pld, and sfi_sp.
2017-05-12 00:36:15 +00:00
|
|
|
ldr r1, [r0, #4]
|
2011-03-05 03:39:15 +00:00
|
|
|
BX (r1)
|
2013-04-19 18:33:01 +00:00
|
|
|
eabi_fnend
|
2011-03-05 03:39:15 +00:00
|
|
|
cfi_endproc
|
|
|
|
.size _dl_tlsdesc_resolve_hold, .-_dl_tlsdesc_resolve_hold
|