Fix TLS on sparc64 for statically and dynamically linked binaries
Approved by: rwatson (mentor) Reviewed by: jmg and marcel
This commit is contained in:
parent
a5ad0b523b
commit
b84c7a797c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=163118
@ -98,13 +98,12 @@ _start(char **ap, void (*cleanup)(void), struct Struct_Obj_Entry *obj __unused,
|
||||
__progname = s + 1;
|
||||
}
|
||||
|
||||
__sparc_utrap_setup();
|
||||
|
||||
if (&_DYNAMIC != NULL)
|
||||
atexit(cleanup);
|
||||
else
|
||||
else {
|
||||
__sparc_utrap_setup();
|
||||
_init_tls();
|
||||
|
||||
}
|
||||
#ifdef GCRT
|
||||
atexit(_mcleanup);
|
||||
#endif
|
||||
|
@ -58,6 +58,15 @@ void _rtld_free_tls(void *tls, size_t tcbsize, size_t tcbalign);
|
||||
void *__libc_allocate_tls(void *oldtls, size_t tcbsize, size_t tcbalign);
|
||||
void __libc_free_tls(void *tls, size_t tcbsize, size_t tcbalign);
|
||||
|
||||
#if defined(__ia64__) || defined(__amd64__)
|
||||
#define TLS_TCB_ALIGN 16
|
||||
#elif defined(__powerpc__) || defined(__i386__) || defined(__arm__) || \
|
||||
defined(__sparc64__)
|
||||
#define TLS_TCB_ALIGN sizeof(void *)
|
||||
#else
|
||||
#error TLS_TCB_ALIGN undefined for target architecture
|
||||
#endif
|
||||
|
||||
#if defined(__ia64__) || defined(__powerpc__)
|
||||
#define TLS_VARIANT_I
|
||||
#endif
|
||||
@ -299,7 +308,7 @@ _init_tls()
|
||||
}
|
||||
}
|
||||
|
||||
tls = _rtld_allocate_tls(NULL, TLS_TCB_SIZE, 1);
|
||||
tls = _rtld_allocate_tls(NULL, TLS_TCB_SIZE, TLS_TCB_ALIGN);
|
||||
|
||||
_set_tp(tls);
|
||||
#endif
|
||||
|
@ -29,7 +29,6 @@
|
||||
void
|
||||
_set_tp(void *tpval)
|
||||
{
|
||||
register void* tp __asm__("%g7");
|
||||
|
||||
tp = tpval;
|
||||
__asm __volatile("mov %0, %%g7" : : "r" (tpval));
|
||||
}
|
||||
|
@ -723,7 +723,7 @@ install_plt(Elf_Word *pltgot, Elf_Addr proc)
|
||||
void
|
||||
allocate_initial_tls(Obj_Entry *objs)
|
||||
{
|
||||
register Elf_Addr** tp __asm__("%g7");
|
||||
Elf_Addr* tpval;
|
||||
|
||||
/*
|
||||
* Fix the size of the static TLS block by using the maximum
|
||||
@ -731,7 +731,8 @@ allocate_initial_tls(Obj_Entry *objs)
|
||||
* use.
|
||||
*/
|
||||
tls_static_space = tls_last_offset + RTLD_STATIC_TLS_EXTRA;
|
||||
tp = allocate_tls(objs, NULL, 3*sizeof(Elf_Addr), sizeof(Elf_Addr));
|
||||
tpval = allocate_tls(objs, NULL, 3*sizeof(Elf_Addr), sizeof(Elf_Addr));
|
||||
__asm __volatile("mov %0, %%g7" : : "r" (tpval));
|
||||
}
|
||||
|
||||
void *__tls_get_addr(tls_index *ti)
|
||||
|
Loading…
Reference in New Issue
Block a user