Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Standalone View
lib/sanitizer_common/sanitizer_linux_libcdep.cc
Show First 20 Lines • Show All 179 Lines • ▼ Show 20 Lines | #endif // __GLIBC__ | ||||
return 0; | return 0; | ||||
} | } | ||||
#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \ | #if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_GO && \ | ||||
!SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS | !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_SOLARIS | ||||
static uptr g_tls_size; | static uptr g_tls_size; | ||||
#ifdef __i386__ | #ifdef __i386__ | ||||
# ifndef __GLIBC_PREREQ | |||||
# define CHECK_GET_TLS_STATIC_INFO_VERSION 1 | # define CHECK_GET_TLS_STATIC_INFO_VERSION 1 | ||||
# else | #else | ||||
jakubjelinek: Why this hunk? This will unnecessary forever pessimize sanitizers built against glibc 2.27+. | |||||
LekensteynAuthorUnsubmitted Not Done ReplyInline ActionsOnly 32-bit builds are affected and the overhead is neglible as InitTlsSize is called only *once* per process. The advantage of this dynamic approach is that 32-bit programs can still be copied to a different OS with older glibc and execute without *unconditionally* crashing. The previous code used dlvsym to perform the version check, but as I now call gnu_get_libc_version directly for GNU libc in D48254, its overhead is pretty small. Given these circumstances, I think it is reasonable to unconditionally check the version. If you are interested in some numbers, Lekensteyn: Only 32-bit builds are affected and the overhead is neglible as InitTlsSize is called only… | |||||
# define CHECK_GET_TLS_STATIC_INFO_VERSION (!__GLIBC_PREREQ(2, 27)) | |||||
# endif | |||||
#else | |||||
# define CHECK_GET_TLS_STATIC_INFO_VERSION 0 | # define CHECK_GET_TLS_STATIC_INFO_VERSION 0 | ||||
#endif | #endif | ||||
#if CHECK_GET_TLS_STATIC_INFO_VERSION | #if CHECK_GET_TLS_STATIC_INFO_VERSION | ||||
# define DL_INTERNAL_FUNCTION __attribute__((regparm(3), stdcall)) | # define DL_INTERNAL_FUNCTION __attribute__((regparm(3), stdcall)) | ||||
#else | #else | ||||
# define DL_INTERNAL_FUNCTION | # define DL_INTERNAL_FUNCTION | ||||
#endif | #endif | ||||
Show All 20 Lines | void InitTlsSize() { | ||||
// all current supported platforms have 16 bytes stack alignment | // all current supported platforms have 16 bytes stack alignment | ||||
const size_t kStackAlign = 16; | const size_t kStackAlign = 16; | ||||
void *get_tls_static_info_ptr = dlsym(RTLD_NEXT, "_dl_get_tls_static_info"); | void *get_tls_static_info_ptr = dlsym(RTLD_NEXT, "_dl_get_tls_static_info"); | ||||
size_t tls_size = 0; | size_t tls_size = 0; | ||||
size_t tls_align = 0; | size_t tls_align = 0; | ||||
// On i?86, _dl_get_tls_static_info used to be internal_function, i.e. | // On i?86, _dl_get_tls_static_info used to be internal_function, i.e. | ||||
// __attribute__((regparm(3), stdcall)) before glibc 2.27 and is normal | // __attribute__((regparm(3), stdcall)) before glibc 2.27 and is normal | ||||
// function in 2.27 and later. | // function in 2.27 and later. | ||||
if (CHECK_GET_TLS_STATIC_INFO_VERSION && | if (CHECK_GET_TLS_STATIC_INFO_VERSION && GetGlibcVersion(nullptr) < 27) | ||||
!dlvsym(RTLD_NEXT, "glob", "GLIBC_2.27")) | |||||
CallGetTls<GetTlsStaticInfoRegparmCall>(get_tls_static_info_ptr, | CallGetTls<GetTlsStaticInfoRegparmCall>(get_tls_static_info_ptr, | ||||
&tls_size, &tls_align); | &tls_size, &tls_align); | ||||
else | else | ||||
CallGetTls<GetTlsStaticInfoCall>(get_tls_static_info_ptr, | CallGetTls<GetTlsStaticInfoCall>(get_tls_static_info_ptr, | ||||
&tls_size, &tls_align); | &tls_size, &tls_align); | ||||
if (tls_align < kStackAlign) | if (tls_align < kStackAlign) | ||||
tls_align = kStackAlign; | tls_align = kStackAlign; | ||||
g_tls_size = RoundUpTo(tls_size, tls_align); | g_tls_size = RoundUpTo(tls_size, tls_align); | ||||
▲ Show 20 Lines • Show All 558 Lines • Show Last 20 Lines |
Why this hunk? This will unnecessary forever pessimize sanitizers built against glibc 2.27+.