Dynamic Linking - binding Lib in runtime.
Posted: Mon Feb 21, 2005 2:42 am
Ok. Yes, I have scanned throu the famous Linkers-Document. I have understood the basics. Now, I want to know how it *works*
Say, you bind a program dynamically against a library (say library.o) The executeable sports a library (ld.o?), which is responsible for resolving symbols at runtime:
Here I have questions:
1. A shared library is shared memory with some additional properties (name, size, table of relative adresses to functions)
2. The executeable of our program sports a table of calls to the functions in the shared library. Those function calls have to be resolved - either upon fetching the library or upon call.
3. the executeable has a table of libraries to be loaded.
4. ld.o is responsible for the resolving of the symbols in the call table for this library - thus resolving "external calls to module XXX" at runtime.
5. scheme of how it might work:
Program starts up. crt0 performs some checks. Eventually it calls ld.o - load_library("name") for each library in the table of required libraries. ld.o fetches the libraries: is a library present, map it in and perform the binding agains the local table of calls. else have the library manager load the library, create a shared memory mapping and hand over a name for the library - then map it in and perform the binding (filling in the call table with the corresp. addresses)
then the program starts to work and can use all the libraries as if linked statically.
That's the scheme as I understand it. Are there any flaws in it? is there more to add?
Thanks for your input!
Say, you bind a program dynamically against a library (say library.o) The executeable sports a library (ld.o?), which is responsible for resolving symbols at runtime:
Here I have questions:
1. A shared library is shared memory with some additional properties (name, size, table of relative adresses to functions)
2. The executeable of our program sports a table of calls to the functions in the shared library. Those function calls have to be resolved - either upon fetching the library or upon call.
3. the executeable has a table of libraries to be loaded.
4. ld.o is responsible for the resolving of the symbols in the call table for this library - thus resolving "external calls to module XXX" at runtime.
5. scheme of how it might work:
Program starts up. crt0 performs some checks. Eventually it calls ld.o - load_library("name") for each library in the table of required libraries. ld.o fetches the libraries: is a library present, map it in and perform the binding agains the local table of calls. else have the library manager load the library, create a shared memory mapping and hand over a name for the library - then map it in and perform the binding (filling in the call table with the corresp. addresses)
then the program starts to work and can use all the libraries as if linked statically.
That's the scheme as I understand it. Are there any flaws in it? is there more to add?
Thanks for your input!