GCC 64 bit Calling Conventions

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
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

GCC 64 bit Calling Conventions

Post 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
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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.
quok
Member
Member
Posts: 490
Joined: Wed Oct 18, 2006 10:43 pm
Location: Kansas City, KS, USA

Post 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
iammisc
Member
Member
Posts: 269
Joined: Thu Nov 09, 2006 6:23 pm

Post 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,.
Post Reply