OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 11:17 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Modules & Grub
PostPosted: Mon Jan 30, 2006 6:01 pm 
Hello,
i've some question regarding modules loading and grub.

i use -R to add my kernel symbols in my modules

fisrt - how should i compile & link my modules ?
second - should i link my modules with the same linker script of the kernel?
third - or there should be another linker script for my modules?

How do u load modules in ur kernel, do it needs a relocation or something ?


Top
  
 
 Post subject: Re:Modules & Grub
PostPosted: Tue Jan 31, 2006 2:31 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
this is how clicker creates and load modules

Quote:
i use -R to add my kernel symbols in my modules

that is incremental linking, right ? that's quite a good idea, but it may make typos hard to catch since you couldn't make the difference at first sight between unresolved "kmalloc" (to be linked with the kernel symbol) and "kmallco" (typo, won't be linked with anything) until you load the module, so you may want to take the time to compare the output of "objdump -x <module>" with the table of symbols exported by your kernel

Quote:
second - should i link my modules with the same linker script of the kernel?

probably not. e.g. the linker script of the kernel may contain hints to load stuff at the expected kernel's place while your module will more likely need to be loaded anywhere. Yet, there are things that you can keep such as the generic guidelines (.rodata* and the like).
Actually, you may even not need a linker script at all for the modules.

Quote:
How do u load modules in ur kernel, do it needs a relocation or something ?

simply put,
- load stuff in proper place (that is, moving it from where GRUB placed it to where I want it to be)
- process relocations (patch the binary so that it fits the place it received)
- process symbols (retrieve required symbols and patch the binary again ... then add exported symbols to the 'ksyms' table)
- call initialization routine(s).

Other steps (such as automatic loading of depending modules, keeping track of dependencies, etc.) have been added over time, but i don't think you're going to need that immediately.

_________________
Image May the source be with you.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 105 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