Page 1 of 1

shared library

Posted: Sat Jun 16, 2007 12:16 am
by cmk128
Hi
how you design your own "shared library"?
how you compile it and load it to memory?
thanks
from Peter ([email protected])

Posted: Sat Jun 16, 2007 6:25 am
by bluecode
I use the elf file format for every executable/shared object. The shared objects are loaded by grub as a multiboot module into memory. My kernel identifies them as shared libraries (that's in the first bytes of the elf header) and links them to a specific address (at least on x86, perhaps they will be true position independant on x86-64). When another executable elf file needs a library the library is mapped at that specific address into the address space and all necessary relocations for the executable elf file are processed.
Perhaps I will provide a callback, in case some elf file needs a not already loaded shared library and perhaps I'll reference count the shared libraries so that the memory can be freed, when they are unused. But that are future plans.

Posted: Sat Jun 16, 2007 1:09 pm
by cmk128
Hi bluecode
How can you map the address of a specific function in your library to the ELF executable?
thanks
from Peter

Posted: Sat Jun 16, 2007 5:01 pm
by jnc100
This might be of help.

Regards,
John.