[lsb-discuss] Does the standard “Function Calling Sequence” described in Sys V ABI specs (both i386 and AMD64) also applies to the static C functions?

Remus Clearwater remus.clearwater at gmail.com
Sat Dec 29 09:33:01 UTC 2018


Hi Alan, thank you very much for your reply.

In some cases it has to:
> static int foo (int bar)
> {
>         return bar + baz;
> }
> void wibble(struct ops *op)
> {
>         ops->foo = foo;
> }
> In other cases it demonstrably does not because gcc will in fact inline
> the entire static function and it will never even appear in the code.


Thus, could we have the following conclusion?

Conclusion:

For the calling of the C static functions, there have only two
possibilities -- either it's been inlined by the compiler optimization, or
it would be called under the "Function Calling Sequence" constraints which
has been described in Sys V ABI specs.

If the above conclusion is correct, then: Is it just a current result of
the current compilers' implementation (the compiler could decide any
solution that as long as could satisfy both the ABI and the C standard)
which is changeable in the future, or it should be always right as long as
the OS is under the constraints of Sys V ABI i386/AMD64?

Or if the above conclusion is incorrect, do you mind to provide some more
exceptions?

Thanks a lot :-)

On Fri, Dec 28, 2018 at 9:06 PM Alan Cox <alan at llwyncelyn.cymru> wrote:

> On Fri, 28 Dec 2018 20:10:43 +0800
> Remus Clearwater <remus.clearwater at gmail.com> wrote:
>
> > Sorry to repost (to make a better type setting).
> >
> > --
> >
> > I am sure that the standard "Function Calling Sequence" described in Sys
> V
> > ABI specs (both i386 and AMD64) constraints the calling of those extern
> > functions in a C library, but does it constraints the calling of those
> > static functions too?
>
> In some cases it has to:
>
> static int foo (int bar)
> {
>         return bar + baz;
> }
>
> void wibble(struct ops *op)
> {
>         ops->foo = foo;
> }
>
> In other cases it demonstrably does not because gcc will in fact inline
> the entire static function and it will never even appear in the code.
>
> Alan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfoundation.org/pipermail/lsb-discuss/attachments/20181229/e3b716c9/attachment.html>


More information about the lsb-discuss mailing list