This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Calling conventions used by gcc
Young, Michael writes:
> >
> > gcc is just a compiler, and doesn't determine the calling conventions:
> > thse tend to be set by the OS being used.
> >
>
> This makes no sense to me... stdcall, cdecl, etc. (wherever they're
> defined/documented, which,
> I believe, is the question) will indeed define an order for
> arguments, handling of CPU flags, and whether the caller or callee
> cleans up the stack.
Right. This is the ABI.
> Since the compiler must generate and maintain the stack frame
> (function prolog and epilog), how is it not "determined" /
> implemented by the compiler?
It is implemented by the compiler and the linker, but it's not part of
the gcc documentation: we follow the platform ABI.
> Admittedly, gcc may not directly "define" the calling convention
> (because it may adopt an existing definition - perhaps defined in
> some "ABI" - which is appropriate, since it is
> architecture-specific), but, ultimately, it must implement
> according to some definition.
> So, where is it documented that for architecture "X", gcc is using
> the calling conventions defined in "Y", and these calling
> conventions are selected by using linkage specification / keyword
> "Z"? (Some architectures may support more than one calling
> convention, although gcc could arbitrarily decide not to implement
> more than one.) Also, I have found precious little formal
> documentation on ABIs (Itanium is the exception) - they tend to be
> more of a convention that is seemingly not well documented (other
> than "folklore" in mailing lists and the code implementations
> themselves), so if it is defined by an ABI, could someone point me
> in the direction of the documentation for that ABI? ("please" and
> "thank you"!)
> I'm personally interested in IA-32, but I believe the original poster was looking for IA-64.
>
> >
> > http://www.freestandards.org/ is the place to look.
> >
>
> What exactly am I looking for here? This looks like a collection
> of standards and forums, and searching the site for "C++ calling
> convention" yields a lot of hits, but nothing definitive.
It's all there. See
http://www.freestandards.org/en/Specifications
http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-IA32/LSB-Core-IA32/book1.html
Andrew.