title: Weak symbols and dlopen() with clang vs. gcc
body: <p>I've got a library that defines something like this:</p>
  
  <pre><code>    //singleton.hpp
      class Singleton
      {
      public:
        static Singleton* getInstance()
        {
          static Singleton* mInstance=0;
          if (!mInstance)
          {
              mInstance=new Singleton();
          }
          return mInstance;
        }
      };
  </code></pre>
  
  <p>I include this header when building a couple of shared object libraries.  When I build these shared object libraries with gcc (Ubuntu), the static gets marked as unique:
  (nm output)</p>
  
  <p>0000000000045780 u Singleton::mInstance</p>
  
  <p>When I build the shared libraries with clang the same symbol gets marked as weak:</p>
  
  <p>0000000000045780 V Singleton::mInstance</p>
  
  <p>When I dlopen(..., RT_NOW) the gcc-built shared objects, the dynamic linker fixes everything up and seems to make a single mInstance symbol.  However, when I dlopen(..., RT_NOW) the clang-built shared objects, I get a separate symbol for each library, which makes the singleton not a singleton.  Is this expected behavior?  Is there some way I can force the dynamic linker to behave as if the symbols were marked as unique, as they are with the gcc compilation?</p>