Page 1 of 1

GCC 64 bit Calling Conventions

Posted: Wed Nov 07, 2007 4:54 am
by AJ
Ok - after some serious banging my head against a brick wall, I have found that 64 bit mode, GCC does not, in fact, push its arguments to the stack, but uses rdi to hold the first parameter.

After some Googling, I have found that GCC does use more of a fastcall-type system in 64 bit mode, but I haven't found a decent reference to the specifics of the system it does use. As I am about to write some asm support functions, this information would obviously be useful! I havent even found what I want on the GNU site - this may be my useless search terms, though :roll: .

Does anyone know of a good online reference to the calling system GCC uses when I am compiling for long mode?

Cheers,
Adam

Posted: Wed Nov 07, 2007 4:57 am
by AJ
:oops:

http://www.x86-64.org/documentation/abi.pdf

I found this link from the nasm web site - I was approaching it from the other end with the GCC website before.

Posted: Wed Nov 07, 2007 2:09 pm
by quok
This link at wikipedia goes over all the x86 calling conventions, and has links to different ABI pdfs as well.

http://en.wikipedia.org/wiki/X86_calling_conventions

Posted: Sun Nov 11, 2007 11:32 am
by iammisc
A little piece of reflection code i've written for a component system:
http://vwp.svn.sourceforge.net/viewvc/v ... 2/vwpCall/

Since i wrote it on amd64, the amd64-call.cpp and amd64-reflect.cpp offer a pretty much complete reflection support for c++ with support for vtables and creating classes on the fly in addition to calling functions with a list of arguments,.