Changing hard-code dynamic libraries

Hi,

Apologies if this is in the wrong forum, it is a difficult topic to place.

I have compiled an executable using a networked version of purify and the sun C++ compiler. When I run ldd to see which dynamic libraries the executable is attempting to link, I see the following:

ldd a.exe.pure

/net/appServer/usr/app/rational/releases/purify.sol.2003a.06.15.FixPack.0194/li b32/libpure_solaris2_init.so

This is a hard-coded library path. Curiously, when I compile another executable using a local-server version of purify against a dummy program, I get the following from running ldd:

ldd a.out

libpure_solaris2_init.so.1 =>/opt/rational/releases/purify.sol.2003a.06.13.FixPack.0168/lib32/libpure_solari s2_init.so.1

The difference here is that "a.out" has a soft-link to a library rather than a hard-wired path. LD_LIBRARY_PATH plays no part in resolving libpure_solaris2_init.so.1 for the hard-wired version and fails to resolve at execution time.

What I am wondering is whether it is possible to change the library pointed to in the executable AFTER the executable has been compiled. In this way, I would be able to "re-instruct" the a.exe.pure to use a local libpure_solaris2_init.so.1 rather than the networked library.

As a first thought, I had a look at the 'ld - link editor' but couldnt seem to find anything that would achieve this.

If anyone have any ideas they would be most welcome.

rgds,

J

[1490 byte] By [Jason_Thomas] at [2007-11-26 10:42:42]
# 1
This would be a topic for the linker disucssion group at opensolaris.org http://www.opensolaris.org/jive/forum.jspa?forumID=63
clamage45 at 2007-7-7 2:54:36 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2
As Steve said, it would be good to start this discussion on the linker-interestforum. I filed a similar RFE a while back. http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6234471--chris
ChrisQuenelle at 2007-7-7 2:54:37 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3

An elf editor would be a great thing, but for your particular case it is easy and safe to do a binary edition of the file. One thing to take care of: don't insert or delete characters, only replace them. So you can replace /path/to/liba.so by liba.so (and the next character should be a null char) and leave whatever garbage remains. As long as you don't want to increase the size of the string, it will work.

Marc_Glisse at 2007-7-7 2:54:37 > top of Java-index,Development Tools,Solaris and Linux Development Tools...