diff options
-rw-r--r-- | lib/csu/sparc64/crt1.c | 7 | ||||
-rw-r--r-- | lib/libc/gen/tls.c | 11 | ||||
-rw-r--r-- | lib/libc/sparc64/gen/_set_tp.c | 3 | ||||
-rw-r--r-- | libexec/rtld-elf/sparc64/reloc.c | 5 |
4 files changed, 17 insertions, 9 deletions
diff --git a/lib/csu/sparc64/crt1.c b/lib/csu/sparc64/crt1.c index 19c0fad..5d8e371 100644 --- a/lib/csu/sparc64/crt1.c +++ b/lib/csu/sparc64/crt1.c @@ -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 diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c index 76e1950..5bc4b87 100644 --- a/lib/libc/gen/tls.c +++ b/lib/libc/gen/tls.c @@ -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 diff --git a/lib/libc/sparc64/gen/_set_tp.c b/lib/libc/sparc64/gen/_set_tp.c index 6255fd3..cf9db26 100644 --- a/lib/libc/sparc64/gen/_set_tp.c +++ b/lib/libc/sparc64/gen/_set_tp.c @@ -29,7 +29,6 @@ void _set_tp(void *tpval) { - register void* tp __asm__("%g7"); - tp = tpval; + __asm __volatile("mov %0, %%g7" : : "r" (tpval)); } diff --git a/libexec/rtld-elf/sparc64/reloc.c b/libexec/rtld-elf/sparc64/reloc.c index dc0d830..225322e 100644 --- a/libexec/rtld-elf/sparc64/reloc.c +++ b/libexec/rtld-elf/sparc64/reloc.c @@ -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) |