aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/sys/interposing_table.c
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2019-03-29 17:52:57 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2019-03-29 17:52:57 +0000
commit5d00c5a6571cdf533228338fa7ca532c91af1d66 (patch)
tree56c529711cd8f3d7791fa3caf99f1256719fabbf /lib/libc/sys/interposing_table.c
parent9f701172635d755151f24e15e78c357d3378bd09 (diff)
downloadsrc-5d00c5a6571cdf533228338fa7ca532c91af1d66.tar.gz
src-5d00c5a6571cdf533228338fa7ca532c91af1d66.zip
Fix initial exec TLS mode for dynamically loaded shared objects.
If dso uses initial exec TLS mode, rtld tries to allocate TLS in static space. If there is no space left, the dlopen(3) fails. If space if allocated, initial content from PT_TLS segment is distributed to all threads' pcbs, which was missed and caused un-initialized TLS segment for such dso after dlopen(3). The mode is auto-detected either due to the relocation used, or if the DF_STATIC_TLS dynamic flag is set. In the later case, the TLS segment is tried to allocate earlier, which increases chance of the dlopen(3) to succeed. LLD was recently fixed to properly emit the flag, ld.bdf did it always. Initial test by: dumbbell Tested by: emaste (amd64), ian (arm) Tested by: Gerald Aryeetey <aryeeteygerald_rogers.com> (arm64) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D19072
Notes
Notes: svn path=/head/; revision=345703
Diffstat (limited to 'lib/libc/sys/interposing_table.c')
-rw-r--r--lib/libc/sys/interposing_table.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/libc/sys/interposing_table.c b/lib/libc/sys/interposing_table.c
index faf1e6ceeb68..670e9fd7dd0f 100644
--- a/lib/libc/sys/interposing_table.c
+++ b/lib/libc/sys/interposing_table.c
@@ -81,6 +81,7 @@ interpos_func_t __libc_interposing[INTERPOS_MAX] = {
SLOT(map_stacks_exec, __libc_map_stacks_exec),
SLOT(fdatasync, __sys_fdatasync),
SLOT(clock_nanosleep, __sys_clock_nanosleep),
+ SLOT(distribute_static_tls, __libc_distribute_static_tls),
};
#undef SLOT