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 ?
Modules & Grub
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Modules & Grub
this is how clicker creates and load modules
Actually, you may even not need a linker script at all for the modules.
- 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.
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 kerneli use -R to add my kernel symbols in my modules
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).second - should i link my modules with the same linker script of the kernel?
Actually, you may even not need a linker script at all for the modules.
simply put,How do u load modules in ur kernel, do it needs a relocation or something ?
- 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.