Hi!
I'm loading modules into the kernel. Unresolved references in the module I'm trying to load is read from the elf symbol table of the kernel itself. This works fine. Now I want one module to be able to resolve references against another previously loaded module. This means that the previously loaded module probably need to be modified after it has been loaded (meaning that it's sections should need to reflect it's currently loaded state).
My question is: What is the de facto way to modify a loaded module?
I can solve it in a few different ways. One way could be to just set the entry address of the module to the value of where it is currently loaded in memory and base my relocations off that. Another is that I could modify all entries in the symbol table and add an offset. There are probably more ways than that but which one would you consider to be the correct one?
[solved] What sections to modify in a loaded module?
[solved] What sections to modify in a loaded module?
Last edited by Jezze on Thu Jun 21, 2012 8:44 pm, edited 1 time in total.
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
http://github.com/Jezze/fudge/
- piranha
- Member
- Posts: 1391
- Joined: Thu Dec 21, 2006 7:42 pm
- Location: Unknown. Momentum is pretty certain, however.
- Contact:
Re: What sections to modify in a loaded module?
Why not just have the module initialization call a kernel function that then stores the address of a function and its name provided by that module to the kernel symbol list? Then then new module can link against the previous module no problem.
-JL
-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
Re: What sections to modify in a loaded module?
Thanks for the reply!
I've found the correct way to do it now. I missed the fact that each section header has an address attribute which of course is ment to hold the physical address of that section. It took me a while to spot that and was just about to go in here and remove this question.
I've found the correct way to do it now. I missed the fact that each section header has an address attribute which of course is ment to hold the physical address of that section. It took me a while to spot that and was just about to go in here and remove this question.
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
http://github.com/Jezze/fudge/