llvm-project/compiler-rt/lib/tsan
Fangrui Song 9be8f8b34d [sanitizer] Simplify GetTls with dl_iterate_phdr
GetTls is the range of

* thread control block and optional TLS_PRE_TCB_SIZE
* static TLS blocks plus static TLS surplus

On glibc, lsan requires the range to include
`pthread::{specific_1stblock,specific}` so that allocations only referenced by
`pthread_setspecific` can be scanned.

This patch uses `dl_iterate_phdr` to collect TLS ranges. Find the one
with `dlpi_tls_modid==1` as one of the initially loaded module, then find
consecutive ranges. The boundaries give us addr and size.

This allows us to drop the glibc internal `_dl_get_tls_static_info` and
`InitTlsSize` entirely. Use the simplified method with non-Android Linux for
now, but in theory this can be used with *BSD and potentially other ELF OSes.

In the future, we can move `ThreadDescriptorSize` code to lsan (and consider
intercepting `pthread_setspecific`) to avoid hacks in generic code.

See https://reviews.llvm.org/D93972#2480556 for analysis on GetTls usage
across various sanitizers.

Differential Revision: https://reviews.llvm.org/D98926
2021-03-25 21:55:27 -07:00
..
benchmarks compiler-rt: Rename .cc file in lib/tsan/{benchmarks,dd,go} to .cpp 2019-08-01 14:30:49 +00:00
dd [tsan] Remove stdlib.h from dd_interceptors.cpp 2020-12-29 14:00:54 -08:00
go [sanitizers] Pass CMAKE_C_FLAGS into TSan buildgo script 2021-02-22 18:49:02 +01:00
rtl [sanitizer] Simplify GetTls with dl_iterate_phdr 2021-03-25 21:55:27 -07:00
tests [CMake] Add -fno-rtti into tsan unittests 2020-10-30 20:03:38 -07:00
.clang-format [sanitizer] Remove unneeded blank lines 2018-05-09 00:44:26 +00:00
CMakeLists.txt [sanitizers] Pass CMAKE_C_FLAGS into TSan buildgo script 2021-02-22 18:49:02 +01:00
analyze_libtsan.sh Revert "[NFC][TSAN] Logs to debug test script on bot" 2020-10-29 01:11:16 -07:00
check_analyze.sh Revert "[NFC][TSAN] Logs to debug test script on bot" 2020-10-29 01:11:16 -07:00
check_cmake.sh