1 /* Thread-local storage handling in the ELF dynamic linker. x86-64 version.
2 Copyright (C) 2017-2024 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 <https://www.gnu.org/licenses/>. */
20 /* Work around GCC PR58066, due to which __tls_get_addr may be called
21 with an unaligned stack. The compat implementation is in
22 tls_get_addr-compat.S. */
26 /* Define __tls_get_addr within elf/dl-tls.c under a different
28 extern __typeof__ (__tls_get_addr
) ___tls_get_addr
;
30 # define __tls_get_addr ___tls_get_addr
31 # include <elf/dl-tls.c>
32 # undef __tls_get_addr
34 hidden_ver (___tls_get_addr
, __tls_get_addr
)
36 /* Only handle slow paths for __tls_get_addr. */
39 __tls_get_addr_slow (GET_ADDR_ARGS
)
41 dtv_t
*dtv
= THREAD_DTV ();
43 size_t gen
= atomic_load_acquire (&GL(dl_tls_generation
));
44 if (__glibc_unlikely (dtv
[0].counter
!= gen
)
45 /* See comment in __tls_get_addr in elf/dl-tls.c. */
46 && !(_dl_tls_allocate_active ()
47 && GET_ADDR_MODULE
< _dl_tls_initial_modid_limit
))
48 return update_get_addr (GET_ADDR_PARAM
, gen
);
50 return tls_get_addr_tail (GET_ADDR_PARAM
, dtv
, NULL
);
54 /* No compatibility symbol needed. */
55 # include <elf/dl-tls.c>