Is there a document for Go ABI specification

688 views
Skip to first unread message

Wei....@arm.com

unread,
Jul 12, 2017, 6:23:49 AM7/12/17
to golang-dev
I find some comments mentioning "Go ABI".
Is there a document for it?

Thanks
Wei

Ian Lance Taylor

unread,
Jul 12, 2017, 9:05:59 AM7/12/17
to Wei....@arm.com, golang-dev
On Wed, Jul 12, 2017 at 3:23 AM, <Wei....@arm.com> wrote:
>
> I find some comments mentioning "Go ABI".
> Is there a document for it?

I assume you mean the ABI that is used by the gc toolchain, which is
the default Go installation. I don't think there is any official
documentation of that ABI. And there are no promises that the ABI
will not change in future versions--for example, see
https://golang.org/issue/18597.

The current ABI is fairly simple: all function arguments are pushed on
the stack, and all result arguments are returned on the stack. In
effect you construct a struct of the receiver, the normal parameters,
and the result parameters, put that struct on the stack, fill in the
receiver and normal parameters, and then call the function. Closures
are handled by passing the address of the closure struct in a
register, where the register varies by platform.

Ian

Wei....@arm.com

unread,
Jul 13, 2017, 12:04:48 AM7/13/17
to golang-dev, Wei....@arm.com
Thanks for the explanation!
So platform related definitions (such as caller-saved registers and callee-saved registers) are not included in Go ABI and they are decided by each port itself.

Ian Lance Taylor

unread,
Jul 13, 2017, 12:09:15 AM7/13/17
to Wei....@arm.com, golang-dev
On Wed, Jul 12, 2017 at 9:04 PM, <Wei....@arm.com> wrote:
>
> So platform related definitions (such as caller-saved registers and
> callee-saved registers) are not included in Go ABI and they are decided by
> each port itself.

Well, sort of. In the current ports there are no callee-saved
registers other than the frame pointer.

Ian
Reply all
Reply to author
Forward
0 new messages