title: Linux: How to modify shared library name in Dynamic Section of an ELF binary
body: <p>I have a shared library with soname: <code>libfoo.so</code></p>
  
  <p>How do I link my binary to libfoo.so such that the shared library name in my binary's ELF section is: libfoo5.so? </p>
  
  <p>I tried creating a symlink: libfoo5.so -> libfoo.so, and then linking my library as such:</p>
  
  <p><code>g++ ... -o mybinary *.o -Lpath -lfoo5</code></p>
  
  <p>However, when I print out the dynamic section in my ELF binary, it reads:</p>
  
  <p><code>readelf -d mybinary</code></p>
  
  <p>I still get:</p>
  
  <p><code>Shared library: [libfoo.so]</code></p>