[coreboot] __attribute__((stdcall)) vs. __attribute__((regparm(0)))
segher at kernel.crashing.org
Thu Oct 16 16:19:38 CEST 2008
> What about __attribute__((regparm(0))) ?
> The gcc documentation is not clear on this, but a call made this way
> should take all of its arguments from the stack.
> Segher: How do regparm(0) and stdcall differ for i386?
"stdcall" means the callee pops the args from the stack when it returns;
"cdecl" (the default) means the caller has to pop them. "stdcall" gives
smaller code, but cannot work for functions without prototype (you
shouldn't have such anyway, with ISO C -- but in olden days it was the
norm). If you would like stdcall by default, use -mrtd.
"regparm" says how many integer arguments are passed in registers
of on the stack. 0 is the default, and 3 is the maximum. The registers
used are A, D, C. Use -mregparm=N to get some other default.
So, "stdcall" and "regparm" are orthogonal. stdcall would be good for
coreboot (smaller code size), but regparm > 0 probably increases code
size (try it though). Whatever you use, "special" code (context
etc. -- but also all assembler routines in general) need to be aware of
the calling sequence in use, of course -- but they can always override
it to something of their liking.
What is the actual problem you are trying to solve here?
More information about the coreboot