5

Recently I got a test binary. When I checked it using objdump, I observed that it includes hard coded library path. Why it is needed to to hardcode the path like that? Shouldn't the path be taken from SHELL environment variables or -L parameter instead ?

objdump -p testprog

The output includes the hardcoded path to shared libraries:

....
  NEEDED      /home/test/lib/liba.so
  NEEDED      /home/test/lib/libb.so
  NEEDED      /home/test/lib/libc.so
....
Lunar Mushrooms
  • 8,358
  • 18
  • 66
  • 88
  • 1
    Maybe that is the resolved path on your system? – RedX Jul 03 '12 at 06:47
  • Agree with RedX. Do you actually get any output when executing `strings testprog | grep /home/test`? – Niklas B. Jul 03 '12 at 06:51
  • @NiklasB. The strings give me the all the embedded path above. It is hardcoded inside binary during the compilation. – Lunar Mushrooms Jul 03 '12 at 06:53
  • @Lunar: What compiler do you use? – Niklas B. Jul 03 '12 at 07:10
  • @NiklasB. I received that binary from a customer. They are using gcc (Arm gcc). I think embedding the library path is a standard feature. But I did not get why it is embedded. Also I am interested to know which compiler option caused this path to be embedded (I cannot get sources from customer) – Lunar Mushrooms Jul 03 '12 at 07:13

1 Answers1

5

This is probably because those three .so files had no SONAME on the host where your test program was built. Tell the person who built it to rebuild liba.so with -Wl,soname,liba.so and similar for the other two, then relink the main program.

Alan Curry
  • 14,255
  • 3
  • 32
  • 33