freebsd-dev/libexec/rtld-elf
Konstantin Belousov 5d00c5a657 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
2019-03-29 17:52:57 +00:00
..
aarch64 Improve R_AARCH64_TLSDESC relocation. 2018-12-15 10:38:07 +00:00
amd64 Improve R_AARCH64_TLSDESC relocation. 2018-12-15 10:38:07 +00:00
arm rtld: attempt to fix reloc_nonplt_object TLS allocation 2019-03-29 14:35:23 +00:00
i386 rtld: pacify -Wmaybe-uninitialized from gcc6 2019-02-01 23:16:59 +00:00
mips rtld: attempt to fix reloc_non_plt TLS allocation on MIPS 2019-03-29 15:07:00 +00:00
powerpc Improve R_AARCH64_TLSDESC relocation. 2018-12-15 10:38:07 +00:00
powerpc64 Fix rtld-elf compilation warning for powerpc64 ELFv2 ABI 2019-01-13 02:33:20 +00:00
riscv Improve R_AARCH64_TLSDESC relocation. 2018-12-15 10:38:07 +00:00
sparc64 Improve R_AARCH64_TLSDESC relocation. 2018-12-15 10:38:07 +00:00
tests Fix regression tests broken by r337067. 2018-08-02 11:55:16 +00:00
debug.c libexec: adoption of SPDX licensing ID tags. 2017-11-27 15:25:02 +00:00
debug.h libexec: adoption of SPDX licensing ID tags. 2017-11-27 15:25:02 +00:00
libmap.c rtld-elf: fix more warnings to allow compiling with WARNS=6 2018-10-29 21:08:28 +00:00
libmap.conf Move libmap.conf to libexec/rtld-elf/ 2018-09-18 00:25:00 +00:00
libmap.h rtld-elf: make it compile with WARNS=3 2018-10-29 21:08:11 +00:00
Makefile revert r341429 "disable BIND_NOW in libc, libthr, and rtld" 2019-03-28 02:12:32 +00:00
Makefile.depend new depends 2015-06-16 23:37:19 +00:00
map_object.c Remove Obj_Entry textsize member. 2018-11-04 00:32:28 +00:00
paths.h rtld-elf: compile with WANRS=4 warnings other than -Wcast-align 2018-10-29 21:08:19 +00:00
rtld_lock.c rtld-elf: fix more warnings to allow compiling with WARNS=6 2018-10-29 21:08:28 +00:00
rtld_lock.h libexec: adoption of SPDX licensing ID tags. 2017-11-27 15:25:02 +00:00
rtld_malloc.c Rename rtld-elf/malloc.c to rtld-elf/rtld_malloc.c. 2019-01-30 16:28:27 +00:00
rtld_malloc.h Add header file missed in r343564. 2019-01-29 22:45:24 +00:00
rtld_printf.c rtld-elf: fix more warnings to allow compiling with WARNS=6 2018-10-29 21:08:28 +00:00
rtld_printf.h libexec: adoption of SPDX licensing ID tags. 2017-11-27 15:25:02 +00:00
rtld_tls.h libexec: adoption of SPDX licensing ID tags. 2017-11-27 15:25:02 +00:00
rtld_utrace.h Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
rtld.1 Add serial comma. 2017-09-01 16:56:37 +00:00
rtld.c Fix initial exec TLS mode for dynamically loaded shared objects. 2019-03-29 17:52:57 +00:00
rtld.h Fix initial exec TLS mode for dynamically loaded shared objects. 2019-03-29 17:52:57 +00:00
Symbol.map Add rtld private interface for dso to detect dynamic loading 2015-01-03 18:09:53 +00:00
xmalloc.c Adjust posix symbols from rtld-elf/malloc.c with the __crt_ prefix. 2019-01-29 22:40:42 +00:00