This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: function arguments are passed in registers


As far as I know, arguments are passed to a function either in registers
or in the stack based on the prototype of the called function.  See the
regparm __attribute__.  My understanding is that this is also arch
dependent, for example s390x always passes arguments in registers (and
then the stack if there are too many).

So your function calling the kernel function should be fine as long as
you have the correct function prototype.

Greg Smith

On Thu, 2008-01-03 at 11:00 +0800, Zheng Da wrote:
> I'm writing a Linux kernel module which needs to call a static
> function in the kernel.
> Unfortunately, the static functions are compiled with arguments passed
> in registers.
> I don't want to change the kernel, so I have to use some trick to pass
> arguments in different ways.
> Currently, I use inline assembly, but I thought maybe GCC provides a better way.
> By the way, how does Linux kernel handle it?
> As I know, static functions pass their arguments in registers, and
> others in the stack.
> How does Linux kernel use them together?
> 
> Zheng Da



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]