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)?
Xi Ruoyao
xry111@mengyan1223.wang
Sun Dec 30 11:30:00 GMT 2018
On 2018-12-30 17:58 +0800, Remus Clearwater wrote:
> > B is correct. We don't care about function pointers because we know if a
> > static function has its address takes in the same compilation unit in
> > which it appears. If it has not had its address taken, we don't have
> > to care about the system ABI. If it has, then we need to use the system
> > ABI.
> > If the address of the static function been taken and then we need to use
>
> the
> > system ABI.
>
> Does such action has been documented somewhere inside GCC or as an
> undocumented convention? Or further, even as an undocumented convention
> inside all the many mainstream C compilers (GCC, clang ...)?
The compiler must obey the C standard and this is the reasonable way to
make it so.
> Furthermore, could I make the following conclusion under GCC and Linux?
> Conclusion:
>
> For the "calling" of the C static functions, it has only two
> possibilities -- either it's been inlined by the compiler optimization
> (i.e. not actually been called by the `call` instruction but been optimized
> for the reason of speed), Or it would be actually called (with the `call`
> instruction) under the "Function Calling Sequence" constraints which have
> been described in the Sys V ABI specs (same as the calling of those extern
> C functions).
No. The compiler may use customized calling convention to maximize the
performance unless this function may be called in other translation units.
--
Xi Ruoyao <xry111@mengyan1223.wang>
School of Aerospace Science and Technology, Xidian University
More information about the Gcc-help
mailing list