This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: marking executables with LD_LIBRARY_PATH
- To: "Marty Leisner" <mleisner at eng dot mc dot xerox dot com>
- Subject: Re: marking executables with LD_LIBRARY_PATH
- From: Ian Lance Taylor <ian at zembu dot com>
- Date: 23 Jan 2001 13:19:54 -0800
- Cc: binutils at sources dot redhat dot com
- References: <200101232006.PAA13993@mailhost.eng.mc.xerox.com>
"Marty Leisner" <mleisner@eng.mc.xerox.com> writes:
> I recently read a paper on "Why LD_LIBRARY_PATH is bad"
> (http://www.visi.com/%7ebarr/ldpath.html).
>
> I agree with this (I'm now going through LD_LIBRARY_PATH gyrations).
>
> One of the things the author asks for is:
> Have OS's ship with programs which allow one to safely change an executable's run-time linker path.
>
> Is there a way to do it in the linker (I'm running 2.10.1) on elf systems?
Not easily, unfortunately. In order to be useful, the library search
path should be in a loadable segment. It's hard to change the size of
a loadable segment in an existing executable. For efficiency,
executables are normally linked to optimize page use. This doesn't
leave any room to stuff additional information in there.
> The choice to "relink" the objects is bad...(when they're not there).
> I tried "relinking" the executable, it doesn't seem to do anything useful
> (although its not making a carbon copy of the input -- but its the same size and
> also runs with the right LD_LIBRARY_PATH).
I'm not sure what you mean here. Did you relink with a different
--rpath option?
> This seems something very useful and very easy -- just sticking a few
> bytes in the right place of a binary...
That is indeed all that is involved, but unfortunately binaries take
up all the bytes.
> Is there a way to look at the built in rpaths with readelf?
Sure. readelf -d or objdump -p. Look for the RPATH entry.
Ian