C++ Thread local storage - same name used in different compilation units

84 views Asked by At

Assume we have the following code in some compilation unit that eventually is compiled to a shared lib on Linux (g++ 4.9)

namespace A {
    class B {
       static __thread MyObj *myobj;
    };
}

So this is compiled into .so and it does not export this symbol (using visibility hidden).

Now, a specific app has the same piece of code that is being used. I.e. same cpp compilation unit is linked with this app, that also access the above shared lib.

Question - are these 2 myobj instances resides in 2 different addresses in TLS? I assume yes but I'm seeing issues that might be related to the above configuration.

0

There are 0 answers