<div dir="ltr">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".<div><br></div><div>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.</div><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="color:rgb(51,51,51);font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px">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.</span>  </blockquote><div><br></div><div>What's even more strange is that when you learn that it is implemented using regparam in x86.</div><div><a href="https://qr.ae/pNy1wL">https://qr.ae/pNy1wL</a><br></div><div><br></div><div>The documentation for regparam is as follows:</div><div><a href="https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html#x86-Function-Attributes">https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html#x86-Function-Attributes</a>  <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">On x86-32 targets, the </span><code style="color:rgb(0,0,0)">regparm</code><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium"> attribute causes the compiler to pass arguments number one to </span><var style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">number</var><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium"> 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.</span>  </blockquote><div><br></div><div>It says just the opposite.</div><div><br></div><div>What is going on ? Which is correct the stack or the registers ? </div><div><br></div><div>Why is there conflicting info out there ?</div>-- </div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Regards,<div>Sreyan Chakravarty</div></div></div></div></div>