1
0
mirror of https://github.com/golang/go synced 2024-11-05 17:36:15 -07:00
Commit Graph

43620 Commits

Author SHA1 Message Date
Than McIntosh
0722a49b37 [dev.link] cmd/link: remove elf sym fields from sym.Symbol
Remove the "ElfSym" and "LocalElfSym" fields from sym.Symbol,
replacing uses with loader method calls as needed.

Change-Id: I3828f13203ece2bdc03eeb09ab37a5c94e21a726
Reviewed-on: https://go-review.googlesource.com/c/go/+/230462
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-28 19:04:47 +00:00
Than McIntosh
3f408fc7fd [dev.link] cmd/link: remove Unit field from sym.Symbol
Remove sym.Symbol 'Unit' field, replacing accesses to the field with
calls into the loader instead.

Change-Id: Ia1abd4c3d93036705dd624a49cb3d9cbe6a5188b
Reviewed-on: https://go-review.googlesource.com/c/go/+/230307
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-28 18:59:09 +00:00
Than McIntosh
12b11f3af9 [dev.link] cmd/link/internal/loader: add elf symbol methods
Add new get/set methods to the loader for recording the ELF symbol
index for a given loader symbol. These are map-based, since it is
expected that many/most symbols will not need an ELF symbol table
entry.

Change-Id: I1102c3637775515ccc6650118e8b059468a2c3ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/230461
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-28 18:57:48 +00:00
Than McIntosh
183d25d996 [dev.link] cmd/link/internal/sym: remove SortSub
Remove SortSub; this function no longer referenced.

Change-Id: Ie0c78f5cd048a8f465f84ceeab30db57be5c05a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/230457
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-28 18:57:33 +00:00
Than McIntosh
43a85a39bf [dev.link] cmd/link: remove Gotype and File fields from sym.Symbol
Remove the 'Gotype' field from sym.Symbol, as it is now no longer
used. Store the loader.Sym for a symbol as a field in sym.Symbol
("SymIdx"). Then remove sym.Symbol 'File' field, and replace the field
accesses in question with calls into the loader instead.

Change-Id: I01c5504425006b8d3fe77fac2b69a86e198c7a5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/230304
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-28 18:54:37 +00:00
Than McIntosh
0612e78f0f [dev.link] cmd/link: tweak genasmsym to eliminate Gotype ref
None of the users of genasmsym are doing anything with the Gotype
field of sym.Symbol, so remove that param from the callback function.

Change-Id: Ie902c4cdbcc6b68d353daf5ce21a99012161a946
Reviewed-on: https://go-review.googlesource.com/c/go/+/230545
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-28 18:54:27 +00:00
Cherry Zhang
dd34841de7 [dev.link] cmd/link: write data sections to heap in Asmb on Wasm
Make Wasm more like other architectures, writing data sections to
heap in Asmb instead of Asmb2. Then we can remove the
copy-on-write logic in applying relocations.

Change-Id: I26d5315ea9fba032fe4bdb9b5c7fe483611c4373
Reviewed-on: https://go-review.googlesource.com/c/go/+/230465
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-28 18:36:45 +00:00
Cherry Zhang
3e8975172f [dev.link] cmd/link: convert dwarfcompress to using the loader
Change-Id: I34f806b54e8e0985a30ef38ea4324352aabfc845
Reviewed-on: https://go-review.googlesource.com/c/go/+/229995
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-28 18:36:18 +00:00
Jeremy Faller
dc83274c95 [dev.link] cmd/link: move wavefront past address
This change is just the mechanical work of moving the wavefront past
address.

Change-Id: I519ec49fa8ba50760c7d23fc084fcd3bb0544546
Reviewed-on: https://go-review.googlesource.com/c/go/+/229700
Run-TryBot: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-28 16:04:30 +00:00
Cherry Zhang
b85a03ccc2 Revert "[dev.link] cmd/link: stop overwriting symbol types in loadlibfull"
This reverts CL 229994.

Reason for revert: break AIX build.

This is nice to have but isn't critical. We can revisit later.

Change-Id: Ifc56a0a4c0fb36859cf7666ab149e25e0e5d4cc0
Reviewed-on: https://go-review.googlesource.com/c/go/+/230459
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-28 14:15:26 +00:00
Cherry Zhang
8e7ddac52d [dev.link] cmd/link: fix accidental shadowing
ctxt.Tlsg2 is supposed to be the embedded ArchSyms.Tlsg2.

