Windows下的調用約定可以是stdcall/cdecl/fastcall,這些標識加在函數名前面,如:
int __stdcall funca()
但在Linux下,如按照上面寫法後,編譯程序將導致編譯錯誤,Linux下正確的語法如下:
int __attribute__((__stdcall__)) funca()
int __attribute__((__cdecl__)) funca()
Linux下如果函數不指定調用約定,默認的情況應該是__attribute__((__cdecl__))
int __attribute__((__cdecl__)) myfunc(int i, int j, int k)
{
return i+j+k;
}
080483d0 <myfunc>:
80483d0: 55 push %ebp
80483d1: 89 e5 mov %esp,%ebp
80483d3: 8b 45 0c mov 0xc(%ebp),%eax
80483d6: 03 45 08 add 0x8(%ebp),%eax
80483d9: 03 45 10 add 0x10(%ebp),%eax
80483dc: 5d pop %ebp
80483dd: c3 ret
80483de: 66 90 xchg %ax,%ax
int __attribute__((__stdcall__)) myfunc(int i, int j, int k)
{
return i+j+k;
}
080483d0 <myfunc>:
80483d0: 55 push %ebp
80483d1: 89 e5 mov %esp,%ebp
80483d3: 8b 45 0c mov 0xc(%ebp),%eax
80483d6: 03 45 08 add 0x8(%ebp),%eax
80483d9: 03 45 10 add 0x10(%ebp),%eax
80483dc: 5d pop %ebp
80483dd: c2 0c 00 ret $0xc