2003-01-28 10:42:28 +00:00
|
|
|
/* Thread-local storage handling in the ELF dynamic linker. s390 version.
|
2020-01-01 00:14:33 +00:00
|
|
|
Copyright (C) 2003-2020 Free Software Foundation, Inc.
|
2003-01-28 10:42:28 +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-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
2003-01-28 10:42:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Type used for the representation of TLS information in the GOT. */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned long int ti_module;
|
|
|
|
unsigned long int ti_offset;
|
|
|
|
} tls_index;
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SHARED
|
2013-11-29 08:57:04 +00:00
|
|
|
|
2003-01-28 10:42:28 +00:00
|
|
|
extern unsigned long __tls_get_offset (unsigned long got_offset);
|
|
|
|
|
2014-11-20 15:39:43 +00:00
|
|
|
# if IS_IN (rtld)
|
2013-11-29 08:57:04 +00:00
|
|
|
|
|
|
|
# include <shlib-compat.h>
|
|
|
|
|
2015-01-14 15:56:50 +00:00
|
|
|
/* dl-tls.c declares __tls_get_addr as an exported symbol if it is not defined
|
|
|
|
as a macro. It seems suitable to do that in the generic code because all
|
|
|
|
architectures other than s390 export __tls_get_addr. The declaration causes
|
|
|
|
problems in s390 though, so we define __tls_get_addr here to avoid declaring
|
|
|
|
__tls_get_addr again. */
|
|
|
|
# define __tls_get_addr __tls_get_addr
|
|
|
|
|
2013-11-29 08:57:04 +00:00
|
|
|
extern void *__tls_get_addr (tls_index *ti) attribute_hidden;
|
|
|
|
/* Make a temporary alias of __tls_get_addr to remove the hidden
|
|
|
|
attribute. Then export __tls_get_addr as __tls_get_addr_internal
|
|
|
|
for use from libc. We do not want to export __tls_get_addr, but we
|
|
|
|
do need to use it from libc when looking up the address of a TLS
|
|
|
|
variable. We don't use __tls_get_offset because it requires r12 to
|
|
|
|
be setup and that might not always be true. Either way it's more
|
|
|
|
optimal to use __tls_get_addr directly (that's what
|
|
|
|
__tls_get_offset does anyways). */
|
|
|
|
strong_alias (__tls_get_addr, __tls_get_addr_internal_tmp);
|
|
|
|
versioned_symbol (ld, __tls_get_addr_internal_tmp,
|
|
|
|
__tls_get_addr_internal, GLIBC_PRIVATE);
|
|
|
|
|
2003-01-28 10:42:28 +00:00
|
|
|
/* The special thing about the s390 TLS ABI is that we do not have the
|
|
|
|
standard __tls_get_addr function but the __tls_get_offset function
|
|
|
|
which differs in two important aspects:
|
|
|
|
1) __tls_get_offset gets a got offset instead of a pointer to the
|
|
|
|
tls_index structure
|
|
|
|
2) __tls_get_offset returns the offset of the requested variable to
|
|
|
|
the thread descriptor instead of a pointer to the variable.
|
|
|
|
*/
|
2004-03-11 09:39:56 +00:00
|
|
|
# ifdef __s390x__
|
2015-11-20 07:56:40 +00:00
|
|
|
__asm__("\n\
|
2003-01-28 10:42:28 +00:00
|
|
|
.text\n\
|
|
|
|
.globl __tls_get_offset\n\
|
|
|
|
.type __tls_get_offset, @function\n\
|
|
|
|
.align 4\n\
|
|
|
|
__tls_get_offset:\n\
|
|
|
|
la %r2,0(%r2,%r12)\n\
|
|
|
|
jg __tls_get_addr\n\
|
|
|
|
");
|
2004-03-11 09:39:56 +00:00
|
|
|
# elif defined __s390__
|
2015-11-20 07:56:40 +00:00
|
|
|
__asm__("\n\
|
2003-01-28 10:42:28 +00:00
|
|
|
.text\n\
|
|
|
|
.globl __tls_get_offset\n\
|
|
|
|
.type __tls_get_offset, @function\n\
|
|
|
|
.align 4\n\
|
|
|
|
__tls_get_offset:\n\
|
|
|
|
basr %r3,0\n\
|
|
|
|
0: la %r2,0(%r2,%r12)\n\
|
|
|
|
l %r4,1f-0b(%r3)\n\
|
|
|
|
b 0(%r4,%r3)\n\
|
|
|
|
1: .long __tls_get_addr - 0b\n\
|
|
|
|
");
|
2004-03-11 09:39:56 +00:00
|
|
|
# endif
|
2014-11-20 15:39:43 +00:00
|
|
|
# else /* IS_IN (rtld) */
|
2013-11-29 08:57:04 +00:00
|
|
|
extern void *__tls_get_addr_internal (tls_index *ti);
|
2014-11-20 15:39:43 +00:00
|
|
|
# endif /* !IS_IN (rtld) */
|
2003-01-28 10:42:28 +00:00
|
|
|
|
2004-03-11 09:39:56 +00:00
|
|
|
# define GET_ADDR_OFFSET \
|
2003-01-28 10:42:28 +00:00
|
|
|
(ti->ti_offset - (unsigned long) __builtin_thread_pointer ())
|
|
|
|
|
2013-11-29 08:57:04 +00:00
|
|
|
/* Use the privately exported __tls_get_addr_internal instead of
|
|
|
|
__tls_get_offset in order to avoid the __tls_get_offset special
|
|
|
|
linkage requiring the GOT pointer to be set up in r12. The
|
|
|
|
compiler will take care of setting up r12 only if itself issued the
|
|
|
|
__tls_get_offset call. */
|
|
|
|
# define __TLS_GET_ADDR(__ti) \
|
2014-01-07 08:40:39 +00:00
|
|
|
({ __tls_get_addr_internal (__ti) \
|
2013-11-29 08:57:04 +00:00
|
|
|
+ (unsigned long) __builtin_thread_pointer (); })
|
2003-01-28 10:42:28 +00:00
|
|
|
|
|
|
|
#endif
|