change RPATH in existing executable

Jeremy C. Reed reed at reedmedia.net
Thu Oct 21 14:40:58 PDT 2004


Any ideas on how to add another path to the RPATH in an existing
executable?

Examples of the files are:

reed at puget:~$ file /usr/lib/libkdeinit_kcookiejar.so
/usr/lib/libkdeinit_kcookiejar.so: ELF 32-bit LSB shared object, Intel
80386, version 1 (SYSV), not stripped

reed at puget:~$ objdump -x /usr/lib/libkdeinit_kcookiejar.so | grep -i rpath
  RPATH       /usr/gcc3/lib:/usr/qt3/lib

reed at puget:~$ file kde-config
kde-config: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for
GNU/Linux 2.0.0, dynamically linked (uses shared libs), not stripped

reed at puget:~$ objdump -x kde-config | grep RPATH
  RPATH       /usr/gcc3/lib:/usr/qt3/lib

I found a program at
 http://www.mail-archive.com/linux-gcc@vger.rutgers.edu/msg00317.htm
which compiled fine for me (under Linux and NetBSD), but it failed:

reed at puget:~$ ./change-rpath kde-config
kde-config:existing RPATH: /usr/gcc3/lib:/usr/qt3/lib

reed at puget:~$ ./change-rpath kde-config /usr/gcc3/lib:/usr/qt3/lib:/usr/X11R6/lib
kde-config:existing RPATH: /usr/gcc3/lib:/usr/qt3/lib
new rpath '/usr/gcc3/lib:/usr/qt3/lib:/usr/X11R6/lib' too large; maximum
length 26

I see that the tool wants to replace (for the same amount of
characters) and not append.

I also found elfsh (http://elfsh.segfault.net/) but I am not sure if it
can handle this too. (I asked on that list a few hours ago, but the email
never appeared to get to their list yet.)

I would rather adjust the RPATH in the binary than adjust my environment.
I guess I could use shorter library path names and symlinks, etc. I also
know I can rebuild, but I wanted to try this first.

Any ideas?

 Jeremy C. Reed

 	  	 	 open source, Unix, *BSD, Linux training
	  	 	 http://www.pugetsoundtechnology.com/



More information about the freebsd-chat mailing list