Best ABI for stdarg/varargs ??
Dave Korn
davek-ml@ntlworld.com
Sat Apr 7 10:12:00 GMT 2001
----- Original Message -----
From: "Greg McGary" <greg@mcgary.org>
Sent: Saturday, April 07, 2001 12:44 AM
> I am doing a new port to a MIPS-like CPU and have the freedom to
> define the ABI. What do you consider to be a clean way to handle
> stdarg/varargs for such a CPU? If an existing port does it well,
> please refer me to it, otherwise please describe how it should be
> done.
>
> BTW, an out-of-the-ordinary thing I plan to do in this ABI is to grow
> the stack from low to high addresses. The rationale is to keep
> stack-saved frame chain and procedure linkage at lower addresses than
> the current function's automatic variables, so that buffer overruns
> can't clobber them.
If you can assume the existence of a decent MMU in the ABI, it's also
worth marking the stack non-executable. I suppose this must require some
alternative way of dealing with thunks / trampolines.
I don't know MIPS so I can't really comment on the best architecture to
use for it's stdargs. I like the SysV4 / EABI way of doing it; it requires
a little more overhead at runtime and it's quite difficult to get right in
the compiler (!) but it makes best use of the cpu's registers and on a RISC
architecture that's pretty important. I guess it depends quite a lot on
what you've chosen as the calling convention for non-variadic functions, it
should really be based around that.
DaveK
More information about the Gcc
mailing list