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

Jakub JelĂ­nek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 9 08:27:13 PDT 2018


jakubjelinek added inline comments.


================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc:177
+#ifndef __GLIBC_PREREQ
+#define __GLIBC_PREREQ(x, y) 0
+#endif
----------------
vitalybuka wrote:
> jakubjelinek wrote:
> > vitalybuka wrote:
> > > Do we need to check for this?
> > > Maybe just always go for dlvsym(RTLD_NEXT, "glob", "GLIBC_2.27") ?
> > It is not strictly needed, just an optimization.  At least in GCC, if somebody configures the compiler against some version of binutils, glibc etc., we assume that at runtime that version or newer of it is available, so it is an optimization; if somebody configures against glibc 2.27+, it avoids the dlvsym calls on startup of every sanitized app.
> ```
> #if defined(__i386__) && (!defined(__GLIBC_PREREQ) || !__GLIBC_PREREQ(2, 27))
> #define CHECK_GET_TLS_STATIC_INFO_VERSION 1
> #else
> #define CHECK_GET_TLS_STATIC_INFO_VERSION 0
> #endif
> 
> ...
> 
> if (CHECK_GET_TLS_STATIC_INFO_VERSION && !dlvsym(RTLD_NEXT, "glob", "GLIBC_2.27")) {
> 
> ```
This will not compile if `__GLIBC_PREREQ` is not defined, it has to be nested #if or `__GLIBC_PREREQ` needs to be always defined.


Repository:
  rL LLVM

https://reviews.llvm.org/D44623





More information about the llvm-commits mailing list