public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Remus Clearwater <remus.clearwater@gmail.com>
To: Xi Ruoyao <xry111@mengyan1223.wang>
Cc: Andrew Haley <aph@redhat.com>, gcc-help@gcc.gnu.org
Subject: Re: 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)?
Date: Mon, 31 Dec 2018 10:49:00 -0000	[thread overview]
Message-ID: <CAMjELSskx7TDp3X_99=Q4ZrSr4=JNn=0omvRYN+UUrWy4VUQcA@mail.gmail.com> (raw)
In-Reply-To: <CAMjELStSRjtByqn_-impOOgpmm-v7MCCW5+ObERMaHOpk8bOYQ@mail.gmail.com>

>
> The compiler must obey the C standard and this is the reasonable way to
>>
> make it so.
>
>
> Yes, it is indeed a very reasonable and elegant way but maybe still not
> the only choice a C compiler could make. Say there is certain C compiler
> tool chain implementation named XCC:
>
> 1. XCC obey the Sys V ABI when calling extern C functions (same as GCC
> does).
> 2. XCC always use a self defined calling convention named
> XCC_CALL_For_Static_Functions to call the static C functions.
> 3. The XCC's XCC_CALL_For_Static_Functions is completely different from
> the calling sequence defined in the Sys V ABI.
> 4. Here is how XCC generated executable binaries (say XBIN for example)
> calling static C functions:
> 4.1. XBIN always maintain a set of all the extern functions' address, and
> the name of this set is "XSET".
> 4.2. When doing function call via any variable function pointers, it would
> check the XSET, if the function pointer pointing to an extern function it
> would choose to use the Sys V ABI Calling Sequence, otherwise the
> XCC_CALL_For_Static_Functions would be used.
> 4.3. For the calling of constant function pointers, XCC will try its best
> to optimize the process described in 4.2 above.
> 5. XCC obey the Sys V ABI and C specs.
>

Suddenly appear to me that it would be much tricky if some C library choose
to export an extern C function pointer variable. I didn't notice such
situation a moment ago.

  reply	other threads:[~2018-12-30 13:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-29 18:52 Remus Clearwater
2018-12-30  9:58 ` Andrew Haley
2018-12-30 10:43   ` Remus Clearwater
2018-12-30 11:30     ` Xi Ruoyao
2018-12-30 12:52       ` Andrew Haley
2018-12-30 13:21       ` Remus Clearwater
2018-12-31 10:49         ` Remus Clearwater [this message]
2018-12-30 13:27       ` Remus Clearwater
2019-01-03 13:46   ` Florian Weimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMjELSskx7TDp3X_99=Q4ZrSr4=JNn=0omvRYN+UUrWy4VUQcA@mail.gmail.com' \
    --to=remus.clearwater@gmail.com \
    --cc=aph@redhat.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=xry111@mengyan1223.wang \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).