Change-Id: I4f9711f83999d4a98bcf6d99c24fab756c580905
Reviewed-on: https://go-review.googlesource.com/c/go/+/230379
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-28 14:06:52 +00:00
Cherry Zhang
b6df7e555e [dev.link] cmd/link: stop overwriting symbol types in loadlibfull
symGroupType was needed for dodata. Now that we have converted
dodata to using the loader, stop overwriting it.

Change-Id: Ie94109c0b35dd2f71a19ebb38f8cf20b6a37c624
Reviewed-on: https://go-review.googlesource.com/c/go/+/229994
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-27 21:18:16 +00:00
Cherry Zhang
98e3fdab3e [dev.link] cmd/link: delete old dodata
Change-Id: I569bbee235630baad3c35ca0c6598b8bd059307a
Reviewed-on: https://go-review.googlesource.com/c/go/+/230311
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-27 21:18:02 +00:00
Cherry Zhang
82f633a8e9 [dev.link] cmd/link: accept more types in Xcoffadddynrel
In dodata we overwrite symbol types to SDATA. Now we'll stop
doing that, so accept more symbol types here. This is basically
a list of all writeable types handled in dodata that could appear
in XCOFF.

Change-Id: Iee35369162f5acd59806a3f0e6c8d3682620067e
Reviewed-on: https://go-review.googlesource.com/c/go/+/230310
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-27 20:46:04 +00:00
Than McIntosh
8bd7c01417 [dev.link] cmd/link: support new dodata for PPC64
Add linux/{ppc64,ppc64le} and aix/ppc64 arch support for the new
dodata() phase.

This completes the picture in terms of architecture support for the
new dodata(), but to be safe this patch leaves the command line flag
in place there are problems on the builders (especially given that we
have a dead aix-ppc64 builder).

Change-Id: I78da615c3b540d8925ed7b3226e199280eb7451d
Reviewed-on: https://go-review.googlesource.com/c/go/+/229983
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-27 17:31:07 +00:00
Cherry Zhang
a742d0ed5f [dev.link] cmd/link: remove ctxt.Syms.Allsym
Replace remaining uses with loader.Syms. Reduces some memory
usage.

Change-Id: I6f295b42b8cd734c6c18f08c61a5473506675075
Reviewed-on: https://go-review.googlesource.com/c/go/+/229992
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-27 15:49:37 +00:00
Cherry Zhang
2a874562bf [dev.link] cmd/link: stop setting ReadOnly attribute in late stage
The ReadOnly attribute was used to do copy on write when applying
relocations to symbols with read-only backing stores. Now that we
always apply relocations in the output buffer (mmap or heap), it
is always writeable. No need to tamper with the ReadOnly
attribute anymore.

Wasm is an exception, where we don't copy symbol contents to the
output buffer first. Do copy-on-write there.

This is in preparation of converting reloc to using the loader.

Change-Id: I15e53b7c162b9124e6689dfd8eb45cbe2ffd7153
Reviewed-on: https://go-review.googlesource.com/c/go/+/229991
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-27 15:34:51 +00:00
Cherry Zhang
51ac260e5a [dev.link] cmd/link: always run Asmb before reloc
Currently, we run Asmb before reloc, except on Wasm, where the
order is reversed. However, Asmb is no-op on Wasm. So we can
always run Asmb first.

Change-Id: Ifb8989d8150ebdd5777deb05cbccec16f8e36d82
Reviewed-on: https://go-review.googlesource.com/c/go/+/229990
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-27 15:34:33 +00:00
Cherry Zhang
512a0219ef [dev.link] cmd/link: enable new dodata on darwin/arm64
Change-Id: I6234e7288212e399f766d19fbca675f45c38e12d
Reviewed-on: https://go-review.googlesource.com/c/go/+/230298
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-27 15:31:21 +00:00
Cherry Zhang
aa74fce005 [dev.link] cmd/link: use new dodata on MIPS(64) and RISCV64
They also don't need to do anything for Adddynrel. So we can just
enable it.

