OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 8:36 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: [solved] What sections to modify in a loaded module?
PostPosted: Thu Jun 21, 2012 6:54 pm 
Offline
Member
Member
User avatar

Joined: Thu Jul 26, 2007 1:53 am
Posts: 395
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?

_________________
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/


Last edited by Jezze on Thu Jun 21, 2012 8:44 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: What sections to modify in a loaded module?
PostPosted: Thu Jun 21, 2012 8:10 pm 
Offline
Member
Member
User avatar

Joined: Thu Dec 21, 2006 7:42 pm
Posts: 1391
Location: Unknown. Momentum is pretty certain, however.
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


Top
 Profile  
 
 Post subject: Re: What sections to modify in a loaded module?
PostPosted: Thu Jun 21, 2012 8:44 pm 
Offline
Member
Member
User avatar

Joined: Thu Jul 26, 2007 1:53 am
Posts: 395
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/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 58 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group