Shared Libraries - loco of GOT & PLT
Posted: Thu Dec 15, 2005 12:50 am
Hi!
Just amidst my coding sessions with TCP IP stuff, I've crossed this Idea of bringing Shared Library & dynamic linking support to my os.
Just in Order to get things straight, I need to ask a few questions which do not receive clear answers by the documents about linkers and loaders -> http://www.iecc.com/linker/linker10.html?the_id=60
f. ex.
1. Where is the PLT & GOT to be placed? In the Process which references the library or in the library itself?
Logic and thinking are telling me: the image of the library can easily be a shared one. If the GOT & PLT are located in the Program binary and are patched in runtime with the needed references by a linker (calls to link fill in the correct addresses in the PLT) so the calls into the library are resolved by merely adjusting symbol offsets with the virtual address the library is mapped to and entering them in the PLT ... complicated sentence, blah.
2. WHat happens, if a library has a dependency in an other library. Other shared library is mapped in either. The first library also has a GOT & PLT, right? Where do these go? Attach them to the process' PLT & GOT? Or how? I'm puzzled.
If I were not for putting lib images into shared memory entities, this stuff 'd be plain easy I reckon. Load all the libraries into the process address space as needed and resolve references immediately. But heck I want this be done with shared memory.
Thanks for the occasional elucidation en advance
stay safe
Just amidst my coding sessions with TCP IP stuff, I've crossed this Idea of bringing Shared Library & dynamic linking support to my os.
Just in Order to get things straight, I need to ask a few questions which do not receive clear answers by the documents about linkers and loaders -> http://www.iecc.com/linker/linker10.html?the_id=60
f. ex.
1. Where is the PLT & GOT to be placed? In the Process which references the library or in the library itself?
Logic and thinking are telling me: the image of the library can easily be a shared one. If the GOT & PLT are located in the Program binary and are patched in runtime with the needed references by a linker (calls to link fill in the correct addresses in the PLT) so the calls into the library are resolved by merely adjusting symbol offsets with the virtual address the library is mapped to and entering them in the PLT ... complicated sentence, blah.
2. WHat happens, if a library has a dependency in an other library. Other shared library is mapped in either. The first library also has a GOT & PLT, right? Where do these go? Attach them to the process' PLT & GOT? Or how? I'm puzzled.
If I were not for putting lib images into shared memory entities, this stuff 'd be plain easy I reckon. Load all the libraries into the process address space as needed and resolve references immediately. But heck I want this be done with shared memory.
Thanks for the occasional elucidation en advance
stay safe