Due to some recent optimizations related to the compare
instruction, DS-form load instructions started to be used
to load 8-byte go.strings. This can cause link time errors
if the go.string is not aligned to 4 bytes.
For DS-form instructions, the value in the offset field must
be a multiple of 4. If the offset is known at the time the
rules are processed, a DS-form load will not be chosen. But for
go.strings, the offset is not known at that time, but a
relocation is generated indicating that the linker should fill
in the DS relocation. When the linker tries to fill in the
relocation, if the offset is not aligned properly, a link error
will occur.
To fix this, when loading a go.string using MOVDload, the full
address of the go.string is generated and loaded into the base
register. Then the go.string is loaded with a 0 offset field.
Added a testcase that reproduces this problem.
Fixes#24799
Change-Id: I6a154e8e1cba64eae290be0fbcb608b75884ecdd
Reviewed-on: https://go-review.googlesource.com/107855
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Current assembler encodes "ADD $0xaaaaaaaa, Rx" to "MOVD off(PC), Rtmp"
+ "ADD Rtmp, Rx", and a 64-bit item is stored in the constant pool.
This patch optimizes it to "MOVWU off(PC), Rtmp" + "ADD Rtmp, Rx",
and a 32-bit item is stored.
The total size of the executable binary go and the library files in
pkg/linux_arm64 decreased about 3KB by this patch.
Change-Id: Ieb1592f78ef9ed52f5d3ad232d6cdf87d0923de1
Reviewed-on: https://go-review.googlesource.com/107516
Reviewed-by: Wei Xiao <Wei.Xiao@arm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
The patch rewrites the content of doc.go file. The file describes some
general rules of the mapping between Go assembly syntax and GNU syntax.
And it gives some Go assembly examples and corresponding GNU assembly
examples.
The patch changes the doc.go to use standard doc comment format so that
the link https://golang.org/cmd/internal/obj/arm64/ can display it.
Assembly document framework is mainly contributed by Eric Fang <Eric.Fang@arm.com>
Documentation work is contributed by Eric Fang and Fannie Zhang <Fannie.Zhang@arm.com>
Change-Id: I8b3f6d6c6b91afdc2c44602e8f796beea905085e
Reviewed-on: https://go-review.googlesource.com/102055
Reviewed-by: Rob Pike <r@golang.org>
There are a bunch of places where we generate functions: equality and
hash functions; method expression and promoted method wrappers; and
print/delete wrappers for defer/go statements.
This CL brings them in sync by:
1) Always using dclfunc and funcbody. Most were already using this,
but makepartialcall needed some changes.
2) Removing duplicate types.Markdcl/types.Popdcl calls. These are
already handled by dclfunc and funcbody.
3) Using structargs (already used by genwrapper) to construct new
param/result lists from existing types.
4) Always accessing the parameter ONAME nodes through Field.Nname
instead of poking into the ODCLFIELD. Also, since creating a slice of
the entire parameter list is common, extract this out into a
paramNnames helper function.
5) Add a Type.IsVariadic method to simplify identifying variadic
function types.
Passes toolstash-check -gcflags=-dwarf=false. DWARF output changes
because using structargs in makepartialcall changes the generated
parameter names.
Change-Id: I6661d3699afdbe7852ad60db5a4ec6eeb2b696e4
Reviewed-on: https://go-review.googlesource.com/108216
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
On Unix systems, the underlying socket is no longer forced into blocking
mode.
Fixes#24942
Change-Id: I3e0c503c72df0844e30a63af298691dedacd1f46
Reviewed-on: https://go-review.googlesource.com/108297
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
By simply rearranging the logic, we avoid the overhead of a superfluous
call to getsockopt. For, if p is already non empty, there's no point
in having to check if we need to attach dummy payload. This has
performance benefits when using send/recvmsg for high speed
communications.
Change-Id: Id85cff17328ecbf6d09dd52fbeeaa691dbe69b75
Reviewed-on: https://go-review.googlesource.com/108338
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This is to allow followup refactorings that will replace
Field.Nname.Pos with Field.Pos.
Passes toolstash-check.
Change-Id: I1060b6a37c60273892f7af5369809057cff61881
Reviewed-on: https://go-review.googlesource.com/108215
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Fixes golint warning about "if block ends with a return statement,
so drop this else and outdent its block".
Change-Id: Iac4fd324e04e3e3fe3e3933f5e59095041d292c5
Reviewed-on: https://go-review.googlesource.com/107115
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Fixes#23373
Fix interfacing with latest(1.4+) pkgconf versions, as they have change the
output format, by extending parsing function splitPkgConfigOutput to accommodate
more possible fragment escaping formats. Function is based on pkgconfigs own
implementation at
https://github.com/pkgconf/pkgconf/blob/master/libpkgconf/argvsplit.c. Along
with this change test case TestSplitPkgConfigOutput have been expanded. Thanks
to ignatenko for help on test cases and insights in to the pkgconfig.
Change-Id: I55301bb564b07128d5564ec1454dd247f84a95c3
Reviewed-on: https://go-review.googlesource.com/86541
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
CL 99337 introduced a file with CRLF line endings. Convert them to LF
line endings as in all other Go files.
Change-Id: I68b28fd443f05bebbbd9280d1821c4ccd33a4a8a
Reviewed-on: https://go-review.googlesource.com/108075
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Make comment example consistent with its description.
Fixes#24767
Change-Id: Icff54b489040b1ce66c644a21343c6576304cf75
Reviewed-on: https://go-review.googlesource.com/107663
Reviewed-by: Rob Pike <r@golang.org>
Previously these examples declared "var v Value" but any caller would
need to write "var v atomic.Value", so we should use the external
package declaration form to avoid confusion about where Value comes
from.
Change-Id: Ic0b1a05fb6b700da61cfc8efca594c49a9bedb69
Reviewed-on: https://go-review.googlesource.com/107975
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Use AT_TIMEKEEP ELF aux entry to access a kernel mapped ring of timehands structs.
The timehands are updated by the kernel periodically, but for accurate measure the
timecounter still needs to be queried.
Currently the fast path is used only when kern.timecounter.hardware==TSC-low
or kern.timecounter.hardware=='ARM MPCore Timecounter',
other timecounters revert back to regular system call.
TODO: add support for HPET timecounter on 386/amd64.
Change-Id: I321ca4e92be63ba21a2574b758ef5c1e729086ad
Reviewed-on: https://go-review.googlesource.com/93156
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
The current code encodes the register and the shift/extension into a.Offset
field and this is done in the frontend. The CL refactors it to have the
frontend record the register/shift/extension information in a.Reg or a.Index
and leave the encoding stuff for the backend.
Change-Id: I600f456aec95377b7b79cd58e94afcb30aca5d19
Reviewed-on: https://go-review.googlesource.com/106815
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Disasm.Decode currently always appends a tab to the formatted instruction,
although not to any relocations after it.
Decode has two clients: objdump and pprof.
pprof emits plain text, so it would be better not to have a trailing tab.
objdump wants the trailing tab for text/tabwriter,
but it is easy to add that to the Fprintf call.
Shifting the responsibility for the trailing tab to the caller
simplifies the code, increases correctness, and slightly improves
performance by reducing and coalescing string concatenations.
Change-Id: I0c85518ee185949e385de819e2e703bce757eba9
Reviewed-on: https://go-review.googlesource.com/106983
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
VDSO calls do manual stack alignment, which doesn't get tracked in the
pcsp table. Without accurate pcsp information, backtracing them is
dangerous, and causes a crash in the SIGPROF handler. Fortunately,
https://golang.org/cl/97315 saves a clean state in m.vdsoPC/SP. Change
to use those if they're present, without attempting a normal backtrace.
Fixes#24925
Change-Id: I4b8501ae73a9d18209e22f839773c4fe6102a509
Reviewed-on: https://go-review.googlesource.com/107778
Run-TryBot: Heschi Kreinick <heschi@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Based on the code from https://github.com/riscv/riscv-go/ originally
written by Amol Bhave.
Change-Id: I8d5377096d4ff8b198dadb630511f9a0347f9797
Reviewed-on: https://go-review.googlesource.com/107339
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
There are no strange messages anymore, so define type MyBuffer in the
block where it is used.
Change-Id: Ic65b15dc76a40f6f734d9ac2116338502fbb66fd
Reviewed-on: https://go-review.googlesource.com/107735
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Some syscall structures used by crypto/x509 have uintptr
fields that store pointers. These pointers are set with
a pointer to another Go structure. But the pointers are
not visible by garbage collector, and GC does not update
the fields after they were set. So when structure with
invalid uintptr pointers passed to Windows, we get
memory corruption.
This CL introduces CertInfo, CertTrustListInfo and
CertRevocationCrlInfo types. It uses pointers to new types
instead of uintptr in CertContext, CertSimpleChain and
CertRevocationInfo.
CertRevocationInfo, CertChainPolicyPara and
CertChainPolicyStatus types have uintptr field that can
be pointer to many different things (according to Windows
API). So this CL introduces Pointer type to be used for
those cases.
As suggested by Austin Clements.
Fixes#21376
Updates #24820
Change-Id: If95cd9eee3c69e4cfc35b7b25b1b40c2dc8f0df7
Reviewed-on: https://go-review.googlesource.com/106275
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
The escape analysis models the flow of "content" of X with a
level of "indirection" (OIND node) of X. This content can be
pointer dereference, or slice/string element. For the latter
case, the type of the OIND node should be the element type of
the slice/string. This CL fixes this. In particular, this
matters when the element type is pointerless, where the data
flow should not cause any escape.
Fixes#15730.
Change-Id: Iba9f92898681625e7e3ddef76ae65d7cd61c41e0
Reviewed-on: https://go-review.googlesource.com/107597
Reviewed-by: David Chase <drchase@google.com>
Use bio.Reader. Include newline character in the expected string value
instead of truncating it. Get rid of weird "empty archive" check.
Passes toolstash-check.
Change-Id: I16e42542db4827e6ee3644b9a5540a4a30b9bc41
Reviewed-on: https://go-review.googlesource.com/107620
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
The documentation for %v behavior for compound objects uses an ellipsis
to indicate indefinite lenght of elements. This is done for struct
fields as well as elements of arrays and slices. This adds the missing
ellipsis for maps.
Change-Id: Ia433387fe189d2daf5095df32085a541458f00a1
Reviewed-on: https://go-review.googlesource.com/107623
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
These fake imports are just so we can emit build dependencies for the
linker, so the package name isn't really necessary. Also, the package
import logic assumes that if we have the name for a package, then
we've already read some package data for it.
Using the empty string allows the importers to correctly populate it
the first time these packages are seen in package export data.
Passes toolstash-check.
Change-Id: I047bde297600e9dc07478fccc3f57ccc75ce8ae4
Reviewed-on: https://go-review.googlesource.com/107619
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This is already written out by printObjHeader in obj.go.
Change-Id: I23e7a3826a6233307bd591021718c4cf143b381c
Reviewed-on: https://go-review.googlesource.com/107618
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This code will be useful for the indexed format importer, so break it
out to be easier to reuse separately.
Change-Id: Ie7e6b2ed89770e1ed9aa1edf11682fe35d6bb373
Reviewed-on: https://go-review.googlesource.com/107617
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
cmd/compile internally rewrites blank return parameters to "~bN". Add
a test to make sure this isn't exposed via the go/types API.
Change-Id: I319644dc5adf483ed30520fd8e9d88cf5cea9751
Reviewed-on: https://go-review.googlesource.com/107616
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Fixes#18037
Change-Id: I20e27bcc013b00b726eb348daf5ca86b138ddcc2
Reviewed-on: https://go-review.googlesource.com/107598
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
CL 106735 changed to the new softfloat support on GOARM=5.
ARM assembly code that uses FP instructions not guarded on GOARM,
if any, will break. The easiest way to fix is probably to use Go
implementation on GOARM=5, like
MOVB runtime·goarm(SB), R11
CMP $5, R11
BEQ arm5
... FP instructions ...
RET
arm5:
CALL or JMP to Go implementation
Change-Id: I52fc76fac9c854ebe7c6c856c365fba35d3f560a
Reviewed-on: https://go-review.googlesource.com/107475
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
cmd/link produces ELF executables on all these geese, so enable
TestNoSectionOverlaps for them as well. Also add a skip message.
Change-Id: I374651dde3679271ef8c0c375c9cabd1adbca310
Reviewed-on: https://go-review.googlesource.com/107535
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This reverts commit 49e3e436e7.
Reason for revert: breaks iOS builders and Daniel can't fix for a week.
Change-Id: Ib6ff08de9540d46345dc31e1f820c8555e3de3ca
Reviewed-on: https://go-review.googlesource.com/107218
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
In the Scan functions documentation, clarify that for float/complex
literals in scientific notation both decimal (e) and binary (p)
exponents are accepted.
Fixes#24453
Change-Id: Ic6dcdb0c36e088ffb65177038aff7a57ab56b805
Reviewed-on: https://go-review.googlesource.com/107416
Reviewed-by: Rob Pike <r@golang.org>
The use of binary was incorrect as executable files can also be scripts.
The docs for Error are also reworded. The old docs implied that Error was
returned when attempting to start an executable, which is not correct: it
was returned by LookPath when the file was not found or did not have the
attributes of an executable.
Change-Id: I757a44b16612936df4498b43c45c12e4c14956d2
Reviewed-on: https://go-review.googlesource.com/90315
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
When a test calls t.Fatal()/t.Fatalf(), only deferred code will execute.
Increment the failure count as part of a deferred call.
Fixes#24412
Change-Id: Ibb154015fcd3d0fb7739718fdda8c9ad22f9e896
Reviewed-on: https://go-review.googlesource.com/101035
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
One might try to implement the Mod or Remainder function with the expression
x - TRUNC(x/y + 0.5)*y, but in fact this method is wrong, because the rounding
of (x/y + 0.5) to initialize the argument of TRUNC may lose too much precision.
However, the current test cases can not detect this error. This CL adds two
test cases to prevent people from continuing to do such attempts.
Change-Id: I6690f5cffb21bf8ae06a314b7a45cafff8bcee13
Reviewed-on: https://go-review.googlesource.com/84275
Reviewed-by: Robert Griesemer <gri@golang.org>
Made constant names more idiomatic,
moved some constants to function seedrand,
and found better name for _M.
Change-Id: I192172f398378bef486a5bbceb6ba86af48ebcc9
Reviewed-on: https://go-review.googlesource.com/107135
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>