Why is there conflicting information out there for asmlinkage ?

Sreyan Chakravarty sreyan32 at gmail.com
Wed May 6 08:51:54 EDT 2020

I thought that all C programs normally use the stack for function calls.
That's why in most languages if you are stuck in an infinite recursion you
get a "Stack Overflow Error".

If that is true, then what is so special about asmlinkage, it tells the
program to look for variables in the stack rather than registers. The
runtime does not look for values in the register in the first place.

The asmlinkage tag is one other thing that we should observe about this
> simple function. This is a #define for some gcc magic that tells the
> compiler that the function should not expect to find any of its arguments
> in registers (a common optimization), but only on the CPU's stack.

What's even more strange is that when you learn that it is implemented
using regparam in x86.

The documentation for regparam is as follows:

> On x86-32 targets, the regparm attribute causes the compiler to pass
> arguments number one to number if they are of integral type in registers
> EAX, EDX, and ECX instead of on the stack. Functions that take a variable
> number of arguments continue to be passed all of their arguments on the
> stack.

It says just the opposite.

What is going on ? Which is correct the stack or the registers ?

Why is there conflicting info out there ?
Sreyan Chakravarty
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20200506/6bf3a429/attachment.html>

More information about the Kernelnewbies mailing list