Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22151

Does asmlinkage mean stack or register?

$
0
0

In most languages, C included the stack is used for function calls. That's why you get a "Stack Overflow" error if you are not careful in recursion. (Pun not intended).

If that is true then what is so special about the asmlinkage GCC directive.

It says, from #kernelnewbies

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.

I mean I don't think the registers are used in normal function calls.

What is even more strange is that when you learn it is implemented using GCC regparm function attribute on x86.

The documentation of regparm 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.

This basically saying opposite of what asmlinkage is trying do.

So what happens ? Are they on the stack or the registers.

Where am I going wrong ?

The information isn't very clear.


Viewing all articles
Browse latest Browse all 22151

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>