aboutsummaryrefslogtreecommitdiff
path: root/misc
AgeCommit message (Collapse)Author
2022-02-14[dev.boringcrypto.go1.16] misc/boring: use go install cmd@latest for ↵Cherry Mui
installing command "go get cmd" is deprecated. Change-Id: I2242764c79b5e4c3ff94e5323d6504b596bdc9e2 Reviewed-on: https://go-review.googlesource.com/c/go/+/385197 Trust: Cherry Mui <cherryyz@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> (cherry picked from commit 8521d1ea346212bcdabe15b4e157b3a2f2ca95f4) Reviewed-on: https://go-review.googlesource.com/c/go/+/385235
2022-02-11[dev.boringcrypto.go1.16] all: merge go1.16.14 into dev.boringcrypto.go1.16Cherry Mui
Change-Id: I186a567b3e76df7ecf1842634a3851eab7c9dfce
2022-02-07[release-branch.go1.16] cmd/link: force eager binding when using plugins on ↵Cherry Mui
darwin When building/using plugins on darwin, we need to use flat namespace so the same symbol from the main executable and the plugin can be resolved to the same address. Apparently, when using flat namespace the dynamic linker can hang at forkExec when resolving a lazy binding. Work around it by forcing early bindings. Updates #38824. Fixes #50245. Change-Id: I983aa0a0960b15bf3f7871382e8231ee244655f4 Reviewed-on: https://go-review.googlesource.com/c/go/+/372798 Trust: Cherry Mui <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> (cherry picked from commit c5fee935bbb8f02406eb653cfed550593755a1a4) Reviewed-on: https://go-review.googlesource.com/c/go/+/373095
2022-01-14[dev.boringcrypto.go1.16] all: merge go1.16.13 into dev.boringcrypto.go1.16David Chase
Change-Id: I1233ad2811a546b008c75242ddd560fd2d121327
2022-01-05[release-branch.go1.16] cmd/link: use SHT_INIT_ARRAY for .init_array sectionIan Lance Taylor
For #50295 Fixes #50296 Change-Id: If55ebcd5f2af724da7c9c744458a56d21a7ddde7 Reviewed-on: https://go-review.googlesource.com/c/go/+/373734 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> (cherry picked from commit cfb0cc355233d4367b188b23a3bc143985a28b8c) Reviewed-on: https://go-review.googlesource.com/c/go/+/374234 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2021-11-04[dev.boringcrypto.go1.16] all: merge go1.16.10 into dev.boringcrypto.go1.16Than McIntosh
Change-Id: I164105d3036f0729da3f0b1dfa034f1d1d6a3a27
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-07[dev.boringcrypto.go1.16] all: merge go1.16.9 into dev.boringcrypto.go1.16Heschi Kreinick
Change-Id: Ic26e9802fe13c491fcc26f34b8847779ac43cfe2
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-04-21[dev.boringcrypto.go1.16] all: merge go1.16.3 into dev.boringcrypto.go1.16Filippo Valsorda
Change-Id: I037c70c43855beee7f2f817cf4304133dfe2ecfa
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-23[dev.boringcrypto.go1.16] all: merge go1.16.2 into dev.boringcrypto.go1.16Filippo Valsorda
Change-Id: I308f7bbaae4c3d4813fb727ff46e858abf93fb5d
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-02-23[dev.boringcrypto.go1.16] all: merge go1.16 into dev.boringcrypto.go1.16Filippo Valsorda
Change-Id: Ie2de5ffb14530857a728cca689475aa2a12941a4
2021-02-05[dev.boringcrypto] misc/boring: add new releases to RELEASES fileDmitri Shuralyov
Change-Id: I23ae197662c681cb91f17b28d0a259f56c2392d4 Reviewed-on: https://go-review.googlesource.com/c/go/+/290133 Trust: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org>
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-01-20[dev.boringcrypto] misc/boring: add new releases to RELEASES fileRoland Shoemaker
Change-Id: Iae94f521ded21e60db435806c7cb0eb13e3b2f2e Reviewed-on: https://go-review.googlesource.com/c/go/+/285072 Trust: Roland Shoemaker <roland@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org>
2021-01-20[dev.boringcrypto] misc/boring: add -trust and roland@ to merge.sh and ↵Filippo Valsorda
release.sh Change-Id: Ic52948d0a0f353760b186c83df8648650457e965 Reviewed-on: https://go-review.googlesource.com/c/go/+/285032 Trust: Filippo Valsorda <filippo@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org>
2020-12-30misc/cgo/testcarchive: remove special flags for Darwin/ARMCherry Zhang
The original Darwin/ARM port is gone. For ARM64, it works fine without the flags on macOS/ARM64. Remove the flags. Change-Id: I9cc00c49dd71376dd9c52abb78c2d8cec656b3db Reviewed-on: https://go-review.googlesource.com/c/go/+/280157 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-30misc/cgo/test: enable TestCrossPackageTests on darwin/arm64Cherry Zhang
Somehow I missed that one. It works fine. Change-Id: I0b1286bf1e6a8f40b9f3f114f49b3034079e0b85 Reviewed-on: https://go-review.googlesource.com/c/go/+/280156 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-29misc/ios: fix wording for command line instructionsDaniel Martí
A typo was made, which I noticed while looking through the recent master commits. Change-Id: Ieed5d6664a1f3ff5892d59abf194963b44ef0e55 Reviewed-on: https://go-review.googlesource.com/c/go/+/280454 Trust: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-29misc/ios: add to README how to build ios executablesCherry Zhang
Updates #43371, #43343. Change-Id: I19386269245f2c20345c6cac7560089b8223e9f9 Reviewed-on: https://go-review.googlesource.com/c/go/+/280153 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-12[dev.boringcrypto] misc/boring: add new releases to RELEASES fileFilippo Valsorda
Change-Id: I5059f2fa82db549c684b083202f1415511b86ce7 Reviewed-on: https://go-review.googlesource.com/c/go/+/277372 Reviewed-by: Roland Shoemaker <roland@golang.org> Trust: Filippo Valsorda <filippo@golang.org>
2020-12-03cmd/compile, runtime: use __msan_memmove for moving data, split msanread to ↵Cherry Zhang
fields Currently, for data moving, we generate an msanread of the source, followed by an msanwrite of the destination. msanread checks the source is initialized. This has a problem: if the source is an aggregate type containing alignment paddings, the padding bytes may not be thought as initialized by MSAN. If we copy the aggregate type by value, if it counts as a read, MSAN reports using uninitialized data. This CL changes it to use __msan_memmove for data copying, which tells MSAN to propagate initialized-ness but not check for it. Caveat: technically __msan_memmove is not a public API of MSAN, although the C compiler does generate direct calls to it. Also, when instrumenting a load of a struct, split the instrumentation to fields, instead of generating an msanread for the whole struct. This skips padding bytes, which may not be considered initialized in MSAN. Fixes #42820. Change-Id: Id861c8bbfd94cfcccefcc58eaf9e4eb43b4d85c6 Reviewed-on: https://go-review.googlesource.com/c/go/+/270859 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2020-11-18[dev.boringcrypto] all: merge master into dev.boringcryptoRoland Shoemaker
Change-Id: Iba19903f0565b11c648e1fa6effc07b8f97dc322
2020-11-18[dev.boringcrypto] crypto/hmac: merge up to 2a206c7 and skip testKatie Hockman
TestNonUniqueHash will not work on boringcrypto because the hash.Hash that sha256 provides is noncomparable. Change-Id: Ie3dc2d5d775953c381674e22272cb3433daa1b31
2020-11-17[dev.boringcrypto] all: merge master into dev.boringcryptoDmitri Shuralyov
Change-Id: I0596a40722bf62952bd2eba85ccf3f104de589e4
2020-11-16[dev.boringcrypto] misc/boring: add new releases to RELEASES fileFilippo Valsorda
Fixes #42589 Change-Id: Ieba62381d6561d4803448c123ce1f1d5980b8a76 Reviewed-on: https://go-review.googlesource.com/c/go/+/269762 Trust: Filippo Valsorda <filippo@golang.org> Reviewed-by: Katie Hockman <katie@golang.org>
2020-11-13cmd/compile: mark plugin-exported types as used in interfaceCherry Zhang
Plugin exports symbols as interfaces. Mark their types as used in interfaces, so their methods will be kept alive by the linker. Fixes #42579. Change-Id: If1b5aacc21510c20c25f88bb131bca61db6f1d56 Reviewed-on: https://go-review.googlesource.com/c/go/+/269819 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2020-11-13cmd/cgo: fix initialization of empty argument typesAustin Clements
CL 258938 changed the way C to Go calls work such that they now construct a C struct on the C side for the arguments and space for the results. Any pointers in the result space must be zeroed, so we just zero the whole struct. However, C makes it surprisingly hard to robustly zero any struct type. We had used a "{0}" initializer, which works in the vast majority of cases, but fails if the type is empty or effectively empty. This CL fixes this by changing how the cgo tool zero-initializes the argument struct to be more robust. Fixes #42495. Change-Id: Id1749b9d751e59eb7a02a9d44fec0698a2bf63cd Reviewed-on: https://go-review.googlesource.com/c/go/+/269337 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-11-12cmd/go, cmd/cgo: don't let bogus symbol set cgo_ldflagIan Lance Taylor
A hand-edited object file can have a symbol name that uses newline and other normally invalid characters. The cgo tool will generate Go files containing symbol names, unquoted. That can permit those symbol names to inject Go code into a cgo-generated file. If that Go code uses the //go:cgo_ldflag pragma, it can cause the C linker to run arbitrary code when building a package. If you build an imported package we permit arbitrary code at run time, but we don't want to permit it at package build time. This CL prevents this in two ways. In cgo, reject invalid symbols that contain non-printable or space characters, or that contain anything that looks like a Go comment. In the go tool, double check all //go:cgo_ldflag directives in generated code, to make sure they follow the existing LDFLAG restrictions. Thanks to Imre Rad / https://www.linkedin.com/in/imre-rad-2358749b for reporting this. Fixes CVE-2020-28367 Change-Id: Ia1ad8f3791ea79612690fa7d26ac451d0f6df7c1 Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/895832 Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/269658 Trust: Katie Hockman <katie@golang.org> Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org>
2020-11-11syscall: improve TestSetuidEtc() /proc/ parsing against racesAndrew G. Morgan
TestSetuidEtc() was failing sporadically on linux-ppc64. From the three https://build.golang.org/ logs, it looked like the logged errors could be associated with threads dying, but proc reads were, in some way, racing with their demise. Exploring ways to increase thread demise, revealed that races of this type can happen on non-ppc64 systems, and that os.IsNotExist(err) was not a sufficient error condition test for a thread's status file disappearing. This change includes a fix for that to. The actual issue on linux-ppc64 appears to be tied to PID reaping and reuse latency on whatever the build test environment is for linux-ppc64-buildlet. I suspect this can happen on any linux system, however, especially where the container has a limited PID range. The fix for this, limited to the test (the runtime syscall support is unchanged), is to confirm that the Pid for the interrogated thread's /proc/<TID>/status file confirms that it is still associated with the test-process' PID. linux-ppc64-buildlet: go/bin/go test syscall -run=TestSetuidEtc -count=10000 ok syscall 104.285s Fixes #42462 Change-Id: I55c84ab8361003570a405fa52ffec4949bf91113 Reviewed-on: https://go-review.googlesource.com/c/go/+/268717 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Tobias Klauser <tobias.klauser@gmail.com>
2020-11-05[dev.boringcrypto] crypto/internal/boring: update BoringCrypto module to ↵Filippo Valsorda
certificate 3678 Replace the chroot scaffolding with Docker, which brings its own caching and works on macOS. Fixes #40188 Change-Id: I5c96417932e952cbaf1e2991d131c1d5dd7d9921 Reviewed-on: https://go-review.googlesource.com/c/go/+/263997 Reviewed-by: Katie Hockman <katie@golang.org> Trust: Filippo Valsorda <filippo@golang.org>
2020-11-03cmd/dist,cmd/go,runtime: add support for cgo on linux/riscv64Joel Sing
Fixes #36641 Change-Id: I51868d83ce341d78d33b221d184c5a5110c60d14 Reviewed-on: https://go-review.googlesource.com/c/go/+/263598 Trust: Joel Sing <joel@sing.id.au> Run-TryBot: Joel Sing <joel@sing.id.au> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-11-02misc/wasm: check type of argument to Go.runRichard Musiol
This results in a nicer error message if the argument to Go.run is omitted or of the wrong type. Fixes #37000 Change-Id: I7f36d007f41a79b2cea1cebf5cce127786341202 Reviewed-on: https://go-review.googlesource.com/c/go/+/266117 Trust: Richard Musiol <neelance@gmail.com> Run-TryBot: Richard Musiol <neelance@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-11-02cmd/link: avoid exporting all symbols on windows buildmode=pieQuim Muntal
Marking one functions with __declspec(dllexport) forces mingw to create .reloc section without having to export all symbols. See https://insights.sei.cmu.edu/cert/2018/08/when-aslr-is-not-really-aslr---the-case-of-incorrect-assumptions-and-bad-defaults.html for more info. This change cuts 73kb of a "hello world" pie binary. Updates #6853 Fixes #40795 Change-Id: I3cc57c3b64f61187550bc8751dfa085f106c8475 Reviewed-on: https://go-review.googlesource.com/c/go/+/264459 Trust: Alex Brainman <alex.brainman@gmail.com> Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Austin Clements <austin@google.com>
2020-10-27misc/cgo/test: test C.enum_*HowJMay
Allocate a C enum object, and test if it can be assigned a value successfully. For #39537 Change-Id: I7b5482112486440b9d99f2ee4051328d87f45dca GitHub-Last-Rev: 81890f40acc5589563ec1206fe119873fb46dc1b GitHub-Pull-Request: golang/go#39977 Reviewed-on: https://go-review.googlesource.com/c/go/+/240697 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2020-10-26runtime,cmd/cgo: simplify C -> Go call pathAustin Clements
This redesigns the way calls work from C to exported Go functions. It removes several steps from the call path, makes cmd/cgo no longer sensitive to the Go calling convention, and eliminates the use of reflectcall from cgo. In order to avoid generating a large amount of FFI glue between the C and Go ABIs, the cgo tool has long depended on generating a C function that marshals the arguments into a struct, and then the actual ABI switch happens in functions with fixed signatures that simply take a pointer to this struct. In a way, this CL simply pushes this idea further. Currently, the cgo tool generates this argument struct in the exact layout of the Go stack frame and depends on reflectcall to unpack it into the appropriate Go call (even though it's actually reflectcall'ing a function generated by cgo). In this CL, we decouple this struct from the Go stack layout. Instead, cgo generates a Go function that takes the struct, unpacks it, and calls the exported function. Since this generated function has a generic signature (like the rest of the call path), we don't need reflectcall and can instead depend on the Go compiler itself to implement the call to the exported Go function. One complication is that syscall.NewCallback on Windows, which converts a Go function into a C function pointer, depends on cgocallback's current dynamic calling approach since the signatures of the callbacks aren't known statically. For this specific case, we continue to depend on reflectcall. Really, the current approach makes some overly simplistic assumptions about translating the C ABI to the Go ABI. Now we're at least in a much better position to do a proper ABI translation. For comparison, the current cgo call path looks like: GoF (generated C function) -> crosscall2 (in cgo/asm_*.s) -> _cgoexp_GoF (generated Go function) -> cgocallback (in asm_*.s) -> cgocallback_gofunc (in asm_*.s) -> cgocallbackg (in cgocall.go) -> cgocallbackg1 (in cgocall.go) -> reflectcall (in asm_*.s) -> _cgoexpwrap_GoF (generated Go function) -> p.GoF Now the call path looks like: GoF (generated C function) -> crosscall2 (in cgo/asm_*.s) -> cgocallback (in asm_*.s) -> cgocallbackg (in cgocall.go) -> cgocallbackg1 (in cgocall.go) -> _cgoexp_GoF (generated Go function) -> p.GoF Notably: 1. We combine _cgoexp_GoF and _cgoexpwrap_GoF and move the combined operation to the end of the sequence. This combined function also handles reflectcall's previous role. 2. We combined cgocallback and cgocallback_gofunc since the only purpose of having both was to convert a raw PC into a Go function value. We instead construct the Go function value in cgocallbackg1. 3. cgocallbackg1 no longer reaches backwards through the stack to get the arguments to cgocallback_gofunc. Instead, we just pass the arguments down. 4. Currently, we need an explicit msanwrite to mark the results struct as written because reflectcall doesn't do this. Now, the results are written by regular Go assignments, so the Go compiler generates the necessary MSAN annotations. This also means we no longer need to track the size of the arguments frame. Updates #40724, since now we don't need to teach cgo about the register ABI or change how it uses reflectcall. Change-Id: I7840489a2597962aeb670e0c1798a16a7359c94f Reviewed-on: https://go-review.googlesource.com/c/go/+/258938 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-10-23syscall: support POSIX semantics for Linux syscallsAndrew G. Morgan
This change adds two new methods for invoking system calls under Linux: syscall.AllThreadsSyscall() and syscall.AllThreadsSyscall6(). These system call wrappers ensure that all OSThreads mirror a common system call. The wrappers serialize execution of the runtime to ensure no race conditions where any Go code observes a non-atomic OS state change. As such, the syscalls have higher runtime overhead than regular system calls, and only need to be used where such thread (or 'm' in the parlance of the runtime sources) consistency is required. The new support is used to enable these functions under Linux: syscall.Setegid(), syscall.Seteuid(), syscall.Setgroups(), syscall.Setgid(), syscall.Setregid(), syscall.Setreuid(), syscall.Setresgid(), syscall.Setresuid() and syscall.Setuid(). They work identically to their glibc counterparts. Extensive discussion of the background issue addressed in this patch can be found here: https://github.com/golang/go/issues/1435 In the case where cgo is used, the C runtime can launch pthreads that are not managed by the Go runtime. As such, the added syscall.AllThreadsSyscall*() return ENOTSUP when cgo is enabled. However, for the 9 syscall.Set*() functions listed above, when cgo is active, these functions redirect to invoke their C.set*() equivalents in glibc, which wraps the raw system calls with a nptl:setxid fixup mechanism. This achieves POSIX semantics for these functions in the combined Go and C runtime. As a side note, the glibc/nptl:setxid support (2019-11-30) does not extend to all security related system calls under Linux so using native Go (CGO_ENABLED=0) and these AllThreadsSyscall*()s, where needed, will yield more well defined/consistent behavior over all threads of a Go program. That is, using the syscall.AllThreadsSyscall*() wrappers for things like setting state through SYS_PRCTL and SYS_CAPSET etc. Fixes #1435 Change-Id: Ib1a3e16b9180f64223196a32fc0f9dce14d9105c Reviewed-on: https://go-review.googlesource.com/c/go/+/210639 Trust: Emmanuel Odeke <emm.odeke@gmail.com> Trust: Ian Lance Taylor <iant@golang.org> Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Austin Clements <austin@google.com>
2020-10-22cmd/cgo: avoid exporting all symbols on windows buildmode=c-sharedQuim Muntal
Disable default symbol auto-export behaviour by marking exported function with the __declspec(dllexport) attribute. Old behaviour can still be used by setting -extldflags=-Wl,--export-all-symbols. See https://sourceware.org/binutils/docs/ld/WIN32.html for more info. This change cuts 50kb of a "hello world" dll. Updates #6853 Fixes #30674 Change-Id: I9c7fb09c677cc760f24d0f7d199740ae73981413 Reviewed-on: https://go-review.googlesource.com/c/go/+/262797 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Trust: Alex Brainman <alex.brainman@gmail.com>
2020-10-21misc/wasm: improve error message if javascript polyfills are requiredRichard Musiol
wasm_exec.js expects that either "require" is available or that the globals "crypto", "TextEncoder" and "TextDecoder" are already defined. Report a better error message if this is not the case, suggesting the use of a polyfill. Updates #41482 Change-Id: I5473cae15c98ae42e39f5928245b7762e7a5a8bf Reviewed-on: https://go-review.googlesource.com/c/go/+/261357 Trust: Richard Musiol <neelance@gmail.com> Run-TryBot: Richard Musiol <neelance@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-10-21misc/wasm: make sure sp is unsignedRichard Musiol
An i32 passed from WebAssembly to JavaScript is always read as a signed integer. Use the bitshift operator to turn it into an unsigned integer. Fixes #40923 Change-Id: Ia91ed2145dd2fc3071e2fc22b86ebfcb3c1e9f4f Reviewed-on: https://go-review.googlesource.com/c/go/+/261358 Trust: Richard Musiol <neelance@gmail.com> Run-TryBot: Richard Musiol <neelance@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-10-20cmd/link: support cgo internal/linking on darwin/arm64Cherry Zhang
Cgo programs work as well. Still not enabled by default for now. Enable internal linking tests. Updates #38485. Change-Id: I8324a5c263fba221eb4e67d71207ca84fa241e6c Reviewed-on: https://go-review.googlesource.com/c/go/+/263637 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>
2020-10-19[dev.boringcrypto] misc/boring: add new releases to RELEASES fileFilippo Valsorda
Change-Id: I468220e0389db2362f90134dc415a427f2b06003 Reviewed-on: https://go-review.googlesource.com/c/go/+/263101 Trust: Filippo Valsorda <filippo@golang.org> Reviewed-by: Katie Hockman <katie@golang.org>
2020-10-14cmd/link: support PIE internal linking on darwin/amd64Cherry Zhang
This CL adds support of PIE internal linking on darwin/amd64. This is also preparation for supporting internal linking on darwin/arm64 (macOS), which requires PIE for everything. Updates #38485. Change-Id: I2ed58583dcc102f5e0521982491fc7ba6f2754ed Reviewed-on: https://go-review.googlesource.com/c/go/+/261642 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2020-10-06all: enable more tests on macOS/ARM64Cherry Zhang
Updates #38485. Change-Id: Iac96f5ffe88521fcb11eab306d0df6463bdce046 Reviewed-on: https://go-review.googlesource.com/c/go/+/256920 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-06runtime: use sigaltstack on macOS/ARM64Cherry Zhang
Currently we don't use sigaltstack on darwin/arm64, as is not supported on iOS. However, it is supported on macOS. Use it. (iOS remains unchanged.) Change-Id: Icc154c5e2edf2dbdc8ca68741ad9157fc15a72ee Reviewed-on: https://go-review.googlesource.com/c/go/+/256917 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-05cmd/compile: export notinheap annotation to object fileKeith Randall
In the rare case when a cgo type makes it into an object file, we need the go:notinheap annotation to go with it. Fixes #41761 Change-Id: I541500cb1a03de954881aef659f96fc0b7738848 Reviewed-on: https://go-review.googlesource.com/c/go/+/259297 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-10-05misc/ios: fixup review comments from CL 255257Elias Naur
Change-Id: I247fc9e0e26e706e6af07367f953eaa1b7e544c1 Reviewed-on: https://go-review.googlesource.com/c/go/+/259577 Trust: Elias Naur <mail@eliasnaur.com> Run-TryBot: Elias Naur <mail@eliasnaur.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
2020-10-03misc/ios: add support for running programs on the iOS simulatorElias Naur
Update the README to mention the emulator. Remove reference to gomobile while here; there are multiple ways to develop for iOS today, including using the c-archive buildmode directly. Updates #38485 Change-Id: Iccef75e646ea8e1b9bc3fc37419cc2d6bf3dfdf4 Reviewed-on: https://go-review.googlesource.com/c/go/+/255257 Run-TryBot: Elias Naur <mail@eliasnaur.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Elias Naur <mail@eliasnaur.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>