I am reading from a thread local variable in my code like this,
// tid_local is declared as __thread int tid_local;
long tid = tid_local
Looking around the dissassembled code, I saw something like this, which I suspect is the instruction which assigns tid by reading tid_local.
movslq %fs:0xfffffffffffffffc,%rbx
Now my question is if this can really be the instruction which is doing this, that is, reading from the local thread variable and if gcc always uses the fs segment for storing thread local variables. How is this supposed to work?
Yes, this could well be the right instruction. From the
gccmanual:edit Here is an excellent link suggested by @janneb in the comments: http://www.akkadia.org/drepper/tls.pdf