shared library

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
cmk128
Posts: 4
Joined: Sat Jun 16, 2007 12:01 am
Location: Hong Kong
Contact:

shared library

Post by cmk128 »

Hi
how you design your own "shared library"?
how you compile it and load it to memory?
thanks
from Peter ([email protected])
User avatar
bluecode
Member
Member
Posts: 202
Joined: Wed Nov 17, 2004 12:00 am
Location: Germany
Contact:

Post 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.
cmk128
Posts: 4
Joined: Sat Jun 16, 2007 12:01 am
Location: Hong Kong
Contact:

Post by cmk128 »

Hi bluecode
How can you map the address of a specific function in your library to the ELF executable?
thanks
from Peter
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Post by jnc100 »

This might be of help.

Regards,
John.
Post Reply