Since r241137 struct S { static __thread int *p; }; int * foo () { return S::p; } emits for non-pic code TLS local exec model relocations instead of initial exec.
The definition of the static data member could be of course in some shared library the binary is linked against. As I've caused this, I'll debug this tomorrow.
Created attachment 40626 [details] gcc7-pr79288.patch Untested fix.
Fix posted for review: http://gcc.gnu.org/ml/gcc-patches/2017-01/msg02349.html
Author: jakub Date: Wed Feb 15 17:09:18 2017 New Revision: 245488 URL: https://gcc.gnu.org/viewcvs?rev=245488&root=gcc&view=rev Log: PR c++/79288 * decl.c (grokdeclarator): For static data members, handle thread_p only after handling inline. * g++.dg/tls/pr79288.C: New test. Added: trunk/gcc/testsuite/g++.dg/tls/pr79288.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog
Fixed.