I've been contemplating on writing a dlopen(), dlsym(), dlclose(), dlerror(), like library for one of my embedded projects where not even a C library exists (for which I already wrote my own C/C++ libraries for which can be found here www.libcaprice.com). But what's bugging me is implementing this dynamic library loader. I've taken a look at the paper: http://www.sco.com/developers/devspecs/gabi41.pdf But I can't seem to wrap my head around relocation and how you initialize the GOT.
At first I figured it should be easy to fopen() a library, and walk over the ELF header, validate it's a correct dynamic library, then search for some symbols when dlsym() is used. The problem with this is the library itself needs to be initialized, or more specifically the GOT. There also needs to be some relocation done to ensure that things are within certian bounds and allignment.
I've taken a look at some user-space implementations of this functionality, and they seem to be rather long, complex, and undocumented. So my question really is: are there any stand-alone opensource implementations of dydl that are licensed under a permissive licene, MIT or public domain perferably. Otherwise if there are none, and I will have to implement my own, can someone point me in the right direction of where I could start?
Please don't link the Application V Binary Interface Specification as I've already read the parts about dynamic linking and loading, and none seem to explain the concept of relocation in an understandable way.