title: Is there any preference linker gives to static symbols or dynamic symbols?
body: <p>I have two headers and two cpp files:</p>
  
  <pre><code>//f1.h
  int f1();
  
  //f1.cpp
  include "f1.h"
  int f1() {return 1;}
  
  //f2.h
  int f2();
  
  //f2.cpp
  #include "f2.h"
  #include "f1.h"
  int f2() {return f1() + 1;}
  
  //main.cpp
  #include "f2.h"
  int main() {return f2();}
  </code></pre>
  
  <p>First I compile a shared object from <code>f1</code> and <code>f2</code> and create a binary from <code>main.cpp</code> depending on that shared object:</p>
  
  <pre><code>g++ -c -fPIC -shared f1.cpp f2.cpp
  g++ -shared -fPIC -o libf.so f2.o f1.o
  g++ -o dynamic main.cpp libf.so
  </code></pre>
  
  <p>Now I introduce some changes to <code>f1.cpp</code> (say <code>f1</code> now returns <code>2</code>):</p>
  
  <pre><code>//f1.cpp#
  include "f1.h"
  int f1() {return 2;}
  </code></pre>
  
  <p>And compile a binary as follows:</p>
  
  <pre><code>g++ -o semistatic main.cpp f1.cpp libf.so
  </code></pre>
  
  <p>The question is whether 'semistatic' binary will use definition of <code>f1()</code> from   <code>libf</code> (in which <code>f1</code> returns <code>1</code>) or it will use statically linked symbol (one in which <code>f1</code> returns <code>2</code>)? Is this different across systems and can I rely on this being consistent within a single system?</p>