aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitri Shuralyov <dmitshur@golang.org>2020-02-21 15:16:40 -0500
committerDmitri Shuralyov <dmitshur@golang.org>2020-02-21 15:24:10 -0500
commitf5293d77a93e3de16f35081dec35474c169714ae (patch)
tree1dd5d5ccc671263afc65153f9370dd77d6812c05
parent51534757da2956ce9570f7c767b1fa818e3077f4 (diff)
parent1cd724acb6304d30d8998d14a5469fbab24dd3b1 (diff)
downloadgo-f5293d77a93e3de16f35081dec35474c169714ae.tar.gz
go-f5293d77a93e3de16f35081dec35474c169714ae.zip
[release-branch.go1.14] all: merge master into release-branch.go1.14
1cd724acb6 doc/go1.14: highlight the addition of hash/maphash package a0cf2c872f doc/go1.14: remove TODO comment for CL 200439 a9ea91d571 cmd/link, runtime: skip holes in func table 88e564edb1 doc/go1.14: add missing period at sentence end 6917529cc6 testing: remove obsolete comment in testing.(*T) docs Change-Id: Ifb581c251474e9445d65a4f34dd4dcbc469fdd79
-rw-r--r--doc/go1.14.html38
-rw-r--r--src/cmd/link/internal/ld/pcln.go22
-rw-r--r--src/runtime/symtab.go10
-rw-r--r--src/testing/testing.go1
4 files changed, 47 insertions, 24 deletions
diff --git a/doc/go1.14.html b/doc/go1.14.html
index d5ad07754a..f83b365704 100644
--- a/doc/go1.14.html
+++ b/doc/go1.14.html
@@ -343,8 +343,6 @@ appropriately.)
visible changes.
</p>
-<!-- TODO: Maybe CL 200439? -->
-
<h2 id="compiler">Compiler</h2>
<p><!-- CL 162237 -->
@@ -378,7 +376,7 @@ appropriately.)
<p><!-- CL 204338 -->
The compiler can now emit machine-readable logs of key optimizations
using the <code>-json</code> flag, including inlining, escape
- analysis, bounds-check elimination, and nil-check elimination
+ analysis, bounds-check elimination, and nil-check elimination.
</p>
<p><!-- CL 196959 -->
@@ -407,8 +405,22 @@ appropriately.)
<h2 id="library">Core library</h2>
+<h3 id="hash/maphash">New byte sequence hashing package</h3>
+
+<p> <!-- golang.org/issue/28322, CL 186877 -->
+ Go 1.14 includes a new package,
+ <a href="/pkg/hash/maphash/"><code>hash/maphash</code></a>,
+ which provides hash functions on byte sequences.
+ These hash functions are intended to be used to implement hash tables or
+ other data structures that need to map arbitrary strings or byte
+ sequences to a uniform distribution on unsigned 64-bit integers.
+</p>
<p>
- All of the changes to the standard library are minor.
+ The hash functions are collision-resistant but not cryptographically secure.
+</p>
+<p>
+ The hash value of a given byte sequence is consistent within a
+ single process, but will be different in different processes.
</p>
<h3 id="minor_library_changes">Minor changes to the library</h3>
@@ -605,24 +617,6 @@ appropriately.)
</dd>
</dl><!-- go/doc -->
-<dl id="hash/maphash"><dt><a href="/pkg/hash/maphash/">hash/maphash</a></dt>
- <dd>
- <p><!-- CL 186877 -->
- This new package provides hash functions on byte sequences.
- These hash functions are intended to be used to implement hash tables or
- other data structures that need to map arbitrary strings or byte
- sequences to a uniform distribution of integers.
- </p>
- <p>
- The hash functions are collision-resistant but not cryptographically secure.
- </p>
- <p>
- The hash value of a given byte sequence is consistent within a
- single process, but will be different in different processes.
- </p>
- </dd>
-</dl><!-- hash/maphash -->
-
<dl id="io/ioutil"><dt><a href="/pkg/io/ioutil/">io/ioutil</a></dt>
<dd>
<p><!-- CL 198488 -->
diff --git a/src/cmd/link/internal/ld/pcln.go b/src/cmd/link/internal/ld/pcln.go
index db44c0292e..3e8135c959 100644
--- a/src/cmd/link/internal/ld/pcln.go
+++ b/src/cmd/link/internal/ld/pcln.go
@@ -138,6 +138,7 @@ func (ctxt *Link) pclntab() {
// Gather some basic stats and info.
var nfunc int32
+ prevSect := ctxt.Textp[0].Sect
for _, s := range ctxt.Textp {
if !emitPcln(ctxt, s) {
continue
@@ -146,6 +147,14 @@ func (ctxt *Link) pclntab() {
if pclntabFirstFunc == nil {
pclntabFirstFunc = s
}
+ if s.Sect != prevSect {
+ // With multiple text sections, the external linker may insert functions
+ // between the sections, which are not known by Go. This leaves holes in
+ // the PC range covered by the func table. We need to generate an entry
+ // to mark the hole.
+ nfunc++
+ prevSect = s.Sect
+ }
}
pclntabNfunc = nfunc
@@ -181,10 +190,23 @@ func (ctxt *Link) pclntab() {
}
nfunc = 0 // repurpose nfunc as a running index
+ prevFunc := ctxt.Textp[0]
for _, s := range ctxt.Textp {
if !emitPcln(ctxt, s) {
continue
}
+
+ if s.Sect != prevFunc.Sect {
+ // With multiple text sections, there may be a hole here in the address
+ // space (see the comment above). We use an invalid funcoff value to
+ // mark the hole.
+ // See also runtime/symtab.go:findfunc
+ ftab.SetAddrPlus(ctxt.Arch, 8+int64(ctxt.Arch.PtrSize)+int64(nfunc)*2*int64(ctxt.Arch.PtrSize), prevFunc, prevFunc.Size)
+ ftab.SetUint(ctxt.Arch, 8+int64(ctxt.Arch.PtrSize)+int64(nfunc)*2*int64(ctxt.Arch.PtrSize)+int64(ctxt.Arch.PtrSize), ^uint64(0))
+ nfunc++
+ }
+ prevFunc = s
+
pcln := s.FuncInfo
if pcln == nil {
pcln = &pclntabZpcln
diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go
index ddcf231929..a6e08d7214 100644
--- a/src/runtime/symtab.go
+++ b/src/runtime/symtab.go
@@ -614,7 +614,15 @@ func findfunc(pc uintptr) funcInfo {
idx++
}
}
- return funcInfo{(*_func)(unsafe.Pointer(&datap.pclntable[datap.ftab[idx].funcoff])), datap}
+ funcoff := datap.ftab[idx].funcoff
+ if funcoff == ^uintptr(0) {
+ // With multiple text sections, there may be functions inserted by the external
+ // linker that are not known by Go. This means there may be holes in the PC
+ // range covered by the func table. The invalid funcoff value indicates a hole.
+ // See also cmd/link/internal/ld/pcln.go:pclntab
+ return funcInfo{}
+ }
+ return funcInfo{(*_func)(unsafe.Pointer(&datap.pclntable[funcoff])), datap}
}
type pcvalueCache struct {
diff --git a/src/testing/testing.go b/src/testing/testing.go
index 030feb7112..8a0c7b3021 100644
--- a/src/testing/testing.go
+++ b/src/testing/testing.go
@@ -571,7 +571,6 @@ var _ TB = (*T)(nil)
var _ TB = (*B)(nil)
// T is a type passed to Test functions to manage test state and support formatted test logs.
-// Logs are accumulated during execution and dumped to standard output when done.
//
// A test ends when its Test function returns or calls any of the methods
// FailNow, Fatal, Fatalf, SkipNow, Skip, or Skipf. Those methods, as well as