Change-Id: If85fceca63a7b3cb5a09e5db224c3018060e86de
Reviewed-on: https://go-review.googlesource.com/c/go/+/229993
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-27 15:31:03 +00:00
Jeremy Faller
5ea431fb63 [dev.link] cmd/link: support Loader in s390x dodata
Recreation of CL 229863 that was removed from the repo because it
included the linker binary.

Change-Id: I5e96afa079b1217df6e7cba63a107546bd96ef76
Reviewed-on: https://go-review.googlesource.com/c/go/+/230028
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-27 14:22:33 +00:00
Cherry Zhang
26d6d07785 [dev.link] cmd/link: remove symbol movement workaround in dodata
It is supposed to work around symbol movement in machosymorder.
But machosymorder doesn't actually move symbols around.

Change-Id: Ibdc2ad41aaa8cd49e865088aa1ddb7ab399736cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/230279
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-27 13:56:20 +00:00
Cherry Zhang
f8b74eafd5 [dev.link] cmd/link: set symbol alignments after dynreloc2
The symbol alignment is set based on its size. In dynreloc2
symbol size may change (e.g. elfdynhash2). So the alignment must
be set after dynreloc2.

Noticed this while debugging nondeterministic build on Solaris.

Idx Name          Size      VMA               LMA               File off  Algn
  8 .hash         000000c8  000000000048add2  000000000048add2  0008add2  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA

This doesn't look right, as the section address is not a multiple
of its alignment.

Change-Id: I23534cbc59695b7bc241838173fcc71dde95b195
Reviewed-on: https://go-review.googlesource.com/c/go/+/230278
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-27 13:56:05 +00:00
Cherry Zhang
e77639f3a4 [dev.link] cmd/link: sort DynidSyms
Sort DynidSyms to ensure a deterministic build.

Fix Solaris build.

Change-Id: I6c01cb3dec5e46b3d881e720e3c2079643b5c7c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/230277
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-27 13:55:35 +00:00
Than McIntosh
d5c9327628 [dev.link] cmd/link: support new dodata for elf/{arm,arm64}
Add elf/ARM arch support for the new dodata() phase.

Change-Id: Iadd772b01036c6c5be95bcc6017f6c05d45a24c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/229868
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-27 13:38:54 +00:00
Cherry Zhang
f9ed846a46 [dev.link] cmd/link: use new dodata on Plan 9 and Wasm
They don't have fancy Adddynrel stuff, so we can just enable it.

Change-Id: I84082c3187d8a9ffa3a9c5458959794df0e3c2b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/230030
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-25 01:21:25 +00:00
Cherry Zhang
b2fde1098a [dev.link] cmd/link: use new dodata on darwin/amd64
This probably breaks darwin/arm64. Will fix.

Change-Id: I8be168985124f971e9d8ab5bc95c303336dd705b
Reviewed-on: https://go-review.googlesource.com/c/go/+/230019
Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-25 01:21:06 +00:00
Cherry Zhang
c7a11099c9 [dev.link] cmd/link: fix buglet in new GCProg generation code
It should check the name of the symbol being added, not the
GC data symbol we're generating.

Change-Id: I123679778ee542b8d1f5c15bf090fa3578025c19
Reviewed-on: https://go-review.googlesource.com/c/go/+/230018
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-25 01:20:55 +00:00
Cherry Zhang
1d083eba5b [dev.link] cmd/link: fix minor error on error reporting
Correctly propagate ... arguments. (Maybe vet should warn on it?)

Reviewed-on: https://go-review.googlesource.com/c/go/+/230017
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>

Change-Id: Ife56dc2321847cdaf0caea3142c2c7dad8b5924d
Reviewed-on: https://go-review.googlesource.com/c/go/+/230027
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-24 22:56:40 +00:00
Than McIntosh
42cca1a7fe [dev.link] cmd/link: create symbol updated lazily in amd64 adddynrel
Tweak the code in the amd64 version of adddynrel to avoid creating a
symbol updated for the symbol being processed until it's clear we need
to alter its relocations. This should help performance for the
PIE+internal linking scenario.

Reviewed-on: https://go-review.googlesource.com/c/go/+/229866
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>

