Compare commits

..

127 Commits

Author SHA1 Message Date
Gopher Robot
8e10ef451a [release-branch.go1.24] go1.24.9
Change-Id: I6deccf317a5f19ca9ee2a2eaddf65203ecfeb665
Reviewed-on: https://go-review.googlesource.com/c/go/+/711461
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Bypass: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-10-13 14:14:38 -07:00
Roland Shoemaker
ca6a5545ba [release-branch.go1.24] crypto/x509: rework fix for CVE-2025-58187
In CL 709854 we enabled strict validation for a number of properties of
domain names (and their constraints). This caused significant breakage,
since we didn't previously disallow the creation of certificates which
contained these malformed domains.

Rollback a number of the properties we enforced, making domainNameValid
only enforce the same properties that domainToReverseLabels does. Since
this also undoes some of the DoS protections our initial fix enabled,
this change also adds caching of constraints in isValid (which perhaps
is the fix we should've initially chosen).

Updates #75835
Updates #75828
Fixes #75860

Change-Id: Ie6ca6b4f30e9b8a143692b64757f7bbf4671ed0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/710735
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
(cherry picked from commit 1cd71689f2)
Reviewed-on: https://go-review.googlesource.com/c/go/+/710879
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2025-10-13 08:39:27 -07:00
Gopher Robot
3a666bca00 [release-branch.go1.24] go1.24.8
Change-Id: Ib7865e22255a979da9552ffd35145bb9dd39b53f
Reviewed-on: https://go-review.googlesource.com/c/go/+/709896
TryBot-Bypass: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-10-07 11:17:23 -07:00
Damien Neil
613e746327 [release-branch.go1.24] archive/tar: set a limit on the size of GNU sparse file 1.0 regions
Sparse files in tar archives contain only the non-zero components
of the file. There are several different encodings for sparse
files. When reading GNU tar pax 1.0 sparse files, archive/tar did
not set a limit on the size of the sparse region data. A malicious
archive containing a large number of sparse blocks could cause
archive/tar to read an unbounded amount of data from the archive
into memory.

Since a malicious input can be highly compressable, a small
compressed input could cause very large allocations.

Cap the size of the sparse block data to the same limit used
for PAX headers (1 MiB).

Thanks to Harshit Gupta (Mr HAX) (https://www.linkedin.com/in/iam-harshit-gupta/)
for reporting this issue.

Fixes CVE-2025-58183
For #75677
Fixes #75710

Change-Id: I70b907b584a7b8676df8a149a1db728ae681a770
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2800
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2967
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/709843
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Bypass: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2025-10-07 11:01:00 -07:00
Roland Shoemaker
74d4d836b9 [release-branch.go1.24] encoding/pem: make Decode complexity linear
Because Decode scanned the input first for the first BEGIN line, and
then the first END line, the complexity of Decode is quadratic. If the
input contained a large number of BEGINs and then a single END right at
the end of the input, we would find the first BEGIN, and then scan the
entire input for the END, and fail to parse the block, so move onto the
next BEGIN, scan the entire input for the END, etc.

Instead, look for the first END in the input, and then the first BEGIN
that precedes the found END. We then process the bytes between the BEGIN
and END, and move onto the bytes after the END for further processing.
This gives us linear complexity.

Fixes CVE-2025-61723
For #75676
Fixes #75708

Change-Id: I813c4f63e78bca4054226c53e13865c781564ccf
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2921
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2986
Reviewed-on: https://go-review.googlesource.com/c/go/+/709842
TryBot-Bypass: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-10-07 11:00:57 -07:00
Nicholas Husin
5c3d61c886 [release-branch.go1.24] encoding/asn1: prevent memory exhaustion when parsing using internal/saferio
Within parseSequenceOf, reflect.MakeSlice is being used to pre-allocate
a slice that is needed in order to fully validate the given DER payload.
The size of the slice allocated are also multiple times larger than the
input DER:

- When using asn1.Unmarshal directly, the allocated slice is ~28x
  larger.
- When passing in DER using x509.ParseCertificateRequest, the allocated
  slice is ~48x larger.
- When passing in DER using ocsp.ParseResponse, the allocated slice is
  ~137x larger.

As a result, a malicious actor can craft a big empty DER payload,
resulting in an unnecessary large allocation of memories. This can be a
way to cause memory exhaustion.

To prevent this, we now use SliceCapWithSize within internal/saferio to
enforce a memory allocation cap.

Thanks to Jakub Ciolek for reporting this issue.

For #75671
Fixes #75704
Fixes CVE-2025-58185

Change-Id: Id50e76187eda43f594be75e516b9ca1d2ae6f428
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2700
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2984
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/709841
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Bypass: Michael Pratt <mpratt@google.com>
2025-10-07 11:00:54 -07:00
Nicholas Husin
c6b04dd33b [release-branch.go1.24] net/http: add httpcookiemaxnum GODEBUG option to limit number of cookies parsed
When handling HTTP headers, net/http does not currently limit the number
of cookies that can be parsed. The only limitation that exists is for
the size of the entire HTTP header, which is controlled by
MaxHeaderBytes (defaults to 1 MB).

Unfortunately, this allows a malicious actor to send HTTP headers which
contain a massive amount of small cookies, such that as much cookies as
possible can be fitted within the MaxHeaderBytes limitation. Internally,
this causes us to allocate a massive number of Cookie struct.

For example, a 1 MB HTTP header with cookies that repeats "a=;" will
cause an allocation of ~66 MB in the heap. This can serve as a way for
malicious actors to induce memory exhaustion.

To fix this, we will now limit the number of cookies we are willing to
parse to 3000 by default. This behavior can be changed by setting a new
GODEBUG option: GODEBUG=httpcookiemaxnum. httpcookiemaxnum can be set to
allow a higher or lower cookie limit. Setting it to 0 will also allow an
infinite number of cookies to be parsed.

Thanks to jub0bs for reporting this issue.

For #75672
Fixes #75706
Fixes CVE-2025-58186

Change-Id: Ied58b3bc8acf5d11c880f881f36ecbf1d5d52622
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2720
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2983
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/709840
TryBot-Bypass: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-10-07 11:00:50 -07:00
Neal Patel
f334417e71 [release-branch.go1.24] crypto/x509: improve domain name verification
Don't use domainToReverseLabels to check if domain names are valid,
since it is not particularly performant, and can contribute to DoS
vectors. Instead just iterate over the name and enforce the properties
we care about.

This also enforces that DNS names, both in SANs and name constraints,
are valid. We previously allowed invalid SANs, because some
intermediates had these weird names (see #23995), but there are
currently no trusted intermediates that have this property, and since we
target the web PKI, supporting this particular case is not a high
priority.

Thank you to Jakub Ciolek for reporting this issue.

Fixes CVE-2025-58187
For #75681
Fixes #75714

Change-Id: I6ebce847dcbe5fc63ef2f9a74f53f11c4c56d3d1
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2820
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2982
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/709839
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Bypass: Michael Pratt <mpratt@google.com>
2025-10-07 11:00:47 -07:00
Ethan Lee
d6d2f7bf76 [release-branch.go1.24] net/url: enforce stricter parsing of bracketed IPv6 hostnames
- Previously, url.Parse did not enforce validation of hostnames within
  square brackets.
- RFC 3986 stipulates that only IPv6 hostnames can be embedded within
  square brackets in a URL.
- Now, the parsing logic should strictly enforce that only IPv6
  hostnames can be resolved when in square brackets. IPv4, IPv4-mapped
  addresses and other input will be rejected.
- Update url_test to add test cases that cover the above scenarios.

Thanks to Enze Wang, Jingcheng Yang and Zehui Miao of Tsinghua
University for reporting this issue.

Fixes CVE-2025-47912
Fixes #75678
Fixes #75712

Change-Id: Iaa41432bf0ee86de95a39a03adae5729e4deb46c
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2680
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2968
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/709838
TryBot-Bypass: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
2025-10-07 11:00:42 -07:00
Damien Neil
a402f4ad28 [release-branch.go1.24] net/textproto: avoid quadratic complexity in Reader.ReadResponse
Reader.ReadResponse constructed a response string from repeated
string concatenation, permitting a malicious sender to cause excessive
memory allocation and CPU consumption by sending a response consisting
of many short lines.

Use a strings.Builder to construct the string instead.

Thanks to Jakub Ciolek for reporting this issue.

Fixes CVE-2025-61724
For #75716
Fixes #75717

Change-Id: I1a98ce85a21b830cb25799f9ac9333a67400d736
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2940
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2980
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/709837
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Bypass: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2025-10-07 11:00:38 -07:00
Neal Patel
f9f198ab05 [release-branch.go1.24] crypto/x509: mitigate DoS vector when intermediate certificate contains DSA public key
An attacker could craft an intermediate X.509 certificate
containing a DSA public key and can crash a remote host
with an unauthenticated call to any endpoint that
verifies the certificate chain.

Thank you to Jakub Ciolek for reporting this issue.

Fixes CVE-2025-58188
For #75675
Fixes #75702

Change-Id: I2ecbb87b9b8268dbc55c8795891e596ab60f0088
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2780
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2964
Reviewed-on: https://go-review.googlesource.com/c/go/+/709836
TryBot-Bypass: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
2025-10-07 11:00:35 -07:00
Damien Neil
bc6981fd74 [release-branch.go1.24] net/mail: avoid quadratic behavior in mail address parsing
RFC 5322 domain-literal parsing built the dtext value one character
at a time with string concatenation, resulting in excessive
resource consumption when parsing very large domain-literal values.

Replace with a subslice.

Benchmark not included in this CL because it's too narrow to be
of general ongoing use, but for:

    ParseAddress("alice@[" + strings.Repeat("a", 0x40000) + "]")

goos: darwin
goarch: arm64
pkg: net/mail
cpu: Apple M4 Pro
                │  /tmp/bench.0  │            /tmp/bench.1             │
                │     sec/op     │   sec/op     vs base                │
ParseAddress-14   1987.732m ± 9%   1.524m ± 5%  -99.92% (p=0.000 n=10)

                │   /tmp/bench.0   │             /tmp/bench.1              │
                │       B/op       │     B/op      vs base                 │
ParseAddress-14   33692.767Mi ± 0%   1.282Mi ± 0%  -100.00% (p=0.000 n=10)

                │  /tmp/bench.0  │            /tmp/bench.1            │
                │   allocs/op    │ allocs/op   vs base                │
ParseAddress-14   263711.00 ± 0%   17.00 ± 0%  -99.99% (p=0.000 n=10)

Thanks to Philippe Antoine (Catena cyber) for reporting this issue.

Fixes CVE-2025-61725
For #75680
Fixes #75700

Change-Id: Id971c2d5b59882bb476e22fceb7e01ec08234bb7
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2840
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2962
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/709835
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Bypass: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-10-07 11:00:31 -07:00
Damien Neil
3234a3cdc0 [release-branch.go1.24] net/http: avoid connCount underflow race
Remove a race condition in counting the number of connections per host,
which can cause a connCount underflow and a panic.

The race occurs when:

  - A RoundTrip call attempts to use a HTTP/2 roundtripper (pconn.alt != nil)
    and receives an isNoCachedConn error. The call removes the pconn from
    the idle conn pool and decrements the connCount for its host.
  - A second RoundTrip call on the same pconn succeeds,
    and delivers the pconn to a third RoundTrip waiting for a conn.
  - The third RoundTrip receives the pconn at the same moment its request
    context is canceled. It places the pconn back into the idle conn pool.

At this time, the connCount is incorrect, because the conn returned to
the idle pool is not matched by an increment in the connCount.

Fix this by not adding HTTP/2 pconns back to the idle pool in
wantConn.cancel.

For #61474
Fixes #75538

Change-Id: I104d6cf85a54d0382eebf3fcf5dda99c69a7c3f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/703936
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit 3203a5da29)
Reviewed-on: https://go-review.googlesource.com/c/go/+/705377
TryBot-Bypass: Carlos Amedee <carlos@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-10-01 12:09:59 -07:00
Ian Lance Taylor
3de7570e76 [release-branch.go1.24] debug/pe: permit symbols with no name
They are reportedly generated by llvm-mingw clang21.

For #75219
Fixes #75220

Change-Id: I7fa7e13039bc7eee826cc19826985ca0e357a9ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/700137
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit ea00650784)
Reviewed-on: https://go-review.googlesource.com/c/go/+/708357
2025-10-01 11:58:07 -07:00
Keith Randall
9b28db7770 [release-branch.go1.24] cmd/compile: don't rely on loop info when there are irreducible loops
Loop information is sketchy when there are irreducible loops.
Sometimes blocks inside 2 loops can be recorded as only being part of
the outer loop. That causes tighten to move values that want to move
into such a block to move out of the loop altogether, breaking the
invariant that operations have to be scheduled after their args.

Fixes #75594

Change-Id: Idd80e6d2268094b8ae6387563081fdc1e211856a
Reviewed-on: https://go-review.googlesource.com/c/go/+/706355
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
(cherry picked from commit f15cd63ec4)
Reviewed-on: https://go-review.googlesource.com/c/go/+/706575
2025-10-01 11:40:42 -07:00
Roland Shoemaker
2e1e356e33 [release-branch.go1.24] crypto/tls: quote protocols in ALPN error message
Quote the protocols sent by the client when returning the ALPN
negotiation error message.

Fixes CVE-2025-58189
Updates #75652
Fixes #75660

Change-Id: Ie7b3a1ed0b6efcc1705b71f0f1e8417126661330
Reviewed-on: https://go-review.googlesource.com/c/go/+/707776
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Neal Patel <nealpatel@google.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
Auto-Submit: Nicholas Husin <nsh@golang.org>
Reviewed-by: Nicholas Husin <husin@google.com>
TryBot-Bypass: Roland Shoemaker <roland@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
(cherry picked from commit 4e9006a716)
Reviewed-on: https://go-review.googlesource.com/c/go/+/708096
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-10-01 11:37:47 -07:00
Michael Pratt
6998277471 [release-branch.go1.24] sync/atomic: correct Uintptr.Or return doc
Uintptr.Or returns the old value, just like all of the other Or
functions. This was a typo in the original CL 544455.

For #75607.
Fixes #75609.

Change-Id: I260959e7e32e51f1152b5271df6cc51adfa02a4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/706816
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
(cherry picked from commit d70ad4e740)
Reviewed-on: https://go-review.googlesource.com/c/go/+/706855
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-10-01 09:40:14 -07:00
Filippo Valsorda
bcdc53bc8e [release-branch.go1.24] lib/fips140: re-seal v1.0.0
Exceptionally, we decided to make a compliance-related change following
CMVP's updated Implementation Guidance on September 2nd.

The Security Policy will be updated to reflect the new zip hash.

mkzip.go has been modified to accept versions of the form vX.Y.Z-hash,
where the -hash suffix is ignored for fips140.Version() but used to
name the zip file and the unpacked cache directory.

The new zip is generated with

	go run ../../src/cmd/go/internal/fips140/mkzip.go -b c2097c7c v1.0.0-c2097c7c

from c2097c7c which is the current release-branch.go1.24 head.

The full diff between the zip file contents is included below.

For #74947
Updates #69536


$ diff -ru golang.org/fips140@v1.0.0/fips140/v1.0.0/ golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c

diff -ru golang.org/fips140@v1.0.0/fips140/v1.0.0/cast.go golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/cast.go
--- golang.org/fips140@v1.0.0/fips140/v1.0.0/cast.go	1980-01-10 00:00:00.000000000 +0100
+++ golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/cast.go	1980-01-10 00:00:00.000000000 +0100
@@ -56,9 +56,10 @@
 }

 // PCT runs the named Pairwise Consistency Test (if operated in FIPS mode) and
-// returns any errors. If an error is returned, the key must not be used.
+// aborts the program (stopping the module input/output and entering the "error
+// state") if the test fails.
 //
-// PCTs are mandatory for every key pair that is generated/imported, including
+// PCTs are mandatory for every generated (but not imported) key pair, including
 // ephemeral keys (which effectively doubles the cost of key establishment). See
 // Implementation Guidance 10.3.A Additional Comment 1.
 //
@@ -66,17 +67,23 @@
 //
 // If a package p calls PCT during key generation, an invocation of that
 // function should be added to fipstest.TestConditionals.
-func PCT(name string, f func() error) error {
+func PCT(name string, f func() error) {
 	if strings.ContainsAny(name, ",#=:") {
 		panic("fips: invalid self-test name: " + name)
 	}
 	if !Enabled {
-		return nil
+		return
 	}

 	err := f()
 	if name == failfipscast {
 		err = errors.New("simulated PCT failure")
 	}
-	return err
+	if err != nil {
+		fatal("FIPS 140-3 self-test failed: " + name + ": " + err.Error())
+		panic("unreachable")
+	}
+	if debug {
+		println("FIPS 140-3 PCT passed:", name)
+	}
 }
diff -ru golang.org/fips140@v1.0.0/fips140/v1.0.0/ecdh/ecdh.go golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/ecdh/ecdh.go
--- golang.org/fips140@v1.0.0/fips140/v1.0.0/ecdh/ecdh.go	1980-01-10 00:00:00.000000000 +0100
+++ golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/ecdh/ecdh.go	1980-01-10 00:00:00.000000000 +0100
@@ -161,6 +161,27 @@
 		if err != nil {
 			continue
 		}
+
+		// A "Pairwise Consistency Test" makes no sense if we just generated the
+		// public key from an ephemeral private key. Moreover, there is no way to
+		// check it aside from redoing the exact same computation again. SP 800-56A
+		// Rev. 3, Section 5.6.2.1.4 acknowledges that, and doesn't require it.
+		// However, ISO 19790:2012, Section 7.10.3.3 has a blanket requirement for a
+		// PCT for all generated keys (AS10.35) and FIPS 140-3 IG 10.3.A, Additional
+		// Comment 1 goes out of its way to say that "the PCT shall be performed
+		// consistent [...], even if the underlying standard does not require a
+		// PCT". So we do it. And make ECDH nearly 50% slower (only) in FIPS mode.
+		fips140.PCT("ECDH PCT", func() error {
+			p1, err := c.newPoint().ScalarBaseMult(privateKey.d)
+			if err != nil {
+				return err
+			}
+			if !bytes.Equal(p1.Bytes(), privateKey.pub.q) {
+				return errors.New("crypto/ecdh: public key does not match private key")
+			}
+			return nil
+		})
+
 		return privateKey, nil
 	}
 }
@@ -188,28 +209,6 @@
 		panic("crypto/ecdh: internal error: public key is the identity element")
 	}

-	// A "Pairwise Consistency Test" makes no sense if we just generated the
-	// public key from an ephemeral private key. Moreover, there is no way to
-	// check it aside from redoing the exact same computation again. SP 800-56A
-	// Rev. 3, Section 5.6.2.1.4 acknowledges that, and doesn't require it.
-	// However, ISO 19790:2012, Section 7.10.3.3 has a blanket requirement for a
-	// PCT for all generated keys (AS10.35) and FIPS 140-3 IG 10.3.A, Additional
-	// Comment 1 goes out of its way to say that "the PCT shall be performed
-	// consistent [...], even if the underlying standard does not require a
-	// PCT". So we do it. And make ECDH nearly 50% slower (only) in FIPS mode.
-	if err := fips140.PCT("ECDH PCT", func() error {
-		p1, err := c.newPoint().ScalarBaseMult(key)
-		if err != nil {
-			return err
-		}
-		if !bytes.Equal(p1.Bytes(), publicKey) {
-			return errors.New("crypto/ecdh: public key does not match private key")
-		}
-		return nil
-	}); err != nil {
-		panic(err)
-	}
-
 	k := &PrivateKey{d: bytes.Clone(key), pub: PublicKey{curve: c.curve, q: publicKey}}
 	return k, nil
 }
diff -ru golang.org/fips140@v1.0.0/fips140/v1.0.0/ecdsa/cast.go golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/ecdsa/cast.go
--- golang.org/fips140@v1.0.0/fips140/v1.0.0/ecdsa/cast.go	1980-01-10 00:00:00.000000000 +0100
+++ golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/ecdsa/cast.go	1980-01-10 00:00:00.000000000 +0100
@@ -51,8 +51,8 @@
 	}
 }

-func fipsPCT[P Point[P]](c *Curve[P], k *PrivateKey) error {
-	return fips140.PCT("ECDSA PCT", func() error {
+func fipsPCT[P Point[P]](c *Curve[P], k *PrivateKey) {
+	fips140.PCT("ECDSA PCT", func() error {
 		hash := testHash()
 		drbg := newDRBG(sha512.New, k.d, bits2octets(P256(), hash), nil)
 		sig, err := sign(c, k, drbg, hash)
diff -ru golang.org/fips140@v1.0.0/fips140/v1.0.0/ecdsa/ecdsa.go golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/ecdsa/ecdsa.go
--- golang.org/fips140@v1.0.0/fips140/v1.0.0/ecdsa/ecdsa.go	1980-01-10 00:00:00.000000000 +0100
+++ golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/ecdsa/ecdsa.go	1980-01-10 00:00:00.000000000 +0100
@@ -166,11 +166,6 @@
 		return nil, err
 	}
 	priv := &PrivateKey{pub: *pub, d: d.Bytes(c.N)}
-	if err := fipsPCT(c, priv); err != nil {
-		// This can happen if the application went out of its way to make an
-		// ecdsa.PrivateKey with a mismatching PublicKey.
-		return nil, err
-	}
 	return priv, nil
 }

@@ -203,10 +198,7 @@
 		},
 		d: k.Bytes(c.N),
 	}
-	if err := fipsPCT(c, priv); err != nil {
-		// This clearly can't happen, but FIPS 140-3 mandates that we check it.
-		panic(err)
-	}
+	fipsPCT(c, priv)
 	return priv, nil
 }

diff -ru golang.org/fips140@v1.0.0/fips140/v1.0.0/ecdsa/hmacdrbg.go golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/ecdsa/hmacdrbg.go
--- golang.org/fips140@v1.0.0/fips140/v1.0.0/ecdsa/hmacdrbg.go	1980-01-10 00:00:00.000000000 +0100
+++ golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/ecdsa/hmacdrbg.go	1980-01-10 00:00:00.000000000 +0100
@@ -121,7 +121,7 @@
 //
 // This should only be used for ACVP testing. hmacDRBG is not intended to be
 // used directly.
-func TestingOnlyNewDRBG(hash func() fips140.Hash, entropy, nonce []byte, s []byte) *hmacDRBG {
+func TestingOnlyNewDRBG[H fips140.Hash](hash func() H, entropy, nonce []byte, s []byte) *hmacDRBG {
 	return newDRBG(hash, entropy, nonce, plainPersonalizationString(s))
 }

diff -ru golang.org/fips140@v1.0.0/fips140/v1.0.0/ed25519/cast.go golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/ed25519/cast.go
--- golang.org/fips140@v1.0.0/fips140/v1.0.0/ed25519/cast.go	1980-01-10 00:00:00.000000000 +0100
+++ golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/ed25519/cast.go	1980-01-10 00:00:00.000000000 +0100
@@ -12,8 +12,8 @@
 	"sync"
 )

-func fipsPCT(k *PrivateKey) error {
-	return fips140.PCT("Ed25519 sign and verify PCT", func() error {
+func fipsPCT(k *PrivateKey) {
+	fips140.PCT("Ed25519 sign and verify PCT", func() error {
 		return pairwiseTest(k)
 	})
 }
diff -ru golang.org/fips140@v1.0.0/fips140/v1.0.0/ed25519/ed25519.go golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/ed25519/ed25519.go
--- golang.org/fips140@v1.0.0/fips140/v1.0.0/ed25519/ed25519.go	1980-01-10 00:00:00.000000000 +0100
+++ golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/ed25519/ed25519.go	1980-01-10 00:00:00.000000000 +0100
@@ -69,10 +69,7 @@
 	fips140.RecordApproved()
 	drbg.Read(priv.seed[:])
 	precomputePrivateKey(priv)
-	if err := fipsPCT(priv); err != nil {
-		// This clearly can't happen, but FIPS 140-3 requires that we check.
-		panic(err)
-	}
+	fipsPCT(priv)
 	return priv, nil
 }

@@ -88,10 +85,6 @@
 	}
 	copy(priv.seed[:], seed)
 	precomputePrivateKey(priv)
-	if err := fipsPCT(priv); err != nil {
-		// This clearly can't happen, but FIPS 140-3 requires that we check.
-		panic(err)
-	}
 	return priv, nil
 }

@@ -137,12 +130,6 @@

 	copy(priv.prefix[:], h[32:])

-	if err := fipsPCT(priv); err != nil {
-		// This can happen if the application messed with the private key
-		// encoding, and the public key doesn't match the seed anymore.
-		return nil, err
-	}
-
 	return priv, nil
 }

diff -ru golang.org/fips140@v1.0.0/fips140/v1.0.0/fips140.go golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/fips140.go
--- golang.org/fips140@v1.0.0/fips140/v1.0.0/fips140.go	1980-01-10 00:00:00.000000000 +0100
+++ golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/fips140.go	1980-01-10 00:00:00.000000000 +0100
@@ -62,6 +62,10 @@
 	return "Go Cryptographic Module"
 }

+// Version returns the formal version (such as "v1.0.0") if building against a
+// frozen module with GOFIPS140. Otherwise, it returns "latest".
 func Version() string {
-	return "v1.0"
+	// This return value is replaced by mkzip.go, it must not be changed or
+	// moved to a different file.
+	return "v1.0.0"
 }
diff -ru golang.org/fips140@v1.0.0/fips140/v1.0.0/mlkem/mlkem1024.go golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/mlkem/mlkem1024.go
--- golang.org/fips140@v1.0.0/fips140/v1.0.0/mlkem/mlkem1024.go	1980-01-10 00:00:00.000000000 +0100
+++ golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/mlkem/mlkem1024.go	1980-01-10 00:00:00.000000000 +0100
@@ -118,10 +118,7 @@
 	var z [32]byte
 	drbg.Read(z[:])
 	kemKeyGen1024(dk, &d, &z)
-	if err := fips140.PCT("ML-KEM PCT", func() error { return kemPCT1024(dk) }); err != nil {
-		// This clearly can't happen, but FIPS 140-3 requires us to check.
-		panic(err)
-	}
+	fips140.PCT("ML-KEM PCT", func() error { return kemPCT1024(dk) })
 	fips140.RecordApproved()
 	return dk, nil
 }
@@ -149,10 +146,6 @@
 	d := (*[32]byte)(seed[:32])
 	z := (*[32]byte)(seed[32:])
 	kemKeyGen1024(dk, d, z)
-	if err := fips140.PCT("ML-KEM PCT", func() error { return kemPCT1024(dk) }); err != nil {
-		// This clearly can't happen, but FIPS 140-3 requires us to check.
-		panic(err)
-	}
 	fips140.RecordApproved()
 	return dk, nil
 }
diff -ru golang.org/fips140@v1.0.0/fips140/v1.0.0/mlkem/mlkem768.go golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/mlkem/mlkem768.go
--- golang.org/fips140@v1.0.0/fips140/v1.0.0/mlkem/mlkem768.go	1980-01-10 00:00:00.000000000 +0100
+++ golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/mlkem/mlkem768.go	1980-01-10 00:00:00.000000000 +0100
@@ -177,10 +177,7 @@
 	var z [32]byte
 	drbg.Read(z[:])
 	kemKeyGen(dk, &d, &z)
-	if err := fips140.PCT("ML-KEM PCT", func() error { return kemPCT(dk) }); err != nil {
-		// This clearly can't happen, but FIPS 140-3 requires us to check.
-		panic(err)
-	}
+	fips140.PCT("ML-KEM PCT", func() error { return kemPCT(dk) })
 	fips140.RecordApproved()
 	return dk, nil
 }
@@ -208,10 +205,6 @@
 	d := (*[32]byte)(seed[:32])
 	z := (*[32]byte)(seed[32:])
 	kemKeyGen(dk, d, z)
-	if err := fips140.PCT("ML-KEM PCT", func() error { return kemPCT(dk) }); err != nil {
-		// This clearly can't happen, but FIPS 140-3 requires us to check.
-		panic(err)
-	}
 	fips140.RecordApproved()
 	return dk, nil
 }
diff -ru golang.org/fips140@v1.0.0/fips140/v1.0.0/rsa/keygen.go golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/rsa/keygen.go
--- golang.org/fips140@v1.0.0/fips140/v1.0.0/rsa/keygen.go	1980-01-10 00:00:00.000000000 +0100
+++ golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/rsa/keygen.go	1980-01-10 00:00:00.000000000 +0100
@@ -105,7 +105,28 @@
 		// negligible chance of failure we can defer the check to the end of key
 		// generation and return an error if it fails. See [checkPrivateKey].

-		return newPrivateKey(N, 65537, d, P, Q)
+		k, err := newPrivateKey(N, 65537, d, P, Q)
+		if err != nil {
+			return nil, err
+		}
+
+		if k.fipsApproved {
+			fips140.PCT("RSA sign and verify PCT", func() error {
+				hash := []byte{
+					0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+					0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+					0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
+					0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
+				}
+				sig, err := signPKCS1v15(k, "SHA-256", hash)
+				if err != nil {
+					return err
+				}
+				return verifyPKCS1v15(k.PublicKey(), "SHA-256", hash, sig)
+			})
+		}
+
+		return k, nil
 	}
 }

diff -ru golang.org/fips140@v1.0.0/fips140/v1.0.0/rsa/rsa.go golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/rsa/rsa.go
--- golang.org/fips140@v1.0.0/fips140/v1.0.0/rsa/rsa.go	1980-01-10 00:00:00.000000000 +0100
+++ golang.org/fips140@v1.0.0-c2097c7c/fips140/v1.0.0-c2097c7c/rsa/rsa.go	1980-01-10 00:00:00.000000000 +0100
@@ -310,26 +310,6 @@
 		return errors.New("crypto/rsa: d too small")
 	}

-	// If the key is still in scope for FIPS mode, perform a Pairwise
-	// Consistency Test.
-	if priv.fipsApproved {
-		if err := fips140.PCT("RSA sign and verify PCT", func() error {
-			hash := []byte{
-				0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
-				0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
-				0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
-				0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
-			}
-			sig, err := signPKCS1v15(priv, "SHA-256", hash)
-			if err != nil {
-				return err
-			}
-			return verifyPKCS1v15(priv.PublicKey(), "SHA-256", hash, sig)
-		}); err != nil {
-			return err
-		}
-	}
-
 	return nil
 }


Change-Id: I6a6a6964b1780f19ec2b5202052de58b47d9342c
Reviewed-on: https://go-review.googlesource.com/c/go/+/706715
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-09-25 13:37:09 -07:00
Filippo Valsorda
c2097c7cc7 [release-branch.go1.24] crypto/internal/fips140: remove key import PCTs, make keygen PCTs fatal
CMVP clarified with the September 2nd changes to IG 10.3.A that PCTs
don't need to run on imported keys.

However, PCT failure must enter the error state (which for us is fatal).

Thankfully, now that PCTs only run on key generation, we can be assured
they will never fail.

This change should only affect FIPS 140-3 mode.

While at it, make the CAST/PCT testing more robust, checking
TestConditional is terminated by a fatal error (and not by t.Fatal).

Fixes #74947
Updates #75523
Updates #69536

Change-Id: I6a6a696439e1560c10f3cce2cb208fd40c5bc641
Reviewed-on: https://go-review.googlesource.com/c/go/+/701438
Reviewed-by: Junyang Shao <shaojunyang@google.com>
TryBot-Bypass: Filippo Valsorda <filippo@golang.org>
Commit-Queue: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-09-25 12:14:05 -07:00
Filippo Valsorda
c78ec927ee [release-branch.go1.24] crypto/internal/fips140/ecdsa: make TestingOnlyNewDRBG generic
We are re-sealing the .zip file anyway for another reason, might as well
take the opportunity to remove the fips140.Hash type indirection.

Updates #75523

Change-Id: I6a6a6964fdb312cc2c64e327f845c398c0f6279b
Reviewed-on: https://go-review.googlesource.com/c/go/+/701442
Reviewed-by: Roland Shoemaker <roland@golang.org>
Commit-Queue: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
TryBot-Bypass: Filippo Valsorda <filippo@golang.org>
2025-09-25 12:14:01 -07:00
Filippo Valsorda
0face6f1a6 [release-branch.go1.24] crypto/internal/fips140test: make TestCASTFailures standalone
We want it to work even when fips140test.test is cross-compiled and
moved to a different machine. Also, make it log more.

Cherry-picked to facilitate applying CL 701438.

Updates #75523

Change-Id: I6a6a46566712f05f6b551ecde75672baf2c0fc6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/644644
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/701437
Reviewed-by: Mark Freeman <markfreeman@google.com>
2025-09-25 12:02:35 -07:00
Filippo Valsorda
908f609315 [release-branch.go1.24] crypto/internal/fips140: revert post-sealing change to FIPS 140-3 module
This small change landed in CL 650675 after v1.0.0.zip was sealed. Since
we are re-sealing it from release-branch.go1.24, revert it to avoid it
showing up on the diff between the two zip files.

Updates #75523

Change-Id: I6a6a6964625880a209682dec72faa8aff74644fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/701440
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Mark Freeman <markfreeman@google.com>
2025-09-25 12:02:28 -07:00
Filippo Valsorda
abbddbbdcb [release-branch.go1.24] crypto/internal/fips140: make Version return latest when not frozen
Cherry-picked to allow running new mkzip.go on release-branch.go1.24.

Updates #75523
Updates #71820

Change-Id: I6a6a46563da281a7b20efc61eefdcbb2e146db33
Reviewed-on: https://go-review.googlesource.com/c/go/+/655795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/701439
Reviewed-by: Mark Freeman <markfreeman@google.com>
2025-09-25 12:02:18 -07:00
Damien Neil
0e3c8891ba [release-branch.go1.24] os: skip TestOpenFileCreateExclDanglingSymlink when no symlinks
Skip this test on plan9, and any other platform that doesn't
have symlinks.

For #73729
Fixes #75359

Change-Id: I8052db24ed54c3361530bd4f54c96c9d10c4714c
Reviewed-on: https://go-review.googlesource.com/c/go/+/674697
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Reviewed-by: Richard Miller <millerresearch@gmail.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
(cherry picked from commit 0375edd901)
Reviewed-on: https://go-review.googlesource.com/c/go/+/704336
Reviewed-by: David du Colombier <0intro@gmail.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2025-09-22 08:35:39 -07:00
Mark Ryan
a0811d4dc9 [release-branch.go1.24] cmd/link: fix cgo on riscv64 when building with gcc-15
It's not currently possible to build cgo programs that are partially
compiled with gcc-15 on riscv64 using the internal linker. There are
two reasons for this.

1. When gcc-15 compiles _cgo_export.c, which contains no actual code,
   for a riscv64 target, it emits a label in the .text section called
   .Letext0. This label is referred to by another section, .debug_line,
   and an entry is generated in the symbol table for it. The Go linker
   panics when processing the .Letext0 symbol in _cgo_export.o, as it
   occurs in an empty section.
2. GCC-15 is generating additional debug symbols with the .LVUS
   prefix, e.g., .LVUS33, that need to be ignored.

We fix the issue by removing the check in
cmd/link/internal/loader/loader.go that panics if we encounter a
symbol in an empty section (the comments preceding this check suggest
it's safe to remove it) and by adding .LVUS to the list of symbol
prefixes to ignore.

For #72840
Fixes #75351

Change-Id: I00658b6bdd01606dde1581b5bc2f42edfc37de82
Reviewed-on: https://go-review.googlesource.com/c/go/+/668276
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
(cherry picked from commit 12e5efd710)
Reviewed-on: https://go-review.googlesource.com/c/go/+/704775
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
2025-09-17 11:00:02 -07:00
Damien Neil
8ac346df85 [release-branch.go1.24] os: set full name for Roots created with Root.OpenRoot
Set the Name for a Root created within a Root to be the
concatenation of the parent's path and the name used to open the child.

This matches the behavior for files opened within a Root
with Root.Open.

For #73868
Fixes #75138

Change-Id: Idf4021602ac25556721b7ef6924dec652c7bf4db
Reviewed-on: https://go-review.googlesource.com/c/go/+/698376
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit ed7f804775)
Reviewed-on: https://go-review.googlesource.com/c/go/+/704278
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2025-09-16 11:04:27 -07:00
Richard Miller
6ab3a41c86 [release-branch.go1.24] net: skip TestIPv4WriteMsgUDPAddrPort on plan9
This test uses method (*UDPConn).WriteMsgUDPAddrPort, which is
not supported on Plan 9. The test needs to be skipped, like
for example TestAllocs which is already skipped for the
same reason.

For #75017
Fixes #75356

Change-Id: Iaa0e6ecdba0938736d8f675fcac43c46db34cb5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/696095
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit cb814bd5bc)
Reviewed-on: https://go-review.googlesource.com/c/go/+/704279
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
2025-09-16 10:09:29 -07:00
Gopher Robot
d41a822213 [release-branch.go1.24] go1.24.7
Change-Id: I072fdd262ab136db9d2d11a73be324106ece5a3f
Reviewed-on: https://go-review.googlesource.com/c/go/+/700735
Auto-Submit: Gopher Robot <gobot@golang.org>
TryBot-Bypass: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-09-03 10:46:07 -07:00
database64128
86c5e2d025 [release-branch.go1.24] net: fix WriteMsgUDPAddrPort addr handling on IPv4 sockets
Accept IPv4-mapped IPv6 destination addresses on IPv4 UDP sockets.

Fixes #74818.

Change-Id: I4624b9b8f861aedcae29e51d5298d23ce1c0f2c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/689976
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
(cherry picked from commit bdb2d50fdf)
Reviewed-on: https://go-review.googlesource.com/c/go/+/695656
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-08-25 19:49:49 -07:00
Richard Miller
94ca1d97b4 [release-branch.go1.24] os/exec: fix incorrect expansion of ".." in LookPath on plan9
The correction in CL 685755 is incomplete for plan9, where path
search is performed even on file strings containing "/". By
applying filepath.Clean to the argument of validateLookPath,
we can check for bogus file strings containing ".." where the
later call to filepath.Join would transform a path like
"badfile/dir/.." to "badfile" even where "dir" isn't a directory
or doesn't exist.

For #74466
Fixes #75007

Change-Id: I3f8b73a1de6bc7d8001b1ca8e74b78722408548e
Reviewed-on: https://go-review.googlesource.com/c/go/+/693935
Reviewed-by: David du Colombier <0intro@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
(cherry picked from commit 674c5f0edd)
Reviewed-on: https://go-review.googlesource.com/c/go/+/698655
TryBot-Bypass: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-08-25 11:16:04 -07:00
Michael Matloob
fe83d4bcad [release-branch.go1.24] cmd/go/internal/gover: fix ModIsPrerelease for toolchain versions
We forgot to call the IsPrerelease function on FromToolchain(vers)
rather than on vers itself. IsPrerelase expects a version without the
"go" prefix. See the corresponding code in ModIsValid and ModIsPrefix
that call FromToolchain before passing the versions to IsValid and
IsLang respectively.

Fixes #74821

Change-Id: I3cf055e1348e6a9dc0334e414f06fe85eaf78024
Reviewed-on: https://go-review.googlesource.com/c/go/+/691655
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
(cherry picked from commit 69338a335a)
Reviewed-on: https://go-review.googlesource.com/c/go/+/691957
2025-08-20 12:48:03 -07:00
Gopher Robot
7f36edc26d [release-branch.go1.24] go1.24.6
Change-Id: I01fc50fa6e6ea1bd93cbbd17885a8934bf97b223
Reviewed-on: https://go-review.googlesource.com/c/go/+/693715
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
TryBot-Bypass: Gopher Robot <gobot@golang.org>
Reviewed-by: Mark Freeman <markfreeman@google.com>
2025-08-06 11:07:24 -07:00
Damien Neil
83b4a5db24 [release-branch.go1.24] database/sql: avoid closing Rows while scan is in progress
A database/sql/driver.Rows can return database-owned data
from Rows.Next. The driver.Rows documentation doesn't explicitly
document the lifetime guarantees for this data, but a reasonable
expectation is that the caller of Next should only access it
until the next call to Rows.Close or Rows.Next.

Avoid violating that constraint when a query is cancelled while
a call to database/sql.Rows.Scan (note the difference between
the two different Rows types!) is in progress. We previously
took care to avoid closing a driver.Rows while the user has
access to driver-owned memory via a RawData, but we could still
close a driver.Rows while a Scan call was in the process of
reading previously-returned driver-owned data.

Update the fake DB used in database/sql tests to invalidate
returned data to help catch other places we might be
incorrectly retaining it.

Updates #74831
Fixes #74833

Change-Id: Ice45b5fad51b679c38e3e1d21ef39156b56d6037
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2540
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Neal Patel <nealpatel@google.com>
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2620
Reviewed-on: https://go-review.googlesource.com/c/go/+/693616
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Mark Freeman <markfreeman@google.com>
2025-08-06 10:49:43 -07:00
Olivier Mengué
0f5133b742 [release-branch.go1.24] os/exec: fix incorrect expansion of "", "." and ".." in LookPath
Fix incorrect expansion of "" and "." when $PATH contains an executable
file or, on Windows, a parent directory of a %PATH% element contains an
file with the same name as the %PATH% element but with one of the
%PATHEXT% extension (ex: C:\utils\bin is in PATH, and C:\utils\bin.exe
exists).

Fix incorrect expansion of ".." when $PATH contains an element which is
an the concatenation of the path to an executable file (or on Windows
a path that can be expanded to an executable by appending a %PATHEXT%
extension), a path separator and a name.

"", "." and ".." are now rejected early with ErrNotFound.

Fixes CVE-2025-47906
Fixes #74804

Change-Id: Ie50cc0a660fce8fbdc952a7f2e05c36062dcb50e
Reviewed-on: https://go-review.googlesource.com/c/go/+/685755
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
(cherry picked from commit e0b07dc22e)
Reviewed-on: https://go-review.googlesource.com/c/go/+/691875
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-07-30 13:59:28 -07:00
Keith Randall
6e1c4529e4 [release-branch.go1.24] cmd/compile: for arm64 epilog, do SP increment with a single instruction
That way, the frame is atomically popped. Previously, for big frames
the SP was unwound in two steps (because arm64 can only add constants
up to 1<<12 in a single instruction).

Fixes #74694

Change-Id: I382c249194ad7bc9fc19607c27487c58d90d49e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/689235
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
(cherry picked from commit f7cc61e7d7)
Reviewed-on: https://go-review.googlesource.com/c/go/+/689596
2025-07-30 11:54:02 -07:00
qmuntal
731de13dc3 [release-branch.go1.24] os/user: user random name for the test user account
TestImpersonated and TestGroupIdsTestUser are flaky due to sporadic
failures when creating the test user account when running the tests
from different processes at the same time.

This flakiness can be fixed by using a random name for the test user
account.

For #73523.
Fixes #74760.

Cq-Include-Trybots: luci.golang.try:go1.24-windows-amd64-longtest
Change-Id: Ib2283a888437420502b1c11d876c975f5af4bc03
Reviewed-on: https://go-review.googlesource.com/c/go/+/690175
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
(cherry picked from commit 374e3be2eb)
Reviewed-on: https://go-review.googlesource.com/c/go/+/690556
Reviewed-by: Mark Freeman <mark@golang.org>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2025-07-30 11:52:37 -07:00
Michael Anthony Knyszek
390ffce7d6 [release-branch.go1.24] runtime: prevent unnecessary zeroing of large objects with pointers
CL 614257 refactored mallocgc but lost an optimization: if a span for a
large object is already backed by memory fresh from the OS (and thus
zeroed), we don't need to zero it. CL 614257 unconditionally zeroed
spans for large objects that contain pointers.

This change restores the optimization from before CL 614257, which seems
to matter in some real-world programs.

While we're here, let's also fix a hole with the garbage collector being
able to observe uninitialized memory of the large object is observed
by the conservative scanner before being published. The gory details are
in a comment in heapSetTypeLarge. In short, this change makes
span.largeType an atomic variable, such that the GC can only observe
initialized memory if span.largeType != nil.

For #72991.
Fixes #73800.

Change-Id: I2048aeb220ab363d252ffda7d980b8788e9674dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/659956
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
(cherry picked from commit df9888ea4e)
Reviewed-on: https://go-review.googlesource.com/c/go/+/682356
2025-07-10 10:03:34 -07:00
Michael Pratt
b454859a8a [release-branch.go1.24] runtime: stash allpSnapshot on the M
findRunnable takes a snapshot of allp prior to dropping the P because
afterwards procresize may mutate allp without synchronization.
procresize is careful to never mutate the contents up to cap(allp), so
findRunnable can still safely access the Ps in the slice.

Unfortunately, growing allp is problematic. If procresize grows the allp
backing array, it drops the reference to the old array. allpSnapshot
still refers to the old array, but allpSnapshot is on the system stack
in findRunnable, which also likely no longer has a P at all.

This means that a future GC will not find the reference and can free the
array and use it for another allocation. This would corrupt later reads
that findRunnable does from the array.

The fix is simple: the M struct itself is reachable by the GC, so we can
stash the snapshot in the M to ensure it is visible to the GC.

The ugliest part of the CL is the cleanup when we are done with the
snapshot because there are so many return/goto top sites. I am tempted
to put mp.clearAllpSnapshot() in the caller and at top to make this less
error prone, at the expensive of extra unnecessary writes.

For #74414.
For #74416.

Change-Id: I6a6a636c484e4f4b34794fd07910b3fffeca830b
Reviewed-on: https://go-review.googlesource.com/c/go/+/684460
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
(cherry picked from commit 740857f529)
Reviewed-on: https://go-review.googlesource.com/c/go/+/685056
2025-07-10 10:03:11 -07:00
Gopher Robot
9d828e80fa [release-branch.go1.24] go1.24.5
Change-Id: I0d1554956b9fb4453fc6cce977d67c56476e3624
Reviewed-on: https://go-review.googlesource.com/c/go/+/686455
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Bypass: Gopher Robot <gobot@golang.org>
2025-07-08 10:00:27 -07:00
Roland Shoemaker
825eeee3f7 [release-branch.go1.24] cmd/go: disable support for multiple vcs in one module
Removes the somewhat redundant vcs.FromDir, "allowNesting" argument,
which was always enabled, and disallow multiple VCS metadata folders
being present in a single directory. This makes VCS injection attacks
much more difficult.

Also adds a GODEBUG, allowmultiplevcs, which re-enables this behavior.

Thanks to RyotaK (https://ryotak.net) of GMO Flatt Security Inc for
reporting this issue.

Updates #74380
Fixes #74381
Fixes CVE-2025-4674

Change-Id: I6c7925b034d60b80d7698cca677b00bdcc67f24e
Reviewed-on: https://go-review.googlesource.com/c/go/+/686395
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Commit-Queue: Carlos Amedee <carlos@golang.org>
2025-07-08 09:29:29 -07:00
Cherry Mui
dbf30d88f3 [release-branch.go1.24] cmd/link: permit a larger size BSS reference to a smaller DATA symbol
Currently, if there is a BSS reference and a DATA symbol
definition with the same name, we pick the DATA symbol, as it
contains the right content. In this case, if the BSS reference
has a larger size, we error out, because it is not safe to access
a smaller symbol as if it has a larger size.

Sometimes code declares a global variable in Go and defines it
in assembly with content. They are expected to be of the same
size. However, in ASAN mode, we insert a red zone for the variable
on the Go side, making it have a larger size, whereas the assembly
symbol is unchanged. This causes the Go reference (BSS) has a
larger size than the assembly definition (DATA). It results in an
error currently. This code is valid and safe, so we should permit
that.

We support this case by increasing the symbol size to match the
larger size (of the BSS side). The symbol content (from the DATA
side) is kept. In some sense, we merge the two symbols. When
loading symbols, it is not easy to change its size (as the object
file may be mapped read-only), so we add it to a fixup list, and
fix it up later after all Go symbols are loaded. This is a very
rare case, so the list should not be long.

We could limit this to just ASAN mode. But it seems okay to allow
this in general. As long as the symbol has the larger size, it is
safe to access it with the larger size.

Updates #74314.
Fixes #74403.

Change-Id: I3ee6e46161d8f59500e2b81befea11e563355a57
Reviewed-on: https://go-review.googlesource.com/c/go/+/684236
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
(cherry picked from commit 0f8ab2db17)
Reviewed-on: https://go-review.googlesource.com/c/go/+/684455
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2025-06-27 10:20:50 -07:00
Michael Anthony Knyszek
6b51660c8c [release-branch.go1.24] runtime: set mspan limit field early and eagerly
Currently the mspan limit field is set after allocSpan returns, *after*
the span has already been published to the GC (including the
conservative scanner). But the limit field is load-bearing, because it's
checked to filter out invalid pointers. A stale limit value could cause
a crash by having the conservative scanner access allocBits out of
bounds.

Fix this by setting the mspan limit field before publishing the span.
For large objects and arena chunks, we adjust the limit down after
allocSpan because we don't have access to the true object's size from
allocSpan. However this is safe, since we first initialize the limit to
something definitely safe (the actual span bounds) and only adjust it
down after. Adjusting it down has the benefit of more precise debug
output, but the window in which it's imprecise is also fine because a
single object (logically, with arena chunks) occupies the whole span, so
the 'invalid' part of the memory will just safely point back to that
object. We can't do this for smaller objects because the limit will
include space that does *not* contain any valid objects.

For #74288.
Fixes #74290.

Change-Id: I0a22e5b9bccc1bfdf51d2b73ea7130f1b99c0c7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/682655
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
(cherry picked from commit 4c7567290c)
Reviewed-on: https://go-review.googlesource.com/c/go/+/684079
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-06-27 10:13:03 -07:00
Michael Anthony Knyszek
cc604130c8 [release-branch.go1.24] runtime: prevent mutual deadlock between GC stopTheWorld and suspendG
Almost everywhere we stop the world we casGToWaitingForGC to prevent
mutual deadlock with the GC trying to scan our stack. This historically
was only necessary if we weren't stopping the world to change the GC
phase, because what we were worried about was mutual deadlock with mark
workers' use of suspendG. And, they were the only users of suspendG.

In Go 1.22 this changed. The execution tracer began using suspendG, too.
This leads to the possibility of mutual deadlock between the execution
tracer and a goroutine trying to start or end the GC mark phase. The fix
is simple: make the stop-the-world calls for the GC also call
casGToWaitingForGC. This way, suspendG is guaranteed to make progress in
this circumstance, and once it completes, the stop-the-world can
complete as well.

We can take this a step further, though, and move casGToWaitingForGC
into stopTheWorldWithSema, since there's no longer really a place we can
afford to skip this detail.

While we're here, rename casGToWaitingForGC to casGToWaitingForSuspendG,
since the GC is now not the only potential source of mutual deadlock.

For #72740.
Fixes #74294.

Change-Id: I5e3739a463ef3e8173ad33c531e696e46260692f
Reviewed-on: https://go-review.googlesource.com/c/go/+/681501
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
(cherry picked from commit c6ac736288)
Reviewed-on: https://go-review.googlesource.com/c/go/+/684078
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-06-27 10:09:36 -07:00
Michael Anthony Knyszek
21b488bb60 [release-branch.go1.24] runtime: handle system goroutines later in goroutine profiling
In Go 1.24 and earlier, it's possible for a just-starting finalizer
goroutine to have its stack traced in goroutine profiles even though
it shouldn't, because it wasn't visible to the goroutine profile STW.
This can also bump out other stacks, because the goroutine profiler
wasn't expecting to have another stack. Fix this by letting all
system goroutines participate in the goroutine profiler's state
machine, like in the CL this is cherry-picking. This ensures that the
finalizer goroutine will be counted as a system goroutine in this
just-starting state, but still composes with the old way of doing
things, because the finalizer goroutine is advanced to the terminal
state during the STW. In Go 1.25, this is fixing a slightly different
issue, but the root of the problem is the same: all goroutines should
participate in the profiler's state machine, and they do not.

For #74090.
Fixes #74363.

Change-Id: Icb9a164a033be22aaa942d19e828e895f700ca74
Reviewed-on: https://go-review.googlesource.com/c/go/+/680477
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit 281cfcfc1b)
Reviewed-on: https://go-review.googlesource.com/c/go/+/684017
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2025-06-27 10:04:49 -07:00
Michael Pratt
e038690847 [release-branch.go1.24] cmd/go/internal/fips140: ignore GOEXPERIMENT on error
During toolchain selection, the GOEXPERIMENT value may not be valid for
the current version (but it is valid for the selected version). In this
case, cfg.ExperimentErr is set and cfg.Experiment is nil.

Normally cmd/go main exits when ExperimentErr is set, so Experiment is
~never nil. But that is skipped during toolchain selection, and
fips140.Init is used during toolchain selection.

For #74111.
Fixes #74113

Change-Id: I6a6a636c65ee5831feaf3d29993a60613bbec6f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/680976
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
(cherry picked from commit 8552bcf7c2)
Reviewed-on: https://go-review.googlesource.com/c/go/+/682735
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Matloob <matloob@google.com>
2025-06-26 10:26:56 -07:00
Cherry Mui
1575127ef8 [release-branch.go1.24] runtime: add missing unlock in sysReserveAlignedSbrk
sysReserveAlignedSbrk locks memlock at entry, but it is not
unlocked at one of the return path. Add the missing unlock.

Updates #74339.
Fixes #74346.

Change-Id: Ib641bc348aca41494ec410e2c4eb9857f3362484
Reviewed-on: https://go-review.googlesource.com/c/go/+/683295
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
(cherry picked from commit 456a90aa16)
Reviewed-on: https://go-review.googlesource.com/c/go/+/684016
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2025-06-25 12:28:15 -07:00
Paul Murphy
7d08a16fba [release-branch.go1.24] cmd/compile/internal/ssa: fix PPC64 merging of (AND (S[RL]Dconst ...)
CL 622236 forgot to check the mask was also a 32 bit rotate mask. Add
a modified version of isPPC64WordRotateMask which valids the mask is
contiguous and fits inside a uint32.

I don't this is possible when merging SRDconst, the first check should
always reject such combines. But, be extra careful and do it there
too.

Fixes #74098

Change-Id: Ie95f74ec5e7d89dc761511126db814f886a7a435
Reviewed-on: https://go-review.googlesource.com/c/go/+/679775
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/680835
2025-06-11 20:49:41 -07:00
Keith Randall
5f2cbe1f64 [release-branch.go1.24] cmd/compile: do nil check before calling duff functions, on arm64 and amd64
On these platforms, we set up a frame pointer record below
the current stack pointer, so when we're in duffcopy or duffzero,
we get a reasonable traceback. See #73753.

But because this frame pointer record is below SP, it is vulnerable.
Anything that adds a new stack frame to the stack might clobber it.
Which actually happens in #73748 on amd64. I have not yet come across
a repro on arm64, but might as well be safe here.

The only real situation this could happen is when duffzero or duffcopy
is passed a nil pointer. So we can just avoid the problem by doing the
nil check outside duffzero/duffcopy. That way we never add a frame
below duffzero/duffcopy. (Most other ways to get a new frame below the
current one, like async preempt or debugger-generated calls, don't
apply to duffzero/duffcopy because they are runtime functions; we're
not allowed to preempt there.)

Longer term, we should stop putting stuff below SP. #73753 will
include that as part of its remit. But that's not for 1.25, so we'll
do the simple thing for 1.25 for this issue.

Fixes #73908

Change-Id: I913c49ee46dcaee8fb439415a4531f7b59d0f612
Reviewed-on: https://go-review.googlesource.com/c/go/+/676916
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
(cherry picked from commit dbaa2d3e65)
Reviewed-on: https://go-review.googlesource.com/c/go/+/677095
2025-06-11 20:48:50 -07:00
Gopher Robot
6796ebb2cb [release-branch.go1.24] go1.24.4
Change-Id: Iec14150cd12e445c3bd927c26f2a54387ba18577
Reviewed-on: https://go-review.googlesource.com/c/go/+/679218
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Bypass: Carlos Amedee <carlos@golang.org>
2025-06-05 11:35:04 -07:00
Neal Patel
85897ca220 [release-branch.go1.24] net/http: strip sensitive proxy headers from redirect requests
Similarly to Authentication entries, Proxy-Authentication entries should be stripped to ensure sensitive information is not leaked on redirects outside of the original domain.

https://fetch.spec.whatwg.org/#authentication-entries

Thanks to Takeshi Kaneko (GMO Cybersecurity by Ierae, Inc.) for reporting this issue.

Updates golang/go#73816
Fixes golang/go#73906
Fixes CVE-2025-4673

Change-Id: I8a0f30d5d6bff6c71689bba6efa0b747947e7eb0
Reviewed-on: https://go-review.googlesource.com/c/go/+/679256
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-06-05 11:10:09 -07:00
Damien Neil
9f9cf28f8f [release-branch.go1.24] os: don't follow symlinks on Windows when O_CREATE|O_EXCL
(This cherry-pick includes both CL 672396 and CL 676655.)

Match standard Unix behavior: Symlinks are not followed when
O_CREATE|O_EXCL is passed to open.

Thanks to Junyoung Park and Dong-uk Kim of KAIST Hacking Lab
for discovering this issue.

For #73702
Fixed #73720
Fixes CVE-2025-0913

Change-Id: Ieb46a6780c5e9a6090b09cd34290f04a8e3b0ca5
Reviewed-on: https://go-review.googlesource.com/c/go/+/672396
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/677215
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Bypass: Michael Knyszek <mknyszek@google.com>
2025-05-29 10:56:18 -07:00
Cherry Mui
a31c931adf [release-branch.go1.24] cmd/link: allow linkname reference to a TEXT symbol regardless of size
In CL 660696, we made the linker to choose the symbol of the
larger size in case there are multiple contentless declarations of
the same symbol. We also made it emit an error in the case that
there are a contentless declaration of a larger size and a
definition with content of a smaller size. In this case, we should
choose the definition with content, but the code accesses it
through the declaration of the larger size could fall into the
next symbol, potentially causing data corruption. So we disallowed
it.

There is one spcial case, though, that some code uses a linknamed
variable declaration to reference a function in assembly, in order
to take its address. The variable is often declared as uintptr.
The function symbol is the definition, which could sometimes be
shorter. This would trigger the error case above, causing existing
code failing to build.

This CL allows it as a special case. It is still not safe to
access the variable's content. But it is actually okay to just
take its address, which the existing code often do.

Updates #73617.
Fixes #73832.

Change-Id: I467381bc5f6baa16caee6752a0a824c7185422f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/676636
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit 70109eb326)
Reviewed-on: https://go-review.googlesource.com/c/go/+/676957
2025-05-29 08:12:17 -07:00
Roland Shoemaker
03811ab1b3 [release-branch.go1.24] crypto/x509: decouple key usage and policy validation
Disabling key usage validation (by passing ExtKeyUsageAny)
unintentionally disabled policy validation. This change decouples these
two checks, preventing the user from unintentionally disabling policy
validation.

Thanks to Krzysztof Skrzętnicki (@Tener) of Teleport for reporting this
issue.

Updates #73612
Fixes #73700
Fixes CVE-2025-22874

Change-Id: Iec8f080a8879a3dd44cb3da30352fa3e7f539d40
Reviewed-on: https://go-review.googlesource.com/c/go/+/670375
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Stapleton Cordasco <graffatcolmingov@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit 9bba799955)
Reviewed-on: https://go-review.googlesource.com/c/go/+/672316
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-05-28 12:34:55 -07:00
Filippo Valsorda
04a9473847 [release-branch.go1.24] lib/fips140: set inprocess.txt to v1.0.0
Updates #70200
Fixes #73809

Change-Id: I6a6a46567ce0834fb4b7f28bf06646326f8e5105
Reviewed-on: https://go-review.googlesource.com/c/go/+/674935
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-05-28 10:21:28 -07:00
Vladislav Yarmak
db8f1dc948 [release-branch.go1.24] hash/maphash: hash channels in purego version of maphash.Comparable
This change makes purego implementation of maphash.Comparable consistent
with the one in runtime and fixes hashing of channels.

For #73657
Fixes #73669

Change-Id: If78a21d996f0c20c0224d4014e4a4177b09c3aa3
GitHub-Last-Rev: 2537216a1e
GitHub-Pull-Request: golang/go#73660
Reviewed-on: https://go-review.googlesource.com/c/go/+/671655
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: qiu laidongfeng2 <2645477756@qq.com>
(cherry picked from commit 1635aed941)
Reviewed-on: https://go-review.googlesource.com/c/go/+/676817
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2025-05-28 10:09:08 -07:00
Sean Liao
664cf832ec [release-branch.go1.24] runtime/debug: document DefaultGODEBUG as a BuildSetting
For #66465
Fixes #73678

Change-Id: I60c017ddba29fa5b452b665d8521cd6c8e20438c
Reviewed-on: https://go-review.googlesource.com/c/go/+/597979
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiu laidongfeng2 <2645477756@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
(cherry picked from commit c4136a433c)
Reviewed-on: https://go-review.googlesource.com/c/go/+/671995
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-05-28 09:32:59 -07:00
Josh Rickmar
431f75a0b9 [release-branch.go1.24] os: fix Root.Mkdir permission bits on OpenBSD
Pass missing mode bits in the mkdirat() syscall wrapper.

For #73559
Fixes #73570

Change-Id: I54b1985bd77b1fe5d1a48acab9f2597f8c931854
GitHub-Last-Rev: 669c17361d
GitHub-Pull-Request: golang/go#73565
Reviewed-on: https://go-review.googlesource.com/c/go/+/669375
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
(cherry picked from commit f0a9ed7dd89f35c187830742402cfebba9d6d33a)
Reviewed-on: https://go-review.googlesource.com/c/go/+/669397
Reviewed-by: Joel Sing <joel@sing.id.au>
2025-05-12 06:46:12 -07:00
Gopher Robot
34c8b14ca9 [release-branch.go1.24] go1.24.3
Change-Id: I83acf5f2bda35ee81abbbb2fc6143fa6c8e342aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/670456
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-05-06 11:13:03 -07:00
Damien Neil
8947f3395e [release-branch.go1.24] os: avoid escape from Root via paths ending in ../
The doInRoot function operates on a path split into components.
The final path component retained any trailing path separator
characters, to permit operations in a Root to retain the
trailing-separator behavior of non-Root operations. However,
doInRoot failed to take trailing separators into account
when checking for .. path components.

This could permit opening the parent directory of the Root
with a path ending in "../".

Change the split path to never include path separators in
components, and handle trailing separators independently
of the split path.

Thanks to Dan Sebastian Thrane of SDU eScience Center for
reporting this issue.

Fixes #73556
Updates #73555
Fixes CVE-2025-22873

Change-Id: I9a33a145c22f5eb1dd4e4cafae5fcc61a8d4f0d4
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2160
Reviewed-by: Neal Patel <nealpatel@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2180
Commit-Queue: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/670357
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-05-06 10:29:09 -07:00
David Chase
06fd2f115b [release-branch.go1.24] cmd/compile: remove no-longer-necessary recursive inlining checks
this does result in a little bit more inlining,
cmd/compile text is 0.5% larger,
bent-benchmark text geomeans grow by only 0.02%.
some of our tests make assumptions about inlining.

Fixes: #73440.

Change-Id: I999d1798aca5dc64a1928bd434258a61e702951a
Reviewed-on: https://go-review.googlesource.com/c/go/+/655157
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/666555
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-04-29 10:12:17 -07:00
Zxilly
f66ab6521c [release-branch.go1.24] cmd/internal/obj/wasm: use i64 for large return addr
Use i64 to avoid overflow when getting PC_F from the return addr.

For #73246.
Fixes #73281.

Change-Id: I5683dccf7eada4b8536edf53e2e83116a2f6d943
GitHub-Last-Rev: 267d9a1a03
GitHub-Pull-Request: golang/go#73277
Reviewed-on: https://go-review.googlesource.com/c/go/+/663995
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
(cherry picked from commit d60a684c87)
Reviewed-on: https://go-review.googlesource.com/c/go/+/668615
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-04-29 10:11:30 -07:00
Dimitri John Ledkov
c1f9c2c7b0 [release-branch.go1.24] cmd/go/internal/load: join incompatible and dirty build specifiers with .
Change "+incompatible+dirty" version to be "+incompatible.dirty" such
that it is SemVer spec compatible.

Fixes #73500

Change-Id: I714ffb3f1ad88c793656c3652367db34739a2144
Reviewed-on: https://go-review.googlesource.com/c/go/+/652955
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Michael Matloob <matloob@golang.org>
(cherry picked from commit a6e7445457)
Reviewed-on: https://go-review.googlesource.com/c/go/+/668135
2025-04-28 13:41:55 -07:00
Michael Pratt
0ab64e2caa [release-branch.go1.24] runtime: cleanup M vgetrandom state before dropping P
When an M is destroyed, we put its vgetrandom state back on the shared
list for another M to reuse. This list is simply a slice, so appending
to the slice may allocate. Currently this operation is performed in
mdestroy, after the P is released, meaning allocation is not allowed.

More the cleanup earlier in mdestroy when allocation is still OK.

Also add //go:nowritebarrierrec to mdestroy since it runs without a P,
which would have caught this bug.

Fixes #73144.
For #73141.

Change-Id: I6a6a636c3fbf5c6eec09d07a260e39dbb4d2db12
Reviewed-on: https://go-review.googlesource.com/c/go/+/662455
Reviewed-by: Jason Donenfeld <Jason@zx2c4.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
(cherry picked from commit 0b31e6d4cc)
Reviewed-on: https://go-review.googlesource.com/c/go/+/662496
2025-04-28 10:33:46 -07:00
Mateusz Poliwczak
56eb99859d [release-branch.go1.24] internal/runtime/maps: pass proper func PC to race.WritePC/race.ReadPC
Fixes #73192
For #73191

Change-Id: I0f8a5a19faa745943a98476c7caf4c97ccdce184
Reviewed-on: https://go-review.googlesource.com/c/go/+/663175
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
(cherry picked from commit 14b15a2bea)
Reviewed-on: https://go-review.googlesource.com/c/go/+/663777
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-04-28 10:31:34 -07:00
Keith Randall
43130aff52 [release-branch.go1.24] runtime: fix 9-arg syscall on darwin/amd64
The last 3 arguments need to be passed on the stack, not registers.

Fixes #73379

Change-Id: Ib1155ad1a805957fad3d9594c93981a558755591
Reviewed-on: https://go-review.googlesource.com/c/go/+/665435
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
(cherry picked from commit 9d7de04838)
Reviewed-on: https://go-review.googlesource.com/c/go/+/665995
2025-04-28 10:28:37 -07:00
古大羊
b2c005e7b2 [release-branch.go1.24] crypto/tls: fix ECH compatibility
Previously, the code only checked supportedVersions[0] for TLS 1.3
However, Chromium-based
browsers may list TLS 1.3 at different positions, causing ECH failures.
This fix:
    Iterates through supportedVersions to accept connections as long as TLS 1.3 is present.
    Improves ECH compatibility, ensuring Chrome, Edge, and other browsers work properly.

Fixes #73118

Change-Id: I32f4219fb6654d5cc22c7f33497c6142c0acb4f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/648015
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
(cherry picked from commit cd2f347c61)
Reviewed-on: https://go-review.googlesource.com/c/go/+/661936
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: 古大羊 <lj1788@gmail.com>
2025-04-28 10:22:47 -07:00
Cherry Mui
a9d9b55709 [release-branch.go1.24] cmd/link: choose one with larger size for duplicated BSS symbols
When two packages declare a variable with the same name (with
linkname at least on one side), the linker will choose one as the
actual definition of the symbol if one has content (i.e. a DATA
symbol) and the other does not (i.e. a BSS symbol). When both have
content, it is redefinition error. When neither has content,
currently the choice is sort of arbitrary (depending on symbol
loading order, etc. which are subject to change).

One use case for that is that one wants to reference a symbol
defined in another package, and the reference side just wants to
see some of the fields, so it may be declared with a smaller type.
In this case, we want to choose the one with the larger size as
the true definition. Otherwise the code accessing the larger
sized one may read/write out of bounds, corrupting the next
variable. This CL makes the linker do so.

Also include the followup fix CL 661915.

Fixes #73092.
Updates #72032.

Change-Id: I160aa9e0234702066cb8f141c186eaa89d0fcfed
Reviewed-on: https://go-review.googlesource.com/c/go/+/660696
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@golang.org>
(cherry picked from commit 8f6c083d7b)
Reviewed-on: https://go-review.googlesource.com/c/go/+/662335
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2025-04-10 08:34:54 -07:00
Damien Neil
fa7217f74d [release-branch.go1.24] os: avoid panic in Root when symlink references the root
We would panic when opening a symlink ending in ..,
where the symlink references the root itself.

For #73081
Fixes #73082

Change-Id: I7dc3f041ca79df7942feec58c197fde6881ecae5
Reviewed-on: https://go-review.googlesource.com/c/go/+/661416
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit cfc784a152)
Reviewed-on: https://go-review.googlesource.com/c/go/+/662315
2025-04-03 11:49:16 -07:00
Gopher Robot
49860cf92a [release-branch.go1.24] go1.24.2
Change-Id: I8e6c68d7fff0519e2bdbc48f6dbf153bc40c02cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/661916
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-04-01 09:11:46 -07:00
Austin Clements
f3a302358f [release-branch.go1.24] testing: detect a stopped timer in B.Loop
Currently, if the user stops the timer in a B.Loop benchmark loop, the
benchmark will run until it hits the timeout and fails.

Fix this by detecting that the timer is stopped and failing the
benchmark right away. We avoid making the fast path more expensive for
this check by "poisoning" the B.Loop iteration counter when the timer
is stopped so that it falls back to the slow path, which can check the
timer.

This causes b to escape from B.Loop, which is totally harmless because
it was already definitely heap-allocated. But it causes the
test/inline_testingbloop.go errorcheck test to fail. I don't think the
escape messages actually mattered to that test, they just had to be
matched. To fix this, we drop the debug level to -m=1, since -m=2
prints a lot of extra information for escaping parameters that we
don't want to deal with, and change one error check to allow b to
escape.

Fixes #72974.

Change-Id: I7d4abbb1ec1e096685514536f91ba0d581cca6b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/659657
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/660558
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2025-03-26 09:44:03 -07:00
Austin Clements
1d755aa488 [release-branch.go1.24] testing: detect early return from B.Loop
Currently, if a benchmark function returns prior to B.Loop() returning
false, we'll report a bogus result. While there was no way to detect
this with b.N-style benchmarks, one way b.Loop()-style benchmarks are
more robust is that we *can* detect it.

This CL adds a flag to B that tracks if B.Loop() has finished and
checks it after the benchmark completes. If there was an early exit
(not caused by another error), it reports a B.Error.

For #72974.

Change-Id: I731c1350e6df938c0ffa08fcedc11dc147e78854
Reviewed-on: https://go-review.googlesource.com/c/go/+/659656
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/660557
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2025-03-26 09:41:07 -07:00
Austin Clements
9204aca6c2 [release-branch.go1.24] testing: separate b.Loop counter from b.N
Currently, b.Loop uses b.N as the iteration count target. However,
since it updates the target as it goes, the behavior is quite
different from a b.N-style benchmark. To avoid user confusion, this CL
gives b.Loop a separate, unexported iteration count target. It ensures
b.N is 0 within the b.Loop loop to help catch misuses, and commits the
final iteration count to b.N only once the loop is done (as the
documentation states "After Loop returns false, b.N contains the total
number of iterations that ran, so the benchmark may use b.N to compute
other average metrics.")

Since there are now two variables used by b.Loop, we put them in an
unnamed struct. Also, we rename b.loopN to b.loop.i because this
variable tracks the current iteration index (conventionally "i"), not
the target (conventionally "n").

Unfortunately, a simple renaming causes B.Loop to be too large for the
inliner. Thus, we make one simplification to B.Loop to keep it under
the threshold. We're about to lean into that simplification anyway in
a follow-up CL, so this is just temporary.

For #72974.

Change-Id: Ide1c4f1b9ca37f300f3beb0e60ba6202331b183e
Reviewed-on: https://go-review.googlesource.com/c/go/+/659655
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/660556
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2025-03-26 09:41:02 -07:00
Andy Pan
0ae3ca0a20 [release-branch.go1.24] runtime: explicitly disable async preempt for internal/runtime
Fixes #72115
For #71591
Relevant CL 560155

Change-Id: Iebc497d56b36d50c13a6dd88e7bca4578a03cf63
Reviewed-on: https://go-review.googlesource.com/c/go/+/654916
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
(cherry picked from commit 92a63bdfee)
Reviewed-on: https://go-review.googlesource.com/c/go/+/660857
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2025-03-26 09:38:08 -07:00
Michael Pratt
dae59b594c [release-branch.go1.24] runtime: skip TestCgoCallbackPprof on platforms with broken profiling
CL 658035 added TestCgoCallbackPprof, which is consistently failing on
solaris. runtime/pprof maintains a list of platforms where CPU profiling
does not work properly. Since this test requires CPU profiling, skip the
this test on those platforms.

For #72870.
For #72876.
For #72872.

Change-Id: I6a6a636cbf6b16abcbba8771178fe1d001be9d9b
Reviewed-on: https://go-review.googlesource.com/c/go/+/658415
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/658416
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-03-25 11:51:27 -07:00
Michael Pratt
b7fd97ae3e [release-branch.go1.24] runtime: only set isExtraInC if there are no Go frames left
mp.isExtraInC is intended to indicate that this M has no Go frames at
all; it is entirely executing in C.

If there was a cgocallback to Go and then a cgocall to C, such that the
leaf frames are C, that is fine. e.g., traceback can handle this fine
with SetCgoTraceback (or by simply skipping the C frames).

However, we currently mismanage isExtraInC, unconditionally setting it
on return from cgocallback. This means that if there are two levels of
cgocallback, we end up running Go code with isExtraInC set.

1. C-created thread calls into Go function 1 (via cgocallback).
2. Go function 1 calls into C function 1 (via cgocall).
3. C function 1 calls into Go function 2 (via cgocallback).
4. Go function 2 returns back to C function 1 (returning via the remainder of cgocallback).
5. C function 1 returns back to Go function 1 (returning via the remainder of cgocall).
6. Go function 1 is now running with mp.isExtraInC == true.

The fix is simple; only set isExtraInC on return from cgocallback if
there are no more Go frames. There can't be more Go frames unless there
is an active cgocall out of the Go frames.

For #72870.
Fixes #72872.

Cq-Include-Trybots: luci.golang.try:go1.24-linux-amd64-longtest
Change-Id: I6a6a636c4e7ba75a29639d7036c5af3738033467
Reviewed-on: https://go-review.googlesource.com/c/go/+/658035
Reviewed-by: Cherry Mui <cherryyz@google.com>
Commit-Queue: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit 577bb3d0ce)
Reviewed-on: https://go-review.googlesource.com/c/go/+/658056
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2025-03-25 11:51:24 -07:00
Rob Findley
311096a6a2 [release-branch.go1.24] go/types,types2: allocate the used* maps in initFiles
As described in the associated comment, we need to reallocate usedVars
and usedPkgNames in initFiles, as they are nilled out at the end of
Checker.Files, which may be called multiple times.

For #72122
For #72826

Change-Id: I9f6eb86e072d9d43a8720f6a5e86d827de6006a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/655437
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
(cherry picked from commit fe9b292b11)
Reviewed-on: https://go-review.googlesource.com/c/go/+/657695
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@google.com>
2025-03-25 09:47:46 -07:00
Rob Findley
e9162e7e22 [release-branch.go1.24] go/types,types2: externalize used objects
The 'used' field on Var and PkgName is fundamentally an aspect of the
type checking pass: it records when objects are used, for the purposes
of reporting errors for unused variables or package names. While
expedient and performant, recording this information in the types.Object
instances themselves increases the memory footprint of type-checked
packages, and (as we saw in golang/go#71817) can lead to data races when
Objects are reused in follow-up type checking, such as is done with the
CheckExpr and Eval APIs.

Fix this by externalizing the 'used' information into two maps (one for
variables and one for packages) on the types.Checker, so that they are
garbage-collected after type checking, and cannot be a source of data
races.

Benchmarks showed essentially no change in performance.

For #72826

Change-Id: I40daeabe4ecaca3bcb494e2f1c62a04232098e49
Reviewed-on: https://go-review.googlesource.com/c/go/+/650796
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
(cherry picked from commit 9189921e47)
Reviewed-on: https://go-review.googlesource.com/c/go/+/657675
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2025-03-25 09:45:16 -07:00
Junyang Shao
d107ee90df [release-branch.go1.24] testing: allow manual timer control in testing.B.Loop
Fixes #72934

Change-Id: I56610d2d11d151a8f95b6434bbedbfcd5c11c317
Reviewed-on: https://go-review.googlesource.com/c/go/+/658975
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/660555
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-03-25 08:50:14 -07:00
Jordan Liggitt
213f1566ee [release-branch.go1.24] internal/godebugs: fix changed version for winsymlink and winreadlinkvolume to 1.23
https://go.dev/doc/godebug#go-123 documents changes to winsymlink and
winreadlinkvolume in Go 1.23.

This fixes the registered "changed" minor version to Go 1.23,
so that defaults when building a Go 1.22 module are correct.

Fixes #72938

Change-Id: I5d5bf31ca04f9e95208fb0fdaad2232f9db653ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/659035
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
(cherry picked from commit 2e749a645a)
Reviewed-on: https://go-review.googlesource.com/c/go/+/659036
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2025-03-24 15:37:49 -07:00
Damien Neil
ac1f5aa3d6 [release-branch.go1.24] net/http: reject newlines in chunk-size lines
Unlike request headers, where we are allowed to leniently accept
a bare LF in place of a CRLF, chunked bodies must always use CRLF
line terminators. We were already enforcing this for chunk-data lines;
do so for chunk-size lines as well. Also reject bare CRs anywhere
other than as part of the CRLF terminator.

Fixes CVE-2025-22871
Fixes #72011
For #71988

Change-Id: Ib0e21af5a8ba28c2a1ca52b72af8e2265ec79e4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/652998
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit d31c805535)
Reviewed-on: https://go-review.googlesource.com/c/go/+/657056
2025-03-18 12:40:27 -07:00
Damien Neil
fd29397dca [release-branch.go1.24] net/http: don't modify caller's tls.Config.NextProtos
Clone the input slice before adjusting NextProtos
to add or remove "http/1.1" and "h2" entries,
so as not to modify a slice that the caller might be using.
(We clone the tls.Config that contains the slice, but
that's a shallow clone.)

For #72100
Fixes #72103

Change-Id: I9f228b8fb6f6f2ca5023179ec114929c002dbda9
Reviewed-on: https://go-review.googlesource.com/c/go/+/654875
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/657215
2025-03-17 14:37:18 -07:00
Alexandr Primak
4524009ba6 [release-branch.go1.24] runtime: Added usage example for the runtime.AddCleanup() function.
The existing description of the function lacks usage examples, which makes it difficult to understand, so I added one.

There is no open issue about this, since the implementation seems trivial.

For #72795
Fixes #72796

Change-Id: I96b29f0b21d1c7fda04128239633c8a2fc36fef2
Reviewed-on: https://go-review.googlesource.com/c/go/+/649995
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit 4c75671871)
Reviewed-on: https://go-review.googlesource.com/c/go/+/656815
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-03-17 14:36:28 -07:00
Filippo Valsorda
bd1bc8a6e7 [release-branch.go1.24] crypto/tls: allow P-521 in FIPS 140-3 mode and Go+BoringCrypto
Partially reverts CL 587296, restoring the Go+BoringCrypto 1.23 behavior
in terms of supported curves.

Updates #71757
Fixes #72823

Change-Id: I6a6a465651a8407056fd0fae091d10a945b37997
Reviewed-on: https://go-review.googlesource.com/c/go/+/657135
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: David Chase <drchase@google.com>
2025-03-17 14:33:52 -07:00
David Chase
c2a34bedee [release-branch.go1.24] cmd/compile: use inline-Pos-based recursion test
Look at the inlining stack of positions for a call site,
if the line/col/file of the call site appears in that
stack, do not inline.  This subsumes all the other
recently-added recursive inlining checks, but they are
left in to make this easier+safer to backport.

Fixes #72822

Change-Id: I0f487bb0d4c514015907c649312672b7be464abd
Reviewed-on: https://go-review.googlesource.com/c/go/+/655155
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
(cherry picked from commit cad4dca518)
Reviewed-on: https://go-review.googlesource.com/c/go/+/657075
2025-03-12 13:50:58 -07:00
Cuong Manh Le
0ace2d8aca [release-branch.go1.24] cmd/compile: fix out of memory when inlining closure
CL 629195 strongly favor closure inlining, allowing closures to be
inlined more aggressively.

However, if the closure body contains a call to a function, which itself
is one of the call arguments, it causes the infinite inlining.

Fixing this by prevent this kind of functions from being inlinable.

Fixes #72067

Change-Id: I5fb5723a819b1e2c5aadb57c1023ec84ca9fa53c
Reviewed-on: https://go-review.googlesource.com/c/go/+/654195
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/654517
Commit-Queue: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
2025-03-05 13:27:11 -08:00
Junyang Shao
e4119e9b74 [release-branch.go1.24] all: updates vendored x/net
This is to update module version to the fixed x/net.

For #71984

Change-Id: I7d50e302e8ba7d3ee28df2669fc16f19c12cf088
Reviewed-on: https://go-review.googlesource.com/c/go/+/654795
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-03-04 12:31:16 -08:00
Gopher Robot
339c903a75 [release-branch.go1.24] go1.24.1
Change-Id: I774fcee39151f830ad58fd1677239bc0207c6679
Reviewed-on: https://go-review.googlesource.com/c/go/+/654319
Auto-Submit: Gopher Robot <gobot@golang.org>
Auto-Submit: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-04 11:27:08 -08:00
Damien Neil
334de7982f [release-branch.go1.24] all: updated vendored x/net with security fix
6ed00d0 [internal-branch.go1.24-vendor] proxy, http/httpproxy: do not mismatch IPv6 zone ids against hosts

Fixes CVE-2025-22870
For #71986

Change-Id: I7bda0825f1a9470b0708714d9cc32b5eae212f8b
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2121
Reviewed-by: Neal Patel <nealpatel@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Commit-Queue: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/654715
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2025-03-04 10:41:47 -08:00
Ian Lance Taylor
5d6920842b [release-branch.go1.24] runtime/cgo: avoid errors from -Wdeclaration-after-statement
CL 652181 accidentally missed this iPhone only code.

For #71961
For #71963

Change-Id: I567f8bb38958907442e69494da330d5199d11f54
Reviewed-on: https://go-review.googlesource.com/c/go/+/653137
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-26 14:41:34 -08:00
Keith Randall
949eae84df [release-branch.go1.24] cmd/compile: don't pull constant offsets out of pointer arithmetic
This could lead to manufacturing a pointer that points outside
its original allocation.

Bug was introduced in CL 629858.

Fixes #71938

Change-Id: Ia86ab0b65ce5f80a8e0f4f4c81babd07c5904f8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/652078
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
(cherry picked from commit 8b8bff7bb2)
Reviewed-on: https://go-review.googlesource.com/c/go/+/652855
2025-02-26 12:15:08 -08:00
Michael Anthony Knyszek
0bfde51e0d [release-branch.go1.24] runtime: document that cleanups can run concurrently with each other
For #71825.
Fixes #71955.

Change-Id: I25af19eb72d75f13cf661fc47ee5717782785326
Reviewed-on: https://go-review.googlesource.com/c/go/+/652637
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2025-02-26 12:04:21 -08:00
Ian Lance Taylor
45a52718e3 [release-branch.go1.24] runtime/cgo: avoid errors from -Wdeclaration-after-statement
It's used by the SWIG CI build, at least, and it's an easy fix.

Fixes #71963
For #71961

Change-Id: Id21071a5aef216b35ecf0e9cd3e05d08972d92fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/652181
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
(cherry picked from commit 76c7028253)
Reviewed-on: https://go-review.googlesource.com/c/go/+/652936
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-02-26 11:46:33 -08:00
qiulaidongfeng
7f375e2c22 [release-branch.go1.24] reflect: let Value.Seq return the iteration value correct type
Fixes #71916
For #71905

Change-Id: I50a418f8552e071c6e5011af5b9accc7d41548d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/651855
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
(cherry picked from commit 194696f1d1)
Reviewed-on: https://go-review.googlesource.com/c/go/+/652895
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2025-02-26 11:11:37 -08:00
Zxilly
4070531920 [release-branch.go1.24] syscall: disable O_DIRECTORY on Windows for js/wasm
O_DIRECTORY is not available on all platforms, as described at

https://nodejs.org/docs/latest/api/fs.html#file-open-constants .

On Windows, only O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR,
O_TRUNC, O_WRONLY, and UV_FS_O_FILEMAP are available.

For #71758.
Fixes #71977.

Change-Id: Iacc890ba9a30dcd75eb746ec324fa0c3e368048e
GitHub-Last-Rev: a0160e8fc8
GitHub-Pull-Request: golang/go#71770
Reviewed-on: https://go-review.googlesource.com/c/go/+/650015
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
(cherry picked from commit ad8b33002b)
Reviewed-on: https://go-review.googlesource.com/c/go/+/652835
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-02-26 10:08:02 -08:00
Michael Anthony Knyszek
5ffdb9c88b [release-branch.go1.24] reflect: correctly handle method values in Seq
Currently method values aren't correctly handled in Seq because we call
canRangeFunc on the reciever type, not the method value type, when we're
handling a method value. reflect.Value.Type has the logic to obtain the
method value type from the Value.

This change slightly refactors reflect.Value.Type into a separate
function so we can obtain the correct type as an abi.Type and pass it
off to canRangeFunc (and canRangeFunc2).

For #71874.
Fixes #71876.

Change-Id: Ie62dfca2a84b8f2f816bb87ff1ed1a58a7bb8122
Reviewed-on: https://go-review.googlesource.com/c/go/+/651416
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
(cherry picked from commit d93f6df0cc)
Reviewed-on: https://go-review.googlesource.com/c/go/+/651515
2025-02-26 09:53:54 -08:00
Michael Pratt
becc17ebcd [release-branch.go1.24] runtime: use WCLONE when waiting on pidfd test child
As of CL 650835, the pidfd test child no longer sends SIGCHLD on exit.
Per clone(2), "If [the child termination] signal is specified as
anything other than SIGCHLD, then the parent process must specify the
__WALL or __WCLONE options when waiting for the child with wait(2)."

Align with this requirement.

For #71849.
For #71828.

Change-Id: I6a6a636c739e4a59abe1533fe429a433e8588939
Reviewed-on: https://go-review.googlesource.com/c/go/+/651415
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit e1e65ae3ee)
Reviewed-on: https://go-review.googlesource.com/c/go/+/651476
2025-02-26 09:45:51 -08:00
Ian Lance Taylor
d418e224ae [release-branch.go1.24] syscall: don't send child signal when testing pidfd
Avoid a spurious SIGCHLD the first time we start a process.

For #71828
Fixes #71849

Change-Id: I744100d21bf6aaaaafc99bc5eec9f9f807a50682
Reviewed-on: https://go-review.googlesource.com/c/go/+/651035
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-02-26 09:45:47 -08:00
Jorropo
456eaf5c29 [release-branch.go1.24] cmd/compile: don't report newLimit discovered when unsat happens multiple times
Fixes #71855

Change-Id: I696fcb8fc8c0c2e5e5ae6ab50596f6bdb9b7d498
Reviewed-on: https://go-review.googlesource.com/c/go/+/650975
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
(cherry picked from commit 00635de759)
Reviewed-on: https://go-review.googlesource.com/c/go/+/652179
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-02-26 09:44:53 -08:00
Michael Pratt
e4ef83383e [release-branch.go1.24] debug/buildinfo: base64-encode test binaries
Overzealous security scanners don't like the Go 1.17 binary because they
think it has every 1.17 security vulnerability. base64-encode the binary
to hide from them.

I've also extended the instructions to make the binary easier to
reproduce.

Since we do the Go binary, we might as well do the C binary too, as it
apparently makes some virus scanners unhappy.

Fixes #71858.
For #71753.
For #71734.
For #71821.

Change-Id: I6a6a636cccbf5312522f52f27f74eded64048fb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/651175
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
(cherry picked from commit af00524a6c)
Reviewed-on: https://go-review.googlesource.com/c/go/+/651235
2025-02-26 09:44:08 -08:00
khr@golang.org
4e6d3468cc [release-branch.go1.24] cmd/compile: ensure we don't reuse temporary register
Before this CL, we could use the same register for both a temporary
register and for moving a value in the output register out of the way.

Fixes #71904

Change-Id: Iefbfd9d4139136174570d8aadf8a0fb391791ea9
Reviewed-on: https://go-review.googlesource.com/c/go/+/651221
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
(cherry picked from commit cc16fb52e6)
Reviewed-on: https://go-review.googlesource.com/c/go/+/652178
2025-02-26 09:43:51 -08:00
Ian Lance Taylor
f5c388313f [release-branch.go1.24] internal/godebugs: add fips140 as an opaque godebug setting
This permits using "godebug fips140=on" in go.mod and
using "//go:debug fips140=on" in the main package.

Change code references to the godebug setting to remove the #
which is no longer required.

For #71666
Fixes #71745

Change-Id: I3a60ecc55b03848dadd6d431eb43137b6df6568b
Reviewed-on: https://go-review.googlesource.com/c/go/+/649495
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
(cherry picked from commit 2b43ce0a9d5825d66aa42a6fa9076f2fb9c181ea)
Reviewed-on: https://go-review.googlesource.com/c/go/+/650675
Commit-Queue: Ian Lance Taylor <iant@google.com>
2025-02-25 21:52:03 -08:00
David Chase
af236716b2 [release-branch.go1.24] cmd/compile, runtime: use deferreturn as target PC for recover from deferrangefunc
The existing code for recover from deferrangefunc was broken in
several ways.

1. the code following a deferrangefunc call did not check the return
value for an out-of-band value indicating "return now" (i.e., recover
was called)

2. the returned value was delivered using a bespoke ABI that happened
to match on register-ABI platforms, but not on older stack-based
ABI.

3. the returned value was the wrong width (1 word versus 2) and
type/value(integer 1, not a pointer to anything) for deferrangefunc's
any-typed return value (in practice, the OOB value check could catch
this, but still, it's sketchy).

This -- using the deferreturn lookup method already in place for
open-coded defers -- turned out to be a much-less-ugly way of
obtaining the desired transfer of control for recover().

TODO: we also could do this for regular defer, and delete some code.

Fixes #71840

Change-Id: If7d7ea789ad4320821aab3b443759a7d71647ff0
Reviewed-on: https://go-review.googlesource.com/c/go/+/650476
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/651497
2025-02-21 18:58:02 -08:00
Ian Lance Taylor
0f7b7600fb [release-branch.go1.24] doc/godebug: mention GODEBUG=fips140
For #71666
For #71745

Change-Id: Ice816cf2943c5b6660f05934b4c7ca38545714b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/648520
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
(cherry picked from commit 5f65e5cb56)
Reviewed-on: https://go-review.googlesource.com/c/go/+/650596
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-02-19 13:59:08 -08:00
Cuong Manh Le
eb58df7dbf [release-branch.go1.24] cmd/compile: avoid infinite recursion when inlining closures
CL 630696 changes budget for once-called closures, making them more
inlinable. However, when recursive inlining involve both the closure and
its parent, the inliner goes into an infinite loop:

	parent (a closure)  -> closure -> parent -> ...

The problem here dues to the closure name mangling, causing the inlined
checking condition failed, since the closure name affects how the
linker symbol generated.

To fix this, just prevent the closure from inlining its parent into
itself, avoid the infinite inlining loop.

Fixes #71829

Change-Id: Ib27626d70f95e5f1c24a3eb1c8e6c3443b7d90c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/649656
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/650555
2025-02-19 13:49:27 -08:00
qmuntal
30f4d9e117 [release-branch.go1.24] syscall: don't truncate newly created files on Windows
There is no need for syscall.OpenFile to truncate newly created files.
Some special Windows files, like the NUL device, can't be
truncated, so we should avoid truncating unless it is really necessary.

For #71752
Fixes #71836

Change-Id: I8238048594f706f6a5281053d55cfe3dc898828d
Reviewed-on: https://go-review.googlesource.com/c/go/+/650276
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
(cherry picked from commit 4267fd389e)
Reviewed-on: https://go-review.googlesource.com/c/go/+/650597
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
2025-02-19 10:46:24 -08:00
Paul Murphy
bb0e5c2045 [release-branch.go1.24] runtime: fix usleep on s390x/linux
The timespec argument takes the remainder in nanoseconds, not
microseconds. Convert the remaining time to nsec.

Fixes #71728

Change-Id: I36cbbe3a088830c5e3afcc9516ef42e96ee21268
Reviewed-on: https://go-review.googlesource.com/c/go/+/648915
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Axel Busch <axel.busch@ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Vishwanatha HD <vishwanatha.hd@ibm.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/649375
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-02-19 09:14:47 -08:00
段仪
cd0e528d3d [release-branch.go1.24] runtime: add some linknames back for github.com/bytedance/sonic
Add some linknames back, therefore sonic (github.com/bytedance/sonic) can work correctly.

For #71672
Fixes #71705

Change-Id: Iae86c837d8a714855106a26766aa08b128e17e58
GitHub-Last-Rev: 4de0a48717
GitHub-Pull-Request: golang/go#71673
Reviewed-on: https://go-review.googlesource.com/c/go/+/650375
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-02-19 09:12:30 -08:00
Quan Tong
80e2e474b8 [release-branch.go1.24] cmd/go: initialize req.Header when loading git credential
Fixes #71687

Change-Id: I3d733a50b4451dfb571aba91a28387ba9e0614dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/647615
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
(cherry picked from commit 58834c3ee0)
Reviewed-on: https://go-review.googlesource.com/c/go/+/648936
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2025-02-12 11:16:33 -08:00
Gopher Robot
3901409b5d [release-branch.go1.24] go1.24.0
Change-Id: I98457f219e75fb99233804d15c8b9577ee3d4a24
Reviewed-on: https://go-review.googlesource.com/c/go/+/648555
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-02-11 09:55:39 -08:00
Cherry Mui
35c0ea22a9 [release-branch.go1.24] bytes: use "subslice" instead of "substring" in doc comments
The bytes package iterators return subslices, not substrings.

Updates #61901.

Change-Id: Ida91d3e33a0f178edfe9a267861adf4f13f9a965
Reviewed-on: https://go-review.googlesource.com/c/go/+/647875
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit ff27d270c9)
Reviewed-on: https://go-review.googlesource.com/c/go/+/648095
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Bypass: Cherry Mui <cherryyz@google.com>
2025-02-10 11:50:28 -08:00
Michael Anthony Knyszek
6d399e9da6 [release-branch.go1.24] os: hide SetFinalizer from users of Root
Currently Root embeds a root and calls SetFinalizer on &r.root. This
sets the finalizer on the outer root, which is visible to users of
os.Root, and thus they can mutate the finalizer attached to it.

This change modifies Root to not embed its inner root, but rather to
refer to it by pointer. This allows us to set the finalizer on this
independent inner object, preventing users of os.Root from changing the
finalizer. This follows the same pattern as os.File's finalizer.

Fixes #71617.

Change-Id: Ibd199bab1b3c877d5e12ef380fd4647b4e10221f
Reviewed-on: https://go-review.googlesource.com/c/go/+/647876
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit a704d39b29)
Reviewed-on: https://go-review.googlesource.com/c/go/+/648135
TryBot-Bypass: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2025-02-10 10:48:31 -08:00
thepudds
b7b4c60585 [release-branch.go1.24] weak: prevent unsafe conversions using weak pointers
Prevent conversions between Pointer types,
like we do for sync/atomic.Pointer.

Fixes #71583

Change-Id: I20e83106d8a27996f221e6cd9d52637b0442cea4
Reviewed-on: https://go-review.googlesource.com/c/go/+/647195
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
(cherry picked from commit 8163ea1458)
Reviewed-on: https://go-review.googlesource.com/c/go/+/647435
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Bypass: Cherry Mui <cherryyz@google.com>
2025-02-06 13:53:01 -08:00
Gopher Robot
18068cb96a [release-branch.go1.24] go1.24rc3
Change-Id: Ib3e93a2ea07a0ef1ce0989143d03c765ede8cc99
Reviewed-on: https://go-review.googlesource.com/c/go/+/646936
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Bypass: Cherry Mui <cherryyz@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
2025-02-05 12:35:01 -08:00
Roland Shoemaker
c43ac38b3b [release-branch.go1.24] Revert "cmd/go/internal/work: allow @ character in some -Wl, linker flags on darwin"
This reverts commit e3cd55e9d2.

This change introduced a security issue as @ flags are first resolved as
files by the darwin linker, before their meaning as flags, allowing the
flag filtering logic to be entirely bypassed.

Thanks to Juho Forsén for reporting this issue.

Fixes #71476
Fixes CVE-2025-22867

Change-Id: I3a4b4a6fc534de105d930b8ed5b9900bc94b0c4e
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1900
Reviewed-by: Russ Cox <rsc@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
(cherry picked from commit cc0d725a4168f234ef38859b2d951a50a8fd94b5)
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1940
Reviewed-by: Neal Patel <nealpatel@google.com>
Commit-Queue: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/646995
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Bypass: Cherry Mui <cherryyz@google.com>
2025-02-05 11:57:13 -08:00
Carlos Amedee
4241f582fc [release-branch.go1.24] all: merge master (37f27fb) into release-branch.go1.24
Conflicts:

- src/cmd/go/testdata/script/goauth_netrc.txt

Merge List:

+ 2025-01-31 37f27fbecd cmd/go: enable fips test and fix caching bug
+ 2025-01-31 77d20838e9 cmd: update golang.org/x/tools to CL 645697, and revendor
+ 2025-01-30 ce7ea0a6a5 cmd/go: refine GOAUTH user parsing to be more strict
+ 2025-01-29 e81f715515 lib/fips140: freeze v1.0.0 FIPS 140 module zip file
+ 2025-01-29 4f48ad5c6b cmd/link/internal/loader: fix linknames from FIPS 140 frozen tree
+ 2025-01-29 1f58ad5d6d Revert "os: employ sendfile(2) for file-to-file copying on Linux when needed"
+ 2025-01-28 90ec9996cb crypto/pbkdf2: add keyLength limit
+ 2025-01-28 62cd7cb6cd crypto/hkdf: check error in TestFIPSServiceIndicator
+ 2025-01-28 7764c502e2 crypto/internal/sysrand: skip TestNoGetrandom without cgo
+ 2025-01-28 50455385b0 internal/coverage: fix bug in text-format coverage output with multiple packages
+ 2025-01-28 28d389ef30 internal/godebug: check error from os.ReadFile in test
+ 2025-01-28 8071f2a169 runtime: mapiter linkname compatibility layer
+ 2025-01-28 78e6f2a1c8 runtime: rename mapiterinit and mapiternext
+ 2025-01-28 4ebd5bf855 internal/goexperiment: update location of baseline experiment in comment
+ 2025-01-27 f8937cb625 archive/zip, archive/tar: writer appends slash to directory names
+ 2025-01-27 11e08d9d96 strconv: adjust comment so that gofmt doesn't mung it
+ 2025-01-27 b9872221cd crypto/internal/fips140/rsa: avoid CAST unsetting the service indicator
+ 2025-01-27 3f791c8dfb crypto/internal/fips140/aes: set FIPS 140 service indicator for CTR and CBC
+ 2025-01-27 e0aeee82f3 crypto/ecdsa: avoid needless ScalarBaseMult in s390x
+ 2025-01-27 f70aa3824b cmd/go: do not call base.fatal for an unset HOME for GOAUTH=netrc
+ 2025-01-27 475e08349d Revert "runtime: Check LSE support on ARM64 at runtime init"
+ 2025-01-27 e2e700f8b1 crypto/internal/boring: keep ECDH public key alive during cgo calls
+ 2025-01-22 608acff847 go/types: avoid importer.Default
+ 2025-01-22 9d21ef3bd4 runtime: fix the equality check in AddCleanup
+ 2025-01-22 5a46b17b5f os: force a goroutine to be scheduled on WASM
+ 2025-01-22 6fc23a3cff crypto/internal/fips140/nistec: make p256NegCond constant time on ppc64le
+ 2025-01-22 70b603f4d2 go/importer: document limitations of this API
+ 2025-01-21 f6d17c5400 net/http: update bundled golang.org/x/net/http2 [generated]
+ 2025-01-21 3aa7c5ef01 testing: fix reference to B.N in docstring
+ 2025-01-20 3f4164f508 runtime: delete out of date comment
+ 2025-01-17 40b3c0e58a internal/coverage: refactor EmitTextual in preparation for bugfix
+ 2025-01-17 87023bb27f go/types, types2: ensure deterministic output when reporting an init cycle
+ 2025-01-17 80bf7d83ed go/types, types2: remove superfluous assertion (fix build)
+ 2025-01-16 1a93e4a2cf lib/time: update to 2025a/2025a
+ 2025-01-16 0b632d26b9 cmd/internal/obj/wasm, runtime: detect wasmexport call before runtime initialization
+ 2025-01-16 6a4effa08b crypto/x509: avoid panic when parsing partial PKCS#1 private keys
+ 2025-01-16 139d6eedae cmd/go: restore netrc preferences for GOAUTH and fix domain lookup
+ 2025-01-16 2b2314e9f6 crypto/x509: properly check for IPv6 hosts in URIs
+ 2025-01-16 6783377295 net/http: persist header stripping across repeated redirects
+ 2025-01-14 368a9ec998 encoding/json: cleanup tests
+ 2025-01-14 bd80d8956f cmd/go/internal/modfetch: do not trust server to send all tags in shallow fetch
+ 2025-01-14 4fa61d6f9c cmd/api: report error in test instead of crashing
+ 2025-01-14 c5e205e928 internal/runtime/maps: re-enable some tests
+ 2025-01-14 befc43655b testing/fstest: fix function name and comment
+ 2025-01-14 c83f2ca4b3 cmd/dist: ignore packages with no Go files in BenchmarkAll
+ 2025-01-13 6da16013ba cmd/go: check go version when parsing go.mod fails
+ 2025-01-13 de9fdc7b71 syscall/js: adjust comments to that gofmt does not change them
+ 2025-01-13 17ed215958 go/types, types2: don't panic when instantiating generic alias with wrong number of type arguments
+ 2025-01-13 c53307c3fd spec: fix grammar issue
+ 2025-01-13 47a56b2b6d encoding/json: add cases to TestUnmarshal for fatal syntactic errors
+ 2025-01-13 7bb192a1c5 encoding/json: always check resulting Go value for unmarshaling
+ 2025-01-12 44a6f817ea cmd/compile: fix write barrier coalescing
+ 2025-01-10 19e923182e crypto/internal/fips140test: add hmac DRBG ACVP tests
+ 2025-01-10 7255b94920 crypto/internal/fips140test: add ML-KEM ACVP tests
+ 2025-01-09 932ec2be8d crypto/rsa: fix GenerateKey flakes for toy-sized keys
+ 2025-01-09 d0c9142ce3 runtime/pprof: hide map runtime frames from heap profiles
+ 2025-01-09 c7c4420ae4 cmd/go: clarify GODEBUG in go help environment
+ 2025-01-09 c6ab13fc43 cmd/go/internal/mmap: reslice to file size on Windows
+ 2025-01-09 f5a89dff67 crypto: fix fips140=only detection of SHA-3
+ 2025-01-08 4225c6cb37 encoding/json: improve fidelity of TestUnmarshal for Numbers
+ 2025-01-08 c87a6f932e crypto/mlkem: merge mlkem768.go and mlkem1024.go to improve godoc
+ 2025-01-08 f57a3a7c04 crypto/mlkem: add example and improve docs
+ 2025-01-08 c9afcbade7 go/types, types2: require iterator yield to return bool (work-around)
+ 2025-01-08 54693a81fd crypto/md5,crypto/sha1: apply fips140=only to Write and Sum, not New
+ 2025-01-08 0cdf8c7a8c crypto/ecdsa: apply fips140=only to deterministic ECDSA hash
+ 2025-01-08 4640e92af7 crypto/rsa: apply fips140=only to opts.Hash in SignPSS

Change-Id: I443d8d9433e7f504905b60652d3fcd975e5f674b
2025-01-31 12:45:08 -05:00
Gopher Robot
8a4c24f9bb [release-branch.go1.24] go1.24rc2
Change-Id: I37362fe37c47078c17f3f6f610d8ca7664985bd0
Reviewed-on: https://go-review.googlesource.com/c/go/+/643157
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-01-16 12:13:48 -08:00
Filippo Valsorda
3de5aca7d0 [release-branch.go1.24] crypto/x509: avoid panic when parsing partial PKCS#1 private keys
These keys are off-spec, but have historically been accepted by
ParsePKCS1PrivateKey.

Thanks to Philippe Antoine (Catena cyber) for reporting this issue.

Fixes #71216
Fixes CVE-2025-22865

Change-Id: I6a6a46564156fa32e29e8d6acbec3fbac47c7352
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1820
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Commit-Queue: Roland Shoemaker <bracewell@google.com>
(cherry picked from commit 36c6c8b6957e155770461fd710aea9477ef3bc88)
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1841
Reviewed-on: https://go-review.googlesource.com/c/go/+/643102
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-16 11:36:09 -08:00
Sam Thanawalla
8336dfde70 [release-branch.go1.24] cmd/go: restore netrc preferences for GOAUTH and fix domain lookup
Store netrc lines into the credential map backward so that earlier lines
take priority over later lines. This matches Go 1.23 netrc lookup which
stopped at the first match it found.
Additionally, this fixes a security issue related to domain parsing
which could have allowed servers to read credentials belonging to other
servers. The fix was to switch from using path.Dir(currentPrefix) to
strings.Cut(currentPrefix, "/")

Thanks to Juho Forsén of Mattermost for reporting this issue.

Fixes #71249
Fixes CVE-2024-45340

Change-Id: I175a00d6d7f4d31c9e4d79b7cf1c2a0ad35b2781
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1781
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Commit-Queue: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
(cherry picked from commit 76833d221aa3ccc978b6f41bd24e26babf771375)
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1840
Reviewed-on: https://go-review.googlesource.com/c/go/+/643101
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2025-01-16 11:36:07 -08:00
Damien Neil
6b60550504 [release-branch.go1.24] net/http: persist header stripping across repeated redirects
When an HTTP redirect changes the host of a request, we drop
sensitive headers such as Authorization from the redirected request.
Fix a bug where a chain of redirects could result in sensitive
headers being sent to the wrong host:

  1. request to a.tld with Authorization header
  2. a.tld redirects to b.tld
  3. request to b.tld with no Authorization header
  4. b.tld redirects to b.tld
  3. request to b.tld with Authorization header restored

Thanks to Kyle Seely for reporting this issue.

For #70530
Fixes #71212
Fixes CVE-2024-45336

Change-Id: Ia58a2e10d33d6b0cc7220935e771450e5c34de72
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1641
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Commit-Queue: Roland Shoemaker <bracewell@google.com>
(cherry picked from commit 2889169b87a61f1218a02994feb80fd3d8bfa87c)
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1766
Reviewed-on: https://go-review.googlesource.com/c/go/+/643100
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-01-16 11:36:03 -08:00
Roland Shoemaker
468fad45a2 [release-branch.go1.24] crypto/x509: properly check for IPv6 hosts in URIs
When checking URI constraints, use netip.ParseAddr, which understands
zones, unlike net.ParseIP which chokes on them. This prevents zone IDs
from mistakenly satisfying URI constraints.

Thanks to Juho Forsén of Mattermost for reporting this issue.

For #71156
Fixes #71209
Fixes CVE-2024-45341

Change-Id: Iecac2529f3605382d257996e0fb6d6983547e400
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1700
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
(cherry picked from commit 22ca55d396ba801e6ae9b2bd67a059fcb30562fd)
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1800
Commit-Queue: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/643099
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-01-16 11:08:59 -08:00
Michael Pratt
e06b6fc58d [release-branch.go1.24] all: merge master (e966a27) into release-branch.go1.24
Merge List:

+ 2025-01-08 e966a2773c crypto/internal/fips140/drbg: avoid global lock on rand state

Change-Id: I1ca8f6bf2ba14ff3d5c4183a26cbd51ac20dad0a
2025-01-08 14:01:58 -05:00
Michael Pratt
b3799ba634 [release-branch.go1.24] all: merge master (9a44df6) into release-branch.go1.24
Merge List:

+ 2025-01-08 9a44df6675 cmd/go/testdata/script: fix TestScript/env_gocacheprog on Windows
+ 2025-01-08 f025d19e7b runtime: hold traceAcquire across casgstatus in injectglist
+ 2025-01-08 1e9835f5b1 internal/sync: fix typo of panic message
+ 2025-01-07 39f2032c17 testing/synctest: add some examples
+ 2025-01-07 b50ccef67a cmd/go/internal/modindex: don't write index entry if file open
+ 2025-01-07 b2aa18b96c cmd/internal/hash: stop using md5, sha1
+ 2025-01-07 d93b549f05 cmd/go/internal/cache: handle cacheprog not responding to close
+ 2025-01-07 d62154db83 weak: don't panic when calling Value on a zero Pointer
+ 2025-01-07 9d0772b23e cmd/compile/internal/syntax: add test case for invalid label use
+ 2025-01-07 1d20bce981 go/types, types2: expand documentation for Info.Types map
+ 2025-01-07 a9bd6239a4 cmd/go/internal/env: add GOCACHEPROG to go env output
+ 2025-01-07 850b276a67 crypto/tls: send illegal_parameter on invalid ECHClientHello.type
+ 2025-01-06 27c5164374 crypto/internal/fips140: zeroise integrity test temporary values
+ 2025-01-06 d8ad4af78b cmd/internal/disasm: correct instruction length handling for riscv64
+ 2025-01-06 a76cc5a4ec crypto/rsa: use λ(N) instead of φ(N)
+ 2025-01-06 3f002abb60 internal/sync: add test from issue 70970
+ 2025-01-06 7a2e88e911 net/http: update NewRequestWithContext wrong link to NewRequest
+ 2025-01-06 c112c0af13 Revert "internal/sync: optimize CompareAndSwap and Swap"
+ 2025-01-03 705b5a569a crypto/ecdsa: drop SEC 1 reference from package doc
+ 2025-01-03 f966695cce context: use "canceled" in docs to refer to timed-out contexts
+ 2025-01-03 5da026354c cmd/go/internal/vcweb: close the .access file
+ 2025-01-03 31cabcf084 crypto/internal/fips140: mark OpenBSD unsupported
+ 2025-01-03 eb0c2b2f96 crypto/internal/fips140: add Supported
+ 2025-01-03 f0a9b6df45 internal/fuzz: remove the exp2 method
+ 2025-01-03 5d626c49ec spec: fix a dead link
+ 2025-01-03 81566aff3a internal/exportdata: add missing return
+ 2025-01-03 e7a8bd5d8b crypto/internal/fips140/check: remove Enabled
+ 2025-01-02 4b652e9f5f cmd/go: fix two typos in helpdoc.go
+ 2025-01-02 0afd7e85e5 cmd/go: document GOCACHEPROG in go help environment
+ 2025-01-02 3c8e5b13df cmd/go/internal/cacheprog: drop redundant Prog prefixes
+ 2025-01-02 20da34c6d2 cmd/go: move GOCACHEPROG protocol types to their own package
+ 2025-01-02 858a0e9dfd crypto/tls: properly return ECH retry configs
+ 2025-01-02 a63aee4955 cmd/go: improve GOCACHEPROG types documentation
+ 2025-01-02 847c357bbb cmd/go: remove references to gopath-get
+ 2025-01-01 d1d9312950 crypto/tls: fix Config.Time in tests using expired certificates
+ 2024-12-31 94f15810e6 cmd/go: document default GOARM value
+ 2024-12-30 856a7bc8e9 builtin: use list instead of indentation for comments in cap, len, and make
+ 2024-12-30 5efb4239c6 spec: document that string conversions don't guarantee result slice capacity
+ 2024-12-30 0d8aa8cce6 spec: describe representation of values
+ 2024-12-30 8857a5a33f crypto/tls: fix misspelling in comment
+ 2024-12-30 3c4102bfd4 encoding/binary: add documentation for endian methods
+ 2024-12-30 b702a26cf8 os: mention fsys modifications during CopyFS
+ 2024-12-30 15f232456a encoding/json: remove suggestion on Unmarshaler with JSON null
+ 2024-12-30 ba1deb1cee cmd/link: document that -s implies -w
+ 2024-12-30 fd5e0d26d9 go/doc: resolve imports before predeclared identifiers in examples
+ 2024-12-30 a785d11ac4 unique: fix typo
+ 2024-12-27 2b794ed86c encoding/json: expand and modernize TestInterfaceSet
+ 2024-12-27 e3cd55e9d2 cmd/go/internal/work: allow @ character in some -Wl, linker flags on darwin
+ 2024-12-27 39794819aa doc/initial: remove fixed-width spacing notice
+ 2024-12-27 7c03fe70b8 cmd/compile: improve compiler directive docs
+ 2024-12-27 d7c3e93c16 iter: improve documentation with iterator example
+ 2024-12-26 cce75da30b crypto/mlkem: swap order of return values of Encapsulate
+ 2024-12-23 772f024c61 weak: fix typo in warning about tiny allocator optimization
+ 2024-12-23 b9955f0ad9 cmd/link, runtime: apply a delta to RODATA->DATA relocations
+ 2024-12-23 eef35e3bd9 internal/goexperiment: run go generate for synctest
+ 2024-12-23 9f6c80a76a cmd/go/internal/work: allow single character values in -Wl, linker flags
+ 2024-12-22 05d8984781 net: document LookupTXT behavior with multiple strings per record
+ 2024-12-21 500675a7c8 cmd/compile: load map length with the right type
+ 2024-12-21 06b191e11f internal/syscall/unix: apply fstatat fix to linux/mips64le
+ 2024-12-21 110ab1aaf4 slices: document two oddities
+ 2024-12-19 669d87a935 runtime/pprof: continued attempt to deflake the VMInfo test.
+ 2024-12-19 45f49139f5 runtime: test trap panic parsing in TestTracebackSystem
+ 2024-12-19 e63eb98e98 net/http: fix nil panic in test
+ 2024-12-19 7b6c94dd03 cmd/go: drop fips140 build ID hacks
+ 2024-12-19 cb72406c36 cmd/go: fix two-step toolchain upgrade through go install, GOTOOLCHAIN
+ 2024-12-18 4f0561f9d3 cmd/dist: skip fips140test in exe mode on Android
+ 2024-12-18 87dbfb9fa7 weak: improve grammar in doc comments
+ 2024-12-18 f4e3ec3dbe crypto/ecdsa: fix condition for fips140=only check
+ 2024-12-18 6aa46eb750 crypto/tls: normalize spelling of "ClientHello" in comments
+ 2024-12-18 10ca5ba4ff crypto/pbkdf2: update RFC reference in package doc
+ 2024-12-18 8ff4cee564 cmd/go,crypto: reject using Go+BoringCrypto and fips140 together
+ 2024-12-18 971448ddf8 testing: support B.Context and F.Context
+ 2024-12-17 95b433eed4 debug/elf: adjust version API per issue discussion
+ 2024-12-17 b2c0168893 crypto/internal/fips140/aes/gcm: use aes.EncryptBlockInternal on ppc64x and s390x
+ 2024-12-17 b9e2ffdcd2 crypto/internal/fips140: add Name and Version
+ 2024-12-17 8790372a8d cmd, go: fix some typos
+ 2024-12-17 b057b8872d bytes, strings: add cross-references in docstrings
+ 2024-12-17 e977b83b32 cmd/go/internal/help: use secure link to swig.org
+ 2024-12-17 4ac8f552e9 syscall, internal/syscall/unix: fix fstatat on linux/mips64
+ 2024-12-17 236a0b4ffb spec: explain function invocation and passing of parameters more precisely
+ 2024-12-17 9f806bb76c go/build: streamline the crypto package graph in TestDependencies
+ 2024-12-17 0cd833d198 go/build: remove nonexistent package from TestDependencies
+ 2024-12-17 31e50af5f3 crypto/rsa: revert minimum GenerateKey size to 32 bits
+ 2024-12-17 b47ce8b0e9 crypto/cipher: block non-AES CTR and CBC in fips140=only mode
+ 2024-12-17 dd7a7ba38f crypto/internal/fips140/aes: mark AES-ECB as not approved
+ 2024-12-17 427a2401af cmd/go/testdata/script: update test_flags for new test output
+ 2024-12-17 75736cc169 fmt, strconv: document that exponent is always two digits
+ 2024-12-16 1218566fe5 cmd/link: update runtime dependency list
+ 2024-12-16 d92c34a387 cmd/go: don't create test actions for incomplete packages
+ 2024-12-16 3bd08b9792 runtime: usleep in TestWeakToStrongMarkTermination
+ 2024-12-15 18b5435fc8 testing: don't measure cleanup time after B.Loop
+ 2024-12-15 c1f2542c8b testing: improve B.Loop test
+ 2024-12-15 6bd56fcaeb testing: improve b.Loop example
+ 2024-12-15 090748d6c7 testing: improve B.Loop docs, use B.Loop in examples
+ 2024-12-13 e39e965e0e cmd/go: drop FailedBuild field if gotestjsonbuildtext=1
+ 2024-12-13 08770a5b94 cmd/link: make dwarf name slice index self-describing
+ 2024-12-13 c4f356dd86 crypto/ecdsa: fix s390x assembly with P-521
+ 2024-12-13 08725f9de2 crypto/internal/cryptotest: skip TestAllocations on s390x
+ 2024-12-13 1cbfe8c482 fmt: add more function and allocation tests
+ 2024-12-13 8391579ece runtime: migrate missing map linkname allowlists
+ 2024-12-12 80a2982a80 spec: align EBNF rules consistently (cosmetic change)
+ 2024-12-12 38e9a671d7 syscall: on freebsd-386 only update written for certain errors
+ 2024-12-12 6f7a4540b1 net: fix example function name for IP.To4
+ 2024-12-12 14e5093ee5 cmd/internal/obj: disallow linknamed access to builtin symbols
+ 2024-12-12 fb764cdad0 cmd/link: block new standard library linknames

Change-Id: Ie423f050db80034c3af6c12bd6007db273c5d281
2025-01-08 13:21:10 -05:00
Gopher Robot
16afa6a740 [release-branch.go1.24] go1.24rc1
Change-Id: Ia3b0a8ec25312b73879d2561a2b4d1cfc648c295
Reviewed-on: https://go-review.googlesource.com/c/go/+/636036
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Gopher Robot <gobot@golang.org>
TryBot-Bypass: Carlos Amedee <carlos@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-12-13 08:52:10 -08:00
Carlos Amedee
817d7bdc0a [release-branch.go1.24] all: merge master (9118060) into release-branch.go1.24
Merge List:

+ 2024-12-12 9118060040 builtin: document clear is a no-op if its argument's value is nil
+ 2024-12-11 077d51909d internal/poll: in SendFile treat ENOTSUP like EOPNOTSUPP
+ 2024-12-11 fafd4477f3 cmd/cgo: use full prototype for main in C code

Change-Id: I4c4941eff4a1e842920eb9be47d28351af0e4c36
2024-12-12 12:06:37 -05:00
Carlos Amedee
14bb1e11b9 [release-branch.go1.24] all: merge master (0ca521f) into release-branch.go1.24
Merge List:

+ 2024-12-11 0ca521f9c1 debug/elf: adjust version API per issue discussion

Change-Id: Ibd6f628528dd366837ad0bbacad624474eee0088
2024-12-11 18:55:28 -05:00
Carlos Amedee
2297c34cdf [release-branch.go1.24] all: merge master (c93477b) into release-branch.go1.24
Merge List:

+ 2024-12-11 c93477b5e5 crypto: use provided random Reader in FIPS mode
+ 2024-12-11 3104b6adbb log/slog: make DiscardHandler example package-level
+ 2024-12-11 5424f2e200 cmd/go: add more tests for GOAUTH's user provided authenticator
+ 2024-12-11 d5c1333eb4 net/http: document zero value of Protocols
+ 2024-12-11 a7c4cadce0 cmd/compile: update broken link
+ 2024-12-11 979c1cfbe8 net: avoid unnecessary interface lookup fetching all interface addresses
+ 2024-12-11 e424d78c3d internal/goos: fix bug in gengoos.go
+ 2024-12-11 6c25cf1c5f cmd/internal/objfile: break out dissassemblers to another package
+ 2024-12-11 e0c76d95ab syscall: remove a wrong comment in Clearenv
+ 2024-12-11 a9922d096f reflect: consistently document when value must be settable
+ 2024-12-10 4ce116a884 runtime: avoid panic in expired synctest timer chan read
+ 2024-12-10 e6de1b2deb html/template: escape script tags in JS errors case insensitively
+ 2024-12-10 fce17b0c77 crypto/internal/fips140/ecdsa: fix reseed_counter check for HMAC_DRBG_Generate_algorithm
+ 2024-12-09 d87878c62b runtime: make special offset a uintptr
+ 2024-12-09 6705ac6885 runtime: remove datadog-agent from prof labels hall of shame
+ 2024-12-09 07398d2e57 weak: align weak.Pointer documentation with runtime.AddCleanup
+ 2024-12-09 e3e1d73528 bufio: make the description of Peek's behavior better
+ 2024-12-09 e79b2e1e3a cmd/go: document the build cache as safe for concurrent use
+ 2024-12-08 c8fb6ae617 lib/wasm: provide fs.constants.O_DIRECTORY definition
+ 2024-12-07 8c3e391573 runtime: improve AddCleanup documentation
+ 2024-12-07 04cdaa9984 cmd/go: document c-shared buildmode for building WASI library/reactor
+ 2024-12-06 312f7c1bd3 runtime: add note that Callers never returns an entry PC

Change-Id: I52e035228121de3d8219ab13f195d4293daaaa34
2024-12-11 17:45:39 -05:00
Michael Anthony Knyszek
26682773ca [release-branch.go1.24] update codereview.cfg for release-branch.go1.24
Change-Id: I63ffca43a935bc5ff060f19c01152a20182cba03
Reviewed-on: https://go-review.googlesource.com/c/go/+/634317
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2024-12-06 21:58:36 +00:00
4015 changed files with 132379 additions and 487581 deletions

1
.gitignore vendored
View File

@@ -30,7 +30,6 @@ _testmain.go
/misc/cgo/testso/main
/pkg/
/src/*.*/
/src/_artifacts/
/src/cmd/cgo/zdefaultcc.go
/src/cmd/dist/dist
/src/cmd/go/internal/cfg/zdefaultcc.go

2
VERSION Normal file
View File

@@ -0,0 +1,2 @@
go1.24.9
time 2025-10-13T16:08:43Z

View File

@@ -1,111 +0,0 @@
pkg crypto, func SignMessage(Signer, io.Reader, []uint8, SignerOpts) ([]uint8, error) #63405
pkg crypto, type MessageSigner interface { Public, Sign, SignMessage } #63405
pkg crypto, type MessageSigner interface, Public() PublicKey #63405
pkg crypto, type MessageSigner interface, Sign(io.Reader, []uint8, SignerOpts) ([]uint8, error) #63405
pkg crypto, type MessageSigner interface, SignMessage(io.Reader, []uint8, SignerOpts) ([]uint8, error) #63405
pkg crypto/ecdsa, func ParseRawPrivateKey(elliptic.Curve, []uint8) (*PrivateKey, error) #63963
pkg crypto/ecdsa, func ParseUncompressedPublicKey(elliptic.Curve, []uint8) (*PublicKey, error) #63963
pkg crypto/ecdsa, method (*PrivateKey) Bytes() ([]uint8, error) #63963
pkg crypto/ecdsa, method (*PublicKey) Bytes() ([]uint8, error) #63963
pkg crypto/sha3, method (*SHA3) Clone() (hash.Cloner, error) #69521
pkg crypto/tls, type Config struct, GetEncryptedClientHelloKeys func(*ClientHelloInfo) ([]EncryptedClientHelloKey, error) #71920
pkg crypto/tls, type ConnectionState struct, CurveID CurveID #67516
pkg debug/elf, const PT_RISCV_ATTRIBUTES = 1879048195 #72843
pkg debug/elf, const PT_RISCV_ATTRIBUTES ProgType #72843
pkg debug/elf, const SHT_RISCV_ATTRIBUTES = 1879048195 #72843
pkg debug/elf, const SHT_RISCV_ATTRIBUTES SectionType #72843
pkg go/ast, const FilterFuncDuplicates //deprecated #73088
pkg go/ast, const FilterImportDuplicates //deprecated #73088
pkg go/ast, const FilterUnassociatedComments //deprecated #73088
pkg go/ast, func FilterPackage //deprecated #73088
pkg go/ast, func MergePackageFiles //deprecated #73088
pkg go/ast, func PackageExports //deprecated #73088
pkg go/ast, func PreorderStack(Node, []Node, func(Node, []Node) bool) #73319
pkg go/ast, type MergeMode //deprecated #73088
pkg go/parser, func ParseDir //deprecated #71122
pkg go/token, method (*FileSet) AddExistingFiles(...*File) #73205
pkg go/types, const FieldVar = 6 #70250
pkg go/types, const FieldVar VarKind #70250
pkg go/types, const LocalVar = 2 #70250
pkg go/types, const LocalVar VarKind #70250
pkg go/types, const PackageVar = 1 #70250
pkg go/types, const PackageVar VarKind #70250
pkg go/types, const ParamVar = 4 #70250
pkg go/types, const ParamVar VarKind #70250
pkg go/types, const RecvVar = 3 #70250
pkg go/types, const RecvVar VarKind #70250
pkg go/types, const ResultVar = 5 #70250
pkg go/types, const ResultVar VarKind #70250
pkg go/types, func LookupSelection(Type, bool, *Package, string) (Selection, bool) #70737
pkg go/types, method (*Var) Kind() VarKind #70250
pkg go/types, method (*Var) SetKind(VarKind) #70250
pkg go/types, method (VarKind) String() string #70250
pkg go/types, type VarKind uint8 #70250
pkg hash, type Cloner interface { BlockSize, Clone, Reset, Size, Sum, Write } #69521
pkg hash, type Cloner interface, BlockSize() int #69521
pkg hash, type Cloner interface, Clone() (Cloner, error) #69521
pkg hash, type Cloner interface, Reset() #69521
pkg hash, type Cloner interface, Size() int #69521
pkg hash, type Cloner interface, Sum([]uint8) []uint8 #69521
pkg hash, type Cloner interface, Write([]uint8) (int, error) #69521
pkg hash, type XOF interface { BlockSize, Read, Reset, Write } #69518
pkg hash, type XOF interface, BlockSize() int #69518
pkg hash, type XOF interface, Read([]uint8) (int, error) #69518
pkg hash, type XOF interface, Reset() #69518
pkg hash, type XOF interface, Write([]uint8) (int, error) #69518
pkg hash/maphash, method (*Hash) Clone() (hash.Cloner, error) #69521
pkg io/fs, func Lstat(FS, string) (FileInfo, error) #49580
pkg io/fs, func ReadLink(FS, string) (string, error) #49580
pkg io/fs, type ReadLinkFS interface { Lstat, Open, ReadLink } #49580
pkg io/fs, type ReadLinkFS interface, Lstat(string) (FileInfo, error) #49580
pkg io/fs, type ReadLinkFS interface, Open(string) (File, error) #49580
pkg io/fs, type ReadLinkFS interface, ReadLink(string) (string, error) #49580
pkg log/slog, func GroupAttrs(string, ...Attr) Attr #66365
pkg log/slog, method (Record) Source() *Source #70280
pkg mime/multipart, func FileContentDisposition(string, string) string #46771
pkg net/http, func NewCrossOriginProtection() *CrossOriginProtection #73626
pkg net/http, method (*CrossOriginProtection) AddInsecureBypassPattern(string) #73626
pkg net/http, method (*CrossOriginProtection) AddTrustedOrigin(string) error #73626
pkg net/http, method (*CrossOriginProtection) Check(*Request) error #73626
pkg net/http, method (*CrossOriginProtection) Handler(Handler) Handler #73626
pkg net/http, method (*CrossOriginProtection) SetDenyHandler(Handler) #73626
pkg net/http, type CrossOriginProtection struct #73626
pkg os, method (*Root) Chmod(string, fs.FileMode) error #67002
pkg os, method (*Root) Chown(string, int, int) error #67002
pkg os, method (*Root) Chtimes(string, time.Time, time.Time) error #67002
pkg os, method (*Root) Lchown(string, int, int) error #67002
pkg os, method (*Root) Link(string, string) error #67002
pkg os, method (*Root) MkdirAll(string, fs.FileMode) error #67002
pkg os, method (*Root) ReadFile(string) ([]uint8, error) #73126
pkg os, method (*Root) Readlink(string) (string, error) #67002
pkg os, method (*Root) RemoveAll(string) error #67002
pkg os, method (*Root) Rename(string, string) error #67002
pkg os, method (*Root) Symlink(string, string) error #67002
pkg os, method (*Root) WriteFile(string, []uint8, fs.FileMode) error #73126
pkg reflect, func TypeAssert[$0 interface{}](Value) ($0, bool) #62121
pkg runtime, func SetDefaultGOMAXPROCS() #73193
pkg runtime/trace, func NewFlightRecorder(FlightRecorderConfig) *FlightRecorder #63185
pkg runtime/trace, method (*FlightRecorder) Enabled() bool #63185
pkg runtime/trace, method (*FlightRecorder) Start() error #63185
pkg runtime/trace, method (*FlightRecorder) Stop() #63185
pkg runtime/trace, method (*FlightRecorder) WriteTo(io.Writer) (int64, error) #63185
pkg runtime/trace, type FlightRecorder struct #63185
pkg runtime/trace, type FlightRecorderConfig struct #63185
pkg runtime/trace, type FlightRecorderConfig struct, MaxBytes uint64 #63185
pkg runtime/trace, type FlightRecorderConfig struct, MinAge time.Duration #63185
pkg sync, method (*WaitGroup) Go(func()) #63796
pkg testing, method (*B) Attr(string, string) #43936
pkg testing, method (*B) Output() io.Writer #59928
pkg testing, method (*F) Attr(string, string) #43936
pkg testing, method (*F) Output() io.Writer #59928
pkg testing, method (*T) Attr(string, string) #43936
pkg testing, method (*T) Output() io.Writer #59928
pkg testing, type TB interface, Attr(string, string) #43936
pkg testing, type TB interface, Output() io.Writer #59928
pkg testing/fstest, method (MapFS) Lstat(string) (fs.FileInfo, error) #49580
pkg testing/fstest, method (MapFS) ReadLink(string) (string, error) #49580
pkg testing/synctest, func Test(*testing.T, func(*testing.T)) #67434
pkg testing/synctest, func Wait() #67434
pkg unicode, var CategoryAliases map[string]string #70780
pkg unicode, var Cn *RangeTable #70780
pkg unicode, var LC *RangeTable #70780

View File

@@ -1,180 +0,0 @@
pkg bytes, method (*Buffer) Peek(int) ([]uint8, error) #73794
pkg crypto, type Decapsulator interface { Decapsulate, Encapsulator } #75300
pkg crypto, type Decapsulator interface, Decapsulate([]uint8) ([]uint8, error) #75300
pkg crypto, type Decapsulator interface, Encapsulator() Encapsulator #75300
pkg crypto, type Encapsulator interface { Bytes, Encapsulate } #75300
pkg crypto, type Encapsulator interface, Bytes() []uint8 #75300
pkg crypto, type Encapsulator interface, Encapsulate() ([]uint8, []uint8) #75300
pkg crypto/ecdh, type KeyExchanger interface { Curve, ECDH, PublicKey } #75300
pkg crypto/ecdh, type KeyExchanger interface, Curve() Curve #75300
pkg crypto/ecdh, type KeyExchanger interface, ECDH(*PublicKey) ([]uint8, error) #75300
pkg crypto/ecdh, type KeyExchanger interface, PublicKey() *PublicKey #75300
pkg crypto/ecdsa, type PrivateKey struct, D //deprecated #63963
pkg crypto/ecdsa, type PublicKey struct, X //deprecated #63963
pkg crypto/ecdsa, type PublicKey struct, Y //deprecated #63963
pkg crypto/fips140, func Enforced() bool #74630
pkg crypto/fips140, func Version() string #75301
pkg crypto/fips140, func WithoutEnforcement(func()) #74630
pkg crypto/hpke, func AES128GCM() AEAD #75300
pkg crypto/hpke, func AES256GCM() AEAD #75300
pkg crypto/hpke, func ChaCha20Poly1305() AEAD #75300
pkg crypto/hpke, func DHKEM(ecdh.Curve) KEM #75300
pkg crypto/hpke, func ExportOnly() AEAD #75300
pkg crypto/hpke, func HKDFSHA256() KDF #75300
pkg crypto/hpke, func HKDFSHA384() KDF #75300
pkg crypto/hpke, func HKDFSHA512() KDF #75300
pkg crypto/hpke, func MLKEM1024() KEM #75300
pkg crypto/hpke, func MLKEM1024P384() KEM #75300
pkg crypto/hpke, func MLKEM768() KEM #75300
pkg crypto/hpke, func MLKEM768P256() KEM #75300
pkg crypto/hpke, func MLKEM768X25519() KEM #75300
pkg crypto/hpke, func NewAEAD(uint16) (AEAD, error) #75300
pkg crypto/hpke, func NewDHKEMPrivateKey(ecdh.KeyExchanger) (PrivateKey, error) #75300
pkg crypto/hpke, func NewDHKEMPublicKey(*ecdh.PublicKey) (PublicKey, error) #75300
pkg crypto/hpke, func NewHybridPrivateKey(crypto.Decapsulator, ecdh.KeyExchanger) (PrivateKey, error) #75300
pkg crypto/hpke, func NewHybridPublicKey(crypto.Encapsulator, *ecdh.PublicKey) (PublicKey, error) #75300
pkg crypto/hpke, func NewKDF(uint16) (KDF, error) #75300
pkg crypto/hpke, func NewKEM(uint16) (KEM, error) #75300
pkg crypto/hpke, func NewMLKEMPrivateKey(crypto.Decapsulator) (PrivateKey, error) #75300
pkg crypto/hpke, func NewMLKEMPublicKey(crypto.Encapsulator) (PublicKey, error) #75300
pkg crypto/hpke, func NewRecipient([]uint8, PrivateKey, KDF, AEAD, []uint8) (*Recipient, error) #75300
pkg crypto/hpke, func NewSender(PublicKey, KDF, AEAD, []uint8) ([]uint8, *Sender, error) #75300
pkg crypto/hpke, func Open(PrivateKey, KDF, AEAD, []uint8, []uint8) ([]uint8, error) #75300
pkg crypto/hpke, func SHAKE128() KDF #75300
pkg crypto/hpke, func SHAKE256() KDF #75300
pkg crypto/hpke, func Seal(PublicKey, KDF, AEAD, []uint8, []uint8) ([]uint8, error) #75300
pkg crypto/hpke, method (*Recipient) Export(string, int) ([]uint8, error) #75300
pkg crypto/hpke, method (*Recipient) Open([]uint8, []uint8) ([]uint8, error) #75300
pkg crypto/hpke, method (*Sender) Export(string, int) ([]uint8, error) #75300
pkg crypto/hpke, method (*Sender) Seal([]uint8, []uint8) ([]uint8, error) #75300
pkg crypto/hpke, type AEAD interface, ID() uint16 #75300
pkg crypto/hpke, type AEAD interface, unexported methods #75300
pkg crypto/hpke, type KDF interface, ID() uint16 #75300
pkg crypto/hpke, type KDF interface, unexported methods #75300
pkg crypto/hpke, type KEM interface, DeriveKeyPair([]uint8) (PrivateKey, error) #75300
pkg crypto/hpke, type KEM interface, GenerateKey() (PrivateKey, error) #75300
pkg crypto/hpke, type KEM interface, ID() uint16 #75300
pkg crypto/hpke, type KEM interface, NewPrivateKey([]uint8) (PrivateKey, error) #75300
pkg crypto/hpke, type KEM interface, NewPublicKey([]uint8) (PublicKey, error) #75300
pkg crypto/hpke, type KEM interface, unexported methods #75300
pkg crypto/hpke, type PrivateKey interface, Bytes() ([]uint8, error) #75300
pkg crypto/hpke, type PrivateKey interface, KEM() KEM #75300
pkg crypto/hpke, type PrivateKey interface, PublicKey() PublicKey #75300
pkg crypto/hpke, type PrivateKey interface, unexported methods #75300
pkg crypto/hpke, type PublicKey interface, Bytes() []uint8 #75300
pkg crypto/hpke, type PublicKey interface, KEM() KEM #75300
pkg crypto/hpke, type PublicKey interface, unexported methods #75300
pkg crypto/hpke, type Recipient struct #75300
pkg crypto/hpke, type Sender struct #75300
pkg crypto/mlkem, method (*DecapsulationKey1024) Encapsulator() crypto.Encapsulator #75300
pkg crypto/mlkem, method (*DecapsulationKey768) Encapsulator() crypto.Encapsulator #75300
pkg crypto/mlkem/mlkemtest, func Encapsulate1024(*mlkem.EncapsulationKey1024, []uint8) ([]uint8, []uint8, error) #73627
pkg crypto/mlkem/mlkemtest, func Encapsulate768(*mlkem.EncapsulationKey768, []uint8) ([]uint8, []uint8, error) #73627
pkg crypto/rsa, func DecryptPKCS1v15 //deprecated #75302
pkg crypto/rsa, func DecryptPKCS1v15SessionKey //deprecated #75302
pkg crypto/rsa, func EncryptOAEPWithOptions(io.Reader, *PublicKey, []uint8, *OAEPOptions) ([]uint8, error) #65716
pkg crypto/rsa, func EncryptPKCS1v15 //deprecated #75302
pkg crypto/rsa, type PKCS1v15DecryptOptions //deprecated #75302
pkg crypto/tls, const QUICErrorEvent = 10 #75108
pkg crypto/tls, const QUICErrorEvent QUICEventKind #75108
pkg crypto/tls, const SecP256r1MLKEM768 = 4587 #71206
pkg crypto/tls, const SecP256r1MLKEM768 CurveID #71206
pkg crypto/tls, const SecP384r1MLKEM1024 = 4589 #71206
pkg crypto/tls, const SecP384r1MLKEM1024 CurveID #71206
pkg crypto/tls, type ClientHelloInfo struct, HelloRetryRequest bool #74425
pkg crypto/tls, type ConnectionState struct, HelloRetryRequest bool #74425
pkg crypto/tls, type QUICEvent struct, Err error #75108
pkg crypto/x509, func OIDFromASN1OID(asn1.ObjectIdentifier) (OID, error) #75325
pkg crypto/x509, method (ExtKeyUsage) OID() OID #75325
pkg crypto/x509, method (ExtKeyUsage) String() string #56866
pkg crypto/x509, method (KeyUsage) String() string #56866
pkg debug/elf, const R_LARCH_CALL36 = 110 #75562
pkg debug/elf, const R_LARCH_CALL36 R_LARCH #75562
pkg debug/elf, const R_LARCH_TLS_DESC32 = 13 #75562
pkg debug/elf, const R_LARCH_TLS_DESC32 R_LARCH #75562
pkg debug/elf, const R_LARCH_TLS_DESC64 = 14 #75562
pkg debug/elf, const R_LARCH_TLS_DESC64 R_LARCH #75562
pkg debug/elf, const R_LARCH_TLS_DESC64_HI12 = 118 #75562
pkg debug/elf, const R_LARCH_TLS_DESC64_HI12 R_LARCH #75562
pkg debug/elf, const R_LARCH_TLS_DESC64_LO20 = 117 #75562
pkg debug/elf, const R_LARCH_TLS_DESC64_LO20 R_LARCH #75562
pkg debug/elf, const R_LARCH_TLS_DESC64_PC_HI12 = 114 #75562
pkg debug/elf, const R_LARCH_TLS_DESC64_PC_HI12 R_LARCH #75562
pkg debug/elf, const R_LARCH_TLS_DESC64_PC_LO20 = 113 #75562
pkg debug/elf, const R_LARCH_TLS_DESC64_PC_LO20 R_LARCH #75562
pkg debug/elf, const R_LARCH_TLS_DESC_CALL = 120 #75562
pkg debug/elf, const R_LARCH_TLS_DESC_CALL R_LARCH #75562
pkg debug/elf, const R_LARCH_TLS_DESC_HI20 = 115 #75562
pkg debug/elf, const R_LARCH_TLS_DESC_HI20 R_LARCH #75562
pkg debug/elf, const R_LARCH_TLS_DESC_LD = 119 #75562
pkg debug/elf, const R_LARCH_TLS_DESC_LD R_LARCH #75562
pkg debug/elf, const R_LARCH_TLS_DESC_LO12 = 116 #75562
pkg debug/elf, const R_LARCH_TLS_DESC_LO12 R_LARCH #75562
pkg debug/elf, const R_LARCH_TLS_DESC_PCREL20_S2 = 126 #75562
pkg debug/elf, const R_LARCH_TLS_DESC_PCREL20_S2 R_LARCH #75562
pkg debug/elf, const R_LARCH_TLS_DESC_PC_HI20 = 111 #75562
pkg debug/elf, const R_LARCH_TLS_DESC_PC_HI20 R_LARCH #75562
pkg debug/elf, const R_LARCH_TLS_DESC_PC_LO12 = 112 #75562
pkg debug/elf, const R_LARCH_TLS_DESC_PC_LO12 R_LARCH #75562
pkg debug/elf, const R_LARCH_TLS_GD_PCREL20_S2 = 125 #75562
pkg debug/elf, const R_LARCH_TLS_GD_PCREL20_S2 R_LARCH #75562
pkg debug/elf, const R_LARCH_TLS_LD_PCREL20_S2 = 124 #75562
pkg debug/elf, const R_LARCH_TLS_LD_PCREL20_S2 R_LARCH #75562
pkg debug/elf, const R_LARCH_TLS_LE_ADD_R = 122 #75562
pkg debug/elf, const R_LARCH_TLS_LE_ADD_R R_LARCH #75562
pkg debug/elf, const R_LARCH_TLS_LE_HI20_R = 121 #75562
pkg debug/elf, const R_LARCH_TLS_LE_HI20_R R_LARCH #75562
pkg debug/elf, const R_LARCH_TLS_LE_LO12_R = 123 #75562
pkg debug/elf, const R_LARCH_TLS_LE_LO12_R R_LARCH #75562
pkg errors, func AsType[$0 error](error) ($0, bool) #51945
pkg go/ast, func ParseDirective(token.Pos, string) (Directive, bool) #68021
pkg go/ast, method (*Directive) End() token.Pos #68021
pkg go/ast, method (*Directive) ParseArgs() ([]DirectiveArg, error) #68021
pkg go/ast, method (*Directive) Pos() token.Pos #68021
pkg go/ast, type BasicLit struct, ValueEnd token.Pos #76031
pkg go/ast, type Directive struct #68021
pkg go/ast, type Directive struct, Args string #68021
pkg go/ast, type Directive struct, ArgsPos token.Pos #68021
pkg go/ast, type Directive struct, Name string #68021
pkg go/ast, type Directive struct, Slash token.Pos #68021
pkg go/ast, type Directive struct, Tool string #68021
pkg go/ast, type DirectiveArg struct #68021
pkg go/ast, type DirectiveArg struct, Arg string #68021
pkg go/ast, type DirectiveArg struct, Pos token.Pos #68021
pkg go/token, method (*File) End() Pos #75849
pkg log/slog, func NewMultiHandler(...Handler) *MultiHandler #65954
pkg log/slog, method (*MultiHandler) Enabled(context.Context, Level) bool #65954
pkg log/slog, method (*MultiHandler) Handle(context.Context, Record) error #65954
pkg log/slog, method (*MultiHandler) WithAttrs([]Attr) Handler #65954
pkg log/slog, method (*MultiHandler) WithGroup(string) Handler #65954
pkg log/slog, type MultiHandler struct #65954
pkg net, method (*Dialer) DialIP(context.Context, string, netip.Addr, netip.Addr) (*IPConn, error) #49097
pkg net, method (*Dialer) DialTCP(context.Context, string, netip.AddrPort, netip.AddrPort) (*TCPConn, error) #49097
pkg net, method (*Dialer) DialUDP(context.Context, string, netip.AddrPort, netip.AddrPort) (*UDPConn, error) #49097
pkg net, method (*Dialer) DialUnix(context.Context, string, *UnixAddr, *UnixAddr) (*UnixConn, error) #49097
pkg net/http, method (*ClientConn) Available() int #75772
pkg net/http, method (*ClientConn) Close() error #75772
pkg net/http, method (*ClientConn) Err() error #75772
pkg net/http, method (*ClientConn) InFlight() int #75772
pkg net/http, method (*ClientConn) Release() #75772
pkg net/http, method (*ClientConn) Reserve() error #75772
pkg net/http, method (*ClientConn) RoundTrip(*Request) (*Response, error) #75772
pkg net/http, method (*ClientConn) SetStateHook(func(*ClientConn)) #75772
pkg net/http, method (*Transport) NewClientConn(context.Context, string, string) (*ClientConn, error) #75772
pkg net/http, type ClientConn struct #75772
pkg net/http, type HTTP2Config struct, StrictMaxConcurrentRequests bool #67813
pkg net/http/httputil, type ReverseProxy struct, Director //deprecated #73161
pkg net/netip, method (Prefix) Compare(Prefix) int #61642
pkg os, method (*Process) WithHandle(func(uintptr)) error #70352
pkg os, var ErrNoHandle error #70352
pkg reflect, method (Value) Fields() iter.Seq2[StructField, Value] #66631
pkg reflect, method (Value) Methods() iter.Seq2[Method, Value] #66631
pkg reflect, type Type interface, Fields() iter.Seq[StructField] #66631
pkg reflect, type Type interface, Ins() iter.Seq[Type] #66631
pkg reflect, type Type interface, Methods() iter.Seq[Method] #66631
pkg reflect, type Type interface, Outs() iter.Seq[Type] #66631
pkg testing, method (*B) ArtifactDir() string #71287
pkg testing, method (*F) ArtifactDir() string #71287
pkg testing, method (*T) ArtifactDir() string #71287
pkg testing, type TB interface, ArtifactDir() string #71287
pkg testing/cryptotest, func SetGlobalRandom(*testing.T, uint64) #70942

View File

@@ -1,2 +1,2 @@
branch: dev.simd
branch: release-branch.go1.24
parent-branch: master

View File

@@ -1039,12 +1039,6 @@ The value of <code>GOMIPS64</code> environment variable (<code>hardfloat</code>
<code>GOMIPS64_hardfloat</code> or <code>GOMIPS64_softfloat</code>.
</p>
<h3 id="riscv64">RISCV64</h3>
<p>
Reference: <a href="/pkg/cmd/internal/obj/riscv">Go RISCV64 Assembly Instructions Reference Manual</a>
</p>
<h3 id="unsupported_opcodes">Unsupported opcodes</h3>
<p>

6864
doc/go1.17_spec.html Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -231,7 +231,7 @@ do exactly this.
<p>
A read of an array, struct, or complex number
may be implemented as a read of each individual sub-value
may by implemented as a read of each individual sub-value
(array element, struct field, or real/imaginary component),
in any order.
Similarly, a write of an array, struct, or complex number
@@ -453,7 +453,7 @@ crash, or do something else.)
</p>
<p class="rule">
The <i>k</i>th receive from a channel with capacity <i>C</i> is synchronized before the completion of the <i>k</i>+<i>C</i>th send on that channel.
The <i>k</i>th receive on a channel with capacity <i>C</i> is synchronized before the completion of the <i>k</i>+<i>C</i>th send from that channel completes.
</p>
<p>

View File

@@ -1,6 +1,6 @@
<!--{
"Title": "The Go Programming Language Specification",
"Subtitle": "Language version go1.26 (Dec 2, 2025)",
"Subtitle": "Language version go1.24 (Dec 30, 2024)",
"Path": "/ref/spec"
}-->
@@ -8,6 +8,8 @@
<p>
This is the reference manual for the Go programming language.
The pre-Go1.18 version, without generics, can be found
<a href="/doc/go1.17_spec.html">here</a>.
For more information and other documents, see <a href="/">go.dev</a>.
</p>
@@ -1856,10 +1858,110 @@ The underlying type of <code>[]B1</code>, <code>B3</code>, and <code>B4</code> i
The underlying type of <code>P</code> is <code>interface{}</code>.
</p>
<h3 id="Core_types">Core types</h3>
<p>
Each non-interface type <code>T</code> has a <i>core type</i>, which is the same as the
<a href="#Underlying_types">underlying type</a> of <code>T</code>.
</p>
<p>
An interface <code>T</code> has a core type if one of the following
conditions is satisfied:
</p>
<ol>
<li>
There is a single type <code>U</code> which is the <a href="#Underlying_types">underlying type</a>
of all types in the <a href="#Interface_types">type set</a> of <code>T</code>; or
</li>
<li>
the type set of <code>T</code> contains only <a href="#Channel_types">channel types</a>
with identical element type <code>E</code>, and all directional channels have the same
direction.
</li>
</ol>
<p>
No other interfaces have a core type.
</p>
<p>
The core type of an interface is, depending on the condition that is satisfied, either:
</p>
<ol>
<li>
the type <code>U</code>; or
</li>
<li>
the type <code>chan E</code> if <code>T</code> contains only bidirectional
channels, or the type <code>chan&lt;- E</code> or <code>&lt;-chan E</code>
depending on the direction of the directional channels present.
</li>
</ol>
<p>
By definition, a core type is never a <a href="#Type_definitions">defined type</a>,
<a href="#Type_parameter_declarations">type parameter</a>, or
<a href="#Interface_types">interface type</a>.
</p>
<p>
Examples of interfaces with core types:
</p>
<pre>
type Celsius float32
type Kelvin float32
interface{ int } // int
interface{ Celsius|Kelvin } // float32
interface{ ~chan int } // chan int
interface{ ~chan int|~chan&lt;- int } // chan&lt;- int
interface{ ~[]*data; String() string } // []*data
</pre>
<p>
Examples of interfaces without core types:
</p>
<pre>
interface{} // no single underlying type
interface{ Celsius|float64 } // no single underlying type
interface{ chan int | chan&lt;- string } // channels have different element types
interface{ &lt;-chan int | chan&lt;- int } // directional channels have different directions
</pre>
<p>
Some operations (<a href="#Slice_expressions">slice expressions</a>,
<a href="#Appending_and_copying_slices"><code>append</code> and <code>copy</code></a>)
rely on a slightly more loose form of core types which accept byte slices and strings.
Specifically, if there are exactly two types, <code>[]byte</code> and <code>string</code>,
which are the underlying types of all types in the type set of interface <code>T</code>,
the core type of <code>T</code> is called <code>bytestring</code>.
</p>
<p>
Examples of interfaces with <code>bytestring</code> core types:
</p>
<pre>
interface{ int } // int (same as ordinary core type)
interface{ []byte | string } // bytestring
interface{ ~[]byte | myString } // bytestring
</pre>
<p>
Note that <code>bytestring</code> is not a real type; it cannot be used to declare
variables or compose other types. It exists solely to describe the behavior of some
operations that read from a sequence of bytes, which may be a byte slice or a string.
</p>
<h3 id="Type_identity">Type identity</h3>
<p>
Two types are either <i>identical</i> ("the same") or <i>different</i>.
Two types are either <i>identical</i> or <i>different</i>.
</p>
<p>
@@ -2487,15 +2589,11 @@ type set[P comparable] = map[P]bool
</pre>
<p>
In an alias declaration the given type cannot be a type parameter declared in the same declaration.
In an alias declaration the given type cannot be a type parameter.
</p>
<pre>
type A[P any] = P // illegal: P is a type parameter declared in the declaration of A
func f[P any]() {
type A = P // ok: T is a type parameter declared by the enclosing function
}
type A[P any] = P // illegal: P is a type parameter
</pre>
<h4 id="Type_definitions">Type definitions</h4>
@@ -2605,8 +2703,8 @@ In a type definition the given type cannot be a type parameter.
<pre>
type T[P any] P // illegal: P is a type parameter
func f[P any]() {
type L P // illegal: P is a type parameter declared by the enclosing function
func f[T any]() {
type L T // illegal: T is a type parameter declared by the enclosing function
}
</pre>
@@ -2690,6 +2788,22 @@ of a <a href="#Method_declarations">method declaration</a> associated
with a generic type.
</p>
<p>
Within a type parameter list of a generic type <code>T</code>, a type constraint
may not (directly, or indirectly through the type parameter list of another
generic type) refer to <code>T</code>.
</p>
<pre>
type T1[P T1[P]] … // illegal: T1 refers to itself
type T2[P interface{ T2[int] }] … // illegal: T2 refers to itself
type T3[P interface{ m(T3[int])}] … // illegal: T3 refers to itself
type T4[P T5[P]] … // illegal: T4 refers to T5 and
type T5[P T4[P]] … // T5 refers to T4
type T6[P int] struct{ f *T6[P] } // ok: reference to T6 is not in type parameter list
</pre>
<h4 id="Type_constraints">Type constraints</h4>
<p>
@@ -3141,8 +3255,7 @@ math.Sin // denotes the Sin function in package math
<h3 id="Composite_literals">Composite literals</h3>
<p>
Composite literals construct new values for structs, arrays, slices, and maps
each time they are evaluated.
Composite literals construct new composite values each time they are evaluated.
They consist of the type of the literal followed by a brace-bound list of elements.
Each element may optionally be preceded by a corresponding key.
</p>
@@ -3160,14 +3273,10 @@ Element = Expression | LiteralValue .
</pre>
<p>
Unless the LiteralType is a type parameter,
its <a href="#Underlying_types">underlying type</a>
The LiteralType's <a href="#Core_types">core type</a> <code>T</code>
must be a struct, array, slice, or map type
(the syntax enforces this constraint except when the type is given
as a TypeName).
If the LiteralType is a type parameter, all types in its type set
must have the same underlying type which must be
a valid composite literal type.
The types of the elements and keys must be <a href="#Assignability">assignable</a>
to the respective field, element, and key types of type <code>T</code>;
there is no additional conversion.
@@ -3352,6 +3461,7 @@ noteFrequency := map[string]float32{
}
</pre>
<h3 id="Function_literals">Function literals</h3>
<p>
@@ -3824,12 +3934,11 @@ The following rules apply:
</p>
<p>
If <code>a</code> is neither a map nor a <a href="#Type_parameter_declarations">type parameter</a>:
If <code>a</code> is neither a map nor a type parameter:
</p>
<ul>
<li>the index <code>x</code> must be an untyped constant, or its type must be
an <a href="#Numeric_types">integer</a> or a type parameter whose type set
contains only integer types</li>
<li>the index <code>x</code> must be an untyped constant or its
<a href="#Core_types">core type</a> must be an <a href="#Numeric_types">integer</a></li>
<li>a constant index must be non-negative and
<a href="#Representability">representable</a> by a value of type <code>int</code></li>
<li>a constant index that is untyped is given type <code>int</code></li>
@@ -3943,26 +4052,14 @@ Assigning to an element of a <code>nil</code> map causes a
<p>
Slice expressions construct a substring or slice from a string, array, pointer
to array, or slice operand.
There are two variants: a simple form that specifies a low
to array, or slice. There are two variants: a simple form that specifies a low
and high bound, and a full form that also specifies a bound on the capacity.
</p>
<p>
If the operand type is a <a href="#Type_parameter_declarations">type parameter</a>,
unless its type set contains string types,
all types in the type set must have the same underlying type, and the slice expression
must be valid for an operand of that type.
If the type set contains string types it may also contain byte slices with underlying
type <code>[]byte</code>.
In this case, the slice expression must be valid for an operand of <code>string</code>
type.
</p>
<h4>Simple slice expressions</h4>
<p>
For a string, array, pointer to array, or slice <code>a</code>, the primary expression
The primary expression
</p>
<pre>
@@ -3970,7 +4067,9 @@ a[low : high]
</pre>
<p>
constructs a substring or slice.
constructs a substring or slice. The <a href="#Core_types">core type</a> of
<code>a</code> must be a string, array, pointer to array, slice, or a
<a href="#Core_types"><code>bytestring</code></a>.
The <i>indices</i> <code>low</code> and
<code>high</code> select which elements of operand <code>a</code> appear
in the result. The result has indices starting at 0 and length equal to
@@ -4050,7 +4149,7 @@ s3 := s[:0] // s3 == nil
<h4>Full slice expressions</h4>
<p>
For an array, pointer to array, or slice <code>a</code> (but not a string), the primary expression
The primary expression
</p>
<pre>
@@ -4061,6 +4160,8 @@ a[low : high : max]
constructs a slice of the same type, and with the same length and elements as the simple slice
expression <code>a[low : high]</code>. Additionally, it controls the resulting slice's capacity
by setting it to <code>max - low</code>. Only the first index may be omitted; it defaults to 0.
The <a href="#Core_types">core type</a> of <code>a</code> must be an array, pointer to array,
or slice (but not a string).
After slicing the array <code>a</code>
</p>
@@ -4166,8 +4267,8 @@ No <a href="#Run_time_panics">run-time panic</a> occurs in this case.
<h3 id="Calls">Calls</h3>
<p>
Given an expression <code>f</code> of <a href="#Function_types">function type</a>
<code>F</code>,
Given an expression <code>f</code> with a <a href="#Core_types">core type</a>
<code>F</code> of <a href="#Function_types">function type</a>,
</p>
<pre>
@@ -4197,12 +4298,6 @@ If <code>f</code> denotes a generic function, it must be
or used as a function value.
</p>
<p>
If the type of <code>f</code> is a <a href="#Type_parameter_declarations">type parameter</a>,
all types in its type set must have the same underlying type, which must be a function type,
and the function call must be valid for that type.
</p>
<p>
In a function call, the function value and arguments are evaluated in
<a href="#Order_of_evaluation">the usual order</a>.
@@ -4716,28 +4811,17 @@ more complicated:
<ul>
<li>
If all types in <code>C</code>'s type set have the same
underlying type <code>U</code>,
If <code>C</code> has a <a href="#Core_types">core type</a>
<code>core(C)</code>
and <code>P</code> has a known type argument <code>A</code>,
<code>U</code> and <code>A</code> must unify loosely.
</li>
<li>
Similarly, if all types in <code>C</code>'s type set are
channel types with the same element type and non-conflicting
channel directions,
and <code>P</code> has a known type argument <code>A</code>,
the most restrictive channel type in <code>C</code>'s type
set and <code>A</code> must unify loosely.
</li>
<li>
<code>core(C)</code> and <code>A</code> must unify loosely.
If <code>P</code> does not have a known type argument
and <code>C</code> contains exactly one type term <code>T</code>
that is not an underlying (tilde) type, unification adds the
mapping <code>P ➞ T</code> to the map.
</li>
<li>
If <code>C</code> does not have a type <code>U</code>
as described above
If <code>C</code> does not have a core type
and <code>P</code> has a known type argument <code>A</code>,
<code>A</code> must have all methods of <code>C</code>, if any,
and corresponding method types must unify exactly.
@@ -4861,7 +4945,7 @@ For instance, <code>x / y * z</code> is the same as <code>(x / y) * z</code>.
x &lt;= f() // x &lt;= f()
^a &gt;&gt; b // (^a) >> b
f() || g() // f() || g()
x == y+1 &amp;&amp; &lt;-chanInt &gt; 0 // (x == (y+1)) &amp;&amp; ((&lt;-chanInt) > 0)
x == y+1 &amp;&amp; &lt;-chanInt &gt; 0 // (x == (y+1)) && ((<-chanInt) > 0)
</pre>
@@ -5288,10 +5372,10 @@ var x *int = nil
<h3 id="Receive_operator">Receive operator</h3>
<p>
For an operand <code>ch</code> of <a href="#Channel_types">channel type</a>,
For an operand <code>ch</code> whose <a href="#Core_types">core type</a> is a
<a href="#Channel_types">channel</a>,
the value of the receive operation <code>&lt;-ch</code> is the value received
from the channel <code>ch</code>.
The channel direction must permit receive operations,
from the channel <code>ch</code>. The channel direction must permit receive operations,
and the type of the receive operation is the element type of the channel.
The expression blocks until a value is available.
Receiving from a <code>nil</code> channel blocks forever.
@@ -5307,12 +5391,6 @@ f(&lt;-ch)
&lt;-strobe // wait until clock pulse and discard received value
</pre>
<p>
If the operand type is a <a href="#Type_parameter_declarations">type parameter</a>,
all types in its type set must be channel types that permit receive operations, and
they must all have the same element type, which is the type of the receive operation.
</p>
<p>
A receive expression used in an <a href="#Assignment_statements">assignment statement</a> or initialization of the special form
</p>
@@ -6048,7 +6126,8 @@ len("foo") // illegal if len is the built-in function
<p>
A send statement sends a value on a channel.
The channel expression must be of <a href="#Channel_types">channel type</a>,
The channel expression's <a href="#Core_types">core type</a>
must be a <a href="#Channel_types">channel</a>,
the channel direction must permit send operations,
and the type of the value to be sent must be <a href="#Assignability">assignable</a>
to the channel's element type.
@@ -6072,13 +6151,6 @@ A send on a <code>nil</code> channel blocks forever.
ch &lt;- 3 // send value 3 to channel ch
</pre>
<p>
If the type of the channel expression is a
<a href="#Type_parameter_declarations">type parameter</a>,
all types in its type set must be channel types that permit send operations,
they must all have the same element type,
and the type of the value to be sent must be assignable to that element type.
</p>
<h3 id="IncDec_statements">IncDec statements</h3>
@@ -6623,7 +6695,7 @@ iteration's variable at that moment.
<pre>
var prints []func()
for i := 0; i &lt; 5; i++ {
for i := 0; i < 5; i++ {
prints = append(prints, func() { println(i) })
i++
}
@@ -6671,7 +6743,8 @@ RangeClause = [ ExpressionList "=" | IdentifierList ":=" ] "range" Expression .
<p>
The expression on the right in the "range" clause is called the <i>range expression</i>,
which may be an array, pointer to an array, slice, string, map, channel permitting
its <a href="#Core_types">core type</a> must be
an array, pointer to an array, slice, string, map, channel permitting
<a href="#Receive_operator">receive operations</a>, an integer, or
a function with specific signature (see below).
As with an assignment, if present the operands on the left must be
@@ -6760,7 +6833,7 @@ if the iteration variable is preexisting, the type of the iteration values is th
variable, which must be of integer type.
Otherwise, if the iteration variable is declared by the "range" clause or is absent,
the type of the iteration values is the <a href="#Constants">default type</a> for <code>n</code>.
If <code>n</code> &lt;= 0, the loop does not run any iterations.
If <code>n</code> &lt= 0, the loop does not run any iterations.
</li>
<li>
@@ -6871,7 +6944,7 @@ type Tree[K cmp.Ordered, V any] struct {
}
func (t *Tree[K, V]) walk(yield func(key K, val V) bool) bool {
return t == nil || t.left.walk(yield) &amp;&amp; yield(t.key, t.value) &amp;&amp; t.right.walk(yield)
return t == nil || t.left.walk(yield) && yield(t.key, t.value) && t.right.walk(yield)
}
func (t *Tree[K, V]) Walk(yield func(key K, val V) bool) {
@@ -6885,12 +6958,6 @@ for k, v := range t.Walk {
}
</pre>
<p>
If the type of the range expression is a <a href="#Type_parameter_declarations">type parameter</a>,
all types in its type set must have the same underlying type and the range expression must be valid
for that type, or, if the type set contains channel types, it must only contain channel types with
identical element types, and all channel types must permit receive operations.
</p>
<h3 id="Go_statements">Go statements</h3>
@@ -7364,28 +7431,23 @@ by the arguments overlaps.
<p>
The <a href="#Function_types">variadic</a> function <code>append</code>
appends zero or more values <code>x</code> to a slice <code>s</code> of
type <code>S</code> and returns the resulting slice, also of type
<code>S</code>.
appends zero or more values <code>x</code> to a slice <code>s</code>
and returns the resulting slice of the same type as <code>s</code>.
The <a href="#Core_types">core type</a> of <code>s</code> must be a slice
of type <code>[]E</code>.
The values <code>x</code> are passed to a parameter of type <code>...E</code>
where <code>E</code> is the element type of <code>S</code>
and the respective <a href="#Passing_arguments_to_..._parameters">parameter
passing rules</a> apply.
As a special case, <code>append</code> also accepts a slice whose type is assignable to
type <code>[]byte</code> with a second argument of <code>string</code> type followed by
<code>...</code>.
This form appends the bytes of the string.
As a special case, if the core type of <code>s</code> is <code>[]byte</code>,
<code>append</code> also accepts a second argument with core type
<a href="#Core_types"><code>bytestring</code></a> followed by <code>...</code>.
This form appends the bytes of the byte slice or string.
</p>
<pre class="grammar">
append(s S, x ...E) S // E is the element type of S
append(s S, x ...E) S // core type of S is []E
</pre>
<p>
If <code>S</code> is a <a href="#Type_parameter_declarations">type parameter</a>,
all types in its type set must have the same underlying slice type <code>[]E</code>.
</p>
<p>
If the capacity of <code>s</code> is not large enough to fit the additional
values, <code>append</code> <a href="#Allocation">allocates</a> a new, sufficiently large underlying
@@ -7411,14 +7473,14 @@ b = append(b, "bar"...) // append string contents b is []byte{'b
The function <code>copy</code> copies slice elements from
a source <code>src</code> to a destination <code>dst</code> and returns the
number of elements copied.
Both arguments must have <a href="#Type_identity">identical</a> element type
<code>E</code> and must be assignable to a slice of type <code>[]E</code>.
The <a href="#Core_types">core types</a> of both arguments must be slices
with <a href="#Type_identity">identical</a> element type.
The number of elements copied is the minimum of
<code>len(src)</code> and <code>len(dst)</code>.
As a special case, <code>copy</code> also accepts a destination argument
assignable to type <code>[]byte</code> with a source argument of a
<code>string</code> type.
This form copies the bytes from the string into the byte slice.
As a special case, if the destination's core type is <code>[]byte</code>,
<code>copy</code> also accepts a source argument with core type
<a href="#Core_types"><code>bytestring</code></a>.
This form copies the bytes from the byte slice or string into the byte slice.
</p>
<pre class="grammar">
@@ -7426,11 +7488,6 @@ copy(dst, src []T) int
copy(dst []byte, src string) int
</pre>
<p>
If the type of one or both arguments is a <a href="#Type_parameter_declarations">type parameter</a>,
all types in their respective type sets must have the same underlying slice type <code>[]E</code>.
</p>
<p>
Examples:
</p>
@@ -7481,7 +7538,8 @@ If the map or slice is <code>nil</code>, <code>clear</code> is a no-op.
<h3 id="Close">Close</h3>
<p>
For a channel <code>ch</code>, the built-in function <code>close(ch)</code>
For an argument <code>ch</code> with a <a href="#Core_types">core type</a>
that is a <a href="#Channel_types">channel</a>, the built-in function <code>close</code>
records that no more values will be sent on the channel.
It is an error if <code>ch</code> is a receive-only channel.
Sending to or closing a closed channel causes a <a href="#Run_time_panics">run-time panic</a>.
@@ -7493,12 +7551,6 @@ The multi-valued <a href="#Receive_operator">receive operation</a>
returns a received value along with an indication of whether the channel is closed.
</p>
<p>
If the type of the argument to <code>close</code> is a
<a href="#Type_parameter_declarations">type parameter</a>,
all types in its type set must be channels.
It is an error if any of those channels is a receive-only channel.
</p>
<h3 id="Complex_numbers">Manipulating complex numbers</h3>
@@ -7668,36 +7720,27 @@ var z complex128
<p>
The built-in function <code>make</code> takes a type <code>T</code>,
which must be a slice, map or channel type, or a type parameter,
optionally followed by a type-specific list of expressions.
The <a href="#Core_types">core type</a> of <code>T</code> must
be a slice, map or channel.
It returns a value of type <code>T</code> (not <code>*T</code>).
The memory is initialized as described in the section on
<a href="#The_zero_value">initial values</a>.
</p>
<pre class="grammar">
Call Type T Result
Call Core type Result
make(T, n) slice slice of type T with length n and capacity n
make(T, n, m) slice slice of type T with length n and capacity m
make(T, n) slice slice of type T with length n and capacity n
make(T, n, m) slice slice of type T with length n and capacity m
make(T) map map of type T
make(T, n) map map of type T with initial space for approximately n elements
make(T) map map of type T
make(T, n) map map of type T with initial space for approximately n elements
make(T) channel unbuffered channel of type T
make(T, n) channel buffered channel of type T, buffer size n
make(T, n) type parameter see below
make(T, n, m) type parameter see below
make(T) channel unbuffered channel of type T
make(T, n) channel buffered channel of type T, buffer size n
</pre>
<p>
If the first argument is a <a href="#Type_parameter_declarations">type parameter</a>,
all types in its type set must have the same underlying type, which must be a slice
or map type, or, if there are channel types, there must only be channel types, they
must all have the same element type, and the channel directions must not conflict.
</p>
<p>
Each of the size arguments <code>n</code> and <code>m</code> must be of <a href="#Numeric_types">integer type</a>,
have a <a href="#Interface_types">type set</a> containing only integer types,
@@ -7787,39 +7830,27 @@ compared lexically byte-wise:
</p>
<pre>
min(x, y) == if x &lt;= y then x else y
min(x, y) == if x <= y then x else y
min(x, y, z) == min(min(x, y), z)
</pre>
<h3 id="Allocation">Allocation</h3>
<p>
The built-in function <code>new</code> creates a new, initialized
<a href="#Variables">variable</a> and returns
a <a href="#Pointer_types">pointer</a> to it.
It accepts a single argument, which may be either a type or an expression.
The built-in function <code>new</code> takes a type <code>T</code>,
allocates storage for a <a href="#Variables">variable</a> of that type
at run time, and returns a value of type <code>*T</code>
<a href="#Pointer_types">pointing</a> to it.
The variable is initialized as described in the section on
<a href="#The_zero_value">initial values</a>.
</p>
<p>
If the argument is a type <code>T</code>, then <code>new(T)</code>
allocates a variable of type <code>T</code> initialized to its
<a href="#The_zero_value">zero value</a>.
</p>
<pre class="grammar">
new(T)
</pre>
<p>
If the argument is an expression <code>x</code>, then <code>new(x)</code>
allocates a variable of the type of <code>x</code> initialized to the value of <code>x</code>.
If that value is an untyped constant, it is first implicitly <a href="#Conversions">converted</a>
to its <a href="#Constants">default type</a>;
if it is an untyped boolean value, it is first implicitly converted to type bool.
The predeclared identifier <code>nil</code> cannot be used as an argument to <code>new</code>.
</p>
<p>
For example, <code>new(int)</code> and <code>new(123)</code> each
return a pointer to a new variable of type <code>int</code>.
The value of the first variable is <code>0</code>, and the value
of the second is <code>123</code>. Similarly
For instance
</p>
<pre>
@@ -7828,12 +7859,13 @@ new(S)
</pre>
<p>
allocates a variable of type <code>S</code>,
allocates storage for a variable of type <code>S</code>,
initializes it (<code>a=0</code>, <code>b=0.0</code>),
and returns a value of type <code>*S</code> containing the address
of the variable.
of the location.
</p>
<h3 id="Handling_panics">Handling panics</h3>
<p> Two built-in functions, <code>panic</code> and <code>recover</code>,
@@ -7893,7 +7925,7 @@ causes a <a href="#Run_time_panics">run-time panic</a>.
<p>
The <code>protect</code> function in the example below invokes
the function argument <code>g</code> and protects callers from
run-time panics caused by <code>g</code>.
run-time panics raised by <code>g</code>.
</p>
<pre>
@@ -8451,14 +8483,17 @@ func String(ptr *byte, len IntegerType) string
func StringData(str string) *byte
</pre>
<!--
These conversions also apply to type parameters with suitable core types.
Determine if we can simply use core type instead of underlying type here,
of if the general conversion rules take care of this.
-->
<p>
A <code>Pointer</code> is a <a href="#Pointer_types">pointer type</a> but a <code>Pointer</code>
value may not be <a href="#Address_operators">dereferenced</a>.
Any pointer or value of <a href="#Underlying_types">underlying type</a> <code>uintptr</code> can be
<a href="#Conversions">converted</a> to a type of underlying type <code>Pointer</code> and vice versa.
If the respective types are <a href="#Type_parameter_declarations">type parameters</a>, all types in
their respective type sets must have the same underlying type, which must be <code>uintptr</code> and
<code>Pointer</code>, respectively.
Any pointer or value of <a href="#Core_types">core type</a> <code>uintptr</code> can be
<a href="#Conversions">converted</a> to a type of core type <code>Pointer</code> and vice versa.
The effect of converting between <code>Pointer</code> and <code>uintptr</code> is implementation-defined.
</p>
@@ -8812,9 +8847,9 @@ following conditions is true:
</li>
<li>
Exactly one type is an <a href="#Type_inference">unbound</a>
type parameter, and all the types in its type set unify with
the other type
per the unification rules for <code><sub>A</sub></code>
type parameter with a <a href="#Core_types">core type</a>,
and that core type unifies with the other type per the
unification rules for <code><sub>A</sub></code>
(loose unification at the top level and exact unification
for element types).
</li>

View File

@@ -109,9 +109,7 @@ Only the work module's `go.mod` is consulted for `godebug` directives.
Any directives in required dependency modules are ignored.
It is an error to list a `godebug` with an unrecognized setting.
(Toolchains older than Go 1.23 reject all `godebug` lines, since they do not
understand `godebug` at all.) When a workspace is in use, `godebug`
directives in `go.mod` files are ignored, and `go.work` will be consulted
for `godebug` directives instead.
understand `godebug` at all.)
The defaults from the `go` and `godebug` lines apply to all main
packages that are built. For more fine-grained control,
@@ -163,67 +161,6 @@ will fail early. The default value is `httpcookiemaxnum=3000`. Setting
number of cookies. To avoid denial of service attacks, this setting and default
was backported to Go 1.25.2 and Go 1.24.8.
Go 1.26 added a new `urlstrictcolons` setting that controls whether `net/url.Parse`
allows malformed hostnames containing colons outside of a bracketed IPv6 address.
The default `urlstrictcolons=1` rejects URLs such as `http://localhost:1:2` or `http://::1/`.
Colons are permitted as part of a bracketed IPv6 address, such as `http://[::1]/`.
Go 1.26 enabled two additional post-quantum key exchange mechanisms:
SecP256r1MLKEM768 and SecP384r1MLKEM1024. The default can be reverted using the
[`tlssecpmlkem` setting](/pkg/crypto/tls/#Config.CurvePreferences).
Go 1.26 added a new `tracebacklabels` setting that controls the inclusion of
goroutine labels set through the the `runtime/pprof` package. Setting `tracebacklabels=1`
includes these key/value pairs in the goroutine status header of runtime
tracebacks and debug=2 runtime/pprof stack dumps. This format may change in the future.
(see go.dev/issue/76349)
Go 1.26 added a new `cryptocustomrand` setting that controls whether most crypto/...
APIs ignore the random `io.Reader` parameter. For Go 1.26, it defaults
to `cryptocustomrand=0`, ignoring the random parameters. Using `cryptocustomrand=1`
reverts to the pre-Go 1.26 behavior.
### Go 1.25
Go 1.25 added a new `decoratemappings` setting that controls whether the Go
runtime annotates OS anonymous memory mappings with context about their
purpose. These annotations appear in /proc/self/maps and /proc/self/smaps as
"[anon: Go: ...]". This setting is only used on Linux. For Go 1.25, it defaults
to `decoratemappings=1`, enabling annotations. Using `decoratemappings=0`
reverts to the pre-Go 1.25 behavior. This setting is fixed at program startup
time, and can't be modified by changing the `GODEBUG` environment variable
after the program starts.
Go 1.25 added a new `embedfollowsymlinks` setting that controls whether the
Go command will follow symlinks to regular files embedding files.
The default value `embedfollowsymlinks=0` does not allow following
symlinks. `embedfollowsymlinks=1` will allow following symlinks.
Go 1.25 added a new `containermaxprocs` setting that controls whether the Go
runtime will consider cgroup CPU limits when setting the default GOMAXPROCS.
The default value `containermaxprocs=1` will use cgroup limits in addition to
the total logical CPU count and CPU affinity. `containermaxprocs=0` will
disable consideration of cgroup limits. This setting only affects Linux.
Go 1.25 added a new `updatemaxprocs` setting that controls whether the Go
runtime will periodically update GOMAXPROCS for new CPU affinity or cgroup
limits. The default value `updatemaxprocs=1` will enable periodic updates.
`updatemaxprocs=0` will disable periodic updates.
Go 1.25 disabled SHA-1 signature algorithms in TLS 1.2 according to RFC 9155.
The default can be reverted using the `tlssha1=1` setting.
Go 1.25 switched to SHA-256 to fill in missing SubjectKeyId in
crypto/x509.CreateCertificate. The setting `x509sha256skid=0` reverts to SHA-1.
Go 1.25 corrected the semantics of contention reports for runtime-internal locks,
and so removed the [`runtimecontentionstacks` setting](/pkg/runtime#hdr-Environment_Variables).
Go 1.25 (starting with Go 1.25 RC 2) disabled build information stamping when
multiple VCS are detected due to concerns around VCS injection attacks. This
behavior and setting was backported to Go 1.24.5 and Go 1.23.11. This behavior
can be renabled with the setting `allowmultiplevcs=1`.
### Go 1.24
Go 1.24 added a new `fips140` setting that controls whether the Go
@@ -290,8 +227,6 @@ field by default.
Go 1.24 enabled the post-quantum key exchange mechanism
X25519MLKEM768 by default. The default can be reverted using the
[`tlsmlkem` setting](/pkg/crypto/tls/#Config.CurvePreferences).
This can be useful when dealing with buggy TLS servers that do not handle large records correctly,
causing a timeout during the handshake (see [TLS post-quantum TL;DR fail](https://tldr.fail/)).
Go 1.24 also removed X25519Kyber768Draft00 and the Go 1.23 `tlskyber` setting.
Go 1.24 made [`ParsePKCS1PrivateKey`](/pkg/crypto/x509/#ParsePKCS1PrivateKey)
@@ -299,6 +234,10 @@ use and validate the CRT parameters in the encoded private key. This behavior
can be controlled with the `x509rsacrt` setting. Using `x509rsacrt=0` restores
the Go 1.23 behavior.
Go 1.24.5 disabled build information stamping when multiple VCS are detected due
to concerns around VCS injection attacks. This behavior can be renabled with the
setting `allowmultiplevcs=1`.
### Go 1.23
Go 1.23 changed the channels created by package time to be unbuffered
@@ -306,7 +245,7 @@ Go 1.23 changed the channels created by package time to be unbuffered
and [`Timer.Reset`](/pkg/time/#Timer.Reset) method results much easier.
The [`asynctimerchan` setting](/pkg/time/#NewTimer) disables this change.
There are no runtime metrics for this change,
This setting will be removed in Go 1.27.
This setting may be removed in a future release, Go 1.27 at the earliest.
Go 1.23 changed the mode bits reported by [`os.Lstat`](/pkg/os#Lstat) and [`os.Stat`](/pkg/os#Stat)
for reparse points, which can be controlled with the `winsymlink` setting.
@@ -328,8 +267,6 @@ Previous versions default to `winreadlinkvolume=0`.
Go 1.23 enabled the experimental post-quantum key exchange mechanism
X25519Kyber768Draft00 by default. The default can be reverted using the
[`tlskyber` setting](/pkg/crypto/tls/#Config.CurvePreferences).
This can be useful when dealing with buggy TLS servers that do not handle large records correctly,
causing a timeout during the handshake (see [TLS post-quantum TL;DR fail](https://tldr.fail/)).
Go 1.23 changed the behavior of
[crypto/x509.ParseCertificate](/pkg/crypto/x509/#ParseCertificate) to reject
@@ -343,7 +280,6 @@ any effect.
Go 1.23 changed the default TLS cipher suites used by clients and servers when
not explicitly configured, removing 3DES cipher suites. The default can be reverted
using the [`tls3des` setting](/pkg/crypto/tls/#Config.CipherSuites).
This setting will be removed in Go 1.27.
Go 1.23 changed the behavior of [`tls.X509KeyPair`](/pkg/crypto/tls#X509KeyPair)
and [`tls.LoadX509KeyPair`](/pkg/crypto/tls#LoadX509KeyPair) to populate the
@@ -351,7 +287,6 @@ Leaf field of the returned [`tls.Certificate`](/pkg/crypto/tls#Certificate).
This behavior is controlled by the `x509keypairleaf` setting. For Go 1.23, it
defaults to `x509keypairleaf=1`. Previous versions default to
`x509keypairleaf=0`.
This setting will be removed in Go 1.27.
Go 1.23 changed
[`net/http.ServeContent`](/pkg/net/http#ServeContent),
@@ -385,31 +320,28 @@ Whether the type checker produces `Alias` types or not is controlled by the
[`gotypesalias` setting](/pkg/go/types#Alias).
For Go 1.22 it defaults to `gotypesalias=0`.
For Go 1.23, `gotypesalias=1` will become the default.
This setting will be removed in Go 1.27.
This setting will be removed in a future release, Go 1.27 at the earliest.
Go 1.22 changed the default minimum TLS version supported by both servers
and clients to TLS 1.2. The default can be reverted to TLS 1.0 using the
[`tls10server` setting](/pkg/crypto/tls/#Config).
This setting will be removed in Go 1.27.
Go 1.22 changed the default TLS cipher suites used by clients and servers when
not explicitly configured, removing the cipher suites which used RSA based key
exchange. The default can be reverted using the [`tlsrsakex` setting](/pkg/crypto/tls/#Config).
This setting will be removed in Go 1.27.
Go 1.22 disabled
[`ConnectionState.ExportKeyingMaterial`](/pkg/crypto/tls/#ConnectionState.ExportKeyingMaterial)
when the connection supports neither TLS 1.3 nor Extended Master Secret
(implemented in Go 1.21). It can be reenabled with the [`tlsunsafeekm`
setting](/pkg/crypto/tls/#ConnectionState.ExportKeyingMaterial).
This setting will be removed in Go 1.27.
Go 1.22 changed how the runtime interacts with transparent huge pages on Linux.
In particular, a common default Linux kernel configuration can result in
significant memory overheads, and Go 1.22 no longer works around this default.
To work around this issue without adjusting kernel settings, transparent huge
pages can be disabled for Go memory with the
[`disablethp` setting](/pkg/runtime#hdr-Environment_Variables).
[`disablethp` setting](/pkg/runtime#hdr-Environment_Variable).
This behavior was backported to Go 1.21.1, but the setting is only available
starting with Go 1.21.6.
This setting may be removed in a future release, and users impacted by this issue
@@ -421,7 +353,7 @@ Go 1.22 added contention on runtime-internal locks to the [`mutex`
profile](/pkg/runtime/pprof#Profile). Contention on these locks is always
reported at `runtime._LostContendedRuntimeLock`. Complete stack traces of
runtime locks can be enabled with the [`runtimecontentionstacks`
setting](/pkg/runtime#hdr-Environment_Variables). These stack traces have
setting](/pkg/runtime#hdr-Environment_Variable). These stack traces have
non-standard semantics, see setting documentation for details.
Go 1.22 added a new [`crypto/x509.Certificate`](/pkg/crypto/x509/#Certificate)
@@ -430,7 +362,7 @@ certificate policy OIDs with components larger than 31 bits. By default this
field is only used during parsing, when it is populated with policy OIDs, but
not used during marshaling. It can be used to marshal these larger OIDs, instead
of the existing PolicyIdentifiers field, by using the
[`x509usepolicies` setting](/pkg/crypto/x509/#CreateCertificate).
[`x509usepolicies` setting.](/pkg/crypto/x509/#CreateCertificate).
### Go 1.21

View File

@@ -1 +1,3 @@
### Minor changes to the library {#minor_library_changes}

View File

@@ -30,7 +30,7 @@ v%.zip:
go run ../../src/cmd/go/internal/fips140/mkzip.go v$*
# normally mkzip refuses to overwrite an existing zip file.
# make v1.2.3.rm removes the zip file and unpacked
# make v1.2.3.rm removes the zip file and and unpacked
# copy from the module cache.
v%.rm:
rm -f v$*.zip

View File

@@ -10,4 +10,3 @@
# go test cmd/go/internal/fips140 -update
#
v1.0.0-c2097c7c.zip daf3614e0406f67ae6323c902db3f953a1effb199142362a039e7526dfb9368b
v1.1.0-rc1.zip ea94f8c3885294c9efe1bd8f9b6e86daeb25b6aff2aeb20707cd9a5101f6f54e

Binary file not shown.

View File

@@ -1,64 +0,0 @@
# Copyright 2025 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.
# Mercurial extension to add a 'goreposum' command that
# computes a hash of a remote repo's tag state.
# Tag definitions can come from the .hgtags file stored in
# any head of any branch, and the server protocol does not
# expose the tags directly. However, the protocol does expose
# the hashes of all the branch heads, so we can use a hash of
# all those branch names and heads as a conservative snapshot
# of the entire remote repo state, and use that as the tag sum.
# Any change on the server then invalidates the tag sum,
# even if it didn't have anything to do with tags, but at least
# we will avoid re-cloning a server when there have been no
# changes at all.
#
# Separately, this extension also adds a 'golookup' command that
# returns the hash of a specific reference, like 'default' or a tag.
# And golookup of a hash confirms that it still exists on the server.
# We can use that to revalidate that specific versions still exist and
# have the same meaning they did the last time we checked.
#
# Usage:
#
# hg --config "extensions.goreposum=$GOROOT/lib/hg/goreposum.py" goreposum REPOURL
import base64, hashlib, sys
from mercurial import registrar, ui, hg, node
from mercurial.i18n import _
cmdtable = {}
command = registrar.command(cmdtable)
@command(b'goreposum', [], _('url'), norepo=True)
def goreposum(ui, url):
"""
goreposum computes a checksum of all the named state in the remote repo.
It hashes together all the branch names and hashes
and then all the bookmark names and hashes.
Tags are stored in .hgtags files in any of the branches,
so the branch metadata includes the tags as well.
"""
h = hashlib.sha256()
peer = hg.peer(ui, {}, url)
for name, revs in peer.branchmap().items():
h.update(name)
for r in revs:
h.update(b' ')
h.update(r)
h.update(b'\n')
if (b'bookmarks' in peer.listkeys(b'namespaces')):
for name, rev in peer.listkeys(b'bookmarks').items():
h.update(name)
h.update(b'=')
h.update(rev)
h.update(b'\n')
print('r1:'+base64.standard_b64encode(h.digest()).decode('utf-8'))
@command(b'golookup', [], _('url rev'), norepo=True)
def golookup(ui, url, rev):
"""
golookup looks up a single identifier in the repo,
printing its hash.
"""
print(node.hex(hg.peer(ui, {}, url).lookup(rev)).decode('utf-8'))

View File

@@ -24,8 +24,8 @@
# in the CL match the update.bash in the CL.
# Versions to use.
CODE=2025c
DATA=2025c
CODE=2025a
DATA=2025a
set -e
@@ -40,12 +40,7 @@ curl -sS -L -O https://www.iana.org/time-zones/repository/releases/tzdata$DATA.t
tar xzf tzcode$CODE.tar.gz
tar xzf tzdata$DATA.tar.gz
# The PACKRATLIST and PACKRATDATA options are copied from Ubuntu:
# https://git.launchpad.net/ubuntu/+source/tzdata/tree/debian/rules?h=debian/sid
#
# You can see the description of these make variables in the tzdata Makefile:
# https://github.com/eggert/tz/blob/main/Makefile
if ! make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo PACKRATDATA=backzone PACKRATLIST=zone.tab posix_only >make.out 2>&1; then
if ! make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo posix_only >make.out 2>&1; then
cat make.out
exit 2
fi

Binary file not shown.

View File

@@ -14,7 +14,7 @@ case "$GOWASIRUNTIME" in
exec wazero run -mount /:/ -env-inherit -cachedir "${TMPDIR:-/tmp}"/wazero ${GOWASIRUNTIMEARGS:-} "$1" "${@:2}"
;;
"wasmtime" | "")
exec wasmtime run --dir=/ --env PWD="$PWD" --env PATH="$PATH" -W max-wasm-stack=8388608 ${GOWASIRUNTIMEARGS:-} "$1" "${@:2}"
exec wasmtime run --dir=/ --env PWD="$PWD" --env PATH="$PATH" -W max-wasm-stack=1048576 ${GOWASIRUNTIMEARGS:-} "$1" "${@:2}"
;;
*)
echo "Unknown Go WASI runtime specified: $GOWASIRUNTIME"

View File

@@ -212,7 +212,7 @@ func copyLocalData(dstbase string) (pkgpath string, err error) {
// Copy all immediate files and testdata directories between
// the package being tested and the source root.
pkgpath = ""
for element := range strings.SplitSeq(finalPkgpath, string(filepath.Separator)) {
for _, element := range strings.Split(finalPkgpath, string(filepath.Separator)) {
if debug {
log.Printf("copying %s", pkgpath)
}

191
misc/linkcheck/linkcheck.go Normal file
View File

@@ -0,0 +1,191 @@
// Copyright 2013 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.
// The linkcheck command finds missing links in the godoc website.
// It crawls a URL recursively and notes URLs and URL fragments
// that it's seen and prints a report of missing links at the end.
package main
import (
"errors"
"flag"
"fmt"
"io"
"log"
"net/http"
"os"
"regexp"
"strings"
"sync"
)
var (
root = flag.String("root", "http://localhost:6060", "Root to crawl")
verbose = flag.Bool("verbose", false, "verbose")
)
var wg sync.WaitGroup // outstanding fetches
var urlq = make(chan string) // URLs to crawl
// urlFrag is a URL and its optional #fragment (without the #)
type urlFrag struct {
url, frag string
}
var (
mu sync.Mutex
crawled = make(map[string]bool) // URL without fragment -> true
neededFrags = make(map[urlFrag][]string) // URL#frag -> who needs it
)
var aRx = regexp.MustCompile(`<a href=['"]?(/[^\s'">]+)`)
// Owned by crawlLoop goroutine:
var (
linkSources = make(map[string][]string) // url no fragment -> sources
fragExists = make(map[urlFrag]bool)
problems []string
)
func localLinks(body string) (links []string) {
seen := map[string]bool{}
mv := aRx.FindAllStringSubmatch(body, -1)
for _, m := range mv {
ref := m[1]
if strings.HasPrefix(ref, "/src/") {
continue
}
if !seen[ref] {
seen[ref] = true
links = append(links, m[1])
}
}
return
}
var idRx = regexp.MustCompile(`\bid=['"]?([^\s'">]+)`)
func pageIDs(body string) (ids []string) {
mv := idRx.FindAllStringSubmatch(body, -1)
for _, m := range mv {
ids = append(ids, m[1])
}
return
}
// url may contain a #fragment, and the fragment is then noted as needing to exist.
func crawl(url string, sourceURL string) {
if strings.Contains(url, "/devel/release") {
return
}
mu.Lock()
defer mu.Unlock()
if u, frag, ok := strings.Cut(url, "#"); ok {
url = u
if frag != "" {
uf := urlFrag{url, frag}
neededFrags[uf] = append(neededFrags[uf], sourceURL)
}
}
if crawled[url] {
return
}
crawled[url] = true
wg.Add(1)
go func() {
urlq <- url
}()
}
func addProblem(url, errmsg string) {
msg := fmt.Sprintf("Error on %s: %s (from %s)", url, errmsg, linkSources[url])
if *verbose {
log.Print(msg)
}
problems = append(problems, msg)
}
func crawlLoop() {
for url := range urlq {
if err := doCrawl(url); err != nil {
addProblem(url, err.Error())
}
}
}
func doCrawl(url string) error {
defer wg.Done()
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return err
}
res, err := http.DefaultTransport.RoundTrip(req)
if err != nil {
return err
}
// Handle redirects.
if res.StatusCode/100 == 3 {
newURL, err := res.Location()
if err != nil {
return fmt.Errorf("resolving redirect: %v", err)
}
if !strings.HasPrefix(newURL.String(), *root) {
// Skip off-site redirects.
return nil
}
crawl(newURL.String(), url)
return nil
}
if res.StatusCode != 200 {
return errors.New(res.Status)
}
slurp, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
log.Fatalf("Error reading %s body: %v", url, err)
}
if *verbose {
log.Printf("Len of %s: %d", url, len(slurp))
}
body := string(slurp)
for _, ref := range localLinks(body) {
if *verbose {
log.Printf(" links to %s", ref)
}
dest := *root + ref
linkSources[dest] = append(linkSources[dest], url)
crawl(dest, url)
}
for _, id := range pageIDs(body) {
if *verbose {
log.Printf(" url %s has #%s", url, id)
}
fragExists[urlFrag{url, id}] = true
}
return nil
}
func main() {
flag.Parse()
go crawlLoop()
crawl(*root, "")
wg.Wait()
close(urlq)
for uf, needers := range neededFrags {
if !fragExists[uf] {
problems = append(problems, fmt.Sprintf("Missing fragment for %+v from %v", uf, needers))
}
}
for _, s := range problems {
fmt.Println(s)
}
if len(problems) > 0 {
os.Exit(1)
}
}

View File

@@ -10,4 +10,4 @@ if [ ! -f make.bash ]; then
fi
. ./make.bash "$@" --no-banner
bash run.bash --no-rebuild
../bin/go tool dist banner # print build info
"$GOTOOLDIR/dist" banner # print build info

View File

@@ -6,11 +6,17 @@
setlocal
if not exist make.bat (
echo all.bat must be run from go\src
exit /b 1
)
if exist make.bat goto ok
echo all.bat must be run from go\src
:: cannot exit: would kill parent command interpreter
goto end
:ok
call .\make.bat --no-banner || exit /b 1
call .\run.bat --no-rebuild || exit /b 1
..\bin\go tool dist banner
call .\make.bat --no-banner --no-local
if %GOBUILDFAIL%==1 goto end
call .\run.bat --no-rebuild --no-local
if %GOBUILDFAIL%==1 goto end
"%GOTOOLDIR%/dist" banner
:end
if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%

View File

@@ -13,4 +13,4 @@ if(! test -f make.rc){
. ./make.rc --no-banner $*
bind -b $GOROOT/bin /bin
./run.rc --no-rebuild
../bin/go tool dist banner # print build info
$GOTOOLDIR/dist banner # print build info

View File

@@ -10,7 +10,6 @@ import (
"errors"
"fmt"
"hash/crc32"
"internal/obscuretestdata"
"io"
"maps"
"math"
@@ -26,11 +25,10 @@ import (
func TestReader(t *testing.T) {
vectors := []struct {
file string // Test input file
obscured bool // Obscured with obscuretestdata package
headers []*Header // Expected output headers
chksums []string // CRC32 checksum of files, leave as nil if not checked
err error // Expected error to occur
file string // Test input file
headers []*Header // Expected output headers
chksums []string // CRC32 checksum of files, leave as nil if not checked
err error // Expected error to occur
}{{
file: "testdata/gnu.tar",
headers: []*Header{{
@@ -525,9 +523,8 @@ func TestReader(t *testing.T) {
file: "testdata/pax-nul-path.tar",
err: ErrHeader,
}, {
file: "testdata/neg-size.tar.base64",
obscured: true,
err: ErrHeader,
file: "testdata/neg-size.tar",
err: ErrHeader,
}, {
file: "testdata/issue10968.tar",
err: ErrHeader,
@@ -632,24 +629,15 @@ func TestReader(t *testing.T) {
}}
for _, v := range vectors {
t.Run(strings.TrimSuffix(path.Base(v.file), ".base64"), func(t *testing.T) {
path := v.file
if v.obscured {
tf, err := obscuretestdata.DecodeToTempFile(path)
if err != nil {
t.Fatalf("obscuredtestdata.DecodeToTempFile(%s): %v", path, err)
}
path = tf
}
f, err := os.Open(path)
t.Run(path.Base(v.file), func(t *testing.T) {
f, err := os.Open(v.file)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
defer f.Close()
var fr io.Reader = f
if strings.HasSuffix(v.file, ".bz2") || strings.HasSuffix(v.file, ".bz2.base64") {
if strings.HasSuffix(v.file, ".bz2") {
fr = bzip2.NewReader(fr)
}
@@ -787,7 +775,7 @@ type readBadSeeker struct{ io.ReadSeeker }
func (rbs *readBadSeeker) Seek(int64, int) (int64, error) { return 0, fmt.Errorf("illegal seek") }
// TestReadTruncation tests the ending condition on various truncated files and
// TestReadTruncation test the ending condition on various truncated files and
// that truncated files are still detected even if the underlying io.Reader
// satisfies io.Seeker.
func TestReadTruncation(t *testing.T) {

View File

@@ -19,7 +19,7 @@ func init() {
sysStat = statUnix
}
// userMap and groupMap cache UID and GID lookups for performance reasons.
// userMap and groupMap caches UID and GID lookups for performance reasons.
// The downside is that renaming uname or gname by the OS never takes effect.
var userMap, groupMap sync.Map // map[int]string

View File

@@ -213,17 +213,15 @@ func parsePAXTime(s string) (time.Time, error) {
}
// Parse the nanoseconds.
// Initialize an array with '0's to handle right padding automatically.
nanoDigits := [maxNanoSecondDigits]byte{'0', '0', '0', '0', '0', '0', '0', '0', '0'}
for i := range len(sn) {
switch c := sn[i]; {
case c < '0' || c > '9':
return time.Time{}, ErrHeader
case i < len(nanoDigits):
nanoDigits[i] = c
}
if strings.Trim(sn, "0123456789") != "" {
return time.Time{}, ErrHeader
}
nsecs, _ := strconv.ParseInt(string(nanoDigits[:]), 10, 64) // Must succeed after validation
if len(sn) < maxNanoSecondDigits {
sn += strings.Repeat("0", maxNanoSecondDigits-len(sn)) // Right pad
} else {
sn = sn[:maxNanoSecondDigits] // Right truncate
}
nsecs, _ := strconv.ParseInt(sn, 10, 64) // Must succeed
if len(ss) > 0 && ss[0] == '-' {
return time.Unix(secs, -1*nsecs), nil // Negative correction
}
@@ -312,7 +310,7 @@ func formatPAXRecord(k, v string) (string, error) {
// "%d %s=%s\n" % (size, key, value)
//
// Keys and values should be UTF-8, but the number of bad writers out there
// forces us to be more liberal.
// forces us to be a more liberal.
// Thus, we only reject all keys with NUL, and only reject NULs in values
// for the PAX version of the USTAR string fields.
// The key must not contain an '=' character.

View File

@@ -439,66 +439,3 @@ func TestFormatPAXRecord(t *testing.T) {
}
}
}
func BenchmarkParsePAXTime(b *testing.B) {
tests := []struct {
name string
in string
want time.Time
ok bool
}{
{
name: "NoNanos",
in: "123456",
want: time.Unix(123456, 0),
ok: true,
},
{
name: "ExactNanos",
in: "1.123456789",
want: time.Unix(1, 123456789),
ok: true,
},
{
name: "WithNanoPadding",
in: "1.123",
want: time.Unix(1, 123000000),
ok: true,
},
{
name: "WithNanoTruncate",
in: "1.123456789123",
want: time.Unix(1, 123456789),
ok: true,
},
{
name: "TrailingError",
in: "1.123abc",
want: time.Time{},
ok: false,
},
{
name: "LeadingError",
in: "1.abc123",
want: time.Time{},
ok: false,
},
}
for _, tt := range tests {
b.Run(tt.name, func(b *testing.B) {
b.ReportAllocs()
for b.Loop() {
ts, err := parsePAXTime(tt.in)
if (err == nil) != tt.ok {
if err != nil {
b.Fatal(err)
}
b.Fatal("expected error")
}
if !ts.Equal(tt.want) {
b.Fatalf("time mismatch: got %v, want %v", ts, tt.want)
}
}
})
}
}

Binary file not shown.

View File

@@ -1,90 +0,0 @@
Z251LXNwYXJzZQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAwMDAwMDAAMDAwMDAw
MAAwMDAwMDAwADAwMDAwMDA2MDAwADAwMDAwMDAwMDAwADAyMjIyNwAgUwAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB1c3RhciAgAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwMDAwMDAwADAwMDAw
MDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAlQL4gAw
MDAwMDAwMTAwMACAAAAAAAAABKgXxgAwMDAwMDAwMTAwMACAAAAAAAAABvwjqgAwMDAwMDAwMTAw
MACAAAAAAAAACVAvjgAwMDAwMDAwMTAwMAABgAAAAAAAAA34R1gAAAAAAAAAAAAAAAAAAAAAAACA
AAAAAAAAC6Q7cgAwMDAwMDAwMTAwMACAAAAAAAAADfhHVgAwMDAwMDAwMTAwMAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1
Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5AAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAADAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2
Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAMDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3
ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OQAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4
OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5AAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAADAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5
MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAMDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkw
MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OQAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=

BIN
src/archive/tar/testdata/neg-size.tar vendored Normal file

Binary file not shown.

View File

@@ -1,9 +0,0 @@
EwMwMBMDLTgyMTk1MDI5NnQTE4NzfINzEzAwcXfhZrsDMDAwAAAAEDAxMRNz9DEwMTAwdBMTg3N8
g3NzADATc3yDc3P0eFMTc/QxMDEwMHQTE4NzfINzc/QwE3N8g3Nz9HFTMNR0MBMwMHEw9DAAAAAQ
MDGAABAwMTETc/QxMDH0MHQTMDBx1OFmuwMAAAD/gICAADExNTYyMQAgMBP///+AMTAwdHhTMDB0
MBMwMHF3MDEwMTAwdBMTg3N8g3Nz9HhTMDB0MBMwMHF34Wa7AzAwMAAAABAwMTETc/QxMDEwMHQT
E4NzfINzc/QwE3N8g3Nz9HhTE3P0MTAxMDB0ExODc3yDc3MwMBNzfINzczB4UzAwdDATMDBxMDAA
gAAAEDAxc/QxMDEwMHQTAAAAIOFmuwMwNAAAABAwMTET////gDEwMHR4UzAwdDATMDBxd+FmuwMw
MDAAAAAQMDExE3ODc3P0eFMTc/QxMDEwMHQTE4NzfINzc/QzMTEwMzM2MjQ4NDYxMjgzODBzfINz
c/R4UzAwdDATMDBxMDAwAAAAEDAxAAAQMDExE3P0MTAxMDB0EzAwcdThZrsDMDQAAAAQg3N8g3Nz
9DATc3yDc3P0eFMwMHQwEzAwcTAwMAAAABAwMQAAEDAxMRNz9DEwMTAwdBMwMHgw4Wa7AwAAEDA=

Binary file not shown.

View File

@@ -1,108 +0,0 @@
UGF4SGVhZGVycy4wL3BheC1zcGFyc2UAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAwMDAwMDAAMDAwMDAw
MAAwMDAwMDAwADAwMDAwMDAwMTcyADAwMDAwMDAwMDAwADAxMjIyNwAgeAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB1c3RhcgAwMAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAy
MiBHTlUuc3BhcnNlLm1ham9yPTEKMjIgR05VLnNwYXJzZS5taW5vcj0wCjMwIEdOVS5zcGFyc2Uu
bmFtZT1wYXgtc3BhcnNlCjM1IEdOVS5zcGFyc2UucmVhbHNpemU9NjAwMDAwMDAwMDAKMTMgc2l6
ZT0zNTg0CgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEdO
VVNwYXJzZUZpbGUuMC9wYXgtc3BhcnNlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwMDAwMDAwADAwMDAwMDAA
MDAwMDAwMAAwMDAwMDAwNzAwMAAwMDAwMDAwMDAwMAAwMTM3MzcAIDAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAdXN0YXIAMDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMDAwMDAwMAAwMDAwMDAw
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANgo5
OTk5OTk5NDg4CjUxMgoxOTk5OTk5OTQ4OAo1MTIKMjk5OTk5OTk0ODgKNTEyCjM5OTk5OTk5NDg4
CjUxMgo0OTk5OTk5OTQ4OAo1MTIKNTk5OTk5OTk0ODgKNTEyCgAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAMDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3
ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OQAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4
OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5AAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAADAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5
MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAMDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkw
MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OQAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAx
MjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5AAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAADAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEy
MzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

Binary file not shown.

View File

@@ -1,27 +0,0 @@
bG9uZ25hbWUvbG9uZ25hbWUvbG9uZ25hbWUvbG9uZ25hbWUvbG9uZ25hbWUvbG9uZ25hbWUvbG9u
Z25hbWUvbG9uZ25hbWUvbG9uZ25hbWUvbG9uZ25hbWUvbG9uZ25hbWUvbDAwMDAwMDAAMDAwMDAw
MAAwMDAwMDAwADAwMDAwMDAwMjU2ADAwMDAwMDAwMDAwADAzMTQyMAAgeAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB1c3RhcgAwMAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAx
NTQgcGF0aD1sb25nbmFtZS9sb25nbmFtZS9sb25nbmFtZS9sb25nbmFtZS9sb25nbmFtZS9sb25n
bmFtZS9sb25nbmFtZS9sb25nbmFtZS9sb25nbmFtZS9sb25nbmFtZS9sb25nbmFtZS9sb25nbmFt
ZS9sb25nbmFtZS9sb25nbmFtZS9sb25nbmFtZS8xNmdpZy50eHQKMjAgc2l6ZT0xNzE3OTg2OTE4
NAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGxv
bmduYW1lL2xvbmduYW1lL2xvbmduYW1lL2xvbmduYW1lL2xvbmduYW1lL2xvbmduYW1lL2xvbmdu
YW1lL2xvbmduYW1lL2xvbmduYW1lL2xvbmduYW1lL2xvbmduYW1lL2wwMDAwNjQ0ADAwMDE3NTAA
MDAwMTc1MAAwMDAwMDAwMDAwMAAxMjMzMjc3MDUwNwAwMzY0NjIAIDAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAdXN0YXIAMDBndWlsbGF1bWUAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAGd1aWxsYXVtZQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMDAwMDAwMAAwMDAwMDAw
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

View File

@@ -415,17 +415,11 @@ func (tw *Writer) AddFS(fsys fs.FS) error {
if err != nil {
return err
}
linkTarget := ""
if typ := d.Type(); typ == fs.ModeSymlink {
var err error
linkTarget, err = fs.ReadLink(fsys, name)
if err != nil {
return err
}
} else if !typ.IsRegular() && typ != fs.ModeDir {
// TODO(#49580): Handle symlinks when fs.ReadLinkFS is available.
if !d.IsDir() && !info.Mode().IsRegular() {
return errors.New("tar: cannot add non-regular file")
}
h, err := FileInfoHeader(info, linkTarget)
h, err := FileInfoHeader(info, "")
if err != nil {
return err
}
@@ -436,7 +430,7 @@ func (tw *Writer) AddFS(fsys fs.FS) error {
if err := tw.WriteHeader(h); err != nil {
return err
}
if !d.Type().IsRegular() {
if d.IsDir() {
return nil
}
f, err := fsys.Open(name)

View File

@@ -8,7 +8,6 @@ import (
"bytes"
"encoding/hex"
"errors"
"internal/obscuretestdata"
"io"
"io/fs"
"maps"
@@ -75,9 +74,8 @@ func TestWriter(t *testing.T) {
)
vectors := []struct {
file string // Optional filename of expected output
obscured bool // Whether file is obscured
tests []testFnc
file string // Optional filename of expected output
tests []testFnc
}{{
// The writer test file was produced with this command:
// tar (GNU tar) 1.26
@@ -153,8 +151,7 @@ func TestWriter(t *testing.T) {
// bsdtar -xvf writer-big-long.tar
//
// This file is in PAX format.
file: "testdata/writer-big-long.tar.base64",
obscured: true,
file: "testdata/writer-big-long.tar",
tests: []testFnc{
testHeader{Header{
Typeflag: TypeReg,
@@ -396,8 +393,7 @@ func TestWriter(t *testing.T) {
testClose{},
},
}, {
file: "testdata/gnu-sparse-big.tar.base64",
obscured: true,
file: "testdata/gnu-sparse-big.tar",
tests: []testFnc{
testHeader{Header{
Typeflag: TypeGNUSparse,
@@ -429,8 +425,7 @@ func TestWriter(t *testing.T) {
testClose{nil},
},
}, {
file: "testdata/pax-sparse-big.tar.base64",
obscured: true,
file: "testdata/pax-sparse-big.tar",
tests: []testFnc{
testHeader{Header{
Typeflag: TypeReg,
@@ -488,7 +483,7 @@ func TestWriter(t *testing.T) {
return x == y
}
for _, v := range vectors {
t.Run(strings.TrimSuffix(path.Base(v.file), ".base64"), func(t *testing.T) {
t.Run(path.Base(v.file), func(t *testing.T) {
const maxSize = 10 << 10 // 10KiB
buf := new(bytes.Buffer)
tw := NewWriter(iotest.TruncateWriter(buf, maxSize))
@@ -527,16 +522,7 @@ func TestWriter(t *testing.T) {
}
if v.file != "" {
path := v.file
if v.obscured {
tf, err := obscuretestdata.DecodeToTempFile(path)
if err != nil {
t.Fatalf("obscuretestdata.DecodeToTempFile(%s): %v", path, err)
}
path = tf
}
want, err := os.ReadFile(path)
want, err := os.ReadFile(v.file)
if err != nil {
t.Fatalf("ReadFile() = %v, want nil", err)
}
@@ -1356,7 +1342,6 @@ func TestWriterAddFS(t *testing.T) {
"emptyfolder": {Mode: 0o755 | os.ModeDir},
"file.go": {Data: []byte("hello")},
"subfolder/another.go": {Data: []byte("world")},
"symlink.go": {Mode: 0o777 | os.ModeSymlink, Data: []byte("file.go")},
// Notably missing here is the "subfolder" directory. This makes sure even
// if we don't have a subfolder directory listed.
}
@@ -1385,7 +1370,7 @@ func TestWriterAddFS(t *testing.T) {
for _, name := range names {
entriesLeft--
entryInfo, err := fsys.Lstat(name)
entryInfo, err := fsys.Stat(name)
if err != nil {
t.Fatalf("getting entry info error: %v", err)
}
@@ -1411,23 +1396,18 @@ func TestWriterAddFS(t *testing.T) {
name, entryInfo.Mode(), hdr.FileInfo().Mode())
}
switch entryInfo.Mode().Type() {
case fs.ModeDir:
// No additional checks necessary.
case fs.ModeSymlink:
origtarget := string(fsys[name].Data)
if hdr.Linkname != origtarget {
t.Fatalf("test fs has link content %s; archive header %v", origtarget, hdr.Linkname)
}
default:
data, err := io.ReadAll(tr)
if err != nil {
t.Fatal(err)
}
origdata := fsys[name].Data
if string(data) != string(origdata) {
t.Fatalf("test fs has file content %v; archive header has %v", origdata, data)
}
if entryInfo.IsDir() {
continue
}
data, err := io.ReadAll(tr)
if err != nil {
t.Fatal(err)
}
origdata := fsys[name].Data
if string(data) != string(origdata) {
t.Fatalf("test fs has file content %v; archive header has %v",
data, origdata)
}
}
if entriesLeft > 0 {

View File

@@ -8,7 +8,6 @@ import (
"bufio"
"encoding/binary"
"errors"
"fmt"
"hash"
"hash/crc32"
"internal/godebug"
@@ -805,9 +804,6 @@ func toValidName(name string) string {
func (r *Reader) initFileList() {
r.fileListOnce.Do(func() {
// Preallocate the minimum size of the index.
// We may also synthesize additional directory entries.
r.fileList = make([]fileListEntry, 0, len(r.File))
// files and knownDirs map from a file/directory name
// to an index into the r.fileList entry that we are
// building. They are used to mark duplicate entries.
@@ -989,12 +985,6 @@ func (d *openDir) ReadDir(count int) ([]fs.DirEntry, error) {
s, err := d.files[d.offset+i].stat()
if err != nil {
return nil, err
} else if s.Name() == "." || !fs.ValidPath(s.Name()) {
return nil, &fs.PathError{
Op: "readdir",
Path: d.e.name,
Err: fmt.Errorf("invalid file name: %v", d.files[d.offset+i].name),
}
}
list[i] = s
}

View File

@@ -8,7 +8,6 @@ import (
"bytes"
"encoding/binary"
"encoding/hex"
"errors"
"internal/obscuretestdata"
"io"
"io/fs"
@@ -1213,6 +1212,7 @@ func TestFS(t *testing.T) {
[]string{"a/b/c"},
},
} {
test := test
t.Run(test.file, func(t *testing.T) {
t.Parallel()
z, err := OpenReader(test.file)
@@ -1246,6 +1246,7 @@ func TestFSWalk(t *testing.T) {
wantErr: true,
},
} {
test := test
t.Run(test.file, func(t *testing.T) {
t.Parallel()
z, err := OpenReader(test.file)
@@ -1280,49 +1281,6 @@ func TestFSWalk(t *testing.T) {
}
}
func TestFSWalkBadFile(t *testing.T) {
t.Parallel()
var buf bytes.Buffer
zw := NewWriter(&buf)
hdr := &FileHeader{Name: "."}
hdr.SetMode(fs.ModeDir | 0o755)
w, err := zw.CreateHeader(hdr)
if err != nil {
t.Fatalf("create zip header: %v", err)
}
_, err = w.Write([]byte("some data"))
if err != nil {
t.Fatalf("write zip contents: %v", err)
}
err = zw.Close()
if err != nil {
t.Fatalf("close zip writer: %v", err)
}
zr, err := NewReader(bytes.NewReader(buf.Bytes()), int64(buf.Len()))
if err != nil {
t.Fatalf("create zip reader: %v", err)
}
var count int
var errRepeat = errors.New("repeated call to path")
err = fs.WalkDir(zr, ".", func(p string, d fs.DirEntry, err error) error {
count++
if count > 2 { // once for directory read, once for the error
return errRepeat
}
return err
})
if err == nil {
t.Fatalf("expected error from invalid file name")
} else if errors.Is(err, errRepeat) {
t.Fatal(err)
}
}
func TestFSModTime(t *testing.T) {
t.Parallel()
z, err := OpenReader("testdata/subdir.zip")

View File

@@ -311,7 +311,10 @@ func (b *Reader) ReadRune() (r rune, size int, err error) {
if b.r == b.w {
return 0, 0, b.readErr()
}
r, size = utf8.DecodeRune(b.buf[b.r:b.w])
r, size = rune(b.buf[b.r]), 1
if r >= utf8.RuneSelf {
r, size = utf8.DecodeRune(b.buf[b.r:b.w])
}
b.r += size
b.lastByte = int(b.buf[b.r-1])
b.lastRuneSize = size
@@ -516,11 +519,9 @@ func (b *Reader) WriteTo(w io.Writer) (n int64, err error) {
b.lastByte = -1
b.lastRuneSize = -1
if b.r < b.w {
n, err = b.writeBuf(w)
if err != nil {
return
}
n, err = b.writeBuf(w)
if err != nil {
return
}
if r, ok := b.rd.(io.WriterTo); ok {

View File

@@ -1149,7 +1149,7 @@ func (w errorWriterToTest) Write(p []byte) (int, error) {
var errorWriterToTests = []errorWriterToTest{
{1, 0, nil, io.ErrClosedPipe, io.ErrClosedPipe},
{0, 1, io.ErrClosedPipe, nil, io.ErrClosedPipe},
{0, 0, io.ErrUnexpectedEOF, io.ErrClosedPipe, io.ErrUnexpectedEOF},
{0, 0, io.ErrUnexpectedEOF, io.ErrClosedPipe, io.ErrClosedPipe},
{0, 1, io.EOF, nil, nil},
}

View File

@@ -1,96 +0,0 @@
// Copyright 2025 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.
//go:build unix
package bufio_test
import (
"bufio"
"io"
"net"
"path/filepath"
"strings"
"sync"
"testing"
)
// TestCopyUnixpacket tests that we can use bufio when copying
// across a unixpacket socket. This used to fail due to an unnecessary
// empty Write call that was interpreted as an EOF.
func TestCopyUnixpacket(t *testing.T) {
tmpDir := t.TempDir()
socket := filepath.Join(tmpDir, "unixsock")
// Start a unixpacket server.
addr := &net.UnixAddr{
Name: socket,
Net: "unixpacket",
}
server, err := net.ListenUnix("unixpacket", addr)
if err != nil {
t.Skipf("skipping test because opening a unixpacket socket failed: %v", err)
}
// Start a goroutine for the server to accept one connection
// and read all the data sent on the connection,
// reporting the number of bytes read on ch.
ch := make(chan int, 1)
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
tot := 0
defer func() {
ch <- tot
}()
serverConn, err := server.Accept()
if err != nil {
t.Error(err)
return
}
buf := make([]byte, 1024)
for {
n, err := serverConn.Read(buf)
tot += n
if err == io.EOF {
return
}
if err != nil {
t.Error(err)
return
}
}
}()
clientConn, err := net.DialUnix("unixpacket", nil, addr)
if err != nil {
// Leaves the server goroutine hanging. Oh well.
t.Fatal(err)
}
defer wg.Wait()
defer clientConn.Close()
const data = "data"
r := bufio.NewReader(strings.NewReader(data))
n, err := io.Copy(clientConn, r)
if err != nil {
t.Fatal(err)
}
if n != int64(len(data)) {
t.Errorf("io.Copy returned %d, want %d", n, len(data))
}
clientConn.Close()
tot := <-ch
if tot != len(data) {
t.Errorf("server read %d, want %d", tot, len(data))
}
}

View File

@@ -260,11 +260,8 @@ func (s *Scanner) setErr(err error) {
}
}
// Buffer controls memory allocation by the Scanner.
// It sets the initial buffer to use when scanning
// Buffer sets the initial buffer to use when scanning
// and the maximum size of buffer that may be allocated during scanning.
// The contents of the buffer are ignored.
//
// The maximum token size must be less than the larger of max and cap(buf).
// If max <= cap(buf), [Scanner.Scan] will use this buffer only and do no allocation.
//

View File

@@ -21,12 +21,6 @@ type Buffer struct {
buf []byte // contents are the bytes buf[off : len(buf)]
off int // read at &buf[off], write at &buf[len(buf)]
lastRead readOp // last read operation, so that Unread* can work correctly.
// Copying and modifying a non-zero Buffer is prone to error,
// but we cannot employ the noCopy trick used by WaitGroup and Mutex,
// which causes vet's copylocks checker to report misuse, as vet
// cannot reliably distinguish the zero and non-zero cases.
// See #26462, #25907, #47276, #48398 for history.
}
// The readOp constants describe the last action performed on
@@ -77,18 +71,6 @@ func (b *Buffer) String() string {
return string(b.buf[b.off:])
}
// Peek returns the next n bytes without advancing the buffer.
// If Peek returns fewer than n bytes, it also returns [io.EOF].
// The slice is only valid until the next call to a read or write method.
// The slice aliases the buffer content at least until the next buffer modification,
// so immediate changes to the slice will affect the result of future reads.
func (b *Buffer) Peek(n int) ([]byte, error) {
if b.Len() < n {
return b.buf[b.off:], io.EOF
}
return b.buf[b.off : b.off+n], nil
}
// empty reports whether the unread portion of the buffer is empty.
func (b *Buffer) empty() bool { return len(b.buf) <= b.off }

View File

@@ -354,7 +354,7 @@ func TestWriteAppend(t *testing.T) {
got.Write(b)
}
if !Equal(got.Bytes(), want) {
t.Fatalf("Bytes() = %q, want %q", &got, want)
t.Fatalf("Bytes() = %q, want %q", got, want)
}
// With a sufficiently sized buffer, there should be no allocations.
@@ -531,40 +531,6 @@ func TestReadString(t *testing.T) {
}
}
var peekTests = []struct {
buffer string
skip int
n int
expected string
err error
}{
{"", 0, 0, "", nil},
{"aaa", 0, 3, "aaa", nil},
{"foobar", 0, 2, "fo", nil},
{"a", 0, 2, "a", io.EOF},
{"helloworld", 4, 3, "owo", nil},
{"helloworld", 5, 5, "world", nil},
{"helloworld", 5, 6, "world", io.EOF},
{"helloworld", 10, 1, "", io.EOF},
}
func TestPeek(t *testing.T) {
for _, test := range peekTests {
buf := NewBufferString(test.buffer)
buf.Next(test.skip)
bytes, err := buf.Peek(test.n)
if string(bytes) != test.expected {
t.Errorf("expected %q, got %q", test.expected, bytes)
}
if err != test.err {
t.Errorf("expected error %v, got %v", test.err, err)
}
if buf.Len() != len(test.buffer)-test.skip {
t.Errorf("bad length after peek: %d, want %d", buf.Len(), len(test.buffer)-test.skip)
}
}
}
func BenchmarkReadString(b *testing.B) {
const n = 32 << 10

View File

@@ -451,9 +451,7 @@ var asciiSpace = [256]uint8{'\t': 1, '\n': 1, '\v': 1, '\f': 1, '\r': 1, ' ': 1}
// Fields interprets s as a sequence of UTF-8-encoded code points.
// It splits the slice s around each instance of one or more consecutive white space
// characters, as defined by [unicode.IsSpace], returning a slice of subslices of s or an
// empty slice if s contains only white space. Every element of the returned slice is
// non-empty. Unlike [Split], leading and trailing runs of white space characters
// are discarded.
// empty slice if s contains only white space.
func Fields(s []byte) [][]byte {
// First count the fields.
// This is an exact count if s is ASCII, otherwise it is an approximation.
@@ -507,9 +505,7 @@ func Fields(s []byte) [][]byte {
// FieldsFunc interprets s as a sequence of UTF-8-encoded code points.
// It splits the slice s at each run of code points c satisfying f(c) and
// returns a slice of subslices of s. If all code points in s satisfy f(c), or
// len(s) == 0, an empty slice is returned. Every element of the returned slice is
// non-empty. Unlike [Split], leading and trailing runs of code points
// satisfying f(c) are discarded.
// len(s) == 0, an empty slice is returned.
//
// FieldsFunc makes no guarantees about the order in which it calls f(c)
// and assumes that f always returns the same value for a given c.
@@ -528,7 +524,11 @@ func FieldsFunc(s []byte, f func(rune) bool) [][]byte {
// more efficient, possibly due to cache effects.
start := -1 // valid span start if >= 0
for i := 0; i < len(s); {
r, size := utf8.DecodeRune(s[i:])
size := 1
r := rune(s[i])
if r >= utf8.RuneSelf {
r, size = utf8.DecodeRune(s[i:])
}
if f(r) {
if start >= 0 {
spans = append(spans, span{start, i})
@@ -610,7 +610,11 @@ func Map(mapping func(r rune) rune, s []byte) []byte {
// fine. It could also shrink but that falls out naturally.
b := make([]byte, 0, len(s))
for i := 0; i < len(s); {
r, wid := utf8.DecodeRune(s[i:])
wid := 1
r := rune(s[i])
if r >= utf8.RuneSelf {
r, wid = utf8.DecodeRune(s[i:])
}
r = mapping(r)
if r >= 0 {
b = utf8.AppendRune(b, r)
@@ -909,7 +913,11 @@ func LastIndexFunc(s []byte, f func(r rune) bool) int {
func indexFunc(s []byte, f func(r rune) bool, truth bool) int {
start := 0
for start < len(s) {
r, wid := utf8.DecodeRune(s[start:])
wid := 1
r := rune(s[start])
if r >= utf8.RuneSelf {
r, wid = utf8.DecodeRune(s[start:])
}
if f(r) == truth {
return start
}
@@ -1040,7 +1048,10 @@ func trimLeftASCII(s []byte, as *asciiSet) []byte {
func trimLeftUnicode(s []byte, cutset string) []byte {
for len(s) > 0 {
r, n := utf8.DecodeRune(s)
r, n := rune(s[0]), 1
if r >= utf8.RuneSelf {
r, n = utf8.DecodeRune(s)
}
if !containsRune(cutset, r) {
break
}
@@ -1102,34 +1113,41 @@ func trimRightUnicode(s []byte, cutset string) []byte {
// TrimSpace returns a subslice of s by slicing off all leading and
// trailing white space, as defined by Unicode.
func TrimSpace(s []byte) []byte {
// Fast path for ASCII: look for the first ASCII non-space byte.
for lo, c := range s {
// Fast path for ASCII: look for the first ASCII non-space byte
start := 0
for ; start < len(s); start++ {
c := s[start]
if c >= utf8.RuneSelf {
// If we run into a non-ASCII byte, fall back to the
// slower unicode-aware method on the remaining bytes.
return TrimFunc(s[lo:], unicode.IsSpace)
// slower unicode-aware method on the remaining bytes
return TrimFunc(s[start:], unicode.IsSpace)
}
if asciiSpace[c] != 0 {
continue
}
s = s[lo:]
// Now look for the first ASCII non-space byte from the end.
for hi := len(s) - 1; hi >= 0; hi-- {
c := s[hi]
if c >= utf8.RuneSelf {
return TrimFunc(s[:hi+1], unicode.IsSpace)
}
if asciiSpace[c] == 0 {
// At this point, s[:hi+1] starts and ends with ASCII
// non-space bytes, so we're done. Non-ASCII cases have
// already been handled above.
return s[:hi+1]
}
if asciiSpace[c] == 0 {
break
}
}
// Special case to preserve previous TrimLeftFunc behavior,
// returning nil instead of empty slice if all spaces.
return nil
// Now look for the first ASCII non-space byte from the end
stop := len(s)
for ; stop > start; stop-- {
c := s[stop-1]
if c >= utf8.RuneSelf {
return TrimFunc(s[start:stop], unicode.IsSpace)
}
if asciiSpace[c] == 0 {
break
}
}
// At this point s[start:stop] starts and ends with an ASCII
// non-space bytes, so we're done. Non-ASCII cases have already
// been handled above.
if start == stop {
// Special case to preserve previous TrimLeftFunc behavior,
// returning nil instead of empty slice if all spaces.
return nil
}
return s[start:stop]
}
// Runes interprets s as a sequence of UTF-8-encoded code points.
@@ -1170,22 +1188,19 @@ func Replace(s, old, new []byte, n int) []byte {
t := make([]byte, len(s)+n*(len(new)-len(old)))
w := 0
start := 0
if len(old) > 0 {
for range n {
j := start + Index(s[start:], old)
w += copy(t[w:], s[start:j])
w += copy(t[w:], new)
start = j + len(old)
for i := 0; i < n; i++ {
j := start
if len(old) == 0 {
if i > 0 {
_, wid := utf8.DecodeRune(s[start:])
j += wid
}
} else {
j += Index(s[start:], old)
}
} else { // len(old) == 0
w += copy(t[w:], s[start:j])
w += copy(t[w:], new)
for range n - 1 {
_, wid := utf8.DecodeRune(s[start:])
j := start + wid
w += copy(t[w:], s[start:j])
w += copy(t[w:], new)
start = j
}
start = j + len(old)
}
w += copy(t[w:], s[start:])
return t[0:w]
@@ -1206,7 +1221,7 @@ func ReplaceAll(s, old, new []byte) []byte {
func EqualFold(s, t []byte) bool {
// ASCII fast path
i := 0
for n := min(len(s), len(t)); i < n; i++ {
for ; i < len(s) && i < len(t); i++ {
sr := s[i]
tr := t[i]
if sr|tr >= utf8.RuneSelf {
@@ -1236,10 +1251,19 @@ hasUnicode:
t = t[i:]
for len(s) != 0 && len(t) != 0 {
// Extract first rune from each.
sr, size := utf8.DecodeRune(s)
s = s[size:]
tr, size := utf8.DecodeRune(t)
t = t[size:]
var sr, tr rune
if s[0] < utf8.RuneSelf {
sr, s = rune(s[0]), s[1:]
} else {
r, size := utf8.DecodeRune(s)
sr, s = r, s[size:]
}
if t[0] < utf8.RuneSelf {
tr, t = rune(t[0]), t[1:]
} else {
r, size := utf8.DecodeRune(t)
tr, t = r, t[size:]
}
// If they match, keep going; if not, return false.

View File

@@ -7,7 +7,6 @@ package bytes_test
import (
. "bytes"
"fmt"
"internal/asan"
"internal/testenv"
"iter"
"math"
@@ -693,14 +692,14 @@ func bmIndexRuneUnicode(rt *unicode.RangeTable, needle rune) func(b *testing.B,
for _, r16 := range rt.R16 {
for r := rune(r16.Lo); r <= rune(r16.Hi); r += rune(r16.Stride) {
if r != needle {
rs = append(rs, r)
rs = append(rs, rune(r))
}
}
}
for _, r32 := range rt.R32 {
for r := rune(r32.Lo); r <= rune(r32.Hi); r += rune(r32.Stride) {
if r != needle {
rs = append(rs, r)
rs = append(rs, rune(r))
}
}
}
@@ -891,7 +890,9 @@ func BenchmarkCountSingle(b *testing.B) {
b.Fatal("bad count", j, expect)
}
}
clear(buf)
for i := 0; i < len(buf); i++ {
buf[i] = 0
}
})
}
@@ -961,7 +962,7 @@ func TestSplit(t *testing.T) {
if tt.n < 0 {
b := sliceOfString(Split([]byte(tt.s), []byte(tt.sep)))
if !slices.Equal(result, b) {
t.Errorf("Split disagrees with SplitN(%q, %q, %d) = %v; want %v", tt.s, tt.sep, tt.n, b, a)
t.Errorf("Split disagrees withSplitN(%q, %q, %d) = %v; want %v", tt.s, tt.sep, tt.n, b, a)
}
}
if len(a) > 0 {
@@ -1023,7 +1024,7 @@ func TestSplitAfter(t *testing.T) {
if tt.n < 0 {
b := sliceOfString(SplitAfter([]byte(tt.s), []byte(tt.sep)))
if !slices.Equal(result, b) {
t.Errorf("SplitAfter disagrees with SplitAfterN(%q, %q, %d) = %v; want %v", tt.s, tt.sep, tt.n, b, a)
t.Errorf("SplitAfter disagrees withSplitAfterN(%q, %q, %d) = %v; want %v", tt.s, tt.sep, tt.n, b, a)
}
}
}
@@ -1224,7 +1225,7 @@ func TestMap(t *testing.T) {
// Run a couple of awful growth/shrinkage tests
a := tenRunes('a')
// 1. Grow. This triggers two reallocations in Map.
// 1. Grow. This triggers two reallocations in Map.
maxRune := func(r rune) rune { return unicode.MaxRune }
m := Map(maxRune, []byte(a))
expect := tenRunes(unicode.MaxRune)
@@ -1785,20 +1786,9 @@ var ReplaceTests = []ReplaceTest{
func TestReplace(t *testing.T) {
for _, tt := range ReplaceTests {
var (
in = []byte(tt.in)
old = []byte(tt.old)
new = []byte(tt.new)
)
if !asan.Enabled {
allocs := testing.AllocsPerRun(10, func() { Replace(in, old, new, tt.n) })
if allocs > 1 {
t.Errorf("Replace(%q, %q, %q, %d) allocates %.2f objects", tt.in, tt.old, tt.new, tt.n, allocs)
}
}
in = append(in, "<spare>"...)
in := append([]byte(tt.in), "<spare>"...)
in = in[:len(tt.in)]
out := Replace(in, old, new, tt.n)
out := Replace(in, []byte(tt.old), []byte(tt.new), tt.n)
if s := string(out); s != tt.out {
t.Errorf("Replace(%q, %q, %q, %d) = %q, want %q", tt.in, tt.old, tt.new, tt.n, s, tt.out)
}
@@ -1806,7 +1796,7 @@ func TestReplace(t *testing.T) {
t.Errorf("Replace(%q, %q, %q, %d) didn't copy", tt.in, tt.old, tt.new, tt.n)
}
if tt.n == -1 {
out := ReplaceAll(in, old, new)
out := ReplaceAll(in, []byte(tt.old), []byte(tt.new))
if s := string(out); s != tt.out {
t.Errorf("ReplaceAll(%q, %q, %q) = %q, want %q", tt.in, tt.old, tt.new, s, tt.out)
}
@@ -1814,69 +1804,6 @@ func TestReplace(t *testing.T) {
}
}
func FuzzReplace(f *testing.F) {
for _, tt := range ReplaceTests {
f.Add([]byte(tt.in), []byte(tt.old), []byte(tt.new), tt.n)
}
f.Fuzz(func(t *testing.T, in, old, new []byte, n int) {
differentImpl := func(in, old, new []byte, n int) []byte {
var out Buffer
if n < 0 {
n = math.MaxInt
}
for i := 0; i < len(in); {
if n == 0 {
out.Write(in[i:])
break
}
if HasPrefix(in[i:], old) {
out.Write(new)
i += len(old)
n--
if len(old) != 0 {
continue
}
if i == len(in) {
break
}
}
if len(old) == 0 {
_, length := utf8.DecodeRune(in[i:])
out.Write(in[i : i+length])
i += length
} else {
out.WriteByte(in[i])
i++
}
}
if len(old) == 0 && n != 0 {
out.Write(new)
}
return out.Bytes()
}
if simple, replace := differentImpl(in, old, new, n), Replace(in, old, new, n); !slices.Equal(simple, replace) {
t.Errorf("The two implementations do not match %q != %q for Replace(%q, %q, %q, %d)", simple, replace, in, old, new, n)
}
})
}
func BenchmarkReplace(b *testing.B) {
for _, tt := range ReplaceTests {
desc := fmt.Sprintf("%q %q %q %d", tt.in, tt.old, tt.new, tt.n)
var (
in = []byte(tt.in)
old = []byte(tt.old)
new = []byte(tt.new)
)
b.Run(desc, func(b *testing.B) {
b.ReportAllocs()
for b.Loop() {
Replace(in, old, new, tt.n)
}
})
}
}
type TitleTest struct {
in, out string
}
@@ -2126,9 +2053,8 @@ func TestContainsFunc(t *testing.T) {
var makeFieldsInput = func() []byte {
x := make([]byte, 1<<20)
// Input is ~10% space, ~10% 2-byte UTF-8, rest ASCII non-space.
r := rand.New(rand.NewSource(99))
for i := range x {
switch r.Intn(10) {
switch rand.Intn(10) {
case 0:
x[i] = ' '
case 1:
@@ -2147,9 +2073,8 @@ var makeFieldsInput = func() []byte {
var makeFieldsInputASCII = func() []byte {
x := make([]byte, 1<<20)
// Input is ~10% space, rest ASCII non-space.
r := rand.New(rand.NewSource(99))
for i := range x {
if r.Intn(10) == 0 {
if rand.Intn(10) == 0 {
x[i] = ' '
} else {
x[i] = 'x'
@@ -2246,9 +2171,8 @@ func makeBenchInputHard() []byte {
"hello", "world",
}
x := make([]byte, 0, 1<<20)
r := rand.New(rand.NewSource(99))
for {
i := r.Intn(len(tokens))
i := rand.Intn(len(tokens))
if len(x)+len(tokens[i]) >= 1<<20 {
break
}

View File

@@ -245,9 +245,9 @@ func ExampleCut() {
}
func ExampleCutPrefix() {
show := func(s, prefix string) {
after, found := bytes.CutPrefix([]byte(s), []byte(prefix))
fmt.Printf("CutPrefix(%q, %q) = %q, %v\n", s, prefix, after, found)
show := func(s, sep string) {
after, found := bytes.CutPrefix([]byte(s), []byte(sep))
fmt.Printf("CutPrefix(%q, %q) = %q, %v\n", s, sep, after, found)
}
show("Gopher", "Go")
show("Gopher", "ph")
@@ -257,9 +257,9 @@ func ExampleCutPrefix() {
}
func ExampleCutSuffix() {
show := func(s, suffix string) {
before, found := bytes.CutSuffix([]byte(s), []byte(suffix))
fmt.Printf("CutSuffix(%q, %q) = %q, %v\n", s, suffix, before, found)
show := func(s, sep string) {
before, found := bytes.CutSuffix([]byte(s), []byte(sep))
fmt.Printf("CutSuffix(%q, %q) = %q, %v\n", s, sep, before, found)
}
show("Gopher", "Go")
show("Gopher", "er")
@@ -628,93 +628,3 @@ func ExampleToUpperSpecial() {
// Original : ahoj vývojári golang
// ToUpper : AHOJ VÝVOJÁRİ GOLANG
}
func ExampleLines() {
text := []byte("Hello\nWorld\nGo Programming\n")
for line := range bytes.Lines(text) {
fmt.Printf("%q\n", line)
}
// Output:
// "Hello\n"
// "World\n"
// "Go Programming\n"
}
func ExampleSplitSeq() {
s := []byte("a,b,c,d")
for part := range bytes.SplitSeq(s, []byte(",")) {
fmt.Printf("%q\n", part)
}
// Output:
// "a"
// "b"
// "c"
// "d"
}
func ExampleSplitAfterSeq() {
s := []byte("a,b,c,d")
for part := range bytes.SplitAfterSeq(s, []byte(",")) {
fmt.Printf("%q\n", part)
}
// Output:
// "a,"
// "b,"
// "c,"
// "d"
}
func ExampleFieldsSeq() {
text := []byte("The quick brown fox")
fmt.Println("Split byte slice into fields:")
for word := range bytes.FieldsSeq(text) {
fmt.Printf("%q\n", word)
}
textWithSpaces := []byte(" lots of spaces ")
fmt.Println("\nSplit byte slice with multiple spaces:")
for word := range bytes.FieldsSeq(textWithSpaces) {
fmt.Printf("%q\n", word)
}
// Output:
// Split byte slice into fields:
// "The"
// "quick"
// "brown"
// "fox"
//
// Split byte slice with multiple spaces:
// "lots"
// "of"
// "spaces"
}
func ExampleFieldsFuncSeq() {
text := []byte("The quick brown fox")
fmt.Println("Split on whitespace(similar to FieldsSeq):")
for word := range bytes.FieldsFuncSeq(text, unicode.IsSpace) {
fmt.Printf("%q\n", word)
}
mixedText := []byte("abc123def456ghi")
fmt.Println("\nSplit on digits:")
for word := range bytes.FieldsFuncSeq(mixedText, unicode.IsDigit) {
fmt.Printf("%q\n", word)
}
// Output:
// Split on whitespace(similar to FieldsSeq):
// "The"
// "quick"
// "brown"
// "fox"
//
// Split on digits:
// "abc"
// "def"
// "ghi"
}

View File

@@ -28,23 +28,30 @@ func Lines(s []byte) iter.Seq[[]byte] {
return
}
}
return
}
}
// explodeSeq returns an iterator over the runes in s.
func explodeSeq(s []byte) iter.Seq[[]byte] {
return func(yield func([]byte) bool) {
for len(s) > 0 {
_, size := utf8.DecodeRune(s)
if !yield(s[:size:size]) {
return
}
s = s[size:]
}
}
}
// splitSeq is SplitSeq or SplitAfterSeq, configured by how many
// bytes of sep to include in the results (none or all).
func splitSeq(s, sep []byte, sepSave int) iter.Seq[[]byte] {
if len(sep) == 0 {
return explodeSeq(s)
}
return func(yield func([]byte) bool) {
if len(sep) == 0 {
for len(s) > 0 {
_, size := utf8.DecodeRune(s)
if !yield(s[:size:size]) {
return
}
s = s[size:]
}
return
}
for {
i := Index(s, sep)
if i < 0 {
@@ -117,7 +124,11 @@ func FieldsFuncSeq(s []byte, f func(rune) bool) iter.Seq[[]byte] {
return func(yield func([]byte) bool) {
start := -1
for i := 0; i < len(s); {
r, size := utf8.DecodeRune(s[i:])
size := 1
r := rune(s[i])
if r >= utf8.RuneSelf {
r, size = utf8.DecodeRune(s[i:])
}
if f(r) {
if start >= 0 {
if !yield(s[start:i:i]) {

View File

@@ -1,56 +0,0 @@
// Copyright 2024 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 bytes_test
import (
. "bytes"
"testing"
)
func BenchmarkSplitSeqEmptySeparator(b *testing.B) {
for range b.N {
for range SplitSeq(benchInputHard, nil) {
}
}
}
func BenchmarkSplitSeqSingleByteSeparator(b *testing.B) {
sep := []byte("/")
for range b.N {
for range SplitSeq(benchInputHard, sep) {
}
}
}
func BenchmarkSplitSeqMultiByteSeparator(b *testing.B) {
sep := []byte("hello")
for range b.N {
for range SplitSeq(benchInputHard, sep) {
}
}
}
func BenchmarkSplitAfterSeqEmptySeparator(b *testing.B) {
for range b.N {
for range SplitAfterSeq(benchInputHard, nil) {
}
}
}
func BenchmarkSplitAfterSeqSingleByteSeparator(b *testing.B) {
sep := []byte("/")
for range b.N {
for range SplitAfterSeq(benchInputHard, sep) {
}
}
}
func BenchmarkSplitAfterSeqMultiByteSeparator(b *testing.B) {
sep := []byte("hello")
for range b.N {
for range SplitAfterSeq(benchInputHard, sep) {
}
}
}

View File

@@ -6,16 +6,27 @@
setlocal
go tool dist env -w -p >env.bat || exit /b 1
set GOBUILDFAIL=0
go tool dist env -w -p >env.bat
if errorlevel 1 goto fail
call .\env.bat
del env.bat
echo.
if not exist %GOTOOLDIR%\dist.exe (
echo cannot find %GOTOOLDIR%\dist.exe; nothing to clean
exit /b 1
)
if exist %GOTOOLDIR%\dist.exe goto distok
echo cannot find %GOTOOLDIR%\dist; nothing to clean
goto fail
:distok
"%GOBIN%\go" clean -i std
"%GOBIN%\go" tool dist clean
"%GOBIN%\go" clean -i cmd
goto end
:fail
set GOBUILDFAIL=1
:end
if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%

View File

@@ -99,11 +99,6 @@ func TestGolden(t *testing.T) {
}
func TestCompareAPI(t *testing.T) {
if *flagCheck {
// not worth repeating in -check
t.Skip("skipping with -check set")
}
tests := []struct {
name string
features, required, exception []string
@@ -185,11 +180,6 @@ func TestCompareAPI(t *testing.T) {
}
func TestSkipInternal(t *testing.T) {
if *flagCheck {
// not worth repeating in -check
t.Skip("skipping with -check set")
}
tests := []struct {
pkg string
want bool
@@ -304,20 +294,14 @@ func TestIssue41358(t *testing.T) {
}
func TestIssue64958(t *testing.T) {
if testing.Short() {
t.Skip("skipping with -short")
}
if *flagCheck {
// slow, not worth repeating in -check
t.Skip("skipping with -check set")
}
testenv.MustHaveGoBuild(t)
defer func() {
if x := recover(); x != nil {
t.Errorf("expected no panic; recovered %v", x)
}
}()
testenv.MustHaveGoBuild(t)
for _, context := range contexts {
w := NewWalker(context, "testdata/src/issue64958")
pkg, err := w.importFrom("p", "", 0)

View File

@@ -1058,7 +1058,7 @@ func (w *Walker) emitIfaceType(name string, typ *types.Interface) {
if w.isDeprecated(m) {
w.emitf("%s //deprecated", m.Name())
}
w.emitf("%s%s", m.Name(), w.signatureString(m.Signature()))
w.emitf("%s%s", m.Name(), w.signatureString(m.Type().(*types.Signature)))
}
if !complete {
@@ -1088,7 +1088,7 @@ func (w *Walker) emitIfaceType(name string, typ *types.Interface) {
}
func (w *Walker) emitFunc(f *types.Func) {
sig := f.Signature()
sig := f.Type().(*types.Signature)
if sig.Recv() != nil {
panic("method considered a regular function: " + f.String())
}

View File

@@ -1,6 +1,6 @@
pkg p1, const A //deprecated
pkg p1, const A = 1
pkg p1, const A ideal-int
pkg p1, const A //deprecated
pkg p1, const A64 = 1
pkg p1, const A64 int64
pkg p1, const AIsLowerA = 11
@@ -25,8 +25,8 @@ pkg p1, func TakesFunc(func(int) int)
pkg p1, method (*B) JustOnB()
pkg p1, method (*B) OnBothTandBPtr()
pkg p1, method (*Embedded) OnEmbedded()
pkg p1, method (*S2) SMethod //deprecated
pkg p1, method (*S2) SMethod(int8, int16, int64)
pkg p1, method (*S2) SMethod //deprecated
pkg p1, method (*T) JustOnT()
pkg p1, method (*T) OnBothTandBPtr()
pkg p1, method (B) OnBothTandBVal()
@@ -53,8 +53,8 @@ pkg p1, type Error interface { Error, Temporary }
pkg p1, type Error interface, Error() string
pkg p1, type Error interface, Temporary() bool
pkg p1, type FuncType func(int, int, string) (*B, error)
pkg p1, type I interface, Get //deprecated
pkg p1, type I interface, Get(string) int64
pkg p1, type I interface, Get //deprecated
pkg p1, type I interface, GetNamed(string) int64
pkg p1, type I interface, Name() string
pkg p1, type I interface, PackageTwoMeth()
@@ -63,9 +63,9 @@ pkg p1, type I interface, unexported methods
pkg p1, type MyInt int
pkg p1, type Namer interface { Name }
pkg p1, type Namer interface, Name() string
pkg p1, type Private //deprecated
pkg p1, type Private interface, X()
pkg p1, type Private interface, unexported methods
pkg p1, type Private //deprecated
pkg p1, type Public interface { X, Y }
pkg p1, type Public interface, X()
pkg p1, type Public interface, Y()
@@ -84,8 +84,8 @@ pkg p1, type TPtrExported struct
pkg p1, type TPtrExported struct, embedded *Embedded
pkg p1, type TPtrUnexported struct
pkg p1, type Time struct
pkg p1, type URL //deprecated
pkg p1, type URL struct
pkg p1, type URL //deprecated
pkg p1, var Byte uint8
pkg p1, var ByteConv []uint8
pkg p1, var ByteFunc func(uint8) int32
@@ -97,8 +97,8 @@ pkg p1, var StrConv string
pkg p1, var V string
pkg p1, var V1 uint64
pkg p1, var V2 p2.Twoer
pkg p1, var VError //deprecated
pkg p1, var VError Error
pkg p1, var VError //deprecated
pkg p1, var X I
pkg p1, var X0 int64
pkg p1, var Y int

View File

@@ -1,7 +1,8 @@
pkg p2, func F //deprecated
pkg p2, func F() string
pkg p2, func F //deprecated
pkg p2, func G() Twoer
pkg p2, func NewError(string) error
pkg p2, type Twoer interface { PackageTwoMeth }
pkg p2, type Twoer interface, PackageTwoMeth //deprecated
pkg p2, type Twoer interface, PackageTwoMeth()
pkg p2, type Twoer interface, PackageTwoMeth //deprecated

View File

@@ -1,6 +1,6 @@
pkg p4, func Clone //deprecated
pkg p4, func Clone[$0 interface{ ~[]$1 }, $1 interface{}]($0) $0
pkg p4, func NewPair[$0 interface{ M }, $1 interface{ ~int }]($0, $1) Pair[$0, $1]
pkg p4, method (Pair[$0, $1]) First() $0
pkg p4, method (Pair[$0, $1]) Second() $1
pkg p4, method (Pair[$0, $1]) First() $0
pkg p4, type Pair[$0 interface{ M }, $1 interface{ ~int }] struct
pkg p4, func Clone[$0 interface{ ~[]$1 }, $1 interface{}]($0) $0
pkg p4, func Clone //deprecated

View File

@@ -92,8 +92,7 @@ func jumpX86(word string) bool {
func jumpRISCV(word string) bool {
switch word {
case "BEQ", "BEQZ", "BGE", "BGEU", "BGEZ", "BGT", "BGTU", "BGTZ", "BLE", "BLEU", "BLEZ",
"BLT", "BLTU", "BLTZ", "BNE", "BNEZ", "CALL", "CBEQZ", "CBNEZ", "CJ", "CJALR", "CJR",
"JAL", "JALR", "JMP":
"BLT", "BLTU", "BLTZ", "BNE", "BNEZ", "CALL", "JAL", "JALR", "JMP":
return true
}
return false

View File

@@ -59,10 +59,10 @@ func jumpArm64(word string) bool {
var arm64SpecialOperand map[string]arm64.SpecialOperand
// ARM64SpecialOperand returns the internal representation of a special operand.
func ARM64SpecialOperand(name string) arm64.SpecialOperand {
// GetARM64SpecialOperand returns the internal representation of a special operand.
func GetARM64SpecialOperand(name string) arm64.SpecialOperand {
if arm64SpecialOperand == nil {
// Generate mapping when function is first called.
// Generate the mapping automatically when the first time the function is called.
arm64SpecialOperand = map[string]arm64.SpecialOperand{}
for opd := arm64.SPOP_BEGIN; opd < arm64.SPOP_END; opd++ {
arm64SpecialOperand[opd.String()] = opd
@@ -195,6 +195,149 @@ func ARM64RegisterShift(reg, op, count int16) (int64, error) {
return int64(reg&31)<<16 | int64(op)<<22 | int64(uint16(count)), nil
}
// ARM64RegisterExtension constructs an ARM64 register with extension or arrangement.
func ARM64RegisterExtension(a *obj.Addr, ext string, reg, num int16, isAmount, isIndex bool) error {
Rnum := (reg & 31) + int16(num<<5)
if isAmount {
if num < 0 || num > 7 {
return errors.New("index shift amount is out of range")
}
}
if reg <= arm64.REG_R31 && reg >= arm64.REG_R0 {
if !isAmount {
return errors.New("invalid register extension")
}
switch ext {
case "UXTB":
if a.Type == obj.TYPE_MEM {
return errors.New("invalid shift for the register offset addressing mode")
}
a.Reg = arm64.REG_UXTB + Rnum
case "UXTH":
if a.Type == obj.TYPE_MEM {
return errors.New("invalid shift for the register offset addressing mode")
}
a.Reg = arm64.REG_UXTH + Rnum
case "UXTW":
// effective address of memory is a base register value and an offset register value.
if a.Type == obj.TYPE_MEM {
a.Index = arm64.REG_UXTW + Rnum
} else {
a.Reg = arm64.REG_UXTW + Rnum
}
case "UXTX":
if a.Type == obj.TYPE_MEM {
return errors.New("invalid shift for the register offset addressing mode")
}
a.Reg = arm64.REG_UXTX + Rnum
case "SXTB":
if a.Type == obj.TYPE_MEM {
return errors.New("invalid shift for the register offset addressing mode")
}
a.Reg = arm64.REG_SXTB + Rnum
case "SXTH":
if a.Type == obj.TYPE_MEM {
return errors.New("invalid shift for the register offset addressing mode")
}
a.Reg = arm64.REG_SXTH + Rnum
case "SXTW":
if a.Type == obj.TYPE_MEM {
a.Index = arm64.REG_SXTW + Rnum
} else {
a.Reg = arm64.REG_SXTW + Rnum
}
case "SXTX":
if a.Type == obj.TYPE_MEM {
a.Index = arm64.REG_SXTX + Rnum
} else {
a.Reg = arm64.REG_SXTX + Rnum
}
case "LSL":
a.Index = arm64.REG_LSL + Rnum
default:
return errors.New("unsupported general register extension type: " + ext)
}
} else if reg <= arm64.REG_V31 && reg >= arm64.REG_V0 {
switch ext {
case "B8":
if isIndex {
return errors.New("invalid register extension")
}
a.Reg = arm64.REG_ARNG + (reg & 31) + ((arm64.ARNG_8B & 15) << 5)
case "B16":
if isIndex {
return errors.New("invalid register extension")
}
a.Reg = arm64.REG_ARNG + (reg & 31) + ((arm64.ARNG_16B & 15) << 5)
case "H4":
if isIndex {
return errors.New("invalid register extension")
}
a.Reg = arm64.REG_ARNG + (reg & 31) + ((arm64.ARNG_4H & 15) << 5)
case "H8":
if isIndex {
return errors.New("invalid register extension")
}
a.Reg = arm64.REG_ARNG + (reg & 31) + ((arm64.ARNG_8H & 15) << 5)
case "S2":
if isIndex {
return errors.New("invalid register extension")
}
a.Reg = arm64.REG_ARNG + (reg & 31) + ((arm64.ARNG_2S & 15) << 5)
case "S4":
if isIndex {
return errors.New("invalid register extension")
}
a.Reg = arm64.REG_ARNG + (reg & 31) + ((arm64.ARNG_4S & 15) << 5)
case "D1":
if isIndex {
return errors.New("invalid register extension")
}
a.Reg = arm64.REG_ARNG + (reg & 31) + ((arm64.ARNG_1D & 15) << 5)
case "D2":
if isIndex {
return errors.New("invalid register extension")
}
a.Reg = arm64.REG_ARNG + (reg & 31) + ((arm64.ARNG_2D & 15) << 5)
case "Q1":
if isIndex {
return errors.New("invalid register extension")
}
a.Reg = arm64.REG_ARNG + (reg & 31) + ((arm64.ARNG_1Q & 15) << 5)
case "B":
if !isIndex {
return nil
}
a.Reg = arm64.REG_ELEM + (reg & 31) + ((arm64.ARNG_B & 15) << 5)
a.Index = num
case "H":
if !isIndex {
return nil
}
a.Reg = arm64.REG_ELEM + (reg & 31) + ((arm64.ARNG_H & 15) << 5)
a.Index = num
case "S":
if !isIndex {
return nil
}
a.Reg = arm64.REG_ELEM + (reg & 31) + ((arm64.ARNG_S & 15) << 5)
a.Index = num
case "D":
if !isIndex {
return nil
}
a.Reg = arm64.REG_ELEM + (reg & 31) + ((arm64.ARNG_D & 15) << 5)
a.Index = num
default:
return errors.New("unsupported simd register extension type: " + ext)
}
} else {
return errors.New("invalid register and extension combination")
}
return nil
}
// ARM64RegisterArrangement constructs an ARM64 vector register arrangement.
func ARM64RegisterArrangement(reg int16, name, arng string) (int64, error) {
var curQ, curSize uint16

View File

@@ -23,6 +23,18 @@ func jumpLoong64(word string) bool {
return false
}
// IsLoong64MUL reports whether the op (as defined by an loong64.A* constant) is
// one of the MUL/DIV/REM instructions that require special handling.
func IsLoong64MUL(op obj.As) bool {
switch op {
case loong64.AMUL, loong64.AMULU, loong64.AMULV, loong64.AMULVU,
loong64.ADIV, loong64.ADIVU, loong64.ADIVV, loong64.ADIVVU,
loong64.AREM, loong64.AREMU, loong64.AREMV, loong64.AREMVU:
return true
}
return false
}
// IsLoong64RDTIME reports whether the op (as defined by an loong64.A*
// constant) is one of the RDTIMELW/RDTIMEHW/RDTIMED instructions that
// require special handling.
@@ -34,14 +46,6 @@ func IsLoong64RDTIME(op obj.As) bool {
return false
}
func IsLoong64PRELD(op obj.As) bool {
switch op {
case loong64.APRELD, loong64.APRELDX:
return true
}
return false
}
func IsLoong64AMO(op obj.As) bool {
return loong64.IsAtomicInst(op)
}

View File

@@ -11,11 +11,11 @@ package arch
import (
"cmd/internal/obj"
"cmd/internal/obj/riscv"
"fmt"
)
// IsRISCV64AMO reports whether op is an AMO instruction that requires
// special handling.
// IsRISCV64AMO reports whether the op (as defined by a riscv.A*
// constant) is one of the AMO instructions that requires special
// handling.
func IsRISCV64AMO(op obj.As) bool {
switch op {
case riscv.ASCW, riscv.ASCD, riscv.AAMOSWAPW, riscv.AAMOSWAPD, riscv.AAMOADDW, riscv.AAMOADDD,
@@ -26,59 +26,3 @@ func IsRISCV64AMO(op obj.As) bool {
}
return false
}
// IsRISCV64VTypeI reports whether op is a vtype immediate instruction that
// requires special handling.
func IsRISCV64VTypeI(op obj.As) bool {
return op == riscv.AVSETVLI || op == riscv.AVSETIVLI
}
// IsRISCV64CSRO reports whether the op is an instruction that uses
// CSR symbolic names and whether that instruction expects a register
// or an immediate source operand.
func IsRISCV64CSRO(op obj.As) (imm bool, ok bool) {
switch op {
case riscv.ACSRRCI, riscv.ACSRRSI, riscv.ACSRRWI:
imm = true
fallthrough
case riscv.ACSRRC, riscv.ACSRRS, riscv.ACSRRW:
ok = true
}
return
}
var riscv64SpecialOperand map[string]riscv.SpecialOperand
// RISCV64SpecialOperand returns the internal representation of a special operand.
func RISCV64SpecialOperand(name string) riscv.SpecialOperand {
if riscv64SpecialOperand == nil {
// Generate mapping when function is first called.
riscv64SpecialOperand = map[string]riscv.SpecialOperand{}
for opd := riscv.SPOP_RVV_BEGIN; opd < riscv.SPOP_RVV_END; opd++ {
riscv64SpecialOperand[opd.String()] = opd
}
// Add the CSRs
for csrCode, csrName := range riscv.CSRs {
// The set of RVV special operand names and the set of CSR special operands
// names are disjoint and so can safely share a single namespace. However,
// it's possible that a future update to the CSRs in inst.go could introduce
// a conflict. This check ensures that such a conflict does not go
// unnoticed.
if _, ok := riscv64SpecialOperand[csrName]; ok {
panic(fmt.Sprintf("riscv64 special operand %q redefined", csrName))
}
riscv64SpecialOperand[csrName] = riscv.SpecialOperand(int(csrCode) + int(riscv.SPOP_CSR_BEGIN))
}
}
if opd, ok := riscv64SpecialOperand[name]; ok {
return opd
}
return riscv.SPOP_END
}
// RISCV64ValidateVectorType reports whether the given configuration is a
// valid vector type.
func RISCV64ValidateVectorType(vsew, vlmul, vtail, vmask int64) error {
_, err := riscv.EncodeVectorType(vsew, vlmul, vtail, vmask)
return err
}

View File

@@ -248,7 +248,7 @@ func (p *Parser) asmData(operands [][]lex.Token) {
case obj.TYPE_CONST:
switch sz {
case 1, 2, 4, 8:
nameAddr.Sym.WriteInt(p.ctxt, nameAddr.Offset, sz, valueAddr.Offset)
nameAddr.Sym.WriteInt(p.ctxt, nameAddr.Offset, int(sz), valueAddr.Offset)
default:
p.errorf("bad int size for DATA argument: %d", sz)
}
@@ -262,10 +262,10 @@ func (p *Parser) asmData(operands [][]lex.Token) {
p.errorf("bad float size for DATA argument: %d", sz)
}
case obj.TYPE_SCONST:
nameAddr.Sym.WriteString(p.ctxt, nameAddr.Offset, sz, valueAddr.Val.(string))
nameAddr.Sym.WriteString(p.ctxt, nameAddr.Offset, int(sz), valueAddr.Val.(string))
case obj.TYPE_ADDR:
if sz == p.arch.PtrSize {
nameAddr.Sym.WriteAddr(p.ctxt, nameAddr.Offset, sz, valueAddr.Sym, valueAddr.Offset)
nameAddr.Sym.WriteAddr(p.ctxt, nameAddr.Offset, int(sz), valueAddr.Sym, valueAddr.Offset)
} else {
p.errorf("bad addr size for DATA argument: %d", sz)
}
@@ -654,12 +654,6 @@ func (p *Parser) asmInstruction(op obj.As, cond string, a []obj.Addr) {
prog.RegTo2 = a[1].Reg
break
}
if arch.IsLoong64PRELD(op) {
prog.From = a[0]
prog.AddRestSource(a[1])
break
}
}
prog.From = a[0]
prog.To = a[1]
@@ -676,11 +670,6 @@ func (p *Parser) asmInstruction(op obj.As, cond string, a []obj.Addr) {
prog.From = a[0]
prog.To = a[1]
prog.RegTo2 = a[2].Reg
case arch.IsLoong64PRELD(op):
prog.From = a[0]
prog.AddRestSourceArgs([]obj.Addr{a[1], a[2]})
default:
prog.From = a[0]
prog.Reg = p.getRegister(prog, op, &a[1])
@@ -782,21 +771,6 @@ func (p *Parser) asmInstruction(op obj.As, cond string, a []obj.Addr) {
prog.RegTo2 = a[2].Reg
break
}
// RISCV64 instructions that reference CSRs with symbolic names.
if isImm, ok := arch.IsRISCV64CSRO(op); ok {
if a[0].Type != obj.TYPE_CONST && isImm {
p.errorf("invalid value for first operand to %s instruction, must be a 5 bit unsigned immediate", op)
return
}
if a[1].Type != obj.TYPE_SPECIAL {
p.errorf("invalid value for second operand to %s instruction, must be a CSR name", op)
return
}
prog.AddRestSourceArgs([]obj.Addr{a[1]})
prog.From = a[0]
prog.To = a[2]
break
}
prog.From = a[0]
prog.Reg = p.getRegister(prog, op, &a[1])
prog.To = a[2]
@@ -941,19 +915,6 @@ func (p *Parser) asmInstruction(op obj.As, cond string, a []obj.Addr) {
prog.To = a[5]
break
}
if p.arch.Family == sys.RISCV64 && arch.IsRISCV64VTypeI(op) {
prog.From = a[0]
vsew := p.getSpecial(prog, op, &a[1])
vlmul := p.getSpecial(prog, op, &a[2])
vtail := p.getSpecial(prog, op, &a[3])
vmask := p.getSpecial(prog, op, &a[4])
if err := arch.RISCV64ValidateVectorType(vsew, vlmul, vtail, vmask); err != nil {
p.errorf("invalid vtype: %v", err)
}
prog.AddRestSourceArgs([]obj.Addr{a[1], a[2], a[3], a[4]})
prog.To = a[5]
break
}
fallthrough
default:
p.errorf("can't handle %s instruction with %d operands", op, len(a))
@@ -989,6 +950,14 @@ func (p *Parser) getConstant(prog *obj.Prog, op obj.As, addr *obj.Addr) int64 {
return addr.Offset
}
// getImmediate checks that addr represents an immediate constant and returns its value.
func (p *Parser) getImmediate(prog *obj.Prog, op obj.As, addr *obj.Addr) int64 {
if addr.Type != obj.TYPE_CONST || addr.Name != 0 || addr.Reg != 0 || addr.Index != 0 {
p.errorf("%s: expected immediate constant; found %s", op, obj.Dconv(prog, addr))
}
return addr.Offset
}
// getRegister checks that addr represents a register and returns its value.
func (p *Parser) getRegister(prog *obj.Prog, op obj.As, addr *obj.Addr) int16 {
if addr.Type != obj.TYPE_REG || addr.Offset != 0 || addr.Name != 0 || addr.Index != 0 {
@@ -996,11 +965,3 @@ func (p *Parser) getRegister(prog *obj.Prog, op obj.As, addr *obj.Addr) int16 {
}
return addr.Reg
}
// getSpecial checks that addr represents a special operand and returns its value.
func (p *Parser) getSpecial(prog *obj.Prog, op obj.As, addr *obj.Addr) int64 {
if addr.Type != obj.TYPE_SPECIAL || addr.Name != 0 || addr.Reg != 0 || addr.Index != 0 {
p.errorf("%s: expected special operand; found %s", op, obj.Dconv(prog, addr))
}
return addr.Offset
}

View File

@@ -38,7 +38,7 @@ func testEndToEnd(t *testing.T, goarch, file string) {
ctxt.IsAsm = true
defer ctxt.Bso.Flush()
failed := false
ctxt.DiagFunc = func(format string, args ...any) {
ctxt.DiagFunc = func(format string, args ...interface{}) {
failed = true
t.Errorf(format, args...)
}
@@ -193,17 +193,12 @@ Diff:
top := pList.Firstpc
var text *obj.LSym
ok = true
ctxt.DiagFunc = func(format string, args ...any) {
ctxt.DiagFunc = func(format string, args ...interface{}) {
t.Errorf(format, args...)
ok = false
}
obj.Flushplist(ctxt, pList, nil)
if !ok {
// If we've encountered errors, the output is unlikely to be sane.
t.FailNow()
}
for p := top; p != nil; p = p.Link {
if p.As == obj.ATEXT {
text = p.From.Sym
@@ -299,7 +294,7 @@ func testErrors(t *testing.T, goarch, file string, flags ...string) {
failed := false
var errBuf bytes.Buffer
parser.errorWriter = &errBuf
ctxt.DiagFunc = func(format string, args ...any) {
ctxt.DiagFunc = func(format string, args ...interface{}) {
failed = true
s := fmt.Sprintf(format, args...)
if !strings.HasSuffix(s, "\n") {
@@ -470,16 +465,9 @@ func TestLOONG64Encoder(t *testing.T) {
testEndToEnd(t, "loong64", "loong64enc1")
testEndToEnd(t, "loong64", "loong64enc2")
testEndToEnd(t, "loong64", "loong64enc3")
testEndToEnd(t, "loong64", "loong64enc4")
testEndToEnd(t, "loong64", "loong64enc5")
testEndToEnd(t, "loong64", "loong64enc6")
testEndToEnd(t, "loong64", "loong64")
}
func TestLOONG64Errors(t *testing.T) {
testErrors(t, "loong64", "loong64error")
}
func TestPPC64EndToEnd(t *testing.T) {
defer func(old int) { buildcfg.GOPPC64 = old }(buildcfg.GOPPC64)
for _, goppc64 := range []int{8, 9, 10} {
@@ -491,35 +479,12 @@ func TestPPC64EndToEnd(t *testing.T) {
}
}
func testRISCV64AllProfiles(t *testing.T, testFn func(t *testing.T)) {
t.Helper()
defer func(orig int) { buildcfg.GORISCV64 = orig }(buildcfg.GORISCV64)
for _, goriscv64 := range []int{20, 22, 23} {
t.Run(fmt.Sprintf("rva%vu64", goriscv64), func(t *testing.T) {
buildcfg.GORISCV64 = goriscv64
testFn(t)
})
}
func TestRISCVEndToEnd(t *testing.T) {
testEndToEnd(t, "riscv64", "riscv64")
}
func TestRISCV64EndToEnd(t *testing.T) {
testRISCV64AllProfiles(t, func(t *testing.T) {
testEndToEnd(t, "riscv64", "riscv64")
})
}
func TestRISCV64Errors(t *testing.T) {
testRISCV64AllProfiles(t, func(t *testing.T) {
testErrors(t, "riscv64", "riscv64error")
})
}
func TestRISCV64Validation(t *testing.T) {
testRISCV64AllProfiles(t, func(t *testing.T) {
testErrors(t, "riscv64", "riscv64validation")
})
func TestRISCVErrors(t *testing.T) {
testErrors(t, "riscv64", "riscv64error")
}
func TestS390XEndToEnd(t *testing.T) {

View File

@@ -21,7 +21,6 @@ import (
"cmd/asm/internal/lex"
"cmd/internal/obj"
"cmd/internal/obj/arm64"
"cmd/internal/obj/riscv"
"cmd/internal/obj/x86"
"cmd/internal/objabi"
"cmd/internal/src"
@@ -78,7 +77,7 @@ func NewParser(ctxt *obj.Link, ar *arch.Arch, lexer lex.TokenReader) *Parser {
// and turn it into a recoverable panic.
var panicOnError bool
func (p *Parser) errorf(format string, args ...any) {
func (p *Parser) errorf(format string, args ...interface{}) {
if panicOnError {
panic(fmt.Errorf(format, args...))
}
@@ -90,7 +89,7 @@ func (p *Parser) errorf(format string, args ...any) {
if p.lex != nil {
// Put file and line information on head of message.
format = "%s:%d: " + format + "\n"
args = append([]any{p.lex.File(), p.lineNum}, args...)
args = append([]interface{}{p.lex.File(), p.lineNum}, args...)
}
fmt.Fprintf(p.errorWriter, format, args...)
p.errorCount++
@@ -399,21 +398,16 @@ func (p *Parser) operand(a *obj.Addr) {
tok := p.next()
name := tok.String()
if tok.ScanToken == scanner.Ident && !p.atStartOfRegister(name) {
// See if this is an architecture specific special operand.
switch p.arch.Family {
case sys.ARM64:
if opd := arch.ARM64SpecialOperand(name); opd != arm64.SPOP_END {
// arm64 special operands.
if opd := arch.GetARM64SpecialOperand(name); opd != arm64.SPOP_END {
a.Type = obj.TYPE_SPECIAL
a.Offset = int64(opd)
break
}
case sys.RISCV64:
if opd := arch.RISCV64SpecialOperand(name); opd != riscv.SPOP_END {
a.Type = obj.TYPE_SPECIAL
a.Offset = int64(opd)
}
}
if a.Type != obj.TYPE_SPECIAL {
fallthrough
default:
// We have a symbol. Parse $sym±offset(symkind)
p.symbolReference(a, p.qualifySymbol(name), prefix)
}
@@ -775,7 +769,7 @@ func (p *Parser) registerExtension(a *obj.Addr, name string, prefix rune) {
switch p.arch.Family {
case sys.ARM64:
err := arm64.ARM64RegisterExtension(a, ext, reg, num, isAmount, isIndex)
err := arch.ARM64RegisterExtension(a, ext, reg, num, isAmount, isIndex)
if err != nil {
p.errorf("%v", err)
}

View File

@@ -169,8 +169,3 @@ TEXT ·a34(SB), 0, $0-0
SHLXQ AX, CX, R15
ADDQ $1, R15
RET
// Ensure from3 get GOT-rewritten without errors.
TEXT ·a35(SB), 0, $0-0
VGF2P8AFFINEQB $0, runtime·writeBarrier(SB), Z1, Z1
RET

View File

@@ -1059,7 +1059,5 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
RDPID DX // f30fc7fa
RDPID R11 // f3410fc7fb
ENDBR64 // f30f1efa
// End of tests.
RET

View File

@@ -400,8 +400,6 @@ TEXT foo(SB), DUPOK|NOSPLIT, $-8
MOVD $0x11110000, R1 // MOVD $286326784, R1 // 2122a2d2
MOVD $0xaaaa0000aaaa1111, R1 // MOVD $-6149102338357718767, R1 // 212282d24155b5f24155f5f2
MOVD $0x1111ffff1111aaaa, R1 // MOVD $1230045644216969898, R1 // a1aa8a922122a2f22122e2f2
MOVD $0xaaaaaaaaaaaaaaab, R1 // MOVD $-6148914691236517205, R1 // e1f301b2615595f2
MOVD $0x0ff019940ff00ff0, R1 // MOVD $1148446028692721648, R1 // e19f0cb28132c3f2
MOVD $0, R1 // e1031faa
MOVD $-1, R1 // 01008092
MOVD $0x210000, R0 // MOVD $2162688, R0 // 2004a0d2
@@ -632,8 +630,6 @@ TEXT foo(SB), DUPOK|NOSPLIT, $-8
FMOVS F1, 0x44332211(R2) // FMOVS F1, 1144201745(R2)
FMOVD F1, 0x1007000(R2) // FMOVD F1, 16805888(R2)
FMOVD F1, 0x44332211(R2) // FMOVD F1, 1144201745(R2)
FMOVQ F1, 0x1003000(R2) // FMOVQ F1, 16789504(R2)
FMOVQ F1, 0x44332211(R2) // FMOVQ F1, 1144201745(R2)
MOVB 0x1000000(R1), R2 // MOVB 16777216(R1), R2
MOVB 0x44332211(R1), R2 // MOVB 1144201745(R1), R2
@@ -647,8 +643,6 @@ TEXT foo(SB), DUPOK|NOSPLIT, $-8
FMOVS 0x44332211(R1), F2 // FMOVS 1144201745(R1), F2
FMOVD 0x1000000(R1), F2 // FMOVD 16777216(R1), F2
FMOVD 0x44332211(R1), F2 // FMOVD 1144201745(R1), F2
FMOVQ 0x1000000(R1), F2 // FMOVQ 16777216(R1), F2
FMOVQ 0x44332211(R1), F2 // FMOVQ 1144201745(R1), F2
// shifted or extended register offset.
MOVD (R2)(R6.SXTW), R4 // 44c866f8
@@ -1894,18 +1888,4 @@ next:
DC CIGDVAC, R25 // b97e0bd5
DC CVAP, R26 // 3a7c0bd5
DC CVADP, R27 // 3b7d0bd5
// Branch Target Identification
BTI C // 5f2403d5
BTI J // 9f2403d5
BTI JC // df2403d5
// Pointer Authentication Codes (PAC)
PACIASP // 3f2303d5
AUTIASP // bf2303d5
PACIBSP // 7f2303d5
AUTIBSP // ff2303d5
AUTIA1716 // 9f2103d5
AUTIB1716 // df2103d5
END

View File

@@ -420,12 +420,4 @@ TEXT errors(SB),$0
AESE V1.B16, V2.B8 // ERROR "invalid arrangement"
SHA256SU1 V1.S4, V2.B16, V3.S4 // ERROR "invalid arrangement"
SHA1H V1.B16, V2.B16 // ERROR "invalid operands"
BTI // ERROR "missing operand"
BTI PLDL1KEEP // ERROR "illegal argument"
PACIASP C // ERROR "illegal combination"
AUTIASP R2 // ERROR "illegal combination"
PACIBSP R0 // ERROR "illegal combination"
AUTIBSP C // ERROR "illegal combination"
AUTIA1716 $45 // ERROR "illegal combination"
AUTIB1716 R0 // ERROR "illegal combination"
RET

File diff suppressed because it is too large Load Diff

View File

@@ -12,7 +12,7 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
AND $-1, R4, R5 // 1efcbf0285f81400
AND $-1, R4 // 1efcbf0284f81400
MOVW $-1, F4 // 1efcbf02c4a71401
MOVW $1, F4 // 1e048003c4a71401
MOVW $1, F4 // 1e048002c4a71401
TEQ $4, R4, R5 // 8508005c04002a00
TEQ $4, R4 // 0408005c04002a00
TNE $4, R4, R5 // 8508005804002a00
@@ -21,10 +21,6 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
ADD $4096, R4, R5 // 3e00001485781000
ADD $65536, R4 // 1e02001484781000
ADD $4096, R4 // 3e00001484781000
ADDW $65536, R4, R5 // 1e02001485781000
ADDW $4096, R4, R5 // 3e00001485781000
ADDW $65536, R4 // 1e02001484781000
ADDW $4096, R4 // 3e00001484781000
ADDV $65536, R4, R5 // 1e02001485f81000
ADDV $4096, R4, R5 // 3e00001485f81000
ADDV $65536, R4 // 1e02001484f81000
@@ -41,6 +37,10 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
SGTU $4096, R4, R5 // 3e00001485f81200
SGTU $65536, R4 // 1e02001484f81200
SGTU $4096, R4 // 3e00001484f81200
ADDU $65536, R4, R5 // 1e02001485781000
ADDU $4096, R4, R5 // 3e00001485781000
ADDU $65536, R4 // 1e02001484781000
ADDU $4096, R4 // 3e00001484781000
ADDVU $65536, R4, R5 // 1e02001485f81000
ADDVU $4096, R4, R5 // 3e00001485f81000
ADDVU $65536, R4 // 1e02001484f81000
@@ -77,49 +77,3 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
MOVH name(SB), R4 // 1e00001ac4034028
MOVHU R4, name(SB) // 1e00001ac4034029
MOVHU name(SB), R4 // 1e00001ac403402a
// MOVV C_DCON12_20S, r
MOVV $0x273fffff80000000, R4 // MOVV $2828260563841187840, R4 // 0400001584cc0903
MOVV $0xf73fffff80000000, R4 // MOVV $-630503949979353088, R4 // 0400001584cc3d03
// MOVV C_DCON20S_20, r
MOVV $0xfff800000f000000, R4 // MOVV $-2251799562027008, R4 // 04001e1404000017
// MOVV C_DCON12_12S, r
MOVV $0x273ffffffffff800, R4 // MOVV $2828260565988669440, R4 // 0400e00284cc0903
MOVV $0xf73ffffffffff800, R4 // MOVV $-630503947831871488, R4 // 0400e00284cc3d03
// MOVV C_DCON20S_12S, r
MOVV $0xfff80000fffff800, R4 // MOVV $-2251795518720000, R4 // 0400a00204000017
MOVV $0xfff8000000000000, R4 // MOVV $-2251799813685248, R4 // 0400800204000017
// MOVV C_DCON12_12U, r
MOVV $0x2730000000000800, R4 // MOVV $2823756966361303040, R4 // 0400a00384cc0903
MOVV $0xf730000000000800, R4 // MOVV $-635007547459237888, R4 // 0400a00384cc3d03
// MOVV C_DCON20S_12U, r
MOVV $0xfff8000000000800, R4 // MOVV $-2251799813683200, R4 // 0400a00304000017
// ADDV/AND C_DCON12_0, [r1], r2
ADDV $0x3210000000000000, R4 // ADDV $3607383301523767296, R4 // 1e840c0384f81000
ADDV $0x3210000000000000, R5, R4 // ADDV $3607383301523767296, R5, R4 // 1e840c03a4f81000
ADDV $0xc210000000000000, R4 // ADDV $-4463067230724161536, R4 // 1e84300384f81000
ADDV $0xc210000000000000, R5, R4 // ADDV $-4463067230724161536, R5, R4 // 1e843003a4f81000
AND $0x3210000000000000, R4 // AND $3607383301523767296, R4 // 1e840c0384f81400
AND $0x3210000000000000, R5, R4 // AND $3607383301523767296, R5, R4 // 1e840c03a4f81400
AND $0xc210000000000000, R4 // AND $-4463067230724161536, R4 // 1e84300384f81400
AND $0xc210000000000000, R5, R4 // AND $-4463067230724161536, R5, R4 // 1e843003a4f81400
// ADDV/AND C_UCON, [r1], r2
ADDV $0x43210000, R4 // ADDV $1126236160, R4 // 1e42861484f81000
ADDV $0x43210000, R5, R4 // ADDV $1126236160, R5, R4 // 1e428614a4f81000
ADDV $0xffffffffc3210000, R4 // ADDV $-1021247488, R4 // 1e42861584f81000
ADDV $0xffffffffc3210000, R5, R4 // ADDV $-1021247488, R5, R4 // 1e428615a4f81000
AND $0x43210000, R4 // AND $1126236160, R4 // 1e42861484f81400
AND $0x43210000, R5, R4 // AND $1126236160, R5, R4 // 1e428614a4f81400
AND $0xffffffffc3210000, R4 // AND $-1021247488, R4 // 1e42861584f81400
AND $0xffffffffc3210000, R5, R4 // AND $-1021247488, R5, R4 // 1e428615a4f81400
// AND C_ADDCON, [r1], r2
AND $0xfffffffffffffc21, R4 // AND $-991, R4 // 1e84b00284f81400
AND $0xfffffffffffffc21, R5, R4 // AND $-991, R5, R4 // 1e84b002a4f81400

View File

@@ -11,16 +11,12 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
MOVV $4096(R4), R5 // 3e000014de03800385f81000
ADD $74565, R4 // 5e020014de178d0384781000
ADD $4097, R4 // 3e000014de07800384781000
ADDW $74565, R4 // 5e020014de178d0384781000
ADDW $4097, R4 // 3e000014de07800384781000
ADDV $74565, R4 // 5e020014de178d0384f81000
ADDV $4097, R4 // 3e000014de07800384f81000
AND $74565, R4 // 5e020014de178d0384f81400
AND $4097, R4 // 3e000014de07800384f81400
ADD $74565, R4, R5 // 5e020014de178d0385781000
ADD $4097, R4, R5 // 3e000014de07800385781000
ADDW $74565, R4, R5 // 5e020014de178d0385781000
ADDW $4097, R4, R5 // 3e000014de07800385781000
ADDV $74565, R4, R5 // 5e020014de178d0385f81000
ADDV $4097, R4, R5 // 3e000014de07800385f81000
AND $74565, R4, R5 // 5e020014de178d0385f81400
@@ -46,10 +42,8 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
MOVB R4, 4096(R5) // 3e000014de971000c4030029
MOVBU R4, 65536(R5) // 1e020014de971000c4030029
MOVBU R4, 4096(R5) // 3e000014de971000c4030029
SC R4, 65536(R5) // 1e040010de971000c4030021
SCV R4, 65536(R5) // 1e040010de971000c4030023
LL 65536(R5), R4 // 1e040010de971000c4030020
LLV 65536(R5), R4 // 1e040010de971000c4030022
SC R4, 65536(R5) // 1e020014de971000c4030021
SC R4, 4096(R5) // 3e000014de971000c4030021
MOVW y+65540(FP), R4 // 1e020014de8f1000c4338028
MOVWU y+65540(FP), R4 // 1e020014de8f1000c433802a
MOVV y+65540(FP), R4 // 1e020014de8f1000c433c028
@@ -111,6 +105,10 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
SGTU $74565, R4, R5 // 5e020014de178d0385f81200
SGTU $4097, R4 // 3e000014de07800384f81200
SGTU $4097, R4, R5 // 3e000014de07800385f81200
ADDU $74565, R4 // 5e020014de178d0384781000
ADDU $74565, R4, R5 // 5e020014de178d0385781000
ADDU $4097, R4 // 3e000014de07800384781000
ADDU $4097, R4, R5 // 3e000014de07800385781000
ADDVU $4097, R4 // 3e000014de07800384f81000
ADDVU $4097, R4, R5 // 3e000014de07800385f81000
ADDVU $74565, R4 // 5e020014de178d0384f81000
@@ -123,83 +121,3 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
XOR $74565, R4, R5 // 5e020014de178d0385f81500
XOR $4097, R4 // 3e000014de07800384f81500
XOR $4097, R4, R5 // 3e000014de07800385f81500
MOVWP R5, -32768(R4) // 1efcff13de931000c5038025
MOVWP R5, 32768(R4) // 1e000010de931000c5038025
MOVWP R5, 65536(R4) // 1e040010de931000c5030025
MOVWP R5, 1048576(R4) // 1e400010de931000c5030025
MOVVP R5, -32768(R4) // 1efcff13de931000c5038027
MOVVP R5, 65536(R4) // 1e040010de931000c5030027
MOVVP R5, 1048576(R4) // 1e400010de931000c5030027
MOVWP -32768(R5), R4 // 1efcff13de971000c4038024
MOVWP 2229248(R5), R4 // 1e880010de971000c4030424
MOVWP -2145518592(R5), R4 // 1e740012de971000c403fc24
MOVVP -32768(R5), R4 // 1efcff13de971000c4038026
MOVVP 2229248(R5), R4 // 1e880010de971000c4030426
MOVVP -2145518592(R5), R4 // 1e740012de971000c403fc26
// MOVV C_DCON32_12S, r
MOVV $0x27312345fffff800, R4 // MOVV $2824077224892692480, R4 // 0400a002a468241684cc0903
MOVV $0xf7312345fffff800, R4 // MOVV $-634687288927848448, R4 // 0400a002a468241684cc3d03
// MOVV C_DCON32_0, r
MOVV $0x2731234500000000, R4 // MOVV $2824077220597727232, R4 // 04008002a468241684cc0903
MOVV $0xf731234500000000, R4 // MOVV $-634687293222813696, R4 // 04008002a468241684cc3d03
// MOVV C_DCON32_20, r
MOVV $0x2731234512345000, R4 // MOVV $2824077220903145472, R4 // a4682414a468241684cc0903
MOVV $0xf731234512345000, R4 // MOVV $-634687292917395456, R4 // a4682414a468241684cc3d03
// MOVV C_DCON12_32S, r
MOVV $0x273fffff80000800, R4 // MOVV $2828260563841189888, R4 // 040000158400a00384cc0903
MOVV $0xf73fffff80000800, R4 // MOVV $-630503949979351040, R4 // 040000158400a00384cc3d03
// MOVV C_DCON20S_32, r
MOVV $0xfff8000080000800, R4 // MOVV $-2251797666199552, R4 // 040000158400a00304000017
// MOVV C_DCON32_12U, r
MOVV $0x2731234500000800, R4 // MOVV $2824077220597729280, R4 // 0400a003a468241684cc0903
MOVV $0xf731234500000800, R4 // MOVV $-634687293222811648, R4 // 0400a003a468241684cc3d03
// ADDV/AND C_DCON12_20S, [r1], r2
ADDV $0x273fffff80000000, R4 // ADDV $2828260563841187840, R4 // 1e000015decf090384f81000
ADDV $0x273fffff80000000, R4, R5 // ADDV $2828260563841187840, R4, R5 // 1e000015decf090385f81000
AND $0x273fffff80000000, R4 // AND $2828260563841187840, R4 // 1e000015decf090384f81400
AND $0x273fffff80000000, R4, R5 // AND $2828260563841187840, R4, R5 // 1e000015decf090385f81400
// ADDV/AND C_DCON20S_20, [r1], r2
ADDV $0xfff800000f000000, R4 // ADDV $-2251799562027008, R4 // 1e001e141e00001784f81000
ADDV $0xfff800000f000000, R4, R5 // ADDV $-2251799562027008, R4, R5 // 1e001e141e00001785f81000
AND $0xfff800000f000000, R4 // AND $-2251799562027008, R4 // 1e001e141e00001784f81400
AND $0xfff800000f000000, R4, R5 // AND $-2251799562027008, R4, R5 // 1e001e141e00001785f81400
// ADDV/AND C_DCON12_12S, [r1], r2
ADDV $0x273ffffffffff800, R4 // ADDV $2828260565988669440, R4 // 1e00e002decf090384f81000
ADDV $0x273ffffffffff800, R4, R5 // ADDV $2828260565988669440, R4, R5 // 1e00e002decf090385f81000
AND $0x273ffffffffff800, R4 // AND $2828260565988669440, R4 // 1e00e002decf090384f81400
AND $0x273ffffffffff800, R4, R5 // AND $2828260565988669440, R4, R5 // 1e00e002decf090385f81400
// ADDV/AND C_DCON20S_12S, [r1], r2
ADDV $0xfff80000fffff800, R4 // ADDV $-2251795518720000, R4 // 1e00a0021e00001784f81000
ADDV $0xfff80000fffff800, R4, R5 // ADDV $-2251795518720000, R4, R5 // 1e00a0021e00001785f81000
AND $0xfff80000fffff800, R4 // AND $-2251795518720000, R4 // 1e00a0021e00001784f81400
AND $0xfff80000fffff800, R4, R5 // AND $-2251795518720000, R4, R5 // 1e00a0021e00001785f81400
// ADDV/AND C_DCON20S_0, [r1], r2
ADDV $0xfff8000000000000, R4 // ADDV $-2251799813685248, R4 // 1e0080021e00001784f81000
ADDV $0xfff8000000000000, R4, R5 // ADDV $-2251799813685248, R4, R5 // 1e0080021e00001785f81000
AND $0xfff8000000000000, R4 // AND $-2251799813685248, R4 // 1e0080021e00001784f81400
AND $0xfff8000000000000, R4, R5 // AND $-2251799813685248, R4, R5 // 1e0080021e00001785f81400
// ADDV/AND C_DCON12_12U, [r1], r2
ADDV $0x2730000000000800, R4 // ADDV $2823756966361303040, R4 // 1e00a003decf090384f81000
ADDV $0x2730000000000800, R4, R5 // ADDV $2823756966361303040, R4, R5 // 1e00a003decf090385f81000
AND $0x2730000000000800, R4 // AND $2823756966361303040, R4 // 1e00a003decf090384f81400
AND $0x2730000000000800, R4, R5 // AND $2823756966361303040, R4, R5 // 1e00a003decf090385f81400
// ADDV/AND C_DCON20S_12U, [r1], r2
ADDV $0xfff8000000000800, R4 // ADDV $-2251799813683200, R4 // 1e00a0031e00001784f81000
ADDV $0xfff8000000000800, R4, R5 // ADDV $-2251799813683200, R4, R5 // 1e00a0031e00001785f81000
AND $0xfff8000000000800, R4 // AND $-2251799813683200, R4 // 1e00a0031e00001784f81400
AND $0xfff8000000000800, R4, R5 // AND $-2251799813683200, R4, R5 // 1e00a0031e00001785f81400

View File

@@ -1,42 +0,0 @@
// Copyright 2024 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.
#include "../../../../../runtime/textflag.h"
TEXT asmtest(SB),DUPOK|NOSPLIT,$0
// ADDV/AND C_DCON32_12S, [r1], r2
ADDV $0x27312345fffff800, R4 // ADDV $2824077224892692480, R4 // 1e00a002be682416decf090384f81000
ADDV $0x27312345fffff800, R4, R5 // ADDV $2824077224892692480, R4, R5 // 1e00a002be682416decf090385f81000
AND $0x27312345fffff800, R4 // AND $2824077224892692480, R4 // 1e00a002be682416decf090384f81400
AND $0x27312345fffff800, R4, R5 // AND $2824077224892692480, R4, R5 // 1e00a002be682416decf090385f81400
// ADDV/AND C_DCON32_0, [r1], r2
ADDV $0x2731234500000000, R4 // ADDV $2824077220597727232, R4 // 1e008002be682416decf090384f81000
ADDV $0x2731234500000000, R4, R5 // ADDV $2824077220597727232, R4, R5 // 1e008002be682416decf090385f81000
AND $0x2731234500000000, R4 // AND $2824077220597727232, R4 // 1e008002be682416decf090384f81400
AND $0x2731234500000000, R4, R5 // AND $2824077220597727232, R4, R5 // 1e008002be682416decf090385f81400
// ADDV/AND C_DCON32_20, [r1], r2
ADDV $0x2731234512345000, R4 // ADDV $2824077220903145472, R4 // be682414be682416decf090384f81000
ADDV $0x2731234512345000, R4, R5 // ADDV $2824077220903145472, R4, R5 // be682414be682416decf090385f81000
AND $0x2731234512345000, R4 // AND $2824077220903145472, R4 // be682414be682416decf090384f81400
AND $0x2731234512345000, R4, R5 // AND $2824077220903145472, R4, R5 // be682414be682416decf090385f81400
// ADDV/AND C_DCON12_32S, [r1], r2
ADDV $0x273fffff80000800, R4 // ADDV $2828260563841189888, R4 // 1e000015de03a003decf090384f81000
ADDV $0x273fffff80000800, R4, R5 // ADDV $2828260563841189888, R4, R5 // 1e000015de03a003decf090385f81000
AND $0x273fffff80000800, R4 // AND $2828260563841189888, R4 // 1e000015de03a003decf090384f81400
AND $0x273fffff80000800, R4, R5 // AND $2828260563841189888, R4, R5 // 1e000015de03a003decf090385f81400
// ADDV/AND C_DCON20S_32, [r1], r2
ADDV $0xfff8000080000800, R4 // ADDV $-2251797666199552, R4 // 1e000015de03a0031e00001784f81000
ADDV $0xfff8000080000800, R4, R5 // ADDV $-2251797666199552, R4, R5 // 1e000015de03a0031e00001785f81000
AND $0xfff8000080000800, R4 // AND $-2251797666199552, R4 // 1e000015de03a0031e00001784f81400
AND $0xfff8000080000800, R4, R5 // AND $-2251797666199552, R4, R5 // 1e000015de03a0031e00001785f81400
// ADDV/AND C_DCON32_12U, [r1], r2
ADDV $0x2731234500000800, R4 // ADDV $2824077220597729280, R4 // 1e00a003be682416decf090384f81000
ADDV $0x2731234500000800, R4, R5 // ADDV $2824077220597729280, R4, R5 // 1e00a003be682416decf090385f81000
AND $0x2731234500000800, R4 // AND $2824077220597729280, R4 // 1e00a003be682416decf090384f81400
AND $0x2731234500000800, R4, R5 // AND $2824077220597729280, R4, R5 // 1e00a003be682416decf090385f81400

View File

@@ -1,22 +0,0 @@
// Copyright 2024 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.
#include "../../../../../runtime/textflag.h"
TEXT asmtest(SB),DUPOK|NOSPLIT,$0
// ADDV/AND C_DCON, [r1], r2
ADDV $0xfedcba9876543210, R4 // ADDV $-81985529216486896, R4 // 7ea8ec14de4388031e539717deb73f0384f81000
ADDV $0xfedcba9876543210, R5, R4 // ADDV $-81985529216486896, R5, R4 // 7ea8ec14de4388031e539717deb73f03a4f81000
ADDV $0x4edcba9876543210, R4 // ADDV $5682621993817747984, R4 // 7ea8ec14de4388031e539717deb7130384f81000
ADDV $0x4edcba9876543210, R5, R4 // ADDV $5682621993817747984, R5, R4 // 7ea8ec14de4388031e539717deb71303a4f81000
AND $0x4edcba9876543210, R4 // AND $5682621993817747984, R4 // 7ea8ec14de4388031e539717deb7130384f81400
AND $0x4edcba9876543210, R5, R4 // AND $5682621993817747984, R5, R4 // 7ea8ec14de4388031e539717deb71303a4f81400
AND $0xfedcba9876543210, R4 // AND $-81985529216486896, R4 // 7ea8ec14de4388031e539717deb73f0384f81400
AND $0xfedcba9876543210, R5, R4 // AND $-81985529216486896, R5, R4 // 7ea8ec14de4388031e539717deb73f03a4f81400
PRELDX 0(R7), $0x80001021, $0 // PRELDX (R7), $2147487777, $0 // 1e020014de0380031e000016de130003e0782c38
PRELDX -1(R7), $0x1021, $2 // PRELDX -1(R7), $4129, $2 // fe030014deffbf031e000016de030003e2782c38
PRELDX 8(R7), $0x80100800, $31 // PRELDX 8(R7), $2148534272, $31 // 1ee00714de238003fe1f0016de130003ff782c38
PRELDX 16(R7), $0x202040, $1 // PRELDX 16(R7), $2105408, $1 // 1e200014de4380033e000216de030003e1782c38

View File

@@ -1,12 +0,0 @@
// Copyright 2025 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.
#include "../../../../../runtime/textflag.h"
TEXT asmtest(SB),DUPOK|NOSPLIT,$0
// MOVWP LOREG_64(Rx), Ry
MOVWP 81985529216486896(R4), R5 // 9e571315dec3b703feac6816de4b000384f8100085000025
MOVWP -81985529216486896(R4), R5 // 7ea8ec14de4388031e539717deb73f0384f8100085000025
MOVWP R4, 81985529216486896(R5) // 9e571315dec3b703feac6816de4b0003a5f81000a4000025
MOVWP R4, -81985529216486896(R5) // 7ea8ec14de4388031e539717deb73f03a5f81000a4000025

View File

@@ -1,14 +0,0 @@
// Copyright 2025 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.
TEXT errors(SB),$0
VSHUF4IV $16, V1, V2 // ERROR "operand out of range 0 to 15"
XVSHUF4IV $16, X1, X2 // ERROR "operand out of range 0 to 15"
ADDV16 $1, R4, R5 // ERROR "the constant must be a multiple of 65536."
ADDV16 $65535, R4, R5 // ERROR "the constant must be a multiple of 65536."
SC R4, 1(R5) // ERROR "offset must be a multiple of 4."
SCV R4, 1(R5) // ERROR "offset must be a multiple of 4."
LL 1(R5), R4 // ERROR "offset must be a multiple of 4."
LLV 1(R5), R4 // ERROR "offset must be a multiple of 4."

File diff suppressed because it is too large Load Diff

View File

@@ -3,27 +3,6 @@
// license that can be found in the LICENSE file.
TEXT errors(SB),$0
CSRRC (X10), CYCLE, X5 // ERROR "integer register or immediate expected for 1st operand"
CSRRC X0, TU, X5 // ERROR "unknown CSR"
CSRRC X0, CYCLE // ERROR "missing CSR name"
CSRRC X0, CYCLE, (X10) // ERROR "needs an integer register output"
CSRRC $-1, TIME, X15 // ERROR "immediate out of range 0 to 31"
CSRRCI $32, TIME, X15 // ERROR "immediate out of range 0 to 31"
CSRRCI $1, TIME, (X15) // ERROR "needs an integer register output"
CSRRS (X10), CYCLE, X5 // ERROR "integer register or immediate expected for 1st operand"
CSRRS X0, CYCLE, (X10) // ERROR "needs an integer register output"
CSRRS X0, TU, X5 // ERROR "unknown CSR"
CSRRS X0, CYCLE // ERROR "missing CSR name"
CSRRS $-1, TIME, X15 // ERROR "immediate out of range 0 to 31"
CSRRSI $32, TIME, X15 // ERROR "immediate out of range 0 to 31"
CSRRSI $1, TIME, (X15) // ERROR "needs an integer register output"
CSRRW (X10), CYCLE, X5 // ERROR "integer register or immediate expected for 1st operand"
CSRRW X0, TU, X5 // ERROR "unknown CSR"
CSRRW X0, CYCLE // ERROR "missing CSR name"
CSRRW X0, CYCLE, (X5) // ERROR "needs an integer register output"
CSRRW $-1, TIME, X15 // ERROR "immediate out of range 0 to 31"
CSRRWI $32, TIME, X15 // ERROR "immediate out of range 0 to 31"
CSRRWI $1, TIME, (X15) // ERROR "needs an integer register output"
MOV $errors(SB), (X5) // ERROR "address load must target register"
MOV $8(SP), (X5) // ERROR "address load must target register"
MOVB $8(SP), X5 // ERROR "unsupported address load"
@@ -51,8 +30,6 @@ TEXT errors(SB),$0
SLLI $64, X5, X6 // ERROR "immediate out of range 0 to 63"
SRLI $64, X5, X6 // ERROR "immediate out of range 0 to 63"
SRAI $64, X5, X6 // ERROR "immediate out of range 0 to 63"
BEQ X5, X6, $1 // ERROR "instruction with branch-like opcode lacks destination"
BEQ X5, X6, 31(X10) // ERROR "instruction with branch-like opcode lacks destination"
RORI $-1, X5, X6 // ERROR "immediate out of range 0 to 63"
SLLI $-1, X5, X6 // ERROR "immediate out of range 0 to 63"
SRLI $-1, X5, X6 // ERROR "immediate out of range 0 to 63"
@@ -66,355 +43,7 @@ TEXT errors(SB),$0
SRLIW $-1, X5, X6 // ERROR "immediate out of range 0 to 31"
SRAIW $-1, X5, X6 // ERROR "immediate out of range 0 to 31"
SD X5, 4294967296(X6) // ERROR "constant 4294967296 too large"
SRLI $1, X5, F1 // ERROR "expected integer register in rd position but got non-integer register F1"
SRLI $1, F1, X5 // ERROR "expected integer register in rs1 position but got non-integer register F1"
FNES F1, (X5) // ERROR "needs an integer register output"
//
// "V" Standard Extension for Vector Operations, Version 1.0
//
VSETIVLI X10, E32, M2, TA, MA, X12 // ERROR "expected immediate value"
VLE8V (X10), V1, V3 // ERROR "invalid vector mask register"
VLE8FFV (X10), V1, V3 // ERROR "invalid vector mask register"
VSE8V V3, V1, (X10) // ERROR "invalid vector mask register"
VLSE8V (X10), X10, V1, V3 // ERROR "invalid vector mask register"
VSSE8V V3, X11, V1, (X10) // ERROR "invalid vector mask register"
VLUXEI8V (X10), V2, V1, V3 // ERROR "invalid vector mask register"
VSUXEI8V V3, V2, V1, (X10) // ERROR "invalid vector mask register"
VLOXEI8V (X10), V2, V1, V3 // ERROR "invalid vector mask register"
VSOXEI8V V3, V2, V1, (X10) // ERROR "invalid vector mask register"
VLSEG2E8V (X10), V1, V3 // ERROR "invalid vector mask register"
VLSEG2E8FFV (X10), V1, V3 // ERROR "invalid vector mask register"
VSSEG2E8V V3, V1, (X10) // ERROR "invalid vector mask register"
VLSSEG2E8V (X10), X10, V1, V3 // ERROR "invalid vector mask register"
VSSSEG2E8V V3, X11, V1, (X10) // ERROR "invalid vector mask register"
VLUXSEG2EI8V (X10), V2, V1, V3 // ERROR "invalid vector mask register"
VSUXSEG2EI8V V3, V2, V1, (X10) // ERROR "invalid vector mask register"
VLOXSEG2EI8V (X10), V2, V1, V3 // ERROR "invalid vector mask register"
VSOXSEG2EI8V V3, V2, V1, (X10) // ERROR "invalid vector mask register"
VL1RV (X10), V0, V3 // ERROR "too many operands for instruction"
VS1RV V3, V0, (X11) // ERROR "too many operands for instruction"
VADDVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VADDVX X10, V2, V1, V3 // ERROR "invalid vector mask register"
VADDVI $15, V4, V1, V2 // ERROR "invalid vector mask register"
VSUBVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSUBVX X10, V2, V1, V3 // ERROR "invalid vector mask register"
VRSUBVX X10, V2, V1, V3 // ERROR "invalid vector mask register"
VRSUBVI $15, V4, V1, V2 // ERROR "invalid vector mask register"
VNEGV V2, V3, V4 // ERROR "invalid vector mask register"
VWADDUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWADDUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWSUBUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWSUBUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWADDVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWADDVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWSUBVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWSUBVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWADDUWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWADDUWX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWSUBUWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWSUBUWX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWADDWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWADDWX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWSUBWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWSUBWX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWCVTXXV V2, V1, V3 // ERROR "invalid vector mask register"
VWCVTUXXV V2, V1, V3 // ERROR "invalid vector mask register"
VZEXTVF2 V2, V3, V4 // ERROR "invalid vector mask register"
VSEXTVF2 V2, V3, V4 // ERROR "invalid vector mask register"
VZEXTVF4 V2, V3, V4 // ERROR "invalid vector mask register"
VSEXTVF4 V2, V3, V4 // ERROR "invalid vector mask register"
VZEXTVF8 V2, V3, V4 // ERROR "invalid vector mask register"
VSEXTVF8 V2, V3, V4 // ERROR "invalid vector mask register"
VADCVVM V1, V2, V4, V3 // ERROR "invalid vector mask register"
VADCVVM V1, V2, V3 // ERROR "invalid vector mask register"
VADCVVM V1, V2, V0, V0 // ERROR "invalid destination register V0"
VADCVXM X10, V2, V4, V3 // ERROR "invalid vector mask register"
VADCVXM X10, V2, V3 // ERROR "invalid vector mask register"
VADCVXM X10, V2, V0, V0 // ERROR "invalid destination register V0"
VADCVIM $15, V2, V1, V3 // ERROR "invalid vector mask register"
VADCVIM $15, V2, V3 // ERROR "invalid vector mask register"
VADCVIM $15, V2, V0, V0 // ERROR "invalid destination register V0"
VMADCVVM V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMADCVVM V1, V2, V3 // ERROR "invalid vector mask register"
VMADCVXM X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMADCVXM X10, V2, V3 // ERROR "invalid vector mask register"
VMADCVIM $15, V2, V1, V3 // ERROR "invalid vector mask register"
VMADCVIM $15, V2, V3 // ERROR "invalid vector mask register"
VSBCVVM V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSBCVVM V1, V2, V3 // ERROR "invalid vector mask register"
VSBCVVM V1, V2, V0, V0 // ERROR "invalid destination register V0"
VSBCVXM X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSBCVXM X10, V2, V3 // ERROR "invalid vector mask register"
VSBCVXM X10, V2, V0, V0 // ERROR "invalid destination register V0"
VMSBCVVM V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSBCVVM V1, V2, V3 // ERROR "invalid vector mask register"
VMSBCVXM X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMSBCVXM X10, V2, V3 // ERROR "invalid vector mask register"
VANDVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VANDVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VANDVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VORVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VORVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VORVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VXORVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VXORVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VXORVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VNOTV V1, V2, V3 // ERROR "invalid vector mask register"
VSLLVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSLLVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSLLVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VSRLVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSRLVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSRLVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VSRAVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSRAVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSRAVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VNSRLWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VNSRLWX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VNSRLWI $31, V2, V4, V3 // ERROR "invalid vector mask register"
VNSRAWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VNSRAWX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VNSRAWI $31, V2, V4, V3 // ERROR "invalid vector mask register"
VNCVTXXW V2, V4, V3 // ERROR "invalid vector mask register"
VMSEQVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSEQVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMSEQVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMSNEVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSNEVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMSNEVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLTUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLTUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLTVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLTVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLEUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLEUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLEUVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLEVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLEVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLEVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGTUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGTUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGTUVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGTVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGTVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGTVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGEVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGEUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLTVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLTUVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGEVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGEUVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMINUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMINUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMINVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMINVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMAXUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMAXUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMAXVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMAXVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMULVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMULVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMULHVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMULHVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMULHUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMULHUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMULHSUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMULHSUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VDIVUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VDIVUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VDIVVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VDIVVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VREMUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VREMUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VREMVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VREMVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWMULVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWMULVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWMULUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWMULUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWMULSUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWMULSUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMACCVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMACCVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VNMSACVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VNMSACVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMADDVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMADDVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VNMSUBVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VNMSUBVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWMACCUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWMACCUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWMACCVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWMACCVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWMACCSUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWMACCSUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWMACCUSVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMERGEVVM V1, V2, V3 // ERROR "invalid vector mask register"
VMERGEVVM V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMERGEVXM X10, V2, V3 // ERROR "invalid vector mask register"
VMERGEVXM X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMERGEVIM $15, V2, V3 // ERROR "invalid vector mask register"
VMERGEVIM $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMVVV V1, V2, V3 // ERROR "too many operands for instruction"
VMVVX X10, V2, V3 // ERROR "too many operands for instruction"
VMVVI $15, V2, V3 // ERROR "too many operands for instruction"
VSADDUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSADDUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSADDUVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VSADDVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSADDVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSADDVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VSSUBUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSSUBUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSSUBVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSSUBVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VAADDUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VAADDUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VAADDVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VAADDVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VASUBUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VASUBUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VASUBVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VASUBVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSMULVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSMULVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSSRLVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSSRLVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSSRLVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VSSRAVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSSRAVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSSRAVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VNCLIPUWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VNCLIPUWX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VNCLIPUWI $16, V2, V4, V3 // ERROR "invalid vector mask register"
VNCLIPWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VNCLIPWX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VNCLIPWI $16, V2, V4, V3 // ERROR "invalid vector mask register"
VFADDVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFADDVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFSUBVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFSUBVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFRSUBVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFWADDVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFWADDVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFWSUBVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFWSUBVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFWADDWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFWADDWF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFWSUBWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFWSUBWF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFMULVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFMULVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFDIVVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFDIVVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFRDIVVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFWMULVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFWMULVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFMACCVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFMACCVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFNMACCVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFNMACCVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFMSACVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFMSACVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFNMSACVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFNMSACVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFMADDVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFMADDVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFNMADDVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFNMADDVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFMSUBVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFMSUBVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFNMSUBVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFNMSUBVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFWMACCVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFWMACCVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFWNMACCVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFWNMACCVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFWMSACVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFWMSACVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFWNMSACVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFWNMSACVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFSQRTV V2, V4, V3 // ERROR "invalid vector mask register"
VFRSQRT7V V2, V4, V3 // ERROR "invalid vector mask register"
VFREC7V V2, V4, V3 // ERROR "invalid vector mask register"
VFMINVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFMINVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFMAXVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFMAXVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFSGNJVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFSGNJVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFSGNJNVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFSGNJNVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFSGNJXVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFSGNJXVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFNEGV V2, V4, V3 // ERROR "invalid vector mask register"
VFABSV V2, V4, V3 // ERROR "invalid vector mask register"
VMFEQVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMFEQVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VMFNEVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMFNEVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VMFLTVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMFLTVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VMFLEVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMFLEVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VMFGTVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VMFGEVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VMFGTVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMFGEVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFMERGEVFM X10, V2, V3 // ERROR "invalid vector mask register"
VFMERGEVFM F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFCVTXUFV V2, V4, V3 // ERROR "invalid vector mask register"
VFCVTXFV V2, V4, V3 // ERROR "invalid vector mask register"
VFCVTRTZXUFV V2, V4, V3 // ERROR "invalid vector mask register"
VFCVTRTZXFV V2, V4, V3 // ERROR "invalid vector mask register"
VFCVTFXUV V2, V4, V3 // ERROR "invalid vector mask register"
VFCVTFXV V2, V4, V3 // ERROR "invalid vector mask register"
VFWCVTXUFV V2, V4, V3 // ERROR "invalid vector mask register"
VFWCVTXFV V2, V4, V3 // ERROR "invalid vector mask register"
VFWCVTRTZXUFV V2, V4, V3 // ERROR "invalid vector mask register"
VFWCVTRTZXFV V2, V4, V3 // ERROR "invalid vector mask register"
VFWCVTFXUV V2, V4, V3 // ERROR "invalid vector mask register"
VFWCVTFXV V2, V4, V3 // ERROR "invalid vector mask register"
VFWCVTFFV V2, V4, V3 // ERROR "invalid vector mask register"
VFNCVTXUFW V2, V4, V3 // ERROR "invalid vector mask register"
VFNCVTXFW V2, V4, V3 // ERROR "invalid vector mask register"
VFNCVTRTZXUFW V2, V4, V3 // ERROR "invalid vector mask register"
VFNCVTRTZXFW V2, V4, V3 // ERROR "invalid vector mask register"
VFNCVTFXUW V2, V4, V3 // ERROR "invalid vector mask register"
VFNCVTFXW V2, V4, V3 // ERROR "invalid vector mask register"
VFNCVTFFW V2, V4, V3 // ERROR "invalid vector mask register"
VFNCVTRODFFW V2, V4, V3 // ERROR "invalid vector mask register"
VREDSUMVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VREDMAXUVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VREDMAXVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VREDMINUVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VREDMINVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VREDANDVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VREDORVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VREDXORVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWREDSUMUVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWREDSUMVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFREDOSUMVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFREDUSUMVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFREDMAXVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFREDMINVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFWREDOSUMVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VCPOPM V2, V4, X10 // ERROR "invalid vector mask register"
VFIRSTM V2, V4, X10 // ERROR "invalid vector mask register"
VMSBFM V2, V4, V3 // ERROR "invalid vector mask register"
VMSIFM V2, V4, V3 // ERROR "invalid vector mask register"
VMSOFM V2, V4, V3 // ERROR "invalid vector mask register"
VIOTAM V2, V4, V3 // ERROR "invalid vector mask register"
VSLIDEUPVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSLIDEUPVI $16, V2, V4, V3 // ERROR "invalid vector mask register"
VSLIDEDOWNVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSLIDEDOWNVI $16, V2, V4, V3 // ERROR "invalid vector mask register"
VSLIDE1UPVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VFSLIDE1UPVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VSLIDE1DOWNVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VFSLIDE1DOWNVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VRGATHERVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VRGATHEREI16VV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VRGATHERVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VRGATHERVI $16, V2, V4, V3 // ERROR "invalid vector mask register"
RET

View File

@@ -1,601 +0,0 @@
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file is for validation errors only, i.e., errors reported by the validate function.
// Negative test cases for errors generated earlier in the assembler's preprocess stage
// should be added to riscv64error.s. If they are added to this file, they will prevent
// the validate function from being run and TestRISCVValidation will report missing
// errors.
TEXT validation(SB),$0
SRLI $1, X5, F1 // ERROR "expected integer register in rd position but got non-integer register F1"
SRLI $1, F1, X5 // ERROR "expected integer register in rs1 position but got non-integer register F1"
WORD $-1 // ERROR "must be in range [0x0, 0xffffffff]"
WORD $0x100000000 // ERROR "must be in range [0x0, 0xffffffff]"
//
// "C" Extension for Compressed Instructions, Version 2.0
//
CLWSP 20(X5), X10 // ERROR "rs2 must be SP/X2"
CLWSP 20(SP), X0 // ERROR "cannot use register X0"
CLWSP 20(SP), F10 // ERROR "expected integer register in rd position"
CLWSP 22(SP), X10 // ERROR "must be a multiple of 4"
CLDSP 24(X5), X10 // ERROR "rs2 must be SP/X2"
CLDSP 24(SP), X0 // ERROR "cannot use register X0"
CLDSP 24(SP), F10 // ERROR "expected integer register in rd position"
CLDSP 28(SP), X10 // ERROR "must be a multiple of 8"
CFLDSP 32(X5), F10 // ERROR "rs2 must be SP/X2"
CFLDSP 32(SP), X10 // ERROR "expected float register in rd position"
CFLDSP 36(SP), F10 // ERROR "must be a multiple of 8"
CSWSP X10, 20(X5) // ERROR "rd must be SP/X2"
CSWSP F10, 20(SP) // ERROR "expected integer register in rs2 position"
CSWSP X10, 22(SP) // ERROR "must be a multiple of 4"
CSDSP X10, 24(X5) // ERROR "rd must be SP/X2"
CSDSP F10, 24(SP) // ERROR "expected integer register in rs2 position"
CSDSP X10, 28(SP) // ERROR "must be a multiple of 8"
CFSDSP F10, 32(X5) // ERROR "rd must be SP/X2"
CFSDSP X10, 32(SP) // ERROR "expected float register in rs2 position"
CFSDSP F10, 36(SP) // ERROR "must be a multiple of 8"
CLW 20(X10), F11 // ERROR "expected integer prime register in rd position"
CLW 20(X5), X11 // ERROR "expected integer prime register in rs1 position"
CLW 20(X10), X5 // ERROR "expected integer prime register in rd position"
CLW -1(X10), X11 // ERROR "must be in range [0, 127]"
CLW 22(X10), X11 // ERROR "must be a multiple of 4"
CLW 128(X10), X11 // ERROR "must be in range [0, 127]"
CLD 24(X10), F11 // ERROR "expected integer prime register in rd position"
CLD 24(X5), X11 // ERROR "expected integer prime register in rs1 position"
CLD -1(X10), X11 // ERROR "must be in range [0, 255]"
CLD 30(X10), X11 // ERROR "must be a multiple of 8"
CLD 256(X10), X11 // ERROR "must be in range [0, 255]"
CFLD 32(X10), X11 // ERROR "expected float prime register in rd position"
CFLD 32(X5), F11 // ERROR "expected integer prime register in rs1 position"
CFLD -1(X10), F11 // ERROR "must be in range [0, 255]"
CFLD 34(X10), F11 // ERROR "must be a multiple of 8"
CFLD 256(X10), F11 // ERROR "must be in range [0, 255]"
CSW F11, 20(X10) // ERROR "expected integer prime register in rs2 position"
CSW X11, -1(X10) // ERROR "must be in range [0, 127]"
CSW X11, 22(X10) // ERROR "must be a multiple of 4"
CSW X11, 128(X10) // ERROR "must be in range [0, 127]"
CSD F11, 24(X10) // ERROR "expected integer prime register in rs2 position"
CSD X11, -1(X10) // ERROR "must be in range [0, 255]"
CSD X11, 28(X10) // ERROR "must be a multiple of 8"
CSD X11, 256(X10) // ERROR "must be in range [0, 255]"
CFSD X11, 32(X10) // ERROR "expected float prime register in rs2 position"
CFSD F11, -1(X10) // ERROR "must be in range [0, 255]"
CFSD F11, 36(X10) // ERROR "must be a multiple of 8"
CFSD F11, 256(X10) // ERROR "must be in range [0, 255]"
CJR X0 // ERROR "cannot use register X0 in rs1"
CJR X10, X11 // ERROR "expected no register in rs2"
CJALR X0 // ERROR "cannot use register X0 in rs1"
CJALR X10, X11 // ERROR "expected no register in rd"
CBEQZ X5, 1(PC) // ERROR "expected integer prime register in rs1"
CBNEZ X5, 1(PC) // ERROR "expected integer prime register in rs1"
CLI $3, X0 // ERROR "cannot use register X0 in rd"
CLI $-33, X5 // ERROR "must be in range [-32, 31]"
CLI $32, X5 // ERROR "must be in range [-32, 31]"
CLUI $0, X5 // ERROR "immediate cannot be zero"
CLUI $3, X0 // ERROR "cannot use register X0 in rd"
CLUI $3, X2 // ERROR "cannot use register SP/X2 in rd"
CLUI $-33, X5 // ERROR "must be in range [-32, 31]"
CLUI $32, X5 // ERROR "must be in range [-32, 31]"
CADD $31, X5, X6 // ERROR "rd must be the same as rs1"
CADD $-33, X5 // ERROR "must be in range [-32, 31]"
CADD $32, X5 // ERROR "must be in range [-32, 31]"
CADDI $0, X5 // ERROR "immediate cannot be zero"
CADDI $31, X5, X6 // ERROR "rd must be the same as rs1"
CADDI $-33, X5 // ERROR "must be in range [-32, 31]"
CADDI $32, X5 // ERROR "must be in range [-32, 31]"
CADDW $-33, X5 // ERROR "must be in range [-32, 31]"
CADDW $32, X5 // ERROR "must be in range [-32, 31]"
CADDIW $-33, X5 // ERROR "must be in range [-32, 31]"
CADDIW $32, X5 // ERROR "must be in range [-32, 31]"
CADDI16SP $0, SP // ERROR "immediate cannot be zero"
CADDI16SP $16, X5 // ERROR "rd must be SP/X2"
CADDI16SP $-513, SP // ERROR "must be in range [-512, 511]"
CADDI16SP $20, SP // ERROR "must be a multiple of 16"
CADDI16SP $512, SP // ERROR "must be in range [-512, 511]"
CADDI4SPN $4, SP, X5 // ERROR "expected integer prime register in rd"
CADDI4SPN $4, X5, X10 // ERROR "SP/X2 must be in rs1"
CADDI4SPN $-1, SP, X10 // ERROR "must be in range [0, 1023]"
CADDI4SPN $0, SP, X10 // ERROR "immediate cannot be zero"
CADDI4SPN $6, SP, X10 // ERROR "must be a multiple of 4"
CADDI4SPN $1024, SP, X10 // ERROR "must be in range [0, 1023]"
CSLLI $63, X5, X6 // ERROR "rd must be the same as rs1"
CSLLI $-1, X5 // ERROR "must be in range [0, 63]"
CSLLI $0, X5 // ERROR "immediate cannot be zero"
CSLLI $64, X5 // ERROR "must be in range [0, 63]"
CSRLI $63, X10, X11 // ERROR "rd must be the same as rs1"
CSRLI $63, X5 // ERROR "expected integer prime register in rd"
CSRLI $-1, X10 // ERROR "must be in range [0, 63]"
CSRLI $0, X10 // ERROR "immediate cannot be zero"
CSRLI $64, X10 // ERROR "must be in range [0, 63]"
CSRAI $63, X10, X11 // ERROR "rd must be the same as rs1"
CSRAI $63, X5 // ERROR "expected integer prime register in rd"
CSRAI $-1, X10 // ERROR "must be in range [0, 63]"
CSRAI $0, X10 // ERROR "immediate cannot be zero"
CSRAI $64, X10 // ERROR "must be in range [0, 63]"
CAND $1, X10, X11 // ERROR "rd must be the same as rs1"
CAND $1, X5 // ERROR "expected integer prime register in rd"
CAND $-64, X10 // ERROR "must be in range [-32, 31]"
CAND $63, X10 // ERROR "must be in range [-32, 31]"
CANDI $1, X10, X11 // ERROR "rd must be the same as rs1"
CANDI $1, X5 // ERROR "expected integer prime register in rd"
CANDI $-64, X10 // ERROR "must be in range [-32, 31]"
CANDI $63, X10 // ERROR "must be in range [-32, 31]"
CMV X0, X5 // ERROR "cannot use register X0 in rs2"
CMV X5, X6, X7 // ERROR "expected no register in rs1"
CMV X5, X0 // ERROR "cannot use register X0 in rd"
CMV F1, X5 // ERROR "expected integer register in rs2"
CMV X5, F1 // ERROR "expected integer register in rd"
CADD X5, X6, X7 // ERROR "rd must be the same as rs1"
CADD X0, X8 // ERROR "cannot use register X0 in rs2"
CADD X8, X0 // ERROR "cannot use register X0 in rd"
CAND X10, X11, X12 // ERROR "rd must be the same as rs1"
CAND X5, X11 // ERROR "expected integer prime register in rs2"
CAND X10, X5 // ERROR "expected integer prime register in rd"
COR X10, X11, X12 // ERROR "rd must be the same as rs1"
COR X5, X11 // ERROR "expected integer prime register in rs2"
COR X10, X5 // ERROR "expected integer prime register in rd"
CXOR X10, X11, X12 // ERROR "rd must be the same as rs1"
CXOR X5, X11 // ERROR "expected integer prime register in rs2"
CXOR X10, X5 // ERROR "expected integer prime register in rd"
CSUB X10, X11, X12 // ERROR "rd must be the same as rs1"
CSUB X5, X11 // ERROR "expected integer prime register in rs2"
CSUB X10, X5 // ERROR "expected integer prime register in rd"
CADDW X10, X11, X12 // ERROR "rd must be the same as rs1"
CADDW X5, X11 // ERROR "expected integer prime register in rs2"
CADDW X10, X5 // ERROR "expected integer prime register in rd"
CSUBW X10, X11, X12 // ERROR "rd must be the same as rs1"
CSUBW X5, X11 // ERROR "expected integer prime register in rs2"
CSUBW X10, X5 // ERROR "expected integer prime register in rd"
CNOP X10 // ERROR "expected no register in rs2"
CEBREAK X10 // ERROR "expected no register in rs2"
//
// "V" Standard Extension for Vector Operations, Version 1.0
//
VSETVLI $32, E16, M1, TU, MU, X12 // ERROR "must be in range [0, 31] (5 bits)"
VSETVLI $-1, E32, M2, TA, MA, X12 // ERROR "must be in range [0, 31] (5 bits)"
VSETVL X10, X11 // ERROR "expected integer register in rs1 position"
VLE8V (X10), X10 // ERROR "expected vector register in vd position"
VLE8V (V1), V3 // ERROR "expected integer register in rs1 position"
VLE8FFV (X10), X10 // ERROR "expected vector register in vd position"
VLE8FFV (V1), V3 // ERROR "expected integer register in rs1 position"
VSE8V X10, (X10) // ERROR "expected vector register in vs1 position"
VSE8V V3, (V1) // ERROR "expected integer register in rd position"
VLSE8V (X10), V3 // ERROR "expected integer register in rs2 position"
VLSE8V (X10), X10, X11 // ERROR "expected vector register in vd position"
VLSE8V (V1), X10, V3 // ERROR "expected integer register in rs1 position"
VLSE8V (X10), V1, V0, V3 // ERROR "expected integer register in rs2 position"
VSSE8V V3, (X10) // ERROR "expected integer register in rs2 position"
VSSE8V X10, X11, (X10) // ERROR "expected vector register in vd position"
VSSE8V V3, X11, (V1) // ERROR "expected integer register in rs1 position"
VSSE8V V3, V1, V0, (X10) // ERROR "expected integer register in rs2 position"
VLUXEI8V (X10), V2, X11 // ERROR "expected vector register in vd position"
VLUXEI8V (X10), V2, X11 // ERROR "expected vector register in vd position"
VLUXEI8V (V1), V2, V3 // ERROR "expected integer register in rs1 position"
VLUXEI8V (X10), X11, V0, V3 // ERROR "expected vector register in vs2 position"
VSUXEI8V X10, V2, (X10) // ERROR "expected vector register in vd position"
VSUXEI8V V3, V2, (V1) // ERROR "expected integer register in rs1 position"
VSUXEI8V V3, X11, V0, (X10) // ERROR "expected vector register in vs2 position"
VLOXEI8V (X10), V2, X11 // ERROR "expected vector register in vd position"
VLOXEI8V (V1), V2, V3 // ERROR "expected integer register in rs1 position"
VLOXEI8V (X10), X11, V0, V3 // ERROR "expected vector register in vs2 position"
VSOXEI8V X10, V2, (X10) // ERROR "expected vector register in vd position"
VSOXEI8V V3, V2, (V1) // ERROR "expected integer register in rs1 position"
VSOXEI8V V3, X11, V0, (X10) // ERROR "expected vector register in vs2 position"
VLSEG2E8V (X10), X10 // ERROR "expected vector register in vd position"
VLSEG2E8V (V1), V3 // ERROR "expected integer register in rs1 position"
VLSEG2E8FFV (X10), X10 // ERROR "expected vector register in vd position"
VLSEG2E8FFV (V1), V3 // ERROR "expected integer register in rs1 position"
VSSEG2E8V X10, (X10) // ERROR "expected vector register in vs1 position"
VSSEG2E8V V3, (V1) // ERROR "expected integer register in rd position"
VLSSEG2E8V (X10), V3 // ERROR "expected integer register in rs2 position"
VLSSEG2E8V (X10), X10, X11 // ERROR "expected vector register in vd position"
VLSSEG2E8V (V1), X10, V3 // ERROR "expected integer register in rs1 position"
VLSSEG2E8V (X10), V1, V0, V3 // ERROR "expected integer register in rs2 position"
VSSSEG2E8V V3, (X10) // ERROR "expected integer register in rs2 position"
VSSSEG2E8V X10, X11, (X10) // ERROR "expected vector register in vd position"
VSSSEG2E8V V3, X11, (V1) // ERROR "expected integer register in rs1 position"
VSSSEG2E8V V3, V1, V0, (X10) // ERROR "expected integer register in rs2 position"
VLUXSEG2EI8V (X10), V2, X11 // ERROR "expected vector register in vd position"
VLUXSEG2EI8V (X10), V2, X11 // ERROR "expected vector register in vd position"
VLUXSEG2EI8V (V1), V2, V3 // ERROR "expected integer register in rs1 position"
VLUXSEG2EI8V (X10), X11, V0, V3 // ERROR "expected vector register in vs2 position"
VSUXSEG2EI8V X10, V2, (X10) // ERROR "expected vector register in vd position"
VSUXSEG2EI8V V3, V2, (V1) // ERROR "expected integer register in rs1 position"
VSUXSEG2EI8V V3, X11, V0, (X10) // ERROR "expected vector register in vs2 position"
VLOXSEG2EI8V (X10), V2, X11 // ERROR "expected vector register in vd position"
VLOXSEG2EI8V (V1), V2, V3 // ERROR "expected integer register in rs1 position"
VLOXSEG2EI8V (X10), X11, V0, V3 // ERROR "expected vector register in vs2 position"
VSOXSEG2EI8V X10, V2, (X10) // ERROR "expected vector register in vd position"
VSOXSEG2EI8V V3, V2, (V1) // ERROR "expected integer register in rs1 position"
VSOXSEG2EI8V V3, X11, V0, (X10) // ERROR "expected vector register in vs2 position"
VL1RV (X10), X10 // ERROR "expected vector register in vd position"
VL1RV (V1), V3 // ERROR "expected integer register in rs1 position"
VS1RV X11, (X11) // ERROR "expected vector register in vs1 position"
VS1RV V3, (V1) // ERROR "expected integer register in rd position"
VADDVV V1, X10, V3 // ERROR "expected vector register in vs2 position"
VADDVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VADDVI $16, V4, V2 // ERROR "signed immediate 16 must be in range [-16, 15] (5 bits)"
VADDVI $-17, V4, V2 // ERROR "signed immediate -17 must be in range [-16, 15] (5 bits)"
VSUBVV V1, X10, V3 // ERROR "expected vector register in vs2 position"
VSUBVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VRSUBVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VRSUBVI $16, V4, V2 // ERROR "signed immediate 16 must be in range [-16, 15] (5 bits)"
VRSUBVI $-17, V4, V2 // ERROR "signed immediate -17 must be in range [-16, 15] (5 bits)"
VNEGV X10, V3 // ERROR "expected vector register in vs2 position"
VNEGV V2 // ERROR "expected vector register in vd position"
VWADDUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWADDUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWSUBUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWSUBUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWADDVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWADDVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWSUBVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWSUBVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWADDUWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWADDUWX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWSUBUWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWSUBUWX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWADDWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWADDWX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWSUBWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWSUBWX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWCVTXXV X10, V3 // ERROR "expected vector register in vs2 position"
VWCVTUXXV X10, V3 // ERROR "expected vector register in vs2 position"
VZEXTVF2 V2, V0, V3, V4 // ERROR "expected no register in rs3"
VZEXTVF2 X10, V3 // ERROR "expected vector register in vs2 position"
VSEXTVF2 V2, V0, V3, V4 // ERROR "expected no register in rs3"
VSEXTVF2 X10, V3 // ERROR "expected vector register in vs2 position"
VZEXTVF4 V2, V0, V3, V4 // ERROR "expected no register in rs3"
VZEXTVF4 X10, V3 // ERROR "expected vector register in vs2 position"
VSEXTVF4 V2, V0, V3, V4 // ERROR "expected no register in rs3"
VSEXTVF4 X10, V3 // ERROR "expected vector register in vs2 position"
VZEXTVF8 V2, V0, V3, V4 // ERROR "expected no register in rs3"
VZEXTVF8 X10, V3 // ERROR "expected vector register in vs2 position"
VSEXTVF8 V2, V0, V3, V4 // ERROR "expected no register in rs3"
VSEXTVF8 X10, V3 // ERROR "expected vector register in vs2 position"
VADCVVM X10, V2, V0, V3 // ERROR "expected vector register in vs1 position"
VADCVXM V1, V2, V0, V3 // ERROR "expected integer register in rs1 position"
VADCVIM $16, V2, V0, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VADCVIM $-17, V2, V0, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMADCVVM X10, V2, V0, V3 // ERROR "expected vector register in vs1 position"
VMADCVXM V1, V2, V0, V3 // ERROR "expected integer register in rs1 position"
VMADCVIM $16, V2, V0, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMADCVIM $-17, V2, V0, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMADCVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMADCVV V1, V2, V0, V3 // ERROR "expected no register in rs3"
VMADCVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMADCVX X10, V2, V0, V3 // ERROR "expected no register in rs3"
VMADCVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMADCVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMADCVI $15, V2, V0, V3 // ERROR "expected no register in rs3"
VSBCVVM X10, V2, V0, V3 // ERROR "expected vector register in vs1 position"
VSBCVXM V1, V2, V0, V3 // ERROR "expected integer register in rs1 position"
VMSBCVVM X10, V2, V0, V3 // ERROR "expected vector register in vs1 position"
VMSBCVXM V1, V2, V0, V3 // ERROR "expected integer register in rs1 position"
VMSBCVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMSBCVV V1, V2, V0, V3 // ERROR "expected no register in rs3"
VMSBCVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMSBCVX X10, V2, V0, V3 // ERROR "expected no register in rs3"
VANDVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VANDVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VANDVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VANDVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VORVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VORVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VORVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VORVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VXORVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VXORVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VXORVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VXORVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VNOTV V3 // ERROR "expected vector register in vd position"
VNOTV X10, V3 // ERROR "expected vector register in vs2 position"
VSLLVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VSLLVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSLLVI $32, V2, V3 // ERROR "unsigned immediate 32 must be in range [0, 31]"
VSLLVI $-1, V2, V3 // ERROR "unsigned immediate -1 must be in range [0, 31]"
VSRLVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VSRLVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSRLVI $32, V2, V3 // ERROR "unsigned immediate 32 must be in range [0, 31]"
VSRLVI $-1, V2, V3 // ERROR "unsigned immediate -1 must be in range [0, 31]"
VSRAVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VSRAVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSRAVI $32, V2, V3 // ERROR "unsigned immediate 32 must be in range [0, 31]"
VSRAVI $-1, V2, V3 // ERROR "unsigned immediate -1 must be in range [0, 31]"
VNSRLWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VNSRLWX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VNSRLWI $32, V2, V3 // ERROR "unsigned immediate 32 must be in range [0, 31]"
VNSRLWI $-1, V2, V3 // ERROR "unsigned immediate -1 must be in range [0, 31]"
VNSRAWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VNSRAWX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VNSRAWI $32, V2, V3 // ERROR "unsigned immediate 32 must be in range [0, 31]"
VNSRAWI $-1, V2, V3 // ERROR "unsigned immediate -1 must be in range [0, 31]"
VNCVTXXW X10, V3 // ERROR "expected vector register in vs2 position"
VMSEQVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMSEQVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMSEQVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSEQVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMSNEVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMSNEVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMSNEVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSNEVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMSLTUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMSLTUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMSLTVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMSLTVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMSLEUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMSLEUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMSLEUVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSLEUVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMSLEVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMSLEVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMSLEVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSLEVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMSGTUVV X10, V2, V3 // ERROR "expected vector register in vs2 position"
VMSGTUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMSGTUVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSGTUVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMSGTVV X10, V2, V3 // ERROR "expected vector register in vs2 position"
VMSGTVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMSGTVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSGTVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMSGEVV X10, V2, V3 // ERROR "expected vector register in vs2 position"
VMSGEUVV X10, V2, V3 // ERROR "expected vector register in vs2 position"
VMSLTVI $17, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSLTVI $-16, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMSLTUVI $17, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSLTUVI $-16, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMSGEVI $17, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSGEVI $-16, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMSGEUVI $17, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSGEUVI $-16, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMINUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMINUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMINVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMINVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMAXUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMAXUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMAXVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMAXVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMULVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMULVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMULHVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMULHVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMULHUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMULHUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMULHSUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMULHSUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VDIVUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VDIVUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VDIVVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VDIVVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VREMUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VREMUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VREMVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VREMVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWMULVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWMULVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWMULUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWMULUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWMULSUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWMULSUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMACCVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VMACCVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VNMSACVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VNMSACVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMADDVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VMADDVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VNMSUBVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VNMSUBVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWMACCUVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VWMACCUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWMACCVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VWMACCVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWMACCSUVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VWMACCSUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWMACCUSVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMERGEVVM X10, V2, V0, V3 // ERROR "expected vector register in vs1 position"
VMERGEVXM V1, V2, V0, V3 // ERROR "expected integer register in rs1 position"
VMERGEVIM $16, V2, V0, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMERGEVIM $-17, V2, V0, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMVVV X10, V3 // ERROR "expected vector register in vs1 position"
VMVVX V1, V2 // ERROR "expected integer register in rs1 position"
VMVVI $16, V2 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMVVI $-17, V2 // ERROR "signed immediate -17 must be in range [-16, 15]"
VSADDUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VSADDUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSADDUVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VSADDUVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VSSUBUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VSSUBUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VAADDUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VAADDUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VAADDVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VAADDVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VASUBUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VASUBUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VASUBVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VASUBVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSMULVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VSMULVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSSRLVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VSSRLVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSSRLVI $32, V2, V3 // ERROR "signed immediate 32 must be in range [0, 31]"
VSSRLVI $-1, V2, V3 // ERROR "signed immediate -1 must be in range [0, 31]"
VSSRAVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VSSRAVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSSRAVI $32, V2, V3 // ERROR "signed immediate 32 must be in range [0, 31]"
VSSRAVI $-1, V2, V3 // ERROR "signed immediate -1 must be in range [0, 31]"
VNCLIPUWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VNCLIPUWX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VNCLIPUWI $32, V2, V3 // ERROR "signed immediate 32 must be in range [0, 31]"
VNCLIPUWI $-1, V2, V3 // ERROR "signed immediate -1 must be in range [0, 31]"
VNCLIPWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VNCLIPWX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VNCLIPWI $32, V2, V3 // ERROR "signed immediate 32 must be in range [0, 31]"
VNCLIPWI $-1, V2, V3 // ERROR "signed immediate -1 must be in range [0, 31]"
VFADDVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFADDVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFSUBVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFSUBVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFRSUBVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFWADDVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFWADDVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFWSUBVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFWSUBVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFWADDWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFWADDWF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFWSUBWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFWSUBWF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFMULVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFMULVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFDIVVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFDIVVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFRDIVVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFWMULVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFWMULVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFMACCVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFMACCVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFNMACCVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFNMACCVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFMSACVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFMSACVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFNMSACVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFNMSACVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFMADDVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFMADDVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFNMADDVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFNMADDVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFMSUBVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFMSUBVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFNMSUBVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFNMSUBVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFWMACCVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFWMACCVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFWNMACCVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFWNMACCVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFWMSACVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFWMSACVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFWNMSACVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFWNMSACVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFSQRTV X10, V3 // ERROR "expected vector register in vs2 position"
VFRSQRT7V X10, V3 // ERROR "expected vector register in vs2 position"
VFREC7V X10, V3 // ERROR "expected vector register in vs2 position"
VFMINVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFMINVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFMAXVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFMAXVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFSGNJVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFSGNJVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFSGNJNVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFSGNJNVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFSGNJXVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFSGNJXVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFNEGV V2, X10 // ERROR "expected vector register in vd position"
VFABSV V2, X10 // ERROR "expected vector register in vd position"
VMFEQVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMFEQVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VMFNEVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMFNEVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VMFLTVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMFLTVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VMFLEVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMFLEVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VMFGTVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VMFGEVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VMFGTVV X10, V2, V3 // ERROR "expected vector register in vs2 position"
VMFGEVV X10, V2, V3 // ERROR "expected vector register in vs2 position"
VFCLASSV X10, V3 // ERROR "expected vector register in vs2 position"
VFMERGEVFM X10, V2, V0, V3 // ERROR "expected float register in rs1 position"
VFMVVF X10, V3 // ERROR "expected float register in rs1 position"
VFCVTXUFV X10, V3 // ERROR "expected vector register in vs2 position"
VFCVTXFV X10, V3 // ERROR "expected vector register in vs2 position"
VFCVTRTZXUFV X10, V3 // ERROR "expected vector register in vs2 position"
VFCVTRTZXFV X10, V3 // ERROR "expected vector register in vs2 position"
VFCVTFXUV X10, V3 // ERROR "expected vector register in vs2 position"
VFCVTFXV X10, V3 // ERROR "expected vector register in vs2 position"
VFWCVTXUFV X10, V3 // ERROR "expected vector register in vs2 position"
VFWCVTXFV X10, V3 // ERROR "expected vector register in vs2 position"
VFWCVTRTZXUFV X10, V3 // ERROR "expected vector register in vs2 position"
VFWCVTRTZXFV X10, V3 // ERROR "expected vector register in vs2 position"
VFWCVTFXUV X10, V3 // ERROR "expected vector register in vs2 position"
VFWCVTFXV X10, V3 // ERROR "expected vector register in vs2 position"
VFWCVTFFV X10, V3 // ERROR "expected vector register in vs2 position"
VFNCVTXUFW X10, V3 // ERROR "expected vector register in vs2 position"
VFNCVTXFW X10, V3 // ERROR "expected vector register in vs2 position"
VFNCVTRTZXUFW X10, V3 // ERROR "expected vector register in vs2 position"
VFNCVTRTZXFW X10, V3 // ERROR "expected vector register in vs2 position"
VFNCVTFXUW X10, V3 // ERROR "expected vector register in vs2 position"
VFNCVTFXW X10, V3 // ERROR "expected vector register in vs2 position"
VFNCVTFFW X10, V3 // ERROR "expected vector register in vs2 position"
VFNCVTRODFFW X10, V3 // ERROR "expected vector register in vs2 position"
VREDSUMVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VREDMAXUVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VREDMAXVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VREDMINUVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VREDMINVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VREDANDVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VREDORVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VREDXORVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWREDSUMUVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWREDSUMVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFREDOSUMVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFREDUSUMVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFREDMAXVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFREDMINVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFWREDOSUMVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFWREDUSUMVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMANDMM X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMNANDMM X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMANDNMM X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMXORMM X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMORMM X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMNORMM X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMORNMM X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMXNORMM X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMMVM V3, X10 // ERROR "expected vector register in vd position"
VMNOTM V3, X10 // ERROR "expected vector register in vd position"
VCPOPM V2, V1 // ERROR "expected integer register in rd position"
VCPOPM X11, X10 // ERROR "expected vector register in vs2 position"
VFIRSTM V2, V1 // ERROR "expected integer register in rd position"
VFIRSTM X11, X10 // ERROR "expected vector register in vs2 position"
VMSBFM X10, V3 // ERROR "expected vector register in vs2 position"
VMSIFM X10, V3 // ERROR "expected vector register in vs2 position"
VMSOFM X10, V3 // ERROR "expected vector register in vs2 position"
VIOTAM X10, V3 // ERROR "expected vector register in vs2 position"
VIDV X10 // ERROR "expected vector register in vd position"
VMVXS X11, X10 // ERROR "expected vector register in vs2 position"
VMVXS V2, V1 // ERROR "expected integer register in rd position"
VMVSX X11, X10 // ERROR "expected vector register in vd position"
VMVSX V2, V1 // ERROR "expected integer register in rs2 position"
VFMVFS X10, F10 // ERROR "expected vector register in vs2 position"
VFMVFS V2, V1 // ERROR "expected float register in rd position"
VFMVSF X10, V2 // ERROR "expected float register in rs2 position"
VFMVSF V2, V1 // ERROR "expected float register in rs2 position"
VSLIDEUPVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSLIDEUPVI $-1, V2, V3 // ERROR "unsigned immediate -1 must be in range [0, 31]"
VSLIDEUPVI $32, V2, V3 // ERROR "unsigned immediate 32 must be in range [0, 31]"
VSLIDEDOWNVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSLIDEDOWNVI $-1, V2, V3 // ERROR "unsigned immediate -1 must be in range [0, 31]"
VSLIDEDOWNVI $32, V2, V3 // ERROR "unsigned immediate 32 must be in range [0, 31]"
VSLIDE1UPVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VFSLIDE1UPVF V1, V2, V3 // ERROR "expected float register in rs1 position"
VSLIDE1DOWNVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VFSLIDE1DOWNVF V1, V2, V3 // ERROR "expected float register in rs1 position"
VRGATHERVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VRGATHEREI16VV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VRGATHERVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VRGATHERVI $-1, V2, V3 // ERROR "unsigned immediate -1 must be in range [0, 31]"
VRGATHERVI $32, V2, V3 // ERROR "unsigned immediate 32 must be in range [0, 31]"
VCOMPRESSVM X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMV1RV X10, V1 // ERROR "expected vector register in vs2 position"
VMV2RV X10, V10 // ERROR "expected vector register in vs2 position"
VMV4RV X10, V4 // ERROR "expected vector register in vs2 position"
VMV8RV X10, V0 // ERROR "expected vector register in vs2 position"
RET

View File

@@ -263,15 +263,10 @@ TEXT main·foo(SB),DUPOK|NOSPLIT,$16-0 // TEXT main.foo(SB), DUPOK|NOSPLIT, $16-
NC $8, (R15), n-8(SP) // d407f010f000
OC $8, (R15), n-8(SP) // d607f010f000
MVC $8, (R15), n-8(SP) // d207f010f000
MVC $256, 8192(R1), 8192(R2) // b90400a2c2a800002000b90400b1c2b800002000d2ffa000b000
MVCIN $8, (R15), n-8(SP) // e807f010f000
CLC $8, (R15), n-8(SP) // d507f000f010
XC $256, -8(R15), -8(R15) // b90400afc2a8fffffff8d7ffa000a000
MVCLE 0, R4, R6 // a8640000
MVCLE 4095, R4, R6 // a8640fff
MVCLE $4095, R4, R6 // a8640fff
MVCLE (R3), R4, R6 // a8643000
MVCLE 10(R3), R4, R6 // a864300a
MVC $256, 8192(R1), 8192(R2) // b90400a2c2a800002000b90400b1c2b800002000d2ffa000b000
CMP R1, R2 // b9200012
CMP R3, $32767 // a73f7fff
@@ -406,7 +401,6 @@ TEXT main·foo(SB),DUPOK|NOSPLIT,$16-0 // TEXT main.foo(SB), DUPOK|NOSPLIT, $16-
FMADDS F1, F2, F3 // b30e3012
FMSUB F4, F5, F5 // b31f5045
FMSUBS F6, F6, F7 // b30f7066
LCDBR F0, F2 // b3130020
LPDFR F1, F2 // b3700021
LNDFR F3, F4 // b3710043
CPSDR F5, F6, F7 // b3725076
@@ -426,8 +420,8 @@ TEXT main·foo(SB),DUPOK|NOSPLIT,$16-0 // TEXT main.foo(SB), DUPOK|NOSPLIT, $16-
KLMD R2, R8 // b93f0028
KIMD R0, R4 // b93e0004
KDSA R0, R8 // b93a0008
KMA R2, R6, R4 // b9296024
KMCTR R2, R6, R4 // b92d6024
KMA R2, R6, R4 // b9296024
KMCTR R2, R6, R4 // b92d6024
// vector add and sub instructions
VAB V3, V4, V4 // e743400000f3
@@ -540,18 +534,6 @@ TEXT main·foo(SB),DUPOK|NOSPLIT,$16-0 // TEXT main.foo(SB), DUPOK|NOSPLIT, $16-
VSTRCZBS V18, V20, V22, V24 // e78240306f8a
VSTRCZHS V18, V20, V22, V24 // e78241306f8a
VSTRCZFS V18, V20, V22, V24 // e78242306f8a
VFMAXSB $1, V2, V3, V4 // e742301020ef
WFMAXSB $2, V5, V6, V7 // e775602820ef
WFMAXSB $2, F5, F6, F7 // e775602820ef
VFMAXDB $3, V8, V9, V10 // e7a8903030ef
WFMAXDB $4, V11, V12, V13 // e7dbc04830ef
WFMAXDB $4, F11, F12, F13 // e7dbc04830ef
VFMINSB $7, V14, V15, V16 // e70ef07028ee
WFMINSB $8, V17, V18, V19 // e73120882eee
WFMINSB $8, F1, F2, F3 // e731208820ee
VFMINDB $9, V20, V21, V22 // e76450903eee
WFMINDB $10, V23, V24, V25 // e79780a83eee
WFMINDB $10, F7, F8, F9 // e79780a830ee
RET
RET foo(SB)

View File

@@ -29,9 +29,8 @@ var (
)
var DebugFlags struct {
CompressInstructions int `help:"use compressed instructions when possible (if supported by architecture)"`
MayMoreStack string `help:"call named function before all stack growth checks"`
PCTab string `help:"print named pc-value table\nOne of: pctospadj, pctofile, pctoline, pctoinline, pctopcdata"`
MayMoreStack string `help:"call named function before all stack growth checks"`
PCTab string `help:"print named pc-value table\nOne of: pctospadj, pctofile, pctoline, pctoinline, pctopcdata"`
}
var (
@@ -48,8 +47,6 @@ func init() {
flag.Var(objabi.NewDebugFlag(&DebugFlags, nil), "d", "enable debugging settings; try -d help")
objabi.AddVersionFlag() // -V
objabi.Flagcount("S", "print assembly and machine code", &PrintOut)
DebugFlags.CompressInstructions = 1
}
// MultiFlag allows setting a value multiple times to collect a list, as in -I=dir1 -I=dir2.

View File

@@ -68,7 +68,7 @@ func predefine(defines flags.MultiFlag) map[string]*Macro {
var panicOnError bool // For testing.
func (in *Input) Error(args ...any) {
func (in *Input) Error(args ...interface{}) {
if panicOnError {
panic(fmt.Errorf("%s:%d: %s", in.File(), in.Line(), fmt.Sprintln(args...)))
}
@@ -77,7 +77,7 @@ func (in *Input) Error(args ...any) {
}
// expectText is like Error but adds "got XXX" where XXX is a quoted representation of the most recent token.
func (in *Input) expectText(args ...any) {
func (in *Input) expectText(args ...interface{}) {
in.Error(append(args, "; got", strconv.Quote(in.Stack.Text()))...)
}

View File

@@ -40,7 +40,6 @@ func main() {
log.Fatalf("unrecognized architecture %s", GOARCH)
}
ctxt := obj.Linknew(architecture.LinkArch)
ctxt.CompressInstructions = flags.DebugFlags.CompressInstructions != 0
ctxt.Debugasm = flags.PrintOut
ctxt.Debugvlog = flags.DebugV
ctxt.Flag_dynlink = *flags.Dynlink
@@ -50,7 +49,6 @@ func main() {
ctxt.Debugpcln = flags.DebugFlags.PCTab
ctxt.IsAsm = true
ctxt.Pkgpath = *flags.Importpath
ctxt.DwTextCount = objabi.DummyDwarfFunctionCountForAssembler()
switch *flags.Spectre {
default:
log.Printf("unknown setting -spectre=%s", *flags.Spectre)
@@ -59,7 +57,7 @@ func main() {
// nothing
case "index":
// known to compiler; ignore here so people can use
// the same list with -gcflags=-spectre=LIST and -asmflags=-spectre=LIST
// the same list with -gcflags=-spectre=LIST and -asmflags=-spectrre=LIST
case "all", "ret":
ctxt.Retpoline = true
}
@@ -94,7 +92,7 @@ func main() {
for _, f := range flag.Args() {
lexer := lex.NewLexer(f)
parser := asm.NewParser(ctxt, architecture, lexer)
ctxt.DiagFunc = func(format string, args ...any) {
ctxt.DiagFunc = func(format string, args ...interface{}) {
diag = true
log.Printf(format, args...)
}

View File

@@ -199,7 +199,7 @@ func commentText(g *ast.CommentGroup) string {
return strings.Join(pieces, "")
}
func (f *File) validateIdents(x any, context astContext) {
func (f *File) validateIdents(x interface{}, context astContext) {
if x, ok := x.(*ast.Ident); ok {
if f.isMangledName(x.Name) {
error_(x.Pos(), "identifier %q may conflict with identifiers generated by cgo", x.Name)
@@ -208,7 +208,7 @@ func (f *File) validateIdents(x any, context astContext) {
}
// Save various references we are going to need later.
func (f *File) saveExprs(x any, context astContext) {
func (f *File) saveExprs(x interface{}, context astContext) {
switch x := x.(type) {
case *ast.Expr:
switch (*x).(type) {
@@ -278,7 +278,7 @@ func (f *File) saveCall(call *ast.CallExpr, context astContext) {
}
// If a function should be exported add it to ExpFunc.
func (f *File) saveExport(x any, context astContext) {
func (f *File) saveExport(x interface{}, context astContext) {
n, ok := x.(*ast.FuncDecl)
if !ok {
return
@@ -318,7 +318,7 @@ func (f *File) saveExport(x any, context astContext) {
}
// Make f.ExpFunc[i] point at the Func from this AST instead of the other one.
func (f *File) saveExport2(x any, context astContext) {
func (f *File) saveExport2(x interface{}, context astContext) {
n, ok := x.(*ast.FuncDecl)
if !ok {
return
@@ -355,7 +355,7 @@ const (
)
// walk walks the AST x, calling visit(f, x, context) for each node.
func (f *File) walk(x any, context astContext, visit func(*File, any, astContext)) {
func (f *File) walk(x interface{}, context astContext, visit func(*File, interface{}, astContext)) {
visit(f, x, context)
switch n := x.(type) {
case *ast.Expr:
@@ -363,8 +363,7 @@ func (f *File) walk(x any, context astContext, visit func(*File, any, astContext
// everything else just recurs
default:
error_(token.NoPos, "unexpected type %T in walk", x)
panic("unexpected type")
f.walkUnexpected(x, context, visit)
case nil:
@@ -397,9 +396,6 @@ func (f *File) walk(x any, context astContext, visit func(*File, any, astContext
case *ast.IndexExpr:
f.walk(&n.X, ctxExpr, visit)
f.walk(&n.Index, ctxExpr, visit)
case *ast.IndexListExpr:
f.walk(&n.X, ctxExpr, visit)
f.walk(n.Indices, ctxExpr, visit)
case *ast.SliceExpr:
f.walk(&n.X, ctxExpr, visit)
if n.Low != nil {
@@ -438,8 +434,8 @@ func (f *File) walk(x any, context astContext, visit func(*File, any, astContext
case *ast.StructType:
f.walk(n.Fields, ctxField, visit)
case *ast.FuncType:
if n.TypeParams != nil {
f.walk(n.TypeParams, ctxParam, visit)
if tparams := funcTypeTypeParams(n); tparams != nil {
f.walk(tparams, ctxParam, visit)
}
f.walk(n.Params, ctxParam, visit)
if n.Results != nil {
@@ -528,8 +524,8 @@ func (f *File) walk(x any, context astContext, visit func(*File, any, astContext
f.walk(n.Values, ctxExpr, visit)
}
case *ast.TypeSpec:
if n.TypeParams != nil {
f.walk(n.TypeParams, ctxParam, visit)
if tparams := typeSpecTypeParams(n); tparams != nil {
f.walk(tparams, ctxParam, visit)
}
f.walk(&n.Type, ctxType, visit)

25
src/cmd/cgo/ast_go1.go Normal file
View File

@@ -0,0 +1,25 @@
// 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.
//go:build compiler_bootstrap
package main
import (
"go/ast"
"go/token"
)
func (f *File) walkUnexpected(x interface{}, context astContext, visit func(*File, interface{}, astContext)) {
error_(token.NoPos, "unexpected type %T in walk", x)
panic("unexpected type")
}
func funcTypeTypeParams(n *ast.FuncType) *ast.FieldList {
return nil
}
func typeSpecTypeParams(n *ast.TypeSpec) *ast.FieldList {
return nil
}

32
src/cmd/cgo/ast_go118.go Normal file
View File

@@ -0,0 +1,32 @@
// 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.
//go:build !compiler_bootstrap
package main
import (
"go/ast"
"go/token"
)
func (f *File) walkUnexpected(x interface{}, context astContext, visit func(*File, interface{}, astContext)) {
switch n := x.(type) {
default:
error_(token.NoPos, "unexpected type %T in walk", x)
panic("unexpected type")
case *ast.IndexListExpr:
f.walk(&n.X, ctxExpr, visit)
f.walk(n.Indices, ctxExpr, visit)
}
}
func funcTypeTypeParams(n *ast.FuncType) *ast.FieldList {
return n.TypeParams
}
func typeSpecTypeParams(n *ast.TypeSpec) *ast.FieldList {
return n.TypeParams
}

View File

@@ -127,7 +127,7 @@ environment variable when running the go tool: set it to 1 to enable
the use of cgo, and to 0 to disable it. The go tool will set the
build constraint "cgo" if cgo is enabled. The special import "C"
implies the "cgo" build constraint, as though the file also said
"//go:build cgo". Therefore, if cgo is disabled, files that import
"//go:build cgo". Therefore, if cgo is disabled, files that import
"C" will not be built by the go tool. (For more about build constraints
see https://golang.org/pkg/go/build/#hdr-Build_Constraints).
@@ -425,8 +425,8 @@ and of course there is nothing stopping the C code from doing anything
it likes. However, programs that break these rules are likely to fail
in unexpected and unpredictable ways.
The type [runtime/cgo.Handle] can be used to safely pass Go values
between Go and C.
The runtime/cgo.Handle type can be used to safely pass Go values
between Go and C. See the runtime/cgo package documentation for details.
Note: the current implementation has a bug. While Go code is permitted
to write nil or a C pointer (but not a Go pointer) to C memory, the

View File

@@ -27,7 +27,6 @@ import (
"slices"
"strconv"
"strings"
"sync/atomic"
"unicode"
"unicode/utf8"
@@ -183,22 +182,25 @@ func splitQuoted(s string) (r []string, err error) {
return args, err
}
// loadDebug runs gcc to load debug information for the File. The debug
// information will be saved to the debugs field of the file, and be
// processed when Translate is called on the file later.
// loadDebug is called concurrently with different files.
func (f *File) loadDebug(p *Package) {
// Translate rewrites f.AST, the original Go input, to remove
// references to the imported package C, replacing them with
// references to the equivalent Go types, functions, and variables.
func (p *Package) Translate(f *File) {
for _, cref := range f.Ref {
// Convert C.ulong to C.unsigned long, etc.
cref.Name.C = cname(cref.Name.Go)
}
ft := fileTypedefs{typedefs: make(map[string]bool)}
var conv typeConv
conv.Init(p.PtrSize, p.IntSize)
p.typedefs = map[string]bool{}
p.typedefList = nil
numTypedefs := -1
for len(ft.typedefs) > numTypedefs {
numTypedefs = len(ft.typedefs)
for len(p.typedefs) > numTypedefs {
numTypedefs = len(p.typedefs)
// Also ask about any typedefs we've seen so far.
for _, info := range ft.typedefList {
for _, info := range p.typedefList {
if f.Name[info.typedef] != nil {
continue
}
@@ -211,7 +213,7 @@ func (f *File) loadDebug(p *Package) {
}
needType := p.guessKinds(f)
if len(needType) > 0 {
f.debugs = append(f.debugs, p.loadDWARF(f, &ft, needType))
p.loadDWARF(f, &conv, needType)
}
// In godefs mode we're OK with the typedefs, which
@@ -221,18 +223,6 @@ func (f *File) loadDebug(p *Package) {
break
}
}
}
// Translate rewrites f.AST, the original Go input, to remove
// references to the imported package C, replacing them with
// references to the equivalent Go types, functions, and variables.
// Preconditions: File.loadDebug must be called prior to translate.
func (p *Package) Translate(f *File) {
var conv typeConv
conv.Init(p.PtrSize, p.IntSize)
for _, d := range f.debugs {
p.recordTypes(f, d, &conv)
}
p.prepareNames(f)
if p.rewriteCalls(f) {
// Add `import _cgo_unsafe "unsafe"` after the package statement.
@@ -251,7 +241,7 @@ func (f *File) loadDefines(gccOptions []string) bool {
stdout := gccDefines(b.Bytes(), gccOptions)
var gccIsClang bool
for line := range strings.SplitSeq(stdout, "\n") {
for _, line := range strings.Split(stdout, "\n") {
if len(line) < 9 || line[0:7] != "#define" {
continue
}
@@ -289,7 +279,6 @@ func (f *File) loadDefines(gccOptions []string) bool {
// guessKinds tricks gcc into revealing the kind of each
// name xxx for the references C.xxx in the Go input.
// The kind is either a constant, type, or variable.
// guessKinds is called concurrently with different files.
func (p *Package) guessKinds(f *File) []*Name {
// Determine kinds for names we already know about,
// like #defines or 'struct foo', before bothering with gcc.
@@ -428,7 +417,7 @@ func (p *Package) guessKinds(f *File) []*Name {
notDeclared
)
sawUnmatchedErrors := false
for line := range strings.SplitSeq(stderr, "\n") {
for _, line := range strings.Split(stderr, "\n") {
// Ignore warnings and random comments, with one
// exception: newer GCC versions will sometimes emit
// an error on a macro #define with a note referring
@@ -533,8 +522,7 @@ func (p *Package) guessKinds(f *File) []*Name {
// loadDWARF parses the DWARF debug information generated
// by gcc to learn the details of the constants, variables, and types
// being referred to as C.xxx.
// loadDwarf is called concurrently with different files.
func (p *Package) loadDWARF(f *File, ft *fileTypedefs, names []*Name) *debug {
func (p *Package) loadDWARF(f *File, conv *typeConv, names []*Name) {
// Extract the types from the DWARF section of an object
// from a well-formed C program. Gcc only generates DWARF info
// for symbols in the object file, so it is not enough to print the
@@ -648,28 +636,13 @@ func (p *Package) loadDWARF(f *File, ft *fileTypedefs, names []*Name) *debug {
fatalf("malformed __cgo__ name: %s", name)
}
types[i] = t.Type
ft.recordTypedefs(t.Type, f.NamePos[names[i]])
p.recordTypedefs(t.Type, f.NamePos[names[i]])
}
if e.Tag != dwarf.TagCompileUnit {
r.SkipChildren()
}
}
return &debug{names, types, ints, floats, strs}
}
// debug is the data extracted by running an iteration of loadDWARF on a file.
type debug struct {
names []*Name
types []dwarf.Type
ints []int64
floats []float64
strs []string
}
func (p *Package) recordTypes(f *File, data *debug, conv *typeConv) {
names, types, ints, floats, strs := data.names, data.types, data.ints, data.floats, data.strs
// Record types and typedef information.
for i, n := range names {
if strings.HasSuffix(n.Go, "GetTypeID") && types[i].String() == "func() CFTypeID" {
@@ -728,17 +701,12 @@ func (p *Package) recordTypes(f *File, data *debug, conv *typeConv) {
}
}
type fileTypedefs struct {
typedefs map[string]bool // type names that appear in the types of the objects we're interested in
typedefList []typedefInfo
// recordTypedefs remembers in p.typedefs all the typedefs used in dtypes and its children.
func (p *Package) recordTypedefs(dtype dwarf.Type, pos token.Pos) {
p.recordTypedefs1(dtype, pos, map[dwarf.Type]bool{})
}
// recordTypedefs remembers in ft.typedefs all the typedefs used in dtypes and its children.
func (ft *fileTypedefs) recordTypedefs(dtype dwarf.Type, pos token.Pos) {
ft.recordTypedefs1(dtype, pos, map[dwarf.Type]bool{})
}
func (ft *fileTypedefs) recordTypedefs1(dtype dwarf.Type, pos token.Pos, visited map[dwarf.Type]bool) {
func (p *Package) recordTypedefs1(dtype dwarf.Type, pos token.Pos, visited map[dwarf.Type]bool) {
if dtype == nil {
return
}
@@ -752,25 +720,25 @@ func (ft *fileTypedefs) recordTypedefs1(dtype dwarf.Type, pos token.Pos, visited
// Don't look inside builtin types. There be dragons.
return
}
if !ft.typedefs[dt.Name] {
ft.typedefs[dt.Name] = true
ft.typedefList = append(ft.typedefList, typedefInfo{dt.Name, pos})
ft.recordTypedefs1(dt.Type, pos, visited)
if !p.typedefs[dt.Name] {
p.typedefs[dt.Name] = true
p.typedefList = append(p.typedefList, typedefInfo{dt.Name, pos})
p.recordTypedefs1(dt.Type, pos, visited)
}
case *dwarf.PtrType:
ft.recordTypedefs1(dt.Type, pos, visited)
p.recordTypedefs1(dt.Type, pos, visited)
case *dwarf.ArrayType:
ft.recordTypedefs1(dt.Type, pos, visited)
p.recordTypedefs1(dt.Type, pos, visited)
case *dwarf.QualType:
ft.recordTypedefs1(dt.Type, pos, visited)
p.recordTypedefs1(dt.Type, pos, visited)
case *dwarf.FuncType:
ft.recordTypedefs1(dt.ReturnType, pos, visited)
p.recordTypedefs1(dt.ReturnType, pos, visited)
for _, a := range dt.ParamType {
ft.recordTypedefs1(a, pos, visited)
p.recordTypedefs1(a, pos, visited)
}
case *dwarf.StructType:
for _, l := range dt.Field {
ft.recordTypedefs1(l.Type, pos, visited)
for _, f := range dt.Field {
p.recordTypedefs1(f.Type, pos, visited)
}
}
}
@@ -1056,7 +1024,7 @@ func (p *Package) rewriteCall(f *File, call *Call) (string, bool) {
func (p *Package) needsPointerCheck(f *File, t ast.Expr, arg ast.Expr) bool {
// An untyped nil does not need a pointer check, and when
// _cgoCheckPointer returns the untyped nil the type assertion we
// are going to insert will fail. Easier to just skip nil arguments.
// are going to insert will fail. Easier to just skip nil arguments.
// TODO: Note that this fails if nil is shadowed.
if id, ok := arg.(*ast.Ident); ok && id.Name == "nil" {
return false
@@ -1121,9 +1089,6 @@ func (p *Package) hasPointer(f *File, t ast.Expr, top bool) bool {
if t.Name == "error" {
return true
}
if t.Name == "any" {
return true
}
if goTypes[t.Name] != nil {
return false
}
@@ -1161,7 +1126,7 @@ func (p *Package) hasPointer(f *File, t ast.Expr, top bool) bool {
// If addPosition is true, add position info to the idents of C names in arg.
func (p *Package) mangle(f *File, arg *ast.Expr, addPosition bool) (ast.Expr, bool) {
needsUnsafe := false
f.walk(arg, ctxExpr, func(f *File, arg any, context astContext) {
f.walk(arg, ctxExpr, func(f *File, arg interface{}, context astContext) {
px, ok := arg.(*ast.Expr)
if !ok {
return
@@ -1791,24 +1756,20 @@ func gccMachine() []string {
return nil
}
var n atomic.Int64
func gccTmp() string {
c := strconv.Itoa(int(n.Add(1)))
return *objDir + "_cgo_" + c + ".o"
return *objDir + "_cgo_.o"
}
// gccCmd returns the gcc command line to use for compiling
// the input.
// gccCommand is called concurrently for different files.
func (p *Package) gccCmd(ofile string) []string {
func (p *Package) gccCmd() []string {
c := append(gccBaseCmd,
"-w", // no warnings
"-Wno-error", // warnings are not errors
"-o"+ofile, // write object to tmp
"-gdwarf-2", // generate DWARF v2 debugging symbols
"-c", // do not link
"-xc", // input language is C
"-w", // no warnings
"-Wno-error", // warnings are not errors
"-o"+gccTmp(), // write object to tmp
"-gdwarf-2", // generate DWARF v2 debugging symbols
"-c", // do not link
"-xc", // input language is C
)
if p.GccIsClang {
c = append(c,
@@ -1844,10 +1805,8 @@ func (p *Package) gccCmd(ofile string) []string {
// gccDebug runs gcc -gdwarf-2 over the C program stdin and
// returns the corresponding DWARF data and, if present, debug data block.
// gccDebug is called concurrently with different C programs.
func (p *Package) gccDebug(stdin []byte, nnames int) (d *dwarf.Data, ints []int64, floats []float64, strs []string) {
ofile := gccTmp()
runGcc(stdin, p.gccCmd(ofile))
runGcc(stdin, p.gccCmd())
isDebugInts := func(s string) bool {
// Some systems use leading _ to denote non-assembly symbols.
@@ -1897,11 +1856,11 @@ func (p *Package) gccDebug(stdin []byte, nnames int) (d *dwarf.Data, ints []int6
}
}
if f, err := macho.Open(ofile); err == nil {
if f, err := macho.Open(gccTmp()); err == nil {
defer f.Close()
d, err := f.DWARF()
if err != nil {
fatalf("cannot load DWARF output from %s: %v", ofile, err)
fatalf("cannot load DWARF output from %s: %v", gccTmp(), err)
}
bo := f.ByteOrder
if f.Symtab != nil {
@@ -1975,11 +1934,11 @@ func (p *Package) gccDebug(stdin []byte, nnames int) (d *dwarf.Data, ints []int6
return d, ints, floats, strs
}
if f, err := elf.Open(ofile); err == nil {
if f, err := elf.Open(gccTmp()); err == nil {
defer f.Close()
d, err := f.DWARF()
if err != nil {
fatalf("cannot load DWARF output from %s: %v", ofile, err)
fatalf("cannot load DWARF output from %s: %v", gccTmp(), err)
}
bo := f.ByteOrder
symtab, err := f.Symbols()
@@ -2075,11 +2034,11 @@ func (p *Package) gccDebug(stdin []byte, nnames int) (d *dwarf.Data, ints []int6
return d, ints, floats, strs
}
if f, err := pe.Open(ofile); err == nil {
if f, err := pe.Open(gccTmp()); err == nil {
defer f.Close()
d, err := f.DWARF()
if err != nil {
fatalf("cannot load DWARF output from %s: %v", ofile, err)
fatalf("cannot load DWARF output from %s: %v", gccTmp(), err)
}
bo := binary.LittleEndian
for _, s := range f.Symbols {
@@ -2147,17 +2106,17 @@ func (p *Package) gccDebug(stdin []byte, nnames int) (d *dwarf.Data, ints []int6
return d, ints, floats, strs
}
if f, err := xcoff.Open(ofile); err == nil {
if f, err := xcoff.Open(gccTmp()); err == nil {
defer f.Close()
d, err := f.DWARF()
if err != nil {
fatalf("cannot load DWARF output from %s: %v", ofile, err)
fatalf("cannot load DWARF output from %s: %v", gccTmp(), err)
}
bo := binary.BigEndian
for _, s := range f.Symbols {
switch {
case isDebugInts(s.Name):
if i := s.SectionNumber - 1; 0 <= i && i < len(f.Sections) {
if i := int(s.SectionNumber) - 1; 0 <= i && i < len(f.Sections) {
sect := f.Sections[i]
if s.Value < sect.Size {
if sdat, err := sect.Data(); err == nil {
@@ -2170,7 +2129,7 @@ func (p *Package) gccDebug(stdin []byte, nnames int) (d *dwarf.Data, ints []int6
}
}
case isDebugFloats(s.Name):
if i := s.SectionNumber - 1; 0 <= i && i < len(f.Sections) {
if i := int(s.SectionNumber) - 1; 0 <= i && i < len(f.Sections) {
sect := f.Sections[i]
if s.Value < sect.Size {
if sdat, err := sect.Data(); err == nil {
@@ -2184,7 +2143,7 @@ func (p *Package) gccDebug(stdin []byte, nnames int) (d *dwarf.Data, ints []int6
}
default:
if n := indexOfDebugStr(s.Name); n != -1 {
if i := s.SectionNumber - 1; 0 <= i && i < len(f.Sections) {
if i := int(s.SectionNumber) - 1; 0 <= i && i < len(f.Sections) {
sect := f.Sections[i]
if s.Value < sect.Size {
if sdat, err := sect.Data(); err == nil {
@@ -2196,7 +2155,7 @@ func (p *Package) gccDebug(stdin []byte, nnames int) (d *dwarf.Data, ints []int6
break
}
if n := indexOfDebugStrlen(s.Name); n != -1 {
if i := s.SectionNumber - 1; 0 <= i && i < len(f.Sections) {
if i := int(s.SectionNumber) - 1; 0 <= i && i < len(f.Sections) {
sect := f.Sections[i]
if s.Value < sect.Size {
if sdat, err := sect.Data(); err == nil {
@@ -2217,7 +2176,7 @@ func (p *Package) gccDebug(stdin []byte, nnames int) (d *dwarf.Data, ints []int6
buildStrings()
return d, ints, floats, strs
}
fatalf("cannot parse gcc output %s as ELF, Mach-O, PE, XCOFF object", ofile)
fatalf("cannot parse gcc output %s as ELF, Mach-O, PE, XCOFF object", gccTmp())
panic("not reached")
}
@@ -2235,10 +2194,9 @@ func gccDefines(stdin []byte, gccOptions []string) string {
// gccErrors runs gcc over the C program stdin and returns
// the errors that gcc prints. That is, this function expects
// gcc to fail.
// gccErrors is called concurrently with different C programs.
func (p *Package) gccErrors(stdin []byte, extraArgs ...string) string {
// TODO(rsc): require failure
args := p.gccCmd(gccTmp())
args := p.gccCmd()
// Optimization options can confuse the error messages; remove them.
nargs := make([]string, 0, len(args)+len(extraArgs))
@@ -2442,7 +2400,7 @@ func (tr *TypeRepr) Empty() bool {
// Set modifies the type representation.
// If fargs are provided, repr is used as a format for fmt.Sprintf.
// Otherwise, repr is used unprocessed as the type representation.
func (tr *TypeRepr) Set(repr string, fargs ...any) {
func (tr *TypeRepr) Set(repr string, fargs ...interface{}) {
tr.Repr = repr
tr.FormatArgs = fargs
}
@@ -2716,7 +2674,7 @@ func (c *typeConv) loadType(dtype dwarf.Type, pos token.Pos, parent string) *Typ
// so execute the basic things that the struct case would do
// other than try to determine a Go representation.
tt := *t
tt.C = &TypeRepr{"%s %s", []any{dt.Kind, tag}}
tt.C = &TypeRepr{"%s %s", []interface{}{dt.Kind, tag}}
// We don't know what the representation of this struct is, so don't let
// anyone allocate one on the Go side. As a side effect of this annotation,
// pointers to this type will not be considered pointers in Go. They won't
@@ -2746,7 +2704,7 @@ func (c *typeConv) loadType(dtype dwarf.Type, pos token.Pos, parent string) *Typ
t.Align = align
tt := *t
if tag != "" {
tt.C = &TypeRepr{"struct %s", []any{tag}}
tt.C = &TypeRepr{"struct %s", []interface{}{tag}}
}
tt.Go = g
if c.incompleteStructs[tag] {
@@ -2905,7 +2863,7 @@ func (c *typeConv) loadType(dtype dwarf.Type, pos token.Pos, parent string) *Typ
if ss, ok := dwarfToName[s]; ok {
s = ss
}
s = strings.ReplaceAll(s, " ", "")
s = strings.Replace(s, " ", "", -1)
name := c.Ident("_Ctype_" + s)
tt := *t
typedef[name.Name] = &tt
@@ -3013,7 +2971,7 @@ func (c *typeConv) FuncType(dtype *dwarf.FuncType, pos token.Pos) *FuncType {
for i, f := range dtype.ParamType {
// gcc's DWARF generator outputs a single DotDotDotType parameter for
// function pointers that specify no parameters (e.g. void
// (*__cgo_0)()). Treat this special case as void. This case is
// (*__cgo_0)()). Treat this special case as void. This case is
// invalid according to ISO C anyway (i.e. void (*__cgo_1)(...) is not
// legal).
if _, ok := f.(*dwarf.DotDotDotType); ok && i == 0 {
@@ -3084,7 +3042,7 @@ func (c *typeConv) Struct(dt *dwarf.StructType, pos token.Pos) (expr *ast.Struct
off := int64(0)
// Rename struct fields that happen to be named Go keywords into
// _{keyword}. Create a map from C ident -> Go ident. The Go ident will
// _{keyword}. Create a map from C ident -> Go ident. The Go ident will
// be mangled. Any existing identifier that already has the same name on
// the C-side will cause the Go-mangled version to be prefixed with _.
// (e.g. in a struct with fields '_type' and 'type', the latter would be
@@ -3312,7 +3270,7 @@ func godefsFields(fld []*ast.Field) {
// fieldPrefix returns the prefix that should be removed from all the
// field names when generating the C or Go code. For generated
// C, we leave the names as is (tv_sec, tv_usec), since that's what
// people are used to seeing in C. For generated Go code, such as
// people are used to seeing in C. For generated Go code, such as
// package syscall's data structures, we drop a common prefix
// (so sec, usec, which will get turned into Sec, Usec for exporting).
func fieldPrefix(fld []*ast.Field) string {
@@ -3459,7 +3417,7 @@ func (c *typeConv) badCFType(dt *dwarf.TypedefType) bool {
// Tagged pointer support
// Low-bit set means tagged object, next 3 bits (currently)
// define the tagged object class, next 4 bits are for type
// information for the specific tagged object class. Thus,
// information for the specific tagged object class. Thus,
// the low byte is for type info, and the rest of a pointer
// (32 or 64-bit) is for payload, whatever the tagged class.
//

View File

@@ -117,7 +117,7 @@ func (p *Package) godefs(f *File, args []string) string {
var gofmtBuf strings.Builder
// gofmt returns the gofmt-formatted string for an AST node.
func gofmt(n any) string {
func gofmt(n interface{}) string {
gofmtBuf.Reset()
err := printer.Fprint(&gofmtBuf, fset, n)
if err != nil {

View File

@@ -40,9 +40,8 @@ func TestCallback(t *testing.T) {
}
func run(t *testing.T, dir string, lto bool, args ...string) {
testenv.MustHaveGoRun(t)
runArgs := append([]string{"run", "."}, args...)
cmd := exec.Command(testenv.GoToolPath(t), runArgs...)
cmd := exec.Command("go", runArgs...)
cmd.Dir = dir
if lto {
// On the builders we're using the default /usr/bin/ld, but
@@ -69,7 +68,7 @@ func run(t *testing.T, dir string, lto bool, args ...string) {
func mustHaveCxx(t *testing.T) {
// Ask the go tool for the CXX it's configured to use.
cxx, err := exec.Command(testenv.GoToolPath(t), "env", "CXX").CombinedOutput()
cxx, err := exec.Command("go", "env", "CXX").CombinedOutput()
if err != nil {
t.Fatalf("go env CXX failed: %s", err)
}
@@ -80,7 +79,7 @@ func mustHaveCxx(t *testing.T) {
if len(args) == 0 {
t.Skip("no C++ compiler")
}
testenv.MustHaveExecPath(t, args[0])
testenv.MustHaveExecPath(t, string(args[0]))
}
var (

View File

@@ -4,9 +4,9 @@
package cgotest
// Test that we have no more than one build ID. In the past we used
// Test that we have no more than one build ID. In the past we used
// to generate a separate build ID for each package using cgo, and the
// linker concatenated them all. We don't want that--we only want
// linker concatenated them all. We don't want that--we only want
// one.
import (
@@ -42,7 +42,7 @@ sections:
for len(d) > 0 {
// ELF standards differ as to the sizes in
// note sections. Both the GNU linker and
// note sections. Both the GNU linker and
// gold always generate 32-bit sizes, so that
// is what we assume here.

View File

@@ -40,7 +40,7 @@ func nestedCall(f func()) {
callbackMutex.Unlock()
// Pass the address of i because the C function was written to
// take a pointer. We could pass an int if we felt like
// take a pointer. We could pass an int if we felt like
// rewriting the C code.
C.callback(unsafe.Pointer(&i))

View File

@@ -1,11 +0,0 @@
// Copyright 2025 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.
//go:build cgo && darwin
package cgotest
import "testing"
func TestIssue76023(t *testing.T) { issue76023(t) }

View File

@@ -12,105 +12,100 @@ import "testing"
// so that they can use cgo (import "C").
// These wrappers are here for gotest to find.
func Test1328(t *testing.T) { test1328(t) }
func Test1560(t *testing.T) { test1560(t) }
func Test1635(t *testing.T) { test1635(t) }
func Test3250(t *testing.T) { test3250(t) }
func Test3729(t *testing.T) { test3729(t) }
func Test3775(t *testing.T) { test3775(t) }
func Test4029(t *testing.T) { test4029(t) }
func Test4339(t *testing.T) { test4339(t) }
func Test5227(t *testing.T) { test5227(t) }
func Test5242(t *testing.T) { test5242(t) }
func Test5337(t *testing.T) { test5337(t) }
func Test5548(t *testing.T) { test5548(t) }
func Test5603(t *testing.T) { test5603(t) }
func Test5986(t *testing.T) { test5986(t) }
func Test6390(t *testing.T) { test6390(t) }
func Test6833(t *testing.T) { test6833(t) }
func Test6907(t *testing.T) { test6907(t) }
func Test6907Go(t *testing.T) { test6907Go(t) }
func Test7560(t *testing.T) { test7560(t) }
func Test7665(t *testing.T) { test7665(t) }
func Test7978(t *testing.T) { test7978(t) }
func Test8092(t *testing.T) { test8092(t) }
func Test8517(t *testing.T) { test8517(t) }
func Test8694(t *testing.T) { test8694(t) }
func Test8756(t *testing.T) { test8756(t) }
func Test8811(t *testing.T) { test8811(t) }
func Test9026(t *testing.T) { test9026(t) }
func Test9510(t *testing.T) { test9510(t) }
func Test9557(t *testing.T) { test9557(t) }
func Test10303(t *testing.T) { test10303(t, 10) }
func Test11925(t *testing.T) { test11925(t) }
func Test12030(t *testing.T) { test12030(t) }
func Test14838(t *testing.T) { test14838(t) }
func Test17065(t *testing.T) { test17065(t) }
func Test17537(t *testing.T) { test17537(t) }
func Test18126(t *testing.T) { test18126(t) }
func Test18720(t *testing.T) { test18720(t) }
func Test20129(t *testing.T) { test20129(t) }
func Test20266(t *testing.T) { test20266(t) }
func Test20369(t *testing.T) { test20369(t) }
func Test20910(t *testing.T) { test20910(t) }
func Test21708(t *testing.T) { test21708(t) }
func Test21809(t *testing.T) { test21809(t) }
func Test21897(t *testing.T) { test21897(t) }
func Test22906(t *testing.T) { test22906(t) }
func Test23356(t *testing.T) { test23356(t) }
func Test24206(t *testing.T) { test24206(t) }
func Test25143(t *testing.T) { test25143(t) }
func Test26066(t *testing.T) { test26066(t) }
func Test26213(t *testing.T) { test26213(t) }
func Test27660(t *testing.T) { test27660(t) }
func Test28896(t *testing.T) { test28896(t) }
func Test30065(t *testing.T) { test30065(t) }
func Test32579(t *testing.T) { test32579(t) }
func Test31891(t *testing.T) { test31891(t) }
func Test42018(t *testing.T) { test42018(t) }
func Test45451(t *testing.T) { test45451(t) }
func Test49633(t *testing.T) { test49633(t) }
func Test69086(t *testing.T) { test69086(t) }
func TestAlign(t *testing.T) { testAlign(t) }
func TestAtol(t *testing.T) { testAtol(t) }
func TestBlocking(t *testing.T) { testBlocking(t) }
func TestBoolAlign(t *testing.T) { testBoolAlign(t) }
func TestCallGoWithString(t *testing.T) { testCallGoWithString(t) }
func TestCallback(t *testing.T) { testCallback(t) }
func TestCallbackCallers(t *testing.T) { testCallbackCallers(t) }
func TestCallbackGC(t *testing.T) { testCallbackGC(t) }
func TestCallbackPanic(t *testing.T) { testCallbackPanic(t) }
func TestCallbackPanicLocked(t *testing.T) { testCallbackPanicLocked(t) }
func TestCallbackPanicLoop(t *testing.T) { testCallbackPanicLoop(t) }
func TestCallbackStack(t *testing.T) { testCallbackStack(t) }
func TestCflags(t *testing.T) { testCflags(t) }
func TestCheckConst(t *testing.T) { testCheckConst(t) }
func TestConst(t *testing.T) { testConst(t) }
func TestCthread(t *testing.T) { testCthread(t) }
func TestEnum(t *testing.T) { testEnum(t) }
func TestNamedEnum(t *testing.T) { testNamedEnum(t) }
func TestCastToEnum(t *testing.T) { testCastToEnum(t) }
func TestErrno(t *testing.T) { testErrno(t) }
func TestFpVar(t *testing.T) { testFpVar(t) }
func TestGCC68255(t *testing.T) { testGCC68255(t) }
func TestHandle(t *testing.T) { testHandle(t) }
func TestHelpers(t *testing.T) { testHelpers(t) }
func TestLibgcc(t *testing.T) { testLibgcc(t) }
func TestMultipleAssign(t *testing.T) { testMultipleAssign(t) }
func TestNaming(t *testing.T) { testNaming(t) }
func TestPanicFromC(t *testing.T) { testPanicFromC(t) }
func TestPrintf(t *testing.T) { testPrintf(t) }
func TestReturnAfterGrow(t *testing.T) { testReturnAfterGrow(t) }
func TestReturnAfterGrowFromGo(t *testing.T) { testReturnAfterGrowFromGo(t) }
func TestSetEnv(t *testing.T) { testSetEnv(t) }
func TestThreadLock(t *testing.T) { testThreadLockFunc(t) }
func TestUnsignedInt(t *testing.T) { testUnsignedInt(t) }
func TestZeroArgCallback(t *testing.T) { testZeroArgCallback(t) }
func Test76340(t *testing.T) { test76340(t) }
func TestDITCgo(t *testing.T) { testDITCgo(t) }
func TestDITCgoCallback(t *testing.T) { testDITCgoCallback(t) }
func TestDITCgoCallbackEnableDIT(t *testing.T) { testDITCgoCallbackEnableDIT(t) }
func TestDITCgoCallbackDisableDIT(t *testing.T) { testDITCgoCallbackDisableDIT(t) }
func Test1328(t *testing.T) { test1328(t) }
func Test1560(t *testing.T) { test1560(t) }
func Test1635(t *testing.T) { test1635(t) }
func Test3250(t *testing.T) { test3250(t) }
func Test3729(t *testing.T) { test3729(t) }
func Test3775(t *testing.T) { test3775(t) }
func Test4029(t *testing.T) { test4029(t) }
func Test4339(t *testing.T) { test4339(t) }
func Test5227(t *testing.T) { test5227(t) }
func Test5242(t *testing.T) { test5242(t) }
func Test5337(t *testing.T) { test5337(t) }
func Test5548(t *testing.T) { test5548(t) }
func Test5603(t *testing.T) { test5603(t) }
func Test5986(t *testing.T) { test5986(t) }
func Test6390(t *testing.T) { test6390(t) }
func Test6833(t *testing.T) { test6833(t) }
func Test6907(t *testing.T) { test6907(t) }
func Test6907Go(t *testing.T) { test6907Go(t) }
func Test7560(t *testing.T) { test7560(t) }
func Test7665(t *testing.T) { test7665(t) }
func Test7978(t *testing.T) { test7978(t) }
func Test8092(t *testing.T) { test8092(t) }
func Test8517(t *testing.T) { test8517(t) }
func Test8694(t *testing.T) { test8694(t) }
func Test8756(t *testing.T) { test8756(t) }
func Test8811(t *testing.T) { test8811(t) }
func Test9026(t *testing.T) { test9026(t) }
func Test9510(t *testing.T) { test9510(t) }
func Test9557(t *testing.T) { test9557(t) }
func Test10303(t *testing.T) { test10303(t, 10) }
func Test11925(t *testing.T) { test11925(t) }
func Test12030(t *testing.T) { test12030(t) }
func Test14838(t *testing.T) { test14838(t) }
func Test17065(t *testing.T) { test17065(t) }
func Test17537(t *testing.T) { test17537(t) }
func Test18126(t *testing.T) { test18126(t) }
func Test18720(t *testing.T) { test18720(t) }
func Test20129(t *testing.T) { test20129(t) }
func Test20266(t *testing.T) { test20266(t) }
func Test20369(t *testing.T) { test20369(t) }
func Test20910(t *testing.T) { test20910(t) }
func Test21708(t *testing.T) { test21708(t) }
func Test21809(t *testing.T) { test21809(t) }
func Test21897(t *testing.T) { test21897(t) }
func Test22906(t *testing.T) { test22906(t) }
func Test23356(t *testing.T) { test23356(t) }
func Test24206(t *testing.T) { test24206(t) }
func Test25143(t *testing.T) { test25143(t) }
func Test26066(t *testing.T) { test26066(t) }
func Test26213(t *testing.T) { test26213(t) }
func Test27660(t *testing.T) { test27660(t) }
func Test28896(t *testing.T) { test28896(t) }
func Test30065(t *testing.T) { test30065(t) }
func Test32579(t *testing.T) { test32579(t) }
func Test31891(t *testing.T) { test31891(t) }
func Test42018(t *testing.T) { test42018(t) }
func Test45451(t *testing.T) { test45451(t) }
func Test49633(t *testing.T) { test49633(t) }
func Test69086(t *testing.T) { test69086(t) }
func TestAlign(t *testing.T) { testAlign(t) }
func TestAtol(t *testing.T) { testAtol(t) }
func TestBlocking(t *testing.T) { testBlocking(t) }
func TestBoolAlign(t *testing.T) { testBoolAlign(t) }
func TestCallGoWithString(t *testing.T) { testCallGoWithString(t) }
func TestCallback(t *testing.T) { testCallback(t) }
func TestCallbackCallers(t *testing.T) { testCallbackCallers(t) }
func TestCallbackGC(t *testing.T) { testCallbackGC(t) }
func TestCallbackPanic(t *testing.T) { testCallbackPanic(t) }
func TestCallbackPanicLocked(t *testing.T) { testCallbackPanicLocked(t) }
func TestCallbackPanicLoop(t *testing.T) { testCallbackPanicLoop(t) }
func TestCallbackStack(t *testing.T) { testCallbackStack(t) }
func TestCflags(t *testing.T) { testCflags(t) }
func TestCheckConst(t *testing.T) { testCheckConst(t) }
func TestConst(t *testing.T) { testConst(t) }
func TestCthread(t *testing.T) { testCthread(t) }
func TestEnum(t *testing.T) { testEnum(t) }
func TestNamedEnum(t *testing.T) { testNamedEnum(t) }
func TestCastToEnum(t *testing.T) { testCastToEnum(t) }
func TestErrno(t *testing.T) { testErrno(t) }
func TestFpVar(t *testing.T) { testFpVar(t) }
func TestGCC68255(t *testing.T) { testGCC68255(t) }
func TestHandle(t *testing.T) { testHandle(t) }
func TestHelpers(t *testing.T) { testHelpers(t) }
func TestLibgcc(t *testing.T) { testLibgcc(t) }
func TestMultipleAssign(t *testing.T) { testMultipleAssign(t) }
func TestNaming(t *testing.T) { testNaming(t) }
func TestPanicFromC(t *testing.T) { testPanicFromC(t) }
func TestPrintf(t *testing.T) { testPrintf(t) }
func TestReturnAfterGrow(t *testing.T) { testReturnAfterGrow(t) }
func TestReturnAfterGrowFromGo(t *testing.T) { testReturnAfterGrowFromGo(t) }
func TestSetEnv(t *testing.T) { testSetEnv(t) }
func TestThreadLock(t *testing.T) { testThreadLockFunc(t) }
func TestUnsignedInt(t *testing.T) { testUnsignedInt(t) }
func TestZeroArgCallback(t *testing.T) { testZeroArgCallback(t) }
func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }
func BenchmarkGoString(b *testing.B) { benchGoString(b) }

View File

@@ -3,7 +3,7 @@
// license that can be found in the LICENSE file.
// Test that it's OK to have C code that does nothing other than
// initialize a global variable. This used to fail with gccgo.
// initialize a global variable. This used to fail with gccgo.
package gcc68255

View File

@@ -11,7 +11,6 @@ package cgotest
import (
"bytes"
"crypto/md5"
"internal/testenv"
"os"
"os/exec"
"runtime"
@@ -74,7 +73,7 @@ func test18146(t *testing.T) {
}
runtime.GOMAXPROCS(threads)
argv := append(os.Args, "-test.run=^$")
if err := syscall.Exec(testenv.Executable(t), argv, os.Environ()); err != nil {
if err := syscall.Exec(os.Args[0], argv, os.Environ()); err != nil {
t.Fatal(err)
}
}
@@ -88,7 +87,7 @@ func test18146(t *testing.T) {
args := append(append([]string(nil), os.Args[1:]...), "-test.run=^Test18146$")
for n := attempts; n > 0; n-- {
cmd := exec.Command(testenv.Executable(t), args...)
cmd := exec.Command(os.Args[0], args...)
cmd.Env = append(os.Environ(), "test18146=exec")
buf := bytes.NewBuffer(nil)
cmd.Stdout = buf

View File

@@ -11,7 +11,6 @@ package cgotest
/*
#include <stdint.h>
#include <stdlib.h>
#include <dlfcn.h>
#cgo linux LDFLAGS: -ldl
@@ -25,7 +24,6 @@ import "C"
import (
"testing"
"unsafe"
)
var callbacks int
@@ -68,9 +66,7 @@ func loadThySelf(t *testing.T, symbol string) {
}
defer C.dlclose4029(this_process)
symCStr := C.CString(symbol)
defer C.free(unsafe.Pointer(symCStr))
symbol_address := C.dlsym4029(this_process, symCStr)
symbol_address := C.dlsym4029(this_process, C.CString(symbol))
if symbol_address == 0 {
t.Error("dlsym:", C.GoString(C.dlerror()))
return

View File

@@ -1,27 +0,0 @@
// Copyright 2025 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.
//go:build darwin
package cgotest
/*
#cgo LDFLAGS: -Wl,-undefined,dynamic_lookup
extern void __gotest_cgo_null_api(void) __attribute__((weak_import));
int issue76023(void) {
if (__gotest_cgo_null_api) return 1;
return 0;
}
*/
import "C"
import "testing"
func issue76023(t *testing.T) {
r := C.issue76023()
if r != 0 {
t.Error("found __gotest_cgo_null_api")
}
}

View File

@@ -1,12 +0,0 @@
// Copyright 2025 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.
//go:build cgo
package cgotest
// Issue 43639: No runtime test needed, make sure package
// cmd/cgo/internal/test/issue76861 compiles without error.
import _ "cmd/cgo/internal/test/issue76861"

View File

@@ -1,13 +0,0 @@
// Copyright 2025 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 issue76861
// #cgo CFLAGS: -Wall -Werror
// void issue76861(void) {}
import "C"
func Issue76861() {
C.issue76861()
}

View File

@@ -245,7 +245,7 @@ static void *thread(void *p) {
return NULL;
}
void testSendSIG() {
enum { N = 20 };
const int N = 20;
int i;
pthread_t tid[N];
for (i = 0; i < N; i++) {
@@ -953,61 +953,13 @@ typedef struct {
} issue69086struct;
static int issue690861(issue69086struct* p) { p->b = 1234; return p->c; }
static int issue690862(unsigned long ul1, unsigned long ul2, unsigned int u, issue69086struct s) { return (int)(s.b); }
char issue75751v = 1;
char * const issue75751p = &issue75751v;
#define issue75751m issue75751p
char * const volatile issue75751p2 = &issue75751v;
#define issue75751m2 issue75751p2
typedef struct { void *t; void *v; } GoInterface;
extern int exportAny76340Param(GoInterface);
extern GoInterface exportAny76340Return(int);
int issue76340testFromC(GoInterface obj) {
return exportAny76340Param(obj);
}
GoInterface issue76340returnFromC(int val) {
return exportAny76340Return(val);
}
static void enableDIT() {
#ifdef __arm64__
__asm__ __volatile__("msr dit, #1");
#endif
}
static void disableDIT() {
#ifdef __arm64__
__asm__ __volatile__("msr dit, #0");
#endif
}
extern uint8_t ditCallback();
static uint8_t ditCallbackTest() {
return ditCallback();
}
static void ditCallbackEnableDIT() {
enableDIT();
ditCallback();
}
static void ditCallbackDisableDIT() {
disableDIT();
ditCallback();
}
*/
import "C"
import (
"context"
"crypto/subtle"
"fmt"
"internal/asan"
"internal/runtime/sys"
"math"
"math/rand"
"os"
@@ -1144,15 +1096,8 @@ func testErrno(t *testing.T) {
}
func testMultipleAssign(t *testing.T) {
if runtime.GOOS == "windows" && usesUCRT(t) {
// UCRT's strtol throws an unrecoverable crash when
// using an invalid base (that is, not 0 or 2..36).
// See go.dev/issue/62887.
t.Skip("skipping test on Windows when linking with UCRT")
}
p := C.CString("234")
n, m := C.strtol(p, nil, 345), C.strtol(p, nil, 10)
defer C.free(unsafe.Pointer(p))
if runtime.GOOS == "openbsd" {
// Bug in OpenBSD strtol(3) - base > 36 succeeds.
if (n != 0 && n != 239089) || m != 234 {
@@ -1161,6 +1106,7 @@ func testMultipleAssign(t *testing.T) {
} else if n != 0 || m != 234 {
t.Fatal("Strtol x2: ", n, m)
}
C.free(unsafe.Pointer(p))
}
var (
@@ -1686,9 +1632,7 @@ func testNaming(t *testing.T) {
func test6907(t *testing.T) {
want := "yarn"
s := C.Issue6907CopyString(want)
defer C.free(unsafe.Pointer(s))
if got := C.GoString(s); got != want {
if got := C.GoString(C.Issue6907CopyString(want)); got != want {
t.Errorf("C.GoString(C.Issue6907CopyString(%q)) == %q, want %q", want, got, want)
}
}
@@ -1937,7 +1881,6 @@ func test17537(t *testing.T) {
}
p := (*C.char)(C.malloc(1))
defer C.free(unsafe.Pointer(p))
*p = 17
if got, want := C.F17537(&p), C.int(17); got != want {
t.Errorf("got %d, want %d", got, want)
@@ -2444,100 +2387,3 @@ func test69086(t *testing.T) {
t.Errorf("call: got %d, want 1234", got)
}
}
// Issue 75751: no runtime test, just make sure it compiles.
func test75751() int {
return int(*C.issue75751m) + int(*C.issue75751m2)
}
// Issue 76340.
func test76340(t *testing.T) {
var emptyInterface C.GoInterface
r1 := C.issue76340testFromC(emptyInterface)
if r1 != 0 {
t.Errorf("issue76340testFromC with nil interface: got %d, want 0", r1)
}
r2 := C.issue76340returnFromC(42)
if r2.t == nil && r2.v == nil {
t.Error("issue76340returnFromC(42) returned nil interface")
}
r3 := C.issue76340returnFromC(0)
if r3.t != nil || r3.v != nil {
t.Errorf("issue76340returnFromC(0) returned non-nil interface: got %v, want nil", r3)
}
}
func testDITCgo(t *testing.T) {
if !sys.DITSupported {
t.Skip("CPU does not support DIT")
}
ditAlreadyEnabled := sys.DITEnabled()
C.enableDIT()
if ditAlreadyEnabled != sys.DITEnabled() {
t.Fatalf("DIT state not preserved across cgo call: before %t, after %t", ditAlreadyEnabled, sys.DITEnabled())
}
subtle.WithDataIndependentTiming(func() {
C.disableDIT()
if !sys.DITEnabled() {
t.Fatal("DIT disabled after disabling in cgo call")
}
})
}
func testDITCgoCallback(t *testing.T) {
if !sys.DITSupported {
t.Skip("CPU does not support DIT")
}
ditAlreadyEnabled := sys.DITEnabled()
subtle.WithDataIndependentTiming(func() {
if C.ditCallbackTest() != 1 {
t.Fatal("DIT not enabled in cgo callback within WithDataIndependentTiming")
}
})
if ditAlreadyEnabled != sys.DITEnabled() {
t.Fatalf("DIT state not preserved across cgo callback: before %t, after %t", ditAlreadyEnabled, sys.DITEnabled())
}
}
func testDITCgoCallbackEnableDIT(t *testing.T) {
if !sys.DITSupported {
t.Skip("CPU does not support DIT")
}
ditAlreadyEnabled := sys.DITEnabled()
C.ditCallbackEnableDIT()
if ditAlreadyEnabled != sys.DITEnabled() {
t.Fatalf("DIT state not preserved across cgo callback: before %t, after %t", ditAlreadyEnabled, sys.DITEnabled())
}
}
func testDITCgoCallbackDisableDIT(t *testing.T) {
if !sys.DITSupported {
t.Skip("CPU does not support DIT")
}
ditAlreadyEnabled := sys.DITEnabled()
subtle.WithDataIndependentTiming(func() {
C.ditCallbackDisableDIT()
if !sys.DITEnabled() {
t.Fatal("DIT disabled after disabling in cgo call")
}
})
if ditAlreadyEnabled != sys.DITEnabled() {
t.Fatalf("DIT state not preserved across cgo callback: before %t, after %t", ditAlreadyEnabled, sys.DITEnabled())
}
}

View File

@@ -6,13 +6,6 @@
package cgotest
import (
"syscall"
"testing"
)
import "syscall"
var syscall_dot_SIGCHLD = syscall.SIGCHLD
func usesUCRT(t *testing.T) bool {
return false
}

Some files were not shown because too many files have changed in this diff Show More