title: Prefixing all text-code symbols in a `.o` file
body: <p>I have multiple Fortran static libraries which have functions with the same name, that I'd like to call from Rust. Using <code>objcopy</code> prefixing, I can make the names unique, as shown <a href="https://stackoverflow.com/questions/393980/restricting-symbols-in-a-linux-static-library">here</a>:</p>
  
  <pre class="lang-sh prettyprint-override"><code>ld -r obj1.o obj2.o ... objn.o -o static1.o
  objcopy --localize-hidden --prefix-symbols=foo static1.o static2.o
  ar -rcs mylib.a static2.o
  </code></pre>
  
  <p>However, it seems that <code>objcopy</code> prefixes <em>all</em> symbols, even the ones that only appear as a function call to an external library. Thus, I get errors such as:</p>
  
  <pre><code>/usr/bin/ld: (.text+0xaf0c): undefined reference to `foo_gfortran_runtime_error_at'
  </code></pre>
  
  <p>It seem then that I only want to rename the symbols that are marked as <code>T</code> in <code>nm</code>. Is this correct? Is there a way to do this with <code>objcopy</code> or <code>ld</code>?</p>
  
  <p>Do you also know of a solution that works on Mac as well (where <code>objcopy</code> is unavailable)?</p>