]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix PR78294 - thread sanitizer broken when using ld.gold
authorMarkus Trippelsdorf <markus@trippelsdorf.de>
Wed, 16 Nov 2016 11:31:18 +0000 (11:31 +0000)
committerMarkus Trippelsdorf <trippels@gcc.gnu.org>
Wed, 16 Nov 2016 11:31:18 +0000 (11:31 +0000)
When one uses ld.gold to build gcc, the thread sanitizer doesn't work,
because gold is more conservative when applying TLS relaxations than
ld.bfd. In this case a missing initial-exec attribute on a declaration
causes gcc to assume the general dynamic model. With ld.bfd this gets
relaxed to initial exec when linking the shared library, so the missing
attribute doesn't matter. But ld.gold doesn't perform this optimization
and this leads to crashes on tsan instrumented binaries.

See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78294
and: https://sourceware.org/bugzilla/show_bug.cgi?id=20805

The fix is easy, just add the missing attribute.

  PR sanitizer/78294
  * tsan/tsan_rtl.cc: Add missing attribute.

From-SVN: r242483

libsanitizer/ChangeLog
libsanitizer/tsan/tsan_rtl.cc

index 009441757fe37f1d8b7dd32f97aa56bca748b49b..13d19493495a36637b50bad604e3ae60d3b2e263 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-16  Markus Trippelsdorf  <markus@trippelsdorf.de>
+
+       PR sanitizer/78294
+       * tsan/tsan_rtl.cc: Add missing attribute.
+
 2016-06-03  Release Manager
 
        * GCC 5.4.0 released.
index bf971b62da4c52728150b187769061a00bb1e645..864d2ee5bcdfcfa1ab6c69072e66456fc6dfd446 100644 (file)
@@ -42,6 +42,7 @@ extern "C" void __tsan_resume() {
 namespace __tsan {
 
 #ifndef TSAN_GO
+__attribute__((tls_model("initial-exec")))
 THREADLOCAL char cur_thread_placeholder[sizeof(ThreadState)] ALIGNED(64);
 #endif
 static char ctx_placeholder[sizeof(Context)] ALIGNED(64);