diff --git a/arch/mips/pthread_arch.h b/arch/mips/pthread_arch.h index f8e35ae46377d5f89ed3eede40dcc1cff83c2747..904a248901892bcffa572dfb6e9d5069ad96df8d 100644 --- a/arch/mips/pthread_arch.h +++ b/arch/mips/pthread_arch.h @@ -13,4 +13,6 @@ static inline struct pthread *__pthread_self() #define TLS_ABOVE_TP #define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000) +#define DTP_OFFSET 0x8000 + #define CANCEL_REG_IP (3-(union {int __i; char __b;}){1}.__b) diff --git a/arch/powerpc/pthread_arch.h b/arch/powerpc/pthread_arch.h index 4115ec8c2357840af373a7aa1098a7e1fac1e61a..1cbfc223ad23e3745243cf90a058ef1be75043d7 100644 --- a/arch/powerpc/pthread_arch.h +++ b/arch/powerpc/pthread_arch.h @@ -12,6 +12,8 @@ static inline struct pthread *__pthread_self() #define TLS_ABOVE_TP #define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000) +#define DTP_OFFSET 0x8000 + // offset of the PC register in mcontext_t, divided by the system wordsize // the kernel calls the ip "nip", it's the first saved value after the 32 // GPRs. diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h index e29f9c82e421066db958d21aa0adb7ce2abc5b83..3890bb56fb4d122db323e513460a4c045666d741 100644 --- a/src/internal/pthread_impl.h +++ b/src/internal/pthread_impl.h @@ -94,6 +94,10 @@ struct __timer { #define CANARY canary #endif +#ifndef DTP_OFFSET +#define DTP_OFFSET 0 +#endif + #define SIGTIMER 32 #define SIGCANCEL 33 #define SIGSYNCCALL 34 diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c index b77c6f6b9c8c1dcce7acea8d5bee7128f501ef6d..d2a72492e7212b45b4f3090c40f55a52728c780a 100644 --- a/src/ldso/dynlink.c +++ b/src/ldso/dynlink.c @@ -337,7 +337,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri *reloc_addr = def.dso->tls_id; break; case REL_DTPOFF: - *reloc_addr = tls_val + addend; + *reloc_addr = tls_val + addend - DTP_OFFSET; break; #ifdef TLS_ABOVE_TP case REL_TPOFF: @@ -1102,7 +1102,7 @@ void *__tls_get_new(size_t *v) __block_all_sigs(&set); if (v[0]<=(size_t)self->dtv[0]) { __restore_sigs(&set); - return (char *)self->dtv[v[0]]+v[1]; + return (char *)self->dtv[v[0]]+v[1]+DTP_OFFSET; } /* This is safe without any locks held because, if the caller @@ -1135,7 +1135,7 @@ void *__tls_get_new(size_t *v) if (p->tls_id == v[0]) break; } __restore_sigs(&set); - return mem + v[1]; + return mem + v[1] + DTP_OFFSET; } static void update_tls_size() diff --git a/src/thread/__tls_get_addr.c b/src/thread/__tls_get_addr.c index 36333967bee9b237d5a006bf435d8a2976ba30f0..84a413d4a8cd4be9bdd662b66d10c6fe877bc76b 100644 --- a/src/thread/__tls_get_addr.c +++ b/src/thread/__tls_get_addr.c @@ -8,9 +8,9 @@ void *__tls_get_addr(size_t *v) __attribute__((__visibility__("hidden"))) void *__tls_get_new(size_t *); if (v[0]<=(size_t)self->dtv[0]) - return (char *)self->dtv[v[0]]+v[1]; + return (char *)self->dtv[v[0]]+v[1]+DTP_OFFSET; return __tls_get_new(v); #else - return (char *)self->dtv[1]+v[1]; + return (char *)self->dtv[1]+v[1]+DTP_OFFSET; #endif }