diff options
| author | Austin Clements <austin@google.com> | 2018-11-01 12:30:23 -0400 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2018-11-12 20:46:55 +0000 |
| commit | 685aca45dc8435df7b7e8059a42a8a98efdaf22c (patch) | |
| tree | 9fa4c1d2e523c8052bc50ed177350eafc77eb9d1 /src/cmd/internal | |
| parent | 1794ee682994ed2efbb9371060856cd7b146f405 (diff) | |
| download | go-685aca45dc8435df7b7e8059a42a8a98efdaf22c.tar.xz | |
cmd/compile, cmd/link: separate stable and internal ABIs
This implements compiler and linker support for separating the
function calling ABI into two ABIs: a stable and an internal ABI. At
the moment, the two ABIs are identical, but we'll be able to evolve
the internal ABI without breaking existing assembly code that depends
on the stable ABI for calling to and from Go.
The Go compiler generates internal ABI symbols for all Go functions.
It uses the symabis information produced by the assembler to create
ABI wrappers whenever it encounters a body-less Go function that's
defined in assembly or a Go function that's referenced from assembly.
Since the two ABIs are currently identical, for the moment this is
implemented using "ABI alias" symbols, which are just forwarding
references to the native ABI symbol for a function. This way there's
no actual code involved in the ABI wrapper, which is good because
we're not deriving any benefit from it right now. Once the ABIs
diverge, we can eliminate ABI aliases.
The linker represents these different ABIs internally as different
versions of the same symbol. This way, the linker keeps us honest,
since every symbol definition and reference also specifies its
version. The linker is responsible for resolving ABI aliases.
Fixes #27539.
Change-Id: I197c52ec9f8fc435db8f7a4259029b20f6d65e95
Reviewed-on: https://go-review.googlesource.com/c/147160
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/internal')
| -rw-r--r-- | src/cmd/internal/obj/arm/asm5.go | 1 | ||||
| -rw-r--r-- | src/cmd/internal/obj/wasm/wasmobj.go | 2 | ||||
| -rw-r--r-- | src/cmd/internal/obj/x86/asm6.go | 1 | ||||
| -rw-r--r-- | src/cmd/internal/objabi/symkind.go | 7 | ||||
| -rw-r--r-- | src/cmd/internal/objabi/symkind_string.go | 4 |
5 files changed, 13 insertions, 2 deletions
diff --git a/src/cmd/internal/obj/arm/asm5.go b/src/cmd/internal/obj/arm/asm5.go index dd6d9265c4..316937bde0 100644 --- a/src/cmd/internal/obj/arm/asm5.go +++ b/src/cmd/internal/obj/arm/asm5.go @@ -1530,6 +1530,7 @@ func buildop(ctxt *obj.Link) { } deferreturn = ctxt.Lookup("runtime.deferreturn") + deferreturn.SetABI(obj.ABIInternal) symdiv = ctxt.Lookup("runtime._div") symdivu = ctxt.Lookup("runtime._divu") diff --git a/src/cmd/internal/obj/wasm/wasmobj.go b/src/cmd/internal/obj/wasm/wasmobj.go index f271101f4b..a1b758836a 100644 --- a/src/cmd/internal/obj/wasm/wasmobj.go +++ b/src/cmd/internal/obj/wasm/wasmobj.go @@ -126,7 +126,9 @@ func instinit(ctxt *obj.Link) { morestackNoCtxt = ctxt.Lookup("runtime.morestack_noctxt") gcWriteBarrier = ctxt.Lookup("runtime.gcWriteBarrier") sigpanic = ctxt.Lookup("runtime.sigpanic") + sigpanic.SetABI(obj.ABIInternal) deferreturn = ctxt.Lookup("runtime.deferreturn") + deferreturn.SetABI(obj.ABIInternal) jmpdefer = ctxt.Lookup(`"".jmpdefer`) } diff --git a/src/cmd/internal/obj/x86/asm6.go b/src/cmd/internal/obj/x86/asm6.go index a4507352f7..520f4be8f5 100644 --- a/src/cmd/internal/obj/x86/asm6.go +++ b/src/cmd/internal/obj/x86/asm6.go @@ -2065,6 +2065,7 @@ func instinit(ctxt *obj.Link) { plan9privates = ctxt.Lookup("_privates") case objabi.Hnacl: deferreturn = ctxt.Lookup("runtime.deferreturn") + deferreturn.SetABI(obj.ABIInternal) } for i := range avxOptab { diff --git a/src/cmd/internal/objabi/symkind.go b/src/cmd/internal/objabi/symkind.go index b95a0d3c70..16b4c535ed 100644 --- a/src/cmd/internal/objabi/symkind.go +++ b/src/cmd/internal/objabi/symkind.go @@ -60,6 +60,13 @@ const ( SDWARFRANGE SDWARFLOC SDWARFMISC + // ABI alias. An ABI alias symbol is an empty symbol with a + // single relocation with 0 size that references the native + // function implementation symbol. + // + // TODO(austin): Remove this and all uses once the compiler + // generates real ABI wrappers rather than symbol aliases. + SABIALIAS // Update cmd/link/internal/sym/AbiSymKindToSymKind for new SymKind values. ) diff --git a/src/cmd/internal/objabi/symkind_string.go b/src/cmd/internal/objabi/symkind_string.go index 7152d6c006..2b9a9080e8 100644 --- a/src/cmd/internal/objabi/symkind_string.go +++ b/src/cmd/internal/objabi/symkind_string.go @@ -4,9 +4,9 @@ package objabi import "strconv" -const _SymKind_name = "SxxxSTEXTSRODATASNOPTRDATASDATASBSSSNOPTRBSSSTLSBSSSDWARFINFOSDWARFRANGESDWARFLOCSDWARFMISC" +const _SymKind_name = "SxxxSTEXTSRODATASNOPTRDATASDATASBSSSNOPTRBSSSTLSBSSSDWARFINFOSDWARFRANGESDWARFLOCSDWARFMISCSABIALIAS" -var _SymKind_index = [...]uint8{0, 4, 9, 16, 26, 31, 35, 44, 51, 61, 72, 81, 91} +var _SymKind_index = [...]uint8{0, 4, 9, 16, 26, 31, 35, 44, 51, 61, 72, 81, 91, 100} func (i SymKind) String() string { if i >= SymKind(len(_SymKind_index)-1) { |
