提交 90c94d6d 编写于 作者: D dhy308

规避dlclose中tls删除的问题

Signed-off-by: Ndhy308 <tony.gan@huawei.com>
上级 c151b352
......@@ -3020,6 +3020,11 @@ static int do_dlclose(struct dso *p)
d->fini_next = p->fini_next;
}
/* empty tls image */
if (p->tls.size != 0) {
p->tls.image = NULL;
}
/* remove dso from global dso list */
if (p == tail) {
tail = p->prev;
......@@ -3037,7 +3042,10 @@ static int do_dlclose(struct dso *p)
if (p->deps != no_deps)
internal_free(p->deps);
unmap_library(p);
internal_free(p);
if (p->tls.size == 0) {
internal_free(p);
}
return 0;
}
......
......@@ -52,7 +52,9 @@ void *__copy_tls(unsigned char *mem)
for (i=1, p=libc.tls_head; p; i++, p=p->next) {
dtv[i] = (uintptr_t)(mem + p->offset) + DTP_OFFSET;
memcpy(mem + p->offset, p->image, p->len);
if (p->image) {
memcpy(mem + p->offset, p->image, p->len);
}
}
#else
dtv = (uintptr_t *)mem;
......@@ -63,7 +65,9 @@ void *__copy_tls(unsigned char *mem)
for (i=1, p=libc.tls_head; p; i++, p=p->next) {
dtv[i] = (uintptr_t)(mem - p->offset) + DTP_OFFSET;
memcpy(mem - p->offset, p->image, p->len);
if (p->image) {
memcpy(mem - p->offset, p->image, p->len);
}
}
#endif
dtv[0] = libc.tls_cnt;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册