Page 1 of 1

calling style of gcc when compiling kernel

Posted: Wed Jul 22, 2020 3:15 am
by ITchimp
Can someone help me understand the default calling convention of GCC when compiling the kernel...

I am vaguely aware that it is _cdecl... but not sure...

if what I am aware is true, then arguments are pushed onto stack in the reverse order it is declared...
the caller will clean up the stack upon returning from function call... result will be placed into eax, ebp s
not used ..

esp will grow or rewind as functions are called and returned

aside from those... are there any guarantees on which registers would the callee free to use and not worry
about overwritten etc?

The related question I have...

I am aware that the most frequent use of stack management of function calls is as follows

Code: Select all

push %ebp;
mov %esb, %ebp;
...// what ever goes in there

mov %ebp, %esp;
pop %ebp
or simply

Code: Select all

leave
why is this the default gcc calling convention?

Re: calling style of gcc when compiling kernel

Posted: Wed Jul 22, 2020 3:43 am
by Octocontrabass
All of your questions are answered by the ABI specifications.