llvm-project/compiler-rt/lib/memprof
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
..
CMakeLists.txt [CMake] Remove cxx-headers from runtime deps 2020-10-30 20:03:38 -07:00
README.txt
memprof.syms.extra
memprof_allocator.cpp [compiler-rt santizer] Use clock_gettime instead of timespec_get 2020-12-08 10:10:17 -08:00
memprof_allocator.h
memprof_descriptions.cpp [sanitizer] Remove max_len parameter from InternalScopedString 2021-03-17 16:57:09 -07:00
memprof_descriptions.h
memprof_flags.cpp
memprof_flags.h
memprof_flags.inc
memprof_init_version.h
memprof_interceptors.cpp [sanitizers] Fix interception of GLibc regexec 2021-03-08 10:53:55 +00:00
memprof_interceptors.h [sanitizers] Fix interception of GLibc regexec 2021-03-08 10:53:55 +00:00
memprof_interceptors_memintrinsics.cpp
memprof_interceptors_memintrinsics.h
memprof_interface_internal.h [MemProf] Add interface to dump profile 2020-11-19 10:21:53 -08:00
memprof_internal.h
memprof_linux.cpp [asan][memprof] Declare _DYNAMIC and fix -Wparentheses 2020-12-27 20:28:59 -08:00
memprof_malloc_linux.cpp
memprof_mapping.h [asan][memprof] Declare _DYNAMIC and fix -Wparentheses 2020-12-27 20:28:59 -08:00
memprof_new_delete.cpp
memprof_posix.cpp
memprof_preinit.cpp
memprof_rtl.cpp [sanitizer] Simplify GetTls with dl_iterate_phdr 2021-03-25 21:55:27 -07:00
memprof_shadow_setup.cpp
memprof_stack.cpp
memprof_stack.h
memprof_stats.cpp
memprof_stats.h
memprof_thread.cpp
memprof_thread.h [memprof] Don't protect destructor in final 2020-11-03 11:33:33 -08:00
weak_symbols.txt

README.txt

MemProfiling RT
================================
This directory contains sources of the MemProfiling (MemProf) runtime library.

Directory structure:
README.txt       : This file.
CMakeLists.txt   : File for cmake-based build.
memprof_*.{cc,h}    : Sources of the memprof runtime library.

Also MemProf runtime needs the following libraries:
lib/interception/      : Machinery used to intercept function calls.
lib/sanitizer_common/  : Code shared between various sanitizers.

MemProf runtime can only be built by CMake. You can run MemProf tests
from the root of your CMake build tree:

make check-memprof