This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug sanitizer/84761] AddressSanitizer is not compatible with glibc 2.27 on x86


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84761

--- Comment #2 from rguenther at suse dot de <rguenther at suse dot de> ---
On Mon, 19 Mar 2018, fw at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84761
> 
> --- Comment #1 from Florian Weimer <fw at gcc dot gnu.org> ---
> This bit needs to change for glibc 2.27 and later:
> 
> #ifdef __i386__
> # define DL_INTERNAL_FUNCTION __attribute__((regparm(3), stdcall))
> #else
> # define DL_INTERNAL_FUNCTION
> #endif
> 
> We removed the regparm attribute for compatibility with CET.  The GCC manual
> says that regparm (3) is ABI-compatible on i386, but it really is not.
> 
> We could perhaps add an alias to newer glibcs (including 2.27), so that libasan
> can detect that glibc is more recent and call the function with the right ABI. 
> Or expose the information via dlinfo (but the interface is problematic because
> it assumes that the static TLS size is fixed—we could eventually switch to a
> model where we have a larger reserved region for the initial thread).

I think as there are already quite some __GLIBC_PREREQ uses in the
sanitizer lib changing the above prototype appropriately would be
good enough.

Of course exposing the desired information without the need to resort
to a private interface would be nice.

So sth like

Index: libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc
===================================================================
--- libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc    (revision 
258641)
+++ libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc    (working 
copy)
@@ -152,7 +152,14 @@ bool SanitizerGetThreadName(char *name,
 static uptr g_tls_size;

 #ifdef __i386__
+#ifndef __GLIBC_PREREQ
+#define __GLIBC_PREREQ(x, y) 0
+#endif
+#ifdef SANITIZER_LINUX && __GLIBC_PREREQ(2, 27)
+# define DL_INTERNAL_FUNCTION
+#else
 # define DL_INTERNAL_FUNCTION __attribute__((regparm(3), stdcall))
+#endif
 #else
 # define DL_INTERNAL_FUNCTION
 #endif

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]