Change-Id: Id25adfd81a5bbd2dde0f80a83b976397ba6abfb5
Reviewed-on: https://go-review.googlesource.com/c/go/+/230026
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-24 22:56:22 +00:00
Cherry Zhang
027055240f [dev.link] cmd/link: check fingerprint for index consistency
Previous CL introduced index fingerprint in the object files.
This CL implements the second part: checking fingerprint
consistency in the linker when packages are loaded.

Change-Id: I05dd4c4045a65adfd95e77b625d6c75a7a70e4f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/229618
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-24 17:48:07 +00:00
Cherry Zhang
e08f10b8b5 [dev.link] cmd/internal/goobj2: add index fingerprint to object file
The new object files use indices for symbol references, instead
of names. Fundamental to the design, it requires that the
importing and imported packages have consistent view of symbol
indices. The Go command should already ensure this, when using
"go build". But in case it goes wrong, it could lead to obscure
errors like run-time crashes. It would be better to check the
index consistency at build time.

To do that, we add a fingerprint to each object file, which is
a hash of symbol indices. In the object file it records the
fingerprints of all imported packages, as well as its own
fingerprint. At link time, the linker checks that a package's
fingerprint matches the fingerprint recorded in the importing
packages, and issue an error if they don't match.

This CL does the first part: introducing the fingerprint in the
object file, and propagating fingerprints through
importing/exporting by the compiler. It is not yet used by the
linker. Next CL will do.

Change-Id: I0aa372da652e4afb11f2867cb71689a3e3f9966e
Reviewed-on: https://go-review.googlesource.com/c/go/+/229617
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-24 17:47:14 +00:00
Cherry Zhang
880ef2da7b [dev.link] cmd/link: panic if HeadType is not set
In the code there are conditions like !ctxt.IsDarwin(). This will
accidentally be true if HeadType is not yet set. Panic when
HeadType is not set, to catch errors.

Change-Id: Ic891123f27f0276fff5a4b5d29e5b1f7ebbb94ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/229869
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-24 17:22:57 +00:00
Cherry Zhang
f2d8da1a35 [dev.link] cmd/link: set HeadType early
So we can use it to set per-OS flags.

Also set flagnewDoData after archinit, where IsELF is set.

This should correct the logic of setting flagnewDoData.

Change-Id: I18c7252f141aa35119005c252becc9d7cb74f2f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/229867
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-24 16:58:37 +00:00
Than McIntosh
f790533d9f [dev.link] cmd/link: support new dodata for elf/386
Add elf/386 arch support for the new dodata() phase.

Change-Id: I78341dfe70a90719d95c0044183980f348a3369f
Reviewed-on: https://go-review.googlesource.com/c/go/+/229797
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-24 15:49:51 +00:00
Cherry Zhang
3b32a44699 [dev.link] cmd/link: remove -a flag
It doesn't do what it says. It has been like that since Go 1.4.
The current ouput is pretty useless. Remove it.

Change-Id: Id9b4ba04139aaf7ea59acbd51428b1c992115389
Reviewed-on: https://go-review.googlesource.com/c/go/+/229859
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-24 14:50:46 +00:00
Than McIntosh
941de9760b [dev.link] cmd/link: begin converting dodata() to loader APIs
This patch begins the work of converting the linker's dodata phase to
work with loader APIs. Passes all.bash on linux/amd64, but hasn't been
tested on anything else (more arch-specific code needs to be written).
Use of the new dodata() phase is currently gated by a temporary
command line flag ("-newdodata"), and there is code in the linker's
main routine to insure that we only use the new version for the right
GOOS/GOARCH (currently restricted to ELF + AMD64).

Change-Id: Ied3966677d2a450bc3e0990e0f519b3fceaab806
Reviewed-on: https://go-review.googlesource.com/c/go/+/229706
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-24 14:09:38 +00:00
Than McIntosh
3d1007d28e [dev.link] cmd/link: move more error handling into loader
Move the guts of ctxt.Errorf into loader.Loader, so that we can make
calls to it from functions that have a "*loader.Loader" available but
not a "ctxt *Link". This is needed to start converting hooks like
"adddynrel" in the arch-specific portions of the linker to use loader
APIs.

