about summary refs log tree commit diff
path: root/arch/mips
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/pthread_arch.h12
-rw-r--r--arch/mips/reloc.h11
2 files changed, 19 insertions, 4 deletions
diff --git a/arch/mips/pthread_arch.h b/arch/mips/pthread_arch.h
index 77b7330d..f8e35ae4 100644
--- a/arch/mips/pthread_arch.h
+++ b/arch/mips/pthread_arch.h
@@ -1,12 +1,16 @@
 static inline struct pthread *__pthread_self()
 {
-	struct pthread *self;
 #ifdef __clang__
-	__asm__ __volatile__ (".word 0x7c03e83b ; move %0, $3" : "=r" (self) : : "$3" );
+	char *tp;
+	__asm__ __volatile__ (".word 0x7c03e83b ; move %0, $3" : "=r" (tp) : : "$3" );
 #else
-	__asm__ __volatile__ (".word 0x7c03e83b" : "=v" (self) );
+	register char *tp __asm__("$3");
+	__asm__ __volatile__ (".word 0x7c03e83b" : "=r" (tp) );
 #endif
-	return self;
+	return (pthread_t)(tp - 0x7000 - sizeof(struct pthread));
 }
 
+#define TLS_ABOVE_TP
+#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000)
+
 #define CANCEL_REG_IP (3-(union {int __i; char __b;}){1}.__b)
diff --git a/arch/mips/reloc.h b/arch/mips/reloc.h
index 785489ed..f5e9c77b 100644
--- a/arch/mips/reloc.h
+++ b/arch/mips/reloc.h
@@ -23,6 +23,17 @@ static inline void do_single_reloc(
 	case R_MIPS_COPY:
 		memcpy(reloc_addr, (void *)sym_val, sym_size);
 		break;
+	case R_MIPS_TLS_DTPMOD32:
+		*reloc_addr = def.dso ? def.dso->tls_id : self->tls_id;
+		break;
+	case R_MIPS_TLS_DTPREL32:
+		*reloc_addr += def.sym->st_value;
+		break;
+	case R_MIPS_TLS_TPREL32:
+		*reloc_addr += def.sym
+			? def.sym->st_value + def.dso->tls_offset - 0x7000
+			: self->tls_offset - 0x7000;
+		break;
 	}
 }