1 /* Thread-local storage handling in the ELF dynamic linker. s390 version.
2 Copyright (C) 2003-2015 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/>. */
20 /* Type used for the representation of TLS information in the GOT. */
23 unsigned long int ti_module
;
24 unsigned long int ti_offset
;
30 extern unsigned long __tls_get_offset (unsigned long got_offset
);
34 # include <shlib-compat.h>
36 extern void *__tls_get_addr (tls_index
*ti
) attribute_hidden
;
37 /* Make a temporary alias of __tls_get_addr to remove the hidden
38 attribute. Then export __tls_get_addr as __tls_get_addr_internal
39 for use from libc. We do not want to export __tls_get_addr, but we
40 do need to use it from libc when looking up the address of a TLS
41 variable. We don't use __tls_get_offset because it requires r12 to
42 be setup and that might not always be true. Either way it's more
43 optimal to use __tls_get_addr directly (that's what
44 __tls_get_offset does anyways). */
45 strong_alias (__tls_get_addr
, __tls_get_addr_internal_tmp
);
46 versioned_symbol (ld
, __tls_get_addr_internal_tmp
,
47 __tls_get_addr_internal
, GLIBC_PRIVATE
);
49 /* The special thing about the s390 TLS ABI is that we do not have the
50 standard __tls_get_addr function but the __tls_get_offset function
51 which differs in two important aspects:
52 1) __tls_get_offset gets a got offset instead of a pointer to the
54 2) __tls_get_offset returns the offset of the requested variable to
55 the thread descriptor instead of a pointer to the variable.
60 .globl __tls_get_offset\n\
61 .type __tls_get_offset, @function\n\
67 # elif defined __s390__
70 .globl __tls_get_offset\n\
71 .type __tls_get_offset, @function\n\
75 0: la %r2,0(%r2,%r12)\n\
78 1: .long __tls_get_addr - 0b\n\
81 # else /* IS_IN (rtld) */
82 extern void *__tls_get_addr_internal (tls_index
*ti
);
83 # endif /* !IS_IN (rtld) */
85 # define GET_ADDR_OFFSET \
86 (ti->ti_offset - (unsigned long) __builtin_thread_pointer ())
88 /* Use the privately exported __tls_get_addr_internal instead of
89 __tls_get_offset in order to avoid the __tls_get_offset special
90 linkage requiring the GOT pointer to be set up in r12. The
91 compiler will take care of setting up r12 only if itself issued the
92 __tls_get_offset call. */
93 # define __TLS_GET_ADDR(__ti) \
94 ({ __tls_get_addr_internal (__ti) \
95 + (unsigned long) __builtin_thread_pointer (); })
99 /* Value used for dtv entries for which the allocation is delayed. */
100 #define TLS_DTV_UNALLOCATED ((void *) -1l)