Which spec has defined the calling sequence of static C functions (like the extern C functions' has been defined in the Sys V ABI specs)?
Remus Clearwater
remus.clearwater@gmail.com
Sat Dec 29 18:52:00 GMT 2018
Hi,
I am sure that the standard "Function Calling Sequence" described in Sys V
ABI specs (both i386 and AMD64) applies to the calling of those extern
functions in a C library, but does it applies to the calling of those
static C functions too if we do not take the compiler's "inline"
optimization into account (say such "inline" optimization has been switched
off)?
I think it should have two possibilities -- A and B:
A. The calling of those un-inlined static C functions should also comply
with the function calling sequence details (including registers usage,
stack frame, parameters passing, variable arguments...) which is defined in
the Sys V ABI spec just like the extern C functions do.
I think A should be correct. But I didn't manage to find any detailed
reference in the Sys V ABI specs (i386 & AMD64) or in the C standard.
B. The calling of those un-inlined static C functions does not have to
comply with the function calling sequence defined in the ABI spec. And
because the calling of the function pointers which are pointing to the
static C functions has to work correctly as the C standard described, so it
is the compiler's free will to decide any "calling sequence" that as long
as could satisfy both the Sys V ABI and the C standard.
If B is right, then what is the special "calling sequence" GCC chooses for
calling static C functions? Is GCC just use the same "Function Calling
Sequence" rule which has been described in Sys V ABI specs (same as the
calling of those extern C functions)?
Thank you very much.
PS:
This question has been discussed on the SO yesterday, but I didn't manage
to get an exact answer.
--
https://stackoverflow.com/questions/53958062/does-the-standard-function-calling-sequence-described-in-sys-v-abi-specs-both
Thanks a lot.
More information about the Gcc-help
mailing list