On Thu, Jul 15, 2010 at 10:13:54PM +0400, Dmitry Krivenok wrote: > Unfortunately, one can easily miss such problems during build of the module. > I'm working on a system which consists of lots of user-space programs > and kernel modules and > uses it's own complicated build system. > gcc option -Werror is not used by the build system (I believe it > should), that's why we just missed > a compiler warning when called undeclared function (actually declared > as static deep in kernel source). > > Then we got kernel panic and started investigating it. > I disassembled seltdinit function and found that it takes pointer to > thread from %eax register and global kernel > functions (e.g. kern_select) calling seltdinit copy the pointer to > %eax just before "call" instruction. > > Then I disassembled my own function calling seltdinit and found that > it passes the pointer via stack and > doesn't do anything with %eax register. > > I'm not OS/compilers/ASM expert, but I guess that gcc is free to > optimize passing of parameters to static functions > because it has all the information about callers of these static > functions (all stuff is inside one translation unit). > So kernel functions call static functions in a right way, but modules > compiled separately may use wrong calling > convention. Your message does not contain the question, but right answer is that you should not call static functions.
pgph7MXonIOXB.pgp
Description: PGP signature