|
|
548bcb |
commit a75a02a696f9f869d77b17b99964823aa8833a8b
|
|
|
548bcb |
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
|
|
548bcb |
Date: Thu Feb 11 11:58:20 2021 +0000
|
|
|
548bcb |
|
|
|
548bcb |
i386: Remove lazy tlsdesc relocation related code
|
|
|
548bcb |
|
|
|
548bcb |
Like in commit e75711ebfa976d5468ec292282566a18b07e4d67 for x86_64,
|
|
|
548bcb |
remove unused lazy tlsdesc relocation processing code:
|
|
|
548bcb |
|
|
|
548bcb |
_dl_tlsdesc_resolve_abs_plus_addend
|
|
|
548bcb |
_dl_tlsdesc_resolve_rel
|
|
|
548bcb |
_dl_tlsdesc_resolve_rela
|
|
|
548bcb |
_dl_tlsdesc_resolve_hold
|
|
|
548bcb |
|
|
|
548bcb |
diff --git a/sysdeps/i386/dl-tlsdesc.S b/sysdeps/i386/dl-tlsdesc.S
|
|
|
548bcb |
index 128f0af3188f46bb..22ecb2c6adc6cc6e 100644
|
|
|
548bcb |
--- a/sysdeps/i386/dl-tlsdesc.S
|
|
|
548bcb |
+++ b/sysdeps/i386/dl-tlsdesc.S
|
|
|
548bcb |
@@ -138,159 +138,3 @@ _dl_tlsdesc_dynamic:
|
|
|
548bcb |
cfi_endproc
|
|
|
548bcb |
.size _dl_tlsdesc_dynamic, .-_dl_tlsdesc_dynamic
|
|
|
548bcb |
#endif /* SHARED */
|
|
|
548bcb |
-
|
|
|
548bcb |
- /* This function is a wrapper for a lazy resolver for TLS_DESC
|
|
|
548bcb |
- REL relocations that reference the *ABS* segment in their own
|
|
|
548bcb |
- link maps. %ebx points to the caller's GOT. %eax points to a
|
|
|
548bcb |
- TLS descriptor, such that 0(%eax) holds the address of the
|
|
|
548bcb |
- resolver wrapper itself (unless some other thread beat us to
|
|
|
548bcb |
- it) and 4(%eax) holds the addend in the relocation.
|
|
|
548bcb |
-
|
|
|
548bcb |
- When the actual resolver returns, it will have adjusted the
|
|
|
548bcb |
- TLS descriptor such that we can tail-call it for it to return
|
|
|
548bcb |
- the TP offset of the symbol. */
|
|
|
548bcb |
-
|
|
|
548bcb |
- .hidden _dl_tlsdesc_resolve_abs_plus_addend
|
|
|
548bcb |
- .global _dl_tlsdesc_resolve_abs_plus_addend
|
|
|
548bcb |
- .type _dl_tlsdesc_resolve_abs_plus_addend,@function
|
|
|
548bcb |
- cfi_startproc
|
|
|
548bcb |
- .align 16
|
|
|
548bcb |
-_dl_tlsdesc_resolve_abs_plus_addend:
|
|
|
548bcb |
-0:
|
|
|
548bcb |
- _CET_ENDBR
|
|
|
548bcb |
- pushl %eax
|
|
|
548bcb |
- cfi_adjust_cfa_offset (4)
|
|
|
548bcb |
- pushl %ecx
|
|
|
548bcb |
- cfi_adjust_cfa_offset (4)
|
|
|
548bcb |
- pushl %edx
|
|
|
548bcb |
- cfi_adjust_cfa_offset (4)
|
|
|
548bcb |
- movl $1f - 0b, %ecx
|
|
|
548bcb |
- movl 4(%ebx), %edx
|
|
|
548bcb |
- call _dl_tlsdesc_resolve_abs_plus_addend_fixup
|
|
|
548bcb |
-1:
|
|
|
548bcb |
- popl %edx
|
|
|
548bcb |
- cfi_adjust_cfa_offset (-4)
|
|
|
548bcb |
- popl %ecx
|
|
|
548bcb |
- cfi_adjust_cfa_offset (-4)
|
|
|
548bcb |
- popl %eax
|
|
|
548bcb |
- cfi_adjust_cfa_offset (-4)
|
|
|
548bcb |
- jmp *(%eax)
|
|
|
548bcb |
- cfi_endproc
|
|
|
548bcb |
- .size _dl_tlsdesc_resolve_abs_plus_addend, .-_dl_tlsdesc_resolve_abs_plus_addend
|
|
|
548bcb |
-
|
|
|
548bcb |
- /* This function is a wrapper for a lazy resolver for TLS_DESC
|
|
|
548bcb |
- REL relocations that had zero addends. %ebx points to the
|
|
|
548bcb |
- caller's GOT. %eax points to a TLS descriptor, such that
|
|
|
548bcb |
- 0(%eax) holds the address of the resolver wrapper itself
|
|
|
548bcb |
- (unless some other thread beat us to it) and 4(%eax) holds a
|
|
|
548bcb |
- pointer to the relocation.
|
|
|
548bcb |
-
|
|
|
548bcb |
- When the actual resolver returns, it will have adjusted the
|
|
|
548bcb |
- TLS descriptor such that we can tail-call it for it to return
|
|
|
548bcb |
- the TP offset of the symbol. */
|
|
|
548bcb |
-
|
|
|
548bcb |
- .hidden _dl_tlsdesc_resolve_rel
|
|
|
548bcb |
- .global _dl_tlsdesc_resolve_rel
|
|
|
548bcb |
- .type _dl_tlsdesc_resolve_rel,@function
|
|
|
548bcb |
- cfi_startproc
|
|
|
548bcb |
- .align 16
|
|
|
548bcb |
-_dl_tlsdesc_resolve_rel:
|
|
|
548bcb |
-0:
|
|
|
548bcb |
- _CET_ENDBR
|
|
|
548bcb |
- pushl %eax
|
|
|
548bcb |
- cfi_adjust_cfa_offset (4)
|
|
|
548bcb |
- pushl %ecx
|
|
|
548bcb |
- cfi_adjust_cfa_offset (4)
|
|
|
548bcb |
- pushl %edx
|
|
|
548bcb |
- cfi_adjust_cfa_offset (4)
|
|
|
548bcb |
- movl $1f - 0b, %ecx
|
|
|
548bcb |
- movl 4(%ebx), %edx
|
|
|
548bcb |
- call _dl_tlsdesc_resolve_rel_fixup
|
|
|
548bcb |
-1:
|
|
|
548bcb |
- popl %edx
|
|
|
548bcb |
- cfi_adjust_cfa_offset (-4)
|
|
|
548bcb |
- popl %ecx
|
|
|
548bcb |
- cfi_adjust_cfa_offset (-4)
|
|
|
548bcb |
- popl %eax
|
|
|
548bcb |
- cfi_adjust_cfa_offset (-4)
|
|
|
548bcb |
- jmp *(%eax)
|
|
|
548bcb |
- cfi_endproc
|
|
|
548bcb |
- .size _dl_tlsdesc_resolve_rel, .-_dl_tlsdesc_resolve_rel
|
|
|
548bcb |
-
|
|
|
548bcb |
- /* This function is a wrapper for a lazy resolver for TLS_DESC
|
|
|
548bcb |
- RELA relocations. %ebx points to the caller's GOT. %eax
|
|
|
548bcb |
- points to a TLS descriptor, such that 0(%eax) holds the
|
|
|
548bcb |
- address of the resolver wrapper itself (unless some other
|
|
|
548bcb |
- thread beat us to it) and 4(%eax) holds a pointer to the
|
|
|
548bcb |
- relocation.
|
|
|
548bcb |
-
|
|
|
548bcb |
- When the actual resolver returns, it will have adjusted the
|
|
|
548bcb |
- TLS descriptor such that we can tail-call it for it to return
|
|
|
548bcb |
- the TP offset of the symbol. */
|
|
|
548bcb |
-
|
|
|
548bcb |
- .hidden _dl_tlsdesc_resolve_rela
|
|
|
548bcb |
- .global _dl_tlsdesc_resolve_rela
|
|
|
548bcb |
- .type _dl_tlsdesc_resolve_rela,@function
|
|
|
548bcb |
- cfi_startproc
|
|
|
548bcb |
- .align 16
|
|
|
548bcb |
-_dl_tlsdesc_resolve_rela:
|
|
|
548bcb |
-0:
|
|
|
548bcb |
- _CET_ENDBR
|
|
|
548bcb |
- pushl %eax
|
|
|
548bcb |
- cfi_adjust_cfa_offset (4)
|
|
|
548bcb |
- pushl %ecx
|
|
|
548bcb |
- cfi_adjust_cfa_offset (4)
|
|
|
548bcb |
- pushl %edx
|
|
|
548bcb |
- cfi_adjust_cfa_offset (4)
|
|
|
548bcb |
- movl $1f - 0b, %ecx
|
|
|
548bcb |
- movl 4(%ebx), %edx
|
|
|
548bcb |
- call _dl_tlsdesc_resolve_rela_fixup
|
|
|
548bcb |
-1:
|
|
|
548bcb |
- popl %edx
|
|
|
548bcb |
- cfi_adjust_cfa_offset (-4)
|
|
|
548bcb |
- popl %ecx
|
|
|
548bcb |
- cfi_adjust_cfa_offset (-4)
|
|
|
548bcb |
- popl %eax
|
|
|
548bcb |
- cfi_adjust_cfa_offset (-4)
|
|
|
548bcb |
- jmp *(%eax)
|
|
|
548bcb |
- cfi_endproc
|
|
|
548bcb |
- .size _dl_tlsdesc_resolve_rela, .-_dl_tlsdesc_resolve_rela
|
|
|
548bcb |
-
|
|
|
548bcb |
- /* This function is a placeholder for lazy resolving of TLS
|
|
|
548bcb |
- relocations. Once some thread starts resolving a TLS
|
|
|
548bcb |
- relocation, it sets up the TLS descriptor to use this
|
|
|
548bcb |
- resolver, such that other threads that would attempt to
|
|
|
548bcb |
- resolve it concurrently may skip the call to the original lazy
|
|
|
548bcb |
- resolver and go straight to a condition wait.
|
|
|
548bcb |
-
|
|
|
548bcb |
- When the actual resolver returns, it will have adjusted the
|
|
|
548bcb |
- TLS descriptor such that we can tail-call it for it to return
|
|
|
548bcb |
- the TP offset of the symbol. */
|
|
|
548bcb |
-
|
|
|
548bcb |
- .hidden _dl_tlsdesc_resolve_hold
|
|
|
548bcb |
- .global _dl_tlsdesc_resolve_hold
|
|
|
548bcb |
- .type _dl_tlsdesc_resolve_hold,@function
|
|
|
548bcb |
- cfi_startproc
|
|
|
548bcb |
- .align 16
|
|
|
548bcb |
-_dl_tlsdesc_resolve_hold:
|
|
|
548bcb |
-0:
|
|
|
548bcb |
- _CET_ENDBR
|
|
|
548bcb |
- pushl %eax
|
|
|
548bcb |
- cfi_adjust_cfa_offset (4)
|
|
|
548bcb |
- pushl %ecx
|
|
|
548bcb |
- cfi_adjust_cfa_offset (4)
|
|
|
548bcb |
- pushl %edx
|
|
|
548bcb |
- cfi_adjust_cfa_offset (4)
|
|
|
548bcb |
- movl $1f - 0b, %ecx
|
|
|
548bcb |
- movl 4(%ebx), %edx
|
|
|
548bcb |
- call _dl_tlsdesc_resolve_hold_fixup
|
|
|
548bcb |
-1:
|
|
|
548bcb |
- popl %edx
|
|
|
548bcb |
- cfi_adjust_cfa_offset (-4)
|
|
|
548bcb |
- popl %ecx
|
|
|
548bcb |
- cfi_adjust_cfa_offset (-4)
|
|
|
548bcb |
- popl %eax
|
|
|
548bcb |
- cfi_adjust_cfa_offset (-4)
|
|
|
548bcb |
- jmp *(%eax)
|
|
|
548bcb |
- cfi_endproc
|
|
|
548bcb |
- .size _dl_tlsdesc_resolve_hold, .-_dl_tlsdesc_resolve_hold
|
|
|
548bcb |
diff --git a/sysdeps/i386/dl-tlsdesc.h b/sysdeps/i386/dl-tlsdesc.h
|
|
|
548bcb |
index c8a1e056150dc418..1a1a22c303baf85b 100644
|
|
|
548bcb |
--- a/sysdeps/i386/dl-tlsdesc.h
|
|
|
548bcb |
+++ b/sysdeps/i386/dl-tlsdesc.h
|
|
|
548bcb |
@@ -43,11 +43,7 @@ struct tlsdesc_dynamic_arg
|
|
|
548bcb |
|
|
|
548bcb |
extern ptrdiff_t attribute_hidden __attribute__ ((regparm (1)))
|
|
|
548bcb |
_dl_tlsdesc_return (struct tlsdesc *),
|
|
|
548bcb |
- _dl_tlsdesc_undefweak (struct tlsdesc *),
|
|
|
548bcb |
- _dl_tlsdesc_resolve_abs_plus_addend (struct tlsdesc *),
|
|
|
548bcb |
- _dl_tlsdesc_resolve_rel (struct tlsdesc *),
|
|
|
548bcb |
- _dl_tlsdesc_resolve_rela (struct tlsdesc *),
|
|
|
548bcb |
- _dl_tlsdesc_resolve_hold (struct tlsdesc *);
|
|
|
548bcb |
+ _dl_tlsdesc_undefweak (struct tlsdesc *);
|
|
|
548bcb |
|
|
|
548bcb |
# ifdef SHARED
|
|
|
548bcb |
extern void *_dl_make_tlsdesc_dynamic (struct link_map *map,
|
|
|
548bcb |
diff --git a/sysdeps/i386/tlsdesc.c b/sysdeps/i386/tlsdesc.c
|
|
|
548bcb |
index 82fa8a1d35fd1912..1b4227c8381e1b3d 100644
|
|
|
548bcb |
--- a/sysdeps/i386/tlsdesc.c
|
|
|
548bcb |
+++ b/sysdeps/i386/tlsdesc.c
|
|
|
548bcb |
@@ -16,242 +16,13 @@
|
|
|
548bcb |
License along with the GNU C Library; if not, see
|
|
|
548bcb |
<http://www.gnu.org/licenses/>. */
|
|
|
548bcb |
|
|
|
548bcb |
-#include <link.h>
|
|
|
548bcb |
#include <ldsodefs.h>
|
|
|
548bcb |
-#include <elf/dynamic-link.h>
|
|
|
548bcb |
#include <tls.h>
|
|
|
548bcb |
#include <dl-tlsdesc.h>
|
|
|
548bcb |
#include <dl-unmap-segments.h>
|
|
|
548bcb |
+#define _dl_tlsdesc_resolve_hold 0
|
|
|
548bcb |
#include <tlsdeschtab.h>
|
|
|
548bcb |
|
|
|
548bcb |
-/* The following 4 functions take an entry_check_offset argument.
|
|
|
548bcb |
- It's computed by the caller as an offset between its entry point
|
|
|
548bcb |
- and the call site, such that by adding the built-in return address
|
|
|
548bcb |
- that is implicitly passed to the function with this offset, we can
|
|
|
548bcb |
- easily obtain the caller's entry point to compare with the entry
|
|
|
548bcb |
- point given in the TLS descriptor. If it's changed, we want to
|
|
|
548bcb |
- return immediately. */
|
|
|
548bcb |
-
|
|
|
548bcb |
-/* This function is used to lazily resolve TLS_DESC REL relocations
|
|
|
548bcb |
- that reference the *ABS* segment in their own link maps. The
|
|
|
548bcb |
- argument is the addend originally stored there. */
|
|
|
548bcb |
-
|
|
|
548bcb |
-void
|
|
|
548bcb |
-__attribute__ ((regparm (3))) attribute_hidden
|
|
|
548bcb |
-_dl_tlsdesc_resolve_abs_plus_addend_fixup (struct tlsdesc volatile *td,
|
|
|
548bcb |
- struct link_map *l,
|
|
|
548bcb |
- ptrdiff_t entry_check_offset)
|
|
|
548bcb |
-{
|
|
|
548bcb |
- ptrdiff_t addend = (ptrdiff_t) td->arg;
|
|
|
548bcb |
-
|
|
|
548bcb |
- if (_dl_tlsdesc_resolve_early_return_p (td, __builtin_return_address (0)
|
|
|
548bcb |
- - entry_check_offset))
|
|
|
548bcb |
- return;
|
|
|
548bcb |
-
|
|
|
548bcb |
-#ifndef SHARED
|
|
|
548bcb |
- CHECK_STATIC_TLS (l, l);
|
|
|
548bcb |
-#else
|
|
|
548bcb |
- if (!TRY_STATIC_TLS (l, l))
|
|
|
548bcb |
- {
|
|
|
548bcb |
- td->arg = _dl_make_tlsdesc_dynamic (l, addend);
|
|
|
548bcb |
- td->entry = _dl_tlsdesc_dynamic;
|
|
|
548bcb |
- }
|
|
|
548bcb |
- else
|
|
|
548bcb |
-#endif
|
|
|
548bcb |
- {
|
|
|
548bcb |
- td->arg = (void*) (addend - l->l_tls_offset);
|
|
|
548bcb |
- td->entry = _dl_tlsdesc_return;
|
|
|
548bcb |
- }
|
|
|
548bcb |
-
|
|
|
548bcb |
- _dl_tlsdesc_wake_up_held_fixups ();
|
|
|
548bcb |
-}
|
|
|
548bcb |
-
|
|
|
548bcb |
-/* This function is used to lazily resolve TLS_DESC REL relocations
|
|
|
548bcb |
- that originally had zero addends. The argument location, that
|
|
|
548bcb |
- originally held the addend, is used to hold a pointer to the
|
|
|
548bcb |
- relocation, but it has to be restored before we call the function
|
|
|
548bcb |
- that applies relocations. */
|
|
|
548bcb |
-
|
|
|
548bcb |
-void
|
|
|
548bcb |
-__attribute__ ((regparm (3))) attribute_hidden
|
|
|
548bcb |
-_dl_tlsdesc_resolve_rel_fixup (struct tlsdesc volatile *td,
|
|
|
548bcb |
- struct link_map *l,
|
|
|
548bcb |
- ptrdiff_t entry_check_offset)
|
|
|
548bcb |
-{
|
|
|
548bcb |
- const ElfW(Rel) *reloc = td->arg;
|
|
|
548bcb |
-
|
|
|
548bcb |
- if (_dl_tlsdesc_resolve_early_return_p (td, __builtin_return_address (0)
|
|
|
548bcb |
- - entry_check_offset))
|
|
|
548bcb |
- return;
|
|
|
548bcb |
-
|
|
|
548bcb |
- /* The code below was borrowed from _dl_fixup(),
|
|
|
548bcb |
- except for checking for STB_LOCAL. */
|
|
|
548bcb |
- const ElfW(Sym) *const symtab
|
|
|
548bcb |
- = (const void *) D_PTR (l, l_info[DT_SYMTAB]);
|
|
|
548bcb |
- const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]);
|
|
|
548bcb |
- const ElfW(Sym) *sym = &symtab[ELFW(R_SYM) (reloc->r_info)];
|
|
|
548bcb |
- lookup_t result;
|
|
|
548bcb |
-
|
|
|
548bcb |
- /* Look up the target symbol. If the normal lookup rules are not
|
|
|
548bcb |
- used don't look in the global scope. */
|
|
|
548bcb |
- if (ELFW(ST_BIND) (sym->st_info) != STB_LOCAL
|
|
|
548bcb |
- && __builtin_expect (ELFW(ST_VISIBILITY) (sym->st_other), 0) == 0)
|
|
|
548bcb |
- {
|
|
|
548bcb |
- const struct r_found_version *version = NULL;
|
|
|
548bcb |
-
|
|
|
548bcb |
- if (l->l_info[VERSYMIDX (DT_VERSYM)] != NULL)
|
|
|
548bcb |
- {
|
|
|
548bcb |
- const ElfW(Half) *vernum =
|
|
|
548bcb |
- (const void *) D_PTR (l, l_info[VERSYMIDX (DT_VERSYM)]);
|
|
|
548bcb |
- ElfW(Half) ndx = vernum[ELFW(R_SYM) (reloc->r_info)] & 0x7fff;
|
|
|
548bcb |
- version = &l->l_versions[ndx];
|
|
|
548bcb |
- if (version->hash == 0)
|
|
|
548bcb |
- version = NULL;
|
|
|
548bcb |
- }
|
|
|
548bcb |
-
|
|
|
548bcb |
- result = _dl_lookup_symbol_x (strtab + sym->st_name, l, &sym,
|
|
|
548bcb |
- l->l_scope, version, ELF_RTYPE_CLASS_PLT,
|
|
|
548bcb |
- DL_LOOKUP_ADD_DEPENDENCY, NULL);
|
|
|
548bcb |
- }
|
|
|
548bcb |
- else
|
|
|
548bcb |
- {
|
|
|
548bcb |
- /* We already found the symbol. The module (and therefore its load
|
|
|
548bcb |
- address) is also known. */
|
|
|
548bcb |
- result = l;
|
|
|
548bcb |
- }
|
|
|
548bcb |
-
|
|
|
548bcb |
- if (!sym)
|
|
|
548bcb |
- {
|
|
|
548bcb |
- td->arg = 0;
|
|
|
548bcb |
- td->entry = _dl_tlsdesc_undefweak;
|
|
|
548bcb |
- }
|
|
|
548bcb |
- else
|
|
|
548bcb |
- {
|
|
|
548bcb |
-# ifndef SHARED
|
|
|
548bcb |
- CHECK_STATIC_TLS (l, result);
|
|
|
548bcb |
-# else
|
|
|
548bcb |
- if (!TRY_STATIC_TLS (l, result))
|
|
|
548bcb |
- {
|
|
|
548bcb |
- td->arg = _dl_make_tlsdesc_dynamic (result, sym->st_value);
|
|
|
548bcb |
- td->entry = _dl_tlsdesc_dynamic;
|
|
|
548bcb |
- }
|
|
|
548bcb |
- else
|
|
|
548bcb |
-# endif
|
|
|
548bcb |
- {
|
|
|
548bcb |
- td->arg = (void*)(sym->st_value - result->l_tls_offset);
|
|
|
548bcb |
- td->entry = _dl_tlsdesc_return;
|
|
|
548bcb |
- }
|
|
|
548bcb |
- }
|
|
|
548bcb |
-
|
|
|
548bcb |
- _dl_tlsdesc_wake_up_held_fixups ();
|
|
|
548bcb |
-}
|
|
|
548bcb |
-
|
|
|
548bcb |
-/* This function is used to lazily resolve TLS_DESC RELA relocations.
|
|
|
548bcb |
- The argument location is used to hold a pointer to the relocation. */
|
|
|
548bcb |
-
|
|
|
548bcb |
-void
|
|
|
548bcb |
-__attribute__ ((regparm (3))) attribute_hidden
|
|
|
548bcb |
-_dl_tlsdesc_resolve_rela_fixup (struct tlsdesc volatile *td,
|
|
|
548bcb |
- struct link_map *l,
|
|
|
548bcb |
- ptrdiff_t entry_check_offset)
|
|
|
548bcb |
-{
|
|
|
548bcb |
- const ElfW(Rela) *reloc = td->arg;
|
|
|
548bcb |
-
|
|
|
548bcb |
- if (_dl_tlsdesc_resolve_early_return_p (td, __builtin_return_address (0)
|
|
|
548bcb |
- - entry_check_offset))
|
|
|
548bcb |
- return;
|
|
|
548bcb |
-
|
|
|
548bcb |
- /* The code below was borrowed from _dl_fixup(),
|
|
|
548bcb |
- except for checking for STB_LOCAL. */
|
|
|
548bcb |
- const ElfW(Sym) *const symtab
|
|
|
548bcb |
- = (const void *) D_PTR (l, l_info[DT_SYMTAB]);
|
|
|
548bcb |
- const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]);
|
|
|
548bcb |
- const ElfW(Sym) *sym = &symtab[ELFW(R_SYM) (reloc->r_info)];
|
|
|
548bcb |
- lookup_t result;
|
|
|
548bcb |
-
|
|
|
548bcb |
- /* Look up the target symbol. If the normal lookup rules are not
|
|
|
548bcb |
- used don't look in the global scope. */
|
|
|
548bcb |
- if (ELFW(ST_BIND) (sym->st_info) != STB_LOCAL
|
|
|
548bcb |
- && __builtin_expect (ELFW(ST_VISIBILITY) (sym->st_other), 0) == 0)
|
|
|
548bcb |
- {
|
|
|
548bcb |
- const struct r_found_version *version = NULL;
|
|
|
548bcb |
-
|
|
|
548bcb |
- if (l->l_info[VERSYMIDX (DT_VERSYM)] != NULL)
|
|
|
548bcb |
- {
|
|
|
548bcb |
- const ElfW(Half) *vernum =
|
|
|
548bcb |
- (const void *) D_PTR (l, l_info[VERSYMIDX (DT_VERSYM)]);
|
|
|
548bcb |
- ElfW(Half) ndx = vernum[ELFW(R_SYM) (reloc->r_info)] & 0x7fff;
|
|
|
548bcb |
- version = &l->l_versions[ndx];
|
|
|
548bcb |
- if (version->hash == 0)
|
|
|
548bcb |
- version = NULL;
|
|
|
548bcb |
- }
|
|
|
548bcb |
-
|
|
|
548bcb |
- result = _dl_lookup_symbol_x (strtab + sym->st_name, l, &sym,
|
|
|
548bcb |
- l->l_scope, version, ELF_RTYPE_CLASS_PLT,
|
|
|
548bcb |
- DL_LOOKUP_ADD_DEPENDENCY, NULL);
|
|
|
548bcb |
- }
|
|
|
548bcb |
- else
|
|
|
548bcb |
- {
|
|
|
548bcb |
- /* We already found the symbol. The module (and therefore its load
|
|
|
548bcb |
- address) is also known. */
|
|
|
548bcb |
- result = l;
|
|
|
548bcb |
- }
|
|
|
548bcb |
-
|
|
|
548bcb |
- if (!sym)
|
|
|
548bcb |
- {
|
|
|
548bcb |
- td->arg = (void*) reloc->r_addend;
|
|
|
548bcb |
- td->entry = _dl_tlsdesc_undefweak;
|
|
|
548bcb |
- }
|
|
|
548bcb |
- else
|
|
|
548bcb |
- {
|
|
|
548bcb |
-# ifndef SHARED
|
|
|
548bcb |
- CHECK_STATIC_TLS (l, result);
|
|
|
548bcb |
-# else
|
|
|
548bcb |
- if (!TRY_STATIC_TLS (l, result))
|
|
|
548bcb |
- {
|
|
|
548bcb |
- td->arg = _dl_make_tlsdesc_dynamic (result, sym->st_value
|
|
|
548bcb |
- + reloc->r_addend);
|
|
|
548bcb |
- td->entry = _dl_tlsdesc_dynamic;
|
|
|
548bcb |
- }
|
|
|
548bcb |
- else
|
|
|
548bcb |
-# endif
|
|
|
548bcb |
- {
|
|
|
548bcb |
- td->arg = (void*) (sym->st_value - result->l_tls_offset
|
|
|
548bcb |
- + reloc->r_addend);
|
|
|
548bcb |
- td->entry = _dl_tlsdesc_return;
|
|
|
548bcb |
- }
|
|
|
548bcb |
- }
|
|
|
548bcb |
-
|
|
|
548bcb |
- _dl_tlsdesc_wake_up_held_fixups ();
|
|
|
548bcb |
-}
|
|
|
548bcb |
-
|
|
|
548bcb |
-/* This function is used to avoid busy waiting for other threads to
|
|
|
548bcb |
- complete the lazy relocation. Once another thread wins the race to
|
|
|
548bcb |
- relocate a TLS descriptor, it sets the descriptor up such that this
|
|
|
548bcb |
- function is called to wait until the resolver releases the
|
|
|
548bcb |
- lock. */
|
|
|
548bcb |
-
|
|
|
548bcb |
-void
|
|
|
548bcb |
-__attribute__ ((regparm (3))) attribute_hidden
|
|
|
548bcb |
-_dl_tlsdesc_resolve_hold_fixup (struct tlsdesc volatile *td,
|
|
|
548bcb |
- struct link_map *l __attribute__((__unused__)),
|
|
|
548bcb |
- ptrdiff_t entry_check_offset)
|
|
|
548bcb |
-{
|
|
|
548bcb |
- /* Maybe we're lucky and can return early. */
|
|
|
548bcb |
- if (__builtin_return_address (0) - entry_check_offset != td->entry)
|
|
|
548bcb |
- return;
|
|
|
548bcb |
-
|
|
|
548bcb |
- /* Locking here will stop execution until the running resolver runs
|
|
|
548bcb |
- _dl_tlsdesc_wake_up_held_fixups(), releasing the lock.
|
|
|
548bcb |
-
|
|
|
548bcb |
- FIXME: We'd be better off waiting on a condition variable, such
|
|
|
548bcb |
- that we didn't have to hold the lock throughout the relocation
|
|
|
548bcb |
- processing. */
|
|
|
548bcb |
- __rtld_lock_lock_recursive (GL(dl_load_lock));
|
|
|
548bcb |
- __rtld_lock_unlock_recursive (GL(dl_load_lock));
|
|
|
548bcb |
-}
|
|
|
548bcb |
-
|
|
|
548bcb |
-
|
|
|
548bcb |
/* Unmap the dynamic object, but also release its TLS descriptor table
|
|
|
548bcb |
if there is one. */
|
|
|
548bcb |
|