Subject: Re: how do I adjust rpath?
To: Luke Mewburn <lukem@NetBSD.org>
From: Eric Haszlakiewicz <erh@jodi.nimenees.com>
List: netbsd-help
Date: 03/29/2005 12:19:20
On Tue, Mar 29, 2005 at 05:25:51PM +1000, Luke Mewburn wrote:
> On Mon, Mar 28, 2005 at 07:00:06PM -0800, Jeremy C. Reed wrote:
>   | On Mon, 28 Mar 2005, Eric Haszlakiewicz wrote:
>   | > 	I have an existing binary.  It's linked against a library in /foo/=
lib.
>   | > I want to move the library to /bar/lib without re-compiling the bin=
ary.
>   | > 	This seems like something that should be easy to do, but I can't
>   | > find the appropriate command and/or flag to do it.
>   |=20
>   | I believe pkgsrc/devel/elfsh can do this.

	ugh.  elfsh sucks.  It has no docs and it's runtime help is not very
helpful.  It also doesn't work very well if you try to append to a section:
the section offsets in the header aren't adjusted so the file just gets
trashed.

>   | And I have done this a few times with this tool:
>   |  http://www.mail-archive.com/linux-gcc@vger.rutgers.edu/msg00317.html
>   | It worked for me.
	hmm.. this looks like a good starting point for writing a more useful
tool.

> If strlen(newrpath) <=3D strlen(origrpath), just binary edit the file.
> No special tools are required.
>=20
> Otherwise, you'll have to relink from the original .o files.
> The tools Jeremy refers to won't help here.

	ugh.  That's not very helpful when I don't have the .o files.
Given ELF's reliance on paths in the binary I would think that being able
to easily change that would have been an important thing to be able to
do, but I guess not.
	I think I can hack something together with a combination of
objdump, elfsh and that rpath changing program to do what I want, but
it seems like making ld do it would make more sense.  I haven't even
glanced at that code though.  Does anyone know how hard it would be
to convince ld to pay attention to the rpath arg when given a binary
instead of .o's for input?

eric