title: gcc:how to remove undefined symbol that is not used?
body: <p>here is some C++ test code:</p>
  
  <pre><code>__attribute__((visibility("hidden"))) void foo()
  {
     int fd = fopen("data1", "rb");
     printf ("%d", fd);
  }
  </code></pre>
  
  <p>And all other code don't call function 'foo' and function 'fopen'</p>
  
  <p>Then I use gcc option -ffunction-sections to compile the code to a so file.</p>
  
  <p>As I think, the function foo symbol and foo binary code has't inlcuded in the so file.</p>
  
  <p>But The problem is, I think the symbol 'fopen' should not be symbol table.
  ps:I can make sure that only function 'foo' has use 'fopen'.
  And it actually is not, when I use command nm, I found 'U' type symbol of 'fopen'.</p>
  
  <p>How is the gcc work?
  And has gcc other compile option to found that, symbol 'fopen' is not use, and remove 'fopen' symbol.</p>