Hi,
When my kernel is linked together from it's source object files I've noticed that if I create functions in a seperate c file that no other function will call the resulting object file will later not be included when I build my kernel. If I call just one of the functions in the file all of them will be included and not just the one I called. This behaviour is probably a good idea in the normal case because it removes unnused code but when you have a kernel and you have modules trying to hook into these functions it is bad when they dont exist. I assume this is one of the reasons you export symbols using macros in the linux kernel among others. Is there any other way that I could tell my linker not to remove code or do you have any other recommendation?
Linking removes unnused code i still need
Linking removes unnused code i still need
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
http://github.com/Jezze/fudge/
Re: Linking removes unnused code i still need
If your code is not exposed in any way, it will be removed. How were you planning to call it? Don't call the kernel just by embedding fixed offsets in driver code. You should have a table of well defined entry points which is used to resolve imports in loaded executables. What I've done is to reserve space for a jump table in the bss section of every executable. This is initialized by the kernel when the executable is loaded.
Re: Linking removes unnused code i still need
I note from your repository that you link your kernel by linking together a set of static library files. In this case, ld by default chooses to only include those files within each archive whose members are actually used. If you wish to include every file in each archive in the link, put the option '--whole-archive' somewhere before the first library on the linker command line.
Regards,
John.
Regards,
John.
Re: Linking removes unnused code i still need
Thanks for your help!
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
http://github.com/Jezze/fudge/