Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #9 from jeffwidman/update-modules-to-go-1.16.3-code
Browse files Browse the repository at this point in the history
Update modules to go 1.16.3 code
  • Loading branch information
thepwagner authored May 3, 2021
2 parents 0d416eb + 45a865f commit 06c097c
Show file tree
Hide file tree
Showing 76 changed files with 6,610 additions and 2,395 deletions.
1 change: 1 addition & 0 deletions _internal_/cfg/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const KnownEnv = `
GOSUMDB
GOTMPDIR
GOTOOLDIR
GOVCS
GOWASM
GO_EXTLINK_ENABLED
PKG_CONFIG
Expand Down
70 changes: 70 additions & 0 deletions _internal_/execabs/execabs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright 2021 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 execabs is a drop-in replacement for os/exec
// that requires PATH lookups to find absolute paths.
// That is, execabs.Command("cmd") runs the same PATH lookup
// as exec.Command("cmd"), but if the result is a path
// which is relative, the Run and Start methods will report
// an error instead of running the executable.
package execabs

import (
"context"
"fmt"
"os/exec"
"path/filepath"
"reflect"
"unsafe"
)

var ErrNotFound = exec.ErrNotFound

type (
Cmd = exec.Cmd
Error = exec.Error
ExitError = exec.ExitError
)

func relError(file, path string) error {
return fmt.Errorf("%s resolves to executable relative to current directory (.%c%s)", file, filepath.Separator, path)
}

func LookPath(file string) (string, error) {
path, err := exec.LookPath(file)
if err != nil {
return "", err
}
if filepath.Base(file) == file && !filepath.IsAbs(path) {
return "", relError(file, path)
}
return path, nil
}

func fixCmd(name string, cmd *exec.Cmd) {
if filepath.Base(name) == name && !filepath.IsAbs(cmd.Path) {
// exec.Command was called with a bare binary name and
// exec.LookPath returned a path which is not absolute.
// Set cmd.lookPathErr and clear cmd.Path so that it
// cannot be run.
lookPathErr := (*error)(unsafe.Pointer(reflect.ValueOf(cmd).Elem().FieldByName("lookPathErr").Addr().Pointer()))
if *lookPathErr == nil {
*lookPathErr = relError(name, cmd.Path)
}
cmd.Path = ""
}
}

func CommandContext(ctx context.Context, name string, arg ...string) *exec.Cmd {
cmd := exec.CommandContext(ctx, name, arg...)
fixCmd(name, cmd)
return cmd

}

func Command(name string, arg ...string) *exec.Cmd {
cmd := exec.Command(name, arg...)
fixCmd(name, cmd)
return cmd
}
2 changes: 1 addition & 1 deletion _internal_/goroot/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
package goroot

import (
exec "github.com/dependabot/gomodules-extracted/_internal_/execabs"
"os"
"os/exec"
"path/filepath"
"strings"
"sync"
Expand Down
2 changes: 1 addition & 1 deletion cmd/_internal_/browser/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
package browser

import (
exec "github.com/dependabot/gomodules-extracted/_internal_/execabs"
"os"
"os/exec"
"runtime"
"time"
)
Expand Down
39 changes: 39 additions & 0 deletions cmd/_internal_/objabi/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package objabi

import (
"bytes"
"flag"
"fmt"
"io"
Expand Down Expand Up @@ -59,6 +60,9 @@ func expandArgs(in []string) (out []string) {
log.Fatal(err)
}
args := strings.Split(strings.TrimSpace(strings.Replace(string(slurp), "\r", "", -1)), "\n")
for i, arg := range args {
args[i] = DecodeArg(arg)
}
out = append(out, expandArgs(args)...)
} else if out != nil {
out = append(out, s)
Expand Down Expand Up @@ -160,3 +164,38 @@ func (f fn1) Set(s string) error {
}

func (f fn1) String() string { return "" }

// DecodeArg decodes an argument.
//
// This function is public for testing with the parallel encoder.
func DecodeArg(arg string) string {
// If no encoding, fastpath out.
if !strings.ContainsAny(arg, "\\\n") {
return arg
}

// We can't use strings.Builder as this must work at bootstrap.
var b bytes.Buffer
var wasBS bool
for _, r := range arg {
if wasBS {
switch r {
case '\\':
b.WriteByte('\\')
case 'n':
b.WriteByte('\n')
default:
// This shouldn't happen. The only backslashes that reach here
// should encode '\n' and '\\' exclusively.
panic("badly formatted input")
}
} else if r == '\\' {
wasBS = true
continue
} else {
b.WriteRune(r)
}
wasBS = false
}
return b.String()
}
15 changes: 4 additions & 11 deletions cmd/_internal_/objabi/funcdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ package objabi
// ../../../runtime/symtab.go.

const (
PCDATA_RegMapIndex = 0 // if !go115ReduceLiveness
PCDATA_UnsafePoint = 0 // if go115ReduceLiveness
PCDATA_UnsafePoint = 0
PCDATA_StackMapIndex = 1
PCDATA_InlTreeIndex = 2

FUNCDATA_ArgsPointerMaps = 0
FUNCDATA_LocalsPointerMaps = 1
FUNCDATA_RegPointerMaps = 2 // if !go115ReduceLiveness
FUNCDATA_StackObjects = 3
FUNCDATA_InlTree = 4
FUNCDATA_OpenCodedDeferInfo = 5
FUNCDATA_StackObjects = 2
FUNCDATA_InlTree = 3
FUNCDATA_OpenCodedDeferInfo = 4

// ArgsSizeUnknown is set in Func.argsize to mark all functions
// whose argument size is unknown (C vararg functions, and
Expand All @@ -32,11 +30,6 @@ const (

// Special PCDATA values.
const (
// PCDATA_RegMapIndex values.
//
// Only if !go115ReduceLiveness.
PCDATA_RegMapUnsafe = -2 // Unsafe for async preemption

// PCDATA_UnsafePoint values.
PCDATA_UnsafePointSafe = -1 // Safe for async preemption
PCDATA_UnsafePointUnsafe = -2 // Unsafe for async preemption
Expand Down
28 changes: 7 additions & 21 deletions cmd/_internal_/objabi/funcid.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

package objabi

import (
"strconv"
"strings"
)

// A FuncID identifies particular functions that need to be treated
// specially by the runtime.
// Note that in some situations involving plugins, there may be multiple
Expand All @@ -31,7 +26,7 @@ const (
FuncID_gcBgMarkWorker
FuncID_systemstack_switch
FuncID_systemstack
FuncID_cgocallback_gofunc
FuncID_cgocallback
FuncID_gogo
FuncID_externalthreadhandler
FuncID_debugCallV1
Expand All @@ -44,7 +39,10 @@ const (

// Get the function ID for the named function in the named file.
// The function should be package-qualified.
func GetFuncID(name, file string) FuncID {
func GetFuncID(name string, isWrapper bool) FuncID {
if isWrapper {
return FuncID_wrapper
}
switch name {
case "runtime.main":
return FuncID_runtime_main
Expand Down Expand Up @@ -72,8 +70,8 @@ func GetFuncID(name, file string) FuncID {
return FuncID_systemstack_switch
case "runtime.systemstack":
return FuncID_systemstack
case "runtime.cgocallback_gofunc":
return FuncID_cgocallback_gofunc
case "runtime.cgocallback":
return FuncID_cgocallback
case "runtime.gogo":
return FuncID_gogo
case "runtime.externalthreadhandler":
Expand All @@ -98,17 +96,5 @@ func GetFuncID(name, file string) FuncID {
// Don't show in the call stack (used when invoking defer functions)
return FuncID_wrapper
}
if file == "<autogenerated>" {
return FuncID_wrapper
}
if strings.HasPrefix(name, "runtime.call") {
if _, err := strconv.Atoi(name[12:]); err == nil {
// runtime.callXX reflect call wrappers.
return FuncID_wrapper
}
}
if strings.HasSuffix(name, "-fm") {
return FuncID_wrapper
}
return FuncID_normal
}
2 changes: 1 addition & 1 deletion cmd/_internal_/objabi/head.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (h *HeadType) Set(s string) error {
switch s {
case "aix":
*h = Haix
case "darwin":
case "darwin", "ios":
*h = Hdarwin
case "dragonfly":
*h = Hdragonfly
Expand Down
33 changes: 22 additions & 11 deletions cmd/_internal_/objabi/line.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,36 @@ func AbsFile(dir, file, rewrites string) string {
abs = filepath.Join(dir, file)
}

abs, rewritten := ApplyRewrites(abs, rewrites)
if !rewritten && hasPathPrefix(abs, GOROOT) {
abs = "$GOROOT" + abs[len(GOROOT):]
}

if abs == "" {
abs = "??"
}
return abs
}

// ApplyRewrites returns the filename for file in the given directory,
// as rewritten by the rewrites argument.
//
// The rewrites argument is a ;-separated list of rewrites.
// Each rewrite is of the form "prefix" or "prefix=>replace",
// where prefix must match a leading sequence of path elements
// and is either removed entirely or replaced by the replacement.
func ApplyRewrites(file, rewrites string) (string, bool) {
start := 0
for i := 0; i <= len(rewrites); i++ {
if i == len(rewrites) || rewrites[i] == ';' {
if new, ok := applyRewrite(abs, rewrites[start:i]); ok {
abs = new
goto Rewritten
if new, ok := applyRewrite(file, rewrites[start:i]); ok {
return new, true
}
start = i + 1
}
}
if hasPathPrefix(abs, GOROOT) {
abs = "$GOROOT" + abs[len(GOROOT):]
}

Rewritten:
if abs == "" {
abs = "??"
}
return abs
return file, false
}

// applyRewrite applies the rewrite to the path,
Expand Down
22 changes: 22 additions & 0 deletions cmd/_internal_/objabi/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,25 @@ func PathToPrefix(s string) string {

return string(p)
}

// IsRuntimePackagePath examines 'pkgpath' and returns TRUE if it
// belongs to the collection of "runtime-related" packages, including
// "runtime" itself, "reflect", "syscall", and the
// "runtime/internal/*" packages. The compiler and/or assembler in
// some cases need to be aware of when they are building such a
// package, for example to enable features such as ABI selectors in
// assembly sources.
func IsRuntimePackagePath(pkgpath string) bool {
rval := false
switch pkgpath {
case "runtime":
rval = true
case "reflect":
rval = true
case "syscall":
rval = true
default:
rval = strings.HasPrefix(pkgpath, "runtime/internal")
}
return rval
}
22 changes: 22 additions & 0 deletions cmd/_internal_/objabi/reloctype.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ const (
// should be linked into the final binary, even if there are no other
// direct references. (This is used for types reachable by reflection.)
R_USETYPE
// R_USEIFACE marks a type is converted to an interface in the function this
// relocation is applied to. The target is a type descriptor.
// This is a marker relocation (0-sized), for the linker's reachabililty
// analysis.
R_USEIFACE
// R_USEIFACEMETHOD marks an interface method that is used in the function
// this relocation is applied to. The target is an interface type descriptor.
// The addend is the offset of the method in the type descriptor.
// This is a marker relocation (0-sized), for the linker's reachabililty
// analysis.
R_USEIFACEMETHOD
// R_METHODOFF resolves to a 32-bit offset from the beginning of the section
// holding the data being relocated to the referenced symbol.
// It is a variant of R_ADDROFF used when linking from the uncommonType of a
Expand Down Expand Up @@ -145,6 +156,9 @@ const (
// R_ARM64_LDST8 sets a LD/ST immediate value to bits [11:0] of a local address.
R_ARM64_LDST8

// R_ARM64_LDST16 sets a LD/ST immediate value to bits [11:1] of a local address.
R_ARM64_LDST16

// R_ARM64_LDST32 sets a LD/ST immediate value to bits [11:2] of a local address.
R_ARM64_LDST32

Expand Down Expand Up @@ -212,6 +226,14 @@ const (
// AUIPC + S-type instruction pair.
R_RISCV_PCREL_STYPE

// R_RISCV_TLS_IE_ITYPE resolves a 32-bit TLS initial-exec TOC offset
// address using an AUIPC + I-type instruction pair.
R_RISCV_TLS_IE_ITYPE

// R_RISCV_TLS_IE_STYPE resolves a 32-bit TLS initial-exec TOC offset
// address using an AUIPC + S-type instruction pair.
R_RISCV_TLS_IE_STYPE

// R_PCRELDBL relocates s390x 2-byte aligned PC-relative addresses.
// TODO(mundaym): remove once variants can be serialized - see issue 14218.
R_PCRELDBL
Expand Down
Loading

0 comments on commit 06c097c

Please sign in to comment.