Dr William Bland <wjb@abstractnonsense.com> [2003-06-25 23:27]: > Lukas Ruf wrote: > > >> I would think that, when you call a function using a function pointer, > >> gcc will assume that all arguments get passed on the stack > >> (asmlinkage) since it can't know anything about the function's actual > >> linkage. > > > > Have you checked what asmlinkage does? IIRC this is defined in > > include/linux/linkage.h. > > Yes I have. It defines __attribute__((regparm(0))), which tells gcc to > pass all the function's arguments on the stack - *not* in registers (which > is something gcc sometimes does to make things faster). > well, but isn't the register calling semantic reserved just for syscalls -- maybe I am mistaken.... Thus, if all functions either statically linked or loaded as modules are not syscalls, the standard calling syntax, i.e. stack-based, is used. Further, isn't it depending on the platform, you base your implementation on? > > 1) push 3 onto the stack > 2) call the function whose address is in bar (i.e. foo) > 3) foo looks for its argument (x) in EAX... OH DEAR! > > Does that make sense? yes. Thanks! wbr, Lukas -- Lukas Ruf | Wanna know anything about raw | <http://www.lpr.ch> | IP? <http://www.rawip.org> | -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/