This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: marking executables with LD_LIBRARY_PATH


"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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]