Motivation for -rpath-link

Nick Clifton nickc@redhat.com
Tue Nov 4 12:19:00 GMT 2003


Hi Vladimir,

> I'm somewhat confused about one sentence in -rpath-link documentaion. It says:
>
>    When using ELF or SunOS, one shared library may require another.
>     [....]
>     When the linker encounters such a dependency when doing a non-shared, 
>     non-relocatable link, it will automatically try to locate the required
>     shared library and include it in the link, if it is not included  
>     explicitly.
>
> Why this behaviour is desired?

The behaviour is desired because the executable that is being created
is supposed to be able to run without requiring *any* shared
libraries.  ie it is completely self-contained.


> For example, I have exe "main" which links to shared library "b",
> which links to shared library "a".

So the linker see that "main" requires symbols/code from shared
library "b" and so it pulls the code from that shared library into the
executable that it is creating.  Then is see that this code requires
code from shared library "a", so it pulls in that code as well.  In
the end you have an executable which can run even if the shared
libraries "a" and "b" are not present in the run-time environment.

Cheers
        Nick
        



More information about the Binutils mailing list