[Bug dynamic-link/27004] ld.so is miscompiled by GCC 11
hjl.tools at gmail dot com
sourceware-bugzilla@sourceware.org
Thu Dec 3 12:37:15 GMT 2020
https://sourceware.org/bugzilla/show_bug.cgi?id=27004
--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> ---
How about this
diff --git a/sysdeps/x86_64/nptl/tls.h b/sysdeps/x86_64/nptl/tls.h
index a08bf972de..4eeab0e7a9 100644
--- a/sysdeps/x86_64/nptl/tls.h
+++ b/sysdeps/x86_64/nptl/tls.h
@@ -180,11 +180,19 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) ==
0x80,
assignments like
pthread_descr self = thread_self();
do not get optimized away. */
-# define THREAD_SELF \
+# if __GNUC_PREREQ (11, 0)
+# define THREAD_SELF \
+ ({ struct pthread *__self; \
+ __self = (struct pthread *) (__builtin_thread_pointer () \
+ + offsetof (struct pthread, header.self)); \
+ __self;})
+# else
+# define THREAD_SELF \
({ struct pthread *__self; \
asm ("mov %%fs:%c1,%0" : "=r" (__self) \
: "i" (offsetof (struct pthread, header.self))); \
__self;})
+# endif
/* Magic for libthread_db to know how to do THREAD_SELF. */
# define DB_THREAD_SELF_INCLUDE <sys/reg.h> /* For the FS constant. */
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Glibc-bugs
mailing list