Page MenuHomePhabricator

[sanitizer] Use dl_iterate_phdr based GetTls on musl and FreeBSD
AbandonedPublic

Authored by MaskRay on Sun, Apr 4, 8:59 PM.

Details

Reviewers
vitalybuka
Group Reviewers
Restricted Project
Summary

... so that FreeBSD specific GetTls code can be removed. This also
helps FreeBSD arm64/powerpc64 which don't have GetTls implementation yet.

Note: as of musl 1.2.2 and FreeBSD 12.2, dlpi_tls_data returned by
dl_iterate_phdr is not desired: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=254774

This can be worked around by using __tls_get_addr({modid,0}) instead
of dlpi_tls_data. The workaround can be shared with the workaround for glibc<2.25.

This fixes some tests on Alpine Linux x86-64 (musl)

test/lsan/Linux/cleanup_in_tsd_destructor.c
test/lsan/Linux/fork.cpp
test/lsan/Linux/fork_threaded.cpp
test/lsan/Linux/use_tls_static.cpp
test/lsan/many_tls_keys_thread.cpp

test/msan/tls_reuse.cpp

The number of sanitizer test failures does not change on FreeBSD/amd64 12.2.

Diff Detail