title: Dynamic loading and weak symbol resolution
body: <p>Analyzing <a href="https://stackoverflow.com/q/20568235/1468366">this question</a> I found out some things about behavior of weak symbol resolution in the context of dynamic loading (<code>dlopen</code>) on Linux. Now I'm looking for the specifications governing this.</p>
  
  <p>Let's take <a href="https://gist.github.com/gagern/7989748" rel="nofollow noreferrer">an example</a>. Suppose there is a program <code>a</code> which dynamically loads libraries <code>b.so</code> and <code>c.so</code>, in that order. If <code>c.so</code> depends on two other libraries <code>foo.so</code> (actually <code>libgcc.so</code> in that example) and <code>bar.so</code> (actually <code>libpthread.so</code>), then usually symbols exported by <code>bar.so</code> can be used to satisfy weak symbol linkages in <code>foo.so</code>. But if <code>b.so</code> also depends on <code>foo.so</code> but not on <code>bar.so</code>, then these weak symbols will apparently not be linked against <code>bar.so</code>. It seems as if <code>foo.so</code> inkages only look for symbols from <code>a</code> and <code>b.so</code> and all their dependencies.</p>
  
  <p>This makes sense, to some degree, since otherwise loading <code>c.so</code> might change the behavior of <code>foo.so</code> at some point where <code>b.so</code> has already been using the library. On the other hand, in the question that got me started this caused quite a bit of trouble, so I wonder whether there is a way around this problem. And in order to find ways around, I first need a good understanding about the very exact details how symbol resolution in these cases is specified.</p>
  
  <p><strong>What is the specification or other technical document to define correct behavior in these scenarios?</strong></p>