Hard coding paths to shared libraries
Alexandre Oliva
aoliva@redhat.com
Thu Aug 21 20:15:00 GMT 2003
On Aug 21, 2003, Daniel Jacobowitz <drow@mvista.com> wrote:
> On Thu, Aug 21, 2003 at 01:59:59PM -0500, Rocha Iran-QIR001 wrote:
>> /usr/platform/SUNW,Ultra-60/lib/libc_psr.so.1
>>
>> Apparently, the path to libc_psr.so.1 was hard coded into the binary.
> Look up "rpath" in the GNU ld documentation.
That's not quite the same. Hardcoding the pathname of the library is
not the same as hardcoding a path in which the library might be found.
If Iran actually wants the latter, the trick I'm aware of is uglier:
create a shared library with the same external interface as the one
you'd want to link with, but with an SONAME that is the full pathname
of the library, and then link with this alternate library instead.
If creating a library with the same interface is difficult, you might
create this alternate library such that it is dynamically linked with
the original library, and add an -rpath-link flag to any command line
in which you reference the alternate library such that the linker
finds the actual library. I'm not entirely sure this indirect
arrangement works, though, since I've never tried it.
Yes, this *is* hideous :-)
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer
More information about the Binutils
mailing list