title: lib specified by LD_PRELOAD can not be loaded
body: <p>I met some trouble when using LD_PRELOAD to load my so.</p>
  
  <p>The steps are as following:</p>
  
  <ol>
  <li><p>libtest.c:</p>
  
  <pre><code>void fun()
  {
      return 
  }
  </code></pre></li>
  <li><p>gcc -o libtest.so libtest.c -fPIC --shared</p></li>
  <li><p>export LD_PRELOAD=<code>pwd</code>/libtest.so</p></li>
  <li><p>main.c</p>
  
  <p><code>extern void fun();
  void main()
  {
      fun()
  }</code></p></li>
  <li><p>gcc -o main -L. main.c -ltest</p></li>
  <li><p>Then <code>ldd main</code></p>
  
  <p><code>
  ldd main
  linux-vdso.so.1=&gt;(0x00007ffff7ffd000)
  /home/shiyanlou/Code/libtest.so(0x00007ffff7df9000)
  libtest.so=&gt;not found
  libc.so.6=&gt;/lib/x86_64-linux-gnu/libc.so.6 (0x00007ffffa29000)
  /lib64/ld-linux-x86-64.so.2 (0x0000555555554000)
  </code></p></li>
  <li>execute main <code>./main</code>
  it promotes:
  error while loading shared library:libtest.so. cannot open shared object file:No such file or directory.</li>
  </ol>
  
  <p>I wonder that why it prompts that libtest.so cannot be found After I exported LD_PRELOAD variable. However, I also tried to use LD_PRELOAD to specify a different shared lib(not "libc.so") to inject malloc function, it works! 
  Why LD_PRELOAD only works for the shared lib that was not used when linking???</p>