Skip to content

Commit

Permalink
[dev.boringcrypto] all: merge master (5b76343) into dev.boringcrypto
Browse files Browse the repository at this point in the history
Change-Id: I52c5b317a97c7723a7c077ae3cdfdc756fd3a1cf
  • Loading branch information
FiloSottile committed Feb 24, 2021
2 parents 0f210b7 + 5b76343 commit 03cd666
Show file tree
Hide file tree
Showing 778 changed files with 60,616 additions and 5,350 deletions.
4 changes: 2 additions & 2 deletions doc/go_spec.html
@@ -1,6 +1,6 @@
<!--{
"Title": "The Go Programming Language Specification",
"Subtitle": "Version of Feb 10, 2021",
"Subtitle": "Version of Feb 19, 2021",
"Path": "/ref/spec"
}-->

Expand Down Expand Up @@ -830,7 +830,7 @@ <h2 id="Types">Types</h2>

<h3 id="Method_sets">Method sets</h3>
<p>
A type may have a <i>method set</i> associated with it.
A type has a (possibly empty) <i>method set</i> associated with it.
The method set of an <a href="#Interface_types">interface type</a> is its interface.
The method set of any other type <code>T</code> consists of all
<a href="#Method_declarations">methods</a> declared with receiver type <code>T</code>.
Expand Down
2 changes: 1 addition & 1 deletion misc/cgo/test/callback.go
Expand Up @@ -182,7 +182,7 @@ func testCallbackCallers(t *testing.T) {
"runtime.cgocallbackg1",
"runtime.cgocallbackg",
"runtime.cgocallback",
"runtime.asmcgocall",
"runtime.systemstack_switch",
"runtime.cgocall",
"test._Cfunc_callback",
"test.nestedCall.func1",
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/asm/internal/asm/endtoend_test.go
Expand Up @@ -36,6 +36,7 @@ func testEndToEnd(t *testing.T, goarch, file string) {
var ok bool
testOut = new(bytes.Buffer) // The assembler writes test output to this buffer.
ctxt.Bso = bufio.NewWriter(os.Stdout)
ctxt.IsAsm = true
defer ctxt.Bso.Flush()
failed := false
ctxt.DiagFunc = func(format string, args ...interface{}) {
Expand Down Expand Up @@ -278,6 +279,7 @@ func testErrors(t *testing.T, goarch, file string) {
var ok bool
testOut = new(bytes.Buffer) // The assembler writes test output to this buffer.
ctxt.Bso = bufio.NewWriter(os.Stdout)
ctxt.IsAsm = true
defer ctxt.Bso.Flush()
failed := false
var errBuf bytes.Buffer
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/asm/internal/flags/flags.go
Expand Up @@ -32,11 +32,13 @@ var (
D MultiFlag
I MultiFlag
PrintOut int
DebugV bool
)

func init() {
flag.Var(&D, "D", "predefined symbol with optional simple value -D=identifier=value; can be set multiple times")
flag.Var(&I, "I", "include directory; can be set multiple times")
flag.BoolVar(&DebugV, "v", false, "print debug output")
objabi.AddVersionFlag() // -V
objabi.Flagcount("S", "print assembly and machine code", &PrintOut)
}
Expand Down
1 change: 1 addition & 0 deletions src/cmd/asm/main.go
Expand Up @@ -36,6 +36,7 @@ func main() {

ctxt := obj.Linknew(architecture.LinkArch)
ctxt.Debugasm = flags.PrintOut
ctxt.Debugvlog = flags.DebugV
ctxt.Flag_dynlink = *flags.Dynlink
ctxt.Flag_linkshared = *flags.Linkshared
ctxt.Flag_shared = *flags.Shared || *flags.Dynlink
Expand Down
1 change: 1 addition & 0 deletions src/cmd/compile/internal/base/flag.go
Expand Up @@ -54,6 +54,7 @@ type CmdFlags struct {
C CountFlag "help:\"disable printing of columns in error messages\""
D string "help:\"set relative `path` for local imports\""
E CountFlag "help:\"debug symbol export\""
G CountFlag "help:\"accept generic code\""
I func(string) "help:\"add `directory` to import search path\""
K CountFlag "help:\"debug missing line numbers\""
L CountFlag "help:\"show full file names in error messages\""
Expand Down
3 changes: 1 addition & 2 deletions src/cmd/compile/internal/dwarfgen/dwarf.go
Expand Up @@ -271,8 +271,7 @@ func createSimpleVar(fnsym *obj.LSym, n *ir.Name) *dwarf.Var {
if base.Ctxt.FixedFrameSize() == 0 {
offs -= int64(types.PtrSize)
}
if objabi.Framepointer_enabled || objabi.GOARCH == "arm64" {
// There is a word space for FP on ARM64 even if the frame pointer is disabled
if objabi.Framepointer_enabled {
offs -= int64(types.PtrSize)
}

Expand Down
4 changes: 3 additions & 1 deletion src/cmd/compile/internal/dwarfgen/scope.go
Expand Up @@ -37,7 +37,9 @@ func assembleScopes(fnsym *obj.LSym, fn *ir.Func, dwarfVars []*dwarf.Var, varSco
}

scopeVariables(dwarfVars, varScopes, dwarfScopes)
scopePCs(fnsym, fn.Marks, dwarfScopes)
if fnsym.Func().Text != nil {
scopePCs(fnsym, fn.Marks, dwarfScopes)
}
return compactScopes(dwarfScopes)
}

Expand Down
5 changes: 5 additions & 0 deletions src/cmd/compile/internal/gc/export.go
Expand Up @@ -25,6 +25,11 @@ func exportf(bout *bio.Writer, format string, args ...interface{}) {
func dumpexport(bout *bio.Writer) {
p := &exporter{marked: make(map[*types.Type]bool)}
for _, n := range typecheck.Target.Exports {
// Must catch it here rather than Export(), because the type can be
// not fully set (still TFORW) when Export() is called.
if n.Type() != nil && n.Type().HasTParam() {
base.Fatalf("Cannot (yet) export a generic type: %v", n)
}
p.markObject(n)
}

Expand Down
92 changes: 92 additions & 0 deletions src/cmd/compile/internal/importer/exportdata.go
@@ -0,0 +1,92 @@
// UNREVIEWED
// Copyright 2011 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.

// This file implements FindExportData.

package importer

import (
"bufio"
"fmt"
"io"
"strconv"
"strings"
)

func readGopackHeader(r *bufio.Reader) (name string, size int, err error) {
// See $GOROOT/include/ar.h.
hdr := make([]byte, 16+12+6+6+8+10+2)
_, err = io.ReadFull(r, hdr)
if err != nil {
return
}
// leave for debugging
if false {
fmt.Printf("header: %s", hdr)
}
s := strings.TrimSpace(string(hdr[16+12+6+6+8:][:10]))
size, err = strconv.Atoi(s)
if err != nil || hdr[len(hdr)-2] != '`' || hdr[len(hdr)-1] != '\n' {
err = fmt.Errorf("invalid archive header")
return
}
name = strings.TrimSpace(string(hdr[:16]))
return
}

// FindExportData positions the reader r at the beginning of the
// export data section of an underlying GC-created object/archive
// file by reading from it. The reader must be positioned at the
// start of the file before calling this function. The hdr result
// is the string before the export data, either "$$" or "$$B".
//
func FindExportData(r *bufio.Reader) (hdr string, err error) {
// Read first line to make sure this is an object file.
line, err := r.ReadSlice('\n')
if err != nil {
err = fmt.Errorf("can't find export data (%v)", err)
return
}

if string(line) == "!<arch>\n" {
// Archive file. Scan to __.PKGDEF.
var name string
if name, _, err = readGopackHeader(r); err != nil {
return
}

// First entry should be __.PKGDEF.
if name != "__.PKGDEF" {
err = fmt.Errorf("go archive is missing __.PKGDEF")
return
}

// Read first line of __.PKGDEF data, so that line
// is once again the first line of the input.
if line, err = r.ReadSlice('\n'); err != nil {
err = fmt.Errorf("can't find export data (%v)", err)
return
}
}

// Now at __.PKGDEF in archive or still at beginning of file.
// Either way, line should begin with "go object ".
if !strings.HasPrefix(string(line), "go object ") {
err = fmt.Errorf("not a Go object file")
return
}

// Skip over object header to export data.
// Begins after first line starting with $$.
for line[0] != '$' {
if line, err = r.ReadSlice('\n'); err != nil {
err = fmt.Errorf("can't find export data (%v)", err)
return
}
}
hdr = string(line)

return
}
175 changes: 175 additions & 0 deletions src/cmd/compile/internal/importer/gcimporter.go
@@ -0,0 +1,175 @@
// UNREVIEWED
// Copyright 2011 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 importer implements Import for gc-generated object files.
package importer

import (
"bufio"
"cmd/compile/internal/types2"
"fmt"
"go/build"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
)

// debugging/development support
const debug = false

var pkgExts = [...]string{".a", ".o"}

// FindPkg returns the filename and unique package id for an import
// path based on package information provided by build.Import (using
// the build.Default build.Context). A relative srcDir is interpreted
// relative to the current working directory.
// If no file was found, an empty filename is returned.
//
func FindPkg(path, srcDir string) (filename, id string) {
if path == "" {
return
}

var noext string
switch {
default:
// "x" -> "$GOPATH/pkg/$GOOS_$GOARCH/x.ext", "x"
// Don't require the source files to be present.
if abs, err := filepath.Abs(srcDir); err == nil { // see issue 14282
srcDir = abs
}
bp, _ := build.Import(path, srcDir, build.FindOnly|build.AllowBinary)
if bp.PkgObj == "" {
id = path // make sure we have an id to print in error message
return
}
noext = strings.TrimSuffix(bp.PkgObj, ".a")
id = bp.ImportPath

case build.IsLocalImport(path):
// "./x" -> "/this/directory/x.ext", "/this/directory/x"
noext = filepath.Join(srcDir, path)
id = noext

case filepath.IsAbs(path):
// for completeness only - go/build.Import
// does not support absolute imports
// "/x" -> "/x.ext", "/x"
noext = path
id = path
}

if false { // for debugging
if path != id {
fmt.Printf("%s -> %s\n", path, id)
}
}

// try extensions
for _, ext := range pkgExts {
filename = noext + ext
if f, err := os.Stat(filename); err == nil && !f.IsDir() {
return
}
}

filename = "" // not found
return
}

// Import imports a gc-generated package given its import path and srcDir, adds
// the corresponding package object to the packages map, and returns the object.
// The packages map must contain all packages already imported.
//
func Import(packages map[string]*types2.Package, path, srcDir string, lookup func(path string) (io.ReadCloser, error)) (pkg *types2.Package, err error) {
var rc io.ReadCloser
var id string
if lookup != nil {
// With custom lookup specified, assume that caller has
// converted path to a canonical import path for use in the map.
if path == "unsafe" {
return types2.Unsafe, nil
}
id = path

// No need to re-import if the package was imported completely before.
if pkg = packages[id]; pkg != nil && pkg.Complete() {
return
}
f, err := lookup(path)
if err != nil {
return nil, err
}
rc = f
} else {
var filename string
filename, id = FindPkg(path, srcDir)
if filename == "" {
if path == "unsafe" {
return types2.Unsafe, nil
}
return nil, fmt.Errorf("can't find import: %q", id)
}

// no need to re-import if the package was imported completely before
if pkg = packages[id]; pkg != nil && pkg.Complete() {
return
}

// open file
f, err := os.Open(filename)
if err != nil {
return nil, err
}
defer func() {
if err != nil {
// add file name to error
err = fmt.Errorf("%s: %v", filename, err)
}
}()
rc = f
}
defer rc.Close()

var hdr string
buf := bufio.NewReader(rc)
if hdr, err = FindExportData(buf); err != nil {
return
}

switch hdr {
case "$$\n":
err = fmt.Errorf("import %q: old textual export format no longer supported (recompile library)", path)

case "$$B\n":
var data []byte
data, err = ioutil.ReadAll(buf)
if err != nil {
break
}

// The indexed export format starts with an 'i'; the older
// binary export format starts with a 'c', 'd', or 'v'
// (from "version"). Select appropriate importer.
if len(data) > 0 && data[0] == 'i' {
_, pkg, err = iImportData(packages, data[1:], id)
} else {
err = fmt.Errorf("import %q: old binary export format no longer supported (recompile library)", path)
}

default:
err = fmt.Errorf("import %q: unknown export data header: %q", path, hdr)
}

return
}

type byPath []*types2.Package

func (a byPath) Len() int { return len(a) }
func (a byPath) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a byPath) Less(i, j int) bool { return a[i].Path() < a[j].Path() }

0 comments on commit 03cd666

Please sign in to comment.