Hi, is there a way to change GCC's long-mode calling convention to act more like the protected-mode calling convention?
When calling a function in protected-mode, all parameters passed to the function are pushed onto the stack before calling the function. In long-mode, the parameters are put in registers before the function call, then the function itself puts the values of those registers on the stack.
I looked around in GCC's documentation but didn't find anything... though I was only skimming through it quite quickly so I might of missed something. Hopefully theres a #pragma that'll do it, that way you could be selective and use the long-mode calling convention for assembly functions etc.
long mode calling convention
- furryfreak
- Member
- Posts: 28
- Joined: Mon Nov 03, 2008 12:45 pm
- Location: SW England
Re: long mode calling convention
I've never heard of being able to. Why would you need that?
the x86_64 ABI specifies that integer arguments must be passed via registers (rdi,rsi,rdx...).
not sure how much help it would be for this, but have you looked at the x86_64 ABI?
You can change the method of function calls in GCC using pragmas, but I remember screwing around with enabling fast calls and such and found that they had minimal/no effect, and definitely nothing as drastic as what you want. If you *must* have that sort of inter-operability, then I'd suggest making some sort of function wrapper that checks to see what mode you're in, and if 64-bit, push the regs to the stack first, and if in 32-bit leave it alone.
the x86_64 ABI specifies that integer arguments must be passed via registers (rdi,rsi,rdx...).
not sure how much help it would be for this, but have you looked at the x86_64 ABI?
You can change the method of function calls in GCC using pragmas, but I remember screwing around with enabling fast calls and such and found that they had minimal/no effect, and definitely nothing as drastic as what you want. If you *must* have that sort of inter-operability, then I'd suggest making some sort of function wrapper that checks to see what mode you're in, and if 64-bit, push the regs to the stack first, and if in 32-bit leave it alone.
Website: https://joscor.com
- furryfreak
- Member
- Posts: 28
- Joined: Mon Nov 03, 2008 12:45 pm
- Location: SW England
Re: long mode calling convention
Thanks, that ABI reference was very useful, though it'd still be nice to be able to force parameters to be passed via the stack.