title: Thread local variables and fs segment
body: <p>I am reading from a thread local variable in my code like this,</p>
  
  <pre><code>// tid_local is declared as __thread int tid_local;
  long tid = tid_local
  </code></pre>
  
  <p>Looking around the dissassembled code, I saw something like this, which I suspect is the instruction which assigns <strong>tid</strong> by reading <strong>tid_local</strong>.</p>
  
  <pre><code>movslq %fs:0xfffffffffffffffc,%rbx
  </code></pre>
  
  <p>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 <strong>fs</strong> segment for storing thread local variables. How is this supposed to work?</p>