aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
AgeCommit message (Collapse)Author
2021-12-09Revert "[release-branch.go1.16] cmd/link: support more load commands on Mach-O"Alex Rakoczy
This reverts commit 98ef91b38e38289b8de07a77cad7a0c4208f0106. Reason for revert: Reducing risk for upcoming minor release. Change-Id: Ic18609383384ebbb49d144bcb17131077de390c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/370554 Run-TryBot: Alex Rakoczy <alex@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org> Trust: Alex Rakoczy <alex@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-02[release-branch.go1.16] cmd/link: support more load commands on Mach-OCherry Zhang
Fixes #49923. Change-Id: I74dd9170a51cc93ce3ec5e5860c2eb2912f081f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/312729 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> (cherry picked from commit b6ff3c69d5fdf933f5265f95ae4bb12eaecc792f) Reviewed-on: https://go-review.googlesource.com/c/go/+/368835 Run-TryBot: Heschi Kreinick <heschi@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Trust: Heschi Kreinick <heschi@google.com>
2021-12-02[release-branch.go1.16] cmd/compile: only update source type when processing ↵Cuong Manh Le
struct/array This is backport of CL 3651594, with the test from CL 360057. CL 360057 fixed missing update source type in storeArgOrLoad. However, we should only update the type when processing struct/array. If we update the type right before calling storeArgOrLoad, we may generate a value with invalid type, e.g, OpStructSelect with non-struct type. Fixes #49391 Change-Id: Ib7e10f72f818880f550aae5c9f653db463ce29b0 Reviewed-on: https://go-review.googlesource.com/c/go/+/361594 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/361597 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2021-11-22[release-branch.go1.16] cmd/go: forward the MallocNanoZone variable to ↵Bryan C. Mills
script tests For #49138 Updates #49723 Fixes #49728 Change-Id: Ia93130fdc042a1e2107be95cccd7e7eeaa909a87 Reviewed-on: https://go-review.googlesource.com/c/go/+/366254 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> (cherry picked from commit 189b4a2f428be7264db76e5275c96d98b847383b) Reviewed-on: https://go-review.googlesource.com/c/go/+/366258 TryBot-Result: Go Bot <gobot@golang.org>
2021-11-09[release-branch.go1.16] cmd/go: fix mod_get_directCuong Manh Le
https://github.com/googleapis/google-cloud-go has changed the default branch from master to main, causing mod_get_direct failed on longtest. Change-Id: I8fe0356b2ff532d1fdedbcb1e1832d7335babaa0 Reviewed-on: https://go-review.googlesource.com/c/go/+/361965 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> (cherry picked from commit b7529c3617a64ed5d1e2a6c7a9366d4a4988a38d) Reviewed-on: https://go-review.googlesource.com/c/go/+/362536 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-10-28[release-branch.go1.16] cmd/link: increase reserved space for passing env on ↵Richard Musiol
wasm On wasm, the wasm_exec.js helper passes the command line arguments and environment variables via a reserved space in the wasm linear memory. Increase this reserved space from 4096 to 8192 bytes so more environment variables can fit into the limit. Later, after https://golang.org/cl/350737 landed, we can switch to the WASI interface for getting the arguments and environment. This would remove the limit entirely. Updates #49011. Fixes #49153. Change-Id: I48a6e952a97d33404ed692c98e9b49c5cd6b269b Reviewed-on: https://go-review.googlesource.com/c/go/+/358194 Trust: Richard Musiol <neelance@gmail.com> Run-TryBot: Richard Musiol <neelance@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> (cherry picked from commit 252324e879e32f948d885f787decf8af06f82be9) Reviewed-on: https://go-review.googlesource.com/c/go/+/359400 Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
2021-10-27[release-branch.go1.16] cmd/compile: ensure constant shift amounts are in ↵Keith Randall
range for arm Ensure constant shift amounts are in the range [0-31]. When shift amounts are out of range, bad things happen. Shift amounts out of range occur when lowering 64-bit shifts (we take an in-range shift s in [0-63] and calculate s-32 and 32-s, both of which might be out of [0-31]). The constant shift operations themselves still work, but their shift amounts get copied unmolested to operations like ORshiftLL which use only the low 5 bits. That changes an operation like <<100 which unconditionally produces 0, to <<4, which doesn't. Fixes #48478 Change-Id: I87363ef2b4ceaf3b2e316426064626efdfbb8ee3 Reviewed-on: https://go-review.googlesource.com/c/go/+/350969 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> (cherry picked from commit eff27e858b771bf5e0b5e7e836827c7d2941e6d4) Reviewed-on: https://go-review.googlesource.com/c/go/+/351070 Reviewed-by: Austin Clements <austin@google.com>
2021-10-27[release-branch.go1.16] cmd/compile: fix simplification rules on arm/arm64Keith Randall
Fixes #48474 Change-Id: Ic1e918f916eae223a3b530a51a58f03031924670 Reviewed-on: https://go-review.googlesource.com/c/go/+/350913 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/351072 Reviewed-by: Austin Clements <austin@google.com>
2021-10-07[release-branch.go1.16] misc/wasm, cmd/link: do not let command line args ↵Michael Knyszek
overwrite global data On Wasm, wasm_exec.js puts command line arguments at the beginning of the linear memory (following the "zero page"). Currently there is no limit for this, and a very long command line can overwrite the program's data section. Prevent this by limiting the command line to 4096 bytes, and in the linker ensuring the data section starts at a high enough address (8192). (Arguably our address assignment on Wasm is a bit confusing. This is the minimum fix I can come up with.) Thanks to Ben Lubar for reporting this issue. Change by Cherry Mui <cherryyz@google.com>. For #48797 Fixes #48799 Fixes CVE-2021-38297 Change-Id: I0f50fbb2a5b6d0d047e3c134a88988d9133e4ab3 Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1205933 Reviewed-by: Roland Shoemaker <bracewell@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/354591 Trust: Michael Knyszek <mknyszek@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com>
2021-08-03[release-branch.go1.16] cmd/go: use path.Dir instead of filepath.Dir for ↵Yasuhiro Matsumoto
package paths in 'go mod vendor' copyMetadata walk-up to parent directory until the pkg become modPath. But pkg should be slash-separated paths. It have to use path.Dir instead of filepath.Dir. Updates #46867 Fixes #47015 Change-Id: I44cf1429fe52379a7415b94cc30ae3275cc430e8 Reviewed-on: https://go-review.googlesource.com/c/go/+/330149 Reviewed-by: Bryan C. Mills <bcmills@google.com> Trust: Bryan C. Mills <bcmills@google.com> Trust: Alexander Rakoczy <alex@golang.org> Trust: Carlos Amedee <carlos@golang.org> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> (cherry picked from commit 835d86a17ebf32a3cb081f66119c74363dbd8825) Reviewed-on: https://go-review.googlesource.com/c/go/+/332329 Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-08-02[release-branch.go1.16] cmd/go: remove hint when no module is suggestedConstantin Konstantinidis
Updates #46528 Fixes #46551 Change-Id: I2453d321ece878ea7823865758aa4a16b3ed7fe8 Reviewed-on: https://go-review.googlesource.com/c/go/+/325430 Reviewed-by: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> Trust: Heschi Kreinick <heschi@google.com> Trust: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Go Bot <gobot@golang.org> (cherry picked from commit e552a6d31270c86064632af1d092e0db5a930250) Reviewed-on: https://go-review.googlesource.com/c/go/+/334371 Trust: Bryan C. Mills <bcmills@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
2021-08-02[release-branch.go1.16] cmd/compile: mark R16, R17 clobbered for ↵Cherry Zhang
non-standard calls on ARM64 On ARM64, (external) linker generated trampoline may clobber R16 and R17. In CL 183842 we change Duff's devices not to use those registers. However, this is not enough. The register allocator also needs to know that these registers may be clobbered in any calls that don't follow the standard Go calling convention. This include Duff's devices and the write barrier. Fixes #46928. Updates #32773. Change-Id: Ia52a891d9bbb8515c927617dd53aee5af5bd9aa4 Reviewed-on: https://go-review.googlesource.com/c/go/+/184437 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Meng Zhuo <mzh@golangcn.org> Reviewed-by: Keith Randall <khr@golang.org> Trust: Meng Zhuo <mzh@golangcn.org> (cherry picked from commit 11b4aee05bfe83513cf08f83091e5aef8b33e766) Reviewed-on: https://go-review.googlesource.com/c/go/+/331029 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com>
2021-08-02[release-branch.go1.16] cmd/{compile,link}: fix bug in map.zero handlingThan McIntosh
In CL 326211 a change was made to switch "go.map.zero" symbols from non-pkg DUPOK symbols to hashed symbols. The intent of this change was ensure that in cases where there are multiple competing go.map.zero symbols feeding into a link, the largest map.zero symbol is selected. The change was buggy, however, and resulted in duplicate symbols in the final binary (see bug cited below for details). This duplication was relatively benign for linux/ELF, but causes duplicate definition errors on Windows. This patch switches "go.map.zero" symbols back from hashed symbols to non-pkg DUPOK symbols, and updates the relevant code in the loader to ensure that we do the right thing when there are multiple competing DUPOK symbols with different sizes. Fixes #47289. Change-Id: I8aeb910c65827f5380144d07646006ba553c9251 Reviewed-on: https://go-review.googlesource.com/c/go/+/334930 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> (cherry picked from commit 49402bee36fd3d5cee9f4b2d2e1e8560ead0203b) Reviewed-on: https://go-review.googlesource.com/c/go/+/335629
2021-08-02[release-branch.go1.16] cmd/go/internal/load: always set IsImportCycle when ↵Roland Shoemaker
in a cycle When hitting an import cycle in reusePackage, and there is already an error set, make sure IsImportCycle is set so that we don't end up stuck in a loop. Updates #25830 Fixes #47348 Change-Id: Iba966aea4a637dfc34ee22782a477209ac48c9bd Reviewed-on: https://go-review.googlesource.com/c/go/+/301289 Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> (cherry picked from commit cdd08e615a9b92742b21a94443720b6d70452510) Reviewed-on: https://go-review.googlesource.com/c/go/+/336649 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com>
2021-06-29[release-branch.go1.16] cmd/compile: make map.zero symbol content-addressableThan McIntosh
The compiler machinery that generates "map.zero" symbols marks them as RODATA and DUPOK, which is problematic when a given application has multiple map zero symbols (from different packages) with varying sizes: the dupok path in the loader assumes that if two symbols have the same name, it is safe to pick any of the versions. In the case of map.zero, the link needs to select the largest symbol, not an arbitrary sym. To fix this problem, mark map.zero symbols as content-addressable, since the loader's content addressability processing path already supports selection of the larger symbol in cases where there are dups. Fixes #46657. Change-Id: Iabd2feef01d448670ba795c7eaddc48c191ea276 Reviewed-on: https://go-review.googlesource.com/c/go/+/326211 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> (cherry picked from commit aa5540cd82170f82c6fe11511e12de96aa58cbc1) Reviewed-on: https://go-review.googlesource.com/c/go/+/326212 Run-TryBot: Cherry Mui <cherryyz@google.com>
2021-06-02[release-branch.go1.16] cmd/go: error out of 'go mod tidy' if the go version ↵Bryan C. Mills
is newer than supported This backports the test from CL 319669, but — because of extensive changes to the module loader during the Go 1.17 cycle — the implementation is entirely different. (This implementation is based on the addGoStmt function present in init.go in the 1.16 branch.) Fixes #46144 Updates #46142 Change-Id: Ib7a0a159e53cbe476be6aa9a050add10cc750dec Reviewed-on: https://go-review.googlesource.com/c/go/+/319671 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-06-02[release-branch.go1.16] cmd/go: use a real Go version in the go.mod files in ↵Bryan C. Mills
TestScript/mod_readonly For some reason, the go.mod file added to this test in CL 147281 lists 'go 1.20' instead of the version that was actually current when the go.mod file was added. That causes the test's behavior to change under lazy loading, because 1.20 is above the threshold to trigger lazy-loading invariants (1.17). This backports CL 314049 to Go 1.16 in order to fix a spurious test failure in a subsequent change. For #46144 Updates #46142 Updates #36460 Change-Id: I92400996cb051ab30e99bfffafd91ff32a1e7087 Reviewed-on: https://go-review.googlesource.com/c/go/+/314049 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-on: https://go-review.googlesource.com/c/go/+/319670 Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-06-02[release-branch.go1.16] cmd/go: in 'go mod download' without args, don't ↵Jay Conrod
save module zip sums 'go mod download' without arguments is frequently used to populate the module cache. It tends to fetch a lot of extra files (for modules in the build list that aren't needed to build packages in the main module). It's annoying when sums are written for these extra files. 'go mod download mod@version' will still write sums for specific modules in the build list. 'go mod download all' still has the previous behavior. For now, all invocations of 'go mod download' still update go.mod and go.sum with changes needed to load the build list (1.15 behavior). Fixes #46214 Change-Id: I9e17d18a7466ac7271a0e1a2b663f6b3cb168c97 Reviewed-on: https://go-review.googlesource.com/c/go/+/318629 Trust: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> (cherry picked from commit 4fb10b2118cb16445f2d089f79beb3d32db3db12) Reviewed-on: https://go-review.googlesource.com/c/go/+/321892 Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-06-02[release-branch.go1.16] cmd/link/internal: fix use of DynlinkingGo with ↵Lynn Boger
ppc64le trampolines When creating programs with large text sections on ppc64le, trampolines are needed for calls that are too far; however they are not created if the code is generated such that the TOC register r2 is initialized and maintained in the code because then the external linker can create the trampolines. Previously the function DynlinkingGo was used to determine this but in the case where plugins are used, this could return true even though r2 is not valid. To fix this problem I've added a new function r2Valid which returns true when the build options indicate that the r2 is initialized and maintained. Because of the ways that DynlinkingGo is used I wanted to maintain its previous behavior. Fixes #45927 Change-Id: I6d902eba6ad41757aa6474948b79acdbd479cb38 Reviewed-on: https://go-review.googlesource.com/c/go/+/315289 Trust: Lynn Boger <laboger@linux.vnet.ibm.com> Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> (cherry picked from commit 9ed736ac2a99aa2e7ef7d8bed3b01ca8b20a6f80) Reviewed-on: https://go-review.googlesource.com/c/go/+/316750 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-05-21[release-branch.go1.16] cmd/link: don't cast end address to int32Cherry Mui
When linking a very large binary, the section address may not fit in int32. Don't truncate it. Fixes #46128. Updates #46126. Change-Id: Ibcc8d74bf5662611949e547ce44ca8b973de383f Reviewed-on: https://go-review.googlesource.com/c/go/+/319289 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> (cherry picked from commit af0f8c149e8a4b237910fc7b41739bedc546473c) Reviewed-on: https://go-review.googlesource.com/c/go/+/319369
2021-05-20[release-branch.go1.16] cmd/link: disable plugin support if cgo is disabledPaul E. Murphy
Functional plugin support requires cgo to be enabled. Disable it if the environment has disabled cgo. This prevents unexpected linker failures when linking large binaries with cgo disabled which use the plugin package. Fixes #45832 Change-Id: Ib71f0e089f7373b7b3e3cd53da3612291e7bc473 Reviewed-on: https://go-review.googlesource.com/c/go/+/314449 Run-TryBot: Paul Murphy <murp@ibm.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Lynn Boger <laboger@linux.vnet.ibm.com> (cherry picked from commit 983dea90c169930e35721232afe39fd4e3fbe4a6) Reviewed-on: https://go-review.googlesource.com/c/go/+/316329 Reviewed-by: Cherry Mui <cherryyz@google.com> Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-05-04[release-branch.go1.16] cmd/compile: fix ANDI/SRWI merge on ppc64Paul E. Murphy
The shift amount should be masked to avoid rotation values beyond the numer of bits. In this case, if the shift amount is 0, it should rotate 0, not 32. Fixes #45636 Change-Id: I1e764497a39d0ec128e29af42352b70c70b2ecc5 Reviewed-on: https://go-review.googlesource.com/c/go/+/310569 Run-TryBot: Paul Murphy <murp@ibm.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org> Trust: Carlos Eduardo Seo <carlos.seo@linaro.org> (cherry picked from commit c8fb0ec5a005289e9dd890b746e543b38bbd9528) Reviewed-on: https://go-review.googlesource.com/c/go/+/311378 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-03-31[release-branch.go1.16] cmd/compile: fix long RMW bit operations on AMD64Pat Gavlin
Under certain circumstances, the existing rules for bit operations can produce code that writes beyond its intended bounds. For example, consider the following code: func repro(b []byte, addr, bit int32) { _ = b[3] v := uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 | 1<<(bit&31) b[0] = byte(v) b[1] = byte(v >> 8) b[2] = byte(v >> 16) b[3] = byte(v >> 24) } Roughly speaking: 1. The expression `1 << (bit & 31)` is rewritten into `(SHLL 1 bit)` 2. The expression `uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24` is rewritten into `(MOVLload &b[0])` 3. The statements `b[0] = byte(v) ... b[3] = byte(v >> 24)` are rewritten into `(MOVLstore &b[0], v)` 4. `(ORL (SHLL 1, bit) (MOVLload &b[0]))` is rewritten into `(BTSL (MOVLload &b[0]) bit)`. This is a valid transformation because the destination is a register: in this case, the bit offset is masked by the number of bits in the destination register. This is identical to the masking performed by `SHL`. 5. `(MOVLstore &b[0] (BTSL (MOVLload &b[0]) bit))` is rewritten into `(BTSLmodify &b[0] bit)`. This is an invalid transformation because the destination is memory: in this case, the bit offset is not masked, and the chosen instruction may write outside its intended 32-bit location. These changes fix the invalid rewrite performed in step (5) by explicitly maksing the bit offset operand to `BT(S|R|C)(L|Q)modify`. In the example above, the adjusted rules produce `(BTSLmodify &b[0] (ANDLconst [31] bit))` in step (5). These changes also add several new rules to rewrite bit sets, toggles, and clears that are rooted at `(OR|XOR|AND)(L|Q)modify` operators into appropriate `BT(S|R|C)(L|Q)modify` operators. These rules catch cases where `MOV(L|Q)store ((OR|XOR|AND)(L|Q) ...)` is rewritten to `(OR|XOR|AND)(L|Q)modify` before the `(OR|XOR|AND)(L|Q) ...` can be rewritten to `BT(S|R|C)(L|Q) ...`. Overall, compilecmp reports small improvements in code size on darwin/amd64 when the changes to the compiler itself are exlcuded: file before after Δ % runtime.s 536464 536412 -52 -0.010% bytes.s 32629 32593 -36 -0.110% strings.s 44565 44529 -36 -0.081% os/signal.s 7967 7959 -8 -0.100% cmd/vendor/golang.org/x/sys/unix.s 81686 81678 -8 -0.010% math/big.s 188235 188253 +18 +0.010% cmd/link/internal/loader.s 89295 89056 -239 -0.268% cmd/link/internal/ld.s 633551 633232 -319 -0.050% cmd/link/internal/arm.s 18934 18928 -6 -0.032% cmd/link/internal/arm64.s 31814 31801 -13 -0.041% cmd/link/internal/riscv64.s 7347 7345 -2 -0.027% cmd/compile/internal/ssa.s 4029173 4033066 +3893 +0.097% total 21298280 21301472 +3192 +0.015% Fixes #45253 Change-Id: I2e560548b515865129e1724e150e30540e9d29ce GitHub-Last-Rev: ab94ede1d097f920a9d1d3da403c8e4a3d8f6d44 GitHub-Pull-Request: golang/go#45242 Reviewed-on: https://go-review.googlesource.com/c/go/+/305069 Trust: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2021-03-31[release-branch.go1.16] cmd/compile: disable shortcircuit optimization for ↵Keith Randall
intertwined phi values We need to be careful that when doing value graph surgery, we not re-substitute a value that has already been substituted. That can lead to confusing a previous iteration's value with the current iteration's value. The simple fix in this CL just aborts the optimization if it detects intertwined phis (a phi which is the argument to another phi). It might be possible to keep the optimization with a more complicated CL, but: 1) This CL is clearly safe to backport. 2) There were no instances of this abort triggering in all.bash, prior to the test introduced in this CL. Fixes #45192 Change-Id: I2411dca03948653c053291f6829a76bec0c32330 Reviewed-on: https://go-review.googlesource.com/c/go/+/304251 Trust: Keith Randall <khr@golang.org> Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> (cherry picked from commit 771c57e68ed5ef2bbb0eafc0d48419f59d143932) Reviewed-on: https://go-review.googlesource.com/c/go/+/304530
2021-03-31[release-branch.go1.16] cmd/go: allow '+' in package import paths in module modeBryan C. Mills
This change upgrades x/mod to pull in the fix from CL 300152. Updates #44776. Fixes #44885. Change-Id: I273f41df2abfff76d91315b7f19fce851c8770d8 Reviewed-on: https://go-review.googlesource.com/c/go/+/300176 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> (cherry picked from commit d33e2192a71c33a604af247161ba1d2c1969e4c7) Reviewed-on: https://go-review.googlesource.com/c/go/+/300153
2021-03-25[release-branch.go1.16] cmd/link: generate trampoline for inter-dependent ↵Cherry Zhang
packages Currently, in the trampoline generation pass we expect packages are laid out in dependency order, so a cross-package jump always has a known target address so we can check if a trampoline is needed. With linknames, there can be cycles in the package dependency graph, making this algorithm no longer work. For them, as the target address is unkown we conservatively generate a trampoline. This may generate unnecessary trampolines (if the packages turn out laid together), but package cycles are extremely rare so this is fine. Updates #44639. Fixes #44640. Change-Id: I2dc2998edacbda27d726fc79452313a21d07787a Reviewed-on: https://go-review.googlesource.com/c/go/+/292490 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> (cherry picked from commit 098504c73ff6ece19566a1ac811ceed73be7c81d) Reviewed-on: https://go-review.googlesource.com/c/go/+/296909 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-03-25[release-branch.go1.16] cmd/compile, cmd/link: dynamically export writable ↵Cherry Zhang
static tmps Static tmps are private to a package, but with plugins a package can be shared among multiple DSOs. They need to have a consistent view of the static tmps, especially for writable ones. So export them. (Read-only static tmps have the same values anyway, so it doesn't matter. Also Mach-O doesn't support dynamically exporting read-only symbols anyway.) Updates #44956. Fixes #45030. Change-Id: I921e25b7ab73cd5d5347800eccdb7931e3448779 Reviewed-on: https://go-review.googlesource.com/c/go/+/301793 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> (cherry picked from commit de012bc095359e1b552d4ea6fb6b2995f3ab04f5) Reviewed-on: https://go-review.googlesource.com/c/go/+/302449
2021-03-25[release-branch.go1.16] cmd/go/internal/modfetch: detect and recover from ↵Jay Conrod
missing ziphash file Previously, if an extracted module directory existed in the module cache, but the corresponding ziphash file did not, if the sum was missing from go.sum, we would not verify the sum. This caused 'go get' not to write missing sums. 'go build' in readonly mode (now the default) checks for missing sums and doesn't attempt to fetch modules that can't be verified against go.sum. With this change, when requesting the module directory with modfetch.DownloadDir, if the ziphash file is missing, the go command will re-hash the zip without downloading or re-extracting it again. Note that the go command creates the ziphash file before the module directory, but another program could remove it separately, and it might not be present after a crash. Fixes #44812 Change-Id: I64551e048a3ba17d069de1ec123d5b8b2757543c Reviewed-on: https://go-review.googlesource.com/c/go/+/298352 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> (cherry picked from commit 302a400316319501748c0f034464fa70e7815272) Reviewed-on: https://go-review.googlesource.com/c/go/+/298851
2021-03-12[release-branch.go1.16] cmd/go: fix godoc formatting for text from 'go help ↵Jay Conrod
install' Fixes #44860 Change-Id: I5a12c6437a91ce59307483ffcc70e084edc32197 Reviewed-on: https://go-review.googlesource.com/c/go/+/301329 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Go Bot <gobot@golang.org> (cherry picked from commit 86bbf4beee276b9a7f9a427a9d1a9277bd904709) Reviewed-on: https://go-review.googlesource.com/c/go/+/301429
2021-03-10[release-branch.go1.16] cmd/go: clarify errors for commands run outside a moduleJay Conrod
The new error message tells the user what was wrong (no go.mod found) and directs them to 'go help modules', which links to tutorials. Includes test fix from CL 298794 Fixes #44746 Change-Id: I98f31fec4a8757eb1792b45491519da4c552cb0f Reviewed-on: https://go-review.googlesource.com/c/go/+/298650 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> (cherry picked from commit b87e9b9f68f1eb0d685fd250b3b47495710e0059) Reviewed-on: https://go-review.googlesource.com/c/go/+/298929
2021-03-10[release-branch.go1.16] cmd/go: don't report missing std import errors for ↵Jay Conrod
tidy and vendor 'go mod tidy' and 'go mod vendor' normally report errors when a package can't be imported, even if the import appears in a file that wouldn't be compiled by the current version of Go. These errors are common for packages introduced in higher versions of Go, like "embed" in 1.16. This change causes 'go mod tidy' and 'go mod vendor' to ignore missing package errors if the import path appears to come from the standard library because it lacks a dot in the first path element. Fixes #44793 Updates #27063 Change-Id: I61d6443e77ab95fd8c0d1514f57ef4c8885a77cc Reviewed-on: https://go-review.googlesource.com/c/go/+/298749 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> (cherry picked from commit 56d52e661114be60fb1893b034ac0c5976b622af) Reviewed-on: https://go-review.googlesource.com/c/go/+/298949
2021-03-03[release-branch.go1.16] cmd: upgrade golang.org/x/mod to relax import path checkJay Conrod
This incorporates CL 298009, which allows leading dots in import path elements but not module path elements. Also added a test. Fixes #44647 Updates #34992 Change-Id: I2d5faabd8f7b23a7943d3f3ccb6707ab5dc2ce3c Reviewed-on: https://go-review.googlesource.com/c/go/+/297530 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> (cherry picked from commit 97bdac03aee805cfa54e7762037a568d85339970) Reviewed-on: https://go-review.googlesource.com/c/go/+/297912 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-03-03[release-branch.go1.16] cmd/go/internal/modload: don't query when fixing ↵Jay Conrod
canonical versions If a canonical version is passed to fixVersion when loading the main go.mod and that version don't match the module path's major version suffix, don't call Query. Query doesn't return a useful error in this case when the path is malformed, for example, when it doens't have a dot in the first path element. It's better to report the major version mismatch error. Fixes #44496 Change-Id: I97b1f64aee894fa0db6fb637aa03a51357ee782c Reviewed-on: https://go-review.googlesource.com/c/go/+/296590 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> (cherry picked from commit 5fafc0bbd4819578e58e5b9163981b0074ab0b01) Reviewed-on: https://go-review.googlesource.com/c/go/+/297989 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-03-03[release-branch.go1.16] cmd: upgrade golang.org/x/mod to fix go.mod parserJay Conrod
modfile.Parse passed an empty string to the VersionFixer for the module path. This caused errors for v2+ versions. For #44496 Change-Id: I13b86b6ecf6815c4bc9a96ec0668284c9228c205 Reviewed-on: https://go-review.googlesource.com/c/go/+/296131 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> (cherry picked from commit bcac57f89c0ec609e6fbebcbcd42bb73fdaef2f0) Reviewed-on: https://go-review.googlesource.com/c/go/+/297990 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-03-01[release-branch.go1.16] cmd/go: add missing newline to retraction warning ↵Jordan Liggitt
message Updates #44674 Fixes #44676 Change-Id: Icbdb79084bf7bd2f52cc0a53abcc1ec6f0c4a1bf Reviewed-on: https://go-review.googlesource.com/c/go/+/297350 Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Jay Conrod <jayconrod@google.com> (cherry picked from commit 87beecd6dfd3b12ed30785ec502f7380dc79ec29) Reviewed-on: https://go-review.googlesource.com/c/go/+/297633 Trust: Bryan C. Mills <bcmills@google.com>
2021-03-01[release-branch.go1.16] cmd/link: handle types as converted to interface ↵Cherry Zhang
when dynlink When using plugins, a type (whose value) may be pass to a plugin and get converted to interface there, or vice versa. We need to treat the type as potentially converted to interface, and retain its methods. Updates #44586. Fixes #44638. Change-Id: I80dd35e68baedaa852a317543ccd78d94628d13b Reviewed-on: https://go-review.googlesource.com/c/go/+/296709 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> (cherry picked from commit a655208c9ecd2fee4de6deff35a863b1c28a091c) Reviewed-on: https://go-review.googlesource.com/c/go/+/296910
2021-03-01[release-branch.go1.16] cmd/compile: fix escape analysis of heap-allocated ↵Matthew Dempsky
results One of escape analysis's responsibilities is to summarize whether/how each function parameter flows to the heap so we can correctly incorporate those flows into callers' escape analysis data flow graphs. As an optimization, we separately record when parameters flow to result parameters, so that we can more precisely analyze parameter flows based on how the results are used at the call site. However, if a named result parameter itself needs to be heap allocated, this optimization isn't safe and the parameter needs to be recorded as flowing to heap rather than flowing to result. Escape analysis used to get this correct because it conservatively rewalked the data-flow graph multiple times. So even though it would incorrectly record the result parameter flow, it would separately find a flow to the heap. However, CL 196811 (specifically, case 3) optimized the walking logic to reduce unnecessary rewalks causing us to stop finding the extra heap flow. This CL fixes the issue by correcting location.leakTo to be sensitive to sink.escapes and not record result-flows when the result parameter escapes to the heap. Fixes #44659. Change-Id: I48742ed35a6cab591094e2d23a439e205bd65c50 Reviewed-on: https://go-review.googlesource.com/c/go/+/297289 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-on: https://go-review.googlesource.com/c/go/+/297290
2021-03-01[release-branch.go1.16] cmd/go: fix version validation in 'go mod edit -exclude'Bryan C. Mills
The fix is to pull in CL 295931 from the x/mod repo. Updates #44497 Fixes #44498 Change-Id: I008b58d0f4bb48c09d4f1e6ed31d11a714f87dc0 Reviewed-on: https://go-review.googlesource.com/c/go/+/295150 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> (cherry picked from commit 691ac806d20616fab66bb50752edfa9e4e9f8151) Reviewed-on: https://go-review.googlesource.com/c/go/+/295930
2021-03-01[release-branch.go1.16] cmd/compile: fix mishandling of unsafe-uintptr ↵Cuong Manh Le
arguments with call method in go/defer In CL 253457, we did the same fix for direct function calls. But for method calls, the receiver argument also need to be passed through the wrapper function, which we are not doing so the compiler crashes with the code in #44415. It will be nicer if we can rewrite OCALLMETHOD to normal OCALLFUNC, but that will be for future CL. The passing receiver argument to wrapper function is easier for backporting to go1.16 branch. Fixes #44464 Change-Id: I03607a64429042c6066ce673931db9769deb3124 Reviewed-on: https://go-review.googlesource.com/c/go/+/296490 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-on: https://go-review.googlesource.com/c/go/+/296769 Trust: Bryan C. Mills <bcmills@google.com>
2021-03-01[release-branch.go1.16] cmd/compile: fix panic in DWARF-gen handling ↵Than McIntosh
obfuscated code DWARF generation uses variable source positions (file/line/col) as a way to uniquely identify locals and parameters, as part of the process of matching up post-optimization variables with the corresponding pre-optimization versions (since the DWARF needs to be in terms of the original source constructs). This strategy can run into problems when compiling obfuscated or machine-generated code, where you can in some circumstances wind up with two local variables that appear to have the same name, file, line, and column. This patch changes DWARF generation to skip over such duplicates as opposed to issuing a fatal error (if an obfuscation tool is in use, it is unlikely that a human being will be able to make much sense of DWARF info in any case). Fixes #44433. Change-Id: I198022d184701aa9ec3dce42c005d29b72d2e321 Reviewed-on: https://go-review.googlesource.com/c/go/+/294289 TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> (cherry picked from commit e78e04ce39b9df316edda08f43f253f5e9ac509e) Reviewed-on: https://go-review.googlesource.com/c/go/+/294789
2021-03-01[release-branch.go1.16] cmd/compile: declare inlined result params early for ↵Matthew Dempsky
empty returns The code for delayed declaration of inlined result parameters only handles non-empty return statements. This is generally okay, because we already early declare if there are any (non-blank) named result parameters. But if a user writes a function with only blank result parameters and with exactly one return statement, which is empty, then they could end up hitting the dreaded "Value live at entry" ICE. This CL fixes the issue by ensuring we always early declare inlined result parameters if there are any empty return statements. Fixes #44358. Change-Id: I315f3853be436452883b1ce31da1bdffdf24d506 Reviewed-on: https://go-review.googlesource.com/c/go/+/293293 TryBot-Result: Go Bot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/296569
2021-02-16doc: remove all docs not tied to distributionRuss Cox
They have moved to x/website in CL 291693. The docs that are left are the ones that are edited at the same time as development in this repository and are tied to the specific version of Go being developed. Those are: - the language spec - the memory model - the assembler manual - the current release's release notes Change-Id: I437c4d33ada1b1716b1919c3c939c2cacf407e83 Reviewed-on: https://go-review.googlesource.com/c/go/+/291711 Trust: Russ Cox <rsc@golang.org> Trust: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-02-15cmd/go: provide a more helpful suggestion for "go vet -?"Rob Pike
For the command go vet -? the output was, usage: go vet [-n] [-x] [-vettool prog] [build flags] [vet flags] [packages] Run 'go help vet' for details. Run 'go tool vet -help' for the vet tool's flags. but "go help vet" is perfunctory at best. (That's another issue I'm working on—see https://go-review.googlesource.com/c/tools/+/291909— but vendoring is required to sort that out.) Add another line and rewrite a bit to make it actually helpful: usage: go vet [-n] [-x] [-vettool prog] [build flags] [vet flags] [packages] Run 'go help vet' for details. Run 'go tool vet help' for a full list of flags and analyzers. Run 'go tool vet -help' for an overview. Change-Id: I9d8580f0573321a57d55875ac3185988ce3eaf64 Reviewed-on: https://go-review.googlesource.com/c/go/+/291929 Trust: Rob Pike <r@golang.org> Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-13cmd/link: fix typo in link_test.goIkko Ashimine
specfic -> specific Change-Id: Icad0f70c77c866a1031a2929b90fef61fe92aaee GitHub-Last-Rev: f66b56491c0125f58c47f7f39410e0aeef2539be GitHub-Pull-Request: golang/go#44246 Reviewed-on: https://go-review.googlesource.com/c/go/+/291829 Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Matthew Dempsky <mdempsky@google.com>
2021-02-11cmd/go: multiple small 'go help' fixesJay Conrod
* Link to privacy policies for proxy.golang.org and sum.golang.org in 'go help modules'. It's important that both policies are linked from the go command's documentation. * Fix wording and typo in 'go help vcs' following comments in CL 290992, which adds reference documentation for GOVCS. * Fix whitespace on GOVCS in 'go help environment'. For #41730 Change-Id: I86abceacd4962b748361244026f219157c9285e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/291230 Trust: Jay Conrod <jayconrod@google.com> Run-TryBot: Jay Conrod <jayconrod@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-02-11cmd/go: reject embedded files that can't be packed into modulesRuss Cox
If the file won't be packed into a module, don't put those files into embeds. Otherwise people will be surprised when things work locally but not when imported by another module. Observed on CL 290709 Change-Id: Ia0ef7d0e0f5e42473c2b774e57c843e68a365bc7 Reviewed-on: https://go-review.googlesource.com/c/go/+/290809 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-02-10cmd/compile: mark concrete call of reflect.(*rtype).Method as REFLECTMETHODCherry Zhang
For functions that call reflect.Type.Method (or MethodByName), we mark it as REFLECTMETHOD, which tells the linker that methods can be retrieved via reflection and the linker keeps all exported methods live. Currently, this marking expects exactly the interface call reflect.Type.Method (or MethodByName). But now the compiler can devirtualize that call to a concrete call reflect.(*rtype).Method (or MethodByName), which is not handled and causing the linker to discard methods too aggressively. Handle the latter in this CL. Fixes #44207. Change-Id: Ia4060472dbff6ab6a83d2ca8e60a3e3f180ee832 Reviewed-on: https://go-review.googlesource.com/c/go/+/290950 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-02-09cmd/go: suppress errors from 'go get -d' for packages that only ↵Bryan C. Mills
conditionally exist Fixes #44106 Fixes #29268 Change-Id: Id113f2ced274d43fbf66cb804581448218996f81 Reviewed-on: https://go-review.googlesource.com/c/go/+/289769 TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com> Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com>
2021-02-02cmd/link: don't decode type symbol in shared library in deadcodeCherry Zhang
In the linker's deadcode pass we decode type symbols for interface satisfaction analysis. When linking against Go shared libraries, the type symbol may come from a shared library, so it doesn't have data in the current module being linked, so we cannot decode it. We already have code to skip DYNIMPORT symbols. However, this doesn't actually work, because at that point the type symbols' names haven't been mangled, whereas they may be mangled in the shared library. So the symbol definition (in shared library) and reference (in current module) haven't been connected. Skip decoding type symbols of type Sxxx (along with DYNIMPORT) when linkShared. Note: we cannot skip all type symbols, as we still need to mark unexported methods defined in the current module. Fixes #44031. Change-Id: I833d19a060c94edbd6fc448172358f9a7d760657 Reviewed-on: https://go-review.googlesource.com/c/go/+/288496 Trust: Cherry Zhang <cherryyz@google.com> Trust: Than McIntosh <thanm@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2021-02-02cmd/link: fix off-by-1 error in findShlibSectionCherry Zhang
We want to find a section that contains addr. sect.Addr+sect.Size is the exclusive upper bound. Change-Id: If2cd6bdd6e03174680e066189b0f4bf9e2ba6630 Reviewed-on: https://go-review.googlesource.com/c/go/+/288592 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>