Page 1 of 1
module support
Posted: Sun Apr 17, 2005 2:30 am
by Poseidon
I want to create module support for my kernel, but what are the basics steps for finding symbols and addresses, what format is the easiest to handle, etc.? What do I need more?
Thanks
Re:module support
Posted: Sun Apr 17, 2005 4:16 am
by Pype.Clicker
from my personnal experience, it was easier to write a tool that converts an 'existing' format (e.g. ELF/COFF) into your own format.
This way, you can re-organize the symbol table in a way that suits easy loading. You may wish to look for more info about it in the wiclicker (
http://clicker.sf.net/wiclicker/)
don't have time for much more atm. but i'll be back.
Re:module support
Posted: Mon Apr 18, 2005 8:33 am
by Poseidon
OK, I'll do that then. What's the best design for such a format, and how do I find the addresses after call and jmp instructions to change them into their actual address?
Thanks
Re:module support
Posted: Mon Apr 18, 2005 10:07 am
by Pype.Clicker
The components i'd suggest are:
- a relocation list (that is simply a list of dwords to be patched with the load address). I wouldn't recommend PIC code at all for kernel modules (at least, not on intel processors)
- a compact header containing all you could need: amount of bytes needed for the modules, amount of bytes in the module, pointer towards the "init" function, pointer towards the "fini" function, pointer towards the import and export symbol tables
* The "export table" is usually fairly simple: it just contains names and addresses associated with those names.
* The "import table" may be more complicated since you also need to patch the loaded code so that it now refers to the existing symbols. The best i've found so far is to use the dwords to be patched to store the linked list of dwords to be patched.