summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrippels <trippels@138bc75d-0d04-0410-961f-82ee72b054a4>2016-11-16 11:28:57 +0000
committertrippels <trippels@138bc75d-0d04-0410-961f-82ee72b054a4>2016-11-16 11:28:57 +0000
commit6f19e5f213ac8ac1c02b0221127b3968adf88f70 (patch)
tree648ea31c0d09ba7d8d4c1f2d688c737b31f65aff
parentbf7dc25e40c18ef3930e916861295c70f7583a88 (diff)
downloadgcc-6f19e5f213ac8ac1c02b0221127b3968adf88f70.tar.gz
Fix PR78294 - thread sanitizer broken when using ld.gold
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-6-branch@242482 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libsanitizer/ChangeLog5
-rw-r--r--libsanitizer/tsan/tsan_rtl.cc1
2 files changed, 6 insertions, 0 deletions
diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog
index 1b1b7acec02..7b2f1d1e00e 100644
--- a/libsanitizer/ChangeLog
+++ b/libsanitizer/ChangeLog
@@ -1,3 +1,8 @@
+2016-11-16 Markus Trippelsdorf <markus@trippelsdorf.de>
+
+ PR sanitizer/78294
+ * tsan/tsan_rtl.cc: Add missing attribute.
+
2016-09-16 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
diff --git a/libsanitizer/tsan/tsan_rtl.cc b/libsanitizer/tsan/tsan_rtl.cc
index 4fceca6f41f..94cf985150e 100644
--- a/libsanitizer/tsan/tsan_rtl.cc
+++ b/libsanitizer/tsan/tsan_rtl.cc
@@ -43,6 +43,7 @@ extern "C" void __tsan_resume() {
namespace __tsan {
#if !defined(SANITIZER_GO) && !SANITIZER_MAC
+__attribute__((tls_model("initial-exec")))
THREADLOCAL char cur_thread_placeholder[sizeof(ThreadState)] ALIGNED(64);
#endif
static char ctx_placeholder[sizeof(Context)] ALIGNED(64);