[PATCH] D44623: Fix asan on i?86-linux (32-bit) against glibc 2.27 and later

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 21 11:39:36 PDT 2018


vitalybuka requested changes to this revision.
vitalybuka added inline comments.
This revision now requires changes to proceed.


================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc:177
+#ifndef __GLIBC_PREREQ
+#define __GLIBC_PREREQ(x, y) 0
+#endif
----------------
Do we need to check for this?
Maybe just always go for dlvsym(RTLD_NEXT, "glob", "GLIBC_2.27") ?


================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc:190
+  void *get_tls_static_info_ptr = dlsym(RTLD_NEXT, "_dl_get_tls_static_info");
+#if defined(__i386__) && !__GLIBC_PREREQ(2, 27)
+  /* On i?86, _dl_get_tls_static_info used to be internal_function, i.e.
----------------
kcc wrote:
> nested ifdefs? I'd prefer to avoid them. Move this code into a separate function, maybe? 
maybe?
```
template<typename GetTlsType>
void GetTlsImpl() {
   void *get_tls_static_info_ptr = dlsym(RTLD_NEXT, "_dl_get_tls_static_info");
   GetTlsType get_tls;
    CHECK_EQ(sizeof(get_tls), sizeof(get_tls_static_info_ptr));
    internal_memcpy(&get_tls, &get_tls_static_info_ptr,
                    sizeof(get_tls_static_info_ptr));
    CHECK_NE(get_tls, 0);
    get_tls(&tls_size, &tls_align);
}

static void GetTls() {
#if defined(__i386__)
   if (!dlvsym(RTLD_NEXT, "glob", "GLIBC_2.27"))
     return GetTlsImpl<>;
#endif
 return GetTlsImpl<>
}

```


Repository:
  rL LLVM

https://reviews.llvm.org/D44623





More information about the llvm-commits mailing list