calling style of gcc when compiling kernel

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
ITchimp
Member
Member
Posts: 137
Joined: Sat Aug 18, 2018 8:44 pm

calling style of gcc when compiling kernel

Post 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?
Octocontrabass
Member
Member
Posts: 5885
Joined: Mon Mar 25, 2013 7:01 pm

Re: calling style of gcc when compiling kernel

Post by Octocontrabass »

All of your questions are answered by the ABI specifications.
Post Reply