title: how does ld deal with code that is supplied twice (in a source file and in a library)?
body: <p>Suppose we call</p>
  
  <pre><code>gcc -Dmyflag -lmylib mycode.c
  </code></pre>
  
  <p>where <code>mylib</code> contains all of <code>mycode</code> but is compiled without <code>-Dmyflag</code>. So all functions and other entities implemented in <code>mycode</code> are available in two versions to the loader. Empirically, I find that the version from <code>mycode</code> is taken. Can I rely on that? Will <code>mycode</code> always overwrite <code>mylib</code>?</p>