This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug ipa/80258] On x86_64 with -fPIC, accesses to TLS can see the wrong thread's TLS


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]