Patch: Re: bug in ld -rpath ??

H . J . Lu hjl@lucon.org
Mon Aug 21 21:16:00 GMT 2000


On Mon, Aug 21, 2000 at 03:40:55PM -0700, Nick Clifton wrote:
> 
> H.J.  Please could you amend your patch to do the following things:
> 
>   * Only search through the DT_RPATH and DT_RUNPATH entries if the
>     -rpath and -rpath-link command line switches have not been
>     specified.  This should make the linker behave as it did before in
>     the presence of these switches.

I disagree. I agree -rpath and -rpath-link should take precedent over
DT_RPATH/DT_RUNPATH. But it doesn't mean DT_RPATH/DT_RUNPATH should be
ignored all together if -rpath and -rpath-link are passed to ld. In my
patch, DT_RPATH/DT_RUNPATH is searched after LD_LIBRARY_PATH, which is
after -rpath and -rpath-link. I checked the Solaris linker. Passing
"-R /lib" to the Solaris ld doesn't ignore DT_RPATH.

BTW, I have changed my patch for native link only since it doesn't
make much senses to do it for cross link. That brings another question.
Should we search -rpath for cross link?. -rpath sets DT_RPATH. For
cross link, DT_RPATH is almost always wrong since it is to be used
at the run time on target.

> 
>   * Update the documentation in ld.texinfo to:
> 
>       1. Make it clear that the -rpath and -rpath-link switches
>          completely stop the linker from using the DT_RPATH and
>          DT_RUNPATH entries, (the wording at the moment is open to
>          interpretation).
> 
>       2. At an item (in the correct place!) to the list of places
>          where the linker will search for shared libraries saying
>          that, for ELF systems, if the -rpath and -rpath-link switches
>          have not been used, then it will look in the directories
>          specified by the DT_RPATH or DT_RUNPATH entries in the
>          relevant object file.

I will do that after we come to an agreement.

> 
>    * Add an entry to the NEWS file noting this new behavior.

Will do.

> 
>    * Add code to the ..._after_open() function to display the searches
>      (both successful and failed) for needed libraries when the
>      -verbose switch is used.  (Searches for libraries specified on
>      the command line are shown with this option, and I believe that
>      it would be helpful to have the needed library searches shown as
>      well).


A good idea. I will do that.


H.J.


More information about the Binutils mailing list