title: __attribute__((constructor)) && __attribute__((destructor)) in multithreaded app
body: <p>I have an app that I am currently writing in C , where I have several TLS static global variables declared inside a library which is part of the project.</p>
  
  <p>The TLS variables are declared using gcc's __thread directive.</p>
  
  <p>I would like to know if I can use .ctor &amp;&amp; .dtor sections to initialise TLS data on a per thread basis inside a shared or static C library, and how thread safe using this method is.</p>
  
  <p>Will the .ctor &amp;&amp; .dtor sections be executed per thread or they exist only in the parent process?</p>
  
  <p>On a final note , the library compiles either statically or dynamically to application code , does this mean the .ctor &amp;&amp; .dotr sections decalred in the shared/static library will be part of the final executable?</p>
  
  <p>I am really confused about the threading part mostly ... anyone who has an idea?</p>