Re: function arguments are passed in registers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You are right. __attribute__((regparm(3))) or fastcall works in my module.
Thanks a lot.

Zheng Da

On Jan 3, 2008 11:26 AM, Greg Smith <gsmith@xxxxxxxxx> wrote:
> 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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux