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
Shared Libraries - loco of GOT & PLT
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Shared Libraries - loco of GOT & PLT
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Shared Libraries - loco of GOT & PLT
i shall admit that i don't know too much how much of the shared library is known at compile time ... but yet.
Let's say that you want to link (dynamically) against libSDL.so, which in turns require libpng.so and libSDLmixer.so ... you can tell all that (well, you should be able to) at compile time. Gather how many entries in the PLT and GOT each of those things will consume and write the program image accordingly.
Let's say that you want to link (dynamically) against libSDL.so, which in turns require libpng.so and libSDLmixer.so ... you can tell all that (well, you should be able to) at compile time. Gather how many entries in the PLT and GOT each of those things will consume and write the program image accordingly.
Re:Shared Libraries - loco of GOT & PLT
It needs to be separate per process, but it belongs to the library (logic-wise). You need to duplicate all data from the library anyway, unless it's explicitly shared (which is not possible in standard C and needs to be done using shared memory or such).beyond infinity wrote: 1. Where is the PLT & GOT to be placed? In the Process which references the library or in the library itself?
Each library has its own PLT and GOT in the process space. You need them to have a separate one in each process, so the process can adjust those entries instead of the code itself.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.
You only share the code!
You /CAN NOT/ share the modifiable data between processes. It's defined to be process-dependant. You /CAN/ and are encouraged to share the read-only data and code, since they will not modify and are thus saving you space.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.
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:Shared Libraries - loco of GOT & PLT
Thanks a lot for your replies, lads!
This enlightens quite a lot.
so
a) I can create ro shm-entities of the code segments of the library images which can be mapped into the process address spaces as needed
b) I can set a side regions for data segments & the PLT of the library images - these get copied over into the process address spaces as needed - and then I'm going to patch PLT & GOT accordingly for each library as dependency and symbol resolving goes on.
Would this work out?
stay safe
This enlightens quite a lot.
so
a) I can create ro shm-entities of the code segments of the library images which can be mapped into the process address spaces as needed
b) I can set a side regions for data segments & the PLT of the library images - these get copied over into the process address spaces as needed - and then I'm going to patch PLT & GOT accordingly for each library as dependency and symbol resolving goes on.
Would this work out?
stay safe
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image