]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix initial exec TLS mode for dynamically loaded shared objects.
authorkib <kib@FreeBSD.org>
Fri, 29 Mar 2019 17:52:57 +0000 (17:52 +0000)
committerkib <kib@FreeBSD.org>
Fri, 29 Mar 2019 17:52:57 +0000 (17:52 +0000)
commit9638d3e2e6c1c7357db25b365ccd7aac41c2ebf5
tree56c529711cd8f3d7791fa3caf99f1256719fabbf
parent9df1f562923bd91535f47c2fff5ee36839f8a63a
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
27 files changed:
lib/libc/aarch64/static_tls.h [new file with mode: 0644]
lib/libc/amd64/static_tls.h [new file with mode: 0644]
lib/libc/arm/static_tls.h [new file with mode: 0644]
lib/libc/gen/Symbol.map
lib/libc/gen/elf_utils.c
lib/libc/i386/static_tls.h [new file with mode: 0644]
lib/libc/include/libc_private.h
lib/libc/mips/static_tls.h [new file with mode: 0644]
lib/libc/powerpc/static_tls.h [new file with mode: 0644]
lib/libc/powerpc64/static_tls.h [new file with mode: 0644]
lib/libc/riscv/static_tls.h [new file with mode: 0644]
lib/libc/sparc64/static_tls.h [new file with mode: 0644]
lib/libc/sys/interposing_table.c
lib/libthr/Makefile
lib/libthr/arch/aarch64/include/pthread_tls.h [new file with mode: 0644]
lib/libthr/arch/amd64/include/pthread_tls.h [new file with mode: 0644]
lib/libthr/arch/arm/include/pthread_tls.h [new file with mode: 0644]
lib/libthr/arch/i386/include/pthread_tls.h [new file with mode: 0644]
lib/libthr/arch/mips/include/pthread_tls.h [new file with mode: 0644]
lib/libthr/arch/powerpc/include/pthread_tls.h [new file with mode: 0644]
lib/libthr/arch/riscv/include/pthread_tls.h [new file with mode: 0644]
lib/libthr/arch/sparc64/include/pthread_tls.h [new file with mode: 0644]
lib/libthr/pthread.map
lib/libthr/thread/thr_list.c
lib/libthr/thread/thr_private.h
libexec/rtld-elf/rtld.c
libexec/rtld-elf/rtld.h