|
|
548bcb |
commit 55c9f3238080e9aba733bc0902779c46cfa16446
|
|
|
548bcb |
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
|
|
548bcb |
Date: Thu Feb 11 11:52:24 2021 +0000
|
|
|
548bcb |
|
|
|
548bcb |
x86_64: Remove lazy tlsdesc relocation related code
|
|
|
548bcb |
|
|
|
548bcb |
_dl_tlsdesc_resolve_rela and _dl_tlsdesc_resolve_hold are only used for
|
|
|
548bcb |
lazy tlsdesc relocation processing which is no longer supported.
|
|
|
548bcb |
|
|
|
548bcb |
diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
|
|
|
548bcb |
index ef5740ba281c7282..b94d3b39ec1dca64 100644
|
|
|
548bcb |
--- a/sysdeps/x86_64/dl-machine.h
|
|
|
548bcb |
+++ b/sysdeps/x86_64/dl-machine.h
|
|
|
548bcb |
@@ -127,10 +127,6 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
|
|
|
548bcb |
}
|
|
|
548bcb |
}
|
|
|
548bcb |
|
|
|
548bcb |
- if (l->l_info[ADDRIDX (DT_TLSDESC_GOT)] && lazy)
|
|
|
548bcb |
- *(ElfW(Addr)*)(D_PTR (l, l_info[ADDRIDX (DT_TLSDESC_GOT)]) + l->l_addr)
|
|
|
548bcb |
- = (ElfW(Addr)) &_dl_tlsdesc_resolve_rela;
|
|
|
548bcb |
-
|
|
|
548bcb |
return lazy;
|
|
|
548bcb |
}
|
|
|
548bcb |
|
|
|
548bcb |
diff --git a/sysdeps/x86_64/dl-tlsdesc.S b/sysdeps/x86_64/dl-tlsdesc.S
|
|
|
548bcb |
index 80d771cd887dd626..77e78cf0a6d8babc 100644
|
|
|
548bcb |
--- a/sysdeps/x86_64/dl-tlsdesc.S
|
|
|
548bcb |
+++ b/sysdeps/x86_64/dl-tlsdesc.S
|
|
|
548bcb |
@@ -148,107 +148,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 |
- RELA relocations. The incoming 0(%rsp) points to the caller's
|
|
|
548bcb |
- link map, pushed by the dynamic object's internal lazy TLS
|
|
|
548bcb |
- resolver front-end before tail-calling us. We need to pop it
|
|
|
548bcb |
- ourselves. %rax points to a TLS descriptor, such that 0(%rax)
|
|
|
548bcb |
- holds the address of the internal resolver front-end (unless
|
|
|
548bcb |
- some other thread beat us to resolving it) and 8(%rax) 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_rela
|
|
|
548bcb |
- .global _dl_tlsdesc_resolve_rela
|
|
|
548bcb |
- .type _dl_tlsdesc_resolve_rela,@function
|
|
|
548bcb |
- cfi_startproc
|
|
|
548bcb |
- .align 16
|
|
|
548bcb |
- /* The PLT entry will have pushed the link_map pointer. */
|
|
|
548bcb |
-_dl_tlsdesc_resolve_rela:
|
|
|
548bcb |
- _CET_ENDBR
|
|
|
548bcb |
- cfi_adjust_cfa_offset (8)
|
|
|
548bcb |
- /* Save all call-clobbered registers. Add 8 bytes for push in
|
|
|
548bcb |
- the PLT entry to align the stack. */
|
|
|
548bcb |
- subq $80, %rsp
|
|
|
548bcb |
- cfi_adjust_cfa_offset (80)
|
|
|
548bcb |
- movq %rax, (%rsp)
|
|
|
548bcb |
- movq %rdi, 8(%rsp)
|
|
|
548bcb |
- movq %rax, %rdi /* Pass tlsdesc* in %rdi. */
|
|
|
548bcb |
- movq %rsi, 16(%rsp)
|
|
|
548bcb |
- movq 80(%rsp), %rsi /* Pass link_map* in %rsi. */
|
|
|
548bcb |
- movq %r8, 24(%rsp)
|
|
|
548bcb |
- movq %r9, 32(%rsp)
|
|
|
548bcb |
- movq %r10, 40(%rsp)
|
|
|
548bcb |
- movq %r11, 48(%rsp)
|
|
|
548bcb |
- movq %rdx, 56(%rsp)
|
|
|
548bcb |
- movq %rcx, 64(%rsp)
|
|
|
548bcb |
- call _dl_tlsdesc_resolve_rela_fixup
|
|
|
548bcb |
- movq (%rsp), %rax
|
|
|
548bcb |
- movq 8(%rsp), %rdi
|
|
|
548bcb |
- movq 16(%rsp), %rsi
|
|
|
548bcb |
- movq 24(%rsp), %r8
|
|
|
548bcb |
- movq 32(%rsp), %r9
|
|
|
548bcb |
- movq 40(%rsp), %r10
|
|
|
548bcb |
- movq 48(%rsp), %r11
|
|
|
548bcb |
- movq 56(%rsp), %rdx
|
|
|
548bcb |
- movq 64(%rsp), %rcx
|
|
|
548bcb |
- addq $88, %rsp
|
|
|
548bcb |
- cfi_adjust_cfa_offset (-88)
|
|
|
548bcb |
- jmp *(%rax)
|
|
|
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 |
- /* Save all call-clobbered registers. */
|
|
|
548bcb |
- subq $72, %rsp
|
|
|
548bcb |
- cfi_adjust_cfa_offset (72)
|
|
|
548bcb |
- movq %rax, (%rsp)
|
|
|
548bcb |
- movq %rdi, 8(%rsp)
|
|
|
548bcb |
- movq %rax, %rdi /* Pass tlsdesc* in %rdi. */
|
|
|
548bcb |
- movq %rsi, 16(%rsp)
|
|
|
548bcb |
- /* Pass _dl_tlsdesc_resolve_hold's address in %rsi. */
|
|
|
548bcb |
- leaq . - _dl_tlsdesc_resolve_hold(%rip), %rsi
|
|
|
548bcb |
- movq %r8, 24(%rsp)
|
|
|
548bcb |
- movq %r9, 32(%rsp)
|
|
|
548bcb |
- movq %r10, 40(%rsp)
|
|
|
548bcb |
- movq %r11, 48(%rsp)
|
|
|
548bcb |
- movq %rdx, 56(%rsp)
|
|
|
548bcb |
- movq %rcx, 64(%rsp)
|
|
|
548bcb |
- call _dl_tlsdesc_resolve_hold_fixup
|
|
|
548bcb |
-1:
|
|
|
548bcb |
- movq (%rsp), %rax
|
|
|
548bcb |
- movq 8(%rsp), %rdi
|
|
|
548bcb |
- movq 16(%rsp), %rsi
|
|
|
548bcb |
- movq 24(%rsp), %r8
|
|
|
548bcb |
- movq 32(%rsp), %r9
|
|
|
548bcb |
- movq 40(%rsp), %r10
|
|
|
548bcb |
- movq 48(%rsp), %r11
|
|
|
548bcb |
- movq 56(%rsp), %rdx
|
|
|
548bcb |
- movq 64(%rsp), %rcx
|
|
|
548bcb |
- addq $72, %rsp
|
|
|
548bcb |
- cfi_adjust_cfa_offset (-72)
|
|
|
548bcb |
- jmp *(%rax)
|
|
|
548bcb |
- cfi_endproc
|
|
|
548bcb |
- .size _dl_tlsdesc_resolve_hold, .-_dl_tlsdesc_resolve_hold
|
|
|
548bcb |
diff --git a/sysdeps/x86_64/dl-tlsdesc.h b/sysdeps/x86_64/dl-tlsdesc.h
|
|
|
548bcb |
index 66e659bb5c7ede74..1cde1ee9664f4908 100644
|
|
|
548bcb |
--- a/sysdeps/x86_64/dl-tlsdesc.h
|
|
|
548bcb |
+++ b/sysdeps/x86_64/dl-tlsdesc.h
|
|
|
548bcb |
@@ -55,9 +55,7 @@ struct tlsdesc_dynamic_arg
|
|
|
548bcb |
|
|
|
548bcb |
extern ptrdiff_t attribute_hidden
|
|
|
548bcb |
_dl_tlsdesc_return(struct tlsdesc *on_rax),
|
|
|
548bcb |
- _dl_tlsdesc_undefweak(struct tlsdesc *on_rax),
|
|
|
548bcb |
- _dl_tlsdesc_resolve_rela(struct tlsdesc *on_rax),
|
|
|
548bcb |
- _dl_tlsdesc_resolve_hold(struct tlsdesc *on_rax);
|
|
|
548bcb |
+ _dl_tlsdesc_undefweak(struct tlsdesc *on_rax);
|
|
|
548bcb |
|
|
|
548bcb |
# ifdef SHARED
|
|
|
548bcb |
extern void *_dl_make_tlsdesc_dynamic (struct link_map *map,
|
|
|
548bcb |
diff --git a/sysdeps/x86_64/tlsdesc.c b/sysdeps/x86_64/tlsdesc.c
|
|
|
548bcb |
index 302d097dbb0c4f1e..61a19ae26944c84f 100644
|
|
|
548bcb |
--- a/sysdeps/x86_64/tlsdesc.c
|
|
|
548bcb |
+++ b/sysdeps/x86_64/tlsdesc.c
|
|
|
548bcb |
@@ -16,120 +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 2 functions take a caller argument, that contains the
|
|
|
548bcb |
- address expected to be in the TLS descriptor. If it's changed, we
|
|
|
548bcb |
- want to return immediately. */
|
|
|
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_hidden
|
|
|
548bcb |
-_dl_tlsdesc_resolve_rela_fixup (struct tlsdesc volatile *td,
|
|
|
548bcb |
- struct link_map *l)
|
|
|
548bcb |
-{
|
|
|
548bcb |
- const ElfW(Rela) *reloc = td->arg;
|
|
|
548bcb |
-
|
|
|
548bcb |
- if (_dl_tlsdesc_resolve_early_return_p
|
|
|
548bcb |
- (td, (void*)(D_PTR (l, l_info[ADDRIDX (DT_TLSDESC_PLT)]) + l->l_addr)))
|
|
|
548bcb |
- return;
|
|
|
548bcb |
-
|
|
|
548bcb |
- /* The code below was borrowed from _dl_fixup(). */
|
|
|
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_hidden
|
|
|
548bcb |
-_dl_tlsdesc_resolve_hold_fixup (struct tlsdesc volatile *td,
|
|
|
548bcb |
- void *caller)
|
|
|
548bcb |
-{
|
|
|
548bcb |
- /* Maybe we're lucky and can return early. */
|
|
|
548bcb |
- if (caller != 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 |
/* Unmap the dynamic object, but also release its TLS descriptor table
|
|
|
548bcb |
if there is one. */
|
|
|
548bcb |
|