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

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
User avatar
Jezze
Member
Member
Posts: 395
Joined: Thu Jul 26, 2007 1:53 am
Libera.chat IRC: jfu
Contact:

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

Post 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?
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/
User avatar
piranha
Member
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?

Post 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
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
Jezze
Member
Member
Posts: 395
Joined: Thu Jul 26, 2007 1:53 am
Libera.chat IRC: jfu
Contact:

Re: What sections to modify in a loaded module?

Post 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.
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
Post Reply