This is the mail archive of the binutils@sourceware.cygnus.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: adding rpath to existing executable


   From: Kasper Peeters <K.Peeters@damtp.cam.ac.uk>
   Date: Sun, 20 Jun 1999 22:38:28 +0100 (BST)

   >    Is there a simple way to add an RPATH to an already existing
   >    executable using binutils?  (this is on i386 elf)
   > 
   > No.

   Ok, let me ask this in a different way ;-)

   Is there a _complicated_ way to add an RPATH to an already existing
   executable using binutils? 

   I looked at libbfd for half an hour, and it seems like I could just
   read the executable file using bfd_openr and friends, add the rpath to
   the private data and write it back. But I find it hard to believe that
   nobody else has had a need for such a program before. 

You could do that, but it wouldn't work.  That is because RPATH goes
into a loadable segment.  When you changed the size of the RPATH, you
would be adjusting the position of everything else in that segment.
The program was linked to expect things to be at a certain position.
When you change that position, the program will no longer work.

   Is libbfd capable of doing this or is more trickery involved that I am
   not aware of?

libbfd is capable of changing the RPATH in certain circumstances which
Richard mentioned: when you can find some place to squeeze it in.  But
you have to do all the work yourself.

I've never known anybody to want to change the RPATH of a linked
executable.  Mostly, people just run a shell script which sets
LD_LIBRARY_PATH.  Otherwise, they rebuild the program, or in extreme
cases they hack the dynamic linker.

Ian

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