Commit af1bfe0a authored by Austin Clements's avatar Austin Clements

runtime: correct ABI information for all functions

There are three cases where we don't currently have the visibility to
get the ABIs of runtime symbols right, which this CL fixes:

1. For Go functions referenced from non-Go code in other packages.
   This is runtime.morestackc (which is referenced from function
   prologues) and a few syscall symbols. For these we need to generate
   ABI0 wrappers, so this CL adds dummy calls in the assembly code to
   force wrapper generation. There are many other cross-package
   references to runtime and runtime/internal/atomic, but these are
   handled specially by cmd/go.

2. For calls generated by the compiler to runtime Go functions, there
   are a few symbols that aren't declared in builtins.go because we've
   never needed their type information before. Now we at least need
   their ABI information, so these are added to builtins.go.

3. For calls generated by the compiler to runtime assembly functions,
   the compiler is going to assume the internal ABI is available, so
   we add Go stubs to the runtime to trigger wrapper generation. For
   these we're probably going to want to provide internal ABI
   definitions directly in the assembly for performance, but for now
   the ABIs are the same so it doesn't matter.

For #27539.

Change-Id: I9c224e7408d2ef4dd9b0e4c9d7e962ddfe111245
Reviewed-on: https://go-review.googlesource.com/c/146822
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarKeith Randall <khr@golang.org>
Reviewed-by: 's avatarMichael Knyszek <mknyszek@google.com>
parent 6096b85b
......@@ -18,6 +18,3 @@ runtime/asm_386.s: [386] aeshashbody: function aeshashbody missing Go declaratio
runtime/asm_386.s: [386] addmoduledata: function addmoduledata missing Go declaration
runtime/duff_386.s: [386] duffzero: function duffzero missing Go declaration
runtime/duff_386.s: [386] duffcopy: function duffcopy missing Go declaration
runtime/asm_386.s: [386] uint32tofloat64: function uint32tofloat64 missing Go declaration
runtime/asm_386.s: [386] float64touint32: function float64touint32 missing Go declaration
......@@ -38,3 +38,11 @@ GLOBL runtime·memstats(SB), NOPTR, $0
// This function must be sizeofSkipFunction bytes.
TEXT runtime·skipPleaseUseCallersFrames(SB),NOSPLIT,$0-0
SKIP64; SKIP64; SKIP64; SKIP64
// abi0Syms is a dummy symbol that creates ABI0 wrappers for Go
// functions called from assembly in other packages.
TEXT abi0Syms<>(SB),NOSPLIT,$0-0
// obj assumes it can call morestack* using ABI0, but
// morestackc is actually defined in Go.
CALL ·morestackc(SB)
// References from syscall are automatically collected by cmd/go.
......@@ -317,3 +317,12 @@ int8 nacl_irt_thread_v0_1_str[] = "nacl-irt-thread-0.1";
void *nacl_irt_thread_v0_1[3]; // thread_create, thread_exit, thread_nice
int32 nacl_irt_thread_v0_1_size = sizeof(nacl_irt_thread_v0_1);
*/
// The following functions are implemented in runtime assembly.
// Provide a Go declaration to go with its assembly definitions.
//go:linkname syscall_naclWrite syscall.naclWrite
func syscall_naclWrite(fd int, b []byte) int
//go:linkname syscall_now syscall.now
func syscall_now() (sec int64, nsec int32)
......@@ -294,6 +294,10 @@ var racearenaend uintptr
func racefuncenter(uintptr)
func racefuncenterfp()
func racefuncexit()
func raceread(uintptr)
func racewrite(uintptr)
func racereadrange(addr, size uintptr)
func racewriterange(addr, size uintptr)
func racereadrangepc1(uintptr, uintptr, uintptr)
func racewriterangepc1(uintptr, uintptr, uintptr)
func racecallbackthunk(uintptr)
......
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package runtime
func float64touint32(a float64) uint32
func uint32tofloat64(a uint32) float64
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "textflag.h"
// abi0Syms is a dummy symbol that creates ABI0 wrappers for Go
// functions called from assembly in other packages.
TEXT abi0Syms<>(SB),NOSPLIT,$0-0
CALL ·getprocaddress(SB)
CALL ·loadlibrary(SB)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment