This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug ipa/80258] On x86_64 with -fPIC, accesses to TLS can see the wrong thread's TLS
- From: "tmyklebu at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 30 Mar 2017 22:58:14 +0000
- Subject: [Bug ipa/80258] On x86_64 with -fPIC, accesses to TLS can see the wrong thread's TLS
- Auto-submitted: auto-generated
- References: <bug-80258-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80258
--- Comment #9 from Tor Myklebust <tmyklebu at gmail dot com> ---
OK, I gather that the gcc developers, as a group, are against changing this
behaviour. (I can speculate why; almost all code that uses TLS will see a
slowdown.)
In order to work around this behaviour, one needs a way to tell gcc that %fs:0
may have been modified. I don't see a way to do this. None of the following
hacks, if placed before and after the call to something(), produce a desirable
result:
- asm volatile("":::"memory"); no change in output.
- asm volatile("":::"fs"); unknown register name 'fs' in 'asm'.
- asm volatile("":::"%fs"); unknown register name '%fs' in 'asm'.
- __seg_fs uintptr_t *hack = 0;
asm volatile("" : "+r"(hack) :: "memory"); no change in behaviour, though
the TLS region pointer at %fs:0 gets roundtripped through %rax.