Linking removes unnused code i still need
Posted: Mon Apr 14, 2014 11:01 am
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?
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?