Change-Id: Ieedd4583b66504be0e77d7f3fbadafe0d2307a69
Reviewed-on: https://go-review.googlesource.com/c/go/+/229497
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-24 13:41:49 +00:00
Than McIntosh
442fd182fb [dev.link] cmd/link/internal/loader: add SetRelocType symbolbuilder method
Clients may need to invoke the loader.Reloc2.SetType method to reset
the type of a relocation from external flavor to internal flavor,
meaning that the external type add-in needs to be zeroed (this is
needed when adding dynsym entries).

Add a new SymbolBuider method to support mutating the type of a reloc
for an external symbol, so that the external type can be changed as
well (Reloc2 doesn't have access to that). Also add similar methods
for updating target symbol and addend, so as to have a consistent
interface for ext reloc mutation.

Change-Id: I8e26cdae0a0f353019acba5f9c8a0506e3970266
Reviewed-on: https://go-review.googlesource.com/c/go/+/229604
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-24 13:41:32 +00:00
Than McIntosh
adea6a90e3 [dev.link] cmd/link/internal/loader: fix buglet in section handling
Allow for the possibility that a client could call newExtSym(), then
ask for the section of the new sym before SetSectSym is called on it
(check in SymSect for this case).

Change-Id: I7bd78e7b3b7618943705b616f62ea78c4a1b68d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/229603
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-24 13:41:20 +00:00
Cherry Zhang
67bf856b96 [dev.link] all: merge branch 'master' into dev.link
Change-Id: Ia6426e8494244fde7e81a7c932c8e3c865676d3d
2020-04-23 11:47:20 -04:00
Cherry Zhang
dee3e3aebd [dev.link] cmd/link: clean up some tests
Use a separate directory for TestBuildFortvOS test files.

Remove a bad comment in TestTrampoline.

Change-Id: I2dc07ae575ec3f73fb7cea26743094b11a41b464
Reviewed-on: https://go-review.googlesource.com/c/go/+/229619
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-23 15:31:01 +00:00
Johan Jansson
c8dea8198e cmd/go: allow generate to process invalid packages
Allow go generate to process packages that contain invalid code. Ignore
errors when loading the package, but process only files which have a
valid package clause. Set $GOPACKAGE individually for each file, based
on the package clause.

Add test script for go generate and invalid packages.

Fixes #36422

Change-Id: I91ea088346a1548ccd6678b4595a527b948331ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/229097
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-23 15:19:53 +00:00
Josh Bleecher Snyder
e354309e1e cmd/compile: add ssa.Block.truncateValues
It is a common operation.

Passes toolstash-check.

Change-Id: Icc34600b0f79d0ecb19f257e3c7f23b6f01a26ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/229599
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-23 14:59:55 +00:00
Josh Bleecher Snyder
806318d6ad cmd/compile: simplify zcse
Minor refactoring.

Passes toolstash-check.

Change-Id: I91e981bf369d4b719163107644fa58f583356c25
Reviewed-on: https://go-review.googlesource.com/c/go/+/229598
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-23 14:59:41 +00:00
witchard
708ac9aacb cmd/go/internal/modget: improve GOINSECURE docs
Recommend use of GOINSECURE over -insecure flang and clarify that GOINSECURE
environment variable does not also imply GONOSUMDB.

Updates #37519 by adding documentation as discussed.

Change-Id: Ia8ab6b3ed1aa559343b72e4ca76c372ee6bf1941
GitHub-Last-Rev: 8d86991f0c
GitHub-Pull-Request: golang/go#38572
Reviewed-on: https://go-review.googlesource.com/c/go/+/229223
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-23 13:46:00 +00:00
Cuong Manh Le
e43239aabe cmd/compile: pre-alloc enough room for Escape.walkAll
Slightly reduce allocs, passes toolstash-check.

name          old time/op       new time/op       delta
Template            181ms ± 4%        174ms ± 0%  -3.59%  (p=0.008 n=5+5)

name          old user-time/op  new user-time/op  delta
Template            249ms ± 3%        240ms ± 2%  -3.59%  (p=0.016 n=5+5)

name          old alloc/op      new alloc/op      delta
Template           35.0MB ± 0%       34.9MB ± 0%  -0.09%  (p=0.008 n=5+5)
Unicode            28.6MB ± 0%       28.6MB ± 0%    ~     (p=0.421 n=5+5)
GoTypes             114MB ± 0%        114MB ± 0%  -0.10%  (p=0.008 n=5+5)
Compiler            542MB ± 0%        541MB ± 0%  -0.13%  (p=0.008 n=5+5)
SSA                1.21GB ± 0%       1.21GB ± 0%  -0.10%  (p=0.008 n=5+5)
Flate              22.0MB ± 0%       22.0MB ± 0%  -0.05%  (p=0.016 n=5+5)
GoParser           27.1MB ± 0%       27.0MB ± 0%  -0.05%  (p=0.008 n=5+5)
Reflect            74.8MB ± 0%       74.8MB ± 0%  -0.11%  (p=0.008 n=5+5)
Tar                33.0MB ± 0%       32.9MB ± 0%  -0.07%  (p=0.008 n=5+5)
XML                42.1MB ± 0%       42.1MB ± 0%  -0.07%  (p=0.008 n=5+5)
LinkCompiler        222MB ± 0%        222MB ± 0%    ~     (p=0.690 n=5+5)
[Geo mean]         81.3MB            81.2MB       -0.07%

name          old allocs/op     new allocs/op     delta
Template             347k ± 0%         347k ± 0%  -0.16%  (p=0.008 n=5+5)
Unicode              334k ± 0%         334k ± 0%  -0.03%  (p=0.016 n=5+5)
GoTypes             1.20M ± 0%        1.20M ± 0%  -0.12%  (p=0.008 n=5+5)
Compiler            5.13M ± 0%        5.12M ± 0%  -0.11%  (p=0.008 n=5+5)
SSA                 11.7M ± 0%        11.7M ± 0%  -0.13%  (p=0.008 n=5+5)
Flate                221k ± 0%         221k ± 0%  -0.18%  (p=0.008 n=5+5)
GoParser             280k ± 0%         280k ± 0%  -0.06%  (p=0.008 n=5+5)
Reflect              902k ± 0%         900k ± 0%  -0.28%  (p=0.008 n=5+5)
Tar                  323k ± 0%         322k ± 0%  -0.18%  (p=0.008 n=5+5)
XML                  401k ± 0%         401k ± 0%  -0.10%  (p=0.008 n=5+5)
LinkCompiler         735k ± 0%         735k ± 0%    ~     (p=0.841 n=5+5)
[Geo mean]           753k              752k       -0.12%

Change-Id: I647bd7752f28b74e6f400fa16cb69632f5c952b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/229517
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-04-23 07:33:21 +00:00
Matthew Dempsky
9f4dd09bf5 cmd/compile: refactor variadac call desugaring
In mid-Walk, we rewrite calls to variadic functions to use explicit
slice literals; e.g., rewriting f(a,b,c) into f([]T{a,b,c}...).
However, it would be useful to do that rewrite much earlier in the
compiler, so that other compiler passes can be simplified.

This CL refactors the rewrite logic into a new fixVariadicCall
function, which subsequent CLs can more easily move into earlier
compiler passes.

Passes toolstash-check -race.

Change-Id: I408e655f2d3aa00446a2e6accf8765abc3b16a8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/229486
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2020-04-23 06:24:40 +00:00
Andrei Tudor Călin
952f7de3b4 testing: make TempDir work for subtests
ioutil.TempDir doesn't like path separators in its pattern. Modify
(*common).TempDir to replace path separators with underscores before
using the test name as a pattern for ioutil.TempDir.

Fixes #38465.

Change-Id: I9e8ae48b99648b2bf9f561762e845165aff01972
Reviewed-on: https://go-review.googlesource.com/c/go/+/229399
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-23 01:34:16 +00:00
Matthew Dempsky
f049d911e9 cmd/compile: be stricter about recognizing safety rule #4
unsafe.Pointer safety rule #4 says "The compiler handles a Pointer
converted to a uintptr in the argument list of a call". Within escape
analysis, we've always required this be a single conversion
unsafe.Pointer->uintptr conversion, but the corresponding logic in
order is somewhat laxer, allowing arbitrary chains of OCONVNOPs from
unsafe.Pointer to uintptr.

This CL changes order to be stricter to match escape analysis.

Passes toolstash-check.

Change-Id: Iadd210d2123accb2020f5728ea2a47814f703352
Reviewed-on: https://go-review.googlesource.com/c/go/+/229578
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-23 00:08:35 +00:00