about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/env/__init_tls.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/env/__init_tls.c b/src/env/__init_tls.c
index 0107a545..b125eb1f 100644
--- a/src/env/__init_tls.c
+++ b/src/env/__init_tls.c
@@ -71,6 +71,9 @@ typedef Elf32_Phdr Phdr;
 typedef Elf64_Phdr Phdr;
 #endif
 
+__attribute__((__weak__, __visibility__("hidden")))
+extern const size_t _DYNAMIC[];
+
 static void static_init_tls(size_t *aux)
 {
 	unsigned char *p;
@@ -83,6 +86,8 @@ static void static_init_tls(size_t *aux)
 		phdr = (void *)p;
 		if (phdr->p_type == PT_PHDR)
 			base = aux[AT_PHDR] - phdr->p_vaddr;
+		if (phdr->p_type == PT_DYNAMIC && _DYNAMIC)
+			base = (size_t)_DYNAMIC - phdr->p_vaddr;
 		if (phdr->p_type == PT_TLS)
 			tls_phdr = phdr;
 	}