Page 1 of 1

[solved] What sections to modify in a loaded module?

Posted: Thu Jun 21, 2012 6:54 pm
by Jezze
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?

Re: What sections to modify in a loaded module?

Posted: Thu Jun 21, 2012 8:10 pm
by piranha
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

Re: What sections to modify in a loaded module?

Posted: Thu Jun 21, 2012 8:44 pm
by Jezze
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.